@qqq123456789/codex-doctor 0.2.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.
- package/LICENSE +21 -0
- package/README.en.md +86 -0
- package/README.md +132 -0
- package/docs/01-installation.en.md +102 -0
- package/docs/01-installation.md +101 -0
- package/docs/02-login-auth.en.md +121 -0
- package/docs/02-login-auth.md +121 -0
- package/docs/03-network-proxy.en.md +96 -0
- package/docs/03-network-proxy.md +96 -0
- package/docs/04-config.en.md +118 -0
- package/docs/04-config.md +120 -0
- package/docs/05-models-limits.en.md +51 -0
- package/docs/05-models-limits.md +51 -0
- package/docs/06-sandbox-windows.en.md +74 -0
- package/docs/06-sandbox-windows.md +74 -0
- package/docs/07-mcp.en.md +55 -0
- package/docs/07-mcp.md +57 -0
- package/docs/08-errors-quickref.en.md +53 -0
- package/docs/08-errors-quickref.md +55 -0
- package/docs/09-maintenance.en.md +77 -0
- package/docs/09-maintenance.md +78 -0
- package/docs/10-ide-vscode.en.md +63 -0
- package/docs/10-ide-vscode.md +63 -0
- package/docs/11-tips.en.md +51 -0
- package/docs/11-tips.md +51 -0
- package/docs/12-walkthrough.en.md +79 -0
- package/docs/12-walkthrough.md +79 -0
- package/docs/13-codex-doctor.en.md +63 -0
- package/docs/13-codex-doctor.md +63 -0
- package/docs/releases.md +59 -0
- package/package.json +25 -0
- package/tool/checks.mjs +335 -0
- package/tool/clean.mjs +72 -0
- package/tool/cli.mjs +162 -0
- package/tool/ops.mjs +179 -0
- package/tool/util.mjs +55 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# 10 · IDE 集成(VS Code / Cursor)
|
|
2
|
+
|
|
3
|
+
> 关键词:插件装不上、插件里 401、插件配置不生效、插件和终端行为不一致
|
|
4
|
+
>
|
|
5
|
+
> English version: [10-ide-vscode.en.md](10-ide-vscode.en.md)
|
|
6
|
+
|
|
7
|
+
## 先搞清架构,排障不走弯路
|
|
8
|
+
|
|
9
|
+
- IDE 扩展和 CLI **共享同一份** `~/.codex`(`config.toml`、`auth.json`)——所以 [02 登录与认证](02-login-auth.md)、[04 config.toml](04-config.md) 里的排障方法对插件同样适用;
|
|
10
|
+
- 插件与 CLI 是**两个独立的发布物**:CLI 升级了插件不一定跟着升级,反之亦然;
|
|
11
|
+
- 排障第一步永远是把两边版本都记下来:终端 `codex --version` + 插件面板里的版本号。
|
|
12
|
+
|
|
13
|
+
## 常见问题
|
|
14
|
+
|
|
15
|
+
### 插件反复要求登录 / 登录成功后仍 401
|
|
16
|
+
|
|
17
|
+
1. 先在终端跑一遍 [02 的 401 决策树](02-login-auth.md)——凭据是共享的,CLI 侧不通插件必然不通;
|
|
18
|
+
2. CLI 侧正常、只有插件异常时:执行「Developer: Reload Window」让插件刷新缓存的凭据;
|
|
19
|
+
3. 仍不行:删除 `~/.codex/auth.json`,然后**在插件的登录入口里**重新登录(而不是先在终端登);
|
|
20
|
+
4. 多个 IDE(VS Code + Cursor)共用同一账号时,一边刷新 token 可能让另一边会话失效——在报 401 的那个 IDE 里重登一次即可。
|
|
21
|
+
|
|
22
|
+
### 改了配置,插件里不生效
|
|
23
|
+
|
|
24
|
+
- `config.toml` 是共享的,但**已开启的会话不会热加载**——在插件里新开一个对话;
|
|
25
|
+
- 重要坑:从图形界面启动 IDE 时,进程读不到 shell 配置文件(`.bashrc` / PowerShell `$PROFILE`)里的环境变量。依赖环境变量的东西——`OPENAI_BASE_URL`、代理、MCP 的 `env`——要么写进 `config.toml` / 插件设置,要么从 IDE 启动器里配,指望终端里 `export` 过是不行的。
|
|
26
|
+
|
|
27
|
+
### 插件里模型的行为和终端不一致
|
|
28
|
+
|
|
29
|
+
- 确认 IDE 实际运行在哪个环境:Windows 原生还是 WSL Remote(见 [06](06-sandbox-windows.md))——两边可能装了**不同版本的 CLI**、不同的默认 shell;
|
|
30
|
+
- WSL 用户推荐路径:装「WSL」扩展 → VS Code 连入 WSL → 在 WSL 内安装 CLI 和插件,行为与 Linux 一致;
|
|
31
|
+
- 在插件里用 `/status`,和终端里的 `/status` 输出对比,差异点就是问题所在。
|
|
32
|
+
|
|
33
|
+
### Windows 版选了 WSL agent 后进不去 / 崩溃
|
|
34
|
+
|
|
35
|
+
Codex 的「在 WSL 中运行」开关状态保存在 `C:\Users\<你>\.codex\codex-global-state.json`:
|
|
36
|
+
|
|
37
|
+
1. 完全退出 Codex / IDE;
|
|
38
|
+
2. 编辑该文件,把 `runCodexInWindowsSubsystemForLinux` 改回 `false`(或直接删除该文件让应用重建默认值);
|
|
39
|
+
3. 把 Microsoft Store 里的 WSL 相关组件与扩展更新到最新再重启——旧版本组合有崩溃案例(参考 [openai/codex #13699](https://github.com/openai/codex/issues/13699))。
|
|
40
|
+
|
|
41
|
+
### 代理:终端能用,插件不通
|
|
42
|
+
|
|
43
|
+
IDE 启动的 codex 进程继承的是 **IDE 的环境**,不是你终端的环境:
|
|
44
|
+
|
|
45
|
+
1. 先在 VS Code 集成终端里跑 [03 的连通性测试](03-network-proxy.md)——终端通、插件不通,基本就是环境差异;
|
|
46
|
+
2. 解决:把代理配在系统层面(对 GUI 程序生效),或在 IDE 设置里指定代理,或让 IDE 从登录 shell 启动(VS Code 设置 `terminal.integrated.inheritEnv` 等);
|
|
47
|
+
3. 改完重启 IDE(不只是重开窗口)。
|
|
48
|
+
|
|
49
|
+
### 日志在哪看
|
|
50
|
+
|
|
51
|
+
- VS Code:Output 面板 → 下拉选择 Codex 的输出通道;
|
|
52
|
+
- CLI 侧:`~/.codex/log/`(见 [09](09-maintenance.md));
|
|
53
|
+
- 提 Issue 前两边都翻一遍,很多"插件 bug"其实是 CLI 报错被插件吞掉了。
|
|
54
|
+
|
|
55
|
+
### 更新与降级
|
|
56
|
+
|
|
57
|
+
- 插件:扩展面板更新;想回退用「Install Another Version…」;
|
|
58
|
+
- CLI:`npm install -g @openai/codex@<版本号>`(见 [01](01-installation.md));
|
|
59
|
+
- 升级后出问题时,先固定一边版本二分定位是插件还是 CLI 引入的。
|
|
60
|
+
|
|
61
|
+
## Cursor 及其他 fork
|
|
62
|
+
|
|
63
|
+
排查思路完全同上(共享 `~/.codex`、共享凭据与配置)。个别 IDE 版本对扩展 API 的兼容差异可能导致插件异常:先在**原版 VS Code** 里复测一次,排除 IDE 差异之后再定位,能少走很多弯路。
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
English | [中文](11-tips.md)
|
|
2
|
+
|
|
3
|
+
# 11 · Efficiency Tips: Slash Commands, Project Memory & Scripting
|
|
4
|
+
|
|
5
|
+
> Not troubleshooting — using Codex faster, cheaper, steadier. Exact commands depend on your version's `/help` output; Codex iterates fast.
|
|
6
|
+
|
|
7
|
+
## TUI slash commands cheat sheet
|
|
8
|
+
|
|
9
|
+
Type `/` in the interactive UI to see all commands. The most-used ones:
|
|
10
|
+
|
|
11
|
+
| Command | Purpose |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `/status` | Current model, provider, approval/sandbox mode — troubleshooting step one (see [08](08-errors-quickref.en.md)) |
|
|
14
|
+
| `/model` | Switch models (see [05](05-models-limits.en.md)) |
|
|
15
|
+
| `/init` | Generate a starter `AGENTS.md` for the current project |
|
|
16
|
+
| `/logout` | Clear login state — common in 401 troubleshooting (see [02](02-login-auth.en.md)) |
|
|
17
|
+
| `/help` | The full command list |
|
|
18
|
+
|
|
19
|
+
## AGENTS.md: project memory
|
|
20
|
+
|
|
21
|
+
Codex reads instruction files (`AGENTS.md`) for every task; a project-root file takes precedence over the user-global one (`~/.codex/AGENTS.md`). Good things to put there:
|
|
22
|
+
|
|
23
|
+
- **Project conventions**: build/test commands, code style, directory layout;
|
|
24
|
+
- **Boundaries**: directories not to touch, actions that require asking first;
|
|
25
|
+
- **Known traps**: project-specific quirks you've already hit — so it never hits them again.
|
|
26
|
+
|
|
27
|
+
Three rules:
|
|
28
|
+
|
|
29
|
+
1. **Keep it lean** — it enters the context every turn; verbose filler costs quota and dilutes what matters;
|
|
30
|
+
2. Generate a starter with `/init`, then prune it down to what you actually want;
|
|
31
|
+
3. Commit team-wide conventions into the repo. This very repository ships an [AGENTS.md](../AGENTS.md) governing AI-agent contributions — use it as a template.
|
|
32
|
+
|
|
33
|
+
## `codex exec`: scripting & CI
|
|
34
|
+
|
|
35
|
+
Non-interactive mode, for embedding Codex into scripts and pipelines:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
codex exec "Fix the type errors in src/utils.ts and make npm test pass"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Key points:
|
|
42
|
+
|
|
43
|
+
- Output is a plain result stream — easy to consume programmatically and to keep in logs;
|
|
44
|
+
- Permissions work the same as interactive mode (`approval_policy` / `sandbox_mode`, see [06](06-sandbox-windows.en.md)) — in CI prefer read-only mode or a disposable container;
|
|
45
|
+
- Combine with `--profile` to switch setups (see [04](04-config.en.md)).
|
|
46
|
+
|
|
47
|
+
## Session management
|
|
48
|
+
|
|
49
|
+
- **Split long tasks into sessions**: context grows every turn — more expensive, slower, and more stream-drop-prone (see [03](03-network-proxy.en.md), [05](05-models-limits.en.md));
|
|
50
|
+
- Session history lives in `~/.codex/sessions/` — revisit or clean it up per [09](09-maintenance.en.md);
|
|
51
|
+
- Newer versions support resuming the last session (check `/help` and `codex --help` for your version's actual output).
|
package/docs/11-tips.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# 11 · 效率技巧:斜杠命令、项目记忆与脚本化
|
|
2
|
+
|
|
3
|
+
> 这篇不是报错排查,而是把 Codex 用得更快、更省、更稳。具体命令以你版本 `/help` 的实际输出为准——Codex 迭代很快。
|
|
4
|
+
>
|
|
5
|
+
> English version: [11-tips.en.md](11-tips.en.md)
|
|
6
|
+
|
|
7
|
+
## TUI 斜杠命令速记
|
|
8
|
+
|
|
9
|
+
在交互界面输入 `/` 可以看到全部命令。最常用的几个:
|
|
10
|
+
|
|
11
|
+
| 命令 | 用途 |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `/status` | 查看当前模型、provider、审批/沙箱模式——排障第一步(见 [08](08-errors-quickref.md)) |
|
|
14
|
+
| `/model` | 切换模型(见 [05](05-models-limits.md)) |
|
|
15
|
+
| `/init` | 为当前项目生成 `AGENTS.md` 初始版 |
|
|
16
|
+
| `/logout` | 清除登录态——401 排障常用(见 [02](02-login-auth.md)) |
|
|
17
|
+
| `/help` | 全量命令与说明 |
|
|
18
|
+
|
|
19
|
+
## AGENTS.md:项目记忆
|
|
20
|
+
|
|
21
|
+
Codex 执行任务会读取指令文件 `AGENTS.md`,项目根目录的优先于用户全局的(`~/.codex/AGENTS.md`)。适合放:
|
|
22
|
+
|
|
23
|
+
- **项目约定**:构建/测试命令、代码风格、目录结构说明;
|
|
24
|
+
- **边界**:哪些目录不要动、哪些操作必须先问;
|
|
25
|
+
- **已知坑**:你踩过的项目特殊行为,别让它再踩一遍。
|
|
26
|
+
|
|
27
|
+
三个要点:
|
|
28
|
+
|
|
29
|
+
1. **保持精炼**——它每轮都会进入上下文,写大段废话既费额度又稀释重点;
|
|
30
|
+
2. 用 `/init` 生成初版,然后手工修剪成你真正想要的;
|
|
31
|
+
3. 团队共享的约定直接提交进仓库。本仓库自己就有一份 [AGENTS.md](../AGENTS.md) 规范 AI 代理的贡献行为,可以当模板参考。
|
|
32
|
+
|
|
33
|
+
## `codex exec`:脚本化与 CI
|
|
34
|
+
|
|
35
|
+
非交互模式,把 Codex 嵌进脚本和流水线:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
codex exec "修复 src/utils.ts 里的类型错误并跑通 npm test"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
要点:
|
|
42
|
+
|
|
43
|
+
- 输出是纯结果流,适合程序化消费与日志留档;
|
|
44
|
+
- 权限控制和交互模式一致(`approval_policy` / `sandbox_mode`,见 [06](06-sandbox-windows.md))——CI 里建议只读模式或一次性容器;
|
|
45
|
+
- 配合 `--profile` 在不同配置间切换(见 [04](04-config.md))。
|
|
46
|
+
|
|
47
|
+
## 会话管理
|
|
48
|
+
|
|
49
|
+
- **长任务拆会话**:上下文越滚越大,又贵又慢还容易断流(见 [03](03-network-proxy.md)、[05](05-models-limits.md));
|
|
50
|
+
- 会话历史在 `~/.codex/sessions/`,可回溯、可清理归档(见 [09](09-maintenance.md));
|
|
51
|
+
- 较新版本支持恢复上次会话(以 `/help` 与 `codex --help` 的实际输出为准)。
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
English | [中文](12-walkthrough.md)
|
|
2
|
+
|
|
3
|
+
# 12 · Walkthrough: Building a Project from Scratch with Codex
|
|
4
|
+
|
|
5
|
+
> This walkthrough strings the manual's best practices into one complete path: from an empty directory to a working project. Exact commands depend on your version's `/help` output.
|
|
6
|
+
|
|
7
|
+
## Step 0: a clean foundation
|
|
8
|
+
|
|
9
|
+
1. Create the project in a normal user directory — **never inside OneDrive / a sync folder** (why: [03](03-network-proxy.en.md)); on Windows, prefer working inside WSL ([06](06-sandbox-windows.en.md));
|
|
10
|
+
2. Run the [doctor script](../scripts/codex-doctor.sh) first — confirm network and credentials are healthy before you start, so you don't troubleshoot mid-task;
|
|
11
|
+
3. **`git init` before launching codex** — with version control, every step the agent produces is reviewable and revertible.
|
|
12
|
+
|
|
13
|
+
## Step 1: teach it before using it
|
|
14
|
+
|
|
15
|
+
Launch `codex` in the project directory; the first command:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
/init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
It scans the project and generates a starter `AGENTS.md`. Then **prune it by hand** (details in [11](11-tips.en.md)):
|
|
22
|
+
|
|
23
|
+
- Build/test commands: `npm test`, `pytest`, etc.;
|
|
24
|
+
- Boundaries: `never touch .env; ask me before any database migration`;
|
|
25
|
+
- Style: `commit messages in Chinese; validate all inputs`.
|
|
26
|
+
|
|
27
|
+
This file applies to every subsequent task — 10 minutes up front saves explanations forever after.
|
|
28
|
+
|
|
29
|
+
## Step 2: the first task
|
|
30
|
+
|
|
31
|
+
Describe it as **goal + constraints + acceptance criteria**, not one vague sentence:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
Implement a CLI todo tool:
|
|
35
|
+
1. Three subcommands: add / list / done; store data in a JSON file
|
|
36
|
+
2. Write tests first, then the implementation, for each command
|
|
37
|
+
3. Done means: npm test fully green, README has usage examples
|
|
38
|
+
Show me the plan first; I'll confirm before you code.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Make it **plan first, code second** — reviewing a plan is much faster than reviewing 500 lines of code. For daily work, `--full-auto` is the usual approval/sandbox balance (see [06](06-sandbox-windows.en.md)).
|
|
42
|
+
|
|
43
|
+
## Step 3: iteration rhythm
|
|
44
|
+
|
|
45
|
+
- **Small steps**: one feature per session, `git commit` when done. Small context = cheaper + faster + fewer stream drops ([03](03-network-proxy.en.md), [05](05-models-limits.en.md));
|
|
46
|
+
- **Make it prove completion**: end every task with "run the tests and paste the output" — never assume it's done;
|
|
47
|
+
- **Stay aligned**: unsure what it changed? `git diff` now, don't batch-review at the end.
|
|
48
|
+
|
|
49
|
+
## Step 4: sediment lessons into AGENTS.md
|
|
50
|
+
|
|
51
|
+
When it repeats the same mistake (e.g. always forgetting to format), don't correct it verbally every time — add one line to `AGENTS.md`: `run npm run lint:fix before committing`. Project memory compounds.
|
|
52
|
+
|
|
53
|
+
## Step 5: script the routine
|
|
54
|
+
|
|
55
|
+
Stable, repetitive tasks go to non-interactive mode (see [11](11-tips.en.md)):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# PR description after a dependency upgrade
|
|
59
|
+
codex exec "Diff package.json against the last release and write a PR description"
|
|
60
|
+
|
|
61
|
+
# Weekly report material
|
|
62
|
+
codex exec "Summarize this week's git log grouped by feature/fix"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
In CI, use a read-only sandbox or a disposable container ([06](06-sandbox-windows.en.md)).
|
|
66
|
+
|
|
67
|
+
## Common mistakes checklist
|
|
68
|
+
|
|
69
|
+
| Mistake | Consequence | Instead |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| Ten requirements in one sentence | Model improvises, mass rework | Split tasks; one acceptance point at a time |
|
|
72
|
+
| Complaining "the model is bad" without `/status` | It was actually the wrong model/config | `/status` is always triage step one |
|
|
73
|
+
| Project inside OneDrive | Stream disconnects | Move it out of the sync folder |
|
|
74
|
+
| One session all day | Expensive, slow, fragile | Split sessions |
|
|
75
|
+
| Letting it hardcode API keys | Credential leak | Keys in env vars / `.env` + `.gitignore` |
|
|
76
|
+
|
|
77
|
+
## When things break
|
|
78
|
+
|
|
79
|
+
Search keywords in the [08 quick reference](08-errors-quickref.en.md); if it's not there, ask in [Discussions](https://github.com/qlw088697-ui/codex-troubleshooting/discussions) or contribute a case per [CONTRIBUTING](../CONTRIBUTING.md).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# 12 · 实战:用 Codex 从零搭一个项目
|
|
2
|
+
|
|
3
|
+
> 这篇把手册里散落的最佳实践串成一条完整路径:从空目录到能跑的项目。命令细节以你版本 `/help` 的实际输出为准。
|
|
4
|
+
>
|
|
5
|
+
> English version: [12-walkthrough.en.md](12-walkthrough.en.md)
|
|
6
|
+
|
|
7
|
+
## 步骤 0:干净的地基
|
|
8
|
+
|
|
9
|
+
1. 项目目录建在普通用户目录下,**不要放 OneDrive / 同步盘**(原因见 [03](03-network-proxy.md));Windows 用户建议在 WSL 内干活([06](06-sandbox-windows.md));
|
|
10
|
+
2. 先跑一次[环境自检脚本](../scripts/codex-doctor.sh),确认网络与凭据健康,省得中途排查;
|
|
11
|
+
3. **先 `git init` 再启动 codex**——有版本控制,对话产出的每一步都可回溯、可审查。
|
|
12
|
+
|
|
13
|
+
## 步骤 1:先教它,再用它
|
|
14
|
+
|
|
15
|
+
进入目录启动 `codex`,第一件事:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
/init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
它会扫描项目生成 `AGENTS.md` 初版。然后**手工修剪**(详见 [11](11-tips.md)):
|
|
22
|
+
|
|
23
|
+
- 写清构建/测试命令:`npm test`、`pytest` 之类;
|
|
24
|
+
- 写清边界:`永远不要改 .env;涉及数据库迁移的改动必须先问我`;
|
|
25
|
+
- 写清风格:`提交信息用中文;所有入口参数做校验`。
|
|
26
|
+
|
|
27
|
+
这份文件每轮任务都会生效——前期花 10 分钟,后面每个任务都省口舌。
|
|
28
|
+
|
|
29
|
+
## 步骤 2:第一个任务
|
|
30
|
+
|
|
31
|
+
用「**目标 + 约束 + 验收标准**」的格式描述,别一句话糊上去:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
实现一个 CLI 待办工具:
|
|
35
|
+
1. add / list / done 三个子命令,数据存 JSON 文件
|
|
36
|
+
2. 每个命令先写测试再写实现
|
|
37
|
+
3. 完成标准:npm test 全绿,README 有用法示例
|
|
38
|
+
先给我实施计划,我确认后再动手。
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
让它**先出计划再写码**——你审一份计划比审 500 行代码快得多。审批/沙箱日常建议 `--full-auto`(详见 [06](06-sandbox-windows.md))。
|
|
42
|
+
|
|
43
|
+
## 步骤 3:迭代节奏
|
|
44
|
+
|
|
45
|
+
- **小步快跑**:一个功能一个会话,做完就 `git commit`。上下文小 = 便宜 + 快 + 不容易断流([03](03-network-proxy.md)、[05](05-models-limits.md));
|
|
46
|
+
- **让它自证完成**:每个任务以「跑测试并贴出输出」收尾,不要脑补它做完了;
|
|
47
|
+
- **随时对齐**:拿不准它改了什么就 `git diff`,别攒到最后一起审。
|
|
48
|
+
|
|
49
|
+
## 步骤 4:把踩坑沉淀进 AGENTS.md
|
|
50
|
+
|
|
51
|
+
发现它反复犯同一个错(比如总忘记跑格式化),别每次口头纠正——写进 `AGENTS.md` 一行:`提交前必须跑 npm run lint:fix`。项目记忆是复利,越写越省。
|
|
52
|
+
|
|
53
|
+
## 步骤 5:例行工作脚本化
|
|
54
|
+
|
|
55
|
+
稳定的重复任务交给非交互模式(详见 [11](11-tips.md)):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 依赖升级后生成 PR 描述
|
|
59
|
+
codex exec "对比 package.json 与上次发布的差异,生成中文 PR 描述"
|
|
60
|
+
|
|
61
|
+
# 周报素材
|
|
62
|
+
codex exec "总结本周 git log,按 feature/fix 分类输出"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
放进 CI 时用只读沙箱或一次性容器([06](06-sandbox-windows.md))。
|
|
66
|
+
|
|
67
|
+
## 常见误区清单
|
|
68
|
+
|
|
69
|
+
| 误区 | 后果 | 正解 |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| 一句话塞十个需求 | 模型自由发挥,大范围返工 | 拆任务,一次一个验收点 |
|
|
72
|
+
| 不看 `/status` 就抱怨"模型不行" | 其实是跑错了模型/配置 | 排障第一步永远是 `/status` |
|
|
73
|
+
| 项目放在 OneDrive 里 | 断流高发 | 移出同步盘 |
|
|
74
|
+
| 一个会话聊一整天 | 越来越贵、越来越慢、容易断 | 拆会话 |
|
|
75
|
+
| 让它把 API Key 写进代码 | 密钥泄露 | 密钥走环境变量 / `.env` 并加入 `.gitignore` |
|
|
76
|
+
|
|
77
|
+
## 遇到问题
|
|
78
|
+
|
|
79
|
+
按 [08 速查表](08-errors-quickref.md) 搜关键词;查不到就去 [Discussions](https://github.com/qlw088697-ui/codex-troubleshooting/discussions) 提问,或按 [CONTRIBUTING](../CONTRIBUTING.md) 补充案例。
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
English | [中文](13-codex-doctor.md)
|
|
2
|
+
|
|
3
|
+
# 13 · codex-doctor CLI: One Command for Maintenance
|
|
4
|
+
|
|
5
|
+
> The repo ships a **zero-dependency** CLI (Node 18.15+, standard library only): environment checks, archiving, backups, release tracking — no more manual checklist walks.
|
|
6
|
+
|
|
7
|
+
## Run it
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Option 1: npx (published on npm, no install)
|
|
11
|
+
npx -y @qqq123456789/codex-doctor doctor
|
|
12
|
+
|
|
13
|
+
# Option 2: run straight from GitHub (skips npm)
|
|
14
|
+
npx github:qlw088697-ui/codex-troubleshooting doctor
|
|
15
|
+
|
|
16
|
+
# Option 3: clone and run locally
|
|
17
|
+
git clone https://github.com/qlw088697-ui/codex-troubleshooting.git
|
|
18
|
+
node codex-troubleshooting/tool/cli.mjs --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Subcommands
|
|
22
|
+
|
|
23
|
+
| Command | Purpose | Risk |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `doctor` | Full environment check (**relay-aware**: probes your configured relay endpoint instead of official ones; codex outdated-version detection, Windows execution policy & system proxy, OneDrive pitfalls; `--no-network` skips probes, `--json` for scripts, `--strict` fails on warnings) | read-only |
|
|
26
|
+
| `clean sessions [--days 30]` | Archive session files older than N days (**dry-run by default**, `--yes` to execute) | low (archive, not delete) |
|
|
27
|
+
| `clean logs [--days 14]` | Same, for logs | low |
|
|
28
|
+
| `backup [--out DIR]` | Back up config.toml + auth.json into a timestamped directory | read-only |
|
|
29
|
+
| `restore <dir>` | Restore from a backup directory | medium (overwrites) |
|
|
30
|
+
| `auth reset` | Back up and delete auth.json, then re-run `codex login` (the 401 last resort, one command) | medium |
|
|
31
|
+
| `archive list` | List archive folders with sizes | read-only |
|
|
32
|
+
| `archive delete <name\|--all>` | Delete archives (interactive confirm by default, `--yes` to skip) | medium (deletes, requires confirm) |
|
|
33
|
+
| `versions [-n 10]` | List the latest openai/codex releases (prerelease flagged) | read-only |
|
|
34
|
+
| `update` | Check the repo's latest release and how to update | read-only |
|
|
35
|
+
|
|
36
|
+
## Design principles
|
|
37
|
+
|
|
38
|
+
1. **Zero dependencies**: Node standard library only — no supply-chain surface;
|
|
39
|
+
2. **Safe by default**: destructive operations are dry-run unless `--yes`; `clean` **archives** into `~/.codex/archive/` instead of deleting;
|
|
40
|
+
3. **auth.json is a password**: `backup` reminds you to guard the backup directory;
|
|
41
|
+
4. **Non-interactive protection**: without a TTY (CI/scripts) confirmations are unavailable — you must pass `--yes` explicitly.
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# weekly checkup
|
|
47
|
+
codex-doctor doctor
|
|
48
|
+
|
|
49
|
+
# see what's older than 30 days in sessions (dry run, changes nothing)
|
|
50
|
+
codex-doctor clean sessions --days 30
|
|
51
|
+
|
|
52
|
+
# actually archive
|
|
53
|
+
codex-doctor clean sessions --days 30 --yes
|
|
54
|
+
|
|
55
|
+
# before migrating machines
|
|
56
|
+
codex-doctor backup
|
|
57
|
+
# on the new machine
|
|
58
|
+
codex-doctor restore ~/.codex-backups/2026-08-31-10-00-00
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Relation to scripts/
|
|
62
|
+
|
|
63
|
+
`scripts/codex-doctor.ps1` / `.sh` are single-file, read-only checkers — handy to toss at a friend. The CLI is the full maintenance tool with identical checks plus cleaning/backup/restore/version tracking. Pick either; results match.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# 13 · codex-doctor CLI:把维护变成一条命令
|
|
2
|
+
|
|
3
|
+
> 仓库自带的**零依赖**命令行工具(Node 18.15+,仅用标准库)。自检、清理、备份、版本追踪,不用再手动对照文档操作。
|
|
4
|
+
>
|
|
5
|
+
> English version: [13-codex-doctor.en.md](13-codex-doctor.en.md)
|
|
6
|
+
|
|
7
|
+
## 运行方式
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 方式一:npx 直跑(发布在 npm,无需安装)
|
|
11
|
+
npx -y @qqq123456789/codex-doctor doctor
|
|
12
|
+
|
|
13
|
+
# 方式二:直接从 GitHub 跑(不经过 npm)
|
|
14
|
+
npx github:qlw088697-ui/codex-troubleshooting doctor
|
|
15
|
+
|
|
16
|
+
# 方式三:克隆仓库后本地跑
|
|
17
|
+
git clone https://github.com/qlw088697-ui/codex-troubleshooting.git
|
|
18
|
+
node codex-troubleshooting/tool/cli.mjs --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 子命令一览
|
|
22
|
+
|
|
23
|
+
| 命令 | 作用 | 危险性 |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `doctor` | 全套环境自检(**中转模式感知**:自动探测你配置的中转端点而非官方端点;含 codex 版本过期检测、Windows 执行策略与系统代理、OneDrive 坑位;`--no-network` 跳过探测,`--json` 供脚本消费,`--strict` 有警告也返回非零) | 只读 |
|
|
26
|
+
| `clean sessions [--days 30]` | 归档超过 N 天的会话文件(默认**预演**,`--yes` 才执行) | 低(归档而非删除) |
|
|
27
|
+
| `clean logs [--days 14]` | 同上,针对日志 | 低 |
|
|
28
|
+
| `backup [--out DIR]` | 备份 config.toml + auth.json 到带时间戳目录 | 只读 |
|
|
29
|
+
| `restore <dir>` | 从备份目录恢复 | 中(覆盖现有文件) |
|
|
30
|
+
| `auth reset` | 备份并删除 auth.json,引导重新 `codex login`(401 终极大招的一键化) | 中 |
|
|
31
|
+
| `archive list` | 查看归档目录与体积 | 只读 |
|
|
32
|
+
| `archive delete <名称\|--all>` | 删除归档(默认需交互确认,`--yes` 跳过) | 中(删除,需确认) |
|
|
33
|
+
| `versions [-n 10]` | 查看 openai/codex 最近 N 个版本(含预发布标记) | 只读 |
|
|
34
|
+
| `update` | 查询仓库最新发布与更新方式 | 只读 |
|
|
35
|
+
|
|
36
|
+
## 设计原则
|
|
37
|
+
|
|
38
|
+
1. **零依赖**:只用 Node 标准库,装了 Node 就能跑,不存在供应链风险;
|
|
39
|
+
2. **安全默认**:一切破坏性操作默认预演(dry-run),加 `--yes` 才真正执行;`clean` 是**归档**到 `~/.codex/archive/` 而不是删除,随时可搬回来;
|
|
40
|
+
3. **auth.json 等同密码**:`backup` 完成时会提醒你保管好备份目录;
|
|
41
|
+
4. **非交互环境保护**:没有 TTY 时(CI / 脚本)确认交互不可用,必须显式 `--yes`,防止误执行。
|
|
42
|
+
|
|
43
|
+
## 使用示例
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 每周例行体检
|
|
47
|
+
codex-doctor doctor
|
|
48
|
+
|
|
49
|
+
# 查看 30 天前的会话都有些什么(预演,不改动)
|
|
50
|
+
codex-doctor clean sessions --days 30
|
|
51
|
+
|
|
52
|
+
# 确认后真正归档
|
|
53
|
+
codex-doctor clean sessions --days 30 --yes
|
|
54
|
+
|
|
55
|
+
# 迁移机器前
|
|
56
|
+
codex-doctor backup
|
|
57
|
+
# 新机器上
|
|
58
|
+
codex-doctor restore ~/.codex-backups/2026-08-31-10-00-00
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 与 scripts/ 下自检脚本的关系
|
|
62
|
+
|
|
63
|
+
`scripts/codex-doctor.ps1` / `.sh` 是单文件只读自检,方便直接甩给朋友跑;本 CLI 是完整维护工具,检查项一致且多了清理/备份/恢复/版本查询能力。二选一即可,检查结果相同。
|
package/docs/releases.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!-- 本文件由 scripts/gen-releases.mjs 自动生成(CI 每周一运行),请勿手动编辑 -->
|
|
2
|
+
<!-- 数据源:https://github.com/openai/codex/releases -->
|
|
3
|
+
|
|
4
|
+
# Codex 版本追踪
|
|
5
|
+
|
|
6
|
+
[openai/codex](https://github.com/openai/codex) 最近 50 个 Release(按时间倒序)。带「预发布」标记的是 rc/beta 版本,生产环境建议用稳定版。
|
|
7
|
+
|
|
8
|
+
| 版本 | 发布日期 | 预发布 | 说明 |
|
|
9
|
+
|---|---|---|---|
|
|
10
|
+
| [rust-v0.153.2](https://github.com/openai/codex/releases/tag/rust-v0.153.2) | 2026-09-03 | | 0.153.2 |
|
|
11
|
+
| [rust-v0.153.1](https://github.com/openai/codex/releases/tag/rust-v0.153.1) | 2026-09-03 | | 0.153.1 |
|
|
12
|
+
| [rust-v0.153.0](https://github.com/openai/codex/releases/tag/rust-v0.153.0) | 2026-09-03 | | 0.153.0 |
|
|
13
|
+
| [rust-v0.154.0-alpha.3](https://github.com/openai/codex/releases/tag/rust-v0.154.0-alpha.3) | 2026-09-04 | 是 | 0.154.0-alpha.3 |
|
|
14
|
+
| [rust-v0.154.0-alpha.2](https://github.com/openai/codex/releases/tag/rust-v0.154.0-alpha.2) | 2026-09-03 | 是 | 0.154.0-alpha.2 |
|
|
15
|
+
| [rust-v0.154.0-alpha.1](https://github.com/openai/codex/releases/tag/rust-v0.154.0-alpha.1) | 2026-09-03 | 是 | 0.154.0-alpha.1 |
|
|
16
|
+
| [rust-v0.153.0-alpha.6](https://github.com/openai/codex/releases/tag/rust-v0.153.0-alpha.6) | 2026-09-02 | 是 | 0.153.0-alpha.6 |
|
|
17
|
+
| [rust-v0.153.0-alpha.5.1](https://github.com/openai/codex/releases/tag/rust-v0.153.0-alpha.5.1) | 2026-09-03 | 是 | 0.153.0-alpha.5.1 |
|
|
18
|
+
| [rust-v0.153.0-alpha.5](https://github.com/openai/codex/releases/tag/rust-v0.153.0-alpha.5) | 2026-09-02 | 是 | 0.153.0-alpha.5 |
|
|
19
|
+
| [rust-v0.152.1](https://github.com/openai/codex/releases/tag/rust-v0.152.1) | 2026-09-01 | | 0.152.1 |
|
|
20
|
+
| [rust-v0.152.0](https://github.com/openai/codex/releases/tag/rust-v0.152.0) | 2026-09-01 | | 0.152.0 |
|
|
21
|
+
| [rust-v0.153.0-alpha.4](https://github.com/openai/codex/releases/tag/rust-v0.153.0-alpha.4) | 2026-09-01 | 是 | 0.153.0-alpha.4 |
|
|
22
|
+
| [rust-v0.153.0-alpha.2](https://github.com/openai/codex/releases/tag/rust-v0.153.0-alpha.2) | 2026-09-01 | 是 | 0.153.0-alpha.2 |
|
|
23
|
+
| [rust-v0.153.0-alpha.1](https://github.com/openai/codex/releases/tag/rust-v0.153.0-alpha.1) | 2026-09-01 | 是 | 0.153.0-alpha.1 |
|
|
24
|
+
| [rust-v0.152.0-alpha.7.2](https://github.com/openai/codex/releases/tag/rust-v0.152.0-alpha.7.2) | 2026-09-01 | 是 | 0.152.0-alpha.7.2 |
|
|
25
|
+
| [rust-v0.152.0-alpha.7](https://github.com/openai/codex/releases/tag/rust-v0.152.0-alpha.7) | 2026-08-31 | 是 | 0.152.0-alpha.7 |
|
|
26
|
+
| [rust-v0.152.0-alpha.6](https://github.com/openai/codex/releases/tag/rust-v0.152.0-alpha.6) | 2026-08-31 | 是 | 0.152.0-alpha.6 |
|
|
27
|
+
| [rust-v0.152.0-alpha.5](https://github.com/openai/codex/releases/tag/rust-v0.152.0-alpha.5) | 2026-08-31 | 是 | 0.152.0-alpha.5 |
|
|
28
|
+
| [rust-v0.152.0-alpha.4](https://github.com/openai/codex/releases/tag/rust-v0.152.0-alpha.4) | 2026-08-30 | 是 | 0.152.0-alpha.4 |
|
|
29
|
+
| [rust-v0.151.0](https://github.com/openai/codex/releases/tag/rust-v0.151.0) | 2026-08-29 | | 0.151.0 |
|
|
30
|
+
| [rust-v0.152.0-alpha.1](https://github.com/openai/codex/releases/tag/rust-v0.152.0-alpha.1) | 2026-08-29 | 是 | 0.152.0-alpha.1 |
|
|
31
|
+
| [rust-v0.151.0-alpha.7.2](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.7.2) | 2026-08-29 | 是 | 0.151.0-alpha.7.2 |
|
|
32
|
+
| [rust-v0.151.0-alpha.12](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.12) | 2026-08-29 | 是 | 0.151.0-alpha.12 |
|
|
33
|
+
| [rust-v0.151.0-alpha.9](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.9) | 2026-08-28 | 是 | 0.151.0-alpha.9 |
|
|
34
|
+
| [rust-v0.151.0-alpha.8](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.8) | 2026-08-28 | 是 | 0.151.0-alpha.8 |
|
|
35
|
+
| [rust-v0.151.0-alpha.7.1](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.7.1) | 2026-08-28 | 是 | 0.151.0-alpha.7.1 |
|
|
36
|
+
| [rust-v0.151.0-alpha.11](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.11) | 2026-08-28 | 是 | 0.151.0-alpha.11 |
|
|
37
|
+
| [rust-v0.151.0-alpha.10](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.10) | 2026-08-28 | 是 | 0.151.0-alpha.10 |
|
|
38
|
+
| [rust-v0.150.1](https://github.com/openai/codex/releases/tag/rust-v0.150.1) | 2026-08-27 | | 0.150.1 |
|
|
39
|
+
| [rust-v0.151.0-alpha.7](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.7) | 2026-08-27 | 是 | 0.151.0-alpha.7 |
|
|
40
|
+
| [rust-v0.151.0-alpha.6](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.6) | 2026-08-27 | 是 | 0.151.0-alpha.6 |
|
|
41
|
+
| [rust-v0.151.0-alpha.5](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.5) | 2026-08-27 | 是 | 0.151.0-alpha.5 |
|
|
42
|
+
| [rust-v0.151.0-alpha.4](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.4) | 2026-08-27 | 是 | 0.151.0-alpha.4 |
|
|
43
|
+
| [rust-v0.150.0-alpha.12.2](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.12.2) | 2026-08-27 | 是 | 0.150.0-alpha.12.2 |
|
|
44
|
+
| [rust-v0.150.0](https://github.com/openai/codex/releases/tag/rust-v0.150.0) | 2026-08-26 | | 0.150.0 |
|
|
45
|
+
| [rust-v0.151.0-alpha.3](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.3) | 2026-08-26 | 是 | 0.151.0-alpha.3 |
|
|
46
|
+
| [rust-v0.151.0-alpha.2](https://github.com/openai/codex/releases/tag/rust-v0.151.0-alpha.2) | 2026-08-26 | 是 | 0.151.0-alpha.2 |
|
|
47
|
+
| [rust-v0.150.0-alpha.13](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.13) | 2026-08-26 | 是 | 0.150.0-alpha.13 |
|
|
48
|
+
| [rust-v0.150.0-alpha.12.1](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.12.1) | 2026-08-27 | 是 | 0.150.0-alpha.12.1 |
|
|
49
|
+
| [rust-v0.150.0-alpha.12](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.12) | 2026-08-26 | 是 | 0.150.0-alpha.12 |
|
|
50
|
+
| [rust-v0.150.0-alpha.9](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.9) | 2026-08-25 | 是 | 0.150.0-alpha.9 |
|
|
51
|
+
| [rust-v0.150.0-alpha.11](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.11) | 2026-08-25 | 是 | 0.150.0-alpha.11 |
|
|
52
|
+
| [rust-v0.150.0-alpha.10](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.10) | 2026-08-25 | 是 | 0.150.0-alpha.10 |
|
|
53
|
+
| [rust-v0.150.0-alpha.8](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.8) | 2026-08-24 | 是 | 0.150.0-alpha.8 |
|
|
54
|
+
| [rust-v0.149.1](https://github.com/openai/codex/releases/tag/rust-v0.149.1) | 2026-08-24 | | 0.149.1 |
|
|
55
|
+
| [rust-v0.149.0-alpha.4.3](https://github.com/openai/codex/releases/tag/rust-v0.149.0-alpha.4.3) | 2026-08-23 | 是 | 0.149.0-alpha.4.3 |
|
|
56
|
+
| [rust-v0.150.0-alpha.7](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.7) | 2026-08-22 | 是 | 0.150.0-alpha.7 |
|
|
57
|
+
| [rust-v0.149.0-alpha.7.2](https://github.com/openai/codex/releases/tag/rust-v0.149.0-alpha.7.2) | 2026-08-22 | 是 | 0.149.0-alpha.7.2 |
|
|
58
|
+
| [rust-v0.150.0-alpha.6](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.6) | 2026-08-21 | 是 | 0.150.0-alpha.6 |
|
|
59
|
+
| [rust-v0.150.0-alpha.5](https://github.com/openai/codex/releases/tag/rust-v0.150.0-alpha.5) | 2026-08-21 | 是 | 0.150.0-alpha.5 |
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qqq123456789/codex-doctor",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Codex CLI 维护与排障工具:环境自检、会话/日志归档、配置与凭据备份恢复、版本追踪(零依赖)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"codex-doctor": "tool/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"tool",
|
|
11
|
+
"docs",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18.15"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/qlw088697-ui/codex-troubleshooting.git"
|
|
24
|
+
}
|
|
25
|
+
}
|