agent-recall-mcp 3.3.2 → 3.3.4
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/dist/index.js +6 -13
- package/dist/index.js.map +1 -1
- package/dist/resources/journal-resources.d.ts.map +1 -1
- package/dist/resources/journal-resources.js +5 -29
- package/dist/resources/journal-resources.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/alignment-check.d.ts.map +1 -1
- package/dist/tools/alignment-check.js +3 -54
- package/dist/tools/alignment-check.js.map +1 -1
- package/dist/tools/awareness-update.d.ts +2 -8
- package/dist/tools/awareness-update.d.ts.map +1 -1
- package/dist/tools/awareness-update.js +3 -66
- package/dist/tools/awareness-update.js.map +1 -1
- package/dist/tools/context-synthesize.d.ts.map +1 -1
- package/dist/tools/context-synthesize.js +6 -187
- package/dist/tools/context-synthesize.js.map +1 -1
- package/dist/tools/journal-archive.d.ts.map +1 -1
- package/dist/tools/journal-archive.js +3 -48
- package/dist/tools/journal-archive.js.map +1 -1
- package/dist/tools/journal-capture.d.ts.map +1 -1
- package/dist/tools/journal-capture.js +3 -60
- package/dist/tools/journal-capture.js.map +1 -1
- package/dist/tools/journal-cold-start.d.ts.map +1 -1
- package/dist/tools/journal-cold-start.js +10 -52
- package/dist/tools/journal-cold-start.js.map +1 -1
- package/dist/tools/journal-list.d.ts.map +1 -1
- package/dist/tools/journal-list.js +3 -23
- package/dist/tools/journal-list.js.map +1 -1
- package/dist/tools/journal-projects.d.ts.map +1 -1
- package/dist/tools/journal-projects.js +3 -16
- package/dist/tools/journal-projects.js.map +1 -1
- package/dist/tools/journal-read.d.ts.map +1 -1
- package/dist/tools/journal-read.js +5 -45
- package/dist/tools/journal-read.js.map +1 -1
- package/dist/tools/journal-rollup.d.ts +3 -0
- package/dist/tools/journal-rollup.d.ts.map +1 -0
- package/dist/tools/journal-rollup.js +21 -0
- package/dist/tools/journal-rollup.js.map +1 -0
- package/dist/tools/journal-search.d.ts.map +1 -1
- package/dist/tools/journal-search.js +3 -91
- package/dist/tools/journal-search.js.map +1 -1
- package/dist/tools/journal-state.d.ts +0 -3
- package/dist/tools/journal-state.d.ts.map +1 -1
- package/dist/tools/journal-state.js +5 -93
- package/dist/tools/journal-state.js.map +1 -1
- package/dist/tools/journal-write.d.ts.map +1 -1
- package/dist/tools/journal-write.js +3 -62
- package/dist/tools/journal-write.js.map +1 -1
- package/dist/tools/knowledge-read.d.ts.map +1 -1
- package/dist/tools/knowledge-read.js +3 -100
- package/dist/tools/knowledge-read.js.map +1 -1
- package/dist/tools/knowledge-write.d.ts.map +1 -1
- package/dist/tools/knowledge-write.js +3 -66
- package/dist/tools/knowledge-write.js.map +1 -1
- package/dist/tools/nudge.d.ts.map +1 -1
- package/dist/tools/nudge.js +3 -25
- package/dist/tools/nudge.js.map +1 -1
- package/dist/tools/palace-lint.d.ts +2 -6
- package/dist/tools/palace-lint.d.ts.map +1 -1
- package/dist/tools/palace-lint.js +3 -135
- package/dist/tools/palace-lint.js.map +1 -1
- package/dist/tools/palace-read.d.ts +2 -5
- package/dist/tools/palace-read.d.ts.map +1 -1
- package/dist/tools/palace-read.js +5 -62
- package/dist/tools/palace-read.js.map +1 -1
- package/dist/tools/palace-search.d.ts +2 -5
- package/dist/tools/palace-search.d.ts.map +1 -1
- package/dist/tools/palace-search.js +3 -66
- package/dist/tools/palace-search.js.map +1 -1
- package/dist/tools/palace-walk.d.ts +2 -11
- package/dist/tools/palace-walk.d.ts.map +1 -1
- package/dist/tools/palace-walk.js +3 -149
- package/dist/tools/palace-walk.js.map +1 -1
- package/dist/tools/palace-write.d.ts +2 -5
- package/dist/tools/palace-write.d.ts.map +1 -1
- package/dist/tools/palace-write.js +3 -90
- package/dist/tools/palace-write.js.map +1 -1
- package/dist/tools/recall-insight.d.ts +2 -8
- package/dist/tools/recall-insight.d.ts.map +1 -1
- package/dist/tools/recall-insight.js +3 -35
- package/dist/tools/recall-insight.js.map +1 -1
- package/package.json +9 -46
- package/README.md +0 -435
- package/dist/helpers/journal-files.d.ts +0 -30
- package/dist/helpers/journal-files.d.ts.map +0 -1
- package/dist/helpers/journal-files.js +0 -96
- package/dist/helpers/journal-files.js.map +0 -1
- package/dist/helpers/sections.d.ts +0 -12
- package/dist/helpers/sections.d.ts.map +0 -1
- package/dist/helpers/sections.js +0 -84
- package/dist/helpers/sections.js.map +0 -1
- package/dist/palace/awareness.d.ts +0 -67
- package/dist/palace/awareness.d.ts.map +0 -1
- package/dist/palace/awareness.js +0 -231
- package/dist/palace/awareness.js.map +0 -1
- package/dist/palace/consolidate.d.ts +0 -28
- package/dist/palace/consolidate.d.ts.map +0 -1
- package/dist/palace/consolidate.js +0 -129
- package/dist/palace/consolidate.js.map +0 -1
- package/dist/palace/fan-out.d.ts +0 -15
- package/dist/palace/fan-out.d.ts.map +0 -1
- package/dist/palace/fan-out.js +0 -78
- package/dist/palace/fan-out.js.map +0 -1
- package/dist/palace/graph.d.ts +0 -11
- package/dist/palace/graph.d.ts.map +0 -1
- package/dist/palace/graph.js +0 -59
- package/dist/palace/graph.js.map +0 -1
- package/dist/palace/identity.d.ts +0 -6
- package/dist/palace/identity.d.ts.map +0 -1
- package/dist/palace/identity.js +0 -18
- package/dist/palace/identity.js.map +0 -1
- package/dist/palace/index-manager.d.ts +0 -7
- package/dist/palace/index-manager.d.ts.map +0 -1
- package/dist/palace/index-manager.js +0 -46
- package/dist/palace/index-manager.js.map +0 -1
- package/dist/palace/insights-index.d.ts +0 -39
- package/dist/palace/insights-index.d.ts.map +0 -1
- package/dist/palace/insights-index.js +0 -101
- package/dist/palace/insights-index.js.map +0 -1
- package/dist/palace/log.d.ts +0 -9
- package/dist/palace/log.d.ts.map +0 -1
- package/dist/palace/log.js +0 -28
- package/dist/palace/log.js.map +0 -1
- package/dist/palace/obsidian.d.ts +0 -12
- package/dist/palace/obsidian.d.ts.map +0 -1
- package/dist/palace/obsidian.js +0 -76
- package/dist/palace/obsidian.js.map +0 -1
- package/dist/palace/rooms.d.ts +0 -14
- package/dist/palace/rooms.d.ts.map +0 -1
- package/dist/palace/rooms.js +0 -117
- package/dist/palace/rooms.js.map +0 -1
- package/dist/palace/salience.d.ts +0 -15
- package/dist/palace/salience.d.ts.map +0 -1
- package/dist/palace/salience.js +0 -33
- package/dist/palace/salience.js.map +0 -1
- package/dist/storage/fs-utils.d.ts +0 -8
- package/dist/storage/fs-utils.d.ts.map +0 -1
- package/dist/storage/fs-utils.js +0 -28
- package/dist/storage/fs-utils.js.map +0 -1
- package/dist/storage/paths.d.ts +0 -21
- package/dist/storage/paths.d.ts.map +0 -1
- package/dist/storage/paths.js +0 -59
- package/dist/storage/paths.js.map +0 -1
- package/dist/storage/project.d.ts +0 -17
- package/dist/storage/project.d.ts.map +0 -1
- package/dist/storage/project.js +0 -130
- package/dist/storage/project.js.map +0 -1
- package/dist/types.d.ts +0 -112
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -31
- package/dist/types.js.map +0 -1
package/README.md
DELETED
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<h1 align="center">AgentRecall</h1>
|
|
3
|
-
<p align="center"><strong>Memory Palace for AI Agents — A Second Brain That Compounds</strong></p>
|
|
4
|
-
<p align="center">Room-based knowledge organization · Cross-project insight recall · Salience scoring · Obsidian-compatible</p>
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
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&color=5D34F2" alt="npm"></a>
|
|
9
|
-
<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>
|
|
10
|
-
<img src="https://img.shields.io/badge/MCP-21_tools-orange?style=flat-square" alt="Tools">
|
|
11
|
-
<img src="https://img.shields.io/badge/protocol-Intelligent_Distance-5B2D8E?style=flat-square" alt="Protocol">
|
|
12
|
-
<img src="https://img.shields.io/badge/cloud-zero-blue?style=flat-square" alt="Zero Cloud">
|
|
13
|
-
<img src="https://img.shields.io/badge/Obsidian-compatible-7C3AED?style=flat-square" alt="Obsidian">
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## What Is AgentRecall?
|
|
19
|
-
|
|
20
|
-
AgentRecall is an **MCP server** (Model Context Protocol) that gives AI agents persistent memory, cross-project insight recall, and a self-compounding awareness system. It works with Claude Code, Cursor, VS Code, Windsurf, and any MCP-compatible agent.
|
|
21
|
-
|
|
22
|
-
**Not just a memory system.** Most agent memory tools store and retrieve. AgentRecall also:
|
|
23
|
-
- **Organizes** knowledge into themed rooms (Memory Palace)
|
|
24
|
-
- **Compounds** — insights merge and strengthen over time, not just accumulate
|
|
25
|
-
- **Cross-references** — writing to one room auto-updates related rooms
|
|
26
|
-
- **Recalls** — before starting a task, surfaces relevant lessons from any project
|
|
27
|
-
- **Detects misunderstanding** — measures the gap between human intent and agent interpretation
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
┌──────────────────────────────────────────────────────────────┐
|
|
31
|
-
│ Layer 1: Quick Capture journal_capture │
|
|
32
|
-
│ Layer 2: Daily Journal journal_write / journal_read │
|
|
33
|
-
│ Layer 3: Memory Palace palace_write / palace_walk │
|
|
34
|
-
│ Layer 4: Awareness awareness_update (compounding) │
|
|
35
|
-
│ Layer 5: Insight Index recall_insight (cross-project) │
|
|
36
|
-
└──────────────────────────────────────────────────────────────┘
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Quick Start
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
# Claude Code
|
|
45
|
-
claude mcp add agent-recall -- npx -y agent-recall-mcp
|
|
46
|
-
|
|
47
|
-
# Cursor — .cursor/mcp.json
|
|
48
|
-
{ "mcpServers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
49
|
-
|
|
50
|
-
# VS Code — .vscode/mcp.json
|
|
51
|
-
{ "servers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
52
|
-
|
|
53
|
-
# Windsurf — ~/.codeium/windsurf/mcp_config.json
|
|
54
|
-
{ "mcpServers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**Skill (Claude Code only):**
|
|
58
|
-
```bash
|
|
59
|
-
mkdir -p ~/.claude/skills/agent-recall
|
|
60
|
-
curl -o ~/.claude/skills/agent-recall/SKILL.md \
|
|
61
|
-
https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/SKILL.md
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## How an Agent Uses AgentRecall
|
|
67
|
-
|
|
68
|
-
### Session Start
|
|
69
|
-
```
|
|
70
|
-
1. recall_insight(context="current task description") → relevant cross-project insights
|
|
71
|
-
2. palace_walk(depth="active") → project context + awareness
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### During Work
|
|
75
|
-
```
|
|
76
|
-
3. alignment_check(goal="...", confidence="medium") → verify understanding before big tasks
|
|
77
|
-
4. palace_write(room="architecture", content="...") → permanent knowledge with cross-refs
|
|
78
|
-
5. journal_capture(question="...", answer="...") → lightweight Q&A log
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Session End
|
|
82
|
-
```
|
|
83
|
-
6. journal_write(content="...", section="decisions") → daily journal entry
|
|
84
|
-
7. awareness_update(insights=[...]) → compound into awareness system
|
|
85
|
-
8. context_synthesize(consolidate=true) → promote journal → palace rooms
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## 21 MCP Tools
|
|
91
|
-
|
|
92
|
-
### Memory Palace (5 tools)
|
|
93
|
-
|
|
94
|
-
| Tool | Purpose |
|
|
95
|
-
|------|---------|
|
|
96
|
-
| `palace_read` | Read a room or list all rooms in the Memory Palace |
|
|
97
|
-
| `palace_write` | Write memory with fan-out — auto-updates cross-references via `[[wikilinks]]` |
|
|
98
|
-
| `palace_walk` | Progressive cold-start: identity (~50 tok) → active (~200) → relevant (~500) → full (~2000) |
|
|
99
|
-
| `palace_lint` | Health check: stale, orphan, low-salience rooms. `fix=true` to auto-archive |
|
|
100
|
-
| `palace_search` | Search across all rooms, results ranked by salience score |
|
|
101
|
-
|
|
102
|
-
### Awareness & Insights (2 tools)
|
|
103
|
-
|
|
104
|
-
| Tool | Purpose |
|
|
105
|
-
|------|---------|
|
|
106
|
-
| `awareness_update` | Add insights to the compounding awareness system. Merges with existing, detects patterns |
|
|
107
|
-
| `recall_insight` | Before starting work, recall cross-project insights relevant to the current task |
|
|
108
|
-
|
|
109
|
-
### Session Memory (6 tools)
|
|
110
|
-
|
|
111
|
-
| Tool | Purpose |
|
|
112
|
-
|------|---------|
|
|
113
|
-
| `journal_read` | Read entry by date or "latest", with section filtering |
|
|
114
|
-
| `journal_write` | Write daily journal. Optional `palace_room` for palace integration |
|
|
115
|
-
| `journal_capture` | Lightweight L1 Q&A capture. Optional `palace_room` |
|
|
116
|
-
| `journal_list` | List recent journal entries |
|
|
117
|
-
| `journal_search` | Full-text search across history. `include_palace=true` for palace too |
|
|
118
|
-
| `journal_projects` | List all tracked projects |
|
|
119
|
-
|
|
120
|
-
### Architecture (3 tools)
|
|
121
|
-
|
|
122
|
-
| Tool | Purpose |
|
|
123
|
-
|------|---------|
|
|
124
|
-
| `journal_state` | JSON state layer — structured read/write for agent-to-agent handoffs |
|
|
125
|
-
| `journal_cold_start` | Cache-aware cold start: HOT (0-1d) / WARM (2-7d) / COLD (7d+) |
|
|
126
|
-
| `journal_archive` | Archive old entries to cold storage with summaries |
|
|
127
|
-
|
|
128
|
-
### Knowledge (2 tools)
|
|
129
|
-
|
|
130
|
-
| Tool | Purpose |
|
|
131
|
-
|------|---------|
|
|
132
|
-
| `knowledge_write` | Write permanent lessons — dynamic categories, auto-creates palace rooms |
|
|
133
|
-
| `knowledge_read` | Read lessons by project, category, or search query |
|
|
134
|
-
|
|
135
|
-
### Alignment (3 tools)
|
|
136
|
-
|
|
137
|
-
| Tool | Purpose |
|
|
138
|
-
|------|---------|
|
|
139
|
-
| `alignment_check` | Record confidence + assumptions → human corrects BEFORE work starts |
|
|
140
|
-
| `nudge` | Detect contradiction between current and past input → surface before damage |
|
|
141
|
-
| `context_synthesize` | L3 synthesis. `consolidate=true` writes results into palace rooms |
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
## Architecture
|
|
146
|
-
|
|
147
|
-
### Memory Palace
|
|
148
|
-
|
|
149
|
-
Inspired by the Method of Loci, Karpathy's LLM Wiki, and nashsu/llm_wiki.
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
~/.agent-recall/
|
|
153
|
-
awareness.md # 200-line compounding document (global)
|
|
154
|
-
awareness-state.json # Structured awareness data
|
|
155
|
-
insights-index.json # Cross-project insight matching
|
|
156
|
-
projects/
|
|
157
|
-
<project>/
|
|
158
|
-
journal/ # RAW SOURCES (immutable)
|
|
159
|
-
YYYY-MM-DD.md # Daily journal
|
|
160
|
-
YYYY-MM-DD-log.md # L1 captures
|
|
161
|
-
YYYY-MM-DD.state.json # JSON state
|
|
162
|
-
palace/ # MEMORY PALACE (mutable wiki)
|
|
163
|
-
identity.md # ~50 token project identity card
|
|
164
|
-
palace-index.json # Room catalog + salience scores
|
|
165
|
-
graph.json # Cross-reference edges
|
|
166
|
-
log.md # Operation audit trail
|
|
167
|
-
rooms/
|
|
168
|
-
goals/ # Active goals, evolution
|
|
169
|
-
architecture/ # Technical decisions, patterns
|
|
170
|
-
blockers/ # Current and resolved
|
|
171
|
-
alignment/ # Human corrections, misunderstandings
|
|
172
|
-
knowledge/ # Learned lessons by category
|
|
173
|
-
<custom>/ # Agents create rooms on demand
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Key Mechanisms
|
|
177
|
-
|
|
178
|
-
**Fan-out writes** — Write to one room, cross-references auto-update in related rooms via `[[wikilinks]]`. Mechanical, zero LLM cost.
|
|
179
|
-
|
|
180
|
-
**Salience scoring** — Every room has a salience score: `importance(0.4) + recency(0.3) + access_frequency(0.2) + connections(0.1)`. High-salience rooms surface first. Below threshold → auto-archive.
|
|
181
|
-
|
|
182
|
-
**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.
|
|
183
|
-
|
|
184
|
-
**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 × confirmation count.
|
|
185
|
-
|
|
186
|
-
**Obsidian-compatible** — Every palace file has YAML frontmatter + `[[wikilinks]]`. Open `palace/` as an Obsidian vault → graph view shows room connections. Zero Obsidian dependency.
|
|
187
|
-
|
|
188
|
-
### Intelligent Distance Protocol
|
|
189
|
-
|
|
190
|
-
The gap between human intent and agent understanding is structural — different cognitive origins, not a temporary technology problem. AgentRecall doesn't close this gap; it navigates it:
|
|
191
|
-
|
|
192
|
-
| Gap | Tool | How |
|
|
193
|
-
|-----|------|-----|
|
|
194
|
-
| Agent misunderstands intent | `alignment_check` | Records confidence + assumptions → human corrects before work |
|
|
195
|
-
| Agent contradicts prior decision | `nudge` | Surfaces contradiction → human clarifies |
|
|
196
|
-
| Agent forgets across sessions | `palace_walk` | Progressive loading from identity to full context |
|
|
197
|
-
| Agent repeats past mistakes | `recall_insight` | Cross-project insights surface before work starts |
|
|
198
|
-
| Agent's work quality is unclear | Think-Execute-Reflect | Counts, not feelings ("built 11 pages") |
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
## Supported Agents
|
|
203
|
-
|
|
204
|
-
| Agent | MCP | Skill | Notes |
|
|
205
|
-
|-------|:---:|:-----:|-------|
|
|
206
|
-
| Claude Code | ✅ | ✅ | Full support — MCP + SKILL.md |
|
|
207
|
-
| Cursor | ✅ | ⚡ | MCP via .cursor/mcp.json |
|
|
208
|
-
| VS Code (Copilot) | ✅ | — | MCP via .vscode/mcp.json |
|
|
209
|
-
| Windsurf | ✅ | ⚡ | MCP via mcp_config.json |
|
|
210
|
-
| Claude Desktop | ✅ | — | MCP server |
|
|
211
|
-
| Any MCP agent | ✅ | — | Standard MCP protocol |
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## Design Philosophy
|
|
216
|
-
|
|
217
|
-
**Memory is not the goal. Understanding is.**
|
|
218
|
-
|
|
219
|
-
Most memory systems optimize for retrieval accuracy. AgentRecall optimizes for **alignment accuracy** — reducing the gap between what the human means and what the agent does.
|
|
220
|
-
|
|
221
|
-
**Compounding over accumulation.** A filing cabinet with better labels is still a filing cabinet. AgentRecall's awareness system forces merge-on-insert: every new insight either strengthens an existing one or replaces the weakest. After 100 sessions, `awareness.md` is still 200 lines — but each line carries the weight of confirmed, cross-validated observations.
|
|
222
|
-
|
|
223
|
-
**Cross-project by default.** Insights learned in one project apply everywhere. `recall_insight` doesn't care which project produced the lesson — it matches the current situation against the global index.
|
|
224
|
-
|
|
225
|
-
**Agent-friendly, human-visible.** Everything is markdown on disk. Agents consume it via MCP tools. Humans browse it in Obsidian (or any text editor). Zero cloud, zero telemetry, zero lock-in.
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
## Real Results
|
|
230
|
-
|
|
231
|
-
Validated over 30+ sessions across 5 production projects:
|
|
232
|
-
- Cold-start: **5 min → 2 seconds** (cache-aware loading)
|
|
233
|
-
- Decision retention: **0% → 100%** across sessions
|
|
234
|
-
- Misunderstanding caught before wrong work: **6+ instances** via alignment checks
|
|
235
|
-
- Repeated mistakes prevented: **3 instances** via cross-project insight recall
|
|
236
|
-
- All data local, all files markdown, all tools stateless
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
## Contributing
|
|
241
|
-
|
|
242
|
-
Built by [tongwu](https://github.com/Goldentrii).
|
|
243
|
-
|
|
244
|
-
- Issues & feedback: [GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
|
|
245
|
-
- Email: tongwu0824@gmail.com
|
|
246
|
-
- Protocol spec: [docs/intelligent-distance-protocol.md](docs/intelligent-distance-protocol.md)
|
|
247
|
-
|
|
248
|
-
MIT License.
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
---
|
|
253
|
-
|
|
254
|
-
# AgentRecall(中文文档)
|
|
255
|
-
|
|
256
|
-
> 给你的 AI 智能体一个会成长的第二大脑。
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
## AgentRecall 是什么?
|
|
261
|
-
|
|
262
|
-
AgentRecall 是一个 **MCP 服务器**(Model Context Protocol),为 AI 智能体提供持久化记忆、跨项目洞察召回和自复合感知系统。支持 Claude Code、Cursor、VS Code、Windsurf 及所有 MCP 兼容的智能体。
|
|
263
|
-
|
|
264
|
-
**不只是记忆系统。** 大多数智能体记忆工具只做存储和检索。AgentRecall 还能:
|
|
265
|
-
- **组织** — 知识按主题房间分类(记忆宫殿)
|
|
266
|
-
- **复合** — 洞察随时间合并增强,不是单纯累积
|
|
267
|
-
- **交叉引用** — 写入一个房间时自动更新相关房间
|
|
268
|
-
- **召回** — 开始任务前,自动呈现任何项目中的相关经验教训
|
|
269
|
-
- **检测误解** — 测量人类意图和智能体理解之间的差距
|
|
270
|
-
|
|
271
|
-
---
|
|
272
|
-
|
|
273
|
-
## 快速开始
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
# Claude Code
|
|
277
|
-
claude mcp add agent-recall -- npx -y agent-recall-mcp
|
|
278
|
-
|
|
279
|
-
# Cursor — .cursor/mcp.json
|
|
280
|
-
{ "mcpServers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
281
|
-
|
|
282
|
-
# VS Code — .vscode/mcp.json
|
|
283
|
-
{ "servers": { "agent-recall": { "command": "npx", "args": ["-y", "agent-recall-mcp"] } } }
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
**Claude Code 技能安装:**
|
|
287
|
-
```bash
|
|
288
|
-
mkdir -p ~/.claude/skills/agent-recall
|
|
289
|
-
curl -o ~/.claude/skills/agent-recall/SKILL.md \
|
|
290
|
-
https://raw.githubusercontent.com/Goldentrii/AgentRecall/main/SKILL.md
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
---
|
|
294
|
-
|
|
295
|
-
## 智能体使用流程
|
|
296
|
-
|
|
297
|
-
### 会话开始
|
|
298
|
-
```
|
|
299
|
-
1. recall_insight(context="当前任务描述") → 跨项目相关洞察
|
|
300
|
-
2. palace_walk(depth="active") → 项目上下文 + 感知摘要
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### 工作中
|
|
304
|
-
```
|
|
305
|
-
3. alignment_check(goal="...", confidence="medium") → 大任务前确认理解
|
|
306
|
-
4. palace_write(room="architecture", content="...") → 永久知识 + 交叉引用
|
|
307
|
-
5. journal_capture(question="...", answer="...") → 轻量问答记录
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### 会话结束
|
|
311
|
-
```
|
|
312
|
-
6. journal_write(content="...", section="decisions") → 每日日志
|
|
313
|
-
7. awareness_update(insights=[...]) → 洞察复合到感知系统
|
|
314
|
-
8. context_synthesize(consolidate=true) → 日志内容提升到宫殿
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
---
|
|
318
|
-
|
|
319
|
-
## 21 个 MCP 工具
|
|
320
|
-
|
|
321
|
-
### 记忆宫殿(5 个)
|
|
322
|
-
|
|
323
|
-
| 工具 | 功能 |
|
|
324
|
-
|------|------|
|
|
325
|
-
| `palace_read` | 读取房间内容或列出所有房间 |
|
|
326
|
-
| `palace_write` | 写入记忆,自动通过 `[[wikilinks]]` 扇出交叉引用 |
|
|
327
|
-
| `palace_walk` | 渐进式冷启动:identity (~50 tok) → active (~200) → relevant (~500) → full (~2000) |
|
|
328
|
-
| `palace_lint` | 健康检查:过期、孤立、低显著性房间。`fix=true` 自动归档 |
|
|
329
|
-
| `palace_search` | 全房间搜索,按显著性评分排序 |
|
|
330
|
-
|
|
331
|
-
### 感知与洞察(2 个)
|
|
332
|
-
|
|
333
|
-
| 工具 | 功能 |
|
|
334
|
-
|------|------|
|
|
335
|
-
| `awareness_update` | 添加洞察到复合感知系统。自动合并相似洞察,检测跨洞察模式 |
|
|
336
|
-
| `recall_insight` | 开始任务前,召回跨项目的相关洞察 |
|
|
337
|
-
|
|
338
|
-
### 会话记忆(6 个)
|
|
339
|
-
|
|
340
|
-
| 工具 | 功能 |
|
|
341
|
-
|------|------|
|
|
342
|
-
| `journal_read` | 按日期读取日志,支持章节过滤 |
|
|
343
|
-
| `journal_write` | 写入每日日志。可选 `palace_room` 同步到宫殿 |
|
|
344
|
-
| `journal_capture` | 轻量问答捕获 |
|
|
345
|
-
| `journal_list` | 列出最近日志 |
|
|
346
|
-
| `journal_search` | 全文搜索。`include_palace=true` 同时搜索宫殿 |
|
|
347
|
-
| `journal_projects` | 列出所有项目 |
|
|
348
|
-
|
|
349
|
-
### 架构工具(3 个)
|
|
350
|
-
|
|
351
|
-
| 工具 | 功能 |
|
|
352
|
-
|------|------|
|
|
353
|
-
| `journal_state` | JSON 状态层 — agent 间毫秒级结构化交接 |
|
|
354
|
-
| `journal_cold_start` | 缓存感知冷启动:热 (0-1天) / 温 (2-7天) / 冷 (7天+) |
|
|
355
|
-
| `journal_archive` | 归档旧条目到冷存储 |
|
|
356
|
-
|
|
357
|
-
### 知识工具(2 个)
|
|
358
|
-
|
|
359
|
-
| 工具 | 功能 |
|
|
360
|
-
|------|------|
|
|
361
|
-
| `knowledge_write` | 写入永久教训 — 动态类别,自动创建宫殿房间 |
|
|
362
|
-
| `knowledge_read` | 按项目、类别或搜索词读取教训 |
|
|
363
|
-
|
|
364
|
-
### 对齐工具(3 个)
|
|
365
|
-
|
|
366
|
-
| 工具 | 功能 |
|
|
367
|
-
|------|------|
|
|
368
|
-
| `alignment_check` | 记录置信度 + 假设 → 人类在工作前纠正 |
|
|
369
|
-
| `nudge` | 检测与过去决策的矛盾 → 在造成损失前提出 |
|
|
370
|
-
| `context_synthesize` | L3 合成。`consolidate=true` 将结果写入宫殿房间 |
|
|
371
|
-
|
|
372
|
-
---
|
|
373
|
-
|
|
374
|
-
## 架构
|
|
375
|
-
|
|
376
|
-
### 五层记忆模型
|
|
377
|
-
|
|
378
|
-
```
|
|
379
|
-
┌──────────────────────────────────────────────────────────────┐
|
|
380
|
-
│ L1: 工作记忆 journal_capture 「发生了什么」 │
|
|
381
|
-
│ L2: 情景记忆 journal_write 「这意味着什么」 │
|
|
382
|
-
│ L3: 记忆宫殿 palace_write / walk 「跨会话的知识」 │
|
|
383
|
-
│ L4: 感知系统 awareness_update 「复合的洞察」 │
|
|
384
|
-
│ L5: 洞察索引 recall_insight 「跨项目的经验」 │
|
|
385
|
-
└──────────────────────────────────────────────────────────────┘
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
### 核心机制
|
|
389
|
-
|
|
390
|
-
**扇出写入** — 写入一个房间,相关房间通过 `[[wikilinks]]` 自动更新交叉引用。机械式处理,零 LLM 成本。
|
|
391
|
-
|
|
392
|
-
**显著性评分** — 每个房间有显著性分数:`重要性(0.4) + 时效性(0.3) + 访问频率(0.2) + 连接数(0.1)`。高显著性房间优先展示,低于阈值自动归档。
|
|
393
|
-
|
|
394
|
-
**复合感知** — `awareness.md` 上限 200 行。新洞察加入时,相似的合并(增强),不相似的竞争(最低确认次数的被替换)。约束创造压缩,压缩创造复合。
|
|
395
|
-
|
|
396
|
-
**跨项目洞察召回** — `insights-index.json` 通过关键词将洞察映射到场景。`recall_insight("构建质量检查")` 返回来自任何项目的相关教训。
|
|
397
|
-
|
|
398
|
-
**Obsidian 兼容** — 每个宫殿文件都有 YAML frontmatter + `[[wikilinks]]`。将 `palace/` 作为 Obsidian vault 打开 → 图形视图展示房间连接。零 Obsidian 依赖。
|
|
399
|
-
|
|
400
|
-
### 智能距离协议
|
|
401
|
-
|
|
402
|
-
人类意图与智能体理解之间的差距是结构性的 — 源于不同的认知起源,不是临时的技术问题。
|
|
403
|
-
|
|
404
|
-
| 差距 | 工具 | 机制 |
|
|
405
|
-
|------|------|------|
|
|
406
|
-
| 智能体误解意图 | `alignment_check` | 记录置信度 + 假设 → 人类在工作前纠正 |
|
|
407
|
-
| 智能体与先前决策矛盾 | `nudge` | 发现矛盾 → 人类澄清 |
|
|
408
|
-
| 智能体跨会话遗忘 | `palace_walk` | 从身份到完整上下文的渐进式加载 |
|
|
409
|
-
| 智能体重复过去的错误 | `recall_insight` | 跨项目洞察在工作前自动呈现 |
|
|
410
|
-
|
|
411
|
-
---
|
|
412
|
-
|
|
413
|
-
## 设计理念
|
|
414
|
-
|
|
415
|
-
**记忆不是目的,理解才是。**
|
|
416
|
-
|
|
417
|
-
大多数记忆系统优化检索准确性。AgentRecall 优化**对齐准确性** — 缩小人类意图和智能体行为之间的差距。
|
|
418
|
-
|
|
419
|
-
**复合优于累积。** 贴了更好标签的文件柜还是文件柜。AgentRecall 的感知系统在插入时强制合并:每个新洞察要么增强已有的,要么替换最弱的。100 个会话后,`awareness.md` 仍是 200 行 — 但每一行承载着经过确认和交叉验证的观察。
|
|
420
|
-
|
|
421
|
-
**默认跨项目。** 在一个项目中学到的洞察适用于所有项目。`recall_insight` 不关心教训来自哪个项目 — 它匹配当前场景和全局索引。
|
|
422
|
-
|
|
423
|
-
**智能体友好,人类可见。** 一切都是磁盘上的 markdown。智能体通过 MCP 工具消费。人类在 Obsidian(或任何文本编辑器)中浏览。零云端、零遥测、零锁定。
|
|
424
|
-
|
|
425
|
-
---
|
|
426
|
-
|
|
427
|
-
## 贡献
|
|
428
|
-
|
|
429
|
-
由 [tongwu](https://github.com/Goldentrii) 构建。
|
|
430
|
-
|
|
431
|
-
- Issues & 反馈:[GitHub Issues](https://github.com/Goldentrii/AgentRecall/issues)
|
|
432
|
-
- 邮箱:tongwu0824@gmail.com
|
|
433
|
-
- 协议规范:[docs/intelligent-distance-protocol.md](docs/intelligent-distance-protocol.md)
|
|
434
|
-
|
|
435
|
-
MIT 许可证。
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Journal file listing, reading, and index maintenance.
|
|
3
|
-
*/
|
|
4
|
-
import type { JournalEntry } from "../types.js";
|
|
5
|
-
/**
|
|
6
|
-
* List all .md journal files across all directories for a project.
|
|
7
|
-
* Returns sorted array with most recent first.
|
|
8
|
-
*/
|
|
9
|
-
export declare function listJournalFiles(project: string): JournalEntry[];
|
|
10
|
-
/**
|
|
11
|
-
* Read a journal file. Checks primary dir first, then legacy.
|
|
12
|
-
*/
|
|
13
|
-
export declare function readJournalFile(project: string, date: string): string | null;
|
|
14
|
-
/**
|
|
15
|
-
* Extract title from journal file content.
|
|
16
|
-
*/
|
|
17
|
-
export declare function extractTitle(content: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Extract momentum indicator from journal content.
|
|
20
|
-
*/
|
|
21
|
-
export declare function extractMomentum(content: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Count entries in a log file (for journal_capture entry numbering).
|
|
24
|
-
*/
|
|
25
|
-
export declare function countLogEntries(logPath: string): number;
|
|
26
|
-
/**
|
|
27
|
-
* Update the index.md for a project.
|
|
28
|
-
*/
|
|
29
|
-
export declare function updateIndex(project: string): void;
|
|
30
|
-
//# sourceMappingURL=journal-files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"journal-files.d.ts","sourceRoot":"","sources":["../../src/helpers/journal-files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAmBhE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAa5E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOvD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAuBjD"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Journal file listing, reading, and index maintenance.
|
|
3
|
-
*/
|
|
4
|
-
import * as fs from "node:fs";
|
|
5
|
-
import * as path from "node:path";
|
|
6
|
-
import { journalDir, journalDirs } from "../storage/paths.js";
|
|
7
|
-
import { ensureDir } from "../storage/fs-utils.js";
|
|
8
|
-
/**
|
|
9
|
-
* List all .md journal files across all directories for a project.
|
|
10
|
-
* Returns sorted array with most recent first.
|
|
11
|
-
*/
|
|
12
|
-
export function listJournalFiles(project) {
|
|
13
|
-
const dirs = journalDirs(project);
|
|
14
|
-
const entries = [];
|
|
15
|
-
const seen = new Set();
|
|
16
|
-
for (const dir of dirs) {
|
|
17
|
-
if (!fs.existsSync(dir))
|
|
18
|
-
continue;
|
|
19
|
-
const files = fs.readdirSync(dir);
|
|
20
|
-
for (const file of files) {
|
|
21
|
-
const match = file.match(/^(\d{4}-\d{2}-\d{2})\.md$/);
|
|
22
|
-
if (match && !seen.has(match[1])) {
|
|
23
|
-
seen.add(match[1]);
|
|
24
|
-
entries.push({ date: match[1], file, dir });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
entries.sort((a, b) => b.date.localeCompare(a.date));
|
|
29
|
-
return entries;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Read a journal file. Checks primary dir first, then legacy.
|
|
33
|
-
*/
|
|
34
|
-
export function readJournalFile(project, date) {
|
|
35
|
-
const filename = `${date}.md`;
|
|
36
|
-
const dirs = journalDirs(project);
|
|
37
|
-
const primaryDir = journalDir(project);
|
|
38
|
-
const allDirs = [primaryDir, ...dirs.filter((d) => d !== primaryDir)];
|
|
39
|
-
for (const dir of allDirs) {
|
|
40
|
-
const filePath = path.join(dir, filename);
|
|
41
|
-
if (fs.existsSync(filePath)) {
|
|
42
|
-
return fs.readFileSync(filePath, "utf-8");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Extract title from journal file content.
|
|
49
|
-
*/
|
|
50
|
-
export function extractTitle(content) {
|
|
51
|
-
const match = content.match(/^# (.+)$/m);
|
|
52
|
-
return match ? match[1].trim() : "(untitled)";
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Extract momentum indicator from journal content.
|
|
56
|
-
*/
|
|
57
|
-
export function extractMomentum(content) {
|
|
58
|
-
const patterns = [/[🟢🟡🔴⚪]\s*\S+/];
|
|
59
|
-
for (const pattern of patterns) {
|
|
60
|
-
const match = content.match(pattern);
|
|
61
|
-
if (match)
|
|
62
|
-
return match[0];
|
|
63
|
-
}
|
|
64
|
-
return "";
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Count entries in a log file (for journal_capture entry numbering).
|
|
68
|
-
*/
|
|
69
|
-
export function countLogEntries(logPath) {
|
|
70
|
-
if (!fs.existsSync(logPath))
|
|
71
|
-
return 0;
|
|
72
|
-
const content = fs.readFileSync(logPath, "utf-8");
|
|
73
|
-
const matches = content.match(/^### Q\d+/gm);
|
|
74
|
-
return matches ? matches.length : 0;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Update the index.md for a project.
|
|
78
|
-
*/
|
|
79
|
-
export function updateIndex(project) {
|
|
80
|
-
const dir = journalDir(project);
|
|
81
|
-
ensureDir(dir);
|
|
82
|
-
const indexPath = path.join(dir, "index.md");
|
|
83
|
-
const entries = listJournalFiles(project);
|
|
84
|
-
let index = `# ${project} — Journal Index\n\n`;
|
|
85
|
-
index += `> Auto-generated. ${entries.length} entries.\n\n`;
|
|
86
|
-
index += `| Date | Title | Momentum |\n`;
|
|
87
|
-
index += `|------|-------|----------|\n`;
|
|
88
|
-
for (const entry of entries) {
|
|
89
|
-
const content = fs.readFileSync(path.join(entry.dir, entry.file), "utf-8");
|
|
90
|
-
const title = extractTitle(content);
|
|
91
|
-
const momentum = extractMomentum(content);
|
|
92
|
-
index += `| ${entry.date} | ${title} | ${momentum} |\n`;
|
|
93
|
-
}
|
|
94
|
-
fs.writeFileSync(indexPath, index, "utf-8");
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=journal-files.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"journal-files.js","sourceRoot":"","sources":["../../src/helpers/journal-files.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Markdown section extraction and manipulation.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Extract a section from a markdown journal entry.
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractSection(content: string, section: string): string | null;
|
|
8
|
-
/**
|
|
9
|
-
* Append content to a specific section in a journal file, or to end of file.
|
|
10
|
-
*/
|
|
11
|
-
export declare function appendToSection(existingContent: string, newContent: string, section: string | null): string;
|
|
12
|
-
//# sourceMappingURL=sections.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../../src/helpers/sections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsC9E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,MAAM,CA0CR"}
|
package/dist/helpers/sections.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Markdown section extraction and manipulation.
|
|
3
|
-
*/
|
|
4
|
-
import { SECTION_HEADERS } from "../types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Extract a section from a markdown journal entry.
|
|
7
|
-
*/
|
|
8
|
-
export function extractSection(content, section) {
|
|
9
|
-
if (section === "all")
|
|
10
|
-
return content;
|
|
11
|
-
if (section === "brief") {
|
|
12
|
-
const lines = content.split("\n");
|
|
13
|
-
const nonEmpty = [];
|
|
14
|
-
let pastTitle = false;
|
|
15
|
-
for (const line of lines) {
|
|
16
|
-
if (line.startsWith("# ")) {
|
|
17
|
-
pastTitle = true;
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (!pastTitle)
|
|
21
|
-
continue;
|
|
22
|
-
const trimmed = line.trim();
|
|
23
|
-
if (trimmed === "")
|
|
24
|
-
continue;
|
|
25
|
-
nonEmpty.push(trimmed);
|
|
26
|
-
if (nonEmpty.length >= 4)
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
return nonEmpty.join("\n") || null;
|
|
30
|
-
}
|
|
31
|
-
const header = SECTION_HEADERS[section];
|
|
32
|
-
if (!header)
|
|
33
|
-
return null;
|
|
34
|
-
const idx = content.indexOf(header);
|
|
35
|
-
if (idx === -1)
|
|
36
|
-
return null;
|
|
37
|
-
const afterHeader = content.slice(idx);
|
|
38
|
-
const lines = afterHeader.split("\n");
|
|
39
|
-
const result = [lines[0]];
|
|
40
|
-
let inCodeFence = false;
|
|
41
|
-
for (let i = 1; i < lines.length; i++) {
|
|
42
|
-
if (lines[i].startsWith("```"))
|
|
43
|
-
inCodeFence = !inCodeFence;
|
|
44
|
-
if (!inCodeFence && lines[i].startsWith("## "))
|
|
45
|
-
break;
|
|
46
|
-
result.push(lines[i]);
|
|
47
|
-
}
|
|
48
|
-
return result.join("\n").trimEnd();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Append content to a specific section in a journal file, or to end of file.
|
|
52
|
-
*/
|
|
53
|
-
export function appendToSection(existingContent, newContent, section) {
|
|
54
|
-
if (section === "replace_all") {
|
|
55
|
-
return newContent;
|
|
56
|
-
}
|
|
57
|
-
if (!section) {
|
|
58
|
-
return existingContent.trimEnd() + "\n\n" + newContent + "\n";
|
|
59
|
-
}
|
|
60
|
-
const header = SECTION_HEADERS[section];
|
|
61
|
-
if (!header) {
|
|
62
|
-
return existingContent.trimEnd() + "\n\n" + newContent + "\n";
|
|
63
|
-
}
|
|
64
|
-
const idx = existingContent.indexOf(header);
|
|
65
|
-
if (idx === -1) {
|
|
66
|
-
return (existingContent.trimEnd() + "\n\n" + header + "\n\n" + newContent + "\n");
|
|
67
|
-
}
|
|
68
|
-
const afterHeader = existingContent.slice(idx);
|
|
69
|
-
const lines = afterHeader.split("\n");
|
|
70
|
-
let insertAt = lines.length;
|
|
71
|
-
let inCodeFence = false;
|
|
72
|
-
for (let i = 1; i < lines.length; i++) {
|
|
73
|
-
if (lines[i].startsWith("```"))
|
|
74
|
-
inCodeFence = !inCodeFence;
|
|
75
|
-
if (!inCodeFence && lines[i].startsWith("## ")) {
|
|
76
|
-
insertAt = i;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const before = existingContent.slice(0, idx + lines.slice(0, insertAt).join("\n").length);
|
|
81
|
-
const after = existingContent.slice(idx + lines.slice(0, insertAt).join("\n").length);
|
|
82
|
-
return before.trimEnd() + "\n\n" + newContent + "\n" + after;
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=sections.js.map
|