@staff0rd/assist 0.684.1 → 0.685.1
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 +10 -3
- package/claude/commands/releases-configure.md +2 -2
- package/dist/commands/sessions/web/bundle.js +463 -463
- package/dist/index.js +270 -78
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.685.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -4815,9 +4815,9 @@ function renderLineChart({
|
|
|
4815
4815
|
// src/commands/activity/fetchCommitsPerDay.ts
|
|
4816
4816
|
import { execSync as execSync14 } from "child_process";
|
|
4817
4817
|
function fetchContributions(from, to) {
|
|
4818
|
-
const
|
|
4818
|
+
const query = `{ viewer { contributionsCollection(from: "${from}T00:00:00Z", to: "${to}T23:59:59Z") { contributionCalendar { weeks { contributionDays { date contributionCount } } } } } }`;
|
|
4819
4819
|
const jq = ".data.viewer.contributionsCollection.contributionCalendar.weeks[].contributionDays[]";
|
|
4820
|
-
const raw = execSync14(`gh api graphql -f query='${
|
|
4820
|
+
const raw = execSync14(`gh api graphql -f query='${query}' --jq '${jq}'`, {
|
|
4821
4821
|
encoding: "utf8"
|
|
4822
4822
|
}).trim();
|
|
4823
4823
|
if (!raw) return [];
|
|
@@ -7412,9 +7412,9 @@ import { eq as eq6 } from "drizzle-orm";
|
|
|
7412
7412
|
|
|
7413
7413
|
// src/commands/backlog/searchItemIds.ts
|
|
7414
7414
|
import { and as and3, asc as asc4, eq as eq8, ilike, or, sql as sql10 } from "drizzle-orm";
|
|
7415
|
-
async function searchItemIds(orm,
|
|
7416
|
-
const pattern2 = `%${
|
|
7417
|
-
const numberPattern = `%${
|
|
7415
|
+
async function searchItemIds(orm, query, origin) {
|
|
7416
|
+
const pattern2 = `%${query}%`;
|
|
7417
|
+
const numberPattern = `%${query.replace(/^#/, "")}%`;
|
|
7418
7418
|
const rows = await orm.selectDistinct({ id: items.id }).from(items).leftJoin(comments, eq8(comments.itemId, items.id)).leftJoin(planPhases, eq8(planPhases.itemId, items.id)).where(
|
|
7419
7419
|
and3(
|
|
7420
7420
|
origin ? eq8(items.origin, origin) : void 0,
|
|
@@ -7473,10 +7473,10 @@ async function loadBacklog(allRepos = false) {
|
|
|
7473
7473
|
const { orm } = await getReady();
|
|
7474
7474
|
return loadAllItems(orm, allRepos ? void 0 : getOrigin());
|
|
7475
7475
|
}
|
|
7476
|
-
async function searchBacklog(
|
|
7476
|
+
async function searchBacklog(query) {
|
|
7477
7477
|
const { orm } = await getReady();
|
|
7478
7478
|
const origin = getOrigin();
|
|
7479
|
-
const ids = await searchItemIds(orm,
|
|
7479
|
+
const ids = await searchItemIds(orm, query, origin);
|
|
7480
7480
|
const allItems = await loadAllItems(orm, origin);
|
|
7481
7481
|
return allItems.filter((item) => ids.includes(item.id));
|
|
7482
7482
|
}
|
|
@@ -10265,10 +10265,10 @@ async function loadBacklogSummaries(allRepos = false) {
|
|
|
10265
10265
|
const { orm } = await getReady();
|
|
10266
10266
|
return loadItemSummaries(orm, allRepos ? void 0 : getOrigin());
|
|
10267
10267
|
}
|
|
10268
|
-
async function searchBacklogSummaries(
|
|
10268
|
+
async function searchBacklogSummaries(query) {
|
|
10269
10269
|
const { orm } = await getReady();
|
|
10270
10270
|
const origin = getOrigin();
|
|
10271
|
-
const ids = await searchItemIds(orm,
|
|
10271
|
+
const ids = await searchItemIds(orm, query, origin);
|
|
10272
10272
|
const summaries = await loadItemSummaries(orm, origin);
|
|
10273
10273
|
return summaries.filter((item) => ids.includes(item.id));
|
|
10274
10274
|
}
|
|
@@ -11573,12 +11573,12 @@ function isBoundary(text18, index3) {
|
|
|
11573
11573
|
if (!/[A-Za-z0-9]/.test(previous)) return true;
|
|
11574
11574
|
return /[a-z0-9]/.test(previous) && /[A-Z]/.test(text18[index3] ?? "");
|
|
11575
11575
|
}
|
|
11576
|
-
function subsequenceScore(text18,
|
|
11576
|
+
function subsequenceScore(text18, query) {
|
|
11577
11577
|
const lower = text18.toLowerCase();
|
|
11578
11578
|
let score = 0;
|
|
11579
11579
|
let cursor = 0;
|
|
11580
11580
|
let previous = -1;
|
|
11581
|
-
for (const char of
|
|
11581
|
+
for (const char of query) {
|
|
11582
11582
|
const at2 = lower.indexOf(char, cursor);
|
|
11583
11583
|
if (at2 === -1) return null;
|
|
11584
11584
|
if (at2 === previous + 1) score += CONSECUTIVE_BONUS;
|
|
@@ -11590,8 +11590,8 @@ function subsequenceScore(text18, query2) {
|
|
|
11590
11590
|
}
|
|
11591
11591
|
return score - Math.min(text18.length, MAX_LENGTH_PENALTY);
|
|
11592
11592
|
}
|
|
11593
|
-
function scoreFilePath(path91,
|
|
11594
|
-
const needle =
|
|
11593
|
+
function scoreFilePath(path91, query) {
|
|
11594
|
+
const needle = query.trim().toLowerCase();
|
|
11595
11595
|
if (!needle) return 0;
|
|
11596
11596
|
const basename30 = path91.slice(path91.lastIndexOf("/") + 1);
|
|
11597
11597
|
const inBasename = subsequenceScore(basename30, needle);
|
|
@@ -11600,10 +11600,10 @@ function scoreFilePath(path91, query2) {
|
|
|
11600
11600
|
}
|
|
11601
11601
|
|
|
11602
11602
|
// src/commands/sessions/web/rankFilePaths.ts
|
|
11603
|
-
function rankFilePaths(paths,
|
|
11603
|
+
function rankFilePaths(paths, query, limit) {
|
|
11604
11604
|
const scored = [];
|
|
11605
11605
|
for (const path91 of paths) {
|
|
11606
|
-
const score = scoreFilePath(path91,
|
|
11606
|
+
const score = scoreFilePath(path91, query);
|
|
11607
11607
|
if (score !== null) scored.push({ path: path91, score });
|
|
11608
11608
|
}
|
|
11609
11609
|
scored.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));
|
|
@@ -11630,10 +11630,10 @@ async function repoFiles(cwd) {
|
|
|
11630
11630
|
async function listFiles(req, res) {
|
|
11631
11631
|
const cwd = getCwdParam(req, res);
|
|
11632
11632
|
if (!cwd) return;
|
|
11633
|
-
const
|
|
11633
|
+
const query = new URL(req.url ?? "/", "http://localhost").searchParams.get("q") ?? "";
|
|
11634
11634
|
try {
|
|
11635
11635
|
const files = await repoFiles(cwd);
|
|
11636
|
-
respondJson(res, 200, { files: rankFilePaths(files,
|
|
11636
|
+
respondJson(res, 200, { files: rankFilePaths(files, query, MAX_RESULTS) });
|
|
11637
11637
|
} catch {
|
|
11638
11638
|
respondJson(res, 500, { error: "Failed to list files" });
|
|
11639
11639
|
}
|
|
@@ -11897,7 +11897,7 @@ function avgContextPerCycle(db) {
|
|
|
11897
11897
|
// src/shared/db/listUsagePeaks.ts
|
|
11898
11898
|
async function listUsagePeaks(db, options2) {
|
|
11899
11899
|
const avgContext = avgContextPerCycle(db);
|
|
11900
|
-
const
|
|
11900
|
+
const query = db.select({
|
|
11901
11901
|
...getTableColumns(usagePeaks),
|
|
11902
11902
|
avgContextPct: avgContext.avgContextPct,
|
|
11903
11903
|
phaseCount: avgContext.phaseCount
|
|
@@ -11914,9 +11914,9 @@ async function listUsagePeaks(db, options2) {
|
|
|
11914
11914
|
desc2(usagePeaks.segment)
|
|
11915
11915
|
);
|
|
11916
11916
|
if (options2?.limit !== void 0) {
|
|
11917
|
-
return
|
|
11917
|
+
return query.limit(options2.limit).offset(options2.offset ?? 0);
|
|
11918
11918
|
}
|
|
11919
|
-
return
|
|
11919
|
+
return query;
|
|
11920
11920
|
}
|
|
11921
11921
|
|
|
11922
11922
|
// src/commands/sessions/web/respondPagedRows.ts
|
|
@@ -12065,7 +12065,7 @@ async function listItemUsageSummaries(db, options2) {
|
|
|
12065
12065
|
const totals = phaseUsageTotals(db);
|
|
12066
12066
|
const planned = planPhaseCounts(db);
|
|
12067
12067
|
const lastPhase = lastPhaseActivity(db);
|
|
12068
|
-
const
|
|
12068
|
+
const query = db.select({
|
|
12069
12069
|
id: items.id,
|
|
12070
12070
|
origin: items.origin,
|
|
12071
12071
|
type: items.type,
|
|
@@ -12081,7 +12081,7 @@ async function listItemUsageSummaries(db, options2) {
|
|
|
12081
12081
|
}).from(items).innerJoin(totals, eq23(totals.itemId, items.id)).leftJoin(planned, eq23(planned.itemId, items.id)).leftJoin(lastPhase, eq23(lastPhase.itemId, items.id)).where(itemUsageWhere(options2)).orderBy(
|
|
12082
12082
|
...itemUsageOrderBy({ totals, planned, lastPhase }, options2?.sort)
|
|
12083
12083
|
);
|
|
12084
|
-
const rows = options2?.limit === void 0 ? await
|
|
12084
|
+
const rows = options2?.limit === void 0 ? await query : await query.limit(options2.limit).offset(options2.offset ?? 0);
|
|
12085
12085
|
return rows.map(toItemUsageSummary);
|
|
12086
12086
|
}
|
|
12087
12087
|
|
|
@@ -12341,53 +12341,109 @@ async function commitsBehind(cwd, repo, base, sha) {
|
|
|
12341
12341
|
}
|
|
12342
12342
|
}
|
|
12343
12343
|
|
|
12344
|
-
// src/commands/sessions/web/releases/
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12344
|
+
// src/commands/sessions/web/releases/declaredNodeState.ts
|
|
12345
|
+
function kindOf(node) {
|
|
12346
|
+
if (node.environment) return "environment";
|
|
12347
|
+
return node.kind === "gate" ? "gate" : "build";
|
|
12348
|
+
}
|
|
12349
|
+
async function declaredNodeState(cwd, repo, defaultBranch, node, deployments, run4) {
|
|
12350
|
+
const environment = node.environment ?? null;
|
|
12351
|
+
const deployment = environment ? deployments.live.get(environment) : void 0;
|
|
12352
|
+
const queued = environment ? deployments.queued.get(environment) : void 0;
|
|
12353
|
+
const behind = deployment && defaultBranch ? await commitsBehind(cwd, repo, defaultBranch, deployment.commit.sha) : null;
|
|
12349
12354
|
return {
|
|
12350
12355
|
id: node.id,
|
|
12356
|
+
kind: kindOf(node),
|
|
12351
12357
|
environment,
|
|
12352
12358
|
label: node.label ?? node.id,
|
|
12353
|
-
|
|
12359
|
+
live: deployment?.commit ?? null,
|
|
12354
12360
|
deployedAt: deployment?.at ?? null,
|
|
12355
|
-
behind
|
|
12361
|
+
behind,
|
|
12362
|
+
queued: queued?.commit ?? null,
|
|
12363
|
+
run: run4
|
|
12356
12364
|
};
|
|
12357
12365
|
}
|
|
12358
12366
|
|
|
12359
|
-
// src/commands/sessions/web/releases/
|
|
12360
|
-
var
|
|
12361
|
-
|
|
12367
|
+
// src/commands/sessions/web/releases/deploymentMaps.ts
|
|
12368
|
+
var NOT_YET_LIVE_STATES = /* @__PURE__ */ new Set([
|
|
12369
|
+
"WAITING",
|
|
12370
|
+
"PENDING",
|
|
12371
|
+
"QUEUED",
|
|
12372
|
+
"IN_PROGRESS"
|
|
12373
|
+
]);
|
|
12374
|
+
function releaseCommit(sha, node) {
|
|
12375
|
+
return {
|
|
12376
|
+
sha,
|
|
12377
|
+
subject: node?.messageHeadline ?? null,
|
|
12378
|
+
author: node?.author?.name ?? null
|
|
12379
|
+
};
|
|
12380
|
+
}
|
|
12381
|
+
function entryOf(node, sha) {
|
|
12382
|
+
return {
|
|
12383
|
+
commit: releaseCommit(sha, node.commit),
|
|
12384
|
+
at: node.latestStatus?.createdAt ?? node.createdAt
|
|
12385
|
+
};
|
|
12386
|
+
}
|
|
12387
|
+
function dropAlreadyLive(maps) {
|
|
12388
|
+
for (const [environment, entry] of maps.queued)
|
|
12389
|
+
if (maps.live.get(environment)?.commit.sha === entry.commit.sha)
|
|
12390
|
+
maps.queued.delete(environment);
|
|
12391
|
+
return maps;
|
|
12392
|
+
}
|
|
12393
|
+
function deploymentMaps(nodes) {
|
|
12394
|
+
const live = /* @__PURE__ */ new Map();
|
|
12395
|
+
const queued = /* @__PURE__ */ new Map();
|
|
12396
|
+
for (const node of nodes) {
|
|
12397
|
+
const state = node?.latestStatus?.state;
|
|
12398
|
+
if (!node?.environment || !node.commitOid || !state) continue;
|
|
12399
|
+
if (state === "SUCCESS") {
|
|
12400
|
+
live.set(node.environment, entryOf(node, node.commitOid));
|
|
12401
|
+
queued.delete(node.environment);
|
|
12402
|
+
} else if (NOT_YET_LIVE_STATES.has(state))
|
|
12403
|
+
queued.set(node.environment, entryOf(node, node.commitOid));
|
|
12404
|
+
}
|
|
12405
|
+
return dropAlreadyLive({ live, queued });
|
|
12406
|
+
}
|
|
12407
|
+
|
|
12408
|
+
// src/commands/sessions/web/releases/deploymentsQuery.ts
|
|
12409
|
+
var DEPLOYMENTS_PER_ENVIRONMENT = 50;
|
|
12410
|
+
var COMMIT_FIELDS = "oid messageHeadline author{ name }";
|
|
12411
|
+
function deploymentsAlias(index3) {
|
|
12412
|
+
return `env${index3}`;
|
|
12413
|
+
}
|
|
12414
|
+
function environmentDeployments(environment, index3) {
|
|
12415
|
+
return `${deploymentsAlias(index3)}: deployments(environments:${JSON.stringify([environment])}, last:${DEPLOYMENTS_PER_ENVIRONMENT}, orderBy:{field:CREATED_AT,direction:ASC}){
|
|
12416
|
+
nodes{ environment createdAt commitOid commit{ ${COMMIT_FIELDS} } latestStatus{ state createdAt } }
|
|
12417
|
+
}`;
|
|
12418
|
+
}
|
|
12419
|
+
function deploymentsQuery(environments) {
|
|
12362
12420
|
return `query($owner:String!,$name:String!){
|
|
12363
12421
|
repository(owner:$owner,name:$name){
|
|
12364
|
-
defaultBranchRef{ name }
|
|
12365
|
-
|
|
12366
|
-
nodes{ environment createdAt commitOid latestStatus{ state createdAt } }
|
|
12367
|
-
}
|
|
12422
|
+
defaultBranchRef{ name target{ ... on Commit { ${COMMIT_FIELDS} } } }
|
|
12423
|
+
${environments.map(environmentDeployments).join("\n ")}
|
|
12368
12424
|
}
|
|
12369
12425
|
}`;
|
|
12370
12426
|
}
|
|
12371
|
-
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12375
|
-
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
return live;
|
|
12427
|
+
|
|
12428
|
+
// src/commands/sessions/web/releases/liveDeployments.ts
|
|
12429
|
+
function headCommit(node) {
|
|
12430
|
+
return node?.oid ? releaseCommit(node.oid, node) : null;
|
|
12431
|
+
}
|
|
12432
|
+
function environmentNodes(repository, count8) {
|
|
12433
|
+
return Array.from(
|
|
12434
|
+
{ length: count8 },
|
|
12435
|
+
(_, index3) => repository[deploymentsAlias(index3)]?.nodes ?? []
|
|
12436
|
+
).flat();
|
|
12382
12437
|
}
|
|
12383
12438
|
async function liveDeployments(cwd, repo, environments) {
|
|
12384
12439
|
const [owner, name] = repo.split("/");
|
|
12385
12440
|
if (!owner || !name) throw new Error(`Not an owner/name repo: ${repo}`);
|
|
12441
|
+
const distinct = [...new Set(environments)];
|
|
12386
12442
|
const response = await ghJson(cwd, [
|
|
12387
12443
|
"api",
|
|
12388
12444
|
"graphql",
|
|
12389
12445
|
"-f",
|
|
12390
|
-
`query=${
|
|
12446
|
+
`query=${deploymentsQuery(distinct)}`,
|
|
12391
12447
|
"-f",
|
|
12392
12448
|
`owner=${owner}`,
|
|
12393
12449
|
"-f",
|
|
@@ -12397,10 +12453,126 @@ async function liveDeployments(cwd, repo, environments) {
|
|
|
12397
12453
|
if (!repository) throw new Error(`Repository not readable: ${repo}`);
|
|
12398
12454
|
return {
|
|
12399
12455
|
defaultBranch: repository.defaultBranchRef?.name ?? null,
|
|
12400
|
-
|
|
12456
|
+
head: headCommit(repository.defaultBranchRef?.target),
|
|
12457
|
+
...deploymentMaps(environmentNodes(repository, distinct.length))
|
|
12458
|
+
};
|
|
12459
|
+
}
|
|
12460
|
+
|
|
12461
|
+
// src/commands/sessions/web/releases/latestRun.ts
|
|
12462
|
+
async function latestRun(cwd, repo, workflow) {
|
|
12463
|
+
const path91 = `repos/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs?per_page=1&exclude_pull_requests=true`;
|
|
12464
|
+
const response = await ghJson(cwd, ["api", path91]);
|
|
12465
|
+
const run4 = response.workflow_runs?.[0];
|
|
12466
|
+
if (!run4) return null;
|
|
12467
|
+
return {
|
|
12468
|
+
id: run4.id,
|
|
12469
|
+
number: run4.run_number,
|
|
12470
|
+
url: run4.html_url,
|
|
12471
|
+
headSha: run4.head_sha,
|
|
12472
|
+
status: run4.status ?? "unknown",
|
|
12473
|
+
startedAt: run4.run_started_at ?? null
|
|
12474
|
+
};
|
|
12475
|
+
}
|
|
12476
|
+
|
|
12477
|
+
// src/commands/sessions/web/releases/releaseJobTokens.ts
|
|
12478
|
+
function normaliseJobName(text18) {
|
|
12479
|
+
return ` ${text18.toLowerCase().replaceAll(/[^a-z0-9]+/g, " ").trim()} `;
|
|
12480
|
+
}
|
|
12481
|
+
function releaseJobTokens(node) {
|
|
12482
|
+
const candidates = [node.environment, node.label, node.id].filter(
|
|
12483
|
+
(value) => Boolean(value)
|
|
12484
|
+
);
|
|
12485
|
+
return [...new Set(candidates.map(normaliseJobName))].filter((token) => token.trim().length > 0).sort((a, b) => b.length - a.length);
|
|
12486
|
+
}
|
|
12487
|
+
|
|
12488
|
+
// src/commands/sessions/web/releases/runJobState.ts
|
|
12489
|
+
var RUNNING_STATUSES = /* @__PURE__ */ new Set([
|
|
12490
|
+
"queued",
|
|
12491
|
+
"in_progress",
|
|
12492
|
+
"pending",
|
|
12493
|
+
"requested"
|
|
12494
|
+
]);
|
|
12495
|
+
var UNREACHED_CONCLUSIONS = /* @__PURE__ */ new Set(["skipped", "neutral"]);
|
|
12496
|
+
var UNREACHED_BY_RUN = {
|
|
12497
|
+
status: "idle",
|
|
12498
|
+
conclusion: null,
|
|
12499
|
+
startedAt: null,
|
|
12500
|
+
completedAt: null,
|
|
12501
|
+
url: null
|
|
12502
|
+
};
|
|
12503
|
+
function statusOf(job) {
|
|
12504
|
+
if (job.status === "waiting") return "gate";
|
|
12505
|
+
if (RUNNING_STATUSES.has(job.status)) return "running";
|
|
12506
|
+
if (job.conclusion === "success") return "ok";
|
|
12507
|
+
if (!job.conclusion || UNREACHED_CONCLUSIONS.has(job.conclusion))
|
|
12508
|
+
return "idle";
|
|
12509
|
+
return "fail";
|
|
12510
|
+
}
|
|
12511
|
+
function runJobState(job) {
|
|
12512
|
+
return {
|
|
12513
|
+
status: statusOf(job),
|
|
12514
|
+
conclusion: job.conclusion,
|
|
12515
|
+
startedAt: job.startedAt,
|
|
12516
|
+
completedAt: job.completedAt,
|
|
12517
|
+
url: job.url
|
|
12401
12518
|
};
|
|
12402
12519
|
}
|
|
12403
12520
|
|
|
12521
|
+
// src/commands/sessions/web/releases/matchRunJobs.ts
|
|
12522
|
+
function mostSpecificFirst(nodes) {
|
|
12523
|
+
return nodes.map((node, index3) => ({ node, index: index3, tokens: releaseJobTokens(node) })).sort(
|
|
12524
|
+
(a, b) => (b.tokens[0]?.length ?? 0) - (a.tokens[0]?.length ?? 0) || a.index - b.index
|
|
12525
|
+
);
|
|
12526
|
+
}
|
|
12527
|
+
function firstUnclaimed(names, claimed, tokens) {
|
|
12528
|
+
for (const token of tokens)
|
|
12529
|
+
for (const [index3, name] of names.entries())
|
|
12530
|
+
if (!claimed.has(index3) && name.includes(token)) return index3;
|
|
12531
|
+
return void 0;
|
|
12532
|
+
}
|
|
12533
|
+
function matchRunJobs(nodes, jobs) {
|
|
12534
|
+
const names = jobs.map((job) => normaliseJobName(job.name));
|
|
12535
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
12536
|
+
const matched = /* @__PURE__ */ new Map();
|
|
12537
|
+
for (const { node, tokens } of mostSpecificFirst(nodes)) {
|
|
12538
|
+
const hit = firstUnclaimed(names, claimed, tokens);
|
|
12539
|
+
const job = hit === void 0 ? void 0 : jobs[hit];
|
|
12540
|
+
if (hit !== void 0) claimed.add(hit);
|
|
12541
|
+
matched.set(node.id, job ? runJobState(job) : UNREACHED_BY_RUN);
|
|
12542
|
+
}
|
|
12543
|
+
return matched;
|
|
12544
|
+
}
|
|
12545
|
+
|
|
12546
|
+
// src/commands/sessions/web/releases/runJobs.ts
|
|
12547
|
+
var JOB_PAGE = 100;
|
|
12548
|
+
async function runJobs(cwd, repo, runId) {
|
|
12549
|
+
const response = await ghJson(cwd, [
|
|
12550
|
+
"api",
|
|
12551
|
+
`repos/${repo}/actions/runs/${runId}/jobs?per_page=${JOB_PAGE}`
|
|
12552
|
+
]);
|
|
12553
|
+
return (response.jobs ?? []).flatMap(
|
|
12554
|
+
(job) => job.name ? [
|
|
12555
|
+
{
|
|
12556
|
+
name: job.name,
|
|
12557
|
+
status: job.status ?? "unknown",
|
|
12558
|
+
conclusion: job.conclusion ?? null,
|
|
12559
|
+
startedAt: job.started_at ?? null,
|
|
12560
|
+
completedAt: job.completed_at ?? null,
|
|
12561
|
+
url: job.html_url ?? null
|
|
12562
|
+
}
|
|
12563
|
+
] : []
|
|
12564
|
+
);
|
|
12565
|
+
}
|
|
12566
|
+
|
|
12567
|
+
// src/commands/sessions/web/releases/streamRunState.ts
|
|
12568
|
+
async function streamRunState(cwd, stream) {
|
|
12569
|
+
const run4 = await latestRun(cwd, stream.repo, stream.workflow);
|
|
12570
|
+
if (!run4) return { run: null, byNode: /* @__PURE__ */ new Map() };
|
|
12571
|
+
const { id, ...state } = run4;
|
|
12572
|
+
const jobs = await runJobs(cwd, stream.repo, id);
|
|
12573
|
+
return { run: state, byNode: matchRunJobs(stream.nodes, jobs) };
|
|
12574
|
+
}
|
|
12575
|
+
|
|
12404
12576
|
// src/commands/sessions/web/releases/streamState.ts
|
|
12405
12577
|
function errorMessage(error) {
|
|
12406
12578
|
if (!(error instanceof Error)) return "Failed to read release state";
|
|
@@ -12410,26 +12582,46 @@ async function streamState(cwd, stream) {
|
|
|
12410
12582
|
const declared = {
|
|
12411
12583
|
name: stream.name,
|
|
12412
12584
|
repo: stream.repo,
|
|
12413
|
-
workflow: stream.workflow
|
|
12585
|
+
workflow: stream.workflow,
|
|
12586
|
+
edges: stream.edges
|
|
12414
12587
|
};
|
|
12415
|
-
const nodes = stream.nodes.filter((node) => node.environment);
|
|
12416
12588
|
try {
|
|
12417
|
-
const {
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12589
|
+
const [deployments, { run: run4, byNode }] = await Promise.all([
|
|
12590
|
+
liveDeployments(
|
|
12591
|
+
cwd,
|
|
12592
|
+
stream.repo,
|
|
12593
|
+
stream.nodes.flatMap(
|
|
12594
|
+
(node) => node.environment ? [node.environment] : []
|
|
12595
|
+
)
|
|
12596
|
+
),
|
|
12597
|
+
streamRunState(cwd, stream)
|
|
12598
|
+
]);
|
|
12599
|
+
const nodes = await Promise.all(
|
|
12600
|
+
stream.nodes.map(
|
|
12601
|
+
(node) => declaredNodeState(
|
|
12602
|
+
cwd,
|
|
12603
|
+
stream.repo,
|
|
12604
|
+
deployments.defaultBranch,
|
|
12605
|
+
node,
|
|
12606
|
+
deployments,
|
|
12607
|
+
byNode.get(node.id) ?? null
|
|
12608
|
+
)
|
|
12425
12609
|
)
|
|
12426
12610
|
);
|
|
12427
|
-
return {
|
|
12611
|
+
return {
|
|
12612
|
+
...declared,
|
|
12613
|
+
defaultBranch: deployments.defaultBranch,
|
|
12614
|
+
head: deployments.head,
|
|
12615
|
+
nodes,
|
|
12616
|
+
run: run4
|
|
12617
|
+
};
|
|
12428
12618
|
} catch (error) {
|
|
12429
12619
|
return {
|
|
12430
12620
|
...declared,
|
|
12431
12621
|
defaultBranch: null,
|
|
12432
|
-
|
|
12622
|
+
head: null,
|
|
12623
|
+
nodes: [],
|
|
12624
|
+
run: null,
|
|
12433
12625
|
error: errorMessage(error)
|
|
12434
12626
|
};
|
|
12435
12627
|
}
|
|
@@ -15772,15 +15964,15 @@ function registerRunCommand(cmd) {
|
|
|
15772
15964
|
|
|
15773
15965
|
// src/commands/backlog/search/index.ts
|
|
15774
15966
|
import chalk90 from "chalk";
|
|
15775
|
-
async function search(
|
|
15776
|
-
const items2 = await searchBacklog(
|
|
15967
|
+
async function search(query) {
|
|
15968
|
+
const items2 = await searchBacklog(query);
|
|
15777
15969
|
if (items2.length === 0) {
|
|
15778
|
-
console.log(chalk90.dim(`No items matching "${
|
|
15970
|
+
console.log(chalk90.dim(`No items matching "${query}".`));
|
|
15779
15971
|
return;
|
|
15780
15972
|
}
|
|
15781
15973
|
console.log(
|
|
15782
15974
|
chalk90.dim(
|
|
15783
|
-
`${items2.length} item${items2.length === 1 ? "" : "s"} matching "${
|
|
15975
|
+
`${items2.length} item${items2.length === 1 ? "" : "s"} matching "${query}":
|
|
15784
15976
|
`
|
|
15785
15977
|
)
|
|
15786
15978
|
);
|
|
@@ -22048,11 +22240,11 @@ import chalk163 from "chalk";
|
|
|
22048
22240
|
|
|
22049
22241
|
// src/shared/runGhGraphqlJson.ts
|
|
22050
22242
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
22051
|
-
function runGhGraphqlJson(
|
|
22243
|
+
function runGhGraphqlJson(query, vars = {}) {
|
|
22052
22244
|
const result = spawnSync5("gh", ["api", "graphql", "--input", "-"], {
|
|
22053
22245
|
encoding: "utf8",
|
|
22054
22246
|
windowsHide: true,
|
|
22055
|
-
input: JSON.stringify({ query
|
|
22247
|
+
input: JSON.stringify({ query, variables: vars }),
|
|
22056
22248
|
maxBuffer: 64 * 1024 * 1024
|
|
22057
22249
|
});
|
|
22058
22250
|
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
@@ -33786,8 +33978,8 @@ function formatToolSummary(input) {
|
|
|
33786
33978
|
if (command) return truncate2(command);
|
|
33787
33979
|
const url = getString(record, "url");
|
|
33788
33980
|
if (url) return url;
|
|
33789
|
-
const
|
|
33790
|
-
if (
|
|
33981
|
+
const query = getString(record, "query");
|
|
33982
|
+
if (query) return truncate2(query);
|
|
33791
33983
|
const description = getString(record, "description");
|
|
33792
33984
|
if (description) return truncate2(description);
|
|
33793
33985
|
return "";
|
|
@@ -35512,8 +35704,8 @@ function isMutation(sql29) {
|
|
|
35512
35704
|
}
|
|
35513
35705
|
|
|
35514
35706
|
// src/commands/sql/sqlMutate.ts
|
|
35515
|
-
async function sqlMutate(
|
|
35516
|
-
if (!isMutation(
|
|
35707
|
+
async function sqlMutate(query, connectionName) {
|
|
35708
|
+
if (!isMutation(query)) {
|
|
35517
35709
|
console.error(
|
|
35518
35710
|
chalk242.red(
|
|
35519
35711
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
@@ -35524,7 +35716,7 @@ async function sqlMutate(query2, connectionName) {
|
|
|
35524
35716
|
const conn = resolveConnection3(connectionName);
|
|
35525
35717
|
const pool = await sqlConnect(conn);
|
|
35526
35718
|
try {
|
|
35527
|
-
const result = await pool.request().query(
|
|
35719
|
+
const result = await pool.request().query(query);
|
|
35528
35720
|
console.log(chalk242.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
35529
35721
|
} finally {
|
|
35530
35722
|
await pool.close();
|
|
@@ -35533,8 +35725,8 @@ async function sqlMutate(query2, connectionName) {
|
|
|
35533
35725
|
|
|
35534
35726
|
// src/commands/sql/sqlQuery.ts
|
|
35535
35727
|
import chalk243 from "chalk";
|
|
35536
|
-
async function sqlQuery(
|
|
35537
|
-
if (isMutation(
|
|
35728
|
+
async function sqlQuery(query, connectionName) {
|
|
35729
|
+
if (isMutation(query)) {
|
|
35538
35730
|
console.error(
|
|
35539
35731
|
chalk243.red(
|
|
35540
35732
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
@@ -35545,7 +35737,7 @@ async function sqlQuery(query2, connectionName) {
|
|
|
35545
35737
|
const conn = resolveConnection3(connectionName);
|
|
35546
35738
|
const pool = await sqlConnect(conn);
|
|
35547
35739
|
try {
|
|
35548
|
-
const result = await pool.request().query(
|
|
35740
|
+
const result = await pool.request().query(query);
|
|
35549
35741
|
const rows = result.recordset ?? [];
|
|
35550
35742
|
if (result.recordset) {
|
|
35551
35743
|
printTable(rows);
|
|
@@ -35595,12 +35787,12 @@ function registerSql(program2) {
|
|
|
35595
35787
|
auth2.command("remove <name>").description("Remove a configured connection").action((name) => sqlAuth.remove(name));
|
|
35596
35788
|
cmd.command("set-connection <name>").description("Set the default SQL connection").action((name) => sqlSetConnection(name));
|
|
35597
35789
|
cmd.command("query <sql> [connection]").description("Execute a read-only SQL query (rejects mutating statements)").action(
|
|
35598
|
-
(
|
|
35790
|
+
(query, connection) => sqlQuery(query, connection)
|
|
35599
35791
|
);
|
|
35600
35792
|
cmd.command("mutate <sql> [connection]").description(
|
|
35601
35793
|
"Execute a mutating SQL statement (rejects non-mutating statements)"
|
|
35602
35794
|
).action(
|
|
35603
|
-
(
|
|
35795
|
+
(query, connection) => sqlMutate(query, connection)
|
|
35604
35796
|
);
|
|
35605
35797
|
cmd.command("tables [connection]").description("List tables in the connected database").action((connection) => sqlTables(connection));
|
|
35606
35798
|
cmd.command("columns <table> [connection]").description(
|