Ports kimi-code's AgentSwarm: a `prompt_template` containing `{{item}}`
expanded over an `items` list into up to 128 subagents, run to completion
and returned as one aggregate. Kigi already exceeds upstream on planning,
verification, isolation and merge via /graph; what it lacked was cheap
immediate fan-out. Entirely client-side — no new backend surface.
The engine is three pure pieces plus a runner: `plan` validates and
expands (every fault reported before a single member starts — a
half-launched swarm is expensive to unwind), `schedule` is the launch
ramp as testable arithmetic, `run` drives it against the existing
`SubagentBackend`. Reuses the single-spawn coordinator rather than
inventing a batch API.
Load-bearing decisions, each the result of a defect found in review:
- `backgrounded` is its own outcome. A member that outlives the 600s
foreground budget is detached by the coordinator and KEEPS RUNNING;
reporting it as failed invites the model to relaunch its item, putting
a second agent on the same files. It is never offered for resume.
- `InFlightGuard` cancels live members on Drop. Send-now cancels the turn
WITHOUT cancelling subagents and aborts the task; the dropped receivers
read as "parent gone" and each child re-attaches itself. There is no
cooperative path to use instead — `Cancellation` is constructed nowhere
in the tree — so Drop is the only seam that fires.
- Retries and wall clock are both bounded. The swarm blocks the caller's
turn, so every wait needs a ceiling it cannot argue past; stragglers at
the deadline are reported as still-running, with their ids.
- `ToolKind::AgentSwarm` is its own variant: `TemplateRenderer`'s
`by_kind` map holds one tool name per kind, so sharing `Task` would
silently redirect `${{ tools.by_kind.task }}` in other tools' prompts.
- An explicitly requested model that cannot be validated is refused, as
the task tool already does — one loud error beats `items.len()` quiet
ones. Depth stays capped at 1: upstream's unlimited nesting is a
hazard, not a feature.
- `SubagentResult.rate_limited` is classified where the typed ACP error
code is still in hand; a scheduler re-deriving it from a formatted
string would stop adapting the day the wording changed.
- Aggregate output is clamped per member (head+tail, loss stated):
native tool output is truncated nowhere downstream.
42 agent_swarm tests. The fake backend awaits, so the concurrency and
ordering assertions can actually fail; the cap test also proves the
fixture can exceed the cap.
kigi-tui
Terminal UI (TUI) for Kigi. Provides the interactive full-screen interface including the scrollback view, prompt input, session management, and all modal dialogs.
Architecture
src/
├── app/ # Application state and event handling
│ ├── app_view.rs # Top-level state (welcome screen, agents, config)
│ ├── agent_view/ # Per-session agent view (struct in mod.rs + per-domain impl modules)
│ ├── dispatch/ # Action → Effect dispatcher (router + per-domain modules)
│ ├── effects.rs # Async side effects (ACP calls, file I/O)
│ └── event_loop.rs # Main event loop (input, ticks, ACP messages)
├── views/ # UI components
│ ├── prompt_widget.rs # Text editor with file search, slash, history
│ ├── welcome/ # Welcome screen (logo, menu, prompt)
│ ├── extensions_modal.rs # Extensions modal (hooks, plugins, marketplace, skills, MCP servers)
│ ├── file_search/ # @-completion dropdown and line viewer
│ ├── slash_dropdown.rs# /command completion dropdown
│ └── ... # Scrollback, status bar, panes, etc.
├── scrollback/ # Message history rendering
├── slash/ # Slash command registry and built-in commands
├── appearance/ # Theme and pager.toml config
├── acp/ # Agent Communication Protocol client state
└── render/ # Low-level rendering helpers (color, wrapping, etc.)
Key Concepts
- AppView — owns the welcome screen, agent sessions, and global config
- AgentView — one per session; owns the prompt, scrollback, tool panes, and modals
- PromptWidget — text editor component with file search (
@), slash commands (/), history search, and paste elements - Action/Effect — Elm-style architecture: input → Action → dispatch → Effect → state update
Keyboard Shortcuts
| Key | Context | Action |
|---|---|---|
Ctrl+P or ? |
Agent screen | Open command palette |
Ctrl+L |
Any (non–VS Code family) | Open plugins/hooks modal; on VS Code / Cursor / Windsurf / Zed use /plugins or /hooks (Ctrl+L is mid-turn interject) |
Tab |
Prompt | Switch to scrollback |
Esc |
Turn running | No-op (does not cancel; use Ctrl+C) |
Esc Esc |
Idle, non-empty prompt | Clear prompt (within 800ms; first press shows hint) |
Esc Esc |
Idle, empty prompt + messages | Open rewind picker (silent first press) |
Ctrl+M |
Prompt | Toggle multiline mode |
Shift+Enter |
Prompt | Insert newline |
/ |
Prompt | Start slash command |
@ |
Prompt | Start file search |
! |
Prompt (empty) | Enter bash mode |
Ctrl+C |
Prompt (with text) | Clear prompt (even while turn running) |
Ctrl+C |
Prompt (empty) + turn running | Cancel running turn |
Docs
- Terminal Support & Troubleshooting — tmux/SSH truecolor, clipboard, mouse, diagnostics, /terminal-setup
- Hooks & Plugins Guide — managing hooks, plugins, and marketplace sources
- Custom Hooks Guide — creating, configuring, and writing your own hooks
- Hook Examples — sample hooks for common workflows
- Hooks Crate (
kigi-hooks) — hook runtime, event types, and execution engine - Plugin Marketplace Crate (
kigi-plugin-marketplace) — marketplace source loading, scanning, and install