@the-vibe-company/armada 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/armada.js +577 -185
- 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
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
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",
|
|
@@ -1884,6 +1780,414 @@ async function fetchTree(opts, delegate) {
|
|
|
1884
1780
|
};
|
|
1885
1781
|
}
|
|
1886
1782
|
|
|
1783
|
+
// ../core/src/brief.ts
|
|
1784
|
+
var ARMADA_PACKAGE = "@the-vibe-company/armada";
|
|
1785
|
+
var WORKER_SKILL_PATH = ".agents/skills/armada-worker/SKILL.md";
|
|
1786
|
+
var CONDUCTOR_HANDLE = '"$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"';
|
|
1787
|
+
var MAX_NOTES = 10;
|
|
1788
|
+
var NOTES = "pageInfo { hasNextPage } nodes { id createdAt body user { name } }";
|
|
1789
|
+
var BRIEF_QUERY = `
|
|
1790
|
+
query Brief($id: String!) {
|
|
1791
|
+
issue(id: $id) {
|
|
1792
|
+
identifier title url branchName description
|
|
1793
|
+
state { name type }
|
|
1794
|
+
parent { identifier title url }
|
|
1795
|
+
comments(first: 50) { ${NOTES} }
|
|
1796
|
+
inverseRelations(first: 25) {
|
|
1797
|
+
pageInfo { hasNextPage }
|
|
1798
|
+
nodes { type issue { identifier title url state { name type } comments(first: 50) { ${NOTES} } } }
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
}`;
|
|
1802
|
+
var noteUrl = (issueUrl, id) => `${issueUrl}#comment-${id.slice(0, 8)}`;
|
|
1803
|
+
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));
|
|
1804
|
+
function normalizeBriefTicket(raw) {
|
|
1805
|
+
const warnings = [];
|
|
1806
|
+
const cut = (c, what) => {
|
|
1807
|
+
if (c.pageInfo?.hasNextPage)
|
|
1808
|
+
warnings.push(`${what}; the brief may miss the newest ones`);
|
|
1809
|
+
};
|
|
1810
|
+
cut(raw.comments, `${raw.identifier} has more comments than Armada reads`);
|
|
1811
|
+
cut(raw.inverseRelations, `${raw.identifier} has more relations than Armada reads`);
|
|
1812
|
+
const blockers = raw.inverseRelations.nodes.filter((r) => r.type === "blocks").map(({ issue: b }) => {
|
|
1813
|
+
cut(b.comments, `blocker ${b.identifier} has more comments than Armada reads`);
|
|
1814
|
+
return {
|
|
1815
|
+
id: b.identifier,
|
|
1816
|
+
title: b.title,
|
|
1817
|
+
url: b.url,
|
|
1818
|
+
status: b.state.name,
|
|
1819
|
+
statusType: b.state.type,
|
|
1820
|
+
notes: toNotes(b.url, b.comments)
|
|
1821
|
+
};
|
|
1822
|
+
}).sort((a, b) => a.id.localeCompare(b.id, "en", { numeric: true }));
|
|
1823
|
+
return {
|
|
1824
|
+
id: raw.identifier,
|
|
1825
|
+
title: raw.title,
|
|
1826
|
+
url: raw.url,
|
|
1827
|
+
branchName: raw.branchName || null,
|
|
1828
|
+
description: raw.description?.trim() ?? "",
|
|
1829
|
+
status: raw.state.name,
|
|
1830
|
+
statusType: raw.state.type,
|
|
1831
|
+
parent: raw.parent ? { id: raw.parent.identifier, title: raw.parent.title, url: raw.parent.url } : null,
|
|
1832
|
+
notes: toNotes(raw.url, raw.comments),
|
|
1833
|
+
blockers,
|
|
1834
|
+
warnings
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
async function fetchBriefTicket(opts, id) {
|
|
1838
|
+
const data = await gql(opts, BRIEF_QUERY, { id }).catch((err) => {
|
|
1839
|
+
if (err instanceof LinearError && /not found/i.test(err.message))
|
|
1840
|
+
return { issue: null };
|
|
1841
|
+
throw err;
|
|
1842
|
+
});
|
|
1843
|
+
return data.issue ? normalizeBriefTicket(data.issue) : null;
|
|
1844
|
+
}
|
|
1845
|
+
function handBackNote(notes) {
|
|
1846
|
+
const withStatus = notes.filter((n) => parseStatusLine(n.body));
|
|
1847
|
+
return withStatus.find((n) => parseStatusLine(n.body)?.phase === "ready-to-merge") ?? withStatus[0] ?? null;
|
|
1848
|
+
}
|
|
1849
|
+
var VARIABLES = [
|
|
1850
|
+
{ name: "LINEAR_API_KEY", required: true, purpose: "Linear key the worker claims and reports with" },
|
|
1851
|
+
{ name: "ARMADA_TURSO_URL", required: false, purpose: "Turso database for live activity" },
|
|
1852
|
+
{ name: "ARMADA_TURSO_TOKEN", required: false, purpose: "Turso database token" }
|
|
1853
|
+
];
|
|
1854
|
+
|
|
1855
|
+
class BriefError extends Error {
|
|
1856
|
+
name = "BriefError";
|
|
1857
|
+
}
|
|
1858
|
+
function buildBrief(input) {
|
|
1859
|
+
const { config, ticket, program } = input;
|
|
1860
|
+
const warnings = [...ticket.warnings, ...program.warnings];
|
|
1861
|
+
const choice = resolveProfile(config, input.profile);
|
|
1862
|
+
if (!choice.profile && choice.problem)
|
|
1863
|
+
throw new BriefError(choice.problem);
|
|
1864
|
+
if (!choice.profile)
|
|
1865
|
+
warnings.push("armada.toml declares no [conductor.profiles.<name>]; add one so the launch passes an explicit agent, model and effort");
|
|
1866
|
+
if (ticket.statusType === "completed" || ticket.statusType === "canceled")
|
|
1867
|
+
warnings.push(`${ticket.id} is ${ticket.status}; there is nothing to launch`);
|
|
1868
|
+
const open = ticket.blockers.filter((b) => b.statusType !== "completed" && b.statusType !== "canceled");
|
|
1869
|
+
if (open.length)
|
|
1870
|
+
warnings.push(`${ticket.id} is blocked by ${open.map((b) => `${b.id} (${b.status})`).join(", ")}`);
|
|
1871
|
+
const m = buildModel(program.issues, program.rootId);
|
|
1872
|
+
const lanes = inFlight(m, program.comments, {
|
|
1873
|
+
now: input.now.getTime(),
|
|
1874
|
+
silentAfterMinutes: config.policy.silentAfterMinutes
|
|
1875
|
+
});
|
|
1876
|
+
const self = lanes.find((l) => l.issue.id === ticket.id);
|
|
1877
|
+
if (self)
|
|
1878
|
+
warnings.push(`${ticket.id} is already in flight (${self.phase}); launching again makes a second worker`);
|
|
1879
|
+
if (!program.issues.some((i) => i.id === ticket.id))
|
|
1880
|
+
warnings.push(`${ticket.id} is not under the program root ${config.tracker.programRoot}`);
|
|
1881
|
+
const parallel = lanes.filter((l) => l.issue.id !== ticket.id).map((l) => ({
|
|
1882
|
+
id: l.issue.id,
|
|
1883
|
+
title: l.issue.title,
|
|
1884
|
+
url: l.issue.url,
|
|
1885
|
+
phase: l.phase,
|
|
1886
|
+
branch: l.claim?.branch ?? null,
|
|
1887
|
+
pr: l.pr?.url ?? null
|
|
1888
|
+
}));
|
|
1889
|
+
const pkg = `${ARMADA_PACKAGE}@${input.version}`;
|
|
1890
|
+
const branch = ticket.branchName;
|
|
1891
|
+
const claimCommand = `armada claim ${ticket.id} --runtime conductor --handle ${CONDUCTOR_HANDLE}${branch ? ` --branch ${branch}` : ""}`;
|
|
1892
|
+
const has = (name) => !!input.env[name]?.trim();
|
|
1893
|
+
const environment = [
|
|
1894
|
+
...VARIABLES.map((v) => ({
|
|
1895
|
+
...v,
|
|
1896
|
+
value: null,
|
|
1897
|
+
inShell: has(v.name),
|
|
1898
|
+
inStore: !has(v.name) && !!input.stored?.includes(v.name)
|
|
1899
|
+
})),
|
|
1900
|
+
{
|
|
1901
|
+
name: "ARMADA_TICKET",
|
|
1902
|
+
required: true,
|
|
1903
|
+
value: ticket.id,
|
|
1904
|
+
inShell: false,
|
|
1905
|
+
inStore: false,
|
|
1906
|
+
purpose: "the ticket this worker owns"
|
|
1907
|
+
}
|
|
1908
|
+
];
|
|
1909
|
+
const brief = {
|
|
1910
|
+
ticket: {
|
|
1911
|
+
id: ticket.id,
|
|
1912
|
+
title: ticket.title,
|
|
1913
|
+
url: ticket.url,
|
|
1914
|
+
branch,
|
|
1915
|
+
status: ticket.status,
|
|
1916
|
+
description: ticket.description
|
|
1917
|
+
},
|
|
1918
|
+
parent: ticket.parent,
|
|
1919
|
+
runtime: "conductor",
|
|
1920
|
+
profile: choice.profile ? { name: choice.name, ...choice.profile } : null,
|
|
1921
|
+
repository: { name: config.github.repository, url: `https://github.com/${config.github.repository}` },
|
|
1922
|
+
install: `npm install -g ${pkg}`,
|
|
1923
|
+
fallback: `npm exec --yes --package=${pkg} -- armada`,
|
|
1924
|
+
claimCommand,
|
|
1925
|
+
environment,
|
|
1926
|
+
blockers: ticket.blockers.map(({ notes, ...b }) => ({ ...b, handBack: handBackNote(notes) })),
|
|
1927
|
+
notes: ticket.notes.slice(0, MAX_NOTES),
|
|
1928
|
+
parallel,
|
|
1929
|
+
warnings
|
|
1930
|
+
};
|
|
1931
|
+
if (ticket.notes.length > MAX_NOTES)
|
|
1932
|
+
warnings.push(`${ticket.id} has ${ticket.notes.length} comments; the brief carries the newest ${MAX_NOTES}`);
|
|
1933
|
+
return { ...brief, prompt: renderPrompt(brief) };
|
|
1934
|
+
}
|
|
1935
|
+
var quote = (body) => body.trim().split(`
|
|
1936
|
+
`).map((l) => l ? `> ${l}` : ">").join(`
|
|
1937
|
+
`);
|
|
1938
|
+
var byLine = (n) => `${n.author ?? "unknown"}, ${n.createdAt.slice(0, 16).replace("T", " ")}Z — ${n.url}`;
|
|
1939
|
+
function renderPrompt(b) {
|
|
1940
|
+
const t = b.ticket;
|
|
1941
|
+
const out = [
|
|
1942
|
+
`# ${t.id} — ${t.title}`,
|
|
1943
|
+
"",
|
|
1944
|
+
`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.`,
|
|
1945
|
+
"",
|
|
1946
|
+
"## First: install Armada and claim the ticket",
|
|
1947
|
+
"",
|
|
1948
|
+
"```sh",
|
|
1949
|
+
b.install,
|
|
1950
|
+
b.claimCommand,
|
|
1951
|
+
"```",
|
|
1952
|
+
"",
|
|
1953
|
+
`This installs the coordinator's Armada version. If the global install is refused, use \`${b.fallback}\` wherever this brief or the skill says \`armada\`.`,
|
|
1954
|
+
"",
|
|
1955
|
+
"If the claim is refused, stop and say why in your reply: another worker holds the ticket.",
|
|
1956
|
+
"",
|
|
1957
|
+
"## Branch",
|
|
1958
|
+
"",
|
|
1959
|
+
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.",
|
|
1960
|
+
""
|
|
1961
|
+
];
|
|
1962
|
+
if (t.description)
|
|
1963
|
+
out.push("## Ticket", "", quote(t.description), "");
|
|
1964
|
+
if (b.parent)
|
|
1965
|
+
out.push("## Parent", "", `${b.parent.id} — ${b.parent.title} (${b.parent.url}). Read it before planning.`, "");
|
|
1966
|
+
if (b.blockers.length) {
|
|
1967
|
+
out.push("## Blockers and their hand-back notes", "");
|
|
1968
|
+
for (const x of b.blockers) {
|
|
1969
|
+
out.push(`### ${x.id} — ${x.title} (${x.status})`, "", x.url, "");
|
|
1970
|
+
out.push(x.handBack ? `${byLine(x.handBack)}
|
|
1971
|
+
|
|
1972
|
+
${quote(x.handBack.body)}` : "No hand-back note.", "");
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
if (b.notes.length) {
|
|
1976
|
+
out.push("## Already recorded on this ticket", "", "Newest first. Decisions here stand unless the coordinator changes them.", "");
|
|
1977
|
+
for (const n of b.notes)
|
|
1978
|
+
out.push(`### ${byLine(n)}`, "", quote(n.body), "");
|
|
1979
|
+
}
|
|
1980
|
+
out.push("## Workers in flight", "");
|
|
1981
|
+
if (b.parallel.length) {
|
|
1982
|
+
out.push("Stay out of their areas. If you must change the same files, say so in a report before you do.", "");
|
|
1983
|
+
for (const w of b.parallel)
|
|
1984
|
+
out.push(`- ${w.id} — ${w.title} (${w.phase})${w.branch ? `, branch \`${w.branch}\`` : ""}${w.pr ? `, ${w.pr}` : ""}`);
|
|
1985
|
+
} else
|
|
1986
|
+
out.push("None.");
|
|
1987
|
+
out.push("", "## Environment", "", `The coordinator set ${b.environment.map((v) => `\`${v.name}\``).join(", ")} in this workspace. Never print, commit or log their values.`);
|
|
1988
|
+
return `${out.join(`
|
|
1989
|
+
`)}
|
|
1990
|
+
`;
|
|
1991
|
+
}
|
|
1992
|
+
async function loadBrief(config, opts) {
|
|
1993
|
+
const now = opts.now ?? (() => new Date);
|
|
1994
|
+
const linear = { apiKey: opts.linearApiKey, ...opts.fetch ? { fetch: opts.fetch } : {} };
|
|
1995
|
+
const choice = resolveProfile(config, opts.profile);
|
|
1996
|
+
if (!choice.profile && choice.problem)
|
|
1997
|
+
throw new BriefError(choice.problem);
|
|
1998
|
+
const [ticket, program] = await Promise.all([
|
|
1999
|
+
fetchBriefTicket(linear, opts.ticket),
|
|
2000
|
+
fetchProgram({ ...linear, rootId: config.tracker.programRoot, labels: config.tracker.labels, now })
|
|
2001
|
+
]);
|
|
2002
|
+
if (!ticket)
|
|
2003
|
+
throw new Error(`ticket ${opts.ticket} not found in Linear`);
|
|
2004
|
+
return buildBrief({
|
|
2005
|
+
config,
|
|
2006
|
+
ticket,
|
|
2007
|
+
program,
|
|
2008
|
+
profile: opts.profile,
|
|
2009
|
+
version: opts.version,
|
|
2010
|
+
env: opts.env,
|
|
2011
|
+
...opts.stored ? { stored: opts.stored } : {},
|
|
2012
|
+
now: now()
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
// ../core/src/credentials.ts
|
|
2016
|
+
var LINEAR_KEY = {
|
|
2017
|
+
name: "linearApiKey",
|
|
2018
|
+
variable: "LINEAR_API_KEY",
|
|
2019
|
+
secret: true,
|
|
2020
|
+
label: "Linear API key",
|
|
2021
|
+
hint: "Linear > Settings > Security & access > Personal API keys"
|
|
2022
|
+
};
|
|
2023
|
+
var STORED_KEYS = [
|
|
2024
|
+
LINEAR_KEY,
|
|
2025
|
+
{
|
|
2026
|
+
name: "tursoUrl",
|
|
2027
|
+
variable: "ARMADA_TURSO_URL",
|
|
2028
|
+
secret: false,
|
|
2029
|
+
label: "Turso database URL",
|
|
2030
|
+
hint: "libsql://<database>-<organization>.turso.io, from `turso db show <database> --url`"
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
name: "tursoToken",
|
|
2034
|
+
variable: "ARMADA_TURSO_TOKEN",
|
|
2035
|
+
secret: true,
|
|
2036
|
+
label: "Turso database token",
|
|
2037
|
+
hint: "`turso db tokens create <database>`"
|
|
2038
|
+
}
|
|
2039
|
+
];
|
|
2040
|
+
var clean = (v) => v?.trim() || null;
|
|
2041
|
+
var fromEnv = (env, variable) => {
|
|
2042
|
+
const value = clean(env[variable]);
|
|
2043
|
+
return value ? { value, source: { kind: "env", variable } } : null;
|
|
2044
|
+
};
|
|
2045
|
+
function resolveCredentials({ env, store = {}, personal, ghToken }) {
|
|
2046
|
+
const fromStore = (variable) => {
|
|
2047
|
+
const value = clean(store[variable]);
|
|
2048
|
+
return value ? { value, source: { kind: "store" } } : null;
|
|
2049
|
+
};
|
|
2050
|
+
const stored = (variable) => fromEnv(env, variable) ?? fromStore(variable);
|
|
2051
|
+
const fromGh = () => {
|
|
2052
|
+
const value = clean(ghToken?.());
|
|
2053
|
+
return value ? { value, source: { kind: "gh" } } : null;
|
|
2054
|
+
};
|
|
2055
|
+
const tursoUrlConfig = clean(personal?.turso.url);
|
|
2056
|
+
const found = {
|
|
2057
|
+
linearApiKey: stored("LINEAR_API_KEY"),
|
|
2058
|
+
tursoUrl: stored("ARMADA_TURSO_URL") ?? (tursoUrlConfig ? { value: tursoUrlConfig, source: { kind: "config", key: "turso.url" } } : null),
|
|
2059
|
+
tursoToken: stored("ARMADA_TURSO_TOKEN"),
|
|
2060
|
+
githubToken: fromEnv(env, "GITHUB_TOKEN") ?? fromEnv(env, "GH_TOKEN") ?? fromGh()
|
|
2061
|
+
};
|
|
2062
|
+
return {
|
|
2063
|
+
linearApiKey: found.linearApiKey?.value ?? null,
|
|
2064
|
+
tursoUrl: found.tursoUrl?.value ?? null,
|
|
2065
|
+
tursoToken: found.tursoToken?.value ?? null,
|
|
2066
|
+
githubToken: found.githubToken?.value ?? null,
|
|
2067
|
+
sources: {
|
|
2068
|
+
linearApiKey: found.linearApiKey?.source ?? null,
|
|
2069
|
+
tursoUrl: found.tursoUrl?.source ?? null,
|
|
2070
|
+
tursoToken: found.tursoToken?.source ?? null,
|
|
2071
|
+
githubToken: found.githubToken?.source ?? null
|
|
2072
|
+
}
|
|
2073
|
+
};
|
|
2074
|
+
}
|
|
2075
|
+
var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name] === null);
|
|
2076
|
+
function missingKeyMessage(key) {
|
|
2077
|
+
return `${key.variable} is not set. Set it in the environment, or run \`armada auth login\` to store it on this machine (${key.hint}).`;
|
|
2078
|
+
}
|
|
2079
|
+
// ../core/src/dotenv.ts
|
|
2080
|
+
var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
2081
|
+
function shellWord(raw) {
|
|
2082
|
+
let out = "";
|
|
2083
|
+
let k = 0;
|
|
2084
|
+
while (k < raw.length) {
|
|
2085
|
+
const c = raw.charAt(k);
|
|
2086
|
+
if (c === " " || c === "\t")
|
|
2087
|
+
break;
|
|
2088
|
+
if (c === "'") {
|
|
2089
|
+
const end = raw.indexOf("'", k + 1);
|
|
2090
|
+
if (end < 0)
|
|
2091
|
+
return null;
|
|
2092
|
+
out += raw.slice(k + 1, end);
|
|
2093
|
+
k = end + 1;
|
|
2094
|
+
} else if (c === '"') {
|
|
2095
|
+
k++;
|
|
2096
|
+
for (;; ) {
|
|
2097
|
+
if (k >= raw.length)
|
|
2098
|
+
return null;
|
|
2099
|
+
const d = raw.charAt(k);
|
|
2100
|
+
if (d === '"')
|
|
2101
|
+
break;
|
|
2102
|
+
const next = raw.charAt(k + 1);
|
|
2103
|
+
if (d === "\\" && (next === '"' || next === "\\" || next === "$" || next === "`")) {
|
|
2104
|
+
out += next;
|
|
2105
|
+
k += 2;
|
|
2106
|
+
} else {
|
|
2107
|
+
out += d;
|
|
2108
|
+
k++;
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
k++;
|
|
2112
|
+
} else if (c === "\\") {
|
|
2113
|
+
if (k + 1 >= raw.length)
|
|
2114
|
+
return null;
|
|
2115
|
+
out += raw.charAt(k + 1);
|
|
2116
|
+
k += 2;
|
|
2117
|
+
} else {
|
|
2118
|
+
out += c;
|
|
2119
|
+
k++;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
const rest = raw.slice(k).trim();
|
|
2123
|
+
return rest === "" || rest.startsWith("#") ? { value: out, comment: rest } : null;
|
|
2124
|
+
}
|
|
2125
|
+
function parseLine(line) {
|
|
2126
|
+
const trimmed = line.trim();
|
|
2127
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
2128
|
+
return "blank";
|
|
2129
|
+
const m = ASSIGNMENT.exec(line);
|
|
2130
|
+
if (!m)
|
|
2131
|
+
return null;
|
|
2132
|
+
const word = shellWord(m[3] ?? "");
|
|
2133
|
+
return word === null ? null : { key: m[2] ?? "", value: word.value };
|
|
2134
|
+
}
|
|
2135
|
+
var splitLines = (text) => text.split(/\r?\n/);
|
|
2136
|
+
function parseDotenv(text) {
|
|
2137
|
+
const values = new Map;
|
|
2138
|
+
const invalidLines = [];
|
|
2139
|
+
const assigned = new Set;
|
|
2140
|
+
splitLines(text).forEach((line, index) => {
|
|
2141
|
+
const key = ASSIGNMENT.exec(line)?.[2];
|
|
2142
|
+
if (key !== undefined)
|
|
2143
|
+
assigned.add(key);
|
|
2144
|
+
const parsed = parseLine(line);
|
|
2145
|
+
if (parsed === null)
|
|
2146
|
+
invalidLines.push(index + 1);
|
|
2147
|
+
else if (parsed !== "blank")
|
|
2148
|
+
values.set(parsed.key, parsed.value);
|
|
2149
|
+
});
|
|
2150
|
+
return { values: Object.fromEntries(values), invalidLines, assigned: [...assigned] };
|
|
2151
|
+
}
|
|
2152
|
+
var SHELL_SAFE = /^[A-Za-z0-9_\-.:/@+=,%]+$/;
|
|
2153
|
+
function formatDotenvValue(key, value) {
|
|
2154
|
+
if (/[\r\n\0]/.test(value))
|
|
2155
|
+
throw new Error(`the value for ${key} contains a line break and cannot be stored`);
|
|
2156
|
+
if (value === "")
|
|
2157
|
+
return "''";
|
|
2158
|
+
return SHELL_SAFE.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
|
|
2159
|
+
}
|
|
2160
|
+
function updateDotenv(text, updates) {
|
|
2161
|
+
const lines = text === "" ? [] : splitLines(text);
|
|
2162
|
+
if (lines.length && lines[lines.length - 1] === "")
|
|
2163
|
+
lines.pop();
|
|
2164
|
+
const seen = new Set;
|
|
2165
|
+
const out = [];
|
|
2166
|
+
for (const line of lines) {
|
|
2167
|
+
const m = ASSIGNMENT.exec(line);
|
|
2168
|
+
const key = m?.[2];
|
|
2169
|
+
if (!m || key === undefined || !Object.hasOwn(updates, key)) {
|
|
2170
|
+
out.push(line);
|
|
2171
|
+
continue;
|
|
2172
|
+
}
|
|
2173
|
+
if (seen.has(key))
|
|
2174
|
+
continue;
|
|
2175
|
+
seen.add(key);
|
|
2176
|
+
const value = updates[key];
|
|
2177
|
+
if (value === null || value === undefined)
|
|
2178
|
+
continue;
|
|
2179
|
+
const comment = shellWord(m[3] ?? "")?.comment;
|
|
2180
|
+
out.push(`${m[1] ?? ""}${key}=${formatDotenvValue(key, value)}${comment ? ` ${comment}` : ""}`);
|
|
2181
|
+
}
|
|
2182
|
+
for (const [key, value] of Object.entries(updates)) {
|
|
2183
|
+
if (seen.has(key) || value === null)
|
|
2184
|
+
continue;
|
|
2185
|
+
out.push(`${key}=${formatDotenvValue(key, value)}`);
|
|
2186
|
+
}
|
|
2187
|
+
return out.length ? `${out.join(`
|
|
2188
|
+
`)}
|
|
2189
|
+
` : "";
|
|
2190
|
+
}
|
|
1887
2191
|
// ../core/src/github.ts
|
|
1888
2192
|
var GITHUB_GRAPHQL = "https://api.github.com/graphql";
|
|
1889
2193
|
|
|
@@ -3578,7 +3882,12 @@ The coordinator turns the owner's intent into merged pull requests. Each worker
|
|
|
3578
3882
|
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
3883
|
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
3884
|
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
|
|
3885
|
+
4. **Launch ready tickets** that do not collide with work in flight, one at a time:
|
|
3886
|
+
- pick the ticket from the frontier in \`armada status\`;
|
|
3887
|
+
- run \`armada brief <ticket>\` and resolve its warnings; the profile (agent, model, effort) comes from \`[conductor]\` in \`armada.toml\`, \`--profile <name>\` picks another one;
|
|
3888
|
+
- 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;
|
|
3889
|
+
- launch it with the runtime guide's *launch* section, passing the profile's values and the environment variables the brief names;
|
|
3890
|
+
- 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
3891
|
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
3892
|
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
3893
|
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 +3903,7 @@ Repeat from step 1; \`armada inbox --wait\` blocks until something needs you.
|
|
|
3594
3903
|
`;
|
|
3595
3904
|
|
|
3596
3905
|
// ../../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
|
|
3906
|
+
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
3907
|
|
|
3599
3908
|
// ../../skills/armada-worker/SKILL.md
|
|
3600
3909
|
var SKILL_default3 = `---
|
|
@@ -3615,7 +3924,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
|
|
|
3615
3924
|
|
|
3616
3925
|
## Steps
|
|
3617
3926
|
|
|
3618
|
-
1. **Claim
|
|
3927
|
+
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
3928
|
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
3929
|
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
3930
|
4. **Implement** test-first. A material change to the approved plan needs a new approval.
|
|
@@ -3984,7 +4293,7 @@ async function loadStatus(config, opts) {
|
|
|
3984
4293
|
});
|
|
3985
4294
|
}
|
|
3986
4295
|
// package.json
|
|
3987
|
-
var version = "0.1.
|
|
4296
|
+
var version = "0.1.4";
|
|
3988
4297
|
|
|
3989
4298
|
// src/io.ts
|
|
3990
4299
|
class UsageError extends Error {
|
|
@@ -4155,6 +4464,77 @@ async function authLogout(io) {
|
|
|
4155
4464
|
return 0;
|
|
4156
4465
|
}
|
|
4157
4466
|
|
|
4467
|
+
// src/brief.ts
|
|
4468
|
+
function renderBrief(b) {
|
|
4469
|
+
const p = b.profile;
|
|
4470
|
+
const width = Math.max(...b.environment.map((v) => v.name.length + (v.value ? v.value.length + 1 : 0)));
|
|
4471
|
+
const out = [
|
|
4472
|
+
`Brief for ${b.ticket.id} — ${b.ticket.title} (${b.ticket.status})`,
|
|
4473
|
+
b.ticket.url,
|
|
4474
|
+
"",
|
|
4475
|
+
`Runtime: conductor (follow the armada-runtime-conductor skill to launch)`,
|
|
4476
|
+
`Profile: ${p ? `${p.name}: agent ${p.agent}, model ${p.model}, effort ${p.effort}${p.fastMode ? ", fast mode" : ""}` : "none declared in armada.toml"}`,
|
|
4477
|
+
`Repository: ${b.repository.url}`,
|
|
4478
|
+
`Branch: ${b.ticket.branch ?? "none suggested by Linear"} (the worker renames its workspace branch to it)`,
|
|
4479
|
+
"",
|
|
4480
|
+
"Environment to pass (values are never printed):",
|
|
4481
|
+
...b.environment.map((v) => {
|
|
4482
|
+
const label = v.value ? `${v.name}=${v.value}` : v.name;
|
|
4483
|
+
const state = v.value ? "value above" : v.inShell ? "set in this shell" : v.inStore ? "in credentials file" : "NOT set in this shell";
|
|
4484
|
+
return ` ${label.padEnd(width)} ${v.required ? "required" : "optional"} ${state.padEnd(21)} ${v.purpose}`;
|
|
4485
|
+
})
|
|
4486
|
+
];
|
|
4487
|
+
if (b.warnings.length)
|
|
4488
|
+
out.push("", "Warnings:", ...b.warnings.map((w) => ` - ${w}`));
|
|
4489
|
+
out.push("", `----- prompt (\`armada brief ${b.ticket.id} --prompt\` prints only this) -----`, "", b.prompt);
|
|
4490
|
+
return out.join(`
|
|
4491
|
+
`);
|
|
4492
|
+
}
|
|
4493
|
+
async function brief2(io, config2, credentials2, a, version2) {
|
|
4494
|
+
const [ticket, ...extra] = a.rest;
|
|
4495
|
+
if (!ticket)
|
|
4496
|
+
throw new UsageError("brief needs a ticket: armada brief <ticket> [--profile <name>]");
|
|
4497
|
+
if (extra.length)
|
|
4498
|
+
throw new UsageError(`unexpected argument ${extra[0]}`);
|
|
4499
|
+
const promptOnly = a.options.prompt === "true";
|
|
4500
|
+
if (a.json && promptOnly)
|
|
4501
|
+
throw new UsageError("pass --json or --prompt, not both");
|
|
4502
|
+
const profile = a.options.profile?.trim() || null;
|
|
4503
|
+
const choice = resolveProfile(config2, profile);
|
|
4504
|
+
if (!choice.profile && choice.problem)
|
|
4505
|
+
throw new UsageError(choice.problem);
|
|
4506
|
+
if (!credentials2.linearApiKey)
|
|
4507
|
+
throw new UsageError(missingKeyMessage(LINEAR_KEY));
|
|
4508
|
+
let b;
|
|
4509
|
+
try {
|
|
4510
|
+
b = await loadBrief(config2, {
|
|
4511
|
+
linearApiKey: credentials2.linearApiKey,
|
|
4512
|
+
ticket: ticket.toUpperCase(),
|
|
4513
|
+
profile,
|
|
4514
|
+
version: version2,
|
|
4515
|
+
env: io.env,
|
|
4516
|
+
stored: STORED_KEYS.filter((k) => credentials2.sources[k.name]?.kind === "store").map((k) => k.variable),
|
|
4517
|
+
...io.fetch ? { fetch: io.fetch } : {},
|
|
4518
|
+
...io.now ? { now: io.now } : {}
|
|
4519
|
+
});
|
|
4520
|
+
} catch (err) {
|
|
4521
|
+
if (err instanceof BriefError)
|
|
4522
|
+
throw new UsageError(err.message);
|
|
4523
|
+
throw err;
|
|
4524
|
+
}
|
|
4525
|
+
if (a.json)
|
|
4526
|
+
io.stdout(`${JSON.stringify(b, null, 2)}
|
|
4527
|
+
`);
|
|
4528
|
+
else if (promptOnly) {
|
|
4529
|
+
io.stdout(b.prompt);
|
|
4530
|
+
for (const w of b.warnings)
|
|
4531
|
+
io.stderr(`armada: warning: ${w}
|
|
4532
|
+
`);
|
|
4533
|
+
} else
|
|
4534
|
+
io.stdout(renderBrief(b));
|
|
4535
|
+
return 0;
|
|
4536
|
+
}
|
|
4537
|
+
|
|
4158
4538
|
// src/repo.ts
|
|
4159
4539
|
import { lstat, mkdir as mkdir2, readdir, readFile as readFile2, readlink, rm as rm2, symlink, writeFile } from "node:fs/promises";
|
|
4160
4540
|
import { dirname, join as join2, relative, sep } from "node:path";
|
|
@@ -5083,6 +5463,10 @@ Commands:
|
|
|
5083
5463
|
lock, close the ticket and list the workers to tell. Never deletes
|
|
5084
5464
|
the branch. --dry-run only runs the checklist. Refused when Turso is
|
|
5085
5465
|
configured but down; --no-lock then merges without the lock.
|
|
5466
|
+
brief <ticket> [--profile <name>] [--prompt]
|
|
5467
|
+
A new worker's launch prompt, the Conductor profile (agent, model,
|
|
5468
|
+
effort) and the environment variables to pass, named, never shown.
|
|
5469
|
+
--prompt prints only the prompt, for \`--message-file -\`
|
|
5086
5470
|
auth login Ask for the missing keys (hidden input) and store them on this machine
|
|
5087
5471
|
auth status Show which keys are set and where each comes from, never their values
|
|
5088
5472
|
auth logout Remove Armada's keys from this machine
|
|
@@ -5096,7 +5480,8 @@ Options:
|
|
|
5096
5480
|
-v, --version Print the version
|
|
5097
5481
|
|
|
5098
5482
|
Keys (the environment always wins over the file):
|
|
5099
|
-
LINEAR_API_KEY Linear API key (required by status, init, claim, report,
|
|
5483
|
+
LINEAR_API_KEY Linear API key (required by status, init, brief, claim, report,
|
|
5484
|
+
release)
|
|
5100
5485
|
ARMADA_TURSO_URL Turso database URL (required by init and status --all; optional
|
|
5101
5486
|
elsewhere; a file: URL works locally)
|
|
5102
5487
|
ARMADA_TURSO_TOKEN Turso database token
|
|
@@ -5120,15 +5505,17 @@ var VALUE_OPTIONS = [
|
|
|
5120
5505
|
"reason",
|
|
5121
5506
|
"program-root",
|
|
5122
5507
|
"name",
|
|
5123
|
-
"slug"
|
|
5508
|
+
"slug",
|
|
5509
|
+
"profile"
|
|
5124
5510
|
];
|
|
5125
|
-
var FLAG_OPTIONS = ["dry-run", "no-lock"];
|
|
5511
|
+
var FLAG_OPTIONS = ["dry-run", "no-lock", "prompt"];
|
|
5126
5512
|
var COMMAND_OPTIONS = {
|
|
5127
5513
|
claim: ["runtime", "handle", "branch"],
|
|
5128
5514
|
report: ["ticket", "message", "message-file", "pr", "sha"],
|
|
5129
5515
|
release: ["ticket", "reason"],
|
|
5130
5516
|
init: ["program-root", "name", "slug"],
|
|
5131
|
-
merge: ["ticket", "dry-run", "no-lock"]
|
|
5517
|
+
merge: ["ticket", "dry-run", "no-lock"],
|
|
5518
|
+
brief: ["profile", "prompt"]
|
|
5132
5519
|
};
|
|
5133
5520
|
function parseArgs(argv) {
|
|
5134
5521
|
const args = {
|
|
@@ -5243,6 +5630,11 @@ async function run(argv, io) {
|
|
|
5243
5630
|
const { credentials: credentials2 } = await loadCredentials(io);
|
|
5244
5631
|
return await merge2(io, parseConfig(text, path), credentials2, args, path);
|
|
5245
5632
|
}
|
|
5633
|
+
if (args.command === "brief") {
|
|
5634
|
+
const { path, text } = await findConfig(io, args.config);
|
|
5635
|
+
const { credentials: credentials2 } = await loadCredentials(io);
|
|
5636
|
+
return await brief2(io, parseConfig(text, path), credentials2, args, version);
|
|
5637
|
+
}
|
|
5246
5638
|
if (args.command === "status") {
|
|
5247
5639
|
noExtra(args.rest);
|
|
5248
5640
|
return await (args.all ? statusAll(io, args.json) : status2(io, args));
|