Skip to content

Commit 4784e5a

Browse files
committed
feat: add bilingual native debug flow
1 parent b65811b commit 4784e5a

19 files changed

Lines changed: 451 additions & 36 deletions

File tree

‎.codex-plugin/plugin.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codex-debug-plugin",
3-
"version": "0.1.0+codex.20260831162256",
3+
"version": "0.1.0+codex.20260831163144",
44
"description": "Evidence-driven debugging for Codex with a native macOS human reproduction gate.",
55
"author": {
66
"name": "Jay Pan"
@@ -33,7 +33,7 @@
3333
"composerIcon": "./assets/icon.png",
3434
"logo": "./assets/logo.png",
3535
"screenshots": [
36-
"./assets/debug-dialog.png"
36+
"./assets/debug-dialog-en.png"
3737
]
3838
},
3939
"mcpServers": "./.mcp.json"

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ jobs:
3030
- name: Check shell scripts
3131
run: zsh -n scripts/*.zsh
3232

33+
- name: Verify bilingual documentation assets
34+
run: |
35+
test -s README.md
36+
test -s README.zh-CN.md
37+
test -s assets/debug-dialog-en.png
38+
test -s assets/debug-dialog-zh-CN.png
39+
test "$(sips -g pixelWidth assets/debug-dialog-en.png | awk '/pixelWidth/ {print $2}')" -ge 1400
40+
test "$(sips -g pixelWidth assets/debug-dialog-zh-CN.png | awk '/pixelWidth/ {print $2}')" -ge 1400
41+
grep -q './assets/debug-dialog-en.png' README.md
42+
grep -q './assets/debug-dialog-zh-CN.png' README.zh-CN.md
43+
3344
- name: Build native companion
3445
run: swift build -c release --package-path native
3546

‎CONTRIBUTING.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ cd ~/plugins/codex-debug-plugin
3535
| Debug workflow | `skills/evidence-debugging/` | hypotheses, instrumentation, verification, cleanup |
3636
| Distribution | `companion/`, `scripts/` | Universal 2 app, installation, launchd, smoke tests |
3737

38+
Native controls support English and Simplified Chinese. Keep user-provided titles, context, steps, and expected evidence in the same language selected through the MCP `language` field.
39+
3840
## Validation
3941

4042
Run the checks relevant to your change before opening a pull request:
@@ -56,6 +58,16 @@ file "companion/Codex Debug Dialog.app/Contents/MacOS/CodexDebugDialog"
5658

5759
The final executable must contain both `arm64` and `x86_64` architectures.
5860

61+
For native UI changes, install the rebuilt companion and inspect both language variants:
62+
63+
```zsh
64+
./scripts/install-macos-companion.zsh
65+
./scripts/preview-dialog.py --language en
66+
./scripts/preview-dialog.py --language zh-CN
67+
```
68+
69+
Commit lossless Retina PNG screenshots for user-visible UI changes. Do not upscale or substitute generated mockups for the real app.
70+
5971
## Pull Request Standard
6072

6173
A strong pull request includes:

‎README.md‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<div align="center">
2+
<p><strong>English</strong> · <a href="./README.zh-CN.md">简体中文</a></p>
3+
24
<img src="./assets/icon.png" width="132" alt="Codex Debug Agent icon" />
35

46
<h1>Codex Debug Agent</h1>
@@ -35,7 +37,7 @@ Codex can read code and run tests, but some bugs only appear after a real person
3537
It turns debugging into a falsifiable evidence loop: form competing hypotheses, add the smallest useful probes, pause for a real reproduction when needed, classify the evidence, apply one supported fix, and verify the exact path again.
3638

3739
<p align="center">
38-
<img src="./assets/debug-dialog.png" width="920" alt="Native macOS reproduction dialog showing debugging steps, notes, and decision controls" />
40+
<img src="./assets/debug-dialog-en.png" width="920" alt="Native macOS reproduction dialog showing English debugging steps, notes, and decision controls" />
3941
</p>
4042

4143
## Why this exists
@@ -55,6 +57,7 @@ Most AI debugging fails in a predictable way: it sees a symptom, guesses a cause
5557

5658
- **Evidence-first debugging** — hypothesis IDs, targeted runtime probes, and explicit `CONFIRMED`, `REJECTED`, or `INCONCLUSIVE` outcomes.
5759
- **Native Human Gate** — a focused SwiftUI dialog for reproduction steps, expected evidence, notes, and the next debugging decision.
60+
- **English and Simplified Chinese** — the Agent selects `en` or `zh-CN` from the conversation language and keeps native controls and reproduction content consistent.
5861
- **Real task suspension** — Codex directly awaits the MCP result instead of polling a detached helper or pretending to pause.
5962
- **Local visual evidence** — paste screenshots or screen recordings with `⌘V`; attachments remain on the Mac.
6063
- **Quiet by design** — the companion uses a launchd-activated Unix socket and stays exited while idle.
@@ -87,6 +90,8 @@ Open a new Codex task so the Skill and MCP tools are loaded, then ask:
8790

8891
> Debug this reproducible issue using runtime evidence. Pause and show the native reproduction dialog when you need me.
8992
93+
The Agent passes `language: en` for English conversations and `language: zh-CN` for Simplified Chinese conversations. `auto` follows the preferred macOS language when no preference is known.
94+
9095
### Verify
9196

9297
```zsh
@@ -134,7 +139,7 @@ codex-debug-plugin/
134139
├── scripts/ # Register, build, install, health-check, and smoke tests
135140
├── skills/
136141
│ └── evidence-debugging/ # Debugging workflow and runtime protocols
137-
└── assets/ # Icon and product screenshot
142+
└── assets/ # Icon and high-resolution bilingual screenshots
138143
```
139144

140145
## Native App
@@ -199,10 +204,3 @@ zsh -n scripts/*.zsh
199204
## License
200205

201206
[MIT](./LICENSE) © 2026 Jay Pan
202-
203-
<details>
204-
<summary><strong>中文简介</strong></summary>
205-
206-
Codex Debug Agent 是一个面向 Codex 的运行时证据调试插件。它通过“可证伪假设 → 最小埋点 → 真实复现 → 证据分类 → 最小修复 → 前后验证”的闭环减少猜测式改代码;当必须由用户操作时,会弹出原生 macOS 窗口并让当前 Codex 任务真正挂起等待,支持通过 `⌘V` 添加本地截图或录屏证据。
207-
208-
</details>

‎README.zh-CN.md‎

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
<div align="center">
2+
<p><a href="./README.md">English</a> · <strong>简体中文</strong></p>
3+
4+
<img src="./assets/icon.png" width="132" alt="Codex Debug Agent 图标" />
5+
6+
<h1>Codex Debug Agent</h1>
7+
8+
<p><strong>用证据调试,而不是靠猜。</strong></p>
9+
<p>
10+
面向 Codex 的运行时证据调试插件,提供原生 macOS Human Gate、<br />
11+
本地图片/视频证据,以及最长 24 小时的真实任务挂起。
12+
</p>
13+
14+
<p>
15+
<a href="https://github.com/pj-workspace/codex-debug-plugin/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/pj-workspace/codex-debug-plugin/actions/workflows/ci.yml/badge.svg" /></a>
16+
<img alt="GitHub stars" src="https://img.shields.io/github/stars/pj-workspace/codex-debug-plugin?style=flat-square&color=111111" />
17+
<img alt="Codex Plugin" src="https://img.shields.io/badge/Codex-Plugin-111111?style=flat-square&logo=openai&logoColor=white" />
18+
<img alt="macOS 14+" src="https://img.shields.io/badge/macOS-14%2B-111111?style=flat-square&logo=apple&logoColor=white" />
19+
<img alt="Universal 2" src="https://img.shields.io/badge/App-Universal%202-111111?style=flat-square" />
20+
<img alt="MIT License" src="https://img.shields.io/badge/License-MIT-111111?style=flat-square" />
21+
</p>
22+
23+
<p>
24+
<a href="#快速开始"><strong>快速开始</strong></a> ·
25+
<a href="#工作原理">工作原理</a> ·
26+
<a href="#系统架构">系统架构</a> ·
27+
<a href="#隐私与安全">隐私与安全</a> ·
28+
<a href="https://github.com/pj-workspace/codex-debug-plugin/issues">反馈问题</a>
29+
</p>
30+
</div>
31+
32+
---
33+
34+
Codex 可以阅读源码、运行测试,但有些 Bug 只会在真人登录、拖拽文件、授予权限或完成特定 UI 操作后出现。Codex Debug Agent 用一个可验证的 Human-in-the-loop 调试闭环补齐了这段能力。
35+
36+
它把调试流程变成:提出可证伪假设、添加最小运行时探针、在必要时等待真人复现、根据证据分类假设、只实施被证据支持的修复,并沿同一路径完成修复前后验证。
37+
38+
<p align="center">
39+
<img src="./assets/debug-dialog-zh-CN.png" width="920" alt="中文原生 macOS 调试复现窗口,包含复现步骤、补充说明和决策按钮" />
40+
</p>
41+
42+
## 为什么需要它
43+
44+
很多 AI 调试会重复同一种失败模式:看到现象、猜测原因,然后立即改代码。本插件改变了默认行为。
45+
46+
| 常见 Agent 调试 | Codex Debug Agent |
47+
| --- | --- |
48+
| 从现象直接跳到补丁 | 先建立可证伪的竞争假设 |
49+
| 把编译通过当作修复证明 | 必须获得原始失败路径的证据 |
50+
| 让用户在聊天里回复“完成” | 弹出结构化 Swift 原生 Human Gate |
51+
| 等待用户时丢失任务上下文 | MCP 调用最长挂起 24 小时 |
52+
| 手动把截图贴回聊天 | 输入框支持通过 `⌘V` 添加图片或视频 |
53+
| 调试完成后遗留临时日志 | 修复后验证,再清理探针和会话产物 |
54+
55+
## 核心能力
56+
57+
- **证据优先**:使用 hypothesis ID、定向运行时探针以及 `CONFIRMED`、`REJECTED`、`INCONCLUSIVE` 分类。
58+
- **原生 Human Gate**:SwiftUI 窗口展示复现步骤、目标证据、补充说明和下一步决策。
59+
- **真实任务挂起**:当前 Codex 任务直接等待 MCP 结果,不通过 detached shell 假装暂停。
60+
- **中英文双语**:Agent 根据对话语言选择 `en` 或 `zh-CN`,原生控件和复现内容保持同一种语言。
61+
- **本地视觉证据**:通过 `⌘V` 粘贴截图或录屏,附件始终留在本机。
62+
- **无感常驻**:launchd 通过 Unix socket 按需唤起 App,空闲时进程自动退出。
63+
- **修复前后验证**:使用同一复现路径对比 `pre-fix` 和 `post-fix` 证据。
64+
- **完整开源**:Swift App、Python MCP、Debug Skill、构建脚本和 Universal 2 App 均在仓库中。
65+
66+
## 快速开始
67+
68+
### 环境要求
69+
70+
- macOS 14 或更高版本
71+
- 支持本地插件的 Codex
72+
- [`uv`](https://docs.astral.sh/uv/) 或 Python 3.11+
73+
74+
仓库内置的 Universal 2 App 同时支持 Apple Silicon 与 Intel Mac。普通安装不需要 Xcode。
75+
76+
### 安装
77+
78+
将仓库克隆到个人插件目录并运行安装器:
79+
80+
```zsh
81+
git clone https://github.com/pj-workspace/codex-debug-plugin.git ~/plugins/codex-debug-plugin
82+
cd ~/plugins/codex-debug-plugin
83+
./scripts/install-plugin.zsh
84+
```
85+
86+
安装器会备份现有 personal marketplace、注册插件、安装原生 App,并在 Codex 中启用插件。
87+
88+
安装完成后新建一个 Codex 任务,然后输入:
89+
90+
> 使用运行时证据调试这个可复现问题。当需要我操作时,挂起任务并弹出原生复现窗口。
91+
92+
中文对话会传入 `language: zh-CN`,英文对话会传入 `language: en`。只有无法判断用户偏好时才使用 `auto` 跟随 macOS 首选语言。
93+
94+
### 验证安装
95+
96+
```zsh
97+
uv run --with 'mcp>=1.25,<2' ./scripts/smoke-test-mcp.py
98+
```
99+
100+
健康的安装会返回 `request_debug_decision` 与 `ping_debug_dialog` 两个 MCP 工具。
101+
102+
## 工作原理
103+
104+
1. **定义失败行为**:明确最短真实复现路径和期望结果。
105+
2. **建立竞争假设**:通常从不同子系统提出 3–5 个解释。
106+
3. **最小化埋点**:只添加能够区分这些假设的探针。
107+
4. **真实复现**:Codex 自主执行,或在必须由用户操作时打开原生 Human Gate。
108+
5. **证据分类**:用具体运行时观察确认、排除或暂时保留每个假设。
109+
6. **实施最小修复**:只修改被证据支持的行为。
110+
7. **验证并清理**:重复同一条路径,对比修复前后结果,再删除临时探针。
111+
112+
## 系统架构
113+
114+
```mermaid
115+
flowchart LR
116+
C[Codex] --> S[Evidence Debugging Skill]
117+
S --> P[运行时探针]
118+
P --> A[被调试应用]
119+
S --> M[stdio MCP Server]
120+
M --> U[用户级 Unix Socket]
121+
U --> L[launchd 按需唤起]
122+
L --> D[Swift 原生窗口]
123+
H[真人复现] --> D
124+
D -->|决策、说明、本地附件| M
125+
M -->|结构化 MCP 结果| C
126+
```
127+
128+
MCP Server 不会启动一个脱离任务的伪交互进程。当前 Codex 任务会直接调用 `request_debug_decision`,直到用户选择操作、取消或达到 24 小时超时后才恢复。
129+
130+
## 仓库结构
131+
132+
```text
133+
codex-debug-plugin/
134+
├── .codex-plugin/ # Codex Plugin manifest
135+
├── companion/ # 已签名的 Universal 2 App Bundle
136+
├── mcp/ # Python stdio MCP Server
137+
├── native/ # SwiftUI 源码与 launchd 配置
138+
├── scripts/ # 注册、构建、安装、健康检查与截图预览
139+
├── skills/
140+
│ └── evidence-debugging/ # 调试工作流与运行时协议
141+
└── assets/ # 图标和中英文高清产品截图
142+
```
143+
144+
## 原生 App
145+
146+
仓库直接包含 ad-hoc 签名的 Universal 2 App:
147+
148+
```text
149+
companion/Codex Debug Dialog.app
150+
```
151+
152+
使用 Swift 5.10+ 从源码重新构建:
153+
154+
```zsh
155+
./scripts/build-macos-companion.zsh
156+
```
157+
158+
安装器优先使用仓库内置 App;只有 App Bundle 不存在时才回退到本地源码构建。
159+
160+
## 隐私与安全
161+
162+
- MCP 与 App 仅通过本机用户级 Unix-domain socket 通信。
163+
- 图片和视频保留在本地路径,插件不会主动上传或转发。
164+
- Skill 禁止记录 Token、密码、Cookie、完整请求体或其他敏感数据。
165+
- 运行时探针只属于当前调试会话,并必须在验证完成后删除。
166+
- Helper 作为用户 LaunchAgent 运行,不使用 root 或系统 LaunchDaemon。
167+
- Socket、LaunchAgent 和 Codex 配置均使用用户级限制权限。
168+
169+
## 当前边界
170+
171+
当前版本提供证据调试工作流、双语原生复现窗口、附件回传和 macOS 本地生命周期管理。浏览器 Console/Network 自动采集、IDE 断点适配、Codex 重启后的会话恢复,以及非 macOS companion 尚未实现。
172+
173+
## Roadmap
174+
175+
- [ ] 自动采集浏览器 Console 与 Network 证据
176+
- [ ] IDE breakpoint / Debug Adapter 集成
177+
- [ ] Codex 重启后的持久化会话恢复
178+
- [ ] 更强的图片与视频证据分析
179+
- [ ] Apple Developer ID 签名与 notarization
180+
- [ ] Windows 与 Linux Human Gate companion
181+
182+
## 参与贡献
183+
184+
欢迎提交 Issue 和聚焦的 Pull Request。较大改动前请先阅读 [CONTRIBUTING.md](./CONTRIBUTING.md)。项目的核心原则是:**只有原始失败路径获得修复前后证据,修复才算被证明。**
185+
186+
开发验证命令:
187+
188+
```zsh
189+
./scripts/build-macos-companion.zsh
190+
uv run --with 'mcp>=1.25,<2' ./scripts/smoke-test-mcp.py
191+
python3 -m py_compile mcp/src/debug_dialog_mcp/*.py scripts/*.py
192+
zsh -n scripts/*.zsh
193+
```
194+
195+
## 社区
196+
197+
- [Bug 与 Feature Request](https://github.com/pj-workspace/codex-debug-plugin/issues)
198+
- [问题与设计讨论](https://github.com/pj-workspace/codex-debug-plugin/discussions)
199+
- [贡献指南](./CONTRIBUTING.md)
200+
- [安全策略](./SECURITY.md)
201+
- [社区行为准则](./CODE_OF_CONDUCT.md)
202+
203+
## License
204+
205+
[MIT](./LICENSE) © 2026 Jay Pan

‎assets/debug-dialog-en.png‎

455 KB
Loading

‎assets/debug-dialog-zh-CN.png‎

441 KB
Loading

‎assets/debug-dialog.png‎

-112 KB
Binary file not shown.

‎companion/Codex Debug Dialog.app/Contents/Info.plist‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
6-
<string>zh_CN</string>
6+
<string>en</string>
77
<key>CFBundleDisplayName</key>
88
<string>Codex Debug Dialog</string>
99
<key>CFBundleExecutable</key>
1.08 KB
Binary file not shown.

0 commit comments

Comments
 (0)