claude-code-cache-fix 2.0.0-beta.2 → 2.0.0-beta.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/preload.mjs +13 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-cache-fix",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.3",
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
@@ -1384,7 +1384,7 @@ globalThis.fetch = async function (url, options) {
1384
1384
  if (block.type === "tool_result" && typeof block.content === "string" && block.content.includes("<system-reminder>")) {
1385
1385
  let newContent = block.content;
1386
1386
  for (let p = 0; p < smooshPatterns.length; p++) {
1387
- smooshPatterns[p].lastIndex = 0; // reset regex state
1387
+ smooshPatterns[p].lastIndex = 0;
1388
1388
  newContent = newContent.replace(smooshPatterns[p], smooshReplacements[p]);
1389
1389
  }
1390
1390
  if (newContent !== block.content) {
@@ -1392,6 +1392,18 @@ globalThis.fetch = async function (url, options) {
1392
1392
  smooshNormalized++;
1393
1393
  }
1394
1394
  }
1395
+ // Unsmooshed standalone text blocks with dynamic system-reminder content
1396
+ if (block.type === "text" && typeof block.text === "string" && block.text.startsWith("<system-reminder>")) {
1397
+ let newText = block.text;
1398
+ for (let p = 0; p < smooshPatterns.length; p++) {
1399
+ smooshPatterns[p].lastIndex = 0;
1400
+ newText = newText.replace(smooshPatterns[p], smooshReplacements[p]);
1401
+ }
1402
+ if (newText !== block.text) {
1403
+ msg.content[i] = { ...block, text: newText };
1404
+ smooshNormalized++;
1405
+ }
1406
+ }
1395
1407
  }
1396
1408
  }
1397
1409
  }