Introduction¶
In DeepSeek Harness (DSH), the common approach for implementing long-term memory for agents is through plugin integration: the model reads and writes facts using tools like memory_write and memory_search, while the system automatically retrieves a summary segment in the prompt. The community plugin dsh-memory@0.1.0 uses SQLite FTS5 to store flat text, but its default tokenizer is unfriendly to Chinese—entire sentences often become a single token, rendering search nearly ineffective. Long-term facts also require scope, tags, deduplication, expiration review, and a controllable prompt budget, rather than just appending and searching.
Below is an introduction to @tr1v3r/dsh-ltm (Community Category: Memory) released by the maintainer tr1v3r. It uses local SQLite as its primary storage, providing CJK-aware tokenization search, hybrid BM25 and character n-gram reranking, near-duplicate detection, and memory lifecycle management. It also supports migration from dsh-memory; it does not force online connectivity, nor does it require an API Key or embedding service.
What is this¶
@tr1v3r/dsh-ltm is a structured long-term memory plugin designed for DeepSeek Harness: data is stored in local SQLite (default $DSH_HOME/memory/ltm.db), independent of the legacy memory/memory.db, and will not write to legacy paths.
In the DSH ecosystem where “everything is a plugin,” plugins are loaded via the profile’s Cordis configuration; the community directory page is available at skillhub.cn/plugins/tr1v3r/dsh-ltm, and the source code and documentation are on GitHub tr1v3r/dsh-ltm (MIT License). The current version of the npm package is 0.3.3 (see package.json in the repository).
Core Features¶
Retrieval and Storage¶
- Local SQLite + FTS5, combined with CJK-aware tokenization and hybrid BM25 + char n-gram reranking to improve Chinese query performance.
- Near-duplicate detection before writing (Jaccard ≥
dedupeThresholddefault 0.8, or cosine ≥dedupeCosineThresholddefault 0.92); duplicates can be returned as candidates instead of written, unlessforce: true. - Structured scope and tags; unconfirmed memories older than
staleAfterDays(default 90) are marked as stale in display, and the review timestamp can be refreshed usingmemory_confirm. - Automatic prompt recall section: configurable recent count and UTF-16 character limit; optional offline
promptMaxTokens+ localtokenizer.jsonfor token budgeting (assets must be prepared by the user, validated at startup, no network requests).
Project Isolation (autoProjectScope)¶
When autoProjectScope: true by default, each agent resolves the project based on session.header.cwd: Git repositories use the canonical common Git directory (subdirectories and linked worktrees share the scope); non-Git workspaces use the canonical directory name. Writing and deduplication are limited to the current project scope; search and automatic recall only see the current project and global (scope=""). memory_list and the CLI can still perform management operations across projects. Scope is for context isolation, not an OS-level permission boundary.
Model-Side Tools¶
Compatible with dsh-memory conventions:
memory_write(text, tags?, pinned?, force?)memory_search(query, limit?)memory_forget(id)
Newly added:
memory_update(id, text?, tags?, pinned?, expectedRevision?)memory_confirm(id | "*", expectedRevision?)memory_list(scope?, tags?, stale?, limit?)memory_merge(targetId, sourceIds[], …)
Each memory carries a revision; passing expectedRevision to memory_update / memory_confirm / memory_forget / memory_merge enables CAS (Compare-And-Swap) within a single transaction. Conflicts return MEMORY_REVISION_CONFLICT and no write occurs. Omitting the version field maintains the legacy non-CAS behavior.
CLI and Management¶
The standalone CLI entry dsh-ltm supports list / search / show / edit / tag / pin / merge / confirm / forget / upgrade-schema / export / import, all with --json support. There is also a read-only doctor for quality diagnostics (does not output memory content). One-time imports from dsh-memory are located in the repository’s scripts/legacy-migration/, not in the published CLI; use export / import for backup transfer between libraries.
Installation and Activation¶
The DSH peer dependency must match the runtime range listed in the README (including verified 0.2.1-rc.1 desktop and 0.2.1-rc.2 CLI, as well as the pre-0.2.0 range; other 0.2.x pre-releases require self-verification of compatibility). The Node engine requires ^22.19.0 || >=24.0.0.
@tr1v3r/dsh-ltm version 0.1.2 and above supports one-click bundle installation and configuration registration:
dsh plugin --profile web add @tr1v3r/dsh-ltm
Replace web with your profile name (e.g., dsh-tui), then restart that profile. The bundle sets the database path to $DSH_HOME/memory/ltm.db.
If switching from dsh-memory, you must first disable the old plugin entry: both register memory_write, memory_search, and memory_forget. If you have manually inserted an ltm entry, delete it before enabling the bundle to avoid duplicate instances. Installation does not automatically migrate old libraries; see below for migration.
For versions 0.1.0–0.1.1 without a bundle manifest, you can manually insert into the profile’s cordis.patch.yml:
- insert:
- id: ltm
name: '@tr1v3r/dsh-ltm'
config:
path: !!js dshHomePath('memory/ltm.db')
path is required and has no default value on the code side; it can also be set to :memory:.
Configuration Highlights¶
| Config Item | Default | Meaning |
|---|---|---|
path |
(Required) | SQLite path or :memory: |
defaultScope |
"" |
Fixed scope when automatic project detection is disabled |
autoProjectScope |
true |
Derive project from session cwd/Git |
promptRecentCount |
10 |
Number of recent unpinned entries in the recall section |
promptMaxChars |
2000 |
Hard limit on UTF-16 characters for the recall section |
maxTextChars |
2000 |
Maximum characters per memory entry |
searchLimitDefault / searchLimitMax |
10 / 50 |
Upper and lower limits for search results |
staleAfterDays |
90 |
Days until unconfirmed memory is considered stale |
Invalid configuration (empty path, thresholds not in [0,1], etc.) throws an error at plugin load time, rather than waiting until the first tool call.
Example of optional token budget (both token-related fields must be set, and a local tokenizer.json must be provided):
promptMaxChars: 2000
promptMaxTokens: 512
promptTokenizerPath: /path/to/pinned-model-revision/tokenizer.json
Typical Usage¶
1. Model Usage within a Profile¶
The agent calls memory_search to query existing facts during conversation and writes with memory_write; if near-duplicate candidates are returned, use memory_update to revise the same entry, or confirm and then write with force: true. Long-term valid preferences can be set with pinned: true. When unsure of the id, search first; prioritize memory_update over duplicate writes for status changes of the same fact.
2. CLI Browsing and Maintenance¶
The default library path is $DSH_HOME/memory/ltm.db:
npx -p @tr1v3r/dsh-ltm dsh-ltm --db /path/to/ltm.db search "deployment commands" --json
npx -p @tr1v3r/dsh-ltm dsh-ltm --db /path/to/ltm.db list --json
Example of editing with CAS (read the revision with show first, then pass --expected-revision):
dsh-ltm --db /path/to/ltm.db edit 42 --text "Updated content" --expected-revision 3
3. Schema v1 → v2¶
If the old library lacks the revision column, normal opening will be rejected. You must stop all writers (including running plugins) and explicitly upgrade:
dsh-ltm --db /path/to/ltm.db upgrade-schema
dsh-ltm --db /path/to/ltm.db upgrade-schema --backup /path/to/new-backup.db
4. Data Migration from dsh-memory¶
Installing the plugin itself does not migrate memory/memory.db. One-time imports from the retired dsh-memory require using the repository’s scripts/legacy-migration/ (see the README in that directory). For backup and transfer between dsh-ltm libraries, use export / import, which preserves project scope and review timestamps.
Suitable Scenarios and Notes¶
Suitable for developers who need to accumulate long-term personal or project-level facts within DSH and value Chinese retrieval and memory lifecycle management (deduplication, review, scope isolation). The design goal is a personal long-term fact library, not a large-scale document library: every non-forced memory_write within the same scope scans all memories in that scope for deduplication, and the writing cost grows with the number of entries and length; multi-session environments can share a local WAL library, but SQLite writes remain serial, and SQLITE_BUSY requires manual retry.
The plugin runs with the current dsh process permissions and can read/write the configured SQLite path; please review the source code and MIT License before installation to ensure the path and profile configuration meet your security expectations. The community directory has no official affiliation with DeepSeek / High-Flyer.
Conclusion¶
@tr1v3r/dsh-ltm makes DSH long-term memory local-first: CJK-aware search, structured scope, deduplication and expiration review, optional revision CAS, and a migration path from dsh-memory—no online connectivity required by default. Directory page: https://www.skillhub.cn/plugins/tr1v3r/dsh-ltm; Repository: https://github.com/tr1v3r/dsh-ltm.