SQL on one side.
Markdown on the other.
Lattice is the engine that models your data and serves it — a bidirectional sync between a database (SQLite or Postgres) and the rendered Markdown your apps and agents read, plus a local REST API and MCP server to serve it live. Your schema, your render specs, your writeback.
Install
The library, the CLI, or a self-updating one-liner. Node 18+. Just want the app? Get the desktop install →
Library
npm install latticesqlCLI + local GUI
npm install -g latticesql
lattice gui # opens the GUI at http://localhost:4317One-liner (macOS / Linux) — brings its own Node if you need it
curl -fsSL https://latticedesktop.com/install.sh | shQuick Start
Define a table. Render a context file. Watch it stay in sync.
import { Lattice } from 'latticesql';
const db = new Lattice('./state.db');
db.define('projects', {
columns: {
id: 'TEXT PRIMARY KEY',
name: 'TEXT NOT NULL',
status: 'TEXT',
owner: 'TEXT',
},
render: 'default-table',
outputFile: 'PROJECTS.md',
});
await db.init();
await db.render('./context');
// → context/PROJECTS.md, ready for any agent to readPrimitives
define()Declare tables with typed columns. Lattice manages schema migrations.
render specsBuilt-in (table/list/detail/json) or your own function. Token-budgeted, cache-friendly.
defineWriteback()Watch a file, parse agent output back into rows. Bidirectional sync, your parser, your validation.
entity contextsOne directory per row with custom templates. Per-entity scope, no monolithic context dumps.
reward trackingScore rows on use and prune below a threshold — a manual, inspectable signal, not a black-box training loop.
adaptersSQLite via better-sqlite3 (sync, local) or Postgres via pg (async, shared). Same API.
Writeback — Agents as Data Producers
Render specs go SQL → markdown. Writeback pipelines go markdown → SQL. Agent output lands as rows you can query.
db.defineWriteback('agent-notes', {
watchFile: 'context/NOTES.md',
parse(content) {
// Your parser. Returns rows to upsert.
return parseMarkdownNotes(content);
},
persist(rows) {
return db.upsert('notes', rows);
},
});
await db.watch('./context');
// → Agent writes to NOTES.md. Lattice parses + persists to SQL.Serve it: REST + MCP
Lattice exposes your modeled data over a local REST API — CRUD plus full-text, semantic, and graph search — and over MCP, so any agent can read your source of truth without a file on disk.
# Serve your modeled data over a local REST API
curl http://localhost:4317/api/tables/projects/rows
# Full-text, semantic, and graph-augmented search
curl "http://localhost:4317/api/search?q=overdue+invoices"
# ...and over MCP, so any agent can read your source of
# truth — no file on disk required.
# Point your MCP-capable client at the Lattice endpoint.SQLite Adapter
Synchronous. Local. Fast.
Backed by better-sqlite3. Sub-ms lookups. WAL mode. Ideal for per-developer or per-agent state.
Postgres Adapter
Async. Shared. Production-ready.
Backed by pg. Same Lattice API. Auto-detected from a postgres:// connection string. Use for team-shared state.
Read the Full API.
Schemas, render specs, writeback, entity contexts, reward tracking, adapters — everything in one reference.