universal-dev-standards 6.13.0-beta.2 → 6.13.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,6 +45,7 @@ import { t, setLanguage, isLanguageExplicitlySet } from '../i18n/messages.js';
45
45
  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
+ import { checkPreCommitHookWiring } from '../utils/git-hooks.js';
48
49
 
49
50
  /**
50
51
  * Display the summary of file integrity status
@@ -509,6 +510,9 @@ export async function checkCommand(options = {}) {
509
510
  // 錯誤訊息單一出口閘門是否已安裝(只報告,不寫入)
510
511
  checkErrorExitGate(projectPath);
511
512
 
513
+ // pre-commit 檢查檔存在,但 git 實際不會執行它(只報告,不寫入 —— 見 checkPreCommitWiring 下方註解)
514
+ checkPreCommitWiring(projectPath, msg);
515
+
512
516
  // Workflow status
513
517
  displayWorkflowStatus(projectPath);
514
518
 
@@ -1252,6 +1256,81 @@ function checkErrorExitGate(projectPath) {
1252
1256
  console.log();
1253
1257
  }
1254
1258
 
1259
+ /**
1260
+ * pre-commit 檢查檔存在,但 git 實際不會執行它:偵測並報告,絕不寫入。
1261
+ *
1262
+ * 🔴 起因:`uds init` 會寫 `.husky/pre-commit`(或非 Node 專案的
1263
+ * `.git/hooks/pre-commit`),但過去從未確認 git 真的會執行它——它依賴 husky
1264
+ * 自己的 bootstrap(`npm install` 觸發 `prepare` script 設定
1265
+ * `core.hooksPath`),而那個時機點如果 `node_modules` 已存在就永遠不會再發生。
1266
+ * 2026-09-26 實測三個既有採用者(asiaostrich-telemetry-server、
1267
+ * asiaostrich-telemetry-client、machine-setup):三者都有呼叫
1268
+ * `npx uds check` 的 `.husky/pre-commit`,但 `core.hooksPath` 皆未設定,
1269
+ * 提交時檢查從未跑過,且沒有任何錯誤訊息——這正是這道檢查要補上的訊號。
1270
+ *
1271
+ * 只報告不寫入的理由與 checkErrorExitGate 相同:`uds check` 不是使用者同意我們
1272
+ * 動他 git 設定的時刻;真要修,`uds init`(新 clone/尚未跑過)或使用者自己
1273
+ * 手動下指令(既有 clone)才是合適的落筆點。
1274
+ *
1275
+ * 🔴 刻意不影響 `allGood` / `--ci` 的 exit code:這是一個既有裝置的健康度警告
1276
+ * (類似 checkErrorExitGate、checkFullCoverageCompliance 的既有慣例),不是
1277
+ * 標準本身的落差,翻動 exit code 會讓不相關的 CI pipeline 因為一個提交前檢查
1278
+ * 的本機設定而失敗,而那個設定本來就是 per-clone、CI 環境通常另有一套。
1279
+ */
1280
+ export function checkPreCommitWiring(projectPath, msg) {
1281
+ const result = checkPreCommitHookWiring(projectPath);
1282
+ if (!result.relevant) return; // 沒有 UDS 管理的 hook
1283
+
1284
+ if (result.wired) {
1285
+ // 🔴 「已確認會執行」在 POSIX 上為真,在 Windows 上不一定——git for
1286
+ // Windows 沒有 POSIX 的 ENOEXEC → /bin/sh 後備機制,缺 shebang 的 hook
1287
+ // 每次 commit 都會失敗,訊息卻指向 hook 檔本身
1288
+ // (`cannot spawn <file>: No such file or directory`),2026-09-27 實測
1289
+ // 於 CI windows-latest。這與「wiring」是兩個獨立的缺陷面,有各自的旗標。
1290
+ if (result.missingShebang) {
1291
+ console.log(chalk.yellow((msg.hookMissingShebangTitle || '⚠ [pre-commit] {file} has no shebang line — git cannot run it on Windows.')
1292
+ .replace('{file}', result.hookFile)));
1293
+ console.log(chalk.gray((msg.hookMissingShebangFix || '').replace(/\{file\}/g, result.hookFile)));
1294
+ console.log();
1295
+ }
1296
+ return; // 已確認會執行——wiring 本身安靜通過
1297
+ }
1298
+
1299
+ console.log(chalk.yellow((msg.hookNotWiredTitle || '⚠ [pre-commit] {file} was installed, but git will not run it.')
1300
+ .replace('{file}', result.hookFile)));
1301
+
1302
+ if (result.configuredHooksPath) {
1303
+ const key = result.hookFile === '.git/hooks/pre-commit' ? 'hookNotWiredFixNative' : 'hookNotWiredOverride';
1304
+ console.log(chalk.gray((msg[key] || '').replace('{path}', result.configuredHooksPath)));
1305
+ // 🔴 legacy 舊範本即使在 override 分支也要提醒——一旦使用者照上面那行改用
1306
+ // .husky,同一個 `_/husky.sh` 陷阱一樣會炸。絕不能只在「非 override」分支講。
1307
+ if (result.legacyV8) {
1308
+ console.log(chalk.gray((msg.hookNotWiredLegacyV8Fix || '').replace(/\{file\}/g, result.hookFile)));
1309
+ }
1310
+ } else if (result.legacyV8) {
1311
+ // 🔴 這是 2026-09-27 的實測教訓:舊 husky v8 範本(含 `_/husky.sh` source
1312
+ // 那一行)若只給「設定 core.hooksPath」這個修法,使用者照做後 git 會直接
1313
+ // 執行這個檔案、卡死在那一行、每次 commit 都失敗——比原本的缺陷更糟。
1314
+ // 這裡絕不能退化成只印 hookNotWiredFix;一定要用把「先刪行、再設定」
1315
+ // 兩步講完整的版本。`uds init` 對已初始化專案會直接拒絕執行,修不了這個,
1316
+ // 所以這裡的文字必須自己講完整,不能叫使用者去跑別的指令。
1317
+ console.log(chalk.gray((msg.hookNotWiredFixLegacy || '').replace(/\{file\}/g, result.hookFile)));
1318
+ } else {
1319
+ console.log(chalk.gray((msg.hookNotWiredUnwired || '').replace('{file}', result.hookFile)));
1320
+ console.log(chalk.gray(msg.hookNotWiredFix || ''));
1321
+ }
1322
+
1323
+ // Independent of wiring — a hook can be fully wired for commit and still
1324
+ // fail every commit on Windows if it has no shebang (see the `wired`
1325
+ // branch above for why). Say so here too so fixing wiring alone does not
1326
+ // look like a complete fix.
1327
+ if (result.missingShebang) {
1328
+ console.log(chalk.gray((msg.hookMissingShebangFix || '').replace(/\{file\}/g, result.hookFile)));
1329
+ }
1330
+
1331
+ console.log();
1332
+ }
1333
+
1255
1334
  /**
1256
1335
  * XSPEC-178: Check full-coverage-testing standard presence and STUB markers
1257
1336
  */
@@ -28,6 +28,7 @@ import { guardAgainstSelfAdoption } from '../utils/detect-self-adoption.js';
28
28
  import { readInstallYaml } from '../utils/config-manager.js';
29
29
  import { resolveIntegrationTargetFile } from '../utils/integration-generator.js';
30
30
  import { withFileTransaction } from '../utils/transaction.js';
31
+ import { wireGitHooksPath, getLocalHooksPathConfig, stripLegacyHuskyShLine, ensureShebang } from '../utils/git-hooks.js';
31
32
 
32
33
  /**
33
34
  * Init command - initialize standards in current project
@@ -292,6 +293,11 @@ export async function initCommand(options) {
292
293
  const codexResult = installCodexHooks(projectPath);
293
294
  if (codexResult.installed) {
294
295
  console.log(chalk.green(' ✓ Codex Stop hook installed (turn-completion-integrity)'));
296
+ // Measured 2026-09-28 (codex-cli 0.155.1): Codex skips a project hook
297
+ // until the project is trusted AND that exact hook definition is
298
+ // trusted via /hooks — silently under `codex exec`. Installed is not
299
+ // running; say so here, where the adopter believes it now works.
300
+ 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. Until then it is skipped (silently under `codex exec`).'));
295
301
  } else {
296
302
  console.log(chalk.yellow(` ⚠ Codex hook not installed — ${codexResult.reason}`));
297
303
  }
@@ -300,7 +306,7 @@ export async function initCommand(options) {
300
306
  const { installGeminiHooks } = await import('../installers/hooks-installer.js');
301
307
  const geminiResult = installGeminiHooks(projectPath);
302
308
  if (geminiResult.installed) {
303
- console.log(chalk.green(' ✓ Gemini CLI AfterAgent hook installed (turn-completion-integrity)'));
309
+ console.log(chalk.green(' ✓ Gemini CLI AfterAgent hook installed (turn-completion-integrity; Gemini CLI is legacy — see the standard)'));
304
310
  } else {
305
311
  console.log(chalk.yellow(` ⚠ Gemini CLI hook not installed — ${geminiResult.reason}`));
306
312
  }
@@ -339,32 +345,42 @@ export async function setupHuskyHook(projectPath, { allowInTest = false } = {})
339
345
  const isNodeProject = existsSync(join(projectPath, 'package.json'));
340
346
 
341
347
  if (isNodeProject) {
342
- console.log(chalk.cyan('Configuring Pre-commit Hook (Husky)...'));
348
+ console.log(chalk.cyan('Configuring Pre-commit Hook...'));
343
349
 
344
350
  // Every edit we make to the adopter's package.json, reported at the end.
345
351
  // `uds init` writes ~70 files; a one-line change to package.json is invisible
346
352
  // in that diff unless we say it out loud (XSPEC-341 R1).
347
353
  const pkgChanges = [];
354
+ const pkgPath = join(projectPath, 'package.json');
348
355
 
349
- // 1. Install husky if needed
356
+ // 1. Do NOT install husky, and do NOT touch package.json's dependencies.
357
+ //
358
+ // This used to run `npm install --save-dev husky` here. Installing a
359
+ // package for the adopter is not this command's call to make, and — the
360
+ // actual bug this fix addresses — the wiring that install produced only
361
+ // took effect the NEXT time `npm install` ran husky's own `prepare`
362
+ // script. If node_modules already existed, that install never ran again,
363
+ // and the hook this function writes below was never executed by git.
364
+ // Verified against three real adopters (asiaostrich-telemetry-server,
365
+ // asiaostrich-telemetry-client, machine-setup, 2026-09-26): all three
366
+ // have `.husky/pre-commit` calling `npx uds check`, none has
367
+ // `core.hooksPath` set, and the check has never once run on commit.
368
+ //
369
+ // Whether husky is installed is the adopter's own decision. Step 5 below
370
+ // wires git directly and works with or without it.
371
+ let hasHusky = false;
350
372
  try {
351
- const pkgPath = join(projectPath, 'package.json');
352
373
  const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
353
- const hasHusky = pkg.devDependencies?.husky || pkg.dependencies?.husky;
354
-
355
- if (!hasHusky) {
356
- console.log(chalk.gray(' Installing husky...'));
357
- // stdio: 'pipe' rather than 'ignore' — the error text belongs in the
358
- // message below, not in /dev/null.
359
- execSync('npm install --save-dev husky', { stdio: 'pipe', cwd: projectPath });
360
- pkgChanges.push('devDependencies.husky — added');
361
- }
374
+ hasHusky = Boolean(pkg.devDependencies?.husky || pkg.dependencies?.husky);
362
375
  } catch (e) {
363
- console.log(chalk.yellow(` ⚠ Failed to check/install husky: ${e.message}`));
364
- return;
376
+ console.log(chalk.yellow(` ⚠ Failed to read package.json: ${e.message}`));
365
377
  }
366
378
 
367
- // 2. Wire husky's `prepare` script ourselves.
379
+ // 2. If the adopter already depends on husky, also chain its `prepare`
380
+ // script so a future `npm install` keeps husky's own wiring in sync too.
381
+ // This is belt-and-suspenders — step 5 wires git directly regardless of
382
+ // whether this succeeds — kept only because an adopter who already uses
383
+ // husky should not have `npm install` silently stop maintaining it.
368
384
  //
369
385
  // We deliberately do NOT run `npx husky init` (XSPEC-341 R1). That command is a
370
386
  // one-time bootstrap for a NEW project, not an idempotent operation: it sets
@@ -375,30 +391,31 @@ export async function setupHuskyHook(projectPath, { allowInTest = false } = {})
375
391
  // (It also seeds .husky/pre-commit with `npm test`, a gate the adopter never asked
376
392
  // for.) Adopting a standards library must never rewrite the adopter's build.
377
393
  const huskyDir = join(projectPath, '.husky');
378
- try {
379
- const pkgPath = join(projectPath, 'package.json');
380
- const raw = readFileSync(pkgPath, 'utf-8');
381
- const pkg = JSON.parse(raw);
382
- pkg.scripts = pkg.scripts || {};
383
- const existing = pkg.scripts.prepare;
384
-
385
- if (!existing) {
386
- pkg.scripts.prepare = 'husky';
387
- pkgChanges.push('scripts.prepare — added: "husky"');
388
- } else if (!/\bhusky\b/.test(existing)) {
389
- // Chain, never clobber. The adopter's command runs first and keeps its
390
- // exit code meaningful.
391
- pkg.scripts.prepare = `${existing} && husky`;
392
- pkgChanges.push(`scripts.prepare — "${existing}" → "${pkg.scripts.prepare}"`);
393
- }
394
+ if (hasHusky) {
395
+ try {
396
+ const raw = readFileSync(pkgPath, 'utf-8');
397
+ const pkg = JSON.parse(raw);
398
+ pkg.scripts = pkg.scripts || {};
399
+ const existing = pkg.scripts.prepare;
400
+
401
+ if (!existing) {
402
+ pkg.scripts.prepare = 'husky';
403
+ pkgChanges.push('scripts.prepare — added: "husky"');
404
+ } else if (!/\bhusky\b/.test(existing)) {
405
+ // Chain, never clobber. The adopter's command runs first and keeps its
406
+ // exit code meaningful.
407
+ pkg.scripts.prepare = `${existing} && husky`;
408
+ pkgChanges.push(`scripts.prepare — "${existing}" → "${pkg.scripts.prepare}"`);
409
+ }
394
410
 
395
- if (pkg.scripts.prepare !== existing) {
396
- // Preserve the file's trailing newline convention.
397
- const indent = raw.match(/^\{\n(\s+)"/)?.[1]?.length ?? 2;
398
- writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + (raw.endsWith('\n') ? '\n' : ''), 'utf-8');
411
+ if (pkg.scripts.prepare !== existing) {
412
+ // Preserve the file's trailing newline convention.
413
+ const indent = raw.match(/^\{\n(\s+)"/)?.[1]?.length ?? 2;
414
+ writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + (raw.endsWith('\n') ? '\n' : ''), 'utf-8');
415
+ }
416
+ } catch (e) {
417
+ console.log(chalk.yellow(` ⚠ Failed to configure the prepare script: ${e.message}`));
399
418
  }
400
- } catch (e) {
401
- console.log(chalk.yellow(` ⚠ Failed to configure the prepare script: ${e.message}`));
402
419
  }
403
420
 
404
421
  // 3. Ensure .husky directory exists
@@ -411,34 +428,97 @@ export async function setupHuskyHook(projectPath, { allowInTest = false } = {})
411
428
  }
412
429
  }
413
430
 
414
- // 4. Add pre-commit hook
431
+ // 4. Add pre-commit hook content
415
432
  const preCommitPath = join(huskyDir, 'pre-commit');
416
433
  const udsCmd = 'npx uds check';
417
434
 
418
435
  try {
419
- // husky v9 hooks are plain shell scripts: no shebang, no `_/husky.sh` sourcing
420
- // (that is v8 syntax, deprecated in v9 and removed in v10). We install husky
421
- // ^9, so a fresh hook must be v9-shaped. Existing files are appended to, never
422
- // rewritten — their contents are the adopter's, not ours.
423
- const content = existsSync(preCommitPath) ? readFileSync(preCommitPath, 'utf-8') : '';
424
-
425
- if (!content.includes('uds check')) {
436
+ // husky v9's own templates carry no shebang, no `_/husky.sh` sourcing
437
+ // (that is v8 syntax, deprecated in v9 and removed in v10). Verified
438
+ // empirically (2026-09-26, macOS): git executes a hook file with no
439
+ // shebang directly and correctly propagates its exit code, once it is
440
+ // on git's hooks path — see step 5.
441
+ //
442
+ // 🔴 That verification did not cover Windows, and Windows behaves
443
+ // differently: POSIX git falls back to `/bin/sh` on ENOEXEC (a script
444
+ // with no shebang) — that fallback is why the shebang-less shape above
445
+ // has always worked on macOS and Linux. Git for Windows has no such
446
+ // fallback and fails EVERY commit with `error: cannot spawn
447
+ // <hookfile>: No such file or directory` (measured 2026-09-27 in CI,
448
+ // windows-latest). So a shebang is added below regardless of platform
449
+ // — cheap, harmless on POSIX, and required on Windows. Existing files
450
+ // are appended to, never rewritten — their contents are the adopter's,
451
+ // not ours; ensureShebang only ever prepends a missing first line.
452
+ let content = existsSync(preCommitPath) ? readFileSync(preCommitPath, 'utf-8') : '';
453
+
454
+ // A pre-existing file may still carry husky v8's `_/husky.sh` sourcing
455
+ // line (adopted before v9, or before this fix). That line references a
456
+ // directory (`.husky/_/`) that only exists after husky's OWN bootstrap
457
+ // has run — but step 5 below wires `core.hooksPath` straight at
458
+ // `.husky`, so git executes THIS FILE directly. Left in place, that
459
+ // line would make every commit fail with "No such file or directory" —
460
+ // strictly worse than the original defect (verified against a real
461
+ // adopter's exact legacy template, 2026-09-27). Rewrite it away rather
462
+ // than appending alongside it; everything else — the adopter's own
463
+ // commands, an existing `uds check` line — is preserved as-is.
464
+ const { content: destripped, removed: hadLegacyLine } = stripLegacyHuskyShLine(content);
465
+ content = destripped;
466
+
467
+ const needsAppend = !content.includes('uds check');
468
+ if (needsAppend) {
426
469
  const sep = content && !content.endsWith('\n') ? '\n' : '';
427
- writeFileSync(preCommitPath, `${content}${sep}\n# UDS Standard Check\n${udsCmd}\n`, 'utf-8');
470
+ content = `${content}${sep}\n# UDS Standard Check\n${udsCmd}\n`;
471
+ }
472
+
473
+ const { content: shebanged, added: addedShebang } = ensureShebang(content);
474
+ content = shebanged;
475
+
476
+ if (hadLegacyLine || needsAppend || addedShebang) {
477
+ writeFileSync(preCommitPath, content, 'utf-8');
428
478
  try {
429
479
  execSync(`chmod +x ${preCommitPath}`);
430
480
  } catch {
431
481
  // Ignore chmod failures on systems that don't support it
432
482
  }
483
+ }
484
+
485
+ if (hadLegacyLine) {
486
+ console.log(chalk.yellow(' ⚠ Rewrote legacy husky v8 template: removed `_/husky.sh` sourcing (that directory only exists after husky\'s own bootstrap runs; git now executes this file directly, so that line would have failed every commit).'));
487
+ }
488
+ if (addedShebang) {
489
+ console.log(chalk.yellow(' ⚠ Added a missing #!/bin/sh shebang: without it, git cannot execute this hook on Windows.'));
490
+ }
491
+ if (needsAppend) {
433
492
  console.log(chalk.green(' ✓ Adding uds check to pre-commit hook'));
434
- } else {
493
+ } else if (!hadLegacyLine && !addedShebang) {
435
494
  console.log(chalk.gray(' ✓ Pre-commit hook already configured'));
436
495
  }
437
496
  } catch (e) {
438
497
  console.log(chalk.red(` ✗ Failed to configure pre-commit hook: ${e.message}`));
439
498
  }
440
499
 
441
- // 5. Say what we changed in their package.json.
500
+ // 5. Wire git so the hook ACTUALLY runs — this is the fix. Setting
501
+ // `core.hooksPath` ourselves is what husky's own bootstrap does internally
502
+ // (verified against husky ^9.1.7's source: `git config core.hooksPath
503
+ // <dir>/_`, plus a shim under `_/` forwarding to the real script); doing
504
+ // it directly means the check is live immediately after `uds init`,
505
+ // whether or not husky is installed or `npm install` ever runs again.
506
+ // Never overrides an adopter's own `core.hooksPath`, or an existing
507
+ // native `.git/hooks/pre-commit` (see wireGitHooksPath).
508
+ const wireResult = wireGitHooksPath(projectPath, '.husky');
509
+ if (wireResult.wired) {
510
+ console.log(chalk.green(' ✓ Pre-commit check is active for this clone (git core.hooksPath → .husky)'));
511
+ } else {
512
+ console.log(chalk.yellow(` ⚠ Pre-commit check NOT enabled: ${wireResult.reason}`));
513
+ console.log(chalk.gray(` ${wireResult.hint}`));
514
+ }
515
+ // `core.hooksPath` is LOCAL git config — it is never committed. This wiring
516
+ // only applies to this clone; `uds check` reports the gap for anyone who
517
+ // clones the repo without re-running this step (see
518
+ // checkPreCommitHookWiring in git-hooks.js / check.js).
519
+ console.log(chalk.gray(' Note: this is per-clone (git config is not committed) — teammates need to run `uds init` (or the fix above) in their own clone too.'));
520
+
521
+ // 6. Say what we changed in their package.json.
442
522
  if (pkgChanges.length > 0) {
443
523
  console.log(chalk.cyan(' package.json modified:'));
444
524
  for (const change of pkgChanges) {
@@ -452,13 +532,34 @@ export async function setupHuskyHook(projectPath, { allowInTest = false } = {})
452
532
  const hookDir = join(projectPath, '.git', 'hooks');
453
533
  const hookPath = join(hookDir, 'pre-commit');
454
534
 
535
+ // git's default hooks directory is `.git/hooks` — but only when
536
+ // `core.hooksPath` is unset. If the adopter (or another tool) already
537
+ // points it elsewhere, writing here would produce a file git never looks
538
+ // at, and `uds init` would report success for a check that never runs.
539
+ const configuredHooksPath = getLocalHooksPathConfig(projectPath);
540
+ if (configuredHooksPath) {
541
+ console.log(chalk.yellow(` ⚠ Pre-commit check NOT enabled: git core.hooksPath is already set to "${configuredHooksPath}"`));
542
+ console.log(chalk.gray(' UDS writes to .git/hooks/pre-commit, but git will not look there while core.hooksPath points elsewhere.'));
543
+ console.log(chalk.gray(` Add "uds check" to a pre-commit hook under "${configuredHooksPath}" yourself, or: git config --local --unset core.hooksPath`));
544
+ console.log();
545
+ return;
546
+ }
547
+
455
548
  try {
456
549
  if (!existsSync(hookDir)) {
457
550
  mkdirSync(hookDir, { recursive: true });
458
551
  }
459
552
 
460
- if (existsSync(hookPath) && readFileSync(hookPath, 'utf-8').includes('uds check')) {
461
- console.log(chalk.gray(' ✓ Pre-commit hook already configured'));
553
+ if (existsSync(hookPath)) {
554
+ const existingContent = readFileSync(hookPath, 'utf-8');
555
+ if (existingContent.includes('uds check')) {
556
+ console.log(chalk.gray(' ✓ Pre-commit hook already configured'));
557
+ } else {
558
+ // Never clobber an adopter's own hook (this fix — it used to be
559
+ // overwritten unconditionally here).
560
+ console.log(chalk.yellow(' ⚠ Pre-commit check NOT enabled: .git/hooks/pre-commit already exists'));
561
+ console.log(chalk.gray(' UDS will not overwrite it. Add "uds check" to it yourself, or remove it and re-run `uds init`.'));
562
+ }
462
563
  } else {
463
564
  const hookContent = `#!/bin/sh
464
565
  # UDS pre-commit hook
@@ -872,6 +872,26 @@ export const messages = {
872
872
  commandsInstalledSuccess: 'Installed commands for {count} AI tools',
873
873
  // Read-only hint
874
874
  missingSkillsHint: 'Tip: Run `uds update` to install missing Skills/Commands',
875
+ // Pre-commit hook wiring (XSPEC: uds init writes a hook but never
876
+ // confirmed git would run it — this reports the gap, read-only)
877
+ hookNotWiredTitle: '⚠ [pre-commit] {file} was installed, but git will not run it.',
878
+ hookNotWiredOverride: ' git core.hooksPath is set to "{path}" — UDS will not override it. Confirm the hook there also runs `npx uds check`, or switch it yourself: git config --local core.hooksPath .husky',
879
+ hookNotWiredUnwired: ' git core.hooksPath is not set, and {file} is not on git\'s default hook path.',
880
+ hookNotWiredFix: ' Fix (per-clone — not committed, teammates must repeat it): git config --local core.hooksPath .husky',
881
+ hookNotWiredFixNative: ' Fix: point core.hooksPath back to the default (git config --local --unset core.hooksPath), or add `uds check` under "{path}" instead.',
882
+ // Order matters here: setting hooksPath BEFORE removing the `_/husky.sh`
883
+ // line makes git execute {file} directly and fail on that line — verified
884
+ // against a real adopter's exact legacy template, 2026-09-27. `uds init`
885
+ // will not fix this for an already-initialized project (it refuses to run
886
+ // at all once `.standards/` exists), so the fix must be self-contained here.
887
+ hookNotWiredFixLegacy: ' Fix, in this exact order — this file still sources `_/husky.sh` (husky v8 syntax), a directory that only exists after husky\'s own bootstrap has run: (1) delete the line `. "$(dirname -- "$0")/_/husky.sh"` from {file}; (2) then run: git config --local core.hooksPath .husky (per-clone — not committed, teammates must repeat it). Doing (2) alone makes every commit fail with an error that `_/husky.sh` cannot be found ("No such file or directory" on macOS, ".: cannot open" on Linux).',
888
+ hookNotWiredLegacyV8Fix: ' Also: {file} still sources `_/husky.sh` (husky v8 syntax) — delete that line too, or the fix above will make every commit fail with an error that `_/husky.sh` cannot be found ("No such file or directory" on macOS, ".: cannot open" on Linux).',
889
+ // Missing shebang: independent of wiring — POSIX git falls back to
890
+ // /bin/sh on ENOEXEC (a hook with no shebang), git for Windows does
891
+ // not, and fails every commit with "cannot spawn {file}: No such
892
+ // file or directory". Measured 2026-09-27 in CI (windows-latest).
893
+ hookMissingShebangTitle: '⚠ [pre-commit] {file} has no shebang line — git cannot run it on Windows.',
894
+ hookMissingShebangFix: ' Fix: add a `#!/bin/sh` shebang as the very first line of {file} (a husky-managed hook gets this automatically the next time `uds init` touches it), or re-run `uds init`.',
875
895
  // Summary mode (--summary)
876
896
  summary_mode: {
877
897
  title: 'UDS Status Summary',
@@ -2112,6 +2132,24 @@ export const messages = {
2112
2132
  commandsInstalledSuccess: '已為 {count} 個 AI 工具安裝斜線命令',
2113
2133
  // Read-only hint
2114
2134
  missingSkillsHint: '提示:執行 `uds update` 安裝缺少的 Skills/斜線命令',
2135
+ // 提交前檢查是否真的會被 git 執行(uds init 寫了檢查檔,卻沒確認 git 會跑它——這裡只回報,不寫入)
2136
+ hookNotWiredTitle: '⚠ [pre-commit] {file} 已安裝,但 git 實際不會執行它。',
2137
+ hookNotWiredOverride: ' git core.hooksPath 已設定為「{path}」——UDS 不會覆蓋它。請確認該路徑下的檔案也會執行 `npx uds check`,或自行改用:git config --local core.hooksPath .husky',
2138
+ hookNotWiredUnwired: ' git core.hooksPath 未設定,而 {file} 也不在 git 預設會讀取的路徑上。',
2139
+ hookNotWiredFix: ' 修復方式(僅對此 clone 生效,不會進版控,其他人 clone 後要自己再跑一次):git config --local core.hooksPath .husky',
2140
+ hookNotWiredFixNative: ' 修復方式:把 core.hooksPath 改回預設(git config --local --unset core.hooksPath),或改在「{path}」底下也加上 `uds check`。',
2141
+ // 順序不可顛倒:先設 hooksPath 再刪那一行,會讓 git 直接執行 {file} 並卡在
2142
+ // `_/husky.sh` 那一行(2026-09-26 已在真實採用者的舊範本上實測到)。
2143
+ // `uds init` 對已初始化的專案會直接拒絕執行,修不了這個,所以這裡要給
2144
+ // 一次就講完整、不需要再跑任何指令的修法。
2145
+ hookNotWiredFixLegacy: ' 修復方式,順序不可顛倒——這個檔案還留著 `_/husky.sh`(husky v8 舊語法),它 source 的目錄只有在 husky 自己的 bootstrap 跑過後才存在:(1) 先刪掉 {file} 裡的這一行:`. "$(dirname -- "$0")/_/husky.sh"`;(2) 再執行:git config --local core.hooksPath .husky(僅對此 clone 生效,不會進版控,其他人要自己再做一次)。只做 (2) 不做 (1) 會讓每一次提交都失敗,印出找不到 `_/husky.sh` 的錯誤(macOS 為「No such file or directory」、Linux 為「.: cannot open」)。',
2146
+ hookNotWiredLegacyV8Fix: ' 另外:{file} 還留著 `_/husky.sh`(husky v8 舊語法)——這一行也要刪掉,不然上面的修復方式會讓每一次提交都失敗,印出找不到 `_/husky.sh` 的錯誤(macOS 為「No such file or directory」、Linux 為「.: cannot open」)。',
2147
+ // 缺少 shebang:與 wiring 無關——POSIX git 在 ENOEXEC(hook 沒有 shebang)
2148
+ // 時會退回用 /bin/sh 執行,git for Windows 沒有這個後備機制,每次提交
2149
+ // 都會失敗,訊息是「cannot spawn {file}: No such file or directory」。
2150
+ // 2026-09-27 於 CI(windows-latest)實測。
2151
+ hookMissingShebangTitle: '⚠ [pre-commit] {file} 沒有 shebang 行——在 Windows 上 git 無法執行它。',
2152
+ hookMissingShebangFix: ' 修復方式:在 {file} 的第一行加上 shebang `#!/bin/sh`(由 husky 管理的 hook,下次 `uds init` 動到它時會自動處理),或重新執行 `uds init`。',
2115
2153
  // Summary mode (--summary)
2116
2154
  summary_mode: {
2117
2155
  title: 'UDS 狀態摘要',
@@ -3364,6 +3402,20 @@ export const messages = {
3364
3402
  commandsInstalledSuccess: '已为 {count} 个 AI 工具安装斜线命令',
3365
3403
  // Read-only hint
3366
3404
  missingSkillsHint: '提示:执行 `uds update` 安装缺少的 Skills/斜线命令',
3405
+ // 提交前检查是否真的会被 git 执行(uds init 写了检查文件,却没确认 git 会跑它——这里只回报,不写入)
3406
+ hookNotWiredTitle: '⚠ [pre-commit] {file} 已安装,但 git 实际不会执行它。',
3407
+ hookNotWiredOverride: ' git core.hooksPath 已设定为“{path}”——UDS 不会覆盖它。请确认该路径下的文件也会执行 `npx uds check`,或自行改用:git config --local core.hooksPath .husky',
3408
+ hookNotWiredUnwired: ' git core.hooksPath 未设定,而 {file} 也不在 git 默认会读取的路径上。',
3409
+ hookNotWiredFix: ' 修复方式(仅对此 clone 生效,不会进版控,其他人 clone 后要自己再跑一次):git config --local core.hooksPath .husky',
3410
+ hookNotWiredFixNative: ' 修复方式:把 core.hooksPath 改回默认(git config --local --unset core.hooksPath),或改在“{path}”下也加上 `uds check`。',
3411
+ hookNotWiredFixLegacy: ' 修复方式,顺序不可颠倒——这个文件还留着 `_/husky.sh`(husky v8 旧语法),它 source 的目录只有在 husky 自己的 bootstrap 跑过后才存在:(1) 先删掉 {file} 里的这一行:`. "$(dirname -- "$0")/_/husky.sh"`;(2) 再执行:git config --local core.hooksPath .husky(仅对此 clone 生效,不会进版控,其他人要自己再做一次)。只做 (2) 不做 (1) 会让每一次提交都失败,打印找不到 `_/husky.sh` 的错误(macOS 为“No such file or directory”、Linux 为“.: cannot open”)。',
3412
+ hookNotWiredLegacyV8Fix: ' 另外:{file} 还留着 `_/husky.sh`(husky v8 旧语法)——这一行也要删掉,不然上面的修复方式会让每一次提交都失败,打印找不到 `_/husky.sh` 的错误(macOS 为“No such file or directory”、Linux 为“.: cannot open”)。',
3413
+ // 缺少 shebang:与 wiring 无关——POSIX git 在 ENOEXEC(hook 没有 shebang)
3414
+ // 时会回退用 /bin/sh 执行,git for Windows 没有这个后备机制,每次提交
3415
+ // 都会失败,消息是“cannot spawn {file}: No such file or directory”。
3416
+ // 2026-09-27 于 CI(windows-latest)实测。
3417
+ hookMissingShebangTitle: '⚠ [pre-commit] {file} 没有 shebang 行——在 Windows 上 git 无法执行它。',
3418
+ hookMissingShebangFix: ' 修复方式:在 {file} 的第一行加上 shebang `#!/bin/sh`(由 husky 管理的 hook,下次 `uds init` 动到它时会自动处理),或重新运行 `uds init`。',
3367
3419
  // Summary mode (--summary)
3368
3420
  summary_mode: {
3369
3421
  title: 'UDS 状态摘要',