sage-mem
基于纯 Markdown 文件的跨会话记忆插件 适合需要持久化跨会话上下文,且不希望使用数据库的轻量用户。
安裝
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:gezi-wen/sage-mem說明文件
閱讀完整 README ↗Configuration Reference
Environment Variables
| Variable | Default | Description |
|---|---|---|
SAGE_MEM_DIR | ~/.sage-mem/memory | memory directory |
SAGE_MEM_STATE_DIR | ` | |
| /.sage-mem` | state directory (configuration, ledger, locks, conflict queue, rollback points) | |
SAGE_MEM_MAX_SESSION_BYTES | 61440 (60 KiB, 4096–524288) | total injection cap per session |
SAGE_MEM_MAX_RESULTS | 10 (1–30) | cap on the number of candidate items injected per turn |
SAGE_MEM_MAX_CHARS | 1500 (200–20000) | character cap for a single memory's injection |
SAGE_MEM_MAX_BASELINE | 8 (1–50) | number of baseline slots |
SAGE_MEM_STALE_DAYS | 1 (0–365) | threshold for marking a heading 「保存于 N 天前」(saved N days ago); 0 = mark every one |
SAGE_MEM_TASK_ID | empty | scope of task checkpoints; empty falls back to the session id |
SAGE_MEM_DEBUG | off | debug logging; when on, the panel's 工具 ▾ → 注入调试 shows the last 8 injection attempts (read-only, never written to disk) |
Value semantics: out-of-range values are clamped to the boundary, illegal values (including pure whitespace) fall back to the default.
What the Settings Page Can Change
The panel can change the five caps above (written to /settings.json, precedence settings page > environment variable > built-in default), as well as reserved names (file names that are protected and that the settings page may not write or delete, written to /reserved.json). Some items take effect only after restarting DSH, and the panel writes out both the value in effect now and the value after restart.
Files in the State Directory
| File | Purpose |
|---|---|
access.json | access ledger (injected / read / use) |
conflicts/.json | write conflicts awaiting manual handling |
tasks//WORKING.md | task checkpoints |
settings.json / reserved.json / locked.json | settings, reserved names, locks |
autodream.json, autodream/ | autodream configuration, snapshots, run records |
dream.json | the legacy name, read once only during migration |
Apart from access.json, conflicts/ and tasks/, the rest is internal implementation state, and its format may change in minor versions; do not depend on it.