概述
更新所有相關文件,反映 OpenCode YOLO Agent 配置與 ACP setSessionMode 模式切換的變更。
父議題:#264
依賴:#265、#268、#267 全部完成
實作步驟
步驟 1:更新 AGENTS.md
1a. ACP Client Integration 區段 — Agent Connector 部分
在 setSessionModel 的描述附近,新增 setSessionMode 的說明。
在 Session Flow 的程式碼範例中加入 setSessionMode:
// 1. Create and connect agent
const connector = new AgentConnector({ agentConfig, clientConfig, skillRegistry });
await connector.connect();
// 2. Create session with workspace and optional MCP servers
const sessionId = await connector.createSession(mcpServers);
await connector.setSessionModel(sessionId, "gpt-4");
// 3. Switch to YOLO mode agent for OpenCode when YOLO is enabled
const modeOverride = getSessionModeOverride(agentType, yolo);
if (modeOverride) {
await connector.setSessionMode(sessionId, modeOverride);
}
// 4. Send prompt and get response
const response = await connector.prompt(sessionId, assembledContext);
// 5. Disconnect when done
await connector.disconnect();
1b. Agent Sandbox Hardening 區段 — OpenCode YOLO 行為
新增一段說明 OpenCode 的 YOLO 模式如何運作:
**OpenCode YOLO Mode (Agent Mode Switching)**:
When YOLO mode is enabled for an OpenCode session, the system switches to the `yolo` agent
defined in `agent-config/opencode.json` via ACP `setSessionMode("yolo")`. This agent has
`"*": "allow"` permissions, matching the unrestricted behavior of Copilot and Gemini `--yolo` flags.
| Mode | OpenCode Agent | Permission Default |
|------|---------------|-------------------|
| Restricted | `build` (default) | `"*": "deny"` + whitelist |
| YOLO | `yolo` | `"*": "allow"` |
Note: The `OPENCODE_YOLO` env var has been removed since upstream OpenCode YOLO mode
(PR anomalyco/opencode#11833) was never functional. YOLO is fully handled via
ACP `setSessionMode("yolo")`.
1c. File Layout Quick Reference
在 agent-config/ 區段確認 opencode.json 的描述仍然準確(不需要新增檔案,但可以補充說明)。
步驟 2:更新 docs/DESIGN.md
在 OpenCode 相關的區段中,更新 opencode.json 的描述以反映 yolo Agent 的存在。
步驟 3:更新 BDD Feature Spec
檢查 docs/features/ 目錄中與以下功能相關的 Feature Spec:
- YOLO 模式(Feature 28 或相關 spec)
- ACP Client Integration
如果存在相關的 .feature 檔案,新增 Scenario 覆蓋 OpenCode YOLO Mode 切換行為:
Scenario: OpenCode Agent switches to YOLO mode
Given the agent type is "opencode"
And YOLO mode is enabled
When a session is created
Then setSessionMode("yolo") is called after setSessionModel
And the OpenCode agent uses permissive permissions
Scenario: OpenCode Agent uses restricted mode by default
Given the agent type is "opencode"
And YOLO mode is disabled
When a session is created
Then setSessionMode is not called
And the OpenCode agent uses the "build" agent with deny-by-default permissions
Scenario: Copilot Agent does not use setSessionMode
Given the agent type is "copilot"
And YOLO mode is enabled
When a session is created
Then setSessionMode is not called
And the Copilot agent uses --yolo CLI flag instead
步驟 4:確認無需修改的檔案
以下檔案不需要修改:
| 檔案 |
原因 |
config.example.yaml |
無新增配置項目 |
.env.example |
無新增環境變數 |
helm/values.yaml |
無新增 Helm 設定 |
Containerfile |
現有 COPY 指令已足夠 |
測試策略
- 文件變更無需自動化測試
- 人工審閱確認所有修改的文件內容一致且正確
相關檔案
| 檔案 |
修改類型 |
AGENTS.md |
更新 ACP 說明、Session Flow、OpenCode YOLO 行為 |
docs/DESIGN.md |
更新 OpenCode 配置說明 |
docs/features/*.feature |
新增 Scenario(如有相關 spec) |
概述
更新所有相關文件,反映 OpenCode YOLO Agent 配置與 ACP
setSessionMode模式切換的變更。父議題:#264
依賴:#265、#268、#267 全部完成
實作步驟
步驟 1:更新
AGENTS.md1a. ACP Client Integration 區段 — Agent Connector 部分
在
setSessionModel的描述附近,新增setSessionMode的說明。在 Session Flow 的程式碼範例中加入
setSessionMode:1b. Agent Sandbox Hardening 區段 — OpenCode YOLO 行為
新增一段說明 OpenCode 的 YOLO 模式如何運作:
1c. File Layout Quick Reference
在
agent-config/區段確認opencode.json的描述仍然準確(不需要新增檔案,但可以補充說明)。步驟 2:更新
docs/DESIGN.md在 OpenCode 相關的區段中,更新
opencode.json的描述以反映yoloAgent 的存在。步驟 3:更新 BDD Feature Spec
檢查
docs/features/目錄中與以下功能相關的 Feature Spec:如果存在相關的
.feature檔案,新增 Scenario 覆蓋 OpenCode YOLO Mode 切換行為:步驟 4:確認無需修改的檔案
以下檔案不需要修改:
config.example.yaml.env.examplehelm/values.yamlContainerfile測試策略
相關檔案
AGENTS.mddocs/DESIGN.mddocs/features/*.feature