dsh-standards 1.6.6 → 1.6.7

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.
@@ -20,6 +20,10 @@
20
20
  * evidence url/sha256 kept for compatibility; reportUrl/
21
21
  * reportSha256 are the same values under the new names
22
22
  * checkedBy {checker, command} that produced the audit
23
+ * security optional {state, checks, summary, command} from
24
+ * `--security-report`; state is derived from the 22
25
+ * coverage values, never hand-set. It is not a security
26
+ * audit and must not be rendered as one.
23
27
  * notChecked short honest list of what the run did not exercise
24
28
  *
25
29
  * Deliberately absent: advice (author view), issuer / recordHash / verifyUrl
@@ -52,7 +56,12 @@ const FORBIDDEN = new Set(['advice', 'issuer', 'recordHash', 'verifyUrl', 'score
52
56
  const NOT_CLAIMED = ['official', 'certification', 'security-audit', 'endorsement', 'ordering', 'comparison', 'warranty']
53
57
  const CHECK_KEYS = new Set(['id', 'result', 'coverage'])
54
58
  const SCOPE_KEYS = new Set(['dsh', 'cordis', 'platform'])
55
- const CHECKED_BY_KEYS = new Set(['checker', 'command'])
59
+ const CHECKED_BY_KEYS = new Set(['checker', 'command', 'securityCommand'])
60
+ const SECURITY_KEYS = new Set(['state', 'checks', 'summary', 'command'])
61
+ const SECURITY_STATES = new Set(['checked', 'partial', 'not-run'])
62
+ const SECURITY_RESULTS = new Set(['PASS', 'WARN', 'FAIL', 'NA'])
63
+ const SECURITY_COVERAGE = new Set(['full', 'partial', 'not-run'])
64
+ const SECURITY_SUMMARY_KEYS = new Set(['total', 'checked', 'blocking', 'warn', 'na', 'notRun'])
56
65
  const REPO_GIT_SHORTHAND = /^github:([^/]+\/[^/]+?)(?:\.git)?$/
57
66
 
58
67
  function usage() {
@@ -76,6 +85,8 @@ Options:
76
85
  --tarball-sha256 <hex> explicit tarball sha256 (checked against --tarball)
77
86
  --report <file> dsh-conformance/1 checker report; its checks are
78
87
  reduced to {id,result,coverage} (no details)
88
+ --security-report <file> optional dsh-conformance/1 report from --scope security;
89
+ adds a top-level security block (checks + counts)
79
90
  --checked-command <s> command recorded in checkedBy.command
80
91
  --evidence-url <url> optional https evidence URL (url + reportUrl)
81
92
  --evidence-file <file> hash this file into evidence.sha256/reportSha256
@@ -129,7 +140,7 @@ function parseArgs(argv) {
129
140
  today: null, todayProvided: false, ttlDays: 90,
130
141
  name: null, version: null, packageDir: null,
131
142
  tarball: null, tarballSha256: null,
132
- report: null, checkedCommand: null,
143
+ report: null, securityReport: null, checkedCommand: null,
133
144
  evidenceUrl: null, evidenceFile: null, evidenceSha256: null,
134
145
  checkerVersion: null, checkerSha: null,
135
146
  indexUrl: 'https://awesome-dsh-plugin.com/index.json',
@@ -155,6 +166,7 @@ function parseArgs(argv) {
155
166
  else if (arg === '--tarball') options.tarball = next()
156
167
  else if (arg === '--tarball-sha256') options.tarballSha256 = next().toLowerCase()
157
168
  else if (arg === '--report') options.report = next()
169
+ else if (arg === '--security-report') options.securityReport = next()
158
170
  else if (arg === '--checked-command') options.checkedCommand = next()
159
171
  else if (arg === '--evidence-url') options.evidenceUrl = next()
160
172
  else if (arg === '--evidence-file') options.evidenceFile = next()
@@ -285,6 +297,41 @@ function extractChecks(report, name, version) {
285
297
  })
286
298
  }
287
299
 
300
+ function buildSecurity(report, name, version) {
301
+ if (!report) return null
302
+ if (!Array.isArray(report.checks)) throw new Error('--security-report checks must be an array')
303
+ if (report.subject && report.subject.name && report.subject.name !== name) {
304
+ throw new Error(`--security-report subject.name ${report.subject.name} does not match ${name}`)
305
+ }
306
+ if (report.subject && report.subject.version && report.subject.version !== version) {
307
+ throw new Error(`--security-report subject.version ${report.subject.version} does not match ${version}`)
308
+ }
309
+ const checks = report.checks.map(check => {
310
+ if (!check || typeof check !== 'object') throw new Error('--security-report checks must be objects')
311
+ if (typeof check.id !== 'string' || typeof check.result !== 'string' || typeof check.coverage !== 'string') {
312
+ throw new Error('--security-report checks need id/result/coverage')
313
+ }
314
+ return { id: check.id, result: check.result, coverage: check.coverage }
315
+ }).sort((a, b) => a.id.localeCompare(b.id))
316
+ const count = (predicate) => checks.filter(predicate).length
317
+ const checked = count(c => c.coverage !== 'not-run')
318
+ const total = checks.length
319
+ const state = checked === 0 ? 'not-run' : checked === total ? 'checked' : 'partial'
320
+ return {
321
+ state,
322
+ checks,
323
+ summary: {
324
+ total,
325
+ checked,
326
+ blocking: count(c => c.result === 'FAIL'),
327
+ warn: count(c => c.result === 'WARN'),
328
+ na: count(c => c.result === 'NA'),
329
+ notRun: count(c => c.coverage === 'not-run'),
330
+ },
331
+ command: 'dsh-standards check <package-dir> --scope security --json',
332
+ }
333
+ }
334
+
288
335
  function summarizeNotChecked(audit, checks, hasReport) {
289
336
  const items = []
290
337
  const entry = audit?.levels?.entry && typeof audit.levels.entry === 'object' ? audit.levels.entry : {}
@@ -386,6 +433,8 @@ function entryFromAudit(audit, options, levelFile) {
386
433
 
387
434
  const report = options.report ? readJson(path.resolve(options.report), '--report') : null
388
435
  const checks = extractChecks(report, name, version)
436
+ const securityReport = options.securityReport ? readJson(path.resolve(options.securityReport), '--security-report') : null
437
+ const security = buildSecurity(securityReport, name, version)
389
438
 
390
439
  const auditLevels = audit.levels && typeof audit.levels === 'object' ? audit.levels : {}
391
440
  const levels = {
@@ -457,8 +506,9 @@ function entryFromAudit(audit, options, levelFile) {
457
506
  scope: inferScope(meta, audit),
458
507
  levels,
459
508
  checks,
509
+ ...(security ? { security } : {}),
460
510
  evidence,
461
- checkedBy: { checker, command },
511
+ checkedBy: security ? { checker, command, securityCommand: security.command } : { checker, command },
462
512
  notChecked: summarizeNotChecked(audit, checks, report !== null),
463
513
  validity: { checkedAt, expiresAt, policy: `${options.ttlDays}d` },
464
514
  lifecycle: 'active',
@@ -624,6 +674,49 @@ function validateSidecar(sidecar) {
624
674
  }
625
675
  }
626
676
  }
677
+ if (entry.security !== undefined) {
678
+ const sec = entry.security
679
+ if (!sec || typeof sec !== 'object' || Array.isArray(sec)) throw new Error(`${key}: security must be an object`)
680
+ for (const field of Object.keys(sec)) {
681
+ if (!SECURITY_KEYS.has(field)) throw new Error(`${key}: security.${field} is not part of the sidecar contract`)
682
+ }
683
+ if (!SECURITY_STATES.has(sec.state)) throw new Error(`${key}: security.state is invalid`)
684
+ if (!Array.isArray(sec.checks)) throw new Error(`${key}: security.checks must be an array`)
685
+ const securityIds = new Set()
686
+ const securityCounts = { total: sec.checks.length, checked: 0, blocking: 0, warn: 0, na: 0, notRun: 0 }
687
+ for (const check of sec.checks) {
688
+ if (!check || typeof check !== 'object') throw new Error(`${key}: security.checks must be objects`)
689
+ for (const field of Object.keys(check)) {
690
+ if (!CHECK_KEYS.has(field)) throw new Error(`${key}: security.checks.${field} is not part of the sidecar contract`)
691
+ }
692
+ for (const field of ['id', 'result', 'coverage']) {
693
+ if (typeof check[field] !== 'string' || check[field] === '') throw new Error(`${key}: security.checks.${field} is required`)
694
+ }
695
+ if (!SECURITY_RESULTS.has(check.result)) throw new Error(`${key}: security ${check.id} result must be PASS/WARN/FAIL/NA`)
696
+ if (!SECURITY_COVERAGE.has(check.coverage)) throw new Error(`${key}: security ${check.id} coverage must be full/partial/not-run`)
697
+ if (securityIds.has(check.id)) throw new Error(`${key}: duplicate security check id ${check.id}`)
698
+ securityIds.add(check.id)
699
+ if (check.coverage === 'not-run') securityCounts.notRun += 1
700
+ else securityCounts.checked += 1
701
+ if (check.result === 'FAIL') securityCounts.blocking += 1
702
+ if (check.result === 'WARN') securityCounts.warn += 1
703
+ if (check.result === 'NA') securityCounts.na += 1
704
+ }
705
+ const summary = sec.summary
706
+ if (!summary || typeof summary !== 'object') throw new Error(`${key}: security.summary must be an object`)
707
+ for (const field of Object.keys(summary)) {
708
+ if (!SECURITY_SUMMARY_KEYS.has(field)) throw new Error(`${key}: security.summary.${field} is not part of the sidecar contract`)
709
+ }
710
+ for (const field of ['total', 'checked', 'blocking', 'warn', 'na', 'notRun']) {
711
+ if (!Number.isInteger(summary[field]) || summary[field] < 0) throw new Error(`${key}: security.summary.${field} is invalid`)
712
+ if (summary[field] !== securityCounts[field]) throw new Error(`${key}: security.summary.${field} must equal ${securityCounts[field]} derived from checks`)
713
+ }
714
+ const expectedState = securityCounts.checked === 0
715
+ ? 'not-run'
716
+ : securityCounts.checked === securityCounts.total ? 'checked' : 'partial'
717
+ if (sec.state !== expectedState) throw new Error(`${key}: security.state must be ${expectedState} for the recorded coverage`)
718
+ if (typeof sec.command !== 'string' || sec.command === '') throw new Error(`${key}: security.command is required`)
719
+ }
627
720
  if (entry.notChecked !== undefined) {
628
721
  if (!Array.isArray(entry.notChecked)) throw new Error(`${key}: notChecked must be an array`)
629
722
  for (const item of entry.notChecked) {
@@ -48,9 +48,20 @@ const HERE = path.dirname(fileURLToPath(import.meta.url))
48
48
  const STD = path.resolve(HERE, '..', '..')
49
49
  const JOURNEY_STATIC = path.join(HERE, 'journey.mjs')
50
50
  const JOURNEY_RUNTIME = path.join(HERE, 'journey-runtime.mjs')
51
- const NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm'
52
51
  const GIT = process.platform === 'win32' ? 'git.exe' : 'git'
53
52
 
53
+ /**
54
+ * npm's Windows launcher is `npm.cmd`. Since Node 18.20/20.12 a direct
55
+ * spawnSync('npm.cmd', ...) without a shell fails with EINVAL (the
56
+ * CVE-2024-27980 mitigation). Go through the shell, which uses `cmd.exe /c`
57
+ * under the hood; Linux stays a direct spawn. Exported so the platform choice
58
+ * is testable without running npm.
59
+ */
60
+ export function npmPackInvocation(platform = process.platform, args = ['pack', '--ignore-scripts', '--json']) {
61
+ if (platform === 'win32') return { command: 'npm.cmd', args, shell: true }
62
+ return { command: 'npm', args, shell: false }
63
+ }
64
+
54
65
  const STATIC_CHECK_IDS = {
55
66
  J1: 'J1.install', J2: 'J2.toggle', J3: 'J3.config', J4: 'J4.first-run',
56
67
  J5: 'J5.permissions', J6: 'J6.upgrade', J7: 'J7.observe', J8: 'J8.client',
@@ -147,11 +158,11 @@ function quoteCommand(command) {
147
158
  return command.map(part => (/^[A-Za-z0-9_./:@=+-]+$/.test(part) ? part : `'${String(part).replace(/'/g, "'\\''")}'`)).join(' ')
148
159
  }
149
160
 
150
- function run(command, args, { cwd, env, timeout = 120_000 } = {}) {
161
+ function run(command, args, { cwd, env, timeout = 120_000, shell = false } = {}) {
151
162
  const startedAt = nowIso()
152
163
  const t0 = Date.now()
153
164
  const result = spawnSync(command, args, {
154
- cwd, env, encoding: 'utf8', timeout, maxBuffer: 16 * 1024 * 1024, killSignal: 'SIGKILL',
165
+ cwd, env, encoding: 'utf8', timeout, maxBuffer: 16 * 1024 * 1024, killSignal: 'SIGKILL', shell,
155
166
  })
156
167
  const endedAt = nowIso()
157
168
  return {
@@ -539,7 +550,8 @@ async function main() {
539
550
 
540
551
  function packSubject(copy, tmpRoot, childEnv, timeout) {
541
552
  const destination = fs.mkdtempSync(path.join(tmpRoot, 'pack-'))
542
- const runResult = run(NPM, ['pack', '--ignore-scripts', '--json', '--pack-destination', destination], { cwd: copy, env: childEnv(), timeout })
553
+ const invocation = npmPackInvocation(process.platform, ['pack', '--ignore-scripts', '--json', '--pack-destination', destination])
554
+ const runResult = run(invocation.command, invocation.args, { cwd: copy, env: childEnv(), timeout, shell: invocation.shell })
543
555
  if (runResult.exitCode !== 0) {
544
556
  throw new Error(`npm pack failed (exit ${runResult.exitCode}): ${tailLines(runResult.stderrText, 10)}`)
545
557
  }
@@ -613,7 +625,13 @@ function collectHints(journeyId, checks, hints, outDir, logDir, toEvidencePath)
613
625
  }
614
626
  }
615
627
 
616
- main().catch(error => {
617
- console.error(`flow-collect: ${error.message}`)
618
- process.exitCode = 3
619
- })
628
+ // Run only when executed as a CLI. Importing the module (for
629
+ // npmPackInvocation in tests) must not start a collection.
630
+ const invokedAsScript = typeof process.argv[1] === 'string'
631
+ && ['flow-collect.mjs', 'dsh-flow-collect.mjs', 'dsh-flow-collect'].includes(path.basename(process.argv[1]))
632
+ if (invokedAsScript) {
633
+ main().catch(error => {
634
+ console.error(`flow-collect: ${error.message}`)
635
+ process.exitCode = 3
636
+ })
637
+ }
@@ -39,6 +39,7 @@ const VALUE_FLAGS = new Set([
39
39
  '--scope', '--profile', '--runtime', '--runtime-version', '--cordis-version', '--commit',
40
40
  '--install-spec', '--market-index', '--plugin-name', '--timeout', '--host', '--base',
41
41
  '--web', '--bare', '--entry-runtime', '--entry-claim', '--max-files', '--max-bytes',
42
+ '--registry-dir',
42
43
  ])
43
44
 
44
45
  export function checkUsage() {
@@ -54,6 +55,7 @@ Options:
54
55
  --html <file> write a single-file HTML report (inline CSS, no assets)
55
56
  --host-version <v> host dsh version for the anchor (default: $DSH_HOST_VERSION)
56
57
  --allow-host-probe resolve the \`dsh\` JS entry and run \`node <entry> --version\`
58
+ --registry-dir <dir> read a dsh registry layout (dsh.plugin.json) instead of package.json
57
59
  --help show this help
58
60
 
59
61
  Safety:
@@ -349,6 +351,10 @@ function safetyBanner(report) {
349
351
  }
350
352
  if (!safety.hostVersionKnown) {
351
353
  lines.push(`> host 版本未知:anchor.dsh=\`${anchor.dsh ?? '?'}\` 是默认值(source=${anchor.runtimeSource ?? 'default'}, suspect=${anchor.suspect ?? true})。用 \`--host-version\`、\`DSH_HOST_VERSION\` 或 \`--allow-host-probe\` 指定宿主版本。`)
354
+ // An explicit --runtime-version still judges C-2, even without a host.
355
+ if (!safety.runtimeVersionExplicit && anchor.runtimeSource !== 'host') {
356
+ lines.push('> C-2.1/C-2.2 兼容性未判定(NA/partial):未指定 host 版本,不能把默认常量当成真实宿主。')
357
+ }
352
358
  } else {
353
359
  lines.push(`> host 版本 \`${anchor.dsh}\`(来源:${anchor.hostVersionSource ?? 'host'});anchor.source=${anchor.runtimeSource ?? 'host'}。`)
354
360
  }
@@ -382,7 +388,10 @@ export function runCheck(argv = process.argv.slice(2)) {
382
388
  hostInfo = resolveHostVersion({ hostVersion: options.hostVersion, allowHostProbe: options.allowHostProbe })
383
389
  const forwarded = [...safety.args, ...options.passthrough]
384
390
  if (hostInfo.version && !hasFlag(options.passthrough, '--runtime-version')) {
385
- forwarded.push('--runtime-version', hostInfo.version)
391
+ // Pass the host anchor as --host-version so the checker's own headline
392
+ // and anchor source already say `host`; applyHostAnchor then only fills
393
+ // in the author-facing provenance fields.
394
+ forwarded.push('--host-version', hostInfo.version)
386
395
  }
387
396
  result = invokeChecker(options, forwarded)
388
397
  } catch (error) {
@@ -4,6 +4,7 @@ import path from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
5
  import { runManifestChecks, DEFAULT_RUNTIME_VERSION } from './manifest.mjs'
6
6
  import { checkCapabilities, checkCredentials, checkImportTimeAdvisory, checkLabels } from './declarations.mjs'
7
+ import { parseVersion } from './semver.mjs'
7
8
  import { runSecurityChecks } from './security.mjs'
8
9
  import { runRuntimeChecks } from './runtime.mjs'
9
10
  import { runStaticBundleChecks } from './bundle-static.mjs'
@@ -40,6 +41,10 @@ Options:
40
41
  --runtime [path|auto] built @deepseek-ai/cordis lib/index.js (or its package dir); bare or
41
42
  'auto' resolves from the installed dsh; enables real L1-L3
42
43
  --runtime-version <v> dsh runtime version used for C-2 (default: host via \`dsh --version\`, else ${DEFAULT_RUNTIME_VERSION})
44
+ --host-version <v> explicit host dsh version for C-2 (skips \`dsh --version\`; when neither is
45
+ available the anchor is source=default, suspect=true and C-2 is NA/partial)
46
+ --registry-dir <dir> read a dsh registry layout (dsh.plugin.json) instead of package.json;
47
+ a <dir> that only has dsh.plugin.json is auto-detected
43
48
  --cordis-version <v> cordis version recorded in the anchor (default: ${DEFAULT_CORDIS})
44
49
  --commit <sha> harness commit recorded in the anchor (default: ${DEFAULT_COMMIT.slice(0, 12)})
45
50
  --install-spec <spec> recommended install spec for C-3 (listing/install check)
@@ -84,6 +89,8 @@ function parseArgs(argv) {
84
89
  profile: null,
85
90
  runtime: null,
86
91
  runtimeVersion: null,
92
+ hostVersion: null,
93
+ registryDir: null,
87
94
  cordisVersion: DEFAULT_CORDIS,
88
95
  commit: DEFAULT_COMMIT,
89
96
  installSpec: null,
@@ -137,6 +144,8 @@ function parseArgs(argv) {
137
144
  break
138
145
  }
139
146
  case '--runtime-version': options.runtimeVersion = value(); break
147
+ case '--host-version': options.hostVersion = value(); break
148
+ case '--registry-dir': options.registryDir = value(); break
140
149
  case '--cordis-version': options.cordisVersion = value(); break
141
150
  case '--commit': options.commit = value(); break
142
151
  case '--install-spec': options.installSpec = value(); break
@@ -180,6 +189,12 @@ function parseArgs(argv) {
180
189
  if (!Number.isFinite(options.timeoutMs) || options.timeoutMs < 100 || options.timeoutMs > 120_000) throw new Error('--timeout must be between 100 and 120000 ms')
181
190
  if (!Number.isInteger(options.maxFiles) || options.maxFiles < 1 || options.maxFiles > 200_000) throw new Error('--max-files must be an integer between 1 and 200000')
182
191
  if (!Number.isInteger(options.maxBytes) || options.maxBytes < 1000 || options.maxBytes > 2_000_000_000) throw new Error('--max-bytes must be an integer between 1000 and 2000000000')
192
+ if (options.hostVersion !== null) {
193
+ const normalized = String(options.hostVersion).trim().replace(/^v/, '')
194
+ if (normalized === '' || parseVersion(normalized) === null) throw new Error('--host-version must be an exact semver version')
195
+ options.hostVersion = normalized
196
+ }
197
+ if (options.registryDir !== null && String(options.registryDir).trim() === '') throw new Error('--registry-dir needs a directory')
183
198
  if (options.target === null) options.target = '.'
184
199
  return options
185
200
  }
@@ -492,8 +507,9 @@ export function detectHostRuntime({ bin = process.env.DSH_BIN || (process.platfo
492
507
  /**
493
508
  * Resolve what `anchor.dsh` means:
494
509
  * cli the caller passed --runtime-version; suspect when it differs from the host
495
- * host no flag: the host version is the anchor, so it cannot be suspect
496
- * fallback dsh unavailable: keep the constant, flagged as not host-derived
510
+ * host the host version is known (--host-version or a successful `dsh --version`)
511
+ * default no host version is available: the constant is only a placeholder, so
512
+ * `suspect` is true and C-2 must be reported as not judged (NA/partial)
497
513
  */
498
514
  export function resolveRuntimeAnchor(requestedVersion = null, hostVersion = null) {
499
515
  if (typeof requestedVersion === 'string' && requestedVersion.trim() !== '') {
@@ -508,7 +524,7 @@ export function resolveRuntimeAnchor(requestedVersion = null, hostVersion = null
508
524
  if (typeof hostVersion === 'string' && hostVersion !== '') {
509
525
  return { dsh: hostVersion, runtimeSource: 'host', hostVersion, suspect: false }
510
526
  }
511
- return { dsh: DEFAULT_RUNTIME_VERSION, runtimeSource: 'fallback', hostVersion: null, suspect: false }
527
+ return { dsh: DEFAULT_RUNTIME_VERSION, runtimeSource: 'default', hostVersion: null, suspect: true }
512
528
  }
513
529
 
514
530
  /** The five optional declaration surfaces, counted but never scored. */
@@ -537,6 +553,53 @@ function anchorOf(options, runtimeInfo, runtimePath) {
537
553
  }
538
554
  }
539
555
 
556
+ /**
557
+ * `howToEnable` is normally derived by report.mjs from the check id alone. A
558
+ * check can know a better answer (e.g. C-2 needs a host version), so copy the
559
+ * check-level hint onto its bucket/notChecked rows. This is additive: the
560
+ * verdict never reads it.
561
+ */
562
+ export function applyCheckHowToEnable(report) {
563
+ const byId = new Map((report?.checks ?? [])
564
+ .filter(item => typeof item?.howToEnable === 'string' && item.howToEnable !== '')
565
+ .map(item => [item.id, item.howToEnable]))
566
+ if (byId.size === 0) return report
567
+ const rows = [
568
+ ...(report.notChecked ?? []),
569
+ ...(report.buckets?.notChecked ?? []),
570
+ ...(report.buckets?.partial ?? []),
571
+ ]
572
+ for (const row of rows) {
573
+ if (byId.has(row.id)) row.howToEnable = byId.get(row.id)
574
+ }
575
+ return report
576
+ }
577
+
578
+ /**
579
+ * When the anchor is the unchecked-in default, C-2 compatibility was not
580
+ * judged. Keep the check at NA/partial and say, in the report itself, how to
581
+ * supply a host version. Never turn the placeholder into a FAIL.
582
+ */
583
+ export function annotateUnknownHostCompatibility(report, runtimeInfo) {
584
+ if (runtimeInfo?.runtimeSource !== 'default') return report
585
+ const howToEnable = 'pass --host-version <v> (or run `check --allow-host-probe`); without a host version C-2.1/C-2.2 stay NA and compatibility is not judged'
586
+ const note = 'C-2 compatibility not judged: 未指定 host 版本,兼容性未判定 (pass --host-version <v> or --allow-host-probe)'
587
+ const compat = (report.checks ?? []).find(item => item.id === 'DSC-02')
588
+ if (compat) {
589
+ compat.coverage = 'partial'
590
+ compat.howToEnable = howToEnable
591
+ }
592
+ for (const row of [...(report.notChecked ?? []), ...(report.buckets?.notChecked ?? []), ...(report.buckets?.partial ?? [])]) {
593
+ if (row.id !== 'DSC-02') continue
594
+ row.coverage = 'partial'
595
+ row.howToEnable = howToEnable
596
+ }
597
+ if (report.conclusion && !String(report.conclusion.reason ?? '').includes('兼容性未判定')) {
598
+ report.conclusion.reason = [report.conclusion.reason, note].filter(Boolean).join('; ')
599
+ }
600
+ return report
601
+ }
602
+
540
603
  export async function main(argv = process.argv.slice(2)) {
541
604
  let options
542
605
  try {
@@ -549,7 +612,7 @@ export async function main(argv = process.argv.slice(2)) {
549
612
  if (options.help) { process.stdout.write(usage()); return 0 }
550
613
  if (options.version) { process.stdout.write(`${VERSION}\n`); return 0 }
551
614
 
552
- const dir = path.resolve(options.target)
615
+ const dir = path.resolve(options.registryDir ?? options.target)
553
616
  let stat
554
617
  try { stat = fs.statSync(dir) } catch {
555
618
  process.stderr.write(`dsh-plugin-verify: target not found: ${dir}\n`)
@@ -559,13 +622,28 @@ export async function main(argv = process.argv.slice(2)) {
559
622
  process.stderr.write(`dsh-plugin-verify: target must be a package directory (tarball support is not in the MVP): ${dir}\n`)
560
623
  return 3
561
624
  }
562
- if (!fs.existsSync(path.join(dir, 'package.json'))) {
563
- process.stderr.write(`dsh-plugin-verify: not a package directory (no package.json): ${dir}\n`)
625
+ const hasPackageJson = fs.existsSync(path.join(dir, 'package.json'))
626
+ const hasRegistryManifest = fs.existsSync(path.join(dir, 'dsh.plugin.json'))
627
+ if (!hasPackageJson && !hasRegistryManifest) {
628
+ process.stderr.write(`dsh-plugin-verify: not a package directory (no package.json or dsh.plugin.json): ${dir}\n`)
629
+ return 3
630
+ }
631
+ if (options.registryDir !== null && !hasRegistryManifest) {
632
+ process.stderr.write(`dsh-plugin-verify: --registry-dir has no dsh.plugin.json: ${dir}\n`)
564
633
  return 3
565
634
  }
635
+ // A sidebar-style `registry/` output has only dsh.plugin.json. Auto-detect it,
636
+ // and let --registry-dir force that mode even when a package.json is present.
637
+ const registryMode = options.registryDir !== null || (!hasPackageJson && hasRegistryManifest)
566
638
 
567
- const host = detectHostRuntime()
639
+ // --host-version is an explicit anchor and skips PATH probing entirely.
640
+ // Otherwise the legacy best-effort `dsh --version` probe still runs; when it
641
+ // fails the anchor is the default constant, suspect=true, and C-2 is NA.
642
+ const host = options.hostVersion !== null
643
+ ? { version: options.hostVersion, bin: '--host-version', error: null }
644
+ : detectHostRuntime()
568
645
  const runtimeInfo = resolveRuntimeAnchor(options.runtimeVersion, host.version)
646
+ const compatibilityKnown = runtimeInfo.runtimeSource !== 'default'
569
647
 
570
648
  // `--runtime auto` / `--host auto` resolve from the installed dsh. A value
571
649
  // that still cannot be resolved is a usage error: silently skipping the run
@@ -586,7 +664,9 @@ export async function main(argv = process.argv.slice(2)) {
586
664
  return 3
587
665
  }
588
666
 
589
- const { manifest, kind, kindInferred, entry, patch, g4, checks: manifestChecks } = runManifestChecks(dir, {
667
+ const { manifest, manifestSource, kind, kindInferred, entry, patch, g4, checks: manifestChecks } = runManifestChecks(dir, {
668
+ registry: registryMode,
669
+ compatibilityKnown,
590
670
  runtimeVersion: runtimeInfo.dsh,
591
671
  installSpec: options.installSpec,
592
672
  marketIndex: options.marketIndex,
@@ -752,6 +832,9 @@ export async function main(argv = process.argv.slice(2)) {
752
832
  name: manifest?.name ?? null,
753
833
  version: manifest?.version ?? null,
754
834
  path: dir,
835
+ // Additive: a registry layout (dsh.plugin.json, no package.json) is a
836
+ // different input contract from an npm package directory.
837
+ ...(manifestSource === 'registry' ? { source: 'registry' } : {}),
755
838
  }
756
839
  const report = buildReport({
757
840
  subject,
@@ -769,6 +852,8 @@ export async function main(argv = process.argv.slice(2)) {
769
852
  runtimeChecks: runtimeSummary,
770
853
  securityChecks,
771
854
  })
855
+ applyCheckHowToEnable(report)
856
+ annotateUnknownHostCompatibility(report, runtimeInfo)
772
857
  // An explicitly requested runtime/host run that could not produce a result
773
858
  // is not a clean static pass: the caller asked for execution, so say the run
774
859
  // is incomplete. A static report (no flag) is unaffected.
@@ -11,6 +11,11 @@ const PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/
11
11
  const PACKAGE_NAME_MAX_LENGTH = 214
12
12
  const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/
13
13
  const COMMIT = /^[0-9a-f]{40}$/
14
+ // A dsh registry id is `<owner>/<name>` (the sidebar uses
15
+ // `dsh-external/dsh-better-sidebar`); it is not required to be an npm name.
16
+ const REGISTRY_ID = /^[a-z0-9][a-z0-9._~-]*(?:\/[a-z0-9][a-z0-9._~-]*)?$/
17
+ const UNKNOWN_HOST_HOW = 'pass --host-version <v> (or run `check --allow-host-probe`); without a host version C-2.1/C-2.2 stay NA and compatibility is not judged'
18
+ const UNKNOWN_HOST_REASON = '未指定 host 版本(host version not specified),兼容性未判定(compatibility not judged);C-2.1/C-2.2 are NA, not FAIL/PASS'
14
19
 
15
20
  export const DEFAULT_RUNTIME_VERSION = '0.2.2-alpha.2'
16
21
 
@@ -157,96 +162,168 @@ function analyzePatch(dir, manifest) {
157
162
  return { present: true, files, problems, rows, enabledPluginManagerTools }
158
163
  }
159
164
 
160
- function supplyChain(dir, manifest) {
165
+ function supplyChain(dir, manifest, { registry = false, packageJsonAvailable = true } = {}) {
161
166
  const details = []
167
+ const label = registry ? 'dsh.plugin.json' : 'package.json'
168
+ if (registry && !packageJsonAvailable) {
169
+ details.push(detail('C-3.3', 'NA', 'registry layout has no package.json; dependency provenance is not judged', [`${label}#dependencies`]))
170
+ details.push(detail('C-3.4', 'NA', 'registry layout has no package.json scripts; install-time scripts are not judged', [`${label}#scripts`]))
171
+ return details
172
+ }
162
173
  const dependencies = isObject(manifest.dependencies) ? manifest.dependencies : {}
163
174
  const peers = isObject(manifest.peerDependencies) ? manifest.peerDependencies : {}
164
175
  const all = { ...dependencies, ...peers }
165
176
  for (const [name, value] of Object.entries(all)) {
166
177
  if (typeof value !== 'string') continue
167
178
  if (/^(?:workspace|file|link|portal):/i.test(value)) {
168
- details.push(detail('C-3.3', 'WARN', `non-registry dependency ${name}: ${value}`, [`package.json#dependencies.${name}`]))
179
+ details.push(detail('C-3.3', 'WARN', `non-registry dependency ${name}: ${value}`, [`${label}#dependencies.${name}`]))
169
180
  continue
170
181
  }
171
182
  if (/^(?:git\+|git@|github:|gitlab:|bitbucket:|gist:|https?:)/i.test(value)) {
172
183
  if (!/#[0-9a-f]{40}$/.test(value) && !/^https?:\/\/[^#]+\.(?:tgz|tar\.gz)/i.test(value)) {
173
- details.push(detail('C-3.3', 'WARN', `non-registry dependency ${name} is not pinned to a commit: ${value}`, [`package.json#dependencies.${name}`]))
184
+ details.push(detail('C-3.3', 'WARN', `non-registry dependency ${name} is not pinned to a commit: ${value}`, [`${label}#dependencies.${name}`]))
174
185
  }
175
186
  }
176
187
  }
177
188
  const scripts = isObject(manifest.scripts) ? manifest.scripts : {}
178
189
  for (const name of ['preinstall', 'install', 'postinstall', 'prepare']) {
179
190
  if (typeof scripts[name] === 'string') {
180
- details.push(detail('C-3.4', 'WARN', `install-time build script present: scripts.${name}`, [`package.json#scripts.${name}`]))
191
+ details.push(detail('C-3.4', 'WARN', `install-time build script present: scripts.${name}`, [`${label}#scripts.${name}`]))
181
192
  }
182
193
  }
183
194
  return details
184
195
  }
185
196
 
197
+ /**
198
+ * A `dsh.plugin.json` registry layout is not an npm package: it has no
199
+ * package.json, and its fields are `id`/`main`/`client.main`/`engines.dsh`
200
+ * instead of `name`/`exports`/`dsh.client`. Normalize it into the shape the
201
+ * existing checks understand, and let the registry-specific branches below
202
+ * downgrade package.json-only fields to NA instead of inventing them.
203
+ */
204
+ export function normalizeRegistryManifest(raw, packageJson = null) {
205
+ const value = isObject(raw) ? raw : {}
206
+ const pkg = isObject(packageJson) ? packageJson : {}
207
+ const pkgDsh = isObject(pkg.dsh) ? pkg.dsh : null
208
+ const client = isObject(value.client)
209
+ ? value.client
210
+ : isObject(pkgDsh?.client) ? pkgDsh.client : null
211
+ const main = typeof value.main === 'string' && value.main.trim() !== ''
212
+ ? value.main
213
+ : typeof pkg.main === 'string' && pkg.main.trim() !== '' ? pkg.main : null
214
+ const clientMain = typeof client?.main === 'string' && client.main.trim() !== '' ? client.main : null
215
+ const exportsField = value.exports !== undefined
216
+ ? value.exports
217
+ : {
218
+ ...(main ? { '.': main } : {}),
219
+ ...(clientMain ? { './client': clientMain } : {}),
220
+ }
221
+ const dsh = isObject(value.dsh) ? { ...value.dsh } : {}
222
+ if (typeof dsh.kind !== 'string' || dsh.kind === '') dsh.kind = 'plugin'
223
+ if (client) dsh.client = { ...client }
224
+ const capabilities = Array.isArray(value.capabilities)
225
+ ? value.capabilities
226
+ : isObject(value.contributes) && Array.isArray(value.contributes.capabilities)
227
+ ? value.contributes.capabilities
228
+ : Array.isArray(pkgDsh?.capabilities) ? pkgDsh.capabilities : undefined
229
+ if (capabilities) dsh.capabilities = capabilities
230
+ if (Array.isArray(pkgDsh?.labels) && dsh.labels === undefined) dsh.labels = pkgDsh.labels
231
+ return {
232
+ name: typeof value.name === 'string' && value.name.trim() !== '' ? value.name : value.id ?? pkg.name,
233
+ version: value.version ?? pkg.version,
234
+ main,
235
+ exports: exportsField,
236
+ engines: value.engines ?? pkg.engines,
237
+ peerDependencies: value.peerDependencies ?? pkg.peerDependencies,
238
+ license: value.license ?? pkg.license,
239
+ repository: value.repository ?? value.repo ?? pkg.repository,
240
+ dependencies: value.dependencies ?? pkg.dependencies,
241
+ scripts: value.scripts ?? pkg.scripts,
242
+ private: value.private ?? pkg.private,
243
+ workspaces: value.workspaces ?? pkg.workspaces,
244
+ type: value.type ?? pkg.type,
245
+ dsh,
246
+ }
247
+ }
248
+
186
249
  /**
187
250
  * @param {string} dir
188
- * @param {{runtimeVersion?: string, installSpec?: string, marketIndex?: string, pluginName?: string}} options
251
+ * @param {{runtimeVersion?: string, installSpec?: string, marketIndex?: string, pluginName?: string, registry?: boolean, compatibilityKnown?: boolean}} options
189
252
  */
190
253
  export function runManifestChecks(dir, options = {}) {
191
254
  const runtimeVersion = options.runtimeVersion ?? DEFAULT_RUNTIME_VERSION
192
- const parsed = readJsonMaybe(path.join(dir, 'package.json'))
255
+ const compatibilityKnown = options.compatibilityKnown !== false
256
+ const packagePath = path.join(dir, 'package.json')
257
+ const registryPath = path.join(dir, 'dsh.plugin.json')
258
+ const packageJsonAvailable = isFile(packagePath)
259
+ const registryMode = options.registry === true || (!packageJsonAvailable && isFile(registryPath))
260
+ const manifestPath = registryMode ? registryPath : packagePath
261
+ const manifestLabel = registryMode ? 'dsh.plugin.json' : 'package.json'
262
+ const parsed = readJsonMaybe(manifestPath)
193
263
  if (parsed.error) {
264
+ const source = registryMode ? 'dsh.plugin.json' : 'package.json'
194
265
  return {
195
266
  manifest: null,
267
+ manifestSource: registryMode ? 'registry' : 'package',
268
+ manifestPath,
196
269
  kind: 'unknown',
197
270
  entry: null,
198
271
  patch: null,
199
272
  g4: { hasClient: false, ok: true, result: 'NA', reason: 'manifest unavailable' },
200
273
  checks: [
201
- check({ id: 'DSC-01', clause: 'C-1', layer: 'L0', result: 'FAIL', reason: `package.json is missing or invalid: ${parsed.error.message}`, details: [detail('C-1.1', 'FAIL', parsed.error.message)], evidence: ['package.json'] }),
274
+ check({ id: 'DSC-01', clause: 'C-1', layer: 'L0', result: 'FAIL', reason: `${source} is missing or invalid: ${parsed.error.message}`, details: [detail('C-1.1', 'FAIL', parsed.error.message)], evidence: [source] }),
202
275
  check({ id: 'DSC-02', clause: 'C-2', layer: 'L0', result: 'ERROR', coverage: 'not-run', reason: 'manifest unavailable' }),
203
276
  check({ id: 'DSC-03', clause: 'C-3', layer: 'L0', result: 'NA', reason: 'manifest unavailable' }),
204
277
  ],
205
278
  }
206
279
  }
207
- const manifest = parsed.value
280
+ const packageJsonValue = packageJsonAvailable ? readJsonMaybe(packagePath).value : null
281
+ const manifest = registryMode ? normalizeRegistryManifest(parsed.value, packageJsonValue) : parsed.value
208
282
  const entry = resolveEntry(dir, manifest)
209
283
  const kindInfo = inferKind(manifest, entry.exists)
210
284
  const kind = kindInfo.kind
211
285
  const patch = analyzePatch(dir, manifest)
212
286
  const g4 = checkClientShape(manifest, dir)
287
+ const packageFieldsJudged = !registryMode || packageJsonAvailable
213
288
 
214
289
  const manifestDetails = []
215
290
  const name = manifest.name
216
- if (typeof name !== 'string' || name.trim() === '' || name.length > PACKAGE_NAME_MAX_LENGTH || !PACKAGE_NAME.test(name)) {
217
- manifestDetails.push(detail('C-1.1', 'FAIL', 'name must be a valid npm package name', ['package.json#name']))
291
+ const validName = typeof name === 'string' && name.trim() !== '' && name.length <= PACKAGE_NAME_MAX_LENGTH
292
+ && (PACKAGE_NAME.test(name) || (registryMode && REGISTRY_ID.test(name)))
293
+ if (!validName) {
294
+ manifestDetails.push(detail('C-1.1', 'FAIL', registryMode ? 'id must be a valid registry plugin id (<owner>/<name>)' : 'name must be a valid npm package name', [`${manifestLabel}#${registryMode ? 'id' : 'name'}`]))
218
295
  } else {
219
296
  manifestDetails.push(detail('C-1.1', 'PASS', `name=${name}`))
220
297
  }
221
298
  if (typeof manifest.version !== 'string' || !EXACT_VERSION.test(manifest.version)) {
222
- manifestDetails.push(detail('C-1.1', 'FAIL', 'version must be an exact SemVer version', ['package.json#version']))
299
+ manifestDetails.push(detail('C-1.1', 'FAIL', 'version must be an exact SemVer version', [`${manifestLabel}#version`]))
223
300
  } else {
224
301
  manifestDetails.push(detail('C-1.1', 'PASS', `version=${manifest.version}`))
225
302
  }
226
303
  if (entry.escape) {
227
- manifestDetails.push(detail('C-1.2', 'FAIL', `entry escapes the package: ${entry.target}`, ['package.json#exports']))
304
+ manifestDetails.push(detail('C-1.2', 'FAIL', `entry escapes the package: ${entry.target}`, [`${manifestLabel}#exports`]))
228
305
  } else if (entry.declaredMissing) {
229
306
  // A declared entry that is absent is a packaging defect. A build hint only
230
307
  // explains it; it does not make the package loadable from the tarball.
231
308
  const hint = entry.buildHint
232
309
  ? ` (build hint: ${entry.sourceEntry ?? 'build script'}; publish the built file)`
233
310
  : ''
234
- manifestDetails.push(detail('C-1.2', 'FAIL', `exports["."] points to a missing file: ${entry.target}${hint}`, ['package.json#exports']))
311
+ manifestDetails.push(detail('C-1.2', 'FAIL', `exports["."] points to a missing file: ${entry.target}${hint}`, [`${manifestLabel}#exports`]))
235
312
  } else if (entry.exists) {
236
313
  manifestDetails.push(detail('C-1.2', 'PASS', `entry resolves via ${entry.source}: ${entry.relative}`, [entry.relative]))
237
314
  } else if (entry.buildHint) {
238
- manifestDetails.push(detail('C-1.2', 'WARN', `entry not present in checkout; source/build hint exists (${entry.sourceEntry ?? 'build script'})`, ['package.json#scripts']))
315
+ manifestDetails.push(detail('C-1.2', 'WARN', `entry not present in checkout; source/build hint exists (${entry.sourceEntry ?? 'build script'})`, [`${manifestLabel}#scripts`]))
239
316
  } else if (kind === 'bundle' && patch.present) {
240
317
  // 2026-11-04: a bundle that ships only a cordis.patch.yml has no runtime entry
241
318
  // by design (dsh.bundle.patch is the carrier). Report NA, not WARN, so the
242
319
  // mandatory coverage is not charged for something the package never claimed.
243
320
  manifestDetails.push(detail('C-1.2', 'NA', 'patch-only bundle; no runtime entry by design', patch.files.map(f => f.relative)))
244
321
  } else if (kind === 'bundle' || kind === 'client') {
245
- manifestDetails.push(detail('C-1.2', 'WARN', `no runtime entry; ${kind} packages may be patch/client only`, ['package.json#exports']))
322
+ manifestDetails.push(detail('C-1.2', 'WARN', `no runtime entry; ${kind} packages may be patch/client only`, [`${manifestLabel}#exports`]))
246
323
  } else if (Array.isArray(manifest.workspaces) || (manifest.workspaces && typeof manifest.workspaces === 'object')) {
247
- manifestDetails.push(detail('C-1.2', 'NA', 'workspace root; run the checker on a package subdirectory', ['package.json#workspaces']))
324
+ manifestDetails.push(detail('C-1.2', 'NA', 'workspace root; run the checker on a package subdirectory', [`${manifestLabel}#workspaces`]))
248
325
  } else {
249
- manifestDetails.push(detail('C-1.2', 'FAIL', 'no resolvable runtime entry', ['package.json#exports', 'package.json#main']))
326
+ manifestDetails.push(detail('C-1.2', 'FAIL', 'no resolvable runtime entry', [`${manifestLabel}#exports`, `${manifestLabel}#main`]))
250
327
  }
251
328
 
252
329
  // Declared `exports` subpaths and `main` must point at files that ship with
@@ -273,10 +350,10 @@ export function runManifestChecks(dir, options = {}) {
273
350
  }
274
351
  for (const item of exportTargets(manifest.exports)) {
275
352
  if (item.label === 'exports["."]') continue // resolveEntry() already judged the root export
276
- noteTarget(item.label, item.target, 'package.json#exports')
353
+ noteTarget(item.label, item.target, `${manifestLabel}#exports`)
277
354
  }
278
355
  if (typeof manifest.main === 'string' && manifest.main.trim() !== '') {
279
- noteTarget('main', manifest.main, 'package.json#main', { allowBare: true })
356
+ noteTarget('main', manifest.main, `${manifestLabel}#main`, { allowBare: true })
280
357
  }
281
358
  manifestDetails.push(...missingTargetDetails.slice(0, 8))
282
359
  const shape = checkExportShape(entry, kind)
@@ -289,36 +366,66 @@ export function runManifestChecks(dir, options = {}) {
289
366
  manifestDetails.push(detail('C-1.4', 'PASS', `bundle patch present (${patch.files.length} file(s))`, patch.files.map(file => file.relative)))
290
367
  }
291
368
  if (typeof manifest.license !== 'string' || manifest.license.trim() === '') {
292
- manifestDetails.push(detail('C-1.5', 'WARN', 'license is missing', ['package.json#license']))
369
+ if (!packageFieldsJudged) {
370
+ manifestDetails.push(detail('C-1.5', 'NA', 'registry layout has no package.json and dsh.plugin.json declares no license; license not judged', [`${manifestLabel}#license`]))
371
+ } else {
372
+ manifestDetails.push(detail('C-1.5', 'WARN', 'license is missing', [`${manifestLabel}#license`]))
373
+ }
293
374
  } else {
294
375
  manifestDetails.push(detail('C-1.5', 'PASS', `license=${manifest.license}`))
295
376
  }
296
377
  if (manifest.private === true) {
297
- manifestDetails.push(detail('C-1.6', 'NA', 'private:true; not publishable to a registry', ['package.json#private']))
378
+ manifestDetails.push(detail('C-1.6', 'NA', 'private:true; not publishable to a registry', [`${manifestLabel}#private`]))
379
+ } else if (!packageFieldsJudged) {
380
+ manifestDetails.push(detail('C-1.6', 'NA', 'registry layout has no package.json; private/publishability is not judged', [`${manifestLabel}#private`]))
298
381
  }
299
382
  const manifestResult = worst(manifestDetails.map(item => item.result))
300
- const manifestCheck = check({
301
- id: 'DSC-01',
302
- clause: 'C-1',
303
- layer: 'L0',
304
- result: manifestResult,
305
- reason: manifestDetails.filter(item => item.result !== 'PASS' && item.result !== 'NA').map(item => `${item.item}: ${item.reason}`).join(' | '),
306
- details: manifestDetails,
307
- evidence: ['package.json'],
308
- })
383
+ const manifestNaReasons = registryMode
384
+ ? manifestDetails.filter(item => item.result === 'NA').map(item => `${item.item}: ${item.reason}`)
385
+ : []
386
+ const manifestCheck = {
387
+ ...check({
388
+ id: 'DSC-01',
389
+ clause: 'C-1',
390
+ layer: 'L0',
391
+ result: manifestResult,
392
+ coverage: packageFieldsJudged ? 'full' : 'partial',
393
+ reason: [
394
+ manifestDetails.filter(item => item.result !== 'PASS' && item.result !== 'NA').map(item => `${item.item}: ${item.reason}`).join(' | '),
395
+ ...manifestNaReasons,
396
+ ].filter(Boolean).join(' | '),
397
+ details: manifestDetails,
398
+ evidence: [manifestLabel],
399
+ }),
400
+ ...(packageFieldsJudged ? {} : {
401
+ howToEnable: 'run against the npm package directory (package.json) to judge license/dependencies/scripts; a registry layout only carries dsh.plugin.json fields',
402
+ }),
403
+ }
309
404
 
310
405
  const compatDetails = []
311
406
  const engines = isObject(manifest.engines) ? manifest.engines : {}
312
407
  const dshEngine = engines.dsh
313
408
  const peers = isObject(manifest.peerDependencies) ? manifest.peerDependencies : {}
314
409
  const dshPeers = Object.entries(peers).filter(([peer]) => peer === '@deepseek-ai/dsh' || peer.startsWith('@deepseek-ai/dsh-'))
315
- if (typeof dshEngine === 'string') {
410
+ const compatEvidence = [`${manifestLabel}#engines.dsh`, `${manifestLabel}#peerDependencies`]
411
+ if (!compatibilityKnown) {
412
+ // The fallback constant is not a host. Never turn it into a C-2 FAIL:
413
+ // record the declared ranges as NA/partial and point at the flag that
414
+ // would make the verdict possible.
415
+ const declared = typeof dshEngine === 'string'
416
+ ? `engines.dsh=${dshEngine}`
417
+ : dshPeers.length > 0
418
+ ? `dsh peer range(s)=${dshPeers.map(([peer, range]) => `${peer}:${range}`).join(', ')}`
419
+ : 'no engines.dsh or @deepseek-ai/dsh* peer range declared'
420
+ compatDetails.push(detail('C-2.1', 'NA', `${UNKNOWN_HOST_REASON}; declaration recorded (${declared}) but validity is not judged`, compatEvidence))
421
+ compatDetails.push(detail('C-2.2', 'NA', `${UNKNOWN_HOST_REASON}; runtime compatibility is not judged`, compatEvidence))
422
+ } else if (typeof dshEngine === 'string') {
316
423
  if (dshEngine.startsWith('workspace:')) {
317
- compatDetails.push(detail('C-2.3', 'FAIL', 'engines.dsh must not be a workspace: range', ['package.json#engines.dsh']))
424
+ compatDetails.push(detail('C-2.3', 'FAIL', 'engines.dsh must not be a workspace: range', [`${manifestLabel}#engines.dsh`]))
318
425
  } else if (!validRange(dshEngine)) {
319
- compatDetails.push(detail('C-2.1', 'FAIL', `engines.dsh is not a SemVer range: ${dshEngine}`, ['package.json#engines.dsh']))
426
+ compatDetails.push(detail('C-2.1', 'FAIL', `engines.dsh is not a SemVer range: ${dshEngine}`, [`${manifestLabel}#engines.dsh`]))
320
427
  } else if (!satisfies(runtimeVersion, dshEngine)) {
321
- compatDetails.push(detail('C-2.2', 'FAIL', `engines.dsh ${dshEngine} is valid but does not satisfy runtime ${runtimeVersion}`, ['package.json#engines.dsh']))
428
+ compatDetails.push(detail('C-2.2', 'FAIL', `engines.dsh ${dshEngine} is valid but does not satisfy runtime ${runtimeVersion}`, [`${manifestLabel}#engines.dsh`]))
322
429
  } else {
323
430
  compatDetails.push(detail('C-2.1', 'PASS', `engines.dsh=${dshEngine}`))
324
431
  compatDetails.push(detail('C-2.2', 'PASS', `runtime ${runtimeVersion} satisfies ${dshEngine}`))
@@ -326,7 +433,7 @@ export function runManifestChecks(dir, options = {}) {
326
433
  for (const [peer, rangeValue] of dshPeers) {
327
434
  if (typeof rangeValue !== 'string' || rangeValue.startsWith('workspace:')) continue
328
435
  if (validRange(rangeValue) && !satisfies(runtimeVersion, rangeValue)) {
329
- compatDetails.push(detail('C-2.4', 'WARN', `peer ${peer} range ${rangeValue} conflicts with engines.dsh`, [`package.json#peerDependencies.${peer}`]))
436
+ compatDetails.push(detail('C-2.4', 'WARN', `peer ${peer} range ${rangeValue} conflicts with engines.dsh`, [`${manifestLabel}#peerDependencies.${peer}`]))
330
437
  }
331
438
  }
332
439
  } else if (dshPeers.length > 0) {
@@ -334,18 +441,18 @@ export function runManifestChecks(dir, options = {}) {
334
441
  let unsatisfied = false
335
442
  for (const [peer, rangeValue] of dshPeers) {
336
443
  if (typeof rangeValue !== 'string') {
337
- compatDetails.push(detail('C-2.1', 'FAIL', `peer ${peer} must be a string range`, [`package.json#peerDependencies.${peer}`]))
444
+ compatDetails.push(detail('C-2.1', 'FAIL', `peer ${peer} must be a string range`, [`${manifestLabel}#peerDependencies.${peer}`]))
338
445
  invalid = true
339
446
  continue
340
447
  }
341
448
  const effective = /^workspace:(?:\^|~|\*)$/.test(rangeValue) ? runtimeVersion : rangeValue
342
449
  if (!validRange(effective)) {
343
- compatDetails.push(detail('C-2.1', 'FAIL', `peer ${peer} is not a SemVer range: ${rangeValue}`, [`package.json#peerDependencies.${peer}`]))
450
+ compatDetails.push(detail('C-2.1', 'FAIL', `peer ${peer} is not a SemVer range: ${rangeValue}`, [`${manifestLabel}#peerDependencies.${peer}`]))
344
451
  invalid = true
345
452
  } else if (!satisfies(runtimeVersion, effective)) {
346
453
  // A syntactically valid range that does not cover this runtime is a
347
454
  // compatibility finding (C-2.2), never an invalid declaration (C-2.1).
348
- compatDetails.push(detail('C-2.2', 'FAIL', `peer ${peer} range ${rangeValue} is valid but does not satisfy runtime ${runtimeVersion}`, [`package.json#peerDependencies.${peer}`]))
455
+ compatDetails.push(detail('C-2.2', 'FAIL', `peer ${peer} range ${rangeValue} is valid but does not satisfy runtime ${runtimeVersion}`, [`${manifestLabel}#peerDependencies.${peer}`]))
349
456
  unsatisfied = true
350
457
  }
351
458
  }
@@ -358,20 +465,26 @@ export function runManifestChecks(dir, options = {}) {
358
465
  compatDetails.push(detail('C-2.2', 'PASS', `runtime ${runtimeVersion} satisfies the dsh peer range(s)`))
359
466
  }
360
467
  } else {
361
- compatDetails.push(detail('C-2.1', 'FAIL', 'neither engines.dsh nor a @deepseek-ai/dsh* peer range is declared', ['package.json#engines', 'package.json#peerDependencies']))
468
+ compatDetails.push(detail('C-2.1', 'FAIL', 'neither engines.dsh nor a @deepseek-ai/dsh* peer range is declared', [`${manifestLabel}#engines`, `${manifestLabel}#peerDependencies`]))
362
469
  }
363
470
  const compatResult = worst(compatDetails.map(item => item.result))
364
- const compatCheck = check({
365
- id: 'DSC-02',
366
- clause: 'C-2',
367
- layer: 'L0',
368
- result: compatResult,
369
- reason: compatDetails.filter(item => item.result !== 'PASS' && item.result !== 'NA').map(item => `${item.item}: ${item.reason}`).join(' | '),
370
- details: compatDetails,
371
- evidence: ['package.json#engines', 'package.json#peerDependencies'],
372
- })
471
+ const compatCheck = {
472
+ ...check({
473
+ id: 'DSC-02',
474
+ clause: 'C-2',
475
+ layer: 'L0',
476
+ result: compatResult,
477
+ coverage: compatibilityKnown ? 'full' : 'partial',
478
+ reason: compatibilityKnown
479
+ ? compatDetails.filter(item => item.result !== 'PASS' && item.result !== 'NA').map(item => `${item.item}: ${item.reason}`).join(' | ')
480
+ : UNKNOWN_HOST_REASON,
481
+ details: compatDetails,
482
+ evidence: [manifestLabel === 'dsh.plugin.json' ? 'dsh.plugin.json#engines' : 'package.json#engines', `${manifestLabel}#peerDependencies`],
483
+ }),
484
+ ...(compatibilityKnown ? {} : { howToEnable: UNKNOWN_HOST_HOW }),
485
+ }
373
486
 
374
- const supplyDetails = supplyChain(dir, manifest)
487
+ const supplyDetails = supplyChain(dir, manifest, { registry: registryMode, packageJsonAvailable })
375
488
  const installDetails = [...supplyDetails]
376
489
  let installResult = 'NA'
377
490
  let installReason = 'install spec not supplied (package profile)'
@@ -393,6 +506,12 @@ export function runManifestChecks(dir, options = {}) {
393
506
  installResult = worst([market.result, ...supplyDetails.map(item => item.result)])
394
507
  installReason = market.reason || (installResult === 'WARN' ? 'market entry is pinned but supply-chain warnings remain' : '')
395
508
  }
509
+ if (registryMode && !packageJsonAvailable && installResult !== 'FAIL') {
510
+ // C-3.3/C-3.4 need package.json. Do not let a pinned --install-spec turn
511
+ // that missing input into a clean C-3 PASS.
512
+ installResult = 'NA'
513
+ installReason = 'registry layout has no package.json; dependency/lifecycle checks are NA (install-spec shape alone is not a C-3 pass)'
514
+ }
396
515
  const installCheck = check({
397
516
  id: 'DSC-03',
398
517
  clause: 'C-3',
@@ -401,10 +520,20 @@ export function runManifestChecks(dir, options = {}) {
401
520
  coverage: installResult === 'NA' ? 'not-run' : 'full',
402
521
  reason: installReason,
403
522
  details: installDetails,
404
- evidence: ['package.json#dependencies', 'package.json#scripts', options.marketIndex ?? '--install-spec'],
523
+ evidence: [`${manifestLabel}#dependencies`, `${manifestLabel}#scripts`, options.marketIndex ?? '--install-spec'],
405
524
  })
406
525
 
407
- return { manifest, kind, kindInferred: kindInfo.inferred, entry, patch, g4, checks: [manifestCheck, compatCheck, installCheck] }
526
+ return {
527
+ manifest,
528
+ manifestSource: registryMode ? 'registry' : 'package',
529
+ manifestPath,
530
+ kind,
531
+ kindInferred: kindInfo.inferred,
532
+ entry,
533
+ patch,
534
+ g4,
535
+ checks: [manifestCheck, compatCheck, installCheck],
536
+ }
408
537
  }
409
538
 
410
539
  export function checkMarketEntry(indexPath, pluginName) {
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 1.6.7 — 2026-11-07
2
+
3
+ ### Added
4
+
5
+ - `check --host-version`:显式指定宿主版本;未知时 C-2.1/C-2.2 记 NA/partial + howToEnable,不再误报 FAIL。
6
+ - `--registry-dir`:读取 sidebar 形态的 `registry/`(`dsh.plugin.json`),输出 `subject.source=registry`,缺 package.json 的检查记 NA。
7
+ - Windows:`flow-collect` 用 `npm.cmd + shell` 调 npm pack,修 `EINVAL`。
8
+ - sidecar 扩到 50 条;security 块正式化(state/checks/summary/command,partial ≠ 安全审计)。
9
+ - 离线包 `dsh-standards-offline-1.6.6.tgz`(992,962 B,64 文件)。
10
+
11
+ ### Verified
12
+
13
+ - `npm test` 313/313。
14
+ - sidebar 0.30.1 / TUI 0.19.0 默认 entry static:exit 1/blocking 1 → exit 0/blocking 0;显式 `--host-version 0.2.1-rc.5` 仍报真实 C-2.2 FAIL。
15
+
1
16
  ## 1.6.6 — 2026-11-07
2
17
 
3
18
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-standards",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "DSH plugin standards and conformance checks: ENTRY/FLOW checks plus BOOST guidance. Non-official; no certification or ranking.",
5
5
  "type": "module",
6
6
  "main": "40-checker/src/index.mjs",