@harness-engineering/core 0.7.0 → 0.8.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.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,244 @@ import { Result, WorkflowStep, WorkflowStepResult, Workflow, WorkflowResult, Ski
2
2
  export * from '@harness-engineering/types';
3
3
  import { z } from 'zod';
4
4
 
5
+ type ErrorCode = string;
6
+ interface BaseError {
7
+ code: ErrorCode;
8
+ message: string;
9
+ details: Record<string, unknown>;
10
+ suggestions: string[];
11
+ }
12
+ interface ValidationError extends BaseError {
13
+ code: 'INVALID_TYPE' | 'MISSING_FIELD' | 'VALIDATION_FAILED' | 'PARSE_ERROR';
14
+ }
15
+ interface ContextError extends BaseError {
16
+ code: 'PARSE_ERROR' | 'SCHEMA_VIOLATION' | 'MISSING_SECTION' | 'BROKEN_LINK';
17
+ }
18
+ interface ConstraintError extends BaseError {
19
+ code: 'WRONG_LAYER' | 'CIRCULAR_DEP' | 'FORBIDDEN_IMPORT' | 'BOUNDARY_ERROR' | 'PARSER_UNAVAILABLE';
20
+ }
21
+ interface EntropyError extends BaseError {
22
+ code: 'SNAPSHOT_BUILD_FAILED' | 'PARSE_ERROR' | 'ENTRY_POINT_NOT_FOUND' | 'INVALID_CONFIG' | 'CONFIG_VALIDATION_ERROR' | 'FIX_FAILED' | 'BACKUP_FAILED';
23
+ details: {
24
+ file?: string;
25
+ reason?: string;
26
+ issues?: unknown[];
27
+ originalError?: Error;
28
+ };
29
+ }
30
+ interface FeedbackError$1 extends BaseError {
31
+ code: 'AGENT_SPAWN_ERROR' | 'AGENT_TIMEOUT' | 'TELEMETRY_ERROR' | 'TELEMETRY_UNAVAILABLE' | 'REVIEW_ERROR' | 'DIFF_PARSE_ERROR' | 'SINK_ERROR';
32
+ details: {
33
+ agentId?: string;
34
+ service?: string;
35
+ reason?: string;
36
+ originalError?: Error;
37
+ };
38
+ }
39
+ declare function createError<T extends BaseError>(code: T['code'], message: string, details?: Record<string, unknown>, suggestions?: string[]): T;
40
+
41
+ interface Convention {
42
+ pattern: string;
43
+ required: boolean;
44
+ description: string;
45
+ examples: string[];
46
+ }
47
+ interface StructureValidation {
48
+ valid: boolean;
49
+ missing: string[];
50
+ unexpected: string[];
51
+ conformance: number;
52
+ }
53
+ interface ConfigError extends ValidationError {
54
+ code: 'INVALID_TYPE' | 'MISSING_FIELD' | 'VALIDATION_FAILED';
55
+ details: {
56
+ zodError?: unknown;
57
+ path?: string[];
58
+ };
59
+ }
60
+ type CommitFormat = 'conventional' | 'angular' | 'custom';
61
+ interface CommitValidation {
62
+ valid: boolean;
63
+ type?: string;
64
+ scope?: string;
65
+ breaking: boolean;
66
+ issues: string[];
67
+ }
68
+
69
+ declare function validateFileStructure(projectPath: string, conventions: Convention[]): Promise<Result<StructureValidation, ValidationError>>;
70
+
71
+ /**
72
+ * Validates configuration data against a Zod schema
73
+ * Returns a Result type with validated data or ConfigError
74
+ *
75
+ * @template T - The type of data being validated
76
+ * @param data - The configuration data to validate
77
+ * @param schema - Zod schema to validate against
78
+ * @returns Result<T, ConfigError> - Success with validated data or error
79
+ */
80
+ declare function validateConfig<T>(data: unknown, schema: z.ZodSchema<T>): Result<T, ConfigError>;
81
+
82
+ /**
83
+ * Validates a commit message according to the specified format
84
+ * Returns a Result type with validation details
85
+ *
86
+ * @param message - The commit message to validate
87
+ * @param format - The commit format to validate against ('conventional', 'angular', 'custom')
88
+ * @returns Result<CommitValidation, ValidationError> - Success with validation details or error
89
+ */
90
+ declare function validateCommitMessage(message: string, format?: CommitFormat): Result<CommitValidation, ValidationError>;
91
+
92
+ interface AgentMapLink {
93
+ text: string;
94
+ path: string;
95
+ exists: boolean;
96
+ line: number;
97
+ error?: ContextError;
98
+ }
99
+ interface AgentMapSection {
100
+ title: string;
101
+ level: number;
102
+ links: AgentMapLink[];
103
+ description?: string;
104
+ line: number;
105
+ }
106
+ interface AgentMapValidation {
107
+ valid: boolean;
108
+ sections: AgentMapSection[];
109
+ totalLinks: number;
110
+ brokenLinks: AgentMapLink[];
111
+ missingSections: string[];
112
+ errors?: ContextError[];
113
+ }
114
+ interface DocumentationGap {
115
+ file: string;
116
+ suggestedSection: string;
117
+ importance: 'high' | 'medium' | 'low';
118
+ }
119
+ interface CoverageReport {
120
+ domain: string;
121
+ documented: string[];
122
+ undocumented: string[];
123
+ coveragePercentage: number;
124
+ gaps: DocumentationGap[];
125
+ }
126
+ interface GraphCoverageData {
127
+ documented: string[];
128
+ undocumented: string[];
129
+ coveragePercentage: number;
130
+ }
131
+ interface CoverageOptions {
132
+ docsDir?: string;
133
+ sourceDir?: string;
134
+ excludePatterns?: string[];
135
+ graphCoverage?: GraphCoverageData;
136
+ }
137
+ interface BrokenLink {
138
+ text: string;
139
+ path: string;
140
+ line: number;
141
+ section: string;
142
+ reason: 'NOT_FOUND' | 'PERMISSION_DENIED' | 'INVALID_PATH';
143
+ suggestion: string;
144
+ }
145
+ interface IntegrityReport {
146
+ totalLinks: number;
147
+ brokenLinks: BrokenLink[];
148
+ validLinks: number;
149
+ integrity: number;
150
+ }
151
+ interface GenerationSection {
152
+ name: string;
153
+ pattern: string;
154
+ description: string;
155
+ }
156
+ interface AgentsMapConfig {
157
+ rootDir: string;
158
+ includePaths: string[];
159
+ excludePaths: string[];
160
+ template?: string;
161
+ sections?: GenerationSection[];
162
+ }
163
+ declare const REQUIRED_SECTIONS: readonly ["Project Overview", "Repository Structure", "Development Workflow"];
164
+
165
+ interface ExtractedLink {
166
+ text: string;
167
+ path: string;
168
+ line: number;
169
+ }
170
+ /**
171
+ * Extract markdown links from content
172
+ * Pattern: [text](path)
173
+ */
174
+ declare function extractMarkdownLinks(content: string): ExtractedLink[];
175
+ /**
176
+ * Extract sections from markdown content
177
+ * Pattern: # Heading or ## Heading etc.
178
+ */
179
+ declare function extractSections(content: string): AgentMapSection[];
180
+ /**
181
+ * Validate an AGENTS.md file
182
+ * - Parses sections and links
183
+ * - Checks for required sections
184
+ * - Verifies all links point to existing files
185
+ */
186
+ declare function validateAgentsMap(path?: string): Promise<Result<AgentMapValidation, ContextError>>;
187
+
188
+ /**
189
+ * Check documentation coverage for a domain
190
+ */
191
+ declare function checkDocCoverage(domain: string, options?: CoverageOptions): Promise<Result<CoverageReport, ContextError>>;
192
+
193
+ /**
194
+ * Validate knowledge map integrity (all links in AGENTS.md and docs)
195
+ */
196
+ declare function validateKnowledgeMap(rootDir?: string): Promise<Result<IntegrityReport, ContextError>>;
197
+
198
+ /**
199
+ * Generate AGENTS.md content from project structure
200
+ */
201
+ declare function generateAgentsMap(config: AgentsMapConfig, graphSections?: Array<{
202
+ name: string;
203
+ files: string[];
204
+ description?: string;
205
+ }>): Promise<Result<string, ContextError>>;
206
+
207
+ interface TokenBudget {
208
+ total: number;
209
+ systemPrompt: number;
210
+ projectManifest: number;
211
+ taskSpec: number;
212
+ activeCode: number;
213
+ interfaces: number;
214
+ reserve: number;
215
+ }
216
+ interface TokenBudgetOverrides {
217
+ systemPrompt?: number;
218
+ projectManifest?: number;
219
+ taskSpec?: number;
220
+ activeCode?: number;
221
+ interfaces?: number;
222
+ reserve?: number;
223
+ }
224
+
225
+ declare function contextBudget(totalTokens: number, overrides?: TokenBudgetOverrides, graphDensity?: Record<string, number>): TokenBudget;
226
+
227
+ type WorkflowPhase = 'implement' | 'review' | 'debug' | 'plan';
228
+ interface FileCategory {
229
+ category: string;
230
+ patterns: string[];
231
+ priority: number;
232
+ }
233
+ interface ContextFilterResult {
234
+ phase: WorkflowPhase;
235
+ includedCategories: string[];
236
+ excludedCategories: string[];
237
+ filePatterns: string[];
238
+ }
239
+
240
+ declare function contextFilter(phase: WorkflowPhase, maxCategories?: number, graphFilePaths?: string[]): ContextFilterResult;
241
+ declare function getPhaseCategories(phase: WorkflowPhase): FileCategory[];
242
+
5
243
  /**
6
244
  * Abstract Syntax Tree representation
7
245
  */
@@ -95,6 +333,7 @@ interface LayerConfig {
95
333
  rootDir: string;
96
334
  parser: LanguageParser;
97
335
  fallbackBehavior?: 'skip' | 'error' | 'warn';
336
+ graphDependencyData?: GraphDependencyData;
98
337
  }
99
338
  interface DependencyEdge {
100
339
  from: string;
@@ -154,16 +393,57 @@ interface BoundaryValidator<T> {
154
393
  validate(input: unknown): Result<boolean, ConstraintError>;
155
394
  schema: z.ZodSchema<T>;
156
395
  }
396
+ /**
397
+ * Pre-computed dependency data from graph — avoids file parsing.
398
+ * Compatible with DependencyGraph shape.
399
+ */
400
+ interface GraphDependencyData {
401
+ nodes: string[];
402
+ edges: Array<{
403
+ from: string;
404
+ to: string;
405
+ importType: 'static' | 'dynamic' | 'type-only';
406
+ line: number;
407
+ }>;
408
+ }
409
+
410
+ /**
411
+ * Create a layer definition
412
+ */
413
+ declare function defineLayer(name: string, patterns: string[], allowedDependencies: string[]): Layer;
414
+ /**
415
+ * Resolve a file path to its layer
416
+ */
417
+ declare function resolveFileToLayer(file: string, layers: Layer[]): Layer | undefined;
418
+
419
+ /**
420
+ * Build a dependency graph from a list of files
421
+ * Note: buildDependencyGraph is exported as an addition beyond spec for advanced use cases
422
+ */
423
+ declare function buildDependencyGraph(files: string[], parser: LanguageParser, graphDependencyData?: GraphDependencyData): Promise<Result<DependencyGraph, ConstraintError>>;
424
+ /**
425
+ * Validate dependencies against layer rules
426
+ */
427
+ declare function validateDependencies(config: LayerConfig): Promise<Result<DependencyValidation, ConstraintError>>;
428
+
429
+ /**
430
+ * Detect circular dependencies in a dependency graph
431
+ */
432
+ declare function detectCircularDeps(graph: DependencyGraph): Result<CircularDepsResult, ConstraintError>;
433
+ /**
434
+ * Detect circular dependencies from a list of files
435
+ */
436
+ declare function detectCircularDepsInFiles(files: string[], parser: LanguageParser, graphDependencyData?: GraphDependencyData): Promise<Result<CircularDepsResult, ConstraintError>>;
437
+
438
+ /**
439
+ * Create a boundary validator from a Zod schema
440
+ */
441
+ declare function createBoundaryValidator<T>(schema: z.ZodSchema<T>, name: string): BoundaryValidator<T>;
442
+ /**
443
+ * Validate multiple boundaries at once
444
+ */
445
+ declare function validateBoundaries(boundaries: BoundaryDefinition[], data: Map<string, unknown>): Result<BoundaryValidation, ConstraintError>;
157
446
 
158
- interface EntropyError extends BaseError {
159
- code: 'SNAPSHOT_BUILD_FAILED' | 'PARSE_ERROR' | 'ENTRY_POINT_NOT_FOUND' | 'INVALID_CONFIG' | 'CONFIG_VALIDATION_ERROR' | 'FIX_FAILED' | 'BACKUP_FAILED';
160
- details: {
161
- file?: string;
162
- reason?: string;
163
- issues?: unknown[];
164
- originalError?: Error;
165
- };
166
- }
167
447
  interface InternalSymbol {
168
448
  name: string;
169
449
  type: 'function' | 'class' | 'variable' | 'type';
@@ -361,382 +641,125 @@ interface ConfigPattern {
361
641
  } | {
362
642
  type: 'max-lines';
363
643
  count: number;
364
- } | {
365
- type: 'require-jsdoc';
366
- for: ('function' | 'class' | 'export')[];
367
- };
368
- message?: string;
369
- }
370
- interface CodePattern {
371
- name: string;
372
- description: string;
373
- severity: 'error' | 'warning';
374
- check: (file: SourceFile, snapshot: CodebaseSnapshot) => PatternMatch[];
375
- }
376
- interface PatternMatch {
377
- line: number;
378
- column?: number;
379
- message: string;
380
- suggestion?: string;
381
- }
382
- interface PatternConfig {
383
- patterns: ConfigPattern[];
384
- customPatterns?: CodePattern[];
385
- ignoreFiles?: string[];
386
- }
387
- interface PatternViolation {
388
- pattern: string;
389
- file: string;
390
- line: number;
391
- column?: number;
392
- severity: 'error' | 'warning';
393
- message: string;
394
- suggestion?: string;
395
- }
396
- interface PatternReport {
397
- violations: PatternViolation[];
398
- stats: {
399
- filesChecked: number;
400
- patternsApplied: number;
401
- violationCount: number;
402
- errorCount: number;
403
- warningCount: number;
404
- };
405
- passRate: number;
406
- }
407
- type FixType = 'unused-imports' | 'dead-files' | 'trailing-whitespace' | 'broken-links' | 'sort-imports';
408
- interface FixConfig {
409
- dryRun: boolean;
410
- fixTypes: FixType[];
411
- createBackup: boolean;
412
- backupDir?: string;
413
- }
414
- interface Fix {
415
- type: FixType;
416
- file: string;
417
- description: string;
418
- action: 'delete-file' | 'delete-lines' | 'replace' | 'insert';
419
- line?: number;
420
- oldContent?: string;
421
- newContent?: string;
422
- safe: true;
423
- reversible: boolean;
424
- }
425
- interface FixResult {
426
- applied: Fix[];
427
- skipped: Fix[];
428
- errors: {
429
- fix: Fix;
430
- error: string;
431
- }[];
432
- stats: {
433
- filesModified: number;
434
- filesDeleted: number;
435
- linesRemoved: number;
436
- backupPath?: string;
437
- };
438
- }
439
- interface Suggestion {
440
- type: 'rename' | 'move' | 'merge' | 'split' | 'delete' | 'update-docs' | 'add-export' | 'refactor';
441
- priority: 'high' | 'medium' | 'low';
442
- source: 'drift' | 'dead-code' | 'pattern';
443
- relatedIssues: string[];
444
- title: string;
445
- description: string;
446
- files: string[];
447
- steps: string[];
448
- preview?: {
449
- file: string;
450
- diff: string;
451
- };
452
- whyManual: string;
453
- }
454
- interface SuggestionReport {
455
- suggestions: Suggestion[];
456
- byPriority: {
457
- high: Suggestion[];
458
- medium: Suggestion[];
459
- low: Suggestion[];
460
- };
461
- estimatedEffort: 'trivial' | 'small' | 'medium' | 'large';
462
- }
463
- interface AnalysisError {
464
- analyzer: 'drift' | 'deadCode' | 'patterns';
465
- error: EntropyError;
466
- }
467
- interface EntropyReport {
468
- snapshot: CodebaseSnapshot;
469
- drift?: DriftReport;
470
- deadCode?: DeadCodeReport;
471
- patterns?: PatternReport;
472
- analysisErrors: AnalysisError[];
473
- summary: {
474
- totalIssues: number;
475
- errors: number;
476
- warnings: number;
477
- fixableCount: number;
478
- suggestionCount: number;
479
- };
480
- timestamp: string;
481
- duration: number;
482
- }
483
-
484
- type ErrorCode = string;
485
- interface BaseError {
486
- code: ErrorCode;
487
- message: string;
488
- details: Record<string, unknown>;
489
- suggestions: string[];
490
- }
491
- interface ValidationError extends BaseError {
492
- code: 'INVALID_TYPE' | 'MISSING_FIELD' | 'VALIDATION_FAILED' | 'PARSE_ERROR';
493
- }
494
- interface ContextError extends BaseError {
495
- code: 'PARSE_ERROR' | 'SCHEMA_VIOLATION' | 'MISSING_SECTION' | 'BROKEN_LINK';
496
- }
497
- interface ConstraintError extends BaseError {
498
- code: 'WRONG_LAYER' | 'CIRCULAR_DEP' | 'FORBIDDEN_IMPORT' | 'BOUNDARY_ERROR' | 'PARSER_UNAVAILABLE';
499
- }
500
-
501
- interface FeedbackError$1 extends BaseError {
502
- code: 'AGENT_SPAWN_ERROR' | 'AGENT_TIMEOUT' | 'TELEMETRY_ERROR' | 'TELEMETRY_UNAVAILABLE' | 'REVIEW_ERROR' | 'DIFF_PARSE_ERROR' | 'SINK_ERROR';
503
- details: {
504
- agentId?: string;
505
- service?: string;
506
- reason?: string;
507
- originalError?: Error;
508
- };
509
- }
510
- declare function createError<T extends BaseError>(code: T['code'], message: string, details?: Record<string, unknown>, suggestions?: string[]): T;
511
-
512
- interface Convention {
513
- pattern: string;
514
- required: boolean;
515
- description: string;
516
- examples: string[];
517
- }
518
- interface StructureValidation {
519
- valid: boolean;
520
- missing: string[];
521
- unexpected: string[];
522
- conformance: number;
523
- }
524
- interface ConfigError extends ValidationError {
525
- code: 'INVALID_TYPE' | 'MISSING_FIELD' | 'VALIDATION_FAILED';
526
- details: {
527
- zodError?: unknown;
528
- path?: string[];
529
- };
530
- }
531
- type CommitFormat = 'conventional' | 'angular' | 'custom';
532
- interface CommitValidation {
533
- valid: boolean;
534
- type?: string;
535
- scope?: string;
536
- breaking: boolean;
537
- issues: string[];
538
- }
539
-
540
- declare function validateFileStructure(projectPath: string, conventions: Convention[]): Promise<Result<StructureValidation, ValidationError>>;
541
-
542
- /**
543
- * Validates configuration data against a Zod schema
544
- * Returns a Result type with validated data or ConfigError
545
- *
546
- * @template T - The type of data being validated
547
- * @param data - The configuration data to validate
548
- * @param schema - Zod schema to validate against
549
- * @returns Result<T, ConfigError> - Success with validated data or error
550
- */
551
- declare function validateConfig<T>(data: unknown, schema: z.ZodSchema<T>): Result<T, ConfigError>;
552
-
553
- /**
554
- * Validates a commit message according to the specified format
555
- * Returns a Result type with validation details
556
- *
557
- * @param message - The commit message to validate
558
- * @param format - The commit format to validate against ('conventional', 'angular', 'custom')
559
- * @returns Result<CommitValidation, ValidationError> - Success with validation details or error
560
- */
561
- declare function validateCommitMessage(message: string, format?: CommitFormat): Result<CommitValidation, ValidationError>;
562
-
563
- interface AgentMapLink {
564
- text: string;
565
- path: string;
566
- exists: boolean;
567
- line: number;
568
- error?: ContextError;
569
- }
570
- interface AgentMapSection {
571
- title: string;
572
- level: number;
573
- links: AgentMapLink[];
574
- description?: string;
575
- line: number;
576
- }
577
- interface AgentMapValidation {
578
- valid: boolean;
579
- sections: AgentMapSection[];
580
- totalLinks: number;
581
- brokenLinks: AgentMapLink[];
582
- missingSections: string[];
583
- errors?: ContextError[];
584
- }
585
- interface DocumentationGap {
586
- file: string;
587
- suggestedSection: string;
588
- importance: 'high' | 'medium' | 'low';
589
- }
590
- interface CoverageReport {
591
- domain: string;
592
- documented: string[];
593
- undocumented: string[];
594
- coveragePercentage: number;
595
- gaps: DocumentationGap[];
644
+ } | {
645
+ type: 'require-jsdoc';
646
+ for: ('function' | 'class' | 'export')[];
647
+ };
648
+ message?: string;
596
649
  }
597
- interface CoverageOptions {
598
- docsDir?: string;
599
- sourceDir?: string;
600
- excludePatterns?: string[];
650
+ interface CodePattern {
651
+ name: string;
652
+ description: string;
653
+ severity: 'error' | 'warning';
654
+ check: (file: SourceFile, snapshot: CodebaseSnapshot) => PatternMatch[];
601
655
  }
602
- interface BrokenLink {
603
- text: string;
604
- path: string;
656
+ interface PatternMatch {
605
657
  line: number;
606
- section: string;
607
- reason: 'NOT_FOUND' | 'PERMISSION_DENIED' | 'INVALID_PATH';
608
- suggestion: string;
658
+ column?: number;
659
+ message: string;
660
+ suggestion?: string;
609
661
  }
610
- interface IntegrityReport {
611
- totalLinks: number;
612
- brokenLinks: BrokenLink[];
613
- validLinks: number;
614
- integrity: number;
662
+ interface PatternConfig {
663
+ patterns: ConfigPattern[];
664
+ customPatterns?: CodePattern[];
665
+ ignoreFiles?: string[];
615
666
  }
616
- interface GenerationSection {
617
- name: string;
667
+ interface PatternViolation {
618
668
  pattern: string;
619
- description: string;
669
+ file: string;
670
+ line: number;
671
+ column?: number;
672
+ severity: 'error' | 'warning';
673
+ message: string;
674
+ suggestion?: string;
620
675
  }
621
- interface AgentsMapConfig {
622
- rootDir: string;
623
- includePaths: string[];
624
- excludePaths: string[];
625
- template?: string;
626
- sections?: GenerationSection[];
676
+ interface PatternReport {
677
+ violations: PatternViolation[];
678
+ stats: {
679
+ filesChecked: number;
680
+ patternsApplied: number;
681
+ violationCount: number;
682
+ errorCount: number;
683
+ warningCount: number;
684
+ };
685
+ passRate: number;
627
686
  }
628
- declare const REQUIRED_SECTIONS: readonly ["Project Overview", "Repository Structure", "Development Workflow"];
629
-
630
- interface ExtractedLink {
631
- text: string;
632
- path: string;
633
- line: number;
687
+ type FixType = 'unused-imports' | 'dead-files' | 'trailing-whitespace' | 'broken-links' | 'sort-imports';
688
+ interface FixConfig {
689
+ dryRun: boolean;
690
+ fixTypes: FixType[];
691
+ createBackup: boolean;
692
+ backupDir?: string;
634
693
  }
635
- /**
636
- * Extract markdown links from content
637
- * Pattern: [text](path)
638
- */
639
- declare function extractMarkdownLinks(content: string): ExtractedLink[];
640
- /**
641
- * Extract sections from markdown content
642
- * Pattern: # Heading or ## Heading etc.
643
- */
644
- declare function extractSections(content: string): AgentMapSection[];
645
- /**
646
- * Validate an AGENTS.md file
647
- * - Parses sections and links
648
- * - Checks for required sections
649
- * - Verifies all links point to existing files
650
- */
651
- declare function validateAgentsMap(path?: string): Promise<Result<AgentMapValidation, ContextError>>;
652
-
653
- /**
654
- * Check documentation coverage for a domain
655
- */
656
- declare function checkDocCoverage(domain: string, options?: CoverageOptions): Promise<Result<CoverageReport, ContextError>>;
657
-
658
- /**
659
- * Validate knowledge map integrity (all links in AGENTS.md and docs)
660
- */
661
- declare function validateKnowledgeMap(rootDir?: string): Promise<Result<IntegrityReport, ContextError>>;
662
-
663
- /**
664
- * Generate AGENTS.md content from project structure
665
- */
666
- declare function generateAgentsMap(config: AgentsMapConfig): Promise<Result<string, ContextError>>;
667
-
668
- interface TokenBudget {
669
- total: number;
670
- systemPrompt: number;
671
- projectManifest: number;
672
- taskSpec: number;
673
- activeCode: number;
674
- interfaces: number;
675
- reserve: number;
694
+ interface Fix {
695
+ type: FixType;
696
+ file: string;
697
+ description: string;
698
+ action: 'delete-file' | 'delete-lines' | 'replace' | 'insert';
699
+ line?: number;
700
+ oldContent?: string;
701
+ newContent?: string;
702
+ safe: true;
703
+ reversible: boolean;
676
704
  }
677
- interface TokenBudgetOverrides {
678
- systemPrompt?: number;
679
- projectManifest?: number;
680
- taskSpec?: number;
681
- activeCode?: number;
682
- interfaces?: number;
683
- reserve?: number;
705
+ interface FixResult {
706
+ applied: Fix[];
707
+ skipped: Fix[];
708
+ errors: {
709
+ fix: Fix;
710
+ error: string;
711
+ }[];
712
+ stats: {
713
+ filesModified: number;
714
+ filesDeleted: number;
715
+ linesRemoved: number;
716
+ backupPath?: string;
717
+ };
684
718
  }
685
-
686
- declare function contextBudget(totalTokens: number, overrides?: TokenBudgetOverrides): TokenBudget;
687
-
688
- type WorkflowPhase = 'implement' | 'review' | 'debug' | 'plan';
689
- interface FileCategory {
690
- category: string;
691
- patterns: string[];
692
- priority: number;
719
+ interface Suggestion {
720
+ type: 'rename' | 'move' | 'merge' | 'split' | 'delete' | 'update-docs' | 'add-export' | 'refactor';
721
+ priority: 'high' | 'medium' | 'low';
722
+ source: 'drift' | 'dead-code' | 'pattern';
723
+ relatedIssues: string[];
724
+ title: string;
725
+ description: string;
726
+ files: string[];
727
+ steps: string[];
728
+ preview?: {
729
+ file: string;
730
+ diff: string;
731
+ };
732
+ whyManual: string;
693
733
  }
694
- interface ContextFilterResult {
695
- phase: WorkflowPhase;
696
- includedCategories: string[];
697
- excludedCategories: string[];
698
- filePatterns: string[];
734
+ interface SuggestionReport {
735
+ suggestions: Suggestion[];
736
+ byPriority: {
737
+ high: Suggestion[];
738
+ medium: Suggestion[];
739
+ low: Suggestion[];
740
+ };
741
+ estimatedEffort: 'trivial' | 'small' | 'medium' | 'large';
742
+ }
743
+ interface AnalysisError {
744
+ analyzer: 'drift' | 'deadCode' | 'patterns';
745
+ error: EntropyError;
746
+ }
747
+ interface EntropyReport {
748
+ snapshot: CodebaseSnapshot;
749
+ drift?: DriftReport;
750
+ deadCode?: DeadCodeReport;
751
+ patterns?: PatternReport;
752
+ analysisErrors: AnalysisError[];
753
+ summary: {
754
+ totalIssues: number;
755
+ errors: number;
756
+ warnings: number;
757
+ fixableCount: number;
758
+ suggestionCount: number;
759
+ };
760
+ timestamp: string;
761
+ duration: number;
699
762
  }
700
-
701
- declare function contextFilter(phase: WorkflowPhase, maxCategories?: number): ContextFilterResult;
702
- declare function getPhaseCategories(phase: WorkflowPhase): FileCategory[];
703
-
704
- /**
705
- * Create a layer definition
706
- */
707
- declare function defineLayer(name: string, patterns: string[], allowedDependencies: string[]): Layer;
708
- /**
709
- * Resolve a file path to its layer
710
- */
711
- declare function resolveFileToLayer(file: string, layers: Layer[]): Layer | undefined;
712
-
713
- /**
714
- * Build a dependency graph from a list of files
715
- * Note: buildDependencyGraph is exported as an addition beyond spec for advanced use cases
716
- */
717
- declare function buildDependencyGraph(files: string[], parser: LanguageParser): Promise<Result<DependencyGraph, ConstraintError>>;
718
- /**
719
- * Validate dependencies against layer rules
720
- */
721
- declare function validateDependencies(config: LayerConfig): Promise<Result<DependencyValidation, ConstraintError>>;
722
-
723
- /**
724
- * Detect circular dependencies in a dependency graph
725
- */
726
- declare function detectCircularDeps(graph: DependencyGraph): Result<CircularDepsResult, ConstraintError>;
727
- /**
728
- * Detect circular dependencies from a list of files
729
- */
730
- declare function detectCircularDepsInFiles(files: string[], parser: LanguageParser): Promise<Result<CircularDepsResult, ConstraintError>>;
731
-
732
- /**
733
- * Create a boundary validator from a Zod schema
734
- */
735
- declare function createBoundaryValidator<T>(schema: z.ZodSchema<T>, name: string): BoundaryValidator<T>;
736
- /**
737
- * Validate multiple boundaries at once
738
- */
739
- declare function validateBoundaries(boundaries: BoundaryDefinition[], data: Map<string, unknown>): Result<BoundaryValidation, ConstraintError>;
740
763
 
741
764
  /**
742
765
  * Main entropy analysis orchestrator
@@ -747,9 +770,29 @@ declare class EntropyAnalyzer {
747
770
  private report?;
748
771
  constructor(config: EntropyConfig);
749
772
  /**
750
- * Run full entropy analysis
773
+ * Run full entropy analysis.
774
+ * When graphOptions is provided, passes graph data to drift and dead code detectors
775
+ * for graph-enhanced analysis instead of snapshot-based analysis.
751
776
  */
752
- analyze(): Promise<Result<EntropyReport, EntropyError>>;
777
+ analyze(graphOptions?: {
778
+ graphDriftData?: {
779
+ staleEdges: Array<{
780
+ docNodeId: string;
781
+ codeNodeId: string;
782
+ edgeType: string;
783
+ }>;
784
+ missingTargets: string[];
785
+ };
786
+ graphDeadCodeData?: {
787
+ reachableNodeIds: Set<string> | string[];
788
+ unreachableNodes: Array<{
789
+ id: string;
790
+ type: string;
791
+ name: string;
792
+ path?: string;
793
+ }>;
794
+ };
795
+ }): Promise<Result<EntropyReport, EntropyError>>;
753
796
  /**
754
797
  * Get the built snapshot (must call analyze first)
755
798
  */
@@ -773,11 +816,26 @@ declare class EntropyAnalyzer {
773
816
  /**
774
817
  * Run drift detection only (snapshot must be built first)
775
818
  */
776
- detectDrift(config?: Partial<DriftConfig>): Promise<Result<DriftReport, EntropyError>>;
819
+ detectDrift(config?: Partial<DriftConfig>, graphDriftData?: {
820
+ staleEdges: Array<{
821
+ docNodeId: string;
822
+ codeNodeId: string;
823
+ edgeType: string;
824
+ }>;
825
+ missingTargets: string[];
826
+ }): Promise<Result<DriftReport, EntropyError>>;
777
827
  /**
778
828
  * Run dead code detection only (snapshot must be built first)
779
829
  */
780
- detectDeadCode(): Promise<Result<DeadCodeReport, EntropyError>>;
830
+ detectDeadCode(graphDeadCodeData?: {
831
+ reachableNodeIds: Set<string> | string[];
832
+ unreachableNodes: Array<{
833
+ id: string;
834
+ type: string;
835
+ name: string;
836
+ path?: string;
837
+ }>;
838
+ }): Promise<Result<DeadCodeReport, EntropyError>>;
781
839
  /**
782
840
  * Run pattern detection only (snapshot must be built first)
783
841
  */
@@ -790,15 +848,32 @@ declare class EntropyAnalyzer {
790
848
  declare function buildSnapshot(config: EntropyConfig): Promise<Result<CodebaseSnapshot, EntropyError>>;
791
849
 
792
850
  /**
793
- * Detect documentation drift in a codebase
851
+ * Detect documentation drift in a codebase.
852
+ * When graphDriftData is provided, uses graph-derived edges instead of snapshot-based analysis.
794
853
  */
795
- declare function detectDocDrift(snapshot: CodebaseSnapshot, config?: Partial<DriftConfig>): Promise<Result<DriftReport, EntropyError>>;
854
+ declare function detectDocDrift(snapshot: CodebaseSnapshot, config?: Partial<DriftConfig>, graphDriftData?: {
855
+ staleEdges: Array<{
856
+ docNodeId: string;
857
+ codeNodeId: string;
858
+ edgeType: string;
859
+ }>;
860
+ missingTargets: string[];
861
+ }): Promise<Result<DriftReport, EntropyError>>;
796
862
 
797
863
  /**
798
864
  * Detect dead code in a codebase snapshot.
799
865
  * Analyzes exports, files, imports, and internal symbols to find unused code.
866
+ * When graphDeadCodeData is provided, uses graph-derived reachability instead of snapshot-based BFS.
800
867
  */
801
- declare function detectDeadCode(snapshot: CodebaseSnapshot): Promise<Result<DeadCodeReport, EntropyError>>;
868
+ declare function detectDeadCode(snapshot: CodebaseSnapshot, graphDeadCodeData?: {
869
+ reachableNodeIds: Set<string> | string[];
870
+ unreachableNodes: Array<{
871
+ id: string;
872
+ type: string;
873
+ name: string;
874
+ path?: string;
875
+ }>;
876
+ }): Promise<Result<DeadCodeReport, EntropyError>>;
802
877
 
803
878
  /**
804
879
  * Detect pattern violations across a codebase
@@ -1859,6 +1934,31 @@ interface ActionSink {
1859
1934
  flush?(): Promise<Result<void, FeedbackError>>;
1860
1935
  close?(): Promise<void>;
1861
1936
  }
1937
+ /**
1938
+ * Pre-computed impact data from graph — enriches diff analysis.
1939
+ */
1940
+ interface GraphImpactData {
1941
+ affectedTests: Array<{
1942
+ testFile: string;
1943
+ coversFile: string;
1944
+ }>;
1945
+ affectedDocs: Array<{
1946
+ docFile: string;
1947
+ documentsFile: string;
1948
+ }>;
1949
+ impactScope: number;
1950
+ }
1951
+ /**
1952
+ * Pre-computed harness check data from graph — replaces placeholders.
1953
+ */
1954
+ interface GraphHarnessCheckData {
1955
+ graphExists: boolean;
1956
+ nodeCount: number;
1957
+ edgeCount: number;
1958
+ constraintViolations: number;
1959
+ undocumentedFiles: number;
1960
+ unreachableNodes: number;
1961
+ }
1862
1962
  interface ActionTracker {
1863
1963
  readonly action: AgentAction;
1864
1964
  complete(result: ActionResult): Promise<Result<AgentAction, FeedbackError>>;
@@ -1883,20 +1983,25 @@ declare function resetFeedbackConfig(): void;
1883
1983
  declare class ChecklistBuilder {
1884
1984
  private rootDir;
1885
1985
  private harnessOptions?;
1986
+ private graphHarnessData?;
1886
1987
  private customRules;
1887
1988
  private diffOptions?;
1989
+ private graphImpactData?;
1888
1990
  constructor(rootDir: string);
1889
- withHarnessChecks(options?: SelfReviewConfig['harness']): this;
1991
+ withHarnessChecks(options?: SelfReviewConfig['harness'], graphData?: GraphHarnessCheckData): this;
1890
1992
  addRule(rule: CustomRule): this;
1891
1993
  addRules(rules: CustomRule[]): this;
1892
- withDiffAnalysis(options: SelfReviewConfig['diffAnalysis']): this;
1994
+ withDiffAnalysis(options: SelfReviewConfig['diffAnalysis'], graphImpactData?: GraphImpactData): this;
1893
1995
  run(changes: CodeChanges): Promise<Result<ReviewChecklist, FeedbackError>>;
1894
1996
  }
1895
1997
 
1896
- declare function createSelfReview(changes: CodeChanges, config: SelfReviewConfig): Promise<Result<ReviewChecklist, FeedbackError>>;
1998
+ declare function createSelfReview(changes: CodeChanges, config: SelfReviewConfig, graphData?: {
1999
+ impact?: GraphImpactData;
2000
+ harness?: GraphHarnessCheckData;
2001
+ }): Promise<Result<ReviewChecklist, FeedbackError>>;
1897
2002
 
1898
2003
  declare function parseDiff(diff: string): Result<CodeChanges, FeedbackError>;
1899
- declare function analyzeDiff(changes: CodeChanges, options: SelfReviewConfig['diffAnalysis']): Promise<Result<ReviewItem[], FeedbackError>>;
2004
+ declare function analyzeDiff(changes: CodeChanges, options: SelfReviewConfig['diffAnalysis'], graphImpactData?: GraphImpactData): Promise<Result<ReviewItem[], FeedbackError>>;
1900
2005
 
1901
2006
  declare function requestPeerReview(agentType: AgentType, context: ReviewContext, options?: PeerReviewOptions): Promise<Result<PeerReview, FeedbackError>>;
1902
2007
  declare function requestMultiplePeerReviews(requests: Array<{
@@ -2113,11 +2218,11 @@ declare const HarnessStateSchema: z.ZodObject<{
2113
2218
  phase: z.ZodOptional<z.ZodString>;
2114
2219
  task: z.ZodOptional<z.ZodString>;
2115
2220
  }, "strip", z.ZodTypeAny, {
2116
- phase?: string | undefined;
2117
2221
  task?: string | undefined;
2118
- }, {
2119
2222
  phase?: string | undefined;
2223
+ }, {
2120
2224
  task?: string | undefined;
2225
+ phase?: string | undefined;
2121
2226
  }>>;
2122
2227
  decisions: z.ZodDefault<z.ZodArray<z.ZodObject<{
2123
2228
  date: z.ZodString;
@@ -2175,8 +2280,8 @@ declare const HarnessStateSchema: z.ZodObject<{
2175
2280
  }[];
2176
2281
  schemaVersion: 1;
2177
2282
  position: {
2178
- phase?: string | undefined;
2179
2283
  task?: string | undefined;
2284
+ phase?: string | undefined;
2180
2285
  };
2181
2286
  progress: Record<string, "pending" | "in_progress" | "complete">;
2182
2287
  lastSession?: {
@@ -2198,8 +2303,8 @@ declare const HarnessStateSchema: z.ZodObject<{
2198
2303
  description: string;
2199
2304
  }[] | undefined;
2200
2305
  position?: {
2201
- phase?: string | undefined;
2202
2306
  task?: string | undefined;
2307
+ phase?: string | undefined;
2203
2308
  } | undefined;
2204
2309
  progress?: Record<string, "pending" | "in_progress" | "complete"> | undefined;
2205
2310
  lastSession?: {
@@ -2267,4 +2372,4 @@ declare function runCIChecks(input: RunCIChecksInput): Promise<Result<CICheckRep
2267
2372
 
2268
2373
  declare const VERSION = "0.6.0";
2269
2374
 
2270
- export { type AST, type ActionContext, type ActionEvent, type ActionEventHandler, type ActionEventType, type ActionResult, type ActionSink, type ActionTracker, type ActionType, type AgentAction, AgentActionEmitter, type AgentConfig, type AgentExecutor, type AgentMapLink, type AgentMapSection, type AgentMapValidation, type AgentProcess, type AgentType, type AgentsMapConfig, type BaseError, type BoundaryDefinition, type BoundaryValidation, type BoundaryValidator, type BoundaryViolation, type BrokenLink, type ChangedFile, ChecklistBuilder, type CircularDependency, type CircularDepsResult, type CodeBlock, type CodeChanges, type CodePattern, type CodeReference, type CodebaseSnapshot, type CommitFormat, type CommitValidation, type ConfigError, type ConfigPattern, ConsoleSink, type ConstraintError, type ContextError, type ContextFilterResult, type Convention, type CoverageOptions, type CoverageReport, type CustomRule, type CustomRuleResult, DEFAULT_STATE, type DeadCodeConfig, type DeadCodeReport, type DeadExport, type DeadFile, type DeadInternal, type DependencyEdge, type DependencyGraph, type DependencyValidation, type DependencyViolation, type DocumentationDrift, type DocumentationFile, type DocumentationGap, type DriftConfig, type DriftReport, EntropyAnalyzer, type EntropyConfig, EntropyConfigSchema, type EntropyError, type EntropyReport, type ExecutorHealth, type Export, type ExportMap, type FailureEntry, FailureEntrySchema, type FeedbackConfig, type FeedbackError$1 as FeedbackError, type FileCategory, FileSink, type Fix, type FixConfig, type FixResult, type FixType, type ForbiddenPattern, type GateConfig, GateConfigSchema, type GateResult, GateResultSchema, type GenerationSection, type Handoff, HandoffSchema, type HarnessState, HarnessStateSchema, type HealthCheckResult, type Import, type InlineReference, type IntegrityReport, type InternalSymbol, type JSDocComment, type LanguageParser, type Layer, type LayerConfig, type LogEntry, type LogFilter, type Metric, NoOpExecutor, NoOpSink, NoOpTelemetryAdapter, type ParseError, type PatternConfig, PatternConfigSchema, type PatternMatch, type PatternReport, type PatternViolation, type PeerReview, type PeerReviewOptions, type PipelineOptions, type PipelineResult, REQUIRED_SECTIONS, type ReachabilityNode, type ReviewChecklist, type ReviewComment, type ReviewContext, type ReviewItem, type RunCIChecksInput, type SelfReviewConfig, type SkillExecutor, type SourceFile, type Span, type SpanEvent, type StepExecutor, type StructureValidation, type Suggestion, type SuggestionReport, type TelemetryAdapter, type TelemetryHealth, type TimeRange, type TokenBudget, type TokenBudgetOverrides, type Trace, type TurnExecutor, TypeScriptParser, type UnusedImport, VERSION, type ValidationError, type WorkflowPhase, analyzeDiff, appendFailure, appendLearning, applyFixes, archiveFailures, buildDependencyGraph, buildSnapshot, checkDocCoverage, configureFeedback, contextBudget, contextFilter, createBoundaryValidator, createError, createFixes, createParseError, createSelfReview, defineLayer, detectCircularDeps, detectCircularDepsInFiles, detectDeadCode, detectDocDrift, detectPatternViolations, executeWorkflow, extractMarkdownLinks, extractSections, generateAgentsMap, generateSuggestions, getActionEmitter, getFeedbackConfig, getPhaseCategories, loadFailures, loadHandoff, loadRelevantLearnings, loadState, logAgentAction, parseDiff, previewFix, requestMultiplePeerReviews, requestPeerReview, resetFeedbackConfig, resolveFileToLayer, runCIChecks, runMechanicalGate, runMultiTurnPipeline, runPipeline, saveHandoff, saveState, trackAction, validateAgentsMap, validateBoundaries, validateCommitMessage, validateConfig, validateDependencies, validateFileStructure, validateKnowledgeMap, validatePatternConfig };
2375
+ export { type AST, type ActionContext, type ActionEvent, type ActionEventHandler, type ActionEventType, type ActionResult, type ActionSink, type ActionTracker, type ActionType, type AgentAction, AgentActionEmitter, type AgentConfig, type AgentExecutor, type AgentMapLink, type AgentMapSection, type AgentMapValidation, type AgentProcess, type AgentType, type AgentsMapConfig, type BaseError, type BoundaryDefinition, type BoundaryValidation, type BoundaryValidator, type BoundaryViolation, type BrokenLink, type ChangedFile, ChecklistBuilder, type CircularDependency, type CircularDepsResult, type CodeBlock, type CodeChanges, type CodePattern, type CodeReference, type CodebaseSnapshot, type CommitFormat, type CommitValidation, type ConfigError, type ConfigPattern, ConsoleSink, type ConstraintError, type ContextError, type ContextFilterResult, type Convention, type CoverageOptions, type CoverageReport, type CustomRule, type CustomRuleResult, DEFAULT_STATE, type DeadCodeConfig, type DeadCodeReport, type DeadExport, type DeadFile, type DeadInternal, type DependencyEdge, type DependencyGraph, type DependencyValidation, type DependencyViolation, type DocumentationDrift, type DocumentationFile, type DocumentationGap, type DriftConfig, type DriftReport, EntropyAnalyzer, type EntropyConfig, EntropyConfigSchema, type EntropyError, type EntropyReport, type ExecutorHealth, type Export, type ExportMap, type FailureEntry, FailureEntrySchema, type FeedbackConfig, type FeedbackError$1 as FeedbackError, type FileCategory, FileSink, type Fix, type FixConfig, type FixResult, type FixType, type ForbiddenPattern, type GateConfig, GateConfigSchema, type GateResult, GateResultSchema, type GenerationSection, type GraphCoverageData, type GraphDependencyData, type GraphHarnessCheckData, type GraphImpactData, type Handoff, HandoffSchema, type HarnessState, HarnessStateSchema, type HealthCheckResult, type Import, type InlineReference, type IntegrityReport, type InternalSymbol, type JSDocComment, type LanguageParser, type Layer, type LayerConfig, type LogEntry, type LogFilter, type Metric, NoOpExecutor, NoOpSink, NoOpTelemetryAdapter, type ParseError, type PatternConfig, PatternConfigSchema, type PatternMatch, type PatternReport, type PatternViolation, type PeerReview, type PeerReviewOptions, type PipelineOptions, type PipelineResult, REQUIRED_SECTIONS, type ReachabilityNode, type ReviewChecklist, type ReviewComment, type ReviewContext, type ReviewItem, type RunCIChecksInput, type SelfReviewConfig, type SkillExecutor, type SourceFile, type Span, type SpanEvent, type StepExecutor, type StructureValidation, type Suggestion, type SuggestionReport, type TelemetryAdapter, type TelemetryHealth, type TimeRange, type TokenBudget, type TokenBudgetOverrides, type Trace, type TurnExecutor, TypeScriptParser, type UnusedImport, VERSION, type ValidationError, type WorkflowPhase, analyzeDiff, appendFailure, appendLearning, applyFixes, archiveFailures, buildDependencyGraph, buildSnapshot, checkDocCoverage, configureFeedback, contextBudget, contextFilter, createBoundaryValidator, createError, createFixes, createParseError, createSelfReview, defineLayer, detectCircularDeps, detectCircularDepsInFiles, detectDeadCode, detectDocDrift, detectPatternViolations, executeWorkflow, extractMarkdownLinks, extractSections, generateAgentsMap, generateSuggestions, getActionEmitter, getFeedbackConfig, getPhaseCategories, loadFailures, loadHandoff, loadRelevantLearnings, loadState, logAgentAction, parseDiff, previewFix, requestMultiplePeerReviews, requestPeerReview, resetFeedbackConfig, resolveFileToLayer, runCIChecks, runMechanicalGate, runMultiTurnPipeline, runPipeline, saveHandoff, saveState, trackAction, validateAgentsMap, validateBoundaries, validateCommitMessage, validateConfig, validateDependencies, validateFileStructure, validateKnowledgeMap, validatePatternConfig };