@agentguard-run/burn 0.5.1 → 0.6.1
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/CHANGELOG.md +16 -0
- package/README.md +78 -1
- package/dist/src/cli.js +150 -4
- package/dist/src/display-mode.d.ts +12 -0
- package/dist/src/display-mode.js +67 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +12 -1
- package/dist/src/insights/compact-replay.d.ts +97 -0
- package/dist/src/insights/compact-replay.js +414 -0
- package/dist/src/insights/compact-settings.d.ts +30 -0
- package/dist/src/insights/compact-settings.js +122 -0
- package/dist/src/insights/i18n.d.ts +19 -0
- package/dist/src/insights/i18n.js +82 -1
- package/dist/src/insights/render.d.ts +13 -1
- package/dist/src/insights/render.js +32 -19
- package/dist/src/insights/simple-data.d.ts +20 -0
- package/dist/src/insights/simple-data.js +229 -0
- package/dist/src/insights/simple-render.d.ts +26 -0
- package/dist/src/insights/simple-render.js +92 -0
- package/dist/src/insights/simple-text.d.ts +33 -0
- package/dist/src/insights/simple-text.js +44 -0
- package/dist/src/insights/status-fields.d.ts +7 -2
- package/dist/src/insights/status-fields.js +18 -1
- package/dist/src/insights/status-text.d.ts +18 -0
- package/dist/src/insights/status-text.js +6 -0
- package/dist/src/insights/week-render.d.ts +4 -0
- package/dist/src/insights/week-render.js +31 -0
- package/dist/src/insights/week.d.ts +75 -0
- package/dist/src/insights/week.js +253 -0
- package/dist/src/live-panel.d.ts +2 -1
- package/dist/src/live-panel.js +29 -2
- package/docs/OCT5_VERIFICATION.md +1 -1
- package/docs/simple-views.md +17 -0
- package/fixtures/burn-week-v1.json +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.6.1 (2026-10-18)
|
|
6
|
+
|
|
7
|
+
- `formatStatusFields` takes an optional `context` (`{tokens, threshold}`) and adds "28% to auto-compact" after the token figure (yellow at 30% of context left, red at 10%; the colour follows the number shown), plus the panel line "Context: 720,000 of 1,000,000 tokens, 28% left before Claude Code compacts the conversation.", in English, Spanish and Portuguese. Hidden without a threshold. The AgentGuard plugin's band supplies the figures; `statusline` has no compaction point to read and is unchanged.
|
|
8
|
+
- Past the session token limit the shared status text says "tokens 24B, past the 5B limit" (with "sub-agents wait for your yes" outside shadow mode) instead of the impossible "24B of 5B". The short forms for narrow widths say "past 5B".
|
|
9
|
+
## 0.6.0 (2026-10-10)
|
|
10
|
+
|
|
11
|
+
A simple view by default and a compaction replay, so the first screen answers "how much is left and what do I change".
|
|
12
|
+
|
|
13
|
+
- The `agentguard-burn` wrapper (0.6.0) requires `@agentguard-run/burn` ^0.6.0, so `npx agentguard-burn` gets this release.
|
|
14
|
+
- Add simple and detailed display modes for statusline, why, live and compact-replay, with a saved local preference, an environment override and per-command overrides. Simple mode is the default for statusline, why and live (compact-replay opens detailed so its table shows); metered sessions show today's reported dollars and the recent pace per hour, never a projected day total. Simple mode uses real host limits or reported metered spending, and offers at most one existing next step in English, Spanish or Portuguese. Preserve detailed reports and JSON bytes. Show existing users one migration notice. Isolate new fixture tests from real host homes and network access.
|
|
15
|
+
- Add local `compact-replay`: compare the current Claude Code window with 600K, 400K, 300K and 200K over seven days by default, with a days option and JSON output. Use recorded per-request context and measured compaction resets, keep sub-agent contexts separate, and report token savings, API list equivalent dollar savings, extra compactions and token change. Show the current-window backtest error under the table; above 10%, mark the replay unreliable and withhold a suggestion. Suggest the smallest tested window within 100K to 1M whose extra compactions stay strictly below twice the recorded current count, while showing the full table. Charge extra summary work conservatively and leave missing evidence unavailable. Verified the setting range and slash command against Claude Code's own documentation. Fixture tests isolate HOME and forbid real home reads, state writes and network calls.
|
|
16
|
+
- Add `week` in English, Spanish and Portuguese: completed UTC weeks, useful work, waste causes, unattributed usage and one concrete fix. Shares use API list price, not a bill, with tokens when a model has no list price.
|
|
17
|
+
- Save only the exact figures displayed locally, with strict integer identities and private atomic files. Expose weekly collection, validation and rendering for the plugin's separate local opt-in.
|
|
18
|
+
|
|
3
19
|
## 0.5.1 (2026-10-08)
|
|
4
20
|
|
|
5
21
|
First-run fixes, so the first command a new user runs gives a clear answer.
|
package/README.md
CHANGED
|
@@ -18,6 +18,14 @@ Press y if npm asks to install Burn. Plain `npx agentguard-burn` shows these thr
|
|
|
18
18
|
|
|
19
19
|
Burn prints its installed version on the first line of every `why` and `calendar` text report, including the empty message. JSON reports include a `version` field. `npx agentguard-burn --version` (or `-v`) prints only the installed version.
|
|
20
20
|
|
|
21
|
+
## Simple and detailed views
|
|
22
|
+
|
|
23
|
+
`statusline`, `why` and `live` default to simple; `compact-replay` defaults to detailed so its table shows. Save a preference with `agentguard-burn mode simple` or `agentguard-burn mode detailed`. It lives in `AGENTGUARD_HOME/burn-config.json`, normally under `~/.agentguard`. `AGENTGUARD_BURN_MODE` overrides it. Per-command `simple` and `detailed` flags, prefixed by two hyphens, override both. Detailed output and JSON stay unchanged.
|
|
24
|
+
|
|
25
|
+
Subscriptions show real host percentages, reset times and time left at the observed pace, or "limit not available". They never show dollars. Explicit API or usage-credit sessions show today's host-reported dollars and the recent pace per hour, never a projected day total. Missing evidence stays unavailable. There is at most one next step, in English, Spanish or Portuguese.
|
|
26
|
+
|
|
27
|
+
Existing users see this once on stderr: "Showing the simple view. For tokens and cache detail: agentguard-burn mode detailed". See [evidence, projections and verification](docs/simple-views.md) for the supported metadata and limitations.
|
|
28
|
+
|
|
21
29
|
### No sessions yet
|
|
22
30
|
|
|
23
31
|
With no sessions, `why`, `calendar` and `card` print the same guidance to stdout and exit 0. This is a normal first run. No card image is created. Burn lists the actual folders it checked, then prints:
|
|
@@ -33,6 +41,56 @@ By default Burn checks `~/.claude/projects` and `~/.codex/sessions`. When `CLAUD
|
|
|
33
41
|
|
|
34
42
|
`npx agentguard-burn why --json` always writes JSON to stdout. No sessions gives `found: false`, `looked_in`, `message`, `next` and `version`, with exit 0. A successful session report includes `found: true` and `version`. Invalid arguments exit 64; a missing requested session or a read failure exits 4. Both errors include an `error` field in JSON mode. `calendar` also returns the empty JSON object when asked for JSON on a machine with no sessions.
|
|
35
43
|
|
|
44
|
+
## week
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
agentguard-burn week
|
|
48
|
+
agentguard-burn week --week 2026-09-28 json
|
|
49
|
+
agentguard-burn week --lang es
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
See your own machine's last completed week first: useful work, waste causes,
|
|
53
|
+
unattributed usage, the largest cause that stands out and one concrete fix.
|
|
54
|
+
Weeks start Monday at 00:00 UTC and end the next Monday at 00:00 UTC.
|
|
55
|
+
An explicit date must be a Monday. English, Spanish and Portuguese are supported.
|
|
56
|
+
With no transcripts, `week` uses the same first-run guidance as `why`.
|
|
57
|
+
|
|
58
|
+
Shares lead with API list price, not a bill. Cache reads usually cost about a
|
|
59
|
+
tenth of fresh input. If any response has no list price, every dollar field is
|
|
60
|
+
null and shares use tokens instead. Useful work is instruction stack, tool
|
|
61
|
+
output, conversation and output. Waste causes are re-sent history, re-read files,
|
|
62
|
+
sub-agent fan-out and full reloads. Unattributed tokens remain separate.
|
|
63
|
+
Sub-agents on the main model are an overlapping subset, never another partition
|
|
64
|
+
bucket. The only counterfactual reprices that subset on `claude-haiku-5-5`.
|
|
65
|
+
The headline describes what was spent on waste causes and promises no savings.
|
|
66
|
+
|
|
67
|
+
Burn uses the midpoint of each dollar range and rounds each leaf bucket once
|
|
68
|
+
to integer micro-dollars. Useful, waste, reload and overall totals sum the
|
|
69
|
+
rounded buckets. Reload leaves are idle, model switch and other. Fan-out stands
|
|
70
|
+
out at 20% of tokens, reloads at 15% of known spend, re-sent history at 30% of
|
|
71
|
+
tokens and re-read files at 10%. The largest at list price wins, or tokens when
|
|
72
|
+
unpriced, with ties in that order. Fan-out becomes the main-model cause when
|
|
73
|
+
at least half of sub-agent tokens belong to that subset. Reload ties prefer
|
|
74
|
+
idle, then model switch, then other.
|
|
75
|
+
|
|
76
|
+
After displaying the figures, Burn atomically saves
|
|
77
|
+
`AGENTGUARD_HOME/week/YYYY-MM-DD.json` (default `~/.agentguard/week/`), with
|
|
78
|
+
directory mode 0700 and file mode 0600. Only complete, nonempty weeks started
|
|
79
|
+
within the last 28 days are saved, since Claude Code normally keeps transcripts
|
|
80
|
+
for 30 days. Older or partial weeks can be viewed locally. The saved file has
|
|
81
|
+
exactly `schema`, `weekStart`, `viewedAt` and `figures`; see the
|
|
82
|
+
[v1 fixture](fixtures/burn-week-v1.json). Local diagnostics, including excluded
|
|
83
|
+
forks, undated tokens and unpriced model ids, never enter it. `week json` prints
|
|
84
|
+
those diagnostics under `local`, and `saved` reports whether the file was written.
|
|
85
|
+
|
|
86
|
+
Five hard lines apply to weekly sharing:
|
|
87
|
+
|
|
88
|
+
1. Content-free: only integer counts, fixed enum codes, a UTC week date, the existing hashed seat id, a public key and signature leave in a weekly upload. No prompts, completions, file contents, file names, paths, usernames, project names, session ids, model ids or free text. Share changes contain only their schema, seat id, choice and UTC timestamp, signed the same way. Fix sentences are looked up locally from the cause code.
|
|
89
|
+
2. No per-person measures or comparisons of effort or productivity. No composite measures, grades, percentiles, ordering of people, team-average comparisons, session counts, active hours, commits or tokens per commit. `why --commits` stays local. Manager per-seat detail is shares and cause only, with no absolute tokens or dollars.
|
|
90
|
+
3. Copy describes where tokens went and what to change, never rates the person. A seat is one machine, not a person.
|
|
91
|
+
4. Only the person changes weekly sharing, locally in the plugin: `off` by default, `totals` for team totals only, or `seat` for that seat's top waste cause and its fix (never its shares, tokens or dollars). Org policy cannot set it. Turning it off sends a removal request immediately to delete that seat's stored weeks; a failed request is retried. Turning it on applies at the next upload.
|
|
92
|
+
5. You see the exact week on this machine before it can be uploaded. The plugin sends this saved file's figures, with no recomputation. Burn itself uploads nothing for `week`.
|
|
93
|
+
|
|
36
94
|
## Launch tree and signed approval tally
|
|
37
95
|
|
|
38
96
|
```sh
|
|
@@ -219,6 +277,25 @@ Multipliers relative to base input: 5m write 1.25x, 1h write 2x, cache read 0.1x
|
|
|
219
277
|
|
|
220
278
|
Every dollar column is an API list equivalent; on a subscription, read the token columns. The multipliers come from Anthropic's prompt caching pricing (five-minute writes 1.25x base input, one-hour writes 2x, cache reads 0.1x) and only fill rates a model row leaves empty; the verified rates in the pricing table, and any local override, take precedence. The verdict lines name the exact setting: `"promptCacheTtl": "1h"` for the main conversation (or `CLAUDE_CODE_PROMPT_CACHE_TTL=1h`) and `"subagentPromptCacheTtl": "1h"` for subagents, forks, compaction and titles. On a Claude subscription within plan usage the main conversation already has a one-hour lifetime; API key and usage-credit sessions start at five minutes. When the net favours five minutes, the report says so plainly.
|
|
221
279
|
|
|
280
|
+
## Replay compaction windows
|
|
281
|
+
|
|
282
|
+
```sh
|
|
283
|
+
agentguard-burn compact-replay
|
|
284
|
+
agentguard-burn compact-replay days 7 json
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Compare Claude Code's current auto-compaction window with 600K, 400K, 300K and 200K using local transcripts from the last seven days. The `days` option changes the lookback, from 1 to 3650 days, and `json` returns the figures and diagnostics. Both options also accept the conventional two-hyphen flag spelling. No Claude Code call, network request or settings write is made. Claude Code transcripts come from `CLAUDE_CONFIG_DIR/projects`, or `~/.claude/projects` when that variable is empty or unset. Sub-agent transcripts have their own contexts; copied responses count once.
|
|
288
|
+
|
|
289
|
+
Claude Code's own [model configuration](https://code.claude.com/docs/en/model-config#set-the-auto-compact-window), [settings reference](https://code.claude.com/docs/en/settings-reference#autocompactwindow) and [commands reference](https://code.claude.com/docs/en/commands#all-commands), checked on October 9, 2026, document `autoCompactWindow` from 100,000 to 1,000,000 tokens and `/autocompact 200k`. Since Claude Code v2.1.288, the command saves a value for the current model under `modelSettings`; `/autocompact auto` returns to its tuned default. Environment and higher-priority settings can override that choice. Burn reads user, project, local and on-disk managed settings, including their environment blocks. When no numeric window is set, the report labels the model window as assumed, normally 1M. It cannot recover old launch flags or remote managed policy.
|
|
290
|
+
|
|
291
|
+
Each table row gives tokens saved, dollars saved as **API list equivalent**, extra compactions and the percentage change in tokens, relative to the current-window replay. Negative savings mean more usage. Dollars retain the cache lifetime range where it is unknown; an unknown model stays unpriced. These are estimates for the same recorded work, not a subscription discount or a promise about task quality.
|
|
292
|
+
|
|
293
|
+
The replay advances context by the measured change between recorded requests. At a recorded automatic compaction it uses `compactMetadata.preTokens` to recover the growth before the reset, then independently decides whether the simulated context crosses the chosen window. A reset uses the median next-request context after real compactions, first from that transcript and model, otherwise from the same model and main or sub-agent role in the selected transcripts. Manual compactions and recorded clears stay fixed. Missing usage or a missing compaction measurement makes affected results unavailable.
|
|
294
|
+
|
|
295
|
+
New resets rewrite the cache. Extra summary requests are conservatively charged a full uncached context read plus the measured reset size as summary output, because the transcript does not reliably identify their usage separately. Fewer summaries receive no credit. Other output stays fixed. This assumption is printed with the report.
|
|
296
|
+
|
|
297
|
+
The caveat immediately under the table gives the replay's error against the recorded token total at the current window. Above 10%, it says the replay is unreliable for this machine and suggests no change. The error is a backtest result, not a statistical confidence interval. With complete evidence, an acceptable backtest and positive conservative dollar savings, the report suggests the smallest tested window within 100K to 1M whose extra compactions are strictly below twice the recorded current count. It keeps every row visible so you can choose, and prints a command such as `/autocompact 400k` to type in Claude Code for each model you want to change. It withholds that command when an override prevents it from applying.
|
|
298
|
+
|
|
222
299
|
## Why this session
|
|
223
300
|
|
|
224
301
|
```sh
|
|
@@ -245,7 +322,7 @@ After a `/compact`, an automatic compaction, a model switch, or a `/clear` that
|
|
|
245
322
|
|
|
246
323
|
When the session's transcripts record sub-agents that ended without finishing, `why` adds one line after the observed calls, for example `Sub-agents that ended without finishing: 2 of 5, 275,000 tokens (58.9% of session tokens, $0.75 API list equivalent).` A sub-agent counts only when Claude Code recorded its status as `failed`, `killed` or `stopped`, and never as `completed` or resumed. One launched in the background with no end recorded may still be running, so it never counts. The count is out of every sub-agent transcript in the session's `subagents` folder, the tokens are their own responses counted once, and the dollars are left out when a model is unpriced. Burn knows whether a sub-agent finished, never whether its work was right. `why json` lists the ids it counted from under `subagents`.
|
|
247
324
|
|
|
248
|
-
`why` prints in Latin American Spanish or Brazilian Portuguese when your machine is set to that language, and `--lang es`, `--lang pt` or `--lang en` picks one explicitly. The order is `--lang`, then `AGENTGUARD_LANG`, then `LC_ALL`, `LC_MESSAGES` and `LANG` (the first one set decides, as POSIX says, so `LC_ALL=C` means English), then the locale Node resolves. Every other language is English. Figures keep their en-US formatting in every language (`1,234,567`, `$1335.37`, `12.3%`), so a translated report matches screenshots digit for digit. `why`, `compare
|
|
325
|
+
`why` prints in Latin American Spanish or Brazilian Portuguese when your machine is set to that language, and `--lang es`, `--lang pt` or `--lang en` picks one explicitly. The order is `--lang`, then `AGENTGUARD_LANG`, then `LC_ALL`, `LC_MESSAGES` and `LANG` (the first one set decides, as POSIX says, so `LC_ALL=C` means English), then the locale Node resolves. Every other language is English. Figures keep their en-US formatting in every language (`1,234,567`, `$1335.37`, `12.3%`), so a translated report matches screenshots digit for digit. `why`, `compare`, `calendar`, `week` and all four simple views are translated. Their JSON output is the same in every language.
|
|
249
326
|
|
|
250
327
|
Later cache reads up to the baseline go to instruction stack + system. Reads above it go to history re-sent. Fresh input plus cache creation is the measured arriving increment. Burn subtracts the previous response's output before assigning that increment to intervening tool results and user messages. Result byte sizes only split that measured total; bytes are never converted into tokens. A result for a previously read Read path goes to re-read files. Mixed user and tool intervals are marked shared and counted in the footer.
|
|
251
328
|
|
package/dist/src/cli.js
CHANGED
|
@@ -92,6 +92,10 @@ const cli_1 = require("./idle/cli");
|
|
|
92
92
|
const telemetry_cli_1 = require("./telemetry-cli");
|
|
93
93
|
const status_fields_1 = require("./insights/status-fields");
|
|
94
94
|
const status_data_1 = require("./insights/status-data");
|
|
95
|
+
const display_mode_1 = require("./display-mode");
|
|
96
|
+
const i18n_2 = require("./insights/i18n");
|
|
97
|
+
const simple_data_1 = require("./insights/simple-data");
|
|
98
|
+
const simple_render_1 = require("./insights/simple-render");
|
|
95
99
|
const HOME = process.env.AGENTGUARD_HOME ?? (0, node_path_1.join)((0, node_os_1.homedir)(), '.agentguard');
|
|
96
100
|
let finishReportNaturally = false;
|
|
97
101
|
const PROXY_HOSTS = ['ollama', 'vllm', 'lm-studio', 'openai-compatible'];
|
|
@@ -140,7 +144,20 @@ function shadowEligibility() {
|
|
|
140
144
|
return (0, eligibility_1.computeShadowEligibility)(readDecisions());
|
|
141
145
|
}
|
|
142
146
|
async function main(argv) {
|
|
143
|
-
const
|
|
147
|
+
const display = (0, display_mode_1.displayArguments)(argv);
|
|
148
|
+
const [command, ...rawRest] = display.args;
|
|
149
|
+
// Machine output never reads display settings or consumes the migration notice.
|
|
150
|
+
const simple = !rawRest.some(arg => arg === 'json' || arg === '--json')
|
|
151
|
+
&& ['why', 'statusline', 'live', 'compact-replay'].includes(command ?? '')
|
|
152
|
+
// compact-replay's table is the answer, so it opens detailed unless a flag, the environment or a saved preference says simple.
|
|
153
|
+
&& (0, display_mode_1.displayMode)(HOME, display.mode, process.env, command === 'compact-replay' ? 'detailed' : 'simple') === 'simple';
|
|
154
|
+
const notice = (lang = (0, i18n_1.detectWhyLang)({ env: process.env, intlLocale: intlLocale() })) => {
|
|
155
|
+
if (!simple)
|
|
156
|
+
return;
|
|
157
|
+
const text = (0, display_mode_1.simpleViewNotice)(HOME, lang);
|
|
158
|
+
if (text)
|
|
159
|
+
process.stderr.write(text + '\n');
|
|
160
|
+
};
|
|
144
161
|
const noColor = rawRest.includes('--no-color');
|
|
145
162
|
const rest = rawRest.filter(value => value !== '--no-color');
|
|
146
163
|
const show = (data, plain, protocol = false) => (0, presentation_1.present)(data, plain, { colour: Boolean(process.stdout.isTTY) && !noColor && process.env.NO_COLOR === undefined, protocol });
|
|
@@ -155,6 +172,17 @@ async function main(argv) {
|
|
|
155
172
|
};
|
|
156
173
|
const has = (name) => rawRest.includes(name);
|
|
157
174
|
switch (command) {
|
|
175
|
+
case 'mode': {
|
|
176
|
+
if (rest.length !== 1 || !['simple', 'detailed'].includes(rest[0])) {
|
|
177
|
+
process.stderr.write('Usage: agentguard-burn mode simple|detailed\n');
|
|
178
|
+
return 64;
|
|
179
|
+
}
|
|
180
|
+
const mode = rest[0];
|
|
181
|
+
(0, display_mode_1.setDisplayMode)(HOME, mode);
|
|
182
|
+
const words = i18n_2.SIMPLE_TEXT[(0, i18n_1.detectWhyLang)({ env: process.env, intlLocale: intlLocale() })];
|
|
183
|
+
process.stdout.write(words.saved(words[mode]) + '\n');
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
158
186
|
case '--version':
|
|
159
187
|
case '-v':
|
|
160
188
|
// The version of this install, from the package that ships it, and nothing else.
|
|
@@ -162,7 +190,8 @@ async function main(argv) {
|
|
|
162
190
|
return 0;
|
|
163
191
|
case 'live': {
|
|
164
192
|
const { runLivePanel } = await Promise.resolve().then(() => __importStar(require('./live-panel')));
|
|
165
|
-
|
|
193
|
+
notice();
|
|
194
|
+
return runLivePanel(HOME, rawRest, simple ? 'simple' : 'detailed');
|
|
166
195
|
}
|
|
167
196
|
case 'record': {
|
|
168
197
|
const { recordLedger, recordLedgerArguments } = await Promise.resolve().then(() => __importStar(require('./record-ledger')));
|
|
@@ -286,6 +315,31 @@ async function main(argv) {
|
|
|
286
315
|
throw error;
|
|
287
316
|
}
|
|
288
317
|
const transcript = (0, transcript_1.readInsightSession)(location.path, { host: location.host, sessionId: location.sessionId });
|
|
318
|
+
if (simple) {
|
|
319
|
+
const language = (0, i18n_1.detectWhyLang)({ flag: lang, env: process.env, intlLocale: intlLocale() });
|
|
320
|
+
notice(language);
|
|
321
|
+
let next = null;
|
|
322
|
+
if (!quietOn()) {
|
|
323
|
+
if (location.host === 'claude') {
|
|
324
|
+
const { collectCompactReplay } = await Promise.resolve().then(() => __importStar(require('./insights/compact-replay')));
|
|
325
|
+
next = (0, simple_render_1.simpleReplayStep)(await collectCompactReplay(), language, 15);
|
|
326
|
+
}
|
|
327
|
+
next ??= (0, simple_render_1.simpleNextStep)(transcript, (0, live_1.readPricing)(HOME), language);
|
|
328
|
+
}
|
|
329
|
+
const usage = (0, simple_data_1.readSimpleUsage)(HOME, { location });
|
|
330
|
+
const helpers = (0, tree_1.readLaunchTree)(location).root.children;
|
|
331
|
+
// Host-defined roles only; arbitrary agent names may contain jargon or content.
|
|
332
|
+
const names = [...new Set(helpers.map(child => child.name).filter(name => ['Explore', 'Plan'].includes(name)))].join(', ');
|
|
333
|
+
const helperLine = helpers.length ? '\n' + i18n_2.SIMPLE_TEXT[language].helpers(helpers.length, names) : '';
|
|
334
|
+
show({ kind: 'command', command, values: { session: transcript.sessionId } }, (0, simple_render_1.renderSimple)(usage, {
|
|
335
|
+
lang: language, next, title: `Burn ${version_1.BURN_VERSION} | AgentGuard why: ${transcript.sessionId}`,
|
|
336
|
+
}) + helperLine + '\n', true);
|
|
337
|
+
if (require.main === module && transcript.turns.length) {
|
|
338
|
+
finishReportNaturally = true;
|
|
339
|
+
await (0, telemetry_cli_1.countFirstReport)(version_1.BURN_VERSION);
|
|
340
|
+
}
|
|
341
|
+
return 0;
|
|
342
|
+
}
|
|
289
343
|
// The commits reader is loaded only with the flag, so a plain `why` never reaches it.
|
|
290
344
|
const commits = withCommits ? await (await Promise.resolve().then(() => __importStar(require('./insights/commits')))).sessionCommits({ path: location.path }) : undefined;
|
|
291
345
|
const launchTree = (0, tree_1.readLaunchTree)(location);
|
|
@@ -333,6 +387,48 @@ async function main(argv) {
|
|
|
333
387
|
show({ kind: 'command', command, values: { ...report } }, json ? JSON.stringify(report, null, 2) + '\n' : renderCompare(report, language) + '\n', json);
|
|
334
388
|
return 0;
|
|
335
389
|
}
|
|
390
|
+
case 'week': {
|
|
391
|
+
let lang, weekStart, invalid = false;
|
|
392
|
+
const json = rest.includes('json') || rest.includes('--json');
|
|
393
|
+
for (let i = 0; i < rest.length; i++) {
|
|
394
|
+
const arg = rest[i];
|
|
395
|
+
if (arg === '--lang' || arg.startsWith('--lang=')) {
|
|
396
|
+
lang = arg === '--lang' ? rest[++i] : arg.slice(7);
|
|
397
|
+
if (!['en', 'es', 'pt'].includes(lang ?? ''))
|
|
398
|
+
invalid = true;
|
|
399
|
+
}
|
|
400
|
+
else if (arg === '--week' || arg.startsWith('--week=')) {
|
|
401
|
+
weekStart = arg === '--week' ? rest[++i] : arg.slice(7);
|
|
402
|
+
if (!weekStart)
|
|
403
|
+
invalid = true;
|
|
404
|
+
}
|
|
405
|
+
else if (arg !== 'json' && arg !== '--json')
|
|
406
|
+
invalid = true;
|
|
407
|
+
}
|
|
408
|
+
const { collectWeek, isMonday, saveWeek } = await Promise.resolve().then(() => __importStar(require('./insights/week')));
|
|
409
|
+
if (invalid || (weekStart !== undefined && !isMonday(weekStart))) {
|
|
410
|
+
process.stderr.write('Usage: agentguard-burn week [--week YYYY-MM-DD] [json] [--lang en|es|pt]\n');
|
|
411
|
+
return 64;
|
|
412
|
+
}
|
|
413
|
+
const roots = (0, sessions_1.transcriptRoots)();
|
|
414
|
+
if (!(0, sessions_1.discoverInsightTranscripts)(roots).length)
|
|
415
|
+
return showNoSessions(Object.values(roots), json);
|
|
416
|
+
const now = Date.now(), report = collectWeek({ weekStart, now, home: HOME, roots });
|
|
417
|
+
const language = (0, i18n_1.detectWhyLang)({ flag: lang, env: process.env, intlLocale: intlLocale() });
|
|
418
|
+
const { renderWeek } = await Promise.resolve().then(() => __importStar(require('./insights/week-render')));
|
|
419
|
+
const value = { version: version_1.BURN_VERSION, found: true, ...report };
|
|
420
|
+
// Flush the exact figures before saving. JSON's final saved field records
|
|
421
|
+
// the actual write result, after the figures have reached stdout.
|
|
422
|
+
const output = json ? JSON.stringify(value).slice(0, -1) : renderWeek(report, language) + '\n';
|
|
423
|
+
await new Promise((resolve, reject) => process.stdout.write(output, error => error ? reject(error) : resolve()));
|
|
424
|
+
const saved = saveWeek(HOME, report, now);
|
|
425
|
+
if (json)
|
|
426
|
+
process.stdout.write(`,"saved":${saved.saved}}\n`);
|
|
427
|
+
else if (saved.reason === 'write_failed')
|
|
428
|
+
process.stderr.write(i18n_1.WEEK_TEXT[language].saveFailed + '\n');
|
|
429
|
+
(0, recording_1.recordFrame)({ kind: 'command', command, values: { ...value, saved: saved.saved } });
|
|
430
|
+
return saved.reason === 'write_failed' ? 4 : 0;
|
|
431
|
+
}
|
|
336
432
|
case 'calendar': {
|
|
337
433
|
// `--weeks N` (1 to 53, also --weeks=N), `json`, and `--lang` exactly as `why` takes it.
|
|
338
434
|
const args = [];
|
|
@@ -427,6 +523,44 @@ async function main(argv) {
|
|
|
427
523
|
: 'Tips are on. The why report ends with one tip when a share of the session stands out.\nHide tips: npx agentguard-burn quiet on\n');
|
|
428
524
|
return 0;
|
|
429
525
|
}
|
|
526
|
+
case 'compact-replay': {
|
|
527
|
+
let days = 7, daysGiven = false, invalid = false;
|
|
528
|
+
let lang;
|
|
529
|
+
const json = rest.includes('--json') || rest.includes('json');
|
|
530
|
+
for (let i = 0; i < rest.length; i++) {
|
|
531
|
+
const arg = rest[i];
|
|
532
|
+
if (arg === '--days' || arg === 'days' || arg.startsWith('--days=')) {
|
|
533
|
+
const value = arg.startsWith('--days=') ? arg.slice(7) : rest[++i];
|
|
534
|
+
if (daysGiven || !/^\d+$/.test(value ?? ''))
|
|
535
|
+
invalid = true;
|
|
536
|
+
daysGiven = true;
|
|
537
|
+
days = Number(value);
|
|
538
|
+
}
|
|
539
|
+
else if (arg === '--lang' || arg.startsWith('--lang=')) {
|
|
540
|
+
lang = arg === '--lang' ? rest[++i] : arg.slice(7);
|
|
541
|
+
if ((0, i18n_1.whyLangOf)(lang) === null)
|
|
542
|
+
invalid = true;
|
|
543
|
+
}
|
|
544
|
+
else if (arg !== '--json' && arg !== 'json')
|
|
545
|
+
invalid = true;
|
|
546
|
+
}
|
|
547
|
+
if (invalid || !Number.isSafeInteger(days) || days < 1 || days > 3650) {
|
|
548
|
+
const error = 'Use agentguard-burn compact-replay with days N (1 to 3650) and optional json.';
|
|
549
|
+
if (json)
|
|
550
|
+
process.stdout.write(JSON.stringify({ version: version_1.BURN_VERSION, error }) + '\n');
|
|
551
|
+
else
|
|
552
|
+
process.stderr.write(error + '\n');
|
|
553
|
+
return 64;
|
|
554
|
+
}
|
|
555
|
+
const { collectCompactReplay, renderCompactReplay } = await Promise.resolve().then(() => __importStar(require('./insights/compact-replay')));
|
|
556
|
+
const report = await collectCompactReplay({ days });
|
|
557
|
+
const language = (0, i18n_1.detectWhyLang)({ flag: lang, env: process.env, intlLocale: intlLocale() });
|
|
558
|
+
if (simple)
|
|
559
|
+
notice(language);
|
|
560
|
+
show({ kind: 'command', command, values: { ...report } }, json ? JSON.stringify(report, null, 2) + '\n'
|
|
561
|
+
: (simple ? (0, simple_render_1.renderSimpleReplay)((0, simple_data_1.readSimpleUsage)(HOME, { locations: (0, sessions_1.discoverInsightTranscripts)().filter(item => item.host === 'claude') }), report, language, !quietOn()) : renderCompactReplay(report)) + '\n', true);
|
|
562
|
+
return 0;
|
|
563
|
+
}
|
|
430
564
|
case 'rewrites':
|
|
431
565
|
case 'ttl': {
|
|
432
566
|
// Like `why`: with no session, the newest top-level transcript plus its stored
|
|
@@ -465,16 +599,25 @@ async function main(argv) {
|
|
|
465
599
|
const raw = !process.stdin.isTTY ? readStdinJson() : null;
|
|
466
600
|
const payload = (raw && typeof raw === 'object' ? raw : {});
|
|
467
601
|
const width = payload.columns ?? payload.terminal_width ?? process.stdout.columns ?? Number(process.env.COLUMNS || 80);
|
|
602
|
+
const language = (0, i18n_1.detectWhyLang)({ flag: lang, env: process.env, intlLocale: intlLocale() });
|
|
603
|
+
if (simple)
|
|
604
|
+
notice(language);
|
|
468
605
|
let location;
|
|
469
606
|
try {
|
|
470
607
|
location = (0, sessions_1.selectInsightTranscript)(payload.transcript_path || selectors[0] || payload.session_id);
|
|
471
608
|
}
|
|
472
609
|
catch {
|
|
473
|
-
process.stdout.write((0,
|
|
610
|
+
process.stdout.write((simple ? (0, simple_render_1.renderSimple)((0, simple_data_1.readSimpleUsage)(HOME, { payload, locations: [] }), { lang: language, line: true })
|
|
611
|
+
: (0, status_fields_1.formatStatusFields)({ fields, width, failed: true }).text) + '\n');
|
|
474
612
|
return 0;
|
|
475
613
|
}
|
|
476
614
|
const session = payload.session_id || location.sessionId;
|
|
477
615
|
const observation = (0, live_1.observeTool)(HOME, { ...payload, session_id: session, transcript_path: location.path }, location.host, (0, pre_tool_use_1.loadPolicy)(HOME));
|
|
616
|
+
if (simple) {
|
|
617
|
+
(0, simple_data_1.recordSimpleHost)(HOME, location.path, payload);
|
|
618
|
+
process.stdout.write((0, simple_render_1.renderSimple)((0, simple_data_1.readSimpleUsage)(HOME, { location, payload }), { lang: language, line: true }) + '\n');
|
|
619
|
+
return 0;
|
|
620
|
+
}
|
|
478
621
|
const metrics = await (0, status_data_1.readStatusMetrics)(HOME, location.path, fields, process.env.PLUGIN_DATA || process.env.CLAUDE_PLUGIN_DATA, true);
|
|
479
622
|
const burn = (0, status_data_1.readStatusBurn)(HOME, session);
|
|
480
623
|
if (!(0, node_fs_1.existsSync)((0, node_path_1.join)(HOME, 'sessions')) && metrics.totalTokens !== undefined)
|
|
@@ -726,7 +869,7 @@ async function main(argv) {
|
|
|
726
869
|
show({ kind: 'command', command: 'help', values: { commands: ['why', 'calendar', 'card'] } }, starter + '\nStart here: npx agentguard-burn why\nAll commands: npx agentguard-burn --help all\n', true);
|
|
727
870
|
return !command || command === 'help' || command === '--help' || command === '-h' ? 0 : 64;
|
|
728
871
|
}
|
|
729
|
-
show({ kind: 'command', command: 'help', values: { commands: ['tree', 'tally', 'ps', 'reap', 'live', 'record', 'render', 'blocks', 'limits', 'price-shadow', 'calendar', 'why', 'compare', 'rewrites', 'ttl', 'pace', 'statusline', 'pricing', 'telemetry', 'replay', 'calibrate', 'status', 'init', 'enforce', 'shadow', 'resume', 'quiet', 'proxy', 'conformance'] } }, starter + '\nAll commands\n' +
|
|
872
|
+
show({ kind: 'command', command: 'help', values: { commands: ['tree', 'tally', 'ps', 'reap', 'live', 'record', 'render', 'blocks', 'limits', 'price-shadow', 'calendar', 'week', 'why', 'compare', 'rewrites', 'compact-replay', 'ttl', 'pace', 'statusline', 'pricing', 'telemetry', 'replay', 'calibrate', 'status', 'init', 'enforce', 'shadow', 'resume', 'quiet', 'proxy', 'conformance'] } }, starter + '\nAll commands\n' +
|
|
730
873
|
' ps [--json] local agent processes, held memory and workspace disk\n' +
|
|
731
874
|
' render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone] local recorded-run export\n' +
|
|
732
875
|
' render <run.jsonl> --mp4 <out.mp4> --dashboard [--wide] [--economics <blocks.json>] dashboard export\n' +
|
|
@@ -744,8 +887,10 @@ async function main(argv) {
|
|
|
744
887
|
' --commits count the commits that landed in its git repository while it ran (runs git on this computer; off by default)\n' +
|
|
745
888
|
' compare [sessionA] [sessionB] two sessions side by side: tokens, cache, sub-agents, rewrites, list USD; json and --lang as for why\n' +
|
|
746
889
|
' calendar [--weeks N] tokens per day, Claude Code and Codex together: sub-agent days, launches AgentGuard held, dollars at API prices; json and --lang as for why\n' +
|
|
890
|
+
' week [--week YYYY-MM-DD] [json] [--lang en|es|pt] your last completed UTC week: useful work, waste causes and one fix\n' +
|
|
747
891
|
' card [--weeks N] [--out file.png] the calendar\'s totals as one 1200x675 image to share (default 4 weeks); written locally, nothing uploaded\n' +
|
|
748
892
|
' rewrites [session|all] every full-prefix cache write with its cause, idle gap and list price\n' +
|
|
893
|
+
' compact-replay replay compaction windows over the last 7 days; accepts days N and json\n' +
|
|
749
894
|
' ttl [session|all] one-hour cache lifetime counterfactual from your own idle gaps\n' +
|
|
750
895
|
' pace [session] ten-minute pace and next-hour projection\n' +
|
|
751
896
|
' statusline [session] one local status line; fields via AGENTGUARD_STATUS_FIELDS or the fields flag\n' +
|
|
@@ -762,6 +907,7 @@ async function main(argv) {
|
|
|
762
907
|
' resume --once --reason "..." let the next STOP through, once, on any host\n' +
|
|
763
908
|
' resume --reason "..." let STOPs through for 15 minutes; --clear ends it\n' +
|
|
764
909
|
' quiet [on|off] hide or show the why tip and the plugin upgrade lines; alone, says which\n' +
|
|
910
|
+
' mode simple|detailed save the display view; AGENTGUARD_BURN_MODE or a per-command simple/detailed flag overrides it\n' +
|
|
765
911
|
' proxy --upstream http://127.0.0.1:11434 --host ollama|vllm|lm-studio|openai-compatible [--listen 127.0.0.1:18080] [--session ID]\n' +
|
|
766
912
|
' conformance check that each host stops the same runaway patterns\n' +
|
|
767
913
|
'Developer review commands (never installed as hooks):\n' +
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type WhyLang } from './insights/i18n';
|
|
2
|
+
export type DisplayMode = 'simple' | 'detailed';
|
|
3
|
+
export declare const displayConfigPath: (home: string) => string;
|
|
4
|
+
export declare function setDisplayMode(home: string, mode: DisplayMode): void;
|
|
5
|
+
export declare function displayArguments(args: string[]): {
|
|
6
|
+
args: string[];
|
|
7
|
+
mode?: DisplayMode;
|
|
8
|
+
};
|
|
9
|
+
/** `fallback` applies only when no flag, environment value or saved preference chooses a mode. */
|
|
10
|
+
export declare function displayMode(home: string, override?: DisplayMode, env?: NodeJS.ProcessEnv, fallback?: DisplayMode): DisplayMode;
|
|
11
|
+
/** Call before observers create state. A migration notice is human output only. */
|
|
12
|
+
export declare function simpleViewNotice(home: string, lang: WhyLang): string | null;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.displayConfigPath = void 0;
|
|
4
|
+
exports.setDisplayMode = setDisplayMode;
|
|
5
|
+
exports.displayArguments = displayArguments;
|
|
6
|
+
exports.displayMode = displayMode;
|
|
7
|
+
exports.simpleViewNotice = simpleViewNotice;
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const i18n_1 = require("./insights/i18n");
|
|
12
|
+
const displayConfigPath = (home) => (0, node_path_1.join)(home, 'burn-config.json');
|
|
13
|
+
exports.displayConfigPath = displayConfigPath;
|
|
14
|
+
const isMode = (value) => value === 'simple' || value === 'detailed';
|
|
15
|
+
function readConfig(home) {
|
|
16
|
+
try {
|
|
17
|
+
const value = JSON.parse((0, node_fs_1.readFileSync)((0, exports.displayConfigPath)(home), 'utf8'));
|
|
18
|
+
if (value && typeof value === 'object' && !Array.isArray(value))
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.code === 'ENOENT')
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
throw new Error('Burn display settings could not be read. Keep the existing file and repair its JSON.');
|
|
26
|
+
}
|
|
27
|
+
function saveConfig(home, value) {
|
|
28
|
+
(0, node_fs_1.mkdirSync)(home, { recursive: true, mode: 0o700 });
|
|
29
|
+
const temporary = `${(0, exports.displayConfigPath)(home)}.${(0, node_crypto_1.randomUUID)()}.tmp`;
|
|
30
|
+
(0, node_fs_1.writeFileSync)(temporary, JSON.stringify(value, null, 2) + '\n', { mode: 0o600 });
|
|
31
|
+
(0, node_fs_1.renameSync)(temporary, (0, exports.displayConfigPath)(home));
|
|
32
|
+
}
|
|
33
|
+
function setDisplayMode(home, mode) {
|
|
34
|
+
saveConfig(home, { ...readConfig(home), displayMode: mode });
|
|
35
|
+
}
|
|
36
|
+
function displayArguments(args) {
|
|
37
|
+
const simple = args.includes('--simple'), detailed = args.includes('--detailed');
|
|
38
|
+
if (simple && detailed)
|
|
39
|
+
throw new Error('Choose either simple or detailed for this command.');
|
|
40
|
+
return { args: args.filter(arg => arg !== '--simple' && arg !== '--detailed'), mode: simple ? 'simple' : detailed ? 'detailed' : undefined };
|
|
41
|
+
}
|
|
42
|
+
/** `fallback` applies only when no flag, environment value or saved preference chooses a mode. */
|
|
43
|
+
function displayMode(home, override, env = process.env, fallback = 'simple') {
|
|
44
|
+
if (override)
|
|
45
|
+
return override;
|
|
46
|
+
if (env.AGENTGUARD_BURN_MODE) {
|
|
47
|
+
if (!isMode(env.AGENTGUARD_BURN_MODE))
|
|
48
|
+
throw new Error('AGENTGUARD_BURN_MODE must be simple or detailed.');
|
|
49
|
+
return env.AGENTGUARD_BURN_MODE;
|
|
50
|
+
}
|
|
51
|
+
const value = readConfig(home).displayMode;
|
|
52
|
+
return isMode(value) ? value : fallback;
|
|
53
|
+
}
|
|
54
|
+
/** Call before observers create state. A migration notice is human output only. */
|
|
55
|
+
function simpleViewNotice(home, lang) {
|
|
56
|
+
try {
|
|
57
|
+
const config = readConfig(home);
|
|
58
|
+
if (config.simpleViewSeen === true)
|
|
59
|
+
return null;
|
|
60
|
+
const existing = config.displayMode === 'detailed' || ['burn-policy.json', 'decisions.ndjson', 'sessions', 'pace', 'calendar'].some(file => (0, node_fs_1.existsSync)((0, node_path_1.join)(home, file)));
|
|
61
|
+
saveConfig(home, { ...config, simpleViewSeen: true });
|
|
62
|
+
return existing ? i18n_1.SIMPLE_TEXT[lang].notice : null;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
} // A read-only home never breaks a status display.
|
|
67
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -32,3 +32,5 @@ export { readLaunchTree, readLaunchTreeWithReceipts, buildLaunchTree, renderLaun
|
|
|
32
32
|
export { sessionTally, tallyEntries, readLedgerTallies, readLedgerDailyTallies, renderSessionTally, pluginLedgerDirectories, sessionLaunchReceipts, type SessionTally, type TallyCounts } from './insights/tally';
|
|
33
33
|
export { formatStatusFields, parseStatusFields, statusPace, statusColor, type StatusInput, type StatusMetrics } from './insights/status-fields';
|
|
34
34
|
export { readStatusBurn, readStatusMetrics } from './insights/status-data';
|
|
35
|
+
export { collectWeek, saveWeek, weekFigures, weekStartOf, lastCompletedWeekStart, isMonday, WEEK_SCHEMA, SMALLER_MODEL, type WeekFigures, type WeekReport, type WeekAmount, type WeekCause, type WeekTopCause, type BurnWeekFile, type CollectWeekOptions, type SaveWeekResult } from './insights/week';
|
|
36
|
+
export { renderWeek } from './insights/week-render';
|
package/dist/src/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.agentOverrideAttempt = exports.asksPerson = exports.settingsSnippet = exports.loadPolicy = exports.refreshSession = exports.handlePreToolUse = exports.calibrate = exports.OVERRIDE_COMMAND = exports.stopSummary = exports.sessionSoFar = exports.primarySummary = exports.overriddenLine = exports.continueLines = exports.askReason = exports.renderStop = exports.renderReplay = exports.discoverTranscripts = exports.replayEvents = exports.replaySession = exports.replayAll = exports.RESERVATION_TTL_MS = exports.Transaction = exports.ReservationStore = exports.cacheReadRatio = exports.medianCompletedMinute = exports.windowSum = exports.newSessionState = exports.applyCorrection = exports.applyEvent = exports.checkPolicyFile = exports.sessionTip = exports.MIN_FINISHED_SUBAGENTS = exports.decisionCostLine = exports.subagentCostLine = exports.finishedSubagents = exports.cloneReaderCursor = exports.restoreReaderCursor = exports.saveReaderCursor = exports.readSessionIncremental = exports.normaliseLine = exports.newCursor = exports.readAll = exports.readIncremental = exports.evaluateLocalCompute = exports.fmt = exports.evaluate = exports.CALL_RESERVATION_TTL_MS = exports.DEFAULT_LOCAL_COMPUTE = exports.DEFAULT_THRESHOLDS = exports.DEFAULT_POLICY = void 0;
|
|
18
18
|
exports.parseStatusFields = exports.formatStatusFields = exports.sessionLaunchReceipts = exports.pluginLedgerDirectories = exports.renderSessionTally = exports.readLedgerDailyTallies = exports.readLedgerTallies = exports.tallyEntries = exports.sessionTally = exports.renderLaunchTree = exports.buildLaunchTree = exports.readLaunchTreeWithReceipts = exports.readLaunchTree = exports.inflateHookSession = exports.findingSignature = exports.renderHostHealth = exports.readHookSessions = exports.configPath = exports.health = exports.install = exports.OVERRIDE_WINDOW_MS = exports.clearOverride = exports.consumeOverride = exports.readOverride = exports.writeOverride = exports.runConformance = exports.renderMachineStatus = exports.UsageObserver = exports.profileFor = exports.startProxy = exports.LAUNCH_TOOLS = exports.isLaunchTool = exports.CODEX_FORBIDDEN_FIELDS = exports.readCodexTranscriptUsage = exports.parseCodexTranscript = exports.codexHooksSnippet = exports.handleCodexHook = exports.cursorHooksSnippet = exports.handleCursorHook = exports.BurnStopError = exports.createRawApiGuard = exports.sha256 = exports.canonical = exports.readSpawnAdmission = exports.receiptDigest = exports.verifyReceipt = exports.ReceiptSigner = exports.mergeCapabilities = exports.Gateway = exports.AGENT_OVERRIDE_REASON = void 0;
|
|
19
|
-
exports.readStatusMetrics = exports.readStatusBurn = exports.statusColor = exports.statusPace = void 0;
|
|
19
|
+
exports.renderWeek = exports.SMALLER_MODEL = exports.WEEK_SCHEMA = exports.isMonday = exports.lastCompletedWeekStart = exports.weekStartOf = exports.weekFigures = exports.saveWeek = exports.collectWeek = exports.readStatusMetrics = exports.readStatusBurn = exports.statusColor = exports.statusPace = void 0;
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
21
21
|
var defaults_1 = require("./defaults");
|
|
22
22
|
Object.defineProperty(exports, "DEFAULT_POLICY", { enumerable: true, get: function () { return defaults_1.DEFAULT_POLICY; } });
|
|
@@ -159,3 +159,14 @@ Object.defineProperty(exports, "statusColor", { enumerable: true, get: function
|
|
|
159
159
|
var status_data_1 = require("./insights/status-data");
|
|
160
160
|
Object.defineProperty(exports, "readStatusBurn", { enumerable: true, get: function () { return status_data_1.readStatusBurn; } });
|
|
161
161
|
Object.defineProperty(exports, "readStatusMetrics", { enumerable: true, get: function () { return status_data_1.readStatusMetrics; } });
|
|
162
|
+
var week_1 = require("./insights/week");
|
|
163
|
+
Object.defineProperty(exports, "collectWeek", { enumerable: true, get: function () { return week_1.collectWeek; } });
|
|
164
|
+
Object.defineProperty(exports, "saveWeek", { enumerable: true, get: function () { return week_1.saveWeek; } });
|
|
165
|
+
Object.defineProperty(exports, "weekFigures", { enumerable: true, get: function () { return week_1.weekFigures; } });
|
|
166
|
+
Object.defineProperty(exports, "weekStartOf", { enumerable: true, get: function () { return week_1.weekStartOf; } });
|
|
167
|
+
Object.defineProperty(exports, "lastCompletedWeekStart", { enumerable: true, get: function () { return week_1.lastCompletedWeekStart; } });
|
|
168
|
+
Object.defineProperty(exports, "isMonday", { enumerable: true, get: function () { return week_1.isMonday; } });
|
|
169
|
+
Object.defineProperty(exports, "WEEK_SCHEMA", { enumerable: true, get: function () { return week_1.WEEK_SCHEMA; } });
|
|
170
|
+
Object.defineProperty(exports, "SMALLER_MODEL", { enumerable: true, get: function () { return week_1.SMALLER_MODEL; } });
|
|
171
|
+
var week_render_1 = require("./insights/week-render");
|
|
172
|
+
Object.defineProperty(exports, "renderWeek", { enumerable: true, get: function () { return week_render_1.renderWeek; } });
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type DollarRange, type PricingTable } from './pricing';
|
|
2
|
+
import type { InsightTurn } from './types';
|
|
3
|
+
import { type CompactSettings, type CompactWindow } from './compact-settings';
|
|
4
|
+
interface Boundary {
|
|
5
|
+
pre: number | null;
|
|
6
|
+
trigger: 'auto' | 'manual' | 'unknown';
|
|
7
|
+
at: number | null;
|
|
8
|
+
}
|
|
9
|
+
export interface CompactReplayTurn {
|
|
10
|
+
usage: InsightTurn;
|
|
11
|
+
boundary?: Boundary;
|
|
12
|
+
clear?: boolean;
|
|
13
|
+
gap?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CompactReplaySession {
|
|
16
|
+
id: string;
|
|
17
|
+
subagent: boolean;
|
|
18
|
+
turns: CompactReplayTurn[];
|
|
19
|
+
settings: CompactSettings;
|
|
20
|
+
incomplete: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CompactReplayRow {
|
|
23
|
+
window: number | null;
|
|
24
|
+
label: string;
|
|
25
|
+
current: boolean;
|
|
26
|
+
tokens: number | null;
|
|
27
|
+
usd: DollarRange | null;
|
|
28
|
+
compactions: number | null;
|
|
29
|
+
extraCompactions: number | null;
|
|
30
|
+
tokensSaved: number | null;
|
|
31
|
+
usdSaved: DollarRange | null;
|
|
32
|
+
tokenChangePercent: number | null;
|
|
33
|
+
usdChangePercent: number | null;
|
|
34
|
+
unavailable: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface CompactReplayReport {
|
|
37
|
+
version: string;
|
|
38
|
+
days: number;
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
basis: 'API list equivalent';
|
|
42
|
+
sessions: number;
|
|
43
|
+
subagentTranscripts: number;
|
|
44
|
+
responses: number;
|
|
45
|
+
measuredCompactions: number;
|
|
46
|
+
recorded: {
|
|
47
|
+
tokens: number;
|
|
48
|
+
usd: DollarRange | null;
|
|
49
|
+
compactions: number;
|
|
50
|
+
};
|
|
51
|
+
settings: Array<CompactWindow & {
|
|
52
|
+
model: string;
|
|
53
|
+
}>;
|
|
54
|
+
windows: CompactReplayRow[];
|
|
55
|
+
backtest: {
|
|
56
|
+
replayTokens: number | null;
|
|
57
|
+
recordedTokens: number;
|
|
58
|
+
errorTokens: number | null;
|
|
59
|
+
errorPercent: number | null;
|
|
60
|
+
unreliable: boolean;
|
|
61
|
+
complete: boolean;
|
|
62
|
+
};
|
|
63
|
+
suggestion: {
|
|
64
|
+
window: number;
|
|
65
|
+
command: string;
|
|
66
|
+
} | null;
|
|
67
|
+
diagnostics: {
|
|
68
|
+
unreadableFiles: number;
|
|
69
|
+
incompleteResponses: number;
|
|
70
|
+
duplicateResponses: number;
|
|
71
|
+
missingTimestamps: number;
|
|
72
|
+
malformedLines: number;
|
|
73
|
+
};
|
|
74
|
+
caveat: string;
|
|
75
|
+
notes: string[];
|
|
76
|
+
settingSource: string;
|
|
77
|
+
}
|
|
78
|
+
export interface CompactReplayOptions {
|
|
79
|
+
days?: number;
|
|
80
|
+
now?: number;
|
|
81
|
+
configDir?: string;
|
|
82
|
+
cwd?: string;
|
|
83
|
+
env?: NodeJS.ProcessEnv;
|
|
84
|
+
/** Explicit settings for fixture callers, with no home or project reads. */
|
|
85
|
+
settings?: CompactSettings;
|
|
86
|
+
rates?: PricingTable;
|
|
87
|
+
}
|
|
88
|
+
/** Pure numerical replay. No observed reset is forced into the automatic backtest. */
|
|
89
|
+
export declare function compactReplay(sessions: CompactReplaySession[], options: {
|
|
90
|
+
days: number;
|
|
91
|
+
now: number;
|
|
92
|
+
rates?: PricingTable;
|
|
93
|
+
diagnostics?: CompactReplayReport['diagnostics'];
|
|
94
|
+
}): CompactReplayReport;
|
|
95
|
+
export declare function collectCompactReplay(options?: CompactReplayOptions): Promise<CompactReplayReport>;
|
|
96
|
+
export declare function renderCompactReplay(report: CompactReplayReport): string;
|
|
97
|
+
export {};
|