claude-overnight 1.11.5 → 1.11.6
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 +12 -1
- package/dist/render.js +3 -3
- package/dist/run.js +28 -3
- package/dist/state.d.ts +18 -0
- package/dist/state.js +59 -0
- package/dist/swarm.js +6 -8
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -14,6 +14,15 @@ npm install -g claude-overnight
|
|
|
14
14
|
|
|
15
15
|
Requires Node.js >= 20 and Claude authentication (`claude auth login`, or set `ANTHROPIC_API_KEY`).
|
|
16
16
|
|
|
17
|
+
### Claude Code plugin
|
|
18
|
+
|
|
19
|
+
This repo also ships a Claude Code plugin so any Claude instance (inside this repo or any other) knows how to use, inspect, and resume `claude-overnight` runs:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
/plugin marketplace add Fornace/claude-overnight
|
|
23
|
+
/plugin install claude-overnight
|
|
24
|
+
```
|
|
25
|
+
|
|
17
26
|
## Quick start
|
|
18
27
|
|
|
19
28
|
```bash
|
|
@@ -131,7 +140,9 @@ If the thinking phase succeeds but orchestration crashes, the next run detects t
|
|
|
131
140
|
|
|
132
141
|
**Knowledge carries forward** — new runs inherit knowledge from completed previous runs. Thinking agents and steering see what past runs built. Run 2 knows run 1 already built the auth system.
|
|
133
142
|
|
|
134
|
-
Add `.claude-overnight
|
|
143
|
+
Add `.claude-overnight/` to your `.gitignore` (with the trailing slash — see below).
|
|
144
|
+
|
|
145
|
+
A separate, tiny `claude-overnight.log.md` is also written at the repo root on every run. It's human-readable, append-only, one block per run (objective, start/finish, cost, outcome, branch), and is designed to be **committed** — so even after `.claude-overnight/` is cleaned up you can still recover which prompt produced which commits. Use `.claude-overnight/` (with trailing slash) in your gitignore so this file isn't matched by accident.
|
|
135
146
|
|
|
136
147
|
## Other usage modes
|
|
137
148
|
|
package/dist/render.js
CHANGED
|
@@ -80,8 +80,8 @@ function renderUsageBars(out, w, swarm) {
|
|
|
80
80
|
}
|
|
81
81
|
let label = `${Math.round(pct * 100)}% used`;
|
|
82
82
|
if (swarm.cappedOut) {
|
|
83
|
-
label = swarm.
|
|
84
|
-
? chalk.red(`
|
|
83
|
+
label = swarm.extraUsageBudget != null
|
|
84
|
+
? chalk.red(`Budget $${swarm.extraUsageBudget} exhausted \u2014 finishing active`)
|
|
85
85
|
: chalk.yellow(`Capped at ${capFrac != null ? Math.round(capFrac * 100) : 100}% \u2014 finishing active`);
|
|
86
86
|
}
|
|
87
87
|
else if (swarm.rateLimitPaused > 0) {
|
|
@@ -93,7 +93,7 @@ function renderUsageBars(out, w, swarm) {
|
|
|
93
93
|
label = chalk.red(`Waiting for reset ${mm > 0 ? `${mm}m ${ss}s` : `${ss}s`}`);
|
|
94
94
|
}
|
|
95
95
|
if (swarm.isUsingOverage && !swarm.cappedOut)
|
|
96
|
-
label += chalk.red(" [
|
|
96
|
+
label += chalk.red(" [OVERAGE]");
|
|
97
97
|
const prefix = windowLabel ? chalk.dim(windowLabel.padEnd(6)) : chalk.dim("Usage ");
|
|
98
98
|
out.push(` ${prefix}${barStr} ${label}`);
|
|
99
99
|
};
|
package/dist/run.js
CHANGED
|
@@ -9,7 +9,7 @@ import { RunDisplay } from "./ui.js";
|
|
|
9
9
|
import { renderSummary } from "./render.js";
|
|
10
10
|
import { fmtTokens } from "./render.js";
|
|
11
11
|
import { isAuthError } from "./cli.js";
|
|
12
|
-
import { readRunMemory, writeStatus, writeGoalUpdate, saveRunState, saveWaveSession, loadWaveHistory, recordBranches, archiveMilestone, writeSteerInbox, consumeSteerInbox, countSteerInbox, } from "./state.js";
|
|
12
|
+
import { readRunMemory, writeStatus, writeGoalUpdate, saveRunState, saveWaveSession, loadWaveHistory, recordBranches, archiveMilestone, writeSteerInbox, consumeSteerInbox, countSteerInbox, appendOvernightLogStart, updateOvernightLogEnd, } from "./state.js";
|
|
13
13
|
export async function executeRun(cfg) {
|
|
14
14
|
const restore = () => { try {
|
|
15
15
|
process.stdout.write("\x1B[?25h\n");
|
|
@@ -160,6 +160,20 @@ export async function executeRun(cfg) {
|
|
|
160
160
|
catch { }
|
|
161
161
|
}
|
|
162
162
|
const waveMerge = (flex && runBranch) ? "yolo" : mergeStrategy;
|
|
163
|
+
const runId = runDir.split(/[/\\]/).pop() ?? "";
|
|
164
|
+
if (!cfg.resuming) {
|
|
165
|
+
try {
|
|
166
|
+
appendOvernightLogStart(cwd, runId, {
|
|
167
|
+
objective: objective || "",
|
|
168
|
+
model: workerModel,
|
|
169
|
+
budget: cfg.budget,
|
|
170
|
+
flex,
|
|
171
|
+
usageCap,
|
|
172
|
+
branch: runBranch,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch { }
|
|
176
|
+
}
|
|
163
177
|
let stopping = false;
|
|
164
178
|
const gracefulStop = () => {
|
|
165
179
|
if (stopping) {
|
|
@@ -369,6 +383,17 @@ export async function executeRun(cfg) {
|
|
|
369
383
|
}
|
|
370
384
|
catch { }
|
|
371
385
|
}
|
|
386
|
+
try {
|
|
387
|
+
updateOvernightLogEnd(cwd, runId, {
|
|
388
|
+
cost: accCost,
|
|
389
|
+
completed: accCompleted,
|
|
390
|
+
failed: accFailed,
|
|
391
|
+
waves: waveNum + 1,
|
|
392
|
+
phase: finalPhase,
|
|
393
|
+
elapsedSec: Math.round((Date.now() - cfg.runStartedAt) / 1000),
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
catch { }
|
|
372
397
|
if (runBranch && originalRef) {
|
|
373
398
|
try {
|
|
374
399
|
execSync(`git checkout "${originalRef}"`, { cwd, encoding: "utf-8", stdio: "pipe" });
|
|
@@ -390,7 +415,7 @@ export async function executeRun(cfg) {
|
|
|
390
415
|
else if (remaining <= 0)
|
|
391
416
|
console.log(chalk.bold.yellow(` CLAUDE OVERNIGHT — BUDGET EXHAUSTED`));
|
|
392
417
|
else if (lastCapped)
|
|
393
|
-
console.log(chalk.bold.yellow(` CLAUDE OVERNIGHT —
|
|
418
|
+
console.log(chalk.bold.yellow(` CLAUDE OVERNIGHT — BUDGET EXHAUSTED`));
|
|
394
419
|
else if (stopping || lastAborted)
|
|
395
420
|
console.log(chalk.bold.yellow(` CLAUDE OVERNIGHT — INTERRUPTED`));
|
|
396
421
|
else
|
|
@@ -406,7 +431,7 @@ export async function executeRun(cfg) {
|
|
|
406
431
|
for (const [k1, v1, k2, v2] of statRows)
|
|
407
432
|
console.log(` ${k1} ${v1.padEnd(20)} ${k2} ${v2}`);
|
|
408
433
|
if (lastCapped)
|
|
409
|
-
console.log(` ${chalk.yellow(`
|
|
434
|
+
console.log(` ${chalk.yellow(`Overage budget exhausted`)}`);
|
|
410
435
|
console.log("");
|
|
411
436
|
const statusFile = join(runDir, "status.md");
|
|
412
437
|
if (existsSync(statusFile)) {
|
package/dist/state.d.ts
CHANGED
|
@@ -11,6 +11,24 @@ export declare function writeSteerInbox(runDir: string, text: string): string;
|
|
|
11
11
|
export declare function consumeSteerInbox(runDir: string, waveNum: number): number;
|
|
12
12
|
export declare function writeStatus(baseDir: string, status: string): void;
|
|
13
13
|
export declare function writeGoalUpdate(baseDir: string, update: string): void;
|
|
14
|
+
export interface OvernightLogStart {
|
|
15
|
+
objective: string;
|
|
16
|
+
model: string;
|
|
17
|
+
budget: number;
|
|
18
|
+
flex: boolean;
|
|
19
|
+
usageCap?: number;
|
|
20
|
+
branch?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface OvernightLogEnd {
|
|
23
|
+
cost: number;
|
|
24
|
+
completed: number;
|
|
25
|
+
failed: number;
|
|
26
|
+
waves: number;
|
|
27
|
+
phase: string;
|
|
28
|
+
elapsedSec: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function appendOvernightLogStart(cwd: string, runId: string, meta: OvernightLogStart): void;
|
|
31
|
+
export declare function updateOvernightLogEnd(cwd: string, runId: string, meta: OvernightLogEnd): void;
|
|
14
32
|
export declare function saveRunState(runDir: string, state: RunState): void;
|
|
15
33
|
export declare function loadRunState(runDir: string): RunState | null;
|
|
16
34
|
export declare function findIncompleteRuns(rootDir: string, filterCwd: string): {
|
package/dist/state.js
CHANGED
|
@@ -109,6 +109,65 @@ export function writeGoalUpdate(baseDir, update) {
|
|
|
109
109
|
const trimmed = full.length > 4000 ? full.slice(0, 1000) + "\n\n...\n\n" + full.slice(-3000) : full;
|
|
110
110
|
writeFileSync(goalPath, trimmed, "utf-8");
|
|
111
111
|
}
|
|
112
|
+
// ── Durable run log (claude-overnight.log.md, committed) ──
|
|
113
|
+
// Tiny human-readable record per run so the objective survives even after
|
|
114
|
+
// .claude-overnight/ is cleaned up. Append-only friendly: each run's block
|
|
115
|
+
// is keyed by runId (the run dir basename) so concurrent runs on different
|
|
116
|
+
// machines don't collide.
|
|
117
|
+
function escapeRegExp(s) {
|
|
118
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
119
|
+
}
|
|
120
|
+
export function appendOvernightLogStart(cwd, runId, meta) {
|
|
121
|
+
const path = join(cwd, "claude-overnight.log.md");
|
|
122
|
+
const startedAt = new Date().toISOString().replace("T", " ").slice(0, 19) + " UTC";
|
|
123
|
+
const capStr = meta.usageCap != null ? ` · **Cap:** ${meta.usageCap}%` : "";
|
|
124
|
+
const branchLine = meta.branch ? `\n- **Branch:** ${meta.branch}` : "";
|
|
125
|
+
const block = [
|
|
126
|
+
`## ${runId}`,
|
|
127
|
+
`- **Objective:** ${meta.objective || "(none)"}`,
|
|
128
|
+
`- **Started:** ${startedAt}`,
|
|
129
|
+
`- **Model:** ${meta.model} · **Budget:** ${meta.budget} · **Flex:** ${meta.flex ? "yes" : "no"}${capStr}${branchLine}`,
|
|
130
|
+
`- **Status:** running`,
|
|
131
|
+
"",
|
|
132
|
+
"",
|
|
133
|
+
].join("\n");
|
|
134
|
+
let existing = "";
|
|
135
|
+
try {
|
|
136
|
+
existing = readFileSync(path, "utf-8");
|
|
137
|
+
}
|
|
138
|
+
catch { }
|
|
139
|
+
const header = existing ? "" : "# claude-overnight — run history\n\n";
|
|
140
|
+
writeFileSync(path, header + existing + block, "utf-8");
|
|
141
|
+
}
|
|
142
|
+
export function updateOvernightLogEnd(cwd, runId, meta) {
|
|
143
|
+
const path = join(cwd, "claude-overnight.log.md");
|
|
144
|
+
let existing = "";
|
|
145
|
+
try {
|
|
146
|
+
existing = readFileSync(path, "utf-8");
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const finishedAt = new Date().toISOString().replace("T", " ").slice(0, 19) + " UTC";
|
|
152
|
+
const sec = meta.elapsedSec;
|
|
153
|
+
const elapsed = sec < 60 ? `${sec}s` : sec < 3600 ? `${Math.floor(sec / 60)}m ${sec % 60}s` : `${Math.floor(sec / 3600)}h ${Math.floor((sec % 3600) / 60)}m`;
|
|
154
|
+
const outcome = meta.phase === "done" ? "✓ done" : meta.phase === "capped" ? "⊘ capped" : "⊘ stopped";
|
|
155
|
+
const endLines = [
|
|
156
|
+
`- **Finished:** ${finishedAt} (${elapsed})`,
|
|
157
|
+
`- **Cost:** $${meta.cost.toFixed(2)}`,
|
|
158
|
+
`- **Tasks:** ${meta.completed} done${meta.failed > 0 ? ` / ${meta.failed} failed` : ""} · **Waves:** ${meta.waves}`,
|
|
159
|
+
`- **Status:** ${outcome}`,
|
|
160
|
+
].join("\n");
|
|
161
|
+
const re = new RegExp(`(## ${escapeRegExp(runId)}\\n(?:(?!\\n## )[\\s\\S])*?)- \\*\\*Status:\\*\\* running`);
|
|
162
|
+
if (re.test(existing)) {
|
|
163
|
+
writeFileSync(path, existing.replace(re, `$1${endLines}`), "utf-8");
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const header = existing ? "" : "# claude-overnight — run history\n\n";
|
|
167
|
+
const block = `## ${runId}\n${endLines}\n\n`;
|
|
168
|
+
writeFileSync(path, header + existing + block, "utf-8");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
112
171
|
// ── Run state persistence ──
|
|
113
172
|
export function saveRunState(runDir, state) {
|
|
114
173
|
mkdirSync(runDir, { recursive: true });
|
package/dist/swarm.js
CHANGED
|
@@ -185,30 +185,28 @@ export class Swarm {
|
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
187
|
// Wait loop: keep waiting until the blocking condition clears
|
|
188
|
+
// isUsingOverage is purely informational — the API enforces overage via 429s
|
|
189
|
+
// which the retry loop handles. Throttle only gates on actual rejections and user cap.
|
|
188
190
|
let consecutiveWaits = 0;
|
|
189
191
|
for (;;) {
|
|
190
192
|
if (this.aborted || this.cappedOut)
|
|
191
193
|
return;
|
|
192
194
|
const cap = this.usageCap;
|
|
193
|
-
const overageBlocked = this.isUsingOverage && !this.allowExtraUsage;
|
|
194
195
|
const capExceeded = cap != null && cap < 1 && this.rateLimitUtilization >= cap;
|
|
195
196
|
const rejected = this.rateLimitResetsAt && this.rateLimitResetsAt > Date.now();
|
|
196
|
-
if (!
|
|
197
|
+
if (!capExceeded && !rejected)
|
|
197
198
|
break;
|
|
198
|
-
// Use SDK reset time if available, otherwise escalate: 1m → 3m → 5m (max)
|
|
199
199
|
const fallbackMs = Math.min(300_000, 60_000 * (1 + consecutiveWaits * 2));
|
|
200
200
|
const waitMs = this.rateLimitResetsAt && this.rateLimitResetsAt > Date.now()
|
|
201
201
|
? Math.max(5000, this.rateLimitResetsAt - Date.now())
|
|
202
202
|
: fallbackMs;
|
|
203
|
-
const reason =
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
const reason = capExceeded
|
|
204
|
+
? `Usage at ${Math.round(this.rateLimitUtilization * 100)}% (cap ${Math.round(cap * 100)}%)`
|
|
205
|
+
: "Rate limited";
|
|
206
206
|
this.log(-1, `${reason} — waiting ${Math.ceil(waitMs / 1000)}s then retrying`);
|
|
207
207
|
this.rateLimitPaused++;
|
|
208
208
|
await sleep(waitMs);
|
|
209
209
|
this.rateLimitPaused--;
|
|
210
|
-
// Reset stale flags — fresh state will come from the next SDK event
|
|
211
|
-
this.isUsingOverage = false;
|
|
212
210
|
this.rateLimitUtilization = 0;
|
|
213
211
|
this.rateLimitResetsAt = undefined;
|
|
214
212
|
consecutiveWaits++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-overnight",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.6",
|
|
4
4
|
"description": "Run 10, 100, or 1000 Claude agents overnight. Parallel autonomous AI coding with thinking waves, iterative quality steering, crash recovery, and rate limit handling. Built on the Claude Agent SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"dev": "tsc --watch",
|
|
12
|
-
"start": "node dist/index.js"
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"prepublishOnly": "node scripts/sync-plugin-version.js"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@anthropic-ai/claude-agent-sdk": "^0.2.92",
|