v1.0.120 — scoped ctx_purge
Hotfix landing the deferred Issue #520 (scoped ctx_purge with sessionId / scope parameters), reported by @murataslan1. Fully additive — existing {confirm: true} callers still work but emit a one-release deprecation warning.
What changed
#520 — scoped ctx_purge
The previous schema was { confirm: boolean }, which always wiped the entire project (FTS5 store + sessionsDir + stats file). v1.0.120 adds two optional parameters:
sessionId?: string— UUID of a single session. Deletes only that session's events row + per-session FTS5 chunks. Preserves stats file and sibling sessions.scope?: "session" | "project"— explicit scope selector.
Refusal rules (MUST language)
The new schema is strict to prevent accidental project-wide wipes:
| Invocation | Behavior |
|---|---|
{ confirm: true, sessionId: "uuid" }
| ✅ Wipes ONLY that session |
{ confirm: true, scope: "project" }
| ✅ Wipes ENTIRE project (KB + sessions + stats) |
{ confirm: true } (bare)
| ⚠️ Treated as scope: "project" + deprecation warning to stderr
|
{ confirm: true, sessionId: "...", scope: "project" }
| ❌ REFUSED — ambiguous |
{ confirm: false, ... }
| ❌ REFUSED — destructive op requires confirm |
The MCP tool description was rewritten in contract style with MUST/MUST NOT language and explicit examples so calling LLMs do not confuse the two modes.
Tests
8 new vertical TDD slices in tests/session/purge-session.test.ts:
- refuses ambiguous combinations
- per-session SQL delete on
session_events - per-session FTS5 chunk delete with sibling preservation
- stats file preserved on
scope:"session" - backward compat: bare
{confirm:true}matches today's behavior + emits warning - handler-level scope-gate assertion
Compatibility
15 adapters / 3 OS. No breaking changes — bare {confirm:true} still works through the deprecation cycle. v1.0.121 will require explicit scope.
Upgrade
npm install -g context-mode@latest
# inside Claude Code:
/ctx-upgrade
# restart your sessionThanks
@murataslan1 — well-structured Observed/Expected/Repro/Suggested-fix report that scoped the design space cleanly. Ship in v1.0.120 (deferred from v1.0.119 to keep the bug ship focused).