@the-vibe-company/armada 0.2.59 → 0.2.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +13 -0
  2. package/dist/armada.js +171 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -706,4 +706,17 @@ pause_on_failure = true
706
706
 
707
707
  With `paths`, a merge that touches none of the globs prints one skip line and starts no watcher or deploy hold. Globs match repository-relative paths, including dot files. Missing or incomplete changed-file coverage (including renames whose original path is unknown) keeps the watcher. Omit `paths` to watch every merge on the target's branch. For an affected target, the live commit must equal the merged commit or be a verified descendant; smoke then runs as usual.
708
708
 
709
+ For commands that need a machine-specific linked folder, declare the setting by name:
710
+
711
+ ```toml
712
+ [[deploy.target]]
713
+ name = "worker"
714
+ live_sha_command = 'cd "$DEPLOY_LINK_DIR" && hosting-cli live-sha'
715
+ requires_env = ["DEPLOY_LINK_DIR"]
716
+ ```
717
+
718
+ On each coordinator machine, run `armada config set deploy.env.DEPLOY_LINK_DIR /path/to/linked-service` from the project checkout. Non-secret values are stored per project in `~/.config/armada/projects/<slug>.json` (or `$XDG_CONFIG_HOME/armada/projects/<slug>.json`), outside the repository. Machine values win over the process environment; only declared names are added to the target's live and smoke commands. Use `armada config unset deploy.env.DEPLOY_LINK_DIR` to return to the process environment. A damaged settings file produces a diagnostic and uses the process environment; `armada config set` repairs it. Keep secrets in Armada's vault and use `armada run` for commands that need them.
719
+
720
+ `armada doctor` names each target's missing settings and gives the exact `armada config set` fixes. Empty environment values count as missing. After a merge, a target missing a required setting emits one `deploy check skipped: <VAR> not set on this machine` warning and records `skipped (not configured on this machine)` without a merge hold or failure inbox item. A configured command that fails still pauses merges. After configuration, `armada deploy watch` can retry the skipped SHA. A machine-local skip preserves any real observation already recorded by another watcher for the same SHA.
721
+
709
722
  `armada deploy status` shows each target's latest state and any open deploy hold; `armada status` includes deploy states. Commands run at the repository root with `ARMADA_DEPLOY_SHA` and `ARMADA_DEPLOY_TARGET`, bounded to one minute and the deploy deadline. Declare `armada run -- <command>` when a command needs project secrets. Watchers share smoke results for the same live SHA. If background startup fails, the merge prints a command to run in a persistent terminal. See the [deployment runbook](docs/runbook.md#check-deployments-after-merges) for recovery and logs.
package/dist/armada.js CHANGED
@@ -2039,6 +2039,18 @@ function selectDeployTargets(targets, branch, coverage) {
2039
2039
  }
2040
2040
  return { targets: selected, skipped };
2041
2041
  }
2042
+ function resolveDeployEnv(target, local, processEnv) {
2043
+ const env = {};
2044
+ const missing = [];
2045
+ for (const name of target.requiresEnv ?? []) {
2046
+ const value = Object.hasOwn(local, name) ? local[name] : Object.hasOwn(processEnv, name) ? processEnv[name] : undefined;
2047
+ if (value?.trim())
2048
+ env[name] = value;
2049
+ else
2050
+ missing.push(name);
2051
+ }
2052
+ return { env, missing };
2053
+ }
2042
2054
  function deployDetail(output) {
2043
2055
  const lines = output.trim().split(`
2044
2056
  `).slice(-30).join(`
@@ -2129,7 +2141,7 @@ ${detail}`;
2129
2141
  }
2130
2142
  function deployLine(row, now) {
2131
2143
  const age = Math.max(0, Math.floor((now.getTime() - Date.parse(row.updatedAt)) / 60000));
2132
- return `${row.target}: ${row.state} ${row.sha}${row.state === "waiting" || row.state === "live" ? ` — watching since ${row.startedAt.slice(11, 16)}, no news for ${age} min${age >= 2 ? "; watcher may have stopped" : ""}` : ""}`;
2144
+ return `${row.target}: ${row.state === "skipped" ? "skipped (not configured on this machine)" : row.state} ${row.sha}${row.state === "waiting" || row.state === "live" ? ` — watching since ${row.startedAt.slice(11, 16)}, no news for ${age} min${age >= 2 ? "; watcher may have stopped" : ""}` : ""}`;
2133
2145
  }
2134
2146
 
2135
2147
  // ../../node_modules/.bun/smol-toml@1.9.0/node_modules/smol-toml/dist/error.js
@@ -3494,6 +3506,9 @@ function overlapLines(reading) {
3494
3506
  }
3495
3507
 
3496
3508
  // ../core/src/config.ts
3509
+ function deployEnvName(name) {
3510
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) && !["__proto__", "constructor", "prototype", "ARMADA_DEPLOY_SHA", "ARMADA_DEPLOY_TARGET"].includes(name);
3511
+ }
3497
3512
  var CONFIG_FILE = "armada.toml";
3498
3513
  var PLAN_POLICIES = ["approve", "pre-approved"];
3499
3514
  var routingLabelKey = (name) => name.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]/gu, "");
@@ -3912,6 +3927,7 @@ function parseConfig(text, source = CONFIG_FILE) {
3912
3927
  "name",
3913
3928
  "branch",
3914
3929
  "paths",
3930
+ "requires_env",
3915
3931
  "github_environment",
3916
3932
  "live_sha_command",
3917
3933
  "smoke",
@@ -3939,7 +3955,10 @@ function parseConfig(text, source = CONFIG_FILE) {
3939
3955
  if (problem || Array.isArray(row.paths) && !row.paths.length)
3940
3956
  problems.push(`"${path}.paths": ${problem ?? "must not be empty"}`);
3941
3957
  }
3958
+ if (row.requires_env !== undefined && (!Array.isArray(row.requires_env) || row.requires_env.some((name) => typeof name !== "string" || !deployEnvName(name))))
3959
+ problems.push(`"${path}.requires_env" must be an array of environment variable names (excluding reserved names)`);
3942
3960
  deployTargets.push({
3961
+ ...Array.isArray(row.requires_env) ? { requiresEnv: [...new Set(row.requires_env)] } : {},
3943
3962
  ...Array.isArray(row.paths) ? { paths: row.paths } : {},
3944
3963
  name,
3945
3964
  branch: optional("branch"),
@@ -4301,7 +4320,10 @@ repository = ${q(p.repository)}
4301
4320
  # paths = ["cmd/**", "internal/**"] # optional: only watch merges touching these globs
4302
4321
  # github_environment = "production"
4303
4322
  ## Alternative to github_environment (choose exactly one live source):
4304
- ## live_sha_command = "curl -fsS https://example.test/version"
4323
+ ## live_sha_command = 'cd "$DEPLOY_LINK_DIR" && hosting-cli live-sha'
4324
+ ## requires_env = ["DEPLOY_LINK_DIR"]
4325
+ ## On each coordinator machine: armada config set deploy.env.DEPLOY_LINK_DIR /path/to/linked-service
4326
+ ## Machine settings win over the process environment; missing settings skip without a hold.
4305
4327
  # smoke = "curl -fsS https://example.test/health"
4306
4328
  # timeout_minutes = 20 # 1–120; smoke shares this deadline
4307
4329
  # pause_on_failure = true
@@ -10939,6 +10961,58 @@ async function ensurePersonalConfig(paths) {
10939
10961
  await writePrivate(paths, paths.config, PERSONAL_CONFIG_TEMPLATE, 420);
10940
10962
  return true;
10941
10963
  }
10964
+ var projectSettingsPath = (paths, project) => {
10965
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(project))
10966
+ throw new Error("invalid project slug");
10967
+ return join(paths.dir, "projects", `${project}.json`);
10968
+ };
10969
+ async function readDeployEnv(paths, project) {
10970
+ const empty = { env: {}, warning: null };
10971
+ if (!paths)
10972
+ return empty;
10973
+ const path = projectSettingsPath(paths, project);
10974
+ let text;
10975
+ try {
10976
+ text = await readFile(path, "utf8");
10977
+ } catch (err) {
10978
+ if (missing(err))
10979
+ return empty;
10980
+ return {
10981
+ env: {},
10982
+ warning: `cannot read project machine settings in ${path}: ${err.code ?? "unknown error"}; using the process environment`
10983
+ };
10984
+ }
10985
+ try {
10986
+ const raw = JSON.parse(text);
10987
+ if (!isTable3(raw) || !isTable3(raw.deploy) || !isTable3(raw.deploy.env))
10988
+ throw new Error;
10989
+ const env = {};
10990
+ for (const [name, value] of Object.entries(raw.deploy.env)) {
10991
+ if (!deployEnvName(name) || typeof value !== "string" || !value.trim() || value.includes("\x00"))
10992
+ throw new Error;
10993
+ env[name] = value;
10994
+ }
10995
+ return { env, warning: null };
10996
+ } catch {
10997
+ return {
10998
+ env: {},
10999
+ warning: `invalid project machine settings in ${path}; using the process environment. armada config set repairs this file`
11000
+ };
11001
+ }
11002
+ }
11003
+ async function updateDeployEnv(paths, project, name, value) {
11004
+ if (!deployEnvName(name))
11005
+ throw new Error("invalid deploy environment variable name");
11006
+ if (value !== null && (!value.trim() || value.includes("\x00")))
11007
+ throw new Error("deploy setting must be a non-empty string without NUL");
11008
+ const { env } = await readDeployEnv(paths, project);
11009
+ if (value === null)
11010
+ delete env[name];
11011
+ else
11012
+ env[name] = value;
11013
+ await writePrivate(paths, projectSettingsPath(paths, project), `${JSON.stringify({ deploy: { env } }, null, 2)}
11014
+ `, 384);
11015
+ }
10942
11016
  function watchFiles(paths, project, name = "default") {
10943
11017
  if (!COORDINATOR.test(name))
10944
11018
  throw new Error("invalid coordinator name");
@@ -15804,7 +15878,7 @@ ${attachments.join(`
15804
15878
  };
15805
15879
  }
15806
15880
  // package.json
15807
- var version = "0.2.59";
15881
+ var version = "0.2.60";
15808
15882
 
15809
15883
  // src/io.ts
15810
15884
  class UsageError extends Error {
@@ -18223,6 +18297,29 @@ async function buildDoctor(io, armadaVersion, options = { readOnly: true }) {
18223
18297
  ...signIn,
18224
18298
  ...versionChecks(hostOf(credentials.armadaApi.url), api, armadaVersion, outdated),
18225
18299
  ...keyFileChecks(machine, credentials),
18300
+ ...await (async () => {
18301
+ if (!config?.deploy?.targets.length)
18302
+ return [];
18303
+ const local = await readDeployEnv(machine.paths, config.project.slug);
18304
+ const checks = config.deploy.targets.map((target) => {
18305
+ const { missing } = resolveDeployEnv(target, local.env, io.env);
18306
+ return {
18307
+ id: `deploy-env:${target.name}`,
18308
+ level: missing.length ? "warning" : "ok",
18309
+ message: missing.length ? `${target.name}: ${missing.join(", ")} not set on this machine; deploy check will be skipped` : `${target.name}: required deploy settings are configured`,
18310
+ fix: missing.length ? missing.map((name) => `armada config set deploy.env.${name} <value> --config ${shellWord(join4(root, CONFIG_FILE))}`).join(`
18311
+ `) : null
18312
+ };
18313
+ });
18314
+ if (local.warning)
18315
+ checks.unshift({
18316
+ id: "deploy-machine-settings",
18317
+ level: "warning",
18318
+ message: local.warning,
18319
+ fix: checks.find((c) => c.fix)?.fix ?? "armada config set deploy.env.<VAR> <value>"
18320
+ });
18321
+ return checks;
18322
+ })(),
18226
18323
  {
18227
18324
  id: "linear-key",
18228
18325
  level: credentials.sources.linearApiKey ? "ok" : "warning",
@@ -21219,6 +21316,22 @@ ${r.runId === null ? "Rerun" : `Run ${r.runId}`}: ${r.status === "refused" ? "re
21219
21316
  return reruns.some((r) => r.status !== "requested") ? 1 : 0;
21220
21317
  }
21221
21318
 
21319
+ // src/config.ts
21320
+ async function configCommand(io, config, args) {
21321
+ const [action, key, value, ...extra] = args.rest;
21322
+ const name = key?.startsWith("deploy.env.") ? key.slice("deploy.env.".length) : "";
21323
+ if (!deployEnvName(name) || extra.length || (action === "set" ? value === undefined : action !== "unset" || value !== undefined))
21324
+ throw new UsageError("use armada config set deploy.env.<VAR> <value> or armada config unset deploy.env.<VAR>");
21325
+ const paths = machinePaths(io.env);
21326
+ if (!paths)
21327
+ throw new UsageError("machine settings need HOME or XDG_CONFIG_HOME");
21328
+ await updateDeployEnv(paths, config.project.slug, name, action === "set" ? value : null);
21329
+ io.stdout(args.json ? `${JSON.stringify({ project: config.project.slug, key, action })}
21330
+ ` : `${key} ${action === "set" ? "set" : "unset"} for ${config.project.slug} on this machine.
21331
+ `);
21332
+ return 0;
21333
+ }
21334
+
21222
21335
  // src/deploy.ts
21223
21336
  import { createHash as createHash7, randomUUID } from "node:crypto";
21224
21337
  import { dirname as dirname7, join as join6 } from "node:path";
@@ -21245,12 +21358,41 @@ async function deployStatus(io, config, credentials) {
21245
21358
  const [rows, holds] = await Promise.all([fleet.deployState(), fleet.holds()]);
21246
21359
  return { rows, holds: holds.filter((h) => h.kind === "deploy") };
21247
21360
  }
21248
- async function startDeploys(io, config, _credentials, configPath, sha, targets, json) {
21361
+ async function skipUnconfigured(io, config, credentials, target, sha, missing) {
21362
+ io.stderr(`armada: ${target.name}: deploy check skipped: ${missing.join(", ")} not set on this machine
21363
+ `);
21364
+ const { fleet } = liveFleet(io, config, credentials);
21365
+ if (sha && fleet) {
21366
+ try {
21367
+ await recordDeploy(io, fleet.recordDeploy, {
21368
+ target: target.name,
21369
+ sha,
21370
+ state: "skipped",
21371
+ detail: `skipped (not configured on this machine): ${missing.join(", ")}`,
21372
+ pauseOnFailure: false
21373
+ });
21374
+ } catch {
21375
+ io.stderr(`armada: could not record skipped deploy state
21376
+ `);
21377
+ }
21378
+ }
21379
+ }
21380
+ async function startDeploys(io, config, credentials, configPath, sha, targets, json) {
21249
21381
  const results = [];
21382
+ const local = await readDeployEnv(machinePaths(io.env), config.project.slug);
21383
+ if (local.warning)
21384
+ io.stderr(`armada: ${local.warning}
21385
+ `);
21250
21386
  for (const name of targets) {
21251
21387
  const target = config.deploy?.targets.find((t) => t.name === name);
21252
21388
  if (!target)
21253
21389
  continue;
21390
+ const { missing } = resolveDeployEnv(target, local.env, io.env);
21391
+ if (missing.length) {
21392
+ await skipUnconfigured(io, config, credentials, target, sha, missing);
21393
+ results.push({ target: name, started: false, next: null, skipped: true });
21394
+ continue;
21395
+ }
21254
21396
  const args = ["deploy", "watch", "--sha", sha ?? "<merge-sha>", "--target", name, "--config", configPath];
21255
21397
  const next = `armada ${args.map(shellWord).join(" ")}`;
21256
21398
  let started = false;
@@ -21294,6 +21436,16 @@ async function deploy2(io, config, credentials, args, configPath) {
21294
21436
  if (!fleet || credentials.armadaSignIn?.kind === "worker")
21295
21437
  throw new UsageError(warning ?? "deploy watch needs an organization sign-in", "armada login");
21296
21438
  const paths = machinePaths(io.env);
21439
+ const local = await readDeployEnv(paths, config.project.slug);
21440
+ if (local.warning)
21441
+ io.stderr(`armada: ${local.warning}
21442
+ `);
21443
+ const settings = resolveDeployEnv(target, local.env, io.env);
21444
+ if (settings.missing.length) {
21445
+ await skipUnconfigured(io, config, credentials, target, sha, settings.missing);
21446
+ io.backgroundReady?.(true);
21447
+ return 0;
21448
+ }
21297
21449
  if (!paths)
21298
21450
  throw new UsageError("deploy watch needs HOME or XDG_CONFIG_HOME for its PID file");
21299
21451
  if (!io.exec)
@@ -21312,7 +21464,8 @@ async function deploy2(io, config, credentials, args, configPath) {
21312
21464
  credentials.armadaSignIn?.kind === "api-key" ? credentials.armadaSignIn.key : credentials.armadaSignIn?.token,
21313
21465
  credentials.linearApiKey,
21314
21466
  credentials.githubToken,
21315
- ...config.secrets.names.map((name) => io.env[name])
21467
+ ...config.secrets.names.map((name) => io.env[name]),
21468
+ ...Object.values(settings.env)
21316
21469
  ].filter((value) => !!value);
21317
21470
  const clean = (text) => redactSecrets(text, secrets);
21318
21471
  const ancestry = new Map;
@@ -21355,7 +21508,7 @@ async function deploy2(io, config, credentials, args, configPath) {
21355
21508
  timeoutMs: Math.max(1, Math.min(remainingMs, 60000)),
21356
21509
  maxOutputBytes: 64 * 1024,
21357
21510
  processGroup: true,
21358
- env: { ...io.env, ARMADA_DEPLOY_SHA: liveSha, ARMADA_DEPLOY_TARGET: target.name }
21511
+ env: { ...io.env, ...settings.env, ARMADA_DEPLOY_SHA: liveSha, ARMADA_DEPLOY_TARGET: target.name }
21359
21512
  });
21360
21513
  return {
21361
21514
  ok: result?.code === 0 && !result.timedOut,
@@ -21407,7 +21560,7 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
21407
21560
  };
21408
21561
  try {
21409
21562
  const prior = (await fleet.deployState({ target: target.name, sha }))[0];
21410
- if (prior && !["waiting", "live"].includes(prior.state)) {
21563
+ if (prior && !["waiting", "live", "skipped"].includes(prior.state)) {
21411
21564
  io.backgroundReady?.(true);
21412
21565
  io.stdout(`${target.name}: ${prior.state}
21413
21566
  `);
@@ -21424,7 +21577,7 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
21424
21577
  const result = await watchDeploy({
21425
21578
  target,
21426
21579
  sha,
21427
- ...prior ? { startedAt: new Date(prior.startedAt) } : {},
21580
+ ...prior && prior.state !== "skipped" ? { startedAt: new Date(prior.startedAt) } : {},
21428
21581
  now,
21429
21582
  sleep: sleepOf2(io),
21430
21583
  record: write,
@@ -25171,6 +25324,10 @@ async function done(io, config, credentials, a) {
25171
25324
 
25172
25325
  // src/cli.ts
25173
25326
  var COMMAND_HELP = {
25327
+ config: ` config set deploy.env.<VAR> <value>
25328
+ config unset deploy.env.<VAR>
25329
+ Set or remove a non-secret deploy setting for this project on this machine.
25330
+ `,
25174
25331
  deploy: ` deploy status [--json]
25175
25332
  deploy watch --sha <sha> --target <name>
25176
25333
  Watch a declared deploy and smoke check; failures pause merges.
@@ -25528,6 +25685,7 @@ var TICKET_OPTION = new Set([
25528
25685
  "unreserve"
25529
25686
  ]);
25530
25687
  var CONFIG_OPTION = new Set([
25688
+ "config",
25531
25689
  "acceptance",
25532
25690
  "lint",
25533
25691
  "job",
@@ -25603,6 +25761,7 @@ Files:
25603
25761
  credentials KEY=value lines, mode 0600, written by \`armada auth login\` and
25604
25762
  \`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY)
25605
25763
  config.toml personal defaults: language, [dashboard] url, [api] url
25764
+ projects/<slug>.json non-secret deploy settings for this project and machine
25606
25765
  coordinators.json coordinator role per project and checkout
25607
25766
  watch/<project>[@<name>].* the coordinator's watch: its lock, what you were shown, who is in flight
25608
25767
  releases.json daily release notices in status/inbox, with version and time.
@@ -26098,6 +26257,10 @@ async function dispatch(argv, io) {
26098
26257
  });
26099
26258
  return await heartbeat2(io, config, credentials, { ...args, config: path });
26100
26259
  }
26260
+ if (args.command === "config") {
26261
+ const { path, text } = await findConfig(io, args.config, "config", args.project);
26262
+ return await configCommand(io, parseConfig(text, path), args);
26263
+ }
26101
26264
  if (args.command === "deploy") {
26102
26265
  const { path, text } = await findConfig(io, args.config, "deploy", args.project);
26103
26266
  const config = parseConfig(text, path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-vibe-company/armada",
3
- "version": "0.2.59",
3
+ "version": "0.2.60",
4
4
  "type": "module",
5
5
  "description": "Run a fleet of coding agents on one project: the armada command line.",
6
6
  "license": "MIT",