@eddacraft/anvil-core 0.1.0

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 (215) hide show
  1. package/LICENSE +14 -0
  2. package/dist/antipattern/index.d.ts +11 -0
  3. package/dist/antipattern/index.d.ts.map +1 -0
  4. package/dist/antipattern/index.js +31 -0
  5. package/dist/antipattern/patterns-css.d.ts +17 -0
  6. package/dist/antipattern/patterns-css.d.ts.map +1 -0
  7. package/dist/antipattern/patterns-css.js +72 -0
  8. package/dist/antipattern/patterns-html.d.ts +21 -0
  9. package/dist/antipattern/patterns-html.d.ts.map +1 -0
  10. package/dist/antipattern/patterns-html.js +139 -0
  11. package/dist/antipattern/patterns.d.ts +72 -0
  12. package/dist/antipattern/patterns.d.ts.map +1 -0
  13. package/dist/antipattern/patterns.js +301 -0
  14. package/dist/antipattern/scanner.d.ts +32 -0
  15. package/dist/antipattern/scanner.d.ts.map +1 -0
  16. package/dist/antipattern/scanner.js +89 -0
  17. package/dist/antipattern/types.d.ts +318 -0
  18. package/dist/antipattern/types.d.ts.map +1 -0
  19. package/dist/antipattern/types.js +278 -0
  20. package/dist/architecture/analyzer.d.ts +123 -0
  21. package/dist/architecture/analyzer.d.ts.map +1 -0
  22. package/dist/architecture/analyzer.js +321 -0
  23. package/dist/architecture/baseline.d.ts +112 -0
  24. package/dist/architecture/baseline.d.ts.map +1 -0
  25. package/dist/architecture/baseline.js +245 -0
  26. package/dist/architecture/compiler.d.ts +24 -0
  27. package/dist/architecture/compiler.d.ts.map +1 -0
  28. package/dist/architecture/compiler.js +57 -0
  29. package/dist/architecture/context.d.ts +129 -0
  30. package/dist/architecture/context.d.ts.map +1 -0
  31. package/dist/architecture/context.js +116 -0
  32. package/dist/architecture/dc-generator.d.ts +9 -0
  33. package/dist/architecture/dc-generator.d.ts.map +1 -0
  34. package/dist/architecture/dc-generator.js +220 -0
  35. package/dist/architecture/definition-schema.d.ts +128 -0
  36. package/dist/architecture/definition-schema.d.ts.map +1 -0
  37. package/dist/architecture/definition-schema.js +94 -0
  38. package/dist/architecture/edge-detector-html.d.ts +6 -0
  39. package/dist/architecture/edge-detector-html.d.ts.map +1 -0
  40. package/dist/architecture/edge-detector-html.js +5 -0
  41. package/dist/architecture/edge-detector-web.d.ts +32 -0
  42. package/dist/architecture/edge-detector-web.d.ts.map +1 -0
  43. package/dist/architecture/edge-detector-web.js +133 -0
  44. package/dist/architecture/edge-detector.d.ts +116 -0
  45. package/dist/architecture/edge-detector.d.ts.map +1 -0
  46. package/dist/architecture/edge-detector.js +229 -0
  47. package/dist/architecture/entry-detector.d.ts +44 -0
  48. package/dist/architecture/entry-detector.d.ts.map +1 -0
  49. package/dist/architecture/entry-detector.js +263 -0
  50. package/dist/architecture/index.d.ts +21 -0
  51. package/dist/architecture/index.d.ts.map +1 -0
  52. package/dist/architecture/index.js +48 -0
  53. package/dist/architecture/layer-detector.d.ts +60 -0
  54. package/dist/architecture/layer-detector.d.ts.map +1 -0
  55. package/dist/architecture/layer-detector.js +331 -0
  56. package/dist/architecture/rego-generator.d.ts +25 -0
  57. package/dist/architecture/rego-generator.d.ts.map +1 -0
  58. package/dist/architecture/rego-generator.js +229 -0
  59. package/dist/architecture/templates/index.d.ts +39 -0
  60. package/dist/architecture/templates/index.d.ts.map +1 -0
  61. package/dist/architecture/templates/index.js +124 -0
  62. package/dist/architecture/types.d.ts +280 -0
  63. package/dist/architecture/types.d.ts.map +1 -0
  64. package/dist/architecture/types.js +269 -0
  65. package/dist/architecture/yaml-parser.d.ts +13 -0
  66. package/dist/architecture/yaml-parser.d.ts.map +1 -0
  67. package/dist/architecture/yaml-parser.js +234 -0
  68. package/dist/config/constants.d.ts +9 -0
  69. package/dist/config/constants.d.ts.map +1 -0
  70. package/dist/config/constants.js +20 -0
  71. package/dist/config/index.d.ts +9 -0
  72. package/dist/config/index.d.ts.map +1 -0
  73. package/dist/config/index.js +8 -0
  74. package/dist/config/loader.d.ts +41 -0
  75. package/dist/config/loader.d.ts.map +1 -0
  76. package/dist/config/loader.js +76 -0
  77. package/dist/config/nudge-config.d.ts +35 -0
  78. package/dist/config/nudge-config.d.ts.map +1 -0
  79. package/dist/config/nudge-config.js +34 -0
  80. package/dist/config/types.d.ts +30 -0
  81. package/dist/config/types.d.ts.map +1 -0
  82. package/dist/config/types.js +4 -0
  83. package/dist/contracts/index.d.ts +14 -0
  84. package/dist/contracts/index.d.ts.map +1 -0
  85. package/dist/contracts/index.js +13 -0
  86. package/dist/contracts/schemas/aps.schema.d.ts +269 -0
  87. package/dist/contracts/schemas/aps.schema.d.ts.map +1 -0
  88. package/dist/contracts/schemas/aps.schema.js +183 -0
  89. package/dist/contracts/schemas/index.d.ts +12 -0
  90. package/dist/contracts/schemas/index.d.ts.map +1 -0
  91. package/dist/contracts/schemas/index.js +14 -0
  92. package/dist/contracts/schemas/json-schema.d.ts +14 -0
  93. package/dist/contracts/schemas/json-schema.d.ts.map +1 -0
  94. package/dist/contracts/schemas/json-schema.js +31 -0
  95. package/dist/contracts/schemas/warning.schema.d.ts +171 -0
  96. package/dist/contracts/schemas/warning.schema.d.ts.map +1 -0
  97. package/dist/contracts/schemas/warning.schema.js +123 -0
  98. package/dist/contracts/types/gate.types.d.ts +194 -0
  99. package/dist/contracts/types/gate.types.d.ts.map +1 -0
  100. package/dist/contracts/types/gate.types.js +19 -0
  101. package/dist/contracts/types/index.d.ts +9 -0
  102. package/dist/contracts/types/index.d.ts.map +1 -0
  103. package/dist/contracts/types/index.js +8 -0
  104. package/dist/crypto/hash.d.ts +47 -0
  105. package/dist/crypto/hash.d.ts.map +1 -0
  106. package/dist/crypto/hash.js +110 -0
  107. package/dist/crypto/index.d.ts +7 -0
  108. package/dist/crypto/index.d.ts.map +1 -0
  109. package/dist/crypto/index.js +6 -0
  110. package/dist/drift/index.d.ts +6 -0
  111. package/dist/drift/index.d.ts.map +1 -0
  112. package/dist/drift/index.js +5 -0
  113. package/dist/drift/report-generator.d.ts +21 -0
  114. package/dist/drift/report-generator.d.ts.map +1 -0
  115. package/dist/drift/report-generator.js +240 -0
  116. package/dist/drift/snapshot-capture.d.ts +26 -0
  117. package/dist/drift/snapshot-capture.d.ts.map +1 -0
  118. package/dist/drift/snapshot-capture.js +195 -0
  119. package/dist/drift/snapshot-compare.d.ts +50 -0
  120. package/dist/drift/snapshot-compare.d.ts.map +1 -0
  121. package/dist/drift/snapshot-compare.js +142 -0
  122. package/dist/drift/snapshot-schema.d.ts +197 -0
  123. package/dist/drift/snapshot-schema.d.ts.map +1 -0
  124. package/dist/drift/snapshot-schema.js +193 -0
  125. package/dist/drift/snapshot-storage.d.ts +25 -0
  126. package/dist/drift/snapshot-storage.d.ts.map +1 -0
  127. package/dist/drift/snapshot-storage.js +179 -0
  128. package/dist/explain/antipattern-explainer.d.ts +4 -0
  129. package/dist/explain/antipattern-explainer.d.ts.map +1 -0
  130. package/dist/explain/antipattern-explainer.js +196 -0
  131. package/dist/explain/boundary-explainer.d.ts +5 -0
  132. package/dist/explain/boundary-explainer.d.ts.map +1 -0
  133. package/dist/explain/boundary-explainer.js +261 -0
  134. package/dist/explain/explain-service.d.ts +19 -0
  135. package/dist/explain/explain-service.d.ts.map +1 -0
  136. package/dist/explain/explain-service.js +106 -0
  137. package/dist/explain/index.d.ts +7 -0
  138. package/dist/explain/index.d.ts.map +1 -0
  139. package/dist/explain/index.js +5 -0
  140. package/dist/explain/template-loader.d.ts +9 -0
  141. package/dist/explain/template-loader.d.ts.map +1 -0
  142. package/dist/explain/template-loader.js +51 -0
  143. package/dist/explain/types.d.ts +46 -0
  144. package/dist/explain/types.d.ts.map +1 -0
  145. package/dist/explain/types.js +31 -0
  146. package/dist/index.d.ts +26 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +37 -0
  149. package/dist/provenance/collector.d.ts +86 -0
  150. package/dist/provenance/collector.d.ts.map +1 -0
  151. package/dist/provenance/collector.js +425 -0
  152. package/dist/provenance/git-ai-standard/git-notes.d.ts +85 -0
  153. package/dist/provenance/git-ai-standard/git-notes.d.ts.map +1 -0
  154. package/dist/provenance/git-ai-standard/git-notes.js +292 -0
  155. package/dist/provenance/git-ai-standard/index.d.ts +44 -0
  156. package/dist/provenance/git-ai-standard/index.d.ts.map +1 -0
  157. package/dist/provenance/git-ai-standard/index.js +47 -0
  158. package/dist/provenance/git-ai-standard/serializer.d.ts +54 -0
  159. package/dist/provenance/git-ai-standard/serializer.d.ts.map +1 -0
  160. package/dist/provenance/git-ai-standard/serializer.js +224 -0
  161. package/dist/provenance/git-ai-standard/session.d.ts +51 -0
  162. package/dist/provenance/git-ai-standard/session.d.ts.map +1 -0
  163. package/dist/provenance/git-ai-standard/session.js +118 -0
  164. package/dist/provenance/git-ai-standard/types.d.ts +173 -0
  165. package/dist/provenance/git-ai-standard/types.d.ts.map +1 -0
  166. package/dist/provenance/git-ai-standard/types.js +109 -0
  167. package/dist/provenance/index.d.ts +5 -0
  168. package/dist/provenance/index.d.ts.map +1 -0
  169. package/dist/provenance/index.js +6 -0
  170. package/dist/provenance/store.d.ts +83 -0
  171. package/dist/provenance/store.d.ts.map +1 -0
  172. package/dist/provenance/store.js +248 -0
  173. package/dist/provenance/types.d.ts +160 -0
  174. package/dist/provenance/types.d.ts.map +1 -0
  175. package/dist/provenance/types.js +112 -0
  176. package/dist/suppression/index.d.ts +4 -0
  177. package/dist/suppression/index.d.ts.map +1 -0
  178. package/dist/suppression/index.js +3 -0
  179. package/dist/suppression/parser.d.ts +31 -0
  180. package/dist/suppression/parser.d.ts.map +1 -0
  181. package/dist/suppression/parser.js +219 -0
  182. package/dist/suppression/service.d.ts +29 -0
  183. package/dist/suppression/service.d.ts.map +1 -0
  184. package/dist/suppression/service.js +132 -0
  185. package/dist/suppression/store.d.ts +61 -0
  186. package/dist/suppression/store.d.ts.map +1 -0
  187. package/dist/suppression/store.js +169 -0
  188. package/dist/utils/debug.d.ts +48 -0
  189. package/dist/utils/debug.d.ts.map +1 -0
  190. package/dist/utils/debug.js +100 -0
  191. package/dist/utils/index.d.ts +4 -0
  192. package/dist/utils/index.d.ts.map +1 -0
  193. package/dist/utils/index.js +3 -0
  194. package/dist/utils/path-safety.d.ts +21 -0
  195. package/dist/utils/path-safety.d.ts.map +1 -0
  196. package/dist/utils/path-safety.js +49 -0
  197. package/dist/utils/severity.d.ts +37 -0
  198. package/dist/utils/severity.d.ts.map +1 -0
  199. package/dist/utils/severity.js +22 -0
  200. package/dist/validation/aps-validator.d.ts +66 -0
  201. package/dist/validation/aps-validator.d.ts.map +1 -0
  202. package/dist/validation/aps-validator.js +173 -0
  203. package/dist/validation/errors.d.ts +52 -0
  204. package/dist/validation/errors.d.ts.map +1 -0
  205. package/dist/validation/errors.js +115 -0
  206. package/dist/validation/index.d.ts +8 -0
  207. package/dist/validation/index.d.ts.map +1 -0
  208. package/dist/validation/index.js +13 -0
  209. package/dist/warnings/index.d.ts +2 -0
  210. package/dist/warnings/index.d.ts.map +1 -0
  211. package/dist/warnings/index.js +1 -0
  212. package/dist/warnings/warning-id.d.ts +180 -0
  213. package/dist/warnings/warning-id.d.ts.map +1 -0
  214. package/dist/warnings/warning-id.js +257 -0
  215. package/package.json +79 -0
@@ -0,0 +1,269 @@
1
+ /**
2
+ * Architecture baseline types
3
+ *
4
+ * Defines the schema for .anvil/architecture.json - the architecture baseline
5
+ * that enables NEW vs existing violation detection.
6
+ */
7
+ import { z } from 'zod';
8
+ // =============================================================================
9
+ // Entry Point Schema
10
+ // =============================================================================
11
+ /**
12
+ * Entry point types detected in the codebase
13
+ */
14
+ export const EntryPointTypeSchema = z.enum([
15
+ 'package', // Package entry (index.ts, main export)
16
+ 'application', // Application entry (main.ts, app.ts)
17
+ 'http', // HTTP handlers (routes, controllers)
18
+ 'api', // API handlers
19
+ 'cli', // CLI commands
20
+ 'worker', // Background workers/jobs
21
+ 'test', // Test entry points
22
+ 'unknown', // Could not determine type
23
+ ]);
24
+ /**
25
+ * Confidence level for detection
26
+ */
27
+ export const DetectionConfidenceSchema = z.enum(['high', 'medium', 'low']);
28
+ /**
29
+ * A detected entry point in the codebase
30
+ */
31
+ export const EntryPointSchema = z.object({
32
+ path: z.string().describe('File path relative to workspace root'),
33
+ type: EntryPointTypeSchema.describe('Type of entry point'),
34
+ confidence: DetectionConfidenceSchema.describe('Detection confidence'),
35
+ exports: z.array(z.string()).optional().describe('Named exports if applicable'),
36
+ });
37
+ // =============================================================================
38
+ // Layer Schema
39
+ // =============================================================================
40
+ /**
41
+ * Standard layer names (can be extended)
42
+ */
43
+ export const StandardLayerSchema = z.enum([
44
+ 'presentation',
45
+ 'application',
46
+ 'domain',
47
+ 'infrastructure',
48
+ 'shared',
49
+ ]);
50
+ /**
51
+ * Layer definition with dependency rules
52
+ */
53
+ export const LayerSchema = z.object({
54
+ patterns: z.array(z.string()).describe('Glob patterns matching files in this layer'),
55
+ depends_on: z.array(z.string()).describe('Layers this layer is allowed to depend on'),
56
+ description: z.string().optional().describe('Human-readable description'),
57
+ });
58
+ /**
59
+ * Map of layer name to layer definition
60
+ */
61
+ export const LayersSchema = z.record(z.string(), LayerSchema);
62
+ // =============================================================================
63
+ // Boundary Schema
64
+ // =============================================================================
65
+ /**
66
+ * Explicit boundary rule
67
+ */
68
+ export const BoundarySchema = z.object({
69
+ name: z.string().describe('Unique boundary name'),
70
+ from: z.string().describe('Source layer'),
71
+ to: z.string().describe('Target layer'),
72
+ severity: z.enum(['error', 'warning', 'info']).describe('Violation severity'),
73
+ message: z.string().describe('Human-readable message when violated'),
74
+ confidence: DetectionConfidenceSchema.optional().describe('Inference confidence (for auto-detected boundaries)'),
75
+ });
76
+ // =============================================================================
77
+ // Violation Schema (for baseline snapshot)
78
+ // =============================================================================
79
+ /**
80
+ * A recorded violation in the baseline
81
+ */
82
+ export const BaselineViolationSchema = z.object({
83
+ id: z.string().describe('Unique violation ID (hash of from+to+line)'),
84
+ from_layer: z.string().describe('Source layer'),
85
+ to_layer: z.string().describe('Target layer'),
86
+ from_file: z.string().describe('File containing the import'),
87
+ to_file: z.string().describe('File being imported'),
88
+ import_line: z.number().int().positive().describe('Line number of import'),
89
+ rule: z.string().optional().describe('Rule name that was violated (for matching new violations)'),
90
+ });
91
+ // =============================================================================
92
+ // Baseline Snapshot Schema
93
+ // =============================================================================
94
+ /**
95
+ * Snapshot of the architecture state at baseline time
96
+ */
97
+ export const BaselineSnapshotSchema = z.object({
98
+ module_count: z.number().int().nonnegative().describe('Total modules analysed'),
99
+ timestamp: z.string().datetime().describe('When baseline was created'),
100
+ violations: z.array(BaselineViolationSchema).describe('Existing violations at baseline time'),
101
+ });
102
+ // =============================================================================
103
+ // Architecture Baseline Schema (Full)
104
+ // =============================================================================
105
+ /**
106
+ * Complete architecture baseline stored in .anvil/architecture.json
107
+ */
108
+ export const ArchitectureBaselineSchema = z.object({
109
+ // Metadata
110
+ schema_version: z.literal('0.1.0').describe('Schema version'),
111
+ created_at: z.string().datetime().describe('When baseline was created'),
112
+ updated_at: z.string().datetime().describe('When baseline was last updated'),
113
+ // Entry points
114
+ entry_points: z.array(EntryPointSchema).describe('Detected entry points'),
115
+ // Layer structure
116
+ layers: LayersSchema.describe('Layer definitions with dependency rules'),
117
+ // Explicit boundaries
118
+ boundaries: z.array(BoundarySchema).describe('Explicit boundary rules'),
119
+ // Baseline snapshot for NEW vs existing detection
120
+ baseline_snapshot: BaselineSnapshotSchema.describe('Snapshot of violations at baseline time'),
121
+ });
122
+ // =============================================================================
123
+ // Layer Detection Result
124
+ // =============================================================================
125
+ /**
126
+ * Result of layer detection for a file
127
+ */
128
+ export const LayerAssignmentSchema = z.object({
129
+ file: z.string().describe('File path'),
130
+ layer: z.string().nullable().describe('Assigned layer (null if unassigned)'),
131
+ confidence: DetectionConfidenceSchema.describe('Assignment confidence'),
132
+ matched_pattern: z.string().optional().describe('Pattern that matched'),
133
+ });
134
+ // =============================================================================
135
+ // Dependency Edge
136
+ // =============================================================================
137
+ /**
138
+ * A dependency edge between two files
139
+ */
140
+ export const DependencyEdgeSchema = z.object({
141
+ from: z.string().describe('Source file'),
142
+ to: z.string().describe('Target file'),
143
+ from_layer: z.string().nullable().describe('Source layer'),
144
+ to_layer: z.string().nullable().describe('Target layer'),
145
+ line: z.number().int().positive().describe('Import line number'),
146
+ type: z.enum(['import', 'require', 'dynamic']).describe('Import type'),
147
+ });
148
+ // =============================================================================
149
+ // Boundary Violation
150
+ // =============================================================================
151
+ /**
152
+ * A detected boundary violation
153
+ */
154
+ export const BoundaryViolationSchema = z.object({
155
+ edge: DependencyEdgeSchema.describe('The violating edge'),
156
+ boundary: BoundarySchema.optional().describe('Explicit boundary violated'),
157
+ is_new: z.boolean().describe('Whether this is a NEW violation'),
158
+ baseline_id: z.string().optional().describe('ID in baseline if existing violation'),
159
+ });
160
+ // =============================================================================
161
+ // Utility Functions
162
+ // =============================================================================
163
+ /**
164
+ * Create a violation ID from edge details
165
+ */
166
+ export function createViolationId(fromFile, toFile, line) {
167
+ // Simple deterministic ID - in production would use proper hash
168
+ return `${fromFile}:${toFile}:${line}`.replace(/[^a-zA-Z0-9:]/g, '_');
169
+ }
170
+ /**
171
+ * Check if a violation exists in the baseline
172
+ */
173
+ export function isExistingViolation(violation, baseline) {
174
+ const id = createViolationId(violation.edge.from, violation.edge.to, violation.edge.line);
175
+ return baseline.violations.some((v) => v.id === id);
176
+ }
177
+ /**
178
+ * Create default layer structure for common patterns.
179
+ *
180
+ * Patterns use **\/ prefix to match files in any directory structure,
181
+ * supporting both single-app (src/) and monorepo (packages/star/src/) layouts.
182
+ */
183
+ export function createDefaultLayers() {
184
+ return {
185
+ presentation: {
186
+ patterns: [
187
+ '**/controllers/**',
188
+ '**/routes/**',
189
+ '**/api/**',
190
+ '**/handlers/**',
191
+ '**/endpoints/**',
192
+ '**/pages/**',
193
+ ],
194
+ depends_on: ['application', 'shared'],
195
+ description: 'HTTP handlers, controllers, API routes',
196
+ },
197
+ application: {
198
+ patterns: [
199
+ '**/services/**',
200
+ '**/use-cases/**',
201
+ '**/usecases/**',
202
+ '**/application/**',
203
+ '**/interactors/**',
204
+ ],
205
+ depends_on: ['domain', 'infrastructure', 'shared'],
206
+ description: 'Business logic, use cases, services',
207
+ },
208
+ domain: {
209
+ patterns: ['**/domain/**', '**/entities/**', '**/models/**', '**/core/**', '**/business/**'],
210
+ depends_on: ['shared'],
211
+ description: 'Domain entities, value objects, domain logic',
212
+ },
213
+ infrastructure: {
214
+ patterns: [
215
+ '**/repositories/**',
216
+ '**/data/**',
217
+ '**/infrastructure/**',
218
+ '**/db/**',
219
+ '**/database/**',
220
+ '**/adapters/**',
221
+ '**/external/**',
222
+ '**/clients/**',
223
+ ],
224
+ depends_on: ['domain', 'shared'],
225
+ description: 'Data access, external services, infrastructure',
226
+ },
227
+ shared: {
228
+ patterns: [
229
+ '**/utils/**',
230
+ '**/lib/**',
231
+ '**/common/**',
232
+ '**/shared/**',
233
+ '**/helpers/**',
234
+ '**/types/**',
235
+ '**/constants/**',
236
+ '**/config/**',
237
+ ],
238
+ depends_on: [],
239
+ description: 'Shared utilities, helpers, common code',
240
+ },
241
+ };
242
+ }
243
+ /**
244
+ * Create default boundaries from layer structure
245
+ */
246
+ export function createDefaultBoundaries(layers) {
247
+ const boundaries = [];
248
+ const layerNames = Object.keys(layers);
249
+ for (const fromLayer of layerNames) {
250
+ const allowedDeps = layers[fromLayer].depends_on;
251
+ for (const toLayer of layerNames) {
252
+ // Skip self-references
253
+ if (fromLayer === toLayer)
254
+ continue;
255
+ // If not in allowed deps, create a boundary
256
+ if (!allowedDeps.includes(toLayer)) {
257
+ boundaries.push({
258
+ name: `no-${fromLayer}-to-${toLayer}`,
259
+ from: fromLayer,
260
+ to: toLayer,
261
+ severity: 'error',
262
+ message: `${fromLayer} layer must not directly depend on ${toLayer}`,
263
+ confidence: 'high',
264
+ });
265
+ }
266
+ }
267
+ }
268
+ return boundaries;
269
+ }
@@ -0,0 +1,13 @@
1
+ import { type ArchitectureDefinition, type ArchitectureTemplate, type LayerDefinition } from './definition-schema.js';
2
+ export declare const ARCHITECTURE_YAML_FILENAME = "architecture.yaml";
3
+ export declare const ANVIL_DIR = ".anvil";
4
+ export declare function getArchitectureYamlPath(workspaceRoot: string): string;
5
+ export declare function architectureYamlExists(workspaceRoot: string): boolean;
6
+ export declare function parseArchitectureDefinition(workspaceRoot: string): Promise<ArchitectureDefinition>;
7
+ export declare function writeArchitectureYaml(workspaceRoot: string, definition: ArchitectureDefinition): Promise<void>;
8
+ type LayersRecord = Record<string, LayerDefinition>;
9
+ export declare function getTemplateDefaults(template: ArchitectureTemplate): LayersRecord;
10
+ export declare function mergeWithTemplate(definition: ArchitectureDefinition): ArchitectureDefinition;
11
+ export declare function createDefinitionFromTemplate(template: ArchitectureTemplate): ArchitectureDefinition;
12
+ export {};
13
+ //# sourceMappingURL=yaml-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-parser.d.ts","sourceRoot":"","sources":["../../src/architecture/yaml-parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAErB,MAAM,wBAAwB,CAAC;AAKhC,eAAO,MAAM,0BAA0B,sBAAsB,CAAC;AAC9D,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,wBAAsB,2BAA2B,CAC/C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,sBAAsB,CAAC,CAkBjC;AAED,wBAAsB,qBAAqB,CACzC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,sBAAsB,GACjC,OAAO,CAAC,IAAI,CAAC,CAIf;AASD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAmLpD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,YAAY,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,sBAAsB,GAAG,sBAAsB,CAS5F;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,oBAAoB,GAC7B,sBAAsB,CAQxB"}
@@ -0,0 +1,234 @@
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import YAML from 'yaml';
5
+ import { ArchitectureDefinitionSchema, getDefaultOptions, } from './definition-schema.js';
6
+ import { createDebugger } from '../utils/debug.js';
7
+ const debug = createDebugger('compiler');
8
+ export const ARCHITECTURE_YAML_FILENAME = 'architecture.yaml';
9
+ export const ANVIL_DIR = '.anvil';
10
+ export function getArchitectureYamlPath(workspaceRoot) {
11
+ return join(workspaceRoot, ANVIL_DIR, ARCHITECTURE_YAML_FILENAME);
12
+ }
13
+ export function architectureYamlExists(workspaceRoot) {
14
+ return existsSync(getArchitectureYamlPath(workspaceRoot));
15
+ }
16
+ export async function parseArchitectureDefinition(workspaceRoot) {
17
+ const yamlPath = getArchitectureYamlPath(workspaceRoot);
18
+ debug('parsing architecture definition', yamlPath);
19
+ if (!existsSync(yamlPath)) {
20
+ throw new Error(`Architecture YAML not found: ${yamlPath}`);
21
+ }
22
+ const content = await readFile(yamlPath, 'utf-8');
23
+ const raw = YAML.parse(content);
24
+ const result = ArchitectureDefinitionSchema.safeParse(raw);
25
+ if (!result.success) {
26
+ debug('architecture.yaml validation failed', result.error.message);
27
+ throw new Error(`Invalid architecture.yaml: ${result.error.message}`);
28
+ }
29
+ debug('architecture definition parsed', {
30
+ template: result.data.template,
31
+ layerCount: Object.keys(result.data.layers).length,
32
+ });
33
+ return applyDefaults(result.data);
34
+ }
35
+ export async function writeArchitectureYaml(workspaceRoot, definition) {
36
+ const yamlPath = getArchitectureYamlPath(workspaceRoot);
37
+ const content = YAML.stringify(definition, { indent: 2 });
38
+ await writeFile(yamlPath, content, 'utf-8');
39
+ }
40
+ function applyDefaults(definition) {
41
+ return {
42
+ ...definition,
43
+ options: definition.options ?? getDefaultOptions(),
44
+ };
45
+ }
46
+ const LAYERED_TEMPLATE = {
47
+ presentation: {
48
+ patterns: ['src/controllers/**', 'src/routes/**', 'src/api/**'],
49
+ depends_on: ['business', 'shared'],
50
+ },
51
+ business: {
52
+ patterns: ['src/services/**', 'src/use-cases/**'],
53
+ depends_on: ['data', 'shared'],
54
+ },
55
+ data: {
56
+ patterns: ['src/repositories/**', 'src/db/**', 'src/data/**'],
57
+ depends_on: ['shared'],
58
+ },
59
+ shared: {
60
+ patterns: ['src/utils/**', 'src/lib/**', 'src/common/**'],
61
+ depends_on: [],
62
+ },
63
+ };
64
+ const HEXAGONAL_TEMPLATE = {
65
+ core: {
66
+ patterns: ['src/domain/**', 'src/core/**'],
67
+ depends_on: [],
68
+ description: 'Domain logic - no external dependencies',
69
+ },
70
+ ports: {
71
+ patterns: ['src/ports/**', 'src/interfaces/**'],
72
+ depends_on: ['core'],
73
+ description: 'Port interfaces',
74
+ },
75
+ adapters: {
76
+ patterns: ['src/adapters/**', 'src/infrastructure/**'],
77
+ depends_on: ['ports', 'core'],
78
+ description: 'Adapter implementations',
79
+ },
80
+ application: {
81
+ patterns: ['src/application/**', 'src/services/**'],
82
+ depends_on: ['core', 'ports'],
83
+ description: 'Application services',
84
+ },
85
+ };
86
+ const CLEAN_TEMPLATE = {
87
+ entities: {
88
+ patterns: ['src/entities/**', 'src/domain/entities/**'],
89
+ depends_on: [],
90
+ description: 'Enterprise business rules',
91
+ },
92
+ use_cases: {
93
+ patterns: ['src/use-cases/**', 'src/application/**'],
94
+ depends_on: ['entities'],
95
+ description: 'Application business rules',
96
+ },
97
+ interface_adapters: {
98
+ patterns: ['src/adapters/**', 'src/controllers/**', 'src/presenters/**'],
99
+ depends_on: ['use_cases', 'entities'],
100
+ description: 'Interface adapters',
101
+ },
102
+ frameworks: {
103
+ patterns: ['src/frameworks/**', 'src/infrastructure/**', 'src/db/**'],
104
+ depends_on: ['interface_adapters', 'use_cases', 'entities'],
105
+ description: 'Frameworks and drivers',
106
+ },
107
+ };
108
+ const DDD_TEMPLATE = {
109
+ domain: {
110
+ patterns: ['src/domain/**'],
111
+ depends_on: [],
112
+ description: 'Domain model and logic',
113
+ },
114
+ application: {
115
+ patterns: ['src/application/**'],
116
+ depends_on: ['domain'],
117
+ description: 'Application services',
118
+ },
119
+ infrastructure: {
120
+ patterns: ['src/infrastructure/**'],
121
+ depends_on: ['domain', 'application'],
122
+ description: 'Infrastructure implementations',
123
+ },
124
+ interfaces: {
125
+ patterns: ['src/interfaces/**', 'src/api/**'],
126
+ depends_on: ['application', 'domain'],
127
+ description: 'User interfaces and API',
128
+ },
129
+ };
130
+ const STARTER_TEMPLATE = {
131
+ components: {
132
+ patterns: ['src/components/**', 'src/ui/**'],
133
+ depends_on: ['lib'],
134
+ description: 'UI components and visual elements',
135
+ },
136
+ lib: {
137
+ patterns: ['src/lib/**', 'src/utils/**', 'src/helpers/**'],
138
+ depends_on: [],
139
+ description: 'Shared utilities and helper functions',
140
+ },
141
+ services: {
142
+ patterns: ['src/services/**', 'src/api/**'],
143
+ depends_on: ['lib'],
144
+ description: 'API calls and external service integrations',
145
+ },
146
+ };
147
+ const MONOREPO_TEMPLATE = {
148
+ packages: {
149
+ patterns: ['apps/**', 'packages/**', 'libs/**', 'utils/**'],
150
+ depends_on: ['shared'],
151
+ description: 'Application and library packages',
152
+ },
153
+ shared: {
154
+ patterns: ['shared/**'],
155
+ depends_on: [],
156
+ description: 'Shared utilities and configurations',
157
+ },
158
+ };
159
+ const SERVERLESS_TEMPLATE = {
160
+ functions: {
161
+ patterns: ['src/functions/**', 'src/handlers/**', 'src/lambdas/**'],
162
+ depends_on: ['services', 'shared'],
163
+ description: 'Serverless function handlers',
164
+ },
165
+ services: {
166
+ patterns: ['src/services/**', 'src/business/**'],
167
+ depends_on: ['shared'],
168
+ description: 'Business logic shared across functions',
169
+ },
170
+ shared: {
171
+ patterns: ['src/shared/**', 'src/utils/**', 'src/lib/**'],
172
+ depends_on: [],
173
+ description: 'Shared utilities and configurations',
174
+ },
175
+ };
176
+ const NX_WORKSPACE_TEMPLATE = {
177
+ apps: {
178
+ patterns: ['apps/**'],
179
+ depends_on: ['feature-libs', 'shared-libs'],
180
+ description: 'Deployable applications',
181
+ },
182
+ 'feature-libs': {
183
+ patterns: ['libs/feature-*/**', 'libs/*/feature-*/**'],
184
+ depends_on: ['data-access-libs', 'ui-libs', 'shared-libs'],
185
+ description: 'Feature libraries',
186
+ },
187
+ 'data-access-libs': {
188
+ patterns: ['libs/data-access-*/**', 'libs/*/data-access-*/**'],
189
+ depends_on: ['shared-libs'],
190
+ description: 'Data access libraries',
191
+ },
192
+ 'ui-libs': {
193
+ patterns: ['libs/ui-*/**', 'libs/*/ui-*/**'],
194
+ depends_on: ['shared-libs'],
195
+ description: 'UI component libraries',
196
+ },
197
+ 'shared-libs': {
198
+ patterns: ['libs/shared/**', 'libs/util-*/**', 'libs/*/util-*/**'],
199
+ depends_on: [],
200
+ description: 'Shared utilities and configurations',
201
+ },
202
+ };
203
+ const TEMPLATE_DEFAULTS = {
204
+ starter: STARTER_TEMPLATE,
205
+ layered: LAYERED_TEMPLATE,
206
+ hexagonal: HEXAGONAL_TEMPLATE,
207
+ clean: CLEAN_TEMPLATE,
208
+ ddd: DDD_TEMPLATE,
209
+ monorepo: MONOREPO_TEMPLATE,
210
+ serverless: SERVERLESS_TEMPLATE,
211
+ 'nx-workspace': NX_WORKSPACE_TEMPLATE,
212
+ custom: {},
213
+ };
214
+ export function getTemplateDefaults(template) {
215
+ return { ...TEMPLATE_DEFAULTS[template] };
216
+ }
217
+ export function mergeWithTemplate(definition) {
218
+ const templateLayers = getTemplateDefaults(definition.template);
219
+ const hasUserLayers = Object.keys(definition.layers).length > 0;
220
+ return {
221
+ ...definition,
222
+ layers: hasUserLayers ? definition.layers : templateLayers,
223
+ options: definition.options ?? getDefaultOptions(),
224
+ };
225
+ }
226
+ export function createDefinitionFromTemplate(template) {
227
+ return {
228
+ schema_version: '0.1.0',
229
+ template,
230
+ layers: getTemplateDefaults(template),
231
+ rules: [],
232
+ options: getDefaultOptions(),
233
+ };
234
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Configuration constants
3
+ */
4
+ /**
5
+ * Default file extensions that Anvil analyses.
6
+ * Includes JS/TS and HTML/CSS file types.
7
+ */
8
+ export declare const DEFAULT_ANALYSABLE_EXTENSIONS: string[];
9
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/config/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,eAAO,MAAM,6BAA6B,UAYzC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Configuration constants
3
+ */
4
+ /**
5
+ * Default file extensions that Anvil analyses.
6
+ * Includes JS/TS and HTML/CSS file types.
7
+ */
8
+ export const DEFAULT_ANALYSABLE_EXTENSIONS = [
9
+ '.ts',
10
+ '.tsx',
11
+ '.js',
12
+ '.jsx',
13
+ '.mjs',
14
+ '.cjs',
15
+ '.html',
16
+ '.htm',
17
+ '.css',
18
+ '.scss',
19
+ '.less',
20
+ ];
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Platform config — constants, loaders, and nudge settings.
3
+ * Formerly @eddacraft/anvil-platform-config, now co-located inside @eddacraft/anvil-core.
4
+ */
5
+ export * from './constants.js';
6
+ export * from './loader.js';
7
+ export * from './nudge-config.js';
8
+ export * from './types.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Platform config — constants, loaders, and nudge settings.
3
+ * Formerly @eddacraft/anvil-platform-config, now co-located inside @eddacraft/anvil-core.
4
+ */
5
+ export * from './constants.js';
6
+ export * from './loader.js';
7
+ export * from './nudge-config.js';
8
+ export * from './types.js';
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Configuration Loader
3
+ *
4
+ * Loads configuration from files and environment variables.
5
+ * This is a placeholder - actual implementation will be enhanced.
6
+ */
7
+ import type { ConfigLoaderOptions, ConfigSource } from './types.js';
8
+ /**
9
+ * Configuration loader class
10
+ */
11
+ export declare class ConfigLoader {
12
+ private readonly _options;
13
+ private config;
14
+ constructor(options?: ConfigLoaderOptions);
15
+ get options(): Required<ConfigLoaderOptions>;
16
+ /**
17
+ * Get a configuration value
18
+ */
19
+ get<T>(key: string): T | undefined;
20
+ /**
21
+ * Get a configuration value with a default
22
+ */
23
+ getOrDefault<T>(key: string, defaultValue: T): T;
24
+ /**
25
+ * Check if a configuration key exists
26
+ */
27
+ has(key: string): boolean;
28
+ /**
29
+ * Set a configuration value
30
+ */
31
+ set<T>(key: string, value: T, source?: ConfigSource): void;
32
+ /**
33
+ * Get all configuration values
34
+ */
35
+ getAll(): Record<string, unknown>;
36
+ }
37
+ /**
38
+ * Create a configuration loader
39
+ */
40
+ export declare function createConfigLoader(options?: ConfigLoaderOptions): ConfigLoader;
41
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAe,YAAY,EAAE,MAAM,YAAY,CAAC;AAKjF;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;IACzD,OAAO,CAAC,MAAM,CAAuC;gBAEzC,OAAO,GAAE,mBAAwB;IAiB7C,IAAI,OAAO,IAAI,QAAQ,CAAC,mBAAmB,CAAC,CAE3C;IAED;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAKlC;;OAEG;IACH,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC;IAIhD;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAE,YAAwB,GAAG,IAAI;IAKrE;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOlC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAE9E"}