@aman_asmuei/amem 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +174 -702
  2. package/package.json +13 -3
package/README.md CHANGED
@@ -1,791 +1,263 @@
1
- <div align="center">
1
+ # amem
2
2
 
3
- # Aman AI Memory
3
+ The memory layer for AI coding tools. Local-first. Developer-specific. Works everywhere.
4
4
 
5
- **Persistent AI memory in markdown files. Multi-user ready.**
6
- **Works with any AI. Auto-integrates with Claude Code.**
5
+ [![npm version](https://img.shields.io/npm/v/@aman_asmuei/amem.svg)](https://www.npmjs.com/package/@aman_asmuei/amem)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
7
 
8
- [![Claude Code](https://img.shields.io/badge/Claude_Code-Ready-6C5CE7?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJ3aGl0ZSI+PHBhdGggZD0iTTEyIDJDNi40OCAyIDIgNi40OCAyIDEyczQuNDggMTAgMTAgMTAgMTAtNC40OCAxMC0xMFMxNy41MiAyIDEyIDJ6bTAgMThjLTQuNDEgMC04LTMuNTktOC04czMuNTktOCA4LTggOCAzLjU5IDggOC0zLjU5IDgtOCA4eiIvPjwvc3ZnPg==)](https://claude.ai/claude-code)
9
- [![Markdown](https://img.shields.io/badge/Storage-Markdown-000000?style=for-the-badge&logo=markdown)](https://en.wikipedia.org/wiki/Markdown)
10
- [![License](https://img.shields.io/badge/License-Open_Source-2ECC71?style=for-the-badge)](#credits)
8
+ > Your AI forgets everything between conversations. amem fixes that.
11
9
 
12
- <br>
13
-
14
- *Your AI remembers you across conversations — your name, preferences, projects, and decisions.*
15
- *No database. No API keys. No setup complexity. Just markdown.*
16
-
17
- </div>
18
-
19
- ---
20
-
21
- ## What Is This?
22
-
23
- Every time you start a new conversation with an AI (ChatGPT, Claude, Gemini), it forgets everything about you. Your name, your projects, your preferences — gone.
24
-
25
- **Aman AI Memory fixes this.** It gives your AI a set of files where it stores what it learns about you. Next conversation, it reads those files and picks up right where you left off.
26
-
27
- - **It remembers your name** and how you like to work
28
- - **It tracks your projects** and decisions you've made
29
- - **It learns your style** over time, adapting to your preferences
30
- - **It works with any AI** — Claude Code has full automation, others work with copy-paste
31
- - **Your data stays on your computer** — no cloud, no accounts, just plain text files
32
-
33
- ---
34
-
35
- ## Quick Start
36
-
37
- ### Install (one-liner)
10
+ ## Install
38
11
 
39
12
  ```bash
40
- curl -fsSL https://raw.githubusercontent.com/amanasmuei/aman-ai-memory/main/get.sh | bash
13
+ npx @aman_asmuei/amem
41
14
  ```
42
15
 
43
- Downloads everything, initializes a fresh git repo, and launches the guided setup wizard. Just answer a few questions — pick from numbered choices or press Enter for defaults.
16
+ ## What it does
44
17
 
45
- > [!TIP]
46
- > No terminal experience needed. Git is installed automatically as part of setup. Each install gets its own clean git history — no template commits carried over.
18
+ amem is an MCP server that gives any AI assistant persistent memory about:
47
19
 
48
- <details>
49
- <summary><strong>Install into a specific folder</strong></summary>
20
+ - **Corrections** — "Don't mock the database in integration tests" *(highest priority, always surfaced)*
21
+ - **Decisions** "Chose Postgres over MongoDB because of ACID requirements"
22
+ - **Patterns** — "User prefers early returns over nested conditionals"
23
+ - **Preferences** — "Uses pnpm, not npm"
24
+ - **Topology** — "Auth module lives in src/auth/, uses JWT"
25
+ - **Facts** — "Project started in January 2025"
50
26
 
51
- <br>
27
+ Memories are ranked by **relevance x recency x confidence x importance**. Corrections always surface first. Old memories decay. Contradictions are detected. Related memories evolve together.
52
28
 
53
- ```bash
54
- # Custom folder name
55
- curl -fsSL https://raw.githubusercontent.com/amanasmuei/aman-ai-memory/main/get.sh | bash -s -- my-project/ai-memory
56
-
57
- # Or clone and run the wizard (init.sh replaces template history with a fresh repo)
58
- git clone https://github.com/amanasmuei/aman-ai-memory.git
59
- cd aman-ai-memory && ./init.sh
60
- ```
61
-
62
- </details>
63
-
64
- <details>
65
- <summary><strong>Already have the files?</strong> — just run the wizard</summary>
29
+ ## Quick start
66
30
 
67
- <br>
31
+ ### Claude Code
68
32
 
69
- ```bash
70
- ./init.sh
71
- ```
72
-
73
- Or run the steps separately:
33
+ Add to `~/.claude/settings.json`:
74
34
 
75
- ```bash
76
- ./setup.sh # Fill in memory.md only
77
- ./install.sh # Install hooks into host project only
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "amem": {
39
+ "command": "npx",
40
+ "args": ["-y", "@aman_asmuei/amem"]
41
+ }
42
+ }
43
+ }
78
44
  ```
79
45
 
80
- </details>
46
+ ### Cursor
81
47
 
82
- ---
48
+ Add to `.cursor/mcp.json`:
83
49
 
84
- ## Your First Conversation
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "amem": {
54
+ "command": "npx",
55
+ "args": ["-y", "@aman_asmuei/amem"]
56
+ }
57
+ }
58
+ }
59
+ ```
85
60
 
86
- There are two ways to get started — pick whichever feels more comfortable:
61
+ ### Any MCP client
87
62
 
88
- ### Option A: Just start talking (recommended for beginners)
63
+ amem speaks standard MCP over stdio. Any client that supports MCP can connect.
89
64
 
90
- 1. **Open Claude Code** in your project folder
91
- 2. **Say hello** — the AI detects this is your first time and walks you through setup
92
- 3. **Answer a few questions** — your name, what you work on, what to call the AI
93
- 4. **Done!** The AI remembers you from now on
65
+ ## Tools
94
66
 
95
- The AI asks questions conversationally, 2-3 at a time. No forms, no commands — just a friendly chat.
67
+ ### `memory_store`
96
68
 
97
- ### Option B: Run the setup wizard first
69
+ Store a typed memory with tags and confidence scoring.
98
70
 
99
- ```bash
100
- ./init.sh
101
71
  ```
102
-
103
- The wizard asks the same questions with numbered choices. Good if you prefer filling things in quickly before your first conversation.
104
-
105
- ### After Setup
106
-
107
- 1. **Chat normally** — the AI quietly takes notes as you work together
108
- 2. **Say "save"** before ending important sessions — this tells the AI to remember what it learned
109
- 3. **Next time**, the AI greets you by name and remembers everything from before
110
-
111
- That's it. No commands to memorize. Just talk naturally and say "save" when it matters.
112
-
113
- > [!TIP]
114
- > **Using ChatGPT, Gemini, or another AI?** At the start of each conversation, paste: *"Read memory.md and session.md, then follow the instructions in CLAUDE.md."* At the end, say: *"Save progress."*
115
-
116
- ---
117
-
118
- ## Quick Reference
119
-
120
- **Things you can say to the AI:**
121
-
122
- | Say this | What happens |
123
- | --- | --- |
124
- | *(just start talking)* | AI loads your memory and continues where you left off |
125
- | **"save"** | AI saves what it learned — patterns, decisions, projects |
126
- | **"write diary entry"** | AI creates a dated log of today's session |
127
- | **"plan"** | AI creates a work plan with checkboxes to track |
128
- | *"what did we decide about X?"* | AI searches its memory and diary for past context |
129
-
130
- **Scripts you can run in the terminal (optional — the AI handles most of this):**
131
-
132
- | Command | What it does |
133
- | --- | --- |
134
- | `./recall.sh <word>` | Search all memory files for a keyword |
135
- | `./archive.sh` | Clean up old entries when memory gets full |
136
- | `./add-user.sh <name>` | Add another person's profile |
137
- | `./switch-user.sh` | Switch between profiles |
138
- | `./setup.sh` | Reconfigure your AI's name and personality |
139
-
140
- ---
141
-
142
- ## Project Structure
143
-
144
- <details>
145
- <summary>Click to view all files</summary>
146
-
147
- <br>
148
-
149
- ```text
150
- aman-ai-memory/
151
-
152
- ├── memory.md Your AI's long-term memory (identity, patterns, decisions)
153
- ├── session.md Current conversation notes (resets each time)
154
- ├── plans.md Work plans with checkboxes (created when you say "plan")
155
- ├── diary/ Daily session logs (optional)
156
- ├── archive/ Old entries moved here to keep memory lean
157
-
158
- ├── CLAUDE.md Instructions the AI follows automatically
159
- ├── .claude/
160
- │ └── settings.json Automation hooks (runs behind the scenes)
161
-
162
- ├── get.sh Remote installer (the curl one-liner)
163
- ├── init.sh Setup wizard (start here)
164
- ├── setup.sh Configure your AI's identity
165
- ├── install.sh Install into an existing project
166
- ├── auto-save.sh Saves your notes when conversation ends
167
- ├── reset-session.sh Prepares a fresh session on start
168
- ├── validate-memory.sh Checks memory files aren't corrupted
169
- ├── archive.sh Moves old entries to archive
170
- ├── recall.sh Searches memory for past context
171
- ├── add-user.sh Adds a new user profile
172
- ├── switch-user.sh Switches between user profiles
173
-
174
- ├── profiles/ Per-user data (multi-user mode only)
175
- │ └── <name>/
176
- │ ├── memory.md
177
- │ ├── session.md
178
- │ └── diary/
179
- └── archive/ Archived entries (created by archive.sh)
72
+ memory_store({
73
+ content: "Never use 'any' type always define proper interfaces",
74
+ type: "correction",
75
+ tags: ["typescript", "types"],
76
+ confidence: 1.0
77
+ })
180
78
  ```
181
79
 
182
- </details>
183
-
184
- ---
185
-
186
- ## How It Works
187
-
188
- Here's what happens behind the scenes during each conversation:
189
-
190
- ### Conversation Lifecycle
191
-
192
- ```text
193
- ┌──────────────────────────────────────────────────────────────┐
194
- │ SESSION START │
195
- │ ┌─────────────┐ ┌────────────────┐ ┌────────────────┐ │
196
- │ │ Load memory │──▶│ Reset session │──▶│ Ready to work │ │
197
- │ │ + archive │ │ + inject time │ │ (time-aware) │ │
198
- │ └─────────────┘ │ + archive diary│ └───────┬────────┘ │
199
- │ └────────────────┘ │ │
200
- │ DURING SESSION ▼ │
201
- │ ┌───────────────────────────────────────────────────────┐ │
202
- │ │ AI updates Working Notes as you make progress │ │
203
- │ │ AI can recall past context from diary and archive │ │
204
- │ │ You say "save" for intelligent save (optional) │ │
205
- │ │ You say "plan" to create a tracked work plan │ │
206
- │ └───────────────────────────────────┬───────────────────┘ │
207
- │ │ │
208
- │ SESSION END ▼ │
209
- │ ┌──────────────┐ ┌────────────────────────────────────┐ │
210
- │ │ Auto-save │──▶│ Working Notes → Summary │ │
211
- │ │ (mechanical) │ │ Ready for next session │ │
212
- │ └──────────────┘ └────────────────────────────────────┘ │
213
- └──────────────────────────────────────────────────────────────┘
214
- ```
80
+ ### `memory_recall`
215
81
 
216
- | Step | When | What Happens |
217
- | --- | --- | --- |
218
- | **Load** | Conversation starts | AI reads `memory.md` + `session.md` + `archive/memory-archive.md` |
219
- | **Reset** | Conversation starts | Session resets, injects current time, archives old diary months |
220
- | **Adapt** | Conversation starts | AI adapts tone to time of day (morning/afternoon/evening/night) |
221
- | **Work** | During conversation | AI updates Working Notes, can recall from diary and archive |
222
- | **Plan** | User says "plan" | AI creates or updates `plans.md` with tracked checkboxes |
223
- | **Save** | User says "save" | AI saves patterns, decisions, projects (max 10), archives old entries |
224
- | **Auto-save** | Conversation ends | Working Notes copied to summary mechanically |
225
- | **Validate** | After every edit | Checks structure, size limits (200/500 lines), and append-only rules |
226
-
227
- ---
228
-
229
- ### Two Types of Save
230
-
231
- <table>
232
- <tr>
233
- <th width="200"></th>
234
- <th width="350">Auto-save (on exit)</th>
235
- <th width="350">Manual save (user says "save")</th>
236
- </tr>
237
- <tr>
238
- <td><strong>What</strong></td>
239
- <td>Copies Working Notes to End-of-Session Summary</td>
240
- <td>Updates patterns, decisions, projects, summary</td>
241
- </tr>
242
- <tr>
243
- <td><strong>How</strong></td>
244
- <td>Bash script — no AI involved</td>
245
- <td>AI with full conversation context</td>
246
- </tr>
247
- <tr>
248
- <td><strong>Cost</strong></td>
249
- <td>0 tokens, instant</td>
250
- <td>Normal AI usage</td>
251
- </tr>
252
- <tr>
253
- <td><strong>When</strong></td>
254
- <td>Every exit, automatically</td>
255
- <td>When you explicitly ask</td>
256
- </tr>
257
- <tr>
258
- <td><strong>Best for</strong></td>
259
- <td>Preserving context between sessions</td>
260
- <td>Recording long-term patterns and decisions</td>
261
- </tr>
262
- </table>
263
-
264
- ---
265
-
266
- ### What Each File Stores
267
-
268
- | File | What Goes Here | Who Updates It | Resets? |
269
- | --- | --- | --- | --- |
270
- | `memory.md` | AI identity, user profile, learned patterns, decision log, projects (max 10) | You (setup) + AI (save) | Never — grows over time |
271
- | `session.md` | Previous recap, time context, goals, working notes, session summary | AI during conversation | Every conversation |
272
- | `diary/YYYY-MM-DD.md` | Daily session logs | AI when you ask | Never — append-only |
273
- | `archive/memory-archive.md` | Archived decisions and completed projects | AI (during archive) | Never — append-only |
274
- | `plans.md` | Active work plans with checkboxes | AI when you say "plan" | When plans complete |
275
-
276
- ---
277
-
278
- ## Detailed Setup Guide
279
-
280
- ### All-in-One (Recommended)
82
+ Semantic search across all memories. Returns results ranked by composite score.
281
83
 
282
- ```bash
283
- curl -fsSL https://raw.githubusercontent.com/amanasmuei/aman-ai-memory/main/get.sh | bash
284
84
  ```
285
-
286
- The installer downloads everything and launches the guided wizard. It handles:
287
-
288
- - Single-user or multi-user mode selection
289
- - Friendly questions with numbered choices (pick 1, 2, 3...)
290
- - Sensible defaults (press Enter to skip)
291
- - Auto-detects if you're in a subfolder and offers to install hooks
292
- - Initializes a fresh git repo (no template history carried over)
293
- - Shows a summary when done
294
-
295
- > [!TIP]
296
- > **You can skip the wizard entirely.** If you prefer, just open Claude Code and start talking — the AI will walk you through setup conversationally on your first conversation. See [Your First Conversation](#your-first-conversation).
297
-
298
- ### Adding to an Existing Project
299
-
300
- ```bash
301
- # Download into your project
302
- curl -fsSL https://raw.githubusercontent.com/amanasmuei/aman-ai-memory/main/get.sh | bash -s -- my-project/ai-memory
303
-
304
- # Run the wizard
305
- cd my-project/ai-memory && ./init.sh
85
+ memory_recall({
86
+ query: "TypeScript best practices",
87
+ limit: 5
88
+ })
306
89
  ```
307
90
 
308
- > [!NOTE]
309
- > The wizard auto-detects that you're inside another project and offers to install hooks for you.
310
-
311
- ### Other AI Platforms (ChatGPT, Gemini, etc.)
312
-
313
- <details>
314
- <summary>Click to expand</summary>
315
-
316
- <br>
317
-
318
- The auto-save and validation hooks are Claude Code specific. For other platforms:
319
-
320
- 1. Run `./init.sh` to fill in `memory.md` (or edit `memory.md` directly — replace the `[AI_NAME]` and `[YOUR_NAME]` placeholders with your details)
321
- 2. At the **start** of each conversation, paste:
322
-
323
- > Read memory.md and session.md, then follow the instructions in CLAUDE.md for how to manage memory during our session.
324
-
325
- 3. At the **end** of each conversation, say:
326
-
327
- > Save progress to memory.md and session.md.
328
-
329
- No automation, but the memory files work the same way.
330
-
331
- </details>
332
-
333
- ---
334
-
335
- ## Usage Guide
336
-
337
- ### Day-to-Day Workflow
338
-
339
- | What You Want | What To Do |
340
- | --- | --- |
341
- | Start a conversation | Just start — AI loads memory automatically |
342
- | Save important context | Say **"save"** |
343
- | Write a diary entry | Say **"write diary entry"** |
344
- | Create a work plan | Say **"plan"** — AI creates `plans.md` with checkboxes |
345
- | Search past context | Run **`./recall.sh <keyword>`** or ask the AI |
346
- | Exit without saving | Just exit — Working Notes are auto-saved |
347
- | Archive old entries | Run **`./archive.sh`** or say "save" (AI archives automatically) |
348
- | Add a team member | Run **`./add-user.sh <name>`** |
349
- | Switch user profile | Run **`./switch-user.sh <name>`** |
350
-
351
- ### Tips for Best Results
352
-
353
- > [!IMPORTANT]
354
- > Say **"save"** before ending important sessions. Auto-save preserves your working notes, but only manual save captures learned patterns and decisions intelligently.
355
-
356
- 1. **Be explicit about decisions.** Say *"let's go with approach X because Y"* — the AI will log it in the Decision Log when you save.
357
-
358
- 2. **Review `memory.md` occasionally.** Check that learned patterns and decisions are accurate. Delete anything wrong.
359
-
360
- 3. **Keep it under 200 lines.** Run `./archive.sh` when it grows, or just say "save" — the AI archives automatically when approaching the limit.
361
-
362
- ---
363
-
364
- ### What the AI Remembers
365
-
366
- After a few sessions, `memory.md` will contain:
367
-
368
- | Section | Example |
369
- | --- | --- |
370
- | **Learned Patterns** | *"Prefers concise answers"*, *"Always wants tests before merging"* |
371
- | **Decision Log** | *"Chose PostgreSQL over MongoDB — relational data needs"* |
372
- | **Active Projects** | *"API rewrite — in progress — migrating from REST to GraphQL"* |
373
-
374
- This context is loaded at the start of every conversation, so the AI picks up where you left off.
375
-
376
- ---
377
-
378
- ## Validation
379
-
380
- Every edit to memory files is automatically checked in the background. You don't need to do anything — if something goes wrong, the AI is told to fix it.
381
-
382
- <details>
383
- <summary>View all validation checks</summary>
384
-
385
- <br>
386
-
387
- | Check | What It Catches |
388
- | --- | --- |
389
- | Required sections | AI accidentally deleted a section heading |
390
- | Table format | Decision Log or Active Projects lost their table structure |
391
- | Placeholder check | `[AI_NAME]` still present — setup not complete (AI will guide you through it) |
392
- | Size guard | `memory.md` over 200 lines or `session.md` over 500 lines |
393
- | Append-only integrity | Learned Patterns or Decision Log entries were deleted |
394
- | Session structure | `session.md` missing required sections |
395
- | Diary format | Wrong filename, missing fields, missing session header |
396
-
397
- </details>
398
-
399
- ---
400
-
401
- ## Diary Format
402
-
403
- <details>
404
- <summary>View diary entry template</summary>
405
-
406
- <br>
407
-
408
- One file per day (`diary/YYYY-MM-DD.md`), multiple entries appended. Never edit past entries.
409
-
410
- ```markdown
411
- ## Session — HH:MM
412
- **Topics**: [comma-separated]
413
- **Summary**: [1-2 sentences]
414
- **Decisions**: [any choices made]
415
- **Learned**: [new user patterns discovered]
416
- ---
91
+ Returns:
417
92
  ```
93
+ 1. [correction] Never use 'any' type — always define proper interfaces
94
+ Score: 0.892 | Confidence: 100% | Age: 2d ago
418
95
 
419
- Previous months are automatically archived to `diary/archive/YYYY-MM/` at the start of each conversation.
420
-
421
- </details>
422
-
423
- ---
424
-
425
- ## Multi-User
426
-
427
- For teams or shared machines where multiple people need their own AI memory.
428
-
429
- ### Getting Started
430
-
431
- **During initial setup** — the wizard asks "Just me" or "Multiple people":
96
+ 2. [pattern] User prefers strict TypeScript with no implicit any
97
+ Score: 0.756 | Confidence: 85% | Age: 5d ago
98
+ ```
432
99
 
433
- ```text
434
- How will this be used?
100
+ ### `memory_context`
435
101
 
436
- 1) Just me single user
437
- 2) Multiple people — shared project
102
+ Load full context for a topic. Groups by type with corrections first.
438
103
 
439
- Pick one [1]: 2
440
- Your profile name [aman]:
104
+ ```
105
+ memory_context({
106
+ topic: "authentication system",
107
+ max_tokens: 2000
108
+ })
441
109
  ```
442
110
 
443
- Each user gets an isolated profile with their own `memory.md`, `session.md`, and `diary/`.
111
+ Returns:
112
+ ```markdown
113
+ ## Context for: authentication system
444
114
 
445
- ### Adding Users Later
115
+ ### Corrections
116
+ - Never store JWT secrets in environment variables (100% confidence)
446
117
 
447
- Already running single-user? No problem — `add-user.sh` migrates your data automatically:
118
+ ### Decisions
119
+ - Chose OAuth2 + PKCE for the auth flow (90% confidence)
448
120
 
449
- ```bash
450
- ./add-user.sh alice
121
+ ### Topology
122
+ - Auth module is in src/auth/, middleware in src/middleware/auth.ts (85% confidence)
451
123
  ```
452
124
 
453
- > [!NOTE]
454
- > The first time you add a user, the script asks for a name for your **existing** profile so your data is preserved. After that, it simply creates a new empty profile.
125
+ ### `memory_extract`
455
126
 
456
- ### Switching Profiles
127
+ Batch-extract memories from a conversation. The AI calls this proactively.
457
128
 
458
- ```bash
459
- ./switch-user.sh # Interactive — lists all profiles, pick one
460
- ./switch-user.sh alice # Switch directly
461
129
  ```
462
-
463
- After switching, all scripts, hooks, and AI instructions work with the new profile — no reconfiguration needed.
464
-
465
- ### How It Works
466
-
467
- Root files (`memory.md`, `session.md`, `diary/`) become **symlinks** to the active profile. This means zero changes to CLAUDE.md, hooks, or AI workflows.
468
-
469
- ```text
470
- aman-ai-memory/
471
- ├── memory.md → profiles/aman/memory.md (symlink)
472
- ├── session.md → profiles/aman/session.md (symlink)
473
- ├── diary → profiles/aman/diary (symlink)
474
-
475
- └── profiles/
476
- ├── aman/
477
- │ ├── memory.md ← AI reads/writes here when aman is active
478
- │ ├── session.md
479
- │ ├── diary/
480
- │ └── archive/
481
- └── alice/
482
- ├── memory.md
483
- ├── session.md
484
- ├── diary/
485
- └── archive/
130
+ memory_extract({
131
+ memories: [
132
+ { content: "Don't mock the DB in integration tests", type: "correction", confidence: 1.0, tags: ["testing"] },
133
+ { content: "Chose event sourcing for audit trail", type: "decision", confidence: 0.9, tags: ["architecture"] }
134
+ ]
135
+ })
486
136
  ```
487
137
 
488
- ### Multi-User Commands
489
-
490
- | Command | What It Does |
491
- | --- | --- |
492
- | `./add-user.sh <name>` | Create a new profile (migrates single-user data if needed) |
493
- | `./switch-user.sh` | List profiles and switch interactively |
494
- | `./switch-user.sh <name>` | Switch to a specific profile directly |
495
- | `./setup.sh` | Reconfigure the **active** profile's identity and preferences |
496
-
497
- ---
498
-
499
- ## Archiving
500
-
501
- AI context windows have limits. When `memory.md` exceeds ~200 lines, details in the middle get lost. The archiving system keeps your memory lean while preserving history.
138
+ Automatically deduplicates — if a memory is >85% similar to an existing one, it reinforces the existing memory instead of creating a duplicate.
502
139
 
503
- ### What Gets Archived
140
+ ### `memory_forget`
504
141
 
505
- | Entry Type | Trigger | Example |
506
- | --- | --- | --- |
507
- | **Completed projects** | Status is *done*, *completed*, *shipped*, *cancelled*, or *closed* | `API rewrite — Completed — shipped to prod` |
508
- | **Old decisions** | Date older than 90 days (configurable) | `2024-11-01 — Chose PostgreSQL over MongoDB` |
142
+ Delete specific memories or search-and-delete with confirmation.
509
143
 
510
- Archived entries move to `archive/memory-archive.md`.
511
-
512
- > [!IMPORTANT]
513
- > **Archived memories are NOT lost.** The AI loads the archive file at the start of every conversation alongside `memory.md`. You don't need to do anything — old decisions and completed projects are still recalled automatically.
514
-
515
- ### How Recall Works
516
-
517
- ```text
518
- Conversation starts
519
-
520
- ├─ 1. Read memory.md ← active memory (always loaded)
521
- ├─ 2. Read session.md ← last session recap (always loaded)
522
- └─ 3. Read archive/memory-archive.md ← archived history (loaded if exists)
523
144
  ```
524
-
525
- | Memory type | Stored in | Loaded automatically? | Purpose |
526
- | --- | --- | --- | --- |
527
- | **Active** | `memory.md` | Yes, always | Current identity, patterns, active projects |
528
- | **Archived** | `archive/memory-archive.md` | Yes, if file exists | Past decisions, completed projects |
529
- | **Session** | `session.md` | Yes, always | Previous session recap, working notes |
530
- | **Diary** | `diary/YYYY-MM-DD.md` | On demand | Detailed daily logs (AI checks when asked) |
531
-
532
- Archiving keeps `memory.md` lean (under 200 lines) while the AI still has full historical context through the archive file. Think of it like moving old emails to a folder — they're organized separately but still searchable.
533
-
534
- ### Automatic (during "save")
535
-
536
- When you say **"save"**, the AI checks the line count. If `memory.md` is approaching 200 lines, it automatically archives eligible entries before saving new ones.
537
-
538
- ### Manual
539
-
540
- ```bash
541
- ./archive.sh # Interactive — previews what can be archived, asks to confirm
542
- ./archive.sh --days 60 # Archive decisions older than 60 days instead of the default 90
145
+ memory_forget({ id: "abc12345" })
146
+ memory_forget({ query: "old project", confirm: true })
543
147
  ```
544
148
 
545
- Example output:
546
-
547
- ```text
548
- Memory Archive
549
-
550
- Current size: 187 lines (approaching 200 limit)
551
-
552
- Completed projects: 2
553
- → API rewrite
554
- → Auth migration
555
-
556
- Decisions older than 90 days: 3
557
- → 2024-09-15: Chose PostgreSQL over MongoDB
558
- → 2024-10-01: Adopted trunk-based branching
559
- → 2024-11-20: Moved CI to GitHub Actions
560
-
561
- Archive these entries? [Y/n]: y
149
+ ### `memory_stats`
562
150
 
563
- Archived 12 lines
564
- ✓ memory.md: 187 → 175 lines
565
- ✓ Archive: archive/memory-archive.md
566
- ```
567
-
568
- ### Accessing Archived Context
151
+ Show memory statistics: total count, breakdown by type, confidence distribution.
569
152
 
570
- The AI can read `archive/memory-archive.md` when historical context is needed. Just ask:
153
+ ### `memory_export`
571
154
 
572
- > *"Check the archive what database did we decide on last year?"*
155
+ Export all memories as formatted markdown, grouped by type.
573
156
 
574
- ---
157
+ ## MCP Prompts
575
158
 
576
- ## Advanced Features
159
+ amem includes two prompts that teach AI clients how to use it effectively:
577
160
 
578
- ### Time-Aware Behavior
161
+ - **`extraction-guide`** — When and what to extract from conversations
162
+ - **`session-start`** — How to load relevant context at conversation start
579
163
 
580
- The AI adapts its communication style based on the time of day. The current time is automatically injected into `session.md` at the start of each conversation — no configuration needed.
164
+ ## MCP Resources
581
165
 
582
- | Time | Tone |
583
- | --- | --- |
584
- | **Morning** (6–12) | Fresh, energetic, proactive |
585
- | **Afternoon** (12–18) | Focused, productive, direct |
586
- | **Evening** (18–22) | Relaxed, reflective, thorough |
587
- | **Night** (22–6) | Calm, concise, gentle |
166
+ Proactive context that clients can read automatically:
588
167
 
589
- ### Memory Recall
168
+ | Resource | Description |
169
+ |----------|-------------|
170
+ | `amem://corrections` | All active corrections — hard constraints |
171
+ | `amem://decisions` | Architectural decisions and rationale |
172
+ | `amem://profile` | Developer preferences and patterns |
173
+ | `amem://summary` | Quick overview of all stored memories |
590
174
 
591
- Can't remember when you made a decision? The recall system searches across all memory sources:
175
+ ## CLI
592
176
 
593
177
  ```bash
594
- ./recall.sh PostgreSQL # Search for a keyword
595
- ./recall.sh "API rewrite" # Search for a phrase
596
- ./recall.sh auth migration # Multiple keywords (OR)
178
+ amem-cli recall "authentication" # Search memories
179
+ amem-cli stats # Show statistics
180
+ amem-cli list --type correction # List by type
181
+ amem-cli export --file memories.md # Export to markdown
182
+ amem-cli forget abc12345 # Delete a memory
597
183
  ```
598
184
 
599
- The AI also does this automatically — if you ask about something not in active memory, it searches diary entries and the archive before responding. It will **never fabricate past events** — it searches for evidence first, and says "I'm not sure" if nothing is found.
600
-
601
- ```text
602
- Memory Recall — searching for: PostgreSQL
603
-
604
- Diary entries:
605
-
606
- 2026-03-15
607
- L5: **Decisions**: Chose PostgreSQL over MongoDB for relational data
608
- L8: Discussed migration plan from SQLite
185
+ ## How it works
609
186
 
610
- Archive (memory-archive.md):
611
- L12: | 2025-12-01 | Chose PostgreSQL over MongoDB | relational data needs |
612
-
613
- Current memory (memory.md):
614
- L28: - User prefers PostgreSQL for relational workloads
615
187
  ```
616
-
617
- ### Work Plans
618
-
619
- Say **"plan"** to create a tracked work plan:
620
-
621
- ```markdown
622
- # Plans
623
-
624
- ## API Migration — started 2026-03-19
625
-
626
- - [x] Design new schema
627
- - [x] Write migration script
628
- - [ ] Test with staging data
629
- - [ ] Deploy to production
630
- - [ ] Monitor for 48 hours
188
+ ┌─────────────────────────────────┐
189
+ │ AI Client │
190
+ │ Claude Code · Cursor · Any MCP │
191
+ └──────────┬──────────────────────┘
192
+ │ MCP Protocol (stdio)
193
+ ┌──────────▼──────────────────────┐
194
+ │ amem server │
195
+ │ │
196
+ │ ┌───────────┐ ┌────────────┐ │
197
+ │ │ Scoring │ │ Conflict │ │
198
+ │ │ Engine │ │ Detection │ │
199
+ │ └─────┬─────┘ └─────┬──────┘ │
200
+ │ │ │ │
201
+ │ ┌─────▼──────────────▼──────┐ │
202
+ │ │ SQLite + Embeddings │ │
203
+ │ │ ~/.amem/memory.db │ │
204
+ │ └───────────────────────────┘ │
205
+ └─────────────────────────────────┘
631
206
  ```
632
207
 
633
- Plans persist in `plans.md` across sessions. Progress is updated when you say "save". Completed plans are moved to the archive.
634
-
635
- ### Smart Project Management (LRU)
636
-
637
- Active projects are capped at **10** in `memory.md`. The AI manages this automatically during "save":
638
-
639
- - Projects not mentioned in 30+ days are archived
640
- - Completed projects are always archived
641
- - Archived projects are still searchable via recall
208
+ ### Scoring formula
642
209
 
643
- This prevents `memory.md` from growing unbounded while keeping recent work front and center.
644
-
645
- ### Diary Auto-Archiving
646
-
647
- Diary entries from previous months are automatically moved to `diary/archive/YYYY-MM/` at the start of each conversation. Current month entries stay in `diary/` for quick access.
648
-
649
- ```text
650
- diary/
651
- 2026-03-15.md ← current month, stays here
652
- 2026-03-18.md
653
- archive/
654
- 2026-01/ ← previous months, auto-archived
655
- 2026-01-05.md
656
- 2026-01-12.md
657
- 2026-02/
658
- 2026-02-03.md
210
+ ```
211
+ score = relevance x recency x confidence x importance
659
212
  ```
660
213
 
661
- Archived diary entries are still searchable via `./recall.sh` and by the AI during recall.
662
-
663
- ### Session Size Guard
664
-
665
- `session.md` is capped at **500 lines**. If Working Notes grow past this, the validation system warns you to save or trim. This prevents session bloat that degrades AI performance.
666
-
667
- ---
668
-
669
- ## FAQ
670
-
671
- <details>
672
- <summary><strong>Do I need to know how to code?</strong></summary>
673
-
674
- <br>
675
-
676
- No. You don't even need to run the setup wizard — just start a conversation and the AI will ask you a few friendly questions to get set up. After that, you just talk normally. The only "technical" thing is running the install command once to download the files.
677
-
678
- </details>
679
-
680
- <details>
681
- <summary><strong>What if I forget to say "save"?</strong></summary>
682
-
683
- <br>
684
-
685
- Your working notes are automatically saved when the conversation ends. But only a manual "save" captures learned patterns and decisions intelligently. For casual conversations, auto-save is fine. For important sessions where you made decisions, say "save" before leaving.
686
-
687
- </details>
688
-
689
- <details>
690
- <summary><strong>Can I use this with ChatGPT, Gemini, or other AIs?</strong></summary>
691
-
692
- <br>
693
-
694
- Yes! The automation (auto-save, validation) is Claude Code specific, but the memory files work with any AI. At the start of each conversation, paste:
695
-
696
- > *"Read memory.md and session.md, then follow the instructions in CLAUDE.md for how to manage memory during our session."*
697
-
698
- At the end, say: *"Save progress to memory.md and session.md."*
699
-
700
- </details>
701
-
702
- <details>
703
- <summary><strong>What if memory gets too big?</strong></summary>
704
-
705
- <br>
706
-
707
- The AI handles this automatically during "save" by archiving old entries. You can also run `./archive.sh` manually. **Archived memories are NOT lost** — they're moved to a separate file that the AI still reads at the start of every conversation.
708
-
709
- </details>
710
-
711
- <details>
712
- <summary><strong>Can multiple people use this on the same project?</strong></summary>
713
-
714
- <br>
715
-
716
- Yes! Run `./add-user.sh alice` to add a new profile. Each person gets their own separate memory, diary, and session. Switch between people with `./switch-user.sh`. See the [Multi-User](#multi-user) section for details.
717
-
718
- </details>
719
-
720
- <details>
721
- <summary><strong>Is my data sent anywhere?</strong></summary>
722
-
723
- <br>
724
-
725
- No. Everything stays in plain text files on your computer. The AI reads these files during your conversation — they're never uploaded to any external service. You own and control your data completely.
726
-
727
- </details>
728
-
729
- <details>
730
- <summary><strong>Can I edit the memory files manually?</strong></summary>
731
-
732
- <br>
733
-
734
- Yes! They're plain text (markdown) files. Open them in any text editor to review, correct, or delete entries. Just keep the section headings (lines starting with `##`) intact.
735
-
736
- </details>
737
-
738
- <details>
739
- <summary><strong>What's the difference between memory, session, and diary?</strong></summary>
740
-
741
- <br>
742
-
743
- Think of it like this:
744
-
745
- - **Memory** (`memory.md`) = your AI's brain — who you are, what you prefer, what you're working on. Persists forever.
746
- - **Session** (`session.md`) = a sticky note for the current conversation. Thrown away and replaced each time.
747
- - **Diary** (`diary/`) = a journal. One entry per day, never edited. Good for looking back at what happened.
748
-
749
- </details>
750
-
751
- ---
752
-
753
- ## Troubleshooting
214
+ | Factor | How it works |
215
+ |--------|-------------|
216
+ | **Relevance** | Cosine similarity between query and memory embeddings (0-1) |
217
+ | **Recency** | Exponential decay: `0.995^hours_since_last_access` |
218
+ | **Confidence** | How many times confirmed (0-1, corrections from user = 1.0) |
219
+ | **Importance** | Memory type weight: correction(1.0) > decision(0.85) > pattern(0.7) > preference(0.7) > topology(0.5) > fact(0.4) |
754
220
 
755
- | Problem | Solution |
756
- | --- | --- |
757
- | AI doesn't remember me | Make sure you're in the right folder. Open `memory.md` — does it have your name? If not, just start a new conversation and the AI will guide you through setup. |
758
- | "memory.md not found" error | Make sure you're inside the ai-memory folder. If the file is missing, run `./init.sh` to create it. |
759
- | AI keeps asking my name | Setup wasn't completed. Start a new conversation — the AI will detect this and walk you through it. Or run `./setup.sh` manually. |
760
- | Memory feels incomplete | Say **"save"** more often. Auto-save only captures working notes, not learned patterns. |
761
- | "memory.md is over 200 lines" | Run `./archive.sh` to move old entries to the archive. Nothing is lost. |
762
- | Session feels slow or repetitive | Session might be too long. Say **"save"**, then start a new conversation. |
763
- | Wrong user profile active | Run `./switch-user.sh` to see who's active and switch if needed. |
764
- | AI invents things that didn't happen | Say *"check the archive"* or *"search for X"* — the AI is instructed to search, not fabricate. |
221
+ ### Conflict detection
765
222
 
766
- ---
223
+ When storing a new memory, amem checks for conflicts:
224
+ - **>85% similarity** with different content — conflict detected, existing memory updated
225
+ - **>80% similarity** with same intent — existing memory reinforced (confidence +0.1)
226
+ - **No match** — new memory stored
767
227
 
768
- ## Known Limitations
228
+ ### Memory evolution
769
229
 
770
- | Limitation | Impact | Workaround |
771
- | --- | --- | --- |
772
- | AI might not update Working Notes | Auto-save has nothing to copy | Say "save" manually for important sessions |
773
- | No cross-project memory | Each project has its own memory | Share `memory.md` manually if needed |
774
- | Keyword search only | Recall uses keyword matching, not semantic search | Use specific keywords with `./recall.sh` |
775
- | Context window cap | Very large archives may exceed AI context | Keep `memory.md` lean via archiving; archive is loaded but prioritized lower |
230
+ When a new memory is stored, related existing memories (0.6-0.8 similarity) are reinforced — their access timestamps update, keeping them active and relevant.
776
231
 
777
- ---
232
+ ### Local-first
778
233
 
779
- <div align="center">
234
+ - All data stays on your machine at `~/.amem/memory.db`
235
+ - Embeddings generated locally via `all-MiniLM-L6-v2` (~80MB model, runs on CPU)
236
+ - No cloud, no API keys, no data leaving your laptop
237
+ - Works offline after first model download
780
238
 
781
- ## Credits
239
+ ## Configuration
782
240
 
783
- Inspired by [Project-AI-MemoryCore](https://github.com/Kiyoraka/Project-AI-MemoryCore) by Kiyoraka Ken & Alice
241
+ | Variable | Default | Description |
242
+ |----------|---------|-------------|
243
+ | `AMEM_DIR` | `~/.amem` | Directory for amem data |
244
+ | `AMEM_DB` | `~/.amem/memory.db` | Database file path |
784
245
 
785
- Simplified and enhanced by **Aman**
246
+ ## Roadmap
786
247
 
787
- ---
248
+ - [x] 7 MCP tools (store, recall, context, forget, extract, stats, export)
249
+ - [x] 2 MCP prompts (extraction guide, session start)
250
+ - [x] 4 MCP resources (corrections, decisions, profile, summary)
251
+ - [x] CLI with 5 commands
252
+ - [x] Local embeddings via HuggingFace transformers
253
+ - [x] Memory evolution (related memories reinforce each other)
254
+ - [x] Conflict detection and deduplication
255
+ - [x] Published on npm
256
+ - [ ] Memory verification (check code-related memories against filesystem)
257
+ - [ ] Knowledge graph (entity + relation tables)
258
+ - [ ] Team memory (shared project context via git-synced SQLite)
259
+ - [ ] Proactive mid-conversation context injection
788
260
 
789
- *Built for humans who want their AI to actually remember them.*
261
+ ## License
790
262
 
791
- </div>
263
+ MIT
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@aman_asmuei/amem",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "The memory layer for AI coding tools. Local-first, developer-specific, works everywhere.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "amem": "dist/index.js",
8
8
  "amem-cli": "dist/cli.js"
9
9
  },
10
- "files": ["dist"],
10
+ "files": [
11
+ "dist"
12
+ ],
11
13
  "scripts": {
12
14
  "build": "tsc",
13
15
  "dev": "tsc --watch",
@@ -16,7 +18,15 @@
16
18
  "prepare": "npm run build",
17
19
  "start": "node dist/index.js"
18
20
  },
19
- "keywords": ["mcp", "memory", "ai", "developer-tools", "context", "sqlite", "embeddings"],
21
+ "keywords": [
22
+ "mcp",
23
+ "memory",
24
+ "ai",
25
+ "developer-tools",
26
+ "context",
27
+ "sqlite",
28
+ "embeddings"
29
+ ],
20
30
  "license": "MIT",
21
31
  "author": "Aman Asmuei",
22
32
  "repository": {