popeye-cli 1.0.0 → 1.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.
- package/README.md +521 -125
- package/dist/adapters/claude.d.ts +16 -4
- package/dist/adapters/claude.d.ts.map +1 -1
- package/dist/adapters/claude.js +679 -33
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/gemini.d.ts +55 -0
- package/dist/adapters/gemini.d.ts.map +1 -0
- package/dist/adapters/gemini.js +318 -0
- package/dist/adapters/gemini.js.map +1 -0
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +41 -7
- package/dist/adapters/openai.js.map +1 -1
- package/dist/auth/claude.d.ts +11 -9
- package/dist/auth/claude.d.ts.map +1 -1
- package/dist/auth/claude.js +107 -71
- package/dist/auth/claude.js.map +1 -1
- package/dist/auth/gemini.d.ts +58 -0
- package/dist/auth/gemini.d.ts.map +1 -0
- package/dist/auth/gemini.js +172 -0
- package/dist/auth/gemini.js.map +1 -0
- package/dist/auth/index.d.ts +11 -7
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +23 -5
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/keychain.d.ts +20 -7
- package/dist/auth/keychain.d.ts.map +1 -1
- package/dist/auth/keychain.js +85 -29
- package/dist/auth/keychain.js.map +1 -1
- package/dist/auth/openai.d.ts +2 -2
- package/dist/auth/openai.d.ts.map +1 -1
- package/dist/auth/openai.js +30 -32
- package/dist/auth/openai.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +4 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/interactive.d.ts +2 -2
- package/dist/cli/interactive.d.ts.map +1 -1
- package/dist/cli/interactive.js +1380 -183
- package/dist/cli/interactive.js.map +1 -1
- package/dist/config/defaults.d.ts +6 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +10 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +19 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/schema.d.ts +20 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +7 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/generators/python.d.ts.map +1 -1
- package/dist/generators/python.js +1 -0
- package/dist/generators/python.js.map +1 -1
- package/dist/generators/typescript.d.ts.map +1 -1
- package/dist/generators/typescript.js +1 -0
- package/dist/generators/typescript.js.map +1 -1
- package/dist/state/index.d.ts +108 -0
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +551 -4
- package/dist/state/index.js.map +1 -1
- package/dist/state/registry.d.ts +52 -0
- package/dist/state/registry.d.ts.map +1 -0
- package/dist/state/registry.js +215 -0
- package/dist/state/registry.js.map +1 -0
- package/dist/types/cli.d.ts +4 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/cli.js.map +1 -1
- package/dist/types/consensus.d.ts +69 -4
- package/dist/types/consensus.d.ts.map +1 -1
- package/dist/types/consensus.js +24 -3
- package/dist/types/consensus.js.map +1 -1
- package/dist/types/workflow.d.ts +55 -0
- package/dist/types/workflow.d.ts.map +1 -1
- package/dist/types/workflow.js +16 -0
- package/dist/types/workflow.js.map +1 -1
- package/dist/workflow/auto-fix.d.ts +45 -0
- package/dist/workflow/auto-fix.d.ts.map +1 -0
- package/dist/workflow/auto-fix.js +274 -0
- package/dist/workflow/auto-fix.js.map +1 -0
- package/dist/workflow/consensus.d.ts +44 -2
- package/dist/workflow/consensus.d.ts.map +1 -1
- package/dist/workflow/consensus.js +565 -17
- package/dist/workflow/consensus.js.map +1 -1
- package/dist/workflow/execution-mode.d.ts +10 -4
- package/dist/workflow/execution-mode.d.ts.map +1 -1
- package/dist/workflow/execution-mode.js +547 -58
- package/dist/workflow/execution-mode.js.map +1 -1
- package/dist/workflow/index.d.ts +14 -2
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +69 -6
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/milestone-workflow.d.ts +34 -0
- package/dist/workflow/milestone-workflow.d.ts.map +1 -0
- package/dist/workflow/milestone-workflow.js +414 -0
- package/dist/workflow/milestone-workflow.js.map +1 -0
- package/dist/workflow/plan-mode.d.ts +14 -1
- package/dist/workflow/plan-mode.d.ts.map +1 -1
- package/dist/workflow/plan-mode.js +589 -47
- package/dist/workflow/plan-mode.js.map +1 -1
- package/dist/workflow/plan-storage.d.ts +142 -0
- package/dist/workflow/plan-storage.d.ts.map +1 -0
- package/dist/workflow/plan-storage.js +331 -0
- package/dist/workflow/plan-storage.js.map +1 -0
- package/dist/workflow/project-verification.d.ts +37 -0
- package/dist/workflow/project-verification.d.ts.map +1 -0
- package/dist/workflow/project-verification.js +381 -0
- package/dist/workflow/project-verification.js.map +1 -0
- package/dist/workflow/task-workflow.d.ts +37 -0
- package/dist/workflow/task-workflow.d.ts.map +1 -0
- package/dist/workflow/task-workflow.js +383 -0
- package/dist/workflow/task-workflow.js.map +1 -0
- package/dist/workflow/test-runner.d.ts +1 -0
- package/dist/workflow/test-runner.d.ts.map +1 -1
- package/dist/workflow/test-runner.js +9 -5
- package/dist/workflow/test-runner.js.map +1 -1
- package/dist/workflow/ui-designer.d.ts +82 -0
- package/dist/workflow/ui-designer.d.ts.map +1 -0
- package/dist/workflow/ui-designer.js +234 -0
- package/dist/workflow/ui-designer.js.map +1 -0
- package/dist/workflow/ui-setup.d.ts +58 -0
- package/dist/workflow/ui-setup.d.ts.map +1 -0
- package/dist/workflow/ui-setup.js +685 -0
- package/dist/workflow/ui-setup.js.map +1 -0
- package/dist/workflow/ui-verification.d.ts +114 -0
- package/dist/workflow/ui-verification.d.ts.map +1 -0
- package/dist/workflow/ui-verification.js +258 -0
- package/dist/workflow/ui-verification.js.map +1 -0
- package/dist/workflow/workflow-logger.d.ts +110 -0
- package/dist/workflow/workflow-logger.d.ts.map +1 -0
- package/dist/workflow/workflow-logger.js +267 -0
- package/dist/workflow/workflow-logger.js.map +1 -0
- package/package.json +2 -2
- package/src/adapters/claude.ts +815 -34
- package/src/adapters/gemini.ts +373 -0
- package/src/adapters/openai.ts +40 -7
- package/src/auth/claude.ts +120 -78
- package/src/auth/gemini.ts +207 -0
- package/src/auth/index.ts +28 -8
- package/src/auth/keychain.ts +95 -28
- package/src/auth/openai.ts +29 -36
- package/src/cli/index.ts +4 -7
- package/src/cli/interactive.ts +1641 -216
- package/src/config/defaults.ts +10 -2
- package/src/config/index.ts +21 -0
- package/src/config/schema.ts +7 -0
- package/src/generators/python.ts +1 -0
- package/src/generators/typescript.ts +1 -0
- package/src/state/index.ts +713 -4
- package/src/state/registry.ts +278 -0
- package/src/types/cli.ts +4 -0
- package/src/types/consensus.ts +65 -6
- package/src/types/workflow.ts +35 -0
- package/src/workflow/auto-fix.ts +340 -0
- package/src/workflow/consensus.ts +750 -16
- package/src/workflow/execution-mode.ts +673 -74
- package/src/workflow/index.ts +95 -6
- package/src/workflow/milestone-workflow.ts +576 -0
- package/src/workflow/plan-mode.ts +696 -50
- package/src/workflow/plan-storage.ts +482 -0
- package/src/workflow/project-verification.ts +471 -0
- package/src/workflow/task-workflow.ts +525 -0
- package/src/workflow/test-runner.ts +10 -5
- package/src/workflow/ui-designer.ts +337 -0
- package/src/workflow/ui-setup.ts +797 -0
- package/src/workflow/ui-verification.ts +357 -0
- package/src/workflow/workflow-logger.ts +353 -0
- package/tests/config/config.test.ts +1 -1
- package/tests/types/consensus.test.ts +3 -3
- package/tests/workflow/plan-mode.test.ts +213 -0
- package/tests/workflow/test-runner.test.ts +5 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-fix module for automatically fixing build and TypeScript errors
|
|
3
|
+
* Uses Claude to analyze errors and apply fixes
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Build error details
|
|
7
|
+
*/
|
|
8
|
+
export interface BuildError {
|
|
9
|
+
file: string;
|
|
10
|
+
line?: number;
|
|
11
|
+
column?: number;
|
|
12
|
+
message: string;
|
|
13
|
+
code?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Auto-fix result
|
|
17
|
+
*/
|
|
18
|
+
export interface AutoFixResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
fixedErrors: number;
|
|
21
|
+
remainingErrors: number;
|
|
22
|
+
attempts: number;
|
|
23
|
+
fixes: Array<{
|
|
24
|
+
file: string;
|
|
25
|
+
description: string;
|
|
26
|
+
}>;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse TypeScript compiler errors from output
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseTypeScriptErrors(output: string): BuildError[];
|
|
33
|
+
/**
|
|
34
|
+
* Auto-fix TypeScript errors in a project
|
|
35
|
+
*/
|
|
36
|
+
export declare function autoFixTypeScriptErrors(projectDir: string, buildOutput: string, maxAttempts?: number, onProgress?: (message: string) => void): Promise<AutoFixResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Run build with auto-fix
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildWithAutoFix(projectDir: string, language: string, maxAttempts?: number, onProgress?: (message: string) => void): Promise<{
|
|
41
|
+
success: boolean;
|
|
42
|
+
output: string;
|
|
43
|
+
autoFixed: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=auto-fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-fix.d.ts","sourceRoot":"","sources":["../../src/workflow/auto-fix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAgBlE;AA6FD;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,GAAE,MAAU,EACvB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACrC,OAAO,CAAC,aAAa,CAAC,CA6GxB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,MAAU,EACvB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACrC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAiEnE"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-fix module for automatically fixing build and TypeScript errors
|
|
3
|
+
* Uses Claude to analyze errors and apply fixes
|
|
4
|
+
*/
|
|
5
|
+
import { promises as fs } from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { executePrompt } from '../adapters/claude.js';
|
|
8
|
+
/**
|
|
9
|
+
* Parse TypeScript compiler errors from output
|
|
10
|
+
*/
|
|
11
|
+
export function parseTypeScriptErrors(output) {
|
|
12
|
+
const errors = [];
|
|
13
|
+
const errorPattern = /^(.+?)\((\d+),(\d+)\): error (TS\d+): (.+)$/gm;
|
|
14
|
+
let match;
|
|
15
|
+
while ((match = errorPattern.exec(output)) !== null) {
|
|
16
|
+
errors.push({
|
|
17
|
+
file: match[1],
|
|
18
|
+
line: parseInt(match[2], 10),
|
|
19
|
+
column: parseInt(match[3], 10),
|
|
20
|
+
code: match[4],
|
|
21
|
+
message: match[5],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return errors;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Group errors by file for efficient fixing
|
|
28
|
+
*/
|
|
29
|
+
function groupErrorsByFile(errors) {
|
|
30
|
+
const grouped = new Map();
|
|
31
|
+
for (const error of errors) {
|
|
32
|
+
const existing = grouped.get(error.file) || [];
|
|
33
|
+
existing.push(error);
|
|
34
|
+
grouped.set(error.file, existing);
|
|
35
|
+
}
|
|
36
|
+
return grouped;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate fix prompt for a file with errors
|
|
40
|
+
*/
|
|
41
|
+
function generateFixPrompt(filePath, fileContent, errors) {
|
|
42
|
+
const errorList = errors
|
|
43
|
+
.map(e => `- Line ${e.line}: ${e.code} - ${e.message}`)
|
|
44
|
+
.join('\n');
|
|
45
|
+
return `
|
|
46
|
+
Fix the following TypeScript errors in this file. Return ONLY the complete fixed file content, no explanations.
|
|
47
|
+
|
|
48
|
+
## File: ${filePath}
|
|
49
|
+
|
|
50
|
+
## Errors to fix:
|
|
51
|
+
${errorList}
|
|
52
|
+
|
|
53
|
+
## Current file content:
|
|
54
|
+
\`\`\`typescript
|
|
55
|
+
${fileContent}
|
|
56
|
+
\`\`\`
|
|
57
|
+
|
|
58
|
+
## Instructions:
|
|
59
|
+
1. Fix ALL the errors listed above
|
|
60
|
+
2. Do not change any working code
|
|
61
|
+
3. Preserve all imports, exports, and functionality
|
|
62
|
+
4. For type-only exports (interfaces, types), use \`export type { ... }\` syntax
|
|
63
|
+
5. For unused variables, either use them or prefix with underscore
|
|
64
|
+
6. For missing properties, add them with appropriate default values
|
|
65
|
+
7. Return ONLY the fixed TypeScript code, no markdown formatting
|
|
66
|
+
|
|
67
|
+
Fixed code:
|
|
68
|
+
`.trim();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extract code from Claude's response
|
|
72
|
+
*/
|
|
73
|
+
function extractCodeFromResponse(response) {
|
|
74
|
+
// Try to extract from code block first
|
|
75
|
+
const codeBlockMatch = response.match(/```(?:typescript|ts)?\n([\s\S]*?)\n```/);
|
|
76
|
+
if (codeBlockMatch) {
|
|
77
|
+
return codeBlockMatch[1].trim();
|
|
78
|
+
}
|
|
79
|
+
// If no code block, assume the entire response is code
|
|
80
|
+
// But strip any leading/trailing explanation text
|
|
81
|
+
const lines = response.split('\n');
|
|
82
|
+
// Find first line that looks like code (import, export, const, etc.)
|
|
83
|
+
const codeStartPatterns = [
|
|
84
|
+
/^import\s/,
|
|
85
|
+
/^export\s/,
|
|
86
|
+
/^const\s/,
|
|
87
|
+
/^let\s/,
|
|
88
|
+
/^var\s/,
|
|
89
|
+
/^function\s/,
|
|
90
|
+
/^class\s/,
|
|
91
|
+
/^interface\s/,
|
|
92
|
+
/^type\s/,
|
|
93
|
+
/^\/\//,
|
|
94
|
+
/^\/\*/,
|
|
95
|
+
/^['"`]/,
|
|
96
|
+
];
|
|
97
|
+
let startIndex = 0;
|
|
98
|
+
for (let i = 0; i < lines.length; i++) {
|
|
99
|
+
const line = lines[i].trim();
|
|
100
|
+
if (codeStartPatterns.some(p => p.test(line))) {
|
|
101
|
+
startIndex = i;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return lines.slice(startIndex).join('\n').trim();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Auto-fix TypeScript errors in a project
|
|
109
|
+
*/
|
|
110
|
+
export async function autoFixTypeScriptErrors(projectDir, buildOutput, maxAttempts = 3, onProgress) {
|
|
111
|
+
const fixes = [];
|
|
112
|
+
let attempts = 0;
|
|
113
|
+
let currentOutput = buildOutput;
|
|
114
|
+
while (attempts < maxAttempts) {
|
|
115
|
+
attempts++;
|
|
116
|
+
onProgress?.(`Auto-fix attempt ${attempts}/${maxAttempts}...`);
|
|
117
|
+
const errors = parseTypeScriptErrors(currentOutput);
|
|
118
|
+
if (errors.length === 0) {
|
|
119
|
+
onProgress?.('No TypeScript errors found');
|
|
120
|
+
return {
|
|
121
|
+
success: true,
|
|
122
|
+
fixedErrors: fixes.length,
|
|
123
|
+
remainingErrors: 0,
|
|
124
|
+
attempts,
|
|
125
|
+
fixes,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
onProgress?.(`Found ${errors.length} TypeScript error(s) to fix`);
|
|
129
|
+
// Group errors by file
|
|
130
|
+
const errorsByFile = groupErrorsByFile(errors);
|
|
131
|
+
let fixedInThisAttempt = 0;
|
|
132
|
+
// Fix each file
|
|
133
|
+
for (const [filePath, fileErrors] of errorsByFile) {
|
|
134
|
+
const absolutePath = path.isAbsolute(filePath) ? filePath : path.join(projectDir, filePath);
|
|
135
|
+
try {
|
|
136
|
+
// Read current file content
|
|
137
|
+
const fileContent = await fs.readFile(absolutePath, 'utf-8');
|
|
138
|
+
onProgress?.(`Fixing ${fileErrors.length} error(s) in ${path.basename(filePath)}...`);
|
|
139
|
+
// Generate fix prompt
|
|
140
|
+
const prompt = generateFixPrompt(filePath, fileContent, fileErrors);
|
|
141
|
+
// Ask Claude to fix
|
|
142
|
+
const result = await executePrompt(prompt, {
|
|
143
|
+
allowedTools: [],
|
|
144
|
+
permissionMode: 'default',
|
|
145
|
+
});
|
|
146
|
+
if (result.success && result.response) {
|
|
147
|
+
const fixedCode = extractCodeFromResponse(result.response);
|
|
148
|
+
// Validate the fix is not empty and looks like code
|
|
149
|
+
if (fixedCode.length > 100 && (fixedCode.includes('import') || fixedCode.includes('export'))) {
|
|
150
|
+
// Write fixed content
|
|
151
|
+
await fs.writeFile(absolutePath, fixedCode, 'utf-8');
|
|
152
|
+
fixes.push({
|
|
153
|
+
file: filePath,
|
|
154
|
+
description: `Fixed ${fileErrors.length} error(s): ${fileErrors.map(e => e.code).join(', ')}`,
|
|
155
|
+
});
|
|
156
|
+
fixedInThisAttempt += fileErrors.length;
|
|
157
|
+
onProgress?.(`Fixed ${path.basename(filePath)}`);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
onProgress?.(`Skipped ${path.basename(filePath)} - fix doesn't look valid`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
onProgress?.(`Failed to get fix for ${path.basename(filePath)}: ${result.error}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
onProgress?.(`Error fixing ${filePath}: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (fixedInThisAttempt === 0) {
|
|
172
|
+
onProgress?.('No fixes were applied in this attempt');
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
// Re-run TypeScript check to get remaining errors
|
|
176
|
+
onProgress?.('Re-checking for remaining errors...');
|
|
177
|
+
const { exec } = await import('node:child_process');
|
|
178
|
+
const { promisify } = await import('node:util');
|
|
179
|
+
const execAsync = promisify(exec);
|
|
180
|
+
try {
|
|
181
|
+
await execAsync('npx tsc --noEmit', { cwd: projectDir });
|
|
182
|
+
currentOutput = '';
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
if (err && typeof err === 'object' && 'stdout' in err) {
|
|
186
|
+
currentOutput = err.stdout + err.stderr;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
currentOutput = '';
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Final error count
|
|
194
|
+
const remainingErrors = parseTypeScriptErrors(currentOutput);
|
|
195
|
+
return {
|
|
196
|
+
success: remainingErrors.length === 0,
|
|
197
|
+
fixedErrors: fixes.length,
|
|
198
|
+
remainingErrors: remainingErrors.length,
|
|
199
|
+
attempts,
|
|
200
|
+
fixes,
|
|
201
|
+
error: remainingErrors.length > 0
|
|
202
|
+
? `${remainingErrors.length} error(s) remain after ${attempts} fix attempt(s)`
|
|
203
|
+
: undefined,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Run build with auto-fix
|
|
208
|
+
*/
|
|
209
|
+
export async function buildWithAutoFix(projectDir, language, maxAttempts = 3, onProgress) {
|
|
210
|
+
const { exec } = await import('node:child_process');
|
|
211
|
+
const { promisify } = await import('node:util');
|
|
212
|
+
const execAsync = promisify(exec);
|
|
213
|
+
// Determine build command based on language
|
|
214
|
+
let buildCommand;
|
|
215
|
+
if (language === 'typescript' || language === 'javascript') {
|
|
216
|
+
// Check for package.json build script
|
|
217
|
+
try {
|
|
218
|
+
const pkgJson = JSON.parse(await fs.readFile(path.join(projectDir, 'package.json'), 'utf-8'));
|
|
219
|
+
if (pkgJson.scripts?.build) {
|
|
220
|
+
buildCommand = 'npm run build';
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
buildCommand = 'npx tsc --noEmit';
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
buildCommand = 'npx tsc --noEmit';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else if (language === 'python') {
|
|
231
|
+
buildCommand = 'python -m py_compile $(find . -name "*.py" -not -path "./venv/*")';
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
buildCommand = 'npm run build';
|
|
235
|
+
}
|
|
236
|
+
// Initial build attempt
|
|
237
|
+
onProgress?.(`Running build: ${buildCommand}`);
|
|
238
|
+
try {
|
|
239
|
+
const { stdout, stderr } = await execAsync(buildCommand, {
|
|
240
|
+
cwd: projectDir,
|
|
241
|
+
timeout: 120000,
|
|
242
|
+
});
|
|
243
|
+
return { success: true, output: stdout + stderr, autoFixed: false };
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
const output = err && typeof err === 'object' && 'stdout' in err
|
|
247
|
+
? err.stdout + err.stderr
|
|
248
|
+
: String(err);
|
|
249
|
+
onProgress?.('Build failed, attempting auto-fix...');
|
|
250
|
+
// Try auto-fix for TypeScript errors
|
|
251
|
+
if (language === 'typescript' || language === 'javascript') {
|
|
252
|
+
const fixResult = await autoFixTypeScriptErrors(projectDir, output, maxAttempts, onProgress);
|
|
253
|
+
if (fixResult.success) {
|
|
254
|
+
// Retry build after fixes
|
|
255
|
+
onProgress?.('Auto-fix successful, retrying build...');
|
|
256
|
+
try {
|
|
257
|
+
const { stdout: retryStdout, stderr: retryStderr } = await execAsync(buildCommand, {
|
|
258
|
+
cwd: projectDir,
|
|
259
|
+
timeout: 120000,
|
|
260
|
+
});
|
|
261
|
+
return { success: true, output: retryStdout + retryStderr, autoFixed: true };
|
|
262
|
+
}
|
|
263
|
+
catch (retryErr) {
|
|
264
|
+
const retryOutput = retryErr && typeof retryErr === 'object' && 'stdout' in retryErr
|
|
265
|
+
? retryErr.stdout + retryErr.stderr
|
|
266
|
+
: String(retryErr);
|
|
267
|
+
return { success: false, output: retryOutput, autoFixed: true };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return { success: false, output, autoFixed: false };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=auto-fix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-fix.js","sourceRoot":"","sources":["../../src/workflow/auto-fix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA4BtD;;GAEG;AACH,MAAM,UAAU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AAC,OAAO,QAAiB,EAAE,CAAC;oBAC3B,MAAM,WAAW,GAAG,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,QAAQ;wBAClF,CAAC,CAAE,QAA+C,CAAC,MAAM,GAAI,QAA+C,CAAC,MAAM;wBACnH,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACrB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;gBAClE,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Consensus workflow module
|
|
3
|
-
* Handles the iterative consensus-building process between Claude and OpenAI
|
|
3
|
+
* Handles the iterative consensus-building process between Claude and OpenAI/Gemini
|
|
4
|
+
* with arbitration support when consensus cannot be reached
|
|
4
5
|
*/
|
|
5
|
-
import type { ConsensusResult, ConsensusIteration, ConsensusConfig } from '../types/consensus.js';
|
|
6
|
+
import type { ConsensusResult, ConsensusIteration, ConsensusConfig, ArbitrationResult, AIProvider } from '../types/consensus.js';
|
|
6
7
|
/**
|
|
7
8
|
* Options for consensus iteration
|
|
8
9
|
*/
|
|
@@ -11,6 +12,9 @@ export interface ConsensusOptions {
|
|
|
11
12
|
config?: Partial<ConsensusConfig>;
|
|
12
13
|
onIteration?: (iteration: number, result: ConsensusResult) => void;
|
|
13
14
|
onRevision?: (iteration: number, revisedPlan: string) => void;
|
|
15
|
+
onConcerns?: (concerns: string[], recommendations: string[]) => void;
|
|
16
|
+
onArbitration?: (result: ArbitrationResult) => void;
|
|
17
|
+
onProgress?: (phase: string, message: string) => void;
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* Result of the consensus process
|
|
@@ -19,8 +23,17 @@ export interface ConsensusProcessResult {
|
|
|
19
23
|
approved: boolean;
|
|
20
24
|
finalPlan: string;
|
|
21
25
|
finalScore: number;
|
|
26
|
+
bestPlan: string;
|
|
27
|
+
bestScore: number;
|
|
28
|
+
bestIteration: number;
|
|
22
29
|
iterations: ConsensusIteration[];
|
|
23
30
|
totalIterations: number;
|
|
31
|
+
finalConcerns: string[];
|
|
32
|
+
finalRecommendations: string[];
|
|
33
|
+
arbitrated: boolean;
|
|
34
|
+
arbitrationResult?: ArbitrationResult;
|
|
35
|
+
/** True if consensus timed out and we accepted the best available plan */
|
|
36
|
+
timedOut?: boolean;
|
|
24
37
|
}
|
|
25
38
|
/**
|
|
26
39
|
* Format a plan for consensus review
|
|
@@ -48,6 +61,7 @@ export declare function extractConcerns(result: ConsensusResult): string[];
|
|
|
48
61
|
export declare function meetsThreshold(score: number, threshold?: number): boolean;
|
|
49
62
|
/**
|
|
50
63
|
* Iterate until consensus is reached
|
|
64
|
+
* Supports configurable reviewer and arbitration when stuck
|
|
51
65
|
*
|
|
52
66
|
* @param initialPlan - The initial plan to review
|
|
53
67
|
* @param context - Project context
|
|
@@ -86,4 +100,32 @@ export declare function calculateAverageScore(iterations: ConsensusIteration[]):
|
|
|
86
100
|
* @returns 'improving', 'declining', or 'stable'
|
|
87
101
|
*/
|
|
88
102
|
export declare function getScoreTrend(iterations: ConsensusIteration[]): 'improving' | 'declining' | 'stable';
|
|
103
|
+
/**
|
|
104
|
+
* Options for optimized consensus
|
|
105
|
+
*/
|
|
106
|
+
export interface OptimizedConsensusOptions extends ConsensusOptions {
|
|
107
|
+
milestoneId: string;
|
|
108
|
+
milestoneName?: string;
|
|
109
|
+
taskId?: string;
|
|
110
|
+
taskName?: string;
|
|
111
|
+
/** Use parallel reviews from multiple providers */
|
|
112
|
+
parallelReviews?: boolean;
|
|
113
|
+
/** Additional reviewers beyond primary */
|
|
114
|
+
additionalReviewers?: AIProvider[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Optimized consensus process that batches feedback and reduces API calls
|
|
118
|
+
*
|
|
119
|
+
* Key optimizations:
|
|
120
|
+
* 1. Plans stored in files, not regenerated from scratch
|
|
121
|
+
* 2. Collects ALL reviewer feedback before revision
|
|
122
|
+
* 3. Claude revises ONCE per round with combined feedback
|
|
123
|
+
* 4. Parallel reviews when multiple reviewers configured
|
|
124
|
+
*
|
|
125
|
+
* @param initialPlan - The initial plan to seek consensus on
|
|
126
|
+
* @param context - Project context for review
|
|
127
|
+
* @param options - Consensus options including tracking info
|
|
128
|
+
* @returns Consensus process result
|
|
129
|
+
*/
|
|
130
|
+
export declare function runOptimizedConsensusProcess(initialPlan: string, context: string, options: OptimizedConsensusOptions): Promise<ConsensusProcessResult>;
|
|
89
131
|
//# sourceMappingURL=consensus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensus.d.ts","sourceRoot":"","sources":["../../src/workflow/consensus.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"consensus.d.ts","sourceRoot":"","sources":["../../src/workflow/consensus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQjI;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACnE,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC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