r/emacs • • 16d ago

My Emacs setup for running coding agents

https://github.com/offline-ant/phimacs

Over the past years since AI I gradually moved from living in Emacs into tmux and then moved to Herdr for running multiple coding agents. When Emacs turned 50 I decided to try and move my whole flow back into Emacs and rebuilt the parts I actually used. I mentioned it on HN and a few people asked for it, so I put it up.

Up front: AI agents wrote all of the code and the docs. It's my own setup, built one problem at a time, not a package I plan to maintain for other people's use cases. Its Linux only, and not tested on anything else. Its set up to be easy (for an AI) to take only the parts you find useful.

What it does: the agents (Pi) run in a background service 'pimux'. Closing Emacs or dropping an SSH connection doesn't stop them. Each project gets its own space, a sidebar shows which agents need me, and an agent can hand tasks to workers that run in parallel under it. The chat is a fork of Pilish.

0 Upvotes

14 comments sorted by

6

u/nimzobogo 16d ago

Why not just agent-shell or emacs-eca?

3

u/Qudit314159 15d ago

Or ghostel. Then you don't have to worry about missing features in the ACP implementation.

2

u/nimzobogo 15d ago

Do you mean ghostel + the native CLI?

At work, they give us GitHub copilot, and for a while I vibe coded my own ACP wrapper until the copilot --acp native implementation caught up.

2

u/Qudit314159 15d ago

Yes. I just run the native clients in ghostel. The Emacs integration is so good I don't miss something like agent-shell. I used to use it but it's an extra unnecessary level of complexity IMO and I kept running into glitches due to ACP gaps.

1

u/nimzobogo 14d ago

At least with these emacs native packages, it can do things like make file paths a link so I can open them with a mouse click or an enter. I suppose one could get that to work with ghostel and an mcp server.

1

u/Qudit314159 14d ago

ghostel has clickable links. I personally open them using keybindings instead.

1

u/nimzobogo 14d ago

Plus I like being able to iterate back and forth between previous prompts and responses easily. With ghostel + CLI you gotta scroll and it makes finding what you're looking for harder. Imo.

1

u/Qudit314159 14d ago

You could just enter read only mode and search for the last prompt. It's also quite easy to turn into a single keybinding if you want.

1

u/nimzobogo 14d ago

Yeah, but then you gotta remember what you wrote uniquely in that prompt. That's still a lot of steps.

Just simple hot keys to go backwards and forwards is great.

1

u/Qudit314159 14d ago

No you don't. You just need to search for the prompt prefix. This is very easy to achieve with ghostel.

0

u/offline-ant 15d ago

My set up came to be from iterating on a tmux/herdr + pi setup. Emacs role is mostly as a replacement for tmux/herdr, not for running the agent.

I kept at it because it mostly features that had no alternative/standard at the time of writing. ( I dont know what agent-shell and eca can do at the moment. )

pi as a harness is just really good. Its minimal, its easy to make extensions, and it got codemode a while ago.

One of the things I added is a daemon that owns the pi session - allowing multiple front ends to the same set of running agents. Emacs is my usual frontend, but there is also a web frontend that works well on my phone.

From an architecture standpoint I think this makes the most sense. An 'agent' harness should just be managing its io, a way to organize/build its tools, and control logins to providers. The layer above that should orchestrate (in my case that's just 2 tools for do and delegate to prompt a new pi process). The layers above that should be the user interface.

2

u/magiollie 16d ago

Here is my attempt with a similar goal in mind
https://gist.github.com/ojhughes/58d4b71a5cab37dadd8cf898b6d18364

-1

u/offline-ant 16d ago

Oh nice, you route the input and output between agents yourself adhoc? I'd thought about something like that but never got round to building it; instead i have a skill & phimacs cli that lets them list/wait/send to arbitrary other agents when i tell it to.

Though this actually bit me in the ass at one point where a sub-sub-agent found the skill and started sending the root agent prompts about what to do next without me knowing.

1

u/dabian2333 15d ago

good, however, tmux seems is overkill, i use zmx instead