SuperAPI AI 工具集

codex-cli

智能体与模型

查看项目

更新于 10-15 17:26

技能介绍

用途:Codex CLI 是运行在终端中的本地 AI 编程智能体,可在项目目录内读取、编辑和执行代码。适用于交互式开发、代码审查、CI/脚本自动化等场景。

安装与认证:npm install -g @openai/codex。运行 codex 启动 TUI 并通过浏览器认证,或设置 export OPENAI_API_KEY="sk-..." 使用 API 密钥。

基本用法:codex 进入交互式 TUI;codex "Fix the TypeScript errors" 预填提示;codex exec "Run tests and fix failures" 为非交互模式,适合 CI 与脚本,短别名为 codex e。

审批模式(-a):仅支持 untrusted、on-request、never、reject。--full-auto 是 CLI 快捷方式,等价于 -a on-request -s workspace-write,不是有效的 approval_policy 配置值。

沙箱模式(-s):仅支持 read-only、workspace-write、danger-full-access。没有 --no-sandbox 标志或 sandbox = "none"。要完全绕过沙箱需使用 --dangerously-bypass-approvals-and-sandbox(别名 --yolo)。常用组合:codex --full-auto "task";codex -a never -s workspace-write "task";codex -s read-only "Review the codebase"。

配置:使用 TOML 格式的 ~/.codex/config.toml(非 config.json)。可设置 model、approval_policy、[sandbox_workspace_write]、[features]、[tui] 等。配置优先级由高到低:CLI 标志、项目 .codex/config.toml(仅受信任项目)、用户配置、系统默认。Profiles 使用 [profiles.<name>],通过 codex --profile ci 或 -p ci 调用。

非交互模式:codex exec 支持 --full-auto、--model、--path、--json、--resume 等选项,可用于 GitHub Actions(配合 OPENAI_API_KEY 密钥)。

TUI 命令与快捷键:/status、/permissions、/model、/clear、/copy、/plan、/review、/mcp、/agent、/feedback、/logout;Enter 注入新指令,Tab 排队后续指令,Esc Esc 编辑上一条消息,!command 运行本地 shell 命令。

MCP 与技能:可通过 [mcp_servers.<name>] 配置第三方工具;codex mcp 子命令可将 Codex 作为 MCP 服务器运行(不是 --mcp-server 标志)。技能存放于 .codex/skills/,在 TUI 中用 $skill-name 引用。网络默认在沙箱中禁用,可用 -c 'sandbox_workspace_write.network_access=true' 开启。

限制与说明:资料未提供具体价格、计费方式及模型可用性细节,相关事实暂未提供。使用前请核对官方参考文档 https://developers.openai.com/codex/cli/reference/。