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,257 @@
|
|
|
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 { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
17
|
+
import { join, dirname } from 'node:path';
|
|
18
|
+
import { execSync } from 'node:child_process';
|
|
19
|
+
import { Agent } from '../agent.js';
|
|
20
|
+
/** Maximum number of debug-fix-test iterations */
|
|
21
|
+
const MAX_DEBUG_ITERATIONS = 3;
|
|
22
|
+
const DEBUGGER_SYSTEM_PROMPT = `You are a senior debugging engineer. Given test failure output and the relevant source files, identify the bugs and provide fixes.
|
|
23
|
+
|
|
24
|
+
Rules:
|
|
25
|
+
1. Analyze the test error messages carefully
|
|
26
|
+
2. Identify the root cause, not just the symptoms
|
|
27
|
+
3. Provide the COMPLETE updated file content for each file you fix
|
|
28
|
+
4. Return each file wrapped in a markdown code block with the file path as the header
|
|
29
|
+
|
|
30
|
+
Format your response as:
|
|
31
|
+
\`\`\`filepath:path/to/file.ts
|
|
32
|
+
// complete fixed file content here
|
|
33
|
+
\`\`\`
|
|
34
|
+
`;
|
|
35
|
+
/**
|
|
36
|
+
* DebuggerAgent — Diagnoses and fixes test failures iteratively.
|
|
37
|
+
*
|
|
38
|
+
* Usage in task plans:
|
|
39
|
+
* ```json
|
|
40
|
+
* { "id": "step-06-debug", "description": "Fix failing tests", "agentType": "debugger", "dependsOn": ["step-05-test"] }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export class DebuggerAgent extends Agent {
|
|
44
|
+
name = 'Debugger';
|
|
45
|
+
description = 'Diagnoses test failures and iteratively applies fixes';
|
|
46
|
+
async execute(context, callLLM) {
|
|
47
|
+
try {
|
|
48
|
+
// 1. Get test result from context metadata
|
|
49
|
+
const testResult = context.metadata['testResult'];
|
|
50
|
+
if (!testResult) {
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
summary: 'No test results found',
|
|
54
|
+
error: 'TesterAgent must run before DebuggerAgent. No testResult found in context metadata.',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// If tests already passed, nothing to debug
|
|
58
|
+
if (testResult.success) {
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
summary: 'No debugging needed — all tests already pass',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const sandboxPath = testResult.sandboxPath;
|
|
65
|
+
if (!existsSync(sandboxPath)) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
summary: 'Sandbox not found',
|
|
69
|
+
error: `Test sandbox at ${sandboxPath} no longer exists. The TesterAgent may have been cleaned up.`,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// 2. Iterative debug cycle
|
|
73
|
+
const allAttempts = [];
|
|
74
|
+
let currentOutput = testResult.output;
|
|
75
|
+
let currentSuccess = false;
|
|
76
|
+
for (let iteration = 0; iteration < MAX_DEBUG_ITERATIONS; iteration++) {
|
|
77
|
+
// 3. Call LLM to diagnose and fix
|
|
78
|
+
const prompt = this.buildPrompt(currentOutput, context, sandboxPath);
|
|
79
|
+
const response = await callLLM(prompt, {
|
|
80
|
+
temperature: 0.3,
|
|
81
|
+
maxTokens: 8192,
|
|
82
|
+
});
|
|
83
|
+
// 4. Parse the fix and apply to sandbox
|
|
84
|
+
const changedFiles = this.applyFixes(response, sandboxPath);
|
|
85
|
+
// 5. Re-run tests
|
|
86
|
+
const testCommand = this.detectTestCommand(sandboxPath);
|
|
87
|
+
const reTestResult = this.runTest(sandboxPath, testCommand);
|
|
88
|
+
// Track this attempt
|
|
89
|
+
allAttempts.push({
|
|
90
|
+
iteration: iteration + 1,
|
|
91
|
+
output: reTestResult.output,
|
|
92
|
+
filesChanged: changedFiles,
|
|
93
|
+
});
|
|
94
|
+
// 6. Check if tests pass now
|
|
95
|
+
if (reTestResult.success) {
|
|
96
|
+
currentSuccess = true;
|
|
97
|
+
// 7. Update the context's fileChanges with the successful fixes
|
|
98
|
+
this.syncChangesToContext(context, sandboxPath, context.workingDirectory, changedFiles);
|
|
99
|
+
// Store final test result
|
|
100
|
+
context.metadata['testResult'] = {
|
|
101
|
+
...testResult,
|
|
102
|
+
success: true,
|
|
103
|
+
output: reTestResult.output,
|
|
104
|
+
exitCode: 0,
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
success: true,
|
|
108
|
+
summary: `All tests pass after ${iteration + 1} debug iteration${iteration > 0 ? 's' : ''}`,
|
|
109
|
+
details: `Files modified: ${changedFiles.join(', ')}`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
currentOutput = reTestResult.output;
|
|
113
|
+
}
|
|
114
|
+
// 8. Max iterations reached — report failure
|
|
115
|
+
return {
|
|
116
|
+
success: false,
|
|
117
|
+
summary: `Tests still failing after ${MAX_DEBUG_ITERATIONS} debug iterations`,
|
|
118
|
+
details: `Latest test output:\n${this.truncateOutput(currentOutput, 2000)}`,
|
|
119
|
+
error: `Debugger exhausted ${MAX_DEBUG_ITERATIONS} iterations without resolving all test failures.`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
124
|
+
return {
|
|
125
|
+
success: false,
|
|
126
|
+
summary: 'Debugger failed',
|
|
127
|
+
error: msg,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Build the debug prompt with failure output and source files.
|
|
133
|
+
*/
|
|
134
|
+
buildPrompt(testOutput, context, sandboxPath) {
|
|
135
|
+
// Get the files that were changed (most likely to contain bugs)
|
|
136
|
+
const changedFiles = context.fileChanges.slice(0, 5);
|
|
137
|
+
const fileContents = changedFiles
|
|
138
|
+
.map((change) => {
|
|
139
|
+
const filePath = join(sandboxPath, change.path);
|
|
140
|
+
if (existsSync(filePath)) {
|
|
141
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
142
|
+
return `--- ${change.path} ---\n${content}`;
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
})
|
|
146
|
+
.filter(Boolean)
|
|
147
|
+
.join('\n\n');
|
|
148
|
+
return `${DEBUGGER_SYSTEM_PROMPT}\n\n## Test Failure Output\n${this.truncateOutput(testOutput, 3000)}\n\n## Source Files\n${fileContents || '(No source files found)'}\n\n## Instructions\nAnalyze the test failures and fix the bugs in the source files. Return the complete updated file content for each file you modify.`;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Parse the LLM response and apply the fixes to files in the sandbox.
|
|
152
|
+
* Returns a list of file paths that were changed.
|
|
153
|
+
*/
|
|
154
|
+
applyFixes(response, sandboxPath) {
|
|
155
|
+
const changedFiles = [];
|
|
156
|
+
const blockRegex = /```(?:[a-zA-Z0-9+#]*\s+)?(?:filepath:)?([^\n`]+(?:\.[a-zA-Z0-9]+|\/[^\n`]+))\n([\s\S]*?)```/g;
|
|
157
|
+
let match;
|
|
158
|
+
while ((match = blockRegex.exec(response)) !== null) {
|
|
159
|
+
let filePath = match[1].trim();
|
|
160
|
+
const content = match[2].trim();
|
|
161
|
+
filePath = filePath.replace(/^['"]|['"]$/g, '').trim();
|
|
162
|
+
if (!filePath || !content)
|
|
163
|
+
continue;
|
|
164
|
+
const absolutePath = join(sandboxPath, filePath);
|
|
165
|
+
const dir = dirname(absolutePath);
|
|
166
|
+
if (!existsSync(dir)) {
|
|
167
|
+
mkdirSync(dir, { recursive: true });
|
|
168
|
+
}
|
|
169
|
+
writeFileSync(absolutePath, content, 'utf-8');
|
|
170
|
+
changedFiles.push(filePath);
|
|
171
|
+
}
|
|
172
|
+
return changedFiles;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Read fixed files from the sandbox and update the context's fileChanges.
|
|
176
|
+
* Handles both files already in context.fileChanges AND new files the LLM
|
|
177
|
+
* may have modified that weren't in the original change set.
|
|
178
|
+
*/
|
|
179
|
+
syncChangesToContext(context, sandboxPath, workingDir, changedFiles) {
|
|
180
|
+
for (const filePath of changedFiles) {
|
|
181
|
+
const sandboxFile = join(sandboxPath, filePath);
|
|
182
|
+
if (!existsSync(sandboxFile))
|
|
183
|
+
continue;
|
|
184
|
+
const newContent = readFileSync(sandboxFile, 'utf-8');
|
|
185
|
+
const originalPath = join(workingDir, filePath);
|
|
186
|
+
const originalContent = existsSync(originalPath) ? readFileSync(originalPath, 'utf-8') : undefined;
|
|
187
|
+
// Update if already in context, or add as new entry
|
|
188
|
+
const existing = context.fileChanges.findIndex((c) => c.path === filePath);
|
|
189
|
+
if (existing >= 0) {
|
|
190
|
+
context.fileChanges[existing] = {
|
|
191
|
+
path: filePath,
|
|
192
|
+
originalContent,
|
|
193
|
+
newContent,
|
|
194
|
+
status: originalContent ? 'modified' : 'created',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
context.fileChanges.push({
|
|
199
|
+
path: filePath,
|
|
200
|
+
originalContent,
|
|
201
|
+
newContent,
|
|
202
|
+
status: originalContent ? 'modified' : 'created',
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Run the test command in the sandbox.
|
|
209
|
+
*/
|
|
210
|
+
runTest(sandboxPath, command) {
|
|
211
|
+
try {
|
|
212
|
+
const output = execSync(command, {
|
|
213
|
+
cwd: sandboxPath,
|
|
214
|
+
timeout: 180_000,
|
|
215
|
+
stdio: 'pipe',
|
|
216
|
+
encoding: 'utf-8',
|
|
217
|
+
});
|
|
218
|
+
return { success: true, output };
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
const error = err;
|
|
222
|
+
const output = [
|
|
223
|
+
error.stdout || '',
|
|
224
|
+
error.stderr || '',
|
|
225
|
+
error.message || '',
|
|
226
|
+
].filter(Boolean).join('\n');
|
|
227
|
+
return { success: false, output };
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Detect the test command from package.json.
|
|
232
|
+
*/
|
|
233
|
+
detectTestCommand(sandboxPath) {
|
|
234
|
+
try {
|
|
235
|
+
const pkgPath = join(sandboxPath, 'package.json');
|
|
236
|
+
if (existsSync(pkgPath)) {
|
|
237
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
238
|
+
if (pkg.scripts?.test) {
|
|
239
|
+
return 'npm run test 2>&1';
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
// Fall through
|
|
245
|
+
}
|
|
246
|
+
return 'npm test 2>&1';
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Truncate long output to avoid huge strings.
|
|
250
|
+
*/
|
|
251
|
+
truncateOutput(output, maxLength) {
|
|
252
|
+
if (output.length <= maxLength)
|
|
253
|
+
return output;
|
|
254
|
+
return output.slice(0, maxLength) + '\n... (output truncated)';
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=debugger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../../../src/agents/agents/debugger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAuC,MAAM,aAAa,CAAC;AAIzE,kDAAkD;AAClD,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,sBAAsB,GAAG;;;;;;;;;;;;CAY9B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,GAAG,UAAU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gBAClB,KAAK,CAAC,MAAM,IAAI,EAAE;gBAClB,KAAK,CAAC,OAAO,IAAI,EAAE;aACpB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,WAAmB;QAC3C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAClD,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAyC,CAAC;gBAC/F,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;oBACtB,OAAO,mBAAmB,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,MAAc,EAAE,SAAiB;QACtD,IAAI,MAAM,CAAC,MAAM,IAAI,SAAS;YAAE,OAAO,MAAM,CAAC;QAC9C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,0BAA0B,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitAgent — Manages git operations for the publishing pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Capabilities:
|
|
5
|
+
* - Create branches
|
|
6
|
+
* - Commit changes with auto-generated commit messages (via LLM)
|
|
7
|
+
* - Generate PR descriptions from git diff
|
|
8
|
+
* - Check git status
|
|
9
|
+
*
|
|
10
|
+
* This agent does NOT require an LLM for basic operations (status, branch, commit),
|
|
11
|
+
* but uses the LLM for generating commit messages and PR descriptions.
|
|
12
|
+
*
|
|
13
|
+
* Usage in task plans:
|
|
14
|
+
* ```json
|
|
15
|
+
* { "id": "step-commit", "description": "Commit changes to git", "agentType": "git", "dependsOn": ["step-write"] }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { Agent, type AgentContext, type AgentResult } from '../agent.js';
|
|
19
|
+
import type { LLMCallFn } from '../agent.js';
|
|
20
|
+
/**
|
|
21
|
+
* GitAgent — Handles git operations for the multi-agent pipeline.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GitAgent extends Agent {
|
|
24
|
+
readonly name = "Git";
|
|
25
|
+
readonly description = "Manages git operations (branch, commit, PR)";
|
|
26
|
+
execute(context: AgentContext, callLLM: LLMCallFn): Promise<AgentResult>;
|
|
27
|
+
private detectOperation;
|
|
28
|
+
private gitStatus;
|
|
29
|
+
private createBranch;
|
|
30
|
+
private commit;
|
|
31
|
+
private generatePRDescription;
|
|
32
|
+
private exec;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=git-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-agent.d.ts","sourceRoot":"","sources":["../../../src/agents/agents/git-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoB7C;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,IAAI,SAAS;IACtB,QAAQ,CAAC,WAAW,iDAAiD;IAE/D,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IA2B9E,OAAO,CAAC,eAAe;YAQT,SAAS;YAUT,YAAY;YAmBZ,MAAM;YA4CN,qBAAqB;IAqCnC,OAAO,CAAC,IAAI;CAoBb"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitAgent — Manages git operations for the publishing pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Capabilities:
|
|
5
|
+
* - Create branches
|
|
6
|
+
* - Commit changes with auto-generated commit messages (via LLM)
|
|
7
|
+
* - Generate PR descriptions from git diff
|
|
8
|
+
* - Check git status
|
|
9
|
+
*
|
|
10
|
+
* This agent does NOT require an LLM for basic operations (status, branch, commit),
|
|
11
|
+
* but uses the LLM for generating commit messages and PR descriptions.
|
|
12
|
+
*
|
|
13
|
+
* Usage in task plans:
|
|
14
|
+
* ```json
|
|
15
|
+
* { "id": "step-commit", "description": "Commit changes to git", "agentType": "git", "dependsOn": ["step-write"] }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { execSync } from 'node:child_process';
|
|
19
|
+
import { writeFileSync, unlinkSync, mkdtempSync } from 'node:fs';
|
|
20
|
+
import { join } from 'node:path';
|
|
21
|
+
import { tmpdir } from 'node:os';
|
|
22
|
+
import { Agent } from '../agent.js';
|
|
23
|
+
const COMMIT_MESSAGE_PROMPT = `You are an expert at writing clear, conventional git commit messages.
|
|
24
|
+
|
|
25
|
+
Given the following git diff, write a concise commit message following conventional commits format:
|
|
26
|
+
|
|
27
|
+
<type>(<scope>): <description>
|
|
28
|
+
|
|
29
|
+
Types: feat, fix, refactor, docs, style, test, chore, perf, ci
|
|
30
|
+
Scope: the module/area affected (optional)
|
|
31
|
+
|
|
32
|
+
Rules:
|
|
33
|
+
- First line: max 72 characters
|
|
34
|
+
- Body: wrap at 72 characters, explain what and why, not how
|
|
35
|
+
- Use imperative mood ("add" not "added" / "adds")
|
|
36
|
+
- Be specific but concise
|
|
37
|
+
|
|
38
|
+
Return ONLY the commit message, nothing else.`;
|
|
39
|
+
/**
|
|
40
|
+
* GitAgent — Handles git operations for the multi-agent pipeline.
|
|
41
|
+
*/
|
|
42
|
+
export class GitAgent extends Agent {
|
|
43
|
+
name = 'Git';
|
|
44
|
+
description = 'Manages git operations (branch, commit, PR)';
|
|
45
|
+
async execute(context, callLLM) {
|
|
46
|
+
try {
|
|
47
|
+
const taskDesc = context.taskPlan.find((s) => s.agentType === 'git' && s.status === 'running')?.description || context.goal;
|
|
48
|
+
// Parse the task to determine the git operation
|
|
49
|
+
const operation = this.detectOperation(taskDesc);
|
|
50
|
+
switch (operation) {
|
|
51
|
+
case 'status':
|
|
52
|
+
return this.gitStatus();
|
|
53
|
+
case 'branch':
|
|
54
|
+
return this.createBranch(context, taskDesc);
|
|
55
|
+
case 'commit':
|
|
56
|
+
return this.commit(context, callLLM);
|
|
57
|
+
case 'pr-description':
|
|
58
|
+
return this.generatePRDescription(context, callLLM);
|
|
59
|
+
default:
|
|
60
|
+
return this.commit(context, callLLM);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
65
|
+
return { success: false, summary: 'Git operation failed', error: msg };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
detectOperation(description) {
|
|
69
|
+
const lower = description.toLowerCase();
|
|
70
|
+
if (lower.includes('status') || lower.includes('check'))
|
|
71
|
+
return 'status';
|
|
72
|
+
if (lower.includes('branch') || lower.includes('checkout') || lower.includes('switch'))
|
|
73
|
+
return 'branch';
|
|
74
|
+
if (lower.includes('pr') || lower.includes('pull request') || lower.includes('description'))
|
|
75
|
+
return 'pr-description';
|
|
76
|
+
return 'commit';
|
|
77
|
+
}
|
|
78
|
+
async gitStatus() {
|
|
79
|
+
const output = this.exec('git status --short');
|
|
80
|
+
const lines = output.trim().split('\n').filter(Boolean);
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
summary: `${lines.length} file(s) changed`,
|
|
84
|
+
details: output,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
async createBranch(context, description) {
|
|
88
|
+
// Generate branch name from goal
|
|
89
|
+
const sanitized = context.goal
|
|
90
|
+
.toLowerCase()
|
|
91
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
92
|
+
.replace(/^-|-$/g, '')
|
|
93
|
+
.slice(0, 40);
|
|
94
|
+
const branchName = `feat/${sanitized}`;
|
|
95
|
+
// Check if branch already exists
|
|
96
|
+
const existing = this.exec(`git branch --list "${branchName}"`);
|
|
97
|
+
if (existing.trim()) {
|
|
98
|
+
return { success: true, summary: `Branch '${branchName}' already exists`, details: branchName };
|
|
99
|
+
}
|
|
100
|
+
this.exec(`git checkout -b "${branchName}"`);
|
|
101
|
+
return { success: true, summary: `Created branch '${branchName}'`, details: branchName };
|
|
102
|
+
}
|
|
103
|
+
async commit(context, callLLM) {
|
|
104
|
+
// Stage all changes
|
|
105
|
+
this.exec('git add -A');
|
|
106
|
+
// Check if there's anything to commit
|
|
107
|
+
const status = this.exec('git status --short');
|
|
108
|
+
if (!status.trim()) {
|
|
109
|
+
return { success: true, summary: 'No changes to commit' };
|
|
110
|
+
}
|
|
111
|
+
// Get the diff for the LLM to summarize
|
|
112
|
+
const diff = this.exec('git diff --cached --stat');
|
|
113
|
+
const fullDiff = this.exec('git diff --cached');
|
|
114
|
+
// Generate commit message via LLM
|
|
115
|
+
let commitMessage = '';
|
|
116
|
+
try {
|
|
117
|
+
const prompt = `${COMMIT_MESSAGE_PROMPT}\n\n## Diff Summary\n${diff}\n\n## Full Diff (truncated)\n${fullDiff.slice(0, 4000)}`;
|
|
118
|
+
commitMessage = await callLLM(prompt, { temperature: 0.3, maxTokens: 500 });
|
|
119
|
+
commitMessage = commitMessage.trim().replace(/^```[\s\S]*?\n|```$/g, '').trim();
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Fallback: generate a simple commit message from the goal
|
|
123
|
+
commitMessage = `feat: ${context.goal.slice(0, 60)}`;
|
|
124
|
+
}
|
|
125
|
+
// Ensure the commit message is valid
|
|
126
|
+
if (!commitMessage || commitMessage.length < 5) {
|
|
127
|
+
commitMessage = `feat: ${context.goal.slice(0, 60)}`;
|
|
128
|
+
}
|
|
129
|
+
// Write commit message to temp file to avoid shell quoting issues (cross-platform)
|
|
130
|
+
const msgDir = mkdtempSync(join(tmpdir(), 'git-msg-'));
|
|
131
|
+
const msgFile = join(msgDir, 'commit-msg.txt');
|
|
132
|
+
writeFileSync(msgFile, commitMessage, 'utf-8');
|
|
133
|
+
this.exec(`git commit -F "${msgFile}"`);
|
|
134
|
+
try {
|
|
135
|
+
unlinkSync(msgFile);
|
|
136
|
+
}
|
|
137
|
+
catch { /* best-effort */ }
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
summary: `Committed with message: ${commitMessage.split('\n')[0].slice(0, 72)}`,
|
|
141
|
+
details: commitMessage,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async generatePRDescription(context, callLLM) {
|
|
145
|
+
const diff = this.exec('git diff main...HEAD --stat');
|
|
146
|
+
const fullDiff = this.exec('git diff main...HEAD');
|
|
147
|
+
const prompt = `Generate a GitHub pull request description from the following diff.
|
|
148
|
+
|
|
149
|
+
## Diff (truncated)
|
|
150
|
+
${fullDiff.slice(0, 4000)}
|
|
151
|
+
|
|
152
|
+
## Format
|
|
153
|
+
### Summary
|
|
154
|
+
[1-2 sentences describing the change]
|
|
155
|
+
|
|
156
|
+
### Changes
|
|
157
|
+
- [list of files changed and why]
|
|
158
|
+
|
|
159
|
+
### Testing
|
|
160
|
+
- [how to test this change]
|
|
161
|
+
|
|
162
|
+
### Related Issues
|
|
163
|
+
- [if applicable]`;
|
|
164
|
+
let description;
|
|
165
|
+
try {
|
|
166
|
+
description = await callLLM(prompt, { temperature: 0.3, maxTokens: 1500 });
|
|
167
|
+
description = description.trim();
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
description = `## Changes\n${diff || 'No diff available'}\n\nAuto-generated by agent-nuvira.`;
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
success: true,
|
|
174
|
+
summary: 'Generated PR description',
|
|
175
|
+
details: description,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
exec(command, cwd) {
|
|
179
|
+
try {
|
|
180
|
+
return execSync(command, {
|
|
181
|
+
cwd: cwd || process.cwd(),
|
|
182
|
+
timeout: 30_000,
|
|
183
|
+
encoding: 'utf-8',
|
|
184
|
+
stdio: 'pipe',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
const error = err;
|
|
189
|
+
// Only swallow stderr for known non-fatal cases (e.g., no commits yet)
|
|
190
|
+
// Re-throw for genuine command failures
|
|
191
|
+
const msg = error.stderr || error.message || '';
|
|
192
|
+
if (msg.includes('Command failed') || msg.includes('not found') || msg.includes('not a git repository')) {
|
|
193
|
+
throw new Error(msg.slice(0, 200));
|
|
194
|
+
}
|
|
195
|
+
// Return available output (maybe partial git log worked)
|
|
196
|
+
return error.stdout || msg;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=git-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-agent.js","sourceRoot":"","sources":["../../../src/agents/agents/git-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAuC,MAAM,aAAa,CAAC;AAIzE,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;8CAegB,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,GAAG,KAAK,CAAC;IACb,WAAW,GAAG,6CAA6C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1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHubReleaseAgent — Creates GitHub releases with auto-generated changelogs.
|
|
3
|
+
*
|
|
4
|
+
* Capabilities:
|
|
5
|
+
* - Create git tags (with optional signing)
|
|
6
|
+
* - Generate release notes from git log between tags (via LLM)
|
|
7
|
+
* - Create GitHub releases via `gh` CLI
|
|
8
|
+
* - List existing releases and tags
|
|
9
|
+
* - Detect version from package.json
|
|
10
|
+
*
|
|
11
|
+
* Requires: `gh` CLI installed and authenticated, or uses `github_api_key` env var.
|
|
12
|
+
*
|
|
13
|
+
* Usage in task plans:
|
|
14
|
+
* ```json
|
|
15
|
+
* { "id": "step-release", "description": "Create GitHub release for v1.2.0", "agentType": "github-release", "dependsOn": ["step-test"] }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { Agent, type AgentContext, type AgentResult } from '../agent.js';
|
|
19
|
+
import type { LLMCallFn } from '../agent.js';
|
|
20
|
+
/**
|
|
21
|
+
* GitHubReleaseAgent — Creates GitHub releases with changelogs.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GitHubReleaseAgent extends Agent {
|
|
24
|
+
readonly name = "GitHub Release";
|
|
25
|
+
readonly description = "Creates GitHub releases with auto-generated changelogs";
|
|
26
|
+
execute(context: AgentContext, callLLM: LLMCallFn): Promise<AgentResult>;
|
|
27
|
+
private detectOperation;
|
|
28
|
+
/**
|
|
29
|
+
* Detect the version to use for the release.
|
|
30
|
+
* Checks: task description → package.json → latest tag + 1
|
|
31
|
+
*/
|
|
32
|
+
private detectVersion;
|
|
33
|
+
/**
|
|
34
|
+
* Create a git tag for the release.
|
|
35
|
+
*/
|
|
36
|
+
private createTag;
|
|
37
|
+
/**
|
|
38
|
+
* Create a full GitHub release (tag + release notes + publish).
|
|
39
|
+
*/
|
|
40
|
+
private createRelease;
|
|
41
|
+
/**
|
|
42
|
+
* Generate release notes from git log using the LLM.
|
|
43
|
+
*/
|
|
44
|
+
private generateReleaseNotes;
|
|
45
|
+
/**
|
|
46
|
+
* List existing releases.
|
|
47
|
+
*/
|
|
48
|
+
private listReleases;
|
|
49
|
+
private generateNotesFromLog;
|
|
50
|
+
private generateNotesFallback;
|
|
51
|
+
/**
|
|
52
|
+
* Create a GitHub release via the `gh` CLI.
|
|
53
|
+
*/
|
|
54
|
+
private createViaCLI;
|
|
55
|
+
/**
|
|
56
|
+
* Create a GitHub release via the API (fallback when gh CLI is not available).
|
|
57
|
+
*/
|
|
58
|
+
private createViaAPI;
|
|
59
|
+
/**
|
|
60
|
+
* Detect the current git branch name.
|
|
61
|
+
*/
|
|
62
|
+
private detectCurrentBranch;
|
|
63
|
+
private exec;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=github-release-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-release-agent.d.ts","sourceRoot":"","sources":["../../../src/agents/agents/github-release-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAmC7C;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,WAAW,4DAA4D;IAE1E,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IA0B9E,OAAO,CAAC,eAAe;IAUvB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAgCrB;;OAEG;YACW,SAAS;IAwBvB;;OAEG;YACW,aAAa;IAmD3B;;OAEG;YACW,oBAAoB;IAuBlC;;OAEG;YACW,YAAY;YA4BZ,oBAAoB;IAiClC,OAAO,CAAC,qBAAqB;IAmB7B;;OAEG;YACW,YAAY;IAwC1B;;OAEG;YACW,YAAY;IAuE1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,IAAI;CAiBb"}
|