universal-dev-standards 6.14.0 → 6.14.1-beta.2

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.
@@ -58,7 +58,7 @@ import {
58
58
  import { getMarketplaceSkillsInfo } from '../utils/github.js';
59
59
  import { printSkillNameCollisionWarning } from '../utils/skill-name-collision.js';
60
60
  import { detectAITools } from '../utils/detector.js';
61
- import { HOOK_CAPABLE_TOOLS, resolveHookTools, installMissingHooks } from '../installers/hooks-installer.js';
61
+ import { HOOK_CAPABLE_TOOLS, resolveHookTools, installMissingHooks, staleHookScripts } from '../installers/hooks-installer.js';
62
62
  import { persistRecorder, mergeRecorderInto, newRecorder } from '../core/install-records.js';
63
63
  import { installGateScripts, gateStandardInstalled, GATE_SCRIPTS } from '../utils/gate-scripts.js';
64
64
  import { migrateLegacyHuskyHook, migrateHuskyBlockWithoutCi, migrateOlderNativeHook } from '../utils/legacy-hook-migration.js';
@@ -431,6 +431,19 @@ export async function updateCommand(options) {
431
431
  console.log(chalk.bold(msg.title));
432
432
  console.log(chalk.gray('─'.repeat(50)));
433
433
 
434
+ // Hook scripts are not part of what this command (or --apply, --force, --plan) reconciles; only
435
+ // `--with-hooks` replaces them. Say so when one is out of date, because the symptom of an old
436
+ // script is a hook that quietly does not do what the new version does (6.14.1-beta.1: the
437
+ // dangerous-command hook that never blocked).
438
+ if (!options.withHooks && !options.rollback) {
439
+ const stale = staleHookScripts(projectPath);
440
+ if (stale.length) {
441
+ console.log(chalk.yellow(` ! ${stale.length} hook script(s) in scripts/hooks/ are unmodified copies of an older UDS and are NOT updated by this command: ${stale.slice(0, 5).map((x) => x.path).join(', ')}${stale.length > 5 ? ', ...' : ''}`));
442
+ console.log(chalk.gray(' Replace them with: uds update --with-hooks (add --plan first to see what changes)'));
443
+ console.log();
444
+ }
445
+ }
446
+
434
447
  // XSPEC-458 R3: `--add-standard <id>` (repeatable) picks standards UDS ships and this project lacks.
435
448
  // Judged here, before any mode runs, so an unknown id stops everything instead of being skipped.
436
449
  const addStandardIds = [].concat(options.addStandard || []);
@@ -551,20 +564,15 @@ export async function updateCommand(options) {
551
564
  return;
552
565
  }
553
566
  await handleReconcile(projectPath, options, { force: !!options.force, addStandards });
554
- // These exit the process on completion, so run Skills last.
555
- if (scopedToCommands) await updateCommandsOnly(projectPath, manifest, options);
556
- if (scopedToSkills) await updateSkillsOnly(projectPath, manifest, options);
567
+ // A single scope exits the process on completion; two are chained and exit once.
568
+ await runScopes(projectPath, manifest, options, { skills: scopedToSkills, commands: scopedToCommands });
557
569
  return;
558
570
  }
559
571
 
560
- // Scope without a mode: the original shortcuts.
561
- if (scopedToSkills) {
562
- await updateSkillsOnly(projectPath, manifest, options);
563
- return;
564
- }
565
-
566
- if (scopedToCommands) {
567
- await updateCommandsOnly(projectPath, manifest, options);
572
+ // Scope without a mode: the original shortcuts. Both flags mean both scopes —
573
+ // neither may be dropped for the other (the 6.14.0 bug).
574
+ if (scopedToSkills || scopedToCommands) {
575
+ await runScopes(projectPath, manifest, options, { skills: scopedToSkills, commands: scopedToCommands });
568
576
  return;
569
577
  }
570
578
 
@@ -2058,9 +2066,27 @@ export async function updateHooksOnly(projectPath, manifest, options = {}) {
2058
2066
  else if (r.outcome === 'unchanged') console.log(chalk.gray(` · ${r.tool}: already installed, not touched — ${rel}`));
2059
2067
  else { failed = true; console.log(chalk.yellow(` ⚠ ${r.tool}: not installed — ${r.why}`)); }
2060
2068
  }
2061
- const installedAny = results.some((r) => r.outcome === 'installed' || r.outcome === 'would-install');
2062
- if (installedAny && scripts.kept.length) {
2063
- console.log(chalk.yellow(` ! ${scripts.kept.length} hook script(s) in scripts/hooks/ differ from this UDS version and were kept: ${scripts.kept.slice(0, 5).join(', ')}${scripts.kept.length > 5 ? ', ...' : ''}`));
2069
+ // Scripts are judged apart from the hook config: a config that is already there says nothing about
2070
+ // whether the script beside it is current (6.14.1-beta.1 shipped a security fix to exactly such a script).
2071
+ const fmt = (list) => `${list.slice(0, 5).join(', ')}${list.length > 5 ? ', ...' : ''}`;
2072
+ // A plan reports what is measured; a real run reports only what the installer says it WROTE
2073
+ // (`replaced`), never what it measured — so a refresh that did nothing cannot print "replaced".
2074
+ const sinceOf = new Map((scripts.stale ?? []).map((x) => [x.path, x.since]));
2075
+ const stale = (options.plan ? (scripts.stale ?? []).map((x) => x.path) : (scripts.replaced ?? []));
2076
+ if (stale.length) {
2077
+ const named = fmt(stale.map((p) => `${p} (unmodified copy from UDS ${sinceOf.get(p)})`));
2078
+ if (options.plan) console.log(chalk.cyan(` + would replace ${stale.length} out-of-date hook script(s) in scripts/hooks/: ${named}`));
2079
+ else console.log(chalk.green(` ✓ replaced ${stale.length} out-of-date hook script(s) in scripts/hooks/: ${named}`));
2080
+ }
2081
+ const overwritten = options.plan ? (options.force ? scripts.kept : []) : (scripts.overwritten ?? []);
2082
+ if (overwritten.length) {
2083
+ if (options.plan) console.log(chalk.cyan(` + --force would overwrite ${overwritten.length} edited hook script(s): ${fmt(overwritten)}`));
2084
+ else console.log(chalk.yellow(` ! --force: overwrote ${overwritten.length} edited hook script(s) with the shipped version: ${fmt(overwritten)}`));
2085
+ }
2086
+ const kept = options.plan && options.force ? [] : scripts.kept;
2087
+ if (kept.length) {
2088
+ console.log(chalk.yellow(` ! ${kept.length} hook script(s) in scripts/hooks/ differ from this UDS version and ${options.plan ? 'would be' : 'were'} kept: ${fmt(kept)}`));
2089
+ console.log(chalk.gray(' They match no copy UDS ever shipped, so they look edited (or are not UDS\'s). An edited script does not receive fixes made to the shipped one.'));
2064
2090
  console.log(chalk.gray(' Add --force to overwrite them with the shipped versions.'));
2065
2091
  }
2066
2092
  if (results.some((r) => r.tool === 'antigravity' && r.outcome === 'installed')) {
@@ -2069,7 +2095,7 @@ export async function updateHooksOnly(projectPath, manifest, options = {}) {
2069
2095
  if (results.some((r) => r.tool === 'codex' && r.outcome === 'installed')) {
2070
2096
  console.log(chalk.yellow(' ⚠ Codex will not run it until you trust it: open Codex in this project, trust the project, then run /hooks and trust this hook.'));
2071
2097
  }
2072
- if (!results.some((r) => r.outcome === 'installed' || r.outcome === 'would-install')) {
2098
+ if (!results.some((r) => r.outcome === 'installed' || r.outcome === 'would-install') && !stale.length && !overwritten.length) {
2073
2099
  console.log(chalk.gray(' Nothing to add.'));
2074
2100
  }
2075
2101
  console.log();
@@ -2835,7 +2861,45 @@ async function skillActionsOf(projectPath) {
2835
2861
  return plan.actions.filter((a) => a.category === 'skill');
2836
2862
  }
2837
2863
 
2838
- async function updateSkillsOnly(projectPath, manifest, options) {
2864
+ /**
2865
+ * How one scope step (Skills or commands) ends.
2866
+ *
2867
+ * Alone, it ends the process, as it always did. When `--skills` and `--commands` come
2868
+ * together the other scope still has to run, so it hands its exit code back instead and
2869
+ * {@link runScopes} ends the process once, with the worse code of the two.
2870
+ * (Found 2026-10-27 on Windows: `--skills --commands` ran one scope, exited 0 and said
2871
+ * nothing about the other. The same two axes XSPEC-372 R1/R2 separated, one level down.)
2872
+ * @param {number} code - 0 on success, non-zero on failure
2873
+ * @param {boolean} chained - true when another scope runs after this one
2874
+ * @returns {number} the code, so a caller can `return endScope(...)`
2875
+ */
2876
+ function endScope(code, chained) {
2877
+ if (!chained) process.exit(code);
2878
+ return code;
2879
+ }
2880
+
2881
+ /**
2882
+ * Run the scope steps the flags name. One scope runs exactly as before (it exits the
2883
+ * process itself). Both run in a fixed order, each printing its own section, and the
2884
+ * process ends with the worst code: any failure is non-zero, and so is a failure the
2885
+ * reconciler already recorded in `process.exitCode` (`--apply`).
2886
+ * @param {string} projectPath
2887
+ * @param {Object} manifest
2888
+ * @param {Object} options
2889
+ * @param {{skills: boolean, commands: boolean}} scopes
2890
+ */
2891
+ async function runScopes(projectPath, manifest, options, { skills, commands }) {
2892
+ if (skills && commands) {
2893
+ const skillsCode = await updateSkillsOnly(projectPath, manifest, options, { chained: true });
2894
+ const commandsCode = await updateCommandsOnly(projectPath, manifest, options, { chained: true });
2895
+ process.exit(Math.max(skillsCode, commandsCode, Number(process.exitCode) || 0));
2896
+ return;
2897
+ }
2898
+ if (skills) await updateSkillsOnly(projectPath, manifest, options);
2899
+ if (commands) await updateCommandsOnly(projectPath, manifest, options);
2900
+ }
2901
+
2902
+ async function updateSkillsOnly(projectPath, manifest, options, { chained = false } = {}) {
2839
2903
  const msg = t().commands.update;
2840
2904
  const repoInfo = getRepositoryInfo();
2841
2905
  const latestVersion = repoInfo.skills.version;
@@ -2897,8 +2961,7 @@ async function updateSkillsOnly(projectPath, manifest, options) {
2897
2961
  console.log(chalk.yellow(msg.skillsViaMarketplace || 'Skills installed via Marketplace'));
2898
2962
  console.log(chalk.gray(` ${msg.updateViaMarketplace || 'Update through Plugin Marketplace'}`));
2899
2963
  console.log();
2900
- process.exit(0);
2901
- return;
2964
+ return endScope(0, chained);
2902
2965
  }
2903
2966
  }
2904
2967
  }
@@ -2907,8 +2970,7 @@ async function updateSkillsOnly(projectPath, manifest, options) {
2907
2970
  console.log(chalk.yellow(msg.noSkillsInstalled || 'No Skills installations found'));
2908
2971
  console.log(chalk.gray(` ${msg.runInitToInstall || 'Run uds init to install Skills'}`));
2909
2972
  console.log();
2910
- process.exit(0);
2911
- return;
2973
+ return endScope(0, chained);
2912
2974
  }
2913
2975
 
2914
2976
  // Show current status
@@ -2938,8 +3000,7 @@ async function updateSkillsOnly(projectPath, manifest, options) {
2938
3000
  if (fileBasedInstallations.length === 0) {
2939
3001
  console.log(chalk.green(msg.allSkillsUpToDate || 'All Skills are up to date'));
2940
3002
  console.log();
2941
- process.exit(0);
2942
- return;
3003
+ return endScope(0, chained);
2943
3004
  }
2944
3005
 
2945
3006
  // XSPEC-454 R1: this step writes outside the reconciler, so it takes its own rollback point — the skill
@@ -2948,8 +3009,7 @@ async function updateSkillsOnly(projectPath, manifest, options) {
2948
3009
  // No backup, no write: an install that cannot be undone must not start.
2949
3010
  const skillsBackup = takeStepBackup(projectPath, 'skills', fileBasedInstallations, 'skills');
2950
3011
  if (!skillsBackup.ok) {
2951
- process.exit(1);
2952
- return;
3012
+ return endScope(1, chained);
2953
3013
  }
2954
3014
 
2955
3015
  const spinner = createSpinner(msg.installingSkills || 'Installing Skills...').start();
@@ -3036,7 +3096,7 @@ async function updateSkillsOnly(projectPath, manifest, options) {
3036
3096
  // XSPEC-465 R1: a personal skill with the same name as one of the UDS skills just written wins silently.
3037
3097
  // Information only: it does not change what was installed or the exit code.
3038
3098
  printSkillNameCollisionWarning(projectPath);
3039
- process.exit(0);
3099
+ return endScope(0, chained);
3040
3100
  }
3041
3101
 
3042
3102
  /**
@@ -3045,7 +3105,7 @@ async function updateSkillsOnly(projectPath, manifest, options) {
3045
3105
  * @param {Object} manifest - Manifest object
3046
3106
  * @param {Object} [options] - CLI options (forwarded for locale resolution)
3047
3107
  */
3048
- async function updateCommandsOnly(projectPath, manifest, options) {
3108
+ async function updateCommandsOnly(projectPath, manifest, options, { chained = false } = {}) {
3049
3109
  const msg = t().commands.update;
3050
3110
 
3051
3111
  console.log(chalk.cyan(msg.updatingCommandsOnly || 'Updating slash commands for all AI Agents...'));
@@ -3072,8 +3132,7 @@ async function updateCommandsOnly(projectPath, manifest, options) {
3072
3132
  console.log(chalk.yellow(msg.noCommandsInstalled || 'No slash commands installations found'));
3073
3133
  console.log(chalk.gray(` ${msg.runInitToInstall || 'Run uds init to install commands'}`));
3074
3134
  console.log();
3075
- process.exit(0);
3076
- return;
3135
+ return endScope(0, chained);
3077
3136
  }
3078
3137
 
3079
3138
  // Show current status
@@ -3095,8 +3154,7 @@ async function updateCommandsOnly(projectPath, manifest, options) {
3095
3154
  // XSPEC-454 R1: same as the Skills step — a rollback point first, and no write without one.
3096
3155
  const commandsBackup = takeStepBackup(projectPath, 'commands', commandsInstallations, 'commands');
3097
3156
  if (!commandsBackup.ok) {
3098
- process.exit(1);
3099
- return;
3157
+ return endScope(1, chained);
3100
3158
  }
3101
3159
 
3102
3160
  const spinner = createSpinner(msg.installingCommands || 'Installing commands...').start();
@@ -3182,7 +3240,7 @@ async function updateCommandsOnly(projectPath, manifest, options) {
3182
3240
  finishStepBackup(projectPath, commandsBackup);
3183
3241
 
3184
3242
  console.log();
3185
- process.exit(0);
3243
+ return endScope(0, chained);
3186
3244
  }
3187
3245
 
3188
3246
  /**
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Which hook-script contents did UDS itself ship in the past?
3
+ *
4
+ * `uds update --with-hooks` must tell two different things apart when a script in
5
+ * `<project>/scripts/hooks/` differs from the version in this package:
6
+ *
7
+ * - an OLD UDS copy nobody touched -> safe to replace with the new one
8
+ * - a copy the adopter EDITED -> must be kept (it may carry their changes)
9
+ *
10
+ * A byte-for-byte match against a script some earlier UDS release shipped is the only
11
+ * evidence of the first kind. The table lives in `hook-script-fingerprints.json`,
12
+ * produced from the git tags by `scripts/generate-hook-fingerprints.mjs` — never typed
13
+ * by hand — and `tests/unit/hooks/hook-script-fingerprints.test.js` fails the moment a
14
+ * script under `scripts/hooks/` has a content the table does not know.
15
+ *
16
+ * Keyed by path as well as by hash: a file shipped under one name does not make the
17
+ * same bytes "UDS's" under another.
18
+ *
19
+ * Node built-ins only. The generator in the repo root imports this file, and the CI
20
+ * jobs that run root scripts install no packages (see
21
+ * tests/e2e/root-scripts-need-no-cli-packages.test.js).
22
+ *
23
+ * @module installers/hook-script-fingerprint
24
+ */
25
+
26
+ import { createHash } from 'node:crypto';
27
+ import { readFileSync } from 'node:fs';
28
+ import { dirname, join } from 'node:path';
29
+ import { fileURLToPath } from 'node:url';
30
+
31
+ export const FINGERPRINT_FILE = join(dirname(fileURLToPath(import.meta.url)), 'hook-script-fingerprints.json');
32
+
33
+ /**
34
+ * sha256 of the script with CRLF folded to LF.
35
+ *
36
+ * A project that commits `scripts/hooks/` on Windows with `core.autocrlf=true` has the
37
+ * same script with different line endings; that is not an edit. Folding is done on a
38
+ * latin1 view so no byte is reinterpreted.
39
+ *
40
+ * @param {Buffer} buf
41
+ * @returns {string} 64 hex chars
42
+ */
43
+ export function hashHookScript(buf) {
44
+ const folded = Buffer.from(buf.toString('latin1').replace(/\r\n/g, '\n'), 'latin1');
45
+ return createHash('sha256').update(folded).digest('hex');
46
+ }
47
+
48
+ /**
49
+ * @returns {{ scripts: Record<string, Record<string, string>> }} path -> { sha256 -> first release that shipped it }
50
+ */
51
+ export function loadFingerprints(file = FINGERPRINT_FILE) {
52
+ const parsed = JSON.parse(readFileSync(file, 'utf-8'));
53
+ return { scripts: parsed.scripts ?? {} };
54
+ }
55
+
56
+ /**
57
+ * Is `buf` exactly a copy of `relPath` that an earlier UDS shipped?
58
+ *
59
+ * @param {string} relPath path under scripts/hooks, with `/` separators
60
+ * @param {Buffer} buf the project's copy
61
+ * @param {{ scripts: Record<string, Record<string, string>> }} [table]
62
+ * @returns {{ since: string } | null} `since` = first release that shipped this content
63
+ */
64
+ export function shippedBefore(relPath, buf, table = loadFingerprints()) {
65
+ const known = table.scripts[relPath];
66
+ if (!known) return null;
67
+ const since = known[hashHookScript(buf)];
68
+ return since ? { since } : null;
69
+ }
@@ -0,0 +1,76 @@
1
+ {
2
+ "_about": "Generated by scripts/generate-hook-fingerprints.mjs from git tags. Do not edit by hand. Append-only: sha256 of each hook script content UDS has shipped (CRLF folded to LF), with the first release that carried it.",
3
+ "scripts": {
4
+ "check-dangerous-cmd.js": {
5
+ "7cc865f4dd09c88899b939e170b953ee97d5aa3e0502769e47b7f8732f30bddb": "v5.1.0-beta.5"
6
+ },
7
+ "check-dangerous-cmd.mjs": {
8
+ "b18d6eb63c073679ce599821ebd0d95b7f276ca8fbcf60dc2d961e5b053ad053": "v6.9.0",
9
+ "0813a859c5b26cb7d13fab5d9dec9212c9fb946aeb9d2d0595b817fd21e08ae8": "v6.14.1-beta.1"
10
+ },
11
+ "check-logging-standard.js": {
12
+ "435b7d937da791499924ef64f6de601e90a442b3a1e10783925cfafe5de4b7ab": "v5.1.0-beta.5"
13
+ },
14
+ "check-logging-standard.mjs": {
15
+ "af5f3f7efa7d9f0ffa199b76c823772473c9d26743e02169373e9f09839ca3bd": "v6.9.0",
16
+ "d7cef4d1c10a919884baf1e5825e92a14b22ca0ebb13c9a758e297ff6046fa2d": "v6.14.1-beta.1"
17
+ },
18
+ "check-turn-completion-agy.mjs": {
19
+ "082e1e7493d00be881c6ec15155883494bbc1aa24f99845ec25a2daf48e82579": "v6.14.0-beta.1"
20
+ },
21
+ "check-turn-completion-codex.mjs": {
22
+ "ec6ba6bb181304b925b76b65a11c37380a24c787c8954a66692522bfc1d5e6db": "v6.13.0-beta.1",
23
+ "503657443b6d069d77ac9a57e170ee75289d7ee763833847f1d523013dadba0f": "v6.13.0-beta.2"
24
+ },
25
+ "check-turn-completion-gemini.mjs": {
26
+ "6dd7455613516966ed233b9c2000ec25394dfc7bacb3d307bc0c4418539f11d8": "v6.13.0-beta.1"
27
+ },
28
+ "check-turn-completion.mjs": {
29
+ "05cb5afdf104a32049c45e663a95e5294889a14421aff1a7ff3b45fd6451e355": "v6.9.0",
30
+ "acb8a858a1266342c6b5e6c81870ea545024774b9f2548a153ce7f9eca77918c": "v6.13.0-beta.1",
31
+ "789a530867920d14432da95da2db64753eee730785711fd85668dd3758694933": "v6.13.0-beta.5"
32
+ },
33
+ "inject-standards.js": {
34
+ "1403a37dd8de000a56efc2ee7365d2961ad2d996c661c8fcdffc12fcb0344f93": "v5.0.0-rc.6",
35
+ "ef0eec1d99f9287c15f6cf47f37a22dc4238a401d05c2ae6fbc9cda437ec18b4": "v5.1.0-beta.4",
36
+ "c8c5bf56dacb341efe0fdf1d2e084b015ac30ec374767ebee3354350b500e939": "v5.1.0-beta.5",
37
+ "fdd5f30fc1352e9b89da9d6a6a5de1b2c18efbac27f970ef1a78a01a80a1168b": "v6.0.0"
38
+ },
39
+ "inject-standards.mjs": {
40
+ "fdd5f30fc1352e9b89da9d6a6a5de1b2c18efbac27f970ef1a78a01a80a1168b": "v6.9.0"
41
+ },
42
+ "telemetry-wrapper.js": {
43
+ "cfa203e3552d9d03b5bc183bb8298aa21f1affca9b25059a1ff06ad59178f538": "v5.1.0-beta.5"
44
+ },
45
+ "telemetry-wrapper.mjs": {
46
+ "cfa203e3552d9d03b5bc183bb8298aa21f1affca9b25059a1ff06ad59178f538": "v6.9.0"
47
+ },
48
+ "turn-completion/detect.mjs": {
49
+ "40e084f6863165b8e200abf18381ffe15dc33d7d5de68b3d7d0761c32890159b": "v6.9.0"
50
+ },
51
+ "turn-completion/engine.mjs": {
52
+ "ab8c6a5ca864b4b38d347f8bd5d5b476a125c98371c16712a8db757078a7bbd8": "v6.13.0-beta.1",
53
+ "1ad9aa9faa9f81c0fd2eae5c426d226fc1cac5d872245f875ae847ac1b16e33d": "v6.13.0-beta.4"
54
+ },
55
+ "turn-completion/locales/en.mjs": {
56
+ "be2baa01821958d4207c57a43b162740e808f482112ceebff54867d6adec6552": "v6.9.0",
57
+ "00534557520151bc2406a3dbba7361884318005a9cbf4c7cdccd590dfcfe177b": "v6.13.0-beta.1",
58
+ "12c4cb76ee77f8a9c3aa41518469baeb386f0dfaf3cf30de30c7bb8fe9549d56": "v6.13.0-beta.2",
59
+ "eb2a730340189d9fdeccc7b387cd2347ace46ab7f277d93370f1243636df8e00": "v6.14.0-beta.2"
60
+ },
61
+ "turn-completion/locales/zh-TW.mjs": {
62
+ "f5a7025642b62b12f7adbe75fa76b88b0d539b7cb88978b7aca03d5aad036609": "v6.9.0",
63
+ "9d93e7c9a1e61163e718bbc041b8f0956890fec78c7dce8da024a1d9b107d4ea": "v6.13.0-beta.1",
64
+ "712c6a59fadc70c1309513eba8cab6dad3447caebb1e9f696c261f3a686fce54": "v6.13.0-beta.2",
65
+ "b7e756a475403accf6b96f1a534d9334c38ced082b328ee751f52a1a22ed95b4": "v6.14.0-beta.2"
66
+ },
67
+ "validate-commit-msg.js": {
68
+ "e90182ee437da8f6f0420b341b06b8e546873a98ed09ecffd18ad6ac35fcef0e": "v5.1.0-beta.5"
69
+ },
70
+ "validate-commit-msg.mjs": {
71
+ "aca50fbdcd903d06eecf76abf4e213561e38fffde7b7617947f08e9b26e9d4d1": "v6.9.0",
72
+ "7afdaaddaf990f21ac607c67ed0798f536d69c3145c6bf4ff3dd813031dcf026": "v6.14.0-beta.13",
73
+ "bb5af4bdf49bb49d36951a5537fae894d4891146c159eed572e31cd527a9388e": "v6.14.1-beta.1"
74
+ }
75
+ }
76
+ }
@@ -38,6 +38,7 @@ import { execFileSync } from 'child_process';
38
38
  import { load as parseYaml } from 'js-yaml';
39
39
  import { detectAITools } from '../utils/detector.js';
40
40
  import { newRecorder, mkdirTracked, recordFile, RECORD_KINDS } from '../core/install-records.js';
41
+ import { shippedBefore, loadFingerprints } from './hook-script-fingerprint.js';
41
42
 
42
43
  const __dirname = dirname(fileURLToPath(import.meta.url));
43
44
 
@@ -564,18 +565,37 @@ export function hookStatus(projectPath, tool) {
564
565
  return { status: 'blocked', path: '', why: `no hook installer for ${tool}` };
565
566
  }
566
567
 
567
- /** Hook scripts UDS ships vs what the project already has: how many are new, identical, or edited. */
568
+ /**
569
+ * Hook scripts UDS ships vs what the project already has, measured before anything is copied.
570
+ *
571
+ * added not in the project yet
572
+ * identical byte-for-byte the shipped one
573
+ * stale differs, but is exactly a copy some EARLIER UDS shipped (nobody edited it):
574
+ * [{ path, since }] — safe to replace
575
+ * kept differs and matches nothing UDS ever shipped, so it was edited (or is not ours):
576
+ * [path] — left alone unless `--force`
577
+ *
578
+ * 🔴 Why `stale` exists (2026-10-29): this used to be a single "differs -> kept" bucket, and it was
579
+ * only consulted when a hook config had to be written. A project whose config was already present
580
+ * never reached the copy at all, so the 6.14.1-beta.1 fix to check-dangerous-cmd.mjs (exit 2
581
+ * instead of a non-blocking exit 1) never arrived by any `uds update` form. "Differs" alone cannot
582
+ * separate an old UDS copy from an adopter's edit; only a match against what UDS shipped can.
583
+ */
568
584
  function scriptDiff(projectPath) {
569
585
  const src = hooksSourceDir();
570
- const out = { added: 0, identical: 0, kept: [] };
586
+ const out = { added: 0, identical: 0, stale: [], kept: [] };
571
587
  if (!src) return out;
588
+ const table = loadFingerprints();
572
589
  const walk = (dir, rel = '') => {
573
590
  for (const e of readdirSync(dir, { withFileTypes: true })) {
574
591
  const r = rel ? `${rel}/${e.name}` : e.name;
575
592
  if (e.isDirectory()) { walk(join(dir, e.name), r); continue; }
576
593
  const dest = join(projectPath, 'scripts', 'hooks', r);
577
- if (!existsSync(dest)) out.added++;
578
- else if (readFileSync(dest).equals(readFileSync(join(dir, e.name)))) out.identical++;
594
+ if (!existsSync(dest)) { out.added++; continue; }
595
+ const have = readFileSync(dest);
596
+ if (have.equals(readFileSync(join(dir, e.name)))) { out.identical++; continue; }
597
+ const old = shippedBefore(r, have, table);
598
+ if (old) out.stale.push({ path: r, since: old.since });
579
599
  else out.kept.push(r);
580
600
  }
581
601
  };
@@ -583,6 +603,50 @@ function scriptDiff(projectPath) {
583
603
  return out;
584
604
  }
585
605
 
606
+ /**
607
+ * Put the shipped version of a script that is already in the project, whatever the hook
608
+ * config looks like. Runs for a tool whose config is `present` too — that is the point.
609
+ *
610
+ * stale scripts (an unmodified older UDS copy) -> always replaced
611
+ * kept scripts (edited) -> replaced only with `force`
612
+ *
613
+ * Mutates `scripts` so the caller reports what actually happened: replaced / overwritten are
614
+ * the paths written, and `kept` is what is still left alone.
615
+ */
616
+ function refreshScripts(projectPath, scripts, { recorder, force = false } = {}) {
617
+ const src = hooksSourceDir();
618
+ if (!src) return;
619
+ const write = (rel) => {
620
+ const dest = join(projectPath, 'scripts', 'hooks', rel);
621
+ copyFileSync(join(src, rel), dest);
622
+ recordFile(recorder, projectPath, relative(projectPath, dest), RECORD_KINDS.HOOK_SCRIPT);
623
+ };
624
+ scripts.replaced = scripts.stale.map((s) => s.path);
625
+ for (const rel of scripts.replaced) write(rel);
626
+ scripts.overwritten = [];
627
+ if (force) {
628
+ scripts.overwritten = scripts.kept;
629
+ scripts.kept = [];
630
+ for (const rel of scripts.overwritten) write(rel);
631
+ }
632
+ }
633
+
634
+ /**
635
+ * Scripts in the project that are unmodified copies of an EARLIER UDS version. Read-only.
636
+ * Lets the other `uds update` forms (which do not manage hook scripts) say so instead of
637
+ * leaving the adopter to find out from a hook that never fires.
638
+ *
639
+ * @returns {Array<{ path: string, since: string }>}
640
+ */
641
+ export function staleHookScripts(projectPath) {
642
+ // Advisory only: a notice about scripts must never be the reason `uds update` itself fails.
643
+ try {
644
+ return scriptDiff(projectPath).stale;
645
+ } catch {
646
+ return [];
647
+ }
648
+ }
649
+
586
650
  const INSTALLERS = {
587
651
  'claude-code': (p, o) => installHooks(p, o),
588
652
  codex: (p, o) => installCodexHooks(p, o),
@@ -597,13 +661,18 @@ const INSTALLERS = {
597
661
  * - The adopter's own hooks are never touched: every installer merges (Claude,
598
662
  * Codex, Gemini) or writes only under the key UDS owns (agy).
599
663
  * - A hook script the project already has and that differs from this version is
600
- * KEPT unless `overwriteScripts` — it may have been edited. It is reported.
664
+ * REPLACED when it is exactly a copy an earlier UDS shipped (nobody edited it; see
665
+ * hook-script-fingerprint.js), and KEPT otherwise unless `overwriteScripts` — it may
666
+ * have been edited. This holds whether or not the tool's hook config is already
667
+ * present: "the config is there" says nothing about the script beside it.
601
668
  * - `plan: true` reads and reports, and writes nothing.
602
669
  *
603
670
  * @param {string} projectPath
604
671
  * @param {string[]} tools
605
672
  * @param {{ plan?: boolean, overwriteScripts?: boolean }} [opts]
606
- * @returns {{ results: Array<{tool:string, outcome:'installed'|'unchanged'|'would-install'|'blocked'|'failed', path:string, why?:string, repaired?:boolean}>, scripts: {added:number, identical:number, kept:string[]}, artifacts: object }}
673
+ * @returns {{ results: Array<{tool:string, outcome:'installed'|'unchanged'|'would-install'|'blocked'|'failed', path:string, why?:string, repaired?:boolean}>, scripts: {added:number, identical:number, stale:Array<{path:string, since:string}>, kept:string[], replaced?:string[], overwritten?:string[]}, artifacts: object }}
674
+ * `scripts.stale` / `scripts.kept` are measured before anything is written; with `plan` they are
675
+ * what WOULD be replaced / kept. Without `plan`, `replaced` / `overwritten` are what was written.
607
676
  * `artifacts` is the recorder of what this call wrote (see core/install-records.js);
608
677
  * the caller persists it into the manifest so `uds uninstall` can remove exactly that.
609
678
  */
@@ -620,5 +689,9 @@ export function installMissingHooks(projectPath, tools, { plan = false, overwrit
620
689
  if (r.installed) results.push({ tool, outcome: 'installed', path: r.settingsPath ?? st.path, repaired: st.status === 'stale' });
621
690
  else results.push({ tool, outcome: 'failed', path: r.settingsPath ?? st.path, why: r.reason ?? 'no standard produced a usable hook' });
622
691
  }
692
+ // The hook config being present (or absent) decides nothing about the scripts. Without this
693
+ // step an up-to-date config left an out-of-date, vulnerable script in place and reported
694
+ // "already installed, not touched".
695
+ if (!plan) refreshScripts(projectPath, scripts, { recorder, force: overwriteScripts });
623
696
  return { results, scripts, artifacts: recorder };
624
697
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "version": "6.14.0",
3
+ "version": "6.14.1-beta.2",
4
4
  "lastUpdated": "2026-05-13",
5
5
  "description": "Standards registry for universal-dev-standards with integrated skills and AI-optimized formats",
6
6
  "formats": {
@@ -58,14 +58,14 @@
58
58
  "standards": {
59
59
  "name": "universal-dev-standards",
60
60
  "url": "https://github.com/AsiaOstrich/universal-dev-standards",
61
- "version": "6.14.0"
61
+ "version": "6.14.1-beta.2"
62
62
  },
63
63
  "skills": {
64
64
  "name": "universal-dev-standards",
65
65
  "url": "https://github.com/AsiaOstrich/universal-dev-standards",
66
66
  "localPath": "skills",
67
67
  "rawUrl": "https://raw.githubusercontent.com/AsiaOstrich/universal-dev-standards/main/skills",
68
- "version": "6.14.0",
68
+ "version": "6.14.1-beta.2",
69
69
  "note": "Skills are now included in the main repository under skills/"
70
70
  }
71
71
  },
@@ -2336,7 +2336,7 @@
2336
2336
  "id": "license-compliance",
2337
2337
  "name": "License Compliance Standards",
2338
2338
  "nameZh": "授權合規標準",
2339
- "version": "6.14.0",
2339
+ "version": "6.14.1-beta.2",
2340
2340
  "source": {
2341
2341
  "human": "core/license-compliance.md",
2342
2342
  "ai": "ai/standards/license-compliance.ai.yaml"
@@ -2348,7 +2348,7 @@
2348
2348
  "id": "verification-oracle",
2349
2349
  "name": "Verification Oracle Standards",
2350
2350
  "nameZh": "驗證 Oracle 標準",
2351
- "version": "6.14.0",
2351
+ "version": "6.14.1-beta.2",
2352
2352
  "source": {
2353
2353
  "human": "core/verification-oracle.md",
2354
2354
  "ai": "ai/standards/verification-oracle.ai.yaml"
@@ -2360,7 +2360,7 @@
2360
2360
  "id": "model-provenance",
2361
2361
  "name": "Model Provenance Policy Standards",
2362
2362
  "nameZh": "模型來源政策標準",
2363
- "version": "6.14.0",
2363
+ "version": "6.14.1-beta.2",
2364
2364
  "source": {
2365
2365
  "human": "core/model-provenance.md",
2366
2366
  "ai": "ai/standards/model-provenance.ai.yaml"
@@ -2372,7 +2372,7 @@
2372
2372
  "id": "resource-cost-boundary",
2373
2373
  "name": "Resource / Cost Boundary Declaration Standards",
2374
2374
  "nameZh": "資源/成本邊界宣告標準",
2375
- "version": "6.14.0",
2375
+ "version": "6.14.1-beta.2",
2376
2376
  "source": {
2377
2377
  "human": "core/resource-cost-boundary.md",
2378
2378
  "ai": "ai/standards/resource-cost-boundary.ai.yaml"