Dev.to · 5 min read

phi – the 12 MB alternative to Pi: no Ts, any model, hashline edit

phi – the 12 MB alternative to Pi: no Ts, any model, hashline edit

Hi everyone I’ve been hacking on a terminal coding agent called phi https://github.com/pulseaiclub/phi for the past few months, and I’d love to share what it is and why it exists. If you’ve used tools like Pi, Claude Code, Aider, or Goose, phi tries to hit the same workflow—but deliberately strips away the runtime baggage. It’s a single Go binary, ~12 MB, with no Node, Electron, or Python in sight. Here’s what makes it tick: No model lock-in This is the whole reason phi exists. Model releases are moving faster than any agent maintainer can keep up with. Instead of chasing every new provider, phi tr eats the model as a pluggable config: anything OpenAI-compatible or Anthropic-native works out of the box. You can swap models in seconds without waiting for a n author to add support. Config is a single YAML file, and there’s also a tiny HTML editor so you can point-and-click your way through ~/.phi/config.yaml. As light as it gets Go is the secret sauce here. A stripped release build (CGO_ENABLED=0) comes in at ~12 MB, cold idle RSS around ~21 MB, and a first frame in roughly 40 ms. Ther e are only 6 direct module dependencies. If you want a coding agent you can go build in half a second and read in an afternoon, this is it. A permission gate that actually matters One thing that always makes me nervous with coding agents is the "model deletes your files" moment. Phi defaults to read-only: the agent can scan your codebase , but writes and shell commands require explicit approval. The approval dialog gives you three choices—allow, deny with feedback, or allow everything for the r est of the session. Rules are granular: • bash.allow → go test ./... is fine. • bash.deny → rm -rf * is blocked. • fetch.allowed_hosts → restrict which domains the agent can reach. Sub-agents that don’t bloat your context One big agent is fine for small tasks, but long-running work pollutes the context window with noise. Phi ships a full set of sub-agent tools (agent_spawn, agen t_task, agent_wait, agent_list, agent_log, agent_cancel), and the key design choice is that sub-agent transcripts live under ~/.phi/jobs// and never get in jected into the main agent’s context. Only the task summary comes back. Your main session stays clean. Sub-agents also have roles: • explore — read-only search • review — read-only checks • worker — independent edits If you don’t need them, you can disable the whole subsystem in config. Hashline edits instead of blind replace Most coding agents edit by doing a textual search-and-replace. The problem is that if the model’s view of the file is even slightly stale, the replace can land in the wrong place. Phi uses hash-anchored lines. When it reads a file, every line gets a short hash (FNV-64a, mapped to a compact 2-char code). Edits target a specific hash, not a fuzzy string. If the file changed since it was last read, the hash won’t match—and instead of failing silently, phi returns the new line references (>>>) so the model can retry with fresh anchors. No re-reading the whole file, no accidental corruption. A TUI built for actual use The TUI is hand-rolled in Go, no historical cruft. First frame in ~40 ms. Features are functional, not cosmetic: • Markdown rendering + syntax-highlighted code blocks • Four themes: Dark, Darcula, Pink, Terminal • Ctrl+K command palette • @ fuzzy file mentions • /sessions and /resume for session management • !command to stream local shell output directly into the transcript Sessions, skills, and compaction • Skills: drop a SKILL.md into ~/.phi/skills/ and the agent picks it up. • Sessions: persisted as JSONL per working directory under ~/.phi/session/. Resume anytime. • Compaction: long conversations auto-compress so context doesn’t just grow forever. Hooks: custom logic without touching the binary Phi has a hook system that lets you run arbitrary code around every tool call—before the permission gate and after execution—without recompiling anything or st uffing logic into config.yaml. Each hook is just a directory with a hook.json manifest and an executable: There are two hook events: • PreTool — runs before the permission gate. Can allow, deny, or rewrite the tool input. A hard deny here stops the tool before any user prompt. • PostTool — runs after the tool finishes. Can append model-facing context back into the agent’s observation (useful for audit notes or redaction). Hooks are scoped per project: drop one in /.phi/hooks/ and it overrides the user-level hook of the same name. Set PHI_HOOKS=off to disable discovery entir ely. They’re the right place for org policy, audit trails, or input rewriting that the built-in permission gate doesn’t cover. Phi is MIT-licensed, and I’d genuinely love contributors. If you’ve ever wanted a coding agent that fits in a single binary and doesn’t drag a runtime along, g ive it a spin and tell me what you think.

This is a summary aggregated from Dev.to. Read the complete article on the original site:

Read full article at Dev.to

More AI & Machine Learning News