corbat-coco 0.1.0

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