burnoff 1.4.1 → 2.1.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/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/burnoff-pr-gate.yml +5 -3
- package/.github/workflows/burnoff-startup-lint.yml +2 -2
- package/CHANGELOG.md +74 -0
- package/README.md +187 -213
- package/SECURITY.md +38 -0
- package/bin/burnoff.mjs +307 -32
- package/commands/burnoff.md +6 -4
- package/docs/CLAUDE_CODE_PLUGIN.md +29 -28
- package/docs/DESIGN_PARTNER_INTAKE.md +3 -3
- package/hooks/hook-io.mjs +216 -11
- package/hooks/hooks.json +44 -0
- package/hooks/post-tool-use.mjs +3 -1
- package/hooks/pre-tool-use.mjs +47 -8
- package/hooks/session-lifecycle.mjs +24 -3
- package/hooks/user-prompt-submit.mjs +98 -0
- package/package.json +6 -4
- package/scripts/bench-hooks.mjs +34 -3
- package/scripts/bench-savings.mjs +318 -0
- package/scripts/burnoff-statusline.mjs +138 -6
- package/src/ci/ci-gate.mjs +199 -13
- package/src/ci/pr-cost.mjs +417 -45
- package/src/ci/pr-summary.mjs +467 -0
- package/src/cli/audit.mjs +179 -28
- package/src/cli/doctor.mjs +32 -6
- package/src/cli/hook-health.mjs +9 -1
- package/src/cli/init.mjs +226 -39
- package/src/cli/preview.mjs +299 -0
- package/src/cli/startup-audit/formatter.mjs +248 -0
- package/src/cli/startup-audit/jsonc.mjs +601 -0
- package/src/cli/startup-audit/mcp-audit.mjs +735 -0
- package/src/cli/startup-audit/rules-hygiene.mjs +645 -0
- package/src/cli/startup-audit/telemetry-scan.mjs +975 -0
- package/src/cli/startup-audit.mjs +451 -2471
- package/src/clients/claude-code.mjs +41 -4
- package/src/config/catalog.json +295 -0
- package/src/config/effort.mjs +145 -0
- package/src/config/harness-quirks.mjs +340 -0
- package/src/config/loader.mjs +27 -2
- package/src/config/policy.mjs +81 -9
- package/src/config/pricing.mjs +247 -19
- package/src/config/semver.mjs +25 -0
- package/src/config/uncached-attribution.mjs +280 -41
- package/src/guards/compaction-baton.mjs +248 -0
- package/src/guards/loop-breaker.mjs +328 -47
- package/src/guards/model-switch-hook.mjs +126 -0
- package/src/guards/phase5-detectors.mjs +275 -21
- package/src/guards/post-tool-engine.mjs +333 -11
- package/src/guards/pre-tool-engine.mjs +607 -45
- package/src/guards/prefix-guard.mjs +609 -0
- package/src/guards/prompt-guard.mjs +309 -0
- package/src/guards/read-clamp.mjs +192 -8
- package/src/guards/session-hook.mjs +149 -7
- package/src/guards/shell-guard.mjs +56 -5
- package/src/guards/snooze.mjs +169 -5
- package/src/ipc/daemon.mjs +76 -0
- package/src/ipc/fast-client.mjs +165 -4
- package/src/ipc/protocol.mjs +16 -3
- package/src/storage/antigravity-parser.mjs +16 -2
- package/src/storage/file-lock.mjs +16 -3
- package/src/storage/jsonl-parser.mjs +133 -22
- package/src/storage/telemetry-metrics.mjs +254 -4
package/SECURITY.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Security Policy & Privacy Guarantees
|
|
2
|
+
|
|
3
|
+
Burnoff (`burnoff`) is a local-first safety firewall, circuit breaker, and context-hygiene linter for Claude Code and Google Antigravity.
|
|
4
|
+
|
|
5
|
+
## Security & Network Model
|
|
6
|
+
|
|
7
|
+
- **Zero outbound network calls.** Burnoff makes no HTTP, HTTPS, WebSocket, telemetry, analytics, or update-check requests at install time, hook runtime, daemon runtime, or CLI audit time.
|
|
8
|
+
- **Zero runtime npm dependencies.** `package.json` declares `"dependencies": {}` and relies exclusively on built-in Node.js modules (`node:fs`, `node:path`, `node:sqlite`, `node:net`, `node:crypto`, `node:child_process`).
|
|
9
|
+
- **Ring-0 fail-closed protections.** Hard blocks for destructive shell/Git commands (`DET-01`), secret & credential boundaries (`DET-02` for `.env`, PEM/SSH keys, token dumps), and concurrent multi-agent write locks (`DET-20`) are never bypassed by `burnoff pause`, `burnoff allow-once`, `burnoff snooze`, or `burnoff bypass --grant`.
|
|
10
|
+
|
|
11
|
+
## Local Filesystem Paths
|
|
12
|
+
|
|
13
|
+
Burnoff only reads or writes local workspace and user-home files inside explicit client/state locations:
|
|
14
|
+
|
|
15
|
+
| Purpose | Local Path | Mode / Notes |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| Workspace hook wiring (Claude) | `.claude/settings.local.json` | Git-excluded via `.git/info/exclude` (never `settings.json`) |
|
|
18
|
+
| Global hook wiring (Claude `--global`) | `~/.claude/settings.json` | Only touched when `--global` is explicitly passed |
|
|
19
|
+
| Hook wiring (Antigravity) | `.agents/hooks.json` or `~/.gemini/config/hooks.json` | Selected by `--client` / `--global` |
|
|
20
|
+
| Repo policy (optional) | `.burnoff.yaml` | Read-only policy overrides |
|
|
21
|
+
| Runtime breaker, read-clamp, snooze & pause state | `<repo>/.burnoff/` or `~/.burnoff/` | POSIX directories `0700`, files `0600`, atomic temp+rename writes |
|
|
22
|
+
| Warm local IPC daemon | Workspace-hashed named pipe (`\\.\pipe\burnoff-*` on Windows) or UDS (`0600` on POSIX) | Localhost/UID only, idle-reaped after 15m |
|
|
23
|
+
| Read-only transcript & config audits | `~/.claude/projects/**/*.jsonl`, `~/.gemini/antigravity/` | Opened read-only during `audit` and bare `burnoff` preview |
|
|
24
|
+
|
|
25
|
+
> During bare `npx burnoff` (or `burnoff preview`), Burnoff runs strictly read-only and writes **zero** files, index caches, or directories.
|
|
26
|
+
|
|
27
|
+
## Credential & Path Scrubbing
|
|
28
|
+
|
|
29
|
+
- `burnoff export` and `burnoff pr-cost` scrub user home directory paths before emitting JSON or markdown reports so local usernames and home paths do not leak into CI artifacts.
|
|
30
|
+
- `burnoff audit --startup` (`BO-CFG-*`) detects plaintext secrets committed to `.claude/settings.local.json` or MCP configurations and checks that `.claude/settings.local.json` is git-ignored.
|
|
31
|
+
|
|
32
|
+
## Reporting a Vulnerability
|
|
33
|
+
|
|
34
|
+
If you discover a Ring-0 bypass (e.g., an unhandled destructive shell command pattern or secret read vector) or another security issue:
|
|
35
|
+
|
|
36
|
+
1. **Do not** open a public issue with exploit payloads against live credentials.
|
|
37
|
+
2. Report privately via [GitHub Security Advisories](https://github.com/Gizzant/burnoff/security/advisories/new) on `Gizzant/burnoff`.
|
|
38
|
+
3. Include minimal reproduction steps (harness/OS, tool input payload, expected vs actual hook verdict).
|
package/bin/burnoff.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
-
import { spawn } from 'node:child_process';
|
|
9
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import {
|
|
12
12
|
suppressSqliteExperimentalWarning,
|
|
@@ -27,7 +27,7 @@ function getPackageVersion() {
|
|
|
27
27
|
} catch (err) {
|
|
28
28
|
void err; // ignore: package.json read fallback
|
|
29
29
|
}
|
|
30
|
-
return '1.
|
|
30
|
+
return '2.1.0';
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const BOOLEAN_FLAGS = new Set([
|
|
@@ -43,6 +43,7 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
43
43
|
'clear',
|
|
44
44
|
'foreground',
|
|
45
45
|
'skip-daemon',
|
|
46
|
+
'no-statusline',
|
|
46
47
|
'global',
|
|
47
48
|
'help',
|
|
48
49
|
'version'
|
|
@@ -53,6 +54,12 @@ function parseCliArgs(argv = []) {
|
|
|
53
54
|
const flags = {};
|
|
54
55
|
for (let i = 0; i < argv.length; i++) {
|
|
55
56
|
const arg = String(argv[i] ?? '');
|
|
57
|
+
if (arg === '--') {
|
|
58
|
+
const trailing = argv.slice(i + 1).map((a) => String(a ?? ''));
|
|
59
|
+
positionals.push(...trailing);
|
|
60
|
+
flags.__rest = trailing;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
56
63
|
if (!arg.startsWith('-')) {
|
|
57
64
|
positionals.push(arg);
|
|
58
65
|
continue;
|
|
@@ -101,15 +108,18 @@ function formatHelp() {
|
|
|
101
108
|
' burnoff <command> [options]',
|
|
102
109
|
'',
|
|
103
110
|
'Commands:',
|
|
104
|
-
'
|
|
111
|
+
' preview [--days 7] [--client auto|claude|antigravity|both] [--json] 3s read-only preview receipt (default)',
|
|
112
|
+
' init [--client claude|antigravity|both|auto] [--global] [--no-statusline] [--dry-run] [--cwd <dir>] Install Burnoff hooks & statusline',
|
|
105
113
|
' uninstall [--client claude|antigravity|both|auto] [--global] [--dry-run] [--cwd <dir>] Remove Burnoff hooks',
|
|
106
114
|
' doctor [--gc] [--json] Run Node/SQLite/hooks/daemon/FTS5/ledger diagnostics',
|
|
107
115
|
' audit [--startup [--ci] [--strict] [--github-annotations]] [--client auto|claude|antigravity|both] [--session <file>] [--otel <path>] [--json] Audit transcripts or Turn-0 config',
|
|
108
|
-
' allow-once [DET-01..DET-04,DET-07..DET-
|
|
109
|
-
' snooze [DET-01..DET-04,DET-07..DET-
|
|
110
|
-
'
|
|
111
|
-
'
|
|
112
|
-
'
|
|
116
|
+
' allow-once [DET-01..DET-04,DET-07..DET-10,DET-17|*] [--scope <substr>] [--minutes <N>] [--session <id>] [--client claude|antigravity|both|auto] [--list|--clear] Temporary ask-gate override',
|
|
117
|
+
' snooze [DET-01..DET-04,DET-07..DET-10,DET-17|*] [--minutes 15] [--scope <substr>] [--session <id>] [--client claude|antigravity|both|auto] [--list|--clear] Timed ask-gate snooze',
|
|
118
|
+
' pause [15m|1h|status|off] [--client claude|antigravity|both|auto] [--json] Soft-pause ask gates & read clamps (Ring-0 denies stay active)',
|
|
119
|
+
' bypass [--grant <substr> | --] <cmd...> Grant a 1-use DET-07 override or run a command outside hook read clamps',
|
|
120
|
+
' pr-cost [--base main] [--client auto|claude|antigravity|both] [--write-summary [file]] [--summary <file>] [--json|--markdown] Attribute branch commits to AI cost',
|
|
121
|
+
' export [--since <7d|ISO-date|sha>] [--base <ref>] [--format json|csv] [--out <file>] Export PR attribution for CI budget gate',
|
|
122
|
+
' ci-gate [--strict] [--summary <file>] [--github-annotations] Enforce .burnoff.yaml ciBudgetGate thresholds',
|
|
113
123
|
' team-digest [--days 7] [--json] Generate 5-line Engineering Manager spend & savings digest',
|
|
114
124
|
' search <turnId> [keyword] Query archived FTS5 tool outputs',
|
|
115
125
|
' daemon <start|stop|status> [--foreground] Manage warm workspace-scoped IPC daemon',
|
|
@@ -128,6 +138,7 @@ async function handleInit(flags, io) {
|
|
|
128
138
|
homeDir: flags.home || undefined,
|
|
129
139
|
client: typeof flags.client === 'string' ? flags.client : 'claude',
|
|
130
140
|
global: Boolean(flags.global),
|
|
141
|
+
noStatusline: Boolean(flags['no-statusline']),
|
|
131
142
|
dryRun: Boolean(flags['dry-run'])
|
|
132
143
|
});
|
|
133
144
|
if (flags.json) {
|
|
@@ -140,6 +151,7 @@ async function handleInit(flags, io) {
|
|
|
140
151
|
}
|
|
141
152
|
io.stdout.write(
|
|
142
153
|
`Burnoff hooks ${res.dryRun ? '[DRY RUN] ' : ''}installed in ${targets.join(' and ')}\n` +
|
|
154
|
+
(res.statusLineWired ? ' statusLine: wired (burnoff-statusline.mjs)\n' : '') +
|
|
143
155
|
(res.excludePath ? ` git exclude: ${res.excludePath}\n` : '') +
|
|
144
156
|
(Array.isArray(res.warnings) && res.warnings.length > 0
|
|
145
157
|
? res.warnings.map((w) => ` warning: ${w}\n`).join('')
|
|
@@ -238,41 +250,90 @@ async function handleAudit(flags, io) {
|
|
|
238
250
|
}
|
|
239
251
|
|
|
240
252
|
async function handlePrCost(flags, io) {
|
|
241
|
-
const { buildPrCostAttribution, formatPrAttributionMarkdown } = await import(
|
|
253
|
+
const { buildPrCostAttribution, formatPrAttributionMarkdown, writePrSummary } = await import(
|
|
254
|
+
'../src/ci/pr-cost.mjs'
|
|
255
|
+
);
|
|
256
|
+
const cwd = flags.cwd || process.cwd();
|
|
242
257
|
const report = buildPrCostAttribution({
|
|
243
|
-
cwd
|
|
258
|
+
cwd,
|
|
244
259
|
homeDir: flags.home || undefined,
|
|
245
260
|
client: typeof flags.client === 'string' ? flags.client : 'auto',
|
|
246
261
|
base: typeof flags.base === 'string' ? flags.base : 'main',
|
|
247
262
|
head: typeof flags.head === 'string' ? flags.head : 'HEAD',
|
|
248
|
-
|
|
263
|
+
wasteRatioBasis: typeof flags['waste-basis'] === 'string' ? flags['waste-basis'] : undefined,
|
|
264
|
+
providerUsagePath: typeof flags['provider-usage'] === 'string' ? flags['provider-usage'] : undefined,
|
|
265
|
+
summaryPath: typeof flags.summary === 'string' ? flags.summary : undefined
|
|
249
266
|
});
|
|
250
267
|
if (!report.ok) {
|
|
251
268
|
io.stderr.write(`Burnoff pr-cost error: ${report.error || 'failed'}\n`);
|
|
252
269
|
return 1;
|
|
253
270
|
}
|
|
271
|
+
|
|
272
|
+
let outputReport = report;
|
|
273
|
+
let writtenNote = '';
|
|
274
|
+
if (flags['write-summary']) {
|
|
275
|
+
const written = writePrSummary(report, {
|
|
276
|
+
cwd,
|
|
277
|
+
outPath: typeof flags['write-summary'] === 'string' ? flags['write-summary'] : undefined
|
|
278
|
+
});
|
|
279
|
+
if (!written.ok) {
|
|
280
|
+
io.stderr.write(`Burnoff pr-cost summary error: ${written.error || 'failed'}\n`);
|
|
281
|
+
return 1;
|
|
282
|
+
}
|
|
283
|
+
if (flags.json) {
|
|
284
|
+
outputReport = {
|
|
285
|
+
...report,
|
|
286
|
+
summaryWritten: {
|
|
287
|
+
format: written.format,
|
|
288
|
+
path: written.relativePath,
|
|
289
|
+
headSha: written.headSha,
|
|
290
|
+
digest: written.digest,
|
|
291
|
+
redactedCount: written.redactedCount
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
} else {
|
|
295
|
+
writtenNote = `\n> Exported zero-secret PR summary: \`${written.relativePath}\` (\`sha256:${written.digest.slice(0, 12)}\`)\n`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
254
299
|
const text = flags.json
|
|
255
|
-
? JSON.stringify(
|
|
256
|
-
: formatPrAttributionMarkdown(report);
|
|
300
|
+
? JSON.stringify(outputReport, null, 2) + '\n'
|
|
301
|
+
: formatPrAttributionMarkdown(report) + writtenNote;
|
|
257
302
|
writeOut(text, flags.out, io.stdout);
|
|
258
303
|
return 0;
|
|
259
304
|
}
|
|
260
305
|
|
|
261
306
|
async function handleExport(flags, io) {
|
|
262
|
-
const { buildPrCostAttribution } = await import('../src/ci/pr-cost.mjs');
|
|
307
|
+
const { buildPrCostAttribution, formatPrAttributionCsv } = await import('../src/ci/pr-cost.mjs');
|
|
308
|
+
const format = typeof flags.format === 'string' ? flags.format.trim().toLowerCase() : 'json';
|
|
309
|
+
if (format !== 'json' && format !== 'csv') {
|
|
310
|
+
io.stderr.write(`Burnoff export error: unsupported --format "${format}" (expected json or csv)\n`);
|
|
311
|
+
return 1;
|
|
312
|
+
}
|
|
313
|
+
for (const name of ['since', 'base']) {
|
|
314
|
+
if (flags[name] !== undefined && typeof flags[name] !== 'string') {
|
|
315
|
+
io.stderr.write(`Burnoff export error: --${name} requires a value\n`);
|
|
316
|
+
return 1;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const since = typeof flags.since === 'string' ? flags.since : undefined;
|
|
320
|
+
const base = typeof flags.base === 'string' ? flags.base : undefined;
|
|
263
321
|
const report = buildPrCostAttribution({
|
|
264
322
|
cwd: flags.cwd || process.cwd(),
|
|
265
323
|
homeDir: flags.home || undefined,
|
|
266
324
|
client: typeof flags.client === 'string' ? flags.client : 'auto',
|
|
267
|
-
base:
|
|
325
|
+
base: base || 'main',
|
|
326
|
+
since,
|
|
268
327
|
head: typeof flags.head === 'string' ? flags.head : 'HEAD',
|
|
328
|
+
// An explicit window or base must never silently fall back to the most recent 100 commits.
|
|
329
|
+
fallbackToRecent: !since && !base,
|
|
269
330
|
providerUsagePath: typeof flags['provider-usage'] === 'string' ? flags['provider-usage'] : undefined
|
|
270
331
|
});
|
|
271
332
|
if (!report.ok) {
|
|
272
333
|
io.stderr.write(`Burnoff export error: ${report.error || 'failed'}\n`);
|
|
273
334
|
return 1;
|
|
274
335
|
}
|
|
275
|
-
const text = JSON.stringify(report, null, 2) + '\n';
|
|
336
|
+
const text = format === 'csv' ? formatPrAttributionCsv(report) : JSON.stringify(report, null, 2) + '\n';
|
|
276
337
|
writeOut(text, flags.out, io.stdout);
|
|
277
338
|
return 0;
|
|
278
339
|
}
|
|
@@ -285,7 +346,11 @@ async function handleCiGate(flags, io) {
|
|
|
285
346
|
base: typeof flags.base === 'string' ? flags.base : 'main',
|
|
286
347
|
head: typeof flags.head === 'string' ? flags.head : 'HEAD',
|
|
287
348
|
inputPath: typeof flags.input === 'string' ? flags.input : undefined,
|
|
349
|
+
summaryPath: typeof flags.summary === 'string' ? flags.summary : undefined,
|
|
350
|
+
wasteRatioBasis: typeof flags['waste-basis'] === 'string' ? flags['waste-basis'] : undefined,
|
|
288
351
|
providerUsagePath: typeof flags['provider-usage'] === 'string' ? flags['provider-usage'] : undefined,
|
|
352
|
+
maxPrQuotaUnits: flags['max-pr-quota-units'] !== undefined ? Number(flags['max-pr-quota-units']) : undefined,
|
|
353
|
+
quotaGateMode: typeof flags['quota-gate-mode'] === 'string' ? flags['quota-gate-mode'] : undefined,
|
|
289
354
|
strict: Boolean(flags.strict)
|
|
290
355
|
});
|
|
291
356
|
if (result.verdict === 'ERROR') {
|
|
@@ -397,9 +462,13 @@ async function handleDaemon(positionals, flags, io) {
|
|
|
397
462
|
if (flags.json) {
|
|
398
463
|
io.stdout.write(JSON.stringify(statusObj, null, 2) + '\n');
|
|
399
464
|
} else {
|
|
465
|
+
const idleLabel =
|
|
466
|
+
Number(statusObj.idleTimeoutMs) > 0
|
|
467
|
+
? `, idleTtl=${Math.round(Number(statusObj.idleTimeoutMs) / 60000)}m`
|
|
468
|
+
: '';
|
|
400
469
|
io.stdout.write(
|
|
401
470
|
statusObj.running
|
|
402
|
-
? `Burnoff daemon running (pid=${statusObj.pid}, ipc=${statusObj.ipcPath}, requests=${statusObj.requestCount})\n`
|
|
471
|
+
? `Burnoff daemon running (pid=${statusObj.pid}, ipc=${statusObj.ipcPath}, requests=${statusObj.requestCount}${idleLabel})\n`
|
|
403
472
|
: `Burnoff daemon stopped (ipc=${ipcPath})\n`
|
|
404
473
|
);
|
|
405
474
|
}
|
|
@@ -423,9 +492,14 @@ async function handleDaemon(positionals, flags, io) {
|
|
|
423
492
|
return 0;
|
|
424
493
|
}
|
|
425
494
|
|
|
495
|
+
const idleTimeoutMs =
|
|
496
|
+
flags['idle-ms'] !== undefined && Number.isFinite(Number(flags['idle-ms']))
|
|
497
|
+
? Math.max(0, Number(flags['idle-ms']))
|
|
498
|
+
: undefined;
|
|
499
|
+
|
|
426
500
|
if (flags.foreground) {
|
|
427
501
|
const { BurnoffDaemon } = await import('../src/ipc/daemon.mjs');
|
|
428
|
-
const daemon = new BurnoffDaemon({ cwd, homeDir, ipcPath });
|
|
502
|
+
const daemon = new BurnoffDaemon({ cwd, homeDir, ipcPath, ...(idleTimeoutMs !== undefined ? { idleTimeoutMs } : {}) });
|
|
429
503
|
await daemon.listen();
|
|
430
504
|
io.stdout.write(`Burnoff daemon listening on ${daemon.ipcPath} (pid=${process.pid})\n`);
|
|
431
505
|
await new Promise((resolve) => {
|
|
@@ -439,6 +513,7 @@ async function handleDaemon(positionals, flags, io) {
|
|
|
439
513
|
const cliEntry = path.join(PACKAGE_ROOT, 'bin', 'burnoff.mjs');
|
|
440
514
|
const spawnArgs = [cliEntry, 'daemon', 'start', '--foreground', '--cwd', cwd, '--ipc', ipcPath];
|
|
441
515
|
if (homeDir) spawnArgs.push('--home', homeDir);
|
|
516
|
+
if (idleTimeoutMs !== undefined) spawnArgs.push('--idle-ms', String(idleTimeoutMs));
|
|
442
517
|
const child = spawn(
|
|
443
518
|
process.execPath,
|
|
444
519
|
spawnArgs,
|
|
@@ -472,6 +547,7 @@ async function handleAllowOnce(cmd, positionals, flags, io) {
|
|
|
472
547
|
grantAskSnoozeAtomicSync,
|
|
473
548
|
listActiveSnoozes,
|
|
474
549
|
clearAskSnoozesAtomicSync,
|
|
550
|
+
resolveSnoozeTargetClients,
|
|
475
551
|
DEFAULT_ALLOW_ONCE_TTL_MS,
|
|
476
552
|
DEFAULT_SNOOZE_TTL_MS
|
|
477
553
|
} = await import('../src/guards/snooze.mjs');
|
|
@@ -479,21 +555,28 @@ async function handleAllowOnce(cmd, positionals, flags, io) {
|
|
|
479
555
|
const cwd = path.resolve(flags.cwd || process.cwd());
|
|
480
556
|
const homeDir = flags.home || undefined;
|
|
481
557
|
const sessionId = typeof flags.session === 'string' && flags.session.trim() ? flags.session.trim() : null;
|
|
482
|
-
|
|
483
|
-
const
|
|
484
|
-
|
|
558
|
+
// Default (auto) writes to every Burnoff-wired client so the active harness always sees the override.
|
|
559
|
+
const targetClients = resolveSnoozeTargetClients(
|
|
560
|
+
typeof flags.client === 'string' ? flags.client : 'auto',
|
|
561
|
+
{ cwd, homeDir }
|
|
562
|
+
);
|
|
563
|
+
const storeOptsFor = (client) => ({ cwd, homeDir, client });
|
|
485
564
|
|
|
486
565
|
const rawDetArg = positionals[1];
|
|
487
566
|
const detectorId = normalizeSnoozeDetectorId(rawDetArg === undefined ? '*' : rawDetArg);
|
|
488
567
|
if (!detectorId) {
|
|
489
|
-
io.stderr.write(`Invalid detector ID "${rawDetArg}". Expected DET-01..DET-04, DET-07..DET-
|
|
568
|
+
io.stderr.write(`Invalid detector ID "${rawDetArg}". Expected DET-01..DET-04, DET-07..DET-10, DET-17, all, or *.\n`);
|
|
490
569
|
return 1;
|
|
491
570
|
}
|
|
492
571
|
|
|
493
572
|
if (flags.list) {
|
|
494
|
-
const entries =
|
|
573
|
+
const entries = targetClients.flatMap((client) =>
|
|
574
|
+
listActiveSnoozes({ sessionId }, storeOptsFor(client)).map((e) => ({ ...e, client }))
|
|
575
|
+
);
|
|
495
576
|
if (flags.json) {
|
|
496
|
-
io.stdout.write(
|
|
577
|
+
io.stdout.write(
|
|
578
|
+
JSON.stringify({ ok: true, count: entries.length, clients: targetClients, snoozes: entries }, null, 2) + '\n'
|
|
579
|
+
);
|
|
497
580
|
} else if (entries.length === 0) {
|
|
498
581
|
io.stdout.write('No active Burnoff ask-gate snoozes.\n');
|
|
499
582
|
} else {
|
|
@@ -508,10 +591,14 @@ async function handleAllowOnce(cmd, positionals, flags, io) {
|
|
|
508
591
|
}
|
|
509
592
|
|
|
510
593
|
if (flags.clear) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
594
|
+
let clearedCount = 0;
|
|
595
|
+
for (const client of targetClients) {
|
|
596
|
+
clearedCount += clearAskSnoozesAtomicSync(
|
|
597
|
+
{ sessionId, detectorId: rawDetArg !== undefined ? detectorId : null },
|
|
598
|
+
storeOptsFor(client)
|
|
599
|
+
).clearedCount;
|
|
600
|
+
}
|
|
601
|
+
const res = { ok: true, clearedCount, ...(targetClients.length > 1 ? { clients: targetClients } : {}) };
|
|
515
602
|
if (flags.json) {
|
|
516
603
|
io.stdout.write(JSON.stringify(res, null, 2) + '\n');
|
|
517
604
|
} else {
|
|
@@ -537,10 +624,13 @@ async function handleAllowOnce(cmd, positionals, flags, io) {
|
|
|
537
624
|
const scope = typeof flags.scope === 'string' && flags.scope.trim() ? flags.scope.trim() : '*';
|
|
538
625
|
const reason = typeof flags.reason === 'string' ? flags.reason : '';
|
|
539
626
|
|
|
540
|
-
const
|
|
541
|
-
{ sessionId, detectorId, scope, count, ttlMs, reason },
|
|
542
|
-
storeOpts
|
|
627
|
+
const grants = targetClients.map((client) =>
|
|
628
|
+
grantAskSnoozeAtomicSync({ sessionId, detectorId, scope, count, ttlMs, reason }, storeOptsFor(client))
|
|
543
629
|
);
|
|
630
|
+
const res =
|
|
631
|
+
grants.length === 1
|
|
632
|
+
? grants[0]
|
|
633
|
+
: { ...grants[0], clients: targetClients, paths: grants.map((g) => g.path), grants: grants.map((g) => g.grant) };
|
|
544
634
|
if (flags.json) {
|
|
545
635
|
io.stdout.write(JSON.stringify(res, null, 2) + '\n');
|
|
546
636
|
} else {
|
|
@@ -552,6 +642,183 @@ async function handleAllowOnce(cmd, positionals, flags, io) {
|
|
|
552
642
|
return 0;
|
|
553
643
|
}
|
|
554
644
|
|
|
645
|
+
async function handlePause(positionals, flags, io) {
|
|
646
|
+
const {
|
|
647
|
+
parseDurationMs,
|
|
648
|
+
setWorkspacePauseAtomicSync,
|
|
649
|
+
getWorkspacePauseStatus,
|
|
650
|
+
clearWorkspacePauseAtomicSync,
|
|
651
|
+
resolveSnoozeTargetClients
|
|
652
|
+
} = await import('../src/guards/snooze.mjs');
|
|
653
|
+
|
|
654
|
+
const cwd = path.resolve(flags.cwd || process.cwd());
|
|
655
|
+
const homeDir = flags.home || undefined;
|
|
656
|
+
const targetClients = resolveSnoozeTargetClients(
|
|
657
|
+
typeof flags.client === 'string' ? flags.client : 'auto',
|
|
658
|
+
{ cwd, homeDir }
|
|
659
|
+
);
|
|
660
|
+
const storeOptsFor = (client) => ({ cwd, homeDir, client });
|
|
661
|
+
const rawArg = String(positionals[1] ?? '').trim().toLowerCase();
|
|
662
|
+
|
|
663
|
+
if (flags.clear || rawArg === 'off' || rawArg === 'resume' || rawArg === 'clear') {
|
|
664
|
+
const results = targetClients.map((client) => ({
|
|
665
|
+
client,
|
|
666
|
+
...clearWorkspacePauseAtomicSync(storeOptsFor(client))
|
|
667
|
+
}));
|
|
668
|
+
const clearedAny = results.some((r) => r.cleared);
|
|
669
|
+
const payload = { ok: true, active: false, cleared: clearedAny, clients: targetClients, results };
|
|
670
|
+
if (flags.json) {
|
|
671
|
+
io.stdout.write(JSON.stringify(payload, null, 2) + '\n');
|
|
672
|
+
} else {
|
|
673
|
+
io.stdout.write(
|
|
674
|
+
clearedAny
|
|
675
|
+
? `Burnoff soft pause cleared (${targetClients.join(', ')}).\n`
|
|
676
|
+
: 'No active Burnoff soft pause.\n'
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
return 0;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (rawArg === 'status') {
|
|
683
|
+
const statuses = targetClients.map((client) => ({
|
|
684
|
+
client,
|
|
685
|
+
...getWorkspacePauseStatus({}, storeOptsFor(client))
|
|
686
|
+
}));
|
|
687
|
+
const activeEntry = statuses.find((s) => s.active) || statuses[0];
|
|
688
|
+
if (flags.json) {
|
|
689
|
+
io.stdout.write(
|
|
690
|
+
JSON.stringify({ ok: true, active: Boolean(activeEntry?.active), statuses }, null, 2) + '\n'
|
|
691
|
+
);
|
|
692
|
+
} else if (activeEntry?.active) {
|
|
693
|
+
const remMins = Math.max(1, Math.ceil((activeEntry.remainingMs || 0) / 60_000));
|
|
694
|
+
io.stdout.write(
|
|
695
|
+
`Burnoff soft-paused (${remMins}m remaining, expires=${new Date(activeEntry.expiresAtMs).toISOString()}; Ring-0 blocks remain active).\n`
|
|
696
|
+
);
|
|
697
|
+
} else {
|
|
698
|
+
io.stdout.write('Burnoff pause status: active protection (not paused).\n');
|
|
699
|
+
}
|
|
700
|
+
return 0;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const durationInput = rawArg || (flags.minutes !== undefined ? Number(flags.minutes) : '15m');
|
|
704
|
+
const durationMs = parseDurationMs(durationInput);
|
|
705
|
+
if (!durationMs) {
|
|
706
|
+
io.stderr.write(
|
|
707
|
+
`Invalid pause argument "${positionals[1]}". Expected duration (e.g. 15m, 1h), "status", or "off".\n`
|
|
708
|
+
);
|
|
709
|
+
return 1;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const reason = typeof flags.reason === 'string' ? flags.reason : '';
|
|
713
|
+
const grants = targetClients.map((client) => ({
|
|
714
|
+
client,
|
|
715
|
+
...setWorkspacePauseAtomicSync({ durationMs, reason }, storeOptsFor(client))
|
|
716
|
+
}));
|
|
717
|
+
const first = grants[0];
|
|
718
|
+
const payload = {
|
|
719
|
+
ok: true,
|
|
720
|
+
active: true,
|
|
721
|
+
durationMs,
|
|
722
|
+
expiresAtMs: first.pause.expiresAtMs,
|
|
723
|
+
clients: targetClients,
|
|
724
|
+
grants
|
|
725
|
+
};
|
|
726
|
+
if (flags.json) {
|
|
727
|
+
io.stdout.write(JSON.stringify(payload, null, 2) + '\n');
|
|
728
|
+
} else {
|
|
729
|
+
const mins = Math.max(1, Math.round(durationMs / 60_000));
|
|
730
|
+
io.stdout.write(
|
|
731
|
+
`Burnoff soft-paused for ${mins}m (expires=${new Date(first.pause.expiresAtMs).toISOString()}; Ring-0 DET-01/DET-02/DET-20 hard blocks remain active).\n`
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
return 0;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
async function handleBypass(positionals, flags, io) {
|
|
738
|
+
const cwd = path.resolve(flags.cwd || process.cwd());
|
|
739
|
+
const homeDir = flags.home || undefined;
|
|
740
|
+
|
|
741
|
+
if (typeof flags.grant === 'string' && flags.grant.trim()) {
|
|
742
|
+
const {
|
|
743
|
+
grantAskSnoozeAtomicSync,
|
|
744
|
+
resolveSnoozeTargetClients,
|
|
745
|
+
DEFAULT_ALLOW_ONCE_TTL_MS
|
|
746
|
+
} = await import('../src/guards/snooze.mjs');
|
|
747
|
+
const sessionId = typeof flags.session === 'string' && flags.session.trim() ? flags.session.trim() : null;
|
|
748
|
+
const scope = flags.grant.trim();
|
|
749
|
+
const targetClients = resolveSnoozeTargetClients(
|
|
750
|
+
typeof flags.client === 'string' ? flags.client : 'auto',
|
|
751
|
+
{ cwd, homeDir }
|
|
752
|
+
);
|
|
753
|
+
const grants = targetClients.map((client) =>
|
|
754
|
+
grantAskSnoozeAtomicSync(
|
|
755
|
+
{
|
|
756
|
+
sessionId,
|
|
757
|
+
detectorId: 'DET-07',
|
|
758
|
+
scope,
|
|
759
|
+
count: 1,
|
|
760
|
+
ttlMs: DEFAULT_ALLOW_ONCE_TTL_MS,
|
|
761
|
+
reason: typeof flags.reason === 'string' && flags.reason ? flags.reason : 'CLI bypass --grant'
|
|
762
|
+
},
|
|
763
|
+
{ cwd, homeDir, client }
|
|
764
|
+
)
|
|
765
|
+
);
|
|
766
|
+
const res =
|
|
767
|
+
grants.length === 1
|
|
768
|
+
? grants[0]
|
|
769
|
+
: { ...grants[0], clients: targetClients, grants: grants.map((g) => g.grant) };
|
|
770
|
+
if (flags.json) {
|
|
771
|
+
io.stdout.write(JSON.stringify(res, null, 2) + '\n');
|
|
772
|
+
} else {
|
|
773
|
+
io.stdout.write(
|
|
774
|
+
`Granted 1-use DET-07 bypass (scope="${res.grant.scope}", expires=${new Date(res.grant.expiresAtMs).toISOString()}).\n`
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
return 0;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const cmdArgs = Array.isArray(flags.__rest) && flags.__rest.length > 0
|
|
781
|
+
? flags.__rest
|
|
782
|
+
: positionals.slice(1);
|
|
783
|
+
if (cmdArgs.length === 0) {
|
|
784
|
+
io.stderr.write('Usage: burnoff bypass [--grant <substr> | -- <cmd...>]\n');
|
|
785
|
+
return 1;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
io.stderr.write(
|
|
789
|
+
`[Burnoff bypass] Running directly outside hook read clamps: ${cmdArgs.join(' ')}\n`
|
|
790
|
+
);
|
|
791
|
+
const run = spawnSync(cmdArgs[0], cmdArgs.slice(1), {
|
|
792
|
+
cwd,
|
|
793
|
+
encoding: 'utf8',
|
|
794
|
+
windowsHide: true
|
|
795
|
+
});
|
|
796
|
+
if (run.stdout) io.stdout.write(run.stdout);
|
|
797
|
+
if (run.stderr) io.stderr.write(run.stderr);
|
|
798
|
+
if (run.error) {
|
|
799
|
+
io.stderr.write(`Burnoff bypass execution failed: ${run.error.message}\n`);
|
|
800
|
+
return 1;
|
|
801
|
+
}
|
|
802
|
+
return Number.isInteger(run.status) ? run.status : 1;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
async function handlePreview(flags, io) {
|
|
806
|
+
const { runQuickPreview, formatPreviewReceipt } = await import('../src/cli/preview.mjs');
|
|
807
|
+
const report = runQuickPreview({
|
|
808
|
+
cwd: flags.cwd || process.cwd(),
|
|
809
|
+
homeDir: flags.home || undefined,
|
|
810
|
+
days: Number(flags.days || 7),
|
|
811
|
+
maxFiles: Number(flags.limit || 10),
|
|
812
|
+
client: flags.client || 'auto'
|
|
813
|
+
});
|
|
814
|
+
if (flags.json) {
|
|
815
|
+
io.stdout.write(JSON.stringify(report, null, 2) + '\n');
|
|
816
|
+
} else {
|
|
817
|
+
io.stdout.write(formatPreviewReceipt(report));
|
|
818
|
+
}
|
|
819
|
+
return 0;
|
|
820
|
+
}
|
|
821
|
+
|
|
555
822
|
/**
|
|
556
823
|
* Dispatches Burnoff CLI commands and returns an exit code.
|
|
557
824
|
*/
|
|
@@ -563,7 +830,7 @@ export async function runCli(argv = process.argv.slice(2), io = { stdout: proces
|
|
|
563
830
|
io.stdout.write(`${getPackageVersion()}\n`);
|
|
564
831
|
return 0;
|
|
565
832
|
}
|
|
566
|
-
if (
|
|
833
|
+
if (flags.help || cmd === 'help') {
|
|
567
834
|
io.stdout.write(formatHelp());
|
|
568
835
|
return 0;
|
|
569
836
|
}
|
|
@@ -577,6 +844,10 @@ export async function runCli(argv = process.argv.slice(2), io = { stdout: proces
|
|
|
577
844
|
return 1;
|
|
578
845
|
}
|
|
579
846
|
|
|
847
|
+
if (!cmd || cmd === 'preview') {
|
|
848
|
+
return handlePreview(flags, io);
|
|
849
|
+
}
|
|
850
|
+
|
|
580
851
|
switch (cmd) {
|
|
581
852
|
case 'init':
|
|
582
853
|
return handleInit(flags, io);
|
|
@@ -589,6 +860,10 @@ export async function runCli(argv = process.argv.slice(2), io = { stdout: proces
|
|
|
589
860
|
case 'allow-once':
|
|
590
861
|
case 'snooze':
|
|
591
862
|
return handleAllowOnce(cmd, positionals, flags, io);
|
|
863
|
+
case 'pause':
|
|
864
|
+
return handlePause(positionals, flags, io);
|
|
865
|
+
case 'bypass':
|
|
866
|
+
return handleBypass(positionals, flags, io);
|
|
592
867
|
case 'pr-cost':
|
|
593
868
|
return handlePrCost(flags, io);
|
|
594
869
|
case 'export':
|
package/commands/burnoff.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Run Burnoff diagnostics, Turn-0 startup audits,
|
|
3
|
-
argument-hint: "[doctor|audit|startup|allow-once <DET-xx>|snooze <DET-xx>|pr-cost|team-digest|init]"
|
|
2
|
+
description: Run Burnoff diagnostics, Turn-0 startup audits, pause/bypass overrides, or PR spend digests
|
|
3
|
+
argument-hint: "[doctor|audit|startup|allow-once <DET-xx>|snooze <DET-xx>|pause [15m|1h|status|off]|bypass [--grant <substr>|-- <cmd>]|pr-cost|team-digest|init]"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Run Burnoff (`npx -y burnoff@1.
|
|
6
|
+
Run Burnoff (`npx -y burnoff@2.1.0` or local `node bin/burnoff.mjs` when developing in the Burnoff repo) according to `$ARGUMENTS`:
|
|
7
7
|
|
|
8
8
|
- Empty arguments: run `burnoff doctor` and `burnoff team-digest --days 7` and summarize findings clearly.
|
|
9
9
|
- `doctor`: run `burnoff doctor` to verify Node/SQLite FTS5, hooks, and warm daemon health.
|
|
10
10
|
- `startup` or `audit --startup`: run `burnoff audit --startup --ci` for repo-local Turn-0 rule, secret, and MCP linting (or drop `--ci` to include local machine config).
|
|
11
11
|
- `audit`: run `burnoff audit --limit 10` across recent local transcripts.
|
|
12
|
-
- `allow-once ...` or `snooze ...`: run `burnoff $ARGUMENTS` to grant/list/clear temporary overrides for interactive `ask` gates (`DET-01`..`DET-04`, `DET-07`..`DET-
|
|
12
|
+
- `allow-once ...` or `snooze ...`: run `burnoff $ARGUMENTS` to grant/list/clear temporary overrides for interactive `ask` gates (`DET-01`..`DET-04`, `DET-07`..`DET-10`, `DET-17`; add `--client claude|antigravity|both|auto` to target a harness; never bypasses `deny` hard blocks).
|
|
13
|
+
- `pause [15m|1h|status|off]`: temporarily soft-pause non-Ring-0 `ask` gates, read clamps, and coaches for the workspace while keeping Ring-0 `deny` / `exitCode: 2` blocks (`DET-01`, `DET-02`, `DET-20`) active.
|
|
14
|
+
- `bypass [--grant <substr> | -- <cmd...>]`: grant a 1-use `DET-07` override or execute a command directly outside hook read clamps.
|
|
13
15
|
- `pr-cost` or `team-digest`: run `burnoff $ARGUMENTS` to inspect AI branch cost attribution or 7-day savings telemetry.
|
|
14
16
|
- `init`: run `burnoff init --client claude` to install/refresh `.claude/settings.local.json` hooks deterministically.
|
|
15
17
|
|