@harness-engineering/core 0.5.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.
@@ -0,0 +1,2310 @@
1
+ import { WorkflowStep, WorkflowStepResult, Workflow, WorkflowResult, SkillLifecycleHooks, SkillContext, SkillResult, TurnContext } from '@harness-engineering/types';
2
+ export * from '@harness-engineering/types';
3
+ import { z } from 'zod';
4
+
5
+ type Result<T, E = Error> = {
6
+ ok: true;
7
+ value: T;
8
+ } | {
9
+ ok: false;
10
+ error: E;
11
+ };
12
+ declare const Ok: <T>(value: T) => Result<T, never>;
13
+ declare function isOk<T, E>(result: Result<T, E>): result is {
14
+ ok: true;
15
+ value: T;
16
+ };
17
+ declare const Err: <E>(error: E) => Result<never, E>;
18
+ declare function isErr<T, E>(result: Result<T, E>): result is {
19
+ ok: false;
20
+ error: E;
21
+ };
22
+
23
+ /**
24
+ * Abstract Syntax Tree representation
25
+ */
26
+ interface AST {
27
+ type: string;
28
+ body: unknown;
29
+ language: string;
30
+ }
31
+ /**
32
+ * Source code location
33
+ */
34
+ interface Location {
35
+ file: string;
36
+ line: number;
37
+ column: number;
38
+ }
39
+ /**
40
+ * Import declaration extracted from source
41
+ */
42
+ interface Import {
43
+ source: string;
44
+ specifiers: string[];
45
+ default?: string;
46
+ namespace?: string;
47
+ location: Location;
48
+ kind: 'value' | 'type';
49
+ }
50
+ /**
51
+ * Export declaration extracted from source
52
+ */
53
+ interface Export {
54
+ name: string;
55
+ type: 'named' | 'default' | 'namespace';
56
+ location: Location;
57
+ isReExport: boolean;
58
+ source?: string;
59
+ }
60
+ /**
61
+ * Parser error with structured details
62
+ */
63
+ interface ParseError extends BaseError {
64
+ code: 'TIMEOUT' | 'SUBPROCESS_FAILED' | 'SYNTAX_ERROR' | 'NOT_FOUND' | 'PARSER_UNAVAILABLE';
65
+ details: {
66
+ exitCode?: number;
67
+ stderr?: string;
68
+ path?: string;
69
+ parser?: string;
70
+ };
71
+ }
72
+ /**
73
+ * Health check result indicating parser availability
74
+ */
75
+ interface HealthCheckResult {
76
+ available: boolean;
77
+ version?: string;
78
+ message?: string;
79
+ }
80
+ /**
81
+ * Language-agnostic parser interface
82
+ * Implementations provide language-specific parsing
83
+ */
84
+ interface LanguageParser {
85
+ name: string;
86
+ extensions: string[];
87
+ parseFile(path: string): Promise<Result<AST, ParseError>>;
88
+ extractImports(ast: AST): Result<Import[], ParseError>;
89
+ extractExports(ast: AST): Result<Export[], ParseError>;
90
+ health(): Promise<Result<HealthCheckResult, ParseError>>;
91
+ }
92
+ /**
93
+ * Create a ParseError with standard structure
94
+ */
95
+ declare function createParseError(code: ParseError['code'], message: string, details?: ParseError['details'], suggestions?: string[]): ParseError;
96
+
97
+ declare class TypeScriptParser implements LanguageParser {
98
+ name: string;
99
+ extensions: string[];
100
+ parseFile(path: string): Promise<Result<AST, ParseError>>;
101
+ extractImports(ast: AST): Result<Import[], ParseError>;
102
+ extractExports(ast: AST): Result<Export[], ParseError>;
103
+ health(): Promise<Result<HealthCheckResult, ParseError>>;
104
+ }
105
+
106
+ interface Layer {
107
+ name: string;
108
+ patterns: string[];
109
+ allowedDependencies: string[];
110
+ }
111
+ interface LayerConfig {
112
+ layers: Layer[];
113
+ rootDir: string;
114
+ parser: LanguageParser;
115
+ fallbackBehavior?: 'skip' | 'error' | 'warn';
116
+ }
117
+ interface DependencyEdge {
118
+ from: string;
119
+ to: string;
120
+ importType: 'static' | 'dynamic' | 'type-only';
121
+ line: number;
122
+ }
123
+ interface DependencyGraph {
124
+ nodes: string[];
125
+ edges: DependencyEdge[];
126
+ }
127
+ interface DependencyViolation {
128
+ file: string;
129
+ imports: string;
130
+ fromLayer: string;
131
+ toLayer: string;
132
+ reason: 'WRONG_LAYER' | 'CIRCULAR_DEP' | 'FORBIDDEN_IMPORT';
133
+ line: number;
134
+ suggestion: string;
135
+ }
136
+ interface DependencyValidation {
137
+ valid: boolean;
138
+ violations: DependencyViolation[];
139
+ graph: DependencyGraph;
140
+ skipped?: boolean;
141
+ reason?: string;
142
+ }
143
+ interface CircularDependency {
144
+ cycle: string[];
145
+ severity: 'error' | 'warning';
146
+ size: number;
147
+ }
148
+ interface CircularDepsResult {
149
+ hasCycles: boolean;
150
+ cycles: CircularDependency[];
151
+ largestCycle: number;
152
+ }
153
+ interface BoundaryDefinition {
154
+ name: string;
155
+ layer: string;
156
+ schema: z.ZodSchema<unknown>;
157
+ direction: 'input' | 'output';
158
+ }
159
+ interface BoundaryViolation {
160
+ boundary: string;
161
+ direction: 'input' | 'output';
162
+ error: z.ZodError;
163
+ data: unknown;
164
+ }
165
+ interface BoundaryValidation {
166
+ valid: boolean;
167
+ violations: BoundaryViolation[];
168
+ }
169
+ interface BoundaryValidator<T> {
170
+ name: string;
171
+ parse(input: unknown): Result<T, ConstraintError>;
172
+ validate(input: unknown): Result<boolean, ConstraintError>;
173
+ schema: z.ZodSchema<T>;
174
+ }
175
+
176
+ interface EntropyError extends BaseError {
177
+ code: 'SNAPSHOT_BUILD_FAILED' | 'PARSE_ERROR' | 'ENTRY_POINT_NOT_FOUND' | 'INVALID_CONFIG' | 'CONFIG_VALIDATION_ERROR' | 'FIX_FAILED' | 'BACKUP_FAILED';
178
+ details: {
179
+ file?: string;
180
+ reason?: string;
181
+ issues?: unknown[];
182
+ originalError?: Error;
183
+ };
184
+ }
185
+ interface InternalSymbol {
186
+ name: string;
187
+ type: 'function' | 'class' | 'variable' | 'type';
188
+ line: number;
189
+ references: number;
190
+ calledBy: string[];
191
+ }
192
+ interface JSDocComment {
193
+ content: string;
194
+ line: number;
195
+ associatedSymbol?: string;
196
+ }
197
+ interface CodeBlock {
198
+ language: string;
199
+ content: string;
200
+ line: number;
201
+ }
202
+ interface InlineReference {
203
+ reference: string;
204
+ line: number;
205
+ column: number;
206
+ }
207
+ interface SourceFile {
208
+ path: string;
209
+ ast: AST;
210
+ imports: Import[];
211
+ exports: Export[];
212
+ internalSymbols: InternalSymbol[];
213
+ jsDocComments: JSDocComment[];
214
+ }
215
+ interface DocumentationFile {
216
+ path: string;
217
+ type: 'markdown' | 'jsdoc' | 'typedoc' | 'text';
218
+ content: string;
219
+ codeBlocks: CodeBlock[];
220
+ inlineRefs: InlineReference[];
221
+ }
222
+ interface CodeReference {
223
+ docFile: string;
224
+ line: number;
225
+ column: number;
226
+ reference: string;
227
+ context: 'code-block' | 'inline' | 'link' | 'jsdoc';
228
+ resolvedTo?: string;
229
+ }
230
+ interface ExportMap {
231
+ byFile: Map<string, Export[]>;
232
+ byName: Map<string, {
233
+ file: string;
234
+ export: Export;
235
+ }[]>;
236
+ }
237
+ interface CodebaseSnapshot {
238
+ files: SourceFile[];
239
+ dependencyGraph: DependencyGraph;
240
+ exportMap: ExportMap;
241
+ docs: DocumentationFile[];
242
+ codeReferences: CodeReference[];
243
+ entryPoints: string[];
244
+ rootDir: string;
245
+ config: EntropyConfig;
246
+ buildTime: number;
247
+ }
248
+ interface DriftConfig {
249
+ docPaths: string[];
250
+ checkApiSignatures: boolean;
251
+ checkExamples: boolean;
252
+ checkStructure: boolean;
253
+ ignorePatterns: string[];
254
+ }
255
+ interface DeadCodeConfig {
256
+ entryPoints?: string[];
257
+ includeTypes: boolean;
258
+ includeInternals: boolean;
259
+ ignorePatterns: string[];
260
+ treatDynamicImportsAs: 'used' | 'unknown';
261
+ }
262
+ interface EntropyConfig {
263
+ rootDir: string;
264
+ parser?: LanguageParser;
265
+ entryPoints?: string[];
266
+ analyze: {
267
+ drift?: boolean | Partial<DriftConfig>;
268
+ deadCode?: boolean | Partial<DeadCodeConfig>;
269
+ patterns?: boolean | PatternConfig;
270
+ };
271
+ include?: string[];
272
+ exclude?: string[];
273
+ docPaths?: string[];
274
+ }
275
+ interface DocumentationDrift {
276
+ type: 'api-signature' | 'example-code' | 'structure';
277
+ docFile: string;
278
+ line: number;
279
+ reference: string;
280
+ context: string;
281
+ issue: 'NOT_FOUND' | 'RENAMED' | 'SIGNATURE_CHANGED' | 'SYNTAX_ERROR' | 'IMPORT_ERROR';
282
+ details: string;
283
+ suggestion?: string;
284
+ possibleMatches?: string[];
285
+ confidence: 'high' | 'medium' | 'low';
286
+ }
287
+ interface DriftReport {
288
+ drifts: DocumentationDrift[];
289
+ stats: {
290
+ docsScanned: number;
291
+ referencesChecked: number;
292
+ driftsFound: number;
293
+ byType: {
294
+ api: number;
295
+ example: number;
296
+ structure: number;
297
+ };
298
+ };
299
+ severity: 'high' | 'medium' | 'low' | 'none';
300
+ }
301
+ interface DeadExport {
302
+ file: string;
303
+ name: string;
304
+ line: number;
305
+ type: 'function' | 'class' | 'variable' | 'type' | 'interface' | 'enum';
306
+ isDefault: boolean;
307
+ reason: 'NO_IMPORTERS' | 'IMPORTERS_ALSO_DEAD';
308
+ }
309
+ interface DeadFile {
310
+ path: string;
311
+ reason: 'NO_IMPORTERS' | 'NOT_ENTRY_POINT' | 'ALL_EXPORTS_DEAD';
312
+ exportCount: number;
313
+ lineCount: number;
314
+ }
315
+ interface DeadInternal {
316
+ file: string;
317
+ name: string;
318
+ line: number;
319
+ type: 'function' | 'class' | 'variable';
320
+ reason: 'NEVER_CALLED' | 'ONLY_CALLED_BY_DEAD';
321
+ }
322
+ interface UnusedImport {
323
+ file: string;
324
+ line: number;
325
+ source: string;
326
+ specifiers: string[];
327
+ isFullyUnused: boolean;
328
+ }
329
+ interface ReachabilityNode {
330
+ file: string;
331
+ reachable: boolean;
332
+ importedBy: string[];
333
+ imports: string[];
334
+ }
335
+ interface DeadCodeReport {
336
+ deadExports: DeadExport[];
337
+ deadFiles: DeadFile[];
338
+ deadInternals: DeadInternal[];
339
+ unusedImports: UnusedImport[];
340
+ stats: {
341
+ filesAnalyzed: number;
342
+ entryPointsUsed: string[];
343
+ totalExports: number;
344
+ deadExportCount: number;
345
+ totalFiles: number;
346
+ deadFileCount: number;
347
+ estimatedDeadLines: number;
348
+ };
349
+ reachabilityTree?: ReachabilityNode;
350
+ }
351
+ interface ConfigPattern {
352
+ name: string;
353
+ description: string;
354
+ severity: 'error' | 'warning';
355
+ files: string[];
356
+ rule: {
357
+ type: 'must-export';
358
+ names: string[];
359
+ } | {
360
+ type: 'must-export-default';
361
+ kind?: 'class' | 'function' | 'object';
362
+ } | {
363
+ type: 'no-export';
364
+ names: string[];
365
+ } | {
366
+ type: 'must-import';
367
+ from: string;
368
+ names?: string[];
369
+ } | {
370
+ type: 'no-import';
371
+ from: string;
372
+ } | {
373
+ type: 'naming';
374
+ match: string;
375
+ convention: 'camelCase' | 'PascalCase' | 'UPPER_SNAKE' | 'kebab-case';
376
+ } | {
377
+ type: 'max-exports';
378
+ count: number;
379
+ } | {
380
+ type: 'max-lines';
381
+ count: number;
382
+ } | {
383
+ type: 'require-jsdoc';
384
+ for: ('function' | 'class' | 'export')[];
385
+ };
386
+ message?: string;
387
+ }
388
+ interface CodePattern {
389
+ name: string;
390
+ description: string;
391
+ severity: 'error' | 'warning';
392
+ check: (file: SourceFile, snapshot: CodebaseSnapshot) => PatternMatch[];
393
+ }
394
+ interface PatternMatch {
395
+ line: number;
396
+ column?: number;
397
+ message: string;
398
+ suggestion?: string;
399
+ }
400
+ interface PatternConfig {
401
+ patterns: ConfigPattern[];
402
+ customPatterns?: CodePattern[];
403
+ ignoreFiles?: string[];
404
+ }
405
+ interface PatternViolation {
406
+ pattern: string;
407
+ file: string;
408
+ line: number;
409
+ column?: number;
410
+ severity: 'error' | 'warning';
411
+ message: string;
412
+ suggestion?: string;
413
+ }
414
+ interface PatternReport {
415
+ violations: PatternViolation[];
416
+ stats: {
417
+ filesChecked: number;
418
+ patternsApplied: number;
419
+ violationCount: number;
420
+ errorCount: number;
421
+ warningCount: number;
422
+ };
423
+ passRate: number;
424
+ }
425
+ type FixType = 'unused-imports' | 'dead-files' | 'trailing-whitespace' | 'broken-links' | 'sort-imports';
426
+ interface FixConfig {
427
+ dryRun: boolean;
428
+ fixTypes: FixType[];
429
+ createBackup: boolean;
430
+ backupDir?: string;
431
+ }
432
+ interface Fix {
433
+ type: FixType;
434
+ file: string;
435
+ description: string;
436
+ action: 'delete-file' | 'delete-lines' | 'replace' | 'insert';
437
+ line?: number;
438
+ oldContent?: string;
439
+ newContent?: string;
440
+ safe: true;
441
+ reversible: boolean;
442
+ }
443
+ interface FixResult {
444
+ applied: Fix[];
445
+ skipped: Fix[];
446
+ errors: {
447
+ fix: Fix;
448
+ error: string;
449
+ }[];
450
+ stats: {
451
+ filesModified: number;
452
+ filesDeleted: number;
453
+ linesRemoved: number;
454
+ backupPath?: string;
455
+ };
456
+ }
457
+ interface Suggestion {
458
+ type: 'rename' | 'move' | 'merge' | 'split' | 'delete' | 'update-docs' | 'add-export' | 'refactor';
459
+ priority: 'high' | 'medium' | 'low';
460
+ source: 'drift' | 'dead-code' | 'pattern';
461
+ relatedIssues: string[];
462
+ title: string;
463
+ description: string;
464
+ files: string[];
465
+ steps: string[];
466
+ preview?: {
467
+ file: string;
468
+ diff: string;
469
+ };
470
+ whyManual: string;
471
+ }
472
+ interface SuggestionReport {
473
+ suggestions: Suggestion[];
474
+ byPriority: {
475
+ high: Suggestion[];
476
+ medium: Suggestion[];
477
+ low: Suggestion[];
478
+ };
479
+ estimatedEffort: 'trivial' | 'small' | 'medium' | 'large';
480
+ }
481
+ interface AnalysisError {
482
+ analyzer: 'drift' | 'deadCode' | 'patterns';
483
+ error: EntropyError;
484
+ }
485
+ interface EntropyReport {
486
+ snapshot: CodebaseSnapshot;
487
+ drift?: DriftReport;
488
+ deadCode?: DeadCodeReport;
489
+ patterns?: PatternReport;
490
+ analysisErrors: AnalysisError[];
491
+ summary: {
492
+ totalIssues: number;
493
+ errors: number;
494
+ warnings: number;
495
+ fixableCount: number;
496
+ suggestionCount: number;
497
+ };
498
+ timestamp: string;
499
+ duration: number;
500
+ }
501
+
502
+ type ErrorCode = string;
503
+ interface BaseError {
504
+ code: ErrorCode;
505
+ message: string;
506
+ details: Record<string, unknown>;
507
+ suggestions: string[];
508
+ }
509
+ interface ValidationError extends BaseError {
510
+ code: 'INVALID_TYPE' | 'MISSING_FIELD' | 'VALIDATION_FAILED' | 'PARSE_ERROR';
511
+ }
512
+ interface ContextError extends BaseError {
513
+ code: 'PARSE_ERROR' | 'SCHEMA_VIOLATION' | 'MISSING_SECTION' | 'BROKEN_LINK';
514
+ }
515
+ interface ConstraintError extends BaseError {
516
+ code: 'WRONG_LAYER' | 'CIRCULAR_DEP' | 'FORBIDDEN_IMPORT' | 'BOUNDARY_ERROR' | 'PARSER_UNAVAILABLE';
517
+ }
518
+
519
+ interface FeedbackError$1 extends BaseError {
520
+ code: 'AGENT_SPAWN_ERROR' | 'AGENT_TIMEOUT' | 'TELEMETRY_ERROR' | 'TELEMETRY_UNAVAILABLE' | 'REVIEW_ERROR' | 'DIFF_PARSE_ERROR' | 'SINK_ERROR';
521
+ details: {
522
+ agentId?: string;
523
+ service?: string;
524
+ reason?: string;
525
+ originalError?: Error;
526
+ };
527
+ }
528
+ declare function createError<T extends BaseError>(code: T['code'], message: string, details?: Record<string, unknown>, suggestions?: string[]): T;
529
+
530
+ interface Convention {
531
+ pattern: string;
532
+ required: boolean;
533
+ description: string;
534
+ examples: string[];
535
+ }
536
+ interface StructureValidation {
537
+ valid: boolean;
538
+ missing: string[];
539
+ unexpected: string[];
540
+ conformance: number;
541
+ }
542
+ interface ConfigError extends ValidationError {
543
+ code: 'INVALID_TYPE' | 'MISSING_FIELD' | 'VALIDATION_FAILED';
544
+ details: {
545
+ zodError?: unknown;
546
+ path?: string[];
547
+ };
548
+ }
549
+ type CommitFormat = 'conventional' | 'angular' | 'custom';
550
+ interface CommitValidation {
551
+ valid: boolean;
552
+ type?: string;
553
+ scope?: string;
554
+ breaking: boolean;
555
+ issues: string[];
556
+ }
557
+
558
+ declare function validateFileStructure(projectPath: string, conventions: Convention[]): Promise<Result<StructureValidation, ValidationError>>;
559
+
560
+ /**
561
+ * Validates configuration data against a Zod schema
562
+ * Returns a Result type with validated data or ConfigError
563
+ *
564
+ * @template T - The type of data being validated
565
+ * @param data - The configuration data to validate
566
+ * @param schema - Zod schema to validate against
567
+ * @returns Result<T, ConfigError> - Success with validated data or error
568
+ */
569
+ declare function validateConfig<T>(data: unknown, schema: z.ZodSchema<T>): Result<T, ConfigError>;
570
+
571
+ /**
572
+ * Validates a commit message according to the specified format
573
+ * Returns a Result type with validation details
574
+ *
575
+ * @param message - The commit message to validate
576
+ * @param format - The commit format to validate against ('conventional', 'angular', 'custom')
577
+ * @returns Result<CommitValidation, ValidationError> - Success with validation details or error
578
+ */
579
+ declare function validateCommitMessage(message: string, format?: CommitFormat): Result<CommitValidation, ValidationError>;
580
+
581
+ interface AgentMapLink {
582
+ text: string;
583
+ path: string;
584
+ exists: boolean;
585
+ line: number;
586
+ error?: ContextError;
587
+ }
588
+ interface AgentMapSection {
589
+ title: string;
590
+ level: number;
591
+ links: AgentMapLink[];
592
+ description?: string;
593
+ line: number;
594
+ }
595
+ interface AgentMapValidation {
596
+ valid: boolean;
597
+ sections: AgentMapSection[];
598
+ totalLinks: number;
599
+ brokenLinks: AgentMapLink[];
600
+ missingSections: string[];
601
+ errors?: ContextError[];
602
+ }
603
+ interface DocumentationGap {
604
+ file: string;
605
+ suggestedSection: string;
606
+ importance: 'high' | 'medium' | 'low';
607
+ }
608
+ interface CoverageReport {
609
+ domain: string;
610
+ documented: string[];
611
+ undocumented: string[];
612
+ coveragePercentage: number;
613
+ gaps: DocumentationGap[];
614
+ }
615
+ interface CoverageOptions {
616
+ docsDir?: string;
617
+ sourceDir?: string;
618
+ excludePatterns?: string[];
619
+ }
620
+ interface BrokenLink {
621
+ text: string;
622
+ path: string;
623
+ line: number;
624
+ section: string;
625
+ reason: 'NOT_FOUND' | 'PERMISSION_DENIED' | 'INVALID_PATH';
626
+ suggestion: string;
627
+ }
628
+ interface IntegrityReport {
629
+ totalLinks: number;
630
+ brokenLinks: BrokenLink[];
631
+ validLinks: number;
632
+ integrity: number;
633
+ }
634
+ interface GenerationSection {
635
+ name: string;
636
+ pattern: string;
637
+ description: string;
638
+ }
639
+ interface AgentsMapConfig {
640
+ rootDir: string;
641
+ includePaths: string[];
642
+ excludePaths: string[];
643
+ template?: string;
644
+ sections?: GenerationSection[];
645
+ }
646
+ declare const REQUIRED_SECTIONS: readonly ["Project Overview", "Repository Structure", "Development Workflow"];
647
+
648
+ interface ExtractedLink {
649
+ text: string;
650
+ path: string;
651
+ line: number;
652
+ }
653
+ /**
654
+ * Extract markdown links from content
655
+ * Pattern: [text](path)
656
+ */
657
+ declare function extractMarkdownLinks(content: string): ExtractedLink[];
658
+ /**
659
+ * Extract sections from markdown content
660
+ * Pattern: # Heading or ## Heading etc.
661
+ */
662
+ declare function extractSections(content: string): AgentMapSection[];
663
+ /**
664
+ * Validate an AGENTS.md file
665
+ * - Parses sections and links
666
+ * - Checks for required sections
667
+ * - Verifies all links point to existing files
668
+ */
669
+ declare function validateAgentsMap(path?: string): Promise<Result<AgentMapValidation, ContextError>>;
670
+
671
+ /**
672
+ * Check documentation coverage for a domain
673
+ */
674
+ declare function checkDocCoverage(domain: string, options?: CoverageOptions): Promise<Result<CoverageReport, ContextError>>;
675
+
676
+ /**
677
+ * Validate knowledge map integrity (all links in AGENTS.md and docs)
678
+ */
679
+ declare function validateKnowledgeMap(rootDir?: string): Promise<Result<IntegrityReport, ContextError>>;
680
+
681
+ /**
682
+ * Generate AGENTS.md content from project structure
683
+ */
684
+ declare function generateAgentsMap(config: AgentsMapConfig): Promise<Result<string, ContextError>>;
685
+
686
+ interface TokenBudget {
687
+ total: number;
688
+ systemPrompt: number;
689
+ projectManifest: number;
690
+ taskSpec: number;
691
+ activeCode: number;
692
+ interfaces: number;
693
+ reserve: number;
694
+ }
695
+ interface TokenBudgetOverrides {
696
+ systemPrompt?: number;
697
+ projectManifest?: number;
698
+ taskSpec?: number;
699
+ activeCode?: number;
700
+ interfaces?: number;
701
+ reserve?: number;
702
+ }
703
+
704
+ declare function contextBudget(totalTokens: number, overrides?: TokenBudgetOverrides): TokenBudget;
705
+
706
+ type WorkflowPhase = 'implement' | 'review' | 'debug' | 'plan';
707
+ interface FileCategory {
708
+ category: string;
709
+ patterns: string[];
710
+ priority: number;
711
+ }
712
+ interface ContextFilterResult {
713
+ phase: WorkflowPhase;
714
+ includedCategories: string[];
715
+ excludedCategories: string[];
716
+ filePatterns: string[];
717
+ }
718
+
719
+ declare function contextFilter(phase: WorkflowPhase, maxCategories?: number): ContextFilterResult;
720
+ declare function getPhaseCategories(phase: WorkflowPhase): FileCategory[];
721
+
722
+ /**
723
+ * Create a layer definition
724
+ */
725
+ declare function defineLayer(name: string, patterns: string[], allowedDependencies: string[]): Layer;
726
+ /**
727
+ * Resolve a file path to its layer
728
+ */
729
+ declare function resolveFileToLayer(file: string, layers: Layer[]): Layer | undefined;
730
+
731
+ /**
732
+ * Build a dependency graph from a list of files
733
+ * Note: buildDependencyGraph is exported as an addition beyond spec for advanced use cases
734
+ */
735
+ declare function buildDependencyGraph(files: string[], parser: LanguageParser): Promise<Result<DependencyGraph, ConstraintError>>;
736
+ /**
737
+ * Validate dependencies against layer rules
738
+ */
739
+ declare function validateDependencies(config: LayerConfig): Promise<Result<DependencyValidation, ConstraintError>>;
740
+
741
+ /**
742
+ * Detect circular dependencies in a dependency graph
743
+ */
744
+ declare function detectCircularDeps(graph: DependencyGraph): Result<CircularDepsResult, ConstraintError>;
745
+ /**
746
+ * Detect circular dependencies from a list of files
747
+ */
748
+ declare function detectCircularDepsInFiles(files: string[], parser: LanguageParser): Promise<Result<CircularDepsResult, ConstraintError>>;
749
+
750
+ /**
751
+ * Create a boundary validator from a Zod schema
752
+ */
753
+ declare function createBoundaryValidator<T>(schema: z.ZodSchema<T>, name: string): BoundaryValidator<T>;
754
+ /**
755
+ * Validate multiple boundaries at once
756
+ */
757
+ declare function validateBoundaries(boundaries: BoundaryDefinition[], data: Map<string, unknown>): Result<BoundaryValidation, ConstraintError>;
758
+
759
+ /**
760
+ * Main entropy analysis orchestrator
761
+ */
762
+ declare class EntropyAnalyzer {
763
+ private config;
764
+ private snapshot?;
765
+ private report?;
766
+ constructor(config: EntropyConfig);
767
+ /**
768
+ * Run full entropy analysis
769
+ */
770
+ analyze(): Promise<Result<EntropyReport, EntropyError>>;
771
+ /**
772
+ * Get the built snapshot (must call analyze first)
773
+ */
774
+ getSnapshot(): CodebaseSnapshot | undefined;
775
+ /**
776
+ * Get the last report (must call analyze first)
777
+ */
778
+ getReport(): EntropyReport | undefined;
779
+ /**
780
+ * Generate suggestions from the last analysis
781
+ */
782
+ getSuggestions(): SuggestionReport;
783
+ /**
784
+ * Build snapshot without running analysis
785
+ */
786
+ buildSnapshot(): Promise<Result<CodebaseSnapshot, EntropyError>>;
787
+ /**
788
+ * Ensure snapshot is built, returning the snapshot or an error
789
+ */
790
+ private ensureSnapshot;
791
+ /**
792
+ * Run drift detection only (snapshot must be built first)
793
+ */
794
+ detectDrift(config?: Partial<DriftConfig>): Promise<Result<DriftReport, EntropyError>>;
795
+ /**
796
+ * Run dead code detection only (snapshot must be built first)
797
+ */
798
+ detectDeadCode(): Promise<Result<DeadCodeReport, EntropyError>>;
799
+ /**
800
+ * Run pattern detection only (snapshot must be built first)
801
+ */
802
+ detectPatterns(config: PatternConfig): Promise<Result<PatternReport, EntropyError>>;
803
+ }
804
+
805
+ /**
806
+ * Resolve entry points for dead code analysis
807
+ *
808
+ * Entry points are the starting files from which reachability analysis begins.
809
+ * The resolution order is:
810
+ * 1. Explicit entries provided as arguments
811
+ * 2. package.json exports/main/bin fields
812
+ * 3. Conventional entry files (src/index.ts, index.ts, etc.)
813
+ */
814
+ declare function resolveEntryPoints(rootDir: string, explicitEntries?: string[]): Promise<Result<string[], EntropyError>>;
815
+ /**
816
+ * Parse a documentation file
817
+ */
818
+ declare function parseDocumentationFile(path: string): Promise<Result<DocumentationFile, EntropyError>>;
819
+ /**
820
+ * Build a complete CodebaseSnapshot
821
+ */
822
+ declare function buildSnapshot(config: EntropyConfig): Promise<Result<CodebaseSnapshot, EntropyError>>;
823
+
824
+ /**
825
+ * Calculate Levenshtein distance between two strings
826
+ */
827
+ declare function levenshteinDistance(a: string, b: string): number;
828
+ /**
829
+ * Find possible matches for a reference in a list of exports
830
+ */
831
+ declare function findPossibleMatches(reference: string, exportNames: string[], maxDistance?: number): string[];
832
+ /**
833
+ * Detect documentation drift in a codebase
834
+ */
835
+ declare function detectDocDrift(snapshot: CodebaseSnapshot, config?: Partial<DriftConfig>): Promise<Result<DriftReport, EntropyError>>;
836
+
837
+ /**
838
+ * Build a map of file reachability from entry points
839
+ */
840
+ declare function buildReachabilityMap(snapshot: CodebaseSnapshot): Map<string, boolean>;
841
+ /**
842
+ * Detect dead code in a codebase snapshot.
843
+ * Analyzes exports, files, imports, and internal symbols to find unused code.
844
+ */
845
+ declare function detectDeadCode(snapshot: CodebaseSnapshot): Promise<Result<DeadCodeReport, EntropyError>>;
846
+
847
+ /**
848
+ * Check a single config pattern against a file
849
+ */
850
+ declare function checkConfigPattern(pattern: ConfigPattern, file: SourceFile, rootDir: string): PatternMatch[];
851
+ /**
852
+ * Detect pattern violations across a codebase
853
+ */
854
+ declare function detectPatternViolations(snapshot: CodebaseSnapshot, config?: PatternConfig): Promise<Result<PatternReport, EntropyError>>;
855
+
856
+ /**
857
+ * Create fixes from dead code report
858
+ */
859
+ declare function createFixes(deadCodeReport: DeadCodeReport, config?: Partial<FixConfig>): Fix[];
860
+ /**
861
+ * Preview what a fix would do
862
+ */
863
+ declare function previewFix(fix: Fix): string;
864
+ /**
865
+ * Apply fixes to codebase
866
+ */
867
+ declare function applyFixes(fixes: Fix[], config?: Partial<FixConfig>): Promise<Result<FixResult, EntropyError>>;
868
+
869
+ /**
870
+ * Generate all suggestions from analysis reports
871
+ */
872
+ declare function generateSuggestions(deadCode?: DeadCodeReport, drift?: DriftReport, patterns?: PatternReport): SuggestionReport;
873
+
874
+ declare const PatternConfigSchema: z.ZodObject<{
875
+ patterns: z.ZodArray<z.ZodObject<{
876
+ name: z.ZodString;
877
+ description: z.ZodString;
878
+ severity: z.ZodEnum<["error", "warning"]>;
879
+ files: z.ZodArray<z.ZodString, "many">;
880
+ rule: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
881
+ type: z.ZodLiteral<"must-export">;
882
+ names: z.ZodArray<z.ZodString, "many">;
883
+ }, "strip", z.ZodTypeAny, {
884
+ type: "must-export";
885
+ names: string[];
886
+ }, {
887
+ type: "must-export";
888
+ names: string[];
889
+ }>, z.ZodObject<{
890
+ type: z.ZodLiteral<"must-export-default">;
891
+ kind: z.ZodOptional<z.ZodEnum<["class", "function", "object"]>>;
892
+ }, "strip", z.ZodTypeAny, {
893
+ type: "must-export-default";
894
+ kind?: "object" | "function" | "class" | undefined;
895
+ }, {
896
+ type: "must-export-default";
897
+ kind?: "object" | "function" | "class" | undefined;
898
+ }>, z.ZodObject<{
899
+ type: z.ZodLiteral<"no-export">;
900
+ names: z.ZodArray<z.ZodString, "many">;
901
+ }, "strip", z.ZodTypeAny, {
902
+ type: "no-export";
903
+ names: string[];
904
+ }, {
905
+ type: "no-export";
906
+ names: string[];
907
+ }>, z.ZodObject<{
908
+ type: z.ZodLiteral<"must-import">;
909
+ from: z.ZodString;
910
+ names: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
911
+ }, "strip", z.ZodTypeAny, {
912
+ type: "must-import";
913
+ from: string;
914
+ names?: string[] | undefined;
915
+ }, {
916
+ type: "must-import";
917
+ from: string;
918
+ names?: string[] | undefined;
919
+ }>, z.ZodObject<{
920
+ type: z.ZodLiteral<"no-import">;
921
+ from: z.ZodString;
922
+ }, "strip", z.ZodTypeAny, {
923
+ type: "no-import";
924
+ from: string;
925
+ }, {
926
+ type: "no-import";
927
+ from: string;
928
+ }>, z.ZodObject<{
929
+ type: z.ZodLiteral<"naming">;
930
+ match: z.ZodString;
931
+ convention: z.ZodEnum<["camelCase", "PascalCase", "UPPER_SNAKE", "kebab-case"]>;
932
+ }, "strip", z.ZodTypeAny, {
933
+ match: string;
934
+ type: "naming";
935
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
936
+ }, {
937
+ match: string;
938
+ type: "naming";
939
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
940
+ }>, z.ZodObject<{
941
+ type: z.ZodLiteral<"max-exports">;
942
+ count: z.ZodNumber;
943
+ }, "strip", z.ZodTypeAny, {
944
+ type: "max-exports";
945
+ count: number;
946
+ }, {
947
+ type: "max-exports";
948
+ count: number;
949
+ }>, z.ZodObject<{
950
+ type: z.ZodLiteral<"max-lines">;
951
+ count: z.ZodNumber;
952
+ }, "strip", z.ZodTypeAny, {
953
+ type: "max-lines";
954
+ count: number;
955
+ }, {
956
+ type: "max-lines";
957
+ count: number;
958
+ }>, z.ZodObject<{
959
+ type: z.ZodLiteral<"require-jsdoc">;
960
+ for: z.ZodArray<z.ZodEnum<["function", "class", "export"]>, "many">;
961
+ }, "strip", z.ZodTypeAny, {
962
+ type: "require-jsdoc";
963
+ for: ("function" | "class" | "export")[];
964
+ }, {
965
+ type: "require-jsdoc";
966
+ for: ("function" | "class" | "export")[];
967
+ }>]>;
968
+ message: z.ZodOptional<z.ZodString>;
969
+ }, "strip", z.ZodTypeAny, {
970
+ files: string[];
971
+ name: string;
972
+ description: string;
973
+ severity: "error" | "warning";
974
+ rule: {
975
+ type: "must-export";
976
+ names: string[];
977
+ } | {
978
+ type: "must-export-default";
979
+ kind?: "object" | "function" | "class" | undefined;
980
+ } | {
981
+ type: "no-export";
982
+ names: string[];
983
+ } | {
984
+ type: "must-import";
985
+ from: string;
986
+ names?: string[] | undefined;
987
+ } | {
988
+ type: "no-import";
989
+ from: string;
990
+ } | {
991
+ match: string;
992
+ type: "naming";
993
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
994
+ } | {
995
+ type: "max-exports";
996
+ count: number;
997
+ } | {
998
+ type: "max-lines";
999
+ count: number;
1000
+ } | {
1001
+ type: "require-jsdoc";
1002
+ for: ("function" | "class" | "export")[];
1003
+ };
1004
+ message?: string | undefined;
1005
+ }, {
1006
+ files: string[];
1007
+ name: string;
1008
+ description: string;
1009
+ severity: "error" | "warning";
1010
+ rule: {
1011
+ type: "must-export";
1012
+ names: string[];
1013
+ } | {
1014
+ type: "must-export-default";
1015
+ kind?: "object" | "function" | "class" | undefined;
1016
+ } | {
1017
+ type: "no-export";
1018
+ names: string[];
1019
+ } | {
1020
+ type: "must-import";
1021
+ from: string;
1022
+ names?: string[] | undefined;
1023
+ } | {
1024
+ type: "no-import";
1025
+ from: string;
1026
+ } | {
1027
+ match: string;
1028
+ type: "naming";
1029
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1030
+ } | {
1031
+ type: "max-exports";
1032
+ count: number;
1033
+ } | {
1034
+ type: "max-lines";
1035
+ count: number;
1036
+ } | {
1037
+ type: "require-jsdoc";
1038
+ for: ("function" | "class" | "export")[];
1039
+ };
1040
+ message?: string | undefined;
1041
+ }>, "many">;
1042
+ customPatterns: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1043
+ ignoreFiles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1044
+ }, "strip", z.ZodTypeAny, {
1045
+ patterns: {
1046
+ files: string[];
1047
+ name: string;
1048
+ description: string;
1049
+ severity: "error" | "warning";
1050
+ rule: {
1051
+ type: "must-export";
1052
+ names: string[];
1053
+ } | {
1054
+ type: "must-export-default";
1055
+ kind?: "object" | "function" | "class" | undefined;
1056
+ } | {
1057
+ type: "no-export";
1058
+ names: string[];
1059
+ } | {
1060
+ type: "must-import";
1061
+ from: string;
1062
+ names?: string[] | undefined;
1063
+ } | {
1064
+ type: "no-import";
1065
+ from: string;
1066
+ } | {
1067
+ match: string;
1068
+ type: "naming";
1069
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1070
+ } | {
1071
+ type: "max-exports";
1072
+ count: number;
1073
+ } | {
1074
+ type: "max-lines";
1075
+ count: number;
1076
+ } | {
1077
+ type: "require-jsdoc";
1078
+ for: ("function" | "class" | "export")[];
1079
+ };
1080
+ message?: string | undefined;
1081
+ }[];
1082
+ customPatterns?: any[] | undefined;
1083
+ ignoreFiles?: string[] | undefined;
1084
+ }, {
1085
+ patterns: {
1086
+ files: string[];
1087
+ name: string;
1088
+ description: string;
1089
+ severity: "error" | "warning";
1090
+ rule: {
1091
+ type: "must-export";
1092
+ names: string[];
1093
+ } | {
1094
+ type: "must-export-default";
1095
+ kind?: "object" | "function" | "class" | undefined;
1096
+ } | {
1097
+ type: "no-export";
1098
+ names: string[];
1099
+ } | {
1100
+ type: "must-import";
1101
+ from: string;
1102
+ names?: string[] | undefined;
1103
+ } | {
1104
+ type: "no-import";
1105
+ from: string;
1106
+ } | {
1107
+ match: string;
1108
+ type: "naming";
1109
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1110
+ } | {
1111
+ type: "max-exports";
1112
+ count: number;
1113
+ } | {
1114
+ type: "max-lines";
1115
+ count: number;
1116
+ } | {
1117
+ type: "require-jsdoc";
1118
+ for: ("function" | "class" | "export")[];
1119
+ };
1120
+ message?: string | undefined;
1121
+ }[];
1122
+ customPatterns?: any[] | undefined;
1123
+ ignoreFiles?: string[] | undefined;
1124
+ }>;
1125
+ declare const EntropyConfigSchema: z.ZodObject<{
1126
+ rootDir: z.ZodString;
1127
+ parser: z.ZodOptional<z.ZodAny>;
1128
+ entryPoints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1129
+ analyze: z.ZodObject<{
1130
+ drift: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
1131
+ docPaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1132
+ checkApiSignatures: z.ZodOptional<z.ZodBoolean>;
1133
+ checkExamples: z.ZodOptional<z.ZodBoolean>;
1134
+ checkStructure: z.ZodOptional<z.ZodBoolean>;
1135
+ ignorePatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1136
+ }, "strip", z.ZodTypeAny, {
1137
+ docPaths?: string[] | undefined;
1138
+ checkApiSignatures?: boolean | undefined;
1139
+ checkExamples?: boolean | undefined;
1140
+ checkStructure?: boolean | undefined;
1141
+ ignorePatterns?: string[] | undefined;
1142
+ }, {
1143
+ docPaths?: string[] | undefined;
1144
+ checkApiSignatures?: boolean | undefined;
1145
+ checkExamples?: boolean | undefined;
1146
+ checkStructure?: boolean | undefined;
1147
+ ignorePatterns?: string[] | undefined;
1148
+ }>]>>;
1149
+ deadCode: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
1150
+ entryPoints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1151
+ includeTypes: z.ZodOptional<z.ZodBoolean>;
1152
+ includeInternals: z.ZodOptional<z.ZodBoolean>;
1153
+ ignorePatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1154
+ treatDynamicImportsAs: z.ZodOptional<z.ZodEnum<["used", "unknown"]>>;
1155
+ }, "strip", z.ZodTypeAny, {
1156
+ ignorePatterns?: string[] | undefined;
1157
+ entryPoints?: string[] | undefined;
1158
+ includeTypes?: boolean | undefined;
1159
+ includeInternals?: boolean | undefined;
1160
+ treatDynamicImportsAs?: "used" | "unknown" | undefined;
1161
+ }, {
1162
+ ignorePatterns?: string[] | undefined;
1163
+ entryPoints?: string[] | undefined;
1164
+ includeTypes?: boolean | undefined;
1165
+ includeInternals?: boolean | undefined;
1166
+ treatDynamicImportsAs?: "used" | "unknown" | undefined;
1167
+ }>]>>;
1168
+ patterns: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
1169
+ patterns: z.ZodArray<z.ZodObject<{
1170
+ name: z.ZodString;
1171
+ description: z.ZodString;
1172
+ severity: z.ZodEnum<["error", "warning"]>;
1173
+ files: z.ZodArray<z.ZodString, "many">;
1174
+ rule: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1175
+ type: z.ZodLiteral<"must-export">;
1176
+ names: z.ZodArray<z.ZodString, "many">;
1177
+ }, "strip", z.ZodTypeAny, {
1178
+ type: "must-export";
1179
+ names: string[];
1180
+ }, {
1181
+ type: "must-export";
1182
+ names: string[];
1183
+ }>, z.ZodObject<{
1184
+ type: z.ZodLiteral<"must-export-default">;
1185
+ kind: z.ZodOptional<z.ZodEnum<["class", "function", "object"]>>;
1186
+ }, "strip", z.ZodTypeAny, {
1187
+ type: "must-export-default";
1188
+ kind?: "object" | "function" | "class" | undefined;
1189
+ }, {
1190
+ type: "must-export-default";
1191
+ kind?: "object" | "function" | "class" | undefined;
1192
+ }>, z.ZodObject<{
1193
+ type: z.ZodLiteral<"no-export">;
1194
+ names: z.ZodArray<z.ZodString, "many">;
1195
+ }, "strip", z.ZodTypeAny, {
1196
+ type: "no-export";
1197
+ names: string[];
1198
+ }, {
1199
+ type: "no-export";
1200
+ names: string[];
1201
+ }>, z.ZodObject<{
1202
+ type: z.ZodLiteral<"must-import">;
1203
+ from: z.ZodString;
1204
+ names: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1205
+ }, "strip", z.ZodTypeAny, {
1206
+ type: "must-import";
1207
+ from: string;
1208
+ names?: string[] | undefined;
1209
+ }, {
1210
+ type: "must-import";
1211
+ from: string;
1212
+ names?: string[] | undefined;
1213
+ }>, z.ZodObject<{
1214
+ type: z.ZodLiteral<"no-import">;
1215
+ from: z.ZodString;
1216
+ }, "strip", z.ZodTypeAny, {
1217
+ type: "no-import";
1218
+ from: string;
1219
+ }, {
1220
+ type: "no-import";
1221
+ from: string;
1222
+ }>, z.ZodObject<{
1223
+ type: z.ZodLiteral<"naming">;
1224
+ match: z.ZodString;
1225
+ convention: z.ZodEnum<["camelCase", "PascalCase", "UPPER_SNAKE", "kebab-case"]>;
1226
+ }, "strip", z.ZodTypeAny, {
1227
+ match: string;
1228
+ type: "naming";
1229
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1230
+ }, {
1231
+ match: string;
1232
+ type: "naming";
1233
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1234
+ }>, z.ZodObject<{
1235
+ type: z.ZodLiteral<"max-exports">;
1236
+ count: z.ZodNumber;
1237
+ }, "strip", z.ZodTypeAny, {
1238
+ type: "max-exports";
1239
+ count: number;
1240
+ }, {
1241
+ type: "max-exports";
1242
+ count: number;
1243
+ }>, z.ZodObject<{
1244
+ type: z.ZodLiteral<"max-lines">;
1245
+ count: z.ZodNumber;
1246
+ }, "strip", z.ZodTypeAny, {
1247
+ type: "max-lines";
1248
+ count: number;
1249
+ }, {
1250
+ type: "max-lines";
1251
+ count: number;
1252
+ }>, z.ZodObject<{
1253
+ type: z.ZodLiteral<"require-jsdoc">;
1254
+ for: z.ZodArray<z.ZodEnum<["function", "class", "export"]>, "many">;
1255
+ }, "strip", z.ZodTypeAny, {
1256
+ type: "require-jsdoc";
1257
+ for: ("function" | "class" | "export")[];
1258
+ }, {
1259
+ type: "require-jsdoc";
1260
+ for: ("function" | "class" | "export")[];
1261
+ }>]>;
1262
+ message: z.ZodOptional<z.ZodString>;
1263
+ }, "strip", z.ZodTypeAny, {
1264
+ files: string[];
1265
+ name: string;
1266
+ description: string;
1267
+ severity: "error" | "warning";
1268
+ rule: {
1269
+ type: "must-export";
1270
+ names: string[];
1271
+ } | {
1272
+ type: "must-export-default";
1273
+ kind?: "object" | "function" | "class" | undefined;
1274
+ } | {
1275
+ type: "no-export";
1276
+ names: string[];
1277
+ } | {
1278
+ type: "must-import";
1279
+ from: string;
1280
+ names?: string[] | undefined;
1281
+ } | {
1282
+ type: "no-import";
1283
+ from: string;
1284
+ } | {
1285
+ match: string;
1286
+ type: "naming";
1287
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1288
+ } | {
1289
+ type: "max-exports";
1290
+ count: number;
1291
+ } | {
1292
+ type: "max-lines";
1293
+ count: number;
1294
+ } | {
1295
+ type: "require-jsdoc";
1296
+ for: ("function" | "class" | "export")[];
1297
+ };
1298
+ message?: string | undefined;
1299
+ }, {
1300
+ files: string[];
1301
+ name: string;
1302
+ description: string;
1303
+ severity: "error" | "warning";
1304
+ rule: {
1305
+ type: "must-export";
1306
+ names: string[];
1307
+ } | {
1308
+ type: "must-export-default";
1309
+ kind?: "object" | "function" | "class" | undefined;
1310
+ } | {
1311
+ type: "no-export";
1312
+ names: string[];
1313
+ } | {
1314
+ type: "must-import";
1315
+ from: string;
1316
+ names?: string[] | undefined;
1317
+ } | {
1318
+ type: "no-import";
1319
+ from: string;
1320
+ } | {
1321
+ match: string;
1322
+ type: "naming";
1323
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1324
+ } | {
1325
+ type: "max-exports";
1326
+ count: number;
1327
+ } | {
1328
+ type: "max-lines";
1329
+ count: number;
1330
+ } | {
1331
+ type: "require-jsdoc";
1332
+ for: ("function" | "class" | "export")[];
1333
+ };
1334
+ message?: string | undefined;
1335
+ }>, "many">;
1336
+ customPatterns: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1337
+ ignoreFiles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1338
+ }, "strip", z.ZodTypeAny, {
1339
+ patterns: {
1340
+ files: string[];
1341
+ name: string;
1342
+ description: string;
1343
+ severity: "error" | "warning";
1344
+ rule: {
1345
+ type: "must-export";
1346
+ names: string[];
1347
+ } | {
1348
+ type: "must-export-default";
1349
+ kind?: "object" | "function" | "class" | undefined;
1350
+ } | {
1351
+ type: "no-export";
1352
+ names: string[];
1353
+ } | {
1354
+ type: "must-import";
1355
+ from: string;
1356
+ names?: string[] | undefined;
1357
+ } | {
1358
+ type: "no-import";
1359
+ from: string;
1360
+ } | {
1361
+ match: string;
1362
+ type: "naming";
1363
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1364
+ } | {
1365
+ type: "max-exports";
1366
+ count: number;
1367
+ } | {
1368
+ type: "max-lines";
1369
+ count: number;
1370
+ } | {
1371
+ type: "require-jsdoc";
1372
+ for: ("function" | "class" | "export")[];
1373
+ };
1374
+ message?: string | undefined;
1375
+ }[];
1376
+ customPatterns?: any[] | undefined;
1377
+ ignoreFiles?: string[] | undefined;
1378
+ }, {
1379
+ patterns: {
1380
+ files: string[];
1381
+ name: string;
1382
+ description: string;
1383
+ severity: "error" | "warning";
1384
+ rule: {
1385
+ type: "must-export";
1386
+ names: string[];
1387
+ } | {
1388
+ type: "must-export-default";
1389
+ kind?: "object" | "function" | "class" | undefined;
1390
+ } | {
1391
+ type: "no-export";
1392
+ names: string[];
1393
+ } | {
1394
+ type: "must-import";
1395
+ from: string;
1396
+ names?: string[] | undefined;
1397
+ } | {
1398
+ type: "no-import";
1399
+ from: string;
1400
+ } | {
1401
+ match: string;
1402
+ type: "naming";
1403
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1404
+ } | {
1405
+ type: "max-exports";
1406
+ count: number;
1407
+ } | {
1408
+ type: "max-lines";
1409
+ count: number;
1410
+ } | {
1411
+ type: "require-jsdoc";
1412
+ for: ("function" | "class" | "export")[];
1413
+ };
1414
+ message?: string | undefined;
1415
+ }[];
1416
+ customPatterns?: any[] | undefined;
1417
+ ignoreFiles?: string[] | undefined;
1418
+ }>]>>;
1419
+ }, "strip", z.ZodTypeAny, {
1420
+ drift?: boolean | {
1421
+ docPaths?: string[] | undefined;
1422
+ checkApiSignatures?: boolean | undefined;
1423
+ checkExamples?: boolean | undefined;
1424
+ checkStructure?: boolean | undefined;
1425
+ ignorePatterns?: string[] | undefined;
1426
+ } | undefined;
1427
+ deadCode?: boolean | {
1428
+ ignorePatterns?: string[] | undefined;
1429
+ entryPoints?: string[] | undefined;
1430
+ includeTypes?: boolean | undefined;
1431
+ includeInternals?: boolean | undefined;
1432
+ treatDynamicImportsAs?: "used" | "unknown" | undefined;
1433
+ } | undefined;
1434
+ patterns?: boolean | {
1435
+ patterns: {
1436
+ files: string[];
1437
+ name: string;
1438
+ description: string;
1439
+ severity: "error" | "warning";
1440
+ rule: {
1441
+ type: "must-export";
1442
+ names: string[];
1443
+ } | {
1444
+ type: "must-export-default";
1445
+ kind?: "object" | "function" | "class" | undefined;
1446
+ } | {
1447
+ type: "no-export";
1448
+ names: string[];
1449
+ } | {
1450
+ type: "must-import";
1451
+ from: string;
1452
+ names?: string[] | undefined;
1453
+ } | {
1454
+ type: "no-import";
1455
+ from: string;
1456
+ } | {
1457
+ match: string;
1458
+ type: "naming";
1459
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1460
+ } | {
1461
+ type: "max-exports";
1462
+ count: number;
1463
+ } | {
1464
+ type: "max-lines";
1465
+ count: number;
1466
+ } | {
1467
+ type: "require-jsdoc";
1468
+ for: ("function" | "class" | "export")[];
1469
+ };
1470
+ message?: string | undefined;
1471
+ }[];
1472
+ customPatterns?: any[] | undefined;
1473
+ ignoreFiles?: string[] | undefined;
1474
+ } | undefined;
1475
+ }, {
1476
+ drift?: boolean | {
1477
+ docPaths?: string[] | undefined;
1478
+ checkApiSignatures?: boolean | undefined;
1479
+ checkExamples?: boolean | undefined;
1480
+ checkStructure?: boolean | undefined;
1481
+ ignorePatterns?: string[] | undefined;
1482
+ } | undefined;
1483
+ deadCode?: boolean | {
1484
+ ignorePatterns?: string[] | undefined;
1485
+ entryPoints?: string[] | undefined;
1486
+ includeTypes?: boolean | undefined;
1487
+ includeInternals?: boolean | undefined;
1488
+ treatDynamicImportsAs?: "used" | "unknown" | undefined;
1489
+ } | undefined;
1490
+ patterns?: boolean | {
1491
+ patterns: {
1492
+ files: string[];
1493
+ name: string;
1494
+ description: string;
1495
+ severity: "error" | "warning";
1496
+ rule: {
1497
+ type: "must-export";
1498
+ names: string[];
1499
+ } | {
1500
+ type: "must-export-default";
1501
+ kind?: "object" | "function" | "class" | undefined;
1502
+ } | {
1503
+ type: "no-export";
1504
+ names: string[];
1505
+ } | {
1506
+ type: "must-import";
1507
+ from: string;
1508
+ names?: string[] | undefined;
1509
+ } | {
1510
+ type: "no-import";
1511
+ from: string;
1512
+ } | {
1513
+ match: string;
1514
+ type: "naming";
1515
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1516
+ } | {
1517
+ type: "max-exports";
1518
+ count: number;
1519
+ } | {
1520
+ type: "max-lines";
1521
+ count: number;
1522
+ } | {
1523
+ type: "require-jsdoc";
1524
+ for: ("function" | "class" | "export")[];
1525
+ };
1526
+ message?: string | undefined;
1527
+ }[];
1528
+ customPatterns?: any[] | undefined;
1529
+ ignoreFiles?: string[] | undefined;
1530
+ } | undefined;
1531
+ }>;
1532
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1533
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1534
+ docPaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1535
+ }, "strip", z.ZodTypeAny, {
1536
+ rootDir: string;
1537
+ analyze: {
1538
+ drift?: boolean | {
1539
+ docPaths?: string[] | undefined;
1540
+ checkApiSignatures?: boolean | undefined;
1541
+ checkExamples?: boolean | undefined;
1542
+ checkStructure?: boolean | undefined;
1543
+ ignorePatterns?: string[] | undefined;
1544
+ } | undefined;
1545
+ deadCode?: boolean | {
1546
+ ignorePatterns?: string[] | undefined;
1547
+ entryPoints?: string[] | undefined;
1548
+ includeTypes?: boolean | undefined;
1549
+ includeInternals?: boolean | undefined;
1550
+ treatDynamicImportsAs?: "used" | "unknown" | undefined;
1551
+ } | undefined;
1552
+ patterns?: boolean | {
1553
+ patterns: {
1554
+ files: string[];
1555
+ name: string;
1556
+ description: string;
1557
+ severity: "error" | "warning";
1558
+ rule: {
1559
+ type: "must-export";
1560
+ names: string[];
1561
+ } | {
1562
+ type: "must-export-default";
1563
+ kind?: "object" | "function" | "class" | undefined;
1564
+ } | {
1565
+ type: "no-export";
1566
+ names: string[];
1567
+ } | {
1568
+ type: "must-import";
1569
+ from: string;
1570
+ names?: string[] | undefined;
1571
+ } | {
1572
+ type: "no-import";
1573
+ from: string;
1574
+ } | {
1575
+ match: string;
1576
+ type: "naming";
1577
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1578
+ } | {
1579
+ type: "max-exports";
1580
+ count: number;
1581
+ } | {
1582
+ type: "max-lines";
1583
+ count: number;
1584
+ } | {
1585
+ type: "require-jsdoc";
1586
+ for: ("function" | "class" | "export")[];
1587
+ };
1588
+ message?: string | undefined;
1589
+ }[];
1590
+ customPatterns?: any[] | undefined;
1591
+ ignoreFiles?: string[] | undefined;
1592
+ } | undefined;
1593
+ };
1594
+ parser?: any;
1595
+ docPaths?: string[] | undefined;
1596
+ entryPoints?: string[] | undefined;
1597
+ include?: string[] | undefined;
1598
+ exclude?: string[] | undefined;
1599
+ }, {
1600
+ rootDir: string;
1601
+ analyze: {
1602
+ drift?: boolean | {
1603
+ docPaths?: string[] | undefined;
1604
+ checkApiSignatures?: boolean | undefined;
1605
+ checkExamples?: boolean | undefined;
1606
+ checkStructure?: boolean | undefined;
1607
+ ignorePatterns?: string[] | undefined;
1608
+ } | undefined;
1609
+ deadCode?: boolean | {
1610
+ ignorePatterns?: string[] | undefined;
1611
+ entryPoints?: string[] | undefined;
1612
+ includeTypes?: boolean | undefined;
1613
+ includeInternals?: boolean | undefined;
1614
+ treatDynamicImportsAs?: "used" | "unknown" | undefined;
1615
+ } | undefined;
1616
+ patterns?: boolean | {
1617
+ patterns: {
1618
+ files: string[];
1619
+ name: string;
1620
+ description: string;
1621
+ severity: "error" | "warning";
1622
+ rule: {
1623
+ type: "must-export";
1624
+ names: string[];
1625
+ } | {
1626
+ type: "must-export-default";
1627
+ kind?: "object" | "function" | "class" | undefined;
1628
+ } | {
1629
+ type: "no-export";
1630
+ names: string[];
1631
+ } | {
1632
+ type: "must-import";
1633
+ from: string;
1634
+ names?: string[] | undefined;
1635
+ } | {
1636
+ type: "no-import";
1637
+ from: string;
1638
+ } | {
1639
+ match: string;
1640
+ type: "naming";
1641
+ convention: "camelCase" | "PascalCase" | "UPPER_SNAKE" | "kebab-case";
1642
+ } | {
1643
+ type: "max-exports";
1644
+ count: number;
1645
+ } | {
1646
+ type: "max-lines";
1647
+ count: number;
1648
+ } | {
1649
+ type: "require-jsdoc";
1650
+ for: ("function" | "class" | "export")[];
1651
+ };
1652
+ message?: string | undefined;
1653
+ }[];
1654
+ customPatterns?: any[] | undefined;
1655
+ ignoreFiles?: string[] | undefined;
1656
+ } | undefined;
1657
+ };
1658
+ parser?: any;
1659
+ docPaths?: string[] | undefined;
1660
+ entryPoints?: string[] | undefined;
1661
+ include?: string[] | undefined;
1662
+ exclude?: string[] | undefined;
1663
+ }>;
1664
+ /**
1665
+ * Validate pattern config
1666
+ */
1667
+ declare function validatePatternConfig(config: unknown): Result<PatternConfig, EntropyError>;
1668
+
1669
+ interface FeedbackError extends BaseError {
1670
+ code: 'AGENT_SPAWN_ERROR' | 'AGENT_TIMEOUT' | 'TELEMETRY_ERROR' | 'TELEMETRY_UNAVAILABLE' | 'REVIEW_ERROR' | 'DIFF_PARSE_ERROR' | 'SINK_ERROR';
1671
+ details: {
1672
+ agentId?: string;
1673
+ service?: string;
1674
+ reason?: string;
1675
+ originalError?: Error;
1676
+ };
1677
+ }
1678
+ interface ReviewItem {
1679
+ id: string;
1680
+ category: 'harness' | 'custom' | 'diff';
1681
+ check: string;
1682
+ passed: boolean;
1683
+ severity: 'error' | 'warning' | 'info';
1684
+ details: string;
1685
+ suggestion?: string;
1686
+ file?: string;
1687
+ line?: number;
1688
+ }
1689
+ interface ReviewChecklist {
1690
+ items: ReviewItem[];
1691
+ passed: boolean;
1692
+ summary: {
1693
+ total: number;
1694
+ passed: number;
1695
+ failed: number;
1696
+ errors: number;
1697
+ warnings: number;
1698
+ };
1699
+ duration: number;
1700
+ }
1701
+ interface CodeChanges {
1702
+ diff: string;
1703
+ files: ChangedFile[];
1704
+ commitMessage?: string;
1705
+ branch?: string;
1706
+ }
1707
+ interface ChangedFile {
1708
+ path: string;
1709
+ status: 'added' | 'modified' | 'deleted' | 'renamed';
1710
+ additions: number;
1711
+ deletions: number;
1712
+ }
1713
+ interface SelfReviewConfig {
1714
+ harness?: {
1715
+ context?: boolean;
1716
+ constraints?: boolean;
1717
+ entropy?: boolean;
1718
+ };
1719
+ customRules?: CustomRule[];
1720
+ diffAnalysis?: {
1721
+ enabled: boolean;
1722
+ checkTestCoverage?: boolean;
1723
+ checkDocumentation?: boolean;
1724
+ maxFileSize?: number;
1725
+ maxChangedFiles?: number;
1726
+ forbiddenPatterns?: ForbiddenPattern[];
1727
+ };
1728
+ rootDir: string;
1729
+ }
1730
+ interface CustomRule {
1731
+ id: string;
1732
+ name: string;
1733
+ description: string;
1734
+ severity: 'error' | 'warning' | 'info';
1735
+ check: (changes: CodeChanges, rootDir: string) => Promise<CustomRuleResult>;
1736
+ }
1737
+ interface CustomRuleResult {
1738
+ passed: boolean;
1739
+ details: string;
1740
+ suggestion?: string;
1741
+ file?: string;
1742
+ line?: number;
1743
+ }
1744
+ interface ForbiddenPattern {
1745
+ pattern: string | RegExp;
1746
+ message: string;
1747
+ severity: 'error' | 'warning';
1748
+ fileGlob?: string;
1749
+ }
1750
+ type AgentType = 'architecture-enforcer' | 'documentation-maintainer' | 'test-reviewer' | 'entropy-cleaner' | 'custom';
1751
+ interface AgentConfig {
1752
+ type: AgentType;
1753
+ customType?: string;
1754
+ context: ReviewContext;
1755
+ skills?: string[];
1756
+ timeout?: number;
1757
+ }
1758
+ interface ReviewContext {
1759
+ files: string[];
1760
+ diff?: string;
1761
+ commitMessage?: string;
1762
+ metadata?: Record<string, unknown>;
1763
+ }
1764
+ interface AgentProcess {
1765
+ id: string;
1766
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'timeout';
1767
+ startedAt: string;
1768
+ config: AgentConfig;
1769
+ }
1770
+ interface PeerReview {
1771
+ agentId: string;
1772
+ agentType: AgentType;
1773
+ approved: boolean;
1774
+ comments: ReviewComment[];
1775
+ suggestions: string[];
1776
+ duration: number;
1777
+ completedAt: string;
1778
+ }
1779
+ interface ReviewComment {
1780
+ file: string;
1781
+ line?: number;
1782
+ severity: 'error' | 'warning' | 'suggestion';
1783
+ message: string;
1784
+ code?: string;
1785
+ }
1786
+ interface PeerReviewOptions {
1787
+ skills?: string[];
1788
+ timeout?: number;
1789
+ wait?: boolean;
1790
+ customAgentType?: string;
1791
+ }
1792
+ interface TimeRange {
1793
+ start: Date | string;
1794
+ end: Date | string;
1795
+ }
1796
+ interface Metric {
1797
+ name: string;
1798
+ value: number;
1799
+ unit: string;
1800
+ timestamp: string;
1801
+ labels: Record<string, string>;
1802
+ }
1803
+ interface Span {
1804
+ traceId: string;
1805
+ spanId: string;
1806
+ parentSpanId?: string;
1807
+ name: string;
1808
+ service: string;
1809
+ startTime: string;
1810
+ endTime: string;
1811
+ duration: number;
1812
+ status: 'ok' | 'error';
1813
+ attributes: Record<string, unknown>;
1814
+ events: SpanEvent[];
1815
+ }
1816
+ interface SpanEvent {
1817
+ name: string;
1818
+ timestamp: string;
1819
+ attributes: Record<string, unknown>;
1820
+ }
1821
+ interface Trace {
1822
+ traceId: string;
1823
+ spans: Span[];
1824
+ rootSpan: Span;
1825
+ duration: number;
1826
+ service: string;
1827
+ }
1828
+ interface LogEntry {
1829
+ timestamp: string;
1830
+ level: 'debug' | 'info' | 'warn' | 'error';
1831
+ message: string;
1832
+ service: string;
1833
+ attributes: Record<string, unknown>;
1834
+ traceId?: string;
1835
+ spanId?: string;
1836
+ }
1837
+ interface LogFilter {
1838
+ level?: LogEntry['level'] | LogEntry['level'][];
1839
+ search?: string;
1840
+ attributes?: Record<string, unknown>;
1841
+ limit?: number;
1842
+ }
1843
+ interface TelemetryHealth {
1844
+ available: boolean;
1845
+ latency?: number;
1846
+ message?: string;
1847
+ }
1848
+ interface ExecutorHealth {
1849
+ available: boolean;
1850
+ maxConcurrent?: number;
1851
+ activeProcesses?: number;
1852
+ message?: string;
1853
+ }
1854
+ type ActionType = 'self-review' | 'peer-review' | 'telemetry-query' | 'spawn-agent' | 'kill-agent' | 'fix-apply' | 'custom';
1855
+ interface AgentAction {
1856
+ id: string;
1857
+ type: ActionType;
1858
+ agentId?: string;
1859
+ timestamp: string;
1860
+ duration?: number;
1861
+ status: 'started' | 'completed' | 'failed';
1862
+ context: ActionContext;
1863
+ result?: ActionResult;
1864
+ error?: {
1865
+ code: string;
1866
+ message: string;
1867
+ };
1868
+ }
1869
+ interface ActionContext {
1870
+ trigger: 'manual' | 'ci' | 'scheduled' | 'agent';
1871
+ files?: string[];
1872
+ commitSha?: string;
1873
+ prNumber?: number;
1874
+ branch?: string;
1875
+ metadata?: Record<string, unknown>;
1876
+ }
1877
+ interface ActionResult {
1878
+ outcome: 'success' | 'partial' | 'failure';
1879
+ summary: string;
1880
+ data?: unknown;
1881
+ }
1882
+ type ActionEventType = 'action:started' | 'action:completed' | 'action:failed' | 'action:*';
1883
+ interface ActionEvent {
1884
+ type: ActionEventType;
1885
+ action: AgentAction;
1886
+ timestamp: string;
1887
+ }
1888
+ type ActionEventHandler = (event: ActionEvent) => void | Promise<void>;
1889
+ interface TelemetryAdapter {
1890
+ readonly name: string;
1891
+ health(): Promise<Result<TelemetryHealth, FeedbackError>>;
1892
+ getMetrics(service: string, timeRange: TimeRange, metricNames?: string[]): Promise<Result<Metric[], FeedbackError>>;
1893
+ getTraces(service: string, timeRange: TimeRange, traceId?: string): Promise<Result<Trace[], FeedbackError>>;
1894
+ getLogs(service: string, timeRange: TimeRange, filter?: LogFilter): Promise<Result<LogEntry[], FeedbackError>>;
1895
+ }
1896
+ interface AgentExecutor {
1897
+ readonly name: string;
1898
+ health(): Promise<Result<ExecutorHealth, FeedbackError>>;
1899
+ spawn(config: AgentConfig): Promise<Result<AgentProcess, FeedbackError>>;
1900
+ status(processId: string): Promise<Result<AgentProcess, FeedbackError>>;
1901
+ wait(processId: string, timeout?: number): Promise<Result<PeerReview, FeedbackError>>;
1902
+ kill(processId: string): Promise<Result<void, FeedbackError>>;
1903
+ }
1904
+ interface ActionSink {
1905
+ readonly name: string;
1906
+ write(action: AgentAction): Promise<Result<void, FeedbackError>>;
1907
+ flush?(): Promise<Result<void, FeedbackError>>;
1908
+ close?(): Promise<void>;
1909
+ }
1910
+ interface ActionTracker {
1911
+ readonly action: AgentAction;
1912
+ complete(result: ActionResult): Promise<Result<AgentAction, FeedbackError>>;
1913
+ fail(error: {
1914
+ code: string;
1915
+ message: string;
1916
+ }): Promise<Result<AgentAction, FeedbackError>>;
1917
+ }
1918
+
1919
+ interface FeedbackConfig {
1920
+ telemetry?: TelemetryAdapter;
1921
+ executor?: AgentExecutor;
1922
+ sinks?: ActionSink[];
1923
+ emitEvents?: boolean;
1924
+ defaultTimeout?: number;
1925
+ rootDir?: string;
1926
+ }
1927
+ declare function configureFeedback(config: Partial<FeedbackConfig>): void;
1928
+ declare function getFeedbackConfig(): Readonly<FeedbackConfig>;
1929
+ declare function resetFeedbackConfig(): void;
1930
+
1931
+ declare class ChecklistBuilder {
1932
+ private rootDir;
1933
+ private harnessOptions?;
1934
+ private customRules;
1935
+ private diffOptions?;
1936
+ constructor(rootDir: string);
1937
+ withHarnessChecks(options?: SelfReviewConfig['harness']): this;
1938
+ addRule(rule: CustomRule): this;
1939
+ addRules(rules: CustomRule[]): this;
1940
+ withDiffAnalysis(options: SelfReviewConfig['diffAnalysis']): this;
1941
+ run(changes: CodeChanges): Promise<Result<ReviewChecklist, FeedbackError>>;
1942
+ }
1943
+
1944
+ declare function createSelfReview(changes: CodeChanges, config: SelfReviewConfig): Promise<Result<ReviewChecklist, FeedbackError>>;
1945
+
1946
+ declare function parseDiff(diff: string): Result<CodeChanges, FeedbackError>;
1947
+ declare function analyzeDiff(changes: CodeChanges, options: SelfReviewConfig['diffAnalysis']): Promise<Result<ReviewItem[], FeedbackError>>;
1948
+
1949
+ declare function requestPeerReview(agentType: AgentType, context: ReviewContext, options?: PeerReviewOptions): Promise<Result<PeerReview, FeedbackError>>;
1950
+ declare function requestMultiplePeerReviews(requests: Array<{
1951
+ agentType: AgentType;
1952
+ context: ReviewContext;
1953
+ options?: PeerReviewOptions;
1954
+ }>): Promise<Result<PeerReview[], FeedbackError>>;
1955
+
1956
+ declare class NoOpTelemetryAdapter implements TelemetryAdapter {
1957
+ readonly name = "noop";
1958
+ health(): Promise<Result<TelemetryHealth, FeedbackError>>;
1959
+ getMetrics(): Promise<Result<Metric[], FeedbackError>>;
1960
+ getTraces(): Promise<Result<Trace[], FeedbackError>>;
1961
+ getLogs(): Promise<Result<LogEntry[], FeedbackError>>;
1962
+ }
1963
+
1964
+ declare class NoOpExecutor implements AgentExecutor {
1965
+ readonly name = "noop";
1966
+ private processes;
1967
+ health(): Promise<Result<ExecutorHealth, FeedbackError>>;
1968
+ spawn(config: AgentConfig): Promise<Result<AgentProcess, FeedbackError>>;
1969
+ status(processId: string): Promise<Result<AgentProcess, FeedbackError>>;
1970
+ wait(processId: string): Promise<Result<PeerReview, FeedbackError>>;
1971
+ kill(processId: string): Promise<Result<void, FeedbackError>>;
1972
+ }
1973
+
1974
+ declare class AgentActionEmitter {
1975
+ private listeners;
1976
+ on(eventType: ActionEventType, handler: ActionEventHandler): () => void;
1977
+ once(eventType: ActionEventType, handler: ActionEventHandler): () => void;
1978
+ off(eventType: ActionEventType, handler: ActionEventHandler): void;
1979
+ emit(event: ActionEvent): void;
1980
+ listenerCount(eventType: ActionEventType): number;
1981
+ removeAllListeners(): void;
1982
+ }
1983
+ declare function getActionEmitter(): AgentActionEmitter;
1984
+ declare function logAgentAction(action: Omit<AgentAction, 'id' | 'timestamp'>): Promise<Result<AgentAction, FeedbackError>>;
1985
+ declare function trackAction(type: ActionType, context: ActionContext): ActionTracker;
1986
+
1987
+ interface ConsoleSinkOptions {
1988
+ level?: 'debug' | 'info' | 'warn' | 'error';
1989
+ format?: 'pretty' | 'json';
1990
+ verbose?: boolean;
1991
+ }
1992
+ declare class ConsoleSink implements ActionSink {
1993
+ readonly name = "console";
1994
+ private options;
1995
+ constructor(options?: ConsoleSinkOptions);
1996
+ write(action: AgentAction): Promise<Result<void, FeedbackError>>;
1997
+ private formatPretty;
1998
+ }
1999
+
2000
+ interface FileSinkOptions {
2001
+ mode?: 'append' | 'overwrite';
2002
+ bufferSize?: number;
2003
+ flushInterval?: number;
2004
+ }
2005
+ declare class FileSink implements ActionSink {
2006
+ readonly name = "file";
2007
+ private filePath;
2008
+ private options;
2009
+ private buffer;
2010
+ private flushTimer?;
2011
+ private initialized;
2012
+ constructor(filePath: string, options?: FileSinkOptions);
2013
+ private ensureDirectory;
2014
+ write(action: AgentAction): Promise<Result<void, FeedbackError>>;
2015
+ flush(): Promise<Result<void, FeedbackError>>;
2016
+ close(): Promise<void>;
2017
+ }
2018
+
2019
+ declare class NoOpSink implements ActionSink {
2020
+ readonly name = "noop";
2021
+ write(): Promise<Result<void, FeedbackError>>;
2022
+ }
2023
+
2024
+ declare const FailureEntrySchema: z.ZodObject<{
2025
+ date: z.ZodString;
2026
+ skill: z.ZodString;
2027
+ type: z.ZodString;
2028
+ description: z.ZodString;
2029
+ }, "strip", z.ZodTypeAny, {
2030
+ type: string;
2031
+ date: string;
2032
+ description: string;
2033
+ skill: string;
2034
+ }, {
2035
+ type: string;
2036
+ date: string;
2037
+ description: string;
2038
+ skill: string;
2039
+ }>;
2040
+ type FailureEntry = z.infer<typeof FailureEntrySchema>;
2041
+ declare const HandoffSchema: z.ZodObject<{
2042
+ timestamp: z.ZodString;
2043
+ fromSkill: z.ZodString;
2044
+ phase: z.ZodString;
2045
+ summary: z.ZodString;
2046
+ completed: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2047
+ pending: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2048
+ concerns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2049
+ decisions: z.ZodDefault<z.ZodArray<z.ZodObject<{
2050
+ what: z.ZodString;
2051
+ why: z.ZodString;
2052
+ }, "strip", z.ZodTypeAny, {
2053
+ what: string;
2054
+ why: string;
2055
+ }, {
2056
+ what: string;
2057
+ why: string;
2058
+ }>, "many">>;
2059
+ blockers: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2060
+ contextKeywords: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2061
+ }, "strip", z.ZodTypeAny, {
2062
+ pending: string[];
2063
+ completed: string[];
2064
+ timestamp: string;
2065
+ fromSkill: string;
2066
+ phase: string;
2067
+ summary: string;
2068
+ concerns: string[];
2069
+ decisions: {
2070
+ what: string;
2071
+ why: string;
2072
+ }[];
2073
+ blockers: string[];
2074
+ contextKeywords: string[];
2075
+ }, {
2076
+ timestamp: string;
2077
+ fromSkill: string;
2078
+ phase: string;
2079
+ summary: string;
2080
+ pending?: string[] | undefined;
2081
+ completed?: string[] | undefined;
2082
+ concerns?: string[] | undefined;
2083
+ decisions?: {
2084
+ what: string;
2085
+ why: string;
2086
+ }[] | undefined;
2087
+ blockers?: string[] | undefined;
2088
+ contextKeywords?: string[] | undefined;
2089
+ }>;
2090
+ type Handoff = z.infer<typeof HandoffSchema>;
2091
+ declare const GateResultSchema: z.ZodObject<{
2092
+ passed: z.ZodBoolean;
2093
+ checks: z.ZodArray<z.ZodObject<{
2094
+ name: z.ZodString;
2095
+ passed: z.ZodBoolean;
2096
+ command: z.ZodString;
2097
+ output: z.ZodOptional<z.ZodString>;
2098
+ duration: z.ZodOptional<z.ZodNumber>;
2099
+ }, "strip", z.ZodTypeAny, {
2100
+ name: string;
2101
+ passed: boolean;
2102
+ command: string;
2103
+ output?: string | undefined;
2104
+ duration?: number | undefined;
2105
+ }, {
2106
+ name: string;
2107
+ passed: boolean;
2108
+ command: string;
2109
+ output?: string | undefined;
2110
+ duration?: number | undefined;
2111
+ }>, "many">;
2112
+ }, "strip", z.ZodTypeAny, {
2113
+ passed: boolean;
2114
+ checks: {
2115
+ name: string;
2116
+ passed: boolean;
2117
+ command: string;
2118
+ output?: string | undefined;
2119
+ duration?: number | undefined;
2120
+ }[];
2121
+ }, {
2122
+ passed: boolean;
2123
+ checks: {
2124
+ name: string;
2125
+ passed: boolean;
2126
+ command: string;
2127
+ output?: string | undefined;
2128
+ duration?: number | undefined;
2129
+ }[];
2130
+ }>;
2131
+ type GateResult = z.infer<typeof GateResultSchema>;
2132
+ declare const GateConfigSchema: z.ZodObject<{
2133
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
2134
+ name: z.ZodString;
2135
+ command: z.ZodString;
2136
+ }, "strip", z.ZodTypeAny, {
2137
+ name: string;
2138
+ command: string;
2139
+ }, {
2140
+ name: string;
2141
+ command: string;
2142
+ }>, "many">>;
2143
+ trace: z.ZodOptional<z.ZodBoolean>;
2144
+ }, "strip", z.ZodTypeAny, {
2145
+ checks?: {
2146
+ name: string;
2147
+ command: string;
2148
+ }[] | undefined;
2149
+ trace?: boolean | undefined;
2150
+ }, {
2151
+ checks?: {
2152
+ name: string;
2153
+ command: string;
2154
+ }[] | undefined;
2155
+ trace?: boolean | undefined;
2156
+ }>;
2157
+ type GateConfig = z.infer<typeof GateConfigSchema>;
2158
+ declare const HarnessStateSchema: z.ZodObject<{
2159
+ schemaVersion: z.ZodLiteral<1>;
2160
+ position: z.ZodDefault<z.ZodObject<{
2161
+ phase: z.ZodOptional<z.ZodString>;
2162
+ task: z.ZodOptional<z.ZodString>;
2163
+ }, "strip", z.ZodTypeAny, {
2164
+ phase?: string | undefined;
2165
+ task?: string | undefined;
2166
+ }, {
2167
+ phase?: string | undefined;
2168
+ task?: string | undefined;
2169
+ }>>;
2170
+ decisions: z.ZodDefault<z.ZodArray<z.ZodObject<{
2171
+ date: z.ZodString;
2172
+ decision: z.ZodString;
2173
+ context: z.ZodString;
2174
+ }, "strip", z.ZodTypeAny, {
2175
+ date: string;
2176
+ context: string;
2177
+ decision: string;
2178
+ }, {
2179
+ date: string;
2180
+ context: string;
2181
+ decision: string;
2182
+ }>, "many">>;
2183
+ blockers: z.ZodDefault<z.ZodArray<z.ZodObject<{
2184
+ id: z.ZodString;
2185
+ description: z.ZodString;
2186
+ status: z.ZodEnum<["open", "resolved"]>;
2187
+ }, "strip", z.ZodTypeAny, {
2188
+ id: string;
2189
+ status: "open" | "resolved";
2190
+ description: string;
2191
+ }, {
2192
+ id: string;
2193
+ status: "open" | "resolved";
2194
+ description: string;
2195
+ }>, "many">>;
2196
+ progress: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<["pending", "in_progress", "complete"]>>>;
2197
+ lastSession: z.ZodOptional<z.ZodObject<{
2198
+ date: z.ZodString;
2199
+ summary: z.ZodString;
2200
+ lastSkill: z.ZodOptional<z.ZodString>;
2201
+ pendingTasks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2202
+ }, "strip", z.ZodTypeAny, {
2203
+ date: string;
2204
+ summary: string;
2205
+ lastSkill?: string | undefined;
2206
+ pendingTasks?: string[] | undefined;
2207
+ }, {
2208
+ date: string;
2209
+ summary: string;
2210
+ lastSkill?: string | undefined;
2211
+ pendingTasks?: string[] | undefined;
2212
+ }>>;
2213
+ }, "strip", z.ZodTypeAny, {
2214
+ decisions: {
2215
+ date: string;
2216
+ context: string;
2217
+ decision: string;
2218
+ }[];
2219
+ blockers: {
2220
+ id: string;
2221
+ status: "open" | "resolved";
2222
+ description: string;
2223
+ }[];
2224
+ schemaVersion: 1;
2225
+ position: {
2226
+ phase?: string | undefined;
2227
+ task?: string | undefined;
2228
+ };
2229
+ progress: Record<string, "pending" | "in_progress" | "complete">;
2230
+ lastSession?: {
2231
+ date: string;
2232
+ summary: string;
2233
+ lastSkill?: string | undefined;
2234
+ pendingTasks?: string[] | undefined;
2235
+ } | undefined;
2236
+ }, {
2237
+ schemaVersion: 1;
2238
+ decisions?: {
2239
+ date: string;
2240
+ context: string;
2241
+ decision: string;
2242
+ }[] | undefined;
2243
+ blockers?: {
2244
+ id: string;
2245
+ status: "open" | "resolved";
2246
+ description: string;
2247
+ }[] | undefined;
2248
+ position?: {
2249
+ phase?: string | undefined;
2250
+ task?: string | undefined;
2251
+ } | undefined;
2252
+ progress?: Record<string, "pending" | "in_progress" | "complete"> | undefined;
2253
+ lastSession?: {
2254
+ date: string;
2255
+ summary: string;
2256
+ lastSkill?: string | undefined;
2257
+ pendingTasks?: string[] | undefined;
2258
+ } | undefined;
2259
+ }>;
2260
+ type HarnessState = z.infer<typeof HarnessStateSchema>;
2261
+ declare const DEFAULT_STATE: HarnessState;
2262
+
2263
+ declare function loadState(projectPath: string): Promise<Result<HarnessState, Error>>;
2264
+ declare function saveState(projectPath: string, state: HarnessState): Promise<Result<void, Error>>;
2265
+ declare function appendLearning(projectPath: string, learning: string, skillName?: string, outcome?: string): Promise<Result<void, Error>>;
2266
+ declare function loadRelevantLearnings(projectPath: string, skillName?: string): Promise<Result<string[], Error>>;
2267
+ declare function appendFailure(projectPath: string, description: string, skillName: string, type: string): Promise<Result<void, Error>>;
2268
+ declare function loadFailures(projectPath: string): Promise<Result<Array<{
2269
+ date: string;
2270
+ skill: string;
2271
+ type: string;
2272
+ description: string;
2273
+ }>, Error>>;
2274
+ declare function archiveFailures(projectPath: string): Promise<Result<void, Error>>;
2275
+ declare function saveHandoff(projectPath: string, handoff: Handoff): Promise<Result<void, Error>>;
2276
+ declare function loadHandoff(projectPath: string): Promise<Result<Handoff | null, Error>>;
2277
+ declare function runMechanicalGate(projectPath: string): Promise<Result<GateResult, Error>>;
2278
+
2279
+ type StepExecutor = (step: WorkflowStep, previousArtifact?: string) => Promise<WorkflowStepResult>;
2280
+ declare function executeWorkflow(workflow: Workflow, executor: StepExecutor): Promise<WorkflowResult>;
2281
+
2282
+ interface PipelineOptions {
2283
+ hooks?: SkillLifecycleHooks;
2284
+ maxTurns?: number;
2285
+ }
2286
+ interface PipelineResult {
2287
+ success: boolean;
2288
+ context: SkillContext;
2289
+ result?: SkillResult;
2290
+ error?: string;
2291
+ turnsExecuted: number;
2292
+ durationMs: number;
2293
+ }
2294
+ type SkillExecutor = (context: SkillContext) => Promise<SkillResult>;
2295
+ type TurnExecutor = (context: TurnContext) => Promise<{
2296
+ result: unknown;
2297
+ done: boolean;
2298
+ }>;
2299
+ declare function runPipeline(initialContext: SkillContext, executor: SkillExecutor, options?: PipelineOptions): Promise<PipelineResult>;
2300
+ declare function runMultiTurnPipeline(initialContext: SkillContext, turnExecutor: TurnExecutor, options?: PipelineOptions): Promise<PipelineResult>;
2301
+
2302
+ /**
2303
+ * @harness-engineering/core
2304
+ *
2305
+ * Core library for Harness Engineering toolkit
2306
+ */
2307
+
2308
+ declare const VERSION = "0.5.0";
2309
+
2310
+ 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, Err, 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, Ok, type ParseError, type PatternConfig, PatternConfigSchema, type PatternMatch, type PatternReport, type PatternViolation, type PeerReview, type PeerReviewOptions, type PipelineOptions, type PipelineResult, REQUIRED_SECTIONS, type ReachabilityNode, type Result, type ReviewChecklist, type ReviewComment, type ReviewContext, type ReviewItem, 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, buildReachabilityMap, buildSnapshot, checkConfigPattern, checkDocCoverage, configureFeedback, contextBudget, contextFilter, createBoundaryValidator, createError, createFixes, createParseError, createSelfReview, defineLayer, detectCircularDeps, detectCircularDepsInFiles, detectDeadCode, detectDocDrift, detectPatternViolations, executeWorkflow, extractMarkdownLinks, extractSections, findPossibleMatches, generateAgentsMap, generateSuggestions, getActionEmitter, getFeedbackConfig, getPhaseCategories, isErr, isOk, levenshteinDistance, loadFailures, loadHandoff, loadRelevantLearnings, loadState, logAgentAction, parseDiff, parseDocumentationFile, previewFix, requestMultiplePeerReviews, requestPeerReview, resetFeedbackConfig, resolveEntryPoints, resolveFileToLayer, runMechanicalGate, runMultiTurnPipeline, runPipeline, saveHandoff, saveState, trackAction, validateAgentsMap, validateBoundaries, validateCommitMessage, validateConfig, validateDependencies, validateFileStructure, validateKnowledgeMap, validatePatternConfig };