Remix.run Logo
Show HN: Pu.sh – a full coding-agent harness in 400 lines of shell(pu.dev)
39 points by nahimn 2 hours ago | 16 comments

I originally was just messing with pi-autoresearch. Gave it a sample task to build the most portable coding agent.

First cut was 6 KB of shell. Great for one-shots, unusable interactively. I was shocked it actually worked.

Started building up -- adding features — but with a self-imposed rule: no new dependencies, and sub 500 LOC. This thing had to be truly portable. Just sh, curl, awk. System primitives only.

Which means I did some genuinely disgusting things in awk, including JSON parsing and the OpenAI Responses tool loop with reasoning items carried across turns.

It's now ~400 lines. In the box: Anthropic + OpenAI, 7 tools (bash, read, write, edit, grep, find, ls), REPL, auto-compaction, checkpoint/resume, pipe mode, 90 no-API tests. Not in the box: TUI, streaming, images, OAuth, Windows, dignity.

Two honest things:

1. I stole/modified the system prompt and the architecture. Pi/Claude/Codex wrote the awk. I cannot read most of this code. This wasn't possible for me a year ago.

2. Heavily inspired by Pi (pi.dev) — same 7-tool surface, same exact-text edit model. Credit where it's due. Pi is awesome -- you should probably use them.

The agent loop itself is tiny. Almost everything else in a "real" agent CLI is DX and hardening. You can probably build your own harness exactly how you like it. Mario Zechner's AI Engineer talk on taking back control of your tools nudged me here.

The name is because it's a .sh file. The other thing it sounds like is, regrettably, also accurate.

ricardobeat 2 hours ago | parent | next [-]

Really like the looks of it, but minifying the code to achieve the “400 lines” marketing gimmick is a huge turn-off.

It’s also a security nightmare, and ensures it remains 100% vibe coded. Would rather have a readable source with an honest line count.

StableAlkyne an hour ago | parent | next [-]

Agreed. It would be one thing if it was a regular bash project that got minified via a script or something, since at least you could tell what it's doing.

This is just spaghetti. Maybe it's spaghetti that runs, but code of this quality does not engender confidence.

sudb 2 hours ago | parent | prev | next [-]

I think it's fine that it's minified, code-golf style, but yes I agree that this would be much more convincing and useful with an unminified source.

cachius an hour ago | parent [-]

Isn’t unwrapping and commenting just one prompt away?

StableAlkyne an hour ago | parent [-]

Assuming the agent doesn't forget or misinterpret anything.

It would be much better to just have a deterministic minification script.

petcat 2 hours ago | parent | prev [-]

I'm not even sure why it stopped at 500 line limit. If it's just a shell script then why not make it one line?

mjuarez 14 minutes ago | parent | prev | next [-]

Could you post the initial 6KB version? I'd love to have a version that I can actually read and understand. I don't care if it's 2K LOC.

kkovacs an hour ago | parent | prev | next [-]

I love this. This is the grown-up brother of my one-liner bash+python at

https://github.com/kkovacs/kkrc/blob/ecff1f65d5ccfa24d5f6695...

:)

cachius an hour ago | parent | prev | next [-]

Does it work in just-bash?

https://github.com/vercel-labs/just-bash/blob/main/packages/...

tecoholic an hour ago | parent | prev | next [-]

Kudos. I set on this exact journey a couple of days back and Pi is what I started reading for inspiration as well. I really can't stand the text boxes and the animations of the mainstream harnesses.

flog an hour ago | parent | prev | next [-]

I'd love to learn how to build something like this, but unfortunately the code is unreadable.

If author could write a heavily commented version that would be amazing.

0gs 13 minutes ago | parent | prev | next [-]

why the LOC limit? just because?

petcat 2 hours ago | parent | prev | next [-]

your 500 LOC requirement has made this thing completely and unnecessarily inscrutable and unreadable.

Pass.

esafak an hour ago | parent [-]

No kidding https://github.com/NahimNasser/pu/blob/main/pu.sh

Imustaskforhelp an hour ago | parent | prev | next [-]

Interested in something like this if the code can be more readable, it would be interesting to see it in languages like lua etc. too in future.

hkt 2 hours ago | parent | prev [-]

I love it. I think I'm going to have fun with this and possibly learn a bit, too. I'm pondering a container based dev environment at the moment and might throw it in with busybox and see how far I get :)