@withone/mem 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/bin/mem +36 -0
- package/dist/cli.d.ts +28 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +656 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +94 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +461 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +14 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +514 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +100 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +60 -0
- package/skills/context/SKILL.md +168 -0
- package/skills/remember/SKILL.md +144 -0
- package/skills/search/SKILL.md +137 -0
- package/skills/setup/SKILL.md +162 -0
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@withone/mem",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Memory for AI agents. Simple, fast, works anywhere.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"memory",
|
|
8
|
+
"agents",
|
|
9
|
+
"supabase",
|
|
10
|
+
"knowledge",
|
|
11
|
+
"graph",
|
|
12
|
+
"mem",
|
|
13
|
+
"claude-code",
|
|
14
|
+
"llm",
|
|
15
|
+
"vector-search"
|
|
16
|
+
],
|
|
17
|
+
"author": "Moe Katib",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/withoneai/mem"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://mem.now",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"bin": {
|
|
28
|
+
"mem": "./bin/mem"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"bin",
|
|
33
|
+
"skills"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"dev": "tsc --watch",
|
|
38
|
+
"lint": "eslint src",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"prepublishOnly": "npm run build"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@clack/prompts": "^1.0.0",
|
|
44
|
+
"@supabase/supabase-js": "^2.49.1",
|
|
45
|
+
"commander": "^12.1.0",
|
|
46
|
+
"openai": "^4.77.0",
|
|
47
|
+
"picocolors": "^1.1.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^22.10.5",
|
|
51
|
+
"typescript": "^5.7.2",
|
|
52
|
+
"vitest": "^2.1.8"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mem-context
|
|
3
|
+
description: Get startup context from Mem memory
|
|
4
|
+
triggers:
|
|
5
|
+
- "get context"
|
|
6
|
+
- "load memory"
|
|
7
|
+
- "what's important"
|
|
8
|
+
- "session context"
|
|
9
|
+
- "/context"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Context Skill
|
|
13
|
+
|
|
14
|
+
Get the most relevant memories for session startup.
|
|
15
|
+
|
|
16
|
+
## Quick Command
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Default: top 20 most relevant
|
|
20
|
+
mem context
|
|
21
|
+
|
|
22
|
+
# Limit results
|
|
23
|
+
mem context -n 10
|
|
24
|
+
|
|
25
|
+
# Filter by types
|
|
26
|
+
mem context -t decision,preference
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## How Relevance Works
|
|
30
|
+
|
|
31
|
+
Context uses a **relevance score** combining:
|
|
32
|
+
- **Weight (40%)**: Explicit importance (1-10, set with `weight` command)
|
|
33
|
+
- **Access frequency (30%)**: How often the memory is accessed/returned
|
|
34
|
+
- **Recency (30%)**: How recently it was accessed (decays over ~30 days)
|
|
35
|
+
|
|
36
|
+
This means:
|
|
37
|
+
- High-weight items always surface (preferences, critical decisions)
|
|
38
|
+
- Frequently useful items rise naturally
|
|
39
|
+
- Old, unused items fade away
|
|
40
|
+
|
|
41
|
+
## When to Use
|
|
42
|
+
|
|
43
|
+
### Session Startup
|
|
44
|
+
|
|
45
|
+
Run at the start of each conversation to load important context:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
mem context
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This returns preferences, active decisions, recent context.
|
|
52
|
+
|
|
53
|
+
### Before Major Work
|
|
54
|
+
|
|
55
|
+
Before starting significant tasks:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
mem context -t decision,preference
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Gets relevant decisions and preferences that should guide your work.
|
|
62
|
+
|
|
63
|
+
### Meeting Prep
|
|
64
|
+
|
|
65
|
+
Before discussing a specific topic:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mem search "topic name"
|
|
69
|
+
mem context -n 10
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Context Output
|
|
73
|
+
|
|
74
|
+
Results show:
|
|
75
|
+
- **Score**: Relevance score (higher = more relevant)
|
|
76
|
+
- **Type**: Memory type
|
|
77
|
+
- **Weight**: Explicit importance setting
|
|
78
|
+
- **Accesses**: How many times accessed
|
|
79
|
+
- **Content preview**
|
|
80
|
+
|
|
81
|
+
Example:
|
|
82
|
+
```
|
|
83
|
+
Startup Context (by relevance):
|
|
84
|
+
|
|
85
|
+
[0.823] preference: Code style preferences
|
|
86
|
+
weight=9, accesses=15
|
|
87
|
+
Prefers TypeScript over JavaScript. Use ESLint...
|
|
88
|
+
|
|
89
|
+
[0.756] decision: API Architecture
|
|
90
|
+
weight=8, accesses=7
|
|
91
|
+
Using REST not GraphQL. Rationale: simpler...
|
|
92
|
+
|
|
93
|
+
[0.534] note: Current sprint goals
|
|
94
|
+
weight=5, accesses=3
|
|
95
|
+
Focus on MCP integration and documentation...
|
|
96
|
+
|
|
97
|
+
20 memories
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Managing Relevance
|
|
101
|
+
|
|
102
|
+
### Increase Relevance
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Set high weight (always surfaces)
|
|
106
|
+
mem weight <id> 9
|
|
107
|
+
|
|
108
|
+
# Accessing via search naturally increases relevance
|
|
109
|
+
mem search "relevant query"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Decrease Relevance
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Archive when done (excludes from context)
|
|
116
|
+
mem archive <id>
|
|
117
|
+
|
|
118
|
+
# Reset access count (lets it fade naturally)
|
|
119
|
+
mem flush <id>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Restore
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Bring back archived memory
|
|
126
|
+
mem unarchive <id>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Lifecycle Pattern
|
|
130
|
+
|
|
131
|
+
1. **Add**: New memory enters with default weight (5)
|
|
132
|
+
2. **Surface**: Frequently accessed = higher relevance
|
|
133
|
+
3. **Fade**: Unused items decay in relevance over time
|
|
134
|
+
4. **Archive**: When done, archive to exclude from context
|
|
135
|
+
5. **Flush**: If over-accessed temporarily, flush to let it decay
|
|
136
|
+
|
|
137
|
+
## Integration Pattern
|
|
138
|
+
|
|
139
|
+
For AI agents, a typical session start:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# 1. Load context
|
|
143
|
+
mem context -n 15
|
|
144
|
+
|
|
145
|
+
# 2. Note any gaps or outdated info
|
|
146
|
+
# 3. Update weights if needed
|
|
147
|
+
mem weight <stale_id> 3
|
|
148
|
+
mem weight <important_id> 9
|
|
149
|
+
|
|
150
|
+
# 4. Archive completed items
|
|
151
|
+
mem archive <done_id>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Related Commands
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Search for specific content
|
|
158
|
+
mem search "query"
|
|
159
|
+
|
|
160
|
+
# Get specific memory
|
|
161
|
+
mem get <id>
|
|
162
|
+
|
|
163
|
+
# Set importance
|
|
164
|
+
mem weight <id> <1-10>
|
|
165
|
+
|
|
166
|
+
# Archive
|
|
167
|
+
mem archive <id>
|
|
168
|
+
```
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: remember
|
|
3
|
+
description: Save information to Mem memory
|
|
4
|
+
triggers:
|
|
5
|
+
- "remember this"
|
|
6
|
+
- "remember that"
|
|
7
|
+
- "save this"
|
|
8
|
+
- "note that"
|
|
9
|
+
- "don't forget"
|
|
10
|
+
- "/remember"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Remember Skill
|
|
14
|
+
|
|
15
|
+
Save information to Mem memory for future retrieval.
|
|
16
|
+
|
|
17
|
+
## Quick Commands
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Basic - add any type of memory
|
|
21
|
+
mem add note '{"content": "The actual information to remember"}'
|
|
22
|
+
|
|
23
|
+
# With topic for organization
|
|
24
|
+
mem add note '{"content": "...", "topic": "Meeting Notes"}'
|
|
25
|
+
|
|
26
|
+
# Decision with high importance
|
|
27
|
+
mem add decision '{"topic": "API Design", "content": "Use REST not GraphQL because...", "weight": 9}'
|
|
28
|
+
|
|
29
|
+
# Preference (usually high weight)
|
|
30
|
+
mem add preference '{"content": "Prefers TypeScript over JavaScript", "weight": 8}'
|
|
31
|
+
|
|
32
|
+
# Link two memories
|
|
33
|
+
mem link <id1> related_to <id2> --bi # bidirectional
|
|
34
|
+
mem link <id1> supersedes <id2> # directional (old -> new)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Workflow
|
|
38
|
+
|
|
39
|
+
### 1. Determine What to Save
|
|
40
|
+
|
|
41
|
+
Extract the key information. Ask if unclear:
|
|
42
|
+
- What exactly should be remembered?
|
|
43
|
+
- Is this a fact, preference, decision, or context?
|
|
44
|
+
- How important is it? (1=low, 5=default, 10=always surface)
|
|
45
|
+
|
|
46
|
+
### 2. Choose Type and Weight
|
|
47
|
+
|
|
48
|
+
| Type | When to Use | Typical Weight |
|
|
49
|
+
|------|-------------|----------------|
|
|
50
|
+
| `note` | General information, context | 5 |
|
|
51
|
+
| `decision` | Choices made with rationale | 7-9 |
|
|
52
|
+
| `preference` | How user likes things done | 8-10 |
|
|
53
|
+
| `insight` | Learnings, realizations | 6-8 |
|
|
54
|
+
| `context` | Background info about people/projects | 5-7 |
|
|
55
|
+
|
|
56
|
+
Weight guide:
|
|
57
|
+
- **1-3**: Nice to know, can fade
|
|
58
|
+
- **4-6**: Standard importance (default is 5)
|
|
59
|
+
- **7-8**: Important, should surface often
|
|
60
|
+
- **9-10**: Critical, always surface
|
|
61
|
+
|
|
62
|
+
### 3. Execute Command
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
mem add <type> '{"content": "...", "weight": N}'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 4. Confirm What Was Saved
|
|
69
|
+
|
|
70
|
+
Tell the user:
|
|
71
|
+
- What was saved
|
|
72
|
+
- The ID (for reference)
|
|
73
|
+
- The weight if non-default
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
**User:** "Remember that I prefer TypeScript over Python for new projects"
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
mem add preference '{"content": "Prefers TypeScript over Python for new projects", "weight": 8}'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Response: "Saved preference with weight 8. ID: abc123"
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
**User:** "We decided to use Supabase for the database because of real-time features"
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
mem add decision '{"topic": "Database Choice", "content": "Using Supabase for database. Rationale: real-time features, built-in auth, and good DX.", "weight": 9}'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Response: "Saved decision about database choice with weight 9."
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
**User:** "Note that Jane prefers async communication"
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
mem add context '{"content": "Jane prefers async communication (Slack/email over calls)", "about": "Jane"}'
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Response: "Noted context about Jane."
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
**User:** "This supersedes our earlier decision about X"
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
mem add decision '{"topic": "X", "content": "New approach..."}'
|
|
111
|
+
# Then link to old decision
|
|
112
|
+
mem link <new_id> supersedes <old_id>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Auto-Remember Triggers
|
|
116
|
+
|
|
117
|
+
Proactively save when you notice:
|
|
118
|
+
- **Preferences**: "I like X", "I prefer Y", "Don't do Z"
|
|
119
|
+
- **Decisions**: "Let's go with A", "We decided B"
|
|
120
|
+
- **Context**: Background about people, companies, relationships
|
|
121
|
+
- **Learnings**: "This worked because...", "Next time we should..."
|
|
122
|
+
- **Corrections**: "Actually, it's X not Y"
|
|
123
|
+
|
|
124
|
+
When auto-remembering, briefly note what you're saving:
|
|
125
|
+
"I'll remember that you prefer TypeScript for new projects."
|
|
126
|
+
|
|
127
|
+
## Other Useful Commands
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Update existing memory
|
|
131
|
+
mem update <id> '{"content": "Updated content"}'
|
|
132
|
+
|
|
133
|
+
# Archive when no longer relevant
|
|
134
|
+
mem archive <id>
|
|
135
|
+
|
|
136
|
+
# Change importance
|
|
137
|
+
mem weight <id> 9
|
|
138
|
+
|
|
139
|
+
# View a memory
|
|
140
|
+
mem get <id>
|
|
141
|
+
|
|
142
|
+
# List by type
|
|
143
|
+
mem list decision
|
|
144
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mem-search
|
|
3
|
+
description: Search Mem memory
|
|
4
|
+
triggers:
|
|
5
|
+
- "search memory"
|
|
6
|
+
- "what do I know about"
|
|
7
|
+
- "find in memory"
|
|
8
|
+
- "mem"
|
|
9
|
+
- "/search"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Search Skill
|
|
13
|
+
|
|
14
|
+
Search the Mem memory system using hybrid (semantic + keyword) search.
|
|
15
|
+
|
|
16
|
+
## Quick Commands
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Basic search
|
|
20
|
+
mem search "query"
|
|
21
|
+
|
|
22
|
+
# Filter by type
|
|
23
|
+
mem search "query" -t decision
|
|
24
|
+
|
|
25
|
+
# More results
|
|
26
|
+
mem search "query" -n 20
|
|
27
|
+
|
|
28
|
+
# Combine options
|
|
29
|
+
mem search "API design" -t decision -n 5
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## How Search Works
|
|
33
|
+
|
|
34
|
+
Mem uses **hybrid search** that combines:
|
|
35
|
+
- **Semantic similarity** (70% weight): Finds conceptually related content
|
|
36
|
+
- **Keyword matching** (30% weight): Finds exact term matches
|
|
37
|
+
|
|
38
|
+
This means searching "database choice" will find memories about "Supabase selection" even if those exact words aren't used.
|
|
39
|
+
|
|
40
|
+
## When to Search
|
|
41
|
+
|
|
42
|
+
**Always search for:**
|
|
43
|
+
- Names, companies, or projects you don't recognize
|
|
44
|
+
- Past decisions about a topic before making new ones
|
|
45
|
+
- Context before meetings or conversations
|
|
46
|
+
- Background on technical approaches
|
|
47
|
+
|
|
48
|
+
**Search patterns:**
|
|
49
|
+
- "What did we decide about X?"
|
|
50
|
+
- "What do I know about [person/company]?"
|
|
51
|
+
- "Any notes on [topic]?"
|
|
52
|
+
- "Previous decisions about [area]"
|
|
53
|
+
|
|
54
|
+
## Examples
|
|
55
|
+
|
|
56
|
+
**User:** "What did we decide about the database?"
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
mem search "database decision" -t decision
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
**User:** "Who is Jane?"
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
mem search "Jane"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
**User:** "Any notes on MCP integration?"
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mem search "MCP integration"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
**User:** "What are my preferences for code style?"
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
mem search "code style preference" -t preference
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Search Output
|
|
87
|
+
|
|
88
|
+
Results show:
|
|
89
|
+
- **Score**: Combined relevance (0-1, higher = more relevant)
|
|
90
|
+
- **Type**: The memory type
|
|
91
|
+
- **Content preview**: First 100 chars of content
|
|
92
|
+
|
|
93
|
+
Example output:
|
|
94
|
+
```
|
|
95
|
+
[0.847] decision: Database Choice
|
|
96
|
+
Using Supabase for database. Rationale: real-time features...
|
|
97
|
+
|
|
98
|
+
[0.634] note: Database evaluation notes
|
|
99
|
+
Compared PostgreSQL, MongoDB, and Supabase...
|
|
100
|
+
|
|
101
|
+
2 results
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Access Tracking
|
|
105
|
+
|
|
106
|
+
Search automatically increments the access count for returned results. This means:
|
|
107
|
+
- Frequently accessed memories rise in relevance
|
|
108
|
+
- Unused memories naturally fade over time
|
|
109
|
+
|
|
110
|
+
If you don't want to affect relevance scores, the `search` function accepts `trackAccess: false` (available via TypeScript API).
|
|
111
|
+
|
|
112
|
+
## Proactive Search
|
|
113
|
+
|
|
114
|
+
When encountering unfamiliar references:
|
|
115
|
+
|
|
116
|
+
1. **Search first** before saying "I don't have information"
|
|
117
|
+
2. **Report findings** if results found
|
|
118
|
+
3. **Note gaps** if no results
|
|
119
|
+
|
|
120
|
+
Example:
|
|
121
|
+
> "I searched for 'Acme Corp' and found: They're a potential customer Jane introduced. Last meeting was Jan 15."
|
|
122
|
+
|
|
123
|
+
Or:
|
|
124
|
+
> "I searched for 'Project Apollo' but found no matches in memory."
|
|
125
|
+
|
|
126
|
+
## Related Commands
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Get full context for session startup
|
|
130
|
+
mem context
|
|
131
|
+
|
|
132
|
+
# Get a specific memory by ID
|
|
133
|
+
mem get <id>
|
|
134
|
+
|
|
135
|
+
# Get linked memories
|
|
136
|
+
mem linked <id>
|
|
137
|
+
```
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mem-setup
|
|
3
|
+
description: Set up Mem memory system with Supabase
|
|
4
|
+
triggers:
|
|
5
|
+
- "set up mem"
|
|
6
|
+
- "initialize memory"
|
|
7
|
+
- "install mem"
|
|
8
|
+
- "/mem-setup"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Mem Setup Skill
|
|
12
|
+
|
|
13
|
+
Guide the user through setting up Mem with Supabase.
|
|
14
|
+
|
|
15
|
+
## Prerequisites Check
|
|
16
|
+
|
|
17
|
+
First, verify the user has what they need:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Check Node.js version (need 18+)
|
|
21
|
+
node --version
|
|
22
|
+
|
|
23
|
+
# Check if mem is installed
|
|
24
|
+
npm list mem-memory 2>/dev/null || echo "Not installed"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Workflow
|
|
28
|
+
|
|
29
|
+
### Step 1: Install Mem
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install mem-memory
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or with a specific project:
|
|
36
|
+
```bash
|
|
37
|
+
cd your-project
|
|
38
|
+
npm install mem-memory
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Step 2: Create Supabase Project
|
|
42
|
+
|
|
43
|
+
If the user doesn't have a Supabase project:
|
|
44
|
+
|
|
45
|
+
1. Go to [supabase.com](https://supabase.com) and sign in
|
|
46
|
+
2. Click "New Project"
|
|
47
|
+
3. Note the project URL and service role key
|
|
48
|
+
|
|
49
|
+
### Step 3: Enable pgvector Extension
|
|
50
|
+
|
|
51
|
+
In Supabase SQL Editor, run:
|
|
52
|
+
|
|
53
|
+
```sql
|
|
54
|
+
CREATE EXTENSION IF NOT EXISTS vector;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This enables semantic search capabilities.
|
|
58
|
+
|
|
59
|
+
### Step 4: Configure Environment
|
|
60
|
+
|
|
61
|
+
Create a `.env` file in the project root:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
SUPABASE_URL=https://your-project.supabase.co
|
|
65
|
+
SUPABASE_SERVICE_KEY=your-service-role-key
|
|
66
|
+
OPENAI_API_KEY=your-openai-key # Optional, for semantic search
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Important:**
|
|
70
|
+
- Use the **service role key**, not the anon key (for server-side operations)
|
|
71
|
+
- The OpenAI key is optional but recommended for better search quality
|
|
72
|
+
|
|
73
|
+
### Step 5: Apply Schema
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx mem migrate
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This creates the `mem_records` and `mem_links` tables plus all the functions.
|
|
80
|
+
|
|
81
|
+
If the migration fails (some Supabase configs don't allow exec_sql), it will save the SQL to `mem-migration.sql`. Run that SQL manually in the Supabase SQL Editor.
|
|
82
|
+
|
|
83
|
+
### Step 6: Verify Setup
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Add a test memory
|
|
87
|
+
npx mem add note '{"content": "Test memory for setup verification"}'
|
|
88
|
+
|
|
89
|
+
# Search for it
|
|
90
|
+
npx mem search "test"
|
|
91
|
+
|
|
92
|
+
# Get context
|
|
93
|
+
npx mem context
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Step 7: Add to CLAUDE.md (for Claude Code users)
|
|
97
|
+
|
|
98
|
+
Add this snippet to your project's `CLAUDE.md`:
|
|
99
|
+
|
|
100
|
+
```markdown
|
|
101
|
+
## Memory System
|
|
102
|
+
|
|
103
|
+
This project uses Mem for memory. Run context at session start:
|
|
104
|
+
|
|
105
|
+
\`\`\`bash
|
|
106
|
+
npx mem context
|
|
107
|
+
\`\`\`
|
|
108
|
+
|
|
109
|
+
### Quick Commands
|
|
110
|
+
|
|
111
|
+
\`\`\`bash
|
|
112
|
+
# Add memory
|
|
113
|
+
npx mem add <type> '{"content": "..."}'
|
|
114
|
+
|
|
115
|
+
# Search
|
|
116
|
+
npx mem search "query"
|
|
117
|
+
|
|
118
|
+
# Get context
|
|
119
|
+
npx mem context
|
|
120
|
+
|
|
121
|
+
# Set importance (1-10)
|
|
122
|
+
npx mem weight <id> 9
|
|
123
|
+
|
|
124
|
+
# Archive when done
|
|
125
|
+
npx mem archive <id>
|
|
126
|
+
\`\`\`
|
|
127
|
+
|
|
128
|
+
### When to Remember
|
|
129
|
+
|
|
130
|
+
Save to memory when:
|
|
131
|
+
- User says "remember this", "note that", "save this"
|
|
132
|
+
- A decision is made with rationale
|
|
133
|
+
- A preference is expressed
|
|
134
|
+
- Important context is shared
|
|
135
|
+
- A lesson is learned
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Troubleshooting
|
|
139
|
+
|
|
140
|
+
### "SUPABASE_URL must be set"
|
|
141
|
+
|
|
142
|
+
Create a `.env` file with your Supabase credentials.
|
|
143
|
+
|
|
144
|
+
### "pgvector extension not found"
|
|
145
|
+
|
|
146
|
+
Run `CREATE EXTENSION IF NOT EXISTS vector;` in the Supabase SQL Editor.
|
|
147
|
+
|
|
148
|
+
### "Failed to generate embedding"
|
|
149
|
+
|
|
150
|
+
Check that `OPENAI_API_KEY` is set. Semantic search requires OpenAI embeddings.
|
|
151
|
+
If you don't have an OpenAI key, search will fall back to keyword-only mode.
|
|
152
|
+
|
|
153
|
+
### Migration fails
|
|
154
|
+
|
|
155
|
+
Copy the SQL from `mem-migration.sql` and run it directly in Supabase SQL Editor.
|
|
156
|
+
|
|
157
|
+
## Done!
|
|
158
|
+
|
|
159
|
+
Once setup is complete, use the other Mem skills:
|
|
160
|
+
- `/remember` - Add memories
|
|
161
|
+
- `/search` - Search memories
|
|
162
|
+
- `/context` - Get startup context
|