@lssm/module.contractspec-workspace 1.41.1 → 1.42.2

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 (134) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/ai/code-generation.d.ts +28 -0
  4. package/dist/ai/code-generation.d.ts.map +1 -0
  5. package/dist/ai/code-generation.js +51 -13
  6. package/dist/ai/code-generation.js.map +1 -0
  7. package/dist/ai/spec-creation.d.ts +27 -0
  8. package/dist/ai/spec-creation.d.ts.map +1 -0
  9. package/dist/ai/spec-creation.js +51 -18
  10. package/dist/ai/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 -2
  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 -1
  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 -1
  26. package/dist/analysis/diff/semantic.js.map +1 -0
  27. package/dist/analysis/feature-scan.d.ts +15 -0
  28. package/dist/analysis/feature-scan.d.ts.map +1 -0
  29. package/dist/analysis/feature-scan.js +152 -1
  30. package/dist/analysis/feature-scan.js.map +1 -0
  31. package/dist/analysis/grouping.d.ts +79 -0
  32. package/dist/analysis/grouping.d.ts.map +1 -0
  33. package/dist/analysis/grouping.js +115 -0
  34. package/dist/analysis/grouping.js.map +1 -0
  35. package/dist/analysis/impact/classifier.d.ts +19 -0
  36. package/dist/analysis/impact/classifier.d.ts.map +1 -0
  37. package/dist/analysis/impact/classifier.js +135 -0
  38. package/dist/analysis/impact/classifier.js.map +1 -0
  39. package/dist/analysis/impact/index.js +2 -0
  40. package/dist/analysis/impact/rules.d.ts +35 -0
  41. package/dist/analysis/impact/rules.d.ts.map +1 -0
  42. package/dist/analysis/impact/rules.js +154 -0
  43. package/dist/analysis/impact/rules.js.map +1 -0
  44. package/dist/analysis/impact/types.d.ts +95 -0
  45. package/dist/analysis/impact/types.d.ts.map +1 -0
  46. package/dist/analysis/index.js +14 -0
  47. package/dist/analysis/snapshot/index.js +2 -0
  48. package/dist/analysis/snapshot/normalizer.d.ts +36 -0
  49. package/dist/analysis/snapshot/normalizer.d.ts.map +1 -0
  50. package/dist/analysis/snapshot/normalizer.js +66 -0
  51. package/dist/analysis/snapshot/normalizer.js.map +1 -0
  52. package/dist/analysis/snapshot/snapshot.d.ts +18 -0
  53. package/dist/analysis/snapshot/snapshot.d.ts.map +1 -0
  54. package/dist/analysis/snapshot/snapshot.js +163 -0
  55. package/dist/analysis/snapshot/snapshot.js.map +1 -0
  56. package/dist/analysis/snapshot/types.d.ts +80 -0
  57. package/dist/analysis/snapshot/types.d.ts.map +1 -0
  58. package/dist/analysis/spec-scan.d.ts +34 -0
  59. package/dist/analysis/spec-scan.d.ts.map +1 -0
  60. package/dist/analysis/spec-scan.js +349 -1
  61. package/dist/analysis/spec-scan.js.map +1 -0
  62. package/dist/analysis/validate/spec-structure.d.ts +29 -0
  63. package/dist/analysis/validate/spec-structure.d.ts.map +1 -0
  64. package/dist/analysis/validate/spec-structure.js +139 -1
  65. package/dist/analysis/validate/spec-structure.js.map +1 -0
  66. package/dist/index.d.ts +34 -0
  67. package/dist/index.js +32 -1
  68. package/dist/templates/app-config.d.ts +7 -0
  69. package/dist/templates/app-config.d.ts.map +1 -0
  70. package/dist/templates/app-config.js +101 -28
  71. package/dist/templates/app-config.js.map +1 -0
  72. package/dist/templates/data-view.d.ts +7 -0
  73. package/dist/templates/data-view.d.ts.map +1 -0
  74. package/dist/templates/data-view.js +42 -27
  75. package/dist/templates/data-view.js.map +1 -0
  76. package/dist/templates/event.d.ts +11 -0
  77. package/dist/templates/event.d.ts.map +1 -0
  78. package/dist/templates/event.js +31 -14
  79. package/dist/templates/event.js.map +1 -0
  80. package/dist/templates/experiment.d.ts +7 -0
  81. package/dist/templates/experiment.d.ts.map +1 -0
  82. package/dist/templates/experiment.js +77 -51
  83. package/dist/templates/experiment.js.map +1 -0
  84. package/dist/templates/handler.d.ts +20 -0
  85. package/dist/templates/handler.d.ts.map +1 -0
  86. package/dist/templates/handler.js +50 -17
  87. package/dist/templates/handler.js.map +1 -0
  88. package/dist/templates/integration-utils.js +98 -26
  89. package/dist/templates/integration-utils.js.map +1 -0
  90. package/dist/templates/integration.d.ts +7 -0
  91. package/dist/templates/integration.d.ts.map +1 -0
  92. package/dist/templates/integration.js +47 -23
  93. package/dist/templates/integration.js.map +1 -0
  94. package/dist/templates/knowledge.d.ts +7 -0
  95. package/dist/templates/knowledge.d.ts.map +1 -0
  96. package/dist/templates/knowledge.js +60 -19
  97. package/dist/templates/knowledge.js.map +1 -0
  98. package/dist/templates/migration.d.ts +7 -0
  99. package/dist/templates/migration.d.ts.map +1 -0
  100. package/dist/templates/migration.js +50 -26
  101. package/dist/templates/migration.js.map +1 -0
  102. package/dist/templates/operation.d.ts +11 -0
  103. package/dist/templates/operation.d.ts.map +1 -0
  104. package/dist/templates/operation.js +41 -28
  105. package/dist/templates/operation.js.map +1 -0
  106. package/dist/templates/presentation.d.ts +11 -0
  107. package/dist/templates/presentation.d.ts.map +1 -0
  108. package/dist/templates/presentation.js +46 -20
  109. package/dist/templates/presentation.js.map +1 -0
  110. package/dist/templates/telemetry.d.ts +7 -0
  111. package/dist/templates/telemetry.d.ts.map +1 -0
  112. package/dist/templates/telemetry.js +74 -53
  113. package/dist/templates/telemetry.js.map +1 -0
  114. package/dist/templates/utils.d.ts +27 -0
  115. package/dist/templates/utils.d.ts.map +1 -0
  116. package/dist/templates/utils.js +39 -1
  117. package/dist/templates/utils.js.map +1 -0
  118. package/dist/templates/workflow-runner.d.ts +16 -0
  119. package/dist/templates/workflow-runner.d.ts.map +1 -0
  120. package/dist/templates/workflow-runner.js +13 -6
  121. package/dist/templates/workflow-runner.js.map +1 -0
  122. package/dist/templates/workflow.d.ts +11 -0
  123. package/dist/templates/workflow.d.ts.map +1 -0
  124. package/dist/templates/workflow.js +51 -24
  125. package/dist/templates/workflow.js.map +1 -0
  126. package/dist/types/analysis-types.d.ts +126 -0
  127. package/dist/types/analysis-types.d.ts.map +1 -0
  128. package/dist/types/generation-types.d.ts +84 -0
  129. package/dist/types/generation-types.d.ts.map +1 -0
  130. package/dist/types/generation-types.js +21 -1
  131. package/dist/types/generation-types.js.map +1 -0
  132. package/dist/types/spec-types.d.ts +345 -0
  133. package/dist/types/spec-types.d.ts.map +1 -0
  134. package/package.json +16 -9
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 CHANGED
@@ -1,5 +1,8 @@
1
1
  # @lssm/module.contractspec-workspace
2
2
 
3
+ Website: https://contractspec.lssm.tech/
4
+
5
+
3
6
  Pure, deterministic domain logic and static analysis utilities for ContractSpec workspace operations.
4
7
 
5
8
  ## Purpose
@@ -0,0 +1,28 @@
1
+ //#region src/ai/code-generation.d.ts
2
+ /**
3
+ * AI prompts for code generation.
4
+ * Extracted from cli-contractspec/src/ai/prompts/code-generation.ts
5
+ */
6
+ /**
7
+ * Build prompt for generating handler implementation.
8
+ */
9
+ declare function buildHandlerPrompt(specCode: string): string;
10
+ /**
11
+ * Build prompt for generating React component from presentation spec.
12
+ */
13
+ declare function buildComponentPrompt(specCode: string): string;
14
+ /**
15
+ * Build prompt for generating form component.
16
+ */
17
+ declare function buildFormPrompt(specCode: string): string;
18
+ /**
19
+ * Build prompt for generating tests.
20
+ */
21
+ declare function buildTestPrompt(specCode: string, implementationCode: string, testType: 'handler' | 'component'): string;
22
+ /**
23
+ * System prompt for code generation.
24
+ */
25
+ declare function getCodeGenSystemPrompt(): string;
26
+ //#endregion
27
+ export { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt };
28
+ //# sourceMappingURL=code-generation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-generation.d.ts","names":[],"sources":["../../src/ai/code-generation.ts"],"sourcesContent":[],"mappings":";;AAQA;AA0BA;AA0BA;AA2BA;AA2CA;;iBA1HgB,kBAAA;;;;iBA0BA,oBAAA;;;;iBA0BA,eAAA;;;;iBA2BA,eAAA;;;;iBA2CA,sBAAA,CAAA"}
@@ -1,9 +1,18 @@
1
- function e(e){return`You are a senior TypeScript developer implementing a handler for a contract specification.
1
+ //#region src/ai/code-generation.ts
2
+ /**
3
+ * AI prompts for code generation.
4
+ * Extracted from cli-contractspec/src/ai/prompts/code-generation.ts
5
+ */
6
+ /**
7
+ * Build prompt for generating handler implementation.
8
+ */
9
+ function buildHandlerPrompt(specCode) {
10
+ return `You are a senior TypeScript developer implementing a handler for a contract specification.
2
11
 
3
12
  Here is the contract spec:
4
13
 
5
14
  \`\`\`typescript
6
- ${e}
15
+ ${specCode}
7
16
  \`\`\`
8
17
 
9
18
  Generate a complete handler implementation that:
@@ -17,12 +26,18 @@ Generate a complete handler implementation that:
17
26
 
18
27
  The handler should be production-ready with proper error handling, logging points, and clear structure.
19
28
 
20
- Return only the TypeScript code for the handler function.`}function t(e){return`You are a senior React developer creating a component for a presentation specification.
29
+ Return only the TypeScript code for the handler function.`;
30
+ }
31
+ /**
32
+ * Build prompt for generating React component from presentation spec.
33
+ */
34
+ function buildComponentPrompt(specCode) {
35
+ return `You are a senior React developer creating a component for a presentation specification.
21
36
 
22
37
  Here is the presentation spec:
23
38
 
24
39
  \`\`\`typescript
25
- ${e}
40
+ ${specCode}
26
41
  \`\`\`
27
42
 
28
43
  Generate a complete React component that:
@@ -36,12 +51,18 @@ Generate a complete React component that:
36
51
 
37
52
  The component should follow Atomic Design principles and be reusable.
38
53
 
39
- Return only the TypeScript/TSX code for the component.`}function n(e){return`You are a senior React developer creating a form component from a form specification.
54
+ Return only the TypeScript/TSX code for the component.`;
55
+ }
56
+ /**
57
+ * Build prompt for generating form component.
58
+ */
59
+ function buildFormPrompt(specCode) {
60
+ return `You are a senior React developer creating a form component from a form specification.
40
61
 
41
62
  Here is the form spec:
42
63
 
43
64
  \`\`\`typescript
44
- ${e}
65
+ ${specCode}
45
66
  \`\`\`
46
67
 
47
68
  Generate a complete form component using react-hook-form that:
@@ -56,25 +77,31 @@ Generate a complete form component using react-hook-form that:
56
77
 
57
78
  The form should provide excellent UX with real-time validation and helpful feedback.
58
79
 
59
- Return only the TypeScript/TSX code for the form component.`}function r(e,t,n){return`You are a senior developer writing comprehensive tests.
80
+ Return only the TypeScript/TSX code for the form component.`;
81
+ }
82
+ /**
83
+ * Build prompt for generating tests.
84
+ */
85
+ function buildTestPrompt(specCode, implementationCode, testType) {
86
+ return `You are a senior developer writing comprehensive tests.
60
87
 
61
88
  Spec:
62
89
  \`\`\`typescript
63
- ${e}
90
+ ${specCode}
64
91
  \`\`\`
65
92
 
66
93
  Implementation:
67
94
  \`\`\`typescript
68
- ${t}
95
+ ${implementationCode}
69
96
  \`\`\`
70
97
 
71
98
  Generate complete test suite using Vitest that:
72
- ${n===`handler`?`
99
+ ${testType === "handler" ? `
73
100
  - Test all acceptance scenarios from the spec
74
101
  - Test error cases defined in spec.io.errors
75
102
  - Verify events are emitted correctly
76
103
  - Test input validation
77
- - Test happy path and edge cases`:`
104
+ - Test happy path and edge cases` : `
78
105
  - Test rendering with various props
79
106
  - Test user interactions
80
107
  - Test accessibility (a11y)
@@ -83,7 +110,13 @@ ${n===`handler`?`
83
110
 
84
111
  Use clear test descriptions and follow AAA pattern (Arrange, Act, Assert).
85
112
 
86
- Return only the TypeScript test code.`}function i(){return`You are an expert TypeScript developer with deep knowledge of:
113
+ Return only the TypeScript test code.`;
114
+ }
115
+ /**
116
+ * System prompt for code generation.
117
+ */
118
+ function getCodeGenSystemPrompt() {
119
+ return `You are an expert TypeScript developer with deep knowledge of:
87
120
  - Type-safe API design
88
121
  - React and modern hooks
89
122
  - Test-driven development
@@ -97,4 +130,9 @@ Generate production-ready code that is:
97
130
  - Defensive and error-safe
98
131
  - Easy to maintain and extend
99
132
 
100
- Always prioritize code quality, safety, and user experience.`}export{t as buildComponentPrompt,n as buildFormPrompt,e as buildHandlerPrompt,r as buildTestPrompt,i as getCodeGenSystemPrompt};
133
+ Always prioritize code quality, safety, and user experience.`;
134
+ }
135
+
136
+ //#endregion
137
+ export { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt };
138
+ //# sourceMappingURL=code-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-generation.js","names":[],"sources":["../../src/ai/code-generation.ts"],"sourcesContent":["/**\n * AI prompts for code generation.\n * Extracted from cli-contractspec/src/ai/prompts/code-generation.ts\n */\n\n/**\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":";;;;;;;;AAQA,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,27 @@
1
+ import { OpKind, PresentationKind } from "../types/spec-types.js";
2
+
3
+ //#region src/ai/spec-creation.d.ts
4
+
5
+ /**
6
+ * Build prompt for creating operation spec from description.
7
+ */
8
+ declare function buildOperationSpecPrompt(description: string, kind: OpKind): string;
9
+ /**
10
+ * Build prompt for creating event spec from description.
11
+ */
12
+ declare function buildEventSpecPrompt(description: string): string;
13
+ /**
14
+ * Build prompt for creating presentation spec from description.
15
+ */
16
+ declare function buildPresentationSpecPrompt(description: string, kind: PresentationKind): string;
17
+ /**
18
+ * Build system prompt for all spec generation.
19
+ */
20
+ declare function getSystemPrompt(): string;
21
+ /**
22
+ * Create example-based prompt for better results.
23
+ */
24
+ declare function addExampleContext(basePrompt: string, examples: string[]): string;
25
+ //#endregion
26
+ export { addExampleContext, buildEventSpecPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, getSystemPrompt };
27
+ //# sourceMappingURL=spec-creation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-creation.d.ts","names":[],"sources":["../../src/ai/spec-creation.ts"],"sourcesContent":[],"mappings":";;;;AA2DA;AAoCA;AAiBA;iBAtGgB,wBAAA,4BAER;;;;iBA0BQ,oBAAA;;;;iBAqBA,2BAAA,4BAER;;;;iBAkCQ,eAAA,CAAA;;;;iBAiBA,iBAAA"}
@@ -1,8 +1,13 @@
1
- function e(e,t){return`You are a senior software architect creating a contract specification for an operation.
1
+ //#region src/ai/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.
2
7
 
3
- The operation is a ${t} (${t===`command`?`changes state, has side effects`:`read-only, idempotent`}).
8
+ The operation is a ${kind} (${kind === "command" ? "changes state, has side effects" : "read-only, idempotent"}).
4
9
 
5
- User description: ${e}
10
+ User description: ${description}
6
11
 
7
12
  Create a complete contract specification following these guidelines:
8
13
 
@@ -16,9 +21,15 @@ Create a complete contract specification following these guidelines:
16
21
  8. **Feature Flags**: Any flags that gate this operation
17
22
  9. **Side Effects**: What events might be emitted, analytics to track
18
23
 
19
- Respond with a structured spec.`}function t(e){return`You are a senior software architect creating an event specification.
24
+ Respond with a structured spec.`;
25
+ }
26
+ /**
27
+ * Build prompt for creating event spec from description.
28
+ */
29
+ function buildEventSpecPrompt(description) {
30
+ return `You are a senior software architect creating an event specification.
20
31
 
21
- User description: ${e}
32
+ User description: ${description}
22
33
 
23
34
  Create a complete event specification following these guidelines:
24
35
 
@@ -30,11 +41,21 @@ Create a complete event specification following these guidelines:
30
41
 
31
42
  Events represent things that have already happened and should use past tense.
32
43
 
33
- Respond with a structured spec.`}function n(e,t){return`You are a senior software architect creating a presentation specification.
44
+ Respond with a structured spec.`;
45
+ }
46
+ /**
47
+ * Build prompt for creating presentation spec from description.
48
+ */
49
+ function buildPresentationSpecPrompt(description, kind) {
50
+ return `You are a senior software architect creating a presentation specification.
34
51
 
35
- This is a ${t} presentation - ${{web_component:`a React component with props schema`,markdown:`markdown/MDX documentation or guide`,data:`structured data export (JSON/XML)`}[t]}.
52
+ This is a ${kind} presentation - ${{
53
+ web_component: "a React component with props schema",
54
+ markdown: "markdown/MDX documentation or guide",
55
+ data: "structured data export (JSON/XML)"
56
+ }[kind]}.
36
57
 
37
- User description: ${e}
58
+ User description: ${description}
38
59
 
39
60
  Create a complete presentation specification following these guidelines:
40
61
 
@@ -42,13 +63,15 @@ Create a complete presentation specification following these guidelines:
42
63
  2. **Version**: Start at 1
43
64
  3. **Description**: What this presentation shows/provides
44
65
  4. **Kind-specific details**:
45
- ${t===`web_component`?`- Component key (symbolic, resolved by host app)
46
- - Props structure
47
- - Analytics events to track`:t===`markdown`?`- Content or resource URI
48
- - Target audience`:`- MIME type (e.g., application/json)
49
- - Data structure description`}
66
+ ${kind === "web_component" ? "- Component key (symbolic, resolved by host app)\n - Props structure\n - Analytics events to track" : kind === "markdown" ? "- Content or resource URI\n - Target audience" : "- MIME type (e.g., application/json)\n - Data structure description"}
50
67
 
51
- Respond with a structured spec.`}function r(){return`You are an expert software architect specializing in API design and contract-driven development.
68
+ Respond with a structured spec.`;
69
+ }
70
+ /**
71
+ * Build system prompt for all spec generation.
72
+ */
73
+ function getSystemPrompt() {
74
+ return `You are an expert software architect specializing in API design and contract-driven development.
52
75
 
53
76
  You create clear, well-documented specifications that serve as the single source of truth for operations, events, and presentations.
54
77
 
@@ -58,12 +81,22 @@ Your specs are:
58
81
  - Business-oriented (capturing the "why" not just "what")
59
82
  - Designed for both humans and AI agents to understand
60
83
 
61
- Always use proper dot notation for names and ensure all metadata is meaningful and accurate.`}function i(e,t){return t.length===0?e:`${e}
84
+ Always use proper dot notation for names and ensure all metadata is meaningful and accurate.`;
85
+ }
86
+ /**
87
+ * Create example-based prompt for better results.
88
+ */
89
+ function addExampleContext(basePrompt, examples) {
90
+ if (examples.length === 0) return basePrompt;
91
+ return `${basePrompt}
62
92
 
63
93
  Here are some good examples for reference:
64
94
 
65
- ${t.join(`
95
+ ${examples.join("\n\n")}
66
96
 
67
- `)}
97
+ Follow this structure and quality level.`;
98
+ }
68
99
 
69
- Follow this structure and quality level.`}export{i as addExampleContext,t as buildEventSpecPrompt,e as buildOperationSpecPrompt,n as buildPresentationSpecPrompt,r as getSystemPrompt};
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/spec-creation.ts"],"sourcesContent":["/**\n * AI prompts for spec creation.\n * Extracted from cli-contractspec/src/ai/prompts/spec-creation.ts\n */\n\nimport type { OpKind, 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":";;;;AAUA,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"}
@@ -1,2 +1,85 @@
1
- function e(e){for(let t of e.values())t.dependents=[];for(let[t,n]of e)for(let r of n.dependencies){let n=e.get(r);n&&n.dependents.push(t)}for(let t of e.values())t.dependents.sort((e,t)=>e.localeCompare(t))}function t(e){let t=new Set,n=new Set,r=[];function i(a,o){if(n.has(a)){let e=o.indexOf(a);e>=0&&r.push([...o.slice(e),a]);return}if(t.has(a))return;t.add(a),n.add(a);let s=e.get(a);if(s)for(let e of s.dependencies)i(e,[...o,a]);n.delete(a)}for(let n of e.keys())t.has(n)||i(n,[]);return r}function n(e){let t=[];for(let[n,r]of e){let i=r.dependencies.filter(t=>!e.has(t));i.length>0&&t.push({contract:n,missing:i})}return t}function r(e){let t=[];t.push(`digraph ContractDependencies {`),t.push(` rankdir=LR;`),t.push(` node [shape=box];`);for(let[n,r]of e){for(let e of r.dependencies)t.push(` "${n}" -> "${e}";`);r.dependencies.length===0&&t.push(` "${n}";`)}return t.push(`}`),t.join(`
2
- `)}function i(){return new Map}function a(e,t,n,r){e.set(t,{name:t,file:n,dependencies:r,dependents:[]})}export{a as addContractNode,e as buildReverseEdges,i as createContractGraph,t as detectCycles,n as findMissingDependencies,r as toDot};
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":["cycles: string[][]","missing: { contract: string; missing: string[] }[]","lines: string[]"],"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,MAAMA,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,MAAMC,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,MAAMC,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"}
@@ -1 +1,31 @@
1
- function e(e,t){let n=[],r=/import\s+.*?\s+from\s+['"]([^'"]+\.(?:contracts|event|presentation|workflow|data-view|migration|telemetry|experiment|app-config|integration|knowledge)(?:\.[jt]s)?)['"]/g,i;for(;(i=r.exec(e))!==null;){let e=i[1];if(!e||!e.startsWith(`.`)&&!e.startsWith(`/`))continue;let t=e.split(`/`),r=(t[t.length-1]??``).replace(/\.(ts|js)$/,``).replace(/\.(contracts|event|presentation|workflow|data-view|migration|telemetry|experiment|app-config|integration|knowledge)$/,``);r.length>0&&n.push(r)}return Array.from(new Set(n)).sort((e,t)=>e.localeCompare(t))}export{e as parseImportedSpecNames};
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":["imports: string[]","match: RegExpExecArray | null"],"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,MAAMA,UAAoB,EAAE;CAM5B,MAAM,cACJ;CAEF,IAAIC;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"}