Open-source code + knowledge graph memory engine, fusing SAGE self-evolving graph memory with CodeGraph structural code understanding.
License: MIT · Runtime: Node.js ≥ 22 · Graph DB: Kuzu (embedded, Cypher) · No LLM required (deterministic)
EngramGraph is a general-purpose engine. The defaults ("single repo + generic markdown + git signals") work out of the box for any project; project-specific behaviour is supplied through pluggable adapters.
Vector search ("find me similar memories") and graph traversal ("find me structurally related nodes") are complementary. EngramGraph adds the graph half:
"I want to change
execute()→ the engine walks: callers → related specs → the decisions behind them."
npm install engramgraphOr run the CLI without installing:
npx engramgraph index ./src# 1. Index a repo into the graph (code + optional docs)
egr index ./src --docs
# 2. "What breaks if I change this function?"
egr callers myFunction --depth 2
# 3. "Which decisions sit behind this spec?"
egr impact SPEC-001The graph DB lives at ENGRAM_DB (default ./.engram/graph.db).
Full command reference: docs/CLI.md.
import { EmbeddedClient } from "engramgraph";
const client = new EmbeddedClient(); // SingleRepoIsolation by default
await client.init(); // opens graph.db + ensures schema
const rows = await client.query("MATCH (f:Function) RETURN f.name AS name");
await client.close();import { createServer, GraphConnection } from "engramgraph";
const conn = GraphConnection.open("./.engram/graph.db");
const app = createServer({ connection: conn }); // Hono app; routes under /graph/*
// GET /health → { status: "ok" }Or just egr serve --port 3000. API reference: docs/API.md.
| Mode | Entry | Use case |
|---|---|---|
| Embedded | EmbeddedClient |
Same-process, zero HTTP overhead (e.g. same-process integration) |
| REST | createServer() (Hono) / egr serve |
Standalone graph service; routes under /graph/* |
| MCP | egr-mcp (stdio) / egr mcp |
Plug-and-play for coding assistants (Claude Code, Codex, Cursor, ...) |
EngramGraph ships an MCP server (stdio) exposing 5 tools — index_code,
index_docs, call_chain, impact_analysis, ingest_feedback — so any
MCP-capable assistant can use it as a code + knowledge graph. Zero LLM,
deterministic, no Docker.
# Claude Code, from an installed package:
claude mcp add egr -- npx egr-mcpFull setup (Claude Code / Codex / Cursor / Windsurf), the 5 tools, and an example flow: docs/MCP.md.
| Layer | Contents | External usability |
|---|---|---|
| Generic Core | CodeGraph (tree-sitter → graph), SAGE evolution, Kuzu abstraction, REST/MCP/Embedded modes, node-sdk | Zero project-specific dependency |
| Pluggable Adapters (interfaces) | (1) knowledge source (2) isolation model (3) SAGE signal source | Core ships interface + a generic default |
- Knowledge source —
KnowledgeSource → { nodes, edges }. Default:MarkdownKnowledgeSourceparses any front-matter markdown (id/title/status+[[ref]]links) into genericDocnodes. - Isolation model —
IsolationModel.dbPath(ctx) → string. Default:SingleRepoIsolation(onegraph.db, no org concept). Opt-in:OrgProjectIsolation(org-{orgId}/project-{projectId}/graph.db). - SAGE signal source —
SignalSource → FeedbackEvent[]. Defaults:GitHistorySignalSource,TestExitCodeSignalSource.
6 node tables — Function, Class, Module, Spec, Decision, Doc.
7 relationship tables — CALLS, IMPORTS, DEFINES, IMPLEMENTS, IMPACTS,
SUPERSEDES, REFERENCES. See docs/API.md for the full DDL
and the front-matter schema that drives knowledge ingestion.
- Phase 1 — scaffold (MIT, Node 22, ESM+CJS, tsup, vitest), Kuzu
abstraction + idempotent schema (6 NODE / 7 REL tables), three adapter
interfaces + generic defaults, Hono
GET /health,EmbeddedClient - Phase 2 — CodeGraph: tree-sitter extractor/indexer, cross-file
CALLSresolution, scope-qualified function ids - Phase 3 — KnowledgeGraph: front-matter markdown →
Spec/Decision+IMPACTS/SUPERSEDESedges - Phase 4 — SAGE evolution layer: confidence feedback (
STEP0.25, floor 0.1),topByConfidence,rankedImpact - Phase 5 — REST routes (
/graph/call-chain,/graph/impact-analysis,/graph/ingest), MCP server (5 tools), standaloneegrCLI
See CONTRIBUTING.md for dev setup, the build/test/health loop, and the kuzu + tree-sitter teardown caveat. Changes are tracked in CHANGELOG.md.
MIT — see LICENSE.