Import & Merge · v1.5.0

Import & Merge

Six tools for moving memory data in and out of VEKTOR — from a simple export CLI to a full drop-folder consolidation daemon with causal lineage reconstruction. All tools are additive: they never modify the core memory engine.

Memory Export

Exports all memories to JSON, Markdown, or CSV. Supports filtering by tag, importance, date, namespace, and limit. No wire-in required — standalone CLI only.

vektor-export.js CLI

CLI

bash
node vektor-export.js json                         # → memories-export.json
node vektor-export.js markdown                     # → memories-export.md
node vektor-export.js csv                          # → memories-export.csv
node vektor-export.js json --out ./backup.json
node vektor-export.js json --tag trading
node vektor-export.js json --min-importance 0.7
node vektor-export.js json --limit 100
node vektor-export.js json --since 2025-01-01
node vektor-export.js json --namespace research
node vektor-export.js json --db ./custom.db

Programmatic

javascript
const { exportMemory } = require('./vektor-export');
const result = await exportMemory({
  format:        'json',
  tag:           'trading',
  minImportance: 0.7,
  out:           './backup.json',
});
// → { dest: './backup.json', count: 42, format: 'json' }

DB auto-detection order

Checks VEKTOR_DB_PATH env var → ./slipstream-memory.db./vektor-slipstream-memory.db → AppData path. Override with --db.

Schema Migrations

Idempotent additive migrations — safe to run repeatedly. Never drops or modifies existing columns. Runs automatically on first boot of any module that requires new columns.

vektor-migrate.js CLI

Migrations

IDDescription
001Add tags TEXT column to memories
002Add confidence REAL column (default 1.0)
003Add source_db TEXT column (tracks import origin)
004Create vektor_migrations tracking table
005Index on memories.tags
006Index on memories.confidence
007Add namespace TEXT column (required by v1.4+)
008Add pinned INTEGER column
009Index on memories.namespace

CLI

bash
node vektor-migrate.js
node vektor-migrate.js --db ./slipstream-memory.db

Programmatic

javascript
const { runMigrations } = require('./vektor-migrate');
await runMigrations('./slipstream-memory.db');

Drop-Folder Daemon

Watches an ./import/ folder. Drop any .db file in — it auto-merges into the main database. Debounced 1.5s to handle slow file copies. Processes files already in the folder on startup. Failed merges move to import/error/, successful merges move to import/done/.

vektor-import-watch.js DAEMON

Wire-in

javascript
try{const _iw=require2('./vektor-import-watch');_iw.startImportWatcher().catch(function(){});}
catch(_){}
Usage
Drop any .db file into the ./import/ folder at any time — while the agent is running or offline. The daemon picks it up on startup if dropped while offline.

Environment Variables

VariableDefaultDescription
VEKTOR_IMPORT_DIR./importWatched folder path
VEKTOR_IMPORT_TARGET_DB./slipstream-memory.dbTarget DB to merge into

DB Merge Engine

Core merge engine used by the drop-folder daemon. Merges memories from any source .db file into the target using content-hash dedup. Dangling edges are guarded. Processed files auto-move to import/done/.

vektor-db-merge.js CLI

CLI

bash
node vektor-db-merge.js --folder ./import --target ./slipstream-memory.db

Programmatic

javascript
const { mergeDb } = require('./vektor-db-merge');
const report = await mergeDb({
  source: './import/old-agent.db',
  target: './slipstream-memory.db',
});
// → { merged: 142, skipped: 18, total: 160 }
Dedup Strategy
Uses content-hash dedup — prevents true duplicates even when source and target have different UUIDs for the same memory content.

Namespace Isolation

Manages per-project or per-user SQLite DB files under a namespaces/ directory. Routes remember() to the active namespace. recall() targets the active namespace by default, or queries all namespaces simultaneously with the /cross prefix.

vektor-namespace.js PROXY

Wire-in

javascript
try{
  const _ns=require2('./vektor-namespace');
  await _ns.initNamespaces(memRef,{push,getMemory});
}catch(_){}

Switching Namespaces

javascript
// Switch at runtime (e.g. from /ns chat command)
await _ns.setActiveNamespace('trading', memRef);

// Cross-namespace recall — queries ALL namespaces simultaneously
const results = await memory.recall('/cross your query');

Environment Variables

VariableDefaultDescription
VEKTOR_NAMESPACEdefaultActive namespace name
VEKTOR_NAMESPACE_DIR./namespacesPath to namespaces folder
VEKTOR_NS_CROSS_RECALL_LIMIT5Results per namespace on cross-query
VEKTOR_NAMESPACE_ENABLEDtrueSet to false to disable

CLI

bash
node vektor-namespace.js list
node vektor-namespace.js create research
node vektor-namespace.js stats
node vektor-namespace.js query research "your query"
node vektor-namespace.js merge trading default

MAGMA Causal Diff

When merging imported DBs, reconstructs the causal lineage — detecting which memories evolved from which across DBs. Preserves the why a memory changed, not just deduplicates content. Three conflict resolution strategies: importance-wins, newest-wins, and llm-arbitrate.

vektor-magma-diff.js ASYNC

Wire-in (registers as global, called by import-watch)

javascript
try{const _mg=require2('./vektor-magma-diff');globalThis.__magmaDiff=_mg;}
catch(_){}

// In vektor-import-watch.js, after merge completes:
if(globalThis.__magmaDiff){
  await globalThis.__magmaDiff.magmaMerge(srcPath, targetPath, { push, callLLM });
}

Conflict Resolution Strategies

StrategyDescription
importance-winsHigher importance score takes precedence
newest-winsMost recently updated memory wins (default fallback)
llm-arbitrateLLM compares both memories and picks the winner. Times out after 8s and falls back to newest-wins

Environment Variables

VariableDefaultDescription
MAGMA_RESOLVE_STRATEGYnewest-winsConflict resolution strategy
MAGMA_LLM_TIMEOUT_MS8000LLM arbitration timeout (ms)

What gets written to the DB

TableDescription
magma_edgesCausal edges between memories (source → derived)
magma_lineageFull provenance chain per memory
magma_diff_logAudit log of every merge decision
Driver Compatibility
Supports both better-sqlite3 and sql.js (required for Claude DXT). Auto-detects Electron context and skips native binary if running inside the DXT sandbox.