goalforge-claude 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -11
- package/dist/components/claude-cli.d.ts +3 -3
- package/dist/components/claude-cli.d.ts.map +1 -1
- package/dist/components/claude-cli.js +214 -16
- package/dist/components/claude-cli.js.map +1 -1
- package/dist/components/cleanup.js +68 -0
- package/dist/components/cleanup.js.map +1 -0
- package/dist/components/cost-optimizer.d.ts +1 -1
- package/dist/components/cost-optimizer.d.ts.map +1 -1
- package/dist/components/cost-optimizer.js +10 -5
- package/dist/components/cost-optimizer.js.map +1 -1
- package/dist/components/executor.d.ts +10 -1
- package/dist/components/executor.d.ts.map +1 -1
- package/dist/components/executor.js +135 -29
- package/dist/components/executor.js.map +1 -1
- package/dist/components/interactive.d.ts +32 -0
- package/dist/components/interactive.d.ts.map +1 -0
- package/dist/components/interactive.js +149 -0
- package/dist/components/interactive.js.map +1 -0
- package/dist/components/memory-store.js +53 -0
- package/dist/components/memory-store.js.map +1 -1
- package/dist/components/planner.d.ts +2 -1
- package/dist/components/planner.d.ts.map +1 -1
- package/dist/components/planner.js +64 -7
- package/dist/components/planner.js.map +1 -1
- package/dist/components/reviewer.d.ts +2 -1
- package/dist/components/reviewer.d.ts.map +1 -1
- package/dist/components/reviewer.js +112 -30
- package/dist/components/reviewer.js.map +1 -1
- package/dist/components/task-queue.d.ts.map +1 -1
- package/dist/components/task-queue.js +30 -1
- package/dist/components/task-queue.js.map +1 -1
- package/dist/components/test-runner.d.ts.map +1 -1
- package/dist/components/test-runner.js +10 -9
- package/dist/components/test-runner.js.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +4 -3
- package/dist/core/config.js.map +1 -1
- package/dist/core/logger.d.ts +5 -4
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +98 -45
- package/dist/core/logger.js.map +1 -1
- package/dist/core/status-bar.d.ts +27 -0
- package/dist/core/status-bar.d.ts.map +1 -0
- package/dist/core/status-bar.js +192 -0
- package/dist/core/status-bar.js.map +1 -0
- package/dist/core/types.d.ts +2 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.js +530 -46
- package/dist/index.js.map +1 -1
- package/dist/loop-controller.d.ts +4 -1
- package/dist/loop-controller.d.ts.map +1 -1
- package/dist/loop-controller.js +295 -72
- package/dist/loop-controller.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ An autonomous AI development loop that decomposes a high-level goal into tasks,
|
|
|
24
24
|
|
|
25
25
|
```
|
|
26
26
|
index.ts
|
|
27
|
+
├── cleanupAfterSuccess() ← post-success full memory wipe (cleanup.ts)
|
|
27
28
|
└── LoopController ← main event loop
|
|
28
29
|
├── Planner ← goal → ordered task list (Claude)
|
|
29
30
|
├── TaskQueue ← dependency-aware in-memory queue + disk persistence
|
|
@@ -31,13 +32,13 @@ index.ts
|
|
|
31
32
|
├── TestRunner ← runs jest/npm test in workspace, parses report
|
|
32
33
|
├── Reviewer ← critiques completed task output (Claude)
|
|
33
34
|
├── CostOptimizer ← spend budget tracking + prompt-level response cache
|
|
34
|
-
└── MemoryStore ← file-system KV store
|
|
35
|
+
└── MemoryStore ← file-system KV store + per-iteration cleanup
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
Each iteration of the loop runs
|
|
38
|
+
Each iteration of the loop runs seven phases in order:
|
|
38
39
|
|
|
39
40
|
```
|
|
40
|
-
PLAN → EXECUTE → TEST → REVIEW → COST CHECK → MEMORY UPDATE → (repeat or exit)
|
|
41
|
+
PLAN → EXECUTE → TEST → REVIEW → COST CHECK → MEMORY UPDATE → CLEANUP → (repeat or exit)
|
|
41
42
|
```
|
|
42
43
|
|
|
43
44
|
---
|
|
@@ -64,7 +65,8 @@ The main orchestrator. Owns all component instances and drives the six-phase loo
|
|
|
64
65
|
| `testPhase` | Calls `TestRunner`, updates coverage + pass/fail on state. |
|
|
65
66
|
| `reviewPhase` | Reviews the last 3 completed tasks; requeues if score < 70 and `retryCount < 2`. |
|
|
66
67
|
| `costCheckPhase` | Exits loop if total spend exceeds `maxCostUsd`. |
|
|
67
|
-
| `updateMemoryPhase` | Persists `ProjectState` to disk
|
|
68
|
+
| `updateMemoryPhase` | Persists `ProjectState` to disk; resets `currentPhase` to `idle`. |
|
|
69
|
+
| `cleanupPhase` | Calls `MemoryStore.cleanupMemory()`: removes critique files for completed tasks and evicts oldest cache entries beyond the 200-entry cap. |
|
|
68
70
|
|
|
69
71
|
---
|
|
70
72
|
|
|
@@ -158,11 +160,23 @@ memory/
|
|
|
158
160
|
state/project.json ← single ProjectState document
|
|
159
161
|
tasks/<uuid>.json ← one file per task
|
|
160
162
|
critiques/<uuid>.json ← one file per Critique
|
|
161
|
-
decisions/<uuid>.json ← one file per ArchitectureDecision
|
|
163
|
+
decisions/<uuid>.json ← one file per ArchitectureDecision (preserved on cleanup)
|
|
162
164
|
files/<path-hash>.json ← metadata for each generated file
|
|
163
165
|
cache/<sha256>.json ← CostOptimizer response cache entries
|
|
164
166
|
```
|
|
165
167
|
|
|
168
|
+
**`cleanupMemory(completedTaskIds, maxCacheEntries = 200)`** — called after every iteration. Deletes critique files whose `taskId` is in `completedTaskIds`, and evicts the oldest cache entries once the cache exceeds `maxCacheEntries` files.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### `Cleanup` (`src/components/cleanup.ts`)
|
|
173
|
+
|
|
174
|
+
Standalone module called from `index.ts` after a successful loop exit (after `appendToChangelog`).
|
|
175
|
+
|
|
176
|
+
**`cleanupAfterSuccess(memoryDir)`** — wipes `tasks/`, `critiques/`, `cache/`, `files/`, and `state/project.json`. Preserves `decisions/` and `OUTBOX.md`. Returns a `CleanupResult` with per-directory counts.
|
|
177
|
+
|
|
178
|
+
**`isSuccessExit(reason)`** — returns `true` for `no-critical-issues`, `all-tasks-complete`, `coverage-met`, `tests-passing`.
|
|
179
|
+
|
|
166
180
|
---
|
|
167
181
|
|
|
168
182
|
## Data Flow
|
|
@@ -206,7 +220,7 @@ memory/
|
|
|
206
220
|
|
|
207
221
|
```
|
|
208
222
|
<project-root>/
|
|
209
|
-
|
|
223
|
+
.goalforge/
|
|
210
224
|
memory/
|
|
211
225
|
state/project.json
|
|
212
226
|
tasks/
|
|
@@ -214,11 +228,13 @@ memory/
|
|
|
214
228
|
decisions/
|
|
215
229
|
files/
|
|
216
230
|
cache/
|
|
217
|
-
|
|
231
|
+
<your generated code lives directly here, at the project root>
|
|
218
232
|
```
|
|
219
233
|
|
|
220
234
|
Paths are configured via `workspaceDir` and `memoryDir` in `LoopConfig`. Tests write to isolated temp directories and clean up in `beforeEach` and `afterAll`.
|
|
221
235
|
|
|
236
|
+
> **Note**: `.goalforge` is automatically added to `.gitignore` on first run.
|
|
237
|
+
|
|
222
238
|
---
|
|
223
239
|
|
|
224
240
|
## Exit Conditions
|
|
@@ -231,6 +247,8 @@ The loop exits (returning a `LoopExitReason`) when the first of these is true:
|
|
|
231
247
|
| `all-tasks-complete` | Queue is complete (all COMPLETE/FAILED) AND at least one task was completed |
|
|
232
248
|
| `cost-exceeded` | `totalSpendUsd >= maxCostUsd` (checked after execute phase and after cost phase) |
|
|
233
249
|
| `max-iterations` | Loop counter reaches `maxIterations` |
|
|
250
|
+
| `user-quit` | User typed `quit` at the interactive pause or finish prompt |
|
|
251
|
+
| `user-redo` | User typed `redo` at the interactive pause or finish prompt; the outer `main()` loop restarts with an updated goal |
|
|
234
252
|
|
|
235
253
|
---
|
|
236
254
|
|
|
@@ -282,14 +300,18 @@ npm run build
|
|
|
282
300
|
# Dry run (no Claude calls, no file writes)
|
|
283
301
|
DRY_RUN=true npm start
|
|
284
302
|
|
|
285
|
-
# Real run
|
|
286
|
-
|
|
303
|
+
# Real run — run from your project directory, files land in place
|
|
304
|
+
cd ~/my-project
|
|
305
|
+
GOAL="Build a REST API for user authentication" goalforge "Build a REST API for user authentication"
|
|
287
306
|
|
|
288
307
|
# Override budget and iteration limit
|
|
289
|
-
|
|
308
|
+
goalforge --iter 10 --cost 5 "Build a REST API for user authentication"
|
|
309
|
+
|
|
310
|
+
# Resume an interrupted run
|
|
311
|
+
goalforge resume
|
|
290
312
|
```
|
|
291
313
|
|
|
292
|
-
Generated code is written
|
|
314
|
+
Generated code is written into `process.cwd()` — the directory you run the command from. Persistent state is stored in `.goalforge/memory/` inside the same directory.
|
|
293
315
|
|
|
294
316
|
---
|
|
295
317
|
|
|
@@ -6,9 +6,9 @@ export interface CliResult {
|
|
|
6
6
|
* Call Claude via the `claude` CLI (uses Claude.ai subscription auth —
|
|
7
7
|
* no ANTHROPIC_API_KEY required).
|
|
8
8
|
*
|
|
9
|
-
* Spawns: claude -p --output-format json --dangerously-skip-permissions
|
|
10
|
-
*
|
|
11
|
-
* Returns the result text and reported cost.
|
|
9
|
+
* Spawns: claude -p --output-format stream-json --dangerously-skip-permissions
|
|
10
|
+
* Streams NDJSON events so the user sees Claude's response as it generates.
|
|
11
|
+
* Returns the result text and reported cost from the final `result` event.
|
|
12
12
|
*/
|
|
13
13
|
export declare function callClaude(systemPrompt: string, userPrompt: string, timeoutMs?: number): Promise<CliResult>;
|
|
14
14
|
//# sourceMappingURL=claude-cli.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-cli.d.ts","sourceRoot":"","sources":["../../src/components/claude-cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claude-cli.d.ts","sourceRoot":"","sources":["../../src/components/claude-cli.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,SAAmD,GAC3D,OAAO,CAAC,SAAS,CAAC,CAyJpB"}
|
|
@@ -1,22 +1,185 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RateLimitError = void 0;
|
|
3
37
|
exports.callClaude = callClaude;
|
|
4
38
|
const child_process_1 = require("child_process");
|
|
39
|
+
const logger_1 = require("../core/logger");
|
|
40
|
+
const StatusBar = __importStar(require("../core/status-bar"));
|
|
41
|
+
const log = (0, logger_1.createLogger)('ClaudeCLI');
|
|
42
|
+
/** Thrown when the Claude CLI reports a rate/usage limit. Loop can sleep and retry. */
|
|
43
|
+
class RateLimitError extends Error {
|
|
44
|
+
constructor(resetDelayMs) {
|
|
45
|
+
super(`Rate limit hit — resets in ${Math.ceil(resetDelayMs / 60000)}m`);
|
|
46
|
+
this.resetDelayMs = resetDelayMs;
|
|
47
|
+
this.name = 'RateLimitError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.RateLimitError = RateLimitError;
|
|
51
|
+
const RATE_LIMIT_PATTERN = /\b(session|usage|rate)\s+limit\b|hit your (session|usage) limit|reached your usage|limit reached|too many requests/i;
|
|
52
|
+
function parseResetDelayMs(text) {
|
|
53
|
+
const match = text.match(/reset[^.]*?(?:at|@)\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)/i);
|
|
54
|
+
if (match) {
|
|
55
|
+
const hour = parseInt(match[1], 10);
|
|
56
|
+
const minute = parseInt(match[2] ?? '0', 10);
|
|
57
|
+
const isPm = match[3].toLowerCase() === 'pm';
|
|
58
|
+
const resetHour = isPm ? (hour === 12 ? 12 : hour + 12) : (hour === 12 ? 0 : hour);
|
|
59
|
+
const now = new Date();
|
|
60
|
+
const reset = new Date(now);
|
|
61
|
+
reset.setHours(resetHour, minute, 0, 0);
|
|
62
|
+
if (reset <= now)
|
|
63
|
+
reset.setDate(reset.getDate() + 1);
|
|
64
|
+
return Math.max(60000, reset.getTime() - now.getTime());
|
|
65
|
+
}
|
|
66
|
+
return 30 * 60000; // default: 30 minutes
|
|
67
|
+
}
|
|
68
|
+
// Max chars of Claude's streaming response to echo to the terminal.
|
|
69
|
+
const STREAM_PREVIEW_LIMIT = 500;
|
|
70
|
+
const DIM = '\x1b[2m';
|
|
71
|
+
const R = '\x1b[0m';
|
|
72
|
+
const CYAN = '\x1b[36m';
|
|
73
|
+
const BOLD = '\x1b[1m';
|
|
74
|
+
const SYS_PREVIEW_CHARS = 120;
|
|
75
|
+
const USER_PREVIEW_CHARS = 400;
|
|
76
|
+
function logPromptToTUI(systemPrompt, userPrompt, taskId) {
|
|
77
|
+
const label = taskId ? ` ${DIM}[${taskId}]${R}` : '';
|
|
78
|
+
const sysLine = systemPrompt.slice(0, SYS_PREVIEW_CHARS).replace(/\n/g, ' ').trim()
|
|
79
|
+
+ (systemPrompt.length > SYS_PREVIEW_CHARS ? '…' : '');
|
|
80
|
+
const userLine = userPrompt.slice(0, USER_PREVIEW_CHARS).replace(/\n/g, '↵').trim()
|
|
81
|
+
+ (userPrompt.length > USER_PREVIEW_CHARS ? '…' : '');
|
|
82
|
+
StatusBar.wrapLog(() => {
|
|
83
|
+
process.stdout.write(`${CYAN}${BOLD}⟡ Claude prompt${R}${label}\n`
|
|
84
|
+
+ ` ${DIM}sys: ${sysLine}${R}\n`
|
|
85
|
+
+ ` ${DIM}usr: ${userLine}${R}\n`);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
5
88
|
/**
|
|
6
89
|
* Call Claude via the `claude` CLI (uses Claude.ai subscription auth —
|
|
7
90
|
* no ANTHROPIC_API_KEY required).
|
|
8
91
|
*
|
|
9
|
-
* Spawns: claude -p --output-format json --dangerously-skip-permissions
|
|
10
|
-
*
|
|
11
|
-
* Returns the result text and reported cost.
|
|
92
|
+
* Spawns: claude -p --output-format stream-json --dangerously-skip-permissions
|
|
93
|
+
* Streams NDJSON events so the user sees Claude's response as it generates.
|
|
94
|
+
* Returns the result text and reported cost from the final `result` event.
|
|
12
95
|
*/
|
|
13
|
-
async function callClaude(systemPrompt, userPrompt, timeoutMs =
|
|
96
|
+
async function callClaude(systemPrompt, userPrompt, timeoutMs = Number(process.env.CLAUDE_TIMEOUT_MS ?? 600000), taskId // when set, streaming goes to the task panel instead of stdout
|
|
97
|
+
) {
|
|
14
98
|
const fullPrompt = `${systemPrompt}\n\n---\n\n${userPrompt}`;
|
|
99
|
+
const debug = process.env.GOALFORGE_DEBUG === 'true';
|
|
100
|
+
// Always log prompts to TUI so the user can see what is being sent to Claude.
|
|
101
|
+
logPromptToTUI(systemPrompt, userPrompt, taskId);
|
|
102
|
+
if (debug) {
|
|
103
|
+
log.debug('Claude call starting', {
|
|
104
|
+
promptChars: fullPrompt.length,
|
|
105
|
+
timeoutMs,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
15
108
|
return new Promise((resolve, reject) => {
|
|
16
|
-
const child = (0, child_process_1.spawn)('claude', ['-p', '--output-format', 'json', '--dangerously-skip-permissions'], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
17
|
-
|
|
109
|
+
const child = (0, child_process_1.spawn)('claude', ['-p', '--output-format', 'stream-json', '--verbose', '--dangerously-skip-permissions'], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
110
|
+
// Track streaming state
|
|
111
|
+
let lastTextLength = 0; // for cumulative assistant events (delta = text.slice(lastTextLength))
|
|
112
|
+
let shownChars = 0;
|
|
113
|
+
let streamStarted = false;
|
|
114
|
+
let resultEvent = null;
|
|
18
115
|
let stderr = '';
|
|
19
|
-
|
|
116
|
+
let lineBuffer = '';
|
|
117
|
+
let rateLimitDetected = false;
|
|
118
|
+
let rateLimitResetMs = 0;
|
|
119
|
+
// Heartbeat: redraw status bar every 5 s so the elapsed timer stays live.
|
|
120
|
+
const heartbeat = setInterval(() => StatusBar.update({}), 5000);
|
|
121
|
+
const processLine = (line) => {
|
|
122
|
+
if (!line.trim())
|
|
123
|
+
return;
|
|
124
|
+
let event;
|
|
125
|
+
try {
|
|
126
|
+
event = JSON.parse(line);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return; // non-JSON line (rare); ignore
|
|
130
|
+
}
|
|
131
|
+
if (event.type === 'assistant') {
|
|
132
|
+
const msg = event.message;
|
|
133
|
+
const content = (msg?.content ?? []);
|
|
134
|
+
for (const block of content) {
|
|
135
|
+
if (block.type !== 'text' || !block.text)
|
|
136
|
+
continue;
|
|
137
|
+
const newChars = block.text.length > lastTextLength
|
|
138
|
+
? block.text.slice(lastTextLength) // cumulative mode
|
|
139
|
+
: block.text; // incremental mode
|
|
140
|
+
lastTextLength = Math.max(lastTextLength, block.text.length);
|
|
141
|
+
if (!newChars)
|
|
142
|
+
continue;
|
|
143
|
+
if (taskId) {
|
|
144
|
+
// Route to task panel row — no char limit, panel truncates visually.
|
|
145
|
+
StatusBar.streamTask(taskId, newChars);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Legacy: stream directly to stdout up to STREAM_PREVIEW_LIMIT.
|
|
149
|
+
if (shownChars >= STREAM_PREVIEW_LIMIT)
|
|
150
|
+
continue;
|
|
151
|
+
const toShow = newChars.slice(0, STREAM_PREVIEW_LIMIT - shownChars);
|
|
152
|
+
if (!toShow)
|
|
153
|
+
continue;
|
|
154
|
+
if (!streamStarted) {
|
|
155
|
+
streamStarted = true;
|
|
156
|
+
StatusBar.wrapLog(() => process.stdout.write('\n'));
|
|
157
|
+
}
|
|
158
|
+
StatusBar.wrapLog(() => process.stdout.write(toShow));
|
|
159
|
+
shownChars += toShow.length;
|
|
160
|
+
if (shownChars >= STREAM_PREVIEW_LIMIT) {
|
|
161
|
+
StatusBar.wrapLog(() => process.stdout.write('…\n'));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (event.type === 'rate_limit_event') {
|
|
167
|
+
rateLimitDetected = true;
|
|
168
|
+
const info = event.rate_limit_info;
|
|
169
|
+
if (typeof info?.resets_at === 'number') {
|
|
170
|
+
rateLimitResetMs = Math.max(0, info.resets_at * 1000 - Date.now());
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (event.type === 'result') {
|
|
174
|
+
resultEvent = event;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
child.stdout.on('data', (chunk) => {
|
|
178
|
+
lineBuffer += chunk.toString();
|
|
179
|
+
const lines = lineBuffer.split('\n');
|
|
180
|
+
lineBuffer = lines.pop() ?? '';
|
|
181
|
+
lines.forEach(processLine);
|
|
182
|
+
});
|
|
20
183
|
child.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
|
|
21
184
|
const timer = setTimeout(() => {
|
|
22
185
|
child.kill('SIGTERM');
|
|
@@ -24,23 +187,58 @@ async function callClaude(systemPrompt, userPrompt, timeoutMs = 180000) {
|
|
|
24
187
|
}, timeoutMs);
|
|
25
188
|
child.on('close', (code) => {
|
|
26
189
|
clearTimeout(timer);
|
|
190
|
+
clearInterval(heartbeat);
|
|
191
|
+
// Flush any remaining partial line
|
|
192
|
+
if (lineBuffer.trim())
|
|
193
|
+
processLine(lineBuffer);
|
|
194
|
+
// Ensure direct-stdout streaming ends on a clean line (task panel handles its own layout).
|
|
195
|
+
if (!taskId && streamStarted && shownChars < STREAM_PREVIEW_LIMIT) {
|
|
196
|
+
StatusBar.wrapLog(() => process.stdout.write('\n'));
|
|
197
|
+
}
|
|
198
|
+
if (debug) {
|
|
199
|
+
log.debug('Claude call finished', {
|
|
200
|
+
exitCode: code,
|
|
201
|
+
resultChars: typeof resultEvent?.result === 'string' ? resultEvent.result.length : 0,
|
|
202
|
+
costUsd: resultEvent?.total_cost_usd,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// Use the result event as the authoritative source of truth.
|
|
206
|
+
const res = resultEvent;
|
|
207
|
+
// Rate limit: structured event OR text pattern in stderr/result
|
|
208
|
+
const combinedOutput = stderr + (typeof resultEvent?.result === 'string' ? resultEvent.result : '');
|
|
209
|
+
if (rateLimitDetected || RATE_LIMIT_PATTERN.test(combinedOutput)) {
|
|
210
|
+
const delay = rateLimitResetMs || parseResetDelayMs(combinedOutput);
|
|
211
|
+
reject(new RateLimitError(delay));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
27
214
|
if (code !== 0) {
|
|
28
|
-
|
|
215
|
+
const message = (typeof res?.result === 'string' && res.result.trim())
|
|
216
|
+
? res.result.trim()
|
|
217
|
+
: (stderr.trim() || '(no output captured)');
|
|
218
|
+
reject(new Error(`claude exited ${code}: ${message.slice(0, 500)}`));
|
|
29
219
|
return;
|
|
30
220
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
221
|
+
if (!res) {
|
|
222
|
+
reject(new Error(`claude produced no result event. stderr: ${stderr.slice(0, 300)}`));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (res.is_error === true) {
|
|
226
|
+
const msg = typeof res.result === 'string' ? res.result.trim() : 'unknown error';
|
|
227
|
+
reject(new Error(`claude returned an error: ${msg}`));
|
|
228
|
+
return;
|
|
37
229
|
}
|
|
38
|
-
|
|
39
|
-
|
|
230
|
+
const costUsd = typeof res.total_cost_usd === 'number' ? res.total_cost_usd : 0;
|
|
231
|
+
if (typeof res.total_cost_usd !== 'number') {
|
|
232
|
+
log.warn('total_cost_usd missing — cost tracking may be inaccurate (subscription billing)');
|
|
40
233
|
}
|
|
234
|
+
resolve({
|
|
235
|
+
text: typeof res.result === 'string' ? res.result : '',
|
|
236
|
+
costUsd,
|
|
237
|
+
});
|
|
41
238
|
});
|
|
42
239
|
child.on('error', (err) => {
|
|
43
240
|
clearTimeout(timer);
|
|
241
|
+
clearInterval(heartbeat);
|
|
44
242
|
reject(new Error(`Failed to spawn claude CLI: ${err.message}. Is claude installed and on PATH?`));
|
|
45
243
|
});
|
|
46
244
|
child.stdin.write(fullPrompt);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-cli.js","sourceRoot":"","sources":["../../src/components/claude-cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claude-cli.js","sourceRoot":"","sources":["../../src/components/claude-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,gCAgLC;AAzPD,iDAAsC;AACtC,2CAA8C;AAC9C,8DAAgD;AAEhD,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C9B,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSuccessExit = isSuccessExit;
|
|
4
|
+
exports.cleanupAfterSuccess = cleanupAfterSuccess;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const logger_1 = require("../core/logger");
|
|
8
|
+
const SUCCESS_EXITS = new Set([
|
|
9
|
+
'no-critical-issues',
|
|
10
|
+
'all-tasks-complete',
|
|
11
|
+
'coverage-met',
|
|
12
|
+
'tests-passing',
|
|
13
|
+
]);
|
|
14
|
+
const log = (0, logger_1.createLogger)('Cleanup');
|
|
15
|
+
/** Returns true when the exit reason indicates the loop completed its goal. */
|
|
16
|
+
function isSuccessExit(reason) {
|
|
17
|
+
return SUCCESS_EXITS.has(reason);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Removes all run-specific memory files after a successful loop completion.
|
|
21
|
+
*
|
|
22
|
+
* Clears: tasks/, critiques/, cache/, files/, state/project.json
|
|
23
|
+
* Preserves: decisions/ (ADRs carry forward), OUTBOX.md (cross-run learning)
|
|
24
|
+
*/
|
|
25
|
+
function cleanupAfterSuccess(memoryDir) {
|
|
26
|
+
const result = {
|
|
27
|
+
tasksRemoved: 0,
|
|
28
|
+
critiquesRemoved: 0,
|
|
29
|
+
cacheEntriesRemoved: 0,
|
|
30
|
+
fileMetadataRemoved: 0,
|
|
31
|
+
stateCleared: false,
|
|
32
|
+
};
|
|
33
|
+
result.tasksRemoved = clearJsonDir((0, path_1.join)(memoryDir, 'tasks'));
|
|
34
|
+
result.critiquesRemoved = clearJsonDir((0, path_1.join)(memoryDir, 'critiques'));
|
|
35
|
+
result.cacheEntriesRemoved = clearJsonDir((0, path_1.join)(memoryDir, 'cache'));
|
|
36
|
+
result.fileMetadataRemoved = clearJsonDir((0, path_1.join)(memoryDir, 'files'));
|
|
37
|
+
const statePath = (0, path_1.join)(memoryDir, 'state', 'project.json');
|
|
38
|
+
if ((0, fs_1.existsSync)(statePath)) {
|
|
39
|
+
try {
|
|
40
|
+
(0, fs_1.unlinkSync)(statePath);
|
|
41
|
+
result.stateCleared = true;
|
|
42
|
+
}
|
|
43
|
+
catch { /* non-fatal */ }
|
|
44
|
+
}
|
|
45
|
+
const total = result.tasksRemoved +
|
|
46
|
+
result.critiquesRemoved +
|
|
47
|
+
result.cacheEntriesRemoved +
|
|
48
|
+
result.fileMetadataRemoved +
|
|
49
|
+
(result.stateCleared ? 1 : 0);
|
|
50
|
+
if (total > 0) {
|
|
51
|
+
log.info('Post-run cleanup complete', result);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
function clearJsonDir(dir) {
|
|
56
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
57
|
+
return 0;
|
|
58
|
+
let removed = 0;
|
|
59
|
+
for (const f of (0, fs_1.readdirSync)(dir).filter((f) => f.endsWith('.json'))) {
|
|
60
|
+
try {
|
|
61
|
+
(0, fs_1.unlinkSync)((0, path_1.join)(dir, f));
|
|
62
|
+
removed++;
|
|
63
|
+
}
|
|
64
|
+
catch { /* non-fatal — skip locked or already-gone files */ }
|
|
65
|
+
}
|
|
66
|
+
return removed;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=cleanup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/components/cleanup.ts"],"names":[],"mappings":";;AAuBA,sCAEC;AAQD,kDAkCC;AAnED,2BAAyD;AACzD,+BAA4B;AAC5B,2CAA8C;AAW9C,MAAM,aAAa,GAAG,IAAI,GAAG,CAA2B;IACtD,oBAAoB;IACpB,oBAAoB;IACpB,cAAc;IACd,eAAe;CAChB,CAAC,CAAC;AAEH,MAAM,GA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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,GAAG,CAAC,IAAI,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,CAAC,IAAI,IAAA,gBAAW,EAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACpE,IAAI,CAAC;YACH,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACzB,OAAO,EAAE,CAAC;QACZ,CAAC;QAAC,MAAM,CAAC,CAAC,mDAAmD,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -38,6 +38,6 @@ export declare class CostOptimizer {
|
|
|
38
38
|
cacheEntries: number;
|
|
39
39
|
};
|
|
40
40
|
/** Sync cumulative totals from a ProjectState so they survive process restarts. */
|
|
41
|
-
restoreFromState(inputTokens: number, outputTokens: number): void;
|
|
41
|
+
restoreFromState(inputTokens: number, outputTokens: number, directCostUsd?: number): void;
|
|
42
42
|
}
|
|
43
43
|
//# sourceMappingURL=cost-optimizer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost-optimizer.d.ts","sourceRoot":"","sources":["../../src/components/cost-optimizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,WAAW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EAAE,GAAG,MAAM;IAKhE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQlD,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAS3D;;;;OAIG;IACH,QAAQ,CACN,UAAU,EAAE,MAAM,EAClB,qBAAqB,EAAE,MAAM,EAC7B,QAAQ,EAAE,MAAM,GACf,YAAY;IA2Df,6EAA6E;IAC7E,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAYpC,8EAA8E;IAC9E,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAY7B,UAAU,IAAI,MAAM;IAIpB,gBAAgB,IAAI,OAAO;IAI3B,QAAQ,IAAI;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,EAAE,MAAM,CAAC;QACzB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,aAAa,EAAE,MAAM,CAAC;QACtB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,YAAY,EAAE,MAAM,CAAC;KACtB;IAYD,mFAAmF;IACnF,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,SAAI,GAAG,IAAI;CAKrF"}
|
|
@@ -26,13 +26,17 @@ class CostOptimizer {
|
|
|
26
26
|
}
|
|
27
27
|
getCachedResponse(cacheKey) {
|
|
28
28
|
const hit = this.memory.getCached(cacheKey);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Treat entries that contain no JSON object as stale/corrupt cache misses.
|
|
30
|
+
if (!hit || !hit.includes('{'))
|
|
31
|
+
return null;
|
|
32
|
+
this.log.debug('Cache hit', { cacheKey: cacheKey.slice(0, 8) + '…' });
|
|
32
33
|
return hit;
|
|
33
34
|
}
|
|
34
35
|
putCachedResponse(cacheKey, response) {
|
|
35
|
-
|
|
36
|
+
// Only cache responses that actually contain a JSON object.
|
|
37
|
+
if (response && response.includes('{')) {
|
|
38
|
+
this.memory.putCache(cacheKey, response);
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
// ── Budget ─────────────────────────────────────────────────────────────────
|
|
38
42
|
/**
|
|
@@ -131,9 +135,10 @@ class CostOptimizer {
|
|
|
131
135
|
};
|
|
132
136
|
}
|
|
133
137
|
/** Sync cumulative totals from a ProjectState so they survive process restarts. */
|
|
134
|
-
restoreFromState(inputTokens, outputTokens) {
|
|
138
|
+
restoreFromState(inputTokens, outputTokens, directCostUsd = 0) {
|
|
135
139
|
this.totalInputTokens = inputTokens;
|
|
136
140
|
this.totalOutputTokens = outputTokens;
|
|
141
|
+
this.directCostUsd = directCostUsd;
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
144
|
exports.CostOptimizer = CostOptimizer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost-optimizer.js","sourceRoot":"","sources":["../../src/components/cost-optimizer.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,2CAA0C;AAE1C,2CAA8C;AAE9C;;;GAGG;AACH,MAAa,aAAa;IAOxB,YACmB,MAAkB,EAClB,MAAmB;QADnB,WAAM,GAAN,MAAM,CAAY;QAClB,WAAM,GAAN,MAAM,CAAa;QAR9B,qBAAgB,GAAG,CAAC,CAAC;QACrB,sBAAiB,GAAG,CAAC,CAAC;QACtB,kBAAa,GAAG,CAAC,CAAC;QAClB,cAAS,GAAG,CAAC,CAAC;QACL,QAAG,GAAG,IAAA,qBAAY,EAAC,eAAe,CAAC,CAAC;IAKlD,CAAC;IAEJ,8EAA8E;IAE9E,sEAAsE;IACtE,aAAa,CAAC,MAAc,EAAE,GAAG,YAAsB;QACrD,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM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AAa,CAAC;YACvE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;SACzC,CAAC;IACJ,CAAC;IAED,mFAAmF;IACnF,gBAAgB,CAAC,WAAmB,EAAE,YAAoB,EAAE,aAAa,GAAG,CAAC;QAC3E,IAAI,CAAC,gBAAgB,GAAG,WAAW,CAAC;QACpC,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AApKD,sCAoKC"}
|
|
@@ -6,13 +6,22 @@ export declare class Executor {
|
|
|
6
6
|
private readonly optimizer;
|
|
7
7
|
private readonly memory;
|
|
8
8
|
private readonly dryRun;
|
|
9
|
+
private readonly timeoutMs;
|
|
9
10
|
private readonly log;
|
|
10
|
-
constructor(workspaceDir: string, optimizer: CostOptimizer, memory: MemoryStore, dryRun?: boolean);
|
|
11
|
+
constructor(workspaceDir: string, optimizer: CostOptimizer, memory: MemoryStore, dryRun?: boolean, timeoutMs?: number);
|
|
11
12
|
execute(task: Task): Promise<TaskResult>;
|
|
12
13
|
private buildContext;
|
|
13
14
|
private callApi;
|
|
14
15
|
private parse;
|
|
15
16
|
private apply;
|
|
17
|
+
/**
|
|
18
|
+
* Analyse why a task failed and return a revised objective.
|
|
19
|
+
* Called before retry so the next attempt has a better goal.
|
|
20
|
+
*/
|
|
21
|
+
repair(task: Task, error: string): Promise<{
|
|
22
|
+
rootCause: string;
|
|
23
|
+
revisedObjective: string | null;
|
|
24
|
+
}>;
|
|
16
25
|
private dryRunResponse;
|
|
17
26
|
}
|
|
18
27
|
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/components/executor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/components/executor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAkC7C,qBAAa,QAAQ;IAIjB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAP5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4B;gBAG7B,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,WAAW,EACnB,MAAM,UAAQ,EACd,SAAS,SAAU;IAKhC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IA0C9C,OAAO,CAAC,YAAY;YAuBN,OAAO;IAarB,OAAO,CAAC,KAAK;YAmBC,KAAK;IAkDnB;;;OAGG;IACG,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IA8CxG,OAAO,CAAC,cAAc;CAavB"}
|