claude-code-cache-fix 1.1.0 → 1.3.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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/package.json +1 -1
  3. package/preload.mjs +31 -0
package/README.md CHANGED
@@ -131,6 +131,7 @@ Logs are written to `~/.claude/cache-fix-debug.log`. Look for:
131
131
  - `BUDGET WARNING: tool result chars at N / 200,000 threshold` — approaching budget cap
132
132
  - `FALSE RATE LIMIT: synthetic model detected` — client-side false rate limit
133
133
  - `GROWTHBOOK FLAGS: {...}` — server-controlled feature flags on first call
134
+ - `PROMPT SIZE: system=N tools=N injected=N (skills=N mcp=N ...)` — per-call prompt size breakdown
134
135
  - `SKIPPED: resume relocation (not a resume or already correct)` — no fix needed
135
136
 
136
137
  ### Prefix diff mode
@@ -170,6 +171,7 @@ Snapshots are saved to `~/.claude/cache-fix-snapshots/` and diff reports are gen
170
171
  ## Related research
171
172
 
172
173
  - **[@ArkNill/claude-code-hidden-problem-analysis](https://github.com/ArkNill/claude-code-hidden-problem-analysis)** — Systematic proxy-based analysis of 7 bugs including microcompact, budget enforcement, false rate limiter, and extended thinking quota impact. The monitoring features in v1.1.0 are informed by this research.
174
+ - **[@Renvect/X-Ray-Claude-Code-Interceptor](https://github.com/Renvect/X-Ray-Claude-Code-Interceptor)** — Diagnostic HTTPS proxy with real-time dashboard, system prompt section diffing, per-tool stripping thresholds, and multi-stream JSONL logging. Works with any Claude client that supports `ANTHROPIC_BASE_URL` (CLI, VS Code extension, desktop app), complementing this package's CLI-only `NODE_OPTIONS` approach.
173
175
 
174
176
  ## Contributors
175
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-cache-fix",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Fixes prompt cache regression in Claude Code that causes up to 20x cost increase on resumed sessions",
5
5
  "type": "module",
6
6
  "exports": "./preload.mjs",
package/preload.mjs CHANGED
@@ -731,6 +731,37 @@ globalThis.fetch = async function (url, options) {
731
731
  monitorContextDegradation(payload.messages);
732
732
  }
733
733
 
734
+ // Prompt size measurement — log system prompt, tools, and injected block sizes
735
+ if (DEBUG && payload.system && payload.tools && payload.messages) {
736
+ const sysChars = JSON.stringify(payload.system).length;
737
+ const toolsChars = JSON.stringify(payload.tools).length;
738
+ const firstUserIdx = payload.messages.findIndex(m => m.role === "user");
739
+ if (firstUserIdx !== -1) {
740
+ const msg0 = payload.messages[firstUserIdx];
741
+ if (Array.isArray(msg0.content)) {
742
+ let skillsChars = 0;
743
+ let mcpChars = 0;
744
+ let deferredChars = 0;
745
+ let hooksChars = 0;
746
+ for (const block of msg0.content) {
747
+ const text = block.text || "";
748
+ if (isSkillsBlock(text)) skillsChars += text.length;
749
+ else if (isMcpBlock(text)) mcpChars += text.length;
750
+ else if (isDeferredToolsBlock(text)) deferredChars += text.length;
751
+ else if (isHooksBlock(text)) hooksChars += text.length;
752
+ }
753
+ const injectedTotal = skillsChars + mcpChars + deferredChars + hooksChars;
754
+ if (injectedTotal > 0) {
755
+ debugLog(
756
+ `PROMPT SIZE: system=${sysChars} tools=${toolsChars}`,
757
+ `injected=${injectedTotal} (skills=${skillsChars} mcp=${mcpChars}`,
758
+ `deferred=${deferredChars} hooks=${hooksChars})`
759
+ );
760
+ }
761
+ }
762
+ }
763
+ }
764
+
734
765
  // Capture prefix snapshot for cross-process diff analysis
735
766
  snapshotPrefix(payload);
736
767