Skip to content
ye-wePublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

miniagent

A tiny, readable CLI coding agent. Give it a goal in plain English and it runs an agent loop against Claude, editing files in your current folder until the goal is done.

cd miniagent
npm install
ANTHROPIC_API_KEY=sk-... npx tsx src/cli.ts "rename a.txt to b.txt and add a header comment"
# add --verbose to print the raw model output each turn

Files touched by the agent are sandboxed to the folder you run it from (../ and absolute paths outside it are blocked). No framework, no LangChain — just a loop you can read.

Where the three pieces live

An agent is three things wired together. Here is exactly which code is which:

  1. The model — src/agent.ts, the client.messages.create({ ... }) call. That single request (system prompt + history + tool list in, a decision out) is the LLM.
  2. The harness — everything else in src/agent.ts: the for loop, reading the model's tool_use blocks, and executeTool()'s switch in src/tools.ts that turns a requested tool into a real filesystem action.
  3. The context — the history array in src/agent.ts. It starts as your goal and grows every turn (assistant replies, tool calls, tool results); we resend the whole thing each call because the API itself is stateless. That array is the memory.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages