@mmerterden/multi-agent-pipeline 23.6.0 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/README.md +61 -27
  3. package/README.tr.md +46 -12
  4. package/SECURITY.md +3 -3
  5. package/docs/architecture.md +47 -8
  6. package/docs/ecosystem.md +20 -18
  7. package/docs/engineering.md +1 -1
  8. package/docs/facts.json +8 -6
  9. package/docs/features.md +59 -15
  10. package/install/_codex-agents.mjs +13 -8
  11. package/install/_common.mjs +24 -0
  12. package/install/_dev-only-files.mjs +4 -0
  13. package/install/_mcp-register.mjs +6 -2
  14. package/install/_rewrite-tree.mjs +197 -0
  15. package/install/codex.mjs +96 -180
  16. package/install/copilot.mjs +24 -54
  17. package/install/index.mjs +29 -11
  18. package/install/templates/codex-instructions.md +21 -5
  19. package/install/templates/copilot-instructions.md +21 -14
  20. package/manifest.json +2082 -0
  21. package/package.json +6 -2
  22. package/pipeline/commands/multi-agent/SKILL.md +7 -5
  23. package/pipeline/commands/multi-agent/analysis/SKILL.md +4 -0
  24. package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
  25. package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
  26. package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
  27. package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
  28. package/pipeline/commands/multi-agent/resume/SKILL.md +2 -0
  29. package/pipeline/commands/multi-agent/review-rounds/SKILL.md +94 -0
  30. package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
  31. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  32. package/pipeline/contract/manifest.json +1 -1
  33. package/pipeline/contract/types/index.d.ts +1 -0
  34. package/pipeline/lib/_jira-auth.sh +50 -78
  35. package/pipeline/lib/_service-account.sh +191 -0
  36. package/pipeline/lib/credential-inventory.sh +49 -37
  37. package/pipeline/lib/credential-store.sh +48 -3
  38. package/pipeline/lib/fetch-confluence.sh +76 -92
  39. package/pipeline/lib/fetch-crashlytics.sh +30 -59
  40. package/pipeline/lib/fetch-figma-annotations.sh +9 -9
  41. package/pipeline/lib/fetch-fortify.sh +77 -81
  42. package/pipeline/lib/fetch-graylog.sh +38 -77
  43. package/pipeline/lib/figma-mcp-refresh.sh +23 -4
  44. package/pipeline/lib/figma-screenshot.sh +7 -8
  45. package/pipeline/lib/figma-token.sh +39 -46
  46. package/pipeline/lib/host.mjs +138 -0
  47. package/pipeline/lib/host.sh +48 -0
  48. package/pipeline/lib/issue-fetcher.sh +25 -41
  49. package/pipeline/lib/jira-publish.sh +23 -21
  50. package/pipeline/lib/local-model.mjs +93 -0
  51. package/pipeline/lib/md2confluence-v3.py +37 -30
  52. package/pipeline/lib/model-dispatch.sh +41 -4
  53. package/pipeline/lib/model-resolve.mjs +58 -0
  54. package/pipeline/lib/post-pr-review.sh +38 -53
  55. package/pipeline/lib/reviewer-families.mjs +70 -0
  56. package/pipeline/lib/service-account.mjs +2131 -0
  57. package/pipeline/lib/service-account.sh +35 -0
  58. package/pipeline/lib/usage-names.generated.mjs +3 -0
  59. package/pipeline/lib/usage-token.mjs +64 -24
  60. package/pipeline/lib/usage-vocab.mjs +1 -1
  61. package/pipeline/lib/user-facing.mjs +11 -3
  62. package/pipeline/lib/vercel-deploy.sh +17 -26
  63. package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
  64. package/pipeline/multi-agent-refs/_input-parser.md +1 -1
  65. package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
  66. package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
  67. package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
  68. package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
  69. package/pipeline/multi-agent-refs/channels/generator.md +10 -2
  70. package/pipeline/multi-agent-refs/channels/menu.md +3 -1
  71. package/pipeline/multi-agent-refs/channels/preview.md +3 -1
  72. package/pipeline/multi-agent-refs/channels/reference.md +16 -2
  73. package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
  74. package/pipeline/multi-agent-refs/component-dispatch.md +2 -2
  75. package/pipeline/multi-agent-refs/cross-cli-contract.md +38 -30
  76. package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +4 -4
  77. package/pipeline/multi-agent-refs/features/doctor.md +37 -11
  78. package/pipeline/multi-agent-refs/features/free-models.md +3 -3
  79. package/pipeline/multi-agent-refs/features/local-model.md +87 -0
  80. package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
  81. package/pipeline/multi-agent-refs/features/product-context.md +6 -5
  82. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  83. package/pipeline/multi-agent-refs/features/review-rounds.md +40 -0
  84. package/pipeline/multi-agent-refs/features/rework-escalation.md +5 -4
  85. package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
  86. package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
  87. package/pipeline/multi-agent-refs/help/en.md +31 -2
  88. package/pipeline/multi-agent-refs/help/tr.md +31 -2
  89. package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +3 -2
  90. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
  91. package/pipeline/multi-agent-refs/phases/modes.md +20 -1
  92. package/pipeline/multi-agent-refs/phases/operations.md +1 -1
  93. package/pipeline/multi-agent-refs/phases/phase-0-init.md +1 -1
  94. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
  95. package/pipeline/multi-agent-refs/phases/phase-3-review.md +7 -3
  96. package/pipeline/multi-agent-refs/phases/phase-5-report.md +12 -10
  97. package/pipeline/multi-agent-refs/phases.md +4 -3
  98. package/pipeline/multi-agent-refs/resume/details.md +2 -0
  99. package/pipeline/multi-agent-refs/review/panel.md +30 -18
  100. package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
  101. package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
  102. package/pipeline/multi-agent-refs/sync/overview.md +11 -5
  103. package/pipeline/multi-agent-refs/tracker-contract.md +28 -10
  104. package/pipeline/office/index.html +4 -4
  105. package/pipeline/schemas/agent-state.schema.json +19 -1
  106. package/pipeline/schemas/autopilot-config.schema.json +29 -4
  107. package/pipeline/schemas/hosts.json +512 -0
  108. package/pipeline/schemas/hosts.schema.json +310 -0
  109. package/pipeline/schemas/launch.json +22 -2
  110. package/pipeline/schemas/launch.schema.json +2 -1
  111. package/pipeline/schemas/phases.json +21 -3
  112. package/pipeline/schemas/phases.schema.json +8 -0
  113. package/pipeline/schemas/prefs.schema.json +346 -7
  114. package/pipeline/schemas/token-budget.json +2 -2
  115. package/pipeline/scripts/.doctor-mut.47076.mjs +2253 -0
  116. package/pipeline/scripts/_autopilot-config.mjs +67 -4
  117. package/pipeline/scripts/_autopilot-item.mjs +67 -0
  118. package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
  119. package/pipeline/scripts/_cost.mjs +75 -3
  120. package/pipeline/scripts/analysis-sources.mjs +22 -5
  121. package/pipeline/scripts/analysis-unattended.mjs +360 -0
  122. package/pipeline/scripts/anonymize-findings.mjs +3 -7
  123. package/pipeline/scripts/autopilot-arming.mjs +19 -10
  124. package/pipeline/scripts/autopilot-intake.mjs +124 -27
  125. package/pipeline/scripts/autopilot-menubar.swift +7 -0
  126. package/pipeline/scripts/autopilot-runner.mjs +77 -48
  127. package/pipeline/scripts/autopilot-status.sh +32 -9
  128. package/pipeline/scripts/bulk-read.sh +37 -5
  129. package/pipeline/scripts/confluence-readback.mjs +15 -7
  130. package/pipeline/scripts/cost-table.json +65 -25
  131. package/pipeline/scripts/doctor.mjs +119 -32
  132. package/pipeline/scripts/entry-mode.mjs +101 -0
  133. package/pipeline/scripts/estimate.mjs +30 -16
  134. package/pipeline/scripts/feedback-send.mjs +11 -8
  135. package/pipeline/scripts/gen-facts.mjs +16 -13
  136. package/pipeline/scripts/jira-attach.sh +23 -28
  137. package/pipeline/scripts/jira-search.sh +5 -21
  138. package/pipeline/scripts/launch-request.mjs +15 -9
  139. package/pipeline/scripts/migrate-prefs.mjs +56 -0
  140. package/pipeline/scripts/phase-tracker.sh +146 -38
  141. package/pipeline/scripts/priority-review.mjs +14 -7
  142. package/pipeline/scripts/product-context.mjs +26 -7
  143. package/pipeline/scripts/prune-logs.sh +4 -2
  144. package/pipeline/scripts/report-file.mjs +285 -0
  145. package/pipeline/scripts/review-rounds.mjs +592 -0
  146. package/pipeline/scripts/rework-escalation.mjs +26 -7
  147. package/pipeline/scripts/service-read.mjs +19 -17
  148. package/pipeline/scripts/skill-siblings.mjs +17 -1
  149. package/pipeline/scripts/status-overview.mjs +20 -10
  150. package/pipeline/scripts/uninstall.mjs +145 -57
  151. package/pipeline/scripts/usage-register.mjs +34 -11
  152. package/pipeline/scripts/usage-report.mjs +31 -26
  153. package/pipeline/scripts/validate-state.mjs +19 -11
  154. package/pipeline/scripts/validate-triage.mjs +11 -1
  155. package/pipeline/scripts/work-items.mjs +25 -28
  156. package/pipeline/scripts/write-store-config.mjs +37 -11
  157. package/pipeline/skills/.skill-manifest.json +11 -7
  158. package/pipeline/skills/.skills-index.json +13 -2
  159. package/pipeline/skills/shared/README.md +4 -3
  160. package/pipeline/skills/shared/core/multi-agent/SKILL.md +14 -6
  161. package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
  162. package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
  163. package/pipeline/skills/shared/core/multi-agent-resume/SKILL.md +1 -1
  164. package/pipeline/skills/shared/core/multi-agent-review-rounds/SKILL.md +92 -0
  165. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  166. package/pipeline/skills/skills-index.md +2 -1
  167. package/pipeline/lib/credential-resolve.mjs +0 -75
@@ -51,7 +51,6 @@ import { DEFAULT_ENDPOINT, canonicalEndpoint, registerUrlAllowed } from "../lib/
51
51
  import { homedir, platform } from "os";
52
52
  import { dirname, join } from "path";
53
53
  import { fileURLToPath, pathToFileURL } from "url";
54
- import { execFileSync } from "child_process";
55
54
  import { randomBytes } from "crypto";
56
55
  import { costUsd } from "./_cost.mjs";
57
56
  import { defaultPrefsPath, identityHidden, resolveReportingLogin } from "./usage-identity.mjs";
@@ -59,6 +58,7 @@ import { installedVersion, lifecycleEvent } from "../lib/usage-lifecycle.mjs";
59
58
  import { lockTimeoutFrom, updateJsonFileSync } from "../lib/json-file-lock.mjs";
60
59
  import { ALWAYS_ON, KNOWN_STACKS, STACK_PLUGIN_ALIAS } from "./_stack-routing.mjs";
61
60
  import { exitOnHelp } from "../lib/cli-help.mjs";
61
+ import { resolveSecret } from "../lib/service-account.mjs";
62
62
  import { detachSelf, shouldDetach } from "../lib/detach-self.mjs";
63
63
  import { isPublicMcpServer, publicServerName } from "../lib/public-mcp-servers.mjs";
64
64
  import { MCP_SERVER_ID } from "../lib/mcp-rename.mjs";
@@ -227,32 +227,22 @@ function resolvePrefs() {
227
227
 
228
228
  /**
229
229
  * Resolve the ingest token without ever storing it in a synced file.
230
- * Order: env, then prefs.usageLog.token, then the Keychain entry mapped by
231
- * prefs.global.keychainMapping.usage_ingest (via credential-store.sh). This
232
- * lets update flip usageLog.enabled on while the secret stays in the Keychain.
230
+ *
231
+ * Order: env, then prefs.usageLog.token, then the account resolver, which
232
+ * reads the store only for the endpoint this report is actually being sent
233
+ * to. That last step is the change: before it, the token was read whatever
234
+ * the endpoint was, so an endpoint edited in the preferences file carried the
235
+ * same token to somewhere else entirely.
233
236
  */
234
237
  function resolveToken() {
235
238
  if (process.env.MULTI_AGENT_USAGE_TOKEN) return process.env.MULTI_AGENT_USAGE_TOKEN;
236
239
  const g = resolveGlobalPrefs();
237
240
  const inline = g.usageLog?.token;
238
241
  if (typeof inline === "string" && inline.trim()) return inline.trim();
239
- const name = g.keychainMapping?.usage_ingest;
240
- if (typeof name === "string" && name.trim()) {
241
- const store = hostFile("lib", "credential-store.sh");
242
- if (store) {
243
- try {
244
- const out = execFileSync("bash", [store, "get", name.trim()], {
245
- encoding: "utf-8",
246
- timeout: 4000,
247
- stdio: ["ignore", "pipe", "ignore"],
248
- }).trim();
249
- if (out) return out;
250
- } catch {
251
- /* keychain unavailable - stay silent */
252
- }
253
- }
254
- }
255
- return "";
242
+ const endpoint = g.usageLog?.endpoint;
243
+ if (typeof endpoint !== "string" || !endpoint.trim()) return "";
244
+ const answer = resolveSecret({ service: "usage_ingest", url: endpoint.trim() });
245
+ return answer.ok ? answer.secret.trim() : "";
256
246
  }
257
247
 
258
248
  // A plugin key mapped to `false` is de-selected (e.g. /multi-agent:stack writes
@@ -658,14 +648,25 @@ function commandName(state) {
658
648
  * invoked command when it names a mode, an explicit state.mode, the autopilot
659
649
  * flag (the mode phases.json marks autopilot: true), then "full", which is
660
650
  * what an absent mode means in agent-state.schema.json.
651
+ *
652
+ * A run that carries the autopilot flag resolves to the unattended variant of
653
+ * whatever mode it is in, when the contract declares one: `/multi-agent:analysis
654
+ * <ref> autopilot` is `analysis-autopilot`, not the attended `analysis` it would
655
+ * otherwise read as. The panel's whole question about a mode is what it cost
656
+ * and how it ended, and those differ between the two.
661
657
  */
662
658
  export function modeOf(state, modes = allowedModes()) {
663
659
  const names = Object.keys(modes);
664
660
  const has = (n) => typeof n === "string" && names.includes(n);
661
+ const unattended = (n) => {
662
+ if (!state.autopilot || modes[n]?.autopilot === true) return n;
663
+ const variant = names.find((v) => v === `${n}-autopilot` && modes[v]?.autopilot === true);
664
+ return variant || n;
665
+ };
665
666
  const cmd = commandName(state);
666
- if (has(cmd)) return cmd;
667
+ if (has(cmd)) return unattended(cmd);
667
668
  if (typeof state.mode === "string" && state.mode.trim()) {
668
- return has(state.mode.trim()) ? state.mode.trim() : "unknown";
669
+ return has(state.mode.trim()) ? unattended(state.mode.trim()) : "unknown";
669
670
  }
670
671
  if (state.autopilot === true) {
671
672
  const ap = names.find((n) => modes[n]?.autopilot === true);
@@ -1363,9 +1364,13 @@ async function selfHeal(rejectedToken) {
1363
1364
  * The login to name a run after. A context that cannot see this machine's
1364
1365
  * accounts (usage-identity.mjs `hidden`) falls back to the login an earlier
1365
1366
  * check cached; the server names the record after the token's login anyway.
1367
+ *
1368
+ * `write: false` resolves without caching the answer in preferences. A dry run
1369
+ * passes it: the environment it resolves under is its caller's, not the one a
1370
+ * real send would use, so remembering its verdict would decide the next run.
1366
1371
  */
1367
- function reportingLogin(prefs) {
1368
- const who = registeredLogin(prefs) ?? resolveReportingLogin();
1372
+ function reportingLogin(prefs, { write = true } = {}) {
1373
+ const who = registeredLogin(prefs) ?? resolveReportingLogin({ write });
1369
1374
  if (who.login || !who.hidden) return who;
1370
1375
  const cached = typeof prefs?.login === "string" ? prefs.login.trim() : "";
1371
1376
  return /^[A-Za-z0-9][A-Za-z0-9_-]{0,38}$/.test(cached) ? { ...who, login: cached } : who;
@@ -1449,7 +1454,7 @@ async function main() {
1449
1454
  if (args.status) state.status = args.status;
1450
1455
  const kind = EVENT_KINDS.includes(args.event) ? args.event : null;
1451
1456
 
1452
- const who = reportingLogin(prefs);
1457
+ const who = reportingLogin(prefs, { write: !args.dryRun });
1453
1458
  if (!who.login) {
1454
1459
  process.stderr.write(`usage-report: not sent - ${who.reason}\n`);
1455
1460
  if (!args.dryRun) {
@@ -126,21 +126,29 @@ async function main() {
126
126
  errors.push(`phases["${k}"] must be an object`);
127
127
  continue;
128
128
  }
129
- // The rework cap. Every phase doc says "hard-kill at retryCount === 3"
130
- // and the schema writes `maximum: 3`, but nothing read either: a fourth
131
- // round produced a state that violates the schema and passed this
132
- // validator, which is the one place that could have said so.
133
- //
134
- // What this does NOT do is stop the loop - that is the orchestrator's
135
- // job and it stays prose. What it does is make an over-cap state fail
136
- // instead of being carried forward as if it were fine.
137
- if (v.retryCount !== undefined) {
138
- if (!Number.isInteger(v.retryCount) || v.retryCount < 0 || v.retryCount > 3) {
129
+ // retryCount counts build retries (cap 3); reworkCount counts review
130
+ // reworks (cap 3, the ceiling of the review limit). Both are the
131
+ // schema's integer 0..3, checked here because a state that violates
132
+ // them must fail resume instead of being carried forward.
133
+ for (const [field, what] of [
134
+ ["retryCount", "the build-retry cap"],
135
+ ["reworkCount", "the review rework cap"],
136
+ ]) {
137
+ if (v[field] === undefined) continue;
138
+ if (!Number.isInteger(v[field]) || v[field] < 0 || v[field] > 3) {
139
139
  errors.push(
140
- `phases["${k}"].retryCount must be integer 0..3 (the rework cap), got ${JSON.stringify(v.retryCount)}`,
140
+ `phases["${k}"].${field} must be integer 0..3 (${what}), got ${JSON.stringify(v[field])}`,
141
141
  );
142
142
  }
143
143
  }
144
+ if (
145
+ v.reworkForIteration !== undefined &&
146
+ (!Number.isInteger(v.reworkForIteration) || v.reworkForIteration < 0)
147
+ ) {
148
+ errors.push(
149
+ `phases["${k}"].reworkForIteration must be a whole number from 0, got ${JSON.stringify(v.reworkForIteration)}`,
150
+ );
151
+ }
144
152
  }
145
153
  }
146
154
  }
@@ -43,7 +43,17 @@ await import("../lib/cli-help.mjs").then(
43
43
  () => {},
44
44
  );
45
45
 
46
- const ALLOWED_REVIEWERS = new Set(["fable", "opus", "sonnet", "gpt"]);
46
+ // The same families anonymize-findings writes back, derived from the host
47
+ // registry rather than listed twice. This script also runs copied on its own,
48
+ // without lib/ beside it, so the import is optional the way --help is: there
49
+ // the hand-written floor applies and no reviewer value is rejected for being
50
+ // newer than this copy.
51
+ const ALLOWED_REVIEWERS = new Set(
52
+ await import("../lib/reviewer-families.mjs").then(
53
+ (m) => m.FAMILIES,
54
+ () => ["fable", "opus", "sonnet", "gpt", "local"],
55
+ ),
56
+ );
47
57
  const FOUND_BY_RE = /^(Source [A-Z]|security-auditor)$/;
48
58
  const ANONYMIZED = process.argv.includes("--anonymized");
49
59
  const ALLOWED_SEVERITIES = new Set(["blocking", "important", "suggestion"]);
@@ -63,11 +63,10 @@ import { spawnAsync } from "./_spawn-async.mjs";
63
63
  import { readRegularJson } from "../lib/regular-file.mjs";
64
64
  import { runMain } from "../lib/fatal.mjs";
65
65
  import { invokedDirectly } from "../lib/invoked-directly.mjs";
66
- import { resolveTokenAsync } from "../lib/credential-resolve.mjs";
66
+ import { authHeaderAsync, selectAccount } from "../lib/service-account.mjs";
67
67
  import { homedir } from "node:os";
68
68
  import { affected } from "./graph-affected.mjs";
69
69
  import { loadGraph } from "./graph-query.mjs";
70
- import { prefsPath } from "../lib/prefs-value.mjs";
71
70
  import { exitOnHelp } from "../lib/cli-help.mjs";
72
71
 
73
72
  exitOnHelp(import.meta.url);
@@ -181,33 +180,31 @@ async function accountEnv(env, account) {
181
180
  * credential store and travels in the request header only.
182
181
  */
183
182
  async function bitbucketPrs(env) {
184
- let host = env.MA_BITBUCKET_HOST || null;
185
- if (!host) {
186
- try {
187
- const prefs = readRegularJson(prefsPath(env), null);
188
- host = prefs?.global?.hosts?.bitbucket ?? null;
189
- } catch {
190
- host = null;
191
- }
183
+ // Account first, then its host, then a header bound to that host. The
184
+ // transport rule, the basic-or-bearer choice and the environment fallback
185
+ // all live in the resolver now, so this reads one answer instead of
186
+ // assembling four.
187
+ // A host in the environment is a destination, not a setting: it is passed
188
+ // to the resolver, which refuses it when no account covers it and when it
189
+ // is not a host a token may be sent to at all.
190
+ const asked = String(env.MA_BITBUCKET_HOST ?? "").trim();
191
+ const chosen = selectAccount({ service: "bitbucket", url: asked || undefined }, { env });
192
+ if (!chosen.ok) {
193
+ const reason =
194
+ chosen.reason === "not-configured"
195
+ ? "not configured"
196
+ : chosen.reason === "insecure-url"
197
+ ? "https required"
198
+ : chosen.message;
199
+ return { ok: false, items: [], reason };
192
200
  }
193
- if (typeof host !== "string" || !host) return { ok: false, items: [], reason: "not configured" };
194
- // The token travels in a header, so only over TLS: a host written with
195
- // http:// is refused unless it is this machine's own loopback.
196
- const loopback = /^http:\/\/(127\.0\.0\.1|localhost)(:\d+)?(\/|$)/i.test(host);
197
- if (/^http:\/\//i.test(host) && !loopback)
198
- return { ok: false, items: [], reason: "https required" };
199
- const base = /^https?:\/\//i.test(host) ? host.replace(/\/+$/, "") : `https://${host}`;
200
- const token =
201
- env.MA_BITBUCKET_TOKEN ||
202
- (await resolveTokenAsync("bitbucket_token", "BITBUCKET_TOKEN", { env }));
203
- if (!token) return { ok: false, items: [], reason: "no token in the credential store" };
204
- // The same rule as credential-inventory.sh: Basic with the stored user (an
205
- // app password), else the token as a bearer.
206
- const user =
207
- env.MA_BITBUCKET_USER || (await resolveTokenAsync("bitbucket_user", "BITBUCKET_USER", { env }));
208
- const authorization = user
209
- ? "Basic " + Buffer.from(`${user}:${token}`).toString("base64")
210
- : `Bearer ${token}`;
201
+ const base = chosen.account.baseUrl ?? `https://${chosen.account.hosts[0]}`;
202
+ const header = await authHeaderAsync(
203
+ { service: "bitbucket", url: base, scheme: "basic-or-bearer" },
204
+ { env },
205
+ );
206
+ if (!header.ok) return { ok: false, items: [], reason: header.message };
207
+ const authorization = header.value;
211
208
  const items = [];
212
209
  try {
213
210
  for (const role of ["REVIEWER", "AUTHOR"]) {
@@ -9,12 +9,13 @@
9
9
  * {"appStoreConnect": {"keyIdService", "issuerIdService", "privateKeyService"},
10
10
  * "googlePlay": {"serviceAccountService"}}
11
11
  *
12
- * This writes that file from the pipeline's own keychainMapping, so the two
13
- * never name different items. Each service name is the mapping value, else the
14
- * standard `${USER}_...` name. A store is written only when every one of its
15
- * items exists; existence is asked through `credential-store.sh probe`, which
16
- * sends the value to /dev/null, so no secret passes through this process.
17
- * Top-level keys other than the two stores are preserved.
12
+ * This writes that file from the items this machine's own accounts name (the
13
+ * account resolver's itemNames), so the two never name different items. Each
14
+ * service name is the account's item, else the standard `${USER}_...` name. A
15
+ * store is written only when every one of its items exists; existence is asked
16
+ * through `credential-store.sh probe`, which sends the value to /dev/null, so
17
+ * no secret passes through this process. Top-level keys other than the two
18
+ * stores are preserved.
18
19
  *
19
20
  * Paths: preferences at MULTI_AGENT_PREFS or ~/.claude/multi-agent-preferences.json
20
21
  * (the default credential-store.sh uses); the reference file at
@@ -45,6 +46,7 @@ import { homedir } from "node:os";
45
46
  import { dirname, join } from "node:path";
46
47
  import { fileURLToPath } from "node:url";
47
48
  import { prefsPath as sharedPrefsPath } from "../lib/prefs-value.mjs";
49
+ import { itemNames } from "../lib/service-account.mjs";
48
50
  import { exitOnHelp } from "../lib/cli-help.mjs";
49
51
 
50
52
  exitOnHelp(import.meta.url);
@@ -56,22 +58,34 @@ export const STORES = Object.freeze({
56
58
  appStoreConnect: [
57
59
  {
58
60
  logical: "appstore_connect_key_id",
61
+ service: "appstore_connect",
62
+ slot: "key_id",
59
63
  field: "keyIdService",
60
64
  standard: "AppStoreConnect_Key_Id",
61
65
  },
62
66
  {
63
67
  logical: "appstore_connect_issuer_id",
68
+ service: "appstore_connect",
69
+ slot: "issuer_id",
64
70
  field: "issuerIdService",
65
71
  standard: "AppStoreConnect_Issuer_Id",
66
72
  },
67
73
  {
68
74
  logical: "appstore_connect_private_key",
75
+ service: "appstore_connect",
76
+ slot: "private_key",
69
77
  field: "privateKeyService",
70
78
  standard: "AppStoreConnect_Private_Key",
71
79
  },
72
80
  ],
73
81
  googlePlay: [
74
- { logical: "google_play", field: "serviceAccountService", standard: "GooglePlay_Access_Json" },
82
+ {
83
+ logical: "google_play",
84
+ service: "google_play",
85
+ slot: "service_account_json",
86
+ field: "serviceAccountService",
87
+ standard: "GooglePlay_Access_Json",
88
+ },
75
89
  ],
76
90
  });
77
91
 
@@ -92,14 +106,26 @@ export function storeConfigPath(env = process.env) {
92
106
  );
93
107
  }
94
108
 
109
+ /**
110
+ * The store item each of these slots is named by, keyed as the STORES rows
111
+ * ask for it. Names only: the store is never read here, and an account that
112
+ * names nothing simply leaves its row to the standard `${USER}_...` name.
113
+ */
95
114
  export function readMapping(path) {
115
+ const out = {};
116
+ let named;
96
117
  try {
97
- const prefs = JSON.parse(readFileSync(path, "utf8"));
98
- const km = prefs?.global?.keychainMapping;
99
- return km && typeof km === "object" ? km : {};
118
+ named = itemNames(JSON.parse(readFileSync(path, "utf8")));
100
119
  } catch {
101
- return {};
120
+ return out;
102
121
  }
122
+ for (const items of Object.values(STORES)) {
123
+ for (const item of items) {
124
+ const found = named.find((x) => x.service === item.service && x.slot === item.slot);
125
+ if (found) out[item.logical] = found.item;
126
+ }
127
+ }
128
+ return out;
103
129
  }
104
130
 
105
131
  export function serviceName(mapping, item, user) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "1.0.0",
3
- "generatedAt": "2026-11-13T09:42:49Z",
4
- "skillCount": 257,
3
+ "generatedAt": "2026-11-16T18:57:02Z",
4
+ "skillCount": 258,
5
5
  "entries": [
6
6
  {
7
7
  "path": "shared/core/apple-archive-compliance/SKILL.md",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  {
27
27
  "path": "shared/core/multi-agent-analysis/SKILL.md",
28
- "sha256": "a3eeeee1ccb9e4e4f1a4f8d0537263c5cc70fda7ce1e2c202d40fcc831b9e308"
28
+ "sha256": "aff332d981fe977f01b190df7a24bc7e9ea6005c77542415cc10feb7cb792526"
29
29
  },
30
30
  {
31
31
  "path": "shared/core/multi-agent-autopilot-off/SKILL.md",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  {
51
51
  "path": "shared/core/multi-agent-channels/SKILL.md",
52
- "sha256": "94ee57622a4066d988e57ce346be033d4b3ee00d67f5891ccc0d5c3538742779"
52
+ "sha256": "78f14705da370e7646b069da35958bbb835b20dc7a2cb63cd85db3de78e3ded7"
53
53
  },
54
54
  {
55
55
  "path": "shared/core/multi-agent-clean-disk/SKILL.md",
@@ -185,7 +185,7 @@
185
185
  },
186
186
  {
187
187
  "path": "shared/core/multi-agent-resume/SKILL.md",
188
- "sha256": "26a0e128e878c23e9c6cd64e35f791b9e6d896518a331cf804f1b56a8237820e"
188
+ "sha256": "ae78ee0e09fc85e61a104bd0c656f8d46611cc5569a7d9ae297f1fa4aa461d47"
189
189
  },
190
190
  {
191
191
  "path": "shared/core/multi-agent-review-analysis/SKILL.md",
@@ -203,6 +203,10 @@
203
203
  "path": "shared/core/multi-agent-review-priority/SKILL.md",
204
204
  "sha256": "386996319752c7377a11592ef56dd00c2bb345781716434a2d436b31c6fbfdb1"
205
205
  },
206
+ {
207
+ "path": "shared/core/multi-agent-review-rounds/SKILL.md",
208
+ "sha256": "f85daf54721ae152e6e2b75c7ba22a2b27008deaed40cdd2ebeb10e54947af5e"
209
+ },
206
210
  {
207
211
  "path": "shared/core/multi-agent-review/SKILL.md",
208
212
  "sha256": "a7e0b71491ee7d8cd9f7f501884f919dfcf609553bf17401620bb2f0a9ed964d"
@@ -293,7 +297,7 @@
293
297
  },
294
298
  {
295
299
  "path": "shared/core/multi-agent-sync/SKILL.md",
296
- "sha256": "60d347888d9b8fc9efd761d436e2b03ba9d87c13fd5e00bb19f445b6b5f046e4"
300
+ "sha256": "92932f294cb308e7096041120bcb561336f870b056705bf53313200518cb94e7"
297
301
  },
298
302
  {
299
303
  "path": "shared/core/multi-agent-test-accessibility/SKILL.md",
@@ -333,7 +337,7 @@
333
337
  },
334
338
  {
335
339
  "path": "shared/core/multi-agent/SKILL.md",
336
- "sha256": "4e633fff2e140d5433133128e9a1fbcc3b449ed4954ac37d18e3d0aeccbfcbe2"
340
+ "sha256": "9cd4c70f6e1aa6833522287918523e82d4245577e117f8509af51070848d897a"
337
341
  },
338
342
  {
339
343
  "path": "shared/external/accessibility-compliance-accessibility-audit/SKILL.md",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": "1.0.0",
3
- "skillCount": 257,
3
+ "skillCount": 258,
4
4
  "entries": [
5
5
  {
6
6
  "name": "accessibility-compliance-accessibility-audit",
@@ -1214,7 +1214,7 @@
1214
1214
  },
1215
1215
  {
1216
1216
  "name": "multi-agent-channels",
1217
- "description": "Multi-channel reporter - Jira/Confluence/Wiki/PR description. Multi-select channels + content, humanizer pass, reviewer-preserving Bitbucket PR PUT. Use to post or redo a run's report; Phase 5 delegates here, or invoke by Jira ID / PR URL / branch.",
1217
+ "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 ",
1218
1218
  "platform": null,
1219
1219
  "group": "core",
1220
1220
  "plugin": null,
@@ -1652,6 +1652,17 @@
1652
1652
  "triggerPaths": [],
1653
1653
  "relativePath": "shared/core/multi-agent-review-priority/SKILL.md"
1654
1654
  },
1655
+ {
1656
+ "name": "multi-agent-review-rounds",
1657
+ "description": "Set how often review sends work back, 1 to 3 (default 2). Use when changing review rounds.",
1658
+ "platform": null,
1659
+ "group": "core",
1660
+ "plugin": null,
1661
+ "invokeAs": "multi-agent-review-rounds",
1662
+ "triggerKeywords": [],
1663
+ "triggerPaths": [],
1664
+ "relativePath": "shared/core/multi-agent-review-rounds/SKILL.md"
1665
+ },
1655
1666
  {
1656
1667
  "name": "multi-agent-route-off",
1657
1668
  "description": "Disable model routing and keep its rules, so turning it back on does not re-ask for the same configuration. Use when asked to turn model routing off.",
@@ -2,11 +2,11 @@
2
2
 
3
3
  Single source of truth for skills delivered to both Claude Code (`~/.claude/skills/`) and Copilot CLI (`~/.copilot/skills/`) by the installer.
4
4
 
5
- **Total:** 257 skills (83 core + 174 external). Auto-generated by `scripts/gen-skills-index.mjs` - do not edit by hand.
5
+ **Total:** 258 skills (84 core + 174 external). Auto-generated by `scripts/gen-skills-index.mjs` - do not edit by hand.
6
6
 
7
7
  ## Directory layout
8
8
 
9
- - **`core/`** - 83 `multi-agent*` orchestration skills that are pipeline-critical. Edits here are core-code changes.
9
+ - **`core/`** - 84 `multi-agent*` orchestration skills that are pipeline-critical. Edits here are core-code changes.
10
10
  - **`external/`** - 174 iOS / Android / generic skills that ship into the stack plugins.
11
11
  - Install destinations (ADR-0009): Claude Code gets NO local copy of `external/` - it loads those skills from the `multi-agent-plugins` marketplace, namespaced (`ai-<stack>-toolkit:<name>`); only the two compliance catalogs from `core/` land in `~/.claude/skills/`. Copilot CLI and Codex CLI receive a flat copy filtered to the enabled stacks. `external/` remains the single authoring source that `build-stack-plugins.mjs` publishes from.
12
12
 
@@ -14,7 +14,7 @@ Source layout is logical grouping only - skill discovery at runtime is unchang
14
14
 
15
15
  ## Categories
16
16
 
17
- - [Pipeline Orchestration](#pipeline-orchestration) - 83
17
+ - [Pipeline Orchestration](#pipeline-orchestration) - 84
18
18
  - [iOS / Apple Ecosystem](#ios-apple-ecosystem) - 95
19
19
  - [Android / Kotlin](#android-kotlin) - 16
20
20
  - [Web](#web) - 10
@@ -77,6 +77,7 @@ Source layout is logical grouping only - skill discovery at runtime is unchang
77
77
  | [`multi-agent-review-issue`](./core/multi-agent-review-issue/) | `core` | Assess whether a GitHub issue is ready for multi-agent development: fetch it, grade scope / acceptance criteria / repro / design / API / sta |
78
78
  | [`multi-agent-review-jira`](./core/multi-agent-review-jira/) | `core` | Assess whether a Jira issue is ready for multi-agent development: fetch it, grade scope / acceptance criteria / repro / design / API / stack |
79
79
  | [`multi-agent-review-priority`](./core/multi-agent-review-priority/) | `core` | Review a team's open Jira bug priorities against its rule file: read-only by default, one report per team, one approved change at a time. In |
80
+ | [`multi-agent-review-rounds`](./core/multi-agent-review-rounds/) | `core` | Set how often review sends work back, 1 to 3 (default 2). Use when changing review rounds. |
80
81
  | [`multi-agent-route-off`](./core/multi-agent-route-off/) | `core` | Disable model routing and keep its rules, so turning it back on does not re-ask for the same configuration. Use when asked to turn model rou |
81
82
  | [`multi-agent-route-on`](./core/multi-agent-route-on/) | `core` | Enable policy-driven model routing: pick a strategy, a scope, and the rules that say which rung a call lands on. Use when asked to turn mode |
82
83
  | [`multi-agent-route-status`](./core/multi-agent-route-status/) | `core` | Report model routing: whether it is armed, which rule applies where, which rung the last dispatches took, and what this run has cost. Use wh |
@@ -2,7 +2,7 @@
2
2
  name: multi-agent
3
3
  description: "Task orchestrator: runs the full pipeline from a Jira ID or GitHub Issue URL - analysis → plan → TDD development → parallel review (Fable + Opus + Sonnet on Claude Code, GPT + Opus + Sonnet on Copilot CLI) → commit → log. Every step is written to agent-log.md. Use when given a Jira ID, a GitHub issue or a free-text task and the whole pipeline should run."
4
4
  user-invocable: true
5
- argument-hint: 'PROJ-12345 feature/PROJ-12345-order-filter | https://github.com/.../issues/316 | "task text" [autopilot [--loop N]] | status | log #1 | resume #1 | kill #1 | clear-logs | purge | review'
5
+ argument-hint: 'PROJ-12345 feature/PROJ-12345-order-filter | https://github.com/.../issues/316 | "task text" [autopilot [--loop N]] [--review-rounds N] | status | log #1 | resume #1 | kill #1 | clear-logs | purge | review'
6
6
  metadata:
7
7
  language: en
8
8
  ---
@@ -27,7 +27,7 @@ ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
27
27
 
28
28
  `status`, `log [id]`, `resume [id]`, `review` (current diff only), the `autopilot` flag, and no args / `help`. `kill [id]` and `purge` are user-only commands, and `clear-logs` is superseded: name `/multi-agent-kill`, `/multi-agent-purge` or `/multi-agent-prune-logs` for the user to type and stop. Anything else is a task input (Jira ID + branch, GitHub issue URL or number, free text) and enters Phase 0.
29
29
 
30
- **Quoting**: For a double-quoted first argument, strip the surrounding double quotes and unescape (`\"` becomes `"`, and `\\` becomes `\` before a quote or at the end). If the resulting value as a whole is a Jira key, a Jira or GitHub issue URL, `repo#N` or `#N`, it is that structured reference; otherwise it is free text, and a structured token inside a sentence stays free text. Everything after the closing quote is modifiers (`autopilot`, `--loop N`, the branch name after a Jira key) (`$HOME/.claude/multi-agent-refs/_input-parser.md` "Quoting").
30
+ **Quoting**: For a double-quoted first argument, strip the surrounding double quotes and unescape (`\"` becomes `"`, and `\\` becomes `\` before a quote or at the end). If the resulting value as a whole is a Jira key, a Jira or GitHub issue URL, `repo#N` or `#N`, it is that structured reference; otherwise it is free text, and a structured token inside a sentence stays free text. Everything after the closing quote is modifiers (`autopilot`, `--loop N`, `--review-rounds N`, the branch name after a Jira key) (`$HOME/.claude/multi-agent-refs/_input-parser.md` "Quoting").
31
31
 
32
32
  ## Task operations
33
33
 
@@ -52,10 +52,18 @@ pref_model="$(awk '/^preferredModel:/ {print $2; exit}' "$persona_file")"
52
52
  override="${PHASE_MODEL_OVERRIDE:-}"
53
53
  routed="${override:-$("$HOME/.claude/lib/model-dispatch.sh" subagent --persona "$persona" --phase "$currentPhase" --task-kind "$taskType" --default "${pref_model:-opus}" 2>/dev/null)}"
54
54
  resolved_model="${routed:-${pref_model:-opus}}"
55
- export CLAUDE_CODE_SUBAGENT_MODEL="$resolved_model" # Copilot CLI also passes it as --model
55
+ export CLAUDE_CODE_SUBAGENT_MODEL="$resolved_model"
56
56
  ```
57
57
 
58
- **Precedence:** per-dispatch `PHASE_MODEL_OVERRIDE` > `prefs.global.modelRouting` rule > persona `preferredModel` > global default (`opus`). Anthropic-only: features/model-fallback.md "Routing at dispatch". Simple text tasks ask `model-dispatch.sh delegate --default host` first; `free` means `multi-agent:llm_delegate`, never for code, plans, reviews or triage (`$HOME/.claude/multi-agent-refs/features/free-models.md`).
58
+ The last line is this host's way of handing a child its model and is the only
59
+ host-specific step: elsewhere the same rung is passed as a flag on the CLI call
60
+ or as a field on the spawn call, and one host also carries a reasoning effort
61
+ and a ceiling on how many children run at once. The table of all of them, and
62
+ what each host's personas are written in, is
63
+ `$HOME/.claude/multi-agent-refs/features/model-fallback.md` "Routing at
64
+ dispatch". Resolve the rung the same way everywhere; only that last line moves.
65
+
66
+ **Precedence:** per-dispatch `PHASE_MODEL_OVERRIDE` > `prefs.global.modelRouting` rule > persona `preferredModel` > global default (`opus`). A rule naming a rung this host does not offer is skipped and the next one answers: features/model-fallback.md "Routing at dispatch". Simple text tasks ask `model-dispatch.sh delegate --default host` first; `free` means `multi-agent:llm_delegate`, never for code, plans, reviews or triage (`$HOME/.claude/multi-agent-refs/features/free-models.md`).
59
67
 
60
68
  Skill injection (`prefs.global.dynamicSkillLoading`): read `$HOME/.claude/multi-agent-refs/orchestrator/skill-loading.md` when it is on or when composing a sub-agent prompt.
61
69
 
@@ -66,7 +74,7 @@ Run phases sequentially, log every step to `agent-log.md`, and on a failure mark
66
74
  ### Canonical phase labels (TaskCreate + banner)
67
75
 
68
76
  | # | Label |
69
- |---|---|
77
+ | --- | -------------------- |
70
78
  | 0 | Phase 0: Init |
71
79
  | 1 | Phase 1: Plan |
72
80
  | 2 | Phase 2: Dev |
@@ -88,7 +96,7 @@ Run all **8 sequential interactive steps** in `$HOME/.claude/multi-agent-refs/ph
88
96
 
89
97
  - **1 Plan**: analysis (`explorer`), planning, then the **Plan Approval Gate** (interactive only): clarification max 2 rounds, approval loop `onayla` / `iptal` / free-text.
90
98
  - **2 Dev**: TDD per todo, build, max 3 fix attempts.
91
- - **3 Review**: three parallel reviewers + one triage pass; blocking goes back to Phase 2 (max 3 iterations). Interactive user test via `AskUserQuestion`, saying yes removes the worktree and checks the branch out: `$HOME/.claude/multi-agent-refs/orchestrator/phase-3-user-test.md`.
99
+ - **3 Review**: three parallel reviewers + one triage pass; blocking goes back to Phase 2 for rework, at most 1 to 3 times (default 2; `review-rounds.mjs next`). Interactive user test via `AskUserQuestion`, saying yes removes the worktree and checks the branch out: `$HOME/.claude/multi-agent-refs/orchestrator/phase-3-user-test.md`.
92
100
  - **4 Commit & PR**: ask before commit (No pauses; `resume` later) and before the PR; `git add` specific files, never `git add -A`; author from `prefs.global.identities[]`. Read `$HOME/.claude/multi-agent-refs/orchestrator/phase-4-5-projects.md`.
93
101
  - **5 Report**: finalize `agent-log.md` (`$HOME/.claude/multi-agent-refs/phases/log-format.md`), print the summary.
94
102
 
@@ -19,6 +19,8 @@ ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
19
19
 
20
20
  **Input**: $ARGUMENTS (optional analysis name, e.g. `"OrderStatus"`)
21
21
 
22
+ `<tracker-ref> autopilot` is not a name: it is the unattended form continuous mode launches for an item carrying the repo's analysis label (`analysisGithubLabel` / `analysisJiraLabel`). It is its own declared mode (`phases.json` `modes.analysis-autopilot`) and asks nothing: Phase 0 answers every question from the item, the repo and the preferences, or parks on it with the reason. The side-effect contract is unchanged - the run stops at the document, which is what the queue records as `doc-delivered`.
23
+
22
24
  `check <doc.md>` / `refresh <doc.md>` is not a name: compare the document with its sources, or redraft from the stale ones. Read `$HOME/.claude/multi-agent-refs/features/analysis-sources.md` and follow it instead of the steps below.
23
25
 
24
26
  `conform <doc.md>` is not a name: map an existing document onto a template without changing what it says. Follow `$HOME/.claude/multi-agent-refs/features/analysis-outline.md` instead of the steps below.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: multi-agent-channels
3
- description: "Multi-channel reporter - Jira/Confluence/Wiki/PR description. Multi-select channels + content, humanizer pass, reviewer-preserving Bitbucket PR PUT. Use to post or redo a run's report; Phase 5 delegates here, or invoke by Jira ID / PR URL / branch."
3
+ 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."
4
4
  user-invocable: true
5
- 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]'
5
+ 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]'
6
6
  metadata:
7
7
  language: en
8
8
  ---
@@ -19,18 +19,20 @@ ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
19
19
 
20
20
  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`).
21
21
 
22
+ 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`.
23
+
22
24
  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.
23
25
 
24
26
  ## Flow
25
27
 
26
28
  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.
27
29
  2. **Context source**: pipeline log (`$HOME/.claude/logs/multi-agent/<project>/<task-id>/agent-log.md`), PR diff, or `--message`. Read `channels/menu.md`.
28
- 3. **Menu (multi-select)**: channels + content, pre-ticked from `prefs.global.reportChannels` / `prefs.global.reportContent`; unavailable rows greyed with a reason (`menu.md`).
29
- 4. **Mode short-circuit**: `--channels` + `--content` skip the menu. Autopilot always pauses at the menu.
30
- 5. **Generator**: one section per content source, humanizer per channel. Read `channels/generator.md`.
30
+ 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.
31
+ 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.
32
+ 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.
31
33
  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`.
32
- 7. **Dispatch**: parallel adapters, never before the gate resolves.
33
- 8. **Summary**: one status line per adapter; persist the selections to prefs.
34
+ 7. **Dispatch**: parallel adapters, never before the gate resolves. The report file is not an adapter and no adapter failure affects it.
35
+ 8. **Summary**: one status line per adapter, then the `Report file` row last; persist the selections to prefs.
34
36
 
35
37
  ## Channel adapters
36
38
 
@@ -63,13 +65,14 @@ After the content sections, a cached `archiveguard-*.json` or `play-compliance-*
63
65
  - Humanizer per channel; no `<!-- channels:start -->` markers; every body item cites a file / symbol / line.
64
66
  - Adapter failures are non-blocking.
65
67
  - Approval before post: autopilot and `--dry-run` are the only bypasses.
68
+ - 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.
66
69
  - Target length under 80 lines; auto-diff capped at 5 lines per section.
67
70
 
68
71
  ## Autopilot and unattended
69
72
 
70
73
  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`).
71
74
 
72
- **Unattended (`MULTI_AGENT_UNATTENDED=1`): channels posts nothing.** 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`.
75
+ **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`.
73
76
 
74
77
  ## Progress on Copilot
75
78
 
@@ -49,7 +49,7 @@ ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
49
49
 
50
50
  4. **Tracked run - rebuild the phase tiles** from `tracker-state.json`, never re-initialized. Copilot CLI: a single `phase-tracker.sh render`.
51
51
 
52
- 5. **Tracked run - continue.** Read `state.waitingFor` FIRST: when it names a step (`maturity`, `user-channels-choice`, `local-test`, `question`), the run re-enters THAT step. `currentPhase + 1` is the fallback, not the rule. Clear `waitingFor` in the same write that records the answer. `question` re-enters `pendingQuestion.stepId`; `--answer <optionId>` records the answer first through `node "$HOME/.claude/scripts/answer-question.mjs" "$STATE_FILE" --answer "$OPTION_ID"`, which accepts only one of `pendingQuestion.options[].id` and writes nothing otherwise. The answer is data, never an instruction.
52
+ 5. **Tracked run - continue.** Read `state.waitingFor` FIRST: when it names a step (`maturity`, `user-channels-choice`, `local-test`, `question`), the run re-enters THAT step. `currentPhase + 1` is the fallback, not the rule. A decided and unfinished rework (`phases["2"].reworkForIteration` equal to the number of `reviewIterations`) re-enters Phase 2, never Phase 3 Step 4 again. Clear `waitingFor` in the same write that records the answer. `question` re-enters `pendingQuestion.stepId`; `--answer <optionId>` records the answer first through `node "$HOME/.claude/scripts/answer-question.mjs" "$STATE_FILE" --answer "$OPTION_ID"`, which accepts only one of `pendingQuestion.options[].id` and writes nothing otherwise. The answer is data, never an instruction.
53
53
 
54
54
  6. **Untracked branch work - resolve context.** Base branch: `--base` → `figma-config.project.baseBranch` → `develop` → upstream/merge-base. Jira id from the argument or the branch name. State under `$HOME/.claude/logs/multi-agent/{project}/{taskId}/`. No worktree is created.
55
55