agent-recall-core 3.3.18 → 3.3.20
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 +206 -1169
- package/dist/helpers/consistency.d.ts +36 -0
- package/dist/helpers/consistency.d.ts.map +1 -0
- package/dist/helpers/consistency.js +135 -0
- package/dist/helpers/consistency.js.map +1 -0
- package/dist/helpers/journal-files.d.ts.map +1 -1
- package/dist/helpers/journal-files.js +41 -22
- package/dist/helpers/journal-files.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/session.d.ts +27 -10
- package/dist/storage/session.d.ts.map +1 -1
- package/dist/storage/session.js +59 -11
- package/dist/storage/session.js.map +1 -1
- package/dist/tools-logic/journal-write.d.ts +2 -0
- package/dist/tools-logic/journal-write.d.ts.map +1 -1
- package/dist/tools-logic/journal-write.js +4 -3
- package/dist/tools-logic/journal-write.js.map +1 -1
- package/dist/tools-logic/session-end.d.ts +2 -0
- package/dist/tools-logic/session-end.d.ts.map +1 -1
- package/dist/tools-logic/session-end.js +1 -1
- package/dist/tools-logic/session-end.js.map +1 -1
- package/dist/tools-logic/smart-remember.d.ts +2 -0
- package/dist/tools-logic/smart-remember.d.ts.map +1 -1
- package/dist/tools-logic/smart-remember.js +13 -0
- package/dist/tools-logic/smart-remember.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,654 +1,212 @@
|
|
|
1
|
-
<h1 align="center">AgentRecall</h1>
|
|
1
|
+
<h1 align="center">AgentRecall — Core</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">
|
|
5
|
-
<p align="center">Persistent, compounding memory + automatic correction capture. MCP server + SDK + CLI.</p>
|
|
4
|
+
<p align="center">Core engine for AgentRecall. Use this package if you're building with the SDK — calling functions directly from LangChain, CrewAI, Vercel AI SDK, or your own agent framework.</p>
|
|
6
5
|
|
|
7
6
|
<p align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/agent-recall-
|
|
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>
|
|
7
|
+
<a href="https://www.npmjs.com/package/agent-recall-core"><img src="https://img.shields.io/npm/v/agent-recall-core?style=flat-square&label=core&color=5D34F2" alt="core npm"></a>
|
|
11
8
|
<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>
|
|
12
|
-
<img src="https://img.shields.io/badge/MCP-5_tools-orange?style=flat-square" alt="Tools">
|
|
13
9
|
<img src="https://img.shields.io/badge/cloud-zero-blue?style=flat-square" alt="Zero Cloud">
|
|
14
|
-
<img src="https://img.shields.io/badge/Obsidian-compatible-7C3AED?style=flat-square" alt="Obsidian">
|
|
15
|
-
<img src="https://img.shields.io/badge/overhead-~876_tokens%2Fsession-22C55E?style=flat-square" alt="Token overhead">
|
|
16
|
-
<img src="https://img.shields.io/badge/saves_up_to-57%25_tokens-FF6B6B?style=flat-square" alt="Token savings">
|
|
17
|
-
<img src="https://img.shields.io/badge/break--even-3--4_sessions-22C55E?style=flat-square" alt="Break-even">
|
|
18
10
|
<img src="https://img.shields.io/badge/scoring-RRF_(Cormack_2009)-7C3AED?style=flat-square" alt="RRF scoring">
|
|
19
|
-
<img src="https://img.shields.io/badge/decay-
|
|
11
|
+
<img src="https://img.shields.io/badge/decay-Ebbinghaus%2BZipf-3B82F6?style=flat-square" alt="Ebbinghaus+Zipf decay">
|
|
20
12
|
<img src="https://img.shields.io/badge/feedback-Bayesian_Beta-F59E0B?style=flat-square" alt="Beta distribution">
|
|
21
13
|
</p>
|
|
22
14
|
|
|
23
15
|
<p align="center">
|
|
24
|
-
<b>
|
|
25
|
-
<a href="#
|
|
26
|
-
<a href="#
|
|
27
|
-
<a href="#
|
|
28
|
-
<a href="#
|
|
29
|
-
<a href="#5-mcp-tools">Tools</a> ·
|
|
30
|
-
<a href="#how-memory-compounds">Compounding</a> ·
|
|
31
|
-
<a href="#sdk-api">SDK</a> ·
|
|
32
|
-
<a href="#architecture">Architecture</a> ·
|
|
33
|
-
<a href="#docs">Docs</a>
|
|
16
|
+
<a href="#install"><b>Install</b></a> ·
|
|
17
|
+
<a href="#sdk-api-reference"><b>SDK API</b></a> ·
|
|
18
|
+
<a href="#example-session-lifecycle"><b>Example</b></a> ·
|
|
19
|
+
<a href="#scoring-architecture"><b>Scoring</b></a> ·
|
|
20
|
+
<a href="#storage-layout"><b>Storage</b></a>
|
|
34
21
|
|
|
|
35
|
-
<
|
|
36
|
-
<a href="#agentrecall中文文档">简介</a> ·
|
|
37
|
-
<a href="#快速开始">安装</a> ·
|
|
38
|
-
<a href="#5-个-mcp-工具">工具</a> ·
|
|
39
|
-
<a href="#记忆如何复合增长">复合</a> ·
|
|
40
|
-
<a href="#sdk-api-1">SDK</a> ·
|
|
41
|
-
<a href="#架构">架构</a>
|
|
22
|
+
<a href="#agent-recall-core中文文档">中文</a>
|
|
42
23
|
</p>
|
|
43
24
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<p align="center">
|
|
47
|
-
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farsave-Save_Session-FF6B6B?style=for-the-badge" alt="/arsave"></a>
|
|
48
|
-
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farstart-Load_Context-4ECDC4?style=for-the-badge" alt="/arstart"></a>
|
|
49
|
-
</p>
|
|
50
|
-
<p align="center">
|
|
51
|
-
<img src="https://img.shields.io/badge/AUTO-hook--start-8B5CF6?style=for-the-badge" alt="hook-start">
|
|
52
|
-
<img src="https://img.shields.io/badge/AUTO-hook--correction-F97316?style=for-the-badge" alt="hook-correction">
|
|
53
|
-
<img src="https://img.shields.io/badge/AUTO-hook--end-06B6D4?style=for-the-badge" alt="hook-end">
|
|
54
|
-
</p>
|
|
55
|
-
<p align="center">
|
|
56
|
-
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/1-AUTO--NAMING-5D34F2?style=for-the-badge" alt="Auto-Naming"></a>
|
|
57
|
-
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/2-INDEXES-0EA5E9?style=for-the-badge" alt="Indexes"></a>
|
|
58
|
-
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/3-RELATIVITY-10B981?style=for-the-badge" alt="Relativity"></a>
|
|
59
|
-
<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>
|
|
60
|
-
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/5-FEEDBACK_LOOP-EF4444?style=for-the-badge" alt="Feedback Loop"></a>
|
|
61
|
-
</p>
|
|
62
|
-
|
|
63
|
-
## `/arsave` and `/arstart`
|
|
25
|
+
> **Not building an app?** If you want to add memory to Claude Code, Cursor, or any MCP-compatible agent, use [`agent-recall-mcp`](../mcp-server/README.md) instead.
|
|
64
26
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| Command | When | What it does |
|
|
68
|
-
|---------|------|-------------|
|
|
69
|
-
| **`/arsave`** | End of session | Write journal + consolidate to palace + update awareness + optional git push |
|
|
70
|
-
| **`/arstart`** | Start of session | Recall cross-project insights + walk palace + load context |
|
|
27
|
+
---
|
|
71
28
|
|
|
72
|
-
|
|
29
|
+
## Install
|
|
73
30
|
|
|
74
31
|
```bash
|
|
75
|
-
|
|
76
|
-
mkdir -p ~/.claude/commands
|
|
77
|
-
curl -o ~/.claude/commands/arsave.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsave.md
|
|
78
|
-
curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstart.md
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### The Difference
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
WITHOUT AgentRecall WITH AgentRecall
|
|
85
|
-
────────────────── ────────────────
|
|
86
|
-
|
|
87
|
-
Day 1: Build monorepo Day 1: /arstart → /arsave
|
|
88
|
-
Day 2: "What monorepo?" Day 2: /arstart
|
|
89
|
-
→ 20 min re-explaining → 2 sec: loads all decisions
|
|
90
|
-
→ Agent repeats same mistakes → Knows "no version inflation"
|
|
91
|
-
→ Forgets your priorities → Knows "arsave = hero section"
|
|
92
|
-
→ Misses half the tasks → Pushes to both repos
|
|
32
|
+
npm install agent-recall-core
|
|
93
33
|
```
|
|
94
34
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
**Layer 1 (5 seconds):** It makes your AI agent remember what happened last session.
|
|
98
|
-
|
|
99
|
-
**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.
|
|
100
|
-
|
|
101
|
-
**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.
|
|
102
|
-
|
|
103
|
-
### Real Session Flow
|
|
104
|
-
|
|
105
|
-
This is from an actual multi-day project where a human gave scattered, non-linear instructions. The agent used AgentRecall throughout:
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
Session 1 (Tuesday) Session 2 (Wednesday, different agent)
|
|
109
|
-
───────────────── ─────────────────────────────────────
|
|
110
|
-
|
|
111
|
-
/arstart /arstart
|
|
112
|
-
│ │
|
|
113
|
-
├─ session_start() ──→ identity, ├─ session_start() ──→ loads Tuesday's
|
|
114
|
-
│ top insights, active rooms, │ decisions in ~400 tokens,
|
|
115
|
-
│ cross-project matches, │ watch_for: "structurize input"
|
|
116
|
-
│ watch_for warnings │
|
|
117
|
-
│ ├─ recall("SDK CLI monorepo") ──→
|
|
118
|
-
├─ recall("SDK CLI versions") ──→ │ • "no version inflation"
|
|
119
|
-
│ • "structurize scattered input" │ • "arsave/arstart = hero section"
|
|
120
|
-
│ • "search before building" │
|
|
121
|
-
│ • "ask when ambiguous" ├─ Continues exactly where
|
|
122
|
-
│ │ Session 1 left off
|
|
123
|
-
▼ │
|
|
124
|
-
Human: "we need SDK, CLI, ▼
|
|
125
|
-
update README, fix versions" Human: "publish to npm,
|
|
126
|
-
│ update both GitHub repos"
|
|
127
|
-
├─ check(goal="SDK+CLI+README", │
|
|
128
|
-
│ confidence="medium") ├─ No re-explanation needed.
|
|
129
|
-
│ → 4 tasks detected │ Agent already knows the
|
|
130
|
-
│ → present plan → human confirms │ monorepo structure, package
|
|
131
|
-
│ │ names, and version policy.
|
|
132
|
-
├─ Execute in order: │
|
|
133
|
-
│ 1. Core extraction ✓ └─ Done in 2 minutes
|
|
134
|
-
│ 2. Tool logic split ✓ (vs 20 min cold start
|
|
135
|
-
│ 3. MCP wrappers ✓ without AgentRecall)
|
|
136
|
-
│ 4. SDK + CLI ✓
|
|
137
|
-
│
|
|
138
|
-
/arsave
|
|
139
|
-
│
|
|
140
|
-
└─ session_end(summary, insights, trajectory)
|
|
141
|
-
→ journal + awareness + palace — one call
|
|
142
|
-
```
|
|
35
|
+
This package is the shared business logic layer used by `agent-recall-mcp`, `agent-recall-sdk`, and `agent-recall-cli`. Import it directly when you want low-level access to palace operations, scoring, awareness, and corrections.
|
|
143
36
|
|
|
144
37
|
---
|
|
145
38
|
|
|
146
|
-
##
|
|
147
|
-
|
|
148
|
-
**AgentRecall is not a memory tool. It's a learning loop.**
|
|
39
|
+
## SDK API Reference
|
|
149
40
|
|
|
150
|
-
|
|
41
|
+
### Session Lifecycle
|
|
151
42
|
|
|
152
|
-
|
|
43
|
+
| Function | Signature | Description |
|
|
44
|
+
|----------|-----------|-------------|
|
|
45
|
+
| `sessionStart(project, opts?)` | `Promise<SessionStartResult>` | Load project context: identity, insights, active rooms, cross-project matches, `watch_for` warnings |
|
|
46
|
+
| `sessionEnd(summary, insights, trajectory, opts?)` | `Promise<SessionEndResult>` | Save everything: journal + awareness + palace consolidation |
|
|
47
|
+
| `check(goal, confidence, opts?)` | `Promise<CheckResult>` | Record what you think the human wants; get `watch_for` patterns from past corrections |
|
|
153
48
|
|
|
154
|
-
|
|
49
|
+
### Memory Storage
|
|
155
50
|
|
|
156
|
-
|
|
51
|
+
| Function | Signature | Description |
|
|
52
|
+
|----------|-----------|-------------|
|
|
53
|
+
| `smartRemember(content, opts?)` | `Promise<RememberResult>` | Auto-classify and route to the right store (journal / palace / awareness / knowledge) |
|
|
54
|
+
| `smartRecall(query, opts?)` | `Promise<RecallResult>` | RRF-ranked search across all stores; accepts `feedback` to adjust future rankings |
|
|
55
|
+
| `generateTags(content)` | `string[]` | Rule-based multi-label tag generation for new memories |
|
|
157
56
|
|
|
158
|
-
|
|
57
|
+
### Palace Operations
|
|
159
58
|
|
|
160
|
-
|
|
59
|
+
| Function | Signature | Description |
|
|
60
|
+
|----------|-----------|-------------|
|
|
61
|
+
| `createRoom(project, room, opts?)` | `Promise<RoomMeta>` | Create a new palace room |
|
|
62
|
+
| `listRooms(project)` | `Promise<RoomMeta[]>` | List all rooms with salience scores |
|
|
63
|
+
| `fanOut(project, room, content, opts?)` | `Promise<FanOutResult>` | Write to a room; auto-update cross-references in related rooms |
|
|
64
|
+
| `palaceSearch(project, query, opts?)` | `Promise<SearchResult[]>` | Tag-union + keyword search across palace rooms |
|
|
65
|
+
| `ensurePalaceInitialized(project)` | `Promise<void>` | Initialize palace structure if not present |
|
|
66
|
+
| `recordAccess(project, room)` | `Promise<void>` | Update room access time for salience scoring |
|
|
161
67
|
|
|
162
|
-
|
|
68
|
+
### Awareness
|
|
163
69
|
|
|
164
|
-
|
|
70
|
+
| Function | Signature | Description |
|
|
71
|
+
|----------|-----------|-------------|
|
|
72
|
+
| `readAwareness()` | `Promise<string>` | Read the 200-line compounding awareness document |
|
|
73
|
+
| `writeAwareness(content)` | `Promise<void>` | Overwrite awareness document |
|
|
74
|
+
| `addInsight(insight, opts?)` | `Promise<void>` | Add insight; triggers merge-or-replace against existing entries |
|
|
75
|
+
| `detectCompoundInsights(project)` | `Promise<CompoundInsight[]>` | Detect patterns across multiple sessions |
|
|
76
|
+
| `renderAwareness()` | `Promise<string>` | Render structured awareness for context injection |
|
|
165
77
|
|
|
166
|
-
|
|
78
|
+
### Corrections Store
|
|
167
79
|
|
|
168
|
-
|
|
80
|
+
| Function | Signature | Description |
|
|
81
|
+
|----------|-----------|-------------|
|
|
82
|
+
| `writeCorrection(rule, why, howToApply, opts?)` | `Promise<void>` | Write a behavioral correction; P0 (never/always/don't) auto-detected |
|
|
83
|
+
| `readP0Corrections(project, limit?)` | `Promise<Correction[]>` | Read highest-priority corrections (max 5, loaded on every session start) |
|
|
169
84
|
|
|
170
|
-
|
|
85
|
+
### Insights Index
|
|
171
86
|
|
|
172
|
-
|
|
|
173
|
-
|
|
174
|
-
|
|
|
175
|
-
|
|
|
176
|
-
| "No version inflation — this human cares about semver discipline" | `nudge` captured mid-session, recalled immediately |
|
|
87
|
+
| Function | Signature | Description |
|
|
88
|
+
|----------|-----------|-------------|
|
|
89
|
+
| `recallInsights(context, opts?)` | `Promise<IndexedInsight[]>` | Cross-project insight recall; ranked by severity × confirmation count |
|
|
90
|
+
| `addIndexedInsight(insight, opts?)` | `Promise<void>` | Add insight to the global index |
|
|
177
91
|
|
|
178
|
-
|
|
92
|
+
### Scoring Utilities
|
|
179
93
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
```
|
|
185
|
-
/arstart on Project B:
|
|
186
|
-
recall_insight: "Rate limiting prevents runaway costs"
|
|
187
|
-
→ source: Project A, confirmed 3x, severity: critical
|
|
188
|
-
→ applies_when: ["api", "proxy", "rate-limit", "cost"]
|
|
189
|
-
→ The lesson from Project A surfaces automatically in Project B
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
The engineer never mentioned rate limiting. AgentRecall matched the project context against the global insights index and surfaced it proactively.
|
|
193
|
-
|
|
194
|
-
### Use Case 3: The Correction That Sticks
|
|
195
|
-
|
|
196
|
-
Session 1: Agent uses version 4.0.0 for a patch release. Human corrects: "That's version inflation. Use 3.3.4."
|
|
197
|
-
|
|
198
|
-
Session 2 (next day, different agent): Awareness already contains "no version inflation — this human cares about conservative versioning." The new agent gets it right the first time.
|
|
199
|
-
|
|
200
|
-
Without AgentRecall, the same correction would be needed again. And again. And again. With AgentRecall, **every correction happens exactly once.**
|
|
94
|
+
| Function | Signature | Description |
|
|
95
|
+
|----------|-----------|-------------|
|
|
96
|
+
| `computeSalience(room)` | `number` | `recency(0.30) + access(0.25) + connections(0.20) + urgency(0.15) + importance(0.10)` |
|
|
201
97
|
|
|
202
98
|
---
|
|
203
99
|
|
|
204
|
-
##
|
|
205
|
-
|
|
206
|
-
**MCP** — for AI agents (Claude Code, Cursor, Windsurf, VS Code, Codex):
|
|
207
|
-
```bash
|
|
208
|
-
claude mcp add --scope user agent-recall -- npx -y agent-recall-mcp
|
|
209
|
-
```
|
|
100
|
+
## Example: Session Lifecycle
|
|
210
101
|
|
|
211
|
-
**SDK** — for any JS/TS application (LangChain, CrewAI, Vercel AI SDK, custom):
|
|
212
102
|
```typescript
|
|
213
|
-
import {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
103
|
+
import {
|
|
104
|
+
sessionStart,
|
|
105
|
+
smartRemember,
|
|
106
|
+
smartRecall,
|
|
107
|
+
sessionEnd,
|
|
108
|
+
writeCorrection,
|
|
109
|
+
readP0Corrections,
|
|
110
|
+
setRoot,
|
|
111
|
+
} from "agent-recall-core";
|
|
112
|
+
|
|
113
|
+
// Optional: override storage root (default: ~/.agent-recall)
|
|
114
|
+
setRoot("/custom/path");
|
|
115
|
+
|
|
116
|
+
// --- Session Start ---
|
|
117
|
+
const ctx = await sessionStart("my-project");
|
|
118
|
+
console.log(ctx.identity); // Project identity card
|
|
119
|
+
console.log(ctx.insights); // Cross-project insights matched to this project
|
|
120
|
+
console.log(ctx.watch_for); // Past corrections that apply — agent should heed these
|
|
121
|
+
|
|
122
|
+
// Load highest-priority behavioral corrections
|
|
123
|
+
const corrections = await readP0Corrections("my-project");
|
|
124
|
+
// e.g. [{ rule: "no black backgrounds", severity: "P0", ... }]
|
|
125
|
+
|
|
126
|
+
// --- During Work ---
|
|
127
|
+
await smartRemember("We switched from REST to GraphQL for the API layer", {
|
|
128
|
+
project: "my-project",
|
|
129
|
+
importance: "high",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const results = await smartRecall("API design decisions", {
|
|
133
|
+
project: "my-project",
|
|
134
|
+
});
|
|
135
|
+
// results.items: ranked list from journal + palace + knowledge stores
|
|
136
|
+
|
|
137
|
+
// If human corrects the agent:
|
|
138
|
+
await writeCorrection(
|
|
139
|
+
"Always ask before choosing a framework",
|
|
140
|
+
"Human was surprised by the GraphQL choice",
|
|
141
|
+
"When picking a framework, present options and get explicit approval",
|
|
142
|
+
{ project: "my-project" }
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// --- Session End ---
|
|
146
|
+
await sessionEnd(
|
|
147
|
+
"Switched API layer to GraphQL. Documented reasoning in architecture room.",
|
|
148
|
+
["GraphQL reduces over-fetching on dashboard queries"],
|
|
149
|
+
"Next: wire authentication middleware",
|
|
150
|
+
{ project: "my-project" }
|
|
151
|
+
);
|
|
222
152
|
```
|
|
223
153
|
|
|
224
154
|
---
|
|
225
155
|
|
|
226
|
-
##
|
|
227
|
-
|
|
228
|
-
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.
|
|
229
|
-
|
|
230
|
-
**The problem:** AI agents don't truly forget — they lose focus. Priorities blur across sessions. Lessons go dormant. The same misunderstanding happens twice because no one stored the correction. The gap between what you mean and what your agent does stays constant, session after session.
|
|
231
|
-
|
|
232
|
-
**The fix:** AgentRecall stores knowledge in a five-layer memory pyramid — from quick captures to cross-project insights — and forces compression so memory gets more valuable over time. But more importantly, it closes the **Intelligent Distance** gap: every human correction is captured, weighted, and recalled before the agent makes the same mistake again.
|
|
233
|
-
|
|
234
|
-
| Without AgentRecall | With AgentRecall |
|
|
235
|
-
|---------------------|------------------|
|
|
236
|
-
| Agent forgets yesterday's decisions | Decisions live in palace rooms, loaded on cold start |
|
|
237
|
-
| Same mistake repeated across sessions | `recall_insight` surfaces past lessons before work starts |
|
|
238
|
-
| 5 min context recovery on each session start | 2 second cold start from palace (~200 tokens) |
|
|
239
|
-
| Flat memory files that grow forever | 200-line awareness cap forces merge-or-replace |
|
|
240
|
-
| Knowledge trapped in one project | Cross-project insights match by keyword |
|
|
241
|
-
| Agent misunderstands, you correct, it forgets | `alignment_check` records corrections permanently |
|
|
242
|
-
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
## Quick Start
|
|
246
|
-
|
|
247
|
-
### MCP Server (for AI agents)
|
|
248
|
-
|
|
249
|
-
```bash
|
|
250
|
-
# Claude Code
|
|
251
|
-
claude mcp add --scope user agent-recall -- npx -y agent-recall-mcp
|
|
252
|
-
|
|
253
|
-
# Cursor — .cursor/mcp.json
|
|
254
|
-
{ "mcpServers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
255
|
-
|
|
256
|
-
# VS Code — .vscode/mcp.json
|
|
257
|
-
{ "servers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
258
|
-
|
|
259
|
-
# Windsurf — ~/.codeium/windsurf/mcp_config.json
|
|
260
|
-
{ "mcpServers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
261
|
-
|
|
262
|
-
# Codex
|
|
263
|
-
codex mcp add agent-recall -- npx -y agent-recall-mcp
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
**Skill (Claude Code only):**
|
|
267
|
-
```bash
|
|
268
|
-
mkdir -p ~/.claude/skills/agent-recall
|
|
269
|
-
curl -o ~/.claude/skills/agent-recall/SKILL.md \
|
|
270
|
-
https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/SKILL.md
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### SDK (for JS/TS applications)
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
npm install agent-recall-sdk
|
|
277
|
-
```
|
|
156
|
+
## LangChain / CrewAI Integration
|
|
278
157
|
|
|
279
158
|
```typescript
|
|
280
|
-
import {
|
|
281
|
-
|
|
282
|
-
const memory = new AgentRecall({ project: "my-app" });
|
|
283
|
-
|
|
284
|
-
// Capture knowledge
|
|
285
|
-
await memory.capture("What ORM?", "Drizzle — type-safe, lightweight");
|
|
286
|
-
|
|
287
|
-
// Write to memory palace
|
|
288
|
-
await memory.palaceWrite("architecture", "Stack: Next.js 16 + Drizzle + Postgres");
|
|
289
|
-
|
|
290
|
-
// Cold start — load project context in ~200 tokens
|
|
291
|
-
const context = await memory.coldStart();
|
|
292
|
-
|
|
293
|
-
// Recall cross-project insights
|
|
294
|
-
const insights = await memory.recallInsight("rate limiting");
|
|
295
|
-
|
|
296
|
-
// Walk the palace at different depths
|
|
297
|
-
const walk = await memory.walk("active");
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### CLI (for terminal and CI)
|
|
301
|
-
|
|
302
|
-
```bash
|
|
303
|
-
npm install -g agent-recall-cli
|
|
304
|
-
# or use npx: npx agent-recall-cli <command>
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
```bash
|
|
308
|
-
# Capture a Q&A pair
|
|
309
|
-
ar capture "What ORM?" "Drizzle" --project my-app
|
|
310
|
-
|
|
311
|
-
# Read today's journal
|
|
312
|
-
ar read --date latest
|
|
313
|
-
|
|
314
|
-
# Walk the memory palace
|
|
315
|
-
ar palace walk --depth active
|
|
316
|
-
|
|
317
|
-
# Search across all memory
|
|
318
|
-
ar search "rate limiting" --include-palace
|
|
319
|
-
|
|
320
|
-
# Recall cross-project insights
|
|
321
|
-
ar insight "building auth middleware"
|
|
322
|
-
|
|
323
|
-
# Write to a palace room
|
|
324
|
-
ar palace write architecture "Switched from REST to tRPC"
|
|
325
|
-
|
|
326
|
-
# Compact old journals into weekly summaries
|
|
327
|
-
ar rollup --min-age-days 14
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
---
|
|
331
|
-
|
|
332
|
-
## How an Agent Uses AgentRecall
|
|
333
|
-
|
|
334
|
-
### Automatic (Zero Discipline — Hooks)
|
|
335
|
-
|
|
336
|
-
Wire once in `~/.claude/settings.json`. Every session is captured automatically, even without `/arsave`:
|
|
337
|
-
|
|
338
|
-
```json
|
|
339
|
-
{
|
|
340
|
-
"hooks": {
|
|
341
|
-
"SessionStart": [{
|
|
342
|
-
"command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-start 2>/dev/null || true"
|
|
343
|
-
}],
|
|
344
|
-
"UserPromptSubmit": [{
|
|
345
|
-
"command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-correction 2>/dev/null || true"
|
|
346
|
-
}],
|
|
347
|
-
"Stop": [{
|
|
348
|
-
"command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-end 2>/dev/null || true"
|
|
349
|
-
}]
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
- **hook-start** — on every session open: prints identity + top insights + watch_for warnings
|
|
355
|
-
- **hook-correction** — on every prompt: detects corrections (regex) and captures them silently
|
|
356
|
-
- **hook-end** — on every session close: appends a lightweight end-of-session log entry
|
|
357
|
-
|
|
358
|
-
### Session Start (`/arstart`)
|
|
359
|
-
```
|
|
360
|
-
session_start() → identity, insights, active rooms, cross-project matches,
|
|
361
|
-
recent journal briefs, watch_for warnings — all in one call
|
|
362
|
-
recall(query) → surface task-specific past knowledge from all stores
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
### During Work
|
|
366
|
-
```
|
|
367
|
-
remember("We decided to use GraphQL instead of REST") → auto-routes to the right store
|
|
368
|
-
recall("authentication design") → searches all stores, ranked results
|
|
369
|
-
check(goal="build auth", confidence="medium") → verify understanding, get warnings
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
### Session End (`/arsave`)
|
|
373
|
-
```
|
|
374
|
-
session_end(summary="...", insights=[...], trajectory="...") → journal + awareness + consolidation
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
---
|
|
378
|
-
|
|
379
|
-
## 5 MCP Tools
|
|
380
|
-
|
|
381
|
-
AgentRecall exposes exactly 5 tools to agents. Each tool composes multiple subsystems internally — the agent doesn't need to know about the plumbing.
|
|
382
|
-
|
|
383
|
-
| Tool | What it does |
|
|
384
|
-
|------|-------------|
|
|
385
|
-
| `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. |
|
|
386
|
-
| `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. |
|
|
387
|
-
| `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. |
|
|
388
|
-
| `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). |
|
|
389
|
-
| `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. |
|
|
390
|
-
|
|
391
|
-
### Legacy tools
|
|
392
|
-
|
|
393
|
-
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.
|
|
394
|
-
|
|
395
|
-
---
|
|
396
|
-
|
|
397
|
-
## How Memory Compounds
|
|
159
|
+
import { sessionStart, smartRecall, smartRemember, sessionEnd } from "agent-recall-core";
|
|
398
160
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
<a href="#3-relativity"><img src="https://img.shields.io/badge/3-RELATIVITY-10B981?style=for-the-badge" alt="Relativity"></a>
|
|
403
|
-
<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>
|
|
404
|
-
<a href="#5-feedback-loop"><img src="https://img.shields.io/badge/5-FEEDBACK_LOOP-EF4444?style=for-the-badge" alt="Feedback Loop"></a>
|
|
405
|
-
</p>
|
|
406
|
-
|
|
407
|
-
> 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. After 10 sessions, the system knows more than any individual memory contains.
|
|
161
|
+
// Before your agent runs
|
|
162
|
+
const ctx = await sessionStart("langchain-app");
|
|
163
|
+
const insights = await smartRecall("current task", { project: "langchain-app" });
|
|
408
164
|
|
|
409
|
-
|
|
165
|
+
const systemPrompt = `You have persistent memory:\n${ctx.identity}\n\nRelevant:\n${
|
|
166
|
+
insights.items.map((i) => i.content).join("\n")
|
|
167
|
+
}`;
|
|
410
168
|
|
|
411
|
-
|
|
169
|
+
// Run your agent with systemPrompt injected...
|
|
412
170
|
|
|
171
|
+
// After your agent runs
|
|
172
|
+
await smartRemember(agentOutput, { project: "langchain-app" });
|
|
173
|
+
await sessionEnd("Agent completed task.", ["Key decision from this run"], "Next: ...", {
|
|
174
|
+
project: "langchain-app",
|
|
175
|
+
});
|
|
413
176
|
```
|
|
414
|
-
Content: "Fixed a critical bug where the payment processor crashed on refunds"
|
|
415
|
-
→ Type detected: bug-fix
|
|
416
|
-
→ Keywords extracted: payment, processor, crashed, refunds
|
|
417
|
-
→ Slug generated: bug-fix-payment-processor-crashed
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
Good naming IS the first layer of retrieval. A well-named memory is 80% findable without any search algorithm.
|
|
421
|
-
|
|
422
|
-
### 2. Indexes
|
|
423
|
-
|
|
424
|
-
Every memory has an address in three index systems:
|
|
425
|
-
|
|
426
|
-
| Index | What it tracks | Token cost |
|
|
427
|
-
|-------|---------------|------------|
|
|
428
|
-
| **Palace index** | Room catalog + salience scores | ~50 tokens to scan |
|
|
429
|
-
| **Insights index** | Cross-project lessons + keyword matching | ~30 tokens to query |
|
|
430
|
-
| **Awareness** | 200-line compounding document (forced merge) | ~200 tokens, but each line carries cross-validated weight |
|
|
431
|
-
|
|
432
|
-
Indexes are cheap pointers. The agent scans indexes first, then loads full content only when needed.
|
|
433
|
-
|
|
434
|
-
### 3. Relativity
|
|
435
|
-
|
|
436
|
-
Memories that relate to each other are connected automatically — no wikilinks needed.
|
|
437
|
-
|
|
438
|
-
```
|
|
439
|
-
Agent writes: "JWT refresh rotation prevents session fixation"
|
|
440
|
-
→ Keywords: jwt, refresh, rotation, session
|
|
441
|
-
→ Room "architecture" has tags: ["technical"]
|
|
442
|
-
→ Room "knowledge" has a lesson about "session management"
|
|
443
|
-
→ Auto-edge created: architecture ←→ knowledge (weight 0.3)
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
When you `recall("session security")`, the system surfaces keyword-matched memories across connected rooms. Edges are stored in `graph.json` and are available for traversal — relativity turns isolated memories into a knowledge graph.
|
|
447
|
-
|
|
448
|
-
### 4. Weight + Decay
|
|
449
|
-
|
|
450
|
-
Not all memories are equal. Salience scoring ensures the right memory surfaces first:
|
|
451
|
-
|
|
452
|
-
```
|
|
453
|
-
salience = recency(0.30) + access(0.25) + connections(0.20) + urgency(0.15) + importance(0.10)
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
- Architecture decisions decay at 0.98/day (persistent). Blockers decay at 0.90/day (ephemeral).
|
|
457
|
-
- Memories you actually access get stronger. Memories you never revisit fade.
|
|
458
|
-
- Demoted insights don't die — they go to the archive. If a future insight matches, they resurrect.
|
|
459
|
-
|
|
460
|
-
`recall` applies the **Ebbinghaus forgetting curve** `R(t) = e^(−t/S)` with memory-type-specific strength values — matching the psychological reality of each type:
|
|
461
|
-
|
|
462
|
-
| Memory type | S (days) | 1-day retention | 1-week retention |
|
|
463
|
-
|-------------|----------|-----------------|------------------|
|
|
464
|
-
| Journal (episodic) | 2 | 60% | ~7% |
|
|
465
|
-
| Knowledge / bug fix (procedural) | 180 | 99% | 96% |
|
|
466
|
-
| Palace / decisions (semantic) | 9999 | ≈100% | ≈100% |
|
|
467
|
-
|
|
468
|
-
Old journal noise fades in days. Architecture decisions persist indefinitely. Same query, right results.
|
|
469
|
-
|
|
470
|
-
### 5. Feedback Loop
|
|
471
|
-
|
|
472
|
-
The system learns what's useful and what's not, using a **Bayesian Beta distribution** — the mathematically optimal estimate of true usefulness from binary observations (`E[Beta(α,β)] = (pos+1)/(pos+neg+2)`):
|
|
473
|
-
|
|
474
|
-
```
|
|
475
|
-
Session 1: recall("auth design") → returns 5 results
|
|
476
|
-
Agent rates: result #1 useful, result #3 not useful
|
|
477
|
-
→ Stored in feedback-log.json with query context
|
|
478
|
-
|
|
479
|
-
Session 2: recall("auth patterns") → similar query
|
|
480
|
-
→ Result #1: Beta(2,1) → E[U]=0.67 → ×1.33 score multiplier
|
|
481
|
-
→ Result #3: Beta(1,2) → E[U]=0.33 → ×0.67 score multiplier
|
|
482
|
-
→ Rankings shift: useful memories rise, noise sinks
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
No-feedback items stay neutral (multiplier ×1.0). Feedback is query-aware — rating a result "useless" for "auth design" doesn't penalize it for "database schema". The system learns per-context, not globally.
|
|
486
|
-
|
|
487
|
-
### The Compounding Effect
|
|
488
|
-
|
|
489
|
-
```
|
|
490
|
-
Session 1: Save 3 memories (auto-named, indexed, edges created)
|
|
491
|
-
Session 5: Recall surfaces memories from sessions 1-4, feedback refines ranking
|
|
492
|
-
Session 10: watch_for warns agent about past mistakes before they repeat
|
|
493
|
-
Session 20: Awareness contains 10 cross-validated insights (merged from 40+ raw observations)
|
|
494
|
-
Session 50: The agent knows your priorities, blind spots, and communication style
|
|
495
|
-
— not because it was told, but because every correction compounded
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
Each layer multiplies the others. Auto-naming makes indexing useful. Indexing makes relativity possible. Relativity makes recall precise. Precise recall generates meaningful feedback. Feedback makes the next recall even better. The loop compounds.
|
|
499
177
|
|
|
500
178
|
---
|
|
501
179
|
|
|
502
|
-
##
|
|
180
|
+
## Scoring Architecture
|
|
503
181
|
|
|
504
|
-
|
|
182
|
+
AgentRecall uses three scoring algorithms layered together:
|
|
505
183
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const ar = new AgentRecall({ project: "my-project" });
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
### Core Methods
|
|
513
|
-
|
|
514
|
-
| Method | Returns | Description |
|
|
515
|
-
|--------|---------|-------------|
|
|
516
|
-
| `capture(question, answer, opts?)` | `JournalCaptureResult` | Quick Q&A capture (L1 memory) |
|
|
517
|
-
| `journalWrite(content, opts?)` | `JournalWriteResult` | Write daily journal entry |
|
|
518
|
-
| `journalRead(opts?)` | `JournalReadResult` | Read journal by date or "latest" |
|
|
519
|
-
| `journalSearch(query, opts?)` | `JournalSearchResult` | Full-text search across journals |
|
|
520
|
-
| `coldStart()` | `JournalColdStartResult` | Palace-first context loading (~200 tokens) |
|
|
521
|
-
|
|
522
|
-
### Palace Methods
|
|
184
|
+
**1. Reciprocal Rank Fusion (RRF) — Cormack 2009**
|
|
185
|
+
Each memory store (journal, palace, knowledge, awareness) ranks results internally. RRF merges the position lists: `score = Σ 1/(k + rank_i)` where `k=60`. No store dominates by default. Tag-union matches get a +0.3 bonus, capped at 1.0.
|
|
523
186
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
| `palaceWrite(room, content, opts?)` | `PalaceWriteResult` | Write to a room with fan-out cross-refs |
|
|
527
|
-
| `palaceRead(room?, topic?)` | `PalaceReadResult` | Read room content or list all rooms |
|
|
528
|
-
| `walk(depth?, focus?)` | `PalaceWalkResult` | Progressive walk: identity → active → relevant → full |
|
|
529
|
-
| `palaceSearch(query, room?)` | `PalaceSearchResult` | Search rooms by content |
|
|
530
|
-
| `lint(fix?)` | `PalaceLintResult` | Health check and auto-archive |
|
|
187
|
+
**2. Ebbinghaus Forgetting Curve with Zipf Adjustment**
|
|
188
|
+
`R(t) = e^(−t/S)` where S is memory-type-specific:
|
|
531
189
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
|
535
|
-
|
|
536
|
-
|
|
|
537
|
-
| `readAwareness()` | `string` | Read the 200-line awareness document |
|
|
538
|
-
| `recallInsight(context, opts?)` | `RecallInsightResult` | Cross-project insight recall |
|
|
539
|
-
|
|
540
|
-
### Alignment Methods
|
|
541
|
-
|
|
542
|
-
| Method | Returns | Description |
|
|
543
|
-
|--------|---------|-------------|
|
|
544
|
-
| `alignmentCheck(input)` | `AlignmentCheckResult` | Record confidence + assumptions |
|
|
545
|
-
| `nudge(input)` | `NudgeResult` | Detect contradictions with past decisions |
|
|
546
|
-
| `synthesize(opts?)` | `ContextSynthesizeResult` | L3 synthesis, optional palace consolidation |
|
|
547
|
-
|
|
548
|
-
### LangChain / CrewAI Integration Example
|
|
549
|
-
|
|
550
|
-
```typescript
|
|
551
|
-
import { AgentRecall } from "agent-recall-sdk";
|
|
190
|
+
| Memory type | S (days) | 1-day retention |
|
|
191
|
+
|-------------|:--------:|:---------------:|
|
|
192
|
+
| Journal (episodic) | 2 | 60% |
|
|
193
|
+
| Knowledge / bug fix | 180 | 99% |
|
|
194
|
+
| Palace / decisions | 9,999 | ≈100% |
|
|
552
195
|
|
|
553
|
-
|
|
196
|
+
Digest cache half-life is Zipf-adjusted: frequently-accessed digests decay slower.
|
|
554
197
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const insights = await memory.recallInsight("current task description");
|
|
198
|
+
**3. Bayesian Beta Distribution**
|
|
199
|
+
`E[Beta(α,β)] = (pos+1)/(pos+neg+2)` — optimal estimate of true usefulness from binary feedback. Feedback is query-aware; rating a result "useless" for one query doesn't penalize it for different queries.
|
|
558
200
|
|
|
559
|
-
|
|
560
|
-
const systemPrompt = `You have persistent memory:\n${context.summary}\n\nRelevant insights:\n${insights.matches.map(m => m.insight).join("\n")}`;
|
|
561
|
-
|
|
562
|
-
// After agent runs — save what was learned
|
|
563
|
-
await memory.capture("What did the agent decide?", agentOutput);
|
|
564
|
-
await memory.awarenessUpdate([{
|
|
565
|
-
insight: "Rate limiting needs token bucket, not fixed window",
|
|
566
|
-
evidence: "Fixed window caused burst failures in load test",
|
|
567
|
-
applies_when: ["rate-limiting", "api-design", "load-testing"]
|
|
568
|
-
}]);
|
|
569
|
-
```
|
|
201
|
+
Full rationale: [docs/SCORING.md](../../docs/SCORING.md)
|
|
570
202
|
|
|
571
203
|
---
|
|
572
204
|
|
|
573
|
-
##
|
|
574
|
-
|
|
575
|
-
The `agent-recall-cli` package provides the `ar` command for terminal workflows, CI pipelines, and quick access to your agent's memory outside of an editor.
|
|
576
|
-
|
|
577
|
-
```
|
|
578
|
-
ar v3.3.14 — AgentRecall CLI
|
|
579
|
-
|
|
580
|
-
JOURNAL:
|
|
581
|
-
ar read [--date YYYY-MM-DD] [--section <name>]
|
|
582
|
-
ar write <content> [--section <name>]
|
|
583
|
-
ar capture <question> <answer> [--tags tag1,tag2]
|
|
584
|
-
ar list [--limit N]
|
|
585
|
-
ar search <query> [--include-palace]
|
|
586
|
-
ar state read|write [data]
|
|
587
|
-
ar cold-start
|
|
588
|
-
ar archive [--older-than-days N]
|
|
589
|
-
ar rollup [--min-age-days N] [--dry-run]
|
|
590
|
-
|
|
591
|
-
PALACE:
|
|
592
|
-
ar palace read [<room>] [--topic <name>]
|
|
593
|
-
ar palace write <room> <content> [--importance high|medium|low]
|
|
594
|
-
ar palace walk [--depth identity|active|relevant|full]
|
|
595
|
-
ar palace search <query>
|
|
596
|
-
ar palace lint [--fix]
|
|
597
|
-
|
|
598
|
-
AWARENESS:
|
|
599
|
-
ar awareness read
|
|
600
|
-
ar awareness update --insight "title" --evidence "ev" --applies-when kw1,kw2
|
|
601
|
-
|
|
602
|
-
INSIGHT:
|
|
603
|
-
ar insight <context> [--limit N]
|
|
604
|
-
|
|
605
|
-
META:
|
|
606
|
-
ar projects
|
|
607
|
-
ar synthesize [--entries N]
|
|
608
|
-
ar knowledge write --category <cat> --title "t" --what "w" --cause "c" --fix "f"
|
|
609
|
-
ar knowledge read [--category <cat>]
|
|
610
|
-
|
|
611
|
-
HOOKS (auto-wired via settings.json — zero discipline required):
|
|
612
|
-
ar hook-start # SessionStart: prints identity + insights + watch_for
|
|
613
|
-
ar hook-correction # UserPromptSubmit: silently captures corrections from prompt
|
|
614
|
-
ar hook-end # Stop: appends end-of-session log entry
|
|
615
|
-
|
|
616
|
-
GLOBAL FLAGS:
|
|
617
|
-
--root <path> Storage root (default: ~/.agent-recall)
|
|
618
|
-
--project <slug> Project override
|
|
619
|
-
```
|
|
620
|
-
|
|
621
|
-
---
|
|
622
|
-
|
|
623
|
-
## Architecture
|
|
624
|
-
|
|
625
|
-
### Five-Layer Memory Pyramid
|
|
626
|
-
|
|
627
|
-
```
|
|
628
|
-
L1: Working Memory journal_capture "what happened"
|
|
629
|
-
L2: Episodic Memory journal_write "what it means"
|
|
630
|
-
L3: Memory Palace palace_write / walk "knowledge across sessions"
|
|
631
|
-
L4: Awareness awareness_update "compounding insights"
|
|
632
|
-
L5: Insight Index recall_insight "cross-project experience"
|
|
633
|
-
```
|
|
634
|
-
|
|
635
|
-
### Key Mechanisms
|
|
636
|
-
|
|
637
|
-
**Fan-out writes** — Write to one room, cross-references auto-update in related rooms via `[[wikilinks]]`. Mechanical, zero LLM cost.
|
|
638
|
-
|
|
639
|
-
**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.
|
|
640
|
-
|
|
641
|
-
**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.
|
|
642
|
-
|
|
643
|
-
**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.
|
|
644
|
-
|
|
645
|
-
**Obsidian-compatible** — Every palace file has YAML frontmatter + `[[wikilinks]]`. Open `palace/` as an Obsidian vault → graph view shows room connections. Zero Obsidian dependency.
|
|
646
|
-
|
|
647
|
-
### Storage Layout
|
|
205
|
+
## Storage Layout
|
|
648
206
|
|
|
649
207
|
```
|
|
650
208
|
~/.agent-recall/
|
|
651
|
-
awareness.md # 200-line compounding document
|
|
209
|
+
awareness.md # 200-line global compounding document
|
|
652
210
|
awareness-state.json # Structured awareness data
|
|
653
211
|
awareness-archive.json # Demoted insights (preserved, not deleted)
|
|
654
212
|
insights-index.json # Cross-project insight matching
|
|
@@ -656,644 +214,123 @@ L5: Insight Index recall_insight "cross-project experience"
|
|
|
656
214
|
<project>/
|
|
657
215
|
journal/
|
|
658
216
|
YYYY-MM-DD.md # Daily journal
|
|
659
|
-
YYYY-MM-DD-log.md # L1 captures (hook
|
|
660
|
-
|
|
661
|
-
index.jsonl # Fast machine-scannable index of all entries
|
|
217
|
+
YYYY-MM-DD-log.md # L1 captures (hook entries)
|
|
218
|
+
index.jsonl # Fast machine-scannable index
|
|
662
219
|
palace/
|
|
663
220
|
identity.md # ~50 token project identity card
|
|
664
221
|
palace-index.json # Room catalog + salience scores
|
|
665
|
-
graph.json # Cross-reference edges
|
|
666
|
-
feedback-log.json # Per-query feedback scores
|
|
667
|
-
alignment-log.json # Past corrections for watch_for
|
|
222
|
+
graph.json # Cross-reference edges
|
|
223
|
+
feedback-log.json # Per-query feedback scores
|
|
224
|
+
alignment-log.json # Past corrections for watch_for
|
|
225
|
+
corrections.json # P0/P1 behavioral corrections store
|
|
668
226
|
rooms/
|
|
669
|
-
goals/
|
|
670
|
-
architecture/
|
|
671
|
-
blockers/
|
|
672
|
-
alignment/
|
|
673
|
-
knowledge/
|
|
674
|
-
<custom>/
|
|
227
|
+
goals/
|
|
228
|
+
architecture/
|
|
229
|
+
blockers/
|
|
230
|
+
alignment/
|
|
231
|
+
knowledge/
|
|
232
|
+
<custom>/ # Agents create rooms on demand
|
|
675
233
|
```
|
|
676
234
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
## Platform Compatibility
|
|
680
|
-
|
|
681
|
-
| Platform | MCP | SDK | CLI | Notes |
|
|
682
|
-
|----------|:---:|:---:|:---:|-------|
|
|
683
|
-
| Claude Code | ✅ | ✅ | ✅ | Full support — MCP + SKILL.md + commands |
|
|
684
|
-
| Cursor | ✅ | ✅ | ✅ | MCP via .cursor/mcp.json |
|
|
685
|
-
| VS Code (Copilot) | ✅ | ✅ | ✅ | MCP via .vscode/mcp.json |
|
|
686
|
-
| Windsurf | ✅ | ✅ | ✅ | MCP via mcp_config.json |
|
|
687
|
-
| OpenAI Codex | ✅ | ✅ | ✅ | `codex mcp add` — config.toml |
|
|
688
|
-
| Claude Desktop | ✅ | — | — | MCP server |
|
|
689
|
-
| LangChain / LangGraph | — | ✅ | — | `new AgentRecall()` in your chain |
|
|
690
|
-
| CrewAI | — | ✅ | — | SDK in tool definitions |
|
|
691
|
-
| Vercel AI SDK | — | ✅ | — | SDK in server actions |
|
|
692
|
-
| Custom JS/TS agents | — | ✅ | ✅ | SDK + CLI for any agent framework |
|
|
693
|
-
| CI / GitHub Actions | — | — | ✅ | `npx agent-recall-cli` in workflows |
|
|
694
|
-
| Any MCP agent | ✅ | — | — | Standard MCP protocol |
|
|
235
|
+
Everything is markdown + JSON on disk. Obsidian-compatible (YAML frontmatter + `[[wikilinks]]`). Version with git, grep in terminal, browse in Obsidian.
|
|
695
236
|
|
|
696
237
|
---
|
|
697
238
|
|
|
698
|
-
##
|
|
699
|
-
|
|
700
|
-
Validated over 42+ sessions across 5 production projects:
|
|
701
|
-
- Cold-start: **5 min → 2 seconds** (palace-first loading, ~400 tokens)
|
|
702
|
-
- Decision retention: **0% → 100%** across sessions
|
|
703
|
-
- Misunderstanding caught before wrong work: **6+ instances** via `check` before publish/deploy
|
|
704
|
-
- Repeated mistakes prevented: **3 instances** via cross-project insight recall
|
|
239
|
+
## Links
|
|
705
240
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
| `check` (MCP) | watch_for patterns + past deltas | ~80 |
|
|
713
|
-
| **Total session overhead** | | **~896 tokens** |
|
|
714
|
-
|
|
715
|
-
Each prevented correction ≈ **1,500 tokens saved** (re-explanation + wrong work + retry).
|
|
716
|
-
Breakeven: **less than 1 correction prevented per session** covers the overhead.
|
|
717
|
-
At 42 sessions with avg 1.5 corrections prevented: **~94,000 tokens saved** vs ~37,600 overhead.
|
|
718
|
-
|
|
719
|
-
### What the 5 Test Rounds Verified
|
|
720
|
-
|
|
721
|
-
**Round 1 — hook-start:**
|
|
722
|
-
Fires on session open (with per-session lock to avoid double-fire). Output: project identity, past correction warnings (watch_for), top 3 awareness insights, today's journal brief, cross-project hint. All in 9 lines.
|
|
723
|
-
|
|
724
|
-
**Round 2 — capture / palace write / search / walk:**
|
|
725
|
-
- `capture "bug fix"` → routes to journal log with auto-tags
|
|
726
|
-
- `palace write architecture "..."` → writes to room with fan-out
|
|
727
|
-
- `search "journal crash fix"` → keyword match finds the entry from 2 minutes ago
|
|
728
|
-
- `palace walk --depth active` → loads 5 rooms, top 10 insights, architecture decisions in one JSON
|
|
729
|
-
|
|
730
|
-
**Round 3 — hook-correction / hook-end / MCP tools:**
|
|
731
|
-
- `hook-correction` with no-correction prompt → silent exit (correct)
|
|
732
|
-
- `hook-correction` with correction ("no use patch not minor") → silent capture, exit 0
|
|
733
|
-
- `hook-end` → exit 0, auto-log entry
|
|
734
|
-
- MCP `session_start` → 601 tokens, all 7 fields populated
|
|
735
|
-
- MCP `check(goal="publish v3.3.14", confidence="high")` → 80 tokens, 1 watch_for pattern surfaced
|
|
736
|
-
|
|
737
|
-
**Round 4 — cross-source recall competition (v3.3.14):**
|
|
738
|
-
- `recall("edge functions cold start")` → palace + journal + insight all queried; RRF merged by rank position — no source dominated by raw score inflation
|
|
739
|
-
- Old journal entries (>3 days) correctly faded via Ebbinghaus S=2; palace decisions surfaced regardless of age
|
|
740
|
-
|
|
741
|
-
**Round 5 — feedback loop (v3.3.14):**
|
|
742
|
-
- `recall("auth design")` + feedback `{useful: true}` → Beta(2,1) → ×1.33 on next query
|
|
743
|
-
- `recall("auth design")` + feedback `{useful: false}` → Beta(1,2) → ×0.67 penalty
|
|
744
|
-
- Zero-feedback items unchanged (Beta(1,1) → ×1.0 neutral)
|
|
745
|
-
|
|
746
|
-
172 tests (129 core + 4 smoke + 28 SDK + 11 CLI), 0 failures. Build clean.
|
|
241
|
+
- **MCP server:** [agent-recall-mcp](../mcp-server/README.md) — use this for Claude Code / Cursor / Windsurf
|
|
242
|
+
- **CLI:** [agent-recall-cli](../cli/README.md) — `ar` command for terminal and CI
|
|
243
|
+
- **Full documentation:** [Main README](../../README.md)
|
|
244
|
+
- **Scoring rationale:** [docs/SCORING.md](../../docs/SCORING.md)
|
|
245
|
+
- **GitHub:** [Goldentrii/AgentRecall](https://github.com/Goldentrii/AgentRecall)
|
|
246
|
+
- **Issues:** [GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
|
|
747
247
|
|
|
748
248
|
---
|
|
749
249
|
|
|
750
|
-
## Docs
|
|
751
|
-
|
|
752
|
-
| Document | Description |
|
|
753
|
-
|----------|-------------|
|
|
754
|
-
| [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 |
|
|
755
|
-
| [Scoring Design Rationale](docs/SCORING.md) | Why the scoring system works this way — RRF, Ebbinghaus, Beta distribution, and the bugs they fix |
|
|
756
|
-
| [MCP Adapter Spec](docs/mcp-adapter-spec.md) | Technical spec for building adapters on top of AgentRecall |
|
|
757
|
-
| [SDK Design](docs/sdk-design.md) | Design doc for the SDK architecture |
|
|
758
|
-
| [Upgrade v3.4](UPGRADE-v3.4.md) | Changelog: weekly roll-up, palace-first cold start, promotion verification |
|
|
759
|
-
|
|
760
250
|
---
|
|
761
251
|
|
|
762
|
-
|
|
252
|
+
# agent-recall-core(中文文档)
|
|
763
253
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
- Issues & feedback: [GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
|
|
767
|
-
- Email: [tong.wu@novada.com](mailto:tong.wu@novada.com)
|
|
768
|
-
- Website: [novada.com](https://www.novada.com)
|
|
769
|
-
|
|
770
|
-
MIT License.
|
|
771
|
-
|
|
772
|
-
---
|
|
773
|
-
|
|
774
|
-
---
|
|
775
|
-
|
|
776
|
-
# AgentRecall(中文文档)
|
|
777
|
-
|
|
778
|
-
> **你的智能体记不清楚?听不懂你说话?每次项目都做得非常乱?**
|
|
779
|
-
>
|
|
780
|
-
> **AgentRecall 让它学会理解你的思维方式。**
|
|
254
|
+
> **Core 引擎包。** 如果你在用 SDK 直接集成 AgentRecall(LangChain、CrewAI、Vercel AI SDK、自定义 agent),使用这个包。
|
|
781
255
|
>
|
|
782
|
-
>
|
|
783
|
-
>
|
|
784
|
-
> 持久复合记忆 + 智能距离协议。MCP 服务器 + SDK + CLI。
|
|
256
|
+
> 如果你只是想给 Claude Code / Cursor 添加记忆,请用 [`agent-recall-mcp`](../mcp-server/README.md)。
|
|
785
257
|
|
|
786
258
|
---
|
|
787
259
|
|
|
788
|
-
|
|
789
|
-
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farsave-保存会话-FF6B6B?style=for-the-badge" alt="/arsave"></a>
|
|
790
|
-
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farstart-加载上下文-4ECDC4?style=for-the-badge" alt="/arstart"></a>
|
|
791
|
-
</p>
|
|
792
|
-
<p align="center">
|
|
793
|
-
<img src="https://img.shields.io/badge/自动-hook--start-8B5CF6?style=for-the-badge" alt="hook-start">
|
|
794
|
-
<img src="https://img.shields.io/badge/自动-hook--correction-F97316?style=for-the-badge" alt="hook-correction">
|
|
795
|
-
<img src="https://img.shields.io/badge/自动-hook--end-06B6D4?style=for-the-badge" alt="hook-end">
|
|
796
|
-
</p>
|
|
797
|
-
<p align="center">
|
|
798
|
-
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/1-自动命名-5D34F2?style=for-the-badge" alt="自动命名"></a>
|
|
799
|
-
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/2-索引-0EA5E9?style=for-the-badge" alt="索引"></a>
|
|
800
|
-
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/3-关联性-10B981?style=for-the-badge" alt="关联性"></a>
|
|
801
|
-
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/4-权重与衰减-F59E0B?style=for-the-badge" alt="权重与衰减"></a>
|
|
802
|
-
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/5-反馈回路-EF4444?style=for-the-badge" alt="反馈回路"></a>
|
|
803
|
-
</p>
|
|
804
|
-
|
|
805
|
-
## `/arsave` 和 `/arstart`
|
|
806
|
-
|
|
807
|
-
> **两个命令,ezpz。**
|
|
808
|
-
|
|
809
|
-
| 命令 | 时机 | 功能 |
|
|
810
|
-
|------|------|------|
|
|
811
|
-
| **`/arsave`** | 会话结束时 | 写入日志 + 整合到记忆宫殿 + 更新感知 + 可选 git 推送 |
|
|
812
|
-
| **`/arstart`** | 会话开始时 | 召回跨项目洞察 + 遍历宫殿 + 加载上下文 |
|
|
813
|
-
|
|
814
|
-
会话结束时输入 `/arsave`,所有内容自动保存。下次开始时输入 `/arstart`,所有上下文自动恢复。
|
|
260
|
+
## 安装
|
|
815
261
|
|
|
816
262
|
```bash
|
|
817
|
-
|
|
818
|
-
mkdir -p ~/.claude/commands
|
|
819
|
-
curl -o ~/.claude/commands/arsave.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arsave.md
|
|
820
|
-
curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/commands/arstart.md
|
|
821
|
-
```
|
|
822
|
-
|
|
823
|
-
### 效果对比
|
|
824
|
-
|
|
825
|
-
```
|
|
826
|
-
没有 AgentRecall 有 AgentRecall
|
|
827
|
-
────────────── ────────────
|
|
828
|
-
|
|
829
|
-
第 1 天:构建单仓 第 1 天:/arstart → /arsave
|
|
830
|
-
第 2 天:"什么单仓?" 第 2 天:/arstart
|
|
831
|
-
→ 20 分钟重新解释 → 2 秒:加载所有决策
|
|
832
|
-
→ 智能体重复同样的错误 → 知道"不要版本膨胀"
|
|
833
|
-
→ 忘记你的优先级 → 知道"arsave 要放首位"
|
|
834
|
-
→ 遗漏一半的任务 → 自动推送两个仓库
|
|
835
|
-
```
|
|
836
|
-
|
|
837
|
-
### 三层价值
|
|
838
|
-
|
|
839
|
-
**第一层(5 秒):** 让你的 AI agent 记住上次会话发生了什么。
|
|
840
|
-
|
|
841
|
-
**第二层(30 秒):** 每次你纠正 agent——"不,不是那个版本"、"先问我"——这个纠正被永久存储,并在 agent 再犯同样错误之前被召回。10 次会话后,你的 agent 理解你的优先级、你的沟通风格、你的不可妥协项。
|
|
842
|
-
|
|
843
|
-
**第三层(2 分钟):** [智能距离协议](https://github.com/Goldentrii/AgentRecall/wiki/Intelligent-Distance)。人类思维和 AI 行动之间的结构性鸿沟无法消除——但可以在每次会话中更好地穿越。纠正就是训练数据。200 行感知上限强制质量优于数量。跨项目洞察意味着学到一次的经验到处适用。
|
|
844
|
-
|
|
845
|
-
### 真实会话流程
|
|
846
|
-
|
|
847
|
-
以下来自一个真实的多日项目,人类给出了分散、非线性的指令。智能体全程使用 AgentRecall:
|
|
848
|
-
|
|
849
|
-
```
|
|
850
|
-
会话 1(周二) 会话 2(周三,不同的智能体)
|
|
851
|
-
────────── ────────────────────────
|
|
852
|
-
|
|
853
|
-
/arstart /arstart
|
|
854
|
-
│ │
|
|
855
|
-
├─ session_start() ──→ 身份 + 洞察 ├─ session_start() ──→ 加载周二
|
|
856
|
-
│ 活跃房间 + 跨项目匹配 │ 架构决策(约 400 token),
|
|
857
|
-
│ watch_for 警告 │ watch_for: "结构化输入"
|
|
858
|
-
│ │
|
|
859
|
-
├─ recall("SDK CLI 版本") ──→ ├─ recall("SDK CLI 单仓") ──→
|
|
860
|
-
│ • "结构化分散的输入" │ • "不要版本膨胀"
|
|
861
|
-
│ • "先搜索再构建" │ • "arsave 放在最显眼的位置"
|
|
862
|
-
│ • "模糊时询问,明确时执行" │
|
|
863
|
-
│ ├─ 从会话 1 离开的地方
|
|
864
|
-
▼ │ 无缝继续
|
|
865
|
-
人类:"我们需要 SDK、CLI, │
|
|
866
|
-
更新 README,修复版本号" ▼
|
|
867
|
-
│ 人类:"发布到 npm,
|
|
868
|
-
├─ check(goal="SDK+CLI+README", 更新两个 GitHub 仓库"
|
|
869
|
-
│ confidence="medium") │
|
|
870
|
-
│ 检测到 4 个任务项 ├─ 无需重新解释。
|
|
871
|
-
│ → 呈现方案 → 人类确认 │ 智能体已经知道单仓结构、
|
|
872
|
-
│ │ 包名和版本策略。
|
|
873
|
-
├─ 按顺序执行: │
|
|
874
|
-
│ 1. 核心提取 ✓ └─ 2 分钟完成
|
|
875
|
-
│ 2. 工具逻辑拆分 ✓ (没有 AgentRecall
|
|
876
|
-
│ 3. MCP 封装 ✓ 需要 2-8 分钟冷启动)
|
|
877
|
-
│ 4. SDK + CLI ✓
|
|
878
|
-
│
|
|
879
|
-
/arsave
|
|
880
|
-
│
|
|
881
|
-
└─ session_end(summary, insights, trajectory)
|
|
882
|
-
→ 日志 + 感知 + 宫殿 — 一次调用全部完成
|
|
263
|
+
npm install agent-recall-core
|
|
883
264
|
```
|
|
884
265
|
|
|
885
266
|
---
|
|
886
267
|
|
|
887
|
-
##
|
|
888
|
-
|
|
889
|
-
**AgentRecall 不是记忆工具,而是学习循环。**
|
|
890
|
-
|
|
891
|
-
你的智能体在会话之间不是真的遗忘——它们是记不清楚、分不清主次,甚至听不懂你在说什么。AgentRecall 像人类记忆一样运作:把不重要的东西冬眠起来,但随时可以唤醒。更重要的是,它让智能体越用越懂你。
|
|
892
|
-
|
|
893
|
-
记忆是机制,理解才是目标。每次你纠正智能体 —— "不要那个版本"、"把这个部分放在最前面"、"做之前先问我" —— 这个纠正会被存储、加权、并在下次自动召回。10 个会话后,你的智能体不只是记住了你的项目,它理解了你的思维方式:你的优先级、你的沟通风格、你的底线。
|
|
894
|
-
|
|
895
|
-
这就是**智能距离协议** —— 不是消除人类与 AI 之间的差距(这个差距是结构性的),而是每次会话都导航得更好。
|
|
896
|
-
|
|
897
|
-
- **你的智能体学会理解你的思维。** 人类本身就是不一致的 —— 我们会从 A 直接跳到 E,跳过 B、C、D。我们会忘记昨天说的话,会在句子中间改变优先级。AgentRecall 捕获每一次纠正,在下一个错误发生之前浮现。你的意图和智能体行为之间的差距,每次会话都在缩小。
|
|
898
|
-
|
|
899
|
-
- **复合感知,而非无限日志。** 记忆上限 200 行。新洞察要么与已有的合并(增强),要么替换最弱的。100 个会话后,感知文件仍然是 200 行 —— 但每一行都承载着经过交叉验证的确认观察。
|
|
900
|
-
|
|
901
|
-
- **跨项目召回。** 在一个项目中学到的教训适用于所有项目。上个月做了限流器?今天在另一个项目构建时,那个教训会自动浮现。
|
|
902
|
-
|
|
903
|
-
- **近乎通用的兼容性。** MCP 服务器支持所有 MCP 兼容智能体(Claude Code、Cursor、Windsurf、VS Code、Codex)。SDK 支持任何 JS/TS 框架(LangChain、CrewAI、Vercel AI SDK、自定义智能体)。CLI 支持终端和 CI 工作流。一套记忆系统,覆盖所有场景。
|
|
904
|
-
|
|
905
|
-
- **零云端,零遥测,全部本地。** 一切都是磁盘上的 markdown。在 Obsidian 中浏览,在终端中 grep,在 git 中版本管理。无需账户、API 密钥或锁定。
|
|
906
|
-
|
|
907
|
-
### 用例一:跳跃式思维的人类
|
|
908
|
-
|
|
909
|
-
一个真实会话,人类在两天项目中给出了非线性、分散的指令:
|
|
910
|
-
|
|
911
|
-
> 人类:"我们需要 SDK、CLI,还有更新 README,哦对了 npm 版本号也错了,一起修"
|
|
912
|
-
|
|
913
|
-
没有 AgentRecall,智能体猜测优先级,遗漏项目。有 AgentRecall:
|
|
914
|
-
|
|
915
|
-
| 智能体已经知道的 | 怎么知道的 |
|
|
916
|
-
|---|---|
|
|
917
|
-
| "这个人沟通是分散的 —— 先结构化成模块再执行" | 3 个先前会话的 `awareness_update` |
|
|
918
|
-
| "模糊时询问,明确时执行" | 上周 `alignment_check` 存储的纠正 |
|
|
919
|
-
| "不要版本膨胀 —— 这个人很在意语义化版本" | 会话中 `nudge` 捕获,立即召回 |
|
|
268
|
+
## 核心函数速查
|
|
920
269
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
### 用例二:跨项目经验传递
|
|
924
|
-
|
|
925
|
-
一个工程师构建了带限流的代理服务器(项目 A)。三周后,开始构建 API 网关(项目 B)。
|
|
926
|
-
|
|
927
|
-
```
|
|
928
|
-
在项目 B 运行 /arstart:
|
|
929
|
-
recall_insight:"限流防止成本失控"
|
|
930
|
-
→ 来源:项目 A,确认 3 次,严重性:critical
|
|
931
|
-
→ 适用场景:["api", "proxy", "rate-limit", "cost"]
|
|
932
|
-
→ 项目 A 的教训在项目 B 中自动浮现
|
|
933
|
-
```
|
|
934
|
-
|
|
935
|
-
工程师从未提到限流。AgentRecall 自动匹配项目上下文与全局洞察索引。
|
|
936
|
-
|
|
937
|
-
### 用例三:纠正只发生一次
|
|
938
|
-
|
|
939
|
-
会话 1:智能体把补丁版本设为 4.0.0。人类纠正:"这是版本膨胀,用 3.3.4。"
|
|
940
|
-
|
|
941
|
-
会话 2(第二天,不同的智能体):感知系统已包含"不要版本膨胀 —— 这个人在意保守的版本策略"。新智能体第一次就做对了。
|
|
942
|
-
|
|
943
|
-
没有 AgentRecall,同样的纠正需要一次又一次。有 AgentRecall,**每个纠正只发生一次。**
|
|
944
|
-
|
|
945
|
-
---
|
|
946
|
-
|
|
947
|
-
## 三种使用方式
|
|
948
|
-
|
|
949
|
-
**MCP** — 面向 AI 智能体(Claude Code、Cursor、Windsurf、VS Code、Codex):
|
|
950
|
-
```bash
|
|
951
|
-
claude mcp add --scope user agent-recall -- npx -y agent-recall-mcp
|
|
952
|
-
```
|
|
953
|
-
|
|
954
|
-
**SDK** — 面向任何 JS/TS 应用(LangChain、CrewAI、Vercel AI SDK、自定义):
|
|
955
|
-
```typescript
|
|
956
|
-
import { AgentRecall } from "agent-recall-sdk";
|
|
957
|
-
const memory = new AgentRecall({ project: "my-app" });
|
|
958
|
-
await memory.capture("用什么技术栈?", "Next.js + Postgres");
|
|
959
|
-
```
|
|
960
|
-
|
|
961
|
-
**CLI** — 面向终端工作流和 CI:
|
|
962
|
-
```bash
|
|
963
|
-
npx agent-recall-cli capture "用什么技术栈?" "Next.js + Postgres"
|
|
964
|
-
npx agent-recall-cli palace walk --depth active
|
|
965
|
-
```
|
|
966
|
-
|
|
967
|
-
---
|
|
968
|
-
|
|
969
|
-
## AgentRecall 是什么?
|
|
970
|
-
|
|
971
|
-
一个**学习系统**,弥合人类思维方式与 AI 智能体工作方式之间的差距。不是日志,不是数据库——是一个复合循环,每一次纠正、决策和洞察都让下一次会话比上一次更好。
|
|
972
|
-
|
|
973
|
-
**问题:** AI 智能体不是真的遗忘——它们主要是无法抓住人类以为的重点。记不清楚优先级,分不清主次,教训进入休眠状态,同样的误解重复发生因为没人存储那次纠正行为。你的意图、目标和智能体行为之间的差距和割裂导致最终项目效果不佳。
|
|
974
|
-
|
|
975
|
-
**解决方案:** AgentRecall 将知识存储在五层记忆金字塔中——从快速捕获到跨项目洞察——并通过强制压缩让记忆随时间增值。但更重要的是,它缩小了**智能距离**差距:每一次人类的纠正都被捕获、加权、并在智能体犯同样错误之前被召回。
|
|
976
|
-
|
|
977
|
-
| 没有 AgentRecall | 有 AgentRecall |
|
|
978
|
-
|-----------------|---------------|
|
|
979
|
-
| 智能体忘记昨天的决策 | 决策存在宫殿房间,冷启动时加载 |
|
|
980
|
-
| 跨会话重复同样的错误 | `recall_insight` 工作前自动呈现过去教训 |
|
|
981
|
-
| 每次开始需要 5 分钟恢复上下文 | 2 秒冷启动,从宫殿加载(~200 token) |
|
|
982
|
-
| 平面记忆文件无限增长 | 200 行感知上限,强制合并或替换 |
|
|
983
|
-
| 知识锁在单个项目 | 跨项目洞察按关键词匹配 |
|
|
984
|
-
|
|
985
|
-
---
|
|
986
|
-
|
|
987
|
-
## 快速开始
|
|
988
|
-
|
|
989
|
-
### MCP 服务器(面向 AI 智能体)
|
|
990
|
-
|
|
991
|
-
```bash
|
|
992
|
-
# Claude Code
|
|
993
|
-
claude mcp add --scope user agent-recall -- npx -y agent-recall-mcp
|
|
994
|
-
|
|
995
|
-
# Cursor — .cursor/mcp.json
|
|
996
|
-
{ "mcpServers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
997
|
-
|
|
998
|
-
# VS Code — .vscode/mcp.json
|
|
999
|
-
{ "servers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
1000
|
-
|
|
1001
|
-
# Codex — ~/.codex/config.toml
|
|
1002
|
-
codex mcp add agent-recall -- npx -y agent-recall-mcp
|
|
1003
|
-
```
|
|
1004
|
-
|
|
1005
|
-
**Claude Code 技能安装:**
|
|
1006
|
-
```bash
|
|
1007
|
-
mkdir -p ~/.claude/skills/agent-recall
|
|
1008
|
-
curl -o ~/.claude/skills/agent-recall/SKILL.md \
|
|
1009
|
-
https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/SKILL.md
|
|
1010
|
-
```
|
|
1011
|
-
|
|
1012
|
-
### SDK(面向 JS/TS 应用)
|
|
1013
|
-
|
|
1014
|
-
```bash
|
|
1015
|
-
npm install agent-recall-sdk
|
|
1016
|
-
```
|
|
270
|
+
### 会话生命周期
|
|
1017
271
|
|
|
1018
|
-
|
|
1019
|
-
import { AgentRecall } from "agent-recall-sdk";
|
|
1020
|
-
|
|
1021
|
-
const memory = new AgentRecall({ project: "my-app" });
|
|
1022
|
-
await memory.capture("用什么 ORM?", "Drizzle — 类型安全、轻量");
|
|
1023
|
-
await memory.palaceWrite("architecture", "技术栈:Next.js 16 + Drizzle + Postgres");
|
|
1024
|
-
const context = await memory.coldStart();
|
|
1025
|
-
```
|
|
1026
|
-
|
|
1027
|
-
### CLI(面向终端和 CI)
|
|
1028
|
-
|
|
1029
|
-
```bash
|
|
1030
|
-
npm install -g agent-recall-cli
|
|
1031
|
-
|
|
1032
|
-
ar capture "用什么 ORM?" "Drizzle" --project my-app
|
|
1033
|
-
ar palace walk --depth active
|
|
1034
|
-
ar insight "构建认证中间件"
|
|
1035
|
-
```
|
|
1036
|
-
|
|
1037
|
-
---
|
|
1038
|
-
|
|
1039
|
-
## 智能体使用流程
|
|
1040
|
-
|
|
1041
|
-
### 会话开始 (`/arstart`)
|
|
1042
|
-
```
|
|
1043
|
-
session_start() → 身份、洞察、活跃房间、跨项目匹配、最近活动、watch_for 预警 — 一次调用
|
|
1044
|
-
```
|
|
1045
|
-
|
|
1046
|
-
### 工作中
|
|
1047
|
-
```
|
|
1048
|
-
remember("我们决定用 GraphQL 替代 REST") → 自动分类并路由到正确的存储
|
|
1049
|
-
recall("认证设计") → 搜索所有存储,排名结果
|
|
1050
|
-
check(goal="构建认证", confidence="medium") → 验证理解,获取预警
|
|
1051
|
-
```
|
|
1052
|
-
|
|
1053
|
-
### 会话结束 (`/arsave`)
|
|
1054
|
-
```
|
|
1055
|
-
session_end(summary="...", insights=[...], trajectory="...") → 日志 + 感知 + 整合
|
|
1056
|
-
```
|
|
1057
|
-
|
|
1058
|
-
---
|
|
1059
|
-
|
|
1060
|
-
## 5 个 MCP 工具
|
|
1061
|
-
|
|
1062
|
-
AgentRecall 目前只向 agent 提供 5 个工具。每个工具内部组合多个子系统 — agent 不需要了解内部管道。
|
|
1063
|
-
|
|
1064
|
-
| 工具 | 功能 |
|
|
272
|
+
| 函数 | 说明 |
|
|
1065
273
|
|------|------|
|
|
1066
|
-
| `
|
|
1067
|
-
| `
|
|
1068
|
-
| `
|
|
1069
|
-
| `session_end` | 一次调用保存全部。写入日志、更新感知、整合到宫殿、归档被替换的洞察(不删除 — 支持复活)。 |
|
|
1070
|
-
| `check` | 记录你对人类意图的理解。返回历史纠正模式的 `watch_for` 预警。支持记录 `human_correction` 和 `delta`。3+ 次的强模式自动提升为感知洞察。 |
|
|
1071
|
-
|
|
1072
|
-
### 旧版工具
|
|
1073
|
-
|
|
1074
|
-
原始 22 个子系统工具(palace_write、journal_capture、awareness_update 等)通过 SDK 和 CLI 仍然可用,适用于向后兼容和高级用例。MCP 服务器默认不注册这些工具。
|
|
1075
|
-
|
|
1076
|
-
---
|
|
1077
|
-
|
|
1078
|
-
## 记忆如何复合增长
|
|
1079
|
-
|
|
1080
|
-
<p align="center">
|
|
1081
|
-
<a href="#1-自动命名"><img src="https://img.shields.io/badge/1-自动命名-5D34F2?style=for-the-badge" alt="自动命名"></a>
|
|
1082
|
-
<a href="#2-索引"><img src="https://img.shields.io/badge/2-索引-0EA5E9?style=for-the-badge" alt="索引"></a>
|
|
1083
|
-
<a href="#3-关联性"><img src="https://img.shields.io/badge/3-关联性-10B981?style=for-the-badge" alt="关联性"></a>
|
|
1084
|
-
<a href="#4-权重与衰减"><img src="https://img.shields.io/badge/4-权重与衰减-F59E0B?style=for-the-badge" alt="权重与衰减"></a>
|
|
1085
|
-
<a href="#5-反馈回路"><img src="https://img.shields.io/badge/5-反馈回路-EF4444?style=for-the-badge" alt="反馈回路"></a>
|
|
1086
|
-
</p>
|
|
1087
|
-
|
|
1088
|
-
> 记忆不是清单,而是一个 1+1+1 > 3 的复合系统。每个子系统喂养下一个 — 命名使检索成为可能,检索使反馈成为可能,反馈使排名成为可能,排名让正确的记忆在正确的时间浮现。10 个会话后,系统知道的比任何单条记忆都多。
|
|
1089
|
-
|
|
1090
|
-
### 1. 自动命名
|
|
1091
|
-
|
|
1092
|
-
Agent 在保存的瞬间对内容理解最深。AgentRecall 把这种理解捕获为语义化的名称 — 不是 `"mcp-verified"` 而是 `"verified-agentrecall-mcp-22tools-functional"`。
|
|
1093
|
-
|
|
1094
|
-
```
|
|
1095
|
-
内容: "修复了支付处理器在退款时崩溃的严重 bug"
|
|
1096
|
-
→ 类型检测: bug-fix
|
|
1097
|
-
→ 关键词提取: payment, processor, crashed, refunds
|
|
1098
|
-
→ 生成名称: bug-fix-payment-processor-crashed
|
|
1099
|
-
```
|
|
1100
|
-
|
|
1101
|
-
好的命名本身就是检索的第一层。一个命名良好的记忆,不需要搜索算法就能被找到 80%。
|
|
1102
|
-
|
|
1103
|
-
### 2. 索引
|
|
1104
|
-
|
|
1105
|
-
每条记忆在三个索引系统中都有地址:
|
|
1106
|
-
|
|
1107
|
-
| 索引 | 追踪什么 | Token 开销 |
|
|
1108
|
-
|------|---------|-----------|
|
|
1109
|
-
| **宫殿索引** | 房间目录 + 显著性评分 | 扫描约 50 token |
|
|
1110
|
-
| **洞察索引** | 跨项目教训 + 关键词匹配 | 查询约 30 token |
|
|
1111
|
-
| **感知文档** | 200 行复合文档(强制合并) | 约 200 token,但每一行都承载交叉验证的权重 |
|
|
1112
|
-
|
|
1113
|
-
索引是轻量指针。Agent 先扫描索引,只在需要时才加载完整内容。
|
|
1114
|
-
|
|
1115
|
-
### 3. 关联性
|
|
1116
|
-
|
|
1117
|
-
相关的记忆会自动连接 — 无需手写 wikilinks。
|
|
274
|
+
| `sessionStart(project, opts?)` | 加载项目上下文:身份、洞察、活跃房间、`watch_for` 警告 |
|
|
275
|
+
| `sessionEnd(summary, insights, trajectory, opts?)` | 一次调用保存所有内容 |
|
|
276
|
+
| `check(goal, confidence, opts?)` | 记录对用户意图的理解,返回历史纠正模式 |
|
|
1118
277
|
|
|
1119
|
-
|
|
1120
|
-
Agent 写入: "JWT 刷新令牌轮换防止会话固定攻击"
|
|
1121
|
-
→ 关键词: jwt, refresh, rotation, session
|
|
1122
|
-
→ "architecture" 房间标签: ["technical"]
|
|
1123
|
-
→ "knowledge" 房间有 "session management" 教训
|
|
1124
|
-
→ 自动创建边: architecture ←→ knowledge (权重 0.3)
|
|
1125
|
-
```
|
|
1126
|
-
|
|
1127
|
-
当你 `recall("会话安全")` 时,系统不只是关键词匹配 — 它沿着边跳 1 步,从关联房间中浮现相关记忆。关联性把孤立的记忆变成知识图谱。
|
|
1128
|
-
|
|
1129
|
-
### 4. 权重与衰减
|
|
1130
|
-
|
|
1131
|
-
不是所有记忆都平等。显著性评分确保最重要的记忆先浮现:
|
|
1132
|
-
|
|
1133
|
-
```
|
|
1134
|
-
显著性 = 时效性(0.30) + 访问频率(0.25) + 连接数(0.20) + 紧迫性(0.15) + 重要性(0.10)
|
|
1135
|
-
```
|
|
1136
|
-
|
|
1137
|
-
- 架构决策以 0.98/天 衰减(持久)。阻塞项以 0.90/天 衰减(短暂)。
|
|
1138
|
-
- 你实际访问的记忆越来越强。从不回顾的记忆逐渐淡化。
|
|
1139
|
-
- 被替换的洞察不会消亡 — 它们进入归档。如果未来的洞察匹配,它们会复活。
|
|
1140
|
-
|
|
1141
|
-
`recall` 基于**艾宾浩斯遗忘曲线**(1885)`R(t) = e^(−t/S)` 对不同记忆类型设定不同衰减强度:
|
|
1142
|
-
|
|
1143
|
-
| 记忆类型 | S(天) | 1天后保留率 | 1周后保留率 |
|
|
1144
|
-
|----------|---------|------------|------------|
|
|
1145
|
-
| 日志(情景记忆) | 2 | 60% | ~7% |
|
|
1146
|
-
| 知识 / Bug 修复(程序记忆) | 180 | 99% | 96% |
|
|
1147
|
-
| 宫殿 / 架构决策(语义记忆) | 9999 | ≈100% | ≈100% |
|
|
1148
|
-
|
|
1149
|
-
旧日志的噪音在数天内消退,架构决策永久保留。相同查询,始终得到正确结果。
|
|
1150
|
-
|
|
1151
|
-
### 5. 反馈回路
|
|
1152
|
-
|
|
1153
|
-
系统通过**贝叶斯 Beta 分布**学习什么有用、什么没用——这是从二元观察中估计"真实有用性"的数学最优解(`E[Beta(α,β)] = (pos+1)/(pos+neg+2)`):
|
|
1154
|
-
|
|
1155
|
-
```
|
|
1156
|
-
会话 1: recall("认证设计") → 返回 5 条结果
|
|
1157
|
-
Agent 评价: 结果 #1 有用, 结果 #3 没用
|
|
1158
|
-
→ 存入 feedback-log.json(带查询上下文)
|
|
1159
|
-
|
|
1160
|
-
会话 2: recall("认证模式") → 类似查询
|
|
1161
|
-
→ 结果 #1: Beta(2,1) → E[U]=0.67 → ×1.33 分数倍增
|
|
1162
|
-
→ 结果 #3: Beta(1,2) → E[U]=0.33 → ×0.67 分数惩罚
|
|
1163
|
-
→ 排名变化: 有用的记忆上升,噪音下沉
|
|
1164
|
-
```
|
|
1165
|
-
|
|
1166
|
-
无反馈的条目保持中性(×1.0)。反馈是查询感知的 — 把一条结果标记为"对认证设计没用"不会惩罚它在"数据库设计"中的表现。系统按上下文学习,而非全局惩罚。
|
|
1167
|
-
|
|
1168
|
-
### 复合效应
|
|
1169
|
-
|
|
1170
|
-
```
|
|
1171
|
-
会话 1: 保存 3 条记忆(自动命名、索引、创建边)
|
|
1172
|
-
会话 5: recall 浮现会话 1-4 的记忆,反馈优化排名
|
|
1173
|
-
会话 10: watch_for 在错误重复之前警告 agent
|
|
1174
|
-
会话 20: 感知包含 10 条交叉验证的洞察(从 40+ 条原始观察合并)
|
|
1175
|
-
会话 50: Agent 了解你的优先级、盲点和沟通风格
|
|
1176
|
-
— 不是因为被告知,而是因为每次纠正都在复合增长
|
|
1177
|
-
```
|
|
1178
|
-
|
|
1179
|
-
每一层放大其他层。自动命名让索引有意义。索引让关联性成为可能。关联性让检索精准。精准检索产生有意义的反馈。反馈让下一次检索更好。循环复合增长。
|
|
278
|
+
### 记忆存储
|
|
1180
279
|
|
|
1181
|
-
|
|
280
|
+
| 函数 | 说明 |
|
|
281
|
+
|------|------|
|
|
282
|
+
| `smartRemember(content, opts?)` | 自动分类,路由到正确存储 |
|
|
283
|
+
| `smartRecall(query, opts?)` | RRF 融合搜索,可反馈调权 |
|
|
284
|
+
| `generateTags(content)` | 规则驱动的多标签生成 |
|
|
1182
285
|
|
|
1183
|
-
|
|
286
|
+
### 纠正存储
|
|
1184
287
|
|
|
1185
|
-
|
|
288
|
+
| 函数 | 说明 |
|
|
289
|
+
|------|------|
|
|
290
|
+
| `writeCorrection(rule, why, how, opts?)` | 写入行为纠正;自动检测 P0 级别(never/always/don't) |
|
|
291
|
+
| `readP0Corrections(project, limit?)` | 读取最高优先级纠正(每次 session_start 自动加载) |
|
|
1186
292
|
|
|
1187
|
-
|
|
1188
|
-
import { AgentRecall } from "agent-recall-sdk";
|
|
1189
|
-
const ar = new AgentRecall({ project: "my-project" });
|
|
1190
|
-
```
|
|
293
|
+
### 感知系统
|
|
1191
294
|
|
|
1192
|
-
|
|
|
295
|
+
| 函数 | 说明 |
|
|
1193
296
|
|------|------|
|
|
1194
|
-
| `
|
|
1195
|
-
| `
|
|
1196
|
-
| `
|
|
1197
|
-
| `palaceWrite(room, content, opts?)` | 写入房间,自动扇出交叉引用 |
|
|
1198
|
-
| `palaceRead(room?, topic?)` | 读取房间内容 |
|
|
1199
|
-
| `walk(depth?, focus?)` | 渐进式宫殿漫步 |
|
|
1200
|
-
| `awarenessUpdate(insights, opts?)` | 复合新洞察到感知系统 |
|
|
1201
|
-
| `recallInsight(context, opts?)` | 跨项目洞察召回 |
|
|
1202
|
-
| `alignmentCheck(input)` | 记录置信度和假设 |
|
|
1203
|
-
| `synthesize(opts?)` | L3 合成,可选宫殿整合 |
|
|
297
|
+
| `readAwareness()` | 读取 200 行复合感知文档 |
|
|
298
|
+
| `addInsight(insight, opts?)` | 添加洞察,触发合并或替换逻辑 |
|
|
299
|
+
| `recallInsights(context, opts?)` | 跨项目洞察召回 |
|
|
1204
300
|
|
|
1205
301
|
---
|
|
1206
302
|
|
|
1207
|
-
##
|
|
1208
|
-
|
|
1209
|
-
`agent-recall-cli` 提供 `ar` 命令,用于终端工作流和 CI 管道。
|
|
303
|
+
## 会话示例
|
|
1210
304
|
|
|
1211
|
-
```
|
|
1212
|
-
|
|
1213
|
-
ar read [--date YYYY-MM-DD] [--section <name>]
|
|
1214
|
-
ar write <content> [--section <name>]
|
|
1215
|
-
ar capture <question> <answer> [--tags tag1,tag2]
|
|
1216
|
-
ar search <query> [--include-palace]
|
|
1217
|
-
ar rollup [--min-age-days N] [--dry-run]
|
|
1218
|
-
|
|
1219
|
-
# 宫殿
|
|
1220
|
-
ar palace read [<room>]
|
|
1221
|
-
ar palace write <room> <content> [--importance high|medium|low]
|
|
1222
|
-
ar palace walk [--depth identity|active|relevant|full]
|
|
1223
|
-
ar palace search <query>
|
|
1224
|
-
|
|
1225
|
-
# 感知与洞察
|
|
1226
|
-
ar awareness read
|
|
1227
|
-
ar awareness update --insight "标题" --evidence "证据" --applies-when kw1,kw2
|
|
1228
|
-
ar insight <context> [--limit N]
|
|
1229
|
-
|
|
1230
|
-
# 全局选项
|
|
1231
|
-
--root <path> 存储根目录(默认:~/.agent-recall)
|
|
1232
|
-
--project <slug> 项目覆盖
|
|
1233
|
-
```
|
|
305
|
+
```typescript
|
|
306
|
+
import { sessionStart, smartRemember, smartRecall, sessionEnd } from "agent-recall-core";
|
|
1234
307
|
|
|
1235
|
-
|
|
308
|
+
const ctx = await sessionStart("my-project");
|
|
309
|
+
// ctx.watch_for — 历史纠正警告
|
|
1236
310
|
|
|
1237
|
-
|
|
311
|
+
await smartRemember("改用 GraphQL 替代 REST", { project: "my-project", importance: "high" });
|
|
1238
312
|
|
|
1239
|
-
|
|
313
|
+
const results = await smartRecall("API 设计决策", { project: "my-project" });
|
|
1240
314
|
|
|
315
|
+
await sessionEnd("完成 API 层切换", ["GraphQL 减少 dashboard 过度请求"], "下一步:认证中间件", {
|
|
316
|
+
project: "my-project",
|
|
317
|
+
});
|
|
1241
318
|
```
|
|
1242
|
-
L1: 工作记忆 journal_capture 「发生了什么」
|
|
1243
|
-
L2: 情景记忆 journal_write 「这意味着什么」
|
|
1244
|
-
L3: 记忆宫殿 palace_write / walk 「跨会话的知识」
|
|
1245
|
-
L4: 感知系统 awareness_update 「复合的洞察」
|
|
1246
|
-
L5: 洞察索引 recall_insight 「跨项目的经验」
|
|
1247
|
-
```
|
|
1248
|
-
|
|
1249
|
-
### 核心机制
|
|
1250
|
-
|
|
1251
|
-
**扇出写入** — 写入一个房间,相关房间通过 `[[wikilinks]]` 自动更新交叉引用。零 LLM 成本。
|
|
1252
|
-
|
|
1253
|
-
**显著性评分** — `时效性(0.30) + 访问频率(0.25) + 连接数(0.20) + 紧迫性(0.15) + 重要性(0.10)`。高显著性房间优先展示,低于阈值自动归档。
|
|
1254
|
-
|
|
1255
|
-
**复合感知** — `awareness.md` 上限 200 行。新洞察与相似的合并(增强),与不相似的竞争(最低确认次数的被替换)。约束创造压缩,压缩创造复合。
|
|
1256
|
-
|
|
1257
|
-
**跨项目洞察召回** — 通过关键词将洞察映射到场景。`recall_insight("构建质量检查")` 返回来自任何项目的相关教训。
|
|
1258
|
-
|
|
1259
|
-
**Obsidian 兼容** — YAML frontmatter + `[[wikilinks]]`。将 `palace/` 作为 Obsidian vault 打开即可。零 Obsidian 依赖。
|
|
1260
319
|
|
|
1261
320
|
---
|
|
1262
321
|
|
|
1263
|
-
##
|
|
322
|
+
## 评分架构(简述)
|
|
1264
323
|
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
| Cursor | ✅ | ✅ | ✅ | MCP via .cursor/mcp.json |
|
|
1269
|
-
| VS Code (Copilot) | ✅ | ✅ | ✅ | MCP via .vscode/mcp.json |
|
|
1270
|
-
| Windsurf | ✅ | ✅ | ✅ | MCP via mcp_config.json |
|
|
1271
|
-
| OpenAI Codex | ✅ | ✅ | ✅ | `codex mcp add` |
|
|
1272
|
-
| LangChain / CrewAI | — | ✅ | — | SDK 集成到你的 chain 中 |
|
|
1273
|
-
| Vercel AI SDK | — | ✅ | — | SDK 在 server actions 中使用 |
|
|
1274
|
-
| CI / GitHub Actions | — | — | ✅ | `npx agent-recall-cli` |
|
|
1275
|
-
| 任何 MCP 智能体 | ✅ | — | — | 标准 MCP 协议 |
|
|
324
|
+
- **RRF(Cormack 2009)** — 各存储内部排名,RRF 融合位置列表,任何存储不独占排名
|
|
325
|
+
- **Ebbinghaus 遗忘曲线 + Zipf 调整** — 日志 2 天衰减,宫殿决策永久保留,高频访问的 digest 衰减更慢
|
|
326
|
+
- **贝叶斯 Beta 分布** — 从用户反馈估计记忆真实有用性,按查询上下文学习,不跨查询污染
|
|
1276
327
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
## 文档
|
|
1280
|
-
|
|
1281
|
-
| 文档 | 说明 |
|
|
1282
|
-
|------|------|
|
|
1283
|
-
| [智能距离协议](docs/intelligent-distance-protocol.md) | 基础理论 — 人类与 AI 之间的差距是结构性的,如何减少两个物种之间的沟通信息损失 |
|
|
1284
|
-
| [评分设计原理](docs/SCORING.md) | 评分系统的工作原理 — RRF、艾宾浩斯、Beta 分布及其修复的 bug |
|
|
1285
|
-
| [MCP 适配器规范](docs/mcp-adapter-spec.md) | 基于 AgentRecall 构建适配器的技术规范 |
|
|
1286
|
-
| [SDK 设计](docs/sdk-design.md) | SDK 架构设计文档 |
|
|
1287
|
-
| [v3.4 升级说明](UPGRADE-v3.4.md) | 周报压缩、宫殿优先冷启动、提升验证 |
|
|
328
|
+
详细说明:[docs/SCORING.md](../../docs/SCORING.md)
|
|
1288
329
|
|
|
1289
330
|
---
|
|
1290
331
|
|
|
1291
|
-
##
|
|
1292
|
-
|
|
1293
|
-
由 [tongwu](https://github.com/Goldentrii) 在 [Novada](https://www.novada.com) 构建。
|
|
1294
|
-
|
|
1295
|
-
- Issues & 反馈:[GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
|
|
1296
|
-
- 邮箱:[tong.wu@novada.com](mailto:tong.wu@novada.com)
|
|
1297
|
-
- 网站:[novada.com](https://www.novada.com)
|
|
332
|
+
## 相关链接
|
|
1298
333
|
|
|
1299
|
-
|
|
334
|
+
- **MCP 服务器:** [agent-recall-mcp](../mcp-server/README.md)
|
|
335
|
+
- **完整文档:** [主 README](../../README.md)
|
|
336
|
+
- **GitHub:** [Goldentrii/AgentRecall](https://github.com/Goldentrii/AgentRecall)
|