Local-First Cognitive Runtime

Don't memorize tokens.
Preserve semantics.

CORTEXTA is a local-first cognitive runtime for software teams that want durable, queryable project memory. It ingests repositories and chat history, compacts large payloads into deterministic envelopes, resurrects content on demand, and compiles relevance-ranked context for coding agents and developer tooling.

"A Developer Memory OS with semantic retrieval, compaction and resurrection, CX-LINK APIs, and a production-ready TypeScript CLI."
98% compaction ratio
cortexa · home
 ██████╗ ██████╗ ██████╗ ████████╗███████╗██╗  ██╗ █████╗ 
██╔════╝██╔═══██╗██╔══██╗╚══██╔══╝██╔════╝╚██╗██╔╝██╔══██╗
██║     ██║   ██║██████╔╝   ██║   █████╗   ╚███╔╝ ███████║
██║     ██║   ██║██╔══██╗   ██║   ██╔══╝   ██╔██╗ ██╔══██║
╚██████╗╚██████╔╝██║  ██║   ██║   ███████╗██╔╝ ██╗██║  ██║
 ╚═════╝ ╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝

CORTEXA CLI
Local-first memory runtime for your dev workflow.
──────────────────────────────────────────────────────────────────────────────────────
Quick start
  $ pnpm run cortexa -- init
  $ pnpm run cortexa -- ingest .
  projectId auto-inferred from folder name (override with --project-id=<id>)
  $ pnpm run cortexa -- query "how did we solve retry jitter?"
  $ pnpm run cortexa -- context "prepare implementation plan"
  $ pnpm run cortexa -- llm status
  $ pnpm run cortexa -- agents list
  $ pnpm run cortexa -- evolve "upgrade progression telemetry" --project-id=my-project --dry-run

Core commands
  init                                 Initialize SQLite schema and vector collection.
  ingest [path] [options]              Ingest code and optional chats; projectId auto-inferred unless overridden.
  llm <status|train|preview> [options] Train/use the quantized local mini LLM for agent-memory workflows.
  query <text>                         Run hybrid retrieval over memories.
  context <text>                       Compile a token-bounded context payload.
  agents <list|run> [options]          List/run Cortexa agents and multi-agent loops.
  evolve <text> [options]              Run progression evolution and emit stage telemetry.
  daemon <start|stop|status>           Control local daemon API runtime.

Memory commands
  memory list [projectId] [--limit=<n>]                List recent memories.
  memory search <query> [--project-id=<id>]            Search memory store with scoring.
  memory get <id> [--full]                             Show memory content.
  memory resurrect <id> [--full]                       Read restored compact content.
  memory delete <id>                                   Delete one memory item.
  memory stats [--project-id=<id>]                     Compaction and integrity stats.
  memory opportunities [--project-id=<id>]             Top estimated compaction savings from plain rows.
  memory audit [--project-id=<id>] [--limit=<n>]       Resurrection integrity audit + repair guidance.
  memory backfill [--apply] [--limit=<n>]              Dry-run/apply compaction backfill.
  memory dashboard [options]                           Compaction dashboard payload/report.

Aliases + help
  dashboard [options]                  Alias of: memory dashboard [options].
  help | -h | --help                   Show this home screen.

──────────────────────────────────────────────────────────────────────────────────────
Tip: use -- after pnpm script invocation, e.g. pnpm run cortexa -- dashboard --json --out-json=./tmp/dashboard.json
4D hybrid retrieval
Release timeline recent work surfaced in the v0.1.3 update
3
Vector Backends
Brotli
Compression Engine
18+
CLI Commands
Local
First by Design

What is Cortexta?

A local-first cognitive runtime that transforms how developers manage, retrieve, and utilize institutional knowledge across projects.

Semantic Memory Store

Hybrid storage combines SQLite metadata with vector indexes (Qdrant, Chroma, or in-memory). Code snippets, design notes, and chat transcripts become searchable memory units with stable, project-scoped identity.

Intelligent Compaction

Memory units are compacted with Brotli into deterministic envelopes. Content is resurrected at read time, reducing storage footprint while preserving checksums, previews, and operational recoverability.

Hybrid Retrieval

Combines vector similarity with lexical ranking to surface the most relevant context. Token-bounded context compilation controls prompt size for coding assistants and CLI workflows that require concise, trustworthy context.

CX-LINK APIs

The daemon exposes HTTP and WebSocket endpoints for query, context compilation, evolution tracking, and compaction operations, enabling integration with editors, agents, and CI tools.

Compaction Analytics

Persistent trend snapshots and per-project anomaly reporting expose integrity issues such as invalid checksums and decode errors, making maintenance predictable over long-running projects.

Local-First by Design

Your code and conversations never leave your machine unless you choose. Full control over vector backends, embedding services, data paths, and daemon exposure boundaries.

What's new — v0.1.3 highlights

Recent operator-facing additions, stability fixes, and UX polish. Full details are available in the CHANGELOG, on the GitHub release page, and in the commit trail below.

🆕

LLM runtime status & diagnostics

Added runtime LLM diagnostics surfaced via POST /cxlink/llm/status and the CLI cortexa llm status --runtime. Operators can now see effective mode, timeout, reachable state, last success/error and diagnostic hints for faster root cause analysis.

How to test
pnpm run cortexa -- llm status --runtime
curl -s -X POST http://localhost:4312/cxlink/llm/status \
  -H "content-type: application/json" \
  -d '{"projectId":"my-project"}'
Expected: the runtime response includes effective mode, timeout, reachability, last success/error, and diagnostic hints.
⚙️

Deterministic ingestion policy

Project-level ingestion via cortexa.policy.json is supported: include/exclude globs, language filters, redaction rules and size limits. The ingestion pipeline applies policy-driven filtering and redaction before persisting memories.

How to test
pnpm run cortexa -- ingest . --policy-check
pnpm run cortexa -- ingest . --policy=.\cortexa.policy.json --max-files=25
Expected: validation passes, ingestion respects include/exclude rules, and the summary shows the filtered scope/redactions applied.
🔁

Context stream stability fix

Improved live context streaming: suggestions are no longer suppressed when compiled context text exists but stored memory counts are zero (useful during inline/ephemeral compilations). This resolves a test-time suppression that prevented valid contextDeltaSuggested events.

How to test
pnpm run test:context-stream
# optional live check
pnpm run cortexa -- daemon start
Expected: the integration test passes and the live stream emits contextDeltaSuggested when compiled context exists.
🧠

Mini LLM & CLI improvements

Quantized local mini-LLM support for compact n-gram inference and JSON schema completions. CLI surface expanded with llm train, llm preview, and improved llm status outputs.

How to test
pnpm run cortexa -- llm train . --project-id=my-project --max-vocab=4096
pnpm run cortexa -- llm preview "summarize the release" --max-tokens=96
Expected: training produces a model artifact, preview returns schema-aware text, and status reports the mini LLM runtime details.
Open Live CLI Site View v0.1.3 on GitHub

Architecture

Modular, layered design separating CLI concerns from the core memory engine.

CLI Layer — primary entry point (cortexa)
ingest
code + chat pipeline
query
hybrid retrieval
context
token-bounded compiler
memory
list / get / resurrect / delete
dashboard
compaction analytics
daemon
HTTP + WS runtime
Daemon Layer — local HTTP + WebSocket APIs
HTTP :4312
RESTful endpoints
WS :4321
streaming socket
CX-LINK API
context + evolution
Auth Token
token-based auth
Mempalace Engine — core memory runtime
Ingestion
AST parse · chunk · embed
Retrieval
hybrid rank · top-k filter
Compaction
Brotli envelope · checksum
Context Compiler
token-bounded assembly
Storage Layer — persistence + indexing
SQLite
metadata + snapshots
data/cortexa.db
Qdrant
vector index
localhost:6333
Chroma
vector index
localhost:8001
In-Memory
ephemeral fallback
no persistence

Memory Ingestion

How raw source files and chat transcripts become searchable memory units.

INGESTION PIPELINE
Source Files
.ts · .js · .py · …
Chat Transcripts
Copilot sessions
AST Parser
parse + hint extract
Chunker
size-bounded splits
embed
Embedder
vector generation
store
SQLite
metadata + tags
Vector Index
Qdrant / Chroma
compact?
Compactor
Brotli envelope
Input sources Parse / chunk Embedding Persistence Compaction (optional, threshold-triggered)

Memory Resurrection

How a compact envelope is verified, decoded, and assembled into a prompt-ready context block.

RESURRECTION PIPELINE
Query
natural language
hybrid
Ranker
vec + lex · top-k
retrieve
Compact Envelope
cortexa://mem/v1/
verify
Checksum
SHA integrity check
decode
Brotli Decode
br64 → raw content
assemble
Context Compiler
token-bounded prompt
Anomaly Path
If checksum fails (invalidChecksum) or Brotli decode throws (decodeError), the anomaly is recorded in the compaction analytics dashboard and the memory unit is flagged for backfill. The preview text is served as a fallback, and context compilation continues with remaining healthy units.
Query input Ranking / output Envelope Integrity Decode

Primary CLI

  • TypeScript-based command interface
  • Lazy-loaded daemon commands
  • Intentional -- delimiter support
  • Health checks & type validation

Mempalace Engine

  • SQLite + better-sqlite3 for metadata
  • Pluggable vector providers
  • Hybrid ranking algorithms
  • Token-bounded packing logic

Ingestion Pipeline

  • AST-derived code parsing & chunking
  • Copilot chat transcript ingestion
  • Configurable file size limits
  • Project-scoped memory grouping

Compaction Layer

  • Brotli-compressed envelope format
  • Deterministic resurrection at read time
  • Checksum verification & anomaly tracking
  • Dry-run backfill with apply gates

Daemon APIs

  • HTTP server on port 4312
  • WebSocket stream on port 4321
  • Token-based authentication
  • RESTful + CX-LINK endpoints

Context Compiler

  • Token-bounded prompt assembly
  • Copilot-friendly content summaries
  • Relevance-ranked memory injection
  • Project-scoped context filtering

Working Process

From ingestion to retrieval — the complete lifecycle of a memory unit in CORTEXTA.

01

Ingestion

Codebases and chat histories are parsed, chunked, and enriched with AST-derived hints. Each unit receives metadata tags, project IDs, and embedding vectors before entering the memory store.

AST parsing chunking embedding copilot transcripts
02

Storage & Indexing

Memory units are persisted in SQLite with full metadata. Vector embeddings are indexed via Qdrant, Chroma, or an in-memory fallback. The system maintains referential integrity between lexical and semantic indexes.

SQLite Qdrant Chroma hybrid index
03

Compaction

Large memory payloads are compressed into compact envelopes using Brotli. The envelope format cortexa://mem/compact/v1/ preserves preview text and checksums. Original content is replaced by the compact envelope to save space.

Brotli br64 codec checksum envelope format
04

Resurrection

When a memory unit is retrieved, the compaction layer deterministically resurrects the original content from its envelope. Integrity is verified via checksum. Anomalies (invalidChecksum, decodeError) are tracked for dashboard reporting.

read-time decode integrity check anomaly tracking
05

Retrieval & Ranking

User queries trigger hybrid retrieval — combining vector similarity scores with lexical matching. Results are ranked by relevance and filtered by project scope, minimum score thresholds, and top-k limits.

semantic search lexical ranking top-k filtering
06

Context Compilation

Retrieved memories are packed into a token-bounded context payload. Copilot-friendly summaries reduce token cost while preserving semantic meaning. The result is a prompt-ready context block for any coding agent.

token budgeting copilotContent prompt assembly

Raw Content

Source code & chat logs

Compact Envelope

Brotli + br64 encoding

Persisted Store

SQLite + vector index

Resurrected

Original content restored

Use Cases

Where Cortexta creates immediate leverage for real development teams.

Solo Developer Continuity

Keep architectural decisions, implementation details, and debugging trails available across days or weeks, even when context switching between projects.

Team Handoffs

Transfer project memory between teammates with queryable provenance, reducing repeated explanations and preserving the rationale behind key changes.

Incident Postmortems

Search historical fixes, recovery steps, and environment constraints to accelerate incident diagnosis and strengthen prevention playbooks.

Multi-Agent Workflows

Feed planners, writers, and refactor agents with compact, ranked context so each step starts from shared memory instead of repeated prompt priming.

Platform Grade

A practical scorecard based on architecture depth, operational design, and developer usability.

Architecture

A

Clear layering across CLI, core engine, storage, and daemon interfaces.

Developer Experience

A-

Strong command surface and observability, with room for guided onboarding presets.

Observability

B+

Compaction analytics and anomaly tracking are strong and improving release by release.

Performance Potential

A-

Efficient compaction and bounded context packing align well with local-first constraints.

Security Posture

B

Good local-first boundaries and daemon token support; policy hardening can extend further.

Overall grade: A- — a robust foundation for long-lived developer memory, with the highest upside in standardized secure defaults and larger-scale team onboarding paths.

Operator Playbook

A concrete, field-friendly flow for turning raw repositories into durable team intelligence.

First 60 minutes: from cold clone to trusted context

A realistic onboarding arc you can run on day one of a legacy service takeover.

  • 00:05

    Establish memory substrateInitialize local persistence and vector setup with pnpm run cortexa -- init.

  • 00:15

    Ingest repo + historical chatRun ingestion with explicit project scope to preserve lineage across future branches and incident threads.

  • 00:30

    Probe semantic coverageIssue targeted queries (auth, retries, migrations, rollbacks) and inspect whether retrieved evidence reflects true implementation intent.

  • 00:45

    Compile agent-ready contextGenerate prompt-bounded bundles via context so automation begins from project memory instead of prompt guesswork.

  • 01:00

    Lock in maintenance rhythmSchedule periodic memory audit and dry-run memory backfill to keep compaction healthy over long-lived projects.

Decision Signals Matrix

A lightweight control table for deciding whether to keep, repair, or escalate memory operations.

Moment Check Signal Action
Coverage drift memory search Low-recall answers for known topics Re-ingest recent diffs + chats for missing feature slices.
Integrity alert memory audit invalidChecksum / decodeError detected Queue backfill and review high-impact items first.
Prompt overflow context Token budget clipping critical rationale Tighten top-k, raise score floor, rerun context compile.
Incident mode query Multiple plausible but conflicting fixes Prioritize newest + highest score, then attach provenance trail.

Solo Builder

Optimize for continuity and fast recall between intense deep-work sessions and context switches.

daily ingest query loops light audits

Team Delivery

Optimize for onboarding velocity and cross-branch memory consistency across rotating contributors.

project-id discipline handoff queries weekly dashboard

Incident Command

Optimize for evidence clarity under pressure, ensuring rollback and mitigation memory are instantly retrievable.

hot query sets resurrection checks postmortem capture

Project Roadmap

Loading roadmap…

System Diagrams

Key architectural views, data flows, and operational patterns.

graph TB A["CLI Interface
(cortexa)"] B["Daemon Core
(HTTP/WS)"] C["Context
Engine"] D["Ingestion
Pipeline"] E["Memory Palace
(Vector DB)"] F["Graph Store
(Relationships)"] G["LLM
Adapter"] H["Retrieval
Engine"] I["Agent
Orchestrator"] A -->|commands| B B -->|manages| C B -->|coordinates| I C -->|ingests| D D -->|stores| E D -->|indexes| F I -->|queries| H H -->|searches| E H -->|traverses| F B -->|calls| G G -->|scores| E style A fill:#3ecfb2,stroke:#2baa93,color:#03080f style B fill:#8b76d6,stroke:#6b5bb8,color:#03080f style C fill:#4e8fd4,stroke:#3a6fb5,color:#fff style D fill:#c9973a,stroke:#a97a29,color:#fff style E fill:#3db383,stroke:#2d9170,color:#fff style F fill:#b85f8e,stroke:#9a4a74,color:#fff style G fill:#c2763d,stroke:#a4612f,color:#fff style H fill:#4e8fd4,stroke:#3a6fb5,color:#fff style I fill:#8b76d6,stroke:#6b5bb8,color:#03080f
graph LR A["File Input"] B["Parser"] C["Tokenizer"] D["Embedder"] E["Feature
Extractor"] F["Vector
Storage"] G["Graph
Index"] H["Metadata
Store"] A -->|bytes| B B -->|text| C C -->|tokens| D D -->|embeddings| F D -->|features| E E -->|scoring| G B -->|metadata| H style A fill:#3ecfb2,stroke:#2baa93,color:#03080f style B fill:#c9973a,stroke:#a97a29,color:#fff style C fill:#c9973a,stroke:#a97a29,color:#fff style D fill:#8b76d6,stroke:#6b5bb8,color:#03080f style E fill:#4e8fd4,stroke:#3a6fb5,color:#fff style F fill:#3db383,stroke:#2d9170,color:#fff style G fill:#b85f8e,stroke:#9a4a74,color:#fff style H fill:#c2763d,stroke:#a4612f,color:#fff
graph LR A["Ingestion"] --> B["Embedding"] B --> C["Storage"] C --> D["Active Memory"] D --> E["Temporal Index"] E --> F["Compaction"] F --> G["Archive"] D --> H["Retrieval"] style A fill:#3ecfb2,stroke:#2baa93,color:#03080f style B fill:#8b76d6,stroke:#6b5bb8,color:#fff style C fill:#4e8fd4,stroke:#3a6fb5,color:#fff style D fill:#3db383,stroke:#2d9170,color:#fff style E fill:#c9973a,stroke:#a97a29,color:#fff style F fill:#b85f8e,stroke:#9a4a74,color:#fff style G fill:#c2763d,stroke:#a4612f,color:#fff style H fill:#4e8fd4,stroke:#3a6fb5,color:#fff
graph TB A["Task Request"] B["Router
Agent"] C["Planner
Agent"] D["Writer
Agent"] E["Refactor
Agent"] F["Critic
Agent"] G["Compressor
Agent"] H["Output
Queue"] A -->|classify| B B -->|route| C C -->|decompose| D D -->|generate| H C -->|decompose| E E -->|optimize| H D -->|review| F E -->|review| F F -->|validate| H H -->|prepare| G G -->|memory| H style A fill:#3ecfb2,stroke:#2baa93,color:#03080f style B fill:#8b76d6,stroke:#6b5bb8,color:#03080f style C fill:#4e8fd4,stroke:#3a6fb5,color:#fff style D fill:#c9973a,stroke:#a97a29,color:#fff style E fill:#3db383,stroke:#2d9170,color:#fff style F fill:#b85f8e,stroke:#9a4a74,color:#fff style G fill:#c2763d,stroke:#a4612f,color:#fff style H fill:#8b76d6,stroke:#6b5bb8,color:#03080f
graph LR A["Query
Input"] B["Embedding
Encode"] C["Vector
Search"] D["Graph
Traversal"] E["Re-ranking
by Relevance"] F["Context
Assembly"] G["Output
Prompt"] A -->|text| B B -->|vector| C C -->|top-k| E D -->|links| E E -->|scored| F F -->|templated| G style A fill:#3ecfb2,stroke:#2baa93,color:#03080f style B fill:#8b76d6,stroke:#6b5bb8,color:#03080f style C fill:#4e8fd4,stroke:#3a6fb5,color:#fff style D fill:#b85f8e,stroke:#9a4a74,color:#fff style E fill:#c9973a,stroke:#a97a29,color:#fff style F fill:#3db383,stroke:#2d9170,color:#fff style G fill:#c2763d,stroke:#a4612f,color:#fff

Primary CLI

The cortexa command is the single entry point for all operations.

init Bootstrap

Initialize SQLite schema and vector collection bootstrap.

pnpm run cortexa -- init
ingest Ingestion

Ingest code and chat sessions into the memory store.

pnpm run cortexa -- ingest . --project-id=my-service
query Retrieval

Hybrid memory retrieval with natural language queries.

pnpm run cortexa -- query "how did we harden websocket streaming?"
context Compilation

Compile a prompt-ready context payload for coding agents.

pnpm run cortexa -- context "add retry-safe checkpointing"
memory Lifecycle

Memory operations: list, search, get, resurrect, delete, stats, backfill, dashboard.

pnpm run cortexa -- memory resurrect <id>
pnpm run cortexa -- memory backfill --apply
daemon Runtime

Manage the local HTTP + WebSocket daemon runtime.

pnpm run cortexa -- daemon start
pnpm run cortexa -- daemon status
llm Local Model

Inspect and operate the local quantized mini-LLM workflow.

pnpm run cortexa -- llm status
pnpm run cortexa -- llm preview "summarize session memory"
agents / evolve Automation

List available agents and run progression-aware memory evolution loops.

pnpm run cortexa -- agents list
pnpm run cortexa -- evolve "improve retrieval relevance" --project-id=my-service

Configuration

Environment variables for storage, vector backends, compaction, and daemon behavior.

Variable Default Description
CORTEXA_DB_PATH data/cortexa.db SQLite database file path
CORTEXA_VECTOR_PROVIDER qdrant Vector backend: qdrant | chroma | memory
CORTEXA_VECTOR_URL http://localhost:6333 Qdrant endpoint URL
CORTEXA_CHROMA_URL http://localhost:8001 Chroma endpoint URL
CORTEXA_EMBEDDING_URL Optional external embedding service
CORTEXA_INGEST_MAX_FILE_BYTES 786432 Maximum file size for ingestion (768 KB)
CORTEXA_DAEMON_PORT 4312 HTTP daemon port
CORTEXA_WS_PORT 4321 WebSocket port
CORTEXA_DAEMON_TOKEN Authentication token for daemon
CORTEXA_DAEMON_BODY_LIMIT 6mb Max request body size
CORTEXA_DAEMON_AUTOSTART 1 Set to 0 to disable daemon module auto-start.
CORTEXA_LLM_MODE mini-local LLM operation mode. Use off or disabled to bypass local generation.
CORTEXA_LLM_MODEL_PATH data/llm/cortexa-mini-llm.q8.json Path to local mini-LLM weights used by llm commands.
CORTEXA_LLM_HF_TOKEN Optional Hugging Face token for authenticated dataset/model fetch workflows.
CORTEXA_DAEMON_RATE_LIMIT_MAX 240 Maximum request count per rate-limit window when limiter is enabled.
CORTEXA_METRICS_REQUIRE_AUTH true Protect /metrics behind daemon authentication checks.
CORTEXA_MEM_COMPACT_BROTLI_QUALITY Brotli compression quality level (0–11, higher favors ratio over speed)