context-doctor 0.31.1 → 0.33.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 +96 -706
- package/dist/autoclear.d.ts +58 -7
- package/dist/autoclear.js +159 -31
- package/dist/autopilot.d.ts +43 -3
- package/dist/autopilot.js +169 -35
- package/dist/cache.d.ts +6 -2
- package/dist/cache.js +48 -23
- package/dist/cacheplan.d.ts +5 -3
- package/dist/cacheplan.js +46 -8
- package/dist/calibration.d.ts +7 -2
- package/dist/calibration.js +14 -3
- package/dist/ci.js +34 -6
- package/dist/cli.js +416 -271
- package/dist/clihelp.d.ts +24 -0
- package/dist/clihelp.js +116 -0
- package/dist/coldresume.d.ts +32 -7
- package/dist/coldresume.js +148 -34
- package/dist/compactquality.d.ts +1 -1
- package/dist/compactquality.js +37 -14
- package/dist/compactwindow.d.ts +29 -5
- package/dist/compactwindow.js +104 -47
- package/dist/config.d.ts +6 -0
- package/dist/config.js +4 -1
- package/dist/cursor.d.ts +9 -0
- package/dist/cursor.js +53 -22
- package/dist/dashboard.d.ts +10 -0
- package/dist/dashboard.js +27 -2
- package/dist/diff.js +33 -4
- package/dist/doctor.d.ts +3 -2
- package/dist/doctor.js +199 -34
- package/dist/embed.d.ts +9 -0
- package/dist/embed.js +40 -5
- package/dist/experiment.d.ts +1 -0
- package/dist/experiment.js +6 -3
- package/dist/hook.js +23 -4
- package/dist/impact.d.ts +32 -0
- package/dist/impact.js +45 -6
- package/dist/install.d.ts +59 -2
- package/dist/install.js +458 -57
- package/dist/invocation.d.ts +18 -0
- package/dist/invocation.js +49 -0
- package/dist/ledger.js +9 -2
- package/dist/mcp.d.ts +6 -3
- package/dist/mcp.js +93 -299
- package/dist/mcpclient.js +45 -0
- package/dist/mcpschema.d.ts +17 -2
- package/dist/mcpschema.js +100 -26
- package/dist/optimize.d.ts +2 -0
- package/dist/optimize.js +151 -64
- package/dist/overhead.d.ts +12 -1
- package/dist/overhead.js +88 -34
- package/dist/pack.d.ts +11 -0
- package/dist/pack.js +75 -12
- package/dist/parse.js +42 -18
- package/dist/preferences.d.ts +1 -1
- package/dist/preferences.js +5 -5
- package/dist/pricing.d.ts +57 -5
- package/dist/pricing.js +94 -8
- package/dist/proxy.d.ts +13 -2
- package/dist/proxy.js +258 -43
- package/dist/reads.d.ts +1 -1
- package/dist/reads.js +61 -24
- package/dist/report.d.ts +10 -0
- package/dist/report.js +12 -4
- package/dist/savings.d.ts +23 -8
- package/dist/savings.js +88 -37
- package/dist/session.d.ts +52 -0
- package/dist/session.js +186 -6
- package/dist/split.js +6 -1
- package/dist/statusline.d.ts +3 -1
- package/dist/statusline.js +29 -17
- package/dist/subagentpay.d.ts +6 -3
- package/dist/subagentpay.js +53 -18
- package/dist/subagents.d.ts +7 -3
- package/dist/subagents.js +28 -8
- package/dist/tasks.d.ts +22 -7
- package/dist/tasks.js +47 -20
- package/dist/wrap.d.ts +6 -0
- package/dist/wrap.js +142 -6
- package/package.json +5 -8
- package/skills/context-doctor/SKILL.md +3 -3
package/dist/ci.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Base contents come from `git show <base>:<path>`; nothing is checked out.
|
|
11
11
|
*/
|
|
12
12
|
import { execFileSync } from "node:child_process";
|
|
13
|
-
import {
|
|
13
|
+
import { readFileSync, statSync } from "node:fs";
|
|
14
14
|
import { join, posix } from "node:path";
|
|
15
15
|
import { estimateTokens, formatTokens } from "./tokens.js";
|
|
16
16
|
import { formatUsd, pricingFor } from "./pricing.js";
|
|
@@ -76,13 +76,41 @@ function measure(paths, read) {
|
|
|
76
76
|
visit(p, false, 0);
|
|
77
77
|
return out;
|
|
78
78
|
}
|
|
79
|
+
/** `-z` output: without it git quotes non-ASCII paths ("caf\303\251/CLAUDE.md") and they match nothing. */
|
|
80
|
+
const paths0 = (out) => (out ?? "").split("\0").filter(Boolean);
|
|
81
|
+
/** A file on disk, not a directory: `@src/components` names a folder, which Claude Code does not load. */
|
|
82
|
+
function isFile(p) {
|
|
83
|
+
try {
|
|
84
|
+
return statSync(p).isFile();
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
79
90
|
export function ciReport(opts = {}) {
|
|
80
91
|
const cwd = opts.cwd ?? process.cwd();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
92
|
+
// Outside a repository `git ls-files` lists nothing, which used to read as
|
|
93
|
+
// "No agent memory files" with exit 0: a CI step in the wrong directory
|
|
94
|
+
// passed every pull request. It is an error, said as one.
|
|
95
|
+
const root = git(["rev-parse", "--show-toplevel"], cwd)?.trim();
|
|
96
|
+
if (!root) {
|
|
97
|
+
throw new Error(git(["--version"], cwd) === undefined
|
|
98
|
+
? "ci needs git, and git is not installed or not on PATH."
|
|
99
|
+
: `ci compares memory files in a git repository, and ${cwd} is not inside one. Run it from the repository's checkout.`);
|
|
100
|
+
}
|
|
101
|
+
// A base git cannot resolve (a typo, or a shallow clone that never fetched
|
|
102
|
+
// it) would read as an empty tree: every file "new", and a failure that
|
|
103
|
+
// blames the PR for the whole memory set. Stop and say so instead.
|
|
104
|
+
if (opts.base && git(["rev-parse", "--verify", "--quiet", `${opts.base}^{commit}`], root) === undefined) {
|
|
105
|
+
throw new Error(`--base ${opts.base} is not a commit in ${root}: check the name, or fetch it first (a shallow clone: git fetch --depth=1 origin ${opts.base})`);
|
|
106
|
+
}
|
|
107
|
+
const headList = paths0(git(["ls-files", "-z", "--cached", "--others", "--exclude-standard"], root));
|
|
108
|
+
const baseList = opts.base ? paths0(git(["ls-tree", "-r", "-z", "--name-only", opts.base], root)) : [];
|
|
109
|
+
// ls-tree -r lists blobs only, so a path outside it (a folder, a missing file) has no base content;
|
|
110
|
+
// `git show base:folder` would print the folder's listing and count it as an imported file.
|
|
111
|
+
const baseFiles = new Set(baseList);
|
|
112
|
+
const head = measure(headList.filter((p) => agentFor(p)), (p) => (isFile(join(root, p)) ? readFileSync(join(root, p), "utf8") : undefined));
|
|
113
|
+
const base = opts.base ? measure(baseList.filter((p) => agentFor(p)), (p) => (baseFiles.has(p) ? git(["show", `${opts.base}:${p}`], root) : undefined)) : new Map();
|
|
86
114
|
const files = [...new Set([...head.keys(), ...base.keys()])].sort().map((p) => ({
|
|
87
115
|
path: p,
|
|
88
116
|
agent: agentFor(p) ?? "Claude Code",
|