agent-nuvira 1.14.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.
- package/LICENSE +21 -0
- package/README.md +891 -0
- package/dist/agent-sdk/src/agent.d.ts +118 -0
- package/dist/agent-sdk/src/agent.d.ts.map +1 -0
- package/dist/agent-sdk/src/agent.js +88 -0
- package/dist/agent-sdk/src/agent.js.map +1 -0
- package/dist/agent-sdk/src/index.d.ts +33 -0
- package/dist/agent-sdk/src/index.d.ts.map +1 -0
- package/dist/agent-sdk/src/index.js +32 -0
- package/dist/agent-sdk/src/index.js.map +1 -0
- package/dist/agent-sdk/src/register.d.ts +70 -0
- package/dist/agent-sdk/src/register.d.ts.map +1 -0
- package/dist/agent-sdk/src/register.js +181 -0
- package/dist/agent-sdk/src/register.js.map +1 -0
- package/dist/agent-sdk/src/scaffold.d.ts +50 -0
- package/dist/agent-sdk/src/scaffold.d.ts.map +1 -0
- package/dist/agent-sdk/src/scaffold.js +291 -0
- package/dist/agent-sdk/src/scaffold.js.map +1 -0
- package/dist/agent-sdk/src/testing.d.ts +187 -0
- package/dist/agent-sdk/src/testing.d.ts.map +1 -0
- package/dist/agent-sdk/src/testing.js +243 -0
- package/dist/agent-sdk/src/testing.js.map +1 -0
- package/dist/agent-sdk/src/types.d.ts +202 -0
- package/dist/agent-sdk/src/types.d.ts.map +1 -0
- package/dist/agent-sdk/src/types.js +11 -0
- package/dist/agent-sdk/src/types.js.map +1 -0
- package/dist/agents/agent.d.ts +132 -0
- package/dist/agents/agent.d.ts.map +1 -0
- package/dist/agents/agent.js +19 -0
- package/dist/agents/agent.js.map +1 -0
- package/dist/agents/agents/context-gatherer.d.ts +42 -0
- package/dist/agents/agents/context-gatherer.d.ts.map +1 -0
- package/dist/agents/agents/context-gatherer.js +366 -0
- package/dist/agents/agents/context-gatherer.js.map +1 -0
- package/dist/agents/agents/debugger.d.ts +58 -0
- package/dist/agents/agents/debugger.d.ts.map +1 -0
- package/dist/agents/agents/debugger.js +257 -0
- package/dist/agents/agents/debugger.js.map +1 -0
- package/dist/agents/agents/git-agent.d.ts +34 -0
- package/dist/agents/agents/git-agent.d.ts.map +1 -0
- package/dist/agents/agents/git-agent.js +200 -0
- package/dist/agents/agents/git-agent.js.map +1 -0
- package/dist/agents/agents/github-release-agent.d.ts +65 -0
- package/dist/agents/agents/github-release-agent.d.ts.map +1 -0
- package/dist/agents/agents/github-release-agent.js +439 -0
- package/dist/agents/agents/github-release-agent.js.map +1 -0
- package/dist/agents/agents/package-agent.d.ts +33 -0
- package/dist/agents/agents/package-agent.d.ts.map +1 -0
- package/dist/agents/agents/package-agent.js +233 -0
- package/dist/agents/agents/package-agent.js.map +1 -0
- package/dist/agents/agents/planner.d.ts +26 -0
- package/dist/agents/agents/planner.d.ts.map +1 -0
- package/dist/agents/agents/planner.js +222 -0
- package/dist/agents/agents/planner.js.map +1 -0
- package/dist/agents/agents/reviewer.d.ts +34 -0
- package/dist/agents/agents/reviewer.d.ts.map +1 -0
- package/dist/agents/agents/reviewer.js +159 -0
- package/dist/agents/agents/reviewer.js.map +1 -0
- package/dist/agents/agents/runner.d.ts +73 -0
- package/dist/agents/agents/runner.d.ts.map +1 -0
- package/dist/agents/agents/runner.js +299 -0
- package/dist/agents/agents/runner.js.map +1 -0
- package/dist/agents/agents/security-agent.d.ts +33 -0
- package/dist/agents/agents/security-agent.d.ts.map +1 -0
- package/dist/agents/agents/security-agent.js +184 -0
- package/dist/agents/agents/security-agent.js.map +1 -0
- package/dist/agents/agents/tester.d.ts +96 -0
- package/dist/agents/agents/tester.d.ts.map +1 -0
- package/dist/agents/agents/tester.js +410 -0
- package/dist/agents/agents/tester.js.map +1 -0
- package/dist/agents/agents/writer.d.ts +51 -0
- package/dist/agents/agents/writer.d.ts.map +1 -0
- package/dist/agents/agents/writer.js +384 -0
- package/dist/agents/agents/writer.js.map +1 -0
- package/dist/agents/context-vault.d.ts +49 -0
- package/dist/agents/context-vault.d.ts.map +1 -0
- package/dist/agents/context-vault.js +134 -0
- package/dist/agents/context-vault.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +97 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +696 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/utils/file-tree.d.ts +28 -0
- package/dist/agents/utils/file-tree.d.ts.map +1 -0
- package/dist/agents/utils/file-tree.js +93 -0
- package/dist/agents/utils/file-tree.js.map +1 -0
- package/dist/cli/agent.d.ts +25 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +374 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/benchmark.d.ts +24 -0
- package/dist/cli/benchmark.d.ts.map +1 -0
- package/dist/cli/benchmark.js +235 -0
- package/dist/cli/benchmark.js.map +1 -0
- package/dist/cli/cache.d.ts +12 -0
- package/dist/cli/cache.d.ts.map +1 -0
- package/dist/cli/cache.js +58 -0
- package/dist/cli/cache.js.map +1 -0
- package/dist/cli/chat.d.ts +37 -0
- package/dist/cli/chat.d.ts.map +1 -0
- package/dist/cli/chat.js +393 -0
- package/dist/cli/chat.js.map +1 -0
- package/dist/cli/commands.d.ts +24 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +18 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/config.d.ts +19 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +162 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/dashboard.d.ts +34 -0
- package/dist/cli/dashboard.d.ts.map +1 -0
- package/dist/cli/dashboard.js +126 -0
- package/dist/cli/dashboard.js.map +1 -0
- package/dist/cli/doctor.d.ts +68 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +585 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/edit.d.ts +11 -0
- package/dist/cli/edit.d.ts.map +1 -0
- package/dist/cli/edit.js +86 -0
- package/dist/cli/edit.js.map +1 -0
- package/dist/cli/execute.d.ts +25 -0
- package/dist/cli/execute.d.ts.map +1 -0
- package/dist/cli/execute.js +186 -0
- package/dist/cli/execute.js.map +1 -0
- package/dist/cli/federation.d.ts +31 -0
- package/dist/cli/federation.d.ts.map +1 -0
- package/dist/cli/federation.js +387 -0
- package/dist/cli/federation.js.map +1 -0
- package/dist/cli/history.d.ts +22 -0
- package/dist/cli/history.d.ts.map +1 -0
- package/dist/cli/history.js +140 -0
- package/dist/cli/history.js.map +1 -0
- package/dist/cli/init.d.ts +49 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +423 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/learn.d.ts +31 -0
- package/dist/cli/learn.d.ts.map +1 -0
- package/dist/cli/learn.js +320 -0
- package/dist/cli/learn.js.map +1 -0
- package/dist/cli/memory.d.ts +38 -0
- package/dist/cli/memory.d.ts.map +1 -0
- package/dist/cli/memory.js +295 -0
- package/dist/cli/memory.js.map +1 -0
- package/dist/cli/model-picker.d.ts +18 -0
- package/dist/cli/model-picker.d.ts.map +1 -0
- package/dist/cli/model-picker.js +225 -0
- package/dist/cli/model-picker.js.map +1 -0
- package/dist/cli/models.d.ts +11 -0
- package/dist/cli/models.d.ts.map +1 -0
- package/dist/cli/models.js +132 -0
- package/dist/cli/models.js.map +1 -0
- package/dist/cli/plan.d.ts +11 -0
- package/dist/cli/plan.d.ts.map +1 -0
- package/dist/cli/plan.js +94 -0
- package/dist/cli/plan.js.map +1 -0
- package/dist/cli/plugins.d.ts +15 -0
- package/dist/cli/plugins.d.ts.map +1 -0
- package/dist/cli/plugins.js +123 -0
- package/dist/cli/plugins.js.map +1 -0
- package/dist/cli/router.d.ts +20 -0
- package/dist/cli/router.d.ts.map +1 -0
- package/dist/cli/router.js +142 -0
- package/dist/cli/router.js.map +1 -0
- package/dist/cli/run.d.ts +22 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +110 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/sandbox.d.ts +27 -0
- package/dist/cli/sandbox.d.ts.map +1 -0
- package/dist/cli/sandbox.js +264 -0
- package/dist/cli/sandbox.js.map +1 -0
- package/dist/cli/sdk.d.ts +27 -0
- package/dist/cli/sdk.d.ts.map +1 -0
- package/dist/cli/sdk.js +204 -0
- package/dist/cli/sdk.js.map +1 -0
- package/dist/cli/stats.d.ts +18 -0
- package/dist/cli/stats.d.ts.map +1 -0
- package/dist/cli/stats.js +78 -0
- package/dist/cli/stats.js.map +1 -0
- package/dist/cli/team.d.ts +42 -0
- package/dist/cli/team.d.ts.map +1 -0
- package/dist/cli/team.js +473 -0
- package/dist/cli/team.js.map +1 -0
- package/dist/cli/workflow.d.ts +27 -0
- package/dist/cli/workflow.d.ts.map +1 -0
- package/dist/cli/workflow.js +347 -0
- package/dist/cli/workflow.js.map +1 -0
- package/dist/config/manager.d.ts +37 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/manager.js +147 -0
- package/dist/config/manager.js.map +1 -0
- package/dist/config/types.d.ts +53 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/context/cache.d.ts +27 -0
- package/dist/context/cache.d.ts.map +1 -0
- package/dist/context/cache.js +116 -0
- package/dist/context/cache.js.map +1 -0
- package/dist/context/history.d.ts +87 -0
- package/dist/context/history.d.ts.map +1 -0
- package/dist/context/history.js +249 -0
- package/dist/context/history.js.map +1 -0
- package/dist/context/parser.d.ts +61 -0
- package/dist/context/parser.d.ts.map +1 -0
- package/dist/context/parser.js +194 -0
- package/dist/context/parser.js.map +1 -0
- package/dist/federation/client.d.ts +49 -0
- package/dist/federation/client.d.ts.map +1 -0
- package/dist/federation/client.js +239 -0
- package/dist/federation/client.js.map +1 -0
- package/dist/federation/protocol.d.ts +155 -0
- package/dist/federation/protocol.d.ts.map +1 -0
- package/dist/federation/protocol.js +57 -0
- package/dist/federation/protocol.js.map +1 -0
- package/dist/federation/server.d.ts +25 -0
- package/dist/federation/server.d.ts.map +1 -0
- package/dist/federation/server.js +401 -0
- package/dist/federation/server.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/inference/factory.d.ts +20 -0
- package/dist/inference/factory.d.ts.map +1 -0
- package/dist/inference/factory.js +46 -0
- package/dist/inference/factory.js.map +1 -0
- package/dist/inference/gemini-adapter.d.ts +17 -0
- package/dist/inference/gemini-adapter.d.ts.map +1 -0
- package/dist/inference/gemini-adapter.js +176 -0
- package/dist/inference/gemini-adapter.js.map +1 -0
- package/dist/inference/groq-adapter.d.ts +17 -0
- package/dist/inference/groq-adapter.d.ts.map +1 -0
- package/dist/inference/groq-adapter.js +103 -0
- package/dist/inference/groq-adapter.js.map +1 -0
- package/dist/inference/interface.d.ts +49 -0
- package/dist/inference/interface.d.ts.map +1 -0
- package/dist/inference/interface.js +2 -0
- package/dist/inference/interface.js.map +1 -0
- package/dist/inference/local-adapter.d.ts +35 -0
- package/dist/inference/local-adapter.d.ts.map +1 -0
- package/dist/inference/local-adapter.js +311 -0
- package/dist/inference/local-adapter.js.map +1 -0
- package/dist/inference/model-catalog.d.ts +53 -0
- package/dist/inference/model-catalog.d.ts.map +1 -0
- package/dist/inference/model-catalog.js +306 -0
- package/dist/inference/model-catalog.js.map +1 -0
- package/dist/inference/nim-adapter.d.ts +17 -0
- package/dist/inference/nim-adapter.d.ts.map +1 -0
- package/dist/inference/nim-adapter.js +103 -0
- package/dist/inference/nim-adapter.js.map +1 -0
- package/dist/inference/openrouter-adapter.d.ts +17 -0
- package/dist/inference/openrouter-adapter.d.ts.map +1 -0
- package/dist/inference/openrouter-adapter.js +105 -0
- package/dist/inference/openrouter-adapter.js.map +1 -0
- package/dist/inference/sse.d.ts +20 -0
- package/dist/inference/sse.d.ts.map +1 -0
- package/dist/inference/sse.js +91 -0
- package/dist/inference/sse.js.map +1 -0
- package/dist/learning/agent-stats.d.ts +109 -0
- package/dist/learning/agent-stats.d.ts.map +1 -0
- package/dist/learning/agent-stats.js +240 -0
- package/dist/learning/agent-stats.js.map +1 -0
- package/dist/learning/benchmark.d.ts +161 -0
- package/dist/learning/benchmark.d.ts.map +1 -0
- package/dist/learning/benchmark.js +589 -0
- package/dist/learning/benchmark.js.map +1 -0
- package/dist/learning/cost-tracker.d.ts +101 -0
- package/dist/learning/cost-tracker.d.ts.map +1 -0
- package/dist/learning/cost-tracker.js +224 -0
- package/dist/learning/cost-tracker.js.map +1 -0
- package/dist/learning/feedback.d.ts +88 -0
- package/dist/learning/feedback.d.ts.map +1 -0
- package/dist/learning/feedback.js +169 -0
- package/dist/learning/feedback.js.map +1 -0
- package/dist/learning/hybrid-router.d.ts +201 -0
- package/dist/learning/hybrid-router.d.ts.map +1 -0
- package/dist/learning/hybrid-router.js +450 -0
- package/dist/learning/hybrid-router.js.map +1 -0
- package/dist/learning/model-compare.d.ts +76 -0
- package/dist/learning/model-compare.d.ts.map +1 -0
- package/dist/learning/model-compare.js +252 -0
- package/dist/learning/model-compare.js.map +1 -0
- package/dist/learning/model-router.d.ts +68 -0
- package/dist/learning/model-router.d.ts.map +1 -0
- package/dist/learning/model-router.js +140 -0
- package/dist/learning/model-router.js.map +1 -0
- package/dist/learning/pattern-extractor.d.ts +99 -0
- package/dist/learning/pattern-extractor.d.ts.map +1 -0
- package/dist/learning/pattern-extractor.js +310 -0
- package/dist/learning/pattern-extractor.js.map +1 -0
- package/dist/learning/scorer.d.ts +51 -0
- package/dist/learning/scorer.d.ts.map +1 -0
- package/dist/learning/scorer.js +64 -0
- package/dist/learning/scorer.js.map +1 -0
- package/dist/learning/self-improver.d.ts +48 -0
- package/dist/learning/self-improver.d.ts.map +1 -0
- package/dist/learning/self-improver.js +161 -0
- package/dist/learning/self-improver.js.map +1 -0
- package/dist/memory/embedder.d.ts +65 -0
- package/dist/memory/embedder.d.ts.map +1 -0
- package/dist/memory/embedder.js +424 -0
- package/dist/memory/embedder.js.map +1 -0
- package/dist/memory/memory-integration.d.ts +56 -0
- package/dist/memory/memory-integration.d.ts.map +1 -0
- package/dist/memory/memory-integration.js +95 -0
- package/dist/memory/memory-integration.js.map +1 -0
- package/dist/memory/trajectory-store.d.ts +149 -0
- package/dist/memory/trajectory-store.d.ts.map +1 -0
- package/dist/memory/trajectory-store.js +476 -0
- package/dist/memory/trajectory-store.js.map +1 -0
- package/dist/memory/vector-store.d.ts +78 -0
- package/dist/memory/vector-store.d.ts.map +1 -0
- package/dist/memory/vector-store.js +186 -0
- package/dist/memory/vector-store.js.map +1 -0
- package/dist/plugins/agent-plugin.d.ts +73 -0
- package/dist/plugins/agent-plugin.d.ts.map +1 -0
- package/dist/plugins/agent-plugin.js +199 -0
- package/dist/plugins/agent-plugin.js.map +1 -0
- package/dist/plugins/registry.d.ts +61 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +67 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/sandbox/images.d.ts +31 -0
- package/dist/sandbox/images.d.ts.map +1 -0
- package/dist/sandbox/images.js +129 -0
- package/dist/sandbox/images.js.map +1 -0
- package/dist/sandbox/manager.d.ts +134 -0
- package/dist/sandbox/manager.d.ts.map +1 -0
- package/dist/sandbox/manager.js +470 -0
- package/dist/sandbox/manager.js.map +1 -0
- package/dist/sandbox/types.d.ts +113 -0
- package/dist/sandbox/types.d.ts.map +1 -0
- package/dist/sandbox/types.js +107 -0
- package/dist/sandbox/types.js.map +1 -0
- package/dist/security/scanner.d.ts +53 -0
- package/dist/security/scanner.d.ts.map +1 -0
- package/dist/security/scanner.js +271 -0
- package/dist/security/scanner.js.map +1 -0
- package/dist/team/config.d.ts +50 -0
- package/dist/team/config.d.ts.map +1 -0
- package/dist/team/config.js +108 -0
- package/dist/team/config.js.map +1 -0
- package/dist/team/memory.d.ts +63 -0
- package/dist/team/memory.d.ts.map +1 -0
- package/dist/team/memory.js +282 -0
- package/dist/team/memory.js.map +1 -0
- package/dist/team/review.d.ts +123 -0
- package/dist/team/review.d.ts.map +1 -0
- package/dist/team/review.js +293 -0
- package/dist/team/review.js.map +1 -0
- package/dist/utils/env.d.ts +19 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +250 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +45 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/web-dashboard/server.d.ts +59 -0
- package/dist/web-dashboard/server.d.ts.map +1 -0
- package/dist/web-dashboard/server.js +418 -0
- package/dist/web-dashboard/server.js.map +1 -0
- package/dist/workflow/registry.d.ts +127 -0
- package/dist/workflow/registry.d.ts.map +1 -0
- package/dist/workflow/registry.js +482 -0
- package/dist/workflow/registry.js.map +1 -0
- package/dist/workflow/templates.d.ts +93 -0
- package/dist/workflow/templates.d.ts.map +1 -0
- package/dist/workflow/templates.js +481 -0
- package/dist/workflow/templates.js.map +1 -0
- package/package.json +78 -0
- package/src/web-dashboard/public/assets/index-B08nDkSB.css +1 -0
- package/src/web-dashboard/public/assets/index-BKL8YOFD.js +135 -0
- package/src/web-dashboard/public/assets/index-BKL8YOFD.js.map +1 -0
- package/src/web-dashboard/public/index.html +13 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContextGathererAgent — Scans the codebase to find files relevant to the user's
|
|
3
|
+
* goal and execution plan. It reads file contents and stores them as artifacts
|
|
4
|
+
* in the shared context bus for downstream agents (Writer, Reviewer) to use.
|
|
5
|
+
*
|
|
6
|
+
* Rate-limit handling:
|
|
7
|
+
* - Short waits (<3s): auto-retry silently
|
|
8
|
+
* - Long waits (>=3s): invokes onRateLimit callback (if available) to let the
|
|
9
|
+
* user choose: wait, switch model, skip (falls back to keyword scan), or abort
|
|
10
|
+
* - Other LLM errors: caught gracefully, falls back to keyword scanning
|
|
11
|
+
*/
|
|
12
|
+
import { Agent, type AgentContext, type AgentResult } from '../agent.js';
|
|
13
|
+
import type { LLMCallFn } from '../agent.js';
|
|
14
|
+
/**
|
|
15
|
+
* ContextGathererAgent — Discovers and reads relevant files from the codebase.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ContextGathererAgent extends Agent {
|
|
18
|
+
readonly name = "Context Gatherer";
|
|
19
|
+
readonly description = "Scans the codebase and identifies relevant files";
|
|
20
|
+
execute(context: AgentContext, callLLM: LLMCallFn): Promise<AgentResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Call identifyRelevantFiles with a retry loop that handles rate-limit errors
|
|
23
|
+
* via the onRateLimit callback.
|
|
24
|
+
*/
|
|
25
|
+
private identifyWithRetry;
|
|
26
|
+
/**
|
|
27
|
+
* Ask the LLM to identify which files are relevant to the goal.
|
|
28
|
+
* Non-rate-limit errors are caught internally (falls back to keyword scanning).
|
|
29
|
+
* Rate-limit errors are re-thrown so identifyWithRetry can handle them.
|
|
30
|
+
*/
|
|
31
|
+
private identifyRelevantFiles;
|
|
32
|
+
/**
|
|
33
|
+
* Extract an array of file paths from the LLM response.
|
|
34
|
+
*/
|
|
35
|
+
private extractPaths;
|
|
36
|
+
private tryParseJson;
|
|
37
|
+
/** Fallback keyword-based file scanning when LLM is unavailable */
|
|
38
|
+
private scanByKeywords;
|
|
39
|
+
private walkAndScore;
|
|
40
|
+
private formatSize;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=context-gatherer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-gatherer.d.ts","sourceRoot":"","sources":["../../../src/agents/agents/context-gatherer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AACxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAqD7C;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,WAAW,sDAAsD;IAEpE,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IA8E9E;;;OAGG;YACW,iBAAiB;IA+F/B;;;;OAIG;YACW,qBAAqB;IAoDnC;;OAEG;IACH,OAAO,CAAC,YAAY;IAiCpB,OAAO,CAAC,YAAY;IAYpB,mEAAmE;IACnE,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,YAAY;IAgDpB,OAAO,CAAC,UAAU;CAKnB"}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContextGathererAgent — Scans the codebase to find files relevant to the user's
|
|
3
|
+
* goal and execution plan. It reads file contents and stores them as artifacts
|
|
4
|
+
* in the shared context bus for downstream agents (Writer, Reviewer) to use.
|
|
5
|
+
*
|
|
6
|
+
* Rate-limit handling:
|
|
7
|
+
* - Short waits (<3s): auto-retry silently
|
|
8
|
+
* - Long waits (>=3s): invokes onRateLimit callback (if available) to let the
|
|
9
|
+
* user choose: wait, switch model, skip (falls back to keyword scan), or abort
|
|
10
|
+
* - Other LLM errors: caught gracefully, falls back to keyword scanning
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync, statSync, readdirSync } from 'node:fs';
|
|
13
|
+
import { join, relative } from 'node:path';
|
|
14
|
+
import { Agent } from '../agent.js';
|
|
15
|
+
import { buildProjectFileTree, truncateTree } from '../utils/file-tree.js';
|
|
16
|
+
import { logger } from '../../utils/logger.js';
|
|
17
|
+
/** File extensions we consider as source code */
|
|
18
|
+
const SOURCE_EXTENSIONS = new Set([
|
|
19
|
+
'.ts', '.js', '.tsx', '.jsx',
|
|
20
|
+
'.go', '.py', '.rs', '.rb', '.java', '.kt',
|
|
21
|
+
'.json', '.yaml', '.yml', '.md', '.toml', '.xml',
|
|
22
|
+
'.css', '.scss', '.html', '.vue', '.svelte',
|
|
23
|
+
]);
|
|
24
|
+
/** Directories to skip during traversal */
|
|
25
|
+
const IGNORE_DIRS = new Set([
|
|
26
|
+
'node_modules', '.git', 'dist', 'build', '.next',
|
|
27
|
+
'.cache', 'coverage', '.nyc_output', '__pycache__',
|
|
28
|
+
'.venv', 'venv', '.env',
|
|
29
|
+
]);
|
|
30
|
+
/** Maximum number of API retry attempts for transient LLM failures (rate limits, timeouts) */
|
|
31
|
+
const MAX_API_RETRIES = 2;
|
|
32
|
+
/** Base delay for exponential backoff in milliseconds (doubles each retry: 5s, 10s) */
|
|
33
|
+
const BASE_RETRY_DELAY_MS = 5000;
|
|
34
|
+
/** Threshold above which we consider a rate-limit wait "long" and prompt the user. */
|
|
35
|
+
const LONG_WAIT_THRESHOLD_MS = 3000;
|
|
36
|
+
// ─── Rate-limit Helpers ────────────────────────────────────────────────────
|
|
37
|
+
function parseRetryAfterHint(errorMessage) {
|
|
38
|
+
const secondMatch = errorMessage.match(/try again in ([\d.]+)s/i);
|
|
39
|
+
if (secondMatch) {
|
|
40
|
+
const seconds = parseFloat(secondMatch[1]);
|
|
41
|
+
if (!isNaN(seconds) && seconds > 0)
|
|
42
|
+
return Math.ceil(seconds * 1000);
|
|
43
|
+
}
|
|
44
|
+
const msMatch = errorMessage.match(/try again in (\d+)ms/i);
|
|
45
|
+
if (msMatch) {
|
|
46
|
+
const ms = parseInt(msMatch[1], 10);
|
|
47
|
+
if (!isNaN(ms) && ms > 0)
|
|
48
|
+
return ms;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function parseModelName(errorMessage) {
|
|
53
|
+
const match = errorMessage.match(/model\s+`([^`]+)`|model\s+'([^']+)'|model\s+([^\s]+)/i);
|
|
54
|
+
return match?.[1] || match?.[2] || match?.[3] || undefined;
|
|
55
|
+
}
|
|
56
|
+
function isRateLimitError(errorMessage) {
|
|
57
|
+
return /rate\s*limit|429|too many requests|try again in/i.test(errorMessage);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* ContextGathererAgent — Discovers and reads relevant files from the codebase.
|
|
61
|
+
*/
|
|
62
|
+
export class ContextGathererAgent extends Agent {
|
|
63
|
+
name = 'Context Gatherer';
|
|
64
|
+
description = 'Scans the codebase and identifies relevant files';
|
|
65
|
+
async execute(context, callLLM) {
|
|
66
|
+
try {
|
|
67
|
+
// 1. Get a broad overview of the project structure
|
|
68
|
+
const fileTree = await buildProjectFileTree(context.workingDirectory);
|
|
69
|
+
// 2. Ask the LLM which files are relevant — with retry and rate-limit handling
|
|
70
|
+
const { paths: relevantPaths, llmError } = await this.identifyWithRetry(context, fileTree, callLLM);
|
|
71
|
+
// 3. Fallback: if LLM returned nothing or errored, try keyword scanning
|
|
72
|
+
if (llmError) {
|
|
73
|
+
logger.debug(`LLM call failed: ${llmError}`);
|
|
74
|
+
}
|
|
75
|
+
let effectivePaths = relevantPaths;
|
|
76
|
+
if (relevantPaths.length === 0) {
|
|
77
|
+
if (llmError) {
|
|
78
|
+
logger.warn(` LLM error: ${llmError}`);
|
|
79
|
+
}
|
|
80
|
+
effectivePaths = this.scanByKeywords(context.goal, context.workingDirectory);
|
|
81
|
+
}
|
|
82
|
+
// 4. Read the identified files
|
|
83
|
+
const artifacts = [];
|
|
84
|
+
const errors = [];
|
|
85
|
+
if (llmError && effectivePaths.length > 0) {
|
|
86
|
+
logger.debug(`Keywords matched ${effectivePaths.length} file(s) after LLM error`);
|
|
87
|
+
}
|
|
88
|
+
for (const filePath of effectivePaths) {
|
|
89
|
+
const absolutePath = join(context.workingDirectory, filePath);
|
|
90
|
+
if (!existsSync(absolutePath) || !statSync(absolutePath).isFile()) {
|
|
91
|
+
errors.push(`File not found: ${filePath}`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const content = readFileSync(absolutePath, 'utf-8');
|
|
96
|
+
artifacts.push({
|
|
97
|
+
path: filePath,
|
|
98
|
+
content,
|
|
99
|
+
description: `${filePath} (${this.formatSize(content.length)} characters)`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
errors.push(`Could not read: ${filePath}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// 5. Store artifacts in the shared context
|
|
107
|
+
context.artifacts.push(...artifacts);
|
|
108
|
+
const details = artifacts.length > 0
|
|
109
|
+
? artifacts.map((a) => ` \u{1F4C4} ${a.path}`).join('\n')
|
|
110
|
+
: undefined;
|
|
111
|
+
const resultSummary = artifacts.length > 0
|
|
112
|
+
? `Gathered ${artifacts.length} file${artifacts.length !== 1 ? 's' : ''}`
|
|
113
|
+
: `No relevant files found${errors.length > 0 ? ` (${errors.length} errors while scanning)` : ''}`;
|
|
114
|
+
return {
|
|
115
|
+
success: true,
|
|
116
|
+
summary: resultSummary,
|
|
117
|
+
details,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
summary: 'Context gathering failed',
|
|
125
|
+
error: msg,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Call identifyRelevantFiles with a retry loop that handles rate-limit errors
|
|
131
|
+
* via the onRateLimit callback.
|
|
132
|
+
*/
|
|
133
|
+
async identifyWithRetry(context, fileTree, callLLM) {
|
|
134
|
+
let latestCallLLM = callLLM;
|
|
135
|
+
let lastError;
|
|
136
|
+
for (let attempt = 0; attempt <= MAX_API_RETRIES; attempt++) {
|
|
137
|
+
try {
|
|
138
|
+
// identifyRelevantFiles re-throws rate-limit errors so we can handle them here
|
|
139
|
+
const result = await this.identifyRelevantFiles(context.goal, context.taskPlan, fileTree, latestCallLLM);
|
|
140
|
+
// Success or non-rate-limit error (caught internally by identifyRelevantFiles)
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
lastError = err instanceof Error ? err.message : String(err);
|
|
145
|
+
// ── Rate-limit handling with user prompt ─────────────────────
|
|
146
|
+
if (isRateLimitError(lastError) && context.onRateLimit) {
|
|
147
|
+
const retryAfterMs = parseRetryAfterHint(lastError) || BASE_RETRY_DELAY_MS;
|
|
148
|
+
if (retryAfterMs >= LONG_WAIT_THRESHOLD_MS) {
|
|
149
|
+
const modelName = parseModelName(lastError);
|
|
150
|
+
const action = await context.onRateLimit({
|
|
151
|
+
retryAfterMs,
|
|
152
|
+
modelName,
|
|
153
|
+
agentName: this.name,
|
|
154
|
+
errorMessage: lastError.slice(0, 300),
|
|
155
|
+
});
|
|
156
|
+
if (action.action === 'abort') {
|
|
157
|
+
// User wants to abort — return failure
|
|
158
|
+
return {
|
|
159
|
+
paths: [],
|
|
160
|
+
llmError: `Aborted by user: ${lastError}`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (action.action === 'skip') {
|
|
164
|
+
// User wants to skip — fall through to keyword scanning
|
|
165
|
+
logger.info('Context-gatherer LLM call skipped by user');
|
|
166
|
+
return { paths: [], llmError: undefined };
|
|
167
|
+
}
|
|
168
|
+
if (action.action === 'switch-model') {
|
|
169
|
+
// Switch model and retry immediately
|
|
170
|
+
logger.info('Switching model for context gathering per user request...');
|
|
171
|
+
latestCallLLM = action.callLLM;
|
|
172
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
// 'retry': wait and retry
|
|
176
|
+
logger.warn(`Context-gatherer rate limited. Waiting ${(retryAfterMs / 1000).toFixed(1)}s as chosen by user...`);
|
|
177
|
+
await new Promise((resolve) => setTimeout(resolve, retryAfterMs));
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
// Short wait: fall through to auto-retry below
|
|
181
|
+
}
|
|
182
|
+
// ── Standard retry for transient errors ──────────────────────
|
|
183
|
+
if (attempt < MAX_API_RETRIES) {
|
|
184
|
+
const delayMs = BASE_RETRY_DELAY_MS * Math.pow(2, attempt);
|
|
185
|
+
if (isRateLimitError(lastError)) {
|
|
186
|
+
logger.warn(`Context-gatherer API error (attempt ${attempt + 1}/${MAX_API_RETRIES + 1}): ` +
|
|
187
|
+
`${lastError.slice(0, 200)}. Waiting ${(delayMs / 1000).toFixed(1)}s...`);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
logger.warn(`Context-gatherer API error (attempt ${attempt + 1}/${MAX_API_RETRIES + 1}): ` +
|
|
191
|
+
`${lastError.slice(0, 200)}. Retrying...`);
|
|
192
|
+
}
|
|
193
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
// All retries exhausted
|
|
197
|
+
logger.warn(`Context-gatherer LLM unavailable after retries: ${lastError}`);
|
|
198
|
+
return { paths: [], llmError: lastError };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Fallback
|
|
202
|
+
return { paths: [], llmError: lastError || 'Unknown error' };
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Ask the LLM to identify which files are relevant to the goal.
|
|
206
|
+
* Non-rate-limit errors are caught internally (falls back to keyword scanning).
|
|
207
|
+
* Rate-limit errors are re-thrown so identifyWithRetry can handle them.
|
|
208
|
+
*/
|
|
209
|
+
async identifyRelevantFiles(goal, taskPlan, fileTree, callLLM) {
|
|
210
|
+
const taskDescriptions = taskPlan
|
|
211
|
+
.filter((s) => s.status !== 'failed')
|
|
212
|
+
.map((s) => ` - ${s.description}`)
|
|
213
|
+
.join('\n');
|
|
214
|
+
// Limit file tree to avoid token overflow on large projects
|
|
215
|
+
const truncatedTree = truncateTree(fileTree, 80);
|
|
216
|
+
const prompt = [
|
|
217
|
+
'You are a codebase navigation expert. Identify files relevant to the task.',
|
|
218
|
+
'',
|
|
219
|
+
'Project files:',
|
|
220
|
+
truncatedTree || '(empty directory)',
|
|
221
|
+
'',
|
|
222
|
+
`Goal: ${goal}`,
|
|
223
|
+
taskDescriptions ? `Plan: ${taskDescriptions}` : '',
|
|
224
|
+
'',
|
|
225
|
+
'Return ONLY a valid JSON array of file paths. Example:',
|
|
226
|
+
'["src/index.ts", "package.json"]',
|
|
227
|
+
'',
|
|
228
|
+
'Rules:',
|
|
229
|
+
'- Only include files shown in the project listing above',
|
|
230
|
+
'- Include config files (package.json, tsconfig.json) when relevant',
|
|
231
|
+
'- Max 10 files',
|
|
232
|
+
'- NO explanation text before or after the JSON',
|
|
233
|
+
].filter(Boolean).join('\n');
|
|
234
|
+
try {
|
|
235
|
+
const response = await callLLM(prompt, {
|
|
236
|
+
temperature: 0.1,
|
|
237
|
+
maxTokens: 1024,
|
|
238
|
+
});
|
|
239
|
+
const paths = this.extractPaths(response);
|
|
240
|
+
return { paths };
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
244
|
+
// Let rate-limit errors propagate so the retry loop can handle them
|
|
245
|
+
if (isRateLimitError(msg)) {
|
|
246
|
+
throw err;
|
|
247
|
+
}
|
|
248
|
+
// Other errors: gracefully return with error flag (falls back to keyword scanning)
|
|
249
|
+
return { paths: [], llmError: msg };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Extract an array of file paths from the LLM response.
|
|
254
|
+
*/
|
|
255
|
+
extractPaths(response) {
|
|
256
|
+
const trimmed = response.trim();
|
|
257
|
+
const fromJson = this.tryParseJson(trimmed);
|
|
258
|
+
if (fromJson.length > 0)
|
|
259
|
+
return fromJson;
|
|
260
|
+
const jsonBlockMatch = trimmed.match(/```(?:json)?\s*\n?([\s\S]*?)```/);
|
|
261
|
+
if (jsonBlockMatch) {
|
|
262
|
+
const fromBlock = this.tryParseJson(jsonBlockMatch[1].trim());
|
|
263
|
+
if (fromBlock.length > 0)
|
|
264
|
+
return fromBlock;
|
|
265
|
+
}
|
|
266
|
+
const arrayMatch = trimmed.match(/\[[\s\S]*?\]/);
|
|
267
|
+
if (arrayMatch) {
|
|
268
|
+
const fromArray = this.tryParseJson(arrayMatch[0]);
|
|
269
|
+
if (fromArray.length > 0)
|
|
270
|
+
return fromArray;
|
|
271
|
+
}
|
|
272
|
+
const lines = trimmed.split('\n')
|
|
273
|
+
.map((l) => l.trim())
|
|
274
|
+
.filter((l) => l.length > 0 && !l.startsWith('`') && !l.startsWith('#'))
|
|
275
|
+
.map((l) => l.replace(/^[-*\d.\s]+/, '').trim())
|
|
276
|
+
.filter((l) => l.includes('.') || l.includes('/'))
|
|
277
|
+
.filter((l) => l.length < 200);
|
|
278
|
+
if (lines.length > 0) {
|
|
279
|
+
const validPaths = lines.filter((l) => !l.includes(' ') && !l.includes('```'));
|
|
280
|
+
if (validPaths.length > 0)
|
|
281
|
+
return validPaths;
|
|
282
|
+
}
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
tryParseJson(text) {
|
|
286
|
+
try {
|
|
287
|
+
const parsed = JSON.parse(text);
|
|
288
|
+
if (Array.isArray(parsed)) {
|
|
289
|
+
return parsed.filter((p) => typeof p === 'string');
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
// Not valid JSON
|
|
294
|
+
}
|
|
295
|
+
return [];
|
|
296
|
+
}
|
|
297
|
+
/** Fallback keyword-based file scanning when LLM is unavailable */
|
|
298
|
+
scanByKeywords(goal, workingDir) {
|
|
299
|
+
const stopWords = new Set([
|
|
300
|
+
'the', 'a', 'an', 'in', 'to', 'for', 'of', 'and', 'or', 'is',
|
|
301
|
+
'add', 'fix', 'update', 'change', 'remove', 'create', 'implement',
|
|
302
|
+
'with', 'on', 'at', 'by', 'from', 'as', 'be', 'this', 'that',
|
|
303
|
+
]);
|
|
304
|
+
const keywords = goal
|
|
305
|
+
.toLowerCase()
|
|
306
|
+
.split(/[\s,.-]+/)
|
|
307
|
+
.filter((w) => w.length > 2 && !stopWords.has(w));
|
|
308
|
+
if (keywords.length === 0)
|
|
309
|
+
return [];
|
|
310
|
+
const scored = this.walkAndScore(workingDir, keywords, 0);
|
|
311
|
+
return scored
|
|
312
|
+
.sort((a, b) => b.score - a.score)
|
|
313
|
+
.filter((s) => s.score > 0)
|
|
314
|
+
.slice(0, 5)
|
|
315
|
+
.map((s) => s.path);
|
|
316
|
+
}
|
|
317
|
+
walkAndScore(dir, keywords, depth, baseDir) {
|
|
318
|
+
const root = baseDir ?? dir;
|
|
319
|
+
if (depth > 5)
|
|
320
|
+
return [];
|
|
321
|
+
const results = [];
|
|
322
|
+
let entries;
|
|
323
|
+
try {
|
|
324
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
return [];
|
|
328
|
+
}
|
|
329
|
+
for (const entry of entries) {
|
|
330
|
+
if (IGNORE_DIRS.has(entry.name))
|
|
331
|
+
continue;
|
|
332
|
+
const entryPath = join(dir, entry.name);
|
|
333
|
+
if (entry.isDirectory()) {
|
|
334
|
+
const subResults = this.walkAndScore(entryPath, keywords, depth + 1, root);
|
|
335
|
+
results.push(...subResults);
|
|
336
|
+
}
|
|
337
|
+
else if (entry.isFile()) {
|
|
338
|
+
const ext = entry.name.slice(entry.name.lastIndexOf('.'));
|
|
339
|
+
if (!SOURCE_EXTENSIONS.has(ext))
|
|
340
|
+
continue;
|
|
341
|
+
let score = 0;
|
|
342
|
+
const lowerName = entry.name.toLowerCase();
|
|
343
|
+
const lowerPath = entryPath.toLowerCase();
|
|
344
|
+
for (const kw of keywords) {
|
|
345
|
+
if (lowerName.includes(kw))
|
|
346
|
+
score += 3;
|
|
347
|
+
else if (lowerPath.includes(kw))
|
|
348
|
+
score += 1;
|
|
349
|
+
}
|
|
350
|
+
if (score > 0) {
|
|
351
|
+
const relPath = relative(root, entryPath);
|
|
352
|
+
results.push({ path: relPath, score });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return results;
|
|
357
|
+
}
|
|
358
|
+
formatSize(bytes) {
|
|
359
|
+
if (bytes < 1024)
|
|
360
|
+
return String(bytes);
|
|
361
|
+
if (bytes < 1024 * 1024)
|
|
362
|
+
return `${(bytes / 1024).toFixed(1)}k`;
|
|
363
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}M`;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
//# sourceMappingURL=context-gatherer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-gatherer.js","sourceRoot":"","sources":["../../../src/agents/agents/context-gatherer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAsD,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;IAC5B,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK;IAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM;IAChD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS;CAC5C,CAAC,CAAC;AAEH,2CAA2C;AAC3C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAChD,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa;IAClD,OAAO,EAA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1C,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,UAAU,CAAC,KAAa;QAC9B,IAAI,KAAK,GAAG,IAAI;YAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;YAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QAChE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DebuggerAgent — Takes test failure output, uses the LLM to diagnose and fix
|
|
3
|
+
* the issues, re-runs tests, and iterates until all tests pass or max attempts
|
|
4
|
+
* are exhausted.
|
|
5
|
+
*
|
|
6
|
+
* This agent depends on the TesterAgent having run first and stored its results
|
|
7
|
+
* in the context metadata under `testResult`.
|
|
8
|
+
*
|
|
9
|
+
* The debug cycle:
|
|
10
|
+
* 1. Read test failure output from `context.metadata.testResult`
|
|
11
|
+
* 2. Call LLM with failure output + source files → get proposed fixes
|
|
12
|
+
* 3. Apply fixes to the sandbox (the TesterAgent's sandbox path is in testResult)
|
|
13
|
+
* 4. Re-run tests in the sandbox
|
|
14
|
+
* 5. If tests pass → done. If not, repeat up to MAX_DEBUG_ITERATIONS.
|
|
15
|
+
*/
|
|
16
|
+
import { Agent, type AgentContext, type AgentResult } from '../agent.js';
|
|
17
|
+
import type { LLMCallFn } from '../agent.js';
|
|
18
|
+
/**
|
|
19
|
+
* DebuggerAgent — Diagnoses and fixes test failures iteratively.
|
|
20
|
+
*
|
|
21
|
+
* Usage in task plans:
|
|
22
|
+
* ```json
|
|
23
|
+
* { "id": "step-06-debug", "description": "Fix failing tests", "agentType": "debugger", "dependsOn": ["step-05-test"] }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class DebuggerAgent extends Agent {
|
|
27
|
+
readonly name = "Debugger";
|
|
28
|
+
readonly description = "Diagnoses test failures and iteratively applies fixes";
|
|
29
|
+
execute(context: AgentContext, callLLM: LLMCallFn): Promise<AgentResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Build the debug prompt with failure output and source files.
|
|
32
|
+
*/
|
|
33
|
+
private buildPrompt;
|
|
34
|
+
/**
|
|
35
|
+
* Parse the LLM response and apply the fixes to files in the sandbox.
|
|
36
|
+
* Returns a list of file paths that were changed.
|
|
37
|
+
*/
|
|
38
|
+
private applyFixes;
|
|
39
|
+
/**
|
|
40
|
+
* Read fixed files from the sandbox and update the context's fileChanges.
|
|
41
|
+
* Handles both files already in context.fileChanges AND new files the LLM
|
|
42
|
+
* may have modified that weren't in the original change set.
|
|
43
|
+
*/
|
|
44
|
+
private syncChangesToContext;
|
|
45
|
+
/**
|
|
46
|
+
* Run the test command in the sandbox.
|
|
47
|
+
*/
|
|
48
|
+
private runTest;
|
|
49
|
+
/**
|
|
50
|
+
* Detect the test command from package.json.
|
|
51
|
+
*/
|
|
52
|
+
private detectTestCommand;
|
|
53
|
+
/**
|
|
54
|
+
* Truncate long output to avoid huge strings.
|
|
55
|
+
*/
|
|
56
|
+
private truncateOutput;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=debugger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugger.d.ts","sourceRoot":"","sources":["../../../src/agents/agents/debugger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoB7C;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,WAAW,2DAA2D;IAEzE,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAkG9E;;OAEG;IACH,OAAO,CAAC,WAAW;IAkBnB;;;OAGG;IACH,OAAO,CAAC,UAAU;IA0BlB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAkC5B;;OAEG;IACH,OAAO,CAAC,OAAO;IAyBf;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB;;OAEG;IACH,OAAO,CAAC,cAAc;CAIvB"}
|