Registry / ai-ml / latticesql

latticesql

JSON →
library1.16.4jsnpmunverified

Persistent structured memory for AI agent systems that keeps a SQLite or Postgres database and context files in sync. Current stable version 1.16.4 (released ~Jan 2025) requires Node >=18 and peer dep better-sqlite3 >=11 <13. Release cadence is monthly with minor features and patches. Key differentiator: schema-agnostic, non-AI-dependent sync loop for agent context, supporting full CRUD, natural keys, soft-delete, FTS5/tsvector full-text search, bring-your-own embeddings for semantic search, token budgeting, and a local browser GUI with multiplayer cloud editing and offline edit queue. Unlike AI-memory-pattern libraries, Lattice leaves schema control entirely to the developer and adds no opinion on agent architecture.

npm install latticesql
INSTALL
IMPORT
SIG · LATTICESQL
L
latticesql
ai-mljavascriptv1.16.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (Lattice class)
import Lattice from 'latticesql'
const Lattice = require('latticesql')
ECMAScript module (ESM) only; CommonJS require is not supported because the package uses ES module syntax. TypeScript types are bundled.
Lattice (named)
import { Lattice } from 'latticesql'
const { Lattice } = require('latticesql')
Named import also works, but default import is more common. The package ships both default and named exports.
LatticeConfig (type)
import type { LatticeConfig } from 'latticesql'
Type-only import for TypeScript users. The package exports types inline.

Shows how to initialize Lattice with an in-memory SQLite database, define an entity, insert a record, render context, and read the output.

import Lattice from 'latticesql'; import Database from 'better-sqlite3'; // Initialize with a SQLite database const db = new Database(':memory:'); const lattice = new Lattice(db, { entities: { tasks: { fields: { id: 'integer', title: 'text', status: 'text' }, render: 'tasks.md', }, }, renderFile: 'context.md', }); await lattice.init(); // Insert a task await lattice.insert('tasks', { title: 'Example task', status: 'pending' }); // Render context await lattice.renderAll(); // Read rendered context const context = await lattice.readRenderFile(); console.log(context); await lattice.close();
Debug
Known issues
breakingVersion 1.16 introduced the .lattice workspace model; existing databases without a .lattice folder may not automatically upgrade the workspace directory structure.
fix
Run lattice migrate --workspace or manually create .lattice directory and run init({ workspace: true }).
affects: <1.16
breakingPeer dependency better-sqlite3 requires version >=11 <13; using an incompatible version will cause runtime errors.
fix
Install a compatible version: npm install better-sqlite3@'>=11 <13'
affects: >=1.16
deprecatedThe defineWriteback() method signature changed in v1.14: the old (table, options) arguments are deprecated in favor of a single options object.
fix
Update to new signature: defineWriteback({ table: 'my_table', parser: myParser }).
affects: <1.14
gotchaWhen using Postgres backend, the 'renderFile' option must be configured differently; the default behavior assumes SQLite.
fix
Explicitly set renderFile in Lattice constructor or use lattice.config.yml to define the file path.
affects: >=1.0
gotchaThe 'natural keys' feature requires that the entity's primary key is not auto-increment; using auto-increment integer keys with natural keys causes insert collisions.
fix
Define entity with a string-based primary key or set { autoIncrement: false } when using natural keys.
affects: >=1.0
Errors
Common errors & fixes
Cannot find package 'better-sqlite3' imported from 'latticesql'
The peer dependency better-sqlite3 is not installed.
fix
Run: npm install better-sqlite3@'>=11 <13'
SyntaxError: Unexpected token 'export'
Using require() to import an ESM-only package.
fix
Use import syntax or set type: 'module' in package.json.
Lattice is not a constructor
Incorrect import; likely imported the named export while expecting default.
fix
Use default import: import Lattice from 'latticesql'
lattice.init is not a function
Lattice instance not properly initialized (e.g., missing 'new' keyword).
fix
Use: const lattice = new Lattice(db, config); then await lattice.init();
Upgrade
Version history
1.16.4latest on npm
Audit
Dependencies
better-sqlite3optionalPeer dependency for SQLite backend (required when using SQLite).
Agent activity
9 hits · last 30 days
node
8
Resources