@contractspec/module.workspace 0.0.0-canary-20260113162409

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 (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -0
  3. package/dist/ai/prompts/code-generation.d.ts +24 -0
  4. package/dist/ai/prompts/code-generation.d.ts.map +1 -0
  5. package/dist/ai/prompts/code-generation.js +134 -0
  6. package/dist/ai/prompts/code-generation.js.map +1 -0
  7. package/dist/ai/prompts/spec-creation.d.ts +28 -0
  8. package/dist/ai/prompts/spec-creation.d.ts.map +1 -0
  9. package/dist/ai/prompts/spec-creation.js +102 -0
  10. package/dist/ai/prompts/spec-creation.js.map +1 -0
  11. package/dist/analysis/deps/graph.d.ts +34 -0
  12. package/dist/analysis/deps/graph.d.ts.map +1 -0
  13. package/dist/analysis/deps/graph.js +85 -0
  14. package/dist/analysis/deps/graph.js.map +1 -0
  15. package/dist/analysis/deps/parse-imports.d.ts +17 -0
  16. package/dist/analysis/deps/parse-imports.d.ts.map +1 -0
  17. package/dist/analysis/deps/parse-imports.js +31 -0
  18. package/dist/analysis/deps/parse-imports.js.map +1 -0
  19. package/dist/analysis/diff/deep-diff.d.ts +33 -0
  20. package/dist/analysis/diff/deep-diff.d.ts.map +1 -0
  21. package/dist/analysis/diff/deep-diff.js +114 -0
  22. package/dist/analysis/diff/deep-diff.js.map +1 -0
  23. package/dist/analysis/diff/semantic.d.ts +11 -0
  24. package/dist/analysis/diff/semantic.d.ts.map +1 -0
  25. package/dist/analysis/diff/semantic.js +97 -0
  26. package/dist/analysis/diff/semantic.js.map +1 -0
  27. package/dist/analysis/example-scan.d.ts +15 -0
  28. package/dist/analysis/example-scan.d.ts.map +1 -0
  29. package/dist/analysis/example-scan.js +116 -0
  30. package/dist/analysis/example-scan.js.map +1 -0
  31. package/dist/analysis/feature-extractor.js +203 -0
  32. package/dist/analysis/feature-extractor.js.map +1 -0
  33. package/dist/analysis/feature-scan.d.ts +15 -0
  34. package/dist/analysis/feature-scan.d.ts.map +1 -0
  35. package/dist/analysis/feature-scan.js +56 -0
  36. package/dist/analysis/feature-scan.js.map +1 -0
  37. package/dist/analysis/grouping.d.ts +79 -0
  38. package/dist/analysis/grouping.d.ts.map +1 -0
  39. package/dist/analysis/grouping.js +115 -0
  40. package/dist/analysis/grouping.js.map +1 -0
  41. package/dist/analysis/impact/classifier.d.ts +19 -0
  42. package/dist/analysis/impact/classifier.d.ts.map +1 -0
  43. package/dist/analysis/impact/classifier.js +135 -0
  44. package/dist/analysis/impact/classifier.js.map +1 -0
  45. package/dist/analysis/impact/index.js +2 -0
  46. package/dist/analysis/impact/rules.d.ts +35 -0
  47. package/dist/analysis/impact/rules.d.ts.map +1 -0
  48. package/dist/analysis/impact/rules.js +154 -0
  49. package/dist/analysis/impact/rules.js.map +1 -0
  50. package/dist/analysis/impact/types.d.ts +95 -0
  51. package/dist/analysis/impact/types.d.ts.map +1 -0
  52. package/dist/analysis/index.js +18 -0
  53. package/dist/analysis/snapshot/index.js +2 -0
  54. package/dist/analysis/snapshot/normalizer.d.ts +36 -0
  55. package/dist/analysis/snapshot/normalizer.d.ts.map +1 -0
  56. package/dist/analysis/snapshot/normalizer.js +67 -0
  57. package/dist/analysis/snapshot/normalizer.js.map +1 -0
  58. package/dist/analysis/snapshot/snapshot.d.ts +18 -0
  59. package/dist/analysis/snapshot/snapshot.d.ts.map +1 -0
  60. package/dist/analysis/snapshot/snapshot.js +163 -0
  61. package/dist/analysis/snapshot/snapshot.js.map +1 -0
  62. package/dist/analysis/snapshot/types.d.ts +74 -0
  63. package/dist/analysis/snapshot/types.d.ts.map +1 -0
  64. package/dist/analysis/spec-parser.d.ts +11 -0
  65. package/dist/analysis/spec-parser.d.ts.map +1 -0
  66. package/dist/analysis/spec-parser.js +89 -0
  67. package/dist/analysis/spec-parser.js.map +1 -0
  68. package/dist/analysis/spec-parsing-utils.d.ts +26 -0
  69. package/dist/analysis/spec-parsing-utils.d.ts.map +1 -0
  70. package/dist/analysis/spec-parsing-utils.js +98 -0
  71. package/dist/analysis/spec-parsing-utils.js.map +1 -0
  72. package/dist/analysis/spec-scan.d.ts +20 -0
  73. package/dist/analysis/spec-scan.d.ts.map +1 -0
  74. package/dist/analysis/spec-scan.js +141 -0
  75. package/dist/analysis/spec-scan.js.map +1 -0
  76. package/dist/analysis/utils/matchers.js +77 -0
  77. package/dist/analysis/utils/matchers.js.map +1 -0
  78. package/dist/analysis/utils/variables.js +45 -0
  79. package/dist/analysis/utils/variables.js.map +1 -0
  80. package/dist/analysis/validate/index.js +1 -0
  81. package/dist/analysis/validate/spec-structure.d.ts +29 -0
  82. package/dist/analysis/validate/spec-structure.d.ts.map +1 -0
  83. package/dist/analysis/validate/spec-structure.js +455 -0
  84. package/dist/analysis/validate/spec-structure.js.map +1 -0
  85. package/dist/formatter.d.ts +42 -0
  86. package/dist/formatter.d.ts.map +1 -0
  87. package/dist/formatter.js +163 -0
  88. package/dist/formatter.js.map +1 -0
  89. package/dist/formatters/index.js +2 -0
  90. package/dist/formatters/spec-markdown.d.ts +31 -0
  91. package/dist/formatters/spec-markdown.d.ts.map +1 -0
  92. package/dist/formatters/spec-markdown.js +263 -0
  93. package/dist/formatters/spec-markdown.js.map +1 -0
  94. package/dist/formatters/spec-to-docblock.d.ts +14 -0
  95. package/dist/formatters/spec-to-docblock.d.ts.map +1 -0
  96. package/dist/formatters/spec-to-docblock.js +48 -0
  97. package/dist/formatters/spec-to-docblock.js.map +1 -0
  98. package/dist/index.d.ts +42 -0
  99. package/dist/index.js +39 -0
  100. package/dist/templates/app-config.d.ts +7 -0
  101. package/dist/templates/app-config.d.ts.map +1 -0
  102. package/dist/templates/app-config.js +107 -0
  103. package/dist/templates/app-config.js.map +1 -0
  104. package/dist/templates/data-view.d.ts +7 -0
  105. package/dist/templates/data-view.d.ts.map +1 -0
  106. package/dist/templates/data-view.js +69 -0
  107. package/dist/templates/data-view.js.map +1 -0
  108. package/dist/templates/event.d.ts +11 -0
  109. package/dist/templates/event.d.ts.map +1 -0
  110. package/dist/templates/event.js +41 -0
  111. package/dist/templates/event.js.map +1 -0
  112. package/dist/templates/experiment.d.ts +7 -0
  113. package/dist/templates/experiment.d.ts.map +1 -0
  114. package/dist/templates/experiment.js +88 -0
  115. package/dist/templates/experiment.js.map +1 -0
  116. package/dist/templates/handler.d.ts +20 -0
  117. package/dist/templates/handler.d.ts.map +1 -0
  118. package/dist/templates/handler.js +96 -0
  119. package/dist/templates/handler.js.map +1 -0
  120. package/dist/templates/integration-utils.js +105 -0
  121. package/dist/templates/integration-utils.js.map +1 -0
  122. package/dist/templates/integration.d.ts +7 -0
  123. package/dist/templates/integration.d.ts.map +1 -0
  124. package/dist/templates/integration.js +62 -0
  125. package/dist/templates/integration.js.map +1 -0
  126. package/dist/templates/knowledge.d.ts +7 -0
  127. package/dist/templates/knowledge.d.ts.map +1 -0
  128. package/dist/templates/knowledge.js +69 -0
  129. package/dist/templates/knowledge.js.map +1 -0
  130. package/dist/templates/migration.d.ts +7 -0
  131. package/dist/templates/migration.d.ts.map +1 -0
  132. package/dist/templates/migration.js +61 -0
  133. package/dist/templates/migration.js.map +1 -0
  134. package/dist/templates/operation.d.ts +11 -0
  135. package/dist/templates/operation.d.ts.map +1 -0
  136. package/dist/templates/operation.js +101 -0
  137. package/dist/templates/operation.js.map +1 -0
  138. package/dist/templates/presentation.d.ts +11 -0
  139. package/dist/templates/presentation.d.ts.map +1 -0
  140. package/dist/templates/presentation.js +79 -0
  141. package/dist/templates/presentation.js.map +1 -0
  142. package/dist/templates/telemetry.d.ts +7 -0
  143. package/dist/templates/telemetry.d.ts.map +1 -0
  144. package/dist/templates/telemetry.js +90 -0
  145. package/dist/templates/telemetry.js.map +1 -0
  146. package/dist/templates/utils.d.ts +27 -0
  147. package/dist/templates/utils.d.ts.map +1 -0
  148. package/dist/templates/utils.js +39 -0
  149. package/dist/templates/utils.js.map +1 -0
  150. package/dist/templates/workflow-runner.d.ts +16 -0
  151. package/dist/templates/workflow-runner.d.ts.map +1 -0
  152. package/dist/templates/workflow-runner.js +49 -0
  153. package/dist/templates/workflow-runner.js.map +1 -0
  154. package/dist/templates/workflow.d.ts +11 -0
  155. package/dist/templates/workflow.d.ts.map +1 -0
  156. package/dist/templates/workflow.js +68 -0
  157. package/dist/templates/workflow.js.map +1 -0
  158. package/dist/types/analysis-types.d.ts +199 -0
  159. package/dist/types/analysis-types.d.ts.map +1 -0
  160. package/dist/types/generation-types.d.ts +87 -0
  161. package/dist/types/generation-types.d.ts.map +1 -0
  162. package/dist/types/generation-types.js +21 -0
  163. package/dist/types/generation-types.js.map +1 -0
  164. package/dist/types/llm-types.d.ts +138 -0
  165. package/dist/types/llm-types.d.ts.map +1 -0
  166. package/dist/types/rulesync-types.d.ts +24 -0
  167. package/dist/types/rulesync-types.d.ts.map +1 -0
  168. package/dist/types/spec-types.d.ts +343 -0
  169. package/dist/types/spec-types.d.ts.map +1 -0
  170. package/package.json +63 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Chaman Ventures, SASU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @contractspec/module.workspace
2
+
3
+ Website: https://contractspec.io/
4
+
5
+
6
+ Pure, deterministic domain logic and static analysis utilities for ContractSpec workspace operations.
7
+
8
+ ## Purpose
9
+
10
+ This module contains platform-agnostic logic used by ContractSpec tooling:
11
+
12
+ - **Types**: Shared type definitions for specs, templates, and analysis results
13
+ - **Analysis**: Static code analysis (spec scanning, dependency graphs, semantic diff)
14
+ - **Templates**: Code generation templates for specs and handlers
15
+ - **AI Prompts**: Prompt builders for AI-assisted spec creation and code generation
16
+
17
+ ## Design Principles
18
+
19
+ - **No side effects**: All functions are pure and deterministic
20
+ - **No CLI dependencies**: No `chalk`, `ora`, `commander`, or `inquirer`
21
+ - **No filesystem access**: Operations take code/data as input, return results
22
+ - **Reusable**: Can be used by CLI, web apps, VS Code extensions, etc.
23
+
24
+ ## Usage
25
+
26
+ ```typescript
27
+ import {
28
+ scanSpecSource,
29
+ computeSemanticDiff,
30
+ buildDependencyGraph,
31
+ validateSpecStructure,
32
+ generateOperationSpec,
33
+ } from '@contractspec/module.workspace';
34
+ ```
35
+
36
+ ## Exports
37
+
38
+ - `analysis/` - Static analysis utilities
39
+ - `templates/` - Code generation templates
40
+ - `ai/` - AI prompt builders
41
+ - `types/` - Shared type definitions
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
@@ -0,0 +1,24 @@
1
+ //#region src/ai/prompts/code-generation.d.ts
2
+ /**
3
+ * Build prompt for generating handler implementation
4
+ */
5
+ declare function buildHandlerPrompt(specCode: string): string;
6
+ /**
7
+ * Build prompt for generating React component from presentation spec
8
+ */
9
+ declare function buildComponentPrompt(specCode: string): string;
10
+ /**
11
+ * Build prompt for generating form component
12
+ */
13
+ declare function buildFormPrompt(specCode: string): string;
14
+ /**
15
+ * Build prompt for generating tests
16
+ */
17
+ declare function buildTestPrompt(specCode: string, implementationCode: string, testType: 'handler' | 'component'): string;
18
+ /**
19
+ * System prompt for code generation
20
+ */
21
+ declare function getCodeGenSystemPrompt(): string;
22
+ //#endregion
23
+ export { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt };
24
+ //# sourceMappingURL=code-generation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-generation.d.ts","names":[],"sources":["../../../src/ai/prompts/code-generation.ts"],"sourcesContent":[],"mappings":";;AAGA;AA0BA;AA0BgB,iBApDA,kBAAA,CAoDe,QAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AA2B/B;AA2CA;;iBAhGgB,oBAAA;;;;iBA0BA,eAAA;;;;iBA2BA,eAAA;;;;iBA2CA,sBAAA,CAAA"}
@@ -0,0 +1,134 @@
1
+ //#region src/ai/prompts/code-generation.ts
2
+ /**
3
+ * Build prompt for generating handler implementation
4
+ */
5
+ function buildHandlerPrompt(specCode) {
6
+ return `You are a senior TypeScript developer implementing a handler for a contract specification.
7
+
8
+ Here is the contract spec:
9
+
10
+ \`\`\`typescript
11
+ ${specCode}
12
+ \`\`\`
13
+
14
+ Generate a complete handler implementation that:
15
+
16
+ 1. **Matches the spec signature**: Input/output types from the spec
17
+ 2. **Handles errors**: Implement error cases defined in spec.io.errors
18
+ 3. **Emits events**: Use the events declared in spec.sideEffects.emits
19
+ 4. **Validates input**: Use zod validation from the schema
20
+ 5. **Follows best practices**: Clean, type-safe TypeScript
21
+ 6. **Includes comments**: Explain business logic
22
+
23
+ The handler should be production-ready with proper error handling, logging points, and clear structure.
24
+
25
+ Return only the TypeScript code for the handler function.`;
26
+ }
27
+ /**
28
+ * Build prompt for generating React component from presentation spec
29
+ */
30
+ function buildComponentPrompt(specCode) {
31
+ return `You are a senior React developer creating a component for a presentation specification.
32
+
33
+ Here is the presentation spec:
34
+
35
+ \`\`\`typescript
36
+ ${specCode}
37
+ \`\`\`
38
+
39
+ Generate a complete React component that:
40
+
41
+ 1. **Props interface**: Typed props from the spec
42
+ 2. **Accessibility**: Proper ARIA labels, roles, keyboard navigation
43
+ 3. **Mobile-first**: Optimized for small screens and touch
44
+ 4. **Clean UI**: Simple, intuitive interface
45
+ 5. **Type-safe**: Full TypeScript with no 'any' types
46
+ 6. **Best practices**: React hooks, proper state management
47
+
48
+ The component should follow Atomic Design principles and be reusable.
49
+
50
+ Return only the TypeScript/TSX code for the component.`;
51
+ }
52
+ /**
53
+ * Build prompt for generating form component
54
+ */
55
+ function buildFormPrompt(specCode) {
56
+ return `You are a senior React developer creating a form component from a form specification.
57
+
58
+ Here is the form spec:
59
+
60
+ \`\`\`typescript
61
+ ${specCode}
62
+ \`\`\`
63
+
64
+ Generate a complete form component using react-hook-form that:
65
+
66
+ 1. **Form validation**: Use zod schema for validation
67
+ 2. **Field types**: Proper inputs for each field type
68
+ 3. **Conditional logic**: Support visibleWhen, enabledWhen, requiredWhen predicates
69
+ 4. **Error handling**: Clear, user-friendly error messages
70
+ 5. **Accessibility**: Labels, hints, ARIA attributes
71
+ 6. **Mobile-optimized**: Touch-friendly, appropriate input types
72
+ 7. **Type-safe**: Full TypeScript
73
+
74
+ The form should provide excellent UX with real-time validation and helpful feedback.
75
+
76
+ Return only the TypeScript/TSX code for the form component.`;
77
+ }
78
+ /**
79
+ * Build prompt for generating tests
80
+ */
81
+ function buildTestPrompt(specCode, implementationCode, testType) {
82
+ return `You are a senior developer writing comprehensive tests.
83
+
84
+ Spec:
85
+ \`\`\`typescript
86
+ ${specCode}
87
+ \`\`\`
88
+
89
+ Implementation:
90
+ \`\`\`typescript
91
+ ${implementationCode}
92
+ \`\`\`
93
+
94
+ Generate complete test suite using Vitest that:
95
+ ${testType === "handler" ? `
96
+ - Test all acceptance scenarios from the spec
97
+ - Test error cases defined in spec.io.errors
98
+ - Verify events are emitted correctly
99
+ - Test input validation
100
+ - Test happy path and edge cases` : `
101
+ - Test rendering with various props
102
+ - Test user interactions
103
+ - Test accessibility (a11y)
104
+ - Test responsive behavior
105
+ - Test error states`}
106
+
107
+ Use clear test descriptions and follow AAA pattern (Arrange, Act, Assert).
108
+
109
+ Return only the TypeScript test code.`;
110
+ }
111
+ /**
112
+ * System prompt for code generation
113
+ */
114
+ function getCodeGenSystemPrompt() {
115
+ return `You are an expert TypeScript developer with deep knowledge of:
116
+ - Type-safe API design
117
+ - React and modern hooks
118
+ - Test-driven development
119
+ - Accessibility best practices
120
+ - Clean code principles
121
+
122
+ Generate production-ready code that is:
123
+ - Fully typed (no 'any' or type assertions unless absolutely necessary)
124
+ - Well-documented with TSDoc comments
125
+ - Following project conventions
126
+ - Defensive and error-safe
127
+ - Easy to maintain and extend
128
+
129
+ Always prioritize code quality, safety, and user experience.`;
130
+ }
131
+
132
+ //#endregion
133
+ export { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt };
134
+ //# sourceMappingURL=code-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-generation.js","names":[],"sources":["../../../src/ai/prompts/code-generation.ts"],"sourcesContent":["/**\n * Build prompt for generating handler implementation\n */\nexport function buildHandlerPrompt(specCode: string): string {\n return `You are a senior TypeScript developer implementing a handler for a contract specification.\n\nHere is the contract spec:\n\n\\`\\`\\`typescript\n${specCode}\n\\`\\`\\`\n\nGenerate a complete handler implementation that:\n\n1. **Matches the spec signature**: Input/output types from the spec\n2. **Handles errors**: Implement error cases defined in spec.io.errors\n3. **Emits events**: Use the events declared in spec.sideEffects.emits\n4. **Validates input**: Use zod validation from the schema\n5. **Follows best practices**: Clean, type-safe TypeScript\n6. **Includes comments**: Explain business logic\n\nThe handler should be production-ready with proper error handling, logging points, and clear structure.\n\nReturn only the TypeScript code for the handler function.`;\n}\n\n/**\n * Build prompt for generating React component from presentation spec\n */\nexport function buildComponentPrompt(specCode: string): string {\n return `You are a senior React developer creating a component for a presentation specification.\n\nHere is the presentation spec:\n\n\\`\\`\\`typescript\n${specCode}\n\\`\\`\\`\n\nGenerate a complete React component that:\n\n1. **Props interface**: Typed props from the spec\n2. **Accessibility**: Proper ARIA labels, roles, keyboard navigation\n3. **Mobile-first**: Optimized for small screens and touch\n4. **Clean UI**: Simple, intuitive interface\n5. **Type-safe**: Full TypeScript with no 'any' types\n6. **Best practices**: React hooks, proper state management\n\nThe component should follow Atomic Design principles and be reusable.\n\nReturn only the TypeScript/TSX code for the component.`;\n}\n\n/**\n * Build prompt for generating form component\n */\nexport function buildFormPrompt(specCode: string): string {\n return `You are a senior React developer creating a form component from a form specification.\n\nHere is the form spec:\n\n\\`\\`\\`typescript\n${specCode}\n\\`\\`\\`\n\nGenerate a complete form component using react-hook-form that:\n\n1. **Form validation**: Use zod schema for validation\n2. **Field types**: Proper inputs for each field type\n3. **Conditional logic**: Support visibleWhen, enabledWhen, requiredWhen predicates\n4. **Error handling**: Clear, user-friendly error messages\n5. **Accessibility**: Labels, hints, ARIA attributes\n6. **Mobile-optimized**: Touch-friendly, appropriate input types\n7. **Type-safe**: Full TypeScript\n\nThe form should provide excellent UX with real-time validation and helpful feedback.\n\nReturn only the TypeScript/TSX code for the form component.`;\n}\n\n/**\n * Build prompt for generating tests\n */\nexport function buildTestPrompt(\n specCode: string,\n implementationCode: string,\n testType: 'handler' | 'component'\n): string {\n const testFocus =\n testType === 'handler'\n ? `\n - Test all acceptance scenarios from the spec\n - Test error cases defined in spec.io.errors\n - Verify events are emitted correctly\n - Test input validation\n - Test happy path and edge cases`\n : `\n - Test rendering with various props\n - Test user interactions\n - Test accessibility (a11y)\n - Test responsive behavior\n - Test error states`;\n\n return `You are a senior developer writing comprehensive tests.\n\nSpec:\n\\`\\`\\`typescript\n${specCode}\n\\`\\`\\`\n\nImplementation:\n\\`\\`\\`typescript\n${implementationCode}\n\\`\\`\\`\n\nGenerate complete test suite using Vitest that:\n${testFocus}\n\nUse clear test descriptions and follow AAA pattern (Arrange, Act, Assert).\n\nReturn only the TypeScript test code.`;\n}\n\n/**\n * System prompt for code generation\n */\nexport function getCodeGenSystemPrompt(): string {\n return `You are an expert TypeScript developer with deep knowledge of:\n- Type-safe API design\n- React and modern hooks\n- Test-driven development\n- Accessibility best practices\n- Clean code principles\n\nGenerate production-ready code that is:\n- Fully typed (no 'any' or type assertions unless absolutely necessary)\n- Well-documented with TSDoc comments\n- Following project conventions\n- Defensive and error-safe\n- Easy to maintain and extend\n\nAlways prioritize code quality, safety, and user experience.`;\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAmB,UAA0B;AAC3D,QAAO;;;;;EAKP,SAAS;;;;;;;;;;;;;;;;;;;AAoBX,SAAgB,qBAAqB,UAA0B;AAC7D,QAAO;;;;;EAKP,SAAS;;;;;;;;;;;;;;;;;;;AAoBX,SAAgB,gBAAgB,UAA0B;AACxD,QAAO;;;;;EAKP,SAAS;;;;;;;;;;;;;;;;;;;;AAqBX,SAAgB,gBACd,UACA,oBACA,UACQ;AAgBR,QAAO;;;;EAIP,SAAS;;;;;EAKT,mBAAmB;;;;EAvBjB,aAAa,YACT;;;;;sCAMA;;;;;uBAoBI;;;;;;;;;AAUZ,SAAgB,yBAAiC;AAC/C,QAAO"}
@@ -0,0 +1,28 @@
1
+ import { PresentationKind } from "../../types/spec-types.js";
2
+ import { OpKind } from "@contractspec/lib.contracts";
3
+
4
+ //#region src/ai/prompts/spec-creation.d.ts
5
+
6
+ /**
7
+ * Build prompt for creating operation spec from description
8
+ */
9
+ declare function buildOperationSpecPrompt(description: string, kind: OpKind): string;
10
+ /**
11
+ * Build prompt for creating event spec from description
12
+ */
13
+ declare function buildEventSpecPrompt(description: string): string;
14
+ /**
15
+ * Build prompt for creating presentation spec from description
16
+ */
17
+ declare function buildPresentationSpecPrompt(description: string, kind: PresentationKind): string;
18
+ /**
19
+ * Build system prompt for all spec generation
20
+ */
21
+ declare function getSystemPrompt(): string;
22
+ /**
23
+ * Create example-based prompt for better results
24
+ */
25
+ declare function addExampleContext(basePrompt: string, examples: string[]): string;
26
+ //#endregion
27
+ export { addExampleContext, buildEventSpecPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, getSystemPrompt };
28
+ //# sourceMappingURL=spec-creation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-creation.d.ts","names":[],"sources":["../../../src/ai/prompts/spec-creation.ts"],"sourcesContent":[],"mappings":";;;;;;;AAMA;AA4BgB,iBA5BA,wBAAA,CA4BoB,WAAA,EAAA,MAAA,EAAA,IAAA,EA1B5B,MA0B4B,CAAA,EAAA,MAAA;AAqBpC;AAoCA;AAiBA;iBA1EgB,oBAAA;;;;iBAqBA,2BAAA,4BAER;;;;iBAkCQ,eAAA,CAAA;;;;iBAiBA,iBAAA"}
@@ -0,0 +1,102 @@
1
+ //#region src/ai/prompts/spec-creation.ts
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.
7
+
8
+ The operation is a ${kind} (${kind === "command" ? "changes state, has side effects" : "read-only, idempotent"}).
9
+
10
+ User description: ${description}
11
+
12
+ Create a complete contract specification following these guidelines:
13
+
14
+ 1. **Name**: Use dot notation like "domain.operationName" (e.g., "user.signup", "payment.charge")
15
+ 2. **Version**: Start at 1
16
+ 3. **Description**: Clear, concise summary (1-2 sentences)
17
+ 4. **Goal**: Business purpose - why this operation exists
18
+ 5. **Context**: Background, constraints, scope (what it does and doesn't do)
19
+ 6. **Input/Output**: Describe the shape (we'll create schemas separately)
20
+ 7. **Auth**: Who can call this - anonymous, user, or admin
21
+ 8. **Feature Flags**: Any flags that gate this operation
22
+ 9. **Side Effects**: What events might be emitted, analytics to track
23
+
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.
31
+
32
+ User description: ${description}
33
+
34
+ Create a complete event specification following these guidelines:
35
+
36
+ 1. **Name**: Use dot notation like "domain.event_name" (e.g., "user.signup_completed", "payment.charged")
37
+ 2. **Version**: Start at 1
38
+ 3. **Description**: Clear description of when this event is emitted
39
+ 4. **Payload**: Describe what data the event carries
40
+ 5. **PII Fields**: List any personally identifiable information fields (e.g., ["email", "name"])
41
+
42
+ Events represent things that have already happened and should use past tense.
43
+
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.
51
+
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]}.
57
+
58
+ User description: ${description}
59
+
60
+ Create a complete presentation specification following these guidelines:
61
+
62
+ 1. **Name**: Use dot notation like "domain.presentation_name" (e.g., "user.profile_card", "docs.api_guide")
63
+ 2. **Version**: Start at 1
64
+ 3. **Description**: What this presentation shows/provides
65
+ 4. **Kind-specific details**:
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"}
67
+
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.
75
+
76
+ You create clear, well-documented specifications that serve as the single source of truth for operations, events, and presentations.
77
+
78
+ Your specs are:
79
+ - Precise and unambiguous
80
+ - Following TypeScript conventions
81
+ - Business-oriented (capturing the "why" not just "what")
82
+ - Designed for both humans and AI agents to understand
83
+
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}
92
+
93
+ Here are some good examples for reference:
94
+
95
+ ${examples.join("\n\n")}
96
+
97
+ Follow this structure and quality level.`;
98
+ }
99
+
100
+ //#endregion
101
+ export { addExampleContext, buildEventSpecPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, getSystemPrompt };
102
+ //# sourceMappingURL=spec-creation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-creation.js","names":[],"sources":["../../../src/ai/prompts/spec-creation.ts"],"sourcesContent":["import type { OpKind } from '@contractspec/lib.contracts';\nimport type { PresentationKind } from '../../types/spec-types';\n\n/**\n * Build prompt for creating operation spec from description\n */\nexport function buildOperationSpecPrompt(\n description: string,\n kind: OpKind\n): string {\n return `You are a senior software architect creating a contract specification for an operation.\n\nThe operation is a ${kind} (${kind === 'command' ? 'changes state, has side effects' : 'read-only, idempotent'}).\n\nUser description: ${description}\n\nCreate a complete contract specification following these guidelines:\n\n1. **Name**: Use dot notation like \"domain.operationName\" (e.g., \"user.signup\", \"payment.charge\")\n2. **Version**: Start at 1\n3. **Description**: Clear, concise summary (1-2 sentences)\n4. **Goal**: Business purpose - why this operation exists\n5. **Context**: Background, constraints, scope (what it does and doesn't do)\n6. **Input/Output**: Describe the shape (we'll create schemas separately)\n7. **Auth**: Who can call this - anonymous, user, or admin\n8. **Feature Flags**: Any flags that gate this operation\n9. **Side Effects**: What events might be emitted, analytics to track\n\nRespond with a structured spec.`;\n}\n\n/**\n * Build prompt for creating event spec from description\n */\nexport function buildEventSpecPrompt(description: string): string {\n return `You are a senior software architect creating an event specification.\n\nUser description: ${description}\n\nCreate a complete event specification following these guidelines:\n\n1. **Name**: Use dot notation like \"domain.event_name\" (e.g., \"user.signup_completed\", \"payment.charged\")\n2. **Version**: Start at 1\n3. **Description**: Clear description of when this event is emitted\n4. **Payload**: Describe what data the event carries\n5. **PII Fields**: List any personally identifiable information fields (e.g., [\"email\", \"name\"])\n\nEvents represent things that have already happened and should use past tense.\n\nRespond with a structured spec.`;\n}\n\n/**\n * Build prompt for creating presentation spec from description\n */\nexport function buildPresentationSpecPrompt(\n description: string,\n kind: PresentationKind\n): string {\n const kindDescriptions = {\n web_component: 'a React component with props schema',\n markdown: 'markdown/MDX documentation or guide',\n data: 'structured data export (JSON/XML)',\n };\n\n return `You are a senior software architect creating a presentation specification.\n\nThis is a ${kind} presentation - ${kindDescriptions[kind]}.\n\nUser description: ${description}\n\nCreate a complete presentation specification following these guidelines:\n\n1. **Name**: Use dot notation like \"domain.presentation_name\" (e.g., \"user.profile_card\", \"docs.api_guide\")\n2. **Version**: Start at 1\n3. **Description**: What this presentation shows/provides\n4. **Kind-specific details**:\n ${\n kind === 'web_component'\n ? '- Component key (symbolic, resolved by host app)\\n - Props structure\\n - Analytics events to track'\n : kind === 'markdown'\n ? '- Content or resource URI\\n - Target audience'\n : '- MIME type (e.g., application/json)\\n - Data structure description'\n }\n\nRespond with a structured spec.`;\n}\n\n/**\n * Build system prompt for all spec generation\n */\nexport function getSystemPrompt(): string {\n return `You are an expert software architect specializing in API design and contract-driven development.\n\nYou create clear, well-documented specifications that serve as the single source of truth for operations, events, and presentations.\n\nYour specs are:\n- Precise and unambiguous\n- Following TypeScript conventions\n- Business-oriented (capturing the \"why\" not just \"what\")\n- Designed for both humans and AI agents to understand\n\nAlways use proper dot notation for names and ensure all metadata is meaningful and accurate.`;\n}\n\n/**\n * Create example-based prompt for better results\n */\nexport function addExampleContext(\n basePrompt: string,\n examples: string[]\n): string {\n if (examples.length === 0) return basePrompt;\n\n return `${basePrompt}\n\nHere are some good examples for reference:\n\n${examples.join('\\n\\n')}\n\nFollow this structure and quality level.`;\n}\n"],"mappings":";;;;AAMA,SAAgB,yBACd,aACA,MACQ;AACR,QAAO;;qBAEY,KAAK,IAAI,SAAS,YAAY,oCAAoC,wBAAwB;;oBAE3F,YAAY;;;;;;;;;;;;;;;;;;;AAoBhC,SAAgB,qBAAqB,aAA6B;AAChE,QAAO;;oBAEW,YAAY;;;;;;;;;;;;;;;;;AAkBhC,SAAgB,4BACd,aACA,MACQ;AAOR,QAAO;;YAEG,KAAK,kBARU;EACvB,eAAe;EACf,UAAU;EACV,MAAM;EACP,CAIiD,MAAM;;oBAEtC,YAAY;;;;;;;;KAS3B,SAAS,kBACL,2GACA,SAAS,aACP,oDACA,wEACP;;;;;;;AAQJ,SAAgB,kBAA0B;AACxC,QAAO;;;;;;;;;;;;;;;AAgBT,SAAgB,kBACd,YACA,UACQ;AACR,KAAI,SAAS,WAAW,EAAG,QAAO;AAElC,QAAO,GAAG,WAAW;;;;EAIrB,SAAS,KAAK,OAAO,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { ContractGraph, ContractNode } from "../../types/analysis-types.js";
2
+
3
+ //#region src/analysis/deps/graph.d.ts
4
+
5
+ /**
6
+ * Build reverse edges (dependents) for all nodes in the graph.
7
+ */
8
+ declare function buildReverseEdges(graph: ContractGraph): void;
9
+ /**
10
+ * Detect circular dependencies in the graph.
11
+ */
12
+ declare function detectCycles(graph: ContractGraph): string[][];
13
+ /**
14
+ * Find missing dependencies (referenced but not defined).
15
+ */
16
+ declare function findMissingDependencies(graph: ContractGraph): {
17
+ contract: string;
18
+ missing: string[];
19
+ }[];
20
+ /**
21
+ * Generate DOT format output for visualization.
22
+ */
23
+ declare function toDot(graph: ContractGraph): string;
24
+ /**
25
+ * Create an empty contract graph.
26
+ */
27
+ declare function createContractGraph(): ContractGraph;
28
+ /**
29
+ * Add a node to the contract graph.
30
+ */
31
+ declare function addContractNode(graph: ContractGraph, key: string, file: string, dependencies: string[]): void;
32
+ //#endregion
33
+ export { addContractNode, buildReverseEdges, createContractGraph, detectCycles, findMissingDependencies, toDot };
34
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","names":[],"sources":["../../../src/analysis/deps/graph.ts"],"sourcesContent":[],"mappings":";;;;AAwFA;AAsBA;AAOA;iBAzGgB,iBAAA,QAAyB;;;;iBAsBzB,YAAA,QAAoB;;;;iBAoCpB,uBAAA,QACP;;;;;;;iBAiBO,KAAA,QAAa;;;;iBAsBb,mBAAA,CAAA,GAAuB;;;;iBAOvB,eAAA,QACP"}
@@ -0,0 +1,85 @@
1
+ //#region src/analysis/deps/graph.ts
2
+ /**
3
+ * Build reverse edges (dependents) for all nodes in the graph.
4
+ */
5
+ function buildReverseEdges(graph) {
6
+ for (const node of graph.values()) node.dependents = [];
7
+ for (const [key, node] of graph) for (const dep of node.dependencies) {
8
+ const depNode = graph.get(dep);
9
+ if (depNode) depNode.dependents.push(key);
10
+ }
11
+ for (const node of graph.values()) node.dependents.sort((a, b) => a.localeCompare(b));
12
+ }
13
+ /**
14
+ * Detect circular dependencies in the graph.
15
+ */
16
+ function detectCycles(graph) {
17
+ const visited = /* @__PURE__ */ new Set();
18
+ const stack = /* @__PURE__ */ new Set();
19
+ const cycles = [];
20
+ function dfs(key, path) {
21
+ if (stack.has(key)) {
22
+ const start = path.indexOf(key);
23
+ if (start >= 0) cycles.push([...path.slice(start), key]);
24
+ return;
25
+ }
26
+ if (visited.has(key)) return;
27
+ visited.add(key);
28
+ stack.add(key);
29
+ const node = graph.get(key);
30
+ if (node) for (const dep of node.dependencies) dfs(dep, [...path, key]);
31
+ stack.delete(key);
32
+ }
33
+ for (const key of graph.keys()) if (!visited.has(key)) dfs(key, []);
34
+ return cycles;
35
+ }
36
+ /**
37
+ * Find missing dependencies (referenced but not defined).
38
+ */
39
+ function findMissingDependencies(graph) {
40
+ const missing = [];
41
+ for (const [key, node] of graph) {
42
+ const absent = node.dependencies.filter((dep) => !graph.has(dep));
43
+ if (absent.length > 0) missing.push({
44
+ contract: key,
45
+ missing: absent
46
+ });
47
+ }
48
+ return missing;
49
+ }
50
+ /**
51
+ * Generate DOT format output for visualization.
52
+ */
53
+ function toDot(graph) {
54
+ const lines = [];
55
+ lines.push("digraph ContractDependencies {");
56
+ lines.push(" rankdir=LR;");
57
+ lines.push(" node [shape=box];");
58
+ for (const [key, node] of graph) {
59
+ for (const dep of node.dependencies) lines.push(` "${key}" -> "${dep}";`);
60
+ if (node.dependencies.length === 0) lines.push(` "${key}";`);
61
+ }
62
+ lines.push("}");
63
+ return lines.join("\n");
64
+ }
65
+ /**
66
+ * Create an empty contract graph.
67
+ */
68
+ function createContractGraph() {
69
+ return /* @__PURE__ */ new Map();
70
+ }
71
+ /**
72
+ * Add a node to the contract graph.
73
+ */
74
+ function addContractNode(graph, key, file, dependencies) {
75
+ graph.set(key, {
76
+ key,
77
+ file,
78
+ dependencies,
79
+ dependents: []
80
+ });
81
+ }
82
+
83
+ //#endregion
84
+ export { addContractNode, buildReverseEdges, createContractGraph, detectCycles, findMissingDependencies, toDot };
85
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","names":[],"sources":["../../../src/analysis/deps/graph.ts"],"sourcesContent":["/**\n * Contract dependency graph utilities.\n * Extracted from cli-contractspec/src/commands/deps/graph.ts\n */\n\nimport type { ContractNode, ContractGraph } from '../../types/analysis-types';\n\nexport type { ContractNode, ContractGraph };\n\n/**\n * Build reverse edges (dependents) for all nodes in the graph.\n */\nexport function buildReverseEdges(graph: ContractGraph): void {\n for (const node of graph.values()) {\n node.dependents = [];\n }\n\n for (const [key, node] of graph) {\n for (const dep of node.dependencies) {\n const depNode = graph.get(dep);\n if (depNode) {\n depNode.dependents.push(key);\n }\n }\n }\n\n for (const node of graph.values()) {\n node.dependents.sort((a, b) => a.localeCompare(b));\n }\n}\n\n/**\n * Detect circular dependencies in the graph.\n */\nexport function detectCycles(graph: ContractGraph): string[][] {\n const visited = new Set<string>();\n const stack = new Set<string>();\n const cycles: string[][] = [];\n\n function dfs(key: string, path: string[]) {\n if (stack.has(key)) {\n const start = path.indexOf(key);\n if (start >= 0) cycles.push([...path.slice(start), key]);\n return;\n }\n if (visited.has(key)) return;\n\n visited.add(key);\n stack.add(key);\n\n const node = graph.get(key);\n if (node) {\n for (const dep of node.dependencies) {\n dfs(dep, [...path, key]);\n }\n }\n\n stack.delete(key);\n }\n\n for (const key of graph.keys()) {\n if (!visited.has(key)) dfs(key, []);\n }\n\n return cycles;\n}\n\n/**\n * Find missing dependencies (referenced but not defined).\n */\nexport function findMissingDependencies(\n graph: ContractGraph\n): { contract: string; missing: string[] }[] {\n const missing: { contract: string; missing: string[] }[] = [];\n\n for (const [key, node] of graph) {\n const absent = node.dependencies.filter((dep) => !graph.has(dep));\n if (absent.length > 0) {\n missing.push({ contract: key, missing: absent });\n }\n }\n\n return missing;\n}\n\n/**\n * Generate DOT format output for visualization.\n */\nexport function toDot(graph: ContractGraph): string {\n const lines: string[] = [];\n lines.push('digraph ContractDependencies {');\n lines.push(' rankdir=LR;');\n lines.push(' node [shape=box];');\n\n for (const [key, node] of graph) {\n for (const dep of node.dependencies) {\n lines.push(` \"${key}\" -> \"${dep}\";`);\n }\n if (node.dependencies.length === 0) {\n lines.push(` \"${key}\";`);\n }\n }\n\n lines.push('}');\n return lines.join('\\n');\n}\n\n/**\n * Create an empty contract graph.\n */\nexport function createContractGraph(): ContractGraph {\n return new Map();\n}\n\n/**\n * Add a node to the contract graph.\n */\nexport function addContractNode(\n graph: ContractGraph,\n key: string,\n file: string,\n dependencies: string[]\n): void {\n graph.set(key, {\n key,\n file,\n dependencies,\n dependents: [],\n });\n}\n"],"mappings":";;;;AAYA,SAAgB,kBAAkB,OAA4B;AAC5D,MAAK,MAAM,QAAQ,MAAM,QAAQ,CAC/B,MAAK,aAAa,EAAE;AAGtB,MAAK,MAAM,CAAC,KAAK,SAAS,MACxB,MAAK,MAAM,OAAO,KAAK,cAAc;EACnC,MAAM,UAAU,MAAM,IAAI,IAAI;AAC9B,MAAI,QACF,SAAQ,WAAW,KAAK,IAAI;;AAKlC,MAAK,MAAM,QAAQ,MAAM,QAAQ,CAC/B,MAAK,WAAW,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC;;;;;AAOtD,SAAgB,aAAa,OAAkC;CAC7D,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,wBAAQ,IAAI,KAAa;CAC/B,MAAM,SAAqB,EAAE;CAE7B,SAAS,IAAI,KAAa,MAAgB;AACxC,MAAI,MAAM,IAAI,IAAI,EAAE;GAClB,MAAM,QAAQ,KAAK,QAAQ,IAAI;AAC/B,OAAI,SAAS,EAAG,QAAO,KAAK,CAAC,GAAG,KAAK,MAAM,MAAM,EAAE,IAAI,CAAC;AACxD;;AAEF,MAAI,QAAQ,IAAI,IAAI,CAAE;AAEtB,UAAQ,IAAI,IAAI;AAChB,QAAM,IAAI,IAAI;EAEd,MAAM,OAAO,MAAM,IAAI,IAAI;AAC3B,MAAI,KACF,MAAK,MAAM,OAAO,KAAK,aACrB,KAAI,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAI5B,QAAM,OAAO,IAAI;;AAGnB,MAAK,MAAM,OAAO,MAAM,MAAM,CAC5B,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAE,KAAI,KAAK,EAAE,CAAC;AAGrC,QAAO;;;;;AAMT,SAAgB,wBACd,OAC2C;CAC3C,MAAM,UAAqD,EAAE;AAE7D,MAAK,MAAM,CAAC,KAAK,SAAS,OAAO;EAC/B,MAAM,SAAS,KAAK,aAAa,QAAQ,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC;AACjE,MAAI,OAAO,SAAS,EAClB,SAAQ,KAAK;GAAE,UAAU;GAAK,SAAS;GAAQ,CAAC;;AAIpD,QAAO;;;;;AAMT,SAAgB,MAAM,OAA8B;CAClD,MAAM,QAAkB,EAAE;AAC1B,OAAM,KAAK,iCAAiC;AAC5C,OAAM,KAAK,gBAAgB;AAC3B,OAAM,KAAK,sBAAsB;AAEjC,MAAK,MAAM,CAAC,KAAK,SAAS,OAAO;AAC/B,OAAK,MAAM,OAAO,KAAK,aACrB,OAAM,KAAK,MAAM,IAAI,QAAQ,IAAI,IAAI;AAEvC,MAAI,KAAK,aAAa,WAAW,EAC/B,OAAM,KAAK,MAAM,IAAI,IAAI;;AAI7B,OAAM,KAAK,IAAI;AACf,QAAO,MAAM,KAAK,KAAK;;;;;AAMzB,SAAgB,sBAAqC;AACnD,wBAAO,IAAI,KAAK;;;;;AAMlB,SAAgB,gBACd,OACA,KACA,MACA,cACM;AACN,OAAM,IAAI,KAAK;EACb;EACA;EACA;EACA,YAAY,EAAE;EACf,CAAC"}
@@ -0,0 +1,17 @@
1
+ //#region src/analysis/deps/parse-imports.d.ts
2
+ /**
3
+ * Import parsing utilities for dependency analysis.
4
+ * Extracted from cli-contractspec/src/commands/deps/parse-imports.ts
5
+ */
6
+ /**
7
+ * Parse spec imports from source code.
8
+ * Returns the names of imported specs based on file naming conventions.
9
+ *
10
+ * @param sourceCode - The source code to parse
11
+ * @param fromFilePath - The path of the file being parsed (for relative resolution)
12
+ * @returns Array of imported spec names
13
+ */
14
+ declare function parseImportedSpecNames(sourceCode: string, _fromFilePath: string): string[];
15
+ //#endregion
16
+ export { parseImportedSpecNames };
17
+ //# sourceMappingURL=parse-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-imports.d.ts","names":[],"sources":["../../../src/analysis/deps/parse-imports.ts"],"sourcesContent":[],"mappings":";;AAaA;;;;;;;;;;;iBAAgB,sBAAA"}
@@ -0,0 +1,31 @@
1
+ //#region src/analysis/deps/parse-imports.ts
2
+ /**
3
+ * Import parsing utilities for dependency analysis.
4
+ * Extracted from cli-contractspec/src/commands/deps/parse-imports.ts
5
+ */
6
+ /**
7
+ * Parse spec imports from source code.
8
+ * Returns the names of imported specs based on file naming conventions.
9
+ *
10
+ * @param sourceCode - The source code to parse
11
+ * @param fromFilePath - The path of the file being parsed (for relative resolution)
12
+ * @returns Array of imported spec names
13
+ */
14
+ function parseImportedSpecNames(sourceCode, _fromFilePath) {
15
+ const imports = [];
16
+ const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+\.(?:contracts|contract|operation|operations|event|presentation|workflow|data-view|migration|telemetry|experiment|app-config|integration|knowledge)(?:\.[jt]s)?)['"]/g;
17
+ let match;
18
+ while ((match = importRegex.exec(sourceCode)) !== null) {
19
+ const importPath = match[1];
20
+ if (!importPath) continue;
21
+ if (!importPath.startsWith(".") && !importPath.startsWith("/")) continue;
22
+ const pathParts = importPath.split("/");
23
+ const name = (pathParts[pathParts.length - 1] ?? "").replace(/\.(ts|js)$/, "").replace(/\.(contracts|contract|operation|operations|event|presentation|workflow|data-view|migration|telemetry|experiment|app-config|integration|knowledge)$/, "");
24
+ if (name.length > 0) imports.push(name);
25
+ }
26
+ return Array.from(new Set(imports)).sort((a, b) => a.localeCompare(b));
27
+ }
28
+
29
+ //#endregion
30
+ export { parseImportedSpecNames };
31
+ //# sourceMappingURL=parse-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-imports.js","names":[],"sources":["../../../src/analysis/deps/parse-imports.ts"],"sourcesContent":["/**\n * Import parsing utilities for dependency analysis.\n * Extracted from cli-contractspec/src/commands/deps/parse-imports.ts\n */\n\n/**\n * Parse spec imports from source code.\n * Returns the names of imported specs based on file naming conventions.\n *\n * @param sourceCode - The source code to parse\n * @param fromFilePath - The path of the file being parsed (for relative resolution)\n * @returns Array of imported spec names\n */\nexport function parseImportedSpecNames(\n sourceCode: string,\n _fromFilePath: string\n): string[] {\n const imports: string[] = [];\n\n // Capture relative imports that reference spec-ish files.\n // Examples:\n // import x from './foo.contracts'\n // import { y } from '../bar.event.ts'\n const importRegex =\n /import\\s+.*?\\s+from\\s+['\"]([^'\"]+\\.(?:contracts|contract|operation|operations|event|presentation|workflow|data-view|migration|telemetry|experiment|app-config|integration|knowledge)(?:\\.[jt]s)?)['\"]/g;\n\n let match: RegExpExecArray | null;\n while ((match = importRegex.exec(sourceCode)) !== null) {\n const importPath = match[1];\n if (!importPath) continue;\n if (!importPath.startsWith('.') && !importPath.startsWith('/')) continue;\n\n // Extract base name from the import path\n const pathParts = importPath.split('/');\n const base = pathParts[pathParts.length - 1] ?? '';\n\n const name = base\n .replace(/\\.(ts|js)$/, '')\n .replace(\n /\\.(contracts|contract|operation|operations|event|presentation|workflow|data-view|migration|telemetry|experiment|app-config|integration|knowledge)$/,\n ''\n );\n\n if (name.length > 0) {\n imports.push(name);\n }\n }\n\n return Array.from(new Set(imports)).sort((a, b) => a.localeCompare(b));\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,uBACd,YACA,eACU;CACV,MAAM,UAAoB,EAAE;CAM5B,MAAM,cACJ;CAEF,IAAI;AACJ,SAAQ,QAAQ,YAAY,KAAK,WAAW,MAAM,MAAM;EACtD,MAAM,aAAa,MAAM;AACzB,MAAI,CAAC,WAAY;AACjB,MAAI,CAAC,WAAW,WAAW,IAAI,IAAI,CAAC,WAAW,WAAW,IAAI,CAAE;EAGhE,MAAM,YAAY,WAAW,MAAM,IAAI;EAGvC,MAAM,QAFO,UAAU,UAAU,SAAS,MAAM,IAG7C,QAAQ,cAAc,GAAG,CACzB,QACC,sJACA,GACD;AAEH,MAAI,KAAK,SAAS,EAChB,SAAQ,KAAK,KAAK;;AAItB,QAAO,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { SemanticDiffItem } from "../../types/analysis-types.js";
2
+ import { FieldSnapshot, IoSnapshot } from "../snapshot/types.js";
3
+
4
+ //#region src/analysis/diff/deep-diff.d.ts
5
+
6
+ /**
7
+ * Deep diff options.
8
+ */
9
+ interface DeepDiffOptions {
10
+ /** Only report breaking changes */
11
+ breakingOnly?: boolean;
12
+ /** Path prefix for nested diffs */
13
+ pathPrefix?: string;
14
+ }
15
+ /**
16
+ * Compute deep differences between two IO schemas.
17
+ */
18
+ declare function computeIoDiff(base: IoSnapshot, head: IoSnapshot, options?: DeepDiffOptions): SemanticDiffItem[];
19
+ /**
20
+ * Compute differences between two field maps.
21
+ */
22
+ declare function computeFieldsDiff(baseFields: Record<string, FieldSnapshot>, headFields: Record<string, FieldSnapshot>, pathPrefix: string, options?: DeepDiffOptions): SemanticDiffItem[];
23
+ /**
24
+ * Compute differences between two field definitions.
25
+ */
26
+ declare function computeFieldDiff(base: FieldSnapshot, head: FieldSnapshot, path: string, _options?: DeepDiffOptions): SemanticDiffItem[];
27
+ /**
28
+ * Classify a diff as breaking based on context.
29
+ */
30
+ declare function isBreakingChange(diff: SemanticDiffItem, context: 'input' | 'output'): boolean;
31
+ //#endregion
32
+ export { DeepDiffOptions, computeFieldDiff, computeFieldsDiff, computeIoDiff, isBreakingChange };
33
+ //# sourceMappingURL=deep-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-diff.d.ts","names":[],"sources":["../../../src/analysis/diff/deep-diff.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8CgB,UAjCC,eAAA,CAiCgB;EACJ;EAAf,YAAA,CAAA,EAAA,OAAA;EACe;EAAf,UAAA,CAAA,EAAA,MAAA;;;;AA+Dd;AACQ,iBAzFQ,aAAA,CAyFR,IAAA,EAxFA,UAwFA,EAAA,IAAA,EAvFA,UAuFA,EAAA,OAAA,CAAA,EAtFG,eAsFH,CAAA,EArFL,gBAqFK,EAAA;;;;AAIW,iBAtEH,iBAAA,CAsEG,UAAA,EArEL,MAqEK,CAAA,MAAA,EArEU,aAqEV,CAAA,EAAA,UAAA,EApEL,MAoEK,CAAA,MAAA,EApEU,aAoEV,CAAA,EAAA,UAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAlER,eAkEQ,CAAA,EAjEhB,gBAiEgB,EAAA;AAwGnB;;;iBA7GgB,gBAAA,OACR,qBACA,wCAEI,kBACT;;;;iBAwGa,gBAAA,OACR"}