claude-code-cache-fix 1.6.1 → 1.6.2-debug.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/preload.mjs +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-cache-fix",
3
- "version": "1.6.1",
3
+ "version": "1.6.2-debug.1",
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
@@ -162,10 +162,19 @@ function sortSkillsBlock(text) {
162
162
  const match = text.match(
163
163
  /^([\s\S]*?\n\n)(- [\s\S]+?)(\n<\/system-reminder>\s*)$/
164
164
  );
165
- if (!match) return text;
165
+ if (!match) {
166
+ debugLog("SKILLS SORT: regex did NOT match — block passed through unsorted",
167
+ `(length=${text.length}, starts=${JSON.stringify(text.slice(0, 80))})`);
168
+ return text;
169
+ }
166
170
  const [, header, entriesText, footer] = match;
167
171
  const entries = entriesText.split(/\n(?=- )/);
172
+ const preSort = entries.map(e => (e.match(/^- ([^:]+)/) || [])[1] || "?");
168
173
  entries.sort();
174
+ const postSort = entries.map(e => (e.match(/^- ([^:]+)/) || [])[1] || "?");
175
+ const orderChanged = preSort.some((name, i) => name !== postSort[i]);
176
+ debugLog(`SKILLS SORT: ${entries.length} entries, order ${orderChanged ? "CHANGED" : "unchanged"}`,
177
+ `footer=${JSON.stringify(footer)}`);
169
178
  return header + entries.join("\n") + footer;
170
179
  }
171
180