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,268 @@
|
|
|
1
|
+
import { buildCompletionSignalInstructions, LOOP_PERMISSION_RULESET } from '../../services/loop';
|
|
2
|
+
import { openDatabase, confirm } from '../utils';
|
|
3
|
+
import { findPartialMatch } from '../../utils/partial-match';
|
|
4
|
+
import { createOpencodeClient } from '@opencode-ai/sdk/v2';
|
|
5
|
+
function createStatusClient(serverUrl, directory) {
|
|
6
|
+
const url = new URL(serverUrl);
|
|
7
|
+
const password = url.password || process.env['OPENCODE_SERVER_PASSWORD'];
|
|
8
|
+
const cleanUrl = new URL(url.toString());
|
|
9
|
+
cleanUrl.username = '';
|
|
10
|
+
cleanUrl.password = '';
|
|
11
|
+
const clientConfig = { baseUrl: cleanUrl.toString(), directory };
|
|
12
|
+
if (password) {
|
|
13
|
+
clientConfig.headers = {
|
|
14
|
+
Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString('base64')}`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return createOpencodeClient(clientConfig);
|
|
18
|
+
}
|
|
19
|
+
export async function run(argv) {
|
|
20
|
+
const db = openDatabase(argv.dbPath);
|
|
21
|
+
try {
|
|
22
|
+
const projectId = argv.resolvedProjectId;
|
|
23
|
+
const now = Date.now();
|
|
24
|
+
let query;
|
|
25
|
+
let params;
|
|
26
|
+
if (projectId) {
|
|
27
|
+
query = 'SELECT project_id, key, data FROM project_kv WHERE project_id = ? AND key LIKE ? AND expires_at > ?';
|
|
28
|
+
params = [projectId, 'loop:%', now];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
query = 'SELECT project_id, key, data FROM project_kv WHERE key LIKE ? AND expires_at > ?';
|
|
32
|
+
params = ['loop:%', now];
|
|
33
|
+
}
|
|
34
|
+
let rows;
|
|
35
|
+
try {
|
|
36
|
+
rows = db.prepare(query).all(...params);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
rows = [];
|
|
40
|
+
}
|
|
41
|
+
if (rows.length === 0) {
|
|
42
|
+
console.log('');
|
|
43
|
+
console.log('No loops.');
|
|
44
|
+
console.log('');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const loops = [];
|
|
48
|
+
for (const row of rows) {
|
|
49
|
+
try {
|
|
50
|
+
const state = JSON.parse(row.data);
|
|
51
|
+
loops.push({ state, row });
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
console.error(`Failed to parse loop state for key ${row.key}:`, err);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (loops.length === 0) {
|
|
58
|
+
console.log('');
|
|
59
|
+
console.log('No loops.');
|
|
60
|
+
console.log('');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let loopToRestart;
|
|
64
|
+
if (argv.name) {
|
|
65
|
+
const { match, candidates } = findPartialMatch(argv.name, loops, (l) => [
|
|
66
|
+
l.state.worktreeName,
|
|
67
|
+
l.state.worktreeBranch,
|
|
68
|
+
]);
|
|
69
|
+
if (!match && candidates.length > 0) {
|
|
70
|
+
console.error(`Multiple loops match '${argv.name}':`);
|
|
71
|
+
for (const c of candidates) {
|
|
72
|
+
console.error(` - ${c.state.worktreeName}`);
|
|
73
|
+
}
|
|
74
|
+
console.error('');
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
if (!match && candidates.length === 0) {
|
|
78
|
+
console.error(`Loop not found: ${argv.name}`);
|
|
79
|
+
console.error('');
|
|
80
|
+
console.error('Available loops:');
|
|
81
|
+
for (const l of loops) {
|
|
82
|
+
console.error(` - ${l.state.worktreeName}`);
|
|
83
|
+
}
|
|
84
|
+
console.error('');
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
loopToRestart = match;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const restartableLoops = loops.filter((l) => l.state.active || (l.state.terminationReason && l.state.terminationReason !== 'completed'));
|
|
91
|
+
if (restartableLoops.length === 0) {
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log('No restartable loops found.');
|
|
94
|
+
console.log('');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (restartableLoops.length === 1) {
|
|
98
|
+
loopToRestart = restartableLoops[0];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.log('');
|
|
102
|
+
console.log('Multiple restartable loops. Please specify which one to restart:');
|
|
103
|
+
console.log('');
|
|
104
|
+
for (const l of restartableLoops) {
|
|
105
|
+
console.log(` - ${l.state.worktreeName}`);
|
|
106
|
+
}
|
|
107
|
+
console.log('');
|
|
108
|
+
console.log("Run 'oc-forge loop restart <name>' to restart a specific loop.");
|
|
109
|
+
console.log('');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!loopToRestart) {
|
|
114
|
+
console.error('Internal error: loop not found');
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
const { state, row } = loopToRestart;
|
|
118
|
+
if (state.terminationReason === 'completed') {
|
|
119
|
+
console.log('');
|
|
120
|
+
console.log(`Loop "${state.worktreeName}" completed successfully and cannot be restarted.`);
|
|
121
|
+
console.log('');
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
if (!state.worktreeDir) {
|
|
125
|
+
console.log('');
|
|
126
|
+
console.log(`Cannot restart "${state.worktreeName}": worktree directory is missing.`);
|
|
127
|
+
console.log('');
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
if (state.worktree && state.worktreeDir) {
|
|
131
|
+
const { existsSync } = await import('fs');
|
|
132
|
+
if (!existsSync(state.worktreeDir)) {
|
|
133
|
+
console.log('');
|
|
134
|
+
console.log(`Cannot restart "${state.worktreeName}": worktree directory no longer exists at ${state.worktreeDir}.`);
|
|
135
|
+
console.log('');
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (state.active && !argv.force) {
|
|
140
|
+
console.log('');
|
|
141
|
+
console.log(`Loop to Force Restart:`);
|
|
142
|
+
console.log(` Worktree: ${state.worktreeName}`);
|
|
143
|
+
console.log(` Session: ${state.sessionId}`);
|
|
144
|
+
console.log(` Iteration: ${state.iteration}/${state.maxIterations}`);
|
|
145
|
+
console.log(` Phase: ${state.phase}`);
|
|
146
|
+
console.log('');
|
|
147
|
+
const shouldProceed = await confirm(`Force restart active loop '${state.worktreeName}'`);
|
|
148
|
+
if (!shouldProceed) {
|
|
149
|
+
console.log('Cancelled.');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const serverUrl = argv.server ?? 'http://localhost:5551';
|
|
154
|
+
const directory = state.worktreeDir;
|
|
155
|
+
const client = createStatusClient(serverUrl, directory);
|
|
156
|
+
if (state.active) {
|
|
157
|
+
try {
|
|
158
|
+
await client.session.abort({ sessionID: state.sessionId });
|
|
159
|
+
console.log(`Aborted old session: ${state.sessionId}`);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
console.log(`Warning: could not abort old session ${state.sessionId}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const createResult = await client.session.create({
|
|
166
|
+
title: state.worktreeName,
|
|
167
|
+
directory,
|
|
168
|
+
permission: LOOP_PERMISSION_RULESET,
|
|
169
|
+
});
|
|
170
|
+
if (createResult.error || !createResult.data) {
|
|
171
|
+
console.error(`Failed to create new session: ${createResult.error}`);
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
const newSessionId = createResult.data.id;
|
|
175
|
+
const sessionKey = `loop-session:${newSessionId}`;
|
|
176
|
+
db.prepare('INSERT OR REPLACE INTO project_kv (project_id, key, data, expires_at, updated_at) VALUES (?, ?, ?, ?, ?)').run(row.project_id, sessionKey, JSON.stringify(state.worktreeName), now + 30 * 24 * 60 * 60 * 1000, now);
|
|
177
|
+
const newState = {
|
|
178
|
+
...state,
|
|
179
|
+
active: true,
|
|
180
|
+
sessionId: newSessionId,
|
|
181
|
+
phase: 'coding',
|
|
182
|
+
errorCount: 0,
|
|
183
|
+
auditCount: 0,
|
|
184
|
+
startedAt: new Date().toISOString(),
|
|
185
|
+
completedAt: undefined,
|
|
186
|
+
terminationReason: undefined,
|
|
187
|
+
};
|
|
188
|
+
db.prepare('UPDATE project_kv SET data = ?, updated_at = ? WHERE project_id = ? AND key = ?').run(JSON.stringify(newState), now, row.project_id, row.key);
|
|
189
|
+
let promptText = state.prompt ?? '';
|
|
190
|
+
if (state.completionSignal) {
|
|
191
|
+
promptText += buildCompletionSignalInstructions(state.completionSignal);
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
await client.session.promptAsync({
|
|
195
|
+
sessionID: newSessionId,
|
|
196
|
+
directory,
|
|
197
|
+
parts: [{ type: 'text', text: promptText }],
|
|
198
|
+
agent: 'code',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
console.error(`Failed to send prompt: ${err}`);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
console.log('');
|
|
206
|
+
console.log(`Restarted loop "${state.worktreeName}"`);
|
|
207
|
+
console.log('');
|
|
208
|
+
console.log(`New session: ${newSessionId}`);
|
|
209
|
+
console.log(`Continuing from iteration: ${state.iteration}`);
|
|
210
|
+
console.log(`Previous termination: ${state.terminationReason ?? 'unknown'}`);
|
|
211
|
+
console.log(`Directory: ${state.worktreeDir}`);
|
|
212
|
+
console.log(`Audit: ${state.audit ? 'enabled' : 'disabled'}`);
|
|
213
|
+
console.log('');
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
db.close();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
export function help() {
|
|
220
|
+
console.log(`
|
|
221
|
+
Restart a loop
|
|
222
|
+
|
|
223
|
+
Usage:
|
|
224
|
+
oc-forge loop restart [name] [options]
|
|
225
|
+
|
|
226
|
+
Arguments:
|
|
227
|
+
name Worktree name to restart (optional if only one active)
|
|
228
|
+
|
|
229
|
+
Options:
|
|
230
|
+
--force Force restart an active loop without confirmation
|
|
231
|
+
--server <url> OpenCode server URL (default: http://localhost:5551)
|
|
232
|
+
--project, -p <id> Project ID (auto-detected from git if not provided)
|
|
233
|
+
--db-path <path> Path to forge database
|
|
234
|
+
--help, -h Show this help message
|
|
235
|
+
`.trim());
|
|
236
|
+
}
|
|
237
|
+
export async function cli(args, globalOpts) {
|
|
238
|
+
const argv = {
|
|
239
|
+
dbPath: globalOpts.dbPath,
|
|
240
|
+
resolvedProjectId: globalOpts.resolvedProjectId,
|
|
241
|
+
server: 'http://localhost:5551',
|
|
242
|
+
};
|
|
243
|
+
let i = 0;
|
|
244
|
+
while (i < args.length) {
|
|
245
|
+
const arg = args[i];
|
|
246
|
+
if (arg === '--force') {
|
|
247
|
+
argv.force = true;
|
|
248
|
+
}
|
|
249
|
+
else if (arg === '--server') {
|
|
250
|
+
argv.server = args[++i];
|
|
251
|
+
}
|
|
252
|
+
else if (arg === '--help' || arg === '-h') {
|
|
253
|
+
help();
|
|
254
|
+
process.exit(0);
|
|
255
|
+
}
|
|
256
|
+
else if (!arg.startsWith('-')) {
|
|
257
|
+
argv.name = arg;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
console.error(`Unknown option: ${arg}`);
|
|
261
|
+
help();
|
|
262
|
+
process.exit(1);
|
|
263
|
+
}
|
|
264
|
+
i++;
|
|
265
|
+
}
|
|
266
|
+
await run(argv);
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=restart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restart.js","sourceRoot":"","sources":["../../../src/cli/commands/restart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAChG,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAU1D,SAAS,kBAAkB,CAAC,SAAiB,EAAE,SAAiB;IAC9D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAA;IAC9B,MAAM,QAAQ,GAAG,GAAG,CA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A;IAED,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC;aAAM,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;QACzB,CAAC;aAAM,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC5C,IAAI,EAAE,CAAA;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;aAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACjB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAA;YACvC,IAAI,EAAE,CAAA;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QACD,CAAC,EAAE,CAAA;IACL,CAAC;IAED,MAAM,GAAG,CAAC,IAAI,CAAC,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface StatusArgs {
|
|
2
|
+
dbPath?: string;
|
|
3
|
+
resolvedProjectId?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
server?: string;
|
|
6
|
+
listWorktrees?: boolean;
|
|
7
|
+
listWorktreesFilter?: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function run(argv: StatusArgs): Promise<void>;
|
|
11
|
+
export declare function help(): void;
|
|
12
|
+
export declare function cli(args: string[], globalOpts: {
|
|
13
|
+
dbPath?: string;
|
|
14
|
+
resolvedProjectId?: string;
|
|
15
|
+
dir?: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/status.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAsB,GAAG,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAsTzD;AAED,wBAAgB,IAAI,IAAI,IAAI,CAoB3B;AAED,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiClI"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { openDatabase } from '../utils';
|
|
2
|
+
import { formatSessionOutput, formatAuditResult } from '../../utils/loop-format';
|
|
3
|
+
import { createOpencodeClient } from '@opencode-ai/sdk/v2';
|
|
4
|
+
import { fetchSessionOutput } from '../../services/loop';
|
|
5
|
+
import { findPartialMatch, filterByPartial } from '../../utils/partial-match';
|
|
6
|
+
export async function run(argv) {
|
|
7
|
+
const db = openDatabase(argv.dbPath);
|
|
8
|
+
function createStatusClient(serverUrl, directory) {
|
|
9
|
+
const url = new URL(serverUrl);
|
|
10
|
+
const password = url.password || process.env['OPENCODE_SERVER_PASSWORD'];
|
|
11
|
+
const cleanUrl = new URL(url.toString());
|
|
12
|
+
cleanUrl.username = '';
|
|
13
|
+
cleanUrl.password = '';
|
|
14
|
+
const clientConfig = { baseUrl: cleanUrl.toString(), directory };
|
|
15
|
+
if (password) {
|
|
16
|
+
clientConfig.headers = {
|
|
17
|
+
Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString('base64')}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return createOpencodeClient(clientConfig);
|
|
21
|
+
}
|
|
22
|
+
async function tryFetchSessionOutput(serverUrl, sessionId, directory) {
|
|
23
|
+
try {
|
|
24
|
+
const client = createStatusClient(serverUrl, directory);
|
|
25
|
+
return await fetchSessionOutput(client, sessionId, directory);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function tryFetchSessionStatus(serverUrl, sessionId, directory) {
|
|
32
|
+
try {
|
|
33
|
+
const client = createStatusClient(serverUrl, directory);
|
|
34
|
+
const statusResult = await client.session.status({ directory });
|
|
35
|
+
const statuses = (statusResult.data ?? {});
|
|
36
|
+
const status = statuses[sessionId];
|
|
37
|
+
if (!status)
|
|
38
|
+
return 'unknown';
|
|
39
|
+
if (status.type === 'retry') {
|
|
40
|
+
return `retry (attempt ${status.attempt}, next in ${Math.round(((status.next ?? 0) - Date.now()) / 1000)}s)`;
|
|
41
|
+
}
|
|
42
|
+
return status.type;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return 'unavailable';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
if (argv.listWorktrees) {
|
|
50
|
+
const rows = db.prepare('SELECT key, data FROM project_kv WHERE key LIKE ? AND expires_at > ?').all('loop:%', Date.now());
|
|
51
|
+
const states = [];
|
|
52
|
+
for (const row of rows) {
|
|
53
|
+
try {
|
|
54
|
+
const state = JSON.parse(row.data);
|
|
55
|
+
states.push(state);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
console.error(`Failed to parse loop state for key ${row.key}:`, err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const filtered = filterByPartial(argv.listWorktreesFilter, states, (s) => [s.worktreeName, s.worktreeBranch]);
|
|
62
|
+
for (const state of filtered) {
|
|
63
|
+
console.log(state.worktreeName);
|
|
64
|
+
}
|
|
65
|
+
db.close();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const projectId = argv.resolvedProjectId;
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
let query;
|
|
71
|
+
let params;
|
|
72
|
+
if (projectId) {
|
|
73
|
+
query = 'SELECT key, data FROM project_kv WHERE project_id = ? AND key LIKE ? AND expires_at > ?';
|
|
74
|
+
params = [projectId, 'loop:%', now];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
query = 'SELECT key, data FROM project_kv WHERE key LIKE ? AND expires_at > ?';
|
|
78
|
+
params = ['loop:%', now];
|
|
79
|
+
}
|
|
80
|
+
let rows;
|
|
81
|
+
try {
|
|
82
|
+
rows = db.prepare(query).all(...params);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
rows = [];
|
|
86
|
+
}
|
|
87
|
+
const activeLoops = [];
|
|
88
|
+
const recentLoops = [];
|
|
89
|
+
for (const row of rows) {
|
|
90
|
+
try {
|
|
91
|
+
const state = JSON.parse(row.data);
|
|
92
|
+
if (state.active && state.sessionId && state.worktreeName && state.iteration != null && state.maxIterations != null && state.phase && state.startedAt) {
|
|
93
|
+
activeLoops.push({
|
|
94
|
+
sessionId: state.sessionId,
|
|
95
|
+
worktreeName: state.worktreeName,
|
|
96
|
+
worktreeBranch: state.worktreeBranch,
|
|
97
|
+
iteration: state.iteration,
|
|
98
|
+
maxIterations: state.maxIterations,
|
|
99
|
+
phase: state.phase,
|
|
100
|
+
startedAt: state.startedAt,
|
|
101
|
+
audit: state.audit ?? false,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else if (state.completedAt) {
|
|
105
|
+
recentLoops.push({ state, row });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch { }
|
|
109
|
+
}
|
|
110
|
+
const worktreeName = argv.name;
|
|
111
|
+
if (worktreeName) {
|
|
112
|
+
const allLoops = [
|
|
113
|
+
...activeLoops.map((l) => ({ type: 'active', loop: l })),
|
|
114
|
+
...recentLoops.map((l) => ({ type: 'recent', loop: l })),
|
|
115
|
+
];
|
|
116
|
+
const { match, candidates } = findPartialMatch(worktreeName, allLoops, (l) => [
|
|
117
|
+
l.type === 'active' ? l.loop.worktreeName : l.loop.state.worktreeName,
|
|
118
|
+
l.type === 'active' ? l.loop.worktreeBranch : l.loop.state.worktreeBranch,
|
|
119
|
+
]);
|
|
120
|
+
if (!match && candidates.length > 0) {
|
|
121
|
+
console.error(`Multiple loops match '${worktreeName}':`);
|
|
122
|
+
for (const c of candidates) {
|
|
123
|
+
const name = c.type === 'active' ? c.loop.worktreeName : c.loop.state.worktreeName;
|
|
124
|
+
console.error(` - ${name}`);
|
|
125
|
+
}
|
|
126
|
+
console.error('');
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
if (!match && candidates.length === 0) {
|
|
130
|
+
console.error(`Loop not found: ${worktreeName}`);
|
|
131
|
+
console.error('');
|
|
132
|
+
if (activeLoops.length > 0) {
|
|
133
|
+
console.error('Active loops:');
|
|
134
|
+
for (const l of activeLoops) {
|
|
135
|
+
console.error(` - ${l.worktreeName}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (recentLoops.length > 0) {
|
|
139
|
+
console.error('Recently completed:');
|
|
140
|
+
for (const l of recentLoops) {
|
|
141
|
+
console.error(` - ${l.state.worktreeName}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
console.error('');
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
const matchedLoop = match;
|
|
148
|
+
const resolvedWorktreeName = matchedLoop.type === 'active'
|
|
149
|
+
? matchedLoop.loop.worktreeName
|
|
150
|
+
: matchedLoop.loop.state.worktreeName;
|
|
151
|
+
if (matchedLoop.type === 'active') {
|
|
152
|
+
const row = rows.find((r) => {
|
|
153
|
+
try {
|
|
154
|
+
const state = JSON.parse(r.data);
|
|
155
|
+
return state.worktreeName === resolvedWorktreeName;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
if (!row) {
|
|
162
|
+
console.error(`Failed to retrieve state for: ${worktreeName}`);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
const state = JSON.parse(row.data);
|
|
166
|
+
const startedAt = state.startedAt;
|
|
167
|
+
const duration = Date.now() - new Date(startedAt).getTime();
|
|
168
|
+
const hours = Math.floor(duration / (1000 * 60 * 60));
|
|
169
|
+
const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60));
|
|
170
|
+
const seconds = Math.floor((duration % (1000 * 60)) / 1000);
|
|
171
|
+
console.log('');
|
|
172
|
+
console.log(`Loop: ${state.worktreeName}`);
|
|
173
|
+
console.log(` Session ID: ${state.sessionId}`);
|
|
174
|
+
console.log(` Worktree: ${state.worktreeName}`);
|
|
175
|
+
if (state.worktreeBranch) {
|
|
176
|
+
console.log(` Branch: ${state.worktreeBranch}`);
|
|
177
|
+
}
|
|
178
|
+
console.log(` Worktree Dir: ${state.worktreeDir}`);
|
|
179
|
+
if (!state.worktree) {
|
|
180
|
+
console.log(` Mode: in-place`);
|
|
181
|
+
}
|
|
182
|
+
console.log(` Phase: ${state.phase}`);
|
|
183
|
+
console.log(` Iteration: ${state.iteration}/${state.maxIterations}`);
|
|
184
|
+
console.log(` Duration: ${hours}h ${minutes}m ${seconds}s`);
|
|
185
|
+
console.log(` Audit: ${state.audit ? 'Yes' : 'No'}`);
|
|
186
|
+
console.log(` Error Count: ${state.errorCount ?? 0}`);
|
|
187
|
+
console.log(` Audit Count: ${state.auditCount ?? 0}`);
|
|
188
|
+
console.log(` Started: ${new Date(startedAt).toISOString()}`);
|
|
189
|
+
const sessionStatus = await tryFetchSessionStatus(argv.server ?? 'http://localhost:5551', state.sessionId, state.worktreeDir);
|
|
190
|
+
console.log(` Status: ${sessionStatus}`);
|
|
191
|
+
if (state.completionSignal) {
|
|
192
|
+
console.log(` Completion: ${state.completionSignal}`);
|
|
193
|
+
}
|
|
194
|
+
if (state.lastAuditResult) {
|
|
195
|
+
for (const line of formatAuditResult(state.lastAuditResult)) {
|
|
196
|
+
console.log(line);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const sessionOutput = await tryFetchSessionOutput(argv.server ?? 'http://localhost:5551', state.sessionId, state.worktreeDir);
|
|
200
|
+
if (sessionOutput) {
|
|
201
|
+
console.log('Session Output:');
|
|
202
|
+
for (const line of formatSessionOutput(sessionOutput)) {
|
|
203
|
+
console.log(line);
|
|
204
|
+
}
|
|
205
|
+
console.log('');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
const state = matchedLoop.loop.state;
|
|
210
|
+
const completedAt = state.completedAt;
|
|
211
|
+
const startedAt = state.startedAt;
|
|
212
|
+
const duration = new Date(completedAt).getTime() - new Date(startedAt).getTime();
|
|
213
|
+
const hours = Math.floor(duration / (1000 * 60 * 60));
|
|
214
|
+
const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60));
|
|
215
|
+
const seconds = Math.floor((duration % (1000 * 60)) / 1000);
|
|
216
|
+
console.log('');
|
|
217
|
+
console.log(`Loop (Completed): ${state.worktreeName}`);
|
|
218
|
+
console.log(` Session ID: ${state.sessionId}`);
|
|
219
|
+
console.log(` Worktree: ${state.worktreeName}`);
|
|
220
|
+
if (state.worktreeBranch) {
|
|
221
|
+
console.log(` Branch: ${state.worktreeBranch}`);
|
|
222
|
+
}
|
|
223
|
+
console.log(` Worktree Dir: ${state.worktreeDir}`);
|
|
224
|
+
if (!state.worktree) {
|
|
225
|
+
console.log(` Mode: in-place (completed)`);
|
|
226
|
+
}
|
|
227
|
+
console.log(` Iteration: ${state.iteration}/${state.maxIterations}`);
|
|
228
|
+
console.log(` Duration: ${hours}h ${minutes}m ${seconds}s`);
|
|
229
|
+
console.log(` Reason: ${state.terminationReason ?? 'unknown'}`);
|
|
230
|
+
console.log(` Started: ${new Date(startedAt).toISOString()}`);
|
|
231
|
+
console.log(` Completed: ${new Date(completedAt).toISOString()}`);
|
|
232
|
+
if (state.lastAuditResult) {
|
|
233
|
+
for (const line of formatAuditResult(state.lastAuditResult)) {
|
|
234
|
+
console.log(line);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const sessionOutput = await tryFetchSessionOutput(argv.server ?? 'http://localhost:5551', state.sessionId, state.worktreeDir);
|
|
238
|
+
if (sessionOutput) {
|
|
239
|
+
console.log('Session Output:');
|
|
240
|
+
for (const line of formatSessionOutput(sessionOutput)) {
|
|
241
|
+
console.log(line);
|
|
242
|
+
}
|
|
243
|
+
console.log('');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
if (activeLoops.length > 0) {
|
|
249
|
+
console.log('');
|
|
250
|
+
console.log('Active Loops:');
|
|
251
|
+
console.log('');
|
|
252
|
+
for (const loop of activeLoops) {
|
|
253
|
+
const duration = Date.now() - new Date(loop.startedAt).getTime();
|
|
254
|
+
const hours = Math.floor(duration / (1000 * 60 * 60));
|
|
255
|
+
const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60));
|
|
256
|
+
const durationStr = `${hours}h ${minutes}m`;
|
|
257
|
+
const iterStr = `${loop.iteration}/${loop.maxIterations}`;
|
|
258
|
+
const audit = loop.audit ? 'Yes' : 'No';
|
|
259
|
+
console.log(` ${loop.worktreeName}`);
|
|
260
|
+
console.log(` Phase: ${loop.phase} Iteration: ${iterStr} Duration: ${durationStr} Audit: ${audit}`);
|
|
261
|
+
console.log('');
|
|
262
|
+
}
|
|
263
|
+
console.log(`Total: ${activeLoops.length} active loop(s)`);
|
|
264
|
+
console.log('');
|
|
265
|
+
}
|
|
266
|
+
if (recentLoops.length > 0) {
|
|
267
|
+
console.log('Recently Completed:');
|
|
268
|
+
console.log('');
|
|
269
|
+
const limit = argv.limit ?? 10;
|
|
270
|
+
const displayedLoops = recentLoops.slice(0, limit);
|
|
271
|
+
for (const loop of displayedLoops) {
|
|
272
|
+
const reason = loop.state.terminationReason ?? 'unknown';
|
|
273
|
+
const completed = new Date(loop.state.completedAt).toLocaleString();
|
|
274
|
+
console.log(` ${loop.state.worktreeName}`);
|
|
275
|
+
console.log(` Iterations: ${loop.state.iteration} Reason: ${reason} Completed: ${completed}`);
|
|
276
|
+
console.log('');
|
|
277
|
+
}
|
|
278
|
+
if (recentLoops.length > limit) {
|
|
279
|
+
console.log(` ... and ${recentLoops.length - limit} more. Use 'oc-forge loop status <name>' for details.`);
|
|
280
|
+
console.log('');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (activeLoops.length === 0 && recentLoops.length === 0) {
|
|
284
|
+
console.log('');
|
|
285
|
+
console.log('No loops found.');
|
|
286
|
+
console.log('');
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
console.log("Run 'oc-forge loop status <name>' for detailed information.");
|
|
290
|
+
console.log('');
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
db.close();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
export function help() {
|
|
299
|
+
console.log(`
|
|
300
|
+
Show loop status
|
|
301
|
+
|
|
302
|
+
Usage:
|
|
303
|
+
oc-forge loop status [options]
|
|
304
|
+
oc-forge loop status <name> [options]
|
|
305
|
+
|
|
306
|
+
Arguments:
|
|
307
|
+
name Worktree name for detailed status (optional, supports partial matching)
|
|
308
|
+
|
|
309
|
+
Options:
|
|
310
|
+
--server <url> OpenCode server URL (default: http://localhost:5551)
|
|
311
|
+
--list-worktrees List all worktree names (for shell completion)
|
|
312
|
+
Optionally provide a filter: --list-worktrees <filter>
|
|
313
|
+
--limit <n> Limit recent loops shown (default: 10)
|
|
314
|
+
--project, -p <id> Project ID (auto-detected from git if not provided)
|
|
315
|
+
--db-path <path> Path to forge database
|
|
316
|
+
--help, -h Show this help message
|
|
317
|
+
`.trim());
|
|
318
|
+
}
|
|
319
|
+
export async function cli(args, globalOpts) {
|
|
320
|
+
const argv = {
|
|
321
|
+
dbPath: globalOpts.dbPath,
|
|
322
|
+
resolvedProjectId: globalOpts.resolvedProjectId,
|
|
323
|
+
server: 'http://localhost:5551',
|
|
324
|
+
};
|
|
325
|
+
let i = 0;
|
|
326
|
+
while (i < args.length) {
|
|
327
|
+
const arg = args[i];
|
|
328
|
+
if (arg === '--server') {
|
|
329
|
+
argv.server = args[++i];
|
|
330
|
+
}
|
|
331
|
+
else if (arg === '--list-worktrees') {
|
|
332
|
+
argv.listWorktrees = true;
|
|
333
|
+
if (i + 1 < args.length && !args[i + 1].startsWith('-')) {
|
|
334
|
+
argv.listWorktreesFilter = args[++i];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
else if (arg === '--limit') {
|
|
338
|
+
argv.limit = parseInt(args[++i], 10);
|
|
339
|
+
}
|
|
340
|
+
else if (arg === '--help' || arg === '-h') {
|
|
341
|
+
help();
|
|
342
|
+
process.exit(0);
|
|
343
|
+
}
|
|
344
|
+
else if (!arg.startsWith('-')) {
|
|
345
|
+
argv.name = arg;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
console.error(`Unknown option: ${arg}`);
|
|
349
|
+
help();
|
|
350
|
+
process.exit(1);
|
|
351
|
+
}
|
|
352
|
+
i++;
|
|
353
|
+
}
|
|
354
|
+
await run(argv);
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=status.js.map
|