@andyqiu/codeforge 0.8.2 → 0.8.3
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/bin/codeforge-doctor.mjs +41 -1
- package/dist/index.js +963 -317
- package/package.json +1 -1
package/bin/codeforge-doctor.mjs
CHANGED
|
@@ -77,10 +77,12 @@ function resolveTarget(args) {
|
|
|
77
77
|
// 参数解析
|
|
78
78
|
// ────────────────────────────────────────────────────────────────────
|
|
79
79
|
function parseArgs(argv) {
|
|
80
|
-
const args = { project: false, help: false }
|
|
80
|
+
const args = { project: false, help: false, runtime: false }
|
|
81
81
|
for (const a of argv) {
|
|
82
82
|
if (a === "--project" || a === "-p") args.project = true
|
|
83
83
|
if (a === "--help" || a === "-h") args.help = true
|
|
84
|
+
// ADR:zero-command-worktree-convergence Amendment (2026-06-12) Phase 6c —— runtime 健康度段
|
|
85
|
+
if (a === "--runtime" || a === "-r") args.runtime = true
|
|
84
86
|
}
|
|
85
87
|
return args
|
|
86
88
|
}
|
|
@@ -97,12 +99,14 @@ if (args.help) {
|
|
|
97
99
|
用法:
|
|
98
100
|
codeforge doctor # 检查 global (~/.config/opencode)
|
|
99
101
|
codeforge doctor --project # 检查 project (<cwd>/.opencode)
|
|
102
|
+
codeforge doctor --runtime # 额外检查当前项目的 worktree 运行时健康度
|
|
100
103
|
|
|
101
104
|
检查项:
|
|
102
105
|
D1 manifest 登记但 disk 缺失 → ✗(建议跑 codeforge install)
|
|
103
106
|
D2 source 有但 disk 缺失 → ✗(建议跑 codeforge install)
|
|
104
107
|
D3 disk∩source 但 manifest 无 → ⚠(manifest 可能未更新)
|
|
105
108
|
第三方 .md 文件(不在 manifest 也不在 source)→ 静默跳过
|
|
109
|
+
--runtime worktree 健康度(追踪文件 / 超期 worktree / 待审 / 留痕 等 8 类信号,带下一步提示)
|
|
106
110
|
|
|
107
111
|
exit code:有 ✗ → 1,仅 ⚠ → 0,全绿 → 0`)
|
|
108
112
|
process.exit(0)
|
|
@@ -184,4 +188,40 @@ if (!hasErrors && stale.length === 0) {
|
|
|
184
188
|
}
|
|
185
189
|
}
|
|
186
190
|
|
|
191
|
+
// ────────────────────────────────────────────────────────────────────
|
|
192
|
+
// --runtime:worktree 运行时健康度(ADR:zero-command-worktree-convergence Phase 6c)
|
|
193
|
+
//
|
|
194
|
+
// 经 dist bundle 动态 import collectHealthDigest(dist 不存在 = 未 build → 优雅降级提示,
|
|
195
|
+
// 不阻断既有安装检查结果)。健康度查询只读,绝不 mutate。
|
|
196
|
+
// ────────────────────────────────────────────────────────────────────
|
|
197
|
+
if (args.runtime) {
|
|
198
|
+
console.log()
|
|
199
|
+
console.log(`${C.bold}runtime 健康度${C.reset}(当前项目 worktree)`)
|
|
200
|
+
const distIndex = path.join(REPO_ROOT, "dist", "index.js")
|
|
201
|
+
if (!existsSync(distIndex)) {
|
|
202
|
+
console.log(` ${C.yellow}⚠${C.reset} dist 未构建(${shortenHome(distIndex)} 不存在),跳过 runtime 检查`)
|
|
203
|
+
console.log(` 建议:跑 ${C.bold}npm run build${C.reset} 后重试`)
|
|
204
|
+
} else {
|
|
205
|
+
try {
|
|
206
|
+
const { collectHealthDigest } = await import(url.pathToFileURL(distIndex).href)
|
|
207
|
+
if (typeof collectHealthDigest !== "function") {
|
|
208
|
+
console.log(` ${C.yellow}⚠${C.reset} 当前 dist 版本不含 collectHealthDigest(旧版本?),请重新 build`)
|
|
209
|
+
} else {
|
|
210
|
+
const digest = await collectHealthDigest(process.cwd())
|
|
211
|
+
if (!digest || !digest.hasIssues) {
|
|
212
|
+
console.log(` ${C.green}✓${C.reset} worktree 运行时健康,无需操作`)
|
|
213
|
+
} else {
|
|
214
|
+
for (const sig of digest.signals) {
|
|
215
|
+
const icon = sig.informational ? `${C.dim}ℹ${C.reset}` : `${C.yellow}⚠${C.reset}`
|
|
216
|
+
console.log(` ${icon} ${sig.nextStep}`)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} catch (e) {
|
|
221
|
+
console.log(` ${C.yellow}⚠${C.reset} runtime 健康度采集失败:${e?.message ?? e}`)
|
|
222
|
+
console.log(` ${C.dim}(不影响上方安装检查结果)${C.reset}`)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
187
227
|
process.exit(hasErrors ? 1 : 0)
|