How nmakod/codecontext works
Project Type and Purpose
• CodeContext is an AI-powered CLI tool (written in Go) plus an embedded “MCP” server.
• Purpose: analyze any codebase (multi-language via Tree-sitter), build a virtual dependency graph, generate token-optimized Markdown context maps, serve real-time context over MCP protocol.
• It’s not a traditional client-server web app; it’s a layered CLI application with an optional long-running server component.
File Structure
• Top-level “cmd/codecontext”: the main entry point (Go main.go), subcommands (generate, init, mcp, watch, etc.).
• internal/cli: CLI parsing, command implementations, tests.
• internal/analyzer, internal/parser, internal/diff, internal/git, internal/compact, internal/vgraph: core engine modules.
• Parser builds ASTs and extracts symbols.
• Git module fetches version/history and change contexts.
• Diff layer computes semantic vs structural diffs.
• Analyzer and vgraph build the dependency/virtual graph.
• Compact strategies shrink context payloads.
• internal/cache: persistent/in-memory caching to avoid re-parsing.
• internal/mcp: MCP server that exposes a persistent gRPC/JSON‐RPC API.
• pkg/types: shared data structures (graph nodes, contexts, symbols).
Key README/Docs Insights
• Architecture is layered: Parser → Graph Engine → Analyzer → Formatter/Output → MCP Server/CLI.
• Virtual Graph Engine: shadow vs actual graph, incremental updates.
• Caching: LRU + persistent disk.
• Multi-threaded file processing.
• External dependencies: Tree-sitter libraries, Git CLI, Claude (as consumer).