context-doctor 0.23.0 → 0.23.1
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/dist/autopilot.js +13 -2
- package/dist/mcp.js +1 -1
- package/dist/proxy.d.ts +1 -1
- package/dist/proxy.js +1 -1
- package/package.json +1 -1
package/dist/autopilot.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* backend, not an API base URL).
|
|
20
20
|
*/
|
|
21
21
|
import { execFileSync, spawn } from "node:child_process";
|
|
22
|
-
import { existsSync, mkdirSync, openSync, readdirSync,
|
|
22
|
+
import { closeSync, existsSync, mkdirSync, openSync, readdirSync, readSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
23
23
|
import { homedir, platform } from "node:os";
|
|
24
24
|
import { dirname, join } from "node:path";
|
|
25
25
|
import { fileURLToPath } from "node:url";
|
|
@@ -215,7 +215,18 @@ export function recentSurfaces(days = 30, home = homedir()) {
|
|
|
215
215
|
try {
|
|
216
216
|
if (statSync(p).mtimeMs < since)
|
|
217
217
|
continue;
|
|
218
|
-
|
|
218
|
+
// The surface is recorded in the first lines; never read a 300 MB
|
|
219
|
+
// transcript to find it (this took 10 s on a real machine).
|
|
220
|
+
const fd = openSync(p, "r");
|
|
221
|
+
const buf = Buffer.alloc(64 * 1024);
|
|
222
|
+
let n = 0;
|
|
223
|
+
try {
|
|
224
|
+
n = readSync(fd, buf, 0, buf.length, 0);
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
closeSync(fd);
|
|
228
|
+
}
|
|
229
|
+
const head = buf.toString("utf8", 0, n);
|
|
219
230
|
const m = head.match(/"entrypoint":"([^"]+)"/);
|
|
220
231
|
const ep = m ? m[1] : "unknown";
|
|
221
232
|
out.set(ep, (out.get(ep) ?? 0) + 1);
|
package/dist/mcp.js
CHANGED
|
@@ -49,7 +49,7 @@ const STRATEGY_IDS = ["dedupe", "trim-tool-results", "trim-tool-calls", "strip-b
|
|
|
49
49
|
* recommended pattern.
|
|
50
50
|
*/
|
|
51
51
|
function createServer() {
|
|
52
|
-
const server = new McpServer({ name: "context-doctor", version: "0.23.
|
|
52
|
+
const server = new McpServer({ name: "context-doctor", version: "0.23.1" }, { instructions: SERVER_INSTRUCTIONS });
|
|
53
53
|
server.tool("profile_context", "Profile an LLM conversation or prompt: token breakdown, largest blocks, and actionable findings about wasted context (duplicates, oversized pastes or tool results, base64 blobs, long history). Two inputs, pass ONE: `conversation` (full OpenAI/Anthropic JSON or raw text, for agents, files and proxies) or `sketch` (for chat apps such as Claude Desktop or ChatGPT where you cannot export the conversation: the turn count plus the few blocks that matter, ~120 tokens to write). Call it whenever the user asks about token usage, context size, cost, speed or limits, and on your own once the conversation passes ~30 turns or holds 3+ large pastes. Act on the top finding in your reply.", {
|
|
54
54
|
conversation: z.string().optional().describe("Conversation JSON (OpenAI or Anthropic format, or bare message array) or raw prompt text. Omit in chat apps and pass `sketch`."),
|
|
55
55
|
sketch: z.object({
|
package/dist/proxy.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface ProxyOptions extends OptimizeOptions {
|
|
|
47
47
|
openaiUpstream?: string;
|
|
48
48
|
}
|
|
49
49
|
/** Reported by /health so `autopilot status` can tell an outdated service from a current one. */
|
|
50
|
-
export declare const PROXY_VERSION = "0.23.
|
|
50
|
+
export declare const PROXY_VERSION = "0.23.1";
|
|
51
51
|
/**
|
|
52
52
|
* Remove a leading `/t/<token>` from a request path, or return undefined when
|
|
53
53
|
* the prefix is absent or the token differs. The comparison is constant time
|
package/dist/proxy.js
CHANGED
|
@@ -20,7 +20,7 @@ import { formatTokens, CHARS_PER_TOKEN, providerFor } from "./tokens.js";
|
|
|
20
20
|
import { formatUsd, inputCostUsd, pricingFor } from "./pricing.js";
|
|
21
21
|
import { recordLedger } from "./ledger.js";
|
|
22
22
|
/** Reported by /health so `autopilot status` can tell an outdated service from a current one. */
|
|
23
|
-
export const PROXY_VERSION = "0.23.
|
|
23
|
+
export const PROXY_VERSION = "0.23.1";
|
|
24
24
|
/** Connection-level headers that must not be forwarded. */
|
|
25
25
|
const SKIP_REQUEST_HEADERS = new Set(["host", "content-length", "connection", "transfer-encoding", "accept-encoding", "expect"]);
|
|
26
26
|
const SKIP_RESPONSE_HEADERS = new Set(["content-length", "content-encoding", "transfer-encoding", "connection"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-doctor",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "See what your Claude Code sessions cost and cut it: offers /compact when you return to a large session after the cache expired (every surface, desktop app included), and a cache-safe autopilot for terminal, IDE and API traffic. Token profiler, hooks, MCP tools and a Claude Code plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|