Skip to content

About

A terminal coding agent from scratch

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

🤖 agent-core

A terminal coding agent built from scratch.
No LangChain. No agent SDKs. Just a loop, four tools, and a healthy fear of rm -rf.

TypeScript Node Frameworks Benchmark

cat typing very fast

the agent, mid-task


✨ What it does

Ask it something about your project. It reads files, runs commands, edits code and answers, deciding each step on its own.

you> what version is in package.json? bump the patch number.

🔧 bash({"command":"ls -R","timeout":120}) → ✅ 5 lines
🔧 read({"path":"package.json","offset":1,"limit":200}) → ✅ 6 lines
🔧 edit({"path":"package.json","oldText":"  \"version\": \"0.1.0\",","newText":"  \"version\": \"0.1.1\","}) → ✅ 1 lines
The package version has been bumped from **0.1.0** to **0.1.1** in `package.json`.
[tokens: 4,191 in, 254 out]
  • 🔁 Streaming tool-calling loop, written by hand
  • 🛠️ 4 tools, same as Pi: read · write · edit · bash
  • 🔌 Any OpenAI-compatible model: OpenAI, Ollama (local or cloud), and more
  • 🛡️ Asks before running shell commands, validates every tool input with zod
  • 📄 AGENTS.md support for per-project instructions

🚀 Quick start

git clone https://github.com/javin1106/agent-core.git && cd agent-core
npm install
cp .env.example .env      # pick a model: Ollama works for free
npm run dev               # add "-- --yolo" to skip command approvals
calmly typing while the room is on fire

you, using --yolo in a repo you didn't write

🏗️ Architecture

flowchart LR
    U([you]) <--> CLI["cli.ts<br/>terminal UI"]
    CLI -- your message --> A["agent.ts<br/>the loop"]
    A -. events .-> CLI
    A --> M["call-model.ts<br/>retry · resume · continue"]
    M --> P["ai/openai.ts<br/>LLMProvider"]
    P <--> LLM[(any OpenAI-<br/>compatible model)]
    A --> T["tools/<br/>read · write · edit · bash"]
    T <--> FS[(your project)]
Loading

The loop, in four lines:

ask the model  →  it wants tools?  →  run them, add the results  →  repeat
                         ↓ no
                   final answer ✅

The agent only emits events; the CLI just draws them. Swapping in a TUI or a web UI means writing a new renderer, not touching the agent.

🧯 Built to survive

this is fine dog

  • Retries with exponential backoff (1s → 2s → 4s → 8s)
  • Dropped connection mid-reply? It resumes the reply instead of restarting
  • Hit the length limit? It asks for the rest automatically
  • Ctrl+C stops the current task, not the app
  • Failed turn? Finished tool steps are kept, so it never forgets a file it changed
  • Token + cost tracking per turn and per session

📊 Benchmark

15 small coding tasks (create, edit, search, run), each in a fresh temp folder, checked automatically. Run it yourself with npm run eval -- --runs 3.

Model Pass rate Model calls / task Tokens / task Time / task
gpt-oss:120b (Ollama Cloud) 93% (42/45, 3 runs) ~3.1 ~3.3K ~2.9s

🗺️ Roadmap

  • Agent loop, tools, zod validation, AGENTS.md
  • Retries, resume, auto-continue, Ctrl+C, cost tracking
  • Eval suite (npm run eval) and importable library (src/index.ts)
  • Context compaction + saved sessions (--continue)
  • Publish to npm, then a proper TUI
Built to learn how agents really work, one loop at a time.

About

A terminal coding agent from scratch

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages