@eddacraft/anvil-runtime 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 (170) hide show
  1. package/LICENSE +14 -0
  2. package/dist/cache/cache-key.d.ts +45 -0
  3. package/dist/cache/cache-key.d.ts.map +1 -0
  4. package/dist/cache/cache-key.js +135 -0
  5. package/dist/cache/index.d.ts +27 -0
  6. package/dist/cache/index.d.ts.map +1 -0
  7. package/dist/cache/index.js +38 -0
  8. package/dist/cache/providers/file-cache.d.ts +63 -0
  9. package/dist/cache/providers/file-cache.d.ts.map +1 -0
  10. package/dist/cache/providers/file-cache.js +369 -0
  11. package/dist/cache/providers/memory-cache.d.ts +52 -0
  12. package/dist/cache/providers/memory-cache.d.ts.map +1 -0
  13. package/dist/cache/providers/memory-cache.js +197 -0
  14. package/dist/cache/providers/null-cache.d.ts +26 -0
  15. package/dist/cache/providers/null-cache.d.ts.map +1 -0
  16. package/dist/cache/providers/null-cache.js +50 -0
  17. package/dist/cache/types.d.ts +114 -0
  18. package/dist/cache/types.d.ts.map +1 -0
  19. package/dist/cache/types.js +4 -0
  20. package/dist/concurrency/agent.d.ts +137 -0
  21. package/dist/concurrency/agent.d.ts.map +1 -0
  22. package/dist/concurrency/agent.js +440 -0
  23. package/dist/concurrency/atomic.d.ts +93 -0
  24. package/dist/concurrency/atomic.d.ts.map +1 -0
  25. package/dist/concurrency/atomic.js +281 -0
  26. package/dist/concurrency/git-agent.d.ts +114 -0
  27. package/dist/concurrency/git-agent.d.ts.map +1 -0
  28. package/dist/concurrency/git-agent.js +313 -0
  29. package/dist/concurrency/index.d.ts +95 -0
  30. package/dist/concurrency/index.d.ts.map +1 -0
  31. package/dist/concurrency/index.js +127 -0
  32. package/dist/concurrency/lock-manager.d.ts +170 -0
  33. package/dist/concurrency/lock-manager.d.ts.map +1 -0
  34. package/dist/concurrency/lock-manager.js +525 -0
  35. package/dist/concurrency/queue-manager.d.ts +166 -0
  36. package/dist/concurrency/queue-manager.d.ts.map +1 -0
  37. package/dist/concurrency/queue-manager.js +442 -0
  38. package/dist/concurrency/types.d.ts +382 -0
  39. package/dist/concurrency/types.d.ts.map +1 -0
  40. package/dist/concurrency/types.js +204 -0
  41. package/dist/export/constraint-collector.d.ts +175 -0
  42. package/dist/export/constraint-collector.d.ts.map +1 -0
  43. package/dist/export/constraint-collector.js +203 -0
  44. package/dist/export/formatters/llms-txt-formatter.d.ts +89 -0
  45. package/dist/export/formatters/llms-txt-formatter.d.ts.map +1 -0
  46. package/dist/export/formatters/llms-txt-formatter.js +249 -0
  47. package/dist/export/formatters/mcp-resource-formatter.d.ts +186 -0
  48. package/dist/export/formatters/mcp-resource-formatter.d.ts.map +1 -0
  49. package/dist/export/formatters/mcp-resource-formatter.js +139 -0
  50. package/dist/export/formatters/prompt-formatter.d.ts +83 -0
  51. package/dist/export/formatters/prompt-formatter.d.ts.map +1 -0
  52. package/dist/export/formatters/prompt-formatter.js +256 -0
  53. package/dist/export/index.d.ts +10 -0
  54. package/dist/export/index.d.ts.map +1 -0
  55. package/dist/export/index.js +9 -0
  56. package/dist/gate/check.interface.d.ts +15 -0
  57. package/dist/gate/check.interface.d.ts.map +1 -0
  58. package/dist/gate/check.interface.js +18 -0
  59. package/dist/gate/checks/antipattern.check.d.ts +27 -0
  60. package/dist/gate/checks/antipattern.check.d.ts.map +1 -0
  61. package/dist/gate/checks/antipattern.check.js +140 -0
  62. package/dist/gate/checks/architecture/circular-detector.d.ts +33 -0
  63. package/dist/gate/checks/architecture/circular-detector.d.ts.map +1 -0
  64. package/dist/gate/checks/architecture/circular-detector.js +71 -0
  65. package/dist/gate/checks/architecture/dependency-analyzer.d.ts +81 -0
  66. package/dist/gate/checks/architecture/dependency-analyzer.d.ts.map +1 -0
  67. package/dist/gate/checks/architecture/dependency-analyzer.js +136 -0
  68. package/dist/gate/checks/architecture/layer-validator.d.ts +75 -0
  69. package/dist/gate/checks/architecture/layer-validator.d.ts.map +1 -0
  70. package/dist/gate/checks/architecture/layer-validator.js +193 -0
  71. package/dist/gate/checks/architecture.check.d.ts +56 -0
  72. package/dist/gate/checks/architecture.check.d.ts.map +1 -0
  73. package/dist/gate/checks/architecture.check.js +394 -0
  74. package/dist/gate/checks/command-safety.check.d.ts +12 -0
  75. package/dist/gate/checks/command-safety.check.d.ts.map +1 -0
  76. package/dist/gate/checks/command-safety.check.js +230 -0
  77. package/dist/gate/checks/coverage.check.d.ts +9 -0
  78. package/dist/gate/checks/coverage.check.d.ts.map +1 -0
  79. package/dist/gate/checks/coverage.check.js +81 -0
  80. package/dist/gate/checks/dependency.check.d.ts +17 -0
  81. package/dist/gate/checks/dependency.check.d.ts.map +1 -0
  82. package/dist/gate/checks/dependency.check.js +342 -0
  83. package/dist/gate/checks/eslint.check.d.ts +14 -0
  84. package/dist/gate/checks/eslint.check.d.ts.map +1 -0
  85. package/dist/gate/checks/eslint.check.js +79 -0
  86. package/dist/gate/checks/policy.check.d.ts +78 -0
  87. package/dist/gate/checks/policy.check.d.ts.map +1 -0
  88. package/dist/gate/checks/policy.check.js +457 -0
  89. package/dist/gate/checks/secret/entropy-detector.d.ts +44 -0
  90. package/dist/gate/checks/secret/entropy-detector.d.ts.map +1 -0
  91. package/dist/gate/checks/secret/entropy-detector.js +76 -0
  92. package/dist/gate/checks/secret/git-scanner.d.ts +36 -0
  93. package/dist/gate/checks/secret/git-scanner.d.ts.map +1 -0
  94. package/dist/gate/checks/secret/git-scanner.js +90 -0
  95. package/dist/gate/checks/secret/secret-patterns.d.ts +42 -0
  96. package/dist/gate/checks/secret/secret-patterns.d.ts.map +1 -0
  97. package/dist/gate/checks/secret/secret-patterns.js +137 -0
  98. package/dist/gate/checks/secret.check.d.ts +56 -0
  99. package/dist/gate/checks/secret.check.d.ts.map +1 -0
  100. package/dist/gate/checks/secret.check.js +245 -0
  101. package/dist/gate/config/command-safety-config.d.ts +5 -0
  102. package/dist/gate/config/command-safety-config.d.ts.map +1 -0
  103. package/dist/gate/config/command-safety-config.js +69 -0
  104. package/dist/gate/config/index.d.ts +2 -0
  105. package/dist/gate/config/index.d.ts.map +1 -0
  106. package/dist/gate/config/index.js +1 -0
  107. package/dist/gate/formatters/command-safety-formatter.d.ts +10 -0
  108. package/dist/gate/formatters/command-safety-formatter.d.ts.map +1 -0
  109. package/dist/gate/formatters/command-safety-formatter.js +64 -0
  110. package/dist/gate/formatters/index.d.ts +2 -0
  111. package/dist/gate/formatters/index.d.ts.map +1 -0
  112. package/dist/gate/formatters/index.js +1 -0
  113. package/dist/gate/gate-config.d.ts +44 -0
  114. package/dist/gate/gate-config.d.ts.map +1 -0
  115. package/dist/gate/gate-config.js +334 -0
  116. package/dist/gate/gate-runner.d.ts +160 -0
  117. package/dist/gate/gate-runner.d.ts.map +1 -0
  118. package/dist/gate/gate-runner.js +531 -0
  119. package/dist/gate/index.d.ts +20 -0
  120. package/dist/gate/index.d.ts.map +1 -0
  121. package/dist/gate/index.js +14 -0
  122. package/dist/gate/parsers/command-parser.d.ts +18 -0
  123. package/dist/gate/parsers/command-parser.d.ts.map +1 -0
  124. package/dist/gate/parsers/command-parser.js +363 -0
  125. package/dist/gate/parsers/index.d.ts +2 -0
  126. package/dist/gate/parsers/index.d.ts.map +1 -0
  127. package/dist/gate/parsers/index.js +1 -0
  128. package/dist/gate/policy/index.d.ts +12 -0
  129. package/dist/gate/policy/index.d.ts.map +1 -0
  130. package/dist/gate/policy/index.js +10 -0
  131. package/dist/gate/rules/default-filesystem-rules.d.ts +3 -0
  132. package/dist/gate/rules/default-filesystem-rules.d.ts.map +1 -0
  133. package/dist/gate/rules/default-filesystem-rules.js +201 -0
  134. package/dist/gate/rules/default-git-rules.d.ts +3 -0
  135. package/dist/gate/rules/default-git-rules.d.ts.map +1 -0
  136. package/dist/gate/rules/default-git-rules.js +192 -0
  137. package/dist/gate/rules/index.d.ts +5 -0
  138. package/dist/gate/rules/index.d.ts.map +1 -0
  139. package/dist/gate/rules/index.js +3 -0
  140. package/dist/gate/rules/rule-matcher.d.ts +27 -0
  141. package/dist/gate/rules/rule-matcher.d.ts.map +1 -0
  142. package/dist/gate/rules/rule-matcher.js +228 -0
  143. package/dist/gate/rules/types.d.ts +250 -0
  144. package/dist/gate/rules/types.d.ts.map +1 -0
  145. package/dist/gate/rules/types.js +1 -0
  146. package/dist/index.d.ts +19 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +35 -0
  149. package/dist/types/gate.types.d.ts +42 -0
  150. package/dist/types/gate.types.d.ts.map +1 -0
  151. package/dist/types/gate.types.js +94 -0
  152. package/dist/watch/debouncer.d.ts +90 -0
  153. package/dist/watch/debouncer.d.ts.map +1 -0
  154. package/dist/watch/debouncer.js +135 -0
  155. package/dist/watch/file-watcher.d.ts +73 -0
  156. package/dist/watch/file-watcher.d.ts.map +1 -0
  157. package/dist/watch/file-watcher.js +121 -0
  158. package/dist/watch/git-status.d.ts +98 -0
  159. package/dist/watch/git-status.d.ts.map +1 -0
  160. package/dist/watch/git-status.js +266 -0
  161. package/dist/watch/index.d.ts +16 -0
  162. package/dist/watch/index.d.ts.map +1 -0
  163. package/dist/watch/index.js +15 -0
  164. package/dist/watch/orchestrator.d.ts +113 -0
  165. package/dist/watch/orchestrator.d.ts.map +1 -0
  166. package/dist/watch/orchestrator.js +409 -0
  167. package/dist/watch/types.d.ts +190 -0
  168. package/dist/watch/types.d.ts.map +1 -0
  169. package/dist/watch/types.js +76 -0
  170. package/package.json +60 -0
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Constraint Collector
3
+ *
4
+ * Aggregates constraints from architecture baselines, anti-pattern catalogues,
5
+ * and project configuration into a single exportable data structure.
6
+ *
7
+ * This module provides the foundation for exporting constraints in various
8
+ * formats (llms.txt, MCP resources, prompt fragments) for AI tool consumption.
9
+ *
10
+ * @module export/constraint-collector
11
+ */
12
+ /**
13
+ * Architecture boundary constraint
14
+ */
15
+ export interface BoundaryConstraint {
16
+ /** Human-readable name */
17
+ name: string;
18
+ /** Source layer */
19
+ from: string;
20
+ /** Target layer */
21
+ to: string;
22
+ /** Violation message */
23
+ message: string;
24
+ /** Severity level */
25
+ severity: 'error' | 'warning' | 'info';
26
+ }
27
+ /**
28
+ * Layer definition constraint
29
+ */
30
+ export interface LayerConstraint {
31
+ /** Layer name */
32
+ name: string;
33
+ /** Glob patterns matching files in this layer */
34
+ patterns: string[];
35
+ /** Layers this layer can depend on */
36
+ dependsOn: string[];
37
+ /** Human-readable description */
38
+ description?: string;
39
+ }
40
+ /**
41
+ * Anti-pattern constraint
42
+ */
43
+ export interface AntiPatternConstraint {
44
+ /** Pattern ID (e.g., AP-001) */
45
+ id: string;
46
+ /** Pattern name */
47
+ name: string;
48
+ /** Pattern category */
49
+ category: string;
50
+ /** Why this pattern is problematic */
51
+ explanation: string;
52
+ /** What to do instead */
53
+ suggestion: string;
54
+ /** Default severity */
55
+ severity: 'error' | 'warning' | 'info';
56
+ /** Whether enabled by default */
57
+ enabled: boolean;
58
+ }
59
+ /**
60
+ * Project convention constraint
61
+ */
62
+ export interface ConventionConstraint {
63
+ /** Convention category */
64
+ category: string;
65
+ /** Human-readable description */
66
+ description: string;
67
+ /** Examples */
68
+ examples?: string[];
69
+ }
70
+ /**
71
+ * Active suppression policy constraint
72
+ */
73
+ export interface SuppressionConstraint {
74
+ /** Pattern ID being suppressed (e.g., AP-001) */
75
+ patternId: string;
76
+ /** Relative file path */
77
+ file: string;
78
+ /** Suppression scope */
79
+ scope: string;
80
+ /** Human-provided reason */
81
+ reason: string;
82
+ /** Expiry date (ISO) for time-boxed suppressions */
83
+ expiresAt?: string;
84
+ }
85
+ /**
86
+ * Aggregated constraints from all sources
87
+ */
88
+ export interface Constraints {
89
+ /** Architecture boundaries */
90
+ boundaries: BoundaryConstraint[];
91
+ /** Layer definitions */
92
+ layers: LayerConstraint[];
93
+ /** Anti-pattern rules */
94
+ antiPatterns: AntiPatternConstraint[];
95
+ /** Project conventions */
96
+ conventions: ConventionConstraint[];
97
+ /** Active suppression policies */
98
+ suppressions: SuppressionConstraint[];
99
+ /** Metadata */
100
+ metadata: {
101
+ /** When constraints were collected */
102
+ collectedAt: string;
103
+ /** Workspace root */
104
+ workspaceRoot: string;
105
+ /** Whether architecture baseline exists */
106
+ hasBaseline: boolean;
107
+ };
108
+ }
109
+ /**
110
+ * Configuration for constraint collection
111
+ */
112
+ export interface ConstraintCollectorConfig {
113
+ /** Workspace root directory */
114
+ workspaceRoot: string;
115
+ /** Include opt-in anti-patterns */
116
+ includeOptInPatterns?: boolean;
117
+ /** Include disabled patterns */
118
+ includeDisabledPatterns?: boolean;
119
+ }
120
+ /**
121
+ * Collects and aggregates constraints from various sources
122
+ */
123
+ export declare class ConstraintCollector {
124
+ private readonly config;
125
+ constructor(config: ConstraintCollectorConfig);
126
+ /**
127
+ * Collect all constraints
128
+ */
129
+ collect(): Promise<Constraints>;
130
+ /**
131
+ * Collect architecture boundaries
132
+ */
133
+ private collectBoundaries;
134
+ /**
135
+ * Collect layer definitions
136
+ */
137
+ private collectLayers;
138
+ /**
139
+ * Collect anti-pattern rules
140
+ */
141
+ private collectAntiPatterns;
142
+ /**
143
+ * Collect active suppression policies from the suppression store
144
+ */
145
+ private collectSuppressions;
146
+ /**
147
+ * Collect project conventions
148
+ *
149
+ * These are static conventions for the Anvil project itself.
150
+ * In a more generic system, these could be loaded from configuration.
151
+ */
152
+ private collectConventions;
153
+ }
154
+ /**
155
+ * Collect constraints with default configuration
156
+ *
157
+ * @param workspaceRoot - Workspace root directory
158
+ * @returns Aggregated constraints
159
+ */
160
+ export declare function collectConstraints(workspaceRoot: string): Promise<Constraints>;
161
+ /**
162
+ * Check if any constraints exist
163
+ *
164
+ * @param constraints - Constraints to check
165
+ * @returns true if any constraints exist
166
+ */
167
+ export declare function hasAnyConstraints(constraints: Constraints): boolean;
168
+ /**
169
+ * Count total constraints
170
+ *
171
+ * @param constraints - Constraints to count
172
+ * @returns Total number of constraints
173
+ */
174
+ export declare function countConstraints(constraints: Constraints): number;
175
+ //# sourceMappingURL=constraint-collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraint-collector.d.ts","sourceRoot":"","sources":["../../src/export/constraint-collector.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Constraint Collector
3
+ *
4
+ * Aggregates constraints from architecture baselines, anti-pattern catalogues,
5
+ * and project configuration into a single exportable data structure.
6
+ *
7
+ * This module provides the foundation for exporting constraints in various
8
+ * formats (llms.txt, MCP resources, prompt fragments) for AI tool consumption.
9
+ *
10
+ * @module export/constraint-collector
11
+ */
12
+ import { PATTERNS } from '@eddacraft/anvil-core/antipattern';
13
+ import { loadBaseline } from '@eddacraft/anvil-core/architecture';
14
+ import { SuppressionStore } from '@eddacraft/anvil-core/suppression';
15
+ import { join } from 'node:path';
16
+ /**
17
+ * Collects and aggregates constraints from various sources
18
+ */
19
+ export class ConstraintCollector {
20
+ config;
21
+ constructor(config) {
22
+ this.config = {
23
+ includeOptInPatterns: false,
24
+ includeDisabledPatterns: false,
25
+ ...config,
26
+ };
27
+ }
28
+ /**
29
+ * Collect all constraints
30
+ */
31
+ async collect() {
32
+ const baseline = loadBaseline(this.config.workspaceRoot);
33
+ const hasBaseline = baseline !== null;
34
+ return {
35
+ boundaries: this.collectBoundaries(baseline),
36
+ layers: this.collectLayers(baseline),
37
+ antiPatterns: this.collectAntiPatterns(),
38
+ conventions: this.collectConventions(),
39
+ suppressions: await this.collectSuppressions(),
40
+ metadata: {
41
+ collectedAt: new Date().toISOString(),
42
+ workspaceRoot: this.config.workspaceRoot,
43
+ hasBaseline,
44
+ },
45
+ };
46
+ }
47
+ /**
48
+ * Collect architecture boundaries
49
+ */
50
+ collectBoundaries(baseline) {
51
+ if (!baseline) {
52
+ return [];
53
+ }
54
+ return baseline.boundaries.map((boundary) => ({
55
+ name: boundary.name,
56
+ from: boundary.from,
57
+ to: boundary.to,
58
+ message: boundary.message,
59
+ severity: boundary.severity,
60
+ }));
61
+ }
62
+ /**
63
+ * Collect layer definitions
64
+ */
65
+ collectLayers(baseline) {
66
+ if (!baseline) {
67
+ return [];
68
+ }
69
+ return Object.entries(baseline.layers).map(([name, layer]) => ({
70
+ name,
71
+ patterns: layer.patterns,
72
+ dependsOn: layer.depends_on,
73
+ description: layer.description,
74
+ }));
75
+ }
76
+ /**
77
+ * Collect anti-pattern rules
78
+ */
79
+ collectAntiPatterns() {
80
+ let patterns = PATTERNS.slice();
81
+ // Filter based on configuration
82
+ if (!this.config.includeDisabledPatterns) {
83
+ patterns = patterns.filter((p) => p.enabled);
84
+ }
85
+ if (!this.config.includeOptInPatterns) {
86
+ patterns = patterns.filter((p) => !p.optIn);
87
+ }
88
+ return patterns.map((pattern) => ({
89
+ id: pattern.id,
90
+ name: pattern.name,
91
+ category: pattern.category,
92
+ explanation: pattern.explanation,
93
+ suggestion: pattern.suggestion,
94
+ severity: pattern.severity,
95
+ enabled: pattern.enabled,
96
+ }));
97
+ }
98
+ /**
99
+ * Collect active suppression policies from the suppression store
100
+ */
101
+ async collectSuppressions() {
102
+ try {
103
+ const anvilDir = join(this.config.workspaceRoot, '.anvil');
104
+ const store = new SuppressionStore(anvilDir);
105
+ await store.load();
106
+ const now = new Date();
107
+ const all = store.getAll();
108
+ // Filter out expired suppressions
109
+ const active = all.filter((record) => {
110
+ if (!record.expires_at)
111
+ return true;
112
+ return new Date(record.expires_at) >= now;
113
+ });
114
+ return active.map((record) => ({
115
+ patternId: record.pattern_id,
116
+ file: record.file,
117
+ scope: record.scope,
118
+ reason: record.reason,
119
+ expiresAt: record.expires_at,
120
+ }));
121
+ }
122
+ catch {
123
+ return [];
124
+ }
125
+ }
126
+ /**
127
+ * Collect project conventions
128
+ *
129
+ * These are static conventions for the Anvil project itself.
130
+ * In a more generic system, these could be loaded from configuration.
131
+ */
132
+ collectConventions() {
133
+ return [
134
+ {
135
+ category: 'spelling',
136
+ description: 'Use UK English spelling',
137
+ examples: ['organised (not organized)', 'behaviour (not behavior)', 'colour (not color)'],
138
+ },
139
+ {
140
+ category: 'imports',
141
+ description: 'ESM imports require .js extensions',
142
+ examples: ["import { foo } from './bar.js'", "NOT: import { foo } from './bar'"],
143
+ },
144
+ {
145
+ category: 'schemas',
146
+ description: 'Zod schemas as source of truth for types',
147
+ examples: [
148
+ 'export const FooSchema = z.object({ ... })',
149
+ 'export type Foo = z.infer<typeof FooSchema>',
150
+ ],
151
+ },
152
+ {
153
+ category: 'naming',
154
+ description: 'Kebab-case for file names',
155
+ examples: ['gate-runner.ts', 'format-detection.ts'],
156
+ },
157
+ {
158
+ category: 'type-safety',
159
+ description: 'No type assertions without runtime validation',
160
+ examples: ['Use Zod parse, not "as" casts', 'Avoid @ts-ignore and @ts-expect-error'],
161
+ },
162
+ ];
163
+ }
164
+ }
165
+ // =============================================================================
166
+ // Convenience Functions
167
+ // =============================================================================
168
+ /**
169
+ * Collect constraints with default configuration
170
+ *
171
+ * @param workspaceRoot - Workspace root directory
172
+ * @returns Aggregated constraints
173
+ */
174
+ export async function collectConstraints(workspaceRoot) {
175
+ const collector = new ConstraintCollector({ workspaceRoot });
176
+ return collector.collect();
177
+ }
178
+ /**
179
+ * Check if any constraints exist
180
+ *
181
+ * @param constraints - Constraints to check
182
+ * @returns true if any constraints exist
183
+ */
184
+ export function hasAnyConstraints(constraints) {
185
+ return (constraints.boundaries.length > 0 ||
186
+ constraints.layers.length > 0 ||
187
+ constraints.antiPatterns.length > 0 ||
188
+ constraints.conventions.length > 0 ||
189
+ constraints.suppressions.length > 0);
190
+ }
191
+ /**
192
+ * Count total constraints
193
+ *
194
+ * @param constraints - Constraints to count
195
+ * @returns Total number of constraints
196
+ */
197
+ export function countConstraints(constraints) {
198
+ return (constraints.boundaries.length +
199
+ constraints.layers.length +
200
+ constraints.antiPatterns.length +
201
+ constraints.conventions.length +
202
+ constraints.suppressions.length);
203
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * llms.txt Formatter
3
+ *
4
+ * Formats Anvil constraints as llms.txt markdown for AI tool consumption.
5
+ *
6
+ * llms.txt is an emerging community standard for providing AI-readable
7
+ * documentation and constraints. See: https://mintlify.com/blog/simplifying-docs-with-llms-txt
8
+ *
9
+ * @module export/formatters/llms-txt-formatter
10
+ */
11
+ import type { Constraints } from '../constraint-collector.js';
12
+ /**
13
+ * Configuration for llms.txt formatting
14
+ */
15
+ export interface LlmsTxtFormatterOptions {
16
+ /** Include metadata header */
17
+ includeMetadata?: boolean;
18
+ /** Include architecture boundaries section */
19
+ includeBoundaries?: boolean;
20
+ /** Include anti-patterns section */
21
+ includeAntiPatterns?: boolean;
22
+ /** Include conventions section */
23
+ includeConventions?: boolean;
24
+ /** Include layer definitions section */
25
+ includeLayers?: boolean;
26
+ /** Include active suppressions section */
27
+ includeSuppressions?: boolean;
28
+ }
29
+ /**
30
+ * Formats constraints as llms.txt markdown
31
+ */
32
+ export declare class LlmsTxtFormatter {
33
+ private readonly options;
34
+ constructor(options?: LlmsTxtFormatterOptions);
35
+ /**
36
+ * Format constraints as llms.txt markdown
37
+ *
38
+ * @param constraints - Constraints to format
39
+ * @returns llms.txt markdown string
40
+ */
41
+ format(constraints: Constraints): string;
42
+ /**
43
+ * Format metadata section
44
+ */
45
+ private formatMetadata;
46
+ /**
47
+ * Format architecture boundaries section
48
+ */
49
+ private formatBoundaries;
50
+ /**
51
+ * Format layer definitions section
52
+ */
53
+ private formatLayers;
54
+ /**
55
+ * Format anti-patterns section
56
+ */
57
+ private formatAntiPatterns;
58
+ /**
59
+ * Format conventions section
60
+ */
61
+ private formatConventions;
62
+ /**
63
+ * Format active suppressions section
64
+ */
65
+ private formatSuppressions;
66
+ /**
67
+ * Get emoji for severity level
68
+ */
69
+ private getSeverityEmoji;
70
+ /**
71
+ * Format category name for display
72
+ */
73
+ private formatCategoryName;
74
+ }
75
+ /**
76
+ * Format constraints as llms.txt with default options
77
+ *
78
+ * @param constraints - Constraints to format
79
+ * @returns llms.txt markdown string
80
+ */
81
+ export declare function formatAsLlmsTxt(constraints: Constraints): string;
82
+ /**
83
+ * Format constraints as llms.txt without metadata
84
+ *
85
+ * @param constraints - Constraints to format
86
+ * @returns llms.txt markdown string
87
+ */
88
+ export declare function formatAsLlmsTxtWithoutMetadata(constraints: Constraints): string;
89
+ //# sourceMappingURL=llms-txt-formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llms-txt-formatter.d.ts","sourceRoot":"","sources":["../../../src/export/formatters/llms-txt-formatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAM9D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8BAA8B;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8CAA8C;IAC9C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oCAAoC;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kCAAkC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wCAAwC;IACxC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0CAA0C;IAC1C,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAMD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;gBAEhD,OAAO,GAAE,uBAA4B;IAYjD;;;;;OAKG;IACH,MAAM,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM;IAuCxC;;OAEG;IACH,OAAO,CAAC,cAAc;IAWtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmCpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiC1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAuBzB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAqC1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAM3B;AAMD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAGhE;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAG/E"}