@lssm/lib.contracts 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217072406

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 (239) hide show
  1. package/dist/app-config/app-config.feature.js +53 -1
  2. package/dist/app-config/contracts.d.ts +50 -50
  3. package/dist/app-config/contracts.js +396 -1
  4. package/dist/app-config/docs/app-config.docblock.js +22 -220
  5. package/dist/app-config/events.d.ts +27 -27
  6. package/dist/app-config/events.js +168 -1
  7. package/dist/app-config/index.js +8 -1
  8. package/dist/app-config/lifecycle-contracts.d.ts +80 -80
  9. package/dist/app-config/lifecycle-contracts.js +441 -1
  10. package/dist/app-config/runtime.js +617 -1
  11. package/dist/app-config/spec.js +36 -1
  12. package/dist/app-config/validation.js +538 -1
  13. package/dist/capabilities/docs/capabilities.docblock.js +22 -1
  14. package/dist/capabilities/openbanking.js +92 -1
  15. package/dist/capabilities.js +50 -1
  16. package/dist/client/index.js +9 -1
  17. package/dist/client/react/drivers/rn-reusables.js +21 -1
  18. package/dist/client/react/drivers/shadcn.js +11 -1
  19. package/dist/client/react/feature-render.js +43 -1
  20. package/dist/client/react/form-render.js +298 -1
  21. package/dist/client/react/index.js +8 -1
  22. package/dist/contract-registry/index.js +3 -1
  23. package/dist/contract-registry/schemas.js +61 -1
  24. package/dist/contracts-adapter-hydration.js +41 -1
  25. package/dist/contracts-adapter-input.js +77 -1
  26. package/dist/data-views/docs/data-views.docblock.js +22 -1
  27. package/dist/data-views/query-generator.js +48 -1
  28. package/dist/data-views/runtime.js +39 -1
  29. package/dist/data-views.js +35 -1
  30. package/dist/docs/PUBLISHING.docblock.js +17 -76
  31. package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -350
  32. package/dist/docs/index.js +33 -1
  33. package/dist/docs/meta.docs.js +15 -2
  34. package/dist/docs/presentations.js +77 -1
  35. package/dist/docs/registry.js +51 -1
  36. package/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +17 -383
  37. package/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +17 -68
  38. package/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +17 -140
  39. package/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +17 -86
  40. package/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +17 -1
  41. package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +25 -2
  42. package/dist/docs/tech/contracts/README.docblock.js +21 -1
  43. package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -1
  44. package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.js +21 -180
  45. package/dist/docs/tech/contracts/migrations.docblock.js +21 -1
  46. package/dist/docs/tech/contracts/openapi-export.docblock.js +22 -2
  47. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +19 -60
  48. package/dist/docs/tech/contracts/overlays.docblock.js +21 -68
  49. package/dist/docs/tech/contracts/tests.docblock.js +21 -132
  50. package/dist/docs/tech/contracts/themes.docblock.js +21 -1
  51. package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +21 -106
  52. package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -213
  53. package/dist/docs/tech/llm/llm-integration.docblock.js +74 -5
  54. package/dist/docs/tech/mcp-endpoints.docblock.js +38 -1
  55. package/dist/docs/tech/presentation-runtime.docblock.js +17 -1
  56. package/dist/docs/tech/schema/README.docblock.js +21 -262
  57. package/dist/docs/tech/studio/learning-events.docblock.js +49 -1
  58. package/dist/docs/tech/studio/learning-journeys.docblock.js +25 -2
  59. package/dist/docs/tech/studio/platform-admin-panel.docblock.js +24 -2
  60. package/dist/docs/tech/studio/project-access-teams.docblock.js +26 -16
  61. package/dist/docs/tech/studio/project-routing.docblock.js +68 -1
  62. package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +23 -2
  63. package/dist/docs/tech/studio/team-invitations.docblock.js +41 -36
  64. package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -1
  65. package/dist/docs/tech/studio/workspaces.docblock.js +24 -2
  66. package/dist/docs/tech/telemetry-ingest.docblock.js +37 -3
  67. package/dist/docs/tech/templates/runtime.docblock.js +21 -1
  68. package/dist/docs/tech/vscode-extension.docblock.js +37 -3
  69. package/dist/docs/tech/workflows/overview.docblock.js +21 -1
  70. package/dist/docs/tech-contracts.docs.js +19 -2
  71. package/dist/events.js +12 -1
  72. package/dist/experiments/docs/experiments.docblock.js +22 -128
  73. package/dist/experiments/evaluator.js +101 -1
  74. package/dist/experiments/spec.js +33 -1
  75. package/dist/features.js +68 -1
  76. package/dist/forms/docs/forms.docblock.js +22 -1
  77. package/dist/forms.js +119 -1
  78. package/dist/index.js +107 -1
  79. package/dist/install.js +40 -1
  80. package/dist/integrations/contracts.d.ts +102 -102
  81. package/dist/integrations/contracts.js +388 -1
  82. package/dist/integrations/docs/integrations.docblock.js +95 -1
  83. package/dist/integrations/health.js +69 -1
  84. package/dist/integrations/index.js +23 -1
  85. package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
  86. package/dist/integrations/openbanking/contracts/accounts.js +237 -1
  87. package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
  88. package/dist/integrations/openbanking/contracts/balances.js +167 -1
  89. package/dist/integrations/openbanking/contracts/index.js +12 -1
  90. package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
  91. package/dist/integrations/openbanking/contracts/transactions.js +218 -1
  92. package/dist/integrations/openbanking/guards.js +32 -1
  93. package/dist/integrations/openbanking/models.d.ts +55 -55
  94. package/dist/integrations/openbanking/models.js +242 -1
  95. package/dist/integrations/openbanking/openbanking.feature.js +68 -1
  96. package/dist/integrations/openbanking/telemetry.js +39 -1
  97. package/dist/integrations/providers/elevenlabs.js +56 -1
  98. package/dist/integrations/providers/gcs-storage.js +79 -1
  99. package/dist/integrations/providers/gmail.js +91 -1
  100. package/dist/integrations/providers/google-calendar.js +70 -1
  101. package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -1
  102. package/dist/integrations/providers/impls/gcs-storage.js +88 -1
  103. package/dist/integrations/providers/impls/gmail-inbound.js +200 -1
  104. package/dist/integrations/providers/impls/gmail-outbound.js +104 -5
  105. package/dist/integrations/providers/impls/google-calendar.js +154 -1
  106. package/dist/integrations/providers/impls/index.js +16 -1
  107. package/dist/integrations/providers/impls/mistral-embedding.js +41 -1
  108. package/dist/integrations/providers/impls/mistral-llm.js +247 -1
  109. package/dist/integrations/providers/impls/postmark-email.js +55 -1
  110. package/dist/integrations/providers/impls/powens-client.js +171 -1
  111. package/dist/integrations/providers/impls/powens-openbanking.js +218 -1
  112. package/dist/integrations/providers/impls/provider-factory.js +142 -1
  113. package/dist/integrations/providers/impls/qdrant-vector.js +69 -1
  114. package/dist/integrations/providers/impls/stripe-payments.js +202 -1
  115. package/dist/integrations/providers/impls/twilio-sms.js +58 -1
  116. package/dist/integrations/providers/index.js +13 -1
  117. package/dist/integrations/providers/mistral.js +72 -1
  118. package/dist/integrations/providers/postmark.js +72 -1
  119. package/dist/integrations/providers/powens.js +120 -1
  120. package/dist/integrations/providers/qdrant.js +77 -1
  121. package/dist/integrations/providers/registry.js +34 -1
  122. package/dist/integrations/providers/stripe.js +87 -1
  123. package/dist/integrations/providers/twilio-sms.js +65 -1
  124. package/dist/integrations/runtime.js +186 -1
  125. package/dist/integrations/secrets/aws-secret-manager.js +231 -1
  126. package/dist/integrations/secrets/env-secret-provider.js +81 -1
  127. package/dist/integrations/secrets/gcp-secret-manager.js +229 -1
  128. package/dist/integrations/secrets/index.js +8 -1
  129. package/dist/integrations/secrets/manager.js +103 -1
  130. package/dist/integrations/secrets/provider.js +58 -1
  131. package/dist/integrations/secrets/scaleway-secret-manager.js +247 -1
  132. package/dist/integrations/spec.js +39 -1
  133. package/dist/jobs/define-job.js +16 -1
  134. package/dist/jobs/gcp-cloud-tasks.js +53 -1
  135. package/dist/jobs/gcp-pubsub.js +39 -1
  136. package/dist/jobs/handlers/gmail-sync-handler.js +9 -1
  137. package/dist/jobs/handlers/index.js +12 -1
  138. package/dist/jobs/handlers/ping-handler.js +15 -1
  139. package/dist/jobs/handlers/storage-document-handler.js +14 -1
  140. package/dist/jobs/index.js +4 -1
  141. package/dist/jobs/memory-queue.js +71 -1
  142. package/dist/jobs/queue.js +33 -1
  143. package/dist/jobs/scaleway-sqs-queue.js +153 -1
  144. package/dist/jsonschema.d.ts +3 -3
  145. package/dist/jsonschema.js +32 -1
  146. package/dist/knowledge/contracts.d.ts +66 -66
  147. package/dist/knowledge/contracts.js +317 -1
  148. package/dist/knowledge/docs/knowledge.docblock.js +22 -138
  149. package/dist/knowledge/index.js +10 -1
  150. package/dist/knowledge/ingestion/document-processor.js +54 -1
  151. package/dist/knowledge/ingestion/embedding-service.js +25 -1
  152. package/dist/knowledge/ingestion/gmail-adapter.js +50 -5
  153. package/dist/knowledge/ingestion/index.js +7 -1
  154. package/dist/knowledge/ingestion/storage-adapter.js +26 -1
  155. package/dist/knowledge/ingestion/vector-indexer.js +32 -1
  156. package/dist/knowledge/query/index.js +3 -1
  157. package/dist/knowledge/query/service.js +64 -2
  158. package/dist/knowledge/runtime.js +49 -1
  159. package/dist/knowledge/spaces/email-threads.js +38 -1
  160. package/dist/knowledge/spaces/financial-docs.js +38 -1
  161. package/dist/knowledge/spaces/financial-overview.js +42 -1
  162. package/dist/knowledge/spaces/index.js +8 -1
  163. package/dist/knowledge/spaces/product-canon.js +38 -1
  164. package/dist/knowledge/spaces/support-faq.js +41 -1
  165. package/dist/knowledge/spaces/uploaded-docs.js +38 -1
  166. package/dist/knowledge/spec.js +39 -1
  167. package/dist/llm/exporters.js +541 -8
  168. package/dist/llm/index.js +4 -1
  169. package/dist/llm/prompts.js +246 -56
  170. package/dist/markdown.js +116 -3
  171. package/dist/migrations.js +33 -1
  172. package/dist/onboarding-base.d.ts +29 -29
  173. package/dist/onboarding-base.js +196 -1
  174. package/dist/openapi.js +75 -1
  175. package/dist/openbanking/docs/openbanking.docblock.js +22 -109
  176. package/dist/ownership.js +40 -1
  177. package/dist/policy/docs/policy.docblock.js +22 -1
  178. package/dist/policy/engine.js +223 -1
  179. package/dist/policy/opa-adapter.js +71 -1
  180. package/dist/policy/spec.js +33 -1
  181. package/dist/presentations/docs/presentations-conventions.docblock.js +21 -7
  182. package/dist/presentations.backcompat.js +47 -1
  183. package/dist/presentations.d.ts +3 -3
  184. package/dist/presentations.js +66 -1
  185. package/dist/presentations.v2.js +278 -6
  186. package/dist/prompt.js +10 -1
  187. package/dist/promptRegistry.js +34 -1
  188. package/dist/regenerator/docs/regenerator.docblock.js +22 -184
  189. package/dist/regenerator/executor.js +86 -1
  190. package/dist/regenerator/index.js +6 -1
  191. package/dist/regenerator/service.js +92 -1
  192. package/dist/regenerator/sinks.js +32 -1
  193. package/dist/regenerator/utils.js +51 -1
  194. package/dist/registry.js +208 -1
  195. package/dist/resources.js +47 -1
  196. package/dist/schema/dist/EnumType.js +2 -1
  197. package/dist/schema/dist/FieldType.js +49 -1
  198. package/dist/schema/dist/ScalarTypeEnum.js +236 -1
  199. package/dist/schema/dist/SchemaModel.js +39 -1
  200. package/dist/schema/dist/entity/defineEntity.js +1 -1
  201. package/dist/schema/dist/entity/index.js +2 -1
  202. package/dist/schema/dist/entity/types.js +1 -1
  203. package/dist/schema/dist/index.js +6 -1
  204. package/dist/schema-to-markdown.js +214 -10
  205. package/dist/server/graphql-pothos.js +128 -1
  206. package/dist/server/index.js +10 -1
  207. package/dist/server/mcp/createMcpServer.js +28 -1
  208. package/dist/server/mcp/registerPresentations.js +151 -1
  209. package/dist/server/mcp/registerPrompts.js +36 -2
  210. package/dist/server/mcp/registerResources.js +35 -1
  211. package/dist/server/mcp/registerTools.js +22 -1
  212. package/dist/server/provider-mcp.js +3 -1
  213. package/dist/server/rest-elysia.js +20 -1
  214. package/dist/server/rest-express.js +39 -1
  215. package/dist/server/rest-generic.js +125 -1
  216. package/dist/server/rest-next-app.js +38 -1
  217. package/dist/server/rest-next-mcp.js +45 -1
  218. package/dist/server/rest-next-pages.js +25 -1
  219. package/dist/spec.js +35 -1
  220. package/dist/telemetry/anomaly.js +48 -1
  221. package/dist/telemetry/docs/telemetry.docblock.js +22 -139
  222. package/dist/telemetry/index.js +5 -1
  223. package/dist/telemetry/spec.js +69 -1
  224. package/dist/telemetry/tracker.js +76 -1
  225. package/dist/tests/index.js +4 -1
  226. package/dist/tests/runner.js +150 -1
  227. package/dist/tests/spec.js +33 -1
  228. package/dist/themes.js +39 -1
  229. package/dist/workflow/adapters/db-adapter.js +83 -1
  230. package/dist/workflow/adapters/file-adapter.js +11 -1
  231. package/dist/workflow/adapters/index.js +5 -1
  232. package/dist/workflow/adapters/memory-store.js +58 -1
  233. package/dist/workflow/expression.js +98 -1
  234. package/dist/workflow/index.js +9 -1
  235. package/dist/workflow/runner.js +337 -1
  236. package/dist/workflow/sla-monitor.js +47 -1
  237. package/dist/workflow/spec.js +32 -1
  238. package/dist/workflow/validation.js +175 -1
  239. package/package.json +11 -4
@@ -1,4 +1,11 @@
1
- import{specToAgentPrompt as e,specToFullMarkdown as t}from"./exporters.js";const n={"claude-code":`You are an expert TypeScript developer working with ContractSpec, a spec-first development framework.
1
+ import { specToAgentPrompt, specToFullMarkdown } from "./exporters.js";
2
+
3
+ //#region src/llm/prompts.ts
4
+ /**
5
+ * System prompts for different agent types.
6
+ */
7
+ const AGENT_SYSTEM_PROMPTS = {
8
+ "claude-code": `You are an expert TypeScript developer working with ContractSpec, a spec-first development framework.
2
9
 
3
10
  Your code follows these principles:
4
11
  - Type-safe with comprehensive TypeScript types (no \`any\`)
@@ -14,7 +21,8 @@ When implementing specs:
14
21
  4. Respect policy constraints (auth, rate limits, PII handling)
15
22
  5. Follow the acceptance scenarios as your implementation guide
16
23
 
17
- Generate clean, idiomatic TypeScript that exactly matches the specification.`,"cursor-cli":`You are implementing features for a ContractSpec-driven codebase.
24
+ Generate clean, idiomatic TypeScript that exactly matches the specification.`,
25
+ "cursor-cli": `You are implementing features for a ContractSpec-driven codebase.
18
26
 
19
27
  ContractSpec is a spec-first framework where specifications define:
20
28
  - Operations (commands and queries) with typed I/O
@@ -29,7 +37,8 @@ When working with specs:
29
37
  - Follow the acceptance scenarios
30
38
  - Respect policy constraints
31
39
 
32
- Use the project's existing patterns and conventions.`,"generic-mcp":`You are a code generation assistant working with ContractSpec specifications.
40
+ Use the project's existing patterns and conventions.`,
41
+ "generic-mcp": `You are a code generation assistant working with ContractSpec specifications.
33
42
 
34
43
  ContractSpec specs define:
35
44
  - meta: name, version, kind (command/query), description, goal, context
@@ -39,14 +48,23 @@ ContractSpec specs define:
39
48
  - acceptance: scenarios and examples
40
49
 
41
50
  Your task is to generate or modify code that complies with the given specification.
42
- Follow the spec exactly and handle all defined cases.`};function r(r,i,a){let o=n[i],s=t(r),c;return c=i===`claude-code`?`## Implementation Task
51
+ Follow the spec exactly and handle all defined cases.`
52
+ };
53
+ /**
54
+ * Generate an implementation prompt for a specific agent type.
55
+ */
56
+ function generateImplementationPrompt(spec, agent, options) {
57
+ const systemPrompt = AGENT_SYSTEM_PROMPTS[agent];
58
+ const specMarkdown = specToFullMarkdown(spec);
59
+ let taskPrompt;
60
+ if (agent === "claude-code") taskPrompt = `## Implementation Task
43
61
 
44
62
  Implement the following ContractSpec operation:
45
63
 
46
- ${s}
64
+ ${specMarkdown}
47
65
 
48
- ${a?.targetPath?`**Target file:** \`${a.targetPath}\`\n`:``}
49
- ${a?.existingCode?`**Existing code to modify:**\n\`\`\`typescript\n${a.existingCode}\n\`\`\`\n`:``}
66
+ ${options?.targetPath ? `**Target file:** \`${options.targetPath}\`\n` : ""}
67
+ ${options?.existingCode ? `**Existing code to modify:**\n\`\`\`typescript\n${options.existingCode}\n\`\`\`\n` : ""}
50
68
 
51
69
  Generate a complete, production-ready TypeScript implementation that:
52
70
  1. Exports a handler function matching the spec signature
@@ -55,25 +73,42 @@ Generate a complete, production-ready TypeScript implementation that:
55
73
  4. Emits events as specified
56
74
  5. Includes JSDoc documentation
57
75
 
58
- Provide ONLY the TypeScript code.`:i===`cursor-cli`?`Implement this ContractSpec operation.
76
+ Provide ONLY the TypeScript code.`;
77
+ else if (agent === "cursor-cli") taskPrompt = `Implement this ContractSpec operation.
59
78
 
60
- ${s}
79
+ ${specMarkdown}
61
80
 
62
- ${a?.targetPath?`Target: ${a.targetPath}\n`:``}
81
+ ${options?.targetPath ? `Target: ${options.targetPath}\n` : ""}
63
82
 
64
83
  Requirements:
65
84
  - TypeScript with strict types
66
85
  - Handle all error cases
67
86
  - Emit specified events
68
- - Follow acceptance scenarios`:e(r,{taskType:`implement`,existingCode:a?.existingCode}),{agent:i,systemPrompt:o,taskPrompt:c}}function i(e,r,i){let a=i?.testFramework??`vitest`,o=`## Test Generation Task
87
+ - Follow acceptance scenarios`;
88
+ else taskPrompt = specToAgentPrompt(spec, {
89
+ taskType: "implement",
90
+ existingCode: options?.existingCode
91
+ });
92
+ return {
93
+ agent,
94
+ systemPrompt,
95
+ taskPrompt
96
+ };
97
+ }
98
+ /**
99
+ * Generate a test generation prompt.
100
+ */
101
+ function generateTestPrompt(spec, agent, options) {
102
+ const framework = options?.testFramework ?? "vitest";
103
+ const taskPrompt = `## Test Generation Task
69
104
 
70
105
  Generate comprehensive tests for this specification:
71
106
 
72
- ${t(e)}
107
+ ${specToFullMarkdown(spec)}
73
108
 
74
- ${i?.implementationCode?`**Implementation:**\n\`\`\`typescript\n${i.implementationCode}\n\`\`\`\n`:``}
109
+ ${options?.implementationCode ? `**Implementation:**\n\`\`\`typescript\n${options.implementationCode}\n\`\`\`\n` : ""}
75
110
 
76
- **Test Framework:** ${a}
111
+ **Test Framework:** ${framework}
77
112
 
78
113
  Generate tests that:
79
114
  1. Cover all acceptance scenarios from the spec
@@ -84,16 +119,27 @@ Generate tests that:
84
119
 
85
120
  Use descriptive test names: "should [behavior] when [condition]"
86
121
 
87
- Provide a complete test file.`;return{agent:r,systemPrompt:n[r],taskPrompt:o}}function a(e,r,i){let a=`## Code Review Task
122
+ Provide a complete test file.`;
123
+ return {
124
+ agent,
125
+ systemPrompt: AGENT_SYSTEM_PROMPTS[agent],
126
+ taskPrompt
127
+ };
128
+ }
129
+ /**
130
+ * Generate a code review prompt.
131
+ */
132
+ function generateReviewPrompt(spec, agent, implementationCode) {
133
+ const taskPrompt = `## Code Review Task
88
134
 
89
135
  Review this implementation against its specification:
90
136
 
91
137
  **Specification:**
92
- ${t(e)}
138
+ ${specToFullMarkdown(spec)}
93
139
 
94
140
  **Implementation:**
95
141
  \`\`\`typescript
96
- ${i}
142
+ ${implementationCode}
97
143
  \`\`\`
98
144
 
99
145
  Provide a structured review:
@@ -111,16 +157,29 @@ List any issues with severity (error/warning/info)
111
157
  ### Suggestions
112
158
  List improvements and recommendations
113
159
 
114
- Be thorough and precise. Focus on spec compliance first, then code quality.`;return{agent:r,systemPrompt:n[r],taskPrompt:a}}function o(e,n){return{agent:`generic-mcp`,taskPrompt:`## Semantic Verification Task
160
+ Be thorough and precise. Focus on spec compliance first, then code quality.`;
161
+ return {
162
+ agent,
163
+ systemPrompt: AGENT_SYSTEM_PROMPTS[agent],
164
+ taskPrompt
165
+ };
166
+ }
167
+ /**
168
+ * Generate a verification prompt for AI-powered semantic review.
169
+ */
170
+ function generateVerificationPrompt(spec, implementationCode) {
171
+ return {
172
+ agent: "generic-mcp",
173
+ taskPrompt: `## Semantic Verification Task
115
174
 
116
175
  Verify that this implementation fulfills the specification's intent.
117
176
 
118
177
  **Specification:**
119
- ${t(e)}
178
+ ${specToFullMarkdown(spec)}
120
179
 
121
180
  **Implementation:**
122
181
  \`\`\`typescript
123
- ${n}
182
+ ${implementationCode}
124
183
  \`\`\`
125
184
 
126
185
  Analyze and respond with JSON:
@@ -144,77 +203,208 @@ Analyze and respond with JSON:
144
203
  ],
145
204
  "summary": "Brief summary of verification results"
146
205
  }
147
- \`\`\``}}function s(e,n){let r=e.meta,i=[],a=n?.projectRoot??`src`,o=r.name.replace(/\./g,`/`);(r.kind===`command`||r.kind===`query`)&&i.push({path:`${a}/${o}/handler.ts`,purpose:`Main handler implementation`,type:`create`},{path:`${a}/${o}/types.ts`,purpose:`Type definitions`,type:`create`},{path:`${a}/${o}/handler.test.ts`,purpose:`Handler tests`,type:`create`});let s=[],c=1;s.push({order:c++,title:`Define Types`,description:`Create TypeScript types for input, output, and internal data structures`,acceptanceCriteria:[`Input type matches spec schema exactly`,`Output type matches spec schema exactly`,`Error types defined for all error cases`]}),s.push({order:c++,title:`Implement Input Validation`,description:`Add validation logic for the input payload`,acceptanceCriteria:[`All required fields are validated`,`Type constraints are enforced`,`Validation errors return appropriate error codes`]}),s.push({order:c++,title:`Implement Core Logic`,description:`Implement the main business logic of the operation`,acceptanceCriteria:e.acceptance?.scenarios?.map(e=>e.name)??[`Operation completes successfully for valid input`]}),e.io.errors&&Object.keys(e.io.errors).length>0&&s.push({order:c++,title:`Implement Error Handling`,description:`Handle all defined error cases`,acceptanceCriteria:Object.entries(e.io.errors).map(([e,t])=>`Handle ${e}: ${t.when}`)}),e.sideEffects?.emits?.length&&s.push({order:c++,title:`Implement Event Emission`,description:`Emit events as specified`,acceptanceCriteria:e.sideEffects.emits.map(e=>`ref`in e?`Emit ${e.ref.name}.v${e.ref.version} when ${e.when}`:`Emit ${e.name}.v${e.version} when ${e.when}`)}),s.push({order:c++,title:`Write Tests`,description:`Create comprehensive test suite`,acceptanceCriteria:[`All acceptance scenarios covered`,`All error cases tested`,`Edge cases handled`,`Events verified`]});let l={policy:[],security:[],pii:[]};return l.policy.push(`Auth level: ${e.policy.auth}`),e.policy.idempotent!==void 0&&l.policy.push(`Idempotent: ${e.policy.idempotent}`),e.policy.rateLimit&&l.policy.push(`Rate limit: ${e.policy.rateLimit.rpm} rpm per ${e.policy.rateLimit.key}`),e.policy.flags?.length&&l.policy.push(`Feature flags required: ${e.policy.flags.join(`, `)}`),e.policy.escalate&&l.security.push(`Escalation required: ${e.policy.escalate}`),e.policy.pii?.length&&(l.pii=e.policy.pii),{target:{type:`spec`,name:r.name,version:r.version},context:{goal:r.goal,description:r.description,background:r.context},specMarkdown:t(e),fileStructure:i,steps:s,constraints:l,verificationChecklist:[`Input validation works for all cases`,`Output matches expected schema`,`All error cases return correct codes`,`Events are emitted with correct payloads`,`Auth requirements are enforced`,`Rate limiting is applied (if applicable)`,`PII fields are handled correctly`,`All acceptance scenarios pass`,`Tests provide adequate coverage`]}}function c(e,t){let r;return r=t===`claude-code`?`## Implementation Plan: ${e.target.name}.v${e.target.version}
206
+ \`\`\``
207
+ };
208
+ }
209
+ /**
210
+ * Generate a feature implementation plan.
211
+ */
212
+ function generateImplementationPlan(spec, options) {
213
+ const m = spec.meta;
214
+ const fileStructure = [];
215
+ const basePath = options?.projectRoot ?? "src";
216
+ const specPath = m.name.replace(/\./g, "/");
217
+ if (m.kind === "command" || m.kind === "query") fileStructure.push({
218
+ path: `${basePath}/${specPath}/handler.ts`,
219
+ purpose: "Main handler implementation",
220
+ type: "create"
221
+ }, {
222
+ path: `${basePath}/${specPath}/types.ts`,
223
+ purpose: "Type definitions",
224
+ type: "create"
225
+ }, {
226
+ path: `${basePath}/${specPath}/handler.test.ts`,
227
+ purpose: "Handler tests",
228
+ type: "create"
229
+ });
230
+ const steps = [];
231
+ let order = 1;
232
+ steps.push({
233
+ order: order++,
234
+ title: "Define Types",
235
+ description: "Create TypeScript types for input, output, and internal data structures",
236
+ acceptanceCriteria: [
237
+ "Input type matches spec schema exactly",
238
+ "Output type matches spec schema exactly",
239
+ "Error types defined for all error cases"
240
+ ]
241
+ });
242
+ steps.push({
243
+ order: order++,
244
+ title: "Implement Input Validation",
245
+ description: "Add validation logic for the input payload",
246
+ acceptanceCriteria: [
247
+ "All required fields are validated",
248
+ "Type constraints are enforced",
249
+ "Validation errors return appropriate error codes"
250
+ ]
251
+ });
252
+ steps.push({
253
+ order: order++,
254
+ title: "Implement Core Logic",
255
+ description: "Implement the main business logic of the operation",
256
+ acceptanceCriteria: spec.acceptance?.scenarios?.map((s) => s.name) ?? ["Operation completes successfully for valid input"]
257
+ });
258
+ if (spec.io.errors && Object.keys(spec.io.errors).length > 0) steps.push({
259
+ order: order++,
260
+ title: "Implement Error Handling",
261
+ description: "Handle all defined error cases",
262
+ acceptanceCriteria: Object.entries(spec.io.errors).map(([code, err]) => `Handle ${code}: ${err.when}`)
263
+ });
264
+ if (spec.sideEffects?.emits?.length) steps.push({
265
+ order: order++,
266
+ title: "Implement Event Emission",
267
+ description: "Emit events as specified",
268
+ acceptanceCriteria: spec.sideEffects.emits.map((e) => {
269
+ if ("ref" in e) return `Emit ${e.ref.name}.v${e.ref.version} when ${e.when}`;
270
+ return `Emit ${e.name}.v${e.version} when ${e.when}`;
271
+ })
272
+ });
273
+ steps.push({
274
+ order: order++,
275
+ title: "Write Tests",
276
+ description: "Create comprehensive test suite",
277
+ acceptanceCriteria: [
278
+ "All acceptance scenarios covered",
279
+ "All error cases tested",
280
+ "Edge cases handled",
281
+ "Events verified"
282
+ ]
283
+ });
284
+ const constraints = {
285
+ policy: [],
286
+ security: [],
287
+ pii: []
288
+ };
289
+ constraints.policy.push(`Auth level: ${spec.policy.auth}`);
290
+ if (spec.policy.idempotent !== void 0) constraints.policy.push(`Idempotent: ${spec.policy.idempotent}`);
291
+ if (spec.policy.rateLimit) constraints.policy.push(`Rate limit: ${spec.policy.rateLimit.rpm} rpm per ${spec.policy.rateLimit.key}`);
292
+ if (spec.policy.flags?.length) constraints.policy.push(`Feature flags required: ${spec.policy.flags.join(", ")}`);
293
+ if (spec.policy.escalate) constraints.security.push(`Escalation required: ${spec.policy.escalate}`);
294
+ if (spec.policy.pii?.length) constraints.pii = spec.policy.pii;
295
+ return {
296
+ target: {
297
+ type: "spec",
298
+ name: m.name,
299
+ version: m.version
300
+ },
301
+ context: {
302
+ goal: m.goal,
303
+ description: m.description,
304
+ background: m.context
305
+ },
306
+ specMarkdown: specToFullMarkdown(spec),
307
+ fileStructure,
308
+ steps,
309
+ constraints,
310
+ verificationChecklist: [
311
+ "Input validation works for all cases",
312
+ "Output matches expected schema",
313
+ "All error cases return correct codes",
314
+ "Events are emitted with correct payloads",
315
+ "Auth requirements are enforced",
316
+ "Rate limiting is applied (if applicable)",
317
+ "PII fields are handled correctly",
318
+ "All acceptance scenarios pass",
319
+ "Tests provide adequate coverage"
320
+ ]
321
+ };
322
+ }
323
+ /**
324
+ * Format an implementation plan for a specific agent.
325
+ */
326
+ function formatPlanForAgent(plan, agent) {
327
+ let taskPrompt;
328
+ if (agent === "claude-code") taskPrompt = `## Implementation Plan: ${plan.target.name}.v${plan.target.version}
148
329
 
149
330
  ### Context
150
- **Goal:** ${e.context.goal}
331
+ **Goal:** ${plan.context.goal}
151
332
 
152
- **Background:** ${e.context.background}
333
+ **Background:** ${plan.context.background}
153
334
 
154
335
  ### Specification
155
- ${e.specMarkdown}
336
+ ${plan.specMarkdown}
156
337
 
157
338
  ### File Structure
158
- ${e.fileStructure.map(e=>`- \`${e.path}\` (${e.type}): ${e.purpose}`).join(`
159
- `)}
339
+ ${plan.fileStructure.map((f) => `- \`${f.path}\` (${f.type}): ${f.purpose}`).join("\n")}
160
340
 
161
341
  ### Implementation Steps
162
- ${e.steps.map(e=>`
163
- #### Step ${e.order}: ${e.title}
164
- ${e.description}
342
+ ${plan.steps.map((s) => `
343
+ #### Step ${s.order}: ${s.title}
344
+ ${s.description}
165
345
 
166
346
  **Acceptance Criteria:**
167
- ${e.acceptanceCriteria.map(e=>`- [ ] ${e}`).join(`
168
- `)}
169
- `).join(`
170
- `)}
347
+ ${s.acceptanceCriteria.map((c) => `- [ ] ${c}`).join("\n")}
348
+ `).join("\n")}
171
349
 
172
350
  ### Constraints
173
- ${e.constraints.policy.length?`**Policy:**\n${e.constraints.policy.map(e=>`- ${e}`).join(`
174
- `)}\n`:``}
175
- ${e.constraints.security.length?`**Security:**\n${e.constraints.security.map(e=>`- ${e}`).join(`
176
- `)}\n`:``}
177
- ${e.constraints.pii.length?`**PII Handling:**\n${e.constraints.pii.map(e=>`- ${e}`).join(`
178
- `)}\n`:``}
351
+ ${plan.constraints.policy.length ? `**Policy:**\n${plan.constraints.policy.map((p) => `- ${p}`).join("\n")}\n` : ""}
352
+ ${plan.constraints.security.length ? `**Security:**\n${plan.constraints.security.map((s) => `- ${s}`).join("\n")}\n` : ""}
353
+ ${plan.constraints.pii.length ? `**PII Handling:**\n${plan.constraints.pii.map((p) => `- ${p}`).join("\n")}\n` : ""}
179
354
 
180
355
  ### Verification Checklist
181
- ${e.verificationChecklist.map(e=>`- [ ] ${e}`).join(`
182
- `)}
356
+ ${plan.verificationChecklist.map((c) => `- [ ] ${c}`).join("\n")}
183
357
 
184
- Implement this plan step by step.`:t===`cursor-cli`?`# ${e.target.name}.v${e.target.version}
358
+ Implement this plan step by step.`;
359
+ else if (agent === "cursor-cli") taskPrompt = `# ${plan.target.name}.v${plan.target.version}
185
360
 
186
- ${e.context.goal}
361
+ ${plan.context.goal}
187
362
 
188
363
  ## Spec
189
- ${e.specMarkdown}
364
+ ${plan.specMarkdown}
190
365
 
191
366
  ## Files to create
192
- ${e.fileStructure.map(e=>`${e.type}: ${e.path}`).join(`
193
- `)}
367
+ ${plan.fileStructure.map((f) => `${f.type}: ${f.path}`).join("\n")}
194
368
 
195
369
  ## Steps
196
- ${e.steps.map(e=>`${e.order}. ${e.title}`).join(`
197
- `)}`:`Implementation plan for ${e.target.name}.v${e.target.version}
370
+ ${plan.steps.map((s) => `${s.order}. ${s.title}`).join("\n")}`;
371
+ else taskPrompt = `Implementation plan for ${plan.target.name}.v${plan.target.version}
198
372
 
199
- ${e.specMarkdown}
373
+ ${plan.specMarkdown}
200
374
 
201
375
  Steps:
202
- ${e.steps.map(e=>`${e.order}. ${e.title}: ${e.description}`).join(`
203
- `)}`,{agent:t,systemPrompt:n[t],taskPrompt:r}}function l(e,n,r){return{agent:`generic-mcp`,taskPrompt:`## Fix Specification Violations
376
+ ${plan.steps.map((s) => `${s.order}. ${s.title}: ${s.description}`).join("\n")}`;
377
+ return {
378
+ agent,
379
+ systemPrompt: AGENT_SYSTEM_PROMPTS[agent],
380
+ taskPrompt
381
+ };
382
+ }
383
+ /**
384
+ * Generate a fix violations prompt after verification.
385
+ */
386
+ function generateFixViolationsPrompt(spec, implementationCode, violations) {
387
+ return {
388
+ agent: "generic-mcp",
389
+ taskPrompt: `## Fix Specification Violations
204
390
 
205
391
  The following implementation has violations against its specification:
206
392
 
207
393
  **Specification:**
208
- ${t(e)}
394
+ ${specToFullMarkdown(spec)}
209
395
 
210
396
  **Current Implementation:**
211
397
  \`\`\`typescript
212
- ${n}
398
+ ${implementationCode}
213
399
  \`\`\`
214
400
 
215
401
  **Violations Found:**
216
- ${r.map((e,t)=>`${t+1}. ${e.message}${e.suggestion?`\n Suggestion: ${e.suggestion}`:``}`).join(`
217
- `)}
402
+ ${violations.map((v, i) => `${i + 1}. ${v.message}${v.suggestion ? `\n Suggestion: ${v.suggestion}` : ""}`).join("\n")}
218
403
 
219
404
  Fix ALL violations while maintaining existing functionality.
220
- Provide the corrected implementation.`}}export{n as AGENT_SYSTEM_PROMPTS,c as formatPlanForAgent,l as generateFixViolationsPrompt,s as generateImplementationPlan,r as generateImplementationPrompt,a as generateReviewPrompt,i as generateTestPrompt,o as generateVerificationPrompt};
405
+ Provide the corrected implementation.`
406
+ };
407
+ }
408
+
409
+ //#endregion
410
+ export { AGENT_SYSTEM_PROMPTS, formatPlanForAgent, generateFixViolationsPrompt, generateImplementationPlan, generateImplementationPrompt, generateReviewPrompt, generateTestPrompt, generateVerificationPrompt };
package/dist/markdown.js CHANGED
@@ -1,3 +1,116 @@
1
- import{isEmitDeclRef as e}from"./spec.js";function t(t,n){let r=[];for(let n of t.listSpecs()){let t=n.meta;if(r.push(`# ${t.name}.v${t.version}`),r.push(``),r.push(`**Kind:** ${t.kind} | **Stability:** ${t.stability} | **Owners:** ${t.owners.join(`, `)}`),r.push(``),r.push(`**Description:** ${t.description}`),r.push(``),r.push(`## Goal`),r.push(t.goal),r.push(``),r.push(`## Context`),r.push(t.context),r.push(``),r.push(`## Policy`),r.push(`- Auth: ${n.policy.auth}`),r.push(`- Idempotent: ${!!n.policy.idempotent}`),n.policy.rateLimit&&r.push(`- Rate Limit: ${n.policy.rateLimit.rpm}/min by ${n.policy.rateLimit.key}`),n.policy.flags?.length&&r.push(`- Flags: ${n.policy.flags.join(`, `)}`),n.policy.pii?.length&&r.push(`- PII: ${n.policy.pii.join(`, `)}`),r.push(``),n.sideEffects?.emits?.length){r.push(`## Emits Events`);for(let t of n.sideEffects.emits)e(t)?r.push(`- \`${t.ref.name}.v${t.ref.version}\` — ${t.when}`):r.push(`- \`${t.name}.v${t.version}\` — ${t.when}`);r.push(``)}if(n.io.errors&&Object.keys(n.io.errors).length){r.push(`## Errors`);for(let[e,t]of Object.entries(n.io.errors))r.push(`- \`${e}\` (${t.http??400}) — ${t.description} (when: ${t.when})`);r.push(``)}if(n.acceptance?.scenarios?.length){r.push(`## Acceptance Scenarios`);for(let e of n.acceptance.scenarios)r.push(`### ${e.name}`),r.push(`- **Given:** ${e.given.join(`; `)}`),r.push(`- **When:** ${e.when.join(`; `)}`),r.push(`- **Then:** ${e.then.join(`; `)}`),r.push(``)}if(n.acceptance?.examples?.length){r.push(`## Examples`);for(let e of n.acceptance.examples)r.push(`- **${e.name}**`),r.push(` - Input:`),r.push(" ```json"),r.push(JSON.stringify(e.input,null,2)),r.push(" ```"),r.push(` - Output:`),r.push(" ```json"),r.push(JSON.stringify(e.output,null,2)),r.push(" ```"),r.push(``)}r.push(`---`),r.push(``)}return r.join(`
2
- `)}function n(e,n){let r=[];if(r.push(t(e,n)),n.presentations){r.push(`# Presentations`),r.push(``);for(let e of n.presentations.list())r.push(`## ${e.meta.name}.v${e.meta.version}`),r.push(``),r.push(`- Kind: ${e.content.kind}`),`framework`in e.content&&r.push(`- Framework: ${e.content.framework}`),`componentKey`in e.content&&r.push(`- Component Key: ${e.content.componentKey}`),`mimeType`in e.content&&r.push(`- MIME Type: ${e.content.mimeType}`),r.push(``);r.push(``)}if(n.features){r.push(`# Features`),r.push(``);for(let e of n.features.list()){if(r.push(`## ${e.meta.title} (${e.meta.key})`),e.meta.description&&r.push(e.meta.description),r.push(``),e.operations?.length){r.push(`- Operations:`);for(let t of e.operations)r.push(` - ${t.name}.v${t.version}`)}if(e.events?.length){r.push(`- Events:`);for(let t of e.events)r.push(` - ${t.name}.v${t.version}`)}if(e.presentations?.length){r.push(`- Presentations:`);for(let t of e.presentations)r.push(` - ${t.name}.v${t.version}`)}r.push(``)}}return r.join(`
3
- `)}export{n as docsToMarkdown,t as specsToMarkdown};
1
+ import { isEmitDeclRef } from "./spec.js";
2
+
3
+ //#region src/markdown.ts
4
+ /**
5
+ * Render simple Markdown docs for each spec.
6
+ * Useful for dev portals and repo docs generation.
7
+ */
8
+ function specsToMarkdown(reg, extras) {
9
+ const lines = [];
10
+ for (const spec of reg.listSpecs()) {
11
+ const m = spec.meta;
12
+ lines.push(`# ${m.name}.v${m.version}`);
13
+ lines.push("");
14
+ lines.push(`**Kind:** ${m.kind} | **Stability:** ${m.stability} | **Owners:** ${m.owners.join(", ")}`);
15
+ lines.push("");
16
+ lines.push(`**Description:** ${m.description}`);
17
+ lines.push("");
18
+ lines.push(`## Goal`);
19
+ lines.push(m.goal);
20
+ lines.push("");
21
+ lines.push(`## Context`);
22
+ lines.push(m.context);
23
+ lines.push("");
24
+ lines.push(`## Policy`);
25
+ lines.push(`- Auth: ${spec.policy.auth}`);
26
+ lines.push(`- Idempotent: ${!!spec.policy.idempotent}`);
27
+ if (spec.policy.rateLimit) lines.push(`- Rate Limit: ${spec.policy.rateLimit.rpm}/min by ${spec.policy.rateLimit.key}`);
28
+ if (spec.policy.flags?.length) lines.push(`- Flags: ${spec.policy.flags.join(", ")}`);
29
+ if (spec.policy.pii?.length) lines.push(`- PII: ${spec.policy.pii.join(", ")}`);
30
+ lines.push("");
31
+ if (spec.sideEffects?.emits?.length) {
32
+ lines.push(`## Emits Events`);
33
+ for (const e of spec.sideEffects.emits) if (isEmitDeclRef(e)) lines.push(`- \`${e.ref.name}.v${e.ref.version}\` — ${e.when}`);
34
+ else lines.push(`- \`${e.name}.v${e.version}\` — ${e.when}`);
35
+ lines.push("");
36
+ }
37
+ if (spec.io.errors && Object.keys(spec.io.errors).length) {
38
+ lines.push(`## Errors`);
39
+ for (const [code, err] of Object.entries(spec.io.errors)) lines.push(`- \`${code}\` (${err.http ?? 400}) — ${err.description} (when: ${err.when})`);
40
+ lines.push("");
41
+ }
42
+ if (spec.acceptance?.scenarios?.length) {
43
+ lines.push(`## Acceptance Scenarios`);
44
+ for (const s of spec.acceptance.scenarios) {
45
+ lines.push(`### ${s.name}`);
46
+ lines.push(`- **Given:** ${s.given.join("; ")}`);
47
+ lines.push(`- **When:** ${s.when.join("; ")}`);
48
+ lines.push(`- **Then:** ${s.then.join("; ")}`);
49
+ lines.push("");
50
+ }
51
+ }
52
+ if (spec.acceptance?.examples?.length) {
53
+ lines.push(`## Examples`);
54
+ for (const ex of spec.acceptance.examples) {
55
+ lines.push(`- **${ex.name}**`);
56
+ lines.push(" - Input:");
57
+ lines.push(" ```json");
58
+ lines.push(JSON.stringify(ex.input, null, 2));
59
+ lines.push(" ```");
60
+ lines.push(" - Output:");
61
+ lines.push(" ```json");
62
+ lines.push(JSON.stringify(ex.output, null, 2));
63
+ lines.push(" ```");
64
+ lines.push("");
65
+ }
66
+ }
67
+ lines.push("---");
68
+ lines.push("");
69
+ }
70
+ return lines.join("\n");
71
+ }
72
+ /** Render presentations and features as additional sections. */
73
+ function docsToMarkdown(reg, extras) {
74
+ const parts = [];
75
+ parts.push(specsToMarkdown(reg, extras));
76
+ if (extras.presentations) {
77
+ parts.push("# Presentations");
78
+ parts.push("");
79
+ for (const p of extras.presentations.list()) {
80
+ parts.push(`## ${p.meta.name}.v${p.meta.version}`);
81
+ parts.push("");
82
+ parts.push(`- Kind: ${p.content.kind}`);
83
+ if ("framework" in p.content) parts.push(`- Framework: ${p.content.framework}`);
84
+ if ("componentKey" in p.content) parts.push(`- Component Key: ${p.content.componentKey}`);
85
+ if ("mimeType" in p.content) parts.push(`- MIME Type: ${p.content.mimeType}`);
86
+ parts.push("");
87
+ }
88
+ parts.push("");
89
+ }
90
+ if (extras.features) {
91
+ parts.push("# Features");
92
+ parts.push("");
93
+ for (const f of extras.features.list()) {
94
+ parts.push(`## ${f.meta.title} (${f.meta.key})`);
95
+ if (f.meta.description) parts.push(f.meta.description);
96
+ parts.push("");
97
+ if (f.operations?.length) {
98
+ parts.push("- Operations:");
99
+ for (const o of f.operations) parts.push(` - ${o.name}.v${o.version}`);
100
+ }
101
+ if (f.events?.length) {
102
+ parts.push("- Events:");
103
+ for (const e of f.events) parts.push(` - ${e.name}.v${e.version}`);
104
+ }
105
+ if (f.presentations?.length) {
106
+ parts.push("- Presentations:");
107
+ for (const p of f.presentations) parts.push(` - ${p.name}.v${p.version}`);
108
+ }
109
+ parts.push("");
110
+ }
111
+ }
112
+ return parts.join("\n");
113
+ }
114
+
115
+ //#endregion
116
+ export { docsToMarkdown, specsToMarkdown };
@@ -1 +1,33 @@
1
- const e=(e,t)=>`${e}.v${t}`;var t=class{items=new Map;register(t){let n=e(t.meta.name,t.meta.version);if(this.items.has(n))throw Error(`Duplicate migration ${n}`);return this.items.set(n,t),this}list(){return[...this.items.values()].sort((t,r)=>n(e(t.meta.name,t.meta.version),e(r.meta.name,r.meta.version)))}get(t,n){if(n!=null)return this.items.get(e(t,n));let r,i=-1/0;for(let e of this.items.values())e.meta.name===t&&e.meta.version>i&&(i=e.meta.version,r=e);return r}};function n(e,t){return e<t?-1:e>t?1:0}export{t as MigrationRegistry};
1
+ //#region src/migrations.ts
2
+ const migrationKey = (name, version) => `${name}.v${version}`;
3
+ var MigrationRegistry = class {
4
+ items = /* @__PURE__ */ new Map();
5
+ register(spec) {
6
+ const key = migrationKey(spec.meta.name, spec.meta.version);
7
+ if (this.items.has(key)) throw new Error(`Duplicate migration ${key}`);
8
+ this.items.set(key, spec);
9
+ return this;
10
+ }
11
+ list() {
12
+ return [...this.items.values()].sort((a, b) => compareKey(migrationKey(a.meta.name, a.meta.version), migrationKey(b.meta.name, b.meta.version)));
13
+ }
14
+ get(name, version) {
15
+ if (version != null) return this.items.get(migrationKey(name, version));
16
+ let candidate;
17
+ let max = -Infinity;
18
+ for (const spec of this.items.values()) {
19
+ if (spec.meta.name !== name) continue;
20
+ if (spec.meta.version > max) {
21
+ max = spec.meta.version;
22
+ candidate = spec;
23
+ }
24
+ }
25
+ return candidate;
26
+ }
27
+ };
28
+ function compareKey(a, b) {
29
+ return a < b ? -1 : a > b ? 1 : 0;
30
+ }
31
+
32
+ //#endregion
33
+ export { MigrationRegistry };