dsh-request-doctor 0.13.3 → 0.13.4

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
4
  **产品标识**:request-doctor
5
- **版本**:0.13.3
5
+ **版本**:0.13.4
6
6
 
7
7
  ---
8
8
 
@@ -1,7 +1,7 @@
1
1
  # 软件设计说明
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.13.3
4
+ **版本**:0.13.4
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.2
6
6
 
7
7
  ---
@@ -1,7 +1,7 @@
1
1
  # 软件测试报告
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.13.3
4
+ **版本**:0.13.4
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.6;GB/T 8566-2007 验证与确认过程
6
6
 
7
7
  ---
@@ -62,10 +62,11 @@
62
62
  | `test/client-half.test.mjs` | 9 | 客户端半:模块身份、注入声明、apply 注册、组件能渲染 |
63
63
  | `test/diagnostics.test.mjs` | 3 | 快照可选写入:不配置不写盘、突发合并、坏路径不致命 |
64
64
  | `test/restart-notice.test.mjs` | 3 |
65
+ | `test/allow-version.test.mjs` | 5 | 放行:版本必填、缺管理器拒绝、成功只调一次、失败如实报 |
65
66
  | `test/panel-blocked.test.mjs` | 7 | 冲突判定:审计兼容却被拒装、清单形状解析、给 allow 动作 |
66
67
  | `test/panel-briefs.test.mjs` | 6 | 界面摘要:按名索引、只送可见行、缺数据不抛、不污染诊断 |
67
68
  | `test/verdict-report.test.mjs` | 29 | why 与 list:判定、理由、环境摘要、自动扫描、分组、缺口、按形态给建议 | 缺导出判为需要重启;其它失败不误判;多次累积不覆盖 |
68
- | **合计** | **206** | **全部通过** |
69
+ | **合计** | **211** | **全部通过** |
69
70
 
70
71
  执行结果:
71
72
 
@@ -218,4 +219,4 @@
218
219
 
219
220
  ### 7.2 分文件执行结果
220
221
 
221
- 33 个测试文件逐个单独执行,每个都有用例且全部通过,不存在因导入失败而静默跳过的文件。用例数分布:compat.test.mjs 17、plugin.test.mjs 15、compat-env.test.mjs 14、classify.test.mjs 13,其余按职能分散,合计 206。
222
+ 34 个测试文件逐个单独执行,每个都有用例且全部通过,不存在因导入失败而静默跳过的文件。用例数分布:compat.test.mjs 17、plugin.test.mjs 15、compat-env.test.mjs 14、classify.test.mjs 13,其余按职能分散,合计 211。
@@ -1,7 +1,7 @@
1
1
  # 软件安装部署说明
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.13.3
4
+ **版本**:0.13.4
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.7
6
6
 
7
7
  ---
@@ -1,7 +1,7 @@
1
1
  # 软件用户手册
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.13.3
4
+ **版本**:0.13.4
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.5
6
6
 
7
7
  ---
@@ -1,7 +1,7 @@
1
1
  # 软件质量度量报告
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.13.3
4
+ **版本**:0.13.4
5
5
  **度量标准**:GB/T 45717-2025《信息技术 软件测量 软件质量测量 自动化的源代码质量测度》
6
6
  **度量工具**:`tools/quality-measure.mjs`(本仓库自带,可复现)
7
7
 
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "standard": "GB/T 45717-2025 信息技术 软件测量 软件质量测量 自动化的源代码质量测度",
3
- "generatedAt": "2026-10-29T16:18:26.713Z",
3
+ "generatedAt": "2026-10-29T16:21:27.245Z",
4
4
  "scope": {
5
- "files": 34,
6
- "totalLines": 5295,
7
- "sourceLines": 3831,
8
- "commentLines": 975
5
+ "files": 35,
6
+ "totalLines": 5313,
7
+ "sourceLines": 3841,
8
+ "commentLines": 982
9
9
  },
10
10
  "measures": {
11
- "commentDensity": 25.45,
12
- "duplicationPercent": 4.92,
13
- "functionCount": 404,
11
+ "commentDensity": 25.57,
12
+ "duplicationPercent": 4.97,
13
+ "functionCount": 406,
14
14
  "maxComplexity": 10,
15
15
  "maxFunctionLines": 59,
16
16
  "maxFileLines": 500,
17
- "averageComplexity": 3.88
17
+ "averageComplexity": 3.87
18
18
  },
19
19
  "limits": {
20
20
  "maxComplexity": 10,
package/index.js CHANGED
@@ -20,6 +20,7 @@
20
20
  import { explainVerdict, listAudited } from './lib/verdict-report.js';
21
21
  import { panelBriefs } from './lib/panel-briefs.js';
22
22
  import { readRefused, refusedRowsOf } from './lib/refused-list.js';
23
+ import { allowVersion } from './lib/allow-version.js';
23
24
  import { parseRetryConfig } from './lib/classify.js';
24
25
  import { collectPackageFacts, entryPathOf } from './lib/compat-repair.js';
25
26
  import { unmetPeers } from './lib/compat.js';
@@ -392,33 +393,12 @@ async function prepareInstallCommand(spec, deps) {
392
393
  // 而检查只认显式授权。所以给用户一个在点安装之前把这件事做掉的入口:
393
394
  // 先 /doctor allow,再在界面上装,装完扫描会自动把声明对齐、环境建好。
394
395
  async function allowVersionCommand(spec, deps) {
395
- const trimmed = String(spec ?? '').trim();
396
- if (trimmed === '') return { kind: 'error', text: '用法:/doctor allow <包名@版本>' };
397
- if (trimmed.includes('@', 1) === false) {
398
- return { kind: 'error', text: '要写清楚版本,例如 /doctor allow dsh-ssh-ops@0.4.0' };
399
- }
400
-
401
- // 授权必须有明确的运行时版本和管理器实例,缺一个都做不了。
402
- const runtimeVersion = deps.probe.runtimeFacts().runtimeVersion ?? '';
403
- const ready = runtimeVersion !== '' && deps.pluginManager !== undefined;
404
- if (ready === false) return { kind: 'error', text: '拿不到当前 DSH 版本或管理器不可用,无法授权' };
405
-
406
- try {
407
- await deps.pluginManager.setVersionExemption(trimmed, runtimeVersion, true, true);
408
- } catch (error) {
409
- return { kind: 'error', text: `授权失败:${String(error)}` };
410
- }
411
- const note = `已放行 ${trimmed} 在 ${runtimeVersion} 上运行`;
412
- deps.record('version-allowed', note);
413
-
414
- return {
415
- kind: 'success',
416
- text: [
417
- `已授权 ${trimmed} 运行在 ${runtimeVersion}`,
418
- '现在可以在插件面板里正常安装它了。',
419
- '装完之后,声明对齐和兼容环境会自动补上。',
420
- ].join('\n'),
421
- };
396
+ const facts = deps.probe.runtimeFacts();
397
+ return allowVersion(spec, {
398
+ runtimeVersion: facts.runtimeVersion,
399
+ manager: deps.pluginManager,
400
+ record: deps.record,
401
+ });
422
402
  }
423
403
 
424
404
  // 自己装一个注册表里的包。
@@ -0,0 +1,38 @@
1
+ // 放行一个插件在某个运行时版本上运行。
2
+ //
3
+ // /doctor allow 与界面上的按钮都要做这件事,规则只有一份:
4
+ // 必须写清版本,必须有当前运行时版本和管理器实例。
5
+
6
+ // @param {string} spec - 形如 包名@版本。
7
+ // @param {object} input - { runtimeVersion, manager, record }。
8
+ // @returns {Promise<{kind: string, text: string}>} 命令结果。
9
+ export async function allowVersion(spec, input) {
10
+ const trimmed = String(spec ?? '').trim();
11
+ if (trimmed === '') return { kind: 'error', text: '用法:/doctor allow <包名@版本>' };
12
+ if (trimmed.includes('@', 1) === false) return { kind: 'error', text: '要写清楚版本,例如 /doctor allow dsh-ssh-ops@0.4.0' };
13
+
14
+ const runtimeVersion = input.runtimeVersion ?? '';
15
+ if (runtimeVersion === '' || input.manager === undefined) return { kind: 'error', text: '拿不到当前 DSH 版本或管理器不可用,无法授权' };
16
+
17
+ try {
18
+ await input.manager.setVersionExemption(trimmed, runtimeVersion, true, true);
19
+ } catch (error) {
20
+ return { kind: 'error', text: `授权失败:${String(error)}` };
21
+ }
22
+ input.record?.('version-allowed', `已放行 ${trimmed} 在 ${runtimeVersion} 上运行`);
23
+
24
+ return {
25
+ kind: 'success',
26
+ text: [
27
+ `已授权 ${trimmed} 运行在 ${runtimeVersion}`,
28
+ '现在可以在插件面板里正常安装它了。',
29
+ '装完之后,声明对齐和兼容环境会自动补上。',
30
+ ].join('\n'),
31
+ };
32
+ }
33
+ // 没写版本时给一条能直接照抄的例子,省得去翻文档。
34
+ export function allowHint(name) {
35
+ const base = String(name ?? '').trim();
36
+ if (base === '') return '用法:/doctor allow <包名@版本>';
37
+ return `要在插件页安装它,先执行:/doctor allow ${base}@<版本>`;
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-request-doctor",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "自动修复客户端引起的请求失败,并让版本不匹配的 DSH 插件能装上、能跑起来。",
5
5
  "keywords": [
6
6
  "dsh-plugin",