burnoff 1.2.0 → 1.4.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 +11 -0
- package/.github/workflows/burnoff-pr-gate.yml +3 -3
- package/.github/workflows/burnoff-startup-lint.yml +37 -0
- package/README.md +47 -6
- package/bin/burnoff.mjs +123 -5
- package/commands/burnoff.md +16 -0
- package/docs/CLAUDE_CODE_PLUGIN.md +67 -0
- package/docs/DESIGN_PARTNER_INTAKE.md +44 -0
- package/package.json +10 -4
- package/scripts/burnoff-statusline.mjs +104 -0
- package/src/cli/audit.mjs +82 -4
- package/src/cli/startup-audit.mjs +390 -71
- package/src/config/policy.mjs +13 -1
- package/src/guards/loop-breaker.mjs +49 -0
- package/src/guards/phase5-detectors.mjs +727 -0
- package/src/guards/pre-tool-engine.mjs +222 -66
- package/src/guards/snooze.mjs +363 -0
- package/src/storage/antigravity-parser.mjs +18 -1
- package/src/storage/jsonl-parser.mjs +29 -1
- package/src/storage/telemetry-metrics.mjs +703 -0
package/src/cli/audit.mjs
CHANGED
|
@@ -20,6 +20,14 @@ import {
|
|
|
20
20
|
import { getSavedQuotaReceiptSummary } from '../storage/ledger.mjs';
|
|
21
21
|
import { attributeUncachedTokens } from '../config/uncached-attribution.mjs';
|
|
22
22
|
import { valuateBatch } from '../config/pricing.mjs';
|
|
23
|
+
import {
|
|
24
|
+
discoverAntigravityConversationDbs,
|
|
25
|
+
readAntigravityConversationDbMetrics,
|
|
26
|
+
discoverLocalOtelFiles,
|
|
27
|
+
parseOtelGenAiSpans,
|
|
28
|
+
extractStepTimingMetrics,
|
|
29
|
+
aggregateTelemetryMetrics
|
|
30
|
+
} from '../storage/telemetry-metrics.mjs';
|
|
23
31
|
|
|
24
32
|
function summarizeParsedSession(meta, parsed, options = {}) {
|
|
25
33
|
const steps = Array.isArray(parsed?.steps) ? parsed.steps : [];
|
|
@@ -111,6 +119,8 @@ function summarizeParsedSession(meta, parsed, options = {}) {
|
|
|
111
119
|
const uncachedAttribution = attributeUncachedTokens(attributionCalls, {
|
|
112
120
|
claudeCodeVersion: options.claudeCodeVersion || null
|
|
113
121
|
});
|
|
122
|
+
const stepTimings = steps.map(extractStepTimingMetrics);
|
|
123
|
+
const sessionTelemetry = aggregateTelemetryMetrics({ stepTimings });
|
|
114
124
|
|
|
115
125
|
return {
|
|
116
126
|
sessionId,
|
|
@@ -134,6 +144,13 @@ function summarizeParsedSession(meta, parsed, options = {}) {
|
|
|
134
144
|
: 0,
|
|
135
145
|
entrypoint,
|
|
136
146
|
mtimeMs: meta.mtimeMs || 0,
|
|
147
|
+
telemetry: {
|
|
148
|
+
ttftSampleCount: sessionTelemetry.ttftSampleCount,
|
|
149
|
+
tpsSampleCount: sessionTelemetry.tpsSampleCount,
|
|
150
|
+
medianTtftMs: sessionTelemetry.medianTtftMs,
|
|
151
|
+
medianTokensPerSec: sessionTelemetry.medianTokensPerSec
|
|
152
|
+
},
|
|
153
|
+
_stepTimings: stepTimings,
|
|
137
154
|
attributionCalls,
|
|
138
155
|
uncachedAttribution
|
|
139
156
|
};
|
|
@@ -148,6 +165,9 @@ export function auditClaudeSessions(options = {}) {
|
|
|
148
165
|
: null;
|
|
149
166
|
const homeDir = explicitHomeDir || getHomeDir();
|
|
150
167
|
const limit = Math.max(1, Number(options.limit ?? 20));
|
|
168
|
+
const clientOpt = String(options.client || 'auto').trim().toLowerCase();
|
|
169
|
+
const includeAg =
|
|
170
|
+
clientOpt === 'antigravity' || clientOpt === 'ag' || clientOpt === 'both' || clientOpt === 'auto';
|
|
151
171
|
let candidates;
|
|
152
172
|
if (options.sessionPath) {
|
|
153
173
|
const abs = path.resolve(options.sessionPath);
|
|
@@ -162,10 +182,7 @@ export function auditClaudeSessions(options = {}) {
|
|
|
162
182
|
}
|
|
163
183
|
];
|
|
164
184
|
} else {
|
|
165
|
-
const clientOpt = String(options.client || 'auto').trim().toLowerCase();
|
|
166
185
|
const includeClaude = clientOpt !== 'antigravity' && clientOpt !== 'ag';
|
|
167
|
-
const includeAg =
|
|
168
|
-
clientOpt === 'antigravity' || clientOpt === 'ag' || clientOpt === 'both' || clientOpt === 'auto';
|
|
169
186
|
const claudeList = includeClaude ? discoverClaudeCodeSessions(homeDir, options) : [];
|
|
170
187
|
const agList = includeAg ? discoverAntigravityTranscripts({ homeDir, cwd: options.cwd }) : [];
|
|
171
188
|
candidates = [...claudeList, ...agList]
|
|
@@ -232,11 +249,53 @@ export function auditClaudeSessions(options = {}) {
|
|
|
232
249
|
const uncachedAttribution = attributeUncachedTokens(allAttributionCalls, {
|
|
233
250
|
claudeCodeVersion: options.claudeCodeVersion || null
|
|
234
251
|
});
|
|
235
|
-
|
|
252
|
+
|
|
253
|
+
const otelFiles =
|
|
254
|
+
options.otelPath || !options.sessionPath
|
|
255
|
+
? discoverLocalOtelFiles({ homeDir, otelPath: options.otelPath || null })
|
|
256
|
+
: [];
|
|
257
|
+
const otelSpans = [];
|
|
258
|
+
for (const otelFile of otelFiles) {
|
|
259
|
+
otelSpans.push(...parseOtelGenAiSpans(otelFile).spans);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let dbPaths = [];
|
|
263
|
+
if (Array.isArray(options.antigravityDbPath)) {
|
|
264
|
+
dbPaths = options.antigravityDbPath.filter(Boolean);
|
|
265
|
+
} else if (typeof options.antigravityDbPath === 'string' && options.antigravityDbPath.trim()) {
|
|
266
|
+
dbPaths = [options.antigravityDbPath.trim()];
|
|
267
|
+
} else if (options.antigravityDbDir || (includeAg && !options.sessionPath)) {
|
|
268
|
+
dbPaths = discoverAntigravityConversationDbs({
|
|
269
|
+
homeDir,
|
|
270
|
+
conversationDirs: options.antigravityDbDir ? [options.antigravityDbDir] : null,
|
|
271
|
+
maxDbs: Math.min(limit, 50)
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
const antigravityDbSteps = [];
|
|
275
|
+
let antigravityDbsScanned = 0;
|
|
276
|
+
for (const dbPath of dbPaths) {
|
|
277
|
+
const dbRes = readAntigravityConversationDbMetrics(dbPath);
|
|
278
|
+
if (dbRes.ok) {
|
|
279
|
+
antigravityDbsScanned += 1;
|
|
280
|
+
antigravityDbSteps.push(...dbRes.steps);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const allStepTimings = sessions.flatMap((s) => s._stepTimings || []);
|
|
285
|
+
const telemetry = aggregateTelemetryMetrics({
|
|
286
|
+
stepTimings: allStepTimings,
|
|
287
|
+
otelSpans,
|
|
288
|
+
antigravityDbSteps,
|
|
289
|
+
otelFilesScanned: otelFiles.length,
|
|
290
|
+
antigravityDbsScanned
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
const cleanSessions = sessions.map(({ attributionCalls: _calls, _stepTimings: _timings, ...rest }) => rest);
|
|
236
294
|
|
|
237
295
|
return {
|
|
238
296
|
ok: true,
|
|
239
297
|
totals,
|
|
298
|
+
telemetry,
|
|
240
299
|
valuation,
|
|
241
300
|
uncachedAttribution,
|
|
242
301
|
ledger: {
|
|
@@ -263,6 +322,25 @@ export function formatAuditReport(report = {}) {
|
|
|
263
322
|
` Estimated Cost : $${Number(t.estimatedCostUsd || 0).toFixed(4)} | 200k-cliff turns=${t.cliffTurns ?? 0} | rewind branches=${t.rewindBranches ?? 0}${quotaTag}`,
|
|
264
323
|
` Guard Savings : $${Number(report.ledger?.avoidedWriteUSD || 0).toFixed(4)} avoided (${(report.ledger?.avoidedWriteTokens || 0).toLocaleString('en-US')} tok)`
|
|
265
324
|
];
|
|
325
|
+
const perf = report.telemetry;
|
|
326
|
+
if (perf) {
|
|
327
|
+
const perfParts = [];
|
|
328
|
+
if (perf.medianTtftMs !== null && perf.medianTtftMs !== undefined) {
|
|
329
|
+
const label = perf.medianTtftMs >= 1000
|
|
330
|
+
? `${(perf.medianTtftMs / 1000).toFixed(2)}s`
|
|
331
|
+
: `${Math.round(perf.medianTtftMs)}ms`;
|
|
332
|
+
perfParts.push(`TTFT p50=${label}`);
|
|
333
|
+
}
|
|
334
|
+
if (perf.medianTokensPerSec !== null && perf.medianTokensPerSec !== undefined) {
|
|
335
|
+
perfParts.push(`${perf.medianTokensPerSec.toFixed(1)} tok/s (p50)`);
|
|
336
|
+
}
|
|
337
|
+
if (Number(perf.otel?.spanCount || 0) > 0) {
|
|
338
|
+
perfParts.push(`OTel gen_ai spans=${perf.otel.spanCount}`);
|
|
339
|
+
}
|
|
340
|
+
if (perfParts.length > 0) {
|
|
341
|
+
lines.push(` Performance : ${perfParts.join(' | ')}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
266
344
|
if (t.sdkCliSessions > 0 || t.sdkCliHeuristicApplied) {
|
|
267
345
|
lines.push(
|
|
268
346
|
` Quota Heuristic: headless sdk-cli (claude -p) observed in ${t.sdkCliSessions || 1} session(s) (~1.8x 5h quota burn heuristic per #97074; observational estimate, not a guaranteed constant).`
|