| name | collaborating-with-codex |
| description | [由 collaborating-hub 路由] Codex CLI 后端实现。直接使用请通过 /collab 或 /codex 触发 collaborating-hub。 |
Quick Start
python3 scripts/codex_bridge.py --cd "/path/to/project" --PROMPT "Your task"
Output: JSON with success, SESSION_ID, agent_messages, and optional error.
Agent Role Injection (NEW)
Inject agent roles from ~/.claude/agents/ to customize Codex behavior:
python3 scripts/codex_bridge.py --cd "/project" --agent planner --PROMPT "Plan the auth feature"
python3 scripts/codex_bridge.py --cd "/project" --agent security-reviewer --PROMPT "Review auth.py for vulnerabilities"
python3 scripts/codex_bridge.py --cd "/project" --list-agents --PROMPT ""
Agent 注入优先级
--instructions - 直接传入指令字符串(最高优先级)
--instructions-file - 指定指令文件路径
--agent-file - 指定自定义 agent 文件路径
--agent - 从 ~/.claude/agents/ 加载 agent
Parameters
usage: codex_bridge.py [-h] --PROMPT PROMPT --cd CD
[--sandbox {read-only,workspace-write,danger-full-access}]
[--SESSION_ID SESSION_ID] [--skip-git-repo-check]
[--return-all-messages] [--image IMAGE] [--model MODEL]
[--yolo] [--profile PROFILE]
[--agent AGENT] [--agent-file AGENT_FILE]
[--agent-dir AGENT_DIR] [--list-agents]
[--instructions INSTRUCTIONS] [--instructions-file FILE]
Codex Bridge with Agent Role Injection
Core Options:
--PROMPT PROMPT Instruction for the task to send to codex.
--cd CD Set the workspace root for codex.
--sandbox Sandbox policy. Defaults to `read-only`.
--SESSION_ID Resume a previous session.
--model MODEL Model to use (e.g., gpt-5.2-codex).
Agent Role Injection:
--agent AGENT Agent name from ~/.claude/agents/ (e.g., 'planner').
--agent-file FILE Custom agent file path.
--agent-dir DIR Agent directory. Defaults to ~/.claude/agents/
--list-agents List available agents and exit.
--instructions STR Direct system instructions string.
--instructions-file Path to custom instructions file.
Other Options:
--skip-git-repo-check Allow running outside a Git repository.
--return-all-messages Return all messages including reasoning.
--image IMAGE Attach image files to the prompt.
--yolo Run without approvals or sandboxing.
--profile PROFILE Configuration profile from config.toml.
Multi-turn Sessions
Always capture SESSION_ID from the first response for follow-up:
python3 scripts/codex_bridge.py --cd "/project" --agent architect --PROMPT "Design the API"
python3 scripts/codex_bridge.py --cd "/project" --SESSION_ID "uuid-from-response" --PROMPT "Add error handling"
Common Patterns
Planning with planner agent:
python3 scripts/codex_bridge.py --cd "/project" --agent planner --PROMPT "Plan refactoring of auth module"
Security review:
python3 scripts/codex_bridge.py --cd "/project" --agent security-reviewer --PROMPT "Audit payment.py"
Code review:
python3 scripts/codex_bridge.py --cd "/project" --agent code-reviewer --PROMPT "Review recent changes"
Custom instructions:
python3 scripts/codex_bridge.py --cd "/project" --instructions "你是 Rust 专家,专注于性能优化" --PROMPT "Optimize this function"
Debug with full trace:
python3 scripts/codex_bridge.py --cd "/project" --agent build-error-resolver --PROMPT "Fix build errors" --return-all-messages
Process Monitoring (NEW)
使用 codex_monitor.py 监控和管理 Codex 进程:
python3 scripts/codex_monitor.py --ps
python3 scripts/codex_monitor.py --session latest --messages 20
python3 scripts/codex_monitor.py --session 019c08b7-8d56-7543 --messages 50
python3 scripts/codex_monitor.py --watch
python3 scripts/codex_monitor.py --kill 12345
python3 scripts/codex_monitor.py --kill all
python3 scripts/codex_monitor.py --ps --json
python3 scripts/codex_monitor.py --session latest --json
Monitor 参数
| 参数 | 说明 |
|---|
--ps | 列出运行中的 Codex 进程 |
--kill <PID|all> | 终止进程 |
--session <ID|latest> | 查看会话内容 |
--watch | 实时监控最新会话 |
--messages N | 显示消息数量(默认 20) |
--json | JSON 格式输出 |
Workspace Integration (NEW)
Agent Workspace 提供任务交接与执行日志的持久化存储:
目录结构
~/agent-workspace/
├── config.json
├── projects/{project-slug}/
│ ├── plans/ # 任务计划文档
│ ├── logs/ # 执行日志 (JSONL)
│ └── artifacts/ # 中间产物
└── templates/
使用方式
python3 scripts/codex_bridge.py --cd "/project" \
--project swun-thesis --plan ch3-expansion --task-num 1 \
--PROMPT "Your task"
python3 scripts/codex_bridge.py --cd "/project" --workspace none --PROMPT "Quick task"
Workspace Manager
python3 scripts/workspace_manager.py init --project my-project --path /path/to/project
python3 scripts/workspace_manager.py logs --project swun-thesis --last 10
python3 scripts/workspace_manager.py status --plan ch3-expansion
python3 scripts/workspace_manager.py clean --project swun-thesis --before 30d