@yuaone/core 0.9.7 → 0.9.9

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 (193) hide show
  1. package/dist/__tests__/context-manager.test.js +5 -9
  2. package/dist/__tests__/context-manager.test.js.map +1 -1
  3. package/dist/agent-coordinator.d.ts +172 -0
  4. package/dist/agent-coordinator.d.ts.map +1 -0
  5. package/dist/agent-coordinator.js +390 -0
  6. package/dist/agent-coordinator.js.map +1 -0
  7. package/dist/agent-loop.d.ts +83 -29
  8. package/dist/agent-loop.d.ts.map +1 -1
  9. package/dist/agent-loop.js +697 -335
  10. package/dist/agent-loop.js.map +1 -1
  11. package/dist/agent-reputation.d.ts +72 -0
  12. package/dist/agent-reputation.d.ts.map +1 -0
  13. package/dist/agent-reputation.js +222 -0
  14. package/dist/agent-reputation.js.map +1 -0
  15. package/dist/arch-summarizer.d.ts +48 -0
  16. package/dist/arch-summarizer.d.ts.map +1 -0
  17. package/dist/arch-summarizer.js +239 -0
  18. package/dist/arch-summarizer.js.map +1 -0
  19. package/dist/autonomous/explicit-planner.d.ts +45 -0
  20. package/dist/autonomous/explicit-planner.d.ts.map +1 -0
  21. package/dist/autonomous/explicit-planner.js +99 -0
  22. package/dist/autonomous/explicit-planner.js.map +1 -0
  23. package/dist/autonomous/incident-debugger.d.ts +78 -0
  24. package/dist/autonomous/incident-debugger.d.ts.map +1 -0
  25. package/dist/autonomous/incident-debugger.js +324 -0
  26. package/dist/autonomous/incident-debugger.js.map +1 -0
  27. package/dist/autonomous/index.d.ts +15 -0
  28. package/dist/autonomous/index.d.ts.map +1 -0
  29. package/dist/autonomous/index.js +10 -0
  30. package/dist/autonomous/index.js.map +1 -0
  31. package/dist/autonomous/patch-tournament.d.ts +82 -0
  32. package/dist/autonomous/patch-tournament.d.ts.map +1 -0
  33. package/dist/autonomous/patch-tournament.js +150 -0
  34. package/dist/autonomous/patch-tournament.js.map +1 -0
  35. package/dist/autonomous/research-agent.d.ts +66 -0
  36. package/dist/autonomous/research-agent.d.ts.map +1 -0
  37. package/dist/autonomous/research-agent.js +210 -0
  38. package/dist/autonomous/research-agent.js.map +1 -0
  39. package/dist/autonomous/task-memory.d.ts +63 -0
  40. package/dist/autonomous/task-memory.d.ts.map +1 -0
  41. package/dist/autonomous/task-memory.js +143 -0
  42. package/dist/autonomous/task-memory.js.map +1 -0
  43. package/dist/budget-governor-v2.d.ts +93 -0
  44. package/dist/budget-governor-v2.d.ts.map +1 -0
  45. package/dist/budget-governor-v2.js +345 -0
  46. package/dist/budget-governor-v2.js.map +1 -0
  47. package/dist/capability-graph.d.ts +102 -0
  48. package/dist/capability-graph.d.ts.map +1 -0
  49. package/dist/capability-graph.js +397 -0
  50. package/dist/capability-graph.js.map +1 -0
  51. package/dist/capability-self-model.d.ts +144 -0
  52. package/dist/capability-self-model.d.ts.map +1 -0
  53. package/dist/capability-self-model.js +312 -0
  54. package/dist/capability-self-model.js.map +1 -0
  55. package/dist/checkpoint-manager.d.ts +94 -0
  56. package/dist/checkpoint-manager.d.ts.map +1 -0
  57. package/dist/checkpoint-manager.js +225 -0
  58. package/dist/checkpoint-manager.js.map +1 -0
  59. package/dist/continuation-engine.js +1 -1
  60. package/dist/continuation-engine.js.map +1 -1
  61. package/dist/dag-orchestrator.d.ts +0 -3
  62. package/dist/dag-orchestrator.d.ts.map +1 -1
  63. package/dist/dag-orchestrator.js +0 -1
  64. package/dist/dag-orchestrator.js.map +1 -1
  65. package/dist/evidence-chain.d.ts +99 -0
  66. package/dist/evidence-chain.d.ts.map +1 -0
  67. package/dist/evidence-chain.js +200 -0
  68. package/dist/evidence-chain.js.map +1 -0
  69. package/dist/execution-engine.d.ts.map +1 -1
  70. package/dist/execution-engine.js +0 -1
  71. package/dist/execution-engine.js.map +1 -1
  72. package/dist/failure-signature-memory.d.ts +61 -0
  73. package/dist/failure-signature-memory.d.ts.map +1 -0
  74. package/dist/failure-signature-memory.js +278 -0
  75. package/dist/failure-signature-memory.js.map +1 -0
  76. package/dist/index.d.ts +52 -5
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +48 -7
  79. package/dist/index.js.map +1 -1
  80. package/dist/language-detector.d.ts.map +1 -1
  81. package/dist/language-detector.js +122 -43
  82. package/dist/language-detector.js.map +1 -1
  83. package/dist/llm-client.d.ts +0 -7
  84. package/dist/llm-client.d.ts.map +1 -1
  85. package/dist/llm-client.js +15 -122
  86. package/dist/llm-client.js.map +1 -1
  87. package/dist/mcp-client.js +1 -1
  88. package/dist/mcp-client.js.map +1 -1
  89. package/dist/memory.d.ts.map +1 -1
  90. package/dist/memory.js +0 -15
  91. package/dist/memory.js.map +1 -1
  92. package/dist/meta-learning-collector.d.ts +64 -0
  93. package/dist/meta-learning-collector.d.ts.map +1 -0
  94. package/dist/meta-learning-collector.js +169 -0
  95. package/dist/meta-learning-collector.js.map +1 -0
  96. package/dist/meta-learning-engine.d.ts +61 -0
  97. package/dist/meta-learning-engine.d.ts.map +1 -0
  98. package/dist/meta-learning-engine.js +250 -0
  99. package/dist/meta-learning-engine.js.map +1 -0
  100. package/dist/overhead-governor.d.ts +105 -0
  101. package/dist/overhead-governor.d.ts.map +1 -0
  102. package/dist/overhead-governor.js +239 -0
  103. package/dist/overhead-governor.js.map +1 -0
  104. package/dist/playbook-library.d.ts +75 -0
  105. package/dist/playbook-library.d.ts.map +1 -0
  106. package/dist/playbook-library.js +241 -0
  107. package/dist/playbook-library.js.map +1 -0
  108. package/dist/project-executive.d.ts +97 -0
  109. package/dist/project-executive.d.ts.map +1 -0
  110. package/dist/project-executive.js +223 -0
  111. package/dist/project-executive.js.map +1 -0
  112. package/dist/research-loop.d.ts +79 -0
  113. package/dist/research-loop.d.ts.map +1 -0
  114. package/dist/research-loop.js +363 -0
  115. package/dist/research-loop.js.map +1 -0
  116. package/dist/resolve-memory-path.d.ts +32 -0
  117. package/dist/resolve-memory-path.d.ts.map +1 -0
  118. package/dist/resolve-memory-path.js +97 -0
  119. package/dist/resolve-memory-path.js.map +1 -0
  120. package/dist/safe-bounds.d.ts +101 -0
  121. package/dist/safe-bounds.d.ts.map +1 -0
  122. package/dist/safe-bounds.js +140 -0
  123. package/dist/safe-bounds.js.map +1 -0
  124. package/dist/sandbox-tiers.d.ts +5 -0
  125. package/dist/sandbox-tiers.d.ts.map +1 -1
  126. package/dist/sandbox-tiers.js +14 -6
  127. package/dist/sandbox-tiers.js.map +1 -1
  128. package/dist/security.d.ts.map +1 -1
  129. package/dist/security.js +3 -0
  130. package/dist/security.js.map +1 -1
  131. package/dist/self-improvement-loop.d.ts +64 -0
  132. package/dist/self-improvement-loop.d.ts.map +1 -0
  133. package/dist/self-improvement-loop.js +156 -0
  134. package/dist/self-improvement-loop.js.map +1 -0
  135. package/dist/session-persistence.d.ts +5 -0
  136. package/dist/session-persistence.d.ts.map +1 -1
  137. package/dist/session-persistence.js +19 -3
  138. package/dist/session-persistence.js.map +1 -1
  139. package/dist/skill-loader.d.ts +16 -9
  140. package/dist/skill-loader.d.ts.map +1 -1
  141. package/dist/skill-loader.js +52 -116
  142. package/dist/skill-loader.js.map +1 -1
  143. package/dist/skill-registry.d.ts +60 -0
  144. package/dist/skill-registry.d.ts.map +1 -0
  145. package/dist/skill-registry.js +162 -0
  146. package/dist/skill-registry.js.map +1 -0
  147. package/dist/stall-detector.d.ts +56 -0
  148. package/dist/stall-detector.d.ts.map +1 -0
  149. package/dist/stall-detector.js +142 -0
  150. package/dist/stall-detector.js.map +1 -0
  151. package/dist/strategy-learner.d.ts +57 -0
  152. package/dist/strategy-learner.d.ts.map +1 -0
  153. package/dist/strategy-learner.js +160 -0
  154. package/dist/strategy-learner.js.map +1 -0
  155. package/dist/strategy-market.d.ts +73 -0
  156. package/dist/strategy-market.d.ts.map +1 -0
  157. package/dist/strategy-market.js +200 -0
  158. package/dist/strategy-market.js.map +1 -0
  159. package/dist/sub-agent.d.ts +0 -3
  160. package/dist/sub-agent.d.ts.map +1 -1
  161. package/dist/sub-agent.js +0 -10
  162. package/dist/sub-agent.js.map +1 -1
  163. package/dist/system-prompt.d.ts +0 -2
  164. package/dist/system-prompt.d.ts.map +1 -1
  165. package/dist/system-prompt.js +97 -490
  166. package/dist/system-prompt.js.map +1 -1
  167. package/dist/task-classifier.d.ts.map +1 -1
  168. package/dist/task-classifier.js +2 -54
  169. package/dist/task-classifier.js.map +1 -1
  170. package/dist/tool-synthesizer.d.ts +149 -0
  171. package/dist/tool-synthesizer.d.ts.map +1 -0
  172. package/dist/tool-synthesizer.js +455 -0
  173. package/dist/tool-synthesizer.js.map +1 -0
  174. package/dist/trace-pattern-extractor.d.ts +76 -0
  175. package/dist/trace-pattern-extractor.d.ts.map +1 -0
  176. package/dist/trace-pattern-extractor.js +321 -0
  177. package/dist/trace-pattern-extractor.js.map +1 -0
  178. package/dist/trace-recorder.d.ts +38 -0
  179. package/dist/trace-recorder.d.ts.map +1 -0
  180. package/dist/trace-recorder.js +94 -0
  181. package/dist/trace-recorder.js.map +1 -0
  182. package/dist/trust-economics.d.ts +50 -0
  183. package/dist/trust-economics.d.ts.map +1 -0
  184. package/dist/trust-economics.js +148 -0
  185. package/dist/trust-economics.js.map +1 -0
  186. package/dist/types.d.ts +272 -3
  187. package/dist/types.d.ts.map +1 -1
  188. package/dist/types.js.map +1 -1
  189. package/dist/yuan-md-loader.d.ts +22 -0
  190. package/dist/yuan-md-loader.d.ts.map +1 -0
  191. package/dist/yuan-md-loader.js +75 -0
  192. package/dist/yuan-md-loader.js.map +1 -0
  193. package/package.json +1 -1
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @module autonomous/explicit-planner
3
+ * @description ExplicitPlanningEngine — generates an explicit numbered plan before coding
4
+ * and persists it to .yuan/tasks/<taskId>/plan.json.
5
+ *
6
+ * Wraps HierarchicalPlanner: uses its TacticalTask list as plan steps,
7
+ * adds task-level persistence and event emission.
8
+ */
9
+ import { mkdirSync, writeFileSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ import { homedir } from "node:os";
12
+ import { EventEmitter } from "node:events";
13
+ import { randomUUID } from "node:crypto";
14
+ import { HierarchicalPlanner, } from "../hierarchical-planner.js";
15
+ // ─── ExplicitPlanningEngine ──────────────────────────────────────────────────
16
+ export class ExplicitPlanningEngine extends EventEmitter {
17
+ tasksDir;
18
+ projectPath;
19
+ constructor(config = {}) {
20
+ super();
21
+ this.projectPath = config.projectPath ?? process.cwd();
22
+ this.tasksDir = config.tasksDir ?? join(homedir(), ".yuan", "tasks");
23
+ mkdirSync(this.tasksDir, { recursive: true });
24
+ }
25
+ /**
26
+ * Generate an explicit plan for a goal using HierarchicalPlanner.
27
+ * Persists to .yuan/tasks/<taskId>/plan.json and emits agent:plan_generated.
28
+ */
29
+ async plan(goal, llmClient, taskId, context) {
30
+ const resolvedTaskId = taskId ?? randomUUID();
31
+ // Build planner config with required projectPath
32
+ const planner = new HierarchicalPlanner({
33
+ projectPath: this.projectPath,
34
+ maxSubGoals: 10,
35
+ maxTasksPerGoal: 20,
36
+ });
37
+ // Get tactical plan from HierarchicalPlanner
38
+ let tacticalTasks = [];
39
+ try {
40
+ const strategic = await planner.planStrategic(goal, llmClient, context);
41
+ tacticalTasks = await planner.planTactical(strategic, llmClient);
42
+ }
43
+ catch {
44
+ // Fallback: single-step plan if LLM fails
45
+ tacticalTasks = [{
46
+ id: "task-0",
47
+ goalId: "goal-0",
48
+ description: goal,
49
+ targetFiles: [],
50
+ readFiles: [],
51
+ toolStrategy: ["file_read", "file_edit"],
52
+ order: 0,
53
+ dependsOn: [],
54
+ estimatedIterations: 3,
55
+ }];
56
+ }
57
+ // Convert TacticalTask[] to AutonomousPlanStep[] (ordered by .order)
58
+ const sorted = [...tacticalTasks].sort((a, b) => a.order - b.order);
59
+ const steps = sorted.map((t, i) => ({
60
+ index: i,
61
+ description: t.description,
62
+ dependsOn: t.dependsOn
63
+ .map(depId => sorted.findIndex(s => s.id === depId))
64
+ .filter((idx) => idx !== -1),
65
+ targetFiles: t.targetFiles,
66
+ }));
67
+ // Persist to .yuan/tasks/<taskId>/plan.json
68
+ const taskDir = join(this.tasksDir, resolvedTaskId);
69
+ mkdirSync(taskDir, { recursive: true });
70
+ const storedAt = join(taskDir, "plan.json");
71
+ const plan = {
72
+ taskId: resolvedTaskId,
73
+ goal,
74
+ steps,
75
+ createdAt: new Date().toISOString(),
76
+ storedAt,
77
+ };
78
+ writeFileSync(storedAt, JSON.stringify(plan, null, 2), "utf-8");
79
+ // Emit event
80
+ this.emitPlanGenerated(plan);
81
+ return plan;
82
+ }
83
+ // ─── private ───────────────────────────────────────────────────────────────
84
+ emitPlanGenerated(plan) {
85
+ const event = {
86
+ kind: "agent:plan_generated",
87
+ taskId: plan.taskId,
88
+ steps: plan.steps.map(s => ({
89
+ index: s.index,
90
+ description: s.description,
91
+ dependsOn: s.dependsOn,
92
+ })),
93
+ storedAt: plan.storedAt,
94
+ timestamp: Date.now(),
95
+ };
96
+ this.emit("event", event);
97
+ }
98
+ }
99
+ //# sourceMappingURL=explicit-planner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explicit-planner.js","sourceRoot":"","sources":["../../src/autonomous/explicit-planner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,mBAAmB,GAGpB,MAAM,4BAA4B,CAAC;AA+BpC,gFAAgF;AAEhF,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IACrC,QAAQ,CAAS;IACjB,WAAW,CAAS;IAErC,YAAY,SAAgC,EAAE;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,OA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AAE,sBAAsB;YAC5B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC1B,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,SAAS,EAAE,CAAC,CAAC,SAAS;aACvB,CAAC,CAAC;YACH,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module autonomous/incident-debugger
3
+ * @description Incident Debug Mode — analyzes failures using logs, trace history,
4
+ * and recent commits to produce a structured debug report.
5
+ *
6
+ * Input sources:
7
+ * 1. Trace JSONL files from ~/.yuan/traces/
8
+ * 2. Git log + git blame for suspected files
9
+ * 3. Process logs passed in (from caller)
10
+ *
11
+ * Output:
12
+ * { rootCause, suspectedFiles, fixStrategy, confidence }
13
+ *
14
+ * Design:
15
+ * - Pure analysis — does NOT call LLM (deterministic)
16
+ * - All output via agent:debug_report event
17
+ * - Reads trace files via TraceEntry format
18
+ * - Goes through OverheadGovernor (caller checks shouldRunDebugMode())
19
+ */
20
+ import { EventEmitter } from "node:events";
21
+ import type { ToolExecutor } from "../types.js";
22
+ export interface DebugReport {
23
+ taskId: string;
24
+ /** Most likely root cause description */
25
+ rootCause: string;
26
+ /** Files most likely involved in the failure */
27
+ suspectedFiles: string[];
28
+ /** Recommended fix strategy */
29
+ fixStrategy: string;
30
+ /** 0.0–1.0 confidence in this diagnosis */
31
+ confidence: number;
32
+ /** Evidence used to form this report */
33
+ evidence: DebugEvidence[];
34
+ timestamp: number;
35
+ }
36
+ export interface DebugEvidence {
37
+ kind: "trace" | "git_log" | "git_blame" | "log_line";
38
+ content: string;
39
+ weight: number;
40
+ }
41
+ export interface IncidentDebuggerConfig {
42
+ tracesDir?: string;
43
+ projectPath?: string;
44
+ /** Max trace entries to analyze */
45
+ maxTraceEntries?: number;
46
+ /** Max git log lines */
47
+ maxGitLogLines?: number;
48
+ }
49
+ export declare class IncidentDebugger extends EventEmitter {
50
+ private readonly toolExecutor;
51
+ private readonly projectPath;
52
+ private readonly tracesDir;
53
+ private readonly maxTraceEntries;
54
+ private readonly maxGitLogLines;
55
+ constructor(toolExecutor: ToolExecutor, projectPath: string, config?: IncidentDebuggerConfig);
56
+ /**
57
+ * Analyze a failure and produce a debug report.
58
+ *
59
+ * @param errorMessage The error message or stack trace
60
+ * @param sessionId Optional: limit trace analysis to this session
61
+ * @param logs Optional: additional log lines to analyze
62
+ * @param taskId Optional: task ID for correlation
63
+ */
64
+ analyze(errorMessage: string, sessionId?: string, logs?: string[], taskId?: string): Promise<DebugReport>;
65
+ private analyzeTraces;
66
+ private listTraceFiles;
67
+ private readTraceFile;
68
+ private analyzeGitLog;
69
+ private analyzeGitBlame;
70
+ private analyzeLogs;
71
+ private extractSuspectedFiles;
72
+ private inferRootCause;
73
+ private inferFixStrategy;
74
+ private computeConfidence;
75
+ private extractKeywords;
76
+ private emitReport;
77
+ }
78
+ //# sourceMappingURL=incident-debugger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incident-debugger.d.ts","sourceRoot":"","sources":["../../src/autonomous/incident-debugger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAM5D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,+BAA+B;IAC/B,WAAW,EAA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O,CAAC,iBAAiB;IAOzB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,UAAU;CAYnB"}
@@ -0,0 +1,324 @@
1
+ /**
2
+ * @module autonomous/incident-debugger
3
+ * @description Incident Debug Mode — analyzes failures using logs, trace history,
4
+ * and recent commits to produce a structured debug report.
5
+ *
6
+ * Input sources:
7
+ * 1. Trace JSONL files from ~/.yuan/traces/
8
+ * 2. Git log + git blame for suspected files
9
+ * 3. Process logs passed in (from caller)
10
+ *
11
+ * Output:
12
+ * { rootCause, suspectedFiles, fixStrategy, confidence }
13
+ *
14
+ * Design:
15
+ * - Pure analysis — does NOT call LLM (deterministic)
16
+ * - All output via agent:debug_report event
17
+ * - Reads trace files via TraceEntry format
18
+ * - Goes through OverheadGovernor (caller checks shouldRunDebugMode())
19
+ */
20
+ import { readFileSync, readdirSync, statSync } from "node:fs";
21
+ import { join, basename } from "node:path";
22
+ import { homedir } from "node:os";
23
+ import { EventEmitter } from "node:events";
24
+ import { randomUUID } from "node:crypto";
25
+ import { BOUNDS, truncate } from "../safe-bounds.js";
26
+ // ─── IncidentDebugger ─────────────────────────────────────────────────────────
27
+ export class IncidentDebugger extends EventEmitter {
28
+ toolExecutor;
29
+ projectPath;
30
+ tracesDir;
31
+ maxTraceEntries;
32
+ maxGitLogLines;
33
+ constructor(toolExecutor, projectPath, config = {}) {
34
+ super();
35
+ this.toolExecutor = toolExecutor;
36
+ this.projectPath = projectPath;
37
+ this.tracesDir = config.tracesDir ?? join(homedir(), ".yuan", "traces");
38
+ this.maxTraceEntries = config.maxTraceEntries ?? 200;
39
+ this.maxGitLogLines = config.maxGitLogLines ?? 30;
40
+ }
41
+ /**
42
+ * Analyze a failure and produce a debug report.
43
+ *
44
+ * @param errorMessage The error message or stack trace
45
+ * @param sessionId Optional: limit trace analysis to this session
46
+ * @param logs Optional: additional log lines to analyze
47
+ * @param taskId Optional: task ID for correlation
48
+ */
49
+ async analyze(errorMessage, sessionId, logs, taskId) {
50
+ const resolvedTaskId = taskId ?? randomUUID();
51
+ const evidence = [];
52
+ // 1. Analyze trace history
53
+ const traceEvidence = this.analyzeTraces(errorMessage, sessionId);
54
+ evidence.push(...traceEvidence);
55
+ // 2. Analyze git log
56
+ const gitEvidence = await this.analyzeGitLog(errorMessage);
57
+ evidence.push(...gitEvidence);
58
+ // 3. Analyze provided log lines
59
+ if (logs && logs.length > 0) {
60
+ const logEvidence = this.analyzeLogs(logs, errorMessage);
61
+ evidence.push(...logEvidence);
62
+ }
63
+ // 4. Synthesize: extract suspected files + root cause
64
+ const suspectedFiles = this.extractSuspectedFiles(evidence, errorMessage);
65
+ const rootCause = this.inferRootCause(evidence, errorMessage);
66
+ const fixStrategy = this.inferFixStrategy(rootCause, suspectedFiles);
67
+ const confidence = this.computeConfidence(evidence);
68
+ // 5. Git blame on suspected files (best-effort)
69
+ if (suspectedFiles.length > 0) {
70
+ const blameEvidence = await this.analyzeGitBlame(suspectedFiles.slice(0, 3));
71
+ evidence.push(...blameEvidence);
72
+ }
73
+ const report = {
74
+ taskId: resolvedTaskId,
75
+ rootCause,
76
+ suspectedFiles,
77
+ fixStrategy,
78
+ confidence,
79
+ evidence: evidence.slice(0, 50), // cap for storage
80
+ timestamp: Date.now(),
81
+ };
82
+ this.emitReport(report);
83
+ return report;
84
+ }
85
+ // ─── private — Trace Analysis ──────────────────────────────────────────────
86
+ analyzeTraces(errorMessage, sessionId) {
87
+ const evidence = [];
88
+ try {
89
+ // Find most recent trace files (last 3)
90
+ const files = this.listTraceFiles()
91
+ .filter(f => !sessionId || basename(f).includes(sessionId))
92
+ .slice(0, 3);
93
+ for (const file of files) {
94
+ const entries = this.readTraceFile(file);
95
+ // Find error events and the tool calls that preceded them
96
+ const errorEntries = entries.filter(e => e.event.kind === "agent:error" ||
97
+ (e.event.kind === "agent:tool_result" && !e.event.output?.includes("success"))).slice(-10);
98
+ for (const entry of errorEntries) {
99
+ evidence.push({
100
+ kind: "trace",
101
+ content: truncate(JSON.stringify(entry.event), 300),
102
+ weight: 0.7,
103
+ });
104
+ }
105
+ // Find the last phase_transition before error
106
+ const phaseEntries = entries.filter(e => e.event.kind === "agent:phase_transition").slice(-3);
107
+ for (const entry of phaseEntries) {
108
+ evidence.push({
109
+ kind: "trace",
110
+ content: truncate(JSON.stringify(entry.event), 200),
111
+ weight: 0.4,
112
+ });
113
+ }
114
+ }
115
+ }
116
+ catch { /* non-fatal */ }
117
+ return evidence;
118
+ }
119
+ listTraceFiles() {
120
+ try {
121
+ return readdirSync(this.tracesDir)
122
+ .filter(f => f.endsWith(".jsonl"))
123
+ .map(f => join(this.tracesDir, f))
124
+ .sort((a, b) => {
125
+ try {
126
+ return statSync(b).mtimeMs - statSync(a).mtimeMs;
127
+ }
128
+ catch {
129
+ return 0;
130
+ }
131
+ });
132
+ }
133
+ catch {
134
+ return [];
135
+ }
136
+ }
137
+ readTraceFile(filePath) {
138
+ try {
139
+ const raw = readFileSync(filePath, "utf-8");
140
+ return raw.split("\n")
141
+ .filter(Boolean)
142
+ .slice(-this.maxTraceEntries)
143
+ .map(line => {
144
+ try {
145
+ return JSON.parse(line);
146
+ }
147
+ catch {
148
+ return null;
149
+ }
150
+ })
151
+ .filter((e) => e !== null);
152
+ }
153
+ catch {
154
+ return [];
155
+ }
156
+ }
157
+ // ─── private — Git Analysis ────────────────────────────────────────────────
158
+ async analyzeGitLog(errorMessage) {
159
+ const evidence = [];
160
+ try {
161
+ const result = await this.toolExecutor.execute({
162
+ id: `debug-gitlog-${Date.now()}`,
163
+ name: "shell_exec",
164
+ arguments: JSON.stringify({
165
+ command: `git log --oneline -${this.maxGitLogLines} 2>/dev/null`,
166
+ cwd: this.projectPath,
167
+ timeout: 5000,
168
+ }),
169
+ });
170
+ if (result.success && result.output) {
171
+ // Find commits that mention files or keywords from error message
172
+ const keywords = this.extractKeywords(errorMessage);
173
+ const relevantLines = result.output.split("\n")
174
+ .filter(line => keywords.some(kw => line.toLowerCase().includes(kw.toLowerCase())))
175
+ .slice(0, 5);
176
+ for (const line of relevantLines) {
177
+ evidence.push({ kind: "git_log", content: line, weight: 0.6 });
178
+ }
179
+ // Always include the last 3 commits (recent changes = likely culprits)
180
+ const recentLines = result.output.split("\n").filter(Boolean).slice(0, 3);
181
+ for (const line of recentLines) {
182
+ if (!relevantLines.includes(line)) {
183
+ evidence.push({ kind: "git_log", content: line, weight: 0.3 });
184
+ }
185
+ }
186
+ }
187
+ }
188
+ catch { /* non-fatal */ }
189
+ return evidence;
190
+ }
191
+ async analyzeGitBlame(files) {
192
+ const evidence = [];
193
+ for (const file of files) {
194
+ try {
195
+ const result = await this.toolExecutor.execute({
196
+ id: `debug-blame-${Date.now()}`,
197
+ name: "shell_exec",
198
+ arguments: JSON.stringify({
199
+ command: `git log --oneline -5 -- "${file}" 2>/dev/null`,
200
+ cwd: this.projectPath,
201
+ timeout: 5000,
202
+ }),
203
+ });
204
+ if (result.success && result.output.trim()) {
205
+ evidence.push({
206
+ kind: "git_blame",
207
+ content: `${file}:\n${truncate(result.output, 300)}`,
208
+ weight: 0.5,
209
+ });
210
+ }
211
+ }
212
+ catch { /* non-fatal */ }
213
+ }
214
+ return evidence;
215
+ }
216
+ // ─── private — Log Analysis ────────────────────────────────────────────────
217
+ analyzeLogs(logs, errorMessage) {
218
+ const keywords = this.extractKeywords(errorMessage);
219
+ return logs
220
+ .filter(line => keywords.some(kw => line.toLowerCase().includes(kw.toLowerCase()))
221
+ || /error|exception|fail|crash|TypeError|SyntaxError/i.test(line))
222
+ .slice(0, 20)
223
+ .map(line => ({
224
+ kind: "log_line",
225
+ content: truncate(line, 200),
226
+ weight: /error|exception|fail/i.test(line) ? 0.8 : 0.4,
227
+ }));
228
+ }
229
+ // ─── private — Synthesis ─────────────────────────────────────────────────
230
+ extractSuspectedFiles(evidence, errorMessage) {
231
+ const filePattern = /([a-zA-Z0-9_/.-]+\.[a-zA-Z]{2,5})(?::\d+)?/g;
232
+ const files = new Map();
233
+ const allText = [
234
+ errorMessage,
235
+ ...evidence.map(e => e.content),
236
+ ].join("\n");
237
+ let match;
238
+ while ((match = filePattern.exec(allText)) !== null) {
239
+ const f = match[1];
240
+ if (f && !f.includes("node_modules") && f.includes("/")) {
241
+ files.set(f, (files.get(f) ?? 0) + 1);
242
+ }
243
+ }
244
+ return [...files.entries()]
245
+ .sort((a, b) => b[1] - a[1])
246
+ .slice(0, 5)
247
+ .map(([f]) => f);
248
+ }
249
+ inferRootCause(evidence, errorMessage) {
250
+ const errLines = errorMessage.split("\n").filter(Boolean);
251
+ const firstError = errLines[0] ?? "Unknown error";
252
+ // Check for common patterns
253
+ if (/TypeError|is not a function|Cannot read prop/i.test(errorMessage)) {
254
+ return `Type error: ${truncate(firstError, 150)}`;
255
+ }
256
+ if (/SyntaxError|Unexpected token|Cannot parse/i.test(errorMessage)) {
257
+ return `Syntax error: ${truncate(firstError, 150)}`;
258
+ }
259
+ if (/Cannot find module|Module not found/i.test(errorMessage)) {
260
+ return `Missing module: ${truncate(firstError, 150)}`;
261
+ }
262
+ if (/ENOENT|No such file/i.test(errorMessage)) {
263
+ return `Missing file: ${truncate(firstError, 150)}`;
264
+ }
265
+ if (/ECONNREFUSED|connection refused|timeout/i.test(errorMessage)) {
266
+ return `Network/connection failure: ${truncate(firstError, 150)}`;
267
+ }
268
+ // High-weight trace evidence
269
+ const highWeightEvidence = evidence
270
+ .filter(e => e.weight >= 0.7)
271
+ .map(e => e.content.slice(0, 100))
272
+ .slice(0, 2);
273
+ if (highWeightEvidence.length > 0) {
274
+ return `${truncate(firstError, 100)} (from trace: ${highWeightEvidence[0]})`;
275
+ }
276
+ return truncate(firstError, 200);
277
+ }
278
+ inferFixStrategy(rootCause, suspectedFiles) {
279
+ if (/type error/i.test(rootCause)) {
280
+ return `Check type definitions in ${suspectedFiles[0] ?? "the failing file"}. Verify function signatures and null checks.`;
281
+ }
282
+ if (/syntax error/i.test(rootCause)) {
283
+ return `Fix syntax in ${suspectedFiles[0] ?? "the failing file"}. Run: npx tsc --noEmit`;
284
+ }
285
+ if (/missing module/i.test(rootCause)) {
286
+ return `Run: pnpm install. Check that all imports reference existing modules.`;
287
+ }
288
+ if (/missing file/i.test(rootCause)) {
289
+ return `Verify ${suspectedFiles[0] ?? "referenced files"} exist. Check build output directory.`;
290
+ }
291
+ if (/network|connection/i.test(rootCause)) {
292
+ return `Check service availability. Verify environment variables for API keys/URLs.`;
293
+ }
294
+ if (suspectedFiles.length > 0) {
295
+ return `Investigate recent changes to: ${suspectedFiles.slice(0, 3).join(", ")}`;
296
+ }
297
+ return "Review recent commits with: git log --oneline -10. Check error stack trace.";
298
+ }
299
+ computeConfidence(evidence) {
300
+ if (evidence.length === 0)
301
+ return 0.1;
302
+ const avgWeight = evidence.reduce((s, e) => s + e.weight, 0) / evidence.length;
303
+ const coverageFactor = Math.min(evidence.length / 10, 1.0);
304
+ return Math.round(avgWeight * coverageFactor * 100) / 100;
305
+ }
306
+ extractKeywords(text) {
307
+ return text.split(/[\s:.()\n]/)
308
+ .filter(t => t.length > 4 && !/^(error|Error|at|in|the|and|for|with)$/.test(t))
309
+ .slice(0, 8);
310
+ }
311
+ emitReport(report) {
312
+ const event = {
313
+ kind: "agent:debug_report",
314
+ taskId: report.taskId,
315
+ rootCause: truncate(report.rootCause, BOUNDS.toolResultPersistence),
316
+ suspectedFiles: report.suspectedFiles,
317
+ fixStrategy: truncate(report.fixStrategy, 500),
318
+ confidence: report.confidence,
319
+ timestamp: report.timestamp,
320
+ };
321
+ this.emit("event", event);
322
+ }
323
+ }
324
+ //# sourceMappingURL=incident-debugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incident-debugger.js","sourceRoot":"","sources":["../../src/autonomous/incident-debugger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE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AAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC9E,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjB,CAAC;IAEO,UAAU,CAAC,MAAmB;QACpC,MAAM,KAAK,GAAe;YACxB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,qBAAqB,CAAC;YACnE,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC;YAC9C,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module autonomous
3
+ * @description Phase 3 Autonomous Engineering Loop — exports all 5 components.
4
+ */
5
+ export { TaskMemory } from "./task-memory.js";
6
+ export type { TaskState, TaskStatus as AutonomousTaskStatus, TaskPhase as TaskMemoryPhase, EvidenceEntry, } from "./task-memory.js";
7
+ export { ResearchAgent } from "./research-agent.js";
8
+ export type { ResearchResult, ResearchSource, ResearchAgentConfig } from "./research-agent.js";
9
+ export { ExplicitPlanningEngine } from "./explicit-planner.js";
10
+ export type { ExplicitPlan, AutonomousPlanStep, ExplicitPlannerConfig, } from "./explicit-planner.js";
11
+ export { PatchTournamentExecutor } from "./patch-tournament.js";
12
+ export type { TournamentResult, CandidatePatch, RunAgentCallback, PatchTournamentConfig, } from "./patch-tournament.js";
13
+ export { IncidentDebugger } from "./incident-debugger.js";
14
+ export type { DebugReport, DebugEvidence, IncidentDebuggerConfig } from "./incident-debugger.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/autonomous/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACV,SAAS,EACT,UAAU,IAAI,oBAAoB,EAClC,SAAS,IAAI,eAAe,EAC5B,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @module autonomous
3
+ * @description Phase 3 Autonomous Engineering Loop — exports all 5 components.
4
+ */
5
+ export { TaskMemory } from "./task-memory.js";
6
+ export { ResearchAgent } from "./research-agent.js";
7
+ export { ExplicitPlanningEngine } from "./explicit-planner.js";
8
+ export { PatchTournamentExecutor } from "./patch-tournament.js";
9
+ export { IncidentDebugger } from "./incident-debugger.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/autonomous/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQ9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAO/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAQhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @module autonomous/patch-tournament
3
+ * @description Patch Tournament Executor — generates N candidate patches for a goal,
4
+ * scores each with the QA pipeline, and selects the best.
5
+ *
6
+ * Design:
7
+ * - Takes a "run agent" callback (injected from CLI — keeps this module pure)
8
+ * - Runs candidates sequentially (not parallel) to avoid file conflicts
9
+ * - Scores via QAPipeline + diff stats from evidence history
10
+ * - Emits agent:tournament_result with winner index
11
+ *
12
+ * Constraints:
13
+ * - Does NOT touch the main agent loop (deterministic)
14
+ * - All scoring goes through QAPipeline (no bypass)
15
+ * - Goes through OverheadGovernor (caller must check shouldRunTournament())
16
+ * - Emits events at every candidate + final result
17
+ */
18
+ import { EventEmitter } from "node:events";
19
+ import { type QAPipelineResult, type QAPipelineConfig } from "../qa-pipeline.js";
20
+ export interface CandidatePatch {
21
+ /** 0-based index */
22
+ index: number;
23
+ /** Strategy hint passed to the agent run */
24
+ strategy: string;
25
+ /** Files changed by this candidate */
26
+ filesChanged: string[];
27
+ /** QA result */
28
+ qaResult: QAPipelineResult | null;
29
+ /** Composite score 0.0–1.0 (higher = better) */
30
+ score: number;
31
+ /** Human-readable explanation */
32
+ reason: string;
33
+ }
34
+ export interface TournamentResult {
35
+ taskId: string;
36
+ goal: string;
37
+ /** 0-based index of the winner */
38
+ winner: number;
39
+ candidates: CandidatePatch[];
40
+ /** Quality score of winner */
41
+ qualityScore: number;
42
+ timestamp: number;
43
+ }
44
+ /**
45
+ * Callback the CLI provides to run a single agent attempt.
46
+ * Returns the list of files changed by this run.
47
+ */
48
+ export type RunAgentCallback = (goal: string, strategy: string, candidateIndex: number) => Promise<string[]>;
49
+ export interface PatchTournamentConfig {
50
+ /** Number of candidate patches to generate (default: 3) */
51
+ candidates?: number;
52
+ /** Strategies to use for each candidate (must match candidates count) */
53
+ strategies?: string[];
54
+ /** QA config for scoring */
55
+ qaConfig?: Partial<QAPipelineConfig>;
56
+ /** Project path for QA pipeline */
57
+ projectPath?: string;
58
+ }
59
+ export declare class PatchTournamentExecutor extends EventEmitter {
60
+ private readonly config;
61
+ constructor(config?: PatchTournamentConfig);
62
+ /**
63
+ * Run the tournament. For each candidate:
64
+ * 1. Call runAgent() to generate a patch
65
+ * 2. Score with QAPipeline
66
+ * 3. Track best
67
+ *
68
+ * Returns TournamentResult with winner index.
69
+ * Emits agent:tournament_result at completion.
70
+ *
71
+ * NOTE: The CLI is responsible for:
72
+ * - Stashing current git state before the first candidate
73
+ * - Restoring baseline between candidates (git stash pop + git stash)
74
+ * - Applying the winner's patch after selection
75
+ */
76
+ run(goal: string, runAgent: RunAgentCallback, taskId?: string): Promise<TournamentResult>;
77
+ private defaultStrategies;
78
+ private describeScore;
79
+ private emitProgress;
80
+ private emitResult;
81
+ }
82
+ //# sourceMappingURL=patch-tournament.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-tournament.d.ts","sourceRoot":"","sources":["../../src/autonomous/patch-tournament.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAc,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAK7F,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB;IAChB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,MAAM,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