Get context-engine-ai running in under 2 minutes.
npm install context-engine-aiimport { ContextEngine } from 'context-engine-ai'
const ctx = new ContextEngine()
await ctx.ingest({ type: 'message', data: { from: 'Alice', text: 'deploy is broken' } })
await ctx.ingest({ type: 'task', data: { title: 'Review PR #42', priority: 'high' } })
const result = await ctx.query('any issues?')
console.log(result.summary)
// => "[message] from: Alice, text: deploy is broken | [task] title: Review PR #42, priority: high"
await ctx.close()Pass a file path to keep events on disk:
const ctx = new ContextEngine({ dbPath: './my-context.db' })Standard SQLite file — inspect with any SQLite tool.
The summary field is formatted for direct use in system prompts:
const context = await ctx.query('what needs attention?', 5)
// Pass to any LLM
const systemPrompt = `You are a developer assistant. Current context:\n${context.summary}`One line:
ctx.serve(3334)Or via CLI:
npx context-engine-ai serve --port 3334Then use the REST API:
# Ingest
curl -X POST http://localhost:3334/ingest \
-H 'Content-Type: application/json' \
-d '{"type": "deploy", "data": {"service": "api", "version": "2.1.0"}}'
# Query
curl "http://localhost:3334/context?q=recent%20deployments"const ctx = new ContextEngine({
dbPath: './context.db', // Persist to file (default: in-memory)
maxEvents: 500, // Auto-prune after 500 events (default: 1000)
decayHours: 8, // Events lose relevance faster (default: 24)
deduplicationWindow: 30000, // 30s dedup window (default: 60s)
})Switch to PostgreSQL + OpenAI embeddings:
const ctx = new ContextEngine({
storage: 'postgres',
pgConnectionString: process.env.DATABASE_URL,
embeddingProvider: 'openai',
openaiApiKey: process.env.OPENAI_API_KEY,
})Requires PostgreSQL with the pgvector extension.
- Browse examples/ for runnable code
- Read Architecture Overview for how it works internally
- Read Custom Adapters to build your own storage or embedding backend