@a-company/paradigm 3.46.0 → 5.4.0

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 (169) hide show
  1. package/dist/{accept-orchestration-ZUWQUHSK.js → accept-orchestration-GX2YRWM4.js} +5 -5
  2. package/dist/{add-VSPZ6FM4.js → add-FZRKEGH4.js} +1 -1
  3. package/dist/agent-WERIO2XV.js +523 -0
  4. package/dist/agent-loader-SJPJJS33.js +36 -0
  5. package/dist/{agents-suggest-65SER5IS.js → agents-suggest-DNSYJ6IA.js} +1 -1
  6. package/dist/{aggregate-SV3VGEIL.js → aggregate-H57K7PNV.js} +1 -1
  7. package/dist/{assess-UHBDYIK7.js → assess-4WVXZLZQ.js} +2 -2
  8. package/dist/{auto-24ICVUH4.js → auto-QFS5NHQU.js} +1 -1
  9. package/dist/{beacon-3SJV4DAP.js → beacon-KXZXYQHX.js} +1 -1
  10. package/dist/{calibration-WWHK73WU.js → calibration-V46G7JTY.js} +2 -2
  11. package/dist/{check-OLI6AUS6.js → check-OWAIWV23.js} +1 -1
  12. package/dist/{chunk-RP6TZYGE.js → chunk-2IO7JAG2.js} +1 -1
  13. package/dist/chunk-2T6BTYBN.js +712 -0
  14. package/dist/{chunk-CDMAMDSG.js → chunk-5VKJBNJL.js} +13 -5
  15. package/dist/{chunk-KB4XJWE3.js → chunk-6N3JTACN.js} +98 -437
  16. package/dist/{chunk-ZMQA6SCO.js → chunk-7HRBT23N.js} +631 -231
  17. package/dist/chunk-7N7GSU6K.js +34 -0
  18. package/dist/chunk-A2L4TSLZ.js +526 -0
  19. package/dist/{chunk-P7XSBJE3.js → chunk-ABVQGRF7.js} +1 -1
  20. package/dist/{chunk-HIKKOCXY.js → chunk-EI32ZBE6.js} +1 -1
  21. package/dist/{chunk-QIOCFXDQ.js → chunk-EKGMAM62.js} +1 -1
  22. package/dist/chunk-EZ3GOCYC.js +132 -0
  23. package/dist/{chunk-DS5QY37M.js → chunk-GTR2TBIJ.js} +247 -15
  24. package/dist/chunk-ICSLIPUS.js +1128 -0
  25. package/dist/{chunk-QDXI2DHR.js → chunk-J2JEQRT3.js} +1 -1
  26. package/dist/{chunk-AKIMFN6I.js → chunk-JASGXLK3.js} +2 -2
  27. package/dist/{chunk-J4E6K5MG.js → chunk-LSRABQIY.js} +25 -1
  28. package/dist/chunk-MCMOGQMU.js +145 -0
  29. package/dist/{chunk-ZXMDA7VB.js → chunk-PDX44BCA.js} +1 -6
  30. package/dist/{chunk-2SKXFXIT.js → chunk-S3ORKP3V.js} +10 -15
  31. package/dist/chunk-TAIJOFOE.js +124 -0
  32. package/dist/{chunk-FS3WTUHY.js → chunk-TXESEO7Y.js} +6 -6
  33. package/dist/{chunk-7COU5S2Z.js → chunk-VL67H5IC.js} +1 -1
  34. package/dist/{chunk-QWA26UNO.js → chunk-WQITYKHM.js} +7 -7
  35. package/dist/{chunk-MW5DMGBB.js → chunk-YMDLDELF.js} +114 -55
  36. package/dist/{claude-63ISJAZK.js → claude-FRRWJSTJ.js} +1 -1
  37. package/dist/{claude-cli-ABML5RHX.js → claude-cli-XJLK2X4L.js} +1 -1
  38. package/dist/{claude-code-JRLMRPTO.js → claude-code-HTBA4XRB.js} +1 -1
  39. package/dist/{claude-code-teams-CAJBEFIZ.js → claude-code-teams-T4SP24MD.js} +1 -1
  40. package/dist/{conductor-HLWYWUVH.js → conductor-PGPDVIVE.js} +1 -1
  41. package/dist/{config-schema-3YNIFJCJ.js → config-schema-EA4XALGG.js} +4 -2
  42. package/dist/{constellation-FAGT45TU.js → constellation-A26CCGQS.js} +1 -1
  43. package/dist/{context-audit-557EO6PK.js → context-audit-RLO3ETRP.js} +8 -5
  44. package/dist/{cost-XEBADYFT.js → cost-BGM32XJU.js} +1 -1
  45. package/dist/{cost-UD3WPEKZ.js → cost-VI46A4XL.js} +1 -1
  46. package/dist/{cursor-cli-QUOOF2N4.js → cursor-cli-JVEZGHWQ.js} +1 -1
  47. package/dist/{cursorrules-3TKZ4E4R.js → cursorrules-HLIKJJZT.js} +1 -1
  48. package/dist/decision-loader-WWCLIQPJ.js +20 -0
  49. package/dist/{delete-RRK4RL6Y.js → delete-KBRPQLPC.js} +2 -2
  50. package/dist/{diff-IP5CIARP.js → diff-RQLLNAFI.js} +5 -5
  51. package/dist/{discipline-5F5OVTXB.js → discipline-FA4OZXIS.js} +1 -1
  52. package/dist/{dist-UXWV4OKX.js → dist-34NA5RS5.js} +1 -1
  53. package/dist/{dist-5QE2BB2B-X6DYVSUL.js → dist-5QE2BB2B-5S3T6Y3T.js} +1 -1
  54. package/dist/{dist-CM3MVWWW.js → dist-77JDTVAY.js} +1 -0
  55. package/dist/{dist-POMVY6WP.js → dist-QK4SQAK7.js} +1 -1
  56. package/dist/{dist-3RVKEJRT.js → dist-TA6LSC2Q.js} +1 -1
  57. package/dist/docs-J2BTKRVU.js +155 -0
  58. package/dist/docs-PBZB7LYP.js +89 -0
  59. package/dist/{doctor-GKZJU7QG.js → doctor-ULBOHEIC.js} +3 -3
  60. package/dist/{drift-YGT4LJ7Q.js → drift-R5NRKFHI.js} +1 -1
  61. package/dist/{echo-A6HD5UP7.js → echo-O2LY7CC2.js} +1 -1
  62. package/dist/{edit-4CLNN5JG.js → edit-R2HNLMOG.js} +2 -2
  63. package/dist/event-25OJKDCE.js +31 -0
  64. package/dist/{export-T7CMMJIB.js → export-IWVL7XLF.js} +1 -1
  65. package/dist/{flow-UFMPVOEM.js → flow-CRRVV3O3.js} +2 -2
  66. package/dist/{global-HHUJSBG5.js → global-3NG5JXUB.js} +1 -1
  67. package/dist/graduate-USAWGBJM.js +160 -0
  68. package/dist/{graph-YYUXI3F7.js → graph-VHUMAAS6.js} +2 -2
  69. package/dist/{graph-server-ZPXRSGCW.js → graph-server-YL22VBBN.js} +1 -1
  70. package/dist/{habits-RG5SVKXP.js → habits-OL5NGPXO.js} +3 -3
  71. package/dist/{history-CETCSUCP.js → history-WOWC573W.js} +1 -1
  72. package/dist/{hooks-TCUHQMPF.js → hooks-HFWSCGPV.js} +2 -2
  73. package/dist/index.js +302 -188
  74. package/dist/{integrity-MK2OP5TA.js → integrity-IHO4FZTS.js} +1 -1
  75. package/dist/{integrity-checker-J7YXRTBT.js → integrity-checker-PSKJA5SB.js} +1 -0
  76. package/dist/journal-loader-5EYSBFFY.js +18 -0
  77. package/dist/{lint-HYWGS3JJ.js → lint-K6CJGGPH.js} +1 -1
  78. package/dist/{list-IUCYPGMK.js → list-4YK7QKFF.js} +1 -1
  79. package/dist/{list-BTLFHSRC.js → list-ENR7Q4CR.js} +2 -2
  80. package/dist/{lore-loader-VTEEZDX3.js → lore-loader-7NO6N6FT.js} +4 -1
  81. package/dist/{lore-server-NOOAHKJX.js → lore-server-UNJY5KC3.js} +1 -1
  82. package/dist/{manual-AFJ2J2V3.js → manual-G6FISID5.js} +1 -1
  83. package/dist/mcp.js +3917 -356
  84. package/dist/{migrate-FQVGQNXZ.js → migrate-LS45DNEV.js} +2 -2
  85. package/dist/{migrate-assessments-JP6Q5KME.js → migrate-assessments-RGH4O6IX.js} +2 -2
  86. package/dist/nomination-engine-HDWMN4IO.js +42 -0
  87. package/dist/notebook-YWIYGEHV.js +155 -0
  88. package/dist/{orchestrate-A226N6FC.js → orchestrate-XZA33TJC.js} +5 -5
  89. package/dist/{peers-RFQCWVLV.js → peers-DEOUIZM6.js} +1 -1
  90. package/dist/persona-UHAHIVST.js +390 -0
  91. package/dist/{pipeline-3G2FRAKM.js → pipeline-L4HCSBGN.js} +1 -1
  92. package/dist/{platform-server-H7Y6Q7O4.js → platform-server-2D6S6YTK.js} +412 -18
  93. package/dist/{plugin-update-checker-HMRPGY5Z.js → plugin-update-checker-ELOEEQYS.js} +1 -0
  94. package/dist/{portal-check-FF5EKZE5.js → portal-check-NPYGII2D.js} +2 -2
  95. package/dist/{portal-compliance-VU4NIFEN.js → portal-compliance-J7DGAPFX.js} +2 -2
  96. package/dist/{probe-7JK7IDNI.js → probe-MHL5HQZ2.js} +3 -3
  97. package/dist/{promote-XO63XMAN.js → promote-F6ZYZZAL.js} +2 -2
  98. package/dist/{providers-YNFSL6HK.js → providers-GK7PB2OL.js} +2 -2
  99. package/dist/{quiz-I75NU2QQ.js → quiz-M66SC7F7.js} +1 -1
  100. package/dist/{record-46CLR4OG.js → record-RA4WR2BO.js} +2 -2
  101. package/dist/{reindex-WIJMCJ4A.js → reindex-65H4WULU.js} +3 -2
  102. package/dist/{remember-4EUZKIIB.js → remember-HBWJ655S.js} +1 -1
  103. package/dist/{retag-KC4JVRLE.js → retag-3OLCVDEQ.js} +2 -2
  104. package/dist/{review-Q7M4CRB5.js → review-27ATYTD2.js} +2 -2
  105. package/dist/review-57QMURZV.js +334 -0
  106. package/dist/{ripple-RI3LOT6R.js → ripple-JPBXP5I3.js} +1 -1
  107. package/dist/{sentinel-UOIGJWHH.js → sentinel-4XIG4STA.js} +2 -2
  108. package/dist/{sentinel-bridge-APDXYAZS.js → sentinel-bridge-MDUXTQRL.js} +2 -2
  109. package/dist/{serve-KKEHE44G.js → serve-EFVRS4GA.js} +2 -2
  110. package/dist/{serve-22A4XOIG.js → serve-INL7SNBK.js} +2 -2
  111. package/dist/{serve-2YJ6D2Y6.js → serve-KBSE36PL.js} +4 -4
  112. package/dist/{server-JV6UFGWZ.js → server-54SKYFFY.js} +2 -2
  113. package/dist/{server-RDLQ3DK7.js → server-XUOIO7E6.js} +1 -1
  114. package/dist/{setup-YNZJQLW7.js → setup-EDS27WUR.js} +1 -1
  115. package/dist/{setup-M2ZKLKNN.js → setup-KO5AFC4K.js} +2 -2
  116. package/dist/{shift-LNMKFYLR.js → shift-VFG23DLA.js} +16 -16
  117. package/dist/{show-P7GYO43X.js → show-5PV5KFJE.js} +2 -2
  118. package/dist/{show-PKZMYKRN.js → show-NQKYX6WQ.js} +1 -1
  119. package/dist/{snapshot-Y3COXK4T.js → snapshot-BK4RBPCG.js} +1 -1
  120. package/dist/{spawn-SSXZX45U.js → spawn-AW6GDECS.js} +3 -3
  121. package/dist/{status-KLHALGW4.js → status-WGIAQODY.js} +1 -1
  122. package/dist/{summary-5NQNOD3F.js → summary-NIRABMF5.js} +2 -2
  123. package/dist/{sweep-EZU3GU6S.js → sweep-QMHNSIY5.js} +2 -2
  124. package/dist/{switch-WYUMVNA5.js → switch-6EJPZDIA.js} +1 -1
  125. package/dist/{symphony-6K3HD7AW.js → symphony-4OCY36AI.js} +5 -5
  126. package/dist/{symphony-YCHBYN3E.js → symphony-B75X2MME.js} +2 -2
  127. package/dist/{symphony-peers-HSY3RI3S.js → symphony-peers-2ZQYLRNI.js} +1 -1
  128. package/dist/{symphony-peers-APOGJPF4.js → symphony-peers-OL7F6M5S.js} +1 -0
  129. package/dist/{symphony-relay-GTAJRCVF.js → symphony-relay-UJYUXN65.js} +28 -1
  130. package/dist/{sync-ZM4Q3R4U.js → sync-VEHUH4OA.js} +3 -3
  131. package/dist/{sync-llms-JIPP3XX4.js → sync-llms-YHCFIE6X.js} +2 -2
  132. package/dist/{task-loader-7M2FCBX6.js → task-loader-LDYWQSLM.js} +1 -0
  133. package/dist/{team-HGLJXWQG.js → team-7HG7XK5C.js} +6 -6
  134. package/dist/{test-WTR5Q33E.js → test-566CP5KC.js} +1 -1
  135. package/dist/{thread-3WM7KKID.js → thread-N754I4D5.js} +1 -1
  136. package/dist/{timeline-ANC7LVDL.js → timeline-M3CICQFE.js} +2 -2
  137. package/dist/{triage-IZ4MDYNB.js → triage-HHYGT3HY.js} +1 -1
  138. package/dist/{tutorial-GC6QL4US.js → tutorial-KD22SUNO.js} +1 -1
  139. package/dist/university-content/courses/.purpose +66 -0
  140. package/dist/university-content/courses/para-401.json +146 -0
  141. package/dist/university-content/courses/para-501.json +67 -0
  142. package/dist/university-content/courses/para-601.json +690 -0
  143. package/dist/university-content/plsat/.purpose +6 -0
  144. package/dist/university-content/plsat/v2.0.json +2 -2
  145. package/dist/university-content/plsat/v3.0.json +563 -3
  146. package/dist/university-content/reference.json +91 -0
  147. package/dist/university-ui/assets/{index-tfi5xN4Q.js → index-C6bH_6xu.js} +2 -2
  148. package/dist/university-ui/assets/{index-tfi5xN4Q.js.map → index-C6bH_6xu.js.map} +1 -1
  149. package/dist/university-ui/index.html +1 -1
  150. package/dist/{upgrade-ANX3LVSA.js → upgrade-H5PF32BW.js} +2 -2
  151. package/dist/{validate-GD5XWILV.js → validate-CNKEKO6A.js} +1 -1
  152. package/dist/{validate-ITC5D6QG.js → validate-MB5ULIHS.js} +1 -1
  153. package/dist/{validate-ZVPNN4FL.js → validate-QH3LADM6.js} +1 -1
  154. package/dist/{watch-X64UK7K4.js → watch-2TKP5PVL.js} +3 -3
  155. package/dist/{watch-ERBEJUJW.js → watch-ZF4ML6CD.js} +2 -2
  156. package/dist/{wisdom-L2WC7J62.js → wisdom-AATMGNFA.js} +1 -1
  157. package/dist/work-log-loader-5L45XNYZ.js +14 -0
  158. package/dist/{workspace-UIUTHZTD.js → workspace-6E6OSRNU.js} +4 -4
  159. package/package.json +1 -1
  160. package/platform-ui/dist/assets/DocsSection-ByAgPzWV.js +1 -0
  161. package/platform-ui/dist/assets/DocsSection-CjdO6R-u.css +1 -0
  162. package/platform-ui/dist/assets/{GitSection-BD3Ze06e.js → GitSection-BLovj9yT.js} +1 -1
  163. package/platform-ui/dist/assets/{GraphSection-SglITfSs.js → GraphSection-C5PCPUFl.js} +1 -1
  164. package/platform-ui/dist/assets/{LoreSection-bR5Km4Fd.js → LoreSection-BftejTla.js} +1 -1
  165. package/platform-ui/dist/assets/{SentinelSection-QSpAZArG.js → SentinelSection-CnYcasN7.js} +1 -1
  166. package/platform-ui/dist/assets/{SymphonySection-CobYJgvg.js → SymphonySection-BpmqCHeK.js} +1 -1
  167. package/platform-ui/dist/assets/{index-DbxeSMkV.js → index-G9JnWEs_.js} +10 -10
  168. package/platform-ui/dist/index.html +1 -1
  169. package/dist/dist-PSF5CP4I.js +0 -7294
@@ -0,0 +1,712 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ../paradigm-mcp/src/utils/docs-loader.ts
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
+ import * as yaml from "js-yaml";
7
+ var SCAN_INDEX_PATH = ".paradigm/scan-index.json";
8
+ var FLOW_INDEX_PATH = ".paradigm/flow-index.json";
9
+ var CONFIG_PATH = ".paradigm/config.yaml";
10
+ var PORTAL_FILE = "portal.yaml";
11
+ var UNIVERSITY_INDEX_PATH = ".paradigm/university/index.yaml";
12
+ var DEFAULT_CONFIG = {
13
+ enabled: true,
14
+ title: null,
15
+ theme: "dark",
16
+ customCss: null,
17
+ customContent: "docs/",
18
+ exclude: { tags: [], patterns: [] },
19
+ sidebar: { collapsed: [] },
20
+ output: ".paradigm/docs-site"
21
+ };
22
+ function loadDocsConfig(rootDir) {
23
+ const configPath = path.join(rootDir, CONFIG_PATH);
24
+ if (!fs.existsSync(configPath)) {
25
+ return { ...DEFAULT_CONFIG };
26
+ }
27
+ try {
28
+ const raw = fs.readFileSync(configPath, "utf8");
29
+ const data = yaml.load(raw);
30
+ if (!data || !data.docs) return { ...DEFAULT_CONFIG };
31
+ const docs = data.docs;
32
+ return {
33
+ enabled: docs.enabled ?? DEFAULT_CONFIG.enabled,
34
+ title: docs.title ?? DEFAULT_CONFIG.title,
35
+ theme: docs.theme ?? DEFAULT_CONFIG.theme,
36
+ customCss: docs.customCss ?? DEFAULT_CONFIG.customCss,
37
+ customContent: docs.customContent ?? DEFAULT_CONFIG.customContent,
38
+ exclude: {
39
+ tags: docs.exclude?.tags ?? DEFAULT_CONFIG.exclude.tags,
40
+ patterns: docs.exclude?.patterns ?? DEFAULT_CONFIG.exclude.patterns
41
+ },
42
+ sidebar: {
43
+ collapsed: docs.sidebar?.collapsed ?? DEFAULT_CONFIG.sidebar.collapsed
44
+ },
45
+ output: docs.output ?? DEFAULT_CONFIG.output
46
+ };
47
+ } catch {
48
+ return { ...DEFAULT_CONFIG };
49
+ }
50
+ }
51
+ function loadScanIndex(rootDir) {
52
+ const filePath = path.join(rootDir, SCAN_INDEX_PATH);
53
+ if (!fs.existsSync(filePath)) return null;
54
+ try {
55
+ const raw = fs.readFileSync(filePath, "utf8");
56
+ return JSON.parse(raw);
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+ function loadFlowIndex(rootDir) {
62
+ const filePath = path.join(rootDir, FLOW_INDEX_PATH);
63
+ if (!fs.existsSync(filePath)) return null;
64
+ try {
65
+ const raw = fs.readFileSync(filePath, "utf8");
66
+ return JSON.parse(raw);
67
+ } catch {
68
+ return null;
69
+ }
70
+ }
71
+ function loadPortal(rootDir) {
72
+ const filePath = path.join(rootDir, PORTAL_FILE);
73
+ if (!fs.existsSync(filePath)) return null;
74
+ try {
75
+ const raw = fs.readFileSync(filePath, "utf8");
76
+ return yaml.load(raw);
77
+ } catch {
78
+ return null;
79
+ }
80
+ }
81
+ function loadUniversityIndex(rootDir) {
82
+ const filePath = path.join(rootDir, UNIVERSITY_INDEX_PATH);
83
+ if (!fs.existsSync(filePath)) return null;
84
+ try {
85
+ const raw = fs.readFileSync(filePath, "utf8");
86
+ return yaml.load(raw);
87
+ } catch {
88
+ return null;
89
+ }
90
+ }
91
+ function parseFrontmatter(content) {
92
+ const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
93
+ if (!match) return null;
94
+ try {
95
+ const frontmatter = yaml.load(match[1]);
96
+ return { frontmatter, body: match[2].trim() };
97
+ } catch {
98
+ return null;
99
+ }
100
+ }
101
+ function allEntries(scanIndex) {
102
+ const entries = /* @__PURE__ */ new Map();
103
+ const categories = [
104
+ scanIndex.components,
105
+ scanIndex.features,
106
+ scanIndex.flows,
107
+ scanIndex.state,
108
+ scanIndex.gates,
109
+ scanIndex.signals,
110
+ scanIndex.aspects
111
+ ];
112
+ for (const cat of categories) {
113
+ if (!cat) continue;
114
+ for (const [id, entry] of Object.entries(cat)) {
115
+ entries.set(id, entry);
116
+ }
117
+ }
118
+ return entries;
119
+ }
120
+ function categoryToSearchKind(category) {
121
+ const mapping = {
122
+ components: "component",
123
+ features: "component",
124
+ flows: "flow",
125
+ state: "component",
126
+ gates: "gate",
127
+ signals: "signal",
128
+ aspects: "aspect"
129
+ };
130
+ return mapping[category] || "component";
131
+ }
132
+ function isExcluded(entry, config) {
133
+ if (config.exclude.tags.length > 0 && entry.visualTags) {
134
+ for (const tag of entry.visualTags) {
135
+ if (config.exclude.tags.includes(tag)) return true;
136
+ }
137
+ }
138
+ if (config.exclude.patterns.length > 0 && entry.path) {
139
+ for (const pattern of config.exclude.patterns) {
140
+ if (pattern.endsWith("*")) {
141
+ const prefix = pattern.slice(0, -1);
142
+ if (entry.path.includes(prefix)) return true;
143
+ } else if (entry.path.includes(pattern)) {
144
+ return true;
145
+ }
146
+ }
147
+ }
148
+ return false;
149
+ }
150
+ function loadCustomPages(rootDir, customContentDir) {
151
+ const dir = path.join(rootDir, customContentDir);
152
+ if (!fs.existsSync(dir)) return [];
153
+ const pages = [];
154
+ try {
155
+ const files = fs.readdirSync(dir).filter((f) => f.endsWith(".md"));
156
+ for (const file of files) {
157
+ try {
158
+ const raw = fs.readFileSync(path.join(dir, file), "utf8");
159
+ const slug = file.replace(/\.md$/, "");
160
+ const parsed = parseFrontmatter(raw);
161
+ if (parsed) {
162
+ pages.push({
163
+ slug,
164
+ title: parsed.frontmatter.title || slug,
165
+ body: parsed.body,
166
+ order: typeof parsed.frontmatter.order === "number" ? parsed.frontmatter.order : void 0,
167
+ description: parsed.frontmatter.description || void 0
168
+ });
169
+ } else {
170
+ pages.push({
171
+ slug,
172
+ title: slug,
173
+ body: raw.trim()
174
+ });
175
+ }
176
+ } catch {
177
+ }
178
+ }
179
+ } catch {
180
+ }
181
+ pages.sort((a, b) => {
182
+ if (a.order != null && b.order != null) return a.order - b.order;
183
+ if (a.order != null) return -1;
184
+ if (b.order != null) return 1;
185
+ return a.title.localeCompare(b.title);
186
+ });
187
+ return pages;
188
+ }
189
+ function loadCustomPage(rootDir, slug, config) {
190
+ const resolvedConfig = config || loadDocsConfig(rootDir);
191
+ const dir = path.join(rootDir, resolvedConfig.customContent);
192
+ const filePath = path.join(dir, `${slug}.md`);
193
+ if (!fs.existsSync(filePath)) return null;
194
+ try {
195
+ const raw = fs.readFileSync(filePath, "utf8");
196
+ const parsed = parseFrontmatter(raw);
197
+ if (parsed) {
198
+ return {
199
+ slug,
200
+ title: parsed.frontmatter.title || slug,
201
+ body: parsed.body,
202
+ order: typeof parsed.frontmatter.order === "number" ? parsed.frontmatter.order : void 0,
203
+ description: parsed.frontmatter.description || void 0
204
+ };
205
+ }
206
+ return {
207
+ slug,
208
+ title: slug,
209
+ body: raw.trim()
210
+ };
211
+ } catch {
212
+ return null;
213
+ }
214
+ }
215
+ function buildDocsManifest(rootDir, config) {
216
+ const resolvedConfig = config || loadDocsConfig(rootDir);
217
+ const scanIndex = loadScanIndex(rootDir);
218
+ const flowIndex = loadFlowIndex(rootDir);
219
+ const portal = loadPortal(rootDir);
220
+ const customPages = loadCustomPages(rootDir, resolvedConfig.customContent);
221
+ const uniIndex = loadUniversityIndex(rootDir);
222
+ const projectName = scanIndex?.$meta?.project || path.basename(rootDir);
223
+ const title = resolvedConfig.title || `${projectName} Docs`;
224
+ const groups = [];
225
+ const symbolCounts = {};
226
+ let totalSymbols = 0;
227
+ if (customPages.length > 0) {
228
+ groups.push({
229
+ id: "custom-pages",
230
+ label: "Pages",
231
+ collapsed: resolvedConfig.sidebar.collapsed.includes("custom-pages"),
232
+ items: customPages.map((p) => ({
233
+ id: p.slug,
234
+ label: p.title,
235
+ kind: "custom",
236
+ description: p.description
237
+ }))
238
+ });
239
+ }
240
+ if (uniIndex && uniIndex.entries.length > 0) {
241
+ const guideEntries = uniIndex.entries.filter(
242
+ (e) => (e.type === "note" || e.type === "policy") && e.symbols.length > 0
243
+ );
244
+ if (guideEntries.length > 0) {
245
+ groups.push({
246
+ id: "guides",
247
+ label: "Guides",
248
+ collapsed: resolvedConfig.sidebar.collapsed.includes("guides"),
249
+ items: guideEntries.map((e) => ({
250
+ id: e.id,
251
+ label: e.title,
252
+ kind: "guide",
253
+ description: void 0,
254
+ badge: e.symbols.length > 0 ? `${e.symbols.length} symbols` : void 0
255
+ }))
256
+ });
257
+ }
258
+ }
259
+ if (scanIndex) {
260
+ const componentEntries = Object.values(scanIndex.components || {}).filter((e) => !isExcluded(e, resolvedConfig));
261
+ if (componentEntries.length > 0) {
262
+ const byType = /* @__PURE__ */ new Map();
263
+ for (const entry of componentEntries) {
264
+ const cType = entry.componentType || "other";
265
+ if (!byType.has(cType)) byType.set(cType, []);
266
+ byType.get(cType).push(entry);
267
+ }
268
+ const sortedTypes = [...byType.entries()].sort((a, b) => b[1].length - a[1].length);
269
+ const subgroups = sortedTypes.map(([cType, entries]) => ({
270
+ id: `components-${cType}`,
271
+ label: `${cType.charAt(0).toUpperCase() + cType.slice(1)} (${entries.length})`,
272
+ collapsed: resolvedConfig.sidebar.collapsed.includes(`components-${cType}`),
273
+ items: entries.sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({
274
+ id: e.id,
275
+ label: e.name,
276
+ kind: "component",
277
+ description: e.description,
278
+ badge: e.componentType
279
+ }))
280
+ }));
281
+ groups.push({
282
+ id: "components",
283
+ label: `Components (${componentEntries.length})`,
284
+ collapsed: resolvedConfig.sidebar.collapsed.includes("components"),
285
+ items: [],
286
+ subgroups
287
+ });
288
+ symbolCounts["components"] = componentEntries.length;
289
+ totalSymbols += componentEntries.length;
290
+ }
291
+ const featureEntries = Object.values(scanIndex.features || {}).filter((e) => !isExcluded(e, resolvedConfig));
292
+ if (featureEntries.length > 0) {
293
+ groups.push({
294
+ id: "features",
295
+ label: `Features (${featureEntries.length})`,
296
+ collapsed: resolvedConfig.sidebar.collapsed.includes("features"),
297
+ items: featureEntries.sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({
298
+ id: e.id,
299
+ label: e.name,
300
+ kind: "component",
301
+ description: e.description
302
+ }))
303
+ });
304
+ symbolCounts["features"] = featureEntries.length;
305
+ totalSymbols += featureEntries.length;
306
+ }
307
+ const flowEntries = Object.values(scanIndex.flows || {}).filter((e) => !isExcluded(e, resolvedConfig));
308
+ const flowIds = new Set(flowEntries.map((f) => f.id));
309
+ const additionalFlows = [];
310
+ if (flowIndex) {
311
+ for (const [fId, flow] of Object.entries(flowIndex.flows)) {
312
+ const cleanId = fId.replace(/^\$/, "");
313
+ if (!flowIds.has(cleanId)) {
314
+ additionalFlows.push({
315
+ id: cleanId,
316
+ label: flow.name || cleanId,
317
+ kind: "flow",
318
+ description: flow.description
319
+ });
320
+ }
321
+ }
322
+ }
323
+ const allFlowItems = [
324
+ ...flowEntries.sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({
325
+ id: e.id,
326
+ label: e.name,
327
+ kind: "flow",
328
+ description: e.description
329
+ })),
330
+ ...additionalFlows
331
+ ];
332
+ if (allFlowItems.length > 0) {
333
+ groups.push({
334
+ id: "flows",
335
+ label: `Flows (${allFlowItems.length})`,
336
+ collapsed: resolvedConfig.sidebar.collapsed.includes("flows"),
337
+ items: allFlowItems
338
+ });
339
+ symbolCounts["flows"] = allFlowItems.length;
340
+ totalSymbols += allFlowItems.length;
341
+ }
342
+ const gateEntries = Object.values(scanIndex.gates || {}).filter((e) => !isExcluded(e, resolvedConfig));
343
+ if (gateEntries.length > 0) {
344
+ groups.push({
345
+ id: "gates",
346
+ label: `Gates (${gateEntries.length})`,
347
+ collapsed: resolvedConfig.sidebar.collapsed.includes("gates"),
348
+ items: gateEntries.sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({
349
+ id: e.id,
350
+ label: e.name,
351
+ kind: "gate",
352
+ description: e.description
353
+ }))
354
+ });
355
+ symbolCounts["gates"] = gateEntries.length;
356
+ totalSymbols += gateEntries.length;
357
+ }
358
+ const signalEntries = Object.values(scanIndex.signals || {}).filter((e) => !isExcluded(e, resolvedConfig));
359
+ if (signalEntries.length > 0) {
360
+ groups.push({
361
+ id: "signals",
362
+ label: `Signals (${signalEntries.length})`,
363
+ collapsed: resolvedConfig.sidebar.collapsed.includes("signals"),
364
+ items: signalEntries.sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({
365
+ id: e.id,
366
+ label: e.name,
367
+ kind: "signal",
368
+ description: e.description
369
+ }))
370
+ });
371
+ symbolCounts["signals"] = signalEntries.length;
372
+ totalSymbols += signalEntries.length;
373
+ }
374
+ const aspectEntries = Object.values(scanIndex.aspects || {}).filter((e) => !isExcluded(e, resolvedConfig));
375
+ if (aspectEntries.length > 0) {
376
+ groups.push({
377
+ id: "aspects",
378
+ label: `Aspects (${aspectEntries.length})`,
379
+ collapsed: resolvedConfig.sidebar.collapsed.includes("aspects"),
380
+ items: aspectEntries.sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({
381
+ id: e.id,
382
+ label: e.name,
383
+ kind: "aspect",
384
+ description: e.description
385
+ }))
386
+ });
387
+ symbolCounts["aspects"] = aspectEntries.length;
388
+ totalSymbols += aspectEntries.length;
389
+ }
390
+ }
391
+ if (portal) {
392
+ const routeCount = Object.keys(portal.routes || {}).length;
393
+ const gateCount = Object.keys(portal.gates || {}).length;
394
+ groups.push({
395
+ id: "portal",
396
+ label: "Portal",
397
+ collapsed: resolvedConfig.sidebar.collapsed.includes("portal"),
398
+ items: [{
399
+ id: "portal-overview",
400
+ label: "Authorization Overview",
401
+ kind: "portal",
402
+ description: `${gateCount} gates, ${routeCount} routes`,
403
+ badge: `${routeCount} routes`
404
+ }]
405
+ });
406
+ }
407
+ return {
408
+ title,
409
+ project: projectName,
410
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
411
+ groups,
412
+ totalSymbols,
413
+ symbolCounts
414
+ };
415
+ }
416
+ function buildSymbolPage(rootDir, symbolId) {
417
+ const scanIndex = loadScanIndex(rootDir);
418
+ if (!scanIndex) return null;
419
+ const entries = allEntries(scanIndex);
420
+ const entry = entries.get(symbolId);
421
+ if (!entry) return null;
422
+ const referencedBy = [];
423
+ for (const [otherId, otherEntry] of entries) {
424
+ if (otherId === symbolId) continue;
425
+ if (otherEntry.related && otherEntry.related.includes(entry.symbol)) {
426
+ referencedBy.push(otherEntry.symbol);
427
+ }
428
+ }
429
+ const references = (entry.related || []).slice();
430
+ const flows = [];
431
+ const flowIndex = loadFlowIndex(rootDir);
432
+ if (flowIndex) {
433
+ for (const [fId, flow] of Object.entries(flowIndex.flows)) {
434
+ const stepSymbols = (flow.steps || []).map((s) => s.symbol);
435
+ if (stepSymbols.includes(entry.symbol) || stepSymbols.includes(`#${symbolId}`)) {
436
+ flows.push({ id: fId.replace(/^\$/, ""), name: flow.name || fId });
437
+ }
438
+ }
439
+ }
440
+ if (scanIndex.flows) {
441
+ for (const [fId, flow] of Object.entries(scanIndex.flows)) {
442
+ if (flows.some((f) => f.id === fId)) continue;
443
+ const stepSymbols = (flow.steps || []).map((s) => s.symbol).filter(Boolean);
444
+ if (stepSymbols.includes(entry.symbol) || stepSymbols.includes(`#${symbolId}`)) {
445
+ flows.push({ id: fId, name: flow.name });
446
+ }
447
+ }
448
+ }
449
+ const gates = [];
450
+ const portal = loadPortal(rootDir);
451
+ if (portal && entry.category === "gates") {
452
+ const gateKey = Object.keys(portal.gates || {}).find(
453
+ (k) => k.replace(/^\^/, "") === symbolId
454
+ );
455
+ if (gateKey) {
456
+ gates.push({
457
+ id: gateKey.replace(/^\^/, ""),
458
+ description: portal.gates[gateKey].description
459
+ });
460
+ }
461
+ } else if (portal) {
462
+ const relatedGateSymbols = new Set((entry.related || []).filter((r) => r.startsWith("^")));
463
+ for (const [_route, routeGates] of Object.entries(portal.routes || {})) {
464
+ for (const gateRef of routeGates) {
465
+ const cleanGate = gateRef.replace(/^\^/, "");
466
+ if (relatedGateSymbols.has(gateRef) || relatedGateSymbols.has(`^${cleanGate}`)) {
467
+ const gateEntry = portal.gates[gateRef] || portal.gates[`^${cleanGate}`] || portal.gates[cleanGate];
468
+ if (gateEntry && !gates.some((g) => g.id === cleanGate)) {
469
+ gates.push({ id: cleanGate, description: gateEntry.description });
470
+ }
471
+ }
472
+ }
473
+ }
474
+ }
475
+ const aspects = [];
476
+ if (scanIndex.aspects) {
477
+ for (const [_aId, aspect] of Object.entries(scanIndex.aspects)) {
478
+ if (aspect.related && aspect.related.includes(entry.symbol)) {
479
+ aspects.push(aspect.symbol);
480
+ }
481
+ }
482
+ }
483
+ for (const ref of entry.related || []) {
484
+ if (ref.startsWith("~") && !aspects.includes(ref)) {
485
+ aspects.push(ref);
486
+ }
487
+ }
488
+ const guides = [];
489
+ const uniIndex = loadUniversityIndex(rootDir);
490
+ if (uniIndex) {
491
+ for (const uEntry of uniIndex.entries) {
492
+ if (uEntry.symbols.includes(entry.symbol)) {
493
+ guides.push({ id: uEntry.id, title: uEntry.title });
494
+ }
495
+ }
496
+ }
497
+ const parent = entry.parent || void 0;
498
+ const children = [];
499
+ if (scanIndex.components) {
500
+ for (const comp of Object.values(scanIndex.components)) {
501
+ if (comp.parent === entry.symbol) {
502
+ children.push(comp.symbol);
503
+ }
504
+ }
505
+ }
506
+ return {
507
+ id: entry.id,
508
+ symbol: entry.symbol,
509
+ name: entry.name,
510
+ description: entry.description || "",
511
+ category: entry.category || "components",
512
+ componentType: entry.componentType,
513
+ tags: entry.visualTags || [],
514
+ path: entry.path || "",
515
+ related: entry.related || [],
516
+ referencedBy,
517
+ references,
518
+ flows,
519
+ gates,
520
+ aspects,
521
+ guides,
522
+ parent,
523
+ children
524
+ };
525
+ }
526
+ function buildFlowPage(rootDir, flowId) {
527
+ const flowIndex = loadFlowIndex(rootDir);
528
+ const scanIndex = loadScanIndex(rootDir);
529
+ if (flowIndex) {
530
+ const flowKey = flowIndex.flows[`$${flowId}`] ? `$${flowId}` : flowId;
531
+ const flow = flowIndex.flows[flowKey];
532
+ if (flow) {
533
+ const steps = (flow.steps || []).map((s) => ({
534
+ type: s.type || "action",
535
+ symbol: s.symbol || "",
536
+ description: s.description
537
+ }));
538
+ const scanEntry = scanIndex?.flows?.[flowId.replace(/^\$/, "")];
539
+ return {
540
+ id: flowId.replace(/^\$/, ""),
541
+ symbol: `$${flowId.replace(/^\$/, "")}`,
542
+ name: flow.name || flowId,
543
+ description: flow.description,
544
+ trigger: flow.trigger,
545
+ steps,
546
+ successSignal: flow.successSignal,
547
+ errorSignal: flow.errorSignal,
548
+ tags: scanEntry?.visualTags || [],
549
+ path: scanEntry?.path || flow.definedIn || ""
550
+ };
551
+ }
552
+ }
553
+ if (scanIndex?.flows) {
554
+ const cleanId = flowId.replace(/^\$/, "");
555
+ const scanFlow = scanIndex.flows[cleanId];
556
+ if (scanFlow) {
557
+ const steps = (scanFlow.steps || []).map((s) => ({
558
+ type: "action",
559
+ symbol: s.symbol || "",
560
+ description: s.action || s.name
561
+ }));
562
+ return {
563
+ id: cleanId,
564
+ symbol: `$${cleanId}`,
565
+ name: scanFlow.name,
566
+ description: scanFlow.description,
567
+ steps,
568
+ tags: scanFlow.visualTags || [],
569
+ path: scanFlow.path || ""
570
+ };
571
+ }
572
+ }
573
+ return null;
574
+ }
575
+ function buildPortalPage(rootDir) {
576
+ const portal = loadPortal(rootDir);
577
+ if (!portal) {
578
+ return { version: "0", gates: [], routes: [] };
579
+ }
580
+ const gateRouteMap = /* @__PURE__ */ new Map();
581
+ for (const [routeKey, routeGates] of Object.entries(portal.routes || {})) {
582
+ for (const gateRef of routeGates) {
583
+ const cleanGate = gateRef.replace(/^\^/, "");
584
+ if (!gateRouteMap.has(cleanGate)) gateRouteMap.set(cleanGate, []);
585
+ gateRouteMap.get(cleanGate).push(routeKey);
586
+ }
587
+ }
588
+ const gates = Object.entries(portal.gates || {}).map(([key, gate]) => {
589
+ const cleanKey = key.replace(/^\^/, "");
590
+ return {
591
+ symbol: `^${cleanKey}`,
592
+ description: gate.description,
593
+ check: gate.check,
594
+ routes: gateRouteMap.get(cleanKey) || []
595
+ };
596
+ });
597
+ const routes = Object.entries(portal.routes || {}).map(([routeKey, routeGates]) => {
598
+ const spaceIdx = routeKey.indexOf(" ");
599
+ const method = spaceIdx > 0 ? routeKey.substring(0, spaceIdx) : "GET";
600
+ const route = spaceIdx > 0 ? routeKey.substring(spaceIdx + 1) : routeKey;
601
+ return {
602
+ route,
603
+ method,
604
+ gates: routeGates.map((gateRef) => {
605
+ const cleanGate = gateRef.replace(/^\^/, "");
606
+ const gateEntry = portal.gates[gateRef] || portal.gates[`^${cleanGate}`] || portal.gates[cleanGate];
607
+ return {
608
+ symbol: `^${cleanGate}`,
609
+ description: gateEntry?.description
610
+ };
611
+ })
612
+ };
613
+ });
614
+ return {
615
+ version: portal.version || "1.0",
616
+ gates,
617
+ routes
618
+ };
619
+ }
620
+ function searchDocs(rootDir, query, limit) {
621
+ const maxResults = limit || 20;
622
+ const results = [];
623
+ const queryLower = query.toLowerCase();
624
+ const scanIndex = loadScanIndex(rootDir);
625
+ if (scanIndex) {
626
+ const entries = allEntries(scanIndex);
627
+ for (const [_id, entry] of entries) {
628
+ const score = scoreMatch(entry.name, entry.description || "", entry.visualTags || [], queryLower);
629
+ if (score > 0) {
630
+ results.push({
631
+ id: entry.id,
632
+ kind: categoryToSearchKind(entry.category),
633
+ label: entry.name,
634
+ description: entry.description || "",
635
+ matchContext: buildMatchContext(entry.name, entry.description || "", queryLower),
636
+ score
637
+ });
638
+ }
639
+ }
640
+ }
641
+ const config = loadDocsConfig(rootDir);
642
+ const customPages = loadCustomPages(rootDir, config.customContent);
643
+ for (const page of customPages) {
644
+ const bodySnippet = page.body.substring(0, 200);
645
+ const score = scoreMatch(page.title, bodySnippet, [], queryLower);
646
+ if (score > 0) {
647
+ results.push({
648
+ id: page.slug,
649
+ kind: "custom",
650
+ label: page.title,
651
+ description: page.description || bodySnippet.substring(0, 100),
652
+ matchContext: buildMatchContext(page.title, page.body, queryLower),
653
+ score
654
+ });
655
+ }
656
+ }
657
+ const portal = loadPortal(rootDir);
658
+ if (portal) {
659
+ for (const [key, gate] of Object.entries(portal.gates || {})) {
660
+ const cleanKey = key.replace(/^\^/, "");
661
+ const score = scoreMatch(cleanKey, gate.description, [], queryLower);
662
+ if (score > 0) {
663
+ results.push({
664
+ id: cleanKey,
665
+ kind: "portal",
666
+ label: `^${cleanKey}`,
667
+ description: gate.description,
668
+ score
669
+ });
670
+ }
671
+ }
672
+ }
673
+ results.sort((a, b) => b.score - a.score || a.label.localeCompare(b.label));
674
+ return results.slice(0, maxResults);
675
+ }
676
+ function scoreMatch(name, description, tags, queryLower) {
677
+ const nameLower = name.toLowerCase();
678
+ const descLower = description.toLowerCase();
679
+ if (nameLower === queryLower) return 1;
680
+ if (nameLower.startsWith(queryLower)) return 0.8;
681
+ if (nameLower.includes(queryLower)) return 0.6;
682
+ if (descLower.includes(queryLower)) return 0.5;
683
+ if (tags.some((t) => t.toLowerCase().includes(queryLower))) return 0.3;
684
+ return 0;
685
+ }
686
+ function buildMatchContext(name, text, queryLower) {
687
+ const textLower = text.toLowerCase();
688
+ const idx = textLower.indexOf(queryLower);
689
+ if (idx < 0) {
690
+ if (name.toLowerCase().includes(queryLower)) {
691
+ return name;
692
+ }
693
+ return void 0;
694
+ }
695
+ const start = Math.max(0, idx - 40);
696
+ const end = Math.min(text.length, idx + queryLower.length + 40);
697
+ let snippet = text.substring(start, end).trim();
698
+ if (start > 0) snippet = `...${snippet}`;
699
+ if (end < text.length) snippet = `${snippet}...`;
700
+ return snippet;
701
+ }
702
+
703
+ export {
704
+ loadDocsConfig,
705
+ loadCustomPages,
706
+ loadCustomPage,
707
+ buildDocsManifest,
708
+ buildSymbolPage,
709
+ buildFlowPage,
710
+ buildPortalPage,
711
+ searchDocs
712
+ };