A local AI coding assistant powered by Ollama, built with TypeScript. Supports agentic workflows — reads files, writes code, runs commands, and iterates until the task is done.
- Agentic loop — model autonomously calls tools until task is complete
- 6 built-in tools —
read_file,write_file,str_replace,delete_file,list_dir,run_command,search_code - Safety guards — path traversal protection, readonly file guard, dangerous command blocking, file size limit
- Diff view — shows changes before applying, requires confirmation for destructive operations
- Streaming output — token-by-token display as model thinks
- Slash commands —
/reset,/history,/help,/exit - Fully local — no API keys, no internet required after model download
- Runtime: Node.js 20+ with TypeScript
- LLM: Ollama (
llama3.1:8borqwen2.5-coder:7b) - CLI: Chalk, Ora, Inquirer, Commander
# Clone the repo
git clone https://github.com/phuoctrung-ppt/coding-agent
cd coding-agent
# Install dependencies
npm install
# Pull the model
ollama pull llama3.1:8b
ollama pull nomic-embed-text
# Create your model with system prompt
ollama create fullstack-dev -f Modelfile
# Copy and configure environment
cp .env.example .envEdit .env:
OLLAMA_MODEL=fullstack-dev
PROJECT_DIR=./path/to/your/project # point to the codebase you want to work withnpm run devYou: list all files in src and explain the project structure
You: add a soft delete method to UserService
You: find all places where any type is used and fix them
The agent follows a simple loop:
- User sends a message
- Model decides: respond with text, or call a tool
- If tool call → agent executes it and feeds result back to model
- Loop repeats until model returns plain text (task done)
This is the same pattern used by Claude Code, Cursor, and most AI coding assistants — the difference is the underlying model.
The agent uses the OpenAI-compatible API format. To use a more capable model, update OLLAMA_MODEL in .env or swap the Ollama client for the Anthropic/OpenAI SDK — no other code changes needed.
src/
├── agent/
│ ├── core.ts # agentic loop + tool routing
│ ├── tools.ts # file and shell tool implementations
│ └── guards.ts # safety checks for all tool calls
├── cli/
│ └── app.ts # terminal interface, streaming, diff view
├── config/
│ └── settings.ts # environment config
└── index.ts # entry point
MIT