claude-code-memory 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 (2026-01-27)
4
+
5
+ Initial release.
6
+
7
+ ### Features
8
+
9
+ - Silent memory capture via Claude Code hooks (Stop, PreCompact, SessionEnd)
10
+ - Haiku-powered extraction — automatically identifies decisions, patterns, gotchas, architecture, progress, context
11
+ - Two-tier memory: compact CLAUDE.md (auto-read) + unlimited .memory/state.json (searchable)
12
+ - 10 MCP tools: search, ask (RAG), related, save, recall, delete, consolidate, consciousness, stats, init
13
+ - Jaccard similarity deduplication
14
+ - Confidence decay (progress: 7 days, context: 30 days)
15
+ - LLM-powered consolidation (auto every 10 extractions or 80+ memories)
16
+ - Line-budgeted CLAUDE.md (~150 lines max, most important first)
17
+ - CLI tool: setup, init, status, search, ask, consolidate, key
18
+ - Interactive setup wizard
19
+ - Global and per-project install modes
20
+ - API key resolution chain (env var, config files)
21
+ - Atomic writes and lock files for concurrent safety
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 memory-mcp contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # memory-mcp
2
+
3
+ Persistent memory for [Claude Code](https://docs.anthropic.com/en/docs/claude-code). Never lose context between sessions again.
4
+
5
+ ## The Problem
6
+
7
+ Every few days, you start a new Claude Code session and have to re-explain your project — the architecture, the decisions you made, the patterns you follow, the gotchas you discovered. All that context is gone.
8
+
9
+ ## The Solution
10
+
11
+ `memory-mcp` silently captures what matters during your sessions and makes it available to every future session — automatically.
12
+
13
+ ```
14
+ Session 1: Claude works → hooks silently extract memories → saved
15
+ Session 2: Claude starts → reads CLAUDE.md → instantly knows everything
16
+ ```
17
+
18
+ No commands to run. No "remember this". It just works.
19
+
20
+ ## How It Works
21
+
22
+ **Two-tier memory architecture:**
23
+
24
+ | Layer | Purpose | Size |
25
+ |-------|---------|------|
26
+ | `CLAUDE.md` | Auto-read on session start. Top ~150 lines of the most important context. | Compact |
27
+ | `.memory/state.json` | Full memory store. Searchable via MCP tools mid-conversation. | Unlimited |
28
+
29
+ **Silent capture via hooks:**
30
+
31
+ Claude Code hooks fire after every response (`Stop`), before context compaction (`PreCompact`), and at session end (`SessionEnd`). A fast LLM (Haiku) reads the transcript and extracts:
32
+
33
+ - **Architecture** — how the system is structured
34
+ - **Decisions** — why X was chosen over Y
35
+ - **Patterns** — conventions and how things are done
36
+ - **Gotchas** — non-obvious pitfalls
37
+ - **Progress** — what's done, what's in flight
38
+ - **Context** — business context, deadlines, preferences
39
+
40
+ **Smart memory management:**
41
+
42
+ - Jaccard similarity deduplication (no duplicate memories)
43
+ - Confidence decay (progress fades after 7 days, context after 30)
44
+ - LLM-powered consolidation (merges overlapping memories, prunes stale ones)
45
+ - Line-budgeted CLAUDE.md (stays under ~150 lines, most important first)
46
+
47
+ ## Quick Start
48
+
49
+ ```bash
50
+ # Install globally
51
+ npm install -g memory-mcp
52
+
53
+ # Interactive setup (API key + hooks)
54
+ memory-mcp setup
55
+
56
+ # Initialize a project
57
+ memory-mcp init ~/Projects/my-app
58
+ ```
59
+
60
+ That's it. Start a Claude Code session and memories will begin accumulating automatically.
61
+
62
+ ## Requirements
63
+
64
+ - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code)
65
+ - Node.js 18+
66
+ - Anthropic API key (for the Haiku-based extractor, ~$0.001 per extraction)
67
+
68
+ ## CLI Commands
69
+
70
+ ```
71
+ memory-mcp setup Interactive first-time setup
72
+ memory-mcp init [dir] Initialize memory for a project
73
+ memory-mcp status [dir] Show memory status and health
74
+ memory-mcp search <query> Search memories by keyword
75
+ memory-mcp ask <question> Ask a question, get answer from memory
76
+ memory-mcp consolidate [dir] Merge duplicates, prune stale memories
77
+ memory-mcp key [api-key] Set or check Anthropic API key
78
+ memory-mcp help Show help
79
+ ```
80
+
81
+ ## MCP Tools (used by Claude mid-conversation)
82
+
83
+ When configured as an MCP server, Claude can access these tools during a session:
84
+
85
+ | Tool | Description |
86
+ |------|-------------|
87
+ | `memory_search` | Keyword search across all memories |
88
+ | `memory_related` | Get memories by tag or area |
89
+ | `memory_ask` | Ask a question, get an LLM-synthesized answer from memory |
90
+ | `memory_save` | Manually save a memory |
91
+ | `memory_recall` | List all memories with filters |
92
+ | `memory_delete` | Remove a memory |
93
+ | `memory_consolidate` | Trigger memory consolidation |
94
+ | `memory_consciousness` | Generate the full consciousness document |
95
+ | `memory_stats` | Show memory statistics |
96
+ | `memory_init` | Set project name and description |
97
+
98
+ ## What Gets Stored
99
+
100
+ Memories are categorized into six types:
101
+
102
+ ```
103
+ architecture "Next.js 14 app router with Supabase backend, Stripe for billing"
104
+ decision "Chose server components for public pages because of SEO requirements"
105
+ pattern "All API routes validate input with zod and return NextResponse"
106
+ gotcha "Supabase RLS policy on word_lists requires user_id OR org_id, not both"
107
+ progress "Auth complete, billing webhook handling in progress"
108
+ context "Client wants launch by March, focus on core features only"
109
+ ```
110
+
111
+ ## File Structure
112
+
113
+ After initialization, your project gets:
114
+
115
+ ```
116
+ your-project/
117
+ ├── CLAUDE.md ← auto-updated memory summary (read on session start)
118
+ ├── .memory/
119
+ │ ├── state.json ← full memory store
120
+ │ └── cursor.json ← tracks what's been processed
121
+ ├── .mcp.json ← MCP server configuration
122
+ └── .claude/
123
+ └── settings.json ← hook configuration
124
+ ```
125
+
126
+ ## CLAUDE.md Format
127
+
128
+ The memory block is inserted between markers, preserving any existing CLAUDE.md content:
129
+
130
+ ```markdown
131
+ <!-- MEMORY:START -->
132
+ # MyProject
133
+ A brief description
134
+
135
+ _Last updated: 2026-01-27 | 45 active memories, 62 total_
136
+
137
+ ## Architecture
138
+ - Next.js 14 app router with Supabase backend
139
+ - Auth via NextAuth with Google and email providers
140
+
141
+ ## Key Decisions
142
+ - Chose server components for SEO pages
143
+ - Using Supabase RLS instead of API-level auth
144
+
145
+ ## Patterns & Conventions
146
+ - All API routes use zod validation
147
+ - Tailwind only, no CSS modules
148
+
149
+ ## Gotchas & Pitfalls
150
+ - RLS policy requires user_id OR org_id, not both
151
+
152
+ ## Current Progress
153
+ - Auth: complete
154
+ - Billing: in progress
155
+
156
+ ## Context
157
+ - Launch target: March
158
+
159
+ _For deeper context, use memory_search, memory_related, or memory_ask tools._
160
+ <!-- MEMORY:END -->
161
+ ```
162
+
163
+ ## Global vs Per-Project Install
164
+
165
+ **Global** (recommended): hooks work for all projects automatically.
166
+
167
+ ```bash
168
+ memory-mcp setup # select "global" when prompted
169
+ ```
170
+
171
+ **Per-project**: hooks and MCP configured per project.
172
+
173
+ ```bash
174
+ memory-mcp init /path/to/project
175
+ ```
176
+
177
+ ## Configuration
178
+
179
+ API key is resolved in order:
180
+ 1. `ANTHROPIC_API_KEY` environment variable
181
+ 2. `~/.memory-mcp/config.json`
182
+ 3. `~/.config/anthropic/api_key`
183
+ 4. `~/.anthropic/api_key`
184
+
185
+ ## Cost
186
+
187
+ The extractor uses Claude Haiku for memory extraction and consolidation. Typical cost:
188
+
189
+ - ~$0.001 per extraction (after each Claude response)
190
+ - ~$0.005 per consolidation (every ~10 extractions)
191
+ - A full day of coding: ~$0.05–0.10
192
+
193
+ ## License
194
+
195
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}