@javen-yan/pi-swarm0.1.1
Antigravity-style /swarm for pi: named workers on one channel-aware board, a verifier, interactive /swarm-ui TUI console, and zero-dependency /swarm-web dashboard
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-swarm
An Antigravity-style /swarm for pi: one coordinator conversation, named workers, one channel-aware board, a verifier, an interactive TUI console (/swarm-ui), and a zero-dependency local Web dashboard (/swarm-web).

| TUI · Members | TUI · Timeline |
|---|---|
![]() |
![]() |
Web Dashboard · Overview (/swarm-web) |
Web Dashboard · Graph & Replay (/swarm-web) |
|---|---|
![]() |
![]() |
A swarm is not a subagent fan-out. Subagents are focused side tasks. A swarm splits a broad task into clean, non-colliding pieces and keeps every piece talking through a single board, so you can see the whole thing work.
Install
pi install npm:@javen-yan/pi-swarm
That is the only required step. Requires Node 22+ and Pi 1.7+ (@earendil-works/pi-tui and typebox are provided by the Pi host as peer dependencies; zero runtime dependencies are installed).
Other install options (project-local, git, local checkout, upgrade / uninstall)
# Project-local install (writes to .pi/settings.json)
pi install npm:@javen-yan/pi-swarm --local
# Install from GitHub (main or a specific tag)
pi install git:github.com/javen-yan/pi-swarm@v0.1.1
# One-shot load from a local checkout without installing
git clone https://github.com/javen-yan/pi-swarm.git
pi -e ./pi-swarm/index.ts
# Manage installed package
pi list
pi update --extensions
pi remove npm:@javen-yan/pi-swarm
Quick start
Run /swarm <task> inside Pi, then open either the TUI console or local Web dashboard:
/swarm migrate the auth module to the new session store, add tests, keep the public API
/swarm-ui # open the interactive TUI console (same as /swarm ui)
/swarm-web # open the local web dashboard (same as /swarm web; --no-open | stop)
/swarm status # print roster, activity, budget and usage
/swarm-stop # stop the swarm, workers go to sleep
What happens next:
- The current conversation becomes the coordinator. It does not write code.
- It breaks the task into non-overlapping pieces and calls
swarm{action:"add"}(ortasks:[…]/n:for a pool): owns / must not touch / definition of done. - Each worker starts as its own
piprocess with a clean context and only the board as a channel.forkstarts one from a warm conversation instead. - It adds one
@verifierper 2–4 workers. The verifier reads diffs, runs the tests, and reports problems to the worker that wrote the code. - All talk is public:
@name,@group,@all. A post that names nobody wakes nobody. Idle members are parked processes that cost nothing. - A larger swarm gets channels (
swarm{action:"channel"}) — everyone is always in#main, each worker posts in its own area channel and writes to#mainonly for what the whole swarm needs. - When the work is verified, the coordinator calls
swarm{action:"finish", summary}— which posts[done] <summary>, the terminator nobody has to be told about.
Skills
The package ships two skills that teach the model when and how to swarm:
/skill:swarm— the coordination doctrine: when a swarm beats a subagent, how to cut ownership boundaries, brief anatomy, verification, worktrees, failure modes.references/brief-templates.md— copy-paste briefs for workers, worktree workers, pools, verifiers, monitors, plus a bad-versus-good pair.
Declared in package.json under pi.skills, so pi install exposes them automatically without any manual symlinks. The coordinator prompt injected by the extension is intentionally narrower than the skill: the skill is for you and the surrounding conversation, the prompt is for the coordinator process.
Prompt templates
Two templates expand into coordinator instructions, so you do not have to hold the doctrine in your head:
/swarm-plan <task>— decomposes before anything is spawned: work areas, ownership and contracts, the fakes each worker needs, then the first threeaddcalls. Nothing is added until you say so./swarm-review [what to verify]— writes an evidence-based brief for averifiermember and tells you not to fix findings yourself.
The TUI console (/swarm-ui) & Web dashboard (/swarm-web)
Both UIs are powered by the same shared SwarmSnapshot ViewModel (src/ui-model.ts) and support live intervention without leaving your session.
TUI Console (/swarm-ui)
/swarm-ui opens a responsive Master-Detail TUI overlay with four views (split-pane on terminals ≥ 104 inner columns, single-pane below):
| View | What it shows |
|---|---|
| 1 Overview | Goal, wall-clock budget progress bar, Work Groups / Channels summary, [done] milestones, detected artifacts/screenshots, and the /swarm-web URL. |
| 2 Board | Compact 2-line channel-aware stream on the left paired with a live padded Post Inspector on the right (full wrapped body with @mention / #channel / [done] highlighting). Filter by @member (/), #channel (c), alerts only (e), or reset (0). |
| 3 Members | Working / Parked / Stopped / Killed sections with scroll-following selection and a right-hand Member Inspector prioritizing Recent Activity (workspace paths automatically shortened) and Latest Posts above the member's Brief, plus model, channels, worktree/branch, and token breakdown. |
| 4 Timeline | Thin-bar (━/─) @from → @to communication flow paired with a synchronized Replay preview showing the exact #seq post at the replay cursor. |
Interactive controls inside /swarm-ui:
- Navigation:
1–4ortab/shift+tabswitch views,↑/↓orj/kselect,enterexpand/filter,pgup/pgdnpage,g/Gtop/bottom,ffollow,q/escclose. - Filtering:
/cycle@member,c/#cycle#channel,etoggle alerts (error/question),0reset filters. - Actions:
ppost to the board as@user,rreply to selected post/member,wwake/nudge selected member,mland worktree branch,xkill member (withy/Nconfirm),Sstop swarm,Wlaunch/swarm-web. - Replay (Timeline):
←/→(h/l) step,spaceplay/pause,Llive.
Size overrides: PI_SWARM_UI_WIDTH / PI_SWARM_UI_HEIGHT (defaults 88% × 84%).
Local Web Dashboard (/swarm-web)
/swarm-web starts a zero-dependency Node http + SSE server bound to 127.0.0.1 (random free port, or PI_SWARM_WEB_PORT) and opens an Antigravity-inspired visual dashboard in your browser (with dark/light IDE theme toggle ◐ and a single left navigation rail for Budget, Channels, and Roster):
- Overview: Goal & summary strip, Groups of Work cards with live per-member activity, horizontal chronological Screenshot & Artifact Timeline (clickable Prev/Next lightbox for
.png/.svg/.webpinside the workspace or/tmp), and completed[done]milestones. - Board: Centered readable feed with inline Markdown (
code, bold,@mention,#channel), automatic folding for long briefs/posts with one-click expand, hover Reply,#channel/@member/kind/search filters, and a bottom Compose bar with@memberquick-mention chips. - Members: Clean single-pane inspector switched from the left Roster rail or top member pills, showing Recent Activity (with shortened workspace paths), collapsible Brief, latest posts, worktree status, and one-click Wake / Switch Model / Land Branch / Kill.
- Graph: Interactive pill-node SVG communication topology (exact border arrow intersections, outward-bowing outer chords, non-overlapping edge badges, clickable node focus) paired with a synchronized Replay scrubber and live message card.
Security & lifecycle: binds strictly to 127.0.0.1, validates a per-session X-Swarm-Token + Host header on all POST /api/* actions, restricts /api/artifact reads to the workspace or /tmp, and shuts down automatically on session_shutdown. Stop it manually with /swarm-web stop, or run /swarm-web --no-open (PI_SWARM_WEB_NO_OPEN=1) to print the URL without opening a browser.
The status widget under the editor stays visible even when the pane is closed, showing live member counts, elapsed/budget time, latest poster, and the active /swarm-web URL.
Tools
Coordinator only — four tools, not nine:
| Tool | Purpose |
|---|---|
swarm{action} |
status (roster + board head), models (list available models), add (one member, or tasks/n for a pool, fork for a warm start), model (switch a parked member's model and resume it), kill, title, channel (create or list work areas), land (merge a working copy), finish (close with a summary). |
post_message |
Post as the coordinator: {text, channel?, to?, kind?}. Name who must act; a post that names nobody wakes nobody. |
read_board |
{since?} for posts after a sequence number, {seqs:[4,6]} for specific ones, {channel} for one area, {roster:true} for the roster instead of messages. |
swarm_wait |
{since} parks until a post lands after that number. Returns at once with "nobody is coming, the swarm is waiting on you" when every worker is parked and nothing is pending. |
Workers get exactly one tool, swarm_worker, with three actions: post_message, read_board, wait. It reads the same board files directly — the coordinator process is what routes and wakes.
How it works
- One pi process per member, on demand. A member is a persistent pi session id (
--session-id). Idle means the process exited: no tokens, no memory. A mention spawnspi --mode json --session-id <id>again, so the conversation continues where it stopped. - Board on disk.
<cwd>/.pi/swarm/<id>/board.jsonlis append-only. The coordinator assigns post numbers as it reads, so writers never race.swarm.jsonholds members and metadata. - Hands-off workers. Children are spawned with
--no-extensions -e <this extension>, so they do not load your other extensions, do not use MCP, and cannot recursively start swarms. They getread,grep,find,ls,bash,edit,write, plusswarm_worker. - Same model by default, live model switching.
swarm{action:"models"}lists models available from the host registry. Each member inherits the swarm model unless overridden;swarm{action:"model", name, model}moves a parked or stopped member to another model while keeping its conversation and automatically wakes it to resume unfinished work. - Mention-driven wakes. One rule: a post wakes the members it names, nobody else. Kinds are labels, not switches — a
statuspost that names someone wakes them, and a report that names nobody wakes nobody.wake_mode: anythingsubscribes a member to every post in its channels. - Parked is free. A parked member is an exited process holding a session id.
swarm_wait{since}is the only clock: it sleeps on a sequence number and wakes the instant something lands after it. Idle is not a timer, it is the absence of a reason to run. - States.
working(inside a turn),parked(asleep on a seq),stopped(its process is gone — after a restart — and a mention revives it),killed(gone for good). - Monitor. If the board goes quiet with no member running and the swarm unfinished, the coordinator nudges its
@monitormember if it has one (@monitor resumerevives it after a restart), otherwise it warns you. 2 minute backoff. - The idle contract. If every worker is parked and nothing is pending, nobody is coming: the swarm is waiting on the user.
swarm_waitsays exactly that and returns immediately instead of sitting out its timeout, which is what used to leave a finished swarm quiet forever. - Convergence. A swarm has a 40 minute wall-clock budget. When it runs out the coordinator gets one interrupt telling it to collect final statuses and finish or stop;
swarm{action:"status"}showselapsed of budgetand anything still running, and a timed-outswarm_waitnames the members holding it up rather than saying "timed out".[done] <summary>with no mentions mutes the monitor: the terminator needs no protocol. - Rate limit. A worker posting closer than 800ms after its last post is refused (
posting too fast; slow down and retry), so a confused member cannot spam a loop onto the board. Coordinator and@userposts are exempt. - Quota. A member that hits a rate limit or quota stops instead of retrying in a loop, posts that it is paused, and stays asleep until woken or switched to another model.
- Forking.
swarm{action:"add", fork:"parser"}(including pools viatasks/n) copies an existing conversation's session file (or the coordinator's own) into the new member's session and rewrites its ids, so new members start warm instead of cold.
Worktrees
swarm{action:"add", workspace:"share"} creates git worktree add -b swarm/<id>/<name> .pi/swarm/<id>/wt/<name> HEAD. The member works there, reports for review, and swarm{action:"land", name} merges the branch back (--no-ff) before deleting the working copy. Killing a member whose branch is unmerged keeps the working copy and tells you where it is.
Without share/branch, members inherit the coordinator's workspace — the default, and the reason briefs must state ownership boundaries.
Files
.pi/swarm/<id>/
swarm.json # title, channels, members, states, usage (version 2)
board.jsonl # append-only posts
sessions/ # worker pi sessions (kept out of your session list)
wt/<member>/ # optional git working copies
/swarm on a session that still has an active swarm reloads it; members that were running are marked asleep and wake again on the next post that names them. Swarm data from earlier prototypes is ignored rather than upgraded: swarm.json carries version: 2.
Testing
Zero external test dependencies — uses Node 22's built-in test runner:
node --experimental-transform-types --test test/ui-and-web.test.ts
Publishing
The package is publish-ready against the Pi packages doc:
npm login
npm pack --dry-run
npm publish --access public # scoped packages publish restricted without this; pi.dev/packages picks it up via the pi-package keyword
Before the first publish, bump version together with a ## [x.y.z] heading in CHANGELOG.md — Pi shows entries newer than the version it last saw. pi.image is the gallery preview, pointing at assets/preview.png in the repository; the same file ships inside the tarball, so switch it to the relative path ./assets/preview.png if the gallery prefers a packaged asset.
Notes
Package metadata follows the pi packages doc:
pi-packagekeyword,pimanifest with explicit entry points, host libraries inpeerDependencies: "*", andCHANGELOG.mdthat pi shows after an upgrade.Workers are real
piprocesses: they cost tokens, and a swarm of six is not cheap. Briefs are the whole game — vague briefs produce collisions.The coordinator refuses to do the work itself. If it starts editing files, it is off-protocol;
/swarm-stopand restate the split.Only one swarm per session is active at a time.



