---
name: ai-agent-system-bootstrap
Run the plugin suite as the sole orchestrator. Produce a new Agent Team from current repository evidence, validate it outside the repository, then transactionally replace the managed output.
Read these files before dispatching a phase:
../../bundle.yaml for the fixed member allowlist and pipeline. The plugin manifest discovers Skills; this file defines suite execution.../../shared/contracts/bootstrap-run.md for run state.../../shared/policies/ownership-and-rebuild.md for ownership, legacy adoption, and replacement rules.Use only the four companion Skills declared in bundle.yaml. Keep dispatch centralized here; a phase Skill returns its result to this orchestrator and does not call a sibling.
Resolve <suite-root> from this SKILL.md location before running a suite script. Invoke the resolved absolute script path; do not resolve script paths from the target repository working directory.
The global-Skill restriction generated into a target repository governs that repository's future Agent Team. It does not constrain this explicitly invoked suite from dispatching its declared companion Skills.
Skill selection and thread selection are separate decisions. Execute the phases strictly in pipeline order:
Using a companion Skill alone does not create a SubAgent. No phase may begin before its declared input artifact is complete.
Create a BootstrapRun with an absolute repository root, mode: pending, suite version, unique run ID, explicit user constraints, and explicit exclusions. Inspect resolves ownership before the orchestrator sets the final mode.
Completion criterion: the run identifies one repository, the pending mode state, the exact user request, and no unresolved target-path ambiguity.
Dispatch ai-agent-system-inspect with the run. Require a complete ProjectSnapshot; do not let later phases independently reinterpret the repository or the user's scope.
Completion criterion: the snapshot covers every source category required by its contract and classifies existing AGENTS.md and .ai ownership. Resolve BootstrapRun.mode exactly once from that classification.
Dispatch ai-agent-system-design with the immutable snapshot, whose request block carries the verbatim user request and constraints. Require one SystemBlueprint that is the sole design input for rendering and semantic validation.
Completion criterion: every generated Agent, local Skill, workflow, orchestration policy, managed path, and root routing rule appears in the blueprint with no unresolved writer overlap.
Run:
python <suite-root>/shared/scripts/create-staging-area.py --repository <absolute-repository-root> --run-id <run-id>
Dispatch ai-agent-system-render with the BootstrapRun, blueprint, and returned staging path. Rendering may write only inside that staging path.
Completion criterion: RenderResult accounts for every staged file and reports no write outside staging.
Dispatch ai-agent-system-validate with the BootstrapRun, immutable ProjectSnapshot, blueprint, render result, and staging path. Before accepting the report, require its run ID, input snapshot-derived blueprint ID, input render result ID, validated run ID, validated blueprint ID, and candidate digest to match the current run artifacts. Accept passed. Accept passed-with-warnings only when every warning code appears in BootstrapRun.allowed_warning_codes.
Completion criterion: structural and semantic validation both finish and the report contains a final decision.
On an accepted validation report, run:
python <suite-root>/shared/scripts/atomic-replace.py --repository <absolute-repository-root> --staging <absolute-staging-root> --expected-digest <ValidationReport.candidate_digest> --expected-run-id <ValidationReport.validated_run_id> --expected-blueprint-id <ValidationReport.validated_blueprint_id> [--allow-warning <accepted-code>]...
Pass only warning codes accepted in BootstrapRun.allowed_warning_codes. The replacement script binds the staging marker, manifest, validation digest, and installed digest; acquires the repository lock before target-state reads; preserves human-owned AGENTS.md text and unrelated repository Skills; replaces the complete .ai directory plus manifest-listed .agents/skills; migrates the legacy routing marker when present; performs a post-replacement structural check; and rolls back on failure. This is a multi-path transaction with rollback, not a filesystem-wide atomic rename.
Completion criterion: the target repository passes its post-replacement check and no backup or staging directory remains.
blocked or failed.<suite-root>/shared/scripts/cleanup-staging.py; preserve the current repository Agent Team..ai directory, malformed ownership marker, or repository mismatch in the staging marker as blocking evidence.Return:
AGENTS.md status