Agent: programmer (
programmer)
Confidence: 65%
Cost: $1.0970
Duration: 3m 32s
Task ID:fe10c95f-c2ff-4f27-9bfa-a284dfa20c70
★ Insight ─────────────────────────────────────
1. shouldUseWorktree() 的 capability 匹配策略是核心設計決策
任務 spec 建議 CODE_CAPABILITIES = ['code', 'architecture', 'refactoring'],但 reviewer 有 architecture capability。如果 reviewer 被獨立派工(非 pipeline),會誤建新 worktree。我的報告建議縮小為 ['code', 'refactoring'],讓 programmer(code)和 architect(refactoring)匹配,reviewer 只能繼承。
2. mcp-code-agent.json 路徑不需要改mcp-code-agent.json 在 data/agent-workspace/ 下(不在 git 追蹤中),且其內容使用相對路徑 ./node_modules/.bin/cclsp。因為 worktree 中 node_modules/ 是 symlink,保持 mcpConfig 指向 LIGHTWEIGHT_CWD 是最安全的做法。
3. bot-tools-server.ts 的 parent 查找可以復用dispatch_task handler 已有 parentTaskId 查找 parent 的邏輯(572-593 行),worktree 繼承可以直接在這個區塊中加入,避免重複 I/O。
─────────────────────────────────────────────────
調查完成
報告已寫入 soul/agent-reports/programmer/phase2-worktree-investigation.md。
關鍵發現摘要
| 項目 | 結論 |
|---|---|
| 可行性 | 完全可行,3 個檔案、~40 行改動 |
| shouldUseWorktree capabilities | 建議用 ['code', 'refactoring'](不含 architecture),避免 reviewer 誤建 worktree |
| mcp-code-agent.json | 不需要改,保持指向 LIGHTWEIGHT_CWD |
| tests/unit/agent-config.test.ts | 不需要改(現有測試不涉及 AgentTask) |
| bot-tools-server.ts | 需要在 task type 中加入欄位 + 在 if (parentTaskId) 區塊加入繼承邏輯 |
| 向後相容 | 所有新欄位都是 optional,queue.json 和 history.jsonl 自然相容 |
主要風險
- reviewer
architecturecapability 問題 — 需要在shouldUseWorktree()中精確處理 - cclsp MCP 在 worktree 中的行為 — 非致命,但值得測試
- Phase 2 不清理 worktree — 靠 TTL 自動清理,需確認 cleanupOrphanWorktrees 有被定期呼叫
由於我是 observer 模式,不執行代碼修改。如需執行實際改動,請以 executor 角色重新派工給 programmer。