Registry / database / cairn-index

cairn-index

JSON →
library1.2.1jsnpmunverified

Cairn is a local-first, daemon-free hybrid search index over a single SQLite file, combining FTS5 full-text search, vector embeddings (via sqlite-vec), and an AST-based knowledge graph for code and text. Version 1.2.1, latest stable release. It requires Node >=20 and an embedding model (default: Ollama with nomic-embed-text, optional embedded runtime via node-llama-cpp). Key differentiators: all-in-one file storage, no external dependencies beyond Ollama (or self-contained embedded runtime), built-in tree-sitter parsing for code entities and call graphs, MCP server for LLM integration, and RRF fusion for hybrid retrieval. Intended for curated personal knowledge bases, codebase indexing, and RAG with local LLMs.

npm install cairn-index
INSTALL
IMPORT
SIG · CAIRN-INDEX
C
cairn-index
databasejavascriptv1.2.1
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.

Cairn
import { Cairn } from 'cairn-index'
const Cairn = require('cairn-index')
ESM-only package; no CommonJS support. TypeScript types are shipped.
OllamaRuntime
import { OllamaRuntime } from 'cairn-index'
import OllamaRuntime from 'cairn-index'
Named export for Ollama runtime configuration.
EmbeddedRuntime
import { EmbeddedRuntime } from 'cairn-index'
Optional export for embedded llama.cpp runtime; only available if node-llama-cpp is installed.

Creates a Cairn instance with Ollama runtime, ingests a text snippet, and performs a hybrid search returning ranked chunks.

import { Cairn } from 'cairn-index'; import { OllamaRuntime } from 'cairn-index'; const cairn = new Cairn({ runtime: new OllamaRuntime('http://127.0.0.1:11434'), path: '~/.cairn', }); await cairn.ingest.add({ kind: 'text', content: 'Cairn is a local hybrid index.', label: 'doc' }); const results = await cairn.retrieve.search('hybrid index', { k: 5 }); console.log(results); cairn.close();
Debug
Known issues
breakingNode <20 is not supported. The package uses modern JavaScript features and will fail to run on older Node versions.
fix
Upgrade Node to version 20 or higher.
affects: <20
breakingESM-only: Cannot require() the package. Import must use ES module syntax.
fix
Use import { Cairn } from 'cairn-index' and ensure your project is configured for ES modules (e.g., type: 'module' in package.json).
affects: >=1.0.0
gotchaRequires an embedding model. By default, expects Ollama running with 'nomic-embed-text' pulled. If using embedded runtime, the model will auto-download (~785 MB) unless CAIRN_OFFLINE=1 is set.
fix
Start Ollama and pull nomic-embed-text: 'ollama pull nomic-embed-text'. For air-gapped use, pre-cache the model and set CAIRN_OFFLINE=1.
affects: >=1.0.0
gotchaThe embedded runtime auto-downloads a GGUF model on first use. In environments with restricted network access, this may fail or incur unexpected data transfer.
fix
Set CAIRN_OFFLINE=1 to disable automatic downloads and require pre-cached models.
affects: >=1.0.0
deprecatedThe 'runtime' option may change in future versions. Currently it accepts a string ('ollama' | 'embedded') or a runtime instance.
fix
Use the runtime instance approach (e.g., new OllamaRuntime(...)) which is more explicit and stable.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'cairn-index'
Package not installed or not installed in node_modules.
fix
Run 'npm install cairn-index' or 'pnpm add cairn-index'.
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'cairn-index'
ESM resolution fails due to missing package.json or incorrect import path.
fix
Ensure you are using 'import { Cairn } from 'cairn-index'' with correct casing and the package is in node_modules.
TypeError: cairn.ingest.add is not a function
Instantiating Cairn without the 'ingest' provider, or using an incompatible version.
fix
Verify you are using Cairn class correctly with proper initialization. Check version compatibility.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
better-sqlite3requiredSQLite driver with synchronous API and extension support
sqlite-vecrequiredVector search extension for SQLite
node-llama-cppoptionalEmbedded runtime for in-process embeddings and chat (optional, falls back to Ollama)
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources