How amoorawat/ai-agent works
This repository is a terminal-based AI coding assistant. The visible workflow accepts a prompt in the CLI, runs it through the agent, builds conversation context, requests a streamed completion from OpenRouter, and renders text in the terminal. A tool framework and a file-reading tool are present, but the sampled agent loop does not dispatch returned tool calls, so that is shown as a separate capability rather than an active workflow. Several links are based on source-index references; unsampled behavior is not assumed.
Main entry points: agent.py Agent Loop · read_file.py File Reader · main.py CLI · manager.py Conversation Context
Components 17
CLI Interaction
- CLI
main.py - Terminal UI
ui/tui.py
Agent Core
- Agent Loop
agent/agent.py - Agent Events
agent/events.py
Model and Context
- Conversation Context
context/manager.py - System Prompt
prompts/system.py - Token Utilities
utils/text.py - LLM Client
client/llm_client.py - Stream Types
client/response.py
Tooling
- Tool Registry
tools/registry.py - Tool Contract
tools/base.py - Built-in Tools
tools/builtin/__init__.py - File Reader
tools/builtin/read_file.py - Path Utilities
utils/paths.py
Other components
- User
- OpenRouter API
- Workspace Files
Connections 19
- User → CLI: enters prompt
main.py - CLI → Agent Loop: runs agent
main.py - Agent Loop → Agent Events: emits events
agent/agent.py - Agent Loop → Conversation Context: updates context
agent/agent.py - Agent Loop → Tool Registry: gets schemas
agent/agent.py - Agent Loop → LLM Client: requests completion
agent/agent.py - LLM Client → OpenRouter API: sends chat request
client/llm_client.py - LLM Client → Stream Types: builds stream events
client/llm_client.py - Agent Events → Stream Types: uses token usage
agent/events.py - Conversation Context → System Prompt: loads prompt
context/manager.py - Conversation Context → Token Utilities: counts tokens
context/manager.py - CLI → Terminal UI: renders stream
main.py - Tool Registry → Built-in Tools: loads defaults
tools/registry.py - Tool Registry → Tool Contract: registers and invokes
tools/registry.py - Built-in Tools → File Reader: provides tool
tools/builtin/__init__.py - File Reader → Tool Contract: implements contract
tools/builtin/read_file.py - File Reader → Path Utilities: resolves and checks paths
tools/builtin/read_file.py - File Reader → Token Utilities: counts and truncates
tools/builtin/read_file.py - File Reader → Workspace Files: reads files
tools/builtin/read_file.py