@agentguard-run/burn 0.5.0 → 0.6.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/CHANGELOG.md +23 -0
- package/README.md +109 -9
- package/dist/src/cli.js +205 -21
- 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/calendar-render.js +2 -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/first-run.d.ts +12 -0
- package/dist/src/insights/first-run.js +17 -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 +35 -21
- package/dist/src/insights/sessions.d.ts +4 -0
- package/dist/src/insights/sessions.js +18 -2
- 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 +2 -2
- 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/dist/src/version.d.ts +2 -0
- package/dist/src/version.js +5 -0
- 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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.6.0 (2026-10-10)
|
|
6
|
+
|
|
7
|
+
A simple view by default and a compaction replay, so the first screen answers "how much is left and what do I change".
|
|
8
|
+
|
|
9
|
+
- The `agentguard-burn` wrapper (0.6.0) requires `@agentguard-run/burn` ^0.6.0, so `npx agentguard-burn` gets this release.
|
|
10
|
+
- 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.
|
|
11
|
+
- 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.
|
|
12
|
+
- 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.
|
|
13
|
+
- 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.
|
|
14
|
+
|
|
15
|
+
## 0.5.1 (2026-10-08)
|
|
16
|
+
|
|
17
|
+
First-run fixes, so the first command a new user runs gives a clear answer.
|
|
18
|
+
|
|
19
|
+
- No sessions yet: with no Claude Code or Codex sessions on the computer, `why`, `calendar` and `card` print the same friendly message, name the folders Burn checked, say what to do next and exit with code 0. No card image is created.
|
|
20
|
+
- `why --json` (and `why json`) always prints JSON to stdout. With no sessions it returns `found: false` with `looked_in`, `message`, `next` and `version`. A usage error or a missing session also returns JSON, with `found: false` and an `error` field, and keeps its exit code (64 or 4). A full report includes `version` and `found: true`, and `calendar --json` includes `version` too.
|
|
21
|
+
- Burn honors `CLAUDE_CONFIG_DIR` and `CODEX_HOME`: it reads `CLAUDE_CONFIG_DIR/projects` and `CODEX_HOME/sessions`, and falls back to `~/.claude/projects` and `~/.codex/sessions` when a variable is unset or empty.
|
|
22
|
+
- `why` and `calendar` text reports print the Burn version on the first line, for example `Burn 0.5.1 | AgentGuard why: <session>`.
|
|
23
|
+
- Shorter help: plain `npx agentguard-burn`, `help`, `--help` or `-h` shows three starting points (`why`, `calendar` and `card`). `--help all` lists every command.
|
|
24
|
+
- The `agentguard-burn` wrapper (0.5.1) now runs Burn as a child process, so Burn's exit codes pass through to your shell. It requires `@agentguard-run/burn` ^0.5.1, so `npx agentguard-burn` gets these fixes.
|
|
25
|
+
|
|
3
26
|
## 0.5.0 (2026-10-07)
|
|
4
27
|
|
|
5
28
|
- Price Claude Haiku 5.5 (`claude-haiku-5-5`), released on October 7, 2026: 0.1, 0.01, 0.125, 0.2 and 0.5 USD per million tokens for fresh input, cache read, five-minute write, one-hour write and output on prompts up to 100,000 tokens, and five times each above that. Before this row its turns were unpriced.
|
package/README.md
CHANGED
|
@@ -1,20 +1,95 @@
|
|
|
1
1
|
# @agentguard-run/burn
|
|
2
2
|
|
|
3
|
+
```sh
|
|
4
|
+
npx agentguard-burn why
|
|
5
|
+
```
|
|
6
|
+
|
|
3
7
|
See where a coding session's tokens went and what the next heavy turn could cost in time and limits. Burn explains recorded usage, warns about large cache rewrites and keeps its existing runaway-session circuit breaker. Runtime observation and enforcement stay on this machine. The developer review command below has an explicit external-ranking option.
|
|
4
8
|
|
|
5
|
-
##
|
|
9
|
+
## Start here
|
|
6
10
|
|
|
7
11
|
```sh
|
|
8
|
-
|
|
9
|
-
agentguard-burn
|
|
10
|
-
agentguard-burn
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
npx agentguard-burn why # your last session
|
|
13
|
+
npx agentguard-burn calendar # every day
|
|
14
|
+
npx agentguard-burn card # an image to share
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Press y if npm asks to install Burn. Plain `npx agentguard-burn` shows these three starting points. Use `npx agentguard-burn --help all` for every command and option.
|
|
18
|
+
|
|
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
|
+
|
|
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
|
+
|
|
29
|
+
### No sessions yet
|
|
30
|
+
|
|
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:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
No Claude Code or Codex sessions found on this computer yet.
|
|
35
|
+
Burn looked in <the actual folders it checked>.
|
|
36
|
+
Next: if you use Claude Code on another computer, run this there.
|
|
37
|
+
If Claude Code is new here, use it for a few minutes, then run npx agentguard-burn why again.
|
|
13
38
|
```
|
|
14
39
|
|
|
15
|
-
|
|
40
|
+
By default Burn checks `~/.claude/projects` and `~/.codex/sessions`. When `CLAUDE_CONFIG_DIR` is set, it checks `CLAUDE_CONFIG_DIR/projects` instead of the Claude default. When `CODEX_HOME` is set, it checks `CODEX_HOME/sessions` instead of the Codex default. Unset or empty variables keep the home-folder defaults.
|
|
16
41
|
|
|
17
|
-
`agentguard-burn --version`
|
|
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.
|
|
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`.
|
|
18
93
|
|
|
19
94
|
## Launch tree and signed approval tally
|
|
20
95
|
|
|
@@ -202,6 +277,25 @@ Multipliers relative to base input: 5m write 1.25x, 1h write 2x, cache read 0.1x
|
|
|
202
277
|
|
|
203
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.
|
|
204
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
|
+
|
|
205
299
|
## Why this session
|
|
206
300
|
|
|
207
301
|
```sh
|
|
@@ -228,7 +322,7 @@ After a `/compact`, an automatic compaction, a model switch, or a `/clear` that
|
|
|
228
322
|
|
|
229
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`.
|
|
230
324
|
|
|
231
|
-
`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.
|
|
232
326
|
|
|
233
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.
|
|
234
328
|
|
|
@@ -491,6 +585,10 @@ Runs the detectors over your existing history and shows what enforcement would
|
|
|
491
585
|
have intercepted, when, and the observed tail after each stop. It is an upper
|
|
492
586
|
bound, labelled as such. Nobody installs a blocker cold.
|
|
493
587
|
|
|
588
|
+
### Optional global install and hooks
|
|
589
|
+
|
|
590
|
+
A global install pins an old version: `npx agentguard-burn why` can keep using that global command instead of downloading a newer Burn. To run the latest release explicitly, use `npx agentguard-burn@latest why`. If you previously installed the scoped package globally, remove it with `npm rm -g @agentguard-run/burn`; for the wrapper, use `npm rm -g agentguard-burn`.
|
|
591
|
+
|
|
494
592
|
```
|
|
495
593
|
npm i -g @agentguard-run/burn
|
|
496
594
|
agentguard-burn init --write # merge the hook into ~/.claude/settings.json (backup taken)
|
|
@@ -499,6 +597,8 @@ agentguard-burn status # hook health, shadow observations, every
|
|
|
499
597
|
agentguard-burn enforce # after 7 days and 50 decisions
|
|
500
598
|
```
|
|
501
599
|
|
|
600
|
+
Without the write flag, `agentguard-burn init claude` and `agentguard-burn init codex` print hook configuration for review. Merge the relevant snippet into your host configuration. For Codex, review and trust the hook through `/hooks`. Upgrading an existing hook requires the new snippet: it matches every tool so pace can update on ordinary tool calls, while admission still gates spawns.
|
|
601
|
+
|
|
502
602
|
The hook installs in **shadow mode**: every decision is recorded, nothing is
|
|
503
603
|
blocked, until you have seen it be right. `status` shows what it would have
|
|
504
604
|
done so far, which sessions are live on every host, and whether each hook's
|
package/dist/src/cli.js
CHANGED
|
@@ -77,6 +77,8 @@ const eligibility_1 = require("./eligibility");
|
|
|
77
77
|
const tree_1 = require("./insights/tree");
|
|
78
78
|
const tally_1 = require("./insights/tally");
|
|
79
79
|
const sessions_1 = require("./insights/sessions");
|
|
80
|
+
const first_run_1 = require("./insights/first-run");
|
|
81
|
+
const version_1 = require("./version");
|
|
80
82
|
const transcript_1 = require("./insights/transcript");
|
|
81
83
|
const live_1 = require("./insights/live");
|
|
82
84
|
const attribution_1 = require("./insights/attribution");
|
|
@@ -90,6 +92,10 @@ const cli_1 = require("./idle/cli");
|
|
|
90
92
|
const telemetry_cli_1 = require("./telemetry-cli");
|
|
91
93
|
const status_fields_1 = require("./insights/status-fields");
|
|
92
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");
|
|
93
99
|
const HOME = process.env.AGENTGUARD_HOME ?? (0, node_path_1.join)((0, node_os_1.homedir)(), '.agentguard');
|
|
94
100
|
let finishReportNaturally = false;
|
|
95
101
|
const PROXY_HOSTS = ['ollama', 'vllm', 'lm-studio', 'openai-compatible'];
|
|
@@ -138,24 +144,54 @@ function shadowEligibility() {
|
|
|
138
144
|
return (0, eligibility_1.computeShadowEligibility)(readDecisions());
|
|
139
145
|
}
|
|
140
146
|
async function main(argv) {
|
|
141
|
-
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
|
+
};
|
|
142
161
|
const noColor = rawRest.includes('--no-color');
|
|
143
162
|
const rest = rawRest.filter(value => value !== '--no-color');
|
|
144
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 });
|
|
164
|
+
const showNoSessions = (lookedIn, json = false) => {
|
|
165
|
+
const report = (0, first_run_1.noSessionsReport)(lookedIn);
|
|
166
|
+
show({ kind: 'command', command: command, values: report }, json ? JSON.stringify(report) + '\n' : (0, first_run_1.renderNoSessions)(lookedIn), true);
|
|
167
|
+
return first_run_1.NO_SESSIONS_EXIT_CODE;
|
|
168
|
+
};
|
|
145
169
|
const flag = (name) => {
|
|
146
170
|
const i = rest.indexOf(name);
|
|
147
171
|
return i >= 0 ? rest[i + 1] : undefined;
|
|
148
172
|
};
|
|
149
173
|
const has = (name) => rawRest.includes(name);
|
|
150
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
|
+
}
|
|
151
186
|
case '--version':
|
|
152
187
|
case '-v':
|
|
153
188
|
// The version of this install, from the package that ships it, and nothing else.
|
|
154
|
-
process.stdout.write(`${
|
|
189
|
+
process.stdout.write(`${version_1.BURN_VERSION}\n`);
|
|
155
190
|
return 0;
|
|
156
191
|
case 'live': {
|
|
157
192
|
const { runLivePanel } = await Promise.resolve().then(() => __importStar(require('./live-panel')));
|
|
158
|
-
|
|
193
|
+
notice();
|
|
194
|
+
return runLivePanel(HOME, rawRest, simple ? 'simple' : 'detailed');
|
|
159
195
|
}
|
|
160
196
|
case 'record': {
|
|
161
197
|
const { recordLedger, recordLedgerArguments } = await Promise.resolve().then(() => __importStar(require('./record-ledger')));
|
|
@@ -241,6 +277,7 @@ async function main(argv) {
|
|
|
241
277
|
return 0;
|
|
242
278
|
}
|
|
243
279
|
case 'why': {
|
|
280
|
+
const json = rest.includes('json') || rest.includes('--json');
|
|
244
281
|
// `--lang en|es|pt` (or --lang=es) picks the report's language and is never a session selector.
|
|
245
282
|
// `--commits` adds the commits that landed while the session ran. It is the only way `why` runs git.
|
|
246
283
|
const args = [];
|
|
@@ -259,23 +296,61 @@ async function main(argv) {
|
|
|
259
296
|
else
|
|
260
297
|
args.push(rest[i]);
|
|
261
298
|
}
|
|
262
|
-
|
|
263
|
-
|
|
299
|
+
const selectors = args.filter(value => value !== 'json' && value !== '--json');
|
|
300
|
+
if ((langGiven && (0, i18n_1.whyLangOf)(lang) === null) || selectors.length > 1 || selectors.some(value => !value.trim() || value.startsWith('--'))) {
|
|
301
|
+
const error = 'Usage: agentguard-burn why [session] [json] [--lang en|es|pt]';
|
|
302
|
+
if (json)
|
|
303
|
+
process.stdout.write(JSON.stringify({ version: version_1.BURN_VERSION, found: false, error }) + '\n');
|
|
304
|
+
else
|
|
305
|
+
process.stderr.write(error + '\n');
|
|
264
306
|
return 64;
|
|
265
307
|
}
|
|
266
|
-
|
|
308
|
+
let location;
|
|
309
|
+
try {
|
|
310
|
+
location = (0, sessions_1.selectInsightTranscript)(selectors[0]);
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
if (error instanceof sessions_1.NoSessionsFoundError)
|
|
314
|
+
return showNoSessions(error.lookedIn, json);
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
267
317
|
const transcript = (0, transcript_1.readInsightSession)(location.path, { host: location.host, sessionId: location.sessionId });
|
|
268
|
-
|
|
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
|
+
}
|
|
269
343
|
// The commits reader is loaded only with the flag, so a plain `why` never reaches it.
|
|
270
344
|
const commits = withCommits ? await (await Promise.resolve().then(() => __importStar(require('./insights/commits')))).sessionCommits({ path: location.path }) : undefined;
|
|
271
345
|
const launchTree = (0, tree_1.readLaunchTree)(location);
|
|
272
346
|
const treeSection = launchTree.root.children.length || launchTree.unlinked.length ? '\n\n' + (0, tree_1.renderLaunchTree)(launchTree, true) : '';
|
|
273
347
|
const commitsValue = commits ? (0, render_2.commitsJson)(commits, transcript.state.forkHistoryBoundaryUnknown ? null : (0, render_2.sessionFigures)(transcript).attribution.totalTokens) : undefined;
|
|
274
|
-
|
|
275
|
-
|
|
348
|
+
const humanReport = json ? '' : (0, render_2.renderWhy)(transcript, (0, live_1.readPricing)(HOME, (0, pre_tool_use_1.loadPolicy)(HOME)), { tips: !quietOn(), lang: (0, i18n_1.detectWhyLang)({ flag: lang, env: process.env, intlLocale: intlLocale() }), ...(commits ? { commits } : {}) });
|
|
349
|
+
show({ kind: 'command', command, values: { session: transcript.sessionId, observations: transcript.observations, diagnostics: transcript.diagnostics, attribution: (0, attribution_1.attributeTurns)((0, transcript_2.deduplicateTurns)(transcript.turns)).buckets, prices: (0, transcript_2.deduplicateTurns)(transcript.turns).map(turn => (0, pricing_1.priceTurn)(turn, (0, live_1.readPricing)(HOME, (0, pre_tool_use_1.loadPolicy)(HOME)))), ...(commitsValue ? { commits: commitsValue } : {}) } }, json ? JSON.stringify({ version: version_1.BURN_VERSION, found: true, ...transcript, ...(treeSection ? { launchTree } : {}), ...(commitsValue ? { commits: commitsValue } : {}) }, null, 2) + '\n'
|
|
350
|
+
: (treeSection ? humanReport.replace('\n', treeSection + '\n\n') : humanReport) + '\n', true);
|
|
276
351
|
if (require.main === module && !json && transcript.turns.length) {
|
|
277
352
|
finishReportNaturally = true;
|
|
278
|
-
await (0, telemetry_cli_1.countFirstReport)(
|
|
353
|
+
await (0, telemetry_cli_1.countFirstReport)(version_1.BURN_VERSION);
|
|
279
354
|
}
|
|
280
355
|
return 0;
|
|
281
356
|
}
|
|
@@ -312,6 +387,48 @@ async function main(argv) {
|
|
|
312
387
|
show({ kind: 'command', command, values: { ...report } }, json ? JSON.stringify(report, null, 2) + '\n' : renderCompare(report, language) + '\n', json);
|
|
313
388
|
return 0;
|
|
314
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
|
+
}
|
|
315
432
|
case 'calendar': {
|
|
316
433
|
// `--weeks N` (1 to 53, also --weeks=N), `json`, and `--lang` exactly as `why` takes it.
|
|
317
434
|
const args = [];
|
|
@@ -347,11 +464,14 @@ async function main(argv) {
|
|
|
347
464
|
const { renderCalendar } = await Promise.resolve().then(() => __importStar(require('./insights/calendar-render')));
|
|
348
465
|
// The span fits the terminal: its columns on a TTY, 80 when piped.
|
|
349
466
|
const columns = process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 ? process.stdout.columns : 80;
|
|
350
|
-
const
|
|
467
|
+
const roots = (0, sessions_1.transcriptRoots)();
|
|
468
|
+
const data = collectCalendar({ home: HOME, roots, rates: (0, live_1.readPricing)(HOME, (0, pre_tool_use_1.loadPolicy)(HOME)) });
|
|
469
|
+
if (data.sources.transcripts + data.sources.rollupFiles + data.sources.unreadable === 0)
|
|
470
|
+
return showNoSessions(Object.values(roots), json);
|
|
351
471
|
if (!data.saved)
|
|
352
472
|
process.stderr.write(i18n_1.CALENDAR_TEXT[language].saveFailed + '\n');
|
|
353
473
|
const report = calendarReport(data, { now: Date.now(), columns, ...(weeks ? { weeks } : {}) });
|
|
354
|
-
show({ kind: 'calendar', report, lang: language, columns }, json ? JSON.stringify(report, null, 2) + '\n' : renderCalendar(report, language, columns) + '\n', json);
|
|
474
|
+
show({ kind: 'calendar', report, lang: language, columns }, json ? JSON.stringify({ version: version_1.BURN_VERSION, ...report }, null, 2) + '\n' : renderCalendar(report, language, columns) + '\n', json);
|
|
355
475
|
return 0;
|
|
356
476
|
}
|
|
357
477
|
case 'card': {
|
|
@@ -375,13 +495,16 @@ async function main(argv) {
|
|
|
375
495
|
return 64;
|
|
376
496
|
}
|
|
377
497
|
const { calendarReport, collectCalendar } = await Promise.resolve().then(() => __importStar(require('./insights/calendar')));
|
|
378
|
-
const
|
|
379
|
-
const data = collectCalendar({ home: HOME, rates: (0, live_1.readPricing)(HOME, (0, pre_tool_use_1.loadPolicy)(HOME)) });
|
|
498
|
+
const roots = (0, sessions_1.transcriptRoots)();
|
|
499
|
+
const data = collectCalendar({ home: HOME, roots, rates: (0, live_1.readPricing)(HOME, (0, pre_tool_use_1.loadPolicy)(HOME)) });
|
|
500
|
+
if (data.sources.transcripts + data.sources.rollupFiles + data.sources.unreadable === 0)
|
|
501
|
+
return showNoSessions(Object.values(roots));
|
|
380
502
|
const report = calendarReport(data, { now: Date.now(), weeks });
|
|
381
503
|
if (!(report.totals.tokens > 0)) {
|
|
382
504
|
process.stderr.write('No Claude Code or Codex usage is recorded on this machine for that span, so there is nothing to put on a card.\n');
|
|
383
505
|
return 1;
|
|
384
506
|
}
|
|
507
|
+
const { cardModel, renderCard } = await Promise.resolve().then(() => __importStar(require('./insights/card')));
|
|
385
508
|
(0, node_fs_1.writeFileSync)(out, await renderCard(cardModel(report)));
|
|
386
509
|
process.stdout.write(`Card saved: ${out} (1200x675). Dollars on it are API list prices, not a bill; nothing was uploaded.\n`);
|
|
387
510
|
return 0;
|
|
@@ -400,6 +523,44 @@ async function main(argv) {
|
|
|
400
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');
|
|
401
524
|
return 0;
|
|
402
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
|
+
}
|
|
403
564
|
case 'rewrites':
|
|
404
565
|
case 'ttl': {
|
|
405
566
|
// Like `why`: with no session, the newest top-level transcript plus its stored
|
|
@@ -438,16 +599,25 @@ async function main(argv) {
|
|
|
438
599
|
const raw = !process.stdin.isTTY ? readStdinJson() : null;
|
|
439
600
|
const payload = (raw && typeof raw === 'object' ? raw : {});
|
|
440
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);
|
|
441
605
|
let location;
|
|
442
606
|
try {
|
|
443
607
|
location = (0, sessions_1.selectInsightTranscript)(payload.transcript_path || selectors[0] || payload.session_id);
|
|
444
608
|
}
|
|
445
609
|
catch {
|
|
446
|
-
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');
|
|
447
612
|
return 0;
|
|
448
613
|
}
|
|
449
614
|
const session = payload.session_id || location.sessionId;
|
|
450
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
|
+
}
|
|
451
621
|
const metrics = await (0, status_data_1.readStatusMetrics)(HOME, location.path, fields, process.env.PLUGIN_DATA || process.env.CLAUDE_PLUGIN_DATA, true);
|
|
452
622
|
const burn = (0, status_data_1.readStatusBurn)(HOME, session);
|
|
453
623
|
if (!(0, node_fs_1.existsSync)((0, node_path_1.join)(HOME, 'sessions')) && metrics.totalTokens !== undefined)
|
|
@@ -693,8 +863,13 @@ async function main(argv) {
|
|
|
693
863
|
: `Override recorded for the next ${override_1.OVERRIDE_WINDOW_MS / 60000} minutes, on any host: "${reason}"\n (agentguard-burn resume --clear to end it early)\n`);
|
|
694
864
|
return 0;
|
|
695
865
|
}
|
|
696
|
-
default:
|
|
697
|
-
|
|
866
|
+
default: {
|
|
867
|
+
const starter = ' why: your last session\n calendar: every day\n card: an image to share\n';
|
|
868
|
+
if (!(command === 'help' || command === '--help' || command === '-h') || rest[0] !== 'all') {
|
|
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);
|
|
870
|
+
return !command || command === 'help' || command === '--help' || command === '-h' ? 0 : 64;
|
|
871
|
+
}
|
|
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' +
|
|
698
873
|
' ps [--json] local agent processes, held memory and workspace disk\n' +
|
|
699
874
|
' render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone] local recorded-run export\n' +
|
|
700
875
|
' render <run.jsonl> --mp4 <out.mp4> --dashboard [--wide] [--economics <blocks.json>] dashboard export\n' +
|
|
@@ -712,8 +887,10 @@ async function main(argv) {
|
|
|
712
887
|
' --commits count the commits that landed in its git repository while it ran (runs git on this computer; off by default)\n' +
|
|
713
888
|
' compare [sessionA] [sessionB] two sessions side by side: tokens, cache, sub-agents, rewrites, list USD; json and --lang as for why\n' +
|
|
714
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' +
|
|
715
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' +
|
|
716
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' +
|
|
717
894
|
' ttl [session|all] one-hour cache lifetime counterfactual from your own idle gaps\n' +
|
|
718
895
|
' pace [session] ten-minute pace and next-hour projection\n' +
|
|
719
896
|
' statusline [session] one local status line; fields via AGENTGUARD_STATUS_FIELDS or the fields flag\n' +
|
|
@@ -721,7 +898,7 @@ async function main(argv) {
|
|
|
721
898
|
' pricing verified model rates and local overrides\n' +
|
|
722
899
|
' replay [files...] [--json] [--top N] [--min-tokens N]\n' +
|
|
723
900
|
' import-bench <run-dir> [--out <directory>] [--publisher-key-id ID] verify and convert a signed bundle\n' +
|
|
724
|
-
' replay <replay.json> --pricing <snapshot.json> [--json]
|
|
901
|
+
' replay <replay.json> --pricing <snapshot.json> [--json] replay a saved run with its original prices\n' +
|
|
725
902
|
' calibrate fit thresholds to your history (writes shadow policy)\n' +
|
|
726
903
|
' status mode, shadow observations, eligibility, hook health, every host\n' +
|
|
727
904
|
' init [claude|cursor|codex] [--write] print the hook snippet, or merge it into the config (with a backup)\n' +
|
|
@@ -730,12 +907,14 @@ async function main(argv) {
|
|
|
730
907
|
' resume --once --reason "..." let the next STOP through, once, on any host\n' +
|
|
731
908
|
' resume --reason "..." let STOPs through for 15 minutes; --clear ends it\n' +
|
|
732
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' +
|
|
733
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' +
|
|
734
|
-
' conformance
|
|
912
|
+
' conformance check that each host stops the same runaway patterns\n' +
|
|
735
913
|
'Developer review commands (never installed as hooks):\n' +
|
|
736
914
|
' guard-candidates [--ledger <local.ndjson>] [--out <name.review.json>] [--rank]\n' +
|
|
737
|
-
'
|
|
915
|
+
' group recorded commands; --rank sends them to an external ranking service\n', true);
|
|
738
916
|
return !command || command === 'help' || command === '--help' || command === '-h' ? 0 : 64;
|
|
917
|
+
}
|
|
739
918
|
}
|
|
740
919
|
}
|
|
741
920
|
async function run() {
|
|
@@ -801,6 +980,11 @@ if (require.main === module)
|
|
|
801
980
|
process.exitCode = code;
|
|
802
981
|
else
|
|
803
982
|
exit(code); }, (error) => {
|
|
804
|
-
|
|
983
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
984
|
+
if (process.argv[2] === 'why' && process.argv.slice(3).some(arg => arg === 'json' || arg === '--json')) {
|
|
985
|
+
process.stdout.write(JSON.stringify({ version: version_1.BURN_VERSION, found: false, error: message }) + '\n');
|
|
986
|
+
}
|
|
987
|
+
else
|
|
988
|
+
process.stderr.write(message + '\n');
|
|
805
989
|
exit(4);
|
|
806
990
|
});
|
|
@@ -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;
|