claude_memory 0.4.0 → 0.5.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 +4 -4
- data/.claude/CLAUDE.md +1 -1
- data/.claude/rules/claude_memory.generated.md +14 -1
- data/.claude/skills/check-memory/SKILL.md +10 -0
- data/.claude/skills/improve/SKILL.md +12 -1
- data/.claude-plugin/plugin.json +1 -1
- data/CHANGELOG.md +70 -0
- data/db/migrations/008_add_provenance_line_range.rb +21 -0
- data/db/migrations/009_add_docid.rb +39 -0
- data/db/migrations/010_add_llm_cache.rb +30 -0
- data/docs/improvements.md +72 -1084
- data/docs/influence/claude-supermemory.md +498 -0
- data/docs/influence/qmd.md +424 -2022
- data/docs/quality_review.md +64 -705
- data/lib/claude_memory/commands/doctor_command.rb +45 -4
- data/lib/claude_memory/commands/explain_command.rb +11 -6
- data/lib/claude_memory/commands/stats_command.rb +1 -1
- data/lib/claude_memory/core/fact_graph.rb +122 -0
- data/lib/claude_memory/core/fact_query_builder.rb +34 -14
- data/lib/claude_memory/core/fact_ranker.rb +3 -20
- data/lib/claude_memory/core/relative_time.rb +45 -0
- data/lib/claude_memory/core/result_sorter.rb +2 -2
- data/lib/claude_memory/core/rr_fusion.rb +57 -0
- data/lib/claude_memory/core/snippet_extractor.rb +97 -0
- data/lib/claude_memory/domain/fact.rb +3 -1
- data/lib/claude_memory/index/index_query.rb +2 -0
- data/lib/claude_memory/index/lexical_fts.rb +18 -0
- data/lib/claude_memory/infrastructure/operation_tracker.rb +7 -21
- data/lib/claude_memory/infrastructure/schema_validator.rb +30 -25
- data/lib/claude_memory/ingest/content_sanitizer.rb +8 -1
- data/lib/claude_memory/ingest/ingester.rb +67 -56
- data/lib/claude_memory/ingest/tool_extractor.rb +1 -1
- data/lib/claude_memory/ingest/tool_filter.rb +55 -0
- data/lib/claude_memory/logging/logger.rb +112 -0
- data/lib/claude_memory/mcp/query_guide.rb +96 -0
- data/lib/claude_memory/mcp/response_formatter.rb +86 -23
- data/lib/claude_memory/mcp/server.rb +34 -4
- data/lib/claude_memory/mcp/text_summary.rb +257 -0
- data/lib/claude_memory/mcp/tool_definitions.rb +20 -4
- data/lib/claude_memory/mcp/tools.rb +133 -120
- data/lib/claude_memory/publish.rb +12 -2
- data/lib/claude_memory/recall/expansion_detector.rb +44 -0
- data/lib/claude_memory/recall.rb +93 -41
- data/lib/claude_memory/resolve/resolver.rb +72 -40
- data/lib/claude_memory/store/sqlite_store.rb +99 -24
- data/lib/claude_memory/sweep/sweeper.rb +6 -0
- data/lib/claude_memory/version.rb +1 -1
- data/lib/claude_memory.rb +21 -0
- metadata +14 -2
- data/docs/remaining_improvements.md +0 -330
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d32c7aa8093eedade1783eefa7109c996aa134d01dea01b67794612c126cf068
|
|
4
|
+
data.tar.gz: 78fe0f2ff602c740b6ab727a0fde88d07fb235f38b1143b644b4e7498f07079f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be68b153e9e25ef3b8e5ad71ba7fdd89e5ace40f0848125b480bf35c96ad8b0a73b1fd891e59faf5807bc99d8d637f0c6d647e2b1d6c86ad0654b9df69c1ab45
|
|
7
|
+
data.tar.gz: 92ee3e92e7967e03f642a5736a84f70563dd6e9f00fc3a7b24714b97294348e35645cdbfdd4b760bc5ee21301bb869bccbc686050cbc95e2bf7399c38508a32e
|
data/.claude/CLAUDE.md
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
This file is auto-generated by claude-memory.
|
|
3
3
|
Do not edit manually - changes will be overwritten.
|
|
4
|
-
Generated: 2026-02-
|
|
4
|
+
Generated: 2026-02-04T16:37:00Z
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
7
|
# Project Memory
|
|
8
8
|
|
|
9
|
+
## Current Decisions
|
|
10
|
+
|
|
11
|
+
- From QMD 2026-02-02 restudy: adopt Claude Code plugin format, MCP structured content pattern, MCP query guide prompt, inline status checks. Carry forward sqlite-vec, RRF, docids, smart expansion from 2026-01-26. Reject custom fine-tuned models, LLM reranking, YAML collections.
|
|
12
|
+
- From claude-supermemory study: adopt SessionStart hook context injection (hookSpecificOutput.additionalContext), tool-specific observation compression, and relative time formatting. Reject cloud storage dependency and no-test approach.
|
|
13
|
+
|
|
14
|
+
## Conventions
|
|
15
|
+
|
|
16
|
+
- MCP tools return dual content (text summary) + structuredContent (JSON) via TextSummary module and Server#handle_tools_call. Compact mode (compact: true) omits receipts for ~60% smaller responses.
|
|
17
|
+
- ContentSanitizer strips system-reminder, local-command-caveat, command-message, command-name, command-args tags in addition to private/no-memory/secret/claude-memory-context.
|
|
18
|
+
- Core::RelativeTime module provides progressive time formatting: just now → Xm ago → Xh ago → Xd ago → YYYY-MM-DD. Used in ResponseFormatter for *_ago fields.
|
|
19
|
+
- MCP server registers memory_guide prompt via prompts/list and prompts/get endpoints. QueryGuide module holds prompt content.
|
|
20
|
+
- Claude Code plugin with marketplace.json, skill definitions, MCP server bundling. 5,700+ stars, by Tobi Lütke. Custom fine-tuned query expansion (Qwen3-1.7B, SFT+GRPO). Dual content/structuredContent MCP pattern.
|
|
21
|
+
- Cloud-backed Claude Code plugin (~1,195 LOC JavaScript) using Supermemory API for persistent memory across sessions. Uses hooks for SessionStart context injection and Stop transcript capture. No local database.
|
|
@@ -16,6 +16,16 @@ The user is asking about: $ARGUMENTS
|
|
|
16
16
|
|
|
17
17
|
## Step-by-Step Workflow
|
|
18
18
|
|
|
19
|
+
### 0. Verify Memory Health
|
|
20
|
+
|
|
21
|
+
Before querying, confirm the memory system is operational:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
memory.check_setup
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If status is not "healthy", inform the user and suggest running `claude-memory doctor` for details.
|
|
28
|
+
|
|
19
29
|
### 1. Query Memory (REQUIRED FIRST STEP)
|
|
20
30
|
|
|
21
31
|
Run multiple memory queries to find existing knowledge:
|
|
@@ -11,7 +11,8 @@ Systematically implement feature improvements from `docs/improvements.md`, makin
|
|
|
11
11
|
|
|
12
12
|
## Process Overview
|
|
13
13
|
|
|
14
|
-
1. **
|
|
14
|
+
1. **Check memory health** by calling `memory.check_setup` to verify the system is operational
|
|
15
|
+
2. **Read the improvements document** from `docs/improvements.md`
|
|
15
16
|
2. **Identify unimplemented features** from "Remaining Tasks" section
|
|
16
17
|
3. **Prioritize by stated priority** (Medium → Low)
|
|
17
18
|
4. **Assess feasibility** (skip if too complex or requires external services)
|
|
@@ -22,6 +23,16 @@ Systematically implement feature improvements from `docs/improvements.md`, makin
|
|
|
22
23
|
|
|
23
24
|
## Detailed Steps
|
|
24
25
|
|
|
26
|
+
### Step 0: Verify Memory Health
|
|
27
|
+
|
|
28
|
+
Before starting, confirm the memory system is operational:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
memory.check_setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If status is not "healthy", address any issues before proceeding.
|
|
35
|
+
|
|
25
36
|
### Step 1: Read and Parse Improvements Document
|
|
26
37
|
|
|
27
38
|
```bash
|
data/.claude-plugin/plugin.json
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,76 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.5.0] - 2026-02-04
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
**MCP Structured Content & Compact Mode**
|
|
12
|
+
- Dual content (text summary) + structuredContent (JSON) for all MCP tools
|
|
13
|
+
- `TextSummary` module generates human-readable summaries alongside structured data
|
|
14
|
+
- Compact mode (`compact: true`) omits provenance receipts for ~60% smaller responses
|
|
15
|
+
- MCP query guide prompt registered via `prompts/list` and `prompts/get` endpoints
|
|
16
|
+
- `QueryGuide` module provides tool selection guidance to Claude
|
|
17
|
+
|
|
18
|
+
**Search & Retrieval Improvements**
|
|
19
|
+
- Reciprocal Rank Fusion (RRF) replacing naive merge for hybrid search
|
|
20
|
+
- Better result ordering when combining FTS5 and semantic search results
|
|
21
|
+
- Smart expansion detection to skip unnecessary vector search
|
|
22
|
+
- Reduces latency when FTS5 already provides strong matches
|
|
23
|
+
- Enhanced snippet extraction for search results
|
|
24
|
+
- Better context windows around matched terms
|
|
25
|
+
|
|
26
|
+
**Provenance & Traceability**
|
|
27
|
+
- Line-range references in provenance for precise source linking
|
|
28
|
+
- Facts now track exact line ranges in source transcripts
|
|
29
|
+
- Fact dependency graph visualization via BFS traversal
|
|
30
|
+
- Trace supersession and conflict chains between facts
|
|
31
|
+
|
|
32
|
+
**User-Friendly Identifiers**
|
|
33
|
+
- Docid short hash system for user-friendly fact references
|
|
34
|
+
- Short, memorable identifiers instead of raw integer IDs
|
|
35
|
+
|
|
36
|
+
**Caching & Performance**
|
|
37
|
+
- LLM response caching schema and store methods
|
|
38
|
+
- Cache layer for expensive extraction operations
|
|
39
|
+
- Structured JSON logging with level filtering
|
|
40
|
+
- Configurable log levels (debug, info, warn, error)
|
|
41
|
+
- JSON format for machine-parseable log output
|
|
42
|
+
|
|
43
|
+
**Ingestion & Content Processing**
|
|
44
|
+
- Configurable tool capture filtering for ingestion
|
|
45
|
+
- Control which tool outputs are captured during transcript processing
|
|
46
|
+
- ContentSanitizer now strips `system-reminder`, `local-command-caveat`, `command-message`,
|
|
47
|
+
`command-name`, and `command-args` tags in addition to privacy tags
|
|
48
|
+
- Relative time formatting in MCP recall output
|
|
49
|
+
- Progressive format: just now → Xm ago → Xh ago → Xd ago → YYYY-MM-DD
|
|
50
|
+
|
|
51
|
+
**Developer Tools**
|
|
52
|
+
- `--brief` flag for doctor command and health checks in skills
|
|
53
|
+
- Quick pass/fail output for automated workflows
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
- Preserve SQLite PRAGMAs across connection reconnects
|
|
57
|
+
- WAL mode and other pragmas now survive reconnection cycles
|
|
58
|
+
- Timestamp-only churn in publish output
|
|
59
|
+
- Publish no longer regenerates files when only the timestamp changed
|
|
60
|
+
|
|
61
|
+
### Internal
|
|
62
|
+
|
|
63
|
+
**Code Quality Improvements**
|
|
64
|
+
- Extract duplicates and decompose long methods across codebase
|
|
65
|
+
- Extract ingester transaction body into focused methods
|
|
66
|
+
- Decompose `resolve_fact` into intention-revealing methods
|
|
67
|
+
- Extract `check_setup` and `detailed_stats` into focused helpers
|
|
68
|
+
- Fix N+1 query patterns in `recall.rb`
|
|
69
|
+
- Fix 6 quick wins from quality review (frozen strings, method sizes, naming)
|
|
70
|
+
|
|
71
|
+
**Research & Studies**
|
|
72
|
+
- QMD restudy (2026-02-02): adopt Claude Code plugin format, MCP structured content pattern,
|
|
73
|
+
MCP query guide prompt, inline status checks
|
|
74
|
+
- claude-supermemory study: adopt SessionStart hook context injection, tool-specific observation
|
|
75
|
+
compression, and relative time formatting
|
|
76
|
+
|
|
7
77
|
## [0.4.0] - 2026-02-02
|
|
8
78
|
|
|
9
79
|
### Added
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Migration v8: Add line range references to provenance
|
|
4
|
+
# - Adds line_start and line_end columns for precise source linking
|
|
5
|
+
# - Enables fact verification by pointing to exact location in source content
|
|
6
|
+
# - 1-indexed line numbers matching standard editor conventions
|
|
7
|
+
Sequel.migration do
|
|
8
|
+
up do
|
|
9
|
+
alter_table(:provenance) do
|
|
10
|
+
add_column :line_start, Integer # 1-indexed start line in source content
|
|
11
|
+
add_column :line_end, Integer # 1-indexed end line in source content
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
down do
|
|
16
|
+
alter_table(:provenance) do
|
|
17
|
+
drop_column :line_start
|
|
18
|
+
drop_column :line_end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Migration v9: Add docid (short hash identifier) to facts
|
|
4
|
+
# - Adds docid column for user-friendly fact references (e.g., "abc123de")
|
|
5
|
+
# - Docids are 8-character hex strings derived from SHA256 of fact content
|
|
6
|
+
# - Enables cross-database references and better UX in CLI/MCP
|
|
7
|
+
# - Backfills existing facts with generated docids
|
|
8
|
+
require "digest"
|
|
9
|
+
|
|
10
|
+
Sequel.migration do
|
|
11
|
+
up do
|
|
12
|
+
alter_table(:facts) do
|
|
13
|
+
add_column :docid, String, size: 8
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
run "CREATE UNIQUE INDEX IF NOT EXISTS idx_facts_docid ON facts(docid)"
|
|
17
|
+
|
|
18
|
+
# Backfill existing facts with docids
|
|
19
|
+
self[:facts].each do |fact|
|
|
20
|
+
input = "#{fact[:subject_entity_id]}:#{fact[:predicate]}:#{fact[:object_literal]}:#{fact[:created_at]}"
|
|
21
|
+
docid = Digest::SHA256.hexdigest(input)[0, 8]
|
|
22
|
+
|
|
23
|
+
# Handle unlikely collisions by appending id
|
|
24
|
+
existing = self[:facts].where(docid: docid).exclude(id: fact[:id]).first
|
|
25
|
+
if existing
|
|
26
|
+
docid = Digest::SHA256.hexdigest("#{input}:#{fact[:id]}")[0, 8]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
self[:facts].where(id: fact[:id]).update(docid: docid)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
down do
|
|
34
|
+
run "DROP INDEX IF EXISTS idx_facts_docid"
|
|
35
|
+
alter_table(:facts) do
|
|
36
|
+
drop_column :docid
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Migration v10: Add LLM response cache for distillation cost reduction
|
|
4
|
+
# - Creates llm_cache table to cache API responses by content hash
|
|
5
|
+
# - Cache key: SHA256(operation + model + input)
|
|
6
|
+
# - Enables significant cost savings for repeated/similar distillation requests
|
|
7
|
+
# - Includes TTL support via created_at for future cache expiration
|
|
8
|
+
Sequel.migration do
|
|
9
|
+
up do
|
|
10
|
+
create_table?(:llm_cache) do
|
|
11
|
+
primary_key :id
|
|
12
|
+
String :cache_key, null: false, unique: true # SHA256 hex digest
|
|
13
|
+
String :operation, null: false # e.g., "distill", "extract"
|
|
14
|
+
String :model, null: false # e.g., "claude-sonnet-4-20250514"
|
|
15
|
+
String :input_hash, null: false # SHA256 of input content
|
|
16
|
+
String :result_json, text: true, null: false # Cached JSON response
|
|
17
|
+
Integer :input_tokens # Tokens in request
|
|
18
|
+
Integer :output_tokens # Tokens in response
|
|
19
|
+
String :created_at, null: false
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
run "CREATE INDEX IF NOT EXISTS idx_llm_cache_key ON llm_cache(cache_key)"
|
|
23
|
+
run "CREATE INDEX IF NOT EXISTS idx_llm_cache_created_at ON llm_cache(created_at)"
|
|
24
|
+
run "CREATE INDEX IF NOT EXISTS idx_llm_cache_operation ON llm_cache(operation)"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
down do
|
|
28
|
+
drop_table?(:llm_cache)
|
|
29
|
+
end
|
|
30
|
+
end
|