词元之母TOK.MOM - 平台充值汇率 1:1 即 1 人民币充值到账 1 美元,支持一个 Key 调用近 600+ 海内外模型,限时特价模型低至 1 折,欢迎上岸!
像开发者一样剖析 OpenCode

opencode debug。这些工具不仅用于开发调试,也能帮助高级用户诊断配置错误、文件系统问题和 AI 行为异常。opencode.json,插件也可以在启动时动态注入配置。{
"$schema": "https://opencode.ai/config.json",
"keybinds": { ... },
// 这里列出了所有已加载的 Agent(包括默认和自定义)
"agent": {
"coder": { ... },
"writer": { ... },
"my-custom-agent": { ... } // 确认自定义 Agent 是否存在
},
// 这里可能包含插件动态注入的配置
"plugin_injected_config": { ... }
}opencode debug config 输出中的 agent 字段。这里列出了所有已注册且可用的 Agent。[
{
"name": "fanyi",
"description": "...",
// 确认加载的是哪个路径下的文件
"location": "/Users/user/.claude/skills/fanyi/SKILL.md"
},
{
"name": "sync-changelog",
// 确认是否覆盖了同名 Skill
"location": "/Users/user/.config/opencode/skill/sync-changelog/SKILL.md"
}
]data /Users/username/.local/share/opencode
config /Users/username/.config/opencode
log /Users/username/.local/share/opencode/log
cache /Users/username/.cache/opencode| 命令 | 用途 | 典型场景 |
|---|---|---|
debug config | 查看最终配置 | 检查配置是否生效、查看默认快捷键 |
debug agent <name> | 查看 Agent 详情 | 检查 Prompt、权限、工具列表 |
debug agent --tool | 手动执行工具 | 验证工具参数格式、测试工具权限 |
debug skill | 列出 Skill | 确认 Skill 是否加载、查看加载路径 |
debug rg search | 测试搜索 | 排查搜索不到文件的问题 |
debug file read | 读取文件 | 检查文件内容读取是否包含元数据 |
debug file status | 文件状态 | 查看 Git 状态集成 |
debug paths | 查看路径 | 找日志文件、清空缓存时确认路径 |
debug lsp | 调试 LSP | 排查代码补全/跳转失效问题 |
debug scrap | 查看项目列表 | 找回历史项目 ID |
| 现象 | 原因 | 解决 |
|---|---|---|
command not found | 旧版本 OpenCode | 升级到最新版 |
| 输出内容过多 | JSON 数据量大 | 配合 > debug.txt 重定向到文件查看 |
debug agent 报错 | 未指定 Agent 名称 | 必须加名字,如 opencode debug agent coder |
opencode debug 命令的核心价值在于**"运行时可见性"**: