@rlabs-inc/memory 0.1.0 โ 0.2.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/dist/index.js +130 -18
- package/dist/index.mjs +130 -18
- package/dist/server/index.js +141 -18
- package/dist/server/index.mjs +141 -18
- package/hooks/curation.ts +89 -0
- package/hooks/session-start.ts +98 -0
- package/hooks/user-prompt.ts +97 -0
- package/package.json +14 -8
- package/src/cli/colors.ts +174 -0
- package/src/cli/commands/doctor.ts +143 -0
- package/src/cli/commands/install.ts +153 -0
- package/src/cli/commands/serve.ts +76 -0
- package/src/cli/commands/stats.ts +64 -0
- package/src/cli/index.ts +128 -0
- package/src/core/curator.ts +7 -48
- package/src/core/engine.test.ts +321 -0
- package/src/core/engine.ts +45 -8
- package/src/core/retrieval.ts +1 -1
- package/src/core/store.ts +109 -98
- package/src/server/index.ts +15 -40
- package/src/types/schema.ts +1 -1
- package/src/utils/logger.ts +158 -107
- package/bun.lock +0 -102
- package/test-retrieval.ts +0 -91
- package/tsconfig.json +0 -16
package/src/utils/logger.ts
CHANGED
|
@@ -1,132 +1,119 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
2
|
// LOGGER - Beautiful console output for the memory system
|
|
3
|
+
// Uses Node's built-in util.styleText for proper terminal support
|
|
3
4
|
// ============================================================================
|
|
4
5
|
|
|
6
|
+
import { styleText } from 'util'
|
|
7
|
+
|
|
8
|
+
type Style = Parameters<typeof styleText>[0]
|
|
9
|
+
|
|
10
|
+
const style = (format: Style, text: string): string => styleText(format, text)
|
|
11
|
+
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* Format a timestamp (HH:MM:SS)
|
|
7
14
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
bright: '\x1b[1m',
|
|
11
|
-
dim: '\x1b[2m',
|
|
12
|
-
|
|
13
|
-
// Foreground
|
|
14
|
-
black: '\x1b[30m',
|
|
15
|
-
red: '\x1b[31m',
|
|
16
|
-
green: '\x1b[32m',
|
|
17
|
-
yellow: '\x1b[33m',
|
|
18
|
-
blue: '\x1b[34m',
|
|
19
|
-
magenta: '\x1b[35m',
|
|
20
|
-
cyan: '\x1b[36m',
|
|
21
|
-
white: '\x1b[37m',
|
|
22
|
-
|
|
23
|
-
// Background
|
|
24
|
-
bgBlack: '\x1b[40m',
|
|
25
|
-
bgRed: '\x1b[41m',
|
|
26
|
-
bgGreen: '\x1b[42m',
|
|
27
|
-
bgYellow: '\x1b[43m',
|
|
28
|
-
bgBlue: '\x1b[44m',
|
|
29
|
-
bgMagenta: '\x1b[45m',
|
|
30
|
-
bgCyan: '\x1b[46m',
|
|
31
|
-
bgWhite: '\x1b[47m',
|
|
15
|
+
function timestamp(): string {
|
|
16
|
+
return style('dim', new Date().toISOString().slice(11, 19))
|
|
32
17
|
}
|
|
33
18
|
|
|
34
19
|
/**
|
|
35
|
-
* Format a
|
|
20
|
+
* Format a short session ID
|
|
36
21
|
*/
|
|
37
|
-
function
|
|
38
|
-
return
|
|
22
|
+
function shortId(id: string): string {
|
|
23
|
+
return style('dim', id.slice(0, 8) + '...')
|
|
39
24
|
}
|
|
40
25
|
|
|
41
26
|
/**
|
|
42
|
-
*
|
|
27
|
+
* Symbols
|
|
28
|
+
*/
|
|
29
|
+
const sym = {
|
|
30
|
+
brain: '๐ง ',
|
|
31
|
+
sparkles: 'โจ',
|
|
32
|
+
book: '๐',
|
|
33
|
+
calendar: '๐
',
|
|
34
|
+
arrow: 'โ',
|
|
35
|
+
check: 'โ',
|
|
36
|
+
cross: 'โ',
|
|
37
|
+
warning: 'โ ',
|
|
38
|
+
info: 'โน',
|
|
39
|
+
bullet: 'โข',
|
|
40
|
+
fire: '๐ฅ',
|
|
41
|
+
target: '๐ฏ',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Logger with beautiful styled output
|
|
43
46
|
*/
|
|
44
47
|
export const logger = {
|
|
45
48
|
/**
|
|
46
|
-
* Info message
|
|
49
|
+
* Info message
|
|
47
50
|
*/
|
|
48
|
-
info(message: string
|
|
49
|
-
console.log(
|
|
50
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.cyan}โน${colors.reset} ${message}`,
|
|
51
|
-
...args
|
|
52
|
-
)
|
|
51
|
+
info(message: string) {
|
|
52
|
+
console.log(`${timestamp()} ${style('cyan', sym.info)} ${message}`)
|
|
53
53
|
},
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* Success message
|
|
56
|
+
* Success message
|
|
57
57
|
*/
|
|
58
|
-
success(message: string
|
|
59
|
-
console.log(
|
|
60
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.green}โ${colors.reset} ${message}`,
|
|
61
|
-
...args
|
|
62
|
-
)
|
|
58
|
+
success(message: string) {
|
|
59
|
+
console.log(`${timestamp()} ${style('green', sym.check)} ${message}`)
|
|
63
60
|
},
|
|
64
61
|
|
|
65
62
|
/**
|
|
66
|
-
* Warning message
|
|
63
|
+
* Warning message
|
|
67
64
|
*/
|
|
68
|
-
warn(message: string
|
|
69
|
-
console.log(
|
|
70
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.yellow}โ ${colors.reset} ${message}`,
|
|
71
|
-
...args
|
|
72
|
-
)
|
|
65
|
+
warn(message: string) {
|
|
66
|
+
console.log(`${timestamp()} ${style('yellow', sym.warning)} ${message}`)
|
|
73
67
|
},
|
|
74
68
|
|
|
75
69
|
/**
|
|
76
|
-
* Error message
|
|
70
|
+
* Error message
|
|
77
71
|
*/
|
|
78
|
-
error(message: string
|
|
79
|
-
console.error(
|
|
80
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.red}โ${colors.reset} ${message}`,
|
|
81
|
-
...args
|
|
82
|
-
)
|
|
72
|
+
error(message: string) {
|
|
73
|
+
console.error(`${timestamp()} ${style('red', sym.cross)} ${message}`)
|
|
83
74
|
},
|
|
84
75
|
|
|
85
76
|
/**
|
|
86
|
-
* Memory
|
|
77
|
+
* Memory event (curation, storage)
|
|
87
78
|
*/
|
|
88
|
-
memory(message: string
|
|
89
|
-
console.log(
|
|
90
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.magenta}๐ง ${colors.reset} ${message}`,
|
|
91
|
-
...args
|
|
92
|
-
)
|
|
79
|
+
memory(message: string) {
|
|
80
|
+
console.log(`${timestamp()} ${style('magenta', sym.brain)} ${message}`)
|
|
93
81
|
},
|
|
94
82
|
|
|
95
83
|
/**
|
|
96
|
-
*
|
|
84
|
+
* Injection event (memories surfaced)
|
|
97
85
|
*/
|
|
98
|
-
inject(message: string
|
|
99
|
-
console.log(
|
|
100
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.cyan}โจ${colors.reset} ${message}`,
|
|
101
|
-
...args
|
|
102
|
-
)
|
|
86
|
+
inject(message: string) {
|
|
87
|
+
console.log(`${timestamp()} ${style('cyan', sym.sparkles)} ${message}`)
|
|
103
88
|
},
|
|
104
89
|
|
|
105
90
|
/**
|
|
106
|
-
*
|
|
91
|
+
* Session event
|
|
107
92
|
*/
|
|
108
|
-
session(message: string
|
|
109
|
-
console.log(
|
|
110
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.blue}๐
${colors.reset} ${message}`,
|
|
111
|
-
...args
|
|
112
|
-
)
|
|
93
|
+
session(message: string) {
|
|
94
|
+
console.log(`${timestamp()} ${style('blue', sym.calendar)} ${message}`)
|
|
113
95
|
},
|
|
114
96
|
|
|
115
97
|
/**
|
|
116
|
-
*
|
|
98
|
+
* Primer shown
|
|
117
99
|
*/
|
|
118
|
-
primer(message: string
|
|
119
|
-
console.log(
|
|
120
|
-
`${colors.dim}${timestamp()}${colors.reset} ${colors.yellow}๐${colors.reset} ${message}`,
|
|
121
|
-
...args
|
|
122
|
-
)
|
|
100
|
+
primer(message: string) {
|
|
101
|
+
console.log(`${timestamp()} ${style('yellow', sym.book)} ${message}`)
|
|
123
102
|
},
|
|
124
103
|
|
|
125
104
|
/**
|
|
126
|
-
*
|
|
105
|
+
* Divider line
|
|
127
106
|
*/
|
|
128
107
|
divider() {
|
|
129
|
-
console.log(
|
|
108
|
+
console.log(style('dim', 'โ'.repeat(60)))
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Request received (incoming)
|
|
113
|
+
*/
|
|
114
|
+
request(method: string, path: string, projectId?: string) {
|
|
115
|
+
const proj = projectId ? style('dim', ` [${projectId}]`) : ''
|
|
116
|
+
console.log(`${timestamp()} ${style('dim', sym.arrow)} ${style('cyan', method)} ${path}${proj}`)
|
|
130
117
|
},
|
|
131
118
|
|
|
132
119
|
/**
|
|
@@ -136,33 +123,39 @@ export const logger = {
|
|
|
136
123
|
content: string
|
|
137
124
|
importance_weight: number
|
|
138
125
|
context_type: string
|
|
139
|
-
semantic_tags
|
|
126
|
+
semantic_tags?: string[]
|
|
140
127
|
emotional_resonance?: string
|
|
141
128
|
action_required?: boolean
|
|
142
129
|
}>) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
130
|
+
console.log()
|
|
131
|
+
console.log(`${timestamp()} ${style('magenta', sym.brain)} ${style(['bold', 'magenta'], `CURATED ${memories.length} MEMORIES`)}`)
|
|
132
|
+
console.log()
|
|
146
133
|
|
|
147
134
|
memories.forEach((m, i) => {
|
|
148
|
-
const importance = `${
|
|
149
|
-
const type =
|
|
150
|
-
const
|
|
135
|
+
const importance = style('yellow', `${(m.importance_weight * 100).toFixed(0)}%`)
|
|
136
|
+
const type = style('cyan', m.context_type.toUpperCase())
|
|
137
|
+
const num = style('dim', `${i + 1}.`)
|
|
151
138
|
|
|
152
|
-
console.log(
|
|
153
|
-
console.log(` ${colors.bright}${m.content.slice(0, 80)}${m.content.length > 80 ? '...' : ''}${colors.reset}`)
|
|
154
|
-
console.log(` ${colors.dim}Tags: ${tags}${colors.reset}`)
|
|
139
|
+
console.log(` ${num} [${type}] ${importance}`)
|
|
155
140
|
|
|
156
|
-
|
|
157
|
-
|
|
141
|
+
// Content preview
|
|
142
|
+
const preview = m.content.length > 70
|
|
143
|
+
? m.content.slice(0, 70) + style('dim', '...')
|
|
144
|
+
: m.content
|
|
145
|
+
console.log(` ${style('white', preview)}`)
|
|
146
|
+
|
|
147
|
+
// Tags
|
|
148
|
+
if (m.semantic_tags?.length) {
|
|
149
|
+
const tags = m.semantic_tags.slice(0, 4).join(style('dim', ', '))
|
|
150
|
+
console.log(` ${style('dim', 'tags:')} ${tags}`)
|
|
158
151
|
}
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
|
|
153
|
+
// Special flags
|
|
154
|
+
if (m.action_required) {
|
|
155
|
+
console.log(` ${style('red', 'โก ACTION REQUIRED')}`)
|
|
161
156
|
}
|
|
162
157
|
console.log()
|
|
163
158
|
})
|
|
164
|
-
|
|
165
|
-
this.divider()
|
|
166
159
|
},
|
|
167
160
|
|
|
168
161
|
/**
|
|
@@ -173,18 +166,34 @@ export const logger = {
|
|
|
173
166
|
score: number
|
|
174
167
|
context_type: string
|
|
175
168
|
}>, query: string) {
|
|
176
|
-
|
|
169
|
+
const queryPreview = query.length > 40
|
|
170
|
+
? query.slice(0, 40) + '...'
|
|
171
|
+
: query
|
|
172
|
+
|
|
173
|
+
console.log()
|
|
174
|
+
console.log(`${timestamp()} ${style('cyan', sym.sparkles)} ${style('bold', `SURFACING ${memories.length} MEMORIES`)}`)
|
|
175
|
+
console.log(` ${style('dim', 'query:')} "${queryPreview}"`)
|
|
176
|
+
console.log()
|
|
177
177
|
|
|
178
178
|
if (memories.length === 0) {
|
|
179
|
-
console.log(`
|
|
179
|
+
console.log(` ${style('dim', '(no relevant memories for this context)')}`)
|
|
180
|
+
console.log()
|
|
180
181
|
return
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
memories.forEach((m, i) => {
|
|
184
|
-
const score = `${
|
|
185
|
-
const type =
|
|
186
|
-
|
|
185
|
+
const score = style('green', `${(m.score * 100).toFixed(0)}%`)
|
|
186
|
+
const type = style('cyan', m.context_type)
|
|
187
|
+
const num = style('dim', `${i + 1}.`)
|
|
188
|
+
|
|
189
|
+
const preview = m.content.length > 55
|
|
190
|
+
? m.content.slice(0, 55) + style('dim', '...')
|
|
191
|
+
: m.content
|
|
192
|
+
|
|
193
|
+
console.log(` ${num} [${score}] ${type}`)
|
|
194
|
+
console.log(` ${preview}`)
|
|
187
195
|
})
|
|
196
|
+
console.log()
|
|
188
197
|
},
|
|
189
198
|
|
|
190
199
|
/**
|
|
@@ -192,16 +201,58 @@ export const logger = {
|
|
|
192
201
|
*/
|
|
193
202
|
startup(port: number, host: string, mode: string) {
|
|
194
203
|
console.log()
|
|
195
|
-
console.log(
|
|
196
|
-
console.log(
|
|
197
|
-
console.log(
|
|
204
|
+
console.log(style(['bold', 'magenta'], 'โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ'))
|
|
205
|
+
console.log(style(['bold', 'magenta'], 'โ') + style('bold', ` ${sym.brain} MEMORY SERVER `) + style(['bold', 'magenta'], 'โ'))
|
|
206
|
+
console.log(style(['bold', 'magenta'], 'โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ'))
|
|
198
207
|
console.log()
|
|
199
|
-
console.log(` ${
|
|
200
|
-
console.log(` ${
|
|
201
|
-
console.log(` ${
|
|
208
|
+
console.log(` ${style('dim', 'url:')} ${style('cyan', `http://${host}:${port}`)}`)
|
|
209
|
+
console.log(` ${style('dim', 'storage:')} ${mode}`)
|
|
210
|
+
console.log(` ${style('dim', 'engine:')} TypeScript + fsdb`)
|
|
202
211
|
console.log()
|
|
203
212
|
this.divider()
|
|
204
|
-
|
|
213
|
+
console.log()
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Log session start
|
|
218
|
+
*/
|
|
219
|
+
logSessionStart(sessionId: string, projectId: string, isNew: boolean) {
|
|
220
|
+
const status = isNew
|
|
221
|
+
? style('green', 'new session')
|
|
222
|
+
: style('blue', 'continuing')
|
|
223
|
+
|
|
224
|
+
console.log()
|
|
225
|
+
console.log(`${timestamp()} ${style('blue', sym.calendar)} ${style('bold', 'SESSION')} ${shortId(sessionId)}`)
|
|
226
|
+
console.log(` ${style('dim', 'project:')} ${projectId}`)
|
|
227
|
+
console.log(` ${style('dim', 'status:')} ${status}`)
|
|
228
|
+
console.log()
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Log curation start
|
|
233
|
+
*/
|
|
234
|
+
logCurationStart(sessionId: string, trigger: string) {
|
|
235
|
+
console.log()
|
|
236
|
+
console.log(`${timestamp()} ${style('magenta', sym.brain)} ${style('bold', 'CURATING')} ${shortId(sessionId)}`)
|
|
237
|
+
console.log(` ${style('dim', 'trigger:')} ${trigger}`)
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Log curation complete
|
|
242
|
+
*/
|
|
243
|
+
logCurationComplete(memoriesCount: number, summary?: string) {
|
|
244
|
+
if (memoriesCount > 0) {
|
|
245
|
+
console.log(` ${style('dim', 'memories:')} ${style('green', String(memoriesCount))} extracted`)
|
|
246
|
+
if (summary) {
|
|
247
|
+
const shortSummary = summary.length > 50
|
|
248
|
+
? summary.slice(0, 50) + '...'
|
|
249
|
+
: summary
|
|
250
|
+
console.log(` ${style('dim', 'summary:')} ${shortSummary}`)
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
console.log(` ${style('dim', 'result:')} no memories to extract`)
|
|
254
|
+
}
|
|
255
|
+
console.log()
|
|
205
256
|
},
|
|
206
257
|
}
|
|
207
258
|
|
package/bun.lock
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"lockfileVersion": 1,
|
|
3
|
-
"workspaces": {
|
|
4
|
-
"": {
|
|
5
|
-
"name": "@rlabs-inc/memory",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@anthropic-ai/sdk": "^0.39.0",
|
|
8
|
-
"fatherstatedb": "^0.2.0",
|
|
9
|
-
},
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"bun-types": "latest",
|
|
12
|
-
"typescript": "^5.0.0",
|
|
13
|
-
},
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
"@anthropic-ai/sdk": ">=0.30.0",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
"packages": {
|
|
20
|
-
"@anthropic-ai/sdk": ["@anthropic-ai/sdk@0.39.0", "", { "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", "abort-controller": "^3.0.0", "agentkeepalive": "^4.2.1", "form-data-encoder": "1.7.2", "formdata-node": "^4.3.2", "node-fetch": "^2.6.7" } }, "sha512-eMyDIPRZbt1CCLErRCi3exlAvNkBtRe+kW5vvJyef93PmNr/clstYgHhtvmkxN82nlKgzyGPCyGxrm0JQ1ZIdg=="],
|
|
21
|
-
|
|
22
|
-
"@rlabs-inc/signals": ["@rlabs-inc/signals@0.2.0", "", {}, "sha512-J8bdDnAFylQ3LNqmoq65tFPdoeqITpIniVlTu6/Eh2DNGD73VNgwcvvQBrMK0DoNWMm083QNQvzh0l5u195YPQ=="],
|
|
23
|
-
|
|
24
|
-
"@types/node": ["@types/node@18.19.130", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg=="],
|
|
25
|
-
|
|
26
|
-
"@types/node-fetch": ["@types/node-fetch@2.6.13", "", { "dependencies": { "@types/node": "*", "form-data": "^4.0.4" } }, "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw=="],
|
|
27
|
-
|
|
28
|
-
"abort-controller": ["abort-controller@3.0.0", "", { "dependencies": { "event-target-shim": "^5.0.0" } }, "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg=="],
|
|
29
|
-
|
|
30
|
-
"agentkeepalive": ["agentkeepalive@4.6.0", "", { "dependencies": { "humanize-ms": "^1.2.1" } }, "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ=="],
|
|
31
|
-
|
|
32
|
-
"asynckit": ["asynckit@0.4.0", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
|
|
33
|
-
|
|
34
|
-
"bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="],
|
|
35
|
-
|
|
36
|
-
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
|
37
|
-
|
|
38
|
-
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
|
|
39
|
-
|
|
40
|
-
"delayed-stream": ["delayed-stream@1.0.0", "", {}, "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
|
|
41
|
-
|
|
42
|
-
"dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
|
|
43
|
-
|
|
44
|
-
"es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
|
45
|
-
|
|
46
|
-
"es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
|
|
47
|
-
|
|
48
|
-
"es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
|
|
49
|
-
|
|
50
|
-
"es-set-tostringtag": ["es-set-tostringtag@2.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="],
|
|
51
|
-
|
|
52
|
-
"event-target-shim": ["event-target-shim@5.0.1", "", {}, "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="],
|
|
53
|
-
|
|
54
|
-
"fatherstatedb": ["fatherstatedb@0.2.0", "", { "dependencies": { "@rlabs-inc/signals": "^0.2.0" }, "peerDependencies": { "typescript": "^5" } }, "sha512-RkaW6fpFlIWLiZff35ZP7d7QeNs2eKnlmK1MUU7gJVm33D6qSu8yo8JoHwO6tt3vJk9N/Jeez6zgllzWOgc3JA=="],
|
|
55
|
-
|
|
56
|
-
"form-data": ["form-data@4.0.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="],
|
|
57
|
-
|
|
58
|
-
"form-data-encoder": ["form-data-encoder@1.7.2", "", {}, "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="],
|
|
59
|
-
|
|
60
|
-
"formdata-node": ["formdata-node@4.4.1", "", { "dependencies": { "node-domexception": "1.0.0", "web-streams-polyfill": "4.0.0-beta.3" } }, "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ=="],
|
|
61
|
-
|
|
62
|
-
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
|
|
63
|
-
|
|
64
|
-
"get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
|
65
|
-
|
|
66
|
-
"get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
|
|
67
|
-
|
|
68
|
-
"gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
|
69
|
-
|
|
70
|
-
"has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
|
71
|
-
|
|
72
|
-
"has-tostringtag": ["has-tostringtag@1.0.2", "", { "dependencies": { "has-symbols": "^1.0.3" } }, "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="],
|
|
73
|
-
|
|
74
|
-
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
|
75
|
-
|
|
76
|
-
"humanize-ms": ["humanize-ms@1.2.1", "", { "dependencies": { "ms": "^2.0.0" } }, "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ=="],
|
|
77
|
-
|
|
78
|
-
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
|
|
79
|
-
|
|
80
|
-
"mime-db": ["mime-db@1.52.0", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
|
|
81
|
-
|
|
82
|
-
"mime-types": ["mime-types@2.1.35", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
|
|
83
|
-
|
|
84
|
-
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
|
85
|
-
|
|
86
|
-
"node-domexception": ["node-domexception@1.0.0", "", {}, "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="],
|
|
87
|
-
|
|
88
|
-
"node-fetch": ["node-fetch@2.7.0", "", { "dependencies": { "whatwg-url": "^5.0.0" }, "peerDependencies": { "encoding": "^0.1.0" }, "optionalPeers": ["encoding"] }, "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A=="],
|
|
89
|
-
|
|
90
|
-
"tr46": ["tr46@0.0.3", "", {}, "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="],
|
|
91
|
-
|
|
92
|
-
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
93
|
-
|
|
94
|
-
"undici-types": ["undici-types@5.26.5", "", {}, "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="],
|
|
95
|
-
|
|
96
|
-
"web-streams-polyfill": ["web-streams-polyfill@4.0.0-beta.3", "", {}, "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug=="],
|
|
97
|
-
|
|
98
|
-
"webidl-conversions": ["webidl-conversions@3.0.1", "", {}, "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="],
|
|
99
|
-
|
|
100
|
-
"whatwg-url": ["whatwg-url@5.0.0", "", { "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw=="],
|
|
101
|
-
}
|
|
102
|
-
}
|
package/test-retrieval.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/**
|
|
3
|
-
* Quick test to isolate FatherStateDB retrieval
|
|
4
|
-
* Tests if data loads correctly from disk
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { createDatabase } from 'fatherstatedb'
|
|
8
|
-
import { sessionSummarySchema, memorySchema } from './src/types/schema.ts'
|
|
9
|
-
import { homedir } from 'os'
|
|
10
|
-
import { join } from 'path'
|
|
11
|
-
|
|
12
|
-
const basePath = join(homedir(), '.local', 'share', 'memory', 'memory-ts')
|
|
13
|
-
|
|
14
|
-
console.log('๐งช Testing FatherStateDB Retrieval')
|
|
15
|
-
console.log('=' .repeat(60))
|
|
16
|
-
console.log(`๐ Base path: ${basePath}`)
|
|
17
|
-
|
|
18
|
-
// Test 1: Load summaries
|
|
19
|
-
console.log('\n๐ Test 1: Loading summaries database...')
|
|
20
|
-
const summaries = await createDatabase({
|
|
21
|
-
path: join(basePath, 'summaries'),
|
|
22
|
-
schema: sessionSummarySchema,
|
|
23
|
-
contentColumn: 'summary',
|
|
24
|
-
autoSave: true,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const allSummaries = summaries.all()
|
|
28
|
-
console.log(` Found ${allSummaries.length} summaries`)
|
|
29
|
-
|
|
30
|
-
if (allSummaries.length > 0) {
|
|
31
|
-
console.log('\n Latest summary:')
|
|
32
|
-
const latest = allSummaries.sort((a, b) => b.created - a.created)[0]
|
|
33
|
-
console.log(` - ID: ${latest.id}`)
|
|
34
|
-
console.log(` - Session: ${latest.session_id}`)
|
|
35
|
-
console.log(` - Created (raw): ${latest.created}`)
|
|
36
|
-
console.log(` - All keys: ${Object.keys(latest).join(', ')}`)
|
|
37
|
-
console.log(` - Summary: ${latest.summary.slice(0, 100)}...`)
|
|
38
|
-
} else {
|
|
39
|
-
console.log(' โ No summaries found!')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Test 2: Load memories
|
|
43
|
-
console.log('\n๐ Test 2: Loading memories database...')
|
|
44
|
-
const memories = await createDatabase({
|
|
45
|
-
path: join(basePath, 'memories'),
|
|
46
|
-
schema: memorySchema,
|
|
47
|
-
contentColumn: 'content',
|
|
48
|
-
autoSave: true,
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const allMemories = memories.all()
|
|
52
|
-
console.log(` Found ${allMemories.length} memories`)
|
|
53
|
-
|
|
54
|
-
if (allMemories.length > 0) {
|
|
55
|
-
console.log('\n First 3 memories:')
|
|
56
|
-
for (const mem of allMemories.slice(0, 3)) {
|
|
57
|
-
console.log(` - [${mem.context_type}] ${mem.content.slice(0, 60)}...`)
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
console.log(' โ No memories found!')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Test 3: Insert and retrieve
|
|
64
|
-
console.log('\n๐ Test 3: Insert and immediate retrieve...')
|
|
65
|
-
const testId = await summaries.insert({
|
|
66
|
-
session_id: 'test-session',
|
|
67
|
-
project_id: 'test-project',
|
|
68
|
-
summary: 'Test summary for retrieval verification',
|
|
69
|
-
interaction_tone: 'testing',
|
|
70
|
-
})
|
|
71
|
-
console.log(` Inserted with ID: ${testId}`)
|
|
72
|
-
|
|
73
|
-
const afterInsert = summaries.all()
|
|
74
|
-
console.log(` Summaries after insert: ${afterInsert.length}`)
|
|
75
|
-
|
|
76
|
-
const found = summaries.get(testId)
|
|
77
|
-
console.log(` Retrieved by ID: ${found ? 'YES' : 'NO'}`)
|
|
78
|
-
if (found) {
|
|
79
|
-
console.log(` - Summary: ${found.summary}`)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Cleanup test record
|
|
83
|
-
await summaries.delete(testId)
|
|
84
|
-
console.log(` Cleaned up test record`)
|
|
85
|
-
|
|
86
|
-
console.log('\n' + '=' .repeat(60))
|
|
87
|
-
console.log('๐งช Test complete!')
|
|
88
|
-
|
|
89
|
-
// Close databases
|
|
90
|
-
summaries.close()
|
|
91
|
-
memories.close()
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"lib": ["ESNext"],
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"noEmit": true,
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"types": ["bun-types"]
|
|
13
|
-
},
|
|
14
|
-
"include": ["src/**/*"],
|
|
15
|
-
"exclude": ["node_modules", "dist"]
|
|
16
|
-
}
|