dsh-triage 0.3.3 → 0.3.5

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.
Files changed (42) hide show
  1. package/README.md +13 -13
  2. package/client.js +96 -29
  3. package/dist/audit-data.d.ts +1 -0
  4. package/dist/audit-data.d.ts.map +1 -1
  5. package/dist/audit-data.js +6 -1
  6. package/dist/audit-data.js.map +1 -1
  7. package/dist/cli.js +269 -11
  8. package/dist/cli.js.map +1 -1
  9. package/dist/host-allow.d.ts +41 -0
  10. package/dist/host-allow.d.ts.map +1 -0
  11. package/dist/host-allow.js +79 -0
  12. package/dist/host-allow.js.map +1 -0
  13. package/dist/host-audit-route.d.ts +25 -0
  14. package/dist/host-audit-route.d.ts.map +1 -1
  15. package/dist/host-audit-route.js +47 -9
  16. package/dist/host-audit-route.js.map +1 -1
  17. package/dist/host-summary-route.d.ts.map +1 -1
  18. package/dist/host-summary-route.js +2 -7
  19. package/dist/host-summary-route.js.map +1 -1
  20. package/dist/host-upgrade-route.d.ts.map +1 -1
  21. package/dist/host-upgrade-route.js +2 -7
  22. package/dist/host-upgrade-route.js.map +1 -1
  23. package/dist/host.d.ts.map +1 -1
  24. package/dist/host.js +4 -0
  25. package/dist/host.js.map +1 -1
  26. package/dist/load.d.ts +18 -0
  27. package/dist/load.d.ts.map +1 -1
  28. package/dist/load.js +41 -8
  29. package/dist/load.js.map +1 -1
  30. package/dist/rescue.d.ts +156 -0
  31. package/dist/rescue.d.ts.map +1 -0
  32. package/dist/rescue.js +271 -0
  33. package/dist/rescue.js.map +1 -0
  34. package/dist/serve.d.ts +38 -1
  35. package/dist/serve.d.ts.map +1 -1
  36. package/dist/serve.js +114 -28
  37. package/dist/serve.js.map +1 -1
  38. package/dist/summary.d.ts +13 -0
  39. package/dist/summary.d.ts.map +1 -1
  40. package/dist/summary.js +17 -1
  41. package/dist/summary.js.map +1 -1
  42. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -16,7 +16,7 @@ import { createHash } from 'node:crypto';
16
16
  import { homedir, tmpdir } from 'node:os';
17
17
  import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
18
18
  import process from 'node:process';
19
- import { catalogFor, compareInventory, DIST_TAG_PACKAGE, distTagTargetOf, evaluateAdmission, extractEntryClaims, extractPresetDeclarations, findEntryIdCollisions, findPresetDivergence, format, groupClaimsBySource, hasNewDenials, judgeUpgradeImpact, judgeVersionDrift, loadEnv, parseInventorySnapshot, parsePatchYaml, redactEnv, redactPath, redactVerdict, registryFactFor, renderUpgradeImpact, renderUpgradeCard, renderVerdict, resolveDistTagTarget, rowTargets, upgradeTargetProblem, verdictFromAdmission, verdictsFromCollisions, verdictsFromDuplicateCopies, verdictsFromInventory, verdictsFromRowAdmission, } from '@dsh-triage/core';
19
+ import { catalogFor, compareInventory, DIST_TAG_PACKAGE, distTagTargetOf, evaluateAdmission, extractEntryClaims, extractPresetDeclarations, findEntryIdCollisions, findPresetDivergence, format, groupClaimsBySource, hasNewDenials, judgeUpgradeImpact, judgeUpdateOrder, judgeVersionDrift, loadEnv, parseInventorySnapshot, parsePatchYaml, redactEnv, redactPath, redactVerdict, registryFactFor, renderUpgradeImpact, renderUpgradeCard, renderVerdict, resolveDistTagTarget, rowTargets, upgradeTargetProblem, verdictFromAdmission, verdictsFromCollisions, verdictsFromDuplicateCopies, verdictsFromInventory, verdictsFromRowAdmission, } from '@dsh-triage/core';
20
20
  import { buildProbePlan, executeProbe, findFreePort, judgeProbe, probeVerdict } from '@dsh-triage/probe';
21
21
  import { discoverLocalArtifacts, fetchPackument } from '@dsh-triage/signals';
22
22
  import { auditExitOutcome, auditJsonPayload, auditRedactRoots, loadAuditData, redactedEnv, redactedVerdicts, } from './audit-data.js';
@@ -29,8 +29,10 @@ import { outcomeStatus, purgeOutcomes, renderPurge, renderStatus } from './outco
29
29
  import { recordOutcomes } from './outcomes/store.js';
30
30
  import { candidatePackageName, normalizeCandidateSpec, probeScratchRoot, realDshHomeOf, realProbeDeps, sandboxBundles, } from './probe-run.js';
31
31
  import { applyExemptionFixes, planFixes, readProfileDependencies, runtimeSupportsExemptions, undoFix } from './fix.js';
32
+ import { applyRescue, classifyBundles, readProfileBundles, undoRescue } from './rescue.js';
33
+ import { allowedHosts } from './host-allow.js';
32
34
  import { startPanel } from './serve.js';
33
- import { buildProfileSummary, formatProfileSummary } from './summary.js';
35
+ import { buildProfileSummary, formatProfileSummary, runtimeLabel } from './summary.js';
34
36
  const EXIT_OK = 0;
35
37
  const EXIT_FINDINGS = 1;
36
38
  const EXIT_USAGE = 2;
@@ -57,11 +59,12 @@ Usage
57
59
  dsh-triage upgrade --to <version> which rows/bundles the target dsh would deny, and how to fix
58
60
  dsh-triage upgrade --to next|latest same judgement, with the target resolved from npm dist-tags
59
61
  dsh-triage fix what can be repaired automatically; --apply writes, --undo reverts
62
+ dsh-triage rescue which third-party bundles a rescue would trim (plan only, read-only)
60
63
  Flags
61
64
  --json machine-readable output
62
65
  --all include findings that are not blocking (audit: print the full ledger)
63
- --apply (fix) actually write the plan; without it nothing is written
64
- --undo <journal> (fix) restore the files an earlier --apply changed
66
+ --apply (fix) actually write the plan; (rescue) take the listed bundles out
67
+ --undo <journal> (fix, rescue) restore the files an earlier --apply changed
65
68
  --strict exit 1 when a conclusion is not "go"
66
69
  --profile <name> profile name (default: web)
67
70
  --dsh-home <path> override $DSH_HOME (default: ~/.dsh)
@@ -79,6 +82,8 @@ Flags
79
82
  --unsettled-timeout <ms> (probe --execute) readiness window while the tree is still composing (default 20000)
80
83
  --copy-profile <name> (probe) measure inside a copy of this profile's declarations (T-304)
81
84
  --port <n> (serve) port to bind on 127.0.0.1; 0 picks a free one
85
+ --host <addr> (serve) bind address; default 127.0.0.1 (ADR-0014)
86
+ --allow-host <name> (serve) extra Host name the panel answers; repeatable; required with --host 0.0.0.0
82
87
  --results <dir> (serve, badge) directory of evidence to read (default: ./data/results)
83
88
  --out <file> (badge) write the SVG here; (upgrade --card) write the card here, print the path
84
89
  --allow-execute (serve) enable actions; without it the panel is read-only
@@ -90,7 +95,7 @@ Flags
90
95
  --purge (outcomes) delete every record this tool stored, then the directory
91
96
  --status (outcomes) how many records exist (default when no verb is given)
92
97
  --to <version> (upgrade) target dsh: exact semver (e.g. 0.3.0), or next / latest (resolved from npm)
93
- --registry (upgrade) annotate with published builds that declare the target (offline by default)
98
+ --registry (upgrade) annotate with published builds that declare the target; (audit) add publish-order evidence per installed package
94
99
  --card (upgrade) paste-ready markdown for the release discussion (four buckets + boundary)
95
100
  --help this text
96
101
 
@@ -113,11 +118,12 @@ const HELP_ZH = `dsh-triage · 本地插件兼容分诊台 — DeepSeek Harness
113
118
  dsh-triage upgrade --to <目标版本> 预检目标 DSH 版本会拦截当前哪些插件,并输出修复建议
114
119
  dsh-triage upgrade --to next|latest 预检升级至 npm 远端 next/latest 版本的兼容影响
115
120
  dsh-triage fix 自动修复计划;--apply 实际写入,--undo 依日志撤销
121
+ dsh-triage rescue 救援计划:哪些第三方 bundle 可以先裁掉(只读,不写盘)
116
122
  参数 (Flags)
117
123
  --json 输出机器可读的 JSON 数据
118
124
  --all 包含非阻断性条目(audit 命令下打印全量台账)
119
- --apply (fix) 真正执行修复写入;不加此参数时仅输出方案
120
- --undo <日志文件> (fix) 依据此前执行生成的日志文件回滚修复改动
125
+ --apply (fix) 真正执行修复写入;(rescue) 把列出的 bundle 从配置中移除
126
+ --undo <日志文件> (fix, rescue) 依据此前执行生成的日志文件回滚改动
121
127
  --strict 当存在非 "go" 结论时以退出码 1 退出
122
128
  --profile <名称> 指定分析的 Profile 名称(默认:web)
123
129
  --dsh-home <路径> 覆盖 $DSH_HOME 路径(默认:~/.dsh)
@@ -125,9 +131,12 @@ const HELP_ZH = `dsh-triage · 本地插件兼容分诊台 — DeepSeek Harness
125
131
  --no-redact 在 --json 输出中保留原始绝对路径(默认脱敏为 ~)
126
132
  --stamp <iso时间戳> 指定固定时间戳以获得确定性输出
127
133
  --to <版本> (upgrade) 目标 DSH 版本:精确 semver(如 0.2.1-rc.5)或 next / latest
134
+ --registry (upgrade) 标注哪些已发布构建声明了目标版本;(audit) 为每个已装包补「发布顺序」证据
128
135
  --card (upgrade) 输出格式化 Markdown 升级卡片
129
136
  --execute (probe) 在独立隔离临时 DSH_HOME 中真正拉起沙盒执行实测
130
137
  --port <端口> (serve) 本地面板绑定的端口(默认自动选取空闲端口)
138
+ --host <地址> (serve) 绑定地址(默认 127.0.0.1;ADR-0014)
139
+ --allow-host <名字> (serve) 额外允许的 Host 名(可重复;--host 0.0.0.0 时必须给)
131
140
  --help 显示帮助信息
132
141
 
133
142
  退出状态码: 0 正常 · 1 存在异常(audit 始终生效,其他命令需加 --strict) · 2 参数错误 · 3 元数据不可用
@@ -147,6 +156,8 @@ async function run(argv) {
147
156
  return commandStatus(flags);
148
157
  case 'fix':
149
158
  return commandFix(flags);
159
+ case 'rescue':
160
+ return commandRescue(flags);
150
161
  case 'env':
151
162
  return commandEnv(flags);
152
163
  case 'why':
@@ -401,7 +412,7 @@ async function commandWhy(flags) {
401
412
  });
402
413
  return exitFor(flags, findings);
403
414
  }
404
- process.stdout.write(`scanned ${composition.layers.length} bundles · ${claims.length} loader rows · ${rows.length} import targets · dsh ${env.dsh ?? 'unknown'} · profile ${env.profile}\n`);
415
+ process.stdout.write(`scanned ${composition.layers.length} bundles · ${claims.length} loader rows · ${rows.length} import targets · dsh ${runtimeLabel(env)} · profile ${env.profile}\n`);
405
416
  for (const error of bannerErrors)
406
417
  process.stdout.write(`warn ${error}\n`);
407
418
  if (findings.length === 0) {
@@ -1027,6 +1038,139 @@ async function commandStatus(flags) {
1027
1038
  * Prints a plan by default and writes NOTHING. `--apply` writes only the items the plan marked
1028
1039
  * `ready`, backs the file up first, and records a journal so `--undo` can put it back.
1029
1040
  */
1041
+ /**
1042
+ * `rescue` (M8): read-only plan by default, `--apply` takes the listed bundles out of
1043
+ * `dsh.profile.bundles`, `--undo <journal>` puts the manifest back byte for byte.
1044
+ *
1045
+ * Three things this command is careful about:
1046
+ * - **the plan writes nothing** — not even a backup, not even a formatted copy (C4);
1047
+ * - **it does not promise a boot** — the boundary sentence is part of the output, both locales (C5);
1048
+ * - **it never touches `dependencies`** — the whole point of trimming bundles is that undo stays
1049
+ * an array edit instead of a reinstall (spec §3 rule 3).
1050
+ */
1051
+ async function commandRescue(flags) {
1052
+ if (flags.undo !== null) {
1053
+ try {
1054
+ const { restored } = undoRescue(flags.undo);
1055
+ if (flags.json) {
1056
+ writeJson({ schema_version: 1, command: 'rescue', undo: flags.undo, restored });
1057
+ }
1058
+ else {
1059
+ process.stdout.write(flags.locale === 'zh'
1060
+ ? `已逐字节还原 ${restored.length} 个文件:\n`
1061
+ : `restored ${restored.length} file(s) byte for byte:\n`);
1062
+ for (const file of restored)
1063
+ process.stdout.write(` ${file}\n`);
1064
+ }
1065
+ return EXIT_OK;
1066
+ }
1067
+ catch (error) {
1068
+ process.stderr.write(`${flags.locale === 'zh' ? '无法撤销' : 'cannot undo'}: ${error instanceof Error ? error.message : String(error)}\n`);
1069
+ return EXIT_UNAVAILABLE;
1070
+ }
1071
+ }
1072
+ const env = await requireEnv(flags);
1073
+ if (env === null)
1074
+ return EXIT_UNAVAILABLE;
1075
+ const reading = readProfileBundles(env.profileDir);
1076
+ if (!reading.ok) {
1077
+ process.stderr.write(`${reading.reason}\n`);
1078
+ process.stderr.write('hint: pass --dsh-home <path> or --profile <name>\n');
1079
+ return EXIT_UNAVAILABLE;
1080
+ }
1081
+ const plan = classifyBundles({
1082
+ profile: env.profile,
1083
+ declared: reading.declared,
1084
+ installed: env.installed,
1085
+ manifestSha256: reading.manifestSha256,
1086
+ field: reading.field,
1087
+ });
1088
+ let run = { journal: '', backupDir: null, changes: [], removed: [], dryRun: true };
1089
+ if (flags.apply && plan.removable.length > 0) {
1090
+ try {
1091
+ run = applyRescue({
1092
+ plan,
1093
+ profileDir: env.profileDir,
1094
+ stamp: stampOf(flags),
1095
+ dryRun: false,
1096
+ });
1097
+ }
1098
+ catch (error) {
1099
+ process.stderr.write(`${flags.locale === 'zh' ? '无法应用' : 'cannot apply'}: ${error instanceof Error ? error.message : String(error)}\n`);
1100
+ return EXIT_UNAVAILABLE;
1101
+ }
1102
+ }
1103
+ if (flags.json) {
1104
+ // The plan carries no absolute paths by construction; the run does (journal/backup), so JSON
1105
+ // output keeps the same contract as every other command: redact unless --no-redact.
1106
+ const payload = {
1107
+ schema_version: 1,
1108
+ command: 'rescue',
1109
+ plan,
1110
+ run: flags.noRedact ? run : { ...run, journal: '', backupDir: null },
1111
+ };
1112
+ writeJson(payload);
1113
+ }
1114
+ else {
1115
+ const zh = flags.locale === 'zh';
1116
+ process.stdout.write(zh
1117
+ ? `rescue 计划 · profile ${plan.profile} · manifest ${plan.manifestSha256.slice(0, 12)}…\n`
1118
+ : `rescue plan · profile ${plan.profile} · manifest ${plan.manifestSha256.slice(0, 12)}…\n`);
1119
+ if (plan.empty) {
1120
+ process.stdout.write(zh
1121
+ ? plan.field === 'absent'
1122
+ ? '这个 profile 的 package.json 里没有 dsh.profile.bundles 字段——通常是 --dsh-home / --profile 指错了,而不是"没有问题"。\n'
1123
+ : 'dsh.profile.bundles 是空数组——这个 profile 没声明任何 bundle。\n'
1124
+ : plan.field === 'absent'
1125
+ ? 'this profile\'s package.json has no dsh.profile.bundles field — usually --dsh-home / --profile points somewhere else, not "nothing is wrong".\n'
1126
+ : 'dsh.profile.bundles is empty — this profile declares no bundles.\n');
1127
+ }
1128
+ else {
1129
+ process.stdout.write(zh
1130
+ ? `可裁 ${plan.removable.length} / ${plan.bundles.length} 个 bundle(第三方 ${plan.thirdParty} · 宣布了但没装 ${plan.unresolved})\n`
1131
+ : `${plan.removable.length} of ${plan.bundles.length} bundle(s) trimmable (${plan.thirdParty} third-party · ${plan.unresolved} listed-but-not-installed)\n`);
1132
+ for (const entry of plan.bundles) {
1133
+ const mark = entry.removable ? '✓' : '·';
1134
+ const version = entry.version === null ? '?' : entry.version;
1135
+ const spec = entry.spec === null ? '—' : entry.spec;
1136
+ process.stdout.write(` ${mark} ${entry.name}@${version} [${entry.origin}] · ${spec}\n`);
1137
+ process.stdout.write(` ${entry.detail}\n`);
1138
+ if (entry.removable) {
1139
+ process.stdout.write(zh
1140
+ ? ` 撤回方式:放回 dsh.profile.bundles 第 ${entry.restore.at + 1} 位\n`
1141
+ : ` undo: put "${entry.restore.entry}" back at position ${entry.restore.at + 1}\n`);
1142
+ }
1143
+ }
1144
+ if (plan.removable.length === 0) {
1145
+ process.stdout.write(zh ? '没有可裁的条目:全部是官方 bundle。\n' : 'nothing to trim: every bundle is official.\n');
1146
+ }
1147
+ }
1148
+ process.stdout.write(zh
1149
+ ? '\n边界:本计划只从声明层读 dsh.profile.bundles,不证明启动成功;启动验证请用 `dsh-triage probe --execute`。\n'
1150
+ : '\nboundary: this plan is read off dsh.profile.bundles only — it does not prove the host boots; verify with `dsh-triage probe --execute`.\n');
1151
+ if (run.dryRun) {
1152
+ process.stdout.write(plan.removable.length > 0
1153
+ ? zh
1154
+ ? '\n当前仅输出计划,未修改任何文件。如需执行:dsh-triage rescue --apply\n'
1155
+ : '\nplan only — nothing was written. To apply: dsh-triage rescue --apply\n'
1156
+ : zh
1157
+ ? '\n未修改任何文件:没有可裁的条目。\n'
1158
+ : '\nnothing was written: nothing to trim.\n');
1159
+ }
1160
+ else {
1161
+ process.stdout.write(zh
1162
+ ? `\n已从 dsh.profile.bundles 移除 ${run.removed.length} 个条目:${run.removed.join('、')}\n`
1163
+ : `\nremoved ${run.removed.length} entry/entries from dsh.profile.bundles: ${run.removed.join(', ')}\n`);
1164
+ process.stdout.write(zh ? `备份:${run.backupDir}\n` : `backup: ${run.backupDir}\n`);
1165
+ process.stdout.write(zh
1166
+ ? `撤销(逐字节还原):dsh-triage rescue --undo ${run.journal}\n`
1167
+ : `undo (byte for byte): dsh-triage rescue --undo ${run.journal}\n`);
1168
+ }
1169
+ }
1170
+ if (!run.dryRun)
1171
+ return EXIT_OK;
1172
+ return plan.removable.length > 0 ? EXIT_FINDINGS : EXIT_OK;
1173
+ }
1030
1174
  async function commandFix(flags) {
1031
1175
  if (flags.undo !== null) {
1032
1176
  try {
@@ -1115,6 +1259,79 @@ async function commandFix(flags) {
1115
1259
  return EXIT_OK;
1116
1260
  return run.dryRun ? EXIT_FINDINGS : plan.applicable === run.changes.length ? EXIT_OK : EXIT_FINDINGS;
1117
1261
  }
1262
+ function updateOrderRow(name, version, order) {
1263
+ return {
1264
+ name,
1265
+ version,
1266
+ verdict: order.verdict,
1267
+ installed_published_at: order.installedPublishedAt,
1268
+ candidate: order.candidate === null
1269
+ ? null
1270
+ : { version: order.candidate.version, published_at: order.candidate.publishedAt, days_older: order.candidate.daysOlder },
1271
+ latest_lags: order.latestLags,
1272
+ detail: order.detail,
1273
+ };
1274
+ }
1275
+ /**
1276
+ * T-861: publish-order evidence for every installed package, read only when the caller asked.
1277
+ *
1278
+ * WHY OPT-IN: `audit` is offline by contract. Adding registry reads to the default path would make
1279
+ * every existing automation depend on npm being reachable, and would break the "audit --json is the
1280
+ * same bytes as before" guarantee the panel and the tests rely on. `--registry` says it out loud.
1281
+ */
1282
+ async function collectUpdateOrders(env, at) {
1283
+ const targets = env.installed.filter((pkg) => pkg.version !== null);
1284
+ const rows = [];
1285
+ const concurrency = 4;
1286
+ for (let index = 0; index < targets.length; index += concurrency) {
1287
+ const slice = targets.slice(index, index + concurrency);
1288
+ const answers = await Promise.all(slice.map(async (pkg) => {
1289
+ const version = pkg.version;
1290
+ const packument = await fetchPackument(pkg.name, { at });
1291
+ if (!packument.ok) {
1292
+ const order = {
1293
+ verdict: 'unmeasured',
1294
+ installed: version,
1295
+ installedPublishedAt: null,
1296
+ candidate: null,
1297
+ latestLags: false,
1298
+ detail: `the registry could not be read for this package (${packument.error.code})`,
1299
+ };
1300
+ return updateOrderRow(pkg.name, version, order);
1301
+ }
1302
+ const value = packument.value;
1303
+ return updateOrderRow(pkg.name, version, judgeUpdateOrder({
1304
+ latest: value.distTags['latest'] ?? null,
1305
+ next: value.distTags['next'] ?? null,
1306
+ versions: [...value.versions.keys()],
1307
+ publishedAt: value.publishedAt,
1308
+ }, version));
1309
+ }));
1310
+ rows.push(...answers);
1311
+ }
1312
+ return rows;
1313
+ }
1314
+ function renderUpdateOrder(rows, locale) {
1315
+ const zh = locale === 'zh';
1316
+ const lines = [zh ? '\nupdate order(只读 registry)' : '\nupdate order (registry read)'];
1317
+ for (const row of rows) {
1318
+ const candidate = row.candidate === null ? '' : ` → ${row.candidate.version}`;
1319
+ const when = row.candidate === null
1320
+ ? ''
1321
+ : row.candidate.days_older > 0
1322
+ ? zh
1323
+ ? `(早 ${String(row.candidate.days_older)} 天发布)`
1324
+ : ` (published ${String(row.candidate.days_older)} day(s) earlier)`
1325
+ : zh
1326
+ ? `(晚 ${String(Math.abs(row.candidate.days_older))} 天发布)`
1327
+ : ` (published ${String(Math.abs(row.candidate.days_older))} day(s) later)`;
1328
+ lines.push(` ${row.verdict.padEnd(11)} ${row.name}@${row.version}${candidate}${when}`);
1329
+ }
1330
+ lines.push(zh
1331
+ ? ' 边界:这条只说明发布顺序,不改上面任何结论;也不证明哪个构建能跑。'
1332
+ : ' boundary: publish order only — it changes none of the conclusions above and proves no build runs.');
1333
+ return lines.join('\n');
1334
+ }
1118
1335
  async function commandAudit(flags) {
1119
1336
  const env = await requireEnv(flags);
1120
1337
  if (env === null)
@@ -1136,14 +1353,21 @@ async function commandAudit(flags) {
1136
1353
  const data = loaded.data;
1137
1354
  const { grouped, collisions, artifacts, duplicates, duplicateFindings, snapshot, diff, rowVerdicts, inventoryVerdicts, declared } = data;
1138
1355
  const rowConclusion = new Map(rowVerdicts.map((verdict) => [verdict.subject.name, verdict.conclusion]));
1356
+ const updateOrder = flags.registry ? await collectUpdateOrders(env, stampOf(flags)) : undefined;
1139
1357
  if (flags.json) {
1140
- writeJson(auditJsonPayload(data, { noRedact: flags.noRedact, roots: auditRedactRoots(dshHome) }));
1358
+ writeJson(auditJsonPayload(data, {
1359
+ noRedact: flags.noRedact,
1360
+ roots: auditRedactRoots(dshHome),
1361
+ ...(updateOrder === undefined ? {} : { updateOrder }),
1362
+ }));
1141
1363
  return auditExitOutcome(data) === 'ok' ? EXIT_OK : EXIT_FINDINGS;
1142
1364
  }
1143
1365
  // R49: the human answer first. The ledger below is the evidence, and it is one flag away
1144
1366
  // (`--all`) instead of being the only thing between the user and their answer.
1145
1367
  const summary = buildProfileSummary(data, { locale: flags.locale });
1146
1368
  process.stdout.write(formatProfileSummary(summary, { locale: flags.locale, env }));
1369
+ if (updateOrder !== undefined)
1370
+ process.stdout.write(`${renderUpdateOrder(updateOrder, flags.locale)}\n`);
1147
1371
  if (!flags.all) {
1148
1372
  process.stdout.write(flags.locale === 'zh'
1149
1373
  ? '\n(使用 --all 可查看完整台账;`audit --json` 输出所有字段)\n'
@@ -1426,6 +1650,19 @@ async function commandProbe(flags, spec) {
1426
1650
  async function commandServe(flags) {
1427
1651
  const resultsDir = flags.results === null ? resolve(process.cwd(), 'data/results') : resolve(flags.results);
1428
1652
  const dshHome = resolveDshHome(flags);
1653
+ /*
1654
+ * ADR-0014: binding every interface without saying which name clients use would leave the Host
1655
+ * check with nothing to accept — the panel would start and then refuse every request. Refuse at
1656
+ * startup instead, and print the flag that fixes it (R50: a missing config must not look like a
1657
+ * broken product).
1658
+ */
1659
+ const bindHost = flags.host ?? '127.0.0.1';
1660
+ const wildcard = bindHost === '0.0.0.0' || bindHost === '::' || bindHost === '[::]';
1661
+ if (wildcard && flags.allowHosts.length === 0) {
1662
+ process.stderr.write(`--host ${bindHost} needs at least one --allow-host <name[:port]>: the panel only answers a Host it was told about.\n` +
1663
+ `example: dsh-triage serve --host ${bindHost} --allow-host 192.168.1.7\n`);
1664
+ return 2;
1665
+ }
1429
1666
  // R49: the panel's whole purpose is the current composition, so it reads the profile by
1430
1667
  // default. `--no-audit` keeps the old artifacts-only mode (and `/api/audit` answers 501,
1431
1668
  // never an empty ledger that looks clean).
@@ -1459,6 +1696,8 @@ async function commandServe(flags) {
1459
1696
  const panel = await startPanel({
1460
1697
  resultsDir,
1461
1698
  port: flags.port ?? 0,
1699
+ host: bindHost,
1700
+ allowHosts: flags.allowHosts,
1462
1701
  allowExecute: flags.allowExecute,
1463
1702
  locale: flags.locale,
1464
1703
  audit,
@@ -1478,7 +1717,10 @@ async function commandServe(flags) {
1478
1717
  process.stdout.write(`panel ${panel.url}\n`);
1479
1718
  process.stdout.write(`results ${resultsDir}${existsSync(resultsDir) ? '' : ' (does not exist yet)'}\n`);
1480
1719
  process.stdout.write(`mode ${readOnly ? 'read-only' : 'actions requested (POST still returns 501)'}\n`);
1481
- process.stdout.write('open the URL above; it carries a one-time token, and the panel binds 127.0.0.1 only\n');
1720
+ // Print exactly the set the Host rule accepts (deduplicated, including [::1]); "only" has to
1721
+ // be true in both directions, which the first version got wrong (duplicate 127.0.0.1, no [::1]).
1722
+ const answered = allowedHosts({ boundHost: bindHost, port: panel.port, allowHosts: flags.allowHosts });
1723
+ process.stdout.write(`hosts answers ${answered.join(', ')} only (ADR-0014)\n`);
1482
1724
  }
1483
1725
  // Stay in the foreground until the user stops it: a panel that backgrounds itself is a
1484
1726
  // process nobody can find later.
@@ -1669,6 +1911,8 @@ function parseArgs(argv) {
1669
1911
  let noHttp = false;
1670
1912
  let browser = null;
1671
1913
  let port = null;
1914
+ let host = null;
1915
+ const allowHosts = [];
1672
1916
  let results = null;
1673
1917
  let out = null;
1674
1918
  let allowExecute = false;
@@ -1794,6 +2038,20 @@ function parseArgs(argv) {
1794
2038
  port = parsed;
1795
2039
  break;
1796
2040
  }
2041
+ case '--host': {
2042
+ const value = takeValue();
2043
+ if (value === null || value.trim() === '')
2044
+ return null;
2045
+ host = value.trim();
2046
+ break;
2047
+ }
2048
+ case '--allow-host': {
2049
+ const value = takeValue();
2050
+ if (value === null || value.trim() === '')
2051
+ return null;
2052
+ allowHosts.push(value.trim());
2053
+ break;
2054
+ }
1797
2055
  case '--results': {
1798
2056
  const value = takeValue();
1799
2057
  if (value === null)
@@ -1887,7 +2145,7 @@ function parseArgs(argv) {
1887
2145
  return null;
1888
2146
  }
1889
2147
  }
1890
- const flags = { json, all, strict, execute, dshHome, profile, stamp, locale, noRedact, snapshot, explain, dshMain, noHttp, browser, port, results, allowExecute, apply, undo, audit, noAudit, readinessTimeoutMs, unsettledReadinessMs, copyProfile, profileExplicit, out, outcomes, enable, disable, purge, status, to, registry, card };
2148
+ const flags = { json, all, strict, execute, dshHome, profile, stamp, locale, noRedact, snapshot, explain, dshMain, noHttp, browser, port, host, allowHosts, results, allowExecute, apply, undo, audit, noAudit, readinessTimeoutMs, unsettledReadinessMs, copyProfile, profileExplicit, out, outcomes, enable, disable, purge, status, to, registry, card };
1891
2149
  if (help)
1892
2150
  return { command: 'help', positionals: [], flags };
1893
2151
  // R49: no subcommand is not an error. It is the question the product exists to answer.