@contractspec/lib.contracts-spec 2.0.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 (1058) hide show
  1. package/README.md +3 -0
  2. package/dist/app-config/app-config.capability.d.ts +1 -0
  3. package/dist/app-config/app-config.capability.js +730 -0
  4. package/dist/app-config/app-config.contracts.d.ts +239 -0
  5. package/dist/app-config/app-config.contracts.js +713 -0
  6. package/dist/app-config/app-config.contracts.test.d.ts +1 -0
  7. package/dist/app-config/app-config.feature.d.ts +5 -0
  8. package/dist/app-config/app-config.feature.js +255 -0
  9. package/dist/app-config/branding.d.ts +52 -0
  10. package/dist/app-config/branding.js +1 -0
  11. package/dist/app-config/branding.test.d.ts +1 -0
  12. package/dist/app-config/docs/app-config.docblock.d.ts +2 -0
  13. package/dist/app-config/docs/app-config.docblock.js +383 -0
  14. package/dist/app-config/events.d.ts +115 -0
  15. package/dist/app-config/events.js +386 -0
  16. package/dist/app-config/events.test.d.ts +1 -0
  17. package/dist/app-config/index.d.ts +9 -0
  18. package/dist/app-config/index.js +2899 -0
  19. package/dist/app-config/lifecycle-contracts.d.ts +265 -0
  20. package/dist/app-config/lifecycle-contracts.js +870 -0
  21. package/dist/app-config/lifecycle-contracts.test.d.ts +1 -0
  22. package/dist/app-config/lifecycle.d.ts +23 -0
  23. package/dist/app-config/lifecycle.js +1 -0
  24. package/dist/app-config/lifecycle.test.d.ts +1 -0
  25. package/dist/app-config/runtime.d.ts +111 -0
  26. package/dist/app-config/runtime.js +734 -0
  27. package/dist/app-config/runtime.test.d.ts +1 -0
  28. package/dist/app-config/spec.d.ts +169 -0
  29. package/dist/app-config/spec.js +229 -0
  30. package/dist/app-config/spec.test.d.ts +1 -0
  31. package/dist/app-config/validation.d.ts +43 -0
  32. package/dist/app-config/validation.js +650 -0
  33. package/dist/app-config/validation.test.d.ts +1 -0
  34. package/dist/capabilities/capabilities.d.ts +96 -0
  35. package/dist/capabilities/capabilities.js +217 -0
  36. package/dist/capabilities/capabilities.test.d.ts +1 -0
  37. package/dist/capabilities/context.d.ts +110 -0
  38. package/dist/capabilities/context.js +101 -0
  39. package/dist/capabilities/context.test.d.ts +1 -0
  40. package/dist/capabilities/docs/capabilities.docblock.d.ts +2 -0
  41. package/dist/capabilities/docs/capabilities.docblock.js +353 -0
  42. package/dist/capabilities/guards.d.ts +121 -0
  43. package/dist/capabilities/guards.js +177 -0
  44. package/dist/capabilities/index.d.ts +6 -0
  45. package/dist/capabilities/index.js +739 -0
  46. package/dist/capabilities/meeting-recorder.d.ts +5 -0
  47. package/dist/capabilities/meeting-recorder.js +154 -0
  48. package/dist/capabilities/openbanking.d.ts +5 -0
  49. package/dist/capabilities/openbanking.js +166 -0
  50. package/dist/capabilities/validation.d.ts +79 -0
  51. package/dist/capabilities/validation.js +185 -0
  52. package/dist/capabilities/validation.test.d.ts +1 -0
  53. package/dist/contract-registry/index.d.ts +3 -0
  54. package/dist/contract-registry/index.js +129 -0
  55. package/dist/contract-registry/schemas.d.ts +120 -0
  56. package/dist/contract-registry/schemas.js +129 -0
  57. package/dist/contract-registry/schemas.test.d.ts +1 -0
  58. package/dist/contract-registry/types.d.ts +42 -0
  59. package/dist/contract-registry/types.js +1 -0
  60. package/dist/data-views/data-views.d.ts +4 -0
  61. package/dist/data-views/data-views.js +232 -0
  62. package/dist/data-views/data-views.test.d.ts +1 -0
  63. package/dist/data-views/docs/data-views.docblock.d.ts +2 -0
  64. package/dist/data-views/docs/data-views.docblock.js +164 -0
  65. package/dist/data-views/index.d.ts +4 -0
  66. package/dist/data-views/index.js +232 -0
  67. package/dist/data-views/query-generator.d.ts +35 -0
  68. package/dist/data-views/query-generator.js +89 -0
  69. package/dist/data-views/registry.d.ts +12 -0
  70. package/dist/data-views/registry.js +226 -0
  71. package/dist/data-views/registry.test.d.ts +1 -0
  72. package/dist/data-views/report/contractVerificationTable.d.ts +4 -0
  73. package/dist/data-views/report/contractVerificationTable.js +240 -0
  74. package/dist/data-views/report/contractVerificationTable.test.d.ts +1 -0
  75. package/dist/data-views/runtime.d.ts +25 -0
  76. package/dist/data-views/runtime.js +108 -0
  77. package/dist/data-views/runtime.test.d.ts +1 -0
  78. package/dist/data-views/spec.d.ts +22 -0
  79. package/dist/data-views/spec.js +38 -0
  80. package/dist/data-views/spec.test.d.ts +1 -0
  81. package/dist/data-views/types.d.ts +152 -0
  82. package/dist/data-views/types.js +1 -0
  83. package/dist/data-views/types.test.d.ts +1 -0
  84. package/dist/docs/accessibility_wcag_compliance_specs.docblock.d.ts +2 -0
  85. package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +513 -0
  86. package/dist/docs/capabilities/documentationSystem.capability.d.ts +1 -0
  87. package/dist/docs/capabilities/documentationSystem.capability.js +784 -0
  88. package/dist/docs/capabilities/index.d.ts +1 -0
  89. package/dist/docs/capabilities/index.js +784 -0
  90. package/dist/docs/commands/docsGenerate.command.d.ts +88 -0
  91. package/dist/docs/commands/docsGenerate.command.js +802 -0
  92. package/dist/docs/commands/docsPublish.command.d.ts +57 -0
  93. package/dist/docs/commands/docsPublish.command.js +781 -0
  94. package/dist/docs/commands/index.d.ts +2 -0
  95. package/dist/docs/commands/index.js +906 -0
  96. package/dist/docs/constants.d.ts +4 -0
  97. package/dist/docs/constants.js +78 -0
  98. package/dist/docs/contracts.d.ts +430 -0
  99. package/dist/docs/contracts.js +1611 -0
  100. package/dist/docs/ensure-docblocks.d.ts +1 -0
  101. package/dist/docs/ensure-docblocks.js +264 -0
  102. package/dist/docs/events/docsGenerated.event.d.ts +56 -0
  103. package/dist/docs/events/docsGenerated.event.js +533 -0
  104. package/dist/docs/events/docsPublished.event.d.ts +64 -0
  105. package/dist/docs/events/docsPublished.event.js +534 -0
  106. package/dist/docs/events/index.d.ts +2 -0
  107. package/dist/docs/events/index.js +567 -0
  108. package/dist/docs/forms/docsSearch.form.d.ts +16 -0
  109. package/dist/docs/forms/docsSearch.form.js +676 -0
  110. package/dist/docs/forms/index.d.ts +1 -0
  111. package/dist/docs/forms/index.js +676 -0
  112. package/dist/docs/index.d.ts +40 -0
  113. package/dist/docs/index.js +4719 -0
  114. package/dist/docs/meta.docs.d.ts +2 -0
  115. package/dist/docs/meta.docs.js +176 -0
  116. package/dist/docs/presentations/docsLayout.presentation.d.ts +2 -0
  117. package/dist/docs/presentations/docsLayout.presentation.js +527 -0
  118. package/dist/docs/presentations/docsReferencePage.presentation.d.ts +2 -0
  119. package/dist/docs/presentations/docsReferencePage.presentation.js +527 -0
  120. package/dist/docs/presentations/index.d.ts +2 -0
  121. package/dist/docs/presentations/index.js +555 -0
  122. package/dist/docs/presentations.d.ts +27 -0
  123. package/dist/docs/presentations.js +97 -0
  124. package/dist/docs/presentations.test.d.ts +1 -0
  125. package/dist/docs/queries/contractReference.query.d.ts +211 -0
  126. package/dist/docs/queries/contractReference.query.js +752 -0
  127. package/dist/docs/queries/docsIndex.query.d.ts +266 -0
  128. package/dist/docs/queries/docsIndex.query.js +752 -0
  129. package/dist/docs/queries/index.d.ts +2 -0
  130. package/dist/docs/queries/index.js +827 -0
  131. package/dist/docs/registry.d.ts +19 -0
  132. package/dist/docs/registry.js +153 -0
  133. package/dist/docs/registry.test.d.ts +1 -0
  134. package/dist/docs/tech/auth/better-auth-nextjs.docblock.d.ts +2 -0
  135. package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +221 -0
  136. package/dist/docs/tech/cli.docblock.d.ts +2 -0
  137. package/dist/docs/tech/cli.docblock.js +291 -0
  138. package/dist/docs/tech/contracts/README.docblock.d.ts +2 -0
  139. package/dist/docs/tech/contracts/README.docblock.js +164 -0
  140. package/dist/docs/tech/contracts/migrations.docblock.d.ts +2 -0
  141. package/dist/docs/tech/contracts/migrations.docblock.js +164 -0
  142. package/dist/docs/tech/contracts/openapi-export.docblock.d.ts +2 -0
  143. package/dist/docs/tech/contracts/openapi-export.docblock.js +201 -0
  144. package/dist/docs/tech/contracts/openapi-import.docblock.d.ts +2 -0
  145. package/dist/docs/tech/contracts/openapi-import.docblock.js +207 -0
  146. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.d.ts +2 -0
  147. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +225 -0
  148. package/dist/docs/tech/contracts/overlays.docblock.d.ts +2 -0
  149. package/dist/docs/tech/contracts/overlays.docblock.js +231 -0
  150. package/dist/docs/tech/contracts/tests.docblock.d.ts +2 -0
  151. package/dist/docs/tech/contracts/tests.docblock.js +164 -0
  152. package/dist/docs/tech/contracts/themes.docblock.d.ts +2 -0
  153. package/dist/docs/tech/contracts/themes.docblock.js +257 -0
  154. package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.d.ts +2 -0
  155. package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +269 -0
  156. package/dist/docs/tech/docs-system.docblock.d.ts +1 -0
  157. package/dist/docs/tech/docs-system.docblock.js +264 -0
  158. package/dist/docs/tech/lifecycle-stage-system.docblock.d.ts +2 -0
  159. package/dist/docs/tech/lifecycle-stage-system.docblock.js +376 -0
  160. package/dist/docs/tech/llm/llm-integration.docblock.d.ts +7 -0
  161. package/dist/docs/tech/llm/llm-integration.docblock.js +482 -0
  162. package/dist/docs/tech/mcp-endpoints.docblock.d.ts +2 -0
  163. package/dist/docs/tech/mcp-endpoints.docblock.js +185 -0
  164. package/dist/docs/tech/presentation-runtime.docblock.d.ts +2 -0
  165. package/dist/docs/tech/presentation-runtime.docblock.js +221 -0
  166. package/dist/docs/tech/report-verification-table.docblock.d.ts +1 -0
  167. package/dist/docs/tech/report-verification-table.docblock.js +191 -0
  168. package/dist/docs/tech/report-verification-table.test.d.ts +1 -0
  169. package/dist/docs/tech/schema/README.docblock.d.ts +2 -0
  170. package/dist/docs/tech/schema/README.docblock.js +164 -0
  171. package/dist/docs/tech/studio/learning-events.docblock.d.ts +2 -0
  172. package/dist/docs/tech/studio/learning-events.docblock.js +190 -0
  173. package/dist/docs/tech/studio/learning-journeys.docblock.d.ts +2 -0
  174. package/dist/docs/tech/studio/learning-journeys.docblock.js +227 -0
  175. package/dist/docs/tech/studio/platform-admin-panel.docblock.d.ts +2 -0
  176. package/dist/docs/tech/studio/platform-admin-panel.docblock.js +226 -0
  177. package/dist/docs/tech/studio/project-access-teams.docblock.d.ts +2 -0
  178. package/dist/docs/tech/studio/project-access-teams.docblock.js +200 -0
  179. package/dist/docs/tech/studio/project-routing.docblock.d.ts +2 -0
  180. package/dist/docs/tech/studio/project-routing.docblock.js +209 -0
  181. package/dist/docs/tech/studio/sandbox-unlogged.docblock.d.ts +2 -0
  182. package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +183 -0
  183. package/dist/docs/tech/studio/team-invitations.docblock.d.ts +2 -0
  184. package/dist/docs/tech/studio/team-invitations.docblock.js +228 -0
  185. package/dist/docs/tech/studio/workspace-ops.docblock.d.ts +2 -0
  186. package/dist/docs/tech/studio/workspace-ops.docblock.js +189 -0
  187. package/dist/docs/tech/studio/workspaces.docblock.d.ts +2 -0
  188. package/dist/docs/tech/studio/workspaces.docblock.js +204 -0
  189. package/dist/docs/tech/telemetry-ingest.docblock.d.ts +2 -0
  190. package/dist/docs/tech/telemetry-ingest.docblock.js +305 -0
  191. package/dist/docs/tech/vscode-extension.docblock.d.ts +2 -0
  192. package/dist/docs/tech/vscode-extension.docblock.js +241 -0
  193. package/dist/docs/tech-contracts.docs.d.ts +2 -0
  194. package/dist/docs/tech-contracts.docs.js +239 -0
  195. package/dist/docs/types.d.ts +37 -0
  196. package/dist/docs/types.js +1 -0
  197. package/dist/docs/views/contractReference.dataView.d.ts +2 -0
  198. package/dist/docs/views/contractReference.dataView.js +838 -0
  199. package/dist/docs/views/docsIndex.dataView.d.ts +2 -0
  200. package/dist/docs/views/docsIndex.dataView.js +832 -0
  201. package/dist/docs/views/exampleCatalog.dataView.d.ts +2 -0
  202. package/dist/docs/views/exampleCatalog.dataView.js +816 -0
  203. package/dist/docs/views/index.d.ts +3 -0
  204. package/dist/docs/views/index.js +1031 -0
  205. package/dist/events.d.ts +142 -0
  206. package/dist/events.js +228 -0
  207. package/dist/events.test.d.ts +1 -0
  208. package/dist/examples/define.d.ts +5 -0
  209. package/dist/examples/define.js +36 -0
  210. package/dist/examples/docs/examples.docblock.d.ts +2 -0
  211. package/dist/examples/docs/examples.docblock.js +307 -0
  212. package/dist/examples/index.d.ts +7 -0
  213. package/dist/examples/index.js +604 -0
  214. package/dist/examples/registry.d.ts +38 -0
  215. package/dist/examples/registry.js +286 -0
  216. package/dist/examples/registry.test.d.ts +1 -0
  217. package/dist/examples/schema.d.ts +278 -0
  218. package/dist/examples/schema.js +166 -0
  219. package/dist/examples/schema.test.d.ts +1 -0
  220. package/dist/examples/types.d.ts +162 -0
  221. package/dist/examples/types.js +77 -0
  222. package/dist/examples/types.test.d.ts +1 -0
  223. package/dist/examples/validation.d.ts +61 -0
  224. package/dist/examples/validation.js +287 -0
  225. package/dist/examples/validation.test.d.ts +1 -0
  226. package/dist/experiments/docs/experiments.docblock.d.ts +2 -0
  227. package/dist/experiments/docs/experiments.docblock.js +291 -0
  228. package/dist/experiments/evaluator.d.ts +33 -0
  229. package/dist/experiments/evaluator.js +155 -0
  230. package/dist/experiments/evaluator.test.d.ts +1 -0
  231. package/dist/experiments/spec-resolver.d.ts +12 -0
  232. package/dist/experiments/spec-resolver.js +1 -0
  233. package/dist/experiments/spec.d.ts +79 -0
  234. package/dist/experiments/spec.js +227 -0
  235. package/dist/experiments/spec.test.d.ts +1 -0
  236. package/dist/features/index.d.ts +5 -0
  237. package/dist/features/index.js +275 -0
  238. package/dist/features/install.d.ts +14 -0
  239. package/dist/features/install.js +95 -0
  240. package/dist/features/install.test.d.ts +1 -0
  241. package/dist/features/registry.d.ts +21 -0
  242. package/dist/features/registry.js +192 -0
  243. package/dist/features/registry.test.d.ts +1 -0
  244. package/dist/features/types.d.ts +82 -0
  245. package/dist/features/types.js +36 -0
  246. package/dist/features/types.test.d.ts +1 -0
  247. package/dist/features/validation.d.ts +4 -0
  248. package/dist/features/validation.js +48 -0
  249. package/dist/features/validation.test.d.ts +1 -0
  250. package/dist/features.capabilities.test.d.ts +1 -0
  251. package/dist/forms/docs/forms.docblock.d.ts +2 -0
  252. package/dist/forms/docs/forms.docblock.js +164 -0
  253. package/dist/forms/forms.d.ts +264 -0
  254. package/dist/forms/forms.js +332 -0
  255. package/dist/forms/index.d.ts +1 -0
  256. package/dist/forms/index.js +332 -0
  257. package/dist/index.d.ts +36 -0
  258. package/dist/index.js +2195 -0
  259. package/dist/install.d.ts +75 -0
  260. package/dist/install.js +60 -0
  261. package/dist/integrations/binding.d.ts +14 -0
  262. package/dist/integrations/binding.js +1 -0
  263. package/dist/integrations/connection.d.ts +47 -0
  264. package/dist/integrations/connection.js +1 -0
  265. package/dist/integrations/docs/integrations.docblock.d.ts +2 -0
  266. package/dist/integrations/docs/integrations.docblock.js +140 -0
  267. package/dist/integrations/health.d.ts +17 -0
  268. package/dist/integrations/health.js +103 -0
  269. package/dist/integrations/health.test.d.ts +1 -0
  270. package/dist/integrations/index.d.ts +11 -0
  271. package/dist/integrations/index.js +3293 -0
  272. package/dist/integrations/integrations.capability.d.ts +1 -0
  273. package/dist/integrations/integrations.capability.js +48 -0
  274. package/dist/integrations/integrations.feature.d.ts +5 -0
  275. package/dist/integrations/integrations.feature.js +63 -0
  276. package/dist/integrations/meeting-recorder/contracts/index.d.ts +7 -0
  277. package/dist/integrations/meeting-recorder/contracts/index.js +504 -0
  278. package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +451 -0
  279. package/dist/integrations/meeting-recorder/contracts/meetings.js +249 -0
  280. package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +166 -0
  281. package/dist/integrations/meeting-recorder/contracts/transcripts.js +317 -0
  282. package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +85 -0
  283. package/dist/integrations/meeting-recorder/contracts/webhooks.js +202 -0
  284. package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +1 -0
  285. package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +48 -0
  286. package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +5 -0
  287. package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +63 -0
  288. package/dist/integrations/meeting-recorder/models.d.ts +402 -0
  289. package/dist/integrations/meeting-recorder/models.js +152 -0
  290. package/dist/integrations/meeting-recorder/telemetry.d.ts +13 -0
  291. package/dist/integrations/meeting-recorder/telemetry.js +84 -0
  292. package/dist/integrations/openbanking/contracts/accounts.d.ts +282 -0
  293. package/dist/integrations/openbanking/contracts/accounts.js +358 -0
  294. package/dist/integrations/openbanking/contracts/balances.d.ts +158 -0
  295. package/dist/integrations/openbanking/contracts/balances.js +322 -0
  296. package/dist/integrations/openbanking/contracts/index.d.ts +7 -0
  297. package/dist/integrations/openbanking/contracts/index.js +674 -0
  298. package/dist/integrations/openbanking/contracts/transactions.d.ts +206 -0
  299. package/dist/integrations/openbanking/contracts/transactions.js +328 -0
  300. package/dist/integrations/openbanking/guards.d.ts +8 -0
  301. package/dist/integrations/openbanking/guards.js +72 -0
  302. package/dist/integrations/openbanking/guards.test.d.ts +1 -0
  303. package/dist/integrations/openbanking/models.d.ts +223 -0
  304. package/dist/integrations/openbanking/models.js +140 -0
  305. package/dist/integrations/openbanking/openbanking.capability.d.ts +1 -0
  306. package/dist/integrations/openbanking/openbanking.capability.js +48 -0
  307. package/dist/integrations/openbanking/openbanking.feature.d.ts +5 -0
  308. package/dist/integrations/openbanking/openbanking.feature.js +65 -0
  309. package/dist/integrations/openbanking/telemetry.d.ts +12 -0
  310. package/dist/integrations/openbanking/telemetry.js +81 -0
  311. package/dist/integrations/operations.d.ts +430 -0
  312. package/dist/integrations/operations.js +327 -0
  313. package/dist/integrations/operations.test.d.ts +1 -0
  314. package/dist/integrations/providers/analytics-reader.d.ts +103 -0
  315. package/dist/integrations/providers/analytics-reader.js +1 -0
  316. package/dist/integrations/providers/analytics-writer.d.ts +6 -0
  317. package/dist/integrations/providers/analytics-writer.js +1 -0
  318. package/dist/integrations/providers/analytics.d.ts +47 -0
  319. package/dist/integrations/providers/analytics.js +1 -0
  320. package/dist/integrations/providers/calendar.d.ts +75 -0
  321. package/dist/integrations/providers/calendar.js +1 -0
  322. package/dist/integrations/providers/database.d.ts +12 -0
  323. package/dist/integrations/providers/database.js +1 -0
  324. package/dist/integrations/providers/elevenlabs.d.ts +3 -0
  325. package/dist/integrations/providers/elevenlabs.js +116 -0
  326. package/dist/integrations/providers/email.d.ts +83 -0
  327. package/dist/integrations/providers/email.js +1 -0
  328. package/dist/integrations/providers/embedding.d.ts +21 -0
  329. package/dist/integrations/providers/embedding.js +1 -0
  330. package/dist/integrations/providers/fal.d.ts +3 -0
  331. package/dist/integrations/providers/fal.js +142 -0
  332. package/dist/integrations/providers/fathom.d.ts +3 -0
  333. package/dist/integrations/providers/fathom.js +156 -0
  334. package/dist/integrations/providers/fireflies.d.ts +3 -0
  335. package/dist/integrations/providers/fireflies.js +136 -0
  336. package/dist/integrations/providers/gcs-storage.d.ts +3 -0
  337. package/dist/integrations/providers/gcs-storage.js +127 -0
  338. package/dist/integrations/providers/gmail.d.ts +3 -0
  339. package/dist/integrations/providers/gmail.js +139 -0
  340. package/dist/integrations/providers/google-calendar.d.ts +3 -0
  341. package/dist/integrations/providers/google-calendar.js +122 -0
  342. package/dist/integrations/providers/gradium.d.ts +3 -0
  343. package/dist/integrations/providers/gradium.js +140 -0
  344. package/dist/integrations/providers/granola.d.ts +3 -0
  345. package/dist/integrations/providers/granola.js +137 -0
  346. package/dist/integrations/providers/index.d.ts +38 -0
  347. package/dist/integrations/providers/index.js +2124 -0
  348. package/dist/integrations/providers/jira.d.ts +3 -0
  349. package/dist/integrations/providers/jira.js +138 -0
  350. package/dist/integrations/providers/linear.d.ts +3 -0
  351. package/dist/integrations/providers/linear.js +137 -0
  352. package/dist/integrations/providers/llm.d.ts +79 -0
  353. package/dist/integrations/providers/llm.js +1 -0
  354. package/dist/integrations/providers/meeting-recorder.d.ts +129 -0
  355. package/dist/integrations/providers/meeting-recorder.js +1 -0
  356. package/dist/integrations/providers/mistral.d.ts +3 -0
  357. package/dist/integrations/providers/mistral.js +124 -0
  358. package/dist/integrations/providers/notion.d.ts +3 -0
  359. package/dist/integrations/providers/notion.js +143 -0
  360. package/dist/integrations/providers/openbanking.d.ts +125 -0
  361. package/dist/integrations/providers/openbanking.js +1 -0
  362. package/dist/integrations/providers/payments.d.ts +106 -0
  363. package/dist/integrations/providers/payments.js +1 -0
  364. package/dist/integrations/providers/posthog-llm-telemetry.d.ts +51 -0
  365. package/dist/integrations/providers/posthog-llm-telemetry.js +206 -0
  366. package/dist/integrations/providers/posthog.d.ts +3 -0
  367. package/dist/integrations/providers/posthog.js +136 -0
  368. package/dist/integrations/providers/postmark.d.ts +3 -0
  369. package/dist/integrations/providers/postmark.js +128 -0
  370. package/dist/integrations/providers/powens.d.ts +3 -0
  371. package/dist/integrations/providers/powens.js +154 -0
  372. package/dist/integrations/providers/project-management.d.ts +32 -0
  373. package/dist/integrations/providers/project-management.js +1 -0
  374. package/dist/integrations/providers/providers.test.d.ts +1 -0
  375. package/dist/integrations/providers/qdrant.d.ts +3 -0
  376. package/dist/integrations/providers/qdrant.js +131 -0
  377. package/dist/integrations/providers/registry.d.ts +6 -0
  378. package/dist/integrations/providers/registry.js +1908 -0
  379. package/dist/integrations/providers/sms.d.ts +31 -0
  380. package/dist/integrations/providers/sms.js +1 -0
  381. package/dist/integrations/providers/storage.d.ts +57 -0
  382. package/dist/integrations/providers/storage.js +1 -0
  383. package/dist/integrations/providers/stripe.d.ts +3 -0
  384. package/dist/integrations/providers/stripe.js +135 -0
  385. package/dist/integrations/providers/supabase-postgres.d.ts +3 -0
  386. package/dist/integrations/providers/supabase-postgres.js +117 -0
  387. package/dist/integrations/providers/supabase-vector.d.ts +3 -0
  388. package/dist/integrations/providers/supabase-vector.js +137 -0
  389. package/dist/integrations/providers/tldv.d.ts +3 -0
  390. package/dist/integrations/providers/tldv.js +136 -0
  391. package/dist/integrations/providers/twilio-sms.d.ts +3 -0
  392. package/dist/integrations/providers/twilio-sms.js +121 -0
  393. package/dist/integrations/providers/vector-store.d.ts +39 -0
  394. package/dist/integrations/providers/vector-store.js +1 -0
  395. package/dist/integrations/providers/voice.d.ts +31 -0
  396. package/dist/integrations/providers/voice.js +1 -0
  397. package/dist/integrations/runtime.d.ts +95 -0
  398. package/dist/integrations/runtime.js +239 -0
  399. package/dist/integrations/runtime.test.d.ts +1 -0
  400. package/dist/integrations/secrets/aws-secret-manager.d.ts +28 -0
  401. package/dist/integrations/secrets/aws-secret-manager.js +376 -0
  402. package/dist/integrations/secrets/env-secret-provider.d.ts +28 -0
  403. package/dist/integrations/secrets/env-secret-provider.js +189 -0
  404. package/dist/integrations/secrets/gcp-secret-manager.d.ts +29 -0
  405. package/dist/integrations/secrets/gcp-secret-manager.js +377 -0
  406. package/dist/integrations/secrets/index.d.ts +6 -0
  407. package/dist/integrations/secrets/index.js +1159 -0
  408. package/dist/integrations/secrets/manager.d.ts +44 -0
  409. package/dist/integrations/secrets/manager.js +213 -0
  410. package/dist/integrations/secrets/provider.d.ts +49 -0
  411. package/dist/integrations/secrets/provider.js +104 -0
  412. package/dist/integrations/secrets/provider.test.d.ts +1 -0
  413. package/dist/integrations/secrets/scaleway-secret-manager.d.ts +35 -0
  414. package/dist/integrations/secrets/scaleway-secret-manager.js +405 -0
  415. package/dist/integrations/secrets-types.d.ts +14 -0
  416. package/dist/integrations/secrets-types.js +1 -0
  417. package/dist/integrations/spec.d.ts +72 -0
  418. package/dist/integrations/spec.js +52 -0
  419. package/dist/integrations/spec.test.d.ts +1 -0
  420. package/dist/jobs/define-job.d.ts +15 -0
  421. package/dist/jobs/define-job.js +41 -0
  422. package/dist/jobs/gcp-cloud-tasks.d.ts +38 -0
  423. package/dist/jobs/gcp-cloud-tasks.js +103 -0
  424. package/dist/jobs/gcp-pubsub.d.ts +22 -0
  425. package/dist/jobs/gcp-pubsub.js +91 -0
  426. package/dist/jobs/handlers/gmail-sync-handler.d.ts +5 -0
  427. package/dist/jobs/handlers/gmail-sync-handler.js +40 -0
  428. package/dist/jobs/handlers/handlers.test.d.ts +1 -0
  429. package/dist/jobs/handlers/index.d.ts +5 -0
  430. package/dist/jobs/handlers/index.js +83 -0
  431. package/dist/jobs/handlers/ping-handler.d.ts +6 -0
  432. package/dist/jobs/handlers/ping-handler.js +47 -0
  433. package/dist/jobs/handlers/storage-document-handler.d.ts +8 -0
  434. package/dist/jobs/handlers/storage-document-handler.js +47 -0
  435. package/dist/jobs/index.d.ts +2 -0
  436. package/dist/jobs/index.js +64 -0
  437. package/dist/jobs/memory-queue.d.ts +14 -0
  438. package/dist/jobs/memory-queue.js +129 -0
  439. package/dist/jobs/queue.d.ts +126 -0
  440. package/dist/jobs/queue.js +55 -0
  441. package/dist/jobs/queue.test.d.ts +1 -0
  442. package/dist/jobs/scaleway-sqs-queue.d.ts +27 -0
  443. package/dist/jobs/scaleway-sqs-queue.js +222 -0
  444. package/dist/jsonschema.d.ts +39 -0
  445. package/dist/jsonschema.js +73 -0
  446. package/dist/jsonschema.test.d.ts +1 -0
  447. package/dist/knowledge/binding.d.ts +22 -0
  448. package/dist/knowledge/binding.js +1 -0
  449. package/dist/knowledge/docs/knowledge.docblock.d.ts +2 -0
  450. package/dist/knowledge/docs/knowledge.docblock.js +301 -0
  451. package/dist/knowledge/index.d.ts +4 -0
  452. package/dist/knowledge/index.js +467 -0
  453. package/dist/knowledge/ingestion/document-processor.d.ts +22 -0
  454. package/dist/knowledge/ingestion/document-processor.js +95 -0
  455. package/dist/knowledge/ingestion/embedding-service.d.ts +8 -0
  456. package/dist/knowledge/ingestion/embedding-service.js +57 -0
  457. package/dist/knowledge/ingestion/gmail-adapter.d.ts +14 -0
  458. package/dist/knowledge/ingestion/gmail-adapter.js +103 -0
  459. package/dist/knowledge/ingestion/index.d.ts +5 -0
  460. package/dist/knowledge/ingestion/index.js +252 -0
  461. package/dist/knowledge/ingestion/ingestion.test.d.ts +1 -0
  462. package/dist/knowledge/ingestion/storage-adapter.d.ts +11 -0
  463. package/dist/knowledge/ingestion/storage-adapter.js +62 -0
  464. package/dist/knowledge/ingestion/vector-indexer.d.ts +14 -0
  465. package/dist/knowledge/ingestion/vector-indexer.js +63 -0
  466. package/dist/knowledge/knowledge.capability.d.ts +1 -0
  467. package/dist/knowledge/knowledge.capability.js +726 -0
  468. package/dist/knowledge/knowledge.feature.d.ts +5 -0
  469. package/dist/knowledge/knowledge.feature.js +300 -0
  470. package/dist/knowledge/operations.d.ts +311 -0
  471. package/dist/knowledge/operations.js +619 -0
  472. package/dist/knowledge/operations.test.d.ts +1 -0
  473. package/dist/knowledge/query/index.d.ts +1 -0
  474. package/dist/knowledge/query/index.js +110 -0
  475. package/dist/knowledge/query/service.d.ts +25 -0
  476. package/dist/knowledge/query/service.js +110 -0
  477. package/dist/knowledge/query/service.test.d.ts +1 -0
  478. package/dist/knowledge/runtime.d.ts +28 -0
  479. package/dist/knowledge/runtime.js +91 -0
  480. package/dist/knowledge/runtime.test.d.ts +1 -0
  481. package/dist/knowledge/source.d.ts +29 -0
  482. package/dist/knowledge/source.js +1 -0
  483. package/dist/knowledge/spaces/email-threads.d.ts +3 -0
  484. package/dist/knowledge/spaces/email-threads.js +102 -0
  485. package/dist/knowledge/spaces/financial-docs.d.ts +3 -0
  486. package/dist/knowledge/spaces/financial-docs.js +102 -0
  487. package/dist/knowledge/spaces/financial-overview.d.ts +3 -0
  488. package/dist/knowledge/spaces/financial-overview.js +102 -0
  489. package/dist/knowledge/spaces/index.d.ts +6 -0
  490. package/dist/knowledge/spaces/index.js +273 -0
  491. package/dist/knowledge/spaces/product-canon.d.ts +3 -0
  492. package/dist/knowledge/spaces/product-canon.js +102 -0
  493. package/dist/knowledge/spaces/spaces.test.d.ts +1 -0
  494. package/dist/knowledge/spaces/support-faq.d.ts +3 -0
  495. package/dist/knowledge/spaces/support-faq.js +103 -0
  496. package/dist/knowledge/spaces/uploaded-docs.d.ts +3 -0
  497. package/dist/knowledge/spaces/uploaded-docs.js +102 -0
  498. package/dist/knowledge/spec.d.ts +42 -0
  499. package/dist/knowledge/spec.js +228 -0
  500. package/dist/knowledge/spec.test.d.ts +1 -0
  501. package/dist/llm/exporters.d.ts +68 -0
  502. package/dist/llm/exporters.js +1011 -0
  503. package/dist/llm/index.d.ts +12 -0
  504. package/dist/llm/index.js +1465 -0
  505. package/dist/llm/prompts.d.ts +53 -0
  506. package/dist/llm/prompts.js +1456 -0
  507. package/dist/llm/types.d.ts +212 -0
  508. package/dist/llm/types.js +1 -0
  509. package/dist/markdown.d.ts +16 -0
  510. package/dist/markdown.js +529 -0
  511. package/dist/migrations.d.ts +48 -0
  512. package/dist/migrations.js +67 -0
  513. package/dist/migrations.test.d.ts +1 -0
  514. package/dist/model-registry.d.ts +9 -0
  515. package/dist/model-registry.js +64 -0
  516. package/dist/model-registry.test.d.ts +1 -0
  517. package/dist/node/app-config/app-config.capability.js +730 -0
  518. package/dist/node/app-config/app-config.contracts.js +713 -0
  519. package/dist/node/app-config/app-config.feature.js +255 -0
  520. package/dist/node/app-config/branding.js +0 -0
  521. package/dist/node/app-config/docs/app-config.docblock.js +383 -0
  522. package/dist/node/app-config/events.js +386 -0
  523. package/dist/node/app-config/index.js +2899 -0
  524. package/dist/node/app-config/lifecycle-contracts.js +870 -0
  525. package/dist/node/app-config/lifecycle.js +0 -0
  526. package/dist/node/app-config/runtime.js +734 -0
  527. package/dist/node/app-config/spec.js +229 -0
  528. package/dist/node/app-config/validation.js +650 -0
  529. package/dist/node/capabilities/capabilities.js +217 -0
  530. package/dist/node/capabilities/context.js +101 -0
  531. package/dist/node/capabilities/docs/capabilities.docblock.js +353 -0
  532. package/dist/node/capabilities/guards.js +177 -0
  533. package/dist/node/capabilities/index.js +739 -0
  534. package/dist/node/capabilities/meeting-recorder.js +154 -0
  535. package/dist/node/capabilities/openbanking.js +166 -0
  536. package/dist/node/capabilities/validation.js +185 -0
  537. package/dist/node/contract-registry/index.js +129 -0
  538. package/dist/node/contract-registry/schemas.js +129 -0
  539. package/dist/node/contract-registry/types.js +0 -0
  540. package/dist/node/data-views/data-views.js +232 -0
  541. package/dist/node/data-views/docs/data-views.docblock.js +164 -0
  542. package/dist/node/data-views/index.js +232 -0
  543. package/dist/node/data-views/query-generator.js +89 -0
  544. package/dist/node/data-views/registry.js +226 -0
  545. package/dist/node/data-views/report/contractVerificationTable.js +240 -0
  546. package/dist/node/data-views/runtime.js +108 -0
  547. package/dist/node/data-views/spec.js +38 -0
  548. package/dist/node/data-views/types.js +0 -0
  549. package/dist/node/docs/accessibility_wcag_compliance_specs.docblock.js +513 -0
  550. package/dist/node/docs/capabilities/documentationSystem.capability.js +784 -0
  551. package/dist/node/docs/capabilities/index.js +784 -0
  552. package/dist/node/docs/commands/docsGenerate.command.js +802 -0
  553. package/dist/node/docs/commands/docsPublish.command.js +781 -0
  554. package/dist/node/docs/commands/index.js +906 -0
  555. package/dist/node/docs/constants.js +78 -0
  556. package/dist/node/docs/contracts.js +1611 -0
  557. package/dist/node/docs/ensure-docblocks.js +264 -0
  558. package/dist/node/docs/events/docsGenerated.event.js +533 -0
  559. package/dist/node/docs/events/docsPublished.event.js +534 -0
  560. package/dist/node/docs/events/index.js +567 -0
  561. package/dist/node/docs/forms/docsSearch.form.js +676 -0
  562. package/dist/node/docs/forms/index.js +676 -0
  563. package/dist/node/docs/index.js +4719 -0
  564. package/dist/node/docs/meta.docs.js +176 -0
  565. package/dist/node/docs/presentations/docsLayout.presentation.js +527 -0
  566. package/dist/node/docs/presentations/docsReferencePage.presentation.js +527 -0
  567. package/dist/node/docs/presentations/index.js +555 -0
  568. package/dist/node/docs/presentations.js +97 -0
  569. package/dist/node/docs/queries/contractReference.query.js +752 -0
  570. package/dist/node/docs/queries/docsIndex.query.js +752 -0
  571. package/dist/node/docs/queries/index.js +827 -0
  572. package/dist/node/docs/registry.js +153 -0
  573. package/dist/node/docs/tech/auth/better-auth-nextjs.docblock.js +221 -0
  574. package/dist/node/docs/tech/cli.docblock.js +291 -0
  575. package/dist/node/docs/tech/contracts/README.docblock.js +164 -0
  576. package/dist/node/docs/tech/contracts/migrations.docblock.js +164 -0
  577. package/dist/node/docs/tech/contracts/openapi-export.docblock.js +201 -0
  578. package/dist/node/docs/tech/contracts/openapi-import.docblock.js +207 -0
  579. package/dist/node/docs/tech/contracts/ops-to-presentation-linking.docblock.js +225 -0
  580. package/dist/node/docs/tech/contracts/overlays.docblock.js +231 -0
  581. package/dist/node/docs/tech/contracts/tests.docblock.js +164 -0
  582. package/dist/node/docs/tech/contracts/themes.docblock.js +257 -0
  583. package/dist/node/docs/tech/contracts/vertical-pocket-family-office.docblock.js +269 -0
  584. package/dist/node/docs/tech/docs-system.docblock.js +264 -0
  585. package/dist/node/docs/tech/lifecycle-stage-system.docblock.js +376 -0
  586. package/dist/node/docs/tech/llm/llm-integration.docblock.js +482 -0
  587. package/dist/node/docs/tech/mcp-endpoints.docblock.js +185 -0
  588. package/dist/node/docs/tech/presentation-runtime.docblock.js +221 -0
  589. package/dist/node/docs/tech/report-verification-table.docblock.js +191 -0
  590. package/dist/node/docs/tech/schema/README.docblock.js +164 -0
  591. package/dist/node/docs/tech/studio/learning-events.docblock.js +190 -0
  592. package/dist/node/docs/tech/studio/learning-journeys.docblock.js +227 -0
  593. package/dist/node/docs/tech/studio/platform-admin-panel.docblock.js +226 -0
  594. package/dist/node/docs/tech/studio/project-access-teams.docblock.js +200 -0
  595. package/dist/node/docs/tech/studio/project-routing.docblock.js +209 -0
  596. package/dist/node/docs/tech/studio/sandbox-unlogged.docblock.js +183 -0
  597. package/dist/node/docs/tech/studio/team-invitations.docblock.js +228 -0
  598. package/dist/node/docs/tech/studio/workspace-ops.docblock.js +189 -0
  599. package/dist/node/docs/tech/studio/workspaces.docblock.js +204 -0
  600. package/dist/node/docs/tech/telemetry-ingest.docblock.js +305 -0
  601. package/dist/node/docs/tech/vscode-extension.docblock.js +241 -0
  602. package/dist/node/docs/tech-contracts.docs.js +239 -0
  603. package/dist/node/docs/types.js +0 -0
  604. package/dist/node/docs/views/contractReference.dataView.js +838 -0
  605. package/dist/node/docs/views/docsIndex.dataView.js +832 -0
  606. package/dist/node/docs/views/exampleCatalog.dataView.js +816 -0
  607. package/dist/node/docs/views/index.js +1031 -0
  608. package/dist/node/events.js +228 -0
  609. package/dist/node/examples/define.js +36 -0
  610. package/dist/node/examples/docs/examples.docblock.js +307 -0
  611. package/dist/node/examples/index.js +604 -0
  612. package/dist/node/examples/registry.js +286 -0
  613. package/dist/node/examples/schema.js +166 -0
  614. package/dist/node/examples/types.js +77 -0
  615. package/dist/node/examples/validation.js +287 -0
  616. package/dist/node/experiments/docs/experiments.docblock.js +291 -0
  617. package/dist/node/experiments/evaluator.js +155 -0
  618. package/dist/node/experiments/spec-resolver.js +0 -0
  619. package/dist/node/experiments/spec.js +227 -0
  620. package/dist/node/features/index.js +275 -0
  621. package/dist/node/features/install.js +95 -0
  622. package/dist/node/features/registry.js +192 -0
  623. package/dist/node/features/types.js +36 -0
  624. package/dist/node/features/validation.js +48 -0
  625. package/dist/node/forms/docs/forms.docblock.js +164 -0
  626. package/dist/node/forms/forms.js +332 -0
  627. package/dist/node/forms/index.js +332 -0
  628. package/dist/node/index.js +2195 -0
  629. package/dist/node/install.js +60 -0
  630. package/dist/node/integrations/binding.js +0 -0
  631. package/dist/node/integrations/connection.js +0 -0
  632. package/dist/node/integrations/docs/integrations.docblock.js +140 -0
  633. package/dist/node/integrations/health.js +103 -0
  634. package/dist/node/integrations/index.js +3293 -0
  635. package/dist/node/integrations/integrations.capability.js +48 -0
  636. package/dist/node/integrations/integrations.feature.js +63 -0
  637. package/dist/node/integrations/meeting-recorder/contracts/index.js +504 -0
  638. package/dist/node/integrations/meeting-recorder/contracts/meetings.js +249 -0
  639. package/dist/node/integrations/meeting-recorder/contracts/transcripts.js +317 -0
  640. package/dist/node/integrations/meeting-recorder/contracts/webhooks.js +202 -0
  641. package/dist/node/integrations/meeting-recorder/meeting-recorder.capability.js +48 -0
  642. package/dist/node/integrations/meeting-recorder/meeting-recorder.feature.js +63 -0
  643. package/dist/node/integrations/meeting-recorder/models.js +152 -0
  644. package/dist/node/integrations/meeting-recorder/telemetry.js +84 -0
  645. package/dist/node/integrations/openbanking/contracts/accounts.js +358 -0
  646. package/dist/node/integrations/openbanking/contracts/balances.js +322 -0
  647. package/dist/node/integrations/openbanking/contracts/index.js +674 -0
  648. package/dist/node/integrations/openbanking/contracts/transactions.js +328 -0
  649. package/dist/node/integrations/openbanking/guards.js +72 -0
  650. package/dist/node/integrations/openbanking/models.js +140 -0
  651. package/dist/node/integrations/openbanking/openbanking.capability.js +48 -0
  652. package/dist/node/integrations/openbanking/openbanking.feature.js +65 -0
  653. package/dist/node/integrations/openbanking/telemetry.js +81 -0
  654. package/dist/node/integrations/operations.js +327 -0
  655. package/dist/node/integrations/providers/analytics-reader.js +0 -0
  656. package/dist/node/integrations/providers/analytics-writer.js +0 -0
  657. package/dist/node/integrations/providers/analytics.js +0 -0
  658. package/dist/node/integrations/providers/calendar.js +0 -0
  659. package/dist/node/integrations/providers/database.js +0 -0
  660. package/dist/node/integrations/providers/elevenlabs.js +116 -0
  661. package/dist/node/integrations/providers/email.js +0 -0
  662. package/dist/node/integrations/providers/embedding.js +0 -0
  663. package/dist/node/integrations/providers/fal.js +142 -0
  664. package/dist/node/integrations/providers/fathom.js +156 -0
  665. package/dist/node/integrations/providers/fireflies.js +136 -0
  666. package/dist/node/integrations/providers/gcs-storage.js +127 -0
  667. package/dist/node/integrations/providers/gmail.js +139 -0
  668. package/dist/node/integrations/providers/google-calendar.js +122 -0
  669. package/dist/node/integrations/providers/gradium.js +140 -0
  670. package/dist/node/integrations/providers/granola.js +137 -0
  671. package/dist/node/integrations/providers/index.js +2124 -0
  672. package/dist/node/integrations/providers/jira.js +138 -0
  673. package/dist/node/integrations/providers/linear.js +137 -0
  674. package/dist/node/integrations/providers/llm.js +0 -0
  675. package/dist/node/integrations/providers/meeting-recorder.js +0 -0
  676. package/dist/node/integrations/providers/mistral.js +124 -0
  677. package/dist/node/integrations/providers/notion.js +143 -0
  678. package/dist/node/integrations/providers/openbanking.js +0 -0
  679. package/dist/node/integrations/providers/payments.js +0 -0
  680. package/dist/node/integrations/providers/posthog-llm-telemetry.js +206 -0
  681. package/dist/node/integrations/providers/posthog.js +136 -0
  682. package/dist/node/integrations/providers/postmark.js +128 -0
  683. package/dist/node/integrations/providers/powens.js +154 -0
  684. package/dist/node/integrations/providers/project-management.js +0 -0
  685. package/dist/node/integrations/providers/qdrant.js +131 -0
  686. package/dist/node/integrations/providers/registry.js +1908 -0
  687. package/dist/node/integrations/providers/sms.js +0 -0
  688. package/dist/node/integrations/providers/storage.js +0 -0
  689. package/dist/node/integrations/providers/stripe.js +135 -0
  690. package/dist/node/integrations/providers/supabase-postgres.js +117 -0
  691. package/dist/node/integrations/providers/supabase-vector.js +137 -0
  692. package/dist/node/integrations/providers/tldv.js +136 -0
  693. package/dist/node/integrations/providers/twilio-sms.js +121 -0
  694. package/dist/node/integrations/providers/vector-store.js +0 -0
  695. package/dist/node/integrations/providers/voice.js +0 -0
  696. package/dist/node/integrations/runtime.js +239 -0
  697. package/dist/node/integrations/secrets/aws-secret-manager.js +376 -0
  698. package/dist/node/integrations/secrets/env-secret-provider.js +189 -0
  699. package/dist/node/integrations/secrets/gcp-secret-manager.js +377 -0
  700. package/dist/node/integrations/secrets/index.js +1159 -0
  701. package/dist/node/integrations/secrets/manager.js +213 -0
  702. package/dist/node/integrations/secrets/provider.js +104 -0
  703. package/dist/node/integrations/secrets/scaleway-secret-manager.js +405 -0
  704. package/dist/node/integrations/secrets-types.js +0 -0
  705. package/dist/node/integrations/spec.js +52 -0
  706. package/dist/node/jobs/define-job.js +41 -0
  707. package/dist/node/jobs/gcp-cloud-tasks.js +103 -0
  708. package/dist/node/jobs/gcp-pubsub.js +91 -0
  709. package/dist/node/jobs/handlers/gmail-sync-handler.js +40 -0
  710. package/dist/node/jobs/handlers/index.js +83 -0
  711. package/dist/node/jobs/handlers/ping-handler.js +47 -0
  712. package/dist/node/jobs/handlers/storage-document-handler.js +47 -0
  713. package/dist/node/jobs/index.js +64 -0
  714. package/dist/node/jobs/memory-queue.js +129 -0
  715. package/dist/node/jobs/queue.js +55 -0
  716. package/dist/node/jobs/scaleway-sqs-queue.js +222 -0
  717. package/dist/node/jsonschema.js +73 -0
  718. package/dist/node/knowledge/binding.js +0 -0
  719. package/dist/node/knowledge/docs/knowledge.docblock.js +301 -0
  720. package/dist/node/knowledge/index.js +467 -0
  721. package/dist/node/knowledge/ingestion/document-processor.js +95 -0
  722. package/dist/node/knowledge/ingestion/embedding-service.js +57 -0
  723. package/dist/node/knowledge/ingestion/gmail-adapter.js +103 -0
  724. package/dist/node/knowledge/ingestion/index.js +252 -0
  725. package/dist/node/knowledge/ingestion/storage-adapter.js +62 -0
  726. package/dist/node/knowledge/ingestion/vector-indexer.js +63 -0
  727. package/dist/node/knowledge/knowledge.capability.js +726 -0
  728. package/dist/node/knowledge/knowledge.feature.js +300 -0
  729. package/dist/node/knowledge/operations.js +619 -0
  730. package/dist/node/knowledge/query/index.js +110 -0
  731. package/dist/node/knowledge/query/service.js +110 -0
  732. package/dist/node/knowledge/runtime.js +91 -0
  733. package/dist/node/knowledge/source.js +0 -0
  734. package/dist/node/knowledge/spaces/email-threads.js +102 -0
  735. package/dist/node/knowledge/spaces/financial-docs.js +102 -0
  736. package/dist/node/knowledge/spaces/financial-overview.js +102 -0
  737. package/dist/node/knowledge/spaces/index.js +273 -0
  738. package/dist/node/knowledge/spaces/product-canon.js +102 -0
  739. package/dist/node/knowledge/spaces/support-faq.js +103 -0
  740. package/dist/node/knowledge/spaces/uploaded-docs.js +102 -0
  741. package/dist/node/knowledge/spec.js +228 -0
  742. package/dist/node/llm/exporters.js +1011 -0
  743. package/dist/node/llm/index.js +1465 -0
  744. package/dist/node/llm/prompts.js +1456 -0
  745. package/dist/node/llm/types.js +0 -0
  746. package/dist/node/markdown.js +529 -0
  747. package/dist/node/migrations.js +67 -0
  748. package/dist/node/model-registry.js +64 -0
  749. package/dist/node/onboarding-base.js +597 -0
  750. package/dist/node/openapi.js +151 -0
  751. package/dist/node/operations/index.js +408 -0
  752. package/dist/node/operations/operation.js +51 -0
  753. package/dist/node/operations/registry.js +405 -0
  754. package/dist/node/operations/report/getContractVerificationStatus.js +170 -0
  755. package/dist/node/operations/report/index.js +305 -0
  756. package/dist/node/ownership.js +73 -0
  757. package/dist/node/policy/context.js +206 -0
  758. package/dist/node/policy/docs/policy.docblock.js +313 -0
  759. package/dist/node/policy/engine.js +325 -0
  760. package/dist/node/policy/guards.js +387 -0
  761. package/dist/node/policy/index.js +1313 -0
  762. package/dist/node/policy/opa-adapter.js +110 -0
  763. package/dist/node/policy/registry.js +221 -0
  764. package/dist/node/policy/spec.js +0 -0
  765. package/dist/node/policy/validation.js +391 -0
  766. package/dist/node/presentations/docs/presentations-conventions.docblock.js +171 -0
  767. package/dist/node/presentations/index.js +227 -0
  768. package/dist/node/presentations/presentations.js +38 -0
  769. package/dist/node/presentations/registry.js +221 -0
  770. package/dist/node/presentations/transform-engine.js +600 -0
  771. package/dist/node/product-intent/contract-patch-intent.js +68 -0
  772. package/dist/node/product-intent/contract-spec-patch.js +75 -0
  773. package/dist/node/product-intent/evidence.js +45 -0
  774. package/dist/node/product-intent/findings.js +81 -0
  775. package/dist/node/product-intent/impact-report.js +62 -0
  776. package/dist/node/product-intent/index.js +742 -0
  777. package/dist/node/product-intent/insights.js +63 -0
  778. package/dist/node/product-intent/opportunity-brief.js +106 -0
  779. package/dist/node/product-intent/problems.js +55 -0
  780. package/dist/node/product-intent/registry.js +242 -0
  781. package/dist/node/product-intent/runtime.js +320 -0
  782. package/dist/node/product-intent/spec.js +425 -0
  783. package/dist/node/product-intent/task-pack.js +69 -0
  784. package/dist/node/product-intent/tickets.js +57 -0
  785. package/dist/node/product-intent/types.js +378 -0
  786. package/dist/node/product-intent/ui-wireframe.js +73 -0
  787. package/dist/node/prompt.js +38 -0
  788. package/dist/node/promptRegistry.js +63 -0
  789. package/dist/node/regenerator/adapters.js +0 -0
  790. package/dist/node/regenerator/docs/regenerator.docblock.js +164 -0
  791. package/dist/node/regenerator/executor.js +157 -0
  792. package/dist/node/regenerator/index.js +341 -0
  793. package/dist/node/regenerator/service.js +183 -0
  794. package/dist/node/regenerator/sinks.js +64 -0
  795. package/dist/node/regenerator/types.js +0 -0
  796. package/dist/node/regenerator/utils.js +87 -0
  797. package/dist/node/registry-utils.js +163 -0
  798. package/dist/node/registry.js +215 -0
  799. package/dist/node/resources.js +83 -0
  800. package/dist/node/schema-to-markdown.js +278 -0
  801. package/dist/node/serialization/index.js +179 -0
  802. package/dist/node/serialization/serializers.js +180 -0
  803. package/dist/node/serialization/types.js +0 -0
  804. package/dist/node/telemetry/anomaly.js +91 -0
  805. package/dist/node/telemetry/docs/telemetry.docblock.js +164 -0
  806. package/dist/node/telemetry/index.js +417 -0
  807. package/dist/node/telemetry/spec.js +261 -0
  808. package/dist/node/telemetry/tracker.js +129 -0
  809. package/dist/node/tests/index.js +231 -0
  810. package/dist/node/tests/runner.js +189 -0
  811. package/dist/node/tests/spec.js +74 -0
  812. package/dist/node/themes.js +225 -0
  813. package/dist/node/translations/catalog.js +0 -0
  814. package/dist/node/translations/index.js +533 -0
  815. package/dist/node/translations/registry.js +170 -0
  816. package/dist/node/translations/spec.js +36 -0
  817. package/dist/node/translations/tenant.js +0 -0
  818. package/dist/node/translations/validation.js +392 -0
  819. package/dist/node/types.js +0 -0
  820. package/dist/node/versioning/index.js +274 -0
  821. package/dist/node/versioning/refs.js +99 -0
  822. package/dist/node/versioning/types.js +55 -0
  823. package/dist/node/versioning/utils.js +184 -0
  824. package/dist/node/workflow/adapters/db-adapter.js +127 -0
  825. package/dist/node/workflow/adapters/file-adapter.js +38 -0
  826. package/dist/node/workflow/adapters/index.js +194 -0
  827. package/dist/node/workflow/adapters/memory-store.js +93 -0
  828. package/dist/node/workflow/context.js +247 -0
  829. package/dist/node/workflow/expression.js +157 -0
  830. package/dist/node/workflow/index.js +1546 -0
  831. package/dist/node/workflow/overview.docblock.js +164 -0
  832. package/dist/node/workflow/runner.js +532 -0
  833. package/dist/node/workflow/sla-monitor.js +84 -0
  834. package/dist/node/workflow/spec.js +221 -0
  835. package/dist/node/workflow/state.js +0 -0
  836. package/dist/node/workflow/validation.js +425 -0
  837. package/dist/node/workspace-config/contractsrc-schema.js +344 -0
  838. package/dist/node/workspace-config/contractsrc-types.js +0 -0
  839. package/dist/node/workspace-config/index.js +325 -0
  840. package/dist/node/workspace-config/workspace-config.docblock.js +188 -0
  841. package/dist/onboarding-base.d.ts +131 -0
  842. package/dist/onboarding-base.js +597 -0
  843. package/dist/openapi.d.ts +33 -0
  844. package/dist/openapi.js +151 -0
  845. package/dist/operations/index.d.ts +2 -0
  846. package/dist/operations/index.js +408 -0
  847. package/dist/operations/operation.d.ts +191 -0
  848. package/dist/operations/operation.js +51 -0
  849. package/dist/operations/registry.d.ts +58 -0
  850. package/dist/operations/registry.js +405 -0
  851. package/dist/operations/report/getContractVerificationStatus.d.ts +68 -0
  852. package/dist/operations/report/getContractVerificationStatus.js +170 -0
  853. package/dist/operations/report/getContractVerificationStatus.test.d.ts +1 -0
  854. package/dist/operations/report/index.d.ts +10 -0
  855. package/dist/operations/report/index.js +305 -0
  856. package/dist/operations/report/index.test.d.ts +1 -0
  857. package/dist/ownership.d.ts +211 -0
  858. package/dist/ownership.js +73 -0
  859. package/dist/ownership.test.d.ts +1 -0
  860. package/dist/policy/context.d.ts +234 -0
  861. package/dist/policy/context.js +206 -0
  862. package/dist/policy/context.test.d.ts +1 -0
  863. package/dist/policy/docs/policy.docblock.d.ts +2 -0
  864. package/dist/policy/docs/policy.docblock.js +313 -0
  865. package/dist/policy/engine.d.ts +36 -0
  866. package/dist/policy/engine.js +325 -0
  867. package/dist/policy/engine.test.d.ts +1 -0
  868. package/dist/policy/guards.d.ts +156 -0
  869. package/dist/policy/guards.js +387 -0
  870. package/dist/policy/guards.test.d.ts +1 -0
  871. package/dist/policy/index.d.ts +12 -0
  872. package/dist/policy/index.js +1313 -0
  873. package/dist/policy/opa-adapter.d.ts +41 -0
  874. package/dist/policy/opa-adapter.js +110 -0
  875. package/dist/policy/opa-adapter.test.d.ts +1 -0
  876. package/dist/policy/registry.d.ts +5 -0
  877. package/dist/policy/registry.js +221 -0
  878. package/dist/policy/spec.d.ts +102 -0
  879. package/dist/policy/spec.js +1 -0
  880. package/dist/policy/validation.d.ts +84 -0
  881. package/dist/policy/validation.js +391 -0
  882. package/dist/policy/validation.test.d.ts +1 -0
  883. package/dist/presentations/docs/presentations-conventions.docblock.d.ts +2 -0
  884. package/dist/presentations/docs/presentations-conventions.docblock.js +171 -0
  885. package/dist/presentations/index.d.ts +2 -0
  886. package/dist/presentations/index.js +227 -0
  887. package/dist/presentations/presentations.d.ts +52 -0
  888. package/dist/presentations/presentations.js +38 -0
  889. package/dist/presentations/registry.d.ts +6 -0
  890. package/dist/presentations/registry.js +221 -0
  891. package/dist/presentations/transform-engine.d.ts +62 -0
  892. package/dist/presentations/transform-engine.js +600 -0
  893. package/dist/presentations/transform-engine.test.d.ts +1 -0
  894. package/dist/product-intent/contract-patch-intent.d.ts +100 -0
  895. package/dist/product-intent/contract-patch-intent.js +68 -0
  896. package/dist/product-intent/contract-spec-patch.d.ts +86 -0
  897. package/dist/product-intent/contract-spec-patch.js +75 -0
  898. package/dist/product-intent/evidence.d.ts +14 -0
  899. package/dist/product-intent/evidence.js +45 -0
  900. package/dist/product-intent/findings.d.ts +57 -0
  901. package/dist/product-intent/findings.js +81 -0
  902. package/dist/product-intent/impact-report.d.ts +57 -0
  903. package/dist/product-intent/impact-report.js +62 -0
  904. package/dist/product-intent/index.d.ts +13 -0
  905. package/dist/product-intent/index.js +742 -0
  906. package/dist/product-intent/insights.d.ts +62 -0
  907. package/dist/product-intent/insights.js +63 -0
  908. package/dist/product-intent/opportunity-brief.d.ts +192 -0
  909. package/dist/product-intent/opportunity-brief.js +106 -0
  910. package/dist/product-intent/problems.d.ts +59 -0
  911. package/dist/product-intent/problems.js +55 -0
  912. package/dist/product-intent/registry.d.ts +28 -0
  913. package/dist/product-intent/registry.js +242 -0
  914. package/dist/product-intent/registry.test.d.ts +1 -0
  915. package/dist/product-intent/runtime.d.ts +92 -0
  916. package/dist/product-intent/runtime.js +320 -0
  917. package/dist/product-intent/runtime.test.d.ts +1 -0
  918. package/dist/product-intent/spec.d.ts +664 -0
  919. package/dist/product-intent/spec.js +425 -0
  920. package/dist/product-intent/task-pack.d.ts +98 -0
  921. package/dist/product-intent/task-pack.js +69 -0
  922. package/dist/product-intent/tickets.d.ts +67 -0
  923. package/dist/product-intent/tickets.js +57 -0
  924. package/dist/product-intent/types.d.ts +11 -0
  925. package/dist/product-intent/types.js +378 -0
  926. package/dist/product-intent/ui-wireframe.d.ts +100 -0
  927. package/dist/product-intent/ui-wireframe.js +73 -0
  928. package/dist/prompt.d.ts +49 -0
  929. package/dist/prompt.js +38 -0
  930. package/dist/prompt.test.d.ts +1 -0
  931. package/dist/promptRegistry.d.ts +11 -0
  932. package/dist/promptRegistry.js +63 -0
  933. package/dist/promptRegistry.test.d.ts +1 -0
  934. package/dist/regenerator/adapters.d.ts +15 -0
  935. package/dist/regenerator/adapters.js +1 -0
  936. package/dist/regenerator/docs/regenerator.docblock.d.ts +2 -0
  937. package/dist/regenerator/docs/regenerator.docblock.js +164 -0
  938. package/dist/regenerator/executor.d.ts +66 -0
  939. package/dist/regenerator/executor.js +157 -0
  940. package/dist/regenerator/executor.test.d.ts +1 -0
  941. package/dist/regenerator/index.d.ts +6 -0
  942. package/dist/regenerator/index.js +341 -0
  943. package/dist/regenerator/service.d.ts +29 -0
  944. package/dist/regenerator/service.js +183 -0
  945. package/dist/regenerator/service.test.d.ts +1 -0
  946. package/dist/regenerator/sinks.d.ts +23 -0
  947. package/dist/regenerator/sinks.js +64 -0
  948. package/dist/regenerator/sinks.test.d.ts +1 -0
  949. package/dist/regenerator/types.d.ts +103 -0
  950. package/dist/regenerator/types.js +1 -0
  951. package/dist/regenerator/utils.d.ts +6 -0
  952. package/dist/regenerator/utils.js +87 -0
  953. package/dist/registry-utils.d.ts +105 -0
  954. package/dist/registry-utils.js +163 -0
  955. package/dist/registry-utils.test.d.ts +1 -0
  956. package/dist/registry.d.ts +27 -0
  957. package/dist/registry.js +215 -0
  958. package/dist/resources.d.ts +60 -0
  959. package/dist/resources.js +83 -0
  960. package/dist/schema-to-markdown.d.ts +56 -0
  961. package/dist/schema-to-markdown.js +278 -0
  962. package/dist/serialization/index.d.ts +10 -0
  963. package/dist/serialization/index.js +179 -0
  964. package/dist/serialization/serializers.d.ts +35 -0
  965. package/dist/serialization/serializers.js +180 -0
  966. package/dist/serialization/types.d.ts +100 -0
  967. package/dist/serialization/types.js +1 -0
  968. package/dist/telemetry/anomaly.d.ts +23 -0
  969. package/dist/telemetry/anomaly.js +91 -0
  970. package/dist/telemetry/anomaly.test.d.ts +1 -0
  971. package/dist/telemetry/docs/telemetry.docblock.d.ts +2 -0
  972. package/dist/telemetry/docs/telemetry.docblock.js +164 -0
  973. package/dist/telemetry/index.d.ts +3 -0
  974. package/dist/telemetry/index.js +417 -0
  975. package/dist/telemetry/spec.d.ts +87 -0
  976. package/dist/telemetry/spec.js +261 -0
  977. package/dist/telemetry/spec.test.d.ts +1 -0
  978. package/dist/telemetry/tracker.d.ts +48 -0
  979. package/dist/telemetry/tracker.js +129 -0
  980. package/dist/telemetry/tracker.test.d.ts +1 -0
  981. package/dist/tests/index.d.ts +2 -0
  982. package/dist/tests/index.js +231 -0
  983. package/dist/tests/runner.d.ts +38 -0
  984. package/dist/tests/runner.js +189 -0
  985. package/dist/tests/runner.test.d.ts +1 -0
  986. package/dist/tests/spec.d.ts +82 -0
  987. package/dist/tests/spec.js +74 -0
  988. package/dist/tests/spec.test.d.ts +1 -0
  989. package/dist/themes.d.ts +50 -0
  990. package/dist/themes.js +225 -0
  991. package/dist/themes.test.d.ts +1 -0
  992. package/dist/translations/catalog.d.ts +25 -0
  993. package/dist/translations/catalog.js +1 -0
  994. package/dist/translations/index.d.ts +44 -0
  995. package/dist/translations/index.js +533 -0
  996. package/dist/translations/registry.d.ts +172 -0
  997. package/dist/translations/registry.js +170 -0
  998. package/dist/translations/registry.test.d.ts +1 -0
  999. package/dist/translations/spec.d.ts +153 -0
  1000. package/dist/translations/spec.js +36 -0
  1001. package/dist/translations/spec.test.d.ts +1 -0
  1002. package/dist/translations/tenant.d.ts +11 -0
  1003. package/dist/translations/tenant.js +1 -0
  1004. package/dist/translations/validation.d.ts +106 -0
  1005. package/dist/translations/validation.js +392 -0
  1006. package/dist/translations/validation.test.d.ts +1 -0
  1007. package/dist/types.d.ts +212 -0
  1008. package/dist/types.js +1 -0
  1009. package/dist/versioning/index.d.ts +9 -0
  1010. package/dist/versioning/index.js +274 -0
  1011. package/dist/versioning/refs.d.ts +176 -0
  1012. package/dist/versioning/refs.js +99 -0
  1013. package/dist/versioning/refs.test.d.ts +4 -0
  1014. package/dist/versioning/types.d.ts +130 -0
  1015. package/dist/versioning/types.js +55 -0
  1016. package/dist/versioning/utils.d.ts +93 -0
  1017. package/dist/versioning/utils.js +184 -0
  1018. package/dist/versioning/utils.test.d.ts +4 -0
  1019. package/dist/workflow/adapters/db-adapter.d.ts +43 -0
  1020. package/dist/workflow/adapters/db-adapter.js +127 -0
  1021. package/dist/workflow/adapters/file-adapter.d.ts +10 -0
  1022. package/dist/workflow/adapters/file-adapter.js +38 -0
  1023. package/dist/workflow/adapters/index.d.ts +3 -0
  1024. package/dist/workflow/adapters/index.js +194 -0
  1025. package/dist/workflow/adapters/memory-store.d.ts +13 -0
  1026. package/dist/workflow/adapters/memory-store.js +93 -0
  1027. package/dist/workflow/context.d.ts +217 -0
  1028. package/dist/workflow/context.js +247 -0
  1029. package/dist/workflow/context.test.d.ts +1 -0
  1030. package/dist/workflow/expression.d.ts +6 -0
  1031. package/dist/workflow/expression.js +157 -0
  1032. package/dist/workflow/expression.test.d.ts +1 -0
  1033. package/dist/workflow/index.d.ts +13 -0
  1034. package/dist/workflow/index.js +1546 -0
  1035. package/dist/workflow/overview.docblock.d.ts +2 -0
  1036. package/dist/workflow/overview.docblock.js +164 -0
  1037. package/dist/workflow/runner.d.ts +71 -0
  1038. package/dist/workflow/runner.js +532 -0
  1039. package/dist/workflow/runner.test.d.ts +1 -0
  1040. package/dist/workflow/sla-monitor.d.ts +16 -0
  1041. package/dist/workflow/sla-monitor.js +84 -0
  1042. package/dist/workflow/spec.d.ts +81 -0
  1043. package/dist/workflow/spec.js +221 -0
  1044. package/dist/workflow/state.d.ts +31 -0
  1045. package/dist/workflow/state.js +1 -0
  1046. package/dist/workflow/validation.d.ts +87 -0
  1047. package/dist/workflow/validation.js +425 -0
  1048. package/dist/workflow/validation.test.d.ts +1 -0
  1049. package/dist/workspace-config/contractsrc-schema.d.ts +144 -0
  1050. package/dist/workspace-config/contractsrc-schema.js +344 -0
  1051. package/dist/workspace-config/contractsrc-schema.test.d.ts +1 -0
  1052. package/dist/workspace-config/contractsrc-types.d.ts +342 -0
  1053. package/dist/workspace-config/contractsrc-types.js +1 -0
  1054. package/dist/workspace-config/index.d.ts +5 -0
  1055. package/dist/workspace-config/index.js +325 -0
  1056. package/dist/workspace-config/workspace-config.docblock.d.ts +2 -0
  1057. package/dist/workspace-config/workspace-config.docblock.js +188 -0
  1058. package/package.json +4426 -0
@@ -0,0 +1,4719 @@
1
+ import { createRequire } from "node:module";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
+
32
+ // src/registry-utils.ts
33
+ var exports_registry_utils = {};
34
+ __export(exports_registry_utils, {
35
+ groupByToArray: () => groupByToArray,
36
+ groupByMultiple: () => groupByMultiple,
37
+ groupBy: () => groupBy,
38
+ getUniqueTags: () => getUniqueTags,
39
+ getUniqueOwners: () => getUniqueOwners,
40
+ getUniqueDomains: () => getUniqueDomains,
41
+ filterBy: () => filterBy,
42
+ GroupingStrategies: () => GroupingStrategies
43
+ });
44
+ function filterBy(items, filter) {
45
+ return items.filter((item) => {
46
+ if (filter.tags?.length) {
47
+ const hasMatchingTag = filter.tags.some((tag) => item.meta.tags?.includes(tag));
48
+ if (!hasMatchingTag)
49
+ return false;
50
+ }
51
+ if (filter.owners?.length) {
52
+ const hasMatchingOwner = filter.owners.some((owner) => item.meta.owners?.includes(owner));
53
+ if (!hasMatchingOwner)
54
+ return false;
55
+ }
56
+ if (filter.stability?.length) {
57
+ if (!filter.stability.includes(item.meta.stability ?? "stable")) {
58
+ return false;
59
+ }
60
+ }
61
+ if (filter.domain) {
62
+ const itemDomain = GroupingStrategies.byDomain(item);
63
+ if (itemDomain !== filter.domain)
64
+ return false;
65
+ }
66
+ if (filter.keyPattern) {
67
+ const name = item.meta.key ?? item.meta.key ?? "";
68
+ const pattern = filter.keyPattern.replace(/\*/g, ".*").replace(/\?/g, ".");
69
+ const regex = new RegExp(`^${pattern}$`, "i");
70
+ if (!regex.test(name))
71
+ return false;
72
+ }
73
+ return true;
74
+ });
75
+ }
76
+ function groupBy(items, keyFn) {
77
+ const groups = new Map;
78
+ for (const item of items) {
79
+ const key = keyFn(item);
80
+ const existing = groups.get(key);
81
+ if (existing) {
82
+ existing.push(item);
83
+ } else {
84
+ groups.set(key, [item]);
85
+ }
86
+ }
87
+ return groups;
88
+ }
89
+ function groupByToArray(items, keyFn) {
90
+ const map = groupBy(items, keyFn);
91
+ return Array.from(map.entries()).map(([key, items2]) => ({ key, items: items2 }));
92
+ }
93
+ function groupByMultiple(items, keysFn) {
94
+ const groups = new Map;
95
+ for (const item of items) {
96
+ const keys = keysFn(item);
97
+ for (const key of keys) {
98
+ const existing = groups.get(key);
99
+ if (existing) {
100
+ existing.push(item);
101
+ } else {
102
+ groups.set(key, [item]);
103
+ }
104
+ }
105
+ }
106
+ return groups;
107
+ }
108
+ function getUniqueTags(items) {
109
+ const tags = new Set;
110
+ for (const item of items) {
111
+ for (const tag of item.meta.tags ?? []) {
112
+ tags.add(tag);
113
+ }
114
+ }
115
+ return Array.from(tags).sort();
116
+ }
117
+ function getUniqueOwners(items) {
118
+ const owners = new Set;
119
+ for (const item of items) {
120
+ for (const owner of item.meta.owners ?? []) {
121
+ owners.add(owner);
122
+ }
123
+ }
124
+ return Array.from(owners).sort();
125
+ }
126
+ function getUniqueDomains(items) {
127
+ const domains = new Set;
128
+ for (const item of items) {
129
+ domains.add(GroupingStrategies.byDomain(item));
130
+ }
131
+ return Array.from(domains).sort();
132
+ }
133
+ var GroupingStrategies;
134
+ var init_registry_utils = __esm(() => {
135
+ GroupingStrategies = {
136
+ byTag: (item) => item.meta.tags?.[0] ?? "untagged",
137
+ byAllTags: (item) => item.meta.tags?.length ? item.meta.tags : ["untagged"],
138
+ byOwner: (item) => item.meta.owners?.[0] ?? "unowned",
139
+ byDomain: (item) => {
140
+ const name = item.meta.key ?? item.meta.key ?? "";
141
+ return name.split(".")[0] ?? "default";
142
+ },
143
+ byStability: (item) => item.meta.stability ?? "stable",
144
+ byUrlPath: (level) => (item) => {
145
+ if (!item.path)
146
+ return "root";
147
+ const segments = item.path.split("/").filter(Boolean);
148
+ return segments.slice(0, level).join("/") || "root";
149
+ }
150
+ };
151
+ });
152
+
153
+ // src/capabilities/capabilities.ts
154
+ import { compareVersions } from "compare-versions";
155
+ var capKey = (key, version) => `${key}.v${version}`;
156
+
157
+ class CapabilityRegistry {
158
+ items = new Map;
159
+ surfaceIndex = null;
160
+ register(spec) {
161
+ const key = capKey(spec.meta.key, spec.meta.version);
162
+ if (this.items.has(key))
163
+ throw new Error(`Duplicate capability ${key}`);
164
+ this.items.set(key, spec);
165
+ this.surfaceIndex = null;
166
+ return this;
167
+ }
168
+ list() {
169
+ return [...this.items.values()];
170
+ }
171
+ get(key, version) {
172
+ if (version != null)
173
+ return this.items.get(capKey(key, version));
174
+ let candidate;
175
+ for (const spec of this.items.values()) {
176
+ if (spec.meta.key !== key)
177
+ continue;
178
+ if (!candidate || compareVersions(spec.meta.version, candidate.meta.version) > 0) {
179
+ candidate = spec;
180
+ }
181
+ }
182
+ return candidate;
183
+ }
184
+ satisfies(requirement, additional) {
185
+ if (requirement.optional)
186
+ return true;
187
+ if (additional?.some((ref) => matchesRequirement(ref, requirement)))
188
+ return true;
189
+ const spec = requirement.version ? this.get(requirement.key, requirement.version) : this.get(requirement.key);
190
+ if (!spec)
191
+ return false;
192
+ if (requirement.kind && spec.meta.kind !== requirement.kind)
193
+ return false;
194
+ if (requirement.version != null && spec.meta.version !== requirement.version)
195
+ return false;
196
+ return true;
197
+ }
198
+ buildSurfaceIndex() {
199
+ if (this.surfaceIndex)
200
+ return this.surfaceIndex;
201
+ this.surfaceIndex = new Map;
202
+ for (const spec of this.items.values()) {
203
+ const capabilityKey = capKey(spec.meta.key, spec.meta.version);
204
+ for (const surface of spec.provides ?? []) {
205
+ const surfaceKey = `${surface.surface}:${surface.key}`;
206
+ if (!this.surfaceIndex.has(surfaceKey)) {
207
+ this.surfaceIndex.set(surfaceKey, new Set);
208
+ }
209
+ this.surfaceIndex.get(surfaceKey)?.add(capabilityKey);
210
+ }
211
+ }
212
+ return this.surfaceIndex;
213
+ }
214
+ getOperationsFor(capabilityKey, version) {
215
+ const spec = this.get(capabilityKey, version);
216
+ if (!spec)
217
+ return [];
218
+ return spec.provides?.filter((s) => s.surface === "operation").map((s) => s.key) ?? [];
219
+ }
220
+ getEventsFor(capabilityKey, version) {
221
+ const spec = this.get(capabilityKey, version);
222
+ if (!spec)
223
+ return [];
224
+ return spec.provides?.filter((s) => s.surface === "event").map((s) => s.key) ?? [];
225
+ }
226
+ getPresentationsFor(capabilityKey, version) {
227
+ const spec = this.get(capabilityKey, version);
228
+ if (!spec)
229
+ return [];
230
+ return spec.provides?.filter((s) => s.surface === "presentation").map((s) => s.key) ?? [];
231
+ }
232
+ getWorkflowsFor(capabilityKey, version) {
233
+ const spec = this.get(capabilityKey, version);
234
+ if (!spec)
235
+ return [];
236
+ return spec.provides?.filter((s) => s.surface === "workflow").map((s) => s.key) ?? [];
237
+ }
238
+ getResourcesFor(capabilityKey, version) {
239
+ const spec = this.get(capabilityKey, version);
240
+ if (!spec)
241
+ return [];
242
+ return spec.provides?.filter((s) => s.surface === "resource").map((s) => s.key) ?? [];
243
+ }
244
+ getCapabilitiesForOperation(operationKey) {
245
+ const index = this.buildSurfaceIndex();
246
+ const capKeys = index.get(`operation:${operationKey}`);
247
+ if (!capKeys)
248
+ return [];
249
+ return [...capKeys].map((k) => {
250
+ const spec = this.items.get(k);
251
+ return { key: spec?.meta.key ?? "", version: spec?.meta.version ?? "" };
252
+ });
253
+ }
254
+ getCapabilitiesForEvent(eventKey) {
255
+ const index = this.buildSurfaceIndex();
256
+ const capKeys = index.get(`event:${eventKey}`);
257
+ if (!capKeys)
258
+ return [];
259
+ return [...capKeys].map((k) => {
260
+ const spec = this.items.get(k);
261
+ return { key: spec?.meta.key ?? "", version: spec?.meta.version ?? "" };
262
+ });
263
+ }
264
+ getCapabilitiesForPresentation(presentationKey) {
265
+ const index = this.buildSurfaceIndex();
266
+ const capKeys = index.get(`presentation:${presentationKey}`);
267
+ if (!capKeys)
268
+ return [];
269
+ return [...capKeys].map((k) => {
270
+ const spec = this.items.get(k);
271
+ return { key: spec?.meta.key ?? "", version: spec?.meta.version ?? "" };
272
+ });
273
+ }
274
+ getAncestors(capabilityKey, version) {
275
+ const ancestors = [];
276
+ const visited = new Set;
277
+ let current = this.get(capabilityKey, version);
278
+ while (current?.extends) {
279
+ const parentKey = capKey(current.extends.key, current.extends.version);
280
+ if (visited.has(parentKey)) {
281
+ break;
282
+ }
283
+ visited.add(parentKey);
284
+ const parent = this.get(current.extends.key, current.extends.version);
285
+ if (!parent)
286
+ break;
287
+ ancestors.push(parent);
288
+ current = parent;
289
+ }
290
+ return ancestors;
291
+ }
292
+ getEffectiveRequirements(capabilityKey, version) {
293
+ const spec = this.get(capabilityKey, version);
294
+ if (!spec)
295
+ return [];
296
+ const ancestors = this.getAncestors(capabilityKey, version);
297
+ const requirementMap = new Map;
298
+ for (const ancestor of [...ancestors].reverse()) {
299
+ for (const req of ancestor.requires ?? []) {
300
+ requirementMap.set(req.key, req);
301
+ }
302
+ }
303
+ for (const req of spec.requires ?? []) {
304
+ requirementMap.set(req.key, req);
305
+ }
306
+ return [...requirementMap.values()];
307
+ }
308
+ getEffectiveSurfaces(capabilityKey, version) {
309
+ const spec = this.get(capabilityKey, version);
310
+ if (!spec)
311
+ return [];
312
+ const ancestors = this.getAncestors(capabilityKey, version);
313
+ const surfaces = [];
314
+ for (const ancestor of [...ancestors].reverse()) {
315
+ surfaces.push(...ancestor.provides ?? []);
316
+ }
317
+ surfaces.push(...spec.provides ?? []);
318
+ return surfaces;
319
+ }
320
+ }
321
+ function matchesRequirement(ref, requirement) {
322
+ if (ref.key !== requirement.key)
323
+ return false;
324
+ if (requirement.version != null && ref.version !== requirement.version)
325
+ return false;
326
+ return true;
327
+ }
328
+ function capabilityKey(spec) {
329
+ return capKey(spec.meta.key, spec.meta.version);
330
+ }
331
+ function defineCapability(spec) {
332
+ return spec;
333
+ }
334
+
335
+ // src/capabilities/validation.ts
336
+ function validateCapabilityConsistency(deps) {
337
+ const errors = [];
338
+ const warnings = [];
339
+ for (const capability of deps.capabilities.list()) {
340
+ const capKey2 = `${capability.meta.key}.v${capability.meta.version}`;
341
+ for (const surface of capability.provides ?? []) {
342
+ const exists = checkSurfaceExists(deps, surface.surface, surface.key);
343
+ if (!exists) {
344
+ errors.push({
345
+ type: "missing_surface_spec",
346
+ message: `Capability "${capKey2}" provides ${surface.surface} "${surface.key}" but spec not found`,
347
+ capabilityKey: capKey2,
348
+ surface: surface.surface,
349
+ specKey: surface.key
350
+ });
351
+ }
352
+ }
353
+ }
354
+ if (deps.operations) {
355
+ for (const op of deps.operations.list()) {
356
+ if (op.capability) {
357
+ const capSpec = deps.capabilities.get(op.capability.key, op.capability.version);
358
+ if (!capSpec) {
359
+ errors.push({
360
+ type: "capability_not_found",
361
+ message: `Operation "${op.meta.key}" references capability "${op.capability.key}.v${op.capability.version}" but capability not found`,
362
+ specKey: op.meta.key,
363
+ capabilityKey: `${op.capability.key}.v${op.capability.version}`,
364
+ surface: "operation"
365
+ });
366
+ } else {
367
+ const inProvides = capSpec.provides?.some((p) => p.surface === "operation" && p.key === op.meta.key);
368
+ if (!inProvides) {
369
+ errors.push({
370
+ type: "surface_not_in_provides",
371
+ message: `Operation "${op.meta.key}" claims capability "${op.capability.key}.v${op.capability.version}" but not in capability's provides`,
372
+ specKey: op.meta.key,
373
+ capabilityKey: `${op.capability.key}.v${op.capability.version}`,
374
+ surface: "operation"
375
+ });
376
+ }
377
+ }
378
+ }
379
+ }
380
+ }
381
+ if (deps.events) {
382
+ for (const event of deps.events.list()) {
383
+ if (event.capability) {
384
+ const capSpec = deps.capabilities.get(event.capability.key, event.capability.version);
385
+ if (!capSpec) {
386
+ errors.push({
387
+ type: "capability_not_found",
388
+ message: `Event "${event.meta.key}" references capability "${event.capability.key}.v${event.capability.version}" but capability not found`,
389
+ specKey: event.meta.key,
390
+ capabilityKey: `${event.capability.key}.v${event.capability.version}`,
391
+ surface: "event"
392
+ });
393
+ } else {
394
+ const inProvides = capSpec.provides?.some((p) => p.surface === "event" && p.key === event.meta.key);
395
+ if (!inProvides) {
396
+ errors.push({
397
+ type: "surface_not_in_provides",
398
+ message: `Event "${event.meta.key}" claims capability "${event.capability.key}.v${event.capability.version}" but not in capability's provides`,
399
+ specKey: event.meta.key,
400
+ capabilityKey: `${event.capability.key}.v${event.capability.version}`,
401
+ surface: "event"
402
+ });
403
+ }
404
+ }
405
+ }
406
+ }
407
+ }
408
+ if (deps.presentations) {
409
+ for (const pres of deps.presentations.list()) {
410
+ if (pres.capability) {
411
+ const capSpec = deps.capabilities.get(pres.capability.key, pres.capability.version);
412
+ if (!capSpec) {
413
+ errors.push({
414
+ type: "capability_not_found",
415
+ message: `Presentation "${pres.meta.key}" references capability "${pres.capability.key}.v${pres.capability.version}" but capability not found`,
416
+ specKey: pres.meta.key,
417
+ capabilityKey: `${pres.capability.key}.v${pres.capability.version}`,
418
+ surface: "presentation"
419
+ });
420
+ } else {
421
+ const inProvides = capSpec.provides?.some((p) => p.surface === "presentation" && p.key === pres.meta.key);
422
+ if (!inProvides) {
423
+ errors.push({
424
+ type: "surface_not_in_provides",
425
+ message: `Presentation "${pres.meta.key}" claims capability "${pres.capability.key}.v${pres.capability.version}" but not in capability's provides`,
426
+ specKey: pres.meta.key,
427
+ capabilityKey: `${pres.capability.key}.v${pres.capability.version}`,
428
+ surface: "presentation"
429
+ });
430
+ }
431
+ }
432
+ }
433
+ }
434
+ }
435
+ return {
436
+ valid: errors.length === 0,
437
+ errors,
438
+ warnings
439
+ };
440
+ }
441
+ function checkSurfaceExists(deps, surface, key) {
442
+ switch (surface) {
443
+ case "operation":
444
+ return deps.operations?.has(key) ?? true;
445
+ case "event":
446
+ return deps.events?.has(key) ?? true;
447
+ case "presentation":
448
+ return deps.presentations?.has(key) ?? true;
449
+ case "workflow":
450
+ case "resource":
451
+ return true;
452
+ default:
453
+ return true;
454
+ }
455
+ }
456
+ function findOrphanSpecs(deps) {
457
+ const result = {
458
+ operations: [],
459
+ events: [],
460
+ presentations: []
461
+ };
462
+ if (deps.operations) {
463
+ for (const op of deps.operations.list()) {
464
+ if (!op.capability) {
465
+ result.operations.push(op.meta.key);
466
+ }
467
+ }
468
+ }
469
+ if (deps.events) {
470
+ for (const event of deps.events.list()) {
471
+ if (!event.capability) {
472
+ result.events.push(event.meta.key);
473
+ }
474
+ }
475
+ }
476
+ if (deps.presentations) {
477
+ for (const pres of deps.presentations.list()) {
478
+ if (!pres.capability) {
479
+ result.presentations.push(pres.meta.key);
480
+ }
481
+ }
482
+ }
483
+ return result;
484
+ }
485
+
486
+ // src/capabilities/context.ts
487
+ class CapabilityMissingError extends Error {
488
+ capabilityKey;
489
+ requiredVersion;
490
+ constructor(capabilityKey2, requiredVersion) {
491
+ const versionSuffix = requiredVersion ? `.v${requiredVersion}` : "";
492
+ super(`Missing required capability: ${capabilityKey2}${versionSuffix}`);
493
+ this.name = "CapabilityMissingError";
494
+ this.capabilityKey = capabilityKey2;
495
+ this.requiredVersion = requiredVersion;
496
+ }
497
+ }
498
+
499
+ class CapabilityContextImpl {
500
+ capabilities;
501
+ capabilityVersions;
502
+ constructor(enabledCapabilities) {
503
+ const capSet = new Set;
504
+ const versionMap = new Map;
505
+ for (const cap of enabledCapabilities) {
506
+ capSet.add(cap.key);
507
+ versionMap.set(cap.key, cap.version);
508
+ }
509
+ this.capabilities = capSet;
510
+ this.capabilityVersions = versionMap;
511
+ }
512
+ hasCapability(key, version) {
513
+ if (!this.capabilities.has(key))
514
+ return false;
515
+ if (version != null) {
516
+ const enabledVersion = this.capabilityVersions.get(key);
517
+ return enabledVersion === version;
518
+ }
519
+ return true;
520
+ }
521
+ requireCapability(key, version) {
522
+ if (!this.hasCapability(key, version)) {
523
+ throw new CapabilityMissingError(key, version);
524
+ }
525
+ }
526
+ hasAllCapabilities(keys) {
527
+ return keys.every((k) => this.capabilities.has(k));
528
+ }
529
+ hasAnyCapability(keys) {
530
+ return keys.some((k) => this.capabilities.has(k));
531
+ }
532
+ getMatchingCapabilities(pattern) {
533
+ if (!pattern.includes("*")) {
534
+ return this.capabilities.has(pattern) ? [pattern] : [];
535
+ }
536
+ const regexPattern = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
537
+ const regex = new RegExp(`^${regexPattern}$`);
538
+ return [...this.capabilities].filter((key) => regex.test(key));
539
+ }
540
+ }
541
+ function createCapabilityContext(enabledCapabilities) {
542
+ return new CapabilityContextImpl(enabledCapabilities);
543
+ }
544
+ function createEmptyCapabilityContext() {
545
+ return new CapabilityContextImpl([]);
546
+ }
547
+ function createBypassCapabilityContext(allCapabilities) {
548
+ return new CapabilityContextImpl(allCapabilities);
549
+ }
550
+
551
+ // src/capabilities/guards.ts
552
+ function checkCapabilityForOperation(ctx, operation) {
553
+ if (!operation.capability) {
554
+ return { allowed: true };
555
+ }
556
+ const { key, version } = operation.capability;
557
+ if (ctx.hasCapability(key, version)) {
558
+ return { allowed: true };
559
+ }
560
+ return {
561
+ allowed: false,
562
+ missingCapability: { key, version },
563
+ reason: `Operation "${operation.meta.key}" requires capability "${key}.v${version}"`
564
+ };
565
+ }
566
+ function assertCapabilityForOperation(ctx, operation) {
567
+ const result = checkCapabilityForOperation(ctx, operation);
568
+ if (!result.allowed && result.missingCapability) {
569
+ throw new CapabilityMissingError(result.missingCapability.key, result.missingCapability.version);
570
+ }
571
+ }
572
+ function checkCapabilityForEvent(ctx, event) {
573
+ if (!event.capability) {
574
+ return { allowed: true };
575
+ }
576
+ const { key, version } = event.capability;
577
+ if (ctx.hasCapability(key, version)) {
578
+ return { allowed: true };
579
+ }
580
+ return {
581
+ allowed: false,
582
+ missingCapability: { key, version },
583
+ reason: `Event "${event.meta.key}" requires capability "${key}.v${version}"`
584
+ };
585
+ }
586
+ function assertCapabilityForEvent(ctx, event) {
587
+ const result = checkCapabilityForEvent(ctx, event);
588
+ if (!result.allowed && result.missingCapability) {
589
+ throw new CapabilityMissingError(result.missingCapability.key, result.missingCapability.version);
590
+ }
591
+ }
592
+ function checkCapabilityForPresentation(ctx, presentation) {
593
+ if (!presentation.capability) {
594
+ return { allowed: true };
595
+ }
596
+ const { key, version } = presentation.capability;
597
+ if (ctx.hasCapability(key, version)) {
598
+ return { allowed: true };
599
+ }
600
+ return {
601
+ allowed: false,
602
+ missingCapability: { key, version },
603
+ reason: `Presentation "${presentation.meta.key}" requires capability "${key}.v${version}"`
604
+ };
605
+ }
606
+ function assertCapabilityForPresentation(ctx, presentation) {
607
+ const result = checkCapabilityForPresentation(ctx, presentation);
608
+ if (!result.allowed && result.missingCapability) {
609
+ throw new CapabilityMissingError(result.missingCapability.key, result.missingCapability.version);
610
+ }
611
+ }
612
+ function filterOperationsByCapability(ctx, operations) {
613
+ return operations.filter((op) => checkCapabilityForOperation(ctx, op).allowed);
614
+ }
615
+ function filterEventsByCapability(ctx, events) {
616
+ return events.filter((ev) => checkCapabilityForEvent(ctx, ev).allowed);
617
+ }
618
+ function filterPresentationsByCapability(ctx, presentations) {
619
+ return presentations.filter((pres) => checkCapabilityForPresentation(ctx, pres).allowed);
620
+ }
621
+
622
+ // src/ownership.ts
623
+ var StabilityEnum = {
624
+ Idea: "idea",
625
+ InCreation: "in_creation",
626
+ Experimental: "experimental",
627
+ Beta: "beta",
628
+ Stable: "stable",
629
+ Deprecated: "deprecated"
630
+ };
631
+ var OwnersEnum = {
632
+ PlatformCore: "platform.core",
633
+ PlatformSigil: "platform.sigil",
634
+ PlatformMarketplace: "platform.marketplace",
635
+ PlatformMessaging: "platform.messaging",
636
+ PlatformContent: "platform.content",
637
+ PlatformFeatureFlags: "platform.featureflags",
638
+ PlatformFinance: "platform.finance"
639
+ };
640
+ var Owners = OwnersEnum;
641
+ var TagsEnum = {
642
+ Spots: "spots",
643
+ Collectivity: "collectivity",
644
+ Marketplace: "marketplace",
645
+ Sellers: "sellers",
646
+ Auth: "auth",
647
+ Login: "login",
648
+ Signup: "signup",
649
+ Guide: "guide",
650
+ Docs: "docs",
651
+ I18n: "i18n",
652
+ Incident: "incident",
653
+ Automation: "automation",
654
+ Hygiene: "hygiene"
655
+ };
656
+ var Tags = TagsEnum;
657
+
658
+ // src/capabilities/openbanking.ts
659
+ var OWNERS = ["platform.finance"];
660
+ var TAGS = ["open-banking", "finance"];
661
+ var openBankingAccountsReadCapability = {
662
+ meta: {
663
+ key: "openbanking.accounts.read",
664
+ version: "1.0.0",
665
+ kind: "integration",
666
+ title: "Open Banking Accounts (Read)",
667
+ description: "Provides read-only access to linked bank accounts, including account summaries and metadata.",
668
+ domain: "finance",
669
+ owners: [...OWNERS],
670
+ tags: [...TAGS],
671
+ stability: StabilityEnum.Experimental
672
+ },
673
+ provides: [
674
+ {
675
+ surface: "operation",
676
+ key: "openbanking.accounts.list",
677
+ version: "1.0.0",
678
+ description: "List bank accounts linked to a Powens open banking connection."
679
+ },
680
+ {
681
+ surface: "operation",
682
+ key: "openbanking.accounts.get",
683
+ version: "1.0.0",
684
+ description: "Retrieve the canonical bank account record for a specific account."
685
+ },
686
+ {
687
+ surface: "operation",
688
+ key: "openbanking.accounts.sync",
689
+ version: "1.0.0",
690
+ description: "Trigger a refresh of bank account metadata from the open banking provider."
691
+ }
692
+ ]
693
+ };
694
+ var openBankingTransactionsReadCapability = {
695
+ meta: {
696
+ key: "openbanking.transactions.read",
697
+ version: "1.0.0",
698
+ kind: "integration",
699
+ title: "Open Banking Transactions (Read)",
700
+ description: "Enables retrieval of transaction history for linked bank accounts via open banking providers.",
701
+ domain: "finance",
702
+ owners: [...OWNERS],
703
+ tags: [...TAGS, "transactions"],
704
+ stability: StabilityEnum.Experimental
705
+ },
706
+ provides: [
707
+ {
708
+ surface: "operation",
709
+ key: "openbanking.transactions.list",
710
+ version: "1.0.0",
711
+ description: "List transactions for a given bank account with optional date filtering."
712
+ },
713
+ {
714
+ surface: "operation",
715
+ key: "openbanking.transactions.sync",
716
+ version: "1.0.0",
717
+ description: "Synchronise transactions from the open banking provider into the canonical ledger."
718
+ }
719
+ ]
720
+ };
721
+ var openBankingBalancesReadCapability = {
722
+ meta: {
723
+ key: "openbanking.balances.read",
724
+ version: "1.0.0",
725
+ kind: "integration",
726
+ title: "Open Banking Balances (Read)",
727
+ description: "Allows querying of current and available balances for linked bank accounts via open banking providers.",
728
+ domain: "finance",
729
+ owners: [...OWNERS],
730
+ tags: [...TAGS, "balances"],
731
+ stability: StabilityEnum.Experimental
732
+ },
733
+ provides: [
734
+ {
735
+ surface: "operation",
736
+ key: "openbanking.balances.get",
737
+ version: "1.0.0",
738
+ description: "Retrieve the latest known balances for a specified bank account."
739
+ },
740
+ {
741
+ surface: "operation",
742
+ key: "openbanking.balances.refresh",
743
+ version: "1.0.0",
744
+ description: "Force a balance refresh from the open banking provider."
745
+ }
746
+ ]
747
+ };
748
+ function registerOpenBankingCapabilities(registry) {
749
+ return registry.register(openBankingAccountsReadCapability).register(openBankingTransactionsReadCapability).register(openBankingBalancesReadCapability);
750
+ }
751
+
752
+ // src/capabilities/meeting-recorder.ts
753
+ var OWNERS2 = ["platform.integrations"];
754
+ var TAGS2 = ["meeting-recorder", "transcripts", "integrations"];
755
+ var meetingRecorderMeetingsReadCapability = {
756
+ meta: {
757
+ key: "meeting-recorder.meetings.read",
758
+ version: "1.0.0",
759
+ kind: "integration",
760
+ title: "Meeting Recorder Meetings (Read)",
761
+ description: "Provides read-only access to recorded meetings and their metadata.",
762
+ domain: "integrations",
763
+ owners: [...OWNERS2],
764
+ tags: [...TAGS2, "meetings"],
765
+ stability: StabilityEnum.Experimental
766
+ },
767
+ provides: [
768
+ {
769
+ surface: "operation",
770
+ key: "meeting-recorder.meetings.list",
771
+ version: "1.0.0",
772
+ description: "List meetings available from the recorder provider."
773
+ },
774
+ {
775
+ surface: "operation",
776
+ key: "meeting-recorder.meetings.get",
777
+ version: "1.0.0",
778
+ description: "Fetch detailed metadata for a specific meeting."
779
+ }
780
+ ]
781
+ };
782
+ var meetingRecorderTranscriptsReadCapability = {
783
+ meta: {
784
+ key: "meeting-recorder.transcripts.read",
785
+ version: "1.0.0",
786
+ kind: "integration",
787
+ title: "Meeting Recorder Transcripts (Read)",
788
+ description: "Enables retrieval of transcripts for recorded meetings from external providers.",
789
+ domain: "integrations",
790
+ owners: [...OWNERS2],
791
+ tags: [...TAGS2, "transcripts"],
792
+ stability: StabilityEnum.Experimental
793
+ },
794
+ provides: [
795
+ {
796
+ surface: "operation",
797
+ key: "meeting-recorder.transcripts.get",
798
+ version: "1.0.0",
799
+ description: "Fetch the transcript for a specific meeting recording."
800
+ },
801
+ {
802
+ surface: "operation",
803
+ key: "meeting-recorder.transcripts.sync",
804
+ version: "1.0.0",
805
+ description: "Trigger a transcript sync from the recorder provider."
806
+ }
807
+ ]
808
+ };
809
+ var meetingRecorderWebhooksCapability = {
810
+ meta: {
811
+ key: "meeting-recorder.webhooks",
812
+ version: "1.0.0",
813
+ kind: "integration",
814
+ title: "Meeting Recorder Webhooks",
815
+ description: "Allows processing of webhook events for meeting transcript readiness.",
816
+ domain: "integrations",
817
+ owners: [...OWNERS2],
818
+ tags: [...TAGS2, "webhooks"],
819
+ stability: StabilityEnum.Experimental
820
+ },
821
+ provides: [
822
+ {
823
+ surface: "operation",
824
+ key: "meeting-recorder.webhooks.ingest",
825
+ version: "1.0.0",
826
+ description: "Ingest and verify meeting recorder webhook payloads."
827
+ }
828
+ ]
829
+ };
830
+ function registerMeetingRecorderCapabilities(registry) {
831
+ return registry.register(meetingRecorderMeetingsReadCapability).register(meetingRecorderTranscriptsReadCapability).register(meetingRecorderWebhooksCapability);
832
+ }
833
+ // src/operations/operation.ts
834
+ var isEmitDeclRef = (e) => ("ref" in e);
835
+ var defineCommand = (spec) => ({
836
+ ...spec,
837
+ meta: { ...spec.meta, kind: "command" },
838
+ policy: {
839
+ ...spec.policy,
840
+ idempotent: spec.policy?.["policy"]?.idempotent ?? false
841
+ }
842
+ });
843
+ var defineQuery = (spec) => ({
844
+ ...spec,
845
+ meta: { ...spec.meta, kind: "query" },
846
+ policy: { ...spec.policy, idempotent: true }
847
+ });
848
+
849
+ // src/registry.ts
850
+ init_registry_utils();
851
+ import { compareVersions as compareVersions2 } from "compare-versions";
852
+ var keyOfSpecContract = (spec) => `${spec.meta.key}.v${spec.meta.version}`;
853
+
854
+ class SpecContractRegistry {
855
+ contractType;
856
+ items = new Map;
857
+ constructor(contractType, items) {
858
+ this.contractType = contractType;
859
+ if (items) {
860
+ items.forEach((p) => this.register(p));
861
+ }
862
+ }
863
+ register(p) {
864
+ const key = keyOfSpecContract(p);
865
+ if (this.items.has(key))
866
+ throw new Error(`Duplicate contract \`${this.contractType}\` ${key}`);
867
+ this.items.set(key, p);
868
+ return this;
869
+ }
870
+ count() {
871
+ return this.items.size;
872
+ }
873
+ list() {
874
+ return [...this.items.values()];
875
+ }
876
+ get(key, version) {
877
+ if (version != null)
878
+ return this.items.get(`${key}.v${version}`);
879
+ let candidate;
880
+ for (const [k, p] of this.items.entries()) {
881
+ if (!k.startsWith(`${key}.v`))
882
+ continue;
883
+ if (!candidate || compareVersions2(p.meta.version, candidate.meta.version) > 0) {
884
+ candidate = p;
885
+ }
886
+ }
887
+ return candidate;
888
+ }
889
+ has(key, version) {
890
+ return !!this.get(key, version);
891
+ }
892
+ filter(criteria) {
893
+ return filterBy(this.list(), criteria);
894
+ }
895
+ listByTag(tag) {
896
+ return this.list().filter((p) => p.meta.tags?.includes(tag));
897
+ }
898
+ listByOwner(owner) {
899
+ return this.list().filter((p) => p.meta.owners?.includes(owner));
900
+ }
901
+ groupBy(keyFn) {
902
+ return groupBy(this.list(), keyFn);
903
+ }
904
+ getUniqueTags() {
905
+ return getUniqueTags(this.list());
906
+ }
907
+ }
908
+
909
+ // src/events.ts
910
+ function defineEvent(e) {
911
+ return e;
912
+ }
913
+ var eventKey = (key, version) => `${key}.v${version}`;
914
+
915
+ class EventRegistry extends SpecContractRegistry {
916
+ constructor(items) {
917
+ super("event", items);
918
+ }
919
+ }
920
+
921
+ // src/operations/registry.ts
922
+ function opKey(key, version) {
923
+ return `${key}.v${version}`;
924
+ }
925
+
926
+ class OperationSpecRegistry extends SpecContractRegistry {
927
+ handlers = new Map;
928
+ constructor(items) {
929
+ super("operation", items);
930
+ }
931
+ bind(spec, handler) {
932
+ const key = opKey(spec.meta.key, spec.meta.version);
933
+ if (!this.items.has(key))
934
+ throw new Error(`Cannot bind; spec not found: ${key}`);
935
+ if (this.handlers.has(key))
936
+ throw new Error(`Handler already bound for ${key}`);
937
+ this.handlers.set(key, handler);
938
+ return this;
939
+ }
940
+ getHandler(key, version) {
941
+ const spec = this.get(key, version);
942
+ if (!spec)
943
+ return;
944
+ return this.handlers.get(opKey(spec.meta.key, spec.meta.version));
945
+ }
946
+ listBound() {
947
+ const out = [];
948
+ for (const [k, spec] of this.items.entries()) {
949
+ const h = this.handlers.get(k);
950
+ if (h)
951
+ out.push({ spec, handler: h });
952
+ }
953
+ return out;
954
+ }
955
+ async execute(key, version, rawInput, ctx) {
956
+ const baseSpec = this.get(key, version);
957
+ if (!baseSpec)
958
+ throw new Error(`Spec not found for ${key}${version ? `.v${version}` : ""}`);
959
+ const spec = await ctx.specVariantResolver?.resolve({
960
+ name: baseSpec.meta.key,
961
+ version: baseSpec.meta.version,
962
+ kind: baseSpec.meta.kind
963
+ }, ctx) ?? baseSpec;
964
+ let handlerKey = opKey(spec.meta.key, spec.meta.version);
965
+ let handler = this.handlers.get(handlerKey);
966
+ if (!handler) {
967
+ const fallbackKey = opKey(baseSpec.meta.key, baseSpec.meta.version);
968
+ handler = this.handlers.get(fallbackKey);
969
+ handlerKey = fallbackKey;
970
+ }
971
+ if (!handler)
972
+ throw new Error(`No handler bound for ${handlerKey}`);
973
+ const parsedInput = spec.io.input?.getZod().parse(rawInput);
974
+ if (ctx.decide) {
975
+ const [service, command] = spec.meta.key.split(".");
976
+ if (!service || !command)
977
+ throw new Error(`Invalid spec name: ${spec.meta.key}`);
978
+ const decision = await ctx.decide({
979
+ service,
980
+ command,
981
+ version: spec.meta.version,
982
+ actor: ctx.actor ?? "anonymous",
983
+ channel: ctx.channel,
984
+ roles: ctx.roles,
985
+ organizationId: ctx.organizationId,
986
+ userId: ctx.userId,
987
+ flags: []
988
+ });
989
+ if (decision.effect === "deny") {
990
+ throw new Error(`PolicyDenied: ${spec.meta.key}.v${spec.meta.version}`);
991
+ }
992
+ if (decision.rateLimit && ctx.rateLimit) {
993
+ const key2 = decision.rateLimit.key ?? "default";
994
+ const rpm = decision.rateLimit.rpm ?? 60;
995
+ await ctx.rateLimit(key2, 1, rpm);
996
+ }
997
+ }
998
+ const allowedEvents = new Map;
999
+ if (spec.sideEffects?.emits) {
1000
+ for (const e of spec.sideEffects.emits) {
1001
+ if (isEmitDeclRef(e)) {
1002
+ const eventSpec = ctx.eventSpecResolver?.get(e.ref.key, e.ref.version);
1003
+ if (eventSpec) {
1004
+ allowedEvents.set(`${e.ref.key}.v${e.ref.version}`, eventSpec.payload);
1005
+ }
1006
+ } else {
1007
+ allowedEvents.set(`${e.key}.v${e.version}`, e.payload);
1008
+ }
1009
+ }
1010
+ }
1011
+ const emitGuard = async (eventName, eventVersion, payload) => {
1012
+ const key2 = eventKey(eventName, eventVersion);
1013
+ const schema = allowedEvents.get(key2);
1014
+ if (!schema)
1015
+ throw new Error(`UndeclaredEvent: ${key2} not allowed by ${opKey(spec.meta.key, spec.meta.version)}`);
1016
+ const parsed = schema.getZod().parse(payload);
1017
+ await ctx.eventPublisher?.({
1018
+ key: eventName,
1019
+ version: eventVersion,
1020
+ payload: parsed,
1021
+ traceId: ctx.traceId
1022
+ });
1023
+ };
1024
+ if (ctx.appConfig) {
1025
+ if (!ctx.branding) {
1026
+ ctx.branding = ctx.appConfig.branding;
1027
+ }
1028
+ if (!ctx.translation) {
1029
+ ctx.translation = { config: ctx.appConfig.translation };
1030
+ } else if (!ctx.translation.config) {
1031
+ ctx.translation = {
1032
+ ...ctx.translation,
1033
+ config: ctx.appConfig.translation
1034
+ };
1035
+ }
1036
+ }
1037
+ const telemetryContext = ctx.telemetry;
1038
+ const trackTelemetry = async (trigger, details) => {
1039
+ if (!telemetryContext || !trigger?.event)
1040
+ return;
1041
+ try {
1042
+ const props = trigger.properties?.(details) ?? {};
1043
+ await telemetryContext.track(trigger.event.key, trigger.event.version ?? "1.0.0", props, {
1044
+ tenantId: ctx.organizationId ?? undefined,
1045
+ organizationId: ctx.organizationId,
1046
+ userId: ctx.userId,
1047
+ actor: ctx.actor,
1048
+ channel: ctx.channel,
1049
+ metadata: ctx.traceId ? { traceId: ctx.traceId } : undefined
1050
+ });
1051
+ } catch (_error) {}
1052
+ };
1053
+ let result;
1054
+ try {
1055
+ result = await handler(parsedInput, {
1056
+ ...ctx,
1057
+ __emitGuard__: emitGuard
1058
+ });
1059
+ } catch (error) {
1060
+ if (spec.telemetry?.failure) {
1061
+ await trackTelemetry(spec.telemetry.failure, {
1062
+ input: parsedInput ?? rawInput,
1063
+ error
1064
+ });
1065
+ }
1066
+ throw error;
1067
+ }
1068
+ if (spec.telemetry?.success) {
1069
+ await trackTelemetry(spec.telemetry.success, {
1070
+ input: parsedInput ?? rawInput,
1071
+ output: result
1072
+ });
1073
+ }
1074
+ const outputModel = spec.io.output;
1075
+ if (outputModel?.getZod) {
1076
+ const parsedOutput = outputModel.getZod().parse(result);
1077
+ return parsedOutput;
1078
+ }
1079
+ return result;
1080
+ }
1081
+ }
1082
+ // src/docs/presentations.ts
1083
+ var DEFAULT_TARGETS = [
1084
+ "markdown",
1085
+ "react"
1086
+ ];
1087
+ function normalizeRoute(route) {
1088
+ if (!route.length)
1089
+ return "/";
1090
+ const withLeading = route.startsWith("/") ? route : `/${route}`;
1091
+ return withLeading === "/" ? "/" : withLeading.replace(/\/+$/, "");
1092
+ }
1093
+ function deriveRoute(block, routePrefix) {
1094
+ if (block.route)
1095
+ return normalizeRoute(block.route);
1096
+ const prefix = routePrefix ?? "/docs";
1097
+ const slug = block.id.replace(/^docs\.?/, "").replace(/\./g, "/").replace(/\/+/g, "/");
1098
+ const path = slug.startsWith("/") ? slug : `${prefix}/${slug}`;
1099
+ return normalizeRoute(path);
1100
+ }
1101
+ function buildName(block, namespace) {
1102
+ return namespace ? `${namespace}.${block.id}` : block.id;
1103
+ }
1104
+ function docBlockToPresentationSpec(block, options) {
1105
+ const targets = options?.defaultTargets ?? DEFAULT_TARGETS;
1106
+ const version = block.version ?? options?.defaultVersion ?? "1.0.0";
1107
+ const stability = block.stability ?? options?.defaultStability ?? "stable";
1108
+ return {
1109
+ meta: {
1110
+ key: buildName(block, options?.namespace),
1111
+ title: block.title,
1112
+ version,
1113
+ description: block.summary ?? block.title,
1114
+ tags: block.tags || [],
1115
+ owners: block.owners || [],
1116
+ domain: block.domain || "",
1117
+ stability,
1118
+ goal: `Documentation of: ${block.summary}`,
1119
+ context: `Auto-generated`
1120
+ },
1121
+ policy: block.visibility && block.visibility !== "public" ? { flags: [block.visibility] } : undefined,
1122
+ source: {
1123
+ type: "blocknotejs",
1124
+ docJson: block.body
1125
+ },
1126
+ targets
1127
+ };
1128
+ }
1129
+ function docBlocksToPresentationRoutes(blocks, options) {
1130
+ return blocks.map((block) => ({
1131
+ block,
1132
+ route: deriveRoute(block, options?.routePrefix),
1133
+ descriptor: docBlockToPresentationSpec(block, options)
1134
+ }));
1135
+ }
1136
+ function docBlocksToPresentationSpecs(blocks, options) {
1137
+ return blocks.map((block) => docBlockToPresentationSpec(block, options));
1138
+ }
1139
+ function mapDocRoutes(routes) {
1140
+ return routes.map(({ route, descriptor }) => [route, descriptor]);
1141
+ }
1142
+
1143
+ // src/docs/registry.ts
1144
+ class DocRegistry {
1145
+ routes = new Map;
1146
+ constructor(blocks = [], options) {
1147
+ blocks.forEach((block) => this.register(block, options));
1148
+ }
1149
+ register(block, options) {
1150
+ const [route] = docBlocksToPresentationRoutes([block], options);
1151
+ if (route) {
1152
+ this.routes.set(block.id, route);
1153
+ }
1154
+ return this;
1155
+ }
1156
+ list() {
1157
+ return [...this.routes.values()];
1158
+ }
1159
+ get(id) {
1160
+ return this.routes.get(id);
1161
+ }
1162
+ toRouteTuples() {
1163
+ return this.list().map(({ route, descriptor }) => [route, descriptor]);
1164
+ }
1165
+ toPresentationSpecs(options) {
1166
+ return this.list().map(({ block }) => docBlockToPresentationSpec(block, options));
1167
+ }
1168
+ }
1169
+ var requiredFields = [
1170
+ "id",
1171
+ "title",
1172
+ "body",
1173
+ "kind",
1174
+ "visibility",
1175
+ "route"
1176
+ ];
1177
+ var defaultDocRegistry = new DocRegistry;
1178
+ function registerDocBlocks(blocks) {
1179
+ for (const block of blocks) {
1180
+ for (const field of requiredFields) {
1181
+ if (!block[field]) {
1182
+ throw new Error(`DocBlock ${block.id ?? "<missing id>"} missing field ${String(field)}`);
1183
+ }
1184
+ }
1185
+ defaultDocRegistry.register(block);
1186
+ }
1187
+ }
1188
+ function listRegisteredDocBlocks() {
1189
+ return defaultDocRegistry.list().map((r) => r.block);
1190
+ }
1191
+ function docId(id) {
1192
+ const found = defaultDocRegistry.get(id);
1193
+ if (!found)
1194
+ throw new Error(`DocBlock not registered: ${id}`);
1195
+ return id;
1196
+ }
1197
+
1198
+ // src/data-views/spec.ts
1199
+ function defineDataView(spec) {
1200
+ return spec;
1201
+ }
1202
+
1203
+ // src/data-views/registry.ts
1204
+ function dataViewKey(spec) {
1205
+ return `${spec.meta.key}.v${spec.meta.version}`;
1206
+ }
1207
+
1208
+ class DataViewRegistry extends SpecContractRegistry {
1209
+ constructor(items) {
1210
+ super("data-view", items);
1211
+ }
1212
+ }
1213
+ // src/docs/accessibility_wcag_compliance_specs.docblock.ts
1214
+ var accessibility_wcag_compliance_specs_DocBlocks = [
1215
+ {
1216
+ id: "docs.accessibility_wcag_compliance_specs",
1217
+ title: "Accessibility & WCAG Compliance — **specs.md**",
1218
+ summary: "> **Goal:** Ship interfaces that are usable by everyone, by default. This spec sets non‑negotiable rules, checklists, and CI gates to meet **WCAG 2.2 AA** (aim for AAA where low‑cost), align with **EN 301 549** (EU), and keep parity on **web (Next.js)** and **mobile (Expo/React Native)**.",
1219
+ kind: "reference",
1220
+ visibility: "public",
1221
+ route: "/docs/accessibility_wcag_compliance_specs",
1222
+ tags: ["accessibility_wcag_compliance_specs"],
1223
+ body: `# Accessibility & WCAG Compliance — **specs.md**
1224
+
1225
+ > **Goal:** Ship interfaces that are usable by everyone, by default. This spec sets non‑negotiable rules, checklists, and CI gates to meet **WCAG 2.2 AA** (aim for AAA where low‑cost), align with **EN 301 549** (EU), and keep parity on **web (Next.js)** and **mobile (Expo/React Native)**.
1226
+
1227
+ ---
1228
+
1229
+ ## 0) Scope & Principles
1230
+
1231
+ - **Standards:** WCAG 2.2 AA (incl. new 2.2 SCs: Focus Not Obscured, Focus Appearance, Target Size, Dragging Movements, Accessible Authentication, Redundant Entry). EN 301 549 compliance by conformance to WCAG.
1232
+ - **Principles:** Perceivable, Operable, Understandable, Robust (POUR).
1233
+ - **Rule of ARIA:** “No ARIA is better than bad ARIA.” Prefer native elements.
1234
+ - **Definition of Done (DoD):** No Critical/Major a11y issues in CI; keyboard complete; SR (screen reader) smoke test passed; contrasts pass; acceptance criteria below satisfied.
1235
+ - **Repo Alignment:** Web apps use **Radix Primitives + shadcn** wrappers centralized in \`packages/lssm/libs/ui-kit-web\`. Prefer those components over per‑app duplicates (\`packages/*/apps/*/src/components/ui\`). When missing, add to \`ui-kit-web\` first, then adopt app‑side.
1236
+
1237
+ ---
1238
+
1239
+ ## 1) Design Requirements (Design System & Tokens)
1240
+
1241
+ **1.1 Color & Contrast**
1242
+
1243
+ - Body text, icons essential to meaning: **≥ 4.5:1**; large text (≥ 18.66px regular / 14px bold): **≥ 3:1**.
1244
+ - Interactive states (default/hover/active/disabled/focus) must maintain contrast **≥ 3:1** against adjacent colors; text within components follows text ratios.
1245
+ - Provide light & dark themes with tokens that guarantee minimums. **Never rely solely on color** to convey meaning; pair with text, shape, or icon.
1246
+
1247
+ **1.2 Focus Indicators (WCAG 2.4.11/12)**
1248
+
1249
+ - Every interactive element has a **visible focus** with clear offset; indicator contrast **≥ 3:1** vs adjacent colors and indicator **area ≥ 2 CSS px** thick.
1250
+ - Focus **must not be obscured** by sticky headers/footers or scroll containers.
1251
+
1252
+ **1.3 Motion & Preferences**
1253
+
1254
+ - Respect \`prefers-reduced-motion\`: suppress large parallax, auto‑animations; provide instant alternatives.
1255
+ - Avoid motion that could trigger vestibular issues; under PRM, use fade/scale under **150ms**.
1256
+
1257
+ **1.4 Target Size (2.5.8)**
1258
+
1259
+ - Hit areas **≥ 24×24 CSS px** (web) and **≥ 44×44 dp** (mobile) unless exempt.
1260
+
1261
+ **1.5 Typography & Layout**
1262
+
1263
+ - Support zoom to **400%** without loss of content/functionality; responsive reflow at **320 CSS px** width.
1264
+ - Maintain clear heading hierarchy (h1…h6), one **h1** per view.
1265
+
1266
+ - Repository baseline (Web): default body text uses Tailwind \`text-lg\` (≈18px). As of 2025‑09‑20, the repository bumped all Tailwind typography scale usages by +1 step (e.g., \`text-sm\`→\`text-base\`, \`text-base\`→\`text-lg\`, …, \`text-8xl\`→\`text-9xl\`). For long‑form content, default to \`prose-lg\`.
1267
+ - Do not use \`text-xs\` for body copy. Reserve \`text-sm\` only for non‑essential meta (timestamps, fine print) while ensuring contrast and touch targets remain compliant.
1268
+ - When increasing font size, ensure line height supports readability. Prefer Tailwind defaults or \`leading-relaxed\`/\`leading-7\` for body text where dense blocks appear.
1269
+
1270
+ **1.6 Iconography & Imagery**
1271
+
1272
+ - Decorative images: \`alt=""\` or \`aria-hidden="true"\`.
1273
+ - Informative images: concise, specific **alt**; complex charts require a **data table or long description**.
1274
+
1275
+ ---
1276
+
1277
+ ## 2) Content Requirements (UX Writing)
1278
+
1279
+ - Links say **what happens** (avoid “click here”).
1280
+ - Buttons start with verbs; avoid ambiguous labels.
1281
+ - Form labels are **visible**; placeholders are **not labels**.
1282
+ - Error messages: human + programmatic association; avoid color‑only.
1283
+ - Authentication: allow **copy/paste**, password managers, and avoid cognitive tests alone (**3.3.7/3.3.8/3.3.9**).
1284
+ - Avoid CAPTCHAs that block users; if unavoidable, provide **multiple alternatives** (logic-free).
1285
+
1286
+ ---
1287
+
1288
+ ## 3) Engineering Requirements (Web — Next.js/React)
1289
+
1290
+ > Use and extend \`packages/lssm/libs/ui-kit-web\` as the default UI surface. It wraps **Radix** primitives with sensible a11y defaults (focus rings, roles, keyboard, ARIA binding). When a gap exists, add it to \`ui-kit-web\` first.
1291
+
1292
+ **3.1 Semantics & Landmarks**
1293
+
1294
+ - Use native elements: \`<button>\`, \`<a href>\`, \`<label for>\`, \`<fieldset>\`, \`<legend>\`, \`<table>\`, etc.
1295
+ - Landmarks per page: \`header\`, \`nav\`, \`main\`, \`aside\`, \`footer\`. Provide a **Skip to main content** link.
1296
+ - Provide a **Route Announcer** (\`aria-live="polite"\`) and move focus to page **h1** after navigation.
1297
+
1298
+ **3.2 Keyboard**
1299
+
1300
+ - All functionality available with keyboard alone. Tab order follows DOM/visual order; **no keyboard traps**.
1301
+ - Common bindings:
1302
+ - Space/Enter → activate button; Enter on link;
1303
+ - Esc closes dialogs/menus;
1304
+ - Arrow keys for lists/menus/tablists with **roving tabindex**.
1305
+
1306
+ **3.3 Focus Management**
1307
+
1308
+ - On route change (Next.js), move focus to the page \`<h1>\` or container and announce via a live region.
1309
+ - Dialogs/menus: **trap focus** inside; return focus to invoking control on close.
1310
+ - Don’t steal focus except after explicit user action.
1311
+
1312
+ **3.4 Forms**
1313
+
1314
+ - Each input has a \`<label>\` or \`aria-label\`. Group related inputs with \`<fieldset><legend>\`.
1315
+ - Associate errors via \`aria-describedby\` or inline IDs; announce with \`role="alert"\` (assertive only for critical).
1316
+ - Provide **autocomplete** tokens for known fields; show **inline validation** and do not block on **onBlur** alone.
1317
+
1318
+ **3.5 ARIA Usage**
1319
+
1320
+ - Only when needed; match patterns (dialog, menu, combobox, tablist, listbox) per ARIA Authoring Practices.
1321
+ - Ensure **name/role/value** are programmatically determinable.
1322
+
1323
+ **3.6 Media**
1324
+
1325
+ - Videos: **captions**; provide **transcripts** for audio; audio descriptions for essential visual info.
1326
+ - No auto‑playing audio. Auto‑playing video must be muted and pausable; provide controls.
1327
+
1328
+ **3.7 Tables & Data**
1329
+
1330
+ - Use \`<th scope>\` for headers; captions via \`<caption>\`; announce sorting via \`aria-sort\`.
1331
+ - Provide CSV/JSON export where charts are primary.
1332
+
1333
+ **3.8 Performance & Robustness**
1334
+
1335
+ - Avoid content shifts that move focus; reserve space or use skeletons.
1336
+ - Maintain accessible names through hydration/SSR; avoid \`dangerouslySetInnerHTML\` where possible.
1337
+
1338
+ **3.9 Next.js specifics**
1339
+
1340
+ - Use \`next/link\` for navigation; ensure links are **links**, not buttons.
1341
+ - \`next/image\` must include **alt** (empty if decorative).
1342
+ - Announce route changes with a **global live region** and shift focus to the new view.
1343
+
1344
+ **3.10 Accessibility library integration**
1345
+
1346
+ - Import \`@contractspec/lib.accessibility\` at app root. It auto-imports its \`styles.css\` via the package entry; ensure bundlers keep CSS side effects. If your app tree-shakes CSS, explicitly import the stylesheet once in your root layout:
1347
+
1348
+ \`\`\`tsx
1349
+ // app/layout.tsx
1350
+ import '@contractspec/lib.accessibility'; // includes tokens and provider exports
1351
+ // or if needed: import '@contractspec/lib.accessibility/src/styles.css';
1352
+ \`\`\`
1353
+
1354
+ - Wrap the app with \`AccessibilityProvider\` and include an element with \`id="main"\` for the skip link target.
1355
+
1356
+ ---
1357
+
1358
+ ## 3b) lssm/ui-kit-web — Component Patterns & Defaults
1359
+
1360
+ > Source: \`packages/lssm/libs/ui-kit-web/ui/*\`
1361
+
1362
+ - **Button/Input/Textarea**: Built‑in \`focus-visible\` rings; ensure visible labels via \`FormLabel\` or \`aria-label\`.
1363
+ - **Form** (\`form.tsx\`): \`FormControl\` wires \`aria-invalid\` and \`aria-describedby\` to \`FormMessage\` and \`FormDescription\`. Prefer \`FormMessage\` for inline errors. Add \`role="alert"\` only for critical.
1364
+ - **Dialog/Sheet/Dropdown**: Use Radix wrappers for focus‑trap and return‑focus. Provide \`DialogTitle\` + \`DialogDescription\` for name/description.
1365
+ - **Select/Combobox**: Prefer \`SelectTrigger\` with visible label; for icon‑only triggers, supply \`aria-label\`. Document examples in each app.
1366
+ - **Tabs**: Use \`TabsList\`, \`TabsTrigger\`, \`TabsContent\`; names are programmatically determinable.
1367
+ - **Toast/Toaster**: Prefer non‑blocking announcements; map critical to assertive region; include action buttons with clear labels.
1368
+ - **Table**: Use \`TableCaption\`; ensure \`TableHead\` cells use proper \`scope\`. Provide \`aria-sort\` on sortable headers.
1369
+ - **Utilities to add (repo action)**:
1370
+ - \`SkipLink\` component and pattern in layouts.
1371
+ - \`RouteAnnouncer\` (\`aria-live="polite"\`) and **FocusOnRouteChange** helper.
1372
+ - \`VisuallyHidden\` wrapper (Radix visually-hidden or minimal utility).
1373
+ - \`useReducedMotion\` helper; honor in animated components.
1374
+ - Touch‑size variants (≥44×44) for interactive atoms.
1375
+
1376
+ ---
1377
+
1378
+ ## 4) Engineering Requirements (Mobile — Expo/React Native)
1379
+
1380
+ - Set \`accessibilityLabel\`, \`accessibilityHint\`, and \`accessibilityRole\` on touchables.
1381
+ - Ensure **hit slop** / min size **≥ 44×44 dp**.
1382
+ - Support Dynamic Type / font scaling; no clipped text at **200%**.
1383
+ - Respect **Invert Colors** and **Reduce Motion**; avoid flashing.
1384
+ - Group related items with \`accessibilityElements\` ordering; hide decoration with \`accessible={false}\` or \`importantForAccessibility="no-hide-descendants"\` when appropriate.
1385
+ - Test with **VoiceOver (iOS)** and **TalkBack (Android)**.
1386
+
1387
+ ---
1388
+
1389
+ ## 5) Component Patterns (Acceptance Rules)
1390
+
1391
+ **Buttons & Links**
1392
+
1393
+ - Use \`<button>\` for actions, \`<a href>\` for navigation. Provide disabled states that are perceivable beyond color.
1394
+
1395
+ **Navigation**
1396
+
1397
+ - Provide **Skip link**. One primary nav landmark. Indicate current page (\`aria-current="page"\`).
1398
+
1399
+ **Menus/Combobox/Autocomplete**
1400
+
1401
+ - Follow ARIA patterns: focus moves into list; \`aria-expanded\`, \`aria-controls\`, \`aria-activedescendant\` when applicable; Esc closes; typing filters.
1402
+
1403
+ **Modals/Dialogs**
1404
+
1405
+ - \`role="dialog"\` or \`alertdialog\` with **label**; focus trapped; background inert; Esc closes; return focus to trigger.
1406
+
1407
+ **Tabs**
1408
+
1409
+ - \`role="tablist"\`; tabs are in the tab order; arrow keys switch focus; content is \`role="tabpanel"\` with \`aria-labelledby\`.
1410
+
1411
+ **Toasts/Notifications**
1412
+
1413
+ - Non-critical: \`aria-live="polite"\`; critical: \`role="alert"\` sparingly.
1414
+
1415
+ **Infinite Scroll / “Load More”**
1416
+
1417
+ - Provide **Load more** control; announce new content to SR; preserve keyboard position.
1418
+
1419
+ **Drag & Drop (2.5.7)**
1420
+
1421
+ - Provide **non‑drag** alternative (e.g., move up/down buttons).
1422
+
1423
+ **Charts & Maps**
1424
+
1425
+ - Provide **table alternative** or textual summary; keyboard access to datapoints where interactive.
1426
+
1427
+ ---
1428
+
1429
+ ## 6) Testing & CI (Blocking Gates)
1430
+
1431
+ **Static & Unit**
1432
+
1433
+ - \`eslint-plugin-jsx-a11y\` — error on violations.
1434
+ - \`jest-axe\` — unit tests for components.
1435
+
1436
+ **Automated Integration**
1437
+
1438
+ - \`axe-core\` via Playwright or Cypress on critical flows.
1439
+ - \`pa11y-ci\` on key routes; threshold: **0 Critical / 0 Serious** to merge.
1440
+ - Lighthouse CI a11y score **≥ 95** on target pages.
1441
+
1442
+ **Manual QA (per release)**
1443
+
1444
+ - **Keyboard patrol:** navigate primary flows without mouse.
1445
+ - **Screen reader smoke:** NVDA (Windows) or VoiceOver (macOS/iOS) across login, navigation, forms, dialogs.
1446
+ - **Zoom & Reflow:** 200–400% & 320 px width.
1447
+ - **Color/Contrast check:** tokens in both themes.
1448
+
1449
+ **Reporting**
1450
+
1451
+ - A11y issues labeled: \`a11y-blocker\`, \`a11y-bug\`, \`a11y-enhancement\` with WCAG ref.
1452
+
1453
+ ---
1454
+
1455
+ ## 7) Repository‑Specific Adoption Plan
1456
+
1457
+ - Centralize UI usage on \`packages/lssm/libs/ui-kit-web\` and de‑duplicate per‑app \`components/ui\` where feasible.
1458
+ - Introduce \`SkipLink\`, \`RouteAnnouncer\`, \`FocusOnRouteChange\`, and \`VisuallyHidden\` in \`ui-kit-web\`. Adopt in app layouts (\`app/layout.tsx\`) first.
1459
+ - Add \`useReducedMotion\` and wire into animated components (e.g., \`drawer\`, \`tooltip\`, \`carousel\`).
1460
+ - Add touch‑size variants to \`Button\`, \`IconButton\`, \`TabsTrigger\`, toggles.
1461
+ - Document Select label patterns and error association in Forms.
1462
+
1463
+ ---
1464
+
1465
+ ## 8) Code Snippets
1466
+
1467
+ **Skip Link**
1468
+
1469
+ \`\`\`html
1470
+ <a
1471
+ class="sr-only focus:not-sr-only focus-visible:outline focus-visible:ring-4 focus-visible:ring-offset-2"
1472
+ href="#main"
1473
+ >Skip to main content</a
1474
+ >
1475
+ <main id="main">…</main>
1476
+ \`\`\`
1477
+
1478
+ **Dialog (Radix + shadcn/ui) — essentials**
1479
+
1480
+ \`\`\`tsx
1481
+ // Ensure label, description, focus trap, and return focus on close remain intact
1482
+ <Dialog>
1483
+ <DialogTrigger asChild>
1484
+ <button aria-haspopup="dialog">Open settings</button>
1485
+ </DialogTrigger>
1486
+ <DialogContent aria-describedby="settings-desc">
1487
+ <DialogTitle>Settings</DialogTitle>
1488
+ <p id="settings-desc">Update your preferences.</p>
1489
+ <DialogClose asChild>
1490
+ <button>Close</button>
1491
+ </DialogClose>
1492
+ </DialogContent>
1493
+ </Dialog>
1494
+ \`\`\`
1495
+
1496
+ **Form error association**
1497
+
1498
+ \`\`\`tsx
1499
+ <label htmlFor="email">Email</label>
1500
+ <input id="email" name="email" type="email" aria-describedby="email-err" />
1501
+ <p id="email-err" role="alert">Enter a valid email.</p>
1502
+ \`\`\`
1503
+
1504
+ **Route change announcement (Next.js)**
1505
+
1506
+ \`\`\`tsx
1507
+ // Add once at app root
1508
+ <div
1509
+ aria-live="polite"
1510
+ aria-atomic="true"
1511
+ id="route-announcer"
1512
+ className="sr-only"
1513
+ />
1514
+ \`\`\`
1515
+
1516
+ ---
1517
+
1518
+ ## 9) Exceptions & Waivers
1519
+
1520
+ - If a criterion cannot be met, file an issue with: context, attempted alternatives, WCAG reference, impact assessment, and a remediation date. **Temporary waivers only.**
1521
+
1522
+ ---
1523
+
1524
+ ## 10) Ownership
1525
+
1526
+ - **Design:** maintains token contrast, component specs.
1527
+ - **Engineering:** enforces CI gates, implements patterns.
1528
+ - **QA:** runs manual checks per release.
1529
+ - **PM:** blocks release if AA not met on user‑visible flows.
1530
+
1531
+ ---
1532
+
1533
+ ## 11) References (internalize; no external dependency at runtime)
1534
+
1535
+ - WCAG 2.2 (AA), EN 301 549. ARIA Authoring Practices. Platform HIG (Apple, Material).
1536
+ - \`packages/lssm/libs/ui-kit-web\` as the canonical UI source for web.
1537
+
1538
+ > **Bottom line:** Shipping means **accessible by default**. We don’t trade a11y for speed; we bake it into speed.
1539
+
1540
+ ---
1541
+
1542
+ ## 12) Adoption Status (2025-09-23)
1543
+
1544
+ - web-artisan: AccessibilityProvider integrated; sr-only/forced-colors applied; 44x44 targets; forms announce errors; jest-axe and cypress-axe in place.
1545
+ - web-strit: AccessibilityProvider integrated; forced-colors, sr-only; forms announce errors; 44x44 targets; contrast tokens and text-scale wired; jest-axe and cypress-axe in place.
1546
+ - web-coliving: AccessibilityProvider integrated; forced-colors and focus visibility added; text-scale wired; landing pages converted to \`Section\`/stacks with text-lg defaults; CTA capture standardized; ESLint guard for text-xs in main content; jest-axe and cypress-axe in place. Next: audit icon-only controls and ensure 44x44 targets; add role="alert" where critical.
1547
+
1548
+ > CI gates: run eslint a11y, jest-axe on components, and cypress-axe on critical flows per app.
1549
+
1550
+ ---
1551
+
1552
+ ## 13) CI Hardening & Visual QA
1553
+
1554
+ - Linting: Run eslint with jsx-a11y rules across all web apps; block on violations.
1555
+ - Unit: Run jest-axe for ui-kit-web and app-level components.
1556
+ - Integration: cypress-axe on key flows (auth, forms, dialogs, tables).
1557
+ - Synthetic scans: pa11y-ci on critical pages (0 Critical/Serious policy).
1558
+ - Performance/A11y audit: Lighthouse CI with a11y score >= 95 on target routes.
1559
+ - Artifacts: Upload pa11y and Lighthouse reports per PR; annotate failures.
1560
+
1561
+ ### Recent additions (2025-09-26)
1562
+
1563
+ - AutocompleteInput (groceries): Upgraded to ARIA combobox pattern with \`aria-controls\`, \`aria-activedescendant\`, \`Escape\`/\`Tab\` handling, and labelled listbox.
1564
+ - Cypress a11y tests added for furniture and incidents modules on \`/modules\` and operators flows; checks run axe with critical/serious impacts.
1565
+
1566
+ ## 14) Accessibility Telemetry (PostHog)
1567
+
1568
+ - Events (anonymized): a11y_pref_changed (text_scale, contrast_mode, reduce_motion), a11y_panel_opened.
1569
+ - Properties: app, route, previous_value, new_value, timestamp.
1570
+ - Dashboards: Adoption over time, per app/route; correlation with reduced bounce on forms.
1571
+ - Privacy: No PII; aggregate only.
1572
+ `
1573
+ }
1574
+ ];
1575
+ registerDocBlocks(accessibility_wcag_compliance_specs_DocBlocks);
1576
+
1577
+ // src/docs/constants.ts
1578
+ var DOCS_DOMAIN = "docs";
1579
+ var DOCS_OWNERS = ["docs-platform"];
1580
+ var DOCS_TAGS = ["docs", "documentation"];
1581
+ var DOCS_STABILITY = StabilityEnum.Experimental;
1582
+
1583
+ // src/docs/capabilities/documentationSystem.capability.ts
1584
+ var DocumentationSystemCapability = defineCapability({
1585
+ meta: {
1586
+ key: "docs.system",
1587
+ version: "1.0.0",
1588
+ kind: "ui",
1589
+ title: "Documentation System",
1590
+ description: "End-to-end docs generation, indexing, and presentation.",
1591
+ domain: DOCS_DOMAIN,
1592
+ owners: DOCS_OWNERS,
1593
+ tags: [...DOCS_TAGS, "system"],
1594
+ stability: DOCS_STABILITY
1595
+ },
1596
+ provides: [
1597
+ {
1598
+ surface: "operation",
1599
+ key: "docs.generate",
1600
+ version: "1.0.0",
1601
+ description: "Generate documentation artifacts."
1602
+ },
1603
+ {
1604
+ surface: "operation",
1605
+ key: "docs.publish",
1606
+ version: "1.0.0",
1607
+ description: "Publish documentation artifacts."
1608
+ },
1609
+ {
1610
+ surface: "operation",
1611
+ key: "docs.search",
1612
+ version: "1.0.0",
1613
+ description: "Index and search DocBlocks."
1614
+ },
1615
+ {
1616
+ surface: "operation",
1617
+ key: "docs.contract.reference",
1618
+ version: "1.0.0",
1619
+ description: "Resolve contract references for docs."
1620
+ },
1621
+ {
1622
+ surface: "event",
1623
+ key: "docs.generated",
1624
+ version: "1.0.0",
1625
+ description: "Docs generation completed."
1626
+ },
1627
+ {
1628
+ surface: "event",
1629
+ key: "docs.published",
1630
+ version: "1.0.0",
1631
+ description: "Docs publish completed."
1632
+ },
1633
+ {
1634
+ surface: "presentation",
1635
+ key: "docs.layout",
1636
+ version: "1.0.0",
1637
+ description: "Docs layout presentation."
1638
+ },
1639
+ {
1640
+ surface: "presentation",
1641
+ key: "docs.reference.page",
1642
+ version: "1.0.0",
1643
+ description: "Docs reference page presentation."
1644
+ }
1645
+ ]
1646
+ });
1647
+ // src/docs/tech/docs-system.docblock.ts
1648
+ var docsSystemDocBlocks = [
1649
+ {
1650
+ id: "docs.tech.docs-system",
1651
+ title: "Docs system overview",
1652
+ summary: "How ContractSpec generates, indexes, and presents documentation.",
1653
+ kind: "reference",
1654
+ visibility: "public",
1655
+ route: "/docs/tech/docs/system",
1656
+ tags: ["docs", "system", "contracts"],
1657
+ body: `# Docs system overview
1658
+
1659
+ ContractSpec treats documentation as a first-class output of your specs. The docs system combines:
1660
+
1661
+ - Contract operations and schemas
1662
+ - DocBlocks (goal/how/usage/reference)
1663
+ - Presentations for rendering
1664
+
1665
+ The result is a consistent docs surface across CLI, web, and MCP.
1666
+
1667
+ ## Key surfaces
1668
+
1669
+ - Generation: \`docs.generate\`
1670
+ - Index/search: \`docs.search\`
1671
+ - Contract reference: \`docs.contract.reference\`
1672
+ - Publish: \`docs.publish\`
1673
+ `
1674
+ },
1675
+ {
1676
+ id: "docs.tech.docs-generator",
1677
+ title: "Docs generator",
1678
+ summary: "Generate reference docs and metadata from ContractSpecs.",
1679
+ kind: "how",
1680
+ visibility: "public",
1681
+ route: "/docs/tech/docs/generator",
1682
+ tags: ["docs", "generator", "cli"],
1683
+ body: `# Docs generator
1684
+
1685
+ The generator produces documentation artifacts from registered ContractSpecs and DocBlocks.
1686
+
1687
+ ## Outputs
1688
+
1689
+ - Reference pages for operations, events, forms, data views, and presentations
1690
+ - Search index metadata (DocBlocks + routes)
1691
+ - Contract schemas rendered to markdown or JSON
1692
+ `
1693
+ },
1694
+ {
1695
+ id: "docs.tech.docs-search",
1696
+ title: "Docs index and search",
1697
+ summary: "Search DocBlocks by query, tag, kind, or visibility.",
1698
+ kind: "reference",
1699
+ visibility: "public",
1700
+ route: "/docs/tech/docs/search",
1701
+ tags: ["docs", "search"],
1702
+ body: `# Docs index and search
1703
+
1704
+ The docs index is the canonical list of DocBlocks exposed to UI and MCP surfaces.
1705
+
1706
+ ## Query
1707
+
1708
+ - Operation: \`docs.search\`
1709
+ - Filters: query, tag, kind, visibility
1710
+ `
1711
+ },
1712
+ {
1713
+ id: "docs.tech.docs-reference",
1714
+ title: "Contract reference pages",
1715
+ summary: "Resolve any spec into a docs-ready reference payload.",
1716
+ kind: "reference",
1717
+ visibility: "public",
1718
+ route: "/docs/tech/docs/reference",
1719
+ tags: ["docs", "reference"],
1720
+ body: `# Contract reference
1721
+
1722
+ Contract reference pages are generated from spec metadata plus schema details.
1723
+
1724
+ ## Query
1725
+
1726
+ - Operation: \`docs.contract.reference\`
1727
+ `
1728
+ },
1729
+ {
1730
+ id: "docs.tech.docs-publish",
1731
+ title: "Docs publish",
1732
+ summary: "Publish generated artifacts to the docs host.",
1733
+ kind: "how",
1734
+ visibility: "public",
1735
+ route: "/docs/tech/docs/publish",
1736
+ tags: ["docs", "publish"],
1737
+ body: `# Docs publish
1738
+
1739
+ Publishing moves generated artifacts to a hosting target with versioning.
1740
+
1741
+ ## Command
1742
+
1743
+ - Operation: \`docs.publish\`
1744
+ `
1745
+ },
1746
+ {
1747
+ id: "docs.tech.docs-examples",
1748
+ title: "Examples catalog",
1749
+ summary: "Document and surface example projects with sandbox support.",
1750
+ kind: "reference",
1751
+ visibility: "public",
1752
+ route: "/docs/tech/docs/examples",
1753
+ tags: ["docs", "examples"],
1754
+ body: `# Examples catalog
1755
+
1756
+ Examples are registered as ExampleSpecs and surface DocBlocks for discovery.
1757
+
1758
+ - Docs index tags should include \`examples\` to populate the catalog.
1759
+ - Sandbox support is available under \`/sandbox\`.
1760
+ `
1761
+ }
1762
+ ];
1763
+ registerDocBlocks(docsSystemDocBlocks);
1764
+ // src/docs/events/docsGenerated.event.ts
1765
+ import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
1766
+ var DocsGeneratedPayload = new SchemaModel({
1767
+ name: "DocsGeneratedPayload",
1768
+ fields: {
1769
+ buildId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
1770
+ version: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
1771
+ generatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
1772
+ outputDir: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
1773
+ artifactCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
1774
+ warnings: {
1775
+ type: ScalarTypeEnum.String_unsecure(),
1776
+ isOptional: true,
1777
+ isArray: true
1778
+ }
1779
+ }
1780
+ });
1781
+ var DocsGeneratedEvent = defineEvent({
1782
+ meta: {
1783
+ key: "docs.generated",
1784
+ version: "1.0.0",
1785
+ description: "Emitted when documentation artifacts are generated.",
1786
+ domain: DOCS_DOMAIN,
1787
+ owners: DOCS_OWNERS,
1788
+ tags: [...DOCS_TAGS, "generation"],
1789
+ stability: DOCS_STABILITY,
1790
+ docId: [docId("docs.tech.docs-generator")]
1791
+ },
1792
+ payload: DocsGeneratedPayload
1793
+ });
1794
+
1795
+ // src/docs/commands/docsGenerate.command.ts
1796
+ import { ScalarTypeEnum as ScalarTypeEnum2, SchemaModel as SchemaModel2 } from "@contractspec/lib.schema";
1797
+ var DocsArtifactModel = new SchemaModel2({
1798
+ name: "DocsArtifact",
1799
+ fields: {
1800
+ path: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
1801
+ format: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1802
+ bytes: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
1803
+ kind: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
1804
+ }
1805
+ });
1806
+ var DocsGenerateInput = new SchemaModel2({
1807
+ name: "DocsGenerateInput",
1808
+ fields: {
1809
+ workspaceRoot: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1810
+ outputDir: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1811
+ version: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1812
+ formats: {
1813
+ type: ScalarTypeEnum2.String_unsecure(),
1814
+ isOptional: true,
1815
+ isArray: true
1816
+ },
1817
+ includeInternal: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
1818
+ includeExperimental: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
1819
+ contractFilter: {
1820
+ type: ScalarTypeEnum2.String_unsecure(),
1821
+ isOptional: true
1822
+ },
1823
+ docblockFilter: {
1824
+ type: ScalarTypeEnum2.String_unsecure(),
1825
+ isOptional: true
1826
+ },
1827
+ dryRun: { type: ScalarTypeEnum2.Boolean(), isOptional: true }
1828
+ }
1829
+ });
1830
+ var DocsGenerateOutput = new SchemaModel2({
1831
+ name: "DocsGenerateOutput",
1832
+ fields: {
1833
+ buildId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
1834
+ version: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1835
+ generatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
1836
+ outputDir: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1837
+ artifacts: { type: DocsArtifactModel, isOptional: true, isArray: true },
1838
+ warnings: {
1839
+ type: ScalarTypeEnum2.String_unsecure(),
1840
+ isOptional: true,
1841
+ isArray: true
1842
+ }
1843
+ }
1844
+ });
1845
+ var DocsGenerateCommand = defineCommand({
1846
+ meta: {
1847
+ key: "docs.generate",
1848
+ title: "Generate Documentation",
1849
+ version: "1.0.0",
1850
+ description: "Generate documentation artifacts from ContractSpecs.",
1851
+ goal: "Produce up-to-date reference docs and guides from specs and DocBlocks.",
1852
+ context: "Used by CLI and CI to keep docs in sync with contract definitions.",
1853
+ domain: DOCS_DOMAIN,
1854
+ owners: DOCS_OWNERS,
1855
+ tags: [...DOCS_TAGS, "generation"],
1856
+ stability: DOCS_STABILITY,
1857
+ docId: [docId("docs.tech.docs-generator")]
1858
+ },
1859
+ capability: {
1860
+ key: "docs.system",
1861
+ version: "1.0.0"
1862
+ },
1863
+ io: {
1864
+ input: DocsGenerateInput,
1865
+ output: DocsGenerateOutput,
1866
+ errors: {
1867
+ OUTPUT_WRITE_FAILED: {
1868
+ description: "Failed to write generated docs output.",
1869
+ http: 500,
1870
+ when: "The generator cannot persist artifacts to the output path."
1871
+ }
1872
+ }
1873
+ },
1874
+ policy: {
1875
+ auth: "admin",
1876
+ pii: []
1877
+ },
1878
+ sideEffects: {
1879
+ emits: [
1880
+ {
1881
+ ref: DocsGeneratedEvent.meta,
1882
+ when: "Docs generation completes successfully."
1883
+ }
1884
+ ]
1885
+ }
1886
+ });
1887
+
1888
+ // src/docs/events/docsPublished.event.ts
1889
+ import { SchemaModel as SchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
1890
+ var DocsPublishedPayload = new SchemaModel3({
1891
+ name: "DocsPublishedPayload",
1892
+ fields: {
1893
+ publishId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1894
+ version: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1895
+ environment: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1896
+ url: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1897
+ publishedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false },
1898
+ status: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1899
+ warnings: {
1900
+ type: ScalarTypeEnum3.String_unsecure(),
1901
+ isOptional: true,
1902
+ isArray: true
1903
+ }
1904
+ }
1905
+ });
1906
+ var DocsPublishedEvent = defineEvent({
1907
+ meta: {
1908
+ key: "docs.published",
1909
+ version: "1.0.0",
1910
+ description: "Emitted when documentation is published.",
1911
+ domain: DOCS_DOMAIN,
1912
+ owners: DOCS_OWNERS,
1913
+ tags: [...DOCS_TAGS, "publish"],
1914
+ stability: DOCS_STABILITY,
1915
+ docId: [docId("docs.tech.docs-publish")]
1916
+ },
1917
+ payload: DocsPublishedPayload
1918
+ });
1919
+
1920
+ // src/docs/commands/docsPublish.command.ts
1921
+ import { ScalarTypeEnum as ScalarTypeEnum4, SchemaModel as SchemaModel4 } from "@contractspec/lib.schema";
1922
+ var DocsPublishInput = new SchemaModel4({
1923
+ name: "DocsPublishInput",
1924
+ fields: {
1925
+ buildId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
1926
+ version: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
1927
+ environment: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
1928
+ deployTarget: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
1929
+ artifactPath: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
1930
+ dryRun: { type: ScalarTypeEnum4.Boolean(), isOptional: true },
1931
+ notes: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true }
1932
+ }
1933
+ });
1934
+ var DocsPublishOutput = new SchemaModel4({
1935
+ name: "DocsPublishOutput",
1936
+ fields: {
1937
+ publishId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
1938
+ publishedAt: { type: ScalarTypeEnum4.DateTime(), isOptional: false },
1939
+ url: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
1940
+ status: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
1941
+ warnings: {
1942
+ type: ScalarTypeEnum4.String_unsecure(),
1943
+ isOptional: true,
1944
+ isArray: true
1945
+ }
1946
+ }
1947
+ });
1948
+ var DocsPublishCommand = defineCommand({
1949
+ meta: {
1950
+ key: "docs.publish",
1951
+ title: "Publish Documentation",
1952
+ version: "1.0.0",
1953
+ description: "Publish generated documentation artifacts.",
1954
+ goal: "Deploy docs to the public docs surface with consistent versioning.",
1955
+ context: "Used by release pipelines to push generated docs to hosting targets.",
1956
+ domain: DOCS_DOMAIN,
1957
+ owners: DOCS_OWNERS,
1958
+ tags: [...DOCS_TAGS, "publish"],
1959
+ stability: DOCS_STABILITY,
1960
+ docId: [docId("docs.tech.docs-publish")]
1961
+ },
1962
+ capability: {
1963
+ key: "docs.system",
1964
+ version: "1.0.0"
1965
+ },
1966
+ io: {
1967
+ input: DocsPublishInput,
1968
+ output: DocsPublishOutput,
1969
+ errors: {
1970
+ DEPLOY_FAILED: {
1971
+ description: "Failed to deploy documentation artifacts.",
1972
+ http: 500,
1973
+ when: "The docs publish step fails to deploy to the target host."
1974
+ }
1975
+ }
1976
+ },
1977
+ policy: {
1978
+ auth: "admin",
1979
+ pii: []
1980
+ },
1981
+ sideEffects: {
1982
+ emits: [
1983
+ {
1984
+ ref: DocsPublishedEvent.meta,
1985
+ when: "Docs publish completes successfully."
1986
+ }
1987
+ ]
1988
+ }
1989
+ });
1990
+ // src/docs/queries/docsIndex.query.ts
1991
+ import { ScalarTypeEnum as ScalarTypeEnum5, SchemaModel as SchemaModel5 } from "@contractspec/lib.schema";
1992
+ var DocSummaryModel = new SchemaModel5({
1993
+ name: "DocSummary",
1994
+ fields: {
1995
+ id: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
1996
+ title: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
1997
+ summary: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
1998
+ route: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
1999
+ visibility: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
2000
+ kind: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
2001
+ version: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
2002
+ tags: {
2003
+ type: ScalarTypeEnum5.String_unsecure(),
2004
+ isOptional: true,
2005
+ isArray: true
2006
+ }
2007
+ }
2008
+ });
2009
+ var DocsIndexInput = new SchemaModel5({
2010
+ name: "DocsIndexInput",
2011
+ fields: {
2012
+ query: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
2013
+ tag: {
2014
+ type: ScalarTypeEnum5.String_unsecure(),
2015
+ isOptional: true,
2016
+ isArray: true
2017
+ },
2018
+ visibility: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
2019
+ kind: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
2020
+ limit: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: true },
2021
+ offset: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: true }
2022
+ }
2023
+ });
2024
+ var DocsIndexOutput = new SchemaModel5({
2025
+ name: "DocsIndexOutput",
2026
+ fields: {
2027
+ items: { type: DocSummaryModel, isOptional: true, isArray: true },
2028
+ docs: { type: DocSummaryModel, isOptional: false, isArray: true },
2029
+ total: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: true },
2030
+ nextOffset: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: true }
2031
+ }
2032
+ });
2033
+ var DocsIndexQuery = defineQuery({
2034
+ meta: {
2035
+ key: "docs.search",
2036
+ title: "Docs Index",
2037
+ version: "1.0.0",
2038
+ description: "Search and filter DocBlocks by query, tag, or visibility.",
2039
+ goal: "Provide a consistent index of documentation entries for UI and MCP.",
2040
+ context: "Used by docs surfaces to list and filter DocBlocks without coupling to storage.",
2041
+ domain: DOCS_DOMAIN,
2042
+ owners: DOCS_OWNERS,
2043
+ tags: [...DOCS_TAGS, "search", "index"],
2044
+ stability: DOCS_STABILITY,
2045
+ docId: [docId("docs.tech.docs-search")]
2046
+ },
2047
+ capability: {
2048
+ key: "docs.system",
2049
+ version: "1.0.0"
2050
+ },
2051
+ io: {
2052
+ input: DocsIndexInput,
2053
+ output: DocsIndexOutput
2054
+ },
2055
+ policy: {
2056
+ auth: "anonymous",
2057
+ pii: []
2058
+ }
2059
+ });
2060
+
2061
+ // src/docs/queries/contractReference.query.ts
2062
+ import { ScalarTypeEnum as ScalarTypeEnum6, SchemaModel as SchemaModel6 } from "@contractspec/lib.schema";
2063
+ var ContractReferenceInput = new SchemaModel6({
2064
+ name: "ContractReferenceInput",
2065
+ fields: {
2066
+ key: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
2067
+ version: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
2068
+ type: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
2069
+ format: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
2070
+ includeSchema: { type: ScalarTypeEnum6.Boolean(), isOptional: true }
2071
+ }
2072
+ });
2073
+ var ContractReferenceModel = new SchemaModel6({
2074
+ name: "ContractReference",
2075
+ fields: {
2076
+ key: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
2077
+ version: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
2078
+ type: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
2079
+ title: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
2080
+ description: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
2081
+ markdown: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
2082
+ route: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
2083
+ schema: { type: ScalarTypeEnum6.JSONObject(), isOptional: true },
2084
+ policy: { type: ScalarTypeEnum6.JSONObject(), isOptional: true },
2085
+ tags: {
2086
+ type: ScalarTypeEnum6.String_unsecure(),
2087
+ isOptional: true,
2088
+ isArray: true
2089
+ },
2090
+ owners: {
2091
+ type: ScalarTypeEnum6.String_unsecure(),
2092
+ isOptional: true,
2093
+ isArray: true
2094
+ },
2095
+ stability: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true }
2096
+ }
2097
+ });
2098
+ var ContractReferenceOutput = new SchemaModel6({
2099
+ name: "ContractReferenceOutput",
2100
+ fields: {
2101
+ reference: { type: ContractReferenceModel, isOptional: false }
2102
+ }
2103
+ });
2104
+ var ContractReferenceQuery = defineQuery({
2105
+ meta: {
2106
+ key: "docs.contract.reference",
2107
+ title: "Contract Reference",
2108
+ version: "1.0.0",
2109
+ description: "Resolve a contract into a documentation-ready reference.",
2110
+ goal: "Expose a canonical reference view for any ContractSpec surface.",
2111
+ context: "Used by docs generators and UI to render consistent reference pages.",
2112
+ domain: DOCS_DOMAIN,
2113
+ owners: DOCS_OWNERS,
2114
+ tags: [...DOCS_TAGS, "reference"],
2115
+ stability: DOCS_STABILITY,
2116
+ docId: [docId("docs.tech.docs-reference")]
2117
+ },
2118
+ capability: {
2119
+ key: "docs.system",
2120
+ version: "1.0.0"
2121
+ },
2122
+ io: {
2123
+ input: ContractReferenceInput,
2124
+ output: ContractReferenceOutput
2125
+ },
2126
+ policy: {
2127
+ auth: "anonymous",
2128
+ pii: []
2129
+ }
2130
+ });
2131
+ // src/presentations/presentations.ts
2132
+ var definePresentation = (spec) => {
2133
+ return spec;
2134
+ };
2135
+
2136
+ // src/presentations/registry.ts
2137
+ class PresentationRegistry extends SpecContractRegistry {
2138
+ constructor(items) {
2139
+ super("presentation", items);
2140
+ }
2141
+ }
2142
+ // src/docs/presentations/docsLayout.presentation.ts
2143
+ var DocsLayoutPresentation = definePresentation({
2144
+ meta: {
2145
+ key: "docs.layout",
2146
+ title: "Docs Layout",
2147
+ version: "1.0.0",
2148
+ description: "Shared layout shell for documentation pages.",
2149
+ goal: "Provide consistent navigation, layout, and docs UI scaffolding.",
2150
+ context: "Used by web docs surfaces to render DocBlock-based content.",
2151
+ domain: DOCS_DOMAIN,
2152
+ owners: DOCS_OWNERS,
2153
+ tags: [...DOCS_TAGS, "layout"],
2154
+ stability: DOCS_STABILITY,
2155
+ docId: [docId("docs.tech.docs-system")]
2156
+ },
2157
+ capability: {
2158
+ key: "docs.system",
2159
+ version: "1.0.0"
2160
+ },
2161
+ source: {
2162
+ type: "component",
2163
+ framework: "react",
2164
+ componentKey: "docsLayout"
2165
+ },
2166
+ targets: ["react"]
2167
+ });
2168
+
2169
+ // src/docs/presentations/docsReferencePage.presentation.ts
2170
+ var DocsReferencePagePresentation = definePresentation({
2171
+ meta: {
2172
+ key: "docs.reference.page",
2173
+ title: "Docs Reference Page",
2174
+ version: "1.0.0",
2175
+ description: "Reference page layout for contract documentation.",
2176
+ goal: "Render contract references with consistent metadata and formatting.",
2177
+ context: "Used by docs surfaces to present contract reference content and schemas.",
2178
+ domain: DOCS_DOMAIN,
2179
+ owners: DOCS_OWNERS,
2180
+ tags: [...DOCS_TAGS, "reference"],
2181
+ stability: DOCS_STABILITY,
2182
+ docId: [docId("docs.tech.docs-reference")]
2183
+ },
2184
+ capability: {
2185
+ key: "docs.system",
2186
+ version: "1.0.0"
2187
+ },
2188
+ source: {
2189
+ type: "component",
2190
+ framework: "react",
2191
+ componentKey: "docsReferencePage"
2192
+ },
2193
+ targets: ["react", "markdown"]
2194
+ });
2195
+ // src/forms/forms.ts
2196
+ import { compareVersions as compareVersions3 } from "compare-versions";
2197
+ function formKey(meta) {
2198
+ return `${meta.key}.v${meta.version}`;
2199
+ }
2200
+
2201
+ class FormRegistry {
2202
+ items = new Map;
2203
+ register(spec) {
2204
+ const key = formKey(spec.meta);
2205
+ if (this.items.has(key))
2206
+ throw new Error(`Duplicate form ${key}`);
2207
+ this.items.set(key, spec);
2208
+ return this;
2209
+ }
2210
+ list() {
2211
+ return [...this.items.values()];
2212
+ }
2213
+ get(key, version) {
2214
+ if (version != null)
2215
+ return this.items.get(`${key}.v${version}`);
2216
+ let candidate;
2217
+ for (const [k, v] of this.items.entries()) {
2218
+ if (v.meta.key !== key)
2219
+ continue;
2220
+ if (!candidate || compareVersions3(v.meta.version, candidate.meta.version) > 0) {
2221
+ candidate = v;
2222
+ }
2223
+ }
2224
+ return candidate;
2225
+ }
2226
+ filter(criteria) {
2227
+ const { filterBy: filterBy2 } = (init_registry_utils(), __toCommonJS(exports_registry_utils));
2228
+ return filterBy2(this.list(), criteria);
2229
+ }
2230
+ listByTag(tag) {
2231
+ return this.list().filter((f) => f.meta.tags?.includes(tag));
2232
+ }
2233
+ listByOwner(owner) {
2234
+ return this.list().filter((f) => f.meta.owners?.includes(owner));
2235
+ }
2236
+ groupBy(keyFn) {
2237
+ const { groupBy: groupBy2 } = (init_registry_utils(), __toCommonJS(exports_registry_utils));
2238
+ return groupBy2(this.list(), keyFn);
2239
+ }
2240
+ getUniqueTags() {
2241
+ const { getUniqueTags: getUniqueTags2 } = (init_registry_utils(), __toCommonJS(exports_registry_utils));
2242
+ return getUniqueTags2(this.list());
2243
+ }
2244
+ }
2245
+ function getAtPath(values, path) {
2246
+ if (!path)
2247
+ return;
2248
+ const segs = path.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
2249
+ let cur = values;
2250
+ for (const s of segs) {
2251
+ if (cur == null)
2252
+ return;
2253
+ if (cur && typeof cur === "object" && s in cur) {
2254
+ cur = cur[s];
2255
+ } else {
2256
+ return;
2257
+ }
2258
+ }
2259
+ return cur;
2260
+ }
2261
+ function evalPredicate(values, pred) {
2262
+ if (!pred)
2263
+ return true;
2264
+ if (pred.not)
2265
+ return !evalPredicate(values, pred.not);
2266
+ if (pred.all && pred.all.length)
2267
+ return pred.all.every((p) => evalPredicate(values, p));
2268
+ if (pred.anyOf && pred.anyOf.length)
2269
+ return pred.anyOf.some((p) => evalPredicate(values, p));
2270
+ if (pred.when) {
2271
+ const { path, op = "truthy", value } = pred.when;
2272
+ const v = getAtPath(values, path);
2273
+ switch (op) {
2274
+ case "equals":
2275
+ return v === value;
2276
+ case "notEquals":
2277
+ return v !== value;
2278
+ case "in":
2279
+ return Array.isArray(value) && value.includes(v);
2280
+ case "notIn":
2281
+ return Array.isArray(value) && !value.includes(v);
2282
+ case "gt":
2283
+ return Number(v) > Number(value);
2284
+ case "gte":
2285
+ return Number(v) >= Number(value);
2286
+ case "lt":
2287
+ return Number(v) < Number(value);
2288
+ case "lte":
2289
+ return Number(v) <= Number(value);
2290
+ case "empty":
2291
+ return v == null || (Array.isArray(v) ? v.length === 0 : String(v).length === 0);
2292
+ case "lengthGt":
2293
+ return (Array.isArray(v) || typeof v === "string") && v.length > Number(value ?? 0);
2294
+ case "lengthGte":
2295
+ return (Array.isArray(v) || typeof v === "string") && v.length >= Number(value ?? 0);
2296
+ case "lengthLt":
2297
+ return (Array.isArray(v) || typeof v === "string") && v.length < Number(value ?? 0);
2298
+ case "lengthLte":
2299
+ return (Array.isArray(v) || typeof v === "string") && v.length <= Number(value ?? 0);
2300
+ case "truthy":
2301
+ default:
2302
+ return Boolean(v);
2303
+ }
2304
+ }
2305
+ return true;
2306
+ }
2307
+ function buildZodWithRelations(spec, handlers) {
2308
+ const base = spec.model.getZod();
2309
+ return base.superRefine((values, ctx) => {
2310
+ const visit = (field, parentPath) => {
2311
+ const path = field.name ? parentPath ? `${parentPath}.${field.name}` : field.name : parentPath ?? "";
2312
+ if (field.requiredWhen) {
2313
+ const should = evalPredicate(values, field.requiredWhen);
2314
+ if (should) {
2315
+ const v = getAtPath(values, path);
2316
+ const empty = v == null || typeof v === "string" && v.trim().length === 0 || Array.isArray(v) && v.length === 0;
2317
+ if (empty)
2318
+ ctx.addIssue({
2319
+ code: "custom",
2320
+ path: path.split("."),
2321
+ message: "required"
2322
+ });
2323
+ }
2324
+ }
2325
+ if (field.kind === "array") {
2326
+ const arr = getAtPath(values, path);
2327
+ if (field.min != null && Array.isArray(arr) && arr.length < field.min) {
2328
+ ctx.addIssue({
2329
+ code: "custom",
2330
+ path: path.split("."),
2331
+ message: `min:${field.min}`
2332
+ });
2333
+ }
2334
+ if (field.max != null && Array.isArray(arr) && arr.length > field.max) {
2335
+ ctx.addIssue({
2336
+ code: "custom",
2337
+ path: path.split("."),
2338
+ message: `max:${field.max}`
2339
+ });
2340
+ }
2341
+ visit(field.of, path);
2342
+ } else if (field.kind === "group") {
2343
+ for (const child of field.fields)
2344
+ visit(child, path);
2345
+ }
2346
+ };
2347
+ for (const f of spec.fields)
2348
+ visit(f);
2349
+ if (spec.constraints && handlers) {
2350
+ for (const c of spec.constraints) {
2351
+ const fn = handlers[c.key];
2352
+ if (!fn)
2353
+ continue;
2354
+ const res = fn(values, c.paths, c.args);
2355
+ if (!res.ok) {
2356
+ ctx.addIssue({
2357
+ code: "custom",
2358
+ path: (res.path ?? c.paths[0] ?? "").split(".").filter(Boolean),
2359
+ message: res.message ?? c.messageI18n
2360
+ });
2361
+ }
2362
+ }
2363
+ }
2364
+ });
2365
+ }
2366
+ function defineFormSpec(spec) {
2367
+ return spec;
2368
+ }
2369
+
2370
+ // src/docs/forms/docsSearch.form.ts
2371
+ import { SchemaModel as SchemaModel7, ScalarTypeEnum as ScalarTypeEnum7 } from "@contractspec/lib.schema";
2372
+ var DocsSearchFormModel = new SchemaModel7({
2373
+ name: "DocsSearchFormModel",
2374
+ fields: {
2375
+ query: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
2376
+ visibility: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
2377
+ kind: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true }
2378
+ }
2379
+ });
2380
+ var DocsSearchForm = defineFormSpec({
2381
+ meta: {
2382
+ key: "docs.search.form",
2383
+ title: "Docs Search",
2384
+ version: "1.0.0",
2385
+ description: "Search form for documentation discovery.",
2386
+ domain: DOCS_DOMAIN,
2387
+ owners: DOCS_OWNERS,
2388
+ tags: [...DOCS_TAGS, "search"],
2389
+ stability: DOCS_STABILITY,
2390
+ docId: [docId("docs.tech.docs-search")]
2391
+ },
2392
+ model: DocsSearchFormModel,
2393
+ fields: [
2394
+ {
2395
+ kind: "text",
2396
+ name: "query",
2397
+ labelI18n: "Search",
2398
+ placeholderI18n: "Search docs"
2399
+ },
2400
+ {
2401
+ kind: "select",
2402
+ name: "visibility",
2403
+ labelI18n: "Visibility",
2404
+ options: {
2405
+ kind: "static",
2406
+ options: [
2407
+ { labelI18n: "Public", value: "public" },
2408
+ { labelI18n: "Internal", value: "internal" },
2409
+ { labelI18n: "Mixed", value: "mixed" }
2410
+ ]
2411
+ }
2412
+ },
2413
+ {
2414
+ kind: "select",
2415
+ name: "kind",
2416
+ labelI18n: "Kind",
2417
+ options: {
2418
+ kind: "static",
2419
+ options: [
2420
+ { labelI18n: "Goal", value: "goal" },
2421
+ { labelI18n: "How", value: "how" },
2422
+ { labelI18n: "Usage", value: "usage" },
2423
+ { labelI18n: "Reference", value: "reference" },
2424
+ { labelI18n: "FAQ", value: "faq" },
2425
+ { labelI18n: "Changelog", value: "changelog" }
2426
+ ]
2427
+ }
2428
+ }
2429
+ ],
2430
+ actions: [
2431
+ {
2432
+ key: "search",
2433
+ labelI18n: "Search"
2434
+ }
2435
+ ],
2436
+ policy: {
2437
+ flags: [],
2438
+ pii: []
2439
+ }
2440
+ });
2441
+ // src/docs/views/docsIndex.dataView.ts
2442
+ var DocsIndexDataView = defineDataView({
2443
+ meta: {
2444
+ key: "docs.index.view",
2445
+ title: "Docs Index",
2446
+ version: "1.0.0",
2447
+ description: "List and filter documentation entries.",
2448
+ domain: DOCS_DOMAIN,
2449
+ owners: DOCS_OWNERS,
2450
+ tags: [...DOCS_TAGS, "index"],
2451
+ stability: DOCS_STABILITY,
2452
+ entity: "docs",
2453
+ docId: [docId("docs.tech.docs-search")]
2454
+ },
2455
+ source: {
2456
+ primary: {
2457
+ key: DocsIndexQuery.meta.key,
2458
+ version: DocsIndexQuery.meta.version
2459
+ }
2460
+ },
2461
+ view: {
2462
+ kind: "list",
2463
+ fields: [
2464
+ { key: "id", label: "ID", dataPath: "id" },
2465
+ { key: "title", label: "Title", dataPath: "title" },
2466
+ { key: "summary", label: "Summary", dataPath: "summary" },
2467
+ { key: "route", label: "Route", dataPath: "route" },
2468
+ { key: "tags", label: "Tags", dataPath: "tags", format: "badge" },
2469
+ { key: "kind", label: "Kind", dataPath: "kind" },
2470
+ { key: "visibility", label: "Visibility", dataPath: "visibility" }
2471
+ ],
2472
+ primaryField: "title",
2473
+ secondaryFields: ["summary", "route"],
2474
+ filters: [
2475
+ { key: "query", label: "Search", field: "query", type: "search" },
2476
+ {
2477
+ key: "visibility",
2478
+ label: "Visibility",
2479
+ field: "visibility",
2480
+ type: "enum",
2481
+ options: [
2482
+ { value: "public", label: "Public" },
2483
+ { value: "internal", label: "Internal" },
2484
+ { value: "mixed", label: "Mixed" }
2485
+ ]
2486
+ },
2487
+ {
2488
+ key: "kind",
2489
+ label: "Kind",
2490
+ field: "kind",
2491
+ type: "enum",
2492
+ options: [
2493
+ { value: "goal", label: "Goal" },
2494
+ { value: "how", label: "How" },
2495
+ { value: "usage", label: "Usage" },
2496
+ { value: "reference", label: "Reference" },
2497
+ { value: "faq", label: "FAQ" },
2498
+ { value: "changelog", label: "Changelog" }
2499
+ ]
2500
+ }
2501
+ ]
2502
+ },
2503
+ policy: {
2504
+ flags: [],
2505
+ pii: []
2506
+ }
2507
+ });
2508
+
2509
+ // src/docs/views/contractReference.dataView.ts
2510
+ var ContractReferenceDataView = defineDataView({
2511
+ meta: {
2512
+ key: "docs.contract.reference.view",
2513
+ title: "Contract Reference",
2514
+ version: "1.0.0",
2515
+ description: "Detail view for a single contract reference.",
2516
+ domain: DOCS_DOMAIN,
2517
+ owners: DOCS_OWNERS,
2518
+ tags: [...DOCS_TAGS, "reference"],
2519
+ stability: DOCS_STABILITY,
2520
+ entity: "contract-reference",
2521
+ docId: [docId("docs.tech.docs-reference")]
2522
+ },
2523
+ source: {
2524
+ primary: {
2525
+ key: ContractReferenceQuery.meta.key,
2526
+ version: ContractReferenceQuery.meta.version
2527
+ }
2528
+ },
2529
+ view: {
2530
+ kind: "detail",
2531
+ fields: [
2532
+ {
2533
+ key: "key",
2534
+ label: "Key",
2535
+ dataPath: "reference.key"
2536
+ },
2537
+ {
2538
+ key: "version",
2539
+ label: "Version",
2540
+ dataPath: "reference.version"
2541
+ },
2542
+ {
2543
+ key: "type",
2544
+ label: "Type",
2545
+ dataPath: "reference.type"
2546
+ },
2547
+ {
2548
+ key: "title",
2549
+ label: "Title",
2550
+ dataPath: "reference.title"
2551
+ },
2552
+ {
2553
+ key: "description",
2554
+ label: "Description",
2555
+ dataPath: "reference.description",
2556
+ format: "markdown"
2557
+ },
2558
+ {
2559
+ key: "tags",
2560
+ label: "Tags",
2561
+ dataPath: "reference.tags"
2562
+ },
2563
+ {
2564
+ key: "owners",
2565
+ label: "Owners",
2566
+ dataPath: "reference.owners"
2567
+ },
2568
+ {
2569
+ key: "stability",
2570
+ label: "Stability",
2571
+ dataPath: "reference.stability"
2572
+ }
2573
+ ],
2574
+ primaryField: "title",
2575
+ secondaryFields: ["description"]
2576
+ },
2577
+ policy: {
2578
+ flags: [],
2579
+ pii: []
2580
+ }
2581
+ });
2582
+
2583
+ // src/docs/views/exampleCatalog.dataView.ts
2584
+ var ExampleCatalogDataView = defineDataView({
2585
+ meta: {
2586
+ key: "docs.examples.catalog.view",
2587
+ title: "Examples Catalog",
2588
+ version: "1.0.0",
2589
+ description: "Catalog view of ContractSpec examples and demos.",
2590
+ domain: DOCS_DOMAIN,
2591
+ owners: DOCS_OWNERS,
2592
+ tags: [...DOCS_TAGS, "examples"],
2593
+ stability: DOCS_STABILITY,
2594
+ entity: "docs-examples",
2595
+ docId: [docId("docs.tech.docs-examples")]
2596
+ },
2597
+ source: {
2598
+ primary: {
2599
+ key: DocsIndexQuery.meta.key,
2600
+ version: DocsIndexQuery.meta.version
2601
+ }
2602
+ },
2603
+ view: {
2604
+ kind: "grid",
2605
+ fields: [
2606
+ { key: "id", label: "ID", dataPath: "id" },
2607
+ { key: "title", label: "Title", dataPath: "title" },
2608
+ { key: "summary", label: "Summary", dataPath: "summary" },
2609
+ { key: "route", label: "Route", dataPath: "route" },
2610
+ { key: "tags", label: "Tags", dataPath: "tags", format: "badge" }
2611
+ ],
2612
+ primaryField: "title",
2613
+ secondaryFields: ["summary"],
2614
+ filters: [
2615
+ { key: "query", label: "Search", field: "query", type: "search" },
2616
+ {
2617
+ key: "tags",
2618
+ label: "Tags",
2619
+ field: "tag",
2620
+ type: "enum",
2621
+ options: [
2622
+ { value: "examples", label: "Examples" },
2623
+ { value: "templates", label: "Templates" },
2624
+ { value: "sandbox", label: "Sandbox" }
2625
+ ]
2626
+ }
2627
+ ]
2628
+ },
2629
+ policy: {
2630
+ flags: [],
2631
+ pii: []
2632
+ }
2633
+ });
2634
+ // src/docs/contracts.ts
2635
+ var docsOperationContracts = {
2636
+ DocsIndexQuery,
2637
+ ContractReferenceQuery,
2638
+ DocsGenerateCommand,
2639
+ DocsPublishCommand
2640
+ };
2641
+ var docsEventContracts = {
2642
+ DocsGeneratedEvent,
2643
+ DocsPublishedEvent
2644
+ };
2645
+ var docsPresentationContracts = {
2646
+ DocsLayoutPresentation,
2647
+ DocsReferencePagePresentation
2648
+ };
2649
+ var docsFormContracts = {
2650
+ DocsSearchForm
2651
+ };
2652
+ var docsDataViewContracts = {
2653
+ DocsIndexDataView,
2654
+ ContractReferenceDataView,
2655
+ ExampleCatalogDataView
2656
+ };
2657
+ function registerDocsOperations(registry3) {
2658
+ return registry3.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
2659
+ }
2660
+ function registerDocsEvents(registry3) {
2661
+ return registry3.register(DocsGeneratedEvent).register(DocsPublishedEvent);
2662
+ }
2663
+ function registerDocsPresentations(registry3) {
2664
+ return registry3.register(DocsLayoutPresentation).register(DocsReferencePagePresentation);
2665
+ }
2666
+ function registerDocsForms(registry3) {
2667
+ return registry3.register(DocsSearchForm);
2668
+ }
2669
+ function registerDocsDataViews(registry3) {
2670
+ return registry3.register(DocsIndexDataView).register(ContractReferenceDataView).register(ExampleCatalogDataView);
2671
+ }
2672
+ // src/docs/tech-contracts.docs.ts
2673
+ var techContractsDocs = [
2674
+ {
2675
+ id: "docs.tech.contracts.presentations",
2676
+ title: "Presentations — Unified Descriptor & Transform Engine",
2677
+ summary: "How PresentationSpec and TransformEngine keep docs/renderers consistent.",
2678
+ visibility: "public",
2679
+ route: "/docs/tech/contracts/presentations",
2680
+ kind: "reference",
2681
+ tags: ["presentations", "docs", "mcp"],
2682
+ body: `## Presentations V2 — Unified Descriptor & Transform Engine
2683
+
2684
+ ### Purpose
2685
+
2686
+ Unify presentations into one descriptor (\`PresentationSpec\`) that declares a single source (React component key or BlockNote doc) and a list of output targets (react, markdown, application/json, application/xml). A pluggable \`TransformEngine\` renders any target and applies PII redaction.
2687
+
2688
+ ### Types
2689
+
2690
+ \`\`\`ts
2691
+ type PresentationTarget =
2692
+ | 'react'
2693
+ | 'markdown'
2694
+ | 'application/json'
2695
+ | 'application/xml';
2696
+
2697
+ type PresentationSource =
2698
+ | {
2699
+ type: 'component';
2700
+ framework: 'react';
2701
+ componentKey: string;
2702
+ props?: AnySchemaModel;
2703
+ }
2704
+ | { type: 'blocknotejs'; docJson: unknown; blockConfig?: unknown };
2705
+
2706
+ interface PresentationSpec {
2707
+ meta: PresentationMeta; // includes partial OwnerShipMeta + description
2708
+ policy?: { flags?: string[]; pii?: string[] };
2709
+ source: PresentationSource;
2710
+ targets: PresentationTarget[];
2711
+ }
2712
+
2713
+ // Shared ownership schema (source of truth in @contractspec/lib.contracts-spec/src/ownership.ts)
2714
+ interface OwnerShipMeta {
2715
+ title: string;
2716
+ description: string;
2717
+ domain: string;
2718
+ owners: Owner[];
2719
+ tags: Tag[];
2720
+ stability: Stability;
2721
+ }
2722
+
2723
+ type Stability = 'experimental' | 'beta' | 'stable' | 'deprecated';
2724
+ type Owner = string; // curated list available in code (e.g., '@sigil-team', 'team-strit')
2725
+ type Tag = string; // curated list available in code (e.g., 'auth', 'spots')
2726
+
2727
+ // For presentations, meta is a Partial<OwnerShipMeta> plus description, name, version
2728
+ interface PresentationMeta extends Partial<OwnerShipMeta> {
2729
+ name: string;
2730
+ version: string;
2731
+ description?: string;
2732
+ }
2733
+ \`\`\`
2734
+
2735
+ ### Engine
2736
+
2737
+ Use \`createDefaultTransformEngine()\` and register custom renderers as needed (e.g., high-fidelity BlockNote → Markdown). The default engine supports markdown/json/xml; a React renderer returns a serializable descriptor the host app renders via a \`componentMap\` or a BlockNote renderer. The canonical source type string is \`blocknotejs\` (not \`blocknote\`).
2738
+
2739
+ PII paths (JSON-like) are redacted from rendered outputs.
2740
+
2741
+ ### MCP Integration
2742
+
2743
+ \`createMcpServer\` accepts \`presentationsV2\`. Each descriptor is exposed under \`presentation://<name>/v<version>\` and negotiated variants (\`.md/.json/.xml\`) are rendered by the engine.
2744
+
2745
+ ### Migration
2746
+
2747
+ - V1 \`PresentationSpec\` remains supported; a back-compat helper converts V1 → V2 when convenient.
2748
+ - Prefer V2 for new work.
2749
+
2750
+ ### Examples (Sigil)
2751
+
2752
+ - \`sigil.auth.webauth_tabs_v2\`: component source (\`componentKey: 'sigil.webauth.tabs'\`), targets \`react/json/xml\`.
2753
+ - \`sigil.signup.guide_v2\`: BlockNote doc source, targets \`react/markdown/json/xml\`.
2754
+
2755
+ ### React Rendering
2756
+
2757
+ Host apps use a \`componentMap\` (e.g., \`'sigil.webauth.tabs' → WebAuthTabs\`) and a BlockNote renderer to turn the React render descriptor into elements.`
2758
+ }
2759
+ ];
2760
+ registerDocBlocks(techContractsDocs);
2761
+
2762
+ // src/docs/meta.docs.ts
2763
+ var metaDocs = [
2764
+ {
2765
+ id: "docs.meta.docblocks-process",
2766
+ title: "DocBlocks process",
2767
+ summary: "How to author goal/how/usage DocBlocks close to code.",
2768
+ kind: "reference",
2769
+ visibility: "mixed",
2770
+ route: "/docs/meta/docblocks-process",
2771
+ tags: ["docs", "process"],
2772
+ body: `## DocBlocks authoring rules
2773
+
2774
+ - Colocate docs beside implementation; avoid barrel /docs folders.
2775
+ - Split intent:
2776
+ - **goal**: why this exists (before implementation).
2777
+ - **how**: operational/runbook steps.
2778
+ - **usage**: quick checklist for consumers.
2779
+ - Use \`visibility\`: public | internal | mixed.
2780
+ - Prefer routes like \`/docs/<domain>/<topic>/<kind>\`; ids mirror that.
2781
+ - Keep body Markdown LLM-friendly; avoid HTML.
2782
+ - Add owners/tags/domain/stability when known.
2783
+ - For presentations/markdown outputs, rely on TransformEngine via DocRegistry.
2784
+ - No sourcePath; DocBlocks are canonical.`
2785
+ }
2786
+ ];
2787
+ registerDocBlocks(metaDocs);
2788
+
2789
+ // src/docs/tech/lifecycle-stage-system.docblock.ts
2790
+ var tech_lifecycle_stage_system_DocBlocks = [
2791
+ {
2792
+ id: "docs.tech.lifecycle-stage-system",
2793
+ title: "ContractSpec Lifecycle Stage System – Technical Design",
2794
+ summary: "This document describes how ContractSpec implements lifecycle detection and guidance. It covers architecture, module boundaries, scoring heuristics, and integration points so libraries, modules, bundles, and Studio surfaces stay synchronized.",
2795
+ kind: "reference",
2796
+ visibility: "public",
2797
+ route: "/docs/tech/lifecycle-stage-system",
2798
+ tags: ["tech", "lifecycle-stage-system"],
2799
+ body: `## ContractSpec Lifecycle Stage System – Technical Design
2800
+
2801
+ This document describes how ContractSpec implements lifecycle detection and guidance. It covers architecture, module boundaries, scoring heuristics, and integration points so libraries, modules, bundles, and Studio surfaces stay synchronized.
2802
+
2803
+ ---
2804
+
2805
+ ### 1. Architecture Overview
2806
+
2807
+ \`\`\`
2808
+ ┌──────────────────────┐
2809
+ │ @contractspec/lib.lifecycle │ Types, enums, helpers (pure data)
2810
+ └───────────┬──────────┘
2811
+
2812
+ ┌───────────▼──────────┐ ┌───────────────────────────┐
2813
+ │ modules/lifecycle- │ │ modules/lifecycle-advisor │
2814
+ │ core (detection) │ │ (guidance & ceremonies) │
2815
+ └───────────┬──────────┘ └───────────┬───────────────┘
2816
+ │ │
2817
+ ├────────────┬──────────────┤
2818
+ ▼ ▼ ▼
2819
+ Adapters: analytics, intent, questionnaires
2820
+
2821
+ ┌───────────▼──────────┐
2822
+ │ bundles/lifecycle- │ Managed service for Studio
2823
+ │ managed │ (REST handlers, AI agent) │
2824
+ └───────────┬──────────┘
2825
+
2826
+ ContractSpec Studio surfaces
2827
+ (web/mobile APIs, CLI, docs)
2828
+ \`\`\`
2829
+
2830
+ - **Libraries** provide shared vocabulary.
2831
+ - **Modules** encapsulate logic, accepting adapters to avoid environment-specific code.
2832
+ - **Bundles** compose modules, register agents/events, and expose APIs for Studio.
2833
+ - **Apps** (web-landing, future Studio views) consume bundle APIs; they do not reimplement logic. For web-landing we now resolve \`@contractspec/bundle.studio\` and \`@contractspec/lib.database-studio\` directly from their \`packages/.../src\` folders via \`tsconfig\` path aliases so Prisma stays on the server build and Turbopack no longer pulls the prebundled \`dist\` artifacts into client chunks.
2834
+
2835
+ ---
2836
+
2837
+ ### 2. Core Library (\`@contractspec/lib.lifecycle\`)
2838
+
2839
+ - Stage enum (0–6) with metadata (\`question\`, \`signals\`, \`traps\`).
2840
+ - Axes types (\`ProductPhase\`, \`CompanyPhase\`, \`CapitalPhase\`).
2841
+ - \`LifecycleSignal\` (source, metric, value, timestamp).
2842
+ - \`LifecycleMetricSnapshot\` (aggregated numbers).
2843
+ - \`LifecycleMilestone\`, \`LifecycleAction\`, \`LifecycleAssessment\` interfaces.
2844
+ - Utility helpers:
2845
+ - \`formatStageSummary(stage, assessment)\`
2846
+ - \`rankStageCandidates(scores)\`
2847
+
2848
+ The library exports **no runtime dependencies** so it can be imported from apps, modules, and bundles alike.
2849
+
2850
+ ---
2851
+
2852
+ ### 3. Lifecycle Core Module
2853
+
2854
+ **Location:** \`packages/modules/lifecycle-core/\`
2855
+
2856
+ #### Components
2857
+ 1. **StageSignalCollector**
2858
+ - Accepts adapter interfaces:
2859
+ - \`AnalyticsAdapter\` (pulls metrics from \`@contractspec/lib.analytics\` or fixture streams).
2860
+ - \`IntentAdapter\` (hooks into \`@contractspec/lib.observability\` intent detectors or logs).
2861
+ - \`QuestionnaireAdapter\` (loads JSON questionnaires and responses).
2862
+ - Produces normalized \`LifecycleSignal[]\`.
2863
+
2864
+ 2. **StageScorer**
2865
+ - Weighted scoring model:
2866
+ - Base weight per stage (reflecting expected maturity).
2867
+ - Feature weights (retention, revenue, team size, qualitative feedback).
2868
+ - Confidence computed via variance of contributing signals.
2869
+ - Supports pluggable scoring matrices via JSON config.
2870
+ - Accepts sparse metric snapshots; the orchestrator sanitizes metrics to numeric-only records before persisting assessments so downstream analytics stay consistent.
2871
+
2872
+ 3. **LifecycleOrchestrator**
2873
+ - Coordinates collectors + scorer.
2874
+ - Returns \`LifecycleAssessment\` with:
2875
+ - \`stage\`, \`confidence\`, \`axisSnapshot\`, \`signalsUsed\`.
2876
+ - Recommended focus areas (high-level categories only).
2877
+ - Emits events (internally) when stage confidence crosses thresholds (consumed later by bundle).
2878
+
2879
+ 4. **LifecycleMilestonePlanner**
2880
+ - Loads \`milestones-catalog.json\` (no DB).
2881
+ - Filters upcoming milestones per stage + axis.
2882
+ - Tracks completion using provided IDs (caller persists).
2883
+
2884
+ #### Data Files
2885
+ - \`configs/stage-weights.json\`
2886
+ - \`configs/milestones-catalog.json\`
2887
+ - \`questionnaires/stage-readiness.json\`
2888
+
2889
+ #### Extension Hooks
2890
+ - All adapters exported as TypeScript interfaces.
2891
+ - Implementations for analytics/intent can live in bundles or apps without modifying module code.
2892
+
2893
+ ---
2894
+
2895
+ ### 4. Lifecycle Advisor Module
2896
+
2897
+ **Location:** \`packages/modules/lifecycle-advisor/\`
2898
+
2899
+ #### Components
2900
+ 1. **LifecycleRecommendationEngine**
2901
+ - Consumes \`LifecycleAssessment\`.
2902
+ - Maps gaps to \`LifecycleAction[]\` using rule tables (\`stage-playbooks.ts\`).
2903
+ - Supports override hooks for customer-specific rules.
2904
+
2905
+ 2. **ContractSpecLibraryRecommender**
2906
+ - Maintains mapping from stage → recommended libraries/modules/bundles.
2907
+ - Returns prioritized list with rationale and adoption prerequisites.
2908
+
2909
+ 3. **LifecycleCeremonyDesigner**
2910
+ - Provides textual/structural data for ceremonies (title, copy, animation cues, soundtrack references).
2911
+ - Ensures low-tech friendly instructions (clear copy, undo guidance).
2912
+
2913
+ 4. **AI Hooks**
2914
+ - Defines prompt templates and tool manifests for lifecycle advisor agents (consumed by bundles).
2915
+ - Keeps actual LLM integration outside module.
2916
+
2917
+ ---
2918
+
2919
+ ### 5. Managed Bundle (\`lifecycle-managed\`)
2920
+
2921
+ **Responsibilities**
2922
+ - Wire modules together.
2923
+ - Provide HTTP/GraphQL handlers (exact transport optional).
2924
+ - Register LifecycleAdvisorAgent via \`@contractspec/lib.ai-agent\`.
2925
+ - LifecycleAdvisorAgent meta: domain \`operations\`, owners \`team-lifecycle\`, stability \`experimental\`, tags \`guide/lifecycle/ops\` so ops tooling can route incidents quickly.
2926
+ - Emit lifecycle events through \`@contractspec/lib.bus\` + \`@contractspec/lib.analytics\`.
2927
+ - Integrate with \`contractspec-studio\` packages:
2928
+ - Use Studio contracts for authentication/tenant context (without accessing tenant DBs).
2929
+ - Store assessments in Studio-managed storage abstractions (in-memory or file-based for now).
2930
+
2931
+ **APIs**
2932
+ - \`POST /lifecycle/assessments\`: Accepts metrics + optional questionnaire answers. Returns \`LifecycleAssessment\`.
2933
+ - \`GET /lifecycle/playbooks/:stage\`: Returns stage playbook + ceremonies.
2934
+ - \`POST /lifecycle/advise\`: Invokes LifecycleAdvisorAgent with context.
2935
+
2936
+ **Events**
2937
+ - \`LifecycleAssessmentCreated\`
2938
+ - \`LifecycleStageChanged\`
2939
+ - \`LifecycleGuidanceConsumed\`
2940
+
2941
+ ---
2942
+
2943
+ ### 6. Library Enhancements
2944
+
2945
+ | Library | Enhancement |
2946
+ | --- | --- |
2947
+ | \`@contractspec/lib.analytics\` | Lifecycle metric collectors, helper to emit stage events, adapter implementation used by \`StageSignalCollector\`. |
2948
+ | \`@contractspec/lib.evolution\` | Accepts \`LifecycleContext\` when ranking spec anomalies/suggestions. |
2949
+ | \`@contractspec/lib.growth\` | Stage-specific experiment templates + guardrails referencing lifecycle enums. |
2950
+ | \`@contractspec/lib.observability\` | Lifecycle KPI pipeline definitions (drift detection, regression alerts). |
2951
+
2952
+ Each enhancement must import stage types from \`@contractspec/lib.lifecycle\`.
2953
+
2954
+ ---
2955
+
2956
+ ### 7. Feature Flags & Progressive Delivery
2957
+
2958
+ - Add new flags in progressive-delivery library:
2959
+ - \`LIFECYCLE_DETECTION_ALPHA\`
2960
+ - \`LIFECYCLE_ADVISOR_ALPHA\`
2961
+ - \`LIFECYCLE_MANAGED_SERVICE\`
2962
+ - Bundles/modules should check flags before enabling workflows.
2963
+ - Flags referenced in docs + Studio UI to avoid accidental exposure.
2964
+
2965
+ ---
2966
+
2967
+ ### 8. Analytics & Telemetry
2968
+
2969
+ - Events defined in analytics library; consumed by bundle/app:
2970
+ - \`lifecycle_assessment_run\`
2971
+ - \`lifecycle_stage_changed\`
2972
+ - \`lifecycle_guidance_consumed\`
2973
+ - Observability pipeline includes:
2974
+ - Composite lifecycle health metric (weighted sum of KPIs).
2975
+ - Drift detection comparing stage predictions over time.
2976
+ - Alert manager recipes for regression (e.g., PMF drop).
2977
+
2978
+ ---
2979
+
2980
+ ### 9. Testing Strategy
2981
+
2982
+ 1. **Unit**
2983
+ - StageScorer weight matrix.
2984
+ - RecommendationEngine mapping.
2985
+ - Library recommender stage coverage.
2986
+
2987
+ 2. **Contract**
2988
+ - Adapters: ensure mock adapters satisfy interfaces.
2989
+ - Bundles: ensure HTTP handlers respect request/response contracts even without persistence.
2990
+
2991
+ 3. **Integration**
2992
+ - CLI example runs detection + guidance end-to-end on fixture data.
2993
+ - Dashboard example renders assessments, verifying JSON structures remain stable.
2994
+
2995
+ ---
2996
+
2997
+ ### 10. Implementation Checklist
2998
+
2999
+ - [ ] Documentation (product, tech, ops, user).
3000
+ - [ ] Library creation (\`@contractspec/lib.lifecycle\`).
3001
+ - [ ] Modules (\`lifecycle-core\`, \`lifecycle-advisor\`).
3002
+ - [ ] Bundle (\`lifecycle-managed\`) + Studio wiring.
3003
+ - [ ] Library enhancements (analytics/evolution/growth/observability).
3004
+ - [ ] Examples (CLI + dashboard).
3005
+ - [ ] Feature flags + telemetry.
3006
+ - [ ] Automated tests + fixtures.
3007
+
3008
+ Keep this document in sync as modules evolve. When adding new stages or axes, update \`@contractspec/lib.lifecycle\` first, then cascade to adapters, then refresh docs + Studio copy.*** End Patch*** End Patch
3009
+
3010
+
3011
+ `
3012
+ }
3013
+ ];
3014
+ registerDocBlocks(tech_lifecycle_stage_system_DocBlocks);
3015
+
3016
+ // src/docs/tech/presentation-runtime.docblock.ts
3017
+ var tech_presentation_runtime_DocBlocks = [
3018
+ {
3019
+ id: "docs.tech.presentation-runtime",
3020
+ title: "Presentation Runtime",
3021
+ summary: "Cross-platform runtime for list pages and presentation flows.",
3022
+ kind: "reference",
3023
+ visibility: "public",
3024
+ route: "/docs/tech/presentation-runtime",
3025
+ tags: ["tech", "presentation-runtime"],
3026
+ body: `## Presentation Runtime
3027
+
3028
+ Cross-platform runtime for list pages and presentation flows.
3029
+
3030
+ ### Packages
3031
+
3032
+ - \`@contractspec/lib.presentation-runtime-core\`: shared types and config helpers
3033
+ - \`@contractspec/lib.presentation-runtime-react\`: React hooks (web/native-compatible API)
3034
+ - \`@contractspec/lib.presentation-runtime-react-native\`: Native entrypoint (re-exports React API for now)
3035
+
3036
+ ### Next.js config helper
3037
+
3038
+ \`\`\`ts
3039
+ // next.config.mjs
3040
+ import { withPresentationNextAliases } from '@contractspec/lib.presentation-runtime-core/next';
3041
+
3042
+ const nextConfig = {
3043
+ webpack: (config) => withPresentationNextAliases(config),
3044
+ };
3045
+
3046
+ export default nextConfig;
3047
+ \`\`\`
3048
+
3049
+ ### Metro config helper
3050
+
3051
+ \`\`\`js
3052
+ // metro.config.js (CJS)
3053
+ const { getDefaultConfig } = require('expo/metro-config');
3054
+ const {
3055
+ withPresentationMetroAliases,
3056
+ } = require('@contractspec/lib.presentation-runtime-core/src/metro.cjs');
3057
+
3058
+ const projectRoot = __dirname;
3059
+ const config = getDefaultConfig(projectRoot);
3060
+
3061
+ module.exports = withPresentationMetroAliases(config);
3062
+ \`\`\`
3063
+
3064
+ ### React hooks
3065
+
3066
+ - \`useListCoordinator\`: URL + RHF + derived variables (no fetching)
3067
+ - \`usePresentationController\`: Same plus \`fetcher\` integration
3068
+ - \`DataViewRenderer\` (design-system): render \`DataViewSpec\` projections (\`list\`, \`table\`, \`detail\`, \`grid\`) using shared UI atoms
3069
+
3070
+ Both accept a \`useUrlState\` adapter. On web, use \`useListUrlState\` (design-system) or a Next adapter.
3071
+
3072
+ ### KYC molecules (bundle)
3073
+
3074
+ - \`ComplianceBadge\` in \`@contractspec/bundle.strit/presentation/components/kyc\` renders a status badge for KYC/compliance snapshots. It accepts a \`state\` (missing_core | incomplete | complete | expiring | unknown) and optional localized \`labels\`. Prefer consuming apps to pass translated labels (e.g., via \`useT('appPlatformAdmin')\`).
3075
+
3076
+ ### Markdown routes and llms.txt
3077
+
3078
+ - Each web app exposes \`/llms\` (and \`/llms.txt\`, \`/llms.md\`) via rewrites. See [llmstxt.org](https://llmstxt.org/).
3079
+ - Catch‑all markdown handler lives at \`app/[...slug].md/route.ts\`. It resolves a page descriptor from \`app/.presentations.manifest.json\` and renders via the \`presentations.v2\` engine (target: \`markdown\`).
3080
+ - Per‑page companion convention: add \`app/<route>/ai.ts\` exporting a \`PresentationSpec\`.
3081
+ - Build‑time tool: \`tools/generate-presentations-manifest.mjs <app-root>\` populates the manifest.
3082
+ - CI check: \`bunllms:check\` verifies coverage (% of pages with descriptors) and fails if below threshold.
3083
+ `
3084
+ }
3085
+ ];
3086
+ registerDocBlocks(tech_presentation_runtime_DocBlocks);
3087
+
3088
+ // src/docs/tech/auth/better-auth-nextjs.docblock.ts
3089
+ var tech_auth_better_auth_nextjs_DocBlocks = [
3090
+ {
3091
+ id: "docs.tech.auth.better-auth-nextjs",
3092
+ title: "Better Auth + Next.js integration (ContractSpec)",
3093
+ summary: "How ContractSpec wires Better Auth into Next.js (server config, client singleton, and proxy cookie-only redirects).",
3094
+ kind: "reference",
3095
+ visibility: "public",
3096
+ route: "/docs/tech/auth/better-auth-nextjs",
3097
+ tags: ["auth", "better-auth", "nextjs", "cookies", "proxy", "hmr"],
3098
+ body: `# Better Auth + Next.js integration (ContractSpec)
3099
+
3100
+ This repo uses Better Auth as the primary auth layer (sessions, organizations, teams, API keys, and OAuth).
3101
+
3102
+ ## Server config (Better Auth)
3103
+
3104
+ - Source: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
3105
+ - Important: \`nextCookies()\` must be the **last** plugin in the Better Auth plugin list so \`Set-Cookie\` is applied correctly in Next.js environments.
3106
+
3107
+ ## Better Auth Admin plugin
3108
+
3109
+ ContractSpec Studio enables the Better Auth **Admin plugin** to support platform-admin user operations (list users, impersonation, etc.).
3110
+
3111
+ - Server: \`admin()\` plugin in \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
3112
+ - Client: \`adminClient()\` in \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
3113
+
3114
+ ### PLATFORM_ADMIN ⇒ Better Auth admin role
3115
+
3116
+ Better Auth Admin endpoints authorize via \`user.role\`. ContractSpec enforces an org-driven rule:
3117
+
3118
+ - If the **active organization** has \`type = PLATFORM_ADMIN\`, the signed-in user is ensured to have \`User.role\` containing \`admin\`.
3119
+ - This is applied in the session creation hook and re-checked in \`assertsPlatformAdmin()\`.
3120
+
3121
+ This keeps admin enablement deterministic and avoids manual role backfills.
3122
+
3123
+ ## Client config (React web + Expo)
3124
+
3125
+ To avoid duplicate background refresh/polling loops in dev (Fast Refresh/HMR), the Better Auth client is implemented as a singleton cached on \`globalThis\`.
3126
+
3127
+ - Web client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
3128
+ - Native client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.native.ts\`
3129
+
3130
+ Import guidance:
3131
+
3132
+ - If you only need the context/hook, prefer importing from \`@contractspec/bundle.studio/presentation/providers/auth\`.
3133
+ - If you explicitly need the Better Auth client instance (e.g. admin impersonation, direct API calls), import from \`@contractspec/bundle.studio/presentation/providers/auth/client\`.
3134
+
3135
+ ## Public routes (login / signup)
3136
+
3137
+ Public auth pages should avoid eager \`authClient\` initialization.
3138
+
3139
+ Pattern used:
3140
+
3141
+ - In the submit handler, dynamically import \`@contractspec/bundle.studio/presentation/providers/auth/index.web\` and call \`authClient.signIn.*\` / \`authClient.signUp.*\`.
3142
+
3143
+ This prevents session refresh behavior from starting just because a public page rendered.
3144
+
3145
+ ## Next.js proxy auth (web-landing)
3146
+
3147
+ The Next.js proxy/middleware is used for **redirect decisions only**. It must not perform DB-backed session reads on every request.
3148
+
3149
+ - Source: \`packages/apps/web-landing/src/proxy.ts\`
3150
+ - Approach: cookie-only checks via Better Auth cookies helpers:
3151
+ - \`getSessionCookie(request)\`
3152
+ - \`getCookieCache(request)\`
3153
+
3154
+ These checks are intentionally optimistic and should only gate routing. Full authorization must still be enforced on server-side actions/routes and GraphQL resolvers.
3155
+ `
3156
+ }
3157
+ ];
3158
+ registerDocBlocks(tech_auth_better_auth_nextjs_DocBlocks);
3159
+
3160
+ // src/docs/tech/schema/README.docblock.ts
3161
+ var tech_schema_README_DocBlocks = [
3162
+ {
3163
+ id: "docs.tech.schema.README",
3164
+ title: "Multi‑File Prisma Schema Conventions (per database)",
3165
+ summary: "We adopt Prisma multi‑file schema (GA ≥ v6.7) to organize each database’s models by domain and to import core LSSM module schemas locally.",
3166
+ kind: "reference",
3167
+ visibility: "public",
3168
+ route: "/docs/tech/schema/README",
3169
+ tags: ["tech", "schema", "README"],
3170
+ body: '# Multi‑File Prisma Schema Conventions (per database)\n\nWe adopt Prisma multi‑file schema (GA ≥ v6.7) to organize each database’s models by domain and to import core LSSM module schemas locally.\n\nCanonical layout per DB:\n\n```\nprisma/\n schema/\n main.prisma # datasource + generators only\n imported/\n lssm_sigil/*.prisma # imported models/enums only (no datasource/generator)\n lssm_content/*.prisma # idem\n <domain>/*.prisma # vertical‑specific models split by bounded context\n```\n\nNotes:\n\n- Imported files contain only `model` and `enum` blocks (strip `datasource`/`generator`).\n- Preserve `@@schema("…")` annotations to keep tables in their Postgres schemas; we now explicitly list schemas in `main.prisma` to avoid P1012: `schemas = ["public","lssm_sigil","lssm_content","lssm_featureflags","lssm_ops","lssm_planning","lssm_quill","lssm_geoterro"]`.\n- Use `@contractspec/app.cli-database` CLI: `database import|check|generate|migrate:*|seed` to manage a single DB; `@contractspec/app.cli-databases` orchestrates multiple DBs.\n\n## Typed merger config\n\n- Define imported module list once per DB with a typed config:\n\n```ts\n// prisma-merger.config.ts\nimport { defineMergedPrismaConfig } from \'@contractspec/app.cli-database\';\n\nexport default defineMergedPrismaConfig({\n modules: [\n \'@contractspec/app.cli-database-sigil\',\n \'@contractspec/app.cli-database-content\',\n // ...\n ],\n});\n```\n\n- Then run `database import --target .` (no need to pass `--modules`).\n\n## Prisma Config (prisma.config.ts)\n\nWe use Prisma Config per official docs to point Prisma to the multi-file schema folder and migrations:\n\n```ts\n// prisma.config.ts\nimport path from \'node:path\';\nimport { defineConfig } from \'prisma/config\';\n\nexport default defineConfig({\n schema: path.join(\'prisma\', \'schema\'),\n migrations: { path: path.join(\'prisma\', \'migrations\') },\n});\n```\n\nReference: Prisma blog – Organize Your Prisma Schema into Multiple Files: https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support\n\n---\n\n# LSSM Auth (Sigil) – Models & Integration\n\nThis document tracks the identity models and integration points used by the LSSM Sigil module.\n\n## Models (Prisma `lssm_sigil`)\n\n- `User` – core identity with email, optional phone, role, passkeys, apiKeys\n- `Session` – session tokens and metadata; includes `activeOrganizationId`\n- `Account` – external providers (password, OAuth)\n- `Organization` – tenant boundary; includes `type` additional field\n- `Member`, `Invitation`, `Team`, `TeamMember` – org/teams\n- `Role`, `Permission`, `PolicyBinding` – RBAC\n- `ApiKey`, `Passkey` – programmable access and WebAuthn\n- `SsoProvider` – OIDC/SAML provider configuration (org- or user-scoped)\n- `OAuthApplication`, `OAuthAccessToken`, `OAuthConsent` – first/third-party OAuth\n\nThese mirror STRIT additions so Better Auth advanced plugins (admin, organization, apiKey, passkey, genericOAuth) work uniformly across apps.\n\n## Better Auth (server)\n\nEnabled methods:\n\n- Email & password\n- Phone OTP (Telnyx)\n- Passkey (WebAuthn)\n- API keys\n- Organizations & Teams\n- Generic OAuth (FranceConnect+ via OIDC with JWE/JWS using JOSE)\n\nServer config lives at `packages/lssm/modules/sigil/src/application/services/auth.ts`.\n\n## Clients (Expo / React)\n\nClient config lives at `packages/lssm/modules/sigil/src/presentation/providers/auth/expo.ts` with plugins for admin, passkey, apiKey, organization, phone, genericOAuth.\n\n## Environment Variables\n\nTelnyx (phone OTP):\n\n- `TELNYX_API_KEY`\n- `TELNYX_MESSAGING_PROFILE_ID`\n- `TELNYX_FROM_NUMBER`\n\nFranceConnect+ (prefer LSSM*… but STRIT*… fallbacks are supported):\n\n- `LSSM_FRANCECONNECTPLUS_DISCOVERY_URL`\n- `LSSM_FRANCECONNECTPLUS_CLIENT_ID`\n- `LSSM_FRANCECONNECTPLUS_CLIENT_SECRET`\n- `LSSM_FRANCECONNECTPLUS_ENC_PRIVATE_KEY_PEM` (PKCS8; RSA-OAEP-256)\n\nGeneric:\n\n- `API_URL_IDENTITIES` – base URL for Better Auth server\n- `BETTER_AUTH_SECRET` – server secret\n\nKeep this in sync with code changes to avoid drift.\n\n## HCircle domain splits and auth removal\n\n- Auth/identity models are not defined locally anymore. They come from `@contractspec/app.cli-database-sigil` under the `lssm_sigil` schema.\n- `packages/hcircle/libs/database-coliving/prisma/schema/domain/` is split by domain; newsletter/waiting list lives in `newsletter.prisma` and uses `@@map("waiting_list")`.\n- To avoid collisions with module names, the local event models were renamed to `SocialEvent`, `SocialEventAttendee`, and `SocialEventRecurrence` with `@@map` pointing to existing table names.\n\n---\n\n## Vertical profiles (current)\n\n### STRIT\n\n- prisma-merger modules:\n - `@contractspec/app.cli-database-sigil`, `@contractspec/app.cli-database-content`, `@contractspec/app.cli-database-ops`, `@contractspec/app.cli-database-planning`, `@contractspec/app.cli-database-quill`, `@contractspec/app.cli-database-geoterro`\n- main.prisma schemas:\n - `schemas = ["public","lssm_sigil","lssm_content","lssm_ops","lssm_planning","lssm_quill","lssm_geoterro"]`\n- domain splits (`packages/strit/libs/database/prisma/schema/domain/`):\n - `bookings.prisma` (Booking, StritDocument + links to Content `File` and Sigil `Organization`)\n - `commerce.prisma` (Wholesale models; `sellerId` linked to Sigil `Organization`)\n - `files.prisma` (PublicFile, PublicFileAccessLog; `ownerId`→Organization, `uploadedBy`→User)\n - `geo.prisma` (PublicCountry, PublicAddress, City; links to Spots/Series)\n - `spots.prisma`, `urbanism.prisma`, `analytics.prisma`, `onboarding.prisma`, `referrals.prisma`, `subscriptions.prisma`, `content.prisma`\n- auth models are imported from Sigil (no local auth tables).\n- Back-relations for `Organization` (e.g., `files`, seller relations) are declared in the Sigil module to avoid scattering.\n\n### ARTISANOS\n\n- prisma-merger modules:\n - `@contractspec/app.cli-database-sigil`, `@contractspec/app.cli-database-content`, `@contractspec/app.cli-database-featureflags`, `@contractspec/app.cli-database-ops`, `@contractspec/app.cli-database-planning`, `@contractspec/app.cli-database-quill`, `@contractspec/app.cli-database-geoterro`\n- main.prisma schemas:\n - `schemas = ["public","lssm_sigil","lssm_content","lssm_featureflags","lssm_ops","lssm_planning","lssm_quill","lssm_geoterro"]`\n- domain splits (`packages/artisanos/libs/database-artisan/prisma/schema/domain/`):\n - `sales.prisma` (Client, Quote, QuoteTemplate, Invoice, FollowUps)\n - `subsidies.prisma` (SubsidyProgram, AidApplication, SupportingDocument)\n - `projects.prisma` (Project, ProjectPlanningSettings)\n - `crm.prisma` (OrganizationProfessionalProfile, OrganizationCertification)\n - `professions.prisma`, `products.prisma`, `templates.prisma`, `analytics.prisma`, `onboarding.prisma`, `referrals.prisma`, `subscriptions.prisma`, `files.prisma`\n- auth/organization/team models are provided by Sigil; local legacy copies were removed.\n- Where names collide with Content, local models are prefixed (e.g., `PublicFile`) and use `@@map` to keep existing table names where applicable.\n\n## Schema Dictionary: `@contractspec/lib.schema`\n\n### Purpose\n\nDescribe operation I/O once and generate:\n\n- zod (runtime validation)\n- GraphQL (Pothos types/refs)\n- JSON Schema (via `zod-to-json-schema` or native descriptors)\n\n### Primitives\n\n- **FieldType<T>**: describes a scalar or composite field and carries:\n - `zod` schema for validation\n - optional JSON Schema descriptor\n - optional GraphQL scalar reference/name\n- **SchemaModel**: named object model composed of fields. Exposes helpers:\n - `getZod(): z.ZodObject<ZodShapeFromFields<Fields>> | z.ZodArray<z.ZodObject<...>>`\n - Preserves each field\'s schema, optionality, and array-ness\n - Top-level lists are supported via `config.isArray: true`\n - `getJsonSchema(): JSONSchema7` (export for docs, MCP, forms)\n - `getPothosInput()` (GraphQL input object name)\n\n### Multi-Format Wrappers\n\nUse existing schema definitions from other libraries:\n- `ZodSchemaType`: Wraps a raw Zod schema (`z.infer` becomes the TS type).\n- `JsonSchemaType`: Wraps a JSON Schema object.\n- `GraphQLSchemaType`: Wraps a GraphQL SDL string.\n\n### Conventions\n\n- Name models with PascalCase; suffix with `Input`/`Result` when ambiguous.\n- Use explicit enums for multi-value constants; reuse the same enum across input/output.\n- Define domain enums via `defineEnum(\'Name\', [...])` in the relevant domain package (e.g., `packages/strit/libs/contracts-strit/src/enums/`), not in `ScalarTypeEnum`.\n- Reference those enums in `SchemaModel` fields directly (they expose `getZod`, `getPothos`, `getJsonSchema`).\n\n#### Example (STRIT)\n\n```ts\n// packages/strit/libs/contracts-strit/src/enums/recurrence.ts\nimport { defineEnum } from \'@contractspec/lib.schema\';\nexport const SpotEnum = {\n Weekday: () =>\n defineEnum(\'Weekday\', [\'MO\', \'TU\', \'WE\', \'TH\', \'FR\', \'SA\', \'SU\'] as const),\n RecurrenceFrequency: () =>\n defineEnum(\'RecurrenceFrequency\', [\n \'DAILY\',\n \'WEEKLY\',\n \'MONTHLY\',\n \'YEARLY\',\n ] as const),\n} as const;\n```\n\n```ts\n// usage in contracts\nfrequency: { type: SpotEnum.RecurrenceFrequency(), isOptional: false },\nbyWeekday: { type: SpotEnum.Weekday(), isOptional: true, isArray: true },\n```\n\n- Use `Date` type for temporal values and ensure ISO strings in JSON transports where needed.\n\n### Mapping rules (summary)\n\n- Strings → GraphQL `String`\n- Numbers → `Int` if safe 32-bit integer else `Float`\n- Booleans → `Boolean`\n- Dates → custom `Date` scalar\n- Arrays<T> → list of mapped T (set `isArray: true` on the field)\n- Top-level arrays → set `isArray: true` on the model config\n- Objects → input/output object types with stable field order\n- Unions → supported for output; input unions map to JSON (structural input is not supported by GraphQL)\n\n### JSON Schema export\n\nPrefer `getZod()` + `zod-to-json-schema` for consistency. For advanced cases, provide a custom `getJsonSchema()` on the model.\n\n### Example\n\n```ts\nimport { ScalarTypeEnum, SchemaModel } from \'@contractspec/lib.schema\';\n\n// Nested model\nconst Weekday = new SchemaModel({\n name: \'Weekday\',\n fields: {\n value: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\n// Parent model with array field and nested object\nconst Rule = new SchemaModel({\n name: \'Rule\',\n fields: {\n timezone: { type: ScalarTypeEnum.TimeZone(), isOptional: false },\n byWeekday: { type: Weekday, isOptional: true, isArray: true },\n },\n});\n\nconst CreateThingInput = new SchemaModel({\n name: \'CreateThingInput\',\n fields: {\n name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n rule: { type: Rule, isOptional: false },\n },\n});\n\n// zod\nconst z = CreateThingInput.getZod();\n```\n'
3171
+ }
3172
+ ];
3173
+ registerDocBlocks(tech_schema_README_DocBlocks);
3174
+
3175
+ // src/workflow/overview.docblock.ts
3176
+ var tech_workflows_overview_DocBlocks = [
3177
+ {
3178
+ id: "docs.tech.workflows.overview",
3179
+ title: "WorkflowSpec Overview",
3180
+ summary: "WorkflowSpec provides a declarative, versioned format for long-running flows that mix automation and human review. Specs stay inside `@contractspec/lib.contracts-spec` (`src/workflow/spec.ts`) so the same definition powers runtime execution, documentation, and future generation.",
3181
+ kind: "reference",
3182
+ visibility: "public",
3183
+ route: "/docs/tech/workflows/overview",
3184
+ tags: ["tech", "workflows", "overview"],
3185
+ body: "# WorkflowSpec Overview\n\n## Purpose\n\nWorkflowSpec provides a declarative, versioned format for long-running flows that mix automation and human review. Specs stay inside `@contractspec/lib.contracts-spec` (`src/workflow/spec.ts`) so the same definition powers runtime execution, documentation, and future generation.\n\n## Core Types\n\n- `WorkflowMeta`: ownership metadata (`title`, `domain`, `owners`, `tags`, `stability`) plus `name` and `version`.\n- `WorkflowDefinition`:\n - `entryStepId?`: optional explicit entry point (defaults to first step).\n - `steps[]`: ordered list of `Step` descriptors.\n - `transitions[]`: directed edges between steps with optional expressions.\n - `sla?`: aggregated timing hints for the overall flow or per-step budgets.\n - `compensation?`: fallback operations executed when a workflow is rolled back or fails.\n- `Step`:\n - `type`: `human`, `automation`, or `decision`.\n - `action`: references either a `ContractSpec` (`operation`) or `FormSpec` (`form`).\n - Optional `guard`, `timeoutMs`, and retry policy (`maxAttempts`, `backoff`, `delayMs`, `maxDelayMs?`).\n - `requiredIntegrations?`: integration slot ids that must be bound before the step may execute.\n - `requiredCapabilities?`: `CapabilityRef[]` that must be enabled in the resolved app config.\n- `Transition`: `from` → `to` with optional `condition` string (simple data expressions).\n\n## Registry & Validation\n\n- `WorkflowRegistry` (`src/workflow/spec.ts`) stores specs by key `<name>.v<version>` and exposes `register`, `list`, and `get`.\n- `validateWorkflowSpec()` (`src/workflow/validation.ts`) checks:\n - Duplicate step IDs.\n - Unknown `from`/`to` transitions.\n - Empty guards/conditions.\n - Reachability from the entry step.\n - Cycles in the graph.\n - Operation/Form references against provided registries.\n- `assertWorkflowSpecValid()` wraps validation and throws `WorkflowValidationError` when errors remain.\n\n## Runtime\n\n- `WorkflowRunner` (`src/workflow/runner.ts`) executes workflows and coordinates steps.\n - `start(name, version?, initialData?)` returns a `workflowId`.\n - `executeStep(workflowId, input?)` runs the current step (automation or human).\n - `getState(workflowId)` retrieves the latest state snapshot.\n - `cancel(workflowId)` marks the workflow as cancelled.\n - `preFlightCheck(name, version?, resolvedConfig?)` evaluates integration/capability requirements before the workflow starts.\n - Throws `WorkflowPreFlightError` if required integration slots are unbound or required capabilities are disabled.\n- `StateStore` (`src/workflow/state.ts`) abstracts persistence. V1 ships with:\n - `InMemoryStateStore` (`src/workflow/adapters/memory-store.ts`) for tests/dev.\n - Placeholder factories for file/database adapters (`adapters/file-adapter.ts`, `adapters/db-adapter.ts`).\n- Guard evaluation: expression guards run through `evaluateExpression()` (`src/workflow/expression.ts`); custom policy guards can be provided via `guardEvaluator`.\n- Events: the runner emits `workflow.started`, `workflow.step_completed`, `workflow.step_failed`, and `workflow.cancelled` through the optional `eventEmitter`.\n- React bindings (`@contractspec/lib.presentation-runtime-react`):\n - `useWorkflow` hook (polls state, exposes `executeStep`, `cancel`, `refresh`).\n - `WorkflowStepper` progress indicator using design-system Stepper.\n - `WorkflowStepRenderer` helper to render human/automation/decision steps with sensible fallbacks.\n\n## Authoring Checklist\n\n1. Reuse existing operations/forms; create new specs when missing.\n2. Prefer explicit `entryStepId` for clarity (especially with decision branches).\n3. Give automation steps an `operation` and human steps a `form` (warnings surface otherwise).\n4. Use short, meaningful step IDs (`submit`, `review`, `finalize`) to simplify analytics.\n5. Keep guard expressions deterministic; complex policy logic should move to PolicySpec (Phase 2).\n\n## Testing\n\n- Add unit tests for new workflows via `assertWorkflowSpecValid`.\n- Use the new Vitest suites (`validation.test.ts`, `expression.test.ts`, `runner.test.ts`) as examples.\n- CLI support will arrive in Phase 1 PR 3 (`contractspec create --type workflow`).\n\n## Tooling\n\n- `contractspec create --type workflow` scaffolds a WorkflowSpec with interactive prompts.\n- `contractspec build <spec.workflow.ts>` generates a runner scaffold (`.runner.ts`) wired to `WorkflowRunner` and the in-memory store.\n- `contractspec validate` understands `.workflow.ts` files and checks core structure (meta, steps, transitions).\n\n## Next Steps (Non-MVP)\n\n- Persistence adapters (database/file) for workflow state (Phase 2).\n- React bindings (`useWorkflow`, `WorkflowStepper`) and presentation-runtime integration (PR 3).\n- Policy engine integration (`guard.type === 'policy'` validated against PolicySpec).\n- Telemetry hooks for step execution metrics.\n\n"
3186
+ }
3187
+ ];
3188
+ registerDocBlocks(tech_workflows_overview_DocBlocks);
3189
+
3190
+ // src/docs/tech/mcp-endpoints.docblock.ts
3191
+ var tech_mcp_endpoints_DocBlocks = [
3192
+ {
3193
+ id: "docs.tech.mcp.endpoints",
3194
+ title: "ContractSpec MCP endpoints",
3195
+ summary: "Dedicated MCP servers for docs, CLI usage, and internal development.",
3196
+ kind: "reference",
3197
+ visibility: "mixed",
3198
+ route: "/docs/tech/mcp/endpoints",
3199
+ tags: ["mcp", "docs", "cli", "internal"],
3200
+ body: `# ContractSpec MCP endpoints
3201
+
3202
+ Three dedicated MCP servers keep AI agents efficient and scoped:
3203
+
3204
+ - **Docs MCP**: \`/api/mcp/docs\` — exposes DocBlocks as resources + presentations. Tool: \`docs.search\`.
3205
+ - **CLI MCP**: \`/api/mcp/cli\` — surfaces CLI quickstart/reference/README and suggests commands. Tool: \`cli.suggestCommand\`.
3206
+ - **Internal MCP**: \`/api/mcp/internal\` — internal routing hints, playbook, and example registry access. Tool: \`internal.describe\`.
3207
+
3208
+ ### Usage notes
3209
+ - Transports are HTTP POST (streamable HTTP); SSE is disabled.
3210
+ - Resources are namespaced (\`docs://*\`, \`cli://*\`, \`internal://*\`) and are read-only.
3211
+ - Internal MCP also exposes the examples registry via \`examples://*\` resources:
3212
+ - \`examples://list?q=<query>\`
3213
+ - \`examples://example/<id>\`
3214
+ - Prompts mirror each surface (navigator, usage, bootstrap) for quick agent onboarding.
3215
+ - GraphQL remains at \`/graphql\`; health at \`/health\`.
3216
+
3217
+ ### Alpic hosting
3218
+ - Alpic exposes MCP at \`/\` (SSE + Streamable HTTP) and \`/mcp\` (Streamable HTTP).
3219
+ - Static UI assets are served at \`/assets\` from repo \`/assets\` or build output \`dist/assets\`.
3220
+ - Use the \`ALPIC_HOST\` environment variable to build absolute asset URLs.
3221
+ `
3222
+ }
3223
+ ];
3224
+ registerDocBlocks(tech_mcp_endpoints_DocBlocks);
3225
+
3226
+ // src/docs/tech/vscode-extension.docblock.ts
3227
+ var tech_vscode_extension_DocBlocks = [
3228
+ {
3229
+ id: "docs.tech.vscode.extension",
3230
+ title: "ContractSpec VS Code Extension",
3231
+ summary: "VS Code extension for spec-first development with validation, scaffolding, and MCP integration.",
3232
+ kind: "reference",
3233
+ visibility: "public",
3234
+ route: "/docs/tech/vscode/extension",
3235
+ tags: ["vscode", "extension", "tooling", "dx"],
3236
+ body: `# ContractSpec VS Code Extension
3237
+
3238
+ The ContractSpec VS Code extension provides spec-first development tooling directly in your editor.
3239
+
3240
+ ## Features
3241
+
3242
+ - **Real-time Validation**: Get instant feedback on spec errors and warnings as you save files
3243
+ - **Build/Scaffold**: Generate handler and component skeletons from specs (no AI required)
3244
+ - **Spec Explorer**: List and navigate all specs in your workspace
3245
+ - **Dependency Analysis**: Visualize spec dependencies and detect cycles
3246
+ - **MCP Integration**: Search ContractSpec documentation via Model Context Protocol
3247
+ - **Snippets**: Code snippets for common ContractSpec patterns
3248
+
3249
+ ## Commands
3250
+
3251
+ | Command | Description |
3252
+ |---------|-------------|
3253
+ | \`ContractSpec: Validate Current Spec\` | Validate the currently open spec file |
3254
+ | \`ContractSpec: Validate All Specs\` | Validate all spec files in the workspace |
3255
+ | \`ContractSpec: Build/Scaffold\` | Generate handler/component from the current spec |
3256
+ | \`ContractSpec: List All Specs\` | Show all specs in the workspace |
3257
+ | \`ContractSpec: Analyze Dependencies\` | Analyze and visualize spec dependencies |
3258
+ | \`ContractSpec: Search Docs (MCP)\` | Search documentation via MCP |
3259
+
3260
+ ## Configuration
3261
+
3262
+ | Setting | Description | Default |
3263
+ |---------|-------------|---------|
3264
+ | \`contractspec.api.baseUrl\` | Base URL for ContractSpec API (enables MCP + remote telemetry) | \`""\` |
3265
+ | \`contractspec.telemetry.posthogHost\` | PostHog host URL for direct telemetry | \`"https://eu.posthog.com"\` |
3266
+ | \`contractspec.telemetry.posthogProjectKey\` | PostHog project key for direct telemetry | \`""\` |
3267
+ | \`contractspec.validation.onSave\` | Run validation on save | \`true\` |
3268
+ | \`contractspec.validation.onOpen\` | Run validation on open | \`true\` |
3269
+
3270
+ ## Architecture
3271
+
3272
+ The extension uses:
3273
+ - \`@contractspec/module.workspace\` for pure analysis + templates
3274
+ - \`@contractspec/bundle.workspace\` for workspace services + adapters
3275
+
3276
+ This allows the extension to work without requiring the CLI to be installed.
3277
+
3278
+ ## Telemetry
3279
+
3280
+ The extension uses a hybrid telemetry approach:
3281
+ 1. If \`contractspec.api.baseUrl\` is configured → send to API \`/api/telemetry/ingest\`
3282
+ 2. Otherwise → send directly to PostHog (if project key configured)
3283
+
3284
+ Telemetry respects VS Code's telemetry settings. No file paths, source code, or PII is collected.
3285
+ `
3286
+ },
3287
+ {
3288
+ id: "docs.tech.vscode.snippets",
3289
+ title: "ContractSpec Snippets",
3290
+ summary: "Code snippets for common ContractSpec patterns in VS Code.",
3291
+ kind: "reference",
3292
+ visibility: "public",
3293
+ route: "/docs/tech/vscode/snippets",
3294
+ tags: ["vscode", "snippets", "dx"],
3295
+ body: `# ContractSpec Snippets
3296
+
3297
+ The VS Code extension includes snippets for common ContractSpec patterns.
3298
+
3299
+ ## Available Snippets
3300
+
3301
+ | Prefix | Description |
3302
+ |--------|-------------|
3303
+ | \`contractspec-command\` | Create a new command (write operation) |
3304
+ | \`contractspec-query\` | Create a new query (read-only operation) |
3305
+ | \`contractspec-event\` | Create a new event |
3306
+ | \`contractspec-docblock\` | Create a new DocBlock |
3307
+ | \`contractspec-telemetry\` | Create a new TelemetrySpec |
3308
+ | \`contractspec-presentation\` | Create a new Presentation |
3309
+
3310
+ ## Usage
3311
+
3312
+ Type the prefix in a TypeScript file and press Tab to expand the snippet. Tab through the placeholders to fill in your values.
3313
+ `
3314
+ }
3315
+ ];
3316
+ registerDocBlocks(tech_vscode_extension_DocBlocks);
3317
+
3318
+ // src/docs/tech/telemetry-ingest.docblock.ts
3319
+ var tech_telemetry_ingest_DocBlocks = [
3320
+ {
3321
+ id: "docs.tech.telemetry.ingest",
3322
+ title: "Telemetry Ingest Endpoint",
3323
+ summary: "Server-side telemetry ingestion for ContractSpec clients (VS Code extension, CLI, etc.).",
3324
+ kind: "reference",
3325
+ visibility: "internal",
3326
+ route: "/docs/tech/telemetry/ingest",
3327
+ tags: ["telemetry", "api", "posthog", "analytics"],
3328
+ body: `# Telemetry Ingest Endpoint
3329
+
3330
+ The ContractSpec API provides a telemetry ingest endpoint for clients to send product analytics events.
3331
+
3332
+ ## Endpoint
3333
+
3334
+ \`\`\`
3335
+ POST /api/telemetry/ingest
3336
+ \`\`\`
3337
+
3338
+ ## Request
3339
+
3340
+ \`\`\`json
3341
+ {
3342
+ "event": "contractspec.vscode.command_run",
3343
+ "distinct_id": "client-uuid",
3344
+ "properties": {
3345
+ "command": "validate"
3346
+ },
3347
+ "timestamp": "2024-01-15T10:30:00.000Z"
3348
+ }
3349
+ \`\`\`
3350
+
3351
+ ### Headers
3352
+
3353
+ | Header | Description |
3354
+ |--------|-------------|
3355
+ | \`x-contractspec-client-id\` | Optional client identifier (used as fallback for distinct_id) |
3356
+ | \`Content-Type\` | Must be \`application/json\` |
3357
+
3358
+ ### Body
3359
+
3360
+ | Field | Type | Required | Description |
3361
+ |-------|------|----------|-------------|
3362
+ | \`event\` | string | Yes | Event name (e.g., \`contractspec.vscode.activated\`) |
3363
+ | \`distinct_id\` | string | Yes | Anonymous client identifier |
3364
+ | \`properties\` | object | No | Event properties |
3365
+ | \`timestamp\` | string | No | ISO 8601 timestamp |
3366
+
3367
+ ## Response
3368
+
3369
+ \`\`\`json
3370
+ {
3371
+ "success": true
3372
+ }
3373
+ \`\`\`
3374
+
3375
+ ## Configuration
3376
+
3377
+ The endpoint requires \`POSTHOG_PROJECT_KEY\` environment variable to be set. If not configured, events are accepted but not forwarded.
3378
+
3379
+ | Environment Variable | Description | Default |
3380
+ |---------------------|-------------|---------|
3381
+ | \`POSTHOG_HOST\` | PostHog host URL | \`https://eu.posthog.com\` |
3382
+ | \`POSTHOG_PROJECT_KEY\` | PostHog project API key | (required) |
3383
+
3384
+ ## Privacy
3385
+
3386
+ - No PII is collected or stored
3387
+ - \`distinct_id\` is an anonymous client-generated UUID
3388
+ - File paths and source code are never included in events
3389
+ - Respects VS Code telemetry settings on the client side
3390
+
3391
+ ## Events
3392
+
3393
+ ### OSS Adoption Funnel
3394
+
3395
+ | Event | Description | Properties |
3396
+ |-------|-------------|------------|
3397
+ | \`cta_install_click\` | Clicked Install OSS CTA | \`surface\` |
3398
+ | \`cta_studio_click\` | Clicked Studio waitlist CTA | \`surface\`, \`variant\` |
3399
+ | \`docs_quickstart_view\` | Entered quickstart docs path | \`surface\`, \`destination\` |
3400
+ | \`copy_command_click\` | Copied a command block | \`surface\`, \`language\`, \`filename\`, \`packageManager\` |
3401
+ | \`example_repo_open\` | Selected a template/example | \`surface\`, \`templateId\`, \`source\` |
3402
+
3403
+ ### Extension Events
3404
+
3405
+ | Event | Description | Properties |
3406
+ |-------|-------------|------------|
3407
+ | \`contractspec.vscode.activated\` | Extension activated | \`version\` |
3408
+ | \`contractspec.vscode.command_run\` | Command executed | \`command\` |
3409
+ | \`contractspec.vscode.mcp_call\` | MCP call made | \`endpoint\`, \`tool\` |
3410
+
3411
+ ### API Events
3412
+
3413
+ | Event | Description | Properties |
3414
+ |-------|-------------|------------|
3415
+ | \`contractspec.api.mcp_request\` | MCP request processed | \`endpoint\`, \`method\`, \`success\`, \`duration_ms\` |
3416
+ `
3417
+ },
3418
+ {
3419
+ id: "docs.tech.telemetry.hybrid",
3420
+ title: "Hybrid Telemetry Model",
3421
+ summary: "How ContractSpec clients choose between direct PostHog and API-routed telemetry.",
3422
+ kind: "usage",
3423
+ visibility: "internal",
3424
+ route: "/docs/tech/telemetry/hybrid",
3425
+ tags: ["telemetry", "architecture", "posthog"],
3426
+ body: `# Hybrid Telemetry Model
3427
+
3428
+ ContractSpec uses a hybrid telemetry model where clients can send events either directly to PostHog or via the API server.
3429
+
3430
+ ## Decision Flow
3431
+
3432
+ \`\`\`
3433
+ Is contractspec.api.baseUrl configured?
3434
+ ├── Yes → Send via /api/telemetry/ingest
3435
+ └── No → Is posthogProjectKey configured?
3436
+ ├── Yes → Send directly to PostHog
3437
+ └── No → Telemetry disabled
3438
+ \`\`\`
3439
+
3440
+ ## Benefits
3441
+
3442
+ ### Direct PostHog
3443
+ - No server dependency
3444
+ - Works offline (with batching)
3445
+ - Lower latency
3446
+
3447
+ ### Via API
3448
+ - Centralized key management (no client-side keys)
3449
+ - Server-side enrichment and validation
3450
+ - Rate limiting and abuse prevention
3451
+ - Easier migration to other providers
3452
+
3453
+ ## Recommendation
3454
+
3455
+ - **Development**: Use direct PostHog with a dev project key
3456
+ - **Production**: Route via API for better governance
3457
+
3458
+ ## Future: OpenTelemetry
3459
+
3460
+ The current PostHog implementation is behind a simple interface that can be swapped for OpenTelemetry:
3461
+
3462
+ \`\`\`typescript
3463
+ interface TelemetryClient {
3464
+ send(event: TelemetryEvent): Promise<void>;
3465
+ }
3466
+ \`\`\`
3467
+
3468
+ This allows future migration without changing client code.
3469
+ `
3470
+ }
3471
+ ];
3472
+ registerDocBlocks(tech_telemetry_ingest_DocBlocks);
3473
+
3474
+ // src/docs/tech/contracts/README.docblock.ts
3475
+ var tech_contracts_README_DocBlocks = [
3476
+ {
3477
+ id: "docs.tech.contracts.README",
3478
+ title: "Contracts: Specs, Registry, Handlers, Adapters",
3479
+ summary: "- `packages/lssm/libs/contracts` defines the contracts core (OperationSpecRegistry, OperationSpec, PresentationSpec, install helpers, REST/MCP adapters, ...).",
3480
+ kind: "reference",
3481
+ visibility: "public",
3482
+ route: "/docs/tech/contracts/README",
3483
+ tags: ["tech", "contracts", "README"],
3484
+ body: "## Contracts: Specs, Registry, Handlers, Adapters\n\n### What lives where\n\n- `packages/lssm/libs/contracts` defines the contracts core (OperationSpecRegistry, OperationSpec, PresentationSpec, install helpers, REST/MCP adapters).\n- `packages/lssm/libs/schema` defines the schema dictionary (`SchemaModel`, `FieldType`) used to describe I/O once and map to multiple targets (zod, GraphQL, JSON Schema).\n- App adapters (e.g. GraphQL) live close to the app. Example: `packages/hcircle/apps/api-coliving/src/graphql/contracts-adapter.ts`.\n\n### npm distribution\n\n- `@contractspec/lib.contracts-spec` (root) keeps the legacy \\\"everything\\\" surface for backward compatibility.\n- `@contractspec/lib.contracts-runtime-client-react` exposes only browser-safe helpers (React renderers, client SDK, drivers). Import from this entry when bundling for the web or React Native to avoid dragging server adapters.\n- `@contractspec/lib.contracts-runtime-server-rest` covers HTTP/MCP adapters, registries, integrations, and other Node-only helpers.\n- `@contractspec/lib.contracts-spec/types` exports the runtime handler context utilities, while `@contractspec/lib.contracts-spec/types/all` re-exports every type alias/interface across the package via `export type` so consumers can import a single module for typings without shipping runtime code.\n- `@contractspec/lib.schema`, `@contractspec/lib.design-system`, `@contractspec/lib.ui-kit`, `@contractspec/lib.ui-kit-web`, `@contractspec/lib.accessibility`, and the presentation runtime packages are published to npm alongside contracts; prefer the scoped packages to keep tree-shaking intact.\n- Bundlers with conditional exports should resolve subpaths first; keep root imports for server-only code paths.\n\n### Core concepts\n\n- **OperationSpec**: immutable description of an operation.\n - `meta`: `{ name, version, kind: 'query' | 'command' }`\n - `io`: `{ input: SchemaModel | zod schema, output: SchemaModel | zod schema }`\n - `policy`: `{ auth?: {...}, rateLimit?: {...}, flags?: string[] }`\n - `transport.gql.field?`: explicit GraphQL field name (otherwise derived via `defaultGqlField`).\n- **OperationSpecRegistry**: registry of specs + handlers. Use `installOp(reg, spec, handler)` to attach a handler.\n- **Handler**: `(ctx, input) => Promise<output>` implementing the operation.\n- **CapabilitySpec**: canonical capability declaration stored in `src/capabilities.ts`. Tracks `meta` (`{ key, version, kind, title, description, domain, owners, tags, stability }`), `provides` surfaces (`operation`, `event`, `workflow`, `presentation`, `resource`), and `requires` which other capabilities must be present. Enforced during `installFeature`.\n- **PolicySpec**: declarative policy rules (`src/policy/spec.ts`) covering ABAC/ReBAC, consent + rate limit requirements, field-level controls, and PII guidance. `PolicyEngine` evaluates refs, while `OPAPolicyAdapter` lets OPA override/augment runtime decisions.\n- **TelemetrySpec**: analytics definitions (`src/telemetry/spec.ts`) describing event semantics, privacy level, retention, sampling, and anomaly detection. `TelemetryTracker` handles redaction/sampling, `TelemetryAnomalyMonitor` raises alerts, and specs integrate with contracts/workflows via `ctx.telemetry`.\n- **TestSpec**: declarative scenario definitions in `src/tests/spec.ts`. `TestRunner` executes fixtures/actions/assertions against a `OperationSpecRegistry`, and the CLI (`contractspec test`) wraps the runner for automation.\n- **ExperimentSpec**: experiment definitions (`src/experiments/spec.ts`) describing variants, allocation strategies, and success metrics. `ExperimentEvaluator` assigns variants (random/sticky/targeted) and integrates with Policy/Telemetry for safe experimentation.\n- **AppBlueprintSpec / TenantAppConfig**: global blueprints and per-tenant overrides (`src/app-config/spec.ts`). `resolveAppConfig()` merges the two into a `ResolvedAppConfig`, while `composeAppConfig()` hydrates the merged view against registries and reports missing references for safe rollout.\n- **RegeneratorService**: background daemon (`src/regenerator/service.ts`) that consumes telemetry/error/behavior signals, evaluates regeneration rules, and produces `SpecChangeProposal`s for Studio review.\n- **DataViewSpec**: declarative data presentation layer in `src/data-views.ts`. Describes entity projections (`fields`, `filters`, `actions`) with `view.kind` (`list`, `table`, `detail`, `grid`), ties to query operations via `source.primary`, and exposes optional presentation-based empty/error states.\n- **ThemeSpec**: design token + component variant definitions in `src/themes.ts`. Supports inheritance (`extends`), tenant/user overrides, and component-specific variant metadata for the design system.\n- **MigrationSpec**: schema/data migration descriptors (`src/migrations.ts`) with ordered step plans, dependency tracking, and pre/post checks to support automated database/content migrations.\n- **WorkflowSpec**: typed definition of multi-step workflows living in `src/workflow/spec.ts`. `WorkflowRegistry` stores versioned specs, and `validateWorkflowSpec()` (in `src/workflow/validation.ts`) checks graph integrity, step references, and reachability.\n\n### Lifecycle\n\n1. Define the spec (I/O via `SchemaModel` or zod) in a vertical lib (e.g. `contracts-coliving`).\n2. Register it: `installOp(registry, spec, handler)` within the app/service.\n3. Expose it via an adapter (REST, GraphQL, MCP). Each adapter maps the I/O to its transport and enforces policy.\n4. Validate at runtime: parse `input` before executing, parse `output` before returning.\n\n### Adapters\n\n- **REST**: see `packages/lssm/libs/contracts/src/server/rest-*`. Binds routes, validates request/response, maps errors/policies.\n- **MCP**: see `packages/lssm/libs/contracts/src/server/provider-mcp.ts` (standalone MCP server) and `packages/lssm/libs/contracts/src/server/rest-next-mcp.ts` (MCP over Next.js route). Provides tools/resources/prompts.\n - Tools + resources are registered from Zod schemas.\n - Resource templates are keyed by full `ResourceMeta.uriTemplate` (e.g. `docs://list`, `docs://doc/{id}`), so multiple templates can share a scheme (`docs://*`) without collisions.\n- **GraphQL (Pothos)**: see `packages/lssm/libs/contracts/src/server/graphql-pothos.ts`. Adds Query/Mutation fields by transforming contract I/O to GraphQL types.\n\n### GraphQL adapter behaviour (summary)\n\n- Field naming: `spec.transport.gql.field` or `<name_with_dots>_v<version>`.\n- Input/Output types from `SchemaModel` (preferred) or fallback zod introspection.\n- Scalars: String/Int/Float/Boolean/Date/JSON; Objects/Arrays/Enums; unions for outputs; input unions => JSON.\n- Policy: auth gate checks GraphQL context; optional feature flag gating.\n- Complexity & tracing: attaches hints and records timings; log includes `{ specName, version }`.\n\n#### Returns mapping and hydration\n\n- `spec.transport.gql.returns` can declare the GraphQL return wrapper: e.g. `\"Spot\"` or `[Spot]`. If omitted, the adapter infers from `io.output` (SchemaModel) or `resourceRef.graphQLType`.\n- Resource outputs: when `io.output` is a `resourceRef(...)` or `transport.gql.resource` is set, the adapter will optionally hydrate via a `ResourceRegistry` using `contracts-adapter-hydration.ts`:\n - Grammar is parsed with `parseReturns()`.\n - Entities are resolved via `hydrateResourceIfNeeded(resources, result, { template, varName, returns })` after handler execution.\n\n### Resource outputs\n\n- Declare resource outputs using `resourceRef(uriTemplate, opts)`.\n- `opts.varName` (default `id`) selects the identifier field returned by the handler for URI substitution.\n- `opts.graphQLType` is the GraphQL return type name (e.g., `Spot`) or list form (e.g., `[Spot]`).\n- `opts.many: true` indicates the handler returns an array of resources. The handler type becomes an array of items that include the identifier field.\n\nExample:\n\n```ts\nio: {\n input: ListThingsInput,\n output: resourceRef('myapp://thing/{id}', { graphQLType: '[Thing]', many: true }),\n}\n```\n\nHandler return (simplified): `{ id: string | number }[]`.\n\n### Errors\n\n- Validation errors → transport 400/GraphQL UserInputError.\n- Policy/auth errors → 401/403 or GraphQL ForbiddenError.\n- Handler errors → mapped to transport error with safe message.\n\n### Versioning & naming\n\n- Keep `meta.version` monotonic. Clients should pin to a versioned field/key.\n- Avoid renaming existing fields; add new fields with new versions.\n\n### Ownership metadata (OwnerShipMeta)\n\nAll contracts, events, features, and presentations reference a shared ownership schema (source of truth in `packages/lssm/libs/contracts/src/ownership.ts`).\n\n- Required fields: `title`, `description`, `domain`, `owners[]`, `tags[]`, `stability`.\n- Curated enums: the library exports suggested constants for owners and tags; free-form strings are still allowed for forward-compatibility.\n- Operations (`spec.ts`): `meta` requires `stability`, `owners`, and `tags` alongside `name`, `version`, `kind`, `description`, `goal`, and `context`.\n- Presentations V2: `meta` is a partial of ownership plus `description`.\n- Events: may specify `ownership` (recommended) for discoverability and docs.\n\n### Quick start\n\n```ts\n// app bootstrap\nconst reg = new OperationSpecRegistry();\ninstallOp(reg, BeginSignupSpec, beginSignupHandler);\nregisterContractsOnBuilder(gqlSchemaBuilder, reg); // GraphQL\n// or: createRestRouter(reg) // REST\n```\n"
3485
+ }
3486
+ ];
3487
+ registerDocBlocks(tech_contracts_README_DocBlocks);
3488
+
3489
+ // src/docs/tech/contracts/openapi-export.docblock.ts
3490
+ var tech_contracts_openapi_export_DocBlocks = [
3491
+ {
3492
+ id: "docs.tech.contracts.openapi-export",
3493
+ title: "OpenAPI export (OpenAPI 3.1) from OperationSpecRegistry",
3494
+ summary: "Generate a deterministic OpenAPI document from a OperationSpecRegistry using jsonSchemaForSpec + REST transport metadata.",
3495
+ kind: "reference",
3496
+ visibility: "public",
3497
+ route: "/docs/tech/contracts/openapi-export",
3498
+ tags: ["contracts", "openapi", "rest"],
3499
+ body: `## OpenAPI export (OpenAPI 3.1) from OperationSpecRegistry
3500
+
3501
+ ### Purpose
3502
+
3503
+ ContractSpec specs can be exported into an **OpenAPI 3.1** document for tooling (SDK generation, docs, gateways).
3504
+
3505
+ The export is **spec-first**:
3506
+
3507
+ - Uses \`jsonSchemaForSpec(spec)\` for input/output JSON Schema (from SchemaModel → zod → JSON Schema)
3508
+ - Uses \`spec.transport.rest.method/path\` when present
3509
+ - Falls back to deterministic defaults:
3510
+ - Method: \`POST\` for commands, \`GET\` for queries
3511
+ - Path: \`defaultRestPath(name, version)\` → \`/<dot/name>/v<version>\`
3512
+
3513
+ ### Library API
3514
+
3515
+ - Function: \`openApiForRegistry(registry, options?)\`
3516
+ - Location: \`@contractspec/lib.contracts-spec/openapi\`
3517
+
3518
+ ### CLI
3519
+
3520
+ Export OpenAPI from a registry module:
3521
+
3522
+ \`\`\`bash
3523
+ contractspec openapi --registry ./src/registry.ts --out ./openapi.json
3524
+ \`\`\`
3525
+
3526
+ The registry module must export one of:
3527
+
3528
+ - \`registry: OperationSpecRegistry\`
3529
+ - \`default(): OperationSpecRegistry | Promise<OperationSpecRegistry>\`
3530
+ - \`createRegistry(): OperationSpecRegistry | Promise<OperationSpecRegistry>\`
3531
+
3532
+ ### Notes / limitations (current)
3533
+
3534
+ - Responses are generated as a basic \`200\` response (plus schemas when available).
3535
+ - Query (GET) inputs are currently represented as a JSON request body when an input schema exists.
3536
+ - Errors are not yet expanded into OpenAPI responses; that will be added when we standardize error envelopes.`
3537
+ }
3538
+ ];
3539
+ registerDocBlocks(tech_contracts_openapi_export_DocBlocks);
3540
+
3541
+ // src/docs/tech/contracts/openapi-import.docblock.ts
3542
+ var tech_contracts_openapi_import_DocBlocks = [
3543
+ {
3544
+ id: "docs.tech.contracts.openapi-import",
3545
+ title: "OpenAPI Import (OpenAPI 3.1) to ContractSpec",
3546
+ summary: "Import OpenAPI specifications into ContractSpec models, or generate pure Zod/JSON-Schema/GraphQL representations.",
3547
+ kind: "reference",
3548
+ visibility: "public",
3549
+ route: "/docs/tech/contracts/openapi-import",
3550
+ tags: ["contracts", "openapi", "import", "codegen"],
3551
+ body: `## OpenAPI Import (OpenAPI 3.1)
3552
+
3553
+ ### Purpose
3554
+
3555
+ Import external API definitions into your codebase. Supports both one-time scaffolding and multi-format generation for integration.
3556
+
3557
+ ### Modes
3558
+
3559
+ #### 1. ContractSpec Scaffolding (Default)
3560
+
3561
+ Generates standard \`defineSchemaModel\` definitions for full ContractSpec integration.
3562
+
3563
+ \`\`\`bash
3564
+ contractspec openapi import --file api.json --output ./src/contracts
3565
+ \`\`\`
3566
+
3567
+ #### 2. Multi-Format Generation
3568
+
3569
+ Generate schemas in specific formats for direct use in other parts of your stack (adapters, UI, etc.).
3570
+
3571
+ - **Zod**: Pure Zod schemas (\`z.object(...)\`).
3572
+ - **GraphQL**: GraphQL SDL type definitions.
3573
+ - **JSON Schema**: Standard JSON Schema objects.
3574
+
3575
+ \`\`\`bash
3576
+ # Generate Zod schemas suitable for runtime validation
3577
+ contractspec openapi import --file api.json --output ./src/zod --schema-format zod
3578
+ \`\`\`
3579
+
3580
+ ### Library API
3581
+
3582
+ - Function: \`importFromOpenApi(doc, options)\`
3583
+ - Location: \`@contractspec/lib.contracts-transformers/openapi\`
3584
+ - Options:
3585
+ - \`schemaFormat\`: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
3586
+ - \`prefix\`: Prefix for model names
3587
+ - \`tags\`: Filter by OpenAPI tags
3588
+
3589
+ ### CLI
3590
+
3591
+ \`\`\`bash
3592
+ contractspec openapi import --file <path-or-url> --output <dir> [--schema-format <format>]
3593
+ \`\`\`
3594
+ `
3595
+ }
3596
+ ];
3597
+ registerDocBlocks(tech_contracts_openapi_import_DocBlocks);
3598
+
3599
+ // src/workspace-config/workspace-config.docblock.ts
3600
+ var tech_workspace_config_DocBlocks = [
3601
+ {
3602
+ id: "docs.tech.contracts.workspace-config",
3603
+ title: "Workspace Configuration (.contractsrc)",
3604
+ summary: "Configuration-as-code conventions for ContractSpec workspaces (`.contractsrc.json`).",
3605
+ kind: "reference",
3606
+ visibility: "public",
3607
+ route: "/docs/tech/contracts/workspace-config",
3608
+ tags: ["tech", "contracts", "config"],
3609
+ body: `## Workspace Configuration (.contractsrc)
3610
+
3611
+ ContractSpec uses a hierarchical configuration system anchored by \`.contractsrc.json\` files. Configuration loader supports standard rc-file discovery (cosmiconfig).
3612
+
3613
+ ### Schema Formats
3614
+
3615
+ The \`schemaFormat\` option controls the output format of schema generation commands (like \`contractspec openapi import\`).
3616
+
3617
+ Supported formats:
3618
+ - \`contractspec\` (default): Generates standard \`defineSchemaModel\` code.
3619
+ - \`zod\`: Generates raw Zod schemas using \`z.object({...})\`.
3620
+ - \`json-schema\`: Generates JSON Schema definitions.
3621
+ - \`graphql\`: Generates GraphQL SDL type definitions.
3622
+
3623
+ ### Config Interface
3624
+
3625
+ \`\`\`ts
3626
+ export interface ContractsrcConfig {
3627
+ // ... existing fields ...
3628
+ schemaFormat?: 'contractspec' | 'zod' | 'json-schema' | 'graphql';
3629
+ }
3630
+ \`\`\`
3631
+
3632
+ Defined in \`@contractspec/lib.contracts-spec/workspace-config\`.
3633
+ `
3634
+ }
3635
+ ];
3636
+ registerDocBlocks(tech_workspace_config_DocBlocks);
3637
+
3638
+ // src/docs/tech/studio/workspaces.docblock.ts
3639
+ var tech_studio_workspaces_DocBlocks = [
3640
+ {
3641
+ id: "docs.tech.studio.workspaces",
3642
+ title: "Studio projects, teams, environments",
3643
+ summary: "Organization-first Studio: projects live under an organization; teams refine access; projects deploy to multiple environments.",
3644
+ kind: "reference",
3645
+ visibility: "mixed",
3646
+ route: "/docs/tech/studio/workspaces",
3647
+ tags: ["studio", "projects", "teams", "rbac", "environments"],
3648
+ body: `## Concepts
3649
+
3650
+ - **Organization**: the primary grouping boundary for Studio projects.
3651
+ - **Project**: one application (specs, overlays, deployments, integrations, evolution, learning).
3652
+ - **Team**: refines who can see/edit a project within an organization.
3653
+ - **Environment**: deployment target (Development / Staging / Production).
3654
+
3655
+ ## Project access (teams + admin override)
3656
+
3657
+ Studio uses multi-team sharing to refine access:
3658
+
3659
+ - **Admins/owners** can access all projects.
3660
+ - If a project is shared with **no teams**, it is **org-wide** (all org members).
3661
+ - If a project is shared with **one or more teams**, it is visible to:
3662
+ - admins/owners, and
3663
+ - members of any linked team.
3664
+
3665
+ ## Current persistence (DB + GraphQL)
3666
+
3667
+ - DB (Prisma): \`StudioProject\`, \`Team\`, \`TeamMember\`, \`StudioProjectTeam\`
3668
+ - GraphQL:
3669
+ - \`myStudioProjects\`
3670
+ - \`createStudioProject(input.teamIds?)\`
3671
+ - \`myTeams\`
3672
+ - \`projectTeams(projectId)\`
3673
+ - \`setProjectTeams(projectId, teamIds)\`
3674
+
3675
+ ## UI shell behavior
3676
+
3677
+ Studio and Sandbox both use a shared shell:
3678
+
3679
+ - Project selector → Module navigation → Environment selector
3680
+ - Always-on Assistant button (floating)
3681
+ - Learning journey progress (Studio persists learning events; Sandbox stays local-only)
3682
+
3683
+ ## Routing
3684
+
3685
+ - \`/studio/projects\`: create/select/delete projects (organization-first).
3686
+ - \`/studio/{projectSlug}/*\`: project modules (canvas/specs/deploy/integrations/evolution/learning).
3687
+ - \`/studio/learning\`: learning hub without selecting a project.
3688
+ `
3689
+ }
3690
+ ];
3691
+ registerDocBlocks(tech_studio_workspaces_DocBlocks);
3692
+
3693
+ // src/docs/tech/studio/sandbox-unlogged.docblock.ts
3694
+ var tech_studio_sandbox_unlogged_DocBlocks = [
3695
+ {
3696
+ id: "docs.tech.studio.sandbox.unlogged",
3697
+ title: "Sandbox (unlogged) vs Studio (authenticated)",
3698
+ summary: "The sandbox is a lightweight, unlogged surface that mirrors Studio navigation without auth or analytics.",
3699
+ kind: "reference",
3700
+ visibility: "public",
3701
+ route: "/docs/tech/studio/sandbox-unlogged",
3702
+ tags: ["studio", "sandbox", "privacy", "analytics"],
3703
+ body: `## Sandbox guarantees
3704
+
3705
+ - Route: \`/sandbox\`
3706
+ - **No auth requirement**
3707
+ - **No PostHog init**
3708
+ - **No Vercel Analytics**
3709
+ - Local-only state (in-browser runtime + localStorage where needed)
3710
+
3711
+ ## What Sandbox is for
3712
+
3713
+ - Try templates and feature modules safely
3714
+ - Preview specs/builder/evolution/learning
3715
+ - Produce copyable CLI commands (no side effects)
3716
+
3717
+ ## What Sandbox is *not* for
3718
+
3719
+ - Persisted projects/workspaces
3720
+ - Real deployments
3721
+ - Organization-scoped integrations (unless explicitly enabled later)
3722
+ `
3723
+ }
3724
+ ];
3725
+ registerDocBlocks(tech_studio_sandbox_unlogged_DocBlocks);
3726
+
3727
+ // src/docs/tech/studio/workspace-ops.docblock.ts
3728
+ var tech_studio_workspace_ops_DocBlocks = [
3729
+ {
3730
+ id: "docs.tech.studio.workspace_ops",
3731
+ title: "Workspace ops (repo-linked): list / validate / deps / diff",
3732
+ summary: "Read-only repo operations used by Studio to inspect and validate a linked ContractSpec workspace.",
3733
+ kind: "reference",
3734
+ visibility: "mixed",
3735
+ route: "/docs/tech/studio/workspace-ops",
3736
+ tags: ["studio", "repo", "workspace", "validate", "diff"],
3737
+ body: `## API surface (api-contractspec)
3738
+
3739
+ Base: \`/api/workspace-ops\`
3740
+
3741
+ These endpoints are **read-only** in v1 and never push to git:
3742
+
3743
+ - \`GET /api/workspace-ops/:integrationId/config?organizationId=\`
3744
+ - \`GET /api/workspace-ops/:integrationId/specs?organizationId=\`
3745
+ - \`POST /api/workspace-ops/:integrationId/validate\` (body: organizationId, files?, pattern?)
3746
+ - \`POST /api/workspace-ops/:integrationId/deps\` (body: organizationId, pattern?)
3747
+ - \`POST /api/workspace-ops/:integrationId/diff\` (body: organizationId, specPath, baseline?, breakingOnly?)
3748
+
3749
+ ## Repo resolution
3750
+
3751
+ - The repo root is resolved from the Studio Integration (\`IntegrationProvider.GITHUB\`) config:
3752
+ - \`config.repoCachePath\` (preferred) or \`config.localPath\`
3753
+ - Resolution is constrained to \`CONTRACTSPEC_REPO_CACHE_DIR\` (default: \`/tmp/contractspec-repos\`)
3754
+
3755
+ ## Intended UX
3756
+
3757
+ - Studio Assistant can run these checks and present results as suggestions.
3758
+ - Users can copy equivalent CLI commands for local runs:
3759
+ - \`contractspec validate\`
3760
+ - \`contractspec deps\`
3761
+ - \`contractspec diff --baseline <ref>\`
3762
+ `
3763
+ }
3764
+ ];
3765
+ registerDocBlocks(tech_studio_workspace_ops_DocBlocks);
3766
+
3767
+ // src/docs/tech/studio/project-routing.docblock.ts
3768
+ var tech_studio_project_routing_DocBlocks = [
3769
+ {
3770
+ id: "docs.tech.studio.project-routing",
3771
+ title: "Studio Project Routing",
3772
+ summary: "Studio uses slugged, project-first routes: /studio/{projectSlug}/* with canonical slug redirects and soft-deleted projects hidden.",
3773
+ kind: "reference",
3774
+ visibility: "public",
3775
+ route: "/docs/tech/studio/project-routing",
3776
+ tags: ["studio", "routing", "projects", "slug", "redirects"],
3777
+ body: `# Studio Project Routing
3778
+
3779
+ ContractSpec Studio uses a **project-first URL scheme**:
3780
+
3781
+ - \`/studio/projects\` — create, select, and delete projects.
3782
+ - \`/studio/{projectSlug}/*\` — project modules (canvas/specs/deploy/integrations/evolution/learning).
3783
+ - \`/studio/learning\` — learning hub that does not require selecting a project.
3784
+
3785
+ ## Studio layout shell
3786
+
3787
+ Studio routes are wrapped in a dedicated **Studio app shell** (header + footer) that provides in-app navigation (Projects/Learning/Teams), organization switching, and account actions.
3788
+
3789
+ Project module routes (\`/studio/{projectSlug}/*\`) render their own module shell (\`WorkspaceProjectShellLayout\`). When combined with the global Studio header, the project shell uses a **sticky header offset** to avoid overlapping sticky headers.
3790
+
3791
+ ## Slug behavior (rename-safe)
3792
+
3793
+ - Each project has a \`slug\` stored in the database (\`StudioProject.slug\`).
3794
+ - When a project name changes, Studio **updates the slug** and stores the previous slug as an alias (\`StudioProjectSlugAlias\`).
3795
+ - Requests to an alias slug are **redirected to the canonical slug**.
3796
+
3797
+ GraphQL entrypoint:
3798
+
3799
+ - \`studioProjectBySlug(slug: String!)\` returns:
3800
+ - \`project\`
3801
+ - \`canonicalSlug\`
3802
+ - \`wasRedirect\`
3803
+
3804
+ ## Deletion behavior (soft delete)
3805
+
3806
+ Projects are **soft-deleted**:
3807
+
3808
+ - \`deleteStudioProject(id: String!)\` sets \`StudioProject.deletedAt\`.
3809
+ - All listings and access checks filter \`deletedAt = null\`.
3810
+ - Soft-deleted projects are treated as “not found” in Studio routes and GraphQL access checks.
3811
+
3812
+ ## Available modules for a selected project
3813
+
3814
+ The following project modules are expected under \`/studio/{projectSlug}\`:
3815
+
3816
+ - \`/canvas\` — Visual builder canvas (stored via overlays and canvas versions).
3817
+ - \`/specs\` — Spec editor (stored as \`StudioSpec\`).
3818
+ - \`/deploy\` — Deployments history + triggers (stored as \`StudioDeployment\`).
3819
+ - \`/integrations\` — Integrations scoped to project (stored as \`StudioIntegration\`).
3820
+ - \`/evolution\` — Evolution sessions (stored as \`EvolutionSession\`).
3821
+ - \`/learning\` — Project learning activity.
3822
+ `
3823
+ }
3824
+ ];
3825
+ registerDocBlocks(tech_studio_project_routing_DocBlocks);
3826
+
3827
+ // src/docs/tech/studio/platform-admin-panel.docblock.ts
3828
+ var tech_studio_platform_admin_panel_DocBlocks = [
3829
+ {
3830
+ id: "docs.tech.studio.platform-admin-panel",
3831
+ title: "Studio Platform Admin Panel",
3832
+ summary: "How PLATFORM_ADMIN organizations manage tenant orgs and integration connections without session switching.",
3833
+ kind: "reference",
3834
+ visibility: "public",
3835
+ route: "/docs/tech/studio/platform-admin-panel",
3836
+ tags: ["studio", "admin", "multi-tenancy", "integrations", "better-auth"],
3837
+ body: `# Studio Platform Admin Panel
3838
+
3839
+ ContractSpec Studio exposes a dedicated **Platform Admin Panel** for users whose **active organization** has:
3840
+
3841
+ - \`Organization.type = PLATFORM_ADMIN\`
3842
+
3843
+ The UI route is:
3844
+
3845
+ - \`/studio/admin\`
3846
+
3847
+ ## Authorization model (no org switching)
3848
+
3849
+ Platform admins **remain in their own organization**. Cross-tenant actions are always explicit and scoped:
3850
+
3851
+ - Admin operations require an explicit \`targetOrganizationId\`.
3852
+ - No session / activeOrganizationId switching is performed as part of admin operations.
3853
+
3854
+ ## Integrations management
3855
+
3856
+ The admin panel manages the full ContractSpec Integrations system:
3857
+
3858
+ - Lists all shipped \`IntegrationSpec\` entries (registry built via \`createDefaultIntegrationSpecRegistry()\`).
3859
+ - CRUD \`IntegrationConnection\` records for a selected tenant org.
3860
+
3861
+ ### Secrets (reference-only + write-only)
3862
+
3863
+ The admin UI supports two modes:
3864
+
3865
+ - **Reference-only (BYOK)**: store only \`secretProvider\` + \`secretRef\`.
3866
+ - **Write-only provisioning/rotation**: paste a raw secret payload; server writes to the selected backend and stores the resulting reference. The secret value is **never returned or displayed**.
3867
+
3868
+ Supported backends:
3869
+
3870
+ - Env overrides (\`env://...\`)
3871
+ - Google Cloud Secret Manager (\`gcp://...\`)
3872
+ - AWS Secrets Manager (\`aws://secretsmanager/...\`)
3873
+ - Scaleway Secret Manager (\`scw://secret-manager/...\`)
3874
+
3875
+ ## Better Auth Admin plugin
3876
+
3877
+ The panel uses the Better Auth **Admin plugin** for user operations (list users, impersonation):
3878
+
3879
+ - Client calls use \`authClient.admin.*\`.
3880
+ - Server-side, ContractSpec enforces that users in a PLATFORM_ADMIN active org have \`User.role\` containing \`admin\` so Better Auth Admin endpoints authorize.
3881
+
3882
+ ## GraphQL surface
3883
+
3884
+ The platform-admin GraphQL operations are guarded by the active org type and include:
3885
+
3886
+ - \`platformAdminOrganizations(search, limit, offset)\`
3887
+ - \`platformAdminIntegrationSpecs\`
3888
+ - \`platformAdminIntegrationConnections(input: { targetOrganizationId, category?, status? })\`
3889
+ - \`platformAdminIntegrationConnectionCreate(input)\`
3890
+ - \`platformAdminIntegrationConnectionUpdate(input)\`
3891
+ - \`platformAdminIntegrationConnectionDelete(targetOrganizationId, connectionId)\`
3892
+
3893
+ ## Key implementation files
3894
+
3895
+ - Auth + role enforcement: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
3896
+ - Admin GraphQL module: \`packages/bundles/contractspec-studio/src/infrastructure/graphql/modules/platform-admin.ts\`
3897
+ - Integrations admin service: \`packages/bundles/contractspec-studio/src/modules/platform-integrations/index.ts\`
3898
+ - Web route: \`packages/apps/web-landing/src/app/(app-customer)/studio/admin/*\`
3899
+ `
3900
+ }
3901
+ ];
3902
+ registerDocBlocks(tech_studio_platform_admin_panel_DocBlocks);
3903
+
3904
+ // src/docs/tech/studio/learning-events.docblock.ts
3905
+ var tech_studio_learning_events_DocBlocks = [
3906
+ {
3907
+ id: "docs.tech.studio.learning-events",
3908
+ title: "Studio Learning Events",
3909
+ summary: "Studio persists learning/activity events to the database; Sandbox keeps learning local-first and unlogged.",
3910
+ kind: "reference",
3911
+ visibility: "public",
3912
+ route: "/docs/tech/studio/learning-events",
3913
+ tags: ["studio", "learning", "events", "analytics", "sandbox"],
3914
+ body: `# Studio Learning Events
3915
+
3916
+ Studio emits lightweight **learning/activity events** to support onboarding, ambient coaching, and learning journeys.
3917
+
3918
+ ## Persistence model
3919
+
3920
+ - **Studio**: events are persisted to the database in \`StudioLearningEvent\` and are organization-scoped (optionally project-scoped).
3921
+ - **Sandbox**: events remain **local-only** (unlogged); they must never be sent to backend services.
3922
+
3923
+ ## GraphQL API
3924
+
3925
+ - \`recordLearningEvent(input: { name, projectId?, payload? })\`
3926
+ - \`myLearningEvents(projectId?, limit?)\`
3927
+ - \`myOnboardingTracks(productId?, includeProgress?)\`
3928
+ - \`myOnboardingProgress(trackKey)\`
3929
+ - \`dismissOnboardingTrack(trackKey)\`
3930
+
3931
+ ## Common event names (convention)
3932
+
3933
+ - \`module.navigated\` — user navigated to a Studio module (payload at minimum: \`{ moduleId }\`).
3934
+ - \`studio.template.instantiated\` — created a new Studio project (starter template). Payload commonly includes \`{ templateId, projectSlug }\`.
3935
+ - \`spec.changed\` — created or updated a Studio spec. Payload may include \`{ action: 'create' | 'update', specId?, specType? }\`.
3936
+ - \`regeneration.completed\` — finished a “regen/deploy” action (currently emitted on successful Studio deploy actions).
3937
+ - \`studio.evolution.applied\` — completed an Evolution session (payload commonly includes \`{ evolutionSessionId }\`).
3938
+
3939
+ These events are intentionally minimal and must avoid PII/secrets in payloads.
3940
+ `
3941
+ }
3942
+ ];
3943
+ registerDocBlocks(tech_studio_learning_events_DocBlocks);
3944
+
3945
+ // src/docs/tech/studio/learning-journeys.docblock.ts
3946
+ var tech_studio_learning_journeys_DocBlocks = [
3947
+ {
3948
+ id: "docs.tech.studio.learning-journeys",
3949
+ title: "Studio learning journeys (onboarding + coach)",
3950
+ summary: "DB-backed learning journeys tracked per organization: seeded tracks/steps, event-driven progress, XP/streaks, and a Studio coach surface.",
3951
+ kind: "reference",
3952
+ visibility: "public",
3953
+ route: "/docs/tech/studio/learning-journeys",
3954
+ tags: [
3955
+ "studio",
3956
+ "learning",
3957
+ "onboarding",
3958
+ "journey",
3959
+ "graphql",
3960
+ "database"
3961
+ ],
3962
+ body: `# Studio learning journeys
3963
+
3964
+ Studio supports **DB-backed learning journeys** (onboarding tracks + ambient coach tips) that are advanced by **recorded learning events**.
3965
+
3966
+ > See also: \`/docs/tech/studio/learning-events\` for event naming + payload guardrails.
3967
+
3968
+ ## Scope (multi-tenancy)
3969
+
3970
+ - Progress is tracked **per organization** (tenant/workspace), via a \`Learner\` record keyed by \`(userId, organizationId)\`.
3971
+ - Learning events are stored as \`StudioLearningEvent\` under the Studio DB schema, scoped to an organization (optionally a project).
3972
+
3973
+ ## Persistence model (Prisma)
3974
+
3975
+ Learning journey progress lives in the \`lssm_learning\` schema:
3976
+
3977
+ - \`Learner\` — one per \`(userId, organizationId)\`
3978
+ - \`OnboardingTrack\` — seeded track definitions (trackKey, name, metadata)
3979
+ - \`OnboardingStep\` — seeded step definitions (stepKey, completionCondition, xpReward, metadata)
3980
+ - \`OnboardingProgress\` — learner × track progress (progress %, xpEarned, completedAt, dismissedAt)
3981
+ - \`OnboardingStepCompletion\` — append-only completion records (stepKey, status, xpEarned, completedAt)
3982
+
3983
+ ## Track definition source (spec-first)
3984
+
3985
+ - Canonical track specs live in \`@contractspec/example.learning-journey-registry\`.
3986
+ - The Studio API seeds/updates the DB definitions via an idempotent “ensure tracks” routine.
3987
+ - The DB is kept aligned with track specs (stale steps are removed) to prevent drift and unblock completion.
3988
+
3989
+ ## Progress advancement (event-driven)
3990
+
3991
+ 1) UI records an event via GraphQL \`recordLearningEvent\`
3992
+ 2) Backend creates \`StudioLearningEvent\`
3993
+ 3) Backend advances onboarding by matching the new event against step completion conditions
3994
+ 4) Backend persists step completions and recomputes:
3995
+ - \`progress\` percentage
3996
+ - \`xpEarned\` (including streak/completion bonuses when configured)
3997
+ - track completion state (\`completedAt\`)
3998
+
3999
+ ## GraphQL API (Studio)
4000
+
4001
+ - \`myOnboardingTracks(productId?, includeProgress?)\`
4002
+ - returns all tracks + optional progress for the current learner
4003
+ - \`myOnboardingProgress(trackKey)\`
4004
+ - returns progress + step completion list for a single track
4005
+ - \`dismissOnboardingTrack(trackKey)\`
4006
+ - marks a track dismissed for the learner (prevents auto-coach)
4007
+
4008
+ ## UI routes/surfaces (web)
4009
+
4010
+ - \`/studio/learning\` — learning hub (track list + progress widget)
4011
+ - \`/studio/learning/{trackKey}\` — track detail (steps + map)
4012
+ - Studio shell mounts a **coach sheet** that can auto-open for incomplete, non-dismissed onboarding.
4013
+
4014
+ ## Security + data hygiene
4015
+
4016
+ - Do not put secrets/PII in \`payload\` fields of learning events.
4017
+ - Prefer shallow payload filters (small, stable keys).
4018
+ `
4019
+ }
4020
+ ];
4021
+ registerDocBlocks(tech_studio_learning_journeys_DocBlocks);
4022
+
4023
+ // src/docs/tech/studio/project-access-teams.docblock.ts
4024
+ var tech_studio_project_access_teams_DocBlocks = [
4025
+ {
4026
+ id: "docs.tech.studio.project-access-teams",
4027
+ title: "Studio Project Access via Teams",
4028
+ summary: "Projects live under organizations; team sharing refines access with an admin/owner override.",
4029
+ kind: "reference",
4030
+ visibility: "public",
4031
+ route: "/docs/tech/studio/project-access-teams",
4032
+ tags: ["studio", "projects", "teams", "rbac", "access-control"],
4033
+ body: `# Studio Project Access via Teams
4034
+
4035
+ Studio access control is **organization-first** with optional **team-based sharing**.
4036
+
4037
+ ## Data model
4038
+
4039
+ - \`Team\` and \`TeamMember\` define team membership inside an organization.
4040
+ - \`StudioProject\` is owned by an organization.
4041
+ - \`StudioProjectTeam\` links projects to 0..N teams.
4042
+
4043
+ ## Access rules
4044
+
4045
+ - **Admins/owners**: always have access to all projects in the organization.
4046
+ - **Org-wide projects**: if a project has **no team links**, all organization members can access it.
4047
+ - **Team-scoped projects**: if a project has **one or more team links**, a user must be a member of at least one linked team.
4048
+
4049
+ ## GraphQL surfaces
4050
+
4051
+ - Read:
4052
+ - \`myStudioProjects\` (returns only projects you can access)
4053
+ - \`studioProjectBySlug(slug)\` (enforces the same access rules)
4054
+ - \`myTeams\`
4055
+ - \`projectTeams(projectId)\`
4056
+
4057
+ - Write:
4058
+ - \`createStudioProject(input.teamIds?)\` (teamIds optional)
4059
+ - \`setProjectTeams(projectId, teamIds)\` (admin-only)
4060
+
4061
+
4062
+ ## Related
4063
+ +
4064
+ +- Team administration + invitations: see \`/docs/tech/studio/team-invitations\`.
4065
+ +
4066
+ ## Notes
4067
+
4068
+ Payloads and events must avoid secrets/PII. For Sandbox, the model remains local-first and unlogged.
4069
+ `
4070
+ }
4071
+ ];
4072
+ registerDocBlocks(tech_studio_project_access_teams_DocBlocks);
4073
+
4074
+ // src/docs/tech/studio/team-invitations.docblock.ts
4075
+ var tech_studio_team_invitations_DocBlocks = [
4076
+ {
4077
+ id: "docs.tech.studio.team-invitations",
4078
+ title: "Studio Teams & Invitations",
4079
+ summary: "Admin-only team management and email invitation flow to join an organization and optionally a team.",
4080
+ kind: "reference",
4081
+ visibility: "public",
4082
+ route: "/docs/tech/studio/team-invitations",
4083
+ tags: ["studio", "teams", "invitations", "access-control", "onboarding"],
4084
+ body: `# Studio Teams & Invitations
4085
+
4086
+ Studio uses **organization membership** as the base access model. Teams are optional and used to refine access to projects.
4087
+
4088
+ ## Who can manage teams?
4089
+
4090
+ - **Admins/owners only**: create, rename, delete teams; manage project team access; issue invitations.
4091
+
4092
+ ## Invitation data model
4093
+
4094
+ - \`Invitation\` rows are stored under an organization and target an **email** address.
4095
+
4096
+ - An invitation can optionally target a \`teamId\`, which will grant the user membership in that team upon acceptance.
4097
+
4098
+ Key fields:
4099
+ - \`email\`: invited address (must match the accepting user's account email)
4100
+
4101
+ - \`status\`: \`pending | accepted | declined | expired\`
4102
+
4103
+ - \`teamId?\`: optional team to join
4104
+
4105
+ - \`inviterId\`: user who issued the invitation
4106
+
4107
+ ## GraphQL surfaces
4108
+
4109
+ - Team CRUD (admin-only):
4110
+
4111
+ - \`createTeam(name)\`
4112
+
4113
+ - \`renameTeam(teamId, name)\`
4114
+
4115
+ - \`deleteTeam(teamId)\`
4116
+
4117
+
4118
+ - Invitations (admin-only):
4119
+
4120
+ - \`organizationInvitations\`
4121
+
4122
+ - \`inviteToOrganization(email, role?, teamId?)\` → returns \`inviteUrl\` and whether an email was sent
4123
+
4124
+ ## Accepting an invitation
4125
+
4126
+ The invite link is served as:
4127
+
4128
+ - \`/invite/{invitationId}\`
4129
+
4130
+ Acceptance rules:
4131
+ - The user must be authenticated.
4132
+
4133
+ - The authenticated user’s email must match \`Invitation.email\`.
4134
+
4135
+ - If not already a member, create \`Member(userId, organizationId, role)\`.
4136
+
4137
+ - If \`teamId\` is present, ensure \`TeamMember(teamId, userId)\`.
4138
+
4139
+ - Mark invitation \`status='accepted'\` and set \`acceptedAt\`.
4140
+
4141
+ - Set \`activeOrganizationId\` for the session so \`/studio/*\` routes work immediately.
4142
+
4143
+ ## Email delivery
4144
+
4145
+ - If \`RESEND_API_KEY\` is set, the system attempts to send an email.
4146
+
4147
+ - Otherwise, the UI uses the returned \`inviteUrl\` for manual copy/share.
4148
+ `
4149
+ }
4150
+ ];
4151
+ registerDocBlocks(tech_studio_team_invitations_DocBlocks);
4152
+
4153
+ // src/docs/tech/llm/llm-integration.docblock.ts
4154
+ var tech_llm_integration_DocBlocks = [
4155
+ {
4156
+ id: "docs.tech.llm.overview",
4157
+ title: "LLM Integration Overview",
4158
+ summary: "Export specs to LLM-friendly formats, generate implementation guides, and verify implementations.",
4159
+ kind: "reference",
4160
+ visibility: "public",
4161
+ route: "/docs/tech/llm/overview",
4162
+ tags: ["llm", "ai", "export", "guide", "verify"],
4163
+ body: `# LLM Integration
4164
+
4165
+ ContractSpec provides first-class LLM integration to bridge specifications and AI coding agents.
4166
+
4167
+ ## Core Features
4168
+
4169
+ ### 1. Multi-Format Export
4170
+
4171
+ Export specs to markdown in formats optimized for LLM consumption:
4172
+
4173
+ - **Context format**: Summary for understanding (goal, context, acceptance criteria)
4174
+ - **Full format**: Complete spec with all details (I/O schemas, policy, events)
4175
+ - **Prompt format**: Actionable prompt with implementation instructions
4176
+
4177
+ ### 2. Implementation Guidance
4178
+
4179
+ Generate agent-specific implementation plans:
4180
+
4181
+ - **Claude Code**: Extended thinking mode with structured prompts
4182
+ - **Cursor CLI**: Background/composer mode with .mdc rules generation
4183
+ - **Generic MCP**: Standard format for any MCP-compatible agent
4184
+
4185
+ ### 3. Tiered Verification
4186
+
4187
+ Verify implementations against specs:
4188
+
4189
+ - **Tier 1 (Structure)**: Types, exports, imports validation
4190
+ - **Tier 2 (Behavior)**: Scenario coverage, error handling, events
4191
+ - **Tier 3 (AI Review)**: Semantic compliance analysis via LLM
4192
+
4193
+ ## Access Points
4194
+
4195
+ | Surface | Commands/Tools |
4196
+ |---------|---------------|
4197
+ | CLI | \`contractspec llm export\`, \`guide\`, \`verify\`, \`copy\` |
4198
+ | MCP | \`llm.export\`, \`llm.guide\`, \`llm.verify\` tools |
4199
+ | VSCode | Export to LLM, Generate Guide, Verify, Copy commands |
4200
+
4201
+ ## Quick Start
4202
+
4203
+ ### CLI Usage
4204
+
4205
+ \`\`\`bash
4206
+ # Export spec as markdown
4207
+ contractspec llm export path/to/my.spec.ts --format full
4208
+
4209
+ # Generate implementation guide
4210
+ contractspec llm guide path/to/my.spec.ts --agent claude-code
4211
+
4212
+ # Verify implementation
4213
+ contractspec llm verify path/to/my.spec.ts path/to/impl.ts --tier 2
4214
+
4215
+ # Copy spec to clipboard
4216
+ contractspec llm copy path/to/my.spec.ts --format context
4217
+ \`\`\`
4218
+
4219
+ ### MCP Usage
4220
+
4221
+ \`\`\`
4222
+ # Export spec
4223
+ llm.export { specPath: "path/to/my.spec.ts", format: "full" }
4224
+
4225
+ # Generate guide
4226
+ llm.guide { specPath: "path/to/my.spec.ts", agent: "cursor-cli" }
4227
+
4228
+ # Verify implementation
4229
+ llm.verify { specPath: "path/to/my.spec.ts", implementationPath: "path/to/impl.ts", tier: "2" }
4230
+ \`\`\`
4231
+
4232
+ ### Programmatic Usage
4233
+
4234
+ \`\`\`typescript
4235
+ import { operationSpecToFullMarkdown, operationSpecToAgentPrompt } from '@contractspec/lib.contracts-spec/llm';
4236
+ import { createAgentGuideService, createVerifyService } from '@contractspec/bundle.workspace';
4237
+
4238
+ // Export
4239
+ const markdown = operationSpecToFullMarkdown(mySpec);
4240
+
4241
+ // Generate guide
4242
+ const guideService = createAgentGuideService({ defaultAgent: 'claude-code' });
4243
+ const guide = guideService.generateGuide(mySpec);
4244
+
4245
+ // Verify
4246
+ const verifyService = createVerifyService();
4247
+ const result = await verifyService.verify(mySpec, implementationCode, {
4248
+ tiers: ['structure', 'behavior']
4249
+ });
4250
+ \`\`\`
4251
+ `
4252
+ },
4253
+ {
4254
+ id: "docs.tech.llm.export-formats",
4255
+ title: "LLM Export Formats",
4256
+ summary: "Detailed explanation of the three export formats for LLM consumption.",
4257
+ kind: "reference",
4258
+ visibility: "public",
4259
+ route: "/docs/tech/llm/export-formats",
4260
+ tags: ["llm", "export", "markdown"],
4261
+ body: `# LLM Export Formats
4262
+
4263
+ ContractSpec provides three export formats optimized for different LLM use cases.
4264
+
4265
+ ## Context Format
4266
+
4267
+ Best for: Understanding what a spec does, providing background to LLMs.
4268
+
4269
+ Includes:
4270
+ - Spec name, version, type
4271
+ - Goal and context
4272
+ - Description
4273
+ - Acceptance scenarios
4274
+
4275
+ Example:
4276
+
4277
+ \`\`\`markdown
4278
+ # users.createUser (v1)
4279
+
4280
+ > Create a new user account with email verification.
4281
+
4282
+ **Type:** command | **Stability:** stable
4283
+
4284
+ ## Goal
4285
+ Create a new user in the system and trigger email verification.
4286
+
4287
+ ## Context
4288
+ Part of the user onboarding flow. Called after signup form submission.
4289
+
4290
+ ## Acceptance Criteria
4291
+ ### Happy path
4292
+ **Given:** Valid email and password
4293
+ **When:** User submits registration
4294
+ **Then:** Account is created, verification email is sent
4295
+ \`\`\`
4296
+
4297
+ ## Full Format
4298
+
4299
+ Best for: Complete documentation, implementation reference.
4300
+
4301
+ Includes everything:
4302
+ - All metadata
4303
+ - JSON schemas for I/O
4304
+ - Error definitions
4305
+ - Policy (auth, rate limits, PII)
4306
+ - Events emitted
4307
+ - Examples
4308
+ - Transport configuration
4309
+
4310
+ ## Prompt Format
4311
+
4312
+ Best for: Feeding directly to coding agents.
4313
+
4314
+ Includes:
4315
+ - Task header with clear instructions
4316
+ - Full spec context
4317
+ - Implementation requirements
4318
+ - Task-specific guidance (implement/test/refactor/review)
4319
+ - Expected output format
4320
+
4321
+ The prompt format adapts based on task type:
4322
+ - **implement**: Full implementation with tests
4323
+ - **test**: Test generation for existing code
4324
+ - **refactor**: Refactoring while maintaining behavior
4325
+ - **review**: Code review against spec
4326
+ `
4327
+ },
4328
+ {
4329
+ id: "docs.tech.llm.agent-adapters",
4330
+ title: "Agent Adapters",
4331
+ summary: "Adapters for different AI coding agents (Claude, Cursor, MCP).",
4332
+ kind: "reference",
4333
+ visibility: "public",
4334
+ route: "/docs/tech/llm/agent-adapters",
4335
+ tags: ["llm", "agents", "claude", "cursor", "mcp"],
4336
+ body: `# Agent Adapters
4337
+
4338
+ ContractSpec provides specialized adapters for different AI coding agents.
4339
+
4340
+ ## Claude Code Adapter
4341
+
4342
+ Optimized for Anthropic Claude's extended thinking and code generation.
4343
+
4344
+ Features:
4345
+ - Structured markdown with clear sections
4346
+ - Checklists for steps and verification
4347
+ - Icons for file operations (\uD83D\uDCDD create, ✏️ modify)
4348
+ - System prompt for ContractSpec context
4349
+
4350
+ Usage:
4351
+ \`\`\`typescript
4352
+ const guideService = createAgentGuideService({ defaultAgent: 'claude-code' });
4353
+ const result = guideService.generateGuide(spec, { agent: 'claude-code' });
4354
+ // result.prompt.systemPrompt - Claude system context
4355
+ // result.prompt.taskPrompt - Task-specific instructions
4356
+ \`\`\`
4357
+
4358
+ ## Cursor CLI Adapter
4359
+
4360
+ Optimized for Cursor's background/composer mode.
4361
+
4362
+ Features:
4363
+ - Compact format for context efficiency
4364
+ - .mdc cursor rules generation
4365
+ - Integration with Cursor's file system
4366
+ - Concise step lists
4367
+
4368
+ Generate Cursor Rules:
4369
+ \`\`\`typescript
4370
+ const cursorRules = guideService.generateAgentConfig(spec, 'cursor-cli');
4371
+ // Save to .cursor/rules/my-spec.mdc
4372
+ \`\`\`
4373
+
4374
+ ## Generic MCP Adapter
4375
+
4376
+ Works with any MCP-compatible agent (Cline, Aider, etc.).
4377
+
4378
+ Features:
4379
+ - Standard markdown format
4380
+ - Table-based metadata
4381
+ - JSON resource format support
4382
+ - Prompt message format
4383
+
4384
+ The generic adapter is the default and works across all agents.
4385
+
4386
+ ## Choosing an Adapter
4387
+
4388
+ | Agent | Best For | Key Features |
4389
+ |-------|----------|--------------|
4390
+ | Claude Code | Complex implementations | Extended thinking, detailed steps |
4391
+ | Cursor CLI | IDE-integrated work | Cursor rules, compact format |
4392
+ | Generic MCP | Any MCP agent | Universal compatibility |
4393
+ `
4394
+ },
4395
+ {
4396
+ id: "docs.tech.llm.verification",
4397
+ title: "Implementation Verification",
4398
+ summary: "Tiered verification of implementations against specifications.",
4399
+ kind: "reference",
4400
+ visibility: "public",
4401
+ route: "/docs/tech/llm/verification",
4402
+ tags: ["llm", "verify", "validation", "testing"],
4403
+ body: `# Implementation Verification
4404
+
4405
+ ContractSpec provides tiered verification to check if implementations comply with specs.
4406
+
4407
+ ## Verification Tiers
4408
+
4409
+ ### Tier 1: Structure (Fast)
4410
+
4411
+ Checks TypeScript structure against spec requirements:
4412
+
4413
+ | Check | What it validates |
4414
+ |-------|------------------|
4415
+ | Handler export | Function is properly exported |
4416
+ | Contracts import | Imports from @contractspec/lib.contracts-spec |
4417
+ | Schema import | Imports from @contractspec/lib.schema |
4418
+ | No \`any\` type | TypeScript strict compliance |
4419
+ | Error handling | Error codes are referenced |
4420
+ | Event emission | Event patterns exist |
4421
+ | Input validation | Validation patterns used |
4422
+ | Async patterns | Async/await for commands |
4423
+
4424
+ ### Tier 2: Behavior (Comprehensive)
4425
+
4426
+ Checks implementation coverage of spec behaviors:
4427
+
4428
+ | Check | What it validates |
4429
+ |-------|------------------|
4430
+ | Scenario coverage | Acceptance scenarios implemented |
4431
+ | Example coverage | Example I/O values referenced |
4432
+ | Error cases | All error conditions handled |
4433
+ | Event conditions | Events emitted correctly |
4434
+ | Idempotency | Idempotent patterns (if required) |
4435
+
4436
+ ### Tier 3: AI Review (Deep)
4437
+
4438
+ Uses LLM for semantic analysis:
4439
+
4440
+ - Does the implementation fulfill the spec's intent?
4441
+ - Are edge cases properly handled?
4442
+ - Is the code quality acceptable?
4443
+ - Are there any subtle violations?
4444
+
4445
+ Requires AI API key configuration.
4446
+
4447
+ ## Running Verification
4448
+
4449
+ \`\`\`typescript
4450
+ const verifyService = createVerifyService({
4451
+ aiApiKey: process.env.ANTHROPIC_API_KEY, // Optional, for Tier 3
4452
+ aiProvider: 'anthropic',
4453
+ });
4454
+
4455
+ const result = await verifyService.verify(spec, implementationCode, {
4456
+ tiers: ['structure', 'behavior'],
4457
+ failFast: false,
4458
+ includeSuggestions: true,
4459
+ });
4460
+
4461
+ console.log(result.passed); // true/false
4462
+ console.log(result.score); // 0-100
4463
+ console.log(result.summary); // Human-readable summary
4464
+ \`\`\`
4465
+
4466
+ ## Verification Report
4467
+
4468
+ The report includes:
4469
+
4470
+ - **passed**: Overall compliance
4471
+ - **score**: 0-100 score
4472
+ - **issues**: Array of problems found
4473
+ - **suggestions**: Recommended fixes
4474
+ - **coverage**: Metrics on scenario/error/field coverage
4475
+
4476
+ Each issue has:
4477
+ - **severity**: error, warning, or info
4478
+ - **category**: type, export, import, scenario, error_handling, semantic
4479
+ - **message**: Description of the issue
4480
+ - **suggestion**: How to fix it
4481
+ `
4482
+ }
4483
+ ];
4484
+ registerDocBlocks(tech_llm_integration_DocBlocks);
4485
+
4486
+ // src/docs/tech/cli.docblock.ts
4487
+ var tech_cli_DocBlocks = [
4488
+ {
4489
+ id: "docs.tech.cli.contractspec",
4490
+ title: "ContractSpec CLI",
4491
+ summary: "The command-line interface for creating, building, and validating contract specifications.",
4492
+ kind: "reference",
4493
+ visibility: "public",
4494
+ route: "/docs/tech/cli/contractspec",
4495
+ tags: ["cli", "tooling", "reference"],
4496
+ owners: ["@contractspec/app.cli-contractspec"],
4497
+ body: `# ContractSpec CLI
4498
+
4499
+ The \`@contractspec/app.cli-contractspec\` package provides the command-line interface for the ContractSpec ecosystem.
4500
+
4501
+ It is also exposed via \`@contractspec/apps-registry/contractspec\` for convenience.
4502
+
4503
+ ## Installation
4504
+
4505
+ \`\`\`bash
4506
+ bun add -D @contractspec/app.cli-contractspec
4507
+ \`\`\`
4508
+
4509
+ ## Quick Start
4510
+
4511
+ \`\`\`bash
4512
+ # Create a new contract spec interactively
4513
+ contractspec create
4514
+
4515
+ # Create with AI assistance
4516
+ contractspec create --ai
4517
+
4518
+ # Build implementation from spec
4519
+ contractspec build src/contracts/mySpec.ts
4520
+
4521
+ # Validate a spec
4522
+ contractspec validate src/contracts/mySpec.ts
4523
+ \`\`\`
4524
+
4525
+ ## Core Commands
4526
+
4527
+ ### \`create\`
4528
+
4529
+ Interactive wizard to create contract specifications.
4530
+
4531
+ \`\`\`bash
4532
+ contractspec create --type operation --ai
4533
+ \`\`\`
4534
+
4535
+ ### \`build\`
4536
+
4537
+ Generate implementation code from contract specs using AI agents or templates.
4538
+
4539
+ \`\`\`bash
4540
+ contractspec build src/contracts/signup.contracts.ts --agent-mode claude-code
4541
+ \`\`\`
4542
+
4543
+ Available agent modes: simple, cursor, claude-code, openai-codex, opencode (alias for opencode-sdk).
4544
+
4545
+ OpenCode uses \`@opencode-ai/sdk\` via dynamic import and is ideal for teams running a self-hosted, open backend.
4546
+
4547
+ ### \`validate\`
4548
+
4549
+ Validate contract specifications and verify implementations.
4550
+
4551
+ \`\`\`bash
4552
+ contractspec validate src/contracts/signup.contracts.ts --check-implementation
4553
+ \`\`\`
4554
+
4555
+ You can also validate with OpenCode:
4556
+
4557
+ \`\`\`bash
4558
+ contractspec validate src/contracts/signup.contracts.ts --check-implementation --agent-mode opencode
4559
+ \`\`\`
4560
+
4561
+ ### \`watch\`
4562
+
4563
+ Watch contract specifications and auto-regenerate on changes.
4564
+
4565
+ \`\`\`bash
4566
+ contractspec watch --build --validate
4567
+ \`\`\`
4568
+
4569
+ ### \`list\`
4570
+
4571
+ List all contract specifications in the project.
4572
+
4573
+ \`\`\`bash
4574
+ contractspec list --owner @team-platform
4575
+ \`\`\`
4576
+
4577
+ ### \`cleanup\` / \`clean\`
4578
+
4579
+ Clean generated files and build artifacts.
4580
+
4581
+ \`\`\`bash
4582
+ contractspec clean
4583
+ \`\`\`
4584
+
4585
+ ### \`deps\`
4586
+
4587
+ Analyze contract dependencies and relationships (circular dependencies, missing refs).
4588
+
4589
+ \`\`\`bash
4590
+ contractspec deps --circular
4591
+ \`\`\`
4592
+
4593
+ ### \`diff\`
4594
+
4595
+ Compare contract specifications and show differences (breaking changes, semantic diff).
4596
+
4597
+ \`\`\`bash
4598
+ contractspec diff spec1.ts spec2.ts --breaking
4599
+ \`\`\`
4600
+
4601
+ ### \`ci\`
4602
+
4603
+ Run all validation checks for CI/CD pipelines (structure, integrity, deps, doctor, handlers, tests).
4604
+
4605
+ \`\`\`bash
4606
+ contractspec ci --format sarif --output results.sarif
4607
+ \`\`\`
4608
+
4609
+ ## Configuration
4610
+
4611
+ The CLI is configured via \`.contractsrc.json\` in your project root.
4612
+
4613
+ \`\`\`json
4614
+ {
4615
+ "aiProvider": "claude",
4616
+ "aiModel": "claude-3-7-sonnet-20250219",
4617
+ "agentMode": "claude-code",
4618
+ "outputDir": "./src"
4619
+ }
4620
+ \`\`\`
4621
+
4622
+ For full documentation, refer to the [package README](https://github.com/contractspec/monorepo/tree/main/packages/apps/cli-contractspec).
4623
+ `
4624
+ }
4625
+ ];
4626
+ registerDocBlocks(tech_cli_DocBlocks);
4627
+
4628
+ // src/docs/tech/report-verification-table.docblock.ts
4629
+ var reportVerificationTableDocBlocks = [
4630
+ {
4631
+ id: "docs.tech.report-verification-table",
4632
+ title: "Contract Verification Table",
4633
+ summary: "How the impact report renders per-contract verification status.",
4634
+ kind: "how",
4635
+ visibility: "public",
4636
+ route: "/docs/tech/report/verification-table",
4637
+ tags: ["report", "drift", "verification", "impact"],
4638
+ owners: ["platform.core"],
4639
+ domain: "report",
4640
+ body: `# Contract Verification Table
4641
+
4642
+ The impact report includes an optional per-contract verification table that summarises the health of each contract at a glance.
4643
+
4644
+ ## Columns
4645
+
4646
+ | Column | Description |
4647
+ |--------|-------------|
4648
+ | Contract / Endpoint / Event | Fully qualified contract name (e.g. \`user.create\`) |
4649
+ | Drift debt | Number of mismatches currently detected |
4650
+ | Time since verified | Human-friendly elapsed time (e.g. "23 days") or "Never" |
4651
+ | Surfaces covered | Comma-separated list (API, runtime validation, UI form, docs/examples, permissions) |
4652
+ | Last verified commit | Short SHA of the last drift-free commit |
4653
+
4654
+ ## Data flow
4655
+
4656
+ 1. The drift detector produces per-contract mismatch counts.
4657
+ 2. \`.contractspec/verified.json\` records the last clean commit per contract.
4658
+ 3. The report script reads both sources and renders the Markdown table.
4659
+
4660
+ ## Backward compatibility
4661
+
4662
+ When \`contracts\` is absent from the report JSON, the table is skipped and the existing report sections render unchanged.
4663
+
4664
+ ## Contracts
4665
+
4666
+ - Query: \`report.getContractVerificationStatus\` (v1.0.0)
4667
+ - Data view: \`report.contractVerificationTable\` (v1.0.0)
4668
+ `
4669
+ }
4670
+ ];
4671
+ registerDocBlocks(reportVerificationTableDocBlocks);
4672
+ export {
4673
+ techContractsDocs,
4674
+ registerDocsPresentations,
4675
+ registerDocsOperations,
4676
+ registerDocsForms,
4677
+ registerDocsEvents,
4678
+ registerDocsDataViews,
4679
+ registerDocBlocks,
4680
+ metaDocs,
4681
+ mapDocRoutes,
4682
+ listRegisteredDocBlocks,
4683
+ docsPresentationContracts,
4684
+ docsOperationContracts,
4685
+ docsFormContracts,
4686
+ docsEventContracts,
4687
+ docsDataViewContracts,
4688
+ docId,
4689
+ docBlocksToPresentationSpecs,
4690
+ docBlocksToPresentationRoutes,
4691
+ docBlockToPresentationSpec,
4692
+ defaultDocRegistry,
4693
+ ExampleCatalogDataView,
4694
+ DocumentationSystemCapability,
4695
+ DocsSearchForm,
4696
+ DocsReferencePagePresentation,
4697
+ DocsPublishedPayload,
4698
+ DocsPublishedEvent,
4699
+ DocsPublishCommand,
4700
+ DocsLayoutPresentation,
4701
+ DocsIndexQuery,
4702
+ DocsIndexOutput,
4703
+ DocsIndexInput,
4704
+ DocsIndexDataView,
4705
+ DocsGeneratedPayload,
4706
+ DocsGeneratedEvent,
4707
+ DocsGenerateCommand,
4708
+ DocSummaryModel,
4709
+ DocRegistry,
4710
+ DOCS_TAGS,
4711
+ DOCS_STABILITY,
4712
+ DOCS_OWNERS,
4713
+ DOCS_DOMAIN,
4714
+ ContractReferenceQuery,
4715
+ ContractReferenceOutput,
4716
+ ContractReferenceModel,
4717
+ ContractReferenceInput,
4718
+ ContractReferenceDataView
4719
+ };