opencode-forge 0.1.5
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 +534 -0
- package/config.jsonc +47 -0
- package/dist/agents/architect.d.ts +3 -0
- package/dist/agents/architect.d.ts.map +1 -0
- package/dist/agents/architect.js +152 -0
- package/dist/agents/architect.js.map +1 -0
- package/dist/agents/auditor.d.ts +3 -0
- package/dist/agents/auditor.d.ts.map +1 -0
- package/dist/agents/auditor.js +168 -0
- package/dist/agents/auditor.js.map +1 -0
- package/dist/agents/code.d.ts +3 -0
- package/dist/agents/code.d.ts.map +1 -0
- package/dist/agents/code.js +67 -0
- package/dist/agents/code.js.map +1 -0
- package/dist/agents/index.d.ts +4 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +9 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/prompts.d.ts +1 -0
- package/dist/agents/prompts.d.ts.map +1 -0
- package/dist/agents/prompts.js +4 -0
- package/dist/agents/prompts.js.map +1 -0
- package/dist/agents/types.d.ts +34 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cache/index.d.ts +4 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +5 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/memory-cache.d.ts +14 -0
- package/dist/cache/memory-cache.d.ts.map +1 -0
- package/dist/cache/memory-cache.js +51 -0
- package/dist/cache/memory-cache.js.map +1 -0
- package/dist/cache/types.d.ts +8 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +2 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/cli/commands/cancel.d.ts +15 -0
- package/dist/cli/commands/cancel.d.ts.map +1 -0
- package/dist/cli/commands/cancel.js +194 -0
- package/dist/cli/commands/cancel.js.map +1 -0
- package/dist/cli/commands/graph.d.ts +16 -0
- package/dist/cli/commands/graph.d.ts.map +1 -0
- package/dist/cli/commands/graph.js +208 -0
- package/dist/cli/commands/graph.js.map +1 -0
- package/dist/cli/commands/restart.d.ts +15 -0
- package/dist/cli/commands/restart.d.ts.map +1 -0
- package/dist/cli/commands/restart.js +268 -0
- package/dist/cli/commands/restart.js.map +1 -0
- package/dist/cli/commands/status.d.ts +17 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +356 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/upgrade.d.ts +3 -0
- package/dist/cli/commands/upgrade.d.ts.map +1 -0
- package/dist/cli/commands/upgrade.js +40 -0
- package/dist/cli/commands/upgrade.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +224 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils.d.ts +36 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +163 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/command/template/review.txt +101 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +186 -0
- package/dist/config.js.map +1 -0
- package/dist/constants/loop.d.ts +10 -0
- package/dist/constants/loop.d.ts.map +1 -0
- package/dist/constants/loop.js +6 -0
- package/dist/constants/loop.js.map +1 -0
- package/dist/graph/cache.d.ts +17 -0
- package/dist/graph/cache.d.ts.map +1 -0
- package/dist/graph/cache.js +50 -0
- package/dist/graph/cache.js.map +1 -0
- package/dist/graph/client.d.ts +51 -0
- package/dist/graph/client.d.ts.map +1 -0
- package/dist/graph/client.js +152 -0
- package/dist/graph/client.js.map +1 -0
- package/dist/graph/clone-detection.d.ts +9 -0
- package/dist/graph/clone-detection.d.ts.map +1 -0
- package/dist/graph/clone-detection.js +148 -0
- package/dist/graph/clone-detection.js.map +1 -0
- package/dist/graph/constants.d.ts +18 -0
- package/dist/graph/constants.d.ts.map +1 -0
- package/dist/graph/constants.js +532 -0
- package/dist/graph/constants.js.map +1 -0
- package/dist/graph/database.d.ts +11 -0
- package/dist/graph/database.d.ts.map +1 -0
- package/dist/graph/database.js +250 -0
- package/dist/graph/database.js.map +1 -0
- package/dist/graph/index.d.ts +14 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/repo-map.d.ts +59 -0
- package/dist/graph/repo-map.d.ts.map +1 -0
- package/dist/graph/repo-map.js +948 -0
- package/dist/graph/repo-map.js.map +1 -0
- package/dist/graph/rpc.d.ts +34 -0
- package/dist/graph/rpc.d.ts.map +1 -0
- package/dist/graph/rpc.js +139 -0
- package/dist/graph/rpc.js.map +1 -0
- package/dist/graph/service.d.ts +46 -0
- package/dist/graph/service.d.ts.map +1 -0
- package/dist/graph/service.js +329 -0
- package/dist/graph/service.js.map +1 -0
- package/dist/graph/tree-sitter.d.ts +40 -0
- package/dist/graph/tree-sitter.d.ts.map +1 -0
- package/dist/graph/tree-sitter.js +799 -0
- package/dist/graph/tree-sitter.js.map +1 -0
- package/dist/graph/types.d.ts +175 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +105 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/graph/utils.d.ts +64 -0
- package/dist/graph/utils.d.ts.map +1 -0
- package/dist/graph/utils.js +406 -0
- package/dist/graph/utils.js.map +1 -0
- package/dist/graph/worker.d.ts +2 -0
- package/dist/graph/worker.d.ts.map +1 -0
- package/dist/graph/worker.js +6043 -0
- package/dist/graph/worker.js.map +1 -0
- package/dist/hooks/compaction-utils.d.ts +21 -0
- package/dist/hooks/compaction-utils.d.ts.map +1 -0
- package/dist/hooks/compaction-utils.js +82 -0
- package/dist/hooks/compaction-utils.js.map +1 -0
- package/dist/hooks/graph-command.d.ts +27 -0
- package/dist/hooks/graph-command.d.ts.map +1 -0
- package/dist/hooks/graph-command.js +57 -0
- package/dist/hooks/graph-command.js.map +1 -0
- package/dist/hooks/graph-tools.d.ts +11 -0
- package/dist/hooks/graph-tools.d.ts.map +1 -0
- package/dist/hooks/graph-tools.js +125 -0
- package/dist/hooks/graph-tools.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/loop.d.ts +23 -0
- package/dist/hooks/loop.d.ts.map +1 -0
- package/dist/hooks/loop.js +667 -0
- package/dist/hooks/loop.js.map +1 -0
- package/dist/hooks/sandbox-tools.d.ts +13 -0
- package/dist/hooks/sandbox-tools.d.ts.map +1 -0
- package/dist/hooks/sandbox-tools.js +105 -0
- package/dist/hooks/sandbox-tools.js.map +1 -0
- package/dist/hooks/session.d.ts +19 -0
- package/dist/hooks/session.d.ts.map +1 -0
- package/dist/hooks/session.js +56 -0
- package/dist/hooks/session.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +298 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox/context.d.ts +27 -0
- package/dist/sandbox/context.d.ts.map +1 -0
- package/dist/sandbox/context.js +18 -0
- package/dist/sandbox/context.js.map +1 -0
- package/dist/sandbox/docker.d.ts +29 -0
- package/dist/sandbox/docker.d.ts.map +1 -0
- package/dist/sandbox/docker.js +213 -0
- package/dist/sandbox/docker.js.map +1 -0
- package/dist/sandbox/manager.d.ts +23 -0
- package/dist/sandbox/manager.d.ts.map +1 -0
- package/dist/sandbox/manager.js +131 -0
- package/dist/sandbox/manager.js.map +1 -0
- package/dist/sandbox/path.d.ts +4 -0
- package/dist/sandbox/path.d.ts.map +1 -0
- package/dist/sandbox/path.js +27 -0
- package/dist/sandbox/path.js.map +1 -0
- package/dist/services/kv.d.ts +17 -0
- package/dist/services/kv.d.ts.map +1 -0
- package/dist/services/kv.js +62 -0
- package/dist/services/kv.js.map +1 -0
- package/dist/services/loop.d.ts +96 -0
- package/dist/services/loop.d.ts.map +1 -0
- package/dist/services/loop.js +315 -0
- package/dist/services/loop.js.map +1 -0
- package/dist/setup.d.ts +4 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +118 -0
- package/dist/setup.js.map +1 -0
- package/dist/storage/database.d.ts +6 -0
- package/dist/storage/database.d.ts.map +1 -0
- package/dist/storage/database.js +90 -0
- package/dist/storage/database.js.map +1 -0
- package/dist/storage/graph-projects.d.ts +80 -0
- package/dist/storage/graph-projects.d.ts.map +1 -0
- package/dist/storage/graph-projects.js +154 -0
- package/dist/storage/graph-projects.js.map +1 -0
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +3 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/kv-queries.d.ts +18 -0
- package/dist/storage/kv-queries.d.ts.map +1 -0
- package/dist/storage/kv-queries.js +70 -0
- package/dist/storage/kv-queries.js.map +1 -0
- package/dist/tools/graph.d.ts +9 -0
- package/dist/tools/graph.d.ts.map +1 -0
- package/dist/tools/graph.js +272 -0
- package/dist/tools/graph.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +16 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/loop.d.ts +21 -0
- package/dist/tools/loop.d.ts.map +1 -0
- package/dist/tools/loop.js +570 -0
- package/dist/tools/loop.js.map +1 -0
- package/dist/tools/plan-approval.d.ts +15 -0
- package/dist/tools/plan-approval.d.ts.map +1 -0
- package/dist/tools/plan-approval.js +203 -0
- package/dist/tools/plan-approval.js.map +1 -0
- package/dist/tools/plan-execute.d.ts +4 -0
- package/dist/tools/plan-execute.d.ts.map +1 -0
- package/dist/tools/plan-execute.js +85 -0
- package/dist/tools/plan-execute.js.map +1 -0
- package/dist/tools/plan-kv.d.ts +4 -0
- package/dist/tools/plan-kv.d.ts.map +1 -0
- package/dist/tools/plan-kv.js +107 -0
- package/dist/tools/plan-kv.js.map +1 -0
- package/dist/tools/review.d.ts +4 -0
- package/dist/tools/review.d.ts.map +1 -0
- package/dist/tools/review.js +90 -0
- package/dist/tools/review.js.map +1 -0
- package/dist/tools/sandbox-fs.d.ts +22 -0
- package/dist/tools/sandbox-fs.d.ts.map +1 -0
- package/dist/tools/sandbox-fs.js +83 -0
- package/dist/tools/sandbox-fs.js.map +1 -0
- package/dist/tools/types.d.ts +26 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tui.d.ts +3 -0
- package/dist/tui.js +2061 -0
- package/dist/types.d.ts +124 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/git-branch.d.ts +11 -0
- package/dist/utils/git-branch.d.ts.map +1 -0
- package/dist/utils/git-branch.js +35 -0
- package/dist/utils/git-branch.js.map +1 -0
- package/dist/utils/graph-status-store.d.ts +72 -0
- package/dist/utils/graph-status-store.d.ts.map +1 -0
- package/dist/utils/graph-status-store.js +62 -0
- package/dist/utils/graph-status-store.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +89 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/loop-format.d.ts +5 -0
- package/dist/utils/loop-format.d.ts.map +1 -0
- package/dist/utils/loop-format.js +29 -0
- package/dist/utils/loop-format.js.map +1 -0
- package/dist/utils/loop-helpers.d.ts +9 -0
- package/dist/utils/loop-helpers.d.ts.map +1 -0
- package/dist/utils/loop-helpers.js +20 -0
- package/dist/utils/loop-helpers.js.map +1 -0
- package/dist/utils/loop-launch.d.ts +32 -0
- package/dist/utils/loop-launch.d.ts.map +1 -0
- package/dist/utils/loop-launch.js +162 -0
- package/dist/utils/loop-launch.js.map +1 -0
- package/dist/utils/model-fallback.d.ts +27 -0
- package/dist/utils/model-fallback.d.ts.map +1 -0
- package/dist/utils/model-fallback.js +33 -0
- package/dist/utils/model-fallback.js.map +1 -0
- package/dist/utils/partial-match.d.ts +7 -0
- package/dist/utils/partial-match.d.ts.map +1 -0
- package/dist/utils/partial-match.js +56 -0
- package/dist/utils/partial-match.js.map +1 -0
- package/dist/utils/plan-execution.d.ts +65 -0
- package/dist/utils/plan-execution.d.ts.map +1 -0
- package/dist/utils/plan-execution.js +107 -0
- package/dist/utils/plan-execution.js.map +1 -0
- package/dist/utils/session-stats.d.ts +36 -0
- package/dist/utils/session-stats.d.ts.map +1 -0
- package/dist/utils/session-stats.js +145 -0
- package/dist/utils/session-stats.js.map +1 -0
- package/dist/utils/tui-graph-status.d.ts +38 -0
- package/dist/utils/tui-graph-status.d.ts.map +1 -0
- package/dist/utils/tui-graph-status.js +95 -0
- package/dist/utils/tui-graph-status.js.map +1 -0
- package/dist/utils/tui-plan-store.d.ts +54 -0
- package/dist/utils/tui-plan-store.d.ts.map +1 -0
- package/dist/utils/tui-plan-store.js +168 -0
- package/dist/utils/tui-plan-store.js.map +1 -0
- package/dist/utils/tui-refresh-helpers.d.ts +44 -0
- package/dist/utils/tui-refresh-helpers.d.ts.map +1 -0
- package/dist/utils/tui-refresh-helpers.js +120 -0
- package/dist/utils/tui-refresh-helpers.js.map +1 -0
- package/dist/utils/upgrade.d.ts +23 -0
- package/dist/utils/upgrade.d.ts.map +1 -0
- package/dist/utils/upgrade.js +111 -0
- package/dist/utils/upgrade.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +92 -0
- package/scripts/build.ts +67 -0
- package/src/command/template/review.txt +101 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
import { tool } from '@opencode-ai/plugin';
|
|
2
|
+
import { execSync, spawnSync } from 'child_process';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import { parseModelString, retryWithModelFallback } from '../utils/model-fallback';
|
|
6
|
+
import { slugify } from '../utils/logger';
|
|
7
|
+
import { findPartialMatch } from '../utils/partial-match';
|
|
8
|
+
import { formatSessionOutput, formatAuditResult } from '../utils/loop-format';
|
|
9
|
+
import { fetchSessionOutput, MAX_RETRIES, LOOP_PERMISSION_RULESET, buildCompletionSignalInstructions, DEFAULT_COMPLETION_SIGNAL } from '../services/loop';
|
|
10
|
+
import { isSandboxEnabled } from '../sandbox/context';
|
|
11
|
+
import { formatDuration, computeElapsedSeconds } from '../utils/loop-helpers';
|
|
12
|
+
const z = tool.schema;
|
|
13
|
+
export async function setupLoop(ctx, options) {
|
|
14
|
+
const { v2, directory, config, loopService, logger, sandboxManager } = ctx;
|
|
15
|
+
const projectDir = directory;
|
|
16
|
+
const maxIter = options.maxIterations ?? config.loop?.defaultMaxIterations ?? 0;
|
|
17
|
+
const uniqueWorktreeName = loopService.generateUniqueWorktreeName(options.worktreeName);
|
|
18
|
+
let loopContext;
|
|
19
|
+
if (!options.worktree) {
|
|
20
|
+
let currentBranch;
|
|
21
|
+
try {
|
|
22
|
+
currentBranch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: projectDir, encoding: 'utf-8' }).trim();
|
|
23
|
+
}
|
|
24
|
+
catch (_err) {
|
|
25
|
+
logger.log(`loop: no git branch detected, running without branch info`);
|
|
26
|
+
}
|
|
27
|
+
const createResult = await v2.session.create({
|
|
28
|
+
title: options.sessionTitle,
|
|
29
|
+
directory: projectDir,
|
|
30
|
+
permission: LOOP_PERMISSION_RULESET,
|
|
31
|
+
});
|
|
32
|
+
if (createResult.error || !createResult.data) {
|
|
33
|
+
logger.error(`loop: failed to create session`, createResult.error);
|
|
34
|
+
return 'Failed to create loop session.';
|
|
35
|
+
}
|
|
36
|
+
loopContext = {
|
|
37
|
+
sessionId: createResult.data.id,
|
|
38
|
+
directory: projectDir,
|
|
39
|
+
branch: currentBranch,
|
|
40
|
+
worktree: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const worktreeResult = await v2.worktree.create({
|
|
45
|
+
worktreeCreateInput: { name: uniqueWorktreeName },
|
|
46
|
+
});
|
|
47
|
+
if (worktreeResult.error || !worktreeResult.data) {
|
|
48
|
+
logger.error(`loop: failed to create worktree`, worktreeResult.error);
|
|
49
|
+
return 'Failed to create worktree.';
|
|
50
|
+
}
|
|
51
|
+
const worktreeInfo = worktreeResult.data;
|
|
52
|
+
logger.log(`loop: worktree created at ${worktreeInfo.directory} (branch: ${worktreeInfo.branch})`);
|
|
53
|
+
const createResult = await v2.session.create({
|
|
54
|
+
title: options.sessionTitle,
|
|
55
|
+
directory: worktreeInfo.directory,
|
|
56
|
+
permission: LOOP_PERMISSION_RULESET,
|
|
57
|
+
});
|
|
58
|
+
if (createResult.error || !createResult.data) {
|
|
59
|
+
logger.error(`loop: failed to create session`, createResult.error);
|
|
60
|
+
try {
|
|
61
|
+
await v2.worktree.remove({ worktreeRemoveInput: { directory: worktreeInfo.directory } });
|
|
62
|
+
}
|
|
63
|
+
catch (cleanupErr) {
|
|
64
|
+
logger.error(`loop: failed to cleanup worktree`, cleanupErr);
|
|
65
|
+
}
|
|
66
|
+
return 'Failed to create loop session.';
|
|
67
|
+
}
|
|
68
|
+
loopContext = {
|
|
69
|
+
sessionId: createResult.data.id,
|
|
70
|
+
directory: worktreeInfo.directory,
|
|
71
|
+
branch: worktreeInfo.branch,
|
|
72
|
+
worktree: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
let sandboxContainerName;
|
|
76
|
+
const sandboxEnabled = isSandboxEnabled(config, sandboxManager) && !!options.worktree;
|
|
77
|
+
if (sandboxEnabled) {
|
|
78
|
+
try {
|
|
79
|
+
const result = await sandboxManager.start(uniqueWorktreeName, loopContext.directory);
|
|
80
|
+
sandboxContainerName = result.containerName;
|
|
81
|
+
logger.log(`Sandbox container ${sandboxContainerName} started for loop ${uniqueWorktreeName}`);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
85
|
+
logger.error(`loop: failed to start sandbox container`, err);
|
|
86
|
+
return `Failed to start sandbox container: ${message}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const state = {
|
|
90
|
+
active: true,
|
|
91
|
+
sessionId: loopContext.sessionId,
|
|
92
|
+
worktreeName: uniqueWorktreeName,
|
|
93
|
+
worktreeDir: loopContext.directory,
|
|
94
|
+
worktreeBranch: loopContext.branch,
|
|
95
|
+
iteration: 1,
|
|
96
|
+
maxIterations: maxIter,
|
|
97
|
+
completionSignal: options.completionSignal,
|
|
98
|
+
startedAt: new Date().toISOString(),
|
|
99
|
+
prompt: options.prompt,
|
|
100
|
+
phase: 'coding',
|
|
101
|
+
audit: options.audit,
|
|
102
|
+
errorCount: 0,
|
|
103
|
+
auditCount: 0,
|
|
104
|
+
worktree: options.worktree,
|
|
105
|
+
sandbox: sandboxEnabled,
|
|
106
|
+
sandboxContainerName,
|
|
107
|
+
};
|
|
108
|
+
loopService.setState(uniqueWorktreeName, state);
|
|
109
|
+
loopService.registerSession(loopContext.sessionId, uniqueWorktreeName);
|
|
110
|
+
logger.log(`loop: state stored for worktree=${uniqueWorktreeName}`);
|
|
111
|
+
let promptText = options.prompt;
|
|
112
|
+
if (options.completionSignal) {
|
|
113
|
+
promptText += buildCompletionSignalInstructions(options.completionSignal);
|
|
114
|
+
}
|
|
115
|
+
const { result: promptResult, usedModel: actualModel } = await retryWithModelFallback(() => v2.session.promptAsync({
|
|
116
|
+
sessionID: loopContext.sessionId,
|
|
117
|
+
directory: loopContext.directory,
|
|
118
|
+
parts: [{ type: 'text', text: promptText }],
|
|
119
|
+
...(options.agent && { agent: options.agent }),
|
|
120
|
+
model: options.model,
|
|
121
|
+
}), () => v2.session.promptAsync({
|
|
122
|
+
sessionID: loopContext.sessionId,
|
|
123
|
+
directory: loopContext.directory,
|
|
124
|
+
parts: [{ type: 'text', text: promptText }],
|
|
125
|
+
...(options.agent && { agent: options.agent }),
|
|
126
|
+
}), options.model, logger);
|
|
127
|
+
if (promptResult.error) {
|
|
128
|
+
logger.error(`loop: failed to send prompt`, promptResult.error);
|
|
129
|
+
loopService.deleteState(uniqueWorktreeName);
|
|
130
|
+
if (sandboxEnabled) {
|
|
131
|
+
try {
|
|
132
|
+
await sandboxManager.stop(uniqueWorktreeName);
|
|
133
|
+
}
|
|
134
|
+
catch (sbxErr) {
|
|
135
|
+
logger.error(`loop: failed to stop sandbox container on prompt failure`, sbxErr);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (options.worktree) {
|
|
139
|
+
try {
|
|
140
|
+
await v2.worktree.remove({ worktreeRemoveInput: { directory: loopContext.directory } });
|
|
141
|
+
}
|
|
142
|
+
catch (cleanupErr) {
|
|
143
|
+
logger.error(`loop: failed to cleanup worktree`, cleanupErr);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return !options.worktree
|
|
147
|
+
? 'Loop session created but failed to send prompt.'
|
|
148
|
+
: 'Loop session created but failed to send prompt. Cleaned up.';
|
|
149
|
+
}
|
|
150
|
+
options.onLoopStarted?.(uniqueWorktreeName);
|
|
151
|
+
if (!options.worktree) {
|
|
152
|
+
v2.tui.selectSession({ sessionID: loopContext.sessionId }).catch((err) => {
|
|
153
|
+
logger.error('loop: failed to navigate TUI to new session', err);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const maxInfo = maxIter > 0 ? maxIter.toString() : 'unlimited';
|
|
157
|
+
const auditInfo = options.audit ? 'enabled' : 'disabled';
|
|
158
|
+
const modelInfo = actualModel ? `${actualModel.providerID}/${actualModel.modelID}` : 'default';
|
|
159
|
+
const lines = [
|
|
160
|
+
!options.worktree ? 'Memory loop activated! (in-place mode)' : 'Memory loop activated!',
|
|
161
|
+
'',
|
|
162
|
+
`Session: ${loopContext.sessionId}`,
|
|
163
|
+
`Title: ${options.sessionTitle}`,
|
|
164
|
+
];
|
|
165
|
+
if (!options.worktree) {
|
|
166
|
+
lines.push(`Directory: ${loopContext.directory}`);
|
|
167
|
+
if (loopContext.branch) {
|
|
168
|
+
lines.push(`Branch: ${loopContext.branch} (in-place)`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
lines.push(`Worktree name: ${uniqueWorktreeName}`);
|
|
173
|
+
lines.push(`Worktree: ${loopContext.directory}`);
|
|
174
|
+
lines.push(`Branch: ${loopContext.branch}`);
|
|
175
|
+
}
|
|
176
|
+
lines.push(`Model: ${modelInfo}`, `Max iterations: ${maxInfo}`, `Completion promise: ${options.completionSignal ?? 'none'}`, `Audit: ${auditInfo}`, '', 'The loop will automatically continue when the session goes idle.', 'Your job is done — just confirm to the user that the loop has been launched.', 'The user can run loop-status or loop-cancel later if needed.');
|
|
177
|
+
return lines.join('\n');
|
|
178
|
+
}
|
|
179
|
+
export function createLoopTools(ctx) {
|
|
180
|
+
const { v2, loopService, loopHandler, config, logger } = ctx;
|
|
181
|
+
return {
|
|
182
|
+
loop: tool({
|
|
183
|
+
description: 'Execute a plan using an iterative development loop. Default runs in current directory. Set worktree to true for isolated git worktree.',
|
|
184
|
+
args: {
|
|
185
|
+
plan: z.string().optional().describe('The full implementation plan. If omitted, reads from the session plan store.'),
|
|
186
|
+
title: z.string().describe('Short title for the session (shown in session list)'),
|
|
187
|
+
worktree: z.boolean().optional().default(false).describe('Run in isolated git worktree instead of current directory'),
|
|
188
|
+
worktreeName: z.string().optional().describe('Name for the worktree (max 25 chars, auto-incremented if collision exists)'),
|
|
189
|
+
},
|
|
190
|
+
execute: async (args, context) => {
|
|
191
|
+
if (config.loop?.enabled === false) {
|
|
192
|
+
return 'Loops are disabled in plugin config. Use plan-execute instead.';
|
|
193
|
+
}
|
|
194
|
+
logger.log(`loop: creating worktree for plan="${args.title}"`);
|
|
195
|
+
let planText = args.plan;
|
|
196
|
+
if (!planText) {
|
|
197
|
+
const planKey = `plan:${context.sessionID}`;
|
|
198
|
+
const cached = ctx.kvService.get(ctx.projectId, planKey);
|
|
199
|
+
if (!cached) {
|
|
200
|
+
return 'No plan found. Write the plan via plan-write before calling this tool, or pass it directly as the plan argument.';
|
|
201
|
+
}
|
|
202
|
+
planText = typeof cached === 'string' ? cached : JSON.stringify(cached, null, 2);
|
|
203
|
+
ctx.kvService.delete(ctx.projectId, planKey);
|
|
204
|
+
}
|
|
205
|
+
const sessionTitle = args.title.length > 60 ? `${args.title.substring(0, 57)}...` : args.title;
|
|
206
|
+
const loopModel = parseModelString(config.loop?.model) ?? parseModelString(config.executionModel);
|
|
207
|
+
const audit = config.loop?.defaultAudit ?? true;
|
|
208
|
+
const worktreeName = args.worktreeName ? slugify(args.worktreeName) : slugify(sessionTitle);
|
|
209
|
+
return setupLoop(ctx, {
|
|
210
|
+
prompt: planText,
|
|
211
|
+
sessionTitle: `Loop: ${sessionTitle}`,
|
|
212
|
+
worktreeName,
|
|
213
|
+
completionSignal: DEFAULT_COMPLETION_SIGNAL,
|
|
214
|
+
maxIterations: config.loop?.defaultMaxIterations ?? 0,
|
|
215
|
+
audit: audit,
|
|
216
|
+
agent: 'code',
|
|
217
|
+
model: loopModel,
|
|
218
|
+
worktree: args.worktree,
|
|
219
|
+
onLoopStarted: (id) => loopHandler.startWatchdog(id),
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
}),
|
|
223
|
+
'loop-cancel': tool({
|
|
224
|
+
description: 'Cancels the only active loop when called with no arguments. Pass a name to cancel a specific loop.',
|
|
225
|
+
args: {
|
|
226
|
+
name: z.string().optional().describe('Worktree name of the loop to cancel'),
|
|
227
|
+
},
|
|
228
|
+
execute: async (args) => {
|
|
229
|
+
let state;
|
|
230
|
+
if (args.name) {
|
|
231
|
+
const name = args.name;
|
|
232
|
+
const matchedState = loopService.findByWorktreeName(name);
|
|
233
|
+
if (!matchedState) {
|
|
234
|
+
const candidates = loopService.findCandidatesByPartialName(name);
|
|
235
|
+
if (candidates.length > 0) {
|
|
236
|
+
return `Multiple loops match "${name}":\n${candidates.map((s) => `- ${s.worktreeName}`).join('\n')}\n\nBe more specific.`;
|
|
237
|
+
}
|
|
238
|
+
const recent = loopService.listRecent();
|
|
239
|
+
const foundRecent = recent.find((s) => s.worktreeName === name || (s.worktreeBranch && s.worktreeBranch.toLowerCase().includes(name.toLowerCase())));
|
|
240
|
+
if (foundRecent) {
|
|
241
|
+
return `Loop "${foundRecent.worktreeName}" has already completed.`;
|
|
242
|
+
}
|
|
243
|
+
return `No active loop found for worktree "${name}".`;
|
|
244
|
+
}
|
|
245
|
+
state = matchedState;
|
|
246
|
+
if (!state.active) {
|
|
247
|
+
return `Loop "${state.worktreeName}" has already completed.`;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
const active = loopService.listActive();
|
|
252
|
+
if (active.length === 0)
|
|
253
|
+
return 'No active loops.';
|
|
254
|
+
if (active.length === 1) {
|
|
255
|
+
state = active[0];
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
return `Multiple active loops. Specify a name:\n${active.map((s) => `- ${s.worktreeName} (iteration ${s.iteration})`).join('\n')}`;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
await loopHandler.cancelBySessionId(state.sessionId);
|
|
262
|
+
logger.log(`loop-cancel: cancelled loop for session=${state.sessionId} at iteration ${state.iteration}`);
|
|
263
|
+
if (config.loop?.cleanupWorktree && state.worktree && state.worktreeDir) {
|
|
264
|
+
try {
|
|
265
|
+
const gitCommonDir = execSync('git rev-parse --git-common-dir', { cwd: state.worktreeDir, encoding: 'utf-8' }).trim();
|
|
266
|
+
const gitRoot = resolve(state.worktreeDir, gitCommonDir, '..');
|
|
267
|
+
const removeResult = spawnSync('git', ['worktree', 'remove', '-f', state.worktreeDir], { cwd: gitRoot, encoding: 'utf-8' });
|
|
268
|
+
if (removeResult.status !== 0) {
|
|
269
|
+
throw new Error(removeResult.stderr || 'git worktree remove failed');
|
|
270
|
+
}
|
|
271
|
+
logger.log(`loop-cancel: removed worktree ${state.worktreeDir}`);
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
logger.error(`loop-cancel: failed to remove worktree`, err);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const modeInfo = !state.worktree ? ' (in-place)' : '';
|
|
278
|
+
const branchInfo = state.worktreeBranch ? `\nBranch: ${state.worktreeBranch}` : '';
|
|
279
|
+
return `Cancelled loop "${state.worktreeName}"${modeInfo} (was at iteration ${state.iteration}).\nDirectory: ${state.worktreeDir}${branchInfo}`;
|
|
280
|
+
},
|
|
281
|
+
}),
|
|
282
|
+
'loop-status': tool({
|
|
283
|
+
description: 'Lists all active loops when called with no arguments. Pass a worktree name for detailed status of a specific loop. Use restart to resume an inactive loop. Use restart with force to force-restart a stuck active loop.',
|
|
284
|
+
args: {
|
|
285
|
+
name: z.string().optional().describe('Worktree name to check for detailed status'),
|
|
286
|
+
restart: z.boolean().optional().default(false).describe('Restart an inactive loop by name'),
|
|
287
|
+
force: z.boolean().optional().default(false).describe('Force restart an active/stuck loop'),
|
|
288
|
+
},
|
|
289
|
+
execute: async (args) => {
|
|
290
|
+
const active = loopService.listActive();
|
|
291
|
+
if (args.restart) {
|
|
292
|
+
if (!args.name) {
|
|
293
|
+
return 'Specify a loop name to restart. Use loop-status to see available loops.';
|
|
294
|
+
}
|
|
295
|
+
const recent = loopService.listRecent();
|
|
296
|
+
const allStates = [...active, ...recent];
|
|
297
|
+
const { match: stoppedState, candidates } = findPartialMatch(args.name, allStates, (s) => [s.worktreeName, s.worktreeBranch]);
|
|
298
|
+
if (!stoppedState && candidates.length > 0) {
|
|
299
|
+
return `Multiple loops match "${args.name}":\n${candidates.map((s) => `- ${s.worktreeName}`).join('\n')}\n\nBe more specific.`;
|
|
300
|
+
}
|
|
301
|
+
if (!stoppedState) {
|
|
302
|
+
const available = [...active, ...recent].map((s) => `- ${s.worktreeName}`).join('\n');
|
|
303
|
+
return `No loop found for "${args.name}".\n\nAvailable loops:\n${available}`;
|
|
304
|
+
}
|
|
305
|
+
if (stoppedState.active) {
|
|
306
|
+
if (!args.force) {
|
|
307
|
+
return `Loop "${stoppedState.worktreeName}" is currently active. Use restart with force: true to force-restart a stuck loop.`;
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
await v2.session.abort({ sessionID: stoppedState.sessionId });
|
|
311
|
+
}
|
|
312
|
+
catch { }
|
|
313
|
+
loopService.unregisterSession(stoppedState.sessionId);
|
|
314
|
+
}
|
|
315
|
+
if (stoppedState.terminationReason === 'completed') {
|
|
316
|
+
return `Loop "${stoppedState.worktreeName}" completed successfully and cannot be restarted.`;
|
|
317
|
+
}
|
|
318
|
+
if (!stoppedState.worktree && stoppedState.worktreeDir) {
|
|
319
|
+
if (!existsSync(stoppedState.worktreeDir)) {
|
|
320
|
+
return `Cannot restart "${stoppedState.worktreeName}": worktree directory no longer exists at ${stoppedState.worktreeDir}. The worktree may have been cleaned up.`;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const createParams = {
|
|
324
|
+
title: stoppedState.worktreeName,
|
|
325
|
+
directory: stoppedState.worktreeDir,
|
|
326
|
+
permission: LOOP_PERMISSION_RULESET,
|
|
327
|
+
};
|
|
328
|
+
const createResult = await v2.session.create(createParams);
|
|
329
|
+
if (createResult.error || !createResult.data) {
|
|
330
|
+
logger.error(`loop-restart: failed to create session`, createResult.error);
|
|
331
|
+
return `Failed to create new session for restart.`;
|
|
332
|
+
}
|
|
333
|
+
const newSessionId = createResult.data.id;
|
|
334
|
+
loopService.deleteState(stoppedState.worktreeName);
|
|
335
|
+
const restartSandbox = isSandboxEnabled(config, ctx.sandboxManager);
|
|
336
|
+
if (restartSandbox) {
|
|
337
|
+
try {
|
|
338
|
+
const sbxResult = await ctx.sandboxManager.start(stoppedState.worktreeName, stoppedState.worktreeDir);
|
|
339
|
+
logger.log(`loop-restart: started sandbox container ${sbxResult.containerName}`);
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
logger.error(`loop-restart: failed to start sandbox container`, err);
|
|
343
|
+
return `Restart failed: could not start sandbox container.`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const newState = {
|
|
347
|
+
active: true,
|
|
348
|
+
sessionId: newSessionId,
|
|
349
|
+
worktreeName: stoppedState.worktreeName,
|
|
350
|
+
worktreeDir: stoppedState.worktreeDir,
|
|
351
|
+
worktreeBranch: stoppedState.worktreeBranch,
|
|
352
|
+
iteration: stoppedState.iteration,
|
|
353
|
+
maxIterations: stoppedState.maxIterations,
|
|
354
|
+
completionSignal: stoppedState.completionSignal,
|
|
355
|
+
startedAt: new Date().toISOString(),
|
|
356
|
+
prompt: stoppedState.prompt,
|
|
357
|
+
phase: 'coding',
|
|
358
|
+
audit: stoppedState.audit,
|
|
359
|
+
errorCount: 0,
|
|
360
|
+
auditCount: 0,
|
|
361
|
+
worktree: stoppedState.worktree,
|
|
362
|
+
sandbox: restartSandbox,
|
|
363
|
+
sandboxContainerName: restartSandbox
|
|
364
|
+
? ctx.sandboxManager?.docker.containerName(stoppedState.worktreeName)
|
|
365
|
+
: undefined,
|
|
366
|
+
};
|
|
367
|
+
loopService.setState(stoppedState.worktreeName, newState);
|
|
368
|
+
loopService.registerSession(newSessionId, stoppedState.worktreeName);
|
|
369
|
+
let promptText = stoppedState.prompt ?? '';
|
|
370
|
+
if (stoppedState.completionSignal) {
|
|
371
|
+
promptText += buildCompletionSignalInstructions(stoppedState.completionSignal);
|
|
372
|
+
}
|
|
373
|
+
const loopModel = parseModelString(config.loop?.model) ?? parseModelString(config.executionModel);
|
|
374
|
+
const { result: promptResult } = await retryWithModelFallback(() => v2.session.promptAsync({
|
|
375
|
+
sessionID: newSessionId,
|
|
376
|
+
directory: stoppedState.worktreeDir,
|
|
377
|
+
parts: [{ type: 'text', text: promptText }],
|
|
378
|
+
agent: 'code',
|
|
379
|
+
model: loopModel,
|
|
380
|
+
}), () => v2.session.promptAsync({
|
|
381
|
+
sessionID: newSessionId,
|
|
382
|
+
directory: stoppedState.worktreeDir,
|
|
383
|
+
parts: [{ type: 'text', text: promptText }],
|
|
384
|
+
agent: 'code',
|
|
385
|
+
}), loopModel, logger);
|
|
386
|
+
if (promptResult.error) {
|
|
387
|
+
logger.error(`loop-restart: failed to send prompt`, promptResult.error);
|
|
388
|
+
loopService.deleteState(stoppedState.worktreeName);
|
|
389
|
+
if (restartSandbox) {
|
|
390
|
+
try {
|
|
391
|
+
await ctx.sandboxManager.stop(stoppedState.worktreeName);
|
|
392
|
+
}
|
|
393
|
+
catch (sbxErr) {
|
|
394
|
+
logger.error(`loop-restart: failed to stop sandbox on prompt failure`, sbxErr);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return `Restart failed: could not send prompt to new session.`;
|
|
398
|
+
}
|
|
399
|
+
loopHandler.startWatchdog(stoppedState.worktreeName);
|
|
400
|
+
const modeInfo = !stoppedState.worktree ? ' (in-place)' : '';
|
|
401
|
+
const branchInfo = stoppedState.worktreeBranch ? `\nBranch: ${stoppedState.worktreeBranch}` : '';
|
|
402
|
+
return [
|
|
403
|
+
`Restarted loop "${stoppedState.worktreeName}"${modeInfo}`,
|
|
404
|
+
'',
|
|
405
|
+
`New session: ${newSessionId}`,
|
|
406
|
+
`Continuing from iteration: ${stoppedState.iteration}`,
|
|
407
|
+
`Previous termination: ${stoppedState.terminationReason}`,
|
|
408
|
+
`Directory: ${stoppedState.worktreeDir}${branchInfo}`,
|
|
409
|
+
`Audit: ${stoppedState.audit ? 'enabled' : 'disabled'}`,
|
|
410
|
+
].join('\n');
|
|
411
|
+
}
|
|
412
|
+
if (!args.name) {
|
|
413
|
+
const recent = loopService.listRecent();
|
|
414
|
+
if (active.length === 0) {
|
|
415
|
+
if (recent.length === 0)
|
|
416
|
+
return 'No loops found.';
|
|
417
|
+
const lines = ['Recently Completed Loops', ''];
|
|
418
|
+
recent.forEach((s, i) => {
|
|
419
|
+
const durationStr = formatDuration(computeElapsedSeconds(s.startedAt, s.completedAt));
|
|
420
|
+
lines.push(`${i + 1}. ${s.worktreeName}`);
|
|
421
|
+
lines.push(` Reason: ${s.terminationReason ?? 'unknown'} | Iterations: ${s.iteration} | Duration: ${durationStr} | Completed: ${s.completedAt ?? 'unknown'}`);
|
|
422
|
+
lines.push('');
|
|
423
|
+
});
|
|
424
|
+
lines.push('Use loop-status <name> for detailed info.');
|
|
425
|
+
return lines.join('\n');
|
|
426
|
+
}
|
|
427
|
+
const statuses = {};
|
|
428
|
+
try {
|
|
429
|
+
const uniqueDirs = [...new Set(active.map((s) => s.worktreeDir).filter(Boolean))];
|
|
430
|
+
const results = await Promise.allSettled(uniqueDirs.map((dir) => v2.session.status({ directory: dir })));
|
|
431
|
+
for (const result of results) {
|
|
432
|
+
if (result.status === 'fulfilled' && result.value.data) {
|
|
433
|
+
Object.assign(statuses, result.value.data);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
}
|
|
439
|
+
const lines = [`Active Loops (${active.length})`, ''];
|
|
440
|
+
active.forEach((s, i) => {
|
|
441
|
+
const duration = formatDuration(computeElapsedSeconds(s.startedAt));
|
|
442
|
+
const iterInfo = s.maxIterations && s.maxIterations > 0 ? `${s.iteration} / ${s.maxIterations}` : `${s.iteration} (unlimited)`;
|
|
443
|
+
const sessionStatus = statuses[s.sessionId]?.type ?? 'unavailable';
|
|
444
|
+
const modeIndicator = !s.worktree ? ' (in-place)' : '';
|
|
445
|
+
const stallInfo = loopHandler.getStallInfo(s.worktreeName);
|
|
446
|
+
const stallCount = stallInfo?.consecutiveStalls ?? 0;
|
|
447
|
+
const stallSuffix = stallCount > 0 ? ` | Stalls: ${stallCount}` : '';
|
|
448
|
+
lines.push(`${i + 1}. ${s.worktreeName}${modeIndicator}`);
|
|
449
|
+
lines.push(` Phase: ${s.phase} | Iteration: ${iterInfo} | Duration: ${duration} | Status: ${sessionStatus}${stallSuffix}`);
|
|
450
|
+
lines.push('');
|
|
451
|
+
});
|
|
452
|
+
if (recent.length > 0) {
|
|
453
|
+
lines.push('Recently Completed:');
|
|
454
|
+
lines.push('');
|
|
455
|
+
const limitedRecent = recent.slice(0, 10);
|
|
456
|
+
limitedRecent.forEach((s, i) => {
|
|
457
|
+
const durationStr = formatDuration(computeElapsedSeconds(s.startedAt, s.completedAt));
|
|
458
|
+
lines.push(`${i + 1}. ${s.worktreeName}`);
|
|
459
|
+
lines.push(` Reason: ${s.terminationReason ?? 'unknown'} | Iterations: ${s.iteration} | Duration: ${durationStr} | Completed: ${s.completedAt ?? 'unknown'}`);
|
|
460
|
+
lines.push('');
|
|
461
|
+
});
|
|
462
|
+
if (recent.length > 10) {
|
|
463
|
+
lines.push(` ... and ${recent.length - 10} more. Use loop-status <name> for details.`);
|
|
464
|
+
lines.push('');
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
lines.push('Use loop-status <name> for detailed info, or loop-cancel <name> to stop a loop.');
|
|
468
|
+
return lines.join('\n');
|
|
469
|
+
}
|
|
470
|
+
const state = loopService.findByWorktreeName(args.name);
|
|
471
|
+
if (!state) {
|
|
472
|
+
const candidates = loopService.findCandidatesByPartialName(args.name);
|
|
473
|
+
if (candidates.length > 0) {
|
|
474
|
+
return `Multiple loops match "${args.name}":\n${candidates.map((s) => `- ${s.worktreeName}`).join('\n')}\n\nBe more specific.`;
|
|
475
|
+
}
|
|
476
|
+
return `No loop found for worktree "${args.name}".`;
|
|
477
|
+
}
|
|
478
|
+
if (!state.active) {
|
|
479
|
+
const maxInfo = state.maxIterations && state.maxIterations > 0 ? `${state.iteration} / ${state.maxIterations}` : `${state.iteration} (unlimited)`;
|
|
480
|
+
const durationStr = formatDuration(computeElapsedSeconds(state.startedAt, state.completedAt));
|
|
481
|
+
const statusLines = [
|
|
482
|
+
'Loop Status (Inactive)',
|
|
483
|
+
'',
|
|
484
|
+
`Name: ${state.worktreeName}`,
|
|
485
|
+
`Session: ${state.sessionId}`,
|
|
486
|
+
];
|
|
487
|
+
if (!state.worktree) {
|
|
488
|
+
statusLines.push(`Mode: in-place | Directory: ${state.worktreeDir}`);
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
statusLines.push(`Worktree: ${state.worktreeDir}`);
|
|
492
|
+
}
|
|
493
|
+
statusLines.push(`Iteration: ${maxInfo}`, `Duration: ${durationStr}`, `Reason: ${state.terminationReason ?? 'unknown'}`);
|
|
494
|
+
if (state.worktreeBranch) {
|
|
495
|
+
statusLines.push(`Branch: ${state.worktreeBranch}`);
|
|
496
|
+
}
|
|
497
|
+
statusLines.push(`Started: ${state.startedAt}`, ...(state.completedAt ? [`Completed: ${state.completedAt}`] : []));
|
|
498
|
+
if (state.lastAuditResult) {
|
|
499
|
+
statusLines.push(...formatAuditResult(state.lastAuditResult));
|
|
500
|
+
}
|
|
501
|
+
const sessionOutput = state.worktreeDir ? await fetchSessionOutput(v2, state.sessionId, state.worktreeDir, logger) : null;
|
|
502
|
+
if (sessionOutput) {
|
|
503
|
+
statusLines.push('');
|
|
504
|
+
statusLines.push('Session Output:');
|
|
505
|
+
statusLines.push(...formatSessionOutput(sessionOutput));
|
|
506
|
+
}
|
|
507
|
+
return statusLines.join('\n');
|
|
508
|
+
}
|
|
509
|
+
const maxInfo = state.maxIterations && state.maxIterations > 0 ? `${state.iteration} / ${state.maxIterations}` : `${state.iteration} (unlimited)`;
|
|
510
|
+
const promptPreview = state.prompt && state.prompt.length > 100 ? `${state.prompt.substring(0, 97)}...` : (state.prompt ?? '');
|
|
511
|
+
let sessionStatus = 'unknown';
|
|
512
|
+
try {
|
|
513
|
+
const statusResult = await v2.session.status({ directory: state.worktreeDir });
|
|
514
|
+
const statuses = statusResult.data;
|
|
515
|
+
const status = statuses?.[state.sessionId];
|
|
516
|
+
if (status) {
|
|
517
|
+
sessionStatus = status.type === 'retry'
|
|
518
|
+
? `retry (attempt ${status.attempt}, next in ${Math.round(((status.next ?? 0) - Date.now()) / 1000)}s)`
|
|
519
|
+
: status.type;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
sessionStatus = 'unavailable';
|
|
524
|
+
}
|
|
525
|
+
const duration = formatDuration(computeElapsedSeconds(state.startedAt));
|
|
526
|
+
const stallInfo = loopHandler.getStallInfo(state.worktreeName);
|
|
527
|
+
const secondsSinceActivity = stallInfo
|
|
528
|
+
? Math.round((Date.now() - stallInfo.lastActivityTime) / 1000)
|
|
529
|
+
: null;
|
|
530
|
+
const stallCount = stallInfo?.consecutiveStalls ?? 0;
|
|
531
|
+
const statusLines = [
|
|
532
|
+
'Loop Status',
|
|
533
|
+
'',
|
|
534
|
+
`Name: ${state.worktreeName}`,
|
|
535
|
+
`Session: ${state.sessionId}`,
|
|
536
|
+
];
|
|
537
|
+
if (!state.worktree) {
|
|
538
|
+
statusLines.push(`Mode: in-place | Directory: ${state.worktreeDir}`);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
statusLines.push(`Worktree: ${state.worktreeDir}`);
|
|
542
|
+
}
|
|
543
|
+
statusLines.push(`Status: ${sessionStatus}`, `Phase: ${state.phase}`, `Iteration: ${maxInfo}`, `Duration: ${duration}`, `Audit: ${state.audit ? 'enabled' : 'disabled'}`);
|
|
544
|
+
if (state.worktreeBranch) {
|
|
545
|
+
statusLines.push(`Branch: ${state.worktreeBranch}`);
|
|
546
|
+
}
|
|
547
|
+
let sessionOutput = null;
|
|
548
|
+
if (state.worktreeDir) {
|
|
549
|
+
try {
|
|
550
|
+
sessionOutput = await fetchSessionOutput(v2, state.sessionId, state.worktreeDir, logger);
|
|
551
|
+
}
|
|
552
|
+
catch {
|
|
553
|
+
// Silently ignore fetch errors to avoid cluttering output
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (sessionOutput) {
|
|
557
|
+
statusLines.push('');
|
|
558
|
+
statusLines.push('Session Output:');
|
|
559
|
+
statusLines.push(...formatSessionOutput(sessionOutput));
|
|
560
|
+
}
|
|
561
|
+
if (state.lastAuditResult) {
|
|
562
|
+
statusLines.push(...formatAuditResult(state.lastAuditResult));
|
|
563
|
+
}
|
|
564
|
+
statusLines.push('', `Completion promise: ${state.completionSignal ?? 'none'}`, `Started: ${state.startedAt}`, ...(state.errorCount && state.errorCount > 0 ? [`Error count: ${state.errorCount} (retries before termination: ${MAX_RETRIES})`] : []), `Audit count: ${state.auditCount ?? 0}`, `Model: ${config.loop?.model || config.executionModel || 'default'}`, `Auditor model: ${config.auditorModel || 'default'}`, ...(stallCount > 0 ? [`Stalls: ${stallCount}`] : []), ...(secondsSinceActivity !== null ? [`Last activity: ${secondsSinceActivity}s ago`] : []), '', `Prompt: ${promptPreview}`);
|
|
565
|
+
return statusLines.join('\n');
|
|
566
|
+
},
|
|
567
|
+
}),
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
//# sourceMappingURL=loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/tools/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAG9B,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,yBAAyB,EAA0C,MAAM,kBAAkB,CAAA;AACjM,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,E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EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACpD,GAAG,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,oBAAoB,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACzF,EAAE,EACF,WAAW,aAAa,EAAE,CAC3B,CAAA;gBAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC/B,CAAC;SACF,CAAC;KACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ToolContext } from './types';
|
|
2
|
+
import type { Hooks } from '@opencode-ai/plugin';
|
|
3
|
+
import { extractPlanTitle } from '../utils/plan-execution';
|
|
4
|
+
declare const LOOP_BLOCKED_TOOLS: Record<string, string>;
|
|
5
|
+
export { LOOP_BLOCKED_TOOLS };
|
|
6
|
+
export { extractPlanTitle };
|
|
7
|
+
export declare function createToolExecuteBeforeHook(ctx: ToolContext): Hooks['tool.execute.before'];
|
|
8
|
+
export declare function createToolExecuteAfterHook(ctx: ToolContext): Hooks['tool.execute.after'];
|
|
9
|
+
export declare function createPlanApprovalEventHook(ctx: ToolContext): (eventInput: {
|
|
10
|
+
event: {
|
|
11
|
+
type: string;
|
|
12
|
+
properties?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
}) => Promise<void>;
|
|
15
|
+
//# sourceMappingURL=plan-approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-approval.d.ts","sourceRoot":"","sources":["../../src/tools/plan-approval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAIhD,OAAO,EAAE,gBAAgB,EAA2C,MAAM,yBAAyB,CAAA;AAEnG,QAAA,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAI9C,CAAA;AAUD,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,WAAW,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAiB1F;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,WAAW,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAyKxF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,WAAW,IAG5C,YAAY;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAA;CAAE,mBA0C5F"}
|