Labsco
gzoonet logo

GZOO Cortex

β˜… 17

from gzoonet

Local-first knowledge graph for developers. Watches project files, extracts entities and relationships via LLMs, and lets you query across projects with natural language and source citations.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredNeeds API keys

GZOO Cortex

GZOO Cortex β€” Local-first knowledge graph for developers

Local-first knowledge graph for developers. Watches your project files, extracts entities and relationships using LLMs, and lets you query across all your projects in natural language.

β€œWhat architecture decisions have I made across projects?”

Cortex finds decisions from your READMEs, TypeScript files, config files, and conversation exports β€” then synthesizes an answer with source citations.

Why

You work on multiple projects. Decisions, patterns, and context are scattered across hundreds of files. You forget what you decided three months ago. You re-solve problems you already solved in another repo.

Cortex watches your project directories, extracts knowledge automatically, and gives it back to you when you need it.

What It Does

  • Watches your project files (md, ts, js, py, json, yaml) for changes
  • Extracts entities: decisions, patterns, components, dependencies, constraints, action items
  • Infers relationships between entities across projects
  • Detects contradictions when decisions conflict
  • Queries in natural language with source citations
  • Searches semantically β€” blends keyword and vector (embedding) similarity so queries match by meaning, not just keywords (optional; see Semantic Search)
  • Routes intelligently between cloud and local LLMs
  • Respects privacy β€” restricted projects never leave your machine
  • Web dashboard with knowledge graph visualization, live feed, and query explorer
  • MCP server for direct integration with Claude Code

How It Works

Cortex runs a pipeline on every file change:

  1. Parse β€” file content is chunked by a language-aware parser (tree-sitter for code, remark for markdown)
  2. Extract β€” LLM identifies entities (decisions, components, patterns, etc.)
  3. Relate β€” LLM infers relationships between new and existing entities
  4. Detect β€” contradictions and duplicates are flagged automatically
  5. Store β€” entities, relationships, and vectors go into SQLite + LanceDB
  6. Query β€” natural language queries search the graph and synthesize answers

All data stays local in ~/.cortex/. Only LLM API calls leave your machine (and never for restricted projects).

LLM Providers

Cortex is provider-agnostic. It supports:

  • Anthropic Claude (Sonnet, Haiku) β€” via native Anthropic API
  • Google Gemini β€” via OpenAI-compatible API
  • DeepSeek (Reasoner, Chat) β€” strong reasoning, very affordable
  • Groq β€” fast inference with free tier
  • Any OpenAI-compatible API β€” OpenRouter, local proxies, etc.
  • Ollama (Mistral, Llama, etc.) β€” fully local, no cloud required

Cost tracking uses provider-aware rates for DeepSeek, Gemini, Groq, and OpenRouter models β€” not a blanket Anthropic fallback.

Embeddings (for semantic search) are configured as a separate provider β€” independent of your chat model β€” so you can run chat on DeepSeek and embeddings on OpenAI. See Semantic Search.

Routing Modes

ModeCloud CostQualityOllama Required
cloud-firstVaries by providerHighestNo
hybridReducedHighYes
local-firstMinimalGoodYes
local-only$0GoodYes

In cloud-first mode, all tasks route to your cloud provider. Ollama is not required and is only used if budget fallback is enabled. Hybrid mode routes high-volume tasks (entity extraction, ranking) to Ollama and reasoning-heavy tasks (relationship inference, queries) to your cloud provider.

Commands

CommandDescription
cortex initInteractive setup wizard
cortex doctorValidate config, providers, projects, secrets, and database
cortex projects add/list/remove/showManage registered projects
cortex serveWeb dashboard + API + file watcher (port 3710)
cortex watch [project]CLI-only file watcher
cortex ingest <file-or-glob>One-shot file ingestion (separate from Live Feed)
cortex reindex [project]Rebuild the semantic (embedding) search index for existing entities
cortex query <question>Natural language query with citations
cortex find <term>Find entities by name
cortex statusGraph stats, costs, provider status
cortex costsDetailed cost breakdown
cortex contradictionsList active contradictions
cortex resolve <id>Resolve a contradiction
cortex models list/pull/test/infoManage Ollama models
cortex mcpStart MCP server for Claude Code
cortex reportPost-ingestion summary
cortex privacy set/listSet directory privacy
cortex config list/get/set/validateRead/write configuration
cortex config exclude add/remove/listManage file/directory exclusions
cortex stop / cortex restartManage running watch/serve processes
cortex dbDatabase operations

Full CLI reference: docs/cli-reference.md

Web Dashboard

Run cortex serve to open a full web dashboard at http://localhost:3710 with:

  • Dashboard Home β€” graph stats, recent activity, entity type breakdown
  • Knowledge Graph β€” interactive D3-force graph with clustering, click to explore
  • Live Feed β€” real-time file change and entity extraction events via WebSocket (from cortex serve only)
  • Query Explorer β€” natural language queries with streaming responses
  • Contradiction Resolver β€” review and resolve conflicting decisions

Remote Deployment

For access beyond localhost, bind to all interfaces and put Cortex behind a reverse proxy:

cortex serve --host 0.0.0.0

Example nginx config β€” protect /api/ and /ws with basic auth; serve static assets without auth (the dashboard injects the bearer token into HTML):

location /api/ {
    auth_basic "Cortex";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://127.0.0.1:3710;
    proxy_set_header Authorization "Bearer $CORTEX_TOKEN";
}

location /ws {
    auth_basic "Cortex";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://127.0.0.1:3710;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

location / {
    auth_basic off;
    proxy_pass http://127.0.0.1:3710;
}

Set CORTEX_SERVER_AUTH_TOKEN or server.auth.token in config. When auth is enabled, Cortex injects the token into the dashboard HTML so API and WebSocket calls authenticate automatically.

MCP Server (Claude Code Integration)

Cortex includes an MCP server so Claude Code can query your knowledge graph directly:

claude mcp add cortex --scope user -- npx @gzoo/cortex mcp

This gives Claude Code 12 tools:

ToolDescription
cortex_askNatural language questions about your projects
get_statusSystem status and graph stats
list_projectsList registered projects
find_entityLook up entities by name
query_cortexStructured knowledge graph queries
get_contradictionsList detected contradictions
resolve_contradictionResolve a contradiction
search_entitiesSearch entities with filters
ingest_fileTrigger file ingestion
add_projectRegister a new project
remove_projectUnregister a project
session_briefContext summary for current session

Architecture

Monorepo with eight packages:

  • @cortex/core β€” types, EventBus, config loader, error classes
  • @cortex/ingest β€” file parsers (tree-sitter + remark), chunker, watcher, pipeline
  • @cortex/graph β€” SQLite store, LanceDB vectors, query engine
  • @cortex/llm β€” Anthropic/Gemini/OpenAI-compatible/Ollama providers, router, prompts, cache
  • @cortex/cli β€” Commander.js CLI
  • @cortex/mcp β€” Model Context Protocol server (stdio transport, 12 tools)
  • @cortex/server β€” Express REST API + WebSocket relay
  • @cortex/web β€” React + Vite + D3 web dashboard

Architecture docs: docs/

Privacy & Security

  • Files classified as restricted are never sent to cloud LLMs
  • Sensitive files (.env, .pem, .key) are auto-detected and blocked
  • API key secrets are scanned and redacted before any cloud transmission
  • All data stored locally in ~/.cortex/ β€” nothing phones home

Full security architecture: docs/security.md

Built With

  • SQLite via better-sqlite3 β€” entity and relationship storage
  • LanceDB β€” vector embeddings for semantic search
  • Anthropic Claude β€” cloud LLM provider
  • Google Gemini β€” cloud LLM provider (via OpenAI-compatible API)
  • DeepSeek β€” cloud LLM provider (reasoning + chat)
  • Groq β€” fast cloud inference
  • Ollama β€” local LLM inference
  • tree-sitter β€” language-aware file parsing
  • Chokidar β€” cross-platform file watching
  • Commander.js β€” CLI framework
  • React + Vite β€” web dashboard
  • D3 β€” knowledge graph visualization

About

Built by GZOO β€” an AI-powered business automation platform.

Cortex started as an internal tool to maintain context across multiple client projects. We open-sourced it because every developer who works on more than one thing loses context, and we think this approach β€” automatic file watching + knowledge graph + natural language queries β€” is the right way to solve it.