SuperAPI AI 工具集

codex-agent

智能体与模型

查看项目

更新于 10-15 17:24

技能介绍

该工具通过 Codex CLI 把任务委派给独立的 Codex 会话执行。自动化入口是 headless 子命令 codex exec,最终结果或事件流打印到 stdout。

前置条件:安装 Codex CLI,命令为 npm install -g @openai/codex;完成 Codex 登录认证;建议在目标项目目录运行,或显式传 -C /path/to/project。

新建会话示例:codex exec --json --sandbox workspace-write --skip-git-repo-check --model <flagship> "任务描述"。输出为 JSONL,每行一个事件,可从 thread.started 提取 thread_id,从 item.completed(item.type 为 agent_message)提取 text,从 turn.completed 提取 usage。

多轮会话续接:codex exec resume --json --model <flagship> "thread_id" "后续提问";或用 --last 恢复最近会话,加 --all 可跨目录查找。加 --ephemeral 会不持久化,无法恢复。

代码审查:codex exec review 支持 --uncommitted 审查未提交变更、--base BRANCH 对比分支、--commit SHA 审查指定提交等。

常用参数:--json 输出 JSONL;--output-schema FILE 约束最终消息结构;-o, --output-last-message FILE 写最后消息到文件;-s, --sandbox(read-only / workspace-write / danger-full-access);--full-auto;-C, --cd DIR;-i, --image FILE 附加图片。长 prompt 建议写入文件后用 - 从 stdin 读取,避免卡在 Reading additional input from stdin...。编码任务用 workspace-write,审查与浏览器调研建议 read-only。

限制与注意:prompt 超过约 500 字符或含多行/特殊字符时不建议用位置参数;模型占位符 <flagship>/<mini> 并非真实 ID,需自行查询确认;--ephemeral 不可恢复;--dangerously-bypass-approvals-and-sandbox 极度危险。参考模板文件包括 references/task-prompt-recipes.md、references/review-prompt-recipes.md、references/browser-research-prompt-recipes.md。具体模型 ID、认证方式和价格资料未提供。