diff --git a/agent-ops/rules/project/rules.md b/agent-ops/rules/project/rules.md index aa90f2e..8dc37ae 100644 --- a/agent-ops/rules/project/rules.md +++ b/agent-ops/rules/project/rules.md @@ -46,6 +46,7 @@ - Dart/Flutter 코드 변경 후 기본 검증은 `flutter analyze`와 `flutter test`로 한다. - macOS platform 파일 변경은 macOS host에서 `flutter run -d macos` 또는 `flutter build macos` 확인이 필요하다. - local 테스트 환경의 기본 evidence는 standard remote Mac runner `toki@toki-labs.com` 기준으로 판단한다. 기본 checkout은 `$HOME/docker/services/code-server/data/volume/workspace/appsok`이다. +- Flutter web preview가 필요한 경우 workspace project-owned slot `13050`을 사용한다. 일반 Flutter unit/analyze/macOS build 검증은 public port를 사용하지 않는다. - 현재 Linux/container checkout에서의 `git diff --check`, `flutter analyze`, `flutter test`는 편집 직후 preflight로 사용할 수 있지만, Flutter/macOS/ADB/runtime evidence가 필요한 완료 검증은 remote runner에서 수행한다. - 2026-06-08 조회 기준 remote runner에는 Flutter, Xcode 26.0.1, Android SDK/ADB, macOS desktop device, Android emulator, valid codesigning identity가 있다. Notary credential profile은 확인되지 않았으므로 notarization 가능으로 단정하지 않는다. - SSH password, Jenkins credential, signing key, notary credential 원문은 tracked 파일, task log, 최종 응답에 기록하지 않는다. diff --git a/agent-roadmap/phase/usable-mvp/PHASE.md b/agent-roadmap/phase/usable-mvp/PHASE.md index e1925ea..f1409c5 100644 --- a/agent-roadmap/phase/usable-mvp/PHASE.md +++ b/agent-roadmap/phase/usable-mvp/PHASE.md @@ -20,7 +20,7 @@ Jenkins에서 Android artifact를 찾고, Mac에 내려받고, USB로 연결된 - [완료] Artifact 탐색과 다운로드 - 경로: `agent-roadmap/archive/phase/usable-mvp/milestones/artifact-browser.md` - 요약: Jenkins job/build/artifact를 조회하고 APK를 Mac에 캐시한다. -- [진행중] Jenkins 로그인과 credential 수명주기 +- [계획] Jenkins 로그인과 credential 수명주기 - 경로: `agent-roadmap/phase/usable-mvp/milestones/jenkins-credential.md` - 요약: 사용자별 Jenkins API token 또는 WebView 기반 token 자동화 흐름을 안전하게 저장/검증한다. - [진행중] USB 설치와 device 선택 diff --git a/agent-roadmap/phase/usable-mvp/milestones/jenkins-credential.md b/agent-roadmap/phase/usable-mvp/milestones/jenkins-credential.md index 5785b08..f1f5f7d 100644 --- a/agent-roadmap/phase/usable-mvp/milestones/jenkins-credential.md +++ b/agent-roadmap/phase/usable-mvp/milestones/jenkins-credential.md @@ -11,7 +11,7 @@ AppSok이 Jenkins에 접근할 수 있는 사용자인지 확인하고, 사용 ## 상태 -[진행중] +[계획] ## 승격 조건 diff --git a/agent-roadmap/phase/usable-mvp/milestones/usb-install.md b/agent-roadmap/phase/usable-mvp/milestones/usb-install.md index d93e245..7a253b6 100644 --- a/agent-roadmap/phase/usable-mvp/milestones/usb-install.md +++ b/agent-roadmap/phase/usable-mvp/milestones/usb-install.md @@ -40,9 +40,9 @@ USB로 연결된 Android device를 표시하고, 선택한 단일 APK를 `adb in 사용자 Mac의 Android Studio, SDK 설치, shell `PATH`에 흔들리지 않는 AppSok-managed ADB runtime을 제공한다. -- [ ] [adb-path] bundled `adb`를 기본 실행 경로로 선택하고, 사용자가 지정한 custom/system `adb`는 명시적 override 또는 fallback으로만 사용한다. +- [x] [adb-path] bundled `adb`를 기본 실행 경로로 선택하고, 사용자가 지정한 custom/system `adb`는 명시적 override 또는 fallback으로만 사용한다. - [ ] [adb-bundle] macOS app bundle에 pin된 최소 ADB subset(`adb`, 필요한 `lib64/*.dylib`, `NOTICE.txt`, `source.properties`)을 포함한다. 검증: remote Mac runner에서 bundled `adb version`과 dylib 의존성 확인이 통과한다. -- [ ] [adb-server] AppSok 전용 ADB server port를 기본으로 사용하고, Android Studio/CLI와 같은 기존 server를 써야 하는 경우 공유 `5037` 모드로 전환할 수 있다. +- [x] [adb-server] AppSok 전용 ADB server port를 기본으로 사용하고, Android Studio/CLI와 같은 기존 server를 써야 하는 경우 공유 `5037` 모드로 전환할 수 있다. - [ ] [adb-diagnostics] ADB 실행 경로, bundled version, runtime hash, server port, fallback 여부를 진단 정보로 표시한다. ### Epic: [device-list] device 탐색 diff --git a/agent-task/m-usb-install/01_adb_bundle/CODE_REVIEW-cloud-G07.md b/agent-task/m-usb-install/01_adb_bundle/CODE_REVIEW-cloud-G07.md new file mode 100644 index 0000000..d271eb5 --- /dev/null +++ b/agent-task/m-usb-install/01_adb_bundle/CODE_REVIEW-cloud-G07.md @@ -0,0 +1,159 @@ + + +# Code Review Reference - API + +> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.** +> The task is NOT complete until every implementation-owned section below is filled in. +> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving. +> Fill implementation-owned sections, then stop with active files in place and report ready for review. +> If implementation is blocked by a user-only decision, user-owned external environment prerequisite, or scope conflict, fill `사용자 리뷰 요청` with evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Evidence gaps that a follow-up agent can close by rerunning commands or collecting artifacts are normal follow-up issues, not user-review blockers by themselves. +> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record the needed decision in `사용자 리뷰 요청` and stop for code-review. +> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume. +> Follow the ownership table at the bottom of this file for which sections you own. + +## 개요 + +date=2026-06-12 +task=m-usb-install/01_adb_bundle, plan=0, tag=API + +## Roadmap Targets + +- Milestone: `agent-roadmap/phase/usable-mvp/milestones/usb-install.md` +- Task ids: + - `adb-bundle`: macOS app bundle에 pin된 최소 ADB subset을 포함한다. +- Completion mode: check-on-pass + +## 이 파일을 읽는 리뷰 에이전트에게 + +> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다. + +각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요. +리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다. + +1. 판정을 append한다. +2. `CODE_REVIEW-cloud-G07.md` → `code_review_cloud_G07_N.log`, `PLAN-cloud-G07.md` → `plan_cloud_G07_M.log`로 아카이브한다. +3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-usb-install/01_adb_bundle/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다. `USER_REVIEW.md`가 사용자 결정으로 완료/PASS 해소되면 code-review가 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log` 작성 후 archive 이동한다. +4. PASS이고 task group이 `m-usb-install`이면 완료 이벤트 메타데이터를 보고한다. roadmap 상태 체크와 `update-roadmap` 호출은 런타임 책임이다. +5. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다. + +--- + +## 구현 항목별 완료 여부 + +| 항목 | 완료 여부 | +|------|---------| +| [API-1] Bundle ADB Runtime | [ ] | + +## 구현 체크리스트 + +- [ ] macOS app bundle에 `Contents/Resources/adb-runtime/`가 생성되도록 pin된 ADB subset copy 방식을 구현한다. +- [ ] bundled `adb version`과 dylib 의존성 확인이 remote Mac runner에서 통과한다. +- [ ] `flutter analyze`, `flutter test`, `flutter build macos`를 remote Mac runner checkout에서 실행한다. +- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. + +## 코드리뷰 전용 체크리스트 + +> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다. +> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다. + +- [ ] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다. +- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다. +- [ ] active `CODE_REVIEW-*-G??.md`를 `code_review_{review_lane}_GNN_N.log`로 아카이브한다. +- [ ] active `PLAN-*-G??.md`를 `plan_{build_lane}_GNN_M.log`로 아카이브한다. +- [ ] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다. +- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다. +- [ ] PASS이면 active task 디렉터리 `agent-task/m-usb-install/01_adb_bundle/`를 `agent-task/archive/YYYY/MM/m-usb-install/01_adb_bundle/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다. +- [ ] PASS이고 task group이 `m-usb-install`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다. +- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-usb-install/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다. +- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-{build_lane}-GNN.md`와 `CODE_REVIEW-{review_lane}-GNN.md`를 작성하고 `complete.log`를 작성하지 않는다. +- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다. +- [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다. + +## 계획 대비 변경 사항 + +_구현 에이전트가 계획과 다르게 구현한 부분을 이유와 함께 기록한다._ + +## 주요 설계 결정 + +_구현 에이전트가 주요 설계 결정 사항을 기록한다._ + +## 사용자 리뷰 요청 + +_기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 변경 없이는 안전하게 진행할 수 없으면 아래 항목을 실제 내용으로 교체하고, 구현을 중단한 뒤 active 파일을 그대로 둔 채 리뷰를 요청한다. 구현 에이전트는 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._ + +- 상태: 없음 +- 사유 유형: 없음 +- 결정 필요: 없음 +- 차단 근거: 없음 +- 실행한 검증/명령: 없음 +- 자동 후속 불가 이유: 없음 +- 재개 조건: 없음 + +## 리뷰어를 위한 체크포인트 + +- Bundle resource path matches `AdbRuntimeConfig.effectiveBundledAdbPath`. +- Runtime subset contains only required ADB files and license/version metadata. +- Remote build and bundled `adb version` evidence are pasted verbatim. +- Sandbox/signing changes, if any, are justified and minimal. + +## 검증 결과 + +_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ + +필수 규칙: +- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다. +- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다. +- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다. +- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다. +- mobile/UI hang, timeout, 또는 2분 무진행은 blind retry를 중단하고 focused rerun 명령과 screenshot/window/UI-tree evidence path를 남기며, 불가능하면 정확한 사유를 남긴다. + +### API-1 중간 검증 +```bash +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter build macos' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && test -x build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb version' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && otool -L build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb' +(output) +``` + +### 최종 검증 +```bash +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && git status --short --branch' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter pub get' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter analyze' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter test' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter build macos' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb version' +(output) +$ zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && otool -L build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb' +(output) +``` + +--- + +> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?** +> If anything is blank, go back and fill it in before saving this file. +> Leave review-agent-only sections unchanged. + +## Sections and their ownership + +| Section | Owner | Note | +|---------|-------|------| +| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation | Implementing agent must not modify or execute these | +| Roadmap Targets | Fixed at stub creation from plan | Implementing agent must not modify; code-review copies it into `complete.log` only on PASS | +| 구현 항목별 완료 여부 | Implementing agent | Check `[ ]` to `[x]` only | +| 구현 체크리스트 | Implementing agent | Check `[ ]` to `[x]` only; final checkbox is mandatory | +| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify or check this section | +| 계획 대비 변경 사항, 주요 설계 결정 | Implementing agent | Replace placeholders with actual content | +| 사용자 리뷰 요청 | Implementing agent | Keep `상태: 없음` unless user input is required | +| 리뷰어를 위한 체크포인트 | Fixed at stub creation | Review focus areas | +| 검증 결과 | Implementing agent | Fill command output only | +| 코드리뷰 결과 | Review agent | Append verdict after review | diff --git a/agent-task/m-usb-install/01_adb_bundle/PLAN-cloud-G07.md b/agent-task/m-usb-install/01_adb_bundle/PLAN-cloud-G07.md new file mode 100644 index 0000000..1df0a29 --- /dev/null +++ b/agent-task/m-usb-install/01_adb_bundle/PLAN-cloud-G07.md @@ -0,0 +1,191 @@ + + +# Plan - API + +## 이 파일을 읽는 구현 에이전트에게 + +구현이 끝나면 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 검증을 실행하고, active 파일은 그대로 둔 채 리뷰 준비를 보고한다. 최종 판정, log rename, `complete.log` 작성, task archive 이동은 code-review 전용이다. 사용자만 결정할 수 있는 외부 환경, secret, 범위 충돌로 막히면 리뷰 stub의 `사용자 리뷰 요청`에 정확한 증거와 재개 조건을 남기고 멈춘다. 구현 중 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. + +## 배경 + +`AdbService`는 이제 bundled ADB를 우선 찾고, 없으면 system `adb`로 fallback한다. 하지만 macOS bundle에는 아직 실제 `adb-runtime` 리소스가 없어 release 앱에서는 계속 fallback에 의존한다. 이 작업은 pin된 최소 ADB subset을 app bundle 리소스로 포함하고 remote Mac runner에서 실행 가능성을 검증한다. + +## 사용자 리뷰 요청 흐름 + +구현 중 차단 사유는 active `CODE_REVIEW-*-G??.md`의 `사용자 리뷰 요청` 섹션에 기록한다. 직접 사용자 프롬프트는 금지이며, code-review가 요청 타당성과 `USER_REVIEW.md` 작성 여부를 판단한다. + +## Roadmap Targets + +- Milestone: `agent-roadmap/phase/usable-mvp/milestones/usb-install.md` +- Task ids: + - `adb-bundle`: macOS app bundle에 pin된 최소 ADB subset을 포함한다. +- Completion mode: check-on-pass + +## 분석 결과 + +### 읽은 파일 + +- `agent-roadmap/current.md` +- `agent-roadmap/phase/usable-mvp/PHASE.md` +- `agent-roadmap/phase/usable-mvp/milestones/usb-install.md` +- `agent-ops/rules/project/domain/device-console/rules.md` +- `agent-ops/rules/project/domain/macos-platform/rules.md` +- `agent-test/local/rules.md` +- `agent-test/local/device-console-smoke.md` +- `agent-test/local/macos-platform-smoke.md` +- `agent-test/local/macos-remote-build-smoke.md` +- `lib/src/services/adb_service.dart` +- `test/adb_service_test.dart` +- `pubspec.yaml` +- `.gitignore` +- `macos/Runner.xcodeproj/project.pbxproj` +- `macos/Runner/Configs/AppInfo.xcconfig` +- `macos/Runner/Configs/Debug.xcconfig` +- `macos/Runner/Configs/Release.xcconfig` +- `macos/Runner/Configs/Warnings.xcconfig` +- `macos/Runner/DebugProfile.entitlements` +- `macos/Runner/Release.entitlements` +- `macos/Runner/Info.plist` +- `macos/Runner/AppDelegate.swift` +- `macos/Runner/MainFlutterWindow.swift` + +### 테스트 환경 규칙 + +- test_env: `local` +- env rules: `agent-test/local/rules.md` present and read. 기본 완료 evidence는 standard remote Mac runner `toki@toki-labs.com` checkout `$HOME/docker/services/code-server/data/volume/workspace/appsok`. +- matched profiles: + - `agent-test/local/device-console-smoke.md`: `flutter analyze`, `flutter test`; ADB runtime evidence는 remote runner `adb` 기준. + - `agent-test/local/macos-platform-smoke.md`: macOS platform 변경 시 remote `flutter build macos`. + - `agent-test/local/macos-remote-build-smoke.md`: remote checkout 상태, Xcode, signing identity, `flutter build macos`. +- 적용 명령: + - `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && git status --short --branch'` + - `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter pub get'` + - `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter analyze'` + - `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter test'` + - `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter build macos'` + - `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb version'` + - `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && otool -L build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb'` +- `<확인 필요>` 값 없음. Notary credential은 이 작업 범위가 아니며 가능으로 단정하지 않는다. + +### 테스트 커버리지 공백 + +- Bundled ADB path resolution: `test/adb_service_test.dart`가 bundled path 존재/fallback 정책을 커버한다. +- macOS resource copy and nested binary runtime: 기존 unit test로 커버되지 않는다. remote `flutter build macos`, bundled `adb version`, `otool -L` evidence가 필요하다. +- codesign/sandbox USB execution: unit test로 커버되지 않는다. remote runner smoke 결과를 기록해야 한다. + +### 심볼 참조 + +- Renamed/removed symbols: none. +- Call sites for ADB runtime entry points: `lib/src/services/adb_service.dart` only. Current UI does not instantiate `AdbService` directly. + +### 분할 판단 + +- split decision policy evaluated. +- Shared task group: `agent-task/m-usb-install/` +- `01_adb_bundle`: independent first task. macOS bundle resources, Xcode project/build phase, remote build/runtime evidence. +- `02+01_adb_diagnostics`: depends on index `01`; predecessor `complete.log` is missing now, so diagnostics implementation must wait for `agent-task/m-usb-install/01_adb_bundle/complete.log` or matching archive `complete.log`. +- Split is required because bundle packaging/codesign evidence and diagnostics UI/service behavior have different ownership, risk, and verification paths. + +### 범위 결정 근거 + +- Include: minimal platform-tools subset under the macOS app bundle, Xcode copy/resource phase, `AdbRuntimeConfig` default bundle path compatibility, remote Mac verification. +- Exclude: settings UI diagnostics display, runtime hash/version model beyond smoke evidence, wireless ADB, split APK/APKS/AAB, notarization. +- Existing `AdbService` API should not be reworked beyond bundle path compatibility unless remote build reveals a required path fix. + +### 빌드 등급 + +- `cloud-G07`: macOS app bundle resource wiring, nested binary/dylib dependencies, process execution, and remote build evidence are central. + +## 구현 체크리스트 + +- [ ] macOS app bundle에 `Contents/Resources/adb-runtime/`가 생성되도록 pin된 ADB subset copy 방식을 구현한다. +- [ ] bundled `adb version`과 dylib 의존성 확인이 remote Mac runner에서 통과한다. +- [ ] `flutter analyze`, `flutter test`, `flutter build macos`를 remote Mac runner checkout에서 실행한다. +- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. + +## 의존 관계 및 구현 순서 + +1. `01_adb_bundle`을 먼저 완료한다. +2. PASS 후 code-review가 `complete.log`를 만들면 `02+01_adb_diagnostics`를 시작할 수 있다. + +### [API-1] Bundle ADB Runtime + +#### 문제 + +- `lib/src/services/adb_service.dart:190-202`는 macOS bundle의 `Contents/Resources/adb-runtime/adb`를 찾지만, `macos/Runner.xcodeproj/project.pbxproj:143-149` Resources group에는 `adb-runtime`이 없다. +- `macos/Runner.xcodeproj/project.pbxproj:213-218` Runner build phases에는 Flutter resources와 framework copy만 있고 ADB runtime copy phase가 없다. +- `macos/Runner.xcodeproj/project.pbxproj:304-320` shell script는 Flutter embed만 수행하므로 nested binary/dylib 준비가 없다. + +#### 해결 방법 + +Before: + +```text +macos/Runner.xcodeproj/project.pbxproj:143 +33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); +``` + +After: + +```text +macos/Runner.xcodeproj/project.pbxproj +Resources children include adb-runtime, and Runner build phases copy it to +$(CONTENTS_FOLDER_PATH)/Resources/adb-runtime before signing/build validation. +``` + +- Add or generate `macos/Runner/Resources/adb-runtime/` with the pinned minimum files: `adb`, required `lib64/*.dylib`, `NOTICE.txt`, `source.properties`. +- Wire the directory into the Runner target as a copied resource or deterministic shell copy phase. Prefer a folder reference/copy phase that preserves executable bits. +- Ensure the final path matches `AdbRuntimeConfig.effectiveBundledAdbPath`: `AppSok.app/Contents/Resources/adb-runtime/adb`. +- Preserve sandbox entitlements unless remote evidence proves a specific entitlement change is required; do not disable sandbox just to make ADB work. + +#### 수정 파일 및 체크리스트 + +- [ ] `macos/Runner.xcodeproj/project.pbxproj`: add resource/copy phase for `adb-runtime`. +- [ ] `macos/Runner/Resources/adb-runtime/**`: add pinned runtime subset and license/version metadata. +- [ ] `lib/src/services/adb_service.dart`: adjust default bundle path only if remote build path differs from the current `Contents/Resources/adb-runtime/adb` contract. +- [ ] `test/adb_service_test.dart`: update only if path contract changes. + +#### 테스트 작성 + +- New Dart unit tests are not required unless `AdbRuntimeConfig` path behavior changes. Existing `test/adb_service_test.dart` covers bundle path preference and fallback. +- Remote smoke evidence is required because actual copied binary/dylib execution is outside unit test scope. + +#### 중간 검증 + +```bash +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter build macos' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && test -x build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb version' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && otool -L build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb' +``` + +Expected: build succeeds; `adb` is executable; version prints platform-tools version; `otool -L` references bundled or system-resolvable dylibs intentionally. + +## 수정 파일 요약 + +| 파일 | 항목 | +|------|------| +| `macos/Runner.xcodeproj/project.pbxproj` | API-1 | +| `macos/Runner/Resources/adb-runtime/**` | API-1 | +| `lib/src/services/adb_service.dart` | API-1, only if path contract needs adjustment | +| `test/adb_service_test.dart` | API-1, only if path contract changes | + +## 최종 검증 + +```bash +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && git status --short --branch' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter pub get' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter analyze' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter test' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter build macos' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb version' +zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && otool -L build/macos/Build/Products/Release/AppSok.app/Contents/Resources/adb-runtime/adb' +``` + +모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다. diff --git a/agent-task/m-usb-install/02+01_adb_diagnostics/CODE_REVIEW-local-G06.md b/agent-task/m-usb-install/02+01_adb_diagnostics/CODE_REVIEW-local-G06.md new file mode 100644 index 0000000..8de41df --- /dev/null +++ b/agent-task/m-usb-install/02+01_adb_diagnostics/CODE_REVIEW-local-G06.md @@ -0,0 +1,156 @@ + + +# Code Review Reference - API + +> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.** +> The task is NOT complete until every implementation-owned section below is filled in. +> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving. +> Fill implementation-owned sections, then stop with active files in place and report ready for review. +> If implementation is blocked by a user-only decision, user-owned external environment prerequisite, or scope conflict, fill `사용자 리뷰 요청` with evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Evidence gaps that a follow-up agent can close by rerunning commands or collecting artifacts are normal follow-up issues, not user-review blockers by themselves. +> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record the needed decision in `사용자 리뷰 요청` and stop for code-review. +> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume. +> Follow the ownership table at the bottom of this file for which sections you own. + +## 개요 + +date=2026-06-12 +task=m-usb-install/02+01_adb_diagnostics, plan=0, tag=API + +## Roadmap Targets + +- Milestone: `agent-roadmap/phase/usable-mvp/milestones/usb-install.md` +- Task ids: + - `adb-diagnostics`: ADB 실행 경로, bundled version, runtime hash, server port, fallback 여부를 진단 정보로 표시한다. +- Completion mode: check-on-pass + +## 이 파일을 읽는 리뷰 에이전트에게 + +> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다. + +각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요. +리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다. + +1. 판정을 append한다. +2. `CODE_REVIEW-local-G06.md` → `code_review_local_G06_N.log`, `PLAN-local-G06.md` → `plan_local_G06_M.log`로 아카이브한다. +3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-usb-install/02+01_adb_diagnostics/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다. `USER_REVIEW.md`가 사용자 결정으로 완료/PASS 해소되면 code-review가 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log` 작성 후 archive 이동한다. +4. PASS이고 task group이 `m-usb-install`이면 완료 이벤트 메타데이터를 보고한다. roadmap 상태 체크와 `update-roadmap` 호출은 런타임 책임이다. +5. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다. + +--- + +## 구현 항목별 완료 여부 + +| 항목 | 완료 여부 | +|------|---------| +| [API-1] Collect ADB Runtime Diagnostics | [ ] | +| [API-2] Display Diagnostics | [ ] | + +## 구현 체크리스트 + +- [ ] `01_adb_bundle` predecessor `complete.log`가 active 또는 archive 경로에 있는지 확인한다. +- [ ] ADB diagnostics model/service method를 추가해 executable path, source, version, runtime hash, server port, fallback 여부를 수집한다. +- [ ] settings 또는 shell ADB surface에 diagnostics를 표시하고 compact viewport overflow가 없도록 한다. +- [ ] version/hash collection unit test와 diagnostics UI widget test를 추가한다. +- [ ] `flutter analyze`, `flutter test`, `flutter test test/adb_service_test.dart`, `flutter test test/widget_test.dart`를 실행한다. +- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. + +## 코드리뷰 전용 체크리스트 + +> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다. +> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다. + +- [ ] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다. +- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다. +- [ ] active `CODE_REVIEW-*-G??.md`를 `code_review_{review_lane}_GNN_N.log`로 아카이브한다. +- [ ] active `PLAN-*-G??.md`를 `plan_{build_lane}_GNN_M.log`로 아카이브한다. +- [ ] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다. +- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다. +- [ ] PASS이면 active task 디렉터리 `agent-task/m-usb-install/02+01_adb_diagnostics/`를 `agent-task/archive/YYYY/MM/m-usb-install/02+01_adb_diagnostics/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다. +- [ ] PASS이고 task group이 `m-usb-install`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다. +- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-usb-install/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다. +- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-{build_lane}-GNN.md`와 `CODE_REVIEW-{review_lane}-GNN.md`를 작성하고 `complete.log`를 작성하지 않는다. +- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다. +- [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다. + +## 계획 대비 변경 사항 + +_구현 에이전트가 계획과 다르게 구현한 부분을 이유와 함께 기록한다._ + +## 주요 설계 결정 + +_구현 에이전트가 주요 설계 결정 사항을 기록한다._ + +## 사용자 리뷰 요청 + +_기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 변경 없이는 안전하게 진행할 수 없으면 아래 항목을 실제 내용으로 교체하고, 구현을 중단한 뒤 active 파일을 그대로 둔 채 리뷰를 요청한다. 구현 에이전트는 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._ + +- 상태: 없음 +- 사유 유형: 없음 +- 결정 필요: 없음 +- 차단 근거: 없음 +- 실행한 검증/명령: 없음 +- 자동 후속 불가 이유: 없음 +- 재개 조건: 없음 + +## 리뷰어를 위한 체크포인트 + +- Implementation waited for `01_adb_bundle` completion evidence. +- Version/hash collection uses resolved runtime and does not call shell `adb` accidentally. +- UI handles fallback/system/custom/bundled states without overflow. +- Tests cover service diagnostics and UI display. + +## 검증 결과 + +_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ + +필수 규칙: +- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다. +- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다. +- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다. +- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다. +- mobile/UI hang, timeout, 또는 2분 무진행은 blind retry를 중단하고 focused rerun 명령과 screenshot/window/UI-tree evidence path를 남기며, 불가능하면 정확한 사유를 남긴다. + +### API-1 중간 검증 +```bash +$ flutter test test/adb_service_test.dart +(output) +``` + +### API-2 중간 검증 +```bash +$ flutter test test/widget_test.dart +(output) +``` + +### 최종 검증 +```bash +$ flutter analyze +(output) +$ flutter test +(output) +$ flutter test test/adb_service_test.dart +(output) +$ flutter test test/widget_test.dart +(output) +``` + +--- + +> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?** +> If anything is blank, go back and fill it in before saving this file. +> Leave review-agent-only sections unchanged. + +## Sections and their ownership + +| Section | Owner | Note | +|---------|-------|------| +| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation | Implementing agent must not modify or execute these | +| Roadmap Targets | Fixed at stub creation from plan | Implementing agent must not modify; code-review copies it into `complete.log` only on PASS | +| 구현 항목별 완료 여부 | Implementing agent | Check `[ ]` to `[x]` only | +| 구현 체크리스트 | Implementing agent | Check `[ ]` to `[x]` only; final checkbox is mandatory | +| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify or check this section | +| 계획 대비 변경 사항, 주요 설계 결정 | Implementing agent | Replace placeholders with actual content | +| 사용자 리뷰 요청 | Implementing agent | Keep `상태: 없음` unless user input is required | +| 리뷰어를 위한 체크포인트 | Fixed at stub creation | Review focus areas | +| 검증 결과 | Implementing agent | Fill command output only | +| 코드리뷰 결과 | Review agent | Append verdict after review | diff --git a/agent-task/m-usb-install/02+01_adb_diagnostics/PLAN-local-G06.md b/agent-task/m-usb-install/02+01_adb_diagnostics/PLAN-local-G06.md new file mode 100644 index 0000000..9835940 --- /dev/null +++ b/agent-task/m-usb-install/02+01_adb_diagnostics/PLAN-local-G06.md @@ -0,0 +1,252 @@ + + +# Plan - API + +## 이 파일을 읽는 구현 에이전트에게 + +구현이 끝나면 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 검증을 실행하고, active 파일은 그대로 둔 채 리뷰 준비를 보고한다. 최종 판정, log rename, `complete.log` 작성, task archive 이동은 code-review 전용이다. 사용자만 결정할 수 있는 외부 환경, secret, 범위 충돌로 막히면 리뷰 stub의 `사용자 리뷰 요청`에 정확한 증거와 재개 조건을 남기고 멈춘다. 구현 중 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. + +## 배경 + +ADB runtime resolution과 AppSok 전용 server port는 서비스 레벨에 들어갔다. 사용자가 실제로 어떤 ADB를 쓰는지, bundle fallback이 발생했는지, server port가 무엇인지 볼 수 있는 진단 표시는 아직 없다. 이 작업은 bundle 작업이 PASS된 뒤 실행 경로, version, hash, server port, fallback 여부를 settings/device surface에 노출한다. + +## 사용자 리뷰 요청 흐름 + +구현 중 차단 사유는 active `CODE_REVIEW-*-G??.md`의 `사용자 리뷰 요청` 섹션에 기록한다. 직접 사용자 프롬프트는 금지이며, code-review가 요청 타당성과 `USER_REVIEW.md` 작성 여부를 판단한다. + +## Roadmap Targets + +- Milestone: `agent-roadmap/phase/usable-mvp/milestones/usb-install.md` +- Task ids: + - `adb-diagnostics`: ADB 실행 경로, bundled version, runtime hash, server port, fallback 여부를 진단 정보로 표시한다. +- Completion mode: check-on-pass + +## 분석 결과 + +### 읽은 파일 + +- `agent-roadmap/current.md` +- `agent-roadmap/phase/usable-mvp/PHASE.md` +- `agent-roadmap/phase/usable-mvp/milestones/usb-install.md` +- `agent-ops/rules/project/domain/device-console/rules.md` +- `agent-ops/rules/project/domain/macos-platform/rules.md` +- `agent-test/local/rules.md` +- `agent-test/local/device-console-smoke.md` +- `agent-test/local/macos-platform-smoke.md` +- `agent-test/local/macos-remote-build-smoke.md` +- `lib/src/services/adb_service.dart` +- `lib/src/features/settings/settings_page.dart` +- `lib/src/features/app_shell.dart` +- `test/adb_service_test.dart` +- `test/widget_test.dart` +- `pubspec.yaml` +- `macos/Runner.xcodeproj/project.pbxproj` +- `macos/Runner/DebugProfile.entitlements` +- `macos/Runner/Release.entitlements` + +### 테스트 환경 규칙 + +- test_env: `local` +- env rules: `agent-test/local/rules.md` present and read. 기본 완료 evidence는 standard remote Mac runner `toki@toki-labs.com` checkout `$HOME/docker/services/code-server/data/volume/workspace/appsok`. +- matched profiles: + - `agent-test/local/device-console-smoke.md`: `flutter analyze`, `flutter test`; ADB runtime evidence는 remote runner 기준. + - `agent-test/local/macos-platform-smoke.md`: macOS bundle/runtime 관련 확인이 남아 있으면 remote `flutter build macos`. + - `agent-test/local/macos-remote-build-smoke.md`: predecessor bundle evidence를 신뢰하려면 remote checkout/build 상태를 확인. +- 적용 명령: + - `flutter analyze` + - `flutter test` + - `flutter test test/adb_service_test.dart` + - `flutter test test/widget_test.dart` + - remote runner: `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter analyze'` + - remote runner: `zsh -lc 'cd "$HOME/docker/services/code-server/data/volume/workspace/appsok" && flutter test'` +- `<확인 필요>` 값 없음. Hash 구현에 새 dependency가 필요하면 `pubspec.yaml`에 명시하고 `flutter pub get` 결과를 기록한다. + +### 테스트 커버리지 공백 + +- Runtime path/source/server port: `test/adb_service_test.dart`가 service-level behavior를 커버한다. +- Runtime version/hash collection: 테스트 없음. 새 unit test가 필요하다. +- Settings or status UI diagnostics display: 현재 `test/widget_test.dart`는 `ADB 대기` placeholder만 확인한다. 새 widget test가 필요하다. +- Real bundled version/hash: predecessor `01_adb_bundle`의 remote evidence와 이 작업의 service test를 함께 본다. + +### 심볼 참조 + +- Renamed/removed symbols: none expected. +- Existing ADB UI references: + - `lib/src/features/settings/settings_page.dart:85-103`: ADB section has only path field/search placeholder. + - `lib/src/features/app_shell.dart:313-316`: top status pill is fixed `ADB 대기`. + - `test/widget_test.dart:780-782`: status placeholder assertions. + +### 분할 판단 + +- split decision policy evaluated. +- Shared task group: `agent-task/m-usb-install/` +- This plan directory is `02+01_adb_diagnostics`, so predecessor index `01` is required. +- Required predecessor: `agent-task/m-usb-install/01_adb_bundle/complete.log` or matching archived `agent-task/archive/*/*/m-usb-install/01_adb_bundle/complete.log`. +- Current state: predecessor `complete.log` missing. Do not implement until predecessor is PASS-complete. +- Split is required because diagnostics should report the final bundle path/version/hash from the packaged runtime, not a speculative path. + +### 범위 결정 근거 + +- Include: diagnostics data model/service method, version command, runtime hash, fallback/source/server port display, focused tests. +- Exclude: actual bundle copy, nested binary signing, device list from live ADB, logcat console, custom adb picker persistence. +- Keep UI restrained: settings page or ADB status area should show compact technical diagnostics, not a landing or explanatory page. + +### 빌드 등급 + +- `local-G06`: bounded service/UI/test work after bundle predecessor completes; process and hash behavior need explicit tests but do not require broad architecture changes. + +## 구현 체크리스트 + +- [ ] `01_adb_bundle` predecessor `complete.log`가 active 또는 archive 경로에 있는지 확인한다. +- [ ] ADB diagnostics model/service method를 추가해 executable path, source, version, runtime hash, server port, fallback 여부를 수집한다. +- [ ] settings 또는 shell ADB surface에 diagnostics를 표시하고 compact viewport overflow가 없도록 한다. +- [ ] version/hash collection unit test와 diagnostics UI widget test를 추가한다. +- [ ] `flutter analyze`, `flutter test`, `flutter test test/adb_service_test.dart`, `flutter test test/widget_test.dart`를 실행한다. +- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. + +## 의존 관계 및 구현 순서 + +`02+01_adb_diagnostics`는 directory name 기준으로 `01_adb_bundle`에 의존한다. 구현 시작 전 다음 중 하나를 확인한다. + +- active: `agent-task/m-usb-install/01_adb_bundle/complete.log` +- archive: `agent-task/archive/*/*/m-usb-install/01_adb_bundle/complete.log` + +둘 다 없으면 구현하지 말고 review stub의 `사용자 리뷰 요청`이 아니라 계획 대비 변경 사항에 "predecessor incomplete"를 기록하고 멈춘다. + +### [API-1] Collect ADB Runtime Diagnostics + +#### 문제 + +- `lib/src/services/adb_service.dart:231-250` has path/source/server port/fallback fields but no version/hash diagnostics. +- `pubspec.yaml` currently has no hash helper dependency, so runtime hash needs either a new package or a deterministic implementation. + +#### 해결 방법 + +Before: + +```dart +// lib/src/services/adb_service.dart:231 +class AdbRuntime { + const AdbRuntime({ + required this.executablePath, + required this.source, + required this.serverPort, +``` + +After: + +```dart +class AdbRuntimeDiagnostics { + const AdbRuntimeDiagnostics({ + required this.runtime, + required this.version, + required this.sha256, + required this.versionError, + }); +} +``` + +- Add `AdbRuntimeDiagnostics` and `AdbService.collectDiagnostics()`. +- Run `adb version` through the resolved executable and same `ADB_SERVER_PORT` environment. +- Compute SHA-256 of the resolved executable. If adding `package:crypto`, update `pubspec.yaml` and `pubspec.lock` intentionally; otherwise keep implementation small and tested. +- Redact nothing except avoid logging private paths outside diagnostics UI/task logs if a user-owned custom path contains sensitive account names. + +#### 수정 파일 및 체크리스트 + +- [ ] `lib/src/services/adb_service.dart`: add diagnostics model and collection method. +- [ ] `test/adb_service_test.dart`: add version/hash/failure tests. +- [ ] `pubspec.yaml`, `pubspec.lock`: update only if using a hash dependency. + +#### 테스트 작성 + +- Add unit tests in `test/adb_service_test.dart`: + - successful `adb version` is captured. + - hash is stable for a temp executable file. + - non-zero `adb version` records error without throwing if UI should still show path/source. + +#### 중간 검증 + +```bash +flutter test test/adb_service_test.dart +``` + +Expected: all ADB service tests pass. + +### [API-2] Display Diagnostics + +#### 문제 + +- `lib/src/features/settings/settings_page.dart:85-103` shows an ADB path text field and search button, but no resolved path, source, version, hash, server port, or fallback state. +- `lib/src/features/app_shell.dart:313-316` shows fixed `ADB 대기`, so users cannot see fallback/system mode. +- `test/widget_test.dart:780-782` asserts only the placeholder label. + +#### 해결 방법 + +Before: + +```dart +// lib/src/features/settings/settings_page.dart:85 +Text('ADB', style: Theme.of(context).textTheme.titleMedium), +const SizedBox(height: 14), +Row( + children: [ + Expanded( + child: TextField( +``` + +After: + +```dart +SettingsPage( + adbDiagnosticsLoader: () => AdbService().collectDiagnostics(), +) +``` + +- Inject a diagnostics loader with a deterministic test fake. +- Show compact rows for executable source/path, version, SHA-256 short prefix, server port, fallback state. +- Keep controls stable at compact viewport; use ellipsis for paths/hash. +- If diagnostics collection fails, show a concise failure state while preserving path/source if available. + +#### 수정 파일 및 체크리스트 + +- [ ] `lib/src/features/settings/settings_page.dart`: add diagnostics loader and display. +- [ ] `lib/src/features/app_shell.dart`: pass diagnostics loader or ADB summary if needed. +- [ ] `test/widget_test.dart`: add diagnostics display and compact viewport coverage. + +#### 테스트 작성 + +- Add widget tests in `test/widget_test.dart`: + - settings page renders source/path/version/hash/port/fallback from fake diagnostics. + - compact viewport has no Flutter overflow exception. + - existing `ADB 대기` assertion is updated only if the top status label intentionally changes. + +#### 중간 검증 + +```bash +flutter test test/widget_test.dart +``` + +Expected: widget tests pass without overflow exceptions. + +## 수정 파일 요약 + +| 파일 | 항목 | +|------|------| +| `lib/src/services/adb_service.dart` | API-1 | +| `test/adb_service_test.dart` | API-1 | +| `pubspec.yaml` | API-1, only if hash dependency is added | +| `pubspec.lock` | API-1, only if hash dependency is added | +| `lib/src/features/settings/settings_page.dart` | API-2 | +| `lib/src/features/app_shell.dart` | API-2, only if shell summary changes | +| `test/widget_test.dart` | API-2 | + +## 최종 검증 + +```bash +flutter analyze +flutter test +flutter test test/adb_service_test.dart +flutter test test/widget_test.dart +``` + +모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다. diff --git a/lib/src/services/adb_service.dart b/lib/src/services/adb_service.dart index 3f036f4..41162fc 100644 --- a/lib/src/services/adb_service.dart +++ b/lib/src/services/adb_service.dart @@ -4,13 +4,31 @@ import 'dart:io'; import '../models/adb_device.dart'; -class AdbService { - const AdbService({this.adbPath = 'adb'}); +typedef AdbProcessRunner = + Future Function( + String executable, + List arguments, { + Map? environment, + }); - final String adbPath; +class AdbService { + AdbService({ + String? adbPath, + AdbRuntimeConfig runtimeConfig = const AdbRuntimeConfig(), + AdbProcessRunner processRunner = Process.run, + }) : runtimeConfig = adbPath == null + ? runtimeConfig + : runtimeConfig.copyWith(customAdbPath: adbPath), + _processRunner = processRunner; + + final AdbRuntimeConfig runtimeConfig; + final AdbProcessRunner _processRunner; + + AdbRuntime get runtime => runtimeConfig.resolve(); + String get adbPath => runtime.executablePath; Future> listDevices() async { - final result = await Process.run(adbPath, ['devices', '-l']); + final result = await _run(['devices', '-l']); if (result.exitCode != 0) { throw AdbException(result.stderr.toString()); } @@ -31,7 +49,7 @@ class AdbService { bool replace = true, }) async { final args = ['-s', serial, 'install', if (replace) '-r', apkPath]; - final result = await Process.run(adbPath, args); + final result = await _run(args); return AdbInstallResult( exitCode: result.exitCode, @@ -45,7 +63,12 @@ class AdbService { if (serial != null) ...['-s', serial], 'logcat', ]; - final process = await Process.start(adbPath, args); + final runtime = this.runtime; + final process = await Process.start( + runtime.executablePath, + args, + environment: runtime.environment, + ); final stdout = process.stdout .transform(utf8.decoder) .transform(const LineSplitter()); @@ -56,6 +79,15 @@ class AdbService { yield* StreamGroup.merge([stdout, stderr]); } + Future _run(List args) { + final runtime = this.runtime; + return _processRunner( + runtime.executablePath, + args, + environment: runtime.environment, + ); + } + AdbDevice _parseDeviceLine(String line) { final parts = line.split(RegExp(r'\s+')); final metadata = {}; @@ -77,6 +109,147 @@ class AdbService { } } +enum AdbExecutableSource { bundled, custom, system } + +enum AdbServerMode { appSok, shared } + +class AdbRuntimeConfig { + const AdbRuntimeConfig({ + this.bundledAdbPath, + this.customAdbPath, + this.serverMode = AdbServerMode.appSok, + this.serverPort = defaultAppSokServerPort, + this.allowSystemFallback = true, + }) : assert(serverPort > 0 && serverPort <= 65535); + + static const defaultAppSokServerPort = 5038; + static const sharedServerPort = 5037; + static const systemAdbPath = 'adb'; + + final String? bundledAdbPath; + final String? customAdbPath; + final AdbServerMode serverMode; + final int serverPort; + final bool allowSystemFallback; + + AdbRuntimeConfig copyWith({ + String? bundledAdbPath, + String? customAdbPath, + AdbServerMode? serverMode, + int? serverPort, + bool? allowSystemFallback, + }) { + return AdbRuntimeConfig( + bundledAdbPath: bundledAdbPath ?? this.bundledAdbPath, + customAdbPath: customAdbPath ?? this.customAdbPath, + serverMode: serverMode ?? this.serverMode, + serverPort: serverPort ?? this.serverPort, + allowSystemFallback: allowSystemFallback ?? this.allowSystemFallback, + ); + } + + AdbRuntime resolve() { + final explicitCustomPath = _trimmedOrNull(customAdbPath); + if (explicitCustomPath != null) { + return _runtime( + executablePath: explicitCustomPath, + source: AdbExecutableSource.custom, + ); + } + + final expectedBundledPath = effectiveBundledAdbPath; + final bundledExists = + expectedBundledPath != null && File(expectedBundledPath).existsSync(); + if (bundledExists) { + return _runtime( + executablePath: expectedBundledPath, + source: AdbExecutableSource.bundled, + expectedBundledPath: expectedBundledPath, + bundledExists: bundledExists, + ); + } + + if (allowSystemFallback) { + return _runtime( + executablePath: systemAdbPath, + source: AdbExecutableSource.system, + expectedBundledPath: expectedBundledPath, + bundledExists: bundledExists, + fallbackUsed: true, + ); + } + + return _runtime( + executablePath: expectedBundledPath ?? systemAdbPath, + source: AdbExecutableSource.bundled, + expectedBundledPath: expectedBundledPath, + bundledExists: bundledExists, + ); + } + + String? get effectiveBundledAdbPath { + final explicitBundledPath = _trimmedOrNull(bundledAdbPath); + if (explicitBundledPath != null) return explicitBundledPath; + + if (!Platform.isMacOS) return null; + + final executable = File(Platform.resolvedExecutable); + final executableDir = executable.parent; + if (executableDir.path.endsWith('/Contents/MacOS')) { + return '${executableDir.parent.path}/Resources/adb-runtime/adb'; + } + + return '${Directory.current.path}/macos/Runner/Resources/adb-runtime/adb'; + } + + int get effectiveServerPort => + serverMode == AdbServerMode.shared ? sharedServerPort : serverPort; + + AdbRuntime _runtime({ + required String executablePath, + required AdbExecutableSource source, + String? expectedBundledPath, + bool bundledExists = false, + bool fallbackUsed = false, + }) { + return AdbRuntime( + executablePath: executablePath, + source: source, + serverPort: effectiveServerPort, + expectedBundledPath: expectedBundledPath, + bundledExists: bundledExists, + fallbackUsed: fallbackUsed, + ); + } + + static String? _trimmedOrNull(String? value) { + final trimmed = value?.trim(); + return trimmed == null || trimmed.isEmpty ? null : trimmed; + } +} + +class AdbRuntime { + const AdbRuntime({ + required this.executablePath, + required this.source, + required this.serverPort, + this.expectedBundledPath, + this.bundledExists = false, + this.fallbackUsed = false, + }); + + final String executablePath; + final AdbExecutableSource source; + final int serverPort; + final String? expectedBundledPath; + final bool bundledExists; + final bool fallbackUsed; + + Map get environment => { + 'ADB_SERVER_PORT': serverPort.toString(), + }; +} + class AdbInstallResult { const AdbInstallResult({ required this.exitCode, diff --git a/test/adb_service_test.dart b/test/adb_service_test.dart new file mode 100644 index 0000000..e9e4bc2 --- /dev/null +++ b/test/adb_service_test.dart @@ -0,0 +1,134 @@ +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +import 'package:appsok/src/services/adb_service.dart'; + +void main() { + group('AdbRuntimeConfig', () { + test('prefers bundled adb when it exists', () { + final tempDir = Directory.systemTemp.createTempSync( + 'appsok-adb-runtime-', + ); + addTearDown(() => tempDir.deleteSync(recursive: true)); + + final bundledAdb = File('${tempDir.path}/adb')..writeAsStringSync(''); + final runtime = AdbRuntimeConfig( + bundledAdbPath: bundledAdb.path, + ).resolve(); + + expect(runtime.executablePath, bundledAdb.path); + expect(runtime.source, AdbExecutableSource.bundled); + expect(runtime.bundledExists, isTrue); + expect(runtime.fallbackUsed, isFalse); + expect(runtime.serverPort, AdbRuntimeConfig.defaultAppSokServerPort); + }); + + test('falls back to system adb when bundled adb is missing', () { + final runtime = const AdbRuntimeConfig( + bundledAdbPath: '/tmp/appsok-missing-adb', + ).resolve(); + + expect(runtime.executablePath, AdbRuntimeConfig.systemAdbPath); + expect(runtime.source, AdbExecutableSource.system); + expect(runtime.bundledExists, isFalse); + expect(runtime.fallbackUsed, isTrue); + }); + + test('uses custom adb as an explicit override', () { + final tempDir = Directory.systemTemp.createTempSync( + 'appsok-adb-runtime-', + ); + addTearDown(() => tempDir.deleteSync(recursive: true)); + + final bundledAdb = File('${tempDir.path}/adb')..writeAsStringSync(''); + final runtime = AdbRuntimeConfig( + bundledAdbPath: bundledAdb.path, + customAdbPath: '/custom/platform-tools/adb', + ).resolve(); + + expect(runtime.executablePath, '/custom/platform-tools/adb'); + expect(runtime.source, AdbExecutableSource.custom); + expect(runtime.fallbackUsed, isFalse); + }); + + test('uses shared ADB server port when requested', () { + final runtime = const AdbRuntimeConfig( + serverMode: AdbServerMode.shared, + ).resolve(); + + expect(runtime.serverPort, AdbRuntimeConfig.sharedServerPort); + expect(runtime.environment, {'ADB_SERVER_PORT': '5037'}); + }); + }); + + group('AdbService', () { + test( + 'runs adb devices with the resolved executable and server port', + () async { + final calls = + <({String executable, List args, String? port})>[]; + final service = AdbService( + runtimeConfig: const AdbRuntimeConfig( + customAdbPath: '/opt/appsok/adb', + serverPort: 15037, + ), + processRunner: (executable, args, {environment}) async { + calls.add(( + executable: executable, + args: args, + port: environment?['ADB_SERVER_PORT'], + )); + return ProcessResult( + 42, + 0, + 'List of devices attached\n' + 'emulator-5554 device product:emu64a ' + 'model:sdk_gphone64_arm64 device:emu64a\n', + '', + ); + }, + ); + + final devices = await service.listDevices(); + + expect(calls, hasLength(1)); + expect(calls.single.executable, '/opt/appsok/adb'); + expect(calls.single.args, ['devices', '-l']); + expect(calls.single.port, '15037'); + expect(devices.single.serial, 'emulator-5554'); + expect(devices.single.state, 'device'); + expect(devices.single.model, 'sdk_gphone64_arm64'); + }, + ); + + test('runs adb install with the shared server port', () async { + final calls = <({List args, String? port})>[]; + final service = AdbService( + runtimeConfig: const AdbRuntimeConfig( + customAdbPath: '/opt/appsok/adb', + serverMode: AdbServerMode.shared, + ), + processRunner: (_, args, {environment}) async { + calls.add((args: args, port: environment?['ADB_SERVER_PORT'])); + return ProcessResult(42, 0, 'Success', ''); + }, + ); + + final result = await service.installApk( + serial: 'R5CT90A1B2C', + apkPath: '/tmp/app.apk', + ); + + expect(result.succeeded, isTrue); + expect(calls.single.args, [ + '-s', + 'R5CT90A1B2C', + 'install', + '-r', + '/tmp/app.apk', + ]); + expect(calls.single.port, '5037'); + }); + }); +}