claude-mem-lite 2.31.1 → 2.31.2

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.
@@ -10,7 +10,7 @@
10
10
  "plugins": [
11
11
  {
12
12
  "name": "claude-mem-lite",
13
- "version": "2.31.1",
13
+ "version": "2.31.2",
14
14
  "source": "./",
15
15
  "description": "Lightweight persistent memory system for Claude Code — FTS5 search, episode batching, error-triggered recall"
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "2.31.1",
3
+ "version": "2.31.2",
4
4
  "description": "Lightweight persistent memory system for Claude Code — FTS5 search, episode batching, error-triggered recall",
5
5
  "author": {
6
6
  "name": "sdsrss"
package/hook-update.mjs CHANGED
@@ -196,6 +196,7 @@ const SOURCE_FILES = [
196
196
  'cli.mjs', 'server.mjs', 'server-internals.mjs', 'tool-schemas.mjs',
197
197
  'hook.mjs', 'hook-shared.mjs', 'hook-llm.mjs', 'hook-memory.mjs', 'skip-tools.mjs',
198
198
  'hook-semaphore.mjs', 'hook-episode.mjs', 'hook-context.mjs', 'hook-handoff.mjs', 'hook-update.mjs',
199
+ 'hook-optimize.mjs', 'plugin-cache-guard.mjs',
199
200
  'haiku-client.mjs', 'utils.mjs', 'schema.mjs', 'package.json', 'package-lock.json', 'skill.md',
200
201
  'registry.mjs', 'registry-scanner.mjs', 'registry-indexer.mjs',
201
202
  'registry-retriever.mjs', 'resource-discovery.mjs',
@@ -289,6 +290,13 @@ export function installExtractedRelease(sourceDir, targetDir = INSTALL_DIR) {
289
290
  // Post-update: prune old plugin cache versions (keep latest 3)
290
291
  try { prunePluginCache(); } catch (e) { debugCatch(e, 'prunePluginCache'); }
291
292
 
293
+ // Post-update: clear cache hooks.json in every remaining version. Claude Code
294
+ // runtime reads plugin hooks from cache, not marketplace source — leaving populated
295
+ // cache hooks.json alongside install.mjs-written settings.json causes double firing.
296
+ // Inline impl (no import of plugin-cache-guard.mjs — this module must run even when
297
+ // the guard module is absent on disk, e.g. auto-upgrading from pre-2.31.2).
298
+ try { clearCacheHookResidue(); } catch (e) { debugCatch(e, 'clearCacheHookResidue'); }
299
+
292
300
  debugLog('DEBUG', 'hook-update', `Auto-update: switched ${installed.length} paths`);
293
301
  return true;
294
302
  } catch (err) {
@@ -348,6 +356,33 @@ function copyReleaseIntoStaging(sourceDir, stagingDir) {
348
356
  debugLog('DEBUG', 'hook-update', `Auto-update staged ${copied} source files`);
349
357
  }
350
358
 
359
+ // ── Cache hook residue clearing ────────────────────────────
360
+ // Inline (does not import plugin-cache-guard.mjs) so hook-update.mjs keeps working
361
+ // even if plugin-cache-guard.mjs is missing on disk in degraded installs.
362
+ export function clearCacheHookResidue() {
363
+ const cacheBase = join(homedir(), '.claude', 'plugins', 'cache', 'sdsrss', 'claude-mem-lite');
364
+ if (!existsSync(cacheBase)) return 0;
365
+ let cleared = 0;
366
+ for (const ver of readdirSync(cacheBase)) {
367
+ const p = join(cacheBase, ver, 'hooks', 'hooks.json');
368
+ if (!existsSync(p)) continue;
369
+ try {
370
+ const h = JSON.parse(readFileSync(p, 'utf8'));
371
+ if (!h.hooks || Object.keys(h.hooks).length === 0) continue;
372
+ writeFileSync(p, JSON.stringify({
373
+ description: h.description || 'claude-mem-lite hooks',
374
+ _note: `Auto-cleared by hook-update.mjs post-install — prevents double hook registration (cache ver: ${ver})`,
375
+ hooks: {},
376
+ }, null, 2) + '\n');
377
+ cleared++;
378
+ } catch { /* ignore single bad entry */ }
379
+ }
380
+ if (cleared > 0) {
381
+ debugLog('DEBUG', 'hook-update', `Cache hooks residue cleared in ${cleared} version(s)`);
382
+ }
383
+ return cleared;
384
+ }
385
+
351
386
  // ── Plugin Cache Pruning ──────────────────────────────────
352
387
  const PLUGIN_CACHE_KEEP = 3;
353
388
 
package/hook.mjs CHANGED
@@ -32,7 +32,16 @@ import { searchRelevantMemories } from './hook-memory.mjs';
32
32
  import { buildAndSaveHandoff, detectContinuationIntent, renderHandoffInjection, extractUnfinishedSummary } from './hook-handoff.mjs';
33
33
  import { checkForUpdate } from './hook-update.mjs';
34
34
  import { handleLLMOptimize } from './hook-optimize.mjs';
35
- import { clearPluginCacheHooks, hasInstallManagedHooks } from './plugin-cache-guard.mjs';
35
+ // plugin-cache-guard.mjs loaded dynamically — pre-2.31.2 installs that auto-upgraded
36
+ // from an older hook-update.mjs SOURCE_FILES (which did not list this module) would
37
+ // crash on static import. Degrade gracefully to no-op when the module is absent.
38
+ let _cacheGuardCache = null;
39
+ async function loadCacheGuard() {
40
+ if (_cacheGuardCache !== null) return _cacheGuardCache;
41
+ try { _cacheGuardCache = await import('./plugin-cache-guard.mjs'); }
42
+ catch { _cacheGuardCache = {}; }
43
+ return _cacheGuardCache;
44
+ }
36
45
  import { SKIP_TOOLS, SKIP_PREFIXES } from './skip-tools.mjs';
37
46
  import { getVocabulary } from './tfidf.mjs';
38
47
 
@@ -402,9 +411,12 @@ async function handleSessionStart() {
402
411
  // re-populate cache/<ver>/hooks/hooks.json, reintroducing duplicate hook
403
412
  // registration alongside install.mjs-managed settings.json entries. Silently
404
413
  // clear — gated by hasInstallManagedHooks to avoid breaking plugin-only users.
414
+ // Dynamic-import fallback: if plugin-cache-guard.mjs is missing (pre-2.31.2
415
+ // auto-upgrade install), skip self-heal instead of crashing the entire hook.
405
416
  try {
406
- if (hasInstallManagedHooks()) {
407
- const cleared = clearPluginCacheHooks({
417
+ const guard = await loadCacheGuard();
418
+ if (guard.hasInstallManagedHooks && guard.hasInstallManagedHooks()) {
419
+ const cleared = guard.clearPluginCacheHooks({
408
420
  reason: 'Auto-healed by hook.mjs session-start — install.mjs-managed hooks active in settings.json',
409
421
  });
410
422
  if (cleared.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "2.31.1",
3
+ "version": "2.31.2",
4
4
  "description": "Lightweight persistent memory system for Claude Code",
5
5
  "type": "module",
6
6
  "engines": {