# Ecosystem: Pipeline × Marketplace Plugins × Dev-Toolkit MCP

This pipeline is not one repo. It's three, each owned separately, each versioned
separately, wired together at install time and at run time:

| Repo | What it owns | Ships as |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| **`multi-agent-pipeline`** (this repo) | Orchestration: the <!-- fact:phaseCount -->6<!-- /fact -->-phase flow, the <!-- fact:commandCount -->82<!-- /fact --> slash commands, quality gates, review/triage, cross-CLI parity | npm package (`@mmerterden/multi-agent-pipeline`), installs itself onto Claude Code / Copilot CLI / Codex CLI |
| **`multi-agent-plugins`** | Stack knowledge: per-platform component/lifecycle skills (iOS, Android, Frontend, Backend) + shared knowledge | Claude Code marketplace, 6 independently-versioned plugins |
| **`multi-agent-mcp`** | The pipeline's hands on devices and browsers: <!-- fact:toolCount -->272<!-- /fact --> MCP tools across <!-- fact:toolFamilyCount -->25<!-- /fact --> families (simulator/emulator control, end-to-end locators and assertions, memory, crash diagnostics, accessibility audit, store compliance and listing lint, web automation and scraping, Figma-vs-mock design audit with contrast checks, code intelligence, a code graph, a learnings ledger, wallet passes, an agent-DSL batch runner, a full-text context index with text-to-image rendering, provider-backed and community research, opt-in social reading, verified hand-off of simple text tasks to free models, video key frames and transcripts, offline security scoring with evidence checks, SARIF export and MCP config launch-selector audits, read-only access to related repositories at their latest branch, travel document fixtures, a voice channel, App Store Connect and Play Console APIs, virtual iPhones, offline facts about builds you own) | npm package, registered as a standard stdio MCP server on every host |

None of the three depends on the others at the code level. They compose through two
narrow contracts: the **Skill tool** (pipeline → plugin, at Phase 2) and the **MCP
protocol** (pipeline skills → multi-agent-mcp, at Phase 3 / design-check / store-ready).
Either can be swapped or removed without touching the other two's source.

<!-- facts: phaseCount="phases" commandCount="commands" -->
```mermaid
graph LR
    subgraph PIPE ["multi-agent-pipeline (orchestrator)"]
        direction TB
        PHASES["6 phases · 82 commands"]
        GATES["deterministic gates + review triage"]
    end

    subgraph PLUG ["multi-agent-plugins (stack knowledge)"]
        direction TB
        IOSP["ai-ios-toolkit"]
        ANDP["ai-android-toolkit"]
        FEP["ai-frontend-toolkit"]
        BEP["ai-backend-toolkit"]
        COMP["ai-common-toolkit"]
        ANAP["ai-analyst-toolkit"]
    end

    subgraph DTK ["multi-agent-mcp (device/browser hands)"]
        direction TB
        DEV["Device Control (59)"]
        MEM["Memory (2)"]
        CRASH["Crash Diagnostics (2)"]
        A11Y["Accessibility Audit (3)"]
        STORE["Store Compliance (5)"]
        WEB["Web Automation (18)"]
        DESIGN["Design Audit (7)"]
        CODE["Code Intelligence (8)"]
        PASS["Wallet Passes (4)"]
        AGENTDSL["Agent DSL (2)"]
    end

    PHASES -->|"Phase 2: Skill tool<br/>taskType===component"| PLUG
    PHASES -->|"Phase 3 / design-check /<br/>store-ready: MCP tool calls"| DTK
    GATES -.->|"Phase 3 Security Auditor"| STORE

    style PIPE fill:#ffd,stroke:#333
    style PLUG fill:#dfd,stroke:#333
    style DTK fill:#dff,stroke:#333
```

---

## 1. Authoring flow: one source of truth, six sync targets

`~/.claude/` on the maintainer's machine is authoritative. Everything else is a
derived, synced, or independently-shipped artifact. `/multi-agent:sync` is the one
command that walks all six targets in order, detects which are stale, and updates
only those:

<!-- facts: commandCount="sub-command skills" commandCount="refs" agentCount="agent TOML" -->
```mermaid
graph TD
    CC["Claude Code<br/>~/.claude/commands/multi-agent/<br/>(source of truth)"]

    CC -->|"Step 2: copy + reformat<br/>82 sub-command skills"| COP["Copilot CLI<br/>~/.copilot/skills/"]
    CC -->|"Step 2b: transform<br/>(install.js --codex)"| COD["Codex CLI<br/>1 router skill + 82 refs<br/>+ 11 agent TOML"]
    CC -->|"Step 3: genericize<br/>(strip personal data)"| REPO["multi-agent-pipeline repo<br/>pipeline/"]
    CC -->|"Step 4: version + feature sync"| WEB["Website<br/>projects.ts / i18n.tsx"]

    REPO -->|"Step 3c: build-stack-plugins.mjs<br/>rebuilds knowledge/ from<br/>shared/external"| PLUGREPO["multi-agent-plugins repo<br/>(6 plugins)"]

    DTK2["multi-agent-mcp repo<br/>(own codebase, own gates,<br/>NOT generated from Claude)"]
    SYNC3D["Step 3d: detect movement →<br/>gate → commit → publish"]
    CC -.->|"sync only SHIPS this,<br/>never authors it"| SYNC3D
    SYNC3D -.-> DTK2

    REPO -->|"npm publish"| NPM["npm registry (public)"]
    WEB -->|"git push → auto-deploy"| VERCEL["Vercel"]
    PLUGREPO -->|"git push"| MKT["Claude Code marketplace"]
    DTK2 -->|"npm publish"| NPM2["npm registry<br/>(public)"]

    style CC fill:#f9f,stroke:#333
    style DTK2 fill:#dff,stroke:#333,stroke-dasharray: 5 5
```

**Why `multi-agent-mcp` is drawn differently.** The other five targets are _derived_
from the Claude Code source - sync writes their content. `multi-agent-mcp` is not:
it's a separate codebase developed on its own schedule. Sync's Step 3d only
_detects_ whether it moved (dirty tree, unpushed commits, untagged version), runs
**its own** gate suite, and ships it - commit, tag, staged publish (section 6). If the pipeline
needs a tool that toolkit doesn't have yet, that's a two-repo change: add the tool
in `multi-agent-mcp`, ship it, then bump the minimum version pin back in
`cross-cli-contract.md` (see section 4).

**Also not generated: the plugins' own authored skills.** `build-stack-plugins.mjs`
only rebuilds each plugin's `knowledge/` folder from `pipeline/skills/shared/external/`.

That rebuild is what delivers those skills to users. The published package carries
`pipeline/schemas/plugins-pin.json` - a minimum version and the skill names per plugin -
and not the skills themselves; install resolves a copy of the marketplace and delivers
from the first one that satisfies the pin. So the authoring tree reaches a host only
through this step, and `gen-plugins-pin.mjs` regenerates the pin afterwards.
The plugins' lifecycle skills - `create-component`, `evolve-component`,
`figma-utility`, `code-connect`, `branch-and-pr`, `fix-bug`, and the rest - are
hand-authored _inside_ `multi-agent-plugins` and are never touched by sync.

---

## 2. Plugin marketplace build: one authoring source, six versioned artifacts

<!-- facts: skillCount="skills - single authoring source" -->
```mermaid
graph TD
    EXT["pipeline/skills/shared/external/<br/>174 skills - single authoring source<br/>(the pipeline's own phases read these too)"]

    EXT -->|"cross-stack skills"| COMMONP["ai-common-toolkit"]
    EXT -->|"outside facts for analysis"| ANAP["ai-analyst-toolkit"]
    EXT -->|"Apple/Xcode-only"| IOSP["ai-ios-toolkit"]
    EXT -->|"Android/Kotlin-only"| ANDP["ai-android-toolkit"]
    EXT -->|"backend-only"| BEP["ai-backend-toolkit"]
    EXT -->|"web/frontend-only"| FEP["ai-frontend-toolkit"]

    COMMONP --> BUMP{"skill set<br/>changed?"}
    ANAP --> BUMP
    IOSP --> BUMP
    ANDP --> BUMP
    BEP --> BUMP
    FEP --> BUMP
    BUMP -->|yes| PATCH["bump that plugin's<br/>patch version"]
    BUMP -->|no| SKIP["idempotent no-op"]

    PATCH --> CONSUMER["/multi-agent:update<br/>→ plugin marketplace update + plugin update"]

    style EXT fill:#ffd,stroke:#333
```

Together the plugins carry more skills than the <!-- fact:skillCount -->174<!-- /fact -->-skill source because each
plugin also carries its own authored `reference/`, `workflow/` and `tools/`
skills and an `index` router. A vendored knowledge skill ships in exactly one
plugin: cross-stack skills go to `ai-common-toolkit` rather than into every
stack plugin, and the marketplace's `tools/validate.py` fails a skill that
appears in two. Versioning is per-plugin and patch-only from this
generator - a repo enabling only `ai-ios-toolkit` never pulls an Android-only
change.

**Consumption is pull, not push.** A consumer repo enables a stack plugin once
(`/multi-agent:stack ios`, writing the enabled-plugins list into
`.claude/settings.json`) and picks up new plugin versions only when it runs
`/multi-agent:update`, which refreshes the catalog with `claude plugin marketplace update multi-agent-plugins` and then runs `claude plugin update` for each installed plugin (`pipeline/scripts/plugin-refresh.sh`).
Publishing a new plugin version does not retroactively change anything already
running in a consumer's session.

---

## 3. Per-host delivery: the same three repos, four different shapes

The three repos land differently on each host, because each host's skill-loading
behavior is different (see `pipeline/multi-agent-refs/cross-cli-contract.md` for the
measurements behind this table):

| | Claude Code | Copilot CLI | Codex CLI | Local LLM |
| ---- | ---- | ---- | ---- | ---- |
| **Pipeline commands** | <!-- fact:commandCount -->82<!-- /fact --> slash-command skills, native | <!-- fact:commandCount -->82<!-- /fact --> sub-command skills, `multi-agent-{cmd}` naming, copied in | 1 router skill (`multi-agent`) + <!-- fact:commandCount -->82<!-- /fact --> command specs as reference files - Codex silently truncates its skills block past a few dozen entries, so sub-commands are not peer skills here | 1 router skill + <!-- fact:commandCount -->82<!-- /fact --> command specs as reference files, the Codex shape in `~/.codex-local/` |
| **Pipeline refs** (phase specs, contracts, standalone command specs) | `~/.claude/multi-agent-refs/`                                                         | `~/.copilot/multi-agent-refs/`, with every ref path retargeted into it, so a Copilot-only machine resolves them on its own; the per-sub-command specs are not copied there, because each already ships as its own skill and the rewrite points at those | `~/.codex/multi-agent-refs/`, including the per-sub-command specs, which the router reads by path                                                                                                                           | `~/.codex-local/multi-agent-refs/`, the same tree as Codex CLI with the root rewritten |
| **Stack plugins** | Marketplace plugin, loaded natively, resolved by `.claude/settings.json` enabled-list | Enabled plugin's authored skills and `knowledge/` tree copied flat into `~/.copilot/skills/`, from the marketplace copy `install/_external-source.mjs` resolved | Copied as reference files under `~/.codex/multi-agent-refs/skills/`, plugin-prefixed on name clash (e.g. `architecture` → `ai-ios-toolkit-architecture`) | Copied as reference files under `~/.codex-local/multi-agent-refs/skills/`, as on Codex CLI |
| **Component dispatch (Phase 3)**                                     | Marketplace plugin's `create-component`/`create-screen` skill via the Skill tool      | No plugin loader - the enabled stack plugin's authored skills (incl. `create-component`) are copied flat into `~/.copilot/skills/` at install time (the old frozen `figma-*` copies are pruned, they were never a fallback)                             | Not part of the enforced parity axis; classification + state-shape must match, skill _inventory_ does not                                                                                                                   | Same as Codex CLI: classification and state shape match, skill inventory does not |
| **multi-agent-mcp** | `claude mcp add multi-agent -- npx -y @mmerterden/multi-agent-mcp` | `copilot mcp add multi-agent -- npx -y @mmerterden/multi-agent-mcp` | `codex mcp add multi-agent -- npx -y @mmerterden/multi-agent-mcp` (skipped with a warning if `codex` isn't on `PATH`) | Registered against this host's own home, so the engine's Codex install is left alone |

`smoke-cross-cli-behavior.sh` and `smoke-codex-install.sh` gate the axes that **do**
have to match (phase labels, placeholder vocabulary, output schemas, command↔skill
parity count); the table above marks the axes that are allowed to diverge by design.

---

## 4. Runtime: what actually happens during a task

Two independent hand-offs happen inside a single pipeline run, neither aware of the
other:

```mermaid
graph TD
    START["Task running: Phase 2 (Dev)"]
    START -->|"taskType !== component"| TDD["Standard TDD loop<br/>(pipeline's own code)"]
    START -->|"taskType === component<br/>+ figmaUrl present"| VALIDATE["ai-ios-toolkit:figma-validate<br/>(registry, Code Connect, token compliance)"]
    VALIDATE -->|pass| DISPATCH["Skill tool →<br/>create-component / create-screen<br/>/ evolve-component (dual-name fallback)"]
    VALIDATE -->|fail| HALT1["halt Phase 2, surface why"]
    DISPATCH --> REPORT1["plugin returns build/test status →<br/>dispatch layer writes state.phases['2'].subphases[]"]

    REPORT1 --> P3["Phase 3: Review + user test"]

    P3 -->|"UI bug hunt / manual-test /<br/>design-check / store-ready"| MCP["MCP tool call over stdio<br/>e.g. ios_xcodebuild, design_visual_compare,<br/>ios_app_store_audit"]
    MCP --> DTKPROC["multi-agent-mcp process<br/>(npx @mmerterden/multi-agent-mcp)"]
    DTKPROC -->|"result: screenshot / xcresult ID /<br/>18-rule audit verdict"| P3

    style DISPATCH fill:#dfd,stroke:#333
    style MCP fill:#dff,stroke:#333
    style HALT1 fill:#fdd,stroke:#333
```

**Phase 2 → plugin** is a one-shot delegation: the plugin skill does its own
lifecycle (test → code → build → wiki) and reports back a coarse
`component-build` result; the pipeline does not re-implement any of that logic, and
a plugin failure counts against the pipeline's own retry cap (the build-retry cap of 3, `retryCount` →
hard stop, per `component-dispatch.md`).

**`/multi-agent:scaffold` → plugin** uses the same seam for a new project: the
enabled toolkit's `scaffold` skill writes the skeleton and a `.scaffold.json`
manifest, and the pipeline judges the result with the stack adapter's build,
test and lint commands before the first commit.

**Phase 3 (and design-check / store-ready) → multi-agent-mcp** is a long-lived MCP
session, not a one-shot call: the same stdio server process answers many tool
calls across a phase (boot simulator once, then screenshot/tap/screenshot/tap...).
Several pipeline skills pin a **minimum toolkit version** for a specific tool -
e.g. `apple-archive-compliance` requires `ios_app_store_audit` from
`multi-agent-mcp ≥ v3.0.0` - enforced in `cross-cli-contract.md` and checked by
`/multi-agent:sync` Step 3d before any multi-agent-mcp release ships (a version bump
that drops or renames a tool a pipeline skill depends on is a **major** bump, by
that step's own contract).

### Unattended runs and the toolkit

An autopilot run nobody watches uses the same MCP contract, narrowed by the
runner before it launches the session. The child gets
`MCP_TOOLKIT_URL_POLICY=strict` and `MCP_TOOLKIT_INDEX_DENY` (the runner refuses to launch without the guard
registered, and `launch.json` carries both). Under `strict` the toolkit's web
tools refuse loopback, private, link-local and metadata addresses on every
request the browser makes, and `context_*` will not index or return the denied
paths. On top of that the pipeline's guard holds `WebFetch` and the `web_*`
tools to its own network allowlist and refuses `web_eval`, the `research_*`
tools, and `llm_delegate` unless `route-on --free` is on. Autonomous research
passes also deny `research_community`, `social_read`, `media_transcript` and
`llm_delegate`. `social_read` refuses itself when `MULTI_AGENT_UNATTENDED=1`,
`media_transcript` needs the `media-remote` capability, and `research_community`
needs `research-community`.

Detail: [`unattended-security.md`](../pipeline/multi-agent-refs/features/unattended-security.md).

### multi-agent-mcp's tools, by category

<!-- fact:toolCount -->272<!-- /fact --> tools in <!-- fact:toolFamilyCount -->25<!-- /fact --> families, counted from the server's own `tools/list` response

at toolkit <!-- fact:toolkitVersion -->4.6.0<!-- /fact --> rather than from a README. Three families are defined in
modules the main file only spreads in, so a count taken from the source reads
low; the response is the only place the whole surface appears at once. A
family is the prefix every tool name carries.

One naming rule for a toolkit tool: a ref under `pipeline/multi-agent-refs/`
writes `mcp__multi-agent__<tool>`, the name the host shows, in a call
instruction, and a prose mention may use the bare tool name. A skill writes
`multi-agent:<tool>`; `lint-mcp-refs.mjs` rejects the `mcp__` form in a
skill body and leaves frontmatter `allowed-tools` alone. A skill the
marketplace plugins are built from (`pipeline/skills/shared/external/`)
writes `mcp__multi-agent__<tool>` instead, the only name a host lets a model
call, and the lint rejects `multi-agent:<tool>` there, which reads like a
skill or a command such as `multi-agent:review`. Both qualified forms
let `lint-mcp-refs.mjs` check that the tool exists.

The families can be narrowed per host: `MCP_TOOLKIT_CAPS` serves only the named
ones, and unset serves all <!-- fact:toolCount -->272<!-- /fact -->. A frontend repo that sets `web,code,context`
sees 50 tools instead of <!-- fact:toolCount -->272<!-- /fact -->, which matters because every registered server's
tool list is charged against the context window on every turn.

Per-family tool counts are `toolCategories` in [`facts.json`](facts.json), taken from the
server's own `tools/list`. Every family's stacks and the phase refs or commands that call
it are in [`toolkit-tools.md`](../pipeline/multi-agent-refs/toolkit-tools.md), which
`lint-mcp-refs.mjs` holds to the live list.

| Family | Primary pipeline consumers |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ios` | Simulator control, UI tree, crash sweep (`ios_list_crashes`), leaks, accessibility audits, archive and App Store audits, `ios_testflight_validate`, `ios_xcodebuild` / `ios_xcresult`, `ios_visual_diff`: `/multi-agent:test`, `test-dark-mode`, `test-accessibility`, `test-dynamic-type`, `test-screenshots`, `manual-test`, `sim-test`, `design-check`, `store-ready`, `testflight-validation` |
| `web` | frontend-stack UI testing (via `test`) and the `e2e-testing` skill: snapshot `ref` targeting and `web_find`, console/network capture, request mocking, offline, clock, dialogs, uploads, traces, ARIA assertions; `web_scrape` for Phase 1 `generic-doc` links; sitemap-aware `web_map` and `web_crawl` with `llms.txt` |
| `android` | Emulator control, UI tree, crash sweep, `android_meminfo`, accessibility and APK audits, launch time: the same test commands as `ios` on Android |
| `store` | App Store Connect and Play Console APIs, `store_listing_lint`, `store_review_themes`, `store_screenshot_*` (store sizes, offline size check, rendering): `/multi-agent:store-ready`, `/multi-agent:test-screenshots`, `complaint-analysis`, `/multi-agent:setup` credential onboarding, the `store-screenshots` skill |
| `vphone` | virtual iPhones from the separately installed vphone-launchpad host, reached outside a run (`outside-the-pipeline.md`): lifecycle, screenshots, UI tree, element-based tap, typing and waits, app listing and launch, URL opening, `vphone_rpc`; the iOS stack guide lists them |
| `code` | `/multi-agent:refactor`, Phase 3 reviewers needing a real symbol graph rather than grep |
| `design` | `design-check` (mock-mode vs Figma conformance, component variants, `design_visual_compare`, `design_contrast_check`) |
| `graph` | `/multi-agent:graph` and the code-graph feature: projects, queries, neighbours, paths, `graph_stats`, `graph_hubs`, `graph_cluster` |
| `repo` | Phase 1 Step 1.6 product context, Phase 3 platform parity, `/multi-agent:review`, `/multi-agent:analysis`; read-only, pinned to a sha |
| `voice` | the local voice host outside a run: speak, ask aloud, answer a permission prompt (`outside-the-pipeline.md`) |
| `ui` | `ui_locate` and target checks for end-to-end steps: `/multi-agent:test`, `/multi-agent:bug-bash`, the `e2e-testing` skill |
| `context` | any skill holding an offloaded payload too large to read; ranks passages instead of grepping lines. `context_render` pages long text into images and reports whether that is cheaper than the text |
| `pass` | Apple Wallet passes outside a run: inspect, validate, certificates, build (`outside-the-pipeline.md`); the iOS stack guide lists them |
| `security` | `security_cvss_score`, `security_dep_inventory`, `security_evidence_check`, `security_sarif_export`, `security_mcp_config_audit`: the Phase 3 security audit (`security-auditor`) and `/multi-agent:security-review`; offline, no egress |
| `binary` | `binary_inspect`, `binary_strings_endpoints`, `binary_compare_versions`, `binary_endpoints_vs_observed`, `binary_js_modules`: optional build facts for `/multi-agent:store-ready` Gate 1 and `/multi-agent:security-review` ([`build-facts.md`](../pipeline/multi-agent-refs/features/build-facts.md)) and the `reverse-engineer-own-app` skill; read-only, offline |
| `document` | the `e2e-testing` skill's MRZ and document-scan recipes, `document_pdf_inspect` |
| `learnings` | `learnings_search`, `learnings_timeline`, `learnings_get`: the knowledge ledger and `/multi-agent:search` |
| `research` | `research_search`, `research_ask`, `research_community`: the research engine, `signal-community`, `/multi-agent:refactor` band E. `research_community` is off unless `MCP_TOOLKIT_CAPS` has `research-community`. Denied in unattended runs and autonomous research |
| `agent` | `agent_run_steps`, `agent_query_output`: any skill that needs a scripted multi-step device flow in one round trip |
| `llm` | `llm_delegate`, `llm_providers`: `route-on --free` ([`free-models.md`](../pipeline/multi-agent-refs/features/free-models.md)). Denied in autonomous research passes |
| `media` | `media_frames` for Phase 2 visual evidence and `media_redact` before a capture goes into a PR; `media_transcript` for the research engine, off unless `MCP_TOOLKIT_CAPS` has `media-remote`, and in an unattended run its video host must be on the network allowlist; `media_video_*`, `media_music_beats` and `media_thumbnail_check` for a release video (the `release-video` skill); `media_ink_plan`, `media_ink_check` and `media_ink_render` for a procedural pen-on-paper animation (the `ink-animation` skill) |
| `coverage` | `coverage_gap`: `/multi-agent:test-gen` |
| `social` | `social_read` for the research engine, off unless `MCP_TOOLKIT_CAPS` has `social`, never unattended |
| `test` | `test_results_classify`: test-result triage |
| `thesis` | thesis and long-paper checks: bibliography, citations, structure, reference lists, Crossref verification, self-overlap, academic style; the `thesis-writing` skill, outside a run (`outside-the-pipeline.md`) |

---

## 5. Why the boundary is drawn where it is

- **Pipeline ↔ plugins boundary = Skill tool, one direction.** The pipeline
  classifies (`taskType`, `componentScope`) and tracks state; it never reads or
  writes plugin-internal files. This is why a corporate marketplace can ship a
  same-named plugin (`ai-ios-toolkit:create-ui-component` vs the public
  `create-component`) and dispatch still resolves correctly - the dual-name
  fallback lives in the pipeline, the implementation stays entirely in whichever
  plugin is enabled.
- **Pipeline ↔ multi-agent-mcp boundary = MCP protocol, versioned contract.** The
  pipeline never shells out to `xcrun simctl` or `adb` directly; every device/browser
  action is a declared MCP tool call with a minimum-version pin. That's what lets
  `multi-agent-mcp` ship on its own release cadence (its own gates, its own
  `npm publish`) without a pipeline release, as long as pinned tools keep their
  contract.
- **Neither boundary is symmetric.** The pipeline depends on both other repos being
  present _for specific task types_ (component work, UI testing) but functions
  without either - a non-component bugfix task never touches the plugin marketplace,
  and a task with no UI-testing step never opens the MCP connection.

---

## 6. Release step: staged npm publish

Both npm packages, the pipeline and `multi-agent-mcp`, are published
with `pipeline/scripts/publish-staged.mjs` from a clean checkout of the
release tag, never with a bare `npm publish`. `latest` then only ever names a
version the registry was seen to serve and that installed:

1. `npm pack`, and the tarball's sha512 computed locally; npm's reported
   integrity must agree.
2. `npm publish <tarball> --tag candidate`. A version the registry already
   holds with the same bytes is a resumed release and is not published again;
   with other bytes it is refused.
3. Poll the packument over HTTP (not `npm view`, whose cache answers before
   the registry does) until the version carries the local integrity and the
   `candidate` tag names it. A different integrity fails at once.
4. Download the tarball the registry serves and compare its sha512.
5. Install that tarball into an empty temp project with scripts off, and check
   the installed version and its bins.
6. Run `--smoke "<cmd>"` in that project, when given.
7. `npm dist-tag add <name>@<version> latest`, then poll until `latest` names it.

```bash
node pipeline/scripts/publish-staged.mjs --dir . --userconfig "$TMP_NPMRC" \
  --smoke "node node_modules/@mmerterden/multi-agent-pipeline/index.js --version"
```

`--userconfig` points every npm call at a temporary npmrc built from the
credential store, so the token never reaches argv. Exit 0 means promoted; 1
means nothing was published; 3 means the version is on `candidate` and
`latest` did not move, and running the same command again resumes from the
registry check. `--dry-run` stops after the pack. `test/publish-staged.test.mjs`
drives the whole flow against a fake npm and a fake registry, including a
corrupted upload, a slow registry, a failed install, a failed smoke and a
resumed release.
