universal-dev-standards 6.14.0-beta.4 → 6.14.0-beta.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.
Files changed (56) hide show
  1. package/bin/uds.js +9 -2
  2. package/bundled/ai/standards/commit-message.ai.yaml +6 -2
  3. package/bundled/ai/standards/full-coverage-testing.ai.yaml +46 -5
  4. package/bundled/core/full-coverage-testing.md +57 -3
  5. package/bundled/locales/zh-CN/CHANGELOG.md +54 -3
  6. package/bundled/locales/zh-CN/README.md +1 -1
  7. package/bundled/locales/zh-CN/SECURITY.md +1 -1
  8. package/bundled/locales/zh-CN/core/full-coverage-testing.md +61 -7
  9. package/bundled/locales/zh-CN/docs/CHEATSHEET.md +4 -2
  10. package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +10 -6
  11. package/bundled/locales/zh-TW/CHANGELOG.md +54 -3
  12. package/bundled/locales/zh-TW/README.md +1 -1
  13. package/bundled/locales/zh-TW/SECURITY.md +1 -1
  14. package/bundled/locales/zh-TW/core/full-coverage-testing.md +61 -7
  15. package/bundled/locales/zh-TW/docs/CHEATSHEET.md +4 -2
  16. package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +10 -6
  17. package/bundled/templates/gates/check-anti-fake-tests.mjs +991 -0
  18. package/bundled/templates/gates/check-stubs.mjs +644 -0
  19. package/package.json +2 -2
  20. package/src/commands/audit.js +11 -0
  21. package/src/commands/check.js +124 -24
  22. package/src/commands/deps.js +31 -1
  23. package/src/commands/init.js +16 -0
  24. package/src/commands/simulate.js +20 -8
  25. package/src/commands/skills.js +42 -2
  26. package/src/commands/spec.js +14 -8
  27. package/src/commands/update.js +222 -21
  28. package/src/core/install-records.js +2 -1
  29. package/src/core/manifest.js +12 -10
  30. package/src/core/marketplace-sentinel.js +5 -0
  31. package/src/core/project-config.js +58 -38
  32. package/src/i18n/messages.js +77 -9
  33. package/src/reconciler/backup-locations.js +75 -0
  34. package/src/reconciler/backup-manager.js +435 -115
  35. package/src/reconciler/index.js +44 -5
  36. package/src/reconciler/install-roots.js +90 -0
  37. package/src/reconciler/plan-executor.js +23 -2
  38. package/src/uninstallers/hook-uninstaller.js +2 -1
  39. package/src/utils/command-hash-ownership.js +103 -0
  40. package/src/utils/commit-message-judge.js +137 -0
  41. package/src/utils/copier.js +21 -1
  42. package/src/utils/deps-applicability.js +25 -0
  43. package/src/utils/gate-scripts.js +141 -0
  44. package/src/utils/health-scorer.js +10 -7
  45. package/src/utils/installed-names-ownership.js +114 -0
  46. package/src/utils/sdd-header.js +65 -0
  47. package/src/utils/skill-hash-ownership.js +64 -0
  48. package/src/utils/skills-installer.js +12 -1
  49. package/src/utils/standard-validator.js +98 -27
  50. package/src/utils/test-change-check.js +160 -0
  51. package/src/utils/test-policy.js +214 -0
  52. package/src/utils/update-summary.js +29 -0
  53. package/src/vibe/micro-spec.js +15 -0
  54. package/standards-registry.json +7 -7
  55. package/bundled/extensions/languages/php/fat-free-patterns.md +0 -915
  56. package/bundled/extensions/languages/php/php-style.md +0 -693
@@ -345,6 +345,17 @@ async function handleReport(auditResult, options, msg) {
345
345
  const isDryRun = options.dryRun || false;
346
346
  const forceGh = options.gh || false;
347
347
 
348
+ // XSPEC-454 R3: submitting means talking to GitHub (the `gh` CLI, or a browser/clipboard
349
+ // fallback). Offline mode must not do that, and must say so — not fail, not skip silently.
350
+ // A dry run only prints the report, so it still works offline and is offered as the way out.
351
+ if (options.offline && !isDryRun) {
352
+ console.log();
353
+ console.log(chalk.yellow(msg.offlineNoSubmit || 'Offline mode: the report is not submitted.'));
354
+ console.log(chalk.gray(msg.offlineDryRunHint || ' Use --dry-run to preview it, or run again without --offline to submit.'));
355
+ console.log();
356
+ return;
357
+ }
358
+
348
359
  // Gather findings for selection
349
360
  const findings = [];
350
361
 
@@ -4,7 +4,7 @@ import { createSpinner } from '../utils/spinner.js';
4
4
  import { existsSync, readFileSync } from 'fs';
5
5
  import { join, basename } from 'path';
6
6
  import { execSync } from 'child_process';
7
- import { readManifest, writeManifest, isInitialized, copyStandard, copyIntegration } from '../utils/copier.js';
7
+ import { readManifest, writeManifest, isInitialized, copyStandard, copyIntegration, readPackagedSource } from '../utils/copier.js';
8
8
  import {
9
9
  getAllStandards,
10
10
  getRepositoryInfo, isShippedFilename, resolveStandardFilename, resolveStandardSourcePath } from '../utils/registry.js';
@@ -16,7 +16,7 @@ import {
16
16
  computeIntegrationBlockHash,
17
17
  pruneIntegrationFileHashes
18
18
  } from '../utils/hasher.js';
19
- import { downloadFromGitHub, getMarketplaceSkillsInfo } from '../utils/github.js';
19
+ import { getMarketplaceSkillsInfo } from '../utils/github.js';
20
20
  import {
21
21
  getInstalledSkillsInfoForAgent,
22
22
  getInstalledCommandsForAgent
@@ -46,6 +46,10 @@ import { guardAgainstSelfAdoption } from '../utils/detect-self-adoption.js';
46
46
  import { lintAll as lintI18nAll, partitionFindings as partitionI18nFindings } from '../lint/i18n.js';
47
47
  import { resolveIntegrationFile } from '../core/constants.js';
48
48
  import { checkPreCommitHookWiring } from '../utils/git-hooks.js';
49
+ import { runTestChangeCheck } from '../utils/test-change-check.js';
50
+ import { runTestQualityGates } from '../utils/gate-scripts.js';
51
+ import { pruneForeignSkillHashes, skillIssuesOf } from '../utils/skill-hash-ownership.js';
52
+ import { pruneForeignCommandHashes, projectCommandHashes, commandIssuesOf } from '../utils/command-hash-ownership.js';
49
53
 
50
54
  /**
51
55
  * Display the summary of file integrity status
@@ -413,11 +417,35 @@ export async function checkCommand(options = {}) {
413
417
 
414
418
  // === Enhanced Integrity Checks (v3.3.0+) ===
415
419
 
416
- // Check Skills integrity if skillHashes exist
417
- checkSkillsIntegrity(manifest, projectPath, msg);
418
-
419
- // Check Commands integrity if commandHashes exist
420
- checkCommandsIntegrity(manifest, projectPath, msg);
420
+ // Check Skills integrity if skillHashes exist.
421
+ //
422
+ // XSPEC-454 R2, in this order and no other. Step 1: forget the records that were never UDS's to
423
+ // keep (the adopter's own skills; `agents/`, `workflows/`, `_shared/` folders an old CLI copied
424
+ // in and a later update removed). In memory only — `check` is read-only — and `uds update`
425
+ // drops them from the file. Step 2: what is left is a record of a file UDS installed, so a
426
+ // missing or changed one is a real finding and counts toward the verdict below. Doing step 2
427
+ // alone would turn every existing project's `check` (and the pre-commit hook that runs it)
428
+ // red the day it upgrades, for files nobody can restore.
429
+ const skillRecordsBefore = Object.keys(manifest.skillHashes || {}).length;
430
+ pruneForeignSkillHashes(manifest);
431
+ const ignoredSkillRecords = skillRecordsBefore - Object.keys(manifest.skillHashes || {}).length;
432
+ const skillsIntegrity = checkSkillsIntegrity(manifest, projectPath, msg, ignoredSkillRecords);
433
+ const skillIssues = skillIssuesOf(skillsIntegrity);
434
+
435
+ // Check Commands integrity if commandHashes exist.
436
+ //
437
+ // XSPEC-454 R2, the Commands half, same order as above: first set aside the records this project's
438
+ // check cannot vouch for (commands UDS does not ship; commands installed at user level, which live
439
+ // outside the project), then let what is left decide the verdict.
440
+ const commandRecordsBefore = Object.keys(manifest.commandHashes || {}).length;
441
+ pruneForeignCommandHashes(manifest);
442
+ const ignoredCommandRecords = commandRecordsBefore - Object.keys(manifest.commandHashes || {}).length;
443
+ const projectCommands = projectCommandHashes(manifest);
444
+ const commandsIntegrity = checkCommandsIntegrity(
445
+ { ...manifest, commandHashes: projectCommands.hashes }, projectPath, msg,
446
+ { foreign: ignoredCommandRecords, elsewhere: projectCommands.ignored.length }
447
+ );
448
+ const commandIssues = commandIssuesOf(commandsIntegrity);
421
449
 
422
450
  // XSPEC adopter-report Q3: neither of the two checks above (content-hash
423
451
  // integrity) says anything about an installed Skills/Commands version
@@ -465,6 +493,13 @@ export async function checkCommand(options = {}) {
465
493
  await showDiff(projectPath, manifest, fileStatus.modified);
466
494
  return;
467
495
  }
496
+ if (options.diff) {
497
+ // Nothing to diff. Say what "nothing" is measured against rather than printing no line at all —
498
+ // silence reads the same as "the diff step did not run".
499
+ printDiffBaseline(manifest, msg);
500
+ console.log(chalk.green(msg.diffNone));
501
+ console.log();
502
+ }
468
503
 
469
504
  // Interactive mode (default when issues detected, only in TTY)
470
505
  const hasIssues = fileStatus.modified.length > 0 ||
@@ -513,6 +548,14 @@ export async function checkCommand(options = {}) {
513
548
  // pre-commit 檢查檔存在,但 git 實際不會執行它(只報告,不寫入 —— 見 checkPreCommitWiring 下方註解)
514
549
  checkPreCommitWiring(projectPath, msg);
515
550
 
551
+ // XSPEC-444 R2 + R5: this commit changes code but no test; fake tests; empty shells.
552
+ // Warnings by default — a commit is blocked only when the project sets "mode": "block" in
553
+ // .standards/test-policy.json. Both are read-only here (nothing is written to the project).
554
+ // XSPEC-454 R2 (same class): both report whether they blocked; in "block" mode they set the exit code
555
+ // themselves, but the run still ended "compliant" because the verdict below never read what they said.
556
+ const testChange = runTestChangeCheck(projectPath);
557
+ const testGates = runTestQualityGates(projectPath);
558
+
516
559
  // Workflow status
517
560
  displayWorkflowStatus(projectPath);
518
561
 
@@ -520,8 +563,14 @@ export async function checkCommand(options = {}) {
520
563
  // XSPEC-418 R1: integration block problems (UDS markers removed, block
521
564
  // modified, or the tracked file missing) now feed the verdict — they used to
522
565
  // be checked and printed above, then silently dropped here.
566
+ // XSPEC-454 R2: the Skills integrity result used to be thrown away (the call above was a bare
567
+ // statement), so a deleted or edited skill file printed ✗ and still ended in "compliant", exit 0.
523
568
  const allGood = fileStatus.missing.length === 0 &&
524
569
  fileStatus.modified.length === 0 &&
570
+ skillIssues.length === 0 &&
571
+ commandIssues.length === 0 &&
572
+ !testChange.blocked &&
573
+ !testGates.blocked &&
525
574
  integrationBlockStatus.modified.length === 0 &&
526
575
  integrationBlockStatus.missing.length === 0 &&
527
576
  integrationBlockStatus.noMarkers.length === 0 &&
@@ -530,6 +579,12 @@ export async function checkCommand(options = {}) {
530
579
  console.log(chalk.green(msg.projectCompliant));
531
580
  } else {
532
581
  console.log(chalk.yellow(msg.issuesDetected));
582
+ if (commandIssues.length > 0) {
583
+ console.log(chalk.gray(msg.commandsIntegrityFix || ' Command files listed above are missing or were changed: run `uds update --apply --commands` to reinstall them.'));
584
+ }
585
+ if (skillIssues.length > 0) {
586
+ console.log(chalk.gray(msg.skillsIntegrityFix || ' Skill files listed above are missing or were changed: run `uds update --apply --skills` to reinstall them.'));
587
+ }
533
588
  // Set non-zero exit code in CI mode so pipelines detect failures
534
589
  if (options.ci) {
535
590
  process.exitCode = 1;
@@ -592,6 +647,7 @@ async function interactiveMode(projectPath, manifest, fileStatus, msg) {
592
647
 
593
648
  switch (action) {
594
649
  case 'view': {
650
+ printDiffBaseline(manifest, msg);
595
651
  await showSingleFileDiff(projectPath, manifest, issue.file, msg);
596
652
  // After viewing, ask again
597
653
  const followUp = await select({
@@ -649,8 +705,33 @@ async function interactiveMode(projectPath, manifest, fileStatus, msg) {
649
705
  }
650
706
  }
651
707
 
708
+ /**
709
+ * Tell the reader what the diff is measured against (XSPEC-453 R1).
710
+ *
711
+ * `uds check --diff` answers "what did I change in what UDS gave me". The original is the copy inside
712
+ * the installed UDS package, so this says that — and where to look for what UDS itself changed since.
713
+ * When the project's standards were installed from a different version than the package now installed,
714
+ * a file UDS changed in between shows up as a difference, so that gap is stated rather than left to be
715
+ * discovered.
716
+ */
717
+ function printDiffBaseline(manifest, msg) {
718
+ const packageVersion = getRepositoryInfo().standards.version;
719
+ console.log(chalk.gray(msg.diffBaseline.replace('{version}', packageVersion)));
720
+ const installedVersion = manifest?.upstream?.version;
721
+ if (installedVersion && installedVersion !== packageVersion) {
722
+ console.log(chalk.yellow(
723
+ msg.diffBaselineVersionDiffers.replace('{installed}', installedVersion).replace('{version}', packageVersion)
724
+ ));
725
+ }
726
+ }
727
+
652
728
  /**
653
729
  * Show diff for a single file
730
+ *
731
+ * The original is read from the installed UDS package, never downloaded (XSPEC-453 R1).
732
+ *
733
+ * @returns {Promise<'shown'|'no-original'|'unreadable'>} What happened; `'no-original'` means the
734
+ * installed package has no original for this file (reported by name, not skipped silently).
654
735
  */
655
736
  async function showSingleFileDiff(projectPath, manifest, relativePath, msg) {
656
737
  const { readFileSync } = await import('fs');
@@ -662,31 +743,31 @@ async function showSingleFileDiff(projectPath, manifest, relativePath, msg) {
662
743
  currentContent = readFileSync(fullPath, 'utf-8');
663
744
  } catch {
664
745
  console.log(chalk.red(msg.couldNotReadFile));
665
- return;
746
+ return 'unreadable';
666
747
  }
667
748
 
668
- // Get original content from GitHub
749
+ // Get original content from the installed package
669
750
  const sourcePath = getSourcePathFromRelative(manifest, relativePath);
670
751
  if (!sourcePath) {
671
752
  console.log(chalk.red(msg.couldNotDetermineSource2));
672
- return;
753
+ return 'unreadable';
673
754
  }
674
755
 
675
- console.log(chalk.gray(msg.fetchingOriginal));
676
756
  let originalContent;
677
757
  try {
678
- originalContent = await downloadFromGitHub(sourcePath);
758
+ originalContent = readPackagedSource(sourcePath);
679
759
  } catch (error) {
680
- if (error.message.includes('429')) {
681
- console.log(chalk.red(msg.rateLimited || 'GitHub API rate limit exceeded. Please wait a few minutes and try again.'));
682
- } else {
683
- console.log(chalk.red(`${msg.couldNotFetchOriginal} (${error.message})`));
684
- }
685
- return;
760
+ console.log(chalk.red(`${msg.couldNotReadOriginal.replace('{file}', relativePath)} (${error.message})`));
761
+ return 'unreadable';
686
762
  }
687
- if (!originalContent) {
688
- console.log(chalk.red(msg.couldNotFetchOriginal));
689
- return;
763
+ if (originalContent === null) {
764
+ console.log(chalk.red(
765
+ msg.noOriginalInPackage
766
+ .replace('{file}', relativePath)
767
+ .replace('{source}', sourcePath)
768
+ .replace('{version}', getRepositoryInfo().standards.version)
769
+ ));
770
+ return 'no-original';
690
771
  }
691
772
 
692
773
  // Simple diff display
@@ -721,6 +802,7 @@ async function showSingleFileDiff(projectPath, manifest, relativePath, msg) {
721
802
  }
722
803
  }
723
804
  console.log();
805
+ return 'shown';
724
806
  }
725
807
 
726
808
  /**
@@ -728,11 +810,17 @@ async function showSingleFileDiff(projectPath, manifest, relativePath, msg) {
728
810
  */
729
811
  async function showDiff(projectPath, manifest, modifiedFiles) {
730
812
  const msg = t().commands.check;
813
+ printDiffBaseline(manifest, msg);
814
+ let missingOriginals = 0;
731
815
  for (const file of modifiedFiles) {
732
816
  console.log(chalk.cyan(`\n${msg.diffFor.replace('{file}', file)}`));
733
817
  console.log(chalk.gray('─'.repeat(50)));
734
- await showSingleFileDiff(projectPath, manifest, file, msg);
818
+ const outcome = await showSingleFileDiff(projectPath, manifest, file, msg);
819
+ if (outcome === 'no-original') missingOriginals++;
735
820
  }
821
+ // A package that lacks the original of a file it should have shipped is a defect worth a non-zero
822
+ // exit: scripts must not read "no diff shown" as "no difference".
823
+ if (missingOriginals > 0) process.exitCode = 1;
736
824
  }
737
825
 
738
826
  /**
@@ -1916,7 +2004,7 @@ function checkSkillsCommandsVersionStaleness(manifest, projectPath, msg) { // es
1916
2004
  * @param {Object} msg - Localized messages
1917
2005
  * @returns {Object} Status { unchanged: [], modified: [], missing: [] }
1918
2006
  */
1919
- function checkSkillsIntegrity(manifest, projectPath, msg) {
2007
+ function checkSkillsIntegrity(manifest, projectPath, msg, ignoredRecords = 0) {
1920
2008
  const skillHashes = manifest.skillHashes;
1921
2009
 
1922
2010
  // Skip if no skill hashes tracked
@@ -1925,6 +2013,10 @@ function checkSkillsIntegrity(manifest, projectPath, msg) {
1925
2013
  }
1926
2014
 
1927
2015
  console.log(chalk.cyan(msg.skillsIntegrityCheck || 'Skills File Integrity'));
2016
+ if (ignoredRecords > 0) {
2017
+ console.log(chalk.gray((msg.skillsStaleRecordsIgnored || ' {count} skill record(s) ignored: they describe files UDS did not install.')
2018
+ .replace('{count}', ignoredRecords)));
2019
+ }
1928
2020
 
1929
2021
  const status = { unchanged: [], modified: [], missing: [], tracked: true };
1930
2022
 
@@ -1987,7 +2079,7 @@ function checkSkillsIntegrity(manifest, projectPath, msg) {
1987
2079
  * @param {Object} msg - Localized messages
1988
2080
  * @returns {Object} Status { unchanged: [], modified: [], missing: [] }
1989
2081
  */
1990
- export function checkCommandsIntegrity(manifest, projectPath, msg) {
2082
+ export function checkCommandsIntegrity(manifest, projectPath, msg, ignored = {}) {
1991
2083
  const commandHashes = manifest.commandHashes;
1992
2084
 
1993
2085
  // Skip if no command hashes tracked
@@ -1996,6 +2088,14 @@ export function checkCommandsIntegrity(manifest, projectPath, msg) {
1996
2088
  }
1997
2089
 
1998
2090
  console.log(chalk.cyan(msg.commandsIntegrityCheck || 'Commands File Integrity'));
2091
+ if (ignored.foreign > 0) {
2092
+ console.log(chalk.gray((msg.commandsStaleRecordsIgnored || ' {count} command record(s) ignored: they describe commands UDS does not ship.')
2093
+ .replace('{count}', ignored.foreign)));
2094
+ }
2095
+ if (ignored.elsewhere > 0) {
2096
+ console.log(chalk.gray((msg.commandsElsewhereIgnored || ' {count} command record(s) ignored: those commands are installed at user level, shared by every project.')
2097
+ .replace('{count}', ignored.elsewhere)));
2098
+ }
1999
2099
 
2000
2100
  const status = { unchanged: [], modified: [], missing: [], untracked: [], tracked: true };
2001
2101
 
@@ -21,6 +21,8 @@
21
21
 
22
22
  import chalk from 'chalk';
23
23
  import { measureResolutionDrift } from '../utils/dependency-resolution.js';
24
+ import { notApplicableReason } from '../utils/deps-applicability.js';
25
+ import { t } from '../i18n/messages.js';
24
26
 
25
27
  /**
26
28
  * Render the human-readable report.
@@ -162,6 +164,23 @@ export function render(result) {
162
164
 
163
165
  export async function depsCommand(options = {}) {
164
166
  const root = options.path ?? process.cwd();
167
+ const msg = t().commands.deps || {};
168
+
169
+ // XSPEC-456 R6: `--if-present` is the explicit way to say "this is a shared script and some of the
170
+ // projects it runs in are not Node projects". Without it nothing changes: no package.json is still
171
+ // exit 1, because a check that examined nothing must not be able to show a pass. With it the run says
172
+ // out loud that nothing was checked and exits 0 - the shell `if [ -f package.json ]` that callers
173
+ // otherwise write around this command, made part of the command and made visible.
174
+ const skip = notApplicableReason(root, Boolean(options.ifPresent));
175
+ if (skip === 'no-package-json') {
176
+ const reason = msg.notApplicableNoPackageJson || 'Not applicable: there is no package.json, so nothing was checked';
177
+ if (options.json) {
178
+ console.log(JSON.stringify({ notApplicable: true, examined: 0, reason, root }, null, 2));
179
+ } else {
180
+ console.log(chalk.yellow(reason));
181
+ }
182
+ return;
183
+ }
165
184
 
166
185
  let result;
167
186
  try {
@@ -174,14 +193,25 @@ export async function depsCommand(options = {}) {
174
193
  return;
175
194
  }
176
195
 
196
+ // A package with no runtime dependencies has nothing to compare. `--if-present` accepts that too (the
197
+ // telemetry SDK publish flow hit exactly this), and says so rather than printing a tick.
198
+ const noRuntimeDeps = Boolean(options.ifPresent) && result.examined === 0 && !result.clean;
199
+ if (noRuntimeDeps) {
200
+ result = { ...result, notApplicable: true };
201
+ }
202
+
177
203
  if (options.json) {
178
204
  console.log(JSON.stringify(result, null, 2));
179
205
  } else {
180
206
  console.log(render(result));
207
+ if (noRuntimeDeps) {
208
+ console.log(chalk.yellow(msg.notApplicableNoRuntimeDeps || 'Not applicable: this package declares no runtime dependencies, so nothing was checked'));
209
+ console.log();
210
+ }
181
211
  }
182
212
 
183
213
  // Drift and unverifiable both fail. Drift is a real divergence; unverifiable
184
214
  // is an unknown, and a check that exits 0 on "I don't know" is a check that
185
215
  // reports success for the case it was built to catch.
186
- if (!result.clean) process.exitCode = 1;
216
+ if (!result.clean && !noRuntimeDeps) process.exitCode = 1;
187
217
  }
@@ -32,6 +32,7 @@ import { withFileTransaction } from '../utils/transaction.js';
32
32
  import { newRecorder, mkdirTracked, recordFile, persistRecorder, RECORD_KINDS } from '../core/install-records.js';
33
33
  import { wireGitHooksPath, getLocalHooksPathConfig, stripLegacyHuskyShLine, ensureShebang, hookRunsUdsCheck, buildPreCommitBlock } from '../utils/git-hooks.js';
34
34
  import { migrateLegacyHuskyHook } from '../utils/legacy-hook-migration.js';
35
+ import { installGateScripts } from '../utils/gate-scripts.js';
35
36
 
36
37
  /**
37
38
  * Init command - initialize standards in current project
@@ -346,6 +347,21 @@ export async function initCommand(options) {
346
347
  for (const created of combinedResults.createdIntegrationFiles ?? []) {
347
348
  recordFile(installRecorder, projectPath, created, RECORD_KINDS.INTEGRATION_FILE);
348
349
  }
350
+
351
+ // 4.8. Ship the fake-test and stub scanners the full-coverage-testing standard asks for
352
+ // (XSPEC-444 R5). They are written whether or not git is present — the hook step below
353
+ // needs a repository, the scanners do not — and recorded so `uds uninstall` removes
354
+ // exactly these files. A file that already exists is the adopter's and is left alone.
355
+ const gateResult = installGateScripts(projectPath, installRecorder);
356
+ for (const rel of gateResult.written) {
357
+ console.log(chalk.green(` ✓ ${rel} (fake-test / stub scanner — \`uds check\` runs it and warns; edit it freely)`));
358
+ }
359
+ for (const rel of gateResult.kept) {
360
+ console.log(chalk.gray(` · ${rel} already exists — kept as is`));
361
+ }
362
+ for (const file of gateResult.missingTemplate) {
363
+ console.log(chalk.yellow(` ⚠ scripts/${file} not installed — the template is missing from this UDS package`));
364
+ }
349
365
  persistRecorder(projectPath, installRecorder);
350
366
 
351
367
  // 5. Setup Pre-commit Hook
@@ -1,6 +1,9 @@
1
1
  import chalk from 'chalk';
2
2
  import { StandardValidator } from '../utils/standard-validator.js';
3
3
 
4
+ /** Process exit code per outcome. 2 means no verdict - it is not a pass. */
5
+ export const EXIT_CODES = { pass: 0, fail: 1, 'cannot-simulate': 2 };
6
+
4
7
  export async function simulateCommand(options) {
5
8
  if (!options.standard) {
6
9
  if (options.json) {
@@ -25,10 +28,13 @@ export async function simulateCommand(options) {
25
28
 
26
29
  try {
27
30
  const result = await validator.simulate(options.standard, options.input);
31
+ // XSPEC-456 R2: exit 0 only for a pass. 1 = the input does not comply, 2 = no verdict could be reached
32
+ // (the same "cannot decide is not a pass" contract as `uds open-work`).
33
+ const exitCode = EXIT_CODES[result.status] ?? EXIT_CODES['cannot-simulate'];
28
34
 
29
35
  if (options.json) {
30
36
  console.log(JSON.stringify(result, null, 2));
31
- if (!result.success) process.exitCode = 1;
37
+ process.exitCode = exitCode;
32
38
  return;
33
39
  }
34
40
 
@@ -37,25 +43,31 @@ export async function simulateCommand(options) {
37
43
  console.log(chalk.gray('Input: ' + options.input));
38
44
  console.log(chalk.gray('─'.repeat(50)));
39
45
 
40
- if (result.success) {
46
+ if (result.status === 'pass') {
41
47
  console.log(chalk.green('✓ Simulation Passed'));
42
48
  if (result.details) console.log(chalk.gray(result.details));
49
+ } else if (result.status === 'fail') {
50
+ console.log(chalk.red('✗ Simulation Failed: the input does not comply'));
51
+ if (result.details) {
52
+ console.log(chalk.gray('\nDetails:'));
53
+ console.log(chalk.gray(result.details));
54
+ }
43
55
  } else {
44
- console.log(chalk.red('✗ Simulation Failed'));
45
- console.log(chalk.red(` ${result.message}`));
56
+ console.log(chalk.yellow('⚠ Cannot simulate: no verdict was reached, so this is neither a pass nor a fail'));
57
+ console.log(chalk.yellow(` ${result.message}`));
46
58
  if (result.details) {
47
59
  console.log(chalk.gray('\nDetails:'));
48
60
  console.log(chalk.gray(result.details));
49
61
  }
50
- process.exitCode = 1;
51
62
  }
63
+ process.exitCode = exitCode;
52
64
  } catch (error) {
53
65
  if (options.json) {
54
- console.log(JSON.stringify({ success: false, message: error.message }));
55
- process.exit(1);
66
+ console.log(JSON.stringify({ status: 'cannot-simulate', success: false, message: error.message }));
67
+ process.exit(EXIT_CODES['cannot-simulate']);
56
68
  }
57
69
  console.error(chalk.red(`Error: ${error.message}`));
58
- process.exit(1);
70
+ process.exit(EXIT_CODES['cannot-simulate']);
59
71
  }
60
72
  if (!options.json) console.log();
61
73
  }
@@ -3,6 +3,9 @@ import { existsSync, readdirSync, readFileSync } from 'fs';
3
3
  import { join } from 'path';
4
4
  import { homedir } from 'os';
5
5
  import { getAllSkillNames } from '../utils/registry.js';
6
+ import { getAvailableSkillNames } from '../utils/skills-installer.js';
7
+ import { pruneForeignSkillHashes } from '../utils/skill-hash-ownership.js';
8
+ import { getSkillsDirForAgent, getAgentDisplayName } from '../config/ai-agent-paths.js';
6
9
  import { readManifest, isInitialized } from '../utils/copier.js';
7
10
  import { t, setLanguage, isLanguageExplicitlySet } from '../i18n/messages.js';
8
11
 
@@ -111,8 +114,13 @@ export function skillsCommand() {
111
114
  console.log(chalk.gray('─'.repeat(50)));
112
115
  console.log();
113
116
 
114
- // Get all known skills from registry
115
- const knownSkills = getAllSkillNames();
117
+ // XSPEC-456 R3: the skills UDS ships are the ones in its skills source tree (what `uds init` and
118
+ // `uds update` install, and what `uds check` verifies). This used to be the `skillFiles` list of
119
+ // standards-registry.json, a hand-kept list that stopped at 30 while UDS ships 56, so a project with
120
+ // all 56 installed read "27 / 30" (27 = the installed ones that happened to be on the stale list).
121
+ // The registry list is only a fallback for a source tree that did not load.
122
+ const shipped = getAvailableSkillNames();
123
+ const knownSkills = shipped.length > 0 ? shipped : getAllSkillNames();
116
124
 
117
125
  // Check different installation locations
118
126
  const installations = [];
@@ -195,6 +203,27 @@ export function skillsCommand() {
195
203
  }
196
204
  }
197
205
 
206
+ // 4. Other AI tools the manifest says Skills were installed for (Codex, OpenCode, ...). Claude Code's
207
+ // own two locations were handled above.
208
+ const manifestForSkills = isInitialized(projectPath) ? readManifest(projectPath) : null;
209
+ const seenDirs = new Set(installations.map(i => i.path));
210
+ for (const entry of manifestForSkills?.skills?.installations || []) {
211
+ const agent = typeof entry === 'string' ? entry : entry?.agent;
212
+ const level = typeof entry === 'string' ? 'project' : (entry?.level || 'project');
213
+ if (!agent || agent === 'claude-code') continue;
214
+ const dir = getSkillsDirForAgent(agent, level, projectPath);
215
+ if (!dir || seenDirs.has(dir)) continue;
216
+ seenDirs.add(dir);
217
+ const udsSkills = listSkillsInDir(dir).filter(s => knownSkills.includes(s));
218
+ if (udsSkills.length === 0) continue;
219
+ installations.push({
220
+ location: `${getAgentDisplayName(agent)} (${level} level)`,
221
+ path: dir,
222
+ version: manifestForSkills.skills.version || 'unknown',
223
+ skills: udsSkills
224
+ });
225
+ }
226
+
198
227
  // Display results
199
228
  if (installations.length === 0) {
200
229
  console.log(chalk.yellow(msg.noSkillsInstalled));
@@ -259,6 +288,17 @@ export function skillsCommand() {
259
288
  console.log(chalk.gray('─'.repeat(50)));
260
289
  console.log(chalk.gray(`${msg.totalUniqueSkills}: ${totalSkills} / ${knownSkills.length}`));
261
290
 
291
+ // The number `uds check` prints is a count of FILES (a skill is one or more files), so say how the two
292
+ // relate instead of leaving two different numbers side by side. Counted the way `check` counts them.
293
+ if (manifestForSkills?.skillHashes) {
294
+ const tracked = structuredClone(manifestForSkills);
295
+ pruneForeignSkillHashes(tracked, new Set(knownSkills));
296
+ const files = Object.keys(tracked.skillHashes || {}).length;
297
+ if (files > 0 && msg.skillFilesTracked) {
298
+ console.log(chalk.gray(msg.skillFilesTracked.replace('{files}', files)));
299
+ }
300
+ }
301
+
262
302
  if (!hasMarketplace && installations.length > 0) {
263
303
  console.log();
264
304
  console.log(chalk.yellow(msg.recommendation));
@@ -131,15 +131,21 @@ export async function specListCommand(options = {}) {
131
131
  return;
132
132
  }
133
133
 
134
- // Display specs as a table
135
- console.log(chalk.gray('─'.repeat(70)));
134
+ // Display specs as a table. A status or type the file does not state is shown as unknown, never as a
135
+ // default (XSPEC-456 R5): an SDD spec whose header could not be read used to be listed as `draft`.
136
+ const unparsed = t('spec.statusUnparsed', 'format: SDD (status not parsed)');
137
+ const statusLabel = (spec) => spec.status ?? unparsed;
138
+ const statusWidth = Math.max(12, ...specs.map((spec) => statusLabel(spec).length + 1));
139
+ const ruleWidth = 70 + (statusWidth - 12);
140
+
141
+ console.log(chalk.gray('─'.repeat(ruleWidth)));
136
142
  console.log(
137
143
  chalk.bold('ID'.padEnd(35)) +
138
- chalk.bold('Status'.padEnd(12)) +
144
+ chalk.bold('Status'.padEnd(statusWidth)) +
139
145
  chalk.bold('Type'.padEnd(10)) +
140
146
  chalk.bold('Title')
141
147
  );
142
- console.log(chalk.gray('─'.repeat(70)));
148
+ console.log(chalk.gray('─'.repeat(ruleWidth)));
143
149
 
144
150
  for (const spec of specs) {
145
151
  const statusColor = {
@@ -152,13 +158,13 @@ export async function specListCommand(options = {}) {
152
158
 
153
159
  console.log(
154
160
  spec.id.slice(0, 34).padEnd(35) +
155
- statusColor(spec.status.padEnd(12)) +
156
- spec.type.padEnd(10) +
161
+ statusColor(statusLabel(spec).padEnd(statusWidth)) +
162
+ (spec.type ?? '-').padEnd(10) +
157
163
  spec.title.slice(0, 25)
158
164
  );
159
165
  }
160
166
 
161
- console.log(chalk.gray('─'.repeat(70)));
167
+ console.log(chalk.gray('─'.repeat(ruleWidth)));
162
168
  console.log(chalk.gray(`${t('spec.total', 'Total')}: ${specs.length}`));
163
169
  }
164
170
 
@@ -333,7 +339,7 @@ export function specSearchCommand(query, options = {}) {
333
339
 
334
340
  console.log(chalk.bold(`\nFound ${results.length} spec(s) matching "${query}":\n`));
335
341
  for (const r of results) {
336
- const badge = r.source === 'archive' ? chalk.gray('[archived]') : chalk.green(`[${r.status}]`);
342
+ const badge = r.source === 'archive' ? chalk.gray('[archived]') : chalk.green(`[${r.status ?? t('spec.statusUnparsed', 'format: SDD (status not parsed)')}]`);
337
343
  console.log(` ${chalk.cyan(r.id)} ${badge} ${r.title}`);
338
344
  }
339
345
  console.log();