@brucewaynedecoy/make-docs 1.0.0-rc.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 (88) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +93 -0
  3. package/dist/chunk-HP3HBG7F.js +626 -0
  4. package/dist/chunk-HP3HBG7F.js.map +1 -0
  5. package/dist/chunk-QRFH4J6H.js +1194 -0
  6. package/dist/chunk-QRFH4J6H.js.map +1 -0
  7. package/dist/chunk-WM3OXYTW.js +2630 -0
  8. package/dist/chunk-WM3OXYTW.js.map +1 -0
  9. package/dist/index.js +1720 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/skills-command-3ESCZ75U.js +547 -0
  12. package/dist/skills-command-3ESCZ75U.js.map +1 -0
  13. package/dist/uninstall-GQE4SJF2.js +150 -0
  14. package/dist/uninstall-GQE4SJF2.js.map +1 -0
  15. package/package.json +49 -0
  16. package/skill-registry.json +276 -0
  17. package/skill-registry.schema.json +64 -0
  18. package/template/.make-docs/scripts/check_path_hygiene.py +435 -0
  19. package/template/AGENTS.md +3 -0
  20. package/template/CLAUDE.md +3 -0
  21. package/template/docs/AGENTS.md +15 -0
  22. package/template/docs/CLAUDE.md +15 -0
  23. package/template/docs/assets/AGENTS.md +9 -0
  24. package/template/docs/assets/CLAUDE.md +9 -0
  25. package/template/docs/assets/archive/AGENTS.md +20 -0
  26. package/template/docs/assets/archive/CLAUDE.md +20 -0
  27. package/template/docs/assets/history/AGENTS.md +12 -0
  28. package/template/docs/assets/history/CLAUDE.md +12 -0
  29. package/template/docs/assets/prompts/AGENTS.md +8 -0
  30. package/template/docs/assets/prompts/CLAUDE.md +8 -0
  31. package/template/docs/assets/prompts/designs-to-plan-change.prompt.md +14 -0
  32. package/template/docs/assets/prompts/designs-to-plan.prompt.md +10 -0
  33. package/template/docs/assets/prompts/docs-path-hygiene-cleanup.prompt.md +27 -0
  34. package/template/docs/assets/prompts/plan-to-prd-change.prompt.md +8 -0
  35. package/template/docs/assets/prompts/plan-to-prd-green-field.prompt.md +6 -0
  36. package/template/docs/assets/prompts/prd-change-to-work.prompt.md +10 -0
  37. package/template/docs/assets/prompts/prd-to-work-full-prd.prompt.md +6 -0
  38. package/template/docs/assets/prompts/prd-to-work-prd-feature.prompt.md +6 -0
  39. package/template/docs/assets/prompts/request-to-design.prompt.md +16 -0
  40. package/template/docs/assets/prompts/session-to-history-record.prompt.md +19 -0
  41. package/template/docs/assets/prompts/update-readme-green-field.prompt.md +6 -0
  42. package/template/docs/assets/prompts/work-to-commit-message.prompt.md +27 -0
  43. package/template/docs/assets/prompts/work-to-guides.prompt.md +18 -0
  44. package/template/docs/assets/references/AGENTS.md +9 -0
  45. package/template/docs/assets/references/CLAUDE.md +9 -0
  46. package/template/docs/assets/references/commit-message-convention.md +198 -0
  47. package/template/docs/assets/references/design-contract.md +62 -0
  48. package/template/docs/assets/references/design-workflow.md +60 -0
  49. package/template/docs/assets/references/execution-workflow.md +157 -0
  50. package/template/docs/assets/references/guide-contract.md +159 -0
  51. package/template/docs/assets/references/harness-capability-matrix.md +52 -0
  52. package/template/docs/assets/references/history-record-contract.md +137 -0
  53. package/template/docs/assets/references/output-contract.md +221 -0
  54. package/template/docs/assets/references/path-and-link-hygiene.md +49 -0
  55. package/template/docs/assets/references/planning-workflow.md +160 -0
  56. package/template/docs/assets/references/prd-change-management.md +129 -0
  57. package/template/docs/assets/references/wave-model.md +76 -0
  58. package/template/docs/assets/templates/AGENTS.md +8 -0
  59. package/template/docs/assets/templates/CLAUDE.md +8 -0
  60. package/template/docs/assets/templates/design.md +30 -0
  61. package/template/docs/assets/templates/guide-developer.md +54 -0
  62. package/template/docs/assets/templates/guide-user.md +58 -0
  63. package/template/docs/assets/templates/history-record.md +62 -0
  64. package/template/docs/assets/templates/plan-overview.md +32 -0
  65. package/template/docs/assets/templates/plan-prd-change.md +99 -0
  66. package/template/docs/assets/templates/plan-prd-decompose.md +70 -0
  67. package/template/docs/assets/templates/plan-prd.md +124 -0
  68. package/template/docs/assets/templates/prd-architecture.md +51 -0
  69. package/template/docs/assets/templates/prd-change-addition.md +45 -0
  70. package/template/docs/assets/templates/prd-change-revision.md +45 -0
  71. package/template/docs/assets/templates/prd-glossary.md +15 -0
  72. package/template/docs/assets/templates/prd-index.md +45 -0
  73. package/template/docs/assets/templates/prd-overview.md +43 -0
  74. package/template/docs/assets/templates/prd-reference.md +17 -0
  75. package/template/docs/assets/templates/prd-risk-register.md +55 -0
  76. package/template/docs/assets/templates/prd-subsystem.md +49 -0
  77. package/template/docs/assets/templates/work-index.md +21 -0
  78. package/template/docs/assets/templates/work-phase.md +34 -0
  79. package/template/docs/designs/AGENTS.md +21 -0
  80. package/template/docs/designs/CLAUDE.md +21 -0
  81. package/template/docs/guides/AGENTS.md +15 -0
  82. package/template/docs/guides/CLAUDE.md +15 -0
  83. package/template/docs/plans/AGENTS.md +20 -0
  84. package/template/docs/plans/CLAUDE.md +20 -0
  85. package/template/docs/prd/AGENTS.md +9 -0
  86. package/template/docs/prd/CLAUDE.md +9 -0
  87. package/template/docs/work/AGENTS.md +18 -0
  88. package/template/docs/work/CLAUDE.md +18 -0
@@ -0,0 +1,2630 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // ../../node_modules/sisteransi/src/index.js
29
+ var require_src = __commonJS({
30
+ "../../node_modules/sisteransi/src/index.js"(exports, module) {
31
+ "use strict";
32
+ var ESC = "\x1B";
33
+ var CSI = `${ESC}[`;
34
+ var beep = "\x07";
35
+ var cursor = {
36
+ to(x3, y2) {
37
+ if (!y2) return `${CSI}${x3 + 1}G`;
38
+ return `${CSI}${y2 + 1};${x3 + 1}H`;
39
+ },
40
+ move(x3, y2) {
41
+ let ret = "";
42
+ if (x3 < 0) ret += `${CSI}${-x3}D`;
43
+ else if (x3 > 0) ret += `${CSI}${x3}C`;
44
+ if (y2 < 0) ret += `${CSI}${-y2}A`;
45
+ else if (y2 > 0) ret += `${CSI}${y2}B`;
46
+ return ret;
47
+ },
48
+ up: (count = 1) => `${CSI}${count}A`,
49
+ down: (count = 1) => `${CSI}${count}B`,
50
+ forward: (count = 1) => `${CSI}${count}C`,
51
+ backward: (count = 1) => `${CSI}${count}D`,
52
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
53
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
54
+ left: `${CSI}G`,
55
+ hide: `${CSI}?25l`,
56
+ show: `${CSI}?25h`,
57
+ save: `${ESC}7`,
58
+ restore: `${ESC}8`
59
+ };
60
+ var scroll = {
61
+ up: (count = 1) => `${CSI}S`.repeat(count),
62
+ down: (count = 1) => `${CSI}T`.repeat(count)
63
+ };
64
+ var erase = {
65
+ screen: `${CSI}2J`,
66
+ up: (count = 1) => `${CSI}1J`.repeat(count),
67
+ down: (count = 1) => `${CSI}J`.repeat(count),
68
+ line: `${CSI}2K`,
69
+ lineEnd: `${CSI}K`,
70
+ lineStart: `${CSI}1K`,
71
+ lines(count) {
72
+ let clear = "";
73
+ for (let i = 0; i < count; i++)
74
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
75
+ if (count)
76
+ clear += cursor.left;
77
+ return clear;
78
+ }
79
+ };
80
+ module.exports = { cursor, scroll, erase, beep };
81
+ }
82
+ });
83
+
84
+ // ../../node_modules/@clack/core/dist/index.mjs
85
+ var import_sisteransi = __toESM(require_src(), 1);
86
+ import { styleText as D } from "util";
87
+ import { stdout as R, stdin as q } from "process";
88
+ import * as k from "readline";
89
+ import ot from "readline";
90
+ import { ReadStream as J } from "tty";
91
+ function x(t2, e, s) {
92
+ if (!s.some((u) => !u.disabled)) return t2;
93
+ const i = t2 + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
94
+ return s[n].disabled ? x(n, e < 0 ? -1 : 1, s) : n;
95
+ }
96
+ var at = (t2) => t2 === 161 || t2 === 164 || t2 === 167 || t2 === 168 || t2 === 170 || t2 === 173 || t2 === 174 || t2 >= 176 && t2 <= 180 || t2 >= 182 && t2 <= 186 || t2 >= 188 && t2 <= 191 || t2 === 198 || t2 === 208 || t2 === 215 || t2 === 216 || t2 >= 222 && t2 <= 225 || t2 === 230 || t2 >= 232 && t2 <= 234 || t2 === 236 || t2 === 237 || t2 === 240 || t2 === 242 || t2 === 243 || t2 >= 247 && t2 <= 250 || t2 === 252 || t2 === 254 || t2 === 257 || t2 === 273 || t2 === 275 || t2 === 283 || t2 === 294 || t2 === 295 || t2 === 299 || t2 >= 305 && t2 <= 307 || t2 === 312 || t2 >= 319 && t2 <= 322 || t2 === 324 || t2 >= 328 && t2 <= 331 || t2 === 333 || t2 === 338 || t2 === 339 || t2 === 358 || t2 === 359 || t2 === 363 || t2 === 462 || t2 === 464 || t2 === 466 || t2 === 468 || t2 === 470 || t2 === 472 || t2 === 474 || t2 === 476 || t2 === 593 || t2 === 609 || t2 === 708 || t2 === 711 || t2 >= 713 && t2 <= 715 || t2 === 717 || t2 === 720 || t2 >= 728 && t2 <= 731 || t2 === 733 || t2 === 735 || t2 >= 768 && t2 <= 879 || t2 >= 913 && t2 <= 929 || t2 >= 931 && t2 <= 937 || t2 >= 945 && t2 <= 961 || t2 >= 963 && t2 <= 969 || t2 === 1025 || t2 >= 1040 && t2 <= 1103 || t2 === 1105 || t2 === 8208 || t2 >= 8211 && t2 <= 8214 || t2 === 8216 || t2 === 8217 || t2 === 8220 || t2 === 8221 || t2 >= 8224 && t2 <= 8226 || t2 >= 8228 && t2 <= 8231 || t2 === 8240 || t2 === 8242 || t2 === 8243 || t2 === 8245 || t2 === 8251 || t2 === 8254 || t2 === 8308 || t2 === 8319 || t2 >= 8321 && t2 <= 8324 || t2 === 8364 || t2 === 8451 || t2 === 8453 || t2 === 8457 || t2 === 8467 || t2 === 8470 || t2 === 8481 || t2 === 8482 || t2 === 8486 || t2 === 8491 || t2 === 8531 || t2 === 8532 || t2 >= 8539 && t2 <= 8542 || t2 >= 8544 && t2 <= 8555 || t2 >= 8560 && t2 <= 8569 || t2 === 8585 || t2 >= 8592 && t2 <= 8601 || t2 === 8632 || t2 === 8633 || t2 === 8658 || t2 === 8660 || t2 === 8679 || t2 === 8704 || t2 === 8706 || t2 === 8707 || t2 === 8711 || t2 === 8712 || t2 === 8715 || t2 === 8719 || t2 === 8721 || t2 === 8725 || t2 === 8730 || t2 >= 8733 && t2 <= 8736 || t2 === 8739 || t2 === 8741 || t2 >= 8743 && t2 <= 8748 || t2 === 8750 || t2 >= 8756 && t2 <= 8759 || t2 === 8764 || t2 === 8765 || t2 === 8776 || t2 === 8780 || t2 === 8786 || t2 === 8800 || t2 === 8801 || t2 >= 8804 && t2 <= 8807 || t2 === 8810 || t2 === 8811 || t2 === 8814 || t2 === 8815 || t2 === 8834 || t2 === 8835 || t2 === 8838 || t2 === 8839 || t2 === 8853 || t2 === 8857 || t2 === 8869 || t2 === 8895 || t2 === 8978 || t2 >= 9312 && t2 <= 9449 || t2 >= 9451 && t2 <= 9547 || t2 >= 9552 && t2 <= 9587 || t2 >= 9600 && t2 <= 9615 || t2 >= 9618 && t2 <= 9621 || t2 === 9632 || t2 === 9633 || t2 >= 9635 && t2 <= 9641 || t2 === 9650 || t2 === 9651 || t2 === 9654 || t2 === 9655 || t2 === 9660 || t2 === 9661 || t2 === 9664 || t2 === 9665 || t2 >= 9670 && t2 <= 9672 || t2 === 9675 || t2 >= 9678 && t2 <= 9681 || t2 >= 9698 && t2 <= 9701 || t2 === 9711 || t2 === 9733 || t2 === 9734 || t2 === 9737 || t2 === 9742 || t2 === 9743 || t2 === 9756 || t2 === 9758 || t2 === 9792 || t2 === 9794 || t2 === 9824 || t2 === 9825 || t2 >= 9827 && t2 <= 9829 || t2 >= 9831 && t2 <= 9834 || t2 === 9836 || t2 === 9837 || t2 === 9839 || t2 === 9886 || t2 === 9887 || t2 === 9919 || t2 >= 9926 && t2 <= 9933 || t2 >= 9935 && t2 <= 9939 || t2 >= 9941 && t2 <= 9953 || t2 === 9955 || t2 === 9960 || t2 === 9961 || t2 >= 9963 && t2 <= 9969 || t2 === 9972 || t2 >= 9974 && t2 <= 9977 || t2 === 9979 || t2 === 9980 || t2 === 9982 || t2 === 9983 || t2 === 10045 || t2 >= 10102 && t2 <= 10111 || t2 >= 11094 && t2 <= 11097 || t2 >= 12872 && t2 <= 12879 || t2 >= 57344 && t2 <= 63743 || t2 >= 65024 && t2 <= 65039 || t2 === 65533 || t2 >= 127232 && t2 <= 127242 || t2 >= 127248 && t2 <= 127277 || t2 >= 127280 && t2 <= 127337 || t2 >= 127344 && t2 <= 127373 || t2 === 127375 || t2 === 127376 || t2 >= 127387 && t2 <= 127404 || t2 >= 917760 && t2 <= 917999 || t2 >= 983040 && t2 <= 1048573 || t2 >= 1048576 && t2 <= 1114109;
97
+ var lt = (t2) => t2 === 12288 || t2 >= 65281 && t2 <= 65376 || t2 >= 65504 && t2 <= 65510;
98
+ var ht = (t2) => t2 >= 4352 && t2 <= 4447 || t2 === 8986 || t2 === 8987 || t2 === 9001 || t2 === 9002 || t2 >= 9193 && t2 <= 9196 || t2 === 9200 || t2 === 9203 || t2 === 9725 || t2 === 9726 || t2 === 9748 || t2 === 9749 || t2 >= 9800 && t2 <= 9811 || t2 === 9855 || t2 === 9875 || t2 === 9889 || t2 === 9898 || t2 === 9899 || t2 === 9917 || t2 === 9918 || t2 === 9924 || t2 === 9925 || t2 === 9934 || t2 === 9940 || t2 === 9962 || t2 === 9970 || t2 === 9971 || t2 === 9973 || t2 === 9978 || t2 === 9981 || t2 === 9989 || t2 === 9994 || t2 === 9995 || t2 === 10024 || t2 === 10060 || t2 === 10062 || t2 >= 10067 && t2 <= 10069 || t2 === 10071 || t2 >= 10133 && t2 <= 10135 || t2 === 10160 || t2 === 10175 || t2 === 11035 || t2 === 11036 || t2 === 11088 || t2 === 11093 || t2 >= 11904 && t2 <= 11929 || t2 >= 11931 && t2 <= 12019 || t2 >= 12032 && t2 <= 12245 || t2 >= 12272 && t2 <= 12287 || t2 >= 12289 && t2 <= 12350 || t2 >= 12353 && t2 <= 12438 || t2 >= 12441 && t2 <= 12543 || t2 >= 12549 && t2 <= 12591 || t2 >= 12593 && t2 <= 12686 || t2 >= 12688 && t2 <= 12771 || t2 >= 12783 && t2 <= 12830 || t2 >= 12832 && t2 <= 12871 || t2 >= 12880 && t2 <= 19903 || t2 >= 19968 && t2 <= 42124 || t2 >= 42128 && t2 <= 42182 || t2 >= 43360 && t2 <= 43388 || t2 >= 44032 && t2 <= 55203 || t2 >= 63744 && t2 <= 64255 || t2 >= 65040 && t2 <= 65049 || t2 >= 65072 && t2 <= 65106 || t2 >= 65108 && t2 <= 65126 || t2 >= 65128 && t2 <= 65131 || t2 >= 94176 && t2 <= 94180 || t2 === 94192 || t2 === 94193 || t2 >= 94208 && t2 <= 100343 || t2 >= 100352 && t2 <= 101589 || t2 >= 101632 && t2 <= 101640 || t2 >= 110576 && t2 <= 110579 || t2 >= 110581 && t2 <= 110587 || t2 === 110589 || t2 === 110590 || t2 >= 110592 && t2 <= 110882 || t2 === 110898 || t2 >= 110928 && t2 <= 110930 || t2 === 110933 || t2 >= 110948 && t2 <= 110951 || t2 >= 110960 && t2 <= 111355 || t2 === 126980 || t2 === 127183 || t2 === 127374 || t2 >= 127377 && t2 <= 127386 || t2 >= 127488 && t2 <= 127490 || t2 >= 127504 && t2 <= 127547 || t2 >= 127552 && t2 <= 127560 || t2 === 127568 || t2 === 127569 || t2 >= 127584 && t2 <= 127589 || t2 >= 127744 && t2 <= 127776 || t2 >= 127789 && t2 <= 127797 || t2 >= 127799 && t2 <= 127868 || t2 >= 127870 && t2 <= 127891 || t2 >= 127904 && t2 <= 127946 || t2 >= 127951 && t2 <= 127955 || t2 >= 127968 && t2 <= 127984 || t2 === 127988 || t2 >= 127992 && t2 <= 128062 || t2 === 128064 || t2 >= 128066 && t2 <= 128252 || t2 >= 128255 && t2 <= 128317 || t2 >= 128331 && t2 <= 128334 || t2 >= 128336 && t2 <= 128359 || t2 === 128378 || t2 === 128405 || t2 === 128406 || t2 === 128420 || t2 >= 128507 && t2 <= 128591 || t2 >= 128640 && t2 <= 128709 || t2 === 128716 || t2 >= 128720 && t2 <= 128722 || t2 >= 128725 && t2 <= 128727 || t2 >= 128732 && t2 <= 128735 || t2 === 128747 || t2 === 128748 || t2 >= 128756 && t2 <= 128764 || t2 >= 128992 && t2 <= 129003 || t2 === 129008 || t2 >= 129292 && t2 <= 129338 || t2 >= 129340 && t2 <= 129349 || t2 >= 129351 && t2 <= 129535 || t2 >= 129648 && t2 <= 129660 || t2 >= 129664 && t2 <= 129672 || t2 >= 129680 && t2 <= 129725 || t2 >= 129727 && t2 <= 129733 || t2 >= 129742 && t2 <= 129755 || t2 >= 129760 && t2 <= 129768 || t2 >= 129776 && t2 <= 129784 || t2 >= 131072 && t2 <= 196605 || t2 >= 196608 && t2 <= 262141;
99
+ var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
100
+ var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
101
+ var L = /\t{1,1000}/y;
102
+ var P = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
103
+ var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
104
+ var ct = new RegExp("\\p{M}+", "gu");
105
+ var ft = { limit: 1 / 0, ellipsis: "" };
106
+ var X = (t2, e = {}, s = {}) => {
107
+ const i = e.limit ?? 1 / 0, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V2 = s.wideWidth ?? 2;
108
+ let h2 = 0, o = 0, p = t2.length, v = 0, F = false, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
109
+ t: for (; ; ) {
110
+ if (w > C || o >= p && o > h2) {
111
+ const ut = t2.slice(C, w) || t2.slice(h2, o);
112
+ v = 0;
113
+ for (const Y of ut.replaceAll(ct, "")) {
114
+ const $ = Y.codePointAt(0) || 0;
115
+ if (lt($) ? f = m : ht($) ? f = V2 : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h2) + v)), c + f > i) {
116
+ F = true;
117
+ break t;
118
+ }
119
+ v += Y.length, c += f;
120
+ }
121
+ C = w = 0;
122
+ }
123
+ if (o >= p) break;
124
+ if (M.lastIndex = o, M.test(t2)) {
125
+ if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
126
+ F = true;
127
+ break;
128
+ }
129
+ c += f, C = h2, w = o, o = h2 = M.lastIndex;
130
+ continue;
131
+ }
132
+ if (O.lastIndex = o, O.test(t2)) {
133
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
134
+ F = true;
135
+ break;
136
+ }
137
+ c += u, C = h2, w = o, o = h2 = O.lastIndex;
138
+ continue;
139
+ }
140
+ if (y.lastIndex = o, y.test(t2)) {
141
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
142
+ F = true;
143
+ break;
144
+ }
145
+ c += f, C = h2, w = o, o = h2 = y.lastIndex;
146
+ continue;
147
+ }
148
+ if (L.lastIndex = o, L.test(t2)) {
149
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
150
+ F = true;
151
+ break;
152
+ }
153
+ c += f, C = h2, w = o, o = h2 = L.lastIndex;
154
+ continue;
155
+ }
156
+ if (P.lastIndex = o, P.test(t2)) {
157
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
158
+ F = true;
159
+ break;
160
+ }
161
+ c += g, C = h2, w = o, o = h2 = P.lastIndex;
162
+ continue;
163
+ }
164
+ o += 1;
165
+ }
166
+ return { width: F ? b : c, index: F ? d : p, truncated: F, ellipsed: F && i >= n };
167
+ };
168
+ var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
169
+ var S = (t2, e = {}) => X(t2, pt, e).width;
170
+ var T = "\x1B";
171
+ var Z = "\x9B";
172
+ var Ft = 39;
173
+ var j = "\x07";
174
+ var Q = "[";
175
+ var dt = "]";
176
+ var tt = "m";
177
+ var U = `${dt}8;;`;
178
+ var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
179
+ var mt = (t2) => {
180
+ if (t2 >= 30 && t2 <= 37 || t2 >= 90 && t2 <= 97) return 39;
181
+ if (t2 >= 40 && t2 <= 47 || t2 >= 100 && t2 <= 107) return 49;
182
+ if (t2 === 1 || t2 === 2) return 22;
183
+ if (t2 === 3) return 23;
184
+ if (t2 === 4) return 24;
185
+ if (t2 === 7) return 27;
186
+ if (t2 === 8) return 28;
187
+ if (t2 === 9) return 29;
188
+ if (t2 === 0) return 0;
189
+ };
190
+ var st = (t2) => `${T}${Q}${t2}${tt}`;
191
+ var it = (t2) => `${T}${U}${t2}${j}`;
192
+ var gt = (t2) => t2.map((e) => S(e));
193
+ var G = (t2, e, s) => {
194
+ const i = e[Symbol.iterator]();
195
+ let r = false, n = false, u = t2.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
196
+ for (; !l.done; ) {
197
+ const m = l.value, A = S(m);
198
+ a + A <= s ? t2[t2.length - 1] += m : (t2.push(m), a = 0), (m === T || m === Z) && (r = true, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t2.push(""), a = 0)), l = E, E = i.next(), g += m.length;
199
+ }
200
+ u = t2.at(-1), !a && u !== void 0 && u.length > 0 && t2.length > 1 && (t2[t2.length - 2] += t2.pop());
201
+ };
202
+ var vt = (t2) => {
203
+ const e = t2.split(" ");
204
+ let s = e.length;
205
+ for (; s > 0 && !(S(e[s - 1]) > 0); ) s--;
206
+ return s === e.length ? t2 : e.slice(0, s).join(" ") + e.slice(s).join("");
207
+ };
208
+ var Et = (t2, e, s = {}) => {
209
+ if (s.trim !== false && t2.trim() === "") return "";
210
+ let i = "", r, n;
211
+ const u = t2.split(" "), a = gt(u);
212
+ let l = [""];
213
+ for (const [h2, o] of u.entries()) {
214
+ s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
215
+ let p = S(l.at(-1) ?? "");
216
+ if (h2 !== 0 && (p >= e && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h2] > e) {
217
+ const v = e - p, F = 1 + Math.floor((a[h2] - v - 1) / e);
218
+ Math.floor((a[h2] - 1) / e) < F && l.push(""), G(l, o, e);
219
+ continue;
220
+ }
221
+ if (p + a[h2] > e && p > 0 && a[h2] > 0) {
222
+ if (s.wordWrap === false && p < e) {
223
+ G(l, o, e);
224
+ continue;
225
+ }
226
+ l.push("");
227
+ }
228
+ if (p + a[h2] > e && s.wordWrap === false) {
229
+ G(l, o, e);
230
+ continue;
231
+ }
232
+ l[l.length - 1] += o;
233
+ }
234
+ s.trim !== false && (l = l.map((h2) => vt(h2)));
235
+ const E = l.join(`
236
+ `), g = E[Symbol.iterator]();
237
+ let m = g.next(), A = g.next(), V2 = 0;
238
+ for (; !m.done; ) {
239
+ const h2 = m.value, o = A.value;
240
+ if (i += h2, h2 === T || h2 === Z) {
241
+ et.lastIndex = V2 + 1;
242
+ const F = et.exec(E)?.groups;
243
+ if (F?.code !== void 0) {
244
+ const d = Number.parseFloat(F.code);
245
+ r = d === Ft ? void 0 : d;
246
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
247
+ }
248
+ const p = r ? mt(r) : void 0;
249
+ o === `
250
+ ` ? (n && (i += it("")), r && p && (i += st(p))) : h2 === `
251
+ ` && (r && p && (i += st(r)), n && (i += it(n))), V2 += h2.length, m = A, A = g.next();
252
+ }
253
+ return i;
254
+ };
255
+ function K(t2, e, s) {
256
+ return String(t2).normalize().replaceAll(`\r
257
+ `, `
258
+ `).split(`
259
+ `).map((i) => Et(i, e, s)).join(`
260
+ `);
261
+ }
262
+ var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
263
+ var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true };
264
+ function H(t2, e) {
265
+ if (typeof t2 == "string") return _.aliases.get(t2) === e;
266
+ for (const s of t2) if (s !== void 0 && H(s, e)) return true;
267
+ return false;
268
+ }
269
+ function _t(t2, e) {
270
+ if (t2 === e) return;
271
+ const s = t2.split(`
272
+ `), i = e.split(`
273
+ `), r = Math.max(s.length, i.length), n = [];
274
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
275
+ return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
276
+ }
277
+ var bt = globalThis.process.platform.startsWith("win");
278
+ var z = /* @__PURE__ */ Symbol("clack:cancel");
279
+ function Ct(t2) {
280
+ return t2 === z;
281
+ }
282
+ function W(t2, e) {
283
+ const s = t2;
284
+ s.isTTY && s.setRawMode(e);
285
+ }
286
+ var rt = (t2) => "columns" in t2 && typeof t2.columns == "number" ? t2.columns : 80;
287
+ var nt = (t2) => "rows" in t2 && typeof t2.rows == "number" ? t2.rows : 20;
288
+ function Bt(t2, e, s, i = s) {
289
+ const r = rt(t2 ?? R);
290
+ return K(e, r - s.length, { hard: true, trim: false }).split(`
291
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
292
+ `);
293
+ }
294
+ var B = class {
295
+ input;
296
+ output;
297
+ _abortSignal;
298
+ rl;
299
+ opts;
300
+ _render;
301
+ _track = false;
302
+ _prevFrame = "";
303
+ _subscribers = /* @__PURE__ */ new Map();
304
+ _cursor = 0;
305
+ state = "initial";
306
+ error = "";
307
+ value;
308
+ userInput = "";
309
+ constructor(e, s = true) {
310
+ const { input: i = q, output: r = R, render: n, signal: u, ...a } = e;
311
+ this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
312
+ }
313
+ unsubscribe() {
314
+ this._subscribers.clear();
315
+ }
316
+ setSubscriber(e, s) {
317
+ const i = this._subscribers.get(e) ?? [];
318
+ i.push(s), this._subscribers.set(e, i);
319
+ }
320
+ on(e, s) {
321
+ this.setSubscriber(e, { cb: s });
322
+ }
323
+ once(e, s) {
324
+ this.setSubscriber(e, { cb: s, once: true });
325
+ }
326
+ emit(e, ...s) {
327
+ const i = this._subscribers.get(e) ?? [], r = [];
328
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
329
+ for (const n of r) n();
330
+ }
331
+ prompt() {
332
+ return new Promise((e) => {
333
+ if (this._abortSignal) {
334
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z);
335
+ this._abortSignal.addEventListener("abort", () => {
336
+ this.state = "cancel", this.close();
337
+ }, { once: true });
338
+ }
339
+ this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), W(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
340
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(this.value);
341
+ }), this.once("cancel", () => {
342
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(z);
343
+ });
344
+ });
345
+ }
346
+ _isActionKey(e, s) {
347
+ return e === " ";
348
+ }
349
+ _setValue(e) {
350
+ this.value = e, this.emit("value", this.value);
351
+ }
352
+ _setUserInput(e, s) {
353
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
354
+ }
355
+ _clearUserInput() {
356
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
357
+ }
358
+ onKeypress(e, s) {
359
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
360
+ if (this.opts.validate) {
361
+ const i = this.opts.validate(this.value);
362
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
363
+ }
364
+ this.state !== "error" && (this.state = "submit");
365
+ }
366
+ H([e, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
367
+ }
368
+ close() {
369
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
370
+ `), W(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
371
+ }
372
+ restoreCursor() {
373
+ const e = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
374
+ `).length - 1;
375
+ this.output.write(import_sisteransi.cursor.move(-999, e * -1));
376
+ }
377
+ render() {
378
+ const e = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
379
+ if (e !== this._prevFrame) {
380
+ if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
381
+ else {
382
+ const s = _t(this._prevFrame, e), i = nt(this.output);
383
+ if (this.restoreCursor(), s) {
384
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
385
+ let u = s.lines.find((a) => a >= r);
386
+ if (u === void 0) {
387
+ this._prevFrame = e;
388
+ return;
389
+ }
390
+ if (s.lines.length === 1) {
391
+ this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
392
+ const a = e.split(`
393
+ `);
394
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
395
+ return;
396
+ } else if (s.lines.length > 1) {
397
+ if (r < n) u = r;
398
+ else {
399
+ const l = u - n;
400
+ l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
401
+ }
402
+ this.output.write(import_sisteransi.erase.down());
403
+ const a = e.split(`
404
+ `).slice(u);
405
+ this.output.write(a.join(`
406
+ `)), this._prevFrame = e;
407
+ return;
408
+ }
409
+ }
410
+ this.output.write(import_sisteransi.erase.down());
411
+ }
412
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
413
+ }
414
+ }
415
+ };
416
+ var kt = class extends B {
417
+ get cursor() {
418
+ return this.value ? 0 : 1;
419
+ }
420
+ get _value() {
421
+ return this.cursor === 0;
422
+ }
423
+ constructor(e) {
424
+ super(e, false), this.value = !!e.initialValue, this.on("userInput", () => {
425
+ this.value = this._value;
426
+ }), this.on("confirm", (s) => {
427
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
428
+ }), this.on("cursor", () => {
429
+ this.value = !this.value;
430
+ });
431
+ }
432
+ };
433
+ var Lt = class extends B {
434
+ options;
435
+ cursor = 0;
436
+ get _value() {
437
+ return this.options[this.cursor].value;
438
+ }
439
+ get _enabledOptions() {
440
+ return this.options.filter((e) => e.disabled !== true);
441
+ }
442
+ toggleAll() {
443
+ const e = this._enabledOptions, s = this.value !== void 0 && this.value.length === e.length;
444
+ this.value = s ? [] : e.map((i) => i.value);
445
+ }
446
+ toggleInvert() {
447
+ const e = this.value;
448
+ if (!e) return;
449
+ const s = this._enabledOptions.filter((i) => !e.includes(i.value));
450
+ this.value = s.map((i) => i.value);
451
+ }
452
+ toggleValue() {
453
+ this.value === void 0 && (this.value = []);
454
+ const e = this.value.includes(this._value);
455
+ this.value = e ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
456
+ }
457
+ constructor(e) {
458
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
459
+ const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
460
+ this.cursor = this.options[s].disabled ? x(s, 1, this.options) : s, this.on("key", (i) => {
461
+ i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
462
+ }), this.on("cursor", (i) => {
463
+ switch (i) {
464
+ case "left":
465
+ case "up":
466
+ this.cursor = x(this.cursor, -1, this.options);
467
+ break;
468
+ case "down":
469
+ case "right":
470
+ this.cursor = x(this.cursor, 1, this.options);
471
+ break;
472
+ case "space":
473
+ this.toggleValue();
474
+ break;
475
+ }
476
+ });
477
+ }
478
+ };
479
+ var Tt = class extends B {
480
+ options;
481
+ cursor = 0;
482
+ get _selectedValue() {
483
+ return this.options[this.cursor];
484
+ }
485
+ changeValue() {
486
+ this.value = this._selectedValue.value;
487
+ }
488
+ constructor(e) {
489
+ super(e, false), this.options = e.options;
490
+ const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
491
+ this.cursor = this.options[i].disabled ? x(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
492
+ switch (r) {
493
+ case "left":
494
+ case "up":
495
+ this.cursor = x(this.cursor, -1, this.options);
496
+ break;
497
+ case "down":
498
+ case "right":
499
+ this.cursor = x(this.cursor, 1, this.options);
500
+ break;
501
+ }
502
+ this.changeValue();
503
+ });
504
+ }
505
+ };
506
+
507
+ // ../../node_modules/@clack/prompts/dist/index.mjs
508
+ var import_sisteransi2 = __toESM(require_src(), 1);
509
+ import { styleText as t, stripVTControlCharacters as ue } from "util";
510
+ import N2 from "process";
511
+ import { readdirSync as $t2, existsSync as dt2, lstatSync as xe } from "fs";
512
+ import { dirname as _e, join as ht2 } from "path";
513
+ function pt2() {
514
+ return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
515
+ }
516
+ var ee = pt2();
517
+ var I2 = (e, r) => ee ? e : r;
518
+ var Re = I2("\u25C6", "*");
519
+ var $e = I2("\u25A0", "x");
520
+ var de = I2("\u25B2", "x");
521
+ var V = I2("\u25C7", "o");
522
+ var he = I2("\u250C", "T");
523
+ var h = I2("\u2502", "|");
524
+ var x2 = I2("\u2514", "\u2014");
525
+ var Oe = I2("\u2510", "T");
526
+ var Pe = I2("\u2518", "\u2014");
527
+ var z2 = I2("\u25CF", ">");
528
+ var H2 = I2("\u25CB", " ");
529
+ var te = I2("\u25FB", "[\u2022]");
530
+ var U2 = I2("\u25FC", "[+]");
531
+ var q2 = I2("\u25FB", "[ ]");
532
+ var Ne = I2("\u25AA", "\u2022");
533
+ var se = I2("\u2500", "-");
534
+ var pe = I2("\u256E", "+");
535
+ var We = I2("\u251C", "+");
536
+ var me = I2("\u256F", "+");
537
+ var ge = I2("\u2570", "+");
538
+ var Ge = I2("\u256D", "+");
539
+ var fe = I2("\u25CF", "\u2022");
540
+ var Fe = I2("\u25C6", "*");
541
+ var ye = I2("\u25B2", "!");
542
+ var Ee = I2("\u25A0", "x");
543
+ var W2 = (e) => {
544
+ switch (e) {
545
+ case "initial":
546
+ case "active":
547
+ return t("cyan", Re);
548
+ case "cancel":
549
+ return t("red", $e);
550
+ case "error":
551
+ return t("yellow", de);
552
+ case "submit":
553
+ return t("green", V);
554
+ }
555
+ };
556
+ var ve = (e) => {
557
+ switch (e) {
558
+ case "initial":
559
+ case "active":
560
+ return t("cyan", h);
561
+ case "cancel":
562
+ return t("red", h);
563
+ case "error":
564
+ return t("yellow", h);
565
+ case "submit":
566
+ return t("green", h);
567
+ }
568
+ };
569
+ var mt2 = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109;
570
+ var gt2 = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510;
571
+ var ft2 = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141;
572
+ var we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
573
+ var re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
574
+ var ie = /\t{1,1000}/y;
575
+ var Ae = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
576
+ var ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
577
+ var Ft2 = new RegExp("\\p{M}+", "gu");
578
+ var yt2 = { limit: 1 / 0, ellipsis: "" };
579
+ var Le = (e, r = {}, s = {}) => {
580
+ const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt2, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
581
+ let $ = 0, m = 0, d = e.length, F = 0, y2 = false, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S2 = 0;
582
+ e: for (; ; ) {
583
+ if (b > A || m >= d && m > $) {
584
+ const T2 = e.slice(A, b) || e.slice($, m);
585
+ F = 0;
586
+ for (const M2 of T2.replaceAll(Ft2, "")) {
587
+ const O2 = M2.codePointAt(0) || 0;
588
+ if (gt2(O2) ? S2 = f : ft2(O2) ? S2 = E : c !== g && mt2(O2) ? S2 = c : S2 = g, w + S2 > C && (v = Math.min(v, Math.max(A, $) + F)), w + S2 > i) {
589
+ y2 = true;
590
+ break e;
591
+ }
592
+ F += M2.length, w += S2;
593
+ }
594
+ A = b = 0;
595
+ }
596
+ if (m >= d) break;
597
+ if (ne.lastIndex = m, ne.test(e)) {
598
+ if (F = ne.lastIndex - m, S2 = F * g, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S2 > i) {
599
+ y2 = true;
600
+ break;
601
+ }
602
+ w += S2, A = $, b = m, m = $ = ne.lastIndex;
603
+ continue;
604
+ }
605
+ if (we.lastIndex = m, we.test(e)) {
606
+ if (w + u > C && (v = Math.min(v, m)), w + u > i) {
607
+ y2 = true;
608
+ break;
609
+ }
610
+ w += u, A = $, b = m, m = $ = we.lastIndex;
611
+ continue;
612
+ }
613
+ if (re.lastIndex = m, re.test(e)) {
614
+ if (F = re.lastIndex - m, S2 = F * l, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S2 > i) {
615
+ y2 = true;
616
+ break;
617
+ }
618
+ w += S2, A = $, b = m, m = $ = re.lastIndex;
619
+ continue;
620
+ }
621
+ if (ie.lastIndex = m, ie.test(e)) {
622
+ if (F = ie.lastIndex - m, S2 = F * n, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S2 > i) {
623
+ y2 = true;
624
+ break;
625
+ }
626
+ w += S2, A = $, b = m, m = $ = ie.lastIndex;
627
+ continue;
628
+ }
629
+ if (Ae.lastIndex = m, Ae.test(e)) {
630
+ if (w + p > C && (v = Math.min(v, m)), w + p > i) {
631
+ y2 = true;
632
+ break;
633
+ }
634
+ w += p, A = $, b = m, m = $ = Ae.lastIndex;
635
+ continue;
636
+ }
637
+ m += 1;
638
+ }
639
+ return { width: y2 ? C : w, index: y2 ? v : d, truncated: y2, ellipsed: y2 && i >= o };
640
+ };
641
+ var Et2 = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
642
+ var D2 = (e, r = {}) => Le(e, Et2, r).width;
643
+ var ae = "\x1B";
644
+ var je = "\x9B";
645
+ var vt2 = 39;
646
+ var Ce = "\x07";
647
+ var ke = "[";
648
+ var wt = "]";
649
+ var Ve = "m";
650
+ var Se = `${wt}8;;`;
651
+ var He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y");
652
+ var At2 = (e) => {
653
+ if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
654
+ if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
655
+ if (e === 1 || e === 2) return 22;
656
+ if (e === 3) return 23;
657
+ if (e === 4) return 24;
658
+ if (e === 7) return 27;
659
+ if (e === 8) return 28;
660
+ if (e === 9) return 29;
661
+ if (e === 0) return 0;
662
+ };
663
+ var Ue = (e) => `${ae}${ke}${e}${Ve}`;
664
+ var Ke = (e) => `${ae}${Se}${e}${Ce}`;
665
+ var Ct2 = (e) => e.map((r) => D2(r));
666
+ var Ie = (e, r, s) => {
667
+ const i = r[Symbol.iterator]();
668
+ let a = false, o = false, u = e.at(-1), l = u === void 0 ? 0 : D2(u), n = i.next(), c = i.next(), p = 0;
669
+ for (; !n.done; ) {
670
+ const f = n.value, g = D2(f);
671
+ l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = true, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = false, o = false) : f === Ve && (a = false) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
672
+ }
673
+ u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
674
+ };
675
+ var St = (e) => {
676
+ const r = e.split(" ");
677
+ let s = r.length;
678
+ for (; s > 0 && !(D2(r[s - 1]) > 0); ) s--;
679
+ return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
680
+ };
681
+ var It2 = (e, r, s = {}) => {
682
+ if (s.trim !== false && e.trim() === "") return "";
683
+ let i = "", a, o;
684
+ const u = e.split(" "), l = Ct2(u);
685
+ let n = [""];
686
+ for (const [$, m] of u.entries()) {
687
+ s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
688
+ let d = D2(n.at(-1) ?? "");
689
+ if ($ !== 0 && (d >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), d = 0), (d > 0 || s.trim === false) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
690
+ const F = r - d, y2 = 1 + Math.floor((l[$] - F - 1) / r);
691
+ Math.floor((l[$] - 1) / r) < y2 && n.push(""), Ie(n, m, r);
692
+ continue;
693
+ }
694
+ if (d + l[$] > r && d > 0 && l[$] > 0) {
695
+ if (s.wordWrap === false && d < r) {
696
+ Ie(n, m, r);
697
+ continue;
698
+ }
699
+ n.push("");
700
+ }
701
+ if (d + l[$] > r && s.wordWrap === false) {
702
+ Ie(n, m, r);
703
+ continue;
704
+ }
705
+ n[n.length - 1] += m;
706
+ }
707
+ s.trim !== false && (n = n.map(($) => St($)));
708
+ const c = n.join(`
709
+ `), p = c[Symbol.iterator]();
710
+ let f = p.next(), g = p.next(), E = 0;
711
+ for (; !f.done; ) {
712
+ const $ = f.value, m = g.value;
713
+ if (i += $, $ === ae || $ === je) {
714
+ He.lastIndex = E + 1;
715
+ const y2 = He.exec(c)?.groups;
716
+ if (y2?.code !== void 0) {
717
+ const v = Number.parseFloat(y2.code);
718
+ a = v === vt2 ? void 0 : v;
719
+ } else y2?.uri !== void 0 && (o = y2.uri.length === 0 ? void 0 : y2.uri);
720
+ }
721
+ const d = a ? At2(a) : void 0;
722
+ m === `
723
+ ` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
724
+ ` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
725
+ }
726
+ return i;
727
+ };
728
+ function J2(e, r, s) {
729
+ return String(e).normalize().replaceAll(`\r
730
+ `, `
731
+ `).split(`
732
+ `).map((i) => It2(i, r, s)).join(`
733
+ `);
734
+ }
735
+ var bt2 = (e, r, s, i, a) => {
736
+ let o = r, u = 0;
737
+ for (let l = s; l < i; l++) {
738
+ const n = e[l];
739
+ if (o = o - n.length, u++, o <= a) break;
740
+ }
741
+ return { lineCount: o, removals: u };
742
+ };
743
+ var X2 = ({ cursor: e, options: r, style: s, output: i = process.stdout, maxItems: a = Number.POSITIVE_INFINITY, columnPadding: o = 0, rowPadding: u = 4 }) => {
744
+ const l = rt(i) - o, n = nt(i), c = t("dim", "..."), p = Math.max(n - u, 0), f = Math.max(Math.min(a, p), 5);
745
+ let g = 0;
746
+ e >= f - 3 && (g = Math.max(Math.min(e - f + 3, r.length - f), 0));
747
+ let E = f < r.length && g > 0, $ = f < r.length && g + f < r.length;
748
+ const m = Math.min(g + f, r.length), d = [];
749
+ let F = 0;
750
+ E && F++, $ && F++;
751
+ const y2 = g + (E ? 1 : 0), v = m - ($ ? 1 : 0);
752
+ for (let A = y2; A < v; A++) {
753
+ const b = J2(s(r[A], A === e), l, { hard: true, trim: false }).split(`
754
+ `);
755
+ d.push(b), F += b.length;
756
+ }
757
+ if (F > p) {
758
+ let A = 0, b = 0, w = F;
759
+ const S2 = e - y2, T2 = (M2, O2) => bt2(d, w, M2, O2, p);
760
+ E ? ({ lineCount: w, removals: A } = T2(0, S2), w > p && ({ lineCount: w, removals: b } = T2(S2 + 1, d.length))) : ({ lineCount: w, removals: b } = T2(S2 + 1, d.length), w > p && ({ lineCount: w, removals: A } = T2(0, S2))), A > 0 && (E = true, d.splice(0, A)), b > 0 && ($ = true, d.splice(d.length - b, b));
761
+ }
762
+ const C = [];
763
+ E && C.push(c);
764
+ for (const A of d) for (const b of A) C.push(b);
765
+ return $ && C.push(c), C;
766
+ };
767
+ var Rt = (e) => {
768
+ const r = e.active ?? "Yes", s = e.inactive ?? "No";
769
+ return new kt({ active: r, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
770
+ const i = e.withGuide ?? _.withGuide, a = `${i ? `${t("gray", h)}
771
+ ` : ""}${W2(this.state)} ${e.message}
772
+ `, o = this.value ? r : s;
773
+ switch (this.state) {
774
+ case "submit": {
775
+ const u = i ? `${t("gray", h)} ` : "";
776
+ return `${a}${u}${t("dim", o)}`;
777
+ }
778
+ case "cancel": {
779
+ const u = i ? `${t("gray", h)} ` : "";
780
+ return `${a}${u}${t(["strikethrough", "dim"], o)}${i ? `
781
+ ${t("gray", h)}` : ""}`;
782
+ }
783
+ default: {
784
+ const u = i ? `${t("cyan", h)} ` : "", l = i ? t("cyan", x2) : "";
785
+ return `${a}${u}${this.value ? `${t("green", z2)} ${r}` : `${t("dim", H2)} ${t("dim", r)}`}${e.vertical ? i ? `
786
+ ${t("cyan", h)} ` : `
787
+ ` : ` ${t("dim", "/")} `}${this.value ? `${t("dim", H2)} ${t("dim", s)}` : `${t("green", z2)} ${s}`}
788
+ ${l}
789
+ `;
790
+ }
791
+ }
792
+ } }).prompt();
793
+ };
794
+ var Wt2 = (e = "", r) => {
795
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${t("gray", he)} ` : "";
796
+ s.write(`${i}${e}
797
+ `);
798
+ };
799
+ var Gt = (e = "", r) => {
800
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${t("gray", h)}
801
+ ${t("gray", x2)} ` : "";
802
+ s.write(`${i}${e}
803
+
804
+ `);
805
+ };
806
+ var Q2 = (e, r) => e.split(`
807
+ `).map((s) => r(s)).join(`
808
+ `);
809
+ var Lt2 = (e) => {
810
+ const r = (i, a) => {
811
+ const o = i.label ?? String(i.value);
812
+ return a === "disabled" ? `${t("gray", q2)} ${Q2(o, (u) => t(["strikethrough", "gray"], u))}${i.hint ? ` ${t("dim", `(${i.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${t("cyan", te)} ${o}${i.hint ? ` ${t("dim", `(${i.hint})`)}` : ""}` : a === "selected" ? `${t("green", U2)} ${Q2(o, (u) => t("dim", u))}${i.hint ? ` ${t("dim", `(${i.hint})`)}` : ""}` : a === "cancelled" ? `${Q2(o, (u) => t(["strikethrough", "dim"], u))}` : a === "active-selected" ? `${t("green", U2)} ${o}${i.hint ? ` ${t("dim", `(${i.hint})`)}` : ""}` : a === "submitted" ? `${Q2(o, (u) => t("dim", u))}` : `${t("dim", q2)} ${Q2(o, (u) => t("dim", u))}`;
813
+ }, s = e.required ?? true;
814
+ return new Lt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValues: e.initialValues, required: s, cursorAt: e.cursorAt, validate(i) {
815
+ if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
816
+ ${t("reset", t("dim", `Press ${t(["gray", "bgWhite", "inverse"], " space ")} to select, ${t("gray", t("bgWhite", t("inverse", " enter ")))} to submit`))}`;
817
+ }, render() {
818
+ const i = Bt(e.output, e.message, `${ve(this.state)} `, `${W2(this.state)} `), a = `${t("gray", h)}
819
+ ${i}
820
+ `, o = this.value ?? [], u = (l, n) => {
821
+ if (l.disabled) return r(l, "disabled");
822
+ const c = o.includes(l.value);
823
+ return n && c ? r(l, "active-selected") : c ? r(l, "selected") : r(l, n ? "active" : "inactive");
824
+ };
825
+ switch (this.state) {
826
+ case "submit": {
827
+ const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "submitted")).join(t("dim", ", ")) || t("dim", "none"), n = Bt(e.output, l, `${t("gray", h)} `);
828
+ return `${a}${n}`;
829
+ }
830
+ case "cancel": {
831
+ const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "cancelled")).join(t("dim", ", "));
832
+ if (l.trim() === "") return `${a}${t("gray", h)}`;
833
+ const n = Bt(e.output, l, `${t("gray", h)} `);
834
+ return `${a}${n}
835
+ ${t("gray", h)}`;
836
+ }
837
+ case "error": {
838
+ const l = `${t("yellow", h)} `, n = this.error.split(`
839
+ `).map((f, g) => g === 0 ? `${t("yellow", x2)} ${t("yellow", f)}` : ` ${f}`).join(`
840
+ `), c = a.split(`
841
+ `).length, p = n.split(`
842
+ `).length + 1;
843
+ return `${a}${l}${X2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: l.length, rowPadding: c + p, style: u }).join(`
844
+ ${l}`)}
845
+ ${n}
846
+ `;
847
+ }
848
+ default: {
849
+ const l = `${t("cyan", h)} `, n = a.split(`
850
+ `).length;
851
+ return `${a}${l}${X2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: l.length, rowPadding: n + 2, style: u }).join(`
852
+ ${l}`)}
853
+ ${t("cyan", x2)}
854
+ `;
855
+ }
856
+ }
857
+ } }).prompt();
858
+ };
859
+ var jt = (e) => t("dim", e);
860
+ var kt2 = (e, r, s) => {
861
+ const i = { hard: true, trim: false }, a = J2(e, r, i).split(`
862
+ `), o = a.reduce((n, c) => Math.max(D2(c), n), 0), u = a.map(s).reduce((n, c) => Math.max(D2(c), n), 0), l = r - (u - o);
863
+ return J2(e, l, i);
864
+ };
865
+ var Vt2 = (e = "", r = "", s) => {
866
+ const i = s?.output ?? N2.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? jt, u = ["", ...kt2(e, rt(i) - 6, o).split(`
867
+ `).map(o), ""], l = D2(r), n = Math.max(u.reduce((g, E) => {
868
+ const $ = D2(E);
869
+ return $ > g ? $ : g;
870
+ }, 0), l) + 2, c = u.map((g) => `${t("gray", h)} ${g}${" ".repeat(n - D2(g))}${t("gray", h)}`).join(`
871
+ `), p = a ? `${t("gray", h)}
872
+ ` : "", f = a ? We : ge;
873
+ i.write(`${p}${t("green", V)} ${t("reset", r)} ${t("gray", se.repeat(Math.max(n - l - 1, 1)) + pe)}
874
+ ${c}
875
+ ${t("gray", f + se.repeat(n + 2) + me)}
876
+ `);
877
+ };
878
+ var ze = { light: I2("\u2500", "-"), heavy: I2("\u2501", "="), block: I2("\u2588", "#") };
879
+ var oe = (e, r) => e.includes(`
880
+ `) ? e.split(`
881
+ `).map((s) => r(s)).join(`
882
+ `) : r(e);
883
+ var Jt = (e) => {
884
+ const r = (s, i) => {
885
+ const a = s.label ?? String(s.value);
886
+ switch (i) {
887
+ case "disabled":
888
+ return `${t("gray", H2)} ${oe(a, (o) => t("gray", o))}${s.hint ? ` ${t("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
889
+ case "selected":
890
+ return `${oe(a, (o) => t("dim", o))}`;
891
+ case "active":
892
+ return `${t("green", z2)} ${a}${s.hint ? ` ${t("dim", `(${s.hint})`)}` : ""}`;
893
+ case "cancelled":
894
+ return `${oe(a, (o) => t(["strikethrough", "dim"], o))}`;
895
+ default:
896
+ return `${t("dim", H2)} ${oe(a, (o) => t("dim", o))}`;
897
+ }
898
+ };
899
+ return new Tt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
900
+ const s = e.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${ve(this.state)} `, o = Bt(e.output, e.message, a, i), u = `${s ? `${t("gray", h)}
901
+ ` : ""}${o}
902
+ `;
903
+ switch (this.state) {
904
+ case "submit": {
905
+ const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "selected"), l);
906
+ return `${u}${n}`;
907
+ }
908
+ case "cancel": {
909
+ const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "cancelled"), l);
910
+ return `${u}${n}${s ? `
911
+ ${t("gray", h)}` : ""}`;
912
+ }
913
+ default: {
914
+ const l = s ? `${t("cyan", h)} ` : "", n = s ? t("cyan", x2) : "", c = u.split(`
915
+ `).length, p = s ? 2 : 1;
916
+ return `${u}${l}${X2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: l.length, rowPadding: c + p, style: (f, g) => r(f, f.disabled ? "disabled" : g ? "active" : "inactive") }).join(`
917
+ ${l}`)}
918
+ ${n}
919
+ `;
920
+ }
921
+ }
922
+ } }).prompt();
923
+ };
924
+ var Qe = `${t("gray", h)} `;
925
+
926
+ // src/utils.ts
927
+ import { createHash } from "crypto";
928
+ import {
929
+ existsSync,
930
+ mkdirSync,
931
+ readFileSync,
932
+ readdirSync,
933
+ rmdirSync,
934
+ rmSync,
935
+ statSync,
936
+ writeFileSync
937
+ } from "fs";
938
+ import path from "path";
939
+ import { fileURLToPath } from "url";
940
+ var PACKAGE_ROOT = findPackageRoot(import.meta.url);
941
+ var TEMPLATE_ROOT = resolveTemplateRoot(PACKAGE_ROOT);
942
+ function findPackageRoot(fromUrl) {
943
+ let current = path.dirname(fileURLToPath(fromUrl));
944
+ while (!existsSync(path.join(current, "package.json"))) {
945
+ const parent = path.dirname(current);
946
+ if (parent === current) {
947
+ throw new Error("Could not locate package.json from current module.");
948
+ }
949
+ current = parent;
950
+ }
951
+ return current;
952
+ }
953
+ function resolveTemplateRoot(packageRoot) {
954
+ const sibling = path.resolve(packageRoot, "..", "docs", "template");
955
+ if (existsSync(sibling)) {
956
+ return sibling;
957
+ }
958
+ const bundled = path.join(packageRoot, "template");
959
+ if (existsSync(bundled)) {
960
+ return bundled;
961
+ }
962
+ throw new Error(
963
+ `Could not locate template root. Tried ${sibling} and ${bundled}.`
964
+ );
965
+ }
966
+ function readPackageFile(relativePath) {
967
+ if (relativePath === "package.json") {
968
+ return readTextFile(path.join(PACKAGE_ROOT, relativePath));
969
+ }
970
+ return readTextFile(path.join(TEMPLATE_ROOT, relativePath));
971
+ }
972
+ function readTextFile(filePath) {
973
+ return readFileSync(filePath, "utf8");
974
+ }
975
+ function writeTextFile(filePath, content) {
976
+ ensureParentDir(filePath);
977
+ writeFileSync(filePath, content, "utf8");
978
+ }
979
+ function ensureParentDir(filePath) {
980
+ mkdirSync(path.dirname(filePath), { recursive: true });
981
+ }
982
+ function normalizeRelativePath(relativePath) {
983
+ return relativePath.split(path.sep).join("/");
984
+ }
985
+ function hashText(content) {
986
+ return createHash("sha256").update(content).digest("hex");
987
+ }
988
+ function readPackageMeta() {
989
+ const raw = JSON.parse(readPackageFile("package.json"));
990
+ return { name: raw.name, version: raw.version };
991
+ }
992
+ function createRunId(now = /* @__PURE__ */ new Date()) {
993
+ return now.toISOString().replace(/[:.]/g, "-");
994
+ }
995
+ function pruneEmptyDirectories(startDir, stopDir) {
996
+ let current = startDir;
997
+ const boundary = path.resolve(stopDir);
998
+ while (current.startsWith(boundary) && current !== boundary) {
999
+ if (!existsSync(current)) {
1000
+ current = path.dirname(current);
1001
+ continue;
1002
+ }
1003
+ const entries = readdirSync(current);
1004
+ if (entries.length > 0) {
1005
+ break;
1006
+ }
1007
+ rmSync(current, { recursive: true, force: true });
1008
+ current = path.dirname(current);
1009
+ }
1010
+ }
1011
+ function removeFileIfPresent(filePath) {
1012
+ if (!existsSync(filePath)) {
1013
+ return false;
1014
+ }
1015
+ const stats = statSync(filePath);
1016
+ if (!stats.isFile()) {
1017
+ throw new Error(`Expected a regular file at ${filePath}, but found a different entry type.`);
1018
+ }
1019
+ rmSync(filePath, { force: false });
1020
+ return true;
1021
+ }
1022
+ function pruneDirectoryIfEmpty(directoryPath) {
1023
+ if (!existsSync(directoryPath)) {
1024
+ return false;
1025
+ }
1026
+ const stats = statSync(directoryPath);
1027
+ if (!stats.isDirectory()) {
1028
+ throw new Error(`Expected a directory at ${directoryPath}, but found a different entry type.`);
1029
+ }
1030
+ if (readdirSync(directoryPath).length > 0) {
1031
+ return false;
1032
+ }
1033
+ rmdirSync(directoryPath);
1034
+ return true;
1035
+ }
1036
+ function formatInlineList(items) {
1037
+ if (items.length === 0) {
1038
+ return "";
1039
+ }
1040
+ if (items.length === 1) {
1041
+ return items[0];
1042
+ }
1043
+ if (items.length === 2) {
1044
+ return `${items[0]} and ${items[1]}`;
1045
+ }
1046
+ return `${items.slice(0, -1).join(", ")}, and ${items.at(-1)}`;
1047
+ }
1048
+ function relativePathToTarget(targetDir, relativePath) {
1049
+ return path.isAbsolute(relativePath) ? path.normalize(relativePath) : path.join(targetDir, relativePath);
1050
+ }
1051
+
1052
+ // src/skill-registry.ts
1053
+ import path2 from "path";
1054
+ var REGISTRY_FILENAME = "skill-registry.json";
1055
+ function loadSkillRegistry(packageRoot) {
1056
+ const registryPath = path2.join(packageRoot, REGISTRY_FILENAME);
1057
+ let raw;
1058
+ try {
1059
+ raw = readTextFile(registryPath);
1060
+ } catch (cause) {
1061
+ throw new Error(`Skill registry not found at ${registryPath}`, { cause });
1062
+ }
1063
+ let parsed;
1064
+ try {
1065
+ parsed = JSON.parse(raw);
1066
+ } catch (cause) {
1067
+ throw new Error(`Skill registry at ${registryPath} is not valid JSON`, {
1068
+ cause
1069
+ });
1070
+ }
1071
+ if (!isPlainObject(parsed) || !Array.isArray(parsed.skills)) {
1072
+ throw new Error(
1073
+ `Skill registry at ${registryPath} must have a \`skills\` array`
1074
+ );
1075
+ }
1076
+ const skills = [];
1077
+ for (const [index, entry] of parsed.skills.entries()) {
1078
+ const validated = validateEntry(entry, index);
1079
+ if (validated) {
1080
+ skills.push(validated);
1081
+ }
1082
+ }
1083
+ return { skills };
1084
+ }
1085
+ function getSkillRegistryNames(registry) {
1086
+ return registry.skills.map((skill) => skill.name).sort();
1087
+ }
1088
+ function validateEntry(entry, index) {
1089
+ if (!isPlainObject(entry)) {
1090
+ console.warn(
1091
+ `Skill registry entry at index ${index} is not an object; skipping.`
1092
+ );
1093
+ return null;
1094
+ }
1095
+ const name = readRequiredString(entry, "name", `entry at index ${index}`);
1096
+ if (name === null) return null;
1097
+ const source = readRequiredString(entry, "source", `entry \`${name}\``);
1098
+ const entryPoint = readRequiredString(
1099
+ entry,
1100
+ "entryPoint",
1101
+ `entry \`${name}\``
1102
+ );
1103
+ const installName = readRequiredString(
1104
+ entry,
1105
+ "installName",
1106
+ `entry \`${name}\``
1107
+ );
1108
+ if (source === null || entryPoint === null || installName === null)
1109
+ return null;
1110
+ if (!isRemoteSource(source)) {
1111
+ console.warn(
1112
+ `Skill registry entry \`${name}\` must use a remote source URL; skipping.`
1113
+ );
1114
+ return null;
1115
+ }
1116
+ if (!Array.isArray(entry.assets)) {
1117
+ console.warn(
1118
+ `Skill registry entry \`${name}\` is missing \`assets\` array; skipping.`
1119
+ );
1120
+ return null;
1121
+ }
1122
+ const assets = [];
1123
+ for (const [assetIndex, asset] of entry.assets.entries()) {
1124
+ if (!isPlainObject(asset) || typeof asset.source !== "string" || typeof asset.installPath !== "string") {
1125
+ console.warn(
1126
+ `Skill \`${name}\` asset at index ${assetIndex} is invalid; skipping asset.`
1127
+ );
1128
+ continue;
1129
+ }
1130
+ assets.push({ source: asset.source, installPath: asset.installPath });
1131
+ }
1132
+ return {
1133
+ name,
1134
+ source,
1135
+ entryPoint,
1136
+ installName,
1137
+ description: typeof entry.description === "string" ? entry.description : "",
1138
+ assets
1139
+ };
1140
+ }
1141
+ function readRequiredString(entry, field, context) {
1142
+ const value = entry[field];
1143
+ if (typeof value !== "string" || value.length === 0) {
1144
+ console.warn(
1145
+ `Skill registry ${context} is missing required field \`${field}\`; skipping.`
1146
+ );
1147
+ return null;
1148
+ }
1149
+ return value;
1150
+ }
1151
+ function isPlainObject(value) {
1152
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1153
+ }
1154
+ function isRemoteSource(source) {
1155
+ return source.startsWith("https://") || source.startsWith("http://") || source.startsWith("github:") || source.startsWith("url:");
1156
+ }
1157
+
1158
+ // src/types.ts
1159
+ var CAPABILITIES = ["designs", "plans", "prd", "work"];
1160
+ var INSTRUCTION_KINDS = ["AGENTS.md", "CLAUDE.md"];
1161
+ var HARNESSES = ["claude-code", "codex"];
1162
+ var HARNESS_TO_INSTRUCTION = {
1163
+ "claude-code": "CLAUDE.md",
1164
+ codex: "AGENTS.md"
1165
+ };
1166
+ function getActiveInstructionKinds(selections) {
1167
+ const active = /* @__PURE__ */ new Set();
1168
+ for (const harness of HARNESSES) {
1169
+ if (selections.harnesses[harness]) {
1170
+ active.add(HARNESS_TO_INSTRUCTION[harness]);
1171
+ }
1172
+ }
1173
+ return active;
1174
+ }
1175
+
1176
+ // src/profile.ts
1177
+ var CAPABILITY_DEPENDENCIES = {
1178
+ designs: [],
1179
+ plans: [],
1180
+ prd: ["plans"],
1181
+ work: ["plans", "prd"]
1182
+ };
1183
+ function defaultSelections() {
1184
+ return {
1185
+ capabilities: {
1186
+ designs: true,
1187
+ plans: true,
1188
+ prd: true,
1189
+ work: true
1190
+ },
1191
+ harnesses: {
1192
+ "claude-code": true,
1193
+ codex: true
1194
+ },
1195
+ skills: true,
1196
+ skillScope: "project",
1197
+ selectedSkills: getDefaultSelectedSkills()
1198
+ };
1199
+ }
1200
+ function cloneSelections(selections) {
1201
+ return structuredClone(selections);
1202
+ }
1203
+ function resolveCapabilityState(selections) {
1204
+ const state = {};
1205
+ for (const capability of CAPABILITIES) {
1206
+ const missingPrerequisites = CAPABILITY_DEPENDENCIES[capability].filter(
1207
+ (dependency) => !state[dependency]?.effectiveSelection
1208
+ );
1209
+ const explicitSelection = selections.capabilities[capability];
1210
+ const effectiveSelection = explicitSelection && missingPrerequisites.length === 0;
1211
+ state[capability] = {
1212
+ explicitSelection,
1213
+ effectiveSelection,
1214
+ missingPrerequisites,
1215
+ disabledReason: missingPrerequisites.length > 0 ? `${capability} requires ${formatInlineList(missingPrerequisites)}` : void 0
1216
+ };
1217
+ }
1218
+ return state;
1219
+ }
1220
+ function resolveInstallProfile(selections) {
1221
+ const capabilityState = resolveCapabilityState(selections);
1222
+ const effectiveCapabilities = CAPABILITIES.filter(
1223
+ (capability) => capabilityState[capability].effectiveSelection
1224
+ );
1225
+ const profileId = hashText(
1226
+ JSON.stringify({
1227
+ capabilities: capabilityState,
1228
+ harnesses: selections.harnesses,
1229
+ skills: selections.skills,
1230
+ skillScope: selections.skillScope,
1231
+ selectedSkills: [...selections.selectedSkills].sort()
1232
+ })
1233
+ ).slice(0, 16);
1234
+ return {
1235
+ selections,
1236
+ capabilityState,
1237
+ effectiveCapabilities,
1238
+ profileId
1239
+ };
1240
+ }
1241
+ function hasEffectiveCapabilities(profile) {
1242
+ return profile.effectiveCapabilities.length > 0;
1243
+ }
1244
+ function isFullDefaultProfile(profile) {
1245
+ return CAPABILITIES.every(
1246
+ (capability) => profile.capabilityState[capability].effectiveSelection
1247
+ ) && profile.selections.harnesses["claude-code"] && profile.selections.harnesses.codex && profile.selections.skills && profile.selections.skillScope === "project" && arraysEqual(
1248
+ [...profile.selections.selectedSkills].sort(),
1249
+ getDefaultSelectedSkills()
1250
+ );
1251
+ }
1252
+ function getDefaultSelectedSkills() {
1253
+ return getSkillRegistryNames(loadSkillRegistry(PACKAGE_ROOT));
1254
+ }
1255
+ function arraysEqual(left, right) {
1256
+ return left.length === right.length && left.every((value, index) => value === right[index]);
1257
+ }
1258
+
1259
+ // src/manifest.ts
1260
+ import os from "os";
1261
+ import { existsSync as existsSync2 } from "fs";
1262
+ import path3 from "path";
1263
+ var MANIFEST_SCHEMA_VERSION = 1;
1264
+ var MAKE_DOCS_STATE_RELATIVE_DIR = ".make-docs";
1265
+ var MANIFEST_RELATIVE_PATH = `${MAKE_DOCS_STATE_RELATIVE_DIR}/manifest.json`;
1266
+ var CONFLICTS_RELATIVE_DIR = `${MAKE_DOCS_STATE_RELATIVE_DIR}/conflicts`;
1267
+ function getManifestPath(targetDir) {
1268
+ return path3.join(targetDir, MANIFEST_RELATIVE_PATH);
1269
+ }
1270
+ function loadManifest(targetDir) {
1271
+ const manifestPath = getManifestPath(targetDir);
1272
+ if (!existsSync2(manifestPath)) {
1273
+ return null;
1274
+ }
1275
+ const parsed = JSON.parse(readTextFile(manifestPath));
1276
+ return validateAndMigrateManifest(parsed, manifestPath);
1277
+ }
1278
+ function migrateSelections(selections) {
1279
+ assertPlainObject(selections, "selections");
1280
+ assertNoRemovedAssetFields(selections, "selections");
1281
+ const legacy = selections;
1282
+ if ("optionalSkills" in legacy) {
1283
+ throw new Error("selections.optionalSkills is no longer supported");
1284
+ }
1285
+ const selectedSkills = validateSelectedSkills(legacy.selectedSkills);
1286
+ if (legacy.instructionKinds && !legacy.harnesses) {
1287
+ assertPlainObject(legacy.instructionKinds, "selections.instructionKinds");
1288
+ const ik = legacy.instructionKinds;
1289
+ const migrated = {
1290
+ capabilities: validateCapabilities(legacy.capabilities),
1291
+ harnesses: {
1292
+ "claude-code": validateBoolean(
1293
+ ik["CLAUDE.md"] ?? false,
1294
+ "selections.instructionKinds.CLAUDE.md"
1295
+ ),
1296
+ codex: validateBoolean(
1297
+ ik["AGENTS.md"] ?? false,
1298
+ "selections.instructionKinds.AGENTS.md"
1299
+ )
1300
+ },
1301
+ skills: legacy.skills === void 0 ? true : validateBoolean(legacy.skills, "selections.skills"),
1302
+ skillScope: validateSkillScope(legacy.skillScope ?? "project"),
1303
+ selectedSkills
1304
+ };
1305
+ return migrated;
1306
+ }
1307
+ return {
1308
+ capabilities: validateCapabilities(legacy.capabilities),
1309
+ harnesses: validateHarnesses(legacy.harnesses),
1310
+ skills: validateBoolean(legacy.skills, "selections.skills"),
1311
+ skillScope: validateSkillScope(legacy.skillScope ?? "project"),
1312
+ selectedSkills
1313
+ };
1314
+ }
1315
+ function createManifest(packageMeta, profile, files, skillFiles) {
1316
+ return {
1317
+ schemaVersion: MANIFEST_SCHEMA_VERSION,
1318
+ packageName: packageMeta.name,
1319
+ packageVersion: packageMeta.version,
1320
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1321
+ profileId: profile.profileId,
1322
+ selections: profile.selections,
1323
+ effectiveCapabilities: profile.effectiveCapabilities,
1324
+ files,
1325
+ skillFiles: Array.from(new Set(skillFiles)).sort()
1326
+ };
1327
+ }
1328
+ function writeManifest(targetDir, manifest) {
1329
+ const manifestPath = getManifestPath(targetDir);
1330
+ writeTextFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
1331
+ `);
1332
+ return manifestPath;
1333
+ }
1334
+ function getManifestAuditContext(targetDir, manifest, homeDir = os.homedir()) {
1335
+ const managedFiles = Object.entries(manifest.files).map(
1336
+ ([managedPath, entry]) => createManifestAuditRecord(
1337
+ targetDir,
1338
+ homeDir,
1339
+ managedPath,
1340
+ "manifest-file",
1341
+ entry
1342
+ )
1343
+ ).sort(compareAuditRecords);
1344
+ const skillFiles = Array.from(new Set(manifest.skillFiles)).map(
1345
+ (managedPath) => createManifestAuditRecord(
1346
+ targetDir,
1347
+ homeDir,
1348
+ managedPath,
1349
+ "manifest-skill-file",
1350
+ manifest.files[managedPath]
1351
+ )
1352
+ ).sort(compareAuditRecords);
1353
+ return {
1354
+ manifestPath: getManifestPath(targetDir),
1355
+ managedFiles,
1356
+ skillFiles,
1357
+ priorSelections: structuredClone(manifest.selections)
1358
+ };
1359
+ }
1360
+ function createAuditPathMetadata(targetDir, auditPath, kind, homeDir = os.homedir()) {
1361
+ const normalizedTargetDir = path3.resolve(targetDir);
1362
+ const absolutePath = path3.isAbsolute(auditPath) ? path3.normalize(auditPath) : path3.resolve(normalizedTargetDir, auditPath);
1363
+ const normalizedHomeDir = path3.resolve(homeDir);
1364
+ const projectRelativePath = getContainedRelativePath(
1365
+ normalizedTargetDir,
1366
+ absolutePath
1367
+ );
1368
+ const homeRelativePath = getContainedRelativePath(
1369
+ normalizedHomeDir,
1370
+ absolutePath
1371
+ );
1372
+ const pathScope = projectRelativePath !== null ? "project" : homeRelativePath !== null ? "home" : "external";
1373
+ const displayPath = pathScope === "project" ? normalizeRelativePath(projectRelativePath ?? auditPath) : normalizeRelativePath(absolutePath);
1374
+ const backupRelativePath = pathScope === "project" ? normalizeRelativePath(projectRelativePath ?? auditPath) : pathScope === "home" ? normalizeRelativePath(path3.join("_home", homeRelativePath ?? "")) : null;
1375
+ const depth = displayPath === "." ? 0 : displayPath.split("/").filter((segment) => segment.length > 0).length;
1376
+ const scopeOrder = pathScope === "project" ? 0 : pathScope === "home" ? 1 : 2;
1377
+ return {
1378
+ path: displayPath,
1379
+ absolutePath,
1380
+ kind,
1381
+ scope: pathScope,
1382
+ pathScope,
1383
+ backupRelativePath,
1384
+ backup: {
1385
+ scope: pathScope === "external" ? null : pathScope,
1386
+ relativePath: backupRelativePath
1387
+ },
1388
+ ordering: {
1389
+ scopeOrder,
1390
+ depth,
1391
+ sortKey: `${scopeOrder}:${displayPath}`,
1392
+ pruneSortKey: `${scopeOrder}:${String(1e4 - depth).padStart(5, "0")}:${displayPath}`
1393
+ }
1394
+ };
1395
+ }
1396
+ function migrateSkillFiles(skillFiles) {
1397
+ if (Array.isArray(skillFiles)) {
1398
+ return skillFiles.filter(
1399
+ (value) => typeof value === "string"
1400
+ );
1401
+ }
1402
+ if (isPlainObject2(skillFiles)) {
1403
+ return Object.keys(skillFiles);
1404
+ }
1405
+ return [];
1406
+ }
1407
+ function validateAndMigrateManifest(value, manifestPath) {
1408
+ try {
1409
+ assertPlainObject(value, "manifest");
1410
+ assertNoRemovedAssetFields(value, "manifest");
1411
+ if (!("skillFiles" in value)) {
1412
+ throw new Error("manifest.skillFiles is required");
1413
+ }
1414
+ const skillFiles = migrateSkillFiles(value.skillFiles);
1415
+ const selections = migrateSelections(value.selections);
1416
+ const files = validateManifestFiles(value.files);
1417
+ const schemaVersion = validateNumber(
1418
+ value.schemaVersion,
1419
+ "manifest.schemaVersion"
1420
+ );
1421
+ if (schemaVersion !== MANIFEST_SCHEMA_VERSION) {
1422
+ throw new Error(
1423
+ `manifest.schemaVersion must be ${MANIFEST_SCHEMA_VERSION}`
1424
+ );
1425
+ }
1426
+ return {
1427
+ schemaVersion,
1428
+ packageName: validateString(value.packageName, "manifest.packageName"),
1429
+ packageVersion: validateString(
1430
+ value.packageVersion,
1431
+ "manifest.packageVersion"
1432
+ ),
1433
+ updatedAt: validateString(value.updatedAt, "manifest.updatedAt"),
1434
+ profileId: validateString(value.profileId, "manifest.profileId"),
1435
+ selections,
1436
+ effectiveCapabilities: validateEffectiveCapabilities(
1437
+ value.effectiveCapabilities
1438
+ ),
1439
+ files,
1440
+ skillFiles
1441
+ };
1442
+ } catch (error) {
1443
+ const reason = error instanceof Error ? error.message : "invalid manifest shape";
1444
+ throw new Error(
1445
+ `Stale or malformed make-docs manifest at ${manifestPath}: ${reason}. Fix or remove the stale manifest and rerun bare \`make-docs\` to rebuild it.`
1446
+ );
1447
+ }
1448
+ }
1449
+ function assertNoRemovedAssetFields(value, label) {
1450
+ for (const field of ["prompts", "templatesMode", "referencesMode"]) {
1451
+ if (field in value) {
1452
+ throw new Error(`${label}.${field} is no longer supported`);
1453
+ }
1454
+ }
1455
+ }
1456
+ function validateCapabilities(value) {
1457
+ assertPlainObject(value, "selections.capabilities");
1458
+ const capabilities = {};
1459
+ for (const capability of CAPABILITIES) {
1460
+ capabilities[capability] = validateBoolean(
1461
+ value[capability],
1462
+ `selections.capabilities.${capability}`
1463
+ );
1464
+ }
1465
+ return capabilities;
1466
+ }
1467
+ function validateHarnesses(value) {
1468
+ assertPlainObject(value, "selections.harnesses");
1469
+ const harnesses = {};
1470
+ for (const harness of HARNESSES) {
1471
+ harnesses[harness] = validateBoolean(
1472
+ value[harness],
1473
+ `selections.harnesses.${harness}`
1474
+ );
1475
+ }
1476
+ return harnesses;
1477
+ }
1478
+ function validateSkillScope(value) {
1479
+ if (value !== "project" && value !== "global") {
1480
+ throw new Error("selections.skillScope must be project or global");
1481
+ }
1482
+ return value;
1483
+ }
1484
+ function validateManifestFiles(value) {
1485
+ assertPlainObject(value, "manifest.files");
1486
+ const files = {};
1487
+ for (const [managedPath, entry] of Object.entries(value)) {
1488
+ assertPlainObject(entry, `manifest.files.${managedPath}`);
1489
+ files[managedPath] = {
1490
+ hash: validateString(entry.hash, `manifest.files.${managedPath}.hash`),
1491
+ sourceId: validateString(
1492
+ entry.sourceId,
1493
+ `manifest.files.${managedPath}.sourceId`
1494
+ )
1495
+ };
1496
+ }
1497
+ return files;
1498
+ }
1499
+ function validateEffectiveCapabilities(value) {
1500
+ if (!Array.isArray(value)) {
1501
+ throw new Error("manifest.effectiveCapabilities must be an array");
1502
+ }
1503
+ return value.map((capability, index) => {
1504
+ if (typeof capability !== "string" || !CAPABILITIES.includes(capability)) {
1505
+ throw new Error(
1506
+ `manifest.effectiveCapabilities.${index} must be a valid capability`
1507
+ );
1508
+ }
1509
+ return capability;
1510
+ });
1511
+ }
1512
+ function validateString(value, label) {
1513
+ if (typeof value !== "string") {
1514
+ throw new Error(`${label} must be a string`);
1515
+ }
1516
+ return value;
1517
+ }
1518
+ function validateNumber(value, label) {
1519
+ if (typeof value !== "number") {
1520
+ throw new Error(`${label} must be a number`);
1521
+ }
1522
+ return value;
1523
+ }
1524
+ function validateBoolean(value, label) {
1525
+ if (typeof value !== "boolean") {
1526
+ throw new Error(`${label} must be a boolean`);
1527
+ }
1528
+ return value;
1529
+ }
1530
+ function assertPlainObject(value, label) {
1531
+ if (!isPlainObject2(value)) {
1532
+ throw new Error(`${label} must be an object`);
1533
+ }
1534
+ }
1535
+ function validateSelectedSkills(value) {
1536
+ if (!Array.isArray(value)) {
1537
+ throw new Error("selections.selectedSkills must be an array");
1538
+ }
1539
+ return Array.from(
1540
+ new Set(
1541
+ value.map(
1542
+ (skill, index) => validateString(skill, `selections.selectedSkills.${index}`)
1543
+ )
1544
+ )
1545
+ ).sort();
1546
+ }
1547
+ function isPlainObject2(value) {
1548
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1549
+ }
1550
+ function createManifestAuditRecord(targetDir, homeDir, managedPath, ownershipSource, manifestEntry) {
1551
+ return {
1552
+ ...createAuditPathMetadata(targetDir, managedPath, "file", homeDir),
1553
+ ownershipSource,
1554
+ sourceId: manifestEntry?.sourceId,
1555
+ manifestHash: manifestEntry?.hash
1556
+ };
1557
+ }
1558
+ function compareAuditRecords(left, right) {
1559
+ return left.ordering.sortKey.localeCompare(right.ordering.sortKey);
1560
+ }
1561
+ function getContainedRelativePath(root, candidate) {
1562
+ const relative = path3.relative(root, candidate);
1563
+ if (relative === "") {
1564
+ return ".";
1565
+ }
1566
+ if (relative.startsWith("..") || path3.isAbsolute(relative)) {
1567
+ return null;
1568
+ }
1569
+ return relative;
1570
+ }
1571
+
1572
+ // src/rules.ts
1573
+ var PROMPT_RULES = [
1574
+ {
1575
+ relativePath: "docs/assets/prompts/docs-path-hygiene-cleanup.prompt.md",
1576
+ requires: []
1577
+ },
1578
+ {
1579
+ relativePath: "docs/assets/prompts/request-to-design.prompt.md",
1580
+ requires: ["designs"]
1581
+ },
1582
+ {
1583
+ relativePath: "docs/assets/prompts/designs-to-plan.prompt.md",
1584
+ requires: ["designs", "plans"]
1585
+ },
1586
+ {
1587
+ relativePath: "docs/assets/prompts/designs-to-plan-change.prompt.md",
1588
+ requires: ["designs", "plans"]
1589
+ },
1590
+ {
1591
+ relativePath: "docs/assets/prompts/plan-to-prd-change.prompt.md",
1592
+ requires: ["plans", "prd"]
1593
+ },
1594
+ {
1595
+ relativePath: "docs/assets/prompts/plan-to-prd-green-field.prompt.md",
1596
+ requires: ["plans", "prd"]
1597
+ },
1598
+ {
1599
+ relativePath: "docs/assets/prompts/prd-change-to-work.prompt.md",
1600
+ requires: ["prd", "work"]
1601
+ },
1602
+ {
1603
+ relativePath: "docs/assets/prompts/prd-to-work-full-prd.prompt.md",
1604
+ requires: ["prd", "work"]
1605
+ },
1606
+ {
1607
+ relativePath: "docs/assets/prompts/prd-to-work-prd-feature.prompt.md",
1608
+ requires: ["prd", "work"]
1609
+ },
1610
+ {
1611
+ relativePath: "docs/assets/prompts/work-to-guides.prompt.md",
1612
+ requires: ["work"]
1613
+ },
1614
+ {
1615
+ relativePath: "docs/assets/prompts/update-readme-green-field.prompt.md",
1616
+ requires: ["designs", "plans"]
1617
+ },
1618
+ {
1619
+ relativePath: "docs/assets/prompts/session-to-history-record.prompt.md",
1620
+ requires: []
1621
+ },
1622
+ {
1623
+ relativePath: "docs/assets/prompts/work-to-commit-message.prompt.md",
1624
+ requires: []
1625
+ }
1626
+ ];
1627
+ var PLAN_TEMPLATE_PATHS = [
1628
+ "docs/assets/templates/plan-overview.md",
1629
+ "docs/assets/templates/plan-prd.md",
1630
+ "docs/assets/templates/plan-prd-decompose.md",
1631
+ "docs/assets/templates/plan-prd-change.md"
1632
+ ];
1633
+ var PRD_TEMPLATE_PATHS = [
1634
+ "docs/assets/templates/prd-architecture.md",
1635
+ "docs/assets/templates/prd-change-addition.md",
1636
+ "docs/assets/templates/prd-change-revision.md",
1637
+ "docs/assets/templates/prd-glossary.md",
1638
+ "docs/assets/templates/prd-index.md",
1639
+ "docs/assets/templates/prd-overview.md",
1640
+ "docs/assets/templates/prd-reference.md",
1641
+ "docs/assets/templates/prd-risk-register.md",
1642
+ "docs/assets/templates/prd-subsystem.md"
1643
+ ];
1644
+ var WORK_TEMPLATE_PATHS = [
1645
+ "docs/assets/templates/work-index.md",
1646
+ "docs/assets/templates/work-phase.md"
1647
+ ];
1648
+ var ALWAYS_TEMPLATE_PATHS = [
1649
+ "docs/assets/templates/guide-developer.md",
1650
+ "docs/assets/templates/guide-user.md",
1651
+ "docs/assets/templates/history-record.md"
1652
+ ];
1653
+ var REQUIRED_REFERENCE_PATHS = {
1654
+ designs: ["docs/assets/references/design-workflow.md", "docs/assets/references/design-contract.md"],
1655
+ plans: [
1656
+ "docs/assets/references/planning-workflow.md",
1657
+ "docs/assets/references/output-contract.md",
1658
+ "docs/assets/references/prd-change-management.md"
1659
+ ],
1660
+ prd: [
1661
+ "docs/assets/references/execution-workflow.md",
1662
+ "docs/assets/references/output-contract.md",
1663
+ "docs/assets/references/prd-change-management.md"
1664
+ ],
1665
+ work: [
1666
+ "docs/assets/references/execution-workflow.md",
1667
+ "docs/assets/references/output-contract.md",
1668
+ "docs/assets/references/prd-change-management.md"
1669
+ ]
1670
+ };
1671
+ var ALWAYS_REFERENCE_PATHS = [
1672
+ "docs/assets/references/guide-contract.md",
1673
+ "docs/assets/references/wave-model.md",
1674
+ "docs/assets/references/history-record-contract.md",
1675
+ "docs/assets/references/commit-message-convention.md",
1676
+ "docs/assets/references/path-and-link-hygiene.md"
1677
+ ];
1678
+ var ALWAYS_SCRIPT_PATHS = [".make-docs/scripts/check_path_hygiene.py"];
1679
+ function profileHasCapabilities(profile, capabilities) {
1680
+ return capabilities.every(
1681
+ (capability) => profile.capabilityState[capability].effectiveSelection
1682
+ );
1683
+ }
1684
+ function getPromptPaths(profile) {
1685
+ return PROMPT_RULES.filter((rule) => profileHasCapabilities(profile, rule.requires)).map(
1686
+ (rule) => rule.relativePath
1687
+ );
1688
+ }
1689
+ function getScriptPaths(_profile) {
1690
+ return [...ALWAYS_SCRIPT_PATHS];
1691
+ }
1692
+ function getTemplatePaths(profile) {
1693
+ const paths = /* @__PURE__ */ new Set();
1694
+ for (const templatePath of ALWAYS_TEMPLATE_PATHS) {
1695
+ paths.add(templatePath);
1696
+ }
1697
+ if (profile.capabilityState.designs.effectiveSelection) {
1698
+ paths.add("docs/assets/templates/design.md");
1699
+ }
1700
+ if (profile.capabilityState.plans.effectiveSelection) {
1701
+ for (const templatePath of PLAN_TEMPLATE_PATHS) {
1702
+ paths.add(templatePath);
1703
+ }
1704
+ }
1705
+ if (profile.capabilityState.prd.effectiveSelection) {
1706
+ for (const templatePath of PRD_TEMPLATE_PATHS) {
1707
+ paths.add(templatePath);
1708
+ }
1709
+ }
1710
+ if (profile.capabilityState.work.effectiveSelection) {
1711
+ for (const templatePath of WORK_TEMPLATE_PATHS) {
1712
+ paths.add(templatePath);
1713
+ }
1714
+ }
1715
+ return Array.from(paths).sort();
1716
+ }
1717
+ function getReferencePaths(profile) {
1718
+ const paths = /* @__PURE__ */ new Set();
1719
+ for (const referencePath of ALWAYS_REFERENCE_PATHS) {
1720
+ paths.add(referencePath);
1721
+ }
1722
+ for (const capability of Object.keys(REQUIRED_REFERENCE_PATHS)) {
1723
+ if (profile.capabilityState[capability].effectiveSelection) {
1724
+ for (const referencePath of REQUIRED_REFERENCE_PATHS[capability]) {
1725
+ paths.add(referencePath);
1726
+ }
1727
+ }
1728
+ }
1729
+ if (profile.effectiveCapabilities.length > 0) {
1730
+ paths.add("docs/assets/references/harness-capability-matrix.md");
1731
+ }
1732
+ return Array.from(paths).sort();
1733
+ }
1734
+ function getReferenceDirInstalled(profile) {
1735
+ return getReferencePaths(profile).length > 0;
1736
+ }
1737
+ function getTemplateDirInstalled(profile) {
1738
+ return getTemplatePaths(profile).length > 0;
1739
+ }
1740
+ function getPromptsDirInstalled(profile) {
1741
+ return getPromptPaths(profile).length > 0;
1742
+ }
1743
+
1744
+ // src/renderers.ts
1745
+ var ROOT_INSTRUCTIONS = /* @__PURE__ */ new Set(["AGENTS.md", "CLAUDE.md"]);
1746
+ var DOCS_ROUTER_INSTRUCTIONS = /* @__PURE__ */ new Set(["docs/AGENTS.md", "docs/CLAUDE.md"]);
1747
+ var TEMPLATE_ROUTER_INSTRUCTIONS = /* @__PURE__ */ new Set([
1748
+ "docs/assets/templates/AGENTS.md",
1749
+ "docs/assets/templates/CLAUDE.md"
1750
+ ]);
1751
+ var PROMPTS_ROUTER_INSTRUCTIONS = /* @__PURE__ */ new Set([
1752
+ "docs/assets/prompts/AGENTS.md",
1753
+ "docs/assets/prompts/CLAUDE.md"
1754
+ ]);
1755
+ var REFERENCES_ROUTER_INSTRUCTIONS = /* @__PURE__ */ new Set([
1756
+ "docs/assets/references/AGENTS.md",
1757
+ "docs/assets/references/CLAUDE.md"
1758
+ ]);
1759
+ var ARCHIVE_ROUTER_INSTRUCTIONS = /* @__PURE__ */ new Set([
1760
+ "docs/assets/archive/AGENTS.md",
1761
+ "docs/assets/archive/CLAUDE.md"
1762
+ ]);
1763
+ var ASSETS_ROUTER_INSTRUCTIONS = /* @__PURE__ */ new Set([
1764
+ "docs/assets/AGENTS.md",
1765
+ "docs/assets/CLAUDE.md",
1766
+ "docs/assets/history/AGENTS.md",
1767
+ "docs/assets/history/CLAUDE.md"
1768
+ ]);
1769
+ var DESIGN_REFERENCE_RENDERERS = /* @__PURE__ */ new Set([
1770
+ "docs/assets/references/design-workflow.md",
1771
+ "docs/assets/references/design-contract.md",
1772
+ "docs/assets/templates/design.md"
1773
+ ]);
1774
+ var GUIDES_ROUTER_INSTRUCTIONS = /* @__PURE__ */ new Set([
1775
+ "docs/guides/AGENTS.md",
1776
+ "docs/guides/CLAUDE.md"
1777
+ ]);
1778
+ function isBuildablePath(relativePath) {
1779
+ return ROOT_INSTRUCTIONS.has(relativePath) || DOCS_ROUTER_INSTRUCTIONS.has(relativePath) || TEMPLATE_ROUTER_INSTRUCTIONS.has(relativePath) || PROMPTS_ROUTER_INSTRUCTIONS.has(relativePath) || REFERENCES_ROUTER_INSTRUCTIONS.has(relativePath) || ARCHIVE_ROUTER_INSTRUCTIONS.has(relativePath) || ASSETS_ROUTER_INSTRUCTIONS.has(relativePath) || DESIGN_REFERENCE_RENDERERS.has(relativePath) || GUIDES_ROUTER_INSTRUCTIONS.has(relativePath);
1780
+ }
1781
+ function renderBuildableAsset(relativePath, profile) {
1782
+ if (isFullDefaultProfile(profile)) {
1783
+ return readPackageFile(relativePath);
1784
+ }
1785
+ if (ROOT_INSTRUCTIONS.has(relativePath)) {
1786
+ return readPackageFile(relativePath);
1787
+ }
1788
+ switch (relativePath) {
1789
+ case "docs/AGENTS.md":
1790
+ case "docs/CLAUDE.md":
1791
+ return renderDocsRouter(profile);
1792
+ case "docs/assets/templates/AGENTS.md":
1793
+ case "docs/assets/templates/CLAUDE.md":
1794
+ return renderTemplatesRouter(profile);
1795
+ case "docs/assets/prompts/AGENTS.md":
1796
+ case "docs/assets/prompts/CLAUDE.md":
1797
+ return renderPromptsRouter(profile);
1798
+ case "docs/assets/references/AGENTS.md":
1799
+ case "docs/assets/references/CLAUDE.md":
1800
+ return readPackageFile(relativePath);
1801
+ case "docs/assets/archive/AGENTS.md":
1802
+ case "docs/assets/archive/CLAUDE.md":
1803
+ return readPackageFile(relativePath);
1804
+ case "docs/assets/AGENTS.md":
1805
+ case "docs/assets/CLAUDE.md":
1806
+ return renderAssetsRouter();
1807
+ case "docs/assets/history/AGENTS.md":
1808
+ case "docs/assets/history/CLAUDE.md":
1809
+ return renderHistoryAssetsRouter();
1810
+ case "docs/assets/references/design-workflow.md":
1811
+ return renderDesignWorkflow(profile);
1812
+ case "docs/assets/references/design-contract.md":
1813
+ return renderDesignContract(profile);
1814
+ case "docs/assets/templates/design.md":
1815
+ return renderDesignTemplate(profile);
1816
+ case "docs/guides/AGENTS.md":
1817
+ case "docs/guides/CLAUDE.md":
1818
+ return renderGuidesRouter(profile);
1819
+ default:
1820
+ throw new Error(`No buildable renderer registered for ${relativePath}.`);
1821
+ }
1822
+ }
1823
+ function renderDocsRouter(profile) {
1824
+ const lines = [
1825
+ "# Documentation Router",
1826
+ "",
1827
+ "Use `docs/` only as a router. Do not create generated files directly in this directory.",
1828
+ "- Source Markdown uses semantic line breaks; for path and link hygiene, use project-relative paths and relative Markdown links, and read `docs/assets/references/path-and-link-hygiene.md` when auditing or deciding whether an absolute path is warranted."
1829
+ ];
1830
+ if (profile.capabilityState.designs.effectiveSelection) {
1831
+ lines.push(
1832
+ "- For design docs, read `docs/assets/references/design-workflow.md`, `docs/assets/references/design-contract.md`, and `docs/assets/templates/design.md`, then continue in `docs/designs/`."
1833
+ );
1834
+ }
1835
+ if (profile.capabilityState.plans.effectiveSelection) {
1836
+ lines.push(
1837
+ "- For plans, read `docs/assets/references/planning-workflow.md` and the selected plan template in `docs/assets/templates/`, then continue in `docs/plans/`."
1838
+ );
1839
+ }
1840
+ if (profile.capabilityState.prd.effectiveSelection && profile.capabilityState.work.effectiveSelection) {
1841
+ lines.push(
1842
+ "- For PRD or work generation, read `docs/assets/references/execution-workflow.md`, `docs/assets/references/output-contract.md`, and the selected template in `docs/assets/templates/`, then continue in `docs/prd/` or `docs/work/`; work phase tasks use `- [ ] t1: ...` checkbox items and acceptance criteria use plain bullets."
1843
+ );
1844
+ } else if (profile.capabilityState.prd.effectiveSelection) {
1845
+ lines.push(
1846
+ "- For PRD generation, read `docs/assets/references/execution-workflow.md`, `docs/assets/references/output-contract.md`, and the selected template in `docs/assets/templates/`, then continue in `docs/prd/`."
1847
+ );
1848
+ }
1849
+ if (profile.capabilityState.plans.effectiveSelection || profile.capabilityState.prd.effectiveSelection || profile.capabilityState.work.effectiveSelection) {
1850
+ lines.push(
1851
+ profile.capabilityState.prd.effectiveSelection || profile.capabilityState.work.effectiveSelection ? "- For requirement changes, also read `docs/assets/references/prd-change-management.md` before choosing change templates or delta outputs." : "- For requirement-change plans, also read `docs/assets/references/prd-change-management.md` before choosing the change-planning template."
1852
+ );
1853
+ }
1854
+ if (profile.capabilityState.prd.effectiveSelection) {
1855
+ lines.push(
1856
+ "- For gaps, drift, unresolved questions, risks, decisions, or closeout findings, first update `docs/prd/03-open-questions-and-risk-register.md` when it exists; do not create separate questions, decisions, risks, gaps, or architecture-decision files unless the user explicitly asks."
1857
+ );
1858
+ }
1859
+ lines.push(
1860
+ "- For guides, continue in `docs/guides/`. Before writing, read `docs/assets/references/guide-contract.md`, inspect existing guides for overlap, choose `developer`, `user`, `both`, `update-existing`, `link-only`, or `none`, and use the matching template (`docs/assets/templates/guide-developer.md` or `docs/assets/templates/guide-user.md`).",
1861
+ "- After guide work, reconcile overlapping existing guides with reciprocal links, `related` frontmatter, or concise supplemental context when it improves discoverability.",
1862
+ "- Use `## Future Coverage` inside guides for downstream-dependent guide updates. Do not create design docs, architecture decisions, or PRD risk-register items solely to remember future guide work.",
1863
+ "- For history records, continue in `docs/assets/history/` \u2014 read `docs/assets/references/history-record-contract.md` and `docs/assets/templates/history-record.md` before writing."
1864
+ );
1865
+ if (getPromptPaths(profile).length > 0) {
1866
+ lines.push(
1867
+ "- For reusable prompt starters, use `docs/assets/prompts/`; prompts are optional starters, not authority."
1868
+ );
1869
+ }
1870
+ return `${lines.join("\n")}
1871
+ `;
1872
+ }
1873
+ function renderGuidesRouter(profile) {
1874
+ return [
1875
+ "# Guides for Devs and Users",
1876
+ "",
1877
+ "Use `docs/guides` only as a router. Do not create generated files directly in this directory.",
1878
+ "",
1879
+ "- Before writing any guide, read `docs/assets/references/guide-contract.md`, inspect existing guides for overlap, and decide whether the right outcome is `developer`, `user`, `both`, `update-existing`, `link-only`, or `none`.",
1880
+ "- **User guides** are stored in `docs/guides/user/`. They explain the shipped product from a user's perspective, from novice orientation through advanced workflows. Use `docs/assets/templates/guide-user.md` when creating one.",
1881
+ "- **Developer guides** are stored in `docs/guides/developer/`. They help contributors, maintainers, integrators, and operators navigate the codebase, docs, contracts, validation, extension points, and safe-change workflows. Use `docs/assets/templates/guide-developer.md` when creating one.",
1882
+ "- Prefer updating an existing guide when it already owns the topic. Use cross-links and `related` frontmatter instead of duplicating full guides across audiences.",
1883
+ "- After creating or updating guides, re-check overlapping guides and add reciprocal links, `related` frontmatter, or concise supplemental context when the new work improves their discoverability.",
1884
+ "- If current confirmed behavior is useful but downstream work will expand it, write the current coverage now and add `## Future Coverage` for the blocked guide update.",
1885
+ "- Do not create design docs, architecture decisions, or PRD risk-register items solely to remember future guide work.",
1886
+ "- History records are not guides. Route them through `docs/assets/history/` instead.",
1887
+ "- If the `docs/guides/user` or `docs/guides/developer` directories do not exist, create them ONLY when first writing a guide that belongs in the specific sub-folder.",
1888
+ "",
1889
+ "Documentation must be easy to understand, easy to use, and easy to follow, with links to supporting sections or documents where necessary and where possible.",
1890
+ ""
1891
+ ].join("\n");
1892
+ }
1893
+ function renderAssetsRouter() {
1894
+ return [
1895
+ "# Document Assets Router",
1896
+ "",
1897
+ "This router describes the target `docs/assets/` document-resource namespace.",
1898
+ "",
1899
+ "- Archive records belong in `docs/assets/archive/`.",
1900
+ "- History records belong in `docs/assets/history/`; read `docs/assets/references/history-record-contract.md` and `docs/assets/templates/history-record.md` before writing.",
1901
+ "- Reusable prompts, references, and templates belong in `docs/assets/prompts/`, `docs/assets/references/`, and `docs/assets/templates/`.",
1902
+ "- make-docs runtime state does not belong under `docs/assets/`; canonical state lives at `.make-docs/manifest.json` and `.make-docs/conflicts/<run-id>/`.",
1903
+ "- Do not create `docs/assets/config/`, `docs/assets/state/`, `docs/assets/manifest.json`, or `docs/assets/conflicts/`.",
1904
+ ""
1905
+ ].join("\n");
1906
+ }
1907
+ function renderHistoryAssetsRouter() {
1908
+ return [
1909
+ "# History Assets Router",
1910
+ "",
1911
+ "This directory stores session history records.",
1912
+ "",
1913
+ "- Before writing, read `docs/assets/references/history-record-contract.md` and `docs/assets/templates/history-record.md`.",
1914
+ "- When W/R/P is known, create records at `docs/assets/history/YYYY-MM-DD-w{W}-r{R}-p{P}-<slug>.md`.",
1915
+ "- If only W/R is known, create records at `docs/assets/history/YYYY-MM-DD-w{W}-r{R}-<slug>.md`.",
1916
+ "- If no coordinate is known, create records at `docs/assets/history/YYYY-MM-DD-<slug>.md`.",
1917
+ "- Keep stage and task detail only in `coordinate` frontmatter, not filenames.",
1918
+ "- Include only known frontmatter fields; do not invent unknown client, model, or provider values.",
1919
+ "- Keep records concise: breadcrumbs for a future auditor, not live logs.",
1920
+ "- Use relative Markdown links when referencing files touched during the session.",
1921
+ ""
1922
+ ].join("\n");
1923
+ }
1924
+ function renderTemplatesRouter(profile) {
1925
+ const templateFamilies = [];
1926
+ if (profile.capabilityState.designs.effectiveSelection) {
1927
+ templateFamilies.push("`design.md` for design docs");
1928
+ }
1929
+ templateFamilies.push("`guide-developer.md` and `guide-user.md` for guides");
1930
+ const wildcardFamilies = [];
1931
+ if (profile.capabilityState.plans.effectiveSelection) {
1932
+ wildcardFamilies.push("`plan-*`");
1933
+ }
1934
+ if (profile.capabilityState.prd.effectiveSelection) {
1935
+ wildcardFamilies.push("`prd-*`");
1936
+ }
1937
+ if (profile.capabilityState.work.effectiveSelection) {
1938
+ wildcardFamilies.push("`work-*`");
1939
+ }
1940
+ if (wildcardFamilies.length > 0) {
1941
+ templateFamilies.push(
1942
+ `the matching ${formatInlineList(wildcardFamilies)} template for the target artifact`
1943
+ );
1944
+ }
1945
+ const usageLine = templateFamilies.length > 0 ? `- Use ${formatInlineList(templateFamilies)}.` : "- Install at least one documentation capability before using templates.";
1946
+ return [
1947
+ "# Templates Router",
1948
+ "",
1949
+ "This directory contains structural starting points for generated docs.",
1950
+ "- Copy the relevant template shape into the target output file; do not write outputs here.",
1951
+ usageLine,
1952
+ "- Resolve workflow and contract questions in `docs/assets/references/`, then continue in the target output directory router.",
1953
+ "- Do not modify template files unless the user explicitly asks.",
1954
+ ""
1955
+ ].join("\n");
1956
+ }
1957
+ function renderPromptsRouter(profile) {
1958
+ const outputs = [];
1959
+ if (profile.capabilityState.plans.effectiveSelection) {
1960
+ outputs.push("plans");
1961
+ }
1962
+ if (profile.capabilityState.prd.effectiveSelection) {
1963
+ outputs.push("PRDs");
1964
+ }
1965
+ if (profile.capabilityState.work.effectiveSelection) {
1966
+ outputs.push("work backlogs");
1967
+ }
1968
+ if (profile.capabilityState.designs.effectiveSelection) {
1969
+ outputs.push("design docs");
1970
+ }
1971
+ const outputText = outputs.length > 0 ? `- Do not write generated ${formatInlineList(outputs)} here.` : "- Do not write generated outputs here.";
1972
+ return [
1973
+ "# Prompts Router",
1974
+ "",
1975
+ "This directory stores reusable prompt starters, not authoritative rules and not generated outputs.",
1976
+ "- Use it only when the user wants a stored prompt or a reusable workflow kickoff.",
1977
+ "- Keep placeholder tokens explicit unless the user asks to instantiate them.",
1978
+ "- When executing a prompt, read the target workflow in `docs/assets/references/`, the matching template in `docs/assets/templates/`, and the router in the target output directory.",
1979
+ outputText,
1980
+ ""
1981
+ ].join("\n");
1982
+ }
1983
+ function renderDesignWorkflow(profile) {
1984
+ if (profile.capabilityState.plans.effectiveSelection && hasDesignPlanningPrompts(profile)) {
1985
+ return readPackageFile("docs/assets/references/design-workflow.md");
1986
+ }
1987
+ if (profile.capabilityState.plans.effectiveSelection) {
1988
+ return [
1989
+ "# Design Workflow",
1990
+ "",
1991
+ "## Purpose",
1992
+ "",
1993
+ "Use this workflow when the user wants to turn a request into one or more design docs before planning, PRD generation, or backlog generation.",
1994
+ "",
1995
+ "This workflow ends with design docs in `docs/designs/` using the form `docs/designs/YYYY-MM-DD-<slug>.md`. It does not draft a plan.",
1996
+ "",
1997
+ "## Preflight",
1998
+ "",
1999
+ "Before writing:",
2000
+ "",
2001
+ "1. Inspect `docs/designs/` for related design docs.",
2002
+ "2. Inspect related plans, PRD docs, or work backlogs only as needed for context or route classification.",
2003
+ "3. Determine whether the request belongs to the same decision area as an existing design.",
2004
+ "4. Choose whether to update an existing design or create a new dated design doc.",
2005
+ "",
2006
+ "## Create Vs Update Rules",
2007
+ "",
2008
+ "- Prefer updating an existing design when the request clearly concerns the same decision area and the existing doc can absorb the change without obscuring prior intent.",
2009
+ "- Create a new dated design doc when no clear related design exists, when the request spans a distinct decision area, or when a substantial direction change would make the existing design misleading.",
2010
+ "- One design doc is the default output unit. Create more than one only when the request clearly spans multiple distinct decision areas.",
2011
+ "",
2012
+ "## Lineage Rules",
2013
+ "",
2014
+ "- If a generated update materially changes prior design intent, add an optional `## Design Lineage` section before `## Intended Follow-On`.",
2015
+ "- Use `## Design Lineage` to record:",
2016
+ " - `Update Mode:` `updated-existing` or `new-doc-related`",
2017
+ " - `Prior Design Docs:` relative links to the earlier design docs",
2018
+ " - `Reason:` a short explanation of why the prior design was updated or why a related new design doc was needed",
2019
+ "- If the request is only a minor clarification and does not materially change prior design intent, the lineage section is optional.",
2020
+ "",
2021
+ "## Intended Follow-On Rules",
2022
+ "",
2023
+ "- Every generated design doc must include `## Intended Follow-On`.",
2024
+ "- Allowed `Route` values:",
2025
+ " - `baseline-plan`",
2026
+ " - `change-plan`",
2027
+ "- Planning prompt links are unavailable in this profile because the required planning assets are not installed locally.",
2028
+ "- Record:",
2029
+ " - `Next Step:` rerun `npx @brucewaynedecoy/make-docs@next reconfigure` and enable `plans` if you want local planning prompts",
2030
+ " - `Why:` a short explanation of why the selected route is the correct downstream workflow",
2031
+ "",
2032
+ "## Stop Rule",
2033
+ "",
2034
+ "- Stop after the design docs are created or updated.",
2035
+ "- Do not draft a plan as part of the request-to-design workflow.",
2036
+ "",
2037
+ "## Validation Checklist",
2038
+ "",
2039
+ "Before closing the task, confirm:",
2040
+ "",
2041
+ "1. The output lives in `docs/designs/` and follows `YYYY-MM-DD-<slug>.md` naming.",
2042
+ "2. The generated design uses the required design template structure.",
2043
+ "3. The create-vs-update choice is justified by the current design tree.",
2044
+ "4. `## Design Lineage` is present when the design materially updates prior intent.",
2045
+ "5. `## Intended Follow-On` uses `baseline-plan` or `change-plan` without linking to missing prompt files.",
2046
+ ""
2047
+ ].join("\n");
2048
+ }
2049
+ return [
2050
+ "# Design Workflow",
2051
+ "",
2052
+ "## Purpose",
2053
+ "",
2054
+ "Use this workflow when the user wants to turn a request into one or more design docs before later planning work.",
2055
+ "",
2056
+ "This workflow ends with design docs in `docs/designs/` using the form `docs/designs/YYYY-MM-DD-<slug>.md`. Local planning assets are not installed in this profile.",
2057
+ "",
2058
+ "## Preflight",
2059
+ "",
2060
+ "Before writing:",
2061
+ "",
2062
+ "1. Inspect `docs/designs/` for related design docs.",
2063
+ "2. Inspect related plans, PRD docs, or work backlogs only as needed for context or route classification.",
2064
+ "3. Determine whether the request belongs to the same decision area as an existing design.",
2065
+ "4. Choose whether to update an existing design or create a new dated design doc.",
2066
+ "",
2067
+ "## Create Vs Update Rules",
2068
+ "",
2069
+ "- Prefer updating an existing design when the request clearly concerns the same decision area and the existing doc can absorb the change without obscuring prior intent.",
2070
+ "- Create a new dated design doc when no clear related design exists, when the request spans a distinct decision area, or when a substantial direction change would make the existing design misleading.",
2071
+ "- One design doc is the default output unit. Create more than one only when the request clearly spans multiple distinct decision areas.",
2072
+ "",
2073
+ "## Lineage Rules",
2074
+ "",
2075
+ "- If a generated update materially changes prior design intent, add an optional `## Design Lineage` section before `## Intended Follow-On`.",
2076
+ "- Use `## Design Lineage` to record:",
2077
+ " - `Update Mode:` `updated-existing` or `new-doc-related`",
2078
+ " - `Prior Design Docs:` relative links to the earlier design docs",
2079
+ " - `Reason:` a short explanation of why the prior design was updated or why a related new design doc was needed",
2080
+ "- If the request is only a minor clarification and does not materially change prior design intent, the lineage section is optional.",
2081
+ "",
2082
+ "## Intended Follow-On Rules",
2083
+ "",
2084
+ "- Every generated design doc must include `## Intended Follow-On`.",
2085
+ "- Because the `plans` capability is not installed in this profile, do not link to prompt starter files that are not installed locally.",
2086
+ "- Record the follow-on as:",
2087
+ " - `Route:` `planning-not-installed`",
2088
+ " - `Next Step:` rerun `npx @brucewaynedecoy/make-docs@next reconfigure` and enable `plans`",
2089
+ " - `Why:` a short explanation of whether the next step should be baseline planning or change planning once planning assets are installed",
2090
+ "",
2091
+ "## Stop Rule",
2092
+ "",
2093
+ "- Stop after the design docs are created or updated.",
2094
+ "- Do not draft a plan as part of the request-to-design workflow.",
2095
+ "",
2096
+ "## Validation Checklist",
2097
+ "",
2098
+ "Before closing the task, confirm:",
2099
+ "",
2100
+ "1. The output lives in `docs/designs/` and follows `YYYY-MM-DD-<slug>.md` naming.",
2101
+ "2. The generated design uses the required design template structure.",
2102
+ "3. The create-vs-update choice is justified by the current design tree.",
2103
+ "4. `## Design Lineage` is present when the design materially updates prior intent.",
2104
+ "5. `## Intended Follow-On` records that local planning assets are not installed and names rerunning the installer as the next step.",
2105
+ ""
2106
+ ].join("\n");
2107
+ }
2108
+ function renderDesignContract(profile) {
2109
+ if (profile.capabilityState.plans.effectiveSelection && hasDesignPlanningPrompts(profile)) {
2110
+ return readPackageFile("docs/assets/references/design-contract.md");
2111
+ }
2112
+ if (profile.capabilityState.plans.effectiveSelection) {
2113
+ return [
2114
+ "# Design Contract",
2115
+ "",
2116
+ "## Purpose",
2117
+ "",
2118
+ "Use this contract for agent-generated design docs under `docs/designs/`.",
2119
+ "",
2120
+ "User-authored design docs may not fully conform. Apply this contract to newly generated design docs and to substantial agent-authored updates.",
2121
+ "",
2122
+ "## Required Path",
2123
+ "",
2124
+ "- `docs/designs/YYYY-MM-DD-<slug>.md`",
2125
+ "",
2126
+ "`YYYY-MM-DD` is today's date (never backdated). `<slug>` is lowercase, hyphens only.",
2127
+ "",
2128
+ "## Required Headings",
2129
+ "",
2130
+ "Generated design docs must include:",
2131
+ "",
2132
+ "- `## Purpose`",
2133
+ "- `## Context`",
2134
+ "- `## Decision`",
2135
+ "- `## Alternatives Considered`",
2136
+ "- `## Consequences`",
2137
+ "- `## Intended Follow-On`",
2138
+ "",
2139
+ "## Intended Follow-On Contract",
2140
+ "",
2141
+ "The `## Intended Follow-On` section must include:",
2142
+ "",
2143
+ "- `Route:` `baseline-plan` or `change-plan`",
2144
+ "- `Next Step:` rerun `npx @brucewaynedecoy/make-docs@next reconfigure` and enable `plans` if you want local planning prompts",
2145
+ "- `Why:` a short explanation of why that route is the correct downstream workflow",
2146
+ "",
2147
+ "Do not add a `Next Prompt` link when the required planning prompts are not installed locally.",
2148
+ "",
2149
+ "## Optional Design Lineage",
2150
+ "",
2151
+ "Add `## Design Lineage` when a generated design materially updates prior design intent or when a new design doc is closely related to an earlier design.",
2152
+ "",
2153
+ "When present, include:",
2154
+ "",
2155
+ "- `Update Mode:` `updated-existing` or `new-doc-related`",
2156
+ "- `Prior Design Docs:` relative Markdown links",
2157
+ "- `Reason:` a short explanation of the lineage relationship",
2158
+ "",
2159
+ "## Link Rules",
2160
+ "",
2161
+ "- Use relative Markdown links between design docs and related plans, PRD docs, or work items.",
2162
+ "- If the required planning prompts are not installed locally, do not create broken prompt links.",
2163
+ ""
2164
+ ].join("\n");
2165
+ }
2166
+ return [
2167
+ "# Design Contract",
2168
+ "",
2169
+ "## Purpose",
2170
+ "",
2171
+ "Use this contract for agent-generated design docs under `docs/designs/`.",
2172
+ "",
2173
+ "User-authored design docs may not fully conform. Apply this contract to newly generated design docs and to substantial agent-authored updates.",
2174
+ "",
2175
+ "## Required Path",
2176
+ "",
2177
+ "- `docs/designs/YYYY-MM-DD-{{DESIGN NAME}}.md`",
2178
+ "",
2179
+ "## Required Headings",
2180
+ "",
2181
+ "Generated design docs must include:",
2182
+ "",
2183
+ "- `## Purpose`",
2184
+ "- `## Context`",
2185
+ "- `## Decision`",
2186
+ "- `## Alternatives Considered`",
2187
+ "- `## Consequences`",
2188
+ "- `## Intended Follow-On`",
2189
+ "",
2190
+ "## Intended Follow-On Contract",
2191
+ "",
2192
+ "The `## Intended Follow-On` section must include:",
2193
+ "",
2194
+ "- `Route:` `planning-not-installed`",
2195
+ "- `Next Step:` rerun `npx @brucewaynedecoy/make-docs@next reconfigure` and enable `plans` if you want local planning prompts and templates",
2196
+ "- `Why:` a short explanation of what planning should happen later",
2197
+ "",
2198
+ "Do not add a `Next Prompt` link when planning assets are not installed locally.",
2199
+ "",
2200
+ "## Optional Design Lineage",
2201
+ "",
2202
+ "Add `## Design Lineage` when a generated design materially updates prior design intent or when a new design doc is closely related to an earlier design.",
2203
+ "",
2204
+ "When present, include:",
2205
+ "",
2206
+ "- `Update Mode:` `updated-existing` or `new-doc-related`",
2207
+ "- `Prior Design Docs:` relative Markdown links",
2208
+ "- `Reason:` a short explanation of the lineage relationship",
2209
+ "",
2210
+ "## Link Rules",
2211
+ "",
2212
+ "- Use relative Markdown links between design docs and related plans, PRD docs, or work items.",
2213
+ "- If planning assets are not installed locally, do not create broken prompt links.",
2214
+ ""
2215
+ ].join("\n");
2216
+ }
2217
+ function renderDesignTemplate(profile) {
2218
+ if (profile.capabilityState.plans.effectiveSelection) {
2219
+ return readPackageFile("docs/assets/templates/design.md");
2220
+ }
2221
+ return [
2222
+ "# {{TITLE}}",
2223
+ "",
2224
+ "> Filename: `YYYY-MM-DD-<slug>.md`. See `docs/assets/references/design-contract.md` for naming and structural rules.",
2225
+ "",
2226
+ "## Purpose",
2227
+ "",
2228
+ "Explain what decision this document captures and why it exists.",
2229
+ "",
2230
+ "## Context",
2231
+ "",
2232
+ "Describe the problem, constraints, forces, and existing conditions that shape the decision.",
2233
+ "",
2234
+ "## Decision",
2235
+ "",
2236
+ "Describe the chosen approach clearly enough that planning can proceed from it once planning assets are installed.",
2237
+ "",
2238
+ "## Alternatives Considered",
2239
+ "",
2240
+ "List the meaningful alternatives and why they were not chosen.",
2241
+ "",
2242
+ "## Consequences",
2243
+ "",
2244
+ "Describe outcomes, trade-offs, risks, and follow-on implications.",
2245
+ "",
2246
+ "## Intended Follow-On",
2247
+ "",
2248
+ "- Route: planning-not-installed",
2249
+ "- Next Step: Re-run `npx @brucewaynedecoy/make-docs@next reconfigure` and enable `plans` to install local planning prompts and templates.",
2250
+ "- Why: Explain whether this design should later feed a baseline plan or a change plan.",
2251
+ ""
2252
+ ].join("\n");
2253
+ }
2254
+ function hasDesignPlanningPrompts(profile) {
2255
+ return getPromptPaths(profile).some(
2256
+ (relativePath) => relativePath === "docs/assets/prompts/designs-to-plan.prompt.md" || relativePath === "docs/assets/prompts/designs-to-plan-change.prompt.md"
2257
+ );
2258
+ }
2259
+
2260
+ // src/catalog.ts
2261
+ function buildAsset(profile, relativePath) {
2262
+ const assetClass = isBuildablePath(relativePath) ? "buildable" : "scoped-static";
2263
+ const content = assetClass === "buildable" ? renderBuildableAsset(relativePath, profile) : readPackageFile(relativePath);
2264
+ return {
2265
+ relativePath,
2266
+ assetClass,
2267
+ sourceId: assetClass === "buildable" ? `build:${relativePath}` : `file:${relativePath}`,
2268
+ content
2269
+ };
2270
+ }
2271
+ function addInstructionAssets(profile, activeInstructionKind, relativePaths) {
2272
+ relativePaths.add(activeInstructionKind);
2273
+ relativePaths.add(`docs/${activeInstructionKind}`);
2274
+ relativePaths.add(`docs/assets/${activeInstructionKind}`);
2275
+ relativePaths.add(`docs/assets/history/${activeInstructionKind}`);
2276
+ relativePaths.add(`docs/guides/${activeInstructionKind}`);
2277
+ relativePaths.add(`docs/assets/archive/${activeInstructionKind}`);
2278
+ if (profile.capabilityState.designs.effectiveSelection) {
2279
+ relativePaths.add(`docs/designs/${activeInstructionKind}`);
2280
+ }
2281
+ if (profile.capabilityState.plans.effectiveSelection) {
2282
+ relativePaths.add(`docs/plans/${activeInstructionKind}`);
2283
+ }
2284
+ if (profile.capabilityState.prd.effectiveSelection) {
2285
+ relativePaths.add(`docs/prd/${activeInstructionKind}`);
2286
+ }
2287
+ if (profile.capabilityState.work.effectiveSelection) {
2288
+ relativePaths.add(`docs/work/${activeInstructionKind}`);
2289
+ }
2290
+ if (getReferenceDirInstalled(profile)) {
2291
+ relativePaths.add(`docs/assets/references/${activeInstructionKind}`);
2292
+ }
2293
+ if (getTemplateDirInstalled(profile)) {
2294
+ relativePaths.add(`docs/assets/templates/${activeInstructionKind}`);
2295
+ }
2296
+ if (getPromptsDirInstalled(profile)) {
2297
+ relativePaths.add(`docs/assets/prompts/${activeInstructionKind}`);
2298
+ }
2299
+ }
2300
+ function getDesiredAssets(profile) {
2301
+ const relativePaths = /* @__PURE__ */ new Set();
2302
+ for (const referencePath of getReferencePaths(profile)) {
2303
+ relativePaths.add(referencePath);
2304
+ }
2305
+ for (const templatePath of getTemplatePaths(profile)) {
2306
+ relativePaths.add(templatePath);
2307
+ }
2308
+ for (const promptPath of getPromptPaths(profile)) {
2309
+ relativePaths.add(promptPath);
2310
+ }
2311
+ for (const scriptPath of getScriptPaths(profile)) {
2312
+ relativePaths.add(scriptPath);
2313
+ }
2314
+ for (const instructionKind of getActiveInstructionKinds(profile.selections)) {
2315
+ addInstructionAssets(profile, instructionKind, relativePaths);
2316
+ }
2317
+ return Array.from(relativePaths).sort().map((relativePath) => buildAsset(profile, relativePath));
2318
+ }
2319
+
2320
+ // src/skill-catalog.ts
2321
+ import * as os2 from "os";
2322
+ import path5 from "path";
2323
+
2324
+ // src/skill-resolver.ts
2325
+ import path4 from "path";
2326
+ var URL_PROTOCOL = "url:";
2327
+ var GITHUB_PROTOCOL = "github:";
2328
+ var DEFAULT_GITHUB_REF = "main";
2329
+ var RAW_GITHUB_HOST = "raw.githubusercontent.com";
2330
+ var remoteTextCache = /* @__PURE__ */ new Map();
2331
+ var remoteBinaryCache = /* @__PURE__ */ new Map();
2332
+ var UnsupportedProtocolError = class extends Error {
2333
+ constructor(protocol) {
2334
+ super(`Unsupported skill source protocol: \`${protocol}\``);
2335
+ this.protocol = protocol;
2336
+ this.name = "UnsupportedProtocolError";
2337
+ }
2338
+ };
2339
+ async function resolveSkillSource(source, entryPoint, assets) {
2340
+ const sourceDir = resolveSourceDirectory(source);
2341
+ const entryPointFile = resolveRelativeFile(entryPoint, sourceDir);
2342
+ const entryPointContent = await readSourceText(entryPointFile);
2343
+ const resolvedAssets = await Promise.all(
2344
+ assets.map(async (asset) => {
2345
+ const file = resolveSourceFile(asset.source, sourceDir);
2346
+ return {
2347
+ installPath: asset.installPath,
2348
+ content: isMarkdownPath(file.virtualPath) ? await readSourceText(file) : await readSourceBinary(file),
2349
+ sourcePath: file.virtualPath
2350
+ };
2351
+ })
2352
+ );
2353
+ return {
2354
+ entryPointContent,
2355
+ assets: resolvedAssets
2356
+ };
2357
+ }
2358
+ function resolveSourceDirectory(source) {
2359
+ if (!isRemoteSource2(source)) {
2360
+ throw new UnsupportedProtocolError(extractProtocol(source));
2361
+ }
2362
+ const location = normalizeRemoteSource(source, { directory: true });
2363
+ return {
2364
+ location,
2365
+ virtualPath: toRemoteVirtualPath(location)
2366
+ };
2367
+ }
2368
+ function resolveSourceFile(source, baseDir) {
2369
+ if (isRemoteSource2(source)) {
2370
+ const location = normalizeRemoteSource(source, { directory: false });
2371
+ return {
2372
+ location,
2373
+ virtualPath: toRemoteVirtualPath(location)
2374
+ };
2375
+ }
2376
+ return resolveRelativeFile(source, baseDir);
2377
+ }
2378
+ function resolveRelativeFile(relativePath, baseDir) {
2379
+ const nextUrl = new URL(relativePath, ensureTrailingSlash(baseDir.location)).href;
2380
+ const location = normalizeRemoteSource(nextUrl, { directory: false });
2381
+ return {
2382
+ location,
2383
+ virtualPath: toRemoteVirtualPath(location)
2384
+ };
2385
+ }
2386
+ async function readSourceText(file) {
2387
+ return fetchRemoteText(file.location);
2388
+ }
2389
+ async function readSourceBinary(file) {
2390
+ return fetchRemoteBinary(file.location);
2391
+ }
2392
+ function isRemoteSource2(source) {
2393
+ return source.startsWith(URL_PROTOCOL) || source.startsWith(GITHUB_PROTOCOL) || source.startsWith("https://") || source.startsWith("http://");
2394
+ }
2395
+ function normalizeRemoteSource(source, options) {
2396
+ if (source.startsWith(GITHUB_PROTOCOL)) {
2397
+ return normalizeGithubProtocol(source, options);
2398
+ }
2399
+ const rawSource = source.startsWith(URL_PROTOCOL) ? source.slice(URL_PROTOCOL.length) : source;
2400
+ const url = new URL(rawSource);
2401
+ if (url.hostname === "github.com") {
2402
+ return normalizeGithubUrl(url, options);
2403
+ }
2404
+ if (url.hostname === RAW_GITHUB_HOST) {
2405
+ return options.directory ? ensureTrailingSlash(url.href) : stripTrailingSlash(url.href);
2406
+ }
2407
+ return options.directory ? ensureTrailingSlash(url.href) : stripTrailingSlash(url.href);
2408
+ }
2409
+ function normalizeGithubProtocol(source, options) {
2410
+ const rawSource = source.slice(GITHUB_PROTOCOL.length);
2411
+ const atIndex = rawSource.lastIndexOf("@");
2412
+ const withoutRef = atIndex === -1 ? rawSource : rawSource.slice(0, atIndex);
2413
+ const ref = atIndex === -1 ? DEFAULT_GITHUB_REF : rawSource.slice(atIndex + 1);
2414
+ const segments = withoutRef.split("/").filter(Boolean);
2415
+ if (segments.length < 3) {
2416
+ throw new Error(
2417
+ `GitHub skill source \`${source}\` must use github:<owner>/<repo>/<path>[@<ref>]`
2418
+ );
2419
+ }
2420
+ const [owner, repo, ...pathSegments] = segments;
2421
+ return buildGithubRawUrl(owner, repo, ref, pathSegments, options.directory);
2422
+ }
2423
+ function normalizeGithubUrl(url, options) {
2424
+ const segments = url.pathname.split("/").filter(Boolean);
2425
+ if (segments.length < 4) {
2426
+ throw new Error(
2427
+ `GitHub skill source \`${url.href}\` must point to a tree or blob URL.`
2428
+ );
2429
+ }
2430
+ const [owner, repo, mode, ref, ...pathSegments] = segments;
2431
+ if (mode !== "tree" && mode !== "blob") {
2432
+ throw new Error(
2433
+ `GitHub skill source \`${url.href}\` must use /tree/ or /blob/ paths.`
2434
+ );
2435
+ }
2436
+ return buildGithubRawUrl(owner, repo, ref, pathSegments, options.directory || mode === "tree");
2437
+ }
2438
+ function buildGithubRawUrl(owner, repo, ref, pathSegments, directory) {
2439
+ const pathname = pathSegments.join("/");
2440
+ const base = `https://${RAW_GITHUB_HOST}/${owner}/${repo}/${ref}/${pathname}`;
2441
+ return directory ? ensureTrailingSlash(base) : stripTrailingSlash(base);
2442
+ }
2443
+ function ensureTrailingSlash(value) {
2444
+ return value.endsWith("/") ? value : `${value}/`;
2445
+ }
2446
+ function stripTrailingSlash(value) {
2447
+ return value.endsWith("/") ? value.slice(0, -1) : value;
2448
+ }
2449
+ function toRemoteVirtualPath(source) {
2450
+ const url = new URL(source);
2451
+ const joined = path4.posix.join("/", url.host, url.pathname);
2452
+ return joined.endsWith("/") ? joined.slice(0, -1) : joined;
2453
+ }
2454
+ async function fetchRemoteText(url) {
2455
+ const cached = remoteTextCache.get(url);
2456
+ if (cached) {
2457
+ return cached;
2458
+ }
2459
+ const request = fetchRemote(url, "text");
2460
+ remoteTextCache.set(url, request);
2461
+ return request;
2462
+ }
2463
+ async function fetchRemoteBinary(url) {
2464
+ const cached = remoteBinaryCache.get(url);
2465
+ if (cached) {
2466
+ return cached;
2467
+ }
2468
+ const request = fetchRemote(url, "binary");
2469
+ remoteBinaryCache.set(url, request);
2470
+ return request;
2471
+ }
2472
+ async function fetchRemote(url, mode) {
2473
+ const response = await fetch(url, {
2474
+ headers: {
2475
+ "User-Agent": "make-docs-cli"
2476
+ }
2477
+ });
2478
+ if (!response.ok) {
2479
+ throw new Error(
2480
+ `Failed to fetch skill source \`${url}\`: ${response.status} ${response.statusText}`
2481
+ );
2482
+ }
2483
+ if (mode === "text") {
2484
+ return response.text();
2485
+ }
2486
+ return Buffer.from(await response.arrayBuffer());
2487
+ }
2488
+ function isMarkdownPath(filePath) {
2489
+ return path4.posix.extname(filePath).toLowerCase() === ".md";
2490
+ }
2491
+ function extractProtocol(uri) {
2492
+ if (/^https?:\/\//.test(uri)) {
2493
+ const url = new URL(uri);
2494
+ return `${url.protocol}//`;
2495
+ }
2496
+ const colon = uri.indexOf(":");
2497
+ return colon === -1 ? uri : uri.slice(0, colon + 1);
2498
+ }
2499
+
2500
+ // src/skill-catalog.ts
2501
+ var HARNESS_SKILL_DIRS = {
2502
+ "claude-code": ".claude/skills",
2503
+ codex: ".agents/skills"
2504
+ };
2505
+ async function getDesiredSkillAssets(selections) {
2506
+ if (!selections.skills) {
2507
+ return [];
2508
+ }
2509
+ const registry = loadSkillRegistry(PACKAGE_ROOT);
2510
+ const selectedSkills = new Set(selections.selectedSkills);
2511
+ const selectedEntries = registry.skills.filter(
2512
+ (entry) => selectedSkills.has(entry.name)
2513
+ );
2514
+ if (selectedEntries.length === 0) {
2515
+ return [];
2516
+ }
2517
+ const installRoot = selections.skillScope === "project" ? "." : os2.homedir();
2518
+ const desiredAssets = (await Promise.all(
2519
+ HARNESSES.flatMap((harness) => {
2520
+ if (!selections.harnesses[harness]) {
2521
+ return [];
2522
+ }
2523
+ return selectedEntries.map(
2524
+ (entry) => buildSkillAssets(entry, harness, installRoot)
2525
+ );
2526
+ })
2527
+ )).flat();
2528
+ return desiredAssets.sort(
2529
+ (left, right) => left.relativePath.localeCompare(right.relativePath)
2530
+ );
2531
+ }
2532
+ function getRecommendedSkillChoices() {
2533
+ const registry = loadSkillRegistry(PACKAGE_ROOT);
2534
+ const toChoice = (entry) => ({
2535
+ name: entry.name,
2536
+ description: entry.description
2537
+ });
2538
+ return registry.skills.map(toChoice).sort((left, right) => left.name.localeCompare(right.name));
2539
+ }
2540
+ async function buildSkillAssets(entry, harness, installRoot) {
2541
+ const resolvedSkill = await resolveSkillSource(
2542
+ entry.source,
2543
+ entry.entryPoint,
2544
+ entry.assets
2545
+ );
2546
+ const skillInstallRoot = getInstallPath(
2547
+ installRoot,
2548
+ HARNESS_SKILL_DIRS[harness],
2549
+ entry.installName
2550
+ );
2551
+ const desiredAssets = [
2552
+ {
2553
+ relativePath: getInstallPath(skillInstallRoot, entry.entryPoint),
2554
+ assetClass: "static",
2555
+ sourceId: getSkillSourceId(entry, harness),
2556
+ content: resolvedSkill.entryPointContent
2557
+ }
2558
+ ];
2559
+ resolvedSkill.assets.forEach((asset) => {
2560
+ desiredAssets.push({
2561
+ relativePath: getInstallPath(skillInstallRoot, asset.installPath),
2562
+ assetClass: "static",
2563
+ sourceId: getSkillAssetSourceId(harness, entry.name, asset.installPath),
2564
+ content: typeof asset.content === "string" ? asset.content : asset.content.toString("utf8")
2565
+ });
2566
+ });
2567
+ return desiredAssets;
2568
+ }
2569
+ function getInstallPath(...segments) {
2570
+ return path5.join(...segments);
2571
+ }
2572
+ function getSkillSourceId(entry, harness) {
2573
+ return `skill:${harness}:${entry.name}`;
2574
+ }
2575
+ function getSkillAssetSourceId(harness, skillName, installPath) {
2576
+ return `skill-asset:${harness}:${skillName}:${installPath}`;
2577
+ }
2578
+
2579
+ export {
2580
+ Ct,
2581
+ Bt,
2582
+ Lt,
2583
+ h,
2584
+ x2 as x,
2585
+ te,
2586
+ U2 as U,
2587
+ q2 as q,
2588
+ W2 as W,
2589
+ Rt,
2590
+ Wt2 as Wt,
2591
+ Gt,
2592
+ Lt2,
2593
+ Vt2 as Vt,
2594
+ Jt,
2595
+ PACKAGE_ROOT,
2596
+ readTextFile,
2597
+ writeTextFile,
2598
+ ensureParentDir,
2599
+ hashText,
2600
+ readPackageMeta,
2601
+ createRunId,
2602
+ pruneEmptyDirectories,
2603
+ removeFileIfPresent,
2604
+ pruneDirectoryIfEmpty,
2605
+ formatInlineList,
2606
+ relativePathToTarget,
2607
+ loadSkillRegistry,
2608
+ getSkillRegistryNames,
2609
+ CAPABILITIES,
2610
+ INSTRUCTION_KINDS,
2611
+ HARNESSES,
2612
+ CAPABILITY_DEPENDENCIES,
2613
+ defaultSelections,
2614
+ cloneSelections,
2615
+ resolveInstallProfile,
2616
+ hasEffectiveCapabilities,
2617
+ renderBuildableAsset,
2618
+ getDesiredAssets,
2619
+ MANIFEST_RELATIVE_PATH,
2620
+ CONFLICTS_RELATIVE_DIR,
2621
+ getManifestPath,
2622
+ loadManifest,
2623
+ createManifest,
2624
+ writeManifest,
2625
+ getManifestAuditContext,
2626
+ createAuditPathMetadata,
2627
+ getDesiredSkillAssets,
2628
+ getRecommendedSkillChoices
2629
+ };
2630
+ //# sourceMappingURL=chunk-WM3OXYTW.js.map