How naprila/code-pilot works
CodePilot is a command-line coding assistant for exploring and working with the current codebase. The main workflow initializes a repository index and agent, then routes /ask questions through session-aware query handling; answers may use a semantic cache. The CLI also supports approved, resumable /plan execution and task-status inspection. The tree and excerpts establish these entry points and capabilities, but do not show the agent’s tool wiring or indexer/retriever implementations in detail, so those internal links are left out where uncertain.
Main entry points: main.py Command interface · tasks/orchestrator.py Plan command · factory.py Coding agent · agent/orchestrator.py Query handling
Components 27
CLI and sessions
- Command interface
codepilot/main.py - Session management
codepilot/memory/session.py - Conversation checkpoint
codepilot/memory/short_term.py
Codebase knowledge
- Repository indexer
codepilot/context/indexers - Source chunking
codepilot/context/indexers/code_parser.py - Code retrieval
codepilot/context/retrievers - Vector store
- Change watcher
codepilot/context/indexers/watcher.py
Assistant runtime
- Query handling
codepilot/agent/orchestrator.py - Coding agent
codepilot/agent/factory.py - Agent tools
codepilot/agent/tools.py - Filesystem tools
codepilot/tools/filesystem_tools.py - Terminal tools
codepilot/tools/terminal_tools.py - Model provider
codepilot/llm/factory.py - MCP tools client
codepilot/mcp/codepilot_mcp_client.py
Task planning
- Plan command
codepilot/tasks/orchestrator.py - Plan generation
codepilot/tasks/planner.py - Plan approval
codepilot/tasks/approval.py - Task execution
codepilot/tasks/executor.py - Task recovery
codepilot/tasks/recovery.py - Task status
codepilot/tasks/status.py
State and cache
- Task records
codepilot/tasks/task_store.py - Semantic cache
codepilot/cache/semantic_cache.py
Other components
- Engineer
- LLM service
- MCP servers
- Redis cache
Connections 26
- Engineer → Command interface: enters commands
- Command interface → Session management: selects session
- Command interface → Conversation checkpoint: opens checkpoint
- Command interface → Repository indexer: initializes or reindexes
- Repository indexer → Vector store: writes index
- Command interface → Change watcher: starts watcher
- Command interface → Coding agent: builds agent
- Command interface → Query handling: dispatches /ask
- Query handling → Semantic cache: checks and stores
- Semantic cache → Redis cache: reads and writes
- Query handling → Coding agent: invokes on cache miss
- Coding agent → Model provider: uses model factory
- Model provider → LLM service: connects to model
- Command interface → Plan command: dispatches /plan
- Plan command → Plan generation: creates plan
- Plan command → Plan approval: requests approval
- Plan command → Task recovery: recovers tasks
- Plan command → Task records: persists and reads tasks
- Plan command → Task execution: runs ready tasks
- Task execution → Task records: updates task state
- Command interface → Task status: shows task status
- Task status → Task records: reads progress
- Coding agent → Agent tools: registers tools
- Agent tools → Filesystem tools: exposes filesystem
- Agent tools → Terminal tools: exposes terminal
- MCP tools client → MCP servers: loads tools