@aman_asmuei/amem 0.1.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,8 +11,9 @@ Your AI assistant forgets everything the moment a conversation ends.<br/>
11
11
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)
12
12
  [![CI](https://img.shields.io/github/actions/workflow/status/amanasmuei/amem/ci.yml?style=flat-square&label=tests)](https://github.com/amanasmuei/amem/actions)
13
13
  [![Node](https://img.shields.io/badge/node-%3E%3D18-brightgreen?style=flat-square)](https://nodejs.org)
14
+ [![MCP](https://img.shields.io/badge/MCP-compatible-8A2BE2?style=flat-square)](https://modelcontextprotocol.io)
14
15
 
15
- [Get Started](#-get-started) · [How It Works](#-how-it-works) · [Tools Reference](#-tools) · [CLI](#-cli) · [FAQ](#-faq)
16
+ [Get Started](#get-started) · [How It Works](#how-it-works) · [Tools](#tools) · [Resources & Prompts](#resources--prompts) · [CLI](#cli) · [FAQ](#faq) · [Contributing](#contributing)
16
17
 
17
18
  </div>
18
19
 
@@ -48,18 +49,18 @@ amem organizes memories into six types, ranked by importance:
48
49
 
49
50
  | Priority | Type | What it captures | Example |
50
51
  |:--------:|------|-----------------|---------|
51
- | 🔴 | **Correction** | Mistakes to never repeat | *"Don't mock the database in integration tests"* |
52
- | 🟠 | **Decision** | Architectural choices + why | *"Chose Postgres over MongoDB for ACID compliance"* |
53
- | 🟡 | **Pattern** | Coding style & habits | *"Prefers early returns over nested conditionals"* |
54
- | 🟢 | **Preference** | Tool & workflow choices | *"Uses pnpm, not npm"* |
55
- | 🔵 | **Topology** | Where things are | *"Auth module lives in src/auth/, uses JWT"* |
56
- | | **Fact** | General project knowledge | *"API uses REST, launched January 2025"* |
52
+ | 1.0 | **Correction** | Mistakes to never repeat | *"Don't mock the database in integration tests"* |
53
+ | 0.85 | **Decision** | Architectural choices + why | *"Chose Postgres over MongoDB for ACID compliance"* |
54
+ | 0.7 | **Pattern** | Coding style & habits | *"Prefers early returns over nested conditionals"* |
55
+ | 0.7 | **Preference** | Tool & workflow choices | *"Uses pnpm, not npm"* |
56
+ | 0.5 | **Topology** | Where things are | *"Auth module lives in src/auth/, uses JWT"* |
57
+ | 0.4 | **Fact** | General project knowledge | *"API uses REST, launched January 2025"* |
57
58
 
58
59
  Corrections always surface first. They're the "never do this" rules your AI should always follow.
59
60
 
60
61
  ---
61
62
 
62
- ## 🚀 Get Started
63
+ ## Get Started
63
64
 
64
65
  ### Step 1: Install
65
66
 
@@ -88,7 +89,7 @@ Add to `~/.claude/settings.json`:
88
89
  }
89
90
  ```
90
91
 
91
- Restart Claude Code. You'll see 7 memory tools available.
92
+ Restart Claude Code. You'll see 9 memory tools, 4 resources, and 2 prompts available.
92
93
 
93
94
  </details>
94
95
 
@@ -153,7 +154,7 @@ It knows.
153
154
 
154
155
  ---
155
156
 
156
- ## 🧠 How It Works
157
+ ## How It Works
157
158
 
158
159
  ```
159
160
  ┌──────────────────────────────────┐
@@ -161,10 +162,12 @@ It knows.
161
162
  │ Claude · Cursor · Windsurf │
162
163
  └──────────┬───────────────────────┘
163
164
 
164
- MCP Protocol (local)
165
+ MCP Protocol (stdio)
165
166
 
166
167
  ┌──────────▼───────────────────────┐
167
- amem server
168
+ amem-mcp-server
169
+ │ │
170
+ │ 9 Tools · 4 Resources · 2 Prompts
168
171
  │ │
169
172
  │ Store → Score → Deduplicate │
170
173
  │ Recall → Rank → Surface │
@@ -180,51 +183,80 @@ It knows.
180
183
 
181
184
  ### Smart ranking
182
185
 
183
- Every memory gets a score:
186
+ Every memory gets a composite score:
184
187
 
185
188
  ```
186
189
  score = relevance × recency × confidence × importance
187
190
  ```
188
191
 
189
- - **Relevance** — How closely the memory matches what you're working on (semantic similarity)
190
- - **Recency** — Recent memories score higher; old ones gradually fade
191
- - **Confidence** — Memories confirmed multiple times score higher
192
- - **Importance** — Corrections (1.0) > Decisions (0.85) > Patterns (0.7) > Facts (0.4)
192
+ - **Relevance** — How closely the memory matches what you're working on (cosine similarity via local embeddings, with keyword fallback)
193
+ - **Recency** — Exponential decay (0.995^hours) — recent memories score higher, old ones gradually fade
194
+ - **Confidence** — Memories confirmed multiple times score higher (0.0 to 1.0)
195
+ - **Importance** — Type-based weight: Corrections (1.0) > Decisions (0.85) > Patterns (0.7) > Facts (0.4)
193
196
 
194
197
  ### Conflict detection
195
198
 
196
199
  Store a memory that contradicts an existing one? amem catches it:
197
200
 
198
- - **>85% similar but different** Flags the conflict, updates the existing memory
199
- - **>80% similar and agreeing** Reinforces the existing memory (+confidence)
200
- - **No match** Stores as new
201
+ - **>85% similar but different** Flags the conflict, updates the existing memory's confidence
202
+ - **>80% similar and agreeing** Reinforces the existing memory (+0.1 confidence)
203
+ - **60-80% related** Touches related memories to keep them fresh
204
+ - **No match** — Stores as new
201
205
 
202
206
  ### Memory evolution
203
207
 
204
- When you store a new memory, related existing memories get reinforced automatically. Your knowledge base stays connected and current.
208
+ When you store a new memory, related existing memories (60-80% similarity) get reinforced automatically their access timestamps update, keeping your knowledge base connected and current.
209
+
210
+ ### Memory consolidation
211
+
212
+ Over time, memories accumulate — duplicates, stale facts, forgotten preferences. amem is the first MCP memory server with built-in consolidation:
213
+
214
+ - **Merge** — Near-duplicate memories (>85% similarity) are combined. The higher-confidence version is kept and boosted.
215
+ - **Prune** — Stale memories (>60 days inactive, low confidence, rarely accessed) are removed. Corrections are **never** pruned.
216
+ - **Promote** — Memories accessed 5+ times with low confidence get promoted to 90% confidence.
217
+ - **Health score** — After consolidation, you get a 0-100 health score (signal-to-noise ratio).
218
+
219
+ Use `memory_consolidate` with `confirm: false` to preview, then `confirm: true` to execute.
220
+
221
+ ### Project scoping
222
+
223
+ Memories know where they apply:
224
+
225
+ - **Global** — Corrections, preferences, and patterns follow you everywhere (e.g., "Don't use `any` in TypeScript")
226
+ - **Project-scoped** — Decisions, topology, and facts stay with their project (e.g., "Auth module is in src/auth/")
227
+
228
+ Project is auto-detected from `AMEM_PROJECT` env var or your git repo name. When recalling, amem returns global memories + current project memories — never leaking another project's context.
205
229
 
206
230
  ---
207
231
 
208
- ## 🔧 Tools
232
+ ## Tools
209
233
 
210
- amem gives your AI **7 tools** it can use during conversation:
234
+ amem gives your AI **9 tools** it can use during conversation. All tools include:
235
+
236
+ - **Strict input validation** with Zod schemas (invalid inputs are rejected with clear error messages)
237
+ - **Tool annotations** (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) so clients understand tool behavior
238
+ - **Structured error handling** — errors return `isError: true` with actionable suggestions
211
239
 
212
240
  ### Core tools
213
241
 
214
- | Tool | What it does |
215
- |------|-------------|
216
- | `memory_store` | Save a single memory with type, tags, and confidence |
217
- | `memory_recall` | Search memories by meaning (not just keywords) |
218
- | `memory_context` | Load everything relevant to a topic, organized by type |
219
- | `memory_extract` | Batch-save multiple memories at once from a conversation |
220
- | `memory_forget` | Delete outdated or incorrect memories |
242
+ | Tool | What it does | Annotations |
243
+ |------|-------------|-------------|
244
+ | `memory_store` | Save a single memory with type, tags, and confidence | write, non-destructive |
245
+ | `memory_recall` | Search memories by meaning (semantic + keyword fallback) | read-only, idempotent |
246
+ | `memory_context` | Load all relevant context for a topic, organized by type | read-only, idempotent |
247
+ | `memory_extract` | Batch-save multiple memories from a conversation | write, non-destructive |
248
+ | `memory_forget` | Delete outdated or incorrect memories (with confirmation) | write, destructive |
249
+ | `memory_inject` | Proactively inject corrections + decisions for a topic (use before coding) | read-only, idempotent |
250
+
251
+ ### Maintenance tools
221
252
 
222
- ### Utility tools
253
+ | Tool | What it does | Annotations |
254
+ |------|-------------|-------------|
255
+ | `memory_stats` | Memory count, type breakdown, confidence distribution, embedding coverage | read-only, idempotent |
256
+ | `memory_export` | Export all memories as markdown (truncates at 50K chars) | read-only, idempotent |
257
+ | `memory_consolidate` | Merge duplicates, prune stale memories, promote frequent ones (preview or execute) | write, destructive |
223
258
 
224
- | Tool | What it does |
225
- |------|-------------|
226
- | `memory_stats` | See how many memories you have, broken down by type |
227
- | `memory_export` | Export all memories as readable markdown |
259
+ All tools return both human-readable text (`content`) and machine-readable JSON (`structuredContent`) with validated `outputSchema`.
228
260
 
229
261
  ### Example: Storing a memory
230
262
 
@@ -237,6 +269,8 @@ memory_store({
237
269
  })
238
270
  ```
239
271
 
272
+ > Stored correction memory (a1b2c3d4). Confidence: 1. Tags: [typescript, types]. Total memories: 42.
273
+
240
274
  ### Example: Recalling memories
241
275
 
242
276
  ```
@@ -244,17 +278,19 @@ memory_recall({ query: "TypeScript best practices", limit: 5 })
244
278
  ```
245
279
 
246
280
  ```
281
+ Found 2 memories for "TypeScript best practices":
282
+
247
283
  1. [correction] Never use 'any' type — always define proper interfaces
248
- Score: 0.892 | Confidence: 100% | Age: 2d ago
284
+ Score: 0.892 | Confidence: 100% | Age: 2d ago | Tags: [typescript, types]
249
285
 
250
286
  2. [pattern] User prefers strict TypeScript with no implicit any
251
- Score: 0.756 | Confidence: 85% | Age: 5d ago
287
+ Score: 0.756 | Confidence: 85% | Age: 5d ago | Tags: [typescript]
252
288
  ```
253
289
 
254
290
  ### Example: Loading context for a task
255
291
 
256
292
  ```
257
- memory_context({ topic: "authentication system" })
293
+ memory_context({ topic: "authentication system", max_tokens: 2000 })
258
294
  ```
259
295
 
260
296
  ```markdown
@@ -277,43 +313,79 @@ Your AI can extract multiple memories from a single conversation:
277
313
  ```
278
314
  memory_extract({
279
315
  memories: [
280
- { content: "Don't mock the DB in integration tests", type: "correction", confidence: 1.0 },
281
- { content: "Chose event sourcing for audit trail", type: "decision", confidence: 0.9 }
316
+ { content: "Don't mock the DB in integration tests", type: "correction", tags: ["testing"], confidence: 1.0 },
317
+ { content: "Chose event sourcing for audit trail", type: "decision", tags: ["architecture"], confidence: 0.9 }
282
318
  ]
283
319
  })
284
320
  ```
285
321
 
286
- ---
322
+ ```
323
+ Extraction complete: 2 stored, 0 reinforced.
324
+ Total memories: 44.
287
325
 
288
- ## 💻 CLI
326
+ + Stored [correction]: "Don't mock the DB in integration tests" (a1b2c3d4)
327
+ + Stored [decision]: "Chose event sourcing for audit trail" (e5f6g7h8)
328
+ ```
289
329
 
290
- amem also includes a command-line interface for managing memories directly:
330
+ ### Example: Forgetting memories
291
331
 
292
- ```bash
293
- amem-cli recall "authentication" # Search memories
294
- amem-cli stats # Show statistics
295
- amem-cli list # List all memories
296
- amem-cli list --type correction # List by type
297
- amem-cli export --file memories.md # Export to markdown
298
- amem-cli forget abc12345 # Delete by ID
332
+ Delete by ID or by query (with a safety confirmation step):
333
+
334
+ ```
335
+ memory_forget({ query: "old project", confirm: false })
336
+ ```
337
+
338
+ ```
339
+ Found 3 memories matching "old project". Preview:
340
+ 1. [a1b2c3d4] Old project used Express.js
341
+ 2. [e5f6g7h8] Old project had no tests
342
+
343
+ Call again with confirm=true to delete these.
299
344
  ```
300
345
 
301
346
  ---
302
347
 
303
- ## 📡 MCP Resources
348
+ ## Resources & Prompts
349
+
350
+ ### MCP Resources
304
351
 
305
- amem exposes **4 resources** that AI clients can read proactively:
352
+ amem exposes **4 resources** that AI clients can read proactively at the start of a conversation:
306
353
 
307
- | Resource | What it provides |
308
- |----------|-----------------|
354
+ | Resource URI | What it provides |
355
+ |-------------|-----------------|
309
356
  | `amem://corrections` | All active corrections — hard rules the AI should always follow |
310
357
  | `amem://decisions` | Past architectural decisions and their rationale |
311
358
  | `amem://profile` | Your preferences and coding patterns |
312
- | `amem://summary` | Quick overview of everything stored |
359
+ | `amem://summary` | Quick overview: memory count and breakdown by type |
360
+
361
+ ### MCP Prompts
362
+
363
+ amem provides **2 prompts** that teach AI clients how to use the memory system effectively:
364
+
365
+ | Prompt | Purpose |
366
+ |--------|---------|
367
+ | `extraction-guide` | Guidelines for *what* to extract from conversations — when to save corrections vs. decisions vs. facts, how often, and what to avoid |
368
+ | `session-start` | How to load relevant context at the beginning of a conversation — load topic context, apply corrections as hard constraints, reference memories naturally |
313
369
 
314
370
  ---
315
371
 
316
- ## ⚙️ Configuration
372
+ ## CLI
373
+
374
+ amem includes a standalone command-line interface for managing memories directly:
375
+
376
+ ```bash
377
+ amem-cli recall "authentication" # Search memories semantically
378
+ amem-cli stats # Show statistics with visual bars
379
+ amem-cli list # List all memories
380
+ amem-cli list --type correction # Filter by type
381
+ amem-cli export # Export to stdout as markdown
382
+ amem-cli export --file memories.md # Export to file
383
+ amem-cli forget abc12345 # Delete by ID (short IDs supported)
384
+ ```
385
+
386
+ ---
387
+
388
+ ## Configuration
317
389
 
318
390
  amem works out of the box with zero configuration. For advanced use:
319
391
 
@@ -321,10 +393,68 @@ amem works out of the box with zero configuration. For advanced use:
321
393
  |---------------------|---------|-------------|
322
394
  | `AMEM_DIR` | `~/.amem` | Where amem stores data |
323
395
  | `AMEM_DB` | `~/.amem/memory.db` | Database file path |
396
+ | `AMEM_PROJECT` | *(auto-detected from git)* | Project name for scoping (e.g., `my-app`) |
397
+
398
+ Project scoping is automatic — amem detects your git repo name. Override with `AMEM_PROJECT`:
399
+
400
+ ```json
401
+ {
402
+ "mcpServers": {
403
+ "amem": {
404
+ "command": "amem",
405
+ "env": { "AMEM_PROJECT": "my-project" }
406
+ }
407
+ }
408
+ }
409
+ ```
324
410
 
325
411
  ---
326
412
 
327
- ## FAQ
413
+ ## Technical Details
414
+
415
+ ### Stack
416
+
417
+ | Layer | Technology |
418
+ |-------|------------|
419
+ | Protocol | [MCP](https://modelcontextprotocol.io/) SDK ^1.25 (modern `registerTool`/`registerResource`/`registerPrompt` APIs) |
420
+ | Language | TypeScript 5.6+ (strict mode, ES2022, zero `any` types) |
421
+ | Database | SQLite via better-sqlite3 (WAL mode, prepared statements, indexed) |
422
+ | Embeddings | HuggingFace Transformers — Xenova/all-MiniLM-L6-v2 (384-dim, local, optional) |
423
+ | Validation | Zod 3.25+ (`.strict()` on all schemas, `.min()` constraints, descriptive errors) |
424
+ | Testing | Vitest — 33 tests across 4 suites |
425
+ | CI/CD | GitHub Actions — Node 18/20/22 |
426
+
427
+ ### MCP Best Practices
428
+
429
+ amem follows the [MCP best practices](https://modelcontextprotocol.io/) checklist:
430
+
431
+ - All 9 tools use `server.registerTool()` with `title`, `description`, `inputSchema`, `outputSchema`, and `annotations`
432
+ - All tool handlers wrapped in `try-catch` with `isError: true` on failures
433
+ - All Zod schemas use `.strict()` to reject unknown fields
434
+ - All error messages are actionable (suggest next steps)
435
+ - Server name follows convention: `amem-mcp-server`
436
+ - Transport: stdio (correct for local-first tool)
437
+ - Logging to stderr (not stdout)
438
+ - Graceful shutdown on SIGINT/SIGTERM
439
+
440
+ ### Architecture
441
+
442
+ ```
443
+ src/
444
+ ├── index.ts Entry point — server, prompts, resources, transport
445
+ ├── tools.ts 10 MCP tools with annotations, validation, structured output
446
+ ├── schemas.ts Zod output schemas for structuredContent responses
447
+ ├── memory.ts Scoring engine, conflict detection, recall algorithm
448
+ ├── database.ts SQLite schema, prepared statements, CRUD interface
449
+ ├── embeddings.ts Local embedding pipeline + cosine similarity
450
+ └── cli.ts Standalone CLI for direct memory management
451
+ ```
452
+
453
+ **~1,300 lines of TypeScript.** Clean separation of concerns, no circular dependencies.
454
+
455
+ ---
456
+
457
+ ## FAQ
328
458
 
329
459
  <details>
330
460
  <summary><strong>Is my data sent to the cloud?</strong></summary>
@@ -336,7 +466,7 @@ No. Everything stays on your machine. amem uses a local SQLite database at `~/.a
336
466
  <details>
337
467
  <summary><strong>Does it work offline?</strong></summary>
338
468
 
339
- Yes. After the first run (which downloads the embedding model), amem works completely offline.
469
+ Yes. After the first run (which downloads the embedding model), amem works completely offline. If the model isn't available, amem falls back to keyword matching — it never crashes.
340
470
 
341
471
  </details>
342
472
 
@@ -350,53 +480,149 @@ Any tool that supports the [Model Context Protocol (MCP)](https://modelcontextpr
350
480
  <details>
351
481
  <summary><strong>How much memory/disk does it use?</strong></summary>
352
482
 
353
- The embedding model is ~80MB (downloaded once). The SQLite database grows with your memories — typically a few MB even after months of use. CPU usage is minimal.
483
+ The embedding model is ~80MB (downloaded once, cached locally). The SQLite database grows with your memories — typically a few MB even after months of use. CPU usage is minimal; the server idles at near-zero when not processing requests.
354
484
 
355
485
  </details>
356
486
 
357
487
  <details>
358
488
  <summary><strong>Can I see what's stored?</strong></summary>
359
489
 
360
- Yes! Use `amem-cli list` to see all memories, `amem-cli stats` for an overview, or `amem-cli export --file backup.md` to export everything as readable markdown.
490
+ Yes! Use `amem-cli list` to see all memories, `amem-cli stats` for a visual overview, or `amem-cli export --file backup.md` to export everything as readable markdown. You can also ask your AI to call `memory_stats` or `memory_export`.
361
491
 
362
492
  </details>
363
493
 
364
494
  <details>
365
495
  <summary><strong>Can I delete specific memories?</strong></summary>
366
496
 
367
- Yes. Use `amem-cli forget <id>` or ask your AI to call `memory_forget`. You can also search-and-delete: `memory_forget({ query: "old project", confirm: true })`.
497
+ Yes. Use `amem-cli forget <id>` (short IDs work — just the first 8 characters) or ask your AI to call `memory_forget`. Query-based deletion requires a confirmation step to prevent accidents: `memory_forget({ query: "old project", confirm: true })`.
368
498
 
369
499
  </details>
370
500
 
371
501
  <details>
372
502
  <summary><strong>Does it slow down my AI?</strong></summary>
373
503
 
374
- No. Memory operations typically take under 50ms. Embedding generation for new memories takes ~200ms. The server runs as a lightweight background process.
504
+ No. Memory operations typically take under 50ms. Embedding generation for new memories takes ~200ms. The server runs as a lightweight background process over stdio.
375
505
 
376
506
  </details>
377
507
 
378
508
  <details>
379
509
  <summary><strong>Can I use it across multiple projects?</strong></summary>
380
510
 
381
- Yes. amem stores memories globally at `~/.amem/memory.db` by default. All your AI conversations across all projects share the same memory. You can also set `AMEM_DB` per-project for isolated memories.
511
+ Yes. By default, amem stores memories globally at `~/.amem/memory.db` all your AI conversations across all projects share the same memory. Set `AMEM_DB` per-project for isolated memories.
512
+
513
+ </details>
514
+
515
+ <details>
516
+ <summary><strong>What happens if the embedding model isn't available?</strong></summary>
517
+
518
+ amem gracefully falls back to keyword-based matching. Semantic search won't work, but storing, recalling (by keyword), and all other operations continue normally. The server never crashes due to missing embeddings.
519
+
520
+ </details>
521
+
522
+ <details>
523
+ <summary><strong>How does conflict detection work?</strong></summary>
524
+
525
+ When you store a new memory, amem computes cosine similarity against all existing memories. If a match exceeds 85% similarity but the content is different, it flags a conflict and updates the existing memory's confidence instead of creating a duplicate. You get a clear message explaining what happened and how to rephrase if the memories are genuinely different.
382
526
 
383
527
  </details>
384
528
 
385
529
  ---
386
530
 
387
- ## 🗺️ Roadmap
531
+ ## Contributing
532
+
533
+ Contributions are welcome! Here's how to get involved.
534
+
535
+ ### Development setup
536
+
537
+ ```bash
538
+ git clone https://github.com/amanasmuei/amem.git
539
+ cd amem
540
+ npm install
541
+ npm run build
542
+ npm test
543
+ ```
544
+
545
+ ### Scripts
546
+
547
+ | Script | What it does |
548
+ |--------|-------------|
549
+ | `npm run build` | Compile TypeScript to `dist/` |
550
+ | `npm run dev` | Watch mode — recompile on save |
551
+ | `npm test` | Run all 33 tests with Vitest |
552
+ | `npm run test:watch` | Run tests in watch mode |
553
+ | `npm start` | Start the MCP server (`node dist/index.js`) |
554
+
555
+ ### Project structure
556
+
557
+ ```
558
+ amem/
559
+ ├── src/
560
+ │ ├── index.ts # MCP server entry point, prompts, resources
561
+ │ ├── tools.ts # 7 tool definitions with validation & error handling
562
+ │ ├── memory.ts # Scoring engine, conflict detection, recall
563
+ │ ├── database.ts # SQLite schema, prepared statements, CRUD
564
+ │ ├── embeddings.ts # Local embedding pipeline + cosine similarity
565
+ │ └── cli.ts # Standalone CLI
566
+ ├── tests/
567
+ │ ├── database.test.ts
568
+ │ ├── embeddings.test.ts
569
+ │ ├── memory.test.ts
570
+ │ └── tools.test.ts
571
+ ├── .github/
572
+ │ └── workflows/
573
+ │ ├── ci.yml # Test on push/PR (Node 18/20/22)
574
+ │ └── publish.yml # Publish to npm on GitHub Release
575
+ ├── package.json
576
+ ├── tsconfig.json
577
+ └── vitest.config.ts
578
+ ```
579
+
580
+ ### Making changes
581
+
582
+ 1. Fork the repository
583
+ 2. Create a feature branch: `git checkout -b feature/your-feature`
584
+ 3. Make your changes
585
+ 4. Ensure the build is clean: `npm run build`
586
+ 5. Ensure all tests pass: `npm test`
587
+ 6. Commit and push your branch
588
+ 7. Open a Pull Request against `main`
589
+
590
+ ### CI/CD
591
+
592
+ **GitHub Actions** runs automatically on every push and pull request:
593
+
594
+ - **CI workflow** (`ci.yml`) — builds and tests against Node.js 18, 20, and 22 on Ubuntu
595
+ - **Publish workflow** (`publish.yml`) — triggered on GitHub Release, builds, tests, and publishes to npm with `--access public`
596
+
597
+ All PRs must pass the CI pipeline before merging.
598
+
599
+ ### Reporting issues
600
+
601
+ Found a bug or have a feature idea?
602
+
603
+ - **Bug reports**: [Open an issue](https://github.com/amanasmuei/amem/issues/new) with steps to reproduce, expected vs. actual behavior, and your Node.js version
604
+ - **Feature requests**: [Open an issue](https://github.com/amanasmuei/amem/issues/new) describing the use case and how it would improve the memory system
605
+ - **Questions**: [Start a discussion](https://github.com/amanasmuei/amem/discussions) (or open an issue)
606
+
607
+ ---
608
+
609
+ ## Roadmap
388
610
 
389
- - [x] 7 MCP tools for storing, recalling, and managing memories
390
- - [x] Semantic search with local embeddings
611
+ - [x] 8 MCP tools with full annotations, validation, and error handling
612
+ - [x] Semantic search with local embeddings (graceful fallback to keywords)
391
613
  - [x] Smart conflict detection and deduplication
392
614
  - [x] Memory evolution (related memories reinforce each other)
393
615
  - [x] CLI for direct memory management
394
616
  - [x] MCP prompts and resources for proactive context
395
617
  - [x] Published on npm
618
+ - [x] `outputSchema` + `structuredContent` for machine-readable tool responses
619
+ - [x] Proactive context injection (`memory_inject` tool)
620
+ - [x] Evaluation suite (10 standardized eval questions)
621
+ - [x] Memory consolidation — merge, prune, promote (the first MCP memory server with this)
622
+ - [x] Project scoping — auto-detect project, scope memories global vs project
396
623
  - [ ] Memory verification against filesystem
397
624
  - [ ] Knowledge graph with entity relationships
398
625
  - [ ] Team memory (shared context across developers)
399
- - [ ] Proactive mid-conversation context injection
400
626
 
401
627
  ---
402
628
 
@@ -404,7 +630,7 @@ Yes. amem stores memories globally at `~/.amem/memory.db` by default. All your A
404
630
 
405
631
  **Built by [Aman Asmuei](https://github.com/amanasmuei)**
406
632
 
407
- [Report Bug](https://github.com/amanasmuei/amem/issues) · [Request Feature](https://github.com/amanasmuei/amem/issues) · [npm](https://www.npmjs.com/package/@aman_asmuei/amem)
633
+ [GitHub](https://github.com/amanasmuei/amem) · [npm](https://www.npmjs.com/package/@aman_asmuei/amem) · [Report Bug](https://github.com/amanasmuei/amem/issues) · [Request Feature](https://github.com/amanasmuei/amem/issues)
408
634
 
409
635
  MIT License
410
636
 
package/dist/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { createDatabase } from "./database.js";
3
3
  import { recallMemories, MemoryType } from "./memory.js";
4
4
  import { generateEmbedding } from "./embeddings.js";
5
+ import { formatAge, TYPE_ORDER } from "./tools.js";
5
6
  import path from "node:path";
6
7
  import os from "node:os";
7
8
  import fs from "node:fs";
@@ -121,8 +122,7 @@ function handleStats() {
121
122
  return;
122
123
  }
123
124
  console.log(" By type:");
124
- const typeOrder = ["correction", "decision", "pattern", "preference", "topology", "fact"];
125
- for (const t of typeOrder) {
125
+ for (const t of TYPE_ORDER) {
126
126
  const count = stats.byType[t] || 0;
127
127
  if (count > 0) {
128
128
  const bar = "\u2588".repeat(Math.min(count, 40));
@@ -163,11 +163,10 @@ function handleExport(args) {
163
163
  console.log("No memories to export.");
164
164
  return;
165
165
  }
166
- const typeOrder = ["correction", "decision", "pattern", "preference", "topology", "fact"];
167
166
  let md = `# Amem Memory Export\n\n`;
168
167
  md += `*Exported: ${new Date().toISOString()}*\n`;
169
168
  md += `*Total: ${all.length} memories*\n\n`;
170
- for (const t of typeOrder) {
169
+ for (const t of TYPE_ORDER) {
171
170
  const memories = all.filter(m => m.type === t);
172
171
  if (memories.length === 0)
173
172
  continue;
@@ -235,18 +234,4 @@ function handleForget(args) {
235
234
  db.deleteMemory(match.id);
236
235
  console.log(`Deleted: "${match.content}" (${match.type})`);
237
236
  }
238
- function formatAge(timestamp) {
239
- const ms = Date.now() - timestamp;
240
- const minutes = Math.floor(ms / 60000);
241
- if (minutes < 60)
242
- return `${minutes}m ago`;
243
- const hours = Math.floor(minutes / 60);
244
- if (hours < 24)
245
- return `${hours}h ago`;
246
- const days = Math.floor(hours / 24);
247
- if (days < 30)
248
- return `${days}d ago`;
249
- const months = Math.floor(days / 30);
250
- return `${months}mo ago`;
251
- }
252
237
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,UAAU,EAA4C,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;AAC1E,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAExE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAExB,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;IAC/E,SAAS,EAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,I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,YAAY,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,YAAY,CAAC,IAAc;IAClC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACnB,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAChD,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,oCAAoC;IACpC,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;IACxB,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,CAAC,OAAO,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;AAC7D,CAAC"}
@@ -6,6 +6,7 @@ export interface MemoryInput {
6
6
  confidence: number;
7
7
  source: string;
8
8
  embedding: Float32Array | null;
9
+ scope: string;
9
10
  }
10
11
  export interface MemoryStats {
11
12
  total: number;
@@ -23,6 +24,8 @@ export interface AmemDatabase {
23
24
  touchAccess(id: string): void;
24
25
  deleteMemory(id: string): void;
25
26
  getStats(): MemoryStats;
27
+ searchByScope(scope: string): Memory[];
28
+ getAllForProject(project: string): Memory[];
26
29
  listTables(): string[];
27
30
  close(): void;
28
31
  }