词元之母TOK.MOM - 平台充值汇率 1:1 即 1 人民币充值到账 1 美元,支持一个 Key 调用近 600+ 海内外模型,限时特价模型低至 1 折,欢迎上岸!
| 来源 | 内置(默认安装) |
| 路径 | skills/autonomous-ai-agents/opencode |
| 版本 | 1.2.0 |
| 作者 | Hermes Agent |
| 许可证 | MIT |
| 平台 | linux, macos, windows |
| 标签 | Coding-Agent, OpenCode, Autonomous, Refactoring, Code-Review |
| 相关 skill | claude-code, codex, hermes-agent |
npm i -g opencode-ai@latest 或 brew install anomalyco/tap/opencodeopencode auth login 或设置 provider 环境变量(OPENROUTER_API_KEY 等)opencode auth list 应显示至少一个 providerpty=trueterminal(command="which -a opencode")
terminal(command="opencode --version")terminal(command="$HOME/.opencode/bin/opencode run '...'", workdir="~/project", pty=true)opencode run 执行有边界的非交互式任务:terminal(command="opencode run 'Add retry logic to API calls and update tests'", workdir="~/project")-f 附加上下文文件:terminal(command="opencode run 'Review this config for security issues' -f config.yaml -f .env.example", workdir="~/project")--thinking 显示模型思考过程:terminal(command="opencode run 'Debug why tests fail in CI' --thinking", workdir="~/project")terminal(command="opencode run 'Refactor auth module' --model openrouter/anthropic/claude-sonnet-4", workdir="~/project")terminal(command="opencode", workdir="~/project", background=true, pty=true)
# 返回 session_id
# 发送 prompt(提示词)
process(action="submit", session_id="<id>", data="Implement OAuth refresh flow and add tests")
# 监控进度
process(action="poll", session_id="<id>")
process(action="log", session_id="<id>")
# 发送后续输入
process(action="submit", session_id="<id>", data="Now add error handling for token expiry")
# 干净退出 — Ctrl+C
process(action="write", session_id="<id>", data="\x03")
# 或直接终止进程
process(action="kill", session_id="<id>")/exit——它不是有效的 OpenCode 命令,会打开 agent 选择器对话框。请使用 Ctrl+C(\x03)或 process(action="kill") 退出。| 按键 | 操作 |
|---|---|
Enter | 提交消息(如有需要可按两次) |
Tab | 在 agent 之间切换(build/plan) |
Ctrl+P | 打开命令面板 |
Ctrl+X L | 切换会话 |
Ctrl+X M | 切换模型 |
Ctrl+X N | 新建会话 |
Ctrl+X E | 打开编辑器 |
Ctrl+C | 退出 OpenCode |
terminal(command="opencode -c", workdir="~/project", background=true, pty=true) # 继续上次会话
terminal(command="opencode -s ses_abc123", workdir="~/project", background=true, pty=true) # 指定会话| 标志 | 用途 |
|---|---|
run 'prompt' | 单次执行后退出 |
--continue / -c | 继续上次 OpenCode 会话 |
--session <id> / -s | 继续指定会话 |
--agent <name> | 选择 OpenCode agent(build 或 plan) |
--model provider/model | 强制使用指定模型 |
--format json | 机器可读的输出/事件 |
--file <path> / -f | 向消息附加文件 |
--thinking | 显示模型思考块 |
--variant <level> | 推理强度(high、max、minimal) |
--title <name> | 为会话命名 |
--attach <url> | 连接到正在运行的 opencode 服务器 |
terminal(command="opencode --version")terminal(command="opencode auth list")opencode run '...'(无需 pty)。background=true, pty=true 启动 opencode。process(action="poll"|"log") 监控长时间运行的任务。process(action="submit", ...) 响应。process(action="write", data="\x03") 或 process(action="kill") 退出,切勿使用 /exit。terminal(command="opencode pr 42", workdir="~/project", pty=true)terminal(command="REVIEW=$(mktemp -d) && git clone https://github.com/user/repo.git $REVIEW && cd $REVIEW && opencode run 'Review this PR vs main. Report bugs, security risks, test gaps, and style issues.' -f $(git diff origin/main --name-only | head -20 | tr '\n' ' ')", pty=true)terminal(command="opencode run 'Fix issue #101 and commit'", workdir="/tmp/issue-101", background=true, pty=true)
terminal(command="opencode run 'Add parser regression tests and commit'", workdir="/tmp/issue-102", background=true, pty=true)
process(action="list")terminal(command="opencode session list")terminal(command="opencode stats")
terminal(command="opencode stats --days 7 --models anthropic/claude-sonnet-4")opencode(TUI)会话需要 pty=true。opencode run 命令不需要 pty。/exit 不是有效命令——它会打开 agent 选择器。请使用 Ctrl+C 退出 TUI。process(action="log", session_id="<id>")terminal(command="opencode run 'Respond with exactly: OPENCODE_SMOKE_OK'")OPENCODE_SMOKE_OKopencode run——更简单且无需 pty。process 日志中提供进度更新。/exit。