edsger 0.2.3 → 0.2.5
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 +17 -0
- package/dist/api/features/batch-operations.d.ts +16 -0
- package/dist/api/features/batch-operations.js +100 -0
- package/dist/api/features/index.d.ts +1 -0
- package/dist/api/features/index.js +1 -0
- package/dist/api/features/test-cases.d.ts +8 -0
- package/dist/api/features/test-cases.js +45 -0
- package/dist/api/features/user-stories.d.ts +8 -0
- package/dist/api/features/user-stories.js +45 -0
- package/dist/cli/commands/refactor-command.d.ts +2 -0
- package/dist/cli/commands/refactor-command.js +123 -0
- package/dist/cli/formatters/formatter-utils.d.ts +23 -0
- package/dist/cli/formatters/formatter-utils.js +67 -0
- package/dist/cli/index.js +7 -0
- package/dist/cli/utils/command-handler.d.ts +23 -0
- package/dist/cli/utils/command-handler.js +39 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +4 -99
- package/dist/phases/code-implementation/analyzer-helpers.d.ts +28 -0
- package/dist/phases/code-implementation/analyzer-helpers.js +177 -0
- package/dist/phases/code-implementation/analyzer.d.ts +2 -0
- package/dist/phases/code-implementation/analyzer.js +304 -175
- package/dist/phases/code-implementation-verification/index.d.ts +1 -0
- package/dist/phases/code-implementation-verification/index.js +1 -0
- package/dist/phases/code-implementation-verification/verifier.d.ts +31 -0
- package/dist/phases/code-implementation-verification/verifier.js +196 -0
- package/dist/phases/feature-analysis/analyzer-helpers.d.ts +62 -0
- package/dist/phases/feature-analysis/analyzer-helpers.js +450 -0
- package/dist/phases/feature-analysis/analyzer.d.ts +1 -0
- package/dist/phases/feature-analysis/analyzer.js +132 -219
- package/dist/phases/feature-analysis-verification/index.d.ts +1 -0
- package/dist/phases/feature-analysis-verification/index.js +1 -0
- package/dist/phases/feature-analysis-verification/verifier.d.ts +37 -0
- package/dist/phases/feature-analysis-verification/verifier.js +147 -0
- package/dist/phases/pull-request/creator.js +2 -1
- package/dist/phases/technical-design/analyzer-helpers.d.ts +37 -0
- package/dist/phases/technical-design/analyzer-helpers.js +144 -0
- package/dist/phases/technical-design/analyzer.d.ts +3 -0
- package/dist/phases/technical-design/analyzer.js +282 -318
- package/dist/phases/technical-design-verification/index.d.ts +1 -0
- package/dist/phases/technical-design-verification/index.js +1 -0
- package/dist/phases/technical-design-verification/verifier.d.ts +36 -0
- package/dist/phases/technical-design-verification/verifier.js +147 -0
- package/dist/prompts/checklist-verification.d.ts +11 -0
- package/dist/prompts/checklist-verification.js +153 -0
- package/dist/prompts/code-implementation-improvement.d.ts +5 -0
- package/dist/prompts/code-implementation-improvement.js +108 -0
- package/dist/prompts/code-implementation-verification.d.ts +3 -0
- package/dist/prompts/code-implementation-verification.js +176 -0
- package/dist/prompts/feature-analysis-improvement.d.ts +8 -0
- package/dist/prompts/feature-analysis-improvement.js +109 -0
- package/dist/prompts/feature-analysis.js +1 -1
- package/dist/prompts/technical-design-improvement.d.ts +5 -0
- package/dist/prompts/technical-design-improvement.js +93 -0
- package/dist/prompts/technical-design-verification.d.ts +11 -0
- package/dist/prompts/technical-design-verification.js +134 -0
- package/dist/prompts/technical-design.js +1 -1
- package/dist/services/audit-logs.d.ts +60 -0
- package/dist/services/audit-logs.js +115 -0
- package/dist/services/checklist.d.ts +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/workflow-runner/executors/phase-executor.js +56 -12
- package/package.json +1 -1
- package/dist/api/features.d.ts +0 -100
- package/dist/api/features.js +0 -219
- package/dist/logger.d.ts +0 -19
- package/dist/logger.js +0 -52
- package/dist/types.d.ts +0 -99
- package/dist/types.js +0 -1
- package/dist/utils/image-processor.d.ts +0 -5
- package/dist/utils/image-processor.js +0 -55
- package/dist/workflow-runner/config/stage-configs.d.ts +0 -5
- package/dist/workflow-runner/config/stage-configs.js +0 -34
- package/dist/workflow-runner/core/feature-filter.test.d.ts +0 -4
- package/dist/workflow-runner/core/feature-filter.test.js +0 -127
- package/dist/workflow-runner/executors/stage-executor.d.ts +0 -8
- package/dist/workflow-runner/executors/stage-executor.js +0 -49
- package/dist/workflow-runner/feature-fetcher.d.ts +0 -41
- package/dist/workflow-runner/feature-fetcher.js +0 -121
- package/dist/workflow-runner/feature-service.d.ts +0 -17
- package/dist/workflow-runner/feature-service.js +0 -60
- package/dist/workflow-runner/pipeline.d.ts +0 -18
- package/dist/workflow-runner/pipeline.js +0 -197
- package/dist/workflow-runner/processor.d.ts +0 -40
- package/dist/workflow-runner/processor.js +0 -191
- package/dist/workflow-runner/status-updater.d.ts +0 -27
- package/dist/workflow-runner/status-updater.js +0 -80
- package/dist/workflow-runner/types.d.ts +0 -48
- package/dist/workflow-runner/types.js +0 -4
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { query } from '@anthropic-ai/claude-code';
|
|
2
|
+
import { logInfo, logError } from '../../utils/logger.js';
|
|
3
|
+
import { createCodeImplementationVerificationSystemPrompt, createCodeImplementationVerificationPrompt, } from '../../prompts/code-implementation-verification.js';
|
|
4
|
+
function userMessage(content) {
|
|
5
|
+
return {
|
|
6
|
+
type: 'user',
|
|
7
|
+
message: { role: 'user', content: content },
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
async function* prompt(verificationPrompt) {
|
|
11
|
+
yield userMessage(verificationPrompt);
|
|
12
|
+
await new Promise((res) => setTimeout(res, 10000));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Verify code implementation against checklist requirements by reviewing git diff
|
|
16
|
+
*/
|
|
17
|
+
export async function verifyCodeImplementationCompliance(options, config) {
|
|
18
|
+
const { featureId, branchName, baseBranch, featureName, featureDescription, checklistContext, verbose, } = options;
|
|
19
|
+
if (verbose) {
|
|
20
|
+
logInfo(`\n🔍 Starting code implementation verification for feature: ${featureName}`);
|
|
21
|
+
logInfo(` Branch: ${branchName}`);
|
|
22
|
+
logInfo(` Base: ${baseBranch}`);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const systemPrompt = createCodeImplementationVerificationSystemPrompt(config);
|
|
26
|
+
const verificationPrompt = createCodeImplementationVerificationPrompt(featureId, branchName, baseBranch, featureName, featureDescription || '', checklistContext);
|
|
27
|
+
let lastAssistantResponse = '';
|
|
28
|
+
let verificationResult = null;
|
|
29
|
+
if (verbose) {
|
|
30
|
+
logInfo('🤖 Starting verification agent query...');
|
|
31
|
+
}
|
|
32
|
+
// Use Claude Code SDK for verification
|
|
33
|
+
for await (const message of query({
|
|
34
|
+
prompt: prompt(verificationPrompt),
|
|
35
|
+
options: {
|
|
36
|
+
appendSystemPrompt: systemPrompt,
|
|
37
|
+
model: config.claude.model || 'sonnet',
|
|
38
|
+
maxTurns: 1000,
|
|
39
|
+
permissionMode: 'bypassPermissions',
|
|
40
|
+
},
|
|
41
|
+
})) {
|
|
42
|
+
if (verbose) {
|
|
43
|
+
logInfo(` Received message type: ${message.type}`);
|
|
44
|
+
}
|
|
45
|
+
// Stream verification process
|
|
46
|
+
if (message.type === 'assistant' && message.message?.content) {
|
|
47
|
+
for (const content of message.message.content) {
|
|
48
|
+
if (content.type === 'text') {
|
|
49
|
+
lastAssistantResponse += content.text + '\n';
|
|
50
|
+
if (verbose) {
|
|
51
|
+
console.log(`\n🔍 ${content.text}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (content.type === 'tool_use') {
|
|
55
|
+
if (verbose) {
|
|
56
|
+
console.log(`\n🔧 ${content.name}: ${content.input.description || 'Running...'}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (message.type === 'result') {
|
|
62
|
+
if (message.subtype === 'success') {
|
|
63
|
+
if (verbose) {
|
|
64
|
+
logInfo('\n✅ Code verification completed, parsing results...');
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const responseText = message.result || lastAssistantResponse;
|
|
68
|
+
let jsonResult = null;
|
|
69
|
+
// Try to extract JSON from markdown code block
|
|
70
|
+
const jsonBlockMatch = responseText.match(/```json\s*\n([\s\S]*?)\n\s*```/);
|
|
71
|
+
if (jsonBlockMatch) {
|
|
72
|
+
jsonResult = JSON.parse(jsonBlockMatch[1]);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Try to find JSON object containing "verification_result"
|
|
76
|
+
let jsonStartIndex = -1;
|
|
77
|
+
if (responseText.includes('"verification_result"')) {
|
|
78
|
+
const targetIndex = responseText.indexOf('"verification_result"');
|
|
79
|
+
// Work backwards to find opening brace
|
|
80
|
+
for (let i = targetIndex; i >= 0; i--) {
|
|
81
|
+
if (responseText[i] === '{') {
|
|
82
|
+
jsonStartIndex = i;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (jsonStartIndex !== -1) {
|
|
88
|
+
// Find matching closing brace
|
|
89
|
+
let braceCount = 0;
|
|
90
|
+
let endIndex = jsonStartIndex;
|
|
91
|
+
let inString = false;
|
|
92
|
+
let escapeNext = false;
|
|
93
|
+
for (let i = jsonStartIndex; i < responseText.length; i++) {
|
|
94
|
+
const char = responseText[i];
|
|
95
|
+
if (escapeNext) {
|
|
96
|
+
escapeNext = false;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (char === '\\' && inString) {
|
|
100
|
+
escapeNext = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (char === '"') {
|
|
104
|
+
inString = !inString;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!inString) {
|
|
108
|
+
if (char === '{') {
|
|
109
|
+
braceCount++;
|
|
110
|
+
}
|
|
111
|
+
else if (char === '}') {
|
|
112
|
+
braceCount--;
|
|
113
|
+
if (braceCount === 0) {
|
|
114
|
+
endIndex = i;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const jsonStr = responseText.substring(jsonStartIndex, endIndex + 1);
|
|
121
|
+
try {
|
|
122
|
+
jsonResult = JSON.parse(jsonStr);
|
|
123
|
+
}
|
|
124
|
+
catch (parseError) {
|
|
125
|
+
logError(`Failed to parse extracted JSON: ${parseError}`);
|
|
126
|
+
jsonResult = JSON.parse(responseText);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
jsonResult = JSON.parse(responseText);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (jsonResult && jsonResult.verification_result) {
|
|
134
|
+
verificationResult = jsonResult.verification_result;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
throw new Error('Invalid JSON structure');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
logError(`Failed to parse verification result: ${error}`);
|
|
142
|
+
// Return a failed verification result
|
|
143
|
+
verificationResult = {
|
|
144
|
+
overall_status: 'failed',
|
|
145
|
+
summary: 'Verification failed due to parse error',
|
|
146
|
+
confirmed_count: 0,
|
|
147
|
+
rejected_count: 1,
|
|
148
|
+
uncertain_count: 0,
|
|
149
|
+
item_verifications: [],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
logError(`\n⚠️ Verification incomplete: ${message.subtype}`);
|
|
155
|
+
verificationResult = {
|
|
156
|
+
overall_status: 'failed',
|
|
157
|
+
summary: 'Verification incomplete',
|
|
158
|
+
confirmed_count: 0,
|
|
159
|
+
rejected_count: 1,
|
|
160
|
+
uncertain_count: 0,
|
|
161
|
+
item_verifications: [],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (!verificationResult) {
|
|
167
|
+
return {
|
|
168
|
+
overall_status: 'failed',
|
|
169
|
+
summary: 'No verification result received',
|
|
170
|
+
confirmed_count: 0,
|
|
171
|
+
rejected_count: 1,
|
|
172
|
+
uncertain_count: 0,
|
|
173
|
+
item_verifications: [],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (verbose) {
|
|
177
|
+
logInfo('\n📊 Verification Results:');
|
|
178
|
+
logInfo(` Status: ${verificationResult.overall_status}`);
|
|
179
|
+
logInfo(` ✅ Confirmed: ${verificationResult.confirmed_count}`);
|
|
180
|
+
logInfo(` ❌ Rejected: ${verificationResult.rejected_count}`);
|
|
181
|
+
logInfo(` ⚠️ Uncertain: ${verificationResult.uncertain_count}`);
|
|
182
|
+
}
|
|
183
|
+
return verificationResult;
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
logError(`Code verification failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
187
|
+
return {
|
|
188
|
+
overall_status: 'failed',
|
|
189
|
+
summary: `Verification error: ${error instanceof Error ? error.message : String(error)}`,
|
|
190
|
+
confirmed_count: 0,
|
|
191
|
+
rejected_count: 1,
|
|
192
|
+
uncertain_count: 0,
|
|
193
|
+
item_verifications: [],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for feature analysis
|
|
3
|
+
* Extracted from analyzer.ts to improve modularity and testability
|
|
4
|
+
*/
|
|
5
|
+
import { EdsgerConfig, FeatureAnalysisResult } from '../../types/index.js';
|
|
6
|
+
import { FeatureAnalysisContext } from './context-fetcher.js';
|
|
7
|
+
import { ChecklistPhaseContext } from '../../services/checklist.js';
|
|
8
|
+
import { ChecklistVerificationResult } from '../feature-analysis-verification/index.js';
|
|
9
|
+
interface ParsedAnalysisResult {
|
|
10
|
+
analysis?: any;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse JSON result from Claude Code response
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseAnalysisResult(responseText: string): ParsedAnalysisResult;
|
|
17
|
+
/**
|
|
18
|
+
* Execute a single analysis query
|
|
19
|
+
*/
|
|
20
|
+
export declare function executeAnalysisQuery(currentPrompt: string, systemPrompt: string, config: EdsgerConfig, verbose?: boolean): Promise<any | null>;
|
|
21
|
+
interface VerificationCycleResult {
|
|
22
|
+
passed: boolean;
|
|
23
|
+
verificationResult: ChecklistVerificationResult | null;
|
|
24
|
+
nextPrompt?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Perform verification and determine if iteration should continue
|
|
28
|
+
* This function only verifies - it does NOT manage artifacts (save/delete/update)
|
|
29
|
+
*/
|
|
30
|
+
export declare function performVerificationCycle(structuredAnalysisResult: any, checklistContext: ChecklistPhaseContext | null, context: FeatureAnalysisContext, config: EdsgerConfig, currentIteration: number, maxIterations: number, mcpServerUrl: string, mcpToken: string, featureId: string, verbose?: boolean): Promise<VerificationCycleResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Save analysis artifacts as draft and return their IDs
|
|
33
|
+
*/
|
|
34
|
+
export declare function saveAnalysisArtifactsAsDraft(mcpServerUrl: string, mcpToken: string, featureId: string, created_user_stories: any[], created_test_cases: any[], verbose?: boolean): Promise<{
|
|
35
|
+
userStoryIds: string[];
|
|
36
|
+
testCaseIds: string[];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Update artifacts to ready status after successful verification
|
|
40
|
+
*/
|
|
41
|
+
export declare function updateArtifactsToReady(mcpServerUrl: string, mcpToken: string, userStoryIds: string[], testCaseIds: string[], verbose?: boolean): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete artifacts after verification failure
|
|
44
|
+
*/
|
|
45
|
+
export declare function deleteArtifacts(mcpServerUrl: string, mcpToken: string, userStoryIds: string[], testCaseIds: string[], verbose?: boolean): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Save analysis artifacts (user stories and test cases) - Legacy function for non-verification flows
|
|
48
|
+
*/
|
|
49
|
+
export declare function saveAnalysisArtifacts(mcpServerUrl: string, mcpToken: string, featureId: string, created_user_stories: any[], created_test_cases: any[], status: string, verbose?: boolean): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Build the final analysis result object
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildAnalysisResult(featureId: string, context: FeatureAnalysisContext, structuredAnalysisResult: any, currentIteration: number): FeatureAnalysisResult;
|
|
54
|
+
/**
|
|
55
|
+
* Build error result when verification fails after all iterations
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildVerificationFailureResult(featureId: string, context: FeatureAnalysisContext, verificationResult: ChecklistVerificationResult, checklist_results: any, checklist_item_results: any, currentIteration: number): FeatureAnalysisResult;
|
|
58
|
+
/**
|
|
59
|
+
* Build error result when no analysis results are received
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildNoResultsError(featureId: string, context: FeatureAnalysisContext): FeatureAnalysisResult;
|
|
62
|
+
export {};
|