@moonquake2004/dsh-doctor 0.4.7 → 0.4.8
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/dsh-doctor.mjs +17 -3
- package/package.json +1 -1
package/dsh-doctor.mjs
CHANGED
|
@@ -493,6 +493,20 @@ function checkProfile(name) {
|
|
|
493
493
|
}
|
|
494
494
|
// P3 insert name 可解析性
|
|
495
495
|
const req = (() => { try { return createRequire(join(dir, '_anchor.js')); } catch { return null; } })();
|
|
496
|
+
// 判据(#1719 taltara 的正确性陷阱,2026-09-12 实测命中我们):**不能以 require.resolve 为准** ——
|
|
497
|
+
// ESM-only 包(exports 只声明 import 条件)会让 require.resolve 抛 ERR_PACKAGE_PATH_NOT_EXPORTED,
|
|
498
|
+
// 而 loader 能正常 import;用它判定会把健康 profile 报成 FAIL(比没有 doctor 更糟)。
|
|
499
|
+
// 改为**存在性判据**:node_modules/<name>/package.json 存在即可(scoped 取两段),
|
|
500
|
+
// 并向上找一层以覆盖 profile 根安装(~/.dsh/profiles/node_modules)。require.resolve 仅作正向加分。
|
|
501
|
+
const nmRoots = [join(dir, 'node_modules'), join(dirname(dir), 'node_modules')];
|
|
502
|
+
const pkgPresent = (n) => {
|
|
503
|
+
if (n.startsWith('cordis:')) return true; // 宿主内置
|
|
504
|
+
if (n.startsWith('.') || n.startsWith('/') || n.startsWith('~')) return true; // 相对/绝对路径
|
|
505
|
+
const seg = String(n).split('/');
|
|
506
|
+
const pkgName = n.startsWith('@') ? seg.slice(0, 2).join('/') : seg[0]; // scoped 需两段
|
|
507
|
+
if (!pkgName) return true;
|
|
508
|
+
return nmRoots.some((root) => existsSync(join(root, pkgName, 'package.json')));
|
|
509
|
+
};
|
|
496
510
|
const bad = [];
|
|
497
511
|
for (const n of userNames) {
|
|
498
512
|
if (n.startsWith('@local/') || n.startsWith('@liustack/')) {
|
|
@@ -503,9 +517,9 @@ function checkProfile(name) {
|
|
|
503
517
|
continue;
|
|
504
518
|
}
|
|
505
519
|
}
|
|
506
|
-
let
|
|
507
|
-
try { if (req) { req.resolve(n);
|
|
508
|
-
if (!
|
|
520
|
+
let resolved = false;
|
|
521
|
+
try { if (req) { req.resolve(n); resolved = true; } } catch { resolved = false; }
|
|
522
|
+
if (!resolved && !pkgPresent(n)) bad.push(n);
|
|
509
523
|
}
|
|
510
524
|
if (bad.length) report('profile', 'P3', false, `用户 patch 中不可解析的 name(#1197/#880): ${bad.join(', ')}`, `dsh plugin --profile ${name} add <包> 或修复 file: 依赖`);
|
|
511
525
|
else report('profile', 'P3', true, '用户 patch insert 均可解析', undefined);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonquake2004/dsh-doctor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Offline diagnostic for DeepSeek Harness — 28 built-in + 5 catalog checks across env/profile/session (Layer A checks-as-data), self-update (Layer B), and a semi-automatic LLM observer (Layer C, --observe); Doctor panel in web UI settings.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|