@staff0rd/assist 0.684.1 → 0.685.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/README.md +8 -1
- package/dist/commands/sessions/web/bundle.js +463 -463
- package/dist/index.js +254 -75
- 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.0",
|
|
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,44 +12341,87 @@ 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/
|
|
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
|
|
12360
12409
|
var DEPLOYMENT_PAGE = 100;
|
|
12361
|
-
|
|
12410
|
+
var COMMIT_FIELDS = "oid messageHeadline author{ name }";
|
|
12411
|
+
function deploymentsQuery(environments) {
|
|
12362
12412
|
return `query($owner:String!,$name:String!){
|
|
12363
12413
|
repository(owner:$owner,name:$name){
|
|
12364
|
-
defaultBranchRef{ name }
|
|
12414
|
+
defaultBranchRef{ name target{ ... on Commit { ${COMMIT_FIELDS} } } }
|
|
12365
12415
|
deployments(environments:${JSON.stringify(environments)}, last:${DEPLOYMENT_PAGE}, orderBy:{field:CREATED_AT,direction:ASC}){
|
|
12366
|
-
nodes{ environment createdAt commitOid latestStatus{ state createdAt } }
|
|
12416
|
+
nodes{ environment createdAt commitOid commit{ ${COMMIT_FIELDS} } latestStatus{ state createdAt } }
|
|
12367
12417
|
}
|
|
12368
12418
|
}
|
|
12369
12419
|
}`;
|
|
12370
12420
|
}
|
|
12371
|
-
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12375
|
-
if (node.latestStatus?.state !== "SUCCESS") continue;
|
|
12376
|
-
live.set(node.environment, {
|
|
12377
|
-
sha: node.commitOid,
|
|
12378
|
-
at: node.latestStatus.createdAt ?? node.createdAt
|
|
12379
|
-
});
|
|
12380
|
-
}
|
|
12381
|
-
return live;
|
|
12421
|
+
|
|
12422
|
+
// src/commands/sessions/web/releases/liveDeployments.ts
|
|
12423
|
+
function headCommit(node) {
|
|
12424
|
+
return node?.oid ? releaseCommit(node.oid, node) : null;
|
|
12382
12425
|
}
|
|
12383
12426
|
async function liveDeployments(cwd, repo, environments) {
|
|
12384
12427
|
const [owner, name] = repo.split("/");
|
|
@@ -12387,7 +12430,7 @@ async function liveDeployments(cwd, repo, environments) {
|
|
|
12387
12430
|
"api",
|
|
12388
12431
|
"graphql",
|
|
12389
12432
|
"-f",
|
|
12390
|
-
`query=${
|
|
12433
|
+
`query=${deploymentsQuery(environments)}`,
|
|
12391
12434
|
"-f",
|
|
12392
12435
|
`owner=${owner}`,
|
|
12393
12436
|
"-f",
|
|
@@ -12397,10 +12440,126 @@ async function liveDeployments(cwd, repo, environments) {
|
|
|
12397
12440
|
if (!repository) throw new Error(`Repository not readable: ${repo}`);
|
|
12398
12441
|
return {
|
|
12399
12442
|
defaultBranch: repository.defaultBranchRef?.name ?? null,
|
|
12400
|
-
|
|
12443
|
+
head: headCommit(repository.defaultBranchRef?.target),
|
|
12444
|
+
...deploymentMaps(repository.deployments?.nodes ?? [])
|
|
12445
|
+
};
|
|
12446
|
+
}
|
|
12447
|
+
|
|
12448
|
+
// src/commands/sessions/web/releases/latestRun.ts
|
|
12449
|
+
async function latestRun(cwd, repo, workflow) {
|
|
12450
|
+
const path91 = `repos/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs?per_page=1&exclude_pull_requests=true`;
|
|
12451
|
+
const response = await ghJson(cwd, ["api", path91]);
|
|
12452
|
+
const run4 = response.workflow_runs?.[0];
|
|
12453
|
+
if (!run4) return null;
|
|
12454
|
+
return {
|
|
12455
|
+
id: run4.id,
|
|
12456
|
+
number: run4.run_number,
|
|
12457
|
+
url: run4.html_url,
|
|
12458
|
+
headSha: run4.head_sha,
|
|
12459
|
+
status: run4.status ?? "unknown",
|
|
12460
|
+
startedAt: run4.run_started_at ?? null
|
|
12461
|
+
};
|
|
12462
|
+
}
|
|
12463
|
+
|
|
12464
|
+
// src/commands/sessions/web/releases/releaseJobTokens.ts
|
|
12465
|
+
function normaliseJobName(text18) {
|
|
12466
|
+
return ` ${text18.toLowerCase().replaceAll(/[^a-z0-9]+/g, " ").trim()} `;
|
|
12467
|
+
}
|
|
12468
|
+
function releaseJobTokens(node) {
|
|
12469
|
+
const candidates = [node.environment, node.label, node.id].filter(
|
|
12470
|
+
(value) => Boolean(value)
|
|
12471
|
+
);
|
|
12472
|
+
return [...new Set(candidates.map(normaliseJobName))].filter((token) => token.trim().length > 0).sort((a, b) => b.length - a.length);
|
|
12473
|
+
}
|
|
12474
|
+
|
|
12475
|
+
// src/commands/sessions/web/releases/runJobState.ts
|
|
12476
|
+
var RUNNING_STATUSES = /* @__PURE__ */ new Set([
|
|
12477
|
+
"queued",
|
|
12478
|
+
"in_progress",
|
|
12479
|
+
"pending",
|
|
12480
|
+
"requested"
|
|
12481
|
+
]);
|
|
12482
|
+
var UNREACHED_CONCLUSIONS = /* @__PURE__ */ new Set(["skipped", "neutral"]);
|
|
12483
|
+
var UNREACHED_BY_RUN = {
|
|
12484
|
+
status: "idle",
|
|
12485
|
+
conclusion: null,
|
|
12486
|
+
startedAt: null,
|
|
12487
|
+
completedAt: null,
|
|
12488
|
+
url: null
|
|
12489
|
+
};
|
|
12490
|
+
function statusOf(job) {
|
|
12491
|
+
if (job.status === "waiting") return "gate";
|
|
12492
|
+
if (RUNNING_STATUSES.has(job.status)) return "running";
|
|
12493
|
+
if (job.conclusion === "success") return "ok";
|
|
12494
|
+
if (!job.conclusion || UNREACHED_CONCLUSIONS.has(job.conclusion))
|
|
12495
|
+
return "idle";
|
|
12496
|
+
return "fail";
|
|
12497
|
+
}
|
|
12498
|
+
function runJobState(job) {
|
|
12499
|
+
return {
|
|
12500
|
+
status: statusOf(job),
|
|
12501
|
+
conclusion: job.conclusion,
|
|
12502
|
+
startedAt: job.startedAt,
|
|
12503
|
+
completedAt: job.completedAt,
|
|
12504
|
+
url: job.url
|
|
12401
12505
|
};
|
|
12402
12506
|
}
|
|
12403
12507
|
|
|
12508
|
+
// src/commands/sessions/web/releases/matchRunJobs.ts
|
|
12509
|
+
function mostSpecificFirst(nodes) {
|
|
12510
|
+
return nodes.map((node, index3) => ({ node, index: index3, tokens: releaseJobTokens(node) })).sort(
|
|
12511
|
+
(a, b) => (b.tokens[0]?.length ?? 0) - (a.tokens[0]?.length ?? 0) || a.index - b.index
|
|
12512
|
+
);
|
|
12513
|
+
}
|
|
12514
|
+
function firstUnclaimed(names, claimed, tokens) {
|
|
12515
|
+
for (const token of tokens)
|
|
12516
|
+
for (const [index3, name] of names.entries())
|
|
12517
|
+
if (!claimed.has(index3) && name.includes(token)) return index3;
|
|
12518
|
+
return void 0;
|
|
12519
|
+
}
|
|
12520
|
+
function matchRunJobs(nodes, jobs) {
|
|
12521
|
+
const names = jobs.map((job) => normaliseJobName(job.name));
|
|
12522
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
12523
|
+
const matched = /* @__PURE__ */ new Map();
|
|
12524
|
+
for (const { node, tokens } of mostSpecificFirst(nodes)) {
|
|
12525
|
+
const hit = firstUnclaimed(names, claimed, tokens);
|
|
12526
|
+
const job = hit === void 0 ? void 0 : jobs[hit];
|
|
12527
|
+
if (hit !== void 0) claimed.add(hit);
|
|
12528
|
+
matched.set(node.id, job ? runJobState(job) : UNREACHED_BY_RUN);
|
|
12529
|
+
}
|
|
12530
|
+
return matched;
|
|
12531
|
+
}
|
|
12532
|
+
|
|
12533
|
+
// src/commands/sessions/web/releases/runJobs.ts
|
|
12534
|
+
var JOB_PAGE = 100;
|
|
12535
|
+
async function runJobs(cwd, repo, runId) {
|
|
12536
|
+
const response = await ghJson(cwd, [
|
|
12537
|
+
"api",
|
|
12538
|
+
`repos/${repo}/actions/runs/${runId}/jobs?per_page=${JOB_PAGE}`
|
|
12539
|
+
]);
|
|
12540
|
+
return (response.jobs ?? []).flatMap(
|
|
12541
|
+
(job) => job.name ? [
|
|
12542
|
+
{
|
|
12543
|
+
name: job.name,
|
|
12544
|
+
status: job.status ?? "unknown",
|
|
12545
|
+
conclusion: job.conclusion ?? null,
|
|
12546
|
+
startedAt: job.started_at ?? null,
|
|
12547
|
+
completedAt: job.completed_at ?? null,
|
|
12548
|
+
url: job.html_url ?? null
|
|
12549
|
+
}
|
|
12550
|
+
] : []
|
|
12551
|
+
);
|
|
12552
|
+
}
|
|
12553
|
+
|
|
12554
|
+
// src/commands/sessions/web/releases/streamRunState.ts
|
|
12555
|
+
async function streamRunState(cwd, stream) {
|
|
12556
|
+
const run4 = await latestRun(cwd, stream.repo, stream.workflow);
|
|
12557
|
+
if (!run4) return { run: null, byNode: /* @__PURE__ */ new Map() };
|
|
12558
|
+
const { id, ...state } = run4;
|
|
12559
|
+
const jobs = await runJobs(cwd, stream.repo, id);
|
|
12560
|
+
return { run: state, byNode: matchRunJobs(stream.nodes, jobs) };
|
|
12561
|
+
}
|
|
12562
|
+
|
|
12404
12563
|
// src/commands/sessions/web/releases/streamState.ts
|
|
12405
12564
|
function errorMessage(error) {
|
|
12406
12565
|
if (!(error instanceof Error)) return "Failed to read release state";
|
|
@@ -12410,26 +12569,46 @@ async function streamState(cwd, stream) {
|
|
|
12410
12569
|
const declared = {
|
|
12411
12570
|
name: stream.name,
|
|
12412
12571
|
repo: stream.repo,
|
|
12413
|
-
workflow: stream.workflow
|
|
12572
|
+
workflow: stream.workflow,
|
|
12573
|
+
edges: stream.edges
|
|
12414
12574
|
};
|
|
12415
|
-
const nodes = stream.nodes.filter((node) => node.environment);
|
|
12416
12575
|
try {
|
|
12417
|
-
const {
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12576
|
+
const [deployments, { run: run4, byNode }] = await Promise.all([
|
|
12577
|
+
liveDeployments(
|
|
12578
|
+
cwd,
|
|
12579
|
+
stream.repo,
|
|
12580
|
+
stream.nodes.flatMap(
|
|
12581
|
+
(node) => node.environment ? [node.environment] : []
|
|
12582
|
+
)
|
|
12583
|
+
),
|
|
12584
|
+
streamRunState(cwd, stream)
|
|
12585
|
+
]);
|
|
12586
|
+
const nodes = await Promise.all(
|
|
12587
|
+
stream.nodes.map(
|
|
12588
|
+
(node) => declaredNodeState(
|
|
12589
|
+
cwd,
|
|
12590
|
+
stream.repo,
|
|
12591
|
+
deployments.defaultBranch,
|
|
12592
|
+
node,
|
|
12593
|
+
deployments,
|
|
12594
|
+
byNode.get(node.id) ?? null
|
|
12595
|
+
)
|
|
12425
12596
|
)
|
|
12426
12597
|
);
|
|
12427
|
-
return {
|
|
12598
|
+
return {
|
|
12599
|
+
...declared,
|
|
12600
|
+
defaultBranch: deployments.defaultBranch,
|
|
12601
|
+
head: deployments.head,
|
|
12602
|
+
nodes,
|
|
12603
|
+
run: run4
|
|
12604
|
+
};
|
|
12428
12605
|
} catch (error) {
|
|
12429
12606
|
return {
|
|
12430
12607
|
...declared,
|
|
12431
12608
|
defaultBranch: null,
|
|
12432
|
-
|
|
12609
|
+
head: null,
|
|
12610
|
+
nodes: [],
|
|
12611
|
+
run: null,
|
|
12433
12612
|
error: errorMessage(error)
|
|
12434
12613
|
};
|
|
12435
12614
|
}
|
|
@@ -15772,15 +15951,15 @@ function registerRunCommand(cmd) {
|
|
|
15772
15951
|
|
|
15773
15952
|
// src/commands/backlog/search/index.ts
|
|
15774
15953
|
import chalk90 from "chalk";
|
|
15775
|
-
async function search(
|
|
15776
|
-
const items2 = await searchBacklog(
|
|
15954
|
+
async function search(query) {
|
|
15955
|
+
const items2 = await searchBacklog(query);
|
|
15777
15956
|
if (items2.length === 0) {
|
|
15778
|
-
console.log(chalk90.dim(`No items matching "${
|
|
15957
|
+
console.log(chalk90.dim(`No items matching "${query}".`));
|
|
15779
15958
|
return;
|
|
15780
15959
|
}
|
|
15781
15960
|
console.log(
|
|
15782
15961
|
chalk90.dim(
|
|
15783
|
-
`${items2.length} item${items2.length === 1 ? "" : "s"} matching "${
|
|
15962
|
+
`${items2.length} item${items2.length === 1 ? "" : "s"} matching "${query}":
|
|
15784
15963
|
`
|
|
15785
15964
|
)
|
|
15786
15965
|
);
|
|
@@ -22048,11 +22227,11 @@ import chalk163 from "chalk";
|
|
|
22048
22227
|
|
|
22049
22228
|
// src/shared/runGhGraphqlJson.ts
|
|
22050
22229
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
22051
|
-
function runGhGraphqlJson(
|
|
22230
|
+
function runGhGraphqlJson(query, vars = {}) {
|
|
22052
22231
|
const result = spawnSync5("gh", ["api", "graphql", "--input", "-"], {
|
|
22053
22232
|
encoding: "utf8",
|
|
22054
22233
|
windowsHide: true,
|
|
22055
|
-
input: JSON.stringify({ query
|
|
22234
|
+
input: JSON.stringify({ query, variables: vars }),
|
|
22056
22235
|
maxBuffer: 64 * 1024 * 1024
|
|
22057
22236
|
});
|
|
22058
22237
|
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
@@ -33786,8 +33965,8 @@ function formatToolSummary(input) {
|
|
|
33786
33965
|
if (command) return truncate2(command);
|
|
33787
33966
|
const url = getString(record, "url");
|
|
33788
33967
|
if (url) return url;
|
|
33789
|
-
const
|
|
33790
|
-
if (
|
|
33968
|
+
const query = getString(record, "query");
|
|
33969
|
+
if (query) return truncate2(query);
|
|
33791
33970
|
const description = getString(record, "description");
|
|
33792
33971
|
if (description) return truncate2(description);
|
|
33793
33972
|
return "";
|
|
@@ -35512,8 +35691,8 @@ function isMutation(sql29) {
|
|
|
35512
35691
|
}
|
|
35513
35692
|
|
|
35514
35693
|
// src/commands/sql/sqlMutate.ts
|
|
35515
|
-
async function sqlMutate(
|
|
35516
|
-
if (!isMutation(
|
|
35694
|
+
async function sqlMutate(query, connectionName) {
|
|
35695
|
+
if (!isMutation(query)) {
|
|
35517
35696
|
console.error(
|
|
35518
35697
|
chalk242.red(
|
|
35519
35698
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
@@ -35524,7 +35703,7 @@ async function sqlMutate(query2, connectionName) {
|
|
|
35524
35703
|
const conn = resolveConnection3(connectionName);
|
|
35525
35704
|
const pool = await sqlConnect(conn);
|
|
35526
35705
|
try {
|
|
35527
|
-
const result = await pool.request().query(
|
|
35706
|
+
const result = await pool.request().query(query);
|
|
35528
35707
|
console.log(chalk242.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
35529
35708
|
} finally {
|
|
35530
35709
|
await pool.close();
|
|
@@ -35533,8 +35712,8 @@ async function sqlMutate(query2, connectionName) {
|
|
|
35533
35712
|
|
|
35534
35713
|
// src/commands/sql/sqlQuery.ts
|
|
35535
35714
|
import chalk243 from "chalk";
|
|
35536
|
-
async function sqlQuery(
|
|
35537
|
-
if (isMutation(
|
|
35715
|
+
async function sqlQuery(query, connectionName) {
|
|
35716
|
+
if (isMutation(query)) {
|
|
35538
35717
|
console.error(
|
|
35539
35718
|
chalk243.red(
|
|
35540
35719
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
@@ -35545,7 +35724,7 @@ async function sqlQuery(query2, connectionName) {
|
|
|
35545
35724
|
const conn = resolveConnection3(connectionName);
|
|
35546
35725
|
const pool = await sqlConnect(conn);
|
|
35547
35726
|
try {
|
|
35548
|
-
const result = await pool.request().query(
|
|
35727
|
+
const result = await pool.request().query(query);
|
|
35549
35728
|
const rows = result.recordset ?? [];
|
|
35550
35729
|
if (result.recordset) {
|
|
35551
35730
|
printTable(rows);
|
|
@@ -35595,12 +35774,12 @@ function registerSql(program2) {
|
|
|
35595
35774
|
auth2.command("remove <name>").description("Remove a configured connection").action((name) => sqlAuth.remove(name));
|
|
35596
35775
|
cmd.command("set-connection <name>").description("Set the default SQL connection").action((name) => sqlSetConnection(name));
|
|
35597
35776
|
cmd.command("query <sql> [connection]").description("Execute a read-only SQL query (rejects mutating statements)").action(
|
|
35598
|
-
(
|
|
35777
|
+
(query, connection) => sqlQuery(query, connection)
|
|
35599
35778
|
);
|
|
35600
35779
|
cmd.command("mutate <sql> [connection]").description(
|
|
35601
35780
|
"Execute a mutating SQL statement (rejects non-mutating statements)"
|
|
35602
35781
|
).action(
|
|
35603
|
-
(
|
|
35782
|
+
(query, connection) => sqlMutate(query, connection)
|
|
35604
35783
|
);
|
|
35605
35784
|
cmd.command("tables [connection]").description("List tables in the connected database").action((connection) => sqlTables(connection));
|
|
35606
35785
|
cmd.command("columns <table> [connection]").description(
|