claude_memory 0.9.1 → 0.11.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/memory.sqlite3 +0 -0
  3. data/.claude/skills/dashboard/SKILL.md +42 -0
  4. data/.claude-plugin/marketplace.json +1 -1
  5. data/.claude-plugin/plugin.json +1 -1
  6. data/CHANGELOG.md +130 -0
  7. data/CLAUDE.md +30 -6
  8. data/README.md +66 -2
  9. data/db/migrations/015_add_activity_events.rb +26 -0
  10. data/db/migrations/016_add_moment_feedback.rb +22 -0
  11. data/db/migrations/017_add_last_recalled_at.rb +15 -0
  12. data/docs/1_0_punchlist.md +371 -0
  13. data/docs/EXAMPLES.md +41 -2
  14. data/docs/GETTING_STARTED.md +33 -4
  15. data/docs/architecture.md +22 -7
  16. data/docs/audit-queries.md +131 -0
  17. data/docs/dashboard.md +192 -0
  18. data/docs/improvements.md +650 -9
  19. data/docs/influence/cq.md +187 -0
  20. data/docs/plugin.md +13 -6
  21. data/docs/quality_review.md +524 -172
  22. data/docs/reflection_memory_as_accumulating_judgment.md +67 -0
  23. data/lib/claude_memory/activity_log.rb +86 -0
  24. data/lib/claude_memory/commands/census_command.rb +210 -0
  25. data/lib/claude_memory/commands/completion_command.rb +3 -0
  26. data/lib/claude_memory/commands/dashboard_command.rb +54 -0
  27. data/lib/claude_memory/commands/dedupe_conflicts_command.rb +55 -0
  28. data/lib/claude_memory/commands/digest_command.rb +273 -0
  29. data/lib/claude_memory/commands/hook_command.rb +61 -2
  30. data/lib/claude_memory/commands/initializers/hooks_configurator.rb +7 -4
  31. data/lib/claude_memory/commands/reclassify_references_command.rb +56 -0
  32. data/lib/claude_memory/commands/registry.rb +7 -1
  33. data/lib/claude_memory/commands/show_command.rb +90 -0
  34. data/lib/claude_memory/commands/skills/distill-transcripts.md +13 -1
  35. data/lib/claude_memory/commands/stats_command.rb +131 -2
  36. data/lib/claude_memory/commands/sweep_command.rb +2 -0
  37. data/lib/claude_memory/configuration.rb +16 -0
  38. data/lib/claude_memory/core/relative_time.rb +9 -0
  39. data/lib/claude_memory/dashboard/api.rb +610 -0
  40. data/lib/claude_memory/dashboard/conflicts.rb +279 -0
  41. data/lib/claude_memory/dashboard/efficacy.rb +127 -0
  42. data/lib/claude_memory/dashboard/fact_presenter.rb +109 -0
  43. data/lib/claude_memory/dashboard/health.rb +175 -0
  44. data/lib/claude_memory/dashboard/index.html +2707 -0
  45. data/lib/claude_memory/dashboard/knowledge.rb +136 -0
  46. data/lib/claude_memory/dashboard/moments.rb +244 -0
  47. data/lib/claude_memory/dashboard/reuse.rb +97 -0
  48. data/lib/claude_memory/dashboard/scoped_fact_resolver.rb +95 -0
  49. data/lib/claude_memory/dashboard/server.rb +211 -0
  50. data/lib/claude_memory/dashboard/timeline.rb +68 -0
  51. data/lib/claude_memory/dashboard/trust.rb +454 -0
  52. data/lib/claude_memory/distill/bare_conclusion_detector.rb +71 -0
  53. data/lib/claude_memory/distill/reference_material_detector.rb +78 -0
  54. data/lib/claude_memory/hook/auto_memory_mirror.rb +112 -0
  55. data/lib/claude_memory/hook/context_injector.rb +97 -3
  56. data/lib/claude_memory/hook/handler.rb +191 -3
  57. data/lib/claude_memory/mcp/handlers/management_handlers.rb +8 -0
  58. data/lib/claude_memory/mcp/query_guide.rb +11 -0
  59. data/lib/claude_memory/mcp/text_summary.rb +29 -0
  60. data/lib/claude_memory/mcp/tool_definitions.rb +13 -0
  61. data/lib/claude_memory/mcp/tools.rb +148 -0
  62. data/lib/claude_memory/publish.rb +13 -21
  63. data/lib/claude_memory/recall/stale_detector.rb +67 -0
  64. data/lib/claude_memory/resolve/predicate_policy.rb +2 -0
  65. data/lib/claude_memory/resolve/resolver.rb +41 -11
  66. data/lib/claude_memory/store/llm_cache.rb +68 -0
  67. data/lib/claude_memory/store/metrics_aggregator.rb +96 -0
  68. data/lib/claude_memory/store/schema_manager.rb +1 -1
  69. data/lib/claude_memory/store/sqlite_store.rb +47 -143
  70. data/lib/claude_memory/store/store_manager.rb +29 -0
  71. data/lib/claude_memory/sweep/maintenance.rb +216 -0
  72. data/lib/claude_memory/sweep/recall_timestamp_refresher.rb +83 -0
  73. data/lib/claude_memory/sweep/sweeper.rb +2 -0
  74. data/lib/claude_memory/templates/hooks.example.json +5 -0
  75. data/lib/claude_memory/version.rb +1 -1
  76. data/lib/claude_memory.rb +24 -0
  77. metadata +51 -1
@@ -0,0 +1,187 @@
1
+ # cq Analysis
2
+
3
+ *Analysis Date: 2026-04-28*
4
+ *Repository: https://github.com/technicalpickles/cq*
5
+ *Focus: Tool usefulness (not internals)*
6
+
7
+ ---
8
+
9
+ ## Executive Summary
10
+
11
+ **cq** is a Rust CLI that indexes Claude Code's JSONL session transcripts into a local DuckDB cache (`~/.cache/cq/index.duckdb`) and exposes four SQL views (`sessions`, `messages`, `tool_calls`, `tool_results`) for querying with raw SQL or canned subcommands.
12
+
13
+ It is positioned squarely as **observability for your own Claude Code usage** — not a memory system, not a curation tool, not an in-session helper. You run it from a separate terminal to ask meta-questions like "which skills are firing?" or "where did context go in that bad session?"
14
+
15
+ **Verdict for ClaudeMemory**: complementary, not competing. cq is a *read* tool over raw transcripts; ClaudeMemory is a *write/curate* tool that distills transcripts into facts. Same data source, different jobs. **Recommendation: install cq as a developer-side audit tool**, especially for validating that the ClaudeMemory plugin itself is being used correctly. Do not adopt internals — the architectures don't overlap meaningfully.
16
+
17
+ **Tech stack**: Rust, DuckDB (with JSON extension), clap, comfy-table, fs2 file locking. ~14 source modules, MIT licensed.
18
+
19
+ ## What cq Actually Gives You
20
+
21
+ The four views are the product. Everything else (subcommands, `--grep`, `-A/-B/-C` context flags, `--since 7d`) is convenience over those views.
22
+
23
+ | View | What it is | Why it matters |
24
+ |------|------------|----------------|
25
+ | `sessions` | One row per session, with timestamps, message counts, tool counts | Fastest way to find "the session where X happened" |
26
+ | `messages` | One row per user/assistant turn | Full-text grep across your entire history |
27
+ | `tool_calls` | One row per tool_use block with input as queryable JSON | The killer view — `json_extract_string(input, '$.command')` etc. |
28
+ | `tool_results` | One row per tool_result with `is_error` flag | Pairs with `tool_calls` to find silent failures |
29
+
30
+ The `tool_calls` view is where the value is. SQL + JSON path extraction over every Bash command, every Read path, every Skill invocation, every MCP tool call, across all your sessions, scoped automatically to the current project.
31
+
32
+ ## Concrete Use Cases (lifted from their docs/use-cases.md)
33
+
34
+ These three patterns are the strongest argument for installing cq today:
35
+
36
+ ### 1. Skill activation gaps
37
+
38
+ > *"Out of 166 sessions that ran `git commit` in a 7-day window, only 16 activated any commit skill. The rest went straight through Bash."*
39
+
40
+ A self-join on `tool_calls` between `Bash WHERE command LIKE '%git commit%'` and `Skill WHERE skill LIKE '%commit%'`, grouped by session_id, tells you which sessions ran `git commit` *without* invoking a commit skill. This is the cleanest "is my skill triggering?" signal that exists.
41
+
42
+ **Direct relevance to you**: ClaudeMemory ships several skills (`/distill-transcripts`, `/release`, `/review-for-quality`, `/review-commit`, etc.) and an MCP plugin. You currently have no way to answer "is the memory plugin actually firing on questions where it should?" Same query shape works:
43
+
44
+ ```sql
45
+ -- Sessions that asked architecture/convention questions but never called memory.*
46
+ WITH memory_sessions AS (
47
+ SELECT DISTINCT session_id FROM tool_calls
48
+ WHERE name LIKE 'mcp__memory__%'
49
+ )
50
+ SELECT m.session_id, m.text
51
+ FROM messages m
52
+ LEFT JOIN memory_sessions ms ON m.session_id = ms.session_id
53
+ WHERE m.type = 'user'
54
+ AND (m.text ILIKE '%convention%' OR m.text ILIKE '%architecture%' OR m.text ILIKE '%why did we%')
55
+ AND ms.session_id IS NULL
56
+ ```
57
+
58
+ ### 2. Silent failures (the wrong-path pattern)
59
+
60
+ > *"The skill instructions referenced the wrong path... Claude recovered every time by Glob-searching for the file, so from the outside everything looked fine. Across 23 sessions over 30 days, the same silent failure repeated."*
61
+
62
+ Detects the `Read fails → Glob → Read succeeds at different path` sequence. For ClaudeMemory's skills (which reference dozens of file paths in `.claude/skills/`), this is a maintenance multiplier — broken paths self-heal at the cost of a few wasted tool calls per invocation, and you'd never notice without this query.
63
+
64
+ ### 3. Context-budget forensics
65
+
66
+ > *"Three calls ate the context budget. Thirty more burned it retrying queries that would never work."*
67
+
68
+ `SELECT name, length(content) AS result_chars FROM tool_calls JOIN tool_results ... ORDER BY result_chars DESC` for a single session. Surfaces the few large tool results that dominate context. Useful when a session "felt slow" but no individual step looked wrong.
69
+
70
+ ## How cq Compares to ClaudeMemory's Existing Data
71
+
72
+ ClaudeMemory already captures some of this in its own SQLite databases:
73
+
74
+ | Capability | ClaudeMemory | cq |
75
+ |------------|--------------|-----|
76
+ | Per-project tool calls | ✅ `tool_calls` table (v3, content_item_id-scoped) | ✅ `tool_calls` view |
77
+ | Cross-project SQL | ❌ Project DB is project-scoped by design | ✅ Default cross-project, opt out with `--project` |
78
+ | MCP tool telemetry | ✅ `mcp_tool_calls` table (v13) | ❌ Doesn't see MCP tools as a distinct category |
79
+ | Tool inputs as queryable JSON | ⚠️ Stored as `tool_input` text, not indexed for JSON path | ✅ DuckDB `json_extract_string` over JSON |
80
+ | Tool results with `is_error` | ✅ `is_error` column | ✅ `is_error` column |
81
+ | Raw SQL access for ad-hoc analysis | ⚠️ `sqlite3 .claude/memory.sqlite3` works but no view layer | ✅ `cq sql "..."` first-class |
82
+ | Session-level rollups | Partial | ✅ `sessions` view |
83
+ | Distills facts, resolves conflicts | ✅ Core purpose | ❌ Not a goal |
84
+ | Cross-session message grep | ❌ FTS5 is fact-scoped | ✅ `cq messages --grep` |
85
+
86
+ **Conclusion**: ClaudeMemory has the *write* path (ingest → distill → resolve → publish). cq has the *read* path (incremental sync → views → SQL). They share input data (Claude Code JSONLs) and stop there.
87
+
88
+ ## Adoption Opportunities
89
+
90
+ ### High Priority ⭐
91
+
92
+ #### 1. Install cq as a developer audit tool for the ClaudeMemory project itself
93
+
94
+ - **Value**: Answer two questions you currently can't answer cheaply:
95
+ 1. "Is the memory plugin being invoked when it should?" (skill activation)
96
+ 2. "Are there silent failures in `mcp__memory__*` calls?" (error rate, retry loops)
97
+ - **Evidence**: cq's three documented use cases (use-cases.md:1–200) translate directly to ClaudeMemory's situation; you ship a plugin with similar trigger ambiguity
98
+ - **Implementation**: `cargo install --git https://github.com/technicalpickles/cq` — no integration needed, runs out-of-band
99
+ - **Effort**: 5 minutes
100
+ - **Trade-off**: Adds a Rust toolchain dependency on the dev machine; DuckDB cache grows over time (rebuild via `--reindex`)
101
+ - **Recommendation**: **ADOPT** as a personal tool, not a project dependency
102
+
103
+ #### 2. Borrow cq's three reference queries for a `docs/audit-queries.md`
104
+
105
+ - **Value**: Pre-written SQL the user (or a future maintainer) can run against ClaudeMemory's own databases or via cq to validate the plugin is doing its job. Useful for releases ("did v0.10 actually move the memory.recall hit rate?") and for reproducing skill-activation regressions.
106
+ - **Evidence**: use-cases.md provides exact query templates; only the predicate names change
107
+ - **Implementation**: New doc file, three queries, ~30 minutes
108
+ - **Effort**: Low
109
+ - **Trade-off**: Maintenance — queries rot when schemas change. Mitigate by pinning to ClaudeMemory's own `tool_calls` schema where possible (stable since v3) rather than cq's view schema (younger).
110
+ - **Recommendation**: **CONSIDER** — only worth it if you're going to actually run the audits
111
+
112
+ ### Medium Priority
113
+
114
+ #### 3. Expose ClaudeMemory's `tool_calls` data via a similar SQL view layer
115
+
116
+ - **Value**: ClaudeMemory's `tool_calls` table already has the data, but `sqlite3 .claude/memory.sqlite3 "SELECT ..."` requires knowing column names. A `claude-memory sql` subcommand mirroring `cq sql` would lower the barrier.
117
+ - **Evidence**: cq's `sql.rs` (intentionally unparameterized passthrough) shows the minimal viable shape
118
+ - **Implementation**: New `SqlCommand` in `lib/claude_memory/commands/`, ~50 lines using existing Sequel connection
119
+ - **Effort**: Half a day including tests
120
+ - **Trade-off**: Power-user feature. Risks footgun (drop tables) — would need read-only enforcement. Adds surface area to maintain.
121
+ - **Recommendation**: **DEFER** — only if users start asking. Right now `memory.recall_semantic` and the shortcut tools cover the curated path, and `sqlite3` covers the power-user path. The middle ground is thinly populated.
122
+
123
+ ### Low Priority
124
+
125
+ #### 4. Adopt cq's `--since 7d` duration parser pattern
126
+
127
+ - **Value**: Unified relative-time parsing across `claude-memory` subcommands; ClaudeMemory has `Core::RelativeTime` for *output*, less consistency on *input*
128
+ - **Evidence**: cq's `scope.rs` parses `7d|24h|30m` uniformly across all commands
129
+ - **Implementation**: A `Core::DurationParser` value object
130
+ - **Effort**: A couple hours
131
+ - **Trade-off**: Real but minor UX win
132
+ - **Recommendation**: **DEFER** — pick up if/when adding more time-filtered commands
133
+
134
+ ### Features to Avoid
135
+
136
+ - **DuckDB as a primary store**. ClaudeMemory's SQLite + extralite + Sequel choice is right for the curation/write workload (FTS5, vec0, transactional resolve). DuckDB is right for cq's analytical scan-everything workload. Don't conflate them.
137
+ - **Cross-project default scoping**. cq defaults to "all projects" with auto-narrowing to current project. ClaudeMemory's project/global split is a feature for memory recall (you don't want one project's conventions leaking into another). Keep what you have.
138
+ - **Re-indexing transcripts on every command**. cq's incremental sync exists because it has no other ingest path. ClaudeMemory's hook-driven ingest is already incremental in a different way and shouldn't be replaced.
139
+
140
+ ## Trade-offs of Using cq Long-Term
141
+
142
+ - **Cache freshness**: cq syncs on every run via mtime/size fast-path. Cost: a few hundred ms on a large transcript history.
143
+ - **Lock contention**: `fs2` file lock means concurrent runs may show stale data (the design choice is "stale-but-available beats error" — fine for a query tool).
144
+ - **No curation**: cq surfaces patterns; you still have to interpret them. The "152 sessions skipped the skill" finding only matters if you act on it.
145
+ - **Schema is Claude Code's JSONL format**: if Anthropic changes the transcript shape, cq breaks until updated. Same risk ClaudeMemory has, just exposed differently.
146
+
147
+ ## Implementation Recommendations
148
+
149
+ **Phase 1 — Just install it (today, 5 minutes)**:
150
+ - `cargo install --git https://github.com/technicalpickles/cq`
151
+ - Run `cq tools` and `cq sessions` to see your own usage
152
+ - Run the skill-activation query against your `mcp__memory__*` tool calls
153
+
154
+ **Phase 2 — If Phase 1 surfaces something useful (~half-day)**:
155
+ - Five concrete queries already pre-written in `docs/audit-queries.md` (activation rate, missed-memory-shaped prompts, tool ranking, error rate, result-size distribution)
156
+ - Decide if any belong as a recurring `/schedule` agent ("audit memory plugin activation weekly")
157
+
158
+ **Phase 3 — Speculative (defer indefinitely)**:
159
+ - A `claude-memory sql` subcommand if users ask for one
160
+ - A `Core::DurationParser` value object if you add another time-filtered command
161
+
162
+ ## Architecture Decisions
163
+
164
+ **Preserve**:
165
+ - ClaudeMemory's two-DB scope split (project vs global)
166
+ - SQLite + extralite + Sequel as the storage stack
167
+ - Hook-driven ingest, not on-demand re-parse
168
+ - Distill → Resolve → Publish curation pipeline
169
+
170
+ **Adopt** (out-of-band, not into the codebase):
171
+ - cq itself, as a developer-side audit tool
172
+
173
+ **Reject**:
174
+ - DuckDB / cross-project default / replacing curation with raw SQL views
175
+
176
+ ## Key Takeaways
177
+
178
+ 1. **cq solves a different problem than ClaudeMemory**: observability vs curation. The right answer is "use both," not "absorb one into the other."
179
+ 2. **The most valuable thing in the cq repo is `docs/use-cases.md`**, not the code. The three query patterns (skill activation, silent failures, context budget) are immediately runnable against your own usage.
180
+ 3. **ClaudeMemory has data parity for the per-project case** (the `tool_calls` table covers the same ground), but lacks cq's cross-project SQL ergonomics. That gap is small — a `sqlite3` shell closes it for power users.
181
+ 4. **Highest-leverage next step**: install cq, run the skill-activation query against `mcp__memory__*`, see whether the memory plugin is firing as expected. That's a 10-minute experiment with a real chance of surfacing a fixable issue.
182
+
183
+ ## Next Steps
184
+
185
+ - [ ] Install cq locally
186
+ - [ ] Run `cq sql` audit on `mcp__memory__*` activation rate over the last 30d
187
+ - [ ] If the audit surfaces a real gap, file it and decide whether the fix lives in skill descriptions, MCP server instructions, or elsewhere
data/docs/plugin.md CHANGED
@@ -133,18 +133,25 @@ Unlike traditional approaches that require a separate API key, ClaudeMemory uses
133
133
 
134
134
  ### MCP Server
135
135
 
136
- The plugin exposes these tools to Claude:
136
+ The plugin exposes 25 tools to Claude. Highlights:
137
137
 
138
138
  | Tool | Description |
139
139
  |------|-------------|
140
- | `memory.recall` | Search facts by query |
140
+ | `memory.recall` | Search facts by query (lexical + semantic + hybrid) |
141
+ | `memory.recall_semantic` | Vector-search facts with optional `explain:` score traces |
142
+ | `memory.search_concepts` | Multi-concept intersection search |
143
+ | `memory.decisions` / `memory.conventions` / `memory.architecture` | Predicate-shortcut readers |
141
144
  | `memory.explain` | Get fact details with provenance |
142
- | `memory.store_extraction` | Store extracted facts |
143
- | `memory.promote` | Promote project fact to global |
144
- | `memory.status` | Check database health |
145
- | `memory.changes` | Recent fact updates |
145
+ | `memory.fact_graph` | Walk supersession + conflict edges around a fact |
146
+ | `memory.store_extraction` | Store extracted facts (used by /distill-transcripts) |
147
+ | `memory.undistilled` / `memory.mark_distilled` | Distillation pipeline tracking |
148
+ | `memory.promote` / `memory.reject_fact` | Manage fact lifecycle |
149
+ | `memory.status` / `memory.stats` / `memory.activity` / `memory.changes` | Observability surfaces |
146
150
  | `memory.conflicts` | Open contradictions |
147
151
  | `memory.sweep_now` | Run maintenance |
152
+ | `memory.check_setup` / `memory.list_projects` | Discovery |
153
+
154
+ See `lib/claude_memory/mcp/tool_definitions.rb` for the full schema of every tool, including arguments, return shapes, and tool annotations (`readOnlyHint`, `idempotentHint`, `destructiveHint`).
148
155
 
149
156
  ### Hooks
150
157