{"versions":{"0.1.0":{"name":"dsh-recall","version":"0.1.0","description":"Conversation history recall for DeepSeek Harness: search the original text of every session (like searching chat records) — literal/fuzzy/semantic retrieval, fully local & offline. AI never forgets what you told it.","type":"module","main":"lib/index.js","exports":{".":{"default":"./lib/index.js"},"./client":{"default":"./lib/client.js"},"./package.json":"./package.json"},"dsh":{"client":{"platform":"web"},"bundle":{"patch":"./cordis.patch.yml"}},"optionalDependencies":{"dsh-recall-models":"0.1.0"},"dependencies":{"@deepseek-ai/dsh-tools":"^0.1.0-rc.6"},"engines":{"node":">=22"},"keywords":["dsh","deepseek-harness","recall","memory","history","search","semantic-search","cordis"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Relistencode/dsh-recall.git"},"gitHead":"3e895767ec70d30cd1b3682911483654296dab4a","_id":"dsh-recall@0.1.0","bugs":{"url":"https://github.com/Relistencode/dsh-recall/issues"},"homepage":"https://github.com/Relistencode/dsh-recall#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-ZZtbEwJtN0/umj254Xt0qx+S9sqfv6L1X2VVWh+2rrfuLv2nHKMdYF5bzZX5CXfohrT+PYK35c5ji+Fg5l5tnA==","shasum":"8c35c89e31f0c8467e9f2654f7ae91616fbc4f7c","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dsh-recall/-/dsh-recall-0.1.0.tgz","fileCount":17,"unpackedSize":14202869,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDNYxpNpI1de+l1HvF4kUeWQY8emSnBAdHo35MMAqdaJAIhAMKRvHNqSCdu2Il95gSXrVyn7fhP0OWsNiE1U7/B+mAn"}],"size":3661315},"_npmUser":{"name":"anonymous","email":"1405650786@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"1405650786@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-recall_0.1.0_1786837380054_0.78201423585354"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-08-15T23:43:00.325Z","publish_time":1786837380325,"_source_registry_name":"default","contributors":[]},"0.2.0":{"name":"dsh-recall","version":"0.2.0","description":"Conversation history recall for DeepSeek Harness: search the original text of every session (like searching chat records) — literal/fuzzy/semantic retrieval, fully local & offline. AI never forgets what you told it.","type":"module","main":"lib/index.js","exports":{".":{"default":"./lib/index.js"},"./client":{"default":"./lib/client.js"},"./package.json":"./package.json"},"dsh":{"client":{"platform":"web"},"bundle":{"patch":"./cordis.patch.yml"}},"optionalDependencies":{"dsh-recall-models":"0.1.0"},"dependencies":{"@deepseek-ai/dsh-tools":"^0.1.0-rc.6"},"engines":{"node":">=22"},"keywords":["dsh","deepseek-harness","recall","memory","history","search","semantic-search","cordis"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Relistencode/dsh-recall.git"},"gitHead":"7bcfc4c9f08a688d1c571753965bd56a9d23f2ee","_id":"dsh-recall@0.2.0","bugs":{"url":"https://github.com/Relistencode/dsh-recall/issues"},"homepage":"https://github.com/Relistencode/dsh-recall#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-y+sw9HXm25MjqIKUUE76zwMocI3SqIl38jVqYIbQSi4ppq3RqT4FQHQTjGkMmMR9PHCpd3ejW+Yvolsvl87mUA==","shasum":"afda4434645f8924f311898c55c178a875ce06c7","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dsh-recall/-/dsh-recall-0.2.0.tgz","fileCount":17,"unpackedSize":14221971,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB31nr1zs8XdG6M/DQeiuw4CWv46tD8qLHAZvmEfYcY4AiAflaAyJnrOEowJzeI8L0TrsGlK8X9+Fo+/8EzIjd/o7g=="}],"size":3666942},"_npmUser":{"name":"anonymous","email":"1405650786@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"1405650786@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-recall_0.2.0_1786863411841_0.6780424083673715"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-08-16T06:56:52.058Z","publish_time":1786863412058,"_source_registry_name":"default","contributors":[]},"0.2.1":{"name":"dsh-recall","version":"0.2.1","description":"Conversation history recall for DeepSeek Harness: search the original text of every session (like searching chat records) — literal/fuzzy/semantic retrieval, fully local & offline. AI never forgets what you told it.","type":"module","main":"lib/index.js","exports":{".":{"default":"./lib/index.js"},"./client":{"default":"./lib/client.js"},"./package.json":"./package.json"},"dsh":{"client":{"platform":"web"},"bundle":{"patch":"./cordis.patch.yml"}},"optionalDependencies":{"dsh-recall-models":"0.1.0"},"dependencies":{"@deepseek-ai/dsh-tools":"^0.1.0-rc.6"},"engines":{"node":">=22"},"keywords":["dsh","deepseek-harness","recall","memory","history","search","semantic-search","cordis"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Relistencode/dsh-recall.git"},"gitHead":"30fe99fa17f822d3bd91945120d3d437ff39acca","_id":"dsh-recall@0.2.1","bugs":{"url":"https://github.com/Relistencode/dsh-recall/issues"},"homepage":"https://github.com/Relistencode/dsh-recall#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-yHNp0Es58wtKaAG9Fr8cRa04ffZzWSYvgvzAxS/LqWpdvxEA7o04NhRfLmHBHWmWdRSXPGMaPeYp8Nrbivozkw==","shasum":"5cb9299d97004e9b2e1a7e575693eb26e7efc9ee","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dsh-recall/-/dsh-recall-0.2.1.tgz","fileCount":17,"unpackedSize":14222712,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD6tDRwnZnyaSYdn7PohxdplG06610LubMQf2jyB1OAagIhAJiCvsPbBXnalZX5XSmyJyxdfMLCe08vs/HdmBmfUMYA"}],"size":3667212},"_npmUser":{"name":"anonymous","email":"1405650786@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"1405650786@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-recall_0.2.1_1786865212215_0.8957067079207519"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-08-16T07:26:52.433Z","publish_time":1786865212433,"_source_registry_name":"default","contributors":[]},"0.2.2":{"name":"dsh-recall","version":"0.2.2","description":"Conversation history recall for DeepSeek Harness: search the original text of every session (like searching chat records) — literal/fuzzy/semantic retrieval, fully local & offline. AI never forgets what you told it.","type":"module","main":"lib/index.js","exports":{".":{"default":"./lib/index.js"},"./client":{"default":"./lib/client.js"},"./package.json":"./package.json"},"dsh":{"client":{"platform":"web"},"bundle":{"patch":"./cordis.patch.yml"}},"optionalDependencies":{"dsh-recall-models":"0.1.0"},"dependencies":{"@deepseek-ai/dsh-tools":"^0.1.0-rc.6"},"engines":{"node":">=22"},"keywords":["dsh","deepseek-harness","recall","memory","history","search","semantic-search","cordis"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Relistencode/dsh-recall.git"},"gitHead":"6ca6a174f89ba4a2259197f5a5b5b71f2df3f1fd","_id":"dsh-recall@0.2.2","bugs":{"url":"https://github.com/Relistencode/dsh-recall/issues"},"homepage":"https://github.com/Relistencode/dsh-recall#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-dF7Upw0fFh6MjJett2T6DDz4s21EjALlgQxyDSRY1KeM0G7dzBjXGYQuIPDqKTm3P4vhd9rtvXeAnH4KLuhr4Q==","shasum":"29fa4bf9d0e6881ddbbec26d5f14de0ad1bd3a8d","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dsh-recall/-/dsh-recall-0.2.2.tgz","fileCount":19,"unpackedSize":14250859,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICH0+fto1JBrsjmhiVe2Jwk5oCtTZyA+i2PnHW4goyJhAiBnx6xFxi+2MooFs1bPtpm7AO9z+oArKXhu76ET6NhtrQ=="}],"size":3675419},"_npmUser":{"name":"anonymous","email":"1405650786@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"1405650786@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-recall_0.2.2_1786873119409_0.6192097552132838"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-08-16T09:38:39.689Z","publish_time":1786873119689,"_source_registry_name":"default","contributors":[]},"0.3.0":{"_id":"dsh-recall@0.3.0","dsh":{"bundle":{"patch":"./cordis.patch.yml"},"client":{"platform":"web"}},"bugs":{"url":"https://github.com/Relistencode/dsh-recall/issues"},"dist":{"shasum":"a686b244efaf911e58103eef9cc3008804c28d96","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dsh-recall/-/dsh-recall-0.3.0.tgz","fileCount":20,"integrity":"sha512-ziHAC5UPn56rdGY40yxFT/zsSzO0TFQt+OrHJ4ls4v85KVmMpoZpIHtYl+6Fip3n5qZ9sxvXR6Mh5Xd/QIZ/jg==","signatures":[{"sig":"MEUCIFNS7LMNeYKuolsJv2F5NoEkxScmJnSnKA0E9rL761ElAiEAt5vMCa0KYZCQ1tqvHL+ngKFe9Q9N/wrXRnTneuKroTc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDBNKR+JiHGhVw72qm+d1jUs4WKkKNnMQXtENY1cvJnsAiAOdqY3bd2TOpOB2psClKmWu5sLTsap4a+NGIb3z8VvJQ=="}],"unpackedSize":14271180,"size":3682034},"main":"lib/index.js","name":"dsh-recall","type":"module","engines":{"node":">=22"},"exports":{".":{"default":"./lib/index.js"},"./client":{"default":"./lib/client.js"},"./package.json":"./package.json"},"gitHead":"83e1611111d233865f39d542ca40c07d0c0cf68b","license":"MIT","version":"0.3.0","_npmUser":{"name":"anonymous","email":"1405650786@qq.com"},"homepage":"https://github.com/Relistencode/dsh-recall#readme","keywords":["dsh","deepseek-harness","recall","memory","history","search","semantic-search","cordis"],"repository":{"url":"git+https://github.com/Relistencode/dsh-recall.git","type":"git"},"_npmVersion":"11.9.0","description":"Conversation history recall for DeepSeek Harness: search the original text of every session (like searching chat records) — literal/fuzzy/semantic retrieval, fully local & offline, plus a silent host auto-recall layer that injects relevant history when yo","directories":{},"maintainers":[{"name":"anonymous","email":"1405650786@qq.com"}],"_nodeVersion":"24.14.0","dependencies":{"@deepseek-ai/dsh-tools":"^0.1.0-rc.6"},"_hasShrinkwrap":false,"optionalDependencies":{"dsh-recall-models":"0.1.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-recall_0.3.0_1787322045275_0.8357496225207179"},"_cnpmcore_publish_time":"2026-08-21T14:20:45.531Z","publish_time":1787322045531,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.3.0"},"name":"dsh-recall","time":{"created":"2026-08-15T23:43:16.952Z","modified":"2026-08-21T14:21:04.170Z","0.1.0":"2026-08-15T23:43:00.325Z","0.2.0":"2026-08-16T06:56:52.058Z","0.2.1":"2026-08-16T07:26:52.433Z","0.2.2":"2026-08-16T09:38:39.689Z","0.3.0":"2026-08-21T14:20:45.531Z"},"readme":"# dsh-recall\n\n🌏 [中文](README.zh.md) · English\n\n<div align=\"center\">\n\n**Conversation history recall plugin — a \"memory maze\" for your DeepSeek Harness agent**\n\n[![Version](https://img.shields.io/badge/version-0.2.2-2563EB)](https://www.npmjs.com/package/dsh-recall)\n[![License](https://img.shields.io/badge/License-MIT-22C55E)](LICENSE)\n[![Node](https://img.shields.io/badge/Node-%E2%89%A522-16A34A)](package.json)\n[![Platform](https://img.shields.io/badge/DSH-web-0F172A)](https://github.com/deepseek-ai/deepseek-harness)\n[![Offline](https://img.shields.io/badge/offline-100%25-0891B2)\n\n</div>\n\n> **AI never forgets what you told it.**\n\nA native [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) plugin that gives the agent a **memory maze** — corridors and rooms built from every conversation you have had together. Every decision, setting, discussion, or casually mentioned requirement is remembered. Ask \"where were we?\" and it walks the maze, brings back the conversation **verbatim**, and answers as naturally as if it had never forgotten — you won't even notice it thought for a moment.\n\nConversation history recall · Three-layer retrieval (literal / fuzzy / semantic) · Fully local & offline · Compaction-proof\n\n- While searching, a quiet sweeping light appears in the corner:\n\n  ![Recalling](assets/recalling.png)\n\n- When done, no trace:\n\n  ![Recall complete](assets/recall-done.png)\n\n## Who is it for\n\n- **Heavy users of long sessions** — conversations spanning days and hundreds of turns, too long to scroll back through\n- **Writers / RP / tavern players** — settings, foreshadowing, and character relationships scattered across months of chat\n- **Code & doc maintainers** — the reasoning behind past decisions and pitfalls, now reduced to a one-line summary\n- **Anyone who has said \"didn't we discuss this before?\"** — it brings back the original words instead of making you retell them\n\nConversely, if your sessions are short and easy to scroll, you probably don't need it — it is built for \"history too long, memory compacted\" scenarios.\n\n## Quick start\n\n```sh\ndsh plugin --profile web add dsh-recall@0.2.2\n```\n\nOne command: the package ships its own composition patch (bundle layer), so the plugin and the search index it needs are wired up automatically. Restart `dsh web`. Nothing else to do — the model ships with the package (~37MB full install), the index builds on first search, and semantic warm-up finishes quietly in the background (a few minutes, imperceptible to you).\n\n> You can also install / disable / uninstall dsh-recall from the **Add-ons** block of the Plugin Management tab in [dsh-extension-hub](https://github.com/Relistencode/dsh-extension-hub).\n\n**Install from source (git clone):**\n\n```sh\ndsh plugin --profile web add git+https://github.com/Relistencode/dsh-recall.git\n```\n\nThe repository tracks the model (`models/model_merged.onnx`) and the vendored runtime, so a git install is fully functional offline with no build step and no `allowBuilds` entry. The optional `dsh-recall-models` dependency is still attempted from npm; if it fails to resolve, the in-repo model is used instead — either way the semantic layer works. The harness resolves all paths through `$DSH_HOME` (default `~/.dsh`), so this works identically regardless of where your harness home lives.\n\n### Optional configuration\n\n```yaml\n- id: recall\n  name: dsh-recall\n  config:\n    semantic: false   # disable the semantic layer (literal + fuzzy only, smaller package)\n    warmup: gentle    # slower warm-up, lower background CPU (only during warm-up; zero afterwards)\n```\n\n## What it is not\n\n- ❌ **Not context engineering** — it does not cram history into the model window\n- ❌ **Not prompt engineering** — it does not rely on prompts to make the model \"pretend to remember\"\n- ❌ **Not a memory-document system** — no MEMORY.md or manual notes to maintain\n- ✅ It is **actual recall**: on-demand retrieval of the **original records** — including history **already compacted away** (compaction only summarizes; the original text stays searchable forever)\n\n## Capability overview\n\n| Capability | Implementation |\n|---|---|\n| Three-layer hybrid retrieval | Literal / fuzzy / semantic merged automatically with a coverage gate (≥90%) and a silent degradation chain |\n| Progressive disclosure | Light coarse recall by default (titles + snippets + events, ~100–800 tokens); `detail` drills into the original text — hit list / exact window / paged browsing |\n| Event aggregation | Repeated mentions of one topic merge into events (`[startSeq..endSeq]`, ≤5 text blocks apart) — one complete episode instead of scattered fragments; the full event text is one `detail` browse away |\n| Proactive recall | The agent recalls on its own when needed (after compaction, when details are missing); explicit user requests also work |\n| Auto-recall layer | A deterministic host-side gate on user messages (process commands / past-reference wording + fuzzy-verified old-only segments) silently injects the relevant history — no extra LLM call, no UI |\n| Compaction anchor | On `compaction/summary`, one lightweight anchor is injected automatically (summary + key original fragments, expires after 3 turns) |\n| Scope control | Current session only by default; `workspace` / `all` only on explicit user request |\n| Compaction-proof | Index covers the full history, including shadowed (compacted) events |\n| Incremental indexing | Live sessions via `ctx.sessions`, persisted via `sessionPersistence`, append-only deltas |\n| Background warm-up | Worker-thread embedding (~10 texts/sec), host event loop never blocked |\n| Invisible UI | \"Recalling…\" sweep → one quiet \"Recall complete\" line; results never enter the UI, the agent presents them naturally |\n| Fully local & offline | Zero npm runtime dependencies; no external model APIs; works with no network at all |\n\n## Architecture\n\n<img src=\"docs/assets/recall-architecture.svg\" width=\"100%\" alt=\"dsh-recall architecture: turn lifecycle on top, capability layers below\">\n\n- **Turn lifecycle (top)**: one recall is a straight line — the user asks, the agent calls the `recall` tool, the three layers are searched, hits are grouped into events per session, and the agent receives either a light coarse recall or a drill-down window, depending on what it needs.\n- **Retrieval layer**: three independent retrieval channels (literal / fuzzy / semantic) that merge under a coverage gate (see [Three-layer hybrid retrieval](#three-layer-hybrid-retrieval)).\n- **Index & data**: everything is read through official services (`ctx.sessions` / `ctx.sessionPersistence` / `ctx.sessionQuery`) — no `.zstd` parsing, no private formats. The plugin's own `recall-index.db` (SQLite) holds the fuzzy index, the vectors and the trigram FTS.\n- **Governance & scope**: the scope red line (session by default), the coverage gate, the degradation chain, and the token budget live here.\n- **Automatic layer**: two silent listeners — a `compaction/summary` listener that turns every compaction into one lightweight anchor, and the auto-recall gate that watches user messages and silently injects relevant history when the user refers to earlier discussion.\n\n## Core mechanisms\n\n### Three-layer hybrid retrieval\n\n| Layer | Technique | Covers |\n|---|---|---|\n| Literal | Official FTS5 full-text index | Exact keyword matches |\n| Fuzzy | Self-built trigram + char-bigram index (zero dependencies) | Rough wording, remembered fragments, typos / missing chars |\n| Semantic | Local bge-small-zh model (int8, 24MB, bundled) | Paraphrase, word substitution, \"roughly what it was about\" |\n\n<img src=\"docs/assets/recall-retrieval.svg\" width=\"100%\" alt=\"Three-layer retrieval: query fans out to literal/fuzzy/semantic, merges through the coverage gate\">\n\n- The fuzzy layer is the **primary path** (it already covers the literal layer's ground with far more tolerance); the official FTS5 layer is the fallback; the semantic layer **joins the mix only when it covers ≥90% of the literal/fuzzy hits** — otherwise it stays silent rather than dragging the ranking down.\n- Any layer failure degrades silently to the layer below — semantic → fuzzy → literal, never an error. The recall tool always answers.\n- Inference runs in a **worker thread** (WASM on the main thread would block the host event loop; measured ~9.6 texts/sec with zero main-thread impact).\n- Everything runs locally and offline — no external model APIs, no network.\n\n### Progressive disclosure\n\nRecall happens in two stages, and the second stage only fires when the agent actually needs it:\n\n| Stage | What the agent gets | Cost |\n|---|---|---|\n| 1 — coarse recall (default) | Session titles + snippets + same-topic events, grouped, ranked | ~100–800 tokens for up to 10 sessions |\n| 2 — `detail` drill-down | A session's hit list / the exact original-text window (`readEvent`) / paged browsing | ~300 tokens per session (e.g. a ±3 event window) |\n\nMeasured live on a real instance: coarse recall saved **~80% of tokens** versus the old full-context windows (2500–3000 → ~600 on a 10-session hit, pre-aggregation). Event aggregation keeps the same discipline — snippets only, full event text one drill-down away — so a coarse call stays under ~800 tokens. Irrelevant content never enters the context — and when it matters, the original text is always one drill-down away.\n\n### Compaction anchors\n\nCompaction is where memories get lost — the harness summarizes, the original text is shadowed. dsh-recall listens for `compaction/summary` and immediately injects one lightweight anchor into the compacted session:\n\n- **Content**: the LLM summary + up to 3 key original fragments (user messages first, then longest text blocks).\n- **Expiry**: after 3 assemblies, the anchor disappears — it is a bearing, not a crutch.\n- **Escape hatch**: the exact original text stays one `detail` drill-down away, always.\n- Verified end-to-end on a live instance: a real `/compact` produced the anchor in the very next assembly, with the correct content, expiring automatically after 3 turns.\n\n### Auto-recall layer\n\nThe agent decides when to call `recall`, but a model cannot reliably judge \"am I missing details?\" — this layer closes exactly that gap. On every user message, the host runs a **local, deterministic gate** (`lib/auto-gate.js`):\n\n- **P — process commands** (\"继续 / 我重启了 / runtime-context restores\"): the previous turn's topics are recalled — measured: 56% of manual-trigger contexts at just 3.6% false positives on ordinary messages.\n- **A — past-reference wording** (\"之前说 / 记得吗 / 搜索历史…\") whose referring segments (char-bigram runs NOT visible in the current turn) **do hit the fuzzy index** — the phrase really existed earlier.\n\nWhen the gate fires, one lightweight in-session recall runs and the hits are injected **silently** into the agent's system prompt (expires after 3 turns; session restores get 1 turn; no re-trigger while an injection is live = built-in dedupe). The agent answers as if it always knew — invisible, no extra LLM call, zero network.\n\nThe gate was calibrated on your real manual-trigger corpus (19 sessions, 18 contexts, `scripts/analyze-triggers.mjs`): **P + (A ∧ B3 ≥ 0.6) covers 89% of manual triggers at 8.9% false positives** (A|P alone: 100% cover at 18.9%). Cost ≈ +190–400 tokens per turn on average (3 rounds × ~700 at 9–19% trigger rates).\n\n### Scope & privacy\n\n- Default scope is the **current session only** — cross-session (`workspace`) and cross-project (`all`) searches happen only on the user's explicit request.\n- The reply layer is invisible: a quiet \"Recalling…\" sweep, one \"Recall complete\" line, nothing else. Results never enter the UI — the agent presents them naturally.\n- Data stays on this machine: no external APIs, no telemetry, no network.\n\n## Measured\n\n### Token benefit (live, v0.2.1)\n\n| Measurement | Result |\n|---|---|\n| Coarse recall cost (default) | ~100–800 tokens per call |\n| Old full-context windows (10 sessions) | ~2500–3000 tokens — **3–4× more** |\n| `detail` ±3 window | ~300 tokens per session |\n| Compaction anchor | Verified live: real `/compact` → anchor injected next assembly, correct content, auto-expires after 3 turns |\n| Semantic warm-up | ~10 texts/sec in a worker thread, host event loop zero-blocked |\n\n### Retrieval quality (golden set)\n\nSynthetic 4-session corpus (32 docs) with 23 hand-annotated queries (exact / fuzzy-typo / paraphrase / cross-session), run in-memory with the real model — repro: `node eval/run-golden.mjs`:\n\n| Variant | recall@5 | MRR | nDCG@10 |\n|---|---|---|---|\n| Literal only (simulated official FTS5) | 0.196 | 0.217 | 0.201 |\n| Fuzzy only | 0.587 | 0.652 | 0.579 |\n| Semantic only | 0.533 | 0.609 | 0.529 |\n| **Hybrid (production path)** | **0.696** | **0.761** | **0.687** |\n\n- The hybrid merge beats every single layer (**+19% recall@5** over the best solo layer) — all three layers contribute, none is decoration.\n- The literal layer alone is the weakest (exact match only; FTS5 unicode61 is word-splitting-blind for Chinese) — confirming its fallback role.\n- The fuzzy layer is the primary path (beats semantic solo); the semantic layer adds recall on paraphrase and word-swap queries.\n- **Coverage gate verified**: at half warm-up the gate correctly falls back to fuzzy-only (0.587 = fuzzy-only); running the half-warmed semantic layer anyway yields a small gain on this small corpus (0.674) — the 0.90 gate is a conservative safety default for real long sessions, not tuned to this set.\n- Known misses (documented boundaries): zero literal-overlap paraphrases below the semantic min-score (e.g. \"打码\" for \"脱敏\") and abstract-concept queries (e.g. \"方案\").\n\n## Recent updates\n\n<details>\n<summary>Recent updates (click to expand)</summary>\n\n> The npm package first published as **0.1.0**; the 0.0.x entries below are development milestones.\n\n- **2026-08** — v0.3.0: **host auto-recall layer** — a local deterministic gate on user messages (P: process commands \"继续/重启/restore\"; A: past-reference wording whose old-only segments hit the fuzzy index) silently injects the relevant history into the system prompt (3 turns; 1 for restores; dedupe while an injection is live). Calibrated on real manual triggers (19 sessions / 18 contexts: P 56% @3.6% FP; P+(A∧B3≥0.6) 89% @8.9%; A|P 100% @18.9%); offline study script `scripts/analyze-triggers.mjs`; fuzzy-index safety — corpus-invisibility guard (an empty live+persisted corpus is never treated as removal of every session) and vectors dropped together with their docs on rebuild/removal.\n- **2026-08** — **Result aggregation**: repeated mentions of one topic now merge into complete events (`[startSeq..endSeq]`, hits ≤5 text blocks apart; threshold measured on real index data — p50 same-topic gap 3, 61% ≤5). Coarse recall returns up to 3 events per session with the same token discipline (snippets only; full event text stays one `detail` browse away). v2 roadmap complete.\n- **2026-08** — Retrieval quality evaluation: golden set (4 sessions / 32 docs / 23 hand-annotated queries) measures the production hybrid path at recall@5 **0.696** / MRR **0.761** / nDCG@10 **0.687** — +19% over the best single layer. Ablation confirms fuzzy-as-primary and literal-as-fallback; the coverage gate is verified live (half warm-up falls back to fuzzy-only). Repro: `node eval/run-golden.mjs`.\n- **2026-08** — Measured live on v0.2.1: coarse recall costs ~100–600 tokens vs ~2500–3000 for the old full-context windows on a 10-session hit (~80% saved); a `detail` ±3 window costs ~300 tokens per session. Compaction anchor verified end-to-end: a real `/compact` injected the LLM summary + 3 key original fragments into the next assembly on a live instance, expiring automatically after 3 turns.\n- **2026-08** — v0.2.1: fix — detail windows now extract assistant/message text blocks (block arrays) and filter by block type, so the exact original text of assistant replies appears in drill-down results (found during live verification).\n- **2026-08** — v0.2.0: **progressive disclosure + manual/automatic dual mode** — `recall` returns a light coarse recall by default (titles + snippets, far fewer tokens), with a new `detail` parameter for the second stage (a session's hit list / the exact original-text window via readEvent / paged browsing); description rewritten so the agent recalls proactively (after compaction, when details are missing — no need for the user to ask), keeping the scope red line and invisible-presentation rules; **compaction anchor** — after a compaction, one lightweight anchor (LLM summary + key original fragments, expires after 3 turns) is injected automatically, with exact text always one drill-down away.\n- **2026-08** — v0.1.0: first release — one-command install (`dsh.bundle.patch` wires the plugin row and enables full-text session search automatically), optional `dsh-recall-models` package for the 23.9MB embedding model (`--omit=optional` for a lightweight build), bilingual README + locale-aware UI.\n- **2026-08** — v0.0.6: semantic layer — local bge-small-zh (int8, bundled, fully offline) running in a worker thread; three-layer hybrid retrieval (literal / fuzzy / semantic) with a coverage gate (≥90%) and silent degradation; background warm-up (~10 texts/sec, host event loop never blocked).\n- **2026-08** — v0.0.4: fuzzy retrieval — self-built trigram + char-bigram index (zero npm dependencies): find conversations when you remember only fragments, rough wording, typos or missing characters.\n- **2026-08** — v0.0.2: the `recall` tool — official FTS5 full-text search over every past session (including compacted history), grouped by session with a bounded context window; scope control (current session by default); invisible UI (Recalling… / Recall complete).\n\n</details>\n\n## Roadmap\n\n**v1 · Done** — Three-layer hybrid retrieval: official FTS5 literal / self-built trigram+bigram fuzzy / local bge embedding semantic; coverage gate, background warm-up, silent degradation chain.\n\n**v2 · Retrieval control**\n- [x] **Two-stage recall (browse/detail drill-down)**: lightweight coarse recall by default (title + snippet, ~100–800 tokens); the agent picks the relevant sessions and requests full context on demand — irrelevant content never enters the context\n- [x] **Compaction anchors**: on `compaction/summary`, inject one lightweight anchor (summary + key fragments) automatically; the original text stays one drill-down away\n- [x] **Proactive recall**: the agent calls on its own when needed (after compaction, when details are missing); explicit user requests also work\n- [x] **Host auto-recall layer**: a deterministic gate on user messages (process commands / past-reference wording + fuzzy-verified old-only segments) silently injects the relevant history — no user prompt needed (v0.3.0)\n- [x] **Result aggregation**: repeated mentions of one topic merge into complete \"episodes\" — consecutive hits ≤5 text blocks apart group into `[startSeq..endSeq]` events (threshold measured on real data: p50 same-topic gap = 3, 61% ≤ 5); the full event text stays one `detail` browse away\n\n**v3 · Memory organization**\n- **Topic clustering**: embed similarity clustering, present results grouped by topic\n- **Memory distillation**: extract settings & decisions across sessions into durable long-term memory\n- Longer term: evaluate topic-based / layered compaction mechanisms — evaluation only, no changes to DSH core\n\n## Known boundaries\n\n- Semantic bridging for very short queries (≤4 chars) is weak (bge short-text cosine has limited separation); the fuzzy layer's LIKE fallback covers it\n- Semantic ranking is not fully reliable for queries with zero literal overlap — the fuzzy layer is always the primary path, and the agent makes the final call\n- The model is int8-quantized: semantic quality is \"good enough\" by design; swap in an fp32 model (~4× size) for maximum quality\n\n## Development & testing\n\n```sh\nnode .smoke-recall.mjs      # unit + integration (mocked, no model needed) — 90+ assertions\nnode .smoke-semantic.mjs    # real-model integration (requires models/ present)\n```\n\nCovers: tokenizer alignment (token-for-token against transformers.js), index increments, scoping, hybrid ranking, degradation, warm-up, event aggregation.\n\n### Modules\n\n| File | Responsibility |\n|---|---|\n| `lib/index.js` | Tool registration, scope resolution, hybrid ranking, session & event aggregation, warm-up scheduling |\n| `lib/fuzzy-index.js` | Self-built SQLite index (trigram FTS + bigram + vector table), zero npm dependencies |\n| `lib/tokenizer.js` | BERT WordPiece tokenizer (pure JS, token-for-token aligned with the reference) |\n| `lib/semantic.js` | Embedder: worker thread, batched embedding, lazy loading |\n| `lib/embed-worker.js` | WASM inference + mask-aware mean pooling + L2 normalization inside the worker |\n| `lib/vendor/` | Vendored onnxruntime-web (0.8MB entry + 12MB wasm) + tokenizer.json |\n| `models/` | Merged single-file int8 model (23MB; split into an optional package at publish) |\n| `lib/client.js` | Minimal ToolView (\"Recalling…\" / \"Recall complete\"), locale-aware zh/en |\n\n### Publish structure\n\n- `dsh-recall` — main package (code + vendored runtime + tokenizer)\n- `dsh-recall-models` — optional dependency (23MB model); npm installs it by default; `--omit=optional` yields the lightweight build, which degrades silently when the model is absent\n\n## References & acknowledgments\n\n- Official: `@deepseek-ai/dsh-session-query(-sqlite)`, `dsh-tools`, `dsh-session-persistence`\n- Model: BAAI/bge-small-zh-v1.5 (MIT) · onnx-community int8 export · onnxruntime-web (MIT)\n- Ecosystem: [dsh-plugin-recall](https://github.com/truelove-dreamer/dsh-plugin-recall) (official-FTS recall tool), [dsh-mneme](https://github.com/modusensus/dsh-mneme) (local semantic memory, hybrid-recall degradation ideas)\n\n## License\n\nMIT","users":{}}