@the-vibe-company/armada 0.2.7 → 0.2.9
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 +19 -2
- package/dist/armada.js +628 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -220,10 +220,11 @@ ARMADA_AUTH_URL=http://localhost:4822 ARMADA_AUTH_OWNER_EMAILS=you@example.com b
|
|
|
220
220
|
| `ARMADA_SECRETS_KEY` | The vault's master key: 32 random bytes in base64 or hex, `openssl rand -base64 32`. It stays in the deployment's environment, never in a database. Changing it makes every stored key unreadable (the Keys page asks to enter them again) |
|
|
221
221
|
|
|
222
222
|
- The Keys page holds the Linear API key, and a GitHub token for the dashboard's own reads, needed only without the [GitHub App](#github-app). Each member may add their own Linear key: their terminals use it, so the comments they post carry their name.
|
|
223
|
-
-
|
|
223
|
+
- Each project can keep its own keys (pick it at the top of the Keys page): a Linear key, which wins for that project over the organization's and anyone's own (a project in another Linear workspace); the dashboard and every command run for that project (`status --all` and `doctor` included) read its Linear with it. And its secrets for workers (see [Secrets for workers](#secrets-for-workers)), next to the organization's, which every project gets; a project's own wins over the organization's of the same name.
|
|
224
|
+
- Values are write-only: once saved, a secret is never shown again, only who set it and when. Each value is sealed with AES-256-GCM under its own data key, itself sealed by the master key, and bound to its organization, project, person and name.
|
|
224
225
|
- A signed-in terminal (a session of `armada login`, an organization API key, or a worker session) calls `POST /api/cli/credentials`. It receives the Linear key (the person's own first), so workers and coordinators can search and edit Linear freely. Answers are never cached; a terminal asking more than 30 times a minute is refused for a minute.
|
|
225
226
|
- No terminal ever receives a database key. Every read and write of the fleet's live data (claims, reports, questions and plans, the inbox, answers, the merge lock, the project registry) goes through `POST /api/cli/fleet/<operation>` with the terminal's sign-in. Armada checks each one: the project must belong to the caller's organization (a project is registered for the first organization that names it), and a worker session only claims, reports, asks and releases its own ticket. Times are Armada's.
|
|
226
|
-
- Every change and every key handed out is in the audit list at the bottom of the Keys page (owners and admins): who, which key, when; never a value.
|
|
227
|
+
- Every change and every key handed out is in the audit list at the bottom of the Keys page (owners and admins): who, which key, when, for which project; never a value. A project picked at the top shows only its own.
|
|
227
228
|
- The dashboard reads each organization's fleet with that organization's Linear and GitHub keys from the vault. Only the deployment's first organization falls back to the environment's (and to `ARMADA_REPOSITORIES`): another organization could name any repository in the registry. Once the keys are on the Keys page, the environment shrinks to `ARMADA_DATABASE_URL`, the accounts variables, `ARMADA_SECRETS_KEY` and the GitHub App's. With the [GitHub App](#github-app), GitHub is read through it rather than with a stored token.
|
|
228
229
|
- Without `ARMADA_SECRETS_KEY` (or under the shared password), nothing changes: the Keys page says how to turn the vault on, the CLI's call answers 503 with that next step, and terminals keep their own keys.
|
|
229
230
|
|
|
@@ -346,6 +347,19 @@ url = "https://<your-armada-dashboard>"
|
|
|
346
347
|
url = "https://armada.example.com" # a self-hosted Armada for `armada login`; used when ARMADA_API_URL is not set
|
|
347
348
|
```
|
|
348
349
|
|
|
350
|
+
### Secrets for workers
|
|
351
|
+
|
|
352
|
+
What a project's workers need to build and test (an LLM provider key, a test database URL) is kept in Armada with the project, never in a worker's launch environment. Names are in upper snake case; the keys Armada itself uses (`LINEAR_API_KEY`, `GITHUB_TOKEN`, `GH_TOKEN`, `ARMADA_*`) are not secrets for workers.
|
|
353
|
+
|
|
354
|
+
- The coordinator sets them, signed in as an owner or admin (or with an organization API key whose creator still is one): `armada secrets set <NAME>` for the current project, `--org` for every project of the organization. The value is read from a hidden prompt, from standard input (`--value-stdin`), or from a variable of the coordinator's environment (`--from-env <VAR>`), so an agent can move a key without reading it. Never from the command line. `armada secrets unset <NAME> [--org]` removes one. Owners and admins can also do both on the Keys page.
|
|
355
|
+
- `armada secrets` lists the names, where each is set (project or organization), who set it and when. Never a value.
|
|
356
|
+
- A worker fetches them through Armada, with its worker session, for its own project only (another project's is refused, and the refusal is in the audit list), in this order:
|
|
357
|
+
- `armada run [--only A,B] -- <command>` runs the command with them in its environment: tests, builds, dev servers. Armada's value wins over a variable of the same name (stderr names it). Nothing is written to disk or printed; the exit code is the command's.
|
|
358
|
+
- `armada secrets export --file <path> [--only A,B]` writes a dotenv file with mode 0600, for a tool that reads one (`.env.local`). It refuses a path git tracks or does not ignore.
|
|
359
|
+
- `armada secrets get <NAME>` prints one value, for a person, with a warning on stderr that it is now visible. An agent never runs it: its command output is its transcript.
|
|
360
|
+
- Every fetch is one release in the audit list, naming the project and the secrets. Nothing is cached: an unset secret is no longer handed out, and a changed one takes effect on the next command.
|
|
361
|
+
- `[secrets] names` in `armada.toml` lists what the project expects; `armada doctor` names those Armada does not keep for it.
|
|
362
|
+
|
|
349
363
|
## Configure a project
|
|
350
364
|
|
|
351
365
|
Add an `armada.toml` at the root of the repository. One project is one repository plus one Linear program root. The file holds no secrets.
|
|
@@ -382,6 +396,9 @@ approval_label = "needs-plan-approval" # a ticket with this label waits for ap
|
|
|
382
396
|
[brief]
|
|
383
397
|
extra = "docs/worker-conventions.md" # every brief ends with this file under "Project conventions" (default: none)
|
|
384
398
|
|
|
399
|
+
[secrets]
|
|
400
|
+
names = ["OPENAI_API_KEY", "TEST_DATABASE_URL"] # what workers need from Armada; `armada doctor` names those not set (names only)
|
|
401
|
+
|
|
385
402
|
[conductor]
|
|
386
403
|
default_profile = "opus" # for tickets no routing rule matches (required with routing)
|
|
387
404
|
|
package/dist/armada.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
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
7
|
import { isatty } from "node:tty";
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
|
-
import { dirname as
|
|
10
|
+
import { dirname as dirname7, join as join6, resolve as resolve2 } from "node:path";
|
|
11
11
|
|
|
12
12
|
// ../core/src/types.ts
|
|
13
13
|
var LABEL_PHASES = [
|
|
@@ -337,6 +337,9 @@ function compareVersions(a, b) {
|
|
|
337
337
|
var versionToInstall = (minimum, latest) => latest && compareVersions(latest, minimum) >= 0 ? latest : minimum;
|
|
338
338
|
var installCommand = (version) => `npm install -g ${CLI_PACKAGE}@${version}`;
|
|
339
339
|
var upgradeLine = (version, install) => `Armada ${version} is older than this server expects: ${installCommand(install)}`;
|
|
340
|
+
var releaseNotesUrl = (version) => `https://github.com/The-Vibe-Company/armada/releases/tag/v${version}`;
|
|
341
|
+
var newerRelease = (running, latest) => latest && running !== "0.0.0" && compareVersions(latest, running) > 0 ? latest : null;
|
|
342
|
+
var releaseLine = (running, latest) => `Armada ${latest} is out (you run ${running}): ${installCommand(latest)} — then armada init to refresh this project's skills. Changes: ${releaseNotesUrl(latest)}`;
|
|
340
343
|
|
|
341
344
|
class ArmadaApiError extends Error {
|
|
342
345
|
next;
|
|
@@ -397,8 +400,10 @@ function armadaApi(opts) {
|
|
|
397
400
|
});
|
|
398
401
|
const minimum = res.headers.get(CLI_MINIMUM_HEADER);
|
|
399
402
|
const latest = res.headers.get(CLI_LATEST_HEADER) || null;
|
|
400
|
-
if (minimum)
|
|
403
|
+
if (minimum) {
|
|
401
404
|
serverCli = { minimum, latest };
|
|
405
|
+
opts.onServerCli?.(serverCli);
|
|
406
|
+
}
|
|
402
407
|
if (opts.version && minimum && compareVersions(opts.version, minimum) < 0) {
|
|
403
408
|
await res.body?.cancel().catch(() => {});
|
|
404
409
|
const install = versionToInstall(minimum, latest);
|
|
@@ -469,10 +474,11 @@ function armadaApi(opts) {
|
|
|
469
474
|
if (!shaped)
|
|
470
475
|
throw new ArmadaApiError(`Armada (${host}) answered the keys in a shape this CLI does not know`);
|
|
471
476
|
const warnings = Array.isArray(body.warnings) ? body.warnings.filter((w) => typeof w === "string") : [];
|
|
477
|
+
const scope = linear?.scope === "own" || linear?.scope === "project" ? linear.scope : "organization";
|
|
472
478
|
return {
|
|
473
479
|
schemaVersion: 1,
|
|
474
480
|
organization: org,
|
|
475
|
-
linear: linear ? { apiKey: linear.apiKey, scope
|
|
481
|
+
linear: linear ? { apiKey: linear.apiKey, scope } : null,
|
|
476
482
|
warnings
|
|
477
483
|
};
|
|
478
484
|
},
|
|
@@ -482,7 +488,15 @@ function armadaApi(opts) {
|
|
|
482
488
|
throw refusal(status, body, status === 401 ? null : "Armada did not list the projects");
|
|
483
489
|
if (!Array.isArray(body.projects))
|
|
484
490
|
throw new ArmadaApiError(`Armada (${host}) answered the projects in a shape this CLI does not know`);
|
|
485
|
-
return body.projects.flatMap((p) => typeof p.slug === "string" && typeof p.name === "string" && typeof p.repository === "string" && typeof p.programRoot === "string" ? [
|
|
491
|
+
return body.projects.flatMap((p) => typeof p.slug === "string" && typeof p.name === "string" && typeof p.repository === "string" && typeof p.programRoot === "string" ? [
|
|
492
|
+
{
|
|
493
|
+
slug: p.slug,
|
|
494
|
+
name: p.name,
|
|
495
|
+
repository: p.repository,
|
|
496
|
+
programRoot: p.programRoot,
|
|
497
|
+
...p.ownLinearKey === true ? { ownLinearKey: true } : {}
|
|
498
|
+
}
|
|
499
|
+
] : []);
|
|
486
500
|
},
|
|
487
501
|
async fleet(signIn, op, body, timeoutMs) {
|
|
488
502
|
const { status, body: answer } = await call("POST", `fleet/${op}`, {
|
|
@@ -498,6 +512,52 @@ function armadaApi(opts) {
|
|
|
498
512
|
throw new ArmadaApiError(`Armada (${host}) answered fleet/${op} in a shape this CLI does not know`);
|
|
499
513
|
return answer.result;
|
|
500
514
|
},
|
|
515
|
+
async listSecrets(signIn, project) {
|
|
516
|
+
const { status, body } = await call("POST", "secrets/list", { signIn, body: { project } });
|
|
517
|
+
if (status !== 200)
|
|
518
|
+
throw refusal(status, body, status === 401 ? null : "Armada did not list the secrets");
|
|
519
|
+
if (!Array.isArray(body.secrets))
|
|
520
|
+
throw new ArmadaApiError(`Armada (${host}) answered the secrets in a shape this CLI does not know`);
|
|
521
|
+
return body.secrets.flatMap((s) => typeof s.name === "string" && typeof s.setBy === "string" && typeof s.setAt === "string" ? [
|
|
522
|
+
{
|
|
523
|
+
name: s.name,
|
|
524
|
+
scope: s.scope === "organization" ? "organization" : "project",
|
|
525
|
+
setBy: s.setBy,
|
|
526
|
+
setAt: s.setAt,
|
|
527
|
+
overridden: s.overridden === true
|
|
528
|
+
}
|
|
529
|
+
] : []);
|
|
530
|
+
},
|
|
531
|
+
async releaseSecrets(signIn, project, names = null) {
|
|
532
|
+
const { status, body } = await call("POST", "secrets/release", { signIn, body: { project, names } });
|
|
533
|
+
if (status !== 200)
|
|
534
|
+
throw refusal(status, body, status === 401 ? null : "Armada gave no secrets");
|
|
535
|
+
const secrets = Array.isArray(body.secrets) ? body.secrets : null;
|
|
536
|
+
if (!secrets?.every((s) => typeof s.name === "string" && typeof s.value === "string"))
|
|
537
|
+
throw new ArmadaApiError(`Armada (${host}) answered the secrets in a shape this CLI does not know`);
|
|
538
|
+
const strings = (v) => Array.isArray(v) ? v.filter((w) => typeof w === "string") : [];
|
|
539
|
+
return {
|
|
540
|
+
project: typeof body.project === "string" ? body.project : project.slug,
|
|
541
|
+
secrets: secrets.map((s) => ({
|
|
542
|
+
name: String(s.name),
|
|
543
|
+
value: String(s.value),
|
|
544
|
+
scope: s.scope === "organization" ? "organization" : "project"
|
|
545
|
+
})),
|
|
546
|
+
missing: strings(body.missing),
|
|
547
|
+
warnings: strings(body.warnings)
|
|
548
|
+
};
|
|
549
|
+
},
|
|
550
|
+
async setSecret(signIn, target) {
|
|
551
|
+
const { status, body } = await call("POST", "secrets/set", { signIn, body: target });
|
|
552
|
+
if (status !== 200)
|
|
553
|
+
throw refusal(status, body, status === 401 ? null : `Armada did not set ${target.name}`);
|
|
554
|
+
},
|
|
555
|
+
async unsetSecret(signIn, target) {
|
|
556
|
+
const { status, body } = await call("POST", "secrets/unset", { signIn, body: target });
|
|
557
|
+
if (status !== 200)
|
|
558
|
+
throw refusal(status, body, status === 401 ? null : `Armada did not unset ${target.name}`);
|
|
559
|
+
return body.deleted === true;
|
|
560
|
+
},
|
|
501
561
|
async launchToken(signIn, target) {
|
|
502
562
|
const { status, body } = await call("POST", "launch-tokens", { signIn, body: target });
|
|
503
563
|
if (status !== 200)
|
|
@@ -1864,6 +1924,15 @@ ${problems.map((p) => ` - ${p}`).join(`
|
|
|
1864
1924
|
}
|
|
1865
1925
|
var SLUG = /^[a-z0-9][a-z0-9-]*$/;
|
|
1866
1926
|
var ISSUE_ID = /^[A-Za-z][A-Za-z0-9]*-\d+$/;
|
|
1927
|
+
var SECRET_NAME = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
1928
|
+
var RESERVED_SECRET_NAMES = ["LINEAR_API_KEY", "GITHUB_TOKEN", "GH_TOKEN"];
|
|
1929
|
+
function secretNameRefusal(name) {
|
|
1930
|
+
if (!SECRET_NAME.test(name))
|
|
1931
|
+
return "a secret name is in upper snake case, e.g. OPENAI_API_KEY";
|
|
1932
|
+
if (RESERVED_SECRET_NAMES.includes(name) || name.startsWith("ARMADA_"))
|
|
1933
|
+
return `${name} is a key Armada itself uses: it is set on the Keys page as such, not as a secret for workers`;
|
|
1934
|
+
return null;
|
|
1935
|
+
}
|
|
1867
1936
|
var REPOSITORY = /^[\w.-]+\/[\w.-]+$/;
|
|
1868
1937
|
var isTable = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1869
1938
|
function parseConfig(text, source = CONFIG_FILE) {
|
|
@@ -1925,6 +1994,10 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1925
1994
|
if (!isTable(brief))
|
|
1926
1995
|
problems.push(`"brief" must be a table`);
|
|
1927
1996
|
const briefT = isTable(brief) ? brief : {};
|
|
1997
|
+
const secrets = raw.secrets === undefined ? {} : raw.secrets;
|
|
1998
|
+
if (!isTable(secrets))
|
|
1999
|
+
problems.push(`"secrets" must be a table`);
|
|
2000
|
+
const secretsT = isTable(secrets) ? secrets : {};
|
|
1928
2001
|
const conductor = raw.conductor === undefined ? {} : raw.conductor;
|
|
1929
2002
|
if (!isTable(conductor))
|
|
1930
2003
|
problems.push(`"conductor" must be a table`);
|
|
@@ -1952,6 +2025,7 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1952
2025
|
]
|
|
1953
2026
|
],
|
|
1954
2027
|
["brief", briefT, ["extra"]],
|
|
2028
|
+
["secrets", secretsT, ["names"]],
|
|
1955
2029
|
["conductor", conductorT, ["default_profile", "profiles", "routing"]]
|
|
1956
2030
|
];
|
|
1957
2031
|
const profiles = {};
|
|
@@ -2062,6 +2136,14 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
2062
2136
|
else if (v)
|
|
2063
2137
|
extra = v;
|
|
2064
2138
|
}
|
|
2139
|
+
let secretNames = [];
|
|
2140
|
+
if (secretsT.names !== undefined) {
|
|
2141
|
+
const v = secretsT.names;
|
|
2142
|
+
if (Array.isArray(v) && v.every((n) => typeof n === "string" && !secretNameRefusal(n.trim())))
|
|
2143
|
+
secretNames = [...new Set(v.map((n) => n.trim()))];
|
|
2144
|
+
else
|
|
2145
|
+
problems.push(`"secrets.names" must be a list of secret names in upper snake case, e.g. ["OPENAI_API_KEY"], none of Armada's own keys`);
|
|
2146
|
+
}
|
|
2065
2147
|
let requiredChecks = [];
|
|
2066
2148
|
if (gatesT.required_checks !== undefined) {
|
|
2067
2149
|
const v = gatesT.required_checks;
|
|
@@ -2102,6 +2184,7 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
2102
2184
|
gates: { requiredChecks, localCommands },
|
|
2103
2185
|
policy: { silentAfterMinutes, coordinatorMinutes, plans, preApprovedLabel, approvalLabel },
|
|
2104
2186
|
brief: { extra },
|
|
2187
|
+
secrets: { names: secretNames },
|
|
2105
2188
|
conductor: { defaultProfile, profiles, routing }
|
|
2106
2189
|
};
|
|
2107
2190
|
if (problems.length)
|
|
@@ -3202,7 +3285,7 @@ function updateDotenv(text, updates) {
|
|
|
3202
3285
|
` : "";
|
|
3203
3286
|
}
|
|
3204
3287
|
// ../core/src/live.ts
|
|
3205
|
-
var entryKey = (e) => e.id
|
|
3288
|
+
var entryKey = (e) => e.id !== null ? `#${e.id}` : e.version ? `version:${e.version}` : `silent:${e.ticket}`;
|
|
3206
3289
|
|
|
3207
3290
|
// ../core/src/fleet-api.ts
|
|
3208
3291
|
var WORKER_FLEET_OPS = ["claim", "report", "ask", "release"];
|
|
@@ -3927,14 +4010,36 @@ async function watchInbox(fleet, o) {
|
|
|
3927
4010
|
for (const w of read.warnings)
|
|
3928
4011
|
warnings.add(w);
|
|
3929
4012
|
await o.onRead?.({ items, inFlight });
|
|
3930
|
-
if (items.some((e) => e.new))
|
|
3931
|
-
return report("items");
|
|
3932
|
-
if (inFlight !== null && !inFlight.length && !items.length)
|
|
3933
|
-
return report("nothing");
|
|
3934
4013
|
}
|
|
4014
|
+
const release = await o.release?.() ?? null;
|
|
4015
|
+
if (release)
|
|
4016
|
+
items = [...items, { ...release, new: true }];
|
|
4017
|
+
if (items.some((e) => e.new))
|
|
4018
|
+
return report("items");
|
|
4019
|
+
if (read && inFlight !== null && !inFlight.length && !items.length)
|
|
4020
|
+
return report("nothing");
|
|
3935
4021
|
await o.sleep(inFlight !== null && !inFlight.length ? idlePollMs : pollMs);
|
|
3936
4022
|
}
|
|
3937
4023
|
}
|
|
4024
|
+
function releaseEntry(running, latest, at) {
|
|
4025
|
+
return {
|
|
4026
|
+
id: null,
|
|
4027
|
+
kind: "version",
|
|
4028
|
+
ticket: null,
|
|
4029
|
+
author: null,
|
|
4030
|
+
version: latest,
|
|
4031
|
+
body: [
|
|
4032
|
+
`Armada ${latest} is out (you run ${running}). Changes: ${releaseNotesUrl(latest)}`,
|
|
4033
|
+
"Not urgent: finish what is in flight first, then, between rounds:",
|
|
4034
|
+
` 1. ${installCommand(latest)}`,
|
|
4035
|
+
" 2. armada init, then merge its pull request: armada merge <n> --no-ticket",
|
|
4036
|
+
"Workers in flight keep the version their brief pinned: tell them nothing unless the notes say otherwise."
|
|
4037
|
+
].join(`
|
|
4038
|
+
`),
|
|
4039
|
+
createdAt: at.toISOString(),
|
|
4040
|
+
new: false
|
|
4041
|
+
};
|
|
4042
|
+
}
|
|
3938
4043
|
var workers = (n) => `${n} worker${n === 1 ? "" : "s"} in flight`;
|
|
3939
4044
|
function rearm(o) {
|
|
3940
4045
|
const then = o.act ? "act on the items above, then " : "";
|
|
@@ -4005,6 +4110,9 @@ async function writePrivate(paths, path, text, mode) {
|
|
|
4005
4110
|
await chmod(paths.dir, 448);
|
|
4006
4111
|
if (dirname(path) !== paths.dir)
|
|
4007
4112
|
await mkdir(dirname(path), { recursive: true, mode: 448 });
|
|
4113
|
+
await writePrivateFile(path, text, mode);
|
|
4114
|
+
}
|
|
4115
|
+
async function writePrivateFile(path, text, mode = 384) {
|
|
4008
4116
|
const tmp = `${path}.${randomBytes(6).toString("hex")}.tmp`;
|
|
4009
4117
|
const handle = await open(tmp, "wx", mode);
|
|
4010
4118
|
try {
|
|
@@ -4197,6 +4305,23 @@ async function runningWatch(paths, project, alive = processAlive) {
|
|
|
4197
4305
|
const pid = await readWatchLock(paths, project).catch(() => null);
|
|
4198
4306
|
return pid !== null && alive(pid) ? pid : null;
|
|
4199
4307
|
}
|
|
4308
|
+
var NOTICED_KEPT = 50;
|
|
4309
|
+
var releasesFile = (paths) => join(paths.dir, "releases.json");
|
|
4310
|
+
async function readNoticedReleases(paths) {
|
|
4311
|
+
try {
|
|
4312
|
+
const raw = JSON.parse(await readFile(releasesFile(paths), "utf8"));
|
|
4313
|
+
return strings(raw?.noticed) ?? [];
|
|
4314
|
+
} catch {
|
|
4315
|
+
return [];
|
|
4316
|
+
}
|
|
4317
|
+
}
|
|
4318
|
+
async function addNoticedRelease(paths, version) {
|
|
4319
|
+
const noticed = (await readNoticedReleases(paths)).filter((v) => v !== version);
|
|
4320
|
+
noticed.push(version);
|
|
4321
|
+
const text = `${JSON.stringify({ noticed: noticed.slice(-NOTICED_KEPT) }, null, 2)}
|
|
4322
|
+
`;
|
|
4323
|
+
await writePrivate(paths, releasesFile(paths), text, 420);
|
|
4324
|
+
}
|
|
4200
4325
|
// ../core/src/merge.ts
|
|
4201
4326
|
var MERGE_LEASE = "merge";
|
|
4202
4327
|
var MERGE_LEASE_TTL_MS = 20 * 60000;
|
|
@@ -4891,6 +5016,7 @@ The coordinator turns the owner's intent into merged pull requests. Each worker
|
|
|
4891
5016
|
A coordinator may start cold, on a laptop or in a fresh cloud session, with nothing but the repository and a sign-in to Armada. Everything it needs is in the tracker, GitHub and Armada; the Armada [runbook](https://github.com/The-Vibe-Company/armada/blob/main/docs/runbook.md) says how to start one.
|
|
4892
5017
|
|
|
4893
5018
|
1. **Sign in to Armada.** \`armada doctor\` (or \`armada whoami\`) says whether this terminal is signed in and to which organization. If not: a person runs \`armada login\` and approves the code in the browser; a headless coordinator (a cloud workspace, CI) sets \`ARMADA_API_KEY\` to an organization API key an owner created on the Organization page. Signed in, Armada gives your commands the organization's keys, and every brief carries a one-time launch token, so no worker needs a key in its environment. Keys set in the environment still win over Armada's: they are the override for CI and a self-hosted Armada without accounts.
|
|
5019
|
+
The secrets workers need to build and test (an LLM provider key, a test database URL) are kept per project in Armada: \`armada secrets set <NAME>\` (owner or admin; \`--org\` for every project) reads the value from a hidden prompt, \`--value-stdin\`, or \`--from-env <VAR>\`, which moves a variable you already have without you ever reading it. Never put a value on a command line or in a brief; \`armada secrets\` lists the names, and \`armada doctor\` names those \`[secrets] names\` in \`armada.toml\` expects and Armada lacks. Workers fetch them with \`armada run\`; a worker of another project never gets them.
|
|
4894
5020
|
2. **Find your coordination ticket.** When the owner gives the coordinator a ticket of its own (a run to carry out, for example "run this ticket end to end"), that ticket holds the run's history. Read its comments, newest first. A last comment \`Agent status: released — <text>\` is a hand-over: the previous coordinator stopped on purpose, \`<text>\` is the state it left (who runs, what was asked and answered, what remains), and the ticket is back without agent labels, waiting for you.
|
|
4895
5021
|
3. **Claim it with your own handle**, never the previous coordinator's: \`armada claim <ticket> --runtime <your runtime> --handle <your handle> --branch <default branch>\`. In a Conductor workspace the runtime is \`conductor\` and the handle \`"$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"\`; on a laptop, the runtime you run in (a value of the runtime label group, for example \`claude-code\`) and a handle that names your session. The claim is refused while the previous coordinator still holds the ticket: ask the owner whether it stopped before releasing it for them. Without a coordination ticket, skip this step.
|
|
4896
5022
|
4. **Read the fleet** (step 1 of the loop): \`armada status\` and \`armada inbox\` give each worker's handle, phase, question and hand-back. Trust them over the hand-over comment where they disagree: the comment is older. If a worker is in flight, start \`armada watch\` in the background now (see [Keep watching](#keep-watching)).
|
|
@@ -4925,6 +5051,7 @@ You only learn of something new when a command you run ends. So while a worker i
|
|
|
4925
5051
|
- Start it as soon as a worker is in flight, and start it again right after acting on what it returned. Never end your turn with a worker in flight and no watch running: that is how a hand-back sits unmerged.
|
|
4926
5052
|
- The last line of \`armada inbox\`, \`armada watch\`, \`armada merge\` and \`armada brief\` says whether to: \`2 workers in flight (ABC-1, ABC-2) — keep watching: armada watch\`, \`armada watch is already running (pid …)\`, or \`nothing to watch\`. Follow it. A second \`armada watch\` on the same project only says the first one is running.
|
|
4927
5053
|
- \`armada watch\` exits with "nothing to watch" when no worker is in flight and nothing is open: the round is over.
|
|
5054
|
+
- A \`version\` item means a newer Armada is out; any coordinator command also says so once, on stderr. It is not urgent: questions, plans, hand-backs and merges come first. Between rounds, upgrade the CLI with the \`npm install -g\` line it gives, run \`armada init\` and merge its pull request with \`armada merge <n> --no-ticket\`. Tell workers in flight nothing: each keeps the version its brief pinned, unless the release notes (the item's link) say otherwise. \`armada status\` and \`armada doctor\` say when this project's skills differ from your CLI's.
|
|
4928
5055
|
- Your own coordination ticket is not a worker: the watch and the re-arm line leave out the claim whose handle is yours, taken from \`ARMADA_COORDINATOR_HANDLE\`, else from Conductor's workspace and session. Outside Conductor, set \`ARMADA_COORDINATOR_HANDLE\` to the handle you claimed with.
|
|
4929
5056
|
- In Claude Code, the stop hook \`armada init\` installs refuses to end your turn while workers are in flight and no watch runs, and tells you to start one. It holds only the checkout where \`armada watch\` ran, never a worker. If it misbehaves, \`ARMADA_STOP_HOOK=off\` in the environment turns it off; say so in your report. Other runtimes have no hook: follow the same rule yourself.
|
|
4930
5057
|
- A runtime that cannot run a command in the background uses \`armada inbox --wait\` instead, again and again: it returns when a new item arrives or at its timeout (default 300 s, \`--timeout <seconds>\`; keep it under your command time limit).
|
|
@@ -5065,6 +5192,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
|
|
|
5065
5192
|
- **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.
|
|
5066
5193
|
- Work only in your own branch and worktree. Never touch another agent's checkout, and stop only the processes you started.
|
|
5067
5194
|
- Never print, commit or log a secret.
|
|
5195
|
+
- **The project's secrets** (an LLM provider key, a test database URL) come from Armada, never from your launch environment; \`armada secrets\` lists their names. Use them, in this order: \`armada run -- <command>\` for tests, builds and dev servers (they go in that command's environment only); \`armada secrets export --file <path>\` for a tool that reads a dotenv file, at a path git ignores (e.g. \`.env.local\`). Never run \`armada secrets get\`, and never echo, \`env\` or \`printenv\` a value: your command output is your transcript. A secret you need and do not have: ask the coordinator for it by name.
|
|
5068
5196
|
|
|
5069
5197
|
## Steps
|
|
5070
5198
|
|
|
@@ -5160,6 +5288,50 @@ function conductorSetup(text) {
|
|
|
5160
5288
|
}
|
|
5161
5289
|
var IGNORES_SHIP = new Set(["plans/ship-pr-dev/", "plans/ship-pr-dev", "plans/", "plans", "plans/*"]);
|
|
5162
5290
|
var ignoresShipArtifacts = (gitignore) => (gitignore ?? "").split(/\r?\n/).some((l) => IGNORES_SHIP.has(l.trim().replace(/^\//, "")));
|
|
5291
|
+
async function installedHash(view, name) {
|
|
5292
|
+
const folder = await view.readFolder(skillDir(name));
|
|
5293
|
+
return folder?.some((f) => f.path === "SKILL.md") ? skillFolderHash(folder) : null;
|
|
5294
|
+
}
|
|
5295
|
+
function behindOf(lock, differing) {
|
|
5296
|
+
if (!differing.length)
|
|
5297
|
+
return null;
|
|
5298
|
+
const refs = differing.flatMap((name) => {
|
|
5299
|
+
const ref = lock?.skills[name]?.ref;
|
|
5300
|
+
return typeof ref === "string" && /^v\d/.test(ref) ? [ref.slice(1)] : [];
|
|
5301
|
+
}).sort(compareVersions);
|
|
5302
|
+
return { recorded: refs[0] ?? null, newest: refs.at(-1) ?? null, differing };
|
|
5303
|
+
}
|
|
5304
|
+
var ahead = (b, cli) => b.newest && compareVersions(b.newest, cli) > 0 ? b.newest : null;
|
|
5305
|
+
function skillsBehindMessage(b, cli) {
|
|
5306
|
+
const which = `${b.differing.join(", ")} ${b.differing.length === 1 ? "differs" : "differ"}`;
|
|
5307
|
+
const newer = ahead(b, cli);
|
|
5308
|
+
if (newer)
|
|
5309
|
+
return `this project's Armada skills are ${newer} (${which}), newer than the CLI ${cli}`;
|
|
5310
|
+
return `this project's Armada skills are ${b.recorded ?? "of an unrecorded version"} (${which}), the CLI is ${cli}`;
|
|
5311
|
+
}
|
|
5312
|
+
function skillsBehindFix(b, cli) {
|
|
5313
|
+
const newer = ahead(b, cli);
|
|
5314
|
+
return newer ? `update the CLI, not the skills: ${installCommand(newer)}` : "run `armada init` and merge its PR (`armada merge <n> --no-ticket`)";
|
|
5315
|
+
}
|
|
5316
|
+
var skillsBehindLine = (b, cli) => `${skillsBehindMessage(b, cli)}: ${skillsBehindFix(b, cli)}`;
|
|
5317
|
+
async function skillsBehind(view) {
|
|
5318
|
+
let lock;
|
|
5319
|
+
try {
|
|
5320
|
+
lock = parseSkillsLock(await view.readFile(SKILLS_LOCK_FILE));
|
|
5321
|
+
} catch (err) {
|
|
5322
|
+
if (err instanceof SetupError)
|
|
5323
|
+
lock = null;
|
|
5324
|
+
else
|
|
5325
|
+
throw err;
|
|
5326
|
+
}
|
|
5327
|
+
const differing = [];
|
|
5328
|
+
for (const skill of BUNDLED_SKILLS) {
|
|
5329
|
+
const installed = await installedHash(view, skill.name);
|
|
5330
|
+
if (installed !== null && installed !== bundledHash(skill))
|
|
5331
|
+
differing.push(skill.name);
|
|
5332
|
+
}
|
|
5333
|
+
return behindOf(lock, differing);
|
|
5334
|
+
}
|
|
5163
5335
|
async function checkRepository(view, armadaVersion) {
|
|
5164
5336
|
const checks = [];
|
|
5165
5337
|
const configText = await view.readFile(CONFIG_FILE);
|
|
@@ -5189,17 +5361,20 @@ async function checkRepository(view, armadaVersion) {
|
|
|
5189
5361
|
if (lockError)
|
|
5190
5362
|
checks.push(bad("skills-lock", "error", lockError, `repair or delete ${SKILLS_LOCK_FILE}`));
|
|
5191
5363
|
const wholeDir = await linksWholeDir(view);
|
|
5364
|
+
const differing = [];
|
|
5365
|
+
let present = 0;
|
|
5192
5366
|
for (const skill of BUNDLED_SKILLS) {
|
|
5193
|
-
const
|
|
5194
|
-
const installed = folder?.some((f) => f.path === "SKILL.md") ? skillFolderHash(folder) : null;
|
|
5367
|
+
const installed = await installedHash(view, skill.name);
|
|
5195
5368
|
const id = `skill:${skill.name}`;
|
|
5196
5369
|
if (installed === null) {
|
|
5197
5370
|
checks.push(bad(id, "error", `skill ${skill.name} is missing from ${AGENTS_SKILLS_DIR}`, "run `armada init`"));
|
|
5198
5371
|
continue;
|
|
5199
5372
|
}
|
|
5200
|
-
|
|
5373
|
+
present++;
|
|
5374
|
+
if (installed !== bundledHash(skill)) {
|
|
5375
|
+
differing.push(skill.name);
|
|
5201
5376
|
checks.push(bad(id, "warning", `skill ${skill.name} differs from the version in Armada ${armadaVersion}`, "run `armada init` to open a pull request that updates it"));
|
|
5202
|
-
else
|
|
5377
|
+
} else
|
|
5203
5378
|
checks.push(ok(id, `skill ${skill.name} is up to date`));
|
|
5204
5379
|
const target = await view.readLink(linkPath(skill.name));
|
|
5205
5380
|
const linkId = `skill-link:${skill.name}`;
|
|
@@ -5220,6 +5395,11 @@ async function checkRepository(view, armadaVersion) {
|
|
|
5220
5395
|
else
|
|
5221
5396
|
checks.push(ok(lockId, `${SKILLS_LOCK_FILE} records ${skill.name}`));
|
|
5222
5397
|
}
|
|
5398
|
+
const behind = behindOf(lock, differing);
|
|
5399
|
+
if (behind)
|
|
5400
|
+
checks.push(bad("skills-version", "warning", skillsBehindMessage(behind, armadaVersion), skillsBehindFix(behind, armadaVersion)));
|
|
5401
|
+
else if (present)
|
|
5402
|
+
checks.push(ok("skills-version", `this project's Armada skills match Armada ${armadaVersion}'s`));
|
|
5223
5403
|
const settings = await view.readFile(CONDUCTOR_SETTINGS);
|
|
5224
5404
|
if (settings === null)
|
|
5225
5405
|
checks.push(bad("conductor", "error", `${CONDUCTOR_SETTINGS} is missing`, "run `armada init` to add it with a setup script"));
|
|
@@ -5524,10 +5704,26 @@ async function loadStatus(config, opts) {
|
|
|
5524
5704
|
});
|
|
5525
5705
|
}
|
|
5526
5706
|
// package.json
|
|
5527
|
-
var version = "0.2.
|
|
5707
|
+
var version = "0.2.9";
|
|
5528
5708
|
|
|
5529
5709
|
// src/api.ts
|
|
5530
|
-
var
|
|
5710
|
+
var runs = new WeakMap;
|
|
5711
|
+
function heard(io) {
|
|
5712
|
+
let h = runs.get(io);
|
|
5713
|
+
if (!h) {
|
|
5714
|
+
h = { server: null };
|
|
5715
|
+
runs.set(io, h);
|
|
5716
|
+
}
|
|
5717
|
+
return h;
|
|
5718
|
+
}
|
|
5719
|
+
var apiOf = (io, url, cliVersion = version) => armadaApi({
|
|
5720
|
+
url,
|
|
5721
|
+
version: cliVersion,
|
|
5722
|
+
onServerCli: (server) => {
|
|
5723
|
+
heard(io).server = server;
|
|
5724
|
+
},
|
|
5725
|
+
...io.fetch ? { fetch: io.fetch } : {}
|
|
5726
|
+
});
|
|
5531
5727
|
|
|
5532
5728
|
// src/io.ts
|
|
5533
5729
|
class UsageError extends Error {
|
|
@@ -5577,11 +5773,11 @@ async function fromArmada(io, credentials, purpose) {
|
|
|
5577
5773
|
return {
|
|
5578
5774
|
linearApiKey: answer.linear ? {
|
|
5579
5775
|
value: answer.linear.apiKey,
|
|
5580
|
-
detail: answer.linear.scope === "own" ? "your own key" : `the key of ${answer.organization.name}`
|
|
5776
|
+
detail: answer.linear.scope === "own" ? "your own key" : answer.linear.scope === "project" && purpose ? `the key of the project ${purpose.project}` : `the key of ${answer.organization.name}`
|
|
5581
5777
|
} : null
|
|
5582
5778
|
};
|
|
5583
5779
|
}
|
|
5584
|
-
async function loadCredentials(io, { armada = true, worker } = {}) {
|
|
5780
|
+
async function loadCredentials(io, { armada = true, worker, project } = {}) {
|
|
5585
5781
|
const machine = await loadMachine(io);
|
|
5586
5782
|
let ticket = null;
|
|
5587
5783
|
if (worker)
|
|
@@ -5604,7 +5800,8 @@ async function loadCredentials(io, { armada = true, worker } = {}) {
|
|
|
5604
5800
|
};
|
|
5605
5801
|
const local = resolveCredentials(sources);
|
|
5606
5802
|
const signIn = local.armadaSignIn;
|
|
5607
|
-
const
|
|
5803
|
+
const scoped = worker?.project ?? project;
|
|
5804
|
+
const purpose = worker && ticket ? { command: worker.command, project: worker.project, ticket } : scoped ? { project: scoped } : null;
|
|
5608
5805
|
if (signIn?.kind === "worker" && armada) {
|
|
5609
5806
|
if (signIn.project !== worker?.project)
|
|
5610
5807
|
throw new UsageError(`the worker session of ${signIn.ticket} is for the project ${signIn.project}, not ${worker?.project} (armada.toml): this repository is not its own`, `cd into the repository of ${signIn.project}`);
|
|
@@ -6271,6 +6468,42 @@ async function inbox2(io, config, credentials, a) {
|
|
|
6271
6468
|
return 0;
|
|
6272
6469
|
}
|
|
6273
6470
|
|
|
6471
|
+
// src/release.ts
|
|
6472
|
+
var NOTICE_COMMANDS = new Set(["status", "inbox", "watch", "brief", "merge", "doctor"]);
|
|
6473
|
+
function newer(io, running) {
|
|
6474
|
+
const server = heard(io).server;
|
|
6475
|
+
if (io.env.ARMADA_TICKET?.trim() || !server || compareVersions(running, server.minimum) < 0)
|
|
6476
|
+
return null;
|
|
6477
|
+
return newerRelease(running, server.latest);
|
|
6478
|
+
}
|
|
6479
|
+
async function noticedReleases(io) {
|
|
6480
|
+
const paths = machinePaths(io.env);
|
|
6481
|
+
return new Set(paths ? await readNoticedReleases(paths).catch(() => []) : []);
|
|
6482
|
+
}
|
|
6483
|
+
async function rememberRelease(io, version) {
|
|
6484
|
+
const paths = machinePaths(io.env);
|
|
6485
|
+
if (paths)
|
|
6486
|
+
await addNoticedRelease(paths, version).catch(() => {});
|
|
6487
|
+
}
|
|
6488
|
+
async function noticeRelease(io, running) {
|
|
6489
|
+
const latest = newer(io, running);
|
|
6490
|
+
if (!latest || (await noticedReleases(io)).has(latest))
|
|
6491
|
+
return;
|
|
6492
|
+
io.stderr(`armada: ${releaseLine(running, latest)}
|
|
6493
|
+
`);
|
|
6494
|
+
await rememberRelease(io, latest);
|
|
6495
|
+
}
|
|
6496
|
+
function pendingRelease(io, running, seen) {
|
|
6497
|
+
return async () => {
|
|
6498
|
+
const latest = newer(io, running);
|
|
6499
|
+
if (!latest || !machinePaths(io.env) || seen.includes(`version:${latest}`))
|
|
6500
|
+
return null;
|
|
6501
|
+
if ((await noticedReleases(io)).has(latest))
|
|
6502
|
+
return null;
|
|
6503
|
+
return releaseEntry(running, latest, (io.now ?? (() => new Date))());
|
|
6504
|
+
};
|
|
6505
|
+
}
|
|
6506
|
+
|
|
6274
6507
|
// src/watch.ts
|
|
6275
6508
|
function coordinatorHandle(io) {
|
|
6276
6509
|
const workspace = io.env.CONDUCTOR_WORKSPACE_ID?.trim();
|
|
@@ -6353,10 +6586,15 @@ async function watchUntil(io, config, credentials, json, configPath) {
|
|
|
6353
6586
|
await remember(io, project, { inFlight, readAt: now(io).toISOString() });
|
|
6354
6587
|
},
|
|
6355
6588
|
onRetry: (message) => io.stderr(`armada: warning: ${message}
|
|
6356
|
-
`)
|
|
6589
|
+
`),
|
|
6590
|
+
release: pendingRelease(io, version, before?.seen ?? [])
|
|
6357
6591
|
});
|
|
6358
6592
|
await remember(io, project, shown(io, report.items, report.inFlight));
|
|
6359
|
-
|
|
6593
|
+
for (const e of report.items)
|
|
6594
|
+
if (e.kind === "version" && e.version)
|
|
6595
|
+
await rememberRelease(io, e.version);
|
|
6596
|
+
const open = report.items.filter((e) => e.kind !== "version").length;
|
|
6597
|
+
const next = rearm({ inFlight: report.inFlight, open, running: null, act: true });
|
|
6360
6598
|
if (json)
|
|
6361
6599
|
io.stdout(`${JSON.stringify({ ...report, watch: next }, null, 2)}
|
|
6362
6600
|
`);
|
|
@@ -6781,13 +7019,36 @@ async function conductorChecks(io, config) {
|
|
|
6781
7019
|
}
|
|
6782
7020
|
];
|
|
6783
7021
|
}
|
|
7022
|
+
async function secretChecks(api, config, credentials) {
|
|
7023
|
+
const expected = config?.secrets.names ?? [];
|
|
7024
|
+
if (!config || !expected.length)
|
|
7025
|
+
return [];
|
|
7026
|
+
const signIn = credentials.armadaSignIn;
|
|
7027
|
+
const list = expected.join(", ");
|
|
7028
|
+
const warning = (message, fix) => [{ id: "secrets", level: "warning", message, fix }];
|
|
7029
|
+
if (!signIn)
|
|
7030
|
+
return warning(`the project expects the secrets ${list}; not checked: not signed in to Armada`, SIGN_IN_FIX);
|
|
7031
|
+
let set;
|
|
7032
|
+
try {
|
|
7033
|
+
set = (await api.listSecrets(signIn, projectOf(config))).map((s) => s.name);
|
|
7034
|
+
} catch (err) {
|
|
7035
|
+
if (!(err instanceof ArmadaApiError))
|
|
7036
|
+
throw err;
|
|
7037
|
+
return warning(`the project expects the secrets ${list}; not checked: ${err.message}`, err.next ?? "run doctor again once Armada answers");
|
|
7038
|
+
}
|
|
7039
|
+
const missing = expected.filter((n) => !set.includes(n));
|
|
7040
|
+
if (!missing.length)
|
|
7041
|
+
return [{ id: "secrets", level: "ok", message: `the secrets the project expects are set: ${list}`, fix: null }];
|
|
7042
|
+
return warning(`the project expects the secrets ${list}; not set in Armada: ${missing.join(", ")}`, "an owner or admin runs `armada secrets set <NAME>` for each (or sets it on the Keys page of Armada)");
|
|
7043
|
+
}
|
|
6784
7044
|
async function buildDoctor(io, armadaVersion) {
|
|
6785
7045
|
const root = (io.exec ? await gitRoot(io.exec, io.cwd) : null) ?? io.cwd;
|
|
6786
7046
|
const upgrade = (err) => err instanceof ArmadaApiError && err.upgrade ? err : null;
|
|
6787
7047
|
let outdated = null;
|
|
6788
7048
|
let loaded;
|
|
7049
|
+
const config = await projectConfig(root);
|
|
6789
7050
|
try {
|
|
6790
|
-
loaded = await loadCredentials(io);
|
|
7051
|
+
loaded = await loadCredentials(io, config ? { project: config.project.slug } : {});
|
|
6791
7052
|
} catch (err) {
|
|
6792
7053
|
outdated = upgrade(err);
|
|
6793
7054
|
if (!outdated)
|
|
@@ -6796,7 +7057,6 @@ async function buildDoctor(io, armadaVersion) {
|
|
|
6796
7057
|
}
|
|
6797
7058
|
const { machine, credentials } = loaded;
|
|
6798
7059
|
const api = apiOf(io, credentials.armadaApi.url, armadaVersion);
|
|
6799
|
-
const config = await projectConfig(root);
|
|
6800
7060
|
let signIn = [];
|
|
6801
7061
|
try {
|
|
6802
7062
|
signIn = await signInChecks(credentials, api);
|
|
@@ -6811,7 +7071,8 @@ async function buildDoctor(io, armadaVersion) {
|
|
|
6811
7071
|
...versionChecks(hostOf(credentials.armadaApi.url), api, armadaVersion, outdated),
|
|
6812
7072
|
...keyFileChecks(machine, credentials),
|
|
6813
7073
|
...await labelChecks(io, config, credentials),
|
|
6814
|
-
...await conductorChecks(io, config)
|
|
7074
|
+
...await conductorChecks(io, config),
|
|
7075
|
+
...await secretChecks(api, config, credentials)
|
|
6815
7076
|
];
|
|
6816
7077
|
return {
|
|
6817
7078
|
schemaVersion: 1,
|
|
@@ -7425,8 +7686,9 @@ async function statusAll(io, json) {
|
|
|
7425
7686
|
});
|
|
7426
7687
|
warning = read.warning;
|
|
7427
7688
|
const config = read.config;
|
|
7689
|
+
const own = p.ownLinearKey && !io.env.LINEAR_API_KEY?.trim() ? (await api.credentials(signIn, { project: p.slug })).linear?.apiKey : undefined;
|
|
7428
7690
|
const report = await loadStatus(config, {
|
|
7429
|
-
linearApiKey,
|
|
7691
|
+
linearApiKey: own ?? linearApiKey,
|
|
7430
7692
|
githubToken: credentials.githubToken,
|
|
7431
7693
|
...io.fetch ? { fetch: io.fetch } : {},
|
|
7432
7694
|
...io.now ? { now: io.now } : {}
|
|
@@ -7458,6 +7720,222 @@ ${"─".repeat(60)}
|
|
|
7458
7720
|
return projects.some((p) => p.error) ? 1 : 0;
|
|
7459
7721
|
}
|
|
7460
7722
|
|
|
7723
|
+
// src/secrets.ts
|
|
7724
|
+
import { dirname as dirname6, relative as relative3, resolve } from "node:path";
|
|
7725
|
+
var NAME_HINT = "upper snake case, e.g. OPENAI_API_KEY";
|
|
7726
|
+
var hhmm = (iso) => `${iso.slice(0, 16).replace("T", " ")} UTC`;
|
|
7727
|
+
function signInOf(config, credentials) {
|
|
7728
|
+
const signIn = credentials.armadaSignIn;
|
|
7729
|
+
if (!signIn)
|
|
7730
|
+
throw new UsageError("not signed in to Armada: a project's secrets are kept there", "armada login (a worker: the `armada login --launch-token` line of its launch message)");
|
|
7731
|
+
if (signIn.kind === "worker" && signIn.project !== config.project.slug)
|
|
7732
|
+
throw new UsageError(`the worker session of ${signIn.ticket} is for the project ${signIn.project}, not ${config.project.slug} (armada.toml): this repository is not its own`, `cd into the repository of ${signIn.project}`);
|
|
7733
|
+
return signIn;
|
|
7734
|
+
}
|
|
7735
|
+
function onlyOf(v) {
|
|
7736
|
+
if (v === undefined)
|
|
7737
|
+
return null;
|
|
7738
|
+
const names = v.split(",").map((n) => n.trim()).filter(Boolean);
|
|
7739
|
+
if (!names.length)
|
|
7740
|
+
throw new UsageError(`--only takes secret names separated by commas, ${NAME_HINT}`);
|
|
7741
|
+
const refusal = names.map(secretNameRefusal).find(Boolean);
|
|
7742
|
+
if (refusal)
|
|
7743
|
+
throw new UsageError(`--only: ${refusal}`);
|
|
7744
|
+
return [...new Set(names)];
|
|
7745
|
+
}
|
|
7746
|
+
function nameOf(rest, sub) {
|
|
7747
|
+
const [name, ...extra] = rest;
|
|
7748
|
+
if (extra.length)
|
|
7749
|
+
throw new UsageError(`secrets ${sub} takes one name: a value is never given on the command line, where it would stay in the shell history and in transcripts`, sub === "set" ? "armada secrets set <NAME>, then type the value at the hidden prompt" : null);
|
|
7750
|
+
if (!name)
|
|
7751
|
+
throw new UsageError(`secrets ${sub} needs a secret name, ${NAME_HINT}`);
|
|
7752
|
+
const refusal = secretNameRefusal(name);
|
|
7753
|
+
if (refusal)
|
|
7754
|
+
throw new UsageError(refusal);
|
|
7755
|
+
return name;
|
|
7756
|
+
}
|
|
7757
|
+
async function secretValue(io, name, options) {
|
|
7758
|
+
const variable = options["from-env"];
|
|
7759
|
+
const stdin = options["value-stdin"] === "true";
|
|
7760
|
+
if (variable !== undefined && stdin)
|
|
7761
|
+
throw new UsageError("--from-env and --value-stdin: one or the other");
|
|
7762
|
+
if (variable !== undefined) {
|
|
7763
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(variable))
|
|
7764
|
+
throw new UsageError("--from-env takes a variable name");
|
|
7765
|
+
const value = io.env[variable];
|
|
7766
|
+
if (!value)
|
|
7767
|
+
throw new UsageError(`${variable} is not set in this environment, so ${name} was not set`);
|
|
7768
|
+
return value;
|
|
7769
|
+
}
|
|
7770
|
+
if (stdin) {
|
|
7771
|
+
if (!io.readStdin)
|
|
7772
|
+
throw new UsageError("standard input cannot be read here");
|
|
7773
|
+
const value = (await io.readStdin()).replace(/\r?\n$/, "");
|
|
7774
|
+
if (!value)
|
|
7775
|
+
throw new UsageError(`standard input was empty, so ${name} was not set`);
|
|
7776
|
+
return value;
|
|
7777
|
+
}
|
|
7778
|
+
if (!io.interactive || !io.prompt)
|
|
7779
|
+
throw new UsageError(`no terminal to ask for the value of ${name}`, `--value-stdin to read it from standard input, or --from-env <VAR> to take it from a variable of this environment`);
|
|
7780
|
+
const value = await io.prompt(`${name} (hidden): `, { hidden: true });
|
|
7781
|
+
if (value === null)
|
|
7782
|
+
return null;
|
|
7783
|
+
if (!value)
|
|
7784
|
+
throw new UsageError(`no value given, so ${name} was not set`);
|
|
7785
|
+
return value;
|
|
7786
|
+
}
|
|
7787
|
+
function renderList(config, secrets) {
|
|
7788
|
+
const p = config.project.slug;
|
|
7789
|
+
if (!secrets.length)
|
|
7790
|
+
return `No secret for workers is set for ${p}.
|
|
7791
|
+
Next: armada secrets set <NAME> (an owner or admin), or the Keys page of Armada
|
|
7792
|
+
`;
|
|
7793
|
+
const width = Math.max(...secrets.map((s) => s.name.length));
|
|
7794
|
+
const lines = [`Secrets for workers of ${p} (names only; values stay in Armada)`];
|
|
7795
|
+
for (const s of secrets)
|
|
7796
|
+
lines.push(` ${s.name.padEnd(width)} ${s.scope.padEnd(12)} set by ${s.setBy}, ${hhmm(s.setAt)}${s.overridden ? " (the project's own wins)" : ""}`);
|
|
7797
|
+
return `${lines.join(`
|
|
7798
|
+
`)}
|
|
7799
|
+
`;
|
|
7800
|
+
}
|
|
7801
|
+
async function exportRefusal(io, path) {
|
|
7802
|
+
if (!io.exec)
|
|
7803
|
+
return "git cannot be run here to check that the file is ignored";
|
|
7804
|
+
const cwd = dirname6(path);
|
|
7805
|
+
const tracked = await io.exec("git", ["ls-files", "--error-unmatch", "--", path], { cwd }).catch(() => null);
|
|
7806
|
+
if (tracked?.code === 0)
|
|
7807
|
+
return `git tracks ${path}: secrets written there would be committed`;
|
|
7808
|
+
const ignored = await io.exec("git", ["check-ignore", "-q", "--", path], { cwd }).catch(() => null);
|
|
7809
|
+
if (ignored?.code === 0)
|
|
7810
|
+
return null;
|
|
7811
|
+
if (ignored?.code === 1)
|
|
7812
|
+
return `git does not ignore ${path}: secrets written there could be committed`;
|
|
7813
|
+
return `git cannot tell whether ${path} is ignored (is it in a git repository?)`;
|
|
7814
|
+
}
|
|
7815
|
+
async function secretsCommand(io, config, credentials, args) {
|
|
7816
|
+
const [sub = "list", ...rest] = args.rest;
|
|
7817
|
+
const signIn = signInOf(config, credentials);
|
|
7818
|
+
const api = apiOf(io, credentials.armadaApi.url);
|
|
7819
|
+
const project = projectOf(config);
|
|
7820
|
+
const p = config.project.slug;
|
|
7821
|
+
const allowed = {
|
|
7822
|
+
list: [],
|
|
7823
|
+
set: ["org", "value-stdin", "from-env"],
|
|
7824
|
+
unset: ["org"],
|
|
7825
|
+
get: [],
|
|
7826
|
+
export: ["file", "only"]
|
|
7827
|
+
};
|
|
7828
|
+
const options = allowed[sub];
|
|
7829
|
+
if (!options)
|
|
7830
|
+
throw new UsageError(`unknown secrets command "${sub}": list, set, unset, get or export`);
|
|
7831
|
+
for (const name of Object.keys(args.options))
|
|
7832
|
+
if (name !== "ticket" && !options.includes(name))
|
|
7833
|
+
throw new UsageError(`--${name} does not apply to secrets ${sub}`);
|
|
7834
|
+
if (args.json && sub !== "list")
|
|
7835
|
+
throw new UsageError(`--json does not apply to secrets ${sub}`);
|
|
7836
|
+
const scope = args.options.org === "true" ? "organization" : "project";
|
|
7837
|
+
const where = scope === "project" ? `the project ${p}` : "every project of the organization";
|
|
7838
|
+
if (sub === "list") {
|
|
7839
|
+
if (rest.length)
|
|
7840
|
+
throw new UsageError(`unexpected argument ${rest[0]}`);
|
|
7841
|
+
const secrets = await api.listSecrets(signIn, project);
|
|
7842
|
+
io.stdout(args.json ? `${JSON.stringify({ schemaVersion: 1, project: p, secrets }, null, 2)}
|
|
7843
|
+
` : renderList(config, secrets));
|
|
7844
|
+
return 0;
|
|
7845
|
+
}
|
|
7846
|
+
if (sub === "set") {
|
|
7847
|
+
const name = nameOf(rest, "set");
|
|
7848
|
+
const value = await secretValue(io, name, args.options);
|
|
7849
|
+
if (value === null) {
|
|
7850
|
+
io.stderr(`Cancelled. ${name} was not set.
|
|
7851
|
+
`);
|
|
7852
|
+
return 130;
|
|
7853
|
+
}
|
|
7854
|
+
await api.setSecret(signIn, { project, name, value, scope });
|
|
7855
|
+
io.stdout(`Set ${name} for ${where}. Workers get it on their next command.
|
|
7856
|
+
`);
|
|
7857
|
+
return 0;
|
|
7858
|
+
}
|
|
7859
|
+
if (sub === "unset") {
|
|
7860
|
+
const name = nameOf(rest, "unset");
|
|
7861
|
+
const deleted = await api.unsetSecret(signIn, { project, name, scope });
|
|
7862
|
+
io.stdout(deleted ? `Unset ${name} for ${where}.
|
|
7863
|
+
` : `${name} was not set for ${where}: nothing changed.
|
|
7864
|
+
`);
|
|
7865
|
+
return 0;
|
|
7866
|
+
}
|
|
7867
|
+
if (sub === "get") {
|
|
7868
|
+
const name = nameOf(rest, "get");
|
|
7869
|
+
const release = await api.releaseSecrets(signIn, project, [name]);
|
|
7870
|
+
for (const w of release.warnings)
|
|
7871
|
+
io.stderr(`! Armada: ${w}
|
|
7872
|
+
`);
|
|
7873
|
+
const found = release.secrets.find((s) => s.name === name);
|
|
7874
|
+
if (!found)
|
|
7875
|
+
throw new UsageError(`${name} is not set for ${p}`, "armada secrets, which lists the names set");
|
|
7876
|
+
io.stderr(`! The value of ${name} is now visible in this terminal, and in any transcript that reads this output. An agent never runs this: it uses \`armada run -- <command>\` or \`armada secrets export --file <path>\`.
|
|
7877
|
+
`);
|
|
7878
|
+
io.stdout(`${found.value}
|
|
7879
|
+
`);
|
|
7880
|
+
return 0;
|
|
7881
|
+
}
|
|
7882
|
+
if (rest.length)
|
|
7883
|
+
throw new UsageError(`unexpected argument ${rest[0]}`);
|
|
7884
|
+
const file = args.options.file;
|
|
7885
|
+
if (!file)
|
|
7886
|
+
throw new UsageError("secrets export needs --file <path>, a file git ignores (e.g. .env.local)");
|
|
7887
|
+
const path = resolve(io.cwd, file);
|
|
7888
|
+
const refusal = await exportRefusal(io, path);
|
|
7889
|
+
if (refusal)
|
|
7890
|
+
throw new UsageError(refusal, "a path git ignores, e.g. .env.local listed in .gitignore");
|
|
7891
|
+
const release = await api.releaseSecrets(signIn, project, onlyOf(args.options.only));
|
|
7892
|
+
for (const w of release.warnings)
|
|
7893
|
+
io.stderr(`! Armada: ${w}
|
|
7894
|
+
`);
|
|
7895
|
+
if (release.missing.length)
|
|
7896
|
+
io.stderr(`! Not set for ${p}: ${release.missing.join(", ")}
|
|
7897
|
+
`);
|
|
7898
|
+
const written = release.secrets.filter((s) => !/[\r\n\0]/.test(s.value));
|
|
7899
|
+
const skipped = release.secrets.filter((s) => !written.includes(s));
|
|
7900
|
+
if (skipped.length)
|
|
7901
|
+
io.stderr(`! Not written: ${skipped.map((s) => s.name).join(", ")}, whose value spans several lines; \`armada run -- <command>\` hands ${skipped.length === 1 ? "it" : "them"} over
|
|
7902
|
+
`);
|
|
7903
|
+
const lines = [
|
|
7904
|
+
`# The secrets for workers of ${p}, written by \`armada secrets export\`. Never commit this file.`,
|
|
7905
|
+
...written.map((s) => `${s.name}=${formatDotenvValue(s.name, s.value)}`)
|
|
7906
|
+
];
|
|
7907
|
+
await writePrivateFile(path, `${lines.join(`
|
|
7908
|
+
`)}
|
|
7909
|
+
`);
|
|
7910
|
+
const names = written.map((s) => s.name);
|
|
7911
|
+
io.stdout(`Wrote ${names.length} secret${names.length === 1 ? "" : "s"} of ${p} to ${relative3(io.cwd, path) || path} (mode 0600)${names.length ? `: ${names.join(", ")}` : ""}.
|
|
7912
|
+
`);
|
|
7913
|
+
return 0;
|
|
7914
|
+
}
|
|
7915
|
+
async function runCommand(io, config, credentials, args) {
|
|
7916
|
+
if (args.rest.length)
|
|
7917
|
+
throw new UsageError(`unexpected argument ${args.rest[0]}: the command goes after --`);
|
|
7918
|
+
const [command, ...commandArgs] = args.passthrough ?? [];
|
|
7919
|
+
if (!command)
|
|
7920
|
+
throw new UsageError("run needs a command after --, e.g. armada run -- bun test");
|
|
7921
|
+
if (!io.spawn)
|
|
7922
|
+
throw new UsageError("this terminal cannot run a command");
|
|
7923
|
+
const signIn = signInOf(config, credentials);
|
|
7924
|
+
const release = await apiOf(io, credentials.armadaApi.url).releaseSecrets(signIn, projectOf(config), onlyOf(args.options.only));
|
|
7925
|
+
for (const w of release.warnings)
|
|
7926
|
+
io.stderr(`! Armada: ${w}
|
|
7927
|
+
`);
|
|
7928
|
+
if (release.missing.length)
|
|
7929
|
+
io.stderr(`! Not set for ${config.project.slug}: ${release.missing.join(", ")}
|
|
7930
|
+
`);
|
|
7931
|
+
const values = Object.fromEntries(release.secrets.map((s) => [s.name, s.value]));
|
|
7932
|
+
const overridden = release.secrets.map((s) => s.name).filter((n) => io.env[n] !== undefined);
|
|
7933
|
+
if (overridden.length)
|
|
7934
|
+
io.stderr(`! armada run: the project's ${overridden.join(", ")} override${overridden.length === 1 ? "s" : ""} the variable${overridden.length === 1 ? "" : "s"} of the same name in this environment
|
|
7935
|
+
`);
|
|
7936
|
+
return io.spawn(command, commandArgs, { cwd: io.cwd, env: { ...io.env, ...values } });
|
|
7937
|
+
}
|
|
7938
|
+
|
|
7461
7939
|
// src/cli.ts
|
|
7462
7940
|
var COMMAND_HELP = {
|
|
7463
7941
|
status: ` status Tickets in flight, tickets ready to start and pull requests waiting
|
|
@@ -7539,6 +8017,26 @@ var COMMAND_HELP = {
|
|
|
7539
8017
|
default_profile; --profile overrides it, with --reason when it differs.
|
|
7540
8018
|
Signed in to Armada, the prompt starts with a one-time launch token, so
|
|
7541
8019
|
the worker needs no key. --prompt prints only the prompt, for \`--message-file -\`
|
|
8020
|
+
`,
|
|
8021
|
+
secrets: ` secrets The project's secrets for workers: names, project or organization,
|
|
8022
|
+
who set each and when; never a value. Needs a sign-in to Armada
|
|
8023
|
+
secrets set <NAME> [--org] [--value-stdin | --from-env <VAR>]
|
|
8024
|
+
Coordinator (owner or admin): set one for this project, or with --org
|
|
8025
|
+
for every project. The value comes from a hidden prompt, standard input
|
|
8026
|
+
or a variable of this environment, never from the command line
|
|
8027
|
+
secrets unset <NAME> [--org]
|
|
8028
|
+
Coordinator: unset one; workers no longer get it from their next command
|
|
8029
|
+
secrets export --file <path> [--only <A,B>]
|
|
8030
|
+
Write them to a dotenv file (mode 0600) for a tool that reads one;
|
|
8031
|
+
refused for a path git tracks or does not ignore
|
|
8032
|
+
secrets get <NAME>
|
|
8033
|
+
Print one value, for a person: it is then visible in any transcript.
|
|
8034
|
+
An agent uses \`armada run\` or \`secrets export\` instead
|
|
8035
|
+
`,
|
|
8036
|
+
run: ` run [--only <A,B>] -- <command> [args...]
|
|
8037
|
+
Run a command with the project's secrets in its environment (they win
|
|
8038
|
+
over variables of the same name, named on stderr): tests, builds, dev
|
|
8039
|
+
servers. Nothing is written to disk or printed. Exits with its code
|
|
7542
8040
|
`,
|
|
7543
8041
|
hook: ` hook stop Claude Code's Stop hook, installed by \`armada init\`: a coordinator
|
|
7544
8042
|
cannot end its turn while workers are in flight and no \`armada watch\`
|
|
@@ -7561,9 +8059,11 @@ var COMMAND_HELP = {
|
|
|
7561
8059
|
auth logout Remove Armada's keys from this machine
|
|
7562
8060
|
`
|
|
7563
8061
|
};
|
|
7564
|
-
var TICKET_OPTION = new Set(["report", "release", "ask", "merge"]);
|
|
8062
|
+
var TICKET_OPTION = new Set(["report", "release", "ask", "merge", "secrets", "run"]);
|
|
7565
8063
|
var CONFIG_OPTION = new Set([
|
|
7566
8064
|
"status",
|
|
8065
|
+
"secrets",
|
|
8066
|
+
"run",
|
|
7567
8067
|
"claim",
|
|
7568
8068
|
"report",
|
|
7569
8069
|
"release",
|
|
@@ -7574,7 +8074,7 @@ var CONFIG_OPTION = new Set([
|
|
|
7574
8074
|
"merge",
|
|
7575
8075
|
"brief"
|
|
7576
8076
|
]);
|
|
7577
|
-
var JSON_OPTION = new Set([...CONFIG_OPTION, "doctor", "auth", "whoami"]);
|
|
8077
|
+
var JSON_OPTION = new Set([...[...CONFIG_OPTION].filter((c) => c !== "run"), "doctor", "auth", "whoami"]);
|
|
7578
8078
|
var TICKET_HELP = ` --ticket <id> Ticket for report, release and ask (default ARMADA_TICKET, then the git
|
|
7579
8079
|
branch) and for merge (default: the ticket the PR branch names)
|
|
7580
8080
|
`;
|
|
@@ -7607,6 +8107,8 @@ Files:
|
|
|
7607
8107
|
\`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY)
|
|
7608
8108
|
config.toml personal defaults: language, [dashboard] url, [api] url
|
|
7609
8109
|
watch/<project>.* the project's watch: its lock, what you were shown, who is in flight
|
|
8110
|
+
releases.json the Armada releases you were told of: a coordinator command says once
|
|
8111
|
+
when a newer one is out (\`armada watch\` ends on it)
|
|
7610
8112
|
`;
|
|
7611
8113
|
function commandHelp(command) {
|
|
7612
8114
|
const block = Object.hasOwn(COMMAND_HELP, command) ? COMMAND_HELP[command] : undefined;
|
|
@@ -7645,9 +8147,23 @@ var VALUE_OPTIONS = [
|
|
|
7645
8147
|
"options",
|
|
7646
8148
|
"timeout",
|
|
7647
8149
|
"launch-token",
|
|
7648
|
-
"api-url"
|
|
8150
|
+
"api-url",
|
|
8151
|
+
"only",
|
|
8152
|
+
"file",
|
|
8153
|
+
"from-env"
|
|
8154
|
+
];
|
|
8155
|
+
var FLAG_OPTIONS = [
|
|
8156
|
+
"dry-run",
|
|
8157
|
+
"no-lock",
|
|
8158
|
+
"no-ticket",
|
|
8159
|
+
"prompt",
|
|
8160
|
+
"wait",
|
|
8161
|
+
"note",
|
|
8162
|
+
"api-key",
|
|
8163
|
+
"no-stop-hook",
|
|
8164
|
+
"org",
|
|
8165
|
+
"value-stdin"
|
|
7649
8166
|
];
|
|
7650
|
-
var FLAG_OPTIONS = ["dry-run", "no-lock", "no-ticket", "prompt", "wait", "note", "api-key", "no-stop-hook"];
|
|
7651
8167
|
var COMMAND_OPTIONS = {
|
|
7652
8168
|
claim: ["runtime", "handle", "branch", "profile", "reason"],
|
|
7653
8169
|
report: ["ticket", "message", "message-file", "plan", "plan-file", "pr", "sha"],
|
|
@@ -7658,7 +8174,9 @@ var COMMAND_OPTIONS = {
|
|
|
7658
8174
|
init: ["program-root", "name", "slug", "no-stop-hook"],
|
|
7659
8175
|
merge: ["ticket", "no-ticket", "dry-run", "no-lock", "wait", "timeout"],
|
|
7660
8176
|
brief: ["profile", "reason", "prompt"],
|
|
7661
|
-
login: ["api-key", "launch-token", "api-url"]
|
|
8177
|
+
login: ["api-key", "launch-token", "api-url"],
|
|
8178
|
+
secrets: ["ticket", "org", "value-stdin", "from-env", "file", "only"],
|
|
8179
|
+
run: ["ticket", "only"]
|
|
7662
8180
|
};
|
|
7663
8181
|
var WORKER_COMMANDS = new Set(["claim", "report", "release", "ask"]);
|
|
7664
8182
|
function parseArgs(argv) {
|
|
@@ -7670,10 +8188,15 @@ function parseArgs(argv) {
|
|
|
7670
8188
|
config: null,
|
|
7671
8189
|
help: false,
|
|
7672
8190
|
version: false,
|
|
7673
|
-
options: {}
|
|
8191
|
+
options: {},
|
|
8192
|
+
passthrough: null
|
|
7674
8193
|
};
|
|
7675
8194
|
for (let k = 0;k < argv.length; k++) {
|
|
7676
8195
|
const a = argv[k];
|
|
8196
|
+
if (a === "--") {
|
|
8197
|
+
args.passthrough = argv.slice(k + 1);
|
|
8198
|
+
break;
|
|
8199
|
+
}
|
|
7677
8200
|
const named = a?.match(/^--([a-z-]+)(?:=([\s\S]*))?$/);
|
|
7678
8201
|
const name = named?.[1];
|
|
7679
8202
|
if (a === "--json")
|
|
@@ -7705,18 +8228,18 @@ function parseArgs(argv) {
|
|
|
7705
8228
|
}
|
|
7706
8229
|
async function findConfig(io, explicit, command = "status") {
|
|
7707
8230
|
if (explicit) {
|
|
7708
|
-
const path =
|
|
8231
|
+
const path = resolve2(io.cwd, explicit);
|
|
7709
8232
|
const text = await io.readFile(path);
|
|
7710
8233
|
if (text === null)
|
|
7711
8234
|
throw new UsageError(`${path} does not exist`, `armada ${command} --config <file>, with the path of an ${CONFIG_FILE}`);
|
|
7712
8235
|
return { path, text };
|
|
7713
8236
|
}
|
|
7714
|
-
for (let dir =
|
|
8237
|
+
for (let dir = resolve2(io.cwd);; dir = dirname7(dir)) {
|
|
7715
8238
|
const path = join6(dir, CONFIG_FILE);
|
|
7716
8239
|
const text = await io.readFile(path);
|
|
7717
8240
|
if (text !== null)
|
|
7718
8241
|
return { path, text };
|
|
7719
|
-
if (
|
|
8242
|
+
if (dirname7(dir) === dir)
|
|
7720
8243
|
break;
|
|
7721
8244
|
}
|
|
7722
8245
|
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`);
|
|
@@ -7724,7 +8247,7 @@ async function findConfig(io, explicit, command = "status") {
|
|
|
7724
8247
|
async function status2(io, args) {
|
|
7725
8248
|
const { path, text } = await findConfig(io, args.config, "status");
|
|
7726
8249
|
const config = parseConfig(text, path);
|
|
7727
|
-
const { credentials } = await loadCredentials(io);
|
|
8250
|
+
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
7728
8251
|
const { linearApiKey, githubToken } = credentials;
|
|
7729
8252
|
if (!linearApiKey)
|
|
7730
8253
|
throw missingKey(LINEAR_KEY);
|
|
@@ -7736,6 +8259,9 @@ async function status2(io, args) {
|
|
|
7736
8259
|
...io.fetch ? { fetch: io.fetch } : {},
|
|
7737
8260
|
...io.now ? { now: io.now } : {}
|
|
7738
8261
|
});
|
|
8262
|
+
const behind = await skillsBehind(fsRepoView(dirname7(path))).catch(() => null);
|
|
8263
|
+
if (behind)
|
|
8264
|
+
report.warnings.push(skillsBehindLine(behind, version));
|
|
7739
8265
|
io.stdout(args.json ? `${JSON.stringify(report, null, 2)}
|
|
7740
8266
|
` : renderStatus(report));
|
|
7741
8267
|
return 0;
|
|
@@ -7773,6 +8299,13 @@ function nextStep(err, command) {
|
|
|
7773
8299
|
return null;
|
|
7774
8300
|
}
|
|
7775
8301
|
async function run(argv, io) {
|
|
8302
|
+
const code = await dispatch(argv, io);
|
|
8303
|
+
const command = commandOf(argv);
|
|
8304
|
+
if (command && NOTICE_COMMANDS.has(command))
|
|
8305
|
+
await noticeRelease(io, version).catch(() => {});
|
|
8306
|
+
return code;
|
|
8307
|
+
}
|
|
8308
|
+
async function dispatch(argv, io) {
|
|
7776
8309
|
try {
|
|
7777
8310
|
const args = parseArgs(argv);
|
|
7778
8311
|
if (args.version) {
|
|
@@ -7794,6 +8327,24 @@ async function run(argv, io) {
|
|
|
7794
8327
|
throw new UsageError(`--${name} does not apply to ${args.command}`);
|
|
7795
8328
|
if (args.all && args.command !== "status")
|
|
7796
8329
|
throw new UsageError(`--all does not apply to ${args.command}`);
|
|
8330
|
+
if (args.passthrough && args.command !== "run")
|
|
8331
|
+
throw new UsageError(`-- does not apply to ${args.command}: only \`armada run\` runs a command`);
|
|
8332
|
+
if (args.command === "secrets" || args.command === "run") {
|
|
8333
|
+
const { path, text } = await findConfig(io, args.config, args.command);
|
|
8334
|
+
const config = parseConfig(text, path);
|
|
8335
|
+
const sets = args.command === "secrets" && ["set", "unset"].includes(args.rest[0] ?? "");
|
|
8336
|
+
const { credentials } = await loadCredentials(io, {
|
|
8337
|
+
armada: false,
|
|
8338
|
+
...sets ? {} : {
|
|
8339
|
+
worker: {
|
|
8340
|
+
command: args.command,
|
|
8341
|
+
project: config.project.slug,
|
|
8342
|
+
ticket: (stored) => currentTicket(io, config, args.options.ticket, stored)
|
|
8343
|
+
}
|
|
8344
|
+
}
|
|
8345
|
+
});
|
|
8346
|
+
return await (args.command === "run" ? runCommand : secretsCommand)(io, config, credentials, args);
|
|
8347
|
+
}
|
|
7797
8348
|
const worker = { claim, report, release, ask, inbox: inbox2, answer }[args.command];
|
|
7798
8349
|
if (worker) {
|
|
7799
8350
|
const { path, text } = await findConfig(io, args.config, args.command);
|
|
@@ -7804,25 +8355,28 @@ async function run(argv, io) {
|
|
|
7804
8355
|
project: config.project.slug,
|
|
7805
8356
|
ticket: (stored) => command === "claim" ? args.rest[0]?.toUpperCase() ?? null : currentTicket(io, config, args.options.ticket, stored)
|
|
7806
8357
|
} : undefined;
|
|
7807
|
-
const { credentials } = await loadCredentials(io, scope ? { worker: scope } : {});
|
|
8358
|
+
const { credentials } = await loadCredentials(io, scope ? { worker: scope } : { project: config.project.slug });
|
|
7808
8359
|
return await worker(io, config, credentials, args);
|
|
7809
8360
|
}
|
|
7810
8361
|
if (args.command === "watch") {
|
|
7811
8362
|
const { path, text } = await findConfig(io, args.config, "watch");
|
|
7812
|
-
const
|
|
7813
|
-
|
|
8363
|
+
const config = parseConfig(text, path);
|
|
8364
|
+
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8365
|
+
return await watch2(io, config, credentials, args, path);
|
|
7814
8366
|
}
|
|
7815
8367
|
if (args.command === "hook")
|
|
7816
8368
|
return await hookStop(io, args.rest, (at) => findConfig(at, null, "hook"));
|
|
7817
8369
|
if (args.command === "merge") {
|
|
7818
8370
|
const { path, text } = await findConfig(io, args.config, "merge");
|
|
7819
|
-
const
|
|
7820
|
-
|
|
8371
|
+
const config = parseConfig(text, path);
|
|
8372
|
+
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8373
|
+
return await merge2(io, config, credentials, args, path);
|
|
7821
8374
|
}
|
|
7822
8375
|
if (args.command === "brief") {
|
|
7823
8376
|
const { path, text } = await findConfig(io, args.config, "brief");
|
|
7824
|
-
const
|
|
7825
|
-
|
|
8377
|
+
const config = parseConfig(text, path);
|
|
8378
|
+
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8379
|
+
return await brief2(io, config, credentials, args, version, path);
|
|
7826
8380
|
}
|
|
7827
8381
|
if (args.command === "status") {
|
|
7828
8382
|
noExtra(args.rest);
|
|
@@ -7908,6 +8462,35 @@ function echo(before, after) {
|
|
|
7908
8462
|
return "\b \b".repeat(before.length - common) + after.slice(common);
|
|
7909
8463
|
}
|
|
7910
8464
|
|
|
8465
|
+
// src/spawn.ts
|
|
8466
|
+
import { spawn } from "node:child_process";
|
|
8467
|
+
import { constants } from "node:os";
|
|
8468
|
+
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
8469
|
+
var spawnInherited = (command, args, { cwd, env }) => new Promise((done, fail) => {
|
|
8470
|
+
const child = spawn(command, args, { cwd, env, stdio: "inherit" });
|
|
8471
|
+
const fromTerminal = process.stdin.isTTY === true;
|
|
8472
|
+
const handlers = SIGNALS.map((signal) => {
|
|
8473
|
+
const handler = () => {
|
|
8474
|
+
if (signal !== "SIGINT" || !fromTerminal)
|
|
8475
|
+
child.kill(signal);
|
|
8476
|
+
};
|
|
8477
|
+
process.on(signal, handler);
|
|
8478
|
+
return [signal, handler];
|
|
8479
|
+
});
|
|
8480
|
+
const stop = () => {
|
|
8481
|
+
for (const [signal, handler] of handlers)
|
|
8482
|
+
process.off(signal, handler);
|
|
8483
|
+
};
|
|
8484
|
+
child.on("error", (err) => {
|
|
8485
|
+
stop();
|
|
8486
|
+
fail(err.code === "ENOENT" ? new Error(`${command}: command not found`) : err);
|
|
8487
|
+
});
|
|
8488
|
+
child.on("exit", (code, signal) => {
|
|
8489
|
+
stop();
|
|
8490
|
+
done(code ?? 128 + (signal ? constants.signals[signal] ?? 0 : 0));
|
|
8491
|
+
});
|
|
8492
|
+
});
|
|
8493
|
+
|
|
7911
8494
|
// src/main.ts
|
|
7912
8495
|
function gitBranch() {
|
|
7913
8496
|
try {
|
|
@@ -7965,7 +8548,7 @@ function openUrl(url) {
|
|
|
7965
8548
|
return false;
|
|
7966
8549
|
const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]];
|
|
7967
8550
|
try {
|
|
7968
|
-
const child =
|
|
8551
|
+
const child = spawn2(command, args, { stdio: "ignore", detached: true });
|
|
7969
8552
|
child.on("error", () => {});
|
|
7970
8553
|
child.unref();
|
|
7971
8554
|
return true;
|
|
@@ -7974,7 +8557,7 @@ function openUrl(url) {
|
|
|
7974
8557
|
}
|
|
7975
8558
|
}
|
|
7976
8559
|
var exec = (command, args, { cwd }) => new Promise((done, fail) => {
|
|
7977
|
-
const child =
|
|
8560
|
+
const child = spawn2(command, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
7978
8561
|
let stdout = "";
|
|
7979
8562
|
let stderr = "";
|
|
7980
8563
|
child.stdout.setEncoding("utf8").on("data", (d) => {
|
|
@@ -8002,6 +8585,7 @@ var code = await run(process.argv.slice(2), {
|
|
|
8002
8585
|
gitBranch,
|
|
8003
8586
|
readStdin,
|
|
8004
8587
|
exec,
|
|
8588
|
+
spawn: spawnInherited,
|
|
8005
8589
|
openUrl
|
|
8006
8590
|
});
|
|
8007
8591
|
process.exitCode = code;
|