@the-vibe-company/armada 0.2.4 → 0.2.6

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 (3) hide show
  1. package/README.md +17 -7
  2. package/dist/armada.js +739 -175
  3. package/package.json +1 -1
package/dist/armada.js CHANGED
@@ -320,16 +320,35 @@ var CHANGED_COMMENTS_QUERY = `
320
320
 
321
321
  // ../core/src/armada-api.ts
322
322
  var displayCode = (code) => code.length === 8 ? `${code.slice(0, 4)}-${code.slice(4)}` : code;
323
+ var CLI_PACKAGE = "@the-vibe-company/armada";
324
+ var CLI_VERSION_HEADER = "x-armada-cli-version";
325
+ var CLI_MINIMUM_HEADER = "x-armada-cli-minimum";
326
+ var CLI_LATEST_HEADER = "x-armada-cli-latest";
327
+ function compareVersions(a, b) {
328
+ const parts = (v) => v.split(/[-+]/)[0]?.split(".").map((n) => Number.parseInt(n, 10) || 0) ?? [];
329
+ const [x, y] = [parts(a), parts(b)];
330
+ for (let i = 0;i < Math.max(x.length, y.length); i++) {
331
+ const d = (x[i] ?? 0) - (y[i] ?? 0);
332
+ if (d)
333
+ return Math.sign(d);
334
+ }
335
+ return 0;
336
+ }
337
+ var versionToInstall = (minimum, latest) => latest && compareVersions(latest, minimum) >= 0 ? latest : minimum;
338
+ var installCommand = (version) => `npm install -g ${CLI_PACKAGE}@${version}`;
339
+ var upgradeLine = (version, install) => `Armada ${version} is older than this server expects: ${installCommand(install)}`;
323
340
 
324
341
  class ArmadaApiError extends Error {
325
342
  next;
326
343
  signedOut;
327
344
  status;
328
- constructor(message, next = null, signedOut = false, status = null) {
345
+ upgrade;
346
+ constructor(message, next = null, signedOut = false, status = null, upgrade = null) {
329
347
  super(message);
330
348
  this.next = next;
331
349
  this.signedOut = signedOut;
332
350
  this.status = status;
351
+ this.upgrade = upgrade;
333
352
  }
334
353
  }
335
354
  var LOGIN_NEXT = "armada login";
@@ -356,6 +375,7 @@ function armadaApi(opts) {
356
375
  const doFetch = opts.fetch ?? fetch;
357
376
  const timeoutMs = opts.timeoutMs ?? TIMEOUT_MS;
358
377
  const host = base.host;
378
+ let serverCli = null;
359
379
  async function call(method, path, init = {}) {
360
380
  const limit = init.timeoutMs ?? timeoutMs;
361
381
  const headers = { Accept: "application/json" };
@@ -365,6 +385,8 @@ function armadaApi(opts) {
365
385
  headers.Authorization = `Bearer ${init.signIn.token}`;
366
386
  if (init.signIn?.kind === "api-key")
367
387
  headers["x-api-key"] = init.signIn.key;
388
+ if (opts.version)
389
+ headers[CLI_VERSION_HEADER] = opts.version;
368
390
  const res = await doFetch(new URL(`api/cli/${path}`, base).toString(), {
369
391
  method,
370
392
  headers,
@@ -373,6 +395,15 @@ function armadaApi(opts) {
373
395
  }).catch((err) => {
374
396
  throw new ArmadaApiError(`Armada (${host}) unreachable: ${networkReason(err, limit)}`, "the same command again once it answers, or check ARMADA_API_URL");
375
397
  });
398
+ const minimum = res.headers.get(CLI_MINIMUM_HEADER);
399
+ const latest = res.headers.get(CLI_LATEST_HEADER) || null;
400
+ if (minimum)
401
+ serverCli = { minimum, latest };
402
+ if (opts.version && minimum && compareVersions(opts.version, minimum) < 0) {
403
+ await res.body?.cancel().catch(() => {});
404
+ const install = versionToInstall(minimum, latest);
405
+ throw new ArmadaApiError(upgradeLine(opts.version, install), null, false, res.status, install);
406
+ }
376
407
  if (res.status === 304)
377
408
  return { status: 304, body: {} };
378
409
  const body = await res.json().catch(() => null);
@@ -386,6 +417,7 @@ function armadaApi(opts) {
386
417
  return new ArmadaApiError(what ? `${what}: ${error}` : error, next, status === 401, status);
387
418
  };
388
419
  return {
420
+ serverCli: () => serverCli,
389
421
  async startDeviceLogin() {
390
422
  const { status, body } = await call("POST", "device/code");
391
423
  if (status !== 200)
@@ -1804,6 +1836,7 @@ var HAS_WELLFORMED = !!"".isWellFormed;
1804
1836
  var CONFIG_FILE = "armada.toml";
1805
1837
  var PLAN_POLICIES = ["approve", "pre-approved"];
1806
1838
  var routingLabelKey = (name) => name.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]/gu, "");
1839
+ var PROFILE_RUNTIMES = ["conductor", "claude-code"];
1807
1840
  var CONFIG_DEFAULTS = {
1808
1841
  language: "en",
1809
1842
  readyLabel: "ready-for-agent",
@@ -1932,10 +1965,16 @@ function parseConfig(text, source = CONFIG_FILE) {
1932
1965
  problems.push(`"${path}" is not a usable profile name`);
1933
1966
  continue;
1934
1967
  }
1935
- known.push([path, p, ["agent", "model", "effort", "fast_mode"]]);
1968
+ known.push([path, p, ["runtime", "agent", "model", "effort", "fast_mode"]]);
1936
1969
  if (p.fast_mode !== undefined && typeof p.fast_mode !== "boolean")
1937
1970
  problems.push(`"${path}.fast_mode" must be true or false`);
1971
+ const runtime = p.runtime ?? "conductor";
1972
+ if (!PROFILE_RUNTIMES.includes(runtime))
1973
+ problems.push(`"${path}.runtime" must be one of ${PROFILE_RUNTIMES.map((r) => `"${r}"`).join(", ")}`);
1974
+ if (runtime === "claude-code" && p.agent !== undefined && p.agent !== "claude")
1975
+ problems.push(`"${path}.agent" must be "claude" with runtime = "claude-code"`);
1938
1976
  profiles[name] = {
1977
+ runtime: PROFILE_RUNTIMES.includes(runtime) ? runtime : "conductor",
1939
1978
  agent: str(p, path, "agent"),
1940
1979
  model: str(p, path, "model"),
1941
1980
  effort: str(p, path, "effort"),
@@ -2125,6 +2164,15 @@ agent = "codex"
2125
2164
  model = "gpt-6.1-sol"
2126
2165
  effort = "xhigh"
2127
2166
 
2167
+ # A worker run as a subagent of a coordinator's Claude Code session, in its own
2168
+ # worktree (the armada-runtime-claude-code skill). It dies with that session, so
2169
+ # long runs belong on Conductor. \`model\` is what the Agent tool takes; it applies no effort.
2170
+ # [conductor.profiles.local]
2171
+ # runtime = "claude-code"
2172
+ # agent = "claude"
2173
+ # model = "opus"
2174
+ # effort = "high"
2175
+
2128
2176
  # Which profile a ticket gets from its Linear labels: the first rule with a label
2129
2177
  # the ticket carries wins, in file order. \`armada brief --profile\` overrides it.
2130
2178
  [[conductor.routing]]
@@ -2189,7 +2237,7 @@ function handBackProblems({ pr, repository, sha, requiredChecks }) {
2189
2237
  if (pr.draft)
2190
2238
  problems.push(`pull request #${pr.number} is a draft; mark it ready for review`);
2191
2239
  if (pr.mergeable === "CONFLICTING")
2192
- problems.push(`pull request #${pr.number} conflicts with its base; rebase it`);
2240
+ problems.push(`pull request #${pr.number} conflicts with its base; bring the base branch in (rebase, or merge it into your branch)`);
2193
2241
  if (!pr.headSha)
2194
2242
  problems.push(`the head of pull request #${pr.number} could not be read from GitHub`);
2195
2243
  else if (sha && FULL_SHA.test(sha) && pr.headSha !== sha)
@@ -2197,26 +2245,34 @@ function handBackProblems({ pr, repository, sha, requiredChecks }) {
2197
2245
  problems.push(...checkProblems(pr.checks ?? [], requiredChecks));
2198
2246
  return problems;
2199
2247
  }
2200
- function checkProblems(checks, requiredChecks) {
2201
- const problems = [];
2248
+ function checkIssues(checks, requiredChecks) {
2249
+ const issues = [];
2250
+ const of = (name, state, required) => ({
2251
+ text: `${required ? "required " : ""}check "${name}" is ${state}`,
2252
+ pending: state !== "failure"
2253
+ });
2202
2254
  if (requiredChecks.length) {
2203
2255
  for (const name of requiredChecks) {
2204
2256
  const runs = checks.filter((c) => c.name === name);
2205
- const bad = runs.find((c) => c.state !== "success");
2257
+ const bad = runs.find((c) => c.state === "failure") ?? runs.find((c) => c.state !== "success");
2206
2258
  if (!runs.length)
2207
- problems.push(`required check "${name}" has not reported on the head yet`);
2259
+ issues.push({ text: `required check "${name}" has not reported on the head yet`, pending: true });
2208
2260
  else if (bad)
2209
- problems.push(`required check "${name}" is ${bad.state}`);
2261
+ issues.push(of(name, bad.state, true));
2210
2262
  }
2211
2263
  } else if (!checks.length) {
2212
- problems.push("no CI check has reported on the head yet (or set [gates] required_checks in armada.toml)");
2264
+ issues.push({
2265
+ text: "no CI check has reported on the head yet (or set [gates] required_checks in armada.toml)",
2266
+ pending: true
2267
+ });
2213
2268
  } else {
2214
2269
  for (const c of checks)
2215
2270
  if (c.state !== "success")
2216
- problems.push(`check "${c.name}" is ${c.state}`);
2271
+ issues.push(of(c.name, c.state, false));
2217
2272
  }
2218
- return problems;
2273
+ return issues;
2219
2274
  }
2275
+ var checkProblems = (checks, requiredChecks) => checkIssues(checks, requiredChecks).map((i) => i.text);
2220
2276
 
2221
2277
  // ../core/src/routing.ts
2222
2278
  class ProfileError extends Error {
@@ -2313,7 +2369,9 @@ async function live(ctx, warnings, what, step) {
2313
2369
  })
2314
2370
  ]);
2315
2371
  } catch (err) {
2316
- warnings.push(`Armada: could not ${what} (${err instanceof Error ? err.message : String(err)}); Linear is up to date`);
2372
+ const warning = err instanceof ArmadaApiError && err.upgrade ? err.message : `Armada: could not ${what} (${err instanceof Error ? err.message : String(err)}); Linear is up to date`;
2373
+ if (!warnings.includes(warning))
2374
+ warnings.push(warning);
2317
2375
  return null;
2318
2376
  } finally {
2319
2377
  clearTimeout(timer);
@@ -2386,6 +2444,10 @@ var firstState = (states, ...types) => {
2386
2444
  }
2387
2445
  return null;
2388
2446
  };
2447
+ function liveProfile({ name, profile, routed, reason, why }) {
2448
+ const { runtime: _, ...settings } = profile;
2449
+ return { name, ...settings, routed, reason, why };
2450
+ }
2389
2451
  function claimLine(o) {
2390
2452
  const line = `Agent claim — runtime: ${o.runtime} · session: ${o.handle} · branch: ${o.branch ?? "unknown"} · started: ${o.started}`;
2391
2453
  const p = o.profile;
@@ -2472,7 +2534,7 @@ ${claimLine({ runtime: runtime.name, handle: input.handle, branch, started, prof
2472
2534
  branch,
2473
2535
  phase: phaseLabel ? "planning" : ticket.agentPhase,
2474
2536
  resuming,
2475
- profile: profile ? { name: profile.name, ...profile.profile, routed: profile.routed, reason: profile.reason, why: profile.why } : null
2537
+ profile: profile ? liveProfile(profile) : null
2476
2538
  }));
2477
2539
  if (launched?.length) {
2478
2540
  const who = [...new Set(launched.map((r) => r.author ?? "the owner"))].join(", ");
@@ -2610,6 +2672,7 @@ async function releaseTicket(ctx, input) {
2610
2672
  var ARMADA_PACKAGE = "@the-vibe-company/armada";
2611
2673
  var WORKER_SKILL_PATH = ".agents/skills/armada-worker/SKILL.md";
2612
2674
  var CONDUCTOR_HANDLE = '"$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"';
2675
+ var subagentName = (ticket) => ticket.toLowerCase();
2613
2676
  var MAX_NOTES = 10;
2614
2677
  var NOTE = "id createdAt body user { name }";
2615
2678
  var NOTES = `pageInfo { hasNextPage endCursor } nodes { ${NOTE} }`;
@@ -2732,8 +2795,10 @@ function buildBrief(input) {
2732
2795
  }));
2733
2796
  const pkg = `${ARMADA_PACKAGE}@${input.version}`;
2734
2797
  const branch = ticket.branchName;
2798
+ const runtime = choice?.profile.runtime ?? "conductor";
2799
+ const handle = runtime === "claude-code" ? subagentName(ticket.id) : CONDUCTOR_HANDLE;
2735
2800
  const claimCommand = [
2736
- `armada claim ${ticket.id} --runtime conductor --handle ${CONDUCTOR_HANDLE}`,
2801
+ `armada claim ${ticket.id} --runtime ${runtime} --handle ${handle}`,
2737
2802
  branch ? ` --branch ${branch}` : "",
2738
2803
  choice ? ` --profile ${shellWord(choice.name)}` : "",
2739
2804
  choice?.reason ? ` --reason ${shellWord(choice.reason)}` : ""
@@ -2748,14 +2813,16 @@ function buildBrief(input) {
2748
2813
  inShell: has(v.name),
2749
2814
  inStore: !has(v.name) && !!input.stored?.includes(v.name)
2750
2815
  })),
2751
- {
2752
- name: "ARMADA_TICKET",
2753
- required: true,
2754
- value: ticket.id,
2755
- inShell: false,
2756
- inStore: false,
2757
- purpose: "the ticket this worker owns"
2758
- }
2816
+ ...runtime === "claude-code" ? [] : [
2817
+ {
2818
+ name: "ARMADA_TICKET",
2819
+ required: true,
2820
+ value: ticket.id,
2821
+ inShell: false,
2822
+ inStore: false,
2823
+ purpose: "the ticket this worker owns"
2824
+ }
2825
+ ]
2759
2826
  ];
2760
2827
  const extra = input.conventions ?? null;
2761
2828
  if (extra && extra.text === null)
@@ -2772,7 +2839,7 @@ function buildBrief(input) {
2772
2839
  description: ticket.description
2773
2840
  },
2774
2841
  parent: ticket.parent,
2775
- runtime: "conductor",
2842
+ runtime,
2776
2843
  profile: choice ? { name: choice.name, ...choice.profile } : null,
2777
2844
  routing: choice ? { source: choice.source, rule: choice.rule, routed: choice.routed, reason: choice.reason, why: choice.why } : null,
2778
2845
  repository: { name: config.github.repository, url: `https://github.com/${config.github.repository}` },
@@ -2803,12 +2870,19 @@ var quote = (body) => body.trim().split(`
2803
2870
  var byLine = (n) => `${n.author ?? "unknown"}, ${n.createdAt.slice(0, 16).replace("T", " ")}Z — ${n.url}`;
2804
2871
  function renderPrompt(b) {
2805
2872
  const t = b.ticket;
2873
+ const subagent = b.runtime === "claude-code";
2806
2874
  const out = [
2807
2875
  `# ${t.id} — ${t.title}`,
2808
2876
  "",
2809
2877
  `You are an Armada worker. You own exactly one ticket, ${t.id} (${t.url}), and turn it into one green pull request on ${b.repository.name}. Follow the \`armada-worker\` skill (\`${WORKER_SKILL_PATH}\`) and the repository's \`AGENTS.md\`. Never merge.`,
2810
2878
  "",
2811
- "## First: install Armada and claim the ticket",
2879
+ ...subagent ? [
2880
+ "## Before anything: your own worktree",
2881
+ "",
2882
+ `You run as a Claude Code subagent of the coordinator's session, in your own git worktree. Before you run anything else or touch a file, check that \`git rev-parse --show-toplevel\` is a folder under \`.claude/worktrees/\`. If it is not, you are in the coordinator's checkout: call the \`EnterWorktree\` tool with the name \`${subagentName(t.id)}\` and work only there. If it is refused, change nothing: reply that you were launched without a worktree and end your turn; the coordinator relaunches you in one. Never edit, commit or switch branches in the coordinator's checkout.`,
2883
+ ""
2884
+ ] : [],
2885
+ subagent ? "## Then: install Armada and claim the ticket" : "## First: install Armada and claim the ticket",
2812
2886
  "",
2813
2887
  "```sh",
2814
2888
  b.install,
@@ -2826,8 +2900,12 @@ function renderPrompt(b) {
2826
2900
  "",
2827
2901
  "## Branch",
2828
2902
  "",
2829
- t.branch ? `Work on \`${t.branch}\`. Your workspace starts on a branch Conductor named; rename it before your first commit: \`git branch -m ${t.branch}\`.` : "Linear suggests no branch name for this ticket; name yours after the ticket id.",
2830
- ""
2903
+ t.branch ? `Work on \`${t.branch}\`. Your ${subagent ? "worktree starts on a branch Claude Code" : "workspace starts on a branch Conductor"} named; rename it before your first commit: \`git branch -m ${t.branch}\`.` : "Linear suggests no branch name for this ticket; name yours after the ticket id.",
2904
+ "",
2905
+ ...subagent ? [
2906
+ `You share the coordinator's machine and environment: its \`ARMADA_TICKET\`, if it has one, is not yours. Pass \`--ticket ${t.id}\` to every \`armada report\`, \`ask\` and \`release\`. You end when the coordinator's session ends: report at every step, so the ticket always says where you are.`,
2907
+ ""
2908
+ ] : []
2831
2909
  ];
2832
2910
  if (t.description)
2833
2911
  out.push("## Ticket", "", quote(t.description), "");
@@ -2855,7 +2933,7 @@ ${quote(x.handBack.body)}` : "No hand-back note.", "");
2855
2933
  out.push(`- ${w.id} — ${w.title} (${w.phase})${w.branch ? `, branch \`${w.branch}\`` : ""}${w.pr ? `, ${w.pr}` : ""}`);
2856
2934
  } else
2857
2935
  out.push("None.");
2858
- out.push("", "## Environment", "", b.launch ? `No key is needed in this workspace: once signed in, Armada hands each command the keys it needs, for ${t.id} only. If a command says this worker was cut off from Armada, stop and say so in your reply. Never print, commit or log a token or a key.` : `The coordinator set ${b.environment.map((v) => `\`${v.name}\``).join(", ")} in this workspace. Never print, commit or log their values.`);
2936
+ out.push("", "## Environment", "", b.launch ? `No key is needed in this workspace: once signed in, Armada hands each command the keys it needs, for ${t.id} only. If a command says this worker was cut off from Armada, stop and say so in your reply. Never print, commit or log a token or a key.` : subagent ? "You run with the coordinator's environment and keys. Never print, commit or log their values." : `The coordinator set ${b.environment.map((v) => `\`${v.name}\``).join(", ")} in this workspace. Never print, commit or log their values.`);
2859
2937
  if (b.conventions)
2860
2938
  out.push("", "## Project conventions", "", b.conventions.text.trim());
2861
2939
  return `${out.join(`
@@ -3401,6 +3479,20 @@ async function fetchPullDiff(opts) {
3401
3479
  throw new GithubError(`GitHub API HTTP ${res.status} reading the diff of #${opts.number}`);
3402
3480
  return res.text();
3403
3481
  }
3482
+ var COMMIT_QUERY = `
3483
+ query Commit($owner: String!, $name: String!, $oid: GitObjectID!) {
3484
+ repository(owner: $owner, name: $name) {
3485
+ object(oid: $oid) { ... on Commit { oid tree { oid } parents(first: 3) { nodes { oid } } } }
3486
+ }
3487
+ }`;
3488
+ async function fetchCommit(opts) {
3489
+ const [owner, name] = opts.repository.split("/");
3490
+ const json = await githubQuery(opts, COMMIT_QUERY, { owner, name, oid: opts.sha });
3491
+ const c = json.data?.repository?.object;
3492
+ if (!c?.oid || !c.tree || !c.parents)
3493
+ return null;
3494
+ return { sha: c.oid, tree: c.tree.oid, parents: c.parents.nodes.map((p) => p.oid) };
3495
+ }
3404
3496
  // ../core/src/inbox.ts
3405
3497
  function questionBody(question, options = []) {
3406
3498
  const listed = options.map((o) => o.trim()).filter(Boolean);
@@ -4112,6 +4204,11 @@ var LEASE_POLL_MS = 5000;
4112
4204
  var MERGE_BACKOFF_MS = [2000, 4000, 8000];
4113
4205
  var CONFIRM_BACKOFF_MS = [1000, 2000, 4000, 8000];
4114
4206
  var UNKNOWN_BACKOFF_MS = [2000, 4000];
4207
+ var MERGE_WAIT_DEFAULT_MS = 30 * 60000;
4208
+ var MERGE_WAIT_POLL_MS = 30000;
4209
+ var UPDATE_STALL_MS = 3 * 60000;
4210
+ var NO_CHECKS_GRACE_MS = 60000;
4211
+ var MAX_UPDATES = 20;
4115
4212
  var COMMITIZEN_TITLE = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([\w./,-]+\))?!?: \S/;
4116
4213
  function findHandBack(ticket) {
4117
4214
  const c = ticket.comments.find((x) => x.status?.phase === "ready-to-merge");
@@ -4121,48 +4218,83 @@ function findHandBack(ticket) {
4121
4218
  const sha = c.status.summary.match(/\bhead ([0-9a-f]+)\b/i)?.[1];
4122
4219
  return { pr: pr ? Number(pr) : null, sha: sha?.toLowerCase() ?? null, at: c.createdAt };
4123
4220
  }
4221
+ var MERGEABLE_STATES = new Set(["CLEAN", "HAS_HOOKS"]);
4124
4222
  var STATE_HELP = {
4125
- BEHIND: "the base branch requires it to be up to date; ask the worker to rebase",
4223
+ BEHIND: "the base branch requires it to be up to date; ask the worker to bring the base branch in, or armada merge --wait updates it",
4126
4224
  BLOCKED: "a branch protection rule blocks it (a required review or check)",
4127
- DIRTY: "it conflicts with its base; ask the worker to rebase",
4225
+ DIRTY: "it conflicts with its base; ask the worker to bring the base branch in and resolve the conflicts",
4128
4226
  DRAFT: "it is a draft",
4129
- HAS_HOOKS: "GitHub reports pre-receive hooks; merge it by hand",
4130
4227
  UNKNOWN: "GitHub is still computing mergeability; try again in a minute",
4131
4228
  UNSTABLE: "a check that is not required is failing"
4132
4229
  };
4133
- function mergeProblems({ pull, ticket, handBack, requiredChecks }) {
4230
+ var stateLine = (pull) => `GitHub reports #${pull.number} as ${pull.mergeStateStatus}, not CLEAN${STATE_HELP[pull.mergeStateStatus] ? `: ${STATE_HELP[pull.mergeStateStatus]}` : ""}`;
4231
+ function assess({ pull, ticket, handBack, requiredChecks, lineage, now }) {
4134
4232
  const n = `#${pull.number}`;
4135
4233
  const problems = [];
4136
- if (ticket.agentPhase !== "ready-to-merge")
4137
- problems.push(`${ticket.id} has not been handed back: its agent phase is ${ticket.agentPhase ?? "not set"}, not ready-to-merge`);
4138
- if (!handBack)
4139
- problems.push(`${ticket.id} has no "Agent status: ready-to-merge" comment carrying the head SHA`);
4140
- else {
4141
- if (handBack.pr !== null && handBack.pr !== pull.number)
4142
- problems.push(`the hand-back on ${ticket.id} names PR #${handBack.pr}, not ${n}`);
4143
- if (!handBack.sha)
4144
- problems.push(`the hand-back on ${ticket.id} carries no head SHA`);
4145
- else if (!FULL_SHA.test(handBack.sha))
4146
- problems.push(`the handed-back SHA ${handBack.sha} is not a full 40-character SHA; ask the worker to report ready-to-merge again`);
4147
- else if (handBack.sha !== pull.headSha)
4148
- problems.push(`the head of ${n} is ${pull.headSha}, not the handed-back ${handBack.sha}: it moved after the hand-back; ask the worker to report again`);
4149
- }
4234
+ const waits = [];
4235
+ const notes = [];
4236
+ if (ticket) {
4237
+ if (ticket.agentPhase !== "ready-to-merge")
4238
+ problems.push(`${ticket.id} has not been handed back: its agent phase is ${ticket.agentPhase ?? "not set"}, not ready-to-merge`);
4239
+ if (!handBack)
4240
+ problems.push(`${ticket.id} has no "Agent status: ready-to-merge" comment carrying the head SHA`);
4241
+ else {
4242
+ if (handBack.pr !== null && handBack.pr !== pull.number)
4243
+ problems.push(`the hand-back on ${ticket.id} names PR #${handBack.pr}, not ${n}`);
4244
+ if (!handBack.sha)
4245
+ problems.push(`the hand-back on ${ticket.id} carries no head SHA`);
4246
+ else if (!FULL_SHA.test(handBack.sha))
4247
+ problems.push(`the handed-back SHA ${handBack.sha} is not a full 40-character SHA; ask the worker to report ready-to-merge again`);
4248
+ else if (handBack.sha !== pull.headSha && (lineage?.from !== handBack.sha || lineage.why !== null))
4249
+ problems.push(`the head of ${n} is ${pull.headSha}, not the handed-back ${handBack.sha}: it moved after the hand-back${lineage?.why ? ` and ${lineage.why}` : ""}; ask the worker to report again`);
4250
+ }
4251
+ } else if (lineage?.why)
4252
+ problems.push(`the head of ${n} moved from ${lineage.from} to ${pull.headSha} during this merge and ${lineage.why}`);
4150
4253
  if (pull.state !== "open")
4151
4254
  problems.push(`${n} is ${pull.state}, not open`);
4152
4255
  if (pull.draft)
4153
4256
  problems.push(`${n} is a draft`);
4154
4257
  if (!COMMITIZEN_TITLE.test(pull.title))
4155
4258
  problems.push(`the title "${pull.title}" is not in Commitizen format, e.g. "feat(cli): add a command"`);
4156
- if (pull.mergeStateStatus !== "CLEAN")
4157
- problems.push(`GitHub reports ${n} as ${pull.mergeStateStatus}, not CLEAN${STATE_HELP[pull.mergeStateStatus] ? `: ${STATE_HELP[pull.mergeStateStatus]}` : ""}`);
4158
- for (const p of checkProblems(pull.checks, requiredChecks))
4159
- problems.push(`on head ${pull.headSha.slice(0, 7)}: ${p}`);
4259
+ const checks = checkStates(pull, requiredChecks, !ticket && !lineage?.updates, now);
4260
+ problems.push(...checks.failed);
4261
+ waits.push(...checks.pending);
4262
+ notes.push(...checks.notes);
4263
+ const state = pull.mergeStateStatus;
4264
+ const running = checks.pending.length > 0 || pull.checks.some((c) => c.state === "pending");
4265
+ if (state === "UNKNOWN" || (state === "BLOCKED" || state === "UNSTABLE") && running)
4266
+ waits.push(stateLine(pull));
4267
+ else if (state === "UNSTABLE" && checks.skipped)
4268
+ notes.push(`GitHub reports #${pull.number} as UNSTABLE with no check failing.`);
4269
+ else if (!MERGEABLE_STATES.has(state) && state !== "BEHIND")
4270
+ problems.push(stateLine(pull));
4160
4271
  const { total, read, unresolved } = pull.reviewThreads;
4161
4272
  if (unresolved)
4162
4273
  problems.push(`${n} has ${unresolved} unresolved review thread${unresolved > 1 ? "s" : ""}`);
4163
4274
  else if (total > read)
4164
4275
  problems.push(`${n} has more than ${read} review threads; check they are resolved by hand`);
4165
- return problems;
4276
+ return { problems, waits, notes, behind: state === "BEHIND" };
4277
+ }
4278
+ function checkStates(pull, required, skippable, now) {
4279
+ const on = `on head ${short(pull.headSha)}: `;
4280
+ const failed = [];
4281
+ const pending = [];
4282
+ const notes = [];
4283
+ const ran = required.length ? pull.checks.some((c) => required.includes(c.name)) : pull.checks.length > 0;
4284
+ const quiet = pull.checks.every((c) => c.state === "success");
4285
+ if (skippable && !ran && quiet) {
4286
+ const pushed = pull.updatedAt ? Date.parse(pull.updatedAt) : Number.NaN;
4287
+ if (!now || Number.isNaN(pushed) || now.getTime() - pushed >= NO_CHECKS_GRACE_MS) {
4288
+ const which = required.length ? `none of ${required.map((r) => `"${r}"`).join(", ")}` : "no CI check";
4289
+ notes.push(`${which} ran on head ${short(pull.headSha)}; with --no-ticket it passes on GitHub's own state${pull.checks.length ? " and the checks that ran" : ""}, as for a release pull request opened with the workflow's token.`);
4290
+ return { failed, pending, notes, skipped: true };
4291
+ }
4292
+ pending.push(`${on}no check has reported yet, and it was updated less than ${NO_CHECKS_GRACE_MS / 60000} min ago`);
4293
+ return { failed, pending, notes, skipped: false };
4294
+ }
4295
+ for (const issue of checkIssues(pull.checks, required))
4296
+ (issue.pending ? pending : failed).push(`${on}${issue.text}`);
4297
+ return { failed, pending, notes, skipped: false };
4166
4298
  }
4167
4299
  function baseProblem(pull, cmp, localCommands) {
4168
4300
  if (!cmp)
@@ -4170,7 +4302,7 @@ function baseProblem(pull, cmp, localCommands) {
4170
4302
  if (cmp.behindBy === 0)
4171
4303
  return null;
4172
4304
  if (!localCommands.length)
4173
- return `the head lacks ${cmp.behindBy} commit${cmp.behindBy > 1 ? "s" : ""} of ${pull.baseRef}; ask the worker to rebase, or declare [gates] local_commands in armada.toml so armada merge can test the merge`;
4305
+ return `the head lacks ${cmp.behindBy} commit${cmp.behindBy > 1 ? "s" : ""} of ${pull.baseRef}; ask the worker to bring ${pull.baseRef} in, or declare [gates] local_commands in armada.toml so armada merge can test the merge (armada merge --wait updates the branch instead)`;
4174
4306
  return null;
4175
4307
  }
4176
4308
  var CODE_FILE = /\.(?:[cm]?[jt]sx?|py|go|rs)$/;
@@ -4271,6 +4403,12 @@ async function withLease(fleet, o, body) {
4271
4403
  }
4272
4404
  }
4273
4405
  var say = (ctx, line) => ctx.progress?.(line);
4406
+ var short = (sha) => sha.slice(0, 7);
4407
+ var plural = (k, word) => `${k} ${word}${k === 1 ? "" : "s"}`;
4408
+
4409
+ class NotYet extends Error {
4410
+ name = "NotYet";
4411
+ }
4274
4412
  async function readSettled(ctx, number) {
4275
4413
  let pull = await ctx.forge.readPull(number);
4276
4414
  for (const ms of UNKNOWN_BACKOFF_MS) {
@@ -4283,24 +4421,113 @@ async function readSettled(ctx, number) {
4283
4421
  throw new Refusal(`pull request #${number} was not found in ${ctx.config.github.repository}`, "armada status, which lists the pull requests waiting");
4284
4422
  return pull;
4285
4423
  }
4286
- async function readTicketFor(ctx, pull, explicit) {
4287
- const id = explicit?.trim().toUpperCase() || (pull.headRef ? ticketFromBranch(pull.headRef, ctx.config.tracker.programRoot) : null);
4424
+ async function readTicketFor(ctx, pull, input) {
4425
+ const named = pull.headRef ? ticketFromBranch(pull.headRef, ctx.config.tracker.programRoot) : null;
4426
+ if (input.noTicket) {
4427
+ if (input.ticket)
4428
+ throw new Refusal("--no-ticket and --ticket cannot go together", `armada merge ${pull.number}`);
4429
+ const team = ctx.config.tracker.programRoot.split("-")[0]?.toUpperCase();
4430
+ if (named && named.split("-")[0] === team)
4431
+ throw new Refusal(`the branch of #${pull.number} (${pull.headRef}) names ${named}: merge it on its worker's hand-back, not with --no-ticket`, `armada merge ${pull.number}`);
4432
+ return null;
4433
+ }
4434
+ const id = input.ticket?.trim().toUpperCase() || named;
4288
4435
  if (!id)
4289
- throw new Refusal(`the branch of #${pull.number} (${pull.headRef ?? "unknown"}) names no ticket`, `armada merge ${pull.number} --ticket <id>`);
4436
+ throw new Refusal(`the branch of #${pull.number} (${pull.headRef ?? "unknown"}) names no ticket`, `armada merge ${pull.number} --ticket <id>, or --no-ticket for a pull request no ticket owns (armada init, a release)`);
4290
4437
  const ticket = await ctx.linear.readTicket(id);
4291
4438
  if (!ticket)
4292
- throw new Refusal(`ticket ${id} not found in Linear`, `armada merge ${pull.number} --ticket <id>, with its ticket`);
4439
+ throw new Refusal(`ticket ${id} not found in Linear`, `armada merge ${pull.number} --ticket <id>, with its ticket, or --no-ticket for a pull request no ticket owns`);
4293
4440
  return ticket;
4294
4441
  }
4295
- async function checklist(ctx, input) {
4296
- const { config } = ctx;
4442
+ async function lineageOf(ctx, pull, from, run) {
4443
+ const known = run.lineages.get(pull.headSha);
4444
+ if (known?.from === from)
4445
+ return known;
4446
+ const base = pull.baseRef;
4447
+ const fail = (why) => ({ from, updates: null, why });
4448
+ try {
4449
+ const lineage = await (async () => {
4450
+ let sha = pull.headSha;
4451
+ for (let updates = 0;; updates++) {
4452
+ if (sha === from)
4453
+ return { from, updates, why: null };
4454
+ if (updates >= MAX_UPDATES)
4455
+ return fail(`more than ${MAX_UPDATES} merge commits stand on it`);
4456
+ const commit = await ctx.forge.commit(sha);
4457
+ const [first, second] = commit?.parents ?? [];
4458
+ if (commit?.parents.length !== 2 || !first || !second)
4459
+ return fail(`${short(sha)} is not a merge commit of ${base}`);
4460
+ const cmp = await ctx.forge.compare(base, second);
4461
+ if (cmp?.status !== "BEHIND" && cmp?.status !== "IDENTICAL")
4462
+ return fail(`the merge commit ${short(sha)} brings in ${short(second)}, which is not on ${base}`);
4463
+ if (!ctx.repo)
4464
+ return fail(`git is not available to check what the merge commit ${short(sha)} changes`);
4465
+ const tree = await ctx.repo.mergeTree({ branch: base, number: pull.number, ours: first, theirs: second });
4466
+ if (tree !== commit.tree)
4467
+ return fail(`the merge commit ${short(sha)} changes more than a clean merge of ${base}`);
4468
+ sha = first;
4469
+ }
4470
+ })();
4471
+ run.lineages.set(pull.headSha, lineage);
4472
+ return lineage;
4473
+ } catch (err) {
4474
+ return fail(`what it changes could not be checked (${err instanceof Error ? err.message : String(err)})`);
4475
+ }
4476
+ }
4477
+ async function look(ctx, input, run) {
4297
4478
  const pull = await readSettled(ctx, input.pr);
4298
- const ticket = await readTicketFor(ctx, pull, input.ticket);
4299
- const handBack = findHandBack(ticket);
4300
- const warnings = [...ticket.warnings];
4301
- const lines = [];
4302
- const problems = mergeProblems({ pull, ticket, handBack, requiredChecks: config.gates.requiredChecks });
4479
+ const ticket = await readTicketFor(ctx, pull, input);
4480
+ if (!ticket)
4481
+ run.pin ??= pull.headSha;
4482
+ const handBack = ticket ? findHandBack(ticket) : null;
4483
+ const from = ticket ? handBack?.sha && FULL_SHA.test(handBack.sha) ? handBack.sha : null : run.pin;
4484
+ let lineage = null;
4485
+ if (from === pull.headSha)
4486
+ lineage = { from, updates: 0, why: null };
4487
+ else if (from && pull.state === "open")
4488
+ lineage = await lineageOf(ctx, pull, from, run);
4303
4489
  const cmp = await ctx.forge.compare(pull.baseRef, pull.headSha);
4490
+ const a = assess({
4491
+ pull,
4492
+ ticket,
4493
+ handBack,
4494
+ requiredChecks: ctx.config.gates.requiredChecks,
4495
+ lineage,
4496
+ now: ctx.now()
4497
+ });
4498
+ const behind = a.behind || (cmp?.behindBy ?? 0) > 0;
4499
+ const testable = MERGEABLE_STATES.has(pull.mergeStateStatus) && ctx.config.gates.localCommands.length > 0 && ctx.repo !== null;
4500
+ return { ...a, behind, mustUpdate: behind && !testable, pull, ticket, cmp, lineage };
4501
+ }
4502
+ var label = (pull, ticket) => `#${pull.number}${ticket ? ` (${ticket.id})` : ""}`;
4503
+ function updatedNote(run, pull) {
4504
+ if (!run.updated.size)
4505
+ return "";
4506
+ return `
4507
+ This run updated the branch of #${pull.number} with ${pull.baseRef} (head now ${pull.headSha}): whoever pushes to it next pulls first.`;
4508
+ }
4509
+ function refuse(ctx, run, l, problems, hints = []) {
4510
+ const { pull, ticket } = l;
4511
+ const n = pull.number;
4512
+ return new Refusal(`${label(pull, ticket)} cannot be merged:
4513
+ ${problems.map((p) => ` - ${p}`).join(`
4514
+ `)}${hints.length ? `
4515
+ Hints (not blocking):
4516
+ ${hints.map((h) => ` - ${h}`).join(`
4517
+ `)}` : ""}${updatedNote(run, pull)}`, pull.state !== "open" ? `gh pr view ${n} --repo ${ctx.config.github.repository}` : !ticket ? `gh pr checks ${n} --repo ${ctx.config.github.repository}; armada merge ${n} --no-ticket once it is fixed` : ticket.agentPhase !== "ready-to-merge" ? ctx.lockRequired ? `armada inbox --wait, until ${ticket.id} is handed back` : `armada status, until ${ticket.id} shows ready-to-merge` : `armada answer --note ${ticket.id} "<what to fix>", once you told its worker; merge again after its next hand-back`);
4518
+ }
4519
+ async function checklist(ctx, input, run) {
4520
+ const { config } = ctx;
4521
+ const l = await look(ctx, input, run);
4522
+ const { pull, ticket, cmp } = l;
4523
+ const warnings = [...ticket?.warnings ?? []];
4524
+ const lines = [];
4525
+ const problems = [...l.problems];
4526
+ if (input.wait && !input.dryRun) {
4527
+ if (!problems.length && (l.waits.length || l.mustUpdate))
4528
+ throw new NotYet(l.mustUpdate ? `${pull.baseRef} moved` : l.waits[0] ?? "not ready");
4529
+ } else
4530
+ problems.push(...l.waits, ...l.pull.mergeStateStatus === "BEHIND" ? [stateLine(pull)] : []);
4304
4531
  const behind = baseProblem(pull, cmp, config.gates.localCommands);
4305
4532
  if (behind)
4306
4533
  problems.push(behind);
@@ -4325,14 +4552,12 @@ ${indent(test.output)}`);
4325
4552
  }
4326
4553
  const hints = await hintsFor(ctx, pull, cmp, warnings);
4327
4554
  if (problems.length)
4328
- throw new Refusal(`#${pull.number} (${ticket.id}) cannot be merged:
4329
- ${problems.map((p) => ` - ${p}`).join(`
4330
- `)}${hints.length ? `
4331
- Hints (not blocking):
4332
- ${hints.map((h) => ` - ${h}`).join(`
4333
- `)}` : ""}`, pull.state !== "open" ? `gh pr view ${pull.number} --repo ${config.github.repository}` : ticket.agentPhase !== "ready-to-merge" ? ctx.lockRequired ? `armada inbox --wait, until ${ticket.id} is handed back` : `armada status, until ${ticket.id} shows ready-to-merge` : `armada answer --note ${ticket.id} "<what to fix>", once you told its worker; merge again after its next hand-back`);
4334
- lines.unshift(`Checklist passed for #${pull.number} (${ticket.id}): handed back at ${pull.headSha}, CLEAN, checks green, no open review thread.`);
4335
- return { pull, ticket, sha: pull.headSha, baseSha: cmp?.baseSha ?? null, lines, hints, warnings };
4555
+ throw refuse(ctx, run, l, problems, hints);
4556
+ const updates = l.lineage?.updates ?? 0;
4557
+ const updatedFrom = updates && l.lineage ? l.lineage.from : null;
4558
+ const head = ticket ? updatedFrom ? `handed back at ${updatedFrom}, now ${pull.headSha} with only ${pull.baseRef} merged in (${plural(updates, "merge commit")})` : `handed back at ${pull.headSha}` : updatedFrom ? `head ${pull.headSha}, which is ${updatedFrom} with only ${pull.baseRef} merged in` : `head ${pull.headSha}`;
4559
+ lines.unshift(`Checklist passed for ${label(pull, ticket)}: ${head}, ${pull.mergeStateStatus}, checks green, no open review thread.`, ...l.notes);
4560
+ return { pull, ticket, sha: pull.headSha, updatedFrom, baseSha: cmp?.baseSha ?? null, lines, hints, warnings };
4336
4561
  }
4337
4562
  var indent = (text) => text.trimEnd().split(`
4338
4563
  `).map((l) => ` ${l}`).join(`
@@ -4357,27 +4582,25 @@ async function hintsFor(ctx, pull, cmp, warnings) {
4357
4582
  return [];
4358
4583
  }
4359
4584
  }
4360
- async function recheck(ctx, c) {
4361
- const pull = await readSettled(ctx, c.pull.number);
4362
- const ticket = await ctx.linear.readTicket(c.ticket.id) ?? c.ticket;
4363
- const problems = mergeProblems({
4364
- pull,
4365
- ticket,
4366
- handBack: findHandBack(ticket),
4367
- requiredChecks: ctx.config.gates.requiredChecks
4368
- });
4369
- if (pull.headSha === c.sha) {
4370
- const cmp = await ctx.forge.compare(pull.baseRef, pull.headSha);
4371
- if (cmp?.baseSha !== c.baseSha)
4372
- problems.push(`${pull.baseRef} moved to ${cmp?.baseSha ?? "an unknown commit"} while #${pull.number} was checked`);
4373
- }
4585
+ async function recheck(ctx, input, run, c) {
4586
+ const l = await look(ctx, input, run);
4587
+ const { pull } = l;
4588
+ const moved = [];
4589
+ if (pull.headSha !== c.sha)
4590
+ moved.push(`the head of #${pull.number} moved to ${pull.headSha} while it was checked`);
4591
+ else if (l.cmp?.baseSha !== c.baseSha)
4592
+ moved.push(`${pull.baseRef} moved to ${l.cmp?.baseSha ?? "an unknown commit"} while #${pull.number} was checked`);
4593
+ if (input.wait && !l.problems.length && (moved.length || l.waits.length))
4594
+ throw new NotYet(moved[0] ?? l.waits[0] ?? "not ready");
4595
+ const problems = [...l.problems, ...l.waits, ...moved];
4374
4596
  if (problems.length)
4375
4597
  throw new Refusal(`#${pull.number} changed while it was checked; nothing was merged:
4376
4598
  ${problems.map((p) => ` - ${p}`).join(`
4377
- `)}`, `armada merge ${pull.number} again`);
4599
+ `)}${updatedNote(run, pull)}`, `armada merge ${pull.number} again`);
4378
4600
  }
4379
4601
  async function mergePinned(ctx, pull, sha, ticket) {
4380
4602
  const n = `#${pull.number}`;
4603
+ const closeByHand = ticket ? `; if it merged, close ${ticket} by hand` : "";
4381
4604
  let readError = "";
4382
4605
  const read = () => {
4383
4606
  readError = "";
@@ -4395,7 +4618,7 @@ async function mergePinned(ctx, pull, sha, ticket) {
4395
4618
  break;
4396
4619
  const view = `gh pr view ${pull.number} --repo ${ctx.config.github.repository}`;
4397
4620
  if (!fresh)
4398
- throw new Refusal(`GitHub failed (${res.message}) and ${n} could not be read back (${readError || "not found"}); if it merged, close ${ticket} by hand`, view);
4621
+ throw new Refusal(`GitHub failed (${res.message}) and ${n} could not be read back (${readError || "not found"})${closeByHand}`, view);
4399
4622
  if (!res.transient)
4400
4623
  throw new Refusal(`GitHub refused to merge ${n}: ${res.message}`, `armada merge ${pull.number} --dry-run`);
4401
4624
  if (fresh.state !== "open")
@@ -4405,7 +4628,7 @@ async function mergePinned(ctx, pull, sha, ticket) {
4405
4628
  const wait = MERGE_BACKOFF_MS[attempt];
4406
4629
  if (wait === undefined)
4407
4630
  throw new Refusal(`GitHub kept failing (${res.message}) after ${attempt + 1} attempts; ${n} is still open and nothing was merged`, `armada merge ${pull.number} again once GitHub answers`);
4408
- say(ctx, `GitHub answered ${res.message}; ${n} is still open at ${sha.slice(0, 7)}, retrying in ${wait / 1000} s…`);
4631
+ say(ctx, `GitHub answered ${res.message}; ${n} is still open at ${short(sha)}, retrying in ${wait / 1000} s…`);
4409
4632
  await ctx.sleep(wait);
4410
4633
  }
4411
4634
  let seen = null;
@@ -4415,15 +4638,15 @@ async function mergePinned(ctx, pull, sha, ticket) {
4415
4638
  break;
4416
4639
  const wait = CONFIRM_BACKOFF_MS[i];
4417
4640
  if (wait === undefined)
4418
- throw new Refusal(seen ? `the merge of ${n} was accepted but GitHub shows it as ${seen.state}, not merged (auto-merge or a merge queue?); the ticket was left as is` : `the merge of ${n} was accepted but GitHub could not be read back (${readError || "not found"}); if it merged, close ${ticket} by hand`, `gh pr view ${pull.number} --repo ${ctx.config.github.repository}`);
4641
+ throw new Refusal(seen ? `the merge of ${n} was accepted but GitHub shows it as ${seen.state}, not merged (auto-merge or a merge queue?)${ticket ? "; the ticket was left as is" : ""}` : `the merge of ${n} was accepted but GitHub could not be read back (${readError || "not found"})${closeByHand}`, `gh pr view ${pull.number} --repo ${ctx.config.github.repository}`);
4419
4642
  await ctx.sleep(wait);
4420
4643
  }
4421
4644
  if (seen.headSha !== sha)
4422
- throw new Refusal(`${n} was merged at ${seen.headSha}, not at the handed-back ${sha}; check ${pull.baseRef} now`, `gh pr view ${pull.number} --repo ${ctx.config.github.repository}`);
4645
+ throw new Refusal(`${n} was merged at ${seen.headSha}, not at the ${ticket ? "handed-back" : "checked"} ${sha}; check ${pull.baseRef} now`, `gh pr view ${pull.number} --repo ${ctx.config.github.repository}`);
4423
4646
  return seen;
4424
4647
  }
4425
4648
  var runtimeGuide = (runtime) => runtime ? `armada-runtime-${runtime.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "")}` : null;
4426
- async function closeTicket(ctx, ticket, merged, unlocked) {
4649
+ async function closeTicket(ctx, ticket, merged, c, unlocked) {
4427
4650
  const groups = ctx.config.tracker.labels;
4428
4651
  const done = ticket.statusType === "completed" ? null : firstState(ticket.states, "completed");
4429
4652
  await ctx.linear.updateTicket(ticket.uuid, {
@@ -4436,48 +4659,121 @@ async function closeTicket(ctx, ticket, merged, unlocked) {
4436
4659
  });
4437
4660
  if (!ticket.prs.some((p) => p.url === merged.url))
4438
4661
  await ctx.linear.linkUrl(ticket.uuid, merged.url, merged.title || `Pull request #${merged.number}`);
4439
- await ctx.linear.comment(ticket.uuid, `Agent status: merged — PR #${merged.number} squash-merged into ${merged.baseRef} as ${merged.mergeCommit ?? "unknown"}, head ${merged.headSha}${unlocked ? ", merged without lock (--no-lock)" : ""}`);
4662
+ await ctx.linear.comment(ticket.uuid, `Agent status: merged — PR #${merged.number} squash-merged into ${merged.baseRef} as ${merged.mergeCommit ?? "unknown"}, head ${merged.headSha}${c.updatedFrom ? `, the handed-back ${c.updatedFrom} updated with ${merged.baseRef}` : ""}${unlocked ? ", merged without lock (--no-lock)" : ""}`);
4440
4663
  return [
4441
4664
  `${ticket.id}: ${done ? `moved to ${done.name}` : "state unchanged"}, agent and ready labels removed, merged status posted.`
4442
4665
  ];
4443
4666
  }
4667
+ async function waitUntilReady(ctx, input, run, deadline) {
4668
+ const minutes = Math.round((input.wait?.timeoutMs ?? 0) / 60000);
4669
+ let shown = "";
4670
+ for (;; ) {
4671
+ const l = await look(ctx, input, run);
4672
+ const { pull } = l;
4673
+ const n = `#${pull.number}`;
4674
+ if (l.problems.length)
4675
+ throw refuse(ctx, run, l, l.problems);
4676
+ let reason;
4677
+ const asked = run.updated.get(pull.headSha);
4678
+ if (l.mustUpdate) {
4679
+ if (pull.mergeable === "CONFLICTING")
4680
+ throw refuse(ctx, run, l, [`${n} conflicts with ${pull.baseRef}; ask the worker to merge it in or rebase`]);
4681
+ if (pull.mergeable !== "MERGEABLE")
4682
+ reason = `GitHub is still computing whether ${n} merges cleanly with ${pull.baseRef}`;
4683
+ else if (asked !== undefined) {
4684
+ if (ctx.now().getTime() - asked >= UPDATE_STALL_MS)
4685
+ throw refuse(ctx, run, l, [
4686
+ `GitHub accepted to update the branch of ${n} with ${pull.baseRef}, but its head is still ${pull.headSha} after ${UPDATE_STALL_MS / 60000} min; update it on GitHub, or ask the worker to merge ${pull.baseRef} in`
4687
+ ]);
4688
+ reason = `GitHub is updating the branch of ${n} with ${pull.baseRef}`;
4689
+ } else {
4690
+ const res = await ctx.forge.updateBranch(pull.number, pull.headSha);
4691
+ const fresh = res.ok ? null : await ctx.forge.readPull(pull.number).catch(() => null);
4692
+ if (res.ok) {
4693
+ run.updated.set(pull.headSha, ctx.now().getTime());
4694
+ say(ctx, `Updated the branch of ${n} with ${pull.baseRef} (a merge commit on ${short(pull.headSha)}).`);
4695
+ reason = `the checks on the updated head of ${n}`;
4696
+ } else if (res.transient || fresh && fresh.headSha !== pull.headSha)
4697
+ reason = `GitHub could not update the branch of ${n} yet (${res.message})`;
4698
+ else
4699
+ throw refuse(ctx, run, l, [
4700
+ `GitHub refused to update the branch of ${n} with ${pull.baseRef}: ${res.message}. A branch protection rule or ruleset can forbid it (signed commits, restricted pushes); ask the worker to merge ${pull.baseRef} in or rebase`
4701
+ ]);
4702
+ }
4703
+ } else if (l.waits.length)
4704
+ reason = l.waits.join("; ");
4705
+ else
4706
+ return;
4707
+ if (reason !== shown)
4708
+ say(ctx, `Waiting: ${reason}…`);
4709
+ shown = reason;
4710
+ if (ctx.now().getTime() >= deadline)
4711
+ throw new Refusal(`${label(pull, l.ticket)} is still not ready after ${minutes} min: ${reason}; nothing was merged${updatedNote(run, pull)}`, `armada merge ${pull.number} --wait again${input.noTicket ? " --no-ticket" : ""}, or armada merge ${pull.number} --dry-run to see the checklist`);
4712
+ await ctx.sleep(MERGE_WAIT_POLL_MS);
4713
+ }
4714
+ }
4444
4715
  async function mergePullRequest(ctx, input) {
4716
+ const run = { pin: null, updated: new Map, lineages: new Map };
4445
4717
  if (input.dryRun) {
4446
- const c = await checklist(ctx, input);
4718
+ const c = await checklist(ctx, input, run);
4447
4719
  return outcome(c, false, null, c.lines.concat("Dry run: nothing was merged."), [], null);
4448
4720
  }
4721
+ if (!input.wait)
4722
+ return locked(ctx, input, run);
4723
+ if (!input.noLock && ctx.lockRequired) {
4724
+ const { fleet, warning } = await ctx.fleet();
4725
+ if (!fleet)
4726
+ throw lockUnavailable(ctx, input, warning);
4727
+ }
4728
+ const deadline = ctx.now().getTime() + input.wait.timeoutMs;
4729
+ for (;; ) {
4730
+ await waitUntilReady(ctx, input, run, deadline);
4731
+ try {
4732
+ return await locked(ctx, input, run);
4733
+ } catch (err) {
4734
+ if (!(err instanceof NotYet))
4735
+ throw err;
4736
+ say(ctx, `Not ready under the merge lock (${err.message}); lock given back, waiting again…`);
4737
+ }
4738
+ }
4739
+ }
4740
+ var lockUnavailable = (ctx, input, warning) => new Refusal(`the merge lock needs Armada, which is unavailable (${warning ?? "no answer"}); nothing was merged`, `armada merge ${input.pr} again once Armada answers, or armada merge ${input.pr} --no-lock if you are sure no other coordinator merges in ${ctx.config.project.slug} now`);
4741
+ async function locked(ctx, input, run) {
4449
4742
  const { config } = ctx;
4450
4743
  const slug = config.project.slug;
4451
4744
  const early = [];
4452
- const run = async (renew) => {
4453
- const c = await checklist(ctx, input);
4745
+ const body = async (renew) => {
4746
+ const c = await checklist(ctx, input, run);
4454
4747
  c.warnings.unshift(...early);
4455
- await recheck(ctx, c);
4748
+ await recheck(ctx, input, run, c);
4456
4749
  if (!await renew())
4457
4750
  throw new Refusal("the merge lock could not be renewed (it expired and another coordinator took it, or Armada did not answer); nothing was merged", `armada merge ${input.pr} again`);
4458
4751
  say(ctx, `Merging #${c.pull.number} at ${c.sha}…`);
4459
- const merged = await mergePinned(ctx, c.pull, c.sha, c.ticket.id);
4752
+ const merged = await mergePinned(ctx, c.pull, c.sha, c.ticket?.id ?? null);
4460
4753
  const lines = [
4461
4754
  ...c.lines,
4462
4755
  `Merged #${merged.number} into ${merged.baseRef} as ${merged.mergeCommit ?? "unknown"} (head ${merged.headSha}).`
4463
4756
  ];
4464
- try {
4465
- lines.push(...await closeTicket(ctx, c.ticket, merged, !!input.noLock));
4466
- } catch (err) {
4467
- throw new Error(`#${merged.number} is merged, but Linear could not be updated (${err instanceof Error ? err.message : String(err)}); close ${c.ticket.id} by hand: Done, agent and ready labels removed, pull request linked`);
4468
- }
4757
+ if (c.ticket)
4758
+ try {
4759
+ lines.push(...await closeTicket(ctx, c.ticket, merged, c, !!input.noLock));
4760
+ } catch (err) {
4761
+ throw new Error(`#${merged.number} is merged, but Linear could not be updated (${err instanceof Error ? err.message : String(err)}); close ${c.ticket.id} by hand: Done, agent and ready labels removed, pull request linked`);
4762
+ }
4763
+ else
4764
+ lines.push("No ticket: nothing was written to Linear.");
4469
4765
  return after(ctx, c, merged, lines);
4470
4766
  };
4471
4767
  if (input.noLock) {
4472
4768
  early.push(`merged without the merge lock (--no-lock): make sure no other coordinator merges in ${slug} now`);
4473
- return run(async () => true);
4769
+ return body(async () => true);
4474
4770
  }
4475
4771
  const { fleet, warning } = await ctx.fleet();
4476
4772
  if (!fleet && ctx.lockRequired)
4477
- throw new Refusal(`the merge lock needs Armada, which is unavailable (${warning ?? "no answer"}); nothing was merged`, `armada merge ${input.pr} again once Armada answers, or armada merge ${input.pr} --no-lock if you are sure no other coordinator merges in ${slug} now`);
4773
+ throw lockUnavailable(ctx, input, warning);
4478
4774
  if (!fleet) {
4479
4775
  early.push(`${warning ?? "not signed in to Armada"}; the merge lock was not taken, so make sure no other coordinator merges in ${slug} now`);
4480
- return run(async () => true);
4776
+ return body(async () => true);
4481
4777
  }
4482
4778
  return withLease(fleet, {
4483
4779
  project: slug,
@@ -4486,23 +4782,24 @@ async function mergePullRequest(ctx, input) {
4486
4782
  ttlMs: MERGE_LEASE_TTL_MS,
4487
4783
  sleep: ctx.sleep,
4488
4784
  onWait: (held) => say(ctx, `Waiting for the merge lock held by ${held?.holder ?? "another coordinator"} (until ${held?.expiresAt ?? "?"})…`)
4489
- }, run);
4785
+ }, body);
4490
4786
  }
4491
4787
  async function after(ctx, c, merged, lines) {
4492
- const live$ = await live(ctx, c.warnings, "record the merge", (fleet) => fleet.merge({
4493
- ticket: c.ticket.id,
4788
+ const ticket = c.ticket;
4789
+ const live$ = ticket ? await live(ctx, c.warnings, "record the merge", (fleet) => fleet.merge({
4790
+ ticket: ticket.id,
4494
4791
  number: merged.number,
4495
4792
  url: merged.url,
4496
4793
  mergeCommit: merged.mergeCommit,
4497
4794
  headSha: merged.headSha
4498
- }));
4795
+ })) : null;
4499
4796
  if (live$?.resolved)
4500
4797
  lines.push(`Hand-back resolved in the coordinator's inbox.`);
4501
4798
  let workers = [];
4502
4799
  let listed = false;
4503
4800
  try {
4504
4801
  const handles = new Map((live$?.open ?? []).map((h) => [h.ticket, h]));
4505
- workers = (await ctx.inFlight()).filter((t) => t.id !== c.ticket.id).map((t) => ({
4802
+ workers = (await ctx.inFlight()).filter((t) => t.id !== ticket?.id).map((t) => ({
4506
4803
  ticket: t.id,
4507
4804
  title: t.title,
4508
4805
  phase: t.phase,
@@ -4513,8 +4810,10 @@ async function after(ctx, c, merged, lines) {
4513
4810
  } catch (err) {
4514
4811
  c.warnings.push(`could not list the workers in flight (${err instanceof Error ? err.message : String(err)}); run armada status`);
4515
4812
  }
4516
- const claim = activeClaimComments(c.ticket.comments)[0]?.claim;
4517
- const runtime = live$?.handle?.runtime ?? c.ticket.agentRuntime ?? claim?.runtime ?? null;
4813
+ if (!ticket)
4814
+ return { ...outcome(c, true, merged, lines, workers, null), workersListed: listed };
4815
+ const claim = activeClaimComments(ticket.comments)[0]?.claim;
4816
+ const runtime = live$?.handle?.runtime ?? ticket.agentRuntime ?? claim?.runtime ?? null;
4518
4817
  const expected = runtimeGuide(runtime);
4519
4818
  let guide = null;
4520
4819
  try {
@@ -4537,7 +4836,7 @@ function outcome(c, merged, pr, lines, workers, archive) {
4537
4836
  headSha: p.headSha,
4538
4837
  mergeCommit: pr?.mergeCommit ?? null
4539
4838
  },
4540
- ticket: { id: c.ticket.id, url: c.ticket.url },
4839
+ ticket: c.ticket ? { id: c.ticket.id, url: c.ticket.url } : null,
4541
4840
  lines,
4542
4841
  hints: c.hints,
4543
4842
  workers,
@@ -4573,7 +4872,7 @@ async function readProjectConfig(p, opts) {
4573
4872
  import { createHash } from "node:crypto";
4574
4873
 
4575
4874
  // ../../skills/armada-coordinator/MERGE.md
4576
- var MERGE_default = "# Merging a pull request\n\nRun `armada merge <pr>` (add `--dry-run` to see the checklist only). It checks everything below, takes the project's merge lock, merges pinned to the handed-back SHA, confirms the merge on GitHub and closes the ticket. Its output lists the workers in flight to tell and the worker session to archive. When a refusal names a rule, fix the cause (usually: ask the worker to rebase and report again) rather than merging by hand. When you must merge by hand, follow the same steps.\n\n## Before\n\n1. The worker has handed back: `Agent phase` is `ready-to-merge` and you have the full 40-character head SHA it reported.\n2. `gh pr view <n> --json headRefOid,mergeStateStatus,isDraft,title` shows that SHA, `CLEAN`, not a draft, and a Commitizen title.\n3. `gh pr checks <n>` shows every required check passing.\n4. The head contains the current default branch: `git merge-base --is-ancestor origin/<default> <sha>`. If not, ask the worker to rebase.\n5. Semantic check: search the default branch for callers of anything the pull request deletes or renames.\n\n## Merge\n\n```sh\ngh pr merge <n> --squash --match-head-commit <full-sha>\n```\n\n- One merge at a time: `armada merge` holds the project's merge lock. If it refuses because Armada is down, use `--no-lock` only when you are sure no other coordinator merges in the project.\n- Leave out `--delete-branch`: it deletes local worktrees that have the branch checked out, including other agents'. Delete the branch once its worktree is gone.\n- If GitHub answers with a 5xx, check `gh pr view <n> --json state` before retrying.\n\n## After\n\n1. The ticket is Done, its `Agent phase` and `Agent runtime` labels removed, the pull request linked.\n2. Tell every in-flight worker what the merge changes for them: a shared file, a migration, a new check, code they must now reuse or delete.\n3. Archive the merged worker's workspace with the \"Stop and archive\" section of its runtime guide.\n4. Launch the tickets this merge unblocked.\n\n## The release pull request\n\nSome repositories publish through release-please: every merge to the default branch opens or updates one release pull request, and merging it tags the version and publishes it. When the repository's rules (`AGENTS.md`) say to merge it after each merge, do it right after the ticket's merge, without a hand-back: no worker owns it, so `armada merge` does not apply.\n\n- **What it looks like.** Title `chore(main): release <version>`, opened by `github-actions`, label `autorelease: pending`, and a diff that only touches the changelog, the manifest and version fields. It is opened with the workflow's own token, so **no CI check runs on it** (only checks from apps such as Vercel, if any) and `mergeStateStatus` is `UNSTABLE`. Both are expected: the publish job runs the repository's checks again before publishing. Anything else in the diff, or a `DIRTY` state, is not expected: stop and tell the owner.\n- **Find it and its head:**\n\n```sh\ngh pr list --state open --label \"autorelease: pending\" --json number,title,headRefOid,mergeStateStatus\n```\n\n- **Merge it** pinned to that head, like any merge, and without `--delete-branch`:\n\n```sh\ngh pr merge <n> --squash --match-head-commit <full-sha>\n```\n\n- **Check the publish.** After a minute or two the new version is on the registry, for example `npm view <package> version` for an npm package (the package is named in `AGENTS.md` or the release workflow). If it is not, open the Release run (`gh run list --workflow release.yml --limit 3`), fix the cause and re-run its failed jobs: a later push does not publish a version already tagged.\n- Release-please updates the same pull request on each merge to the default branch; one release pull request can carry several merges.\n";
4875
+ var MERGE_default = "# Merging a pull request\n\nRun `armada merge <pr>` (add `--dry-run` to see the checklist only, `--wait` when main keeps moving, `--no-ticket` for a pull request no ticket owns). It checks everything below, takes the project's merge lock, merges pinned to the handed-back SHA, confirms the merge on GitHub and closes the ticket. Its output lists the workers in flight to tell and the worker session to archive. When a refusal names a rule, fix the cause (usually: ask the worker to bring the default branch in and report again) rather than merging by hand. When you must merge by hand, follow the same steps.\n\n## Main kept moving: `--wait`\n\nWith several workers in flight, main often moves between a green hand-back and its merge. Instead of asking the worker to bring main in, run `armada merge <pr> --wait [--timeout <min>]` (30 minutes by default), in the background where your runtime allows it (Claude Code: `run_in_background`):\n\n- A head behind main that GitHub says merges cleanly is updated with GitHub's \"update branch\": a merge commit on the branch, no force-push. Squash merges make that merge commit harmless. When main does not require heads to be up to date and `[gates] local_commands` is set, it is test-merged instead, as without `--wait`, so a busy main does not restart CI each time.\n- It waits for every required check on the new head, then merges pinned to that head.\n- It holds the project's merge lock only while merging, not while waiting, so two waits never block each other. Signed in with Armada down, it refuses before touching the branch.\n- It stops at once, naming the cause, on a red check, a conflict, any other refused rule, or when GitHub refuses the update (a branch protection rule or ruleset can forbid it) or accepts it without the head moving within 3 minutes: ask the worker to fix it. A refusal after an update says so: the worker pulls the updated branch before pushing again.\n- The updated head still counts as the worker's hand-back, because the only change is main coming in: `armada merge` accepts a head that is the handed-back SHA followed only by merge commits, each bringing in a commit of main, with the tree of a clean merge (checked with git). That holds without `--wait` too, for example after \"Update branch\" on GitHub. The ticket's merged comment names both heads: `head <new>, the handed-back <old> updated with main`.\n\n## No ticket: `--no-ticket`\n\n`armada merge <pr> --no-ticket` merges a pull request no ticket owns: the `armada init` pull request (its output names the command) or the release pull request below. There is no hand-back and nothing is written to Linear; every other check is unchanged, and the merge is pinned to the head it checked. It refuses a branch that names a ticket of the program: that one is merged on its worker's hand-back.\n\nWhen none of the required checks ran on the head (a release pull request opened with the workflow's own token gets no CI run), it passes with a note, on GitHub's own state (`UNSTABLE` included, when nothing failed) and the checks that did run, once the head is a minute old; a younger head, or a head this run updated (its update starts CI), is waited for (`--wait`) or refused.\n\n## Before\n\n1. The worker has handed back: `Agent phase` is `ready-to-merge` and you have the full 40-character head SHA it reported.\n2. `gh pr view <n> --json headRefOid,mergeStateStatus,isDraft,title` shows that SHA (or that SHA with only main merged in), `CLEAN` (or `HAS_HOOKS`), not a draft, and a Commitizen title.\n3. `gh pr checks <n>` shows every required check passing.\n4. The head contains the current default branch: `git merge-base --is-ancestor origin/<default> <sha>`. If not, update it (`--wait`) or ask the worker to bring the default branch in (rebase, or merge it into their branch; never force-push a branch someone else pushed to).\n5. Semantic check: search the default branch for callers of anything the pull request deletes or renames.\n\n## Merge\n\n```sh\ngh pr merge <n> --squash --match-head-commit <full-sha>\n```\n\n- One merge at a time: `armada merge` holds the project's merge lock. If it refuses because Armada is down, use `--no-lock` only when you are sure no other coordinator merges in the project.\n- Leave out `--delete-branch`: it deletes local worktrees that have the branch checked out, including other agents'. Delete the branch once its worktree is gone.\n- If GitHub answers with a 5xx, check `gh pr view <n> --json state` before retrying.\n\n## After\n\n1. The ticket is Done, its `Agent phase` and `Agent runtime` labels removed, the pull request linked.\n2. Tell every in-flight worker what the merge changes for them: a shared file, a migration, a new check, code they must now reuse or delete.\n3. Archive the merged worker's workspace with the \"Stop and archive\" section of its runtime guide.\n4. Launch the tickets this merge unblocked.\n\n## The release pull request\n\nSome repositories publish through release-please: every merge to the default branch opens or updates one release pull request, and merging it tags the version and publishes it. When the repository's rules (`AGENTS.md`) say to merge it after each merge, do it right after the ticket's merge, without a hand-back: no worker owns it.\n\n- **What it looks like.** Title `chore(main): release <version>`, opened by `github-actions`, label `autorelease: pending`, and a diff that only touches the changelog, the manifest and version fields. It is opened with the workflow's own token, so **no CI check runs on it** (only checks from apps such as Vercel, if any) and `mergeStateStatus` is often `UNSTABLE` (`armada merge --no-ticket` accepts it when none of the required checks ran and nothing failed). Both are expected: the publish job runs the repository's checks again before publishing. Anything else in the diff, or a `DIRTY` state, is not expected: stop and tell the owner.\n- **Find it and its head:**\n\n```sh\ngh pr list --state open --label \"autorelease: pending\" --json number,title,headRefOid,mergeStateStatus\n```\n\n- **Merge it** with `armada merge <n> --no-ticket`: no ticket owns it, and no required check runs on it (see \"No ticket\" above). By hand, pin it to that head, like any merge, and without `--delete-branch`:\n\n```sh\ngh pr merge <n> --squash --match-head-commit <full-sha>\n```\n\n- **Check the publish.** After a minute or two the new version is on the registry, for example `npm view <package> version` for an npm package (the package is named in `AGENTS.md` or the release workflow). If it is not, open the Release run (`gh run list --workflow release.yml --limit 3`), fix the cause and re-run its failed jobs: a later push does not publish a version already tagged.\n- Release-please updates the same pull request on each merge to the default branch; one release pull request can carry several merges.\n";
4577
4876
 
4578
4877
  // ../../skills/armada-coordinator/SKILL.md
4579
4878
  var SKILL_default = `---
@@ -4585,7 +4884,7 @@ The coordinator turns the owner's intent into merged pull requests. Each worker
4585
4884
 
4586
4885
  **Standing authority.** Unless the owner said otherwise, they delegate reversible technical decisions, plan approval and merging to you: act, then report. Escalate only product decisions, irreversible or outward-facing actions, and anything that spends money.
4587
4886
 
4588
- **Armada never drives a runtime.** Launching, messaging, checking and stopping a worker go through the runtime guide skill for the worker's runtime (for example \`armada-runtime-conductor\`). Armada records what happened.
4887
+ **Armada never drives a runtime.** Launching, messaging, checking and stopping a worker go through the runtime guide skill for the worker's runtime: \`armada-runtime-conductor\` for a Conductor workspace, \`armada-runtime-claude-code\` for a subagent of your own Claude Code session (the \`Runtime:\` line of \`armada brief\` names it). Armada records what happened.
4589
4888
 
4590
4889
  ## Take over a run
4591
4890
 
@@ -4601,7 +4900,7 @@ A coordinator may start cold, on a laptop or in a fresh cloud session, with noth
4601
4900
  ## Loop
4602
4901
 
4603
4902
  1. **Read the fleet** with \`armada status\` and \`armada inbox\`, never from memory. Done when you can name every ticket in flight and its phase, every ready ticket, every pull request waiting, every silent worker and every pending question, plan or request.
4604
- 2. **Answer what waits for you first.** For each question in \`armada inbox\`: decide it, or escalate it to the owner when it is a product decision and wait for theirs. For each \`plan\` item: read the full plan, approve it or give concrete amendments. Deliver the decision in the worker's session with the runtime guide's *message* section, then record it with \`armada answer <item> "approved"\` or \`armada answer <item> "<amendments and reason>"\`. The worker resumes with \`implementing\` on approval, or returns to \`planning\` and submits a revised plan. \`armada answer\` only records; it never reaches the worker. Decide reversible choices yourself and prefer the option that keeps behaviour observable. When two workers need the same shared resource (a migration slot, a generated file, a version number), set the rule once and tell both. A message the worker did not ask for (main moved, rebase needed) takes the same path: deliver it with the runtime guide, then \`armada answer --note <ticket> "<message>"\`. Done when the inbox shows no open question or plan.
4903
+ 2. **Answer what waits for you first.** For each question in \`armada inbox\`: decide it, or escalate it to the owner when it is a product decision and wait for theirs. For each \`plan\` item: read the full plan, approve it or give concrete amendments. Deliver the decision in the worker's session with the runtime guide's *message* section, then record it with \`armada answer <item> "approved"\` or \`armada answer <item> "<amendments and reason>"\`. The worker resumes with \`implementing\` on approval, or returns to \`planning\` and submits a revised plan. \`armada answer\` only records; it never reaches the worker. Decide reversible choices yourself and prefer the option that keeps behaviour observable. When two workers need the same shared resource (a migration slot, a generated file, a version number), set the rule once and tell both. A message the worker did not ask for (main moved, bring it in) takes the same path: deliver it with the runtime guide, then \`armada answer --note <ticket> "<message>"\`. Done when the inbox shows no open question or plan.
4605
4904
  3. **Carry out the owner's dashboard requests.** They are the owner's word, signed with their name; they never reached a worker.
4606
4905
  - \`answer-request\` (it names the question or plan it answers, \`answers #<id>\`): deliver its text in the worker's session with the runtime guide's *message* section, as the owner's answer or plan approval, then \`armada answer <request id> "<the text you delivered>"\`. That resolves the request and its question or plan, and the ticket names who answered. If the item is gone (the worker was released or changed phase), \`armada answer <request id> "<why>"\` closes it.
4607
4906
  - \`launch-request\` (it names the profile the owner chose): launch the ticket as in step 5, with that profile. When it differs from the routed one, the request's body gives the \`--profile\` and \`--reason\` to pass to \`armada brief\` and to the worker's claim. The worker's \`armada claim\` resolves the request and posts who asked. If the ticket must not start (it collides with work in flight, or its plan changed), decline it: \`armada answer <request id> "<why>"\`, and tell the owner in your report.
@@ -4613,7 +4912,7 @@ A coordinator may start cold, on a laptop or in a fresh cloud session, with noth
4613
4912
  - write the prompt with \`armada brief <ticket> --prompt > <file>\` and add what only you know: which parallel workers touch neighbouring code and where the boundary is, and decisions not yet on the ticket. The brief already says whether the plan needs approval (\`[policy] plans\`, or the ticket's label) and ends with the project's conventions (\`[brief] extra\`): put a note every worker needs in that file, not in each prompt;
4614
4913
  - launch it with the runtime guide's *launch* section, passing the profile's values. When the brief's \`Launch:\` line says the prompt carries a one-time token, pass no key: the worker signs in with it. When it says there is none, fix the reason (usually your sign-in) and brief again, rather than pass keys; the token works once, within the hour, so brief right before the launch;
4615
4914
  - check the claim: \`armada status\` shows the ticket in flight, phase \`planning\`, with the handle the runtime returned. Done when every launched ticket is In Progress with a claim.
4616
- 6. **Merge handed-back pull requests** one at a time with \`armada merge <pr>\`, following [MERGE.md](MERGE.md). Done when the pull request is merged, the ticket is Done with its agent labels removed, and every in-flight worker affected by what landed has been told. When the repository's rules (\`AGENTS.md\`) ask you to ship each merge through its release pull request (release-please's \`chore(main): release …\`), merge that one next, as "The release pull request" in [MERGE.md](MERGE.md) describes.
4915
+ 6. **Merge handed-back pull requests** one at a time with \`armada merge <pr>\` (\`--wait\` when main moved since the hand-back, \`--no-ticket\` for a pull request no ticket owns), following [MERGE.md](MERGE.md). Done when the pull request is merged, the ticket is Done with its agent labels removed, and every in-flight worker affected by what landed has been told. When the repository's rules (\`AGENTS.md\`) ask you to ship each merge through its release pull request (release-please's \`chore(main): release …\`), merge that one next, as "The release pull request" in [MERGE.md](MERGE.md) describes.
4617
4916
  7. **Turn findings into tickets.** A gap a worker reports or a bug you see becomes a ticket under the right spec, with blocked-by relations, and is launched when ready. No finding lives only in a transcript.
4618
4917
  8. **Report to the owner** in their language (\`tracker.language\` in \`armada.toml\`, or the owner's personal setting): what merged, what runs, what you decided for them, and the one thing they must do, with its exact place (a URL, a setting). Outcomes and numbers, no process narration.
4619
4918
 
@@ -4632,17 +4931,126 @@ You only learn of something new when a command you run ends. So while a worker i
4632
4931
 
4633
4932
  ## Rules of thumb
4634
4933
 
4635
- - Merge only after the worker's hand-back; a green pull request can still get one more rebased push.
4934
+ - Merge only after the worker's hand-back; a green pull request can still get one more push that brings the default branch in.
4636
4935
  - Parallel workers in one area collide: stagger them, or give each a disjoint area and tell them the boundary.
4637
4936
  - Everything that must survive your session goes to the tracker or the repository. The next coordinator may be a fresh cloud session with none of your context: it resumes from \`armada status\` and \`armada inbox\`.
4638
4937
  - When a command named here is missing from your Armada version (\`armada --help\`), do the step by hand with the same protocol and say so in your report.
4639
4938
  `;
4640
4939
 
4940
+ // ../../skills/armada-runtime-claude-code/SKILL.md
4941
+ var SKILL_default2 = `---
4942
+ name: armada-runtime-claude-code
4943
+ description: Runtime guide for running Armada workers as local subagents of a Claude Code coordinator. Use when an Armada coordinator running in Claude Code must launch a worker on a ticket with the Agent tool, send it a message, check whether a silent worker is still alive, or stop it and clean up its worktree. Four fixed sections, each with the exact tool call and how to read its result.
4944
+ ---
4945
+
4946
+ Armada never calls a runtime. This guide tells a coordinator running inside Claude Code how to launch, message, check and stop a worker as one of its own subagents (the Agent tool), and what to record in Armada afterwards. It was checked against Claude Code's Agent, SendMessage, TaskStop and EnterWorktree tools as of October 2026; if a parameter below is refused, read the tool's own description and adapt.
4947
+
4948
+ - **A subagent lives inside your session.** It dies when your session ends: closing the terminal, a crash or the end of a cloud machine stops every worker you launched this way, mid-turn. Use this runtime for short tickets you will see through in one sitting. Long runs, and anything that must survive you, go to Conductor (the \`armada-runtime-conductor\` skill).
4949
+ - **Always in its own worktree.** A subagent launched without \`isolation: "worktree"\` works in your own checkout: it edits your files and switches your branch under you, and two such workers overwrite each other. Never launch one without it.
4950
+ - A worker is one background subagent. Its Armada handle is its name: the ticket id in lowercase (\`abc-12\` for ABC-12), which the brief's claim line already uses. The worker's claim comment carries it, so \`armada status\` and the ticket lead back to the subagent.
4951
+ - **It shares your machine and environment**: your \`gh\` sign-in for its pushes, your installed \`armada\`, and every environment variable of your session. A worker needs no key: the prompt of \`armada brief\` carries a one-time launch token, and its first command exchanges it for a session limited to its ticket, kept in the machine's credentials file next to your own sign-in. Because it inherits your environment, an \`ARMADA_TICKET\` of yours is not its ticket: the brief tells it to pass \`--ticket\` to every command.
4952
+ - Run \`armada watch\` in the background while a worker is in flight, as the coordinator skill says: a worker's question, plan or hand-back reaches your inbox, not your conversation. The task notification Claude Code sends when a subagent stops is a hint to look, not the record.
4953
+
4954
+ ## Launch
4955
+
4956
+ 1. Pick a ready ticket from \`armada status\` that does not collide with work in flight.
4957
+ 2. Run \`armada brief ABC-12\` (with \`--profile <name> --reason "<why>"\` when you override the routed profile), right before the launch. Its \`Runtime:\` line must say \`claude-code\`: the profile has \`runtime = "claude-code"\` in \`armada.toml\`. Read the profile (model), the \`Launch:\` line and the warnings, and resolve every warning first. The profile's effort is not applied by the Agent tool; a worker that needs a set effort goes to Conductor.
4958
+ - \`Launch: one-time token in the prompt\` is the normal case. \`Launch: no launch token (…)\` says why: usually \`armada login\`, then brief again.
4959
+ 3. Read the prompt: \`armada brief ABC-12 --prompt\`. The token in it works once, within the hour: brief again when that hour has passed before the launch. Add what only you know (the boundary with a parallel worker, a decision not yet on the ticket) at the end.
4960
+ 4. Launch with the Agent tool, every value set:
4961
+
4962
+ \`\`\`json
4963
+ {
4964
+ "description": "ABC-12 <short title>",
4965
+ "name": "abc-12",
4966
+ "prompt": "<the whole armada brief --prompt text, then your notes>",
4967
+ "subagent_type": "general-purpose",
4968
+ "model": "<the profile's model, e.g. opus>",
4969
+ "isolation": "worktree",
4970
+ "run_in_background": true
4971
+ }
4972
+ \`\`\`
4973
+
4974
+ - \`isolation: "worktree"\` gives the worker a git worktree of its own under \`.claude/worktrees/\` (for example \`.claude/worktrees/agent-<id>\`), on a new branch (\`worktree-agent-<id>\`) from the default branch; the brief tells the worker to rename it to the ticket's branch. Never leave it out.
4975
+ - \`run_in_background: true\` returns at once, so you keep coordinating. Without it your turn waits for the whole ticket.
4976
+ - \`name\` is the handle in the brief's claim line. When your Agent tool has no \`name\` parameter, the result's \`agentId\` is the only way to reach the worker: record it at once with \`armada answer --note ABC-12 "subagent <agentId>"\`, so the ticket leads back to it after your context is compacted or a new coordinator takes over.
4977
+ - The result gives the \`agentId\` and an \`output_file\`: the worker's transcript (JSONL). Keep both. Never read that file whole: it is the entire conversation (Status section).
4978
+ - \`.claude/worktrees/\` appears as untracked in your own checkout: never commit it (add it to \`.gitignore\`).
4979
+
4980
+ 5. **Check the claim.** Within a few minutes, \`armada status\` lists the ticket in flight, phase \`planning\`, runtime \`Claude Code\`, and the claim comment reads \`session: abc-12\` and \`profile: <name>\`. No claim: read the transcript (Status section). A worker whose launch token was refused needs a new one: brief again and message it only the \`armada login --launch-token …\` line of the new prompt. A worker cut off from Armada was revoked on the dashboard or left idle for three days: ask the owner before you give it a new token.
4981
+
4982
+ ## Message
4983
+
4984
+ \`\`\`json
4985
+ { "to": "abc-12", "summary": "ABC-12 plan approved", "message": "Plan approved. Go on." }
4986
+ \`\`\`
4987
+
4988
+ SendMessage reaches the worker by its name, or by its \`agentId\` when it has none. A worker that is running gets the message at its next tool call; a worker that finished its turn (it handed back, asks a question, or stopped) is resumed from its transcript, in its worktree, and answers in a new turn. Success means the message was delivered, not that the worker acted on it: check its status, then read its reply. Make the first line a sentence that says what the message is. Use it to deliver an answer, a plan approval, or a heads-up that the default branch moved. Then record it in Armada: \`armada answer <item> "<answer>"\` for a question from \`armada inbox\`, \`armada answer --note ABC-12 "<message>"\` for a message the worker did not ask for.
4989
+
4990
+ ## Status
4991
+
4992
+ Is the worker alive, and what did it do last? Three readings, cheapest first:
4993
+
4994
+ - **ListAgents** lists your subagents that are running: \`abc-12 · general-purpose · running · started 4m ago\`. A worker not in the list has finished its turn: it handed back, waits for an answer, or stopped. If \`armada status\` does not show it \`ready-to-merge\`, \`awaiting-approval\` or \`blocked\`, it has stopped without finishing: read its last reply, then message it to go on, or stop it and release the ticket.
4995
+ - **The task notification** Claude Code sends you when a subagent stops: \`status\` is \`completed\` (its turn ended) or \`killed\` (stopped), and \`result\` is its final reply. A worker that stops on an error says so there: read the transcript and message it to resume.
4996
+ - **Its last activity**: the time its transcript was last written, and the last event in it. A \`running\` worker whose transcript has not moved for twice \`policy.silence_minutes\` is stuck: message it, then stop it if it does not answer.
4997
+
4998
+ \`\`\`sh
4999
+ f=<output_file>
5000
+ date -u -r "$f" +%FT%TZ
5001
+ tail -n 1 "$f" | jq -r '[.timestamp, .type, (.message.content[0].type // "")] | join(" ")'
5002
+ \`\`\`
5003
+
5004
+ Its final reply and the commands it ran, without reading the whole file:
5005
+
5006
+ \`\`\`sh
5007
+ tail -n 200 "$f" | jq -r 'select(.type == "assistant") | .message.content[] | select(.type == "text") | .text' | tail -n 40
5008
+ tail -n 200 "$f" | jq -r 'select(.type == "assistant") | .message.content[] | select(.type == "tool_use") | .input.command // .name'
5009
+ \`\`\`
5010
+
5011
+ A filter that prints nothing: count the event types of the last lines, look at one event of the type you need, and adapt.
5012
+
5013
+ \`\`\`sh
5014
+ tail -n 200 "$f" | jq -r '.type' | sort | uniq -c
5015
+ \`\`\`
5016
+
5017
+ ## Stop and archive
5018
+
5019
+ A subagent has no workspace to archive: archiving it means stopping it and removing its worktree.
5020
+
5021
+ 1. Stop a worker that runs the wrong thing, or one you release: TaskStop with its name (or \`agentId\`).
5022
+
5023
+ \`\`\`json
5024
+ { "task_id": "abc-12" }
5025
+ \`\`\`
5026
+
5027
+ The notification that follows says \`killed\` and names the worktree it leaves: \`worktreePath\` and \`worktreeBranch\`. A stopped worker keeps its worktree and its changes; a message would resume it there.
5028
+
5029
+ 2. Record why when it does not hand back: \`armada release --ticket ABC-12 --reason "<why>"\`.
5030
+ 3. Remove its worktree once its pull request is merged, or once you released the ticket and nothing in the worktree is worth keeping. Wait until the worker is no longer running (ListAgents), then, from your own checkout:
5031
+
5032
+ \`\`\`sh
5033
+ git worktree list # find the worker's path and branch
5034
+ git -C .claude/worktrees/<dir> status --short # what would be lost
5035
+ git worktree remove --force .claude/worktrees/<dir>
5036
+ git branch -D <the worker's local branch> # the ticket's branch; the pull request and the remote branch stay on GitHub
5037
+ \`\`\`
5038
+
5039
+ A worktree in which the worker changed nothing is removed by Claude Code when the subagent ends; \`git worktree list\` no longer shows it.
5040
+
5041
+ ## A worker without a worktree
5042
+
5043
+ A subagent launched without \`isolation: "worktree"\` runs in your checkout. The brief's first section makes the worker check \`git rev-parse --show-toplevel\` before anything else and, when it is not under \`.claude/worktrees/\`, call the \`EnterWorktree\` tool with its name to move into a worktree of its own before it touches a file. Claude Code may refuse that from a subagent (it would change the working folder of your whole session); the worker then changes nothing, says so in its reply and ends its turn. Then:
5044
+
5045
+ 1. Check your own checkout: \`git status --short\` and \`git branch --show-current\`. Anything the worker changed there is not yours: move it to a worktree before you go on (\`git stash push -- <its files>\`, then \`git stash pop\` inside the new worker's worktree once it runs), and switch back to your branch if it moved.
5046
+ 2. Stop it (TaskStop), and launch it again under the same name with \`isolation: "worktree"\`. A worker that had already claimed claims again from the same handle, which keeps its claim.
5047
+ `;
5048
+
4641
5049
  // ../../skills/armada-runtime-conductor/SKILL.md
4642
- var SKILL_default2 = "---\nname: armada-runtime-conductor\ndescription: Runtime guide for running Armada workers on Conductor Cloud. Use when an Armada coordinator must launch a worker on a ticket, send it a message, check whether a silent worker is still alive, or stop and archive it. Four fixed sections, each with the exact conductor command and how to read its output.\n---\n\nArmada never calls a runtime. This guide tells the coordinator how to launch, message, check and stop a worker with the `conductor` command line tool, and what to record in Armada afterwards. It was checked against `conductor` 0.89.x (the desktop app's CLI, macOS) and 0.1.x (the CLI inside a Conductor Cloud workspace, Linux); every command below works in both. `conductor --version` prints yours; if a flag is refused, compare with `conductor <command> --help`.\n\n- Always pass `--json` and read fields with `jq`. Exit codes: 0 ok, 1 runtime error, 2 usage error, 3 authentication, 4 server error.\n- On exit code 3, `conductor auth whoami` checks the token the CLI uses (it exits 0 when the token works). Do not rely on `conductor auth status`: it only looks for a macOS Keychain entry and fails on Linux (\"Keychain storage is only supported on macOS\"). In a Conductor Cloud workspace the CLI reads `CONDUCTOR_API_KEY` from the environment and needs no login; on a Mac, `conductor auth login` stores a token in the Keychain.\n- A worker is one workspace with one session. Its Armada handle is `<workspaceId>/<sessionId>`; the worker's claim comment carries it, so `armada status` and the ticket always lead back to the session.\n- A worker needs no key in its workspace: the prompt of `armada brief` carries a one-time launch token, and the worker's first command exchanges it for a session limited to its ticket, through which Armada gives each command its keys. The token works once, within the hour, so a copy left in a transcript is useless once used.\n- Never type a secret value into a command, a file or a message: name the variable and let your shell expand it. The expanded value is still in the `conductor` process's arguments while it runs, so launch from a machine only you use.\n\n## Launch\n\n1. Pick a ready ticket from `armada status` that does not collide with work in flight.\n2. Run `armada brief ABC-12` (with `--profile <name> --reason \"<why>\"` when you override the routed profile), right before the launch. Read the profile (agent, model, effort, fast mode), the `Launch:` line and the warnings. Resolve every warning first: an open blocker, a ticket already in flight.\n - `Launch: one-time token in the prompt` is the normal case: the worker signs in to Armada with it and fetches its own keys. Its workspace receives no key at all.\n - `Launch: no launch token (…)` says why. Not signed in: `armada login` (a headless coordinator sets `ARMADA_API_KEY`), then brief again; `armada doctor` checks the sign-in. Launch with keys (step 4, second block) only on an Armada that keeps no keys yet (no accounts or no vault: a self-hosted one, CI, or before the owner's switch to the Keys page).\n3. Write the prompt to a file only you can read, and add what only you know (the boundary with a parallel worker, a decision not yet on the ticket). The token in it works once, within the hour: brief again when that hour has passed before the launch.\n\n```sh\n(umask 077; armada brief ABC-12 --prompt > /tmp/abc-12-brief.md)\n```\n\n4. Create the workspace with every value from the profile. Never leave the agent, model or effort to Conductor's defaults. Add `--fast-mode` when the profile says fast mode. Run the whole block as one command: shell state does not carry over between separate calls.\n\n```sh\nconductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\nrm -f /tmp/abc-12-brief.md\njq -r '\"\\(.workspaceId)/\\(.sessionId)\"' /tmp/abc-12-launch.json\n```\n\nWithout a launch token (an Armada that keeps no keys), pass the keys the brief's environment table marks `required`, from your shell or from Armada's credentials file (`in credentials file`: the `set -a` line loads it without printing it; drop it when every variable is set in your shell). The subshell keeps the keys out of the rest of your session. Without a launch token the worker is not signed in to Armada: its claims and reports reach Linear only, with a warning. When Conductor's organization environment still holds the keys, every workspace already has them: use the first block.\n\n```sh\n(\n set -a; . \"${XDG_CONFIG_HOME:-$HOME/.config}/armada/credentials\"; set +a\n [ -n \"$LINEAR_API_KEY\" ] || { echo \"LINEAR_API_KEY is missing\" >&2; exit 1; }\n conductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n --env LINEAR_API_KEY=\"$LINEAR_API_KEY\" \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\n)\nrm -f /tmp/abc-12-brief.md\n```\n\n- `--branch` is the base branch (the default branch). Conductor creates a branch named `conductor/<slug of --name>`; the brief tells the worker to rename it to the ticket's branch.\n- The output has `workspaceId`, `sessionId`, `deepLink` and `initialMessage` (`messageId`, `state: \"queued\"`). Keep the handle the `jq` line prints, and give the owner the `deepLink` when they want to watch.\n- Conductor sets `CONDUCTOR_WORKSPACE_ID` and `CONDUCTOR_SESSION_ID` inside the workspace, and signs `gh` in for the worker's pushes. The brief's first commands install your Armada version (`npm install -g`), sign in with the launch token (`armada login --launch-token`) and claim the ticket. `--env` values are not shown back by `workspace get`.\n- Keys in Conductor's organization environment reach every workspace, workers included: once Armada keeps the organization's keys, they belong on Armada's Keys page, not there.\n- An unknown agent, model or effort fails the command. Check the ids with `conductor model` (each agent's models, efforts and defaults) and fix the profile in `armada.toml`.\n\n5. **Check the claim.** Within a few minutes, `armada status` lists the ticket in flight, phase `planning`, runtime `Conductor`, and the ticket's claim comment reads `session: <workspaceId>/<sessionId>` and `profile: <name>`. No claim after ten minutes: read the transcript (Status section). A worker whose launch token was refused (already used, or more than an hour old) needs a new one: `armada brief ABC-12 --prompt` again, and message it only the `armada login --launch-token …` line of the new prompt (Message section). A worker cut off from Armada was revoked on the dashboard (Organization > Workers says by whom) or left idle for three days: ask the owner before you give a revoked worker a new token. If the worker cannot claim for another reason, fix the cause and message it; as a last resort record the handle yourself with `armada claim ABC-12 --runtime conductor --handle <workspaceId>/<sessionId> --profile <name>`, adding the brief's `--reason` for an override.\n\n## Message\n\n```sh\nprintf '%s\\n' \"Plan approved. Go on.\" | conductor --json message create --session <sessionId> --message-file -\nconductor --json message create --session <sessionId> --message-file - < /tmp/abc-12-answer.md\n```\n\nThe output is `{\"messageId\": …, \"state\": \"sent\"}`. Exit code 0 means Conductor accepted the message, not that the worker read it: check that the session turns `working`, then read its reply in the transcript. Use it to deliver an answer, a plan approval, or a heads-up that the default branch moved. Then record it in Armada: `armada answer <item> \"<answer>\"` for a question from `armada inbox`, `armada answer --note ABC-12 \"<message>\"` for a message the worker did not ask for.\n\n## Status\n\n```sh\nconductor --json session status <sessionId>\n```\n\nThe output is `{\"workspaceId\", \"sessionId\", \"status\", \"updatedAt\"}`. For a worker:\n\n- `working`: a turn is running. A silent worker that is `working` is busy (a long build or test run): leave it, and read the transcript if it stays silent past twice `policy.silence_minutes`.\n- `idle`: no turn is running. The worker finished its turn: it handed back, it waits for an answer, or it stopped without finishing. If `armada status` does not show it `ready-to-merge`, `awaiting-approval` or `blocked`, it has stopped: read its last reply, then message it to go on, or release and relaunch the ticket.\n- `error`: the last turn failed (agent or provider failure). Read the transcript and message it to resume; if it fails again, cancel, archive, release and relaunch.\n- Right after launch the session is `idle` for a few seconds while the workspace is initializing and the first message is queued; it turns `working` when the agent starts.\n\nThe workspace itself: `conductor --json workspace status <workspaceId>` gives `status` `initializing`, `ready` or `archived`.\n\n**Read the transcript** to see what a worker did or said. Events come oldest first, 100 per page; `hasMore` tells when to fetch the next page with `--after` the last event id. Keep the last id you read and poll from it.\n\n```sh\nconductor --json session message <sessionId> --limit 100 > /tmp/abc-12-events.json\njq -r '.hasMore, .data[-1].id' /tmp/abc-12-events.json\nconductor --json session message <sessionId> --after <lastEventId> --limit 100\n```\n\nThe second line prints whether more pages exist and the id to continue from. `.content.rawPayload` is the agent's own event format, so the filters depend on the worker's agent (the `agent` of its profile in `armada.toml`).\n\nA `claude` worker: each turn's final reply, then the commands and tools it ran.\n\n```sh\njq -r '.data[] | select(.content.rawPayload.type == \"result\") | .content.rawPayload | \"error=\\(.is_error)\\n\\(.result)\"' /tmp/abc-12-events.json\njq -r '.data[] | select(.content.rawPayload.type == \"assistant\") | .content.rawPayload.message.content[] | select(.type == \"tool_use\") | .input.command // .name' /tmp/abc-12-events.json\n```\n\nA `codex` worker: its events are `.content.rawPayload.event`, each item once as `item.started` and once as `item.completed`; read the completed ones. Its messages (`phase` is `commentary` along the way, `final_answer` at the end of a turn), then each command with its exit code, and its tool calls (Linear and other MCP servers).\n\n```sh\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"agentMessage\") | \"[\\(.phase)] \\(.text)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"commandExecution\") | \"exit=\\(.exitCode) \\(.command)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"mcpToolCall\") | \"\\(.server) \\(.tool)\"' /tmp/abc-12-events.json\n```\n\nAnother agent, or a filter that prints nothing: count the event types, look at one event of the type you need, and adapt the filter.\n\n```sh\njq -r '.data[].content.rawPayload | .type // .event.type // \"(no payload)\"' /tmp/abc-12-events.json | sort | uniq -c\n```\n\n## Stop and archive\n\n```sh\nconductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n\n- `session cancel` stops the running turn: `{\"status\", \"canceledQueuedMessages\"}`, and the session is `idle` within seconds. The workspace stays; a message starts a new turn. Use it on a worker that runs the wrong thing.\n- `workspace archive` answers `{\"status\": \"archived\"}`. Archive a worker's workspace after its pull request is merged, or after `armada release --ticket ABC-12 --reason \"<why>\"` for a worker that stops without handing back. The branch and the pull request stay on GitHub.\n- **Wait for `idle` before archiving.** A hand-back often arrives while the worker's session is still `working`: `armada report ready-to-merge` runs inside its last turn, which then writes its final reply. Archive only once `session status` answers `idle`. Poll it every 15 seconds; if it is still `working` after 10 minutes, cancel the turn and archive (the transcript keeps what it was doing). Run the whole block as one command; it can take up to 10 minutes, so run it in the background or give it a longer command timeout:\n\n```sh\nfor i in $(seq 40); do\n [ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] || break\n sleep 15\ndone\n[ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] && conductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n- After an archive, `session status` still answers `idle`; `workspace status` says `archived`.\n";
5050
+ var SKILL_default3 = "---\nname: armada-runtime-conductor\ndescription: Runtime guide for running Armada workers on Conductor Cloud. Use when an Armada coordinator must launch a worker on a ticket, send it a message, check whether a silent worker is still alive, or stop and archive it. Four fixed sections, each with the exact conductor command and how to read its output.\n---\n\nArmada never calls a runtime. This guide tells the coordinator how to launch, message, check and stop a worker with the `conductor` command line tool, and what to record in Armada afterwards. It was checked against `conductor` 0.89.x (the desktop app's CLI, macOS) and 0.1.x (the CLI inside a Conductor Cloud workspace, Linux); every command below works in both. `conductor --version` prints yours; if a flag is refused, compare with `conductor <command> --help`.\n\n- On a Mac, the app ships the CLI at `/Applications/Conductor.app/Contents/Resources/bin/conductor`, which is not on PATH. `armada doctor` looks for it and prints the fix: a link from a directory already on PATH (`ln -s \"/Applications/Conductor.app/Contents/Resources/bin/conductor\" ~/.local/bin/conductor`), or a PATH line for your shell profile.\n- Always pass `--json` and read fields with `jq`. Exit codes: 0 ok, 1 runtime error, 2 usage error, 3 authentication, 4 server error.\n- On exit code 3, `conductor auth whoami` checks the token the CLI uses (it exits 0 when the token works). Do not rely on `conductor auth status`: it only looks for a macOS Keychain entry and fails on Linux (\"Keychain storage is only supported on macOS\"). In a Conductor Cloud workspace the CLI reads `CONDUCTOR_API_KEY` from the environment and needs no login; on a Mac, `conductor auth login` stores a token in the Keychain.\n- A worker is one workspace with one session. Its Armada handle is `<workspaceId>/<sessionId>`; the worker's claim comment carries it, so `armada status` and the ticket always lead back to the session.\n- A worker needs no key in its workspace: the prompt of `armada brief` carries a one-time launch token, and the worker's first command exchanges it for a session limited to its ticket, through which Armada gives each command its keys. The token works once, within the hour, so a copy left in a transcript is useless once used.\n- Never type a secret value into a command, a file or a message: name the variable and let your shell expand it. The expanded value is still in the `conductor` process's arguments while it runs, so launch from a machine only you use.\n\n## Launch\n\n1. Pick a ready ticket from `armada status` that does not collide with work in flight.\n2. Run `armada brief ABC-12` (with `--profile <name> --reason \"<why>\"` when you override the routed profile), right before the launch. Read the profile (agent, model, effort, fast mode), the `Launch:` line and the warnings. Resolve every warning first: an open blocker, a ticket already in flight.\n - `Launch: one-time token in the prompt` is the normal case: the worker signs in to Armada with it and fetches its own keys. Its workspace receives no key at all. This view and `--json` show the token as `armada_launch_••••`; only `--prompt` prints it.\n - `Launch: no launch token (…)` says why. Not signed in: `armada login` (a headless coordinator sets `ARMADA_API_KEY`), then brief again; `armada doctor` checks the sign-in. Launch with keys (step 4, second block) only on an Armada that keeps no keys yet (no accounts or no vault: a self-hosted one, CI, or before the owner's switch to the Keys page).\n3. Write the prompt to a file only you can read, and add what only you know (the boundary with a parallel worker, a decision not yet on the ticket). The token in it works once, within the hour: brief again when that hour has passed before the launch.\n\n```sh\n(umask 077; armada brief ABC-12 --prompt > /tmp/abc-12-brief.md)\n```\n\n4. Create the workspace with every value from the profile. Never leave the agent, model or effort to Conductor's defaults. Add `--fast-mode` when the profile says fast mode. Run the whole block as one command: shell state does not carry over between separate calls.\n\n```sh\nconductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\nrm -f /tmp/abc-12-brief.md\njq -r '\"\\(.workspaceId)/\\(.sessionId)\"' /tmp/abc-12-launch.json\n```\n\nWithout a launch token (an Armada that keeps no keys), pass the keys the brief's environment table marks `required`, from your shell or from Armada's credentials file (`in credentials file`: the `set -a` line loads it without printing it; drop it when every variable is set in your shell). The subshell keeps the keys out of the rest of your session. Without a launch token the worker is not signed in to Armada: its claims and reports reach Linear only, with a warning. When Conductor's organization environment still holds the keys, every workspace already has them: use the first block.\n\n```sh\n(\n set -a; . \"${XDG_CONFIG_HOME:-$HOME/.config}/armada/credentials\"; set +a\n [ -n \"$LINEAR_API_KEY\" ] || { echo \"LINEAR_API_KEY is missing\" >&2; exit 1; }\n conductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n --env LINEAR_API_KEY=\"$LINEAR_API_KEY\" \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\n)\nrm -f /tmp/abc-12-brief.md\n```\n\n- `--branch` is the base branch (the default branch). Conductor creates a branch named `conductor/<slug of --name>`; the brief tells the worker to rename it to the ticket's branch.\n- The output has `workspaceId`, `sessionId`, `deepLink` and `initialMessage` (`messageId`, `state: \"queued\"`). Keep the handle the `jq` line prints, and give the owner the `deepLink` when they want to watch.\n- Conductor sets `CONDUCTOR_WORKSPACE_ID` and `CONDUCTOR_SESSION_ID` inside the workspace, and signs `gh` in for the worker's pushes. The brief's first commands install your Armada version (`npm install -g`), sign in with the launch token (`armada login --launch-token`) and claim the ticket. `--env` values are not shown back by `workspace get`.\n- Keys in Conductor's organization environment reach every workspace, workers included: once Armada keeps the organization's keys, they belong on Armada's Keys page, not there.\n- An unknown agent, model or effort fails the command. Check the ids with `conductor model` (each agent's models, efforts and defaults) and fix the profile in `armada.toml`.\n\n5. **Check the claim.** Within a few minutes, `armada status` lists the ticket in flight, phase `planning`, runtime `Conductor`, and the ticket's claim comment reads `session: <workspaceId>/<sessionId>` and `profile: <name>`. No claim after ten minutes: read the transcript (Status section). A worker whose launch token was refused (already used, or more than an hour old) needs a new one: `armada brief ABC-12 --prompt` again, and message it only the `armada login --launch-token …` line of the new prompt (Message section). A worker cut off from Armada was revoked on the dashboard (Organization > Workers says by whom) or left idle for three days: ask the owner before you give a revoked worker a new token. If the worker cannot claim for another reason, fix the cause and message it; as a last resort record the handle yourself with `armada claim ABC-12 --runtime conductor --handle <workspaceId>/<sessionId> --profile <name>`, adding the brief's `--reason` for an override.\n\n## Message\n\n```sh\nprintf '%s\\n' \"Plan approved. Go on.\" | conductor --json message create --session <sessionId> --message-file -\nconductor --json message create --session <sessionId> --message-file - < /tmp/abc-12-answer.md\n```\n\nThe output is `{\"messageId\": …, \"state\": \"sent\"}`. Exit code 0 means Conductor accepted the message, not that the worker read it: check that the session turns `working`, then read its reply in the transcript. Use it to deliver an answer, a plan approval, or a heads-up that the default branch moved. Then record it in Armada: `armada answer <item> \"<answer>\"` for a question from `armada inbox`, `armada answer --note ABC-12 \"<message>\"` for a message the worker did not ask for.\n\n## Status\n\n```sh\nconductor --json session status <sessionId>\n```\n\nThe output is `{\"workspaceId\", \"sessionId\", \"status\", \"updatedAt\"}`. For a worker:\n\n- `working`: a turn is running. A silent worker that is `working` is busy (a long build or test run): leave it, and read the transcript if it stays silent past twice `policy.silence_minutes`.\n- `idle`: no turn is running. The worker finished its turn: it handed back, it waits for an answer, or it stopped without finishing. If `armada status` does not show it `ready-to-merge`, `awaiting-approval` or `blocked`, it has stopped: read its last reply, then message it to go on, or release and relaunch the ticket.\n- `error`: the last turn failed (agent or provider failure). Read the transcript and message it to resume; if it fails again, cancel, archive, release and relaunch.\n- Right after launch the session is `idle` for a few seconds while the workspace is initializing and the first message is queued; it turns `working` when the agent starts.\n\nThe workspace itself: `conductor --json workspace status <workspaceId>` gives `status` `initializing`, `ready` or `archived`.\n\n**Read the transcript** to see what a worker did or said. Events come oldest first, 100 per page; `hasMore` tells when to fetch the next page with `--after` the last event id. Keep the last id you read and poll from it.\n\n```sh\nconductor --json session message <sessionId> --limit 100 > /tmp/abc-12-events.json\njq -r '.hasMore, .data[-1].id' /tmp/abc-12-events.json\nconductor --json session message <sessionId> --after <lastEventId> --limit 100\n```\n\nThe second line prints whether more pages exist and the id to continue from. `.content.rawPayload` is the agent's own event format, so the filters depend on the worker's agent (the `agent` of its profile in `armada.toml`).\n\nA `claude` worker: each turn's final reply, then the commands and tools it ran.\n\n```sh\njq -r '.data[] | select(.content.rawPayload.type == \"result\") | .content.rawPayload | \"error=\\(.is_error)\\n\\(.result)\"' /tmp/abc-12-events.json\njq -r '.data[] | select(.content.rawPayload.type == \"assistant\") | .content.rawPayload.message.content[] | select(.type == \"tool_use\") | .input.command // .name' /tmp/abc-12-events.json\n```\n\nA `codex` worker: its events are `.content.rawPayload.event`, each item once as `item.started` and once as `item.completed`; read the completed ones. Its messages (`phase` is `commentary` along the way, `final_answer` at the end of a turn), then each command with its exit code, and its tool calls (Linear and other MCP servers).\n\n```sh\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"agentMessage\") | \"[\\(.phase)] \\(.text)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"commandExecution\") | \"exit=\\(.exitCode) \\(.command)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"mcpToolCall\") | \"\\(.server) \\(.tool)\"' /tmp/abc-12-events.json\n```\n\nAnother agent, or a filter that prints nothing: count the event types, look at one event of the type you need, and adapt the filter.\n\n```sh\njq -r '.data[].content.rawPayload | .type // .event.type // \"(no payload)\"' /tmp/abc-12-events.json | sort | uniq -c\n```\n\n## Stop and archive\n\n```sh\nconductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n\n- `session cancel` stops the running turn: `{\"status\", \"canceledQueuedMessages\"}`, and the session is `idle` within seconds. The workspace stays; a message starts a new turn. Use it on a worker that runs the wrong thing.\n- `workspace archive` answers `{\"status\": \"archived\"}`. Archive a worker's workspace after its pull request is merged, or after `armada release --ticket ABC-12 --reason \"<why>\"` for a worker that stops without handing back. The branch and the pull request stay on GitHub.\n- **Wait for `idle` before archiving.** A hand-back often arrives while the worker's session is still `working`: `armada report ready-to-merge` runs inside its last turn, which then writes its final reply. Archive only once `session status` answers `idle`. Poll it every 15 seconds; if it is still `working` after 10 minutes, cancel the turn and archive (the transcript keeps what it was doing). Run the whole block as one command; it can take up to 10 minutes, so run it in the background or give it a longer command timeout:\n\n```sh\nfor i in $(seq 40); do\n [ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] || break\n sleep 15\ndone\n[ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] && conductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n- After an archive, `session status` still answers `idle`; `workspace status` says `archived`.\n";
4643
5051
 
4644
5052
  // ../../skills/armada-worker/SKILL.md
4645
- var SKILL_default3 = `---
5053
+ var SKILL_default4 = `---
4646
5054
  name: armada-worker
4647
5055
  description: Working one ticket as an Armada worker agent. Use when you were launched on a ticket by an Armada coordinator, or asked to claim, plan, implement and ship one ticket of a project that has an armada.toml. Covers the claim, the phase reports every 15 minutes, questions to the coordinator, the green pull request and the hand-back. A worker never merges.
4648
5056
  ---
@@ -4665,7 +5073,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
4665
5073
  3. **Plan.** Write the plan: what changes, how it is tested, and the checks a person could observe when it is done. Your brief's "Plan" section says in one line whether it needs approval (from \`[policy] plans\` in \`armada.toml\`, or a label on the ticket); follow that line, do not guess. Pre-approved: post the plan with \`armada report implementing --plan-file -\` (or \`--plan-file <path>\`) and go on; do not enter \`awaiting-approval\`. Otherwise post it with \`armada report awaiting-approval --plan-file -\`: it creates a \`plan\` item in the coordinator's inbox. \`--plan-file\` posts the plan as its own block, under a one-line status (\`--message\` sets that line, else the plan's first line). Push your branch and wait for the coordinator's decision in your session. On approval, report \`implementing\`; on amendments, report \`planning\`, revise the plan and submit it for approval again.
4666
5074
  4. **Implement** test-first. A material change to the approved plan needs a new approval.
4667
5075
  5. **Ship.** \`armada report shipping --pr <number>\`. Use the \`ship-pr-dev\` skill when the repository has it; otherwise run the repository's local checks, open the pull request with a Commitizen title (\`feat(scope): …\`), link it on the ticket, and fix CI until every required check is green.
4668
- 6. **Rebase** on the latest default branch right before hand-back, and get CI green on that final head.
5076
+ 6. **Bring the default branch in** right before hand-back (rebase, or merge it into your branch; squash merges make both fine), and get CI green on that final head. Never force-push a branch someone else pushed to.
4669
5077
  7. **Hand back.** \`armada report ready-to-merge --pr <number> --sha <full 40-character head SHA>\`. Armada refuses a short SHA, a SHA that is not the pull request head, or a red check. Then report to the coordinator: pull request URL, full SHA, CI state, the decisions you made, and what the next tickets need to know.
4670
5078
 
4671
5079
  If you stop without finishing, run \`armada release --reason "<why>"\` so the ticket is free again.
@@ -4685,8 +5093,9 @@ var BUNDLED_SKILLS = [
4685
5093
  { path: "SKILL.md", content: SKILL_default }
4686
5094
  ]
4687
5095
  },
4688
- { name: "armada-runtime-conductor", files: [{ path: "SKILL.md", content: SKILL_default2 }] },
4689
- { name: "armada-worker", files: [{ path: "SKILL.md", content: SKILL_default3 }] }
5096
+ { name: "armada-runtime-claude-code", files: [{ path: "SKILL.md", content: SKILL_default2 }] },
5097
+ { name: "armada-runtime-conductor", files: [{ path: "SKILL.md", content: SKILL_default3 }] },
5098
+ { name: "armada-worker", files: [{ path: "SKILL.md", content: SKILL_default4 }] }
4690
5099
  ];
4691
5100
  function skillFolderHash(files) {
4692
5101
  const hash = createHash("sha256");
@@ -5115,7 +5524,10 @@ async function loadStatus(config, opts) {
5115
5524
  });
5116
5525
  }
5117
5526
  // package.json
5118
- var version = "0.2.4";
5527
+ var version = "0.2.6";
5528
+
5529
+ // src/api.ts
5530
+ var apiOf = (io, url, cliVersion = version) => armadaApi({ url, version: cliVersion, ...io.fetch ? { fetch: io.fetch } : {} });
5119
5531
 
5120
5532
  // src/io.ts
5121
5533
  class UsageError extends Error {
@@ -5145,12 +5557,14 @@ async function fromArmada(io, credentials, purpose) {
5145
5557
  return null;
5146
5558
  let answer;
5147
5559
  try {
5148
- answer = await armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} }).credentials(signIn, purpose);
5560
+ answer = await apiOf(io, credentials.armadaApi.url).credentials(signIn, purpose);
5149
5561
  } catch (err) {
5150
5562
  if (!(err instanceof ArmadaApiError))
5151
5563
  throw err;
5152
5564
  if ((err.signedOut || err.status === 403) && signIn.kind === "worker")
5153
5565
  throw err;
5566
+ if (err.upgrade)
5567
+ throw err;
5154
5568
  if (err.status === 503)
5155
5569
  return null;
5156
5570
  io.stderr(`! Armada gave no keys (${err.message}); using this machine's${err.next ? `. Next: ${err.next}` : ""}
@@ -5376,7 +5790,6 @@ var hostOf = (url) => {
5376
5790
  }
5377
5791
  };
5378
5792
  var RETIRED = Object.fromEntries(RETIRED_VARIABLES.map((v) => [v, null]));
5379
- var apiOf = (io, url) => armadaApi({ url, ...io.fetch ? { fetch: io.fetch } : {} });
5380
5793
  var storedAt = (machine) => armadaAddress(machine.store?.values[SIGNED_IN_TO_VARIABLE]?.trim() || DEFAULT_ARMADA_API_URL);
5381
5794
  var sleepOf = (io) => io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
5382
5795
  function requireSignIn(credentials) {
@@ -5569,7 +5982,7 @@ function liveFleet(io, config, credentials) {
5569
5982
  warning: "not signed in to Armada (armada login); live activity is not recorded, Linear is"
5570
5983
  };
5571
5984
  try {
5572
- const api = armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} });
5985
+ const api = apiOf(io, credentials.armadaApi.url);
5573
5986
  return { fleet: fleetClient({ api, signIn, project: projectOf(config) }), warning: null };
5574
5987
  } catch (err) {
5575
5988
  return {
@@ -5731,7 +6144,7 @@ async function endWorkerSessions(io, config, credentials, ticket, reason, quiet)
5731
6144
  const signIn = credentials.armadaSignIn;
5732
6145
  if (!signIn)
5733
6146
  return;
5734
- const api = armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} });
6147
+ const api = apiOf(io, credentials.armadaApi.url);
5735
6148
  try {
5736
6149
  if (signIn.kind === "worker") {
5737
6150
  const paths = machinePaths(io.env);
@@ -5983,6 +6396,14 @@ async function hookStop(io, rest, findConfig) {
5983
6396
  }
5984
6397
 
5985
6398
  // src/brief.ts
6399
+ var HIDDEN_LAUNCH_TOKEN = "armada_launch_••••";
6400
+ function hideLaunchToken(b) {
6401
+ if (!b.launch)
6402
+ return b;
6403
+ const token = b.launch.command.match(/--launch-token[ =](\S+)/)?.[1];
6404
+ const hide = (text) => (token ? text.replaceAll(token, HIDDEN_LAUNCH_TOKEN) : text).replace(/armada_launch_[^\s'"`•]+/g, HIDDEN_LAUNCH_TOKEN);
6405
+ return { ...b, prompt: hide(b.prompt), launch: { ...b.launch, command: hide(b.launch.command) } };
6406
+ }
5986
6407
  function renderBrief(b) {
5987
6408
  const p = b.profile;
5988
6409
  const width = Math.max(...b.environment.map((v) => v.name.length + (v.value ? v.value.length + 1 : 0)));
@@ -5990,14 +6411,15 @@ function renderBrief(b) {
5990
6411
  `Brief for ${b.ticket.id} — ${b.ticket.title} (${b.ticket.status})`,
5991
6412
  b.ticket.url,
5992
6413
  "",
5993
- `Runtime: conductor (follow the armada-runtime-conductor skill to launch)`,
5994
- `Profile: ${p ? `${p.name}: agent ${p.agent}, model ${p.model}, effort ${p.effort}${p.fastMode ? ", fast mode" : ""}` : "none declared in armada.toml"}`,
6414
+ `Runtime: ${b.runtime} (follow the armada-runtime-${b.runtime} skill to launch)`,
6415
+ `Profile: ${p ? `${p.name}: agent ${p.agent}, model ${p.model}, effort ${p.effort}${b.runtime === "claude-code" ? " (not applied by the Agent tool)" : ""}${p.fastMode ? ", fast mode" : ""}` : "none declared in armada.toml"}`,
5995
6416
  ...b.routing ? [`Chosen by: ${b.routing.why}`] : [],
5996
6417
  `Plans: ${b.plans.rule === "pre-approved" ? "pre-approved" : "wait for approval"} (${b.plans.why})`,
5997
6418
  ...b.conventions ? [`Conventions: ${b.conventions.path} (under "Project conventions" in the prompt)`] : [],
5998
6419
  `Repository: ${b.repository.url}`,
5999
6420
  `Branch: ${b.ticket.branch ?? "none suggested by Linear"} (the worker renames its workspace branch to it)`,
6000
- `Launch: ${b.launch ? `one-time token in the prompt, valid until ${b.launch.expiresAt.slice(0, 16).replace("T", " ")} UTC: the worker needs no key` : `no launch token${b.noLaunch ? ` (${b.noLaunch})` : ""}: pass the keys below in the worker's environment`}`,
6421
+ `Launch: ${b.launch ? `one-time token in the prompt, valid until ${b.launch.expiresAt.slice(0, 16).replace("T", " ")} UTC: the worker needs no key
6422
+ (shown as ${HIDDEN_LAUNCH_TOKEN} here; \`armada brief ${b.ticket.id} --prompt\` prints it)` : `no launch token${b.noLaunch ? ` (${b.noLaunch})` : ""}: pass the keys below in the worker's environment`}`,
6001
6423
  "",
6002
6424
  "Environment to pass (values are never printed):",
6003
6425
  ...b.environment.map((v) => {
@@ -6022,7 +6444,7 @@ function launcher(io, config, credentials) {
6022
6444
  };
6023
6445
  const url = credentials.armadaApi.url;
6024
6446
  try {
6025
- const t = await armadaApi({ url, ...io.fetch ? { fetch: io.fetch } : {} }).launchToken(signIn, {
6447
+ const t = await apiOf(io, url).launchToken(signIn, {
6026
6448
  project: config.project.slug,
6027
6449
  ticket
6028
6450
  });
@@ -6091,11 +6513,12 @@ async function brief2(io, config, credentials, a, version, configPath) {
6091
6513
  return 0;
6092
6514
  }
6093
6515
  const next = await rearmFor(io, project, { inFlight, open: null });
6516
+ const shown = hideLaunchToken(b);
6094
6517
  if (a.json)
6095
- io.stdout(`${JSON.stringify({ ...b, watch: next }, null, 2)}
6518
+ io.stdout(`${JSON.stringify({ ...shown, watch: next }, null, 2)}
6096
6519
  `);
6097
6520
  else
6098
- io.stdout(`${renderBrief(b)}
6521
+ io.stdout(`${renderBrief(shown)}
6099
6522
 
6100
6523
  ----- once launched -----
6101
6524
  ${next.line}
@@ -6195,7 +6618,7 @@ async function gitRoot(exec, cwd) {
6195
6618
 
6196
6619
  // src/doctor.ts
6197
6620
  var SIGN_IN_FIX = `\`armada login\`; a headless coordinator sets ${API_KEY_VARIABLE} to an organization API key`;
6198
- async function signInChecks(io, credentials) {
6621
+ async function signInChecks(credentials, api) {
6199
6622
  const host = hostOf(credentials.armadaApi.url);
6200
6623
  const signIn = credentials.armadaSignIn;
6201
6624
  const warning = (message, fix) => [{ id: "sign-in", level: "warning", message, fix }];
@@ -6208,10 +6631,7 @@ The worker session${credentials.workerTickets.length === 1 ? "" : "s"} of ${cred
6208
6631
  return warning(`not signed in to Armada (${host}): \`armada brief\` gives workers no launch token, so each worker needs the fleet's keys in its environment${workers}`, SIGN_IN_FIX);
6209
6632
  }
6210
6633
  try {
6211
- const identity = await armadaApi({
6212
- url: credentials.armadaApi.url,
6213
- ...io.fetch ? { fetch: io.fetch } : {}
6214
- }).whoami(signIn);
6634
+ const identity = await api.whoami(signIn);
6215
6635
  if (!identity.organization)
6216
6636
  return warning(`signed in to ${host} as ${describeIdentity(identity)}: launch tokens need an organization`, `create or join an organization on ${credentials.armadaApi.url}`);
6217
6637
  return [
@@ -6220,6 +6640,8 @@ The worker session${credentials.workerTickets.length === 1 ? "" : "s"} of ${cred
6220
6640
  } catch (err) {
6221
6641
  if (!(err instanceof ArmadaApiError))
6222
6642
  throw err;
6643
+ if (err.upgrade)
6644
+ throw err;
6223
6645
  if (err.signedOut)
6224
6646
  return warning(`the Armada sign-in of this terminal no longer works: ${err.message}`, signIn.kind === "api-key" && signIn.source.kind === "env" ? `replace ${API_KEY_VARIABLE} with a valid organization API key` : SIGN_IN_FIX);
6225
6647
  return warning(`Armada sign-in not checked: ${err.message}`, err.next ?? "run doctor again once Armada answers");
@@ -6253,18 +6675,21 @@ function keyFileChecks(machine, credentials) {
6253
6675
  }
6254
6676
  ];
6255
6677
  }
6256
- async function labelChecks(io, root, credentials) {
6678
+ async function projectConfig(root) {
6257
6679
  const text = await fsRepoView(root).readFile(CONFIG_FILE);
6258
6680
  if (text === null)
6259
- return [];
6260
- let config;
6681
+ return null;
6261
6682
  try {
6262
- config = parseConfig(text, CONFIG_FILE);
6683
+ return parseConfig(text, CONFIG_FILE);
6263
6684
  } catch (err) {
6264
6685
  if (err instanceof ConfigError)
6265
- return [];
6686
+ return null;
6266
6687
  throw err;
6267
6688
  }
6689
+ }
6690
+ async function labelChecks(io, config, credentials) {
6691
+ if (!config)
6692
+ return [];
6268
6693
  const { linearApiKey } = credentials;
6269
6694
  if (!linearApiKey)
6270
6695
  return [
@@ -6289,14 +6714,104 @@ async function labelChecks(io, root, credentials) {
6289
6714
  ];
6290
6715
  }
6291
6716
  }
6717
+ function versionChecks(host, api, armadaVersion, outdated) {
6718
+ if (outdated?.upgrade)
6719
+ return [
6720
+ {
6721
+ id: "cli-version",
6722
+ level: "error",
6723
+ message: `Armada ${armadaVersion} is older than ${host} expects: it no longer reads its answers`,
6724
+ fix: installCommand(outdated.upgrade)
6725
+ }
6726
+ ];
6727
+ const server = api.serverCli();
6728
+ if (!server)
6729
+ return [];
6730
+ const newer = server.latest && compareVersions(server.latest, armadaVersion) > 0 ? server.latest : null;
6731
+ return [
6732
+ {
6733
+ id: "cli-version",
6734
+ level: "ok",
6735
+ message: `Armada ${armadaVersion} is recent enough for ${host} (${server.minimum} or newer)${newer ? `; ${newer} is out: ${installCommand(newer)}` : ""}`,
6736
+ fix: null
6737
+ }
6738
+ ];
6739
+ }
6740
+ var BUNDLED_CONDUCTOR = "/Applications/Conductor.app/Contents/Resources/bin/conductor";
6741
+ async function versionOf(io, command) {
6742
+ if (!io.exec)
6743
+ return null;
6744
+ try {
6745
+ const r = await io.exec(command, ["--version"], { cwd: io.cwd });
6746
+ return r.code === 0 ? r.stdout.trim().split(`
6747
+ `)[0] ?? "" : "";
6748
+ } catch {
6749
+ return null;
6750
+ }
6751
+ }
6752
+ async function conductorChecks(io, config) {
6753
+ if (!io.exec || !Object.values(config?.conductor.profiles ?? {}).some((p) => p.runtime === "conductor"))
6754
+ return [];
6755
+ const onPath = await versionOf(io, "conductor");
6756
+ if (onPath !== null)
6757
+ return [
6758
+ { id: "conductor-cli", level: "ok", message: `conductor ${onPath ? `${onPath} ` : ""}is on PATH`, fix: null }
6759
+ ];
6760
+ const home = io.env.HOME?.replace(/\/+$/, "");
6761
+ const path = (io.env.PATH ?? "").split(":").map((d) => d.replace(/\/+$/, ""));
6762
+ const userBin = home ? [".local/bin", "bin"].find((d) => path.includes(`${home}/${d}`)) : undefined;
6763
+ const link = (dir) => `ln -s "${BUNDLED_CONDUCTOR}" ${dir}/conductor`;
6764
+ const pathLine = `export PATH="${BUNDLED_CONDUCTOR.slice(0, -"/conductor".length)}:$PATH"`;
6765
+ const fix = userBin ? link(`~/${userBin}`) : `add \`${pathLine}\` to your shell profile (~/.zshrc), or \`sudo ${link("/usr/local/bin")}\``;
6766
+ if (await versionOf(io, BUNDLED_CONDUCTOR) !== null)
6767
+ return [
6768
+ {
6769
+ id: "conductor-cli",
6770
+ level: "warning",
6771
+ message: `conductor is not on PATH; the Conductor app ships it at ${BUNDLED_CONDUCTOR}`,
6772
+ fix
6773
+ }
6774
+ ];
6775
+ return [
6776
+ {
6777
+ id: "conductor-cli",
6778
+ level: "warning",
6779
+ message: `conductor is not on PATH, nor at ${BUNDLED_CONDUCTOR}: the armada-runtime-conductor guide launches workers with it`,
6780
+ fix: "on a Mac, install the Conductor app, then run doctor again; elsewhere, put a conductor command on PATH (a Conductor workspace has one)"
6781
+ }
6782
+ ];
6783
+ }
6292
6784
  async function buildDoctor(io, armadaVersion) {
6293
6785
  const root = (io.exec ? await gitRoot(io.exec, io.cwd) : null) ?? io.cwd;
6294
- const { machine, credentials } = await loadCredentials(io);
6786
+ const upgrade = (err) => err instanceof ArmadaApiError && err.upgrade ? err : null;
6787
+ let outdated = null;
6788
+ let loaded;
6789
+ try {
6790
+ loaded = await loadCredentials(io);
6791
+ } catch (err) {
6792
+ outdated = upgrade(err);
6793
+ if (!outdated)
6794
+ throw err;
6795
+ loaded = await loadCredentials(io, { armada: false });
6796
+ }
6797
+ const { machine, credentials } = loaded;
6798
+ const api = apiOf(io, credentials.armadaApi.url, armadaVersion);
6799
+ const config = await projectConfig(root);
6800
+ let signIn = [];
6801
+ try {
6802
+ signIn = await signInChecks(credentials, api);
6803
+ } catch (err) {
6804
+ outdated = upgrade(err);
6805
+ if (!outdated)
6806
+ throw err;
6807
+ }
6295
6808
  const checks = [
6296
6809
  ...await checkRepository(fsRepoView(root), armadaVersion),
6297
- ...await signInChecks(io, credentials),
6810
+ ...signIn,
6811
+ ...versionChecks(hostOf(credentials.armadaApi.url), api, armadaVersion, outdated),
6298
6812
  ...keyFileChecks(machine, credentials),
6299
- ...await labelChecks(io, root, credentials)
6813
+ ...await labelChecks(io, config, credentials),
6814
+ ...await conductorChecks(io, config)
6300
6815
  ];
6301
6816
  return {
6302
6817
  schemaVersion: 1,
@@ -6307,7 +6822,7 @@ async function buildDoctor(io, armadaVersion) {
6307
6822
  warnings: checks.filter((c) => c.level === "warning").length
6308
6823
  };
6309
6824
  }
6310
- var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
6825
+ var plural2 = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
6311
6826
  function renderDoctor(r) {
6312
6827
  const lines = [`Armada ${r.armadaVersion} doctor · ${r.root}`, ""];
6313
6828
  for (const c of r.checks) {
@@ -6323,7 +6838,7 @@ function renderDoctor(r) {
6323
6838
  if (!r.errors && !r.warnings)
6324
6839
  lines.push("Everything Armada needs is in place.");
6325
6840
  else
6326
- lines.push(`${plural(r.errors, "error")}, ${plural(r.warnings, "warning")}.${r.errors ? " Workers cannot be launched until the errors are fixed." : ""}`);
6841
+ lines.push(`${plural2(r.errors, "error")}, ${plural2(r.warnings, "warning")}.${r.errors ? " Workers cannot be launched until the errors are fixed." : ""}`);
6327
6842
  const errors = r.checks.filter((c) => c.level === "error");
6328
6843
  if (errors.length)
6329
6844
  lines.push(errors.some((c) => c.fix?.includes("armada init")) ? "Next: armada init, which opens one pull request with the fixes it can make" : `Next: ${errors[0]?.fix}`);
@@ -6425,6 +6940,7 @@ function prText(plan, version) {
6425
6940
  return { title, body: lines.join(`
6426
6941
  `) };
6427
6942
  }
6943
+ var mergeHint = (n) => `No ticket owns it: merge it with armada merge ${n} --no-ticket --wait, which waits for its checks`;
6428
6944
  async function init(io, opts) {
6429
6945
  const exec = requireExec(io);
6430
6946
  const first = (await loadCredentials(io)).credentials;
@@ -6504,6 +7020,7 @@ async function init(io, opts) {
6504
7020
  body
6505
7021
  ]);
6506
7022
  log(`Updated pull request ${existing.url}`);
7023
+ log(mergeHint(existing.number));
6507
7024
  } else {
6508
7025
  const url = await sh(exec, root, "gh", [
6509
7026
  "pr",
@@ -6519,8 +7036,12 @@ async function init(io, opts) {
6519
7036
  "--body",
6520
7037
  body
6521
7038
  ]);
6522
- log(`Opened pull request ${url.split(`
6523
- `).pop()}`);
7039
+ const opened = url.split(`
7040
+ `).pop() ?? "";
7041
+ log(`Opened pull request ${opened}`);
7042
+ const number = opened.match(/\/pull\/(\d+)/)?.[1];
7043
+ if (number)
7044
+ log(mergeHint(Number(number)));
6524
7045
  }
6525
7046
  if (plan.installed.length)
6526
7047
  log(`Installs: ${plan.installed.join(", ")}`);
@@ -6550,22 +7071,28 @@ var TRANSIENT = /\bHTTP 5\d\d\b|\b5\d\d (?:Bad Gateway|Service Unavailable|Gatew
6550
7071
  var tail = (text, lines = 30) => text.trimEnd().split(`
6551
7072
  `).slice(-lines).join(`
6552
7073
  `);
6553
- function ghMerge(exec, cwd, repository) {
6554
- return async (number, sha) => {
6555
- const args = ["pr", "merge", String(number), "--repo", repository, "--squash", "--match-head-commit", sha];
6556
- try {
6557
- const r = await exec("gh", args, { cwd });
6558
- const message = tail(`${r.stderr}
7074
+ async function ghAttempt(exec, cwd, args) {
7075
+ try {
7076
+ const r = await exec("gh", args, { cwd });
7077
+ const message = tail(`${r.stderr}
6559
7078
  ${r.stdout}`.trim(), 5) || `gh exited with ${r.code}`;
6560
- return { ok: r.code === 0, message, transient: r.code !== 0 && TRANSIENT.test(message) };
6561
- } catch (err) {
6562
- return {
6563
- ok: false,
6564
- message: `cannot run gh: ${err instanceof Error ? err.message : String(err)}`,
6565
- transient: false
6566
- };
6567
- }
6568
- };
7079
+ return { ok: r.code === 0, message, transient: r.code !== 0 && TRANSIENT.test(message) };
7080
+ } catch (err) {
7081
+ return {
7082
+ ok: false,
7083
+ message: `cannot run gh: ${err instanceof Error ? err.message : String(err)}`,
7084
+ transient: false
7085
+ };
7086
+ }
7087
+ }
7088
+ function ghMerge(exec, cwd, repository) {
7089
+ return (number, sha) => ghAttempt(exec, cwd, ["pr", "merge", String(number), "--repo", repository, "--squash", "--match-head-commit", sha]);
7090
+ }
7091
+ function ghUpdateBranch(exec, cwd, repository) {
7092
+ return (number, sha) => ghAttempt(exec, cwd, [
7093
+ ...["api", "--method", "PUT", `repos/${repository}/pulls/${number}/update-branch`],
7094
+ ...["-f", `expected_head_sha=${sha}`]
7095
+ ]);
6569
7096
  }
6570
7097
  var escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6571
7098
  function gitRepo(exec, cwd) {
@@ -6603,6 +7130,18 @@ function gitRepo(exec, cwd) {
6603
7130
  }
6604
7131
  return uses;
6605
7132
  },
7133
+ async mergeTree({ branch, number, ours, theirs }) {
7134
+ const present = async (sha) => (await git(["cat-file", "-e", `${sha}^{commit}`])).code === 0;
7135
+ if (!await present(ours) || !await present(theirs))
7136
+ await must(["fetch", "--quiet", "origin", branch, `refs/pull/${number}/head`]);
7137
+ const r = await git(["merge-tree", "--write-tree", "--no-messages", ours, theirs]);
7138
+ if (r.code === 1)
7139
+ return null;
7140
+ if (r.code !== 0)
7141
+ throw new Error(`git merge-tree failed: ${tail(r.stderr || r.stdout, 5)}`);
7142
+ return r.stdout.split(`
7143
+ `)[0]?.trim() || null;
7144
+ },
6606
7145
  async testMerge({ branch, base, head, number, commands }) {
6607
7146
  await must(["fetch", "--quiet", "origin", branch, `refs/pull/${number}/head`]);
6608
7147
  const dir = join5(tmpdir2(), `armada-merge-${number}-${randomUUID().slice(0, 8)}`);
@@ -6654,8 +7193,14 @@ function prNumber(arg, repository) {
6654
7193
  throw new UsageError(`${pr.url} is not in the project repository ${repository}`);
6655
7194
  return pr.number;
6656
7195
  }
7196
+ function waitMinutes(raw) {
7197
+ const n = Number(raw);
7198
+ if (!Number.isFinite(n) || n <= 0)
7199
+ throw new UsageError(`--timeout must be a number of minutes, got "${raw}"`);
7200
+ return n;
7201
+ }
6657
7202
  function render(o) {
6658
- const out = [...o.lines, o.pr.url, o.ticket.url];
7203
+ const out = [...o.lines, o.pr.url, ...o.ticket ? [o.ticket.url] : []];
6659
7204
  if (o.hints.length)
6660
7205
  out.push("Hints for you to judge (not blocking):", ...o.hints.map((h) => ` - ${h}`));
6661
7206
  if (!o.merged)
@@ -6665,12 +7210,12 @@ function render(o) {
6665
7210
  if (!o.workers.length)
6666
7211
  out.push("No other worker is in flight.");
6667
7212
  else {
6668
- out.push(`Tell these workers in flight what landed on ${o.pr.base} (rebase, shared files, new checks):`);
7213
+ out.push(`Tell these workers in flight what landed on ${o.pr.base} (bring it in, shared files, new checks):`);
6669
7214
  for (const w of o.workers)
6670
7215
  out.push(` ${w.ticket} ${w.phase} ${[w.runtime, w.handle].filter(Boolean).join(" · ") || "runtime unknown"} ${w.title}`);
6671
7216
  }
6672
7217
  const a = o.archive;
6673
- if (a) {
7218
+ if (a && o.ticket) {
6674
7219
  const who = `${o.ticket.id} (${[a.runtime, a.handle].filter(Boolean).join(" · ") || "session unknown"})`;
6675
7220
  out.push(a.guide ? `Archive the worker's workspace of ${who} with the "Stop and archive" section of the ${a.guide} skill.` : `No runtime guide is installed for ${a.runtime ?? "the worker's runtime"}, so Armada has nothing to archive for ${who}: a local session or subagent ends with its task; stop it yourself if it still runs.`);
6676
7221
  }
@@ -6683,6 +7228,15 @@ async function merge2(io, config, credentials, a, configPath) {
6683
7228
  if (extra.length)
6684
7229
  throw new UsageError(`unexpected argument ${extra[0]}`);
6685
7230
  const number = prNumber(arg, config.github.repository);
7231
+ const noTicket = !!a.options["no-ticket"];
7232
+ if (noTicket && a.options.ticket)
7233
+ throw new UsageError("--no-ticket and --ticket cannot go together");
7234
+ const wait = !!a.options.wait;
7235
+ if (wait && a.options["dry-run"])
7236
+ throw new UsageError("--wait and --dry-run cannot go together");
7237
+ if (!wait && a.options.timeout !== undefined)
7238
+ throw new UsageError("--timeout applies to --wait");
7239
+ const timeoutMs = a.options.timeout === undefined ? MERGE_WAIT_DEFAULT_MS : waitMinutes(a.options.timeout) * 60000;
6686
7240
  if (!credentials.linearApiKey)
6687
7241
  throw missingKey(LINEAR_KEY);
6688
7242
  const token = credentials.githubToken;
@@ -6705,7 +7259,9 @@ async function merge2(io, config, credentials, a, configPath) {
6705
7259
  readPull: (n) => fetchMergePull({ ...gh, number: n }),
6706
7260
  compare: (base, head) => fetchComparison({ ...gh, base, head }),
6707
7261
  diff: (n) => fetchPullDiff({ ...gh, number: n }),
6708
- merge: ghMerge(exec, repoDir, config.github.repository)
7262
+ merge: ghMerge(exec, repoDir, config.github.repository),
7263
+ commit: (sha) => fetchCommit({ ...gh, sha }),
7264
+ updateBranch: ghUpdateBranch(exec, repoDir, config.github.repository)
6709
7265
  },
6710
7266
  repo: gitRepo(exec, repoDir),
6711
7267
  lockRequired: !!credentials.armadaSignIn,
@@ -6731,13 +7287,15 @@ async function merge2(io, config, credentials, a, configPath) {
6731
7287
  const o = await mergePullRequest(ctx, {
6732
7288
  pr: number,
6733
7289
  ticket: a.options.ticket ?? null,
7290
+ noTicket,
7291
+ wait: wait ? { timeoutMs } : null,
6734
7292
  dryRun: !!a.options["dry-run"],
6735
7293
  noLock: !!a.options["no-lock"]
6736
7294
  });
6737
7295
  const project = config.project.slug;
6738
7296
  const coordinator = coordinatorHandle(io);
6739
7297
  const known = (await watchOf(io, project)).state?.inFlight ?? null;
6740
- const inFlight = o.workersListed ? o.workers.filter((w) => !coordinator || w.handle !== coordinator).map((w) => w.ticket).sort((x, y) => x.localeCompare(y, "en", { numeric: true })) : o.merged && known ? known.filter((t) => t !== o.ticket.id) : known;
7298
+ const inFlight = o.workersListed ? o.workers.filter((w) => !coordinator || w.handle !== coordinator).map((w) => w.ticket).sort((x, y) => x.localeCompare(y, "en", { numeric: true })) : o.merged && known ? known.filter((t) => t !== o.ticket?.id) : known;
6741
7299
  if (o.merged)
6742
7300
  await remember(io, project, { inFlight, readAt: (io.now ?? (() => new Date))().toISOString() });
6743
7301
  const next = await rearmFor(io, project, { inFlight, open: null });
@@ -6747,7 +7305,7 @@ async function merge2(io, config, credentials, a, configPath) {
6747
7305
  for (const w of o.warnings)
6748
7306
  io.stderr(`armada: warning: ${w}
6749
7307
  `);
6750
- if (o.merged)
7308
+ if (o.merged && o.ticket)
6751
7309
  await endWorkerSessions(io, config, credentials, o.ticket.id, "merged", a.json);
6752
7310
  return 0;
6753
7311
  }
@@ -6855,7 +7413,7 @@ async function statusAll(io, json) {
6855
7413
  const linearApiKey = credentials.linearApiKey;
6856
7414
  if (!linearApiKey)
6857
7415
  throw missingKey(LINEAR_KEY);
6858
- const api = armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} });
7416
+ const api = apiOf(io, credentials.armadaApi.url);
6859
7417
  const records = await api.projects(signIn);
6860
7418
  const projects = await Promise.all(records.map(async (p) => {
6861
7419
  const base = { slug: p.slug, name: p.name, repository: p.repository };
@@ -6960,13 +7518,19 @@ var COMMAND_HELP = {
6960
7518
  answer --note <ticket|plan item> "<message>"
6961
7519
  Coordinator: record a delivered note; an open plan is resolved
6962
7520
  `,
6963
- merge: ` merge <pr> [--ticket <id>] [--dry-run] [--no-lock]
7521
+ merge: ` merge <pr> [--ticket <id> | --no-ticket] [--dry-run] [--no-lock] [--wait [--timeout <min>]]
6964
7522
  Coordinator: check a handed-back pull request (hand-back SHA = head,
6965
7523
  CLEAN, required checks green, no open review thread, base contained
6966
7524
  or test-merged), squash-merge it pinned to that SHA under the merge
6967
7525
  lock, close the ticket and list the workers to tell. Never deletes
6968
7526
  the branch. --dry-run only runs the checklist. Signed in to Armada,
6969
7527
  refused while Armada is down; --no-lock then merges without the lock.
7528
+ --wait (--timeout in minutes, default 30): a head behind its base is
7529
+ updated on GitHub (a merge commit, no force-push) and its checks waited
7530
+ for, without the lock; a red check or a conflict stops it. A head that
7531
+ is the hand-back with only the base merged in counts as the hand-back.
7532
+ --no-ticket: a pull request no ticket owns (armada init, a release);
7533
+ nothing is written to Linear.
6970
7534
  `,
6971
7535
  brief: ` brief <ticket> [--profile <name> [--reason <why>]] [--prompt]
6972
7536
  A new worker's launch prompt, the Conductor profile (agent, model,
@@ -7083,7 +7647,7 @@ var VALUE_OPTIONS = [
7083
7647
  "launch-token",
7084
7648
  "api-url"
7085
7649
  ];
7086
- var FLAG_OPTIONS = ["dry-run", "no-lock", "prompt", "wait", "note", "api-key", "no-stop-hook"];
7650
+ var FLAG_OPTIONS = ["dry-run", "no-lock", "no-ticket", "prompt", "wait", "note", "api-key", "no-stop-hook"];
7087
7651
  var COMMAND_OPTIONS = {
7088
7652
  claim: ["runtime", "handle", "branch", "profile", "reason"],
7089
7653
  report: ["ticket", "message", "message-file", "plan", "plan-file", "pr", "sha"],
@@ -7092,7 +7656,7 @@ var COMMAND_OPTIONS = {
7092
7656
  inbox: ["wait", "timeout"],
7093
7657
  answer: ["note", "message", "message-file"],
7094
7658
  init: ["program-root", "name", "slug", "no-stop-hook"],
7095
- merge: ["ticket", "dry-run", "no-lock"],
7659
+ merge: ["ticket", "no-ticket", "dry-run", "no-lock", "wait", "timeout"],
7096
7660
  brief: ["profile", "reason", "prompt"],
7097
7661
  login: ["api-key", "launch-token", "api-url"]
7098
7662
  };