@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217073102

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 (257) hide show
  1. package/dist/_virtual/rolldown_runtime.js +22 -1
  2. package/dist/adapters/ai.js +82 -1
  3. package/dist/adapters/factory.js +36 -1
  4. package/dist/adapters/fs.js +118 -1
  5. package/dist/adapters/git.js +54 -1
  6. package/dist/adapters/index.js +7 -1
  7. package/dist/adapters/logger.js +80 -1
  8. package/dist/adapters/watcher.js +69 -1
  9. package/dist/adapters/workspace.js +190 -2
  10. package/dist/ai/agents/claude-code-agent.js +146 -9
  11. package/dist/ai/agents/cursor-agent.js +286 -17
  12. package/dist/ai/agents/index.js +5 -1
  13. package/dist/ai/agents/openai-codex-agent.js +140 -8
  14. package/dist/ai/agents/orchestrator.js +142 -1
  15. package/dist/ai/agents/simple-agent.js +80 -4
  16. package/dist/ai/client.js +162 -1
  17. package/dist/ai/index.js +27 -1
  18. package/dist/ai/prompts/code-generation.js +55 -13
  19. package/dist/ai/prompts/index.js +12 -1
  20. package/dist/ai/prompts/spec-creation.js +61 -20
  21. package/dist/ai/providers.js +40 -1
  22. package/dist/formatters/index.js +18 -1
  23. package/dist/formatters/json.js +71 -1
  24. package/dist/formatters/sarif.js +163 -1
  25. package/dist/formatters/text.js +208 -2
  26. package/dist/index.js +81 -1
  27. package/dist/libs/ai-providers/dist/factory.js +154 -1
  28. package/dist/libs/ai-providers/dist/index.js +4 -1
  29. package/dist/libs/ai-providers/dist/legacy.js +72 -1
  30. package/dist/libs/ai-providers/dist/models.js +287 -1
  31. package/dist/libs/ai-providers/dist/validation.js +1 -1
  32. package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -1
  33. package/dist/libs/contracts/dist/client/index.js +5 -1
  34. package/dist/libs/contracts/dist/client/react/feature-render.js +2 -1
  35. package/dist/libs/contracts/dist/client/react/form-render.js +4 -1
  36. package/dist/libs/contracts/dist/client/react/index.js +4 -1
  37. package/dist/libs/contracts/dist/contract-registry/index.js +1 -1
  38. package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -1
  39. package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -76
  40. package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -350
  41. package/dist/libs/contracts/dist/docs/index.js +29 -1
  42. package/dist/libs/contracts/dist/docs/presentations.js +71 -1
  43. package/dist/libs/contracts/dist/docs/registry.js +44 -1
  44. package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -383
  45. package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -68
  46. package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -140
  47. package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -86
  48. package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -1
  49. package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +24 -2
  50. package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +21 -2
  51. package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -213
  52. package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +73 -5
  53. package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -1
  54. package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -1
  55. package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -262
  56. package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -1
  57. package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +24 -2
  58. package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +23 -2
  59. package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +25 -16
  60. package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -1
  61. package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +22 -2
  62. package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +40 -36
  63. package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -1
  64. package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +23 -2
  65. package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +36 -3
  66. package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -1
  67. package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +36 -3
  68. package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -1
  69. package/dist/libs/contracts/dist/events.js +8 -1
  70. package/dist/libs/contracts/dist/experiments/evaluator.js +1 -1
  71. package/dist/libs/contracts/dist/index.js +72 -1
  72. package/dist/libs/contracts/dist/install.js +2 -1
  73. package/dist/libs/contracts/dist/integrations/contracts.js +377 -1
  74. package/dist/libs/contracts/dist/integrations/index.js +18 -1
  75. package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -1
  76. package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -1
  77. package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -1
  78. package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -1
  79. package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -1
  80. package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -1
  81. package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -1
  82. package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -1
  83. package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -1
  84. package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -1
  85. package/dist/libs/contracts/dist/integrations/providers/index.js +11 -1
  86. package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -1
  87. package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -1
  88. package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -1
  89. package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -1
  90. package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -1
  91. package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -1
  92. package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -1
  93. package/dist/libs/contracts/dist/jsonschema.js +24 -1
  94. package/dist/libs/contracts/dist/knowledge/contracts.js +306 -1
  95. package/dist/libs/contracts/dist/knowledge/index.js +7 -1
  96. package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -1
  97. package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -1
  98. package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -1
  99. package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -1
  100. package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -1
  101. package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -1
  102. package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -1
  103. package/dist/libs/contracts/dist/llm/exporters.js +352 -4
  104. package/dist/libs/contracts/dist/llm/index.js +2 -1
  105. package/dist/libs/contracts/dist/llm/prompts.js +143 -7
  106. package/dist/libs/contracts/dist/onboarding-base.js +196 -1
  107. package/dist/libs/contracts/dist/openapi.js +75 -1
  108. package/dist/libs/contracts/dist/ownership.js +21 -1
  109. package/dist/libs/contracts/dist/presentations.js +1 -1
  110. package/dist/libs/contracts/dist/presentations.v2.js +11 -1
  111. package/dist/libs/contracts/dist/prompt.js +1 -1
  112. package/dist/libs/contracts/dist/promptRegistry.js +1 -1
  113. package/dist/libs/contracts/dist/regenerator/index.js +2 -1
  114. package/dist/libs/contracts/dist/regenerator/service.js +92 -1
  115. package/dist/libs/contracts/dist/regenerator/utils.js +51 -1
  116. package/dist/libs/contracts/dist/registry.js +208 -1
  117. package/dist/libs/contracts/dist/resources.js +1 -1
  118. package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -1
  119. package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -1
  120. package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -1
  121. package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +34 -1
  122. package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -1
  123. package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -1
  124. package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -1
  125. package/dist/libs/contracts/dist/schema/dist/index.js +6 -1
  126. package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -1
  127. package/dist/libs/contracts/dist/server/index.js +8 -1
  128. package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -1
  129. package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -1
  130. package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -1
  131. package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -1
  132. package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -1
  133. package/dist/libs/contracts/dist/server/provider-mcp.js +1 -1
  134. package/dist/libs/contracts/dist/server/rest-elysia.js +1 -1
  135. package/dist/libs/contracts/dist/server/rest-express.js +1 -1
  136. package/dist/libs/contracts/dist/server/rest-generic.js +1 -1
  137. package/dist/libs/contracts/dist/server/rest-next-app.js +1 -1
  138. package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -1
  139. package/dist/libs/contracts/dist/spec.js +35 -1
  140. package/dist/libs/contracts/dist/telemetry/index.js +1 -1
  141. package/dist/libs/contracts/dist/telemetry/tracker.js +1 -1
  142. package/dist/libs/contracts/dist/tests/index.js +1 -1
  143. package/dist/libs/contracts/dist/tests/runner.js +150 -1
  144. package/dist/libs/contracts/dist/workflow/index.js +1 -1
  145. package/dist/libs/contracts/dist/workflow/runner.js +1 -1
  146. package/dist/libs/contracts-transformers/dist/common/utils.js +47 -1
  147. package/dist/libs/contracts-transformers/dist/openapi/exporter.js +1 -1
  148. package/dist/libs/contracts-transformers/dist/openapi/importer.js +255 -2
  149. package/dist/libs/contracts-transformers/dist/openapi/index.js +4 -1
  150. package/dist/libs/contracts-transformers/dist/openapi/parser.js +231 -1
  151. package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +201 -4
  152. package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +50 -13
  153. package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +50 -18
  154. package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +84 -2
  155. package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +30 -1
  156. package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +96 -1
  157. package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +151 -1
  158. package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +344 -1
  159. package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +122 -1
  160. package/dist/modules/contractspec-workspace/dist/templates/app-config.js +100 -28
  161. package/dist/modules/contractspec-workspace/dist/templates/data-view.js +41 -27
  162. package/dist/modules/contractspec-workspace/dist/templates/event.js +28 -14
  163. package/dist/modules/contractspec-workspace/dist/templates/experiment.js +76 -51
  164. package/dist/modules/contractspec-workspace/dist/templates/handler.js +49 -17
  165. package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +97 -26
  166. package/dist/modules/contractspec-workspace/dist/templates/integration.js +46 -23
  167. package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +59 -19
  168. package/dist/modules/contractspec-workspace/dist/templates/migration.js +49 -26
  169. package/dist/modules/contractspec-workspace/dist/templates/operation.js +40 -28
  170. package/dist/modules/contractspec-workspace/dist/templates/presentation.js +45 -20
  171. package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +73 -53
  172. package/dist/modules/contractspec-workspace/dist/templates/utils.js +38 -1
  173. package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +12 -6
  174. package/dist/modules/contractspec-workspace/dist/templates/workflow.js +50 -24
  175. package/dist/modules/contractspec-workspace/dist/types/generation-types.js +20 -1
  176. package/dist/services/agent-guide/adapters/claude-code.js +144 -3
  177. package/dist/services/agent-guide/adapters/cursor-cli.js +135 -3
  178. package/dist/services/agent-guide/adapters/generic-mcp.js +159 -3
  179. package/dist/services/agent-guide/adapters/index.js +30 -1
  180. package/dist/services/agent-guide/agent-guide-service.js +148 -1
  181. package/dist/services/agent-guide/index.js +5 -1
  182. package/dist/services/build.js +140 -1
  183. package/dist/services/ci-check/ci-check-service.js +393 -1
  184. package/dist/services/ci-check/index.js +2 -1
  185. package/dist/services/ci-check/types.js +28 -1
  186. package/dist/services/clean.js +71 -1
  187. package/dist/services/config.js +76 -1
  188. package/dist/services/deps.js +62 -1
  189. package/dist/services/diff.js +33 -1
  190. package/dist/services/doctor/checks/ai.js +118 -2
  191. package/dist/services/doctor/checks/cli.js +146 -1
  192. package/dist/services/doctor/checks/config.js +170 -1
  193. package/dist/services/doctor/checks/deps.js +180 -1
  194. package/dist/services/doctor/checks/index.js +6 -1
  195. package/dist/services/doctor/checks/mcp.js +144 -1
  196. package/dist/services/doctor/checks/workspace.js +243 -1
  197. package/dist/services/doctor/doctor-service.js +115 -2
  198. package/dist/services/doctor/index.js +2 -1
  199. package/dist/services/doctor/types.js +26 -1
  200. package/dist/services/implementation/discovery.js +143 -2
  201. package/dist/services/implementation/index.js +2 -1
  202. package/dist/services/implementation/resolver.js +223 -1
  203. package/dist/services/index.js +53 -1
  204. package/dist/services/integrity-diagram.js +274 -6
  205. package/dist/services/integrity.js +272 -1
  206. package/dist/services/list.js +35 -1
  207. package/dist/services/openapi/export-service.js +51 -2
  208. package/dist/services/openapi/import-service.js +75 -1
  209. package/dist/services/openapi/index.js +4 -1
  210. package/dist/services/openapi/sync-service.js +121 -1
  211. package/dist/services/openapi/validate-service.js +130 -1
  212. package/dist/services/regenerator.js +23 -1
  213. package/dist/services/registry.js +73 -1
  214. package/dist/services/setup/config-generators.js +113 -26
  215. package/dist/services/setup/file-merger.js +60 -2
  216. package/dist/services/setup/index.js +4 -1
  217. package/dist/services/setup/setup-service.js +95 -1
  218. package/dist/services/setup/targets/agents-md.js +46 -1
  219. package/dist/services/setup/targets/cli-config.js +59 -1
  220. package/dist/services/setup/targets/cursor-rules.js +47 -1
  221. package/dist/services/setup/targets/mcp-claude.js +59 -1
  222. package/dist/services/setup/targets/mcp-cursor.js +58 -1
  223. package/dist/services/setup/targets/vscode-settings.js +62 -1
  224. package/dist/services/setup/types.js +26 -1
  225. package/dist/services/sync.js +62 -1
  226. package/dist/services/test.js +30 -1
  227. package/dist/services/validate-implementation.js +69 -1
  228. package/dist/services/validate.js +47 -1
  229. package/dist/services/verification-cache/adapters/filesystem.js +121 -1
  230. package/dist/services/verification-cache/adapters/in-memory.js +45 -1
  231. package/dist/services/verification-cache/adapters/index.js +3 -1
  232. package/dist/services/verification-cache/adapters/workspace-state.js +90 -1
  233. package/dist/services/verification-cache/cache-service.js +255 -1
  234. package/dist/services/verification-cache/index.js +6 -1
  235. package/dist/services/verification-cache/types.js +15 -1
  236. package/dist/services/verify/ai-verifier.js +336 -9
  237. package/dist/services/verify/behavior-verifier.js +185 -1
  238. package/dist/services/verify/index.js +4 -1
  239. package/dist/services/verify/structure-verifier.js +195 -2
  240. package/dist/services/verify/verify-service.js +203 -3
  241. package/dist/services/watch.js +31 -1
  242. package/dist/services/workspace-info.js +102 -2
  243. package/dist/templates/app-config.template.js +101 -28
  244. package/dist/templates/data-view.template.js +42 -27
  245. package/dist/templates/event.template.js +29 -14
  246. package/dist/templates/experiment.template.js +77 -51
  247. package/dist/templates/handler.template.js +53 -17
  248. package/dist/templates/index.js +36 -1
  249. package/dist/templates/integration.template.js +134 -50
  250. package/dist/templates/knowledge.template.js +62 -21
  251. package/dist/templates/migration.template.js +50 -26
  252. package/dist/templates/operation.template.js +44 -28
  253. package/dist/templates/presentation.template.js +46 -20
  254. package/dist/templates/telemetry.template.js +74 -53
  255. package/dist/templates/workflow-runner.template.js +12 -6
  256. package/dist/templates/workflow.template.js +51 -24
  257. package/package.json +13 -9
@@ -1 +1,231 @@
1
- import{parse as e}from"yaml";const t=[`get`,`post`,`put`,`delete`,`patch`,`head`,`options`,`trace`];function n(t,n=`json`){return n===`yaml`?e(t):JSON.parse(t)}function r(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`[`)?`json`:`yaml`}function i(e){return e.openapi.startsWith(`3.1`)?`3.1`:`3.0`}function a(e){return typeof e==`object`&&!!e&&`$ref`in e}function o(e,t){if(!t.startsWith(`#/`))return;let n=t.slice(2).split(`/`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r}function s(e,t){if(t)return a(t)?o(e,t.$ref)??t:t}function c(e,t){let n={path:[],query:[],header:[],cookie:[]};if(!t)return n;for(let r of t){let t;if(a(r)){let n=o(e,r.$ref);if(!n)continue;t=n}else t=r;let i={name:t.name,in:t.in,required:t.required??t.in===`path`,description:t.description,schema:t.schema,deprecated:t.deprecated??!1};n[t.in]?.push(i)}return n}function l(e,t){return e+t.split(`/`).filter(Boolean).map(e=>e.startsWith(`{`)&&e.endsWith(`}`)?`By`+e.slice(1,-1).charAt(0).toUpperCase()+e.slice(2,-1):e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function u(e,t,n,r,i){let u=c(e,[...i??[],...r.parameters??[]]),d;if(r.requestBody){let t=a(r.requestBody)?o(e,r.requestBody.$ref):r.requestBody;if(t){let n=Object.keys(t.content??{})[0]??`application/json`,r=t.content?.[n];r?.schema&&(d={required:t.required??!1,schema:s(e,r.schema),contentType:n})}}let f={};for(let[t,n]of Object.entries(r.responses??{})){let r=a(n)?o(e,n.$ref):n;if(r){let n=Object.keys(r.content??{})[0],i=n?r.content?.[n]:void 0;f[t]={description:r.description,schema:i?.schema?s(e,i.schema):void 0,contentType:n}}}let p=r?.[`x-contractspec`];return{operationId:r.operationId??l(t,n),method:t,path:n,summary:r.summary,description:r.description,tags:r.tags??[],pathParams:u.path,queryParams:u.query,headerParams:u.header,cookieParams:u.cookie,requestBody:d,responses:f,deprecated:r.deprecated??!1,security:r.security,contractSpecMeta:p}}function d(e,n={}){let r=i(e),a=[],o=[];for(let[n,r]of Object.entries(e.paths??{})){if(!r)continue;let i=r.parameters;for(let s of t){let t=r[s];if(t)try{o.push(u(e,s,n,t,i))}catch(e){a.push(`Failed to parse ${s.toUpperCase()} ${n}: ${e}`)}}}let s={},c=e.components;if(c?.schemas)for(let[e,t]of Object.entries(c.schemas))s[e]=t;let l=(e.servers??[]).map(e=>({url:e.url,description:e.description,variables:e.variables}));return{document:e,version:r,info:{title:e.info.title,version:e.info.version,description:e.info.description},operations:o,schemas:s,servers:l,warnings:a}}async function f(e,t={}){let{fetch:i=globalThis.fetch,readFile:a,timeout:o=3e4}=t,s,c;if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=new AbortController,n=setTimeout(()=>t.abort(),o);try{let n=await i(e,{signal:t.signal});if(!n.ok)throw Error(`HTTP ${n.status}: ${n.statusText}`);s=await n.text()}finally{clearTimeout(n)}c=e.endsWith(`.yaml`)||e.endsWith(`.yml`)?`yaml`:e.endsWith(`.json`)?`json`:r(s)}else{if(!a)throw Error(`readFile adapter required for file paths`);s=await a(e),c=e.endsWith(`.yaml`)||e.endsWith(`.yml`)?`yaml`:e.endsWith(`.json`)?`json`:r(s)}return d(n(s,c),t)}export{d,f,i,n,r};
1
+ import { parse } from "yaml";
2
+
3
+ //#region ../../libs/contracts-transformers/dist/openapi/parser.js
4
+ /**
5
+ * OpenAPI document parser.
6
+ * Parses OpenAPI 3.x documents from JSON/YAML files or URLs.
7
+ */
8
+ const HTTP_METHODS = [
9
+ "get",
10
+ "post",
11
+ "put",
12
+ "delete",
13
+ "patch",
14
+ "head",
15
+ "options",
16
+ "trace"
17
+ ];
18
+ /**
19
+ * Parse an OpenAPI document from a string (JSON or YAML).
20
+ */
21
+ function parseOpenApiString(content, format = "json") {
22
+ if (format === "yaml") return parse(content);
23
+ return JSON.parse(content);
24
+ }
25
+ /**
26
+ * Detect the format of content (JSON or YAML).
27
+ */
28
+ function detectFormat(content) {
29
+ const trimmed = content.trim();
30
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "json";
31
+ return "yaml";
32
+ }
33
+ /**
34
+ * Detect OpenAPI version from document.
35
+ */
36
+ function detectVersion(doc) {
37
+ if (doc.openapi.startsWith("3.1")) return "3.1";
38
+ return "3.0";
39
+ }
40
+ /**
41
+ * Check if a value is a reference object.
42
+ */
43
+ function isReference(obj) {
44
+ return typeof obj === "object" && obj !== null && "$ref" in obj;
45
+ }
46
+ /**
47
+ * Resolve a $ref reference in the document.
48
+ */
49
+ function resolveRef(doc, ref) {
50
+ if (!ref.startsWith("#/")) return;
51
+ const path = ref.slice(2).split("/");
52
+ let current = doc;
53
+ for (const part of path) {
54
+ if (current === null || current === void 0) return void 0;
55
+ if (typeof current !== "object") return void 0;
56
+ current = current[part];
57
+ }
58
+ return current;
59
+ }
60
+ /**
61
+ * Resolve a schema, following $ref if needed.
62
+ */
63
+ function resolveSchema(doc, schema) {
64
+ if (!schema) return void 0;
65
+ if (isReference(schema)) return resolveRef(doc, schema.$ref) ?? schema;
66
+ return schema;
67
+ }
68
+ /**
69
+ * Parse parameters from an operation.
70
+ */
71
+ function parseParameters(doc, params) {
72
+ const result = {
73
+ path: [],
74
+ query: [],
75
+ header: [],
76
+ cookie: []
77
+ };
78
+ if (!params) return result;
79
+ for (const param of params) {
80
+ let resolved;
81
+ if (isReference(param)) {
82
+ const ref = resolveRef(doc, param.$ref);
83
+ if (!ref) continue;
84
+ resolved = ref;
85
+ } else resolved = param;
86
+ const parsed = {
87
+ name: resolved.name,
88
+ in: resolved.in,
89
+ required: resolved.required ?? resolved.in === "path",
90
+ description: resolved.description,
91
+ schema: resolved.schema,
92
+ deprecated: resolved.deprecated ?? false
93
+ };
94
+ result[resolved.in]?.push(parsed);
95
+ }
96
+ return result;
97
+ }
98
+ /**
99
+ * Generate an operationId if not present.
100
+ */
101
+ function generateOperationId(method, path) {
102
+ return method + path.split("/").filter(Boolean).map((part) => {
103
+ if (part.startsWith("{") && part.endsWith("}")) return "By" + part.slice(1, -1).charAt(0).toUpperCase() + part.slice(2, -1);
104
+ return part.charAt(0).toUpperCase() + part.slice(1);
105
+ }).join("");
106
+ }
107
+ /**
108
+ * Parse a single operation.
109
+ */
110
+ function parseOperation(doc, method, path, operation, pathParams) {
111
+ const params = parseParameters(doc, [...pathParams ?? [], ...operation.parameters ?? []]);
112
+ let requestBody;
113
+ if (operation.requestBody) {
114
+ const body = isReference(operation.requestBody) ? resolveRef(doc, operation.requestBody.$ref) : operation.requestBody;
115
+ if (body) {
116
+ const contentType = Object.keys(body.content ?? {})[0] ?? "application/json";
117
+ const content = body.content?.[contentType];
118
+ if (content?.schema) requestBody = {
119
+ required: body.required ?? false,
120
+ schema: resolveSchema(doc, content.schema),
121
+ contentType
122
+ };
123
+ }
124
+ }
125
+ const responses = {};
126
+ for (const [status, response] of Object.entries(operation.responses ?? {})) {
127
+ const resolved = isReference(response) ? resolveRef(doc, response.$ref) : response;
128
+ if (resolved) {
129
+ const contentType = Object.keys(resolved.content ?? {})[0];
130
+ const content = contentType ? resolved.content?.[contentType] : void 0;
131
+ responses[status] = {
132
+ description: resolved.description,
133
+ schema: content?.schema ? resolveSchema(doc, content.schema) : void 0,
134
+ contentType
135
+ };
136
+ }
137
+ }
138
+ const contractSpecMeta = operation?.["x-contractspec"];
139
+ return {
140
+ operationId: operation.operationId ?? generateOperationId(method, path),
141
+ method,
142
+ path,
143
+ summary: operation.summary,
144
+ description: operation.description,
145
+ tags: operation.tags ?? [],
146
+ pathParams: params.path,
147
+ queryParams: params.query,
148
+ headerParams: params.header,
149
+ cookieParams: params.cookie,
150
+ requestBody,
151
+ responses,
152
+ deprecated: operation.deprecated ?? false,
153
+ security: operation.security,
154
+ contractSpecMeta
155
+ };
156
+ }
157
+ /**
158
+ * Parse an OpenAPI document into a structured result.
159
+ */
160
+ function parseOpenApiDocument(doc, _options = {}) {
161
+ const version = detectVersion(doc);
162
+ const warnings = [];
163
+ const operations = [];
164
+ for (const [path, pathItem] of Object.entries(doc.paths ?? {})) {
165
+ if (!pathItem) continue;
166
+ const pathParams = pathItem.parameters;
167
+ for (const method of HTTP_METHODS) {
168
+ const operation = pathItem[method];
169
+ if (operation) try {
170
+ operations.push(parseOperation(doc, method, path, operation, pathParams));
171
+ } catch (error) {
172
+ warnings.push(`Failed to parse ${method.toUpperCase()} ${path}: ${error}`);
173
+ }
174
+ }
175
+ }
176
+ const schemas = {};
177
+ const components = doc.components;
178
+ if (components?.schemas) for (const [name, schema] of Object.entries(components.schemas)) schemas[name] = schema;
179
+ const servers = (doc.servers ?? []).map((s) => ({
180
+ url: s.url,
181
+ description: s.description,
182
+ variables: s.variables
183
+ }));
184
+ return {
185
+ document: doc,
186
+ version,
187
+ info: {
188
+ title: doc.info.title,
189
+ version: doc.info.version,
190
+ description: doc.info.description
191
+ },
192
+ operations,
193
+ schemas,
194
+ servers,
195
+ warnings
196
+ };
197
+ }
198
+ /**
199
+ * Parse OpenAPI from a file path or URL.
200
+ * Note: This is an async function that requires I/O adapters.
201
+ * For pure parsing, use parseOpenApiString or parseOpenApiDocument.
202
+ */
203
+ async function parseOpenApi(source, options = {}) {
204
+ const { fetch: fetchFn = globalThis.fetch, readFile, timeout = 3e4 } = options;
205
+ let content;
206
+ let format;
207
+ if (source.startsWith("http://") || source.startsWith("https://")) {
208
+ const controller = new AbortController();
209
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
210
+ try {
211
+ const response = await fetchFn(source, { signal: controller.signal });
212
+ if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
213
+ content = await response.text();
214
+ } finally {
215
+ clearTimeout(timeoutId);
216
+ }
217
+ if (source.endsWith(".yaml") || source.endsWith(".yml")) format = "yaml";
218
+ else if (source.endsWith(".json")) format = "json";
219
+ else format = detectFormat(content);
220
+ } else {
221
+ if (!readFile) throw new Error("readFile adapter required for file paths");
222
+ content = await readFile(source);
223
+ if (source.endsWith(".yaml") || source.endsWith(".yml")) format = "yaml";
224
+ else if (source.endsWith(".json")) format = "json";
225
+ else format = detectFormat(content);
226
+ }
227
+ return parseOpenApiDocument(parseOpenApiString(content, format), options);
228
+ }
229
+
230
+ //#endregion
231
+ export { detectFormat, detectVersion, parseOpenApi, parseOpenApiDocument, parseOpenApiString };
@@ -1,4 +1,201 @@
1
- import{e,i as t,t as n}from"../common/utils.js";const r={string:`ScalarTypeEnum.STRING`,integer:`ScalarTypeEnum.INT`,number:`ScalarTypeEnum.FLOAT`,boolean:`ScalarTypeEnum.BOOLEAN`,"string:date":`ScalarTypeEnum.DATE`,"string:date-time":`ScalarTypeEnum.DATE_TIME`,"string:email":`ScalarTypeEnum.EMAIL`,"string:uri":`ScalarTypeEnum.URL`,"string:uuid":`ScalarTypeEnum.ID`};function i(e){return`$ref`in e}function a(e){let t=e.split(`/`);return t[t.length-1]??`Unknown`}function o(t,n){if(i(t))return{type:e(a(t.$ref)),optional:!1,array:!1,primitive:!1};let r=t,s=r.type,c=r.format,l=r.nullable;if(s===`array`){let e=r.items;return e?{...o(e,n),array:!0,optional:l??!1}:{type:`unknown`,optional:l??!1,array:!0,primitive:!1}}return s===`object`||r.properties?{type:n?e(n):`Record<string, unknown>`,optional:l??!1,array:!1,primitive:!1}:r.enum?{type:n?e(n):`string`,optional:l??!1,array:!1,primitive:!1}:(c&&`${s}${c}`,s===`string`?{type:`string`,optional:l??!1,array:!1,primitive:!0}:s===`integer`||s===`number`?{type:`number`,optional:l??!1,array:!1,primitive:!0}:s===`boolean`?{type:`boolean`,optional:l??!1,array:!1,primitive:!0}:{type:`unknown`,optional:l??!1,array:!1,primitive:!1})}function s(e){if(i(e))return;let t=e,n=t.type,a=t.format;if(n)return r[a?`${n}:${a}`:n]??r[n]}function c(e,r,a){let c=o(e,r),l=s(e),u;if(!i(e)){let t=e.enum;t&&(u=t.map(String))}return{name:t(n(r)),type:{...c,optional:!a||c.optional,description:i(e)?void 0:e.description},scalarType:l,enumValues:u}}function l(n,r,o=0){let s=` `.repeat(o),l=[],d;if(i(n))return{name:e(a(n.$ref)),fields:[],code:`// Reference to ${n.$ref}`};let f=n;d=f.description;let p=f.properties,m=f.required??[];if(!p)return{name:e(r),description:d,fields:[],code:`${s}// Empty schema for ${r}`};for(let[e,t]of Object.entries(p)){let n=m.includes(e);l.push(c(t,e,n))}let h=[],g=e(t(r));h.push(`${s}export const ${g} = defineSchemaModel({`),h.push(`${s} name: '${g}',`),d&&h.push(`${s} description: ${JSON.stringify(d)},`),h.push(`${s} fields: {`);for(let e of l){let t=u(e,o+2);h.push(t)}return h.push(`${s} },`),h.push(`${s}});`),{name:g,description:d,fields:l,code:h.join(`
2
- `)}}function u(e,t){let n=` `.repeat(t),r=[];return r.push(`${n}${e.name}: {`),e.enumValues?r.push(`${n} type: new EnumType([${e.enumValues.map(e=>`'${e}'`).join(`, `)}]),`):e.scalarType?r.push(`${n} type: ${e.scalarType},`):r.push(`${n} type: ${e.type.type}, // TODO: Define or import this type`),e.type.optional&&r.push(`${n} isOptional: true,`),e.type.array&&r.push(`${n} isArray: true,`),r.push(`${n}},`),r.join(`
3
- `)}function d(e){let t=new Set;t.add(`import { defineSchemaModel, ScalarTypeEnum, EnumType } from '@lssm/lib.schema';`);for(let t of e)!t.type.primitive&&!t.enumValues&&t.scalarType;return Array.from(t).join(`
4
- `)}export{c,d,l,o,s};
1
+ import { toCamelCase, toPascalCase, toValidIdentifier } from "../common/utils.js";
2
+
3
+ //#region ../../libs/contracts-transformers/dist/openapi/schema-converter.js
4
+ /**
5
+ * Map JSON Schema types to ContractSpec ScalarTypeEnum values.
6
+ */
7
+ const JSON_SCHEMA_TO_SCALAR = {
8
+ string: "ScalarTypeEnum.STRING",
9
+ integer: "ScalarTypeEnum.INT",
10
+ number: "ScalarTypeEnum.FLOAT",
11
+ boolean: "ScalarTypeEnum.BOOLEAN",
12
+ "string:date": "ScalarTypeEnum.DATE",
13
+ "string:date-time": "ScalarTypeEnum.DATE_TIME",
14
+ "string:email": "ScalarTypeEnum.EMAIL",
15
+ "string:uri": "ScalarTypeEnum.URL",
16
+ "string:uuid": "ScalarTypeEnum.ID"
17
+ };
18
+ /**
19
+ * Check if a schema is a reference object.
20
+ */
21
+ function isReference(schema) {
22
+ return "$ref" in schema;
23
+ }
24
+ /**
25
+ * Extract type name from a $ref.
26
+ */
27
+ function typeNameFromRef(ref) {
28
+ const parts = ref.split("/");
29
+ return parts[parts.length - 1] ?? "Unknown";
30
+ }
31
+ /**
32
+ * Convert a JSON Schema to a TypeScript type representation.
33
+ */
34
+ function jsonSchemaToType(schema, name) {
35
+ if (isReference(schema)) return {
36
+ type: toPascalCase(typeNameFromRef(schema.$ref)),
37
+ optional: false,
38
+ array: false,
39
+ primitive: false
40
+ };
41
+ const schemaObj = schema;
42
+ const type = schemaObj["type"];
43
+ const format = schemaObj["format"];
44
+ const nullable = schemaObj["nullable"];
45
+ if (type === "array") {
46
+ const items = schemaObj["items"];
47
+ if (items) return {
48
+ ...jsonSchemaToType(items, name),
49
+ array: true,
50
+ optional: nullable ?? false
51
+ };
52
+ return {
53
+ type: "unknown",
54
+ optional: nullable ?? false,
55
+ array: true,
56
+ primitive: false
57
+ };
58
+ }
59
+ if (type === "object" || schemaObj["properties"]) return {
60
+ type: name ? toPascalCase(name) : "Record<string, unknown>",
61
+ optional: nullable ?? false,
62
+ array: false,
63
+ primitive: false
64
+ };
65
+ if (schemaObj["enum"]) return {
66
+ type: name ? toPascalCase(name) : "string",
67
+ optional: nullable ?? false,
68
+ array: false,
69
+ primitive: false
70
+ };
71
+ format && `${type}${format}`;
72
+ if (type === "string") return {
73
+ type: "string",
74
+ optional: nullable ?? false,
75
+ array: false,
76
+ primitive: true
77
+ };
78
+ if (type === "integer" || type === "number") return {
79
+ type: "number",
80
+ optional: nullable ?? false,
81
+ array: false,
82
+ primitive: true
83
+ };
84
+ if (type === "boolean") return {
85
+ type: "boolean",
86
+ optional: nullable ?? false,
87
+ array: false,
88
+ primitive: true
89
+ };
90
+ return {
91
+ type: "unknown",
92
+ optional: nullable ?? false,
93
+ array: false,
94
+ primitive: false
95
+ };
96
+ }
97
+ /**
98
+ * Get the ScalarTypeEnum value for a JSON Schema type.
99
+ */
100
+ function getScalarType(schema) {
101
+ if (isReference(schema)) return;
102
+ const schemaObj = schema;
103
+ const type = schemaObj["type"];
104
+ const format = schemaObj["format"];
105
+ if (!type) return void 0;
106
+ return JSON_SCHEMA_TO_SCALAR[format ? `${type}:${format}` : type] ?? JSON_SCHEMA_TO_SCALAR[type];
107
+ }
108
+ /**
109
+ * Convert a JSON Schema to a SchemaModel field definition.
110
+ */
111
+ function jsonSchemaToField(schema, fieldName, required) {
112
+ const type = jsonSchemaToType(schema, fieldName);
113
+ const scalarType = getScalarType(schema);
114
+ let enumValues;
115
+ if (!isReference(schema)) {
116
+ const enumArr = schema["enum"];
117
+ if (enumArr) enumValues = enumArr.map(String);
118
+ }
119
+ return {
120
+ name: toValidIdentifier(toCamelCase(fieldName)),
121
+ type: {
122
+ ...type,
123
+ optional: !required || type.optional,
124
+ description: !isReference(schema) ? schema["description"] : void 0
125
+ },
126
+ scalarType,
127
+ enumValues
128
+ };
129
+ }
130
+ /**
131
+ * Generate SchemaModel TypeScript code for a JSON Schema object.
132
+ */
133
+ function generateSchemaModelCode(schema, modelName, indent = 0) {
134
+ const spaces = " ".repeat(indent);
135
+ const fields = [];
136
+ let description;
137
+ if (isReference(schema)) return {
138
+ name: toPascalCase(typeNameFromRef(schema.$ref)),
139
+ fields: [],
140
+ code: `// Reference to ${schema.$ref}`
141
+ };
142
+ const schemaObj = schema;
143
+ description = schemaObj["description"];
144
+ const properties = schemaObj["properties"];
145
+ const required = schemaObj["required"] ?? [];
146
+ if (!properties) return {
147
+ name: toPascalCase(modelName),
148
+ description,
149
+ fields: [],
150
+ code: `${spaces}// Empty schema for ${modelName}`
151
+ };
152
+ for (const [propName, propSchema] of Object.entries(properties)) {
153
+ const isRequired = required.includes(propName);
154
+ fields.push(jsonSchemaToField(propSchema, propName, isRequired));
155
+ }
156
+ const lines = [];
157
+ const safeModelName = toPascalCase(toValidIdentifier(modelName));
158
+ lines.push(`${spaces}export const ${safeModelName} = defineSchemaModel({`);
159
+ lines.push(`${spaces} name: '${safeModelName}',`);
160
+ if (description) lines.push(`${spaces} description: ${JSON.stringify(description)},`);
161
+ lines.push(`${spaces} fields: {`);
162
+ for (const field of fields) {
163
+ const fieldLines = generateFieldCode(field, indent + 2);
164
+ lines.push(fieldLines);
165
+ }
166
+ lines.push(`${spaces} },`);
167
+ lines.push(`${spaces}});`);
168
+ return {
169
+ name: safeModelName,
170
+ description,
171
+ fields,
172
+ code: lines.join("\n")
173
+ };
174
+ }
175
+ /**
176
+ * Generate TypeScript code for a single field.
177
+ */
178
+ function generateFieldCode(field, indent) {
179
+ const spaces = " ".repeat(indent);
180
+ const lines = [];
181
+ lines.push(`${spaces}${field.name}: {`);
182
+ if (field.enumValues) lines.push(`${spaces} type: new EnumType([${field.enumValues.map((v) => `'${v}'`).join(", ")}]),`);
183
+ else if (field.scalarType) lines.push(`${spaces} type: ${field.scalarType},`);
184
+ else lines.push(`${spaces} type: ${field.type.type}, // TODO: Define or import this type`);
185
+ if (field.type.optional) lines.push(`${spaces} isOptional: true,`);
186
+ if (field.type.array) lines.push(`${spaces} isArray: true,`);
187
+ lines.push(`${spaces}},`);
188
+ return lines.join("\n");
189
+ }
190
+ /**
191
+ * Generate import statements for a SchemaModel.
192
+ */
193
+ function generateImports(fields) {
194
+ const imports = /* @__PURE__ */ new Set();
195
+ imports.add("import { defineSchemaModel, ScalarTypeEnum, EnumType } from '@lssm/lib.schema';");
196
+ for (const field of fields) if (!field.type.primitive && !field.enumValues && !field.scalarType) {}
197
+ return Array.from(imports).join("\n");
198
+ }
199
+
200
+ //#endregion
201
+ export { generateImports, generateSchemaModelCode, getScalarType, jsonSchemaToField, jsonSchemaToType };
@@ -1,9 +1,18 @@
1
- function e(e){return`You are a senior TypeScript developer implementing a handler for a contract specification.
1
+ //#region ../../modules/contractspec-workspace/dist/ai/code-generation.js
2
+ /**
3
+ * AI prompts for code generation.
4
+ * Extracted from cli-contracts/src/ai/prompts/code-generation.ts
5
+ */
6
+ /**
7
+ * Build prompt for generating handler implementation.
8
+ */
9
+ function buildHandlerPrompt(specCode) {
10
+ return `You are a senior TypeScript developer implementing a handler for a contract specification.
2
11
 
3
12
  Here is the contract spec:
4
13
 
5
14
  \`\`\`typescript
6
- ${e}
15
+ ${specCode}
7
16
  \`\`\`
8
17
 
9
18
  Generate a complete handler implementation that:
@@ -17,12 +26,18 @@ Generate a complete handler implementation that:
17
26
 
18
27
  The handler should be production-ready with proper error handling, logging points, and clear structure.
19
28
 
20
- Return only the TypeScript code for the handler function.`}function t(e){return`You are a senior React developer creating a component for a presentation specification.
29
+ Return only the TypeScript code for the handler function.`;
30
+ }
31
+ /**
32
+ * Build prompt for generating React component from presentation spec.
33
+ */
34
+ function buildComponentPrompt(specCode) {
35
+ return `You are a senior React developer creating a component for a presentation specification.
21
36
 
22
37
  Here is the presentation spec:
23
38
 
24
39
  \`\`\`typescript
25
- ${e}
40
+ ${specCode}
26
41
  \`\`\`
27
42
 
28
43
  Generate a complete React component that:
@@ -36,12 +51,18 @@ Generate a complete React component that:
36
51
 
37
52
  The component should follow Atomic Design principles and be reusable.
38
53
 
39
- Return only the TypeScript/TSX code for the component.`}function n(e){return`You are a senior React developer creating a form component from a form specification.
54
+ Return only the TypeScript/TSX code for the component.`;
55
+ }
56
+ /**
57
+ * Build prompt for generating form component.
58
+ */
59
+ function buildFormPrompt(specCode) {
60
+ return `You are a senior React developer creating a form component from a form specification.
40
61
 
41
62
  Here is the form spec:
42
63
 
43
64
  \`\`\`typescript
44
- ${e}
65
+ ${specCode}
45
66
  \`\`\`
46
67
 
47
68
  Generate a complete form component using react-hook-form that:
@@ -56,25 +77,31 @@ Generate a complete form component using react-hook-form that:
56
77
 
57
78
  The form should provide excellent UX with real-time validation and helpful feedback.
58
79
 
59
- Return only the TypeScript/TSX code for the form component.`}function r(e,t,n){return`You are a senior developer writing comprehensive tests.
80
+ Return only the TypeScript/TSX code for the form component.`;
81
+ }
82
+ /**
83
+ * Build prompt for generating tests.
84
+ */
85
+ function buildTestPrompt(specCode, implementationCode, testType) {
86
+ return `You are a senior developer writing comprehensive tests.
60
87
 
61
88
  Spec:
62
89
  \`\`\`typescript
63
- ${e}
90
+ ${specCode}
64
91
  \`\`\`
65
92
 
66
93
  Implementation:
67
94
  \`\`\`typescript
68
- ${t}
95
+ ${implementationCode}
69
96
  \`\`\`
70
97
 
71
98
  Generate complete test suite using Vitest that:
72
- ${n===`handler`?`
99
+ ${testType === "handler" ? `
73
100
  - Test all acceptance scenarios from the spec
74
101
  - Test error cases defined in spec.io.errors
75
102
  - Verify events are emitted correctly
76
103
  - Test input validation
77
- - Test happy path and edge cases`:`
104
+ - Test happy path and edge cases` : `
78
105
  - Test rendering with various props
79
106
  - Test user interactions
80
107
  - Test accessibility (a11y)
@@ -83,7 +110,13 @@ ${n===`handler`?`
83
110
 
84
111
  Use clear test descriptions and follow AAA pattern (Arrange, Act, Assert).
85
112
 
86
- Return only the TypeScript test code.`}function i(){return`You are an expert TypeScript developer with deep knowledge of:
113
+ Return only the TypeScript test code.`;
114
+ }
115
+ /**
116
+ * System prompt for code generation.
117
+ */
118
+ function getCodeGenSystemPrompt() {
119
+ return `You are an expert TypeScript developer with deep knowledge of:
87
120
  - Type-safe API design
88
121
  - React and modern hooks
89
122
  - Test-driven development
@@ -97,4 +130,8 @@ Generate production-ready code that is:
97
130
  - Defensive and error-safe
98
131
  - Easy to maintain and extend
99
132
 
100
- Always prioritize code quality, safety, and user experience.`}export{e,i,n,r,t};
133
+ Always prioritize code quality, safety, and user experience.`;
134
+ }
135
+
136
+ //#endregion
137
+ export { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt };
@@ -1,8 +1,13 @@
1
- function e(e,t){return`You are a senior software architect creating a contract specification for an operation.
1
+ //#region ../../modules/contractspec-workspace/dist/ai/spec-creation.js
2
+ /**
3
+ * Build prompt for creating operation spec from description.
4
+ */
5
+ function buildOperationSpecPrompt(description, kind) {
6
+ return `You are a senior software architect creating a contract specification for an operation.
2
7
 
3
- The operation is a ${t} (${t===`command`?`changes state, has side effects`:`read-only, idempotent`}).
8
+ The operation is a ${kind} (${kind === "command" ? "changes state, has side effects" : "read-only, idempotent"}).
4
9
 
5
- User description: ${e}
10
+ User description: ${description}
6
11
 
7
12
  Create a complete contract specification following these guidelines:
8
13
 
@@ -16,9 +21,15 @@ Create a complete contract specification following these guidelines:
16
21
  8. **Feature Flags**: Any flags that gate this operation
17
22
  9. **Side Effects**: What events might be emitted, analytics to track
18
23
 
19
- Respond with a structured spec.`}function t(e){return`You are a senior software architect creating an event specification.
24
+ Respond with a structured spec.`;
25
+ }
26
+ /**
27
+ * Build prompt for creating event spec from description.
28
+ */
29
+ function buildEventSpecPrompt(description) {
30
+ return `You are a senior software architect creating an event specification.
20
31
 
21
- User description: ${e}
32
+ User description: ${description}
22
33
 
23
34
  Create a complete event specification following these guidelines:
24
35
 
@@ -30,11 +41,21 @@ Create a complete event specification following these guidelines:
30
41
 
31
42
  Events represent things that have already happened and should use past tense.
32
43
 
33
- Respond with a structured spec.`}function n(e,t){return`You are a senior software architect creating a presentation specification.
44
+ Respond with a structured spec.`;
45
+ }
46
+ /**
47
+ * Build prompt for creating presentation spec from description.
48
+ */
49
+ function buildPresentationSpecPrompt(description, kind) {
50
+ return `You are a senior software architect creating a presentation specification.
34
51
 
35
- This is a ${t} presentation - ${{web_component:`a React component with props schema`,markdown:`markdown/MDX documentation or guide`,data:`structured data export (JSON/XML)`}[t]}.
52
+ This is a ${kind} presentation - ${{
53
+ web_component: "a React component with props schema",
54
+ markdown: "markdown/MDX documentation or guide",
55
+ data: "structured data export (JSON/XML)"
56
+ }[kind]}.
36
57
 
37
- User description: ${e}
58
+ User description: ${description}
38
59
 
39
60
  Create a complete presentation specification following these guidelines:
40
61
 
@@ -42,13 +63,15 @@ Create a complete presentation specification following these guidelines:
42
63
  2. **Version**: Start at 1
43
64
  3. **Description**: What this presentation shows/provides
44
65
  4. **Kind-specific details**:
45
- ${t===`web_component`?`- Component key (symbolic, resolved by host app)
46
- - Props structure
47
- - Analytics events to track`:t===`markdown`?`- Content or resource URI
48
- - Target audience`:`- MIME type (e.g., application/json)
49
- - Data structure description`}
66
+ ${kind === "web_component" ? "- Component key (symbolic, resolved by host app)\n - Props structure\n - Analytics events to track" : kind === "markdown" ? "- Content or resource URI\n - Target audience" : "- MIME type (e.g., application/json)\n - Data structure description"}
50
67
 
51
- Respond with a structured spec.`}function r(){return`You are an expert software architect specializing in API design and contract-driven development.
68
+ Respond with a structured spec.`;
69
+ }
70
+ /**
71
+ * Build system prompt for all spec generation.
72
+ */
73
+ function getSystemPrompt() {
74
+ return `You are an expert software architect specializing in API design and contract-driven development.
52
75
 
53
76
  You create clear, well-documented specifications that serve as the single source of truth for operations, events, and presentations.
54
77
 
@@ -58,12 +81,21 @@ Your specs are:
58
81
  - Business-oriented (capturing the "why" not just "what")
59
82
  - Designed for both humans and AI agents to understand
60
83
 
61
- Always use proper dot notation for names and ensure all metadata is meaningful and accurate.`}function i(e,t){return t.length===0?e:`${e}
84
+ Always use proper dot notation for names and ensure all metadata is meaningful and accurate.`;
85
+ }
86
+ /**
87
+ * Create example-based prompt for better results.
88
+ */
89
+ function addExampleContext(basePrompt, examples) {
90
+ if (examples.length === 0) return basePrompt;
91
+ return `${basePrompt}
62
92
 
63
93
  Here are some good examples for reference:
64
94
 
65
- ${t.join(`
95
+ ${examples.join("\n\n")}
66
96
 
67
- `)}
97
+ Follow this structure and quality level.`;
98
+ }
68
99
 
69
- Follow this structure and quality level.`}export{e,i,n,r,t};
100
+ //#endregion
101
+ export { addExampleContext, buildEventSpecPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, getSystemPrompt };