DeepSeek Harness Plugin

Luengzoen/dsh-memory-go#plugin

Stars ★ 0 Category Memory Added 2026-12-01

Project-scoped cross-session memory for DeepSeek Harness, built as a three-layer tree: topics, current-state summaries and discrete facts, each fact carrying an evidence pointer it can be checked against. The opening brief is capped at 1200 tokens and carries every branch plus the five most recent facts whatever the library size; a fixed "check memory first" policy lives in the system prompt while the claims themselves never enter it. A claim leaves only when a newer one explicitly supersedes it, and it is the one tool set that reports dead evidence pointers, empty branches and stale summaries without changing a single row. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Install

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:Luengzoen/dsh-memory-go#path:/plugin

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

dsh-memory-go

Project-scoped cross-session memory for DeepSeek Harness.

One memory is one discrete claim with an evidence pointer. Not a document. Not a container you keep piling text into.

     

中文


Why

Conversations get compacted. Sessions end. Models forget. Store conclusions as chat history and you re-read it next time; store them as documents and in three months you have a notebook nobody opens.

This plugin takes another route: one memory is one claim with a pointer that lets you verify it.

"dedup narrowed to same layer and parent"   ← claim, ≤60 chars
"src/store/fact.js#L212"                    ← evidence, points at the proof

You state your grounds when you write it, and pull only pointers when you read. Four hundred rows or ten thousand, the opening cost is identical.

Highlights

  • Zero dependencies — 0 runtime packages, 0 native modules, 0 build steps. node:sqlite gives FTS5 directly.
  • Constant injection cost — the opening brief carries topics, summaries and the 5 most recent facts: 1200 tokens for memory, 360 more for persona. A ten-thousand-row library produces the same brief size.
  • CJK search built in — FTS5 trigram indexing with substring matching, no external tokenizer, no separate table for CJK.
  • Truth does not expire — no row cap, no eviction, no time decay. An old claim leaves only when a newer one explicitly supersedes it, with the trail kept.
  • In-process singleton — born and gone with DSH. No daemon, no IPC, no orphans.
  • Three-layer tree — topics, summaries and facts each do one job, with layer validation enforced at write time.
  • Check before acting — one fixed "evidence first" policy lives in the system prompt: when a step rests on prior facts, call memory_recall first. A hit names the pointer to verify; a miss just means carry on — no blocking, no repeated fishing.

Architecture

┌──────────────────────────────────────────────────────────────┐
│  DSH Host (same process)                                     │
│                                                              │
│   agent/pre-step ──► inject/render ──► brief (≤1200 tok)     │
│   systemPrompt   ──► inject/policy ──► evidence-first policy │
│   memory_* tools ──► recall/query  ──► pointers (id+claim)   │
│   memory_manage  ─► store/*       ──► write / supersede     │
│   settings RPC    ─► tree / lint   ──► structure & audit     │
└──────────────────────────┬───────────────────────────────────┘
                           │  node:sqlite (sync, in-process)
        ┌──────────────────┼──────────────────┐
        ▼                  ▼                  ▼
   project.db          local.db          global.db
   FTS5 trigram        FTS5 trigram      FTS5 trigram
   this repo           this machine      every repo

Five gates sit on the write path: shape → layer → scope vs kind → near-duplicate → stale-parent notice. Rejection codes are deterministic.

Performance

10,000 facts, single process, laptop:

Scenario Result
10,000 inserts (single transaction) 848 ms
Full-library search, one recall 15.9 ms avg / 29.6 ms worst
Opening brief tokens (400 rows → 10,000 rows) constant, growth < 400 tok

Recall pulls candidates through the FTS5 inverted index, re-ranks by usage / recency / confidence, then truncates. No table scans, no grep.

Install

dsh plugin --profile <profile> add -w "https://github.com/Luengzoen/dsh-memory-go/releases/latest/download/dsh-memory-go.tgz"

Restart DSH. A Memory section appears in Settings.

To work on the source, point the profile dependency at the plugin/ directory in the repository:

// ~/.dsh/profiles/<profile>/package.json
{
  "dsh": { "profile": { "bundles": ["dsh-memory-go"] } },
  "dependencies": { "dsh-memory-go": "link:D:/path/to/dsh-memory-go/plugin" }
}
Requirement Version
DSH >= 0.2.2-rc.5
Node >= 22.5
Dependencies none
Build none

How to use it

Once installed there is nothing to learn. Just talk to the model — it reads and writes memory at the right moments.

Ask it to remember

Remember: this project releases by testing first, then tagging
Note that the client wants every API to return UTC
Write down the three conclusions we just reached

The model decides which layer and which scope, then calls the tool. You see a tool call and its result.

Ask it to look something up

What was the release process we settled on?
What did we conclude about that SQLite locking problem?
How many branches does this project have, and which one is stale?

The model checks memory first, then answers. When nothing is there it says so instead of inventing.

Ask it to tidy up

Clean up memory — drop what no longer holds
Audit the memory library for broken references
Refresh the summary of the deployment branch

"Clean up" does two things. What a machine can decide — broken pointers, orphans whose parent is gone, empty summaries — gets handled directly, and every action is reversible. What needs reading the content — whether a claim has been overturned, whether two rows should merge — is only listed for you to confirm.

Look at it, and edit it, in Settings

DSH Settings → "Memory". Four tabs: Soul / Identity / About me / Memory. The first three are persona; the last is the library itself — browse topics, summaries and every fact, create topics, rewrite summaries.

The "Auto-inject" switch sits on the right of the status row. Turned off: no opening brief, tools keep working, not a single row is removed.

When memory shows up

A new session opens with at most eight topics, the current summary under each, and the five most recent changes. After that the model looks things up on demand — the whole library never enters context.

Anything you want present every time belongs in a persona file (Soul / Identity / About me); that part is injected at every opening.

Quick start

memory_write({
  layer: "L3",
  kind: "decision",
  claim: "Run the full suite before every release",
  evidence: "package.json#L8"
})

The next session opens with topics, summaries and the 5 most recent facts. Everything else is fetched on demand:

memory_recall({ tree: true, parent: "m-l1a2b3c4" })   // expand a whole branch
memory_recall({ query: "dedup", layer: "L3" })        // keyword search

Three-layer tree

Layer What it is Max length Required
L1 topic domain name 16 chars no parent
L2 summary where this branch stands 60 chars parent = L1
L3 fact one checkable assertion 60 chars evidence

At most 8 L1 topics per scope. An L3 may omit parent.

Scopes

scope Holds Location
project (default) this project's state, decisions, pitfalls, techniques <project>/.dsh/memory/project.db
global preferences and cross-project pitfalls $DSH_HOME/memory/global.db
local facts about this machine <project>/.dsh/memory/local.db

state and decision are accepted only in project / local.

Tools

Tool What it does
memory_write Write one node; returns the result or a rejection code
memory_recall Fetch entries by keyword, tag, layer or parent
memory_snapshot Record a stage anchor: a label plus the git head and tree hash
memory_lint Report dead links, dangling supersedes, empty branches, single-leaf branches, stale summaries, promotion candidates
memory_clean Tidy up: mechanical cases are fixed (reversibly), content-dependent ones are only listed
memory_manage Management actions: status / tree / branch / doctor / verify / export
memory_forget Discard a claim (archived, kept for audit)
persona_write Write one rule into a persona file: SOUL / IDENTITY / USER

memory_manage parameters

op What it does
status Counts, layer totals, injection budget, last snapshot
tree The whole three-layer tree (L1 + L2, no L3), with fact counts and stale flags
branch Every active fact under one branch; needs id
doctor Environment check: path resolution, database writability, FTS5
verify Mark as human-confirmed; needs id
export Write the Markdown view to .dsh/memory/export/

memory_recall parameters

Parameter Meaning
query Keywords
subject Tag, exact match, takes precedence over query
layer L1 / L2 / L3
parent An L1 id returns its L2s; an L2 id returns its L3s
tree true expands the whole branch, ignoring limit
limit Default 8, maximum 12
scope Default project; all merges the three databases

Rejection codes

Code Meaning
E_SHAPE missing layer, empty or over-long claim, empty L3 evidence, kind/scope outside the enum
E_LAYER_SHAPE an L1 was given a parent
E_PARENT_MISSING an L2/L3 parent is missing, not active, or of the wrong layer
E_LAYER_CYCLE the parent points at itself or forms a cycle
E_L1_TAKEN an active L1 with that name already exists in this scope
E_L1_LIMIT already 8 L1 topics
E_SCOPE_KIND state / decision sent to global
E_NEAR_DUP judged duplicate within the same layer and parent; pass force: true for a genuinely new entry

Configuration

Key Default Meaning
enabled true Auto-injection on/off; tools keep working and no row is removed
projectRoot '' Pin the project root; empty resolves per session from its working directory
selectedProject '' Project chosen in Settings (Settings and context-free entry points only)
injectMaxTokens 1200 Token ceiling for the memory half (protocol + topics + recent)
personaMaxTokens 360 Combined ceiling for the three persona files; tightened, never dropped
personaMaxTokensEach 200 Starting ceiling per persona file

Settings page

A Memory section with four tabs:

  • Soul / Identity / About me — edit the three persona files.
  • Memory — topics and summaries on the left, the selected summary and its entries on the right.
  • "+ New topic" creates a topic; entries go under an existing one.
  • The status row carries the auto-inject switch.

The Memory tab in a session

Every session's tab row gains a Memory tab after Trajectory. It reads .dsh/memory/*.db directly and is read-only: it writes nothing and changes no entry.

It shows the databases of the project this session belongs to, not the one picked in Settings: switch to a session in another project and the tab follows. With projectRoot empty, the project comes from the session's own working directory (nearest .git boundary).

  • The left rail lists databases and their tables: project.db (project memory), local.db (this machine), plus an Other memory group when the folder holds more. Only real tables appear; search indexes are left out.
  • The right side shows every column of the selected table. Column widths drag, and a cell shows its full value on hover.
  • 100 rows per page, anchored on rowid: new writes never push the page you are reading, they raise a n changes prompt that takes you back to the newest page only when you click it.
  • Refresh returns to the first page and re-reads. A table is fetched once per DSH lifetime; after that the refresh button and the change prompt keep it current.
  • Writes made inside the plugin appear at once; writes from other processes arrive through file events, within a few hundred milliseconds.

Stack

Layer Choice Why
Storage SQLite (node:sqlite) single file, transactions, WAL; no server to install
Search FTS5 + trigram CJK substring matching without a tokenizer
Ranking BM25 candidates → custom score relevance sorts, it never decides
Runtime Node ESM, zero compile edits take effect, no build chain
Process in-process singleton no IPC, no subprocess, no orphans

Install package 115 KB (tgz), 390 KB unpacked, of which 364 KB is code.

Where the data lives

Content Path
Project and local databases <project>/.dsh/memory/{project,local}.db
Global database $DSH_HOME/memory/global.db
Persona files $DSH_HOME/persona/{SOUL,IDENTITY,USER}.md
Exports <project>/.dsh/memory/export/

Known limits

  • A claim is at most 60 characters.
  • At most 8 L1 topics per scope.
  • memory_recall returns at most 12 entries per call.
  • A persona file is at most 8 KiB.
  • The opening brief is capped at 1,200 tokens for memory and 360 for persona, tracked separately.
  • memory_lint checks file-path evidence pointers only.

Licence

MIT © Luengzoen

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.