context-doctor 0.47.0 → 0.48.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 +3 -1
- package/dist/ab.d.ts +51 -3
- package/dist/ab.js +68 -26
- package/dist/abclaude.d.ts +167 -0
- package/dist/abclaude.js +511 -0
- package/dist/abstore.d.ts +46 -0
- package/dist/abstore.js +58 -0
- package/dist/cli.js +19 -0
- package/dist/fix.d.ts +7 -2
- package/dist/fix.js +6 -3
- package/dist/install.js +2 -0
- package/dist/mcp.d.ts +4 -0
- package/dist/mcp.js +142 -98
- package/dist/mcpclient.js +73 -42
- package/dist/modelids.d.ts +58 -0
- package/dist/modelids.js +133 -1
- package/dist/pricing.js +14 -2
- package/dist/proxy.d.ts +1 -1
- package/dist/proxy.js +1 -1
- package/package.json +6 -3
package/dist/cli.js
CHANGED
|
@@ -23,6 +23,7 @@ import { claudeCodeInstallsFromEnv, claudePluginEnabled, runInstall, runUninstal
|
|
|
23
23
|
import { listSessions, parseSessionFile, pickCurrentSession, isClaudeSession } from "./session.js";
|
|
24
24
|
import { runHook } from "./hook.js";
|
|
25
25
|
import { abCommand } from "./ab.js";
|
|
26
|
+
import { latestModelComparison } from "./abstore.js";
|
|
26
27
|
import { buildImpactReport } from "./impact.js";
|
|
27
28
|
import { measureTokenizer, renderTokenizer } from "./tokenizer-measure.js";
|
|
28
29
|
import { autopilotOff, autopilotOn, autopilotPauseResult, autopilotPaths, autopilotStatus, DEFAULT_AUTOPILOT_PORT } from "./autopilot.js";
|
|
@@ -184,6 +185,13 @@ Measure:
|
|
|
184
185
|
side. Bills ANTHROPIC_API_KEY: prints the estimate,
|
|
185
186
|
sends nothing without --yes, never passes --budget usd.
|
|
186
187
|
--list shows the tasks; --model (default claude-opus-5-5)
|
|
188
|
+
context-doctor ab --via claude-code [--model m] [--compare m2] [--repeat n] [--yes]
|
|
189
|
+
The same tasks through your own Claude Code (claude -p,
|
|
190
|
+
your sign-in: on a plan, its limits, not dollars), one
|
|
191
|
+
arm per model: --model (default claude-sonnet-5-5) vs
|
|
192
|
+
--compare (default claude-opus-5-5). Each run confined
|
|
193
|
+
to a temp copy under Claude Code's sandbox; --timeout s
|
|
194
|
+
per run (default 600). fix quotes the result
|
|
187
195
|
|
|
188
196
|
Fix automatically:
|
|
189
197
|
context-doctor autopilot on|off|pause|resume|status
|
|
@@ -319,6 +327,11 @@ Options:
|
|
|
319
327
|
--check <cmd> (experiment) Command whose exit code is the pass/fail for each arm
|
|
320
328
|
--existing <id> (experiment) Session id to fork the second arm from (never mutated)
|
|
321
329
|
--budget <usd> (experiment) Spend cap per arm (default 1)
|
|
330
|
+
--via <api|claude-code> (ab) The Messages API on ANTHROPIC_API_KEY (default), or claude -p on
|
|
331
|
+
your own Claude Code sign-in, one arm per model
|
|
332
|
+
--compare <model> (ab --via claude-code) Model(s) to run against --model (default
|
|
333
|
+
claude-opus-5-5; "none" for --model alone)
|
|
334
|
+
--timeout <s> (ab --via claude-code) Seconds before a run is killed (default 600)
|
|
322
335
|
--dry-run (experiment) Print the claude commands and stop
|
|
323
336
|
--allow-dirty (experiment) Skip the clean-tree check (uncommitted changes will be lost)
|
|
324
337
|
--statusline (install) Also set Claude Code's statusLine to context-doctor (never
|
|
@@ -483,6 +496,8 @@ async function measureFixInputs(days) {
|
|
|
483
496
|
prune: prunePlan,
|
|
484
497
|
subagentModel,
|
|
485
498
|
subagentModelSet,
|
|
499
|
+
// The newest ab --via claude-code comparison of Sonnet 5.5 with another model: the subagent-model line quotes it.
|
|
500
|
+
abComparison: latestModelComparison(),
|
|
486
501
|
toolOutput,
|
|
487
502
|
toolOutputSet,
|
|
488
503
|
progressSummaries,
|
|
@@ -541,6 +556,9 @@ const FLAGS = [
|
|
|
541
556
|
{ names: ["--repeat"], value: "number", num: { min: 1, integer: true }, set: (a, v) => { a.repeat = v; } },
|
|
542
557
|
{ names: ["--max-turns"], value: "number", num: { min: 1, integer: true }, set: (a, v) => { a.maxTurns = v; } },
|
|
543
558
|
{ names: ["--concurrency"], value: "number", num: { min: 1, integer: true }, set: (a, v) => { a.concurrency = v; } },
|
|
559
|
+
{ names: ["--via"], value: "text", set: (a, v) => { a.via = v; } },
|
|
560
|
+
{ names: ["--compare"], value: "text", set: (a, v) => { (a.compare ??= []).push(v); } },
|
|
561
|
+
{ names: ["--timeout"], value: "number", num: { min: 1, integer: true }, set: (a, v) => { a.timeoutS = v; } },
|
|
544
562
|
{ names: ["--yes"], set: (a) => { a.yes = true; } },
|
|
545
563
|
{ names: ["--dry-run"], set: (a) => { a.dryRun = true; } },
|
|
546
564
|
{ names: ["--copy"], set: (a) => { a.copy = true; } },
|
|
@@ -866,6 +884,7 @@ async function main() {
|
|
|
866
884
|
process.exitCode = await abCommand({
|
|
867
885
|
levers: args.levers, tasks: args.abTasks, model: args.model, repeat: args.repeat, maxTurns: args.maxTurns,
|
|
868
886
|
concurrency: args.concurrency, budgetUsd: args.budgetUsd, yes: args.yes === true, json: args.json, out: args.out, list: args.list,
|
|
887
|
+
via: args.via, compare: args.compare, timeoutS: args.timeoutS,
|
|
869
888
|
});
|
|
870
889
|
return;
|
|
871
890
|
}
|
package/dist/fix.d.ts
CHANGED
|
@@ -33,13 +33,16 @@
|
|
|
33
33
|
* variable), estimated as `spend` estimates them (progresssummaries.ts).
|
|
34
34
|
*
|
|
35
35
|
* The subagents' model is the one lever with a quality cost `fix` cannot
|
|
36
|
-
* measure
|
|
37
|
-
*
|
|
36
|
+
* measure from history: its quality line quotes the newest `ab --via
|
|
37
|
+
* claude-code` comparison when there is one (abstore.ts), and says so when
|
|
38
|
+
* there is none. It is applied only when named (never by `--apply all`),
|
|
39
|
+
* and never over a value the user set.
|
|
38
40
|
*/
|
|
39
41
|
import { type CacheTtlReport, type CurrentTtl } from "./cachettl.js";
|
|
40
42
|
import { type ClaudeCodeInstall } from "./modelswitch.js";
|
|
41
43
|
import { type ProjectPlan } from "./prune.js";
|
|
42
44
|
import { readLedger } from "./ledger.js";
|
|
45
|
+
import { type AbStoredResult } from "./abstore.js";
|
|
43
46
|
import { type SubagentModelReplay } from "./subagentmodel.js";
|
|
44
47
|
import { type ToolOutputReplay } from "./tooloutput.js";
|
|
45
48
|
import { type ProgressSummaryEstimate } from "./progresssummaries.js";
|
|
@@ -111,6 +114,8 @@ export interface FixInputs {
|
|
|
111
114
|
recordProblem?: string;
|
|
112
115
|
/** Every subagent request replayed at Sonnet 5.5 (subagentmodel.ts). */
|
|
113
116
|
subagentModel?: SubagentModelReplay;
|
|
117
|
+
/** The newest kept `ab --via claude-code` comparison of the candidate with another model (abstore.ts): the subagent-model line quotes it. */
|
|
118
|
+
abComparison?: AbStoredResult;
|
|
114
119
|
/** CLAUDE_CODE_SUBAGENT_MODEL as the user set it (their settings.json env, or the environment fix runs in): never overwritten. */
|
|
115
120
|
subagentModelSet?: {
|
|
116
121
|
value: string;
|
package/dist/fix.js
CHANGED
|
@@ -33,8 +33,10 @@
|
|
|
33
33
|
* variable), estimated as `spend` estimates them (progresssummaries.ts).
|
|
34
34
|
*
|
|
35
35
|
* The subagents' model is the one lever with a quality cost `fix` cannot
|
|
36
|
-
* measure
|
|
37
|
-
*
|
|
36
|
+
* measure from history: its quality line quotes the newest `ab --via
|
|
37
|
+
* claude-code` comparison when there is one (abstore.ts), and says so when
|
|
38
|
+
* there is none. It is applied only when named (never by `--apply all`),
|
|
39
|
+
* and never over a value the user set.
|
|
38
40
|
*/
|
|
39
41
|
import { existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
|
|
40
42
|
import { homedir } from "node:os";
|
|
@@ -51,6 +53,7 @@ import { tilde } from "./claudedir.js";
|
|
|
51
53
|
import { applyPrune, undoPrune } from "./prune.js";
|
|
52
54
|
import { fallbackStateDir, readLedger } from "./ledger.js";
|
|
53
55
|
import { claudeDir } from "./claudedir.js";
|
|
56
|
+
import { comparisonLine } from "./abstore.js";
|
|
54
57
|
import { movedFromNames, renderSubagentTypes, subagentModelSavedSince, SUBAGENT_CANDIDATE, SUBAGENT_CANDIDATE_NAME, SUBAGENT_MODEL_ENV } from "./subagentmodel.js";
|
|
55
58
|
import { BASH_OUTPUT_DEFAULT, BASH_OUTPUT_KEY, BASH_OUTPUT_SINCE, breakEven, renderToolOutputCaps, toolOutputSavedSince } from "./tooloutput.js";
|
|
56
59
|
import { disablesSummaries, estimateProgressSummaries, hostName, PROGRESS_SUMMARIES_ENV, PROGRESS_SUMMARIES_OFF, PROGRESS_SUMMARIES_SINCE } from "./progresssummaries.js";
|
|
@@ -184,7 +187,7 @@ export function planFixes(i) {
|
|
|
184
187
|
// The subagents' own bill, not the main conversations' input the plan's first line names.
|
|
185
188
|
shareOf: "of subagents",
|
|
186
189
|
basis: `${reqs.toLocaleString("en-US")} subagent requests priced at ${SUBAGENT_CANDIDATE_NAME} with the token counts they had (${money(sm.billedUsd)} billed for all ${sm.agents} subagents); an estimate: another model tokenizes and works differently`,
|
|
187
|
-
quality: `this changes the model your subagents run on (${moved.map((t) => t.type).join(", ")}); the quality cost is not measured here: context-doctor ab can measure it (its tasks with --model ${SUBAGENT_CANDIDATE} and without)`,
|
|
190
|
+
quality: `this changes the model your subagents run on (${moved.map((t) => t.type).join(", ")}); ${i.abComparison ? `measured by context-doctor ab ${comparisonLine(i.abComparison)} (${i.abComparison.tasks} small coding tasks, ${i.abComparison.repeat} run${i.abComparison.repeat === 1 ? "" : "s"} each; your subagents' own work may differ)` : `the quality cost is not measured here: context-doctor ab can measure it (its tasks with --model ${SUBAGENT_CANDIDATE} and without)`}`,
|
|
188
191
|
change: `${where}: env.${SUBAGENT_MODEL_ENV} = "${SUBAGENT_CANDIDATE}"`,
|
|
189
192
|
state: "available",
|
|
190
193
|
value: SUBAGENT_CANDIDATE,
|
package/dist/install.js
CHANGED
|
@@ -1631,6 +1631,8 @@ const OUR_CLAUDE_FILES = [
|
|
|
1631
1631
|
".context-doctor-budget.json",
|
|
1632
1632
|
".context-doctor-budget-state.json",
|
|
1633
1633
|
".context-doctor-budget-said.d",
|
|
1634
|
+
// ab --via claude-code's kept comparisons (abstore.ts), which fix quotes.
|
|
1635
|
+
".context-doctor-ab.json",
|
|
1634
1636
|
];
|
|
1635
1637
|
export async function runUninstall() {
|
|
1636
1638
|
changes = 0;
|
package/dist/mcp.d.ts
CHANGED
|
@@ -18,5 +18,9 @@
|
|
|
18
18
|
* save_handoff — store a handoff brief the next chat starts from (a chat's history cannot be cut)
|
|
19
19
|
* recall — search this session's own transcript (compacted turns, cleared output); stdio only
|
|
20
20
|
* Prompts: context_checkup, handoff, ask_file. Resources (stdio): handoff://latest, handoff://<id>.
|
|
21
|
+
*
|
|
22
|
+
* Built on the MCP SDK's v2 packages: one server definition answers both
|
|
23
|
+
* protocol eras, a 2025-era client's `initialize` (2024-10-07 to 2025-11-25)
|
|
24
|
+
* and a 2026-07-28 client's `server/discover`, over stdio and --http.
|
|
21
25
|
*/
|
|
22
26
|
export {};
|