@yuaone/core 0.2.0 → 0.3.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 (41) hide show
  1. package/dist/agent-loop.d.ts +40 -0
  2. package/dist/agent-loop.d.ts.map +1 -1
  3. package/dist/agent-loop.js +182 -4
  4. package/dist/agent-loop.js.map +1 -1
  5. package/dist/benchmark-runner.d.ts +141 -0
  6. package/dist/benchmark-runner.d.ts.map +1 -0
  7. package/dist/benchmark-runner.js +526 -0
  8. package/dist/benchmark-runner.js.map +1 -0
  9. package/dist/codebase-context.d.ts +49 -0
  10. package/dist/codebase-context.d.ts.map +1 -1
  11. package/dist/codebase-context.js +146 -0
  12. package/dist/codebase-context.js.map +1 -1
  13. package/dist/cost-optimizer.d.ts +159 -0
  14. package/dist/cost-optimizer.d.ts.map +1 -0
  15. package/dist/cost-optimizer.js +406 -0
  16. package/dist/cost-optimizer.js.map +1 -0
  17. package/dist/execution-policy-engine.d.ts +133 -0
  18. package/dist/execution-policy-engine.d.ts.map +1 -0
  19. package/dist/execution-policy-engine.js +367 -0
  20. package/dist/execution-policy-engine.js.map +1 -0
  21. package/dist/failure-recovery.d.ts +228 -0
  22. package/dist/failure-recovery.d.ts.map +1 -0
  23. package/dist/failure-recovery.js +664 -0
  24. package/dist/failure-recovery.js.map +1 -0
  25. package/dist/hierarchical-planner.d.ts +69 -1
  26. package/dist/hierarchical-planner.d.ts.map +1 -1
  27. package/dist/hierarchical-planner.js +117 -0
  28. package/dist/hierarchical-planner.js.map +1 -1
  29. package/dist/impact-analyzer.d.ts +92 -0
  30. package/dist/impact-analyzer.d.ts.map +1 -0
  31. package/dist/impact-analyzer.js +615 -0
  32. package/dist/impact-analyzer.js.map +1 -0
  33. package/dist/index.d.ts +14 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +13 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/world-state.d.ts +87 -0
  38. package/dist/world-state.d.ts.map +1 -0
  39. package/dist/world-state.js +435 -0
  40. package/dist/world-state.js.map +1 -0
  41. package/package.json +11 -21
@@ -0,0 +1,664 @@
1
+ /**
2
+ * @module failure-recovery
3
+ * @description Intelligent error recovery on top of AutoFixLoop.
4
+ *
5
+ * While AutoFixLoop handles simple retry loops (validate → fix prompt → retry),
6
+ * FailureRecovery classifies root causes and selects from 5 recovery strategies:
7
+ * 1. retry — same approach, try again
8
+ * 2. rollback — undo changes, restore originals
9
+ * 3. approach_change — different implementation approach
10
+ * 4. scope_reduce — simplify the task
11
+ * 5. escalate — ask user for help
12
+ *
13
+ * Flow:
14
+ * error → analyzeRootCause → selectStrategy → buildRecoveryPrompt
15
+ * → (optionally) executeRollback / buildScopeReduction
16
+ *
17
+ * @see auto-fix.ts for the underlying AutoFixLoop
18
+ * @see 설계 문서 Section 6.4
19
+ */
20
+ import { rename, writeFile } from "node:fs/promises";
21
+ import path from "node:path";
22
+ // ─── Constants ───
23
+ const DEFAULT_CONFIG = {
24
+ maxStrategySwitches: 3,
25
+ enableRollback: true,
26
+ enableScopeReduce: true,
27
+ escalateThreshold: 2,
28
+ };
29
+ /**
30
+ * Patterns used to classify errors into categories.
31
+ * Order matters: more specific patterns are checked first.
32
+ */
33
+ const ERROR_PATTERNS = [
34
+ {
35
+ category: "PERMISSION_ERROR",
36
+ patterns: [
37
+ /EACCES/i,
38
+ /EPERM/i,
39
+ /permission denied/i,
40
+ /sandbox/i,
41
+ ],
42
+ suggestion: "Check file permissions or sandbox configuration.",
43
+ },
44
+ {
45
+ category: "RESOURCE_ERROR",
46
+ patterns: [
47
+ /ENOMEM/i,
48
+ /ENOSPC/i,
49
+ /heap out of memory/i,
50
+ /out of memory/i,
51
+ ],
52
+ suggestion: "Free resources or reduce scope of operation.",
53
+ },
54
+ {
55
+ category: "TIMEOUT",
56
+ patterns: [
57
+ /ETIMEDOUT/i,
58
+ /\btimeout\b/i,
59
+ /timed out/i,
60
+ ],
61
+ suggestion: "Increase timeout or reduce operation scope.",
62
+ },
63
+ {
64
+ category: "IMPORT_ERROR",
65
+ patterns: [
66
+ /Cannot find module/i,
67
+ /Module not found/i,
68
+ /ERR_MODULE_NOT_FOUND/i,
69
+ ],
70
+ suggestion: "Check import paths and ensure the module is installed.",
71
+ },
72
+ {
73
+ category: "TYPE_ERROR",
74
+ patterns: [
75
+ /Type .+ is not assignable/i,
76
+ /Property .+ does not exist/i,
77
+ /error TS\d+/i,
78
+ ],
79
+ suggestion: "Fix type annotations or add missing type definitions.",
80
+ },
81
+ {
82
+ category: "LINT_ERROR",
83
+ patterns: [
84
+ /eslint/i,
85
+ /prettier/i,
86
+ /\blint\b/i,
87
+ /\bwarning:/i,
88
+ ],
89
+ suggestion: "Fix lint/style issues per project config.",
90
+ },
91
+ {
92
+ category: "TEST_FAIL",
93
+ patterns: [
94
+ /\bFAIL\b/,
95
+ /AssertionError/i,
96
+ /AssertionError/i,
97
+ /Expected .+ received/i,
98
+ /test failed/i,
99
+ ],
100
+ suggestion: "Fix test assertions or update expected values.",
101
+ },
102
+ {
103
+ category: "BUILD_FAIL",
104
+ patterns: [
105
+ /Unexpected token/i,
106
+ /SyntaxError/i,
107
+ /build failed/i,
108
+ /compilation failed/i,
109
+ ],
110
+ suggestion: "Fix syntax or build configuration errors.",
111
+ },
112
+ {
113
+ category: "RUNTIME_ERROR",
114
+ patterns: [
115
+ /\bError:/,
116
+ /TypeError:/,
117
+ /ReferenceError:/,
118
+ /RangeError:/,
119
+ ],
120
+ suggestion: "Debug the runtime error and fix the underlying logic.",
121
+ },
122
+ ];
123
+ // ─── FailureRecovery ───
124
+ /**
125
+ * FailureRecovery — Intelligent error recovery with root cause analysis
126
+ * and multi-strategy recovery selection.
127
+ *
128
+ * Sits on top of AutoFixLoop to provide higher-level recovery when
129
+ * simple retries are insufficient.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const recovery = new FailureRecovery({ maxStrategySwitches: 3 });
134
+ *
135
+ * // Analyze the error
136
+ * const rootCause = recovery.analyzeRootCause(errorOutput, 'shell_exec');
137
+ *
138
+ * // Select a strategy
139
+ * const decision = recovery.selectStrategy(rootCause, failureContext);
140
+ *
141
+ * // Get the recovery prompt for LLM
142
+ * const prompt = recovery.buildRecoveryPrompt(decision, failureContext);
143
+ *
144
+ * // If rollback was selected
145
+ * if (decision.strategy === 'rollback') {
146
+ * await recovery.executeRollback(changedFiles, originalSnapshots);
147
+ * }
148
+ *
149
+ * // Record outcome
150
+ * recovery.recordStrategyResult(decision.strategy, wasSuccessful);
151
+ * ```
152
+ */
153
+ export class FailureRecovery {
154
+ config;
155
+ history = [];
156
+ constructor(config) {
157
+ this.config = { ...DEFAULT_CONFIG, ...config };
158
+ }
159
+ // ─── Root Cause Analysis ───
160
+ /**
161
+ * Analyze an error string and classify its root cause.
162
+ *
163
+ * Checks against known error patterns in priority order and extracts
164
+ * file/line information when available.
165
+ *
166
+ * @param error Raw error string
167
+ * @param toolName Optional tool that produced the error
168
+ * @returns Root cause analysis with category, confidence, and suggestion
169
+ */
170
+ analyzeRootCause(error, toolName) {
171
+ // Try each pattern group in priority order
172
+ for (const group of ERROR_PATTERNS) {
173
+ for (const pattern of group.patterns) {
174
+ if (pattern.test(error)) {
175
+ const { file, line } = this.extractFileLocation(error);
176
+ const confidence = this.computeConfidence(error, group.category, toolName);
177
+ return {
178
+ category: group.category,
179
+ message: this.extractErrorMessage(error),
180
+ file,
181
+ line,
182
+ suggestion: group.suggestion,
183
+ confidence,
184
+ };
185
+ }
186
+ }
187
+ }
188
+ // No pattern matched
189
+ return {
190
+ category: "UNKNOWN",
191
+ message: this.extractErrorMessage(error),
192
+ suggestion: "Investigate the error manually.",
193
+ confidence: 0.2,
194
+ };
195
+ }
196
+ // ─── Strategy Selection ───
197
+ /**
198
+ * Select the best recovery strategy based on root cause and context.
199
+ *
200
+ * Strategy selection logic:
201
+ * - Attempt 1 + fixable categories → retry
202
+ * - PERMISSION_ERROR / RESOURCE_ERROR → escalate immediately
203
+ * - Attempt 2+ + rollback not tried → rollback
204
+ * - Rollback tried + approach_change not tried → approach_change
205
+ * - TIMEOUT + attempt 2+ → scope_reduce
206
+ * - Too many strategies tried → escalate
207
+ * - Default → approach_change
208
+ *
209
+ * @param rootCause Analyzed root cause
210
+ * @param context Full failure context
211
+ * @returns Recovery decision with strategy, reason, and optional prompt
212
+ */
213
+ selectStrategy(rootCause, context) {
214
+ const { category } = rootCause;
215
+ const { attemptNumber, previousStrategies } = context;
216
+ const tried = (s) => previousStrategies.includes(s);
217
+ // Immediate escalation for unrecoverable errors
218
+ if (category === "PERMISSION_ERROR" || category === "RESOURCE_ERROR") {
219
+ return {
220
+ strategy: "escalate",
221
+ reason: `${category} requires user intervention — cannot be auto-resolved.`,
222
+ context: { category, immediateEscalation: true },
223
+ };
224
+ }
225
+ // First attempt with fixable errors → simple retry
226
+ const fixableOnRetry = [
227
+ "BUILD_FAIL",
228
+ "LINT_ERROR",
229
+ "TYPE_ERROR",
230
+ ];
231
+ if (attemptNumber === 1 && fixableOnRetry.includes(category)) {
232
+ return {
233
+ strategy: "retry",
234
+ reason: `First attempt with ${category} — retry with targeted fix.`,
235
+ context: { category, attemptNumber },
236
+ };
237
+ }
238
+ // Too many strategies tried → escalate
239
+ if (previousStrategies.length >= this.config.escalateThreshold) {
240
+ return {
241
+ strategy: "escalate",
242
+ reason: `Exhausted ${previousStrategies.length} strategies (threshold: ${this.config.escalateThreshold}).`,
243
+ context: {
244
+ triedStrategies: [...previousStrategies],
245
+ threshold: this.config.escalateThreshold,
246
+ },
247
+ };
248
+ }
249
+ // Timeout on second+ attempt → scope_reduce
250
+ if (category === "TIMEOUT" && attemptNumber >= 2 && this.config.enableScopeReduce) {
251
+ return {
252
+ strategy: "scope_reduce",
253
+ reason: "Operation timed out repeatedly — reducing scope.",
254
+ context: { category, attemptNumber },
255
+ };
256
+ }
257
+ // Attempt 2+ and haven't tried rollback yet
258
+ if (attemptNumber >= 2 && !tried("rollback") && this.config.enableRollback) {
259
+ return {
260
+ strategy: "rollback",
261
+ reason: `Attempt ${attemptNumber} failed — rolling back to start fresh.`,
262
+ context: {
263
+ category,
264
+ attemptNumber,
265
+ filesCount: context.changedFiles.length,
266
+ },
267
+ };
268
+ }
269
+ // Tried rollback but not approach_change
270
+ if (tried("rollback") && !tried("approach_change")) {
271
+ return {
272
+ strategy: "approach_change",
273
+ reason: "Rollback completed — trying a fundamentally different approach.",
274
+ context: { category, previousStrategies: [...previousStrategies] },
275
+ };
276
+ }
277
+ // Default: approach_change
278
+ return {
279
+ strategy: "approach_change",
280
+ reason: `${category} persists after ${attemptNumber} attempts — switching approach.`,
281
+ context: { category, attemptNumber },
282
+ };
283
+ }
284
+ // ─── Recovery Prompts ───
285
+ /**
286
+ * Build an LLM prompt tailored to the selected recovery strategy.
287
+ *
288
+ * Each strategy produces a different prompt style:
289
+ * - retry: focused on the specific error with suggestion
290
+ * - rollback: instructs fresh start after file restoration
291
+ * - approach_change: suggests alternative implementations
292
+ * - scope_reduce: narrows down the task scope
293
+ * - escalate: summarizes the situation for the user
294
+ *
295
+ * @param decision Recovery decision from selectStrategy
296
+ * @param context Full failure context
297
+ * @returns Formatted prompt string
298
+ */
299
+ buildRecoveryPrompt(decision, context) {
300
+ switch (decision.strategy) {
301
+ case "retry":
302
+ return this.buildRetryPrompt(decision, context);
303
+ case "rollback":
304
+ return this.buildRollbackPrompt(decision, context);
305
+ case "approach_change":
306
+ return this.buildApproachChangePrompt(decision, context);
307
+ case "scope_reduce":
308
+ return this.buildScopeReducePrompt(decision, context);
309
+ case "escalate":
310
+ return this.buildEscalatePrompt(decision, context);
311
+ default:
312
+ return this.buildRetryPrompt(decision, context);
313
+ }
314
+ }
315
+ // ─── Rollback ───
316
+ /**
317
+ * Execute a rollback by restoring original file contents.
318
+ *
319
+ * Uses atomic writes: writes to a .tmp file first, then renames.
320
+ * This prevents partial writes from corrupting files.
321
+ *
322
+ * @param changedFiles List of file paths to restore
323
+ * @param originalSnapshots Map of file path → original content
324
+ * @returns true if all files were successfully restored
325
+ */
326
+ async executeRollback(changedFiles, originalSnapshots) {
327
+ let allSuccess = true;
328
+ for (const filePath of changedFiles) {
329
+ const originalContent = originalSnapshots.get(filePath);
330
+ if (originalContent === undefined) {
331
+ // No snapshot for this file — skip (it may be a new file)
332
+ continue;
333
+ }
334
+ try {
335
+ // Atomic write: write to .tmp then rename
336
+ const tmpPath = filePath + ".recovery.tmp";
337
+ await writeFile(tmpPath, originalContent, "utf-8");
338
+ await rename(tmpPath, filePath);
339
+ }
340
+ catch (err) {
341
+ allSuccess = false;
342
+ // Continue restoring other files even if one fails
343
+ }
344
+ }
345
+ return allSuccess;
346
+ }
347
+ // ─── Scope Reduction ───
348
+ /**
349
+ * Build a scope-reduced version of the task description.
350
+ *
351
+ * Strips failed aspects from the original goal and produces
352
+ * a simplified task that avoids the problematic areas.
353
+ *
354
+ * @param originalGoal The original task description
355
+ * @param failedAspects Aspects that failed and should be skipped
356
+ * @returns Scope-reduced task description
357
+ */
358
+ buildScopeReduction(originalGoal, failedAspects) {
359
+ const skipList = failedAspects
360
+ .map((aspect) => ` - ${aspect}`)
361
+ .join("\n");
362
+ return [
363
+ "The full task is too complex for the current context. Focus on the core requirement only.",
364
+ "",
365
+ `Original goal: ${originalGoal}`,
366
+ "",
367
+ "Reduced scope:",
368
+ " - Implement only the essential, minimum-viable version",
369
+ " - Skip edge cases and optional features",
370
+ " - Use simple/direct approaches over elegant ones",
371
+ "",
372
+ "Skip these aspects (they caused failures):",
373
+ skipList,
374
+ "",
375
+ "You can add TODO comments for the skipped parts.",
376
+ ].join("\n");
377
+ }
378
+ // ─── Strategy Tracking ───
379
+ /**
380
+ * Record the outcome of a strategy attempt.
381
+ *
382
+ * Used to track success rates and inform future strategy selection.
383
+ *
384
+ * @param strategy The strategy that was attempted
385
+ * @param success Whether it resolved the error
386
+ */
387
+ recordStrategyResult(strategy, success) {
388
+ this.history.push({
389
+ strategy,
390
+ success,
391
+ timestamp: Date.now(),
392
+ });
393
+ }
394
+ /**
395
+ * Reset all state for a new task.
396
+ * Clears strategy history and statistics.
397
+ */
398
+ reset() {
399
+ this.history.length = 0;
400
+ }
401
+ /**
402
+ * Get statistics about strategy usage and success rate.
403
+ *
404
+ * @returns Object with strategies used, success rate, and current attempt count
405
+ */
406
+ getStats() {
407
+ const strategiesUsed = this.history.map((r) => r.strategy);
408
+ const total = this.history.length;
409
+ const successes = this.history.filter((r) => r.success).length;
410
+ return {
411
+ strategiesUsed,
412
+ successRate: total > 0 ? successes / total : 0,
413
+ currentAttempt: total + 1,
414
+ };
415
+ }
416
+ // ─── Private: Prompt Builders ───
417
+ buildRetryPrompt(decision, context) {
418
+ const rootCause = this.analyzeRootCause(context.error, context.toolName);
419
+ const suggestion = rootCause.suggestion ?? "analyze the error and try a different fix";
420
+ return [
421
+ `[RECOVERY: RETRY — Attempt ${context.attemptNumber}/${context.maxAttempts}]`,
422
+ "",
423
+ `The previous attempt failed with:`,
424
+ "```",
425
+ this.truncate(context.error, 2000),
426
+ "```",
427
+ "",
428
+ `Try again with a different approach to fix: ${suggestion}`,
429
+ "",
430
+ "Instructions:",
431
+ "- Make minimal, targeted changes.",
432
+ "- Do not repeat the same approach that failed.",
433
+ rootCause.file ? `- Focus on file: ${rootCause.file}${rootCause.line ? ` (line ${rootCause.line})` : ""}` : "",
434
+ ].filter(Boolean).join("\n");
435
+ }
436
+ buildRollbackPrompt(decision, context) {
437
+ const fileList = context.changedFiles.length > 0
438
+ ? context.changedFiles.map((f) => path.basename(f)).join(", ")
439
+ : "modified files";
440
+ return [
441
+ "[RECOVERY: ROLLBACK]",
442
+ "",
443
+ `Rolling back changes to ${fileList}.`,
444
+ `The original approach failed because: ${decision.reason}`,
445
+ "",
446
+ "Start fresh with a different strategy:",
447
+ "- Analyze why the previous approach failed before writing code.",
448
+ "- Consider a fundamentally different implementation path.",
449
+ "- Test incrementally — don't make large changes at once.",
450
+ "",
451
+ "Previous error:",
452
+ "```",
453
+ this.truncate(context.error, 1500),
454
+ "```",
455
+ ].join("\n");
456
+ }
457
+ buildApproachChangePrompt(decision, context) {
458
+ const rootCause = this.analyzeRootCause(context.error, context.toolName);
459
+ const alternatives = this.suggestAlternatives(rootCause);
460
+ return [
461
+ "[RECOVERY: APPROACH CHANGE]",
462
+ "",
463
+ `Previous approach failed (${decision.reason}).`,
464
+ "Consider alternative implementations:",
465
+ "",
466
+ ...alternatives.map((alt, i) => `${i + 1}. ${alt}`),
467
+ "",
468
+ "Previous error:",
469
+ "```",
470
+ this.truncate(context.error, 1200),
471
+ "```",
472
+ "",
473
+ "Requirements:",
474
+ "- Use a fundamentally different approach than before.",
475
+ "- Avoid the pattern/API that caused the previous failure.",
476
+ "- Start with the simplest possible implementation.",
477
+ ].join("\n");
478
+ }
479
+ buildScopeReducePrompt(decision, context) {
480
+ return [
481
+ "[RECOVERY: SCOPE REDUCE]",
482
+ "",
483
+ "The full task is too complex. Focus on the core requirement only.",
484
+ "",
485
+ "Previous error:",
486
+ "```",
487
+ this.truncate(context.error, 1000),
488
+ "```",
489
+ "",
490
+ "Reduced scope instructions:",
491
+ "- Implement the minimum viable version only.",
492
+ "- Skip optional features, edge cases, and optimizations.",
493
+ "- Use TODO comments for deferred work.",
494
+ "- Break the task into smaller, independent steps.",
495
+ "",
496
+ `Changed files so far: ${context.changedFiles.length}`,
497
+ `Attempt: ${context.attemptNumber}/${context.maxAttempts}`,
498
+ ].join("\n");
499
+ }
500
+ buildEscalatePrompt(decision, context) {
501
+ const stats = this.getStats();
502
+ const strategiesTried = context.previousStrategies.length > 0
503
+ ? context.previousStrategies.join(", ")
504
+ : "none";
505
+ return [
506
+ "[RECOVERY: ESCALATE — User Help Needed]",
507
+ "",
508
+ `I need your help. After ${context.attemptNumber} attempts with strategies [${strategiesTried}], I couldn't resolve:`,
509
+ "",
510
+ "```",
511
+ this.truncate(context.error, 1500),
512
+ "```",
513
+ "",
514
+ "Suggested next steps:",
515
+ "- Review the error manually and provide guidance.",
516
+ "- Check if the project environment is set up correctly.",
517
+ "- Consider if this task requires a different approach entirely.",
518
+ "",
519
+ `Strategies tried: ${strategiesTried}`,
520
+ `Success rate: ${(stats.successRate * 100).toFixed(0)}%`,
521
+ `Files changed: ${context.changedFiles.join(", ") || "none"}`,
522
+ ].join("\n");
523
+ }
524
+ // ─── Private: Root Cause Helpers ───
525
+ /**
526
+ * Extract file path and line number from an error string.
527
+ * Handles common formats: "file.ts(10,5)", "file.ts:10:5", "(file.ts:10)"
528
+ */
529
+ extractFileLocation(error) {
530
+ // TypeScript style: src/foo.ts(10,5): error TS...
531
+ const tsMatch = error.match(/([^\s(]+\.(?:ts|tsx|js|jsx|mjs|cjs))\((\d+),\d+\)/);
532
+ if (tsMatch) {
533
+ return { file: tsMatch[1], line: parseInt(tsMatch[2], 10) };
534
+ }
535
+ // Colon style: src/foo.ts:10:5
536
+ const colonMatch = error.match(/([^\s:]+\.(?:ts|tsx|js|jsx|mjs|cjs)):(\d+):\d+/);
537
+ if (colonMatch) {
538
+ return { file: colonMatch[1], line: parseInt(colonMatch[2], 10) };
539
+ }
540
+ // Just file, no line
541
+ const fileMatch = error.match(/([^\s]+\.(?:ts|tsx|js|jsx|mjs|cjs))/);
542
+ if (fileMatch) {
543
+ return { file: fileMatch[1] };
544
+ }
545
+ return {};
546
+ }
547
+ /**
548
+ * Extract a clean error message from raw output.
549
+ * Takes the first meaningful error line.
550
+ */
551
+ extractErrorMessage(error) {
552
+ const lines = error.split("\n").map((l) => l.trim()).filter(Boolean);
553
+ // Look for lines starting with "error", "Error:", "TypeError:", etc.
554
+ for (const line of lines) {
555
+ if (/^(error|Error|TypeError|ReferenceError|SyntaxError)/i.test(line)) {
556
+ return this.truncate(line, 300);
557
+ }
558
+ }
559
+ // Look for "error TS" patterns
560
+ for (const line of lines) {
561
+ if (/error TS\d+/i.test(line)) {
562
+ return this.truncate(line, 300);
563
+ }
564
+ }
565
+ // Fallback: first non-empty line
566
+ return this.truncate(lines[0] ?? error, 300);
567
+ }
568
+ /**
569
+ * Compute confidence score for a category match.
570
+ * Higher confidence when multiple signals align.
571
+ */
572
+ computeConfidence(error, category, toolName) {
573
+ let confidence = 0.6; // Base confidence for pattern match
574
+ // Boost if tool name aligns with category
575
+ const toolCategoryMap = {
576
+ shell_exec: ["BUILD_FAIL", "RUNTIME_ERROR", "TIMEOUT"],
577
+ file_write: ["PERMISSION_ERROR", "RESOURCE_ERROR"],
578
+ file_edit: ["PERMISSION_ERROR"],
579
+ file_read: ["PERMISSION_ERROR", "IMPORT_ERROR"],
580
+ };
581
+ if (toolName && toolCategoryMap[toolName]?.includes(category)) {
582
+ confidence += 0.15;
583
+ }
584
+ // Boost if multiple patterns match
585
+ const group = ERROR_PATTERNS.find((g) => g.category === category);
586
+ if (group) {
587
+ const matchCount = group.patterns.filter((p) => p.test(error)).length;
588
+ if (matchCount > 1) {
589
+ confidence += 0.1 * Math.min(matchCount - 1, 2);
590
+ }
591
+ }
592
+ // Boost for very specific patterns (e.g., "error TS2345")
593
+ if (/error TS\d{4}/.test(error) && category === "TYPE_ERROR") {
594
+ confidence += 0.1;
595
+ }
596
+ if (/EACCES|EPERM/.test(error) && category === "PERMISSION_ERROR") {
597
+ confidence += 0.1;
598
+ }
599
+ return Math.min(confidence, 1.0);
600
+ }
601
+ /**
602
+ * Suggest alternative approaches based on the root cause category.
603
+ */
604
+ suggestAlternatives(rootCause) {
605
+ switch (rootCause.category) {
606
+ case "TYPE_ERROR":
607
+ return [
608
+ "Use explicit type assertions or generics to resolve the type mismatch.",
609
+ "Simplify the type structure — use a union or intersection type.",
610
+ "Break the operation into smaller, type-safe steps.",
611
+ ];
612
+ case "IMPORT_ERROR":
613
+ return [
614
+ "Verify the module exists and is installed (check package.json).",
615
+ "Use a relative import path instead of a package name.",
616
+ "Check for typos in the import path and verify the export name.",
617
+ ];
618
+ case "BUILD_FAIL":
619
+ return [
620
+ "Fix syntax errors or missing tokens reported in the build output.",
621
+ "Check for incompatible API usage with the current library version.",
622
+ "Simplify the implementation to avoid the problematic construct.",
623
+ ];
624
+ case "TEST_FAIL":
625
+ return [
626
+ "Update expected values to match the new behavior.",
627
+ "Mock or stub the dependency that causes the test to fail.",
628
+ "Simplify the test case to isolate the failure.",
629
+ ];
630
+ case "LINT_ERROR":
631
+ return [
632
+ "Fix the specific lint rule violations reported.",
633
+ "Use inline lint-disable comments only as a last resort.",
634
+ "Refactor to follow the project's code style conventions.",
635
+ ];
636
+ case "TIMEOUT":
637
+ return [
638
+ "Reduce the amount of work in a single operation.",
639
+ "Add chunking or pagination to process data incrementally.",
640
+ "Skip optional validations to reduce execution time.",
641
+ ];
642
+ case "RUNTIME_ERROR":
643
+ return [
644
+ "Add null/undefined checks before accessing properties.",
645
+ "Wrap the operation in try/catch and handle the error gracefully.",
646
+ "Verify input data format matches what the code expects.",
647
+ ];
648
+ default:
649
+ return [
650
+ "Try a simpler implementation that avoids the problematic pattern.",
651
+ "Break the task into smaller, independent steps.",
652
+ "Check project documentation for guidance on the expected approach.",
653
+ ];
654
+ }
655
+ }
656
+ // ─── Private: Utilities ───
657
+ truncate(text, maxLength) {
658
+ if (text.length <= maxLength)
659
+ return text;
660
+ const half = Math.floor(maxLength / 2);
661
+ return text.slice(0, half) + "\n... [truncated] ...\n" + text.slice(-half);
662
+ }
663
+ }
664
+ //# sourceMappingURL=failure-recovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure-recovery.js","sourceRoot":"","sources":["../src/failure-recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAC/D,OAAO,IAAI,MAAM,WAAW,CAAC;AAgG7B,oBAAoB;AAEpB,MAAM,cAAc,GAA0B;IAC5C,mBAAmB,EAAE,CAAC;IACtB,cAAc,EAAE,IAAI;IACpB,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,cAAc,GAIf;IACH;QACE,QAAQ,E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