Skip to content
This repository was archived by the owner on Jun 23, 2026. It is now read-only.

v0.5.6 — capture pipeline correctness (dedup + SessionEnd + PreCompact)

Latest

Choose a tag to compare

@VKirill VKirill released this 17 May 21:43
· 2 commits to main since this release

TL;DR

Capture pipeline correctness fix. The Stop hook in Claude Code fires per-turn (after every Claude response), not per-session — and the wrapper captures the rolling 4 KB transcript tail each fire. Real install showed 40% duplication (269 of 662 L0 rows were exact copies).

This release adds dedup at the capture layer and extends hook coverage to PreCompact + SessionEnd, closing the gap where /clear and /compact previously lost their dialog without being captured.

Drop-in upgrade from 0.5.5 — no DB schema change.

Upgrade from 0.5.5

npm i -g github:VKirill/TencentDB-Memory-Claude-Code#v0.5.6

# Re-run install.sh to pick up new event subscriptions:
bash "$(npm root -g)/@vkirill/tencentdb-memory-claude-code/claude-code-integration/install.sh"

# Restart Claude Code so MCP picks up new binary

What changed

Fixed: Dedup in runCapture

Stop hook fires after every Claude response. The wrapper captures the rolling 4 KB transcript tail each time. Without dedup, the same content was recorded 2-5× per session — confirmed on real install:

Walkaround on /home/ubuntu/{*}/.claude/memory/conversations/:
  total lines before: 662
  total lines after:  393
  dropped duplicates: 269 (40%)

runCapture now reads the last user+assistant pair from today's JSONL and compares against the incoming payload. If identical under the same sessionKey, the write is skipped and the call returns { ok: true, l0Recorded: 0 } with a debug log:

[capture] dedup skip — identical to last record

"Nothing changed" is success — hook discipline already requires exit 0.

Added: Subscribe to PreCompact + SessionEnd

Claude Code emits richer lifecycle events the fork was ignoring:

Event Fires when Why it matters
PreCompact BEFORE context compaction Capture full dialogue before nuance is summarized away
SessionEnd On /clear, /compact, /exit, /logout (matcher tells you which) Paths that Stop alone never sees
Stop (existing) After every Claude response Per-turn capture (now deduped)

All three events share the transcript_path schema, so the existing stop-wrapper.sh handles them with no code change. With the dedup layer above, multiple events firing on overlapping content stay idempotent.

install.sh's existing jq deep-merge unions hook arrays per event name, so the two new subscriptions pass through automatically on next install.sh run — no migration script needed.

Migration notes

  • Existing installs: re-run install.sh once to pick up new event subscriptions in ~/.claude/settings.json. Old subscriptions are preserved (merge, not overwrite).
  • Historical duplicates in JSONL are unaffected — the dedup is only for new writes. A one-shot cleanup can be done with the included logic:
    # See dedup walkaround in PR — drops by (sessionId, role, content) tuple
  • No DB schema change. Existing vectors.db files continue working.
  • Tests: new dedup test in capture.test.ts covers first-write / identical-skip / different-append.