@the-vibe-company/armada 0.2.10 → 0.2.11
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/dist/armada.js +90 -9
- package/package.json +1 -1
package/dist/armada.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
5
5
|
import { createReadStream } from "node:fs";
|
|
6
6
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
7
|
+
import { hostname as hostname2 } from "node:os";
|
|
7
8
|
import { isatty } from "node:tty";
|
|
8
9
|
|
|
9
10
|
// src/cli.ts
|
|
@@ -3362,6 +3363,8 @@ var WORKER_FLEET_OPS = ["claim", "report", "ask", "release"];
|
|
|
3362
3363
|
var FLEET_OPS = [
|
|
3363
3364
|
...WORKER_FLEET_OPS,
|
|
3364
3365
|
"register",
|
|
3366
|
+
"coordinator",
|
|
3367
|
+
"request",
|
|
3365
3368
|
"events/latest",
|
|
3366
3369
|
"launches",
|
|
3367
3370
|
"inbox",
|
|
@@ -3380,6 +3383,10 @@ var CALL_TIMEOUT_MS = 15000;
|
|
|
3380
3383
|
function fleetClient(o) {
|
|
3381
3384
|
const call = async (op, input) => await o.api.fleet(o.signIn, op, { project: o.project, input }, CALL_TIMEOUT_MS);
|
|
3382
3385
|
return {
|
|
3386
|
+
coordinator: (facts) => call("coordinator", facts).then(() => {
|
|
3387
|
+
return;
|
|
3388
|
+
}),
|
|
3389
|
+
request: (input) => call("request", input),
|
|
3383
3390
|
register: () => call("register", {}).then(() => {
|
|
3384
3391
|
return;
|
|
3385
3392
|
}),
|
|
@@ -3442,13 +3449,19 @@ function normalizePull(raw, repo) {
|
|
|
3442
3449
|
const status = raw.commits.nodes[0]?.commit.statusCheckRollup ?? null;
|
|
3443
3450
|
const checks = status?.contexts.nodes.map((c) => c.__typename === "CheckRun" ? { name: c.name, state: checkState(c.status, c.conclusion) } : { name: c.context, state: checkState("", c.state) });
|
|
3444
3451
|
return {
|
|
3452
|
+
files: raw.files?.nodes ?? null,
|
|
3453
|
+
additions: raw.additions ?? null,
|
|
3454
|
+
deletions: raw.deletions ?? null,
|
|
3455
|
+
filesComplete: !!raw.files && !raw.files.pageInfo.hasNextPage,
|
|
3456
|
+
checksComplete: !status || status.contexts.pageInfo?.hasNextPage === false,
|
|
3457
|
+
mergeability: raw.mergeable === "CONFLICTING" || raw.mergeStateStatus === "DIRTY" ? "conflicting" : raw.mergeStateStatus === "BEHIND" ? "behind" : raw.mergeable === "MERGEABLE" ? "clean" : "unknown",
|
|
3445
3458
|
url: raw.url,
|
|
3446
3459
|
number: raw.number,
|
|
3447
3460
|
repo,
|
|
3448
3461
|
title: raw.title,
|
|
3449
3462
|
state: raw.state === "OPEN" ? "open" : raw.state === "MERGED" ? "merged" : "closed",
|
|
3450
3463
|
draft: raw.isDraft,
|
|
3451
|
-
ci: checks ? rollup(checks.map((c) => c.state)) : "none",
|
|
3464
|
+
ci: status?.contexts.pageInfo?.hasNextPage ? checkState("", status.state) : checks ? rollup(checks.map((c) => c.state)) : "none",
|
|
3452
3465
|
checks: checks ?? [],
|
|
3453
3466
|
mergeable: raw.mergeable,
|
|
3454
3467
|
headRef: raw.headRefName,
|
|
@@ -3460,8 +3473,9 @@ function normalizePull(raw, repo) {
|
|
|
3460
3473
|
}
|
|
3461
3474
|
var PULL_FIELDS = `
|
|
3462
3475
|
fragment P on PullRequest {
|
|
3463
|
-
number title url state isDraft mergeable headRefName headRefOid createdAt updatedAt mergedAt
|
|
3464
|
-
|
|
3476
|
+
number title url state isDraft mergeable mergeStateStatus headRefName headRefOid createdAt updatedAt mergedAt additions deletions
|
|
3477
|
+
files(first: 100) { nodes { path additions deletions } pageInfo { hasNextPage } }
|
|
3478
|
+
commits(last: 1) { nodes { commit { statusCheckRollup { state contexts(first: 50) { pageInfo { hasNextPage } nodes {
|
|
3465
3479
|
__typename
|
|
3466
3480
|
... on CheckRun { name status conclusion }
|
|
3467
3481
|
... on StatusContext { context state }
|
|
@@ -3519,7 +3533,13 @@ async function fetchForge(opts) {
|
|
|
3519
3533
|
repo: opts.repository,
|
|
3520
3534
|
fetchedAt: (opts.now?.() ?? new Date).toISOString(),
|
|
3521
3535
|
prs: [...repo.open.nodes, ...repo.closed.nodes].map((p) => normalizePull(p, opts.repository)),
|
|
3522
|
-
warnings:
|
|
3536
|
+
warnings: [
|
|
3537
|
+
...repo.open.pageInfo?.hasNextPage ? ["more than 100 open pull requests; the least recently updated are ignored"] : [],
|
|
3538
|
+
...repo.open.nodes.flatMap((pr) => [
|
|
3539
|
+
...pr.files?.pageInfo.hasNextPage ? [`PR #${pr.number}: changed files are incomplete (first 100)`] : [],
|
|
3540
|
+
...pr.commits.nodes[0]?.commit.statusCheckRollup?.contexts.pageInfo?.hasNextPage ? [`PR #${pr.number}: checks are incomplete (first 50)`] : []
|
|
3541
|
+
])
|
|
3542
|
+
]
|
|
3523
3543
|
};
|
|
3524
3544
|
}
|
|
3525
3545
|
function attachPullRequests(program, forge) {
|
|
@@ -3677,6 +3697,7 @@ async function checkInbox(fleet, o) {
|
|
|
3677
3697
|
const query = {
|
|
3678
3698
|
coordinator: o.coordinator ?? null,
|
|
3679
3699
|
silentAfterMinutes: o.silentAfterMinutes,
|
|
3700
|
+
...o.facts ? { facts: o.facts } : {},
|
|
3680
3701
|
...o.notStartedMinutes !== undefined ? { notStartedMinutes: o.notStartedMinutes } : {}
|
|
3681
3702
|
};
|
|
3682
3703
|
const first = await fleet.inbox({ ...query, etag: null });
|
|
@@ -3727,7 +3748,16 @@ function statusComment(phase, word, text, ref) {
|
|
|
3727
3748
|
|
|
3728
3749
|
${detail}` : line;
|
|
3729
3750
|
}
|
|
3730
|
-
var ANSWERABLE = [
|
|
3751
|
+
var ANSWERABLE = [
|
|
3752
|
+
"question",
|
|
3753
|
+
"plan",
|
|
3754
|
+
"request",
|
|
3755
|
+
"answer-request",
|
|
3756
|
+
"launch-request",
|
|
3757
|
+
"merge-request",
|
|
3758
|
+
"release-request",
|
|
3759
|
+
"plan-changes"
|
|
3760
|
+
];
|
|
3731
3761
|
async function answerItem(ctx, input) {
|
|
3732
3762
|
const { config, linear } = ctx;
|
|
3733
3763
|
const project = config.project.slug;
|
|
@@ -3764,6 +3794,10 @@ async function answerItem(ctx, input) {
|
|
|
3764
3794
|
}
|
|
3765
3795
|
if (item?.kind === "launch-request")
|
|
3766
3796
|
return declineLaunch(ctx, item, text, warnings);
|
|
3797
|
+
if (item && ["merge-request", "release-request", "plan-changes"].includes(item.kind)) {
|
|
3798
|
+
const recorded = await live(ctx, warnings, "resolve the dashboard request", (fleet) => fleet.answer({ text, note: false, ticket: item.ticket, item: item.id }));
|
|
3799
|
+
return { ticket: item.ticket ?? `#${item.id}`, url: "", lines: recorded ? [recorded] : [], warnings, inbox: null };
|
|
3800
|
+
}
|
|
3767
3801
|
const question = item?.kind === "answer-request" ? item.request?.question ?? null : null;
|
|
3768
3802
|
const answered = question === null ? item : await live(ctx, warnings, `read the item answered by #${item?.id}`, (fleet) => fleet.inboxItem(question));
|
|
3769
3803
|
const answerKind = answered?.kind === "plan" ? "plan" : "question";
|
|
@@ -4050,6 +4084,7 @@ async function watchInbox(fleet, o) {
|
|
|
4050
4084
|
const query = {
|
|
4051
4085
|
coordinator: o.coordinator,
|
|
4052
4086
|
silentAfterMinutes: o.silentAfterMinutes,
|
|
4087
|
+
...o.facts ? { facts: o.facts } : {},
|
|
4053
4088
|
...o.notStartedMinutes !== undefined ? { notStartedMinutes: o.notStartedMinutes } : {}
|
|
4054
4089
|
};
|
|
4055
4090
|
const pollMs = o.pollMs ?? WATCH_POLL_MS;
|
|
@@ -5689,6 +5724,13 @@ function buildStatus({
|
|
|
5689
5724
|
});
|
|
5690
5725
|
const phaseOf = new Map(lanes.map((l) => [l.issue.id, l.phase]));
|
|
5691
5726
|
const prRef = (p) => ({
|
|
5727
|
+
files: p.files ?? null,
|
|
5728
|
+
additions: p.additions ?? null,
|
|
5729
|
+
deletions: p.deletions ?? null,
|
|
5730
|
+
filesComplete: p.filesComplete ?? false,
|
|
5731
|
+
checksComplete: p.checksComplete ?? false,
|
|
5732
|
+
mergeability: p.mergeability ?? "unknown",
|
|
5733
|
+
failingChecks: (p.checks ?? []).filter((check) => check.state === "failure").map((check) => check.name),
|
|
5692
5734
|
number: p.number,
|
|
5693
5735
|
url: p.url,
|
|
5694
5736
|
title: p.title,
|
|
@@ -5698,6 +5740,10 @@ function buildStatus({
|
|
|
5698
5740
|
});
|
|
5699
5741
|
return {
|
|
5700
5742
|
schemaVersion: STATUS_SCHEMA_VERSION,
|
|
5743
|
+
progress: {
|
|
5744
|
+
done: m.program.filter((ticket) => m.isLeaf(ticket) && isDone(ticket)).length,
|
|
5745
|
+
total: m.program.filter(m.isLeaf).length
|
|
5746
|
+
},
|
|
5701
5747
|
generatedAt: now.toISOString(),
|
|
5702
5748
|
project: { name: config.project.name, slug: config.project.slug, repository: config.github.repository },
|
|
5703
5749
|
programRoot: { id: m.root.id, title: m.root.title, url: m.root.url },
|
|
@@ -5798,7 +5844,7 @@ async function loadStatus(config, opts) {
|
|
|
5798
5844
|
});
|
|
5799
5845
|
}
|
|
5800
5846
|
// package.json
|
|
5801
|
-
var version = "0.2.
|
|
5847
|
+
var version = "0.2.11";
|
|
5802
5848
|
|
|
5803
5849
|
// src/api.ts
|
|
5804
5850
|
var runs = new WeakMap;
|
|
@@ -6464,6 +6510,29 @@ async function endWorkerSessions(io, config, credentials, ticket, reason, quiet)
|
|
|
6464
6510
|
}
|
|
6465
6511
|
}
|
|
6466
6512
|
|
|
6513
|
+
// src/presence.ts
|
|
6514
|
+
function detectCoordinator(io) {
|
|
6515
|
+
const read = (name) => io.env[name]?.trim() || null;
|
|
6516
|
+
const workspace = read("CONDUCTOR_WORKSPACE_ID");
|
|
6517
|
+
const harness = workspace ? "conductor-cloud" : read("CLAUDECODE") ? "claude-code" : ["CODEX_THREAD_ID", "CODEX_CI", "CODEX_SANDBOX_ENV", "CODEX_SESSION_ID"].some(read) ? "codex" : "terminal";
|
|
6518
|
+
const handle = read("ARMADA_COORDINATOR_HANDLE") ?? (workspace ? [workspace, read("CONDUCTOR_SESSION_ID")].filter(Boolean).join("/") : [io.machineName, io.ttyName].filter(Boolean).join("/") || null);
|
|
6519
|
+
const model = harness === "conductor-cloud" ? read("CONDUCTOR_MODEL") ?? read("CODEX_MODEL") ?? read("CLAUDE_MODEL") : harness === "claude-code" ? read("CLAUDE_MODEL") ?? read("ANTHROPIC_MODEL") : harness === "codex" ? read("CODEX_MODEL") ?? read("OPENAI_MODEL") : null;
|
|
6520
|
+
return { harness, handle, model, cliVersion: version };
|
|
6521
|
+
}
|
|
6522
|
+
async function recordPresence(io, config, credentials) {
|
|
6523
|
+
if (!credentials.armadaSignIn || credentials.armadaSignIn.kind === "worker")
|
|
6524
|
+
return;
|
|
6525
|
+
const { fleet, warning } = liveFleet(io, config, credentials);
|
|
6526
|
+
try {
|
|
6527
|
+
if (!fleet)
|
|
6528
|
+
throw new Error(warning ?? "Armada is unreachable");
|
|
6529
|
+
await fleet.coordinator(detectCoordinator(io));
|
|
6530
|
+
} catch (error) {
|
|
6531
|
+
io.stderr(`armada: warning: could not record coordinator activity (${error instanceof Error ? error.message : String(error)})
|
|
6532
|
+
`);
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6535
|
+
|
|
6467
6536
|
// src/inbox.ts
|
|
6468
6537
|
var DEFAULT_WAIT_SECONDS = 300;
|
|
6469
6538
|
async function ask(io, config, credentials, a) {
|
|
@@ -6513,8 +6582,9 @@ function renderEntries(project, items) {
|
|
|
6513
6582
|
e.id === null ? e.kind : `#${e.id} ${e.kind}`,
|
|
6514
6583
|
e.ticket,
|
|
6515
6584
|
e.author && `from ${e.author}`,
|
|
6516
|
-
e.request?.question &&
|
|
6585
|
+
e.request?.question && `${e.kind === "plan-changes" ? "amends" : "answers"} #${e.request.question}`,
|
|
6517
6586
|
e.request?.profile && `profile ${e.request.profile}`,
|
|
6587
|
+
e.request?.pr && `PR #${e.request.pr}`,
|
|
6518
6588
|
e.createdAt
|
|
6519
6589
|
].filter(Boolean).join(" · ");
|
|
6520
6590
|
out.push(`${e.new ? "* " : " "}${head}`, ...e.body.split(`
|
|
@@ -6522,8 +6592,8 @@ function renderEntries(project, items) {
|
|
|
6522
6592
|
}
|
|
6523
6593
|
if (items.some((e) => e.kind === "question" || e.kind === "plan"))
|
|
6524
6594
|
out.push(`Deliver each answer in the worker's session with the runtime guide, then record it: armada answer <id> "<answer>".`);
|
|
6525
|
-
if (items.some((e) =>
|
|
6526
|
-
out.push('Dashboard requests: deliver an answer-request, then armada answer <id> "<answer>"; launch a launch-request (its claim resolves it), or decline it with armada answer <id> "<why>".');
|
|
6595
|
+
if (items.some((e) => ["answer-request", "launch-request", "merge-request", "release-request", "plan-changes"].includes(e.kind)))
|
|
6596
|
+
out.push('Dashboard requests: deliver an answer-request, then armada answer <id> "<answer>"; launch a launch-request (its claim resolves it), or decline it with armada answer <id> "<why>". Handle or decline merge-request, release-request and plan-changes, then resolve them with armada answer <id> "<result>". Plan changes are not an approval.');
|
|
6527
6597
|
return out;
|
|
6528
6598
|
}
|
|
6529
6599
|
function renderInbox(r, next) {
|
|
@@ -6551,6 +6621,7 @@ async function inbox2(io, config, credentials, a) {
|
|
|
6551
6621
|
const report = await checkInbox(fleet, {
|
|
6552
6622
|
project: config.project.slug,
|
|
6553
6623
|
coordinator: coordinatorHandle(io),
|
|
6624
|
+
facts: detectCoordinator(io),
|
|
6554
6625
|
silentAfterMinutes: config.policy.silentAfterMinutes,
|
|
6555
6626
|
notStartedMinutes: config.policy.notStartedMinutes,
|
|
6556
6627
|
now: io.now ?? (() => new Date),
|
|
@@ -6679,6 +6750,7 @@ async function watchUntil(io, config, credentials, json, configPath) {
|
|
|
6679
6750
|
const report = await watchInbox(fleet, {
|
|
6680
6751
|
project,
|
|
6681
6752
|
coordinator: coordinatorHandle(io),
|
|
6753
|
+
facts: detectCoordinator(io),
|
|
6682
6754
|
silentAfterMinutes: config.policy.silentAfterMinutes,
|
|
6683
6755
|
notStartedMinutes: config.policy.notStartedMinutes,
|
|
6684
6756
|
seen: before?.seen ?? [],
|
|
@@ -7800,6 +7872,7 @@ async function statusAll(io, json) {
|
|
|
7800
7872
|
warning = read.warning;
|
|
7801
7873
|
const config = read.config;
|
|
7802
7874
|
const own = p.ownLinearKey && !io.env.LINEAR_API_KEY?.trim() ? (await api.credentials(signIn, { project: p.slug })).linear?.apiKey : undefined;
|
|
7875
|
+
await recordPresence(io, config, credentials);
|
|
7803
7876
|
const report = await loadStatus(config, {
|
|
7804
7877
|
linearApiKey: own ?? linearApiKey,
|
|
7805
7878
|
githubToken: credentials.githubToken,
|
|
@@ -8362,6 +8435,7 @@ async function status2(io, args) {
|
|
|
8362
8435
|
const config = parseConfig(text, path);
|
|
8363
8436
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8364
8437
|
const { linearApiKey, githubToken } = credentials;
|
|
8438
|
+
await recordPresence(io, config, credentials);
|
|
8365
8439
|
if (!linearApiKey)
|
|
8366
8440
|
throw missingKey(LINEAR_KEY);
|
|
8367
8441
|
const live = statusLive(io, config, credentials);
|
|
@@ -8469,12 +8543,15 @@ async function dispatch(argv, io) {
|
|
|
8469
8543
|
ticket: (stored) => command === "claim" ? args.rest[0]?.toUpperCase() ?? null : currentTicket(io, config, args.options.ticket, stored)
|
|
8470
8544
|
} : undefined;
|
|
8471
8545
|
const { credentials } = await loadCredentials(io, scope ? { worker: scope } : { project: config.project.slug });
|
|
8546
|
+
if (command === "inbox")
|
|
8547
|
+
await recordPresence(io, config, credentials);
|
|
8472
8548
|
return await worker(io, config, credentials, args);
|
|
8473
8549
|
}
|
|
8474
8550
|
if (args.command === "watch") {
|
|
8475
8551
|
const { path, text } = await findConfig(io, args.config, "watch");
|
|
8476
8552
|
const config = parseConfig(text, path);
|
|
8477
8553
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8554
|
+
await recordPresence(io, config, credentials);
|
|
8478
8555
|
return await watch2(io, config, credentials, args, path);
|
|
8479
8556
|
}
|
|
8480
8557
|
if (args.command === "hook")
|
|
@@ -8483,12 +8560,14 @@ async function dispatch(argv, io) {
|
|
|
8483
8560
|
const { path, text } = await findConfig(io, args.config, "merge");
|
|
8484
8561
|
const config = parseConfig(text, path);
|
|
8485
8562
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8563
|
+
await recordPresence(io, config, credentials);
|
|
8486
8564
|
return await merge2(io, config, credentials, args, path);
|
|
8487
8565
|
}
|
|
8488
8566
|
if (args.command === "brief") {
|
|
8489
8567
|
const { path, text } = await findConfig(io, args.config, "brief");
|
|
8490
8568
|
const config = parseConfig(text, path);
|
|
8491
8569
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8570
|
+
await recordPresence(io, config, credentials);
|
|
8492
8571
|
return await brief2(io, config, credentials, args, version, path);
|
|
8493
8572
|
}
|
|
8494
8573
|
if (args.command === "status") {
|
|
@@ -8683,6 +8762,8 @@ var exec = (command, args, { cwd }) => new Promise((done, fail) => {
|
|
|
8683
8762
|
child.on("close", (code) => done({ code: code ?? 1, stdout, stderr }));
|
|
8684
8763
|
});
|
|
8685
8764
|
var code = await run(process.argv.slice(2), {
|
|
8765
|
+
machineName: hostname2(),
|
|
8766
|
+
ttyName: process.stdin.isTTY ? spawnSync("tty", [], { encoding: "utf8", stdio: ["inherit", "pipe", "ignore"] }).stdout?.trim() || null : null,
|
|
8686
8767
|
cwd: process.cwd(),
|
|
8687
8768
|
env: process.env,
|
|
8688
8769
|
readFile: (path) => readFile3(path, "utf8").catch((err) => {
|