@corbat-tech/coco 1.0.2

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,3184 @@
1
+ import { z } from 'zod';
2
+ import { Logger, ILogObj } from 'tslog';
3
+
4
+ declare const VERSION: string;
5
+
6
+ /**
7
+ * Phase types for Corbat-Coco
8
+ */
9
+ /**
10
+ * Project phases
11
+ */
12
+ type Phase = "idle" | "converge" | "orchestrate" | "complete" | "output";
13
+ /**
14
+ * Result of phase execution
15
+ */
16
+ interface PhaseResult {
17
+ phase: Phase;
18
+ success: boolean;
19
+ artifacts: PhaseArtifact[];
20
+ error?: string;
21
+ metrics?: PhaseMetrics;
22
+ }
23
+ /**
24
+ * Artifact produced by a phase
25
+ */
26
+ interface PhaseArtifact {
27
+ type: ArtifactType;
28
+ path: string;
29
+ description: string;
30
+ }
31
+ /**
32
+ * Types of artifacts
33
+ */
34
+ type ArtifactType = "specification" | "architecture" | "adr" | "diagram" | "backlog" | "code" | "test" | "documentation" | "cicd" | "deployment";
35
+ /**
36
+ * Phase execution metrics
37
+ */
38
+ interface PhaseMetrics {
39
+ startTime: Date;
40
+ endTime: Date;
41
+ durationMs: number;
42
+ llmCalls: number;
43
+ tokensUsed: number;
44
+ }
45
+ /**
46
+ * Phase executor interface
47
+ */
48
+ interface PhaseExecutor {
49
+ name: string;
50
+ description: string;
51
+ /**
52
+ * Check if the phase can start given current state
53
+ */
54
+ canStart(context: PhaseContext): boolean;
55
+ /**
56
+ * Execute the phase
57
+ */
58
+ execute(context: PhaseContext): Promise<PhaseResult>;
59
+ /**
60
+ * Check if the phase can complete
61
+ */
62
+ canComplete(context: PhaseContext): boolean;
63
+ /**
64
+ * Create a checkpoint for recovery
65
+ */
66
+ checkpoint(context: PhaseContext): Promise<PhaseCheckpoint>;
67
+ /**
68
+ * Restore from a checkpoint
69
+ */
70
+ restore(checkpoint: PhaseCheckpoint, context: PhaseContext): Promise<void>;
71
+ }
72
+ /**
73
+ * Context passed to phase executors
74
+ */
75
+ interface PhaseContext {
76
+ projectPath: string;
77
+ config: PhaseConfig;
78
+ state: PhaseState;
79
+ tools: PhaseTools;
80
+ llm: LLMInterface;
81
+ }
82
+ /**
83
+ * Phase-specific configuration
84
+ */
85
+ interface PhaseConfig {
86
+ quality: {
87
+ minScore: number;
88
+ minCoverage: number;
89
+ maxIterations: number;
90
+ convergenceThreshold: number;
91
+ };
92
+ timeouts: {
93
+ phaseTimeout: number;
94
+ taskTimeout: number;
95
+ llmTimeout: number;
96
+ };
97
+ }
98
+ /**
99
+ * Phase state (what the phase has produced so far)
100
+ */
101
+ interface PhaseState {
102
+ artifacts: PhaseArtifact[];
103
+ progress: number;
104
+ checkpoint: PhaseCheckpoint | null;
105
+ }
106
+ /**
107
+ * Tools available to phases
108
+ */
109
+ interface PhaseTools {
110
+ file: FileTools;
111
+ bash: BashTools;
112
+ git: GitTools;
113
+ test: TestTools;
114
+ quality: QualityTools;
115
+ }
116
+ /**
117
+ * LLM interface for phases
118
+ */
119
+ interface LLMInterface {
120
+ chat(messages: Message$1[]): Promise<ChatResponse$1>;
121
+ chatWithTools(messages: Message$1[], tools: ToolDefinition$2[]): Promise<ChatWithToolsResponse$1>;
122
+ }
123
+ /**
124
+ * Phase checkpoint for recovery
125
+ */
126
+ interface PhaseCheckpoint {
127
+ phase: Phase;
128
+ timestamp: Date;
129
+ state: PhaseState;
130
+ resumePoint: string;
131
+ }
132
+ interface FileTools {
133
+ read(path: string): Promise<string>;
134
+ write(path: string, content: string): Promise<void>;
135
+ exists(path: string): Promise<boolean>;
136
+ glob(pattern: string): Promise<string[]>;
137
+ }
138
+ interface BashTools {
139
+ exec(command: string, options?: ExecOptions): Promise<ExecResult>;
140
+ }
141
+ interface GitTools {
142
+ status(): Promise<GitStatus>;
143
+ commit(message: string, files?: string[]): Promise<void>;
144
+ push(): Promise<void>;
145
+ }
146
+ interface TestTools {
147
+ run(pattern?: string): Promise<TestResult>;
148
+ coverage(): Promise<CoverageResult>;
149
+ }
150
+ interface QualityTools {
151
+ lint(files: string[]): Promise<LintResult>;
152
+ complexity(files: string[]): Promise<ComplexityResult>;
153
+ security(files: string[]): Promise<SecurityResult>;
154
+ }
155
+ interface Message$1 {
156
+ role: "system" | "user" | "assistant";
157
+ content: string;
158
+ }
159
+ interface ChatResponse$1 {
160
+ content: string;
161
+ usage: {
162
+ inputTokens: number;
163
+ outputTokens: number;
164
+ };
165
+ }
166
+ interface ToolDefinition$2 {
167
+ name: string;
168
+ description: string;
169
+ parameters: Record<string, unknown>;
170
+ }
171
+ interface ChatWithToolsResponse$1 extends ChatResponse$1 {
172
+ toolCalls?: ToolCall$1[];
173
+ }
174
+ interface ToolCall$1 {
175
+ name: string;
176
+ arguments: Record<string, unknown>;
177
+ }
178
+ interface ExecOptions {
179
+ cwd?: string;
180
+ timeout?: number;
181
+ env?: Record<string, string>;
182
+ }
183
+ interface ExecResult {
184
+ stdout: string;
185
+ stderr: string;
186
+ exitCode: number;
187
+ }
188
+ interface GitStatus {
189
+ branch: string;
190
+ clean: boolean;
191
+ staged: string[];
192
+ unstaged: string[];
193
+ untracked: string[];
194
+ }
195
+ interface TestResult {
196
+ passed: number;
197
+ failed: number;
198
+ skipped: number;
199
+ duration: number;
200
+ failures: TestFailure[];
201
+ }
202
+ interface TestFailure {
203
+ name: string;
204
+ message: string;
205
+ stack?: string;
206
+ }
207
+ interface CoverageResult {
208
+ lines: number;
209
+ branches: number;
210
+ functions: number;
211
+ statements: number;
212
+ }
213
+ interface LintResult {
214
+ errors: number;
215
+ warnings: number;
216
+ issues: LintIssue[];
217
+ }
218
+ interface LintIssue {
219
+ file: string;
220
+ line: number;
221
+ column: number;
222
+ severity: "error" | "warning";
223
+ message: string;
224
+ rule: string;
225
+ }
226
+ interface ComplexityResult {
227
+ averageComplexity: number;
228
+ maxComplexity: number;
229
+ files: FileComplexity[];
230
+ }
231
+ interface FileComplexity {
232
+ file: string;
233
+ complexity: number;
234
+ functions: FunctionComplexity[];
235
+ }
236
+ interface FunctionComplexity {
237
+ name: string;
238
+ complexity: number;
239
+ line: number;
240
+ }
241
+ interface SecurityResult {
242
+ vulnerabilities: number;
243
+ issues: SecurityIssue[];
244
+ }
245
+ interface SecurityIssue {
246
+ severity: "critical" | "high" | "medium" | "low";
247
+ type: string;
248
+ message: string;
249
+ file?: string;
250
+ line?: number;
251
+ }
252
+
253
+ /**
254
+ * Quality system types for Corbat-Coco
255
+ */
256
+ /**
257
+ * Multi-dimensional quality scores
258
+ */
259
+ interface QualityScores {
260
+ /**
261
+ * Overall weighted score (0-100)
262
+ */
263
+ overall: number;
264
+ /**
265
+ * Individual dimension scores
266
+ */
267
+ dimensions: QualityDimensions;
268
+ /**
269
+ * Metadata
270
+ */
271
+ evaluatedAt: Date;
272
+ evaluationDurationMs: number;
273
+ }
274
+ /**
275
+ * Quality dimensions
276
+ */
277
+ interface QualityDimensions {
278
+ /**
279
+ * Does the code work correctly? (tests pass, logic correct)
280
+ */
281
+ correctness: number;
282
+ /**
283
+ * Are all requirements met?
284
+ */
285
+ completeness: number;
286
+ /**
287
+ * Are edge cases handled?
288
+ */
289
+ robustness: number;
290
+ /**
291
+ * Is the code clear and understandable?
292
+ */
293
+ readability: number;
294
+ /**
295
+ * Is the code easy to modify?
296
+ */
297
+ maintainability: number;
298
+ /**
299
+ * Cyclomatic complexity score (inverted - higher is better)
300
+ */
301
+ complexity: number;
302
+ /**
303
+ * DRY score - code duplication (inverted - higher is better)
304
+ */
305
+ duplication: number;
306
+ /**
307
+ * Line and branch coverage
308
+ */
309
+ testCoverage: number;
310
+ /**
311
+ * Test meaningfulness and quality
312
+ */
313
+ testQuality: number;
314
+ /**
315
+ * Security vulnerability score (100 = no vulnerabilities)
316
+ */
317
+ security: number;
318
+ /**
319
+ * Documentation coverage
320
+ */
321
+ documentation: number;
322
+ /**
323
+ * Linting and style compliance
324
+ */
325
+ style: number;
326
+ }
327
+ /**
328
+ * Quality thresholds
329
+ */
330
+ interface QualityThresholds {
331
+ /**
332
+ * Minimum acceptable scores (must achieve to pass)
333
+ */
334
+ minimum: {
335
+ overall: number;
336
+ testCoverage: number;
337
+ security: number;
338
+ };
339
+ /**
340
+ * Target scores (excellent quality)
341
+ */
342
+ target: {
343
+ overall: number;
344
+ testCoverage: number;
345
+ };
346
+ /**
347
+ * Convergence threshold (max score delta to consider converged)
348
+ */
349
+ convergenceThreshold: number;
350
+ /**
351
+ * Maximum iterations before forced completion
352
+ */
353
+ maxIterations: number;
354
+ /**
355
+ * Minimum iterations before checking convergence
356
+ */
357
+ minIterations: number;
358
+ }
359
+
360
+ /**
361
+ * Main orchestrator interface
362
+ */
363
+ interface Orchestrator {
364
+ initialize(projectPath: string): Promise<void>;
365
+ start(): Promise<void>;
366
+ pause(): Promise<void>;
367
+ resume(): Promise<void>;
368
+ stop(): Promise<void>;
369
+ getCurrentPhase(): Phase;
370
+ transitionTo(phase: Phase): Promise<PhaseResult>;
371
+ getState(): ProjectState;
372
+ getProgress(): Progress;
373
+ on<K extends keyof OrchestratorEvents>(event: K, handler: OrchestratorEvents[K]): void;
374
+ off<K extends keyof OrchestratorEvents>(event: K, handler: OrchestratorEvents[K]): void;
375
+ }
376
+ /**
377
+ * Orchestrator configuration
378
+ */
379
+ interface OrchestratorConfig {
380
+ projectPath: string;
381
+ provider: {
382
+ type: "anthropic" | "openai" | "gemini" | "kimi" | "lmstudio";
383
+ apiKey?: string;
384
+ model: string;
385
+ maxTokens?: number;
386
+ };
387
+ quality: {
388
+ minScore: number;
389
+ minCoverage: number;
390
+ maxIterations: number;
391
+ convergenceThreshold: number;
392
+ };
393
+ persistence: {
394
+ checkpointInterval: number;
395
+ maxCheckpoints: number;
396
+ };
397
+ }
398
+ /**
399
+ * Project state
400
+ */
401
+ interface ProjectState {
402
+ id: string;
403
+ name: string;
404
+ path: string;
405
+ createdAt: Date;
406
+ updatedAt: Date;
407
+ currentPhase: Phase;
408
+ phaseHistory: PhaseTransition[];
409
+ currentTask: TaskState | null;
410
+ completedTasks: string[];
411
+ pendingTasks: string[];
412
+ lastScores: QualityScores | null;
413
+ qualityHistory: QualityScores[];
414
+ lastCheckpoint: CheckpointRef | null;
415
+ }
416
+ /**
417
+ * Phase transition record
418
+ */
419
+ interface PhaseTransition {
420
+ from: Phase;
421
+ to: Phase;
422
+ timestamp: Date;
423
+ reason: string;
424
+ }
425
+ /**
426
+ * Current task state
427
+ */
428
+ interface TaskState {
429
+ id: string;
430
+ title: string;
431
+ iteration: number;
432
+ startedAt: Date;
433
+ scores: QualityScores[];
434
+ }
435
+ /**
436
+ * Checkpoint reference
437
+ */
438
+ interface CheckpointRef {
439
+ id: string;
440
+ timestamp: Date;
441
+ phase: Phase;
442
+ canResume: boolean;
443
+ }
444
+ /**
445
+ * Progress information
446
+ */
447
+ interface Progress {
448
+ phase: Phase;
449
+ phaseProgress: number;
450
+ overallProgress: number;
451
+ sprint?: {
452
+ id: string;
453
+ tasksCompleted: number;
454
+ tasksTotal: number;
455
+ avgQuality: number;
456
+ };
457
+ task?: {
458
+ id: string;
459
+ title: string;
460
+ iteration: number;
461
+ currentScore: number;
462
+ };
463
+ startedAt: Date;
464
+ estimatedCompletion?: Date;
465
+ }
466
+ /**
467
+ * Orchestrator events
468
+ */
469
+ interface OrchestratorEvents {
470
+ "phase:start": (phase: Phase) => void;
471
+ "phase:complete": (phase: Phase, result: PhaseResult) => void;
472
+ "task:start": (taskId: string) => void;
473
+ "task:iteration": (taskId: string, iteration: number, score: number) => void;
474
+ "task:complete": (taskId: string, finalScore: number) => void;
475
+ "checkpoint:created": (checkpointId: string) => void;
476
+ error: (error: Error) => void;
477
+ }
478
+
479
+ /**
480
+ * Create a new orchestrator instance
481
+ */
482
+ declare function createOrchestrator(config: OrchestratorConfig): Orchestrator;
483
+
484
+ /**
485
+ * Configuration schema for Corbat-Coco
486
+ */
487
+
488
+ /**
489
+ * Complete configuration schema
490
+ */
491
+ declare const CocoConfigSchema: z.ZodObject<{
492
+ project: z.ZodObject<{
493
+ name: z.ZodString;
494
+ version: z.ZodDefault<z.ZodString>;
495
+ description: z.ZodOptional<z.ZodString>;
496
+ }, z.core.$strip>;
497
+ provider: z.ZodDefault<z.ZodObject<{
498
+ type: z.ZodDefault<z.ZodEnum<{
499
+ anthropic: "anthropic";
500
+ openai: "openai";
501
+ gemini: "gemini";
502
+ kimi: "kimi";
503
+ }>>;
504
+ apiKey: z.ZodOptional<z.ZodString>;
505
+ model: z.ZodDefault<z.ZodString>;
506
+ maxTokens: z.ZodDefault<z.ZodNumber>;
507
+ temperature: z.ZodDefault<z.ZodNumber>;
508
+ timeout: z.ZodDefault<z.ZodNumber>;
509
+ }, z.core.$strip>>;
510
+ quality: z.ZodDefault<z.ZodObject<{
511
+ minScore: z.ZodDefault<z.ZodNumber>;
512
+ minCoverage: z.ZodDefault<z.ZodNumber>;
513
+ maxIterations: z.ZodDefault<z.ZodNumber>;
514
+ minIterations: z.ZodDefault<z.ZodNumber>;
515
+ convergenceThreshold: z.ZodDefault<z.ZodNumber>;
516
+ securityThreshold: z.ZodDefault<z.ZodNumber>;
517
+ }, z.core.$strip>>;
518
+ persistence: z.ZodDefault<z.ZodObject<{
519
+ checkpointInterval: z.ZodDefault<z.ZodNumber>;
520
+ maxCheckpoints: z.ZodDefault<z.ZodNumber>;
521
+ retentionDays: z.ZodDefault<z.ZodNumber>;
522
+ compressOldCheckpoints: z.ZodDefault<z.ZodBoolean>;
523
+ }, z.core.$strip>>;
524
+ stack: z.ZodOptional<z.ZodObject<{
525
+ language: z.ZodEnum<{
526
+ typescript: "typescript";
527
+ python: "python";
528
+ go: "go";
529
+ rust: "rust";
530
+ java: "java";
531
+ }>;
532
+ framework: z.ZodOptional<z.ZodString>;
533
+ profile: z.ZodOptional<z.ZodString>;
534
+ }, z.core.$strip>>;
535
+ integrations: z.ZodOptional<z.ZodObject<{
536
+ github: z.ZodOptional<z.ZodObject<{
537
+ enabled: z.ZodDefault<z.ZodBoolean>;
538
+ token: z.ZodOptional<z.ZodString>;
539
+ repo: z.ZodOptional<z.ZodString>;
540
+ createPRs: z.ZodDefault<z.ZodBoolean>;
541
+ createIssues: z.ZodDefault<z.ZodBoolean>;
542
+ }, z.core.$strip>>;
543
+ }, z.core.$strip>>;
544
+ mcp: z.ZodOptional<z.ZodObject<{
545
+ enabled: z.ZodDefault<z.ZodBoolean>;
546
+ configFile: z.ZodOptional<z.ZodString>;
547
+ servers: z.ZodDefault<z.ZodArray<z.ZodObject<{
548
+ name: z.ZodString;
549
+ transport: z.ZodEnum<{
550
+ stdio: "stdio";
551
+ http: "http";
552
+ sse: "sse";
553
+ }>;
554
+ command: z.ZodOptional<z.ZodString>;
555
+ args: z.ZodOptional<z.ZodArray<z.ZodString>>;
556
+ url: z.ZodOptional<z.ZodString>;
557
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
558
+ auth: z.ZodOptional<z.ZodObject<{
559
+ type: z.ZodEnum<{
560
+ apikey: "apikey";
561
+ oauth: "oauth";
562
+ bearer: "bearer";
563
+ }>;
564
+ token: z.ZodOptional<z.ZodString>;
565
+ tokenEnv: z.ZodOptional<z.ZodString>;
566
+ headerName: z.ZodOptional<z.ZodString>;
567
+ }, z.core.$strip>>;
568
+ enabled: z.ZodDefault<z.ZodBoolean>;
569
+ description: z.ZodOptional<z.ZodString>;
570
+ }, z.core.$strip>>>;
571
+ }, z.core.$strip>>;
572
+ tools: z.ZodOptional<z.ZodObject<{
573
+ webSearch: z.ZodOptional<z.ZodObject<{
574
+ engine: z.ZodDefault<z.ZodEnum<{
575
+ duckduckgo: "duckduckgo";
576
+ brave: "brave";
577
+ serpapi: "serpapi";
578
+ }>>;
579
+ apiKey: z.ZodOptional<z.ZodString>;
580
+ maxResults: z.ZodDefault<z.ZodNumber>;
581
+ }, z.core.$strip>>;
582
+ memory: z.ZodOptional<z.ZodObject<{
583
+ maxMemories: z.ZodDefault<z.ZodNumber>;
584
+ scope: z.ZodDefault<z.ZodEnum<{
585
+ global: "global";
586
+ project: "project";
587
+ both: "both";
588
+ }>>;
589
+ }, z.core.$strip>>;
590
+ checkpoint: z.ZodOptional<z.ZodObject<{
591
+ maxCheckpoints: z.ZodDefault<z.ZodNumber>;
592
+ useGitStash: z.ZodDefault<z.ZodBoolean>;
593
+ }, z.core.$strip>>;
594
+ semanticSearch: z.ZodOptional<z.ZodObject<{
595
+ model: z.ZodDefault<z.ZodString>;
596
+ chunkSize: z.ZodDefault<z.ZodNumber>;
597
+ threshold: z.ZodDefault<z.ZodNumber>;
598
+ }, z.core.$strip>>;
599
+ }, z.core.$strip>>;
600
+ }, z.core.$strip>;
601
+ type CocoConfig = z.infer<typeof CocoConfigSchema>;
602
+
603
+ /**
604
+ * Configuration loader for Corbat-Coco
605
+ *
606
+ * Supports hierarchical configuration with priority:
607
+ * 1. Project config (<project>/.coco/config.json)
608
+ * 2. Global config (~/.coco/config.json)
609
+ * 3. Environment variables
610
+ * 4. Built-in defaults
611
+ */
612
+
613
+ /**
614
+ * Load configuration from file with hierarchical fallback
615
+ *
616
+ * Priority order:
617
+ * 1. Explicit configPath parameter
618
+ * 2. Project config (<cwd>/.coco/config.json)
619
+ * 3. Global config (~/.coco/config.json)
620
+ * 4. Built-in defaults
621
+ */
622
+ declare function loadConfig(configPath?: string): Promise<CocoConfig>;
623
+ /**
624
+ * Save configuration to file
625
+ *
626
+ * @param config - Configuration to save
627
+ * @param configPath - Path to save to (defaults to project config)
628
+ * @param global - If true, saves to global config instead
629
+ */
630
+ declare function saveConfig(config: CocoConfig, configPath?: string, global?: boolean): Promise<void>;
631
+ /**
632
+ * Create default configuration
633
+ */
634
+ declare function createDefaultConfig(projectName: string, language?: "typescript" | "python" | "go" | "rust" | "java"): CocoConfig;
635
+ /**
636
+ * Check if configuration exists
637
+ *
638
+ * @param scope - "project" | "global" | "any" (default: "any")
639
+ */
640
+ declare function configExists(configPath?: string, scope?: "project" | "global" | "any"): Promise<boolean>;
641
+
642
+ /**
643
+ * Types for the CONVERGE phase
644
+ *
645
+ * This phase focuses on requirement discovery and specification generation
646
+ */
647
+ /**
648
+ * Discovery session state
649
+ */
650
+ interface DiscoverySession {
651
+ id: string;
652
+ startedAt: Date;
653
+ updatedAt: Date;
654
+ status: DiscoveryStatus;
655
+ /** Initial user input */
656
+ initialInput: string;
657
+ /** Conversation history */
658
+ conversation: DiscoveryMessage[];
659
+ /** Extracted requirements */
660
+ requirements: Requirement[];
661
+ /** Open questions */
662
+ openQuestions: Question[];
663
+ /** Clarifications received */
664
+ clarifications: Clarification[];
665
+ /** Assumptions made */
666
+ assumptions: Assumption[];
667
+ /** Technology decisions */
668
+ techDecisions: TechDecision[];
669
+ }
670
+ /**
671
+ * Discovery session status
672
+ */
673
+ type DiscoveryStatus = "gathering" | "clarifying" | "refining" | "complete" | "spec_generated";
674
+ /**
675
+ * Message in discovery conversation
676
+ */
677
+ interface DiscoveryMessage {
678
+ id: string;
679
+ timestamp: Date;
680
+ role: "user" | "assistant";
681
+ content: string;
682
+ /** Extracted data from this message */
683
+ extracted?: {
684
+ requirements?: string[];
685
+ questions?: string[];
686
+ decisions?: string[];
687
+ };
688
+ }
689
+ /**
690
+ * A requirement gathered from discovery
691
+ */
692
+ interface Requirement {
693
+ id: string;
694
+ category: RequirementCategory;
695
+ priority: RequirementPriority;
696
+ title: string;
697
+ description: string;
698
+ /** Source message ID */
699
+ sourceMessageId: string;
700
+ /** Whether this is explicitly stated or inferred */
701
+ explicit: boolean;
702
+ /** Acceptance criteria */
703
+ acceptanceCriteria?: string[];
704
+ /** Related requirements */
705
+ relatedTo?: string[];
706
+ /** Status */
707
+ status: "draft" | "confirmed" | "removed";
708
+ }
709
+ /**
710
+ * Requirement categories
711
+ */
712
+ type RequirementCategory = "functional" | "non_functional" | "technical" | "user_experience" | "integration" | "deployment" | "constraint";
713
+ /**
714
+ * Requirement priority
715
+ */
716
+ type RequirementPriority = "must_have" | "should_have" | "could_have" | "wont_have";
717
+ /**
718
+ * A question to ask the user
719
+ */
720
+ interface Question {
721
+ id: string;
722
+ category: QuestionCategory;
723
+ question: string;
724
+ context: string;
725
+ importance: "critical" | "important" | "helpful";
726
+ /** Default answer if user doesn't respond */
727
+ defaultAnswer?: string;
728
+ /** Suggested options */
729
+ options?: string[];
730
+ /** Whether this has been asked */
731
+ asked: boolean;
732
+ /** User's answer */
733
+ answer?: string;
734
+ }
735
+ /**
736
+ * Question categories
737
+ */
738
+ type QuestionCategory = "clarification" | "expansion" | "decision" | "confirmation" | "scope" | "priority";
739
+ /**
740
+ * A clarification received from user
741
+ */
742
+ interface Clarification {
743
+ questionId: string;
744
+ answer: string;
745
+ timestamp: Date;
746
+ /** Requirements affected by this clarification */
747
+ affectedRequirements: string[];
748
+ /** New requirements created from this */
749
+ newRequirements?: string[];
750
+ }
751
+ /**
752
+ * An assumption made during discovery
753
+ */
754
+ interface Assumption {
755
+ id: string;
756
+ category: string;
757
+ statement: string;
758
+ confidence: "high" | "medium" | "low";
759
+ /** Whether user has confirmed this */
760
+ confirmed: boolean;
761
+ /** Impact if wrong */
762
+ impactIfWrong: string;
763
+ }
764
+ /**
765
+ * A technology decision
766
+ */
767
+ interface TechDecision {
768
+ id: string;
769
+ area: TechArea;
770
+ decision: string;
771
+ alternatives: string[];
772
+ rationale: string;
773
+ /** Whether explicitly requested or recommended */
774
+ explicit: boolean;
775
+ /** Impact on other decisions */
776
+ impact?: string[];
777
+ }
778
+ /**
779
+ * Technology areas
780
+ */
781
+ type TechArea = "language" | "framework" | "database" | "infrastructure" | "testing" | "ci_cd" | "monitoring" | "security";
782
+ /**
783
+ * Generated specification document
784
+ */
785
+ interface Specification {
786
+ version: string;
787
+ generatedAt: Date;
788
+ /** Project overview */
789
+ overview: ProjectOverview;
790
+ /** All requirements organized */
791
+ requirements: RequirementsSection;
792
+ /** Technical specifications */
793
+ technical: TechnicalSection;
794
+ /** Assumptions and risks */
795
+ assumptions: AssumptionsSection;
796
+ /** Out of scope items */
797
+ outOfScope: string[];
798
+ /** Open questions (if any remain) */
799
+ openQuestions: Question[];
800
+ }
801
+ /**
802
+ * Project overview section
803
+ */
804
+ interface ProjectOverview {
805
+ name: string;
806
+ description: string;
807
+ goals: string[];
808
+ targetUsers: string[];
809
+ successCriteria: string[];
810
+ }
811
+ /**
812
+ * Requirements section
813
+ */
814
+ interface RequirementsSection {
815
+ functional: Requirement[];
816
+ nonFunctional: Requirement[];
817
+ constraints: Requirement[];
818
+ }
819
+ /**
820
+ * Technical specifications section
821
+ */
822
+ interface TechnicalSection {
823
+ stack: TechDecision[];
824
+ architecture: string;
825
+ integrations: string[];
826
+ deployment: string;
827
+ }
828
+ /**
829
+ * Assumptions section
830
+ */
831
+ interface AssumptionsSection {
832
+ confirmed: Assumption[];
833
+ unconfirmed: Assumption[];
834
+ risks: Risk[];
835
+ }
836
+ /**
837
+ * A project risk
838
+ */
839
+ interface Risk {
840
+ id: string;
841
+ description: string;
842
+ probability: "high" | "medium" | "low";
843
+ impact: "high" | "medium" | "low";
844
+ mitigation: string;
845
+ }
846
+ /**
847
+ * Discovery engine configuration
848
+ */
849
+ interface DiscoveryConfig {
850
+ /** Maximum questions to ask in a single round */
851
+ maxQuestionsPerRound: number;
852
+ /** Minimum requirements before proceeding */
853
+ minRequirements: number;
854
+ /** Whether to auto-confirm low-confidence assumptions */
855
+ autoConfirmLowConfidence: boolean;
856
+ /** Default language if not specified */
857
+ defaultLanguage: "typescript" | "python" | "go" | "rust" | "java";
858
+ /** Whether to generate diagrams in spec */
859
+ includeDiagrams: boolean;
860
+ }
861
+ /**
862
+ * Result of analyzing user input
863
+ */
864
+ interface InputAnalysis {
865
+ /** Detected project type */
866
+ projectType: ProjectType;
867
+ /** Complexity assessment */
868
+ complexity: "simple" | "moderate" | "complex" | "enterprise";
869
+ /** Completeness of input */
870
+ completeness: number;
871
+ /** Extracted requirements */
872
+ requirements: Requirement[];
873
+ /** Questions to ask */
874
+ suggestedQuestions: Question[];
875
+ /** Inferred assumptions */
876
+ assumptions: Assumption[];
877
+ /** Technology hints */
878
+ techHints: Partial<TechDecision>[];
879
+ }
880
+ /**
881
+ * Project types
882
+ */
883
+ type ProjectType = "cli" | "api" | "web_app" | "library" | "service" | "full_stack" | "automation" | "unknown";
884
+
885
+ /**
886
+ * LLM Provider types for Corbat-Coco
887
+ */
888
+ /**
889
+ * Message role
890
+ */
891
+ type MessageRole = "system" | "user" | "assistant";
892
+ /**
893
+ * Message content types
894
+ */
895
+ type MessageContent = string | Array<TextContent | ImageContent | ToolUseContent | ToolResultContent>;
896
+ /**
897
+ * Text content block
898
+ */
899
+ interface TextContent {
900
+ type: "text";
901
+ text: string;
902
+ }
903
+ /**
904
+ * Image content block
905
+ */
906
+ interface ImageContent {
907
+ type: "image";
908
+ source: {
909
+ type: "base64";
910
+ media_type: string;
911
+ data: string;
912
+ };
913
+ }
914
+ /**
915
+ * Tool use content block
916
+ */
917
+ interface ToolUseContent {
918
+ type: "tool_use";
919
+ id: string;
920
+ name: string;
921
+ input: Record<string, unknown>;
922
+ }
923
+ /**
924
+ * Tool result content block
925
+ */
926
+ interface ToolResultContent {
927
+ type: "tool_result";
928
+ tool_use_id: string;
929
+ content: string;
930
+ is_error?: boolean;
931
+ }
932
+ /**
933
+ * Chat message
934
+ */
935
+ interface Message {
936
+ role: MessageRole;
937
+ content: MessageContent;
938
+ }
939
+ /**
940
+ * Tool definition for LLM
941
+ */
942
+ interface ToolDefinition$1 {
943
+ name: string;
944
+ description: string;
945
+ input_schema: {
946
+ type: "object";
947
+ properties: Record<string, unknown>;
948
+ required?: string[];
949
+ };
950
+ }
951
+ /**
952
+ * Tool call from LLM
953
+ */
954
+ interface ToolCall {
955
+ id: string;
956
+ name: string;
957
+ input: Record<string, unknown>;
958
+ }
959
+ /**
960
+ * Chat options
961
+ */
962
+ interface ChatOptions {
963
+ model?: string;
964
+ maxTokens?: number;
965
+ temperature?: number;
966
+ stopSequences?: string[];
967
+ system?: string;
968
+ timeout?: number;
969
+ }
970
+ /**
971
+ * Chat response
972
+ */
973
+ interface ChatResponse {
974
+ id: string;
975
+ content: string;
976
+ stopReason: "end_turn" | "max_tokens" | "stop_sequence" | "tool_use";
977
+ usage: {
978
+ inputTokens: number;
979
+ outputTokens: number;
980
+ };
981
+ model: string;
982
+ }
983
+ /**
984
+ * Chat with tools options
985
+ */
986
+ interface ChatWithToolsOptions extends ChatOptions {
987
+ tools: ToolDefinition$1[];
988
+ toolChoice?: "auto" | "any" | {
989
+ type: "tool";
990
+ name: string;
991
+ };
992
+ }
993
+ /**
994
+ * Chat with tools response
995
+ */
996
+ interface ChatWithToolsResponse extends ChatResponse {
997
+ toolCalls: ToolCall[];
998
+ }
999
+ /**
1000
+ * Stream chunk
1001
+ */
1002
+ interface StreamChunk {
1003
+ type: "text" | "tool_use_start" | "tool_use_delta" | "tool_use_end" | "done";
1004
+ text?: string;
1005
+ toolCall?: Partial<ToolCall>;
1006
+ }
1007
+ /**
1008
+ * LLM Provider interface
1009
+ */
1010
+ interface LLMProvider {
1011
+ /**
1012
+ * Provider identifier
1013
+ */
1014
+ id: string;
1015
+ /**
1016
+ * Provider display name
1017
+ */
1018
+ name: string;
1019
+ /**
1020
+ * Initialize the provider
1021
+ */
1022
+ initialize(config: ProviderConfig): Promise<void>;
1023
+ /**
1024
+ * Send a chat message
1025
+ */
1026
+ chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
1027
+ /**
1028
+ * Send a chat message with tool use
1029
+ */
1030
+ chatWithTools(messages: Message[], options: ChatWithToolsOptions): Promise<ChatWithToolsResponse>;
1031
+ /**
1032
+ * Stream a chat response
1033
+ */
1034
+ stream(messages: Message[], options?: ChatOptions): AsyncIterable<StreamChunk>;
1035
+ /**
1036
+ * Stream a chat response with tool use
1037
+ */
1038
+ streamWithTools(messages: Message[], options: ChatWithToolsOptions): AsyncIterable<StreamChunk>;
1039
+ /**
1040
+ * Count tokens in text
1041
+ */
1042
+ countTokens(text: string): number;
1043
+ /**
1044
+ * Get context window size
1045
+ */
1046
+ getContextWindow(): number;
1047
+ /**
1048
+ * Check if provider is available
1049
+ */
1050
+ isAvailable(): Promise<boolean>;
1051
+ }
1052
+ /**
1053
+ * Provider configuration
1054
+ */
1055
+ interface ProviderConfig {
1056
+ apiKey?: string;
1057
+ baseUrl?: string;
1058
+ model?: string;
1059
+ maxTokens?: number;
1060
+ temperature?: number;
1061
+ timeout?: number;
1062
+ /** Internal: flag to indicate using Google Cloud ADC */
1063
+ useADC?: boolean;
1064
+ }
1065
+
1066
+ /**
1067
+ * Discovery Engine for the CONVERGE phase
1068
+ *
1069
+ * Handles requirement gathering through conversation with the user
1070
+ */
1071
+
1072
+ /**
1073
+ * Discovery Engine
1074
+ *
1075
+ * Manages the requirement discovery process through conversation
1076
+ */
1077
+ declare class DiscoveryEngine {
1078
+ private session;
1079
+ private config;
1080
+ private llm;
1081
+ constructor(llm: LLMProvider, config?: Partial<DiscoveryConfig>);
1082
+ /**
1083
+ * Start a new discovery session
1084
+ */
1085
+ startSession(initialInput: string): Promise<DiscoverySession>;
1086
+ /**
1087
+ * Resume an existing session
1088
+ */
1089
+ resumeSession(session: DiscoverySession): void;
1090
+ /**
1091
+ * Get the current session
1092
+ */
1093
+ getSession(): DiscoverySession | null;
1094
+ /**
1095
+ * Analyze user input for requirements
1096
+ */
1097
+ analyzeInput(input: string): Promise<InputAnalysis>;
1098
+ /**
1099
+ * Process a user's answer to a question
1100
+ */
1101
+ processAnswer(questionId: string, answer: string): Promise<void>;
1102
+ /**
1103
+ * Generate follow-up questions based on current state
1104
+ */
1105
+ generateQuestions(): Promise<Question[]>;
1106
+ /**
1107
+ * Process a free-form message from the user
1108
+ */
1109
+ processMessage(message: string): Promise<{
1110
+ newRequirements: Requirement[];
1111
+ questions: Question[];
1112
+ }>;
1113
+ /**
1114
+ * Check if discovery is complete
1115
+ */
1116
+ isComplete(): boolean;
1117
+ /**
1118
+ * Get unanswered questions
1119
+ */
1120
+ getOpenQuestions(): Question[];
1121
+ /**
1122
+ * Get critical questions that must be answered
1123
+ */
1124
+ getCriticalQuestions(): Question[];
1125
+ /**
1126
+ * Mark discovery as complete
1127
+ */
1128
+ markComplete(): void;
1129
+ /**
1130
+ * Force complete with current requirements
1131
+ */
1132
+ forceComplete(): void;
1133
+ private addMessage;
1134
+ private applyAnalysis;
1135
+ private updateSessionStatus;
1136
+ }
1137
+ /**
1138
+ * Create a discovery engine with default configuration
1139
+ */
1140
+ declare function createDiscoveryEngine(llm: LLMProvider, config?: Partial<DiscoveryConfig>): DiscoveryEngine;
1141
+
1142
+ /**
1143
+ * Types and configuration for the Specification Generator
1144
+ */
1145
+ /**
1146
+ * Configuration for specification generation
1147
+ */
1148
+ interface SpecificationConfig {
1149
+ /** Include mermaid diagrams */
1150
+ includeDiagrams: boolean;
1151
+ /** Maximum spec document length */
1152
+ maxLength: number;
1153
+ /** Include risk analysis */
1154
+ includeRisks: boolean;
1155
+ /** Output format */
1156
+ format: "markdown" | "json";
1157
+ }
1158
+ /**
1159
+ * Simplified specification format (for tests and simple use cases)
1160
+ */
1161
+ interface SimpleSpec {
1162
+ name: string;
1163
+ description?: string;
1164
+ requirements?: {
1165
+ functional?: (string | {
1166
+ title?: string;
1167
+ description?: string;
1168
+ })[];
1169
+ nonFunctional?: (string | {
1170
+ title?: string;
1171
+ description?: string;
1172
+ })[];
1173
+ };
1174
+ assumptions?: string[];
1175
+ constraints?: string[];
1176
+ }
1177
+
1178
+ /**
1179
+ * Specification Generator for the CONVERGE phase
1180
+ *
1181
+ * Generates comprehensive project specifications from discovered requirements
1182
+ */
1183
+
1184
+ /**
1185
+ * Specification Generator
1186
+ *
1187
+ * Creates comprehensive project specification documents
1188
+ */
1189
+ declare class SpecificationGenerator {
1190
+ private llm;
1191
+ private config;
1192
+ constructor(llm: LLMProvider, config?: Partial<SpecificationConfig>);
1193
+ /**
1194
+ * Generate a specification from a discovery session
1195
+ */
1196
+ generate(session: DiscoverySession): Promise<Specification>;
1197
+ /**
1198
+ * Generate a markdown document from the specification
1199
+ * Supports both full Specification and simplified test format
1200
+ */
1201
+ toMarkdown(spec: Specification | SimpleSpec): string;
1202
+ /**
1203
+ * Generate a markdown document from the specification (alias for toMarkdown)
1204
+ */
1205
+ generateMarkdown(spec: Specification): string;
1206
+ /**
1207
+ * Generate JSON output
1208
+ */
1209
+ generateJSON(spec: Specification): string;
1210
+ private generateArchitecture;
1211
+ }
1212
+ /**
1213
+ * Create a specification generator with default configuration
1214
+ */
1215
+ declare function createSpecificationGenerator(llm: LLMProvider, config?: Partial<SpecificationConfig>): SpecificationGenerator;
1216
+
1217
+ /**
1218
+ * Session Persistence for the CONVERGE phase
1219
+ *
1220
+ * Handles saving and loading discovery sessions for recovery
1221
+ */
1222
+
1223
+ /**
1224
+ * Session persistence manager
1225
+ */
1226
+ declare class SessionPersistence {
1227
+ private paths;
1228
+ constructor(projectPath: string);
1229
+ /**
1230
+ * Ensure the persistence directory exists
1231
+ */
1232
+ ensureDir(): Promise<void>;
1233
+ /**
1234
+ * Save a discovery session
1235
+ */
1236
+ saveSession(session: DiscoverySession): Promise<void>;
1237
+ /**
1238
+ * Load a discovery session
1239
+ */
1240
+ loadSession(): Promise<DiscoverySession | null>;
1241
+ /**
1242
+ * Check if a session exists
1243
+ */
1244
+ hasSession(): Promise<boolean>;
1245
+ /**
1246
+ * Delete a session
1247
+ */
1248
+ deleteSession(): Promise<void>;
1249
+ /**
1250
+ * Save the specification markdown
1251
+ */
1252
+ saveSpecification(content: string): Promise<void>;
1253
+ /**
1254
+ * Load the specification markdown
1255
+ */
1256
+ loadSpecification(): Promise<string | null>;
1257
+ /**
1258
+ * Append a message to the conversation log
1259
+ */
1260
+ appendConversation(role: "user" | "assistant", content: string): Promise<void>;
1261
+ /**
1262
+ * Load the full conversation log
1263
+ */
1264
+ loadConversationLog(): Promise<Array<{
1265
+ timestamp: string;
1266
+ role: string;
1267
+ content: string;
1268
+ }>>;
1269
+ /**
1270
+ * Save a checkpoint
1271
+ */
1272
+ saveCheckpoint(checkpoint: ConvergeCheckpoint): Promise<void>;
1273
+ /**
1274
+ * Load a checkpoint
1275
+ */
1276
+ loadCheckpoint(): Promise<ConvergeCheckpoint | null>;
1277
+ /**
1278
+ * Clear all persisted data
1279
+ */
1280
+ clearAll(): Promise<void>;
1281
+ /**
1282
+ * Get the specification file path
1283
+ */
1284
+ getSpecPath(): string;
1285
+ }
1286
+ /**
1287
+ * Checkpoint data for CONVERGE phase
1288
+ */
1289
+ interface ConvergeCheckpoint {
1290
+ /** Checkpoint ID */
1291
+ id: string;
1292
+ /** When the checkpoint was created */
1293
+ timestamp: Date;
1294
+ /** Current step in the converge process */
1295
+ step: ConvergeStep;
1296
+ /** Session ID being processed */
1297
+ sessionId: string;
1298
+ /** Progress percentage */
1299
+ progress: number;
1300
+ /** Whether spec has been generated */
1301
+ specGenerated: boolean;
1302
+ /** Metadata for resumption */
1303
+ metadata: Record<string, unknown>;
1304
+ }
1305
+ /**
1306
+ * Steps in the CONVERGE process
1307
+ */
1308
+ type ConvergeStep = "init" | "discovery" | "clarification" | "refinement" | "spec_generation" | "complete";
1309
+ /**
1310
+ * Session manager that combines persistence with session operations
1311
+ */
1312
+ declare class SessionManager {
1313
+ private persistence;
1314
+ constructor(projectPath: string);
1315
+ /**
1316
+ * Get the persistence layer
1317
+ */
1318
+ getPersistence(): SessionPersistence;
1319
+ /**
1320
+ * Save session with automatic checkpoint
1321
+ */
1322
+ saveWithCheckpoint(session: DiscoverySession, step: ConvergeStep, progress: number): Promise<void>;
1323
+ /**
1324
+ * Resume from last checkpoint
1325
+ */
1326
+ resume(): Promise<{
1327
+ session: DiscoverySession;
1328
+ checkpoint: ConvergeCheckpoint;
1329
+ } | null>;
1330
+ /**
1331
+ * Check if can resume
1332
+ */
1333
+ canResume(): Promise<boolean>;
1334
+ /**
1335
+ * Get resume info without loading full session
1336
+ */
1337
+ getResumeInfo(): Promise<{
1338
+ sessionId: string;
1339
+ step: ConvergeStep;
1340
+ progress: number;
1341
+ timestamp: Date;
1342
+ } | null>;
1343
+ /**
1344
+ * Complete the session and save specification
1345
+ */
1346
+ complete(session: DiscoverySession, specMarkdown: string): Promise<void>;
1347
+ }
1348
+ /**
1349
+ * Create a session manager for a project
1350
+ */
1351
+ declare function createSessionManager(projectPath: string): SessionManager;
1352
+
1353
+ /**
1354
+ * CONVERGE Phase Executor
1355
+ *
1356
+ * Orchestrates the discovery and specification process
1357
+ */
1358
+
1359
+ /**
1360
+ * CONVERGE phase configuration
1361
+ */
1362
+ interface ConvergeConfig {
1363
+ /** Maximum rounds of questions */
1364
+ maxQuestionRounds: number;
1365
+ /** Maximum questions per round */
1366
+ maxQuestionsPerRound: number;
1367
+ /** Auto-proceed if no critical questions */
1368
+ autoProceed: boolean;
1369
+ /** Include diagrams in specification */
1370
+ includeDiagrams: boolean;
1371
+ /** Callback for user interaction */
1372
+ onUserInput?: (prompt: string, options?: string[]) => Promise<string>;
1373
+ /** Callback for progress updates */
1374
+ onProgress?: (step: ConvergeStep, progress: number, message: string) => void;
1375
+ }
1376
+ /**
1377
+ * CONVERGE Phase Executor
1378
+ *
1379
+ * Implements the PhaseExecutor interface for the CONVERGE phase
1380
+ */
1381
+ declare class ConvergeExecutor implements PhaseExecutor {
1382
+ readonly name = "converge";
1383
+ readonly description = "Gather requirements and generate specification";
1384
+ private config;
1385
+ private discovery;
1386
+ private specGenerator;
1387
+ private sessionManager;
1388
+ private currentSession;
1389
+ private llm;
1390
+ constructor(config?: Partial<ConvergeConfig>);
1391
+ /**
1392
+ * Check if the phase can start
1393
+ */
1394
+ canStart(_context: PhaseContext): boolean;
1395
+ /**
1396
+ * Execute the CONVERGE phase
1397
+ */
1398
+ execute(context: PhaseContext): Promise<PhaseResult>;
1399
+ /**
1400
+ * Check if the phase can complete
1401
+ */
1402
+ canComplete(_context: PhaseContext): boolean;
1403
+ /**
1404
+ * Create a checkpoint for recovery
1405
+ */
1406
+ checkpoint(_context: PhaseContext): Promise<PhaseCheckpoint>;
1407
+ /**
1408
+ * Restore from a checkpoint
1409
+ */
1410
+ restore(_checkpoint: PhaseCheckpoint, context: PhaseContext): Promise<void>;
1411
+ private initialize;
1412
+ private createLLMAdapter;
1413
+ private runDiscoveryLoop;
1414
+ private askQuestion;
1415
+ private getUserInput;
1416
+ private reportProgress;
1417
+ private saveProgress;
1418
+ private getCurrentStep;
1419
+ private calculateProgress;
1420
+ }
1421
+ /**
1422
+ * Create a CONVERGE phase executor
1423
+ */
1424
+ declare function createConvergeExecutor(config?: Partial<ConvergeConfig>): ConvergeExecutor;
1425
+
1426
+ /**
1427
+ * Task types for Corbat-Coco
1428
+ */
1429
+
1430
+ /**
1431
+ * Task in the backlog
1432
+ */
1433
+ interface Task {
1434
+ id: string;
1435
+ storyId: string;
1436
+ title: string;
1437
+ description: string;
1438
+ type: TaskType;
1439
+ files: string[];
1440
+ dependencies: string[];
1441
+ estimatedComplexity: TaskComplexity;
1442
+ status: TaskStatus;
1443
+ assignedSprint?: string;
1444
+ }
1445
+ /**
1446
+ * Task types
1447
+ */
1448
+ type TaskType = "feature" | "test" | "refactor" | "docs" | "infra" | "config";
1449
+ /**
1450
+ * Task complexity levels
1451
+ */
1452
+ type TaskComplexity = "trivial" | "simple" | "moderate" | "complex";
1453
+ /**
1454
+ * Task status
1455
+ */
1456
+ type TaskStatus = "pending" | "in_progress" | "completed" | "blocked" | "rolled_back";
1457
+ /**
1458
+ * Version of a task (iteration snapshot)
1459
+ */
1460
+ interface TaskVersion {
1461
+ version: number;
1462
+ timestamp: Date;
1463
+ /**
1464
+ * Files changed in this version
1465
+ */
1466
+ changes: TaskChanges;
1467
+ /**
1468
+ * Diffs for each changed file
1469
+ */
1470
+ diffs: FileDiff[];
1471
+ /**
1472
+ * Quality scores for this version
1473
+ */
1474
+ scores: QualityScores;
1475
+ /**
1476
+ * Test results
1477
+ */
1478
+ testResults: TaskTestResults;
1479
+ /**
1480
+ * Analysis and reasoning
1481
+ */
1482
+ analysis: TaskAnalysis;
1483
+ }
1484
+ /**
1485
+ * Changes made in a task version
1486
+ */
1487
+ interface TaskChanges {
1488
+ filesCreated: string[];
1489
+ filesModified: string[];
1490
+ filesDeleted: string[];
1491
+ }
1492
+ /**
1493
+ * Diff for a single file
1494
+ */
1495
+ interface FileDiff {
1496
+ file: string;
1497
+ diff: string;
1498
+ additions: number;
1499
+ deletions: number;
1500
+ }
1501
+ /**
1502
+ * Test results for a task version
1503
+ */
1504
+ interface TaskTestResults {
1505
+ passed: number;
1506
+ failed: number;
1507
+ skipped: number;
1508
+ coverage: {
1509
+ lines: number;
1510
+ branches: number;
1511
+ functions: number;
1512
+ };
1513
+ failures: TestFailureInfo[];
1514
+ }
1515
+ /**
1516
+ * Information about a test failure
1517
+ */
1518
+ interface TestFailureInfo {
1519
+ name: string;
1520
+ file: string;
1521
+ message: string;
1522
+ stack?: string;
1523
+ }
1524
+ /**
1525
+ * Analysis of a task version
1526
+ */
1527
+ interface TaskAnalysis {
1528
+ /**
1529
+ * Issues found in this version
1530
+ */
1531
+ issuesFound: TaskIssue[];
1532
+ /**
1533
+ * Improvements applied from previous version
1534
+ */
1535
+ improvementsApplied: TaskImprovement[];
1536
+ /**
1537
+ * LLM reasoning for changes
1538
+ */
1539
+ reasoning: string;
1540
+ /**
1541
+ * Confidence level (0-100)
1542
+ */
1543
+ confidence: number;
1544
+ }
1545
+ /**
1546
+ * Issue found in task code
1547
+ */
1548
+ interface TaskIssue {
1549
+ category: IssueCategory;
1550
+ severity: "critical" | "major" | "minor" | "info";
1551
+ message: string;
1552
+ file?: string;
1553
+ line?: number;
1554
+ suggestion?: string;
1555
+ }
1556
+ /**
1557
+ * Issue categories
1558
+ */
1559
+ type IssueCategory = "correctness" | "completeness" | "robustness" | "readability" | "maintainability" | "performance" | "security" | "testing" | "documentation" | "style";
1560
+ /**
1561
+ * Improvement made to task code
1562
+ */
1563
+ interface TaskImprovement {
1564
+ category: IssueCategory;
1565
+ description: string;
1566
+ impact: "high" | "medium" | "low";
1567
+ scoreImpact: number;
1568
+ }
1569
+ /**
1570
+ * Complete history of a task
1571
+ */
1572
+ interface TaskHistory {
1573
+ taskId: string;
1574
+ task: Task;
1575
+ versions: TaskVersion[];
1576
+ currentVersion: number;
1577
+ status: TaskStatus;
1578
+ /**
1579
+ * Metrics
1580
+ */
1581
+ metrics: TaskMetrics;
1582
+ /**
1583
+ * Final result (if completed)
1584
+ */
1585
+ finalResult?: TaskFinalResult;
1586
+ }
1587
+ /**
1588
+ * Task execution metrics
1589
+ */
1590
+ interface TaskMetrics {
1591
+ totalIterations: number;
1592
+ totalTimeMs: number;
1593
+ llmCalls: number;
1594
+ tokensUsed: number;
1595
+ qualityProgression: number[];
1596
+ convergenceIteration?: number;
1597
+ }
1598
+ /**
1599
+ * Final result of completed task
1600
+ */
1601
+ interface TaskFinalResult {
1602
+ completedAt: Date;
1603
+ finalScore: number;
1604
+ totalIterations: number;
1605
+ filesCreated: string[];
1606
+ filesModified: string[];
1607
+ converged: boolean;
1608
+ convergenceReason: string;
1609
+ }
1610
+ /**
1611
+ * Story (user story containing tasks)
1612
+ */
1613
+ interface Story {
1614
+ id: string;
1615
+ epicId: string;
1616
+ title: string;
1617
+ asA: string;
1618
+ iWant: string;
1619
+ soThat: string;
1620
+ acceptanceCriteria: string[];
1621
+ tasks: string[];
1622
+ points: number;
1623
+ status: StoryStatus;
1624
+ }
1625
+ /**
1626
+ * Story status
1627
+ */
1628
+ type StoryStatus = "backlog" | "ready" | "in_progress" | "review" | "done";
1629
+ /**
1630
+ * Epic (collection of related stories)
1631
+ */
1632
+ interface Epic {
1633
+ id: string;
1634
+ title: string;
1635
+ description: string;
1636
+ stories: string[];
1637
+ priority: 1 | 2 | 3 | 4 | 5;
1638
+ dependencies: string[];
1639
+ status: EpicStatus;
1640
+ }
1641
+ /**
1642
+ * Epic status
1643
+ */
1644
+ type EpicStatus = "planned" | "in_progress" | "done";
1645
+ /**
1646
+ * Sprint
1647
+ */
1648
+ interface Sprint {
1649
+ id: string;
1650
+ name: string;
1651
+ goal: string;
1652
+ startDate: Date;
1653
+ endDate?: Date;
1654
+ stories: string[];
1655
+ status: SprintStatus;
1656
+ metrics?: SprintMetrics;
1657
+ }
1658
+ /**
1659
+ * Sprint status
1660
+ */
1661
+ type SprintStatus = "planning" | "active" | "review" | "completed";
1662
+ /**
1663
+ * Sprint metrics
1664
+ */
1665
+ interface SprintMetrics {
1666
+ plannedPoints: number;
1667
+ completedPoints: number;
1668
+ tasksCompleted: number;
1669
+ tasksTotal: number;
1670
+ averageQuality: number;
1671
+ velocity: number;
1672
+ }
1673
+ /**
1674
+ * Backlog (all epics, stories, tasks)
1675
+ */
1676
+ interface Backlog {
1677
+ epics: Epic[];
1678
+ stories: Story[];
1679
+ tasks: Task[];
1680
+ currentSprint: Sprint | null;
1681
+ completedSprints: Sprint[];
1682
+ }
1683
+
1684
+ /**
1685
+ * Types for the ORCHESTRATE phase
1686
+ *
1687
+ * This phase focuses on architecture design, ADR creation, and backlog generation
1688
+ */
1689
+
1690
+ /**
1691
+ * Architecture document
1692
+ */
1693
+ interface ArchitectureDoc {
1694
+ version: string;
1695
+ generatedAt: Date;
1696
+ /** High-level overview */
1697
+ overview: ArchitectureOverview;
1698
+ /** System components */
1699
+ components: Component[];
1700
+ /** Component relationships */
1701
+ relationships: Relationship[];
1702
+ /** Data models */
1703
+ dataModels: DataModel[];
1704
+ /** External integrations */
1705
+ integrations: Integration[];
1706
+ /** Diagrams */
1707
+ diagrams: ArchitectureDiagram[];
1708
+ }
1709
+ /**
1710
+ * Architecture overview
1711
+ */
1712
+ interface ArchitectureOverview {
1713
+ pattern: ArchitecturePattern;
1714
+ description: string;
1715
+ principles: string[];
1716
+ qualityAttributes: QualityAttribute[];
1717
+ }
1718
+ /**
1719
+ * Architecture patterns
1720
+ */
1721
+ type ArchitecturePattern = "layered" | "hexagonal" | "clean" | "microservices" | "event_driven" | "cqrs" | "modular_monolith" | "serverless";
1722
+ /**
1723
+ * Quality attribute
1724
+ */
1725
+ interface QualityAttribute {
1726
+ name: string;
1727
+ description: string;
1728
+ priority: "high" | "medium" | "low";
1729
+ tradeoffs?: string[];
1730
+ }
1731
+ /**
1732
+ * System component
1733
+ */
1734
+ interface Component {
1735
+ id: string;
1736
+ name: string;
1737
+ type: ComponentType;
1738
+ description: string;
1739
+ responsibilities: string[];
1740
+ technology?: string;
1741
+ layer?: string;
1742
+ dependencies: string[];
1743
+ }
1744
+ /**
1745
+ * Component types
1746
+ */
1747
+ type ComponentType = "service" | "controller" | "repository" | "adapter" | "port" | "domain" | "usecase" | "utility" | "external";
1748
+ /**
1749
+ * Relationship between components
1750
+ */
1751
+ interface Relationship {
1752
+ from: string;
1753
+ to: string;
1754
+ type: RelationshipType;
1755
+ description?: string;
1756
+ }
1757
+ /**
1758
+ * Relationship types
1759
+ */
1760
+ type RelationshipType = "uses" | "implements" | "extends" | "depends" | "calls" | "publishes" | "subscribes";
1761
+ /**
1762
+ * Data model
1763
+ */
1764
+ interface DataModel {
1765
+ name: string;
1766
+ description: string;
1767
+ fields: DataField[];
1768
+ relationships: DataRelationship[];
1769
+ }
1770
+ /**
1771
+ * Data field
1772
+ */
1773
+ interface DataField {
1774
+ name: string;
1775
+ type: string;
1776
+ required: boolean;
1777
+ description?: string;
1778
+ }
1779
+ /**
1780
+ * Data relationship
1781
+ */
1782
+ interface DataRelationship {
1783
+ type: "one_to_one" | "one_to_many" | "many_to_many";
1784
+ target: string;
1785
+ description?: string;
1786
+ }
1787
+ /**
1788
+ * External integration
1789
+ */
1790
+ interface Integration {
1791
+ name: string;
1792
+ type: IntegrationType;
1793
+ description: string;
1794
+ endpoint?: string;
1795
+ authentication?: string;
1796
+ }
1797
+ /**
1798
+ * Integration types
1799
+ */
1800
+ type IntegrationType = "rest_api" | "graphql" | "grpc" | "database" | "message_queue" | "file_system" | "external_service";
1801
+ /**
1802
+ * Architecture diagram
1803
+ */
1804
+ interface ArchitectureDiagram {
1805
+ id: string;
1806
+ type: DiagramType;
1807
+ title: string;
1808
+ description: string;
1809
+ mermaid: string;
1810
+ }
1811
+ /**
1812
+ * Diagram types (C4 model + others)
1813
+ */
1814
+ type DiagramType = "c4_context" | "c4_container" | "c4_component" | "c4_code" | "sequence" | "class" | "er" | "flowchart";
1815
+ /**
1816
+ * Architecture Decision Record
1817
+ */
1818
+ interface ADR {
1819
+ id: string;
1820
+ number: number;
1821
+ title: string;
1822
+ date: Date;
1823
+ status: ADRStatus;
1824
+ context: string;
1825
+ decision: string;
1826
+ consequences: ADRConsequences;
1827
+ alternatives?: Alternative[];
1828
+ references?: string[];
1829
+ }
1830
+ /**
1831
+ * ADR status
1832
+ */
1833
+ type ADRStatus = "proposed" | "accepted" | "deprecated" | "superseded";
1834
+ /**
1835
+ * ADR consequences
1836
+ */
1837
+ interface ADRConsequences {
1838
+ positive: string[];
1839
+ negative: string[];
1840
+ neutral?: string[];
1841
+ }
1842
+ /**
1843
+ * Alternative considered in ADR
1844
+ */
1845
+ interface Alternative {
1846
+ option: string;
1847
+ pros: string[];
1848
+ cons: string[];
1849
+ reason: string;
1850
+ }
1851
+ /**
1852
+ * Backlog generation result
1853
+ */
1854
+ interface BacklogResult {
1855
+ backlog: Backlog;
1856
+ estimatedSprints: number;
1857
+ estimatedVelocity: number;
1858
+ warnings: string[];
1859
+ }
1860
+ /**
1861
+ * Sprint planning configuration
1862
+ */
1863
+ interface SprintConfig {
1864
+ /** Sprint duration in days */
1865
+ sprintDuration: number;
1866
+ /** Target velocity (story points per sprint) */
1867
+ targetVelocity: number;
1868
+ /** Maximum stories per sprint */
1869
+ maxStoriesPerSprint: number;
1870
+ /** Include buffer for unexpected work */
1871
+ bufferPercentage: number;
1872
+ }
1873
+ /**
1874
+ * Task breakdown strategy
1875
+ */
1876
+ type TaskBreakdownStrategy = "by_layer" | "by_feature" | "by_component" | "tdd" | "incremental";
1877
+ /**
1878
+ * ORCHESTRATE phase configuration
1879
+ */
1880
+ interface OrchestrateConfig {
1881
+ /** Generate C4 diagrams */
1882
+ generateC4Diagrams: boolean;
1883
+ /** Generate sequence diagrams */
1884
+ generateSequenceDiagrams: boolean;
1885
+ /** Number of ADRs to generate for key decisions */
1886
+ maxADRs: number;
1887
+ /** Sprint configuration */
1888
+ sprint: SprintConfig;
1889
+ /** Task breakdown strategy */
1890
+ breakdownStrategy: TaskBreakdownStrategy;
1891
+ /** Generate deployment docs */
1892
+ generateDeploymentDocs: boolean;
1893
+ }
1894
+
1895
+ /**
1896
+ * Architecture Generator for the ORCHESTRATE phase
1897
+ *
1898
+ * Generates architecture documents, components, and diagrams
1899
+ */
1900
+
1901
+ /**
1902
+ * Architecture Generator
1903
+ */
1904
+ declare class ArchitectureGenerator {
1905
+ private llm;
1906
+ private config;
1907
+ constructor(llm: LLMProvider, config: OrchestrateConfig);
1908
+ /**
1909
+ * Generate architecture from specification
1910
+ */
1911
+ generate(specification: Specification): Promise<ArchitectureDoc>;
1912
+ /**
1913
+ * Generate base architecture
1914
+ */
1915
+ private generateBaseArchitecture;
1916
+ /**
1917
+ * Generate C4 diagrams
1918
+ */
1919
+ private generateC4Diagrams;
1920
+ /**
1921
+ * Generate sequence diagrams
1922
+ */
1923
+ private generateSequenceDiagrams;
1924
+ /**
1925
+ * Generate fallback C4 diagrams if LLM fails
1926
+ */
1927
+ private generateFallbackC4Diagrams;
1928
+ }
1929
+ /**
1930
+ * Create an architecture generator
1931
+ */
1932
+ declare function createArchitectureGenerator(llm: LLMProvider, config: OrchestrateConfig): ArchitectureGenerator;
1933
+
1934
+ /**
1935
+ * ADR Generator for the ORCHESTRATE phase
1936
+ *
1937
+ * Generates Architecture Decision Records
1938
+ */
1939
+
1940
+ /**
1941
+ * ADR Generator
1942
+ */
1943
+ declare class ADRGenerator {
1944
+ private llm;
1945
+ private config;
1946
+ constructor(llm: LLMProvider, config: OrchestrateConfig);
1947
+ /**
1948
+ * Generate ADRs from architecture and specification
1949
+ */
1950
+ generate(architecture: ArchitectureDoc, specification: Specification): Promise<ADR[]>;
1951
+ /**
1952
+ * Parse a single ADR from LLM response
1953
+ */
1954
+ private parseADR;
1955
+ }
1956
+ /**
1957
+ * Create an ADR generator
1958
+ */
1959
+ declare function createADRGenerator(llm: LLMProvider, config: OrchestrateConfig): ADRGenerator;
1960
+
1961
+ /**
1962
+ * Backlog Generator for the ORCHESTRATE phase
1963
+ *
1964
+ * Generates epics, stories, tasks, and sprint plans
1965
+ */
1966
+
1967
+ /**
1968
+ * Backlog Generator
1969
+ */
1970
+ declare class BacklogGenerator {
1971
+ private llm;
1972
+ private config;
1973
+ constructor(llm: LLMProvider, config: OrchestrateConfig);
1974
+ /**
1975
+ * Generate complete backlog from architecture and specification
1976
+ */
1977
+ generate(architecture: ArchitectureDoc, specification: Specification): Promise<BacklogResult>;
1978
+ /**
1979
+ * Plan the first sprint from the backlog
1980
+ */
1981
+ planFirstSprint(backlog: Backlog): Promise<Sprint>;
1982
+ /**
1983
+ * Auto-select stories for a sprint based on priority and velocity
1984
+ */
1985
+ private autoSelectSprint;
1986
+ private parseEpics;
1987
+ private parseStories;
1988
+ private parseTasks;
1989
+ private normalizePoints;
1990
+ }
1991
+ /**
1992
+ * Create a backlog generator
1993
+ */
1994
+ declare function createBacklogGenerator(llm: LLMProvider, config: OrchestrateConfig): BacklogGenerator;
1995
+
1996
+ /**
1997
+ * ORCHESTRATE Phase Executor
1998
+ *
1999
+ * Orchestrates the architecture design, ADR creation, and backlog generation
2000
+ */
2001
+
2002
+ /**
2003
+ * ORCHESTRATE phase executor
2004
+ */
2005
+ declare class OrchestrateExecutor implements PhaseExecutor {
2006
+ readonly name = "orchestrate";
2007
+ readonly description = "Design architecture, create ADRs, and generate backlog";
2008
+ private config;
2009
+ constructor(config?: Partial<OrchestrateConfig>);
2010
+ /**
2011
+ * Check if the phase can start
2012
+ */
2013
+ canStart(_context: PhaseContext): boolean;
2014
+ /**
2015
+ * Execute the ORCHESTRATE phase
2016
+ */
2017
+ execute(context: PhaseContext): Promise<PhaseResult>;
2018
+ /**
2019
+ * Check if the phase can complete
2020
+ */
2021
+ canComplete(_context: PhaseContext): boolean;
2022
+ /**
2023
+ * Create a checkpoint
2024
+ */
2025
+ checkpoint(_context: PhaseContext): Promise<PhaseCheckpoint>;
2026
+ /**
2027
+ * Restore from checkpoint
2028
+ */
2029
+ restore(_checkpoint: PhaseCheckpoint, _context: PhaseContext): Promise<void>;
2030
+ private createLLMAdapter;
2031
+ private loadSpecification;
2032
+ private createMinimalSpec;
2033
+ private saveArchitecture;
2034
+ private saveADRs;
2035
+ private saveBacklog;
2036
+ private saveSprint;
2037
+ private saveDiagram;
2038
+ }
2039
+ /**
2040
+ * Create an ORCHESTRATE phase executor
2041
+ */
2042
+ declare function createOrchestrateExecutor(config?: Partial<OrchestrateConfig>): OrchestrateExecutor;
2043
+
2044
+ /**
2045
+ * Types for the COMPLETE phase
2046
+ *
2047
+ * This phase focuses on task execution with quality iteration
2048
+ */
2049
+
2050
+ /**
2051
+ * Task execution result
2052
+ */
2053
+ interface TaskExecutionResult {
2054
+ taskId: string;
2055
+ success: boolean;
2056
+ versions: TaskVersion[];
2057
+ finalScore: number;
2058
+ converged: boolean;
2059
+ iterations: number;
2060
+ error?: string;
2061
+ }
2062
+ /**
2063
+ * Task execution context
2064
+ */
2065
+ interface TaskExecutionContext {
2066
+ task: Task;
2067
+ projectPath: string;
2068
+ sprint: Sprint;
2069
+ previousVersions: TaskVersion[];
2070
+ qualityConfig: QualityConfig;
2071
+ }
2072
+ /**
2073
+ * Quality configuration for iterations
2074
+ */
2075
+ interface QualityConfig {
2076
+ /** Minimum acceptable score */
2077
+ minScore: number;
2078
+ /** Minimum coverage percentage */
2079
+ minCoverage: number;
2080
+ /** Maximum iterations before giving up */
2081
+ maxIterations: number;
2082
+ /** Score improvement threshold for convergence */
2083
+ convergenceThreshold: number;
2084
+ /** Minimum iterations before considering convergence */
2085
+ minConvergenceIterations: number;
2086
+ }
2087
+ /**
2088
+ * Code generation request
2089
+ */
2090
+ interface CodeGenerationRequest {
2091
+ task: Task;
2092
+ context: string;
2093
+ previousCode?: string;
2094
+ feedback?: string;
2095
+ iteration: number;
2096
+ }
2097
+ /**
2098
+ * Code generation response
2099
+ */
2100
+ interface CodeGenerationResponse {
2101
+ files: GeneratedFile[];
2102
+ explanation: string;
2103
+ confidence: number;
2104
+ }
2105
+ /**
2106
+ * Generated file
2107
+ */
2108
+ interface GeneratedFile {
2109
+ path: string;
2110
+ content: string;
2111
+ action: "create" | "modify" | "delete";
2112
+ }
2113
+ /**
2114
+ * Code review result
2115
+ */
2116
+ interface CodeReviewResult {
2117
+ passed: boolean;
2118
+ scores: QualityScores;
2119
+ issues: ReviewIssue[];
2120
+ suggestions: ReviewSuggestion[];
2121
+ testResults: TestExecutionResult;
2122
+ }
2123
+ /**
2124
+ * Review issue
2125
+ */
2126
+ interface ReviewIssue {
2127
+ severity: "critical" | "major" | "minor" | "info";
2128
+ category: keyof QualityDimensions;
2129
+ message: string;
2130
+ file?: string;
2131
+ line?: number;
2132
+ suggestion?: string;
2133
+ }
2134
+ /**
2135
+ * Review suggestion
2136
+ */
2137
+ interface ReviewSuggestion {
2138
+ type: "improvement" | "refactor" | "test" | "documentation";
2139
+ description: string;
2140
+ priority: "high" | "medium" | "low";
2141
+ impact: number;
2142
+ }
2143
+ /**
2144
+ * Test execution result
2145
+ */
2146
+ interface TestExecutionResult {
2147
+ passed: number;
2148
+ failed: number;
2149
+ skipped: number;
2150
+ coverage: {
2151
+ lines: number;
2152
+ branches: number;
2153
+ functions: number;
2154
+ statements: number;
2155
+ };
2156
+ failures: TestFailureDetail[];
2157
+ duration: number;
2158
+ }
2159
+ /**
2160
+ * Test failure detail
2161
+ */
2162
+ interface TestFailureDetail {
2163
+ name: string;
2164
+ file: string;
2165
+ message: string;
2166
+ stack?: string;
2167
+ expected?: string;
2168
+ actual?: string;
2169
+ }
2170
+ /**
2171
+ * Convergence check result
2172
+ */
2173
+ interface ConvergenceCheck {
2174
+ converged: boolean;
2175
+ reason: string;
2176
+ scoreHistory: number[];
2177
+ improvement: number;
2178
+ }
2179
+ /**
2180
+ * COMPLETE phase configuration
2181
+ */
2182
+ interface CompleteConfig {
2183
+ /** Quality configuration */
2184
+ quality: QualityConfig;
2185
+ /** Enable parallel task execution */
2186
+ parallelExecution: boolean;
2187
+ /** Maximum parallel tasks */
2188
+ maxParallelTasks: number;
2189
+ /** Save intermediate versions */
2190
+ saveVersions: boolean;
2191
+ /** Run tests after each iteration */
2192
+ runTestsEachIteration: boolean;
2193
+ /** Callback for progress updates */
2194
+ onProgress?: (progress: CompleteProgress) => void;
2195
+ /** Callback for user interaction */
2196
+ onUserInput?: (prompt: string) => Promise<string>;
2197
+ }
2198
+ /**
2199
+ * Progress update
2200
+ */
2201
+ interface CompleteProgress {
2202
+ phase: "executing" | "reviewing" | "iterating" | "complete" | "blocked";
2203
+ sprintId: string;
2204
+ taskId?: string;
2205
+ taskTitle?: string;
2206
+ iteration?: number;
2207
+ currentScore?: number;
2208
+ tasksCompleted: number;
2209
+ tasksTotal: number;
2210
+ message: string;
2211
+ }
2212
+
2213
+ /**
2214
+ * Code Generator for the COMPLETE phase
2215
+ *
2216
+ * Generates code based on task requirements
2217
+ */
2218
+
2219
+ /**
2220
+ * Code Generator
2221
+ */
2222
+ declare class CodeGenerator {
2223
+ private llm;
2224
+ private maxValidationRetries;
2225
+ constructor(llm: LLMProvider);
2226
+ /**
2227
+ * Generate initial code for a task
2228
+ */
2229
+ generate(request: CodeGenerationRequest): Promise<CodeGenerationResponse>;
2230
+ /**
2231
+ * Improve existing code based on feedback
2232
+ */
2233
+ improve(currentCode: string, issues: Array<{
2234
+ severity: string;
2235
+ message: string;
2236
+ suggestion?: string;
2237
+ }>, suggestions: Array<{
2238
+ description: string;
2239
+ priority: string;
2240
+ }>, request: CodeGenerationRequest): Promise<CodeGenerationResponse>;
2241
+ /**
2242
+ * Validate generated files and auto-fix syntax errors
2243
+ */
2244
+ private validateAndFixFiles;
2245
+ /**
2246
+ * Fix syntax errors using LLM
2247
+ */
2248
+ private fixSyntaxErrors;
2249
+ /**
2250
+ * Generate tests for existing code
2251
+ */
2252
+ generateTests(codeToTest: string, targetCoverage: number, currentCoverage: {
2253
+ lines: number;
2254
+ branches: number;
2255
+ functions: number;
2256
+ }): Promise<GeneratedFile[]>;
2257
+ /**
2258
+ * Parse generation response from LLM
2259
+ */
2260
+ private parseGenerationResponse;
2261
+ /**
2262
+ * Parse improvement response from LLM
2263
+ */
2264
+ private parseImprovementResponse;
2265
+ }
2266
+ /**
2267
+ * Create a code generator
2268
+ */
2269
+ declare function createCodeGenerator(llm: LLMProvider): CodeGenerator;
2270
+
2271
+ /**
2272
+ * Code Reviewer for the COMPLETE phase
2273
+ *
2274
+ * Reviews generated code and calculates quality scores
2275
+ */
2276
+
2277
+ /**
2278
+ * Code Reviewer
2279
+ */
2280
+ declare class CodeReviewer {
2281
+ private llm;
2282
+ private config;
2283
+ constructor(llm: LLMProvider, config: QualityConfig);
2284
+ /**
2285
+ * Review code and generate quality scores
2286
+ */
2287
+ review(taskTitle: string, taskDescription: string, files: Array<{
2288
+ path: string;
2289
+ content: string;
2290
+ }>, testResults: TestExecutionResult): Promise<CodeReviewResult>;
2291
+ /**
2292
+ * Analyze test failures and suggest fixes
2293
+ */
2294
+ analyzeFailures(failures: Array<{
2295
+ name: string;
2296
+ message: string;
2297
+ stack?: string;
2298
+ }>, sourceCode: string): Promise<Array<{
2299
+ testName: string;
2300
+ rootCause: string;
2301
+ suggestedFix: string;
2302
+ confidence: number;
2303
+ }>>;
2304
+ /**
2305
+ * Check if review passes quality thresholds
2306
+ */
2307
+ checkPassed(scores: QualityScores): boolean;
2308
+ /**
2309
+ * Get critical issues from review
2310
+ */
2311
+ getCriticalIssues(issues: ReviewIssue[]): ReviewIssue[];
2312
+ /**
2313
+ * Get high-priority suggestions
2314
+ */
2315
+ getHighPrioritySuggestions(suggestions: ReviewSuggestion[]): ReviewSuggestion[];
2316
+ /**
2317
+ * Parse review response from LLM
2318
+ */
2319
+ private parseReviewResponse;
2320
+ /**
2321
+ * Normalize dimension scores
2322
+ */
2323
+ private normalizeDimensions;
2324
+ /**
2325
+ * Normalize a single score
2326
+ */
2327
+ private normalizeScore;
2328
+ /**
2329
+ * Calculate overall score from dimensions
2330
+ */
2331
+ private calculateOverallScore;
2332
+ /**
2333
+ * Normalize an issue
2334
+ */
2335
+ private normalizeIssue;
2336
+ /**
2337
+ * Normalize a suggestion
2338
+ */
2339
+ private normalizeSuggestion;
2340
+ /**
2341
+ * Normalize severity
2342
+ */
2343
+ private normalizeSeverity;
2344
+ /**
2345
+ * Normalize category
2346
+ */
2347
+ private normalizeCategory;
2348
+ /**
2349
+ * Normalize suggestion type
2350
+ */
2351
+ private normalizeSuggestionType;
2352
+ /**
2353
+ * Normalize priority
2354
+ */
2355
+ private normalizePriority;
2356
+ /**
2357
+ * Create a default failed review
2358
+ */
2359
+ private createDefaultReview;
2360
+ }
2361
+ /**
2362
+ * Create a code reviewer
2363
+ */
2364
+ declare function createCodeReviewer(llm: LLMProvider, config: QualityConfig): CodeReviewer;
2365
+
2366
+ /**
2367
+ * Task Iterator for the COMPLETE phase
2368
+ *
2369
+ * Manages the quality convergence loop for tasks
2370
+ */
2371
+
2372
+ /**
2373
+ * Task Iterator
2374
+ *
2375
+ * Manages the generate-review-iterate cycle
2376
+ */
2377
+ declare class TaskIterator {
2378
+ private generator;
2379
+ private reviewer;
2380
+ private config;
2381
+ constructor(llm: LLMProvider, config: QualityConfig);
2382
+ /**
2383
+ * Execute a task with quality iteration
2384
+ */
2385
+ execute(context: TaskExecutionContext, runTests: () => Promise<TestExecutionResult>, saveFiles: (files: GeneratedFile[]) => Promise<void>, onProgress?: (iteration: number, score: number) => void): Promise<TaskExecutionResult>;
2386
+ /**
2387
+ * Check if quality has converged
2388
+ */
2389
+ checkConvergence(scoreHistory: number[], review: CodeReviewResult, iteration: number): ConvergenceCheck;
2390
+ /**
2391
+ * Calculate improvement from score history
2392
+ */
2393
+ private calculateImprovement;
2394
+ /**
2395
+ * Build context string for code generation
2396
+ */
2397
+ private buildContext;
2398
+ /**
2399
+ * Build feedback string from review
2400
+ */
2401
+ private buildFeedback;
2402
+ /**
2403
+ * Convert files array to string
2404
+ */
2405
+ private filesToString;
2406
+ /**
2407
+ * Map QualityDimensions key to IssueCategory
2408
+ */
2409
+ private mapToIssueCategory;
2410
+ /**
2411
+ * Create a version snapshot
2412
+ */
2413
+ private createVersion;
2414
+ }
2415
+ /**
2416
+ * Create a task iterator
2417
+ */
2418
+ declare function createTaskIterator(llm: LLMProvider, config: QualityConfig): TaskIterator;
2419
+
2420
+ /**
2421
+ * COMPLETE Phase Executor
2422
+ *
2423
+ * Orchestrates task execution with quality iteration
2424
+ */
2425
+
2426
+ declare class CompleteExecutor implements PhaseExecutor {
2427
+ readonly name = "complete";
2428
+ readonly description = "Execute tasks with quality iteration";
2429
+ private config;
2430
+ private iterator;
2431
+ private currentSprint;
2432
+ private backlog;
2433
+ private llmAdapter;
2434
+ private checkpointState;
2435
+ private completedTaskIds;
2436
+ constructor(config?: Partial<CompleteConfig>);
2437
+ /**
2438
+ * Check if the phase can start
2439
+ */
2440
+ canStart(_context: PhaseContext): boolean;
2441
+ /**
2442
+ * Execute the COMPLETE phase
2443
+ */
2444
+ execute(context: PhaseContext): Promise<PhaseResult>;
2445
+ /**
2446
+ * Check if the phase can complete
2447
+ */
2448
+ canComplete(_context: PhaseContext): boolean;
2449
+ /**
2450
+ * Create a checkpoint
2451
+ */
2452
+ checkpoint(context: PhaseContext): Promise<PhaseCheckpoint>;
2453
+ /**
2454
+ * Restore from checkpoint
2455
+ */
2456
+ restore(checkpoint: PhaseCheckpoint, context: PhaseContext): Promise<void>;
2457
+ /**
2458
+ * Calculate current progress (0-100)
2459
+ */
2460
+ private calculateProgress;
2461
+ /**
2462
+ * Execute a sprint with dependency checking, checkpointing, and parallel execution
2463
+ */
2464
+ private executeSprint;
2465
+ /**
2466
+ * Execute tasks sequentially (original behavior)
2467
+ */
2468
+ private executeTasksSequential;
2469
+ /**
2470
+ * Execute tasks in parallel batches based on dependencies
2471
+ */
2472
+ private executeTasksParallel;
2473
+ /**
2474
+ * Execute a single task
2475
+ */
2476
+ private executeTask;
2477
+ /**
2478
+ * Run tests for a task
2479
+ */
2480
+ private runTests;
2481
+ /**
2482
+ * Get tasks for a sprint, ordered by dependencies (topological sort)
2483
+ */
2484
+ private getSprintTasks;
2485
+ /**
2486
+ * Topological sort tasks by dependencies
2487
+ */
2488
+ private topologicalSort;
2489
+ /**
2490
+ * Check if task dependencies are satisfied
2491
+ */
2492
+ private areDependenciesSatisfied;
2493
+ /**
2494
+ * Report progress
2495
+ */
2496
+ private reportProgress;
2497
+ /**
2498
+ * Load backlog
2499
+ */
2500
+ private loadBacklog;
2501
+ /**
2502
+ * Load current sprint
2503
+ */
2504
+ private loadCurrentSprint;
2505
+ /**
2506
+ * Save sprint results
2507
+ */
2508
+ private saveSprintResults;
2509
+ /**
2510
+ * Generate results markdown
2511
+ */
2512
+ private generateResultsMarkdown;
2513
+ }
2514
+ /**
2515
+ * Create a COMPLETE phase executor
2516
+ */
2517
+ declare function createCompleteExecutor(config?: Partial<CompleteConfig>): CompleteExecutor;
2518
+
2519
+ /**
2520
+ * Types for the OUTPUT phase
2521
+ *
2522
+ * This phase focuses on CI/CD generation, documentation, and deployment
2523
+ */
2524
+ /**
2525
+ * CI/CD configuration
2526
+ */
2527
+ interface CICDConfig {
2528
+ provider: CICDProvider;
2529
+ features: CICDFeatures;
2530
+ environments: Environment[];
2531
+ secrets: SecretReference[];
2532
+ }
2533
+ /**
2534
+ * CI/CD providers
2535
+ */
2536
+ type CICDProvider = "github_actions" | "gitlab_ci" | "jenkins" | "circleci" | "azure_devops";
2537
+ /**
2538
+ * CI/CD features to enable
2539
+ */
2540
+ interface CICDFeatures {
2541
+ /** Run tests on push/PR */
2542
+ tests: boolean;
2543
+ /** Run linting */
2544
+ lint: boolean;
2545
+ /** Generate coverage reports */
2546
+ coverage: boolean;
2547
+ /** Build artifacts */
2548
+ build: boolean;
2549
+ /** Create releases */
2550
+ release: boolean;
2551
+ /** Deploy to environments */
2552
+ deploy: boolean;
2553
+ /** Security scanning */
2554
+ security: boolean;
2555
+ /** Dependency updates */
2556
+ dependabot: boolean;
2557
+ }
2558
+ /**
2559
+ * Deployment environment
2560
+ */
2561
+ interface Environment {
2562
+ name: string;
2563
+ type: EnvironmentType;
2564
+ branch?: string;
2565
+ approvalRequired: boolean;
2566
+ secrets: string[];
2567
+ }
2568
+ /**
2569
+ * Environment types
2570
+ */
2571
+ type EnvironmentType = "development" | "staging" | "production";
2572
+ /**
2573
+ * Secret reference
2574
+ */
2575
+ interface SecretReference {
2576
+ name: string;
2577
+ description: string;
2578
+ required: boolean;
2579
+ }
2580
+ /**
2581
+ * Generated CI/CD file
2582
+ */
2583
+ interface CICDFile {
2584
+ path: string;
2585
+ content: string;
2586
+ description: string;
2587
+ }
2588
+ /**
2589
+ * Dockerfile configuration
2590
+ */
2591
+ interface DockerConfig {
2592
+ baseImage: string;
2593
+ port?: number;
2594
+ buildArgs: Record<string, string>;
2595
+ envVars: Record<string, string>;
2596
+ stages: DockerStage[];
2597
+ }
2598
+ /**
2599
+ * Docker stage (multi-stage build)
2600
+ */
2601
+ interface DockerStage {
2602
+ name: string;
2603
+ baseImage: string;
2604
+ commands: string[];
2605
+ }
2606
+ /**
2607
+ * Docker Compose configuration
2608
+ */
2609
+ interface ComposeConfig {
2610
+ version: string;
2611
+ services: ComposeService[];
2612
+ networks: string[];
2613
+ volumes: string[];
2614
+ }
2615
+ /**
2616
+ * Docker Compose service
2617
+ */
2618
+ interface ComposeService {
2619
+ name: string;
2620
+ image?: string;
2621
+ build?: string;
2622
+ ports: string[];
2623
+ environment: Record<string, string>;
2624
+ volumes: string[];
2625
+ dependsOn: string[];
2626
+ }
2627
+ /**
2628
+ * Documentation structure
2629
+ */
2630
+ interface DocumentationSet {
2631
+ readme: string;
2632
+ contributing: string;
2633
+ changelog: string;
2634
+ api?: string;
2635
+ deployment?: string;
2636
+ development?: string;
2637
+ }
2638
+ /**
2639
+ * Release configuration
2640
+ */
2641
+ interface ReleaseConfig {
2642
+ versioning: "semver" | "calver" | "custom";
2643
+ changelog: boolean;
2644
+ assets: string[];
2645
+ prerelease: boolean;
2646
+ }
2647
+ /**
2648
+ * OUTPUT phase configuration
2649
+ */
2650
+ interface OutputConfig {
2651
+ /** CI/CD configuration */
2652
+ cicd: {
2653
+ provider: CICDProvider;
2654
+ features: Partial<CICDFeatures>;
2655
+ };
2656
+ /** Docker configuration */
2657
+ docker: {
2658
+ enabled: boolean;
2659
+ compose: boolean;
2660
+ };
2661
+ /** Documentation to generate */
2662
+ docs: {
2663
+ readme: boolean;
2664
+ contributing: boolean;
2665
+ changelog: boolean;
2666
+ api: boolean;
2667
+ };
2668
+ /** Release configuration */
2669
+ release: Partial<ReleaseConfig>;
2670
+ }
2671
+ /**
2672
+ * Project metadata for output generation
2673
+ */
2674
+ interface ProjectMetadata {
2675
+ name: string;
2676
+ description: string;
2677
+ version: string;
2678
+ language: string;
2679
+ packageManager: string;
2680
+ testCommand: string;
2681
+ buildCommand: string;
2682
+ startCommand: string;
2683
+ author?: string;
2684
+ license?: string;
2685
+ repository?: string;
2686
+ }
2687
+
2688
+ /**
2689
+ * CI/CD Generator for the OUTPUT phase
2690
+ *
2691
+ * Generates CI/CD configurations for various providers
2692
+ */
2693
+
2694
+ /**
2695
+ * CI/CD Generator
2696
+ */
2697
+ declare class CICDGenerator {
2698
+ private metadata;
2699
+ private config;
2700
+ constructor(metadata: ProjectMetadata, config: CICDConfig);
2701
+ /**
2702
+ * Generate CI/CD files based on configuration
2703
+ */
2704
+ generate(): CICDFile[];
2705
+ /**
2706
+ * Generate GitHub Actions workflows
2707
+ */
2708
+ private generateGitHubActions;
2709
+ /**
2710
+ * Generate GitHub Actions CI workflow
2711
+ */
2712
+ private generateGitHubCI;
2713
+ /**
2714
+ * Generate GitHub Actions release workflow
2715
+ */
2716
+ private generateGitHubRelease;
2717
+ /**
2718
+ * Generate Dependabot configuration
2719
+ */
2720
+ private generateDependabot;
2721
+ /**
2722
+ * Generate GitLab CI
2723
+ */
2724
+ private generateGitLabCI;
2725
+ }
2726
+ /**
2727
+ * Create a CI/CD generator
2728
+ */
2729
+ declare function createCICDGenerator(metadata: ProjectMetadata, config: CICDConfig): CICDGenerator;
2730
+
2731
+ /**
2732
+ * Docker Generator for the OUTPUT phase
2733
+ *
2734
+ * Generates Dockerfile and Docker Compose configurations
2735
+ */
2736
+
2737
+ /**
2738
+ * Docker Generator
2739
+ */
2740
+ declare class DockerGenerator {
2741
+ private metadata;
2742
+ constructor(metadata: ProjectMetadata);
2743
+ /**
2744
+ * Generate Dockerfile
2745
+ */
2746
+ generateDockerfile(config?: Partial<DockerConfig>): string;
2747
+ /**
2748
+ * Generate Node.js Dockerfile (multi-stage)
2749
+ */
2750
+ private generateNodeDockerfile;
2751
+ /**
2752
+ * Generate Python Dockerfile
2753
+ */
2754
+ private generatePythonDockerfile;
2755
+ /**
2756
+ * Generate Go Dockerfile
2757
+ */
2758
+ private generateGoDockerfile;
2759
+ /**
2760
+ * Generate Docker Compose file
2761
+ */
2762
+ generateDockerCompose(_config?: Partial<ComposeConfig>): string;
2763
+ /**
2764
+ * Generate .dockerignore file
2765
+ */
2766
+ generateDockerignore(): string;
2767
+ }
2768
+ /**
2769
+ * Create a Docker generator
2770
+ */
2771
+ declare function createDockerGenerator(metadata: ProjectMetadata): DockerGenerator;
2772
+
2773
+ /**
2774
+ * Documentation Generator for the OUTPUT phase
2775
+ *
2776
+ * Generates README, CONTRIBUTING, and other documentation
2777
+ */
2778
+
2779
+ /**
2780
+ * Documentation Generator
2781
+ */
2782
+ declare class DocsGenerator {
2783
+ private metadata;
2784
+ constructor(metadata: ProjectMetadata);
2785
+ /**
2786
+ * Generate all documentation
2787
+ */
2788
+ generate(): DocumentationSet;
2789
+ /**
2790
+ * Generate README.md
2791
+ */
2792
+ generateReadme(): string;
2793
+ /**
2794
+ * Generate CONTRIBUTING.md
2795
+ */
2796
+ generateContributing(): string;
2797
+ /**
2798
+ * Generate CHANGELOG.md
2799
+ */
2800
+ generateChangelog(): string;
2801
+ /**
2802
+ * Generate API documentation
2803
+ */
2804
+ generateApiDocs(): string;
2805
+ /**
2806
+ * Generate deployment documentation
2807
+ */
2808
+ generateDeploymentDocs(): string;
2809
+ /**
2810
+ * Generate development documentation
2811
+ */
2812
+ generateDevelopmentDocs(): string;
2813
+ }
2814
+ /**
2815
+ * Create a documentation generator
2816
+ */
2817
+ declare function createDocsGenerator(metadata: ProjectMetadata): DocsGenerator;
2818
+
2819
+ /**
2820
+ * OUTPUT Phase Executor
2821
+ *
2822
+ * Orchestrates CI/CD, Docker, and documentation generation
2823
+ */
2824
+
2825
+ /**
2826
+ * OUTPUT phase executor
2827
+ */
2828
+ declare class OutputExecutor implements PhaseExecutor {
2829
+ readonly name = "output";
2830
+ readonly description = "Generate CI/CD, Docker, and documentation";
2831
+ private config;
2832
+ constructor(config?: Partial<OutputConfig>);
2833
+ /**
2834
+ * Deep merge configuration
2835
+ */
2836
+ private mergeConfig;
2837
+ /**
2838
+ * Check if the phase can start
2839
+ */
2840
+ canStart(_context: PhaseContext): boolean;
2841
+ /**
2842
+ * Execute the OUTPUT phase
2843
+ */
2844
+ execute(context: PhaseContext): Promise<PhaseResult>;
2845
+ /**
2846
+ * Check if the phase can complete
2847
+ */
2848
+ canComplete(_context: PhaseContext): boolean;
2849
+ /**
2850
+ * Create a checkpoint
2851
+ */
2852
+ checkpoint(_context: PhaseContext): Promise<PhaseCheckpoint>;
2853
+ /**
2854
+ * Restore from checkpoint
2855
+ */
2856
+ restore(_checkpoint: PhaseCheckpoint, _context: PhaseContext): Promise<void>;
2857
+ /**
2858
+ * Load project metadata from package.json
2859
+ */
2860
+ private loadMetadata;
2861
+ /**
2862
+ * Ensure directory exists
2863
+ */
2864
+ private ensureDir;
2865
+ }
2866
+ /**
2867
+ * Create an OUTPUT phase executor
2868
+ */
2869
+ declare function createOutputExecutor(config?: Partial<OutputConfig>): OutputExecutor;
2870
+
2871
+ /**
2872
+ * Anthropic Claude provider for Corbat-Coco
2873
+ */
2874
+
2875
+ /**
2876
+ * Anthropic provider implementation
2877
+ */
2878
+ declare class AnthropicProvider implements LLMProvider {
2879
+ readonly id = "anthropic";
2880
+ readonly name = "Anthropic Claude";
2881
+ private client;
2882
+ private config;
2883
+ private retryConfig;
2884
+ /**
2885
+ * Initialize the provider
2886
+ */
2887
+ initialize(config: ProviderConfig): Promise<void>;
2888
+ /**
2889
+ * Send a chat message
2890
+ */
2891
+ chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
2892
+ /**
2893
+ * Send a chat message with tool use
2894
+ */
2895
+ chatWithTools(messages: Message[], options: ChatWithToolsOptions): Promise<ChatWithToolsResponse>;
2896
+ /**
2897
+ * Stream a chat response
2898
+ */
2899
+ stream(messages: Message[], options?: ChatOptions): AsyncIterable<StreamChunk>;
2900
+ /**
2901
+ * Stream a chat response with tool use
2902
+ */
2903
+ streamWithTools(messages: Message[], options: ChatWithToolsOptions): AsyncIterable<StreamChunk>;
2904
+ /**
2905
+ * Count tokens (improved heuristic for Claude models)
2906
+ *
2907
+ * Claude uses a BPE tokenizer similar to GPT models. The average ratio varies:
2908
+ * - English text: ~4.5 characters per token
2909
+ * - Code: ~3.5 characters per token
2910
+ * - Whitespace-heavy: ~5 characters per token
2911
+ *
2912
+ * This heuristic analyzes the text to provide a better estimate.
2913
+ */
2914
+ countTokens(text: string): number;
2915
+ /**
2916
+ * Get context window size
2917
+ */
2918
+ getContextWindow(): number;
2919
+ /**
2920
+ * Check if provider is available
2921
+ */
2922
+ isAvailable(): Promise<boolean>;
2923
+ /**
2924
+ * Ensure client is initialized
2925
+ */
2926
+ private ensureInitialized;
2927
+ /**
2928
+ * Convert messages to Anthropic format
2929
+ */
2930
+ private convertMessages;
2931
+ /**
2932
+ * Convert message content to Anthropic format
2933
+ */
2934
+ private convertContent;
2935
+ /**
2936
+ * Convert tools to Anthropic format
2937
+ */
2938
+ private convertTools;
2939
+ /**
2940
+ * Convert tool choice to Anthropic format
2941
+ */
2942
+ private convertToolChoice;
2943
+ /**
2944
+ * Extract text content from response
2945
+ */
2946
+ private extractTextContent;
2947
+ /**
2948
+ * Extract tool calls from response
2949
+ */
2950
+ private extractToolCalls;
2951
+ /**
2952
+ * Map stop reason to our format
2953
+ */
2954
+ private mapStopReason;
2955
+ /**
2956
+ * Handle API errors
2957
+ */
2958
+ private handleError;
2959
+ }
2960
+ /**
2961
+ * Create an Anthropic provider
2962
+ */
2963
+ declare function createAnthropicProvider(config?: ProviderConfig): AnthropicProvider;
2964
+
2965
+ /**
2966
+ * Error handling for Corbat-Coco
2967
+ * Custom error types with context and recovery information
2968
+ */
2969
+ /**
2970
+ * Base error class for Corbat-Coco
2971
+ */
2972
+ declare class CocoError extends Error {
2973
+ readonly code: string;
2974
+ readonly context: Record<string, unknown>;
2975
+ readonly recoverable: boolean;
2976
+ readonly suggestion?: string;
2977
+ constructor(message: string, options: {
2978
+ code: string;
2979
+ context?: Record<string, unknown>;
2980
+ recoverable?: boolean;
2981
+ suggestion?: string;
2982
+ cause?: Error;
2983
+ });
2984
+ /**
2985
+ * Convert to JSON for logging
2986
+ */
2987
+ toJSON(): Record<string, unknown>;
2988
+ }
2989
+ /**
2990
+ * Configuration error
2991
+ */
2992
+ declare class ConfigError extends CocoError {
2993
+ readonly issues: ConfigIssue[];
2994
+ constructor(message: string, options?: {
2995
+ issues?: ConfigIssue[];
2996
+ configPath?: string;
2997
+ cause?: Error;
2998
+ });
2999
+ /**
3000
+ * Format issues as a readable string
3001
+ */
3002
+ formatIssues(): string;
3003
+ }
3004
+ interface ConfigIssue {
3005
+ path: string;
3006
+ message: string;
3007
+ }
3008
+ /**
3009
+ * Phase execution error
3010
+ */
3011
+ declare class PhaseError extends CocoError {
3012
+ readonly phase: string;
3013
+ constructor(message: string, options: {
3014
+ phase: string;
3015
+ recoverable?: boolean;
3016
+ cause?: Error;
3017
+ });
3018
+ }
3019
+ /**
3020
+ * Task execution error
3021
+ */
3022
+ declare class TaskError extends CocoError {
3023
+ readonly taskId: string;
3024
+ readonly iteration?: number;
3025
+ constructor(message: string, options: {
3026
+ taskId: string;
3027
+ iteration?: number;
3028
+ recoverable?: boolean;
3029
+ cause?: Error;
3030
+ });
3031
+ }
3032
+
3033
+ /**
3034
+ * Provider exports for Corbat-Coco
3035
+ */
3036
+
3037
+ /**
3038
+ * Supported provider types
3039
+ */
3040
+ type ProviderType = "anthropic" | "openai" | "codex" | "gemini" | "kimi" | "lmstudio";
3041
+ /**
3042
+ * Create a provider by type
3043
+ */
3044
+ declare function createProvider(type: ProviderType, config?: ProviderConfig): Promise<LLMProvider>;
3045
+
3046
+ /**
3047
+ * Tool Registry for Corbat-Coco
3048
+ * Central management of all available tools
3049
+ */
3050
+
3051
+ /**
3052
+ * Tool definition
3053
+ */
3054
+ interface ToolDefinition<TInput = unknown, TOutput = unknown> {
3055
+ name: string;
3056
+ description: string;
3057
+ category: ToolCategory;
3058
+ parameters: z.ZodType<TInput, any, any>;
3059
+ execute: (params: TInput) => Promise<TOutput>;
3060
+ }
3061
+ /**
3062
+ * Tool categories
3063
+ */
3064
+ type ToolCategory = "file" | "bash" | "git" | "test" | "quality" | "build" | "deploy" | "config" | "web" | "search" | "memory" | "document";
3065
+ /**
3066
+ * Tool execution result
3067
+ */
3068
+ interface ToolResult<T = unknown> {
3069
+ success: boolean;
3070
+ data?: T;
3071
+ error?: string;
3072
+ duration: number;
3073
+ }
3074
+ /**
3075
+ * Progress callback for long-running operations
3076
+ */
3077
+ type ProgressCallback = (progress: ProgressInfo) => void;
3078
+ /**
3079
+ * Progress information
3080
+ */
3081
+ interface ProgressInfo {
3082
+ /** Current step or phase name */
3083
+ phase: string;
3084
+ /** Progress percentage (0-100), null if indeterminate */
3085
+ percent: number | null;
3086
+ /** Human-readable message */
3087
+ message?: string;
3088
+ /** Estimated time remaining in ms, null if unknown */
3089
+ estimatedTimeRemaining?: number | null;
3090
+ /** Additional metadata */
3091
+ metadata?: Record<string, unknown>;
3092
+ }
3093
+ /**
3094
+ * Options for tool execution
3095
+ */
3096
+ interface ExecuteOptions {
3097
+ /** Progress callback for long operations */
3098
+ onProgress?: ProgressCallback;
3099
+ /** Abort signal for cancellation */
3100
+ signal?: AbortSignal;
3101
+ }
3102
+ /**
3103
+ * Tool registry
3104
+ */
3105
+ declare class ToolRegistry {
3106
+ private tools;
3107
+ private logger;
3108
+ /**
3109
+ * Register a tool
3110
+ */
3111
+ register<TInput, TOutput>(tool: ToolDefinition<TInput, TOutput>): void;
3112
+ /**
3113
+ * Unregister a tool
3114
+ */
3115
+ unregister(name: string): boolean;
3116
+ /**
3117
+ * Get a tool by name
3118
+ */
3119
+ get<TInput = unknown, TOutput = unknown>(name: string): ToolDefinition<TInput, TOutput> | undefined;
3120
+ /**
3121
+ * Check if a tool exists
3122
+ */
3123
+ has(name: string): boolean;
3124
+ /**
3125
+ * Get all tools
3126
+ */
3127
+ getAll(): ToolDefinition[];
3128
+ /**
3129
+ * Get tools by category
3130
+ */
3131
+ getByCategory(category: ToolCategory): ToolDefinition[];
3132
+ /**
3133
+ * Execute a tool
3134
+ */
3135
+ execute<TInput, TOutput>(name: string, params: TInput, options?: ExecuteOptions): Promise<ToolResult<TOutput>>;
3136
+ /**
3137
+ * Get tool definitions for LLM (simplified format)
3138
+ */
3139
+ getToolDefinitionsForLLM(): Array<{
3140
+ name: string;
3141
+ description: string;
3142
+ input_schema: Record<string, unknown>;
3143
+ }>;
3144
+ }
3145
+ /**
3146
+ * Create a new tool registry
3147
+ */
3148
+ declare function createToolRegistry(): ToolRegistry;
3149
+
3150
+ /**
3151
+ * Tool exports for Corbat-Coco
3152
+ */
3153
+
3154
+ declare function registerAllTools(registry: ToolRegistry): void;
3155
+ /**
3156
+ * Create a registry with all tools registered
3157
+ */
3158
+ declare function createFullToolRegistry(): ToolRegistry;
3159
+
3160
+ /**
3161
+ * Logging system for Corbat-Coco
3162
+ * Based on tslog with structured output
3163
+ */
3164
+
3165
+ /**
3166
+ * Log levels
3167
+ */
3168
+ type LogLevel = "silly" | "trace" | "debug" | "info" | "warn" | "error" | "fatal";
3169
+ /**
3170
+ * Logger configuration
3171
+ */
3172
+ interface LoggerConfig {
3173
+ name: string;
3174
+ level: LogLevel;
3175
+ prettyPrint: boolean;
3176
+ logToFile: boolean;
3177
+ logDir?: string;
3178
+ }
3179
+ /**
3180
+ * Create a logger instance
3181
+ */
3182
+ declare function createLogger(config?: Partial<LoggerConfig>): Logger<ILogObj>;
3183
+
3184
+ export { ADRGenerator, AnthropicProvider, ArchitectureGenerator, type Backlog, BacklogGenerator, CICDGenerator, type ChatOptions, type ChatResponse, type CocoConfig, CocoError, CodeGenerator, CodeReviewer, CompleteExecutor, ConfigError, ConvergeExecutor, DiscoveryEngine, DockerGenerator, DocsGenerator, type Epic, type LLMProvider, type Message, OrchestrateExecutor, type Orchestrator, type OrchestratorConfig, OutputExecutor, type Phase, type PhaseContext, PhaseError, type PhaseExecutor, type PhaseResult, type Progress, type ProjectState, type QualityDimensions, type QualityScores, type QualityThresholds, SessionManager, SpecificationGenerator, type Sprint, type Story, type Task, TaskError, type TaskHistory, TaskIterator, type TaskVersion, ToolRegistry, VERSION, configExists, createADRGenerator, createAnthropicProvider, createArchitectureGenerator, createBacklogGenerator, createCICDGenerator, createCodeGenerator, createCodeReviewer, createCompleteExecutor, createConvergeExecutor, createDefaultConfig, createDiscoveryEngine, createDockerGenerator, createDocsGenerator, createFullToolRegistry, createLogger, createOrchestrateExecutor, createOrchestrator, createOutputExecutor, createProvider, createSessionManager, createSpecificationGenerator, createTaskIterator, createToolRegistry, loadConfig, registerAllTools, saveConfig };