@ipation/specbridge 0.2.1

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.
@@ -0,0 +1,1802 @@
1
+ import { z } from 'zod';
2
+ import { SourceFile, Project } from 'ts-morph';
3
+ import { Document } from 'yaml';
4
+ export { minimatch } from 'minimatch';
5
+
6
+ /**
7
+ * Core type definitions for SpecBridge
8
+ */
9
+ type DecisionStatus = 'draft' | 'active' | 'deprecated' | 'superseded';
10
+ type ConstraintType = 'invariant' | 'convention' | 'guideline';
11
+ type Severity = 'critical' | 'high' | 'medium' | 'low';
12
+ type VerificationFrequency = 'commit' | 'pr' | 'daily' | 'weekly';
13
+ type VerificationLevel = 'commit' | 'pr' | 'full';
14
+ /**
15
+ * Decision metadata
16
+ */
17
+ interface DecisionMetadata {
18
+ id: string;
19
+ title: string;
20
+ status: DecisionStatus;
21
+ owners: string[];
22
+ createdAt?: string;
23
+ updatedAt?: string;
24
+ supersededBy?: string;
25
+ tags?: string[];
26
+ }
27
+ /**
28
+ * Core decision content
29
+ */
30
+ interface DecisionContent {
31
+ summary: string;
32
+ rationale: string;
33
+ context?: string;
34
+ consequences?: string[];
35
+ }
36
+ /**
37
+ * A single constraint within a decision
38
+ */
39
+ interface Constraint {
40
+ id: string;
41
+ type: ConstraintType;
42
+ rule: string;
43
+ severity: Severity;
44
+ scope: string;
45
+ verifier?: string;
46
+ autofix?: boolean;
47
+ exceptions?: ConstraintException[];
48
+ }
49
+ /**
50
+ * Exception to a constraint
51
+ */
52
+ interface ConstraintException {
53
+ pattern: string;
54
+ reason: string;
55
+ approvedBy?: string;
56
+ expiresAt?: string;
57
+ }
58
+ /**
59
+ * Automated verification configuration
60
+ */
61
+ interface VerificationConfig {
62
+ check: string;
63
+ target: string;
64
+ frequency: VerificationFrequency;
65
+ timeout?: number;
66
+ }
67
+ /**
68
+ * Complete decision document
69
+ */
70
+ interface Decision {
71
+ kind: 'Decision';
72
+ metadata: DecisionMetadata;
73
+ decision: DecisionContent;
74
+ constraints: Constraint[];
75
+ verification?: {
76
+ automated?: VerificationConfig[];
77
+ };
78
+ links?: {
79
+ related?: string[];
80
+ supersedes?: string[];
81
+ references?: string[];
82
+ };
83
+ }
84
+ /**
85
+ * A violation of a constraint
86
+ */
87
+ interface Violation {
88
+ decisionId: string;
89
+ constraintId: string;
90
+ type: ConstraintType;
91
+ severity: Severity;
92
+ message: string;
93
+ file: string;
94
+ line?: number;
95
+ column?: number;
96
+ endLine?: number;
97
+ endColumn?: number;
98
+ suggestion?: string;
99
+ autofix?: ViolationFix;
100
+ }
101
+ /**
102
+ * Auto-fix for a violation
103
+ */
104
+ interface ViolationFix {
105
+ description: string;
106
+ patch: string;
107
+ }
108
+ /**
109
+ * A pattern detected during inference
110
+ */
111
+ interface Pattern {
112
+ id: string;
113
+ name: string;
114
+ description: string;
115
+ confidence: number;
116
+ occurrences: number;
117
+ examples: PatternExample[];
118
+ suggestedConstraint?: Partial<Constraint>;
119
+ analyzer: string;
120
+ }
121
+ /**
122
+ * Example of a detected pattern
123
+ */
124
+ interface PatternExample {
125
+ file: string;
126
+ line: number;
127
+ snippet: string;
128
+ }
129
+ /**
130
+ * SpecBridge project configuration
131
+ */
132
+ interface SpecBridgeConfig {
133
+ version: string;
134
+ project: {
135
+ name: string;
136
+ sourceRoots: string[];
137
+ exclude?: string[];
138
+ };
139
+ inference?: {
140
+ minConfidence?: number;
141
+ analyzers?: string[];
142
+ };
143
+ verification?: {
144
+ levels?: {
145
+ commit?: LevelConfig;
146
+ pr?: LevelConfig;
147
+ full?: LevelConfig;
148
+ };
149
+ };
150
+ agent?: {
151
+ format?: 'markdown' | 'json' | 'mcp';
152
+ includeRationale?: boolean;
153
+ };
154
+ }
155
+ /**
156
+ * Configuration for a verification level
157
+ */
158
+ interface LevelConfig {
159
+ timeout?: number;
160
+ severity?: Severity[];
161
+ }
162
+ /**
163
+ * Result of a verification run
164
+ */
165
+ interface VerificationResult {
166
+ success: boolean;
167
+ violations: Violation[];
168
+ checked: number;
169
+ passed: number;
170
+ failed: number;
171
+ skipped: number;
172
+ duration: number;
173
+ }
174
+ /**
175
+ * Result of an inference run
176
+ */
177
+ interface InferenceResult {
178
+ patterns: Pattern[];
179
+ analyzersRun: string[];
180
+ filesScanned: number;
181
+ duration: number;
182
+ }
183
+ /**
184
+ * Compliance report
185
+ */
186
+ interface ComplianceReport {
187
+ timestamp: string;
188
+ project: string;
189
+ summary: {
190
+ totalDecisions: number;
191
+ activeDecisions: number;
192
+ totalConstraints: number;
193
+ violations: {
194
+ critical: number;
195
+ high: number;
196
+ medium: number;
197
+ low: number;
198
+ };
199
+ compliance: number;
200
+ };
201
+ byDecision: DecisionCompliance[];
202
+ recentTrend?: TrendData[];
203
+ }
204
+ /**
205
+ * Compliance data for a single decision
206
+ */
207
+ interface DecisionCompliance {
208
+ decisionId: string;
209
+ title: string;
210
+ status: DecisionStatus;
211
+ constraints: number;
212
+ violations: number;
213
+ compliance: number;
214
+ }
215
+ /**
216
+ * Trend data point
217
+ */
218
+ interface TrendData {
219
+ date: string;
220
+ compliance: number;
221
+ violations: number;
222
+ }
223
+ /**
224
+ * Agent context for code generation
225
+ */
226
+ interface AgentContext {
227
+ file: string;
228
+ applicableDecisions: ApplicableDecision[];
229
+ generatedAt: string;
230
+ }
231
+ /**
232
+ * Decision applicable to a specific context
233
+ */
234
+ interface ApplicableDecision {
235
+ id: string;
236
+ title: string;
237
+ summary: string;
238
+ constraints: ApplicableConstraint[];
239
+ }
240
+ /**
241
+ * Constraint applicable to a specific context
242
+ */
243
+ interface ApplicableConstraint {
244
+ id: string;
245
+ type: ConstraintType;
246
+ rule: string;
247
+ severity: Severity;
248
+ }
249
+ /**
250
+ * Impact analysis result
251
+ */
252
+ interface ImpactAnalysis {
253
+ decision: string;
254
+ change: 'created' | 'modified' | 'deprecated';
255
+ affectedFiles: AffectedFile[];
256
+ estimatedEffort: 'low' | 'medium' | 'high';
257
+ migrationSteps?: MigrationStep[];
258
+ }
259
+ /**
260
+ * File affected by a decision change
261
+ */
262
+ interface AffectedFile {
263
+ path: string;
264
+ violations: number;
265
+ autoFixable: number;
266
+ }
267
+ /**
268
+ * Step in a migration plan
269
+ */
270
+ interface MigrationStep {
271
+ order: number;
272
+ description: string;
273
+ files: string[];
274
+ automated: boolean;
275
+ }
276
+
277
+ /**
278
+ * Zod schemas for decision YAML validation
279
+ */
280
+
281
+ declare const DecisionStatusSchema: z.ZodEnum<["draft", "active", "deprecated", "superseded"]>;
282
+ declare const ConstraintTypeSchema: z.ZodEnum<["invariant", "convention", "guideline"]>;
283
+ declare const SeveritySchema: z.ZodEnum<["critical", "high", "medium", "low"]>;
284
+ declare const VerificationFrequencySchema: z.ZodEnum<["commit", "pr", "daily", "weekly"]>;
285
+ declare const DecisionMetadataSchema: z.ZodObject<{
286
+ id: z.ZodString;
287
+ title: z.ZodString;
288
+ status: z.ZodEnum<["draft", "active", "deprecated", "superseded"]>;
289
+ owners: z.ZodArray<z.ZodString, "many">;
290
+ createdAt: z.ZodOptional<z.ZodString>;
291
+ updatedAt: z.ZodOptional<z.ZodString>;
292
+ supersededBy: z.ZodOptional<z.ZodString>;
293
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
294
+ }, "strip", z.ZodTypeAny, {
295
+ id: string;
296
+ title: string;
297
+ status: "draft" | "active" | "deprecated" | "superseded";
298
+ owners: string[];
299
+ createdAt?: string | undefined;
300
+ updatedAt?: string | undefined;
301
+ supersededBy?: string | undefined;
302
+ tags?: string[] | undefined;
303
+ }, {
304
+ id: string;
305
+ title: string;
306
+ status: "draft" | "active" | "deprecated" | "superseded";
307
+ owners: string[];
308
+ createdAt?: string | undefined;
309
+ updatedAt?: string | undefined;
310
+ supersededBy?: string | undefined;
311
+ tags?: string[] | undefined;
312
+ }>;
313
+ declare const DecisionContentSchema: z.ZodObject<{
314
+ summary: z.ZodString;
315
+ rationale: z.ZodString;
316
+ context: z.ZodOptional<z.ZodString>;
317
+ consequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
318
+ }, "strip", z.ZodTypeAny, {
319
+ summary: string;
320
+ rationale: string;
321
+ context?: string | undefined;
322
+ consequences?: string[] | undefined;
323
+ }, {
324
+ summary: string;
325
+ rationale: string;
326
+ context?: string | undefined;
327
+ consequences?: string[] | undefined;
328
+ }>;
329
+ declare const ConstraintExceptionSchema: z.ZodObject<{
330
+ pattern: z.ZodString;
331
+ reason: z.ZodString;
332
+ approvedBy: z.ZodOptional<z.ZodString>;
333
+ expiresAt: z.ZodOptional<z.ZodString>;
334
+ }, "strip", z.ZodTypeAny, {
335
+ pattern: string;
336
+ reason: string;
337
+ approvedBy?: string | undefined;
338
+ expiresAt?: string | undefined;
339
+ }, {
340
+ pattern: string;
341
+ reason: string;
342
+ approvedBy?: string | undefined;
343
+ expiresAt?: string | undefined;
344
+ }>;
345
+ declare const ConstraintSchema: z.ZodObject<{
346
+ id: z.ZodString;
347
+ type: z.ZodEnum<["invariant", "convention", "guideline"]>;
348
+ rule: z.ZodString;
349
+ severity: z.ZodEnum<["critical", "high", "medium", "low"]>;
350
+ scope: z.ZodString;
351
+ verifier: z.ZodOptional<z.ZodString>;
352
+ autofix: z.ZodOptional<z.ZodBoolean>;
353
+ exceptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
354
+ pattern: z.ZodString;
355
+ reason: z.ZodString;
356
+ approvedBy: z.ZodOptional<z.ZodString>;
357
+ expiresAt: z.ZodOptional<z.ZodString>;
358
+ }, "strip", z.ZodTypeAny, {
359
+ pattern: string;
360
+ reason: string;
361
+ approvedBy?: string | undefined;
362
+ expiresAt?: string | undefined;
363
+ }, {
364
+ pattern: string;
365
+ reason: string;
366
+ approvedBy?: string | undefined;
367
+ expiresAt?: string | undefined;
368
+ }>, "many">>;
369
+ }, "strip", z.ZodTypeAny, {
370
+ id: string;
371
+ type: "invariant" | "convention" | "guideline";
372
+ rule: string;
373
+ severity: "critical" | "high" | "medium" | "low";
374
+ scope: string;
375
+ verifier?: string | undefined;
376
+ autofix?: boolean | undefined;
377
+ exceptions?: {
378
+ pattern: string;
379
+ reason: string;
380
+ approvedBy?: string | undefined;
381
+ expiresAt?: string | undefined;
382
+ }[] | undefined;
383
+ }, {
384
+ id: string;
385
+ type: "invariant" | "convention" | "guideline";
386
+ rule: string;
387
+ severity: "critical" | "high" | "medium" | "low";
388
+ scope: string;
389
+ verifier?: string | undefined;
390
+ autofix?: boolean | undefined;
391
+ exceptions?: {
392
+ pattern: string;
393
+ reason: string;
394
+ approvedBy?: string | undefined;
395
+ expiresAt?: string | undefined;
396
+ }[] | undefined;
397
+ }>;
398
+ declare const VerificationConfigSchema: z.ZodObject<{
399
+ check: z.ZodString;
400
+ target: z.ZodString;
401
+ frequency: z.ZodEnum<["commit", "pr", "daily", "weekly"]>;
402
+ timeout: z.ZodOptional<z.ZodNumber>;
403
+ }, "strip", z.ZodTypeAny, {
404
+ check: string;
405
+ target: string;
406
+ frequency: "commit" | "pr" | "daily" | "weekly";
407
+ timeout?: number | undefined;
408
+ }, {
409
+ check: string;
410
+ target: string;
411
+ frequency: "commit" | "pr" | "daily" | "weekly";
412
+ timeout?: number | undefined;
413
+ }>;
414
+ declare const LinksSchema: z.ZodObject<{
415
+ related: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
416
+ supersedes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
417
+ references: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
418
+ }, "strip", z.ZodTypeAny, {
419
+ related?: string[] | undefined;
420
+ supersedes?: string[] | undefined;
421
+ references?: string[] | undefined;
422
+ }, {
423
+ related?: string[] | undefined;
424
+ supersedes?: string[] | undefined;
425
+ references?: string[] | undefined;
426
+ }>;
427
+ declare const DecisionSchema: z.ZodObject<{
428
+ kind: z.ZodLiteral<"Decision">;
429
+ metadata: z.ZodObject<{
430
+ id: z.ZodString;
431
+ title: z.ZodString;
432
+ status: z.ZodEnum<["draft", "active", "deprecated", "superseded"]>;
433
+ owners: z.ZodArray<z.ZodString, "many">;
434
+ createdAt: z.ZodOptional<z.ZodString>;
435
+ updatedAt: z.ZodOptional<z.ZodString>;
436
+ supersededBy: z.ZodOptional<z.ZodString>;
437
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
438
+ }, "strip", z.ZodTypeAny, {
439
+ id: string;
440
+ title: string;
441
+ status: "draft" | "active" | "deprecated" | "superseded";
442
+ owners: string[];
443
+ createdAt?: string | undefined;
444
+ updatedAt?: string | undefined;
445
+ supersededBy?: string | undefined;
446
+ tags?: string[] | undefined;
447
+ }, {
448
+ id: string;
449
+ title: string;
450
+ status: "draft" | "active" | "deprecated" | "superseded";
451
+ owners: string[];
452
+ createdAt?: string | undefined;
453
+ updatedAt?: string | undefined;
454
+ supersededBy?: string | undefined;
455
+ tags?: string[] | undefined;
456
+ }>;
457
+ decision: z.ZodObject<{
458
+ summary: z.ZodString;
459
+ rationale: z.ZodString;
460
+ context: z.ZodOptional<z.ZodString>;
461
+ consequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
462
+ }, "strip", z.ZodTypeAny, {
463
+ summary: string;
464
+ rationale: string;
465
+ context?: string | undefined;
466
+ consequences?: string[] | undefined;
467
+ }, {
468
+ summary: string;
469
+ rationale: string;
470
+ context?: string | undefined;
471
+ consequences?: string[] | undefined;
472
+ }>;
473
+ constraints: z.ZodArray<z.ZodObject<{
474
+ id: z.ZodString;
475
+ type: z.ZodEnum<["invariant", "convention", "guideline"]>;
476
+ rule: z.ZodString;
477
+ severity: z.ZodEnum<["critical", "high", "medium", "low"]>;
478
+ scope: z.ZodString;
479
+ verifier: z.ZodOptional<z.ZodString>;
480
+ autofix: z.ZodOptional<z.ZodBoolean>;
481
+ exceptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
482
+ pattern: z.ZodString;
483
+ reason: z.ZodString;
484
+ approvedBy: z.ZodOptional<z.ZodString>;
485
+ expiresAt: z.ZodOptional<z.ZodString>;
486
+ }, "strip", z.ZodTypeAny, {
487
+ pattern: string;
488
+ reason: string;
489
+ approvedBy?: string | undefined;
490
+ expiresAt?: string | undefined;
491
+ }, {
492
+ pattern: string;
493
+ reason: string;
494
+ approvedBy?: string | undefined;
495
+ expiresAt?: string | undefined;
496
+ }>, "many">>;
497
+ }, "strip", z.ZodTypeAny, {
498
+ id: string;
499
+ type: "invariant" | "convention" | "guideline";
500
+ rule: string;
501
+ severity: "critical" | "high" | "medium" | "low";
502
+ scope: string;
503
+ verifier?: string | undefined;
504
+ autofix?: boolean | undefined;
505
+ exceptions?: {
506
+ pattern: string;
507
+ reason: string;
508
+ approvedBy?: string | undefined;
509
+ expiresAt?: string | undefined;
510
+ }[] | undefined;
511
+ }, {
512
+ id: string;
513
+ type: "invariant" | "convention" | "guideline";
514
+ rule: string;
515
+ severity: "critical" | "high" | "medium" | "low";
516
+ scope: string;
517
+ verifier?: string | undefined;
518
+ autofix?: boolean | undefined;
519
+ exceptions?: {
520
+ pattern: string;
521
+ reason: string;
522
+ approvedBy?: string | undefined;
523
+ expiresAt?: string | undefined;
524
+ }[] | undefined;
525
+ }>, "many">;
526
+ verification: z.ZodOptional<z.ZodObject<{
527
+ automated: z.ZodOptional<z.ZodArray<z.ZodObject<{
528
+ check: z.ZodString;
529
+ target: z.ZodString;
530
+ frequency: z.ZodEnum<["commit", "pr", "daily", "weekly"]>;
531
+ timeout: z.ZodOptional<z.ZodNumber>;
532
+ }, "strip", z.ZodTypeAny, {
533
+ check: string;
534
+ target: string;
535
+ frequency: "commit" | "pr" | "daily" | "weekly";
536
+ timeout?: number | undefined;
537
+ }, {
538
+ check: string;
539
+ target: string;
540
+ frequency: "commit" | "pr" | "daily" | "weekly";
541
+ timeout?: number | undefined;
542
+ }>, "many">>;
543
+ }, "strip", z.ZodTypeAny, {
544
+ automated?: {
545
+ check: string;
546
+ target: string;
547
+ frequency: "commit" | "pr" | "daily" | "weekly";
548
+ timeout?: number | undefined;
549
+ }[] | undefined;
550
+ }, {
551
+ automated?: {
552
+ check: string;
553
+ target: string;
554
+ frequency: "commit" | "pr" | "daily" | "weekly";
555
+ timeout?: number | undefined;
556
+ }[] | undefined;
557
+ }>>;
558
+ links: z.ZodOptional<z.ZodObject<{
559
+ related: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
560
+ supersedes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
561
+ references: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
562
+ }, "strip", z.ZodTypeAny, {
563
+ related?: string[] | undefined;
564
+ supersedes?: string[] | undefined;
565
+ references?: string[] | undefined;
566
+ }, {
567
+ related?: string[] | undefined;
568
+ supersedes?: string[] | undefined;
569
+ references?: string[] | undefined;
570
+ }>>;
571
+ }, "strip", z.ZodTypeAny, {
572
+ kind: "Decision";
573
+ metadata: {
574
+ id: string;
575
+ title: string;
576
+ status: "draft" | "active" | "deprecated" | "superseded";
577
+ owners: string[];
578
+ createdAt?: string | undefined;
579
+ updatedAt?: string | undefined;
580
+ supersededBy?: string | undefined;
581
+ tags?: string[] | undefined;
582
+ };
583
+ decision: {
584
+ summary: string;
585
+ rationale: string;
586
+ context?: string | undefined;
587
+ consequences?: string[] | undefined;
588
+ };
589
+ constraints: {
590
+ id: string;
591
+ type: "invariant" | "convention" | "guideline";
592
+ rule: string;
593
+ severity: "critical" | "high" | "medium" | "low";
594
+ scope: string;
595
+ verifier?: string | undefined;
596
+ autofix?: boolean | undefined;
597
+ exceptions?: {
598
+ pattern: string;
599
+ reason: string;
600
+ approvedBy?: string | undefined;
601
+ expiresAt?: string | undefined;
602
+ }[] | undefined;
603
+ }[];
604
+ verification?: {
605
+ automated?: {
606
+ check: string;
607
+ target: string;
608
+ frequency: "commit" | "pr" | "daily" | "weekly";
609
+ timeout?: number | undefined;
610
+ }[] | undefined;
611
+ } | undefined;
612
+ links?: {
613
+ related?: string[] | undefined;
614
+ supersedes?: string[] | undefined;
615
+ references?: string[] | undefined;
616
+ } | undefined;
617
+ }, {
618
+ kind: "Decision";
619
+ metadata: {
620
+ id: string;
621
+ title: string;
622
+ status: "draft" | "active" | "deprecated" | "superseded";
623
+ owners: string[];
624
+ createdAt?: string | undefined;
625
+ updatedAt?: string | undefined;
626
+ supersededBy?: string | undefined;
627
+ tags?: string[] | undefined;
628
+ };
629
+ decision: {
630
+ summary: string;
631
+ rationale: string;
632
+ context?: string | undefined;
633
+ consequences?: string[] | undefined;
634
+ };
635
+ constraints: {
636
+ id: string;
637
+ type: "invariant" | "convention" | "guideline";
638
+ rule: string;
639
+ severity: "critical" | "high" | "medium" | "low";
640
+ scope: string;
641
+ verifier?: string | undefined;
642
+ autofix?: boolean | undefined;
643
+ exceptions?: {
644
+ pattern: string;
645
+ reason: string;
646
+ approvedBy?: string | undefined;
647
+ expiresAt?: string | undefined;
648
+ }[] | undefined;
649
+ }[];
650
+ verification?: {
651
+ automated?: {
652
+ check: string;
653
+ target: string;
654
+ frequency: "commit" | "pr" | "daily" | "weekly";
655
+ timeout?: number | undefined;
656
+ }[] | undefined;
657
+ } | undefined;
658
+ links?: {
659
+ related?: string[] | undefined;
660
+ supersedes?: string[] | undefined;
661
+ references?: string[] | undefined;
662
+ } | undefined;
663
+ }>;
664
+ type DecisionStatusSchema_ = z.infer<typeof DecisionStatusSchema>;
665
+ type ConstraintTypeSchema_ = z.infer<typeof ConstraintTypeSchema>;
666
+ type SeveritySchema_ = z.infer<typeof SeveritySchema>;
667
+ type VerificationFrequencySchema_ = z.infer<typeof VerificationFrequencySchema>;
668
+ type DecisionMetadataSchema_ = z.infer<typeof DecisionMetadataSchema>;
669
+ type DecisionContentSchema_ = z.infer<typeof DecisionContentSchema>;
670
+ type ConstraintExceptionSchema_ = z.infer<typeof ConstraintExceptionSchema>;
671
+ type ConstraintSchema_ = z.infer<typeof ConstraintSchema>;
672
+ type VerificationConfigSchema_ = z.infer<typeof VerificationConfigSchema>;
673
+ type DecisionTypeSchema = z.infer<typeof DecisionSchema>;
674
+ /**
675
+ * Validate a decision document
676
+ */
677
+ declare function validateDecision(data: unknown): {
678
+ success: true;
679
+ data: DecisionTypeSchema;
680
+ } | {
681
+ success: false;
682
+ errors: z.ZodError;
683
+ };
684
+ /**
685
+ * Format Zod errors into human-readable messages
686
+ */
687
+ declare function formatValidationErrors(errors: z.ZodError): string[];
688
+
689
+ /**
690
+ * Zod schemas for SpecBridge configuration
691
+ */
692
+
693
+ declare const SpecBridgeConfigSchema: z.ZodObject<{
694
+ version: z.ZodString;
695
+ project: z.ZodObject<{
696
+ name: z.ZodString;
697
+ sourceRoots: z.ZodArray<z.ZodString, "many">;
698
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
699
+ }, "strip", z.ZodTypeAny, {
700
+ name: string;
701
+ sourceRoots: string[];
702
+ exclude?: string[] | undefined;
703
+ }, {
704
+ name: string;
705
+ sourceRoots: string[];
706
+ exclude?: string[] | undefined;
707
+ }>;
708
+ inference: z.ZodOptional<z.ZodObject<{
709
+ minConfidence: z.ZodOptional<z.ZodNumber>;
710
+ analyzers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
711
+ }, "strip", z.ZodTypeAny, {
712
+ minConfidence?: number | undefined;
713
+ analyzers?: string[] | undefined;
714
+ }, {
715
+ minConfidence?: number | undefined;
716
+ analyzers?: string[] | undefined;
717
+ }>>;
718
+ verification: z.ZodOptional<z.ZodObject<{
719
+ levels: z.ZodOptional<z.ZodObject<{
720
+ commit: z.ZodOptional<z.ZodObject<{
721
+ timeout: z.ZodOptional<z.ZodNumber>;
722
+ severity: z.ZodOptional<z.ZodArray<z.ZodEnum<["critical", "high", "medium", "low"]>, "many">>;
723
+ }, "strip", z.ZodTypeAny, {
724
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
725
+ timeout?: number | undefined;
726
+ }, {
727
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
728
+ timeout?: number | undefined;
729
+ }>>;
730
+ pr: z.ZodOptional<z.ZodObject<{
731
+ timeout: z.ZodOptional<z.ZodNumber>;
732
+ severity: z.ZodOptional<z.ZodArray<z.ZodEnum<["critical", "high", "medium", "low"]>, "many">>;
733
+ }, "strip", z.ZodTypeAny, {
734
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
735
+ timeout?: number | undefined;
736
+ }, {
737
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
738
+ timeout?: number | undefined;
739
+ }>>;
740
+ full: z.ZodOptional<z.ZodObject<{
741
+ timeout: z.ZodOptional<z.ZodNumber>;
742
+ severity: z.ZodOptional<z.ZodArray<z.ZodEnum<["critical", "high", "medium", "low"]>, "many">>;
743
+ }, "strip", z.ZodTypeAny, {
744
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
745
+ timeout?: number | undefined;
746
+ }, {
747
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
748
+ timeout?: number | undefined;
749
+ }>>;
750
+ }, "strip", z.ZodTypeAny, {
751
+ commit?: {
752
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
753
+ timeout?: number | undefined;
754
+ } | undefined;
755
+ pr?: {
756
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
757
+ timeout?: number | undefined;
758
+ } | undefined;
759
+ full?: {
760
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
761
+ timeout?: number | undefined;
762
+ } | undefined;
763
+ }, {
764
+ commit?: {
765
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
766
+ timeout?: number | undefined;
767
+ } | undefined;
768
+ pr?: {
769
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
770
+ timeout?: number | undefined;
771
+ } | undefined;
772
+ full?: {
773
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
774
+ timeout?: number | undefined;
775
+ } | undefined;
776
+ }>>;
777
+ }, "strip", z.ZodTypeAny, {
778
+ levels?: {
779
+ commit?: {
780
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
781
+ timeout?: number | undefined;
782
+ } | undefined;
783
+ pr?: {
784
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
785
+ timeout?: number | undefined;
786
+ } | undefined;
787
+ full?: {
788
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
789
+ timeout?: number | undefined;
790
+ } | undefined;
791
+ } | undefined;
792
+ }, {
793
+ levels?: {
794
+ commit?: {
795
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
796
+ timeout?: number | undefined;
797
+ } | undefined;
798
+ pr?: {
799
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
800
+ timeout?: number | undefined;
801
+ } | undefined;
802
+ full?: {
803
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
804
+ timeout?: number | undefined;
805
+ } | undefined;
806
+ } | undefined;
807
+ }>>;
808
+ agent: z.ZodOptional<z.ZodObject<{
809
+ format: z.ZodOptional<z.ZodEnum<["markdown", "json", "mcp"]>>;
810
+ includeRationale: z.ZodOptional<z.ZodBoolean>;
811
+ }, "strip", z.ZodTypeAny, {
812
+ format?: "markdown" | "json" | "mcp" | undefined;
813
+ includeRationale?: boolean | undefined;
814
+ }, {
815
+ format?: "markdown" | "json" | "mcp" | undefined;
816
+ includeRationale?: boolean | undefined;
817
+ }>>;
818
+ }, "strip", z.ZodTypeAny, {
819
+ version: string;
820
+ project: {
821
+ name: string;
822
+ sourceRoots: string[];
823
+ exclude?: string[] | undefined;
824
+ };
825
+ verification?: {
826
+ levels?: {
827
+ commit?: {
828
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
829
+ timeout?: number | undefined;
830
+ } | undefined;
831
+ pr?: {
832
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
833
+ timeout?: number | undefined;
834
+ } | undefined;
835
+ full?: {
836
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
837
+ timeout?: number | undefined;
838
+ } | undefined;
839
+ } | undefined;
840
+ } | undefined;
841
+ inference?: {
842
+ minConfidence?: number | undefined;
843
+ analyzers?: string[] | undefined;
844
+ } | undefined;
845
+ agent?: {
846
+ format?: "markdown" | "json" | "mcp" | undefined;
847
+ includeRationale?: boolean | undefined;
848
+ } | undefined;
849
+ }, {
850
+ version: string;
851
+ project: {
852
+ name: string;
853
+ sourceRoots: string[];
854
+ exclude?: string[] | undefined;
855
+ };
856
+ verification?: {
857
+ levels?: {
858
+ commit?: {
859
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
860
+ timeout?: number | undefined;
861
+ } | undefined;
862
+ pr?: {
863
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
864
+ timeout?: number | undefined;
865
+ } | undefined;
866
+ full?: {
867
+ severity?: ("critical" | "high" | "medium" | "low")[] | undefined;
868
+ timeout?: number | undefined;
869
+ } | undefined;
870
+ } | undefined;
871
+ } | undefined;
872
+ inference?: {
873
+ minConfidence?: number | undefined;
874
+ analyzers?: string[] | undefined;
875
+ } | undefined;
876
+ agent?: {
877
+ format?: "markdown" | "json" | "mcp" | undefined;
878
+ includeRationale?: boolean | undefined;
879
+ } | undefined;
880
+ }>;
881
+ type SpecBridgeConfigType = z.infer<typeof SpecBridgeConfigSchema>;
882
+ /**
883
+ * Validate configuration
884
+ */
885
+ declare function validateConfig(data: unknown): {
886
+ success: true;
887
+ data: SpecBridgeConfigType;
888
+ } | {
889
+ success: false;
890
+ errors: z.ZodError;
891
+ };
892
+ /**
893
+ * Default configuration
894
+ */
895
+ declare const defaultConfig: SpecBridgeConfigType;
896
+
897
+ /**
898
+ * Custom error types for SpecBridge
899
+ */
900
+ /**
901
+ * Base error for SpecBridge
902
+ */
903
+ declare class SpecBridgeError extends Error {
904
+ readonly code: string;
905
+ readonly details?: Record<string, unknown> | undefined;
906
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
907
+ }
908
+ /**
909
+ * Configuration errors
910
+ */
911
+ declare class ConfigError extends SpecBridgeError {
912
+ constructor(message: string, details?: Record<string, unknown>);
913
+ }
914
+ /**
915
+ * Decision validation errors
916
+ */
917
+ declare class DecisionValidationError extends SpecBridgeError {
918
+ readonly decisionId: string;
919
+ readonly validationErrors: string[];
920
+ constructor(message: string, decisionId: string, validationErrors: string[]);
921
+ }
922
+ /**
923
+ * Decision not found
924
+ */
925
+ declare class DecisionNotFoundError extends SpecBridgeError {
926
+ constructor(decisionId: string);
927
+ }
928
+ /**
929
+ * Registry errors
930
+ */
931
+ declare class RegistryError extends SpecBridgeError {
932
+ constructor(message: string, details?: Record<string, unknown>);
933
+ }
934
+ /**
935
+ * Verification errors
936
+ */
937
+ declare class VerificationError extends SpecBridgeError {
938
+ constructor(message: string, details?: Record<string, unknown>);
939
+ }
940
+ /**
941
+ * Inference errors
942
+ */
943
+ declare class InferenceError extends SpecBridgeError {
944
+ constructor(message: string, details?: Record<string, unknown>);
945
+ }
946
+ /**
947
+ * File system errors
948
+ */
949
+ declare class FileSystemError extends SpecBridgeError {
950
+ readonly path: string;
951
+ constructor(message: string, path: string);
952
+ }
953
+ /**
954
+ * Already initialized error
955
+ */
956
+ declare class AlreadyInitializedError extends SpecBridgeError {
957
+ constructor(path: string);
958
+ }
959
+ /**
960
+ * Not initialized error
961
+ */
962
+ declare class NotInitializedError extends SpecBridgeError {
963
+ constructor();
964
+ }
965
+ /**
966
+ * Verifier not found
967
+ */
968
+ declare class VerifierNotFoundError extends SpecBridgeError {
969
+ constructor(verifierId: string);
970
+ }
971
+ /**
972
+ * Analyzer not found
973
+ */
974
+ declare class AnalyzerNotFoundError extends SpecBridgeError {
975
+ constructor(analyzerId: string);
976
+ }
977
+ /**
978
+ * Hook installation error
979
+ */
980
+ declare class HookError extends SpecBridgeError {
981
+ constructor(message: string, details?: Record<string, unknown>);
982
+ }
983
+ /**
984
+ * Format error message for CLI output
985
+ */
986
+ declare function formatError(error: Error): string;
987
+
988
+ /**
989
+ * Configuration loader
990
+ */
991
+
992
+ /**
993
+ * Load configuration from .specbridge/config.yaml
994
+ */
995
+ declare function loadConfig(basePath?: string): Promise<SpecBridgeConfig>;
996
+ /**
997
+ * Merge partial config with defaults
998
+ */
999
+ declare function mergeWithDefaults(partial: Partial<SpecBridgeConfig>): SpecBridgeConfig;
1000
+
1001
+ interface LoadedDecision {
1002
+ decision: Decision;
1003
+ filePath: string;
1004
+ }
1005
+ interface LoadResult {
1006
+ decisions: LoadedDecision[];
1007
+ errors: LoadError[];
1008
+ }
1009
+ interface LoadError {
1010
+ filePath: string;
1011
+ error: string;
1012
+ }
1013
+ /**
1014
+ * Load a single decision file
1015
+ */
1016
+ declare function loadDecisionFile(filePath: string): Promise<Decision>;
1017
+ /**
1018
+ * Load all decisions from a directory
1019
+ */
1020
+ declare function loadDecisionsFromDir(dirPath: string): Promise<LoadResult>;
1021
+ /**
1022
+ * Validate a decision file without loading it into registry
1023
+ */
1024
+ declare function validateDecisionFile(filePath: string): Promise<{
1025
+ valid: boolean;
1026
+ errors: string[];
1027
+ }>;
1028
+
1029
+ /**
1030
+ * Decision Registry - Central store for architectural decisions
1031
+ */
1032
+
1033
+ interface RegistryOptions {
1034
+ basePath?: string;
1035
+ }
1036
+ interface DecisionFilter {
1037
+ status?: DecisionStatus[];
1038
+ tags?: string[];
1039
+ constraintType?: ConstraintType[];
1040
+ severity?: Severity[];
1041
+ }
1042
+ interface RegistryConstraintMatch {
1043
+ decisionId: string;
1044
+ decisionTitle: string;
1045
+ constraintId: string;
1046
+ type: ConstraintType;
1047
+ rule: string;
1048
+ severity: Severity;
1049
+ scope: string;
1050
+ }
1051
+ /**
1052
+ * Decision Registry class
1053
+ */
1054
+ declare class Registry {
1055
+ private decisions;
1056
+ private basePath;
1057
+ private loaded;
1058
+ constructor(options?: RegistryOptions);
1059
+ /**
1060
+ * Load all decisions from the decisions directory
1061
+ */
1062
+ load(): Promise<LoadResult>;
1063
+ /**
1064
+ * Ensure registry is loaded
1065
+ */
1066
+ private ensureLoaded;
1067
+ /**
1068
+ * Get all decisions
1069
+ */
1070
+ getAll(filter?: DecisionFilter): Decision[];
1071
+ /**
1072
+ * Get active decisions only
1073
+ */
1074
+ getActive(): Decision[];
1075
+ /**
1076
+ * Get a decision by ID
1077
+ */
1078
+ get(id: string): Decision;
1079
+ /**
1080
+ * Get a decision with its file path
1081
+ */
1082
+ getWithPath(id: string): LoadedDecision;
1083
+ /**
1084
+ * Check if a decision exists
1085
+ */
1086
+ has(id: string): boolean;
1087
+ /**
1088
+ * Get all decision IDs
1089
+ */
1090
+ getIds(): string[];
1091
+ /**
1092
+ * Get constraints applicable to a specific file
1093
+ */
1094
+ getConstraintsForFile(filePath: string, filter?: DecisionFilter): RegistryConstraintMatch[];
1095
+ /**
1096
+ * Get decisions by tag
1097
+ */
1098
+ getByTag(tag: string): Decision[];
1099
+ /**
1100
+ * Get decisions by owner
1101
+ */
1102
+ getByOwner(owner: string): Decision[];
1103
+ /**
1104
+ * Apply filter to decisions
1105
+ */
1106
+ private applyFilter;
1107
+ /**
1108
+ * Get count of decisions by status
1109
+ */
1110
+ getStatusCounts(): Record<DecisionStatus, number>;
1111
+ /**
1112
+ * Get total constraint count
1113
+ */
1114
+ getConstraintCount(): number;
1115
+ }
1116
+ /**
1117
+ * Create a new registry instance
1118
+ */
1119
+ declare function createRegistry(options?: RegistryOptions): Registry;
1120
+
1121
+ /**
1122
+ * Codebase scanner using ts-morph
1123
+ */
1124
+
1125
+ interface ScanResult {
1126
+ files: ScannedFile[];
1127
+ totalFiles: number;
1128
+ totalLines: number;
1129
+ }
1130
+ interface ScannedFile {
1131
+ path: string;
1132
+ sourceFile: SourceFile;
1133
+ lines: number;
1134
+ }
1135
+ interface ScanOptions {
1136
+ sourceRoots: string[];
1137
+ exclude?: string[];
1138
+ cwd?: string;
1139
+ }
1140
+ /**
1141
+ * Scanner class for analyzing TypeScript/JavaScript codebases
1142
+ */
1143
+ declare class CodeScanner {
1144
+ private project;
1145
+ private scannedFiles;
1146
+ constructor();
1147
+ /**
1148
+ * Scan files matching the given patterns
1149
+ */
1150
+ scan(options: ScanOptions): Promise<ScanResult>;
1151
+ /**
1152
+ * Get all scanned files
1153
+ */
1154
+ getFiles(): ScannedFile[];
1155
+ /**
1156
+ * Get a specific file
1157
+ */
1158
+ getFile(path: string): ScannedFile | undefined;
1159
+ /**
1160
+ * Get project instance for advanced analysis
1161
+ */
1162
+ getProject(): Project;
1163
+ /**
1164
+ * Find all classes in scanned files
1165
+ */
1166
+ findClasses(): {
1167
+ file: string;
1168
+ name: string;
1169
+ line: number;
1170
+ }[];
1171
+ /**
1172
+ * Find all functions in scanned files
1173
+ */
1174
+ findFunctions(): {
1175
+ file: string;
1176
+ name: string;
1177
+ line: number;
1178
+ isExported: boolean;
1179
+ }[];
1180
+ /**
1181
+ * Find all imports in scanned files
1182
+ */
1183
+ findImports(): {
1184
+ file: string;
1185
+ module: string;
1186
+ named: string[];
1187
+ line: number;
1188
+ }[];
1189
+ /**
1190
+ * Find all interfaces in scanned files
1191
+ */
1192
+ findInterfaces(): {
1193
+ file: string;
1194
+ name: string;
1195
+ line: number;
1196
+ }[];
1197
+ /**
1198
+ * Find all type aliases in scanned files
1199
+ */
1200
+ findTypeAliases(): {
1201
+ file: string;
1202
+ name: string;
1203
+ line: number;
1204
+ }[];
1205
+ /**
1206
+ * Find try-catch blocks in scanned files
1207
+ */
1208
+ findTryCatchBlocks(): {
1209
+ file: string;
1210
+ line: number;
1211
+ hasThrow: boolean;
1212
+ }[];
1213
+ }
1214
+ /**
1215
+ * Create a scanner from config
1216
+ */
1217
+ declare function createScannerFromConfig(_config: SpecBridgeConfig): CodeScanner;
1218
+
1219
+ /**
1220
+ * Inference Engine - Orchestrates pattern detection
1221
+ */
1222
+
1223
+ interface InferenceOptions {
1224
+ analyzers?: string[];
1225
+ minConfidence?: number;
1226
+ sourceRoots?: string[];
1227
+ exclude?: string[];
1228
+ cwd?: string;
1229
+ }
1230
+ /**
1231
+ * Inference Engine class
1232
+ */
1233
+ declare class InferenceEngine {
1234
+ private scanner;
1235
+ private analyzers;
1236
+ constructor();
1237
+ /**
1238
+ * Configure analyzers to use
1239
+ */
1240
+ configureAnalyzers(analyzerIds: string[]): void;
1241
+ /**
1242
+ * Run inference on the codebase
1243
+ */
1244
+ infer(options: InferenceOptions): Promise<InferenceResult>;
1245
+ /**
1246
+ * Get scanner for direct access
1247
+ */
1248
+ getScanner(): CodeScanner;
1249
+ }
1250
+ /**
1251
+ * Create an inference engine from config
1252
+ */
1253
+ declare function createInferenceEngine(): InferenceEngine;
1254
+ /**
1255
+ * Run inference with config
1256
+ */
1257
+ declare function runInference(config: SpecBridgeConfig, options?: Partial<InferenceOptions>): Promise<InferenceResult>;
1258
+
1259
+ /**
1260
+ * Base analyzer interface
1261
+ */
1262
+
1263
+ /**
1264
+ * Analyzer interface - all analyzers must implement this
1265
+ */
1266
+ interface Analyzer {
1267
+ /**
1268
+ * Unique identifier for this analyzer
1269
+ */
1270
+ readonly id: string;
1271
+ /**
1272
+ * Human-readable name
1273
+ */
1274
+ readonly name: string;
1275
+ /**
1276
+ * Description of what this analyzer detects
1277
+ */
1278
+ readonly description: string;
1279
+ /**
1280
+ * Analyze the codebase and return detected patterns
1281
+ */
1282
+ analyze(scanner: CodeScanner): Promise<Pattern[]>;
1283
+ }
1284
+ /**
1285
+ * Helper to create a pattern with consistent structure
1286
+ */
1287
+ declare function createPattern(analyzer: string, params: {
1288
+ id: string;
1289
+ name: string;
1290
+ description: string;
1291
+ confidence: number;
1292
+ occurrences: number;
1293
+ examples: PatternExample[];
1294
+ suggestedConstraint?: Pattern['suggestedConstraint'];
1295
+ }): Pattern;
1296
+ /**
1297
+ * Calculate confidence based on occurrence ratio
1298
+ */
1299
+ declare function calculateConfidence(occurrences: number, total: number, minOccurrences?: number): number;
1300
+ /**
1301
+ * Extract a code snippet around a line
1302
+ */
1303
+ declare function extractSnippet(content: string, line: number, contextLines?: number): string;
1304
+
1305
+ /**
1306
+ * Naming convention analyzer
1307
+ */
1308
+
1309
+ declare class NamingAnalyzer implements Analyzer {
1310
+ readonly id = "naming";
1311
+ readonly name = "Naming Convention Analyzer";
1312
+ readonly description = "Detects naming conventions for classes, functions, interfaces, and types";
1313
+ analyze(scanner: CodeScanner): Promise<Pattern[]>;
1314
+ private analyzeClassNaming;
1315
+ private analyzeFunctionNaming;
1316
+ private analyzeInterfaceNaming;
1317
+ private analyzeTypeNaming;
1318
+ private findBestMatch;
1319
+ }
1320
+
1321
+ /**
1322
+ * Import pattern analyzer
1323
+ */
1324
+
1325
+ declare class ImportsAnalyzer implements Analyzer {
1326
+ readonly id = "imports";
1327
+ readonly name = "Import Pattern Analyzer";
1328
+ readonly description = "Detects import organization patterns and module usage conventions";
1329
+ analyze(scanner: CodeScanner): Promise<Pattern[]>;
1330
+ private analyzeBarrelImports;
1331
+ private analyzeRelativeImports;
1332
+ private analyzeCommonModules;
1333
+ }
1334
+
1335
+ declare class StructureAnalyzer implements Analyzer {
1336
+ readonly id = "structure";
1337
+ readonly name = "Code Structure Analyzer";
1338
+ readonly description = "Detects file organization and directory structure patterns";
1339
+ analyze(scanner: CodeScanner): Promise<Pattern[]>;
1340
+ private analyzeDirectoryConventions;
1341
+ private analyzeFileNaming;
1342
+ private analyzeColocation;
1343
+ }
1344
+
1345
+ declare class ErrorsAnalyzer implements Analyzer {
1346
+ readonly id = "errors";
1347
+ readonly name = "Error Handling Analyzer";
1348
+ readonly description = "Detects error handling patterns and custom error class usage";
1349
+ analyze(scanner: CodeScanner): Promise<Pattern[]>;
1350
+ private analyzeCustomErrorClasses;
1351
+ private analyzeTryCatchPatterns;
1352
+ private analyzeThrowPatterns;
1353
+ }
1354
+
1355
+ /**
1356
+ * Analyzer exports
1357
+ */
1358
+
1359
+ /**
1360
+ * Built-in analyzers registry
1361
+ */
1362
+ declare const builtinAnalyzers: Record<string, () => Analyzer>;
1363
+ /**
1364
+ * Get analyzer by ID
1365
+ */
1366
+ declare function getAnalyzer(id: string): Analyzer | null;
1367
+ /**
1368
+ * Get all analyzer IDs
1369
+ */
1370
+ declare function getAnalyzerIds(): string[];
1371
+
1372
+ interface VerificationOptions {
1373
+ level?: VerificationLevel;
1374
+ files?: string[];
1375
+ decisions?: string[];
1376
+ severity?: Severity[];
1377
+ timeout?: number;
1378
+ cwd?: string;
1379
+ }
1380
+ /**
1381
+ * Verification Engine class
1382
+ */
1383
+ declare class VerificationEngine {
1384
+ private registry;
1385
+ private project;
1386
+ constructor(registry?: Registry);
1387
+ /**
1388
+ * Run verification
1389
+ */
1390
+ verify(config: SpecBridgeConfig, options?: VerificationOptions): Promise<VerificationResult>;
1391
+ /**
1392
+ * Verify a single file
1393
+ */
1394
+ verifyFile(filePath: string, decisions: Decision[], severityFilter?: Severity[]): Promise<Violation[]>;
1395
+ /**
1396
+ * Verify multiple files
1397
+ */
1398
+ private verifyFiles;
1399
+ /**
1400
+ * Check if file is excepted from constraint
1401
+ */
1402
+ private isExcepted;
1403
+ /**
1404
+ * Get registry
1405
+ */
1406
+ getRegistry(): Registry;
1407
+ }
1408
+ /**
1409
+ * Create verification engine
1410
+ */
1411
+ declare function createVerificationEngine(registry?: Registry): VerificationEngine;
1412
+
1413
+ /**
1414
+ * Base verifier interface
1415
+ */
1416
+
1417
+ /**
1418
+ * Context passed to verifiers
1419
+ */
1420
+ interface VerificationContext {
1421
+ filePath: string;
1422
+ sourceFile: SourceFile;
1423
+ constraint: Constraint;
1424
+ decisionId: string;
1425
+ }
1426
+ /**
1427
+ * Verifier interface - all verifiers must implement this
1428
+ */
1429
+ interface Verifier {
1430
+ /**
1431
+ * Unique identifier for this verifier
1432
+ */
1433
+ readonly id: string;
1434
+ /**
1435
+ * Human-readable name
1436
+ */
1437
+ readonly name: string;
1438
+ /**
1439
+ * Description of what this verifier checks
1440
+ */
1441
+ readonly description: string;
1442
+ /**
1443
+ * Verify a file against a constraint
1444
+ */
1445
+ verify(ctx: VerificationContext): Promise<Violation[]>;
1446
+ }
1447
+ /**
1448
+ * Helper to create a violation
1449
+ */
1450
+ declare function createViolation(params: {
1451
+ decisionId: string;
1452
+ constraintId: string;
1453
+ type: Constraint['type'];
1454
+ severity: Severity;
1455
+ message: string;
1456
+ file: string;
1457
+ line?: number;
1458
+ column?: number;
1459
+ endLine?: number;
1460
+ endColumn?: number;
1461
+ suggestion?: string;
1462
+ autofix?: Violation['autofix'];
1463
+ }): Violation;
1464
+
1465
+ /**
1466
+ * Naming convention verifier
1467
+ */
1468
+
1469
+ declare class NamingVerifier implements Verifier {
1470
+ readonly id = "naming";
1471
+ readonly name = "Naming Convention Verifier";
1472
+ readonly description = "Verifies naming conventions for classes, functions, and variables";
1473
+ verify(ctx: VerificationContext): Promise<Violation[]>;
1474
+ }
1475
+
1476
+ /**
1477
+ * Import pattern verifier
1478
+ */
1479
+
1480
+ declare class ImportsVerifier implements Verifier {
1481
+ readonly id = "imports";
1482
+ readonly name = "Import Pattern Verifier";
1483
+ readonly description = "Verifies import patterns like barrel imports, path aliases, etc.";
1484
+ verify(ctx: VerificationContext): Promise<Violation[]>;
1485
+ }
1486
+
1487
+ declare class ErrorsVerifier implements Verifier {
1488
+ readonly id = "errors";
1489
+ readonly name = "Error Handling Verifier";
1490
+ readonly description = "Verifies error handling patterns";
1491
+ verify(ctx: VerificationContext): Promise<Violation[]>;
1492
+ }
1493
+
1494
+ /**
1495
+ * Regex-based verifier for simple pattern matching
1496
+ */
1497
+
1498
+ /**
1499
+ * A generic verifier that uses regex patterns from constraint rules
1500
+ * This handles constraints that specify patterns to match or avoid
1501
+ */
1502
+ declare class RegexVerifier implements Verifier {
1503
+ readonly id = "regex";
1504
+ readonly name = "Regex Pattern Verifier";
1505
+ readonly description = "Verifies code against regex patterns specified in constraints";
1506
+ verify(ctx: VerificationContext): Promise<Violation[]>;
1507
+ }
1508
+
1509
+ /**
1510
+ * Verifier exports
1511
+ */
1512
+
1513
+ /**
1514
+ * Built-in verifiers registry
1515
+ */
1516
+ declare const builtinVerifiers: Record<string, () => Verifier>;
1517
+ /**
1518
+ * Get verifier by ID
1519
+ */
1520
+ declare function getVerifier(id: string): Verifier | null;
1521
+ /**
1522
+ * Get all verifier IDs
1523
+ */
1524
+ declare function getVerifierIds(): string[];
1525
+ /**
1526
+ * Select appropriate verifier based on constraint rule
1527
+ */
1528
+ declare function selectVerifierForConstraint(rule: string, specifiedVerifier?: string): Verifier | null;
1529
+
1530
+ /**
1531
+ * Dependency graph for impact analysis
1532
+ */
1533
+
1534
+ interface GraphNode {
1535
+ type: 'decision' | 'constraint' | 'file';
1536
+ id: string;
1537
+ edges: string[];
1538
+ }
1539
+ interface DependencyGraph {
1540
+ nodes: Map<string, GraphNode>;
1541
+ decisionToFiles: Map<string, Set<string>>;
1542
+ fileToDecisions: Map<string, Set<string>>;
1543
+ }
1544
+ /**
1545
+ * Build dependency graph from decisions and file list
1546
+ */
1547
+ declare function buildDependencyGraph(decisions: Decision[], files: string[]): Promise<DependencyGraph>;
1548
+ /**
1549
+ * Get files affected by a decision
1550
+ */
1551
+ declare function getAffectedFiles(graph: DependencyGraph, decisionId: string): string[];
1552
+ /**
1553
+ * Get decisions affecting a file
1554
+ */
1555
+ declare function getAffectingDecisions(graph: DependencyGraph, filePath: string): string[];
1556
+ /**
1557
+ * Calculate transitive closure for a node
1558
+ */
1559
+ declare function getTransitiveDependencies(graph: DependencyGraph, nodeId: string, visited?: Set<string>): string[];
1560
+
1561
+ /**
1562
+ * Propagation Engine - Analyze impact of decision changes
1563
+ */
1564
+
1565
+ interface PropagationOptions {
1566
+ cwd?: string;
1567
+ }
1568
+ /**
1569
+ * Propagation Engine class
1570
+ */
1571
+ declare class PropagationEngine {
1572
+ private registry;
1573
+ private graph;
1574
+ constructor(registry?: Registry);
1575
+ /**
1576
+ * Initialize the engine with current state
1577
+ */
1578
+ initialize(config: SpecBridgeConfig, options?: PropagationOptions): Promise<void>;
1579
+ /**
1580
+ * Analyze impact of changing a decision
1581
+ */
1582
+ analyzeImpact(decisionId: string, change: 'created' | 'modified' | 'deprecated', config: SpecBridgeConfig, options?: PropagationOptions): Promise<ImpactAnalysis>;
1583
+ /**
1584
+ * Generate migration steps
1585
+ */
1586
+ private generateMigrationSteps;
1587
+ /**
1588
+ * Get dependency graph
1589
+ */
1590
+ getGraph(): DependencyGraph | null;
1591
+ }
1592
+ /**
1593
+ * Create propagation engine
1594
+ */
1595
+ declare function createPropagationEngine(registry?: Registry): PropagationEngine;
1596
+
1597
+ /**
1598
+ * Compliance reporter
1599
+ */
1600
+
1601
+ interface ReportOptions {
1602
+ includeAll?: boolean;
1603
+ cwd?: string;
1604
+ }
1605
+ /**
1606
+ * Generate a compliance report
1607
+ */
1608
+ declare function generateReport(config: SpecBridgeConfig, options?: ReportOptions): Promise<ComplianceReport>;
1609
+ /**
1610
+ * Check if compliance has degraded from previous report
1611
+ */
1612
+ declare function checkDegradation(current: ComplianceReport, previous: ComplianceReport | null): {
1613
+ degraded: boolean;
1614
+ details: string[];
1615
+ };
1616
+ /**
1617
+ * Reporter class for formatting verification results
1618
+ */
1619
+ declare class Reporter {
1620
+ /**
1621
+ * Generate formatted report from verification result
1622
+ */
1623
+ generate(result: any, options?: {
1624
+ format?: 'table' | 'json' | 'markdown';
1625
+ includePassedChecks?: boolean;
1626
+ groupBy?: 'severity' | 'file';
1627
+ colorize?: boolean;
1628
+ }): string;
1629
+ /**
1630
+ * Generate compliance overview from multiple results
1631
+ */
1632
+ generateComplianceReport(results: any[]): string;
1633
+ private formatAsTable;
1634
+ private formatAsTableGrouped;
1635
+ private formatAsMarkdown;
1636
+ }
1637
+
1638
+ /**
1639
+ * Format report for console output
1640
+ */
1641
+ declare function formatConsoleReport(report: ComplianceReport): string;
1642
+
1643
+ /**
1644
+ * Markdown format for reports
1645
+ */
1646
+
1647
+ /**
1648
+ * Format report as Markdown
1649
+ */
1650
+ declare function formatMarkdownReport(report: ComplianceReport): string;
1651
+
1652
+ /**
1653
+ * Agent context generator
1654
+ */
1655
+
1656
+ interface ContextOptions {
1657
+ includeRationale?: boolean;
1658
+ format?: 'markdown' | 'json' | 'mcp';
1659
+ cwd?: string;
1660
+ }
1661
+ /**
1662
+ * Generate agent context for a file
1663
+ */
1664
+ declare function generateContext(filePath: string, config: SpecBridgeConfig, options?: ContextOptions): Promise<AgentContext>;
1665
+ /**
1666
+ * Format context as Markdown for agent prompts
1667
+ */
1668
+ declare function formatContextAsMarkdown(context: AgentContext): string;
1669
+ /**
1670
+ * Format context as JSON
1671
+ */
1672
+ declare function formatContextAsJson(context: AgentContext): string;
1673
+ /**
1674
+ * Format context for MCP (Model Context Protocol)
1675
+ */
1676
+ declare function formatContextAsMcp(context: AgentContext): object;
1677
+ /**
1678
+ * Generate context in specified format
1679
+ */
1680
+ declare function generateFormattedContext(filePath: string, config: SpecBridgeConfig, options?: ContextOptions): Promise<string>;
1681
+ /**
1682
+ * AgentContextGenerator class for test compatibility
1683
+ */
1684
+ declare class AgentContextGenerator {
1685
+ /**
1686
+ * Generate context from decisions
1687
+ */
1688
+ generateContext(options: {
1689
+ decisions: any[];
1690
+ filePattern?: string;
1691
+ format?: 'markdown' | 'plain' | 'json';
1692
+ concise?: boolean;
1693
+ minSeverity?: string;
1694
+ includeExamples?: boolean;
1695
+ }): string;
1696
+ /**
1697
+ * Generate prompt suffix for AI agents
1698
+ */
1699
+ generatePromptSuffix(options: {
1700
+ decisions: any[];
1701
+ }): string;
1702
+ /**
1703
+ * Extract relevant decisions for a specific file
1704
+ */
1705
+ extractRelevantDecisions(options: {
1706
+ decisions: any[];
1707
+ filePath: string;
1708
+ }): any[];
1709
+ }
1710
+
1711
+ /**
1712
+ * Check if a path exists
1713
+ */
1714
+ declare function pathExists(path: string): Promise<boolean>;
1715
+ /**
1716
+ * Check if a path is a directory
1717
+ */
1718
+ declare function isDirectory(path: string): Promise<boolean>;
1719
+ /**
1720
+ * Ensure a directory exists
1721
+ */
1722
+ declare function ensureDir(path: string): Promise<void>;
1723
+ /**
1724
+ * Read a text file
1725
+ */
1726
+ declare function readTextFile(path: string): Promise<string>;
1727
+ /**
1728
+ * Write a text file, creating directories as needed
1729
+ */
1730
+ declare function writeTextFile(path: string, content: string): Promise<void>;
1731
+ /**
1732
+ * Read all files in a directory matching a pattern
1733
+ */
1734
+ declare function readFilesInDir(dirPath: string, filter?: (filename: string) => boolean): Promise<string[]>;
1735
+ /**
1736
+ * Get the .specbridge directory path
1737
+ */
1738
+ declare function getSpecBridgeDir(basePath?: string): string;
1739
+ /**
1740
+ * Get the decisions directory path
1741
+ */
1742
+ declare function getDecisionsDir(basePath?: string): string;
1743
+ /**
1744
+ * Get the verifiers directory path
1745
+ */
1746
+ declare function getVerifiersDir(basePath?: string): string;
1747
+ /**
1748
+ * Get the inferred patterns directory path
1749
+ */
1750
+ declare function getInferredDir(basePath?: string): string;
1751
+ /**
1752
+ * Get the reports directory path
1753
+ */
1754
+ declare function getReportsDir(basePath?: string): string;
1755
+ /**
1756
+ * Get the config file path
1757
+ */
1758
+ declare function getConfigPath(basePath?: string): string;
1759
+
1760
+ /**
1761
+ * YAML utilities with comment preservation
1762
+ */
1763
+
1764
+ /**
1765
+ * Parse YAML string to object
1766
+ */
1767
+ declare function parseYaml<T = unknown>(content: string): T;
1768
+ /**
1769
+ * Stringify object to YAML with nice formatting
1770
+ */
1771
+ declare function stringifyYaml(data: unknown, options?: {
1772
+ indent?: number;
1773
+ }): string;
1774
+ /**
1775
+ * Parse YAML preserving document structure (for editing)
1776
+ */
1777
+ declare function parseYamlDocument(content: string): Document;
1778
+ /**
1779
+ * Update YAML document preserving comments
1780
+ */
1781
+ declare function updateYamlDocument(doc: Document, path: string[], value: unknown): void;
1782
+
1783
+ interface GlobOptions {
1784
+ cwd?: string;
1785
+ ignore?: string[];
1786
+ absolute?: boolean;
1787
+ onlyFiles?: boolean;
1788
+ }
1789
+ /**
1790
+ * Find files matching glob patterns
1791
+ */
1792
+ declare function glob(patterns: string | string[], options?: GlobOptions): Promise<string[]>;
1793
+ /**
1794
+ * Check if a file path matches a glob pattern
1795
+ */
1796
+ declare function matchesPattern(filePath: string, pattern: string): boolean;
1797
+ /**
1798
+ * Check if a file path matches any of the given patterns
1799
+ */
1800
+ declare function matchesAnyPattern(filePath: string, patterns: string[]): boolean;
1801
+
1802
+ export { type AffectedFile, type AgentContext, AgentContextGenerator, AlreadyInitializedError, type Analyzer, AnalyzerNotFoundError, type ApplicableConstraint, type ApplicableDecision, CodeScanner, type ComplianceReport, ConfigError, type Constraint, type ConstraintException, ConstraintExceptionSchema, type ConstraintExceptionSchema_, ConstraintSchema, type ConstraintSchema_, type ConstraintType, ConstraintTypeSchema, type ConstraintTypeSchema_, type ContextOptions, type Decision, type DecisionCompliance, type DecisionContent, DecisionContentSchema, type DecisionContentSchema_, type DecisionFilter, type DecisionMetadata, DecisionMetadataSchema, type DecisionMetadataSchema_, DecisionNotFoundError, DecisionSchema, type DecisionStatus, DecisionStatusSchema, type DecisionStatusSchema_, type DecisionTypeSchema, DecisionValidationError, type DependencyGraph, ErrorsAnalyzer, ErrorsVerifier, FileSystemError, type GlobOptions, type GraphNode, HookError, type ImpactAnalysis, ImportsAnalyzer, ImportsVerifier, InferenceEngine, InferenceError, type InferenceOptions, type InferenceResult, type LevelConfig, LinksSchema, type LoadError, type LoadResult, type LoadedDecision, type MigrationStep, NamingAnalyzer, NamingVerifier, NotInitializedError, type Pattern, type PatternExample, PropagationEngine, type PropagationOptions, RegexVerifier, Registry, type RegistryConstraintMatch, RegistryError, type RegistryOptions, type ReportOptions, Reporter, type ScanOptions, type ScanResult, type ScannedFile, type Severity, SeveritySchema, type SeveritySchema_, type SpecBridgeConfig, SpecBridgeConfigSchema, type SpecBridgeConfigType, SpecBridgeError, StructureAnalyzer, type TrendData, type VerificationConfig, VerificationConfigSchema, type VerificationConfigSchema_, type VerificationContext, VerificationEngine, VerificationError, type VerificationFrequency, VerificationFrequencySchema, type VerificationFrequencySchema_, type VerificationLevel, type VerificationOptions, type VerificationResult, type Verifier, VerifierNotFoundError, type Violation, type ViolationFix, buildDependencyGraph, builtinAnalyzers, builtinVerifiers, calculateConfidence, checkDegradation, createInferenceEngine, createPattern, createPropagationEngine, createRegistry, createScannerFromConfig, createVerificationEngine, createViolation, defaultConfig, ensureDir, extractSnippet, formatConsoleReport, formatContextAsJson, formatContextAsMarkdown, formatContextAsMcp, formatError, formatMarkdownReport, formatValidationErrors, generateContext, generateFormattedContext, generateReport, getAffectedFiles, getAffectingDecisions, getAnalyzer, getAnalyzerIds, getConfigPath, getDecisionsDir, getInferredDir, getReportsDir, getSpecBridgeDir, getTransitiveDependencies, getVerifier, getVerifierIds, getVerifiersDir, glob, isDirectory, loadConfig, loadDecisionFile, loadDecisionsFromDir, matchesAnyPattern, matchesPattern, mergeWithDefaults, parseYaml, parseYamlDocument, pathExists, readFilesInDir, readTextFile, runInference, selectVerifierForConstraint, stringifyYaml, updateYamlDocument, validateConfig, validateDecision, validateDecisionFile, writeTextFile };