context-doctor 0.52.0 → 0.53.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/README.md CHANGED
@@ -34,7 +34,7 @@ Each takes about a minute and is fully reversible. Work somewhere else? Same ide
34
34
  | **claude.ai, ChatGPT, phone apps** | `npx context-doctor instructions --copy`, then paste into the app's personal preferences (it tells you where). ChatGPT can also reach the MCP server at a URL ([how](./docs/chat-apps.md#chatgpt)) |
35
35
  | **Your own app on an LLM API** | Run `npx context-doctor proxy --autopilot` and point `ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL` (add `/v1`) or `GOOGLE_GEMINI_BASE_URL` at the proxy on `127.0.0.1:8787`, plain HTTP ([exact values](./docs/proxy.md)). No proxy possible? Wrap the SDK client: `withContextDoctor(new Anthropic())` ([library](./docs/library.md)) |
36
36
  | **Python / RAG pipelines** | `pip install "git+https://github.com/KushalP1/context-doctor#subdirectory=python"` (PyPI release coming), then `pack_documents(retrieved_docs, question, budget=4000)` trims LangChain or LlamaIndex results to the chunks that matter. [Python README](./python/README.md) |
37
- | **GitHub pull requests** | `uses: KushalP1/context-doctor@v0.52.0` comments how much a PR grows CLAUDE.md, AGENTS.md and rules, and can fail over a budget ([setup](./docs/ci.md)) |
37
+ | **GitHub pull requests** | `uses: KushalP1/context-doctor@v0.53.0` comments how much a PR grows CLAUDE.md, AGENTS.md and rules, and can fail over a budget ([setup](./docs/ci.md)) |
38
38
 
39
39
  ## What it does
40
40
 
@@ -44,7 +44,7 @@ Each takes about a minute and is fully reversible. Work somewhere else? Same ide
44
44
  - `overhead`: what every request re-reads before your message (system prompt, tools, MCP servers, CLAUDE.md, rules, memory), each file priced per month.
45
45
  - `tasks`, `reads`, `subagents`, `compactions`: cost per commit; files read into session after session; whether each subagent was cheaper than the same steps in the parent; whether sessions work worse after compacting.
46
46
  - `cache-misses`: requests that re-wrote the prompt cache while it should still have been warm, priced, by model and context size, with the cause where the transcript shows one. And the cold returns (back after the cache expired): each one as billed, compacted on return, and kept warm by a cache read every 55 minutes, by how long you were away; what keeping warm for up to 1-8 hours would have netted; and a compacted segment the Desktop app put back ([#107157](https://github.com/anthropics/claude-code/issues/107157)).
47
- - `limits`: your plan's weekly and 5-hour windows (Claude Pro, Max and Ultra, which has no 5-hour window; recorded by the plugin's mod, the status line or the proxy) and Codex's, the pace and when each runs out, what 1M tokens of each kind cost in % of the limit, and for each weekly window the API-equivalent dollars and tokens per 1%, by entrypoint and model, with every move in that figure dated and checked against the model mix (a week moved to a model that uses the limit faster per dollar is said to be the mix, not the limit draining faster), and, when a limit ran out and Claude Code kept going on usage credits, when and about how much (or, with extra usage on and the weekly limit on pace to run out early, about how much the hours until the reset would cost). `limits --report` prints it as a block to paste into a bug report, with no prompts, paths or ids.
47
+ - `limits`: your plan's weekly and 5-hour windows (Claude Pro, Max and Ultra, which has no 5-hour window; recorded by the plugin's mod, the status line or the proxy) and Codex's, the pace and when each runs out, what 1M tokens of each kind cost in % of the limit, and for each weekly window the API-equivalent dollars and tokens per 1%, by entrypoint and model, with every move in that figure dated and checked against the model mix (a week moved to a model that uses the limit faster per dollar is said to be the mix, not the limit draining faster), what a full 5-hour window costs of the weekly limit and whether that moved (both windows count the same requests, so the model mix cannot explain a move in it), and, when a limit ran out and Claude Code kept going on usage credits, when and about how much (or, with extra usage on and the weekly limit on pace to run out early, about how much the hours until the reset would cost). `limits --report` prints it as a block to paste into a bug report, with no prompts, paths or ids.
48
48
  - `cache-plan <request.json>`: where an Anthropic API request should carry `cache_control`, and what it saves over N calls.
49
49
  - `session`, `watch`, `analyze`, `report`, `dashboard`: token breakdown and wasted-context findings for any session, conversation file or agent trace.
50
50
 
@@ -169,7 +169,7 @@ Rules 1-4 end exactly at character 512, the part ChatGPT's guide says must stand
169
169
  | `context-doctor subagents [--days n]` | Which subagents paid for themselves: each one's bill vs the same steps run in the parent session (read through the transcript cache: 15 s to 0.3 s warm on the author's machine) |
170
170
  | `context-doctor compactions [--days n]` | Do sessions work worse right after compacting? Re-reads, tool errors and your corrections, before vs after each compaction |
171
171
  | `context-doctor cache-misses [--days n]` | Requests that re-wrote the prompt cache within its lifetime (no compaction between, previous context over 20k, over 60% of it written again): priced above the cache-read rate, by model and context size, with the cause where visible and the model versions that miss less; by Claude Code version, with step changes after an upgrade flagged (the 1-hour cache share, the first request's size, a model's miss rate). Then the cold returns, each replayed as billed, compacted on return and kept warm (a cache read every 55 min while away, 4.5 on a 5-minute cache), by time away (<1h to >8h); keeping warm for up to 1, 2, 4 and 8 hours priced with every ping a timer would send; #107157's re-added compacted segment with its re-write; and requests the cache never saw (no cache write, most of the prompt billed as new input, [#111948](https://github.com/anthropics/claude-code/issues/111948)) by Claude Code version, priced against a working cache; `--json` per model and version |
172
- | `context-doctor limits [--days n] [--report [--copy]]` | Your plan's limits in their own unit: each window's %, pace (from the window's reset when it began within the last hour, or day for a weekly one) and run-out time (Claude's weekly and 5-hour windows, from the readings the plugin's mod, the status line or the proxy record; Ultra has no 5-hour window; Codex's from its rollouts), and % of the limit per 1M tokens of input, cache read, cache write and output, fitted on your readings with the fit's error; too-thin data is said to be thin, never quoted. Each weekly window, reset to reset: API-equivalent $ and tokens per 1%, split by entrypoint (`cli`, `claude-desktop`, `sdk-cli`) and model, and where that moved, by how much and on what date, checked against the model mix (a move the mix explains is said to be the mix, not the limit draining faster). With extra usage on and the weekly limit on pace to run out before its reset, one line says about how many dollars the hours until the reset would go on usage credits (at the last 24 hours' pace, list prices, an estimate). When a limit ran out and Claude Code kept going on usage credits (extra usage), one line says when, how many requests and about how much at API list prices (an estimate), from the API's own headers where the proxy read them, else inferred from a 100% reading and said to be. `--report`: the same as a block to paste into a GitHub issue (no prompts, paths, session or account ids) |
172
+ | `context-doctor limits [--days n] [--report [--copy]]` | Your plan's limits in their own unit: each window's %, pace (from the window's reset when it began within the last hour, or day for a weekly one) and run-out time (Claude's weekly and 5-hour windows, from the readings the plugin's mod, the status line or the proxy record; Ultra has no 5-hour window; Codex's from its rollouts), and % of the limit per 1M tokens of input, cache read, cache write and output, fitted on your readings with the fit's error; too-thin data is said to be thin, never quoted. Each weekly window, reset to reset: API-equivalent $ and tokens per 1%, split by entrypoint (`cli`, `claude-desktop`, `sdk-cli`) and model, and where that moved, by how much and on what date, checked against the model mix (a move the mix explains is said to be the mix, not the limit draining faster). One line says what a full 5-hour window costs of the weekly limit (the weekly rise over the 5-hour rise between the same readings, with its error), about how many fit in a week, and whether that moved, from what to what and at which weekly reset (both windows count the same requests, so the model mix cannot explain it); too-thin data is said to be thin, with no figure, and a plan with no 5-hour window gets no line. Codex's 5-hour and weekly windows the same way. With extra usage on and the weekly limit on pace to run out before its reset, one line says about how many dollars the hours until the reset would go on usage credits (at the last 24 hours' pace, list prices, an estimate). When a limit ran out and Claude Code kept going on usage credits (extra usage), one line says when, how many requests and about how much at API list prices (an estimate), from the API's own headers where the proxy read them, else inferred from a 100% reading and said to be. `--report`: the same as a block to paste into a GitHub issue (no prompts, paths, session or account ids) |
173
173
  | `context-doctor cache-plan <request.json> [--calls n] [--out file] [--explicit]` | Where an Anthropic API request should carry `cache_control` (top-level automatic caching for the moving end, unless `--explicit`), and what it saves over n calls; `--out` writes it applied |
174
174
  | `context-doctor accuracy` | How much of what you are billed for is visible in your transcript (the fixed harness baseline, per-turn injected content), plus a tokenizer check: real chars/token per model from the API's own counts, next to the ratio the estimator uses |
175
175
  | `context-doctor report` | Machine-wide impact report (proxy savings persist across restarts): exact proxy savings, hook activity, how often the cold-resume `/compact` offer was followed by a compaction, recoverable waste in recent sessions |
@@ -188,6 +188,7 @@ Rules 1-4 end exactly at character 512, the part ChatGPT's guide says must stand
188
188
 
189
189
  ## What's new
190
190
 
191
+ - **0.53 The 5-hour window's share of the week, warnings for the Claude Code you run, and a price check that checks prices**: `limits` says what a full 5-hour window costs of your weekly limit (the author's: 16.1%, about 6 a week, unchanged since Nov 16), the one limit figure your model mix cannot move, and flags it with a date when it does; Codex's windows too. `fix` warns about an old Claude Code only where your sessions run: the Desktop app's own for the Desktop tools lever, and a terminal install no session used is said to be unused. The Desktop tools lever is priced net of re-loading tools after compactions (claude-code #111915; 22 of the author's 39 compactions). The weekly price check compares every figure on OpenAI's, Anthropic's and Google's price pages with ours, not only that a model has a price: it fixed GPT-6 Rosalind (we charged 1.5x), GPT-6 Astra for Law's missing long-prompt tier and four unpriced healthcare models, and an ending promotion is now its own step so it cannot hide a new red ([details](./ROADMAP.md#shipped-in-0530-the-5-hour-windows-share-of-the-week-warnings-for-the-claude-code-you-run-and-a-price-check-that-checks-prices)).
191
192
  - **0.52 An honest empty state, a sample report, and one command up front**: with nothing of yours to replay, `savings` says so, offers `savings --sample`, the same report on generated example sessions, labelled SAMPLE, and says when to run it again; the measured report's footer says it too. `doctor` no longer says "All good" when nothing is protected: the verdict distinguishes no supported app, installed-but-not-wired ("not actively protecting any workflow") and wired. The README leads with one audience and one command, the savings figure captioned as measured on the author's own sessions, the other surfaces in a table. A new bug-report template asks for `doctor` output and `limits --report`, never transcripts; security reports go through private advisories ([details](./ROADMAP.md#shipped-in-0520-an-honest-empty-state-a-sample-report-and-one-command-up-front)).
192
193
  - **0.51 Limits that tell the model mix from the limit, proof before a lever, and the cache in the usage pane**: `limits` no longer reads a switch to a hungrier model as the limit draining faster: it says when the move comes from your model mix, and claims a drain only when what is left is 1.5x or more. `limits` and `budget` say when the weekly limit would run out at your current pace and, with extra usage on, about what would go on usage credits before the reset; `budget` counts what credits already paid. The mod records which tools the Desktop app hands over, so `fix` and `doctor` confirm or withdraw `desktop-tools-defer` before you apply it. The `/context-doctor-usage` pane shows how long the cache stays warm and what your next message costs now and after it expires. `cache-misses` and `doctor` count requests the cache never saw (claude-code #111948). Progress summaries are priced in the form Claude Code really sends on your setup; `overhead` gives one total; `doctor` shows the Desktop app's auto-compact offer. Fixes: "1000k" for a 1M window, a flaky download-budget test, the ledger path `doctor` names ([details](./ROADMAP.md#shipped-in-0510-limits-that-tell-the-model-mix-from-the-limit-proof-before-a-lever-and-the-cache-in-the-usage-pane)).
193
194
  - **0.50 The Desktop app's own tools, money past the limit, a Codex status line, and two audits**: `fix --apply desktop-tools-defer` has the mod keep the Desktop app's own tools (browser, terminal, sessions, visualize) behind tool search until a session needs them (about $70 a month on the author's history; opt-in, undo with `fix undo`). `limits` says when a plan limit ran out and usage credits paid, `spend` splits dollars inside the plan and past it, `doctor` says whether extra usage is on. `compact-window` and `fix` read the window the Desktop app offered and your answer. Progress summaries are priced on the small model Claude Code 2.1.328 uses. Codex users can turn on a status line served by the MCP server. Gemini 4 Neon is priced. Two audits fixed 14 issues: a crash on a bad date, `limits` reading pace from a burst after a reset, subagent counts that disagreed, a false "contracted rates" warning, and more ([details](./ROADMAP.md#shipped-in-0500-the-desktop-apps-own-tools-money-past-the-limit-a-codex-status-line-and-two-audits)).
package/dist/cli.js CHANGED
@@ -60,7 +60,8 @@ import { analyzeCacheUsage, renderCacheReport } from "./cache.js";
60
60
  import { renderToolTimings } from "./timing.js";
61
61
  import { packContextSemantic, readSources, renderPack } from "./pack.js";
62
62
  import { measureBaselines, measureMcpSizes, overheadReport, renderOverhead } from "./overhead.js";
63
- import { CALL_ROWS, deferrableApp, deferrableConfigured, measureStarts, START_ROWS } from "./starts.js";
63
+ import { CALL_ROWS, deferrableApp, deferrableConfigured, measureStarts, RELOAD_ROWS, sessionHosts, START_ROWS } from "./starts.js";
64
+ import { HOST_ROWS } from "./limits.js";
64
65
  import { DEFER_APP_TOOLS_ENV } from "./mod/logic.js";
65
66
  import { applySplit, planSplit, renderSplit } from "./split.js";
66
67
  import { ciReport, renderCiMarkdown, renderCiText } from "./ci.js";
@@ -428,8 +429,8 @@ async function measureFixInputs(days) {
428
429
  const configured = claudeMcpConfigs(cwd).some((c) => c.scope !== ".mcp.json");
429
430
  // Each transcript read once for every replay below; what an earlier run kept is not read again (scan.ts).
430
431
  prescan([
431
- { paths: claudeTranscripts(days), extractors: [savingsRows(!autopilotOnNow), REQUEST_ROWS, TOOL_OUTPUT_ROWS, START_ROWS, CALL_ROWS] },
432
- { paths: subagentTranscripts(Date.now() - days * 86_400_000), extractors: [REQUEST_ROWS, SUBAGENT_ROWS, TOOL_OUTPUT_ROWS, PROGRESS_ROWS, START_ROWS, CALL_ROWS] },
432
+ { paths: claudeTranscripts(days), extractors: [savingsRows(!autopilotOnNow), REQUEST_ROWS, TOOL_OUTPUT_ROWS, START_ROWS, CALL_ROWS, HOST_ROWS, RELOAD_ROWS] },
433
+ { paths: subagentTranscripts(Date.now() - days * 86_400_000), extractors: [REQUEST_ROWS, SUBAGENT_ROWS, TOOL_OUTPUT_ROWS, PROGRESS_ROWS, START_ROWS, CALL_ROWS, RELOAD_ROWS] },
433
434
  ...(setWindow === undefined ? [{ paths: claudeTranscripts(60), extractors: [QUALITY_ROWS] }] : []),
434
435
  { paths: codexRollouts(Date.now() - days * 86_400_000), extractors: [CODEX_COMPACT_ROWS] },
435
436
  ], replaying.tick);
@@ -508,7 +509,7 @@ async function measureFixInputs(days) {
508
509
  userSettings = JSON.parse(readFileSync(join(claudeDir(), "settings.json"), "utf8")) ?? {};
509
510
  }
510
511
  catch { /* none */ }
511
- const starts = measureStarts({ days, cwd });
512
+ const starts = measureStarts({ days, cwd, compactions: true });
512
513
  const deferrable = configured ? deferrableConfigured(starts) : [];
513
514
  const appTools = deferrableApp(starts);
514
515
  // CONTEXT_DOCTOR_DEFER_MCP: the user's settings.json env (fix writes it there), else a shell's own value (not the session's copy of a settings value).
@@ -545,7 +546,7 @@ async function measureFixInputs(days) {
545
546
  mcpServers: toolSearchOff ? servers.length : 0,
546
547
  prune: prunePlan,
547
548
  ...(deferrable.length ? { mcpDefer: { servers: deferrable, days } } : {}),
548
- ...(appTools.length ? { desktopTools: { servers: appTools.map((s) => ({ name: s.name, tools: s.tools, tokens: s.tokens, starts: s.starts, calledStarts: s.calledStarts, usd: s.usd, unusedUsd: s.unusedUsd, calledUsd: s.calledUsd })), days } } : {}),
549
+ ...(appTools.length ? { desktopTools: { servers: appTools.map((s) => ({ name: s.name, tools: s.tools, tokens: s.tokens, starts: s.starts, calledStarts: s.calledStarts, usd: s.usd, unusedUsd: s.unusedUsd, calledUsd: s.calledUsd })), days, ...(starts.compactions ? { compactions: starts.compactions } : {}) } } : {}),
549
550
  ...(desktopToolsSet ? { desktopToolsSet } : {}),
550
551
  // What context-doctor's mod saw Claude Code hand over (apptools.ts): proof the lever reaches the app, or why not.
551
552
  ...(appToolsSeen.length ? { appToolsSeen } : {}),
@@ -563,6 +564,8 @@ async function measureFixInputs(days) {
563
564
  recordProblem,
564
565
  // The installs a setting is too new for are named on its fix.
565
566
  claudeCodeInstalls: claudeCodeInstallsFromEnv(),
567
+ // …and whether any of the period's sessions ran on them.
568
+ sessionHosts: sessionHosts(claudeTranscripts(days), Date.now() - days * 86_400_000),
566
569
  coldResume: { netUsd: Math.max(0, report.coldResumeNetUsd), returns: report.coldResumes, hooked: claudePluginEnabled() || /context-doctor|cli\.js"?\s+hook/.test(JSON.stringify(userSettings.hooks?.UserPromptSubmit ?? [])) },
567
570
  ...(keepWarm ? { keepWarm } : {}),
568
571
  },
package/dist/fix.d.ts CHANGED
@@ -40,6 +40,7 @@
40
40
  */
41
41
  import { type CacheTtlReport, type CurrentTtl } from "./cachettl.js";
42
42
  import { type ClaudeCodeInstall } from "./modelswitch.js";
43
+ import type { SessionHost } from "./starts.js";
43
44
  import { type ProjectPlan } from "./prune.js";
44
45
  import { type DeferEntry } from "./mcpdefer.js";
45
46
  import { type ToolsLine } from "./apptools.js";
@@ -81,6 +82,20 @@ export interface Fix {
81
82
  tooOld?: string;
82
83
  /** More lines under it in the plan (the subagents' model: per agent type). */
83
84
  detail?: string[];
85
+ /**
86
+ * desktop-tools-defer: the tool loads compactions would have cost with the
87
+ * servers behind tool search (#111915: loaded tools are deferred again after
88
+ * a compaction). `reloads` counts each server once per compaction, over
89
+ * `compactions` of the period's `ofCompactions`; `usd` is already taken off
90
+ * `savedUsd`.
91
+ */
92
+ reloadsAfterCompaction?: {
93
+ reloads: number;
94
+ compactions: number;
95
+ ofCompactions: number;
96
+ usd: number;
97
+ unpriced?: number;
98
+ };
84
99
  }
85
100
  /** The measurements a plan is made from (so the plan itself is testable without a machine's history). */
86
101
  export interface FixInputs {
@@ -158,6 +173,12 @@ export interface FixInputs {
158
173
  codexCompact?: CodexCompactReport;
159
174
  /** The Claude Code installs found here (CLI and desktop app), to name the ones a setting is too new for. */
160
175
  claudeCodeInstalls?: ClaudeCodeInstall[];
176
+ /**
177
+ * The entrypoints and versions the period's sessions ran on (starts.ts
178
+ * sessionHosts): an install too old for a setting that ran none of them is
179
+ * still named, with "no session ran there".
180
+ */
181
+ sessionHosts?: SessionHost[];
161
182
  /** model_auto_compact_token_limit at the top of the user's config.toml, as written: never overwritten. */
162
183
  codexCompactSet?: {
163
184
  raw: string;
@@ -203,6 +224,15 @@ export interface FixInputs {
203
224
  calledUsd?: number;
204
225
  }>;
205
226
  days: number;
227
+ /** The period's compactions and, per compaction, each server called after it with what loading it again would cost (starts.ts; #111915). */
228
+ compactions?: {
229
+ total: number;
230
+ after: Array<Array<{
231
+ server: string;
232
+ usd: number;
233
+ unpriced?: true;
234
+ }>>;
235
+ };
206
236
  };
207
237
  /** CONTEXT_DOCTOR_DEFER_MCP where the user (or fix) set it: applied, never overwritten. */
208
238
  desktopToolsSet?: {
package/dist/fix.js CHANGED
@@ -72,6 +72,38 @@ export const DESKTOP_TOOLS_DEFER_SINCE = "2.1.326";
72
72
  * is not in 2.1.62 and the changelog does not say when it came: not named.
73
73
  */
74
74
  const SINCE = { "mcp-defer": MCP_DEFER_SINCE, "desktop-tools-defer": DESKTOP_TOOLS_DEFER_SINCE, "cache-ttl": CACHE_TTL_SINCE, "cache-ttl-subagents": CACHE_TTL_SINCE, "tool-output": BASH_OUTPUT_SINCE, "progress-summaries": PROGRESS_SUMMARIES_SINCE };
75
+ /** Levers that act only in the Desktop app: an old CLI elsewhere on the machine never reads them. */
76
+ const DESKTOP_ONLY = new Set(["desktop-tools-defer"]);
77
+ /**
78
+ * Whether any of the period's sessions could have run on this install: the
79
+ * app's own when a Desktop session ran; a CLI's when a session outside the
80
+ * app ran its version or an older one (the same binary before an update).
81
+ * Unknown (no sessions recorded) counts as ran.
82
+ */
83
+ function ranThere(c, hosts) {
84
+ if (!hosts?.length)
85
+ return true;
86
+ if (c.source === "desktop app")
87
+ return hosts.some((h) => h.entrypoint === "claude-desktop");
88
+ return hosts.some((h) => h.entrypoint !== "claude-desktop" && (h.version === undefined || compareVersions(h.version, c.version) <= 0));
89
+ }
90
+ /**
91
+ * "Claude Code 2.1.311 (…) predates this setting …: update it for it to take
92
+ * effect there", and, for an install none of the period's sessions ran on,
93
+ * that none did. Kept rather than dropped: the setting sits in the
94
+ * settings.json every Claude Code here reads, so a session started there
95
+ * tomorrow would still ignore it; it just did not cost the figure above.
96
+ */
97
+ function tooOldLine(old, since, hosts, days) {
98
+ const one = (n, a, b) => (n === 1 ? a : b);
99
+ const ran = old.filter((c) => ranThere(c, hosts));
100
+ const idle = old.filter((c) => !ranThere(c, hosts));
101
+ const none = `no session ran there in the last ${days} days`;
102
+ if (!ran.length)
103
+ return `${describeInstalls(idle)} ${one(idle.length, "predates", "predate")} this setting (Claude Code ${since}+) and ${one(idle.length, "ignores", "ignore")} it, but ${none}: update ${one(idle.length, "it", "them")} before you use ${one(idle.length, "it", "them")} again`;
104
+ const line = `${describeInstalls(ran)} ${one(ran.length, "predates", "predate")} this setting (Claude Code ${since}+) and ${one(ran.length, "ignores", "ignore")} it: update ${one(ran.length, "it", "them")} for it to take effect there`;
105
+ return idle.length ? `${line}; ${describeInstalls(idle)} ${one(idle.length, "is", "are")} older too, but ${none}` : line;
106
+ }
75
107
  /** Below this a priced fix is not worth a setting. */
76
108
  const MIN_USD = 1;
77
109
  export const money = (n) => (n >= 100 ? `$${Math.round(n).toLocaleString("en-US")}` : `$${n.toFixed(2)}`);
@@ -312,7 +344,18 @@ export function planFixes(i) {
312
344
  const verdict = i.appToolsSeen ? appToolsVerdict(i.appToolsSeen, candidates.map((s) => s.name)) : undefined;
313
345
  const pick = verdict ? candidates.filter((s) => verdict.reach.some((r) => r.server === s.name)) : candidates;
314
346
  const kept = dt.servers.filter((s) => !pick.includes(s)).map((s) => s.name);
315
- const usd = pick.reduce((t, s) => t + s.unusedUsd, 0);
347
+ const gross = pick.reduce((t, s) => t + s.unusedUsd, 0);
348
+ // #111915: after a compaction, a tool loaded through tool search is deferred again, so the first call to each
349
+ // moved server after a compaction loads it once more. Each such load is taken off the figure.
350
+ const names = new Set(pick.map((s) => s.name));
351
+ const hit = (dt.compactions?.after ?? []).map((c) => c.filter((r) => names.has(r.server))).filter((c) => c.length);
352
+ const reloadUsd = hit.reduce((t, c) => t + c.reduce((x, r) => x + r.usd, 0), 0);
353
+ const reloads = hit.reduce((t, c) => t + c.length, 0);
354
+ const unpricedReloads = hit.reduce((t, c) => t + c.filter((r) => r.unpriced).length, 0);
355
+ const usd = gross - reloadUsd;
356
+ const after = reloads
357
+ ? `. Less ${money(reloadUsd)}${unpricedReloads ? ` (${unpricedReloads} on a model with no price, not counted)` : ""} for loading them again after compactions: a compaction puts loaded tools back behind tool search, and ${hit.length} of the ${dt.compactions.total} compactions in those days were followed by a call to one of them (${reloads} load${reloads === 1 ? "" : "s"}, a server once per compaction, each priced as one more request at the context then plus the tool's definition)`
358
+ : "";
316
359
  if (verdict && candidates.length && !pick.length) {
317
360
  // Withdrawn before anyone applies it, with the reason the mod saw.
318
361
  fixes.push({ id: "desktop-tools-defer", title: "The Desktop app's own tools behind tool search", basis: "", quality: "", change: "", state: "not-here", note: `not offered: ${verdictLines(verdict).join(" ")}` });
@@ -326,8 +369,9 @@ export function planFixes(i) {
326
369
  id: "desktop-tools-defer",
327
370
  title: `Keep the Desktop app's own tools behind tool search (${pick.map((s) => s.name).join(", ")})`,
328
371
  savedUsd: usd,
329
- basis: `the Desktop app sends these tools' definitions whole into every session and subagent start, and each step re-reads them: ${pick.map((s) => `${s.name} ~${s.tokens < 1000 ? s.tokens : k(s.tokens)} tokens, called in ${s.calledStarts} of ${s.starts} starts`).join("; ")}. The figure is what that cost in the ${i.desktopTools.days} days' starts that never called them (${money(all)} counting the ones that did${exact ? "" : ", as overhead lists it"}; those would load a tool through tool search instead)`,
330
- quality: `Claude loads one of these tools through tool search the first time a conversation needs it: one more step then. Kept in front: ${[...KEEP_APP_SERVERS, ...kept.filter((n) => !KEEP_APP_SERVERS.includes(n))].join(", ")} (called in most sessions). It takes effect in new sessions only, so no running conversation's cache is written again. Not measured here: applied only when named`,
372
+ basis: `the Desktop app sends these tools' definitions whole into every session and subagent start, and each step re-reads them: ${pick.map((s) => `${s.name} ~${s.tokens < 1000 ? s.tokens : k(s.tokens)} tokens, called in ${s.calledStarts} of ${s.starts} starts`).join("; ")}. The figure is what that cost in the ${i.desktopTools.days} days' starts that never called them (${money(all)} counting the ones that did${exact ? "" : ", as overhead lists it"}; those would load a tool through tool search instead)${after}`,
373
+ ...(dt.compactions ? { reloadsAfterCompaction: { reloads, compactions: hit.length, ofCompactions: dt.compactions.total, usd: reloadUsd, ...(unpricedReloads ? { unpriced: unpricedReloads } : {}) } } : {}),
374
+ quality: `Claude loads one of these tools through tool search the first time a conversation needs it, and again after each compaction (Claude Code issue #111915, reported on 2.1.321 to 2.1.331: a compaction puts loaded tools back behind tool search; those loads are taken off the figure): one more step each time. Kept in front: ${[...KEEP_APP_SERVERS, ...kept.filter((n) => !KEEP_APP_SERVERS.includes(n))].join(", ")} (called in most sessions). It takes effect in new sessions only, so no running conversation's cache is written again. Not measured here: applied only when named`,
331
375
  change: `${where}: env.${DEFER_APP_TOOLS_ENV} = "${value}", read by context-doctor's mod (its plugin, Claude Code ${DESKTOP_TOOLS_DEFER_SINCE}+)`,
332
376
  state: "available",
333
377
  value,
@@ -343,9 +387,11 @@ export function planFixes(i) {
343
387
  if (o?.length && f.state === "available")
344
388
  f.overriddenBy = o;
345
389
  const since = SINCE[f.id];
346
- const old = since && f.state === "available" ? (i.claudeCodeInstalls ?? []).filter((c) => compareVersions(c.version, since) < 0) : [];
390
+ // A lever that acts only in the Desktop app is read only by the Claude Code the app bundles.
391
+ const installs = (i.claudeCodeInstalls ?? []).filter((c) => !DESKTOP_ONLY.has(f.id) || c.source === "desktop app");
392
+ const old = since && f.state === "available" ? installs.filter((c) => compareVersions(c.version, since) < 0) : [];
347
393
  if (old.length)
348
- f.tooOld = `${describeInstalls(old)} ${old.length === 1 ? "predates" : "predate"} this setting (Claude Code ${since}+) and ${old.length === 1 ? "ignores" : "ignore"} it: update ${old.length === 1 ? "it" : "them"} for it to take effect there`;
394
+ f.tooOld = tooOldLine(old, since, i.sessionHosts, i.days);
349
395
  }
350
396
  const rank = (f) => (f.state === "available" ? 0 : f.state === "applied" ? 2 : 3) + (f.savedUsd === undefined ? 1 : 0);
351
397
  return fixes.sort((a, b) => rank(a) - rank(b) || (b.savedUsd ?? 0) - (a.savedUsd ?? 0));
package/dist/limits.d.ts CHANGED
@@ -516,6 +516,78 @@ export declare function reportModel(model: string | undefined): string;
516
516
  * stretches): `cause` says whether the limit moved or the mix did.
517
517
  */
518
518
  export declare function slopeChanges(windows: ResetWindow[], usage?: UsagePoint[], readings?: LimitReading[], stretchMs?: number): SlopeChange[];
519
+ /**
520
+ * Both of a plan's windows count the same requests, so the ratio of their
521
+ * rises is the one limit figure the model mix cancels out of: a move in it
522
+ * is a move in one of the two limits, never in your models. People measured
523
+ * it moving on Pro from 10% to 12% of the week per full 5-hour window
524
+ * (claude-code#111886, #111759, #111593). Each 5-hour period is paired with
525
+ * the weekly reading taken at the same moment: the line the recorder wrote
526
+ * beside it, or, where the weekly % had not moved (the recorder writes a
527
+ * window only when it moves, and again every 15 minutes), the weekly line
528
+ * before it. The ratio is the sum of the weekly rises over the sum of the
529
+ * 5-hour rises, per weekly window and pooled; its error is the larger of the
530
+ * whole-percent steps' and the spread between 5-hour windows'.
531
+ */
532
+ /** One 5-hour period's rise and the weekly limit's rise between the same two moments. */
533
+ export interface ExchangeSample {
534
+ from: number;
535
+ to: number;
536
+ fivePct: number;
537
+ weekPct: number;
538
+ }
539
+ /** A ratio over some 5-hour windows, or why there is none worth quoting. */
540
+ export interface ExchangeFigure {
541
+ /** 5-hour windows with weekly readings beside them, and the points each limit rose over them. */
542
+ windows: number;
543
+ fivePct: number;
544
+ weekPct: number;
545
+ /** % of the weekly limit a full 5-hour window (100 points) costs: 100 × weekly rise / 5-hour rise. */
546
+ pct?: number;
547
+ /** Its standard error, in points of the weekly limit. */
548
+ err?: number;
549
+ /** Why it is not quoted, when it is not (pct may still be there, too loose to say). */
550
+ why?: string;
551
+ }
552
+ /** One weekly window, reset to reset, and the ratio inside it. */
553
+ export interface ExchangeWeek extends ExchangeFigure {
554
+ start: number;
555
+ resetsAt: number;
556
+ current: boolean;
557
+ }
558
+ /** A move in the ratio between two weekly windows that each have one. */
559
+ export interface ExchangeMove {
560
+ /** The later window's start, and the earlier one's reset (equal unless a window is missing between them). */
561
+ at: number;
562
+ prevEnd: number;
563
+ pctBefore: number;
564
+ errBefore: number;
565
+ pctAfter: number;
566
+ errAfter: number;
567
+ /** How many standard errors apart. */
568
+ sigma: number;
569
+ }
570
+ /** One app's exchange: the figure since its last move (or since the first reading), each weekly window, and the moves. */
571
+ export interface Exchange extends ExchangeFigure {
572
+ app: "claude" | "codex";
573
+ /** "Claude", "Codex (plus)". */
574
+ label: string;
575
+ /** The two windows paired ("five_hour" and "seven_day"; Codex's 300- and 10080-minute ones). */
576
+ short: string;
577
+ long: string;
578
+ /** The first moment the figure counts from. */
579
+ since: number;
580
+ /** Weekly windows with a figure of their own: two or more were compared. */
581
+ compared: number;
582
+ weeks: ExchangeWeek[];
583
+ moves: ExchangeMove[];
584
+ }
585
+ /** One app's exchange from its short (5-hour) and long (weekly) readings; undefined when either is missing (Ultra has no 5-hour window). */
586
+ export declare function exchangeOf(short: LimitReading[], long: LimitReading[], opts: {
587
+ app: "claude" | "codex";
588
+ label: string;
589
+ now?: number;
590
+ }): Exchange | undefined;
519
591
  export interface LimitsReport {
520
592
  days: number;
521
593
  now: number;
@@ -533,6 +605,8 @@ export interface LimitsReport {
533
605
  claudeWindows: string[];
534
606
  /** How many Claude readings each recorder wrote ("statusline", "mod", "proxy"; "earlier" for lines from before 0.49). */
535
607
  claudeSources: Record<string, number>;
608
+ /** What a full 5-hour window costs of the weekly limit, Claude's then Codex's (exchangeOf); none on a plan without a 5-hour window. */
609
+ exchange: Exchange[];
536
610
  }
537
611
  export interface LimitsOptions {
538
612
  now?: number;
@@ -586,6 +660,12 @@ export declare function limitSavingsLines(fit: LimitFit | undefined, items: Arra
586
660
  * Code), or the autopilot proxy (from the API's rate-limit headers).
587
661
  */
588
662
  export declare const HOW_TO_RECORD = "To record them: `context-doctor install` (the plugin's mod writes them after each turn, Claude Code 2.1.286+; `install --statusline` on older ones), or `context-doctor autopilot on` (its proxy reads them from the API's replies).";
663
+ /**
664
+ * The exchange in one line: what a full 5-hour window costs of the weekly
665
+ * limit, its error, how many fit in a week, and whether it moved (from what
666
+ * to what, and when). Too thin: says so, with no figure.
667
+ */
668
+ export declare function exchangeLine(e: Exchange): string;
589
669
  /** "claude-fable-5-2" as "Fable 5.2"; any other id as it is. */
590
670
  export declare function modelLabel(key: string | undefined): string;
591
671
  /**
package/dist/limits.js CHANGED
@@ -1654,6 +1654,159 @@ function perReset(readings, usage, now) {
1654
1654
  }
1655
1655
  return { resets, changes };
1656
1656
  }
1657
+ /** A weekly line this close before a 5-hour one still stands for that moment: the recorder would have written the weekly window again had it moved (a minute's throttle) or after 15 minutes unchanged. */
1658
+ const EXCHANGE_PAIR_MS = KEEPALIVE_MS + MIN;
1659
+ /** A figure is quoted from this many 5-hour windows... */
1660
+ const MIN_EXCHANGE_WINDOWS = 3;
1661
+ /** ...known to this relative error or better. */
1662
+ const MAX_EXCHANGE_REL_SE = 0.25;
1663
+ /**
1664
+ * A move is reported beyond this many standard errors (1.5 times a
1665
+ * two-standard-error band: the bar slopeChanges sets between windows) and
1666
+ * of at least this factor either way.
1667
+ */
1668
+ const EXCHANGE_SIGMA = 3;
1669
+ const MIN_EXCHANGE_FACTOR = 1.1;
1670
+ /** Each 5-hour period's rise and the weekly rise over the same moments, split where a weekly reset falls inside it; with the weekly period each belongs to. */
1671
+ function exchangeSamples(short, long) {
1672
+ const weeks = periodsOf(long);
1673
+ const flat = weeks.flatMap((p) => p.map((r) => ({ r, week: p }))).sort((a, b) => a.r.ts - b.r.ts);
1674
+ /** The weekly reading standing at `ts`: the last one at or before it, within EXCHANGE_PAIR_MS, its period not reset by then. */
1675
+ const at = (ts) => {
1676
+ let lo = 0, hi = flat.length - 1, found = -1;
1677
+ while (lo <= hi) {
1678
+ const mid = (lo + hi) >> 1;
1679
+ if (flat[mid].r.ts <= ts) {
1680
+ found = mid;
1681
+ lo = mid + 1;
1682
+ }
1683
+ else
1684
+ hi = mid - 1;
1685
+ }
1686
+ const e = found >= 0 ? flat[found] : undefined;
1687
+ if (!e || ts - e.r.ts > EXCHANGE_PAIR_MS || (e.r.resetsAt !== undefined && e.r.resetsAt < ts))
1688
+ return undefined;
1689
+ return e;
1690
+ };
1691
+ const out = [];
1692
+ for (const period of periodsOf(short)) {
1693
+ let run = [];
1694
+ let week;
1695
+ const flush = () => {
1696
+ if (week && run.length >= 2) {
1697
+ const a = run[0], b = run[run.length - 1];
1698
+ const fivePct = Math.max(0, b.f - a.f), weekPct = Math.max(0, b.w - a.w);
1699
+ if (fivePct > 0 || weekPct > 0)
1700
+ out.push({ from: a.ts, to: b.ts, fivePct, weekPct, week });
1701
+ }
1702
+ run = [];
1703
+ };
1704
+ for (const r of period) {
1705
+ const e = at(r.ts);
1706
+ if (!e)
1707
+ continue;
1708
+ if (e.week !== week) {
1709
+ flush();
1710
+ week = e.week;
1711
+ }
1712
+ run.push({ ts: r.ts, f: r.pct, w: e.r.pct });
1713
+ }
1714
+ flush();
1715
+ }
1716
+ return out.sort((a, b) => a.from - b.from);
1717
+ }
1718
+ /** The ratio over some samples, with its error, or why it is not quoted. `res`: each window's reading step (1 for whole percents). */
1719
+ function exchangeFigure(samples, res) {
1720
+ const n = samples.length;
1721
+ const fivePct = samples.reduce((a, s) => a + s.fivePct, 0), weekPct = samples.reduce((a, s) => a + s.weekPct, 0);
1722
+ const fig = { windows: n, fivePct, weekPct };
1723
+ if (n < MIN_EXCHANGE_WINDOWS) {
1724
+ fig.why = `${n} five-hour window${n === 1 ? "" : "s"} with weekly readings beside ${n === 1 ? "it" : "them"}; ${MIN_EXCHANGE_WINDOWS} make a figure`;
1725
+ return fig;
1726
+ }
1727
+ if (!(fivePct > 0)) {
1728
+ fig.why = "the 5-hour window has not risen beside weekly readings yet";
1729
+ return fig;
1730
+ }
1731
+ if (!(weekPct > 0)) {
1732
+ fig.why = `the weekly reading has not moved across ${pts(fivePct)} points of 5-hour windows yet`;
1733
+ return fig;
1734
+ }
1735
+ const r = weekPct / fivePct;
1736
+ // The spread between windows (the ratio estimator's error), and the whole-percent steps: each rise is a difference of two readings, each off by up to half a step.
1737
+ const spread = ratio(samples.map((s) => s.weekPct), samples.map((s) => s.fivePct))?.relSe ?? Infinity;
1738
+ const steps = Math.sqrt((n * ((res.long / weekPct) ** 2 + (res.short / fivePct) ** 2)) / 6);
1739
+ const relSe = Math.max(spread, steps);
1740
+ fig.pct = 100 * r;
1741
+ fig.err = 100 * r * relSe;
1742
+ if (!(relSe <= MAX_EXCHANGE_REL_SE))
1743
+ fig.why = `known only to ±${Number.isFinite(relSe) ? Math.round(relSe * 100) : "∞"}% so far`;
1744
+ return fig;
1745
+ }
1746
+ /** One app's exchange from its short (5-hour) and long (weekly) readings; undefined when either is missing (Ultra has no 5-hour window). */
1747
+ export function exchangeOf(short, long, opts) {
1748
+ if (!short.length || !long.length)
1749
+ return undefined;
1750
+ const now = opts.now ?? Date.now();
1751
+ const res = { short: resolutionOf(short), long: resolutionOf(long) };
1752
+ const samples = exchangeSamples(short, long);
1753
+ const byWeek = new Map();
1754
+ for (const s of samples) {
1755
+ const list = byWeek.get(s.week);
1756
+ if (list)
1757
+ list.push(s);
1758
+ else
1759
+ byWeek.set(s.week, [s]);
1760
+ }
1761
+ const weeks = [...byWeek].map(([period, list]) => {
1762
+ const last = period[period.length - 1];
1763
+ const windowMs = last.windowMs ?? 7 * DAY;
1764
+ const resetsAt = last.resetsAt ?? period[0].ts + windowMs;
1765
+ return { start: resetsAt - windowMs, resetsAt, current: resetsAt > now, ...exchangeFigure(list, res) };
1766
+ }).sort((a, b) => a.start - b.start);
1767
+ const quoted = weeks.filter((w) => w.pct !== undefined && w.err !== undefined && !w.why);
1768
+ const moves = [];
1769
+ for (let i = 1; i < quoted.length; i++) {
1770
+ const a = quoted[i - 1], b = quoted[i];
1771
+ const se = Math.hypot(a.err, b.err);
1772
+ const sigma = se > 0 ? Math.abs(b.pct - a.pct) / se : Infinity;
1773
+ const factor = b.pct / a.pct;
1774
+ if (sigma < EXCHANGE_SIGMA || Math.max(factor, 1 / factor) < MIN_EXCHANGE_FACTOR)
1775
+ continue;
1776
+ moves.push({ at: b.start, prevEnd: a.resetsAt, pctBefore: a.pct, errBefore: a.err, pctAfter: b.pct, errAfter: b.err, sigma });
1777
+ }
1778
+ const lastMove = moves[moves.length - 1];
1779
+ const pooled = lastMove ? samples.filter((s) => s.from >= lastMove.at) : samples;
1780
+ const since = lastMove ? lastMove.at : samples[0]?.from ?? short[0].ts;
1781
+ return {
1782
+ app: opts.app, label: opts.label, short: short[short.length - 1].window, long: long[long.length - 1].window,
1783
+ ...exchangeFigure(pooled, res),
1784
+ since, compared: quoted.length, weeks, moves,
1785
+ };
1786
+ }
1787
+ /** Codex's windows paired: per plan and limit id, the 5-hour one with the weekly one. */
1788
+ function codexExchanges(readings, now) {
1789
+ const groups = new Map();
1790
+ for (const [key, rs] of byWindow(readings)) {
1791
+ const ms = rs[rs.length - 1]?.windowMs;
1792
+ const kind = ms === 5 * HOUR ? "short" : ms === 7 * DAY ? "long" : undefined;
1793
+ if (!kind)
1794
+ continue;
1795
+ const base = key.split(":").slice(0, -1).join(":");
1796
+ const g = groups.get(base) ?? (groups.set(base, {}), groups.get(base));
1797
+ g[kind] = rs;
1798
+ }
1799
+ const out = [];
1800
+ for (const g of groups.values()) {
1801
+ if (!g.short || !g.long)
1802
+ continue;
1803
+ const long = g.long[g.long.length - 1];
1804
+ const e = exchangeOf(g.short, g.long, { app: "codex", label: windowLabel(long.window, long.windowMs).replace(" weekly", ""), now });
1805
+ if (e)
1806
+ out.push(e);
1807
+ }
1808
+ return out;
1809
+ }
1657
1810
  function byWindow(readings) {
1658
1811
  const m = new Map();
1659
1812
  for (const r of readings) {
@@ -1680,6 +1833,9 @@ export function limitsReport(days = 30, opts = {}) {
1680
1833
  const claudeUse = claude.length >= 2 ? claudeUsage(claude[0].ts - HOUR, claude[claude.length - 1].ts, opts.claudePaths) : [];
1681
1834
  const claudeReset = perReset(claude, claudeUse, now);
1682
1835
  const codexReset = perReset(codex.readings, codex.usage, now);
1836
+ const claudeByWindow = byWindow(claude);
1837
+ const claudeExchange = exchangeOf(claudeByWindow.get("five_hour") ?? [], claudeByWindow.get("seven_day") ?? [], { app: "claude", label: "Claude", now });
1838
+ const exchange = [...(claudeExchange ? [claudeExchange] : []), ...codexExchanges(codex.readings, now)];
1683
1839
  const claudeSources = {};
1684
1840
  for (const r of claude)
1685
1841
  claudeSources[r.source ?? "earlier"] = (claudeSources[r.source ?? "earlier"] ?? 0) + 1;
@@ -1705,6 +1861,7 @@ export function limitsReport(days = 30, opts = {}) {
1705
1861
  changes: [...claudeReset.changes, ...codexReset.changes],
1706
1862
  claudeWindows: CLAUDE_WINDOWS.filter((w) => claude.some((r) => r.window === w)),
1707
1863
  claudeSources,
1864
+ exchange,
1708
1865
  };
1709
1866
  }
1710
1867
  /**
@@ -1835,6 +1992,30 @@ function changeLine(c) {
1835
1992
  }
1836
1993
  return `${head} (${move(c.factor)}). Part of it is your model mix: ${used}${per}${predicted}. Beyond the mix, per model, 1% buys ${move(r).replace(" per 1%", "")}: ${drains(r)}${tok}${ver}.`;
1837
1994
  }
1995
+ /** "Nov 16", in UTC like the report's other dates. */
1996
+ const monthDay = (ms) => new Date(ms).toLocaleDateString("en-US", { month: "short", day: "numeric", timeZone: "UTC" });
1997
+ const tenth = (v) => (Math.round(v * 10) / 10).toFixed(1);
1998
+ /**
1999
+ * The exchange in one line: what a full 5-hour window costs of the weekly
2000
+ * limit, its error, how many fit in a week, and whether it moved (from what
2001
+ * to what, and when). Too thin: says so, with no figure.
2002
+ */
2003
+ export function exchangeLine(e) {
2004
+ const whose = e.app === "claude" ? "" : `${e.label}: `;
2005
+ if (e.pct === undefined || e.err === undefined || e.why)
2006
+ return `${whose}What a full 5-hour window costs of your weekly limit: too thin to quote yet (${e.why ?? "no figure"}).`;
2007
+ const perWeek = Math.max(1, Math.round(100 / e.pct));
2008
+ const head = `${whose}${whose ? "a" : "A"} full 5-hour window is ${tenth(e.pct)}% of your weekly limit (±${tenth(Math.max(0.1, e.err))}), about ${perWeek} a week`;
2009
+ const m = e.moves[e.moves.length - 1];
2010
+ if (m) {
2011
+ const when = Math.abs(m.prevEnd - m.at) > SAME_RESET_MS ? `between ${monthDay(m.prevEnd)} and ${monthDay(m.at)}` : `at the weekly reset of ${monthDay(m.at)}`;
2012
+ const earlier = e.moves.length > 1 ? ` (the latest of ${e.moves.length} moves since ${monthDay(e.weeks[0].start)})` : "";
2013
+ return `${head}; it was ${tenth(m.pctBefore)}% (±${tenth(Math.max(0.1, m.errBefore))}) and moved ${when}${earlier}. Your model mix does not explain this: both limits count the same requests, so one of the two limits changed.`;
2014
+ }
2015
+ if (e.compared >= 2)
2016
+ return `${head}; unchanged since ${monthDay(e.since)}.`;
2017
+ return `${head} (since ${monthDay(e.since)}; one weekly window so far, nothing to compare yet).`;
2018
+ }
1838
2019
  /** "claude-fable-5-2" as "Fable 5.2"; any other id as it is. */
1839
2020
  export function modelLabel(key) {
1840
2021
  const m = /^claude-(opus|sonnet|haiku|fable|mythos)-(\d+)(?:-(\d{1,2}))?(?!\d)/i.exec(key ?? "");
@@ -1893,6 +2074,8 @@ export function renderLimits(r, pastLimit = [], ahead) {
1893
2074
  if (r.claudeWindows.length === 1 && r.claudeWindows[0] === "seven_day") {
1894
2075
  out.push("", "No 5-hour window in Claude's readings: a plan without one (Ultra), so the weekly window is the limit.");
1895
2076
  }
2077
+ if (r.exchange.length)
2078
+ out.push("", ...r.exchange.map(exchangeLine));
1896
2079
  if (pastLimit.length) {
1897
2080
  out.push("", "Past your plan's limit: usage credits", "─".repeat(60), ...pastLimit);
1898
2081
  }
@@ -2005,6 +2188,8 @@ export function renderLimitsReport(r) {
2005
2188
  const nowWeek = r.windows.find((w) => w.window === "seven_day");
2006
2189
  if (nowWeek || now5h)
2007
2190
  out.push("", `Now: ${[nowWeek ? `weekly ${pts(nowWeek.pct)}%` : "", now5h ? `5-hour ${pts(now5h.pct)}%` : ""].filter(Boolean).join(", ")}.`);
2191
+ if (r.exchange.length)
2192
+ out.push("", ...r.exchange.map(exchangeLine));
2008
2193
  out.push("", "No prompts, file paths, session or account ids are included.");
2009
2194
  return out.join("\n");
2010
2195
  }