claude-token-saver 3.5.0 → 3.5.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/src/installer.js +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-token-saver",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Save tokens on Claude Code — spike diagnosis, 1M-context detection, TTL countdown, statusline. (formerly claude-cache-monitor)",
5
5
  "type": "module",
6
6
  "bin": {
package/src/installer.js CHANGED
@@ -223,6 +223,11 @@ export function installSessionStartHook() {
223
223
  }
224
224
 
225
225
  settings.hooks = settings.hooks || {};
226
+ // A present-but-non-array value is schema-invalid, but it's the user's
227
+ // data — back off instead of silently replacing it.
228
+ if (settings.hooks.SessionStart !== undefined && !Array.isArray(settings.hooks.SessionStart)) {
229
+ return { path: file, action: 'skipped', reason: 'hooks.SessionStart is not an array — fix settings.json manually' };
230
+ }
226
231
  const list = Array.isArray(settings.hooks.SessionStart) ? settings.hooks.SessionStart : [];
227
232
  const already = list.some((m) =>
228
233
  Array.isArray(m?.hooks) && m.hooks.some((h) => typeof h?.command === 'string' && h.command.includes('route-scan --hook')),
@@ -260,6 +265,11 @@ export function installBriefHook() {
260
265
  }
261
266
 
262
267
  settings.hooks = settings.hooks || {};
268
+ // A present-but-non-array value is schema-invalid, but it's the user's
269
+ // data — back off instead of silently replacing it.
270
+ if (settings.hooks.UserPromptSubmit !== undefined && !Array.isArray(settings.hooks.UserPromptSubmit)) {
271
+ return { path: file, action: 'skipped', reason: 'hooks.UserPromptSubmit is not an array — fix settings.json manually' };
272
+ }
263
273
  const list = Array.isArray(settings.hooks.UserPromptSubmit) ? settings.hooks.UserPromptSubmit : [];
264
274
  const already = list.some((m) =>
265
275
  Array.isArray(m?.hooks) && m.hooks.some((h) => typeof h?.command === 'string' && h.command.includes('brief --hook')),