minimem 0.0.5 → 0.0.7

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 CHANGED
@@ -24,6 +24,7 @@ import {
24
24
  // src/minimem.ts
25
25
  import { randomUUID } from "crypto";
26
26
  import fs from "fs/promises";
27
+ import fsSync2 from "fs";
27
28
  import path2 from "path";
28
29
  import { DatabaseSync } from "sqlite";
29
30
  import chokidar from "chokidar";
@@ -1389,6 +1390,14 @@ async function runGeminiEmbeddingBatches(params) {
1389
1390
  }
1390
1391
 
1391
1392
  // src/minimem.ts
1393
+ function resolveMinimemSubdir(memoryDir) {
1394
+ const envDir = process.env.MINIMEM_CONFIG_DIR;
1395
+ if (envDir) return envDir;
1396
+ if (fsSync2.existsSync(path2.join(memoryDir, "config.json"))) return ".";
1397
+ const swarmDir = path2.join(memoryDir, ".swarm", "minimem");
1398
+ if (fsSync2.existsSync(path2.join(swarmDir, "config.json"))) return path2.join(".swarm", "minimem");
1399
+ return ".minimem";
1400
+ }
1392
1401
  var META_KEY = "memory_index_meta_v1";
1393
1402
  var SNIPPET_MAX_CHARS = 700;
1394
1403
  var VECTOR_TABLE = "chunks_vec";
@@ -1428,7 +1437,7 @@ var Minimem = class _Minimem {
1428
1437
  embeddingOptions;
1429
1438
  constructor(config) {
1430
1439
  this.memoryDir = path2.resolve(config.memoryDir);
1431
- this.dbPath = config.dbPath ?? path2.join(this.memoryDir, ".minimem", "index.db");
1440
+ this.dbPath = config.dbPath ?? path2.join(this.memoryDir, resolveMinimemSubdir(this.memoryDir), "index.db");
1432
1441
  this.chunking = {
1433
1442
  tokens: config.chunking?.tokens ?? 256,
1434
1443
  overlap: config.chunking?.overlap ?? 32