@the-vibe-company/armada 0.2.20 → 0.2.22
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.
- package/README.md +30 -3
- package/dist/armada.js +716 -64
- package/package.json +1 -1
package/dist/armada.js
CHANGED
|
@@ -1120,7 +1120,9 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1120
1120
|
"approval_label",
|
|
1121
1121
|
"attachments_per_ticket",
|
|
1122
1122
|
"attachments_project_mb",
|
|
1123
|
-
"attachments_retention_days"
|
|
1123
|
+
"attachments_retention_days",
|
|
1124
|
+
"merge_approval",
|
|
1125
|
+
"validation"
|
|
1124
1126
|
]
|
|
1125
1127
|
],
|
|
1126
1128
|
["brief", briefT, ["extra"]],
|
|
@@ -1253,6 +1255,26 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1253
1255
|
const attachmentsPerTicket = quota("attachments_per_ticket", CONFIG_DEFAULTS.attachmentsPerTicket);
|
|
1254
1256
|
const attachmentsProjectMb = quota("attachments_project_mb", CONFIG_DEFAULTS.attachmentsProjectMb);
|
|
1255
1257
|
const attachmentsRetentionDays = quota("attachments_retention_days", CONFIG_DEFAULTS.attachmentsRetentionDays);
|
|
1258
|
+
const mergeApproval = policyT.merge_approval === undefined ? null : str(policyT, "policy", "merge_approval") || null;
|
|
1259
|
+
const validations = [];
|
|
1260
|
+
const validationRaw = policyT.validation ?? [];
|
|
1261
|
+
if (!Array.isArray(validationRaw))
|
|
1262
|
+
problems.push(`"policy.validation" must be a list of [[policy.validation]] rules`);
|
|
1263
|
+
else
|
|
1264
|
+
for (const [i, r] of validationRaw.entries()) {
|
|
1265
|
+
const path = `policy.validation[${i + 1}]`;
|
|
1266
|
+
if (!isTable(r)) {
|
|
1267
|
+
problems.push(`"${path}" must be a table`);
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
for (const key of Object.keys(r))
|
|
1271
|
+
if (key !== "when" && key !== "then")
|
|
1272
|
+
problems.push(`unknown key "${path}.${key}"`);
|
|
1273
|
+
const when = str(r, path, "when");
|
|
1274
|
+
const then = str(r, path, "then");
|
|
1275
|
+
if (when && then)
|
|
1276
|
+
validations.push({ when, show: then });
|
|
1277
|
+
}
|
|
1256
1278
|
const approvalLabel = str(policyT, "policy", "approval_label", { default: CONFIG_DEFAULTS.approvalLabel });
|
|
1257
1279
|
if (preApprovedLabel && approvalLabel && routingLabelKey(preApprovedLabel) === routingLabelKey(approvalLabel))
|
|
1258
1280
|
problems.push(`"policy.pre_approved_label" and "policy.approval_label" must name different labels`);
|
|
@@ -1320,7 +1342,9 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1320
1342
|
approvalLabel,
|
|
1321
1343
|
attachmentsPerTicket,
|
|
1322
1344
|
attachmentsProjectMb,
|
|
1323
|
-
attachmentsRetentionDays
|
|
1345
|
+
attachmentsRetentionDays,
|
|
1346
|
+
mergeApproval,
|
|
1347
|
+
validations
|
|
1324
1348
|
},
|
|
1325
1349
|
brief: { extra },
|
|
1326
1350
|
secrets: { names: secretNames },
|
|
@@ -1367,6 +1391,15 @@ coordinator_minutes = 10 # an inbox item open longer than this shows "waiting fo
|
|
|
1367
1391
|
# attachments_retention_days = 30
|
|
1368
1392
|
# pre_approved_label = "plan-approved" # a ticket with this label skips the approval
|
|
1369
1393
|
# approval_label = "needs-plan-approval" # a ticket with this label waits for it; wins over the other
|
|
1394
|
+
# Which merges need your approval, in plain words; without it the coordinator merges everything on its own.
|
|
1395
|
+
# The coordinator judges it per pull request and sends you one approval link for the others.
|
|
1396
|
+
# merge_approval = "merge on your own, except front-end changes: send me a link to check them first"
|
|
1397
|
+
|
|
1398
|
+
# Kinds of tickets whose work you validate before it goes on: the coordinator judges at launch
|
|
1399
|
+
# which apply, and the worker shows you its work with \`armada validate\` and waits for your decision.
|
|
1400
|
+
# [[policy.validation]]
|
|
1401
|
+
# when = "a design ticket: a mockup, a visual direction or the look of a new screen"
|
|
1402
|
+
# then = "produce the design, attach it, ask the owner to validate it on Armada, and stop until they decide; never merge or build it on your own"
|
|
1370
1403
|
|
|
1371
1404
|
[brief]
|
|
1372
1405
|
# extra = "docs/worker-conventions.md" # a file every worker brief carries under "Project conventions"
|
|
@@ -1556,21 +1589,23 @@ var LABEL_PHASES = [
|
|
|
1556
1589
|
"implementing",
|
|
1557
1590
|
"shipping",
|
|
1558
1591
|
"blocked",
|
|
1559
|
-
"ready-to-merge"
|
|
1592
|
+
"ready-to-merge",
|
|
1593
|
+
"awaiting-validation"
|
|
1560
1594
|
];
|
|
1561
1595
|
|
|
1562
1596
|
// ../core/src/fleet.ts
|
|
1563
1597
|
var MIN = 60000;
|
|
1564
|
-
var NEEDS_HUMAN = ["awaiting-approval", "blocked", "ready-to-merge"];
|
|
1598
|
+
var NEEDS_HUMAN = ["awaiting-approval", "awaiting-validation", "blocked", "ready-to-merge"];
|
|
1565
1599
|
var PHASE_RANK = {
|
|
1566
1600
|
merged: 0,
|
|
1567
1601
|
"ready-to-merge": 1,
|
|
1568
1602
|
shipping: 2,
|
|
1569
1603
|
implementing: 3,
|
|
1570
|
-
"awaiting-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1604
|
+
"awaiting-validation": 4,
|
|
1605
|
+
"awaiting-approval": 5,
|
|
1606
|
+
planning: 6,
|
|
1607
|
+
blocked: 7,
|
|
1608
|
+
released: 8
|
|
1574
1609
|
};
|
|
1575
1610
|
var PLAN_HINT = /\b(plan|objective|assumptions|awaiting (?:plan )?approval)\b/i;
|
|
1576
1611
|
function commentsFor(comments, id) {
|
|
@@ -1758,8 +1793,6 @@ function notStartedBody(l, now) {
|
|
|
1758
1793
|
}
|
|
1759
1794
|
var notStartedLaunches = (launches, now, minutes) => followedLaunches(launches, now).filter((l) => now.getTime() - Date.parse(l.launchedAt) > minutes * MIN2);
|
|
1760
1795
|
|
|
1761
|
-
// ../core/src/activity.ts
|
|
1762
|
-
var SAME_MS = 10 * 60000;
|
|
1763
1796
|
// ../core/src/linear.ts
|
|
1764
1797
|
var LINEAR_ENDPOINT = "https://api.linear.app/graphql";
|
|
1765
1798
|
var MAX_DEPTH = 8;
|
|
@@ -2386,6 +2419,7 @@ async function waitForApproval({ api, code, sleep, now }) {
|
|
|
2386
2419
|
}
|
|
2387
2420
|
throw new ArmadaApiError("the code expired before it was approved", LOGIN_NEXT);
|
|
2388
2421
|
}
|
|
2422
|
+
|
|
2389
2423
|
// ../core/src/attachments.ts
|
|
2390
2424
|
var MAX_ATTACHMENT_BYTES = 2 * 1024 * 1024;
|
|
2391
2425
|
function attachmentImageType(bytes) {
|
|
@@ -2425,14 +2459,16 @@ function checkAttachment(input) {
|
|
|
2425
2459
|
return "attachment link type limit: a valid HTTPS URL is required";
|
|
2426
2460
|
}
|
|
2427
2461
|
}
|
|
2462
|
+
|
|
2428
2463
|
// ../core/src/phases.ts
|
|
2429
2464
|
var TRANSITIONS = {
|
|
2430
|
-
planning: ["awaiting-approval", "implementing"],
|
|
2465
|
+
planning: ["awaiting-approval", "implementing", "awaiting-validation"],
|
|
2431
2466
|
"awaiting-approval": ["planning", "implementing"],
|
|
2432
|
-
implementing: ["shipping"],
|
|
2433
|
-
shipping: ["implementing", "ready-to-merge"],
|
|
2467
|
+
implementing: ["shipping", "awaiting-validation"],
|
|
2468
|
+
shipping: ["implementing", "ready-to-merge", "awaiting-validation"],
|
|
2434
2469
|
"ready-to-merge": ["shipping"],
|
|
2435
|
-
|
|
2470
|
+
"awaiting-validation": ["planning", "implementing", "shipping"],
|
|
2471
|
+
blocked: ["planning", "awaiting-approval", "implementing", "shipping", "ready-to-merge", "awaiting-validation"]
|
|
2436
2472
|
};
|
|
2437
2473
|
var isLabelPhase = (v) => LABEL_PHASES.includes(v);
|
|
2438
2474
|
function transitionProblem(from, to) {
|
|
@@ -2583,6 +2619,96 @@ function chooseProfile(config, input) {
|
|
|
2583
2619
|
return { name, profile, source: "requested", rule: null, routed: route?.name ?? null, reason, why };
|
|
2584
2620
|
}
|
|
2585
2621
|
|
|
2622
|
+
// ../core/src/validations.ts
|
|
2623
|
+
var VALIDATION_LIMITS = { what: 4000, reason: 1000, choice: 120, choices: 6, note: 4000, attachments: 20 };
|
|
2624
|
+
var approvalPath = (id) => `/approve/${id}`;
|
|
2625
|
+
var approvalUrl = (appUrl, id) => appUrl ? new URL(approvalPath(id), appUrl).toString() : approvalPath(id);
|
|
2626
|
+
function parseChoices(raw) {
|
|
2627
|
+
if (!raw?.trim())
|
|
2628
|
+
return null;
|
|
2629
|
+
const choices = [...new Set(raw.split("|").map((c) => c.replace(/\s+/g, " ").trim()))].filter(Boolean);
|
|
2630
|
+
return choices.length ? choices : null;
|
|
2631
|
+
}
|
|
2632
|
+
var when = (iso) => `${iso.slice(0, 16).replace("T", " ")} UTC`;
|
|
2633
|
+
function decidedLine(d) {
|
|
2634
|
+
const who = `${d.by ?? "the owner"} at ${when(d.at)}`;
|
|
2635
|
+
if (d.outcome === "approved")
|
|
2636
|
+
return `approved by ${who}`;
|
|
2637
|
+
if (d.outcome === "changes")
|
|
2638
|
+
return `changes requested by ${who}`;
|
|
2639
|
+
if (d.outcome === "answered")
|
|
2640
|
+
return `answered "${d.answer ?? ""}" by ${who}`;
|
|
2641
|
+
return `superseded at ${when(d.at)}`;
|
|
2642
|
+
}
|
|
2643
|
+
function mergeApproval(validations, pr, head) {
|
|
2644
|
+
const asked = validations.filter((v) => v.kind === "merge" && v.pr?.number === pr && v.decision?.outcome !== "superseded").sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.id - a.id)[0];
|
|
2645
|
+
if (!asked?.pr)
|
|
2646
|
+
return { state: "none" };
|
|
2647
|
+
const d = asked.decision;
|
|
2648
|
+
if (!d)
|
|
2649
|
+
return { state: "pending", validation: asked };
|
|
2650
|
+
if (d.outcome !== "approved")
|
|
2651
|
+
return { state: "changes", validation: asked };
|
|
2652
|
+
const approved = asked.pr.headSha;
|
|
2653
|
+
if (head.sha !== approved && !head.sameAs.includes(approved))
|
|
2654
|
+
return { state: "stale", validation: asked };
|
|
2655
|
+
return { state: "approved", validation: asked, decision: d };
|
|
2656
|
+
}
|
|
2657
|
+
function lastValidation(validations, ticket) {
|
|
2658
|
+
return validations.filter((v) => v.ticket === ticket && v.kind === "validation" && v.decision?.outcome !== "superseded").sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.id - a.id)[0] ?? null;
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
class ValidationChoiceError extends Error {
|
|
2662
|
+
next;
|
|
2663
|
+
name = "ValidationChoiceError";
|
|
2664
|
+
constructor(message, next) {
|
|
2665
|
+
super(message);
|
|
2666
|
+
this.next = next;
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
var quoteWord = (s) => /^\w[\w./:@+-]*$/.test(s) ? s : `'${s.replaceAll("'", `'\\''`)}'`;
|
|
2670
|
+
function chooseValidations(rules, input) {
|
|
2671
|
+
const reason = input.reason?.replace(/\s+/g, " ").trim() || null;
|
|
2672
|
+
const requested = input.requested?.trim().toLowerCase() || null;
|
|
2673
|
+
const listed = rules.map((r, k) => ` ${k + 1}. when ${r.when}
|
|
2674
|
+
then ${r.show}`).join(`
|
|
2675
|
+
`);
|
|
2676
|
+
const none = `${input.command} --validation none`;
|
|
2677
|
+
const some = (n) => `${input.command} --validation ${n} --validation-reason ${quoteWord("<why this ticket is one>")}`;
|
|
2678
|
+
if (!rules.length) {
|
|
2679
|
+
if (requested && requested !== "none")
|
|
2680
|
+
throw new ValidationChoiceError("armada.toml has no [[policy.validation]] rule to apply", none.replace(/ --validation none$/, ""));
|
|
2681
|
+
return null;
|
|
2682
|
+
}
|
|
2683
|
+
if (requested === null)
|
|
2684
|
+
throw new ValidationChoiceError(`armada.toml has [[policy.validation]] rules: judge whether ${input.ticket} is one of them
|
|
2685
|
+
${listed}
|
|
2686
|
+
Most tickets are none: ${none}
|
|
2687
|
+
One applies: ${some("<n>")}`, none);
|
|
2688
|
+
if (requested === "none")
|
|
2689
|
+
return { rules: [], reason };
|
|
2690
|
+
const numbers = requested.split(",").map((n) => n.trim());
|
|
2691
|
+
const picked = numbers.map((n) => Number(n));
|
|
2692
|
+
if (picked.some((n, k) => !/^\d+$/.test(numbers[k] ?? "") || n < 1 || n > rules.length))
|
|
2693
|
+
throw new ValidationChoiceError(`--validation takes none or rule numbers from 1 to ${rules.length}, got "${input.requested}"
|
|
2694
|
+
${listed}`, none);
|
|
2695
|
+
if (!reason)
|
|
2696
|
+
throw new ValidationChoiceError(`say why ${input.ticket} needs the owner's validation with --validation-reason`, some([...new Set(picked)].join(",")));
|
|
2697
|
+
return {
|
|
2698
|
+
rules: [...new Set(picked)].sort((a, b) => a - b).map((index) => {
|
|
2699
|
+
const r = rules[index - 1];
|
|
2700
|
+
return { index, when: r.when, show: r.show };
|
|
2701
|
+
}),
|
|
2702
|
+
reason
|
|
2703
|
+
};
|
|
2704
|
+
}
|
|
2705
|
+
function validationClaimLine(choice) {
|
|
2706
|
+
if (!choice?.rules.length)
|
|
2707
|
+
return null;
|
|
2708
|
+
const rules = choice.rules.map((r) => `rule ${r.index} (${r.when})`).join(", ");
|
|
2709
|
+
return `Owner validation: ${rules}${choice.reason ? ` — ${choice.reason}` : ""}`;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2586
2712
|
// ../core/src/worker.ts
|
|
2587
2713
|
class Refusal extends Error {
|
|
2588
2714
|
next;
|
|
@@ -2740,9 +2866,11 @@ async function claimTicket(ctx, input) {
|
|
|
2740
2866
|
throw err;
|
|
2741
2867
|
}
|
|
2742
2868
|
const started = ctx.now().toISOString();
|
|
2869
|
+
const validation = validationClaimLine(input.validation ?? null);
|
|
2743
2870
|
const body = `Agent status: planning — claimed by ${runtime.name} (${input.handle})
|
|
2744
2871
|
|
|
2745
|
-
${claimLine({ runtime: runtime.name, handle: input.handle, branch, started, profile })}
|
|
2872
|
+
${claimLine({ runtime: runtime.name, handle: input.handle, branch, started, profile })}${validation ? `
|
|
2873
|
+
${validation}` : ""}`;
|
|
2746
2874
|
const mine = await linear.comment(ticket.uuid, body);
|
|
2747
2875
|
const after = await linear.readTicket(ticket.id);
|
|
2748
2876
|
const winner = after ? activeClaimComments(after.comments)[0] : undefined;
|
|
@@ -3013,7 +3141,12 @@ var VARIABLES = [
|
|
|
3013
3141
|
];
|
|
3014
3142
|
|
|
3015
3143
|
class BriefError extends Error {
|
|
3144
|
+
next;
|
|
3016
3145
|
name = "BriefError";
|
|
3146
|
+
constructor(message, next = null) {
|
|
3147
|
+
super(message);
|
|
3148
|
+
this.next = next;
|
|
3149
|
+
}
|
|
3017
3150
|
}
|
|
3018
3151
|
function buildBrief(input) {
|
|
3019
3152
|
const { config, ticket, program } = input;
|
|
@@ -3065,7 +3198,11 @@ function buildBrief(input) {
|
|
|
3065
3198
|
`armada claim ${ticket.id} --runtime ${runtime} --handle ${handle}`,
|
|
3066
3199
|
branch ? ` --branch ${branch}` : "",
|
|
3067
3200
|
choice ? ` --profile ${shellWord(choice.name)}` : "",
|
|
3068
|
-
choice?.reason ? ` --reason ${shellWord(choice.reason)}` : ""
|
|
3201
|
+
choice?.reason ? ` --reason ${shellWord(choice.reason)}` : "",
|
|
3202
|
+
...input.validation?.rules.length ? [
|
|
3203
|
+
` --validation ${input.validation.rules.map((r) => r.index).join(",")}`,
|
|
3204
|
+
input.validation.reason ? ` --validation-reason ${shellWord(input.validation.reason)}` : ""
|
|
3205
|
+
] : []
|
|
3069
3206
|
].join("");
|
|
3070
3207
|
const has = (name) => !!input.env[name]?.trim();
|
|
3071
3208
|
const launch = input.launch ?? null;
|
|
@@ -3121,6 +3258,7 @@ function buildBrief(input) {
|
|
|
3121
3258
|
notes: ticket.notes.slice(0, MAX_NOTES),
|
|
3122
3259
|
parallel,
|
|
3123
3260
|
plans: planRule(config, ticket.labels),
|
|
3261
|
+
validation: input.validation ?? null,
|
|
3124
3262
|
conventions: extra?.text?.trim() ? { path: extra.path, text: extra.text } : null,
|
|
3125
3263
|
warnings
|
|
3126
3264
|
};
|
|
@@ -3212,6 +3350,9 @@ ${quote(x.handBack.body)}` : "No hand-back note.", "");
|
|
|
3212
3350
|
out.push(`### ${byLine(n)}`, "", quote(n.body), "");
|
|
3213
3351
|
}
|
|
3214
3352
|
out.push("## Plan", "", b.plans.rule === "pre-approved" ? `Plans are pre-approved for ${t.id} (${b.plans.why}): post your plan with \`armada report implementing --plan-file -\` and go on.` : `Plans need the coordinator's approval for ${t.id} (${b.plans.why}): post your plan with \`armada report awaiting-approval --plan-file -\` and wait for approval.`, "");
|
|
3353
|
+
const validation = b.validation?.rules ?? [];
|
|
3354
|
+
if (validation.length)
|
|
3355
|
+
out.push("## Owner validation", "", `This ticket needs the owner's validation: ${validation.map((r) => r.show.replace(/[.\s]+$/, "")).join("; ")}.`, "", `The coordinator judged it so${b.validation?.reason ? `: ${b.validation.reason}` : ""}. Submit your work with \`armada validate "<what to check>" --attach <files|urls>\`: your phase becomes \`awaiting-validation\`, the owner sees it on Armada's Validations page, and you stop until the coordinator relays their decision. On "Request changes", revise and submit again.`, "");
|
|
3215
3356
|
out.push("## Workers in flight", "");
|
|
3216
3357
|
if (b.parallel.length) {
|
|
3217
3358
|
out.push("Stay out of their areas. If you must change the same files, say so in a report before you do.", "");
|
|
@@ -3275,6 +3416,19 @@ async function loadBrief(config, opts) {
|
|
|
3275
3416
|
throw new BriefError(err.message);
|
|
3276
3417
|
throw err;
|
|
3277
3418
|
}
|
|
3419
|
+
let validation;
|
|
3420
|
+
try {
|
|
3421
|
+
validation = chooseValidations(config.policy.validations ?? [], {
|
|
3422
|
+
ticket: ticket.id,
|
|
3423
|
+
requested: opts.validation?.requested ?? null,
|
|
3424
|
+
reason: opts.validation?.reason ?? null,
|
|
3425
|
+
command: opts.validation?.command ?? `armada brief ${ticket.id}`
|
|
3426
|
+
});
|
|
3427
|
+
} catch (err) {
|
|
3428
|
+
if (err instanceof ValidationChoiceError)
|
|
3429
|
+
throw new BriefError(`${err.message}`, err.next);
|
|
3430
|
+
throw err;
|
|
3431
|
+
}
|
|
3278
3432
|
const launch = await launchForBrief(ticket, opts.prompt === true ? opts.launch : undefined);
|
|
3279
3433
|
const made = launch && "token" in launch ? launch : null;
|
|
3280
3434
|
const missed = launch && "reason" in launch ? launch : null;
|
|
@@ -3293,6 +3447,7 @@ async function loadBrief(config, opts) {
|
|
|
3293
3447
|
launch: made,
|
|
3294
3448
|
noLaunch: missed?.reason ?? null,
|
|
3295
3449
|
conventions: opts.conventions ?? null,
|
|
3450
|
+
validation,
|
|
3296
3451
|
now: now()
|
|
3297
3452
|
});
|
|
3298
3453
|
return opts.prompt ? brief : { ...brief, launchHint };
|
|
@@ -3300,6 +3455,7 @@ async function loadBrief(config, opts) {
|
|
|
3300
3455
|
async function launchForBrief(ticket, launch) {
|
|
3301
3456
|
return ticket.statusType !== "completed" && ticket.statusType !== "canceled" && launch ? launch(ticket.id) : null;
|
|
3302
3457
|
}
|
|
3458
|
+
|
|
3303
3459
|
// ../core/src/credentials.ts
|
|
3304
3460
|
var DEFAULT_ARMADA_API_URL = "https://armada.thevibecompany.co";
|
|
3305
3461
|
var SESSION_TOKEN_VARIABLE = "ARMADA_SESSION_TOKEN";
|
|
@@ -3412,6 +3568,7 @@ var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name]
|
|
|
3412
3568
|
function missingKeyMessage(key) {
|
|
3413
3569
|
return `${key.variable} is not set. Set it in the environment, run \`armada auth login\` to store it on this machine (${key.hint}), or sign in with \`armada login\` to an Armada that keeps your organization's keys.`;
|
|
3414
3570
|
}
|
|
3571
|
+
|
|
3415
3572
|
// ../core/src/dotenv.ts
|
|
3416
3573
|
var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
3417
3574
|
function shellWord2(raw) {
|
|
@@ -3524,8 +3681,9 @@ function updateDotenv(text, updates) {
|
|
|
3524
3681
|
`)}
|
|
3525
3682
|
` : "";
|
|
3526
3683
|
}
|
|
3684
|
+
|
|
3527
3685
|
// ../core/src/fleet-api.ts
|
|
3528
|
-
var WORKER_FLEET_OPS = ["claim", "report", "ask", "release", "heartbeat"];
|
|
3686
|
+
var WORKER_FLEET_OPS = ["claim", "report", "ask", "release", "heartbeat", "validate"];
|
|
3529
3687
|
var FLEET_OPS = [
|
|
3530
3688
|
...WORKER_FLEET_OPS,
|
|
3531
3689
|
"register",
|
|
@@ -3540,6 +3698,8 @@ var FLEET_OPS = [
|
|
|
3540
3698
|
"inbox/resolve",
|
|
3541
3699
|
"answer",
|
|
3542
3700
|
"merge",
|
|
3701
|
+
"validations",
|
|
3702
|
+
"done",
|
|
3543
3703
|
"lease/acquire",
|
|
3544
3704
|
"lease/renew",
|
|
3545
3705
|
"lease/release"
|
|
@@ -3573,6 +3733,9 @@ function fleetClient(o) {
|
|
|
3573
3733
|
answer: (a) => call("answer", a),
|
|
3574
3734
|
resolve: (r) => call("inbox/resolve", r),
|
|
3575
3735
|
merge: (m) => call("merge", m),
|
|
3736
|
+
validate: (v) => call("validate", v),
|
|
3737
|
+
validations: (q) => call("validations", q),
|
|
3738
|
+
done: (d) => call("done", d),
|
|
3576
3739
|
acquireLease: (l) => call("lease/acquire", l),
|
|
3577
3740
|
renewLease: (l) => call("lease/renew", l),
|
|
3578
3741
|
releaseLease: (l) => call("lease/release", l).then(() => {
|
|
@@ -3580,6 +3743,7 @@ function fleetClient(o) {
|
|
|
3580
3743
|
})
|
|
3581
3744
|
};
|
|
3582
3745
|
}
|
|
3746
|
+
|
|
3583
3747
|
// ../core/src/github.ts
|
|
3584
3748
|
var GITHUB_GRAPHQL = "https://api.github.com/graphql";
|
|
3585
3749
|
|
|
@@ -3837,6 +4001,36 @@ async function fetchCommit(opts) {
|
|
|
3837
4001
|
return null;
|
|
3838
4002
|
return { sha: c.oid, tree: c.tree.oid, parents: c.parents.nodes.map((p) => p.oid) };
|
|
3839
4003
|
}
|
|
4004
|
+
var PREVIEW_QUERY = `
|
|
4005
|
+
query Preview($owner: String!, $name: String!, $oid: GitObjectID!) {
|
|
4006
|
+
repository(owner: $owner, name: $name) {
|
|
4007
|
+
object(oid: $oid) {
|
|
4008
|
+
... on Commit {
|
|
4009
|
+
deployments(last: 10) { nodes { environment latestStatus { state environmentUrl } } }
|
|
4010
|
+
status { contexts { context state targetUrl } }
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
}`;
|
|
4015
|
+
var https = (url) => {
|
|
4016
|
+
try {
|
|
4017
|
+
return url && new URL(url).protocol === "https:" ? url : null;
|
|
4018
|
+
} catch {
|
|
4019
|
+
return null;
|
|
4020
|
+
}
|
|
4021
|
+
};
|
|
4022
|
+
async function fetchPreview(opts) {
|
|
4023
|
+
const [owner, name] = opts.repository.split("/");
|
|
4024
|
+
const json = await githubQuery(opts, PREVIEW_QUERY, { owner, name, oid: opts.sha });
|
|
4025
|
+
const commit = json.data?.repository?.object;
|
|
4026
|
+
const deployed = (commit?.deployments?.nodes ?? []).filter((d) => d.latestStatus?.state === "SUCCESS" && https(d.latestStatus.environmentUrl)).reverse();
|
|
4027
|
+
const preview = deployed.find((d) => /preview/i.test(d.environment ?? "")) ?? deployed[0];
|
|
4028
|
+
if (preview)
|
|
4029
|
+
return preview.latestStatus?.environmentUrl ?? null;
|
|
4030
|
+
const vercel = commit?.status?.contexts.find((c) => /vercel/i.test(c.context) && c.state === "SUCCESS");
|
|
4031
|
+
return https(vercel?.targetUrl);
|
|
4032
|
+
}
|
|
4033
|
+
|
|
3840
4034
|
// ../core/src/heartbeat.ts
|
|
3841
4035
|
async function heartbeatLoop(options) {
|
|
3842
4036
|
let claimedAt = null;
|
|
@@ -3865,6 +4059,7 @@ async function heartbeatLoop(options) {
|
|
|
3865
4059
|
}
|
|
3866
4060
|
return "parent-exited";
|
|
3867
4061
|
}
|
|
4062
|
+
|
|
3868
4063
|
// ../core/src/inbox.ts
|
|
3869
4064
|
function questionBody(question, options = []) {
|
|
3870
4065
|
const listed = options.map((o) => o.trim()).filter(Boolean);
|
|
@@ -3954,7 +4149,8 @@ var ANSWERABLE = [
|
|
|
3954
4149
|
"launch-request",
|
|
3955
4150
|
"merge-request",
|
|
3956
4151
|
"release-request",
|
|
3957
|
-
"plan-changes"
|
|
4152
|
+
"plan-changes",
|
|
4153
|
+
"decision"
|
|
3958
4154
|
];
|
|
3959
4155
|
async function answerItem(ctx, input) {
|
|
3960
4156
|
const { config, linear } = ctx;
|
|
@@ -3992,7 +4188,7 @@ async function answerItem(ctx, input) {
|
|
|
3992
4188
|
}
|
|
3993
4189
|
if (item?.kind === "launch-request")
|
|
3994
4190
|
return declineLaunch(ctx, item, text, warnings);
|
|
3995
|
-
if (item && ["merge-request", "release-request", "plan-changes"].includes(item.kind)) {
|
|
4191
|
+
if (item && ["merge-request", "release-request", "plan-changes", "decision"].includes(item.kind)) {
|
|
3996
4192
|
const recorded = await live(ctx, warnings, "resolve the dashboard request", (fleet) => fleet.answer({ text, note: false, ticket: item.ticket, item: item.id }));
|
|
3997
4193
|
return { ticket: item.ticket ?? `#${item.id}`, url: "", lines: recorded ? [recorded] : [], warnings, inbox: null };
|
|
3998
4194
|
}
|
|
@@ -4030,6 +4226,7 @@ async function declineLaunch(ctx, item, reason, warnings) {
|
|
|
4030
4226
|
];
|
|
4031
4227
|
return { ticket: item.ticket ?? `#${item.id}`, url: "", lines, warnings: [...new Set(warnings)], inbox: null };
|
|
4032
4228
|
}
|
|
4229
|
+
|
|
4033
4230
|
// ../core/src/labels.ts
|
|
4034
4231
|
function requiredLabels(config) {
|
|
4035
4232
|
return [
|
|
@@ -4119,6 +4316,7 @@ async function createMissingLabels(state, opts) {
|
|
|
4119
4316
|
}
|
|
4120
4317
|
return created;
|
|
4121
4318
|
}
|
|
4319
|
+
|
|
4122
4320
|
// ../core/src/linear-write.ts
|
|
4123
4321
|
var LABEL = "id name parent { name }";
|
|
4124
4322
|
var ATTACHMENT = "title url";
|
|
@@ -4259,6 +4457,7 @@ function createLinearWriter(opts) {
|
|
|
4259
4457
|
}
|
|
4260
4458
|
};
|
|
4261
4459
|
}
|
|
4460
|
+
|
|
4262
4461
|
// ../core/src/machine.ts
|
|
4263
4462
|
import { randomBytes } from "node:crypto";
|
|
4264
4463
|
import { chmod, link, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
@@ -4636,6 +4835,7 @@ async function addNoticedRelease(paths, version) {
|
|
|
4636
4835
|
`;
|
|
4637
4836
|
await writePrivate(paths, releasesFile(paths), text, 420);
|
|
4638
4837
|
}
|
|
4838
|
+
|
|
4639
4839
|
// ../core/src/merge.ts
|
|
4640
4840
|
var MERGE_LEASE = "merge";
|
|
4641
4841
|
var MERGE_LEASE_TTL_MS = 20 * 60000;
|
|
@@ -4887,9 +5087,11 @@ async function lineageOf(ctx, pull, from, run) {
|
|
|
4887
5087
|
try {
|
|
4888
5088
|
const lineage = await (async () => {
|
|
4889
5089
|
let sha = pull.headSha;
|
|
5090
|
+
const chain = [];
|
|
4890
5091
|
for (let updates = 0;; updates++) {
|
|
5092
|
+
chain.push(sha);
|
|
4891
5093
|
if (sha === from)
|
|
4892
|
-
return { from, updates, why: null };
|
|
5094
|
+
return { from, updates, why: null, chain };
|
|
4893
5095
|
if (updates >= MAX_UPDATES)
|
|
4894
5096
|
return fail(`more than ${MAX_UPDATES} merge commits stand on it`);
|
|
4895
5097
|
const commit = await ctx.forge.commit(sha);
|
|
@@ -4996,7 +5198,8 @@ ${indent(test.output)}`);
|
|
|
4996
5198
|
const updatedFrom = updates && l.lineage ? l.lineage.from : null;
|
|
4997
5199
|
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}`;
|
|
4998
5200
|
lines.unshift(`Checklist passed for ${label(pull, ticket)}: ${head}, ${pull.mergeStateStatus}, checks green, no open review thread.`, ...l.notes);
|
|
4999
|
-
|
|
5201
|
+
const chain = [pull.headSha, ...l.lineage?.why === null ? l.lineage.chain ?? [l.lineage.from] : []];
|
|
5202
|
+
return { pull, ticket, sha: pull.headSha, updatedFrom, baseSha: cmp?.baseSha ?? null, lines, hints, warnings, chain };
|
|
5000
5203
|
}
|
|
5001
5204
|
var indent = (text) => text.trimEnd().split(`
|
|
5002
5205
|
`).map((l) => ` ${l}`).join(`
|
|
@@ -5037,6 +5240,123 @@ async function recheck(ctx, input, run, c) {
|
|
|
5037
5240
|
${problems.map((p) => ` - ${p}`).join(`
|
|
5038
5241
|
`)}${updatedNote(run, pull)}`, `armada merge ${pull.number} again`);
|
|
5039
5242
|
}
|
|
5243
|
+
async function ownerDecision(ctx, input, c, dryRun) {
|
|
5244
|
+
const n = c.pull.number;
|
|
5245
|
+
const rule = c.ticket ? ctx.config.policy.mergeApproval ?? null : null;
|
|
5246
|
+
const reason = input.reason?.replace(/\s+/g, " ").trim() || null;
|
|
5247
|
+
const lines = rule ? [`Merge rule (armada.toml [policy] merge_approval): "${rule}"`] : [];
|
|
5248
|
+
let approval = { state: "none" };
|
|
5249
|
+
let unreadable = null;
|
|
5250
|
+
const { fleet, warning } = await ctx.fleet();
|
|
5251
|
+
try {
|
|
5252
|
+
if (fleet)
|
|
5253
|
+
approval = mergeApproval(await fleet.validations({ pr: n }), n, { sha: c.sha, sameAs: c.chain ?? [] });
|
|
5254
|
+
else
|
|
5255
|
+
unreadable = warning ?? "not signed in to Armada";
|
|
5256
|
+
} catch (err) {
|
|
5257
|
+
unreadable = err instanceof Error ? err.message : String(err);
|
|
5258
|
+
}
|
|
5259
|
+
const link = (v) => approvalUrl(ctx.appUrl ?? null, v.id);
|
|
5260
|
+
const judge = `armada merge ${n} --reason "<why it may merge on its own>", or armada merge ${n} --ask-owner --reason "<why the owner must see it>"`;
|
|
5261
|
+
let problem = null;
|
|
5262
|
+
let next = "";
|
|
5263
|
+
let decided = null;
|
|
5264
|
+
if (unreadable && rule) {
|
|
5265
|
+
problem = `the owner's approvals of #${n} could not be read (${unreadable})`;
|
|
5266
|
+
next = `armada merge ${n} again once Armada answers`;
|
|
5267
|
+
} else if (approval.state === "approved")
|
|
5268
|
+
decided = decidedLine(approval.decision);
|
|
5269
|
+
else if (approval.state === "pending") {
|
|
5270
|
+
problem = `the owner has not decided on the merge of #${n} yet (asked ${approval.validation.createdAt}): ${link(approval.validation)}`;
|
|
5271
|
+
next = "armada inbox --wait: the owner's decision arrives there";
|
|
5272
|
+
} else if (approval.state === "changes") {
|
|
5273
|
+
const d = approval.validation.decision;
|
|
5274
|
+
problem = `the owner requested changes on #${n}${d?.note ? `: ${d.note}` : ""}`;
|
|
5275
|
+
next = c.ticket ? `armada answer --note ${c.ticket.id} "<the owner's changes>", once you told its worker; then armada merge ${n} --ask-owner again on its next hand-back` : `armada merge ${n} --ask-owner --reason "<why>" once the changes are made`;
|
|
5276
|
+
} else if (approval.state === "stale") {
|
|
5277
|
+
problem = `the owner approved #${n} at ${approval.validation.pr?.headSha}, but its head is now ${c.sha}: a new head needs a new approval`;
|
|
5278
|
+
next = `armada merge ${n} --ask-owner --reason "<why the owner must see it>"`;
|
|
5279
|
+
} else if (rule && !reason) {
|
|
5280
|
+
problem = `the merge rule asks you to judge #${n}: look at its files and what users will see, and record why`;
|
|
5281
|
+
next = judge;
|
|
5282
|
+
} else if (c.ticket)
|
|
5283
|
+
decided = rule ? `merged on its own (rule: ${rule})${reason ? `: ${reason}` : ""}` : `merged on its own (no merge rule)${reason ? `: ${reason}` : ""}`;
|
|
5284
|
+
if (unreadable && !rule && fleet)
|
|
5285
|
+
c.warnings.push(`the owner's approvals of #${n} could not be read (${unreadable}); none is required without a merge rule`);
|
|
5286
|
+
if (problem) {
|
|
5287
|
+
if (dryRun)
|
|
5288
|
+
return { lines: [...lines, `Not mergeable yet: ${problem}`, `Next: ${next}`], decided: null };
|
|
5289
|
+
throw new Refusal(`#${n}${c.ticket ? ` (${c.ticket.id})` : ""} cannot be merged: ${problem}`, next);
|
|
5290
|
+
}
|
|
5291
|
+
return { lines: decided ? [...lines, `Decided: ${decided}.`] : lines, decided };
|
|
5292
|
+
}
|
|
5293
|
+
async function askOwnerToMerge(ctx, input) {
|
|
5294
|
+
const reason = input.reason.replace(/\s+/g, " ").trim();
|
|
5295
|
+
if (!reason)
|
|
5296
|
+
throw new Refusal("say why the owner must see this merge", `armada merge ${input.pr} --ask-owner --reason "<what in it the owner checks>"`);
|
|
5297
|
+
const { fleet, warning } = await ctx.fleet();
|
|
5298
|
+
if (!fleet)
|
|
5299
|
+
throw new Refusal(`asking the owner needs Armada (${warning ?? "not signed in"}); nothing was asked`, "armada login, then the same command again");
|
|
5300
|
+
const pull = await readSettled(ctx, input.pr);
|
|
5301
|
+
if (pull.state !== "open")
|
|
5302
|
+
throw new Refusal(`#${pull.number} is ${pull.state}: there is nothing to approve`, `gh pr view ${pull.number}`);
|
|
5303
|
+
const ticket = await readTicketFor(ctx, pull, { pr: input.pr, ticket: input.ticket ?? null });
|
|
5304
|
+
if (!ticket)
|
|
5305
|
+
throw new Refusal(`#${pull.number} names no ticket`, `armada merge ${pull.number} --ticket <id> --ask-owner`);
|
|
5306
|
+
const warnings = [...ticket.warnings];
|
|
5307
|
+
let preview = null;
|
|
5308
|
+
try {
|
|
5309
|
+
preview = await ctx.forge.preview?.(pull.headSha) ?? null;
|
|
5310
|
+
} catch (err) {
|
|
5311
|
+
warnings.push(`no preview link: ${err instanceof Error ? err.message : String(err)}`);
|
|
5312
|
+
}
|
|
5313
|
+
const { url } = await fleet.validate({
|
|
5314
|
+
ticket: ticket.id,
|
|
5315
|
+
kind: "merge",
|
|
5316
|
+
what: pull.title || `Pull request #${pull.number}`,
|
|
5317
|
+
reason,
|
|
5318
|
+
choices: null,
|
|
5319
|
+
pr: {
|
|
5320
|
+
number: pull.number,
|
|
5321
|
+
url: pull.url,
|
|
5322
|
+
title: pull.title,
|
|
5323
|
+
headSha: pull.headSha,
|
|
5324
|
+
files: pull.files ?? null,
|
|
5325
|
+
additions: pull.additions ?? null,
|
|
5326
|
+
deletions: pull.deletions ?? null,
|
|
5327
|
+
ci: pull.ci ?? null,
|
|
5328
|
+
preview
|
|
5329
|
+
},
|
|
5330
|
+
attachments: []
|
|
5331
|
+
});
|
|
5332
|
+
await ctx.linear.comment(ticket.uuid, `Owner approval asked for the merge of PR #${pull.number} at ${pull.headSha}: ${reason}
|
|
5333
|
+
|
|
5334
|
+
${url}`);
|
|
5335
|
+
const rule = ctx.config.policy.mergeApproval;
|
|
5336
|
+
return {
|
|
5337
|
+
merged: false,
|
|
5338
|
+
pr: {
|
|
5339
|
+
number: pull.number,
|
|
5340
|
+
url: pull.url,
|
|
5341
|
+
title: pull.title,
|
|
5342
|
+
base: pull.baseRef,
|
|
5343
|
+
headSha: pull.headSha,
|
|
5344
|
+
mergeCommit: null
|
|
5345
|
+
},
|
|
5346
|
+
ticket: { id: ticket.id, url: ticket.url },
|
|
5347
|
+
lines: [
|
|
5348
|
+
...rule ? [`Merge rule (armada.toml [policy] merge_approval): "${rule}"`] : [],
|
|
5349
|
+
`Asked the owner to approve the merge of #${pull.number} at ${pull.headSha}${preview ? ` (preview ${preview})` : ""}: ${reason}`,
|
|
5350
|
+
`Approval link, posted on ${ticket.id}: ${url}`,
|
|
5351
|
+
`The owner's decision arrives in your inbox; once approved, armada merge ${pull.number}. A new head needs a new approval.`
|
|
5352
|
+
],
|
|
5353
|
+
hints: [],
|
|
5354
|
+
workers: [],
|
|
5355
|
+
workersListed: false,
|
|
5356
|
+
archive: null,
|
|
5357
|
+
warnings
|
|
5358
|
+
};
|
|
5359
|
+
}
|
|
5040
5360
|
async function mergePinned(ctx, pull, sha, ticket) {
|
|
5041
5361
|
const n = `#${pull.number}`;
|
|
5042
5362
|
const closeByHand = ticket ? `; if it merged, close ${ticket} by hand` : "";
|
|
@@ -5098,7 +5418,7 @@ async function closeTicket(ctx, ticket, merged, c, unlocked) {
|
|
|
5098
5418
|
});
|
|
5099
5419
|
if (!ticket.prs.some((p) => p.url === merged.url))
|
|
5100
5420
|
await ctx.linear.linkUrl(ticket.uuid, merged.url, merged.title || `Pull request #${merged.number}`);
|
|
5101
|
-
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)" : ""}`);
|
|
5421
|
+
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)" : ""}${c.decided ? `; ${c.decided}` : ""}`);
|
|
5102
5422
|
return [
|
|
5103
5423
|
`${ticket.id}: ${done ? `moved to ${done.name}` : "state unchanged"}, agent and ready labels removed, merged status posted.`
|
|
5104
5424
|
];
|
|
@@ -5155,7 +5475,8 @@ async function mergePullRequest(ctx, input) {
|
|
|
5155
5475
|
const run = { pin: null, updated: new Map, lineages: new Map };
|
|
5156
5476
|
if (input.dryRun) {
|
|
5157
5477
|
const c = await checklist(ctx, input, run);
|
|
5158
|
-
|
|
5478
|
+
const owner = await ownerDecision(ctx, input, c, true);
|
|
5479
|
+
return outcome(c, false, null, [...c.lines, ...owner.lines, "Dry run: nothing was merged."], [], null);
|
|
5159
5480
|
}
|
|
5160
5481
|
if (!input.wait)
|
|
5161
5482
|
return locked(ctx, input, run);
|
|
@@ -5184,6 +5505,9 @@ async function locked(ctx, input, run) {
|
|
|
5184
5505
|
const body = async (renew) => {
|
|
5185
5506
|
const c = await checklist(ctx, input, run);
|
|
5186
5507
|
c.warnings.unshift(...early);
|
|
5508
|
+
const owner = await ownerDecision(ctx, input, c, false);
|
|
5509
|
+
c.lines.push(...owner.lines);
|
|
5510
|
+
c.decided = owner.decided;
|
|
5187
5511
|
await recheck(ctx, input, run, c);
|
|
5188
5512
|
if (!await renew())
|
|
5189
5513
|
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`);
|
|
@@ -5230,7 +5554,8 @@ async function after(ctx, c, merged, lines) {
|
|
|
5230
5554
|
number: merged.number,
|
|
5231
5555
|
url: merged.url,
|
|
5232
5556
|
mergeCommit: merged.mergeCommit,
|
|
5233
|
-
headSha: merged.headSha
|
|
5557
|
+
headSha: merged.headSha,
|
|
5558
|
+
decision: c.decided ?? null
|
|
5234
5559
|
})) : null;
|
|
5235
5560
|
if (live$?.resolved)
|
|
5236
5561
|
lines.push(`Hand-back resolved in the coordinator's inbox.`);
|
|
@@ -5284,10 +5609,7 @@ function outcome(c, merged, pr, lines, workers, archive) {
|
|
|
5284
5609
|
warnings: c.warnings
|
|
5285
5610
|
};
|
|
5286
5611
|
}
|
|
5287
|
-
|
|
5288
|
-
var SAME_REPORT_MS = 2 * 60000;
|
|
5289
|
-
var MIN3 = 60000;
|
|
5290
|
-
var HOUR = 60 * MIN3;
|
|
5612
|
+
|
|
5291
5613
|
// ../core/src/projects.ts
|
|
5292
5614
|
var message = (err) => err instanceof Error ? err.message : String(err);
|
|
5293
5615
|
async function readProjectConfig(p, opts) {
|
|
@@ -5311,11 +5633,12 @@ async function readProjectConfig(p, opts) {
|
|
|
5311
5633
|
return fallback(message(err));
|
|
5312
5634
|
}
|
|
5313
5635
|
}
|
|
5636
|
+
|
|
5314
5637
|
// ../core/src/skills.ts
|
|
5315
5638
|
import { createHash as createHash2 } from "node:crypto";
|
|
5316
5639
|
|
|
5317
5640
|
// ../../skills/armada-coordinator/MERGE.md
|
|
5318
|
-
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.\n6. A dashboard pull request (one that changes Armada's own dashboard, `packages/dashboard`): compare with /agents and /design. Open each page it changes on its preview or the demo next to `/agents` and `/design`. The header bar, the toolbar, the sections and the rows must match them. A page with a title of its own, another font or its own list style goes back to the worker.\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";
|
|
5641
|
+
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## The owner's merge rule: `--reason` and `--ask-owner`\n\n`[policy] merge_approval` in `armada.toml` says in plain words which merges the owner wants to approve first, for example \"merge on your own, except front-end changes: send me a link to check them first\". Without it you merge everything on your own. With it, `armada merge` prints the rule and you judge each pull request: look at its files and at what users will see, then record why either way.\n\n- It may merge on your own: `armada merge <pr> --reason \"<why>\"`, for example `--reason \"CLI only\"`. The ticket's merged comment and the dashboard say `merged on its own (rule: …): CLI only`.\n- The rule keeps it for the owner: `armada merge <pr> --ask-owner --reason \"<why>\"`, for example `--reason \"touches components/timeline\"`. It merges nothing: it records the pull request as GitHub shows it now (title, files with +/−, CI, the preview deployment of its head) with the ticket's screenshots on the owner's Validations page, posts the approval link (`https://<dashboard>/approve/<id>`) on the ticket and prints it. Send it to the owner. Their decision arrives in your inbox as a `decision` item (it wakes `armada watch`): approved, run `armada merge <pr>`, which records `approved by <owner> at <time>`; changes requested, relay them to the worker.\n- Once the owner was asked about a pull request, `armada merge` refuses it until they approved that exact head; a head that is it with only main merged in still counts. Any other new head needs `--ask-owner` again.\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.\n6. A dashboard pull request (one that changes Armada's own dashboard, `packages/dashboard`): compare with /agents and /design. Open each page it changes on its preview or the demo next to `/agents` and `/design`. The header bar, the toolbar, the sections and the rows must match them. A page with a title of its own, another font or its own list style goes back to the worker.\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";
|
|
5319
5642
|
|
|
5320
5643
|
// ../../skills/armada-coordinator/SKILL.md
|
|
5321
5644
|
var SKILL_default = `---
|
|
@@ -5344,19 +5667,21 @@ A coordinator may start cold, on a laptop or in a fresh cloud session, with noth
|
|
|
5344
5667
|
## Loop
|
|
5345
5668
|
|
|
5346
5669
|
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.
|
|
5347
|
-
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
|
|
5670
|
+
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: \`armada ask-owner <ticket> "<question>" --choices "<a> | <b>"\` puts it on the owner's Validations page and prints the link to send them; their pick arrives as a \`decision\` item. 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.
|
|
5348
5671
|
3. **Carry out the owner's dashboard requests.** They are the owner's word, signed with their name; they never reached a worker.
|
|
5349
5672
|
- \`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.
|
|
5350
5673
|
- \`launch-request\`: launch the ticket as in step 5. A request may name a label-routed profile or one the owner chose; otherwise choose from the profiles' \`when\` rules. Pass \`--profile\` and \`--reason\` when a choice or override is needed. 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.
|
|
5674
|
+
- \`decision\` (THE-885): the owner decided something you or a worker sent to their Validations page. A merge they approved: \`armada merge <pr>\`. Changes requested: deliver them in the worker's session with the runtime guide. A validation approved: tell the worker; for a design ticket, \`armada done <ticket>\` records the design on the ticket and closes it, then cut the ticket that builds it, blocked by this one. A choice to a question you escalated: deliver it as the answer. Then \`armada answer <item> "<what you did>"\`.
|
|
5351
5675
|
Done when the inbox shows no open request.
|
|
5352
5676
|
4. **Check silent workers and workers that never started** with the runtime guide's *status* section. A worker that is still working gets a nudge to report; a worker that died is relaunched or its ticket released. A \`not-started\` entry is a worker launched that has not claimed after \`[policy] not_started_minutes\` (10 by default); it says whether the worker never used its launch token (it never reached its \`armada login\` line: an install that failed, a prompt cut short) or signed in and stopped before its claim. Read its session: a worker stuck on a setup choice gets a message to take the safe option and go on; one that is gone is launched again with a new brief, or its launch revoked on the dashboard's Workers page. The entry clears on the claim.
|
|
5353
5677
|
5. **Launch ready tickets** that do not collide with work in flight, one at a time:
|
|
5354
5678
|
- pick the ticket from the frontier in \`armada status\`;
|
|
5355
5679
|
- run \`armada brief <ticket>\` and resolve its warnings. A matching \`[[conductor.routing]]\` label rule wins. Otherwise, when profiles have \`when\` rules, the brief prints **Choose a profile** and mints no launch token. Read the ticket and its parent spec; match each profile's plain-language rule and prefer the one covering most files the ticket will change. If it spans front end and back end, choose where most of the work is and say so. Run \`armada brief <ticket> --profile <name> --reason "<why>"\`, naming the files or work that justify the choice. Armada never calls a model to classify tickets. Only projects without \`when\` rules fall back to \`default_profile\` (or their only profile). Override a matching label rule only when the labels mislead, with the same reasoned command. Keep \`--profile\` and \`--reason\` on every subsequent \`--prompt\` call; the reason reaches the worker's claim, status and agent page;
|
|
5680
|
+
- judge \`[[policy.validation]]\` when \`armada.toml\` has rules, the same way: each says in plain words which kind of ticket the owner must see first (\`when\`) and what the worker shows (\`then\`). Most tickets are none: \`armada brief <ticket> --validation none\` (no reason needed). When one applies (a design ticket, a new screen's look), \`--validation <n> --validation-reason "<why this ticket is one>"\`: the prompt then tells the worker to submit its work with \`armada validate\` and stop, and the claim records your judgement. The brief refuses until you judge, and prints the command to copy;
|
|
5356
5681
|
- write the prompt with one launch call: \`armada brief <ticket> --prompt --profile-line > <file>\`, keeping the chosen \`--profile\` and \`--reason\` flags. Stdout is the exact prompt; stderr gives the selected profile, agent, model, effort, runtime and reason for the runtime's launch settings. Human and \`--json\` previews are read-only and create no token or launch row. **The launch message is that \`--prompt\` output, never text cut from either preview**. Cancel a minted launch with \`armada launch revoke <ticket>\` if the runtime launch fails or you change your mind; a worker that has claimed must use \`armada release\` instead. 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;
|
|
5357
5682
|
- 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;
|
|
5358
5683
|
- 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.
|
|
5359
|
-
6. **Merge handed-back pull requests** one at a time with \`armada merge <pr
|
|
5684
|
+
6. **Merge handed-back pull requests** one at a time with \`armada merge <pr>\`. When \`armada.toml\` has \`[policy] merge_approval\`, judge each pull request against it in plain words: look at its files and what users will see. When it may merge on its own, \`armada merge <pr> --reason "<why>"\` (for example "CLI only"); when the rule keeps it for the owner, \`armada merge <pr> --ask-owner --reason "<why>"\` (for example "touches components/timeline"): it merges nothing, posts the approval link on the ticket and prints it; send it to the owner, and merge once their approval arrives in your inbox. A new head needs a new approval. Either way the merge records how it was decided. Without the rule, merge on your own (\`--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.
|
|
5360
5685
|
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.
|
|
5361
5686
|
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.
|
|
5362
5687
|
|
|
@@ -5512,6 +5837,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
|
|
|
5512
5837
|
- **Report at each real step** with \`armada report <phase> --message "<what changed, what is next>"\`: the plan, meaningful implementation progress, blockers, tests, shipping and hand-back. The same phase is allowed. Reports are progress, not liveness: \`policy.silence_minutes\` measures missing heartbeats (15 by default); \`policy.quiet_minutes\` is a coordinator-only reminder for a live worker without a report (45 by default). Never post empty reports just to look alive.
|
|
5513
5838
|
- **Keep going on setup choices.** When setup needs a choice (an install fallback, a retry, a missing tool), pick the safe option, say which in your next report, and keep going: never stop to ask about it. Ask only for product decisions.
|
|
5514
5839
|
- **Ask instead of guessing** when a choice changes the ticket's outcome: \`armada ask "<question and your recommendation>" --options "<a> | <b>"\`. Your phase becomes \`blocked\` and the question reaches the coordinator's inbox. Then **stop and end your turn**: the answer arrives as a message in this session, not in a command's output. When it arrives, report the phase you resume, for example \`armada report implementing --message "resumed: <the decision>"\`. Decide reversible technical choices yourself and record each one, with its reason, on the ticket and in the pull request.
|
|
5840
|
+
- **Show the owner when your brief says so.** A brief with an "Owner validation" block names what the owner must see before the work goes on (a design ticket: the mockup itself). Produce it, then \`armada validate "<what to check>" --attach <files|https-urls>... [--caption "<text>"]\`: the attachments and the question go to the owner's Validations page on Armada, your phase becomes \`awaiting-validation\`, and the command prints the approval link. Then **stop and end your turn**: the coordinator relays the owner's decision in this session. On "Request changes", revise and run \`armada validate\` again (it replaces the open one); on approval, report the phase you resume, or, for a design ticket, stop: the coordinator closes it and building it is another ticket. Never merge or build what the owner has not approved.
|
|
5515
5841
|
- **The ticket is the source of truth.** Read it, its parent spec and the hand-back comments of its merged blockers in full before planning.
|
|
5516
5842
|
- Work only in your own branch and worktree. Never touch another agent's checkout, and stop only the processes you started.
|
|
5517
5843
|
- Never print, commit or log a secret.
|
|
@@ -5532,7 +5858,7 @@ If you stop without finishing, run \`armada release --reason "<why>"\` so the ti
|
|
|
5532
5858
|
|
|
5533
5859
|
## When a command is missing
|
|
5534
5860
|
|
|
5535
|
-
This skill is versioned with Armada; an older CLI may lack a command (\`armada --help\` lists them). Do the same step by hand in the tracker, keeping the protocol: exactly one label from the phase group (\`planning\`, \`awaiting-approval\`, \`implementing\`, \`shipping\`, \`blocked\`, \`ready-to-merge\`) and one from the runtime group; a first comment \`Agent claim — runtime: <runtime> · session: <id> · branch: <branch> · started: <ISO date>\`; and every comment starting with \`Agent status: <phase> — <one-line summary>\`.
|
|
5861
|
+
This skill is versioned with Armada; an older CLI may lack a command (\`armada --help\` lists them). Do the same step by hand in the tracker, keeping the protocol: exactly one label from the phase group (\`planning\`, \`awaiting-approval\`, \`implementing\`, \`shipping\`, \`blocked\`, \`ready-to-merge\`, \`awaiting-validation\`) and one from the runtime group; a first comment \`Agent claim — runtime: <runtime> · session: <id> · branch: <branch> · started: <ISO date>\`; and every comment starting with \`Agent status: <phase> — <one-line summary>\`.
|
|
5536
5862
|
`;
|
|
5537
5863
|
|
|
5538
5864
|
// ../core/src/skills.ts
|
|
@@ -5905,6 +6231,7 @@ ${SHIP_ARTIFACTS}
|
|
|
5905
6231
|
return plan;
|
|
5906
6232
|
}
|
|
5907
6233
|
var planIsEmpty = (p) => !p.writes.length && !p.removes.length && !p.links.length;
|
|
6234
|
+
|
|
5908
6235
|
// ../core/src/status.ts
|
|
5909
6236
|
var STATUS_SCHEMA_VERSION = 1;
|
|
5910
6237
|
function routeOf(config, labels) {
|
|
@@ -6063,8 +6390,132 @@ async function loadStatus(config, opts) {
|
|
|
6063
6390
|
now: now()
|
|
6064
6391
|
});
|
|
6065
6392
|
}
|
|
6393
|
+
|
|
6394
|
+
// ../core/src/validate.ts
|
|
6395
|
+
var PHASE = "awaiting-validation";
|
|
6396
|
+
async function submitValidation(ctx, input) {
|
|
6397
|
+
const what = input.what.trim();
|
|
6398
|
+
const usage = input.kind === "question" ? `armada ask-owner ${input.ticket} "<question>" --choices "<a> | <b>"` : `armada validate "<what to check>" --attach <file|url>`;
|
|
6399
|
+
if (!what)
|
|
6400
|
+
throw new Refusal("say what the owner checks", usage);
|
|
6401
|
+
if (what.length > VALIDATION_LIMITS.what)
|
|
6402
|
+
throw new Refusal(`what to check has at most ${VALIDATION_LIMITS.what} characters`, usage);
|
|
6403
|
+
if (input.kind === "question" && !input.choices?.length)
|
|
6404
|
+
throw new Refusal("a question for the owner needs its choices", usage);
|
|
6405
|
+
const ticket = await readOpenTicket(ctx, input.ticket);
|
|
6406
|
+
if (input.worker && ticket.agentPhase !== PHASE) {
|
|
6407
|
+
const problem = transitionProblem(ticket.agentPhase, PHASE);
|
|
6408
|
+
if (problem)
|
|
6409
|
+
throw new Refusal(`${ticket.id}: ${problem}`, `armada report <phase> --message "<what you did>"`);
|
|
6410
|
+
}
|
|
6411
|
+
const { fleet, warning } = await ctx.fleet();
|
|
6412
|
+
if (!fleet)
|
|
6413
|
+
throw new Refusal(`the owner validates on Armada, which this terminal cannot reach (${warning ?? "not signed in"}); nothing was sent`, "armada login, then the same command again");
|
|
6414
|
+
const uploaded = input.upload ? await input.upload() : [];
|
|
6415
|
+
const { validation, url } = await fleet.validate({
|
|
6416
|
+
ticket: ticket.id,
|
|
6417
|
+
kind: input.kind,
|
|
6418
|
+
what,
|
|
6419
|
+
reason: null,
|
|
6420
|
+
choices: input.choices,
|
|
6421
|
+
pr: null,
|
|
6422
|
+
attachments: [...input.attachments, ...uploaded]
|
|
6423
|
+
});
|
|
6424
|
+
const [first = "", ...rest] = what.split(`
|
|
6425
|
+
`);
|
|
6426
|
+
if (input.worker) {
|
|
6427
|
+
const out = await reportPhase(ctx, {
|
|
6428
|
+
ticket: ticket.id,
|
|
6429
|
+
phase: PHASE,
|
|
6430
|
+
message: [`${first.trim()} — ${url}`, rest.join(`
|
|
6431
|
+
`).trim()].filter(Boolean).join(`
|
|
6432
|
+
`)
|
|
6433
|
+
});
|
|
6434
|
+
return {
|
|
6435
|
+
...out,
|
|
6436
|
+
lines: [
|
|
6437
|
+
...out.lines,
|
|
6438
|
+
`Validation #${validation.id} waits for the owner: ${url}`,
|
|
6439
|
+
"Stop here until the owner decides: the coordinator relays the decision in this session. On changes, revise and run armada validate again."
|
|
6440
|
+
],
|
|
6441
|
+
validation,
|
|
6442
|
+
link: url
|
|
6443
|
+
};
|
|
6444
|
+
}
|
|
6445
|
+
const label = input.kind === "question" ? "Question for the owner" : "Owner validation asked";
|
|
6446
|
+
const choices = input.choices?.length ? `
|
|
6447
|
+
|
|
6448
|
+
Choices: ${input.choices.join(" | ")}` : "";
|
|
6449
|
+
await ctx.linear.comment(ticket.uuid, `${label}: ${what}${choices}
|
|
6450
|
+
|
|
6451
|
+
${url}`);
|
|
6452
|
+
return {
|
|
6453
|
+
ticket: ticket.id,
|
|
6454
|
+
url: ticket.url,
|
|
6455
|
+
lines: [
|
|
6456
|
+
`${input.kind === "question" ? "Question" : "Validation"} #${validation.id} for ${ticket.id} waits for the owner: ${url}`,
|
|
6457
|
+
"The link is posted on the ticket; the owner's decision arrives in your inbox."
|
|
6458
|
+
],
|
|
6459
|
+
warnings: [...ticket.warnings],
|
|
6460
|
+
inbox: null,
|
|
6461
|
+
validation,
|
|
6462
|
+
link: url
|
|
6463
|
+
};
|
|
6464
|
+
}
|
|
6465
|
+
async function closeValidated(ctx, input) {
|
|
6466
|
+
const { config, linear } = ctx;
|
|
6467
|
+
const ticket = await readOpenTicket(ctx, input.ticket);
|
|
6468
|
+
const { fleet, warning } = await ctx.fleet();
|
|
6469
|
+
if (!fleet)
|
|
6470
|
+
throw new Refusal(`the owner's decisions are on Armada, which this terminal cannot reach (${warning ?? "not signed in"})`, "armada login, then the same command again");
|
|
6471
|
+
const v = lastValidation(await fleet.validations({ ticket: ticket.id }), ticket.id);
|
|
6472
|
+
if (v?.decision?.outcome !== "approved" && v?.decision?.outcome !== "answered")
|
|
6473
|
+
throw new Refusal(v ? `${ticket.id}'s validation #${v.id} is ${v.decision ? decidedLine(v.decision) : "still waiting for the owner"}: only an approved one closes the ticket` : `${ticket.id} has no validation the owner approved`, v && !v.decision ? "armada inbox --wait: the owner's decision arrives there" : `armada validate ${ticket.id} "<what to check>"`);
|
|
6474
|
+
const decided = decidedLine(v.decision);
|
|
6475
|
+
const groups = config.tracker.labels;
|
|
6476
|
+
const done = firstState(ticket.states, "completed");
|
|
6477
|
+
await linear.updateTicket(ticket.uuid, {
|
|
6478
|
+
...done ? { stateId: done.id } : {},
|
|
6479
|
+
removeLabelIds: [
|
|
6480
|
+
...others(ticket, groups.phaseGroup, null),
|
|
6481
|
+
...others(ticket, groups.runtimeGroup, null),
|
|
6482
|
+
...ticket.labels.filter((label) => label.name === config.tracker.readyLabel).map((label) => label.id)
|
|
6483
|
+
]
|
|
6484
|
+
});
|
|
6485
|
+
const attachments = v.attachments.map((id) => `- ${input.attachmentUrl(id)}`);
|
|
6486
|
+
const summary = `done without a pull request: validation #${v.id} ${decided}`;
|
|
6487
|
+
await linear.comment(ticket.uuid, [
|
|
6488
|
+
`Agent status: merged — ${summary}`,
|
|
6489
|
+
`What the owner validated:
|
|
6490
|
+
${v.what}`,
|
|
6491
|
+
v.decision.note ? `The owner's note:
|
|
6492
|
+
${v.decision.note}` : "",
|
|
6493
|
+
attachments.length ? `Attachments:
|
|
6494
|
+
${attachments.join(`
|
|
6495
|
+
`)}` : ""
|
|
6496
|
+
].filter(Boolean).join(`
|
|
6497
|
+
|
|
6498
|
+
`));
|
|
6499
|
+
const warnings = [...ticket.warnings];
|
|
6500
|
+
try {
|
|
6501
|
+
await fleet.done({ ticket: ticket.id, message: summary });
|
|
6502
|
+
} catch (err) {
|
|
6503
|
+
warnings.push(`Armada did not record it (${err instanceof Error ? err.message : String(err)})`);
|
|
6504
|
+
}
|
|
6505
|
+
return {
|
|
6506
|
+
ticket: ticket.id,
|
|
6507
|
+
url: ticket.url,
|
|
6508
|
+
lines: [
|
|
6509
|
+
`${ticket.id}: ${done ? `moved to ${done.name}` : "state unchanged"}, agent and ready labels removed; ${summary}.`,
|
|
6510
|
+
"Building it is a separate ticket: cut it, blocked by this one."
|
|
6511
|
+
],
|
|
6512
|
+
warnings,
|
|
6513
|
+
inbox: null,
|
|
6514
|
+
validation: v
|
|
6515
|
+
};
|
|
6516
|
+
}
|
|
6066
6517
|
// package.json
|
|
6067
|
-
var version = "0.2.
|
|
6518
|
+
var version = "0.2.22";
|
|
6068
6519
|
|
|
6069
6520
|
// src/attach.ts
|
|
6070
6521
|
import { resolve } from "node:path";
|
|
@@ -6730,13 +7181,28 @@ async function claim(io, config, credentials, a) {
|
|
|
6730
7181
|
}
|
|
6731
7182
|
if (!handle)
|
|
6732
7183
|
throw new UsageError("--handle is required: the runtime's id for this session, e.g. <workspace>/<session>");
|
|
7184
|
+
let validation = null;
|
|
7185
|
+
if (a.options.validation !== undefined)
|
|
7186
|
+
try {
|
|
7187
|
+
validation = chooseValidations(config.policy.validations, {
|
|
7188
|
+
ticket: ticket.toUpperCase(),
|
|
7189
|
+
requested: a.options.validation,
|
|
7190
|
+
reason: a.options["validation-reason"] ?? null,
|
|
7191
|
+
command: `armada claim ${ticket.toUpperCase()} --runtime ${runtime} --handle ${handle}`
|
|
7192
|
+
});
|
|
7193
|
+
} catch (err) {
|
|
7194
|
+
if (err instanceof ValidationChoiceError)
|
|
7195
|
+
throw new UsageError(err.message, err.next);
|
|
7196
|
+
throw err;
|
|
7197
|
+
}
|
|
6733
7198
|
return withContext(io, config, credentials, a.json, (ctx) => claimTicket(ctx, {
|
|
6734
7199
|
ticket: ticket.toUpperCase(),
|
|
6735
7200
|
runtime,
|
|
6736
7201
|
handle,
|
|
6737
7202
|
...a.options.branch ? { branch: a.options.branch } : {},
|
|
6738
7203
|
profile,
|
|
6739
|
-
reason
|
|
7204
|
+
reason,
|
|
7205
|
+
validation
|
|
6740
7206
|
}));
|
|
6741
7207
|
}
|
|
6742
7208
|
async function report(io, config, credentials, a) {
|
|
@@ -6895,7 +7361,7 @@ function renderInbox(r, next) {
|
|
|
6895
7361
|
`)}
|
|
6896
7362
|
`;
|
|
6897
7363
|
}
|
|
6898
|
-
async function
|
|
7364
|
+
async function inbox(io, config, credentials, a) {
|
|
6899
7365
|
if (a.rest.length)
|
|
6900
7366
|
throw new UsageError(`unexpected argument ${a.rest[0]}`);
|
|
6901
7367
|
const wait = a.options.wait === "true";
|
|
@@ -7004,7 +7470,7 @@ var shown = (io, items, inFlight) => ({
|
|
|
7004
7470
|
...inFlight ? { inFlight, readAt: now(io).toISOString() } : {},
|
|
7005
7471
|
stopped: null
|
|
7006
7472
|
});
|
|
7007
|
-
async function
|
|
7473
|
+
async function watch(io, config, credentials, a, configPath) {
|
|
7008
7474
|
if (a.rest.length)
|
|
7009
7475
|
throw new UsageError(`unexpected argument ${a.rest[0]}`);
|
|
7010
7476
|
const project = config.project.slug;
|
|
@@ -7109,7 +7575,9 @@ function hideLaunchToken(b) {
|
|
|
7109
7575
|
}
|
|
7110
7576
|
function renderBrief(b) {
|
|
7111
7577
|
const p = b.profile;
|
|
7112
|
-
const
|
|
7578
|
+
const v = b.validation;
|
|
7579
|
+
const validationFlags = v ? v.rules.length ? ` --validation ${v.rules.map((r) => r.index).join(",")}${v.reason ? ` --validation-reason ${shellWord(v.reason)}` : ""}` : " --validation none" : "";
|
|
7580
|
+
const promptCommand = `armada brief ${b.ticket.id}${p && (b.routing?.source === "requested" || b.routing?.reason) ? ` --profile ${shellWord(p.name)}${b.routing?.reason ? ` --reason ${shellWord(b.routing.reason)}` : ""}` : ""}${validationFlags} --prompt`;
|
|
7113
7581
|
const width = Math.max(...b.environment.map((v) => v.name.length + (v.value ? v.value.length + 1 : 0)));
|
|
7114
7582
|
const out = [
|
|
7115
7583
|
`Brief for ${b.ticket.id} — ${b.ticket.title} (${b.ticket.status})`,
|
|
@@ -7119,6 +7587,9 @@ function renderBrief(b) {
|
|
|
7119
7587
|
`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"}`,
|
|
7120
7588
|
...b.routing ? [`Chosen by: ${b.routing.why}`] : [],
|
|
7121
7589
|
`Plans: ${b.plans.rule === "pre-approved" ? "pre-approved" : "wait for approval"} (${b.plans.why})`,
|
|
7590
|
+
...v ? [
|
|
7591
|
+
`Validation: ${v.rules.length ? `the owner validates: ${v.rules.map((r) => `rule ${r.index} (${r.when})`).join(", ")}${v.reason ? ` — ${v.reason}` : ""}` : "no [[policy.validation]] rule applies"}`
|
|
7592
|
+
] : [],
|
|
7122
7593
|
...b.conventions ? [`Conventions: ${b.conventions.path} (under "Project conventions" in the prompt)`] : [],
|
|
7123
7594
|
`Repository: ${b.repository.url}`,
|
|
7124
7595
|
`Branch: ${b.ticket.branch ?? "none suggested by Linear"} (the worker renames its workspace branch to it)`,
|
|
@@ -7178,7 +7649,18 @@ function launcher(io, config, credentials) {
|
|
|
7178
7649
|
}
|
|
7179
7650
|
};
|
|
7180
7651
|
}
|
|
7181
|
-
|
|
7652
|
+
function briefCommand(ticket, a) {
|
|
7653
|
+
const o = a.options;
|
|
7654
|
+
return [
|
|
7655
|
+
`armada brief ${ticket}`,
|
|
7656
|
+
o.profile ? ` --profile ${shellWord(o.profile)}` : "",
|
|
7657
|
+
o.reason ? ` --reason ${shellWord(o.reason)}` : "",
|
|
7658
|
+
o.prompt === "true" ? " --prompt" : "",
|
|
7659
|
+
o["profile-line"] === "true" ? " --profile-line" : "",
|
|
7660
|
+
a.json ? " --json" : ""
|
|
7661
|
+
].join("");
|
|
7662
|
+
}
|
|
7663
|
+
async function brief(io, config, credentials, a, version, configPath) {
|
|
7182
7664
|
const [ticket, ...extra] = a.rest;
|
|
7183
7665
|
if (!ticket)
|
|
7184
7666
|
throw new UsageError('brief needs a ticket: armada brief <ticket> [--profile <name> [--reason "<why>"]]');
|
|
@@ -7218,12 +7700,17 @@ async function brief2(io, config, credentials, a, version, configPath) {
|
|
|
7218
7700
|
launch: launcher(io, config, credentials),
|
|
7219
7701
|
npm: (v) => checkPublished(v, io.fetch ?? fetch),
|
|
7220
7702
|
conventions,
|
|
7703
|
+
validation: {
|
|
7704
|
+
requested: a.options.validation ?? null,
|
|
7705
|
+
reason: a.options["validation-reason"] ?? null,
|
|
7706
|
+
command: briefCommand(ticket.toUpperCase(), a)
|
|
7707
|
+
},
|
|
7221
7708
|
...io.fetch ? { fetch: io.fetch } : {},
|
|
7222
7709
|
...io.now ? { now: io.now } : {}
|
|
7223
7710
|
});
|
|
7224
7711
|
} catch (err) {
|
|
7225
7712
|
if (err instanceof BriefError)
|
|
7226
|
-
throw new UsageError(err.message);
|
|
7713
|
+
throw new UsageError(err.message, err.next ?? undefined);
|
|
7227
7714
|
throw err;
|
|
7228
7715
|
}
|
|
7229
7716
|
if ("selection" in b) {
|
|
@@ -7617,7 +8104,7 @@ async function doctor(io, json, armadaVersion) {
|
|
|
7617
8104
|
|
|
7618
8105
|
// src/heartbeat.ts
|
|
7619
8106
|
import { createHash as createHash3 } from "node:crypto";
|
|
7620
|
-
async function
|
|
8107
|
+
async function heartbeat(io, config, credentials, args) {
|
|
7621
8108
|
if (args.rest.length)
|
|
7622
8109
|
throw new UsageError("heartbeat takes no positional argument");
|
|
7623
8110
|
const interval = args.options.every ?? "5m";
|
|
@@ -8093,7 +8580,7 @@ function render(o) {
|
|
|
8093
8580
|
`)}
|
|
8094
8581
|
`;
|
|
8095
8582
|
}
|
|
8096
|
-
async function
|
|
8583
|
+
async function merge(io, config, credentials, a, configPath) {
|
|
8097
8584
|
const [arg, ...extra] = a.rest;
|
|
8098
8585
|
if (extra.length)
|
|
8099
8586
|
throw new UsageError(`unexpected argument ${extra[0]}`);
|
|
@@ -8102,6 +8589,13 @@ async function merge2(io, config, credentials, a, configPath) {
|
|
|
8102
8589
|
if (noTicket && a.options.ticket)
|
|
8103
8590
|
throw new UsageError("--no-ticket and --ticket cannot go together");
|
|
8104
8591
|
const wait = !!a.options.wait;
|
|
8592
|
+
const askOwner = a.options["ask-owner"] === "true";
|
|
8593
|
+
if (askOwner && (wait || a.options["dry-run"] || noTicket || a.options["no-lock"]))
|
|
8594
|
+
throw new UsageError("--ask-owner only asks the owner: it goes with --reason (and --ticket), nothing else");
|
|
8595
|
+
if (askOwner && !a.options.reason?.trim())
|
|
8596
|
+
throw new UsageError(`--ask-owner needs --reason: armada merge ${number} --ask-owner --reason "<why the owner must see it>"`);
|
|
8597
|
+
if (noTicket && a.options.reason !== undefined)
|
|
8598
|
+
throw new UsageError("--reason judges a ticket's merge; --no-ticket has none");
|
|
8105
8599
|
if (wait && a.options["dry-run"])
|
|
8106
8600
|
throw new UsageError("--wait and --dry-run cannot go together");
|
|
8107
8601
|
if (!wait && a.options.timeout !== undefined)
|
|
@@ -8131,8 +8625,10 @@ async function merge2(io, config, credentials, a, configPath) {
|
|
|
8131
8625
|
diff: (n) => fetchPullDiff({ ...gh, number: n }),
|
|
8132
8626
|
merge: ghMerge(exec, repoDir, config.github.repository),
|
|
8133
8627
|
commit: (sha) => fetchCommit({ ...gh, sha }),
|
|
8134
|
-
updateBranch: ghUpdateBranch(exec, repoDir, config.github.repository)
|
|
8628
|
+
updateBranch: ghUpdateBranch(exec, repoDir, config.github.repository),
|
|
8629
|
+
preview: (sha) => fetchPreview({ ...gh, sha })
|
|
8135
8630
|
},
|
|
8631
|
+
appUrl: credentials.armadaSignIn ? credentials.armadaApi.url : null,
|
|
8136
8632
|
repo: gitRepo(exec, repoDir),
|
|
8137
8633
|
lockRequired: !!credentials.armadaSignIn,
|
|
8138
8634
|
fleet: async () => live,
|
|
@@ -8154,13 +8650,33 @@ async function merge2(io, config, credentials, a, configPath) {
|
|
|
8154
8650
|
return false;
|
|
8155
8651
|
}
|
|
8156
8652
|
};
|
|
8653
|
+
if (askOwner) {
|
|
8654
|
+
const asked = await askOwnerToMerge(ctx, {
|
|
8655
|
+
pr: number,
|
|
8656
|
+
ticket: a.options.ticket ?? null,
|
|
8657
|
+
reason: a.options.reason ?? ""
|
|
8658
|
+
});
|
|
8659
|
+
const project = config.project.slug;
|
|
8660
|
+
const next = await rearmFor(io, project, {
|
|
8661
|
+
inFlight: (await watchOf(io, project)).state?.inFlight ?? null,
|
|
8662
|
+
open: null
|
|
8663
|
+
});
|
|
8664
|
+
io.stdout(a.json ? `${JSON.stringify({ ...asked, watch: next }, null, 2)}
|
|
8665
|
+
` : `${render(asked)}${next.line}
|
|
8666
|
+
`);
|
|
8667
|
+
for (const w of asked.warnings)
|
|
8668
|
+
io.stderr(`armada: warning: ${w}
|
|
8669
|
+
`);
|
|
8670
|
+
return 0;
|
|
8671
|
+
}
|
|
8157
8672
|
const o = await mergePullRequest(ctx, {
|
|
8158
8673
|
pr: number,
|
|
8159
8674
|
ticket: a.options.ticket ?? null,
|
|
8160
8675
|
noTicket,
|
|
8161
8676
|
wait: wait ? { timeoutMs } : null,
|
|
8162
8677
|
dryRun: !!a.options["dry-run"],
|
|
8163
|
-
noLock: !!a.options["no-lock"]
|
|
8678
|
+
noLock: !!a.options["no-lock"],
|
|
8679
|
+
reason: a.options.reason ?? null
|
|
8164
8680
|
});
|
|
8165
8681
|
const project = config.project.slug;
|
|
8166
8682
|
const coordinator = coordinatorHandle(io);
|
|
@@ -8181,10 +8697,10 @@ async function merge2(io, config, credentials, a, configPath) {
|
|
|
8181
8697
|
}
|
|
8182
8698
|
|
|
8183
8699
|
// src/render.ts
|
|
8184
|
-
var
|
|
8700
|
+
var MIN3 = 60000;
|
|
8185
8701
|
function relative2(iso, now) {
|
|
8186
8702
|
const diff = now - Date.parse(iso);
|
|
8187
|
-
const m = Math.round(Math.abs(diff) /
|
|
8703
|
+
const m = Math.round(Math.abs(diff) / MIN3);
|
|
8188
8704
|
const suffix = diff >= 0 ? "ago" : "from now";
|
|
8189
8705
|
if (m < 1)
|
|
8190
8706
|
return "just now";
|
|
@@ -8560,6 +9076,101 @@ async function runCommand(io, config, credentials, args) {
|
|
|
8560
9076
|
return io.spawn(command, commandArgs, { cwd: io.cwd, env: { ...io.env, ...values } });
|
|
8561
9077
|
}
|
|
8562
9078
|
|
|
9079
|
+
// src/validate.ts
|
|
9080
|
+
var TICKET = /^[A-Za-z][A-Za-z0-9]*-\d+$/;
|
|
9081
|
+
var attachList = (raw) => (raw ?? "").split(`
|
|
9082
|
+
`).map((a) => a.trim()).filter(Boolean);
|
|
9083
|
+
async function ensurePhaseLabel(io, config, credentials) {
|
|
9084
|
+
const apiKey = credentials.linearApiKey;
|
|
9085
|
+
if (!apiKey)
|
|
9086
|
+
return;
|
|
9087
|
+
const opts = { apiKey, ...io.fetch ? { fetch: io.fetch } : {} };
|
|
9088
|
+
const state = await readLabels(config, opts);
|
|
9089
|
+
const groups = state.groups.filter((g) => g.name === config.tracker.labels.phaseGroup && g.id && g.missing.includes("awaiting-validation")).map((g) => ({ ...g, missing: ["awaiting-validation"] }));
|
|
9090
|
+
if (groups.length)
|
|
9091
|
+
await createMissingLabels({ ...state, groups }, opts);
|
|
9092
|
+
}
|
|
9093
|
+
function namedTicket(rest, options) {
|
|
9094
|
+
const [first, second] = rest;
|
|
9095
|
+
const fromOption = options.message !== undefined || options["message-file"] !== undefined;
|
|
9096
|
+
if (first && (second !== undefined || fromOption && TICKET.test(first)))
|
|
9097
|
+
return first.toUpperCase();
|
|
9098
|
+
return null;
|
|
9099
|
+
}
|
|
9100
|
+
async function validate(io, config, credentials, a) {
|
|
9101
|
+
if (a.rest.length > 2)
|
|
9102
|
+
throw new UsageError(`unexpected argument ${a.rest[2]}; quote what to check`);
|
|
9103
|
+
const named = namedTicket(a.rest, a.options);
|
|
9104
|
+
const positional = named ? a.rest[1] : a.rest[0];
|
|
9105
|
+
const fromOption = await readMessage(io, a.options);
|
|
9106
|
+
if (positional !== undefined && fromOption !== null)
|
|
9107
|
+
throw new UsageError("give what to check once: as an argument, --message or --message-file");
|
|
9108
|
+
const what = positional ?? fromOption;
|
|
9109
|
+
if (!what?.trim())
|
|
9110
|
+
throw new UsageError('validate needs what the owner checks: armada validate "<what to check>" --attach <file|url>');
|
|
9111
|
+
if (named && !TICKET.test(named))
|
|
9112
|
+
throw new UsageError(`"${named}" is not a ticket id such as ABC-12`);
|
|
9113
|
+
const ticket = named ?? currentTicket(io, config, a.options.ticket, credentials.workerTickets);
|
|
9114
|
+
const worker = !named && credentials.armadaSignIn?.kind === "worker";
|
|
9115
|
+
const items = attachList(a.options.attach);
|
|
9116
|
+
if (worker)
|
|
9117
|
+
await ensurePhaseLabel(io, config, credentials);
|
|
9118
|
+
return withContext(io, config, credentials, a.json, (ctx) => submitValidation(ctx, {
|
|
9119
|
+
ticket,
|
|
9120
|
+
kind: "validation",
|
|
9121
|
+
what,
|
|
9122
|
+
choices: parseChoices(a.options.choices),
|
|
9123
|
+
attachments: [],
|
|
9124
|
+
upload: async () => items.length ? (await attachItems(io, config, credentials, {
|
|
9125
|
+
ticket,
|
|
9126
|
+
items,
|
|
9127
|
+
...a.options.caption ? { caption: a.options.caption } : {},
|
|
9128
|
+
reference: "validation"
|
|
9129
|
+
})).map((saved) => saved.attachment.id) : [],
|
|
9130
|
+
worker
|
|
9131
|
+
}));
|
|
9132
|
+
}
|
|
9133
|
+
async function askOwner(io, config, credentials, a) {
|
|
9134
|
+
const [ticket, question, ...extra] = a.rest;
|
|
9135
|
+
const usage = 'armada ask-owner <ticket> "<question>" --choices "<a> | <b>"';
|
|
9136
|
+
if (!ticket || !TICKET.test(ticket))
|
|
9137
|
+
throw new UsageError(`ask-owner needs a ticket: ${usage}`);
|
|
9138
|
+
if (extra.length)
|
|
9139
|
+
throw new UsageError(`unexpected argument ${extra[0]}; quote the question`);
|
|
9140
|
+
if (!question?.trim())
|
|
9141
|
+
throw new UsageError(`ask-owner needs the question: ${usage}`);
|
|
9142
|
+
const choices = parseChoices(a.options.choices);
|
|
9143
|
+
if (!choices || choices.length < 2)
|
|
9144
|
+
throw new UsageError(`give the owner at least two choices: ${usage}`);
|
|
9145
|
+
if (credentials.armadaSignIn?.kind === "worker")
|
|
9146
|
+
throw new UsageError("a worker asks the coordinator (armada ask), who escalates to the owner");
|
|
9147
|
+
return withContext(io, config, credentials, a.json, (ctx) => submitValidation(ctx, {
|
|
9148
|
+
ticket: ticket.toUpperCase(),
|
|
9149
|
+
kind: "question",
|
|
9150
|
+
what: question,
|
|
9151
|
+
choices,
|
|
9152
|
+
attachments: [],
|
|
9153
|
+
worker: false
|
|
9154
|
+
}));
|
|
9155
|
+
}
|
|
9156
|
+
async function done(io, config, credentials, a) {
|
|
9157
|
+
const [ticket, ...extra] = a.rest;
|
|
9158
|
+
if (!ticket || !TICKET.test(ticket))
|
|
9159
|
+
throw new UsageError("done needs a ticket: armada done <ticket>");
|
|
9160
|
+
if (extra.length)
|
|
9161
|
+
throw new UsageError(`unexpected argument ${extra[0]}`);
|
|
9162
|
+
if (credentials.armadaSignIn?.kind === "worker")
|
|
9163
|
+
throw new UsageError("workers never close their ticket: the coordinator runs armada done");
|
|
9164
|
+
const id = ticket.toUpperCase();
|
|
9165
|
+
const base = credentials.armadaApi.url;
|
|
9166
|
+
const code = await withContext(io, config, credentials, a.json, (ctx) => closeValidated(ctx, {
|
|
9167
|
+
ticket: id,
|
|
9168
|
+
attachmentUrl: (attachment) => new URL(`/agents/${encodeURIComponent(id)}?tab=attachments&attachment=${attachment}`, base).toString()
|
|
9169
|
+
}));
|
|
9170
|
+
await endWorkerSessions(io, config, credentials, id, "merged", a.json);
|
|
9171
|
+
return code;
|
|
9172
|
+
}
|
|
9173
|
+
|
|
8563
9174
|
// src/cli.ts
|
|
8564
9175
|
var COMMAND_HELP = {
|
|
8565
9176
|
attach: ` attach <ticket> <file|url>... [--caption <text>] [--for <item>]
|
|
@@ -8586,16 +9197,18 @@ var COMMAND_HELP = {
|
|
|
8586
9197
|
.claude/settings.json (yes without a terminal); --no-stop-hook skips it
|
|
8587
9198
|
`,
|
|
8588
9199
|
claim: ` claim <ticket> --runtime <name> --handle <id> [--branch <name>]
|
|
8589
|
-
[--profile <name> [--reason <why>]]
|
|
9200
|
+
[--profile <name> [--reason <why>]] [--validation <n,...> --validation-reason <why>]
|
|
8590
9201
|
Claim a ticket for this worker: In Progress, phase planning, runtime
|
|
8591
9202
|
label and an Agent claim comment; refused if another worker holds it.
|
|
8592
9203
|
--profile records the Conductor profile; one other than the ticket's
|
|
8593
|
-
routed profile needs --reason.
|
|
9204
|
+
routed profile needs --reason. --validation records the owner-validation
|
|
9205
|
+
rules the coordinator judged apply. Prints the ticket's state afterwards
|
|
8594
9206
|
`,
|
|
8595
9207
|
report: ` report <phase> [--message <text> | --message-file <path|->] [--pr <n|url>] [--sha <sha>]
|
|
8596
9208
|
[--plan <text> | --plan-file <path|->]
|
|
8597
9209
|
Report a phase (planning, awaiting-approval, implementing, shipping,
|
|
8598
|
-
blocked, ready-to-merge); the same phase again is a
|
|
9210
|
+
blocked, ready-to-merge, awaiting-validation); the same phase again is a
|
|
9211
|
+
status update; armada validate is how a worker enters awaiting-validation.
|
|
8599
9212
|
--plan posts the plan as its own block under a one-line status (the
|
|
8600
9213
|
message's first line, else the plan's); awaiting-approval sends it to
|
|
8601
9214
|
the coordinator's inbox.
|
|
@@ -8609,6 +9222,22 @@ var COMMAND_HELP = {
|
|
|
8609
9222
|
Worker: ask the coordinator. The phase becomes blocked, the question
|
|
8610
9223
|
goes on the ticket and in the coordinator's inbox. Then stop and wait
|
|
8611
9224
|
for the answer in your session, and report the phase you resume
|
|
9225
|
+
`,
|
|
9226
|
+
validate: ` validate [<ticket>] "<what to check>" [--attach <file|url>]... [--caption <text>]
|
|
9227
|
+
[--choices "<a> | <b>"]
|
|
9228
|
+
Ask the owner to validate on Armada's Validations page, with the
|
|
9229
|
+
attachments (images up to 2 MB, HTTPS links). Prints the approval link.
|
|
9230
|
+
Worker: its own ticket; the phase becomes awaiting-validation: stop until
|
|
9231
|
+
the coordinator relays the owner's decision. Coordinator: any ticket.
|
|
9232
|
+
The owner's buttons are Approve and Request changes, or the --choices
|
|
9233
|
+
`,
|
|
9234
|
+
"ask-owner": ` ask-owner <ticket> "<question>" --choices "<a> | <b>"
|
|
9235
|
+
Coordinator: escalate a question or a plan to the owner, with its
|
|
9236
|
+
choices. Prints the approval link; the owner's pick arrives in the inbox
|
|
9237
|
+
`,
|
|
9238
|
+
done: ` done <ticket> Coordinator: close a ticket whose newest validation the owner approved,
|
|
9239
|
+
with no pull request (a design ticket): the design and the owner's note
|
|
9240
|
+
are posted on it, it moves to Done, agent labels removed, session ended
|
|
8612
9241
|
`,
|
|
8613
9242
|
inbox: ` inbox [--wait [--timeout <seconds>]]
|
|
8614
9243
|
Coordinator: open questions, plans, requests, hand-backs and silent workers,
|
|
@@ -8631,6 +9260,7 @@ var COMMAND_HELP = {
|
|
|
8631
9260
|
Coordinator: record a delivered note; an open plan is resolved
|
|
8632
9261
|
`,
|
|
8633
9262
|
merge: ` merge <pr> [--ticket <id> | --no-ticket] [--dry-run] [--no-lock] [--wait [--timeout <min>]]
|
|
9263
|
+
[--reason <why>] [--ask-owner --reason <why>]
|
|
8634
9264
|
Coordinator: check a handed-back pull request (hand-back SHA = head,
|
|
8635
9265
|
CLEAN, required checks green, no open review thread, base contained
|
|
8636
9266
|
or test-merged), squash-merge it pinned to that SHA under the merge
|
|
@@ -8643,12 +9273,18 @@ var COMMAND_HELP = {
|
|
|
8643
9273
|
is the hand-back with only the base merged in counts as the hand-back.
|
|
8644
9274
|
--no-ticket: a pull request no ticket owns (armada init, a release);
|
|
8645
9275
|
nothing is written to Linear.
|
|
9276
|
+
With [policy] merge_approval, judge each pull request: --reason "<why>"
|
|
9277
|
+
merges on its own; --ask-owner --reason "<why>" merges nothing, asks the
|
|
9278
|
+
owner (PR, files, CI, preview, screenshots) and prints the approval link.
|
|
9279
|
+
A pull request the owner was asked about merges only once they approved
|
|
9280
|
+
that exact head (or it with only the base merged in).
|
|
8646
9281
|
`,
|
|
8647
9282
|
launch: ` launch revoke <ticket>
|
|
8648
9283
|
Cancel the newest pending launch through Armada, including a worker
|
|
8649
9284
|
signed in but not claimed. A claimed launch needs armada release instead
|
|
8650
9285
|
`,
|
|
8651
9286
|
brief: ` brief <ticket> [--profile <name> [--reason <why>]] [--prompt [--profile-line]]
|
|
9287
|
+
[--validation none | --validation <n,...> --validation-reason <why>]
|
|
8652
9288
|
A new worker's launch prompt, the Conductor profile (agent, model,
|
|
8653
9289
|
effort) and the environment variables to pass, named, never shown.
|
|
8654
9290
|
The profile follows [[conductor.routing]] on the ticket's labels, then
|
|
@@ -8657,7 +9293,9 @@ var COMMAND_HELP = {
|
|
|
8657
9293
|
Signed in to Armada, the prompt starts with a one-time launch token, so
|
|
8658
9294
|
the worker needs no key. --prompt prints only the prompt, for \`--message-file -\`
|
|
8659
9295
|
Human and --json views mint nothing. --prompt --profile-line also
|
|
8660
|
-
prints the profile and its reason on stderr, leaving stdout unchanged
|
|
9296
|
+
prints the profile and its reason on stderr, leaving stdout unchanged.
|
|
9297
|
+
With [[policy.validation]] rules, judge which apply: --validation none,
|
|
9298
|
+
or their numbers and why; the prompt then tells the worker what to show
|
|
8661
9299
|
`,
|
|
8662
9300
|
secrets: ` secrets The project's secrets for workers: names, project or organization,
|
|
8663
9301
|
who set each and when; never a value. Needs a sign-in to Armada
|
|
@@ -8700,7 +9338,7 @@ var COMMAND_HELP = {
|
|
|
8700
9338
|
auth logout Remove Armada's keys from this machine
|
|
8701
9339
|
`
|
|
8702
9340
|
};
|
|
8703
|
-
var TICKET_OPTION = new Set(["report", "release", "ask", "merge", "secrets", "run"]);
|
|
9341
|
+
var TICKET_OPTION = new Set(["report", "release", "ask", "validate", "merge", "secrets", "run"]);
|
|
8704
9342
|
var CONFIG_OPTION = new Set([
|
|
8705
9343
|
"attach",
|
|
8706
9344
|
"status",
|
|
@@ -8710,6 +9348,9 @@ var CONFIG_OPTION = new Set([
|
|
|
8710
9348
|
"report",
|
|
8711
9349
|
"release",
|
|
8712
9350
|
"ask",
|
|
9351
|
+
"validate",
|
|
9352
|
+
"ask-owner",
|
|
9353
|
+
"done",
|
|
8713
9354
|
"inbox",
|
|
8714
9355
|
"watch",
|
|
8715
9356
|
"answer",
|
|
@@ -8802,7 +9443,11 @@ var VALUE_OPTIONS = [
|
|
|
8802
9443
|
"file",
|
|
8803
9444
|
"from-env",
|
|
8804
9445
|
"caption",
|
|
8805
|
-
"for"
|
|
9446
|
+
"for",
|
|
9447
|
+
"attach",
|
|
9448
|
+
"choices",
|
|
9449
|
+
"validation",
|
|
9450
|
+
"validation-reason"
|
|
8806
9451
|
];
|
|
8807
9452
|
var FLAG_OPTIONS = [
|
|
8808
9453
|
"background",
|
|
@@ -8816,25 +9461,28 @@ var FLAG_OPTIONS = [
|
|
|
8816
9461
|
"api-key",
|
|
8817
9462
|
"no-stop-hook",
|
|
8818
9463
|
"org",
|
|
8819
|
-
"value-stdin"
|
|
9464
|
+
"value-stdin",
|
|
9465
|
+
"ask-owner"
|
|
8820
9466
|
];
|
|
8821
9467
|
var COMMAND_OPTIONS = {
|
|
8822
9468
|
attach: ["caption", "for"],
|
|
8823
9469
|
heartbeat: ["every", "parent", "background", "ticket", "handle"],
|
|
8824
|
-
claim: ["runtime", "handle", "branch", "profile", "reason"],
|
|
9470
|
+
claim: ["runtime", "handle", "branch", "profile", "reason", "validation", "validation-reason"],
|
|
8825
9471
|
report: ["ticket", "message", "message-file", "plan", "plan-file", "pr", "sha"],
|
|
8826
9472
|
release: ["ticket", "reason"],
|
|
8827
9473
|
ask: ["ticket", "options", "message", "message-file"],
|
|
8828
9474
|
inbox: ["wait", "timeout"],
|
|
8829
9475
|
answer: ["note", "message", "message-file"],
|
|
8830
9476
|
init: ["program-root", "name", "slug", "no-stop-hook"],
|
|
8831
|
-
merge: ["ticket", "no-ticket", "dry-run", "no-lock", "wait", "timeout"],
|
|
8832
|
-
brief: ["profile", "reason", "prompt", "profile-line"],
|
|
9477
|
+
merge: ["ticket", "no-ticket", "dry-run", "no-lock", "wait", "timeout", "reason", "ask-owner"],
|
|
9478
|
+
brief: ["profile", "reason", "prompt", "profile-line", "validation", "validation-reason"],
|
|
9479
|
+
validate: ["ticket", "attach", "caption", "choices", "message", "message-file"],
|
|
9480
|
+
"ask-owner": ["choices"],
|
|
8833
9481
|
login: ["api-key", "launch-token", "api-url"],
|
|
8834
9482
|
secrets: ["ticket", "org", "value-stdin", "from-env", "file", "only"],
|
|
8835
9483
|
run: ["ticket", "only"]
|
|
8836
9484
|
};
|
|
8837
|
-
var WORKER_COMMANDS = new Set(["claim", "report", "release", "ask"]);
|
|
9485
|
+
var WORKER_COMMANDS = new Set(["claim", "report", "release", "ask", "validate"]);
|
|
8838
9486
|
function parseArgs(argv) {
|
|
8839
9487
|
const args = {
|
|
8840
9488
|
command: null,
|
|
@@ -8871,6 +9519,9 @@ function parseArgs(argv) {
|
|
|
8871
9519
|
throw new UsageError(`--${name} needs a value`);
|
|
8872
9520
|
if (name === "config")
|
|
8873
9521
|
args.config = v;
|
|
9522
|
+
else if (name === "attach" && args.options.attach !== undefined)
|
|
9523
|
+
args.options.attach += `
|
|
9524
|
+
${v}`;
|
|
8874
9525
|
else
|
|
8875
9526
|
args.options[name] = v;
|
|
8876
9527
|
} else if (a?.startsWith("-"))
|
|
@@ -8900,7 +9551,7 @@ async function findConfig(io, explicit, command = "status") {
|
|
|
8900
9551
|
}
|
|
8901
9552
|
throw new UsageError(`no ${CONFIG_FILE} found in ${io.cwd} or any parent directory, so this is not a repository Armada runs`, `armada init to set this repository up, armada ${command} --config <file> to use another ${CONFIG_FILE}, or armada status --all to see the registered projects`);
|
|
8902
9553
|
}
|
|
8903
|
-
async function
|
|
9554
|
+
async function status(io, args) {
|
|
8904
9555
|
const { path, text } = await findConfig(io, args.config, "status");
|
|
8905
9556
|
const config = parseConfig(text, path);
|
|
8906
9557
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
@@ -9022,14 +9673,15 @@ async function dispatch(argv, io) {
|
|
|
9022
9673
|
ticket: (stored) => currentTicket(io, config, args.options.ticket, stored)
|
|
9023
9674
|
}
|
|
9024
9675
|
});
|
|
9025
|
-
return await
|
|
9676
|
+
return await heartbeat(io, config, credentials, args);
|
|
9026
9677
|
}
|
|
9027
|
-
const worker = { claim, report, release, ask, inbox:
|
|
9678
|
+
const worker = { claim, report, release, ask, inbox, answer, validate, "ask-owner": askOwner, done }[args.command];
|
|
9028
9679
|
if (worker) {
|
|
9029
9680
|
const { path, text } = await findConfig(io, args.config, args.command);
|
|
9030
9681
|
const config = parseConfig(text, path);
|
|
9031
9682
|
const command = args.command;
|
|
9032
|
-
const
|
|
9683
|
+
const workerScope = WORKER_COMMANDS.has(command) && !(command === "validate" && namedTicket(args.rest, args.options));
|
|
9684
|
+
const scope = workerScope ? {
|
|
9033
9685
|
command,
|
|
9034
9686
|
project: config.project.slug,
|
|
9035
9687
|
ticket: (stored) => command === "claim" ? args.rest[0]?.toUpperCase() ?? null : currentTicket(io, config, args.options.ticket, stored)
|
|
@@ -9044,7 +9696,7 @@ async function dispatch(argv, io) {
|
|
|
9044
9696
|
const config = parseConfig(text, path);
|
|
9045
9697
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
9046
9698
|
await recordPresence(io, config, credentials);
|
|
9047
|
-
return await
|
|
9699
|
+
return await watch(io, config, credentials, args, path);
|
|
9048
9700
|
}
|
|
9049
9701
|
if (args.command === "hook")
|
|
9050
9702
|
return await hookStop(io, args.rest, (at) => findConfig(at, null, "hook"));
|
|
@@ -9053,7 +9705,7 @@ async function dispatch(argv, io) {
|
|
|
9053
9705
|
const config = parseConfig(text, path);
|
|
9054
9706
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
9055
9707
|
await recordPresence(io, config, credentials);
|
|
9056
|
-
return await
|
|
9708
|
+
return await merge(io, config, credentials, args, path);
|
|
9057
9709
|
}
|
|
9058
9710
|
if (args.command === "brief") {
|
|
9059
9711
|
const { path, text } = await findConfig(io, args.config, "brief");
|
|
@@ -9061,7 +9713,7 @@ async function dispatch(argv, io) {
|
|
|
9061
9713
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
9062
9714
|
if (args.options.prompt === "true")
|
|
9063
9715
|
await recordPresence(io, config, credentials);
|
|
9064
|
-
return await
|
|
9716
|
+
return await brief(io, config, credentials, args, version, path);
|
|
9065
9717
|
}
|
|
9066
9718
|
if (args.command === "launch") {
|
|
9067
9719
|
const { path, text } = await findConfig(io, args.config, "launch");
|
|
@@ -9071,7 +9723,7 @@ async function dispatch(argv, io) {
|
|
|
9071
9723
|
}
|
|
9072
9724
|
if (args.command === "status") {
|
|
9073
9725
|
noExtra(args.rest);
|
|
9074
|
-
return await (args.all ? statusAll(io, args.json) :
|
|
9726
|
+
return await (args.all ? statusAll(io, args.json) : status(io, args));
|
|
9075
9727
|
}
|
|
9076
9728
|
if (args.command === "doctor") {
|
|
9077
9729
|
noExtra(args.rest);
|