github mksglu/context-mode v1.0.145

latest release: v1.0.146
6 hours ago

v1.0.145

Five independent fixes — each one a contributor-spotted defect that the EM army turned around in one wave.

Fixes

SessionStart cache cleanup no longer follows symlinks (#644). hooks/sessionstart.mjs:44,249 used statSync for the 1-hour age gate. statSync follows symlinks, so fresh symlinks were evaluated against the target's stale mtime, tripped the gate, and got unlinked by rmSync({recursive: true, force: true}). Switched to lstatSync per upstream openclaw / gemini-cli precedent. Closes #644.

Pi + OMP SessionDB now uses canonical path (#645). Two adapters wrote SessionDB to a hardcoded <sessionDir>/context-mode.db literal while the MCP server read from the canonical <16-hex-hash>.db produced by resolveSessionDbPath. Two files, different filenames, never the same — ctx_stats and ctx_search timeline silently degraded for every Pi/OMP user. Commit d923716 ("C2 narrowing") migrated only the opencode adapter; Pi (predates the resolver) and OMP (copy-pasted from Pi) were missed. Both adapters now route through resolveSessionDbPath. Bonus: a parallel bug in src/adapters/openclaw/plugin.ts:199-205 uses raw sha256().slice(0,16) instead of the resolver — flagged for follow-up. Closes #645.

ctx_search source filter no longer leaks across sources (#646). ContentStore#sourceFilterParam (src/store.ts:1010) interpolated user source labels into %${source}% without escaping SQLite LIKE metacharacters. Search scoped to api_v1 returned chunks from apiXv1, api-v1, etc. 100%off matched any 100…off source. v1.0.145 escapes \%_ (order matters; backslash first) and adds ESCAPE '\\' to all four prepared LIKE statements (Porter/Trigram × plain/ContentType). Closes #646.

Pi MCP bridge retries initialize on slow handshake (#647). Single un-retried initialize handshake on cold NFS / JIT warm-up / constrained CI surfaced as a 60s timeout → extension logged once and ran the session with no ctx_* tools while the routing block kept emitting ~2.5K tokens/turn of dead instructions. Retry loop wrapping start() + initialize() — 1 + 2 attempts, 1s backoff, client.shutdown() between attempts to release fds. Per-attempt 60s bound unchanged (preserves #643 contract). Mirrors #583 respawn sequencing, hoisted to bootstrap layer. Closes #647.

CONTEXT_MODE_DATA_DIR env var lets users relocate storage (#649). Single override for getSessionDir + getMemoryDir across all adapters (claude-code, codex, opencode, vscode-copilot, openclaw, others). getConfigDir deliberately untouched — that's platform-native config, not context-mode-owned state. Honors tilde expansion + whitespace + unset fallback. New resolveContextModeDataRoot() helper in src/adapters/base.ts. Closes #649.

Tests

  • 1 new test in existing tests/core/cli.test.ts (#644 lstatSync source-pin)
  • 1+1 new tests in existing tests/pi-extension.test.ts + tests/adapters/omp-plugin.test.ts (#645 — plus 4 pre-existing tests migrated, not deleted)
  • 4 new tests in existing tests/store.test.ts (#646 wildcard + backslash + plain)
  • 2 new tests in existing tests/adapters/pi-mcp-bridge.test.ts Slice 9 (#647 retry exhaustion + success-on-second-attempt)
  • 7 new tests in existing tests/adapters/base-adapter-memory.test.ts (#649 override + tilde + whitespace + getConfigDir-NOT-relocated)

All slotted per CONTRIBUTING L275 — no new test files. Full suite: 3408+ pass.

Compatibility

15 adapters, 3 OS. No schema migration. engines.node >= 22.5.0 preserved. New env var CONTEXT_MODE_DATA_DIR is opt-in (unset = current behavior).

Upgrade

npm install -g context-mode@latest
# Restart Claude Code / Pi / OpenCode (Cmd+Q + reopen)

Credits

  • @dtmsyi#644 file:line + root cause + fix exact
  • Reporter who flagged #645 with the path discrepancy
  • Reporter who flagged #646 with LIKE-wildcard repro
  • Reporter who diagnosed #647 — bisect + reasoning verbatim
  • @jetnet#649 with the universal-override scope nailed

Don't miss a new context-mode release

NewReleases is sending notifications on new releases.