@dadado/agent-kit-cli 6.8.0 → 6.9.0
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/dashboard/README.md +16 -6
- package/dashboard/dashboard-data.mjs +237 -3
- package/dashboard/dashboard.html +398 -74
- package/dashboard/lib/ship-lane.mjs +690 -0
- package/dashboard/serve.mjs +19 -0
- package/dist/index.js +2 -2
- package/dist/{run-DXGTFYJK.js → run-VOVR5O7S.js} +32 -9
- package/package.json +1 -1
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ship lane signal for the Git e CI/CD section (ADR 2026-10-23
|
|
3
|
+
* git-cicd-tab-read-in-mc-act-in-colony, points 2, 3, 6 and 7).
|
|
4
|
+
*
|
|
5
|
+
* Read-only. One `gh api graphql` call fetches the forge half (open PRs with
|
|
6
|
+
* mergeable state and check rollups, the latest tag's CI jobs, GitHub Release
|
|
7
|
+
* Latest, and, in the factory lane, the public repo's release and sync PRs);
|
|
8
|
+
* one registry fetch reads the npm version. Local git facts (latest v* tag,
|
|
9
|
+
* manifest version, staging vs main) are recomputed on every snapshot, so the
|
|
10
|
+
* rows stay current while the network half is cached between snapshots the
|
|
11
|
+
* way pipeline-cache.mjs does it for `gh run list`.
|
|
12
|
+
*
|
|
13
|
+
* Forge text (PR titles, branch names, check names) is untrusted input: it is
|
|
14
|
+
* capped here and the panel renders it through textContent / escaping only.
|
|
15
|
+
* Rows carry copy-only next commands (`kind: "copy"` in the panel); nothing in
|
|
16
|
+
* this module runs a mutating command.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { truncateStr } from "./guards.mjs";
|
|
20
|
+
|
|
21
|
+
export const SHIP_LANE_CACHE_ENV = "AGENT_KIT_PREV_SHIP_LANE";
|
|
22
|
+
/**
|
|
23
|
+
* Twice the pipeline TTL: ship state moves on human merges and tag CI jobs
|
|
24
|
+
* (minutes), not on the few-second snapshot cadence, and one GraphQL call
|
|
25
|
+
* per two minutes keeps the forge load flat while a release is watched.
|
|
26
|
+
*/
|
|
27
|
+
export const SHIP_LANE_CACHE_TTL_MS = 120_000;
|
|
28
|
+
/** Measured 2026-10-23 on this repo: about 1.2s for the full query. */
|
|
29
|
+
export const SHIP_LANE_GH_TIMEOUT_MS = 8_000;
|
|
30
|
+
export const SHIP_LANE_NPM_TIMEOUT_MS = 4_000;
|
|
31
|
+
/** Public storefront of the factory checkout (same constant as public-inbound-radar.ts). */
|
|
32
|
+
export const FACTORY_PUBLIC_REPO = "agent-kit-startup/agent-kit";
|
|
33
|
+
|
|
34
|
+
export const MAX_SHIP_LANE_PRS = 15;
|
|
35
|
+
const MAX_PR_TITLE_CHARS = 120;
|
|
36
|
+
const MAX_BRANCH_CHARS = 100;
|
|
37
|
+
const MAX_CHECK_NAME_CHARS = 60;
|
|
38
|
+
const MAX_FAILING_CHECKS = 8;
|
|
39
|
+
const MAX_TAG_JOBS = 12;
|
|
40
|
+
const MAX_SYNC_PRS = 5;
|
|
41
|
+
const MAX_REASON_CHARS = 80;
|
|
42
|
+
|
|
43
|
+
/** Signature scan check name (errors/2026-10-05_git-prod-signature-gate-merged-staging-commit.md). */
|
|
44
|
+
const SIGNATURE_SCAN_CHECK = "signature-scan";
|
|
45
|
+
const FAILING_CONCLUSIONS = new Set([
|
|
46
|
+
"failure",
|
|
47
|
+
"cancelled",
|
|
48
|
+
"timed_out",
|
|
49
|
+
"action_required",
|
|
50
|
+
"startup_failure",
|
|
51
|
+
]);
|
|
52
|
+
const PASSING_CONCLUSIONS = new Set(["success", "neutral", "skipped"]);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Provider and slug of a remote URL. Same host rule as remote-issues.ts
|
|
56
|
+
* parseRemoteUrl: a gitlab host (or git.<domain>) is gitlab, anything else github.
|
|
57
|
+
* @param {string | null | undefined} url
|
|
58
|
+
* @returns {{ provider: "github" | "gitlab", host: string, owner: string, name: string, slug: string } | null}
|
|
59
|
+
*/
|
|
60
|
+
export function parseForgeRemote(url) {
|
|
61
|
+
if (!url || typeof url !== "string") return null;
|
|
62
|
+
const trimmed = url.trim();
|
|
63
|
+
const m =
|
|
64
|
+
trimmed.match(/^[a-z+]+:\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/i) ||
|
|
65
|
+
trimmed.match(/^(?:[^@/]+@)?([^/:]+):(.+?)(?:\.git)?\/?$/);
|
|
66
|
+
if (!m) return null;
|
|
67
|
+
const host = m[1].toLowerCase();
|
|
68
|
+
const parts = m[2].split("/").filter(Boolean);
|
|
69
|
+
if (parts.length < 2) return null;
|
|
70
|
+
const name = parts[parts.length - 1];
|
|
71
|
+
const owner = parts.slice(0, -1).join("/");
|
|
72
|
+
if (!/^[\w.-]+(?:\/[\w.-]+)*$/.test(owner) || !/^[\w.-]+$/.test(name)) return null;
|
|
73
|
+
const provider = /gitlab|(^|\.)git\.[^.]+\./i.test(host) ? "gitlab" : "github";
|
|
74
|
+
return { provider, host, owner, name, slug: `${owner}/${name}` };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A v* tag name that is safe to put in a copyable shell command. Git allows
|
|
79
|
+
* `;`, `$`, `|`, `&`, backticks and quotes in ref names, and tags arrive from
|
|
80
|
+
* the remote, so anything outside this set is dropped rather than quoted
|
|
81
|
+
* (security pass p4, 2026-10-23).
|
|
82
|
+
* @param {unknown} name
|
|
83
|
+
* @returns {string | null}
|
|
84
|
+
*/
|
|
85
|
+
export function safeTagName(name) {
|
|
86
|
+
return typeof name === "string" && /^v[0-9A-Za-z][0-9A-Za-z._+-]{0,62}$/.test(name) ? name : null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** npm package name (lowercase, optional scope) safe for `npm view <name>`; else null. */
|
|
90
|
+
export function safeNpmName(name) {
|
|
91
|
+
return typeof name === "string" &&
|
|
92
|
+
name.length <= 214 &&
|
|
93
|
+
/^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/.test(name)
|
|
94
|
+
? name
|
|
95
|
+
: null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Factory checkout: origin is the private agent-kit-dev repo (detectFactoryCheckout rule). */
|
|
99
|
+
export function isFactorySlug(slug) {
|
|
100
|
+
return typeof slug === "string" && /agent-kit-dev$/i.test(slug);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const SHIP_LANE_QUERY = `query($owner:String!,$name:String!,$tag:String!,$withPublic:Boolean!,$pubOwner:String!,$pubName:String!){
|
|
104
|
+
repo: repository(owner:$owner,name:$name){
|
|
105
|
+
pullRequests(states:OPEN,first:${MAX_SHIP_LANE_PRS},orderBy:{field:UPDATED_AT,direction:DESC}){
|
|
106
|
+
totalCount
|
|
107
|
+
nodes{ number title isDraft baseRefName headRefName mergeable mergeStateStatus
|
|
108
|
+
commits(last:1){ nodes{ commit{ statusCheckRollup{ state contexts(first:40){ nodes{ __typename ... on CheckRun{ name status conclusion } ... on StatusContext{ context state } } } } } } } }
|
|
109
|
+
}
|
|
110
|
+
latestRelease{ tagName publishedAt }
|
|
111
|
+
tag: ref(qualifiedName:$tag){ name target{ __typename ... on Commit{ ...suites } ... on Tag{ target{ ... on Commit{ ...suites } } } } }
|
|
112
|
+
}
|
|
113
|
+
pub: repository(owner:$pubOwner,name:$pubName) @include(if:$withPublic){
|
|
114
|
+
latestRelease{ tagName publishedAt }
|
|
115
|
+
pullRequests(states:[OPEN,MERGED],last:${MAX_SYNC_PRS}){ nodes{ number title state mergedAt } }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
fragment suites on Commit{ checkSuites(first:12){ nodes{ workflowRun{ databaseId event workflow{ name } } checkRuns(first:20){ nodes{ name status conclusion } } } } }`;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* argv for `gh` (no shell; values are validated slugs and a v* tag name).
|
|
122
|
+
* @param {{ owner: string, name: string, tag: string | null, publicRepo: string | null }} p
|
|
123
|
+
*/
|
|
124
|
+
export function shipLaneGhArgs({ owner, name, tag, publicRepo }) {
|
|
125
|
+
const [pubOwner, pubName] = publicRepo ? publicRepo.split("/") : ["_", "_"];
|
|
126
|
+
return [
|
|
127
|
+
"api",
|
|
128
|
+
"graphql",
|
|
129
|
+
"-f",
|
|
130
|
+
`query=${SHIP_LANE_QUERY}`,
|
|
131
|
+
"-F",
|
|
132
|
+
`owner=${owner}`,
|
|
133
|
+
"-F",
|
|
134
|
+
`name=${name}`,
|
|
135
|
+
"-F",
|
|
136
|
+
`tag=refs/tags/${tag || "__no_tag__"}`,
|
|
137
|
+
"-F",
|
|
138
|
+
`withPublic=${publicRepo ? "true" : "false"}`,
|
|
139
|
+
"-F",
|
|
140
|
+
`pubOwner=${pubOwner}`,
|
|
141
|
+
"-F",
|
|
142
|
+
`pubName=${pubName}`,
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const lower = (v) => (typeof v === "string" && v ? v.toLowerCase() : null);
|
|
147
|
+
const capText = (v, n) => truncateStr(String(v ?? ""), n);
|
|
148
|
+
|
|
149
|
+
/** One check context (CheckRun or StatusContext) as {name, state: success|failure|pending}. */
|
|
150
|
+
function contextState(node) {
|
|
151
|
+
if (!node || typeof node !== "object") return null;
|
|
152
|
+
if (node.__typename === "StatusContext") {
|
|
153
|
+
const st = lower(node.state);
|
|
154
|
+
return {
|
|
155
|
+
name: capText(node.context, MAX_CHECK_NAME_CHARS),
|
|
156
|
+
state:
|
|
157
|
+
st === "success"
|
|
158
|
+
? "success"
|
|
159
|
+
: st === "pending" || st === "expected"
|
|
160
|
+
? "pending"
|
|
161
|
+
: "failure",
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const status = lower(node.status);
|
|
165
|
+
const conclusion = lower(node.conclusion);
|
|
166
|
+
let state = "pending";
|
|
167
|
+
if (status === "completed") {
|
|
168
|
+
if (FAILING_CONCLUSIONS.has(conclusion)) state = "failure";
|
|
169
|
+
else if (conclusion === "skipped") state = "skipped";
|
|
170
|
+
else if (PASSING_CONCLUSIONS.has(conclusion)) state = "success";
|
|
171
|
+
else state = "failure";
|
|
172
|
+
}
|
|
173
|
+
return { name: capText(node.name, MAX_CHECK_NAME_CHARS), state };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function trimPr(node) {
|
|
177
|
+
const rollup = node?.commits?.nodes?.[0]?.commit?.statusCheckRollup ?? null;
|
|
178
|
+
const contexts = (rollup?.contexts?.nodes ?? []).map(contextState).filter(Boolean);
|
|
179
|
+
const failing = contexts.filter((c) => c.state === "failure").map((c) => c.name);
|
|
180
|
+
const sig = contexts.find((c) => c.name === SIGNATURE_SCAN_CHECK);
|
|
181
|
+
return {
|
|
182
|
+
number: Number(node?.number) || 0,
|
|
183
|
+
title: capText(node?.title, MAX_PR_TITLE_CHARS),
|
|
184
|
+
base: capText(node?.baseRefName, MAX_BRANCH_CHARS),
|
|
185
|
+
head: capText(node?.headRefName, MAX_BRANCH_CHARS),
|
|
186
|
+
draft: node?.isDraft === true,
|
|
187
|
+
mergeable: lower(node?.mergeable),
|
|
188
|
+
mergeState: lower(node?.mergeStateStatus),
|
|
189
|
+
stackedOn: null,
|
|
190
|
+
checks: {
|
|
191
|
+
state: lower(rollup?.state),
|
|
192
|
+
total: contexts.length,
|
|
193
|
+
failing: failing.slice(0, MAX_FAILING_CHECKS),
|
|
194
|
+
pending: contexts.filter((c) => c.state === "pending").length,
|
|
195
|
+
signatureScan: sig ? sig.state : "missing",
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The tag's own CI run: among push-event suites, the one with the most non-skipped jobs. */
|
|
201
|
+
function trimTagCi(tagRef) {
|
|
202
|
+
const commit = tagRef?.target?.__typename === "Tag" ? tagRef.target.target : tagRef?.target;
|
|
203
|
+
const suites = commit?.checkSuites?.nodes ?? [];
|
|
204
|
+
let best = null;
|
|
205
|
+
let bestScore = -1;
|
|
206
|
+
for (const suite of suites) {
|
|
207
|
+
if (lower(suite?.workflowRun?.event) !== "push") continue;
|
|
208
|
+
const jobs = (suite.checkRuns?.nodes ?? []).map(contextState).filter(Boolean);
|
|
209
|
+
const score = jobs.filter((j) => j.state !== "skipped").length;
|
|
210
|
+
if (jobs.length && score >= bestScore) {
|
|
211
|
+
best = { suite, jobs };
|
|
212
|
+
bestScore = score;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (!best) return null;
|
|
216
|
+
const runId = Number(best.suite.workflowRun?.databaseId);
|
|
217
|
+
return {
|
|
218
|
+
workflow: capText(best.suite.workflowRun?.workflow?.name, MAX_CHECK_NAME_CHARS),
|
|
219
|
+
runId: Number.isSafeInteger(runId) && runId > 0 ? runId : null,
|
|
220
|
+
jobs: best.jobs.slice(0, MAX_TAG_JOBS),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function trimRelease(release) {
|
|
225
|
+
if (!release || typeof release.tagName !== "string") return null;
|
|
226
|
+
return {
|
|
227
|
+
tag: capText(release.tagName, 64),
|
|
228
|
+
publishedAt: typeof release.publishedAt === "string" ? release.publishedAt : null,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Trimmed, capped forge half from the GraphQL response (untrusted input).
|
|
234
|
+
* @param {unknown} json parsed `gh api graphql` stdout
|
|
235
|
+
* @param {{ repo: string, tag: string | null, publicRepo: string | null, fetchedAt: string }} meta
|
|
236
|
+
*/
|
|
237
|
+
export function trimShipLaneGraphql(json, { repo: repoSlug, tag, publicRepo, fetchedAt }) {
|
|
238
|
+
const data = json && typeof json === "object" ? json.data : null;
|
|
239
|
+
const repo = data?.repo;
|
|
240
|
+
if (!repo || typeof repo !== "object") return null;
|
|
241
|
+
const prs = (repo.pullRequests?.nodes ?? []).slice(0, MAX_SHIP_LANE_PRS).map(trimPr);
|
|
242
|
+
const byHead = new Map(prs.map((p) => [p.head, p.number]));
|
|
243
|
+
for (const pr of prs) pr.stackedOn = byHead.get(pr.base) ?? null;
|
|
244
|
+
const pub = data?.pub;
|
|
245
|
+
return {
|
|
246
|
+
available: true,
|
|
247
|
+
fetchedAt,
|
|
248
|
+
repo: repoSlug,
|
|
249
|
+
tag: tag || null,
|
|
250
|
+
publicRepo: publicRepo || null,
|
|
251
|
+
prs,
|
|
252
|
+
prsTotal: Number(repo.pullRequests?.totalCount) || prs.length,
|
|
253
|
+
originRelease: trimRelease(repo.latestRelease),
|
|
254
|
+
tagCi: tag ? trimTagCi(repo.tag) : null,
|
|
255
|
+
public:
|
|
256
|
+
publicRepo && pub
|
|
257
|
+
? {
|
|
258
|
+
release: trimRelease(pub.latestRelease),
|
|
259
|
+
syncPrs: (pub.pullRequests?.nodes ?? []).slice(-MAX_SYNC_PRS).map((p) => ({
|
|
260
|
+
number: Number(p?.number) || 0,
|
|
261
|
+
title: capText(p?.title, MAX_PR_TITLE_CHARS),
|
|
262
|
+
state: lower(p?.state),
|
|
263
|
+
mergedAt: typeof p?.mergedAt === "string" ? p.mergedAt : null,
|
|
264
|
+
})),
|
|
265
|
+
}
|
|
266
|
+
: null,
|
|
267
|
+
npm: null,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Reason for a failed `gh` attempt, from the execFile error shape.
|
|
273
|
+
* @param {any} err
|
|
274
|
+
* @param {string} [stderr]
|
|
275
|
+
*/
|
|
276
|
+
export function classifyGhFailure(err, stderr = "") {
|
|
277
|
+
if (err?.code === "ENOENT") return "gh-missing";
|
|
278
|
+
if (err?.killed || err?.signal === "SIGTERM") return "timeout";
|
|
279
|
+
if (/auth login|not logged in|authenticat/i.test(String(stderr))) return "gh-auth";
|
|
280
|
+
return "call-failed";
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Human note for an unavailable forge half (the remote issues lane wording). */
|
|
284
|
+
export function shipLaneReasonNote(reason) {
|
|
285
|
+
const notes = {
|
|
286
|
+
budget: "skipped: snapshot budget ran out before gh was attempted",
|
|
287
|
+
"gh-missing": "skipped: gh not installed",
|
|
288
|
+
"gh-auth": "skipped: gh not authenticated",
|
|
289
|
+
timeout: "skipped: gh timed out",
|
|
290
|
+
"call-failed": "skipped: gh call failed (offline or no access)",
|
|
291
|
+
"no-remote": "skipped: no origin remote",
|
|
292
|
+
"provider-unsupported": "skipped: glab support comes later (git provider is gitlab)",
|
|
293
|
+
};
|
|
294
|
+
return notes[reason] ?? `skipped: ${capText(reason, MAX_REASON_CHARS)}`;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function isCacheableRemote(remote) {
|
|
298
|
+
return (
|
|
299
|
+
!!remote &&
|
|
300
|
+
typeof remote === "object" &&
|
|
301
|
+
!Array.isArray(remote) &&
|
|
302
|
+
typeof remote.available === "boolean" &&
|
|
303
|
+
typeof remote.fetchedAt === "string" &&
|
|
304
|
+
Number.isFinite(Date.parse(remote.fetchedAt))
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Cached forge half from the env blob when younger than `ttlMs` and fetched
|
|
310
|
+
* for the same repo and tag; else null (a new tag invalidates it at once).
|
|
311
|
+
* @param {string | undefined} raw
|
|
312
|
+
* @param {number} nowMs
|
|
313
|
+
* @param {{ repo: string | null, tag: string | null }} key
|
|
314
|
+
* @param {number} [ttlMs]
|
|
315
|
+
*/
|
|
316
|
+
export function readCachedShipLaneRemote(raw, nowMs, key, ttlMs = SHIP_LANE_CACHE_TTL_MS) {
|
|
317
|
+
if (!raw || typeof raw !== "string") return null;
|
|
318
|
+
let parsed;
|
|
319
|
+
try {
|
|
320
|
+
parsed = JSON.parse(raw);
|
|
321
|
+
} catch {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
if (!isCacheableRemote(parsed)) return null;
|
|
325
|
+
if ((parsed.repo ?? null) !== (key.repo ?? null)) return null;
|
|
326
|
+
if (parsed.available && (parsed.tag ?? null) !== (key.tag ?? null)) return null;
|
|
327
|
+
const age = nowMs - Date.parse(parsed.fetchedAt);
|
|
328
|
+
return age >= 0 && age < ttlMs ? parsed : null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Env blob for the next snapshot, or null to keep the prior one. */
|
|
332
|
+
export function shipLaneCacheJsonFromSnapshot(snapshot) {
|
|
333
|
+
const remote = snapshot?.shipLane?.remote;
|
|
334
|
+
return isCacheableRemote(remote) ? JSON.stringify(remote) : null;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const cmd = (text, destination = "terminal") => ({ text, destination });
|
|
338
|
+
|
|
339
|
+
function prCheckState(pr) {
|
|
340
|
+
if (pr.checks.failing.length || pr.mergeable === "conflicting") return "red";
|
|
341
|
+
return "pending";
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function prDetail(pr) {
|
|
345
|
+
const bits = [`#${pr.number} ${pr.head} → ${pr.base}`];
|
|
346
|
+
if (pr.checks.failing.length) bits.push(`failing: ${pr.checks.failing.join(", ")}`);
|
|
347
|
+
else if (pr.checks.pending) bits.push(`${pr.checks.pending} check(s) running`);
|
|
348
|
+
if (pr.mergeable === "conflicting") bits.push("conflicts");
|
|
349
|
+
else if (pr.mergeState) bits.push(pr.mergeState);
|
|
350
|
+
return bits.join(" · ");
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* The /kit-prod §5 Done rows (or the generic /git-prod subset in a consumer
|
|
355
|
+
* repo), each green / red / pending / unknown with one copyable next command.
|
|
356
|
+
* @param {{ lane: "factory" | "consumer", repo: string | null, publicRepo: string | null,
|
|
357
|
+
* local: { latestTag: string | null, version: string | null, mainRef: string | null,
|
|
358
|
+
* stagingAheadOfMain: number | null, mainInStaging: boolean | null, tagOnMain: boolean | null },
|
|
359
|
+
* remote: any }} input
|
|
360
|
+
*/
|
|
361
|
+
export function buildShipLaneRows({ lane, repo, publicRepo, local, remote }) {
|
|
362
|
+
const slash = lane === "factory" ? "/kit-prod" : "/git-prod";
|
|
363
|
+
const tag = local.latestTag;
|
|
364
|
+
const tagVersion = tag ? tag.replace(/^v/, "") : null;
|
|
365
|
+
const forgeUp = remote?.available === true;
|
|
366
|
+
const forgeNote = forgeUp ? null : shipLaneReasonNote(remote?.reason ?? "call-failed");
|
|
367
|
+
const prs = forgeUp ? remote.prs : [];
|
|
368
|
+
const mainBase = local.mainRef ? local.mainRef.replace(/^origin\//, "") : "main";
|
|
369
|
+
const rows = [];
|
|
370
|
+
|
|
371
|
+
// 1. Release close (manifests bumped, close PR into staging).
|
|
372
|
+
const closePr = prs.find((p) => /close-release/i.test(p.head));
|
|
373
|
+
if (closePr) {
|
|
374
|
+
rows.push({
|
|
375
|
+
id: "release-close",
|
|
376
|
+
label: "Release close",
|
|
377
|
+
state: prCheckState(closePr),
|
|
378
|
+
detail: prDetail(closePr),
|
|
379
|
+
next: cmd(`gh pr checks ${closePr.number}`),
|
|
380
|
+
});
|
|
381
|
+
} else if (!local.version) {
|
|
382
|
+
rows.push({
|
|
383
|
+
id: "release-close",
|
|
384
|
+
label: "Release close",
|
|
385
|
+
state: "unknown",
|
|
386
|
+
detail: "no manifest version",
|
|
387
|
+
next: null,
|
|
388
|
+
});
|
|
389
|
+
} else if (tagVersion !== local.version) {
|
|
390
|
+
rows.push({
|
|
391
|
+
id: "release-close",
|
|
392
|
+
label: "Release close",
|
|
393
|
+
state: "green",
|
|
394
|
+
detail: `v${local.version} closed`,
|
|
395
|
+
next: null,
|
|
396
|
+
});
|
|
397
|
+
} else if ((local.stagingAheadOfMain ?? 0) > 0) {
|
|
398
|
+
rows.push({
|
|
399
|
+
id: "release-close",
|
|
400
|
+
label: "Release close",
|
|
401
|
+
state: "pending",
|
|
402
|
+
detail: `staging is ${local.stagingAheadOfMain} commit(s) ahead of ${mainBase}; next release not closed`,
|
|
403
|
+
next: cmd(slash, "agent chat input"),
|
|
404
|
+
});
|
|
405
|
+
} else {
|
|
406
|
+
rows.push({
|
|
407
|
+
id: "release-close",
|
|
408
|
+
label: "Release close",
|
|
409
|
+
state: "green",
|
|
410
|
+
detail: `v${local.version} shipped; nothing to close`,
|
|
411
|
+
next: null,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// 2. Staging -> main PR.
|
|
416
|
+
const promotePr = prs.find(
|
|
417
|
+
(p) => p.head === "staging" && (p.base === "main" || p.base === "master"),
|
|
418
|
+
);
|
|
419
|
+
if (promotePr) {
|
|
420
|
+
rows.push({
|
|
421
|
+
id: "staging-main",
|
|
422
|
+
label: `Staging → ${promotePr.base}`,
|
|
423
|
+
state: prCheckState(promotePr),
|
|
424
|
+
detail: prDetail(promotePr),
|
|
425
|
+
next: cmd(`gh pr checks ${promotePr.number}`),
|
|
426
|
+
});
|
|
427
|
+
} else if (local.stagingAheadOfMain == null) {
|
|
428
|
+
rows.push({
|
|
429
|
+
id: "staging-main",
|
|
430
|
+
label: `Staging → ${mainBase}`,
|
|
431
|
+
state: "unknown",
|
|
432
|
+
detail: "no origin/staging or origin/main ref",
|
|
433
|
+
next: null,
|
|
434
|
+
});
|
|
435
|
+
} else if (local.stagingAheadOfMain > 0) {
|
|
436
|
+
rows.push({
|
|
437
|
+
id: "staging-main",
|
|
438
|
+
label: `Staging → ${mainBase}`,
|
|
439
|
+
state: "pending",
|
|
440
|
+
detail: `staging ${local.stagingAheadOfMain} ahead, no open PR${forgeNote ? ` (${forgeNote})` : ""}`,
|
|
441
|
+
next: cmd(slash, "agent chat input"),
|
|
442
|
+
});
|
|
443
|
+
} else {
|
|
444
|
+
rows.push({
|
|
445
|
+
id: "staging-main",
|
|
446
|
+
label: `Staging → ${mainBase}`,
|
|
447
|
+
state: "green",
|
|
448
|
+
detail: `${mainBase} has everything on staging`,
|
|
449
|
+
next: null,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// 3. Tag.
|
|
454
|
+
if (!tag && local.unsafeTag) {
|
|
455
|
+
rows.push({
|
|
456
|
+
id: "tag",
|
|
457
|
+
label: "Tag",
|
|
458
|
+
state: "unknown",
|
|
459
|
+
detail: "latest v* tag has characters outside [A-Za-z0-9._+-]; not shown or copied",
|
|
460
|
+
next: null,
|
|
461
|
+
});
|
|
462
|
+
} else if (!tag) {
|
|
463
|
+
rows.push({ id: "tag", label: "Tag", state: "unknown", detail: "no v* tag", next: null });
|
|
464
|
+
} else if (local.version && tagVersion !== local.version) {
|
|
465
|
+
rows.push({
|
|
466
|
+
id: "tag",
|
|
467
|
+
label: "Tag",
|
|
468
|
+
state: "pending",
|
|
469
|
+
detail: `v${local.version} not tagged (latest ${tag})`,
|
|
470
|
+
next: cmd(slash, "agent chat input"),
|
|
471
|
+
});
|
|
472
|
+
} else if (local.tagOnMain === false) {
|
|
473
|
+
rows.push({
|
|
474
|
+
id: "tag",
|
|
475
|
+
label: "Tag",
|
|
476
|
+
state: "pending",
|
|
477
|
+
detail: `${tag} not on ${local.mainRef || "origin/main"}`,
|
|
478
|
+
next: cmd("git fetch origin --tags"),
|
|
479
|
+
});
|
|
480
|
+
} else {
|
|
481
|
+
rows.push({
|
|
482
|
+
id: "tag",
|
|
483
|
+
label: "Tag",
|
|
484
|
+
state: "green",
|
|
485
|
+
detail: `${tag} on ${local.mainRef || "origin/main"}`,
|
|
486
|
+
next: null,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// 4. Tag CI jobs.
|
|
491
|
+
if (!tag) {
|
|
492
|
+
rows.push({ id: "tag-ci", label: "Tag CI", state: "unknown", detail: "no v* tag", next: null });
|
|
493
|
+
} else if (!forgeUp) {
|
|
494
|
+
rows.push({
|
|
495
|
+
id: "tag-ci",
|
|
496
|
+
label: "Tag CI",
|
|
497
|
+
state: "unknown",
|
|
498
|
+
detail: forgeNote,
|
|
499
|
+
next: cmd(`gh run list --branch ${tag}`),
|
|
500
|
+
});
|
|
501
|
+
} else if (!remote.tagCi) {
|
|
502
|
+
rows.push({
|
|
503
|
+
id: "tag-ci",
|
|
504
|
+
label: "Tag CI",
|
|
505
|
+
state: "pending",
|
|
506
|
+
detail: `no CI run found for ${tag}`,
|
|
507
|
+
next: cmd(`gh run list --branch ${tag}`),
|
|
508
|
+
});
|
|
509
|
+
} else {
|
|
510
|
+
const { jobs, runId } = remote.tagCi;
|
|
511
|
+
const failed = jobs.filter((j) => j.state === "failure").map((j) => j.name);
|
|
512
|
+
const running = jobs.filter((j) => j.state === "pending").map((j) => j.name);
|
|
513
|
+
const list = jobs
|
|
514
|
+
.filter((j) => j.state !== "skipped")
|
|
515
|
+
.map((j) => j.name)
|
|
516
|
+
.join(", ");
|
|
517
|
+
if (failed.length) {
|
|
518
|
+
rows.push({
|
|
519
|
+
id: "tag-ci",
|
|
520
|
+
label: "Tag CI",
|
|
521
|
+
state: "red",
|
|
522
|
+
detail: `${tag}: ${failed.join(", ")} failed`,
|
|
523
|
+
next: cmd(runId ? `gh run rerun ${runId} --failed` : `gh run list --branch ${tag}`),
|
|
524
|
+
});
|
|
525
|
+
} else if (running.length) {
|
|
526
|
+
rows.push({
|
|
527
|
+
id: "tag-ci",
|
|
528
|
+
label: "Tag CI",
|
|
529
|
+
state: "pending",
|
|
530
|
+
detail: `${tag}: ${running.join(", ")} running`,
|
|
531
|
+
next: cmd(runId ? `gh run watch ${runId}` : `gh run list --branch ${tag}`),
|
|
532
|
+
});
|
|
533
|
+
} else {
|
|
534
|
+
rows.push({
|
|
535
|
+
id: "tag-ci",
|
|
536
|
+
label: "Tag CI",
|
|
537
|
+
state: "green",
|
|
538
|
+
detail: `${tag}: ${list || "all jobs"} green`,
|
|
539
|
+
next: null,
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// 5. Staging fast-forward sync (main is an ancestor of staging).
|
|
545
|
+
if (local.mainInStaging == null) {
|
|
546
|
+
rows.push({
|
|
547
|
+
id: "staging-sync",
|
|
548
|
+
label: "Staging sync",
|
|
549
|
+
state: "unknown",
|
|
550
|
+
detail: "no origin/staging or origin/main ref",
|
|
551
|
+
next: null,
|
|
552
|
+
});
|
|
553
|
+
} else if (local.mainInStaging) {
|
|
554
|
+
rows.push({
|
|
555
|
+
id: "staging-sync",
|
|
556
|
+
label: "Staging sync",
|
|
557
|
+
state: "green",
|
|
558
|
+
detail: `${mainBase} is an ancestor of staging`,
|
|
559
|
+
next: null,
|
|
560
|
+
});
|
|
561
|
+
} else {
|
|
562
|
+
rows.push({
|
|
563
|
+
id: "staging-sync",
|
|
564
|
+
label: "Staging sync",
|
|
565
|
+
state: "red",
|
|
566
|
+
detail: `${mainBase} has commits staging lacks`,
|
|
567
|
+
next: cmd(`git log --oneline origin/staging..${local.mainRef || "origin/main"}`),
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// 6. npm.
|
|
572
|
+
const npm = forgeUp ? remote.npm : null;
|
|
573
|
+
if (npm?.name) {
|
|
574
|
+
if (!npm.version) {
|
|
575
|
+
rows.push({
|
|
576
|
+
id: "npm",
|
|
577
|
+
label: "npm",
|
|
578
|
+
state: "unknown",
|
|
579
|
+
detail: `${npm.name}: registry not reachable`,
|
|
580
|
+
next: cmd(`npm view ${npm.name} version`),
|
|
581
|
+
});
|
|
582
|
+
} else if (tagVersion && npm.version === tagVersion) {
|
|
583
|
+
rows.push({
|
|
584
|
+
id: "npm",
|
|
585
|
+
label: "npm",
|
|
586
|
+
state: "green",
|
|
587
|
+
detail: `${npm.name}@${npm.version}`,
|
|
588
|
+
next: null,
|
|
589
|
+
});
|
|
590
|
+
} else {
|
|
591
|
+
rows.push({
|
|
592
|
+
id: "npm",
|
|
593
|
+
label: "npm",
|
|
594
|
+
state: "pending",
|
|
595
|
+
detail: `${npm.name}@${npm.version}, expected ${tagVersion ?? "a tag"}`,
|
|
596
|
+
next: cmd(`npm view ${npm.name} version`),
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// 7-8. Public sync PR and public Release Latest (factory lane).
|
|
602
|
+
if (publicRepo) {
|
|
603
|
+
const pub = forgeUp ? remote.public : null;
|
|
604
|
+
if (!pub) {
|
|
605
|
+
const detail = forgeNote ?? "public repo not readable";
|
|
606
|
+
rows.push({
|
|
607
|
+
id: "public-sync",
|
|
608
|
+
label: "Public sync PR",
|
|
609
|
+
state: "unknown",
|
|
610
|
+
detail,
|
|
611
|
+
next: cmd(`gh pr list -R ${publicRepo} --state all --limit 5`),
|
|
612
|
+
});
|
|
613
|
+
rows.push({
|
|
614
|
+
id: "public-release",
|
|
615
|
+
label: "Public Release Latest",
|
|
616
|
+
state: "unknown",
|
|
617
|
+
detail,
|
|
618
|
+
next: cmd(`gh release list -R ${publicRepo} --limit 3`),
|
|
619
|
+
});
|
|
620
|
+
} else {
|
|
621
|
+
const sync = tag ? [...pub.syncPrs].reverse().find((p) => p.title.includes(tag)) : null;
|
|
622
|
+
if (sync?.state === "merged") {
|
|
623
|
+
rows.push({
|
|
624
|
+
id: "public-sync",
|
|
625
|
+
label: "Public sync PR",
|
|
626
|
+
state: "green",
|
|
627
|
+
detail: `#${sync.number} merged`,
|
|
628
|
+
next: null,
|
|
629
|
+
});
|
|
630
|
+
} else if (sync) {
|
|
631
|
+
rows.push({
|
|
632
|
+
id: "public-sync",
|
|
633
|
+
label: "Public sync PR",
|
|
634
|
+
state: "pending",
|
|
635
|
+
detail: `#${sync.number} ${sync.state ?? "open"}`,
|
|
636
|
+
next: cmd(`gh pr view ${sync.number} -R ${publicRepo}`),
|
|
637
|
+
});
|
|
638
|
+
} else {
|
|
639
|
+
rows.push({
|
|
640
|
+
id: "public-sync",
|
|
641
|
+
label: "Public sync PR",
|
|
642
|
+
state: "pending",
|
|
643
|
+
detail: `no sync PR for ${tag ?? "the latest tag"}`,
|
|
644
|
+
next: cmd(`gh pr list -R ${publicRepo} --state all --limit 5`),
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
const rel = pub.release?.tag ?? null;
|
|
648
|
+
rows.push(
|
|
649
|
+
rel && rel === tag
|
|
650
|
+
? {
|
|
651
|
+
id: "public-release",
|
|
652
|
+
label: "Public Release Latest",
|
|
653
|
+
state: "green",
|
|
654
|
+
detail: `${rel} is Latest`,
|
|
655
|
+
next: null,
|
|
656
|
+
}
|
|
657
|
+
: {
|
|
658
|
+
id: "public-release",
|
|
659
|
+
label: "Public Release Latest",
|
|
660
|
+
state: "pending",
|
|
661
|
+
detail: rel ? `Latest is ${rel}, expected ${tag ?? "a tag"}` : "no public release",
|
|
662
|
+
next: cmd(`gh release list -R ${publicRepo} --limit 3`),
|
|
663
|
+
},
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// GitHub Release Latest on origin, when the repo publishes releases there.
|
|
669
|
+
const originRelease = forgeUp ? remote.originRelease : null;
|
|
670
|
+
if (originRelease) {
|
|
671
|
+
rows.push(
|
|
672
|
+
originRelease.tag === tag
|
|
673
|
+
? {
|
|
674
|
+
id: "origin-release",
|
|
675
|
+
label: "Release Latest",
|
|
676
|
+
state: "green",
|
|
677
|
+
detail: `${originRelease.tag} is Latest`,
|
|
678
|
+
next: null,
|
|
679
|
+
}
|
|
680
|
+
: {
|
|
681
|
+
id: "origin-release",
|
|
682
|
+
label: "Release Latest",
|
|
683
|
+
state: "pending",
|
|
684
|
+
detail: `Latest is ${originRelease.tag}, expected ${tag ?? "a tag"}`,
|
|
685
|
+
next: cmd(`gh release list${repo ? ` -R ${repo}` : ""} --limit 3`),
|
|
686
|
+
},
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
return rows;
|
|
690
|
+
}
|