feat: 增加 OpenCode 配置支持
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 1
- Avg merge
- 5h 2m
- Merged PRs (30d)
- 1
Description
背景
Coding Helper 目前已经支持 Claude Code 和 Codex 的配置写入,但项目定位中也包含 OpenCode。希望新增 OpenCode 配置能力,让用户可以通过统一的初始化向导和命令行流程,把七牛 API 端点、API Key 和模型配置写入 OpenCode。
目标
- 在工具列表中新增 OpenCode,可在初始化向导、主菜单和工具配置菜单中选择。
- 支持
coding-helper auth reload opencode重新加载 OpenCode 配置。 - 将七牛 OpenAI-compatible API 配置写入 OpenCode 的配置文件,并保留用户已有的非 Coding Helper 管理配置。
- API Key 建议复用当前 Codex 的环境变量管理思路,避免把密钥明文直接写进 OpenCode 配置文件。
- 支持卸载/清理 Coding Helper 管理的 OpenCode 配置,不影响用户自有配置。
实现提示
- 新增
OpenCodeTool,实现现有ITool接口,并注册到toolManager。 - 优先复用已有工具配置流程:
tool-setup-flow.ts、tool-menu.ts不应为 OpenCode 引入大量特殊分支。 - 参考 Codex 工具的 API Key 持久化、安全权限、冲突处理和测试覆盖方式。
- OpenCode 当前第三方 provider 配置格式需要在实现前重新核对官方文档,避免写入过期结构。
- 预期配置目标可以先按
~/.config/opencode/opencode.json方向验证,但最终以 OpenCode 当前文档和实际行为为准。
验收标准
coding-helper初始化/主菜单中可以看到并配置 OpenCode。coding-helper auth reload opencode可以基于当前七牛线路、API Key、模型重新生成 OpenCode 配置。coding-helper doctor能识别 OpenCode 安装状态和配置状态。- 配置写入不会覆盖用户自有 OpenCode 配置,只更新 Coding Helper 管理的 provider/model 片段。
- API Key 冲突或无法安全覆盖时有明确错误,不静默成功。
- 增加对应自动化测试,覆盖配置写入、清理、保留用户配置、API Key 管理等关键路径。
pnpm test通过。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing Codex implementation and the shared tool-setup-flow.ts, tool-menu.ts, and toolManager paths. Verify OpenCode’s current provider format against its official documentation before deciding the configuration target, then add tests for writing, cleanup, preserving user configuration, and API key handling. Done means the initialization, menus, reload command, doctor check, and pnpm test all meet the stated acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100