edsger 0.1.5 → 0.2.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.
Files changed (61) hide show
  1. package/README.md +124 -86
  2. package/dist/bug-fixing/analyzer.d.ts +19 -0
  3. package/dist/bug-fixing/analyzer.js +280 -0
  4. package/dist/bug-fixing/context-fetcher.d.ts +40 -0
  5. package/dist/bug-fixing/context-fetcher.js +154 -0
  6. package/dist/bug-fixing/index.d.ts +7 -0
  7. package/dist/bug-fixing/index.js +7 -0
  8. package/dist/bug-fixing/mcp-server.d.ts +1 -0
  9. package/dist/bug-fixing/mcp-server.js +104 -0
  10. package/dist/cli.js +474 -5
  11. package/dist/code-implementation/analyzer.d.ts +19 -0
  12. package/dist/code-implementation/analyzer.js +344 -0
  13. package/dist/code-implementation/context-fetcher.d.ts +38 -0
  14. package/dist/code-implementation/context-fetcher.js +147 -0
  15. package/dist/code-implementation/mcp-server.d.ts +1 -0
  16. package/dist/code-implementation/mcp-server.js +118 -0
  17. package/dist/code-review/reviewer.js +25 -17
  18. package/dist/feature-analysis/analyzer.d.ts +9 -0
  19. package/dist/feature-analysis/analyzer.js +369 -0
  20. package/dist/feature-analysis/context-fetcher.d.ts +54 -0
  21. package/dist/feature-analysis/context-fetcher.js +193 -0
  22. package/dist/feature-analysis/http-fallback.d.ts +20 -0
  23. package/dist/feature-analysis/http-fallback.js +95 -0
  24. package/dist/feature-analysis/index.d.ts +4 -0
  25. package/dist/feature-analysis/index.js +4 -0
  26. package/dist/feature-analysis/mcp-server.d.ts +1 -0
  27. package/dist/feature-analysis/mcp-server.js +161 -0
  28. package/dist/functional-testing/analyzer.d.ts +34 -0
  29. package/dist/functional-testing/analyzer.js +341 -0
  30. package/dist/functional-testing/context-fetcher.d.ts +47 -0
  31. package/dist/functional-testing/context-fetcher.js +192 -0
  32. package/dist/functional-testing/http-fallback.d.ts +12 -0
  33. package/dist/functional-testing/http-fallback.js +133 -0
  34. package/dist/functional-testing/index.d.ts +4 -0
  35. package/dist/functional-testing/index.js +4 -0
  36. package/dist/functional-testing/mcp-server.d.ts +1 -0
  37. package/dist/functional-testing/mcp-server.js +157 -0
  38. package/dist/functional-testing/test-report-creator.d.ts +46 -0
  39. package/dist/functional-testing/test-report-creator.js +213 -0
  40. package/dist/pull-request/creator.d.ts +34 -0
  41. package/dist/pull-request/creator.js +225 -0
  42. package/dist/technical-design/analyzer.d.ts +16 -0
  43. package/dist/technical-design/analyzer.js +338 -0
  44. package/dist/technical-design/context-fetcher.d.ts +42 -0
  45. package/dist/technical-design/context-fetcher.js +170 -0
  46. package/dist/technical-design/http-fallback.d.ts +19 -0
  47. package/dist/technical-design/http-fallback.js +147 -0
  48. package/dist/technical-design/mcp-server.d.ts +1 -0
  49. package/dist/technical-design/mcp-server.js +178 -0
  50. package/dist/types.d.ts +69 -0
  51. package/dist/workflow-runner/feature-fetcher.d.ts +41 -0
  52. package/dist/workflow-runner/feature-fetcher.js +121 -0
  53. package/dist/workflow-runner/index.d.ts +3 -0
  54. package/dist/workflow-runner/index.js +3 -0
  55. package/dist/workflow-runner/pipeline-runner.d.ts +25 -0
  56. package/dist/workflow-runner/pipeline-runner.js +273 -0
  57. package/dist/workflow-runner/status-updater.d.ts +27 -0
  58. package/dist/workflow-runner/status-updater.js +80 -0
  59. package/dist/workflow-runner/workflow-processor.d.ts +71 -0
  60. package/dist/workflow-runner/workflow-processor.js +232 -0
  61. package/package.json +17 -6
package/README.md CHANGED
@@ -1,144 +1,182 @@
1
- # Edsger - AI-Powered Code Review CLI
1
+ # Edsger
2
2
 
3
- An AI-powered code review tool that uses Claude Code to review your uncommitted changes. Perfect for pre-commit hooks and automated code quality checks.
3
+ AI-powered software development CLI tool with comprehensive feature management, code review, and testing capabilities using Claude Code SDK and MCP integration.
4
4
 
5
5
  ## Features
6
6
 
7
- - 🤖 **AI-Powered Reviews**: Uses Claude Code for intelligent code analysis
8
- - 🔗 **Git Integration**: Reviews uncommitted or staged changes automatically
9
- - ⚙️ **Configurable**: Customize patterns, exclusions, and review severity
10
- - 🚀 **Hook-Friendly**: Designed for husky pre-commit hooks and CI/CD
11
- - 📊 **Detailed Output**: Clear feedback with blocking/warning/passing results
7
+ ### 🔍 Code Review
12
8
 
13
- ## Installation
9
+ - **AI-Powered Reviews**: Uses Claude Code SDK for intelligent code analysis
10
+ - **Git Integration**: Reviews uncommitted or staged changes automatically
11
+ - **Configurable**: Customize patterns, exclusions, and review severity
12
+ - **Hook-Friendly**: Designed for pre-commit hooks and CI/CD automation
13
+ - **Detailed Output**: Clear feedback with blocking/warning/passing results
14
14
 
15
- First, install Claude Code CLI globally:
15
+ ### 🎯 Feature Analysis
16
16
 
17
- ```bash
18
- npm install -g @anthropic-ai/claude-code
19
- ```
17
+ - **MCP Integration**: Analyze features using Model Context Protocol
18
+ - **User Story Generation**: Create comprehensive user stories for features
19
+ - **Test Case Creation**: Generate detailed test cases with criticality levels
20
+ - **Deduplication**: Avoid creating similar existing user stories and test cases
21
+ - **Real-time Streaming**: Live analysis feedback with Claude Code SDK
22
+
23
+ ### 🎨 Technical Design
24
+
25
+ - **Design Generation**: Create technical specifications for features
26
+ - **Architecture Planning**: Generate implementation roadmaps and technical details
27
+ - **Integration Support**: Works with MCP for structured design output
28
+
29
+ ### 💻 Code Implementation
30
+
31
+ - **Feature Implementation**: Automatically implement features based on specifications
32
+ - **Branch Management**: Creates feature branches and manages git workflow
33
+ - **Code Generation**: AI-powered code writing with proper git integration
34
+
35
+ ### 🎭 Functional Testing
36
+
37
+ - **Automated Testing**: Run Playwright-based functional tests for features
38
+ - **Test Execution**: Execute test cases with detailed reporting
39
+ - **Status Tracking**: Monitor test results with pass/fail statistics
20
40
 
21
- Then install Edsger:
41
+ ### 🚀 Workflow Management
42
+
43
+ - **Continuous Processing**: Monitor and process features ready for development
44
+ - **End-to-End Automation**: Complete feature lifecycle from analysis to testing
45
+ - **Real-time Monitoring**: Live workflow processing with statistics and graceful shutdown
46
+
47
+ ## Installation
22
48
 
23
49
  ```bash
24
- npm install -g edsger
50
+ npm install edsger
25
51
  ```
26
52
 
27
- ## Quick Start
53
+ ## Usage
54
+
55
+ ### Code Review
28
56
 
29
57
  ```bash
30
58
  # Review all uncommitted changes
31
59
  edsger --review
32
60
 
33
- # Review only staged changes
61
+ # Review only staged changes
34
62
  edsger --review --staged
35
63
 
36
- # Review specific files
37
- edsger --review --files "src/**/*.js"
64
+ # Review specific file patterns
65
+ edsger --review --files "**/*.ts" "**/*.js"
38
66
 
39
67
  # Verbose output
40
68
  edsger --review --verbose
41
69
  ```
42
70
 
43
- ## Configuration
71
+ ### Feature Analysis
44
72
 
45
- Create `.edsgerrc` in your project root or add an `edsger` section to `package.json`:
73
+ ```bash
74
+ # Analyze a feature and generate user stories/test cases
75
+ edsger --feature-analysis <feature-id>
46
76
 
47
- ```json
48
- {
49
- "patterns": ["src/**/*.js", "src/**/*.ts"],
50
- "exclude": ["**/*.test.js", "**/*.spec.js"],
51
- "severity": "error",
52
- "maxFiles": 50,
53
- "claude": {
54
- "model": "sonnet",
55
- "timeout": 120000
56
- }
57
- }
77
+ # Verbose analysis output
78
+ edsger --feature-analysis <feature-id> --verbose
58
79
  ```
59
80
 
60
- ### Configuration Options
81
+ ### Technical Design
61
82
 
62
- - **patterns**: File patterns to include (default: common code files)
63
- - **exclude**: File patterns to exclude (default: tests, builds, node_modules)
64
- - **severity**: `"error"` (exit 1 on issues) or `"warning"` (exit 0 always)
65
- - **maxFiles**: Maximum files to review in one run
66
- - **claude.model**: Claude model to use (`sonnet`, `opus`, etc.)
67
- - **claude.timeout**: Timeout in milliseconds
68
-
69
- ## Integration with Husky
70
-
71
- Add to your `package.json`:
83
+ ```bash
84
+ # Generate technical design for a feature
85
+ edsger --technical-design <feature-id>
72
86
 
73
- ```json
74
- {
75
- "scripts": {
76
- "review": "edsger --review"
77
- }
78
- }
87
+ # Verbose design output
88
+ edsger --technical-design <feature-id> --verbose
79
89
  ```
80
90
 
81
- Setup husky hook:
91
+ ### Code Implementation
82
92
 
83
93
  ```bash
84
- npx husky add .husky/pre-commit "npm run review"
94
+ # Implement feature code based on specifications
95
+ edsger --implement <feature-id>
96
+
97
+ # Verbose implementation output
98
+ edsger --implement <feature-id> --verbose
85
99
  ```
86
100
 
87
- ## Exit Codes
101
+ ### Functional Testing
88
102
 
89
- - **0**: Review passed or warnings only
90
- - **1**: Review failed with blocking issues
91
- - **1**: Configuration or runtime errors
103
+ ```bash
104
+ # Run functional tests for a feature
105
+ edsger --test <feature-id>
92
106
 
93
- ## Examples
107
+ # Verbose test output
108
+ edsger --test <feature-id> --verbose
109
+ ```
110
+
111
+ ### Workflow Management
94
112
 
95
- ### Basic Usage
96
113
  ```bash
97
- edsger --review
98
- ```
114
+ # Run continuous workflow processor
115
+ edsger --workflow
99
116
 
100
- ### Review Only Staged Files
101
- ```bash
102
- edsger --review --staged
117
+ # Run with verbose logging
118
+ edsger --workflow --verbose
103
119
  ```
104
120
 
105
- ### Review Specific Patterns
121
+ ### Default Behavior
122
+
106
123
  ```bash
107
- edsger --review --files "src/**/*.js" "lib/**/*.ts"
124
+ # Auto-detects mode based on environment:
125
+ # - If EDSGER_PRODUCT_ID and EDSGER_MCP_TOKEN are set: workflow mode
126
+ # - Otherwise: code review mode
127
+ edsger
108
128
  ```
109
129
 
110
- ### Custom Configuration
111
- ```bash
112
- edsger --review --config ./my-config.json --verbose
130
+ ## Configuration
131
+
132
+ Create a configuration file (`.edsgerrc.json`, `edsger.config.js`, etc.):
133
+
134
+ ```json
135
+ {
136
+ "patterns": ["**/*.js", "**/*.ts"],
137
+ "exclude": ["node_modules/**", "*.test.js"],
138
+ "severity": "error",
139
+ "maxFiles": 100,
140
+ "claude": {
141
+ "model": "sonnet",
142
+ "timeout": 120000
143
+ }
144
+ }
113
145
  ```
114
146
 
115
- ## Requirements
147
+ ## Environment Variables
116
148
 
117
- - Claude Code CLI installed and authenticated
118
- - Active Claude subscription or API access
149
+ ### Required for Advanced Features (Feature Analysis, Technical Design, Implementation, Testing, Workflow)
119
150
 
120
- ## How It Works
151
+ - `EDSGER_MCP_SERVER_URL`: MCP server URL for feature operations
152
+ - `EDSGER_MCP_TOKEN`: Required authentication token for MCP server
153
+ - `EDSGER_PRODUCT_ID`: Product ID for workflow management (optional for workflow mode)
121
154
 
122
- 1. **Git Analysis**: Detects uncommitted or staged file changes
123
- 2. **File Filtering**: Applies include/exclude patterns from configuration
124
- 3. **AI Review**: Sends files to Claude Code for intelligent analysis
125
- 4. **Result Processing**: Categorizes feedback as OK/WARN/BLOCK
126
- 5. **Exit Handling**: Returns appropriate exit codes for automation
155
+ ### Configuration Options
127
156
 
128
- ## Troubleshooting
157
+ - **patterns**: File patterns to include (default: common code files)
158
+ - **exclude**: File patterns to exclude (default: tests, builds, node_modules)
159
+ - **severity**: `"error"` (exit 1 on issues) or `"warning"` (exit 0 always)
160
+ - **maxFiles**: Maximum files to review in one run
161
+ - **claude.model**: Claude model to use (`sonnet`, `opus`, etc.)
162
+ - **claude.timeout**: Timeout in milliseconds
163
+
164
+ ## Git Hooks Integration
129
165
 
130
- **"Claude Code CLI not found"**
131
- - Install: `npm install -g @anthropic-ai/claude-code`
132
- - Verify: `claude --version`
166
+ Add to your `.git/hooks/pre-commit`:
133
167
 
134
- **"Not in a git repository"**
135
- - Run from within a git repository
136
- - Initialize with `git init` if needed
168
+ ```bash
169
+ #!/bin/sh
170
+ npx edsger --review --staged
171
+ ```
172
+
173
+ ## Requirements
137
174
 
138
- **"No files to review"**
139
- - Check if you have uncommitted changes: `git status`
140
- - Verify your file patterns include the changed files
175
+ - Node.js >= 18.0.0
176
+ - `@anthropic-ai/claude-code` SDK
177
+ - MCP server for advanced feature operations (analysis, design, implementation, testing)
178
+ - Playwright for functional testing (when using `--test` flag)
141
179
 
142
180
  ## License
143
181
 
144
- ISC
182
+ ISC
@@ -0,0 +1,19 @@
1
+ import { EdsgerConfig } from '../types.js';
2
+ export interface BugFixingOptions {
3
+ featureId: string;
4
+ mcpServerUrl: string;
5
+ mcpToken: string;
6
+ testErrors: string;
7
+ attemptNumber?: number;
8
+ verbose?: boolean;
9
+ }
10
+ export interface BugFixingResult {
11
+ featureId: string;
12
+ fixSummary: string | null;
13
+ status: 'success' | 'error';
14
+ message: string;
15
+ filesFixed?: string[];
16
+ attemptNumber?: number;
17
+ }
18
+ export declare const fixTestFailures: (options: BugFixingOptions, config: EdsgerConfig) => Promise<BugFixingResult>;
19
+ export declare function checkBugFixingRequirements(): Promise<boolean>;
@@ -0,0 +1,280 @@
1
+ import { query } from '@anthropic-ai/claude-code';
2
+ import { logInfo, logError } from '../logger.js';
3
+ import { fetchBugFixingContext, formatContextForPrompt, } from './context-fetcher.js';
4
+ function userMessage(content) {
5
+ return {
6
+ type: 'user',
7
+ message: { role: 'user', content: content },
8
+ };
9
+ }
10
+ async function* prompt(bugFixPrompt) {
11
+ yield userMessage(bugFixPrompt);
12
+ await new Promise((res) => setTimeout(res, 10000));
13
+ }
14
+ export const fixTestFailures = async (options, config) => {
15
+ const { featureId, mcpServerUrl, mcpToken, testErrors, attemptNumber = 1, verbose, } = options;
16
+ if (verbose) {
17
+ logInfo(`Starting bug fixing for feature ID: ${featureId} (Attempt ${attemptNumber})`);
18
+ logInfo(`Using MCP server: ${mcpServerUrl}`);
19
+ }
20
+ try {
21
+ // Fetch all required context information via MCP endpoints
22
+ if (verbose) {
23
+ logInfo('Fetching bug fixing context via MCP endpoints...');
24
+ }
25
+ const context = await fetchBugFixingContext(mcpServerUrl, mcpToken, featureId, verbose);
26
+ const systemPrompt = createSystemPrompt(config);
27
+ const bugFixPrompt = createBugFixPromptWithContext(featureId, testErrors, attemptNumber, context);
28
+ let lastAssistantResponse = '';
29
+ let structuredFixResult = null;
30
+ if (verbose) {
31
+ logInfo('Starting Claude Code query with pre-fetched information...');
32
+ }
33
+ // Use Claude Code SDK without MCP servers - all info is pre-fetched
34
+ for await (const message of query({
35
+ prompt: prompt(bugFixPrompt),
36
+ options: {
37
+ appendSystemPrompt: systemPrompt,
38
+ model: config.claude.model || 'sonnet',
39
+ maxTurns: 2000,
40
+ permissionMode: 'bypassPermissions',
41
+ },
42
+ })) {
43
+ if (verbose) {
44
+ logInfo(`Received message type: ${message.type}`);
45
+ }
46
+ // Stream the bug fixing process
47
+ if (message.type === 'assistant' && message.message?.content) {
48
+ for (const content of message.message.content) {
49
+ if (content.type === 'text') {
50
+ lastAssistantResponse += content.text + '\n';
51
+ if (verbose) {
52
+ console.log(`\n🔧 ${content.text}`);
53
+ }
54
+ }
55
+ else if (content.type === 'tool_use') {
56
+ if (verbose) {
57
+ console.log(`\n🛠️ ${content.name}: ${content.input.description || 'Running...'}`);
58
+ }
59
+ }
60
+ }
61
+ }
62
+ else if (message.type === 'result') {
63
+ if (message.subtype === 'success') {
64
+ logInfo('\n🛠️ Bug fixing completed, parsing results...');
65
+ try {
66
+ // Try to extract JSON from markdown code block or parse directly
67
+ const responseText = message.result || lastAssistantResponse;
68
+ let jsonResult = null;
69
+ // First 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 parse the entire response as JSON
76
+ jsonResult = JSON.parse(responseText);
77
+ }
78
+ if (jsonResult && jsonResult.fix_result) {
79
+ structuredFixResult = jsonResult.fix_result;
80
+ }
81
+ else {
82
+ throw new Error('Invalid JSON structure');
83
+ }
84
+ }
85
+ catch (error) {
86
+ logError(`Failed to parse structured fix result: ${error}`);
87
+ // Fallback parsing
88
+ structuredFixResult = parseBugFixResponse(message.result || lastAssistantResponse);
89
+ }
90
+ }
91
+ else {
92
+ logError(`\n⚠️ Bug fixing incomplete: ${message.subtype}`);
93
+ if (message.subtype === 'error_max_turns') {
94
+ logError('💡 Try simplifying the fixes or reducing scope');
95
+ }
96
+ // Try to parse results from the last assistant response
97
+ if (lastAssistantResponse) {
98
+ try {
99
+ const responseText = lastAssistantResponse;
100
+ let jsonResult = null;
101
+ const jsonBlockMatch = responseText.match(/```json\s*\n([\s\S]*?)\n\s*```/);
102
+ if (jsonBlockMatch) {
103
+ jsonResult = JSON.parse(jsonBlockMatch[1]);
104
+ if (jsonResult && jsonResult.fix_result) {
105
+ structuredFixResult = jsonResult.fix_result;
106
+ }
107
+ }
108
+ else {
109
+ structuredFixResult = parseBugFixResponse(lastAssistantResponse);
110
+ }
111
+ }
112
+ catch (error) {
113
+ logError(`Failed to parse assistant response: ${error}`);
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ if (structuredFixResult) {
120
+ const { summary, files_modified } = structuredFixResult;
121
+ if (verbose) {
122
+ logInfo(`Bug fixing completed for feature: ${featureId}`);
123
+ if (files_modified?.length > 0) {
124
+ logInfo(`Files fixed: ${files_modified.join(', ')}`);
125
+ }
126
+ }
127
+ return {
128
+ featureId,
129
+ fixSummary: summary || 'Bug fixes applied',
130
+ status: 'success',
131
+ message: 'Bug fixes applied successfully',
132
+ filesFixed: files_modified || [],
133
+ attemptNumber,
134
+ };
135
+ }
136
+ else {
137
+ return {
138
+ featureId,
139
+ fixSummary: null,
140
+ status: 'error',
141
+ message: 'Bug fixing failed or incomplete',
142
+ attemptNumber,
143
+ };
144
+ }
145
+ }
146
+ catch (error) {
147
+ const errorMessage = error instanceof Error ? error.message : String(error);
148
+ logError(`Bug fixing failed: ${errorMessage}`);
149
+ return {
150
+ featureId,
151
+ fixSummary: null,
152
+ status: 'error',
153
+ message: `Bug fixing failed: ${errorMessage}`,
154
+ attemptNumber,
155
+ };
156
+ }
157
+ };
158
+ function createSystemPrompt(_config) {
159
+ return `You are an expert software engineer specializing in fixing bugs and test failures. Your goal is to analyze test failures and fix the underlying issues in the code.
160
+
161
+ **Your Role**: Fix bugs and test failures while maintaining existing functionality and code quality.
162
+
163
+ **Available Tools**:
164
+ - Bash: Run commands, tests, and git operations
165
+ - Glob: Find files and understand project structure
166
+ - Read: Examine existing code and files
167
+ - Edit: Modify existing files to fix issues
168
+ - Write: Create new files if absolutely necessary
169
+ - TodoWrite: Track bug fixing tasks (use proactively)
170
+
171
+ **Bug Fixing Process**:
172
+ 1. **Git Pull Rebase**: Ensure main branch is up to date: git pull origin main --rebase
173
+ 2. **Analyze Failures**: Study test error messages and stack traces to identify root causes
174
+ 3. **Examine Code**: Read the relevant code files to understand current implementation
175
+ 4. **Fix Issues**: Make minimal, targeted changes to resolve the failures
176
+ 5. **Test Fixes**: Run tests to verify fixes work and don't break other functionality
177
+ 6. **Validate**: Ensure all critical test cases pass
178
+
179
+ **Important Guidelines**:
180
+ - All feature context, user stories, test cases, and test reports are provided in the prompt
181
+ - Focus ONLY on fixing the reported test failures
182
+ - Do not refactor or optimize unrelated code
183
+ - Preserve existing functionality and patterns
184
+ - Make minimal necessary changes
185
+ - Test your fixes thoroughly
186
+
187
+ **CRITICAL - Result Format**:
188
+ You MUST end your response with a JSON object containing the bug fix results in this EXACT format:
189
+
190
+ \`\`\`json
191
+ {
192
+ "fix_result": {
193
+ "feature_id": "FEATURE_ID_PLACEHOLDER",
194
+ "attempt_number": 1,
195
+ "summary": "Brief description of what was fixed",
196
+ "files_modified": ["file1.ts", "file2.tsx"],
197
+ "tests_passed": true,
198
+ "fixes_applied": [
199
+ {
200
+ "issue": "Description of the issue",
201
+ "fix": "Description of how it was fixed",
202
+ "file": "path/to/file.ts"
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ \`\`\`
208
+
209
+ Focus on systematic bug fixing based on the provided context and test failure information.`;
210
+ }
211
+ function createBugFixPromptWithContext(featureId, testErrors, attemptNumber, context) {
212
+ const contextInfo = formatContextForPrompt(context, testErrors);
213
+ return `Fix the test failures for feature: ${featureId} (Attempt ${attemptNumber})
214
+
215
+ ${contextInfo}
216
+
217
+ ## Bug Fixing Instructions
218
+
219
+ Follow this systematic approach:
220
+
221
+ 1. **Analyze Test Failures**: Study the test error messages above to understand:
222
+ - What specific functionality is failing
223
+ - Error messages and stack traces
224
+ - Which user stories or test cases are not working
225
+
226
+ 2. **Examine Current Code**: Use Read and Glob tools to understand:
227
+ - Current implementation that's causing failures
228
+ - Code structure and patterns
229
+ - Related files and dependencies
230
+
231
+ 3. **Fix Issues**: Make targeted fixes to resolve the test failures:
232
+ - Focus on the specific issues causing test failures
233
+ - Maintain existing code patterns and conventions
234
+ - Make minimal necessary changes
235
+ - Don't refactor unrelated code
236
+
237
+ 4. **Test Your Fixes**: Verify that your changes work:
238
+ - Run the tests to ensure they now pass
239
+ - Check that you haven't broken other functionality
240
+ - Ensure critical test cases still work
241
+
242
+ 5. **Document Changes**: Clearly explain what was fixed and why
243
+
244
+ ## Important Notes
245
+ - This is attempt ${attemptNumber}, so be thorough and systematic
246
+ - Focus ONLY on making the failing tests pass
247
+ - Use the user stories and test cases to understand expected behavior
248
+ - Reference the technical design and test report for additional context
249
+ - Make sure critical functionality continues to work
250
+
251
+ Begin by analyzing the test failures and examining the relevant code files.`;
252
+ }
253
+ function parseBugFixResponse(response) {
254
+ // Extract summary and file information from the response as fallback
255
+ const summaryMatch = response.match(/## Fix Summary\n([\s\S]*?)(?=\n##|\n\n|$)/);
256
+ const summary = summaryMatch ? summaryMatch[1].trim() : 'Bug fixes applied';
257
+ const filesMatch = response.match(/## Files Fixed\n([\s\S]*?)(?=\n##|\n\n|$)/);
258
+ let files_modified = [];
259
+ if (filesMatch) {
260
+ files_modified = filesMatch[1]
261
+ .split('\n')
262
+ .filter((line) => line.trim().startsWith('-'))
263
+ .map((line) => line.replace(/^-\s*/, '').trim());
264
+ }
265
+ return {
266
+ summary,
267
+ files_modified,
268
+ tests_passed: true,
269
+ fixes_applied: [],
270
+ };
271
+ }
272
+ export function checkBugFixingRequirements() {
273
+ try {
274
+ require.resolve('@anthropic-ai/claude-code');
275
+ return Promise.resolve(true);
276
+ }
277
+ catch {
278
+ return Promise.resolve(false);
279
+ }
280
+ }
@@ -0,0 +1,40 @@
1
+ export interface BugFixingContext {
2
+ feature: {
3
+ id: string;
4
+ name: string;
5
+ description?: string;
6
+ technical_design?: string;
7
+ status: string;
8
+ product_id: string;
9
+ };
10
+ user_stories: Array<{
11
+ id: string;
12
+ title: string;
13
+ description: string;
14
+ status: string;
15
+ [key: string]: any;
16
+ }>;
17
+ test_cases: Array<{
18
+ id: string;
19
+ name: string;
20
+ description: string;
21
+ is_critical: boolean;
22
+ [key: string]: any;
23
+ }>;
24
+ latest_test_report?: {
25
+ id: string;
26
+ title: string;
27
+ test_results: string;
28
+ status: string;
29
+ created_at: string;
30
+ [key: string]: any;
31
+ } | null;
32
+ }
33
+ /**
34
+ * Fetch all bug fixing context information via MCP endpoints
35
+ */
36
+ export declare function fetchBugFixingContext(mcpServerUrl: string, mcpToken: string, featureId: string, verbose?: boolean): Promise<BugFixingContext>;
37
+ /**
38
+ * Format the context into a readable string for Claude Code
39
+ */
40
+ export declare function formatContextForPrompt(context: BugFixingContext, testErrors: string): string;