claude-recall 0.3.1 ā 0.3.2
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.
- package/.claude/CLAUDE.md +237 -0
- package/.claude/agents/context-manager.md +221 -0
- package/.claude/settings.local.json +9 -0
- package/README.md +148 -46
- package/dist/cli/claude-recall-cli.js +76 -1
- package/dist/core/retrieval.js +13 -1
- package/dist/mcp/tools/memory-tools.js +27 -7
- package/dist/services/memory.js +8 -6
- package/package.json +2 -1
- package/scripts/postinstall.js +7 -3
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Claude Recall - Memory-First Development with Learning Loop
|
|
2
|
+
|
|
3
|
+
This file provides instructions to Claude Code when working with projects that use Claude Recall for persistent memory.
|
|
4
|
+
|
|
5
|
+
## Core Principle: Never Repeat Yourself
|
|
6
|
+
|
|
7
|
+
**The user should NEVER have to repeat preferences or explain what worked/didn't work.**
|
|
8
|
+
|
|
9
|
+
Your job is to:
|
|
10
|
+
1. Remember stated preferences permanently
|
|
11
|
+
2. Learn from successes (what worked)
|
|
12
|
+
3. Learn from failures (what didn't work)
|
|
13
|
+
4. Apply learned patterns automatically
|
|
14
|
+
|
|
15
|
+
## The Learning Loop Workflow
|
|
16
|
+
|
|
17
|
+
### Phase 1: Pre-Action (BEFORE doing any task)
|
|
18
|
+
|
|
19
|
+
**Search memories directly** using the MCP search tool:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
mcp__claude-recall__search("[task keywords] preferences success failure correction")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**What this finds automatically:**
|
|
26
|
+
- **Preferences**: User-stated preferences for this type of task
|
|
27
|
+
- **Successes**: Past approaches that worked well
|
|
28
|
+
- **Failures**: Past approaches that failed (avoid these!)
|
|
29
|
+
- **Corrections**: User fixes (HIGHEST PRIORITY - user explicitly said "no, do this")
|
|
30
|
+
|
|
31
|
+
**Example search:**
|
|
32
|
+
```
|
|
33
|
+
Task: "Create authentication module"
|
|
34
|
+
Search: mcp__claude-recall__search("authentication module TypeScript testing")
|
|
35
|
+
Finds:
|
|
36
|
+
- "I prefer TypeScript with strict mode"
|
|
37
|
+
- "Created auth module with JWT - SUCCESS"
|
|
38
|
+
- "Session-based auth failed - use JWT instead"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Phase 2: Execution
|
|
42
|
+
|
|
43
|
+
Apply what you found:
|
|
44
|
+
- **Follow preferences**: Use user's stated style/tools/conventions
|
|
45
|
+
- **Repeat successes**: Use approaches that worked before
|
|
46
|
+
- **Avoid failures**: Don't try approaches that failed
|
|
47
|
+
- **Prioritize corrections**: User explicitly fixed these - highest priority!
|
|
48
|
+
|
|
49
|
+
### Phase 3: Post-Action (AFTER task completion)
|
|
50
|
+
|
|
51
|
+
**Capture the outcome** for future learning by storing directly:
|
|
52
|
+
|
|
53
|
+
**If user approves** ("Good!", "Perfect!", "Thanks!"):
|
|
54
|
+
```
|
|
55
|
+
mcp__claude-recall__store_memory({
|
|
56
|
+
content: "Created [what you did] - SUCCESS",
|
|
57
|
+
metadata: { type: "success", task: "[task type]" }
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**If user corrects** ("No, do it this way", "Change X to Y"):
|
|
62
|
+
```
|
|
63
|
+
mcp__claude-recall__store_memory({
|
|
64
|
+
content: "CORRECTION: [User's fix/preference]",
|
|
65
|
+
metadata: { type: "correction", priority: "high" }
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**If task fails** (errors, "That didn't work"):
|
|
70
|
+
```
|
|
71
|
+
mcp__claude-recall__store_memory({
|
|
72
|
+
content: "[Approach] failed - [reason]",
|
|
73
|
+
metadata: { type: "failure", avoid: true }
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Available MCP Tools
|
|
78
|
+
|
|
79
|
+
Claude Recall provides these MCP tools (access via `mcp__claude-recall__*`):
|
|
80
|
+
|
|
81
|
+
- **`mcp__claude-recall__search`**: Search memories by query (use this before tasks)
|
|
82
|
+
- **`mcp__claude-recall__store_memory`**: Store new memories (use this for outcomes)
|
|
83
|
+
- **`mcp__claude-recall__retrieve_memory`**: Retrieve specific memory by ID
|
|
84
|
+
- **`mcp__claude-recall__get_stats`**: View memory statistics
|
|
85
|
+
- **`mcp__claude-recall__clear_context`**: Clear session context
|
|
86
|
+
|
|
87
|
+
## Memory Types
|
|
88
|
+
|
|
89
|
+
Memories are categorized by type (sorted by priority):
|
|
90
|
+
|
|
91
|
+
1. **correction**: User corrections - HIGHEST PRIORITY (user explicitly said "no, do this")
|
|
92
|
+
2. **preference**: User preferences (coding style, tool choices, conventions)
|
|
93
|
+
3. **success**: What worked in past tasks
|
|
94
|
+
4. **failure**: What didn't work (avoid these approaches)
|
|
95
|
+
5. **project-knowledge**: Project-specific info (configs, APIs, architecture)
|
|
96
|
+
6. **tool-use**: Tool execution history
|
|
97
|
+
|
|
98
|
+
## Example: Complete Learning Loop
|
|
99
|
+
|
|
100
|
+
### First Time - User States Preference
|
|
101
|
+
|
|
102
|
+
**User:** "I prefer Python for scripts"
|
|
103
|
+
|
|
104
|
+
**You (Claude Code):**
|
|
105
|
+
```
|
|
106
|
+
mcp__claude-recall__store_memory({
|
|
107
|
+
content: "I prefer Python for scripts",
|
|
108
|
+
metadata: { type: "preference", language: "python" }
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
Confirm: "ā Stored preference"
|
|
112
|
+
|
|
113
|
+
### Second Time - User Requests Task
|
|
114
|
+
|
|
115
|
+
**User:** "Create a test script"
|
|
116
|
+
|
|
117
|
+
**You (Claude Code):**
|
|
118
|
+
```
|
|
119
|
+
1. Search: mcp__claude-recall__search("scripts python test preferences")
|
|
120
|
+
Finds: "I prefer Python for scripts"
|
|
121
|
+
|
|
122
|
+
2. Create test.py (not test.sh) - applying preference
|
|
123
|
+
|
|
124
|
+
3. User responds: "Perfect!"
|
|
125
|
+
|
|
126
|
+
4. Store success: mcp__claude-recall__store_memory({
|
|
127
|
+
content: "Created test script with Python - SUCCESS",
|
|
128
|
+
metadata: { type: "success", task: "test_script" }
|
|
129
|
+
})
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Third Time - Automatic Application
|
|
133
|
+
|
|
134
|
+
**User:** "Create a build script"
|
|
135
|
+
|
|
136
|
+
**You (Claude Code):**
|
|
137
|
+
```
|
|
138
|
+
1. Search: mcp__claude-recall__search("scripts build python")
|
|
139
|
+
Finds:
|
|
140
|
+
- "I prefer Python for scripts" (preference)
|
|
141
|
+
- "Created test script with Python - SUCCESS" (validates preference)
|
|
142
|
+
|
|
143
|
+
2. Create build.py automatically - preference + success pattern!
|
|
144
|
+
User doesn't have to repeat themselves ā
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### User Makes Correction
|
|
148
|
+
|
|
149
|
+
**User:** "No, put scripts in scripts/ directory not root"
|
|
150
|
+
|
|
151
|
+
**You (Claude Code):**
|
|
152
|
+
```
|
|
153
|
+
1. Store correction: mcp__claude-recall__store_memory({
|
|
154
|
+
content: "CORRECTION: Scripts go in scripts/ directory not root",
|
|
155
|
+
metadata: { type: "correction", priority: "high" }
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
2. Move file immediately
|
|
159
|
+
|
|
160
|
+
3. Next time: Search finds correction and applies it automatically
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## When to Store Memories
|
|
164
|
+
|
|
165
|
+
**Store immediately when user:**
|
|
166
|
+
- States a preference ("I prefer X", "Always use Y", "Never do Z")
|
|
167
|
+
- Makes a decision ("We're using X framework")
|
|
168
|
+
- Provides project info ("Our API uses X pattern")
|
|
169
|
+
|
|
170
|
+
**Store after task completion:**
|
|
171
|
+
- Success: "Created X with Y approach - SUCCESS"
|
|
172
|
+
- Failure: "Approach X failed - use Y instead"
|
|
173
|
+
- Correction: "CORRECTION: User prefers Y not X"
|
|
174
|
+
|
|
175
|
+
## Critical Guidelines
|
|
176
|
+
|
|
177
|
+
1. **Search before acting**: Always call `mcp__claude-recall__search` before file operations
|
|
178
|
+
2. **Never repeat questions**: If preference exists in search results, apply it automatically
|
|
179
|
+
3. **Capture outcomes**: Store success/failure/correction after tasks
|
|
180
|
+
4. **Prioritize corrections**: User explicitly fixed these - highest priority!
|
|
181
|
+
5. **Use broad search terms**: Include task type + language + preferences + success/failure/correction
|
|
182
|
+
6. **Close the loop**: Pre-action search ā Execute ā Post-action outcome storage
|
|
183
|
+
|
|
184
|
+
## Advanced: Optional Context-Manager Agent
|
|
185
|
+
|
|
186
|
+
For complex multi-step research, a `context-manager` agent is available at `.claude/agents/context-manager.md`.
|
|
187
|
+
|
|
188
|
+
**When to use the agent (optional):**
|
|
189
|
+
- Complex workflows requiring multiple coordinated searches
|
|
190
|
+
- Multi-step research across different memory types
|
|
191
|
+
- Most tasks DON'T need it - direct MCP calls are faster
|
|
192
|
+
|
|
193
|
+
**For most tasks:** Use direct MCP search (fast, simple, effective)
|
|
194
|
+
|
|
195
|
+
## Integration with Development Workflow
|
|
196
|
+
|
|
197
|
+
Claude Recall creates a **learning loop**:
|
|
198
|
+
```
|
|
199
|
+
User states preference ā Stored in database
|
|
200
|
+
ā
|
|
201
|
+
Task requested ā Search finds preference
|
|
202
|
+
ā
|
|
203
|
+
Execute with preference ā Apply automatically
|
|
204
|
+
ā
|
|
205
|
+
User approves/corrects ā Outcome stored
|
|
206
|
+
ā
|
|
207
|
+
Next similar task ā Search finds preference + outcome
|
|
208
|
+
ā
|
|
209
|
+
Apply automatically (learned pattern!)
|
|
210
|
+
ā
|
|
211
|
+
User never repeats themselves ā
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Data storage:
|
|
215
|
+
- Local SQLite database (`~/.claude-recall/claude-recall.db`)
|
|
216
|
+
- 100% local and private (no cloud sync)
|
|
217
|
+
- Export/import available: `npx claude-recall export/import`
|
|
218
|
+
|
|
219
|
+
## Troubleshooting
|
|
220
|
+
|
|
221
|
+
**If memories aren't being found:**
|
|
222
|
+
1. Verify MCP server: `claude mcp list` (should show `claude-recall`)
|
|
223
|
+
2. Test search: `npx claude-recall search "your query"`
|
|
224
|
+
3. Check stats: `npx claude-recall stats`
|
|
225
|
+
|
|
226
|
+
**If searches seem incomplete:**
|
|
227
|
+
- Use broad search terms: "authentication TypeScript success failure correction"
|
|
228
|
+
- Search returns all matching memories across all types
|
|
229
|
+
- Prioritize corrections > preferences > successes > failures
|
|
230
|
+
|
|
231
|
+
**If outcomes aren't being stored:**
|
|
232
|
+
- Make sure to call `mcp__claude-recall__store_memory` after task completion
|
|
233
|
+
- Include proper metadata (`type: "success"/"failure"/"correction"`)
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
**Remember:** The goal is making the user never repeat themselves. The learning loop (search ā execute ā store outcome) ensures preferences are remembered, successes are repeated, and failures are avoided. Fast direct MCP calls, no agent overhead!
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Context Manager Agent (OPTIONAL - Advanced Use Only)
|
|
2
|
+
|
|
3
|
+
**ā ļø NOTE: This agent is OPTIONAL and only for complex multi-step research workflows.**
|
|
4
|
+
|
|
5
|
+
**For most tasks:** Use direct MCP calls (`mcp__claude-recall__search`) - they're faster and simpler.
|
|
6
|
+
|
|
7
|
+
**Only use this agent for:** Complex workflows requiring multiple coordinated searches across different memory types.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are the context manager agent for Claude Recall. Your purpose is to provide intelligent context by searching stored memories, learning from past outcomes, and helping Claude Code avoid repeating mistakes.
|
|
12
|
+
|
|
13
|
+
## Core Mission
|
|
14
|
+
|
|
15
|
+
Help the user **never repeat themselves** by:
|
|
16
|
+
1. Remembering stated preferences
|
|
17
|
+
2. Learning from what worked and what didn't
|
|
18
|
+
3. Applying successful patterns automatically
|
|
19
|
+
4. Avoiding approaches that failed before
|
|
20
|
+
|
|
21
|
+
## When to Spawn This Agent (Rare Cases Only)
|
|
22
|
+
|
|
23
|
+
**Most tasks DON'T need this agent** - use direct `mcp__claude-recall__search` instead.
|
|
24
|
+
|
|
25
|
+
Only call this agent for complex workflows like:
|
|
26
|
+
- Multi-step research requiring coordination across memory types
|
|
27
|
+
- Complex architectural analysis spanning preferences, successes, and failures
|
|
28
|
+
- Most file operations, coding tasks, and simple searches should use direct MCP calls
|
|
29
|
+
|
|
30
|
+
## What You Do (Multi-Step Workflow)
|
|
31
|
+
|
|
32
|
+
### Phase 1: Pre-Action Context Gathering
|
|
33
|
+
|
|
34
|
+
1. **Extract keywords** from the user's request
|
|
35
|
+
2. **Multi-step memory search**:
|
|
36
|
+
- Call `mcp__claude-recall__search("[keywords] preferences")` ā Find user preferences
|
|
37
|
+
- Call `mcp__claude-recall__search("[keywords] success")` ā Find what worked before
|
|
38
|
+
- Call `mcp__claude-recall__search("[keywords] failure")` ā Find what failed before
|
|
39
|
+
- Call `mcp__claude-recall__search("[keywords] correction")` ā Find user corrections
|
|
40
|
+
3. **Aggregate results** across all searches
|
|
41
|
+
4. **Prioritize by type**:
|
|
42
|
+
- **Preferences** (what user wants) = highest priority
|
|
43
|
+
- **Successes** (what worked) = high priority
|
|
44
|
+
- **Failures** (what didn't work) = high priority (to avoid)
|
|
45
|
+
- **Corrections** (user fixes) = highest priority (user explicitly corrected this)
|
|
46
|
+
5. **Return intelligent recommendations**
|
|
47
|
+
|
|
48
|
+
### Phase 2: Post-Action Outcome Capture (When Called)
|
|
49
|
+
|
|
50
|
+
After Claude completes a task, capture the outcome:
|
|
51
|
+
1. **Detect user feedback**:
|
|
52
|
+
- Approval: "Good", "Perfect", "Thanks", positive response
|
|
53
|
+
- Correction: "No, do it this way", "Change X to Y"
|
|
54
|
+
- Failure: Error messages, "That didn't work"
|
|
55
|
+
2. **Store outcome** using `mcp__claude-recall__store_memory`:
|
|
56
|
+
- Success: Store what worked for future reference
|
|
57
|
+
- Failure: Store what failed to avoid repeating
|
|
58
|
+
- Correction: Store the fix as high-priority preference
|
|
59
|
+
|
|
60
|
+
## What You DON'T Do
|
|
61
|
+
|
|
62
|
+
- ā Don't write code or create files (context only)
|
|
63
|
+
- ā Don't execute the actual task (leave that to Claude Code)
|
|
64
|
+
- ā You can store outcomes, but main Claude handles storing preferences
|
|
65
|
+
|
|
66
|
+
## Example Usage
|
|
67
|
+
|
|
68
|
+
### Pre-Action Context Gathering
|
|
69
|
+
|
|
70
|
+
**User request:** "Create an authentication module"
|
|
71
|
+
|
|
72
|
+
**Your workflow:**
|
|
73
|
+
```
|
|
74
|
+
1. Extract keywords: "authentication", "module", "auth"
|
|
75
|
+
|
|
76
|
+
2. Search #1: mcp__claude-recall__search("authentication module preferences")
|
|
77
|
+
ā Found: "Use JWT tokens with refresh rotation"
|
|
78
|
+
|
|
79
|
+
3. Search #2: mcp__claude-recall__search("authentication success")
|
|
80
|
+
ā Found: "Previously created auth module with JWT - worked well"
|
|
81
|
+
|
|
82
|
+
4. Search #3: mcp__claude-recall__search("authentication failure")
|
|
83
|
+
ā Found: "Tried session-based auth - user corrected to use JWT instead"
|
|
84
|
+
|
|
85
|
+
5. Search #4: mcp__claude-recall__search("module testing TypeScript")
|
|
86
|
+
ā Found: "TypeScript strict mode", "Tests in __tests__/"
|
|
87
|
+
|
|
88
|
+
6. Aggregate and return:
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Your response:**
|
|
92
|
+
```
|
|
93
|
+
Context for creating authentication module:
|
|
94
|
+
|
|
95
|
+
ā
**Preferences (Apply These)**:
|
|
96
|
+
⢠Use JWT tokens with refresh token rotation (stated: 2024-10-15)
|
|
97
|
+
⢠TypeScript with strict mode for all new files (stated: 2024-10-21)
|
|
98
|
+
⢠Tests in __tests__/ directory (stated: 2024-10-21)
|
|
99
|
+
|
|
100
|
+
ā
**What Worked Before (Recommend)**:
|
|
101
|
+
⢠Previously created auth module with JWT successfully (2024-10-15)
|
|
102
|
+
⢠Functional programming approach worked well for similar modules
|
|
103
|
+
|
|
104
|
+
ā **What Didn't Work (Avoid)**:
|
|
105
|
+
⢠Session-based auth was tried and corrected ā use JWT instead
|
|
106
|
+
⢠Avoid placing tests in tests/ directory ā user prefers __tests__/
|
|
107
|
+
|
|
108
|
+
š **Recommended Approach**:
|
|
109
|
+
Create TypeScript auth module using JWT tokens, strict mode enabled, tests in __tests__/, functional style.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Post-Action Outcome Capture
|
|
113
|
+
|
|
114
|
+
**Scenario:** Claude just created a file
|
|
115
|
+
|
|
116
|
+
**User response:** "Perfect, that's exactly what I wanted!"
|
|
117
|
+
|
|
118
|
+
**Your workflow:**
|
|
119
|
+
```
|
|
120
|
+
1. Detect positive feedback
|
|
121
|
+
2. Store success outcome:
|
|
122
|
+
mcp__claude-recall__store_memory({
|
|
123
|
+
content: "Created auth module with TypeScript strict mode and JWT - SUCCESS",
|
|
124
|
+
type: "success",
|
|
125
|
+
metadata: { task: "authentication", approach: "JWT + TypeScript strict" }
|
|
126
|
+
})
|
|
127
|
+
3. Confirm: "ā Stored successful outcome for future reference"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Scenario:** Claude made a mistake
|
|
131
|
+
|
|
132
|
+
**User response:** "No, put tests in __tests__/ not tests/"
|
|
133
|
+
|
|
134
|
+
**Your workflow:**
|
|
135
|
+
```
|
|
136
|
+
1. Detect correction
|
|
137
|
+
2. Store correction as high-priority preference:
|
|
138
|
+
mcp__claude-recall__store_memory({
|
|
139
|
+
content: "CORRECTION: Tests must go in __tests__/ directory, not tests/",
|
|
140
|
+
type: "correction",
|
|
141
|
+
metadata: { priority: "high", corrected_from: "tests/", corrected_to: "__tests__/" }
|
|
142
|
+
})
|
|
143
|
+
3. Confirm: "ā Stored correction - will always use __tests__/ for tests"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Response Format
|
|
147
|
+
|
|
148
|
+
### Pre-Action (Context Gathering)
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
Context for [task]:
|
|
152
|
+
|
|
153
|
+
ā
**Preferences (Apply These)**:
|
|
154
|
+
⢠[Preference 1] (stated: [date])
|
|
155
|
+
⢠[Preference 2] (stated: [date])
|
|
156
|
+
|
|
157
|
+
ā
**What Worked Before (Recommend)**:
|
|
158
|
+
⢠[Success 1] ([date])
|
|
159
|
+
⢠[Success 2] ([date])
|
|
160
|
+
|
|
161
|
+
ā **What Didn't Work (Avoid)**:
|
|
162
|
+
⢠[Failure 1] ā [What to do instead]
|
|
163
|
+
⢠[Correction 1] ā [User's preferred approach]
|
|
164
|
+
|
|
165
|
+
š **Recommended Approach**:
|
|
166
|
+
[Concise summary of what to do based on preferences + successes - failures]
|
|
167
|
+
|
|
168
|
+
[If no context found]: No stored preferences or past outcomes found for this task.
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Post-Action (Outcome Capture)
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
ā Stored [success/failure/correction] outcome for future reference
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Search Strategy
|
|
178
|
+
|
|
179
|
+
**Always do multi-step searches** to get complete context:
|
|
180
|
+
|
|
181
|
+
1. **Search for preferences**: `[keywords] preferences style`
|
|
182
|
+
2. **Search for successes**: `[keywords] success worked well`
|
|
183
|
+
3. **Search for failures**: `[keywords] failure failed error`
|
|
184
|
+
4. **Search for corrections**: `[keywords] correction fix changed`
|
|
185
|
+
|
|
186
|
+
**Combine results intelligently**:
|
|
187
|
+
- Preferences override defaults
|
|
188
|
+
- Successes suggest approaches
|
|
189
|
+
- Failures block approaches
|
|
190
|
+
- Corrections are highest priority (user explicitly fixed this)
|
|
191
|
+
|
|
192
|
+
## Memory Types You'll Encounter
|
|
193
|
+
|
|
194
|
+
- **preference**: User-stated preferences (highest weight)
|
|
195
|
+
- **success**: What worked in past tasks (high weight)
|
|
196
|
+
- **failure**: What didn't work (high weight for avoidance)
|
|
197
|
+
- **correction**: User corrections (highest weight - user explicitly fixed)
|
|
198
|
+
- **project-knowledge**: Project-specific info
|
|
199
|
+
- **tool-use**: Historical tool usage
|
|
200
|
+
|
|
201
|
+
## Important Notes
|
|
202
|
+
|
|
203
|
+
- **Multi-step search** is critical - don't just search once
|
|
204
|
+
- **Aggregate across searches** to get complete picture
|
|
205
|
+
- **Prioritize corrections** above everything (user explicitly said "no, do this")
|
|
206
|
+
- **Learn from failures** to avoid repeating mistakes
|
|
207
|
+
- **Apply successes** to similar future tasks
|
|
208
|
+
- You only provide CONTEXT - Claude Code makes final decisions and executes
|
|
209
|
+
|
|
210
|
+
## Learning Loop Reminder
|
|
211
|
+
|
|
212
|
+
Your job creates a **learning loop**:
|
|
213
|
+
```
|
|
214
|
+
User states preference ā You remember it
|
|
215
|
+
Claude tries approach ā User approves/corrects
|
|
216
|
+
You capture outcome ā Store as success/failure
|
|
217
|
+
Next similar task ā You recommend what worked, avoid what didn't
|
|
218
|
+
User never repeats themselves ā
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
This is the core value of Claude Recall.
|
package/README.md
CHANGED
|
@@ -8,30 +8,32 @@ Every time you start a new conversation with Claude, you're starting from scratc
|
|
|
8
8
|
|
|
9
9
|
## Key Features
|
|
10
10
|
|
|
11
|
-
### š§
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
11
|
+
### š§ Intelligent Learning Loop
|
|
12
|
+
- **Never repeat yourself** - State preferences once, Claude remembers forever
|
|
13
|
+
- **Learn from outcomes** - Automatically captures what worked and what didn't
|
|
14
|
+
- **Direct MCP search** - Fast, simple memory lookup (milliseconds, no agent overhead)
|
|
15
|
+
- **Automatic application** - Preferences and successful patterns applied without asking
|
|
16
|
+
- **Persistent across restarts** - Your learnings survive Claude Code restarts
|
|
15
17
|
|
|
16
18
|
### š Intelligent Capture
|
|
17
19
|
- **Automatic extraction** - Captures preferences, patterns, and important information from conversations
|
|
18
20
|
- **Categorized storage** - Organizes memories by type (preferences, project knowledge, corrections)
|
|
19
21
|
- **Priority-based** - More important or frequently used memories are prioritized
|
|
20
22
|
|
|
21
|
-
### ā” Advanced Features (v0.3.
|
|
22
|
-
- **MCP
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
23
|
+
### ā” Advanced Features (v0.3.2+)
|
|
24
|
+
- **Direct MCP calls** - Fast memory search without agent overhead (milliseconds)
|
|
25
|
+
- **Comprehensive search** - Single search finds preferences, successes, failures, and corrections
|
|
26
|
+
- **Outcome capture** - Stores what worked and what didn't for future learning
|
|
27
|
+
- **Learning loop** - Pre-action search ā Execute ā Post-action outcome ā Future tasks apply learnings
|
|
28
|
+
- **Optional agent** - Advanced context-manager agent available for complex workflows
|
|
29
|
+
- **Correction priority** - User corrections given highest priority (never repeat mistakes)
|
|
28
30
|
|
|
29
31
|
### š Privacy & Security First
|
|
30
32
|
- **100% Local** - All memories stored locally in SQLite (~/.claude-recall/)
|
|
31
33
|
- **No cloud sync** - Your data never leaves your machine
|
|
32
34
|
- **You own your data** - Export, view, or delete memories at any time
|
|
33
35
|
- **Zero telemetry** - No data collection or phone-home behavior
|
|
34
|
-
- **Security
|
|
36
|
+
- **Security audited** - Reviewed using `/security-review` command: No exposed secrets, SQL injection protection, 0 npm vulnerabilities
|
|
35
37
|
|
|
36
38
|
## Quick Start
|
|
37
39
|
|
|
@@ -49,58 +51,155 @@ For CLI access from anywhere:
|
|
|
49
51
|
npm install -g claude-recall@latest
|
|
50
52
|
```
|
|
51
53
|
|
|
52
|
-
**Note:** You can have both installations.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
- Use `mcp__claude-recall__search_memory` to check for stored preferences and project knowledge
|
|
57
|
-
- Memories include: coding preferences, file locations, project patterns, and team conventions
|
|
58
|
-
```
|
|
54
|
+
**Note:** You can have both installations. Installation automatically includes:
|
|
55
|
+
- `.claude/agents/context-manager.md` - Optional agent for complex workflows
|
|
56
|
+
- `.claude/CLAUDE.md` - Memory-first workflow with direct MCP search instructions
|
|
57
|
+
- MCP server configuration in `~/.claude.json`
|
|
59
58
|
|
|
60
59
|
After installation, verify with: `claude-recall --version` (or `npx claude-recall --version` for local installs)
|
|
61
60
|
|
|
62
|
-
##
|
|
61
|
+
## Updating Claude Recall
|
|
62
|
+
|
|
63
|
+
To update to the latest version and refresh the MCP server connection:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 1. Update the package
|
|
67
|
+
npm install -g claude-recall@latest
|
|
68
|
+
|
|
69
|
+
# 2. Remove the old MCP server configuration
|
|
70
|
+
claude mcp remove claude-recall
|
|
71
|
+
|
|
72
|
+
# 3. Re-add the MCP server
|
|
73
|
+
claude mcp add --transport stdio claude-recall -- claude-recall mcp start
|
|
74
|
+
|
|
75
|
+
# 4. Verify it's configured
|
|
76
|
+
claude mcp list
|
|
77
|
+
|
|
78
|
+
# 5. Restart Claude Code to apply changes
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Note:** Always restart Claude Code after updating the MCP server configuration.
|
|
82
|
+
|
|
83
|
+
## Verifying Claude Recall is Working
|
|
84
|
+
|
|
85
|
+
To confirm claude-recall is active in your Claude Code session:
|
|
86
|
+
|
|
87
|
+
**1. Check MCP Server Status**
|
|
88
|
+
```bash
|
|
89
|
+
claude mcp list
|
|
90
|
+
```
|
|
91
|
+
Should show `claude-recall` in the list of active servers.
|
|
92
|
+
|
|
93
|
+
**2. Ask Claude to Search Memories**
|
|
94
|
+
Simply ask: "Search my memories for [anything]" - Claude should be able to call the search tool.
|
|
95
|
+
|
|
96
|
+
**3. Check Available MCP Tools**
|
|
97
|
+
Ask Claude: "What MCP tools do you have access to?" - Claude should list tools starting with `mcp__claude-recall__` including:
|
|
98
|
+
- `mcp__claude-recall__store_memory`
|
|
99
|
+
- `mcp__claude-recall__retrieve_memory`
|
|
100
|
+
- `mcp__claude-recall__search`
|
|
63
101
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
4. **Injects** context so Claude remembers your preferences
|
|
102
|
+
**4. Store and Retrieve a Test Memory**
|
|
103
|
+
```
|
|
104
|
+
You: "Remember that I prefer testing with Jest"
|
|
105
|
+
Claude: [Should call store_memory tool]
|
|
69
106
|
|
|
70
|
-
|
|
107
|
+
You: "What testing framework do I prefer?"
|
|
108
|
+
Claude: [Should search memories and find Jest]
|
|
71
109
|
```
|
|
72
|
-
You: "I prefer TypeScript with strict mode for all my projects"
|
|
73
|
-
[Claude Recall automatically stores this preference]
|
|
74
110
|
|
|
75
|
-
|
|
111
|
+
**5. Check Stats via CLI**
|
|
112
|
+
```bash
|
|
113
|
+
claude-recall stats
|
|
114
|
+
```
|
|
115
|
+
This shows if memories are being stored.
|
|
76
116
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
117
|
+
**6. Check Running Process**
|
|
118
|
+
```bash
|
|
119
|
+
ps aux | grep claude-recall
|
|
120
|
+
```
|
|
121
|
+
Should show the MCP server process running.
|
|
122
|
+
|
|
123
|
+
## How It Works
|
|
124
|
+
|
|
125
|
+
Claude Recall implements an **intelligent learning loop** that ensures you never repeat yourself:
|
|
126
|
+
|
|
127
|
+
### The Learning Loop
|
|
128
|
+
|
|
129
|
+
1. **Store Preferences**: When you express preferences, they're stored in SQLite
|
|
130
|
+
2. **Pre-Action Search**: Before tasks, Claude searches memories directly (fast MCP call)
|
|
131
|
+
3. **Find Context**: Search finds preferences + successes + failures + corrections automatically
|
|
132
|
+
4. **Execute with Context**: Claude applies what was learned
|
|
133
|
+
5. **Capture Outcome**: After task, Claude stores success/failure/correction
|
|
134
|
+
6. **Future Application**: Next similar task automatically applies learnings
|
|
135
|
+
|
|
136
|
+
### Complete Example: Never Repeat Yourself
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
=== First Time: State Preference ===
|
|
140
|
+
You: "I prefer Python for scripts"
|
|
141
|
+
[Claude stores preference via MCP]
|
|
142
|
+
|
|
143
|
+
=== Second Time: First Use ===
|
|
144
|
+
You: "Create a test script"
|
|
145
|
+
[Claude searches: mcp__claude-recall__search("scripts python test")]
|
|
146
|
+
[Search finds: "I prefer Python for scripts"]
|
|
147
|
+
[Claude creates test.py using Python]
|
|
148
|
+
You: "Perfect!"
|
|
149
|
+
[Claude stores: "Created test script with Python - SUCCESS"]
|
|
150
|
+
|
|
151
|
+
=== Third Time: Automatic Application ===
|
|
152
|
+
You: "Create a build script"
|
|
153
|
+
[Claude searches: mcp__claude-recall__search("scripts build python")]
|
|
154
|
+
[Search finds: "I prefer Python" + "test.py SUCCESS"]
|
|
155
|
+
[Claude creates build.py automatically - learned pattern!]
|
|
156
|
+
You: *Don't have to repeat preference - it was learned!*
|
|
157
|
+
|
|
158
|
+
=== Correction Loop ===
|
|
159
|
+
You: "No, put scripts in scripts/ directory not root"
|
|
160
|
+
[Claude stores: "CORRECTION: Scripts in scripts/ directory" (highest priority)]
|
|
161
|
+
[Claude moves file immediately]
|
|
162
|
+
Next time: Search finds correction and applies automatically
|
|
80
163
|
```
|
|
81
164
|
|
|
82
165
|
## Memory Types
|
|
83
166
|
|
|
84
|
-
|
|
167
|
+
Claude Recall stores different types of memories (sorted by priority):
|
|
168
|
+
|
|
169
|
+
### 1. Corrections (Highest Priority)
|
|
170
|
+
- User explicitly said "No, do this instead"
|
|
171
|
+
- Fixes to mistakes Claude made
|
|
172
|
+
- Override previous approaches
|
|
173
|
+
- **Example**: "CORRECTION: Tests in __tests__/ not tests/"
|
|
174
|
+
|
|
175
|
+
### 2. Preferences
|
|
85
176
|
- Coding style preferences (languages, frameworks, patterns)
|
|
86
177
|
- Tool preferences (testing frameworks, build tools)
|
|
87
178
|
- Workflow preferences (git conventions, file structures)
|
|
179
|
+
- **Example**: "I prefer TypeScript with strict mode"
|
|
180
|
+
|
|
181
|
+
### 3. Successes
|
|
182
|
+
- What worked in past tasks
|
|
183
|
+
- Approaches that user approved
|
|
184
|
+
- Validated patterns
|
|
185
|
+
- **Example**: "Created auth module with JWT tokens - SUCCESS"
|
|
88
186
|
|
|
89
|
-
###
|
|
187
|
+
### 4. Failures
|
|
188
|
+
- What didn't work and should be avoided
|
|
189
|
+
- Approaches that failed or were rejected
|
|
190
|
+
- Deprecated approaches
|
|
191
|
+
- **Example**: "Session-based auth failed, use JWT instead"
|
|
192
|
+
|
|
193
|
+
### 5. Project Knowledge
|
|
90
194
|
- Database configurations
|
|
91
195
|
- API patterns and endpoints
|
|
92
196
|
- Architecture decisions
|
|
93
197
|
- Dependencies and versions
|
|
94
198
|
|
|
95
|
-
###
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
### Corrections
|
|
101
|
-
- Learned from mistakes
|
|
102
|
-
- Updated patterns
|
|
103
|
-
- Deprecated approaches to avoid
|
|
199
|
+
### 6. Tool Use
|
|
200
|
+
- Historical tool execution
|
|
201
|
+
- Command patterns
|
|
202
|
+
- Workflow steps
|
|
104
203
|
|
|
105
204
|
## CLI Commands
|
|
106
205
|
|
|
@@ -213,9 +312,12 @@ npm --version
|
|
|
213
312
|
## Best Practices
|
|
214
313
|
|
|
215
314
|
1. **Be explicit about preferences** - Clear statements like "Always use..." or "Never..." are captured better
|
|
216
|
-
2. **
|
|
217
|
-
3. **
|
|
218
|
-
4. **
|
|
315
|
+
2. **Approve or correct** - Say "Good!" or "No, do this" after tasks to build the learning loop
|
|
316
|
+
3. **Trust the learning loop** - Direct MCP search finds preferences, successes, and failures instantly
|
|
317
|
+
4. **Correct mistakes immediately** - Corrections get highest priority and won't be repeated
|
|
318
|
+
5. **Review periodically** - Use `claude-recall stats` to see what's being remembered
|
|
319
|
+
6. **Export important memories** - Backup critical preferences with `claude-recall export`
|
|
320
|
+
7. **Fast and simple** - Direct MCP calls work great for most tasks (agent is optional)
|
|
219
321
|
|
|
220
322
|
## Acknowledgements
|
|
221
323
|
|
|
@@ -98,7 +98,18 @@ class ClaudeRecallCLI {
|
|
|
98
98
|
const results = this.memoryService.search(query);
|
|
99
99
|
const topResults = results.slice(0, limit);
|
|
100
100
|
if (options.json) {
|
|
101
|
-
|
|
101
|
+
// Format for hook consumption - include relevance_score field
|
|
102
|
+
const formattedResults = topResults.map((result) => ({
|
|
103
|
+
key: result.key,
|
|
104
|
+
value: result.value,
|
|
105
|
+
type: result.type,
|
|
106
|
+
timestamp: result.timestamp,
|
|
107
|
+
relevance_score: result.score, // Rename score to relevance_score for hooks
|
|
108
|
+
access_count: result.access_count,
|
|
109
|
+
project_id: result.project_id,
|
|
110
|
+
file_path: result.file_path
|
|
111
|
+
}));
|
|
112
|
+
console.log(JSON.stringify(formattedResults, null, 2));
|
|
102
113
|
return;
|
|
103
114
|
}
|
|
104
115
|
if (topResults.length === 0) {
|
|
@@ -248,6 +259,54 @@ class ClaudeRecallCLI {
|
|
|
248
259
|
console.log('\n');
|
|
249
260
|
this.logger.info('CLI', 'Status displayed');
|
|
250
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Store a memory directly from CLI
|
|
264
|
+
*/
|
|
265
|
+
async store(content, options) {
|
|
266
|
+
try {
|
|
267
|
+
const type = options.type || 'preference';
|
|
268
|
+
const confidence = options.confidence || 0.8;
|
|
269
|
+
// Parse metadata if provided
|
|
270
|
+
let metadata = {};
|
|
271
|
+
if (options.metadata) {
|
|
272
|
+
try {
|
|
273
|
+
metadata = JSON.parse(options.metadata);
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
console.error('ā Invalid metadata JSON');
|
|
277
|
+
process.exit(1);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Generate unique key
|
|
281
|
+
const key = `cli_${type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
282
|
+
// Store memory
|
|
283
|
+
this.memoryService.store({
|
|
284
|
+
key,
|
|
285
|
+
value: {
|
|
286
|
+
content,
|
|
287
|
+
confidence,
|
|
288
|
+
source: 'cli',
|
|
289
|
+
...metadata,
|
|
290
|
+
timestamp: Date.now()
|
|
291
|
+
},
|
|
292
|
+
type,
|
|
293
|
+
context: {
|
|
294
|
+
timestamp: Date.now()
|
|
295
|
+
},
|
|
296
|
+
relevanceScore: confidence
|
|
297
|
+
});
|
|
298
|
+
console.log(`ā
Memory stored successfully`);
|
|
299
|
+
console.log(` ID: ${key}`);
|
|
300
|
+
console.log(` Type: ${type}`);
|
|
301
|
+
console.log(` Confidence: ${confidence}`);
|
|
302
|
+
this.logger.info('CLI', 'Memory stored', { key, type, confidence });
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
console.error('ā Store failed:', error);
|
|
306
|
+
this.logger.error('CLI', 'Store failed', error);
|
|
307
|
+
process.exit(1);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
251
310
|
truncateContent(content) {
|
|
252
311
|
const str = typeof content === 'string' ? content : JSON.stringify(content);
|
|
253
312
|
const maxLength = 100;
|
|
@@ -404,6 +463,22 @@ async function main() {
|
|
|
404
463
|
await cli.status();
|
|
405
464
|
process.exit(0);
|
|
406
465
|
});
|
|
466
|
+
// Store command
|
|
467
|
+
program
|
|
468
|
+
.command('store <content>')
|
|
469
|
+
.description('Store a memory directly')
|
|
470
|
+
.option('-t, --type <type>', 'Memory type (default: preference)', 'preference')
|
|
471
|
+
.option('-c, --confidence <score>', 'Confidence score 0.0-1.0 (default: 0.8)', '0.8')
|
|
472
|
+
.option('-m, --metadata <json>', 'Additional metadata as JSON string')
|
|
473
|
+
.action(async (content, options) => {
|
|
474
|
+
const cli = new ClaudeRecallCLI(program.opts());
|
|
475
|
+
await cli.store(content, {
|
|
476
|
+
type: options.type,
|
|
477
|
+
confidence: parseFloat(options.confidence),
|
|
478
|
+
metadata: options.metadata
|
|
479
|
+
});
|
|
480
|
+
process.exit(0);
|
|
481
|
+
});
|
|
407
482
|
// Test memory search command
|
|
408
483
|
program
|
|
409
484
|
.command('test-memory-search')
|
package/dist/core/retrieval.js
CHANGED
|
@@ -24,13 +24,25 @@ class MemoryRetrieval {
|
|
|
24
24
|
// Combine keywords and significant words
|
|
25
25
|
return [...new Set([...keywords, ...words])];
|
|
26
26
|
}
|
|
27
|
-
findRelevant(context) {
|
|
27
|
+
findRelevant(context, sortBy = 'relevance') {
|
|
28
28
|
// Extract keywords from query if provided
|
|
29
29
|
if (context.query && !context.keywords) {
|
|
30
30
|
context.keywords = this.extractKeywords(context.query);
|
|
31
31
|
}
|
|
32
32
|
// Use enhanced search that looks for keywords in memory values
|
|
33
33
|
const candidates = this.storage.searchByContext(context);
|
|
34
|
+
if (sortBy === 'timestamp') {
|
|
35
|
+
// Sort by timestamp DESC (newest first)
|
|
36
|
+
const sorted = candidates
|
|
37
|
+
.map(memory => ({
|
|
38
|
+
...memory,
|
|
39
|
+
score: 1.0 // Placeholder score for timestamp sorting
|
|
40
|
+
}))
|
|
41
|
+
.sort((a, b) => (b.timestamp || 0) - (a.timestamp || 0));
|
|
42
|
+
// Return top results (no limit applied here, caller controls via slice)
|
|
43
|
+
return sorted;
|
|
44
|
+
}
|
|
45
|
+
// Default: relevance sorting
|
|
34
46
|
// Score and prioritize by memory type
|
|
35
47
|
const scored = candidates
|
|
36
48
|
.map(memory => ({
|
|
@@ -94,7 +94,7 @@ class MemoryTools {
|
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
name: 'mcp__claude-recall__retrieve_memory',
|
|
97
|
-
description: 'Get relevant memories by ID or
|
|
97
|
+
description: 'Get relevant memories by ID, query, or recency. Use sortBy="timestamp" for most recent memories.',
|
|
98
98
|
inputSchema: {
|
|
99
99
|
type: 'object',
|
|
100
100
|
properties: {
|
|
@@ -109,6 +109,11 @@ class MemoryTools {
|
|
|
109
109
|
limit: {
|
|
110
110
|
type: 'number',
|
|
111
111
|
description: 'Maximum number of memories to return (default: 10)'
|
|
112
|
+
},
|
|
113
|
+
sortBy: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
enum: ['relevance', 'timestamp'],
|
|
116
|
+
description: 'Sort order: "relevance" (default, keyword-based) or "timestamp" (newest first)'
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
},
|
|
@@ -241,7 +246,20 @@ class MemoryTools {
|
|
|
241
246
|
}
|
|
242
247
|
async handleRetrieveMemory(input, context) {
|
|
243
248
|
try {
|
|
244
|
-
|
|
249
|
+
let { query, id, limit = 10, sortBy } = input;
|
|
250
|
+
// Smart detection: Auto-detect timestamp sorting from query keywords
|
|
251
|
+
if (!sortBy && query) {
|
|
252
|
+
const timeKeywords = ['recent', 'latest', 'newest', 'last', 'new'];
|
|
253
|
+
const lowerQuery = query.toLowerCase();
|
|
254
|
+
if (timeKeywords.some(kw => lowerQuery.includes(kw))) {
|
|
255
|
+
sortBy = 'timestamp';
|
|
256
|
+
this.logger.debug('MemoryTools', 'Auto-detected timestamp sorting', { query });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Default to relevance sorting
|
|
260
|
+
if (!sortBy) {
|
|
261
|
+
sortBy = 'relevance';
|
|
262
|
+
}
|
|
245
263
|
if (id) {
|
|
246
264
|
// Retrieve specific memory by ID
|
|
247
265
|
const memory = this.memoryService.retrieve(id);
|
|
@@ -258,8 +276,8 @@ class MemoryTools {
|
|
|
258
276
|
};
|
|
259
277
|
}
|
|
260
278
|
if (query) {
|
|
261
|
-
// Search for relevant memories
|
|
262
|
-
const results = this.memoryService.search(query);
|
|
279
|
+
// Search for relevant memories with sort option
|
|
280
|
+
const results = this.memoryService.search(query, sortBy);
|
|
263
281
|
const limitedResults = results.slice(0, limit);
|
|
264
282
|
return {
|
|
265
283
|
memories: limitedResults.map(r => ({
|
|
@@ -267,7 +285,8 @@ class MemoryTools {
|
|
|
267
285
|
relevanceScore: r.score
|
|
268
286
|
})),
|
|
269
287
|
count: limitedResults.length,
|
|
270
|
-
totalFound: results.length
|
|
288
|
+
totalFound: results.length,
|
|
289
|
+
sortBy
|
|
271
290
|
};
|
|
272
291
|
}
|
|
273
292
|
// Get recent memories from context
|
|
@@ -275,14 +294,15 @@ class MemoryTools {
|
|
|
275
294
|
sessionId: context.sessionId,
|
|
276
295
|
projectId: context.projectId,
|
|
277
296
|
timestamp: context.timestamp
|
|
278
|
-
});
|
|
297
|
+
}, sortBy);
|
|
279
298
|
const limitedResults = contextResults.slice(0, limit);
|
|
280
299
|
return {
|
|
281
300
|
memories: limitedResults.map(r => ({
|
|
282
301
|
...r,
|
|
283
302
|
relevanceScore: r.score
|
|
284
303
|
})),
|
|
285
|
-
count: limitedResults.length
|
|
304
|
+
count: limitedResults.length,
|
|
305
|
+
sortBy
|
|
286
306
|
};
|
|
287
307
|
}
|
|
288
308
|
catch (error) {
|
package/dist/services/memory.js
CHANGED
|
@@ -79,7 +79,7 @@ class MemoryService {
|
|
|
79
79
|
/**
|
|
80
80
|
* Find relevant memories based on context
|
|
81
81
|
*/
|
|
82
|
-
findRelevant(context) {
|
|
82
|
+
findRelevant(context, sortBy = 'relevance') {
|
|
83
83
|
try {
|
|
84
84
|
const retrievalContext = {
|
|
85
85
|
project_id: context.projectId || this.config.getProjectId(),
|
|
@@ -90,12 +90,13 @@ class MemoryService {
|
|
|
90
90
|
query: context.query,
|
|
91
91
|
keywords: context.keywords
|
|
92
92
|
};
|
|
93
|
-
const memories = this.retrieval.findRelevant(retrievalContext);
|
|
93
|
+
const memories = this.retrieval.findRelevant(retrievalContext, sortBy);
|
|
94
94
|
this.logger.logRetrieval(context.query || 'context-based', memories.length, {
|
|
95
95
|
projectId: retrievalContext.project_id,
|
|
96
96
|
filePath: retrievalContext.file_path,
|
|
97
97
|
tool: retrievalContext.tool,
|
|
98
|
-
keywords: retrievalContext.keywords
|
|
98
|
+
keywords: retrievalContext.keywords,
|
|
99
|
+
sortBy
|
|
99
100
|
});
|
|
100
101
|
return memories;
|
|
101
102
|
}
|
|
@@ -107,16 +108,17 @@ class MemoryService {
|
|
|
107
108
|
/**
|
|
108
109
|
* Search memories by keyword
|
|
109
110
|
*/
|
|
110
|
-
search(query) {
|
|
111
|
+
search(query, sortBy = 'relevance') {
|
|
111
112
|
try {
|
|
112
113
|
// Use findRelevant with query context for better semantic matching
|
|
113
114
|
const context = {
|
|
114
115
|
query: query,
|
|
115
116
|
timestamp: Date.now()
|
|
116
117
|
};
|
|
117
|
-
const results = this.retrieval.findRelevant(context);
|
|
118
|
+
const results = this.retrieval.findRelevant(context, sortBy);
|
|
118
119
|
this.logger.logRetrieval(query, results.length, {
|
|
119
|
-
searchType: 'contextual'
|
|
120
|
+
searchType: 'contextual',
|
|
121
|
+
sortBy
|
|
120
122
|
});
|
|
121
123
|
return results;
|
|
122
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-recall",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Persistent memory for Claude Code with automatic capture via hooks and MCP server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/",
|
|
11
|
+
".claude/",
|
|
11
12
|
"scripts/postinstall.js",
|
|
12
13
|
"scripts/postinstall-claude-md.js",
|
|
13
14
|
"README.md",
|
package/scripts/postinstall.js
CHANGED
|
@@ -58,9 +58,13 @@ try {
|
|
|
58
58
|
|
|
59
59
|
console.log('\nš Installation complete!');
|
|
60
60
|
console.log(' Claude Recall MCP server is now configured.');
|
|
61
|
-
console.log(' Restart
|
|
62
|
-
console.log('\nš” Tip: Claude Recall works automatically
|
|
63
|
-
console.log('
|
|
61
|
+
console.log(' Restart your terminal to activate the memory system.');
|
|
62
|
+
console.log('\nš” Tip: Claude Recall works automatically with the memory-researcher agent.');
|
|
63
|
+
console.log(' Claude Code will search memories before file operations and decisions.');
|
|
64
|
+
console.log('\nšÆ Agent Integration:');
|
|
65
|
+
console.log(' The memory-researcher agent is available in .claude/agents/');
|
|
66
|
+
console.log(' Claude Code reads .claude/CLAUDE.md for memory-first instructions.');
|
|
67
|
+
console.log('\n Your memories persist across conversations and restarts.\n');
|
|
64
68
|
|
|
65
69
|
} catch (error) {
|
|
66
70
|
console.error('ā Error updating ~/.claude.json:', error.message);
|