---
name: multi-agent-channels
description: "Multi-channel reporter  -  Jira/Confluence/Wiki/PR description. Multi-select channels + content, humanizer pass, reviewer-preserving Bitbucket PR PUT. Also writes the run's report to a local file on every run, whatever the channels did. Use to post or redo a run's report; Phase 5 delegates here, or invoke by Jira ID / PR URL / branch."
user-invocable: true
argument-hint: '<Jira-id | PR-url | #N | Jira-url> [--channels pr,jira,confluence,wiki] [--content normal,technical,test,auto-diff,note,test-run] [--flow-run <runId>[,<runId>...]] [--message "..."] [--message-file path] [--dry-run] [--append] [--ready] [--file-only]'
metadata:
  language: en
---

# multi-agent-channels - Multi-Channel Reporter

**Access check, before anything else.** This command can write outside this machine, so a login the site closed is stopped here, before any question or write.

```bash
ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
```

`ACCESS_RC` 3: print `$ACCESS_LINE` as written and stop: no question, no write, attended or unattended. Any other exit continues (the check fails open). Contract: `$HOME/.claude/multi-agent-refs/features/usage-reporting.md` "The access check".

Single entry point for posting a task report to Jira, Confluence, Wiki (component-only) and the PR description. Phase 5 delegates here; users also invoke it post-hoc by Jira ID / PR URL / branch. Copilot CLI: `multi-agent-channels <target>`; Claude Code: `/multi-agent:channels <target>`. Prompts are byte-identical between the two (`smoke-cross-cli-behavior.sh`).

Every run that composes a body also writes it to `task-report.md` beside the run's `agent-log.md`. That file is not a channel and has no setting: it is what a machine with no tracker, an unattended run and a cancelled menu are left with. Contract: `channels/report-file.md`.

References under `$HOME/.claude/multi-agent-refs/channels/` are installed with Claude Code. Before step 1, read `reference.md` there: input forms, flags, target resolution, the mode table, error handling, examples and the Phase 5 delegation contract.

## Flow

1. **Target resolution**: classify the argument (Jira id / url, GitHub or Bitbucket PR URL, `#N`, empty = cwd + branch), resolve Jira <-> PR, detect the remote type. A Phase 5 call passes a state bundle and skips this step.
2. **Context source**: pipeline log (`$HOME/.claude/logs/multi-agent/<project>/<task-id>/agent-log.md`), PR diff, or `--message`. Read `channels/menu.md`.
3. **Menu (multi-select)**: channels + content, pre-ticked from `prefs.global.reportChannels` / `prefs.global.reportContent`; unavailable rows greyed with a reason (`menu.md`). One line above the picker says the report file is always written, and where; zero channels ticked is a valid selection and means file-only.
4. **Mode short-circuit**: `--channels` + `--content` skip the menu, and `--file-only` skips the menu, the gate and the dispatch. Autopilot always pauses at the menu.
5. **Generator**: one section per content source, humanizer per channel. Read `channels/generator.md`. After the humanizer, write the report file (`report-file.mjs write`), before step 6; it always carries one PR-shaped body.
6. **Body preview + approval gate**: interactive runs render every final body and ask Approve & post / Edit (loop) / Skip channels / Cancel BEFORE any external write. Skipped only by autopilot and `--dry-run`. What is posted is byte-identical to the approved preview. Read `channels/preview.md`.
7. **Dispatch**: parallel adapters, never before the gate resolves. The report file is not an adapter and no adapter failure affects it.
8. **Summary**: one status line per adapter, then the `Report file` row last; persist the selections to prefs.

## Channel adapters

- **PR description**: Bitbucket uses a reviewer-preserving PUT built with `jq -n --rawfile`; every PUT includes `reviewers`, `fromRef`, `toRef`, `draft` (and `version`), or the server resets them. GitHub uses `gh pr edit --body-file`. Payload snippet and retry: `channels/pr.md`.
- **Jira comment**: PR link on line 1, then `h2. Geliştirme Özeti`, `h2. Test Senaryoları`, `h2. Etki Analizi`, `h2. Bağlantılar` in that order: never class names, file paths or a diff walk; the technical view stays in the PR. Template: `channels/jira.md`. Post through the publisher, never a hand-rolled `curl`:

  ```bash
  bash "$HOME/.claude/lib/jira-publish.sh" --issue "$JIRA_ID" --body-file "$F" --target comment
  ```

  Issue family (`state.jiraFamily` set): show every write from `jira-family/plan.json` as one multi-select, re-plan with `--skip` for deselected ids, then apply (`$HOME/.claude/multi-agent-refs/features/jira-family.md`):

  ```bash
  bash "$HOME/.copilot/lib/jira-family-write.sh" plan --state "$STATE_FILE" --dev-body "$F"
  bash "$HOME/.copilot/lib/jira-family-write.sh" apply --state "$STATE_FILE"
  ```

- **Confluence page**: token from `keychainMapping.confluence` via `~/.copilot/lib/credential-store.sh get` (missing: Token Save Flow from the setup skill); parent page from recents or a pasted URL. Contract: `channels/confluence.md`.
- **Wiki** (component tasks only): Case A scope multi-select when `taskType=component` and `wiki.enabled=true`, otherwise the Case B menu in `refs/wiki-capture.md`. Contract: `channels/wiki.md`.

## Store compliance

After the content sections, a cached `archiveguard-*.json` or `play-compliance-*.json` report from the last 6 hours appends a `### Store compliance` block when a PR / Jira / Confluence channel is selected; none found: skip silently. Augmentation, not a gate. Table and wording: `channels/generator.md`.

## Required rules

- Bitbucket reviewer preservation: every PR PUT carries current `reviewers`, `fromRef`, `toRef`, `draft`.
- Default is **replace** for the PR description; `--append` opt-in.
- Real newlines + no HTML entities in every body.
- Humanizer per channel; no `<!-- channels:start -->` markers; every body item cites a file / symbol / line.
- Adapter failures are non-blocking.
- Approval before post: autopilot and `--dry-run` are the only bypasses.
- Report file every run: written whenever a body was composed, never gated, never posted; `--dry-run` is the only case that composes and does not write.
- Target length under 80 lines; auto-diff capped at 5 lines per section.

## Autopilot and unattended

Phase 5 always pauses at the channels menu: a 30-min timeout ends the session cleanly, resumable via `/multi-agent:resume` (`refs/phases/modes.md`).

**Unattended (`MULTI_AGENT_UNATTENDED=1`): channels posts nothing.** It still runs with `--file-only`, so the report lands under `LOGS_ROOT`. Phase 5 records `step1.status = "deferred-to-runner"`, and a direct invocation stops before the menu with that status. The autopilot runner publishes only through its own opt-in, and the guard blocks every publisher script and `gh` / `curl` write under the variable. Contract: `$HOME/.claude/multi-agent-refs/features/unattended-security.md`.

## Progress on Copilot

No native TaskCreate UI: `bash ~/.copilot/scripts/phase-tracker.sh sub 5 1 "Channels dispatch" in_progress`, then `completed` after the adapters run.
