angusjf

AI coding harness in 100 lines

Here's an AI/agentic coding harness I wrote that's ~ 100 lines of code: sfch.

It's easy to forget how simple they are to build - just before I wrote this I was served a YouTube AD for codex... which is a tool you can build in like 5 mins.

(I was kind hoping this is what pi.dev would be - but that's kinda "simple" but still tens of thousands of lines of code.)

The process is straightforward:

So that's an LLM chatbot... so then to let it code:

The thing that makes it so easy is that llms are naturally append-only, so a terminal app is a super natural fit (way more than e.g. a text editor). You don't even have to implement a /quit command, you can just hit CTRL-D for end of file.

If you want to make it resumable, a nice idea is just appending / loading messages from a jsonl file at every step. Generate a random ID for the filename at the beginning (or allow passing one in) and then at the end print it out.

There's a few things that stand in your way if you wanna make something as complex as pi:

The magic kicks in when you set the agent on improving the agent! You can get it to make a /reload command or even a reload() tool ... then when you ask for a change... it can just build it! Feels like sci-fi.