universal-dev-standards 6.14.1 → 6.15.0-beta.1

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 (62) hide show
  1. package/bin/uds.js +2 -2
  2. package/bundled/ai/standards/developer-memory.ai.yaml +2 -2
  3. package/bundled/ai/standards/full-coverage-testing.ai.yaml +6 -4
  4. package/bundled/ai/standards/project-context-memory.ai.yaml +2 -2
  5. package/bundled/core/developer-memory.md +1 -1
  6. package/bundled/core/full-coverage-testing.md +4 -2
  7. package/bundled/core/open-work-tracking.md +13 -0
  8. package/bundled/core/project-context-memory.md +1 -1
  9. package/bundled/locales/COVERAGE.md +5 -4
  10. package/bundled/locales/zh-CN/CHANGELOG.md +49 -4
  11. package/bundled/locales/zh-CN/README.md +2 -2
  12. package/bundled/locales/zh-CN/SECURITY.md +1 -0
  13. package/bundled/locales/zh-CN/core/full-coverage-testing.md +5 -3
  14. package/bundled/locales/zh-CN/docs/AVAILABLE-STANDARDS.md +4 -4
  15. package/bundled/locales/zh-CN/docs/CHEATSHEET.md +1 -0
  16. package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +8 -3
  17. package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +5 -4
  18. package/bundled/locales/zh-CN/skills/README.md +2 -1
  19. package/bundled/locales/zh-CN/skills/commands/sdd-retro.md +1 -1
  20. package/bundled/locales/zh-CN/skills/dev-workflow-guide/SKILL.md +7 -7
  21. package/bundled/locales/zh-CN/skills/open-work-assistant/SKILL.md +133 -0
  22. package/bundled/locales/zh-TW/CHANGELOG.md +49 -4
  23. package/bundled/locales/zh-TW/README.md +2 -2
  24. package/bundled/locales/zh-TW/SECURITY.md +1 -0
  25. package/bundled/locales/zh-TW/core/developer-memory.md +3 -3
  26. package/bundled/locales/zh-TW/core/full-coverage-testing.md +5 -3
  27. package/bundled/locales/zh-TW/core/open-work-tracking.md +13 -2
  28. package/bundled/locales/zh-TW/core/project-context-memory.md +3 -3
  29. package/bundled/locales/zh-TW/docs/AVAILABLE-STANDARDS.md +4 -4
  30. package/bundled/locales/zh-TW/docs/CHEATSHEET.md +1 -0
  31. package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +8 -3
  32. package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +5 -4
  33. package/bundled/locales/zh-TW/skills/README.md +2 -1
  34. package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +7 -7
  35. package/bundled/locales/zh-TW/skills/open-work-assistant/SKILL.md +133 -0
  36. package/bundled/skills/README.md +2 -1
  37. package/bundled/skills/dev-workflow-guide/SKILL.md +4 -4
  38. package/bundled/skills/open-work-assistant/SKILL.md +127 -0
  39. package/bundled/templates/gates/check-anti-fake-tests.mjs +183 -23
  40. package/bundled/templates/gates/check-stubs.mjs +85 -16
  41. package/package.json +2 -2
  42. package/src/commands/audit.js +4 -1
  43. package/src/commands/check.js +55 -6
  44. package/src/commands/config.js +2 -3
  45. package/src/commands/init.js +10 -3
  46. package/src/commands/update.js +239 -43
  47. package/src/i18n/messages.js +87 -0
  48. package/src/installers/hooks-installer.js +32 -5
  49. package/src/installers/skills-installer.js +45 -0
  50. package/src/reconciler/backup-locations.js +3 -2
  51. package/src/reconciler/backup-manager.js +14 -11
  52. package/src/reconciler/plan-executor.js +51 -7
  53. package/src/utils/copier.js +13 -8
  54. package/src/utils/flush-and-exit.js +37 -0
  55. package/src/utils/group-errors.js +65 -0
  56. package/src/utils/integration-generator.js +14 -5
  57. package/src/utils/skill-hash-ownership.js +33 -0
  58. package/src/utils/skill-link-rewriter.js +184 -0
  59. package/src/utils/skills-installer.js +115 -11
  60. package/src/utils/transient-fs.js +168 -14
  61. package/standards-registry.json +10 -19
  62. package/bundled/ai/standards/open-work-tracking.ai.yaml +0 -466
@@ -22,6 +22,31 @@ export const messages = {
22
22
  disableHint: 'Set UDS_NO_UPDATE_CHECK=1 to disable'
23
23
  },
24
24
 
25
+ // Board #77 (XSPEC-516 follow-up): the two ways a file or folder step can fail for a reason that is not a bug -
26
+ // a short-lived lock, or a real permission problem. Used by src/utils/transient-fs.js; {placeholders} are filled there.
27
+ fsErrors: {
28
+ couldNot: {
29
+ copy: 'Could not copy "{source}" to "{path}"',
30
+ createFolder: 'Could not create the folder "{path}"',
31
+ generic: 'Could not {action} "{path}"'
32
+ },
33
+ what: { file: 'file', folder: 'folder' },
34
+ locked: '{lead}: the {what} is locked by another program ({code}). UDS tried {attempts} times over {seconds} s and the lock did not clear. ' +
35
+ 'Likely causes: antivirus real-time scanning, the Windows search indexer, a cloud-sync client (OneDrive, Dropbox) or an editor that has the file open. ' +
36
+ 'Close whatever is using the file or add the project folder to the antivirus exclusions, then run the command again. (Original error: {original})',
37
+ permissionDenied: '{lead}: permission denied ({code}). This looks like a permission problem rather than a temporary file lock. {tried}{found}' +
38
+ 'Check: {check} Fix the permission, then run the command again. (Original error: {original})',
39
+ permissionTried: 'UDS tried {attempts} times over {seconds} s and the error did not change. ',
40
+ permissionFound: 'UDS checked: {reason}. ',
41
+ checkFile: '(1) the file is not marked read-only; (2) your account may read the source and write the file and its folder (owner and permissions; on Windows, the Security tab of the folder); (3) the folder is not on a read-only drive or in a protected location.',
42
+ checkFolder: '(1) the folder, or the folder above it, is not marked read-only; (2) your account may create folders in the parent folder (owner and permissions; on Windows, the Security tab of the parent folder); (3) the parent folder is not on a read-only drive or in a protected location.',
43
+ reasons: {
44
+ sourceUnreadable: 'the source "{source}" cannot be opened for reading ({code})',
45
+ targetUnwritable: '"{path}" cannot be opened for writing ({code}): it is read-only or this account may not write it',
46
+ folderUnwritable: 'a file cannot be created in the folder "{folder}" ({code})',
47
+ folderCannotBeMade: 'a folder cannot be created inside "{folder}" ({code})'
48
+ }
49
+ },
25
50
  // XSPEC-458: standards UDS ships that this project does not have
26
51
  availableStandards: {
27
52
  title: 'Available upstream, not installed ({count})',
@@ -908,6 +933,8 @@ export const messages = {
908
933
  standardsIndexPresent: 'Standards index present',
909
934
  standardsIndexCount: 'Index declares {count} standards (matches manifest)',
910
935
  standardsIndexCountMismatch: 'Index declares {declared} standards but the manifest has {actual}',
936
+ agentsMdUnresolvedEntries: 'Manifest entries that match no installed standard ({count}), not counted above: {list}',
937
+ agentsMdUnresolvedFix: 'They were removed upstream or misspelled. `uds update` does not prune them: delete them from the "standards" list in .standards/manifest.json.',
911
938
  standardsReferenced: '{count}/{total} standards referenced',
912
939
  missingStandardsList: 'Missing: {list}',
913
940
  usingMinimalMode: 'Using minimal mode (no standards index)',
@@ -1068,6 +1095,8 @@ export const messages = {
1068
1095
  skillsLabel: 'Skills',
1069
1096
  skillsMarketplace: 'Plugin Marketplace (managed by Claude Code)',
1070
1097
  skillsFromPluginTitle: 'Skills: provided by the Claude Code plugin (no skill file was written to this project).',
1098
+ installErrorsAffectedAll: '-> {count} files affected: {names}',
1099
+ installErrorsAffectedFirst: '-> {count} files affected, the first {shown}: {names}',
1071
1100
  skillsSkippedTitle: 'Skills: none will be installed into this project.',
1072
1101
  skillsFromPluginLines: [
1073
1102
  'Install the plugin in Claude Code: /plugin marketplace add AsiaOstrich/universal-dev-standards, then /plugin install universal-dev-standards@asia-ostrich',
@@ -1429,6 +1458,31 @@ export const messages = {
1429
1458
  disableHint: '設定 UDS_NO_UPDATE_CHECK=1 可關閉'
1430
1459
  },
1431
1460
 
1461
+ // 看板 #77(XSPEC-516 後續):檔案或資料夾步驟失敗、但原因不是程式錯誤的兩種情況:短暫的檔案鎖,或真的權限不足。
1462
+ // 由 src/utils/transient-fs.js 使用;{placeholders} 在那裡填入。
1463
+ fsErrors: {
1464
+ couldNot: {
1465
+ copy: '無法複製「{source}」到「{path}」',
1466
+ createFolder: '無法建立資料夾「{path}」',
1467
+ generic: '無法{action}「{path}」'
1468
+ },
1469
+ what: { file: '檔案', folder: '資料夾' },
1470
+ locked: '{lead}:{what}被其他程式鎖住({code})。UDS 試了 {attempts} 次、共 {seconds} 秒,鎖都沒有解開。' +
1471
+ '可能的原因:防毒軟體即時掃描、Windows 搜尋索引、雲端同步軟體(OneDrive、Dropbox),或正開著這個檔案的編輯器。' +
1472
+ '請關掉正在使用它的程式,或把專案資料夾加入防毒軟體的排除清單,然後再執行一次指令。(原始錯誤:{original})',
1473
+ permissionDenied: '{lead}:權限不足({code})。這看起來是權限問題,不是暫時的檔案鎖定。{tried}{found}' +
1474
+ '請檢查:{check}修好權限後,再執行一次指令。(原始錯誤:{original})',
1475
+ permissionTried: 'UDS 試了 {attempts} 次、共 {seconds} 秒,錯誤都沒有變。',
1476
+ permissionFound: 'UDS 實際檢查的結果:{reason}。',
1477
+ checkFile: '(1)檔案沒有被設成唯讀;(2)你的帳號可以讀取來源,也可以寫入該檔案與它所在的資料夾(擁有者與權限;Windows 請看資料夾內容的「安全性」索引標籤);(3)該資料夾不在唯讀磁碟或受保護的位置。',
1478
+ checkFolder: '(1)該資料夾或它的上一層沒有被設成唯讀;(2)你的帳號可以在上一層資料夾裡建立資料夾(擁有者與權限;Windows 請看上一層資料夾內容的「安全性」索引標籤);(3)上一層不在唯讀磁碟或受保護的位置。',
1479
+ reasons: {
1480
+ sourceUnreadable: '來源「{source}」無法開啟讀取({code})',
1481
+ targetUnwritable: '「{path}」無法開啟寫入({code}):它是唯讀,或這個帳號沒有寫入權限',
1482
+ folderUnwritable: '無法在資料夾「{folder}」裡建立檔案({code})',
1483
+ folderCannotBeMade: '無法在資料夾「{folder}」裡建立資料夾({code})'
1484
+ }
1485
+ },
1432
1486
  // XSPEC-458:UDS 有出貨、這個專案沒有的標準
1433
1487
  availableStandards: {
1434
1488
  title: '上游有、專案沒裝({count} 個)',
@@ -2315,6 +2369,8 @@ export const messages = {
2315
2369
  standardsIndexPresent: '標準索引存在',
2316
2370
  standardsIndexCount: '索引宣告 {count} 條標準(與 manifest 一致)',
2317
2371
  standardsIndexCountMismatch: '索引宣告 {declared} 條標準,manifest 實際有 {actual} 條',
2372
+ agentsMdUnresolvedEntries: 'manifest 有 {count} 個條目無法對應到已安裝的標準,上面的數字沒有算入:{list}',
2373
+ agentsMdUnresolvedFix: '它們是上游已移除或拼錯的標準。`uds update` 不會清掉它們:請自 .standards/manifest.json 的 "standards" 清單刪除。',
2318
2374
  standardsReferenced: '{count}/{total} 項標準已參考',
2319
2375
  missingStandardsList: '缺少:{list}',
2320
2376
  usingMinimalMode: '使用最小模式(無標準索引)',
@@ -2473,6 +2529,8 @@ export const messages = {
2473
2529
  skillsLabel: 'Skills',
2474
2530
  skillsMarketplace: 'Plugin Marketplace(由 Claude Code 管理)',
2475
2531
  skillsFromPluginTitle: '技能:由 Claude Code 外掛提供(這個專案沒有寫入任何技能檔)。',
2532
+ installErrorsAffectedAll: '→ 影響 {count} 個檔案:{names}',
2533
+ installErrorsAffectedFirst: '→ 影響 {count} 個檔案,前 {shown} 個:{names}',
2476
2534
  skillsSkippedTitle: '技能:不會把任何技能裝進這個專案。',
2477
2535
  skillsFromPluginLines: [
2478
2536
  '在 Claude Code 安裝外掛:/plugin marketplace add AsiaOstrich/universal-dev-standards,再執行 /plugin install universal-dev-standards@asia-ostrich',
@@ -2829,6 +2887,31 @@ export const messages = {
2829
2887
  disableHint: '设置 UDS_NO_UPDATE_CHECK=1 可关闭'
2830
2888
  },
2831
2889
 
2890
+ // 看板 #77(XSPEC-516 后续):文件或文件夹步骤失败、但原因不是程序错误的两种情况:短暂的文件锁,或真的权限不足。
2891
+ // 由 src/utils/transient-fs.js 使用;{placeholders} 在那里填入。
2892
+ fsErrors: {
2893
+ couldNot: {
2894
+ copy: '无法复制“{source}”到“{path}”',
2895
+ createFolder: '无法创建文件夹“{path}”',
2896
+ generic: '无法{action}“{path}”'
2897
+ },
2898
+ what: { file: '文件', folder: '文件夹' },
2899
+ locked: '{lead}:{what}被其他程序锁定({code})。UDS 试了 {attempts} 次、共 {seconds} 秒,锁一直没有解开。' +
2900
+ '可能的原因:杀毒软件实时扫描、Windows 搜索索引、云同步软件(OneDrive、Dropbox),或正开着这个文件的编辑器。' +
2901
+ '请关掉正在使用它的程序,或把项目文件夹加入杀毒软件的排除列表,然后再运行一次命令。(原始错误:{original})',
2902
+ permissionDenied: '{lead}:权限不足({code})。这看起来是权限问题,不是暂时的文件锁定。{tried}{found}' +
2903
+ '请检查:{check}修好权限后,再运行一次命令。(原始错误:{original})',
2904
+ permissionTried: 'UDS 试了 {attempts} 次、共 {seconds} 秒,错误一直没有变。',
2905
+ permissionFound: 'UDS 实际检查的结果:{reason}。',
2906
+ checkFile: '(1)文件没有被设成只读;(2)你的账号可以读取来源,也可以写入该文件与它所在的文件夹(所有者与权限;Windows 请看文件夹属性里的“安全”选项卡);(3)该文件夹不在只读磁盘或受保护的位置。',
2907
+ checkFolder: '(1)该文件夹或它的上一层没有被设成只读;(2)你的账号可以在上一层文件夹里创建文件夹(所有者与权限;Windows 请看上一层文件夹属性里的“安全”选项卡);(3)上一层不在只读磁盘或受保护的位置。',
2908
+ reasons: {
2909
+ sourceUnreadable: '来源“{source}”无法打开读取({code})',
2910
+ targetUnwritable: '“{path}”无法打开写入({code}):它是只读,或这个账号没有写入权限',
2911
+ folderUnwritable: '无法在文件夹“{folder}”里创建文件({code})',
2912
+ folderCannotBeMade: '无法在文件夹“{folder}”里创建文件夹({code})'
2913
+ }
2914
+ },
2832
2915
  // XSPEC-458:UDS 有发布、这个项目没有的标准
2833
2916
  availableStandards: {
2834
2917
  title: '上游有、项目没装({count} 个)',
@@ -3539,6 +3622,8 @@ export const messages = {
3539
3622
  skillsLabel: 'Skills',
3540
3623
  skillsMarketplace: 'Plugin Marketplace(由 Claude Code 管理)',
3541
3624
  skillsFromPluginTitle: '技能:由 Claude Code 插件提供(这个项目没有写入任何技能文件)。',
3625
+ installErrorsAffectedAll: '→ 影响 {count} 个文件:{names}',
3626
+ installErrorsAffectedFirst: '→ 影响 {count} 个文件,前 {shown} 个:{names}',
3542
3627
  skillsSkippedTitle: '技能:不会把任何技能装进这个项目。',
3543
3628
  skillsFromPluginLines: [
3544
3629
  '在 Claude Code 安装插件:/plugin marketplace add AsiaOstrich/universal-dev-standards,再执行 /plugin install universal-dev-standards@asia-ostrich',
@@ -3741,6 +3826,8 @@ export const messages = {
3741
3826
  standardsIndexPresent: '标准索引存在',
3742
3827
  standardsIndexCount: '索引声明 {count} 条标准(与 manifest 一致)',
3743
3828
  standardsIndexCountMismatch: '索引声明 {declared} 条标准,manifest 实际有 {actual} 条',
3829
+ agentsMdUnresolvedEntries: 'manifest 有 {count} 个条目无法对应到已安装的标准,上面的数字没有计入:{list}',
3830
+ agentsMdUnresolvedFix: '它们是上游已移除或拼错的标准。`uds update` 不会清除它们:请从 .standards/manifest.json 的 "standards" 列表删除。',
3744
3831
  standardsReferenced: '已引用 {count}/{total} 项标准',
3745
3832
  missingStandardsList: '缺失:{list}',
3746
3833
  usingMinimalMode: '使用最小模式(无标准索引)',
@@ -581,9 +581,9 @@ export function hookStatus(projectPath, tool) {
581
581
  * instead of a non-blocking exit 1) never arrived by any `uds update` form. "Differs" alone cannot
582
582
  * separate an old UDS copy from an adopter's edit; only a match against what UDS shipped can.
583
583
  */
584
- function scriptDiff(projectPath) {
584
+ export function diffHookScripts(projectPath) {
585
585
  const src = hooksSourceDir();
586
- const out = { added: 0, identical: 0, stale: [], kept: [] };
586
+ const out = { added: 0, addedPaths: [], identical: 0, stale: [], kept: [] };
587
587
  if (!src) return out;
588
588
  const table = loadFingerprints();
589
589
  const walk = (dir, rel = '') => {
@@ -591,7 +591,7 @@ function scriptDiff(projectPath) {
591
591
  const r = rel ? `${rel}/${e.name}` : e.name;
592
592
  if (e.isDirectory()) { walk(join(dir, e.name), r); continue; }
593
593
  const dest = join(projectPath, 'scripts', 'hooks', r);
594
- if (!existsSync(dest)) { out.added++; continue; }
594
+ if (!existsSync(dest)) { out.added++; out.addedPaths.push(r); continue; }
595
595
  const have = readFileSync(dest);
596
596
  if (have.equals(readFileSync(join(dir, e.name)))) { out.identical++; continue; }
597
597
  const old = shippedBefore(r, have, table);
@@ -619,6 +619,11 @@ function refreshScripts(projectPath, scripts, { recorder, force = false } = {})
619
619
  const write = (rel) => {
620
620
  const dest = join(projectPath, 'scripts', 'hooks', rel);
621
621
  copyFileSync(join(src, rel), dest);
622
+ // Read it back: "copied" is a claim, the bytes on disk are the fact. A caller that holds a backup
623
+ // turns this throw into a restore, so a write that did not take can never be reported as replaced.
624
+ if (!readFileSync(dest).equals(readFileSync(join(src, rel)))) {
625
+ throw new Error(`scripts/hooks/${rel} does not match the shipped version after it was written`);
626
+ }
622
627
  recordFile(recorder, projectPath, relative(projectPath, dest), RECORD_KINDS.HOOK_SCRIPT);
623
628
  };
624
629
  scripts.replaced = scripts.stale.map((s) => s.path);
@@ -641,12 +646,34 @@ function refreshScripts(projectPath, scripts, { recorder, force = false } = {})
641
646
  export function staleHookScripts(projectPath) {
642
647
  // Advisory only: a notice about scripts must never be the reason `uds update` itself fails.
643
648
  try {
644
- return scriptDiff(projectPath).stale;
649
+ return diffHookScripts(projectPath).stale;
645
650
  } catch {
646
651
  return [];
647
652
  }
648
653
  }
649
654
 
655
+ /**
656
+ * Replace the hook scripts in the project that are unmodified copies of an EARLIER UDS, and nothing else.
657
+ *
658
+ * This is what the `uds update` forms that do not install hooks (`--apply`, plain `uds update`) use: no hook
659
+ * config is read or written, no script is added, an edited script is left alone (it comes back in
660
+ * `scripts.kept`). `plan: true` reads and reports, and writes nothing.
661
+ *
662
+ * It does not take a backup and does not catch a failed write: the caller owns the rollback point
663
+ * (see `withHookScriptBackup` in commands/update.js), because the backup has to be finalized after the
664
+ * manifest records are written, which only the caller knows.
665
+ *
666
+ * @param {string} projectPath
667
+ * @param {{ plan?: boolean, recorder?: object }} [opts]
668
+ * @returns {{ scripts: { stale: Array<{path:string, since:string}>, kept: string[], replaced?: string[], overwritten?: string[] }, artifacts: object }}
669
+ * @throws when a script cannot be written or does not read back equal to the shipped one
670
+ */
671
+ export function replaceStaleHookScripts(projectPath, { plan = false, recorder = newRecorder() } = {}) {
672
+ const scripts = diffHookScripts(projectPath);
673
+ if (!plan) refreshScripts(projectPath, scripts, { recorder, force: false });
674
+ return { scripts, artifacts: recorder };
675
+ }
676
+
650
677
  const INSTALLERS = {
651
678
  'claude-code': (p, o) => installHooks(p, o),
652
679
  codex: (p, o) => installCodexHooks(p, o),
@@ -678,7 +705,7 @@ const INSTALLERS = {
678
705
  */
679
706
  export function installMissingHooks(projectPath, tools, { plan = false, overwriteScripts = false, recorder = newRecorder() } = {}) {
680
707
  // Measured BEFORE anything is copied: afterwards every script would read "identical".
681
- const scripts = scriptDiff(projectPath);
708
+ const scripts = diffHookScripts(projectPath);
682
709
  const results = [];
683
710
  for (const tool of tools) {
684
711
  const st = hookStatus(projectPath, tool);
@@ -33,6 +33,7 @@ import {
33
33
  getCommandsDirForAgent
34
34
  } from '../config/ai-agent-paths.js';
35
35
  import { getRepositoryInfo } from '../utils/registry.js';
36
+ import { hasLocalSkillsSource } from '../utils/skills-source.js';
36
37
 
37
38
  /**
38
39
  * Print a single WARN block summarizing skills that fell back to the English
@@ -190,6 +191,50 @@ export async function installSkills(skillsConfig, projectPath, messages, results
190
191
  async function installSkillsLegacy(skillsConfig, projectPath, messages, results) {
191
192
  const skillSpinner = createSpinner(messages.installingSkills).start();
192
193
 
194
+ // With the skill texts on this machine (an npm install or a checkout: always, in practice), the legacy targets
195
+ // are installed by the same installer as every other path, into the folder this branch has always used
196
+ // (`.claude/skills/`, project or user level). A second way of writing skill files here would be a second copy
197
+ // of the rules for what an installed skill may contain (dev-platform #61: links that point outside the install).
198
+ // The remote download below stays for a machine that has no skill texts at all; it writes the files as the
199
+ // download returns them.
200
+ if (hasLocalSkillsSource()) {
201
+ let installedCount = 0;
202
+ let failedCount = 0;
203
+ for (const target of skillsConfig.updateTargets) {
204
+ const level = target === 'project' ? 'project' : 'user';
205
+ const installResult = await installSkillsToMultipleAgents(
206
+ [{ agent: 'claude-code', level }],
207
+ null,
208
+ level === 'project' ? projectPath : null,
209
+ skillsConfig.locale || 'en'
210
+ );
211
+ for (const agentResult of installResult.installations) {
212
+ for (const skillName of agentResult.installed) {
213
+ installedCount++;
214
+ if (!results.skills.includes(skillName)) results.skills.push(skillName);
215
+ }
216
+ for (const err of agentResult.errors) {
217
+ failedCount++;
218
+ results.errors.push(`Skill ${err.skill} (${target}): ${err.error}`);
219
+ }
220
+ }
221
+ if (installResult.allFileHashes) Object.assign(results.skillHashes, installResult.allFileHashes);
222
+ }
223
+ const where = skillsConfig.updateTargets.map(t =>
224
+ t === 'project' ? getProjectSkillsDir(projectPath) : getSkillsDir()
225
+ ).join(', ');
226
+ if (failedCount === 0) {
227
+ skillSpinner.succeed(messages.installedSkills
228
+ .replace('{count}', installedCount)
229
+ .replace('{locations}', where));
230
+ } else {
231
+ skillSpinner.warn(messages.installedSkillsWithErrors
232
+ .replace('{count}', installedCount)
233
+ .replace('{errors}', failedCount));
234
+ }
235
+ return;
236
+ }
237
+
193
238
  const skillFiles = getSkillFiles();
194
239
  let successCount = 0;
195
240
  let errorCount = 0;
@@ -10,8 +10,9 @@
10
10
  * @module reconciler/backup-locations
11
11
  */
12
12
 
13
- import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';
13
+ import { existsSync, readdirSync, writeFileSync } from 'fs';
14
14
  import { join } from 'path';
15
+ import { mkdirSyncRetrying } from '../utils/transient-fs.js';
15
16
 
16
17
  /** The one folder new backups go into. */
17
18
  export const BACKUPS_DIR = '.uds-backups';
@@ -49,7 +50,7 @@ export function newBackupId() {
49
50
  export function ensureBackupsDir(projectPath, errors) {
50
51
  const dir = join(projectPath, BACKUPS_DIR);
51
52
  try {
52
- mkdirSync(dir, { recursive: true });
53
+ mkdirSyncRetrying(dir);
53
54
  const ignoreFile = join(dir, '.gitignore');
54
55
  if (!existsSync(ignoreFile)) writeFileSync(ignoreFile, '*\n', 'utf8');
55
56
  } catch (err) {
@@ -35,8 +35,6 @@
35
35
 
36
36
  import {
37
37
  existsSync,
38
- mkdirSync,
39
- cpSync,
40
38
  lstatSync,
41
39
  readlinkSync,
42
40
  readFileSync,
@@ -46,6 +44,7 @@ import {
46
44
  rmdirSync
47
45
  } from 'fs';
48
46
  import { createHash } from 'crypto';
47
+ import { cpSyncRetrying, mkdirSyncRetrying } from '../utils/transient-fs.js';
49
48
  import { join, dirname, isAbsolute, sep } from 'path';
50
49
  import { newBackupId, ensureBackupsDir, sharedBackupIds, addLegacyBackupIds, isSharedBackupId } from './backup-locations.js';
51
50
 
@@ -85,7 +84,9 @@ function copyLeaf(src, dst) {
85
84
  } catch {
86
85
  // dst does not exist
87
86
  }
88
- cpSync(src, dst, { force: true, verbatimSymlinks: true });
87
+ // Retried on a short lock and worded as "permission denied" for a permission problem (board #77); a plain cpSync
88
+ // gave up on the first EBUSY and printed Node's bare text in "Failed to backup ...".
89
+ cpSyncRetrying(src, dst, { force: true, verbatimSymlinks: true });
89
90
  }
90
91
 
91
92
  /** Every file under `rel` (project-relative, posix). A file lists itself; a missing path lists nothing. */
@@ -154,7 +155,7 @@ function snapshot(projectPath, spec) {
154
155
  // The shared folder first (with its .gitignore), then this backup inside it.
155
156
  ensureBackupsDir(projectPath, errors);
156
157
  try {
157
- mkdirSync(backupDir, { recursive: true });
158
+ mkdirSyncRetrying(backupDir);
158
159
  } catch (err) {
159
160
  return { backupId, backupDir, backedUp, errors: [`Failed to create backup directory: ${err.message}`] };
160
161
  }
@@ -194,12 +195,12 @@ function snapshot(projectPath, spec) {
194
195
 
195
196
  const targetPath = join(backupDir, relativePath);
196
197
  try {
197
- mkdirSync(dirname(targetPath), { recursive: true });
198
+ mkdirSyncRetrying(dirname(targetPath));
198
199
  if (lstatSync(sourcePath).isDirectory()) {
199
200
  for (const d of listDirs(projectPath, relativePath)) preexistingDirs.add(d);
200
- mkdirSync(targetPath, { recursive: true });
201
+ mkdirSyncRetrying(targetPath);
201
202
  for (const f of listFiles(projectPath, relativePath)) {
202
- mkdirSync(dirname(join(backupDir, f)), { recursive: true });
203
+ mkdirSyncRetrying(dirname(join(backupDir, f)));
203
204
  copyLeaf(join(projectPath, f), join(backupDir, f));
204
205
  }
205
206
  } else {
@@ -295,12 +296,14 @@ export function createBackup(projectPath, plan, options = {}) {
295
296
  * @param {Object} spec
296
297
  * @param {string} spec.label - 'skills' | 'commands'
297
298
  * @param {string[]} spec.paths - Project-relative directories the step writes into
299
+ * @param {string[]} [spec.mustBackUp] - Project-relative paths the step is about to OVERWRITE (hook scripts):
300
+ * the backup's `coverage` counts them, so a copy that did not happen shows as a gap instead of as nothing
298
301
  * @param {Array<{path: string, reason: string}>} [spec.notBackedUp] - Targets outside the project
299
302
  */
300
303
  export function createStepBackup(projectPath, spec) {
301
304
  return snapshot(projectPath, {
302
305
  label: spec.label,
303
- mustBackUp: [],
306
+ mustBackUp: spec.mustBackUp || [],
304
307
  alsoWatch: spec.paths || [],
305
308
  notBackedUp: spec.notBackedUp || [],
306
309
  plan: { summary: null, actionCount: 0, actions: [] }
@@ -398,14 +401,14 @@ function restoreOne(projectPath, backupId) {
398
401
  }
399
402
  try {
400
403
  if (lstatSync(sourcePath).isDirectory()) {
401
- mkdirSync(join(projectPath, relativePath), { recursive: true });
404
+ mkdirSyncRetrying(join(projectPath, relativePath));
402
405
  for (const f of listFiles(backupDir, relativePath)) {
403
- mkdirSync(dirname(join(projectPath, f)), { recursive: true });
406
+ mkdirSyncRetrying(dirname(join(projectPath, f)));
404
407
  copyLeaf(join(backupDir, f), join(projectPath, f));
405
408
  restored.push(f);
406
409
  }
407
410
  } else {
408
- mkdirSync(dirname(join(projectPath, relativePath)), { recursive: true });
411
+ mkdirSyncRetrying(dirname(join(projectPath, relativePath)));
409
412
  copyLeaf(sourcePath, join(projectPath, relativePath));
410
413
  restored.push(relativePath);
411
414
  }
@@ -11,11 +11,12 @@
11
11
  * Each action is executed independently — single failures don't block the rest.
12
12
  */
13
13
 
14
- import { existsSync, unlinkSync, mkdirSync, rmSync, copyFileSync, statSync, readFileSync, writeFileSync } from 'fs';
14
+ import { existsSync, unlinkSync, rmSync, statSync, readFileSync, writeFileSync } from 'fs';
15
15
  import { UDS_MARKERS } from '../core/constants.js';
16
16
  import { tryLocateMarkerBlock } from '../utils/marker-locator.js';
17
17
  import { join, dirname } from 'path';
18
18
  import { copyStandard } from '../utils/copier.js';
19
+ import { copyFileSyncRetrying, mkdirSyncRetrying } from '../utils/transient-fs.js';
19
20
  import {
20
21
  writeIntegrationFile,
21
22
  buildToolIntegrationConfig,
@@ -27,12 +28,13 @@ import {
27
28
  installCommandsToMultipleAgents
28
29
  } from '../utils/skills-installer.js';
29
30
  import { writeManifest, mergeInstalledNames } from '../core/manifest.js';
30
- import { getRepositoryInfo } from '../utils/registry.js';
31
+ import { getRepositoryInfo, isShippedFilename } from '../utils/registry.js';
31
32
  import { displayLanguageToLocale } from '../utils/locale.js';
32
33
  import { computeFileHash, pruneIntegrationFileHashes } from '../utils/hasher.js';
33
34
  import { createBackup, cleanupBackups, finalizeBackup } from './backup-manager.js';
34
35
  import { bookkeepingFiles } from './install-roots.js';
35
36
  import { alignRecordedVersions } from './recorded-versions.js';
37
+ import { replaceSkillHashesForInstalled } from '../utils/skill-hash-ownership.js';
36
38
 
37
39
  /**
38
40
  * @typedef {Object} ExecutionResult
@@ -309,8 +311,10 @@ async function executeCreateOrUpdate(projectPath, action, manifest) {
309
311
 
310
312
  // Direct copy from resolved source
311
313
  const targetPath = join(projectPath, action.path);
312
- mkdirSync(dirname(targetPath), { recursive: true });
313
- copyFileSync(sourcePath, targetPath);
314
+ // Same retry and the same "permission denied" wording as the copy `uds init` does (board #77): a bare
315
+ // mkdirSync / copyFileSync here printed Node's own "EACCES: permission denied, copyfile" text and gave up on the first lock.
316
+ mkdirSyncRetrying(dirname(targetPath));
317
+ copyFileSyncRetrying(sourcePath, targetPath);
314
318
 
315
319
  // Update hash in manifest
316
320
  const hashInfo = computeFileHash(targetPath);
@@ -357,6 +361,46 @@ function removeUdsBlock(targetPath) {
357
361
  return { ok: true };
358
362
  }
359
363
 
364
+ /**
365
+ * A standard UDS retired (its registry entry is gone) has just been deleted from `.standards/`: make `manifest.standards` stop naming it.
366
+ *
367
+ * Without this the file went and the name stayed. `uds check` then warned "Manifest entries that match no installed standard ...
368
+ * `uds update` does not prune them: delete them from the "standards" list", and the next `uds update` wrote the same sentence
369
+ * into the adopter's CLAUDE.md ("1 manifest entry could not be matched to an installed file"). Found when `open-work-tracking`
370
+ * stopped being a standard (dev-platform XSPEC-427): the one command that removes the file left the one entry that makes the
371
+ * project look broken.
372
+ *
373
+ * The CLAUDE.md and AGENTS.md blocks are generated from `manifest.standards` by the migrate_block actions. `diffPlan` lists the standards
374
+ * before the integrations, so by the time a block is rewritten the entry is already gone and the block does not name the standard.
375
+ *
376
+ * An entry is dropped when it is the file's path (`ai/standards/x.ai.yaml`) or the id the file is named after (`x`). A standard
377
+ * UDS still ships is never touched: the file is only deleted for it when the manifest does not list it, so there is nothing to drop.
378
+ *
379
+ * @param {Object} manifest - Manifest being rewritten (mutated)
380
+ * @param {string} deletedPath - Path of the deleted file, relative to the project (e.g. `.standards/x.ai.yaml`)
381
+ * @returns {string[]} The manifest entries that were dropped
382
+ */
383
+ export function dropRetiredStandardEntries(manifest, deletedPath) {
384
+ if (!Array.isArray(manifest?.standards)) return [];
385
+ const fileName = String(deletedPath || '').replace(/\\/g, '/').split('/').pop();
386
+ if (!fileName || isShippedFilename(fileName)) return [];
387
+ const names = (entry) => {
388
+ if (typeof entry !== 'string') return false;
389
+ const normalized = entry.replace(/\\/g, '/');
390
+ const isThatPath = normalized.split('/').pop() === fileName;
391
+ // the bare id the file is named after: x.ai.yaml (format ai) and x.md (format human) are both "x"
392
+ const isThatId = !normalized.includes('/') && !normalized.includes('.') && normalized === fileName.replace(/\.ai\.yaml$|\.md$/, '');
393
+ return isThatPath || isThatId;
394
+ };
395
+ const dropped = manifest.standards.filter(names);
396
+ manifest.standards = manifest.standards.filter((entry) => !names(entry));
397
+ // The copy of the list that each integration file's config keeps (a snapshot taken when the file was written) names it too.
398
+ for (const config of Object.values(manifest.integrationConfigs || {})) {
399
+ if (Array.isArray(config?.installedStandards)) config.installedStandards = config.installedStandards.filter((entry) => !names(entry));
400
+ }
401
+ return dropped;
402
+ }
403
+
360
404
  /**
361
405
  * Execute a delete action.
362
406
  */
@@ -384,6 +428,7 @@ function executeDelete(projectPath, action, manifest) {
384
428
  // Remove from manifest tracking
385
429
  delete manifest.fileHashes[action.path];
386
430
  delete manifest.integrationBlockHashes[action.path];
431
+ if (action.category === 'standard') dropRetiredStandardEntries(manifest, action.path);
387
432
 
388
433
  return { action, success: true };
389
434
  } catch (err) {
@@ -555,9 +600,8 @@ async function executeSkillBatch(projectPath, skillActions, manifest) {
555
600
  skillLocale
556
601
  );
557
602
 
558
- if (installResult.allFileHashes) {
559
- Object.assign(manifest.skillHashes, installResult.allFileHashes);
560
- }
603
+ // Replace, not merge: files the installer pruned from a rewritten skill must lose their records (#46).
604
+ replaceSkillHashesForInstalled(manifest, installResult);
561
605
  // XSPEC-475 R6: the skill files were just rewritten to what this UDS ships, so the records that describe them
562
606
  // are brought to match. They were left at the old version and name list (the 6.11.0 -> 6.14 upgrade rewrote about
563
607
  // 200 files and still recorded 6.11.0 and no `comprehension-ladder`), and the second command `--skills` was the
@@ -1,5 +1,5 @@
1
- import { existsSync, mkdirSync, copyFileSync, readFileSync } from 'fs';
2
- import { copyFileSyncRetrying } from './transient-fs.js';
1
+ import { existsSync, readFileSync } from 'fs';
2
+ import { copyFileSyncRetrying, mkdirSyncRetrying } from './transient-fs.js';
3
3
  import { dirname, join, basename } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { downloadStandard, downloadIntegration } from './github.js';
@@ -66,7 +66,7 @@ export async function copyExtension(sourcePath, targetDir, projectPath) {
66
66
  const targetFolder = join(projectPath, targetDir);
67
67
  const targetFile = join(targetFolder, basename(sourcePath));
68
68
  if (!existsSync(targetFolder)) {
69
- mkdirSync(targetFolder, { recursive: true });
69
+ mkdirSyncRetrying(targetFolder);
70
70
  }
71
71
  copyFileSyncRetrying(packagedSource, targetFile);
72
72
  return success(targetFile, { source: 'local', sourcePath, targetFile });
@@ -119,7 +119,7 @@ export async function copyStandard(sourcePath, targetDir, projectPath) {
119
119
 
120
120
  // Ensure target directory exists
121
121
  if (!existsSync(targetFolder)) {
122
- mkdirSync(targetFolder, { recursive: true });
122
+ mkdirSyncRetrying(targetFolder);
123
123
  }
124
124
 
125
125
  // Try local copy first (bundled or repo)
@@ -174,17 +174,22 @@ export async function copyStandard(sourcePath, targetDir, projectPath) {
174
174
  export async function copyIntegration(sourcePath, targetPath, projectPath) {
175
175
  const target = join(projectPath, targetPath);
176
176
 
177
- // Ensure target directory exists
177
+ // Ensure target directory exists. A folder that cannot be made is reported like a file that cannot be
178
+ // copied ({ success: false, error }); it used to throw out of this function with Node's bare text.
178
179
  const targetDir = dirname(target);
179
- if (!existsSync(targetDir)) {
180
- mkdirSync(targetDir, { recursive: true });
180
+ try {
181
+ if (!existsSync(targetDir)) {
182
+ mkdirSyncRetrying(targetDir);
183
+ }
184
+ } catch (error) {
185
+ return { success: false, error: error.message, path: null };
181
186
  }
182
187
 
183
188
  // Try local copy first (bundled or repo)
184
189
  const source = getSourcePath(sourcePath);
185
190
  if (source) {
186
191
  try {
187
- copyFileSync(source, target);
192
+ copyFileSyncRetrying(source, target);
188
193
  return {
189
194
  success: true,
190
195
  error: null,
@@ -0,0 +1,37 @@
1
+ /**
2
+ * End the process without losing output that is still waiting to be written (board #81).
3
+ *
4
+ * `process.exit()` throws away what Node has not yet handed to a pipe. On macOS (and on Windows) a pipe is written
5
+ * asynchronously, so a command that prints a lot and then calls `process.exit()` can stop at exactly one pipe's worth
6
+ * (65,536 bytes measured) when the reader is slow: the end of the output - the part that says what failed last - is
7
+ * the part that is lost, while the exit code still arrives.
8
+ *
9
+ * Use this for a command that must still end the process explicitly (a handle - a spinner, a prompt - would otherwise
10
+ * keep it alive) and whose output can grow with the project. For a command that can simply return, set
11
+ * `process.exitCode` and return instead. A command whose output is a handful of fixed lines does not need either.
12
+ *
13
+ * It waits for an empty write on each stream to finish. Writes on a stream are finished in the order they were made, so
14
+ * when the empty one is done, everything before it has been taken by the reader.
15
+ *
16
+ * @param {number} code - the exit code; also left in `process.exitCode`
17
+ * @returns {Promise<void>} resolves only if `process.exit` is stubbed (tests); otherwise the process ends here
18
+ */
19
+ export async function flushAndExit(code) {
20
+ process.exitCode = code;
21
+ await Promise.all([drained(process.stdout), drained(process.stderr)]);
22
+ process.exit(code);
23
+ }
24
+
25
+ /** Resolves when everything already written to `stream` has been taken by its reader, or at once if it cannot be written. */
26
+ function drained(stream) {
27
+ return new Promise((resolve) => {
28
+ if (!stream || stream.destroyed || stream.writableEnded) return resolve();
29
+ // A reader that has gone away (EPIPE) must not keep us from exiting.
30
+ stream.once('error', resolve);
31
+ try {
32
+ stream.write('', () => resolve());
33
+ } catch {
34
+ resolve();
35
+ }
36
+ });
37
+ }