Skip to main content
Glama

为什么做 commandcodex?

直接让终端 AI 代理硬敲子 CLI 常踩三个坑:终端沙箱隔离导致找不到 codex/断网、长任务卡死超时、轻信子代理口头“已改好”却留一堆烂尾 diff。

commandcodex 采用 Plugin-First + Thick-Core, Thin-Adapter 架构:

  • Antigravity 当大脑与质检官:负责发散思考、需求翻译施工单、独立检查 git diff 与跑测试、精准打回返工。

  • 宿主机 MCP 当手脚:由 agy 在宿主机直接拉起,天然打通网络与 ~/.codex 凭证,零沙箱摩擦。

  • 极薄抗变动 Codex 适配:只依赖最稳定的 codex exec --json - 与 codex exec resume --json <session_id> -,工作目录走 spawn({ cwd })、Prompt 走 stdin,权限默认 inherit(直接尊重 ~/.codex/config.toml),并支持 extra_args 纯透传与鸭子类型 JSONL 兜底解析。

  • 通用多 Worker 引擎:90% 监工内核与具体 CLI 解耦,支持通过 ~/.commandcodex/workers.json 零代码接入 Claude Code 或任意可执行 CLI。


Related MCP server: Antigravity MCP Bridge

🚀 一键 AI 自动部署(复制到你的 Antigravity CLI)

懒人推荐:直接把下面任意一段 Prompt 复制发给你本机的 Antigravity CLI (agy),它会自己检查环境、克隆仓库、跑通测试、校验并安装插件!

中文版 Prompt(直接复制发送给 agy)

请帮我部署并安装开源项目 commandcodex(https://github.com/multi-zhangyang/commandcodex.git)到本机的 Antigravity CLI(agy):
1. 检查本机环境:确认 Node.js >= 22、agy CLI 已安装,以及 codex CLI(或其他准备被调度的 CLI)可用。
2. 如果 ~/.local/share/commandcodex 不存在,克隆 https://github.com/multi-zhangyang/commandcodex.git 到 ~/.local/share/commandcodex;如果已存在,进入该目录执行 git pull --ff-only 更新到最新。
3. 在仓库目录执行 npm install && npm run build && npm test,确认全部测试通过。
4. 运行 node scripts/install-agy.mjs(如需写入 ~/.local/bin 和 ~/.gemini 请申请必要权限),校验并安装 Antigravity 插件及 commandcodex CLI 软链。
5. 运行 commandcodex doctor 和 agy plugin list --json 验证插件已启用且驱动健康。
6. 完成后提示我重载/重开一次 agy 会话,并告诉我如何用 worker_review 和 commandcodex watch 做第一次试跑。

English Prompt (Copy & paste into your agy session)

Please deploy and install commandcodex (https://github.com/multi-zhangyang/commandcodex.git) into my local Antigravity CLI (agy):
1. Verify prerequisites: Node.js >= 22, `agy` CLI installed, and `codex` CLI (or another target worker CLI) available.
2. Clone https://github.com/multi-zhangyang/commandcodex.git to ~/.local/share/commandcodex (or pull latest if it already exists).
3. Inside that directory, run `npm install && npm run build && npm test` and verify all tests pass.
4. Run `node scripts/install-agy.mjs` to strictly validate and install the Antigravity plugin and symlink `~/.local/bin/commandcodex`.
5. Verify with `commandcodex doctor` and `agy plugin list --json` that the plugin is enabled and drivers are healthy.
6. Tell me to reload/restart my `agy` session and show how to test it with `worker_review` and `commandcodex watch`.

系统架构

flowchart TB
    User["用户 (WSL / Linux / macOS)"] -->|"发散思考 / 拍板方向"| Agy["Antigravity CLI (agy)"]
    User -.->|"分屏实时围观"| Watch["commandcodex watch"]
    User -.->|"随时亲自接管"| Resume["codex resume <session_id>"]

    subgraph Plugin["Antigravity Plugin (commandcodex)"]
        Rules["rules/AGENTS.md (极简路由)"]
        Skill["skills/cli-supervisor/SKILL.md (监工 SOP)"]
        MCPCfg["mcp_config.json (Stdio)"]
    end

    Agy <-->|"MCP Stdio JSON-RPC"| Server["commandcodex MCP Server (7 个通用工具)"]
    Agy -.->|"按需加载"| Skill

    subgraph Core["通用监工内核 (90% 与具体 CLI 解耦)"]
        Server --> JM["JobManager<br/>Auto-Async(35s) / 多写锁 / 3轮熔断 / 进程组清理"]
        JM --> Store["RunStore (~/.commandcodex/runs/)<br/>10 MiB 硬上限 + 按字节窗口读尾部"]
        JM --> Git["GitInspector<br/>独立采集 changed_files + diff --stat"]
        JM --> Reg["DriverRegistry (WorkerDriver + Capabilities)"]
    end

    Reg --> D1["CodexExecDriver (~140行)<br/>exec --json / exec resume --json"]
    Reg --> D2["GenericExecDriver<br/>~/.commandcodex/workers.json 零代码扩展"]
    Store -.->|"fs.watch + 轮询"| Watch

手动安装与常用命令

git clone https://github.com/multi-zhangyang/commandcodex.git ~/.local/share/commandcodex
cd ~/.local/share/commandcodex
npm install
npm run build
npm test
npm run install:agy

安装完成后新开一次 agy 会话即可全局生效。常用终端命令:

commandcodex doctor          # 检查 Node、Codex/其他驱动、agy 与运行日志目录
commandcodex list            # 查看最近任务列表
commandcodex watch [job_id]  # 分屏实时彩色围观 Worker 动态(默认锁定最新运行任务)

MCP 工具列表(7 个高内聚监工工具)

工具名

核心能力

worker_delegate

下发新任务(默认等待 35s,超时自动转后台返回 job_id;同目录写锁保护)

worker_followup

按 job_id 或 session_id 续杯鞭策返工(自动累计返工轮次,默认 3 轮熔断)

worker_review

只读评审,默认 adversarial 对抗式挑刺审查(也可切 standard)

worker_wait

阻塞等待后台任务完成或返回最新阶段进展

worker_status

非阻塞查看单个任务进度或最近任务列表

worker_cancel

按进程组终止卡死/跑偏的后台任务

worker_inspect

按需钻取 summary / last_message / events / stderr / prompt / diff(events/stderr 按字节窗口直接读尾部)


权限预设与环境变量

环境变量

默认值

说明

COMMANDCODEX_PERMISSION_MODE

inherit

inherit(沿用 ~/.codex/config.toml)| read-only(只读覆写)| bypass(全放开免审批)

COMMANDCODEX_EXTRA_ARGS

空

透传给 CLI 的额外参数,支持 JSON 数组或空格分隔字符串(例如 '["--skip-git-repo-check"]')

COMMANDCODEX_CODEX_BIN

codex

Codex 可执行文件名或绝对路径

COMMANDCODEX_RUNS_DIR

~/.commandcodex/runs

运行事件流与产物落盘目录

COMMANDCODEX_MAX_LOG_BYTES

10485760 (10 MiB)

单个任务 events.jsonl / stderr.log 的最大字节上限

COMMANDCODEX_DEFAULT_WAIT_SECONDS

35

Auto-Async 默认同步等待秒数(上限 55s)

COMMANDCODEX_DEFAULT_TIMEOUT_SECONDS

900

单次任务硬超时秒数

COMMANDCODEX_DEFAULT_MAX_REWORK

3

返工熔断上限轮次

COMMANDCODEX_DEFAULT_MODEL

空

可选默认模型覆盖

COMMANDCODEX_WORKERS_FILE

~/.commandcodex/workers.json

通用可配置 CLI Worker 清单路径

COMMANDCODEX_WORKERS_JSON

空

内联 JSON 数组形式声明额外 CLI Worker

小技巧:如果希望全局默认免沙箱/免审批放开权限,安装时传入环境变量即可:

COMMANDCODEX_PERMISSION_MODE=bypass node scripts/install-agy.mjs

零代码扩展其他 CLI Worker

通过 ~/.commandcodex/workers.json(或 COMMANDCODEX_WORKERS_JSON)即可直接接入任意 CLI 工具,无需修改 TypeScript 代码:

[
  {
    "name": "claude",
    "command": "claude",
    "args": ["-p", "--output-format", "stream-json"],
    "readOnlyArgs": ["--permission-mode", "plan"],
    "resumeArgs": ["--resume", "{{session_id}}"],
    "takeoverTemplate": "claude --resume {{session_id}}"
  }
]

如需深度定制事件解析或协议(例如接入 codex app-server),实现 src/drivers/driver.ts 中的 WorkerDriver 接口并在 src/drivers/registry.ts 注册即可复用全套 MCP、Auto-Async、Git 证据采集与 Watch 看板。


License

MIT

Available Tools

7 tools
worker_cancelA

Terminate a running background worker process group and mark the job cancelled.

Inputs: job_id (required).

worker_delegateA

Delegate a bounded coding, refactoring, or debugging task to a CLI worker (default: codex). Runs synchronously up to wait_seconds (default 35s) and seamlessly defers to a background job if still running.

Inputs: cwd (required), task (required), model, worker, +6 more.

worker_followupA

Resume an existing worker session (by job_id or session_id) to request rework, fixes, or follow-up changes. Enforces the rework circuit breaker unless force=true.

Inputs: feedback (required), cwd, force, model, +7 more.

worker_inspectA

Inspect persisted raw artifacts or full git diff for a job without polluting normal briefs.

Inputs: job_id (required), section (required), max_chars, tail_lines.

worker_reviewB

Run a read-only code review (default: skeptical adversarial review) on a directory using a worker CLI.

Inputs: cwd (required), mode, focus, model, +4 more.

worker_statusB

Check non-blocking status of one job_id or list recent jobs.

Inputs: limit, job_id.

worker_waitA

Wait for a running background job to finish (up to wait_seconds, default 45s).

Inputs: job_id (required), wait_seconds.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 7 tools

    Disambiguation4/5

    Each tool maps to a distinct lifecycle action: delegate starts work, followup resumes a session, review is read-only analysis, cancel terminates, inspect exposes raw artifacts. The only mild overlaps are worker_wait vs worker_status (blocking vs non-blocking job polling) and delegate vs followup (both can spawn work), but descriptions make the boundaries clear.

    Naming Consistency5/5

    Uniform worker_<verb> snake_case pattern across all seven tools, with no deviations or mixed casing. The shared prefix also makes the tool family instantly recognizable.

    Tool Count5/5

    Seven tools is well within the sweet spot and each earns its place: dispatch, resumption, review, three job-control operations, and artifact inspection. No redundant or filler tools.

    Completeness4/5

    The async job lifecycle is covered end to end: start, resume, poll, block, cancel, and inspect artifacts. Minor gaps remain, such as no explicit result/output retrieval beyond inspect or job cleanup/history pruning, but agents can work around these.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      Enables a local Codex chat to ask a second opinion, review staged, unstaged, or revision-based diffs, and delegate coding tasks to the Antigravity CLI running in isolated or disposable workspaces. Supports starting, polling, retrieving, and cancelling tasks with returned answers, diffs, changed-file lists, exit codes, and time/output limits, while never auto-applying returned patches.
      8
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Codex or Claude Code to orchestrate persistent Antigravity CLI workers as independent implementers and testers within restricted workspace roots. It supports asynchronous task dispatch, progress polling, result inspection, follow-up messages, and cancellation with bounded, audited local event logging.
      5
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Lets one main agent dispatch and supervise parallel workers, each a Codex CLI or Claude Code process in its own Git worktree. The supervisor checks write-path conflicts before dispatch, runs acceptance commands itself, lands a worker’s changes, and cleans up worktrees. 14 tools, state in SQLite, web board. Formerly codex-supervisor-mcp.
      14
      3
      MIT