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
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
# Updated ClaudeMemory Plan (for Claude Code)
|
|
2
|
+
|
|
3
|
+
## Architecture Overview
|
|
4
|
+
|
|
5
|
+
ClaudeMemory uses a **dual-database architecture**:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
~/.claude/memory.sqlite3 # Global DB - user-wide knowledge
|
|
9
|
+
.claude/memory.sqlite3 # Project DB - project-specific facts
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**Key components:**
|
|
13
|
+
- `Store::StoreManager` — manages both database connections
|
|
14
|
+
- `Recall` — queries both databases, merges results (project facts prioritized)
|
|
15
|
+
- `promote` command — graduates project facts to global memory
|
|
16
|
+
- MCP server — exposes tools that query both databases
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What changed from the original plan (specifically changed, not brand new)
|
|
21
|
+
These items are **modifications to the original plan’s approach**, driven by Claude Code’s official docs for Settings, Memory, Plugins, and Hooks.
|
|
22
|
+
|
|
23
|
+
1) **Hooks configuration now targets Claude Code Settings files**
|
|
24
|
+
- Replaced “drop-in hooks template JSON” with an `init` flow that **creates/merges** hook config into:
|
|
25
|
+
- `.claude/settings.json` (team/shared, committed)
|
|
26
|
+
- `.claude/settings.local.json` (personal, uncommitted)
|
|
27
|
+
|
|
28
|
+
2) **Hook execution is now routed through a dedicated CLI “hook entrypoint”**
|
|
29
|
+
- Instead of relying on shell parsing or external tooling (e.g. `jq`), hooks call:
|
|
30
|
+
- `claude-memory hook ingest`
|
|
31
|
+
- `claude-memory hook sweep`
|
|
32
|
+
- `claude-memory hook publish`
|
|
33
|
+
- These commands **read the hook payload JSON from stdin** and act deterministically.
|
|
34
|
+
|
|
35
|
+
3) **Hook time-bounding is explicit**
|
|
36
|
+
- Hook configurations include per-hook `timeout` values, aligned with “sweep/publish should never stall coding”.
|
|
37
|
+
|
|
38
|
+
4) **Enterprise/managed environments are acknowledged**
|
|
39
|
+
- The plan now includes a documented fallback when hooks are blocked (e.g., managed “hooks only” policies):
|
|
40
|
+
- manual CLI workflows remain fully usable
|
|
41
|
+
- `doctor` reports likely restriction states and suggests safe alternatives
|
|
42
|
+
|
|
43
|
+
5) **Publishing to Claude Code memory now supports more targets**
|
|
44
|
+
- “Publish snapshot” now supports:
|
|
45
|
+
- repo-shared rules import (`.claude/rules/*.md`)
|
|
46
|
+
- project-local private (`CLAUDE.local.md`)
|
|
47
|
+
- home-dir shared (`~/.claude/...`) with import wiring
|
|
48
|
+
- Also adds an optional “nested subtree” publishing strategy for monorepos.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## New aspects added to the plan (and how to execute them)
|
|
53
|
+
The sections below describe the **newly added capabilities** and where they fit into implementation milestones.
|
|
54
|
+
|
|
55
|
+
### F) Dual-database architecture ✅ IMPLEMENTED
|
|
56
|
+
**Goal:** Separate global and project-specific memory into distinct databases.
|
|
57
|
+
|
|
58
|
+
**Problem**
|
|
59
|
+
- Single database approach conflates cross-project knowledge with project-specific facts
|
|
60
|
+
- Project A's decisions can pollute Project B's recall
|
|
61
|
+
- Need both persistent user-wide knowledge AND project-specific knowledge
|
|
62
|
+
|
|
63
|
+
**Solution: Two separate SQLite databases**
|
|
64
|
+
|
|
65
|
+
1. **Database locations**
|
|
66
|
+
- **Global DB**: `~/.claude/memory.sqlite3` — user-wide knowledge that persists across all projects
|
|
67
|
+
- **Project DB**: `.claude/memory.sqlite3` — project-specific facts, lives in project directory
|
|
68
|
+
|
|
69
|
+
2. **StoreManager class**
|
|
70
|
+
- Manages both database connections via `Store::StoreManager`
|
|
71
|
+
- Lazy initialization: databases created on first use
|
|
72
|
+
- `ensure_global!`, `ensure_project!`, `ensure_both!` methods
|
|
73
|
+
- `promote_fact(fact_id)` copies a project fact to global DB
|
|
74
|
+
|
|
75
|
+
3. **Recall searches both databases**
|
|
76
|
+
- Queries both databases when `scope: all` (default)
|
|
77
|
+
- Deduplicates by fact signature (subject:predicate:object)
|
|
78
|
+
- Project facts take precedence over global facts
|
|
79
|
+
- `--scope project` queries only project DB
|
|
80
|
+
- `--scope global` queries only global DB
|
|
81
|
+
|
|
82
|
+
4. **Promote command for fact graduation**
|
|
83
|
+
- `claude-memory promote <fact_id>` copies a project fact to global
|
|
84
|
+
- Copies entity, fact, and provenance records
|
|
85
|
+
- Use when user says a preference should apply everywhere
|
|
86
|
+
|
|
87
|
+
5. **MCP tools updated**
|
|
88
|
+
- `memory.status` returns stats for both databases
|
|
89
|
+
- `memory.promote` promotes facts via MCP
|
|
90
|
+
- `memory.explain` accepts `scope` parameter
|
|
91
|
+
|
|
92
|
+
**Alignment with Organizational Memory Playbook**
|
|
93
|
+
- Axiom 2: Truth is temporal → extends to spatial (project context)
|
|
94
|
+
- Axiom 4: Provenance includes WHERE (which project/database)
|
|
95
|
+
- Scale 2: "Which belief is in force?" → database + scope determines applicability
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### A) Settings-driven hook installation (instead of standalone templates)
|
|
100
|
+
**Goal:** Make setup “Claude-native” by writing hooks into the real settings locations Claude Code reads.
|
|
101
|
+
|
|
102
|
+
**Implementation notes (process-level)**
|
|
103
|
+
- `claude-memory init` should:
|
|
104
|
+
1) Detect whether `.claude/settings.json` exists
|
|
105
|
+
2) Merge in a `hooks` section (do not overwrite unrelated settings)
|
|
106
|
+
3) Optionally add entries to `.claude/settings.local.json` when the user selects local-only behavior
|
|
107
|
+
4) Use environment variables like `$CLAUDE_PROJECT_DIR` in commands where helpful
|
|
108
|
+
5) Print a “what changed” summary so the user can review diffs
|
|
109
|
+
|
|
110
|
+
**Design preference**
|
|
111
|
+
- Keep “team-wide” automation minimal and safe:
|
|
112
|
+
- ingest on Stop + safety events
|
|
113
|
+
- sweep on idle_prompt + safety events
|
|
114
|
+
- publish only on SessionEnd/PreCompact (optional, avoids churn)
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### B) Hook entrypoint subcommands (stdin JSON)
|
|
119
|
+
**Goal:** Make hooks robust, cross-platform, and dependency-light.
|
|
120
|
+
|
|
121
|
+
**Commands**
|
|
122
|
+
- `claude-memory hook ingest`
|
|
123
|
+
- `claude-memory hook sweep`
|
|
124
|
+
- `claude-memory hook publish`
|
|
125
|
+
|
|
126
|
+
**Process flow**
|
|
127
|
+
- Claude Code runs the hook command and provides event payload JSON to stdin.
|
|
128
|
+
- The hook command:
|
|
129
|
+
- parses stdin JSON
|
|
130
|
+
- extracts `session_id`, `transcript_path`, the hook event name, and any useful metadata
|
|
131
|
+
- calls the internal action (ingest/sweep/publish)
|
|
132
|
+
- exits quickly with clear exit codes (0 success, non-zero on error)
|
|
133
|
+
|
|
134
|
+
**Benefits**
|
|
135
|
+
- Avoids `jq`
|
|
136
|
+
- Avoids shell quoting bugs
|
|
137
|
+
- Makes local testing easy (replay fixtures)
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### C) Managed hooks restriction fallback
|
|
142
|
+
**Goal:** Ensure ClaudeMemory is still usable even when hooks are restricted by enterprise policy.
|
|
143
|
+
|
|
144
|
+
**Behavior**
|
|
145
|
+
- If hooks appear blocked/ignored:
|
|
146
|
+
- user runs `claude-memory ingest` manually (or via slash command if plugin is enabled)
|
|
147
|
+
- sweep/publish can be run on demand
|
|
148
|
+
|
|
149
|
+
**Doctor improvements**
|
|
150
|
+
- `claude-memory doctor` should:
|
|
151
|
+
- verify settings file presence and hook configuration
|
|
152
|
+
- warn if the environment is likely to ignore user/project hooks
|
|
153
|
+
- offer the manual-mode commands as next steps
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### D) Plugin packaging milestone (Phase 2 / Team-ready)
|
|
158
|
+
**Goal:** Make ClaudeMemory easy to distribute and enable across many repos.
|
|
159
|
+
|
|
160
|
+
**What the plugin adds**
|
|
161
|
+
- Slash commands:
|
|
162
|
+
- `/claude-memory:recall`
|
|
163
|
+
- `/claude-memory:publish`
|
|
164
|
+
- `/claude-memory:sweep`
|
|
165
|
+
- `/claude-memory:status`
|
|
166
|
+
- Optional: plugin-shipped MCP server config and “Memory Steward” agent/skill bundle
|
|
167
|
+
|
|
168
|
+
**Why this matters**
|
|
169
|
+
- Versioned distribution
|
|
170
|
+
- One “enable” switch in settings
|
|
171
|
+
- Fewer manual config steps for teams
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
### E) Expanded publishing strategies for Claude Code memory
|
|
176
|
+
**Goal:** Use Claude’s built-in memory system as the “thin, always-on RAM” layer.
|
|
177
|
+
|
|
178
|
+
**Publish modes**
|
|
179
|
+
1) `--mode shared` (repo)
|
|
180
|
+
- writes `.claude/rules/claude_memory.generated.md`
|
|
181
|
+
- ensures `.claude/CLAUDE.md` imports it
|
|
182
|
+
|
|
183
|
+
2) `--mode local` (repo private)
|
|
184
|
+
- writes `CLAUDE.local.md` or a local-only generated file
|
|
185
|
+
- safe for secrets/personal prefs
|
|
186
|
+
|
|
187
|
+
3) `--mode home` (user home)
|
|
188
|
+
- writes `~/.claude/claude_memory/<project>.md`
|
|
189
|
+
- project imports the home file via `@~/...` import (where appropriate)
|
|
190
|
+
|
|
191
|
+
**Granularity**
|
|
192
|
+
- `--granularity repo` (single snapshot)
|
|
193
|
+
- `--granularity paths` (optional path-scoped rules)
|
|
194
|
+
- `--granularity nested` (optional subtree `CLAUDE.md` snapshots for monorepos)
|
|
195
|
+
|
|
196
|
+
**No-churn**
|
|
197
|
+
- Publish only rewrites generated files if content changed (hash compare).
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Full updated end-to-end plan
|
|
202
|
+
This is the consolidated plan that Claude Code should execute.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## North Star
|
|
207
|
+
**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:
|
|
208
|
+
- **Automated ingestion + sweep** using Claude Code hooks (installed via settings)
|
|
209
|
+
- **On-demand recall/explain** via an **MCP server**
|
|
210
|
+
- **Published concise snapshots** into Claude Code’s memory files (`CLAUDE.md` / `.claude/rules/`)
|
|
211
|
+
- A **project Output Style** that encourages memory-aware behavior and consistent formatting
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Success criteria (MVP)
|
|
216
|
+
1) `claude-memory init` creates a working setup in a repo:
|
|
217
|
+
- **Dual databases**: global (`~/.claude/memory.sqlite3`) + project (`.claude/memory.sqlite3`)
|
|
218
|
+
- **merges hook config into `.claude/settings.json`** (and optionally `.claude/settings.local.json`)
|
|
219
|
+
- Output Style file template
|
|
220
|
+
- MCP server config in `.mcp.json`
|
|
221
|
+
2) When Claude Code runs in the repo, hooks trigger via the hook entrypoints:
|
|
222
|
+
- **ingest** on Stop + safety events
|
|
223
|
+
- **sweep** on idle_prompt + safety events
|
|
224
|
+
- optional publish on SessionEnd/PreCompact
|
|
225
|
+
3) ClaudeMemory can **publish a thin “Current Truth Snapshot”** into Claude Code memory files:
|
|
226
|
+
- generates `.claude/rules/claude_memory.generated.md` (and optional path-scoped or nested subtree snapshots)
|
|
227
|
+
- `.claude/CLAUDE.md` imports the generated snapshot
|
|
228
|
+
4) `claude-memory recall "..."` returns relevant **canonical facts** plus at least one **receipt** per fact after a few Claude turns.
|
|
229
|
+
5) Contradictory beliefs do **not** overwrite silently:
|
|
230
|
+
- if explicit replacement or strong provenance: create **supersedes** link and close old validity window
|
|
231
|
+
- otherwise: create **conflict** record
|
|
232
|
+
6) Everything runs **locally by default** with minimal dependencies:
|
|
233
|
+
- SQLite file DB (required)
|
|
234
|
+
- No embeddings required for MVP
|
|
235
|
+
- LLM distillation is pluggable (MVP can ship with a stub distiller)
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Non-goals (MVP)
|
|
240
|
+
- No full RDF/SPARQL store
|
|
241
|
+
- No multi-source ingestion (Slack/GitHub/etc.) beyond transcript ingestion
|
|
242
|
+
- No complex UI (CLI + MCP is enough)
|
|
243
|
+
- No mandatory background daemon (hooks drive automation)
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Milestones and tasks
|
|
248
|
+
|
|
249
|
+
### Milestone 0: Bootstrap the gem skeleton (1–2 commits)
|
|
250
|
+
Goal: runnable gem + CLI + tests.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### Milestone 1: SQLite Store + schema (2–4 commits)
|
|
255
|
+
Goal: persist content, cursors, entities, facts, provenance, conflicts.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### Milestone 2: Transcript delta ingestion (2–4 commits)
|
|
260
|
+
Goal: ingest transcript deltas using transcript_path + session_id.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### Milestone 3: Lexical index for recall (MVP) (2–5 commits)
|
|
265
|
+
Goal: fast search without embeddings (SQLite FTS preferred).
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### Milestone 4: Distiller interface + NullDistiller (2–4 commits)
|
|
270
|
+
Goal: define extraction contract; ship with stub distiller.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
### Milestone 5: Resolver (truth maintenance) (3–6 commits)
|
|
275
|
+
Goal: deterministic equivalent/additive/supersession/conflict.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### Milestone 6: Recall + Explain (CLI) (2–4 commits)
|
|
280
|
+
Goal: human-usable recall and receipts.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Milestone 7: Sweep mechanics (2–5 commits)
|
|
285
|
+
Goal: time-bounded maintenance via `claude-memory sweep`.
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
### Milestone 8: MCP server (3–6 commits)
|
|
290
|
+
Goal: provide memory tools to Claude Code.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### Milestone 9 (UPDATED): Settings-driven hook installation + hook entrypoints (3–6 commits)
|
|
295
|
+
**Goal:** Make automation turnkey and robust.
|
|
296
|
+
|
|
297
|
+
Tasks
|
|
298
|
+
- Add CLI subcommands:
|
|
299
|
+
- `claude-memory hook ingest`
|
|
300
|
+
- `claude-memory hook sweep`
|
|
301
|
+
- `claude-memory hook publish`
|
|
302
|
+
- Implement stdin JSON parsing for hook payloads
|
|
303
|
+
- Update `claude-memory init` to:
|
|
304
|
+
- create/merge `.claude/settings.json` with hook definitions
|
|
305
|
+
- optionally create/merge `.claude/settings.local.json`
|
|
306
|
+
- install safe per-hook `timeout` values
|
|
307
|
+
- Ensure hook commands use project-relative paths and `$CLAUDE_PROJECT_DIR` where useful
|
|
308
|
+
- Extend `doctor` to validate:
|
|
309
|
+
- hooks present and syntactically correct in settings
|
|
310
|
+
- print manual fallback steps for managed environments
|
|
311
|
+
|
|
312
|
+
Acceptance checks
|
|
313
|
+
- Running `init` results in settings files Claude Code uses
|
|
314
|
+
- Hook entrypoints can be tested by piping in fixture JSON
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
### Milestone 10: Output Style template (1–2 commits)
|
|
319
|
+
Goal: encourage memory-aware behavior without breaking coding guidance.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
### Milestone 10.5 (UPDATED): Publish snapshot to Claude Code memory (2–5 commits)
|
|
324
|
+
**Goal:** Treat Claude Code memory files as a curated publishing layer.
|
|
325
|
+
|
|
326
|
+
Tasks
|
|
327
|
+
- Add CLI: `claude-memory publish`
|
|
328
|
+
- `--mode shared|local|home`
|
|
329
|
+
- `--granularity repo|paths|nested`
|
|
330
|
+
- optional `--since <iso>`
|
|
331
|
+
- Implement no-churn rewriting via hash comparison
|
|
332
|
+
- Ensure `.claude/CLAUDE.md` imports the generated snapshot
|
|
333
|
+
- Optional: path-scoped `.claude/rules/*.md` via YAML frontmatter
|
|
334
|
+
- Optional: nested subtree snapshot strategy for monorepos
|
|
335
|
+
|
|
336
|
+
Acceptance checks
|
|
337
|
+
- Claude Code automatically loads published snapshot content
|
|
338
|
+
- Publish does not rewrite files when unchanged
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
### Milestone 11: Dual-database architecture ✅ COMPLETE
|
|
343
|
+
**Goal:** Separate global and project memory into distinct databases.
|
|
344
|
+
|
|
345
|
+
Tasks ✅
|
|
346
|
+
- Created `Store::StoreManager` class to manage both databases
|
|
347
|
+
- Global DB at `~/.claude/memory.sqlite3`
|
|
348
|
+
- Project DB at `.claude/memory.sqlite3`
|
|
349
|
+
- Updated `Recall` to query both databases and merge results
|
|
350
|
+
- Added `promote` command and MCP tool to graduate facts to global
|
|
351
|
+
- Updated all CLI commands to use `StoreManager`
|
|
352
|
+
- Removed `--db` option from most commands (paths derived automatically)
|
|
353
|
+
- Added `--scope` flag to `recall`, `conflicts`, `changes`, `sweep`, `publish`
|
|
354
|
+
|
|
355
|
+
Acceptance checks ✅
|
|
356
|
+
- `claude-memory init` creates both databases
|
|
357
|
+
- `claude-memory recall` queries both, project facts prioritized
|
|
358
|
+
- `claude-memory promote <id>` copies fact to global DB
|
|
359
|
+
- `claude-memory doctor` reports status of both databases
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
### Milestone 12: End-to-end demo + doctor (1–2 commits)
|
|
364
|
+
Goal: verify full loop; doctor detects managed-hook limitations.
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
### Milestone 13: Packaging + Release hygiene (2–4 commits)
|
|
369
|
+
Goal: make it usable by others.
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
### Milestone 14 (Phase 2): Plugin packaging (optional but recommended for teams) (4–10 commits)
|
|
374
|
+
**Goal:** Distribute ClaudeMemory via a Claude plugin.
|
|
375
|
+
|
|
376
|
+
Tasks
|
|
377
|
+
- Create plugin wrapper with:
|
|
378
|
+
- slash commands (`/claude-memory:*`)
|
|
379
|
+
- optional bundled MCP config and agent/skill (later)
|
|
380
|
+
- Document enabling the plugin in settings
|
|
381
|
+
- Provide private marketplace instructions if needed
|
|
382
|
+
|
|
383
|
+
Acceptance checks
|
|
384
|
+
- Enabling plugin exposes slash commands that call your gem
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## Command surface (updated)
|
|
389
|
+
|
|
390
|
+
### Database management
|
|
391
|
+
- `claude-memory db:init [--global] [--project]` — initialize databases
|
|
392
|
+
- `claude-memory init [--global]` — full project setup (creates both DBs, hooks, MCP config)
|
|
393
|
+
|
|
394
|
+
### Ingestion
|
|
395
|
+
- `claude-memory ingest --session-id ... --transcript-path ... [--db PATH]`
|
|
396
|
+
- `claude-memory hook ingest|sweep|publish [--db PATH]` — reads stdin JSON
|
|
397
|
+
|
|
398
|
+
### Recall & query
|
|
399
|
+
- `claude-memory recall "..." [--limit N] [--scope project|global|all]`
|
|
400
|
+
- `claude-memory search "..." [--limit N] [--scope project|global]`
|
|
401
|
+
- `claude-memory explain <fact_id> [--scope project|global]`
|
|
402
|
+
- `claude-memory conflicts [--scope project|global|all]`
|
|
403
|
+
- `claude-memory changes [--since ISO] [--limit N] [--scope project|global|all]`
|
|
404
|
+
|
|
405
|
+
### Maintenance
|
|
406
|
+
- `claude-memory sweep [--budget N] [--scope project|global]`
|
|
407
|
+
- `claude-memory publish [--mode shared|local|home] [--granularity repo|paths|nested] [--scope project|global]`
|
|
408
|
+
- `claude-memory promote <fact_id>` — copy project fact to global DB
|
|
409
|
+
|
|
410
|
+
### Services
|
|
411
|
+
- `claude-memory serve-mcp` — start MCP server (queries both DBs)
|
|
412
|
+
- `claude-memory doctor` — health check for both databases
|
|
413
|
+
|
|
414
|
+
**Database locations:**
|
|
415
|
+
- Global: `~/.claude/memory.sqlite3`
|
|
416
|
+
- Project: `.claude/memory.sqlite3`
|
|
417
|
+
|
|
418
|
+
**Scope options:**
|
|
419
|
+
- `project`: current project's database only
|
|
420
|
+
- `global`: global database only
|
|
421
|
+
- `all` (default for recall): both databases, project facts take precedence
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## MCP Tools (updated)
|
|
426
|
+
|
|
427
|
+
The MCP server exposes these tools to Claude Code:
|
|
428
|
+
|
|
429
|
+
| Tool | Description |
|
|
430
|
+
|------|-------------|
|
|
431
|
+
| `memory.recall` | Search both databases for matching facts |
|
|
432
|
+
| `memory.explain` | Get detailed fact with provenance (requires `scope` param) |
|
|
433
|
+
| `memory.changes` | List recent fact changes from both databases |
|
|
434
|
+
| `memory.conflicts` | List open conflicts from both databases |
|
|
435
|
+
| `memory.sweep_now` | Run maintenance sweep on specified database |
|
|
436
|
+
| `memory.status` | Get stats for both global and project databases |
|
|
437
|
+
| `memory.promote` | Promote a project fact to global memory |
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Hook wiring (updated target behavior)
|
|
442
|
+
- Ingest backbone: Stop (plus SessionStart/PreCompact/SessionEnd safety)
|
|
443
|
+
- Sweep backbone: Notification idle_prompt (plus PreCompact/SessionEnd hygiene)
|
|
444
|
+
- Publish: optional on SessionEnd and/or PreCompact (budgeted; avoid churn)
|
|
445
|
+
- Hooks should call the **hook entrypoint subcommands** (stdin JSON).
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## Appendix: Managed environment fallback
|
|
450
|
+
If hooks are blocked by policy:
|
|
451
|
+
- Run `claude-memory ingest` manually at key points
|
|
452
|
+
- Run `claude-memory sweep` and `claude-memory publish` on demand
|
|
453
|
+
- Use MCP tools for recall/explain regardless
|
data/exe/claude-memory
ADDED
data/hooks/hooks.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"Stop": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "claude-memory hook ingest"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"SessionStart": [
|
|
14
|
+
{
|
|
15
|
+
"hooks": [
|
|
16
|
+
{
|
|
17
|
+
"type": "command",
|
|
18
|
+
"command": "claude-memory hook ingest"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"PreCompact": [
|
|
24
|
+
{
|
|
25
|
+
"hooks": [
|
|
26
|
+
{
|
|
27
|
+
"type": "command",
|
|
28
|
+
"command": "claude-memory hook ingest"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "command",
|
|
32
|
+
"command": "claude-memory hook publish"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"Notification": [
|
|
38
|
+
{
|
|
39
|
+
"matcher": "idle_prompt",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "claude-memory hook sweep"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"SessionEnd": [
|
|
49
|
+
{
|
|
50
|
+
"hooks": [
|
|
51
|
+
{
|
|
52
|
+
"type": "command",
|
|
53
|
+
"command": "claude-memory hook publish"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|