claude_memory 0.2.0 → 0.3.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/.mind.mv2.o2N83S +0 -0
- data/.claude/CLAUDE.md +1 -0
- data/.claude/rules/claude_memory.generated.md +28 -9
- data/.claude/settings.local.json +9 -1
- data/.claude/skills/check-memory/SKILL.md +77 -0
- data/.claude/skills/improve/SKILL.md +532 -0
- data/.claude/skills/improve/feature-patterns.md +1221 -0
- data/.claude/skills/quality-update/SKILL.md +229 -0
- data/.claude/skills/quality-update/implementation-guide.md +346 -0
- data/.claude/skills/review-commit/SKILL.md +199 -0
- data/.claude/skills/review-for-quality/SKILL.md +154 -0
- data/.claude/skills/review-for-quality/expert-checklists.md +79 -0
- data/.claude/skills/setup-memory/SKILL.md +168 -0
- data/.claude/skills/study-repo/SKILL.md +307 -0
- data/.claude/skills/study-repo/analysis-template.md +323 -0
- data/.claude/skills/study-repo/focus-examples.md +327 -0
- data/CHANGELOG.md +133 -0
- data/CLAUDE.md +130 -11
- data/README.md +117 -10
- data/db/migrations/001_create_initial_schema.rb +117 -0
- data/db/migrations/002_add_project_scoping.rb +33 -0
- data/db/migrations/003_add_session_metadata.rb +42 -0
- data/db/migrations/004_add_fact_embeddings.rb +20 -0
- data/db/migrations/005_add_incremental_sync.rb +21 -0
- data/db/migrations/006_add_operation_tracking.rb +40 -0
- data/db/migrations/007_add_ingestion_metrics.rb +26 -0
- data/docs/.claude/mind.mv2.lock +0 -0
- data/docs/GETTING_STARTED.md +587 -0
- data/docs/RELEASE_NOTES_v0.2.0.md +0 -1
- data/docs/RUBY_COMMUNITY_POST_v0.2.0.md +0 -2
- data/docs/architecture.md +9 -8
- data/docs/auto_init_design.md +230 -0
- data/docs/improvements.md +557 -731
- data/docs/influence/.gitkeep +13 -0
- data/docs/influence/grepai.md +933 -0
- data/docs/influence/qmd.md +2195 -0
- data/docs/plugin.md +257 -11
- data/docs/quality_review.md +472 -1273
- data/docs/remaining_improvements.md +330 -0
- data/lefthook.yml +13 -0
- data/lib/claude_memory/commands/checks/claude_md_check.rb +41 -0
- data/lib/claude_memory/commands/checks/database_check.rb +120 -0
- data/lib/claude_memory/commands/checks/hooks_check.rb +112 -0
- data/lib/claude_memory/commands/checks/reporter.rb +110 -0
- data/lib/claude_memory/commands/checks/snapshot_check.rb +30 -0
- data/lib/claude_memory/commands/doctor_command.rb +12 -129
- data/lib/claude_memory/commands/help_command.rb +1 -0
- data/lib/claude_memory/commands/hook_command.rb +9 -2
- data/lib/claude_memory/commands/index_command.rb +169 -0
- data/lib/claude_memory/commands/ingest_command.rb +1 -1
- data/lib/claude_memory/commands/init_command.rb +5 -197
- data/lib/claude_memory/commands/initializers/database_ensurer.rb +30 -0
- data/lib/claude_memory/commands/initializers/global_initializer.rb +85 -0
- data/lib/claude_memory/commands/initializers/hooks_configurator.rb +156 -0
- data/lib/claude_memory/commands/initializers/mcp_configurator.rb +56 -0
- data/lib/claude_memory/commands/initializers/memory_instructions_writer.rb +135 -0
- data/lib/claude_memory/commands/initializers/project_initializer.rb +111 -0
- data/lib/claude_memory/commands/recover_command.rb +75 -0
- data/lib/claude_memory/commands/registry.rb +5 -1
- data/lib/claude_memory/commands/stats_command.rb +239 -0
- data/lib/claude_memory/commands/uninstall_command.rb +226 -0
- data/lib/claude_memory/core/batch_loader.rb +32 -0
- data/lib/claude_memory/core/concept_ranker.rb +73 -0
- data/lib/claude_memory/core/embedding_candidate_builder.rb +37 -0
- data/lib/claude_memory/core/fact_collector.rb +51 -0
- data/lib/claude_memory/core/fact_query_builder.rb +154 -0
- data/lib/claude_memory/core/fact_ranker.rb +113 -0
- data/lib/claude_memory/core/result_builder.rb +54 -0
- data/lib/claude_memory/core/result_sorter.rb +25 -0
- data/lib/claude_memory/core/scope_filter.rb +61 -0
- data/lib/claude_memory/core/text_builder.rb +29 -0
- data/lib/claude_memory/embeddings/generator.rb +161 -0
- data/lib/claude_memory/embeddings/similarity.rb +69 -0
- data/lib/claude_memory/hook/handler.rb +4 -3
- data/lib/claude_memory/index/lexical_fts.rb +7 -2
- data/lib/claude_memory/infrastructure/operation_tracker.rb +158 -0
- data/lib/claude_memory/infrastructure/schema_validator.rb +206 -0
- data/lib/claude_memory/ingest/content_sanitizer.rb +6 -7
- data/lib/claude_memory/ingest/ingester.rb +99 -15
- data/lib/claude_memory/ingest/metadata_extractor.rb +57 -0
- data/lib/claude_memory/ingest/tool_extractor.rb +71 -0
- data/lib/claude_memory/mcp/response_formatter.rb +331 -0
- data/lib/claude_memory/mcp/server.rb +19 -0
- data/lib/claude_memory/mcp/setup_status_analyzer.rb +73 -0
- data/lib/claude_memory/mcp/tool_definitions.rb +279 -0
- data/lib/claude_memory/mcp/tool_helpers.rb +80 -0
- data/lib/claude_memory/mcp/tools.rb +330 -320
- data/lib/claude_memory/recall/dual_query_template.rb +63 -0
- data/lib/claude_memory/recall.rb +304 -237
- data/lib/claude_memory/resolve/resolver.rb +52 -49
- data/lib/claude_memory/store/sqlite_store.rb +210 -144
- data/lib/claude_memory/store/store_manager.rb +6 -6
- data/lib/claude_memory/sweep/sweeper.rb +6 -0
- data/lib/claude_memory/version.rb +1 -1
- data/lib/claude_memory.rb +35 -3
- metadata +71 -11
- data/.claude/.mind.mv2.aLCUZd +0 -0
- data/.claude/memory.sqlite3 +0 -0
- data/.mcp.json +0 -11
- /data/docs/{feature_adoption_plan.md → plans/feature_adoption_plan.md} +0 -0
- /data/docs/{feature_adoption_plan_revised.md → plans/feature_adoption_plan_revised.md} +0 -0
- /data/docs/{plan.md → plans/plan.md} +0 -0
- /data/docs/{updated_plan.md → plans/updated_plan.md} +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Auto-Initialization and Upgrade Design
|
|
2
|
+
|
|
3
|
+
## Problem Statement
|
|
4
|
+
|
|
5
|
+
When users install ClaudeMemory (add to MCP), they must manually run `claude-memory init`. There's no:
|
|
6
|
+
- Automatic detection of uninitialized state
|
|
7
|
+
- Upgrade detection when CLAUDE.md instructions change
|
|
8
|
+
- Graceful degradation when not configured
|
|
9
|
+
|
|
10
|
+
## Constraints
|
|
11
|
+
|
|
12
|
+
1. **No hooks before init**: Can't use SessionStart hook to auto-init (hooks aren't configured yet)
|
|
13
|
+
2. **MCP server is stateless**: Starts fresh each time, no persistent memory
|
|
14
|
+
3. **Skills unavailable pre-init**: Can't use skills to detect/fix initialization
|
|
15
|
+
|
|
16
|
+
## Proposed Multi-Layer Solution
|
|
17
|
+
|
|
18
|
+
### Layer 1: Setup Status MCP Tool (Immediate Detection)
|
|
19
|
+
|
|
20
|
+
**Add new MCP tool: `memory.check_setup`**
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
{
|
|
24
|
+
name: "memory.check_setup",
|
|
25
|
+
description: "Check if ClaudeMemory is properly initialized. CALL THIS FIRST if memory tools fail or on first use of ClaudeMemory.",
|
|
26
|
+
result: {
|
|
27
|
+
initialized: true/false,
|
|
28
|
+
version: "1.2.3",
|
|
29
|
+
issues: ["No CLAUDE.md found", "Hooks not configured"],
|
|
30
|
+
recommendation: "Run: claude-memory init"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Implementation:**
|
|
36
|
+
- Check for database existence
|
|
37
|
+
- Check for CLAUDE.md with version marker
|
|
38
|
+
- Check for hooks configuration
|
|
39
|
+
- Return actionable recommendations
|
|
40
|
+
|
|
41
|
+
**Update other tool descriptions:**
|
|
42
|
+
```ruby
|
|
43
|
+
description: "... If this tool fails with 'database not found', run memory.check_setup for guidance."
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Layer 2: Version Markers (Upgrade Detection)
|
|
47
|
+
|
|
48
|
+
**Add version to CLAUDE.md:**
|
|
49
|
+
|
|
50
|
+
```markdown
|
|
51
|
+
<!-- ClaudeMemory v1.0.0 -->
|
|
52
|
+
# ClaudeMemory
|
|
53
|
+
|
|
54
|
+
...
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Create `claude-memory upgrade` command:**
|
|
58
|
+
- Detect current version in CLAUDE.md
|
|
59
|
+
- Compare with ClaudeMemory::VERSION
|
|
60
|
+
- Offer to upgrade instructions
|
|
61
|
+
- Preserve user customizations
|
|
62
|
+
|
|
63
|
+
**Workflow:**
|
|
64
|
+
```bash
|
|
65
|
+
$ claude-memory upgrade
|
|
66
|
+
Checking configuration version...
|
|
67
|
+
Current: v0.9.0
|
|
68
|
+
Latest: v1.0.0
|
|
69
|
+
|
|
70
|
+
Changes in v1.0.0:
|
|
71
|
+
- Added memory-first workflow instructions
|
|
72
|
+
- Updated tool descriptions
|
|
73
|
+
- New /check-memory skill
|
|
74
|
+
|
|
75
|
+
Upgrade? [y/N] y
|
|
76
|
+
✓ Backed up old CLAUDE.md to CLAUDE.md.backup
|
|
77
|
+
✓ Updated workflow instructions
|
|
78
|
+
✓ Preserved custom sections
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Layer 3: Graceful Degradation (Error Handling)
|
|
82
|
+
|
|
83
|
+
**Update MCP Tools to detect uninitialized state:**
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
def recall(args)
|
|
87
|
+
unless database_exists?
|
|
88
|
+
return {
|
|
89
|
+
error: "ClaudeMemory not initialized",
|
|
90
|
+
help: "Run 'claude-memory init' to set up databases and configuration",
|
|
91
|
+
documentation: "https://github.com/your-repo#installation"
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
# ... normal recall logic
|
|
95
|
+
end
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Benefit**: Claude sees clear actionable errors instead of cryptic database failures.
|
|
99
|
+
|
|
100
|
+
### Layer 4: Setup Reminder Skill
|
|
101
|
+
|
|
102
|
+
**Create `/setup-memory` skill:**
|
|
103
|
+
|
|
104
|
+
```markdown
|
|
105
|
+
---
|
|
106
|
+
name: setup-memory
|
|
107
|
+
description: Guide user through ClaudeMemory installation
|
|
108
|
+
disable-model-invocation: true
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
# ClaudeMemory Setup Guide
|
|
112
|
+
|
|
113
|
+
ClaudeMemory is installed but not initialized.
|
|
114
|
+
|
|
115
|
+
## Quick Setup
|
|
116
|
+
|
|
117
|
+
Run this command:
|
|
118
|
+
```bash
|
|
119
|
+
claude-memory init
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This will:
|
|
123
|
+
1. Create global and project databases
|
|
124
|
+
2. Configure hooks for automatic ingestion
|
|
125
|
+
3. Add workflow instructions to CLAUDE.md
|
|
126
|
+
4. Set up MCP server
|
|
127
|
+
|
|
128
|
+
After running, restart Claude Code to load the configuration.
|
|
129
|
+
|
|
130
|
+
## Verification
|
|
131
|
+
|
|
132
|
+
After init, run:
|
|
133
|
+
```bash
|
|
134
|
+
claude-memory doctor
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Need Help?
|
|
138
|
+
|
|
139
|
+
See: https://github.com/your-repo#troubleshooting
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Usage**: When Claude encounters "not initialized" errors, it can suggest: "Run `/setup-memory` for installation help"
|
|
143
|
+
|
|
144
|
+
### Layer 5: Doctor Command Enhancement
|
|
145
|
+
|
|
146
|
+
**Add `--fix` flag to doctor:**
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
$ claude-memory doctor --fix
|
|
150
|
+
Checking configuration...
|
|
151
|
+
✗ Project database missing
|
|
152
|
+
✗ No CLAUDE.md found
|
|
153
|
+
|
|
154
|
+
Would you like to run init? [y/N] y
|
|
155
|
+
Running: claude-memory init
|
|
156
|
+
...
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Add `--quiet` flag for programmatic checks:**
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
$ claude-memory doctor --quiet
|
|
163
|
+
# Exit code 0 = healthy, 1 = needs init, 2 = needs upgrade
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Implementation Priority
|
|
167
|
+
|
|
168
|
+
### Phase 1 (Immediate Value)
|
|
169
|
+
1. ✅ Add version markers to init command
|
|
170
|
+
2. ✅ Create `memory.check_setup` MCP tool
|
|
171
|
+
3. ✅ Update error messages with actionable help
|
|
172
|
+
4. ✅ Create `/setup-memory` skill
|
|
173
|
+
|
|
174
|
+
### Phase 2 (Enhanced UX)
|
|
175
|
+
5. ⬜ Create `claude-memory upgrade` command
|
|
176
|
+
6. ⬜ Add `doctor --fix` and `doctor --quiet`
|
|
177
|
+
7. ⬜ Add upgrade detection to SessionStart hook
|
|
178
|
+
|
|
179
|
+
### Phase 3 (Polish)
|
|
180
|
+
8. ⬜ Version migration system (v1.0.0 → v1.1.0)
|
|
181
|
+
9. ⬜ Preserve custom CLAUDE.md sections during upgrade
|
|
182
|
+
10. ⬜ Add upgrade notifications via MCP tool
|
|
183
|
+
|
|
184
|
+
## Decision: Why Not Auto-Init?
|
|
185
|
+
|
|
186
|
+
We deliberately **don't** auto-initialize because:
|
|
187
|
+
|
|
188
|
+
1. **User control**: Installation should be explicit, not magical
|
|
189
|
+
2. **Git hygiene**: Creates `.claude/` directory - users should understand this
|
|
190
|
+
3. **Global vs project**: Users choose `--global` or project-local
|
|
191
|
+
4. **Customization**: Users may want to review CLAUDE.md before committing
|
|
192
|
+
|
|
193
|
+
Instead, we make initialization **obvious** and **frictionless** when needed.
|
|
194
|
+
|
|
195
|
+
## Example User Journey
|
|
196
|
+
|
|
197
|
+
### First-Time User
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
User: Where are client errors handled?
|
|
201
|
+
Claude: Let me check memory...
|
|
202
|
+
Claude: (calls memory.recall)
|
|
203
|
+
MCP: Error - database not found. Run memory.check_setup.
|
|
204
|
+
Claude: (calls memory.check_setup)
|
|
205
|
+
MCP: Not initialized. Run: claude-memory init
|
|
206
|
+
Claude: "It looks like ClaudeMemory isn't set up yet. Run `claude-memory init` to configure it. Would you like me to explain what this does first?"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Upgrading User
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
User: Check memory about authentication
|
|
213
|
+
Claude: (calls memory.recall)
|
|
214
|
+
MCP: Returns results with warning: "Using outdated configuration v0.9.0. Run: claude-memory upgrade"
|
|
215
|
+
Claude: "I found these facts about authentication: [...]. Note: You can upgrade to the latest ClaudeMemory configuration by running `claude-memory upgrade`."
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Testing Strategy
|
|
219
|
+
|
|
220
|
+
- Unit tests for version detection logic
|
|
221
|
+
- Integration tests for upgrade workflow
|
|
222
|
+
- Manual testing of error messages
|
|
223
|
+
- Test preservation of custom CLAUDE.md sections
|
|
224
|
+
|
|
225
|
+
## Documentation Updates
|
|
226
|
+
|
|
227
|
+
- Update README with upgrade instructions
|
|
228
|
+
- Add CHANGELOG for version history
|
|
229
|
+
- Document version markers in CLAUDE.md
|
|
230
|
+
- Add troubleshooting guide for common issues
|