@the-vibe-company/armada 0.1.12 → 0.1.13

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 +2 -1
  2. package/dist/armada.js +226 -244
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -292,7 +292,8 @@ The program follows one convention: specs are direct children of the root titled
292
292
 
293
293
  ## Develop
294
294
 
295
- Requires [Bun](https://bun.sh) 1.3 or later.
295
+ Use the [Bun](https://bun.sh) version pinned in `package.json`'s `packageManager`
296
+ (currently 1.4.2). CI and release builds read the same pin.
296
297
 
297
298
  ```sh
298
299
  bun install
package/dist/armada.js CHANGED
@@ -1,22 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- var __create = Object.create;
4
- var __getProtoOf = Object.getPrototypeOf;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __toESM = (mod, isNodeMode, target) => {
9
- target = mod != null ? __create(__getProtoOf(mod)) : {};
10
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
- for (let key of __getOwnPropNames(mod))
12
- if (!__hasOwnProp.call(to, key))
13
- __defProp(to, key, {
14
- get: () => mod[key],
15
- enumerable: true
16
- });
17
- return to;
18
- };
19
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
2
 
21
3
  // src/main.ts
22
4
  import { spawn, spawnSync } from "node:child_process";
@@ -1135,8 +1117,8 @@ function parseDate(ctx, c, endChr) {
1135
1117
  if (!isDigit(ctx.s.charCodeAt(ctx.p++)))
1136
1118
  TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
1137
1119
  if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) {
1138
- let t2 = ctx.s.slice(startPtr, ctx.p);
1139
- return readDate(ctx, t2, 3, false, startPtr);
1120
+ let t = ctx.s.slice(startPtr, ctx.p);
1121
+ return readDate(ctx, t, 3, false, startPtr);
1140
1122
  }
1141
1123
  if (ctx.s.charCodeAt(ctx.p += 3) !== 58)
1142
1124
  TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
@@ -1147,12 +1129,12 @@ function parseDate(ctx, c, endChr) {
1147
1129
  ;
1148
1130
  if (c = ctx.s.charCodeAt(ctx.p)) {
1149
1131
  if (c === 90 || c === 122) {
1150
- let t2 = ctx.s.slice(startPtr, ++ctx.p);
1151
- return readDate(ctx, t2, 1, unsafeSeparator, startPtr, "[+00:00]");
1132
+ let t = ctx.s.slice(startPtr, ++ctx.p);
1133
+ return readDate(ctx, t, 1, unsafeSeparator, startPtr, "[+00:00]");
1152
1134
  }
1153
1135
  if (c === 43 || c === 45) {
1154
- let t2 = ctx.s.slice(startPtr, ctx.p += 6);
1155
- return readDate(ctx, t2, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
1136
+ let t = ctx.s.slice(startPtr, ctx.p += 6);
1137
+ return readDate(ctx, t, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
1156
1138
  }
1157
1139
  }
1158
1140
  let t = ctx.s.slice(startPtr, ctx.p);
@@ -1735,15 +1717,15 @@ function parseConfig(text, source = CONFIG_FILE) {
1735
1717
  continue;
1736
1718
  }
1737
1719
  known.push([path, r, ["labels", "profile"]]);
1738
- const labels2 = r.labels;
1739
- const ok = Array.isArray(labels2) && labels2.length && labels2.every((l) => typeof l === "string" && routingLabelKey(l));
1720
+ const labels = r.labels;
1721
+ const ok = Array.isArray(labels) && labels.length && labels.every((l) => typeof l === "string" && routingLabelKey(l));
1740
1722
  if (!ok)
1741
1723
  problems.push(`"${path}.labels" must be a non-empty list of Linear label names, each with a letter or digit`);
1742
1724
  const profile = str(r, path, "profile");
1743
1725
  if (profile && !Object.hasOwn(profiles, profile))
1744
1726
  problems.push(`"${path}.profile" is "${profile}", but there is no [conductor.profiles.${profile}]`);
1745
1727
  if (ok && profile)
1746
- routing.push({ labels: labels2.map((l) => l.trim()), profile });
1728
+ routing.push({ labels: labels.map((l) => l.trim()), profile });
1747
1729
  }
1748
1730
  if (Array.isArray(routingRaw) && routingRaw.length && conductorT.default_profile === undefined)
1749
1731
  problems.push(`"conductor.default_profile" is required with [[conductor.routing]], for tickets no rule matches`);
@@ -3425,8 +3407,8 @@ function attachPullRequests(program, forge) {
3425
3407
  }
3426
3408
  return program.issues.map((issue) => {
3427
3409
  const prs = issue.prs.map((p) => {
3428
- const live2 = byUrl.get(p.url);
3429
- return live2 ? { ...p, ...live2, title: live2.title || p.title } : p;
3410
+ const live = byUrl.get(p.url);
3411
+ return live ? { ...p, ...live, title: live.title || p.title } : p;
3430
3412
  });
3431
3413
  for (const p of byTicket.get(issue.id) ?? [])
3432
3414
  if (!prs.some((x) => x.url === p.url))
@@ -4725,11 +4707,11 @@ var SKILLS_LOCK_FILE = "skills-lock.json";
4725
4707
  var CONDUCTOR_SETTINGS = ".conductor/settings.toml";
4726
4708
  var GITIGNORE = ".gitignore";
4727
4709
  var SHIP_ARTIFACTS = "plans/ship-pr-dev/";
4728
- var ok = (id, message2) => ({ id, level: "ok", message: message2, fix: null });
4729
- var bad = (id, level, message2, fix) => ({
4710
+ var ok = (id, message) => ({ id, level: "ok", message, fix: null });
4711
+ var bad = (id, level, message, fix) => ({
4730
4712
  id,
4731
4713
  level,
4732
- message: message2,
4714
+ message,
4733
4715
  fix
4734
4716
  });
4735
4717
  var skillDir = (name) => `${AGENTS_SKILLS_DIR}/${name}`;
@@ -4958,7 +4940,7 @@ function buildStatus({
4958
4940
  forge,
4959
4941
  forgeError = null,
4960
4942
  lastEvents,
4961
- live: live2,
4943
+ live,
4962
4944
  extraWarnings = [],
4963
4945
  now
4964
4946
  }) {
@@ -4968,7 +4950,7 @@ function buildStatus({
4968
4950
  now: now.getTime(),
4969
4951
  silentAfterMinutes: config.policy.silentAfterMinutes,
4970
4952
  ...lastEvents ? { lastEvents } : {},
4971
- ...live2 ? { live: live2 } : {}
4953
+ ...live ? { live } : {}
4972
4954
  });
4973
4955
  const phaseOf = new Map(lanes.map((l) => [l.issue.id, l.phase]));
4974
4956
  const prRef = (p) => ({
@@ -4998,7 +4980,7 @@ function buildStatus({
4998
4980
  phaseSource: l.phaseSource,
4999
4981
  runtime: l.runtime,
5000
4982
  handle: l.handle,
5001
- profile: live2?.handles?.[l.issue.id]?.profile ?? l.claim?.profile ?? null,
4983
+ profile: live?.handles?.[l.issue.id]?.profile ?? l.claim?.profile ?? null,
5002
4984
  agent: l.agent,
5003
4985
  since: l.since,
5004
4986
  lastUpdate: l.lastUpdate,
@@ -5043,13 +5025,13 @@ async function readStatusSources(config, opts) {
5043
5025
  repository: config.github.repository,
5044
5026
  ...opts.fetch ? { fetch: opts.fetch } : {},
5045
5027
  now
5046
- }).then((forge2) => ({ forge: forge2, forgeError: null }), (err) => ({ forge: null, forgeError: err instanceof Error ? err.message : String(err) })) : Promise.resolve({ forge: null, forgeError: "no GitHub token (set GITHUB_TOKEN or run gh auth login)" });
5028
+ }).then((forge) => ({ forge, forgeError: null }), (err) => ({ forge: null, forgeError: err instanceof Error ? err.message : String(err) })) : Promise.resolve({ forge: null, forgeError: "no GitHub token (set GITHUB_TOKEN or run gh auth login)" });
5047
5029
  const [program, forge] = await Promise.all([programP, forgeP]);
5048
5030
  return { program, ...forge };
5049
5031
  }
5050
5032
  async function loadStatus(config, opts) {
5051
5033
  const now = opts.now ?? (() => new Date);
5052
- const eventsP = opts.lastEvents ? opts.lastEvents().then((events2) => ({ events: events2 }), (err) => ({
5034
+ const eventsP = opts.lastEvents ? opts.lastEvents().then((events) => ({ events }), (err) => ({
5053
5035
  warning: `Turso could not be read (${err instanceof Error ? err.message : String(err)}); silence is measured from Linear only`
5054
5036
  })) : Promise.resolve({});
5055
5037
  const [{ program, forge, forgeError }, events] = await Promise.all([readStatusSources(config, opts), eventsP]);
@@ -5064,13 +5046,13 @@ async function loadStatus(config, opts) {
5064
5046
  });
5065
5047
  }
5066
5048
  // package.json
5067
- var version = "0.1.12";
5049
+ var version = "0.1.13";
5068
5050
 
5069
5051
  // src/io.ts
5070
5052
  class UsageError extends Error {
5071
5053
  next;
5072
- constructor(message2, next = null) {
5073
- super(message2);
5054
+ constructor(message, next = null) {
5055
+ super(message);
5074
5056
  this.next = next;
5075
5057
  }
5076
5058
  }
@@ -5088,14 +5070,14 @@ async function loadMachine(io) {
5088
5070
  return { paths, store, personal };
5089
5071
  }
5090
5072
  async function loadCredentials(io) {
5091
- const machine2 = await loadMachine(io);
5092
- const credentials2 = resolveCredentials({
5073
+ const machine = await loadMachine(io);
5074
+ const credentials = resolveCredentials({
5093
5075
  env: io.env,
5094
5076
  ghToken: io.ghToken,
5095
- ...machine2.store ? { store: machine2.store.values } : {},
5096
- ...machine2.personal ? { personal: machine2.personal.config } : {}
5077
+ ...machine.store ? { store: machine.store.values } : {},
5078
+ ...machine.personal ? { personal: machine.personal.config } : {}
5097
5079
  });
5098
- return { machine: machine2, credentials: credentials2 };
5080
+ return { machine, credentials };
5099
5081
  }
5100
5082
  var describeSource = (s) => {
5101
5083
  switch (s.kind) {
@@ -5115,8 +5097,8 @@ function requirePaths(paths) {
5115
5097
  return paths;
5116
5098
  throw new UsageError(`neither HOME nor XDG_CONFIG_HOME is set, so there is no place to store keys on this machine. Set ${STORED_KEYS.map((k) => k.variable).join(", ")} in the environment instead.`);
5117
5099
  }
5118
- function storeWarnings(machine2) {
5119
- const store = machine2.store;
5100
+ function storeWarnings(machine) {
5101
+ const store = machine.store;
5120
5102
  if (!store?.exists)
5121
5103
  return [];
5122
5104
  const warnings = [];
@@ -5127,17 +5109,17 @@ function storeWarnings(machine2) {
5127
5109
  return warnings;
5128
5110
  }
5129
5111
  async function authLogin(io) {
5130
- const { machine: machine2, credentials: credentials2 } = await loadCredentials(io);
5131
- const missing2 = missingKeys(credentials2);
5132
- if (!missing2.length) {
5112
+ const { machine, credentials } = await loadCredentials(io);
5113
+ const missing = missingKeys(credentials);
5114
+ if (!missing.length) {
5133
5115
  io.stdout("Every Armada key is already set. Run `armada auth status` to see where each comes from.\n");
5134
5116
  return 0;
5135
5117
  }
5136
- const paths = requirePaths(machine2.paths);
5118
+ const paths = requirePaths(machine.paths);
5137
5119
  if (!io.interactive || !io.prompt) {
5138
- const width = Math.max(...missing2.map((k) => k.variable.length));
5120
+ const width = Math.max(...missing.map((k) => k.variable.length));
5139
5121
  io.stderr(`armada: auth login needs an interactive terminal. Set these environment variables instead:
5140
- ${missing2.map((k) => ` ${k.variable.padEnd(width)} ${k.label}: ${k.hint}`).join(`
5122
+ ${missing.map((k) => ` ${k.variable.padEnd(width)} ${k.label}: ${k.hint}`).join(`
5141
5123
  `)}
5142
5124
  or add them as KEY=value lines to ${paths.credentials} (mode 0600).
5143
5125
  `);
@@ -5147,7 +5129,7 @@ or add them as KEY=value lines to ${paths.credentials} (mode 0600).
5147
5129
  Leave an answer empty to skip it.
5148
5130
  `);
5149
5131
  const updates = {};
5150
- for (const key of missing2) {
5132
+ for (const key of missing) {
5151
5133
  io.stderr(`
5152
5134
  ${key.label}: ${key.hint}
5153
5135
  `);
@@ -5174,52 +5156,52 @@ Saved ${saved.join(", ")} in ${paths.credentials}.
5174
5156
  io.stdout(`
5175
5157
  Nothing saved.
5176
5158
  `);
5177
- const skipped = missing2.filter((k) => !saved.includes(k.variable)).map((k) => k.variable);
5159
+ const skipped = missing.filter((k) => !saved.includes(k.variable)).map((k) => k.variable);
5178
5160
  if (skipped.length)
5179
5161
  io.stdout(`Still missing: ${skipped.join(", ")}. Run \`armada auth login\` again to add them.
5180
5162
  `);
5181
5163
  return 0;
5182
5164
  }
5183
- function buildAuthStatus(machine2, credentials2) {
5165
+ function buildAuthStatus(machine, credentials) {
5184
5166
  const keys = [
5185
- ...STORED_KEYS.map((k) => ({ variable: k.variable, label: k.label, source: credentials2.sources[k.name] })),
5186
- { variable: "GITHUB_TOKEN", label: "GitHub token", source: credentials2.sources.githubToken }
5167
+ ...STORED_KEYS.map((k) => ({ variable: k.variable, label: k.label, source: credentials.sources[k.name] })),
5168
+ { variable: "GITHUB_TOKEN", label: "GitHub token", source: credentials.sources.githubToken }
5187
5169
  ].map((k) => ({ ...k, present: k.source !== null }));
5188
5170
  return {
5189
5171
  schemaVersion: 1,
5190
5172
  keys,
5191
- credentialsFile: machine2.store ? {
5192
- path: machine2.store.path,
5193
- exists: machine2.store.exists,
5194
- mode: machine2.store.mode === null ? null : octal(machine2.store.mode)
5173
+ credentialsFile: machine.store ? {
5174
+ path: machine.store.path,
5175
+ exists: machine.store.exists,
5176
+ mode: machine.store.mode === null ? null : octal(machine.store.mode)
5195
5177
  } : null,
5196
- personalConfig: machine2.paths && machine2.personal ? { path: machine2.paths.config, exists: machine2.personal.exists } : null,
5197
- warnings: storeWarnings(machine2)
5178
+ personalConfig: machine.paths && machine.personal ? { path: machine.paths.config, exists: machine.personal.exists } : null,
5179
+ warnings: storeWarnings(machine)
5198
5180
  };
5199
5181
  }
5200
- function renderAuthStatus(status2) {
5201
- const width = Math.max(...status2.keys.map((k) => k.variable.length));
5182
+ function renderAuthStatus(status) {
5183
+ const width = Math.max(...status.keys.map((k) => k.variable.length));
5202
5184
  const lines = ["Armada keys"];
5203
- for (const k of status2.keys) {
5185
+ for (const k of status.keys) {
5204
5186
  const where = k.source ? describeSource(k.source) : k.variable === "GITHUB_TOKEN" ? "set GITHUB_TOKEN or run `gh auth login`" : `set ${k.variable} or run \`armada auth login\``;
5205
5187
  lines.push(` ${k.variable.padEnd(width)} ${(k.present ? "set" : "missing").padEnd(7)} ${where}`);
5206
5188
  }
5207
5189
  lines.push("");
5208
- const file = status2.credentialsFile;
5190
+ const file = status.credentialsFile;
5209
5191
  lines.push(file ? `Credentials file ${file.path}${file.exists ? ` (mode ${file.mode})` : " (not created yet)"}` : "Credentials file none: neither HOME nor XDG_CONFIG_HOME is set");
5210
- if (status2.personalConfig)
5211
- lines.push(`Personal config ${status2.personalConfig.path}${status2.personalConfig.exists ? "" : " (not created yet)"}`);
5212
- for (const w of status2.warnings)
5192
+ if (status.personalConfig)
5193
+ lines.push(`Personal config ${status.personalConfig.path}${status.personalConfig.exists ? "" : " (not created yet)"}`);
5194
+ for (const w of status.warnings)
5213
5195
  lines.push(`! ${w}`);
5214
5196
  return `${lines.join(`
5215
5197
  `)}
5216
5198
  `;
5217
5199
  }
5218
5200
  async function authStatus(io, json) {
5219
- const { machine: machine2, credentials: credentials2 } = await loadCredentials(io);
5220
- const status2 = buildAuthStatus(machine2, credentials2);
5221
- io.stdout(json ? `${JSON.stringify(status2, null, 2)}
5222
- ` : renderAuthStatus(status2));
5201
+ const { machine, credentials } = await loadCredentials(io);
5202
+ const status = buildAuthStatus(machine, credentials);
5203
+ io.stdout(json ? `${JSON.stringify(status, null, 2)}
5204
+ ` : renderAuthStatus(status));
5223
5205
  return 0;
5224
5206
  }
5225
5207
  async function authLogout(io) {
@@ -5234,9 +5216,9 @@ async function authLogout(io) {
5234
5216
  io.stdout(`Removed ${stored.map((k) => k.variable).join(", ")} from ${paths.credentials}.
5235
5217
  `);
5236
5218
  }
5237
- const fromEnv2 = STORED_KEYS.filter((k) => io.env[k.variable]?.trim()).map((k) => k.variable);
5238
- if (fromEnv2.length)
5239
- io.stdout(`Still set in the environment, and still used: ${fromEnv2.join(", ")}. Unset them to stop using them.
5219
+ const fromEnv = STORED_KEYS.filter((k) => io.env[k.variable]?.trim()).map((k) => k.variable);
5220
+ if (fromEnv.length)
5221
+ io.stdout(`Still set in the environment, and still used: ${fromEnv.join(", ")}. Unset them to stop using them.
5240
5222
  `);
5241
5223
  return 0;
5242
5224
  }
@@ -5268,7 +5250,7 @@ function renderBrief(b) {
5268
5250
  return out.join(`
5269
5251
  `);
5270
5252
  }
5271
- async function brief2(io, config2, credentials2, a, version2) {
5253
+ async function brief2(io, config, credentials, a, version) {
5272
5254
  const [ticket, ...extra] = a.rest;
5273
5255
  if (!ticket)
5274
5256
  throw new UsageError('brief needs a ticket: armada brief <ticket> [--profile <name> [--reason "<why>"]]');
@@ -5282,24 +5264,24 @@ async function brief2(io, config2, credentials2, a, version2) {
5282
5264
  if (reason && !profile)
5283
5265
  throw new UsageError("--reason goes with --profile: it says why the routed profile is not used");
5284
5266
  try {
5285
- checkRequestedProfile(config2, profile);
5267
+ checkRequestedProfile(config, profile);
5286
5268
  } catch (err) {
5287
5269
  if (err instanceof ProfileError)
5288
5270
  throw new UsageError(err.message);
5289
5271
  throw err;
5290
5272
  }
5291
- if (!credentials2.linearApiKey)
5273
+ if (!credentials.linearApiKey)
5292
5274
  throw missingKey(LINEAR_KEY);
5293
5275
  let b;
5294
5276
  try {
5295
- b = await loadBrief(config2, {
5296
- linearApiKey: credentials2.linearApiKey,
5277
+ b = await loadBrief(config, {
5278
+ linearApiKey: credentials.linearApiKey,
5297
5279
  ticket: ticket.toUpperCase(),
5298
5280
  profile,
5299
5281
  reason,
5300
- version: version2,
5282
+ version,
5301
5283
  env: io.env,
5302
- stored: STORED_KEYS.filter((k) => credentials2.sources[k.name]?.kind === "store").map((k) => k.variable),
5284
+ stored: STORED_KEYS.filter((k) => credentials.sources[k.name]?.kind === "store").map((k) => k.variable),
5303
5285
  ...io.fetch ? { fetch: io.fetch } : {},
5304
5286
  ...io.now ? { now: io.now } : {}
5305
5287
  });
@@ -5416,9 +5398,9 @@ async function labelChecks(io, root) {
5416
5398
  const text = await fsRepoView(root).readFile(CONFIG_FILE);
5417
5399
  if (text === null)
5418
5400
  return [];
5419
- let config2;
5401
+ let config;
5420
5402
  try {
5421
- config2 = parseConfig(text, CONFIG_FILE);
5403
+ config = parseConfig(text, CONFIG_FILE);
5422
5404
  } catch (err) {
5423
5405
  if (err instanceof ConfigError)
5424
5406
  return [];
@@ -5435,7 +5417,7 @@ async function labelChecks(io, root) {
5435
5417
  }
5436
5418
  ];
5437
5419
  try {
5438
- const state = await readLabels(config2, { apiKey: linearApiKey, ...io.fetch ? { fetch: io.fetch } : {} });
5420
+ const state = await readLabels(config, { apiKey: linearApiKey, ...io.fetch ? { fetch: io.fetch } : {} });
5439
5421
  return checkLabels(state);
5440
5422
  } catch (err) {
5441
5423
  return [
@@ -5493,11 +5475,11 @@ async function doctor(io, json, armadaVersion) {
5493
5475
 
5494
5476
  // src/worker.ts
5495
5477
  var TURSO_OPEN_TIMEOUT_MS = 1e4;
5496
- async function openLive(credentials2) {
5497
- if (!credentials2.tursoUrl)
5478
+ async function openLive(credentials) {
5479
+ if (!credentials.tursoUrl)
5498
5480
  return { db: null, warning: "Turso is not configured (ARMADA_TURSO_URL); live activity is not recorded" };
5499
5481
  let timer;
5500
- const opening = openTurso({ url: credentials2.tursoUrl, token: credentials2.tursoToken });
5482
+ const opening = openTurso({ url: credentials.tursoUrl, token: credentials.tursoToken });
5501
5483
  try {
5502
5484
  const db = await Promise.race([
5503
5485
  opening,
@@ -5514,79 +5496,79 @@ async function openLive(credentials2) {
5514
5496
  clearTimeout(timer);
5515
5497
  }
5516
5498
  }
5517
- function statusEvents(config2, credentials2) {
5518
- if (!credentials2.tursoUrl)
5499
+ function statusEvents(config, credentials) {
5500
+ if (!credentials.tursoUrl)
5519
5501
  return;
5520
5502
  return async () => {
5521
- const { db, warning } = await openLive(credentials2);
5503
+ const { db, warning } = await openLive(credentials);
5522
5504
  if (!db)
5523
5505
  throw new Error(warning ?? "Turso unavailable");
5524
5506
  try {
5525
- return await lastEventTimes(db, config2.project.slug);
5507
+ return await lastEventTimes(db, config.project.slug);
5526
5508
  } finally {
5527
5509
  db.close();
5528
5510
  }
5529
5511
  };
5530
5512
  }
5531
- function currentTicket(io, config2, explicit) {
5532
- const fromEnv2 = io.env.ARMADA_TICKET?.trim();
5533
- const id = explicit?.trim() || fromEnv2 || (() => {
5513
+ function currentTicket(io, config, explicit) {
5514
+ const fromEnv = io.env.ARMADA_TICKET?.trim();
5515
+ const id = explicit?.trim() || fromEnv || (() => {
5534
5516
  const branch = io.gitBranch?.();
5535
- return branch ? ticketFromBranch(branch, config2.tracker.programRoot) : null;
5517
+ return branch ? ticketFromBranch(branch, config.tracker.programRoot) : null;
5536
5518
  })();
5537
5519
  if (!id)
5538
5520
  throw new UsageError("which ticket? pass --ticket <id>, set ARMADA_TICKET, or run on the ticket's branch");
5539
5521
  return id.toUpperCase();
5540
5522
  }
5541
- async function context(io, config2, credentials2) {
5542
- if (!credentials2.linearApiKey)
5523
+ async function context(io, config, credentials) {
5524
+ if (!credentials.linearApiKey)
5543
5525
  throw missingKey(LINEAR_KEY);
5544
5526
  const linearOpts = {
5545
- apiKey: credentials2.linearApiKey,
5546
- labels: config2.tracker.labels,
5527
+ apiKey: credentials.linearApiKey,
5528
+ labels: config.tracker.labels,
5547
5529
  ...io.fetch ? { fetch: io.fetch } : {}
5548
5530
  };
5549
- const linear2 = io.linearWriter ? io.linearWriter(linearOpts) : createLinearWriter(linearOpts);
5550
- let live2 = null;
5551
- const token = credentials2.githubToken;
5531
+ const linear = io.linearWriter ? io.linearWriter(linearOpts) : createLinearWriter(linearOpts);
5532
+ let live = null;
5533
+ const token = credentials.githubToken;
5552
5534
  const ctx = {
5553
- config: config2,
5554
- linear: linear2,
5535
+ config,
5536
+ linear,
5555
5537
  turso: () => {
5556
- live2 ??= openLive(credentials2);
5557
- return live2;
5538
+ live ??= openLive(credentials);
5539
+ return live;
5558
5540
  },
5559
5541
  readPull: token ? (number) => fetchPullRequest({
5560
5542
  token,
5561
- repository: config2.github.repository,
5543
+ repository: config.github.repository,
5562
5544
  number,
5563
5545
  ...io.fetch ? { fetch: io.fetch } : {}
5564
5546
  }) : null,
5565
5547
  now: io.now ?? (() => new Date)
5566
5548
  };
5567
5549
  const close = async () => {
5568
- const opened = await live2;
5550
+ const opened = await live;
5569
5551
  opened?.db?.close();
5570
5552
  };
5571
5553
  return { ctx, close };
5572
5554
  }
5573
- function print(io, outcome2, json) {
5555
+ function print(io, outcome, json) {
5574
5556
  if (json) {
5575
- io.stdout(`${JSON.stringify(outcome2, null, 2)}
5557
+ io.stdout(`${JSON.stringify(outcome, null, 2)}
5576
5558
  `);
5577
5559
  return;
5578
5560
  }
5579
- const out = [...outcome2.lines];
5580
- const s = outcome2.state;
5561
+ const out = [...outcome.lines];
5562
+ const s = outcome.state;
5581
5563
  if (s)
5582
5564
  out.push(`Now: ${s.status} · phase ${s.phase ?? "none"} · runtime ${s.runtime ?? "none"} · profile ${s.profile ?? "none"}`);
5583
- out.push(outcome2.url);
5584
- if (outcome2.inbox) {
5585
- if (!outcome2.inbox.length)
5565
+ out.push(outcome.url);
5566
+ if (outcome.inbox) {
5567
+ if (!outcome.inbox.length)
5586
5568
  out.push("Inbox: nothing waiting for you.");
5587
5569
  else {
5588
- out.push(`Inbox (${outcome2.inbox.length}) — read and act on these:`);
5589
- for (const item of outcome2.inbox)
5570
+ out.push(`Inbox (${outcome.inbox.length}) — read and act on these:`);
5571
+ for (const item of outcome.inbox)
5590
5572
  out.push(` #${item.id} ${item.kind}${item.author ? ` from ${item.author}` : ""} · ${item.createdAt}`, ...item.body.split(`
5591
5573
  `).map((l) => ` ${l}`));
5592
5574
  }
@@ -5594,7 +5576,7 @@ function print(io, outcome2, json) {
5594
5576
  io.stdout(`${out.join(`
5595
5577
  `)}
5596
5578
  `);
5597
- for (const w of outcome2.warnings)
5579
+ for (const w of outcome.warnings)
5598
5580
  io.stderr(`armada: warning: ${w}
5599
5581
  `);
5600
5582
  }
@@ -5611,8 +5593,8 @@ async function readMessage(io, options) {
5611
5593
  throw new UsageError(`${file === "-" ? "standard input" : `message file ${file}`} is empty or whitespace-only`, 'pass --message "<text>" or pipe a non-empty message into --message-file -');
5612
5594
  return text;
5613
5595
  }
5614
- async function withContext(io, config2, credentials2, json, act) {
5615
- const { ctx, close } = await context(io, config2, credentials2);
5596
+ async function withContext(io, config, credentials, json, act) {
5597
+ const { ctx, close } = await context(io, config, credentials);
5616
5598
  try {
5617
5599
  print(io, await act(ctx), json);
5618
5600
  return 0;
@@ -5620,7 +5602,7 @@ async function withContext(io, config2, credentials2, json, act) {
5620
5602
  await close();
5621
5603
  }
5622
5604
  }
5623
- async function claim(io, config2, credentials2, a) {
5605
+ async function claim(io, config, credentials, a) {
5624
5606
  const [ticket, ...extra] = a.rest;
5625
5607
  if (!ticket)
5626
5608
  throw new UsageError("claim needs a ticket: armada claim <ticket> --runtime <name> --handle <id>");
@@ -5635,7 +5617,7 @@ async function claim(io, config2, credentials2, a) {
5635
5617
  if (reason && !profile)
5636
5618
  throw new UsageError("--reason goes with --profile: it says why the routed profile is not used");
5637
5619
  try {
5638
- checkRequestedProfile(config2, profile);
5620
+ checkRequestedProfile(config, profile);
5639
5621
  } catch (err) {
5640
5622
  if (err instanceof ProfileError)
5641
5623
  throw new UsageError(err.message);
@@ -5643,7 +5625,7 @@ async function claim(io, config2, credentials2, a) {
5643
5625
  }
5644
5626
  if (!handle)
5645
5627
  throw new UsageError("--handle is required: the runtime's id for this session, e.g. <workspace>/<session>");
5646
- return withContext(io, config2, credentials2, a.json, (ctx) => claimTicket(ctx, {
5628
+ return withContext(io, config, credentials, a.json, (ctx) => claimTicket(ctx, {
5647
5629
  ticket: ticket.toUpperCase(),
5648
5630
  runtime,
5649
5631
  handle,
@@ -5652,37 +5634,37 @@ async function claim(io, config2, credentials2, a) {
5652
5634
  reason
5653
5635
  }));
5654
5636
  }
5655
- async function report(io, config2, credentials2, a) {
5637
+ async function report(io, config, credentials, a) {
5656
5638
  const [phase, ...extra] = a.rest;
5657
5639
  if (!phase || !isLabelPhase(phase))
5658
5640
  throw new UsageError(`report needs a phase: ${LABEL_PHASES.join(", ")}${phase ? ` (got "${phase}")` : ""}`);
5659
5641
  if (extra.length)
5660
5642
  throw new UsageError(`unexpected argument ${extra[0]}`);
5661
- const message2 = await readMessage(io, a.options);
5662
- if (!message2?.trim() && phase !== "ready-to-merge")
5643
+ const message = await readMessage(io, a.options);
5644
+ if (!message?.trim() && phase !== "ready-to-merge")
5663
5645
  throw new UsageError("--message is required: what you did or what you are doing (first line = summary)");
5664
- const ticket = currentTicket(io, config2, a.options.ticket);
5665
- return withContext(io, config2, credentials2, a.json, (ctx) => reportPhase(ctx, {
5646
+ const ticket = currentTicket(io, config, a.options.ticket);
5647
+ return withContext(io, config, credentials, a.json, (ctx) => reportPhase(ctx, {
5666
5648
  ticket,
5667
5649
  phase,
5668
- message: message2,
5650
+ message,
5669
5651
  pr: a.options.pr ?? null,
5670
5652
  sha: a.options.sha ?? null
5671
5653
  }));
5672
5654
  }
5673
- async function release(io, config2, credentials2, a) {
5655
+ async function release(io, config, credentials, a) {
5674
5656
  if (a.rest.length)
5675
5657
  throw new UsageError(`unexpected argument ${a.rest[0]}`);
5676
5658
  const reason = a.options.reason?.trim();
5677
5659
  if (!reason)
5678
5660
  throw new UsageError("--reason is required: why the ticket is given back");
5679
- const ticket = currentTicket(io, config2, a.options.ticket);
5680
- return withContext(io, config2, credentials2, a.json, (ctx) => releaseTicket(ctx, { ticket, reason }));
5661
+ const ticket = currentTicket(io, config, a.options.ticket);
5662
+ return withContext(io, config, credentials, a.json, (ctx) => releaseTicket(ctx, { ticket, reason }));
5681
5663
  }
5682
5664
 
5683
5665
  // src/inbox.ts
5684
5666
  var DEFAULT_WAIT_SECONDS = 300;
5685
- async function ask(io, config2, credentials2, a) {
5667
+ async function ask(io, config, credentials, a) {
5686
5668
  const [positional, ...extra] = a.rest;
5687
5669
  if (extra.length)
5688
5670
  throw new UsageError(`unexpected argument ${extra[0]}; quote the question`);
@@ -5693,10 +5675,10 @@ async function ask(io, config2, credentials2, a) {
5693
5675
  if (!question?.trim())
5694
5676
  throw new UsageError('ask needs a question: armada ask "<question, the options, your recommendation>"');
5695
5677
  const options = (a.options.options ?? "").split("|").map((o) => o.trim()).filter(Boolean);
5696
- const ticket = currentTicket(io, config2, a.options.ticket);
5697
- return withContext(io, config2, credentials2, a.json, (ctx) => askCoordinator(ctx, { ticket, question, options }));
5678
+ const ticket = currentTicket(io, config, a.options.ticket);
5679
+ return withContext(io, config, credentials, a.json, (ctx) => askCoordinator(ctx, { ticket, question, options }));
5698
5680
  }
5699
- async function answer(io, config2, credentials2, a) {
5681
+ async function answer(io, config, credentials, a) {
5700
5682
  const note = a.options.note === "true";
5701
5683
  const [target, positional, ...extra] = a.rest;
5702
5684
  const usage = note ? 'armada answer --note <ticket> "<message>"' : 'armada answer <item or ticket> "<answer>"';
@@ -5710,7 +5692,7 @@ async function answer(io, config2, credentials2, a) {
5710
5692
  const text = positional ?? fromOption;
5711
5693
  if (!text?.trim())
5712
5694
  throw new UsageError(`answer needs the text: ${usage}`);
5713
- return withContext(io, config2, credentials2, a.json, (ctx) => answerItem(ctx, { target, text, note }));
5695
+ return withContext(io, config, credentials, a.json, (ctx) => answerItem(ctx, { target, text, note }));
5714
5696
  }
5715
5697
  function waitSeconds(raw) {
5716
5698
  if (raw === undefined)
@@ -5751,28 +5733,28 @@ function renderInbox(r) {
5751
5733
  `)}
5752
5734
  `;
5753
5735
  }
5754
- async function inbox2(io, config2, credentials2, a) {
5736
+ async function inbox2(io, config, credentials, a) {
5755
5737
  if (a.rest.length)
5756
5738
  throw new UsageError(`unexpected argument ${a.rest[0]}`);
5757
5739
  const wait = a.options.wait === "true";
5758
5740
  if (!wait && a.options.timeout !== undefined)
5759
5741
  throw new UsageError("--timeout applies to --wait");
5760
5742
  const timeoutMs = waitSeconds(a.options.timeout) * 1000;
5761
- if (!credentials2.tursoUrl)
5743
+ if (!credentials.tursoUrl)
5762
5744
  throw new UsageError("the inbox lives in Turso: set ARMADA_TURSO_URL", "armada auth login");
5763
- const { db, warning } = await openLive(credentials2);
5745
+ const { db, warning } = await openLive(credentials);
5764
5746
  if (!db)
5765
5747
  throw new Refusal(`the inbox lives in Turso, which is unavailable: ${warning ?? "no answer"}`, "armada inbox again once Turso answers (armada auth status shows the URL in use)");
5766
5748
  try {
5767
- const report2 = await checkInbox(db, {
5768
- project: config2.project.slug,
5769
- silentAfterMinutes: config2.policy.silentAfterMinutes,
5749
+ const report = await checkInbox(db, {
5750
+ project: config.project.slug,
5751
+ silentAfterMinutes: config.policy.silentAfterMinutes,
5770
5752
  now: io.now ?? (() => new Date),
5771
5753
  ...wait ? { wait: { timeoutMs, sleep: io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms))) } } : {}
5772
5754
  });
5773
- io.stdout(a.json ? `${JSON.stringify(report2, null, 2)}
5774
- ` : renderInbox(report2));
5775
- for (const w of report2.warnings)
5755
+ io.stdout(a.json ? `${JSON.stringify(report, null, 2)}
5756
+ ` : renderInbox(report));
5757
+ for (const w of report.warnings)
5776
5758
  io.stderr(`armada: warning: ${w}
5777
5759
  `);
5778
5760
  return 0;
@@ -5785,7 +5767,7 @@ async function inbox2(io, config2, credentials2, a) {
5785
5767
  import { mkdtemp, realpath, rm as rm3 } from "node:fs/promises";
5786
5768
  import { tmpdir } from "node:os";
5787
5769
  import { join as join3 } from "node:path";
5788
- var initBranch = (version2) => `armada/init-${version2}`;
5770
+ var initBranch = (version) => `armada/init-${version}`;
5789
5771
  async function defaultBranch(exec, root) {
5790
5772
  const out = await sh(exec, root, "git", ["ls-remote", "--symref", "origin", "HEAD"]);
5791
5773
  const m = out.match(/^ref:\s+refs\/heads\/(\S+)\s+HEAD/m);
@@ -5794,9 +5776,9 @@ async function defaultBranch(exec, root) {
5794
5776
  return m[1];
5795
5777
  }
5796
5778
  async function resolveConfig(exec, root, checkout, opts) {
5797
- const parse2 = (text2, where) => {
5779
+ const parse = (text, where) => {
5798
5780
  try {
5799
- return parseConfig(text2, where);
5781
+ return parseConfig(text, where);
5800
5782
  } catch (err) {
5801
5783
  if (err instanceof ConfigError)
5802
5784
  throw new UsageError(err.message, "armada init again once the file is fixed");
@@ -5805,16 +5787,16 @@ async function resolveConfig(exec, root, checkout, opts) {
5805
5787
  };
5806
5788
  const onDefault = await fsRepoView(checkout).readFile(CONFIG_FILE);
5807
5789
  if (onDefault !== null)
5808
- return { config: parse2(onDefault, `${CONFIG_FILE} on the default branch`), text: null, source: "default branch" };
5790
+ return { config: parse(onDefault, `${CONFIG_FILE} on the default branch`), text: null, source: "default branch" };
5809
5791
  const local = await fsRepoView(root).readFile(CONFIG_FILE);
5810
5792
  if (local !== null && !opts.programRoot)
5811
- return { config: parse2(local, join3(root, CONFIG_FILE)), text: local, source: "working tree" };
5793
+ return { config: parse(local, join3(root, CONFIG_FILE)), text: local, source: "working tree" };
5812
5794
  const branch = initBranch(opts.armadaVersion);
5813
5795
  if (!opts.programRoot && await sh(exec, root, "git", ["ls-remote", "origin", `refs/heads/${branch}`])) {
5814
5796
  await sh(exec, root, "git", ["fetch", "--quiet", "origin", branch]);
5815
5797
  const shown = await exec("git", ["show", `FETCH_HEAD:${CONFIG_FILE}`], { cwd: root });
5816
5798
  if (shown.code === 0)
5817
- return { config: parse2(shown.stdout, `${CONFIG_FILE} on ${branch}`), text: shown.stdout, source: branch };
5799
+ return { config: parse(shown.stdout, `${CONFIG_FILE} on ${branch}`), text: shown.stdout, source: branch };
5818
5800
  }
5819
5801
  if (!opts.programRoot)
5820
5802
  throw new UsageError(`${CONFIG_FILE} is missing, and armada init needs the Linear issue at the root of the program to write one`, "armada init --program-root <ISSUE-ID>");
@@ -5826,7 +5808,7 @@ async function resolveConfig(exec, root, checkout, opts) {
5826
5808
  programRoot: opts.programRoot,
5827
5809
  repository: repo.nameWithOwner
5828
5810
  });
5829
- return { config: parse2(text, `the new ${CONFIG_FILE}`), text, source: "new" };
5811
+ return { config: parse(text, `the new ${CONFIG_FILE}`), text, source: "new" };
5830
5812
  }
5831
5813
  async function branchIsCurrent(exec, checkout, branch, baseSha) {
5832
5814
  if (!await sh(exec, checkout, "git", ["ls-remote", "origin", `refs/heads/${branch}`]))
@@ -5839,10 +5821,10 @@ async function branchIsCurrent(exec, checkout, branch, baseSha) {
5839
5821
  ]);
5840
5822
  return remoteTree === tree && remoteParent === baseSha;
5841
5823
  }
5842
- function prText(plan, version2) {
5843
- const title = plan.installed.length ? `chore(armada): set up Armada ${version2}` : `chore(armada): update the Armada setup to ${version2}`;
5824
+ function prText(plan, version) {
5825
+ const title = plan.installed.length ? `chore(armada): set up Armada ${version}` : `chore(armada): update the Armada setup to ${version}`;
5844
5826
  const lines = [
5845
- `Adds what \`armada doctor\` checks, so Armada ${version2} can run agents on this repository.`,
5827
+ `Adds what \`armada doctor\` checks, so Armada ${version} can run agents on this repository.`,
5846
5828
  "",
5847
5829
  ...plan.writes.map((w) => `- write \`${w.path}\``),
5848
5830
  ...plan.links.map((l) => `- link \`${l.path}\` → \`${l.target}\``),
@@ -5864,12 +5846,12 @@ async function init(io, opts) {
5864
5846
  if (login !== 0)
5865
5847
  return login;
5866
5848
  }
5867
- const { credentials: credentials2 } = await loadCredentials(io);
5868
- const missing2 = required(credentials2).find(Boolean);
5869
- if (missing2)
5870
- throw missingKey(missing2);
5871
- const linearApiKey = credentials2.linearApiKey ?? "";
5872
- const tursoUrl = credentials2.tursoUrl ?? "";
5849
+ const { credentials } = await loadCredentials(io);
5850
+ const missing = required(credentials).find(Boolean);
5851
+ if (missing)
5852
+ throw missingKey(missing);
5853
+ const linearApiKey = credentials.linearApiKey ?? "";
5854
+ const tursoUrl = credentials.tursoUrl ?? "";
5873
5855
  const root = await gitRoot(exec, io.cwd);
5874
5856
  if (!root)
5875
5857
  throw new UsageError(`${io.cwd} is not inside a git repository`, "armada init again from the checkout of the repository to set up");
@@ -5879,16 +5861,16 @@ async function init(io, opts) {
5879
5861
  const checkout = await realpath(await mkdtemp(join3(tmpdir(), "armada-init-")));
5880
5862
  try {
5881
5863
  await sh(exec, root, "git", ["worktree", "add", "--quiet", "--detach", checkout, baseSha]);
5882
- const { config: config2, text, source } = await resolveConfig(exec, root, checkout, opts);
5864
+ const { config, text, source } = await resolveConfig(exec, root, checkout, opts);
5883
5865
  const view = fsRepoView(checkout);
5884
5866
  const plan = await planSetup(view, { armadaVersion: opts.armadaVersion, configText: text });
5885
5867
  const log = (line) => io.stdout(`${line}
5886
5868
  `);
5887
- log(`Armada ${opts.armadaVersion} · ${config2.github.repository} · ${config2.tracker.programRoot}`);
5869
+ log(`Armada ${opts.armadaVersion} · ${config.github.repository} · ${config.tracker.programRoot}`);
5888
5870
  if (source !== "default branch" && source !== "new")
5889
5871
  log(`Using ${CONFIG_FILE} from ${source === "working tree" ? "the working tree" : source}; the pull request adds it.`);
5890
- const linear2 = { apiKey: linearApiKey, ...io.fetch ? { fetch: io.fetch } : {} };
5891
- const created = await createMissingLabels(await readLabels(config2, linear2), linear2);
5872
+ const linear = { apiKey: linearApiKey, ...io.fetch ? { fetch: io.fetch } : {} };
5873
+ const created = await createMissingLabels(await readLabels(config, linear), linear);
5892
5874
  log(created.length ? `Created Linear labels: ${created.join(", ")}` : "Linear labels: all present");
5893
5875
  if (planIsEmpty(plan))
5894
5876
  log(`${base} already has everything Armada needs; no pull request to open.`);
@@ -5903,8 +5885,8 @@ async function init(io, opts) {
5903
5885
  log(`${branch} is already up to date.`);
5904
5886
  else
5905
5887
  await sh(exec, checkout, "git", ["push", "--quiet", "--force", "origin", `HEAD:refs/heads/${branch}`]);
5906
- const repo = config2.github.repository;
5907
- const open2 = JSON.parse(await sh(exec, root, "gh", [
5888
+ const repo = config.github.repository;
5889
+ const open = JSON.parse(await sh(exec, root, "gh", [
5908
5890
  "pr",
5909
5891
  "list",
5910
5892
  "--repo",
@@ -5916,7 +5898,7 @@ async function init(io, opts) {
5916
5898
  "--json",
5917
5899
  "number,url"
5918
5900
  ]) || "[]");
5919
- const existing = open2[0];
5901
+ const existing = open[0];
5920
5902
  if (existing) {
5921
5903
  await sh(exec, root, "gh", [
5922
5904
  "pr",
@@ -5953,19 +5935,19 @@ async function init(io, opts) {
5953
5935
  if (plan.updated.length)
5954
5936
  log(`Updates: ${plan.updated.join(", ")}`);
5955
5937
  }
5956
- const db = await openTurso({ url: tursoUrl, token: credentials2.tursoToken });
5938
+ const db = await openTurso({ url: tursoUrl, token: credentials.tursoToken });
5957
5939
  try {
5958
5940
  const project = {
5959
- slug: config2.project.slug,
5960
- name: config2.project.name,
5961
- repository: config2.github.repository,
5962
- programRoot: config2.tracker.programRoot
5941
+ slug: config.project.slug,
5942
+ name: config.project.name,
5943
+ repository: config.github.repository,
5944
+ programRoot: config.tracker.programRoot
5963
5945
  };
5964
5946
  await upsertProject(db, project, io.now?.() ?? new Date);
5965
5947
  } finally {
5966
5948
  db.close();
5967
5949
  }
5968
- log(`Registered project ${config2.project.slug}; armada status --all lists it.`);
5950
+ log(`Registered project ${config.project.slug}; armada status --all lists it.`);
5969
5951
  return 0;
5970
5952
  } finally {
5971
5953
  await exec("git", ["worktree", "remove", "--force", checkout], { cwd: root }).catch(() => null);
@@ -5987,9 +5969,9 @@ function ghMerge(exec, cwd, repository) {
5987
5969
  const args = ["pr", "merge", String(number), "--repo", repository, "--squash", "--match-head-commit", sha];
5988
5970
  try {
5989
5971
  const r = await exec("gh", args, { cwd });
5990
- const message2 = tail(`${r.stderr}
5972
+ const message = tail(`${r.stderr}
5991
5973
  ${r.stdout}`.trim(), 5) || `gh exited with ${r.code}`;
5992
- return { ok: r.code === 0, message: message2, transient: r.code !== 0 && TRANSIENT.test(message2) };
5974
+ return { ok: r.code === 0, message, transient: r.code !== 0 && TRANSIENT.test(message) };
5993
5975
  } catch (err) {
5994
5976
  return {
5995
5977
  ok: false,
@@ -6110,42 +6092,42 @@ function render(o) {
6110
6092
  `)}
6111
6093
  `;
6112
6094
  }
6113
- async function merge2(io, config2, credentials2, a, configPath) {
6095
+ async function merge2(io, config, credentials, a, configPath) {
6114
6096
  const [arg, ...extra] = a.rest;
6115
6097
  if (extra.length)
6116
6098
  throw new UsageError(`unexpected argument ${extra[0]}`);
6117
- const number = prNumber(arg, config2.github.repository);
6118
- if (!credentials2.linearApiKey)
6099
+ const number = prNumber(arg, config.github.repository);
6100
+ if (!credentials.linearApiKey)
6119
6101
  throw missingKey(LINEAR_KEY);
6120
- const token = credentials2.githubToken;
6102
+ const token = credentials.githubToken;
6121
6103
  if (!token)
6122
6104
  throw new UsageError("armada merge reads GitHub: set GITHUB_TOKEN", "gh auth login");
6123
6105
  const exec = io.exec;
6124
6106
  if (!exec)
6125
6107
  throw new UsageError("armada merge needs to run git and gh");
6126
- const linearApiKey = credentials2.linearApiKey;
6108
+ const linearApiKey = credentials.linearApiKey;
6127
6109
  const repoDir = dirname2(configPath);
6128
6110
  const fetchOpt = io.fetch ? { fetch: io.fetch } : {};
6129
- const gh = { token, repository: config2.github.repository, ...fetchOpt };
6130
- const linearOpts = { apiKey: linearApiKey, labels: config2.tracker.labels, ...fetchOpt };
6111
+ const gh = { token, repository: config.github.repository, ...fetchOpt };
6112
+ const linearOpts = { apiKey: linearApiKey, labels: config.tracker.labels, ...fetchOpt };
6131
6113
  const now = io.now ?? (() => new Date);
6132
- const turso2 = { live: null };
6114
+ const turso = { live: null };
6133
6115
  const ctx = {
6134
- config: config2,
6116
+ config,
6135
6117
  linear: io.linearWriter ? io.linearWriter(linearOpts) : createLinearWriter(linearOpts),
6136
6118
  forge: {
6137
6119
  readPull: (n) => fetchMergePull({ ...gh, number: n }),
6138
6120
  compare: (base, head) => fetchComparison({ ...gh, base, head }),
6139
6121
  diff: (n) => fetchPullDiff({ ...gh, number: n }),
6140
- merge: ghMerge(exec, repoDir, config2.github.repository)
6122
+ merge: ghMerge(exec, repoDir, config.github.repository)
6141
6123
  },
6142
6124
  repo: gitRepo(exec, repoDir),
6143
- tursoConfigured: !!credentials2.tursoUrl,
6125
+ tursoConfigured: !!credentials.tursoUrl,
6144
6126
  turso: () => {
6145
- turso2.live ??= openLive(credentials2);
6146
- return turso2.live;
6127
+ turso.live ??= openLive(credentials);
6128
+ return turso.live;
6147
6129
  },
6148
- inFlight: async () => (await loadStatus(config2, { linearApiKey, githubToken: null, ...fetchOpt, now })).inFlight.map((t) => ({
6130
+ inFlight: async () => (await loadStatus(config, { linearApiKey, githubToken: null, ...fetchOpt, now })).inFlight.map((t) => ({
6149
6131
  id: t.id,
6150
6132
  title: t.title,
6151
6133
  phase: t.phase,
@@ -6177,7 +6159,7 @@ async function merge2(io, config2, credentials2, a, configPath) {
6177
6159
  `);
6178
6160
  return 0;
6179
6161
  } finally {
6180
- (await turso2.live)?.db?.close();
6162
+ (await turso.live)?.db?.close();
6181
6163
  }
6182
6164
  }
6183
6165
 
@@ -6215,7 +6197,7 @@ function renderStatus(r) {
6215
6197
  const now = Date.parse(r.generatedAt);
6216
6198
  const out = [];
6217
6199
  const idWidth = Math.max(6, ...r.inFlight.map((t) => t.id.length), ...r.frontier.map((t) => t.id.length), ...(r.pullRequests ?? []).map((p) => `#${p.number}`.length));
6218
- const indent2 = " ".repeat(idWidth + 4);
6200
+ const indent = " ".repeat(idWidth + 4);
6219
6201
  const phaseWidth = Math.max(0, ...r.inFlight.map((t) => phaseLabel(t).length));
6220
6202
  out.push(`${r.project.name} · ${r.programRoot.id} ${r.programRoot.title}`);
6221
6203
  const gh = r.sources.github.error ? `GitHub not read: ${r.sources.github.error}` : `GitHub ${r.project.repository}`;
@@ -6226,13 +6208,13 @@ function renderStatus(r) {
6226
6208
  for (const t of r.inFlight) {
6227
6209
  const who = [t.runtime, t.agent].filter(Boolean).join(" · ") || "unassigned";
6228
6210
  out.push(` ${pad(t.id, idWidth)} ${pad(phaseLabel(t), phaseWidth)} ${who} · ${t.lastReport ? `reported ${relative2(t.lastReport, now)}` : `updated ${relative2(t.lastUpdate, now)}`}`);
6229
- out.push(`${indent2}${truncate(t.title, 90)}${t.spec ? ` [${t.spec}]` : ""}`);
6211
+ out.push(`${indent}${truncate(t.title, 90)}${t.spec ? ` [${t.spec}]` : ""}`);
6230
6212
  if (t.statusLine?.summary)
6231
- out.push(`${indent2}“${truncate(t.statusLine.summary, 100)}”`);
6213
+ out.push(`${indent}“${truncate(t.statusLine.summary, 100)}”`);
6232
6214
  if (t.pr)
6233
- out.push(`${indent2}${[`PR #${t.pr.number}`, prState(t.pr)].filter(Boolean).join(" · ")}`);
6215
+ out.push(`${indent}${[`PR #${t.pr.number}`, prState(t.pr)].filter(Boolean).join(" · ")}`);
6234
6216
  if (t.flags.length)
6235
- out.push(`${indent2}! ${t.flags.join(", ")}`);
6217
+ out.push(`${indent}! ${t.flags.join(", ")}`);
6236
6218
  }
6237
6219
  const ready = r.frontier.filter((t) => t.readyForAgent);
6238
6220
  const untriaged = r.frontier.filter((t) => !t.readyForAgent);
@@ -6260,9 +6242,9 @@ function renderStatus(r) {
6260
6242
  for (const p of r.pullRequests ?? []) {
6261
6243
  const ticket = p.ticket ? `${p.ticket.id}${p.ticket.phase ? ` ${p.ticket.phase}` : ""}` : "no ticket";
6262
6244
  out.push(` ${pad(`#${p.number}`, idWidth)} ${[ticket, prState(p)].filter(Boolean).join(" · ")}`);
6263
- out.push(`${indent2}${truncate(p.title, 90)}`);
6245
+ out.push(`${indent}${truncate(p.title, 90)}`);
6264
6246
  if (p.failingChecks.length)
6265
- out.push(`${indent2}! failing: ${p.failingChecks.join(", ")}`);
6247
+ out.push(`${indent}! failing: ${p.failingChecks.join(", ")}`);
6266
6248
  }
6267
6249
  if (r.warnings.length) {
6268
6250
  out.push("", `Warnings (${r.warnings.length})`);
@@ -6277,49 +6259,49 @@ function renderStatus(r) {
6277
6259
  // src/projects.ts
6278
6260
  var message2 = (err) => err instanceof Error ? err.message : String(err);
6279
6261
  async function statusAll(io, json) {
6280
- const { credentials: credentials2 } = await loadCredentials(io);
6281
- const linearApiKey = credentials2.linearApiKey;
6262
+ const { credentials } = await loadCredentials(io);
6263
+ const linearApiKey = credentials.linearApiKey;
6282
6264
  if (!linearApiKey)
6283
6265
  throw missingKey(LINEAR_KEY);
6284
6266
  const tursoKey = STORED_KEYS.find((k) => k.name === "tursoUrl");
6285
- if (!credentials2.tursoUrl && tursoKey)
6267
+ if (!credentials.tursoUrl && tursoKey)
6286
6268
  throw missingKey(tursoKey);
6287
- const db = await openTurso({ url: credentials2.tursoUrl ?? "", token: credentials2.tursoToken });
6269
+ const db = await openTurso({ url: credentials.tursoUrl ?? "", token: credentials.tursoToken });
6288
6270
  let records;
6289
6271
  try {
6290
6272
  records = await listProjects(db);
6291
6273
  } finally {
6292
6274
  db.close();
6293
6275
  }
6294
- const projects2 = await Promise.all(records.map(async (p) => {
6276
+ const projects = await Promise.all(records.map(async (p) => {
6295
6277
  const base = { slug: p.slug, name: p.name, repository: p.repository };
6296
6278
  let warning = null;
6297
6279
  try {
6298
6280
  const read = await readProjectConfig(p, {
6299
- githubToken: credentials2.githubToken,
6281
+ githubToken: credentials.githubToken,
6300
6282
  ...io.fetch ? { fetch: io.fetch } : {}
6301
6283
  });
6302
6284
  warning = read.warning;
6303
- const config2 = read.config;
6304
- const report2 = await loadStatus(config2, {
6285
+ const config = read.config;
6286
+ const report = await loadStatus(config, {
6305
6287
  linearApiKey,
6306
- githubToken: credentials2.githubToken,
6288
+ githubToken: credentials.githubToken,
6307
6289
  ...io.fetch ? { fetch: io.fetch } : {},
6308
6290
  ...io.now ? { now: io.now } : {}
6309
6291
  });
6310
- return { ...base, report: report2, error: null, configWarning: warning };
6292
+ return { ...base, report, error: null, configWarning: warning };
6311
6293
  } catch (err) {
6312
6294
  return { ...base, report: null, error: message2(err), configWarning: warning };
6313
6295
  }
6314
6296
  }));
6315
- const all = { schemaVersion: 1, projects: projects2 };
6297
+ const all = { schemaVersion: 1, projects };
6316
6298
  if (json)
6317
6299
  io.stdout(`${JSON.stringify(all, null, 2)}
6318
6300
  `);
6319
- else if (!projects2.length)
6301
+ else if (!projects.length)
6320
6302
  io.stdout("No project is registered yet. Run `armada init` in a repository to register it.\n");
6321
6303
  else
6322
- io.stdout(projects2.map((p) => {
6304
+ io.stdout(projects.map((p) => {
6323
6305
  if (!p.report)
6324
6306
  return `${p.name} (${p.slug}) · ${p.repository}
6325
6307
  ! not read: ${p.error}
@@ -6331,7 +6313,7 @@ ${p.configWarning ? ` ! ${p.configWarning}
6331
6313
  ${"─".repeat(60)}
6332
6314
 
6333
6315
  `));
6334
- return projects2.some((p) => p.error) ? 1 : 0;
6316
+ return projects.some((p) => p.error) ? 1 : 0;
6335
6317
  }
6336
6318
 
6337
6319
  // src/cli.ts
@@ -6538,21 +6520,21 @@ async function findConfig(io, explicit, command = "status") {
6538
6520
  }
6539
6521
  async function status2(io, args) {
6540
6522
  const { path, text } = await findConfig(io, args.config, "status");
6541
- const config2 = parseConfig(text, path);
6542
- const { credentials: credentials2 } = await loadCredentials(io);
6543
- const { linearApiKey, githubToken } = credentials2;
6523
+ const config = parseConfig(text, path);
6524
+ const { credentials } = await loadCredentials(io);
6525
+ const { linearApiKey, githubToken } = credentials;
6544
6526
  if (!linearApiKey)
6545
6527
  throw missingKey(LINEAR_KEY);
6546
- const events = statusEvents(config2, credentials2);
6547
- const report2 = await loadStatus(config2, {
6528
+ const events = statusEvents(config, credentials);
6529
+ const report = await loadStatus(config, {
6548
6530
  linearApiKey,
6549
6531
  githubToken,
6550
6532
  ...events ? { lastEvents: events } : {},
6551
6533
  ...io.fetch ? { fetch: io.fetch } : {},
6552
6534
  ...io.now ? { now: io.now } : {}
6553
6535
  });
6554
- io.stdout(args.json ? `${JSON.stringify(report2, null, 2)}
6555
- ` : renderStatus(report2));
6536
+ io.stdout(args.json ? `${JSON.stringify(report, null, 2)}
6537
+ ` : renderStatus(report));
6556
6538
  return 0;
6557
6539
  }
6558
6540
  function noExtra(rest) {
@@ -6607,22 +6589,22 @@ async function run(argv, io) {
6607
6589
  throw new UsageError(`--${name} does not apply to ${args.command}`);
6608
6590
  if (args.all && args.command !== "status")
6609
6591
  throw new UsageError(`--all does not apply to ${args.command}`);
6610
- const worker2 = { claim, report, release, ask, inbox: inbox2, answer }[args.command];
6611
- if (worker2) {
6592
+ const worker = { claim, report, release, ask, inbox: inbox2, answer }[args.command];
6593
+ if (worker) {
6612
6594
  const { path, text } = await findConfig(io, args.config, args.command);
6613
- const config2 = parseConfig(text, path);
6614
- const { credentials: credentials2 } = await loadCredentials(io);
6615
- return await worker2(io, config2, credentials2, args);
6595
+ const config = parseConfig(text, path);
6596
+ const { credentials } = await loadCredentials(io);
6597
+ return await worker(io, config, credentials, args);
6616
6598
  }
6617
6599
  if (args.command === "merge") {
6618
6600
  const { path, text } = await findConfig(io, args.config, "merge");
6619
- const { credentials: credentials2 } = await loadCredentials(io);
6620
- return await merge2(io, parseConfig(text, path), credentials2, args, path);
6601
+ const { credentials } = await loadCredentials(io);
6602
+ return await merge2(io, parseConfig(text, path), credentials, args, path);
6621
6603
  }
6622
6604
  if (args.command === "brief") {
6623
6605
  const { path, text } = await findConfig(io, args.config, "brief");
6624
- const { credentials: credentials2 } = await loadCredentials(io);
6625
- return await brief2(io, parseConfig(text, path), credentials2, args, version);
6606
+ const { credentials } = await loadCredentials(io);
6607
+ return await brief2(io, parseConfig(text, path), credentials, args, version);
6626
6608
  }
6627
6609
  if (args.command === "status") {
6628
6610
  noExtra(args.rest);
@@ -6666,7 +6648,7 @@ ${next ? `Next: ${next}
6666
6648
  // src/line.ts
6667
6649
  var emptyLine = () => ({ answer: "", sequence: "none" });
6668
6650
  function feedLine(line, chunk) {
6669
- let { answer: answer2, sequence } = line;
6651
+ let { answer, sequence } = line;
6670
6652
  for (const c of chunk) {
6671
6653
  if (sequence === "start")
6672
6654
  sequence = c === "[" ? "csi" : "none";
@@ -6677,21 +6659,21 @@ function feedLine(line, chunk) {
6677
6659
  sequence = "start";
6678
6660
  else if (c === "\r" || c === `
6679
6661
  `)
6680
- return { answer: answer2, sequence, result: answer2 };
6681
- else if (c === "\x03" || c === "\x04" && !answer2)
6682
- return { answer: answer2, sequence, result: null };
6662
+ return { answer, sequence, result: answer };
6663
+ else if (c === "\x03" || c === "\x04" && !answer)
6664
+ return { answer, sequence, result: null };
6683
6665
  else if (c === "" || c === "\b")
6684
- answer2 = answer2.slice(0, -1);
6666
+ answer = answer.slice(0, -1);
6685
6667
  else if (c >= " ")
6686
- answer2 += c;
6668
+ answer += c;
6687
6669
  }
6688
- return { answer: answer2, sequence };
6670
+ return { answer, sequence };
6689
6671
  }
6690
- function echo(before, after2) {
6672
+ function echo(before, after) {
6691
6673
  let common = 0;
6692
- while (common < before.length && common < after2.length && before[common] === after2[common])
6674
+ while (common < before.length && common < after.length && before[common] === after[common])
6693
6675
  common++;
6694
- return "\b \b".repeat(before.length - common) + after2.slice(common);
6676
+ return "\b \b".repeat(before.length - common) + after.slice(common);
6695
6677
  }
6696
6678
 
6697
6679
  // src/main.ts
@@ -6774,4 +6756,4 @@ var code = await run(process.argv.slice(2), {
6774
6756
  readStdin,
6775
6757
  exec
6776
6758
  });
6777
- process.stdout.write("", () => process.exit(code));
6759
+ process.exitCode = code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-vibe-company/armada",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "description": "Run a fleet of coding agents on one project: the armada command line.",
6
6
  "license": "MIT",