ai-engineering-init 1.12.2 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: collaborating-with-codex
3
3
  description: |
4
- OpenAI Codex CLI 协同开发。支持 MCP 原生集成和桥接脚本两种模式。
5
- 默认模型:gpt-5.3-codex
4
+ 与 Codex MCP 协同开发。通过 GuDaStudio/codexmcp 集成,使用 mcp__codex__codex 工具。
5
+ 默认沙箱:read-only(严禁 codex 修改真实代码)。
6
6
 
7
7
  触发场景:
8
8
  - 需要算法实现或复杂逻辑分析
@@ -14,110 +14,128 @@ description: |
14
14
  触发词:Codex、协作、多模型、原型、Diff、算法分析、代码审查、codex协同
15
15
 
16
16
  前置要求:
17
- - 已安装 Codex CLI (npm install -g @openai/codex)
18
- - 已配置 OpenAI API Key (codex auth login)
17
+ - 已通过 `claude mcp add codex -s user --transport stdio -- uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp` 注册
18
+ - ~/.claude/settings.json permissions.allow 已加入 mcp__codex__codex
19
19
  ---
20
20
 
21
- # 与 Codex CLI 协同开发
21
+ # 与 Codex MCP 协同开发
22
22
 
23
- > 两种调用方式:**MCP 原生集成**(推荐)和桥接脚本。默认模型 `gpt-5.3-codex`。
23
+ > 通过 `mcp__codex__codex` 工具直接调用,无需命令行。始终使用 `read-only` 沙箱,要求 codex 只输出 unified diff patch。
24
24
 
25
25
  ---
26
26
 
27
- ## 方式一:MCP 原生集成(推荐)
27
+ ## MCP 工具说明
28
28
 
29
- 已通过 `codex-mcp-server` 注册为 Claude Code 的 MCP 工具,可直接在对话中使用。
29
+ ### 工具名
30
+ `mcp__codex__codex`
30
31
 
31
- ### MCP 工具列表
32
+ ### 参数
32
33
 
33
- | 工具 | 用途 | 示例指令 |
34
- |------|------|---------|
35
- | `codex` | AI 编码助手,支持会话、模型选择 | "用 codex 分析这个函数" |
36
- | `review` | 代码审查(未提交代码、分支、提交) | "用 codex review 检查 main 分支差异" |
37
- | `listSessions` | 查看活跃会话 | "列出 codex 会话" |
38
- | `ping` | 测试连接 | "ping codex" |
39
-
40
- ### MCP 使用示例
34
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
35
+ |------|------|------|--------|------|
36
+ | `PROMPT` | string | | - | 发送给 Codex 的任务指令(建议用英语) |
37
+ | `cd` | Path | | - | 工作目录根路径(必须存在) |
38
+ | `sandbox` | string | | `read-only` | `read-only` / `workspace-write` / `danger-full-access` |
39
+ | `SESSION_ID` | UUID | | None | 继续之前的会话,保持上下文 |
40
+ | `return_all_messages` | bool | ❌ | False | 是否返回推理过程和工具调用详情 |
41
+ | `model` | string | ❌ | None | 指定模型(None 使用用户默认配置) |
42
+ | `image` | List[Path] | ❌ | None | 附加图片文件 |
43
+ | `yolo` | bool | ❌ | False | 跳过沙箱审批(危险,不推荐) |
44
+ | `profile` | string | ❌ | None | 从 `~/.codex/config.toml` 加载的配置名 |
45
+ | `skip_git_repo_check` | bool | ❌ | False | 允许在非 Git 仓库中运行 |
46
+
47
+ ### 返回值
48
+
49
+ ```json
50
+ // 成功
51
+ {
52
+ "success": true,
53
+ "SESSION_ID": "uuid-string", // 必须保存,用于多轮交互
54
+ "agent_messages": "codex回复内容"
55
+ }
56
+
57
+ // 失败
58
+ {
59
+ "success": false,
60
+ "error": "错误信息"
61
+ }
62
+ ```
41
63
 
42
- **基础调用**:直接在 Claude Code 对话中说:
43
- - "用 codex 工具分析 OrderInfoService 的业务逻辑"
44
- - "用 codex review 检查当前未提交的代码变更"
45
- - "用 codex 生成这个方法的单元测试,模型用 gpt-5.3-codex"
64
+ ---
46
65
 
47
- **多轮会话**:codex 工具支持 `sessionId` 参数,自动维持上下文。
66
+ ## 标准协作流程
48
67
 
49
- **模型指定**:调用时传入 `model: "gpt-5.3-codex"` 参数(已配置为默认)。
68
+ ```
69
+ 1. 需求分析阶段
70
+ Claude 形成初步分析 → 告知 codex → codex 完善方案
50
71
 
51
- ### MCP 配置位置
72
+ 2. 编码前(原型阶段)
73
+ 调用 codex(read-only)→ 要求输出 unified diff patch
74
+ Claude 以 diff 为逻辑参考 → 重写为生产级代码
52
75
 
53
- ```
54
- ~/.claude.json projects mcpServers codex-cli
55
- ~/.codex/config.toml → profiles(review/analyze/prototype)
76
+ 3. 编码后(审查阶段)
77
+ 调用 codex review 改动验证需求完成度和代码质量
56
78
  ```
57
79
 
58
80
  ---
59
81
 
60
- ## 方式二:桥接脚本
82
+ ## 调用示例
61
83
 
62
- 适用于需要精细控制参数或后台批量执行的场景。
84
+ ### 场景一:需求分析完善
63
85
 
64
- ### 快速开始
86
+ ```
87
+ PROMPT: "Here is my requirement: [需求描述]. My initial approach: [初步思路].
88
+ Please review and improve the analysis and implementation plan.
89
+ Output: structured analysis with potential risks."
65
90
 
66
- ```bash
67
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
68
- --cd . --model gpt-5.3-codex --PROMPT "Your task"
91
+ cd: /path/to/project
92
+ sandbox: read-only
69
93
  ```
70
94
 
71
- ### 参数说明
95
+ ### 场景二:获取代码原型(Diff)
72
96
 
73
- | 参数 | 类型 | 必填 | 默认值 | 说明 |
74
- |------|------|------|--------|------|
75
- | `--PROMPT` | str | ✅ | - | 发送给 Codex 的任务指令(使用英语) |
76
- | `--cd` | Path | ✅ | - | 工作目录根路径 |
77
- | `--model` | str | ❌ | `gpt-5.3-codex` | 指定模型 |
78
- | `--sandbox` | Literal | ❌ | `read-only` | 沙箱策略 |
79
- | `--SESSION_ID` | UUID | ❌ | `None` | 会话 ID(继续之前的对话) |
80
- | `--profile` | str | ❌ | `None` | Codex profile(review/analyze/prototype) |
81
- | `--return-all-messages` | bool | ❌ | `False` | 返回完整推理信息 |
82
- | `--image` | List[Path] | ❌ | `None` | 附加图片 |
83
- | `--yolo` | bool | ❌ | `False` | 跳过审批(危险) |
84
-
85
- ### 使用示例
97
+ ```
98
+ PROMPT: "Generate a unified diff patch to implement [功能描述].
99
+ File: [目标文件路径]
100
+ Requirements:
101
+ - [要求1]
102
+ - [要求2]
86
103
 
87
- ```bash
88
- # 代码分析(只读)
89
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
90
- --cd . --model gpt-5.3-codex --profile analyze \
91
- --PROMPT "Analyze the four-layer architecture in OrderInfoWebController"
92
-
93
- # 代码审查
94
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
95
- --cd . --model gpt-5.3-codex --profile review \
96
- --PROMPT "Review OrderWebBusiness.java for bugs. OUTPUT: Review with line numbers."
97
-
98
- # 生成 Diff 补丁
99
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
100
- --cd . --model gpt-5.3-codex \
101
- --PROMPT "Generate unified diff to add logging. OUTPUT: Unified Diff Patch ONLY."
102
-
103
- # 多轮会话
104
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
105
- --cd . --model gpt-5.3-codex \
106
- --SESSION_ID "uuid-from-previous" \
107
- --PROMPT "Now write unit tests for the method we discussed"
104
+ IMPORTANT: Output unified diff patch ONLY. Do NOT modify any real files.
105
+ IMPORTANT: All Java comments and SQL COMMENTs MUST be in Chinese."
106
+
107
+ cd: /path/to/project
108
+ sandbox: read-only
108
109
  ```
109
110
 
110
- ---
111
+ ### 场景三:代码审查
112
+
113
+ ```
114
+ PROMPT: "Review the following code changes for correctness, performance, and security.
115
+ [粘贴代码或说明文件路径]
116
+
117
+ Check:
118
+ 1. Logic correctness
119
+ 2. Edge cases
120
+ 3. Performance issues
121
+ 4. Security vulnerabilities
122
+
123
+ Output: review with line numbers and severity (CRITICAL/WARNING/INFO)."
124
+
125
+ cd: /path/to/project
126
+ sandbox: read-only
127
+ ```
111
128
 
112
- ## Codex Profile 配置
129
+ ### 场景四:多轮交互(继续会话)
113
130
 
114
- 已在 `~/.codex/config.toml` 中预设 3 个 profile:
131
+ ```
132
+ // 第一轮
133
+ SESSION_ID: None → 保存返回的 SESSION_ID
115
134
 
116
- | Profile | 模型 | 沙箱 | 推理强度 | 适用场景 |
117
- |---------|------|------|---------|---------|
118
- | `review` | gpt-5.3-codex | read-only | medium | 快速代码审查 |
119
- | `analyze` | gpt-5.3-codex | read-only | high | 深度逻辑分析 |
120
- | `prototype` | gpt-5.3-codex | workspace-write | high | 原型生成 |
135
+ // 第二轮
136
+ SESSION_ID: "上一轮返回的 uuid"
137
+ PROMPT: "Now refine the diff based on the feedback: [反馈内容]"
138
+ ```
121
139
 
122
140
  ---
123
141
 
@@ -125,24 +143,18 @@ python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
125
143
 
126
144
  | 角色 | Claude Code 负责 | Codex 负责 |
127
145
  |------|-----------------|-----------|
128
- | **架构** | 设计、决策、审校 | 分析现有代码 |
129
- | **开发** | 规范重构、最终代码 | 原型生成(Diff) |
130
- | **审查** | 规范检查、最终判定 | 逐文件审查、安全扫描 |
131
- | **调试** | 日志分析、定位 | 深度代码分析、补丁 |
146
+ | **架构** | 设计决策、规范审校 | 分析现有代码结构 |
147
+ | **开发** | 规范重写、最终代码实施 | 输出原型 diff(只读参考) |
148
+ | **审查** | 规范检查、最终判定 | 逐文件逻辑审查 |
149
+ | **调试** | 日志分析、问题定位 | 深度代码分析、补丁建议 |
132
150
 
133
151
  ### 重要约束
134
152
 
135
- 1. **只读优先**: 默认 `read-only`,仅原型生成用 `workspace-write`
136
- 2. **英语 Prompt**: Codex 交互用英语
137
- 3. **中文强制**: 每次 PROMPT 末尾追加:
138
- ```
139
- IMPORTANT LANGUAGE RULES:
140
- - All SQL COMMENT values MUST be in Chinese
141
- - All Java/code comments MUST be in Chinese
142
- - Variable names and class names remain in English
143
- ```
144
- 4. **脏原型思维**: Codex 输出视为草稿,Claude 按项目规范重构
145
- 5. **后台运行**: 长时间任务用 subagent `run_in_background`
153
+ 1. **只读优先**:始终使用 `sandbox="read-only"`
154
+ 2. **英语 Prompt**:与 codex 交互用英语,代码注释要求中文
155
+ 3. **脏原型思维**:codex 输出视为草稿,Claude 按项目规范重构
156
+ 4. **保存 SESSION_ID**:每次调用后记录,多轮对话时传入
157
+ 5. **质疑 codex**:codex 仅供参考,必须有独立判断
146
158
 
147
159
  ---
148
160
 
@@ -150,8 +162,19 @@ python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
150
162
 
151
163
  | 问题 | 解决方案 |
152
164
  |------|---------|
153
- | MCP 工具未出现 | 重启 Claude Code 会话,检查 `~/.claude.json` |
154
- | `codex: command not found` | `npm i -g @openai/codex` 并确认 PATH |
155
- | 模型不对 | 调用时显式传 `model: "gpt-5.3-codex"` |
156
- | MCP 连接超时 | `npx -y codex-mcp-server` 手动测试 |
157
- | 桥接脚本 SESSION_ID 失败 | 检查网络和 API Key |
165
+ | 工具未出现 | 重启 Claude Code,检查 `~/.claude.json` 中 codex 配置 |
166
+ | `cd` 参数报错 | 确认目录存在,使用绝对路径 |
167
+ | 连接超时 | 检查网络,`uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp` 手动测试 |
168
+ | SESSION_ID 失效 | 重新开启新会话(不传 SESSION_ID) |
169
+ | codex 修改了文件 | 确认 `sandbox="read-only"` 已设置 |
170
+
171
+ ## 安装验证
172
+
173
+ ```bash
174
+ # 查看 MCP 配置
175
+ cat ~/.claude.json | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('mcpServers', {}).get('codex', 'not found'))"
176
+
177
+ # 重启后运行
178
+ claude mcp list
179
+ # 期望看到: codex: uvx ... - ✓ Connected
180
+ ```
package/AGENTS.md CHANGED
@@ -84,6 +84,7 @@
84
84
  | `lanhu-design` | 蓝湖设计稿、原型图、蓝湖链接、设计图、切图 |
85
85
  | `task-tracker` | 任务跟踪、进度管理 |
86
86
  | `test-development` | 测试、单元测试 |
87
+ | `auto-test` | API 自动化测试、Hurl、接口测试、测试报告、回归测试 |
87
88
  | `analyze-requirements` | 需求分析全流程编排(原型图/云效任务 → 开发任务清单) |
88
89
  | `fix-bug` | 修复 Bug 全流程编排(排查+修复+提交) |
89
90
  | `bug-detective` | Bug 排查、报错、异常 |
package/CLAUDE.md CHANGED
@@ -94,6 +94,34 @@
94
94
  | 深度分析、仔细思考、全面评估 | `sequential-thinking` |
95
95
  | 最佳实践、官方文档、标准写法 | `context7` |
96
96
  | 打开浏览器、截图、检查元素 | `chrome-devtools` |
97
+ | 代码原型、代码审查、算法分析 | `codex` (mcp__codex__codex) |
98
+
99
+ ## Core Instruction for CodeX MCP
100
+
101
+ 在任何时刻,你必须思考当前过程可以如何与 codex 进行协作,如何调用 Codex 为你提供的 MCP 工具作为你客观全面分析的保障。其中你**务必执行**以下几个步骤:
102
+
103
+ **1** 在你对用户需求形成初步分析后,将用户需求、初始思路告知 codex,并要求其完善需求分析和实施计划。
104
+
105
+ **2** 在实施具体编码任务前,**必须向 codex 索要代码实现原型(要求 codex 仅给出 unified diff patch,严禁对代码做任何真实修改)**。在获取代码原型后,你**只能以此为逻辑参考,再次对代码修改进行重写**,形成企业生产级别、可读性极高、可维护性极高的代码后,才能实施具体编程修改任务。
106
+
107
+ **3** 无论何时,只要完成切实编码行为后,**必须立即使用 codex review 代码改动和对应需求完成程度**。
108
+
109
+ **4** codex 只能给出参考,你**必须有自己的思考,甚至需要对 codex 的回答提出质疑**。尽信书则不如无书,你与 codex 的最终使命都是达成统一、全面、精准的意见,所以你们必须不断争辩以找到通向真理的唯一途径。
110
+
111
+ ### Codex 工具调用规范
112
+
113
+ - **工具名**:`mcp__codex__codex`
114
+ - **必选参数**:`PROMPT`(指令)、`cd`(工作目录,必须存在)
115
+ - **沙箱策略**:始终使用 `sandbox="read-only"`,严禁 codex 修改真实代码
116
+ - **会话管理**:保存每次返回的 `SESSION_ID`,多轮交互时传入以保持上下文
117
+ - **输出约定**:要求 codex 仅输出 unified diff patch,不执行实际文件修改
118
+
119
+ ```
120
+ 标准协作流程:
121
+ 需求分析 → codex 完善方案
122
+ 编码前 → codex 给出 diff 原型(只读参考)
123
+ 编码后 → codex review 改动质量
124
+ ```
97
125
 
98
126
  ## Skills 强制评估
99
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-engineering-init",
3
- "version": "1.12.2",
3
+ "version": "1.14.0",
4
4
  "description": "AI 工程化配置初始化工具 — 一键为 Claude Code、OpenAI Codex 等 AI 工具初始化 Skills 和项目规范",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: collaborating-with-codex
3
3
  description: |
4
- OpenAI Codex CLI 协同开发。支持 MCP 原生集成和桥接脚本两种模式。
5
- 默认模型:gpt-5.3-codex
4
+ 与 Codex MCP 协同开发。通过 GuDaStudio/codexmcp 集成,使用 mcp__codex__codex 工具。
5
+ 默认沙箱:read-only(严禁 codex 修改真实代码)。
6
6
 
7
7
  触发场景:
8
8
  - 需要算法实现或复杂逻辑分析
@@ -14,110 +14,128 @@ description: |
14
14
  触发词:Codex、协作、多模型、原型、Diff、算法分析、代码审查、codex协同
15
15
 
16
16
  前置要求:
17
- - 已安装 Codex CLI (npm install -g @openai/codex)
18
- - 已配置 OpenAI API Key (codex auth login)
17
+ - 已通过 `claude mcp add codex -s user --transport stdio -- uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp` 注册
18
+ - ~/.claude/settings.json permissions.allow 已加入 mcp__codex__codex
19
19
  ---
20
20
 
21
- # 与 Codex CLI 协同开发
21
+ # 与 Codex MCP 协同开发
22
22
 
23
- > 两种调用方式:**MCP 原生集成**(推荐)和桥接脚本。默认模型 `gpt-5.3-codex`。
23
+ > 通过 `mcp__codex__codex` 工具直接调用,无需命令行。始终使用 `read-only` 沙箱,要求 codex 只输出 unified diff patch。
24
24
 
25
25
  ---
26
26
 
27
- ## 方式一:MCP 原生集成(推荐)
27
+ ## MCP 工具说明
28
28
 
29
- 已通过 `codex-mcp-server` 注册为 Claude Code 的 MCP 工具,可直接在对话中使用。
29
+ ### 工具名
30
+ `mcp__codex__codex`
30
31
 
31
- ### MCP 工具列表
32
+ ### 参数
32
33
 
33
- | 工具 | 用途 | 示例指令 |
34
- |------|------|---------|
35
- | `codex` | AI 编码助手,支持会话、模型选择 | "用 codex 分析这个函数" |
36
- | `review` | 代码审查(未提交代码、分支、提交) | "用 codex review 检查 main 分支差异" |
37
- | `listSessions` | 查看活跃会话 | "列出 codex 会话" |
38
- | `ping` | 测试连接 | "ping codex" |
39
-
40
- ### MCP 使用示例
34
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
35
+ |------|------|------|--------|------|
36
+ | `PROMPT` | string | | - | 发送给 Codex 的任务指令(建议用英语) |
37
+ | `cd` | Path | | - | 工作目录根路径(必须存在) |
38
+ | `sandbox` | string | | `read-only` | `read-only` / `workspace-write` / `danger-full-access` |
39
+ | `SESSION_ID` | UUID | | None | 继续之前的会话,保持上下文 |
40
+ | `return_all_messages` | bool | ❌ | False | 是否返回推理过程和工具调用详情 |
41
+ | `model` | string | ❌ | None | 指定模型(None 使用用户默认配置) |
42
+ | `image` | List[Path] | ❌ | None | 附加图片文件 |
43
+ | `yolo` | bool | ❌ | False | 跳过沙箱审批(危险,不推荐) |
44
+ | `profile` | string | ❌ | None | 从 `~/.codex/config.toml` 加载的配置名 |
45
+ | `skip_git_repo_check` | bool | ❌ | False | 允许在非 Git 仓库中运行 |
46
+
47
+ ### 返回值
48
+
49
+ ```json
50
+ // 成功
51
+ {
52
+ "success": true,
53
+ "SESSION_ID": "uuid-string", // 必须保存,用于多轮交互
54
+ "agent_messages": "codex回复内容"
55
+ }
56
+
57
+ // 失败
58
+ {
59
+ "success": false,
60
+ "error": "错误信息"
61
+ }
62
+ ```
41
63
 
42
- **基础调用**:直接在 Claude Code 对话中说:
43
- - "用 codex 工具分析 OrderInfoService 的业务逻辑"
44
- - "用 codex review 检查当前未提交的代码变更"
45
- - "用 codex 生成这个方法的单元测试,模型用 gpt-5.3-codex"
64
+ ---
46
65
 
47
- **多轮会话**:codex 工具支持 `sessionId` 参数,自动维持上下文。
66
+ ## 标准协作流程
48
67
 
49
- **模型指定**:调用时传入 `model: "gpt-5.3-codex"` 参数(已配置为默认)。
68
+ ```
69
+ 1. 需求分析阶段
70
+ Claude 形成初步分析 → 告知 codex → codex 完善方案
50
71
 
51
- ### MCP 配置位置
72
+ 2. 编码前(原型阶段)
73
+ 调用 codex(read-only)→ 要求输出 unified diff patch
74
+ Claude 以 diff 为逻辑参考 → 重写为生产级代码
52
75
 
53
- ```
54
- ~/.claude.json projects mcpServers codex-cli
55
- ~/.codex/config.toml → profiles(review/analyze/prototype)
76
+ 3. 编码后(审查阶段)
77
+ 调用 codex review 改动验证需求完成度和代码质量
56
78
  ```
57
79
 
58
80
  ---
59
81
 
60
- ## 方式二:桥接脚本
82
+ ## 调用示例
61
83
 
62
- 适用于需要精细控制参数或后台批量执行的场景。
84
+ ### 场景一:需求分析完善
63
85
 
64
- ### 快速开始
86
+ ```
87
+ PROMPT: "Here is my requirement: [需求描述]. My initial approach: [初步思路].
88
+ Please review and improve the analysis and implementation plan.
89
+ Output: structured analysis with potential risks."
65
90
 
66
- ```bash
67
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
68
- --cd . --model gpt-5.3-codex --PROMPT "Your task"
91
+ cd: /path/to/project
92
+ sandbox: read-only
69
93
  ```
70
94
 
71
- ### 参数说明
95
+ ### 场景二:获取代码原型(Diff)
72
96
 
73
- | 参数 | 类型 | 必填 | 默认值 | 说明 |
74
- |------|------|------|--------|------|
75
- | `--PROMPT` | str | ✅ | - | 发送给 Codex 的任务指令(使用英语) |
76
- | `--cd` | Path | ✅ | - | 工作目录根路径 |
77
- | `--model` | str | ❌ | `gpt-5.3-codex` | 指定模型 |
78
- | `--sandbox` | Literal | ❌ | `read-only` | 沙箱策略 |
79
- | `--SESSION_ID` | UUID | ❌ | `None` | 会话 ID(继续之前的对话) |
80
- | `--profile` | str | ❌ | `None` | Codex profile(review/analyze/prototype) |
81
- | `--return-all-messages` | bool | ❌ | `False` | 返回完整推理信息 |
82
- | `--image` | List[Path] | ❌ | `None` | 附加图片 |
83
- | `--yolo` | bool | ❌ | `False` | 跳过审批(危险) |
84
-
85
- ### 使用示例
97
+ ```
98
+ PROMPT: "Generate a unified diff patch to implement [功能描述].
99
+ File: [目标文件路径]
100
+ Requirements:
101
+ - [要求1]
102
+ - [要求2]
86
103
 
87
- ```bash
88
- # 代码分析(只读)
89
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
90
- --cd . --model gpt-5.3-codex --profile analyze \
91
- --PROMPT "Analyze the four-layer architecture in OrderInfoWebController"
92
-
93
- # 代码审查
94
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
95
- --cd . --model gpt-5.3-codex --profile review \
96
- --PROMPT "Review OrderWebBusiness.java for bugs. OUTPUT: Review with line numbers."
97
-
98
- # 生成 Diff 补丁
99
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
100
- --cd . --model gpt-5.3-codex \
101
- --PROMPT "Generate unified diff to add logging. OUTPUT: Unified Diff Patch ONLY."
102
-
103
- # 多轮会话
104
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
105
- --cd . --model gpt-5.3-codex \
106
- --SESSION_ID "uuid-from-previous" \
107
- --PROMPT "Now write unit tests for the method we discussed"
104
+ IMPORTANT: Output unified diff patch ONLY. Do NOT modify any real files.
105
+ IMPORTANT: All Java comments and SQL COMMENTs MUST be in Chinese."
106
+
107
+ cd: /path/to/project
108
+ sandbox: read-only
108
109
  ```
109
110
 
110
- ---
111
+ ### 场景三:代码审查
112
+
113
+ ```
114
+ PROMPT: "Review the following code changes for correctness, performance, and security.
115
+ [粘贴代码或说明文件路径]
116
+
117
+ Check:
118
+ 1. Logic correctness
119
+ 2. Edge cases
120
+ 3. Performance issues
121
+ 4. Security vulnerabilities
122
+
123
+ Output: review with line numbers and severity (CRITICAL/WARNING/INFO)."
124
+
125
+ cd: /path/to/project
126
+ sandbox: read-only
127
+ ```
111
128
 
112
- ## Codex Profile 配置
129
+ ### 场景四:多轮交互(继续会话)
113
130
 
114
- 已在 `~/.codex/config.toml` 中预设 3 个 profile:
131
+ ```
132
+ // 第一轮
133
+ SESSION_ID: None → 保存返回的 SESSION_ID
115
134
 
116
- | Profile | 模型 | 沙箱 | 推理强度 | 适用场景 |
117
- |---------|------|------|---------|---------|
118
- | `review` | gpt-5.3-codex | read-only | medium | 快速代码审查 |
119
- | `analyze` | gpt-5.3-codex | read-only | high | 深度逻辑分析 |
120
- | `prototype` | gpt-5.3-codex | workspace-write | high | 原型生成 |
135
+ // 第二轮
136
+ SESSION_ID: "上一轮返回的 uuid"
137
+ PROMPT: "Now refine the diff based on the feedback: [反馈内容]"
138
+ ```
121
139
 
122
140
  ---
123
141
 
@@ -125,24 +143,18 @@ python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
125
143
 
126
144
  | 角色 | Claude Code 负责 | Codex 负责 |
127
145
  |------|-----------------|-----------|
128
- | **架构** | 设计、决策、审校 | 分析现有代码 |
129
- | **开发** | 规范重构、最终代码 | 原型生成(Diff) |
130
- | **审查** | 规范检查、最终判定 | 逐文件审查、安全扫描 |
131
- | **调试** | 日志分析、定位 | 深度代码分析、补丁 |
146
+ | **架构** | 设计决策、规范审校 | 分析现有代码结构 |
147
+ | **开发** | 规范重写、最终代码实施 | 输出原型 diff(只读参考) |
148
+ | **审查** | 规范检查、最终判定 | 逐文件逻辑审查 |
149
+ | **调试** | 日志分析、问题定位 | 深度代码分析、补丁建议 |
132
150
 
133
151
  ### 重要约束
134
152
 
135
- 1. **只读优先**: 默认 `read-only`,仅原型生成用 `workspace-write`
136
- 2. **英语 Prompt**: Codex 交互用英语
137
- 3. **中文强制**: 每次 PROMPT 末尾追加:
138
- ```
139
- IMPORTANT LANGUAGE RULES:
140
- - All SQL COMMENT values MUST be in Chinese
141
- - All Java/code comments MUST be in Chinese
142
- - Variable names and class names remain in English
143
- ```
144
- 4. **脏原型思维**: Codex 输出视为草稿,Claude 按项目规范重构
145
- 5. **后台运行**: 长时间任务用 subagent `run_in_background`
153
+ 1. **只读优先**:始终使用 `sandbox="read-only"`
154
+ 2. **英语 Prompt**:与 codex 交互用英语,代码注释要求中文
155
+ 3. **脏原型思维**:codex 输出视为草稿,Claude 按项目规范重构
156
+ 4. **保存 SESSION_ID**:每次调用后记录,多轮对话时传入
157
+ 5. **质疑 codex**:codex 仅供参考,必须有独立判断
146
158
 
147
159
  ---
148
160
 
@@ -150,8 +162,19 @@ python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
150
162
 
151
163
  | 问题 | 解决方案 |
152
164
  |------|---------|
153
- | MCP 工具未出现 | 重启 Claude Code 会话,检查 `~/.claude.json` |
154
- | `codex: command not found` | `npm i -g @openai/codex` 并确认 PATH |
155
- | 模型不对 | 调用时显式传 `model: "gpt-5.3-codex"` |
156
- | MCP 连接超时 | `npx -y codex-mcp-server` 手动测试 |
157
- | 桥接脚本 SESSION_ID 失败 | 检查网络和 API Key |
165
+ | 工具未出现 | 重启 Claude Code,检查 `~/.claude.json` 中 codex 配置 |
166
+ | `cd` 参数报错 | 确认目录存在,使用绝对路径 |
167
+ | 连接超时 | 检查网络,`uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp` 手动测试 |
168
+ | SESSION_ID 失效 | 重新开启新会话(不传 SESSION_ID) |
169
+ | codex 修改了文件 | 确认 `sandbox="read-only"` 已设置 |
170
+
171
+ ## 安装验证
172
+
173
+ ```bash
174
+ # 查看 MCP 配置
175
+ cat ~/.claude.json | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('mcpServers', {}).get('codex', 'not found'))"
176
+
177
+ # 重启后运行
178
+ claude mcp list
179
+ # 期望看到: codex: uvx ... - ✓ Connected
180
+ ```