OpenCode
适用于 OpenCode(测试版)的 Apothem 工具适配器。
厂商: OpenCode
安装名称: opencode
状态: 测试版
原生配置: ~/.config/opencode/
安装
apothem install --harness opencode适配器写入 OpenCode 的 JSON 配置,将 Apothem 技能安装到 OpenCode 技能表面,将命令提示词转换为 OpenCode Markdown 命令文件,并将 Apothem 辅助器定义规范化为 OpenCode 子辅助器。
写入的文件:
~/.config/opencode/opencode.json
~/.config/opencode/apothem/rules/00-apothem-profile.md
~/.config/opencode/commands/
~/.config/opencode/skills/
~/.config/opencode/agents/
~/.config/opencode/.apothem/support/{rules,templates,hooks}/配置档案到原生配置的映射
适配器渲染 opencode.json,其中的 instructions 文件列表指明你的配置档案文档、四条核心规则和规则索引,然后将每个共享的 Apothem 集合传播到 OpenCode 原生表面或 Apothem 自有的支持子树中。现有的、匹配的 Apothem 管理子项会在替换之前被备份。
兼容性说明
OpenCode 会将 instructions 列表指明的每个文件合并到每个会话中(OpenCode 规则)。因此,该列表首先指明你的配置档案文档,然后只列出 alwaysApply 为 true 的规则,每条规则一个明确的 ~/.config/opencode/.apothem/support/rules/<name>.md 路径;OpenCode 会将开头的 ~/ 展开为你的主目录。这些规则是 agnostic-posture、authority-inquiry、context-management、session-closure,以及规则索引 apothem-rule-index。OpenCode 不按路径限定任何规则,因此其他每条规则都按需读取。它们仍作为参考材料安装在 ~/.config/opencode/.apothem/support/ 下,而该索引指明每条规则以及需要用到它的情形。引用某条规则、模板或钩子提示词的规则、技能或命令会从那里读取它。命令、技能和辅助器定义使用原生发现位置。
配置档案文档 ~/.config/opencode/apothem/rules/00-apothem-profile.md 携带共享配置档案中你的身份和偏好,并以一个 Apothem 支持文件小节结尾,该小节写明每条仓库式引用(rules/<name>.md、templates/...、hooks/...)所解析到的、位于 ~/.config/opencode/.apothem/support/ 下的绝对目录。它是第一个 instructions 条目,因此 OpenCode 会在每个会话中加载它。
由较早发布写入的 opencode.json 列出单个通配模式 ~/.config/opencode/.apothem/support/rules/*.md,它会加载每条规则;或者为当时始终启用的 28 条规则各列出一个明确的路径。apothem install 和 apothem update 会将任一形式替换为上述列表,从而去掉不再在启动时加载的 24 个路径,而 apothem uninstall 会移除所有这些条目。在任何情况下,你自己的 instructions 条目都会被保留。
验证
apothem verify --harness opencodeverify 命令确认:
- 原生配置存在于预期路径。
- 每个受管目标都存在;受管文件非空,并且 JSON 或 YAML 配置可以解析。添加
--profile PATH还可以确认已安装的文件与该配置档案相符。 - 适配器专属的验证例程报告成功。
更新
apothem update --harness opencode刷新 opencode.json、原生命令、技能、辅助器定义以及 Apothem 支持树。
卸载
apothem uninstall --harness opencode移除适配器添加到 ~/.config/opencode/opencode.json 的条目(你自己的键、MCP 服务器和 instructions 条目会保留;只有当该文件由 Apothem 创建且其中没有你的任何内容时,才会删除该文件)。从配置档案文档 ~/.config/opencode/apothem/rules/00-apothem-profile.md 中移除 Apothem 块,并保留其中的其他任何文本;只有当该文件中不再剩下其他内容时,才会删除该文件。同时移除 ~/.config/opencode/commands/、~/.config/opencode/skills/、~/.config/opencode/agents/ 和 ~/.config/opencode/.apothem/support/ 中的 Apothem 文件;这些文件夹中的其他文件会保留。每个文件在被更改或移除之前,都会先备份到 ~/.apothem/backups/ 下。共享配置档案 YAML 和 Apothem 引擎不受影响。
合规闸门
python -m apothem.conformity.gate --all .故障排查
| 症状 | 修复方法 |
|---|---|
| 找不到配置文件 | 重新运行 apothem install --harness opencode |
| 验证失败 | 运行 apothem update --harness opencode,然后再次验证 |
| 意外的配置内容 | 检查 ~/.config/apothem/profile.yaml 或 --profile PATH,然后重新运行 apothem update --harness opencode |
配置开关
| 标志 | 默认值 | 说明 |
|---|---|---|
--dry-run | false | 预览安装而不写入文件。 |
另请参阅
- 所有工具——受支持工具的完整目录
- 安装指南——将 Apothem 安装到此工具中
apothem harnesses参考——从 CLI 列出并检查适配器