@qqq123456789/codex-doctor 1.0.0 → 1.1.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/README.en.md CHANGED
@@ -8,6 +8,7 @@ English | [中文](README.md)
8
8
 
9
9
  [![CI](https://github.com/qlw088697-ui/codex-troubleshooting/actions/workflows/ci.yml/badge.svg)](https://github.com/qlw088697-ui/codex-troubleshooting/actions/workflows/ci.yml)
10
10
  [![npm](https://img.shields.io/npm/v/@qqq123456789/codex-doctor)](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
11
+ [![Downloads](https://img.shields.io/npm/dt/@qqq123456789/codex-doctor)](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
11
12
  [![Latest release](https://img.shields.io/npm/v/@qqq123456789/codex-doctor?label=release)](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
12
13
  [![Latest Codex](https://img.shields.io/github/v/release/openai/codex?label=latest%20codex)](docs/releases.md)
13
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
package/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  [![CI](https://github.com/qlw088697-ui/codex-troubleshooting/actions/workflows/ci.yml/badge.svg)](https://github.com/qlw088697-ui/codex-troubleshooting/actions/workflows/ci.yml)
10
10
  [![npm](https://img.shields.io/npm/v/@qqq123456789/codex-doctor)](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
11
+ [![Downloads](https://img.shields.io/npm/dt/@qqq123456789/codex-doctor)](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
11
12
  [![Latest release](https://img.shields.io/github/v/release/qlw088697-ui/codex-troubleshooting?label=release)](https://github.com/qlw088697-ui/codex-troubleshooting/releases)
12
13
  [![Latest Codex](https://img.shields.io/github/v/release/openai/codex?label=latest%20codex)](docs/releases.md)
13
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
@@ -22,7 +22,7 @@ node codex-troubleshooting/tool/cli.mjs --help
22
22
 
23
23
  | Command | Purpose | Risk |
24
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 |
25
+ | `doctor` | Full environment check (**relay-aware**, codex outdated-version detection, MCP command availability, Windows execution policy & system proxy, OneDrive pitfalls, login-state expiry; `--no-network` skips probes, `--json` for scripts, `--strict` fails on warnings) | read-only |
26
26
  | `clean sessions [--days 30]` | Archive session files older than N days (**dry-run by default**, `--yes` to execute) | low (archive, not delete) |
27
27
  | `clean logs [--days 14]` | Same, for logs | low |
28
28
  | `backup [--out DIR]` | Back up config.toml + auth.json into a timestamped directory | read-only |
@@ -22,7 +22,7 @@ node codex-troubleshooting/tool/cli.mjs --help
22
22
 
23
23
  | 命令 | 作用 | 危险性 |
24
24
  |---|---|---|
25
- | `doctor` | 全套环境自检(**中转模式感知**:自动探测你配置的中转端点而非官方端点;含 codex 版本过期检测、Windows 执行策略与系统代理、OneDrive 坑位;`--no-network` 跳过探测,`--json` 供脚本消费,`--strict` 有警告也返回非零) | 只读 |
25
+ | `doctor` | 全套环境自检(**中转模式感知**、codex 版本过期检测、MCP 启动命令可达性、Windows 执行策略与系统代理、OneDrive 坑位、登录态有效期;`--no-network` 跳过网络探测,`--json` 供脚本消费,`--strict` 有警告也返回非零) | 只读 |
26
26
  | `clean sessions [--days 30]` | 归档超过 N 天的会话文件(默认**预演**,`--yes` 才执行) | 低(归档而非删除) |
27
27
  | `clean logs [--days 14]` | 同上,针对日志 | 低 |
28
28
  | `backup [--out DIR]` | 备份 config.toml + auth.json 到带时间戳目录 | 只读 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qqq123456789/codex-doctor",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "scripts": {
5
5
  "test": "bash scripts/test-codex-doctor.sh",
6
6
  "check:links": "bash scripts/check-links.sh",
package/tool/checks.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // doctor 自检:与 scripts/codex-doctor.ps1/.sh 检查项一致,跨平台单一实现
2
- import { execFileSync } from 'node:child_process';
2
+ import { execFileSync, execSync } from 'node:child_process';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import { HOME, CODEX_DIR, exists, dirBytes } from './util.mjs';
@@ -63,6 +63,17 @@ function runShell(cmdString) {
63
63
  }
64
64
  }
65
65
 
66
+ function commandExists(cmd) {
67
+ if (/[\\\/]/.test(cmd)) return exists(cmd);
68
+ const check = process.platform === 'win32' ? `where ${cmd}` : `command -v ${cmd}`;
69
+ try {
70
+ execSync(check, { stdio: 'ignore', shell: true, timeout: 8000 });
71
+ return true;
72
+ } catch {
73
+ return false;
74
+ }
75
+ }
76
+
66
77
  function compareSemver(a, b) {
67
78
  const pa = String(a).split('.').map(Number);
68
79
  const pb = String(b).split('.').map(Number);
@@ -143,6 +154,35 @@ export async function collectChecks({ network = true } = {}) {
143
154
  } else {
144
155
  add('config-roots', 'ok', '未发现根级键位置问题');
145
156
  }
157
+ // MCP server 命令可达性(「工具不出现」的头号原因就是命令起不来)
158
+ const mcpCmds = [];
159
+ let inMcp = false;
160
+ let mcpName = null;
161
+ for (const raw of content.split(/\r?\n/)) {
162
+ const l = raw.trim();
163
+ const tm = l.match(/^\[([^\]]+)\]$/);
164
+ if (tm) {
165
+ const n = tm[1].trim();
166
+ inMcp = n.startsWith('mcp_servers.') && n.split('.').length === 2;
167
+ mcpName = inMcp ? n.replace('mcp_servers.', '') : null;
168
+ continue;
169
+ }
170
+ if (!inMcp || !l || l.startsWith('#')) continue;
171
+ const cm = l.match(/^command\s*=\s*["']([^"']+)["']/);
172
+ if (cm && mcpName && mcpCmds.length < 5) mcpCmds.push({ name: mcpName, cmd: cm[1] });
173
+ }
174
+ if (mcpCmds.length > 0) {
175
+ const missing = mcpCmds.filter((x) => !commandExists(x.cmd));
176
+ add(
177
+ 'mcp',
178
+ missing.length === 0 ? 'ok' : 'fail',
179
+ missing.length === 0
180
+ ? `${mcpCmds.length} 个 MCP server 的启动命令均可解析`
181
+ : `MCP 启动命令不可解析: ${missing.map((x) => `${x.name}(${x.cmd})`).join(', ')}`,
182
+ 'docs/07-mcp.md'
183
+ );
184
+ }
185
+
146
186
  if (/^\[model_providers\./m.test(content)) {
147
187
  add('providers', 'warn', '检测到第三方 provider 配置——用官方账号报 401 时先核对它', 'docs/04-config.md');
148
188
  // 提取第一个中转 base_url(供网络探测感知中转模式)
package/tool/cli.mjs CHANGED
@@ -8,7 +8,7 @@ import { configSummary } from './config.mjs';
8
8
  import { CODEX_DIR } from './util.mjs';
9
9
  import path from 'node:path';
10
10
 
11
- const VERSION = '1.0.0';
11
+ const VERSION = '1.1.0';
12
12
 
13
13
  const HELP = `codex-doctor v${VERSION} — Codex CLI 维护与排障工具(零依赖)
14
14