ai-sdlc 0.2.0-alpha.6 → 0.2.0-alpha.61
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 +65 -1057
- package/dist/agents/implementation.d.ts +36 -1
- package/dist/agents/implementation.d.ts.map +1 -1
- package/dist/agents/implementation.js +259 -30
- package/dist/agents/implementation.js.map +1 -1
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/orchestrator.d.ts +61 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +443 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/planning.d.ts +1 -1
- package/dist/agents/planning.d.ts.map +1 -1
- package/dist/agents/planning.js +55 -4
- package/dist/agents/planning.js.map +1 -1
- package/dist/agents/refinement.d.ts.map +1 -1
- package/dist/agents/refinement.js +22 -3
- package/dist/agents/refinement.js.map +1 -1
- package/dist/agents/research.d.ts +85 -1
- package/dist/agents/research.d.ts.map +1 -1
- package/dist/agents/research.js +506 -16
- package/dist/agents/research.js.map +1 -1
- package/dist/agents/review.d.ts +116 -2
- package/dist/agents/review.d.ts.map +1 -1
- package/dist/agents/review.js +847 -93
- package/dist/agents/review.js.map +1 -1
- package/dist/agents/rework.d.ts.map +1 -1
- package/dist/agents/rework.js +25 -4
- package/dist/agents/rework.js.map +1 -1
- package/dist/agents/single-task.d.ts +41 -0
- package/dist/agents/single-task.d.ts.map +1 -0
- package/dist/agents/single-task.js +357 -0
- package/dist/agents/single-task.js.map +1 -0
- package/dist/agents/state-assessor.d.ts +3 -3
- package/dist/agents/state-assessor.d.ts.map +1 -1
- package/dist/agents/state-assessor.js +6 -6
- package/dist/agents/state-assessor.js.map +1 -1
- package/dist/agents/test-pattern-detector.d.ts +49 -0
- package/dist/agents/test-pattern-detector.d.ts.map +1 -0
- package/dist/agents/test-pattern-detector.js +273 -0
- package/dist/agents/test-pattern-detector.js.map +1 -0
- package/dist/agents/verification.d.ts +11 -0
- package/dist/agents/verification.d.ts.map +1 -1
- package/dist/agents/verification.js +99 -12
- package/dist/agents/verification.js.map +1 -1
- package/dist/cli/batch-processor.d.ts +64 -0
- package/dist/cli/batch-processor.d.ts.map +1 -0
- package/dist/cli/batch-processor.js +85 -0
- package/dist/cli/batch-processor.js.map +1 -0
- package/dist/cli/batch-validator.d.ts +80 -0
- package/dist/cli/batch-validator.d.ts.map +1 -0
- package/dist/cli/batch-validator.js +121 -0
- package/dist/cli/batch-validator.js.map +1 -0
- package/dist/cli/commands/migrate.js +1 -1
- package/dist/cli/commands/migrate.js.map +1 -1
- package/dist/cli/commands.d.ts +67 -3
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +1765 -198
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/daemon.js +25 -3
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/runner.d.ts.map +1 -1
- package/dist/cli/runner.js +35 -12
- package/dist/cli/runner.js.map +1 -1
- package/dist/core/auth.d.ts +43 -0
- package/dist/core/auth.d.ts.map +1 -1
- package/dist/core/auth.js +105 -1
- package/dist/core/auth.js.map +1 -1
- package/dist/core/client.d.ts +25 -1
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +247 -7
- package/dist/core/client.js.map +1 -1
- package/dist/core/config.d.ts +32 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +146 -3
- package/dist/core/config.js.map +1 -1
- package/dist/core/conflict-detector.d.ts +108 -0
- package/dist/core/conflict-detector.d.ts.map +1 -0
- package/dist/core/conflict-detector.js +413 -0
- package/dist/core/conflict-detector.js.map +1 -0
- package/dist/core/git-utils.d.ts +28 -0
- package/dist/core/git-utils.d.ts.map +1 -0
- package/dist/core/git-utils.js +146 -0
- package/dist/core/git-utils.js.map +1 -0
- package/dist/core/index.d.ts +19 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +19 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/kanban.d.ts +1 -1
- package/dist/core/kanban.d.ts.map +1 -1
- package/dist/core/kanban.js +3 -3
- package/dist/core/kanban.js.map +1 -1
- package/dist/core/llm-utils.d.ts +103 -0
- package/dist/core/llm-utils.d.ts.map +1 -0
- package/dist/core/llm-utils.js +368 -0
- package/dist/core/llm-utils.js.map +1 -0
- package/dist/core/logger.d.ts +92 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +221 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/process-manager.d.ts +15 -0
- package/dist/core/process-manager.d.ts.map +1 -0
- package/dist/core/process-manager.js +132 -0
- package/dist/core/process-manager.js.map +1 -0
- package/dist/core/story-logger.d.ts +102 -0
- package/dist/core/story-logger.d.ts.map +1 -0
- package/dist/core/story-logger.js +265 -0
- package/dist/core/story-logger.js.map +1 -0
- package/dist/core/story.d.ts +113 -20
- package/dist/core/story.d.ts.map +1 -1
- package/dist/core/story.js +328 -40
- package/dist/core/story.js.map +1 -1
- package/dist/core/task-parser.d.ts +59 -0
- package/dist/core/task-parser.d.ts.map +1 -0
- package/dist/core/task-parser.js +235 -0
- package/dist/core/task-parser.js.map +1 -0
- package/dist/core/task-progress.d.ts +92 -0
- package/dist/core/task-progress.d.ts.map +1 -0
- package/dist/core/task-progress.js +280 -0
- package/dist/core/task-progress.js.map +1 -0
- package/dist/core/workflow-state.d.ts +45 -6
- package/dist/core/workflow-state.d.ts.map +1 -1
- package/dist/core/workflow-state.js +201 -12
- package/dist/core/workflow-state.js.map +1 -1
- package/dist/core/worktree.d.ts +186 -0
- package/dist/core/worktree.d.ts.map +1 -0
- package/dist/core/worktree.js +554 -0
- package/dist/core/worktree.js.map +1 -0
- package/dist/index.js +146 -5
- package/dist/index.js.map +1 -1
- package/dist/services/error-classifier.d.ts +119 -0
- package/dist/services/error-classifier.d.ts.map +1 -0
- package/dist/services/error-classifier.js +182 -0
- package/dist/services/error-classifier.js.map +1 -0
- package/dist/types/index.d.ts +381 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +5 -2
- package/templates/story.md +5 -0
package/dist/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import {
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import { init, status, add, run, details, unblock, migrate, listWorktrees, addWorktree, removeWorktree } from './cli/commands.js';
|
|
4
5
|
import { hasApiKey } from './core/auth.js';
|
|
5
|
-
import { loadConfig, saveConfig } from './core/config.js';
|
|
6
|
+
import { loadConfig, saveConfig, DEFAULT_LOGGING_CONFIG, getSdlcRoot } from './core/config.js';
|
|
6
7
|
import { getThemedChalk } from './core/theme.js';
|
|
8
|
+
import { initLogger, getLogger } from './core/logger.js';
|
|
9
|
+
import { getLatestLogPath, readLastLines, tailLog } from './core/story-logger.js';
|
|
10
|
+
import { setupGlobalCleanupHandlers } from './core/process-manager.js';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
setupGlobalCleanupHandlers();
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const packageJson = require('../package.json');
|
|
7
16
|
// Check for API key when running commands that need it
|
|
8
17
|
function checkApiKey() {
|
|
9
18
|
if (!hasApiKey()) {
|
|
@@ -24,7 +33,7 @@ const program = new Command();
|
|
|
24
33
|
program
|
|
25
34
|
.name('ai-sdlc')
|
|
26
35
|
.description('Agent-first SDLC workflow manager')
|
|
27
|
-
.version(
|
|
36
|
+
.version(packageJson.version);
|
|
28
37
|
program
|
|
29
38
|
.command('init')
|
|
30
39
|
.description('Initialize .ai-sdlc folder structure')
|
|
@@ -35,9 +44,10 @@ program
|
|
|
35
44
|
.option('--active', 'Hide done stories from output')
|
|
36
45
|
.action((options) => status(options));
|
|
37
46
|
program
|
|
38
|
-
.command('add
|
|
47
|
+
.command('add [title]')
|
|
39
48
|
.description('Add a new story to the backlog')
|
|
40
|
-
.
|
|
49
|
+
.option('-f, --file <path>', 'Create story from file (supports .md, .txt, .markdown)')
|
|
50
|
+
.action((title, options) => add(title, options));
|
|
41
51
|
program
|
|
42
52
|
.command('details <id>')
|
|
43
53
|
.alias('d')
|
|
@@ -62,14 +72,67 @@ program
|
|
|
62
72
|
.option('--dry-run', 'Show what would be done without executing')
|
|
63
73
|
.option('--continue', 'Resume workflow from last checkpoint')
|
|
64
74
|
.option('--story <id-or-slug>', 'Target a specific story by ID or slug')
|
|
75
|
+
.option('--batch <story-ids>', 'Process multiple stories sequentially (comma-separated list, e.g., S-001,S-002,S-003)')
|
|
65
76
|
.option('--step <phase>', 'Run a specific phase (refine, research, plan, implement, review) - cannot be combined with --auto --story')
|
|
66
77
|
.option('--max-iterations <number>', 'Maximum retry iterations (default: infinite)')
|
|
67
78
|
.option('--watch', 'Run in daemon mode, continuously processing backlog')
|
|
68
79
|
.option('-v, --verbose', 'Show detailed daemon output (use with --watch)')
|
|
80
|
+
.option('--force', 'Skip git validation and conflict checks (use with caution)')
|
|
81
|
+
.option('--worktree', 'Create isolated git worktree for story execution (requires --story)')
|
|
82
|
+
.option('--no-worktree', 'Disable worktree even when enabled in config')
|
|
83
|
+
.option('--clean', 'Clean existing worktree and restart from scratch (requires --story)')
|
|
84
|
+
.option('--log-level <level>', 'Set log verbosity (debug, info, warn, error)', 'info')
|
|
69
85
|
.action((options) => {
|
|
70
86
|
if (!options.dryRun && !options.watch) {
|
|
71
87
|
checkApiKey();
|
|
72
88
|
}
|
|
89
|
+
// Initialize logger with config and CLI override
|
|
90
|
+
const config = loadConfig();
|
|
91
|
+
const logConfig = {
|
|
92
|
+
...DEFAULT_LOGGING_CONFIG,
|
|
93
|
+
...config.logging,
|
|
94
|
+
};
|
|
95
|
+
// CLI --log-level overrides config
|
|
96
|
+
if (options.logLevel) {
|
|
97
|
+
const validLevels = ['debug', 'info', 'warn', 'error'];
|
|
98
|
+
if (validLevels.includes(options.logLevel)) {
|
|
99
|
+
logConfig.level = options.logLevel;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const c = getThemedChalk(config);
|
|
103
|
+
console.log(c.warning(`Invalid log level "${options.logLevel}", using "${logConfig.level}"`));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
initLogger(process.cwd(), logConfig);
|
|
107
|
+
// Log startup information
|
|
108
|
+
const logger = getLogger();
|
|
109
|
+
logger.info('cli', 'ai-sdlc started', {
|
|
110
|
+
version: packageJson.version,
|
|
111
|
+
command: 'run',
|
|
112
|
+
options: {
|
|
113
|
+
auto: options.auto,
|
|
114
|
+
dryRun: options.dryRun,
|
|
115
|
+
continue: options.continue,
|
|
116
|
+
story: options.story,
|
|
117
|
+
step: options.step,
|
|
118
|
+
worktree: options.worktree,
|
|
119
|
+
clean: options.clean,
|
|
120
|
+
watch: options.watch,
|
|
121
|
+
logLevel: logConfig.level,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
// Validate --worktree requires --story
|
|
125
|
+
if (options.worktree && !options.story) {
|
|
126
|
+
const c = getThemedChalk(config);
|
|
127
|
+
console.log(c.error('Error: --worktree requires --story flag'));
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
// Validate --clean requires --story
|
|
131
|
+
if (options.clean && !options.story) {
|
|
132
|
+
const c = getThemedChalk(config);
|
|
133
|
+
console.log(c.error('Error: --clean requires --story flag'));
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
73
136
|
return run(options);
|
|
74
137
|
});
|
|
75
138
|
program
|
|
@@ -113,5 +176,83 @@ program
|
|
|
113
176
|
console.log(c.dim('Available keys: theme'));
|
|
114
177
|
}
|
|
115
178
|
});
|
|
179
|
+
// Logs command
|
|
180
|
+
program
|
|
181
|
+
.command('logs <storyId>')
|
|
182
|
+
.description('View logs for a story')
|
|
183
|
+
.option('-t, --tail', 'Follow log output (like tail -f)')
|
|
184
|
+
.option('-n, --lines <n>', 'Number of lines to show', '50')
|
|
185
|
+
.option('-f, --file <timestamp>', 'View specific log file by timestamp (e.g., 2026-01-15T10-30-00)')
|
|
186
|
+
.action(async (storyId, options) => {
|
|
187
|
+
try {
|
|
188
|
+
const config = loadConfig();
|
|
189
|
+
const c = getThemedChalk(config);
|
|
190
|
+
const sdlcRoot = getSdlcRoot();
|
|
191
|
+
// Determine which log file to view
|
|
192
|
+
let logPath;
|
|
193
|
+
if (options.file) {
|
|
194
|
+
// View specific log file by timestamp
|
|
195
|
+
const sanitizedStoryId = storyId; // Will be sanitized by getLatestLogPath
|
|
196
|
+
const logDir = path.join(sdlcRoot, 'stories', sanitizedStoryId, 'logs');
|
|
197
|
+
logPath = path.join(logDir, `${options.file}.log`);
|
|
198
|
+
if (!fs.existsSync(logPath)) {
|
|
199
|
+
console.log(c.error(`Log file not found: ${options.file}.log`));
|
|
200
|
+
console.log(c.dim(` Story: ${storyId}`));
|
|
201
|
+
console.log(c.dim(` Expected path: ${logPath}`));
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
// Get latest log file
|
|
207
|
+
logPath = getLatestLogPath(sdlcRoot, storyId);
|
|
208
|
+
if (!logPath) {
|
|
209
|
+
console.log(c.error(`No logs found for story: ${storyId}`));
|
|
210
|
+
console.log(c.dim(' Logs are created when running actions with `ai-sdlc run`'));
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Display logs
|
|
215
|
+
if (options.tail) {
|
|
216
|
+
// Follow mode (tail -f)
|
|
217
|
+
console.log(c.dim(`Following log: ${path.basename(logPath)}`));
|
|
218
|
+
console.log(c.dim(`Press Ctrl+C to exit\n`));
|
|
219
|
+
tailLog(logPath);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
// Show last N lines
|
|
223
|
+
const numLines = parseInt(options.lines || '50', 10);
|
|
224
|
+
const content = await readLastLines(logPath, numLines);
|
|
225
|
+
console.log(c.dim(`Log file: ${path.basename(logPath)}`));
|
|
226
|
+
console.log(c.dim(`Showing last ${numLines} lines\n`));
|
|
227
|
+
console.log(content);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
const config = loadConfig();
|
|
232
|
+
const c = getThemedChalk(config);
|
|
233
|
+
if (error instanceof Error && error.message.includes('Invalid story ID')) {
|
|
234
|
+
console.log(c.error(`Invalid story ID: ${storyId}`));
|
|
235
|
+
console.log(c.dim(' Story IDs cannot contain path traversal sequences or separators'));
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
console.log(c.error(`Error viewing logs: ${error instanceof Error ? error.message : String(error)}`));
|
|
239
|
+
}
|
|
240
|
+
process.exit(1);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
// Worktree management commands
|
|
244
|
+
program
|
|
245
|
+
.command('worktrees')
|
|
246
|
+
.description('List managed worktrees')
|
|
247
|
+
.action(listWorktrees);
|
|
248
|
+
program
|
|
249
|
+
.command('worktrees:add <story-id>')
|
|
250
|
+
.description('Create a worktree for a story')
|
|
251
|
+
.action(addWorktree);
|
|
252
|
+
program
|
|
253
|
+
.command('worktrees:remove <story-id>')
|
|
254
|
+
.description('Remove a worktree for a story')
|
|
255
|
+
.option('--force', 'Skip confirmation prompt')
|
|
256
|
+
.action((storyId, options) => removeWorktree(storyId, options));
|
|
116
257
|
program.parse();
|
|
117
258
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,OAA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BAA+B,CAAC;KAC5C,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,OAAO;KACJ,OAAO,CAAC,6BAA6B,CAAC;KACtC,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,SAAS,EAAE,0BAA0B,CAAC;KAC7C,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAElE,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Error Classification Service
|
|
3
|
+
*
|
|
4
|
+
* Classifies TypeScript compiler errors into two categories:
|
|
5
|
+
* - Source errors: Root causes in production code (e.g., missing type definitions)
|
|
6
|
+
* - Cascading errors: Downstream effects caused by source errors (e.g., test file imports failing)
|
|
7
|
+
*
|
|
8
|
+
* This enables the implementation agent to prioritize fixing root causes first,
|
|
9
|
+
* which often resolves multiple cascading errors automatically.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Structured representation of a TypeScript compiler error
|
|
13
|
+
*/
|
|
14
|
+
export interface TypeScriptError {
|
|
15
|
+
/** The file path where the error occurred */
|
|
16
|
+
filePath: string;
|
|
17
|
+
/** The line number (1-indexed) where the error occurred */
|
|
18
|
+
line?: number;
|
|
19
|
+
/** The column number (1-indexed) where the error occurred */
|
|
20
|
+
column?: number;
|
|
21
|
+
/** The TypeScript error code (e.g., "TS2322") */
|
|
22
|
+
code: string;
|
|
23
|
+
/** The error message text */
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of classifying and sorting TypeScript errors
|
|
28
|
+
*/
|
|
29
|
+
export interface ClassifiedErrors {
|
|
30
|
+
/** Source errors that are root causes and should be fixed first */
|
|
31
|
+
source: TypeScriptError[];
|
|
32
|
+
/** Cascading errors that may resolve automatically when source errors are fixed */
|
|
33
|
+
cascading: TypeScriptError[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Error classification type
|
|
37
|
+
*/
|
|
38
|
+
export type ErrorClassification = 'source' | 'cascading';
|
|
39
|
+
/**
|
|
40
|
+
* Parses TypeScript compiler output and extracts structured error information.
|
|
41
|
+
*
|
|
42
|
+
* Expected format: `<filePath>(<line>,<col>): error <code>: <message>`
|
|
43
|
+
* Example: `src/app.tsx(59,12): error TS2322: Type 'string' is not assignable to type 'number'.`
|
|
44
|
+
*
|
|
45
|
+
* @param buildOutput - Raw output from TypeScript compiler (tsc)
|
|
46
|
+
* @returns Array of structured TypeScript errors
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const output = "src/app.tsx(59,12): error TS2322: Type 'string' is not assignable to type 'number'.";
|
|
51
|
+
* const errors = parseTypeScriptErrors(output);
|
|
52
|
+
* // errors[0] = { filePath: 'src/app.tsx', line: 59, column: 12, code: 'TS2322', message: '...' }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseTypeScriptErrors(buildOutput: string): TypeScriptError[];
|
|
56
|
+
/**
|
|
57
|
+
* Determines if a file path points to a test file.
|
|
58
|
+
*
|
|
59
|
+
* Test files are identified by:
|
|
60
|
+
* - File extension: .test.ts, .test.tsx, .spec.ts, .spec.tsx, .test.js, .test.jsx, .spec.js, .spec.jsx
|
|
61
|
+
* - Directory patterns: tests/, __tests__/
|
|
62
|
+
*
|
|
63
|
+
* @param filePath - The file path to check
|
|
64
|
+
* @returns true if the file is a test file, false otherwise
|
|
65
|
+
*/
|
|
66
|
+
export declare function isTestFile(filePath: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Determines if a file path points to a type definition file.
|
|
69
|
+
*
|
|
70
|
+
* Type definition files are identified by:
|
|
71
|
+
* - File extension: .d.ts
|
|
72
|
+
* - Directory patterns: types/, @types/
|
|
73
|
+
*
|
|
74
|
+
* @param filePath - The file path to check
|
|
75
|
+
* @returns true if the file is a type definition file, false otherwise
|
|
76
|
+
*/
|
|
77
|
+
export declare function isTypeDefinitionFile(filePath: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Classifies a single TypeScript error as either a source error (root cause)
|
|
80
|
+
* or a cascading error (downstream effect).
|
|
81
|
+
*
|
|
82
|
+
* Classification logic:
|
|
83
|
+
* 1. Known cascading-only codes (TS2345) → cascading
|
|
84
|
+
* 2. Known source codes (TS2304, TS2339) in non-test files → source
|
|
85
|
+
* 3. Context-dependent codes (TS2307, TS2322) → analyze file path
|
|
86
|
+
* 4. Conservative default → cascading
|
|
87
|
+
*
|
|
88
|
+
* @param error - The TypeScript error to classify
|
|
89
|
+
* @returns 'source' if root cause, 'cascading' if downstream effect
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const error = { code: 'TS2304', filePath: 'src/app.ts', message: 'Cannot find name Foo' };
|
|
94
|
+
* const classification = classifyError(error); // 'source'
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function classifyError(error: TypeScriptError): ErrorClassification;
|
|
98
|
+
/**
|
|
99
|
+
* Classifies and sorts multiple TypeScript errors into source and cascading categories.
|
|
100
|
+
*
|
|
101
|
+
* Source errors are prioritized for fixing as they may automatically resolve
|
|
102
|
+
* multiple cascading errors.
|
|
103
|
+
*
|
|
104
|
+
* @param errors - Array of TypeScript errors to classify
|
|
105
|
+
* @returns Object with separated source and cascading error arrays
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const errors = [
|
|
110
|
+
* { code: 'TS2304', filePath: 'src/app.ts', message: '...' },
|
|
111
|
+
* { code: 'TS2307', filePath: 'tests/app.test.ts', message: '...' }
|
|
112
|
+
* ];
|
|
113
|
+
* const classified = classifyAndSortErrors(errors);
|
|
114
|
+
* // classified.source = [{ code: 'TS2304', ... }]
|
|
115
|
+
* // classified.cascading = [{ code: 'TS2307', ... }]
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function classifyAndSortErrors(errors: TypeScriptError[]): ClassifiedErrors;
|
|
119
|
+
//# sourceMappingURL=error-classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classifier.d.ts","sourceRoot":"","sources":["../../src/services/error-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mEAAmE;IACnE,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,mFAAmF;IACnF,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,EAAE,CAyB5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAmBpD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAmB9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,mBAAmB,CAgCzE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAcjF"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Error Classification Service
|
|
3
|
+
*
|
|
4
|
+
* Classifies TypeScript compiler errors into two categories:
|
|
5
|
+
* - Source errors: Root causes in production code (e.g., missing type definitions)
|
|
6
|
+
* - Cascading errors: Downstream effects caused by source errors (e.g., test file imports failing)
|
|
7
|
+
*
|
|
8
|
+
* This enables the implementation agent to prioritize fixing root causes first,
|
|
9
|
+
* which often resolves multiple cascading errors automatically.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Parses TypeScript compiler output and extracts structured error information.
|
|
13
|
+
*
|
|
14
|
+
* Expected format: `<filePath>(<line>,<col>): error <code>: <message>`
|
|
15
|
+
* Example: `src/app.tsx(59,12): error TS2322: Type 'string' is not assignable to type 'number'.`
|
|
16
|
+
*
|
|
17
|
+
* @param buildOutput - Raw output from TypeScript compiler (tsc)
|
|
18
|
+
* @returns Array of structured TypeScript errors
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const output = "src/app.tsx(59,12): error TS2322: Type 'string' is not assignable to type 'number'.";
|
|
23
|
+
* const errors = parseTypeScriptErrors(output);
|
|
24
|
+
* // errors[0] = { filePath: 'src/app.tsx', line: 59, column: 12, code: 'TS2322', message: '...' }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function parseTypeScriptErrors(buildOutput) {
|
|
28
|
+
if (!buildOutput || buildOutput.trim() === '') {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const errors = [];
|
|
32
|
+
// Regex pattern to match TypeScript error format:
|
|
33
|
+
// <filePath>(<line>,<col>): error <code>: <message>
|
|
34
|
+
// Supports both Windows (C:\...) and Unix (/...) paths
|
|
35
|
+
const tsErrorPattern = /^(.+?)\((\d+),(\d+)\):\s*error\s+(TS\d+):\s*(.+)$/gm;
|
|
36
|
+
let match;
|
|
37
|
+
while ((match = tsErrorPattern.exec(buildOutput)) !== null) {
|
|
38
|
+
const [, filePath, lineStr, colStr, code, message] = match;
|
|
39
|
+
errors.push({
|
|
40
|
+
filePath: filePath.trim(),
|
|
41
|
+
line: parseInt(lineStr, 10),
|
|
42
|
+
column: parseInt(colStr, 10),
|
|
43
|
+
code: code.trim(),
|
|
44
|
+
message: message.trim(),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return errors;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Determines if a file path points to a test file.
|
|
51
|
+
*
|
|
52
|
+
* Test files are identified by:
|
|
53
|
+
* - File extension: .test.ts, .test.tsx, .spec.ts, .spec.tsx, .test.js, .test.jsx, .spec.js, .spec.jsx
|
|
54
|
+
* - Directory patterns: tests/, __tests__/
|
|
55
|
+
*
|
|
56
|
+
* @param filePath - The file path to check
|
|
57
|
+
* @returns true if the file is a test file, false otherwise
|
|
58
|
+
*/
|
|
59
|
+
export function isTestFile(filePath) {
|
|
60
|
+
// Check for test file extensions
|
|
61
|
+
if (/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filePath)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
// Check for test directories (handle both Windows and Unix path separators)
|
|
65
|
+
// Also handle paths that start with the directory name (e.g., "tests/app.ts")
|
|
66
|
+
if (/(^|[\\/])tests?[\\/]/.test(filePath)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
// Check for __tests__ directory
|
|
70
|
+
// Also handle paths that start with __tests__ (e.g., "__tests__/app.ts")
|
|
71
|
+
if (/(^|[\\/])__tests__[\\/]/.test(filePath)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Determines if a file path points to a type definition file.
|
|
78
|
+
*
|
|
79
|
+
* Type definition files are identified by:
|
|
80
|
+
* - File extension: .d.ts
|
|
81
|
+
* - Directory patterns: types/, @types/
|
|
82
|
+
*
|
|
83
|
+
* @param filePath - The file path to check
|
|
84
|
+
* @returns true if the file is a type definition file, false otherwise
|
|
85
|
+
*/
|
|
86
|
+
export function isTypeDefinitionFile(filePath) {
|
|
87
|
+
// Check for .d.ts extension
|
|
88
|
+
if (filePath.endsWith('.d.ts')) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
// Check for types/ directory (handle both Windows and Unix path separators)
|
|
92
|
+
// Also handle paths that start with types/ (e.g., "types/global.ts")
|
|
93
|
+
if (/(^|[\\/])types[\\/]/.test(filePath)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
// Check for @types/ directory
|
|
97
|
+
// Also handle paths that start with @types/ (e.g., "@types/custom/foo.ts")
|
|
98
|
+
if (/(^|[\\/])@types[\\/]/.test(filePath)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Classifies a single TypeScript error as either a source error (root cause)
|
|
105
|
+
* or a cascading error (downstream effect).
|
|
106
|
+
*
|
|
107
|
+
* Classification logic:
|
|
108
|
+
* 1. Known cascading-only codes (TS2345) → cascading
|
|
109
|
+
* 2. Known source codes (TS2304, TS2339) in non-test files → source
|
|
110
|
+
* 3. Context-dependent codes (TS2307, TS2322) → analyze file path
|
|
111
|
+
* 4. Conservative default → cascading
|
|
112
|
+
*
|
|
113
|
+
* @param error - The TypeScript error to classify
|
|
114
|
+
* @returns 'source' if root cause, 'cascading' if downstream effect
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const error = { code: 'TS2304', filePath: 'src/app.ts', message: 'Cannot find name Foo' };
|
|
119
|
+
* const classification = classifyError(error); // 'source'
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function classifyError(error) {
|
|
123
|
+
const { code, filePath } = error;
|
|
124
|
+
// Known cascading-only error codes
|
|
125
|
+
const CASCADING_ONLY_CODES = ['TS2345']; // Argument type mismatch
|
|
126
|
+
// Known source error codes (when in non-test files)
|
|
127
|
+
const SOURCE_ERROR_CODES = ['TS2304', 'TS2339']; // Cannot find name, Property does not exist
|
|
128
|
+
// Priority 1: Known cascading-only codes
|
|
129
|
+
if (CASCADING_ONLY_CODES.includes(code)) {
|
|
130
|
+
return 'cascading';
|
|
131
|
+
}
|
|
132
|
+
// Priority 2: Known source codes in non-test files
|
|
133
|
+
if (SOURCE_ERROR_CODES.includes(code) && !isTestFile(filePath)) {
|
|
134
|
+
return 'source';
|
|
135
|
+
}
|
|
136
|
+
// Priority 3: Context-dependent codes need path analysis
|
|
137
|
+
if (code === 'TS2307') {
|
|
138
|
+
// Module not found: source in src, cascading in tests
|
|
139
|
+
return isTestFile(filePath) ? 'cascading' : 'source';
|
|
140
|
+
}
|
|
141
|
+
if (code === 'TS2322') {
|
|
142
|
+
// Type mismatch: source in type definitions, cascading elsewhere
|
|
143
|
+
return isTypeDefinitionFile(filePath) ? 'source' : 'cascading';
|
|
144
|
+
}
|
|
145
|
+
// Priority 4: Conservative default (when uncertain)
|
|
146
|
+
return 'cascading';
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Classifies and sorts multiple TypeScript errors into source and cascading categories.
|
|
150
|
+
*
|
|
151
|
+
* Source errors are prioritized for fixing as they may automatically resolve
|
|
152
|
+
* multiple cascading errors.
|
|
153
|
+
*
|
|
154
|
+
* @param errors - Array of TypeScript errors to classify
|
|
155
|
+
* @returns Object with separated source and cascading error arrays
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const errors = [
|
|
160
|
+
* { code: 'TS2304', filePath: 'src/app.ts', message: '...' },
|
|
161
|
+
* { code: 'TS2307', filePath: 'tests/app.test.ts', message: '...' }
|
|
162
|
+
* ];
|
|
163
|
+
* const classified = classifyAndSortErrors(errors);
|
|
164
|
+
* // classified.source = [{ code: 'TS2304', ... }]
|
|
165
|
+
* // classified.cascading = [{ code: 'TS2307', ... }]
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export function classifyAndSortErrors(errors) {
|
|
169
|
+
const source = [];
|
|
170
|
+
const cascading = [];
|
|
171
|
+
for (const error of errors) {
|
|
172
|
+
const classification = classifyError(error);
|
|
173
|
+
if (classification === 'source') {
|
|
174
|
+
source.push(error);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
cascading.push(error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return { source, cascading };
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=error-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classifier.js","sourceRoot":"","sources":["../../src/services/error-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiCH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IACvD,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,kDAAkD;IAClD,oDAAoD;IACpD,uDAAuD;IACvD,MAAM,cAAc,GAAG,qDAAqD,CAAC;IAE7E,IAAI,KAAK,CAAC;IACV,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC3D,MAAM,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;QAE3D,MAAM,CAAC,IAAI,CAAC;YACV,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE;YACzB,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC5B,IAAI,E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