/install codex-allinone
Codex All-in-One for ArkClaw
让 ArkClaw / OpenClaw 用户在对话框里完成 Codex CLI 的全部配置 — 不用打开终端、不用写 config.toml、不用记 base_url。
整体流程(决策树)
用户触发本 skill(说"用 codex 帮我..." / "/codex-allinone ..." / 报错 等)
│
▼
┌───────────────────────────┐
│ 运行 scripts/doctor.sh │ ← 每次触发都会运行,检测当前环境状态
└─────────────┬─────────────┘
│
当前配置状态 = ?
│
┌─────────────┼──────────────────────────────────┐
│ │ │
"全新环境" "本 skill 配过" "用户手动配过"
(从未配置) (之前用本 skill 配置的) (有 config.toml 但不是本 skill 写的)
│ │ │
▼ ▼ ▼
路径 ① 路径 ② 路径 ③
首次配置 正常使用(绝大多数情况) 兼容性检查
│ │ │
│ │ ├─ 检查通过 → 保留不动,转到路径 ②
│ │ └─ 检查不通过 → 告知用户具体问题,
│ │ 询问是否用本 skill 重新配置
│ │
问用户选择 自动确保服务就绪
A/B 菜单 然后执行: codex exec "用户的需求"
│
▼
完成配置后
转到路径 ②
三条路径说明
| 路径 | 什么时候走 | 用户需要做什么 |
|---|---|---|
| ① 首次配置 | 环境里从未配过 codex,或用户主动要求重新配置 | 选一次 A/B(AgentPlan 还是第三方),粘贴一次 Key |
| ② 正常使用 | 已经配好了(本 skill 配的,或用户自配且体检通过) | 什么都不用做,直接说编程需求即可 |
| ③ 兼容性检查 | 用户手动写过 config.toml,本 skill 首次遇到 | 如果检查通过:无需操作;如果不通过:选择重配或自己修 |
重要:正常使用时不要打扰用户
当配置已经就绪(路径 ②)时,不允许:
- 复述配置流程
- 解释 skill 在做什么
- 询问"是否需要切换 / 是否需要重新配置"
- 把 skill 的存在感暴露给用户
只做:
- 运行
bash scripts/ensure-relay.sh(自动按当前 profile 启对应端口的 relay,不需要时立即退出) - 执行
cd ~ && codex exec --skip-git-repo-check "用户的完整需求原文" - 把 codex 的输出原样返回给用户
用户体验应该等同于"直接跟 codex 对话",完全感觉不到 skill 的存在。
只有这三种情况允许打扰用户:
- 首次配置(环境全新)
- 兼容性检查不通过,且无法自动修复
- 用户主动说"切换 / 换一家 / 切到 X"
触发方式
- 自然语言:"用 codex 帮我重构 utils.py" / "codex 跑一下这个测试"
- 显式命令:
/codex-allinone \x3C你的编程需求>(强制走本 skill) - 报错触发:用户贴出
command not found: codex/connection refused 444X等
详细流程
Step 0 — 运行 doctor.sh 检测环境
每次触发都先运行 bash scripts/doctor.sh,它会输出一个 JSON,包含:
{
"codex_installed": true,
"codex_version": "0.130.x",
"codex_outdated": false,
"config_state": "clean | managed-by-skill | user-managed",
"active_profile": "agentplan | kimi | deepseek | arkv3 | custom | null",
"user_config_summary": {"model_provider": "...", "model": "..."} | null,
"user_health": {"is_healthy": true/false, "checks": [...], "issues": [...]} | null,
"expected_relay_port": 4446 | 4447 | 4448 | 4449 | null,
"relay_running": true,
"ark_api_key_set": true,
"moonshot_api_key_set": false,
"deepseek_api_key_set": false,
"ark_v3_api_key_set": false,
"custom_api_key_set": false,
"issues": []
}
根据 config_state 决定走哪条路径。
Step 1 — 安装 / 升级 Codex CLI(仅首次需要)
scripts/install.sh 的行为:
| 当前状态 | 行为 |
|---|---|
| 未安装 codex | 通过 npm 安装最新版 |
| 版本低于 0.130 | 升级到最新 |
| 已是最新版 | 跳过,不做任何事 |
Step 2 — 询问用户选择模型服务(仅路径 ① 触发)
向用户输出:
你想用哪种模型来驱动 Codex?
A. 火山方舟 AgentPlan(推荐)
✅ 套餐内额度,无需额外付费
✅ ark-code-latest 智能路由
📋 需要"AgentPlan 控制台"分配的专属 Key
B. 第三方 OpenAI 兼容 Key
✅ 已经有 Kimi / DeepSeek / 自购方舟 Key,或公司自建网关等
📋 需要你自己有这些 Key
请回复 A 或 B。
- 选 A → 引导粘贴 Key → 运行
bash scripts/setup-agentplan.sh "$KEY" - 选 B → 展示二级菜单(具体哪家)→ 运行
bash scripts/setup-thirdparty.sh \x3Cprovider> "$KEY"
配置脚本会自动完成:写 Key → 写 profile → 按需启动 codex-relay → 写自动恢复命令到 .bashrc。如果用户已有 config.toml,会先备份再覆盖。
Step 3 — 兼容性检查(仅路径 ③ 触发)
当 doctor.sh 返回 config_state == "user-managed" 时,说明用户之前手动写过 config.toml。此时读取 user_health 字段:
检查通过(is_healthy == true):
- 不打扰用户,直接当作"已配好",进入正常使用
检查不通过(is_healthy == false):
向用户展示具体问题,并询问:
检测到你已有的 codex 配置存在以下问题:
1. \x3C具体问题描述>
2. \x3C具体问题描述>
你希望:
A. 让本 skill 帮你重新配置(推荐,会先备份你现有的文件)
B. 我自己去修改
请回复 A 或 B。
Step 4 — 正常使用
bash scripts/ensure-relay.sh
cd ~ && codex exec --skip-git-repo-check "用户的完整需求原文"
ensure-relay.sh做什么?
- 读取
~/.codex/active-profile,根据当前 profile 自动启对应端口的 codex-relay- 端口分配:agentplan=4446 / kimi=4447 / deepseek=4448 / custom=4449
- arkv3(直连)和 custom 直连模式立即退出,不耗时
Step 5 — 切换模型服务(用户主动要求时)
bash scripts/switch-profile.sh # 列出已配置的服务
bash scripts/switch-profile.sh kimi # 切换到 Kimi
codex-relay 是什么?
Codex CLI 0.130+ 默认发 OpenAI Responses 协议,而多数模型服务只支持 Chat 协议。codex-relay 是一个轻量的本地服务,负责做协议翻译:
Codex CLI ──(Responses)──→ codex-relay (本机端口) ──(Chat)──→ 上游模型服务
每个 profile 占一个独立端口:
| Profile | 端口 | 是否需要 relay |
|---|---|---|
| agentplan | 4446 | ✅ |
| kimi | 4447 | ✅ |
| deepseek | 4448 | ✅ |
| arkv3 | — | ❌ 直连(原生支持 Responses) |
| custom | 4449 / — | 🔍 自动探测(setup 时 curl /responses 决定) |
custom 路径的探测:POST {base_url}/responses 返回 404 → 不支持 → 走 relay;返回 200/400/401/403/422 → 支持 → 直连。
安装方式:
pip install --user --break-system-packages codex-relay
安装后可通过 codex-relay --help 验证。
健康检查都检查什么?
| 检查项 | 不通过时的具体表现 |
|---|---|
| model_provider 字段是否设置 | Codex 不知道连接哪个服务 |
| base_url 地址是否填写 | Codex 不知道请求发往哪里 |
| wire_api 协议是否有效 | 老版本的 chat_completions 在 0.130 以后已废弃;chat 也已 deprecated,推荐 responses |
| API Key 环境变量是否存在 | 连接时会被拒绝(401 错误) |
| 当前 profile 对应端口的 relay 是否在运行 | 会报 connection refused |
| 是否硬编码了 temperature/top_p | 部分模型不支持,会返回 400 错误 |
Profile 设计
每个模型服务在 ~/.codex/profiles/ 下有一个 .toml 配置文件:
~/.codex/profiles/
├── agentplan.toml — 火山方舟 AgentPlan(经 relay 端口 4446)
├── kimi.toml — Kimi (月之暗面 Moonshot,经 relay 端口 4447)
├── deepseek.toml — DeepSeek(经 relay 端口 4448)
├── arkv3.toml — 火山方舟普通 v3 Key(直连)
└── custom.toml — 自定义 OpenAI 兼容端点(自动探测,直连或经 relay 端口 4449)
~/.codex/config.toml 是一个快捷方式(软链接),指向当前使用的配置文件。切换模型服务 = 把快捷方式指向另一个文件。
必读参考文档
| 场景 | 需要读的文件 |
|---|---|
| 引导用户选择第三方 Key | references/thirdparty-providers.md |
| 用户报错 / 检查不通过 | references/troubleshooting.md |
| 不确定整体流程 | references/routing-flow.md |
安全规则
- 用户的 Key 只保存在
~/.bashrc和~/.codex/profiles/*.toml中(用户家目录内) - 覆盖配置前自动备份到
~/.codex/config.toml.bak.\x3C时间戳> - 不上传任何外部服务,不在日志中记录 Key 明文
不做什么
- ❌ 不尝试连接 OpenAI 官方服务(沙箱网络在境内 IDC,连不上 openai.com)
- ❌ 不自动猜测 Key,所有 Key 必须由用户主动粘贴
- ❌ 不做 Claude Code 的配置(那是另一个 skill)
- ❌ 不在用户没确认前覆盖已有的 config.toml
常用对话示例
| 用户说 | Skill 做什么 |
|---|---|
| "帮我装 codex" / "在 ArkClaw 里用 codex" | 安装 + 引导配置 |
| "/codex-allinone 帮我写个 Python 脚本" | 直接执行(如果已配好) |
| "切换到 Kimi" / "换成 DeepSeek" | 运行 switch-profile.sh |
| "切换模型服务" / "换一家" | 列出已配置的选项 |
| "codex 报 connection refused 444X" | 查 active-profile,跑 ensure-relay.sh |
| "codex 报 401" | 检查对应 profile 的 Key 是否正确 |
| "我现在用的哪家?" | 读取 ~/.codex/active-profile |
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install codex-allinone - After installation, invoke the skill by name or use
/codex-allinone - Provide required inputs per the skill's parameter spec and get structured output
What is Codex All-in-One for ArkClaw?
ArkClaw / OpenClaw 沙箱里一键安装并配置 Codex CLI 的 all-in-one skill。当用户提到 codex、想在 ArkClaw 里用 OpenAI 官方 Coding CLI、提到 ark-code-latest / 火山方舟 AgentPlan / Kimi / DeepSe... It is an AI Agent Skill for Claude Code / OpenClaw, with 101 downloads so far.
How do I install Codex All-in-One for ArkClaw?
Run "/install codex-allinone" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Codex All-in-One for ArkClaw free?
Yes, Codex All-in-One for ArkClaw is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Codex All-in-One for ArkClaw support?
Codex All-in-One for ArkClaw is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Codex All-in-One for ArkClaw?
It is built and maintained by jingjing (@bao2200220); the current version is v1.0.0.