@theokit/sdk-memory 0.3.1 → 0.3.3

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 (88) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/LICENSE +2 -2
  3. package/README.md +42 -0
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/active-memory/active-memory-cache.d.ts +18 -0
  7. package/dist/internal/active-memory/active-memory-cache.d.ts.map +1 -1
  8. package/dist/internal/active-memory/active-memory-types.d.ts +25 -0
  9. package/dist/internal/active-memory/active-memory-types.d.ts.map +1 -1
  10. package/dist/internal/active-memory/active-memory.d.ts +54 -29
  11. package/dist/internal/active-memory/active-memory.d.ts.map +1 -1
  12. package/dist/internal/adapter-http-error.d.ts +18 -0
  13. package/dist/internal/adapter-http-error.d.ts.map +1 -1
  14. package/dist/internal/circuit-breaker.d.ts +17 -0
  15. package/dist/internal/circuit-breaker.d.ts.map +1 -1
  16. package/dist/internal/dreaming/dreaming-diary.d.ts +27 -0
  17. package/dist/internal/dreaming/dreaming-diary.d.ts.map +1 -1
  18. package/dist/internal/dreaming/dreaming-phases.d.ts +11 -0
  19. package/dist/internal/dreaming/dreaming-phases.d.ts.map +1 -1
  20. package/dist/internal/dreaming/dreaming-run.d.ts +34 -2
  21. package/dist/internal/dreaming/dreaming-run.d.ts.map +1 -1
  22. package/dist/internal/embedding/azure-openai-embedding.d.ts +22 -0
  23. package/dist/internal/embedding/azure-openai-embedding.d.ts.map +1 -1
  24. package/dist/internal/embedding/cohere-embedding.d.ts +18 -2
  25. package/dist/internal/embedding/cohere-embedding.d.ts.map +1 -1
  26. package/dist/internal/embedding/deepinfra-embedding.d.ts +13 -0
  27. package/dist/internal/embedding/deepinfra-embedding.d.ts.map +1 -1
  28. package/dist/internal/embedding/embedding-adapter.d.ts +36 -2
  29. package/dist/internal/embedding/embedding-adapter.d.ts.map +1 -1
  30. package/dist/internal/embedding/gemini-embedding.d.ts +9 -0
  31. package/dist/internal/embedding/gemini-embedding.d.ts.map +1 -1
  32. package/dist/internal/embedding/jina-embedding.d.ts +9 -0
  33. package/dist/internal/embedding/jina-embedding.d.ts.map +1 -1
  34. package/dist/internal/embedding/mistral-embedding.d.ts +8 -0
  35. package/dist/internal/embedding/mistral-embedding.d.ts.map +1 -1
  36. package/dist/internal/embedding/ollama-embedding.d.ts +21 -0
  37. package/dist/internal/embedding/ollama-embedding.d.ts.map +1 -1
  38. package/dist/internal/embedding/openai-embedding.d.ts +19 -12
  39. package/dist/internal/embedding/openai-embedding.d.ts.map +1 -1
  40. package/dist/internal/embedding/openrouter-embedding.d.ts +12 -0
  41. package/dist/internal/embedding/openrouter-embedding.d.ts.map +1 -1
  42. package/dist/internal/embedding/voyage-embedding.d.ts +9 -0
  43. package/dist/internal/embedding/voyage-embedding.d.ts.map +1 -1
  44. package/dist/internal/index/index-db.d.ts +25 -0
  45. package/dist/internal/index/index-db.d.ts.map +1 -1
  46. package/dist/internal/index/index-manager-contract.d.ts +28 -0
  47. package/dist/internal/index/index-manager-contract.d.ts.map +1 -1
  48. package/dist/internal/index/index-manager.d.ts +29 -0
  49. package/dist/internal/index/index-manager.d.ts.map +1 -1
  50. package/dist/internal/index/lance-index.d.ts +25 -0
  51. package/dist/internal/index/lance-index.d.ts.map +1 -1
  52. package/dist/internal/index/lance-memory-adapter.d.ts +27 -5
  53. package/dist/internal/index/lance-memory-adapter.d.ts.map +1 -1
  54. package/dist/internal/index/memory-index.d.ts +17 -2
  55. package/dist/internal/index/memory-index.d.ts.map +1 -1
  56. package/dist/internal/index/migrate-sqlite-to-lance.d.ts +12 -0
  57. package/dist/internal/index/migrate-sqlite-to-lance.d.ts.map +1 -1
  58. package/dist/internal/index/migration.d.ts +26 -0
  59. package/dist/internal/index/migration.d.ts.map +1 -1
  60. package/dist/internal/index/vec-index.d.ts +67 -16
  61. package/dist/internal/index/vec-index.d.ts.map +1 -1
  62. package/dist/internal/memory-types.d.ts +17 -1
  63. package/dist/internal/memory-types.d.ts.map +1 -1
  64. package/dist/internal/store/chunk-markdown.d.ts +17 -0
  65. package/dist/internal/store/chunk-markdown.d.ts.map +1 -1
  66. package/dist/internal/store/markdown-store.d.ts +26 -0
  67. package/dist/internal/store/markdown-store.d.ts.map +1 -1
  68. package/dist/internal/store/reader.d.ts +26 -3
  69. package/dist/internal/store/reader.d.ts.map +1 -1
  70. package/dist/internal/store/session-loader.d.ts +5 -0
  71. package/dist/internal/store/session-loader.d.ts.map +1 -1
  72. package/dist/internal/store/session-summary-writer.d.ts +14 -0
  73. package/dist/internal/store/session-summary-writer.d.ts.map +1 -1
  74. package/dist/internal/store/transcript-store.d.ts +12 -0
  75. package/dist/internal/store/transcript-store.d.ts.map +1 -1
  76. package/dist/internal/store/wiki-loader.d.ts +11 -0
  77. package/dist/internal/store/wiki-loader.d.ts.map +1 -1
  78. package/dist/internal/tools.d.ts +38 -0
  79. package/dist/internal/tools.d.ts.map +1 -1
  80. package/package.json +8 -7
  81. package/dist/internal/active-memory/composite-scorer.d.ts +0 -19
  82. package/dist/internal/active-memory/composite-scorer.d.ts.map +0 -1
  83. package/dist/internal/active-memory/query-analyzer.d.ts +0 -16
  84. package/dist/internal/active-memory/query-analyzer.d.ts.map +0 -1
  85. package/dist/internal/embedding/batch-encoder.d.ts +0 -30
  86. package/dist/internal/embedding/batch-encoder.d.ts.map +0 -1
  87. package/dist/internal/memory-scope.d.ts +0 -21
  88. package/dist/internal/memory-scope.d.ts.map +0 -1
@@ -12,5 +12,13 @@ import type { MemoryEmbeddingProviderAdapter } from "./embedding-adapter.js";
12
12
  * @internal
13
13
  */
14
14
  export declare const DEFAULT_MISTRAL_EMBEDDING_MODEL = "mistral-embed";
15
+ /**
16
+ * Mistral embeddings, over the standard OpenAI wire. One model only,
17
+ * `mistral-embed` at 1024 dimensions; any other id is refused with
18
+ * `embedding_unknown_model`.
19
+ *
20
+ * Reads `MISTRAL_API_KEY` and honours `MISTRAL_API_BASE_URL`. Priority 18, just
21
+ * below OpenAI.
22
+ */
15
23
  export declare const mistralMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
16
24
  //# sourceMappingURL=mistral-embedding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mistral-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/mistral-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,+BAA+B,kBAAkB,CAAC;AAM/D,eAAO,MAAM,qCAAqC,EAAE,8BAkBnD,CAAC"}
1
+ {"version":3,"file":"mistral-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/mistral-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,+BAA+B,kBAAkB,CAAC;AAM/D;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,EAAE,8BAkBnD,CAAC"}
@@ -36,6 +36,27 @@
36
36
  * @internal
37
37
  */
38
38
  import type { MemoryEmbeddingProviderAdapter } from "./embedding-adapter.js";
39
+ /**
40
+ * Model used when the caller names none: `nomic-embed-text`, 768 dimensions,
41
+ * roughly 274MB to pull. `all-minilm` is the smaller alternative at 384
42
+ * dimensions and roughly 45MB.
43
+ */
39
44
  export declare const DEFAULT_OLLAMA_EMBEDDING_MODEL = "nomic-embed-text";
45
+ /**
46
+ * Embeddings from a local Ollama instance — the only adapter in the catalog with
47
+ * `transport: "local"`, and the one to choose when the corpus must not leave the
48
+ * machine or when there is no API key to spend.
49
+ *
50
+ * It needs an Ollama server reachable at `OLLAMA_HOST` (default
51
+ * `http://localhost:11434`) with the chosen embedding model already pulled;
52
+ * nothing here starts a server or downloads a model, so a missing model surfaces
53
+ * as an HTTP error from Ollama rather than a configuration error.
54
+ *
55
+ * No credential is required: a sentinel key is sent and local Ollama ignores it.
56
+ * Set `OLLAMA_API_KEY` for Ollama Cloud or an authenticating reverse proxy.
57
+ *
58
+ * Auto-select priority is 10, the lowest in the catalog, so a configured remote
59
+ * provider wins over it. Request it explicitly to prefer local.
60
+ */
40
61
  export declare const ollamaMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
41
62
  //# sourceMappingURL=ollama-embedding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ollama-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/ollama-embedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E,eAAO,MAAM,8BAA8B,qBAAqB,CAAC;AAsBjE,eAAO,MAAM,oCAAoC,EAAE,8BAyBlD,CAAC"}
1
+ {"version":3,"file":"ollama-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/ollama-embedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,qBAAqB,CAAC;AAsBjE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oCAAoC,EAAE,8BAyBlD,CAAC"}
@@ -1,16 +1,4 @@
1
1
  import type { MemoryEmbeddingProviderAdapter } from "./embedding-adapter.js";
2
- /**
3
- * **Iter 74 rollup-plugin-dts workaround:** importing
4
- * `MemoryEmbeddingProviderAdapter` from sibling `./embedding-adapter.js`
5
- * fails dts emit because no public type reaches it transitively yet
6
- * (same iter 48/53/55/66/67/69/72 class). Fix: drop the explicit
7
- * type annotation on the exported adapter; TS infers the structural
8
- * shape from the literal, and the catalog (iter 37 / this same iter)
9
- * pin assignability against the canonical interface via its own
10
- * `Record<string, MemoryEmbeddingProviderAdapter>` constraint.
11
- *
12
- * @internal
13
- */
14
2
  /**
15
3
  * OpenAI embedding adapter (ADR D3) — built on the shared OpenAI-compatible
16
4
  * factory. Native fetch only.
@@ -23,5 +11,24 @@ import type { MemoryEmbeddingProviderAdapter } from "./embedding-adapter.js";
23
11
  * @internal
24
12
  */
25
13
  export declare const DEFAULT_OPENAI_EMBEDDING_MODEL = "text-embedding-3-small";
14
+ /**
15
+ * OpenAI embeddings — `text-embedding-3-small` (1536), `text-embedding-3-large` (3072) and
16
+ * `text-embedding-ada-002` (1536).
17
+ *
18
+ * It is NOT selected for you. The provider is whatever the caller names in
19
+ * `embedding: { provider }`; omit that and no embedding runtime is built at all. Its
20
+ * `autoSelectPriority` of `20` is metadata no code path reads today, and it is not the highest
21
+ * value in the catalog either — `jina` is 35, `cohere` and `gemini` are 30, `azure-openai` is 25.
22
+ * The 3072-wide `text-embedding-3-large` is reachable through `azure-openai` and, as
23
+ * `openai/text-embedding-3-large`, through `openrouter` as well.
24
+ *
25
+ * Reads `OPENAI_API_KEY`; `OPENAI_API_BASE_URL` redirects it at a compatible
26
+ * gateway. `create` rejects with an `AuthenticationError`
27
+ * (`embedding_missing_api_key`) when no key is found, and with a
28
+ * `ConfigurationError` (`embedding_unknown_model`) for a model outside
29
+ * `text-embedding-3-small`, `text-embedding-3-large` and
30
+ * `text-embedding-ada-002` — the dimension has to be known before any vector
31
+ * table is created, so an unlisted model is refused rather than probed.
32
+ */
26
33
  export declare const openAiMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
27
34
  //# sourceMappingURL=openai-embedding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openai-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAG7E;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,8BAA8B,2BAA2B,CAAC;AAQvE,eAAO,MAAM,oCAAoC,EAAE,8BAkBlD,CAAC"}
1
+ {"version":3,"file":"openai-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openai-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAY7E;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,8BAA8B,2BAA2B,CAAC;AAQvE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oCAAoC,EAAE,8BAkBlD,CAAC"}
@@ -14,5 +14,17 @@ import type { MemoryEmbeddingProviderAdapter } from "./embedding-adapter.js";
14
14
  * @internal
15
15
  */
16
16
  export declare const DEFAULT_OPENROUTER_EMBEDDING_MODEL = "openai/text-embedding-3-small";
17
+ /**
18
+ * Embeddings routed through OpenRouter, which lets one key reach several
19
+ * upstream providers. Use it when you want to switch provider without changing
20
+ * credentials; use the provider's own adapter when you want its full model
21
+ * range, since only the four ids in this adapter's dimension table are
22
+ * accepted.
23
+ *
24
+ * Model ids carry the upstream prefix, for example
25
+ * `openai/text-embedding-3-small` or `mistralai/mistral-embed`. The endpoint is
26
+ * `/v1/embeddings` under the base `https://openrouter.ai/api`. Reads
27
+ * `OPENROUTER_API_KEY` and honours `OPENROUTER_API_BASE_URL`. Priority 15.
28
+ */
17
29
  export declare const openRouterMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
18
30
  //# sourceMappingURL=openrouter-embedding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openrouter-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openrouter-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,kCAAkC,kCAAkC,CAAC;AASlF,eAAO,MAAM,wCAAwC,EAAE,8BAkBtD,CAAC"}
1
+ {"version":3,"file":"openrouter-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openrouter-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,kCAAkC,kCAAkC,CAAC;AASlF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wCAAwC,EAAE,8BAkBtD,CAAC"}
@@ -12,5 +12,14 @@ import type { MemoryEmbeddingProviderAdapter } from "./embedding-adapter.js";
12
12
  * @internal
13
13
  */
14
14
  export declare const DEFAULT_VOYAGE_EMBEDDING_MODEL = "voyage-3-lite";
15
+ /**
16
+ * Voyage AI embeddings, over the standard OpenAI wire. Default model
17
+ * `voyage-3-lite` at 512 dimensions — the narrowest in the catalog, which makes
18
+ * the index smaller and the search cheaper at some cost in quality; `voyage-3`
19
+ * and `voyage-3-large` are 1024, and `voyage-code-3` is the one to pick for
20
+ * source code.
21
+ *
22
+ * Reads `VOYAGE_API_KEY` and honours `VOYAGE_API_BASE_URL`. Priority 14.
23
+ */
15
24
  export declare const voyageMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
16
25
  //# sourceMappingURL=voyage-embedding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"voyage-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/voyage-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,8BAA8B,kBAAkB,CAAC;AAU9D,eAAO,MAAM,oCAAoC,EAAE,8BAkBlD,CAAC"}
1
+ {"version":3,"file":"voyage-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/voyage-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAK7E;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,8BAA8B,kBAAkB,CAAC;AAU9D;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,EAAE,8BAkBlD,CAAC"}
@@ -37,6 +37,7 @@ export interface MemoryDb {
37
37
  /** Load a SQLite loadable extension at the given path (used by sqlite-vec). */
38
38
  loadExtension(path: string): void;
39
39
  }
40
+ /** Options for {@link openMemoryDb}. */
40
41
  export interface OpenDbOptions {
41
42
  filePath: string;
42
43
  /**
@@ -45,6 +46,30 @@ export interface OpenDbOptions {
45
46
  */
46
47
  recoverCorrupt?: boolean;
47
48
  }
49
+ /**
50
+ * Open (or create) the SQLite memory index at `filePath`, applying the pragmas
51
+ * and creating the schema before returning. Parent directories are created as
52
+ * needed, so pointing this at a fresh workspace works.
53
+ *
54
+ * The driver is chosen at runtime: `node:sqlite` where the running Node exposes
55
+ * it, and `better-sqlite3` otherwise. `better-sqlite3` is an optional peer
56
+ * dependency of this package — on a Node build without `node:sqlite` and
57
+ * without it installed, opening fails.
58
+ *
59
+ * A file that is corrupt, truncated or encrypted is renamed aside to
60
+ * `<path>.corrupt-<timestamp>` and rebuilt empty, unless `recoverCorrupt` is
61
+ * `false`. Recovery loses every indexed chunk; the markdown corpus is the source
62
+ * of truth and the next `sync()` rebuilds from it.
63
+ *
64
+ * Loading the sqlite-vec extension is a separate step — this returns an index
65
+ * that can do text search only.
66
+ */
48
67
  export declare function openMemoryDb(opts: OpenDbOptions): Promise<MemoryDb>;
68
+ /**
69
+ * Where the SQLite index lives when the caller does not name a path:
70
+ * `<cwd>/.theokit/memory/.index/memory.sqlite`. Pure path computation. The file
71
+ * sits under the memory root but outside the markdown corpus, so it is never
72
+ * indexed as content.
73
+ */
49
74
  export declare function defaultIndexPath(cwd: string): string;
50
75
  //# sourceMappingURL=index-db.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-db.d.ts","sourceRoot":"","sources":["../../../src/intern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AM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QACpB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAC;QAC/E,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;QAC7D,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACzD,CAAC;IACF,iEAAiE;IACjE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;IACnE,KAAK,IAAI,IAAI,CAAC;IACd,+EAA+E;IAC/E,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,wCAAwC;AACxC,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWzE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -42,12 +42,31 @@ export interface MemorySearchHit {
42
42
  /** path:startLine-endLine for citations. */
43
43
  citation: string;
44
44
  }
45
+ /**
46
+ * A snapshot of index health. `backend` is `hybrid` when a vector index is live
47
+ * and `fts-only` when the index can do text search only, which is what an index
48
+ * opened without an embedding runtime reports.
49
+ *
50
+ * `lastSyncMs` is present only after a `sync()` in this process; it is not
51
+ * persisted, so a freshly opened index omits it however recently it was synced.
52
+ */
45
53
  export interface IndexStatus {
46
54
  backend: "fts-only" | "hybrid";
47
55
  filesIndexed: number;
48
56
  chunksIndexed: number;
49
57
  lastSyncMs?: number;
50
58
  }
59
+ /**
60
+ * Search tuning. `maxResults` defaults to 10 and is floored at 1. `minScore`
61
+ * defaults to 0 and is compared against the combined score, not the text or
62
+ * vector score alone. `sources` filters by corpus; omitting it searches all
63
+ * three.
64
+ *
65
+ * The two weights only matter on a hybrid index — with no vector index every
66
+ * vector score is 0, so raising `vectorWeight` only scales the text score down.
67
+ * They are normalised by their sum, so `{vectorWeight: 6, textWeight: 4}`
68
+ * behaves the same as the defaults.
69
+ */
51
70
  export interface SearchOptions {
52
71
  maxResults?: number;
53
72
  minScore?: number;
@@ -59,6 +78,15 @@ export interface SearchOptions {
59
78
  }
60
79
  /** Vector backend selector. SQLite default; Lance opt-in (ADR D43). */
61
80
  export type MemoryBackend = "sqlite-vec" | "lance";
81
+ /**
82
+ * Options for `IndexManager.open`.
83
+ *
84
+ * Passing `embedding` is what turns on vector search; without it the index is
85
+ * text-only. The Lance backend requires it and refuses to open without one.
86
+ *
87
+ * `filePath` means different things per backend: on `sqlite-vec` it is the
88
+ * database file, on `lance` it is the storage directory.
89
+ */
62
90
  export interface OpenIndexOptions {
63
91
  cwd: string;
64
92
  filePath?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index-manager-contract.d.ts","sourceRoot":"","sources":["../../../src/internal/index/index-manager-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,sGAAsG;IACtG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IACvC,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;IACxD,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,oEAAoE;IACpE,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB"}
1
+ {"version":3,"file":"index-manager-contract.d.ts","sourceRoot":"","sources":["../../../src/internal/index/index-manager-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS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* The default memory index: SQLite for storage, FTS5 for text matching, and
54
+ * sqlite-vec for vectors when an embedding runtime is supplied.
55
+ *
56
+ * Open it with the static `open`, which is also the dispatch point for
57
+ * `backend: "lance"` — that overload returns a `LanceMemoryAdapter`, not an
58
+ * `IndexManager`, so hold the result as {@link MemoryIndex} unless you need this
59
+ * class specifically.
60
+ *
61
+ * Storage needs `better-sqlite3` unless the running Node exposes `node:sqlite`,
62
+ * and vectors additionally need `sqlite-vec`. Both are optional peer
63
+ * dependencies of this package. Without an embedding runtime the index opens
64
+ * text-only and reports `backend: "fts-only"`; no vector table is created and
65
+ * search degrades to BM25 rather than failing.
66
+ *
67
+ * `sync()` crawls the markdown corpus — `MEMORY.md`, `notes/`, `wiki/` and
68
+ * `sessions/` — skipping files whose content hash has not moved, and re-chunking
69
+ * the rest. Nothing is indexed until it runs.
70
+ *
71
+ * If the embedding provider, model or dimension differs from what the database
72
+ * recorded, opening drops the whole vector table so the next `sync()` re-embeds
73
+ * from scratch. Switching embedding models is therefore safe but not cheap.
74
+ *
75
+ * `search()` runs both halves and blends them per chunk, so a chunk found only
76
+ * by vector still appears with a text score of 0 and the other way round.
77
+ * `close()` releases the database handle; it is synchronous here, unlike the
78
+ * Lance adapter's, so a caller holding the {@link MemoryIndex} type must await
79
+ * it either way.
80
+ */
52
81
  export declare class IndexManager implements MemoryIndex {
53
82
  private readonly cwd;
54
83
  private readonly db;
@@ -1 +1 @@
1
- {"version":3,"file":"index-manager.d.ts","sourceRoot":"","sources":["../../../src/internal/index/index-manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAO1E,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,mBAAmB,CAAC;AAYzE;;;;;;;;;;;;;;;;;;GAkBG;AAmBH,UAAU,eAAe;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QA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,OAAO,CAAC,WAAW,CAAC;WACzE,IAAI,CACf,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG,CAAC,gBAAgB,GAAG;QAAE,OAAO,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC,GACxF,OAAO,CAAC,YAAY,CAAC;IAQxB,sEAAsE;mBACjD,kBAAkB;YAQzB,iBAAiB;IAkB/B,wDAAwD;IAClD,IAAI,IAAI,OAAO,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IAkCI,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAYpF,MAAM,IAAI,WAAW;IAcrB,OAAO,CAAC,SAAS;YA4CH,gBAAgB;IAiB9B,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,gBAAgB;IAkCxB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,WAAW;IAcnB,KAAK,IAAI,IAAI;CAGd"}
@@ -1,4 +1,13 @@
1
1
  import type { EmbeddingRuntime } from "../embedding/embedding-adapter.js";
2
+ /**
3
+ * One row of the Lance `facts` table, as it is stored. Field names are the
4
+ * on-disk column names, which is why `user_id` is snake_case here while the
5
+ * search result reports `userId`.
6
+ *
7
+ * `embedding` must be exactly as wide as the table was created with; the width
8
+ * is fixed by the embedding runtime on the first open and checked on every
9
+ * later one.
10
+ */
2
11
  export interface LanceFactRecord {
3
12
  id: string;
4
13
  text: string;
@@ -9,18 +18,34 @@ export interface LanceFactRecord {
9
18
  user_id: string;
10
19
  timestamp: number;
11
20
  }
21
+ /**
22
+ * Options for `LanceIndex.open`. The embedding runtime is required, not
23
+ * optional: Lance here is vector-only, so there is no text-search fallback to
24
+ * open without one.
25
+ */
12
26
  export interface OpenLanceOptions {
13
27
  cwd: string;
14
28
  embedding: EmbeddingRuntime;
15
29
  /** Override storage location. Default: `<cwd>/.theokit/memory/lance/`. */
16
30
  storagePath?: string;
17
31
  }
32
+ /**
33
+ * Filters for `LanceIndex.search`. `namespace` is required and `scope` is
34
+ * optional; both are applied as a SQL predicate inside Lance. `sources` is
35
+ * applied in this process, after the rows come back, so it narrows the result
36
+ * without narrowing what `limit` counted.
37
+ */
18
38
  export interface LanceSearchOptions {
19
39
  namespace: string;
20
40
  scope?: string;
21
41
  limit?: number;
22
42
  sources?: ReadonlyArray<"memory" | "sessions" | "wiki">;
23
43
  }
44
+ /**
45
+ * One Lance search result. `score` is a similarity in `(0, 1]` derived from
46
+ * Lance's distance as `1 / (1 + distance)`, so higher is better — the opposite
47
+ * direction from the raw distance Lance returns.
48
+ */
24
49
  export interface LanceSearchHit {
25
50
  id: string;
26
51
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"lance-index.d.ts","sourceRoot":"","sources":["../../../src/internal/index/lance-index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AA+D1E,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IACvC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,gBAAgB,CAAC;IAC5B,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;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AAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAH/B,OAAO;WAMM,IAAI,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IA2CxD,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvF;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA+B1E,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ9C,WAAW,CAAC,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAiCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAQ1C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -11,11 +11,13 @@
11
11
  * facts use `LanceIndex.addFacts` directly (exposed via the index
12
12
  * object returned to advanced callers).
13
13
  * - `search()` performs vector-only retrieval. `MemorySearchHit.textScore`
14
- * is undefined (no FTS5 layer); `vectorScore === score`.
15
- * - `status()` reports `backend: "hybrid"` only when an embedding runtime
16
- * is wired (always the case for Lance embedding is required at open).
17
- * `chunksIndexed` reflects total Lance row count; `filesIndexed` is 0
18
- * because Lance does not track file provenance per-row.
14
+ * is 0 on every hit (no FTS5 layer); `vectorScore === score`.
15
+ * - `status()` always reports `backend: "hybrid"` embedding is required
16
+ * at open, so there is no text-only Lance index. Both counts are 0: the
17
+ * Lance row count is only available asynchronously and `status()` is
18
+ * synchronous, so callers needing a real count call
19
+ * `unwrap().countFacts()`. Lance does not track file provenance per row,
20
+ * so `filesIndexed` has nothing to report either way.
19
21
  *
20
22
  * Ships with the lancedb-backend-ship-v1-1 plan (close D12, supersede via
21
23
  * D43). v1.4.0 of `@theokit/sdk`.
@@ -81,6 +83,26 @@ interface LanceIndex {
81
83
  removeFacts(ids: ReadonlyArray<string>): Promise<void>;
82
84
  close(): Promise<void>;
83
85
  }
86
+ /**
87
+ * Presents a `LanceIndex` as a {@link MemoryIndex}, so a consumer written
88
+ * against the SQLite index runs unchanged on `backend: "lance"`.
89
+ *
90
+ * Choose it when the corpus is large enough that SQLite plus sqlite-vec is the
91
+ * bottleneck and you are willing to feed the index yourself. Stay on the SQLite
92
+ * default when you want the markdown corpus crawled for you, or text matching on
93
+ * exact terms: this adapter's `sync()` does nothing and its `search()` is
94
+ * vector-only, so a query that would have matched by keyword now has to match by
95
+ * meaning.
96
+ *
97
+ * Requires `@lancedb/lancedb`, an optional peer dependency. It is loaded when
98
+ * the index is opened, not here.
99
+ *
100
+ * Two behaviours are worth knowing before switching. Facts only enter the index
101
+ * through `unwrap().addFacts(...)` — nothing else writes to it. And `search()`
102
+ * always queries the `default` namespace, because `SearchOptions` has no
103
+ * namespace field to pass through, so a multi-tenant caller must open one index
104
+ * per tenant rather than relying on the filter.
105
+ */
84
106
  export declare class LanceMemoryAdapter implements MemoryIndex {
85
107
  private readonly inner;
86
108
  constructor(inner: LanceIndex);
@@ -1 +1 @@
1
- {"version":3,"file":"lance-memory-adapter.d.ts","sourceRoot":"","sources":["../../../src/internal/index/lance-memory-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,KAAK,WAAW,EAAsB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE1F;;;;;;;;;;;;;;;;;GAiB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AQ,GAAG,UAAU,GAAG,MAAM,CAAC;QACvC,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CACH,CAAC;IACF,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,WAAW,CAAC,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAqBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,UAAU;IAE9C;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAO3B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAepF,MAAM,IAAI,WAAW;IAWf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;OAGG;IACH,MAAM,IAAI,UAAU;CAGrB"}
@@ -31,6 +31,12 @@
31
31
  * @internal
32
32
  */
33
33
  import type { IndexStatus, MemorySearchHit, SearchOptions } from "./index-manager-contract.js";
34
+ /**
35
+ * What one `sync()` did. `filesScanned` counts every markdown file discovered,
36
+ * including the unchanged ones; `filesUpdated` counts only those whose content
37
+ * hash moved. `chunksEmbedded` is 0 on an index with no embedding runtime, and
38
+ * also on a hybrid index where every chunk already had a vector.
39
+ */
34
40
  export interface SyncResult {
35
41
  filesScanned: number;
36
42
  filesUpdated: number;
@@ -47,6 +53,15 @@ export declare function parseSearchOptions(options?: SearchOptions): {
47
53
  maxResults: number;
48
54
  minScore: number;
49
55
  };
56
+ /**
57
+ * The four operations both backends implement, and the type every consumer
58
+ * should hold. `IndexManager.open` returns this rather than a concrete class
59
+ * precisely so `backend: "lance"` can be swapped in without changing the caller.
60
+ *
61
+ * The two backends differ in what they can honour, and the differences are
62
+ * visible in the results rather than in the types — see `sync` and `search`
63
+ * below, and `LanceMemoryAdapter` for the full list.
64
+ */
50
65
  export interface MemoryIndex {
51
66
  /**
52
67
  * Walk the memory corpus + reindex changed files. Lance backend has no
@@ -56,8 +71,8 @@ export interface MemoryIndex {
56
71
  sync(): Promise<SyncResult>;
57
72
  /**
58
73
  * Semantic + textual search over the indexed corpus. Both backends
59
- * return the same `MemorySearchHit[]` shape; Lance leaves `textScore`
60
- * undefined (vector-only no FTS5 layer).
74
+ * return the same `MemorySearchHit[]` shape; Lance reports `textScore` as 0
75
+ * on every hit, because it is vector-only and has no FTS5 layer.
61
76
  */
62
77
  search(query: string, options?: SearchOptions): Promise<MemorySearchHit[]>;
63
78
  /** Snapshot of the index health (backend type + counts). */
@@ -1 +1 @@
1
- {"version":3,"file":"memory-index.d.ts","sourceRoot":"","sources":["../../../src/internal/index/memory-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAW/F,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,aAAkB,GAAG;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAKA;AAED,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAE5B;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE3E,4DAA4D;IAC5D,MAAM,IAAI,WAAW,CAAC;IAEtB,0CAA0C;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC/B"}
1
+ {"version":3,"file":"memory-index.d.ts","sourceRoot":"","sources":["../../../src/internal/index/memory-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAW/F;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,aAAkB,GAAG;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAKA;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAE5B;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE3E,4DAA4D;IAC5D,MAAM,IAAI,WAAW,CAAC;IAEtB,0CAA0C;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC/B"}
@@ -23,6 +23,18 @@ export interface MigrateOptions {
23
23
  /** Inject for tests; defaults to console.log. */
24
24
  logger?: (msg: string) => void;
25
25
  }
26
+ /**
27
+ * Outcome of {@link migrateSqliteToLance}.
28
+ *
29
+ * Read `committed` first: it is `false` for a dry run and for a failed
30
+ * validation, and only `true` when the staging directory was promoted to
31
+ * `lance/`. `validated` reports whether the counts matched and the sampled facts
32
+ * compared equal; `sampleComparisons` holds up to ten of those comparisons so a
33
+ * failure can be inspected rather than merely counted.
34
+ *
35
+ * The SQLite database is left in place either way — this migration copies, it
36
+ * does not move.
37
+ */
26
38
  export interface MigrateResult {
27
39
  countSqlite: number;
28
40
  countLance: number;
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-sqlite-to-lance.d.ts","sourceRoot":"","sources":["../../../src/internal/index/migrate-sqlite-to-lance.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,EAAE,OAAO,CAAC;IACnB,gEAAgE;IAChE,iBAAiB,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACjE,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;CACpB;AA0DD;;;;;;GAMG;AAEH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAmJvF"}
1
+ {"version":3,"file":"migrate-sqlite-to-lance.d.ts","sourceRoot":"","sources":["../../../src/internal/index/migrate-sqlite-to-lance.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,EAAE,OAAO,CAAC;IACnB,gEAAgE;IAChE,iBAAiB,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACjE,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;CACpB;AA0DD;;;;;;GAMG;AAEH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAmJvF"}
@@ -1,9 +1,35 @@
1
1
  import { type MemoryConfig } from "../memory-types.js";
2
+ /**
3
+ * Outcome of {@link migrateLegacyJson}. `reason` is present on every non-migrated
4
+ * result and says which guard stopped it: `already-migrated` (this key was
5
+ * attempted earlier in this process), `no-legacy-json` (nothing to migrate, or
6
+ * the file could not be read or parsed), `markdown-exists` (both files present,
7
+ * so neither was touched), `readonly-fs` (the write failed).
8
+ */
2
9
  export interface MigrationResult {
3
10
  migrated: boolean;
4
11
  factCount: number;
5
12
  reason?: "already-migrated" | "no-legacy-json" | "markdown-exists" | "readonly-fs";
6
13
  }
14
+ /**
15
+ * Move facts from the pre-markdown JSON store into `MEMORY.md`, once.
16
+ *
17
+ * It runs only when the legacy file exists and `MEMORY.md` does not. When both
18
+ * exist it stops and leaves both alone — merging would need a conflict rule
19
+ * nobody has picked, and losing hand-written notes is worse than skipping. On
20
+ * success each fact is appended as a `## Facts` bullet and the JSON file is
21
+ * deleted.
22
+ *
23
+ * Guarded by a per-process set keyed on cwd, namespace, scope and user id, so
24
+ * the second call for the same key returns `already-migrated` without touching
25
+ * disk — including after a genuine failure. That set is per module instance, so
26
+ * a process that loads both this package's copy and the one inside
27
+ * `@theokit/sdk` has two independent sets.
28
+ *
29
+ * Never throws: a JSON file that cannot be read or parsed reports
30
+ * `no-legacy-json`, and a failed write reports `readonly-fs` after a warning on
31
+ * stderr.
32
+ */
7
33
  export declare function migrateLegacyJson(cwd: string, config: MemoryConfig): Promise<MigrationResult>;
8
34
  /** Test-only — reset the in-process migration flag map. */
9
35
  export declare function resetMigrationStateForTests(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/internal/index/migration.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAqE9F,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,aAAa,CAAC;CACpF;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAED,2DAA2D;AAC3D,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}
1
+ {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/internal/index/migration.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAqE9F;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,aAAa,CAAC;CACpF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAED,2DAA2D;AAC3D,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}