From 6079f26118be074c6ded8456291d8d981e21e36f Mon Sep 17 00:00:00 2001 From: toki Date: Mon, 4 May 2026 17:10:34 +0900 Subject: [PATCH] chore: update cli adapter and sync agent-task logs --- .../CODE_REVIEW.md | 58 --------- .../code_review_0.log | 111 ++++++++++++++++++ .../complete.log | 19 +++ .../{PLAN.md => plan_0.log} | 0 apps/node/internal/adapters/cli/cli.go | 9 +- apps/node/internal/adapters/cli/cli_test.go | 39 ++++++ 6 files changed, 170 insertions(+), 66 deletions(-) delete mode 100644 agent-task/01_cli_capabilities_real_profiles/CODE_REVIEW.md create mode 100644 agent-task/01_cli_capabilities_real_profiles/code_review_0.log create mode 100644 agent-task/01_cli_capabilities_real_profiles/complete.log rename agent-task/01_cli_capabilities_real_profiles/{PLAN.md => plan_0.log} (100%) diff --git a/agent-task/01_cli_capabilities_real_profiles/CODE_REVIEW.md b/agent-task/01_cli_capabilities_real_profiles/CODE_REVIEW.md deleted file mode 100644 index 8aa9860..0000000 --- a/agent-task/01_cli_capabilities_real_profiles/CODE_REVIEW.md +++ /dev/null @@ -1,58 +0,0 @@ - - -# Code Review Reference - REFACTOR - -## 개요 - -date=2026-05-04 -task=01_cli_capabilities_real_profiles, plan=0, tag=REFACTOR - -## 이 파일을 읽는 리뷰 에이전트에게 - -각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요. -리뷰 완료 후 반드시 아래 순서로 아카이브하세요. - -1. `CODE_REVIEW.md` → `code_review_N.log` -2. `PLAN.md` → `plan_M.log` -3. PASS인 경우 `complete.log` 작성 후 종료. WARN/FAIL인 경우 새 `PLAN.md` + `CODE_REVIEW.md` 스텁 작성. - ---- - -## 구현 항목별 완료 여부 - -| 항목 | 완료 여부 | -|------|---------| -| [REFACTOR-1] knownAgents 제거 및 Capabilities 단순화 | [ ] | - -## 계획 대비 변경 사항 - -_구현 에이전트가 계획과 다르게 구현한 부분을 이유와 함께 기록한다._ - -## 주요 설계 결정 - -_구현 에이전트가 주요 설계 결정 사항을 기록한다._ - -## 리뷰어를 위한 체크포인트 - -- `knownAgents` 심볼이 코드베이스 어디에도 남아있지 않은지 (`rg knownAgents`) -- `Capabilities().Models`가 정렬된 상태로 반환되어 결과가 결정적인지 -- 빈 profiles에 대해 `Models`가 nil이 아닌 길이 0 슬라이스인지 -- 다른 어댑터(mock/ollama/vllm)의 Capabilities 동작에 영향 없는지 - -## 검증 결과 - -_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ - -### REFACTOR-1 중간 검증 -``` -$ go test ./apps/node/internal/adapters/cli/... -(output) -``` - -### 최종 검증 -``` -$ go build ./... -$ go test ./apps/node/... -$ rg -n 'knownAgents' apps/node/ -(output) -``` diff --git a/agent-task/01_cli_capabilities_real_profiles/code_review_0.log b/agent-task/01_cli_capabilities_real_profiles/code_review_0.log new file mode 100644 index 0000000..cc45c7a --- /dev/null +++ b/agent-task/01_cli_capabilities_real_profiles/code_review_0.log @@ -0,0 +1,111 @@ + + +# Code Review Reference - REFACTOR + +## 개요 + +date=2026-05-04 +task=01_cli_capabilities_real_profiles, plan=0, tag=REFACTOR + +## 이 파일을 읽는 리뷰 에이전트에게 + +각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요. +리뷰 완료 후 반드시 아래 순서로 아카이브하세요. + +1. `CODE_REVIEW.md` → `code_review_N.log` +2. `PLAN.md` → `plan_M.log` +3. PASS인 경우 `complete.log` 작성 후 종료. WARN/FAIL인 경우 새 `PLAN.md` + `CODE_REVIEW.md` 스텁 작성. + +--- + +## 구현 항목별 완료 여부 + +| 항목 | 완료 여부 | +|------|---------| +| [REFACTOR-1] knownAgents 제거 및 Capabilities 단순화 | [x] | + +## 계획 대비 변경 사항 + +- 테스트는 PLAN이 제안한 `lifecycle_blackbox_test.go`가 아닌 기존 `apps/node/internal/adapters/cli/cli_test.go`에 추가했다. 해당 파일이 이미 `cli_test` 패키지의 외부 블랙박스 테스트 진입점이고, 새 테스트는 PTY/exec 등 lifecycle 종속성이 없어 별도 파일을 만들 필요가 없다고 판단했다. + +## 주요 설계 결정 + +- `Capabilities.Models`는 `make([]string, 0, len(c.profiles))`로 길이 0의 비-nil 슬라이스로 초기화한다. 빈 profiles 시에도 nil이 아닌 결정적 결과를 반환하기 위함이다. +- `sort.Strings`로 정렬해 등록 순서와 무관하게 결정적 출력을 보장한다. +- `MaxConcurrency: 4`는 PLAN 지시대로 그대로 유지했다. + +## 리뷰어를 위한 체크포인트 + +- `knownAgents` 심볼이 코드베이스 어디에도 남아있지 않은지 (`rg knownAgents`) +- `Capabilities().Models`가 정렬된 상태로 반환되어 결과가 결정적인지 +- 빈 profiles에 대해 `Models`가 nil이 아닌 길이 0 슬라이스인지 +- 다른 어댑터(mock/ollama/vllm)의 Capabilities 동작에 영향 없는지 + +## 검증 결과 + +_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ + +### REFACTOR-1 중간 검증 +``` +$ go test ./apps/node/internal/adapters/cli/... +ok iop/apps/node/internal/adapters/cli 0.003s +? iop/apps/node/internal/adapters/cli/internal/testutil [no test files] +ok iop/apps/node/internal/adapters/cli/lifecycle 2.257s +ok iop/apps/node/internal/adapters/cli/oneshot 0.298s +ok iop/apps/node/internal/adapters/cli/persistent 63.234s +ok iop/apps/node/internal/adapters/cli/status (cached) +``` + +신규 추가 테스트: `TestCapabilities_OnlyConfiguredProfiles`, `TestCapabilities_EmptyProfilesReturnsEmptyModels` 모두 PASS. + +### 최종 검증 +``` +$ go build ./... +(no output — build success) + +$ go test ./apps/node/... +? iop/apps/node/cmd/node [no test files] +ok iop/apps/node/internal/adapters 0.003s +ok iop/apps/node/internal/adapters/cli (cached) +? iop/apps/node/internal/adapters/cli/internal/testutil [no test files] +ok iop/apps/node/internal/adapters/cli/lifecycle (cached) +ok iop/apps/node/internal/adapters/cli/oneshot (cached) +ok iop/apps/node/internal/adapters/cli/persistent (cached) +ok iop/apps/node/internal/adapters/cli/status (cached) +? iop/apps/node/internal/adapters/mock [no test files] +? iop/apps/node/internal/adapters/ollama [no test files] +? iop/apps/node/internal/adapters/vllm [no test files] +ok iop/apps/node/internal/bootstrap 0.165s +ok iop/apps/node/internal/node 0.008s +ok iop/apps/node/internal/router 0.010s +? iop/apps/node/internal/runtime [no test files] +ok iop/apps/node/internal/store (cached) +ok iop/apps/node/internal/transport (cached) + +$ rg -n 'knownAgents' apps/node/ +(no matches — exit 1) +``` + +## 코드리뷰 결과 + +- 종합 판정: PASS + +### 차원별 평가 + +| 차원 | 평가 | 근거 | +|------|------|------| +| correctness | Pass | `apps/node/internal/adapters/cli/cli.go:75`가 등록된 profile 키만 수집하고 정렬해 반환한다. | +| completeness | Pass | PLAN의 `knownAgents` 제거, `Capabilities` 단순화, 테스트 추가가 모두 반영됐다. | +| test coverage | Pass | `apps/node/internal/adapters/cli/cli_test.go:80`, `apps/node/internal/adapters/cli/cli_test.go:104`에서 정렬 결과와 빈 profile 케이스를 검증한다. | +| API contract | Pass | `runtime.Capabilities.Models`가 실제 실행 가능한 profile 집합만 노출하도록 계약이 개선됐고, 다른 adapter 구현과 충돌하지 않는다. | +| code quality | Pass | 하드코딩 목록과 관련 분기가 제거됐고, 불필요한 잔여 코드나 디버그 출력이 없다. | +| plan deviation | Pass | 테스트 파일 위치만 계획과 달라졌고, `cli_test`의 기존 블랙박스 테스트 문맥에 맞는 합리적 변경이다. | +| verification trust | Pass | 실제 `go build ./...`, `go test ./apps/node/internal/adapters/cli/...`, `go test ./apps/node/...` 결과와 문서 기재가 일치한다. | + +### 발견된 문제 + +- Nit [apps/node/internal/adapters/cli/cli_test.go:104]: `TestCapabilities_EmptyProfilesReturnsEmptyModels`는 현재 길이만 검증한다. `CODE_REVIEW.md`의 설계 결정처럼 non-nil empty slice 계약까지 고정하려면 `caps.Models == nil` 여부도 함께 단언하면 더 좋다. + +### 다음 단계 + +- PASS: 아카이브 후 `complete.log`를 작성하고 종료한다. diff --git a/agent-task/01_cli_capabilities_real_profiles/complete.log b/agent-task/01_cli_capabilities_real_profiles/complete.log new file mode 100644 index 0000000..cc52ec9 --- /dev/null +++ b/agent-task/01_cli_capabilities_real_profiles/complete.log @@ -0,0 +1,19 @@ +완료 일시: 2026-05-04 + +요약: CLI capabilities가 실제 등록된 profile만 노출하도록 수정한 작업을 1회 리뷰 루프로 완료했다. + +루프 이력: + +| plan log | code review log | verdict | +|----------|-----------------|---------| +| `plan_0.log` | `code_review_0.log` | PASS | + +최종 리뷰 요약: + +- `apps/node/internal/adapters/cli/cli.go`에서 `knownAgents` 하드코딩 목록과 관련 추가 로직을 제거했다. +- `CLI.Capabilities`가 `c.profiles`의 키만 수집해 정렬된 `Models`로 반환하도록 단순화했다. +- `apps/node/internal/adapters/cli/cli_test.go`에 등록된 profile만 노출하는 케이스와 빈 profile 케이스 테스트를 추가했다. + +잔여 Nit: + +- `TestCapabilities_EmptyProfilesReturnsEmptyModels`에 non-nil empty slice 여부까지 단언하면 설계 결정이 테스트에 더 직접적으로 고정된다. diff --git a/agent-task/01_cli_capabilities_real_profiles/PLAN.md b/agent-task/01_cli_capabilities_real_profiles/plan_0.log similarity index 100% rename from agent-task/01_cli_capabilities_real_profiles/PLAN.md rename to agent-task/01_cli_capabilities_real_profiles/plan_0.log diff --git a/apps/node/internal/adapters/cli/cli.go b/apps/node/internal/adapters/cli/cli.go index ffb5cc9..a51adb2 100644 --- a/apps/node/internal/adapters/cli/cli.go +++ b/apps/node/internal/adapters/cli/cli.go @@ -22,9 +22,6 @@ import ( const Name = "cli" -// known agents — must match CLI tool names -var knownAgents = []string{"claude", "gemini", "codex", "opencode", "cline"} - type cliOutput struct { line string } @@ -80,11 +77,7 @@ func (c *CLI) Capabilities(_ context.Context) (runtime.Capabilities, error) { for name := range c.profiles { models = append(models, name) } - for _, agent := range knownAgents { - if _, ok := c.profiles[agent]; !ok { - models = append(models, agent) - } - } + sort.Strings(models) return runtime.Capabilities{ AdapterName: Name, Models: models, diff --git a/apps/node/internal/adapters/cli/cli_test.go b/apps/node/internal/adapters/cli/cli_test.go index 4dbf7b1..2441ad1 100644 --- a/apps/node/internal/adapters/cli/cli_test.go +++ b/apps/node/internal/adapters/cli/cli_test.go @@ -76,3 +76,42 @@ func TestCLIHandleCommandUsageStatusUsesSelectedAgent(t *testing.T) { t.Errorf("expected unsupported command error, got %v", err) } } + +func TestCapabilities_OnlyConfiguredProfiles(t *testing.T) { + c := cli.New(config.CLIConf{ + Enabled: true, + Profiles: map[string]config.CLIProfileConf{ + "foo": {Command: "foo"}, + "bar": {Command: "bar"}, + }, + }, zap.NewNop()) + + caps, err := c.Capabilities(context.Background()) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + want := []string{"bar", "foo"} + if len(caps.Models) != len(want) { + t.Fatalf("expected models %v, got %v", want, caps.Models) + } + for i, m := range want { + if caps.Models[i] != m { + t.Errorf("Models[%d] = %q, want %q", i, caps.Models[i], m) + } + } +} + +func TestCapabilities_EmptyProfilesReturnsEmptyModels(t *testing.T) { + c := cli.New(config.CLIConf{ + Enabled: true, + Profiles: map[string]config.CLIProfileConf{}, + }, zap.NewNop()) + + caps, err := c.Capabilities(context.Background()) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(caps.Models) != 0 { + t.Errorf("expected empty models, got %v", caps.Models) + } +}