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,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI refresh helpers for reading loop states from KV.
|
|
3
|
+
*
|
|
4
|
+
* This module provides testable helpers for accessing loop state
|
|
5
|
+
* from the shared project KV store.
|
|
6
|
+
*/
|
|
7
|
+
import { Database } from 'bun:sqlite';
|
|
8
|
+
import { existsSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
import { resolveDataDir } from '../storage';
|
|
11
|
+
/**
|
|
12
|
+
* Gets the database path used by the memory plugin.
|
|
13
|
+
* Exported for testing purposes.
|
|
14
|
+
*/
|
|
15
|
+
export function getDbPath() {
|
|
16
|
+
return join(resolveDataDir(), 'graph.db');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads loop states from the shared KV store.
|
|
20
|
+
*
|
|
21
|
+
* @param projectId - The project ID (git commit hash)
|
|
22
|
+
* @param dbPathOverride - Optional database path override (for testing)
|
|
23
|
+
* @returns Array of loop states
|
|
24
|
+
*/
|
|
25
|
+
export function readLoopStates(projectId, dbPathOverride) {
|
|
26
|
+
const dbPath = dbPathOverride || getDbPath();
|
|
27
|
+
if (!existsSync(dbPath))
|
|
28
|
+
return [];
|
|
29
|
+
let db = null;
|
|
30
|
+
try {
|
|
31
|
+
db = new Database(dbPath, { readonly: true });
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
const stmt = db.prepare('SELECT key, data FROM project_kv WHERE project_id = ? AND key LIKE ? AND expires_at > ?');
|
|
34
|
+
const rows = stmt.all(projectId, 'loop:%', now);
|
|
35
|
+
const loops = [];
|
|
36
|
+
for (const row of rows) {
|
|
37
|
+
try {
|
|
38
|
+
const state = JSON.parse(row.data);
|
|
39
|
+
if (!state.worktreeName || !state.sessionId)
|
|
40
|
+
continue;
|
|
41
|
+
loops.push({
|
|
42
|
+
name: state.worktreeName,
|
|
43
|
+
phase: state.phase ?? 'coding',
|
|
44
|
+
iteration: state.iteration ?? 0,
|
|
45
|
+
maxIterations: state.maxIterations ?? 0,
|
|
46
|
+
sessionId: state.sessionId,
|
|
47
|
+
active: state.active ?? false,
|
|
48
|
+
startedAt: state.startedAt,
|
|
49
|
+
completedAt: state.completedAt,
|
|
50
|
+
terminationReason: state.terminationReason,
|
|
51
|
+
worktreeBranch: state.worktreeBranch,
|
|
52
|
+
worktree: state.worktree ?? false,
|
|
53
|
+
worktreeDir: state.worktreeDir,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch { }
|
|
57
|
+
}
|
|
58
|
+
return loops;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
try {
|
|
65
|
+
db?.close();
|
|
66
|
+
}
|
|
67
|
+
catch { }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Reads a single loop's current state by name from KV.
|
|
72
|
+
* Used by LoopDetailsDialog to avoid stale snapshots.
|
|
73
|
+
*
|
|
74
|
+
* @param projectId - The project ID (git commit hash)
|
|
75
|
+
* @param loopName - The loop name to read
|
|
76
|
+
* @param dbPathOverride - Optional database path override (for testing)
|
|
77
|
+
* @returns The loop state or null if not found
|
|
78
|
+
*/
|
|
79
|
+
export function readLoopByName(projectId, loopName, dbPathOverride) {
|
|
80
|
+
const dbPath = dbPathOverride || getDbPath();
|
|
81
|
+
if (!existsSync(dbPath))
|
|
82
|
+
return null;
|
|
83
|
+
let db = null;
|
|
84
|
+
try {
|
|
85
|
+
db = new Database(dbPath, { readonly: true });
|
|
86
|
+
const now = Date.now();
|
|
87
|
+
const key = `loop:${loopName}`;
|
|
88
|
+
const row = db.prepare('SELECT data FROM project_kv WHERE project_id = ? AND key = ? AND expires_at > ?')
|
|
89
|
+
.get(projectId, key, now);
|
|
90
|
+
if (!row)
|
|
91
|
+
return null;
|
|
92
|
+
const state = JSON.parse(row.data);
|
|
93
|
+
if (!state.worktreeName || !state.sessionId)
|
|
94
|
+
return null;
|
|
95
|
+
return {
|
|
96
|
+
name: state.worktreeName,
|
|
97
|
+
phase: state.phase ?? 'coding',
|
|
98
|
+
iteration: state.iteration ?? 0,
|
|
99
|
+
maxIterations: state.maxIterations ?? 0,
|
|
100
|
+
sessionId: state.sessionId,
|
|
101
|
+
active: state.active ?? false,
|
|
102
|
+
startedAt: state.startedAt,
|
|
103
|
+
completedAt: state.completedAt,
|
|
104
|
+
terminationReason: state.terminationReason,
|
|
105
|
+
worktreeBranch: state.worktreeBranch,
|
|
106
|
+
worktree: state.worktree ?? false,
|
|
107
|
+
worktreeDir: state.worktreeDir,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
try {
|
|
115
|
+
db?.close();
|
|
116
|
+
}
|
|
117
|
+
catch { }
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=tui-refresh-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui-refresh-helpers.js","sourceRoot":"","sources":["../../src/utils/tui-refresh-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAiB3C;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE,UAAU,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB,EAAE,cAAuB;IACvE,MAAM,MAAM,GAAG,cAAc,IAAI,SAAS,EAAE,CAAA;IAE5C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,CAAA;IAElC,IAAI,EAAE,GAAoB,IAAI,CAAA;IAC9B,IAAI,CAAC;QACH,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;QAC7C,MAAM,GAAG,GAAG,IAA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AAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK;YACjC,WAAW,EAAE,KAAK,CAAC,WAAW;SAC/B,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YAAC,EAAE,EAAE,KAAK,EAAE,CAAA;QAAC,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function resolveOpencodeCacheDir(): string;
|
|
2
|
+
export declare function fetchLatestVersion(): Promise<string | null>;
|
|
3
|
+
export declare function getCurrentVersion(): string;
|
|
4
|
+
export interface UpgradeResult {
|
|
5
|
+
upgraded: boolean;
|
|
6
|
+
from: string;
|
|
7
|
+
to: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export interface UpgradeCheckResult {
|
|
11
|
+
current: string;
|
|
12
|
+
latest: string | null;
|
|
13
|
+
updateAvailable: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
16
|
+
export declare function checkForUpdate(): Promise<UpgradeCheckResult>;
|
|
17
|
+
export declare function updateCachePackageJson(cacheDir: string, version: string): void;
|
|
18
|
+
export declare function performUpgrade(runInstall: (cacheDir: string, version: string) => Promise<{
|
|
19
|
+
exitCode: number;
|
|
20
|
+
stderr: string;
|
|
21
|
+
}>): Promise<UpgradeResult>;
|
|
22
|
+
export declare function formatUpgradeCheck(check: UpgradeCheckResult): string;
|
|
23
|
+
//# sourceMappingURL=upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AASA,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAejE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,eAAe,EAAE,OAAO,CAAA;CACzB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAW5D;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAKlE;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAe9E;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/F,OAAO,CAAC,aAAa,CAAC,CA2CxB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAQpE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { VERSION } from '../version';
|
|
2
|
+
import { homedir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
+
const VERSION_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
6
|
+
let cachedVersion = null;
|
|
7
|
+
export function resolveOpencodeCacheDir() {
|
|
8
|
+
const xdgCacheHome = process.env['XDG_CACHE_HOME'] || join(homedir(), '.cache');
|
|
9
|
+
return join(xdgCacheHome, 'opencode');
|
|
10
|
+
}
|
|
11
|
+
export async function fetchLatestVersion() {
|
|
12
|
+
if (cachedVersion && Date.now() < cachedVersion.expiresAt) {
|
|
13
|
+
return cachedVersion.value;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch('https://registry.npmjs.org/opencode-forge/latest');
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
cachedVersion = { value: data.version, expiresAt: Date.now() + VERSION_CACHE_TTL_MS };
|
|
22
|
+
return data.version;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function getCurrentVersion() {
|
|
29
|
+
return VERSION;
|
|
30
|
+
}
|
|
31
|
+
export function compareVersions(a, b) {
|
|
32
|
+
const aParts = a.split('.').map(Number);
|
|
33
|
+
const bParts = b.split('.').map(Number);
|
|
34
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
35
|
+
const aNum = aParts[i] || 0;
|
|
36
|
+
const bNum = bParts[i] || 0;
|
|
37
|
+
if (aNum !== bNum) {
|
|
38
|
+
return aNum - bNum;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
export async function checkForUpdate() {
|
|
44
|
+
const latest = await fetchLatestVersion();
|
|
45
|
+
const current = getCurrentVersion();
|
|
46
|
+
const updateAvailable = latest !== null && compareVersions(latest, current) > 0;
|
|
47
|
+
return { current, latest, updateAvailable };
|
|
48
|
+
}
|
|
49
|
+
export function updateCachePackageJson(cacheDir, version) {
|
|
50
|
+
const packageJsonPath = join(cacheDir, 'package.json');
|
|
51
|
+
if (!existsSync(packageJsonPath)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const content = readFileSync(packageJsonPath, 'utf-8');
|
|
56
|
+
const packageJson = JSON.parse(content);
|
|
57
|
+
if (packageJson.dependencies) {
|
|
58
|
+
packageJson.dependencies['opencode-forge'] = version;
|
|
59
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function performUpgrade(runInstall) {
|
|
66
|
+
const checkResult = await checkForUpdate();
|
|
67
|
+
const { current, latest } = checkResult;
|
|
68
|
+
if (!latest || !checkResult.updateAvailable) {
|
|
69
|
+
return {
|
|
70
|
+
upgraded: false,
|
|
71
|
+
from: current,
|
|
72
|
+
to: current,
|
|
73
|
+
message: 'Already on latest version',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const cacheDir = resolveOpencodeCacheDir();
|
|
77
|
+
if (!existsSync(cacheDir)) {
|
|
78
|
+
return {
|
|
79
|
+
upgraded: false,
|
|
80
|
+
from: current,
|
|
81
|
+
to: latest,
|
|
82
|
+
message: 'OpenCode cache directory not found. Run OpenCode first to initialize the plugin.',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const installResult = await runInstall(cacheDir, latest);
|
|
86
|
+
if (installResult.exitCode !== 0) {
|
|
87
|
+
return {
|
|
88
|
+
upgraded: false,
|
|
89
|
+
from: current,
|
|
90
|
+
to: latest,
|
|
91
|
+
message: `Upgrade failed: ${installResult.stderr || 'Unknown error'}`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
updateCachePackageJson(cacheDir, latest);
|
|
95
|
+
return {
|
|
96
|
+
upgraded: true,
|
|
97
|
+
from: current,
|
|
98
|
+
to: latest,
|
|
99
|
+
message: `Successfully upgraded from v${current} to v${latest}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function formatUpgradeCheck(check) {
|
|
103
|
+
if (check.latest === null) {
|
|
104
|
+
return `v${check.current} (unable to check for updates)`;
|
|
105
|
+
}
|
|
106
|
+
if (check.updateAvailable) {
|
|
107
|
+
return `v${check.current} → v${check.latest} available. Run oc-forge upgrade to update.`;
|
|
108
|
+
}
|
|
109
|
+
return `v${check.current} (latest)`;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAE5D,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;AAE1C,IAAI,aAAa,GAAuD,IAAI,CAAA;AAE5E,MAAM,UAAU,uBAAuB;IACrC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAA;IAC/E,OAAO,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,IAAI,aAAa,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE,CAAC;QAC1D,OAAO,aAAa,CAAC,KAAK,CAAA;IAC5B,CAAC;IACD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAA;QAChF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAyB,CAAA;QAC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C5F,CAAA;IACH,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAExD,IAAI,aAAa,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,OAAO;YACb,EAAE,EAAE,MAAM;YACV,OAAO,EAAE,mBAAmB,aAAa,CAAC,MAAM,IAAI,eAAe,EAAE;SACtE,CAAA;IACH,CAAC;IAED,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAExC,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,OAAO;QACb,EAAE,EAAE,MAAM;QACV,OAAO,EAAE,+BAA+B,OAAO,QAAQ,MAAM,EAAE;KAChE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAyB;IAC1D,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,KAAK,CAAC,OAAO,gCAAgC,CAAA;IAC1D,CAAC;IACD,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,IAAI,KAAK,CAAC,OAAO,OAAO,KAAK,CAAC,MAAM,6CAA6C,CAAA;IAC1F,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,OAAO,WAAW,CAAA;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAA"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-forge",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"oc-plugin": [
|
|
6
|
+
"server",
|
|
7
|
+
"tui"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./server": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./tui": {
|
|
21
|
+
"import": "./dist/tui.js",
|
|
22
|
+
"types": "./dist/tui.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"config.jsonc",
|
|
28
|
+
"scripts",
|
|
29
|
+
"README.md",
|
|
30
|
+
"src/command/template"
|
|
31
|
+
],
|
|
32
|
+
"bin": {
|
|
33
|
+
"oc-forge": "./dist/cli/index.js"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/chriswritescode-dev/opencode-forge.git"
|
|
38
|
+
},
|
|
39
|
+
"author": "Chris Scott",
|
|
40
|
+
"description": "OpenCode Forge - autonomous dev loops, plan storage, code graph indexing, and sandboxing for OpenCode",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"opencode",
|
|
43
|
+
"graph",
|
|
44
|
+
"iterative-loops",
|
|
45
|
+
"ai-agent",
|
|
46
|
+
"plugin",
|
|
47
|
+
"forge"
|
|
48
|
+
],
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"homepage": "https://github.com/chriswritescode-dev/opencode-forge",
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@opencode-ai/plugin": "^1.4.2",
|
|
53
|
+
"@opencode-ai/sdk": "^1.4.2",
|
|
54
|
+
"web-tree-sitter": "0.25.10",
|
|
55
|
+
"tree-sitter-wasms": "0.1.13"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@opentui/core": ">=0.1.92",
|
|
59
|
+
"@opentui/solid": ">=0.1.92"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"@opentui/core": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
65
|
+
"@opentui/solid": {
|
|
66
|
+
"optional": true
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@eslint/js": "^10.0.1",
|
|
71
|
+
"@opentui/core": "0.1.97",
|
|
72
|
+
"@opentui/solid": "0.1.97",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
|
74
|
+
"@typescript-eslint/parser": "^8.58.0",
|
|
75
|
+
"bun-types": "latest",
|
|
76
|
+
"eslint": "^10.2.0",
|
|
77
|
+
"eslint-config-prettier": "^10.1.8",
|
|
78
|
+
"eslint-plugin-solid": "^0.14.5",
|
|
79
|
+
"prettier": "^3.8.1",
|
|
80
|
+
"solid-js": "^1.9.12",
|
|
81
|
+
"typescript": "^5.7.3",
|
|
82
|
+
"typescript-eslint": "^8.58.0"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "bun scripts/build.ts",
|
|
86
|
+
"lint": "eslint .",
|
|
87
|
+
"prepublishOnly": "pnpm build",
|
|
88
|
+
"test": "bun test",
|
|
89
|
+
"typecheck": "tsc --noEmit",
|
|
90
|
+
"cli": "bun src/cli/index.ts"
|
|
91
|
+
}
|
|
92
|
+
}
|
package/scripts/build.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, cpSync, mkdirSync } from 'fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
import { execSync } from 'child_process'
|
|
4
|
+
import solidPlugin from '@opentui/solid/bun-plugin'
|
|
5
|
+
|
|
6
|
+
const packageJsonPath = join(__dirname, '..', 'package.json')
|
|
7
|
+
const versionPath = join(__dirname, '..', 'src', 'version.ts')
|
|
8
|
+
|
|
9
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
|
|
10
|
+
const version = packageJson.version as string
|
|
11
|
+
|
|
12
|
+
const versionContent = `export const VERSION = '${version}'\n`
|
|
13
|
+
writeFileSync(versionPath, versionContent, 'utf-8')
|
|
14
|
+
|
|
15
|
+
console.log(`Version ${version} written to src/version.ts`)
|
|
16
|
+
|
|
17
|
+
console.log('Compiling main code...')
|
|
18
|
+
execSync('tsc -p tsconfig.build.json', {
|
|
19
|
+
cwd: join(__dirname, '..'),
|
|
20
|
+
stdio: 'inherit'
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
console.log('Compiling TUI plugin...')
|
|
24
|
+
const result = await Bun.build({
|
|
25
|
+
entrypoints: [join(__dirname, '..', 'src', 'tui.tsx')],
|
|
26
|
+
outdir: join(__dirname, '..', 'dist'),
|
|
27
|
+
target: 'node',
|
|
28
|
+
plugins: [solidPlugin],
|
|
29
|
+
external: ['@opentui/solid', '@opentui/core', '@opencode-ai/plugin/tui', 'solid-js'],
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
console.log('Bundling graph worker...')
|
|
33
|
+
const workerResult = await Bun.build({
|
|
34
|
+
entrypoints: [join(__dirname, '..', 'src', 'graph', 'worker.ts')],
|
|
35
|
+
outdir: join(__dirname, '..', 'dist', 'graph'),
|
|
36
|
+
target: 'node',
|
|
37
|
+
format: 'esm',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
if (!workerResult.success) {
|
|
41
|
+
for (const log of workerResult.logs) {
|
|
42
|
+
console.error(log)
|
|
43
|
+
}
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!result.success) {
|
|
48
|
+
for (const log of result.logs) {
|
|
49
|
+
console.error(log)
|
|
50
|
+
}
|
|
51
|
+
process.exit(1)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.log('Generating TUI type declarations...')
|
|
55
|
+
const tuiDtsContent = `import type { TuiPluginModule } from '@opencode-ai/plugin/tui';
|
|
56
|
+
declare const plugin: TuiPluginModule & { id: string };
|
|
57
|
+
export default plugin;
|
|
58
|
+
`
|
|
59
|
+
writeFileSync(join(__dirname, '..', 'dist', 'tui.d.ts'), tuiDtsContent, 'utf-8')
|
|
60
|
+
|
|
61
|
+
console.log('Copying template files...')
|
|
62
|
+
const srcTemplateDir = join(__dirname, '..', 'src', 'command', 'template')
|
|
63
|
+
const distTemplateDir = join(__dirname, '..', 'dist', 'command', 'template')
|
|
64
|
+
mkdirSync(distTemplateDir, { recursive: true })
|
|
65
|
+
cpSync(srcTemplateDir, distTemplateDir, { recursive: true })
|
|
66
|
+
|
|
67
|
+
console.log('Build complete!')
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
You are a code reviewer. Your job is to review code changes and provide actionable feedback.
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Input: $ARGUMENTS
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Determining What to Review
|
|
10
|
+
|
|
11
|
+
Based on the input provided, determine which type of review to perform:
|
|
12
|
+
|
|
13
|
+
1. **No arguments (default)**: Review all uncommitted changes
|
|
14
|
+
- Run: `git diff` for unstaged changes
|
|
15
|
+
- Run: `git diff --cached` for staged changes
|
|
16
|
+
- Run: `git status --short` to identify untracked (net new) files
|
|
17
|
+
|
|
18
|
+
2. **Commit hash** (40-char SHA or short hash): Review that specific commit
|
|
19
|
+
- Run: `git show $ARGUMENTS`
|
|
20
|
+
|
|
21
|
+
3. **Branch name**: Compare current branch to the specified branch
|
|
22
|
+
- Run: `git diff $ARGUMENTS...HEAD`
|
|
23
|
+
|
|
24
|
+
4. **PR URL or number** (contains "github.com" or "pull" or looks like a PR number): Review the pull request
|
|
25
|
+
- Run: `gh pr view $ARGUMENTS` to get PR context
|
|
26
|
+
- Run: `gh pr diff $ARGUMENTS` to get the diff
|
|
27
|
+
|
|
28
|
+
Use best judgement when processing input.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Gathering Context
|
|
33
|
+
|
|
34
|
+
**Diffs alone are not enough.** After getting the diff, read the entire file(s) being modified to understand the full context. Code that looks wrong in isolation may be correct given surrounding logic—and vice versa.
|
|
35
|
+
|
|
36
|
+
- Use the diff to identify which files changed
|
|
37
|
+
- Use `git status --short` to identify untracked files, then read their full contents
|
|
38
|
+
- Read the full file to understand existing patterns, control flow, and error handling
|
|
39
|
+
- Check for existing style guide or conventions files (CONVENTIONS.md, AGENTS.md, .editorconfig, etc.)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## What to Look For
|
|
44
|
+
|
|
45
|
+
**Bugs** - Your primary focus.
|
|
46
|
+
- Logic errors, off-by-one mistakes, incorrect conditionals
|
|
47
|
+
- If-else guards: missing guards, incorrect branching, unreachable code paths
|
|
48
|
+
- Edge cases: null/empty/undefined inputs, error conditions, race conditions
|
|
49
|
+
- Security issues: injection, auth bypass, data exposure
|
|
50
|
+
- Broken error handling that swallows failures, throws unexpectedly or returns error types that are not caught.
|
|
51
|
+
|
|
52
|
+
**Structure** - Does the code fit the codebase?
|
|
53
|
+
- Does it follow existing patterns and conventions?
|
|
54
|
+
- Are there established abstractions it should use but doesn't?
|
|
55
|
+
- Excessive nesting that could be flattened with early returns or extraction
|
|
56
|
+
|
|
57
|
+
**Performance** - Only flag if obviously problematic.
|
|
58
|
+
- O(n²) on unbounded data, N+1 queries, blocking I/O on hot paths
|
|
59
|
+
|
|
60
|
+
**Behavior Changes** - If a behavioral change is introduced, raise it (especially if it's possibly unintentional).
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Before You Flag Something
|
|
65
|
+
|
|
66
|
+
**Be certain.** If you're going to call something a bug, you need to be confident it actually is one.
|
|
67
|
+
|
|
68
|
+
- Only review the changes - do not review pre-existing code that wasn't modified
|
|
69
|
+
- Don't flag something as a bug if you're unsure - investigate first
|
|
70
|
+
- Don't invent hypothetical problems - if an edge case matters, explain the realistic scenario where it breaks
|
|
71
|
+
- If you need more context to be sure, use the tools below to get it
|
|
72
|
+
|
|
73
|
+
**Don't be a zealot about style.** When checking code against conventions:
|
|
74
|
+
|
|
75
|
+
- Verify the code is *actually* in violation. Don't complain about else statements if early returns are already being used correctly.
|
|
76
|
+
- Some "violations" are acceptable when they're the simplest option. A `let` statement is fine if the alternative is convoluted.
|
|
77
|
+
- Excessive nesting is a legitimate concern regardless of other style choices.
|
|
78
|
+
- Don't flag style preferences as issues unless they clearly violate established project conventions.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Tools
|
|
83
|
+
|
|
84
|
+
Use these to inform your review:
|
|
85
|
+
|
|
86
|
+
- **Explore agent** - Find how existing code handles similar problems. Check patterns, conventions, and prior art before claiming something doesn't fit.
|
|
87
|
+
- **Exa Code Context** - Verify correct usage of libraries/APIs before flagging something as wrong.
|
|
88
|
+
- **Exa Web Search** - Research best practices if you're unsure about a pattern.
|
|
89
|
+
|
|
90
|
+
If you're uncertain about something and can't verify it with these tools, say "I'm not sure about X" rather than flagging it as a definite issue.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Output
|
|
95
|
+
|
|
96
|
+
1. If there is a bug, be direct and clear about why it is a bug.
|
|
97
|
+
2. Clearly communicate severity of issues. Do not overstate severity.
|
|
98
|
+
3. Critiques should clearly and explicitly communicate the scenarios, environments, or inputs that are necessary for the bug to arise. The comment should immediately indicate that the issue's severity depends on these factors.
|
|
99
|
+
4. Your tone should be matter-of-fact and not accusatory or overly positive. It should read as a helpful AI assistant suggestion without sounding too much like a human reviewer.
|
|
100
|
+
5. Write so the reader can quickly understand the issue without reading too closely.
|
|
101
|
+
6. AVOID flattery, do not give any comments that are not helpful to the reader. Avoid phrasing like "Great job ...", "Thanks for ...".
|