context-doctor 0.46.0 → 0.47.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 +7 -4
- package/dist/ab.js +3 -2
- package/dist/autopilot.js +9 -5
- package/dist/blob.js +66 -12
- package/dist/budget.d.ts +8 -2
- package/dist/budget.js +30 -7
- package/dist/ci.js +2 -1
- package/dist/claudeplugin.d.ts +97 -0
- package/dist/claudeplugin.js +142 -0
- package/dist/cli.js +109 -36
- package/dist/compactcost.d.ts +74 -0
- package/dist/compactcost.js +115 -0
- package/dist/cursor.js +2 -0
- package/dist/doctor.js +90 -18
- package/dist/extract.js +4 -3
- package/dist/fanout.d.ts +15 -0
- package/dist/fanout.js +30 -9
- package/dist/firstfix.d.ts +43 -0
- package/dist/firstfix.js +80 -0
- package/dist/fix.d.ts +46 -2
- package/dist/fix.js +95 -10
- package/dist/httpguard.d.ts +13 -0
- package/dist/httpguard.js +22 -0
- package/dist/install.d.ts +21 -9
- package/dist/install.js +211 -40
- package/dist/limits.d.ts +5 -0
- package/dist/limits.js +26 -2
- package/dist/mcp.js +60 -59
- package/dist/missledger.js +5 -3
- package/dist/mod/api.d.ts +8 -2
- package/dist/mod/api.js +2 -2
- package/dist/mod/logic.d.ts +13 -1
- package/dist/mod/logic.js +24 -2
- package/dist/mod/register.d.ts +2 -0
- package/dist/mod/register.js +19 -5
- package/dist/modelids.d.ts +4 -3
- package/dist/modelids.js +23 -7
- package/dist/modelswitch.js +8 -4
- package/dist/modmeasure.js +13 -1
- package/dist/orgrates.d.ts +18 -0
- package/dist/orgrates.js +51 -2
- package/dist/pack.d.ts +13 -0
- package/dist/pack.js +38 -2
- package/dist/preferences.js +2 -1
- package/dist/pricing.d.ts +8 -0
- package/dist/pricing.js +16 -0
- package/dist/progresssummaries.d.ts +148 -0
- package/dist/progresssummaries.js +248 -0
- package/dist/proxy.d.ts +1 -1
- package/dist/proxy.js +1 -1
- package/dist/prune.d.ts +8 -0
- package/dist/prune.js +11 -1
- package/dist/spend.d.ts +34 -0
- package/dist/spend.js +48 -4
- package/dist/subagentmodel.d.ts +12 -0
- package/dist/subagentmodel.js +17 -4
- package/dist/subagentpay.d.ts +8 -0
- package/dist/subagentpay.js +8 -1
- package/dist/toolcwd.d.ts +14 -0
- package/dist/toolcwd.js +17 -0
- package/package.json +1 -1
package/dist/limits.d.ts
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import { type Extractor } from "./scan.js";
|
|
29
29
|
import { type ModelPricing, type Modifiers } from "./pricing.js";
|
|
30
|
+
import { type CompactionRequest } from "./compactcost.js";
|
|
30
31
|
/** Claude Code's two windows, as its status line input names them. */
|
|
31
32
|
export declare const CLAUDE_WINDOWS: readonly ["five_hour", "seven_day"];
|
|
32
33
|
/** One reading of one window: how much of it was used at `ts`. */
|
|
@@ -107,6 +108,8 @@ export declare function codexLimitData(since: number, root?: string): {
|
|
|
107
108
|
export declare const USAGE_ROWS: Extractor<{
|
|
108
109
|
ids: Record<string, 1>;
|
|
109
110
|
}>;
|
|
111
|
+
/** A compaction's estimated request as a request point (no message id: its key is the boundary's uuid). */
|
|
112
|
+
export declare function compactionPoint(c: CompactionRequest): ClaudeRequest;
|
|
110
113
|
/** One Claude Code request as `claudeFileUsage` reads it: the usage point, and what `spend` and `budget` add up. */
|
|
111
114
|
export interface ClaudeRequest extends UsagePoint {
|
|
112
115
|
/** The row's uuid: what tells a fork's copy of a reply from the reply itself. */
|
|
@@ -125,6 +128,8 @@ export interface ClaudeRequest extends UsagePoint {
|
|
|
125
128
|
estimated?: boolean;
|
|
126
129
|
/** Its row's price changed on this day, before the request. */
|
|
127
130
|
changedOn?: string;
|
|
131
|
+
/** A compaction's own request, which no row records usage for: estimated (compactcost.ts). */
|
|
132
|
+
compaction?: boolean;
|
|
128
133
|
}
|
|
129
134
|
/**
|
|
130
135
|
* The requests of one Claude Code transcript between `since` and `until`,
|
package/dist/limits.js
CHANGED
|
@@ -35,6 +35,7 @@ import { subagentFiles } from "./subagents.js";
|
|
|
35
35
|
import { pick, rowsOf, slimUsage } from "./scan.js";
|
|
36
36
|
import { isUnbilledModel, NO_MODIFIERS, openAIUsage, requestCost } from "./pricing.js";
|
|
37
37
|
import { realModel } from "./tokens.js";
|
|
38
|
+
import { isCompactionRow, newTrack, slimSummary, trackCompaction } from "./compactcost.js";
|
|
38
39
|
const MIN = 60_000;
|
|
39
40
|
const HOUR = 60 * MIN;
|
|
40
41
|
const DAY = 24 * HOUR;
|
|
@@ -338,10 +339,11 @@ export function codexLimitData(since, root = codexSessionsRoot()) {
|
|
|
338
339
|
* main thread.
|
|
339
340
|
*/
|
|
340
341
|
export const USAGE_ROWS = {
|
|
341
|
-
id: "usage.
|
|
342
|
+
id: "usage.4",
|
|
342
343
|
init: () => ({ ids: {} }),
|
|
343
344
|
line(line, row, out, st) {
|
|
344
|
-
|
|
345
|
+
const compaction = isCompactionRow(line);
|
|
346
|
+
if (!compaction && !line.includes('"usage"'))
|
|
345
347
|
return;
|
|
346
348
|
let e;
|
|
347
349
|
try {
|
|
@@ -350,6 +352,15 @@ export const USAGE_ROWS = {
|
|
|
350
352
|
catch {
|
|
351
353
|
return;
|
|
352
354
|
}
|
|
355
|
+
// A compaction's boundary (the context it read) and its summary (the output): what its own request is estimated from (compactcost.ts).
|
|
356
|
+
if (compaction && e?.type === "system" && e.subtype === "compact_boundary") {
|
|
357
|
+
out.push(pick({ ...e, isSidechain: e.isSidechain === true || undefined, compactMetadata: pick(e.compactMetadata ?? {}, ["preTokens"]) }, ["type", "subtype", "uuid", "sessionId", "timestamp", "isSidechain", "compactMetadata"]));
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (compaction && e?.type === "user" && e.isCompactSummary === true) {
|
|
361
|
+
out.push(slimSummary(e));
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
353
364
|
const m = e?.message;
|
|
354
365
|
if (e?.type !== "assistant" || !m?.usage)
|
|
355
366
|
return;
|
|
@@ -363,6 +374,15 @@ export const USAGE_ROWS = {
|
|
|
363
374
|
out.push(pick({ ...e, isSidechain: e.isSidechain === true || undefined, message: pick({ ...m, usage: slimUsage(m.usage) }, ["id", "model", "usage"]) }, ["type", "uuid", "timestamp", "isSidechain", "message"]));
|
|
364
375
|
},
|
|
365
376
|
};
|
|
377
|
+
/** A compaction's estimated request as a request point (no message id: its key is the boundary's uuid). */
|
|
378
|
+
export function compactionPoint(c) {
|
|
379
|
+
const u = c.usage;
|
|
380
|
+
return {
|
|
381
|
+
ts: c.ts, app: "claude", model: c.model, input: num(u.input_tokens), read: num(u.cache_read_input_tokens), write: num(u.cache_creation_input_tokens), output: num(u.output_tokens),
|
|
382
|
+
usd: c.cost.totalUsd, promptUsd: c.cost.promptUsd, rates: c.cost.rates, modifiers: c.cost.modifiers, compaction: true,
|
|
383
|
+
...(c.uuid ? { uuid: c.uuid } : {}), ...(c.sidechain ? { sidechain: true } : {}), ...(c.cost.estimated ? { estimated: true } : {}), ...(c.cost.changedOn ? { changedOn: c.cost.changedOn } : {}),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
366
386
|
/**
|
|
367
387
|
* The requests of one Claude Code transcript between `since` and `until`,
|
|
368
388
|
* each reply once, its output settled on its last row (billed at the
|
|
@@ -376,7 +396,11 @@ export function claudeFileUsage(file, since, until = Infinity, runRows) {
|
|
|
376
396
|
const sighting = replyCounter(runRows);
|
|
377
397
|
const settle = outputSettler();
|
|
378
398
|
const byId = new Map();
|
|
399
|
+
const track = newTrack();
|
|
379
400
|
rowsOf(file, USAGE_ROWS).forEach((e) => {
|
|
401
|
+
const done = trackCompaction(track, e);
|
|
402
|
+
if (done && done.ts >= since && done.ts <= until)
|
|
403
|
+
out.push(compactionPoint(done));
|
|
380
404
|
const m = e?.message;
|
|
381
405
|
if (e?.type !== "assistant" || !m?.usage)
|
|
382
406
|
return;
|