Lessons on disk. Evidence enforced. Auto-injected into every session.
๐ English ยท ็ฎไฝไธญๆ
index ยท inject ยท list ยท search ยท show ยท store ยท forget ยท review ยท draft ยท drafts ยท approve ยท reject ยท prune-drafts ยท write-mode ยท explain ยท verify ยท feedback ยท map ยท gather ยท conflicts ยท resolve ยท global-sync ยท stats ยท doctor
mem_recallยทmem_saveยท/memory recall|save|doctor|review|map|conflicts|resolve|explain|verify|feedback|stats|draft|drafts|approve|reject|write-mode
๐จ Click to see the ASCII art โจ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ A G E N T L E S S O N B O O K ยท ้ ้ข ๆฌ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ
โ โSYMPTOM ๐กโโโ CAUSE ๐โโโ FIX ๐ โโโVERIFY โ
โ = 1 lesson โ
โ โ ็ฐ่ฑก โ โ ๅคๅฎ โ โ ่งฃๆณ โ โ ้ช่ฏ โ โ
โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ
โ ๐พ plain text ๐ findable ๐ก audited โ
โ ๐ฅ โค2KB injected ๐ survives updates โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโ
โ grep โ โ IDF โ โ aliasโ โ gramsโ โ statsโ
โโโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโ
โฆ zero dependencies ยท pure Node.js โฆ
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 |
Contents โ What's in v0.5.0 ยท Why ยท Features ยท Two ways to run ยท Entry format ยท Commands ยท Architecture ยท Security ยท Roadmap
The lesson book runs standalone and natively inside DeepSeek Harness โ one zero-dependency engine, two delivery faces, plus a read-only settings card in the Harness UI.
| Standalone CLI | Harness plugin | |
|---|---|---|
| Memory in context | mem inject block in AGENTS.md |
prompt section every turn (โค 2 KB, fail-degrade) |
| Search from the agent | run mem.mjs search via shell |
mem_recall tool (lesson book + session full-text) |
| Write a lesson | mem.mjs store via shell |
mem_save tool โ gated by the write mode |
| Human maintenance | mem.mjs commands |
/memory โฆ (17 subcommands) |
| At a glance | mem doctor |
read-only Settings card โ status, confidence mix, recall hit-rate, entry search |
What landed recently (see CHANGELOG.md):
- Read-only Settings card โ a
settings.sectionview of index budget, entry count, write mode, confidence mix, draft/conflict counts, 7-day recall hit-rate, recent entries and an entry search. It is read-only by design: data comes from a same-origin route with onlystatus/search, never a write path; if it can't load, it degrades to a pointer back to/memory, which stays fully functional. - Write modes โ
write-mode approval | auto-draft | auto-low-risk | off.approval(the default) asks a human on every model write; the auto modes let a well-gated engine write without prompts, andoffblocks model writes outright. Human commands are never gated. - Confidence & lifecycle โ every entry derives
verified / provisional / needs-review / stale / disputedfrom evidence, freshness and conflicts;explain <name>shows why an entry is trusted,verifyruns whitelisted re-checks, andreviewkeeps it honest on a 90-day clock. - Two-stage recall + feedback loop โ candidate search reranks by confidence, freshness
and what you actually adopted (
feedback), so the book learns which lessons proved useful. - Conflict adjudication โ
conflictslists contradicting pairs;resolve <loser> --prefer <winner> --reason โฆrecords a verdict while keeping both entries (the loser derives tostale, nothing is hard-deleted). - Scales to 1,000 entries โ the injected index stays โค 2 KB (token cost unchanged); an inverted index plus an mtime parse cache keep search fast (โ 1 ms steady-state, flat as the book grows).
- Privacy switches โ
DSH_MEMORY_TELEMETRY=offstops local telemetry writes; ascanPiigate refuses entries containing an email address or mainland mobile number. - Hardened release โ 70 unit tests (14 files), a zero-dependency release smoke, and a
GitHub Actions workflow (
sync-release --check+ tests + smoke + syntax).
Every new AI session starts amnesia-grade clean. Heavyweight memory platforms solve this with vector databases, knowledge graphs, gateways and LLM extraction pipelines. That is a lot of machinery โ and a lot of attack surface โ for a personal mistake notebook.
Agent Lesson Book takes the opposite bet:
What you get instead of infrastructure:
- ๐ Four-section lessons โ
Symptom / Cause / Fix / Verification(or ็ฐ่ฑก / ๅคๅฎ / ่งฃๆณ / ้ช่ฏ). A lesson without a verifiable evidence reference in its Verification section is rejected at write time. Memories that cannot prove themselves do not enter the book. - ๐งพ Evidence chain, enforced by code โ every Verification must cite a locatable reference (path / filename / section / issue number), so future sessions can drill straight to the proof.
- ๐ฅ Auto-injection โ
mem injectmirrors the โค 2 KB index into yourAGENTS.md; the Harness plugin injects it into the prompt directly. Every new session starts with memory already in context. Fail-safe: over budget โ lines drop; anything breaks โ silent degrade to plain conventions. Never blocks a session. - ๐ก Anti-poisoning by design โ human-approved writes, secret- and PII-pattern rejection, near-duplicate interception, source stamps, and full git rollback. (Compare: OWASP ASI06 "memory & context poisoning" โ auto-writing memory systems are the target.)
| ๐ฎ | Feature | Why it matters |
|---|---|---|
| ๐ | Four-section entries (bilingual labels) | Structure survives translation and time |
| ๐ | Evidence-chain gate | No proof โ no entry. Kills "I remember something like that" |
| ๐ฅ | mem inject auto-injection |
Memory without relying on agent discipline |
| ๐งฉ | Native Harness plugin | Index in the prompt every turn โ not even AGENTS.md discipline needed |
| ๐ฅ | Read-only Settings card | Status, confidence, recall hit-rate and search at a glance โ no write buttons |
| ๐ | mem_recall tool |
Lesson book โช past-session full-text in one call |
| โ๏ธ | mem_save tool |
Writes gated by the write mode; approval always asks a human first |
| ๐ | Write modes | approval / auto-draft / auto-low-risk / off โ tune prompts vs automation; humans never gated |
| ๐ฌ | /memory command |
17 subcommands from the chat box; typing one is the approval |
| ๐ฏ | IDF-ranked 3-way search | Literal โช CJK bigram/unigram โช aliases synonyms; rare terms win |
| ๐ | Two-stage recall + feedback | Candidates rerank by confidence, freshness and what you actually used |
| ๐ | explain / verify |
See why an entry is trusted; re-run whitelisted evidence checks |
| โป๏ธ | supersedes auto-archive |
Lessons evolve; old versions retire to archive/ automatically |
| โ๏ธ | Conflict adjudication | conflicts lists contradictions; resolve records a verdict, both sides kept |
| ๐บ | mem map text knowledge graph |
Six sections: supersede ยท causal ยท conflicts ยท expired ยท timeline ยท root causes |
| ๐ฑ | mem gather evidence pack |
Confidence-tiered evidence for synthesis โ never writes a conclusion |
| ๐ | mem draft pipeline |
Skeleton first, human approval, then store |
| โฐ | review due dates |
Memory rots โ 90-day checks keep it honest |
| ๐ซ | Near-duplicate interception | Two sessions, same lesson โ one entry, not two |
| ๐ | mem global-sync mirror |
scope: global lessons reachable from any workspace |
| ๐งช | mem stats telemetry |
Search hit-rate โ evidence, not vibes |
| ๐ฉบ | mem doctor health check |
Index budget, drift, stale reviews โ one command |
| ๐งช | install/smoke.mjs E2E |
One command proves an install: gates, search, injection, doctor |
| ๐ฒ | UTF-8 / CJK-safe | Node-only writes; PowerShell encoding traps documented |
| 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 |
The three hard rules (from docs/DESIGN.md):
- Budget cap โ injection = the index verbatim โค 2 KB; over budget โ drop lines.
- Fail-degrade โ unreadable index โ silent fallback to pointer conventions. Sessions never block.
- Human-approved writes โ the tool proposes (
draft/mem_save), the human disposes (store/ approval). The auto write-modes are opt-in.
Requirements: Node.js โฅ 18. Nothing else. No npm install, no database, no API key. (The plugin face additionally needs DeepSeek Harness; the engine stays zero-dependency.)
Step 1 โ copy the folder into your project root (the folder where your AGENTS.md lives):
cp -r cross-session-memory/* your-project/
cd your-projectStep 2 โ one-shot bootstrap:
node install/setup.mjs --with-sample[setup] memory bank ready โ .memory/
[setup] conventions wired โ AGENTS.md (created / updated)
[setup] index injected โ 2.0 KB / 2.0 KB hard cap
[setup] doctor โ healthy: no anomalies
[setup] next: node tools/mem.mjs draft my-first-lesson
Step 3 โ prove the install (optional but lovely):
node install/smoke.mjs # E2E: gates ยท search ยท injection budget ยท doctorplugin_manager โ install_bundle โ target = <clone>/plugin/dsh-memory
That one command mounts the whole trio (prompt injection ยท mem_recall / mem_save ยท
/memory) plus the read-only Settings card. Exact dependency recipe, configuration keys
(memoryCorePath, maxHits) and a six-item acceptance checklist live in
plugin/README.md.
Your first lesson (ask the user's consent first, per convention):
node tools/mem.mjs draft ssh-timeout
# edit .memory/drafts/<date>-ssh-timeout.md โ four sections, evidence in Verification
node tools/mem.mjs store .memory/drafts/<date>-ssh-timeout.md
node tools/mem.mjs doctorThat's it. Every new session now starts with your lesson index in context.
Four sections. Chinese and English labels are both accepted. Missing Verification โ or Verification without a locatable reference โ is rejected.
---
name: git-autocrlf-breaks-byte-exact-restore
description: core.autocrlf=true turns LF into CRLF on checkout
aliases: line ending,CRLF,restore
metadata:
type: lesson
scope: global
created: 2026-09-22
verified: 2026-09-22
review: 2026-12-21
---
Symptom๏ผRestore test fails byte counts: 1898 โ 1915 after `git checkout`.
Cause๏ผcore.autocrlf=true smudge filter rewrites LF to CRLF on checkout.
Fix๏ผgit config core.autocrlf false + writers emit LF.
Verification๏ผRe-test returns 1898 โ 1898 byte-identical (see `tools/mem.mjs`, CHANGELOG 0.2.0).๐งช Try the gates:
node tools/mem.mjs store examples/lesson-autocrlf.md # โ accepted # now strip the reference from its Verification section and retry: node tools/mem.mjs store broken.md # โ rejected: no locatable reference
| Command | Effect |
|---|---|
index |
print / regenerate the budgeted index |
inject |
sync the injection block into AGENTS.md (auto on writes) |
list |
list all entries with health flags |
search <q> [n] [--two-stage] |
IDF 3-way search with snippets; --two-stage reranks by confidence / freshness / feedback |
show <name> |
print one full entry |
store <file|-> [--overwrite] [--force] [--model] |
validate & store (secrets/PII/dupes/evidence gated) |
forget <name> |
archive, never hard-delete |
review <name> |
refresh verification date, push review +90 days |
draft [topic] |
generate a four-section skeleton (lands in drafts/) |
drafts |
list pending drafts |
approve <draft> |
approve a draft into the book (full store gate) |
reject <draft> [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 <name> |
why an entry is trusted โ confidence, state, evidence, relations |
verify [name|--all] |
run verification recipes (whitelist only, never arbitrary shell) |
feedback <q> <adopted,csv> [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 <q> [budget] |
evidence pack, confidence-tiered โ never writes a conclusion |
conflicts |
list unresolved conflictsWith pairs |
resolve <loser> --prefer <winner> --reason <text> |
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) |
| Surface | Effect |
|---|---|
| prompt section | lesson index โค 2 KB, every turn, fail-degrade |
mem_recall <query> [limit] |
lesson book โช session full-text, merged & ranked |
mem_save <content> |
write one lesson โ gated by the write mode (approval always asks) |
/memory <subcommand> |
17 maintenance subcommands โ typing one is the approval |
| Settings card | read-only status ยท confidence ยท hit-rate ยท search |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ .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.
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
| 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_savereturnsaskon every call, aneverapproval policy refuses it outright, and the Settings card exposes no write buttons at all.
- ๐ 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.
PRs welcome โ especially new lesson packs (sanitized!). Run node install/smoke.mjs green
before submitting. All code must stay zero-dependency.
- 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/. CJK text uses your system fonts (nothing bundled). - No warranty. Software provided as-is under the MIT License โ see
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