agent-recall-mcp 3.3.27 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,34 +1,366 @@
1
- <h1 align="center">AgentRecall — MCP Server</h1>
1
+ <h1 align="center">AgentRecall</h1>
2
2
 
3
3
  <p align="center"><strong>Your agent doesn't just remember. It learns how you think.</strong></p>
4
- <p align="center">Persistent, compounding memory + automatic correction capture for Claude Code, Cursor, Windsurf, Codex, and any MCP-compatible agent.</p>
4
+ <p align="center">Every correction saved is a mistake never repeated. Every insight compounded is tokens never wasted rebuilding context.</p>
5
+ <p align="center">Persistent, compounding memory + automatic correction capture. MCP server + SDK + CLI.</p>
5
6
 
6
7
  <p align="center">
7
8
  <a href="https://www.npmjs.com/package/agent-recall-mcp"><img src="https://img.shields.io/npm/v/agent-recall-mcp?style=flat-square&label=MCP&color=5D34F2" alt="MCP npm"></a>
9
+ <a href="https://www.npmjs.com/package/agent-recall-sdk"><img src="https://img.shields.io/npm/v/agent-recall-sdk?style=flat-square&label=SDK&color=0EA5E9" alt="SDK npm"></a>
10
+ <a href="https://www.npmjs.com/package/agent-recall-cli"><img src="https://img.shields.io/npm/v/agent-recall-cli?style=flat-square&label=CLI&color=10B981" alt="CLI npm"></a>
8
11
  <a href="https://github.com/Goldentrii/AgentRecall/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen?style=flat-square" alt="License"></a>
9
12
  <a href="https://lobehub.com/mcp/goldentrii-agentrecall"><img src="https://lobehub.com/badge/mcp/goldentrii-agentrecall" alt="MCP Badge"></a>
10
- <img src="https://img.shields.io/badge/MCP-7_tools-orange?style=flat-square" alt="Tools">
13
+ <img src="https://img.shields.io/badge/MCP-10_tools-orange?style=flat-square" alt="Tools">
11
14
  <img src="https://img.shields.io/badge/cloud-zero-blue?style=flat-square" alt="Zero Cloud">
15
+ <img src="https://img.shields.io/badge/Obsidian-compatible-7C3AED?style=flat-square" alt="Obsidian">
16
+ <img src="https://img.shields.io/badge/digest_cache-83%25_token_savings-FF6B6B?style=flat-square" alt="Digest cache savings">
12
17
  <img src="https://img.shields.io/badge/saves_up_to-57%25_tokens-FF6B6B?style=flat-square" alt="Token savings">
13
18
  <img src="https://img.shields.io/badge/break--even-3--4_sessions-22C55E?style=flat-square" alt="Break-even">
19
+ <img src="https://img.shields.io/badge/scoring-RRF_(Cormack_2009)-7C3AED?style=flat-square" alt="RRF scoring">
20
+ <img src="https://img.shields.io/badge/decay-Ebbinghaus%2BZipf-3B82F6?style=flat-square" alt="Ebbinghaus+Zipf decay">
21
+ <img src="https://img.shields.io/badge/feedback-Bayesian_Beta_(active)-F59E0B?style=flat-square" alt="Beta distribution">
22
+ <img src="https://img.shields.io/badge/semantic_recall-pgvector_%2B_RRF-8B5CF6?style=flat-square" alt="Semantic recall">
14
23
  </p>
15
24
 
16
25
  <p align="center">
17
- <a href="#quick-start"><b>Install</b></a> ·
18
- <a href="#four-commands"><b>Commands</b></a> ·
19
- <a href="#auto-hooks"><b>Hooks</b></a> ·
20
- <a href="#6-mcp-tools"><b>Tools</b></a> ·
21
- <a href="#benchmarked-savings"><b>Benchmarks</b></a> ·
22
- <a href="#architecture"><b>Architecture</b></a>
26
+ <b>EN:</b>&nbsp;
27
+ <a href="#why-choose-agentrecall">Why</a> ·
28
+ <a href="#three-ways-to-use-it">Use</a> ·
29
+ <a href="#quick-start">Install</a> ·
30
+ <a href="#semantic-recall--pgvector-backend-v340">Semantic Recall</a> ·
31
+ <a href="#10-mcp-tools">Tools</a> ·
32
+ <a href="#how-memory-compounds">Compounding</a> ·
33
+ <a href="#sdk-api">SDK</a> ·
34
+ <a href="#architecture">Architecture</a> ·
35
+ <a href="#docs">Docs</a>
23
36
  &nbsp;&nbsp;|&nbsp;&nbsp;
24
- <a href="#agentrecall-mcp中文文档">中文</a>
37
+ <b>中文:</b>&nbsp;
38
+ <a href="#agentrecall中文文档">简介</a> ·
39
+ <a href="#快速开始">安装</a> ·
40
+ <a href="#语义召回--pgvector-v340">语义召回</a> ·
41
+ <a href="#10-个-mcp-工具">工具</a> ·
42
+ <a href="#记忆如何复合增长">复合</a> ·
43
+ <a href="#架构">架构</a>
25
44
  </p>
26
45
 
27
46
  ---
28
47
 
48
+ <p align="center">
49
+ <a href="#arstatus-arsave-arstart-arsaveall-and-arbootstrap"><img src="https://img.shields.io/badge/%2Farstatus-START_HERE-22C55E?style=for-the-badge" alt="/arstatus"></a>
50
+ <a href="#arstatus-arsave-arstart-arsaveall-and-arbootstrap"><img src="https://img.shields.io/badge/%2Farstart-Load_Context-4ECDC4?style=for-the-badge" alt="/arstart"></a>
51
+ <a href="#arstatus-arsave-arstart-arsaveall-and-arbootstrap"><img src="https://img.shields.io/badge/%2Farsave-Save_Session-FF6B6B?style=for-the-badge" alt="/arsave"></a>
52
+ <a href="#arstatus-arsave-arstart-arsaveall-and-arbootstrap"><img src="https://img.shields.io/badge/%2Farsaveall-Batch_Save_All-FFD93D?style=for-the-badge" alt="/arsaveall"></a>
53
+ <a href="#already-using-another-memory-system-arbootstrap"><img src="https://img.shields.io/badge/%2Farbootstrap-Transfer_Memory-8B5CF6?style=for-the-badge" alt="/arbootstrap"></a>
54
+ </p>
55
+ <p align="center">
56
+ <img src="https://img.shields.io/badge/AUTO-hook--start-8B5CF6?style=for-the-badge" alt="hook-start">
57
+ <img src="https://img.shields.io/badge/AUTO-hook--correction-F97316?style=for-the-badge" alt="hook-correction">
58
+ <img src="https://img.shields.io/badge/AUTO-hook--end-06B6D4?style=for-the-badge" alt="hook-end">
59
+ </p>
60
+ <p align="center">
61
+ <a href="#how-memory-compounds"><img src="https://img.shields.io/badge/1-AUTO--NAMING-5D34F2?style=for-the-badge" alt="Auto-Naming"></a>
62
+ <a href="#how-memory-compounds"><img src="https://img.shields.io/badge/2-INDEXES-0EA5E9?style=for-the-badge" alt="Indexes"></a>
63
+ <a href="#how-memory-compounds"><img src="https://img.shields.io/badge/3-RELATIVITY-10B981?style=for-the-badge" alt="Relativity"></a>
64
+ <a href="#how-memory-compounds"><img src="https://img.shields.io/badge/4-WEIGHT_%2B_DECAY-F59E0B?style=for-the-badge" alt="Weight + Decay"></a>
65
+ <a href="#how-memory-compounds"><img src="https://img.shields.io/badge/5-FEEDBACK_LOOP-EF4444?style=for-the-badge" alt="Feedback Loop"></a>
66
+ </p>
67
+
68
+ ## Already Using Another Memory System? `/arbootstrap`
69
+
70
+ > [!NOTE]
71
+ > **You don't start from zero.** If you've been using Claude's built-in memory, Mem0, or just working in git repos — AgentRecall can discover and import your existing context automatically.
72
+
73
+ Most users installing AgentRecall aren't starting fresh. They already have:
74
+ - **Git repos** with months of commit history and project structure
75
+ - **Claude AutoMemory** (`~/.claude/projects/`) with user profiles, feedback, and project memories
76
+ - **CLAUDE.md files** with project conventions and architecture decisions
77
+
78
+ **`/arbootstrap`** scans your machine and imports everything in one shot:
79
+
80
+ ```
81
+ /arbootstrap
82
+
83
+ ──────────────────────────────────────────────────────────────
84
+ AgentRecall Bootstrap Scan 2026-04-26
85
+ ──────────────────────────────────────────────────────────────
86
+
87
+ Found on your machine:
88
+ 24 git repos
89
+ 92 Claude memory files
90
+ 3 CLAUDE.md files
91
+
92
+ Projects:
93
+ 18 new (not yet in AgentRecall)
94
+ 10 already imported
95
+
96
+ Scan time: 141ms
97
+ ──────────────────────────────────────────────────────────────
98
+ ```
99
+
100
+ **What gets imported per project:**
101
+ - **Identity** — project name, language, description → `palace/identity.md`
102
+ - **Architecture** — CLAUDE.md conventions → `palace/rooms/architecture/`
103
+ - **Memory** — Claude AutoMemory files → `palace/rooms/knowledge/`
104
+ - **Trajectory** — recent git history → initial journal entry
105
+
106
+ **Safety guarantees:**
107
+ - Scan is read-only — never writes to your machine
108
+ - Import only writes to `~/.agent-recall/` — never modifies source files
109
+ - Skips `.env`, credentials, `.pem`, `.key` — never reads secrets
110
+ - Projects already in AgentRecall are skipped (no double-import)
111
+
112
+ **For MCP-only environments** (Codex, Cursor, VS Code Copilot):
113
+ ```
114
+ bootstrap_scan() # discover what's on the machine
115
+ bootstrap_import({ scan_result }) # import selected projects
116
+ ```
117
+
118
+ **For CLI:**
119
+ ```bash
120
+ ar bootstrap # scan and show results
121
+ ar bootstrap --dry-run # preview what would be imported
122
+ ar bootstrap --import # import all new projects
123
+ ar bootstrap --import --project X # import one project
124
+ ```
125
+
126
+ After bootstrap, run `/arstatus` — your projects are ready.
127
+
128
+ ---
129
+
130
+ ## `/arstatus`, `/arsave`, `/arstart`, `/arsaveall`, and `/arbootstrap`
131
+
132
+ > [!TIP]
133
+ > **New to AgentRecall?** Read the **[→ Command Reference](docs/commands.md)** — full instructions, all example outputs, installation, and troubleshooting in one place.
134
+
135
+ > [!IMPORTANT]
136
+ > **Run `/arstatus` at the start of every session.** It shows all your projects, what's pending, what's blocked, and lets you pick what to work on — by number, not by remembering project names. Without it, a fresh agent has no idea where to begin.
137
+
138
+ | Command | When | What it does |
139
+ |---------|------|-------------|
140
+ | ⭐ **`/arstatus`** | **Every session — run this first** | **Status board across ALL projects: pending work, blockers, numbered pick list. The true cold start.** |
141
+ | **`/arstart`** | After picking a project | Load deep context for one project: palace rooms, corrections, task-specific recall |
142
+ | **`/arsave`** | End of session | Write journal + consolidate to palace + update awareness |
143
+ | **`/arsaveall`** | End of day (multi-session) | **Batch save all parallel sessions at once** — scan, merge, deduplicate, done |
144
+ | **`/arbootstrap`** | **First install / switching from another memory system** | **Scan your machine for existing projects and import them into AgentRecall in seconds** |
145
+
146
+ **The session flow:** `/arstatus` → pick a number → `/arstart <project>` → work → `/arsave`.
147
+
148
+ **Running 5 agents in parallel?** Don't `/arsave` five times. Type **`/arsaveall`** once — it scans all of today's sessions across all projects, merges them into consolidated journals, deduplicates insights, and updates awareness in one shot. Each session writes to its own file (session-ID scoped), so **no conflicts, no data loss, no matter how many windows you have open.**
149
+
150
+ ### What You'll See
151
+
152
+ Type `/arstatus` → see everything in flight across all projects, pick by number:
153
+
154
+ ```
155
+ ──────────────────────────────────────────────────────────────
156
+ AgentRecall Status Board 2026-04-21 5 projects
157
+ ──────────────────────────────────────────────────────────────
158
+
159
+ 1 ⚠ novada-site 2026-04-21 BLOCKED
160
+ Blocked: .env.local missing — Phase 1 cannot proceed
161
+
162
+ 2 ● novada-mcp 2026-04-21
163
+ Next: fix novada_search POST /request → publish v0.8.0
164
+
165
+ 3 ● prismma-scraper 2026-04-17
166
+ Next: UI upgrade Option A — light mode + 3D visuals
167
+
168
+ 4 ✓ AgentRecall 2026-04-21 complete
169
+ Collecting real production data
170
+
171
+ ──────────────────────────────────────────────────────────────
172
+ Enter a number, or:
173
+ N New project (with memory — agent knows your full history)
174
+ X New project (clean slate — no prior context, pure objectivity)
175
+ ──────────────────────────────────────────────────────────────
176
+ ```
177
+
178
+ Type `/arsave` → the system saves everything and renders a card with exact file paths and counts:
179
+
180
+ ```
181
+ ──────────────────────────────────────────────────────────────
182
+ AgentRecall ✓ Saved my-project 2026-04-20 #12
183
+ ──────────────────────────────────────────────────────────────
184
+
185
+ Journal ~/.agent-recall/projects/my-project/journal/
186
+ └─ 2026-04-20--arsave--15L--review-feedback.md [written]
187
+
188
+ Awareness 2 insights added (8 total)
189
+
190
+ Palace ~/.agent-recall/projects/my-project/palace/
191
+ ├─ rooms/Architecture [updated]
192
+ └─ rooms/Goals [updated]
193
+
194
+ Corrections 3 stored (always loaded at session start)
195
+
196
+ ⚡ Similar entries found — consider merging:
197
+ 2026-04-19 (review, feedback, architecture)
198
+
199
+ ──────────────────────────────────────────────────────────────
200
+ ```
201
+
202
+ Type `/arstart` → loads all context from memory in one shot:
203
+
204
+ ```
205
+ ──────────────────────────────────────────────────────────────
206
+ AgentRecall ↻ Loaded my-project 2026-04-21
207
+ ──────────────────────────────────────────────────────────────
208
+
209
+ Project my-project — SaaS platform for AI agents
210
+ Last session 2026-04-20 — review + feedback loop shipped
211
+
212
+ Insights (top 3):
213
+ [5×] Server-rendered cards beat agent templates
214
+ [3×] Per-message dedup beats per-session dedup
215
+ [2×] Stemming + synonyms improve keyword recall
216
+
217
+ ⚠ Past corrections — watch out:
218
+ - "No dark backgrounds" (corrected 3×)
219
+ - "Use bb-browser, not Playwright" (corrected 2×)
220
+
221
+ Cross-project: 2 related insights from novada-mcp
222
+
223
+ ──────────────────────────────────────────────────────────────
224
+ ```
225
+
226
+ Type `/arsaveall` → batch-saves all parallel sessions at once:
227
+
228
+ ```
229
+ ──────────────────────────────────────────────────────────────
230
+ AgentRecall ✓ Batch Saved 2026-04-20
231
+ ──────────────────────────────────────────────────────────────
232
+
233
+ Sessions scanned 5
234
+ Projects saved my-project, novada-mcp, prismma-scraper
235
+ Insights merged 4 (deduplicated from 7)
236
+ Corrections 2 new (auto-captured via hooks)
237
+
238
+ ──────────────────────────────────────────────────────────────
239
+ ```
240
+
241
+ Type `/arbootstrap` → discover and import projects from your existing tools:
242
+
243
+ ```
244
+ ──────────────────────────────────────────────────────────────
245
+ AgentRecall Bootstrap Complete 2026-04-26
246
+ ──────────────────────────────────────────────────────────────
247
+
248
+ 12 projects created
249
+ 87 items imported (identity, memory, architecture, trajectory)
250
+ 3 items skipped
251
+ 0 errors
252
+
253
+ Run /arstatus to see your projects.
254
+ ──────────────────────────────────────────────────────────────
255
+ ```
256
+
257
+ The cards are **rendered server-side** — computed from actual operation results, not agent interpretation. What you see is always accurate.
258
+
259
+ ```bash
260
+ # Install commands (one-time, Claude Code only)
261
+ mkdir -p ~/.claude/commands
262
+ curl -o ~/.claude/commands/arstatus.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstatus.md
263
+ curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstart.md
264
+ curl -o ~/.claude/commands/arsave.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsave.md
265
+ curl -o ~/.claude/commands/arsaveall.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsaveall.md
266
+ curl -o ~/.claude/commands/arbootstrap.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arbootstrap.md
267
+ ```
268
+
269
+ ### The Difference
270
+
271
+ ```
272
+ WITHOUT AgentRecall WITH AgentRecall
273
+ ────────────────── ────────────────
274
+
275
+ Day 1: Build monorepo Day 1: /arstart → /arsave
276
+ Day 2: "What monorepo?" Day 2: /arstart
277
+ → 20 min re-explaining → 2 sec: loads all decisions
278
+ → Agent repeats same mistakes → Knows "no version inflation"
279
+ → Forgets your priorities → Knows "arsave = hero section"
280
+ → Misses half the tasks → Pushes to both repos
281
+ ```
282
+
283
+ ```
284
+ WITHOUT AgentRecall (5 parallel agents) WITH AgentRecall (5 parallel agents)
285
+ ────────────────────────────────────── ────────────────────────────────────
286
+
287
+ Agent 1 finishes: you /arsave Agent 1-5 finish: you type /arsaveall once
288
+ Agent 2 finishes: you /arsave again → Scans all 5 sessions automatically
289
+ Agent 3 finishes: you /arsave again → Merges into consolidated journals
290
+ Agent 4 finishes: you /arsave again → Deduplicates insights across sessions
291
+ Agent 5 finishes: you /arsave again → Zero conflicts (session-ID scoped files)
292
+ → 5x the work, corrections lost → One command, everything saved
293
+ → Agent 3's correction unknown to Agent 5 → All agents share the same memory
294
+ ```
295
+
296
+ ### Three Layers of Value
297
+
298
+ **Layer 1 (5 seconds):** It makes your AI agent remember what happened last session.
299
+
300
+ **Layer 2 (30 seconds):** Every time you correct your agent — "no, not that version", "ask me first" — that correction is stored permanently and recalled before the agent makes the same mistake again. After 10 sessions, your agent understands your priorities, your communication style, your non-negotiables.
301
+
302
+ **Layer 3 (2 minutes):** The [Intelligent Distance Protocol](https://github.com/Goldentrii/AgentRecall/wiki/Intelligent-Distance). The structural gap between human thinking and AI action can't be closed — but it can be navigated better every session. Corrections are training data. The 200-line awareness cap forces quality over quantity. Cross-project insights mean lessons learned once apply everywhere.
303
+
304
+ ---
305
+
306
+ ## Why Choose AgentRecall
307
+
308
+ **AgentRecall is not a memory tool. It's a learning loop.**
309
+
310
+ Memory is the mechanism. Understanding is the goal. Every time you correct your agent — "no, not that version", "put this section first", "ask me before you assume" — that correction is stored, weighted, and recalled next time. After 10 sessions, your agent doesn't just remember your project. It understands how you think: your priorities, your communication style, your non-negotiables.
311
+
312
+ - **Your agent learns how you think.** Humans are inconsistent — we skip from A to E, forget what we said yesterday, change priorities mid-sentence. AgentRecall captures every correction and surfaces it before the next mistake. The gap between what you mean and what your agent does shrinks with every session.
313
+
314
+ - **Compounding awareness, not infinite logs.** Memory is capped at 200 lines. New insights either merge with existing ones (strengthening them) or replace the weakest. After 100 sessions, your awareness file is still 200 lines — but each line carries the weight of cross-validated, confirmed observations.
315
+
316
+ - **Cross-project recall.** Lessons learned in one project apply everywhere. Built a rate limiter last month? That lesson surfaces when you're building one today — in a different repo, through a different agent.
317
+
318
+ - **Near-universal compatibility.** MCP server for any MCP-compatible agent (Claude Code, Cursor, Windsurf, VS Code, Codex). SDK for any JS/TS framework (LangChain, CrewAI, Vercel AI SDK, custom agents). CLI for terminal and CI workflows. One memory system, every surface.
319
+
320
+ - **Zero cloud, zero telemetry, all local.** Everything is markdown on disk. Browse it in Obsidian, grep it in the terminal, version it in git. No accounts, no API keys, no lock-in.
321
+
322
+ ---
323
+
324
+ ## Three Ways to Use It
325
+
326
+ **MCP** — for AI agents (Claude Code, Cursor, Windsurf, VS Code, Codex):
327
+ ```bash
328
+ claude mcp add --scope user agent-recall -- npx -y agent-recall-mcp
329
+ ```
330
+
331
+ **SDK** — for any JS/TS application (LangChain, CrewAI, Vercel AI SDK, custom):
332
+ ```typescript
333
+ import { AgentRecall } from "agent-recall-sdk";
334
+ const memory = new AgentRecall({ project: "my-app" });
335
+ await memory.capture("What stack?", "Next.js + Postgres");
336
+ ```
337
+
338
+ **CLI** — for terminal workflows and CI:
339
+ ```bash
340
+ npx agent-recall-cli capture "What stack?" "Next.js + Postgres"
341
+ npx agent-recall-cli palace walk --depth active
342
+ ```
343
+
344
+ ---
345
+
346
+ ## What Is AgentRecall?
347
+
348
+ A **learning system** that bridges the gap between how humans think and how AI agents work. Not a log. Not a database. A compounding loop where every correction, decision, and insight makes the next session better than the last.
349
+
350
+ | Without AgentRecall | With AgentRecall |
351
+ |---------------------|------------------|
352
+ | Agent forgets yesterday's decisions | Decisions live in palace rooms, loaded on cold start |
353
+ | Same mistake repeated across sessions | `recall_insight` surfaces past lessons before work starts |
354
+ | 5 min context recovery on each session start | 2 second cold start from palace (~200 tokens) |
355
+ | Flat memory files that grow forever | 200-line awareness cap forces merge-or-replace |
356
+ | Knowledge trapped in one project | Cross-project insights match by keyword |
357
+ | Agent misunderstands, you correct, it forgets | `alignment_check` records corrections permanently |
358
+
359
+ ---
360
+
29
361
  ## Quick Start
30
362
 
31
- One command to wire AgentRecall into your agent:
363
+ ### MCP Server (for AI agents)
32
364
 
33
365
  ```bash
34
366
  # Claude Code
@@ -47,45 +379,93 @@ claude mcp add --scope user agent-recall -- npx -y agent-recall-mcp
47
379
  codex mcp add agent-recall -- npx -y agent-recall-mcp
48
380
  ```
49
381
 
50
- **Claude Code skill (one-time, recommended):**
382
+ **Skill (Claude Code only):**
51
383
  ```bash
52
384
  mkdir -p ~/.claude/skills/agent-recall
53
385
  curl -o ~/.claude/skills/agent-recall/SKILL.md \
54
386
  https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/SKILL.md
55
387
  ```
56
388
 
57
- **Install slash commands (Claude Code only):**
389
+ ### SDK (for JS/TS applications)
390
+
58
391
  ```bash
59
- mkdir -p ~/.claude/commands
60
- curl -o ~/.claude/commands/arstatus.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstatus.md
61
- curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstart.md
62
- curl -o ~/.claude/commands/arsave.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsave.md
63
- curl -o ~/.claude/commands/arsaveall.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsaveall.md
392
+ npm install agent-recall-sdk
393
+ ```
394
+
395
+ ```typescript
396
+ import { AgentRecall } from "agent-recall-sdk";
397
+ const memory = new AgentRecall({ project: "my-app" });
398
+ await memory.coldStart(); // load context (~200 tokens)
399
+ await memory.capture("Q", "A"); // quick capture
400
+ await memory.palaceWrite("architecture", "Stack: Next.js + Drizzle");
401
+ ```
402
+
403
+ ### CLI (for terminal and CI)
404
+
405
+ ```bash
406
+ npm install -g agent-recall-cli
407
+ ar capture "What ORM?" "Drizzle" --project my-app
408
+ ar palace walk --depth active
409
+ ar search "rate limiting" --include-palace
64
410
  ```
65
411
 
66
412
  ---
67
413
 
68
- ## Four Commands
414
+ ## Semantic Recall — pgvector Backend (v3.4.0)
69
415
 
70
- > [!IMPORTANT]
71
- > **Start every session with `/arstatus`** it shows all your projects, what's pending, what's blocked, and lets you pick what to work on. Without it, a fresh agent has no idea where to begin.
416
+ > [!NOTE]
417
+ > **New in v3.4.0.** Default keyword recall works without any configuration. Upgrade to Supabase + pgvector when keyword search hits its ceiling: synonyms, paraphrased queries, multi-language recall.
72
418
 
73
- | Command | When | What it does |
74
- |---------|------|-------------|
75
- | **`/arstatus`** | **Every session run this first** | **Status board across ALL projects: pending work, blockers, numbered list to pick from. True cold start.** |
76
- | **`/arstart`** | After picking a project | Load deep context for one project: palace rooms, corrections, task-specific recall |
77
- | **`/arsave`** | End of session | Write journal + consolidate to palace + update awareness |
78
- | **`/arsaveall`** | End of day (multi-session) | Batch save all parallel sessions at once — scan, merge, deduplicate |
419
+ Keyword search matches tokens. Semantic search matches **meaning**. After upgrading:
420
+ - `recall("session expiry")` also surfaces entries about "token refresh" and "auth timeout"
421
+ - No hand-crafted synonyms neededembeddings handle the gap
422
+ - Local files remain the source of truth Supabase is a derived read index
79
423
 
80
- **The session flow:** `/arstatus` → pick a number → `/arstart <project>` → work → `/arsave`.
424
+ ### Setup (3 steps)
425
+
426
+ ```bash
427
+ # Step 1 — interactive setup wizard
428
+ ar setup supabase
81
429
 
82
- **Running 5 agents in parallel?** Don't `/arsave` five times. Type **`/arsaveall`** once it scans all sessions across all projects, merges them into consolidated journals, deduplicates insights. Each session writes to its own file (session-ID scoped), so no conflicts, no data loss.
430
+ # Step 2apply pgvector migration to your Supabase project
431
+ ar setup supabase --migrate
432
+
433
+ # Step 3 — done. Run /arstart — backfill happens automatically.
434
+ ```
435
+
436
+ The wizard prompts for your Supabase project URL and service role key → writes to `~/.agent-recall/config.json`. Never committed to git.
437
+
438
+ ### How it works
439
+
440
+ ```
441
+ remember() / session_end()
442
+ → writes to local ~/.agent-recall/ as always ← source of truth, unchanged
443
+ → async: syncs to Supabase memories table
444
+ → OpenAI text-embedding-3-small (1536 dims)
445
+ or Voyage voyage-3-lite (512 dims, zero-padded to 1536)
446
+ → pgvector stores the embedding
447
+
448
+ recall(query)
449
+ → Supabase configured?
450
+ YES → cosine similarity search via pgvector, reranked with local RRF
451
+ NO → local keyword search (existing behavior, unchanged)
452
+ ```
453
+
454
+ ### Graceful degradation
455
+
456
+ If Supabase is unreachable (network error, quota exceeded, not configured), `recall()` falls back to local keyword search silently. Zero behavior change if the feature is never configured.
457
+
458
+ **Required:** `SUPABASE_URL` + `SUPABASE_SERVICE_ROLE_KEY` + either `OPENAI_API_KEY` or `VOYAGE_API_KEY`. All optional — AgentRecall works fully without them.
459
+
460
+ **Rebuild index:** `ar setup supabase --backfill` — re-embeds all local memories into Supabase.
83
461
 
84
462
  ---
85
463
 
86
- ## Auto Hooks
464
+ ## How an Agent Uses AgentRecall
87
465
 
88
- Wire once in `~/.claude/settings.json`. Every session is saved automatically even without typing `/arsave`:
466
+ ### Automatic (Zero DisciplineHooks)
467
+
468
+ Wire once in `~/.claude/settings.json`. Every session is captured automatically, even without `/arsave`:
89
469
 
90
470
  ```json
91
471
  {
@@ -95,8 +475,6 @@ Wire once in `~/.claude/settings.json`. Every session is saved automatically —
95
475
  }],
96
476
  "UserPromptSubmit": [{
97
477
  "command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-correction 2>/dev/null || true"
98
- }, {
99
- "command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-ambient 2>/dev/null || true"
100
478
  }],
101
479
  "Stop": [{
102
480
  "command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-end 2>/dev/null || true"
@@ -105,106 +483,440 @@ Wire once in `~/.claude/settings.json`. Every session is saved automatically —
105
483
  }
106
484
  ```
107
485
 
108
- | Hook | Trigger | What it does |
109
- |------|---------|-------------|
110
- | `hook-start` | SessionStart | Prints identity + top insights + `watch_for` warnings |
111
- | `hook-correction` | Every user prompt | Detects corrections (regex) and captures them silently — no agent discretion |
112
- | `hook-ambient` | Every user prompt | Extracts keywords → fires recall → injects top results before agent responds |
113
- | `hook-end` | Session close | Appends lightweight end-of-session log entry |
486
+ - **hook-start** on every session open: prints identity + top insights + watch_for warnings
487
+ - **hook-correction** — on every prompt: detects corrections (regex) and captures them silently
488
+ - **hook-end** on every session close: appends a lightweight end-of-session log entry
114
489
 
115
- Hooks move the save burden from agent discretion → harness enforcement. The agent never has to remember to save.
490
+ ### Session Start (`/arstart`)
491
+ ```
492
+ session_start() → identity, insights, active rooms, cross-project matches,
493
+ recent journal briefs, watch_for warnings — all in one call
494
+ recall(query) → surface task-specific past knowledge from all stores
495
+ ```
496
+
497
+ ### During Work
498
+ ```
499
+ remember("We decided to use GraphQL instead of REST") → auto-routes to the right store
500
+ recall("authentication design") → searches all stores, ranked results
501
+ check(goal="build auth", confidence="medium") → verify understanding, get warnings
502
+ ```
503
+
504
+ ### Session End (`/arsave`)
505
+ ```
506
+ session_end(summary="...", insights=[...], trajectory="...") → journal + awareness + consolidation
507
+ ```
116
508
 
117
509
  ---
118
510
 
119
- ## 7 MCP Tools
511
+ ## 10 MCP Tools
120
512
 
121
- AgentRecall exposes 7 tools to your agent. Each tool composes multiple subsystems — the agent doesn't need to know about the plumbing.
513
+ AgentRecall exposes 10 tools to agents. Each tool composes multiple subsystems internally — the agent doesn't need to know about the plumbing.
122
514
 
123
515
  | Tool | What it does |
124
516
  |------|-------------|
125
- | `project_board` | **Run this first.** Status board across ALL projects pending work, blockers, numbered list to pick from. The MCP equivalent of `/arstatus`. Works in Codex, Cursor, Windsurf. |
126
- | `session_start` | Load project context. Returns identity, top insights, active rooms, cross-project matches, and `watch_for` warnings from past corrections. One call, ~400 tokens. |
127
- | `remember` | Save a memory. Auto-classifies and routes to the right store (journal, palace, knowledge, or awareness). Auto-generates semantic names for retrieval. |
128
- | `recall` | Search all memory stores with **Reciprocal Rank Fusion (RRF)**. Returns ranked results. Accepts `feedback` to rate previous results positive boosts future ranking, negative penalizes. |
129
- | `session_end` | Save everything in one call: journal + awareness update + palace consolidation + archive demoted insights (preserved, not deleted). |
130
- | `check` | Record what you think the human wants. Returns `watch_for` patterns from past corrections. Accepts `human_correction` and `delta` after the human responds. |
131
- | `digest` | **Context cache** store pre-computed analysis results and recall them instead of recomputing. Supports TTL, global store, and dedup. **83% token savings on repeated analysis.** |
517
+ | `session_start` | Load project context for a new session. Returns identity, top insights, active rooms, cross-project matches, recent activity, and predictive `watch_for` warnings from past corrections. One call, ~400 tokens. |
518
+ | `remember` | Save a memory. Auto-classifies content (bug fix, architecture decision, insight, session note) and routes to the right store (journal, palace, knowledge, or awareness). Auto-generates semantic names for future retrieval. |
519
+ | `recall` | Search all memory stores at once using **Reciprocal Rank Fusion (RRF)** — each source ranks internally, then positions are merged so no source dominates by default. Returns ranked results with stable IDs. Accepts `feedback` to rate previous results: positive boosts future ranking, negative penalizes. Query-aware feedback from one search doesn't bleed into unrelated queries. |
520
+ | `session_end` | Save everything in one call. Writes journal, updates awareness with new insights, consolidates to palace rooms, archives demoted insights (not deleted preserved with resurrection support). |
521
+ | `check` | Record what you think the human wants. Returns `watch_for` patterns from past correction history ("You've been corrected on X 3 times — ask about it"). Accepts `human_correction` and `delta` after the human responds. Auto-promotes strong patterns (3+) to awareness. |
522
+ | `digest` | **Context cache** store pre-computed analysis results (codebase audits, subagent explorations) and recall them instead of recomputing. Actions: `store`, `recall`, `read`, `invalidate`. Scoring uses Ebbinghaus decay with Zipf-adjusted half-life. **Benchmarked: 83% token savings on repeated analysis vs. recompute.** |
523
+ | `project_board` | Status board across all AgentRecall projects same data as `/arstatus`. Returns numbered project list with pending work, blockers, and last activity. Use at the start of any multi-project session. |
524
+ | `project_status` | Deep status for a single project — next actions, blockers, recent journal summary, palace room health. Use after `project_board` to pick and focus. |
525
+ | `bootstrap_scan` | Scan the machine for existing projects (git repos, Claude AutoMemory, CLAUDE.md files). Read-only — no writes. Returns scan results for review before import. |
526
+ | `bootstrap_import` | Import projects discovered by `bootstrap_scan` into AgentRecall. Writes identity, architecture, memory, and trajectory to `~/.agent-recall/`. Safe: never modifies source files. |
527
+
528
+ ### Legacy tools
529
+
530
+ The original 22 subsystem tools (palace_write, journal_capture, awareness_update, etc.) remain available via the SDK and CLI for backward compatibility and advanced use cases. They are not registered in the MCP server by default.
132
531
 
133
532
  ---
134
533
 
135
534
  ## How Memory Compounds
136
535
 
137
- Memory is not a list. It's a compounding system — each layer feeds the next:
536
+ <p align="center">
537
+ <a href="#1-auto-naming"><img src="https://img.shields.io/badge/1-AUTO--NAMING-5D34F2?style=for-the-badge" alt="Auto-Naming"></a>
538
+ <a href="#2-indexes"><img src="https://img.shields.io/badge/2-INDEXES-0EA5E9?style=for-the-badge" alt="Indexes"></a>
539
+ <a href="#3-relativity"><img src="https://img.shields.io/badge/3-RELATIVITY-10B981?style=for-the-badge" alt="Relativity"></a>
540
+ <a href="#4-weight--decay"><img src="https://img.shields.io/badge/4-WEIGHT_%2B_DECAY-F59E0B?style=for-the-badge" alt="Weight + Decay"></a>
541
+ <a href="#5-feedback-loop"><img src="https://img.shields.io/badge/5-FEEDBACK_LOOP-EF4444?style=for-the-badge" alt="Feedback Loop"></a>
542
+ </p>
543
+
544
+ > Memory is not a list. It's a compounding system where 1+1+1 > 3. Each subsystem feeds the next — naming enables retrieval, retrieval enables feedback, feedback enables ranking, ranking surfaces the right memory at the right time.
545
+
546
+ ### 1. Auto-Naming
547
+
548
+ The agent knows content best at the moment of saving. AgentRecall captures that understanding in a semantic slug — not `"mcp-verified"` but `"verified-agentrecall-mcp-22tools-functional"`. Good naming IS the first layer of retrieval. A well-named memory is 80% findable without any search algorithm.
549
+
550
+ **File naming:** `{date}--{saveType}--{lines}L--{slug}.md` — parseable by agents (`split("--")` → `[date, type, size, topic]`), readable by humans. Line count tells the agent the token cost before opening the file.
551
+
552
+ ### 2. Indexes
553
+
554
+ | Index | What it tracks | Token cost |
555
+ |-------|---------------|------------|
556
+ | **Palace index** | Room catalog + salience scores | ~50 tokens to scan |
557
+ | **Insights index** | Cross-project lessons + keyword matching | ~30 tokens to query |
558
+ | **Awareness** | 200-line compounding document (forced merge) | ~200 tokens, each line cross-validated |
559
+
560
+ ### 3. Relativity
561
+
562
+ Memories that relate to each other are connected automatically — no wikilinks needed. When you `recall("session security")`, the system surfaces keyword-matched memories across connected rooms. Edges are stored in `graph.json` — relativity turns isolated memories into a knowledge graph.
563
+
564
+ ### 4. Weight + Decay
565
+
566
+ Not all memories are equal. Salience scoring: `recency(0.30) + access(0.25) + connections(0.20) + urgency(0.15) + importance(0.10)`
138
567
 
139
- 1. **Auto-Naming** Content is saved with semantic slugs. Good naming is the first layer of retrieval.
140
- 2. **Indexes** — Every memory has an address in palace index, insights index, and the 200-line awareness document.
141
- 3. **Relativity** Memories that relate to each other are connected automatically via graph edges.
142
- 4. **Weight + Decay** — Salience scoring: `recency(0.30) + access(0.25) + connections(0.20) + urgency(0.15) + importance(0.10)`. Architecture decisions persist; blocker noise fades.
143
- 5. **Feedback Loop** — Bayesian Beta distribution (designed) learns which recalled memories are actually useful. Useful memories rise; noise sinks. *Note: the scoring math is implemented but no activation path submits feedback signals yet.*
568
+ `recall` applies the **Ebbinghaus forgetting curve** `R(t) = e^(−t/S)` with memory-type-specific strength values:
569
+
570
+ | Memory type | S (days) | 1-day retention | 1-week retention |
571
+ |-------------|----------|-----------------|------------------|
572
+ | Journal (episodic) | 2 | 60% | ~7% |
573
+ | Knowledge / bug fix (procedural) | 180 | 99% | 96% |
574
+ | Palace / decisions (semantic) | 9999 | ≈100% | ≈100% |
575
+
576
+ Old journal noise fades in days. Architecture decisions persist indefinitely. **Hot-window boost:** Items from the last 6 hours get a 3× score multiplier, last 24 hours get 2×, last 72 hours get 1.3×.
577
+
578
+ ### 5. Feedback Loop
579
+
580
+ The system uses a **Bayesian Beta distribution** — the mathematically optimal estimate of true usefulness from binary observations (`E[Beta(α,β)] = (pos+1)/(pos+neg+2)`). Rating a result "useless" for one query doesn't penalize it for unrelated queries. Feedback is query-aware, not global.
581
+
582
+ > **Feedback is now automatic.** The ambient recall hook tracks which memories were surfaced. Human's next message is a correction → negative feedback. Not a correction → positive feedback. No agent action required.
583
+
584
+ ### The Compounding Effect
144
585
 
145
586
  ```
146
- Session 1: Save 3 memories auto-named, indexed, edges created
147
- Session 5: Recall surfaces sessions 1-4; feedback refines ranking
587
+ Session 1: Save 3 memories (auto-named, indexed, edges created)
588
+ Session 5: Recall surfaces memories from sessions 1-4, feedback refines ranking
148
589
  Session 10: watch_for warns agent about past mistakes before they repeat
149
- Session 20: Awareness has 10 cross-validated insights (merged from 40+ raw)
150
- Session 50: The agent knows your priorities, blind spots, communication style
590
+ Session 20: Awareness contains 10 cross-validated insights (merged from 40+ raw observations)
591
+ Session 50: The agent knows your priorities, blind spots, and communication style
592
+ — not because it was told, but because every correction compounded
151
593
  ```
152
594
 
595
+ **Stemming + synonyms:** "deploying" matches "deployment," "ship," and "release." A 19-rule suffix stemmer + 100-pair synonym table — no vector DB needed (keyword mode), zero external dependencies.
596
+
153
597
  ---
154
598
 
155
- ## Benchmarked Savings
599
+ ## SDK API
156
600
 
157
- > **Honest caveat:** The "without AR" costs are modeled estimateswe estimated what a human would spend re-explaining context. These are not long-term production data. Real savings depend on project complexity and session count. [Let us know](mailto:tong.wu@novada.com) if your results differ.
601
+ The `agent-recall-sdk` package exposes the `AgentRecall` class — a programmatic interface to the full memory system. Use it to add persistent, compounding memory to any JS/TS agent framework.
158
602
 
159
- | Scenario | Without AR | With AR | Saved |
160
- |----------|:----------:|:-------:|:-----:|
161
- | **A: Simple** (2 sessions, 0 corrections) | 567 | 1,131 | **+99% overhead** |
162
- | **B: Medium** (5 sessions, 1 correction) | 6,220 | 4,382 | **-30%** |
163
- | **C: Complex** (20 sessions, 5 corrections) | 40,910 | 17,520 | **-57%** |
164
- | **D: Multi-agent** (3 agents × 5 sessions) | 20,781 | 13,140 | **-37%** |
165
- | **E: Digest cache** (repeated analysis) | ~2,400 | ~400 | **-83%** |
603
+ ```typescript
604
+ import { AgentRecall } from "agent-recall-sdk";
605
+ const ar = new AgentRecall({ project: "my-project" });
606
+ ```
607
+
608
+ ### Core Methods
609
+
610
+ | Method | Returns | Description |
611
+ |--------|---------|-------------|
612
+ | `capture(question, answer, opts?)` | `JournalCaptureResult` | Quick Q&A capture (L1 memory) |
613
+ | `journalWrite(content, opts?)` | `JournalWriteResult` | Write daily journal entry |
614
+ | `journalRead(opts?)` | `JournalReadResult` | Read journal by date or "latest" |
615
+ | `journalSearch(query, opts?)` | `JournalSearchResult` | Full-text search across journals |
616
+ | `coldStart()` | `JournalColdStartResult` | Palace-first context loading (~200 tokens) |
617
+
618
+ ### Palace Methods
619
+
620
+ | Method | Returns | Description |
621
+ |--------|---------|-------------|
622
+ | `palaceWrite(room, content, opts?)` | `PalaceWriteResult` | Write to a room with fan-out cross-refs |
623
+ | `palaceRead(room?, topic?)` | `PalaceReadResult` | Read room content or list all rooms |
624
+ | `walk(depth?, focus?)` | `PalaceWalkResult` | Progressive walk: identity → active → relevant → full |
625
+ | `palaceSearch(query, room?)` | `PalaceSearchResult` | Search rooms by content |
626
+ | `lint(fix?)` | `PalaceLintResult` | Health check and auto-archive |
627
+
628
+ ### Awareness & Insight Methods
629
+
630
+ | Method | Returns | Description |
631
+ |--------|---------|-------------|
632
+ | `awarenessUpdate(insights, opts?)` | `AwarenessUpdateResult` | Compound new insights into awareness |
633
+ | `readAwareness()` | `string` | Read the 200-line awareness document |
634
+ | `recallInsight(context, opts?)` | `RecallInsightResult` | Cross-project insight recall |
635
+
636
+ ### Alignment Methods
637
+
638
+ | Method | Returns | Description |
639
+ |--------|---------|-------------|
640
+ | `alignmentCheck(input)` | `AlignmentCheckResult` | Record confidence + assumptions |
641
+ | `nudge(input)` | `NudgeResult` | Detect contradictions with past decisions |
642
+ | `synthesize(opts?)` | `ContextSynthesizeResult` | L3 synthesis, optional palace consolidation |
643
+
644
+ ---
166
645
 
167
- **Break-even: ~3-4 sessions.** For simple throwaway tasks, AR is overhead. For anything with 3+ sessions, corrections, or multiple agents, it pays for itself.
646
+ ## CLI Commands
647
+
648
+ The `agent-recall-cli` package provides the `ar` command for terminal workflows and CI pipelines.
649
+
650
+ ```
651
+ ar v3.4.0 — AgentRecall CLI
652
+
653
+ JOURNAL:
654
+ ar read [--date YYYY-MM-DD] [--section <name>]
655
+ ar write <content> [--section <name>]
656
+ ar capture <question> <answer> [--tags tag1,tag2]
657
+ ar list [--limit N]
658
+ ar search <query> [--include-palace]
659
+ ar state read|write [data]
660
+ ar cold-start
661
+ ar archive [--older-than-days N]
662
+ ar rollup [--min-age-days N] [--dry-run]
663
+
664
+ PALACE:
665
+ ar palace read [<room>] [--topic <name>]
666
+ ar palace write <room> <content> [--importance high|medium|low]
667
+ ar palace walk [--depth identity|active|relevant|full]
668
+ ar palace search <query>
669
+ ar palace lint [--fix]
670
+
671
+ AWARENESS:
672
+ ar awareness read
673
+ ar awareness update --insight "title" --evidence "ev" --applies-when kw1,kw2
674
+
675
+ INSIGHT:
676
+ ar insight <context> [--limit N]
677
+
678
+ SETUP:
679
+ ar setup supabase # interactive Supabase setup wizard
680
+ ar setup supabase --migrate # apply pgvector migration
681
+ ar setup supabase --backfill # re-embed all local memories
682
+
683
+ META:
684
+ ar projects
685
+ ar synthesize [--entries N]
686
+ ar knowledge write --category <cat> --title "t" --what "w" --cause "c" --fix "f"
687
+ ar knowledge read [--category <cat>]
688
+ ar bootstrap [--dry-run] [--import] [--project X]
689
+
690
+ HOOKS (auto-wired via settings.json — zero discipline required):
691
+ ar hook-start # SessionStart: prints identity + insights + watch_for
692
+ ar hook-correction # UserPromptSubmit: silently captures corrections from prompt
693
+ ar hook-end # Stop: appends end-of-session log entry
694
+
695
+ GLOBAL FLAGS:
696
+ --root <path> Storage root (default: ~/.agent-recall)
697
+ --project <slug> Project override
698
+ ```
168
699
 
169
700
  ---
170
701
 
171
702
  ## Architecture
172
703
 
704
+ ### Five-Layer Memory Pyramid
705
+
173
706
  ```
174
- Agent (Claude Code / Cursor / Windsurf / Codex)
175
-
176
- └─ MCP tools: session_start, remember, recall, session_end, check, digest
177
-
178
- └─ agent-recall-core (local, no cloud)
179
-
180
- ├─ ~/.agent-recall/awareness.md (200-line global document)
181
- ├─ ~/.agent-recall/insights-index.json (cross-project recall)
182
- └─ ~/.agent-recall/projects/<project>/
183
- ├─ journal/ (daily logs)
184
- └─ palace/rooms/ (persistent decisions, Obsidian-compatible)
707
+ L1: Working Memory journal_capture "what happened"
708
+ L2: Episodic Memory journal_write "what it means"
709
+ L3: Memory Palace palace_write / walk "knowledge across sessions"
710
+ L4: Awareness awareness_update "compounding insights"
711
+ L5: Insight Index recall_insight "cross-project experience"
185
712
  ```
186
713
 
187
- Everything is markdown on disk. Browse in Obsidian, grep in terminal, version in git. Zero cloud, zero telemetry.
714
+ ### Key Mechanisms
715
+
716
+ **Fan-out writes** — Write to one room, cross-references auto-update in related rooms via `[[wikilinks]]`. Mechanical, zero LLM cost.
717
+
718
+ **Salience scoring** — Every room has a salience score: `recency(0.30) + access(0.25) + connections(0.20) + urgency(0.15) + importance(0.10)`. High-salience rooms surface first. Below threshold → auto-archive.
719
+
720
+ **Compounding awareness** — `awareness.md` is capped at 200 lines. When new insights are added, similar existing ones merge (strengthen), dissimilar ones compete (lowest-confirmation gets replaced). The constraint creates compression. Compression creates compounding.
721
+
722
+ **Cross-project insight recall** — `insights-index.json` maps insights to situations via keywords. `recall_insight("building quality gates")` returns relevant lessons from any project, ranked by severity x confirmation count.
723
+
724
+ **Obsidian-compatible** — Every palace file has YAML frontmatter + `[[wikilinks]]`. Open `palace/` as an Obsidian vault → graph view shows room connections. Zero Obsidian dependency.
725
+
726
+ ### Storage Layout
727
+
728
+ ```
729
+ ~/.agent-recall/
730
+ awareness.md # 200-line compounding document (global)
731
+ awareness-state.json # Structured awareness data
732
+ awareness-archive.json # Demoted insights (preserved, not deleted)
733
+ insights-index.json # Cross-project insight matching
734
+ config.json # Optional: Supabase URL + keys (never git-committed)
735
+ projects/
736
+ <project>/
737
+ journal/
738
+ YYYY-MM-DD.md # Daily journal
739
+ YYYY-MM-DD-log.md # L1 captures (hook-start/hook-end entries)
740
+ YYYY-MM-DD.state.json # JSON state
741
+ index.jsonl # Fast machine-scannable index of all entries
742
+ palace/
743
+ identity.md # ~50 token project identity card
744
+ palace-index.json # Room catalog + salience scores
745
+ graph.json # Cross-reference edges (relativity)
746
+ feedback-log.json # Per-query feedback scores (recall learning)
747
+ alignment-log.json # Past corrections for watch_for patterns
748
+ rooms/
749
+ goals/ # Active goals, evolution
750
+ architecture/ # Technical decisions, patterns
751
+ decisions/ # Decision trails with prior/posterior tracking
752
+ blockers/ # Current and resolved
753
+ alignment/ # Human corrections
754
+ knowledge/ # Learned lessons by category
755
+ <custom>/ # Agents create rooms on demand
756
+ ```
757
+
758
+ ---
759
+
760
+ ## Platform Compatibility
761
+
762
+ | Platform | MCP | SDK | CLI | Notes |
763
+ |----------|:---:|:---:|:---:|-------|
764
+ | Claude Code | ✅ | ✅ | ✅ | Full support — MCP + SKILL.md + commands |
765
+ | Cursor | ✅ | ✅ | ✅ | MCP via .cursor/mcp.json |
766
+ | VS Code (Copilot) | ✅ | ✅ | ✅ | MCP via .vscode/mcp.json |
767
+ | Windsurf | ✅ | ✅ | ✅ | MCP via mcp_config.json |
768
+ | OpenAI Codex | ✅ | ✅ | ✅ | `codex mcp add` — config.toml |
769
+ | Claude Desktop | ✅ | — | — | MCP server |
770
+ | LangChain / LangGraph | — | ✅ | — | `new AgentRecall()` in your chain |
771
+ | CrewAI | — | ✅ | — | SDK in tool definitions |
772
+ | Vercel AI SDK | — | ✅ | — | SDK in server actions |
773
+ | Custom JS/TS agents | — | ✅ | ✅ | SDK + CLI for any agent framework |
774
+ | CI / GitHub Actions | — | — | ✅ | `npx agent-recall-cli` in workflows |
775
+ | Any MCP agent | ✅ | — | — | Standard MCP protocol |
188
776
 
189
777
  ---
190
778
 
191
- ## Links
779
+ ## Benchmarked Token Savings
780
+
781
+ We ran two controlled benchmarks: a 5-round A/B test (Next.js + Drizzle + Stripe project) and a 10-round v3.3.16 benchmark validating `digest` cache, `arsaveall`, and cross-project recall. **Read this table honestly:** for simple throwaway tasks, AR is pure overhead. For anything with 3+ sessions, corrections, or multiple agents, it pays for itself — and the savings compound.
782
+
783
+ | Scenario | Without AR | With AR | **Saved** |
784
+ |----------|:---------:|:------:|:--------:|
785
+ | **A: Simple** (2 sessions, 0 corrections) | 567 | 1,131 | **+99% overhead** |
786
+ | **B: Medium** (5 sessions, 1 correction) | 6,220 | 4,382 | **-30%** |
787
+ | **C: Complex** (20 sessions, 5 corrections) | 40,910 | 17,520 | **-57%** |
788
+ | **D: Multi-agent** (3 agents × 5 sessions) | 20,781 | 13,140 | **-37%** |
789
+ | **E: Digest cache** (repeated analysis, 1 recall hit) | ~2,400 | ~400 | **-83%** |
790
+
791
+ **Break-even: ~3-4 sessions.** After that, every session with AR is cheaper than without.
792
+
793
+ ### Where the Savings Come From
192
794
 
193
- - **Full documentation:** [Main README](../../README.md)
194
- - **SDK API reference:** [agent-recall-core](../core/README.md)
195
- - **GitHub:** [Goldentrii/AgentRecall](https://github.com/Goldentrii/AgentRecall)
196
- - **Issues:** [GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
197
- - **Email:** [tong.wu@novada.com](mailto:tong.wu@novada.com)
795
+ | Source | Without AR cost | With AR cost | Why |
796
+ |--------|:-:|:-:|-----|
797
+ | **Context rebuild** | Up to ~1,100+ tokens/session | Fixed ~385 tokens (cold start) | AR loads palace context in one call |
798
+ | **Correction retention** | ~800 tokens per repeat | 0 (stored once, never repeated) | Biggest single savings driver in long projects |
799
+ | **Clarification avoidance** | ~400 tokens/session | 0 (already loaded) | Steady per-session savings |
800
+ | **Cross-project recall** | ~500 tokens per insight | ~350 tokens (automatic recall) | Compounds across projects |
801
+ | **Digest cache** | ~2,400 tokens (full re-analysis) | ~400 tokens (recall stored digest) | 83% savings on repeated heavy analysis |
802
+
803
+ All benchmark code: [`benchmark/run.mjs`](benchmark/run.mjs), [`benchmark/ab-comparison.mjs`](benchmark/ab-comparison.mjs), and [`benchmark/v3316-benchmark.mjs`](benchmark/v3316-benchmark.mjs). Run them yourself: `node benchmark/run.mjs && node benchmark/ab-comparison.mjs`.
198
804
 
199
805
  ---
200
806
 
807
+ ## Docs
808
+
809
+ | Document | Description |
810
+ |----------|-------------|
811
+ | **[→ Command Reference](docs/commands.md)** | **Full guide to `/arstatus`, `/arstart`, `/arsave`, `/arsaveall` — example outputs, modes, palace rules, troubleshooting** |
812
+ | [Intelligent Distance Protocol](docs/intelligent-distance-protocol.md) | The foundational theory — why the gap between human and AI is structural, and how to navigate it |
813
+ | [Scoring Design Rationale](docs/SCORING.md) | Why the scoring system works this way — RRF, Ebbinghaus, Beta distribution, and the bugs they fix |
814
+ | [MCP Adapter Spec](docs/mcp-adapter-spec.md) | Technical spec for building adapters on top of AgentRecall |
815
+ | [SDK Design](docs/sdk-design.md) | Design doc for the SDK architecture |
816
+ | [Upgrade v3.4](UPGRADE-v3.4.md) | Changelog: semantic recall, pgvector backend, 10 MCP tools, bootstrap, palace decisions room |
817
+ | [MCP Server README](packages/mcp-server/README.md) | Focused guide for Claude Code / Cursor / Windsurf users |
818
+ | [Core SDK README](packages/core/README.md) | SDK API reference for building with AgentRecall programmatically |
819
+
201
820
  ---
202
821
 
203
- # AgentRecall MCP(中文文档)
822
+ ## Contributing
823
+
824
+ Built by [tongwu](https://github.com/Goldentrii) at [Novada](https://www.novada.com).
825
+
826
+ - Issues & feedback: [GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
827
+ - Email: [tong.wu@novada.com](mailto:tong.wu@novada.com)
828
+ - Website: [novada.com](https://www.novada.com)
829
+
830
+ MIT License.
831
+
832
+ ---
204
833
 
205
- > **你的智能体记不清楚?AgentRecall 让它学会理解你的思维方式。**
834
+ ---
835
+
836
+ # AgentRecall(中文文档)
837
+
838
+ > **你的智能体记不清楚?听不懂你说话?每次项目都做得非常乱?**
206
839
  >
207
- > 持久复合记忆 + 自动纠正捕获。适用于 Claude Code、Cursor、Windsurf、Codex 等 MCP 兼容智能体。
840
+ > **AgentRecall 让它学会理解你的思维方式。**
841
+ >
842
+ > 赋能agent长期记忆,并从错误中学习和纠正,随时间和项目难度进化,越来越擅长和了解用户和agent的思维。
843
+ >
844
+ > 持久复合记忆 + 智能距离协议。MCP 服务器 + SDK + CLI。
845
+
846
+ ---
847
+
848
+ <p align="center">
849
+ <a href="#arstatus-arsave-arstart-和-arsaveall"><img src="https://img.shields.io/badge/%2Farstatus-从这里开始-22C55E?style=for-the-badge" alt="/arstatus"></a>
850
+ <a href="#arstatus-arsave-arstart-和-arsaveall"><img src="https://img.shields.io/badge/%2Farstart-加载上下文-4ECDC4?style=for-the-badge" alt="/arstart"></a>
851
+ <a href="#arstatus-arsave-arstart-和-arsaveall"><img src="https://img.shields.io/badge/%2Farsave-保存会话-FF6B6B?style=for-the-badge" alt="/arsave"></a>
852
+ <a href="#arstatus-arsave-arstart-和-arsaveall"><img src="https://img.shields.io/badge/%2Farsaveall-批量保存-FFD93D?style=for-the-badge" alt="/arsaveall"></a>
853
+ </p>
854
+ <p align="center">
855
+ <img src="https://img.shields.io/badge/自动-hook--start-8B5CF6?style=for-the-badge" alt="hook-start">
856
+ <img src="https://img.shields.io/badge/自动-hook--correction-F97316?style=for-the-badge" alt="hook-correction">
857
+ <img src="https://img.shields.io/badge/自动-hook--end-06B6D4?style=for-the-badge" alt="hook-end">
858
+ </p>
859
+
860
+ ## `/arstatus`、`/arsave`、`/arstart` 和 `/arsaveall`
861
+
862
+ > [!IMPORTANT]
863
+ > **每次新会话都先运行 `/arstatus`。** 它会显示你所有项目的状态、待完成的工作、阻塞项,让你用数字选择下一步——无需记住项目名称。没有它,全新的 agent 根本不知道从哪里开始。
864
+
865
+ | 命令 | 时机 | 功能 |
866
+ |------|------|------|
867
+ | ⭐ **`/arstatus`** | **每次会话——先运行这个** | **跨所有项目的状态看板:待办事项、阻塞项、编号选择列表。真正的冷启动。** |
868
+ | **`/arstart`** | 选好项目后 | 加载单个项目的深度上下文:宫殿房间、纠正记录、任务相关召回 |
869
+ | **`/arsave`** | 会话结束时 | 写入日志 + 整合到记忆宫殿 + 更新感知 |
870
+ | **`/arsaveall`** | 一天结束时(多会话) | **一次性批量保存所有并行会话** — 扫描、合并、去重、完成 |
871
+
872
+ **会话流程:** `/arstatus` → 输入编号 → `/arstart <项目>` → 工作 → `/arsave`。
873
+
874
+ ### 你会看到什么
875
+
876
+ 输入 `/arstatus` → 一眼看清所有项目进展:
877
+
878
+ ```
879
+ ──────────────────────────────────────────────────────────────
880
+ AgentRecall 状态看板 2026-04-21 5 个项目
881
+ ──────────────────────────────────────────────────────────────
882
+
883
+ 1 ⚠ novada-site 2026-04-21 阻塞
884
+ 阻塞:缺少 .env.local — Phase 1 无法继续
885
+
886
+ 2 ● novada-mcp 2026-04-21
887
+ 下一步:修复 novada_search POST /request → 发布 v0.8.0
888
+
889
+ 3 ● prismma-scraper 2026-04-17
890
+ 下一步:UI 升级 Option A — 浅色模式 + 3D 视觉
891
+
892
+ 4 ✓ AgentRecall 2026-04-21 已完成
893
+ 收集真实生产数据中
894
+
895
+ ──────────────────────────────────────────────────────────────
896
+ 输入编号,或:
897
+ N 新项目(带记忆——agent 了解你的完整历史)
898
+ X 新项目(空白状态——无历史上下文,纯客观模式)
899
+ ──────────────────────────────────────────────────────────────
900
+ ```
901
+
902
+ ### 效果对比
903
+
904
+ | 没有 AgentRecall | 有 AgentRecall |
905
+ |-----------------|---------------|
906
+ | 智能体忘记昨天的决策 | 决策存在宫殿房间,冷启动时加载 |
907
+ | 跨会话重复同样的错误 | `recall_insight` 工作前自动呈现过去教训 |
908
+ | 每次开始需要 5 分钟恢复上下文 | 2 秒冷启动,从宫殿加载(~200 token) |
909
+ | 平面记忆文件无限增长 | 200 行感知上限,强制合并或替换 |
910
+ | 知识锁在单个项目 | 跨项目洞察按关键词匹配 |
911
+
912
+ ```bash
913
+ # 安装命令(一次性,仅 Claude Code)
914
+ mkdir -p ~/.claude/commands
915
+ curl -o ~/.claude/commands/arstatus.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstatus.md
916
+ curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstart.md
917
+ curl -o ~/.claude/commands/arsave.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsave.md
918
+ curl -o ~/.claude/commands/arsaveall.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsaveall.md
919
+ ```
208
920
 
209
921
  ---
210
922
 
@@ -216,73 +928,217 @@ claude mcp add --scope user agent-recall -- npx -y agent-recall-mcp
216
928
 
217
929
  # Cursor — .cursor/mcp.json
218
930
  { "mcpServers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
931
+
932
+ # VS Code — .vscode/mcp.json
933
+ { "servers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
934
+
935
+ # Codex
936
+ codex mcp add agent-recall -- npx -y agent-recall-mcp
219
937
  ```
220
938
 
221
- **安装斜杠命令(Claude Code):**
939
+ **Claude Code 技能安装:**
222
940
  ```bash
223
- mkdir -p ~/.claude/commands
224
- curl -o ~/.claude/commands/arsave.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsave.md
225
- curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstart.md
226
- curl -o ~/.claude/commands/arsaveall.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsaveall.md
941
+ mkdir -p ~/.claude/skills/agent-recall
942
+ curl -o ~/.claude/skills/agent-recall/SKILL.md \
943
+ https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/SKILL.md
227
944
  ```
228
945
 
229
946
  ---
230
947
 
231
- ## 三个命令
948
+ ## 语义召回 — pgvector (v3.4.0)
232
949
 
233
- | 命令 | 时机 | 功能 |
234
- |------|------|------|
235
- | **`/arsave`** | 会话结束时 | 写入日志 + 整合到记忆宫殿 + 更新感知 |
236
- | **`/arstart`** | 会话开始时 | 召回跨项目洞察 + 遍历宫殿 + 加载上下文 |
237
- | **`/arsaveall`** | 一天结束时(多会话) | 一次性批量保存所有并行会话 |
950
+ > [!NOTE]
951
+ > **v3.4.0 新功能。** 默认关键词召回无需任何配置。当关键词搜索遇到天花板时——同义词、改写查询、多语言——升级到 Supabase pgvector 后端。
238
952
 
239
- ---
953
+ 关键词搜索匹配词汇,语义搜索匹配**含义**。升级后:`recall("会话过期")` 也能找到"token 刷新"和"认证超时"相关的条目,无需手动添加同义词。
240
954
 
241
- ## 自动 Hooks
955
+ ```bash
956
+ # 第 1 步 — 交互式配置向导
957
+ ar setup supabase
958
+
959
+ # 第 2 步 — 将 pgvector 迁移应用到你的 Supabase 项目
960
+ ar setup supabase --migrate
242
961
 
243
- 配置一次,永久自动保存。四个 hook 完全覆盖会话生命周期:
962
+ # 3 步 — 完成。运行 /arstart — 下次会话自动回填。
963
+ ```
244
964
 
245
- | Hook | 触发时机 | 功能 |
246
- |------|---------|------|
247
- | `hook-start` | 会话开始 | 打印身份 + 洞察 + `watch_for` 警告 |
248
- | `hook-correction` | 每条用户消息 | 静默捕获纠正信号,无需 agent 手动调用 |
249
- | `hook-ambient` | 每条用户消息 | 提取关键词 → 自动召回 → 注入上下文 |
250
- | `hook-end` | 会话关闭 | 追加轻量级结束日志 |
965
+ 本地文件仍为数据源。Supabase 是派生的读取索引 随时可删除并用 `ar setup supabase --backfill` 重建。
966
+
967
+ **所需环境变量:** `SUPABASE_URL` + `SUPABASE_SERVICE_ROLE_KEY` + `OPENAI_API_KEY`(或 `VOYAGE_API_KEY`)。全部可选 不配置时 AgentRecall 完全正常运行。
968
+
969
+ **优雅降级:** Supabase 不可达时,`recall()` 静默回退到本地关键词搜索,零行为变化。
251
970
 
252
971
  ---
253
972
 
254
- ## 6 个 MCP 工具
973
+ ## 10 个 MCP 工具
974
+
975
+ AgentRecall 目前向 agent 提供 10 个工具。每个工具内部组合多个子系统——agent 不需要了解内部管道。
255
976
 
256
977
  | 工具 | 功能 |
257
978
  |------|------|
258
- | `session_start` | 加载项目上下文,返回身份、洞察、活跃房间、跨项目匹配、`watch_for` 警告 |
259
- | `remember` | 保存记忆,自动分类路由到正确存储 |
260
- | `recall` | RRF 融合搜索所有存储,结果可反馈调权 |
261
- | `session_end` | 一次调用保存所有:日志 + 感知 + 宫殿整合 |
262
- | `check` | 记录 agent 对用户意图的理解,返回历史纠正的 `watch_for` 模式 |
263
- | `digest` | 上下文缓存——存储预计算分析结果,避免重复推理。**重复分析节省 83% token** |
979
+ | `session_start` | 加载项目上下文。返回身份、洞察、活跃房间、跨项目匹配、watch_for 预警。约 400 token。 |
980
+ | `remember` | 保存记忆。自动分类并路由到正确的存储(日志、宫殿、知识库或感知系统)。 |
981
+ | `recall` | 通过 **RRF** 一次搜索所有记忆。支持 `feedback` 评价:正面提升排名,负面降低。查询感知。 |
982
+ | `session_end` | 一次调用保存全部:写日志、更新感知、整合宫殿、归档被替换洞察。 |
983
+ | `check` | 记录对人类意图的理解。返回 `watch_for` 预警。3+ 次强模式自动提升为感知洞察。 |
984
+ | `digest` | **上下文缓存**。存储耗时分析结果(代码库探索、API 审计)。实测节省 83% token |
985
+ | `project_board` | 跨所有项目的状态看板,等同于 `/arstatus`。返回编号项目列表、待办、阻塞项。 |
986
+ | `project_status` | 单个项目的深度状态:下一步行动、阻塞项、最近日志摘要、宫殿健康度。 |
987
+ | `bootstrap_scan` | 扫描机器上的现有项目(git 仓库、Claude AutoMemory、CLAUDE.md)。只读,不写入。 |
988
+ | `bootstrap_import` | 将 `bootstrap_scan` 发现的项目导入 AgentRecall。安全:不修改源文件。 |
264
989
 
265
990
  ---
266
991
 
267
- ## 基准测试(诚实说明)
992
+ ## 记忆如何复合增长
993
+
994
+ 不是所有记忆都平等。五个子系统相互喂养,自动命名让索引有意义,索引让关联性成为可能,关联性让检索精准,精准检索产生有意义的反馈,反馈让下一次检索更好。
995
+
996
+ **显著性评分:** `时效性(0.30) + 访问频率(0.25) + 连接数(0.20) + 紧迫性(0.15) + 重要性(0.10)`
268
997
 
269
- > 以下数据为建模估算,并非长期生产数据。简单任务中 AR 是纯开销;3+ 会话后开始回本,随后持续节省。
998
+ **Ebbinghaus 衰减 `R(t) = e^(−t/S)`:**
270
999
 
271
- | 场景 | AR | AR | 节省 |
272
- |------|:-----:|:-----:|:----:|
273
- | A:简单(2 次会话,0 次纠正) | 567 | 1,131 | **+99% 开销** |
274
- | B:中等(5 次会话,1 次纠正) | 6,220 | 4,382 | **-30%** |
275
- | C:复杂(20 次会话,5 次纠正) | 40,910 | 17,520 | **-57%** |
276
- | D:多 agent(3 agent × 5 次) | 20,781 | 13,140 | **-37%** |
277
- | E:Digest 缓存(重复分析) | ~2,400 | ~400 | **-83%** |
1000
+ | 记忆类型 | S(天) | 1天后 | 1周后 |
1001
+ |----------|---------|-------|-------|
1002
+ | 日志(情景) | 2 | 60% | ~7% |
1003
+ | 知识/Bug修复(程序) | 180 | 99% | 96% |
1004
+ | 宫殿/架构决策(语义) | 9999 | ≈100% | ≈100% |
278
1005
 
279
- **盈亏平衡点:约 3-4 次会话。**
1006
+ 旧日志噪音数天内消退,架构决策永久保留。
1007
+
1008
+ **复合效应:**
1009
+ ```
1010
+ 会话 1: 保存 3 条记忆(自动命名、索引、创建边)
1011
+ 会话 10: watch_for 在错误重复之前警告 agent
1012
+ 会话 20: 感知包含 10 条交叉验证的洞察(从 40+ 条原始观察合并)
1013
+ 会话 50: Agent 了解你的优先级、盲点和沟通风格
1014
+ ```
1015
+
1016
+ ---
1017
+
1018
+ ## SDK API
1019
+
1020
+ ```typescript
1021
+ import { AgentRecall } from "agent-recall-sdk";
1022
+ const ar = new AgentRecall({ project: "my-project" });
1023
+ ```
1024
+
1025
+ | 方法 | 说明 |
1026
+ |------|------|
1027
+ | `capture(question, answer, opts?)` | 快速问答捕获(L1 记忆) |
1028
+ | `journalWrite(content, opts?)` | 写入每日日志 |
1029
+ | `coldStart()` | 宫殿优先上下文加载(~200 token) |
1030
+ | `palaceWrite(room, content, opts?)` | 写入房间,自动扇出交叉引用 |
1031
+ | `palaceRead(room?, topic?)` | 读取房间内容 |
1032
+ | `walk(depth?, focus?)` | 渐进式宫殿漫步 |
1033
+ | `awarenessUpdate(insights, opts?)` | 复合新洞察到感知系统 |
1034
+ | `recallInsight(context, opts?)` | 跨项目洞察召回 |
1035
+ | `alignmentCheck(input)` | 记录置信度和假设 |
1036
+ | `synthesize(opts?)` | L3 合成,可选宫殿整合 |
1037
+
1038
+ ---
1039
+
1040
+ ## CLI 命令
1041
+
1042
+ ```bash
1043
+ # 日志
1044
+ ar capture <question> <answer> [--tags tag1,tag2]
1045
+ ar read [--date YYYY-MM-DD]
1046
+ ar search <query> [--include-palace]
1047
+ ar rollup [--min-age-days N] [--dry-run]
1048
+
1049
+ # 宫殿
1050
+ ar palace write <room> <content> [--importance high|medium|low]
1051
+ ar palace walk [--depth identity|active|relevant|full]
1052
+ ar palace search <query>
1053
+
1054
+ # 感知与洞察
1055
+ ar awareness update --insight "标题" --evidence "证据" --applies-when kw1,kw2
1056
+ ar insight <context> [--limit N]
1057
+
1058
+ # 语义召回配置
1059
+ ar setup supabase [--migrate] [--backfill]
1060
+
1061
+ # 全局选项
1062
+ --root <path> 存储根目录(默认:~/.agent-recall)
1063
+ --project <slug> 项目覆盖
1064
+ ```
280
1065
 
281
1066
  ---
282
1067
 
283
- ## 相关链接
1068
+ ## 架构
1069
+
1070
+ ### 五层记忆模型
1071
+
1072
+ ```
1073
+ L1: 工作记忆 journal_capture 「发生了什么」
1074
+ L2: 情景记忆 journal_write 「这意味着什么」
1075
+ L3: 记忆宫殿 palace_write / walk 「跨会话的知识」
1076
+ L4: 感知系统 awareness_update 「复合的洞察」
1077
+ L5: 洞察索引 recall_insight 「跨项目的经验」
1078
+ ```
1079
+
1080
+ **扇出写入** — 写入一个房间,相关房间通过 `[[wikilinks]]` 自动更新交叉引用。零 LLM 成本。
1081
+
1082
+ **Obsidian 兼容** — YAML frontmatter + `[[wikilinks]]`。将 `palace/` 作为 Obsidian vault 打开即可。
1083
+
1084
+ ---
1085
+
1086
+ ## 平台兼容性
1087
+
1088
+ | 平台 | MCP | SDK | CLI | 说明 |
1089
+ |------|:---:|:---:|:---:|------|
1090
+ | Claude Code | ✅ | ✅ | ✅ | 完整支持 — MCP + 技能 + 命令 |
1091
+ | Cursor | ✅ | ✅ | ✅ | MCP via .cursor/mcp.json |
1092
+ | VS Code (Copilot) | ✅ | ✅ | ✅ | MCP via .vscode/mcp.json |
1093
+ | Windsurf | ✅ | ✅ | ✅ | MCP via mcp_config.json |
1094
+ | OpenAI Codex | ✅ | ✅ | ✅ | `codex mcp add` |
1095
+ | LangChain / CrewAI | — | ✅ | — | SDK 集成到你的 chain 中 |
1096
+ | Vercel AI SDK | — | ✅ | — | SDK 在 server actions 中使用 |
1097
+ | CI / GitHub Actions | — | — | ✅ | `npx agent-recall-cli` |
1098
+ | 任何 MCP 智能体 | ✅ | — | — | 标准 MCP 协议 |
1099
+
1100
+ ---
1101
+
1102
+ ## 实测 Token 节省
1103
+
1104
+ | 场景 | 无 AR | 有 AR | **节省** |
1105
+ |------|:----:|:----:|:------:|
1106
+ | **A: 简单** (2 会话,0 纠正) | 567 | 1,131 | **+99% 纯开销** |
1107
+ | **B: 中等** (5 会话,1 次纠正) | 6,220 | 4,382 | **-30%** |
1108
+ | **C: 复杂** (20 会话,5 次纠正) | 40,910 | 17,520 | **-57%** |
1109
+ | **D: 多 Agent** (3 个 agent × 5 会话) | 20,781 | 13,140 | **-37%** |
1110
+ | **E: Digest 缓存** (重复分析,1 次命中) | ~2,400 | ~400 | **-83%** |
1111
+
1112
+ > **盈亏平衡:~3-4 个会话。** 简单一次性任务,AR 是纯开销。3+ 会话、有纠正、多 agent 的场景,AR 都能回本。
1113
+
1114
+ ---
1115
+
1116
+ ## 文档
1117
+
1118
+ | 文档 | 说明 |
1119
+ |------|------|
1120
+ | **[→ 命令参考](docs/commands.md)** | **`/arstatus`、`/arstart`、`/arsave`、`/arsaveall` 完整指南** |
1121
+ | [智能距离协议](docs/intelligent-distance-protocol.md) | 基础理论 — 人类与 AI 之间的差距是结构性的,如何减少信息损失 |
1122
+ | [评分设计原理](docs/SCORING.md) | RRF、艾宾浩斯、Beta 分布及其修复的 bug |
1123
+ | [v3.4 升级说明](UPGRADE-v3.4.md) | 语义召回、pgvector、10 工具、bootstrap、decisions 房间 |
1124
+
1125
+ ---
1126
+
1127
+ ## 贡献
1128
+
1129
+ 由 [tongwu](https://github.com/Goldentrii) 在 [Novada](https://www.novada.com) 构建。
1130
+
1131
+ - Issues & 反馈:[GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
1132
+ - 邮箱:[tong.wu@novada.com](mailto:tong.wu@novada.com)
1133
+
1134
+ MIT 许可证。
1135
+
1136
+ ## Star History
284
1137
 
285
- - **完整文档:** [主 README](../../README.md)
286
- - **SDK API:** [agent-recall-core](../core/README.md)
287
- - **GitHub:** [Goldentrii/AgentRecall](https://github.com/Goldentrii/AgentRecall)
288
- - **问题反馈:** [GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
1138
+ <a href="https://www.star-history.com/?repos=Goldentrii%2FAgentRecall&type=date&legend=top-left">
1139
+ <picture>
1140
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=Goldentrii/AgentRecall&type=date&theme=dark&legend=top-left" />
1141
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=Goldentrii/AgentRecall&type=date&legend=top-left" />
1142
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=Goldentrii/AgentRecall&type=date&legend=top-left" />
1143
+ </picture>
1144
+ </a>