@the-vibe-company/armada 0.2.8 → 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.
Files changed (2) hide show
  1. package/dist/armada.js +180 -14
  2. package/package.json +1 -1
package/dist/armada.js CHANGED
@@ -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);
@@ -3280,7 +3285,7 @@ function updateDotenv(text, updates) {
3280
3285
  ` : "";
3281
3286
  }
3282
3287
  // ../core/src/live.ts
3283
- var entryKey = (e) => e.id === null ? `silent:${e.ticket}` : `#${e.id}`;
3288
+ var entryKey = (e) => e.id !== null ? `#${e.id}` : e.version ? `version:${e.version}` : `silent:${e.ticket}`;
3284
3289
 
3285
3290
  // ../core/src/fleet-api.ts
3286
3291
  var WORKER_FLEET_OPS = ["claim", "report", "ask", "release"];
@@ -4005,14 +4010,36 @@ async function watchInbox(fleet, o) {
4005
4010
  for (const w of read.warnings)
4006
4011
  warnings.add(w);
4007
4012
  await o.onRead?.({ items, inFlight });
4008
- if (items.some((e) => e.new))
4009
- return report("items");
4010
- if (inFlight !== null && !inFlight.length && !items.length)
4011
- return report("nothing");
4012
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");
4013
4021
  await o.sleep(inFlight !== null && !inFlight.length ? idlePollMs : pollMs);
4014
4022
  }
4015
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
+ }
4016
4043
  var workers = (n) => `${n} worker${n === 1 ? "" : "s"} in flight`;
4017
4044
  function rearm(o) {
4018
4045
  const then = o.act ? "act on the items above, then " : "";
@@ -4278,6 +4305,23 @@ async function runningWatch(paths, project, alive = processAlive) {
4278
4305
  const pid = await readWatchLock(paths, project).catch(() => null);
4279
4306
  return pid !== null && alive(pid) ? pid : null;
4280
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
+ }
4281
4325
  // ../core/src/merge.ts
4282
4326
  var MERGE_LEASE = "merge";
4283
4327
  var MERGE_LEASE_TTL_MS = 20 * 60000;
@@ -5007,6 +5051,7 @@ You only learn of something new when a command you run ends. So while a worker i
5007
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.
5008
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.
5009
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.
5010
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.
5011
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.
5012
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).
@@ -5243,6 +5288,50 @@ function conductorSetup(text) {
5243
5288
  }
5244
5289
  var IGNORES_SHIP = new Set(["plans/ship-pr-dev/", "plans/ship-pr-dev", "plans/", "plans", "plans/*"]);
5245
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
+ }
5246
5335
  async function checkRepository(view, armadaVersion) {
5247
5336
  const checks = [];
5248
5337
  const configText = await view.readFile(CONFIG_FILE);
@@ -5272,17 +5361,20 @@ async function checkRepository(view, armadaVersion) {
5272
5361
  if (lockError)
5273
5362
  checks.push(bad("skills-lock", "error", lockError, `repair or delete ${SKILLS_LOCK_FILE}`));
5274
5363
  const wholeDir = await linksWholeDir(view);
5364
+ const differing = [];
5365
+ let present = 0;
5275
5366
  for (const skill of BUNDLED_SKILLS) {
5276
- const folder = await view.readFolder(skillDir(skill.name));
5277
- const installed = folder?.some((f) => f.path === "SKILL.md") ? skillFolderHash(folder) : null;
5367
+ const installed = await installedHash(view, skill.name);
5278
5368
  const id = `skill:${skill.name}`;
5279
5369
  if (installed === null) {
5280
5370
  checks.push(bad(id, "error", `skill ${skill.name} is missing from ${AGENTS_SKILLS_DIR}`, "run `armada init`"));
5281
5371
  continue;
5282
5372
  }
5283
- if (installed !== bundledHash(skill))
5373
+ present++;
5374
+ if (installed !== bundledHash(skill)) {
5375
+ differing.push(skill.name);
5284
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"));
5285
- else
5377
+ } else
5286
5378
  checks.push(ok(id, `skill ${skill.name} is up to date`));
5287
5379
  const target = await view.readLink(linkPath(skill.name));
5288
5380
  const linkId = `skill-link:${skill.name}`;
@@ -5303,6 +5395,11 @@ async function checkRepository(view, armadaVersion) {
5303
5395
  else
5304
5396
  checks.push(ok(lockId, `${SKILLS_LOCK_FILE} records ${skill.name}`));
5305
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`));
5306
5403
  const settings = await view.readFile(CONDUCTOR_SETTINGS);
5307
5404
  if (settings === null)
5308
5405
  checks.push(bad("conductor", "error", `${CONDUCTOR_SETTINGS} is missing`, "run `armada init` to add it with a setup script"));
@@ -5607,10 +5704,26 @@ async function loadStatus(config, opts) {
5607
5704
  });
5608
5705
  }
5609
5706
  // package.json
5610
- var version = "0.2.8";
5707
+ var version = "0.2.9";
5611
5708
 
5612
5709
  // src/api.ts
5613
- var apiOf = (io, url, cliVersion = version) => armadaApi({ url, version: cliVersion, ...io.fetch ? { fetch: io.fetch } : {} });
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
+ });
5614
5727
 
5615
5728
  // src/io.ts
5616
5729
  class UsageError extends Error {
@@ -6355,6 +6468,42 @@ async function inbox2(io, config, credentials, a) {
6355
6468
  return 0;
6356
6469
  }
6357
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
+
6358
6507
  // src/watch.ts
6359
6508
  function coordinatorHandle(io) {
6360
6509
  const workspace = io.env.CONDUCTOR_WORKSPACE_ID?.trim();
@@ -6437,10 +6586,15 @@ async function watchUntil(io, config, credentials, json, configPath) {
6437
6586
  await remember(io, project, { inFlight, readAt: now(io).toISOString() });
6438
6587
  },
6439
6588
  onRetry: (message) => io.stderr(`armada: warning: ${message}
6440
- `)
6589
+ `),
6590
+ release: pendingRelease(io, version, before?.seen ?? [])
6441
6591
  });
6442
6592
  await remember(io, project, shown(io, report.items, report.inFlight));
6443
- const next = rearm({ inFlight: report.inFlight, open: report.items.length, running: null, act: true });
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 });
6444
6598
  if (json)
6445
6599
  io.stdout(`${JSON.stringify({ ...report, watch: next }, null, 2)}
6446
6600
  `);
@@ -7953,6 +8107,8 @@ Files:
7953
8107
  \`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY)
7954
8108
  config.toml personal defaults: language, [dashboard] url, [api] url
7955
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)
7956
8112
  `;
7957
8113
  function commandHelp(command) {
7958
8114
  const block = Object.hasOwn(COMMAND_HELP, command) ? COMMAND_HELP[command] : undefined;
@@ -8103,6 +8259,9 @@ async function status2(io, args) {
8103
8259
  ...io.fetch ? { fetch: io.fetch } : {},
8104
8260
  ...io.now ? { now: io.now } : {}
8105
8261
  });
8262
+ const behind = await skillsBehind(fsRepoView(dirname7(path))).catch(() => null);
8263
+ if (behind)
8264
+ report.warnings.push(skillsBehindLine(behind, version));
8106
8265
  io.stdout(args.json ? `${JSON.stringify(report, null, 2)}
8107
8266
  ` : renderStatus(report));
8108
8267
  return 0;
@@ -8140,6 +8299,13 @@ function nextStep(err, command) {
8140
8299
  return null;
8141
8300
  }
8142
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) {
8143
8309
  try {
8144
8310
  const args = parseArgs(argv);
8145
8311
  if (args.version) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-vibe-company/armada",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "type": "module",
5
5
  "description": "Run a fleet of coding agents on one project: the armada command line.",
6
6
  "license": "MIT",