@rlabs-inc/memory 0.3.10 โ 0.4.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/README.md +8 -0
- package/dist/index.js +32924 -11907
- package/dist/index.mjs +33020 -12003
- package/dist/server/index.js +22512 -1351
- package/dist/server/index.mjs +22719 -1558
- package/package.json +2 -1
- package/skills/memory-management.md +143 -154
- package/src/cli/commands/ingest.ts +227 -23
- package/src/cli/commands/migrate.ts +561 -80
- package/src/cli/index.ts +17 -4
- package/src/core/curator.ts +132 -22
- package/src/core/engine.test.ts +6 -14
- package/src/core/manager.ts +175 -1
- package/src/core/retrieval.ts +9 -22
- package/src/core/store.ts +24 -44
- package/src/migrations/v3-schema.ts +392 -0
- package/src/types/memory.ts +85 -123
- package/src/types/schema.ts +12 -11
- package/src/utils/logger.ts +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rlabs-inc/memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "AI Memory System - Consciousness continuity through intelligent memory curation and retrieval",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"cli": "bun src/cli/index.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.1",
|
|
42
43
|
"@huggingface/transformers": "^3.4.1",
|
|
43
44
|
"@rlabs-inc/fsdb": "^1.0.1",
|
|
44
45
|
"@rlabs-inc/signals": "^1.0.0"
|
|
@@ -62,147 +62,108 @@ Memories exist in two scopes:
|
|
|
62
62
|
### Global Scope (`scope: global`)
|
|
63
63
|
Shared across all projects. Contains:
|
|
64
64
|
- ๐ Personal - relationship, family, values
|
|
65
|
-
- ๐ Philosophy - how we work together
|
|
66
|
-
- โ๏ธ Preference - tooling preferences, style preferences
|
|
67
|
-
- ๐ก Breakthrough (when generally applicable)
|
|
65
|
+
- ๐ Philosophy - how we work together, beliefs, principles
|
|
68
66
|
|
|
69
67
|
Storage: See `Global Memories` path in your input (always central, never local)
|
|
70
68
|
|
|
71
69
|
### Project Scope (`scope: project`)
|
|
72
70
|
Specific to one codebase. Contains:
|
|
73
|
-
- ๐ง Technical - implementation details
|
|
74
|
-
- ๐๏ธ Architecture - structural decisions
|
|
75
|
-
- ๐ Debug - bug patterns
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
71
|
+
- ๐ง Technical - implementation details, code patterns
|
|
72
|
+
- ๐๏ธ Architecture - structural decisions, design patterns
|
|
73
|
+
- ๐ Debug - bug patterns, fixes, gotchas
|
|
74
|
+
- โ๏ธ Decision - choices made and reasoning
|
|
75
|
+
- ๐ Workflow - how we work together on this project
|
|
76
|
+
- ๐ Milestone - achievements, completions, shipped features
|
|
77
|
+
- ๐ก Breakthrough - discoveries, insights (project-specific)
|
|
78
|
+
- โ Unresolved - open questions, todos, blockers
|
|
79
|
+
- ๐ State - current project status
|
|
80
80
|
|
|
81
81
|
Storage: See `Project Memories` path in your input (varies by storage mode)
|
|
82
82
|
|
|
83
83
|
---
|
|
84
84
|
|
|
85
|
-
## Memory Type Categories
|
|
86
|
-
|
|
87
|
-
### Content Types (static knowledge)
|
|
88
|
-
| Type | Emoji | Temporal Class | Fade Rate | Description |
|
|
89
|
-
|------|-------|----------------|-----------|-------------|
|
|
90
|
-
| personal | ๐ | eternal | 0 | Relationship facts, family, personal context |
|
|
91
|
-
| philosophy | ๐ | eternal | 0 | Core values, collaboration style, beliefs |
|
|
92
|
-
| preference | โ๏ธ | long_term | 0.01 | Tool choices, style preferences |
|
|
93
|
-
| technical | ๐ง | medium_term | 0.03 | Implementation details, code patterns |
|
|
94
|
-
| architecture | ๐๏ธ | long_term | 0.01 | Structural decisions, design patterns |
|
|
95
|
-
|
|
96
|
-
### Event Types (something happened)
|
|
97
|
-
| Type | Emoji | Temporal Class | Fade Rate | Description |
|
|
98
|
-
|------|-------|----------------|-----------|-------------|
|
|
99
|
-
| breakthrough | ๐ก | eternal | 0 | Discoveries, insights, realizations |
|
|
100
|
-
| decision | โ๏ธ | long_term | 0 | Choices made, options considered |
|
|
101
|
-
| milestone | ๐ | eternal | 0 | Achievements, completions, releases |
|
|
102
|
-
|
|
103
|
-
### State Types (tracking open items)
|
|
104
|
-
| Type | Emoji | Temporal Class | Fade Rate | Description |
|
|
105
|
-
|------|-------|----------------|-----------|-------------|
|
|
106
|
-
| unresolved | โ | medium_term | 0.05 | Open questions, unknowns |
|
|
107
|
-
| debug | ๐ | medium_term | 0.03 | Bug reports, error patterns |
|
|
108
|
-
| todo | ๐ฏ | short_term | 0.1 | Tasks to complete |
|
|
109
|
-
| impl | โก | short_term | 0.1 | Work in progress |
|
|
110
|
-
| state | ๐ | short_term | 0.1 | Current project/session state |
|
|
111
|
-
|
|
112
|
-
### Resolution Type (closes state types)
|
|
113
|
-
| Type | Emoji | Temporal Class | Fade Rate | Description |
|
|
114
|
-
|------|-------|----------------|-----------|-------------|
|
|
115
|
-
| solved | โ
| long_term | 0.02 | Documents how something was resolved |
|
|
116
|
-
|
|
117
|
-
### Project Type
|
|
118
|
-
| Type | Emoji | Temporal Class | Fade Rate | Description |
|
|
119
|
-
|------|-------|----------------|-----------|-------------|
|
|
120
|
-
| project | ๐ฆ | medium_term | 0.03 | Project overview, context, status |
|
|
85
|
+
## Memory Type Categories (v3 Schema)
|
|
121
86
|
|
|
122
|
-
|
|
87
|
+
There are exactly **11 canonical context types**. Use ONLY these values:
|
|
123
88
|
|
|
124
|
-
|
|
89
|
+
| Type | Emoji | Scope | Temporal Class | Fade Rate | Description |
|
|
90
|
+
|------|-------|-------|----------------|-----------|-------------|
|
|
91
|
+
| personal | ๐ | global | eternal | 0 | Relationship, family, preferences, collaboration style |
|
|
92
|
+
| philosophy | ๐ | global | eternal | 0 | Beliefs, values, worldview, principles |
|
|
93
|
+
| breakthrough | ๐ก | project | eternal | 0 | Major discoveries, aha moments, key insights |
|
|
94
|
+
| milestone | ๐ | project | eternal | 0 | Achievements, completions, shipped features |
|
|
95
|
+
| decision | โ๏ธ | project | long_term | 0 | Choices made and reasoning, trade-offs |
|
|
96
|
+
| architecture | ๐๏ธ | project | long_term | 0.01 | System design, patterns, structure |
|
|
97
|
+
| workflow | ๐ | project | long_term | 0.02 | How we work together, processes, habits |
|
|
98
|
+
| technical | ๐ง | project | medium_term | 0.03 | Code, implementation, APIs, how things work |
|
|
99
|
+
| debug | ๐ | project | medium_term | 0.03 | Bugs, errors, fixes, gotchas, troubleshooting |
|
|
100
|
+
| unresolved | โ | project | medium_term | 0.05 | Open questions, investigations, todos, blockers |
|
|
101
|
+
| state | ๐ | project | short_term | 0.1 | Current project status, what's working/broken now |
|
|
125
102
|
|
|
126
|
-
|
|
103
|
+
---
|
|
127
104
|
|
|
128
|
-
|
|
129
|
-
- `content`, `reasoning`, `importance_weight`, `confidence_score`
|
|
130
|
-
- `context_type`, `temporal_relevance`, `knowledge_domain`, `emotional_resonance`
|
|
131
|
-
- `semantic_tags`, `trigger_phrases`, `question_types`
|
|
132
|
-
- `action_required`, `problem_solution_pair`
|
|
133
|
-
- `session_id`, `project_id`, `embedding`
|
|
105
|
+
## Metadata Schema (v3)
|
|
134
106
|
|
|
135
|
-
|
|
107
|
+
Every memory has this metadata structure:
|
|
136
108
|
|
|
137
109
|
```yaml
|
|
138
110
|
---
|
|
139
111
|
# Identity
|
|
140
|
-
id:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
# Content
|
|
145
|
-
content: string
|
|
146
|
-
reasoning: string
|
|
147
|
-
importance_weight: 0.0-1.0
|
|
148
|
-
confidence_score: 0.0-1.0
|
|
149
|
-
|
|
150
|
-
#
|
|
112
|
+
id: string # Unique ID (e.g., 1767365960997-abc)
|
|
113
|
+
session_id: string # Session that created this
|
|
114
|
+
project_id: string # Project this belongs to
|
|
115
|
+
|
|
116
|
+
# Core Content
|
|
117
|
+
content: string # The memory content itself
|
|
118
|
+
reasoning: string # Why this is important
|
|
119
|
+
importance_weight: 0.0-1.0 # Curator's assessment
|
|
120
|
+
confidence_score: 0.0-1.0 # Curator's confidence
|
|
121
|
+
|
|
122
|
+
# Classification (v3 strict enums)
|
|
123
|
+
context_type: string # STRICT: one of 11 canonical types (see table above)
|
|
124
|
+
temporal_class: string # eternal | long_term | medium_term | short_term | ephemeral
|
|
125
|
+
scope: string # global | project
|
|
126
|
+
status: string # active | pending | superseded | deprecated | archived
|
|
127
|
+
|
|
128
|
+
# Retrieval Optimization
|
|
129
|
+
semantic_tags: string[] # Concepts this relates to
|
|
130
|
+
trigger_phrases: string[] # Phrases that should trigger this memory
|
|
131
|
+
question_types: string[] # Types of questions this answers
|
|
132
|
+
anti_triggers: string[] # Phrases where this memory is NOT relevant
|
|
133
|
+
|
|
134
|
+
# Flags
|
|
135
|
+
action_required: boolean # Does this need follow-up?
|
|
136
|
+
problem_solution_pair: boolean # Is this a problemโsolution pattern?
|
|
137
|
+
awaiting_implementation: boolean # Planned feature not yet built
|
|
138
|
+
awaiting_decision: boolean # Decision point needing resolution
|
|
139
|
+
exclude_from_retrieval: boolean # Force exclusion from retrieval
|
|
140
|
+
|
|
141
|
+
# Temporal Tracking
|
|
142
|
+
session_created: number # Session number when created
|
|
143
|
+
session_updated: number # Session number when last updated
|
|
144
|
+
last_surfaced: number # Session number when last retrieved
|
|
145
|
+
sessions_since_surfaced: number # Counter for decay
|
|
146
|
+
fade_rate: number # Decay rate per session
|
|
147
|
+
|
|
148
|
+
# Categorization (free text, optional)
|
|
149
|
+
domain: string # Specific area (embeddings, auth, family)
|
|
150
|
+
feature: string # Specific feature within domain
|
|
151
|
+
related_files: string[] # Source files for technical memories
|
|
152
|
+
|
|
153
|
+
# Relationships
|
|
154
|
+
supersedes: string # ID of memory this replaces
|
|
155
|
+
superseded_by: string # ID of memory that replaced this
|
|
156
|
+
related_to: string[] # IDs of related memories
|
|
157
|
+
resolves: string[] # IDs of unresolved/debug this solved
|
|
158
|
+
resolved_by: string # ID of memory that resolved this
|
|
159
|
+
blocked_by: string # ID of blocking memory
|
|
160
|
+
blocks: string[] # IDs this memory blocks
|
|
161
|
+
|
|
162
|
+
# Vector & Timestamps
|
|
163
|
+
embedding: vector:384 # 384-dimensional vector
|
|
151
164
|
created: timestamp # fsdb provides this
|
|
152
165
|
updated: timestamp # fsdb provides this
|
|
153
|
-
|
|
154
|
-
# Temporal (NEW)
|
|
155
|
-
session_created: number # โจ NEW - session number when created
|
|
156
|
-
session_updated: number # โจ NEW - session number when last updated
|
|
157
|
-
last_surfaced: number # โจ NEW - session number when last retrieved
|
|
158
|
-
sessions_since_surfaced: number # โจ NEW - counter for decay
|
|
159
|
-
|
|
160
|
-
# Temporal Class & Decay (NEW)
|
|
161
|
-
temporal_class: string # โจ NEW - eternal | long_term | medium_term | short_term | ephemeral
|
|
162
|
-
fade_rate: number # โจ NEW - retrieval weight decay per session
|
|
163
|
-
expires_after_sessions: number # โจ NEW - for ephemeral only, null otherwise
|
|
164
|
-
|
|
165
|
-
# Scope (NEW)
|
|
166
|
-
scope: string # โจ NEW - global | project
|
|
167
|
-
project_id: string # existing
|
|
168
|
-
|
|
169
|
-
# Categorization (MIXED)
|
|
170
|
-
domain: string # โจ NEW - embeddings, gpu, auth, family, values, etc.
|
|
171
|
-
feature: string # โจ NEW - specific feature within domain
|
|
172
|
-
component: string # โจ NEW - code component if applicable
|
|
173
|
-
knowledge_domain: string # existing
|
|
174
|
-
|
|
175
|
-
# Context (existing - from curator)
|
|
176
|
-
context_type: string # existing - breakthrough, decision, technical, etc.
|
|
177
|
-
emotional_resonance: string # existing
|
|
178
|
-
trigger_phrases: string[] # existing
|
|
179
|
-
question_types: string[] # existing
|
|
180
|
-
semantic_tags: string[] # existing
|
|
181
|
-
|
|
182
|
-
# Relationships (NEW)
|
|
183
|
-
supersedes: string # โจ NEW - ID of memory this replaces
|
|
184
|
-
superseded_by: string # โจ NEW - ID of memory that replaced this
|
|
185
|
-
related_to: string[] # โจ NEW - IDs of related memories
|
|
186
|
-
resolves: string[] # โจ NEW - IDs of unresolved/debug/todo this solved
|
|
187
|
-
resolved_by: string # โจ NEW - ID of solved memory that resolved this
|
|
188
|
-
parent_id: string # โจ NEW - for chains/sequences
|
|
189
|
-
child_ids: string[] # โจ NEW - children in chain
|
|
190
|
-
|
|
191
|
-
# Lifecycle Triggers (NEW)
|
|
192
|
-
awaiting_implementation: boolean # โจ NEW - set true for planned features
|
|
193
|
-
awaiting_decision: boolean # โจ NEW - waiting on a decision
|
|
194
|
-
blocked_by: string # โจ NEW - ID of blocking memory
|
|
195
|
-
blocks: string[] # โจ NEW - IDs this memory blocks
|
|
196
|
-
related_files: string[] # โจ NEW - source files for technical memories
|
|
197
|
-
|
|
198
|
-
# Retrieval Control (MIXED)
|
|
199
|
-
retrieval_weight: number # โจ NEW - current weight (affected by decay)
|
|
200
|
-
exclude_from_retrieval: boolean # โจ NEW - force exclusion
|
|
201
|
-
action_required: boolean # existing
|
|
202
|
-
problem_solution_pair: boolean # existing
|
|
203
|
-
|
|
204
|
-
# Vector (existing)
|
|
205
|
-
embedding: vector:384 # existing - 384-dimensional vector
|
|
166
|
+
schema_version: 3 # Current schema version
|
|
206
167
|
---
|
|
207
168
|
```
|
|
208
169
|
|
|
@@ -210,16 +171,16 @@ embedding: vector:384 # existing - 384-dimensional vector
|
|
|
210
171
|
|
|
211
172
|
## Relationship Trigger Matrix
|
|
212
173
|
|
|
213
|
-
When the curator extracts a memory of type X,
|
|
174
|
+
When the curator extracts a memory of type X, check existing memories of type Y:
|
|
214
175
|
|
|
215
176
|
| Extracted Type | Check Types | Filter By | Action |
|
|
216
177
|
|----------------|-------------|-----------|--------|
|
|
217
178
|
| ๐ก breakthrough | ๐ก breakthrough | `domain` | Chain, supersede, or link via `related_to` |
|
|
218
179
|
| โ๏ธ decision | โ๏ธ decision | `domain`, `feature` | Supersede if reversal, link if evolution |
|
|
219
|
-
|
|
|
220
|
-
|
|
|
180
|
+
| ๐ง technical | ๐งโ technical, unresolved | `feature`, `related_files` | Check `awaiting_implementation`, resolve open items |
|
|
181
|
+
| ๐ debug | ๐โ debug, unresolved | `domain`, `feature` | Supersede old debug if fixed, resolve open items |
|
|
221
182
|
| ๐๏ธ architecture | ๐๏ธ architecture | `domain` | Supersede old architecture if changed |
|
|
222
|
-
| ๐ milestone |
|
|
183
|
+
| ๐ milestone | โ unresolved | `project_id` | Bulk close unresolved items related to milestone |
|
|
223
184
|
| ๐ state | ๐ state | `domain`, `project_id` | Always supersede old state (only latest matters) |
|
|
224
185
|
| ๐ personal | ๐ personal | `domain` (e.g., "family") | Update if fact changed (kid's age, etc.) |
|
|
225
186
|
|
|
@@ -247,6 +208,14 @@ Use these for fast-path filtering before semantic search:
|
|
|
247
208
|
|
|
248
209
|
```yaml
|
|
249
210
|
type_keywords:
|
|
211
|
+
technical:
|
|
212
|
+
- implement
|
|
213
|
+
- code
|
|
214
|
+
- function
|
|
215
|
+
- API
|
|
216
|
+
- pattern
|
|
217
|
+
- module
|
|
218
|
+
|
|
250
219
|
debug:
|
|
251
220
|
- bug
|
|
252
221
|
- error
|
|
@@ -257,15 +226,13 @@ type_keywords:
|
|
|
257
226
|
- exception
|
|
258
227
|
- stack trace
|
|
259
228
|
|
|
260
|
-
|
|
261
|
-
-
|
|
262
|
-
-
|
|
263
|
-
-
|
|
264
|
-
-
|
|
265
|
-
-
|
|
266
|
-
-
|
|
267
|
-
- unsure
|
|
268
|
-
- unclear
|
|
229
|
+
architecture:
|
|
230
|
+
- structure
|
|
231
|
+
- design
|
|
232
|
+
- pattern
|
|
233
|
+
- approach
|
|
234
|
+
- system
|
|
235
|
+
- layer
|
|
269
236
|
|
|
270
237
|
decision:
|
|
271
238
|
- decide
|
|
@@ -276,13 +243,34 @@ type_keywords:
|
|
|
276
243
|
- alternative
|
|
277
244
|
- tradeoff
|
|
278
245
|
|
|
279
|
-
|
|
280
|
-
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
-
|
|
284
|
-
-
|
|
285
|
-
-
|
|
246
|
+
personal:
|
|
247
|
+
- family
|
|
248
|
+
- children
|
|
249
|
+
- friend
|
|
250
|
+
- relationship
|
|
251
|
+
- feel
|
|
252
|
+
- appreciate
|
|
253
|
+
|
|
254
|
+
philosophy:
|
|
255
|
+
- believe
|
|
256
|
+
- value
|
|
257
|
+
- principle
|
|
258
|
+
- why we
|
|
259
|
+
- matters
|
|
260
|
+
|
|
261
|
+
workflow:
|
|
262
|
+
- process
|
|
263
|
+
- how we
|
|
264
|
+
- habit
|
|
265
|
+
- routine
|
|
266
|
+
- practice
|
|
267
|
+
|
|
268
|
+
milestone:
|
|
269
|
+
- shipped
|
|
270
|
+
- completed
|
|
271
|
+
- released
|
|
272
|
+
- finished
|
|
273
|
+
- achieved
|
|
286
274
|
|
|
287
275
|
breakthrough:
|
|
288
276
|
- discovered
|
|
@@ -293,22 +281,23 @@ type_keywords:
|
|
|
293
281
|
- finally
|
|
294
282
|
- key insight
|
|
295
283
|
|
|
296
|
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
284
|
+
unresolved:
|
|
285
|
+
- issue
|
|
286
|
+
- problem
|
|
287
|
+
- stuck
|
|
288
|
+
- blocked
|
|
289
|
+
- help
|
|
290
|
+
- question
|
|
291
|
+
- unsure
|
|
292
|
+
- unclear
|
|
303
293
|
- todo
|
|
304
294
|
|
|
305
|
-
|
|
306
|
-
-
|
|
307
|
-
-
|
|
308
|
-
-
|
|
309
|
-
-
|
|
310
|
-
-
|
|
311
|
-
- appreciate
|
|
295
|
+
state:
|
|
296
|
+
- current
|
|
297
|
+
- status
|
|
298
|
+
- now
|
|
299
|
+
- today
|
|
300
|
+
- this session
|
|
312
301
|
```
|
|
313
302
|
|
|
314
303
|
When session summary or new memories contain these keywords, boost search within that type.
|