pi-hermes-memory 0.4.1 → 0.4.3

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.
@@ -0,0 +1,341 @@
1
+ # Your AI Agent Just Got a Brain Upgrade: Pi Hermes Memory v0.4
2
+
3
+ **TL;DR**: Your coding agent can now remember every conversation you've ever had with it. Search through weeks of context in milliseconds. Never lose an insight again.
4
+
5
+ ---
6
+
7
+ ## The Problem
8
+
9
+ Every time you start a new session with an AI coding agent, it forgets everything. That debugging session from last Tuesday? Gone. The architecture decision you discussed for 2 hours? Vanished. The user preferences you explained 5 times? You'll explain them a 6th.
10
+
11
+ You're not just losing context — you're losing **hours of accumulated knowledge**.
12
+
13
+ ## The Solution: Persistent Memory + Session Search
14
+
15
+ Pi Hermes Memory v0.4 introduces **SQLite-powered session history** with full-text search. Your agent now has:
16
+
17
+ - 🧠 **Persistent memory** that survives across sessions (MEMORY.md + USER.md)
18
+ - 🔍 **Full-text search** across every conversation you've ever had
19
+ - 📦 **Unlimited extended memory** via SQLite — no more "memory is full" errors
20
+ - 🔎 **Two search tools** — `session_search` for conversations, `memory_search` for facts
21
+ - 📊 **5,000 character limits** (up from 2,200) — more room for context
22
+
23
+ ## What Changed: Before vs After
24
+
25
+ ### Before v0.4
26
+ ```
27
+ You: "What did we discuss about the auth flow last week?"
28
+ Agent: "I don't have access to previous sessions."
29
+ You: *sighs, re-explains everything*
30
+ ```
31
+
32
+ ### After v0.4
33
+ ```
34
+ You: "What did we discuss about the auth flow last week?"
35
+ Agent: *searches session history*
36
+ "Last Tuesday we discussed implementing JWT with refresh tokens.
37
+ You preferred httpOnly cookies over localStorage. We also decided
38
+ to use the auth0 SDK. Want me to continue from there?"
39
+ You: *continues where you left off*
40
+ ```
41
+
42
+ ## New Capabilities Deep Dive
43
+
44
+ ### 1. Session History Search
45
+
46
+ Every conversation is automatically indexed into SQLite with FTS5 (full-text search 5). When you ask about something from the past, your agent searches across all sessions instantly.
47
+
48
+ **How it works:**
49
+ - Sessions are indexed on shutdown (automatic)
50
+ - Full-text search via FTS5 — fast, keyword-based
51
+ - Filter by project, role (user/assistant), or date
52
+
53
+ **Try it:**
54
+ ```
55
+ "What was that error we fixed with the database connection?"
56
+ "Find the PR where we added the secret scanning feature"
57
+ "What testing approach did we use for the memory store?"
58
+ ```
59
+
60
+ ### 2. Extended Memory Store
61
+
62
+ The old memory had a 2,200 character limit. Now it's 5,000 — but more importantly, there's an **unlimited extended store** in SQLite. When core memory fills up, entries are preserved in the extended store and remain searchable.
63
+
64
+ **What this means:**
65
+ - Core memory (MEMORY.md): 5,000 chars — always in context
66
+ - Extended memory (SQLite): Unlimited — searchable on demand
67
+ - No more losing memories to consolidation
68
+
69
+ ### 3. Two-Tier Search Architecture
70
+
71
+ | Tool | What It Searches | When to Use |
72
+ |---|---|---|
73
+ | `session_search` | Past conversations | "What did we discuss about X?" |
74
+ | `memory_search` | Extended memory store | "What do I know about X?" |
75
+
76
+ The agent decides which tool to use based on your question. But you can also invoke them directly.
77
+
78
+ ### 4. Hybrid Memory Design
79
+
80
+ ```
81
+ Always in Context (5,000 chars each)
82
+ ┌─────────────────────────────────────┐
83
+ │ MEMORY.md — Facts, conventions │
84
+ │ USER.md — Who you are │
85
+ │ Project memory — When cwd matches │
86
+ └─────────────────────────────────────┘
87
+
88
+ Searchable on Demand (Unlimited)
89
+ ┌─────────────────────────────────────┐
90
+ │ session_search("auth flow") │
91
+ │ memory_search("testing patterns") │
92
+ └─────────────────────────────────────┘
93
+ ```
94
+
95
+ Your agent always knows who you are and what you prefer (core memory). When it needs deeper context, it searches.
96
+
97
+ ## How to Test Your Memory
98
+
99
+ ### Step 1: Index Your Past Sessions
100
+
101
+ ```bash
102
+ /memory-index-sessions
103
+ ```
104
+
105
+ This imports all your existing Pi sessions into the search database. You'll see:
106
+
107
+ ```
108
+ 🔍 Scanning session directories...
109
+ 📁 Found 36 session files across 5 projects
110
+ ⏳ Indexing...
111
+
112
+ ✅ Session indexing complete!
113
+
114
+ 📊 Results:
115
+ ├─ Sessions processed: 36
116
+ ├─ Sessions indexed: 36
117
+ ├─ Messages indexed: 1,247
118
+
119
+ 📁 Projects indexed:
120
+ ├─ pi-hermes-memory: 12 sessions, 856 messages
121
+ ├─ my-other-project: 8 sessions, 234 messages
122
+ └─ ...
123
+ ```
124
+
125
+ ### Step 2: Explore Your Memory
126
+
127
+ ```bash
128
+ /memory-insights
129
+ ```
130
+
131
+ Shows everything stored in your memory — facts, user profile, and project-specific memories.
132
+
133
+ ### Step 3: Search Your History
134
+
135
+ Ask your agent to search:
136
+
137
+ ```
138
+ "Search my sessions for discussions about TypeScript configuration"
139
+ "What do I know about the user's testing preferences?"
140
+ "Find conversations about database migrations"
141
+ ```
142
+
143
+ ### Step 4: Query the Database Directly
144
+
145
+ For the curious, your data lives in `~/.pi/agent/memory/sessions.db`:
146
+
147
+ ```bash
148
+ # Sessions overview
149
+ sqlite3 -header -column ~/.pi/agent/memory/sessions.db \
150
+ "SELECT project, COUNT(*) as sessions, SUM(message_count) as messages
151
+ FROM sessions GROUP BY project;"
152
+
153
+ # Full-text search
154
+ sqlite3 -header -column ~/.pi/agent/memory/sessions.db \
155
+ "SELECT s.project, substr(m.content, 1, 100) as snippet
156
+ FROM messages m JOIN sessions s ON s.id = m.session_id
157
+ WHERE m.rowid IN (SELECT rowid FROM message_fts WHERE message_fts MATCH 'SQLite')
158
+ LIMIT 5;"
159
+
160
+ # Messages by role
161
+ sqlite3 ~/.pi/agent/memory/sessions.db \
162
+ "SELECT role, COUNT(*) FROM messages GROUP BY role;"
163
+ ```
164
+
165
+ ## Real-World Impact
166
+
167
+ ### For Individual Developers
168
+ - **Context continuity**: Pick up where you left off, even days later
169
+ - **No more re-explaining**: Your preferences and setup are remembered
170
+ - **Institutional memory**: Your debugging insights persist
171
+
172
+ ### For Teams
173
+ - **Shared knowledge**: Project conventions are stored and searchable
174
+ - **Onboarding**: New team members can search past discussions
175
+ - **Decision history**: Architecture decisions are preserved
176
+
177
+ ### For Power Users
178
+ - **Pattern recognition**: Search for similar problems across projects
179
+ - **Learning retention**: Your coding learnings accumulate over time
180
+ - **Workflow optimization**: Discover what approaches worked before
181
+
182
+ ## The Architecture (For the Technical)
183
+
184
+ ```
185
+ ┌─────────────────────────────────────────────────────────┐
186
+ │ Pi Extension │
187
+ ├─────────────────────────────────────────────────────────┤
188
+ │ Tools: │
189
+ │ ├── memory (add/replace/remove) │
190
+ │ ├── skill (create/view/patch/edit/delete) │
191
+ │ ├── session_search (FTS5 across messages) │
192
+ │ └── memory_search (FTS5 across extended memories) │
193
+ ├─────────────────────────────────────────────────────────┤
194
+ │ Storage: │
195
+ │ ├── MEMORY.md / USER.md (core, always injected) │
196
+ │ ├── skills/*.md (procedural, on-demand) │
197
+ │ └── sessions.db (SQLite + FTS5, searchable) │
198
+ ├─────────────────────────────────────────────────────────┤
199
+ │ Events: │
200
+ │ ├── session_start → Load core memory │
201
+ │ ├── context → Inject memory into system prompt │
202
+ │ ├── session_shutdown → Auto-index session │
203
+ │ └── turn_count ≥ 10 → Background review │
204
+ └─────────────────────────────────────────────────────────┘
205
+ ```
206
+
207
+ **Key technical decisions:**
208
+ - **better-sqlite3**: Native C++ addon, synchronous API, built-in FTS5
209
+ - **WAL mode**: Write-ahead logging for concurrent reads
210
+ - **Lazy initialization**: DB only opened when first needed
211
+ - **Single file**: `sessions.db` — easy to backup, easy to delete
212
+
213
+ ## What's Next (v0.5+)
214
+
215
+ - **Semantic search**: Embedding-based search using local models (potion-base-4M)
216
+ - **Cross-project insights**: Find patterns across all your projects
217
+ - **Memory visualization**: Timeline view of your knowledge accumulation
218
+ - **Collaborative memory**: Share project memories with team members
219
+
220
+ ## Get Started
221
+
222
+ ```bash
223
+ # Install or update
224
+ pi install chandra447/pi-hermes-memory
225
+
226
+ # Index your past sessions
227
+ /memory-index-sessions
228
+
229
+ # Learn how to use it
230
+ /learn-memory-tool
231
+
232
+ # Check what's stored
233
+ /memory-insights
234
+ ```
235
+
236
+ ## Links
237
+
238
+ - **npm**: [pi-hermes-memory](https://www.npmjs.com/package/pi-hermes-memory)
239
+ - **GitHub**: [chandra447/pi-hermes-memory](https://github.com/chandra447/pi-hermes-memory)
240
+ - **Pi**: [pi.dev](https://pi.dev)
241
+
242
+ ---
243
+
244
+ *Your AI agent should remember as much as you do. Now it does.*
245
+
246
+ ---
247
+
248
+ ## Social Media Posts
249
+
250
+ ### X/Twitter (Thread)
251
+
252
+ **Post 1:**
253
+ 🚀 Just shipped v0.4 of Pi Hermes Memory — your AI coding agent can now search through every conversation you've ever had with it.
254
+
255
+ No more re-explaining context. No more lost debugging sessions.
256
+
257
+ Thread 🧵👇
258
+
259
+ **Post 2:**
260
+ The problem: Every AI session starts from zero. That 2-hour debugging session from Tuesday? Gone. The architecture decision you discussed? Vanished.
261
+
262
+ You're not just losing context — you're losing hours of accumulated knowledge.
263
+
264
+ **Post 3:**
265
+ The solution: SQLite-powered session history with full-text search.
266
+
267
+ Your agent now has:
268
+ • Persistent memory (survives across sessions)
269
+ • Full-text search across all conversations
270
+ • Unlimited extended memory
271
+ • 5,000 char limits (up from 2,200)
272
+
273
+ **Post 4:**
274
+ How it works:
275
+
276
+ 1. Sessions auto-indexed on shutdown
277
+ 2. FTS5 search finds relevant context in milliseconds
278
+ 3. Agent decides when to search based on your question
279
+ 4. Core memory always in context, extended memory searchable on demand
280
+
281
+ **Post 5:**
282
+ Try it yourself:
283
+
284
+ ```
285
+ /memory-index-sessions # Import past sessions
286
+ /memory-insights # See what's stored
287
+ "Search my sessions for discussions about auth" # Test it
288
+ ```
289
+
290
+ **Post 6:**
291
+ Technical details:
292
+ • better-sqlite3 (native C++ addon)
293
+ • WAL mode for concurrent reads
294
+ • Single sessions.db file (easy backup)
295
+ • Lazy initialization (no startup cost)
296
+
297
+ **Post 7:**
298
+ Your AI agent should remember as much as you do. Now it does.
299
+
300
+ npm: npmjs.com/package/pi-hermes-memory
301
+ GitHub: github.com/chandra447/pi-hermes-memory
302
+
303
+ #AI #DevTools #CodingAgent #Pi #OpenSource
304
+
305
+ ---
306
+
307
+ ### LinkedIn Post
308
+
309
+ **Your AI Agent Just Got a Brain Upgrade**
310
+
311
+ Every time you start a new session with an AI coding agent, it forgets everything. That debugging session from last week? Gone. The architecture decision you discussed? Vanished.
312
+
313
+ Pi Hermes Memory v0.4 changes this.
314
+
315
+ Your agent now has:
316
+ ✅ Persistent memory that survives across sessions
317
+ ✅ Full-text search across every conversation
318
+ ✅ Unlimited extended memory via SQLite
319
+ ✅ Automatic session indexing
320
+
321
+ The result? Context continuity. No more re-explaining your preferences. No more lost debugging insights. Your accumulated knowledge persists.
322
+
323
+ I built this because I was tired of re-explaining context every session. Now my agent remembers what we discussed last week, last month, last year.
324
+
325
+ Key technical decisions:
326
+ • SQLite with FTS5 for fast full-text search
327
+ • Hybrid memory: core (always in context) + extended (searchable on demand)
328
+ • 5,000 character limits (up from 2,200)
329
+ • Auto-indexing on session shutdown
330
+
331
+ Try it:
332
+ ```
333
+ pi install chandra447/pi-hermes-memory
334
+ /memory-index-sessions
335
+ ```
336
+
337
+ Your AI agent should remember as much as you do. Now it does.
338
+
339
+ Open source: github.com/chandra447/pi-hermes-memory
340
+
341
+ #AI #DevTools #SoftwareEngineering #OpenSource #CodingAgent #DeveloperProductivity #MachineLearning #ArtificialIntelligence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-hermes-memory",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Your Pi agent remembers everything across sessions — your preferences, your stack, your corrections, and even how it solved problems. Zero-config install, works immediately. Persistent memory + procedural skills + auto-correction detection + security-first content scanning.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,11 @@
1
+ /**
2
+ * Index sessions command — /memory-index-sessions imports past sessions into SQLite.
3
+ */
4
+
1
5
  import path from 'node:path';
6
+ import fs from 'node:fs';
2
7
  import os from 'node:os';
3
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
8
+ import type { ExtensionAPI, ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
4
9
  import { DatabaseManager } from '../store/db.js';
5
10
  import { indexAllSessions, getSessionStats } from '../store/session-indexer.js';
6
11
 
@@ -9,16 +14,26 @@ const SESSIONS_DIR = path.join(os.homedir(), '.pi', 'agent', 'sessions');
9
14
  export function registerIndexSessionsCommand(pi: ExtensionAPI): void {
10
15
  pi.registerCommand("memory-index-sessions", {
11
16
  description: "Import past Pi sessions into the search database",
12
- handler: async (_args, ctx) => {
13
- const sendUserMessage = (msg: string) => {
14
- if (ctx && typeof ctx === 'object' && 'sendUserMessage' in ctx) {
15
- (ctx as { sendUserMessage: (msg: string) => void }).sendUserMessage(msg);
17
+ handler: async (_args, ctx: ExtensionCommandContext) => {
18
+ // Show initial progress
19
+ ctx.ui.notify('🔍 Scanning session directories...', 'info');
20
+
21
+ try {
22
+ // Count sessions first for progress display
23
+ let totalFiles = 0;
24
+ let projectDirs: string[] = [];
25
+ if (fs.existsSync(SESSIONS_DIR)) {
26
+ projectDirs = fs.readdirSync(SESSIONS_DIR)
27
+ .filter(d => fs.statSync(path.join(SESSIONS_DIR, d)).isDirectory());
28
+ for (const dir of projectDirs) {
29
+ const files = fs.readdirSync(path.join(SESSIONS_DIR, dir))
30
+ .filter(f => f.endsWith('.jsonl'));
31
+ totalFiles += files.length;
32
+ }
16
33
  }
17
- };
18
34
 
19
- sendUserMessage('🔍 Indexing session history...');
35
+ ctx.ui.notify(`📁 Found ${totalFiles} session files across ${projectDirs.length} projects\n⏳ Indexing...`, 'info');
20
36
 
21
- try {
22
37
  const memoryDir = path.join(os.homedir(), '.pi', 'agent', 'memory');
23
38
  const dbManager = new DatabaseManager(memoryDir);
24
39
 
@@ -28,36 +43,42 @@ export function registerIndexSessionsCommand(pi: ExtensionAPI): void {
28
43
 
29
44
  let output = `\n✅ Session indexing complete!\n\n`;
30
45
  output += `📊 Results:\n`;
31
- output += `• Sessions processed: ${result.sessionsProcessed}\n`;
32
- output += `• Sessions indexed: ${result.sessionsIndexed}\n`;
33
- output += `• Sessions skipped (already indexed): ${result.sessionsSkipped}\n`;
34
- output += `• Messages indexed: ${result.messagesIndexed}\n`;
46
+ output += `├─ Sessions processed: ${result.sessionsProcessed}\n`;
47
+ output += `├─ Sessions indexed: ${result.sessionsIndexed}\n`;
48
+ output += `├─ Sessions skipped (already indexed): ${result.sessionsSkipped}\n`;
49
+ output += `└─ Messages indexed: ${result.messagesIndexed}\n`;
35
50
 
36
51
  if (stats.projects.length > 0) {
37
- output += `\n📁 Projects:\n`;
52
+ output += `\n📁 Projects indexed:\n`;
38
53
  for (const p of stats.projects) {
39
- output += `• ${p.project}: ${p.sessions} sessions, ${p.messages} messages\n`;
54
+ output += `├─ ${p.project}: ${p.sessions} sessions, ${p.messages} messages\n`;
40
55
  }
41
56
  }
42
57
 
58
+ // Show totals
59
+ output += `\n📈 Database totals:\n`;
60
+ output += `├─ ${stats.totalSessions} sessions\n`;
61
+ output += `├─ ${stats.totalMessages} messages\n`;
62
+ output += `└─ ${stats.projects.length} projects\n`;
63
+
43
64
  if (result.errors.length > 0) {
44
65
  output += `\n⚠️ Errors (${result.errors.length}):\n`;
45
- for (const err of result.errors.slice(0, 5)) {
46
- output += `• ${err}\n`;
66
+ for (const err of result.errors.slice(0, 3)) {
67
+ output += `├─ ${err}\n`;
47
68
  }
48
- if (result.errors.length > 5) {
49
- output += `• ... and ${result.errors.length - 5} more\n`;
69
+ if (result.errors.length > 3) {
70
+ output += `└─ ... and ${result.errors.length - 3} more\n`;
50
71
  }
51
72
  }
52
73
 
53
- output += `\n💡 Use the \`session_search\` tool to search across indexed sessions.`;
74
+ output += `\n💡 Use the session_search tool to search across indexed sessions.`;
54
75
 
55
- sendUserMessage(output);
76
+ ctx.ui.notify(output, 'info');
56
77
  } finally {
57
78
  dbManager.close();
58
79
  }
59
80
  } catch (err) {
60
- sendUserMessage(`❌ Session indexing failed: ${err instanceof Error ? err.message : String(err)}`);
81
+ ctx.ui.notify(`❌ Session indexing failed: ${err instanceof Error ? err.message : String(err)}`, 'error');
61
82
  }
62
83
  },
63
84
  });
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Learn memory tool command — /learn-memory-tool teaches users about the memory system.
3
+ */
4
+
5
+ import type { ExtensionAPI, ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
6
+
7
+ const LEARN_MEMORY_CONTENT = `# Pi Hermes Memory — Quick Guide
8
+
9
+ ## What Gets Saved
10
+
11
+ | Type | File | What Goes Here | Limit |
12
+ |---|---|---|---|
13
+ | **Memory** | MEMORY.md | Facts — env details, project conventions, tool quirks | 5,000 chars |
14
+ | **User Profile** | USER.md | Who you are — name, preferences, communication style | 5,000 chars |
15
+ | **Skills** | skills/*.md | Procedures — how to debug, deploy, test | Unlimited |
16
+ | **Extended Memory** | sessions.db | Searchable memories beyond the core limit | Unlimited |
17
+
18
+ ## Tools Available
19
+
20
+ | Tool | What It Does |
21
+ |---|---|
22
+ | memory (add/replace/remove) | Save, update, or delete memories |
23
+ | skill (create/view/patch/edit/delete) | Save reusable procedures |
24
+ | session_search | Search past conversations across all sessions |
25
+ | memory_search | Search extended memory store (unlimited) |
26
+
27
+ ## Commands
28
+
29
+ | Command | What It Does |
30
+ |---|---|
31
+ | /memory-insights | Shows everything stored in memory |
32
+ | /memory-skills | Lists all saved skills |
33
+ | /memory-consolidate | Manually trigger memory cleanup |
34
+ | /memory-interview | Answer questions to pre-fill your profile |
35
+ | /memory-switch-project | List all project memories |
36
+ | /memory-index-sessions | Import past sessions for search |
37
+
38
+ ## Best Practices
39
+
40
+ **DO save:**
41
+ - User preferences ("prefers pnpm", "uses vim", "likes concise answers")
42
+ - Environment facts ("macOS M1", "Node 20", "project uses Prisma")
43
+ - Corrections ("don't use npm — use pnpm", "always run tests first")
44
+ - Project conventions ("monorepo with turborepo", "conventional commits")
45
+
46
+ **DON'T save:**
47
+ - Task progress ("finished implementing auth") — temporary
48
+ - Session outcomes ("PR #42 was merged") — belongs in git history
49
+ - Temporary state ("currently debugging X") — will be irrelevant soon
50
+
51
+ ## How Memory Flows
52
+
53
+ 1. Session starts → Core memory injected into system prompt
54
+ 2. During conversation → Agent saves via memory tool
55
+ 3. Every 10 turns → Background review saves noteworthy items
56
+ 4. On correction → Immediate save
57
+ 5. When full → Auto-consolidation merges entries
58
+ 6. Session ends → Final flush
59
+
60
+ ## Two-Tier Architecture
61
+
62
+ - Global (always injected): ~/.pi/agent/memory/ — your name, preferences, tools
63
+ - Project (when cwd matches): ~/.pi/agent/<project>/ — project-specific facts
64
+
65
+ ## Troubleshooting
66
+
67
+ - "Memory is full" → /memory-consolidate to merge entries
68
+ - "Can't find something" → memory_search to search extended store
69
+ - "Agent forgot something" → Check /memory-insights, tell agent "remember that X"
70
+ - "Want to edit manually" → Files are plain markdown at ~/.pi/agent/memory/`;
71
+
72
+ export function registerLearnMemoryCommand(pi: ExtensionAPI): void {
73
+ pi.registerCommand("learn-memory-tool", {
74
+ description: "Learn how to use the pi-hermes-memory extension effectively",
75
+ handler: async (_args, ctx: ExtensionCommandContext) => {
76
+ ctx.ui.notify(LEARN_MEMORY_CONTENT, 'info');
77
+ },
78
+ });
79
+ }
package/src/index.ts CHANGED
@@ -44,6 +44,7 @@ import { registerSkillsCommand } from "./handlers/skills-command.js";
44
44
  import { registerInterviewCommand } from "./handlers/interview.js";
45
45
  import { registerSwitchProjectCommand } from "./handlers/switch-project.js";
46
46
  import { registerIndexSessionsCommand } from "./handlers/index-sessions.js";
47
+ import { registerLearnMemoryCommand } from "./handlers/learn-memory.js";
47
48
  import { loadConfig } from "./config.js";
48
49
  import { detectProject } from "./project.js";
49
50
 
@@ -118,6 +119,7 @@ export default function (pi: ExtensionAPI) {
118
119
  registerSkillsCommand(pi, skillStore);
119
120
  registerInterviewCommand(pi, store);
120
121
  registerSwitchProjectCommand(pi);
122
+ registerLearnMemoryCommand(pi);
121
123
 
122
124
  // ── 11. SQLite session search + extended memory ──
123
125
  registerSessionSearchTool(pi, dbManager);
@@ -1,125 +0,0 @@
1
- ---
2
- name: learn-memory-tool
3
- description: Learn how to use the pi-hermes-memory extension effectively — when to save memories, how to search, and best practices for persistent memory.
4
- version: 1
5
- created: 2026-05-03
6
- updated: 2026-05-03
7
- ---
8
-
9
- ## When to Use
10
-
11
- When a user asks about the memory system, how to use it, or when they seem confused about what gets remembered. Also useful for onboarding new users to the extension.
12
-
13
- ## Overview
14
-
15
- Pi Hermes Memory gives your AI agent persistent memory across sessions. Here's what it does:
16
-
17
- ### What Gets Saved
18
-
19
- | Type | File | What Goes Here | Limit |
20
- |---|---|---|---|
21
- | **Memory** | `MEMORY.md` | Facts — env details, project conventions, tool quirks | 5,000 chars |
22
- | **User Profile** | `USER.md` | Who you are — name, preferences, communication style | 5,000 chars |
23
- | **Skills** | `skills/*.md` | Procedures — *how* to debug, deploy, test | Unlimited |
24
- | **Extended Memory** | `sessions.db` | Searchable memories beyond the core limit | Unlimited |
25
-
26
- ### The `memory` Tool
27
-
28
- The agent has a `memory` tool with these actions:
29
-
30
- | Action | Target | What It Does |
31
- |---|---|---|
32
- | `add` | `memory` or `user` | Append a new entry |
33
- | `replace` | `memory` or `user` | Update an existing entry (matched by substring) |
34
- | `remove` | `memory` or `user` | Delete an entry (matched by substring) |
35
-
36
- ### The `skill` Tool
37
-
38
- For saving reusable procedures:
39
-
40
- | Action | What It Does |
41
- |---|---|
42
- | `create` | Save a new skill |
43
- | `view` | Read a skill or list all skills |
44
- | `patch` | Update one section of a skill |
45
- | `edit` | Replace description and/or body |
46
- | `delete` | Remove a skill |
47
-
48
- ### Search Tools
49
-
50
- | Tool | What It Does |
51
- |---|---|
52
- | `session_search` | Search past conversations across all sessions |
53
- | `memory_search` | Search extended memory store (unlimited capacity) |
54
-
55
- ### Commands
56
-
57
- | Command | What It Does |
58
- |---|---|
59
- | `/memory-insights` | Shows everything stored in memory and user profile |
60
- | `/memory-skills` | Lists all agent-created skills |
61
- | `/memory-consolidate` | Manually trigger memory consolidation |
62
- | `/memory-interview` | Answer questions to pre-fill your user profile |
63
- | `/memory-switch-project` | List all project memories |
64
- | `/memory-index-sessions` | Import past sessions for search |
65
-
66
- ## Best Practices
67
-
68
- ### What TO Save
69
-
70
- - **User preferences**: "prefers pnpm over npm", "uses vim", "likes concise answers"
71
- - **Environment facts**: "macOS M1", "Node 20", "project uses Prisma"
72
- - **Corrections**: "don't use npm — use pnpm", "always run tests first"
73
- - **Project conventions**: "monorepo with turborepo", "conventional commits"
74
- - **Tool quirks**: "CI needs `--frozen-lockfile`", "deploy script is in scripts/deploy.sh"
75
-
76
- ### What NOT to Save
77
-
78
- - **Task progress**: "finished implementing auth" — this is temporary
79
- - **Session outcomes**: "PR #42 was merged" — this belongs in git history
80
- - **Temporary state**: "currently debugging the test failure" — will be irrelevant soon
81
- - **Large code blocks**: Use skills instead for procedures
82
-
83
- ### How Memory Flows
84
-
85
- 1. **Session starts**: Core memory (MEMORY.md + USER.md) is injected into the system prompt
86
- 2. **During conversation**: Agent saves memories via the `memory` tool
87
- 3. **Every 10 turns or 15 tool calls**: Background review saves anything noteworthy
88
- 4. **When you correct the agent**: Immediate save — no waiting
89
- 5. **When memory is full**: Auto-consolidation merges and prunes entries
90
- 6. **Session ends**: One last flush before shutdown
91
-
92
- ### Two-Tier Architecture
93
-
94
- - **Global memory** (`~/.pi/agent/memory/`): Always injected — your name, preferences, tools
95
- - **Project memory** (`~/.pi/agent/<project>/`): Injected when cwd matches — project-specific facts
96
-
97
- ### Memory Aging
98
-
99
- Entries carry timestamps. When consolidating, the agent knows which entries are stale (created long ago, never referenced) and which are fresh.
100
-
101
- ### Context Fencing
102
-
103
- Memory is wrapped in `<memory-context>` XML tags so the LLM never treats stored facts as user instructions. This prevents injection attacks through stored memory.
104
-
105
- ## Troubleshooting
106
-
107
- ### "Memory is full"
108
- Run `/memory-consolidate` to manually merge entries. Or let auto-consolidation handle it.
109
-
110
- ### "I can't find what I'm looking for"
111
- Use `memory_search` to search the extended store, or `session_search` to search past conversations.
112
-
113
- ### "The agent forgot something"
114
- Check `/memory-insights` to see what's stored. If it's not there, the agent may not have saved it yet. You can tell the agent: "remember that X".
115
-
116
- ### "I want to edit memory manually"
117
- Memory files are plain markdown at `~/.pi/agent/memory/MEMORY.md` and `USER.md`. Edit them directly if you want.
118
-
119
- ## Verification
120
-
121
- After reading this skill, the user should understand:
122
- 1. What the memory tool does and when to use it
123
- 2. The difference between memory, user profile, skills, and extended memory
124
- 3. How to search across sessions and extended memory
125
- 4. Best practices for what to save and what not to save