@the-vibe-company/armada 0.2.2 → 0.2.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 +34 -6
- package/dist/armada.js +253 -126
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,8 @@ armada brief ABC-12 --profile codex --reason "a back-end bug behind a web label"
|
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
- 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), signing in with `armada login --launch-token <token>` 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.
|
|
83
|
+
- **Plan rule.** A "Plan" section says in one line whether the worker waits for approval: "post your plan with `armada report implementing --plan-file -` and go on" when plans are pre-approved, "post your plan with `armada report awaiting-approval --plan-file -` and wait for approval" otherwise. `[policy] plans` decides (`approve` by default, or `pre-approved`); a ticket labelled `plan-approved` (`policy.pre_approved_label`) is pre-approved, and one labelled `needs-plan-approval` (`policy.approval_label`) waits for approval, which wins when a ticket has both. The settings show the rule and where it comes from (`Plans:`), and `--json` carries it as `plans`.
|
|
84
|
+
- **Project conventions.** `[brief] extra = "<path>"` names a file of the repository (relative to `armada.toml`) that every prompt ends with, under "Project conventions": the checks to run, the generated files to refresh, how to bring main in. A missing file is a brief warning, and `armada doctor` checks it.
|
|
83
85
|
- **Workers need no key.** When the coordinator is signed in to an Armada that keeps the organization's keys, the brief asks it for a launch token: one ticket, used once, valid one hour. The worker exchanges it for a session limited to its ticket's `claim`, `report`, `ask` and `release`, and Armada gives each of those commands its keys. The `Launch:` line says whether the prompt carries one, and when there is none, why (not signed in, or an Armada without accounts or keys). Make the brief right before the launch; the token is the only secret a prompt ever holds, useless once used. Merging or releasing the ticket ends the worker's session, and Organization > Workers on the dashboard revokes one.
|
|
84
86
|
- The settings give the profile's agent, model and effort from `[conductor]` in `armada.toml`, and the environment variables: `ARMADA_TICKET=<ticket>`, and, only without a launch token, `LINEAR_API_KEY` (required). Each shows whether this shell has it. No value is ever printed.
|
|
85
87
|
- The profile follows the ticket's Linear labels: the first `[[conductor.routing]]` rule with a label the ticket carries (case, spaces and punctuation ignored), else `conductor.default_profile`, else the only profile. The settings say which rule chose it.
|
|
@@ -92,7 +94,7 @@ A worker writes to the tracker only through three commands. They set the labels
|
|
|
92
94
|
```sh
|
|
93
95
|
armada login --launch-token <token> # the first line of the launch message: no key needed after it
|
|
94
96
|
armada claim ABC-12 --runtime conductor --handle <workspace>/<session>
|
|
95
|
-
armada report awaiting-approval --
|
|
97
|
+
armada report awaiting-approval --plan-file plan.md # the plan as its own block, one-line status
|
|
96
98
|
armada report implementing --message "plan approved, writing the parser"
|
|
97
99
|
armada report implementing --message "parser done, wiring the CLI" # same phase = status update
|
|
98
100
|
armada report shipping --message "PR open" --pr 34
|
|
@@ -103,6 +105,7 @@ armada release --reason "wrong ticket"
|
|
|
103
105
|
- `claim` re-reads the ticket and refuses it when another worker holds it; if two claims race, the older comment wins and the other withdraws. It assigns the ticket to the Linear key's user, moves it to the team's first started state, sets the `planning` phase label and the runtime label (matched by name, so `conductor` finds `Conductor`), and posts an `Agent claim — runtime · session · branch · started` line. The handle is kept in that comment and on Armada, so a coordinator finds the session either way. Claiming again with the same handle repairs labels and state. It reads every comment and label of the ticket, however many.
|
|
104
106
|
- `report <phase>` accepts: planning → awaiting-approval or implementing; awaiting-approval → planning or implementing; implementing → shipping; shipping → implementing or ready-to-merge; ready-to-merge → shipping; blocked from anywhere and back to any phase; the current phase again as a status update. Anything else exits 1 with the reason. The output lists what waits in the worker's inbox.
|
|
105
107
|
- `report`, `ask` and `answer` accept `--message-file -` to read standard input to EOF, including a pipe or a shell heredoc. For example: `printf 'line one\nline two' | bun run armada report implementing --ticket ABC-12 --message-file -`. An explicitly empty or whitespace-only message file or stdin exits 2 before any tracker or database write, with a retry naming `--message` or a non-empty pipe. A `ready-to-merge` report may still omit the message option.
|
|
108
|
+
- `--plan <text>` or `--plan-file <path|->` posts the plan as its own `## Plan` block under the status line. `--message` becomes optional: its first line is the status, else the plan's first line (cut at 100 characters). `armada status` then shows that one line and `plan: <comment url>`, and the dashboard's status line gets a "plan ↗" link. Only one of `--message-file -` and `--plan-file -` can read standard input.
|
|
106
109
|
- `claim` and `report` read the ticket back and print where it stands, for example `Now: In Progress · phase implementing · runtime Conductor · profile none`, so a worker can check it without opening Linear. `--json` carries the same as `state`.
|
|
107
110
|
- `ready-to-merge` is refused unless the pull request is open in the project repository, `--sha` is the full 40-character SHA of its head, and every check in `[gates] required_checks` is green on that head (with none declared: at least one check, all green). It needs a GitHub token.
|
|
108
111
|
- `release` removes the phase and runtime labels, keeps the configured ready label so the ticket can be taken again, moves the ticket back to the team's first unstarted state and posts `Agent status: released — <reason>`.
|
|
@@ -122,7 +125,7 @@ armada answer --note ABC-12 "main moved: rebase before you ship" # an unsolicit
|
|
|
122
125
|
```
|
|
123
126
|
|
|
124
127
|
- `ask` reports the `blocked` phase with `Agent status: blocked — question: <first line>` (the rest and the numbered options below it) and adds a `question` item to the coordinator's inbox on Armada. The worker then stops and waits for the answer in its session, and reports the phase it resumes. It finds the ticket like `report`.
|
|
125
|
-
- `report awaiting-approval` adds a `plan` item with the full message and worker handle to the coordinator's inbox. Same-phase heartbeats neither duplicate nor reopen it. Answering it, recording a note, leaving the phase or releasing the ticket closes the plan and any pending approval request. For a pre-approved plan, post the plan with `report implementing
|
|
128
|
+
- `report awaiting-approval` adds a `plan` item with the full message (and the `--plan` block) and worker handle to the coordinator's inbox. Same-phase heartbeats neither duplicate nor reopen it. Answering it, recording a note, leaving the phase or releasing the ticket closes the plan and any pending approval request. For a pre-approved plan (the brief's "Plan" line says which), post the plan with `report implementing --plan-file -` instead: no approval item is needed.
|
|
126
129
|
- `inbox` lists the coordinator's open items (questions, plans, requests, hand-backs) and silent workers, oldest first. A worker is silent when it holds a ticket, its newest event is older than `policy.silence_minutes`, and its phase does not wait on someone else. It reads Armada only (a sign-in, no Linear key) and records that the coordinator is at work, for the dashboard. `--wait` asks Armada every 15 s until `--timeout`; Armada answers "not modified" (HTTP 304, no body) while the inbox holds the same entries, so a waiting coordinator costs one short request per ask and holds nothing open. It marks the items that were not there before with `*`; loop on it.
|
|
127
130
|
- `watch` is how a coordinator keeps listening, run in the background while a worker is in flight. It asks Armada like `inbox --wait` (every 15 s, every 60 s when no worker is in flight, 304 while nothing changed) with no time limit of its own, and exits as soon as something needs the coordinator that it has not been shown yet by `inbox` or `watch` on this machine: it prints the inbox, new items marked `*`. It exits with "nothing to watch" when no worker is in flight and nothing is open. Armada unreachable or answering 5xx only prints a warning and it keeps going, waiting longer each time; a refusal (signed out) ends it. One watch per project and machine: a second one says the first is running. Its state (a lock, the entries shown, the tickets in flight at the last read, the checkout it ran in) lives in `~/.config/armada/watch/`, no secret.
|
|
128
131
|
- The last line of `inbox`, `watch`, `merge` and `brief` (not `brief --prompt`) says whether to start watching again, for example `2 workers in flight (ABC-1, ABC-2) — keep watching: armada watch`; with `--json`, the same is the `watch` field.
|
|
@@ -155,8 +158,9 @@ armada merge 34 # or the pull request URL; --ticket ABC-12 when the
|
|
|
155
158
|
- **At work** has one row per ticket in flight. A row shows the project, the runtime and session, the six-step phase pipeline, time in phase, the last report, the pull request with its CI, and the flags (red CI, conflict, double claim).
|
|
156
159
|
- A filter shows one project. Each project shows whether its coordinator is active, from its last inbox read.
|
|
157
160
|
- **Answer** a question from its line in Waiting for you (an option of the question fills the answer in). **Ready to launch** lists the frontier with a Launch button and a profile picker, the routed profile preselected. Neither reaches a worker: each becomes a request in that project's coordinator inbox, signed with the signed-in person's name and address (with accounts) or with the name the viewer gives (under the shared password; remembered in a cookie, default `ARMADA_DASHBOARD_AUTHOR`), and shows as pending until the coordinator carries it out. The dashboard holds no runtime credential.
|
|
158
|
-
- It stays live without a reload. Linear and GitHub
|
|
159
|
-
-
|
|
161
|
+
- It stays live without a reload, and no page waits for Linear or GitHub. Each project's last reading of Linear and GitHub is kept in the app's Postgres database, and every page and poll reads only that database: the reading, plus the fleet's live data (events, claims, inboxes, coordinator activity), so a recorded report shows within seconds. A reading older than a minute (ten minutes for a project both [webhooks](#webhooks) reached within the last day) is served as is and refreshed in the background, reading only what changed in Linear since and the pull requests; Linear is read whole every 30 minutes at most, and only while someone looks. The top bar says how old the oldest reading on the page is, so a stale view never passes for a live one. A new project shows "reading Linear and GitHub for the first time" for a few seconds.
|
|
162
|
+
- The page polls every 5 s while work is in flight (a worker, a request waiting for the coordinator, a first reading), every 30 s when the fleet is quiet, and not at all while its tab is hidden. The server answers 304 while nothing changed. Answer, Approve and Launch show as sent on the click; a refusal puts the form back with the reason.
|
|
163
|
+
- When that database is unreachable, a banner says so and the view falls back to the last readings the server holds, refreshed from Linear and GitHub.
|
|
160
164
|
- The interface is in English or French (`ARMADA_DASHBOARD_LANGUAGE`, or the EN/FR switch).
|
|
161
165
|
|
|
162
166
|
Try it locally with synthetic data and no key:
|
|
@@ -181,7 +185,7 @@ ARMADA_AUTH_URL=http://localhost:4822 ARMADA_AUTH_OWNER_EMAILS=you@example.com b
|
|
|
181
185
|
- Root Directory: `packages/dashboard`, with files outside the root directory included (the default). The framework preset is Next.js, and Bun installs the workspace from `bun.lock`.
|
|
182
186
|
- Functions run in the region `packages/dashboard/vercel.json` names (`fra1`, Frankfurt): keep them next to the database, or change it to your database's region. Every poll makes a few database round trips, so the distance between the two is what the dashboard's speed depends on.
|
|
183
187
|
- The database: one Postgres database holds everything (accounts, organizations, the vault, the workers, the fleet's live data). [Neon](https://neon.com) works well: create a project in the region of the functions (`aws-eu-central-1` for `fra1`) and set its pooled connection string as `ARMADA_DATABASE_URL` (`DATABASE_URL`, which Neon's Vercel integration sets, is read too). A remote database is reached over verified TLS unless its URL says otherwise: a Postgres without TLS on a private network needs `?sslmode=disable`. The schema is applied on first use; `ARMADA_DATABASE_URL=<direct URL> bun run db migrate` (in `packages/dashboard`) applies it beforehand. Accounts are Better Auth run by the app on that database, not Neon's managed auth, which offers neither the device sign-in of `armada login` nor organization API keys, nor a way to keep sign-up by invitation only.
|
|
184
|
-
- Environment variables: `ARMADA_DATABASE_URL`, the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), the [GitHub App](#github-app)'s `ARMADA_GITHUB_APP_ID` and `ARMADA_GITHUB_APP_PRIVATE_KEY`, and `LINEAR_API_KEY`. With accounts and the vault (`ARMADA_SECRETS_KEY`, see [Keys kept in Armada](#keys-kept-in-armada)), `LINEAR_API_KEY` moves to the Keys page and is only a fallback here, for the deployment's first organization. `GITHUB_TOKEN` is read only without the GitHub App, or for a repository it cannot read. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while the database is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`), `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (
|
|
188
|
+
- Environment variables: `ARMADA_DATABASE_URL`, the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), the [GitHub App](#github-app)'s `ARMADA_GITHUB_APP_ID` and `ARMADA_GITHUB_APP_PRIVATE_KEY`, and `LINEAR_API_KEY`. With accounts and the vault (`ARMADA_SECRETS_KEY`, see [Keys kept in Armada](#keys-kept-in-armada)), `LINEAR_API_KEY` moves to the Keys page and is only a fallback here, for the deployment's first organization. `GITHUB_TOKEN` is read only without the GitHub App, or for a repository it cannot read. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while the database is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`), `ARMADA_LINEAR_WEBHOOK_SECRET` and `ARMADA_GITHUB_WEBHOOK_SECRET` (the [webhooks](#webhooks)), `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (how old a reading may get before a view refreshes it: default 60; a project both webhooks reached within the last day waits 10 minutes) and `ARMADA_DASHBOARD_AUTHOR` (the name requests are signed with until a viewer gives theirs). Never add a runtime token (Conductor or other): the coordinator carries out every request.
|
|
185
189
|
- The keys stay on the server; the browser only receives the fleet reading.
|
|
186
190
|
|
|
187
191
|
**Accounts.** People sign in with GitHub (or email and password where enabled) and belong to organizations, with the roles owner, admin and member. Accounts, sessions, organizations and invitations live in the app's database (`ARMADA_DATABASE_URL`), with the fleet's data; its schema is applied on first use. Accounts turn on only when every required variable below is set. With none of them set, the shared password applies, unchanged; with some but not all, the dashboard fails closed (503, naming the missing ones) rather than fall back to a password that shows every organization's projects.
|
|
@@ -245,7 +249,7 @@ Create the app once, under the GitHub organization that owns the projects (its S
|
|
|
245
249
|
| Expire user authorization tokens | on (the default): Armada refreshes them |
|
|
246
250
|
| Request user authorization (OAuth) during installation | off |
|
|
247
251
|
| Setup URL | `<ARMADA_AUTH_URL>/organization/github`, with Redirect on update: GitHub sends whoever clicks Install on GitHub in Armada back to the page, which links the installation in the same step |
|
|
248
|
-
| Webhook |
|
|
252
|
+
| Webhook | Active, URL `<ARMADA_AUTH_URL>/api/webhooks/github`, secret the value of `ARMADA_GITHUB_WEBHOOK_SECRET` (see [Webhooks](#webhooks)); subscribe to Pull request, Check suite, Check run and Status |
|
|
249
253
|
| Repository permissions | all **Read-only**: Actions, Checks, Commit statuses, Contents, Metadata, Pull requests. Nothing else, and no write access |
|
|
250
254
|
| Account permissions | Email addresses: **Read-only** (sign-in reads the verified address) |
|
|
251
255
|
| Where can this GitHub App be installed? | Only on this account; Any account if the projects live under several GitHub accounts |
|
|
@@ -270,6 +274,23 @@ Then:
|
|
|
270
274
|
- Without `ARMADA_GITHUB_APP_ID` and `ARMADA_GITHUB_APP_PRIVATE_KEY`, nothing changes: the dashboard reads GitHub with the Keys page's GitHub token or `GITHUB_TOKEN`. With the app, that token is only the fallback for a repository the app cannot read, and the Fleet view says why the app could not (not installed there, or not linked).
|
|
271
275
|
- Terminals do not change: `armada` reads GitHub with `GITHUB_TOKEN`, `GH_TOKEN` or `gh auth token`, and the coordinator merges with its own `gh`.
|
|
272
276
|
|
|
277
|
+
## Webhooks
|
|
278
|
+
|
|
279
|
+
Two webhooks bring a change in Linear or on a pull request to the dashboard within seconds; without them, a reading is refreshed when someone looks and it is older than a minute.
|
|
280
|
+
|
|
281
|
+
| Variable | What |
|
|
282
|
+
| --- | --- |
|
|
283
|
+
| `ARMADA_LINEAR_WEBHOOK_SECRET` | The signing secret Linear shows for the webhook below |
|
|
284
|
+
| `ARMADA_GITHUB_WEBHOOK_SECRET` | A random secret (`openssl rand -hex 32`), also pasted in the GitHub App's webhook settings |
|
|
285
|
+
|
|
286
|
+
1. **Linear:** Settings > API > Webhooks > New webhook, URL `<ARMADA_AUTH_URL>/api/webhooks/linear`, data change events Issues, Comments, Issue attachments and Issue labels, for all public teams (or the program's teams). Copy its signing secret into `ARMADA_LINEAR_WEBHOOK_SECRET`.
|
|
287
|
+
2. **GitHub:** on the [GitHub App](#github-app)'s settings, turn the webhook on with the URL `<ARMADA_AUTH_URL>/api/webhooks/github` and the secret of `ARMADA_GITHUB_WEBHOOK_SECRET`; under Permissions & events > Subscribe to events, tick Pull request, Check suite, Check run and Status.
|
|
288
|
+
3. Set both variables for Production (and Preview if it has its own database), and redeploy.
|
|
289
|
+
|
|
290
|
+
- Each delivery is checked (Linear's `Linear-Signature` and a timestamp within a minute; GitHub's `X-Hub-Signature-256`), marks the projects it concerns in one statement, and is answered at once; the refresh runs after the answer. A delivery only says which projects to read again: nothing in it is stored or shown, and the reading always comes from Linear and GitHub with the project's own keys.
|
|
291
|
+
- A Linear delivery concerns the projects whose reading holds its ticket (or the ticket's parent, for a new ticket); a GitHub delivery, the projects of its repository. A burst of deliveries (a CI run) makes one read every 10 s at most, not one each; a mark left by the burst waits for the next view or delivery, and stays until a reading that saw it is written, even if a refresh fails or is cut short. A label renamed in Linear asks every project for a whole read on its next view.
|
|
292
|
+
- Until a variable is set, its webhook answers 503 and the dashboard refreshes on view as before.
|
|
293
|
+
|
|
273
294
|
## Sign in from a terminal
|
|
274
295
|
|
|
275
296
|
The CLI knows who is acting, and for which organization, by signing in to Armada, the way `gh auth login` does:
|
|
@@ -344,6 +365,13 @@ local_commands = ["npm ci", "npm test"] # run by `armada merge` on a test merge
|
|
|
344
365
|
|
|
345
366
|
[policy]
|
|
346
367
|
silence_minutes = 15 # a worker with no report for longer is flagged silent (default 15)
|
|
368
|
+
coordinator_minutes = 10 # an inbox item open longer shows "waiting for the coordinator" (default 10)
|
|
369
|
+
plans = "approve" # or "pre-approved": workers post their plan and go on (default "approve")
|
|
370
|
+
pre_approved_label = "plan-approved" # a ticket with this label is pre-approved (default)
|
|
371
|
+
approval_label = "needs-plan-approval" # a ticket with this label waits for approval; wins over the other (default)
|
|
372
|
+
|
|
373
|
+
[brief]
|
|
374
|
+
extra = "docs/worker-conventions.md" # every brief ends with this file under "Project conventions" (default: none)
|
|
347
375
|
|
|
348
376
|
[conductor]
|
|
349
377
|
default_profile = "opus" # for tickets no routing rule matches (required with routing)
|
package/dist/armada.js
CHANGED
|
@@ -7,7 +7,7 @@ import { readFile as readFile3 } from "node:fs/promises";
|
|
|
7
7
|
import { isatty } from "node:tty";
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
|
-
import { dirname as
|
|
10
|
+
import { dirname as dirname6, join as join6, resolve } from "node:path";
|
|
11
11
|
|
|
12
12
|
// ../core/src/types.ts
|
|
13
13
|
var LABEL_PHASES = [
|
|
@@ -40,6 +40,7 @@ var LEGACY = { "handed-back": "ready-to-merge", "ci-fixing": "shipping" };
|
|
|
40
40
|
var firstLine = (body) => (body.split(`
|
|
41
41
|
`).find((l) => l.trim()) ?? "").replace(/[*_`]/g, "");
|
|
42
42
|
var COORDINATOR_RECORD = /^(?:answer|note)\s*:/i;
|
|
43
|
+
var PLAN_BLOCK = /^## Plan[ \t]*$/m;
|
|
43
44
|
function parseStatusLine(body) {
|
|
44
45
|
const m = firstLine(body).match(/^\s*Agent status\s*:\s*([a-z-]+)\s*(?:[—–-]+\s*(.*))?$/i);
|
|
45
46
|
if (!m?.[1])
|
|
@@ -49,7 +50,9 @@ function parseStatusLine(body) {
|
|
|
49
50
|
const summary = (m[2] ?? "").trim();
|
|
50
51
|
if (COORDINATOR_RECORD.test(summary))
|
|
51
52
|
return null;
|
|
52
|
-
|
|
53
|
+
if (!PHASES.includes(phase))
|
|
54
|
+
return null;
|
|
55
|
+
return PLAN_BLOCK.test(body) ? { phase, summary, plan: true } : { phase, summary };
|
|
53
56
|
}
|
|
54
57
|
var unescapeMarkdown = (line) => line.replace(/\\([!-/:-@[-`{-~])/g, "$1");
|
|
55
58
|
var trimMarks = (v) => {
|
|
@@ -220,6 +223,19 @@ function networkReason(err, timeoutMs) {
|
|
|
220
223
|
}
|
|
221
224
|
var chunks = (xs, n) => Array.from({ length: Math.ceil(xs.length / n) }, (_, k) => xs.slice(k * n, k * n + n));
|
|
222
225
|
var CLOSED = new Set(["completed", "canceled"]);
|
|
226
|
+
var isCandidate = (i, rootId) => i.id !== rootId && !CLOSED.has(i.statusType) && (i.agentPhase !== null || i.statusType === "started");
|
|
227
|
+
async function readComments(opts, issues, warnings) {
|
|
228
|
+
const comments = [];
|
|
229
|
+
for (const batch of chunks(issues.map((i) => i.uuid), COMMENT_BATCH)) {
|
|
230
|
+
const data = await gql(opts, COMMENTS_QUERY, { ids: batch });
|
|
231
|
+
for (const n of data.issues.nodes) {
|
|
232
|
+
await readRest(opts, n.identifier, MORE.comments, n.comments, warnings);
|
|
233
|
+
for (const c of n.comments.nodes)
|
|
234
|
+
comments.push(normalizeComment(c, n.identifier));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return comments;
|
|
238
|
+
}
|
|
223
239
|
async function fetchProgram(opts) {
|
|
224
240
|
try {
|
|
225
241
|
return await fetchTree(opts, true);
|
|
@@ -260,16 +276,7 @@ async function fetchTree(opts, delegate) {
|
|
|
260
276
|
for (const field of ["inverseRelations", "labels", "attachments"])
|
|
261
277
|
await readRest(opts, r.identifier, MORE[field], r[field], warnings);
|
|
262
278
|
const issues = all.map((r) => normalizeIssue(r, opts.labels));
|
|
263
|
-
const
|
|
264
|
-
const comments = [];
|
|
265
|
-
for (const batch of chunks(candidates.map((i) => i.uuid), COMMENT_BATCH)) {
|
|
266
|
-
const data = await gql(opts, COMMENTS_QUERY, { ids: batch });
|
|
267
|
-
for (const n of data.issues.nodes) {
|
|
268
|
-
await readRest(opts, n.identifier, MORE.comments, n.comments, warnings);
|
|
269
|
-
for (const c of n.comments.nodes)
|
|
270
|
-
comments.push(normalizeComment(c, n.identifier));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
279
|
+
const comments = await readComments(opts, issues.filter((i) => isCandidate(i, root.identifier)), warnings);
|
|
273
280
|
return {
|
|
274
281
|
rootId: root.identifier,
|
|
275
282
|
fetchedAt: (opts.now?.() ?? new Date).toISOString(),
|
|
@@ -303,6 +310,13 @@ async function readRest(opts, identifier, more, conn, warnings) {
|
|
|
303
310
|
}
|
|
304
311
|
}
|
|
305
312
|
}
|
|
313
|
+
var CHANGED_COMMENTS_QUERY = `
|
|
314
|
+
query ChangedComments($filter: CommentFilter, $after: String) {
|
|
315
|
+
comments(first: ${MORE_PAGE}, after: $after, filter: $filter) {
|
|
316
|
+
pageInfo { hasNextPage endCursor }
|
|
317
|
+
nodes { ${MORE.comments.nodes} issue { identifier } }
|
|
318
|
+
}
|
|
319
|
+
}`;
|
|
306
320
|
|
|
307
321
|
// ../core/src/armada-api.ts
|
|
308
322
|
var displayCode = (code) => code.length === 8 ? `${code.slice(0, 4)}-${code.slice(4)}` : code;
|
|
@@ -759,11 +773,12 @@ function buildLane(m, allComments, issue, opts) {
|
|
|
759
773
|
since,
|
|
760
774
|
lastUpdate,
|
|
761
775
|
lastReport,
|
|
762
|
-
statusLine: fresh?.message && phaseSource === "live" ? { summary: fresh.message, at: fresh.at, author: null, url: issue.url } : withStatus?.status ? {
|
|
776
|
+
statusLine: fresh?.message && phaseSource === "live" ? { summary: fresh.message, at: fresh.at, author: null, url: issue.url, plan: false } : withStatus?.status ? {
|
|
763
777
|
summary: withStatus.status.summary,
|
|
764
778
|
at: withStatus.createdAt,
|
|
765
779
|
author: withStatus.author,
|
|
766
|
-
url: commentUrl(issue, withStatus)
|
|
780
|
+
url: commentUrl(issue, withStatus),
|
|
781
|
+
plan: !!withStatus.status.plan
|
|
767
782
|
} : null,
|
|
768
783
|
pr,
|
|
769
784
|
openBlockers,
|
|
@@ -1787,6 +1802,7 @@ var HAS_WELLFORMED = !!"".isWellFormed;
|
|
|
1787
1802
|
|
|
1788
1803
|
// ../core/src/config.ts
|
|
1789
1804
|
var CONFIG_FILE = "armada.toml";
|
|
1805
|
+
var PLAN_POLICIES = ["approve", "pre-approved"];
|
|
1790
1806
|
var routingLabelKey = (name) => name.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]/gu, "");
|
|
1791
1807
|
var CONFIG_DEFAULTS = {
|
|
1792
1808
|
language: "en",
|
|
@@ -1795,7 +1811,10 @@ var CONFIG_DEFAULTS = {
|
|
|
1795
1811
|
runtimeGroup: "Agent runtime",
|
|
1796
1812
|
runtimes: ["Claude Code", "Codex", "Conductor"],
|
|
1797
1813
|
silentAfterMinutes: 15,
|
|
1798
|
-
coordinatorMinutes: 10
|
|
1814
|
+
coordinatorMinutes: 10,
|
|
1815
|
+
plans: "approve",
|
|
1816
|
+
preApprovedLabel: "plan-approved",
|
|
1817
|
+
approvalLabel: "needs-plan-approval"
|
|
1799
1818
|
};
|
|
1800
1819
|
|
|
1801
1820
|
class ConfigError extends Error {
|
|
@@ -1869,6 +1888,10 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1869
1888
|
if (!isTable(gates))
|
|
1870
1889
|
problems.push(`"gates" must be a table`);
|
|
1871
1890
|
const gatesT = isTable(gates) ? gates : {};
|
|
1891
|
+
const brief = raw.brief === undefined ? {} : raw.brief;
|
|
1892
|
+
if (!isTable(brief))
|
|
1893
|
+
problems.push(`"brief" must be a table`);
|
|
1894
|
+
const briefT = isTable(brief) ? brief : {};
|
|
1872
1895
|
const conductor = raw.conductor === undefined ? {} : raw.conductor;
|
|
1873
1896
|
if (!isTable(conductor))
|
|
1874
1897
|
problems.push(`"conductor" must be a table`);
|
|
@@ -1883,7 +1906,19 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1883
1906
|
["tracker.labels", labelsT, ["phase_group", "runtime_group", "runtimes"]],
|
|
1884
1907
|
["github", github, ["repository"]],
|
|
1885
1908
|
["gates", gatesT, ["required_checks", "local_commands"]],
|
|
1886
|
-
[
|
|
1909
|
+
[
|
|
1910
|
+
"policy",
|
|
1911
|
+
policyT,
|
|
1912
|
+
[
|
|
1913
|
+
"silence_minutes",
|
|
1914
|
+
"silent_after_minutes",
|
|
1915
|
+
"coordinator_minutes",
|
|
1916
|
+
"plans",
|
|
1917
|
+
"pre_approved_label",
|
|
1918
|
+
"approval_label"
|
|
1919
|
+
]
|
|
1920
|
+
],
|
|
1921
|
+
["brief", briefT, ["extra"]],
|
|
1887
1922
|
["conductor", conductorT, ["default_profile", "profiles", "routing"]]
|
|
1888
1923
|
];
|
|
1889
1924
|
const profiles = {};
|
|
@@ -1968,6 +2003,26 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1968
2003
|
else
|
|
1969
2004
|
problems.push(`"policy.coordinator_minutes" must be a positive number`);
|
|
1970
2005
|
}
|
|
2006
|
+
let plans = CONFIG_DEFAULTS.plans;
|
|
2007
|
+
if (policyT.plans !== undefined) {
|
|
2008
|
+
const v = policyT.plans;
|
|
2009
|
+
if (typeof v === "string" && PLAN_POLICIES.includes(v.trim()))
|
|
2010
|
+
plans = v.trim();
|
|
2011
|
+
else
|
|
2012
|
+
problems.push(`"policy.plans" must be ${PLAN_POLICIES.map((p) => `"${p}"`).join(" or ")}`);
|
|
2013
|
+
}
|
|
2014
|
+
const preApprovedLabel = str(policyT, "policy", "pre_approved_label", { default: CONFIG_DEFAULTS.preApprovedLabel });
|
|
2015
|
+
const approvalLabel = str(policyT, "policy", "approval_label", { default: CONFIG_DEFAULTS.approvalLabel });
|
|
2016
|
+
if (preApprovedLabel && approvalLabel && routingLabelKey(preApprovedLabel) === routingLabelKey(approvalLabel))
|
|
2017
|
+
problems.push(`"policy.pre_approved_label" and "policy.approval_label" must name different labels`);
|
|
2018
|
+
let extra = null;
|
|
2019
|
+
if (briefT.extra !== undefined) {
|
|
2020
|
+
const v = str(briefT, "brief", "extra");
|
|
2021
|
+
if (v && (v.startsWith("/") || v.split(/[\\/]/).includes("..")))
|
|
2022
|
+
problems.push(`"brief.extra" is "${v}", expected a path inside the repository, relative to ${CONFIG_FILE}`);
|
|
2023
|
+
else if (v)
|
|
2024
|
+
extra = v;
|
|
2025
|
+
}
|
|
1971
2026
|
let requiredChecks = [];
|
|
1972
2027
|
if (gatesT.required_checks !== undefined) {
|
|
1973
2028
|
const v = gatesT.required_checks;
|
|
@@ -2006,7 +2061,8 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
2006
2061
|
repository: str(github, "github", "repository", { pattern: REPOSITORY, hint: "owner/name" })
|
|
2007
2062
|
},
|
|
2008
2063
|
gates: { requiredChecks, localCommands },
|
|
2009
|
-
policy: { silentAfterMinutes, coordinatorMinutes },
|
|
2064
|
+
policy: { silentAfterMinutes, coordinatorMinutes, plans, preApprovedLabel, approvalLabel },
|
|
2065
|
+
brief: { extra },
|
|
2010
2066
|
conductor: { defaultProfile, profiles, routing }
|
|
2011
2067
|
};
|
|
2012
2068
|
if (problems.length)
|
|
@@ -2042,6 +2098,12 @@ repository = ${q(p.repository)}
|
|
|
2042
2098
|
[policy]
|
|
2043
2099
|
silence_minutes = 15 # a worker with no report for longer than this shows as silent
|
|
2044
2100
|
coordinator_minutes = 10 # an inbox item open longer than this shows "waiting for the coordinator"
|
|
2101
|
+
# plans = "approve" # or "pre-approved": workers post their plan and go on without waiting
|
|
2102
|
+
# pre_approved_label = "plan-approved" # a ticket with this label skips the approval
|
|
2103
|
+
# approval_label = "needs-plan-approval" # a ticket with this label waits for it; wins over the other
|
|
2104
|
+
|
|
2105
|
+
[brief]
|
|
2106
|
+
# extra = "docs/worker-conventions.md" # a file every worker brief carries under "Project conventions"
|
|
2045
2107
|
|
|
2046
2108
|
# How \`armada brief\` launches workers on Conductor. Every value is passed explicitly;
|
|
2047
2109
|
# \`conductor model\` lists each agent's model ids and effort levels.
|
|
@@ -2082,6 +2144,80 @@ function slugify(name) {
|
|
|
2082
2144
|
return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "project";
|
|
2083
2145
|
}
|
|
2084
2146
|
|
|
2147
|
+
// ../core/src/phases.ts
|
|
2148
|
+
var TRANSITIONS = {
|
|
2149
|
+
planning: ["awaiting-approval", "implementing"],
|
|
2150
|
+
"awaiting-approval": ["planning", "implementing"],
|
|
2151
|
+
implementing: ["shipping"],
|
|
2152
|
+
shipping: ["implementing", "ready-to-merge"],
|
|
2153
|
+
"ready-to-merge": ["shipping"],
|
|
2154
|
+
blocked: ["planning", "awaiting-approval", "implementing", "shipping", "ready-to-merge"]
|
|
2155
|
+
};
|
|
2156
|
+
var isLabelPhase = (v) => LABEL_PHASES.includes(v);
|
|
2157
|
+
function transitionProblem(from, to) {
|
|
2158
|
+
if (from === null)
|
|
2159
|
+
return "the ticket has no agent phase: no worker has claimed it";
|
|
2160
|
+
if (from === to || to === "blocked" || TRANSITIONS[from].includes(to))
|
|
2161
|
+
return null;
|
|
2162
|
+
const allowed = [...TRANSITIONS[from], "blocked", `${from} (status update)`].join(", ");
|
|
2163
|
+
return `cannot go from ${from} to ${to}; from ${from} a worker may report: ${allowed}`;
|
|
2164
|
+
}
|
|
2165
|
+
function planRule(config, labels) {
|
|
2166
|
+
const { plans, preApprovedLabel, approvalLabel } = config.policy;
|
|
2167
|
+
const has = (name) => labels.some((l) => routingLabelKey(l) === routingLabelKey(name));
|
|
2168
|
+
if (has(approvalLabel))
|
|
2169
|
+
return { rule: "approve", why: `the ticket's label ${approvalLabel}` };
|
|
2170
|
+
if (has(preApprovedLabel))
|
|
2171
|
+
return { rule: "pre-approved", why: `the ticket's label ${preApprovedLabel}` };
|
|
2172
|
+
return { rule: plans, why: `armada.toml [policy] plans = "${plans}"` };
|
|
2173
|
+
}
|
|
2174
|
+
var FULL_SHA = /^[0-9a-f]{40}$/;
|
|
2175
|
+
function handBackProblems({ pr, repository, sha, requiredChecks }) {
|
|
2176
|
+
const problems = [];
|
|
2177
|
+
if (!sha)
|
|
2178
|
+
problems.push("--sha is required: the full 40-character head SHA of the pull request");
|
|
2179
|
+
else if (!FULL_SHA.test(sha))
|
|
2180
|
+
problems.push(`--sha must be the full 40-character commit SHA, got "${sha}" (${sha.length} characters)`);
|
|
2181
|
+
if (!pr) {
|
|
2182
|
+
problems.push("no pull request is linked to the ticket; pass --pr <number or URL>");
|
|
2183
|
+
return problems;
|
|
2184
|
+
}
|
|
2185
|
+
if (pr.repo.toLowerCase() !== repository.toLowerCase())
|
|
2186
|
+
problems.push(`pull request #${pr.number} is in ${pr.repo}, not in the project repository ${repository}`);
|
|
2187
|
+
if (pr.state && pr.state !== "open")
|
|
2188
|
+
problems.push(`pull request #${pr.number} is ${pr.state}, not open`);
|
|
2189
|
+
if (pr.draft)
|
|
2190
|
+
problems.push(`pull request #${pr.number} is a draft; mark it ready for review`);
|
|
2191
|
+
if (pr.mergeable === "CONFLICTING")
|
|
2192
|
+
problems.push(`pull request #${pr.number} conflicts with its base; rebase it`);
|
|
2193
|
+
if (!pr.headSha)
|
|
2194
|
+
problems.push(`the head of pull request #${pr.number} could not be read from GitHub`);
|
|
2195
|
+
else if (sha && FULL_SHA.test(sha) && pr.headSha !== sha)
|
|
2196
|
+
problems.push(`${sha} is not the head of pull request #${pr.number} (head is ${pr.headSha}); push, then report`);
|
|
2197
|
+
problems.push(...checkProblems(pr.checks ?? [], requiredChecks));
|
|
2198
|
+
return problems;
|
|
2199
|
+
}
|
|
2200
|
+
function checkProblems(checks, requiredChecks) {
|
|
2201
|
+
const problems = [];
|
|
2202
|
+
if (requiredChecks.length) {
|
|
2203
|
+
for (const name of requiredChecks) {
|
|
2204
|
+
const runs = checks.filter((c) => c.name === name);
|
|
2205
|
+
const bad = runs.find((c) => c.state !== "success");
|
|
2206
|
+
if (!runs.length)
|
|
2207
|
+
problems.push(`required check "${name}" has not reported on the head yet`);
|
|
2208
|
+
else if (bad)
|
|
2209
|
+
problems.push(`required check "${name}" is ${bad.state}`);
|
|
2210
|
+
}
|
|
2211
|
+
} else if (!checks.length) {
|
|
2212
|
+
problems.push("no CI check has reported on the head yet (or set [gates] required_checks in armada.toml)");
|
|
2213
|
+
} else {
|
|
2214
|
+
for (const c of checks)
|
|
2215
|
+
if (c.state !== "success")
|
|
2216
|
+
problems.push(`check "${c.name}" is ${c.state}`);
|
|
2217
|
+
}
|
|
2218
|
+
return problems;
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2085
2221
|
// ../core/src/routing.ts
|
|
2086
2222
|
class ProfileError extends Error {
|
|
2087
2223
|
name = "ProfileError";
|
|
@@ -2151,71 +2287,6 @@ function chooseProfile(config, input) {
|
|
|
2151
2287
|
return { name, profile, source: "requested", rule: null, routed: route?.name ?? null, reason, why };
|
|
2152
2288
|
}
|
|
2153
2289
|
|
|
2154
|
-
// ../core/src/phases.ts
|
|
2155
|
-
var TRANSITIONS = {
|
|
2156
|
-
planning: ["awaiting-approval", "implementing"],
|
|
2157
|
-
"awaiting-approval": ["planning", "implementing"],
|
|
2158
|
-
implementing: ["shipping"],
|
|
2159
|
-
shipping: ["implementing", "ready-to-merge"],
|
|
2160
|
-
"ready-to-merge": ["shipping"],
|
|
2161
|
-
blocked: ["planning", "awaiting-approval", "implementing", "shipping", "ready-to-merge"]
|
|
2162
|
-
};
|
|
2163
|
-
var isLabelPhase = (v) => LABEL_PHASES.includes(v);
|
|
2164
|
-
function transitionProblem(from, to) {
|
|
2165
|
-
if (from === null)
|
|
2166
|
-
return "the ticket has no agent phase: no worker has claimed it";
|
|
2167
|
-
if (from === to || to === "blocked" || TRANSITIONS[from].includes(to))
|
|
2168
|
-
return null;
|
|
2169
|
-
const allowed = [...TRANSITIONS[from], "blocked", `${from} (status update)`].join(", ");
|
|
2170
|
-
return `cannot go from ${from} to ${to}; from ${from} a worker may report: ${allowed}`;
|
|
2171
|
-
}
|
|
2172
|
-
var FULL_SHA = /^[0-9a-f]{40}$/;
|
|
2173
|
-
function handBackProblems({ pr, repository, sha, requiredChecks }) {
|
|
2174
|
-
const problems = [];
|
|
2175
|
-
if (!sha)
|
|
2176
|
-
problems.push("--sha is required: the full 40-character head SHA of the pull request");
|
|
2177
|
-
else if (!FULL_SHA.test(sha))
|
|
2178
|
-
problems.push(`--sha must be the full 40-character commit SHA, got "${sha}" (${sha.length} characters)`);
|
|
2179
|
-
if (!pr) {
|
|
2180
|
-
problems.push("no pull request is linked to the ticket; pass --pr <number or URL>");
|
|
2181
|
-
return problems;
|
|
2182
|
-
}
|
|
2183
|
-
if (pr.repo.toLowerCase() !== repository.toLowerCase())
|
|
2184
|
-
problems.push(`pull request #${pr.number} is in ${pr.repo}, not in the project repository ${repository}`);
|
|
2185
|
-
if (pr.state && pr.state !== "open")
|
|
2186
|
-
problems.push(`pull request #${pr.number} is ${pr.state}, not open`);
|
|
2187
|
-
if (pr.draft)
|
|
2188
|
-
problems.push(`pull request #${pr.number} is a draft; mark it ready for review`);
|
|
2189
|
-
if (pr.mergeable === "CONFLICTING")
|
|
2190
|
-
problems.push(`pull request #${pr.number} conflicts with its base; rebase it`);
|
|
2191
|
-
if (!pr.headSha)
|
|
2192
|
-
problems.push(`the head of pull request #${pr.number} could not be read from GitHub`);
|
|
2193
|
-
else if (sha && FULL_SHA.test(sha) && pr.headSha !== sha)
|
|
2194
|
-
problems.push(`${sha} is not the head of pull request #${pr.number} (head is ${pr.headSha}); push, then report`);
|
|
2195
|
-
problems.push(...checkProblems(pr.checks ?? [], requiredChecks));
|
|
2196
|
-
return problems;
|
|
2197
|
-
}
|
|
2198
|
-
function checkProblems(checks, requiredChecks) {
|
|
2199
|
-
const problems = [];
|
|
2200
|
-
if (requiredChecks.length) {
|
|
2201
|
-
for (const name of requiredChecks) {
|
|
2202
|
-
const runs = checks.filter((c) => c.name === name);
|
|
2203
|
-
const bad = runs.find((c) => c.state !== "success");
|
|
2204
|
-
if (!runs.length)
|
|
2205
|
-
problems.push(`required check "${name}" has not reported on the head yet`);
|
|
2206
|
-
else if (bad)
|
|
2207
|
-
problems.push(`required check "${name}" is ${bad.state}`);
|
|
2208
|
-
}
|
|
2209
|
-
} else if (!checks.length) {
|
|
2210
|
-
problems.push("no CI check has reported on the head yet (or set [gates] required_checks in armada.toml)");
|
|
2211
|
-
} else {
|
|
2212
|
-
for (const c of checks)
|
|
2213
|
-
if (c.state !== "success")
|
|
2214
|
-
problems.push(`check "${c.name}" is ${c.state}`);
|
|
2215
|
-
}
|
|
2216
|
-
return problems;
|
|
2217
|
-
}
|
|
2218
|
-
|
|
2219
2290
|
// ../core/src/worker.ts
|
|
2220
2291
|
class Refusal extends Error {
|
|
2221
2292
|
next;
|
|
@@ -2412,6 +2483,14 @@ ${claimLine({ runtime: runtime.name, handle: input.handle, branch, started, prof
|
|
|
2412
2483
|
const state = await readBack(ctx, ticket.id, warnings);
|
|
2413
2484
|
return { ticket: ticket.id, url: ticket.url, lines, warnings, inbox: null, state };
|
|
2414
2485
|
}
|
|
2486
|
+
var PLAN_HEADING = "## Plan";
|
|
2487
|
+
var SUMMARY_MAX = 100;
|
|
2488
|
+
function planSummary(plan) {
|
|
2489
|
+
const lines = plan.split(`
|
|
2490
|
+
`).map((l) => l.replace(/^\s*(?:#+|>|[-*+]|\d+[.)])\s*/, "").replace(/[*_`]/g, "").trim()).filter((l) => l && !/^plan\s*:?$/i.test(l));
|
|
2491
|
+
const first = lines[0] ?? "plan posted";
|
|
2492
|
+
return first.length > SUMMARY_MAX ? `${first.slice(0, SUMMARY_MAX - 1).trimEnd()}…` : first;
|
|
2493
|
+
}
|
|
2415
2494
|
function resolvePr(ticket, repository, pr) {
|
|
2416
2495
|
if (pr) {
|
|
2417
2496
|
const trimmed = pr.trim().replace(/^#/, "");
|
|
@@ -2436,6 +2515,7 @@ async function reportPhase(ctx, input) {
|
|
|
2436
2515
|
throw new Refusal(`${ticket.id}: ${problem}`, ticket.agentPhase ? `armada report <one of the phases above> --ticket ${ticket.id} --message "<what you did>"` : `armada claim ${ticket.id} --runtime <name> --handle <id>`);
|
|
2437
2516
|
const warnings = [...ticket.warnings];
|
|
2438
2517
|
const message = input.message?.trim() ?? "";
|
|
2518
|
+
const plan = input.plan?.trim() ?? "";
|
|
2439
2519
|
let pr = resolvePr(ticket, config.github.repository, input.pr);
|
|
2440
2520
|
const sha = input.sha?.trim().toLowerCase() || null;
|
|
2441
2521
|
let summary;
|
|
@@ -2463,14 +2543,20 @@ ${problems.map((p) => ` - ${p}`).join(`
|
|
|
2463
2543
|
summary = `PR #${pr?.number}, head ${sha}, CI green`;
|
|
2464
2544
|
body = message;
|
|
2465
2545
|
} else {
|
|
2466
|
-
if (!message)
|
|
2546
|
+
if (!message && !plan)
|
|
2467
2547
|
throw new Refusal("--message is required: say what you did or what you are doing", `armada report ${input.phase} --ticket ${ticket.id} --message "<what you did>"`);
|
|
2468
2548
|
const [first = "", ...rest] = message.split(`
|
|
2469
2549
|
`);
|
|
2470
|
-
summary = first.trim();
|
|
2550
|
+
summary = message ? first.trim() : planSummary(plan);
|
|
2471
2551
|
body = rest.join(`
|
|
2472
2552
|
`).trim();
|
|
2473
2553
|
}
|
|
2554
|
+
if (plan)
|
|
2555
|
+
body = [body, `${PLAN_HEADING}
|
|
2556
|
+
|
|
2557
|
+
${plan}`].filter(Boolean).join(`
|
|
2558
|
+
|
|
2559
|
+
`);
|
|
2474
2560
|
const target = ticket.agentPhase === input.phase ? null : findLabel(await linear.groupLabels(groups.phaseGroup, ticket.teamId), input.phase, groups.phaseGroup);
|
|
2475
2561
|
if (pr && input.pr && !ticket.prs.some((p) => p.url === pr?.url)) {
|
|
2476
2562
|
await linear.linkUrl(ticket.uuid, pr.url, pr.title || `Pull request #${pr.number}`);
|
|
@@ -2493,7 +2579,9 @@ ${body}` : statusLine);
|
|
|
2493
2579
|
phase: input.phase,
|
|
2494
2580
|
previous: ticket.agentPhase,
|
|
2495
2581
|
summary,
|
|
2496
|
-
message,
|
|
2582
|
+
message: plan ? [summary, body].join(`
|
|
2583
|
+
|
|
2584
|
+
`) : message,
|
|
2497
2585
|
prUrl: pr?.url ?? null,
|
|
2498
2586
|
headSha: sha
|
|
2499
2587
|
}));
|
|
@@ -2669,6 +2757,11 @@ function buildBrief(input) {
|
|
|
2669
2757
|
purpose: "the ticket this worker owns"
|
|
2670
2758
|
}
|
|
2671
2759
|
];
|
|
2760
|
+
const extra = input.conventions ?? null;
|
|
2761
|
+
if (extra && extra.text === null)
|
|
2762
|
+
warnings.push(`[brief] extra names ${extra.path}, which could not be read; the brief has no project conventions`);
|
|
2763
|
+
else if (extra && !extra.text?.trim())
|
|
2764
|
+
warnings.push(`[brief] extra names ${extra.path}, which is empty`);
|
|
2672
2765
|
const brief = {
|
|
2673
2766
|
ticket: {
|
|
2674
2767
|
id: ticket.id,
|
|
@@ -2695,6 +2788,8 @@ function buildBrief(input) {
|
|
|
2695
2788
|
blockers: ticket.blockers.map(({ notes, ...b }) => ({ ...b, handBack: handBackNote(notes) })),
|
|
2696
2789
|
notes: ticket.notes.slice(0, MAX_NOTES),
|
|
2697
2790
|
parallel,
|
|
2791
|
+
plans: planRule(config, ticket.labels),
|
|
2792
|
+
conventions: extra?.text?.trim() ? { path: extra.path, text: extra.text } : null,
|
|
2698
2793
|
warnings
|
|
2699
2794
|
};
|
|
2700
2795
|
if (ticket.notes.length > MAX_NOTES)
|
|
@@ -2752,6 +2847,7 @@ ${quote(x.handBack.body)}` : "No hand-back note.", "");
|
|
|
2752
2847
|
for (const n of b.notes)
|
|
2753
2848
|
out.push(`### ${byLine(n)}`, "", quote(n.body), "");
|
|
2754
2849
|
}
|
|
2850
|
+
out.push("## Plan", "", b.plans.rule === "pre-approved" ? `Plans are pre-approved for ${t.id} (${b.plans.why}): post your plan with \`armada report implementing --plan-file -\` and go on.` : `Plans need the coordinator's approval for ${t.id} (${b.plans.why}): post your plan with \`armada report awaiting-approval --plan-file -\` and wait for approval.`, "");
|
|
2755
2851
|
out.push("## Workers in flight", "");
|
|
2756
2852
|
if (b.parallel.length) {
|
|
2757
2853
|
out.push("Stay out of their areas. If you must change the same files, say so in a report before you do.", "");
|
|
@@ -2760,6 +2856,8 @@ ${quote(x.handBack.body)}` : "No hand-back note.", "");
|
|
|
2760
2856
|
} else
|
|
2761
2857
|
out.push("None.");
|
|
2762
2858
|
out.push("", "## Environment", "", b.launch ? `No key is needed in this workspace: once signed in, Armada hands each command the keys it needs, for ${t.id} only. If a command says this worker was cut off from Armada, stop and say so in your reply. Never print, commit or log a token or a key.` : `The coordinator set ${b.environment.map((v) => `\`${v.name}\``).join(", ")} in this workspace. Never print, commit or log their values.`);
|
|
2859
|
+
if (b.conventions)
|
|
2860
|
+
out.push("", "## Project conventions", "", b.conventions.text.trim());
|
|
2763
2861
|
return `${out.join(`
|
|
2764
2862
|
`)}
|
|
2765
2863
|
`;
|
|
@@ -2797,6 +2895,7 @@ async function loadBrief(config, opts) {
|
|
|
2797
2895
|
...opts.stored ? { stored: opts.stored } : {},
|
|
2798
2896
|
launch: made,
|
|
2799
2897
|
noLaunch: missed?.reason ?? null,
|
|
2898
|
+
conventions: opts.conventions ?? null,
|
|
2800
2899
|
now: now()
|
|
2801
2900
|
});
|
|
2802
2901
|
}
|
|
@@ -4511,7 +4610,7 @@ A coordinator may start cold, on a laptop or in a fresh cloud session, with noth
|
|
|
4511
4610
|
5. **Launch ready tickets** that do not collide with work in flight, one at a time:
|
|
4512
4611
|
- pick the ticket from the frontier in \`armada status\`;
|
|
4513
4612
|
- run \`armada brief <ticket>\` and resolve its warnings. The profile (agent, model, effort) is routed from the ticket's labels by \`[[conductor.routing]]\` in \`armada.toml\`, else \`default_profile\`, and the brief says which rule chose it. Follow it. Override it only when the ticket's labels mislead (for example a \`web\` ticket that is really a tricky back-end bug): \`armada brief <ticket> --profile <name> --reason "<why>"\`. The reason lands in the worker's claim comment;
|
|
4514
|
-
- 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;
|
|
4613
|
+
- 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. The brief already says whether the plan needs approval (\`[policy] plans\`, or the ticket's label) and ends with the project's conventions (\`[brief] extra\`): put a note every worker needs in that file, not in each prompt;
|
|
4515
4614
|
- launch it with the runtime guide's *launch* section, passing the profile's values. When the brief's \`Launch:\` line says the prompt carries a one-time token, pass no key: the worker signs in with it. When it says there is none, fix the reason (usually your sign-in) and brief again, rather than pass keys; the token works once, within the hour, so brief right before the launch;
|
|
4516
4615
|
- 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.
|
|
4517
4616
|
6. **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. When the repository's rules (\`AGENTS.md\`) ask you to ship each merge through its release pull request (release-please's \`chore(main): release …\`), merge that one next, as "The release pull request" in [MERGE.md](MERGE.md) describes.
|
|
@@ -4563,7 +4662,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
|
|
|
4563
4662
|
|
|
4564
4663
|
1. **Claim** with the exact commands 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\`. When the brief has an \`armada login --launch-token <token>\` line, run it once, right after the install and before the claim: it signs your workspace in to Armada for your ticket only, and Armada then gives your \`claim\`, \`report\`, \`ask\` and \`release\` their keys, so none is needed in your environment (do not ask for one; \`armada whoami\` shows the sign-in). The token works once, within the hour; never copy it anywhere else. If it is refused, or a later command says you were cut off from Armada, stop and say so in your reply: the coordinator decides whether you get a new one. The claim 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.
|
|
4565
4664
|
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.
|
|
4566
|
-
3. **Plan.** Write the plan: what changes, how it is tested, and the checks a person could observe when it is done.
|
|
4665
|
+
3. **Plan.** Write the plan: what changes, how it is tested, and the checks a person could observe when it is done. Your brief's "Plan" section says in one line whether it needs approval (from \`[policy] plans\` in \`armada.toml\`, or a label on the ticket); follow that line, do not guess. Pre-approved: post the plan with \`armada report implementing --plan-file -\` (or \`--plan-file <path>\`) and go on; do not enter \`awaiting-approval\`. Otherwise post it with \`armada report awaiting-approval --plan-file -\`: it creates a \`plan\` item in the coordinator's inbox. \`--plan-file\` posts the plan as its own block, under a one-line status (\`--message\` sets that line, else the plan's first line). Push your branch and wait for the coordinator's decision in your session. On approval, report \`implementing\`; on amendments, report \`planning\`, revise the plan and submit it for approval again.
|
|
4567
4666
|
4. **Implement** test-first. A material change to the approved plan needs a new approval.
|
|
4568
4667
|
5. **Ship.** \`armada report shipping --pr <number>\`. Use the \`ship-pr-dev\` skill when the repository has it; otherwise run the repository's local checks, open the pull request with a Commitizen title (\`feat(scope): …\`), link it on the ticket, and fix CI until every required check is green.
|
|
4569
4668
|
6. **Rebase** on the latest default branch right before hand-back, and get CI green on that final head.
|
|
@@ -4661,6 +4760,9 @@ async function checkRepository(view, armadaVersion) {
|
|
|
4661
4760
|
try {
|
|
4662
4761
|
const config = parseConfig(configText, CONFIG_FILE);
|
|
4663
4762
|
checks.push(ok("config", `${CONFIG_FILE} is valid (project ${config.project.slug})`));
|
|
4763
|
+
const extra = config.brief.extra;
|
|
4764
|
+
if (extra)
|
|
4765
|
+
checks.push(await view.readFile(extra) === null ? bad("brief-extra", "warning", `[brief] extra names ${extra}, which is missing: briefs go out without the project conventions`, `add ${extra}, or fix the path in ${CONFIG_FILE}`) : ok("brief-extra", `${extra} goes into every brief as the project conventions`));
|
|
4664
4766
|
} catch (err) {
|
|
4665
4767
|
if (!(err instanceof ConfigError))
|
|
4666
4768
|
throw err;
|
|
@@ -4949,7 +5051,7 @@ function buildStatus({
|
|
|
4949
5051
|
lastUpdate: l.lastUpdate,
|
|
4950
5052
|
lastReport: l.lastReport,
|
|
4951
5053
|
silent: l.flags.includes("silent"),
|
|
4952
|
-
statusLine: l.statusLine ? { summary: l.statusLine.summary, at: l.statusLine.at, url: l.statusLine.url } : null,
|
|
5054
|
+
statusLine: l.statusLine ? { summary: l.statusLine.summary, at: l.statusLine.at, url: l.statusLine.url, plan: l.statusLine.plan } : null,
|
|
4953
5055
|
pr: l.pr ? prRef(l.pr) : null,
|
|
4954
5056
|
openBlockers: l.openBlockers,
|
|
4955
5057
|
flags: l.flags
|
|
@@ -4983,14 +5085,18 @@ async function readStatusSources(config, opts) {
|
|
|
4983
5085
|
...opts.fetch ? { fetch: opts.fetch } : {},
|
|
4984
5086
|
now
|
|
4985
5087
|
});
|
|
4986
|
-
const
|
|
5088
|
+
const [program, forge] = await Promise.all([programP, readForge(config, opts, now)]);
|
|
5089
|
+
return { program, ...forge };
|
|
5090
|
+
}
|
|
5091
|
+
function readForge(config, opts, now) {
|
|
5092
|
+
if (!opts.githubToken)
|
|
5093
|
+
return Promise.resolve({ forge: null, forgeError: "no GitHub token (set GITHUB_TOKEN or run gh auth login)" });
|
|
5094
|
+
return fetchForge({
|
|
4987
5095
|
token: opts.githubToken,
|
|
4988
5096
|
repository: config.github.repository,
|
|
4989
5097
|
...opts.fetch ? { fetch: opts.fetch } : {},
|
|
4990
5098
|
now
|
|
4991
|
-
}).then((forge) => ({ forge, forgeError: null }), (err) => ({ forge: null, forgeError: err instanceof Error ? err.message : String(err) }))
|
|
4992
|
-
const [program, forge] = await Promise.all([programP, forgeP]);
|
|
4993
|
-
return { program, ...forge };
|
|
5099
|
+
}).then((forge) => ({ forge, forgeError: null }), (err) => ({ forge: null, forgeError: err instanceof Error ? err.message : String(err) }));
|
|
4994
5100
|
}
|
|
4995
5101
|
async function loadStatus(config, opts) {
|
|
4996
5102
|
const now = opts.now ?? (() => new Date);
|
|
@@ -5009,7 +5115,7 @@ async function loadStatus(config, opts) {
|
|
|
5009
5115
|
});
|
|
5010
5116
|
}
|
|
5011
5117
|
// package.json
|
|
5012
|
-
var version = "0.2.
|
|
5118
|
+
var version = "0.2.4";
|
|
5013
5119
|
|
|
5014
5120
|
// src/io.ts
|
|
5015
5121
|
class UsageError extends Error {
|
|
@@ -5255,6 +5361,9 @@ async function authLogout(io) {
|
|
|
5255
5361
|
return 0;
|
|
5256
5362
|
}
|
|
5257
5363
|
|
|
5364
|
+
// src/brief.ts
|
|
5365
|
+
import { dirname as dirname3, join as join2 } from "node:path";
|
|
5366
|
+
|
|
5258
5367
|
// src/watch.ts
|
|
5259
5368
|
import { dirname as dirname2 } from "node:path";
|
|
5260
5369
|
|
|
@@ -5535,17 +5644,18 @@ function print(io, outcome, json) {
|
|
|
5535
5644
|
io.stderr(`armada: warning: ${w}
|
|
5536
5645
|
`);
|
|
5537
5646
|
}
|
|
5538
|
-
async function readMessage(io, options) {
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5647
|
+
async function readMessage(io, options, name = "message") {
|
|
5648
|
+
const fileOption = `${name}-file`;
|
|
5649
|
+
if (options[name] !== undefined && options[fileOption] !== undefined)
|
|
5650
|
+
throw new UsageError(`pass --${name} or --${fileOption}, not both`);
|
|
5651
|
+
const file = options[fileOption];
|
|
5542
5652
|
if (file === undefined)
|
|
5543
|
-
return options
|
|
5653
|
+
return options[name] ?? null;
|
|
5544
5654
|
const text = file === "-" ? await io.readStdin?.() ?? null : await io.readFile(file);
|
|
5545
5655
|
if (text === null)
|
|
5546
|
-
throw new UsageError(`cannot read the
|
|
5656
|
+
throw new UsageError(`cannot read the ${name} from ${file}`);
|
|
5547
5657
|
if (!text.trim())
|
|
5548
|
-
throw new UsageError(`${file === "-" ? "standard input" :
|
|
5658
|
+
throw new UsageError(`${file === "-" ? "standard input" : `${name} file ${file}`} is empty or whitespace-only`, `pass --${name} "<text>" or pipe a non-empty ${name} into --${fileOption} -`);
|
|
5549
5659
|
return text;
|
|
5550
5660
|
}
|
|
5551
5661
|
async function withContext(io, config, credentials, json, act) {
|
|
@@ -5590,14 +5700,18 @@ async function report(io, config, credentials, a) {
|
|
|
5590
5700
|
throw new UsageError(`report needs a phase: ${LABEL_PHASES.join(", ")}${phase ? ` (got "${phase}")` : ""}`);
|
|
5591
5701
|
if (extra.length)
|
|
5592
5702
|
throw new UsageError(`unexpected argument ${extra[0]}`);
|
|
5703
|
+
if (a.options["message-file"] === "-" && a.options["plan-file"] === "-")
|
|
5704
|
+
throw new UsageError("--message-file - and --plan-file - both read standard input; give one of them a file");
|
|
5593
5705
|
const message = await readMessage(io, a.options);
|
|
5594
|
-
|
|
5595
|
-
|
|
5706
|
+
const plan = await readMessage(io, a.options, "plan");
|
|
5707
|
+
if (!message?.trim() && !plan?.trim() && phase !== "ready-to-merge")
|
|
5708
|
+
throw new UsageError("--message is required: what you did or what you are doing (first line = summary), or --plan-file with your plan");
|
|
5596
5709
|
const ticket = currentTicket(io, config, a.options.ticket, credentials.workerTickets);
|
|
5597
5710
|
return withContext(io, config, credentials, a.json, (ctx) => reportPhase(ctx, {
|
|
5598
5711
|
ticket,
|
|
5599
5712
|
phase,
|
|
5600
5713
|
message,
|
|
5714
|
+
plan,
|
|
5601
5715
|
pr: a.options.pr ?? null,
|
|
5602
5716
|
sha: a.options.sha ?? null
|
|
5603
5717
|
}));
|
|
@@ -5879,6 +5993,8 @@ function renderBrief(b) {
|
|
|
5879
5993
|
`Runtime: conductor (follow the armada-runtime-conductor skill to launch)`,
|
|
5880
5994
|
`Profile: ${p ? `${p.name}: agent ${p.agent}, model ${p.model}, effort ${p.effort}${p.fastMode ? ", fast mode" : ""}` : "none declared in armada.toml"}`,
|
|
5881
5995
|
...b.routing ? [`Chosen by: ${b.routing.why}`] : [],
|
|
5996
|
+
`Plans: ${b.plans.rule === "pre-approved" ? "pre-approved" : "wait for approval"} (${b.plans.why})`,
|
|
5997
|
+
...b.conventions ? [`Conventions: ${b.conventions.path} (under "Project conventions" in the prompt)`] : [],
|
|
5882
5998
|
`Repository: ${b.repository.url}`,
|
|
5883
5999
|
`Branch: ${b.ticket.branch ?? "none suggested by Linear"} (the worker renames its workspace branch to it)`,
|
|
5884
6000
|
`Launch: ${b.launch ? `one-time token in the prompt, valid until ${b.launch.expiresAt.slice(0, 16).replace("T", " ")} UTC: the worker needs no key` : `no launch token${b.noLaunch ? ` (${b.noLaunch})` : ""}: pass the keys below in the worker's environment`}`,
|
|
@@ -5919,7 +6035,7 @@ function launcher(io, config, credentials) {
|
|
|
5919
6035
|
}
|
|
5920
6036
|
};
|
|
5921
6037
|
}
|
|
5922
|
-
async function brief2(io, config, credentials, a, version) {
|
|
6038
|
+
async function brief2(io, config, credentials, a, version, configPath) {
|
|
5923
6039
|
const [ticket, ...extra] = a.rest;
|
|
5924
6040
|
if (!ticket)
|
|
5925
6041
|
throw new UsageError('brief needs a ticket: armada brief <ticket> [--profile <name> [--reason "<why>"]]');
|
|
@@ -5941,6 +6057,8 @@ async function brief2(io, config, credentials, a, version) {
|
|
|
5941
6057
|
}
|
|
5942
6058
|
if (!credentials.linearApiKey)
|
|
5943
6059
|
throw missingKey(LINEAR_KEY);
|
|
6060
|
+
const extraPath = config.brief.extra;
|
|
6061
|
+
const conventions = extraPath ? { path: extraPath, text: await io.readFile(join2(dirname3(configPath), extraPath)).catch(() => null) } : null;
|
|
5944
6062
|
let b;
|
|
5945
6063
|
try {
|
|
5946
6064
|
b = await loadBrief(config, {
|
|
@@ -5952,6 +6070,7 @@ async function brief2(io, config, credentials, a, version) {
|
|
|
5952
6070
|
env: io.env,
|
|
5953
6071
|
stored: STORED_KEYS.filter((k) => credentials.sources[k.name]?.kind === "store").map((k) => k.variable),
|
|
5954
6072
|
launch: launcher(io, config, credentials),
|
|
6073
|
+
conventions,
|
|
5955
6074
|
...io.fetch ? { fetch: io.fetch } : {},
|
|
5956
6075
|
...io.now ? { now: io.now } : {}
|
|
5957
6076
|
});
|
|
@@ -5986,14 +6105,14 @@ ${next.line}
|
|
|
5986
6105
|
|
|
5987
6106
|
// src/repo.ts
|
|
5988
6107
|
import { lstat, mkdir as mkdir2, readdir, readFile as readFile2, readlink, rm as rm2, symlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
5989
|
-
import { dirname as
|
|
6108
|
+
import { dirname as dirname4, join as join3, relative, sep } from "node:path";
|
|
5990
6109
|
var absent = (err) => {
|
|
5991
6110
|
const code = err.code;
|
|
5992
6111
|
return code === "ENOENT" || code === "ENOTDIR" || code === "EISDIR";
|
|
5993
6112
|
};
|
|
5994
6113
|
async function collect(base, dir, out) {
|
|
5995
6114
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
5996
|
-
const full =
|
|
6115
|
+
const full = join3(dir, entry.name);
|
|
5997
6116
|
if (entry.isDirectory()) {
|
|
5998
6117
|
if (entry.name !== ".git" && entry.name !== "node_modules")
|
|
5999
6118
|
await collect(base, full, out);
|
|
@@ -6003,12 +6122,12 @@ async function collect(base, dir, out) {
|
|
|
6003
6122
|
}
|
|
6004
6123
|
function fsRepoView(root) {
|
|
6005
6124
|
return {
|
|
6006
|
-
readFile: (path) => readFile2(
|
|
6125
|
+
readFile: (path) => readFile2(join3(root, path), "utf8").catch((err) => {
|
|
6007
6126
|
if (absent(err))
|
|
6008
6127
|
return null;
|
|
6009
6128
|
throw err;
|
|
6010
6129
|
}),
|
|
6011
|
-
readLink: (path) => readlink(
|
|
6130
|
+
readLink: (path) => readlink(join3(root, path)).catch((err) => {
|
|
6012
6131
|
if (absent(err) || err.code === "EINVAL")
|
|
6013
6132
|
return null;
|
|
6014
6133
|
throw err;
|
|
@@ -6016,7 +6135,7 @@ function fsRepoView(root) {
|
|
|
6016
6135
|
readFolder: async (path) => {
|
|
6017
6136
|
const out = [];
|
|
6018
6137
|
try {
|
|
6019
|
-
await collect(
|
|
6138
|
+
await collect(join3(root, path), join3(root, path), out);
|
|
6020
6139
|
} catch (err) {
|
|
6021
6140
|
if (absent(err))
|
|
6022
6141
|
return null;
|
|
@@ -6030,7 +6149,7 @@ async function assertNoLinkedParent(root, path) {
|
|
|
6030
6149
|
const parts = path.split("/").slice(0, -1);
|
|
6031
6150
|
for (let k = 1;k <= parts.length; k++) {
|
|
6032
6151
|
const parent = parts.slice(0, k).join("/");
|
|
6033
|
-
if ((await lstat(
|
|
6152
|
+
if ((await lstat(join3(root, parent)).catch(() => null))?.isSymbolicLink())
|
|
6034
6153
|
throw new CommandError(`${parent} is a link; Armada does not write through it. Replace it with a folder first.`);
|
|
6035
6154
|
}
|
|
6036
6155
|
}
|
|
@@ -6038,15 +6157,15 @@ async function applyPlan(root, plan) {
|
|
|
6038
6157
|
for (const path of [...plan.removes, ...plan.writes.map((w) => w.path), ...plan.links.map((l) => l.path)])
|
|
6039
6158
|
await assertNoLinkedParent(root, path);
|
|
6040
6159
|
for (const path of plan.removes)
|
|
6041
|
-
await rm2(
|
|
6160
|
+
await rm2(join3(root, path), { force: true });
|
|
6042
6161
|
for (const w of plan.writes) {
|
|
6043
|
-
const full =
|
|
6044
|
-
await mkdir2(
|
|
6162
|
+
const full = join3(root, w.path);
|
|
6163
|
+
await mkdir2(dirname4(full), { recursive: true });
|
|
6045
6164
|
await writeFile2(full, w.content);
|
|
6046
6165
|
}
|
|
6047
6166
|
for (const l of plan.links) {
|
|
6048
|
-
const full =
|
|
6049
|
-
await mkdir2(
|
|
6167
|
+
const full = join3(root, l.path);
|
|
6168
|
+
await mkdir2(dirname4(full), { recursive: true });
|
|
6050
6169
|
if (await lstat(full).catch(() => null))
|
|
6051
6170
|
await rm2(full, { recursive: true, force: true });
|
|
6052
6171
|
await symlink(l.target, full);
|
|
@@ -6222,7 +6341,7 @@ async function doctor(io, json, armadaVersion) {
|
|
|
6222
6341
|
// src/init.ts
|
|
6223
6342
|
import { mkdtemp, realpath, rm as rm3 } from "node:fs/promises";
|
|
6224
6343
|
import { tmpdir } from "node:os";
|
|
6225
|
-
import { join as
|
|
6344
|
+
import { join as join4 } from "node:path";
|
|
6226
6345
|
var STOP_HOOK_QUESTION = "Add the Claude Code stop hook to this repository's .claude/settings.json? A coordinator then cannot end its turn while workers are in flight and no armada watch runs; your user settings are not touched. [Y/n] ";
|
|
6227
6346
|
async function wantsStopHook(io, opts) {
|
|
6228
6347
|
if (opts.stopHook !== null)
|
|
@@ -6255,7 +6374,7 @@ async function resolveConfig(exec, root, checkout, opts) {
|
|
|
6255
6374
|
return { config: parse(onDefault, `${CONFIG_FILE} on the default branch`), text: null, source: "default branch" };
|
|
6256
6375
|
const local = await fsRepoView(root).readFile(CONFIG_FILE);
|
|
6257
6376
|
if (local !== null && !opts.programRoot)
|
|
6258
|
-
return { config: parse(local,
|
|
6377
|
+
return { config: parse(local, join4(root, CONFIG_FILE)), text: local, source: "working tree" };
|
|
6259
6378
|
const branch = initBranch(opts.armadaVersion);
|
|
6260
6379
|
if (!opts.programRoot && await sh(exec, root, "git", ["ls-remote", "origin", `refs/heads/${branch}`])) {
|
|
6261
6380
|
await sh(exec, root, "git", ["fetch", "--quiet", "origin", branch]);
|
|
@@ -6325,7 +6444,7 @@ async function init(io, opts) {
|
|
|
6325
6444
|
const base = await defaultBranch(exec, root);
|
|
6326
6445
|
await sh(exec, root, "git", ["fetch", "--quiet", "origin", base]);
|
|
6327
6446
|
const baseSha = await sh(exec, root, "git", ["rev-parse", "FETCH_HEAD"]);
|
|
6328
|
-
const checkout = await realpath(await mkdtemp(
|
|
6447
|
+
const checkout = await realpath(await mkdtemp(join4(tmpdir(), "armada-init-")));
|
|
6329
6448
|
try {
|
|
6330
6449
|
await sh(exec, root, "git", ["worktree", "add", "--quiet", "--detach", checkout, baseSha]);
|
|
6331
6450
|
const { config, text, source } = await resolveConfig(exec, root, checkout, opts);
|
|
@@ -6426,7 +6545,7 @@ async function init(io, opts) {
|
|
|
6426
6545
|
import { randomUUID } from "node:crypto";
|
|
6427
6546
|
import { rm as rm4 } from "node:fs/promises";
|
|
6428
6547
|
import { hostname, tmpdir as tmpdir2 } from "node:os";
|
|
6429
|
-
import { dirname as
|
|
6548
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
6430
6549
|
var TRANSIENT = /\bHTTP 5\d\d\b|\b5\d\d (?:Bad Gateway|Service Unavailable|Gateway Time-?out|Internal Server Error)\b|Bad Gateway|Service Unavailable|Gateway Time-?out|ECONNRESET|ETIMEDOUT|connection reset|i\/o timeout|TLS handshake timeout/i;
|
|
6431
6550
|
var tail = (text, lines = 30) => text.trimEnd().split(`
|
|
6432
6551
|
`).slice(-lines).join(`
|
|
@@ -6486,7 +6605,7 @@ function gitRepo(exec, cwd) {
|
|
|
6486
6605
|
},
|
|
6487
6606
|
async testMerge({ branch, base, head, number, commands }) {
|
|
6488
6607
|
await must(["fetch", "--quiet", "origin", branch, `refs/pull/${number}/head`]);
|
|
6489
|
-
const dir =
|
|
6608
|
+
const dir = join5(tmpdir2(), `armada-merge-${number}-${randomUUID().slice(0, 8)}`);
|
|
6490
6609
|
const remove = async () => {
|
|
6491
6610
|
await git(["worktree", "remove", "--force", dir]);
|
|
6492
6611
|
await git(["worktree", "prune"]);
|
|
@@ -6573,7 +6692,7 @@ async function merge2(io, config, credentials, a, configPath) {
|
|
|
6573
6692
|
if (!exec)
|
|
6574
6693
|
throw new UsageError("armada merge needs to run git and gh");
|
|
6575
6694
|
const linearApiKey = credentials.linearApiKey;
|
|
6576
|
-
const repoDir =
|
|
6695
|
+
const repoDir = dirname5(configPath);
|
|
6577
6696
|
const fetchOpt = io.fetch ? { fetch: io.fetch } : {};
|
|
6578
6697
|
const gh = { token, repository: config.github.repository, ...fetchOpt };
|
|
6579
6698
|
const linearOpts = { apiKey: linearApiKey, labels: config.tracker.labels, ...fetchOpt };
|
|
@@ -6604,7 +6723,7 @@ async function merge2(io, config, credentials, a, configPath) {
|
|
|
6604
6723
|
`),
|
|
6605
6724
|
installedSkill: async (name) => {
|
|
6606
6725
|
for (const dir of [AGENTS_SKILLS_DIR, CLAUDE_SKILLS_DIR])
|
|
6607
|
-
if (await io.readFile(
|
|
6726
|
+
if (await io.readFile(join5(repoDir, dir, name, "SKILL.md")) !== null)
|
|
6608
6727
|
return true;
|
|
6609
6728
|
return false;
|
|
6610
6729
|
}
|
|
@@ -6681,6 +6800,8 @@ function renderStatus(r) {
|
|
|
6681
6800
|
out.push(`${indent}${truncate(t.title, 90)}${t.spec ? ` [${t.spec}]` : ""}`);
|
|
6682
6801
|
if (t.statusLine?.summary)
|
|
6683
6802
|
out.push(`${indent}“${truncate(t.statusLine.summary, 100)}”`);
|
|
6803
|
+
if (t.statusLine?.plan)
|
|
6804
|
+
out.push(`${indent}plan: ${t.statusLine.url}`);
|
|
6684
6805
|
if (t.pr)
|
|
6685
6806
|
out.push(`${indent}${[`PR #${t.pr.number}`, prState(t.pr)].filter(Boolean).join(" · ")}`);
|
|
6686
6807
|
if (t.flags.length)
|
|
@@ -6802,8 +6923,12 @@ var COMMAND_HELP = {
|
|
|
6802
6923
|
routed profile needs --reason. Prints the ticket's state afterwards
|
|
6803
6924
|
`,
|
|
6804
6925
|
report: ` report <phase> [--message <text> | --message-file <path|->] [--pr <n|url>] [--sha <sha>]
|
|
6926
|
+
[--plan <text> | --plan-file <path|->]
|
|
6805
6927
|
Report a phase (planning, awaiting-approval, implementing, shipping,
|
|
6806
6928
|
blocked, ready-to-merge); the same phase again is a status update.
|
|
6929
|
+
--plan posts the plan as its own block under a one-line status (the
|
|
6930
|
+
message's first line, else the plan's); awaiting-approval sends it to
|
|
6931
|
+
the coordinator's inbox.
|
|
6807
6932
|
ready-to-merge needs --sha (full 40 characters, the PR head) and green CI.
|
|
6808
6933
|
Prints the ticket's state and what waits in this worker's inbox.
|
|
6809
6934
|
`,
|
|
@@ -6944,6 +7069,8 @@ var VALUE_OPTIONS = [
|
|
|
6944
7069
|
"ticket",
|
|
6945
7070
|
"message",
|
|
6946
7071
|
"message-file",
|
|
7072
|
+
"plan",
|
|
7073
|
+
"plan-file",
|
|
6947
7074
|
"pr",
|
|
6948
7075
|
"sha",
|
|
6949
7076
|
"reason",
|
|
@@ -6959,7 +7086,7 @@ var VALUE_OPTIONS = [
|
|
|
6959
7086
|
var FLAG_OPTIONS = ["dry-run", "no-lock", "prompt", "wait", "note", "api-key", "no-stop-hook"];
|
|
6960
7087
|
var COMMAND_OPTIONS = {
|
|
6961
7088
|
claim: ["runtime", "handle", "branch", "profile", "reason"],
|
|
6962
|
-
report: ["ticket", "message", "message-file", "pr", "sha"],
|
|
7089
|
+
report: ["ticket", "message", "message-file", "plan", "plan-file", "pr", "sha"],
|
|
6963
7090
|
release: ["ticket", "reason"],
|
|
6964
7091
|
ask: ["ticket", "options", "message", "message-file"],
|
|
6965
7092
|
inbox: ["wait", "timeout"],
|
|
@@ -7020,12 +7147,12 @@ async function findConfig(io, explicit, command = "status") {
|
|
|
7020
7147
|
throw new UsageError(`${path} does not exist`, `armada ${command} --config <file>, with the path of an ${CONFIG_FILE}`);
|
|
7021
7148
|
return { path, text };
|
|
7022
7149
|
}
|
|
7023
|
-
for (let dir = resolve(io.cwd);; dir =
|
|
7024
|
-
const path =
|
|
7150
|
+
for (let dir = resolve(io.cwd);; dir = dirname6(dir)) {
|
|
7151
|
+
const path = join6(dir, CONFIG_FILE);
|
|
7025
7152
|
const text = await io.readFile(path);
|
|
7026
7153
|
if (text !== null)
|
|
7027
7154
|
return { path, text };
|
|
7028
|
-
if (
|
|
7155
|
+
if (dirname6(dir) === dir)
|
|
7029
7156
|
break;
|
|
7030
7157
|
}
|
|
7031
7158
|
throw new UsageError(`no ${CONFIG_FILE} found in ${io.cwd} or any parent directory, so this is not a repository Armada runs`, `armada init to set this repository up, armada ${command} --config <file> to use another ${CONFIG_FILE}, or armada status --all to see the registered projects`);
|
|
@@ -7131,7 +7258,7 @@ async function run(argv, io) {
|
|
|
7131
7258
|
if (args.command === "brief") {
|
|
7132
7259
|
const { path, text } = await findConfig(io, args.config, "brief");
|
|
7133
7260
|
const { credentials } = await loadCredentials(io);
|
|
7134
|
-
return await brief2(io, parseConfig(text, path), credentials, args, version);
|
|
7261
|
+
return await brief2(io, parseConfig(text, path), credentials, args, version, path);
|
|
7135
7262
|
}
|
|
7136
7263
|
if (args.command === "status") {
|
|
7137
7264
|
noExtra(args.rest);
|