DURABLE plain text on disk |
RETRIEVABLE IDF 3-way search |
AUDITED evidence chain enforced |
AUTO-INJECT ≤2KB per session |
ONE COMMAND 24-command CLI + plugin |
| Layer | Choice | Glow |
|---|---|---|
| Runtime | Node.js ≥ 18 | 🟢 zero dependencies · zero services · zero API cost |
| Storage | .memory/ plain markdown | 🧾 human-readable · diffable · git-friendly |
| Index | MEMORY.md ≤ 60 lines / 2 KB | 📥 hard-capped, overflow listed in footer |
| Scale | up to 1,000 entries | ⚡ injected index stays 2 KB; search scales via inverted index |
| Retrieval | IDF + CJK n-gram + aliases, two-stage rerank | 🎯 multi-strategy without a vector store |
| Delivery | AGENTS.md block + Harness plugin + Settings card | 🔌 two faces over one engine (mem-core.mjs) |
| Safety | approval · secret/PII scan · Jaccard gate | 🛡 four-layer defense (OWASP ASI06 aware) |
| Quality | 70 tests · release smoke · CI | 🧪 every change is checked before it ships |
[n] [--two-stage]` | IDF 3-way search with snippets; `--two-stage` reranks by confidence / freshness / feedback | | `show` | print one full entry | | `store [--overwrite] [--force] [--model]` | validate & store (secrets/PII/dupes/evidence gated) | | `forget ` | archive, never hard-delete | | `review ` | refresh verification date, push review +90 days | | `draft [topic]` | generate a four-section skeleton (lands in `drafts/`) | | `drafts` | list pending drafts | | `approve ` | approve a draft into the book (full store gate) | | `reject [reason]` | reject a draft — archived, never hard-deleted | | `write-mode [approval\|auto-draft\|auto-low-risk\|off]` | read / set the write mode (models are gated, humans never are) | | `explain ` | why an entry is trusted — confidence, state, evidence, relations | | `verify [name\|--all]` | run verification recipes (whitelist only, never arbitrary shell) | | `feedback [reason]` | record what a recall was used for; later recalls boost adopted entries | | `map [name]` | text knowledge graph — six sections: supersede chains · causal chains · conflict pairs · expired nodes · review timeline · common-root grouping | | `gather [budget]` | evidence pack, confidence-tiered — **never writes a conclusion** | | `conflicts` | list unresolved `conflictsWith` pairs | | `resolve--prefer --reason ` | adjudicate a conflict — loser derives to `stale`, both entries kept | | `global-sync` | mirror `scope: global` entries cross-workspace | | `stats [days]` | retrieval telemetry (hit-rate); non-integer falls back to 7 | | `doctor` | full health check — **green = exit 0 = zero findings** (notes are informational) | ### Harness plugin | Surface | Effect | |---|---| | prompt section | lesson index ≤ 2 KB, every turn, fail-degrade | | `mem_recall [limit]` | lesson book ∪ session full-text, merged & ranked | | `mem_save ` | write one lesson — gated by the write mode (`approval` always asks) | | `/memory ` | 17 maintenance subcommands — typing one **is** the approval | | Settings card | read-only status · confidence · hit-rate · search | --- ## 🏗️ Architecture: two faces, one engine ``` ┌───────────────────────────────────────────┐ │ .memory/ (DATA) │ │ *.md lessons · MEMORY.md index · stats │ └────────────────────┬──────────────────────┘ │ tools/mem.mjs (engine, 24 commands) │ tools/mem-core.mjs (facade) promptIndexText · formatRecall · saveAndSync ┌────┴─────┐ │ │ CLI face ───┘ └─── plugin/dsh-memory (AGENTS.md block) (Harness: prompt section mem_recall · mem_save · /memory · Settings card) ``` Hard rules hold across both faces: budget cap, fail-degrade, human-approved writes. --- ## 📂 Repository Anatomy ``` cross-session-memory/ ├── README.md · README.zh-CN.md ├── LICENSE · CHANGELOG.md · .gitignore ├── tools/ │ ├── mem.mjs # the 24-command engine (single file, zero deps) │ └── mem-core.mjs # shared facade — the single entry for plugin & CLI ├── plugin/dsh-memory/ # DeepSeek Harness bundle (Plugin Edition) │ ├── index.js # prompt injection · mem_recall · mem_save · /memory │ ├── client.js # read-only Settings card (settings.section) │ ├── cordis.patch.yml # loader rows + config (memoryCorePath, maxHits) │ ├── locale/ # en / zh metadata │ └── README.md # install · dependency materialization · acceptance ├── install/ │ ├── setup.mjs # one-shot bootstrap │ └── smoke.mjs # end-to-end smoke test ├── templates/ # AGENTS.md.example + entry.example.md ├── docs/ # DESIGN · COMMANDS · RESTORE · ATTRIBUTION ├── examples/ # real sanitized lessons └── assets/fonts/ # self-hosted OFL fonts + license texts ``` --- ## 🔐 Security & Trust Model | Layer | Mechanism | Defends against | |---|---|---| | 1️⃣ Provenance | `originSessionId` + `created/verified` stamps | unattributed claims | | 2️⃣ Approval | human consent + `store` gate + write mode (`approval` asks **every** call) | agent over-eager writing | | 3️⃣ Detection | secret patterns · PII gate · Jaccard ≥0.6 gate · evidence chain | leaks, PII, duplication, rumor | | 4️⃣ Integrity | git rollback (local-only recommended) | everything else | > Memory poisoning is a recognized attack class (OWASP **ASI06**). Auto-writing memory systems > are the target. The default write mode **never** writes without a human — `mem_save` returns > `ask` on **every** call, a `never` approval policy refuses it outright, and the Settings card > exposes **no write buttons** at all. --- ## 🗺 Roadmap - 🔌 **Now (0.5.x)** — everything above is shipped; maintenance and polish only. - 🌱 **later** — optional multi-book federation · more CJK session-search fallbacks · optional SQLite FTS5 recall (stays off the zero-dependency default). - 🚫 **Won't do** — vector stores · gateways · silent auto-write. Triggers documented in `docs/DESIGN.md`. --- ## 🤝 Contributing PRs welcome — especially **new lesson packs** (sanitized!). Run `node install/smoke.mjs` green before submitting. All code must stay **zero-dependency**. --- ## ⚖️ Legal & attribution - **Unofficial project.** Not affiliated with, sponsored by, or endorsed by any named product, company or organization (including DeepSeek, Anthropic, OpenAI, Mem0, Zep, Letta, Cognee, Tencent Cloud, OWASP, or the SIL). Product names are used only for factual, nominative reference. - **Opinions are ours.** Comparison statements reflect publicly documented facts and personal experience at a point in time — verify against current vendor documentation before deciding. - **Fonts:** Orbitron, Space Grotesk and IBM Plex Mono are bundled under the **SIL Open Font License 1.1** — full license texts in [`assets/fonts/licenses/`](./assets/fonts/licenses/). CJK text uses your system fonts (nothing bundled). - **No warranty.** Software provided as-is under the MIT License — see [`LICENSE`](./LICENSE).---``` ╔═══════════════════════════════════════════════════════════╗ ║ ★ L E S S O N S L I V E O N D I S K ★ ║ ║ Evidence in, garbage out — never. ║ ║ 错题本 · lesson book ║ ╚═══════════════════════════════════════════════════════════╝ ``` _Made with 📕 + 🛠 + zero dependencies — **MIT** © 2026 Agent Lesson Book contributors_