System Architecture
Explore the internal pipeline that maps, stores, and compresses repository contexts locally.
AST Relational Parser & Watcher
Parses files statically using tree-sitter compiler definitions to extract symbols, implementations, and call relationships. Monitored by a background fsnotify watchdog.
Relevant Repository Files
- internal/watcher/watcher.go
- internal/watcher/watchdog.go
- internal/parser/ast.go
Pipeline Subcomponents
1. Tree-sitter AST Parser
Statically parses source code to compile tree nodes. Maps variables, structures, and function bounds to extract symbol-level boundaries.
2. SQLite Knowledge Store
Stores relational data maps including file hashes, tag names, call trees, and references. Optimized index triggers ensure query results return in microseconds.
3. Watchdog Daemon
Passive background file watcher using system notification boundaries. When files are saved, watchdog re-parses only the changed file paths in 8ms.
Execution Flow: Code Sync to Tool Query
This flowchart traces the lifecycle of a code edit and how it translates to token-saving context injection.
Relational Index Database Schema
CostAffective maps directory relationships statically into four unified SQLite tables.
- • hash TEXT PRIMARY KEY
- • path TEXT UNIQUE
- • indexed_at TIMESTAMP
- • id INTEGER PRIMARY KEY
- • file_path TEXT
- • name TEXT
- • kind TEXT (func, struct, interface)
- • start_line INTEGER
- • end_line INTEGER