@the-vibe-company/armada 0.1.4 → 0.1.6
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 +215 -119
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,6 +109,34 @@ armada merge 34 # or the pull request URL; --ticket ABC-12 when the
|
|
|
109
109
|
- Then the ticket moves to Done with its agent labels removed, the pull request is linked, `Agent status: merged — …` is posted, the Turso hand-back is resolved and the runtime handle released. The output lists the workers in flight to tell and the worker session to archive with its runtime guide.
|
|
110
110
|
- It runs `gh` and `git` in the repository checkout and needs `LINEAR_API_KEY` and a GitHub token.
|
|
111
111
|
|
|
112
|
+
## Watch the fleet (dashboard)
|
|
113
|
+
|
|
114
|
+
`packages/dashboard` is a Next.js app with one page: the Fleet of every project registered in Turso.
|
|
115
|
+
|
|
116
|
+
- **Waiting for you** comes first, across projects. It lists questions, blocked workers, plans to approve, hand-backs and silent workers, the most urgent first.
|
|
117
|
+
- **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).
|
|
118
|
+
- A filter shows one project. Each project shows whether its coordinator is active, from its last inbox read.
|
|
119
|
+
- It stays live without a reload. Linear and GitHub are read at most once a minute per project. Turso is read on every 5-second poll, so a worker's `armada report` shows within seconds.
|
|
120
|
+
- When Turso is unreachable, a banner says so and the view falls back to Linear and GitHub.
|
|
121
|
+
- The interface is in English or French (`ARMADA_DASHBOARD_LANGUAGE`, or the EN/FR switch).
|
|
122
|
+
|
|
123
|
+
Try it locally with synthetic data and no key:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
cd packages/dashboard
|
|
127
|
+
bun run demo:seed # a local file: database with two invented projects
|
|
128
|
+
ARMADA_DASHBOARD_DEMO=fleet ARMADA_TURSO_URL=file:.demo/armada.db bun run dev # http://localhost:4822
|
|
129
|
+
bun run demo:report WID-12 shipping "Opened the pull request" # watch the row change
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Deploy on Vercel.** Create a project from this repository and set these options:
|
|
133
|
+
|
|
134
|
+
- 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`.
|
|
135
|
+
- Environment variables: `LINEAR_API_KEY`, `GITHUB_TOKEN`, `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN`. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while Turso is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`) and `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (Linear and GitHub read period, default 60).
|
|
136
|
+
- Keep it private. Turn on Vercel Authentication (Settings > Deployment Protection). The keys stay on the server; the browser only receives the fleet reading.
|
|
137
|
+
|
|
138
|
+
One deployment covers one Linear workspace and one GitHub organization: its keys must read every registered project.
|
|
139
|
+
|
|
112
140
|
## Keys
|
|
113
141
|
|
|
114
142
|
Armada needs a few keys. Set them up once per machine with `armada auth login`, or pass them as environment variables, which always win over the stored ones (the way to go in CI and cloud sandboxes).
|
|
@@ -205,7 +233,7 @@ See [AGENTS.md](https://github.com/The-Vibe-Company/armada/blob/main/AGENTS.md)
|
|
|
205
233
|
- **Linear** holds the plan: specs, tickets, dependencies and agent phases.
|
|
206
234
|
- **Turso** (libSQL) holds live telemetry: events, heartbeats, pending questions and locks. Losing it loses live detail, never progress.
|
|
207
235
|
- **Conductor Cloud** runs the workers in the first version. Other runtimes come later without changing the worker contract.
|
|
208
|
-
- **Dashboard
|
|
236
|
+
- **Dashboard** (Next.js, `packages/dashboard`): the live Fleet view of every project. The program view comes later.
|
|
209
237
|
|
|
210
238
|
## License
|
|
211
239
|
|
package/dist/armada.js
CHANGED
|
@@ -1381,6 +1381,16 @@ function criticalIds(m) {
|
|
|
1381
1381
|
return out;
|
|
1382
1382
|
}
|
|
1383
1383
|
|
|
1384
|
+
// ../core/src/types.ts
|
|
1385
|
+
var LABEL_PHASES = [
|
|
1386
|
+
"planning",
|
|
1387
|
+
"awaiting-approval",
|
|
1388
|
+
"implementing",
|
|
1389
|
+
"shipping",
|
|
1390
|
+
"blocked",
|
|
1391
|
+
"ready-to-merge"
|
|
1392
|
+
];
|
|
1393
|
+
|
|
1384
1394
|
// ../core/src/fleet.ts
|
|
1385
1395
|
var MIN = 60000;
|
|
1386
1396
|
var NEEDS_HUMAN = ["awaiting-approval", "blocked", "ready-to-merge"];
|
|
@@ -1424,6 +1434,12 @@ function inferPhase(pr, comments) {
|
|
|
1424
1434
|
return "awaiting-approval";
|
|
1425
1435
|
return "planning";
|
|
1426
1436
|
}
|
|
1437
|
+
var ENDS_WORK = ["release", "merge"];
|
|
1438
|
+
var livePhase = (e) => e.kind === "release" ? "released" : LABEL_PHASES.find((p) => p === e.phase) ?? null;
|
|
1439
|
+
function freshEvent(issueId, opts) {
|
|
1440
|
+
const e = opts.live?.events[issueId];
|
|
1441
|
+
return e && opts.live && e.at > opts.live.after ? e : null;
|
|
1442
|
+
}
|
|
1427
1443
|
function buildLane(m, allComments, issue, opts) {
|
|
1428
1444
|
const comments = commentsFor(allComments, issue.id);
|
|
1429
1445
|
const withStatus = comments.find((c) => c.status && c.status.phase !== "released");
|
|
@@ -1441,13 +1457,27 @@ function buildLane(m, allComments, issue, opts) {
|
|
|
1441
1457
|
phase = inferPhase(pr, comments);
|
|
1442
1458
|
phaseSource = "inferred";
|
|
1443
1459
|
}
|
|
1460
|
+
const fresh = freshEvent(issue.id, opts);
|
|
1461
|
+
const freshPhase = fresh ? livePhase(fresh) : null;
|
|
1462
|
+
const trackerPhase = phase;
|
|
1463
|
+
if (freshPhase && freshPhase !== "released") {
|
|
1464
|
+
phase = freshPhase;
|
|
1465
|
+
phaseSource = "live";
|
|
1466
|
+
}
|
|
1444
1467
|
const shippingPhase = phase === "shipping" || phase === "ready-to-merge";
|
|
1445
|
-
if (pr?.state === "merged" && !isDone(issue) && (shippingPhase || phaseSource
|
|
1468
|
+
if (pr?.state === "merged" && !isDone(issue) && (shippingPhase || phaseSource === "status-line" || phaseSource === "inferred"))
|
|
1446
1469
|
phase = "merged";
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1470
|
+
let announcing;
|
|
1471
|
+
for (const c of comments) {
|
|
1472
|
+
if (!c.status || c.status.phase === "released")
|
|
1473
|
+
continue;
|
|
1474
|
+
if (c.status.phase !== phase)
|
|
1475
|
+
break;
|
|
1476
|
+
announcing = c;
|
|
1477
|
+
}
|
|
1478
|
+
const since = (fresh && phaseSource === "live" && phase !== trackerPhase ? fresh.at : undefined) ?? announcing?.createdAt ?? (fresh && phaseSource === "live" ? fresh.at : undefined) ?? (phase === "shipping" || phase === "ready-to-merge" ? pr?.createdAt : undefined) ?? claims[0]?.at ?? issue.startedAt ?? issue.updatedAt;
|
|
1479
|
+
const lastUpdate = latest(issue.updatedAt, comments[0]?.createdAt, pr?.updatedAt, issue.startedAt, fresh?.at);
|
|
1480
|
+
const lastReport = latest(comments.find((c) => c.status || c.claim)?.createdAt, claims.at(-1)?.at, opts.lastEvents?.[issue.id], fresh?.at) || null;
|
|
1451
1481
|
const openBlockers = m.openBlockersOf(issue);
|
|
1452
1482
|
const agent = issue.delegate ?? issue.assignee;
|
|
1453
1483
|
const flags = [];
|
|
@@ -1465,9 +1495,9 @@ function buildLane(m, allComments, issue, opts) {
|
|
|
1465
1495
|
flags.push("double-claim");
|
|
1466
1496
|
if (openBlockers.length)
|
|
1467
1497
|
flags.push("started-before-blockers");
|
|
1468
|
-
if (!agent)
|
|
1498
|
+
if (!agent && phaseSource !== "live")
|
|
1469
1499
|
flags.push("no-assignee");
|
|
1470
|
-
if (!issue.agentPhase)
|
|
1500
|
+
if (!issue.agentPhase && phaseSource !== "live")
|
|
1471
1501
|
flags.push("no-phase-label");
|
|
1472
1502
|
const spec = m.specOf(issue.id);
|
|
1473
1503
|
return {
|
|
@@ -1475,13 +1505,14 @@ function buildLane(m, allComments, issue, opts) {
|
|
|
1475
1505
|
spec: spec ? `Spec ${spec.ordinal}` : null,
|
|
1476
1506
|
phase,
|
|
1477
1507
|
phaseSource,
|
|
1478
|
-
runtime: issue.agentRuntime ?? claimRuntime ?? null,
|
|
1508
|
+
runtime: issue.agentRuntime ?? claimRuntime ?? fresh?.runtime ?? opts.live?.handles?.[issue.id]?.runtime ?? null,
|
|
1509
|
+
handle: opts.live?.handles?.[issue.id]?.handle ?? claims[0]?.session ?? fresh?.handle ?? null,
|
|
1479
1510
|
claim: claims[0] ?? null,
|
|
1480
1511
|
agent,
|
|
1481
1512
|
since,
|
|
1482
1513
|
lastUpdate,
|
|
1483
1514
|
lastReport,
|
|
1484
|
-
statusLine: withStatus?.status ? {
|
|
1515
|
+
statusLine: fresh?.message && phaseSource === "live" ? { summary: fresh.message, at: fresh.at, author: null, url: issue.url } : withStatus?.status ? {
|
|
1485
1516
|
summary: withStatus.status.summary,
|
|
1486
1517
|
at: withStatus.createdAt,
|
|
1487
1518
|
author: withStatus.author,
|
|
@@ -1493,7 +1524,11 @@ function buildLane(m, allComments, issue, opts) {
|
|
|
1493
1524
|
};
|
|
1494
1525
|
}
|
|
1495
1526
|
function inFlight(m, comments, opts) {
|
|
1496
|
-
|
|
1527
|
+
const held = (i) => {
|
|
1528
|
+
const fresh = freshEvent(i.id, opts);
|
|
1529
|
+
return fresh ? !ENDS_WORK.includes(fresh.kind) : !!i.agentPhase || isStarted(i);
|
|
1530
|
+
};
|
|
1531
|
+
return m.program.filter((i) => m.isLeaf(i) && !isClosed(i) && held(i)).map((i) => buildLane(m, comments, i, opts)).sort((a, b) => PHASE_RANK[a.phase] - PHASE_RANK[b.phase] || a.issue.id.localeCompare(b.issue.id, "en", { numeric: true }));
|
|
1497
1532
|
}
|
|
1498
1533
|
function frontier(m, readyLabel) {
|
|
1499
1534
|
const dependents = new Map;
|
|
@@ -1535,26 +1570,21 @@ function waitingPullRequests(m, prs) {
|
|
|
1535
1570
|
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);
|
|
1536
1571
|
}
|
|
1537
1572
|
|
|
1538
|
-
// ../core/src/types.ts
|
|
1539
|
-
var LABEL_PHASES = [
|
|
1540
|
-
"planning",
|
|
1541
|
-
"awaiting-approval",
|
|
1542
|
-
"implementing",
|
|
1543
|
-
"shipping",
|
|
1544
|
-
"blocked",
|
|
1545
|
-
"ready-to-merge"
|
|
1546
|
-
];
|
|
1547
|
-
|
|
1548
1573
|
// ../core/src/linear.ts
|
|
1549
1574
|
var LINEAR_ENDPOINT = "https://api.linear.app/graphql";
|
|
1550
1575
|
var MAX_DEPTH = 8;
|
|
1551
|
-
var MAX_PAGES = 20;
|
|
1552
1576
|
var COMMENT_BATCH = 25;
|
|
1553
1577
|
var MAX_COMMENTS = 100;
|
|
1578
|
+
var MORE_PAGE = 100;
|
|
1554
1579
|
var REQUEST_TIMEOUT_MS = 30000;
|
|
1555
1580
|
|
|
1556
1581
|
class LinearError extends Error {
|
|
1582
|
+
transport;
|
|
1557
1583
|
name = "LinearError";
|
|
1584
|
+
constructor(message, transport = false) {
|
|
1585
|
+
super(message);
|
|
1586
|
+
this.transport = transport;
|
|
1587
|
+
}
|
|
1558
1588
|
}
|
|
1559
1589
|
var PHASES = [...LABEL_PHASES, "released", "merged"];
|
|
1560
1590
|
var LEGACY = { "handed-back": "ready-to-merge", "ci-fixing": "shipping" };
|
|
@@ -1609,14 +1639,6 @@ function agentLabels(labels, groups) {
|
|
|
1609
1639
|
}
|
|
1610
1640
|
var sameName = (a, b) => a.toLowerCase().replace(/[^a-z0-9]/g, "") === b.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
1611
1641
|
var phaseNamed = (name) => LABEL_PHASES.find((p) => sameName(p, name)) ?? null;
|
|
1612
|
-
function truncationWarnings(raw) {
|
|
1613
|
-
const cut = (c, what) => c.pageInfo?.hasNextPage ? [`${raw.identifier}: more ${what} than Armada reads; some are ignored`] : [];
|
|
1614
|
-
return [
|
|
1615
|
-
...cut(raw.inverseRelations, "relations"),
|
|
1616
|
-
...cut(raw.labels, "labels"),
|
|
1617
|
-
...cut(raw.attachments, "attachments")
|
|
1618
|
-
];
|
|
1619
|
-
}
|
|
1620
1642
|
function normalizeIssue(raw, groups) {
|
|
1621
1643
|
const blockers = new Map;
|
|
1622
1644
|
for (const r of raw.inverseRelations.nodes)
|
|
@@ -1667,6 +1689,28 @@ function normalizeComment(raw, issueId) {
|
|
|
1667
1689
|
claim: parseClaim(raw.body, raw.createdAt, author)
|
|
1668
1690
|
};
|
|
1669
1691
|
}
|
|
1692
|
+
var MORE = {
|
|
1693
|
+
inverseRelations: {
|
|
1694
|
+
field: "inverseRelations",
|
|
1695
|
+
nodes: "type issue { identifier state { type } }",
|
|
1696
|
+
operation: "MoreRelations",
|
|
1697
|
+
what: "relations"
|
|
1698
|
+
},
|
|
1699
|
+
labels: { field: "labels", nodes: "name parent { name }", operation: "MoreLabels", what: "labels" },
|
|
1700
|
+
attachments: { field: "attachments", nodes: "title url", operation: "MoreAttachments", what: "attachments" },
|
|
1701
|
+
comments: {
|
|
1702
|
+
field: "comments",
|
|
1703
|
+
nodes: "id createdAt body user { name }",
|
|
1704
|
+
operation: "MoreComments",
|
|
1705
|
+
what: "comments"
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
var MORE_QUERY = (m) => `
|
|
1709
|
+
query ${m.operation}($id: String!, $after: String) {
|
|
1710
|
+
issue(id: $id) {
|
|
1711
|
+
${m.field}(first: ${m.first ?? MORE_PAGE}, after: $after) { pageInfo { hasNextPage endCursor } nodes { ${m.nodes} } }
|
|
1712
|
+
}
|
|
1713
|
+
}`;
|
|
1670
1714
|
var FIELDS = (delegate) => `
|
|
1671
1715
|
fragment F on Issue {
|
|
1672
1716
|
id identifier title url description createdAt updatedAt startedAt completedAt canceledAt
|
|
@@ -1674,9 +1718,9 @@ var FIELDS = (delegate) => `
|
|
|
1674
1718
|
assignee { name }
|
|
1675
1719
|
${delegate ? "delegate { name }" : ""}
|
|
1676
1720
|
parent { identifier }
|
|
1677
|
-
labels(first: 25) { pageInfo { hasNextPage } nodes {
|
|
1678
|
-
attachments(first: 25) { pageInfo { hasNextPage } nodes {
|
|
1679
|
-
inverseRelations(first: 50) { pageInfo { hasNextPage } nodes {
|
|
1721
|
+
labels(first: 25) { pageInfo { hasNextPage endCursor } nodes { ${MORE.labels.nodes} } }
|
|
1722
|
+
attachments(first: 25) { pageInfo { hasNextPage endCursor } nodes { ${MORE.attachments.nodes} } }
|
|
1723
|
+
inverseRelations(first: 50) { pageInfo { hasNextPage endCursor } nodes { ${MORE.inverseRelations.nodes} } }
|
|
1680
1724
|
}
|
|
1681
1725
|
`;
|
|
1682
1726
|
var ROOT_QUERY = (d) => `${FIELDS(d)} query Root($id: String!) { issue(id: $id) { ...F } }`;
|
|
@@ -1690,7 +1734,7 @@ var CHILDREN_QUERY = (d) => `${FIELDS(d)}
|
|
|
1690
1734
|
var COMMENTS_QUERY = `
|
|
1691
1735
|
query Comments($ids: [ID!]) {
|
|
1692
1736
|
issues(first: 50, filter: { id: { in: $ids } }) {
|
|
1693
|
-
nodes { identifier comments(first: ${MAX_COMMENTS}) { pageInfo { hasNextPage } nodes {
|
|
1737
|
+
nodes { identifier comments(first: ${MAX_COMMENTS}) { pageInfo { hasNextPage endCursor } nodes { ${MORE.comments.nodes} } } }
|
|
1694
1738
|
}
|
|
1695
1739
|
}`;
|
|
1696
1740
|
async function gql(opts, query, variables) {
|
|
@@ -1702,15 +1746,15 @@ async function gql(opts, query, variables) {
|
|
|
1702
1746
|
body: JSON.stringify({ query, variables }),
|
|
1703
1747
|
signal: AbortSignal.timeout(timeoutMs)
|
|
1704
1748
|
}).catch((err) => {
|
|
1705
|
-
throw new LinearError(`Linear API unreachable: ${networkReason(err, timeoutMs)}
|
|
1749
|
+
throw new LinearError(`Linear API unreachable: ${networkReason(err, timeoutMs)}`, true);
|
|
1706
1750
|
});
|
|
1707
1751
|
if (res.status === 401)
|
|
1708
|
-
throw new LinearError("Linear rejected the API key (HTTP 401); check LINEAR_API_KEY");
|
|
1752
|
+
throw new LinearError("Linear rejected the API key (HTTP 401); check LINEAR_API_KEY", true);
|
|
1709
1753
|
const json = await res.json().catch(() => ({}));
|
|
1710
1754
|
if (json.errors?.length)
|
|
1711
1755
|
throw new LinearError(`Linear API: ${json.errors.map((e) => e.message).join("; ")}`);
|
|
1712
1756
|
if (!res.ok)
|
|
1713
|
-
throw new LinearError(`Linear API HTTP ${res.status}
|
|
1757
|
+
throw new LinearError(`Linear API HTTP ${res.status}`, true);
|
|
1714
1758
|
if (!json.data)
|
|
1715
1759
|
throw new LinearError("Linear API: empty response");
|
|
1716
1760
|
return json.data;
|
|
@@ -1741,34 +1785,35 @@ async function fetchTree(opts, delegate) {
|
|
|
1741
1785
|
for (let depth = 0;depth < MAX_DEPTH && parents.length; depth++) {
|
|
1742
1786
|
const next = [];
|
|
1743
1787
|
let after = null;
|
|
1744
|
-
for (
|
|
1745
|
-
if (page === MAX_PAGES) {
|
|
1746
|
-
warnings.push(`more than ${MAX_PAGES * 50} issues at depth ${depth + 1}; the rest are ignored`);
|
|
1747
|
-
break;
|
|
1748
|
-
}
|
|
1788
|
+
for (;; ) {
|
|
1749
1789
|
const data = await gql(opts, CHILDREN_QUERY(delegate), { parents, after });
|
|
1750
1790
|
all.push(...data.issues.nodes);
|
|
1751
1791
|
next.push(...data.issues.nodes.map((n) => n.id));
|
|
1752
|
-
|
|
1792
|
+
const { hasNextPage, endCursor } = data.issues.pageInfo;
|
|
1793
|
+
if (!hasNextPage)
|
|
1794
|
+
break;
|
|
1795
|
+
if (!endCursor || endCursor === after) {
|
|
1796
|
+
warnings.push(`issues at depth ${depth + 1}: Linear did not advance to the next page; the rest are ignored`);
|
|
1753
1797
|
break;
|
|
1754
|
-
|
|
1798
|
+
}
|
|
1799
|
+
after = endCursor;
|
|
1755
1800
|
}
|
|
1756
1801
|
parents = next;
|
|
1757
1802
|
}
|
|
1758
1803
|
if (parents.length)
|
|
1759
1804
|
warnings.push(`the program is deeper than ${MAX_DEPTH} levels; deeper issues are ignored`);
|
|
1760
1805
|
for (const r of all)
|
|
1761
|
-
|
|
1806
|
+
for (const field of ["inverseRelations", "labels", "attachments"])
|
|
1807
|
+
await readRest(opts, r.identifier, MORE[field], r[field], warnings);
|
|
1762
1808
|
const issues = all.map((r) => normalizeIssue(r, opts.labels));
|
|
1763
1809
|
const candidates = issues.filter((i) => i.id !== root.identifier && !CLOSED2.has(i.statusType) && (i.agentPhase || i.statusType === "started"));
|
|
1764
1810
|
const comments = [];
|
|
1765
1811
|
for (const batch of chunks(candidates.map((i) => i.uuid), COMMENT_BATCH)) {
|
|
1766
1812
|
const data = await gql(opts, COMMENTS_QUERY, { ids: batch });
|
|
1767
1813
|
for (const n of data.issues.nodes) {
|
|
1814
|
+
await readRest(opts, n.identifier, MORE.comments, n.comments, warnings);
|
|
1768
1815
|
for (const c of n.comments.nodes)
|
|
1769
1816
|
comments.push(normalizeComment(c, n.identifier));
|
|
1770
|
-
if (n.comments.pageInfo?.hasNextPage)
|
|
1771
|
-
warnings.push(`${n.identifier}: more than ${MAX_COMMENTS} comments; its phase and claim may be out of date`);
|
|
1772
1817
|
}
|
|
1773
1818
|
}
|
|
1774
1819
|
return {
|
|
@@ -1779,13 +1824,40 @@ async function fetchTree(opts, delegate) {
|
|
|
1779
1824
|
warnings
|
|
1780
1825
|
};
|
|
1781
1826
|
}
|
|
1827
|
+
async function readRest(opts, identifier, more, conn, warnings) {
|
|
1828
|
+
while (conn.pageInfo?.hasNextPage) {
|
|
1829
|
+
const after = conn.pageInfo.endCursor;
|
|
1830
|
+
try {
|
|
1831
|
+
if (!after)
|
|
1832
|
+
throw new LinearError("Linear gave no cursor for the next page");
|
|
1833
|
+
const data = await gql(opts, MORE_QUERY(more), {
|
|
1834
|
+
id: identifier,
|
|
1835
|
+
after
|
|
1836
|
+
});
|
|
1837
|
+
const page = data.issue?.[more.field];
|
|
1838
|
+
if (!page)
|
|
1839
|
+
throw new LinearError(`Linear: issue ${identifier} not found`);
|
|
1840
|
+
conn.nodes.push(...page.nodes);
|
|
1841
|
+
conn.pageInfo = page.pageInfo;
|
|
1842
|
+
if (page.pageInfo?.hasNextPage && page.pageInfo.endCursor === after)
|
|
1843
|
+
throw new LinearError("Linear did not advance to a next page");
|
|
1844
|
+
} catch (err) {
|
|
1845
|
+
if (!(err instanceof LinearError) || err.transport)
|
|
1846
|
+
throw err;
|
|
1847
|
+
warnings.push(`${identifier}: could not read all its ${more.what} (${err.message}); some may be missing`);
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1782
1852
|
|
|
1783
1853
|
// ../core/src/brief.ts
|
|
1784
1854
|
var ARMADA_PACKAGE = "@the-vibe-company/armada";
|
|
1785
1855
|
var WORKER_SKILL_PATH = ".agents/skills/armada-worker/SKILL.md";
|
|
1786
1856
|
var CONDUCTOR_HANDLE = '"$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"';
|
|
1787
1857
|
var MAX_NOTES = 10;
|
|
1788
|
-
var
|
|
1858
|
+
var NOTE = "id createdAt body user { name }";
|
|
1859
|
+
var NOTES = `pageInfo { hasNextPage endCursor } nodes { ${NOTE} }`;
|
|
1860
|
+
var RELATION = `type issue { identifier title url state { name type } comments(first: 50) { ${NOTES} } }`;
|
|
1789
1861
|
var BRIEF_QUERY = `
|
|
1790
1862
|
query Brief($id: String!) {
|
|
1791
1863
|
issue(id: $id) {
|
|
@@ -1793,33 +1865,28 @@ var BRIEF_QUERY = `
|
|
|
1793
1865
|
state { name type }
|
|
1794
1866
|
parent { identifier title url }
|
|
1795
1867
|
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
|
-
}
|
|
1868
|
+
inverseRelations(first: 25) { pageInfo { hasNextPage endCursor } nodes { ${RELATION} } }
|
|
1800
1869
|
}
|
|
1801
1870
|
}`;
|
|
1871
|
+
var MORE_NOTES = { field: "comments", nodes: NOTE, operation: "MoreBriefComments", what: "comments" };
|
|
1872
|
+
var MORE_RELATIONS = {
|
|
1873
|
+
field: "inverseRelations",
|
|
1874
|
+
nodes: RELATION,
|
|
1875
|
+
operation: "MoreBriefRelations",
|
|
1876
|
+
what: "relations",
|
|
1877
|
+
first: 25
|
|
1878
|
+
};
|
|
1802
1879
|
var noteUrl = (issueUrl, id) => `${issueUrl}#comment-${id.slice(0, 8)}`;
|
|
1803
1880
|
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
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
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 }));
|
|
1881
|
+
function normalizeBriefTicket(raw, warnings = []) {
|
|
1882
|
+
const blockers = raw.inverseRelations.nodes.filter((r) => r.type === "blocks").map(({ issue: b }) => ({
|
|
1883
|
+
id: b.identifier,
|
|
1884
|
+
title: b.title,
|
|
1885
|
+
url: b.url,
|
|
1886
|
+
status: b.state.name,
|
|
1887
|
+
statusType: b.state.type,
|
|
1888
|
+
notes: toNotes(b.url, b.comments)
|
|
1889
|
+
})).sort((a, b) => a.id.localeCompare(b.id, "en", { numeric: true }));
|
|
1823
1890
|
return {
|
|
1824
1891
|
id: raw.identifier,
|
|
1825
1892
|
title: raw.title,
|
|
@@ -1840,7 +1907,16 @@ async function fetchBriefTicket(opts, id) {
|
|
|
1840
1907
|
return { issue: null };
|
|
1841
1908
|
throw err;
|
|
1842
1909
|
});
|
|
1843
|
-
|
|
1910
|
+
const raw = data.issue;
|
|
1911
|
+
if (!raw)
|
|
1912
|
+
return null;
|
|
1913
|
+
const warnings = [];
|
|
1914
|
+
await readRest(opts, raw.identifier, MORE_NOTES, raw.comments, warnings);
|
|
1915
|
+
await readRest(opts, raw.identifier, MORE_RELATIONS, raw.inverseRelations, warnings);
|
|
1916
|
+
for (const r of raw.inverseRelations.nodes)
|
|
1917
|
+
if (r.type === "blocks")
|
|
1918
|
+
await readRest(opts, r.issue.identifier, MORE_NOTES, r.issue.comments, warnings);
|
|
1919
|
+
return normalizeBriefTicket(raw, warnings);
|
|
1844
1920
|
}
|
|
1845
1921
|
function handBackNote(notes) {
|
|
1846
1922
|
const withStatus = notes.filter((n) => parseStatusLine(n.body));
|
|
@@ -1857,7 +1933,7 @@ class BriefError extends Error {
|
|
|
1857
1933
|
}
|
|
1858
1934
|
function buildBrief(input) {
|
|
1859
1935
|
const { config, ticket, program } = input;
|
|
1860
|
-
const warnings = [...ticket.warnings, ...program.warnings];
|
|
1936
|
+
const warnings = [...new Set([...ticket.warnings, ...program.warnings])];
|
|
1861
1937
|
const choice = resolveProfile(config, input.profile);
|
|
1862
1938
|
if (!choice.profile && choice.problem)
|
|
1863
1939
|
throw new BriefError(choice.problem);
|
|
@@ -2890,6 +2966,13 @@ var MIGRATIONS = [
|
|
|
2890
2966
|
PRIMARY KEY (project, name)
|
|
2891
2967
|
)`
|
|
2892
2968
|
]
|
|
2969
|
+
},
|
|
2970
|
+
{
|
|
2971
|
+
version: 2,
|
|
2972
|
+
statements: [
|
|
2973
|
+
"CREATE INDEX IF NOT EXISTS events_by_time ON events (project, created_at)",
|
|
2974
|
+
"CREATE INDEX IF NOT EXISTS events_by_kind ON events (project, kind, created_at)"
|
|
2975
|
+
]
|
|
2893
2976
|
}
|
|
2894
2977
|
];
|
|
2895
2978
|
var SCHEMA_VERSION = MIGRATIONS.at(-1)?.version ?? 0;
|
|
@@ -2988,7 +3071,7 @@ async function recordEvent(db, e) {
|
|
|
2988
3071
|
}
|
|
2989
3072
|
async function lastEventTimes(db, project) {
|
|
2990
3073
|
const rs = await db.execute({
|
|
2991
|
-
sql: "SELECT ticket, max(created_at) AS at FROM events WHERE project = ? GROUP BY ticket",
|
|
3074
|
+
sql: "SELECT ticket, max(created_at) AS at FROM events WHERE project = ? AND ticket <> '' GROUP BY ticket",
|
|
2992
3075
|
args: [project]
|
|
2993
3076
|
});
|
|
2994
3077
|
return Object.fromEntries(rs.rows.map((r) => [String(r.ticket), String(r.at)]));
|
|
@@ -3859,6 +3942,29 @@ function outcome(c, merged, pr, lines, workers, archive) {
|
|
|
3859
3942
|
warnings: c.warnings
|
|
3860
3943
|
};
|
|
3861
3944
|
}
|
|
3945
|
+
// ../core/src/projects.ts
|
|
3946
|
+
var message = (err) => err instanceof Error ? err.message : String(err);
|
|
3947
|
+
async function readProjectConfig(p, opts) {
|
|
3948
|
+
const fallback = (why) => ({
|
|
3949
|
+
config: parseConfig(configTemplate(p), `registry record ${p.slug}`),
|
|
3950
|
+
warning: `${CONFIG_FILE} not read (${why}); using the registry record with default labels and policy`
|
|
3951
|
+
});
|
|
3952
|
+
if (!opts.githubToken)
|
|
3953
|
+
return fallback("no GitHub token");
|
|
3954
|
+
try {
|
|
3955
|
+
const text = await fetchDefaultBranchFile({
|
|
3956
|
+
token: opts.githubToken,
|
|
3957
|
+
repository: p.repository,
|
|
3958
|
+
path: CONFIG_FILE,
|
|
3959
|
+
...opts.fetch ? { fetch: opts.fetch } : {}
|
|
3960
|
+
});
|
|
3961
|
+
if (text === null)
|
|
3962
|
+
return fallback(`not on the default branch of ${p.repository}`);
|
|
3963
|
+
return { config: parseConfig(text, `${p.repository}:${CONFIG_FILE}`), warning: null };
|
|
3964
|
+
} catch (err) {
|
|
3965
|
+
return fallback(message(err));
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3862
3968
|
// ../core/src/skills.ts
|
|
3863
3969
|
import { createHash } from "node:crypto";
|
|
3864
3970
|
|
|
@@ -3968,11 +4074,11 @@ var SKILLS_LOCK_FILE = "skills-lock.json";
|
|
|
3968
4074
|
var CONDUCTOR_SETTINGS = ".conductor/settings.toml";
|
|
3969
4075
|
var GITIGNORE = ".gitignore";
|
|
3970
4076
|
var SHIP_ARTIFACTS = "plans/ship-pr-dev/";
|
|
3971
|
-
var ok = (id,
|
|
3972
|
-
var bad = (id, level,
|
|
4077
|
+
var ok = (id, message2) => ({ id, level: "ok", message: message2, fix: null });
|
|
4078
|
+
var bad = (id, level, message2, fix) => ({
|
|
3973
4079
|
id,
|
|
3974
4080
|
level,
|
|
3975
|
-
message,
|
|
4081
|
+
message: message2,
|
|
3976
4082
|
fix
|
|
3977
4083
|
});
|
|
3978
4084
|
var skillDir = (name) => `${AGENTS_SKILLS_DIR}/${name}`;
|
|
@@ -4197,6 +4303,7 @@ function buildStatus({
|
|
|
4197
4303
|
forge,
|
|
4198
4304
|
forgeError = null,
|
|
4199
4305
|
lastEvents,
|
|
4306
|
+
live: live2,
|
|
4200
4307
|
extraWarnings = [],
|
|
4201
4308
|
now
|
|
4202
4309
|
}) {
|
|
@@ -4205,7 +4312,8 @@ function buildStatus({
|
|
|
4205
4312
|
const lanes = inFlight(m, program.comments, {
|
|
4206
4313
|
now: now.getTime(),
|
|
4207
4314
|
silentAfterMinutes: config.policy.silentAfterMinutes,
|
|
4208
|
-
...lastEvents ? { lastEvents } : {}
|
|
4315
|
+
...lastEvents ? { lastEvents } : {},
|
|
4316
|
+
...live2 ? { live: live2 } : {}
|
|
4209
4317
|
});
|
|
4210
4318
|
const phaseOf = new Map(lanes.map((l) => [l.issue.id, l.phase]));
|
|
4211
4319
|
const prRef = (p) => ({
|
|
@@ -4234,6 +4342,7 @@ function buildStatus({
|
|
|
4234
4342
|
phase: l.phase,
|
|
4235
4343
|
phaseSource: l.phaseSource,
|
|
4236
4344
|
runtime: l.runtime,
|
|
4345
|
+
handle: l.handle,
|
|
4237
4346
|
agent: l.agent,
|
|
4238
4347
|
since: l.since,
|
|
4239
4348
|
lastUpdate: l.lastUpdate,
|
|
@@ -4244,7 +4353,7 @@ function buildStatus({
|
|
|
4244
4353
|
openBlockers: l.openBlockers,
|
|
4245
4354
|
flags: l.flags
|
|
4246
4355
|
})),
|
|
4247
|
-
frontier: frontier(m, config.tracker.readyLabel).map((c) => ({
|
|
4356
|
+
frontier: frontier(m, config.tracker.readyLabel).filter((c) => !phaseOf.has(c.issue.id)).map((c) => ({
|
|
4248
4357
|
id: c.issue.id,
|
|
4249
4358
|
title: c.issue.title,
|
|
4250
4359
|
url: c.issue.url,
|
|
@@ -4263,7 +4372,7 @@ function buildStatus({
|
|
|
4263
4372
|
warnings: [...program.warnings, ...forge?.warnings ?? [], ...extraWarnings]
|
|
4264
4373
|
};
|
|
4265
4374
|
}
|
|
4266
|
-
async function
|
|
4375
|
+
async function readStatusSources(config, opts) {
|
|
4267
4376
|
const now = opts.now ?? (() => new Date);
|
|
4268
4377
|
const programP = fetchProgram({
|
|
4269
4378
|
apiKey: opts.linearApiKey,
|
|
@@ -4277,23 +4386,28 @@ async function loadStatus(config, opts) {
|
|
|
4277
4386
|
repository: config.github.repository,
|
|
4278
4387
|
...opts.fetch ? { fetch: opts.fetch } : {},
|
|
4279
4388
|
now
|
|
4280
|
-
}).then((forge2) => ({ forge: forge2,
|
|
4389
|
+
}).then((forge2) => ({ forge: forge2, forgeError: null }), (err) => ({ forge: null, forgeError: err instanceof Error ? err.message : String(err) })) : Promise.resolve({ forge: null, forgeError: "no GitHub token (set GITHUB_TOKEN or run gh auth login)" });
|
|
4390
|
+
const [program, forge] = await Promise.all([programP, forgeP]);
|
|
4391
|
+
return { program, ...forge };
|
|
4392
|
+
}
|
|
4393
|
+
async function loadStatus(config, opts) {
|
|
4394
|
+
const now = opts.now ?? (() => new Date);
|
|
4281
4395
|
const eventsP = opts.lastEvents ? opts.lastEvents().then((events2) => ({ events: events2 }), (err) => ({
|
|
4282
4396
|
warning: `Turso could not be read (${err instanceof Error ? err.message : String(err)}); silence is measured from Linear only`
|
|
4283
4397
|
})) : Promise.resolve({});
|
|
4284
|
-
const [program,
|
|
4398
|
+
const [{ program, forge, forgeError }, events] = await Promise.all([readStatusSources(config, opts), eventsP]);
|
|
4285
4399
|
return buildStatus({
|
|
4286
4400
|
config,
|
|
4287
4401
|
program,
|
|
4288
4402
|
forge,
|
|
4289
|
-
forgeError
|
|
4403
|
+
forgeError,
|
|
4290
4404
|
...events.events ? { lastEvents: events.events } : {},
|
|
4291
4405
|
extraWarnings: events.warning ? [events.warning] : [],
|
|
4292
4406
|
now: now()
|
|
4293
4407
|
});
|
|
4294
4408
|
}
|
|
4295
4409
|
// package.json
|
|
4296
|
-
var version = "0.1.
|
|
4410
|
+
var version = "0.1.6";
|
|
4297
4411
|
|
|
4298
4412
|
// src/io.ts
|
|
4299
4413
|
class UsageError extends Error {
|
|
@@ -5040,20 +5154,20 @@ async function report(io, config2, credentials2, a) {
|
|
|
5040
5154
|
throw new UsageError(`unexpected argument ${extra[0]}`);
|
|
5041
5155
|
if (a.options.message !== undefined && a.options["message-file"] !== undefined)
|
|
5042
5156
|
throw new UsageError("pass --message or --message-file, not both");
|
|
5043
|
-
let
|
|
5157
|
+
let message2 = a.options.message ?? null;
|
|
5044
5158
|
const file = a.options["message-file"];
|
|
5045
5159
|
if (file !== undefined) {
|
|
5046
|
-
|
|
5047
|
-
if (
|
|
5160
|
+
message2 = file === "-" ? await io.readStdin?.() ?? null : await io.readFile(file);
|
|
5161
|
+
if (message2 === null)
|
|
5048
5162
|
throw new UsageError(`cannot read the message from ${file}`);
|
|
5049
5163
|
}
|
|
5050
|
-
if (!
|
|
5164
|
+
if (!message2?.trim() && phase !== "ready-to-merge")
|
|
5051
5165
|
throw new UsageError("--message is required: what you did or what you are doing (first line = summary)");
|
|
5052
5166
|
const ticket = currentTicket(io, config2, a.options.ticket);
|
|
5053
5167
|
return withContext(io, config2, credentials2, a.json, (ctx) => reportPhase(ctx, {
|
|
5054
5168
|
ticket,
|
|
5055
5169
|
phase,
|
|
5056
|
-
message,
|
|
5170
|
+
message: message2,
|
|
5057
5171
|
pr: a.options.pr ?? null,
|
|
5058
5172
|
sha: a.options.sha ?? null
|
|
5059
5173
|
}));
|
|
@@ -5078,9 +5192,9 @@ function ghMerge(exec, cwd, repository) {
|
|
|
5078
5192
|
const args = ["pr", "merge", String(number), "--repo", repository, "--squash", "--match-head-commit", sha];
|
|
5079
5193
|
try {
|
|
5080
5194
|
const r = await exec("gh", args, { cwd });
|
|
5081
|
-
const
|
|
5195
|
+
const message2 = tail(`${r.stderr}
|
|
5082
5196
|
${r.stdout}`.trim(), 5) || `gh exited with ${r.code}`;
|
|
5083
|
-
return { ok: r.code === 0, message, transient: r.code !== 0 && TRANSIENT.test(
|
|
5197
|
+
return { ok: r.code === 0, message: message2, transient: r.code !== 0 && TRANSIENT.test(message2) };
|
|
5084
5198
|
} catch (err) {
|
|
5085
5199
|
return {
|
|
5086
5200
|
ok: false,
|
|
@@ -5358,28 +5472,7 @@ function renderStatus(r) {
|
|
|
5358
5472
|
}
|
|
5359
5473
|
|
|
5360
5474
|
// src/projects.ts
|
|
5361
|
-
var
|
|
5362
|
-
async function projectConfig(p, githubToken, io) {
|
|
5363
|
-
const fallback = (why) => ({
|
|
5364
|
-
config: parseConfig(configTemplate(p), `registry record ${p.slug}`),
|
|
5365
|
-
warning: `${CONFIG_FILE} not read (${why}); using the registry record with default labels and policy`
|
|
5366
|
-
});
|
|
5367
|
-
if (!githubToken)
|
|
5368
|
-
return fallback("no GitHub token");
|
|
5369
|
-
try {
|
|
5370
|
-
const text = await fetchDefaultBranchFile({
|
|
5371
|
-
token: githubToken,
|
|
5372
|
-
repository: p.repository,
|
|
5373
|
-
path: CONFIG_FILE,
|
|
5374
|
-
...io.fetch ? { fetch: io.fetch } : {}
|
|
5375
|
-
});
|
|
5376
|
-
if (text === null)
|
|
5377
|
-
return fallback(`not on the default branch of ${p.repository}`);
|
|
5378
|
-
return { config: parseConfig(text, `${p.repository}:${CONFIG_FILE}`), warning: null };
|
|
5379
|
-
} catch (err) {
|
|
5380
|
-
return fallback(message(err));
|
|
5381
|
-
}
|
|
5382
|
-
}
|
|
5475
|
+
var message2 = (err) => err instanceof Error ? err.message : String(err);
|
|
5383
5476
|
async function statusAll(io, json) {
|
|
5384
5477
|
const { credentials: credentials2 } = await loadCredentials(io);
|
|
5385
5478
|
const linearApiKey = credentials2.linearApiKey;
|
|
@@ -5395,11 +5488,14 @@ async function statusAll(io, json) {
|
|
|
5395
5488
|
} finally {
|
|
5396
5489
|
db.close();
|
|
5397
5490
|
}
|
|
5398
|
-
const
|
|
5491
|
+
const projects2 = await Promise.all(records.map(async (p) => {
|
|
5399
5492
|
const base = { slug: p.slug, name: p.name, repository: p.repository };
|
|
5400
5493
|
let warning = null;
|
|
5401
5494
|
try {
|
|
5402
|
-
const read = await
|
|
5495
|
+
const read = await readProjectConfig(p, {
|
|
5496
|
+
githubToken: credentials2.githubToken,
|
|
5497
|
+
...io.fetch ? { fetch: io.fetch } : {}
|
|
5498
|
+
});
|
|
5403
5499
|
warning = read.warning;
|
|
5404
5500
|
const config2 = read.config;
|
|
5405
5501
|
const report2 = await loadStatus(config2, {
|
|
@@ -5410,17 +5506,17 @@ async function statusAll(io, json) {
|
|
|
5410
5506
|
});
|
|
5411
5507
|
return { ...base, report: report2, error: null, configWarning: warning };
|
|
5412
5508
|
} catch (err) {
|
|
5413
|
-
return { ...base, report: null, error:
|
|
5509
|
+
return { ...base, report: null, error: message2(err), configWarning: warning };
|
|
5414
5510
|
}
|
|
5415
5511
|
}));
|
|
5416
|
-
const all = { schemaVersion: 1, projects };
|
|
5512
|
+
const all = { schemaVersion: 1, projects: projects2 };
|
|
5417
5513
|
if (json)
|
|
5418
5514
|
io.stdout(`${JSON.stringify(all, null, 2)}
|
|
5419
5515
|
`);
|
|
5420
|
-
else if (!
|
|
5516
|
+
else if (!projects2.length)
|
|
5421
5517
|
io.stdout("No project is registered yet. Run `armada init` in a repository to register it.\n");
|
|
5422
5518
|
else
|
|
5423
|
-
io.stdout(
|
|
5519
|
+
io.stdout(projects2.map((p) => {
|
|
5424
5520
|
if (!p.report)
|
|
5425
5521
|
return `${p.name} (${p.slug}) · ${p.repository}
|
|
5426
5522
|
! not read: ${p.error}
|
|
@@ -5432,7 +5528,7 @@ ${p.configWarning ? ` ! ${p.configWarning}
|
|
|
5432
5528
|
${"─".repeat(60)}
|
|
5433
5529
|
|
|
5434
5530
|
`));
|
|
5435
|
-
return
|
|
5531
|
+
return projects2.some((p) => p.error) ? 1 : 0;
|
|
5436
5532
|
}
|
|
5437
5533
|
|
|
5438
5534
|
// src/cli.ts
|