claude_memory 0.1.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.
- checksums.yaml +7 -0
- data/.claude/CLAUDE.md +3 -0
- data/.claude/memory.sqlite3 +0 -0
- data/.claude/output-styles/memory-aware.md +21 -0
- data/.claude/rules/claude_memory.generated.md +21 -0
- data/.claude/settings.json +62 -0
- data/.claude/settings.local.json +21 -0
- data/.claude-plugin/marketplace.json +13 -0
- data/.claude-plugin/plugin.json +10 -0
- data/.mcp.json +11 -0
- data/CHANGELOG.md +36 -0
- data/CLAUDE.md +224 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +212 -0
- data/Rakefile +10 -0
- data/commands/analyze.md +29 -0
- data/commands/recall.md +17 -0
- data/commands/remember.md +26 -0
- data/docs/demo.md +126 -0
- data/docs/organizational_memory_playbook.md +291 -0
- data/docs/plan.md +411 -0
- data/docs/plugin.md +202 -0
- data/docs/updated_plan.md +453 -0
- data/exe/claude-memory +8 -0
- data/hooks/hooks.json +59 -0
- data/lib/claude_memory/cli.rb +869 -0
- data/lib/claude_memory/distill/distiller.rb +11 -0
- data/lib/claude_memory/distill/extraction.rb +29 -0
- data/lib/claude_memory/distill/json_schema.md +78 -0
- data/lib/claude_memory/distill/null_distiller.rb +123 -0
- data/lib/claude_memory/hook/handler.rb +49 -0
- data/lib/claude_memory/index/lexical_fts.rb +58 -0
- data/lib/claude_memory/ingest/ingester.rb +46 -0
- data/lib/claude_memory/ingest/transcript_reader.rb +21 -0
- data/lib/claude_memory/mcp/server.rb +127 -0
- data/lib/claude_memory/mcp/tools.rb +409 -0
- data/lib/claude_memory/publish.rb +201 -0
- data/lib/claude_memory/recall.rb +360 -0
- data/lib/claude_memory/resolve/predicate_policy.rb +30 -0
- data/lib/claude_memory/resolve/resolver.rb +152 -0
- data/lib/claude_memory/store/sqlite_store.rb +340 -0
- data/lib/claude_memory/store/store_manager.rb +139 -0
- data/lib/claude_memory/sweep/sweeper.rb +80 -0
- data/lib/claude_memory/templates/hooks.example.json +74 -0
- data/lib/claude_memory/templates/output-styles/memory-aware.md +21 -0
- data/lib/claude_memory/version.rb +5 -0
- data/lib/claude_memory.rb +36 -0
- data/sig/claude_memory.rbs +4 -0
- data/skills/analyze/SKILL.md +126 -0
- data/skills/memory/SKILL.md +82 -0
- metadata +123 -0
data/docs/plan.md
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# ClaudeMemory Plan (for Claude Code)
|
|
2
|
+
Turn-key Ruby gem providing Claude Code with instant, high-quality, long-term, self-managed memory using **Claude Code Hooks + MCP + Output Style**, with **minimal dependencies** (SQLite by default).
|
|
3
|
+
|
|
4
|
+
This file is designed to be handed to Claude Code so it can iteratively implement the project end-to-end. Follow the milestones in order, keep commits small, and keep the project runnable at every step.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## North Star
|
|
9
|
+
**ClaudeMemory** continuously ingests Claude Code transcripts, distills them into durable “Facts” with provenance and time validity, resolves contradictions into **supersession** or **conflicts**, and exposes memory via:
|
|
10
|
+
- **Automated ingestion + sweep** using Claude Code hooks
|
|
11
|
+
- **On-demand recall/explain** via an **MCP server**
|
|
12
|
+
- A **project Output Style** that encourages memory-aware behavior and consistent formatting
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Success criteria (MVP)
|
|
17
|
+
1) `claude-memory init` creates a working setup in a repo:
|
|
18
|
+
- local SQLite DB
|
|
19
|
+
- sample Claude Code hooks config snippet (Stop + SessionStart + PreCompact + SessionEnd + Notification idle_prompt)
|
|
20
|
+
- Output Style file template
|
|
21
|
+
- MCP server config instructions
|
|
22
|
+
2) When Claude Code runs in the repo, hooks trigger:
|
|
23
|
+
- **ingest** on Stop + safety events
|
|
24
|
+
- **sweep** on idle_prompt + safety events
|
|
25
|
+
3) ClaudeMemory can **publish a thin “Current Truth Snapshot”** into Claude Code memory files:
|
|
26
|
+
- generates `.claude/rules/claude_memory.generated.md` (and optional path-scoped rule files)
|
|
27
|
+
- top-level `.claude/CLAUDE.md` includes an `@.claude/rules/claude_memory.generated.md` import
|
|
28
|
+
- snapshot stays concise (decisions/conventions/constraints/conflicts)
|
|
29
|
+
4) `claude-memory recall "..."` returns relevant **canonical facts** plus at least one **receipt** per fact after a few Claude turns.
|
|
30
|
+
5) Contradictory beliefs do **not** overwrite silently:
|
|
31
|
+
- if explicit replacement or strong provenance: create **supersedes** link and close old validity window
|
|
32
|
+
- otherwise: create **conflict** record
|
|
33
|
+
6) Everything runs **locally by default** with minimal dependencies:
|
|
34
|
+
- SQLite file DB (required)
|
|
35
|
+
- No embeddings required for MVP
|
|
36
|
+
- LLM distillation is pluggable (MVP can ship with a stub distiller)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Non-goals (MVP)
|
|
41
|
+
- No full RDF/SPARQL store
|
|
42
|
+
- No multi-source ingestion (Slack/GitHub/etc.) beyond transcript ingestion
|
|
43
|
+
- No complex UI (CLI + MCP is enough)
|
|
44
|
+
- No mandatory background daemon (hooks drive automation)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Repository structure (target)
|
|
49
|
+
```
|
|
50
|
+
claude_memory/
|
|
51
|
+
lib/
|
|
52
|
+
claude_memory.rb
|
|
53
|
+
claude_memory/
|
|
54
|
+
version.rb
|
|
55
|
+
config.rb
|
|
56
|
+
store/
|
|
57
|
+
sqlite_store.rb
|
|
58
|
+
migrations.rb
|
|
59
|
+
ingest/
|
|
60
|
+
delta_cursor.rb
|
|
61
|
+
transcript_reader.rb
|
|
62
|
+
distill/
|
|
63
|
+
distiller.rb
|
|
64
|
+
null_distiller.rb
|
|
65
|
+
json_schema.md
|
|
66
|
+
prompts/
|
|
67
|
+
resolve/
|
|
68
|
+
predicate_policy.rb
|
|
69
|
+
resolver.rb
|
|
70
|
+
index/
|
|
71
|
+
lexical_fts.rb
|
|
72
|
+
mcp/
|
|
73
|
+
server.rb
|
|
74
|
+
tools.rb
|
|
75
|
+
sweep/
|
|
76
|
+
sweeper.rb
|
|
77
|
+
cli.rb
|
|
78
|
+
templates/
|
|
79
|
+
hooks.example.json
|
|
80
|
+
output-styles/
|
|
81
|
+
memory-aware.md
|
|
82
|
+
exe/
|
|
83
|
+
claude-memory
|
|
84
|
+
spec/
|
|
85
|
+
plan.md
|
|
86
|
+
README.md
|
|
87
|
+
LICENSE
|
|
88
|
+
Gemfile
|
|
89
|
+
claude_memory.gemspec
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Implementation principles
|
|
95
|
+
- **Ship thin vertical slices**: ingest → store → recall in smallest increments.
|
|
96
|
+
- **Idempotency** is sacred: re-running ingest must not duplicate.
|
|
97
|
+
- **Determinism first**: resolver rules should be consistent without LLM judgment.
|
|
98
|
+
- **Time-bounded sweep**: sweep must accept a `--budget` and stop within it.
|
|
99
|
+
- **Explainability**: every recalled statement can point back to receipts.
|
|
100
|
+
- **Minimal deps**: prefer stdlib; required external gems should be few.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Glossary
|
|
105
|
+
- **Content**: immutable evidence (transcript text + metadata)
|
|
106
|
+
- **Delta**: only new transcript content since last ingest
|
|
107
|
+
- **Entity**: identity-resolved “thing” (repo/module/person/service)
|
|
108
|
+
- **Fact**: atomic assertion with validity window + status + confidence
|
|
109
|
+
- **Provenance**: receipts: links from facts to content excerpts
|
|
110
|
+
- **Supersession**: new fact replaces old fact for the same slot
|
|
111
|
+
- **Conflict**: overlapping contradictory facts without supersession signal
|
|
112
|
+
- **Sweep**: maintenance/pruning/compaction process
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Milestones and tasks
|
|
117
|
+
|
|
118
|
+
### Milestone 0: Bootstrap the gem skeleton (1–2 commits)
|
|
119
|
+
**Goal:** A runnable Ruby gem with CLI entry point and tests.
|
|
120
|
+
|
|
121
|
+
Tasks
|
|
122
|
+
- Create gem scaffold (`bundle gem claude_memory`) if not already.
|
|
123
|
+
- Add `exe/claude-memory` that calls `ClaudeMemory::CLI`.
|
|
124
|
+
- Add RSpec (or Minitest) test harness.
|
|
125
|
+
- Add basic `README.md` describing purpose and MVP commands.
|
|
126
|
+
|
|
127
|
+
Acceptance checks
|
|
128
|
+
- `bundle exec rspec` passes (even if only a dummy test)
|
|
129
|
+
- `bundle exec exe/claude-memory --help` prints help
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### Milestone 1: SQLite Store + schema (2–4 commits)
|
|
134
|
+
**Goal:** Persist content, cursors, entities, facts, provenance, conflicts.
|
|
135
|
+
|
|
136
|
+
Design decisions
|
|
137
|
+
- Store is a single SQLite file (default `.claude_memory.sqlite3` in repo root, configurable).
|
|
138
|
+
- Use a minimal migration mechanism (Ruby-based schema creator on first run).
|
|
139
|
+
|
|
140
|
+
Tables (MVP)
|
|
141
|
+
- `meta`: key/value (db_version, created_at)
|
|
142
|
+
- `content_items`: id, source, session_id, transcript_path, occurred_at, ingested_at, text_hash, byte_len, raw_text (or chunk storage), metadata_json
|
|
143
|
+
- `delta_cursors`: id, session_id, transcript_path, last_byte_offset, updated_at
|
|
144
|
+
- `entities`: id, type, canonical_name, slug, created_at
|
|
145
|
+
- `entity_aliases`: id, entity_id, source, alias, confidence
|
|
146
|
+
- `facts`: id, subject_entity_id, predicate, object_entity_id, object_literal, datatype, polarity, valid_from, valid_to, status, confidence, created_from, created_at
|
|
147
|
+
- `provenance`: id, fact_id, content_item_id, quote, attribution_entity_id, strength
|
|
148
|
+
- `fact_links`: id, from_fact_id, to_fact_id, link_type
|
|
149
|
+
- `conflicts`: id, fact_a_id, fact_b_id, status, detected_at, notes
|
|
150
|
+
|
|
151
|
+
Tasks
|
|
152
|
+
- Implement `ClaudeMemory::Store::SQLiteStore`:
|
|
153
|
+
- open DB, ensure schema, basic CRUD helpers
|
|
154
|
+
- JSON encode/decode helpers
|
|
155
|
+
- Implement migrations:
|
|
156
|
+
- `ensure_schema!` checks meta/db_version and creates tables if missing
|
|
157
|
+
- Implement store methods needed later:
|
|
158
|
+
- `upsert_content_item(...)`
|
|
159
|
+
- `get_delta_cursor(session_id, transcript_path)`
|
|
160
|
+
- `update_delta_cursor(...)`
|
|
161
|
+
- `facts_for_slot(subject_id, predicate)`
|
|
162
|
+
- `insert_fact(...)`, `update_fact(...)`
|
|
163
|
+
- `insert_provenance(...)`
|
|
164
|
+
- `insert_conflict(...)`
|
|
165
|
+
|
|
166
|
+
Acceptance checks
|
|
167
|
+
- `claude-memory db:init` creates DB file and schema
|
|
168
|
+
- Running twice is idempotent
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### Milestone 2: Transcript delta ingestion (2–4 commits)
|
|
173
|
+
**Goal:** Ingest transcript deltas using transcript_path + session_id.
|
|
174
|
+
|
|
175
|
+
Process flow
|
|
176
|
+
- CLI receives `--transcript_path` and `--session_id`.
|
|
177
|
+
- Read file size, compare to stored cursor offset.
|
|
178
|
+
- If file shrank (compaction/rotate), reset offset to 0.
|
|
179
|
+
- Read only new bytes from last offset.
|
|
180
|
+
- Store a `content_item` with delta payload and metadata.
|
|
181
|
+
- Update cursor offset.
|
|
182
|
+
|
|
183
|
+
Tasks
|
|
184
|
+
- Implement `Ingest::TranscriptReader.read_delta(path, from_offset)`
|
|
185
|
+
- Implement CLI command: `claude-memory ingest --source claude_code --session_id ... --transcript_path ...`
|
|
186
|
+
- Store `content_item` record with occurred_at/ingested_at now.
|
|
187
|
+
|
|
188
|
+
Acceptance checks
|
|
189
|
+
- No-change ingest does nothing
|
|
190
|
+
- Appending text creates a new content_item and cursor update
|
|
191
|
+
- Reset behavior when file shrinks works
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### Milestone 3: Lexical index for recall (MVP) (2–5 commits)
|
|
196
|
+
**Goal:** Provide fast search without embeddings.
|
|
197
|
+
|
|
198
|
+
Preferred: SQLite FTS5 (fallback to pure Ruby index if needed)
|
|
199
|
+
|
|
200
|
+
Tasks
|
|
201
|
+
- Implement `Index::LexicalFTS`:
|
|
202
|
+
- `index_content_item(id, text)`
|
|
203
|
+
- `search(query, limit) => ids`
|
|
204
|
+
- Implement `claude-memory search "query"` for debugging.
|
|
205
|
+
|
|
206
|
+
Acceptance checks
|
|
207
|
+
- Search returns recently ingested deltas containing query terms
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### Milestone 4: Distiller interface + NullDistiller (2–4 commits)
|
|
212
|
+
**Goal:** Define extraction contract; ship with stub distiller.
|
|
213
|
+
|
|
214
|
+
Extraction schema (v1)
|
|
215
|
+
- entities: [{type, name, aliases?, confidence?}]
|
|
216
|
+
- facts: [{subject, predicate, object, polarity, confidence, quote, strength, time_hint, decision_ref?}]
|
|
217
|
+
- decisions: [{title, summary, status_hint, emits_fact_indexes}]
|
|
218
|
+
- signals: [{kind, value}]
|
|
219
|
+
|
|
220
|
+
Tasks
|
|
221
|
+
- Implement `Distill::Distiller` interface
|
|
222
|
+
- Implement `Distill::NullDistiller` with minimal heuristics
|
|
223
|
+
- Document schema in `json_schema.md`
|
|
224
|
+
|
|
225
|
+
Acceptance checks
|
|
226
|
+
- Distill returns an Extraction object even without LLM
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
### Milestone 5: Resolver (truth maintenance) (3–6 commits)
|
|
231
|
+
**Goal:** Deterministic equivalent/additive/supersession/conflict rules.
|
|
232
|
+
|
|
233
|
+
Tasks
|
|
234
|
+
- Implement `PredicatePolicy` registry
|
|
235
|
+
- Implement `Resolve::Resolver.apply(extraction, occurred_at:)`
|
|
236
|
+
- Persist facts, provenance, fact_links, conflicts
|
|
237
|
+
|
|
238
|
+
Acceptance checks
|
|
239
|
+
- Contradiction without explicit replace creates conflict
|
|
240
|
+
- Explicit replace/switch/no longer triggers supersession and closes old validity
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### Milestone 6: Recall + Explain (CLI) (2–4 commits)
|
|
245
|
+
**Goal:** Human-usable recall and receipts.
|
|
246
|
+
|
|
247
|
+
Tasks
|
|
248
|
+
- `claude-memory recall "query"` returns facts + receipts + conflicts
|
|
249
|
+
- `claude-memory explain FACT_ID` returns provenance receipts
|
|
250
|
+
- `claude-memory changes --since ...` basic support
|
|
251
|
+
|
|
252
|
+
Acceptance checks
|
|
253
|
+
- Recall returns canonical facts + receipts after a few turns
|
|
254
|
+
- Explain prints receipts
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
### Milestone 7: Sweep mechanics (2–5 commits)
|
|
259
|
+
**Goal:** Maintenance runs quickly and safely via hooks.
|
|
260
|
+
|
|
261
|
+
Tasks
|
|
262
|
+
- Implement `Sweep::Sweeper.run!(budget_seconds:)`
|
|
263
|
+
- CLI: `claude-memory sweep --budget 5s`
|
|
264
|
+
|
|
265
|
+
Acceptance checks
|
|
266
|
+
- Sweep honors budget, safe to run repeatedly
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### Milestone 8: MCP server (3–6 commits)
|
|
271
|
+
**Goal:** Provide memory tools to Claude Code.
|
|
272
|
+
|
|
273
|
+
Tools (MVP)
|
|
274
|
+
- memory.recall, memory.explain, memory.changes, memory.conflicts, memory.sweep_now, memory.status
|
|
275
|
+
|
|
276
|
+
Tasks
|
|
277
|
+
- Implement MCP server + tools
|
|
278
|
+
- CLI: `claude-memory serve-mcp`
|
|
279
|
+
|
|
280
|
+
Acceptance checks
|
|
281
|
+
- Server starts, tools return compact JSON
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
### Milestone 9: Claude Code hooks templates (2–3 commits)
|
|
286
|
+
**Goal:** Turn-key automation configuration.
|
|
287
|
+
|
|
288
|
+
Templates
|
|
289
|
+
- Stop -> ingest
|
|
290
|
+
- SessionStart -> ingest catch-up
|
|
291
|
+
- PreCompact -> ingest flush + sweep
|
|
292
|
+
- SessionEnd -> ingest flush + sweep
|
|
293
|
+
- Notification idle_prompt -> sweep budget small
|
|
294
|
+
|
|
295
|
+
Tasks
|
|
296
|
+
- `claude-memory init` prints/copies templates
|
|
297
|
+
|
|
298
|
+
Acceptance checks
|
|
299
|
+
- Easy to apply; referenced commands exist
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
### Milestone 10: Output Style template (1–2 commits)
|
|
304
|
+
**Goal:** Encourage memory-aware behavior without breaking coding guidance.
|
|
305
|
+
|
|
306
|
+
Tasks
|
|
307
|
+
- Provide `memory-aware.md` with `keep-coding-instructions: true`
|
|
308
|
+
- Installed/referenced by `init`
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
### Milestone 10.5: Publish snapshot to Claude Code memory (2–4 commits)
|
|
313
|
+
**Goal:** Use Claude Code’s built-in memory system as a **curated publishing layer** (thin “RAM”), while SQLite remains the truth-maintained store.
|
|
314
|
+
|
|
315
|
+
Key Claude Code memory behaviors to lean into
|
|
316
|
+
- Project memory files: `./CLAUDE.md` or `./.claude/CLAUDE.md`
|
|
317
|
+
- Modular project rules: `./.claude/rules/*.md` (auto-loaded)
|
|
318
|
+
- Path-scoped rules via YAML frontmatter `paths:` globs
|
|
319
|
+
- Imports via `@relative/path` (depth capped), enabling a small hand-written top-level file that imports a generated snapshot
|
|
320
|
+
- Nested subtree memory loads lazily when Claude reads files in that subtree (useful for monorepos)
|
|
321
|
+
|
|
322
|
+
Outputs (MVP)
|
|
323
|
+
- `.claude/rules/claude_memory.generated.md` (generated, concise)
|
|
324
|
+
- Optional: `.claude/rules/claude_memory.<area>.md` files with `paths:` frontmatter for major modules (auth, deploy, etc.)
|
|
325
|
+
- Ensure `.claude/CLAUDE.md` (or `CLAUDE.md`) imports the generated file:
|
|
326
|
+
- Add a single line: `@.claude/rules/claude_memory.generated.md`
|
|
327
|
+
|
|
328
|
+
Snapshot format guidance
|
|
329
|
+
- Keep it short, structured, and reviewable:
|
|
330
|
+
- **Current Decisions**
|
|
331
|
+
- **Conventions**
|
|
332
|
+
- **Known Constraints**
|
|
333
|
+
- **Open Conflicts**
|
|
334
|
+
- Prefer bullets over paragraphs; avoid dumping raw logs or long histories.
|
|
335
|
+
|
|
336
|
+
Tasks
|
|
337
|
+
- Add CLI: `claude-memory publish`
|
|
338
|
+
- Modes:
|
|
339
|
+
- `--mode shared` writes generated files under `.claude/rules/`
|
|
340
|
+
- `--mode local` writes into `CLAUDE.local.md` or a local-only generated file
|
|
341
|
+
- Granularity:
|
|
342
|
+
- `--granularity repo` writes a single snapshot
|
|
343
|
+
- `--granularity paths` writes repo + a few path-scoped rule files (optional, MVP can start with repo-only)
|
|
344
|
+
- Selection:
|
|
345
|
+
- default to “current canonical facts + open conflicts + recent supersessions”
|
|
346
|
+
- optionally allow `--since <iso>` for “recent changes only”
|
|
347
|
+
- Add `init` behavior:
|
|
348
|
+
- Create `.claude/rules/` if missing
|
|
349
|
+
- Install a minimal `.claude/CLAUDE.md` (if user opts in) that imports the generated snapshot
|
|
350
|
+
- Or print clear instructions for the import line
|
|
351
|
+
- Add a “no-churn” strategy:
|
|
352
|
+
- Only rewrite generated files if content actually changed (hash compare) to reduce noisy diffs
|
|
353
|
+
|
|
354
|
+
Optional hook wiring (recommended)
|
|
355
|
+
- Publish only on “safe events”:
|
|
356
|
+
- `SessionEnd` and/or `PreCompact`
|
|
357
|
+
- Keep it budgeted and/or incremental (avoid running on every Stop)
|
|
358
|
+
|
|
359
|
+
Acceptance checks
|
|
360
|
+
- Running `publish` produces a concise snapshot that Claude Code loads automatically
|
|
361
|
+
- Editing files under a path-scoped rule causes that scoped memory to apply (paths mode)
|
|
362
|
+
- Re-running publish with no changes does not rewrite files unnecessarily
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
### Milestone 11: End-to-end demo + doctor (1–2 commits)
|
|
366
|
+
**Goal:** Verify full loop.
|
|
367
|
+
|
|
368
|
+
Tasks
|
|
369
|
+
- `docs/demo.md`
|
|
370
|
+
- `claude-memory doctor` validates DB, last ingest, and optional MCP
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
### Milestone 12: Packaging + Release hygiene (2–4 commits)
|
|
375
|
+
**Goal:** Make it usable by others.
|
|
376
|
+
|
|
377
|
+
Tasks
|
|
378
|
+
- README install + usage
|
|
379
|
+
- CI
|
|
380
|
+
- `gem build` succeeds
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Command surface (target)
|
|
385
|
+
- claude-memory init
|
|
386
|
+
- claude-memory publish [--mode shared|local] [--granularity repo|paths] [--since <iso>]
|
|
387
|
+
- claude-memory ingest --source claude_code --session_id ... --transcript_path ...
|
|
388
|
+
- claude-memory recall "..."
|
|
389
|
+
- claude-memory explain FACT_ID
|
|
390
|
+
- claude-memory conflicts
|
|
391
|
+
- claude-memory changes --since ...
|
|
392
|
+
- claude-memory sweep --budget 5s
|
|
393
|
+
- claude-memory serve-mcp
|
|
394
|
+
- claude-memory doctor
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Appendices
|
|
399
|
+
|
|
400
|
+
### Appendix A: Suggested initial predicate policies (MVP)
|
|
401
|
+
- convention: multi, non-exclusive
|
|
402
|
+
- decision: multi (by scope)
|
|
403
|
+
- auth_method: single, exclusive
|
|
404
|
+
- uses_database: single, exclusive
|
|
405
|
+
- deployment_platform: single, exclusive
|
|
406
|
+
|
|
407
|
+
### Appendix B: Suggested sweep defaults (MVP)
|
|
408
|
+
- proposed_fact_ttl_days: 14
|
|
409
|
+
- disputed_fact_ttl_days: 30
|
|
410
|
+
- content_retention_days: 30 (purge only if not referenced by provenance)
|
|
411
|
+
- default sweep budget: 5s (idle_prompt), 15s (session end)
|
data/docs/plugin.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# ClaudeMemory Plugin for Claude Code
|
|
2
|
+
|
|
3
|
+
ClaudeMemory integrates with Claude Code as a plugin, providing long-term memory capabilities powered by Claude's own intelligence.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
The `claude-memory` gem must be installed and available in your PATH:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
gem install claude_memory
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Install the Plugin
|
|
16
|
+
|
|
17
|
+
From within Claude Code:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Add the marketplace (use the path to your claude_memory directory)
|
|
21
|
+
/plugin marketplace add /path/to/claude_memory
|
|
22
|
+
|
|
23
|
+
# Install the plugin
|
|
24
|
+
/plugin install claude-memory
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Verify Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Check plugin is loaded
|
|
31
|
+
/plugin
|
|
32
|
+
# Go to "Installed" tab - should see claude-memory
|
|
33
|
+
|
|
34
|
+
# Check MCP tools are available
|
|
35
|
+
# Ask Claude: "check memory status"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## How It Works
|
|
39
|
+
|
|
40
|
+
### Claude-Powered Fact Extraction
|
|
41
|
+
|
|
42
|
+
Unlike traditional approaches that require a separate API key, ClaudeMemory uses **prompt hooks** to leverage Claude Code's own session:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
46
|
+
│ Claude Code Session │
|
|
47
|
+
├─────────────────────────────────────────────────────────────┤
|
|
48
|
+
│ 1. User has conversation with Claude │
|
|
49
|
+
│ 2. Session stops (user done, timeout, etc.) │
|
|
50
|
+
│ 3. Stop hook triggers prompt hook │
|
|
51
|
+
│ 4. Claude reviews session, extracts durable facts │
|
|
52
|
+
│ 5. Claude calls memory.store_extraction MCP tool │
|
|
53
|
+
│ 6. Facts stored in SQLite with truth maintenance │
|
|
54
|
+
└─────────────────────────────────────────────────────────────┘
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Benefits
|
|
58
|
+
|
|
59
|
+
| Feature | Traditional API | Claude-Powered |
|
|
60
|
+
|---------|-----------------|----------------|
|
|
61
|
+
| API Key Required | ✅ Yes | ❌ No |
|
|
62
|
+
| Extra Cost | ✅ Per-token | ❌ None |
|
|
63
|
+
| Context Awareness | Limited | Full session context |
|
|
64
|
+
| Extraction Quality | Template-based | Intelligent |
|
|
65
|
+
|
|
66
|
+
## Plugin Components
|
|
67
|
+
|
|
68
|
+
### MCP Server
|
|
69
|
+
|
|
70
|
+
The plugin exposes these tools to Claude:
|
|
71
|
+
|
|
72
|
+
| Tool | Description |
|
|
73
|
+
|------|-------------|
|
|
74
|
+
| `memory.recall` | Search facts by query |
|
|
75
|
+
| `memory.explain` | Get fact details with provenance |
|
|
76
|
+
| `memory.store_extraction` | Store extracted facts |
|
|
77
|
+
| `memory.promote` | Promote project fact to global |
|
|
78
|
+
| `memory.status` | Check database health |
|
|
79
|
+
| `memory.changes` | Recent fact updates |
|
|
80
|
+
| `memory.conflicts` | Open contradictions |
|
|
81
|
+
| `memory.sweep_now` | Run maintenance |
|
|
82
|
+
|
|
83
|
+
### Hooks
|
|
84
|
+
|
|
85
|
+
| Event | Hook Type | Action |
|
|
86
|
+
|-------|-----------|--------|
|
|
87
|
+
| `Stop` | command | Ingest transcript delta |
|
|
88
|
+
| `Stop` | prompt | Ask Claude to extract facts |
|
|
89
|
+
| `SessionStart` | command | Ingest any missed content |
|
|
90
|
+
| `PreCompact` | command + prompt | Ingest, extract, then publish |
|
|
91
|
+
| `Notification` (idle) | command | Run sweep maintenance |
|
|
92
|
+
| `SessionEnd` | command | Publish snapshot |
|
|
93
|
+
|
|
94
|
+
### Skill
|
|
95
|
+
|
|
96
|
+
The `/memory` skill provides manual access:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
/memory
|
|
100
|
+
# Shows available memory commands and usage
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Configuration
|
|
104
|
+
|
|
105
|
+
### Database Locations
|
|
106
|
+
|
|
107
|
+
| Database | Path | Purpose |
|
|
108
|
+
|----------|------|---------|
|
|
109
|
+
| Global | `~/.claude/memory.sqlite3` | User-wide facts |
|
|
110
|
+
| Project | `.claude/memory.sqlite3` | Project-specific facts |
|
|
111
|
+
|
|
112
|
+
### Scope System
|
|
113
|
+
|
|
114
|
+
Facts are scoped to control where they apply:
|
|
115
|
+
|
|
116
|
+
- **project**: Only this project (e.g., "this app uses PostgreSQL")
|
|
117
|
+
- **global**: All projects (e.g., "I prefer 4-space indentation")
|
|
118
|
+
|
|
119
|
+
Claude automatically detects scope signals:
|
|
120
|
+
- "always", "in all projects", "my preference" → global
|
|
121
|
+
- Project-specific tech choices → project
|
|
122
|
+
|
|
123
|
+
## Usage Examples
|
|
124
|
+
|
|
125
|
+
### Natural Conversation
|
|
126
|
+
|
|
127
|
+
Just talk to Claude naturally. Facts are extracted automatically:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
User: "We're using PostgreSQL for the database and deploying to Vercel"
|
|
131
|
+
Claude: [works on task]
|
|
132
|
+
# On session stop, extracts:
|
|
133
|
+
# - uses_database: postgresql (project scope)
|
|
134
|
+
# - deployment_platform: vercel (project scope)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Check What's Remembered
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
User: "What do you remember about our tech stack?"
|
|
141
|
+
Claude: [calls memory.recall] "Based on my memory, this project uses..."
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Promote to Global
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
User: "I always prefer 4-space indentation - remember that globally"
|
|
148
|
+
Claude: [stores with scope_hint: global]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### View Conflicts
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
User: "Are there any conflicting facts?"
|
|
155
|
+
Claude: [calls memory.conflicts] "I found 2 conflicts..."
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Troubleshooting
|
|
159
|
+
|
|
160
|
+
### MCP Tools Not Appearing
|
|
161
|
+
|
|
162
|
+
1. Check `claude-memory` is in PATH: `which claude-memory`
|
|
163
|
+
2. Verify plugin is installed: `/plugin` → Installed tab
|
|
164
|
+
3. Check for errors: `/plugin` → Errors tab
|
|
165
|
+
4. Restart Claude Code
|
|
166
|
+
|
|
167
|
+
### Facts Not Being Extracted
|
|
168
|
+
|
|
169
|
+
1. Prompt hooks require session to stop (not just pause)
|
|
170
|
+
2. Check if hooks are registered: Run with `claude --debug`
|
|
171
|
+
3. Verify database exists: `claude-memory doctor`
|
|
172
|
+
|
|
173
|
+
### Database Issues
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Check health
|
|
177
|
+
claude-memory doctor
|
|
178
|
+
|
|
179
|
+
# Reinitialize if needed
|
|
180
|
+
claude-memory db:init
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## File Structure
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
claude_memory/
|
|
187
|
+
├── .claude-plugin/
|
|
188
|
+
│ ├── plugin.json # Plugin manifest
|
|
189
|
+
│ └── marketplace.json # Marketplace definition
|
|
190
|
+
├── .mcp.json # MCP server config
|
|
191
|
+
├── hooks/
|
|
192
|
+
│ └── hooks.json # Hook definitions
|
|
193
|
+
└── skills/
|
|
194
|
+
└── memory/
|
|
195
|
+
└── SKILL.md # /memory skill
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## See Also
|
|
199
|
+
|
|
200
|
+
- [README.md](../README.md) - Full project documentation
|
|
201
|
+
- [CLAUDE.md](../CLAUDE.md) - Development guidance
|
|
202
|
+
- [updated_plan.md](updated_plan.md) - Architecture deep dive
|