@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.
Files changed (79) hide show
  1. package/dist/{db-BMh1OP4b.mjs → db-CHpq7OOi.mjs} +46 -15
  2. package/dist/db-CHpq7OOi.mjs.map +1 -0
  3. package/dist/doc-DnYN4jAU.mjs +2 -0
  4. package/dist/doc-DnYN4jAU.mjs.map +1 -0
  5. package/dist/{embed-rUMZxqed.mjs → embed-CZI5Dz1q.mjs} +3 -1
  6. package/dist/embed-CZI5Dz1q.mjs.map +1 -0
  7. package/dist/frecency-CiaqPIOy.mjs +30 -0
  8. package/dist/frecency-CiaqPIOy.mjs.map +1 -0
  9. package/dist/fs-DMp26Byo.mjs +2 -0
  10. package/dist/fs-DMp26Byo.mjs.map +1 -0
  11. package/dist/glob.d.mts +2 -1
  12. package/dist/glob.d.mts.map +1 -0
  13. package/dist/glob.mjs +2 -0
  14. package/dist/glob.mjs.map +1 -0
  15. package/dist/index.d.mts +21 -11
  16. package/dist/index.d.mts.map +1 -0
  17. package/dist/index.mjs +7 -5
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/{llama-CT3dc9Cn.mjs → llama-CpNV7Lh9.mjs} +3 -1
  20. package/dist/llama-CpNV7Lh9.mjs.map +1 -0
  21. package/dist/{models-DFQSgBNr.mjs → models-Bo6czhQe.mjs} +5 -3
  22. package/dist/models-Bo6czhQe.mjs.map +1 -0
  23. package/dist/{openai-j2_2GM4J.mjs → openai-ALl6_YhI.mjs} +3 -1
  24. package/dist/openai-ALl6_YhI.mjs.map +1 -0
  25. package/dist/progress-B1JdNapX.mjs +2 -0
  26. package/dist/progress-B1JdNapX.mjs.map +1 -0
  27. package/dist/query-VFSpErTB.mjs +2 -0
  28. package/dist/query-VFSpErTB.mjs.map +1 -0
  29. package/dist/runtime.node-DlQPaGrV.mjs +2 -0
  30. package/dist/runtime.node-DlQPaGrV.mjs.map +1 -0
  31. package/dist/{search-BllHWtZF.mjs → search-DsVjB-9f.mjs} +2 -0
  32. package/dist/search-DsVjB-9f.mjs.map +1 -0
  33. package/dist/{store-DE7S35SS.mjs → store-I5nVEYxK.mjs} +10 -6
  34. package/dist/store-I5nVEYxK.mjs.map +1 -0
  35. package/dist/{transformers-CJ3QA2PK.mjs → transformers-Df56Nq9G.mjs} +3 -1
  36. package/dist/transformers-Df56Nq9G.mjs.map +1 -0
  37. package/dist/uri-CehXVDGB.mjs +2 -0
  38. package/dist/uri-CehXVDGB.mjs.map +1 -0
  39. package/dist/util-DNyrmcA3.mjs +2 -0
  40. package/dist/util-DNyrmcA3.mjs.map +1 -0
  41. package/dist/{vfs-CNQbkhsf.mjs → vfs-QUP1rnSI.mjs} +2 -0
  42. package/dist/vfs-QUP1rnSI.mjs.map +1 -0
  43. package/package.json +25 -25
  44. package/src/db.ts +73 -23
  45. package/src/frecency.ts +29 -46
  46. package/src/store.ts +13 -7
  47. package/foo.ts +0 -3
  48. package/foo2.ts +0 -20
  49. package/test/doc.test.ts +0 -61
  50. package/test/fixtures/ignore-test/keep.md +0 -0
  51. package/test/fixtures/ignore-test/skip.log +0 -0
  52. package/test/fixtures/ignore-test/sub/keep.md +0 -0
  53. package/test/fixtures/store/agent/index.md +0 -9
  54. package/test/fixtures/store/agent/lessons.md +0 -21
  55. package/test/fixtures/store/agent/soul.md +0 -28
  56. package/test/fixtures/store/agent/tools.md +0 -25
  57. package/test/fixtures/store/concepts/frecency.md +0 -30
  58. package/test/fixtures/store/concepts/index.md +0 -9
  59. package/test/fixtures/store/concepts/memory-coherence.md +0 -33
  60. package/test/fixtures/store/concepts/rag.md +0 -27
  61. package/test/fixtures/store/index.md +0 -9
  62. package/test/fixtures/store/projects/index.md +0 -9
  63. package/test/fixtures/store/projects/rekall-inc/architecture.md +0 -41
  64. package/test/fixtures/store/projects/rekall-inc/decisions/index.md +0 -9
  65. package/test/fixtures/store/projects/rekall-inc/decisions/no-military.md +0 -20
  66. package/test/fixtures/store/projects/rekall-inc/index.md +0 -28
  67. package/test/fixtures/store/user/family.md +0 -13
  68. package/test/fixtures/store/user/index.md +0 -9
  69. package/test/fixtures/store/user/preferences.md +0 -29
  70. package/test/fixtures/store/user/profile.md +0 -29
  71. package/test/fs.test.ts +0 -15
  72. package/test/glob.test.ts +0 -190
  73. package/test/md.test.ts +0 -177
  74. package/test/query.test.ts +0 -105
  75. package/test/uri.test.ts +0 -46
  76. package/test/util.test.ts +0 -62
  77. package/test/vfs.test.ts +0 -164
  78. package/tsconfig.json +0 -3
  79. 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
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json"
3
- }
package/tsdown.config.ts DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from "tsdown"
2
-
3
- export default defineConfig({
4
- entry: {
5
- glob: "src/glob.ts",
6
- index: "src/index.ts",
7
- },
8
- })