---
description: Guided setup — install agent-fleet artifacts into a workspace for a chosen coding agent
---

Load and follow the `guided-workspace-setup` skill before proceeding.

Run the guided install for a target workspace. If the user passed a workspace path, use it; otherwise ask for it. Detect the running coding agent and confirm it with the user.

Analyse the workspace. If prior install state is found (`.ai/agent-fleet-setup.md` or a populated agent directory), run the **Doctor preflight** first (Step 5) — scan for broken symlinks and stale persona references, present findings as a table, and apply the fixes the user picks before continuing.

**Bootstrap `pi-ask-user` first (Step 5b).** Before the install menu, check whether the `pi-ask-user` interaction package is available (bundled by `@chankov/agent-fleet`, recorded as a project package, or global). If it is missing, offer to install it project-scoped (`pi install -l npm:pi-ask-user`), record it as an external/project pi package, then **stop the pass** and ask the user to reload pi and re-run `/setup-agent-fleet`. The tool only becomes callable after reload, and on the re-run the menu uses its native multi-select widget. Only fall back to a text menu in this pass if the user *declines* the bootstrap.

The Skills group draws from **two roots**: fleet-native `skills/` and the vendored upstream import `vendor/agent-skills-upstream/skills/` (see `docs/UPSTREAM-SKILLS.md`). On a name collision the native copy wins — never offer the vendored duplicate as a separate row.

Then present the install menu per the skill's Step 1 interaction contract — drive every decision through the `ask_user` widget, never a printed table awaiting a free-text reply (the table format is reserved for the no-widget fallback when the user declined the bootstrap). Open with the **Express question** (fresh workspace: `Recommended ★` / `Everything` / `Custom — group by group` / `Nothing`; existing: `Keep as-is` / `Apply updates` / `Keep + add recommended ★` / `Custom`) — any answer but `Custom` skips all group screens. On `Custom`, run the **7 groups** (4 shared: Skills, Agent personas, Commands/prompts, References & Hooks; 3 pi-only: pi extensions & runtime skills, pi harnesses, External pi packages): each opens as a single-select quick screen (`Recommended ★ (n)` / `Everything (m)` / `Customise` / `Skip group`, or the installed-state variants with `Remove some…`), and multi-select drill-ins appear only behind `Customise`, chunked by sub-category (lifecycle phase for Skills, `rw`/`ro`/`pi-only` for personas, harness category, …) at ≤ 9 options per call, ≤ 8 `context` lines. Option titles carry `name ★ [st]` (`ok`/`upd`/`mod`/`cflt`/`gone`/`new`/`pkg`/`—`/`brk`); descriptions carry the purpose plus the state in plain words (`mod` → warn that refreshing overwrites local edits). There is **no pre-checking** (`ask_user` has no preselect) — installed state shows as counts on quick screens and words in descriptions; leaving an installed item unselected in a drill-in keeps it as-is. Freeform stays on so `all` / `recommended` (adds `★` on top — never removes) / `none` / `keep` still work; cancel = keep-as-is/skip. `cflt` rows are resolved only by printing the three-way diff and asking per row with `displayMode: "inline"` — never by Express or `Apply updates`. The External pi packages group lists `pi-ask-user` and the optional suggested `pi-codex-image-gen`. After Step 5b, `pi-ask-user` normally counts toward `Keep as-is` (`pkg`, scope `project` / `bundled by @chankov/agent-fleet` / `global` — state it in the restate line, no duplicate entries). `pi-codex-image-gen` is not bundled or bootstrapped; offer `pi install -l npm:pi-codex-image-gen` only when the user selects it. Never offer `setup`, `doctor`, or `guided-workspace-setup` — those are installer-only and live in the source agent-fleet repo.

Removal happens **only** on an explicit `Remove some…` multi-select (empty selection = remove nothing), and it is scoped: the screen lists only items whose name is in the agent-fleet inventory **and** that are recorded in `## install-status` (or are symlinks resolving into the source repo). User-authored skills, custom commands, third-party plugins, external pi packages not recorded by this setup, and unrelated settings/env keys are left untouched and logged as "Skipped — not owned by agent-fleet".

**No cross-tool substitution.** Each row is offered only when the source file the chosen agent needs already exists — for `pi`, that means `.pi/prompts/<name>.md`, `.pi/extensions/<name>/`, etc. Never fall back to `.claude/commands/` (or another agent's tree) to satisfy a pi prompt request; items missing their per-agent source are filtered out of the menu entirely.

**Personas are generated for non-pi targets.** The personas group lists the full availability roster from `node <source-root>/bin/cli.js transform-persona --list --agent <agent>`. For `pi` the canonical `agents/<name>.md` installs as-is (copy or symlink). For `claude-code`/`opencode` the apply step runs `transform-persona --agent <agent> --workspace <workspace> <name…>` instead — always a generated copy, even in symlink mode — and records the rows with `transformed: true`; status checks diff against the generated output, not the raw source.

**pi harness companions.** Installing, refreshing, or removing any pi harness also refreshes its companions in the same pass — the `justfile` launch recipes, `scripts/team-up.ts`, the peer/team YAML and personas, `.pi/damage-control-rules.yaml`, and `.pi/harnesses/package.json`. When `agent-hub` is installed or kept, keep its required launch companions together: `damage-control`, `damage-control-continue`, and `ask-user-remote`; the managed `just hub` / `hub-solo` recipes load `damage-control-continue`, then `ask-user-remote`, then `agent-hub` so the dispatcher probe sees `ask_user`. Refresh the `justfile` from the **current** source so retired-harness recipes are pruned and new ones added, rewriting only the managed region between the `agent-fleet:harnesses` sentinels so any user recipes survive. Leaving a stale `justfile` (recipes pointing at deleted harness dirs, or no recipe for a new harness) is the regression this prevents.

**No mid-apply overwrite prompts.** The `mod` description already warns that refreshing overwrites local edits. The user's selection is the consent; the Step 9 confirmation is the single gate. During apply, refresh selected items unconditionally — never pause to ask "should I overwrite this file?". Genuine errors (permission denied, missing source) still stop and report.

Offer override sections for the workspace's `.ai/agent-fleet-overrides.md` based on the analysis (print each draft, then `Accept` / `Edit` / `Skip` per section via `ask_user`), and record what was installed in `.ai/agent-fleet-setup.md`. Print the plan as compact action-grouped lines (Add / Refresh / Remove / Keep-count / Records / Method), then confirm with one `ask_user` single-select asked with `displayMode: "inline"` — `Apply — and remove the installer commands` (default) / `Apply — keep the installer commands` / `Adjust picks` / `Cancel` — and write nothing until an Apply is chosen. Then perform the setup, re-scan for any new breakage, and report what changed.
