dsh-memory-panel
Agent 与会话 活跃维护

dsh-memory-panel

sdf-jkl-gh/dsh-memory-panel

dsh-memory-panel

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
34 KB
仓库大小
3 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:sdf-jkl-gh/dsh-memory-panel
git clone https://github.com/sdf-jkl-gh/dsh-memory-panel.git
git clone git@github.com:sdf-jkl-gh/dsh-memory-panel.git
README.md main

dsh-memory-panel

Persistent memory plugin for DeepSeek Harness: model-facing memory_* tools, automatic memory:recall prompt injection, /memory/api JSON routes, and a Settings → 记忆 (Memory) management panel.

License: MIT
Node
CI

中文说明 · Design · FAQ


What it does

dsh-memory-panel gives every agent session a durable, searchable memory
that survives process restarts:

Capability Where Description
memory_save model tool Create or update a memory entry (title + content + tags + importance)
memory_search model tool Ranked keyword search — Latin whole-word plus CJK bigram scoring
memory_list model tool List entries newest-first, optionally filtered by tag, with tag/importance stats
memory_get model tool Read one full entry by id
memory_delete model tool Delete an entry by id
memory:recall system prompt Top 6 memories (high-importance first) are auto-injected into every agent's prompt at assembly time
/memory/api/* host route JSON API used by the settings panel
Settings → 记忆 web panel Browse, search, create, edit, and delete memories in the GUI

The plugin is mounted at the user layer of the DSH profile composition, so
its tools are visible to every session regardless of which agent preset is
active.

How it works

┌────────────────────────────  DSH host process  ───────────────────────────┐
│                                                                           │
│  tools registry  ◄── memory_save/search/list/get/delete  (model-facing)   │
│        ▲                                                                  │
│        │                     createMemoryStore (src/store.js)             │
│        │                     ┌──────────────────────────────────┐         │
│        │                     │ pure logic: scoring, recall,     │         │
│        └──── execute ────────│ serialized write chain           │         │
│                              └───────────────┬──────────────────┘         │
│                                              │ load / persist (injected)  │
│  /memory/api/* routes ◄── POST ──┐           ▼                            │
│        ▲                        │   fs service                            │
│        │                        │        │                                │
│  systemPrompt.memory:recall ◄───┘        ▼                                │
│        ▲                           <home>/.dsh-memory/memories.json      │
│        │ (30s guarded refresh +                                        │
│        │  refresh on every save/delete)                                 │
└────────┴───────────────────────────────────────────────────────────────────┘

┌──────────────────────────  browser (web client)  ─────────────────────────┐
│  Settings → 记忆 panel ── fetch('/memory/api/<method>', { method: 'POST' })│
└────────────────────────────────────────────────────────────────────────────┘
  • Storage: memories.json under <user home>/.dsh-memory/ — resolved from
    the host sandboxPolicy.workspaceRoot, i.e. the user home, not the
    session workspace. Created on first save; survives restarts.
  • Concurrency: every mutation goes through a serialized write chain, so
    concurrent saves/deletes can never interleave on the backing file.
  • Recall: the memory:recall system-prompt section renders a plain-string
    cache synchronously (the section text hook is sync, ctx.fs is async);
    the cache is rebuilt after every save/delete and on a guarded 30s timer.
  • Scoring: title (×3) > tags (×2) > content (×1); CJK queries additionally
    score every overlapping bigram, so short Chinese queries still hit long
    entries; high-importance entries get a flat +2 (and thus surface even on
    no-hit queries).

Installation

Option A — official CLI (bundle channel, recommended)

dsh plugin --profile <profile-name> add dsh-memory-panel

The package declares dsh.bundle.patch: ./cordis.patch.yml; the CLI reconciles
the profile bundle stack and the patch inserts the plugin row, so no profile
file edits are needed.

Option B — manual patch

Copy the package anywhere DSH can resolve it, then append to your profile's
cordis.patch.yml:

- insert:
    - id: tool-memory
      name: 'dsh-memory-panel'

Restart DSH. New entries must be added with insert (an id-less override is
ignored by the patch loader).

Upgrading from an older manual mount: if your profile already mounts the
plugin row in its own cordis.patch.yml, remove that line before switching
to the bundle channel to avoid double-mounting (two host halves, duplicated
tools and routes).

Usage

As a model

Just talk naturally — or call the tools directly:

memory_save(title="User prefers Chinese thinking", content="...", tags=["preference"], importance="high")
memory_search(query="Chinese thinking")
memory_list(tag="preference")
memory_get(id="m...")
memory_delete(id="m...")

Every agent automatically sees the top saved memories through the
memory:recall section (marked [重要] when high importance) and is told to
call memory_search for the full picture.

In the GUI

Open Settings → 记忆 (Memory): browse all entries with stats, search,
create/edit/delete. The panel talks to the host through
POST /memory/api/* JSON routes.

Development

npm test          # node:test — pure-logic + plugin-level integration tests
src/
  index.js        Host half: tools, routes, recall injection (Cordis plugin)
  client.js       Client half: Settings → 记忆 panel (module-loader bundle)
  store.js        Pure logic: scoring, recall builder, injected store factory
test/
  store.test.js   Unit tests for src/store.js
  index.test.js   Integration tests with a mocked Cordis ctx + in-memory fs
docs/
  design.md       Architecture and data-flow deep dive
  FAQ.md          Common questions

License

MIT © 2026 dsh-memory-panel contributors