@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217060834 → 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 (269) 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.d.ts +0 -3
  27. package/dist/index.js +81 -1
  28. package/dist/libs/ai-providers/dist/factory.js +154 -0
  29. package/dist/libs/ai-providers/dist/index.js +4 -0
  30. package/dist/libs/ai-providers/dist/legacy.js +72 -0
  31. package/dist/libs/ai-providers/dist/models.js +287 -0
  32. package/dist/libs/ai-providers/dist/validation.js +1 -0
  33. package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -0
  34. package/dist/libs/contracts/dist/client/index.js +5 -0
  35. package/dist/libs/contracts/dist/client/react/feature-render.js +2 -0
  36. package/dist/libs/contracts/dist/client/react/form-render.js +4 -0
  37. package/dist/libs/contracts/dist/client/react/index.js +4 -0
  38. package/dist/libs/contracts/dist/contract-registry/index.js +1 -0
  39. package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -0
  40. package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -0
  41. package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -0
  42. package/dist/libs/contracts/dist/docs/index.js +29 -0
  43. package/dist/libs/contracts/dist/docs/presentations.js +71 -0
  44. package/dist/libs/contracts/dist/docs/registry.js +44 -0
  45. package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -0
  46. package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -0
  47. package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -0
  48. package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -0
  49. package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -0
  50. package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +80 -0
  51. package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +57 -0
  52. package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -0
  53. package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +357 -0
  54. package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -0
  55. package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -0
  56. package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -0
  57. package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -0
  58. package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +79 -0
  59. package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +84 -0
  60. package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +45 -0
  61. package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -0
  62. package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +40 -0
  63. package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +69 -0
  64. package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -0
  65. package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +62 -0
  66. package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +155 -0
  67. package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -0
  68. package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +101 -0
  69. package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -0
  70. package/dist/libs/contracts/dist/events.js +8 -0
  71. package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
  72. package/dist/libs/contracts/dist/index.js +72 -0
  73. package/dist/libs/contracts/dist/install.js +2 -0
  74. package/dist/libs/contracts/dist/integrations/contracts.js +377 -0
  75. package/dist/libs/contracts/dist/integrations/index.js +18 -0
  76. package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -0
  77. package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -0
  78. package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -0
  79. package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -0
  80. package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -0
  81. package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -0
  82. package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -0
  83. package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -0
  84. package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -0
  85. package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -0
  86. package/dist/libs/contracts/dist/integrations/providers/index.js +11 -0
  87. package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -0
  88. package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -0
  89. package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -0
  90. package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -0
  91. package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -0
  92. package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -0
  93. package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -0
  94. package/dist/libs/contracts/dist/jsonschema.js +24 -0
  95. package/dist/libs/contracts/dist/knowledge/contracts.js +306 -0
  96. package/dist/libs/contracts/dist/knowledge/index.js +7 -0
  97. package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -0
  98. package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -0
  99. package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -0
  100. package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -0
  101. package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -0
  102. package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -0
  103. package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -0
  104. package/dist/libs/contracts/dist/llm/exporters.js +352 -0
  105. package/dist/libs/contracts/dist/llm/index.js +2 -0
  106. package/dist/libs/contracts/dist/llm/prompts.js +211 -0
  107. package/dist/libs/contracts/dist/onboarding-base.js +196 -0
  108. package/dist/libs/contracts/dist/openapi.js +75 -0
  109. package/dist/libs/contracts/dist/ownership.js +21 -0
  110. package/dist/libs/contracts/dist/presentations.js +1 -0
  111. package/dist/libs/contracts/dist/presentations.v2.js +11 -0
  112. package/dist/libs/contracts/dist/prompt.js +1 -0
  113. package/dist/libs/contracts/dist/promptRegistry.js +1 -0
  114. package/dist/libs/contracts/dist/regenerator/index.js +2 -0
  115. package/dist/libs/contracts/dist/regenerator/service.js +92 -0
  116. package/dist/libs/contracts/dist/regenerator/utils.js +51 -0
  117. package/dist/libs/contracts/dist/registry.js +208 -0
  118. package/dist/libs/contracts/dist/resources.js +1 -0
  119. package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -0
  120. package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -0
  121. package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -0
  122. package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +34 -0
  123. package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
  124. package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -0
  125. package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
  126. package/dist/libs/contracts/dist/schema/dist/index.js +6 -0
  127. package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -0
  128. package/dist/libs/contracts/dist/server/index.js +8 -0
  129. package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -0
  130. package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -0
  131. package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -0
  132. package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -0
  133. package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -0
  134. package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
  135. package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
  136. package/dist/libs/contracts/dist/server/rest-express.js +1 -0
  137. package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
  138. package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
  139. package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
  140. package/dist/libs/contracts/dist/spec.js +35 -0
  141. package/dist/libs/contracts/dist/telemetry/index.js +1 -0
  142. package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
  143. package/dist/libs/contracts/dist/tests/index.js +1 -0
  144. package/dist/libs/contracts/dist/tests/runner.js +150 -0
  145. package/dist/libs/contracts/dist/workflow/index.js +1 -0
  146. package/dist/libs/contracts/dist/workflow/runner.js +1 -0
  147. package/dist/libs/contracts-transformers/dist/common/utils.js +47 -0
  148. package/dist/libs/contracts-transformers/dist/openapi/exporter.js +1 -0
  149. package/dist/libs/contracts-transformers/dist/openapi/importer.js +255 -0
  150. package/dist/libs/contracts-transformers/dist/openapi/index.js +4 -0
  151. package/dist/libs/contracts-transformers/dist/openapi/parser.js +231 -0
  152. package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +201 -0
  153. package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +137 -0
  154. package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +101 -0
  155. package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +84 -0
  156. package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +30 -0
  157. package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +96 -0
  158. package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +151 -0
  159. package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +344 -0
  160. package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +122 -0
  161. package/dist/modules/contractspec-workspace/dist/templates/app-config.js +105 -0
  162. package/dist/modules/contractspec-workspace/dist/templates/data-view.js +68 -0
  163. package/dist/modules/contractspec-workspace/dist/templates/event.js +38 -0
  164. package/dist/modules/contractspec-workspace/dist/templates/experiment.js +87 -0
  165. package/dist/modules/contractspec-workspace/dist/templates/handler.js +95 -0
  166. package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +104 -0
  167. package/dist/modules/contractspec-workspace/dist/templates/integration.js +62 -0
  168. package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +68 -0
  169. package/dist/modules/contractspec-workspace/dist/templates/migration.js +60 -0
  170. package/dist/modules/contractspec-workspace/dist/templates/operation.js +100 -0
  171. package/dist/modules/contractspec-workspace/dist/templates/presentation.js +78 -0
  172. package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +89 -0
  173. package/dist/modules/contractspec-workspace/dist/templates/utils.js +38 -0
  174. package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +48 -0
  175. package/dist/modules/contractspec-workspace/dist/templates/workflow.js +67 -0
  176. package/dist/modules/contractspec-workspace/dist/types/generation-types.js +20 -0
  177. package/dist/services/agent-guide/adapters/claude-code.js +144 -3
  178. package/dist/services/agent-guide/adapters/cursor-cli.js +135 -3
  179. package/dist/services/agent-guide/adapters/generic-mcp.js +159 -3
  180. package/dist/services/agent-guide/adapters/index.js +30 -1
  181. package/dist/services/agent-guide/agent-guide-service.js +148 -1
  182. package/dist/services/agent-guide/index.js +5 -1
  183. package/dist/services/build.js +140 -1
  184. package/dist/services/ci-check/ci-check-service.js +393 -1
  185. package/dist/services/ci-check/index.js +2 -1
  186. package/dist/services/ci-check/types.js +28 -1
  187. package/dist/services/clean.js +71 -1
  188. package/dist/services/config.js +76 -1
  189. package/dist/services/deps.js +62 -1
  190. package/dist/services/diff.js +33 -1
  191. package/dist/services/doctor/checks/ai.js +118 -2
  192. package/dist/services/doctor/checks/cli.js +146 -1
  193. package/dist/services/doctor/checks/config.js +170 -1
  194. package/dist/services/doctor/checks/deps.js +180 -1
  195. package/dist/services/doctor/checks/index.js +6 -1
  196. package/dist/services/doctor/checks/mcp.js +144 -1
  197. package/dist/services/doctor/checks/workspace.js +243 -1
  198. package/dist/services/doctor/doctor-service.js +115 -2
  199. package/dist/services/doctor/index.js +2 -1
  200. package/dist/services/doctor/types.js +26 -1
  201. package/dist/services/implementation/discovery.js +143 -2
  202. package/dist/services/implementation/index.js +2 -1
  203. package/dist/services/implementation/resolver.js +223 -1
  204. package/dist/services/index.js +53 -1
  205. package/dist/services/integrity-diagram.js +274 -6
  206. package/dist/services/integrity.js +272 -1
  207. package/dist/services/list.js +35 -1
  208. package/dist/services/openapi/export-service.js +51 -2
  209. package/dist/services/openapi/import-service.js +75 -1
  210. package/dist/services/openapi/index.js +4 -1
  211. package/dist/services/openapi/sync-service.js +121 -1
  212. package/dist/services/openapi/validate-service.js +130 -1
  213. package/dist/services/regenerator.js +23 -1
  214. package/dist/services/registry.js +73 -1
  215. package/dist/services/setup/config-generators.js +113 -26
  216. package/dist/services/setup/file-merger.js +60 -2
  217. package/dist/services/setup/index.js +4 -1
  218. package/dist/services/setup/setup-service.js +95 -1
  219. package/dist/services/setup/targets/agents-md.js +46 -1
  220. package/dist/services/setup/targets/cli-config.js +59 -1
  221. package/dist/services/setup/targets/cursor-rules.js +47 -1
  222. package/dist/services/setup/targets/mcp-claude.js +59 -1
  223. package/dist/services/setup/targets/mcp-cursor.js +58 -1
  224. package/dist/services/setup/targets/vscode-settings.js +62 -1
  225. package/dist/services/setup/types.js +26 -1
  226. package/dist/services/sync.js +62 -1
  227. package/dist/services/test.js +30 -1
  228. package/dist/services/validate-implementation.js +69 -1
  229. package/dist/services/validate.js +47 -1
  230. package/dist/services/verification-cache/adapters/filesystem.js +121 -1
  231. package/dist/services/verification-cache/adapters/in-memory.js +45 -1
  232. package/dist/services/verification-cache/adapters/index.js +3 -1
  233. package/dist/services/verification-cache/adapters/workspace-state.js +90 -1
  234. package/dist/services/verification-cache/cache-service.js +255 -1
  235. package/dist/services/verification-cache/index.js +6 -1
  236. package/dist/services/verification-cache/types.js +15 -1
  237. package/dist/services/verify/ai-verifier.js +336 -9
  238. package/dist/services/verify/behavior-verifier.js +185 -1
  239. package/dist/services/verify/index.js +4 -1
  240. package/dist/services/verify/structure-verifier.js +195 -2
  241. package/dist/services/verify/verify-service.js +203 -3
  242. package/dist/services/watch.js +31 -1
  243. package/dist/services/workspace-info.js +102 -2
  244. package/dist/templates/app-config.template.js +101 -28
  245. package/dist/templates/data-view.template.js +42 -27
  246. package/dist/templates/event.template.js +29 -14
  247. package/dist/templates/experiment.template.js +77 -51
  248. package/dist/templates/handler.template.js +53 -17
  249. package/dist/templates/index.js +36 -1
  250. package/dist/templates/integration.template.js +134 -50
  251. package/dist/templates/knowledge.template.js +62 -21
  252. package/dist/templates/migration.template.js +50 -26
  253. package/dist/templates/operation.template.js +44 -28
  254. package/dist/templates/presentation.template.js +46 -20
  255. package/dist/templates/telemetry.template.js +74 -53
  256. package/dist/templates/workflow-runner.template.js +12 -6
  257. package/dist/templates/workflow.template.js +51 -24
  258. package/package.json +13 -9
  259. package/dist/adapters/index.d.ts +0 -7
  260. package/dist/ports/index.d.ts +0 -5
  261. package/dist/services/agent-guide/index.d.ts +0 -6
  262. package/dist/services/ci-check/index.d.ts +0 -2
  263. package/dist/services/doctor/index.d.ts +0 -2
  264. package/dist/services/implementation/index.d.ts +0 -3
  265. package/dist/services/index.d.ts +0 -56
  266. package/dist/services/openapi/index.d.ts +0 -5
  267. package/dist/services/verification-cache/adapters/index.d.ts +0 -3
  268. package/dist/services/verification-cache/index.d.ts +0 -6
  269. package/dist/services/verify/index.d.ts +0 -5
@@ -1,2 +1,195 @@
1
- import{isEmitDeclRef as e}from"@lssm/lib.contracts/spec";function t(e){let t=/export\s+(async\s+)?function\s+\w+/.test(e)||/export\s+const\s+\w+\s*=\s*(async\s*)?\(/.test(e)||/export\s+default\s+(async\s+)?function/.test(e)||/export\s+\{\s*\w+/.test(e);return{name:`handler_export`,passed:t,details:t?void 0:`No exported handler function found`,suggestion:`Export a function that handles the operation: export async function handle(...) { }`}}function n(e){let t=e.includes(`from '@lssm/lib.contracts'`)||e.includes(`from "@lssm/lib.contracts"`);return{name:`contracts_import`,passed:t,details:t?void 0:`Missing import from @lssm/lib.contracts`,suggestion:`Add: import { ... } from '@lssm/lib.contracts';`}}function r(e,t){if(!(t.io.input!==null||t.io.output!==null))return{name:`schema_import`,passed:!0};let n=e.includes(`from '@lssm/lib.schema'`)||e.includes(`from "@lssm/lib.schema"`);return{name:`schema_import`,passed:n,details:n?void 0:`Missing import from @lssm/lib.schema`,suggestion:`Add: import { ... } from '@lssm/lib.schema';`}}function i(e){let t=/:\s*any\b|as\s+any\b|<any>/,n=e.split(`
2
- `),r=[];for(let e=0;e<n.length;e++){let i=n[e]??``;i.trim().startsWith(`//`)||i.trim().startsWith(`*`)||t.test(i)&&r.push(e+1)}return{name:`no_any_type`,passed:r.length===0,details:r.length>0?`Found 'any' type on lines: ${r.slice(0,5).join(`, `)}${r.length>5?`...`:``}`:void 0,suggestion:`Replace any with proper types from the spec schema`}}function a(e,t){let n=t.io.errors;if(!n||Object.keys(n).length===0)return{name:`error_handling`,passed:!0};let r=Object.keys(n),i=[];for(let t of r)e.includes(t)||i.push(t);return{name:`error_handling`,passed:i.length===0,details:i.length>0?`Missing error handling for: ${i.join(`, `)}`:void 0,suggestion:`Implement handlers for all error cases defined in the spec`}}function o(t,n){let r=n.sideEffects?.emits;if(!r||r.length===0)return{name:`event_emission`,passed:!0};let i=t.includes(`emit(`)||t.includes(`.emit(`)||t.includes(`publish(`)||t.includes(`.publish(`)||t.includes(`dispatchEvent`)||t.includes(`eventBus`),a=r.map(t=>e(t)?t.ref.name:t.name),o=a.filter(e=>t.includes(e));return{name:`event_emission`,passed:i&&o.length>0,details:i?o.length===0?`Events not referenced: ${a.join(`, `)}`:void 0:`No event emission pattern found`,suggestion:`Emit events as specified in sideEffects.emits`}}function s(e,t){if(!t.io.input)return{name:`input_validation`,passed:!0};let n=e.includes(`.parse(`)||e.includes(`.safeParse(`)||e.includes(`validate(`)||e.includes(`.validate(`)||e.includes(`schema.`)||e.includes(`zodSchema`)||e.includes(`.getZod()`);return{name:`input_validation`,passed:n,details:n?void 0:`No input validation pattern found`,suggestion:`Validate input using the schema: schema.parse(input) or schema.safeParse(input)`}}function c(e,t){let n=/export\s+(const\s+\w+\s*=\s*)?async/.test(e)||/async\s+function/.test(e);return t.meta.kind===`command`?{name:`async_patterns`,passed:n,details:n?void 0:`Handler should be async for command operations`,suggestion:`Make the handler function async: export async function handle(...)`}:{name:`async_patterns`,passed:!0}}function l(e){let{spec:l,implementationCode:u,implementationPath:d}=e,f=Date.now(),p=[t(u),n(u),r(u,l),i(u),a(u,l),o(u,l),s(u,l),c(u,l)],m=p.filter(e=>!e.passed).map(e=>({severity:e.name===`no_any_type`?`warning`:`error`,category:e.name.includes(`import`)?`import`:e.name.includes(`export`)?`export`:`type`,message:e.details??`Check failed: ${e.name}`,location:d?{file:d}:void 0,suggestion:e.suggestion})),h=p.filter(e=>e.passed).length,g=Math.round(h/p.length*100),_=m.filter(e=>e.severity===`error`).length===0,v=p.filter(e=>!e.passed&&e.suggestion).map(e=>e.suggestion),y=Object.keys(l.io.errors??{}).length;return{tier:`structure`,passed:_,score:g,issues:m,suggestions:v,coverage:{scenarios:{total:0,covered:0},errors:{total:y,handled:p.find(e=>e.name===`error_handling`)?.passed?y:0},fields:{total:p.length,implemented:h}},meta:{specName:l.meta.name,specVersion:l.meta.version,implementationPath:d??`unknown`,verifiedAt:new Date().toISOString(),duration:Date.now()-f}}}export{l as verifyStructure};
1
+ import { isEmitDeclRef } from "../../libs/contracts/dist/spec.js";
2
+
3
+ //#region src/services/verify/structure-verifier.ts
4
+ /**
5
+ * Check if code exports a handler function.
6
+ */
7
+ function checkHandlerExport(code) {
8
+ const hasExport = /export\s+(async\s+)?function\s+\w+/.test(code) || /export\s+const\s+\w+\s*=\s*(async\s*)?\(/.test(code) || /export\s+default\s+(async\s+)?function/.test(code) || /export\s+\{\s*\w+/.test(code);
9
+ return {
10
+ name: "handler_export",
11
+ passed: hasExport,
12
+ details: hasExport ? void 0 : "No exported handler function found",
13
+ suggestion: "Export a function that handles the operation: export async function handle(...) { }"
14
+ };
15
+ }
16
+ /**
17
+ * Check if code imports from @lssm/lib.contracts.
18
+ */
19
+ function checkContractsImport(code) {
20
+ const hasImport = code.includes("from '@lssm/lib.contracts'") || code.includes("from \"@lssm/lib.contracts\"");
21
+ return {
22
+ name: "contracts_import",
23
+ passed: hasImport,
24
+ details: hasImport ? void 0 : "Missing import from @lssm/lib.contracts",
25
+ suggestion: "Add: import { ... } from '@lssm/lib.contracts';"
26
+ };
27
+ }
28
+ /**
29
+ * Check if code imports from @lssm/lib.schema.
30
+ */
31
+ function checkSchemaImport(code, spec) {
32
+ if (!(spec.io.input !== null || spec.io.output !== null)) return {
33
+ name: "schema_import",
34
+ passed: true
35
+ };
36
+ const hasImport = code.includes("from '@lssm/lib.schema'") || code.includes("from \"@lssm/lib.schema\"");
37
+ return {
38
+ name: "schema_import",
39
+ passed: hasImport,
40
+ details: hasImport ? void 0 : "Missing import from @lssm/lib.schema",
41
+ suggestion: "Add: import { ... } from '@lssm/lib.schema';"
42
+ };
43
+ }
44
+ /**
45
+ * Check for TypeScript any usage.
46
+ */
47
+ function checkNoAnyType(code) {
48
+ const anyPattern = /:\s*any\b|as\s+any\b|<any>/;
49
+ const lines = code.split("\n");
50
+ const anyUsages = [];
51
+ for (let i = 0; i < lines.length; i++) {
52
+ const line = lines[i] ?? "";
53
+ if (line.trim().startsWith("//") || line.trim().startsWith("*")) continue;
54
+ if (anyPattern.test(line)) anyUsages.push(i + 1);
55
+ }
56
+ return {
57
+ name: "no_any_type",
58
+ passed: anyUsages.length === 0,
59
+ details: anyUsages.length > 0 ? `Found 'any' type on lines: ${anyUsages.slice(0, 5).join(", ")}${anyUsages.length > 5 ? "..." : ""}` : void 0,
60
+ suggestion: "Replace any with proper types from the spec schema"
61
+ };
62
+ }
63
+ /**
64
+ * Check if error codes from spec are handled.
65
+ */
66
+ function checkErrorHandling(code, spec) {
67
+ const errors = spec.io.errors;
68
+ if (!errors || Object.keys(errors).length === 0) return {
69
+ name: "error_handling",
70
+ passed: true
71
+ };
72
+ const errorCodes = Object.keys(errors);
73
+ const missingErrors = [];
74
+ for (const errorCode of errorCodes) if (!code.includes(errorCode)) missingErrors.push(errorCode);
75
+ return {
76
+ name: "error_handling",
77
+ passed: missingErrors.length === 0,
78
+ details: missingErrors.length > 0 ? `Missing error handling for: ${missingErrors.join(", ")}` : void 0,
79
+ suggestion: "Implement handlers for all error cases defined in the spec"
80
+ };
81
+ }
82
+ /**
83
+ * Check if events are emitted.
84
+ */
85
+ function checkEventEmission(code, spec) {
86
+ const events = spec.sideEffects?.emits;
87
+ if (!events || events.length === 0) return {
88
+ name: "event_emission",
89
+ passed: true
90
+ };
91
+ const hasEmitPattern = code.includes("emit(") || code.includes(".emit(") || code.includes("publish(") || code.includes(".publish(") || code.includes("dispatchEvent") || code.includes("eventBus");
92
+ const eventNames = events.map((e) => {
93
+ if (isEmitDeclRef(e)) return e.ref.name;
94
+ return e.name;
95
+ });
96
+ const mentionedEvents = eventNames.filter((name) => code.includes(name));
97
+ return {
98
+ name: "event_emission",
99
+ passed: hasEmitPattern && mentionedEvents.length > 0,
100
+ details: !hasEmitPattern ? "No event emission pattern found" : mentionedEvents.length === 0 ? `Events not referenced: ${eventNames.join(", ")}` : void 0,
101
+ suggestion: "Emit events as specified in sideEffects.emits"
102
+ };
103
+ }
104
+ /**
105
+ * Check for validation of input.
106
+ */
107
+ function checkInputValidation(code, spec) {
108
+ if (!spec.io.input) return {
109
+ name: "input_validation",
110
+ passed: true
111
+ };
112
+ const hasValidation = code.includes(".parse(") || code.includes(".safeParse(") || code.includes("validate(") || code.includes(".validate(") || code.includes("schema.") || code.includes("zodSchema") || code.includes(".getZod()");
113
+ return {
114
+ name: "input_validation",
115
+ passed: hasValidation,
116
+ details: hasValidation ? void 0 : "No input validation pattern found",
117
+ suggestion: "Validate input using the schema: schema.parse(input) or schema.safeParse(input)"
118
+ };
119
+ }
120
+ /**
121
+ * Check for async/await usage on async operations.
122
+ */
123
+ function checkAsyncPatterns(code, spec) {
124
+ const isAsync = /export\s+(const\s+\w+\s*=\s*)?async/.test(code) || /async\s+function/.test(code);
125
+ if (!(spec.meta.kind === "command")) return {
126
+ name: "async_patterns",
127
+ passed: true
128
+ };
129
+ return {
130
+ name: "async_patterns",
131
+ passed: isAsync,
132
+ details: isAsync ? void 0 : "Handler should be async for command operations",
133
+ suggestion: "Make the handler function async: export async function handle(...)"
134
+ };
135
+ }
136
+ /**
137
+ * Run all structure checks and produce a verification report.
138
+ */
139
+ function verifyStructure(input) {
140
+ const { spec, implementationCode, implementationPath } = input;
141
+ const startTime = Date.now();
142
+ const checks = [
143
+ checkHandlerExport(implementationCode),
144
+ checkContractsImport(implementationCode),
145
+ checkSchemaImport(implementationCode, spec),
146
+ checkNoAnyType(implementationCode),
147
+ checkErrorHandling(implementationCode, spec),
148
+ checkEventEmission(implementationCode, spec),
149
+ checkInputValidation(implementationCode, spec),
150
+ checkAsyncPatterns(implementationCode, spec)
151
+ ];
152
+ const issues = checks.filter((c) => !c.passed).map((c) => ({
153
+ severity: c.name === "no_any_type" ? "warning" : "error",
154
+ category: c.name.includes("import") ? "import" : c.name.includes("export") ? "export" : "type",
155
+ message: c.details ?? `Check failed: ${c.name}`,
156
+ location: implementationPath ? { file: implementationPath } : void 0,
157
+ suggestion: c.suggestion
158
+ }));
159
+ const passedCount = checks.filter((c) => c.passed).length;
160
+ const score = Math.round(passedCount / checks.length * 100);
161
+ const passed = issues.filter((i) => i.severity === "error").length === 0;
162
+ const suggestions = checks.filter((c) => !c.passed && c.suggestion).map((c) => c.suggestion);
163
+ const errorCount = Object.keys(spec.io.errors ?? {}).length;
164
+ return {
165
+ tier: "structure",
166
+ passed,
167
+ score,
168
+ issues,
169
+ suggestions,
170
+ coverage: {
171
+ scenarios: {
172
+ total: 0,
173
+ covered: 0
174
+ },
175
+ errors: {
176
+ total: errorCount,
177
+ handled: checks.find((c) => c.name === "error_handling")?.passed ? errorCount : 0
178
+ },
179
+ fields: {
180
+ total: checks.length,
181
+ implemented: passedCount
182
+ }
183
+ },
184
+ meta: {
185
+ specName: spec.meta.name,
186
+ specVersion: spec.meta.version,
187
+ implementationPath: implementationPath ?? "unknown",
188
+ verifiedAt: (/* @__PURE__ */ new Date()).toISOString(),
189
+ duration: Date.now() - startTime
190
+ }
191
+ };
192
+ }
193
+
194
+ //#endregion
195
+ export { verifyStructure };
@@ -1,3 +1,203 @@
1
- import{verifyStructure as e}from"./structure-verifier.js";import{verifyBehavior as t}from"./behavior-verifier.js";import{createQuickAIReview as n,verifyWithAI as r}from"./ai-verifier.js";const i={verbose:!1},a=[`structure`,`behavior`,`ai_review`];var o=class{config;constructor(e={}){this.config={...i,...e}}async verify(i,o,s={}){let c=Date.now(),l=new Map,u=[],d={spec:i,implementationCode:o},f=s.tiers??[`structure`,`behavior`];for(let i of a){if(!f.includes(i))continue;let a;switch(i){case`structure`:a=e(d);break;case`behavior`:a=t(d);break;case`ai_review`:a=this.config.aiApiKey?await r(d,this.config):n(d);break;default:continue}if(l.set(i,a),u.push(...a.issues),s.failFast&&!a.passed)break}let p=Array.from(l.values());return{passed:p.every(e=>e.passed),score:p.length>0?Math.round(p.reduce((e,t)=>e+t.score,0)/p.length):100,reports:l,allIssues:u,summary:this.generateSummary(p,u),duration:Date.now()-c}}verifyStructure(t,n,r){return e({spec:t,implementationCode:n,implementationPath:r})}verifyBehavior(e,n,r){return t({spec:e,implementationCode:n,implementationPath:r})}async verifyAI(e,t,i){let a={spec:e,implementationCode:t,implementationPath:i};return this.config.aiApiKey?r(a,this.config):n(a)}quickVerify(t,n){return e({spec:t,implementationCode:n})}generateSummary(e,t){let n=[],r=e.every(e=>e.passed),i=e.length>0?Math.round(e.reduce((e,t)=>e+t.score,0)/e.length):100;n.push(r?`✓ Verification passed`:`✗ Verification failed`),n.push(`Score: ${i}/100`),n.push(``);for(let t of e){let e=t.passed?`✓`:`✗`;n.push(`${e} ${t.tier}: ${t.score}/100`)}n.push(``);let a=t.filter(e=>e.severity===`error`),o=t.filter(e=>e.severity===`warning`),s=t.filter(e=>e.severity===`info`);return a.length>0&&n.push(`Errors: ${a.length}`),o.length>0&&n.push(`Warnings: ${o.length}`),s.length>0&&n.push(`Info: ${s.length}`),n.join(`
2
- `)}formatAsMarkdown(e){let t=[];t.push(`# Verification Report`),t.push(``),t.push(`**Status:** ${e.passed?`✓ Passed`:`✗ Failed`}`),t.push(`**Score:** ${e.score}/100`),t.push(`**Duration:** ${e.duration}ms`),t.push(``);for(let[n,r]of e.reports){if(t.push(`## ${this.formatTierName(n)}`),t.push(``),t.push(`**Status:** ${r.passed?`✓ Passed`:`✗ Failed`}`),t.push(`**Score:** ${r.score}/100`),t.push(``),r.issues.length>0){t.push(`### Issues`),t.push(``);for(let e of r.issues){let n=e.severity===`error`?`❌`:e.severity===`warning`?`⚠️`:`ℹ️`;t.push(`${n} **${e.category}**: ${e.message}`),e.suggestion&&t.push(` - Suggestion: ${e.suggestion}`)}t.push(``)}r.coverage.scenarios.total>0&&t.push(`**Scenarios:** ${r.coverage.scenarios.covered}/${r.coverage.scenarios.total}`),r.coverage.errors.total>0&&t.push(`**Errors handled:** ${r.coverage.errors.handled}/${r.coverage.errors.total}`),t.push(``)}let n=Array.from(e.reports.values()).flatMap(e=>e.suggestions);if(n.length>0){t.push(`## Suggestions`),t.push(``);for(let e of n.slice(0,10))t.push(`- ${e}`);n.length>10&&t.push(`- ... and ${n.length-10} more`),t.push(``)}return t.join(`
3
- `)}formatTierName(e){switch(e){case`structure`:return`Tier 1: Structure`;case`behavior`:return`Tier 2: Behavior`;case`ai_review`:return`Tier 3: AI Review`;default:return e}}configure(e){this.config={...this.config,...e}}};function s(e){return new o(e)}const c=new o;export{o as VerifyService,s as createVerifyService,c as verifyService};
1
+ import { verifyStructure } from "./structure-verifier.js";
2
+ import { verifyBehavior } from "./behavior-verifier.js";
3
+ import { createQuickAIReview, verifyWithAI } from "./ai-verifier.js";
4
+
5
+ //#region src/services/verify/verify-service.ts
6
+ const DEFAULT_CONFIG = { verbose: false };
7
+ const TIER_ORDER = [
8
+ "structure",
9
+ "behavior",
10
+ "ai_review"
11
+ ];
12
+ /**
13
+ * Verification Service
14
+ *
15
+ * Main service for verifying implementations against specs.
16
+ */
17
+ var VerifyService = class {
18
+ config;
19
+ constructor(config = {}) {
20
+ this.config = {
21
+ ...DEFAULT_CONFIG,
22
+ ...config
23
+ };
24
+ }
25
+ /**
26
+ * Run verification on an implementation.
27
+ */
28
+ async verify(spec, implementationCode, options = {}) {
29
+ const startTime = Date.now();
30
+ const reports = /* @__PURE__ */ new Map();
31
+ const allIssues = [];
32
+ const input = {
33
+ spec,
34
+ implementationCode
35
+ };
36
+ const tiersToRun = options.tiers ?? ["structure", "behavior"];
37
+ for (const tier of TIER_ORDER) {
38
+ if (!tiersToRun.includes(tier)) continue;
39
+ let report;
40
+ switch (tier) {
41
+ case "structure":
42
+ report = verifyStructure(input);
43
+ break;
44
+ case "behavior":
45
+ report = verifyBehavior(input);
46
+ break;
47
+ case "ai_review":
48
+ if (this.config.aiApiKey) report = await verifyWithAI(input, this.config);
49
+ else report = createQuickAIReview(input);
50
+ break;
51
+ default: continue;
52
+ }
53
+ reports.set(tier, report);
54
+ allIssues.push(...report.issues);
55
+ if (options.failFast && !report.passed) break;
56
+ }
57
+ const reportsArray = Array.from(reports.values());
58
+ return {
59
+ passed: reportsArray.every((r) => r.passed),
60
+ score: reportsArray.length > 0 ? Math.round(reportsArray.reduce((sum, r) => sum + r.score, 0) / reportsArray.length) : 100,
61
+ reports,
62
+ allIssues,
63
+ summary: this.generateSummary(reportsArray, allIssues),
64
+ duration: Date.now() - startTime
65
+ };
66
+ }
67
+ /**
68
+ * Run only structure verification (Tier 1).
69
+ */
70
+ verifyStructure(spec, implementationCode, implementationPath) {
71
+ return verifyStructure({
72
+ spec,
73
+ implementationCode,
74
+ implementationPath
75
+ });
76
+ }
77
+ /**
78
+ * Run only behavior verification (Tier 2).
79
+ */
80
+ verifyBehavior(spec, implementationCode, implementationPath) {
81
+ return verifyBehavior({
82
+ spec,
83
+ implementationCode,
84
+ implementationPath
85
+ });
86
+ }
87
+ /**
88
+ * Run only AI verification (Tier 3).
89
+ */
90
+ async verifyAI(spec, implementationCode, implementationPath) {
91
+ const input = {
92
+ spec,
93
+ implementationCode,
94
+ implementationPath
95
+ };
96
+ if (this.config.aiApiKey) return verifyWithAI(input, this.config);
97
+ return createQuickAIReview(input);
98
+ }
99
+ /**
100
+ * Quick verification (structure only, fast).
101
+ */
102
+ quickVerify(spec, implementationCode) {
103
+ return verifyStructure({
104
+ spec,
105
+ implementationCode
106
+ });
107
+ }
108
+ /**
109
+ * Generate a human-readable summary of verification results.
110
+ */
111
+ generateSummary(reports, allIssues) {
112
+ const parts = [];
113
+ const passed = reports.every((r) => r.passed);
114
+ const avgScore = reports.length > 0 ? Math.round(reports.reduce((sum, r) => sum + r.score, 0) / reports.length) : 100;
115
+ parts.push(passed ? "✓ Verification passed" : "✗ Verification failed");
116
+ parts.push(`Score: ${avgScore}/100`);
117
+ parts.push("");
118
+ for (const report of reports) {
119
+ const icon = report.passed ? "✓" : "✗";
120
+ parts.push(`${icon} ${report.tier}: ${report.score}/100`);
121
+ }
122
+ parts.push("");
123
+ const errors = allIssues.filter((i) => i.severity === "error");
124
+ const warnings = allIssues.filter((i) => i.severity === "warning");
125
+ const infos = allIssues.filter((i) => i.severity === "info");
126
+ if (errors.length > 0) parts.push(`Errors: ${errors.length}`);
127
+ if (warnings.length > 0) parts.push(`Warnings: ${warnings.length}`);
128
+ if (infos.length > 0) parts.push(`Info: ${infos.length}`);
129
+ return parts.join("\n");
130
+ }
131
+ /**
132
+ * Format verification result as markdown.
133
+ */
134
+ formatAsMarkdown(result) {
135
+ const lines = [];
136
+ lines.push(`# Verification Report`);
137
+ lines.push("");
138
+ lines.push(`**Status:** ${result.passed ? "✓ Passed" : "✗ Failed"}`);
139
+ lines.push(`**Score:** ${result.score}/100`);
140
+ lines.push(`**Duration:** ${result.duration}ms`);
141
+ lines.push("");
142
+ for (const [tier, report] of result.reports) {
143
+ lines.push(`## ${this.formatTierName(tier)}`);
144
+ lines.push("");
145
+ lines.push(`**Status:** ${report.passed ? "✓ Passed" : "✗ Failed"}`);
146
+ lines.push(`**Score:** ${report.score}/100`);
147
+ lines.push("");
148
+ if (report.issues.length > 0) {
149
+ lines.push("### Issues");
150
+ lines.push("");
151
+ for (const issue of report.issues) {
152
+ const icon = issue.severity === "error" ? "❌" : issue.severity === "warning" ? "⚠️" : "ℹ️";
153
+ lines.push(`${icon} **${issue.category}**: ${issue.message}`);
154
+ if (issue.suggestion) lines.push(` - Suggestion: ${issue.suggestion}`);
155
+ }
156
+ lines.push("");
157
+ }
158
+ if (report.coverage.scenarios.total > 0) lines.push(`**Scenarios:** ${report.coverage.scenarios.covered}/${report.coverage.scenarios.total}`);
159
+ if (report.coverage.errors.total > 0) lines.push(`**Errors handled:** ${report.coverage.errors.handled}/${report.coverage.errors.total}`);
160
+ lines.push("");
161
+ }
162
+ const allSuggestions = Array.from(result.reports.values()).flatMap((r) => r.suggestions);
163
+ if (allSuggestions.length > 0) {
164
+ lines.push("## Suggestions");
165
+ lines.push("");
166
+ for (const suggestion of allSuggestions.slice(0, 10)) lines.push(`- ${suggestion}`);
167
+ if (allSuggestions.length > 10) lines.push(`- ... and ${allSuggestions.length - 10} more`);
168
+ lines.push("");
169
+ }
170
+ return lines.join("\n");
171
+ }
172
+ /**
173
+ * Format tier name for display.
174
+ */
175
+ formatTierName(tier) {
176
+ switch (tier) {
177
+ case "structure": return "Tier 1: Structure";
178
+ case "behavior": return "Tier 2: Behavior";
179
+ case "ai_review": return "Tier 3: AI Review";
180
+ default: return tier;
181
+ }
182
+ }
183
+ /**
184
+ * Update configuration.
185
+ */
186
+ configure(config) {
187
+ this.config = {
188
+ ...this.config,
189
+ ...config
190
+ };
191
+ }
192
+ };
193
+ /**
194
+ * Create a new VerifyService instance.
195
+ */
196
+ function createVerifyService(config) {
197
+ return new VerifyService(config);
198
+ }
199
+ /** Default singleton instance */
200
+ const verifyService = new VerifyService();
201
+
202
+ //#endregion
203
+ export { VerifyService, createVerifyService, verifyService };
@@ -1 +1,31 @@
1
- import{validateSpec as e}from"./validate.js";import{buildSpec as t}from"./build.js";function n(n,r,i,a){let{watcher:o,fs:s,logger:c}=n,l=o.watch(i),u=a?.validate??(async t=>{await e(t,{fs:s,logger:c})}),d=a?.build??(async e=>{await t(e,{fs:s,logger:c},r)});return l.on(async e=>{e.type===`change`&&(c.info(`watchSpecs.changed`,{path:e.path}),i.runValidate&&await u(e.path),i.runBuild&&(i.dryRun?c.info(`[dry-run] watchSpecs skipped build`,{path:e.path}):await d(e.path)))}),l}export{n as watchSpecs};
1
+ import { validateSpec } from "./validate.js";
2
+ import { buildSpec } from "./build.js";
3
+
4
+ //#region src/services/watch.ts
5
+ function watchSpecs(adapters, config, options, overrides) {
6
+ const { watcher, fs, logger } = adapters;
7
+ const w = watcher.watch(options);
8
+ const validateFn = overrides?.validate ?? (async (specPath) => {
9
+ await validateSpec(specPath, {
10
+ fs,
11
+ logger
12
+ });
13
+ });
14
+ const buildFn = overrides?.build ?? (async (specPath) => {
15
+ await buildSpec(specPath, {
16
+ fs,
17
+ logger
18
+ }, config);
19
+ });
20
+ w.on(async (event) => {
21
+ if (event.type !== "change") return;
22
+ logger.info("watchSpecs.changed", { path: event.path });
23
+ if (options.runValidate) await validateFn(event.path);
24
+ if (options.runBuild) if (options.dryRun) logger.info("[dry-run] watchSpecs skipped build", { path: event.path });
25
+ else await buildFn(event.path);
26
+ });
27
+ return w;
28
+ }
29
+
30
+ //#endregion
31
+ export { watchSpecs };
@@ -1,2 +1,102 @@
1
- import{detectPackageManager as e,findPackageRoot as t,findWorkspaceRoot as n,getWorkspaceInfo as r}from"../adapters/workspace.js";async function i(e,t){let n=r(t),i=e.join(n.workspaceRoot,`.contractsrc.json`),a=e.join(n.packageRoot,`.contractsrc.json`),o=await e.exists(i),s=n.workspaceRoot===n.packageRoot?!1:await e.exists(a),c;if(o)try{let t=await e.readFile(i),n=JSON.parse(t);(n.packages||n.excludePackages||n.recursive)&&(c={packages:n.packages,excludePackages:n.excludePackages,recursive:n.recursive})}catch{}return{...n,monorepoConfig:c,workspaceConfigPath:o?i:void 0,packageConfigPath:s?a:void 0}}async function a(e,t){let n=[],r=e.join(t,`.contractsrc.json`);await e.exists(r)&&n.push(r);let i=await e.glob({pattern:`**/.contractsrc.json`,ignore:[`node_modules/**`,`.git/**`]});for(let e of i)e!==r&&n.push(e);return n}async function o(e,t,n){let r={};if(t&&await e.exists(t))try{let n=await e.readFile(t);r=JSON.parse(n)}catch{}if(n&&await e.exists(n))try{let t=await e.readFile(n),i=JSON.parse(t);r=s(r,i)}catch{}return r}function s(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];typeof i==`object`&&i&&!Array.isArray(i)&&typeof a==`object`&&a&&!Array.isArray(a)?n[r]=s(i,a):n[r]=a}return n}function c(e){let t=[];return t.push(`Package Manager: ${e.packageManager}`),t.push(`Workspace Root: ${e.workspaceRoot}`),e.isMonorepo?(t.push(`Monorepo: Yes`),t.push(`Package Root: ${e.packageRoot}`),e.packageName&&t.push(`Current Package: ${e.packageName}`),e.packages&&e.packages.length>0&&t.push(`Package Patterns: ${e.packages.join(`, `)}`)):t.push(`Monorepo: No`),e.workspaceConfigPath&&t.push(`Workspace Config: ${e.workspaceConfigPath}`),e.packageConfigPath&&t.push(`Package Config: ${e.packageConfigPath}`),t.join(`
2
- `)}export{a as findAllConfigFiles,c as formatWorkspaceInfo,i as getExtendedWorkspaceInfo,o as mergeMonorepoConfigs};
1
+ import { detectPackageManager, findPackageRoot, findWorkspaceRoot, getWorkspaceInfo } from "../adapters/workspace.js";
2
+
3
+ //#region src/services/workspace-info.ts
4
+ /**
5
+ * Workspace info service.
6
+ *
7
+ * Provides workspace detection and configuration loading
8
+ * with support for monorepos.
9
+ */
10
+ /**
11
+ * Get extended workspace information including config paths.
12
+ */
13
+ async function getExtendedWorkspaceInfo(fs, startDir) {
14
+ const baseInfo = getWorkspaceInfo(startDir);
15
+ const workspaceConfigPath = fs.join(baseInfo.workspaceRoot, ".contractsrc.json");
16
+ const packageConfigPath = fs.join(baseInfo.packageRoot, ".contractsrc.json");
17
+ const hasWorkspaceConfig = await fs.exists(workspaceConfigPath);
18
+ const hasPackageConfig = baseInfo.workspaceRoot !== baseInfo.packageRoot ? await fs.exists(packageConfigPath) : false;
19
+ let monorepoConfig;
20
+ if (hasWorkspaceConfig) try {
21
+ const content = await fs.readFile(workspaceConfigPath);
22
+ const config = JSON.parse(content);
23
+ if (config.packages || config.excludePackages || config.recursive) monorepoConfig = {
24
+ packages: config.packages,
25
+ excludePackages: config.excludePackages,
26
+ recursive: config.recursive
27
+ };
28
+ } catch {}
29
+ return {
30
+ ...baseInfo,
31
+ monorepoConfig,
32
+ workspaceConfigPath: hasWorkspaceConfig ? workspaceConfigPath : void 0,
33
+ packageConfigPath: hasPackageConfig ? packageConfigPath : void 0
34
+ };
35
+ }
36
+ /**
37
+ * Find all .contractsrc.json files in a monorepo.
38
+ *
39
+ * Returns paths in order of priority (workspace first, then packages).
40
+ */
41
+ async function findAllConfigFiles(fs, workspaceRoot) {
42
+ const configFiles = [];
43
+ const rootConfig = fs.join(workspaceRoot, ".contractsrc.json");
44
+ if (await fs.exists(rootConfig)) configFiles.push(rootConfig);
45
+ const packageConfigs = await fs.glob({
46
+ pattern: "**/.contractsrc.json",
47
+ ignore: ["node_modules/**", ".git/**"]
48
+ });
49
+ for (const config of packageConfigs) if (config !== rootConfig) configFiles.push(config);
50
+ return configFiles;
51
+ }
52
+ /**
53
+ * Merge workspace and package configurations.
54
+ *
55
+ * Package config overrides workspace config.
56
+ */
57
+ async function mergeMonorepoConfigs(fs, workspaceConfigPath, packageConfigPath) {
58
+ let merged = {};
59
+ if (workspaceConfigPath && await fs.exists(workspaceConfigPath)) try {
60
+ const content = await fs.readFile(workspaceConfigPath);
61
+ merged = JSON.parse(content);
62
+ } catch {}
63
+ if (packageConfigPath && await fs.exists(packageConfigPath)) try {
64
+ const content = await fs.readFile(packageConfigPath);
65
+ const packageConfig = JSON.parse(content);
66
+ merged = deepMerge(merged, packageConfig);
67
+ } catch {}
68
+ return merged;
69
+ }
70
+ /**
71
+ * Deep merge two objects.
72
+ */
73
+ function deepMerge(base, override) {
74
+ const result = { ...base };
75
+ for (const key of Object.keys(override)) {
76
+ const baseValue = base[key];
77
+ const overrideValue = override[key];
78
+ if (typeof baseValue === "object" && baseValue !== null && !Array.isArray(baseValue) && typeof overrideValue === "object" && overrideValue !== null && !Array.isArray(overrideValue)) result[key] = deepMerge(baseValue, overrideValue);
79
+ else result[key] = overrideValue;
80
+ }
81
+ return result;
82
+ }
83
+ /**
84
+ * Format workspace info for display.
85
+ */
86
+ function formatWorkspaceInfo(info) {
87
+ const lines = [];
88
+ lines.push(`Package Manager: ${info.packageManager}`);
89
+ lines.push(`Workspace Root: ${info.workspaceRoot}`);
90
+ if (info.isMonorepo) {
91
+ lines.push(`Monorepo: Yes`);
92
+ lines.push(`Package Root: ${info.packageRoot}`);
93
+ if (info.packageName) lines.push(`Current Package: ${info.packageName}`);
94
+ if (info.packages && info.packages.length > 0) lines.push(`Package Patterns: ${info.packages.join(", ")}`);
95
+ } else lines.push(`Monorepo: No`);
96
+ if (info.workspaceConfigPath) lines.push(`Workspace Config: ${info.workspaceConfigPath}`);
97
+ if (info.packageConfigPath) lines.push(`Package Config: ${info.packageConfigPath}`);
98
+ return lines.join("\n");
99
+ }
100
+
101
+ //#endregion
102
+ export { findAllConfigFiles, formatWorkspaceInfo, getExtendedWorkspaceInfo, mergeMonorepoConfigs };