@qqq123456789/codex-doctor 0.2.0 → 0.3.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 +2 -1
- package/README.md +1 -0
- package/package.json +1 -1
- package/tool/checks.mjs +23 -0
- package/tool/cli.mjs +1 -1
- package/tool/ops.mjs +8 -8
package/README.en.md
CHANGED
|
@@ -7,7 +7,8 @@ English | [中文](README.md)
|
|
|
7
7
|
> **Every topic guide is available in English** — the map below links straight to the English versions; each one cross-links back to the Chinese original.
|
|
8
8
|
|
|
9
9
|
[](https://github.com/qlw088697-ui/codex-troubleshooting/actions/workflows/ci.yml)
|
|
10
|
-
[](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
|
|
11
|
+
[](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
|
|
11
12
|
[](docs/releases.md)
|
|
12
13
|
[](LICENSE)
|
|
13
14
|
[](docs/06-sandbox-windows.md)
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
> A Chinese-first troubleshooting & maintenance guide for OpenAI Codex CLI.
|
|
8
8
|
|
|
9
9
|
[](https://github.com/qlw088697-ui/codex-troubleshooting/actions/workflows/ci.yml)
|
|
10
|
+
[](https://www.npmjs.com/package/@qqq123456789/codex-doctor)
|
|
10
11
|
[](https://github.com/qlw088697-ui/codex-troubleshooting/releases)
|
|
11
12
|
[](docs/releases.md)
|
|
12
13
|
[](LICENSE)
|
package/package.json
CHANGED
package/tool/checks.mjs
CHANGED
|
@@ -179,6 +179,29 @@ export async function collectChecks({ network = true } = {}) {
|
|
|
179
179
|
'docs/02-login-auth.md'
|
|
180
180
|
);
|
|
181
181
|
|
|
182
|
+
// 4b. 登录态有效期(解码 auth.json 中 id_token 的 exp 声明,不输出任何敏感内容)
|
|
183
|
+
if (exists(auth)) {
|
|
184
|
+
try {
|
|
185
|
+
const j = JSON.parse(fs.readFileSync(auth, 'utf8'));
|
|
186
|
+
const idToken = j?.tokens?.id_token;
|
|
187
|
+
if (typeof idToken === 'string' && idToken.split('.').length >= 2) {
|
|
188
|
+
const payload = JSON.parse(Buffer.from(idToken.split('.')[1], 'base64url').toString('utf8'));
|
|
189
|
+
if (typeof payload?.exp === 'number') {
|
|
190
|
+
const days = Math.floor((payload.exp * 1000 - Date.now()) / 86400e3);
|
|
191
|
+
if (days < 0) {
|
|
192
|
+
add('auth-expiry', 'warn', `登录态已过期 ${-days} 天——重新 codex login 即可`, 'docs/02-login-auth.md');
|
|
193
|
+
} else if (days <= 7) {
|
|
194
|
+
add('auth-expiry', 'warn', `登录态将于 ${days} 天内过期——建议尽快 codex login 刷新`, 'docs/02-login-auth.md');
|
|
195
|
+
} else {
|
|
196
|
+
add('auth-expiry', 'ok', `登录态剩余约 ${days} 天`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch {
|
|
201
|
+
/* auth.json 结构不符或解析失败则静默跳过 */
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
182
205
|
// 5. 环境变量
|
|
183
206
|
if (process.env.OPENAI_API_KEY) add('env-key', 'ok', 'OPENAI_API_KEY 已设置(值不显示)');
|
|
184
207
|
else add('env-key', 'info', 'OPENAI_API_KEY 未设置(ChatGPT 登录方式无需设置)');
|
package/tool/cli.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { collectChecks, summarize, renderHuman } from './checks.mjs';
|
|
|
4
4
|
import { cleanTarget } from './clean.mjs';
|
|
5
5
|
import { backupConfig, restoreBackup, resetAuth, listVersions, listArchives, deleteArchive, checkUpdate } from './ops.mjs';
|
|
6
6
|
|
|
7
|
-
const VERSION = '0.
|
|
7
|
+
const VERSION = '0.3.0';
|
|
8
8
|
|
|
9
9
|
const HELP = `codex-doctor v${VERSION} — Codex CLI 维护与排障工具(零依赖)
|
|
10
10
|
|
package/tool/ops.mjs
CHANGED
|
@@ -159,20 +159,20 @@ function compareSemver(a, b) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
export async function checkUpdate(currentVersion) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
// 与 npm registry 上的包版本对比(仓库 GitHub release 版本号与本工具版本号不同步)
|
|
163
|
+
const res = await fetch('https://registry.npmjs.org/@qqq123456789%2Fcodex-doctor/latest', {
|
|
164
|
+
headers: { Accept: 'application/vnd.npm.install-v1+json', 'User-Agent': 'codex-doctor-cli' },
|
|
165
|
+
});
|
|
166
|
+
if (!res.ok) throw new Error(`npm registry HTTP ${res.status}`);
|
|
166
167
|
const r = await res.json();
|
|
167
|
-
const
|
|
168
|
-
const latest = tag.replace(/^v/, '');
|
|
168
|
+
const latest = r.version || '';
|
|
169
169
|
const newer = latest ? compareSemver(currentVersion, latest) < 0 : false;
|
|
170
170
|
return {
|
|
171
171
|
lines: [
|
|
172
172
|
`当前工具版本: ${currentVersion}`,
|
|
173
|
-
|
|
173
|
+
`npm 最新版本: ${latest}`,
|
|
174
174
|
newer
|
|
175
|
-
? 'npx
|
|
175
|
+
? 'npx 直跑始终使用最新代码,无需操作;全局安装用户请执行 npm install -g @qqq123456789/codex-doctor@latest'
|
|
176
176
|
: '已是最新版本。',
|
|
177
177
|
],
|
|
178
178
|
};
|