@the-vibe-company/armada 0.1.3 → 0.1.5

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 +29 -1
  2. package/dist/armada.js +654 -211
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ Armada runs a fleet of coding agents on one project and keeps every piece of wor
4
4
 
5
5
  It imposes one method: grill the decisions, write a spec, cut it into tickets, let one worker agent ship each ticket as a green pull request, and let a coordinator agent merge. The tracker is the source of truth for progress; Armada adds live telemetry, contention rules and a fleet dashboard on top.
6
6
 
7
- **Status:** early. `armada status`, `armada auth`, `armada doctor`, `armada init`, `armada claim`, `armada report` and `armada release` work; the other commands are being built.
7
+ **Status:** early. `armada status`, `armada auth`, `armada doctor`, `armada init`, `armada brief`, `armada claim`, `armada report` and `armada release` work; the other commands are being built.
8
8
 
9
9
  ## Install
10
10
 
@@ -59,6 +59,20 @@ On a repository without `armada.toml`, pass `--program-root <ISSUE-ID>`; the nam
59
59
 
60
60
  `armada status --all` prints the status of every registered project, each read with the `armada.toml` on its repository's default branch. A project that cannot be read shows its error without hiding the others.
61
61
 
62
+ ## Launch a worker (coordinators)
63
+
64
+ Armada prepares a launch; it never starts a runtime itself. The `armada-runtime-conductor` skill gives the exact Conductor Cloud commands.
65
+
66
+ ```sh
67
+ armada brief ABC-12 # launch settings, then the worker's prompt
68
+ armada brief ABC-12 --prompt # only the prompt, to pipe into the runtime (--message-file -)
69
+ armada brief ABC-12 --profile codex --json
70
+ ```
71
+
72
+ - The prompt names the ticket and its Linear branch, starts by installing the coordinator's Armada version (`npm install -g`, with an `npm exec` fallback) and running `armada claim` with the handle `$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID`, and carries the blockers with their hand-back notes, the comments already on the ticket and the workers in flight.
73
+ - The settings give the profile's agent, model and effort from `[conductor]` in `armada.toml`, and the environment variables to pass: `LINEAR_API_KEY` (required), `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN` (optional), `ARMADA_TICKET=<ticket>`. Each shows whether this shell has it. No value is ever printed.
74
+ - `--profile` defaults to `conductor.default_profile`, then to the only profile. An unknown profile exits 2.
75
+
62
76
  ## Work on a ticket (workers)
63
77
 
64
78
  A worker writes to the tracker only through three commands. They set the labels and write the comments in the protocol format, and record each event in Turso.
@@ -152,6 +166,20 @@ local_commands = ["npm ci", "npm test"] # run by `armada merge` on a test merge
152
166
 
153
167
  [policy]
154
168
  silence_minutes = 15 # a worker with no report for longer is flagged silent (default 15)
169
+
170
+ [conductor]
171
+ default_profile = "opus" # profile `armada brief` uses without --profile
172
+
173
+ [conductor.profiles.opus] # one table per profile; `conductor model` lists the ids
174
+ agent = "claude"
175
+ model = "opus-5-5-1m"
176
+ effort = "high"
177
+ # fast_mode = true # optional, default false
178
+
179
+ [conductor.profiles.codex]
180
+ agent = "codex"
181
+ model = "gpt-6.1-sol"
182
+ effort = "high"
155
183
  ```
156
184
 
157
185
  A missing or invalid key stops the command with a message naming it, for example `missing required key "tracker.program_root"`. This repository's own configuration is in [`armada.toml`](https://github.com/The-Vibe-Company/armada/blob/main/armada.toml).
package/dist/armada.js CHANGED
@@ -1075,14 +1075,50 @@ function parseConfig(text, source = CONFIG_FILE) {
1075
1075
  if (!isTable(gates))
1076
1076
  problems.push(`"gates" must be a table`);
1077
1077
  const gatesT = isTable(gates) ? gates : {};
1078
+ const conductor = raw.conductor === undefined ? {} : raw.conductor;
1079
+ if (!isTable(conductor))
1080
+ problems.push(`"conductor" must be a table`);
1081
+ const conductorT = isTable(conductor) ? conductor : {};
1082
+ const profilesRaw = conductorT.profiles === undefined ? {} : conductorT.profiles;
1083
+ if (!isTable(profilesRaw))
1084
+ problems.push(`"conductor.profiles" must be a table of profiles`);
1085
+ const profilesT = isTable(profilesRaw) ? profilesRaw : {};
1078
1086
  const known = [
1079
1087
  ["project", project, ["name", "slug"]],
1080
1088
  ["tracker", tracker, ["program_root", "language", "ready_label", "labels"]],
1081
1089
  ["tracker.labels", labelsT, ["phase_group", "runtime_group", "runtimes"]],
1082
1090
  ["github", github, ["repository"]],
1083
1091
  ["gates", gatesT, ["required_checks", "local_commands"]],
1084
- ["policy", policyT, ["silence_minutes", "silent_after_minutes"]]
1092
+ ["policy", policyT, ["silence_minutes", "silent_after_minutes"]],
1093
+ ["conductor", conductorT, ["default_profile", "profiles"]]
1085
1094
  ];
1095
+ const profiles = {};
1096
+ for (const [name, p] of Object.entries(profilesT)) {
1097
+ const path = `conductor.profiles.${name}`;
1098
+ if (!isTable(p)) {
1099
+ problems.push(`"${path}" must be a table`);
1100
+ continue;
1101
+ }
1102
+ if (name === "__proto__") {
1103
+ problems.push(`"${path}" is not a usable profile name`);
1104
+ continue;
1105
+ }
1106
+ known.push([path, p, ["agent", "model", "effort", "fast_mode"]]);
1107
+ if (p.fast_mode !== undefined && typeof p.fast_mode !== "boolean")
1108
+ problems.push(`"${path}.fast_mode" must be true or false`);
1109
+ profiles[name] = {
1110
+ agent: str(p, path, "agent"),
1111
+ model: str(p, path, "model"),
1112
+ effort: str(p, path, "effort"),
1113
+ fastMode: p.fast_mode === true
1114
+ };
1115
+ }
1116
+ let defaultProfile = null;
1117
+ if (conductorT.default_profile !== undefined) {
1118
+ defaultProfile = str(conductorT, "conductor", "default_profile") || null;
1119
+ if (defaultProfile && !Object.hasOwn(profiles, defaultProfile))
1120
+ problems.push(`"conductor.default_profile" is "${defaultProfile}", but there is no [conductor.profiles.${defaultProfile}]`);
1121
+ }
1086
1122
  for (const [path, t, keys] of known)
1087
1123
  for (const key of Object.keys(t))
1088
1124
  if (!keys.includes(key))
@@ -1144,7 +1180,8 @@ function parseConfig(text, source = CONFIG_FILE) {
1144
1180
  repository: str(github, "github", "repository", { pattern: REPOSITORY, hint: "owner/name" })
1145
1181
  },
1146
1182
  gates: { requiredChecks, localCommands },
1147
- policy: { silentAfterMinutes }
1183
+ policy: { silentAfterMinutes },
1184
+ conductor: { defaultProfile, profiles }
1148
1185
  };
1149
1186
  if (problems.length)
1150
1187
  throw new ConfigError(source, problems);
@@ -1178,187 +1215,45 @@ repository = ${q(p.repository)}
1178
1215
 
1179
1216
  [policy]
1180
1217
  silence_minutes = 15 # a worker with no report for longer than this shows as silent
1218
+
1219
+ # How \`armada brief\` launches workers on Conductor. Every value is passed explicitly;
1220
+ # \`conductor model\` lists each agent's model ids and effort levels.
1221
+ [conductor]
1222
+ default_profile = "opus"
1223
+
1224
+ [conductor.profiles.opus]
1225
+ agent = "claude"
1226
+ model = "opus-5-5-1m"
1227
+ effort = "high"
1228
+
1229
+ [conductor.profiles.codex]
1230
+ agent = "codex"
1231
+ model = "gpt-6.1-sol"
1232
+ effort = "high"
1181
1233
  `;
1182
1234
  }
1183
1235
  function slugify(name) {
1184
1236
  return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "project";
1185
1237
  }
1186
- // ../core/src/credentials.ts
1187
- var LINEAR_KEY = {
1188
- name: "linearApiKey",
1189
- variable: "LINEAR_API_KEY",
1190
- secret: true,
1191
- label: "Linear API key",
1192
- hint: "Linear > Settings > Security & access > Personal API keys"
1193
- };
1194
- var STORED_KEYS = [
1195
- LINEAR_KEY,
1196
- {
1197
- name: "tursoUrl",
1198
- variable: "ARMADA_TURSO_URL",
1199
- secret: false,
1200
- label: "Turso database URL",
1201
- hint: "libsql://<database>-<organization>.turso.io, from `turso db show <database> --url`"
1202
- },
1203
- {
1204
- name: "tursoToken",
1205
- variable: "ARMADA_TURSO_TOKEN",
1206
- secret: true,
1207
- label: "Turso database token",
1208
- hint: "`turso db tokens create <database>`"
1209
- }
1210
- ];
1211
- var clean = (v) => v?.trim() || null;
1212
- var fromEnv = (env, variable) => {
1213
- const value = clean(env[variable]);
1214
- return value ? { value, source: { kind: "env", variable } } : null;
1215
- };
1216
- function resolveCredentials({ env, store = {}, personal, ghToken }) {
1217
- const fromStore = (variable) => {
1218
- const value = clean(store[variable]);
1219
- return value ? { value, source: { kind: "store" } } : null;
1220
- };
1221
- const stored = (variable) => fromEnv(env, variable) ?? fromStore(variable);
1222
- const fromGh = () => {
1223
- const value = clean(ghToken?.());
1224
- return value ? { value, source: { kind: "gh" } } : null;
1225
- };
1226
- const tursoUrlConfig = clean(personal?.turso.url);
1227
- const found = {
1228
- linearApiKey: stored("LINEAR_API_KEY"),
1229
- tursoUrl: stored("ARMADA_TURSO_URL") ?? (tursoUrlConfig ? { value: tursoUrlConfig, source: { kind: "config", key: "turso.url" } } : null),
1230
- tursoToken: stored("ARMADA_TURSO_TOKEN"),
1231
- githubToken: fromEnv(env, "GITHUB_TOKEN") ?? fromEnv(env, "GH_TOKEN") ?? fromGh()
1232
- };
1233
- return {
1234
- linearApiKey: found.linearApiKey?.value ?? null,
1235
- tursoUrl: found.tursoUrl?.value ?? null,
1236
- tursoToken: found.tursoToken?.value ?? null,
1237
- githubToken: found.githubToken?.value ?? null,
1238
- sources: {
1239
- linearApiKey: found.linearApiKey?.source ?? null,
1240
- tursoUrl: found.tursoUrl?.source ?? null,
1241
- tursoToken: found.tursoToken?.source ?? null,
1242
- githubToken: found.githubToken?.source ?? null
1243
- }
1244
- };
1245
- }
1246
- var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name] === null);
1247
- function missingKeyMessage(key) {
1248
- return `${key.variable} is not set. Set it in the environment, or run \`armada auth login\` to store it on this machine (${key.hint}).`;
1249
- }
1250
- // ../core/src/dotenv.ts
1251
- var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
1252
- function shellWord(raw) {
1253
- let out = "";
1254
- let k = 0;
1255
- while (k < raw.length) {
1256
- const c = raw.charAt(k);
1257
- if (c === " " || c === "\t")
1258
- break;
1259
- if (c === "'") {
1260
- const end = raw.indexOf("'", k + 1);
1261
- if (end < 0)
1262
- return null;
1263
- out += raw.slice(k + 1, end);
1264
- k = end + 1;
1265
- } else if (c === '"') {
1266
- k++;
1267
- for (;; ) {
1268
- if (k >= raw.length)
1269
- return null;
1270
- const d = raw.charAt(k);
1271
- if (d === '"')
1272
- break;
1273
- const next = raw.charAt(k + 1);
1274
- if (d === "\\" && (next === '"' || next === "\\" || next === "$" || next === "`")) {
1275
- out += next;
1276
- k += 2;
1277
- } else {
1278
- out += d;
1279
- k++;
1280
- }
1281
- }
1282
- k++;
1283
- } else if (c === "\\") {
1284
- if (k + 1 >= raw.length)
1285
- return null;
1286
- out += raw.charAt(k + 1);
1287
- k += 2;
1288
- } else {
1289
- out += c;
1290
- k++;
1291
- }
1292
- }
1293
- const rest = raw.slice(k).trim();
1294
- return rest === "" || rest.startsWith("#") ? { value: out, comment: rest } : null;
1295
- }
1296
- function parseLine(line) {
1297
- const trimmed = line.trim();
1298
- if (!trimmed || trimmed.startsWith("#"))
1299
- return "blank";
1300
- const m = ASSIGNMENT.exec(line);
1301
- if (!m)
1302
- return null;
1303
- const word = shellWord(m[3] ?? "");
1304
- return word === null ? null : { key: m[2] ?? "", value: word.value };
1305
- }
1306
- var splitLines = (text) => text.split(/\r?\n/);
1307
- function parseDotenv(text) {
1308
- const values = new Map;
1309
- const invalidLines = [];
1310
- const assigned = new Set;
1311
- splitLines(text).forEach((line, index) => {
1312
- const key = ASSIGNMENT.exec(line)?.[2];
1313
- if (key !== undefined)
1314
- assigned.add(key);
1315
- const parsed = parseLine(line);
1316
- if (parsed === null)
1317
- invalidLines.push(index + 1);
1318
- else if (parsed !== "blank")
1319
- values.set(parsed.key, parsed.value);
1320
- });
1321
- return { values: Object.fromEntries(values), invalidLines, assigned: [...assigned] };
1322
- }
1323
- var SHELL_SAFE = /^[A-Za-z0-9_\-.:/@+=,%]+$/;
1324
- function formatDotenvValue(key, value) {
1325
- if (/[\r\n\0]/.test(value))
1326
- throw new Error(`the value for ${key} contains a line break and cannot be stored`);
1327
- if (value === "")
1328
- return "''";
1329
- return SHELL_SAFE.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
1330
- }
1331
- function updateDotenv(text, updates) {
1332
- const lines = text === "" ? [] : splitLines(text);
1333
- if (lines.length && lines[lines.length - 1] === "")
1334
- lines.pop();
1335
- const seen = new Set;
1336
- const out = [];
1337
- for (const line of lines) {
1338
- const m = ASSIGNMENT.exec(line);
1339
- const key = m?.[2];
1340
- if (!m || key === undefined || !Object.hasOwn(updates, key)) {
1341
- out.push(line);
1342
- continue;
1343
- }
1344
- if (seen.has(key))
1345
- continue;
1346
- seen.add(key);
1347
- const value = updates[key];
1348
- if (value === null || value === undefined)
1349
- continue;
1350
- const comment = shellWord(m[3] ?? "")?.comment;
1351
- out.push(`${m[1] ?? ""}${key}=${formatDotenvValue(key, value)}${comment ? ` ${comment}` : ""}`);
1352
- }
1353
- for (const [key, value] of Object.entries(updates)) {
1354
- if (seen.has(key) || value === null)
1355
- continue;
1356
- out.push(`${key}=${formatDotenvValue(key, value)}`);
1357
- }
1358
- return out.length ? `${out.join(`
1359
- `)}
1360
- ` : "";
1238
+ function resolveProfile(config, requested) {
1239
+ const { profiles, defaultProfile } = config.conductor;
1240
+ const names = Object.keys(profiles);
1241
+ const name = requested ?? defaultProfile ?? (names.length === 1 ? names[0] ?? null : null);
1242
+ const profile = name && Object.hasOwn(profiles, name) ? profiles[name] : undefined;
1243
+ if (name && profile)
1244
+ return { name, profile };
1245
+ const available = names.length ? names.join(", ") : "none";
1246
+ if (name)
1247
+ return { name: null, profile: null, problem: `no Conductor profile "${name}" (available: ${available})` };
1248
+ if (names.length)
1249
+ return {
1250
+ name: null,
1251
+ profile: null,
1252
+ problem: `several Conductor profiles and no conductor.default_profile; pass --profile (${available})`
1253
+ };
1254
+ return { name: null, profile: null, problem: null };
1361
1255
  }
1256
+
1362
1257
  // ../core/src/model.ts
1363
1258
  var CLOSED = ["completed", "canceled"];
1364
1259
  var NOT_STARTED = ["triage", "backlog", "unstarted"];
@@ -1639,6 +1534,7 @@ function waitingPullRequests(m, prs) {
1639
1534
  ticketOf.set(p.url, i);
1640
1535
  return prs.filter((p) => p.state === "open").map((pr) => ({ pr, ticket: ticketOf.get(pr.url) ?? null })).sort((a, b) => a.pr.number - b.pr.number);
1641
1536
  }
1537
+
1642
1538
  // ../core/src/types.ts
1643
1539
  var LABEL_PHASES = [
1644
1540
  "planning",
@@ -1652,13 +1548,18 @@ var LABEL_PHASES = [
1652
1548
  // ../core/src/linear.ts
1653
1549
  var LINEAR_ENDPOINT = "https://api.linear.app/graphql";
1654
1550
  var MAX_DEPTH = 8;
1655
- var MAX_PAGES = 20;
1656
1551
  var COMMENT_BATCH = 25;
1657
1552
  var MAX_COMMENTS = 100;
1553
+ var MORE_PAGE = 100;
1658
1554
  var REQUEST_TIMEOUT_MS = 30000;
1659
1555
 
1660
1556
  class LinearError extends Error {
1557
+ transport;
1661
1558
  name = "LinearError";
1559
+ constructor(message, transport = false) {
1560
+ super(message);
1561
+ this.transport = transport;
1562
+ }
1662
1563
  }
1663
1564
  var PHASES = [...LABEL_PHASES, "released", "merged"];
1664
1565
  var LEGACY = { "handed-back": "ready-to-merge", "ci-fixing": "shipping" };
@@ -1713,14 +1614,6 @@ function agentLabels(labels, groups) {
1713
1614
  }
1714
1615
  var sameName = (a, b) => a.toLowerCase().replace(/[^a-z0-9]/g, "") === b.toLowerCase().replace(/[^a-z0-9]/g, "");
1715
1616
  var phaseNamed = (name) => LABEL_PHASES.find((p) => sameName(p, name)) ?? null;
1716
- function truncationWarnings(raw) {
1717
- const cut = (c, what) => c.pageInfo?.hasNextPage ? [`${raw.identifier}: more ${what} than Armada reads; some are ignored`] : [];
1718
- return [
1719
- ...cut(raw.inverseRelations, "relations"),
1720
- ...cut(raw.labels, "labels"),
1721
- ...cut(raw.attachments, "attachments")
1722
- ];
1723
- }
1724
1617
  function normalizeIssue(raw, groups) {
1725
1618
  const blockers = new Map;
1726
1619
  for (const r of raw.inverseRelations.nodes)
@@ -1771,6 +1664,28 @@ function normalizeComment(raw, issueId) {
1771
1664
  claim: parseClaim(raw.body, raw.createdAt, author)
1772
1665
  };
1773
1666
  }
1667
+ var MORE = {
1668
+ inverseRelations: {
1669
+ field: "inverseRelations",
1670
+ nodes: "type issue { identifier state { type } }",
1671
+ operation: "MoreRelations",
1672
+ what: "relations"
1673
+ },
1674
+ labels: { field: "labels", nodes: "name parent { name }", operation: "MoreLabels", what: "labels" },
1675
+ attachments: { field: "attachments", nodes: "title url", operation: "MoreAttachments", what: "attachments" },
1676
+ comments: {
1677
+ field: "comments",
1678
+ nodes: "id createdAt body user { name }",
1679
+ operation: "MoreComments",
1680
+ what: "comments"
1681
+ }
1682
+ };
1683
+ var MORE_QUERY = (m) => `
1684
+ query ${m.operation}($id: String!, $after: String) {
1685
+ issue(id: $id) {
1686
+ ${m.field}(first: ${m.first ?? MORE_PAGE}, after: $after) { pageInfo { hasNextPage endCursor } nodes { ${m.nodes} } }
1687
+ }
1688
+ }`;
1774
1689
  var FIELDS = (delegate) => `
1775
1690
  fragment F on Issue {
1776
1691
  id identifier title url description createdAt updatedAt startedAt completedAt canceledAt
@@ -1778,9 +1693,9 @@ var FIELDS = (delegate) => `
1778
1693
  assignee { name }
1779
1694
  ${delegate ? "delegate { name }" : ""}
1780
1695
  parent { identifier }
1781
- labels(first: 25) { pageInfo { hasNextPage } nodes { name parent { name } } }
1782
- attachments(first: 25) { pageInfo { hasNextPage } nodes { title url } }
1783
- inverseRelations(first: 50) { pageInfo { hasNextPage } nodes { type issue { identifier state { type } } } }
1696
+ labels(first: 25) { pageInfo { hasNextPage endCursor } nodes { ${MORE.labels.nodes} } }
1697
+ attachments(first: 25) { pageInfo { hasNextPage endCursor } nodes { ${MORE.attachments.nodes} } }
1698
+ inverseRelations(first: 50) { pageInfo { hasNextPage endCursor } nodes { ${MORE.inverseRelations.nodes} } }
1784
1699
  }
1785
1700
  `;
1786
1701
  var ROOT_QUERY = (d) => `${FIELDS(d)} query Root($id: String!) { issue(id: $id) { ...F } }`;
@@ -1794,7 +1709,7 @@ var CHILDREN_QUERY = (d) => `${FIELDS(d)}
1794
1709
  var COMMENTS_QUERY = `
1795
1710
  query Comments($ids: [ID!]) {
1796
1711
  issues(first: 50, filter: { id: { in: $ids } }) {
1797
- nodes { identifier comments(first: ${MAX_COMMENTS}) { pageInfo { hasNextPage } nodes { id createdAt body user { name } } } }
1712
+ nodes { identifier comments(first: ${MAX_COMMENTS}) { pageInfo { hasNextPage endCursor } nodes { ${MORE.comments.nodes} } } }
1798
1713
  }
1799
1714
  }`;
1800
1715
  async function gql(opts, query, variables) {
@@ -1806,15 +1721,15 @@ async function gql(opts, query, variables) {
1806
1721
  body: JSON.stringify({ query, variables }),
1807
1722
  signal: AbortSignal.timeout(timeoutMs)
1808
1723
  }).catch((err) => {
1809
- throw new LinearError(`Linear API unreachable: ${networkReason(err, timeoutMs)}`);
1724
+ throw new LinearError(`Linear API unreachable: ${networkReason(err, timeoutMs)}`, true);
1810
1725
  });
1811
1726
  if (res.status === 401)
1812
- throw new LinearError("Linear rejected the API key (HTTP 401); check LINEAR_API_KEY");
1727
+ throw new LinearError("Linear rejected the API key (HTTP 401); check LINEAR_API_KEY", true);
1813
1728
  const json = await res.json().catch(() => ({}));
1814
1729
  if (json.errors?.length)
1815
1730
  throw new LinearError(`Linear API: ${json.errors.map((e) => e.message).join("; ")}`);
1816
1731
  if (!res.ok)
1817
- throw new LinearError(`Linear API HTTP ${res.status}`);
1732
+ throw new LinearError(`Linear API HTTP ${res.status}`, true);
1818
1733
  if (!json.data)
1819
1734
  throw new LinearError("Linear API: empty response");
1820
1735
  return json.data;
@@ -1845,34 +1760,35 @@ async function fetchTree(opts, delegate) {
1845
1760
  for (let depth = 0;depth < MAX_DEPTH && parents.length; depth++) {
1846
1761
  const next = [];
1847
1762
  let after = null;
1848
- for (let page = 0;; page++) {
1849
- if (page === MAX_PAGES) {
1850
- warnings.push(`more than ${MAX_PAGES * 50} issues at depth ${depth + 1}; the rest are ignored`);
1851
- break;
1852
- }
1763
+ for (;; ) {
1853
1764
  const data = await gql(opts, CHILDREN_QUERY(delegate), { parents, after });
1854
1765
  all.push(...data.issues.nodes);
1855
1766
  next.push(...data.issues.nodes.map((n) => n.id));
1856
- if (!data.issues.pageInfo.hasNextPage)
1767
+ const { hasNextPage, endCursor } = data.issues.pageInfo;
1768
+ if (!hasNextPage)
1769
+ break;
1770
+ if (!endCursor || endCursor === after) {
1771
+ warnings.push(`issues at depth ${depth + 1}: Linear did not advance to the next page; the rest are ignored`);
1857
1772
  break;
1858
- after = data.issues.pageInfo.endCursor;
1773
+ }
1774
+ after = endCursor;
1859
1775
  }
1860
1776
  parents = next;
1861
1777
  }
1862
1778
  if (parents.length)
1863
1779
  warnings.push(`the program is deeper than ${MAX_DEPTH} levels; deeper issues are ignored`);
1864
1780
  for (const r of all)
1865
- warnings.push(...truncationWarnings(r));
1781
+ for (const field of ["inverseRelations", "labels", "attachments"])
1782
+ await readRest(opts, r.identifier, MORE[field], r[field], warnings);
1866
1783
  const issues = all.map((r) => normalizeIssue(r, opts.labels));
1867
1784
  const candidates = issues.filter((i) => i.id !== root.identifier && !CLOSED2.has(i.statusType) && (i.agentPhase || i.statusType === "started"));
1868
1785
  const comments = [];
1869
1786
  for (const batch of chunks(candidates.map((i) => i.uuid), COMMENT_BATCH)) {
1870
1787
  const data = await gql(opts, COMMENTS_QUERY, { ids: batch });
1871
1788
  for (const n of data.issues.nodes) {
1789
+ await readRest(opts, n.identifier, MORE.comments, n.comments, warnings);
1872
1790
  for (const c of n.comments.nodes)
1873
1791
  comments.push(normalizeComment(c, n.identifier));
1874
- if (n.comments.pageInfo?.hasNextPage)
1875
- warnings.push(`${n.identifier}: more than ${MAX_COMMENTS} comments; its phase and claim may be out of date`);
1876
1792
  }
1877
1793
  }
1878
1794
  return {
@@ -1883,7 +1799,446 @@ async function fetchTree(opts, delegate) {
1883
1799
  warnings
1884
1800
  };
1885
1801
  }
1802
+ async function readRest(opts, identifier, more, conn, warnings) {
1803
+ while (conn.pageInfo?.hasNextPage) {
1804
+ const after = conn.pageInfo.endCursor;
1805
+ try {
1806
+ if (!after)
1807
+ throw new LinearError("Linear gave no cursor for the next page");
1808
+ const data = await gql(opts, MORE_QUERY(more), {
1809
+ id: identifier,
1810
+ after
1811
+ });
1812
+ const page = data.issue?.[more.field];
1813
+ if (!page)
1814
+ throw new LinearError(`Linear: issue ${identifier} not found`);
1815
+ conn.nodes.push(...page.nodes);
1816
+ conn.pageInfo = page.pageInfo;
1817
+ if (page.pageInfo?.hasNextPage && page.pageInfo.endCursor === after)
1818
+ throw new LinearError("Linear did not advance to a next page");
1819
+ } catch (err) {
1820
+ if (!(err instanceof LinearError) || err.transport)
1821
+ throw err;
1822
+ warnings.push(`${identifier}: could not read all its ${more.what} (${err.message}); some may be missing`);
1823
+ return;
1824
+ }
1825
+ }
1826
+ }
1827
+
1828
+ // ../core/src/brief.ts
1829
+ var ARMADA_PACKAGE = "@the-vibe-company/armada";
1830
+ var WORKER_SKILL_PATH = ".agents/skills/armada-worker/SKILL.md";
1831
+ var CONDUCTOR_HANDLE = '"$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"';
1832
+ var MAX_NOTES = 10;
1833
+ var NOTE = "id createdAt body user { name }";
1834
+ var NOTES = `pageInfo { hasNextPage endCursor } nodes { ${NOTE} }`;
1835
+ var RELATION = `type issue { identifier title url state { name type } comments(first: 50) { ${NOTES} } }`;
1836
+ var BRIEF_QUERY = `
1837
+ query Brief($id: String!) {
1838
+ issue(id: $id) {
1839
+ identifier title url branchName description
1840
+ state { name type }
1841
+ parent { identifier title url }
1842
+ comments(first: 50) { ${NOTES} }
1843
+ inverseRelations(first: 25) { pageInfo { hasNextPage endCursor } nodes { ${RELATION} } }
1844
+ }
1845
+ }`;
1846
+ var MORE_NOTES = { field: "comments", nodes: NOTE, operation: "MoreBriefComments", what: "comments" };
1847
+ var MORE_RELATIONS = {
1848
+ field: "inverseRelations",
1849
+ nodes: RELATION,
1850
+ operation: "MoreBriefRelations",
1851
+ what: "relations",
1852
+ first: 25
1853
+ };
1854
+ var noteUrl = (issueUrl, id) => `${issueUrl}#comment-${id.slice(0, 8)}`;
1855
+ var toNotes = (issueUrl, raw) => raw.nodes.map((c) => ({ url: noteUrl(issueUrl, c.id), author: c.user?.name ?? null, createdAt: c.createdAt, body: c.body })).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
1856
+ function normalizeBriefTicket(raw, warnings = []) {
1857
+ const blockers = raw.inverseRelations.nodes.filter((r) => r.type === "blocks").map(({ issue: b }) => ({
1858
+ id: b.identifier,
1859
+ title: b.title,
1860
+ url: b.url,
1861
+ status: b.state.name,
1862
+ statusType: b.state.type,
1863
+ notes: toNotes(b.url, b.comments)
1864
+ })).sort((a, b) => a.id.localeCompare(b.id, "en", { numeric: true }));
1865
+ return {
1866
+ id: raw.identifier,
1867
+ title: raw.title,
1868
+ url: raw.url,
1869
+ branchName: raw.branchName || null,
1870
+ description: raw.description?.trim() ?? "",
1871
+ status: raw.state.name,
1872
+ statusType: raw.state.type,
1873
+ parent: raw.parent ? { id: raw.parent.identifier, title: raw.parent.title, url: raw.parent.url } : null,
1874
+ notes: toNotes(raw.url, raw.comments),
1875
+ blockers,
1876
+ warnings
1877
+ };
1878
+ }
1879
+ async function fetchBriefTicket(opts, id) {
1880
+ const data = await gql(opts, BRIEF_QUERY, { id }).catch((err) => {
1881
+ if (err instanceof LinearError && /not found/i.test(err.message))
1882
+ return { issue: null };
1883
+ throw err;
1884
+ });
1885
+ const raw = data.issue;
1886
+ if (!raw)
1887
+ return null;
1888
+ const warnings = [];
1889
+ await readRest(opts, raw.identifier, MORE_NOTES, raw.comments, warnings);
1890
+ await readRest(opts, raw.identifier, MORE_RELATIONS, raw.inverseRelations, warnings);
1891
+ for (const r of raw.inverseRelations.nodes)
1892
+ if (r.type === "blocks")
1893
+ await readRest(opts, r.issue.identifier, MORE_NOTES, r.issue.comments, warnings);
1894
+ return normalizeBriefTicket(raw, warnings);
1895
+ }
1896
+ function handBackNote(notes) {
1897
+ const withStatus = notes.filter((n) => parseStatusLine(n.body));
1898
+ return withStatus.find((n) => parseStatusLine(n.body)?.phase === "ready-to-merge") ?? withStatus[0] ?? null;
1899
+ }
1900
+ var VARIABLES = [
1901
+ { name: "LINEAR_API_KEY", required: true, purpose: "Linear key the worker claims and reports with" },
1902
+ { name: "ARMADA_TURSO_URL", required: false, purpose: "Turso database for live activity" },
1903
+ { name: "ARMADA_TURSO_TOKEN", required: false, purpose: "Turso database token" }
1904
+ ];
1905
+
1906
+ class BriefError extends Error {
1907
+ name = "BriefError";
1908
+ }
1909
+ function buildBrief(input) {
1910
+ const { config, ticket, program } = input;
1911
+ const warnings = [...new Set([...ticket.warnings, ...program.warnings])];
1912
+ const choice = resolveProfile(config, input.profile);
1913
+ if (!choice.profile && choice.problem)
1914
+ throw new BriefError(choice.problem);
1915
+ if (!choice.profile)
1916
+ warnings.push("armada.toml declares no [conductor.profiles.<name>]; add one so the launch passes an explicit agent, model and effort");
1917
+ if (ticket.statusType === "completed" || ticket.statusType === "canceled")
1918
+ warnings.push(`${ticket.id} is ${ticket.status}; there is nothing to launch`);
1919
+ const open = ticket.blockers.filter((b) => b.statusType !== "completed" && b.statusType !== "canceled");
1920
+ if (open.length)
1921
+ warnings.push(`${ticket.id} is blocked by ${open.map((b) => `${b.id} (${b.status})`).join(", ")}`);
1922
+ const m = buildModel(program.issues, program.rootId);
1923
+ const lanes = inFlight(m, program.comments, {
1924
+ now: input.now.getTime(),
1925
+ silentAfterMinutes: config.policy.silentAfterMinutes
1926
+ });
1927
+ const self = lanes.find((l) => l.issue.id === ticket.id);
1928
+ if (self)
1929
+ warnings.push(`${ticket.id} is already in flight (${self.phase}); launching again makes a second worker`);
1930
+ if (!program.issues.some((i) => i.id === ticket.id))
1931
+ warnings.push(`${ticket.id} is not under the program root ${config.tracker.programRoot}`);
1932
+ const parallel = lanes.filter((l) => l.issue.id !== ticket.id).map((l) => ({
1933
+ id: l.issue.id,
1934
+ title: l.issue.title,
1935
+ url: l.issue.url,
1936
+ phase: l.phase,
1937
+ branch: l.claim?.branch ?? null,
1938
+ pr: l.pr?.url ?? null
1939
+ }));
1940
+ const pkg = `${ARMADA_PACKAGE}@${input.version}`;
1941
+ const branch = ticket.branchName;
1942
+ const claimCommand = `armada claim ${ticket.id} --runtime conductor --handle ${CONDUCTOR_HANDLE}${branch ? ` --branch ${branch}` : ""}`;
1943
+ const has = (name) => !!input.env[name]?.trim();
1944
+ const environment = [
1945
+ ...VARIABLES.map((v) => ({
1946
+ ...v,
1947
+ value: null,
1948
+ inShell: has(v.name),
1949
+ inStore: !has(v.name) && !!input.stored?.includes(v.name)
1950
+ })),
1951
+ {
1952
+ name: "ARMADA_TICKET",
1953
+ required: true,
1954
+ value: ticket.id,
1955
+ inShell: false,
1956
+ inStore: false,
1957
+ purpose: "the ticket this worker owns"
1958
+ }
1959
+ ];
1960
+ const brief = {
1961
+ ticket: {
1962
+ id: ticket.id,
1963
+ title: ticket.title,
1964
+ url: ticket.url,
1965
+ branch,
1966
+ status: ticket.status,
1967
+ description: ticket.description
1968
+ },
1969
+ parent: ticket.parent,
1970
+ runtime: "conductor",
1971
+ profile: choice.profile ? { name: choice.name, ...choice.profile } : null,
1972
+ repository: { name: config.github.repository, url: `https://github.com/${config.github.repository}` },
1973
+ install: `npm install -g ${pkg}`,
1974
+ fallback: `npm exec --yes --package=${pkg} -- armada`,
1975
+ claimCommand,
1976
+ environment,
1977
+ blockers: ticket.blockers.map(({ notes, ...b }) => ({ ...b, handBack: handBackNote(notes) })),
1978
+ notes: ticket.notes.slice(0, MAX_NOTES),
1979
+ parallel,
1980
+ warnings
1981
+ };
1982
+ if (ticket.notes.length > MAX_NOTES)
1983
+ warnings.push(`${ticket.id} has ${ticket.notes.length} comments; the brief carries the newest ${MAX_NOTES}`);
1984
+ return { ...brief, prompt: renderPrompt(brief) };
1985
+ }
1986
+ var quote = (body) => body.trim().split(`
1987
+ `).map((l) => l ? `> ${l}` : ">").join(`
1988
+ `);
1989
+ var byLine = (n) => `${n.author ?? "unknown"}, ${n.createdAt.slice(0, 16).replace("T", " ")}Z — ${n.url}`;
1990
+ function renderPrompt(b) {
1991
+ const t = b.ticket;
1992
+ const out = [
1993
+ `# ${t.id} — ${t.title}`,
1994
+ "",
1995
+ `You are an Armada worker. You own exactly one ticket, ${t.id} (${t.url}), and turn it into one green pull request on ${b.repository.name}. Follow the \`armada-worker\` skill (\`${WORKER_SKILL_PATH}\`) and the repository's \`AGENTS.md\`. Never merge.`,
1996
+ "",
1997
+ "## First: install Armada and claim the ticket",
1998
+ "",
1999
+ "```sh",
2000
+ b.install,
2001
+ b.claimCommand,
2002
+ "```",
2003
+ "",
2004
+ `This installs the coordinator's Armada version. If the global install is refused, use \`${b.fallback}\` wherever this brief or the skill says \`armada\`.`,
2005
+ "",
2006
+ "If the claim is refused, stop and say why in your reply: another worker holds the ticket.",
2007
+ "",
2008
+ "## Branch",
2009
+ "",
2010
+ t.branch ? `Work on \`${t.branch}\`. Your workspace starts on a branch Conductor named; rename it before your first commit: \`git branch -m ${t.branch}\`.` : "Linear suggests no branch name for this ticket; name yours after the ticket id.",
2011
+ ""
2012
+ ];
2013
+ if (t.description)
2014
+ out.push("## Ticket", "", quote(t.description), "");
2015
+ if (b.parent)
2016
+ out.push("## Parent", "", `${b.parent.id} — ${b.parent.title} (${b.parent.url}). Read it before planning.`, "");
2017
+ if (b.blockers.length) {
2018
+ out.push("## Blockers and their hand-back notes", "");
2019
+ for (const x of b.blockers) {
2020
+ out.push(`### ${x.id} — ${x.title} (${x.status})`, "", x.url, "");
2021
+ out.push(x.handBack ? `${byLine(x.handBack)}
1886
2022
 
2023
+ ${quote(x.handBack.body)}` : "No hand-back note.", "");
2024
+ }
2025
+ }
2026
+ if (b.notes.length) {
2027
+ out.push("## Already recorded on this ticket", "", "Newest first. Decisions here stand unless the coordinator changes them.", "");
2028
+ for (const n of b.notes)
2029
+ out.push(`### ${byLine(n)}`, "", quote(n.body), "");
2030
+ }
2031
+ out.push("## Workers in flight", "");
2032
+ if (b.parallel.length) {
2033
+ out.push("Stay out of their areas. If you must change the same files, say so in a report before you do.", "");
2034
+ for (const w of b.parallel)
2035
+ out.push(`- ${w.id} — ${w.title} (${w.phase})${w.branch ? `, branch \`${w.branch}\`` : ""}${w.pr ? `, ${w.pr}` : ""}`);
2036
+ } else
2037
+ out.push("None.");
2038
+ out.push("", "## Environment", "", `The coordinator set ${b.environment.map((v) => `\`${v.name}\``).join(", ")} in this workspace. Never print, commit or log their values.`);
2039
+ return `${out.join(`
2040
+ `)}
2041
+ `;
2042
+ }
2043
+ async function loadBrief(config, opts) {
2044
+ const now = opts.now ?? (() => new Date);
2045
+ const linear = { apiKey: opts.linearApiKey, ...opts.fetch ? { fetch: opts.fetch } : {} };
2046
+ const choice = resolveProfile(config, opts.profile);
2047
+ if (!choice.profile && choice.problem)
2048
+ throw new BriefError(choice.problem);
2049
+ const [ticket, program] = await Promise.all([
2050
+ fetchBriefTicket(linear, opts.ticket),
2051
+ fetchProgram({ ...linear, rootId: config.tracker.programRoot, labels: config.tracker.labels, now })
2052
+ ]);
2053
+ if (!ticket)
2054
+ throw new Error(`ticket ${opts.ticket} not found in Linear`);
2055
+ return buildBrief({
2056
+ config,
2057
+ ticket,
2058
+ program,
2059
+ profile: opts.profile,
2060
+ version: opts.version,
2061
+ env: opts.env,
2062
+ ...opts.stored ? { stored: opts.stored } : {},
2063
+ now: now()
2064
+ });
2065
+ }
2066
+ // ../core/src/credentials.ts
2067
+ var LINEAR_KEY = {
2068
+ name: "linearApiKey",
2069
+ variable: "LINEAR_API_KEY",
2070
+ secret: true,
2071
+ label: "Linear API key",
2072
+ hint: "Linear > Settings > Security & access > Personal API keys"
2073
+ };
2074
+ var STORED_KEYS = [
2075
+ LINEAR_KEY,
2076
+ {
2077
+ name: "tursoUrl",
2078
+ variable: "ARMADA_TURSO_URL",
2079
+ secret: false,
2080
+ label: "Turso database URL",
2081
+ hint: "libsql://<database>-<organization>.turso.io, from `turso db show <database> --url`"
2082
+ },
2083
+ {
2084
+ name: "tursoToken",
2085
+ variable: "ARMADA_TURSO_TOKEN",
2086
+ secret: true,
2087
+ label: "Turso database token",
2088
+ hint: "`turso db tokens create <database>`"
2089
+ }
2090
+ ];
2091
+ var clean = (v) => v?.trim() || null;
2092
+ var fromEnv = (env, variable) => {
2093
+ const value = clean(env[variable]);
2094
+ return value ? { value, source: { kind: "env", variable } } : null;
2095
+ };
2096
+ function resolveCredentials({ env, store = {}, personal, ghToken }) {
2097
+ const fromStore = (variable) => {
2098
+ const value = clean(store[variable]);
2099
+ return value ? { value, source: { kind: "store" } } : null;
2100
+ };
2101
+ const stored = (variable) => fromEnv(env, variable) ?? fromStore(variable);
2102
+ const fromGh = () => {
2103
+ const value = clean(ghToken?.());
2104
+ return value ? { value, source: { kind: "gh" } } : null;
2105
+ };
2106
+ const tursoUrlConfig = clean(personal?.turso.url);
2107
+ const found = {
2108
+ linearApiKey: stored("LINEAR_API_KEY"),
2109
+ tursoUrl: stored("ARMADA_TURSO_URL") ?? (tursoUrlConfig ? { value: tursoUrlConfig, source: { kind: "config", key: "turso.url" } } : null),
2110
+ tursoToken: stored("ARMADA_TURSO_TOKEN"),
2111
+ githubToken: fromEnv(env, "GITHUB_TOKEN") ?? fromEnv(env, "GH_TOKEN") ?? fromGh()
2112
+ };
2113
+ return {
2114
+ linearApiKey: found.linearApiKey?.value ?? null,
2115
+ tursoUrl: found.tursoUrl?.value ?? null,
2116
+ tursoToken: found.tursoToken?.value ?? null,
2117
+ githubToken: found.githubToken?.value ?? null,
2118
+ sources: {
2119
+ linearApiKey: found.linearApiKey?.source ?? null,
2120
+ tursoUrl: found.tursoUrl?.source ?? null,
2121
+ tursoToken: found.tursoToken?.source ?? null,
2122
+ githubToken: found.githubToken?.source ?? null
2123
+ }
2124
+ };
2125
+ }
2126
+ var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name] === null);
2127
+ function missingKeyMessage(key) {
2128
+ return `${key.variable} is not set. Set it in the environment, or run \`armada auth login\` to store it on this machine (${key.hint}).`;
2129
+ }
2130
+ // ../core/src/dotenv.ts
2131
+ var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
2132
+ function shellWord(raw) {
2133
+ let out = "";
2134
+ let k = 0;
2135
+ while (k < raw.length) {
2136
+ const c = raw.charAt(k);
2137
+ if (c === " " || c === "\t")
2138
+ break;
2139
+ if (c === "'") {
2140
+ const end = raw.indexOf("'", k + 1);
2141
+ if (end < 0)
2142
+ return null;
2143
+ out += raw.slice(k + 1, end);
2144
+ k = end + 1;
2145
+ } else if (c === '"') {
2146
+ k++;
2147
+ for (;; ) {
2148
+ if (k >= raw.length)
2149
+ return null;
2150
+ const d = raw.charAt(k);
2151
+ if (d === '"')
2152
+ break;
2153
+ const next = raw.charAt(k + 1);
2154
+ if (d === "\\" && (next === '"' || next === "\\" || next === "$" || next === "`")) {
2155
+ out += next;
2156
+ k += 2;
2157
+ } else {
2158
+ out += d;
2159
+ k++;
2160
+ }
2161
+ }
2162
+ k++;
2163
+ } else if (c === "\\") {
2164
+ if (k + 1 >= raw.length)
2165
+ return null;
2166
+ out += raw.charAt(k + 1);
2167
+ k += 2;
2168
+ } else {
2169
+ out += c;
2170
+ k++;
2171
+ }
2172
+ }
2173
+ const rest = raw.slice(k).trim();
2174
+ return rest === "" || rest.startsWith("#") ? { value: out, comment: rest } : null;
2175
+ }
2176
+ function parseLine(line) {
2177
+ const trimmed = line.trim();
2178
+ if (!trimmed || trimmed.startsWith("#"))
2179
+ return "blank";
2180
+ const m = ASSIGNMENT.exec(line);
2181
+ if (!m)
2182
+ return null;
2183
+ const word = shellWord(m[3] ?? "");
2184
+ return word === null ? null : { key: m[2] ?? "", value: word.value };
2185
+ }
2186
+ var splitLines = (text) => text.split(/\r?\n/);
2187
+ function parseDotenv(text) {
2188
+ const values = new Map;
2189
+ const invalidLines = [];
2190
+ const assigned = new Set;
2191
+ splitLines(text).forEach((line, index) => {
2192
+ const key = ASSIGNMENT.exec(line)?.[2];
2193
+ if (key !== undefined)
2194
+ assigned.add(key);
2195
+ const parsed = parseLine(line);
2196
+ if (parsed === null)
2197
+ invalidLines.push(index + 1);
2198
+ else if (parsed !== "blank")
2199
+ values.set(parsed.key, parsed.value);
2200
+ });
2201
+ return { values: Object.fromEntries(values), invalidLines, assigned: [...assigned] };
2202
+ }
2203
+ var SHELL_SAFE = /^[A-Za-z0-9_\-.:/@+=,%]+$/;
2204
+ function formatDotenvValue(key, value) {
2205
+ if (/[\r\n\0]/.test(value))
2206
+ throw new Error(`the value for ${key} contains a line break and cannot be stored`);
2207
+ if (value === "")
2208
+ return "''";
2209
+ return SHELL_SAFE.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
2210
+ }
2211
+ function updateDotenv(text, updates) {
2212
+ const lines = text === "" ? [] : splitLines(text);
2213
+ if (lines.length && lines[lines.length - 1] === "")
2214
+ lines.pop();
2215
+ const seen = new Set;
2216
+ const out = [];
2217
+ for (const line of lines) {
2218
+ const m = ASSIGNMENT.exec(line);
2219
+ const key = m?.[2];
2220
+ if (!m || key === undefined || !Object.hasOwn(updates, key)) {
2221
+ out.push(line);
2222
+ continue;
2223
+ }
2224
+ if (seen.has(key))
2225
+ continue;
2226
+ seen.add(key);
2227
+ const value = updates[key];
2228
+ if (value === null || value === undefined)
2229
+ continue;
2230
+ const comment = shellWord(m[3] ?? "")?.comment;
2231
+ out.push(`${m[1] ?? ""}${key}=${formatDotenvValue(key, value)}${comment ? ` ${comment}` : ""}`);
2232
+ }
2233
+ for (const [key, value] of Object.entries(updates)) {
2234
+ if (seen.has(key) || value === null)
2235
+ continue;
2236
+ out.push(`${key}=${formatDotenvValue(key, value)}`);
2237
+ }
2238
+ return out.length ? `${out.join(`
2239
+ `)}
2240
+ ` : "";
2241
+ }
1887
2242
  // ../core/src/github.ts
1888
2243
  var GITHUB_GRAPHQL = "https://api.github.com/graphql";
1889
2244
 
@@ -3578,7 +3933,12 @@ The coordinator turns the owner's intent into merged pull requests. Each worker
3578
3933
  1. **Read the fleet** with \`armada status\` and \`armada inbox\`, never from memory. Done when you can name every ticket in flight and its phase, every ready ticket, every pull request waiting, every silent worker and every pending question or request.
3579
3934
  2. **Answer what waits for you first.** For each question: decide, deliver the answer in the worker's session with the runtime guide's *message* section, then \`armada answer <item> --message "<decision and reason>"\`. Decide reversible choices yourself and prefer the option that keeps behaviour observable. When two workers need the same shared resource (a migration slot, a generated file, a version number), set the rule once and tell both.
3580
3935
  3. **Check silent workers** with the runtime guide's *status* section. A worker that is still working gets a nudge to report; a worker that died is relaunched or its ticket released.
3581
- 4. **Launch ready tickets** that do not collide with work in flight: \`armada brief <ticket>\` gives the launch prompt and the environment the runtime must pass; launch with the runtime guide's *launch* section, then record the handle with \`armada claim\` if the worker did not. Add to the brief what only you know: merged blockers and their hand-back notes, decisions already made, and which parallel workers touch neighbouring code. Done when every launched ticket is In Progress with a claim.
3936
+ 4. **Launch ready tickets** that do not collide with work in flight, one at a time:
3937
+ - pick the ticket from the frontier in \`armada status\`;
3938
+ - run \`armada brief <ticket>\` and resolve its warnings; the profile (agent, model, effort) comes from \`[conductor]\` in \`armada.toml\`, \`--profile <name>\` picks another one;
3939
+ - write the prompt with \`armada brief <ticket> --prompt > <file>\` and add what only you know: which parallel workers touch neighbouring code and where the boundary is, and decisions not yet on the ticket;
3940
+ - launch it with the runtime guide's *launch* section, passing the profile's values and the environment variables the brief names;
3941
+ - check the claim: \`armada status\` shows the ticket in flight, phase \`planning\`, with the handle the runtime returned. Done when every launched ticket is In Progress with a claim.
3582
3942
  5. **Merge handed-back pull requests** one at a time with \`armada merge <pr>\`, following [MERGE.md](MERGE.md). Done when the pull request is merged, the ticket is Done with its agent labels removed, and every in-flight worker affected by what landed has been told.
3583
3943
  6. **Turn findings into tickets.** A gap a worker reports or a bug you see becomes a ticket under the right spec, with blocked-by relations, and is launched when ready. No finding lives only in a transcript.
3584
3944
  7. **Report to the owner** in their language (\`tracker.language\` in \`armada.toml\`, or the owner's personal setting): what merged, what runs, what you decided for them, and the one thing they must do, with its exact place (a URL, a setting). Outcomes and numbers, no process narration.
@@ -3594,7 +3954,7 @@ Repeat from step 1; \`armada inbox --wait\` blocks until something needs you.
3594
3954
  `;
3595
3955
 
3596
3956
  // ../../skills/armada-runtime-conductor/SKILL.md
3597
- var SKILL_default2 = "---\nname: armada-runtime-conductor\ndescription: Runtime guide for running Armada workers on Conductor. Use when an Armada coordinator must launch a worker, send it a message, check whether it is alive, or stop and archive it on Conductor. Four fixed sections, each with the conductor command and how to read its output.\n---\n\nArmada never calls a runtime itself. This guide tells the coordinator how to do the four runtime actions with the `conductor` command line tool, and what to record in Armada afterwards. Check the exact flags with `conductor --help` and `conductor <command> --help`: this first version gives the commands to use, and a later Armada release completes the options and sample outputs.\n\n## Launch\n\n```sh\nconductor workspace create --repo <owner/name> --branch <ticket branch>\n```\n\nPass the prompt from `armada brief <ticket>` as the first message, and the environment variables it lists. Read the workspace id and the session id from the output; they form the handle `<workspace>/<session>`. Record it with `armada claim <ticket> --runtime conductor --handle <workspace>/<session>` unless the worker claims it itself.\n\n## Message\n\n```sh\nconductor message create --workspace <workspace> --session <session> --message \"<text>\"\n```\n\nUse it to deliver an answer, an approval or a heads-up that the default branch moved. A zero exit code means Conductor accepted the message; it does not mean the worker read it. After delivering an answer, record it with `armada answer`.\n\n## Status\n\n```sh\nconductor session status --workspace <workspace> --session <session>\n```\n\nTells whether the session is running, idle or ended. A silent worker whose session is running is busy: nudge it to report. An idle or ended session with the ticket not handed back needs a message or a relaunch.\n\n## Stop and archive\n\n```sh\nconductor workspace archive --workspace <workspace>\n```\n\nArchive a worker's workspace after its pull request is merged, or when its ticket is released. Archiving stops the session and frees the workspace; the branch and the pull request stay on GitHub.\n";
3957
+ var SKILL_default2 = "---\nname: armada-runtime-conductor\ndescription: Runtime guide for running Armada workers on Conductor Cloud. Use when an Armada coordinator must launch a worker on a ticket, send it a message, check whether a silent worker is still alive, or stop and archive it. Four fixed sections, each with the exact conductor command and how to read its output.\n---\n\nArmada never calls a runtime. This guide tells the coordinator how to launch, message, check and stop a worker with the `conductor` command line tool, and what to record in Armada afterwards. It was checked against `conductor` 0.89.2; if a flag is refused, compare with `conductor <command> --help`.\n\n- Always pass `--json` and read fields with `jq`. Exit codes: 0 ok, 1 runtime error, 2 usage error, 3 authentication (`conductor auth status`), 4 server error.\n- A worker is one workspace with one session. Its Armada handle is `<workspaceId>/<sessionId>`; the worker's claim comment carries it, so `armada status` and the ticket always lead back to the session.\n- Never type a secret value into a command, a file or a message: name the variable and let your shell expand it. The expanded value is still in the `conductor` process's arguments while it runs, so launch from a machine only you use.\n\n## Launch\n\n1. Pick a ready ticket from `armada status` that does not collide with work in flight.\n2. Run `armada brief ABC-12`. Read the profile (agent, model, effort, fast mode), the environment table and the warnings. Resolve every warning first: an open blocker, a ticket already in flight. Export each required variable the table marks `NOT set in this shell`. One marked `in credentials file` is in Armada's machine store: keep the `set -a` line of the launch command below, which loads that file without printing it.\n3. Write the prompt to a file, and add what only you know (the boundary with a parallel worker, a decision not yet on the ticket):\n\n```sh\narmada brief ABC-12 --prompt > /tmp/abc-12-brief.md\n```\n\n4. Create the workspace with every value from the profile. Never leave the agent, model or effort to Conductor's defaults. Add `--fast-mode` when the profile says fast mode; drop an optional `--env` line whose variable you do not have. Run the whole block as one command: shell state does not carry over between separate calls, and the subshell keeps the keys out of the rest of your session. Drop the `set -a` line when every variable is set in your shell.\n\n```sh\n(\n set -a; . \"${XDG_CONFIG_HOME:-$HOME/.config}/armada/credentials\"; set +a\n [ -n \"$LINEAR_API_KEY\" ] || { echo \"LINEAR_API_KEY is missing\" >&2; exit 1; }\n conductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n --env LINEAR_API_KEY=\"$LINEAR_API_KEY\" \\\n --env ARMADA_TURSO_URL=\"$ARMADA_TURSO_URL\" \\\n --env ARMADA_TURSO_TOKEN=\"$ARMADA_TURSO_TOKEN\" \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\n)\njq -r '\"\\(.workspaceId)/\\(.sessionId)\"' /tmp/abc-12-launch.json\n```\n\n- `--branch` is the base branch (the default branch). Conductor creates a branch named `conductor/<slug of --name>`; the brief tells the worker to rename it to the ticket's branch.\n- The output has `workspaceId`, `sessionId`, `deepLink` and `initialMessage` (`messageId`, `state: \"queued\"`). Keep the handle the `jq` line prints, and give the owner the `deepLink` when they want to watch.\n- Conductor sets `CONDUCTOR_WORKSPACE_ID` and `CONDUCTOR_SESSION_ID` inside the workspace. The brief's first commands install your Armada version (`npm install -g`) and claim the ticket with them. `--env` values are not shown back by `workspace get`.\n- An unknown agent, model or effort fails the command. Check the ids with `conductor model` (each agent's models, efforts and defaults) and fix the profile in `armada.toml`.\n\n5. **Check the claim.** Within a few minutes, `armada status` lists the ticket in flight, phase `planning`, runtime `Conductor`, and the ticket's claim comment reads `session: <workspaceId>/<sessionId>`. No claim after ten minutes: read the transcript (Status section). If the worker cannot claim (for example a missing key), fix the cause and message it; as a last resort record the handle yourself with `armada claim ABC-12 --runtime conductor --handle <workspaceId>/<sessionId>`.\n\n## Message\n\n```sh\nprintf '%s\\n' \"Plan approved. Go on.\" | conductor --json message create --session <sessionId> --message-file -\nconductor --json message create --session <sessionId> --message-file - < /tmp/abc-12-answer.md\n```\n\nThe output is `{\"messageId\": …, \"state\": \"sent\"}`. Exit code 0 means Conductor accepted the message, not that the worker read it: check that the session turns `working`, then read its reply in the transcript. Use it to deliver an answer, a plan approval, or a heads-up that the default branch moved. After delivering an answer, record it with `armada answer` when your Armada version has it.\n\n## Status\n\n```sh\nconductor --json session status <sessionId>\n```\n\nThe output is `{\"workspaceId\", \"sessionId\", \"status\", \"updatedAt\"}`. For a worker:\n\n- `working`: a turn is running. A silent worker that is `working` is busy (a long build or test run): leave it, and read the transcript if it stays silent past twice `policy.silence_minutes`.\n- `idle`: no turn is running. The worker finished its turn: it handed back, it waits for an answer, or it stopped without finishing. If `armada status` does not show it `ready-to-merge`, `awaiting-approval` or `blocked`, it has stopped: read its last reply, then message it to go on, or release and relaunch the ticket.\n- `error`: the last turn failed (agent or provider failure). Read the transcript and message it to resume; if it fails again, cancel, archive, release and relaunch.\n- Right after launch the session is `idle` for a few seconds while the workspace is initializing and the first message is queued; it turns `working` when the agent starts.\n\nThe workspace itself: `conductor --json workspace status <workspaceId>` gives `status` `initializing`, `ready` or `archived`.\n\n**Read the transcript** to see what a worker did or said. Events come oldest first, 100 per page; `hasMore` tells when to fetch the next page with `--after` the last event id. Keep the last id you read and poll from it.\n\n```sh\nconductor --json session message <sessionId> --limit 100 > /tmp/abc-12-events.json\njq -r '.hasMore, .data[-1].id' /tmp/abc-12-events.json\njq -r '.data[] | select(.content.rawPayload.type == \"result\") | .content.rawPayload | \"error=\\(.is_error)\\n\\(.result)\"' /tmp/abc-12-events.json\njq -r '.data[] | select(.content.rawPayload.type == \"assistant\") | .content.rawPayload.message.content[] | select(.type == \"tool_use\") | .input.command // .name' /tmp/abc-12-events.json\nconductor --json session message <sessionId> --after <lastEventId> --limit 100\n```\n\nThe second line prints whether more pages exist and the id to continue from; the third, each turn's final reply; the fourth, the commands and tools the worker ran. `.content.rawPayload` is the agent's own event format: these filters read the `claude` agent; for another agent, look at one event and adapt the filter.\n\n## Stop and archive\n\n```sh\nconductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n\n- `session cancel` stops the running turn: `{\"status\", \"canceledQueuedMessages\"}`, and the session is `idle` within seconds. The workspace stays; a message starts a new turn. Use it on a worker that runs the wrong thing.\n- `workspace archive` answers `{\"status\": \"archived\"}`. Archive a worker's workspace after its pull request is merged, or after `armada release --ticket ABC-12 --reason \"<why>\"` for a worker that stops without handing back. The branch and the pull request stay on GitHub.\n- After an archive, `session status` still answers `idle`; `workspace status` says `archived`.\n";
3598
3958
 
3599
3959
  // ../../skills/armada-worker/SKILL.md
3600
3960
  var SKILL_default3 = `---
@@ -3615,7 +3975,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
3615
3975
 
3616
3976
  ## Steps
3617
3977
 
3618
- 1. **Claim.** \`armada claim <ticket> --runtime <runtime> --handle <workspace>/<session>\`. It assigns the ticket, moves it to In Progress, sets \`Agent phase = planning\` and your \`Agent runtime\`, and posts the \`Agent claim\` comment. If it refuses because another claim exists, stop: the older claim wins.
3978
+ 1. **Claim** with the exact command your brief starts with, for example \`armada claim <ticket> --runtime conductor --handle "$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"\`. Install the Armada version the brief names first; if it gives a fallback command, use it wherever this skill says \`armada\`. It assigns the ticket, moves it to In Progress, sets \`Agent phase = planning\` and your \`Agent runtime\`, and posts the \`Agent claim\` comment. If it refuses because another claim exists, stop: the older claim wins.
3619
3979
  2. **Branch.** Use the branch named after the ticket (the tracker suggests one, for example \`feature/abc-12-short-title\`), created from the latest default branch.
3620
3980
  3. **Plan.** Write the plan: what changes, how it is tested, and the checks a person could observe when it is done. If your brief says plans are pre-approved, post it with \`armada report implementing --message "<plan>"\` and go on. Otherwise post it with \`armada report awaiting-approval --message "<plan>"\`, push your branch, and wait for the coordinator's answer in your session.
3621
3981
  4. **Implement** test-first. A material change to the approved plan needs a new approval.
@@ -3984,7 +4344,7 @@ async function loadStatus(config, opts) {
3984
4344
  });
3985
4345
  }
3986
4346
  // package.json
3987
- var version = "0.1.3";
4347
+ var version = "0.1.5";
3988
4348
 
3989
4349
  // src/io.ts
3990
4350
  class UsageError extends Error {
@@ -4155,6 +4515,77 @@ async function authLogout(io) {
4155
4515
  return 0;
4156
4516
  }
4157
4517
 
4518
+ // src/brief.ts
4519
+ function renderBrief(b) {
4520
+ const p = b.profile;
4521
+ const width = Math.max(...b.environment.map((v) => v.name.length + (v.value ? v.value.length + 1 : 0)));
4522
+ const out = [
4523
+ `Brief for ${b.ticket.id} — ${b.ticket.title} (${b.ticket.status})`,
4524
+ b.ticket.url,
4525
+ "",
4526
+ `Runtime: conductor (follow the armada-runtime-conductor skill to launch)`,
4527
+ `Profile: ${p ? `${p.name}: agent ${p.agent}, model ${p.model}, effort ${p.effort}${p.fastMode ? ", fast mode" : ""}` : "none declared in armada.toml"}`,
4528
+ `Repository: ${b.repository.url}`,
4529
+ `Branch: ${b.ticket.branch ?? "none suggested by Linear"} (the worker renames its workspace branch to it)`,
4530
+ "",
4531
+ "Environment to pass (values are never printed):",
4532
+ ...b.environment.map((v) => {
4533
+ const label = v.value ? `${v.name}=${v.value}` : v.name;
4534
+ const state = v.value ? "value above" : v.inShell ? "set in this shell" : v.inStore ? "in credentials file" : "NOT set in this shell";
4535
+ return ` ${label.padEnd(width)} ${v.required ? "required" : "optional"} ${state.padEnd(21)} ${v.purpose}`;
4536
+ })
4537
+ ];
4538
+ if (b.warnings.length)
4539
+ out.push("", "Warnings:", ...b.warnings.map((w) => ` - ${w}`));
4540
+ out.push("", `----- prompt (\`armada brief ${b.ticket.id} --prompt\` prints only this) -----`, "", b.prompt);
4541
+ return out.join(`
4542
+ `);
4543
+ }
4544
+ async function brief2(io, config2, credentials2, a, version2) {
4545
+ const [ticket, ...extra] = a.rest;
4546
+ if (!ticket)
4547
+ throw new UsageError("brief needs a ticket: armada brief <ticket> [--profile <name>]");
4548
+ if (extra.length)
4549
+ throw new UsageError(`unexpected argument ${extra[0]}`);
4550
+ const promptOnly = a.options.prompt === "true";
4551
+ if (a.json && promptOnly)
4552
+ throw new UsageError("pass --json or --prompt, not both");
4553
+ const profile = a.options.profile?.trim() || null;
4554
+ const choice = resolveProfile(config2, profile);
4555
+ if (!choice.profile && choice.problem)
4556
+ throw new UsageError(choice.problem);
4557
+ if (!credentials2.linearApiKey)
4558
+ throw new UsageError(missingKeyMessage(LINEAR_KEY));
4559
+ let b;
4560
+ try {
4561
+ b = await loadBrief(config2, {
4562
+ linearApiKey: credentials2.linearApiKey,
4563
+ ticket: ticket.toUpperCase(),
4564
+ profile,
4565
+ version: version2,
4566
+ env: io.env,
4567
+ stored: STORED_KEYS.filter((k) => credentials2.sources[k.name]?.kind === "store").map((k) => k.variable),
4568
+ ...io.fetch ? { fetch: io.fetch } : {},
4569
+ ...io.now ? { now: io.now } : {}
4570
+ });
4571
+ } catch (err) {
4572
+ if (err instanceof BriefError)
4573
+ throw new UsageError(err.message);
4574
+ throw err;
4575
+ }
4576
+ if (a.json)
4577
+ io.stdout(`${JSON.stringify(b, null, 2)}
4578
+ `);
4579
+ else if (promptOnly) {
4580
+ io.stdout(b.prompt);
4581
+ for (const w of b.warnings)
4582
+ io.stderr(`armada: warning: ${w}
4583
+ `);
4584
+ } else
4585
+ io.stdout(renderBrief(b));
4586
+ return 0;
4587
+ }
4588
+
4158
4589
  // src/repo.ts
4159
4590
  import { lstat, mkdir as mkdir2, readdir, readFile as readFile2, readlink, rm as rm2, symlink, writeFile } from "node:fs/promises";
4160
4591
  import { dirname, join as join2, relative, sep } from "node:path";
@@ -5083,6 +5514,10 @@ Commands:
5083
5514
  lock, close the ticket and list the workers to tell. Never deletes
5084
5515
  the branch. --dry-run only runs the checklist. Refused when Turso is
5085
5516
  configured but down; --no-lock then merges without the lock.
5517
+ brief <ticket> [--profile <name>] [--prompt]
5518
+ A new worker's launch prompt, the Conductor profile (agent, model,
5519
+ effort) and the environment variables to pass, named, never shown.
5520
+ --prompt prints only the prompt, for \`--message-file -\`
5086
5521
  auth login Ask for the missing keys (hidden input) and store them on this machine
5087
5522
  auth status Show which keys are set and where each comes from, never their values
5088
5523
  auth logout Remove Armada's keys from this machine
@@ -5096,7 +5531,8 @@ Options:
5096
5531
  -v, --version Print the version
5097
5532
 
5098
5533
  Keys (the environment always wins over the file):
5099
- LINEAR_API_KEY Linear API key (required by status, init, claim, report, release)
5534
+ LINEAR_API_KEY Linear API key (required by status, init, brief, claim, report,
5535
+ release)
5100
5536
  ARMADA_TURSO_URL Turso database URL (required by init and status --all; optional
5101
5537
  elsewhere; a file: URL works locally)
5102
5538
  ARMADA_TURSO_TOKEN Turso database token
@@ -5120,15 +5556,17 @@ var VALUE_OPTIONS = [
5120
5556
  "reason",
5121
5557
  "program-root",
5122
5558
  "name",
5123
- "slug"
5559
+ "slug",
5560
+ "profile"
5124
5561
  ];
5125
- var FLAG_OPTIONS = ["dry-run", "no-lock"];
5562
+ var FLAG_OPTIONS = ["dry-run", "no-lock", "prompt"];
5126
5563
  var COMMAND_OPTIONS = {
5127
5564
  claim: ["runtime", "handle", "branch"],
5128
5565
  report: ["ticket", "message", "message-file", "pr", "sha"],
5129
5566
  release: ["ticket", "reason"],
5130
5567
  init: ["program-root", "name", "slug"],
5131
- merge: ["ticket", "dry-run", "no-lock"]
5568
+ merge: ["ticket", "dry-run", "no-lock"],
5569
+ brief: ["profile", "prompt"]
5132
5570
  };
5133
5571
  function parseArgs(argv) {
5134
5572
  const args = {
@@ -5243,6 +5681,11 @@ async function run(argv, io) {
5243
5681
  const { credentials: credentials2 } = await loadCredentials(io);
5244
5682
  return await merge2(io, parseConfig(text, path), credentials2, args, path);
5245
5683
  }
5684
+ if (args.command === "brief") {
5685
+ const { path, text } = await findConfig(io, args.config);
5686
+ const { credentials: credentials2 } = await loadCredentials(io);
5687
+ return await brief2(io, parseConfig(text, path), credentials2, args, version);
5688
+ }
5246
5689
  if (args.command === "status") {
5247
5690
  noExtra(args.rest);
5248
5691
  return await (args.all ? statusAll(io, args.json) : status2(io, args));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-vibe-company/armada",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "Run a fleet of coding agents on one project: the armada command line.",
6
6
  "license": "MIT",