Architecture

100 TypeScript files. 18,000+ lines. Zero dependencies on any AI provider.

File structure

tree
src/
├── commands/        # CLI commands (init, status, search, etc.)
├── memory/          # Knowledge Graph engine (SQLite, 15 tables)
├── extraction/      # Entity-relationship extraction + verification
├── signal/          # Thalamus, activation, spreading activation
├── senses/          # 6 senses (code, tone, emotion, health, stability, context)
├── learning/        # Hebbian, self-tuner, engrams, cold start
├── consolidation/   # NREM/REM sleep, reconsolidation, schemas
├── regulation/      # Echo system, metacognition, self-model, user-model
├── meta/            # AI profiles, development phases, idle brain
├── hooks/           # Provider integration (session-start, user-prompt, etc.)
├── watcher/         # Background daemon (HTTP port 7899)
├── mcp/             # MCP server (7 tools, stdio JSON-RPC)
├── tacit/           # Knowledge hunger, curiosity system
├── hygiene/         # Pruning, garbage collection, brain maintenance
├── providers/       # Multi-provider detection + configuration
├── llm/             # Cloud LLM client (OpenAI, Anthropic, etc.)
├── dashboard/       # 3D brain visualization
└── config.ts        # Central configuration

Tech stack

  • Runtime: Node.js + TypeScript
  • Database: better-sqlite3 (Knowledge Graph)
  • CLI: Commander.js + @clack/prompts
  • LLM Analysis: OpenAI API (gpt-4o-mini) or any compatible endpoint
  • Embeddings: text-embedding-3-small (hybrid search)
  • Dashboard: Vanilla HTML + Three.js (3D visualization)

Database: 15 tables

TablePurpose
nodesKnowledge entities (facts, preferences, decisions...)
edgesWeighted relationships between nodes
chunksRaw conversation chunks for processing
patternsDetected recurring patterns and schemas
moodsEmotional state tracking
outcomesSomatic markers — what worked, what didn't
raw_bufferIncoming data before Thalamus filtering
knowledge_gapsDetected holes in knowledge (hunger system)
sessionsSession metadata (provider, timestamps, messages)
snapshotsBrain state at points in time (growth tracking)
expertiseSkill levels and domain expertise
hot_memoryCurrently activated nodes (working memory)
signal_countersThalamus signal tracking
tacit_patternsImplicit knowledge patterns
system_stateGlobal brain state (phase, mood, thresholds)