---
name: multi-agent-diff-explain
language: en
description: "Map Phase 4 triage findings to branch diff lines. Read-only post-hoc command, used after review to answer 'which finding lines up with which code change'. Use when a review finding has to be traced to the exact lines that caused it."
user-invocable: true
argument-hint: "[#task-id | --triage <path> | --state <path>] [--branch <name>] [--base <name>]"
---

# multi-agent-diff-explain  -  Phase 4 Triage to Diff Bridge

**Input**: $ARGUMENTS

Maps the Phase 4 triage output (`accepted` / `deferred` / `rejected`) to the branch's `git diff` output. For each finding, the relevant file/line hunk is embedded in the output. **Produces no side effects**  -  it only runs `git diff` and emits markdown.

## When to use it

- After Phase 4 but before Phase 5/6: to answer "which finding lines up with which code?".
- Phase 7 reporting content: "review summary with code context" for Wiki / Confluence.
- Post-hoc audit: review-vs-fix comparison for a closed PR.

## Steps

1. **Resolve the input**  -  `$ARGUMENTS`:
   - `#N` or `JIRA-N`: pull the triage from the task state
   - `--triage <path>`: triage-output.json directly
   - `--state <path>`: agent-state.json (embedded triage)

2. **Determine the diff source**:
   - `--branch <name>` (default: HEAD)
   - `--base <name>` (default: origin/main → main)
   - `--diff <path>` (CI/sandbox: precomputed diff)

3. **Run the script**:
   ```bash
   node "$HOME/.copilot/scripts/diff-explain.mjs" \
     --triage "<resolved-path>" \
     --branch "<branch>" \
     --base "<base>"
   ```

4. **Show the output to the user** and optionally add commentary:
   - Phase 3 fix coverage: were all blocking findings touched
   - Deferred follow-up: are they all on the Phase 7 list

## Output template

```markdown
# Phase 4 Triage Diff Bridge

## Summary
- Accepted: 3 (🚫 1 blocking · ⚠️ 1 important · 💡 1 suggestion)
- Deferred: 1 · Rejected: 0 · Approved: ❌ no

## src/api/checkout.ts

### ✅ 🚫 BLOCKING  -  line 102 (opus)
> Race condition: order total computed twice without lock
**Fix:** Compute total once inside the existing transaction block
\`\`\`diff
@@ -98,5 +98,7 @@ ...
\`\`\`
```

Icons:
- Bucket: ✅ accepted · ⏭️ deferred · ❌ rejected
- Severity: 🚫 blocking · ⚠️ important · 💡 suggestion
