@rekal/mem 0.0.0 → 0.0.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/dist/{db-BMh1OP4b.mjs → db-CHpq7OOi.mjs} +46 -15
- package/dist/db-CHpq7OOi.mjs.map +1 -0
- package/dist/doc-DnYN4jAU.mjs +2 -0
- package/dist/doc-DnYN4jAU.mjs.map +1 -0
- package/dist/{embed-rUMZxqed.mjs → embed-CZI5Dz1q.mjs} +3 -1
- package/dist/embed-CZI5Dz1q.mjs.map +1 -0
- package/dist/frecency-CiaqPIOy.mjs +30 -0
- package/dist/frecency-CiaqPIOy.mjs.map +1 -0
- package/dist/fs-DMp26Byo.mjs +2 -0
- package/dist/fs-DMp26Byo.mjs.map +1 -0
- package/dist/glob.d.mts +2 -1
- package/dist/glob.d.mts.map +1 -0
- package/dist/glob.mjs +2 -0
- package/dist/glob.mjs.map +1 -0
- package/dist/index.d.mts +21 -11
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -0
- package/dist/{llama-CT3dc9Cn.mjs → llama-CpNV7Lh9.mjs} +3 -1
- package/dist/llama-CpNV7Lh9.mjs.map +1 -0
- package/dist/{models-DFQSgBNr.mjs → models-Bo6czhQe.mjs} +5 -3
- package/dist/models-Bo6czhQe.mjs.map +1 -0
- package/dist/{openai-j2_2GM4J.mjs → openai-ALl6_YhI.mjs} +3 -1
- package/dist/openai-ALl6_YhI.mjs.map +1 -0
- package/dist/progress-B1JdNapX.mjs +2 -0
- package/dist/progress-B1JdNapX.mjs.map +1 -0
- package/dist/query-VFSpErTB.mjs +2 -0
- package/dist/query-VFSpErTB.mjs.map +1 -0
- package/dist/runtime.node-DlQPaGrV.mjs +2 -0
- package/dist/runtime.node-DlQPaGrV.mjs.map +1 -0
- package/dist/{search-BllHWtZF.mjs → search-DsVjB-9f.mjs} +2 -0
- package/dist/search-DsVjB-9f.mjs.map +1 -0
- package/dist/{store-DE7S35SS.mjs → store-I5nVEYxK.mjs} +10 -6
- package/dist/store-I5nVEYxK.mjs.map +1 -0
- package/dist/{transformers-CJ3QA2PK.mjs → transformers-Df56Nq9G.mjs} +3 -1
- package/dist/transformers-Df56Nq9G.mjs.map +1 -0
- package/dist/uri-CehXVDGB.mjs +2 -0
- package/dist/uri-CehXVDGB.mjs.map +1 -0
- package/dist/util-DNyrmcA3.mjs +2 -0
- package/dist/util-DNyrmcA3.mjs.map +1 -0
- package/dist/{vfs-CNQbkhsf.mjs → vfs-QUP1rnSI.mjs} +2 -0
- package/dist/vfs-QUP1rnSI.mjs.map +1 -0
- package/package.json +25 -25
- package/src/db.ts +73 -23
- package/src/frecency.ts +29 -46
- package/src/store.ts +13 -7
- package/foo.ts +0 -3
- package/foo2.ts +0 -20
- package/test/doc.test.ts +0 -61
- package/test/fixtures/ignore-test/keep.md +0 -0
- package/test/fixtures/ignore-test/skip.log +0 -0
- package/test/fixtures/ignore-test/sub/keep.md +0 -0
- package/test/fixtures/store/agent/index.md +0 -9
- package/test/fixtures/store/agent/lessons.md +0 -21
- package/test/fixtures/store/agent/soul.md +0 -28
- package/test/fixtures/store/agent/tools.md +0 -25
- package/test/fixtures/store/concepts/frecency.md +0 -30
- package/test/fixtures/store/concepts/index.md +0 -9
- package/test/fixtures/store/concepts/memory-coherence.md +0 -33
- package/test/fixtures/store/concepts/rag.md +0 -27
- package/test/fixtures/store/index.md +0 -9
- package/test/fixtures/store/projects/index.md +0 -9
- package/test/fixtures/store/projects/rekall-inc/architecture.md +0 -41
- package/test/fixtures/store/projects/rekall-inc/decisions/index.md +0 -9
- package/test/fixtures/store/projects/rekall-inc/decisions/no-military.md +0 -20
- package/test/fixtures/store/projects/rekall-inc/index.md +0 -28
- package/test/fixtures/store/user/family.md +0 -13
- package/test/fixtures/store/user/index.md +0 -9
- package/test/fixtures/store/user/preferences.md +0 -29
- package/test/fixtures/store/user/profile.md +0 -29
- package/test/fs.test.ts +0 -15
- package/test/glob.test.ts +0 -190
- package/test/md.test.ts +0 -177
- package/test/query.test.ts +0 -105
- package/test/uri.test.ts +0 -46
- package/test/util.test.ts +0 -62
- package/test/vfs.test.ts +0 -164
- package/tsconfig.json +0 -3
- package/tsdown.config.ts +0 -8
package/test/vfs.test.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import type { VfsEntry } from "../src/vfs.ts"
|
|
2
|
-
|
|
3
|
-
import { fileURLToPath } from "node:url"
|
|
4
|
-
import { join } from "pathe"
|
|
5
|
-
import { describe, expect, test } from "vitest"
|
|
6
|
-
import { Context } from "../src/context.ts"
|
|
7
|
-
import { Vfs } from "../src/vfs.ts"
|
|
8
|
-
|
|
9
|
-
const FIXTURES = join(fileURLToPath(import.meta.url), "..", "fixtures/store")
|
|
10
|
-
|
|
11
|
-
function createVfs() {
|
|
12
|
-
const ctx = new Context({})
|
|
13
|
-
return new Vfs(ctx)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function collect(vfs: Vfs, uri: string, depth?: number) {
|
|
17
|
-
const results: VfsEntry[] = []
|
|
18
|
-
for await (const item of vfs.find({ depth, uri })) {
|
|
19
|
-
results.push(item)
|
|
20
|
-
}
|
|
21
|
-
return results
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
describe("Vfs addFolder", () => {
|
|
25
|
-
test("adds a folder to the VFS", () => {
|
|
26
|
-
const vfs = createVfs()
|
|
27
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://notes" })
|
|
28
|
-
expect(vfs.folders).toHaveLength(1)
|
|
29
|
-
expect(vfs.folders[0].uri).toBe("rekal://notes/")
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test("normalizes trailing slash on URI", () => {
|
|
33
|
-
const vfs = createVfs()
|
|
34
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://notes" })
|
|
35
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://docs/" })
|
|
36
|
-
expect(vfs.folders[0].uri).toBe("rekal://notes/")
|
|
37
|
-
expect(vfs.folders[1].uri).toBe("rekal://docs/")
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe("Vfs find", () => {
|
|
42
|
-
test("finds files in a single mount", async () => {
|
|
43
|
-
const vfs = createVfs()
|
|
44
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://store" })
|
|
45
|
-
const results = await collect(vfs, "rekal://store")
|
|
46
|
-
expect(results.length).toBeGreaterThan(0)
|
|
47
|
-
|
|
48
|
-
const uris = results.map((r) => r.uri)
|
|
49
|
-
expect(uris.some((u) => u.includes("family.md"))).toBe(true)
|
|
50
|
-
expect(uris.some((u) => u.includes("user/"))).toBe(true)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test("depth=1 shows only immediate children", async () => {
|
|
54
|
-
const vfs = createVfs()
|
|
55
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://store" })
|
|
56
|
-
const results = await collect(vfs, "rekal://store", 1)
|
|
57
|
-
const uris = results.map((r) => r.uri)
|
|
58
|
-
|
|
59
|
-
// Should see top-level dirs (index.md is filtered as a dir node)
|
|
60
|
-
expect(uris.some((u) => u === "rekal://store/user/")).toBe(true)
|
|
61
|
-
expect(uris.some((u) => u === "rekal://store/projects/")).toBe(true)
|
|
62
|
-
|
|
63
|
-
// Should NOT see nested files
|
|
64
|
-
expect(uris.some((u) => u.includes("family.md"))).toBe(false)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test("nested mount appears as virtual directory", async () => {
|
|
68
|
-
const vfs = createVfs()
|
|
69
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://notes" })
|
|
70
|
-
vfs.addFolder({ path: join(FIXTURES, "concepts"), uri: "rekal://notes/extra" })
|
|
71
|
-
const results = await collect(vfs, "rekal://notes", 1)
|
|
72
|
-
const uris = results.map((r) => r.uri)
|
|
73
|
-
|
|
74
|
-
// The nested mount should appear as a directory
|
|
75
|
-
expect(uris).toContain("rekal://notes/extra/")
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
test("nested mount has correct path", async () => {
|
|
79
|
-
const vfs = createVfs()
|
|
80
|
-
const toolsDir = join(FIXTURES, "concepts")
|
|
81
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://notes" })
|
|
82
|
-
vfs.addFolder({ path: toolsDir, uri: "rekal://notes/extra" })
|
|
83
|
-
const results = await collect(vfs, "rekal://notes", 1)
|
|
84
|
-
|
|
85
|
-
const extra = results.find((r) => r.uri === "rekal://notes/extra/")
|
|
86
|
-
expect(extra).toBeDefined()
|
|
87
|
-
// Should have a path from the explicit mount
|
|
88
|
-
expect(extra!.path.startsWith(toolsDir)).toBe(true)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test("nested mount contents are found at depth=2", async () => {
|
|
92
|
-
const vfs = createVfs()
|
|
93
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://notes" })
|
|
94
|
-
vfs.addFolder({ path: join(FIXTURES, "concepts"), uri: "rekal://notes/extra" })
|
|
95
|
-
const results = await collect(vfs, "rekal://notes", 2)
|
|
96
|
-
const uris = results.map((r) => r.uri)
|
|
97
|
-
|
|
98
|
-
// Should find files inside the nested mount
|
|
99
|
-
expect(uris.some((u) => u.includes("extra/") && u.endsWith(".md"))).toBe(true)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
test("find below a mount resolves correctly", async () => {
|
|
103
|
-
const vfs = createVfs()
|
|
104
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://store" })
|
|
105
|
-
const results = await collect(vfs, "rekal://store/user")
|
|
106
|
-
const uris = results.map((r) => r.uri)
|
|
107
|
-
|
|
108
|
-
expect(uris.some((u) => u.includes("family.md"))).toBe(true)
|
|
109
|
-
expect(uris.some((u) => u.includes("preferences.md"))).toBe(true)
|
|
110
|
-
// Should NOT include files from other top-level dirs
|
|
111
|
-
expect(uris.some((u) => u.includes("concepts/"))).toBe(false)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
test("multiple paths for same URI prefix", async () => {
|
|
115
|
-
const vfs = createVfs()
|
|
116
|
-
vfs.addFolder({ path: join(FIXTURES, "user"), uri: "rekal://merged" })
|
|
117
|
-
vfs.addFolder({ path: join(FIXTURES, "concepts"), uri: "rekal://merged" })
|
|
118
|
-
const results = await collect(vfs, "rekal://merged")
|
|
119
|
-
const uris = results.map((r) => r.uri)
|
|
120
|
-
|
|
121
|
-
// Should find files from both directories
|
|
122
|
-
expect(uris.some((u) => u.includes("family.md"))).toBe(true) // from user
|
|
123
|
-
expect(uris.some((u) => u.includes("frecency.md"))).toBe(true) // from concepts
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test("deduplicates URIs from overlapping mounts", async () => {
|
|
127
|
-
const vfs = createVfs()
|
|
128
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://notes" })
|
|
129
|
-
// Mount the user subdir again explicitly
|
|
130
|
-
vfs.addFolder({ path: join(FIXTURES, "user"), uri: "rekal://notes/user" })
|
|
131
|
-
const results = await collect(vfs, "rekal://notes")
|
|
132
|
-
const uris = results.map((r) => r.uri)
|
|
133
|
-
|
|
134
|
-
// family.md should appear only once
|
|
135
|
-
const familyResults = uris.filter((u) => u === "rekal://notes/user/family.md")
|
|
136
|
-
expect(familyResults).toHaveLength(1)
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test("overlapping mount yields results from both sources", async () => {
|
|
140
|
-
const vfs = createVfs()
|
|
141
|
-
const userDir = join(FIXTURES, "user")
|
|
142
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://notes" })
|
|
143
|
-
vfs.addFolder({ path: userDir, uri: "rekal://notes/user" })
|
|
144
|
-
const results = await collect(vfs, "rekal://notes")
|
|
145
|
-
const uris = results.map((r) => r.uri)
|
|
146
|
-
|
|
147
|
-
// Should find the user/ directory and files from both mounts
|
|
148
|
-
expect(uris.some((u) => u === "rekal://notes/user/")).toBe(true)
|
|
149
|
-
expect(uris.some((u) => u.includes("family.md"))).toBe(true)
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
describe("Vfs ls", () => {
|
|
154
|
-
test("ls is equivalent to find with depth=1", async () => {
|
|
155
|
-
const vfs = createVfs()
|
|
156
|
-
vfs.addFolder({ path: FIXTURES, uri: "rekal://store" })
|
|
157
|
-
const lsResults = await collect(vfs, "rekal://store", 1)
|
|
158
|
-
const findResults: VfsEntry[] = []
|
|
159
|
-
for await (const item of vfs.ls({ uri: "rekal://store" })) {
|
|
160
|
-
findResults.push(item)
|
|
161
|
-
}
|
|
162
|
-
expect(lsResults.map((r) => r.uri).toSorted()).toEqual(findResults.map((r) => r.uri).toSorted())
|
|
163
|
-
})
|
|
164
|
-
})
|
package/tsconfig.json
DELETED