Skip to main content
X

dsh-whale-memory

xkshct198570/dsh-whale-memory

Local long-term memory and rule source for DeepSeek Harness. SQLite recall injection, write auditing, six-tab panel, and rules kept in a local git Markdown repository with proposals, plan/apply, tombstone numbering and a health check. No external service or API key by default. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Install

dsh plugin --profile web add github:xkshct198570/dsh-whale-memory

README

Whale Memory

中文 | English

Local-first long-term memory for DeepSeek Harness sessions: recall relevant memories before each turn, review and edit them in a six-tab panel, and keep rules in a local git Markdown repository where the database is only a search mirror.

Current version 0.6.3 (R11: first-run recommendations, collapsible settings groups, offline manual, rewritten core rules): local SQLite memory store, automatic recall, six-tab panel, write auditing and adoption signals, optional two-way sync/outbox, metrics and daily reports, and legacy migration auditing. Rule source of truth: ~/.dsh/rules (proposals, plan/apply, tombstone numbering, health check). Requirements: DSH >=0.2.2-rc.5 <0.3.0, Node >=22.13.0 (built-in SQLite).

Install

  • Market: add this project's index source (format 1) in the DSH plugin market and search dsh-whale-memory (once listed).
  • GitHub Release: dsh plugin --profile <profile> add <release-tarball.tgz>, or choose the tarball on the Plugins page.
  • Local development: install with link:<repository-directory> from the plugin manager. Run pnpm install first; rebuild and restart after code changes. link: is for development; market indexes use published packages.
  • Works out of the box: local store, automatic recall, six-tab panel; no extra service and no API key.

Use

Automatic recall

  • Before each turn, search local memories with the last user message and inject hits above the relevance threshold (minRel=0.34 by default). No hits means no injection.
  • A 2-second timeout skips recall for that turn instead of blocking the reply; results are session-scoped and expire after 120 seconds; subagents are skipped.
  • Intent budgets: chat 3 / troubleshooting 5 / recall 4 / image-and-creation 0.
  • Identity dimensions: userId, roleId, and workspace derived from the session cwd. A persona plugin only sends roleId; workspace always stays with the session.

Six-tab panel

Overview / Memories / Rules / Recall / Writes & relations / Settings.

  • Memories: search, edit, archive, import/export, node relations.
  • Rules: rule files, create, edit, retire/reactivate, purge, pending proposals, history diff/rollback, git status, /rules/health.
  • Recall and writes: injection parameters, candidates, audit and adoption; Settings groups backend, rules and panel options.

Rules (iron rules)

  • The source of truth is one Markdown file per rule under ~/.dsh/rules/, versioned by a purely local git repository. Rows in nodes with origin=rule:<key> are a panel/audit mirror only and are excluded from recall.
  • A spoken rule becomes a candidate; it never applies automatically. Confirm from the Rules tab or reply 收录 <p...> in chat (one pending proposal per session, 30 minutes).
  • Apply builds a plan (per-file guards, old hashes, plan hash), then writes in one transaction and one commit; failures roll back without half-written state.
  • Purge writes a tombstone under retired/<key>.json; the number is never reused. /rules/health checks files, manifest, tombstones, chains and mirror consistency.
  • Global rules render into the managed block in AGENTS.md. A clean install creates a minimal block (rules.createAgentsIfMissing=true); an existing file without markers is never appended to.
  • Scoped rules (role: / workspace:) inject only in matching sessions, under injectChars (0 = off).

Configuration

Rules group (9 visible in the panel, 3 config-only):

KeyDefaultMeaning
rules.enabledtrueMaster switch for proposals, injection and self-heal
rules.dir''Rules repository; empty = $DSH_HOME/rules
rules.requireGitfalsetrue = refuse rule writes when git is unavailable
rules.askModepanel+chatWhere to offer proposals; panel/off never draft automatically
rules.llmfalseAllow the model to reword merge/conflict candidates
rules.maxProposals20Pending proposal limit
rules.guardStricttrueStrict guards
rules.mirrorAutotrueAutomatic DB mirror
rules.askCooldownDays30Rejection cooldown
rules.renderAgentstrueRe-render the AGENTS block (config-only)
rules.injectChars600Per-turn scoped-rule budget (config-only; 0 = off)
rules.createAgentsIfMissingtrueCreate a minimal AGENTS block on a clean install (config-only)

The backend defaults to local ($DSH_HOME/whale-memory/memory.db). http/hybrid can point at an external memory service; failures fall back locally or show "not connected".

Data, privacy and security

  • No outbound requests by default. Only when backend.mode is set to http/hybrid does the plugin send /stats /recent /search /recall /write to the configured URL.
  • Memories and rules stay on this machine; the rules repository never pushes and never fetches.
  • The panel/API is loopback-only by default; write endpoints require JSON and same-origin, rejecting cross-site simple requests.
  • Logs record keys, numbers, commits and traces, not rule bodies or credentials.

Limits

  • Web panel only; no separate mobile client.
  • Recall fails open: a timeout or error never blocks chat, but that turn has no memory injection.
  • Global rules depend on the AGENTS.md digest; an existing file without markers is not modified.
  • With rules.llm=false, merge/conflict candidates need a manual rewrite in the panel. The model only rewords; it never writes directly.
  • Node's built-in SQLite is still experimental; include the database and rules repository in backups.

Development and tests

cd dsh-whale-memory
npm test                    # full layered suite(unit/contract/hook/data/worker/lifecycle/sync/client/integration)
node scripts/check.mjs      # contract gate
node scripts/i18n-check.mjs # zh/en/ja locale keys

Clean-install smoke (does not touch your live profile): create a temporary DSH_HOME, bootstrap a fresh web profile, install this package, then boot on --port 0 and check /whale-memory/api/rules + /rules/health. The repository's CI runs the same static gates and full test suite on every push.

Migration and failure handling

  • Legacy migration and rollback: see docs/MIGRATION.md and docs/DETAIL.en.md.
  • Broken rules repository: files remain the source of truth; move .git to .git.broken-<ts> and re-init, then rebuild the manifest from files.
  • With a yellow/red git status, rule reads/writes still work; history and diff use local snapshots.

Repository

https://github.com/xkshct198570/dsh-whale-memory · Issues and releases: GitHub Releases.

License

MIT.

Related plugins