@moonquake2004/dsh-doctor 0.4.5 → 0.4.6
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.md +1 -0
- package/README.zh.md +1 -0
- package/dsh-doctor.mjs +99 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ With `--envelope` (doctor-contract mode): `0` = all pass · `1` = any WARN · `2
|
|
|
53
53
|
| P13 | client-half `provide` service name clashes with core client services (`chatFileMentions` etc. from `@deepseek-ai/dsh-client-*`, warn) or cross-bundle same-name grabs (browser-side "service already registered" → UI white screen, server logs see nothing) | [#2752](https://github.com/deepseek-ai/deepseek-harness/discussions/2752) |
|
|
54
54
|
| P14 | declared `bin` executability (target file present + shebang required for text `bin`; exec-bit alone does not identify the interpreter → ENOEXEC on direct run, #1846) | [#1846](https://github.com/deepseek-ai/deepseek-harness/discussions/1846) |
|
|
55
55
|
| P16 | plugin imports a named export the installed package does not provide (warn; boot fails hard on one bad entry) | [#5864](https://github.com/deepseek-ai/deepseek-harness/discussions/5864) |
|
|
56
|
+
| P17 | client-side `require()` of a specifier the host module table cannot serve (platform seeds ∪ installed graph rows ∪ declared externals) — warn-only; catches the browser `Failed to load plugins` white screen | [#5719](https://github.com/deepseek-ai/deepseek-harness/discussions/5719) |
|
|
56
57
|
|
|
57
58
|
### session
|
|
58
59
|
| ID | Checks | Discussion |
|
package/README.zh.md
CHANGED
|
@@ -48,6 +48,7 @@ node dsh-doctor.mjs --no-catalog # 不拉远程目录(只用内置副
|
|
|
48
48
|
| P13 | client 半 `provide` 服务名抢注核心客户端服务(`chatFileMentions` 等 `@deepseek-ai/dsh-client-*`,warn)或跨 bundle 同名(浏览器端 service already registered → UI 白屏、服务端日志无感知) | [#2752](https://github.com/deepseek-ai/deepseek-harness/discussions/2752) |
|
|
49
49
|
| P14 | 声明 `bin` 可执行性(目标文件在位 + 文本 bin 必须带 shebang;仅可执行位不识别解释器 → 直接执行 ENOEXEC,#1846) | [#1846](https://github.com/deepseek-ai/deepseek-harness/discussions/1846) |
|
|
50
50
|
| P16 | 插件导入了已装包未提供的命名导出(warn;单条坏 entry 即 boot 硬失败) | [#5864](https://github.com/deepseek-ai/deepseek-harness/discussions/5864) |
|
|
51
|
+
| P17 | client 端 `require()` 的模块宿主模块表无法服务(平台种子 ∪ 已装图行 ∪ 声明的 external)——warn 级;抓浏览器 `Failed to load plugins` 白屏 | [#5719](https://github.com/deepseek-ai/deepseek-harness/discussions/5719) |
|
|
51
52
|
|
|
52
53
|
### session
|
|
53
54
|
| ID | 检查 | 对应讨论 |
|
package/dsh-doctor.mjs
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* P10 inject 引用客户端专属服务(#1947:@deepseek-ai/dsh-client-* 服务端永不提供 → Fiber 永久 PENDING → web boot 失败)
|
|
16
16
|
* P11 已装 bundle 的 main 入口产物缺失(#1965:市场装未构建源码树 → ERR_MODULE_NOT_FOUND → boot 崩)
|
|
17
17
|
* P13 client 端 provide 服务名抢注核心客户端服务 / 跨 bundle 同名(#2752:浏览器端 service already registered → UI 白屏,服务端日志无感知)
|
|
18
|
+
* P17 client 端 require 不在宿主模块表(#5719:warn 级,种子表自省自 web-frontend 产物)
|
|
18
19
|
* P16 命名导入的导出缺失(#5864:warn 级,静态自省已装包导出面)
|
|
19
20
|
* P14 declared bin 可执行性(#1846:打包成功但 bin 缺 shebang/产物 → 直接执行 ENOEXEC;与 P11 互补)
|
|
20
21
|
* P12 `installed_bundle`(#1719 v1.1 词汇:profile 内 bundle 版本 vs 运行 CLI 版本——web 面板/API 跑的是 profile 里装的 bundle,可与独立 CLI 版本不一致)
|
|
@@ -957,6 +958,72 @@ function packageNamedExports(pkgDir) {
|
|
|
957
958
|
} else {
|
|
958
959
|
report('profile', 'P16', true, '插件命名导入均在已装包的导出里(静态可判定的部分)', undefined);
|
|
959
960
|
}
|
|
961
|
+
|
|
962
|
+
/* P17:client 端 require 的 specifier 不在宿主模块表(#5719:dsh-client-modules 的 makeRequire 硬 throw
|
|
963
|
+
* → 浏览器端 Failed to load plugins / 白屏,服务端 HTTP 200 且日志零感知)。
|
|
964
|
+
* 可服务 ⟺ 平台种子 ∪ 图行(已装包同时有 dsh.client 与 exports["./client"])∪ 该包声明的 external/inject。
|
|
965
|
+
* 防误报(#5719 实测得出):必须先剥注释(JSDoc 里的 require("picomatch") 示例会误报)、只认双引号形态、
|
|
966
|
+
* 排除模板插值/相对路径/Node 内置、归一 /client 后缀、跳过自引用。warn 级(静态近似,宁可漏报不误报)。 */
|
|
967
|
+
const p17Issues = [];
|
|
968
|
+
const composedRows = new Set();
|
|
969
|
+
{
|
|
970
|
+
const roots = [];
|
|
971
|
+
try { roots.push(join(resolveProfile(profileArg), 'node_modules')); } catch { /* 无 profile */ }
|
|
972
|
+
for (const lib of SESSION_LIBS) roots.push(lib.slice(0, lib.indexOf(join('@deepseek-ai', 'dsh-session'))));
|
|
973
|
+
for (const nm of roots) {
|
|
974
|
+
if (!existsSync(nm)) continue;
|
|
975
|
+
const pkgs = [];
|
|
976
|
+
for (const d of readdirSync(nm)) {
|
|
977
|
+
if (d.startsWith('.')) continue;
|
|
978
|
+
if (d.startsWith('@')) { // scoped:@scope/name 两层
|
|
979
|
+
const scopeDir = join(nm, d);
|
|
980
|
+
try { for (const n of readdirSync(scopeDir)) pkgs.push(join(scopeDir, n)); } catch { /* 忽略 */ }
|
|
981
|
+
} else pkgs.push(join(nm, d));
|
|
982
|
+
}
|
|
983
|
+
for (const dir of pkgs) {
|
|
984
|
+
const pj = join(dir, 'package.json');
|
|
985
|
+
if (!existsSync(pj)) continue;
|
|
986
|
+
try {
|
|
987
|
+
const pkg = JSON.parse(readFileSync(pj, 'utf8'));
|
|
988
|
+
if (pkg.name && pkg.dsh?.client && pkg.exports?.['./client']) { composedRows.add(pkg.name); composedRows.add(`${pkg.name}/client`); }
|
|
989
|
+
} catch { /* 忽略 */ }
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
const stripClientSuffix = (s) => s.replace(/\/client$/, '');
|
|
994
|
+
for (const [b, d] of bundleDirs) {
|
|
995
|
+
const declared = new Set();
|
|
996
|
+
try {
|
|
997
|
+
const pkg = JSON.parse(readFileSync(join(d, 'package.json'), 'utf8'));
|
|
998
|
+
for (const k of ['external', 'inject']) {
|
|
999
|
+
const v = pkg.dsh?.client?.[k];
|
|
1000
|
+
if (Array.isArray(v)) for (const x of v) if (typeof x === 'string') declared.add(x);
|
|
1001
|
+
}
|
|
1002
|
+
} catch { /* 无 manifest */ }
|
|
1003
|
+
const misses = new Map();
|
|
1004
|
+
for (const f of collectClientJsFiles(d)) {
|
|
1005
|
+
let code = readJs(f);
|
|
1006
|
+
code = code.replace(/\/\*[\s\S]*?\*\//g, ''); // 块注释(JSDoc 示例会误报)
|
|
1007
|
+
code = code.replace(/(^|[^:])\/\/[^\n]*/g, '$1'); // 行注释(避开 https://)
|
|
1008
|
+
for (const m of code.matchAll(/require\(\s*"([^"]+)"\s*\)/g)) { // 打包产物用双引号;单引号多为文档示例
|
|
1009
|
+
const spec = m[1];
|
|
1010
|
+
if (!spec || spec.includes('${') || spec.startsWith('.') || spec.startsWith('/') || spec.startsWith('node:')) continue;
|
|
1011
|
+
if (NODE_BUILTINS.has(spec)) continue;
|
|
1012
|
+
const id = stripClientSuffix(spec);
|
|
1013
|
+
if (CLIENT_SEEDS.has(spec) || CLIENT_SEEDS.has(id)) continue;
|
|
1014
|
+
if (composedRows.has(spec) || composedRows.has(id)) continue;
|
|
1015
|
+
if (declared.has(spec) || declared.has(id)) continue;
|
|
1016
|
+
if (id === b || spec === b) continue; // 自引用 → 打包内联
|
|
1017
|
+
misses.set(spec, relative(d, f));
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
if (misses.size) p17Issues.push(`${b}(${[...misses].map(([s, f]) => `require("${s}") [${f}]`).join('; ')})`);
|
|
1021
|
+
}
|
|
1022
|
+
if (p17Issues.length) {
|
|
1023
|
+
report('profile', 'P17', false, `client 端 require 的模块不在宿主模块表(#5719:makeRequire 硬 throw → 浏览器白屏且服务端无感知): ${p17Issues.join('; ')}`, `改用宿主提供的模块名;若确由宿主提供,在本包 package.json 的 dsh.client.external/inject 里声明;平台种子当前 ${CLIENT_SEEDS.size} 项、已装图行 ${composedRows.size} 项`);
|
|
1024
|
+
} else {
|
|
1025
|
+
report('profile', 'P17', true, `client 端 require 的 specifier 均可服务(平台种子 ${CLIENT_SEEDS.size} 项 + 已装图行 ${composedRows.size} 项)`, undefined);
|
|
1026
|
+
}
|
|
960
1027
|
}
|
|
961
1028
|
|
|
962
1029
|
/* ================= session ================= */
|
|
@@ -1174,6 +1241,37 @@ function loadFormatCatalog() {
|
|
|
1174
1241
|
}
|
|
1175
1242
|
const FORMAT_CATALOG = loadFormatCatalog();
|
|
1176
1243
|
|
|
1244
|
+
/* P17:平台种子表 + Node 内置模块(#5719)
|
|
1245
|
+
* 种子 = 浏览器端 require 的"平台种子词",由宿主 web-frontend 构建产物决定;自省失败回退常量。 */
|
|
1246
|
+
const CLIENT_PLATFORM_SEEDS_FALLBACK = new Set([
|
|
1247
|
+
'react', 'react/jsx-runtime', 'react-dom', 'react-dom/client', '@deepseek-ai/cordis',
|
|
1248
|
+
'@deepseek-ai/dsh-client-store', '@deepseek-ai/dsh-client-ui-slots',
|
|
1249
|
+
'@deepseek-ai/dsh-client-ui-primitives', '@deepseek-ai/dsh-client-ui-dockkit',
|
|
1250
|
+
]);
|
|
1251
|
+
function clientPlatformSeeds() {
|
|
1252
|
+
for (const lib of SESSION_LIBS) {
|
|
1253
|
+
const nm = lib.slice(0, lib.indexOf(join('@deepseek-ai', 'dsh-session')));
|
|
1254
|
+
const assets = join(nm, '@deepseek-ai', 'dsh-web-frontend', 'dist', 'assets');
|
|
1255
|
+
if (!existsSync(assets)) continue;
|
|
1256
|
+
for (const f of readdirSync(assets)) {
|
|
1257
|
+
if (!/^index-.*\.js$/.test(f) && !/\.js$/.test(f)) continue;
|
|
1258
|
+
try {
|
|
1259
|
+
const s = readFileSync(join(assets, f), 'utf8');
|
|
1260
|
+
const i = s.indexOf('dsh-client-ui-dockkit');
|
|
1261
|
+
if (i < 0) continue;
|
|
1262
|
+
const win = s.slice(Math.max(0, i - 1400), i + 60);
|
|
1263
|
+
const keys = [...win.matchAll(/["']?([A-Za-z@][^"':,{}]*)["']?\s*:\s*[A-Za-z_$][\w$]*/g)]
|
|
1264
|
+
.map((m) => m[1].trim()).filter((k) => /^(react|react-dom|@deepseek-ai\/)/.test(k));
|
|
1265
|
+
if (keys.length >= 8) return new Set(keys);
|
|
1266
|
+
} catch { /* 试下一个资产 */ }
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return CLIENT_PLATFORM_SEEDS_FALLBACK;
|
|
1270
|
+
}
|
|
1271
|
+
const CLIENT_SEEDS = clientPlatformSeeds();
|
|
1272
|
+
const NODE_BUILTINS = new Set(['url','path','fs','util','events','stream','buffer','crypto','os','zlib','assert','worker_threads','perf_hooks','querystring','string_decoder','timers','tty','net','http','https','child_process','process','module','v8','vm','tls','dns','readline','repl','cluster','constants','domain','punycode','sys','timers/promises','fs/promises','stream/web','stream/promises','util/types','dns/promises']);
|
|
1273
|
+
|
|
1274
|
+
|
|
1177
1275
|
/** 用**真实迁移链**在内存里跑一遍:返回 null = 可恢复,否则返回拒载原因(截断)。
|
|
1178
1276
|
* 比复刻规则更准(上游每条 fail-closed 规则都覆盖,且自动跟随版本变化)。 */
|
|
1179
1277
|
function realChainRefusal(text) {
|
|
@@ -1361,6 +1459,7 @@ catalogSeverity.set('P13', 'warn');
|
|
|
1361
1459
|
catalogSeverity.set('P14', 'warn');
|
|
1362
1460
|
catalogSeverity.set('P15', 'error');
|
|
1363
1461
|
catalogSeverity.set('P16', 'warn');
|
|
1462
|
+
catalogSeverity.set('P17', 'warn');
|
|
1364
1463
|
|
|
1365
1464
|
function bundledCatalog() {
|
|
1366
1465
|
const p = new URL('./checks.json', import.meta.url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonquake2004/dsh-doctor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
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": [
|