@staff0rd/assist 0.684.0 → 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/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.684.0",
9
+ version: "0.685.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -3066,7 +3066,7 @@ var refactorConfigHelp = [
3066
3066
  var releasesConfigHelp = [
3067
3067
  {
3068
3068
  key: "releases.streams",
3069
- setter: "assist releases configure <owner/repo>",
3069
+ setter: "assist releases configure --streams <file>",
3070
3070
  note: "promotion streams the /releases page draws; each names a repo, its release workflow, its nodes and the edges between them"
3071
3071
  }
3072
3072
  ];
@@ -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 query2 = `{ viewer { contributionsCollection(from: "${from}T00:00:00Z", to: "${to}T23:59:59Z") { contributionCalendar { weeks { contributionDays { date contributionCount } } } } } }`;
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='${query2}' --jq '${jq}'`, {
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, query2, origin) {
7416
- const pattern2 = `%${query2}%`;
7417
- const numberPattern = `%${query2.replace(/^#/, "")}%`;
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(query2) {
7476
+ async function searchBacklog(query) {
7477
7477
  const { orm } = await getReady();
7478
7478
  const origin = getOrigin();
7479
- const ids = await searchItemIds(orm, query2, origin);
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(query2) {
10268
+ async function searchBacklogSummaries(query) {
10269
10269
  const { orm } = await getReady();
10270
10270
  const origin = getOrigin();
10271
- const ids = await searchItemIds(orm, query2, origin);
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, query2) {
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 query2) {
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, query2) {
11594
- const needle = query2.trim().toLowerCase();
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, query2, limit) {
11603
+ function rankFilePaths(paths, query, limit) {
11604
11604
  const scored = [];
11605
11605
  for (const path91 of paths) {
11606
- const score = scoreFilePath(path91, query2);
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 query2 = new URL(req.url ?? "/", "http://localhost").searchParams.get("q") ?? "";
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, query2, MAX_RESULTS) });
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 query2 = db.select({
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 query2.limit(options2.limit).offset(options2.offset ?? 0);
11917
+ return query.limit(options2.limit).offset(options2.offset ?? 0);
11918
11918
  }
11919
- return query2;
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 query2 = db.select({
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 query2 : await query2.limit(options2.limit).offset(options2.offset ?? 0);
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
 
@@ -12127,7 +12127,7 @@ import { execFile as execFile5 } from "child_process";
12127
12127
  import { promisify as promisify5 } from "util";
12128
12128
  var execFileAsync4 = promisify5(execFile5);
12129
12129
  var CACHE_TTL_MS4 = 3e4;
12130
- function createCachedGhJson(args, parse4, fallback, options2 = {}) {
12130
+ function createCachedGhJson(args, parse5, fallback, options2 = {}) {
12131
12131
  const { cacheFallback = true } = options2;
12132
12132
  const cache6 = /* @__PURE__ */ new Map();
12133
12133
  return async (cwd, extraArgs = []) => {
@@ -12142,7 +12142,7 @@ function createCachedGhJson(args, parse4, fallback, options2 = {}) {
12142
12142
  windowsHide: true,
12143
12143
  cwd: toGitCwd(cwd)
12144
12144
  });
12145
- value = parse4(stdout);
12145
+ value = parse5(stdout);
12146
12146
  } catch {
12147
12147
  value = fallback;
12148
12148
  }
@@ -12341,44 +12341,87 @@ async function commitsBehind(cwd, repo, base, sha) {
12341
12341
  }
12342
12342
  }
12343
12343
 
12344
- // src/commands/sessions/web/releases/environmentState.ts
12345
- async function environmentState(cwd, repo, defaultBranch, node, live) {
12346
- const environment = node.environment ?? node.id;
12347
- const deployment = live.get(environment);
12348
- const behind = deployment && defaultBranch ? await commitsBehind(cwd, repo, defaultBranch, deployment.sha) : null;
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
- sha: deployment?.sha ?? null,
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/liveDeployments.ts
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
- function query(environments) {
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
- function newestSuccessful(nodes) {
12372
- const live = /* @__PURE__ */ new Map();
12373
- for (const node of nodes) {
12374
- if (!node?.environment || !node.commitOid) continue;
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=${query(environments)}`,
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
- live: newestSuccessful(repository.deployments?.nodes ?? [])
12443
+ head: headCommit(repository.defaultBranchRef?.target),
12444
+ ...deploymentMaps(repository.deployments?.nodes ?? [])
12401
12445
  };
12402
12446
  }
12403
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
12505
+ };
12506
+ }
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 { defaultBranch, live } = await liveDeployments(
12418
- cwd,
12419
- stream.repo,
12420
- nodes.map((node) => node.environment ?? node.id)
12421
- );
12422
- const environments = await Promise.all(
12423
- nodes.map(
12424
- (node) => environmentState(cwd, stream.repo, defaultBranch, node, live)
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 { ...declared, defaultBranch, environments };
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
- environments: [],
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(query2) {
15776
- const items2 = await searchBacklog(query2);
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 "${query2}".`));
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 "${query2}":
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(query2, vars = {}) {
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: query2, variables: vars }),
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);
@@ -28754,71 +28933,63 @@ function registerRavendb(program2) {
28754
28933
  // src/commands/releases/releasesConfigure.ts
28755
28934
  import chalk198 from "chalk";
28756
28935
 
28757
- // src/commands/releases/buildConfigurePrompt.ts
28758
- var SCHEMA_EXAMPLE = `releases:
28759
- streams:
28760
- - name: Web App
28761
- repo: owner/name
28762
- workflow: release.yml
28763
- nodes:
28764
- - { id: build, kind: build }
28765
- - { id: dev, environment: dev }
28766
- - { id: promote, kind: gate }
28767
- - { id: uk-prod, environment: UK Production, label: uk-prod }
28768
- edges:
28769
- - [build, dev]
28770
- - [dev, promote]
28771
- - [promote, uk-prod]`;
28772
- function buildConfigurePrompt(repo) {
28773
- return `Derive the release promotion topology of ${repo} and write it into assist's config under \`releases.streams\`.
28774
-
28775
- ## Read the workflows from GitHub
28776
-
28777
- Do not assume ${repo} is checked out here.
28778
-
28779
- - \`gh api repos/${repo}/contents/.github/workflows --jq '.[].name'\` lists the workflow files.
28780
- - \`gh api repos/${repo}/contents/.github/workflows/<file> --jq .content | base64 -d\` reads one.
28781
- - A job with \`uses: <owner>/<name>/.github/workflows/<file>@<ref>\` calls a reusable workflow. Read that file too, from the repo and ref it names, and keep following \`uses:\` to any depth \u2014 a deploy three levels down is still a node in the graph.
28782
-
28783
- ## Derive
28784
-
28785
- - **Streams** \u2014 one per release pipeline. A repo releasing two apps has two streams, whether they share a workflow or not. Name each after the thing released, not after the workflow file. \`workflow\` is the file name of the workflow the promotion runs under, the top-level one, not the reusable ones it calls.
28786
- - **Nodes** \u2014 one per step worth drawing:
28787
- - a job that deploys to a GitHub environment: \`{ id: <short-id>, environment: <name> }\`
28788
- - a job that builds or packages and deploys nothing: \`{ id: <short-id>, kind: build }\`
28789
- - a job or environment approval that only gates promotion: \`{ id: <short-id>, kind: gate }\`
28790
- - \`label\` overrides the text drawn on the node; set it only where \`id\` reads badly.
28791
- - **Environment names** must be the names GitHub knows, spelled as the repo's environments spell them \u2014 live state is read from the repo's deployments against them. Where a reusable workflow takes the name as an input, follow the input back to its value at the call site rather than recording the input's name. \`gh api repos/${repo}/environments --jq '.environments[].name'\` is the check.
28792
- - **Edges** \u2014 \`[from, to]\` for each \`needs:\` relation between the nodes you kept, flattened across reusable-workflow boundaries: where a job needs a \`uses:\` job, the edge runs to or from the inner job that actually neighbours it. Fan-in (several nodes into one gate) and fan-out (one node into several) are both expected and must both survive the flattening.
28793
-
28794
- ## Confirm before writing
28795
-
28796
- Ask rather than guess: which jobs deserve a node, how jobs split into streams, what to call a stream, and any environment name that is computed rather than written literally. Show the graph you intend to write \u2014 nodes and edges \u2014 and let me correct it before anything is written.
28797
-
28798
- ## Write
28799
-
28800
- Put the block in the assist config of the repo you are running in (\`.claude/assist.yml\` or \`assist.yml\`), or in \`~/.assist.yml\` for one that should follow me everywhere. Ask which if there is any doubt. Keep streams already declared for other repos, and replace the ones whose \`repo\` is \`${repo}\`.
28801
-
28802
- ${SCHEMA_EXAMPLE}
28803
-
28804
- Then run \`assist releases list\` to confirm assist reads the block back as you meant it, and exit. Do not run \`assist releases configure\`.`;
28936
+ // src/commands/releases/checkStreamGraph.ts
28937
+ function nodeIds(stream) {
28938
+ const nodes = Array.isArray(stream.nodes) ? stream.nodes : [];
28939
+ return nodes.flatMap(
28940
+ (node) => node !== null && typeof node === "object" && typeof node.id === "string" ? [node.id] : []
28941
+ );
28942
+ }
28943
+ function repeatedIds(ids) {
28944
+ const seen = /* @__PURE__ */ new Set();
28945
+ const repeated = /* @__PURE__ */ new Set();
28946
+ for (const id of ids) {
28947
+ if (seen.has(id)) repeated.add(id);
28948
+ seen.add(id);
28949
+ }
28950
+ return [...repeated];
28951
+ }
28952
+ function unknownEdgeIds(stream, known) {
28953
+ const edges = Array.isArray(stream.edges) ? stream.edges : [];
28954
+ return edges.flatMap(
28955
+ (edge) => (Array.isArray(edge) ? edge : []).filter(
28956
+ (id) => typeof id === "string" && !known.has(id)
28957
+ )
28958
+ );
28959
+ }
28960
+ function checkStreamGraph(streams) {
28961
+ return streams.flatMap((stream, index3) => {
28962
+ const where = typeof stream.name === "string" ? stream.name : `stream ${index3}`;
28963
+ const ids = nodeIds(stream);
28964
+ return [
28965
+ ...repeatedIds(ids).map((id) => `${where}: duplicate node id "${id}"`),
28966
+ ...unknownEdgeIds(stream, new Set(ids)).map(
28967
+ (id) => `${where}: edge refers to unknown node "${id}"`
28968
+ )
28969
+ ];
28970
+ });
28805
28971
  }
28806
28972
 
28807
- // src/commands/releases/readRepoStreams.ts
28808
- import { ZodError } from "zod";
28809
- function readRepoStreams(repo) {
28973
+ // src/commands/releases/readStreamsInput.ts
28974
+ import { readFileSync as readFileSync47 } from "fs";
28975
+ import { parse as parse4 } from "yaml";
28976
+ function readSource2(source) {
28977
+ return readFileSync47(source === "-" ? 0 : source, "utf8");
28978
+ }
28979
+ function readStreamsInput(source) {
28980
+ let parsed;
28810
28981
  try {
28811
- const streams = loadConfig().releases?.streams ?? [];
28812
- const wanted = repo.toLowerCase();
28813
- return { streams: streams.filter((s) => s.repo.toLowerCase() === wanted) };
28982
+ parsed = parse4(readSource2(source));
28814
28983
  } catch (error) {
28815
- return { error: describeConfigError(error) };
28984
+ return { error: error instanceof Error ? error.message : String(error) };
28816
28985
  }
28817
- }
28818
- function describeConfigError(error) {
28819
- if (error instanceof ZodError)
28820
- return error.issues.map((issue) => ` ${issue.path.join(".")}: ${issue.message}`).join("\n");
28821
- return error instanceof Error ? error.message : String(error);
28986
+ if (!Array.isArray(parsed))
28987
+ return { error: `Expected an array of streams, got ${typeof parsed}.` };
28988
+ const bad = parsed.findIndex(
28989
+ (s) => s === null || typeof s !== "object" || Array.isArray(s)
28990
+ );
28991
+ if (bad !== -1) return { error: `Stream ${bad} is not an object.` };
28992
+ return { streams: parsed };
28822
28993
  }
28823
28994
 
28824
28995
  // src/commands/releases/reportDerivedStreams.ts
@@ -28839,39 +29010,130 @@ function printDerived(stream) {
28839
29010
  const edges = stream.edges.map(([from, to]) => `${from} \u2192 ${to}`);
28840
29011
  console.log(` edges: ${edges.join(", ") || chalk197.dim("none")}`);
28841
29012
  }
28842
- function reportDerivedStreams(repo, before) {
28843
- const after = readRepoStreams(repo);
28844
- if ("error" in after) {
28845
- console.error(
28846
- chalk197.red(`releases.streams does not validate:
28847
- ${after.error}`)
28848
- );
28849
- process.exitCode = 1;
28850
- return;
29013
+ function reportDerivedStreams(streams, target) {
29014
+ for (const stream of streams) printDerived(stream);
29015
+ console.log(chalk197.dim(`Written to ${target}`));
29016
+ }
29017
+
29018
+ // src/commands/releases/withCurrentRepo.ts
29019
+ function withCurrentRepo(streams) {
29020
+ if (streams.every((stream) => typeof stream.repo === "string"))
29021
+ return streams;
29022
+ const { org, repo } = getRepoInfo();
29023
+ return streams.map((stream) => ({ repo: `${org}/${repo}`, ...stream }));
29024
+ }
29025
+
29026
+ // src/commands/config/applyConfigWrites.ts
29027
+ function applyConfigWrites(base, writes, schema2) {
29028
+ let updated2 = base;
29029
+ for (const write of writes) {
29030
+ updated2 = setNestedValue(updated2, write.key, write.value);
29031
+ const validation = validateConfig(updated2, write.key, schema2);
29032
+ if (!validation.ok) return validation;
28851
29033
  }
28852
- if (after.streams.length === 0) {
28853
- console.log(chalk197.yellow(`No stream is declared for ${repo}.`));
28854
- return;
29034
+ return { ok: true, updated: updated2 };
29035
+ }
29036
+
29037
+ // src/commands/config/writeConfigKeys.ts
29038
+ function writeConfigKeys(writes, scope, cwd = process.cwd(), globalConfigPath) {
29039
+ const globalOnly = writes.filter((write) => isGlobalOnlyConfigKey(write.key));
29040
+ if (globalOnly.length > 0) {
29041
+ return {
29042
+ ok: false,
29043
+ errors: globalOnly.map(
29044
+ (write) => `"${write.key}" is a global-only key. Set it with 'assist config set ${write.key} <value> -g'`
29045
+ )
29046
+ };
28855
29047
  }
28856
- if (JSON.stringify(after.streams) === JSON.stringify(before))
28857
- console.log(chalk197.dim(`releases.streams for ${repo} is unchanged.`));
28858
- for (const stream of after.streams) printDerived(stream);
29048
+ if (scope === "repo") return writeRepoBlock(writes, cwd, globalConfigPath);
29049
+ const applied = applyConfigWrites(loadProjectConfig(cwd), writes);
29050
+ if (!applied.ok) return applied;
29051
+ saveConfig(applied.updated, cwd);
29052
+ return { ok: true, target: "project assist.yml" };
29053
+ }
29054
+ function writeRepoBlock(writes, cwd, globalConfigPath) {
29055
+ const { globalRaw, repos: repos2, label: label2, block } = resolveRepoConfigBlock(
29056
+ void 0,
29057
+ cwd,
29058
+ globalConfigPath
29059
+ );
29060
+ const applied = applyConfigWrites(block, writes, repoConfigSchema);
29061
+ if (!applied.ok) return applied;
29062
+ repos2[label2] = applied.updated;
29063
+ saveGlobalConfig({ ...globalRaw, repos: repos2 }, globalConfigPath);
29064
+ return { ok: true, target: `~/.assist.yml, repo: ${label2}` };
29065
+ }
29066
+
29067
+ // src/commands/releases/declaredStreamsInScope.ts
29068
+ function streamsOf(block) {
29069
+ const releases = block.releases;
29070
+ if (releases === null || typeof releases !== "object") return [];
29071
+ const streams = releases.streams;
29072
+ return Array.isArray(streams) ? streams : [];
29073
+ }
29074
+ function declaredStreamsInScope(scope, cwd = process.cwd()) {
29075
+ if (scope === "repo")
29076
+ return streamsOf(resolveRepoConfigBlock(void 0, cwd).block);
29077
+ return streamsOf(loadProjectConfig(cwd));
29078
+ }
29079
+
29080
+ // src/commands/releases/mergeRepoStreams.ts
29081
+ function repoOf(stream) {
29082
+ return typeof stream.repo === "string" ? stream.repo.toLowerCase() : "";
29083
+ }
29084
+ function mergeRepoStreams(declared, incoming) {
29085
+ const replaced = new Set(incoming.map(repoOf));
29086
+ return [
29087
+ ...declared.filter((stream) => !replaced.has(repoOf(stream))),
29088
+ ...incoming
29089
+ ];
29090
+ }
29091
+
29092
+ // src/commands/releases/writeReleaseStreams.ts
29093
+ function writeReleaseStreams(incoming, scope) {
29094
+ return writeConfigKeys(
29095
+ [
29096
+ {
29097
+ key: "releases.streams",
29098
+ value: mergeRepoStreams(declaredStreamsInScope(scope), incoming)
29099
+ }
29100
+ ],
29101
+ scope
29102
+ );
28859
29103
  }
28860
29104
 
28861
29105
  // src/commands/releases/releasesConfigure.ts
28862
- var REPO_RE = /^[^/\s]+\/[^/\s]+$/;
28863
- async function releasesConfigure(repo) {
28864
- if (!REPO_RE.test(repo)) {
28865
- console.error(chalk198.red(`Expected <owner/repo>, got '${repo}'.`));
28866
- process.exitCode = 1;
28867
- return;
28868
- }
28869
- const before = readRepoStreams(repo);
28870
- const { done: done2 } = spawnClaude(buildConfigurePrompt(repo), {
28871
- allowEdits: true
28872
- });
28873
- await done2;
28874
- reportDerivedStreams(repo, "streams" in before ? before.streams : []);
29106
+ function fail6(message3, details = []) {
29107
+ console.error(chalk198.red(message3));
29108
+ for (const detail of details) console.error(chalk198.red(` ${detail}`));
29109
+ process.exitCode = 1;
29110
+ }
29111
+ function reportWritten(incoming, target) {
29112
+ const repos2 = new Set(incoming.map((s) => String(s.repo).toLowerCase()));
29113
+ const declared = loadConfig().releases?.streams ?? [];
29114
+ reportDerivedStreams(
29115
+ declared.filter((s) => repos2.has(s.repo.toLowerCase())),
29116
+ target
29117
+ );
29118
+ }
29119
+ function releasesConfigure(options2 = {}) {
29120
+ const scope = options2.scope === "repo" ? "repo" : "project";
29121
+ const input = readStreamsInput(options2.streams ?? "-");
29122
+ if ("error" in input) return fail6(`Could not read --streams: ${input.error}`);
29123
+ const incoming = withCurrentRepo(input.streams);
29124
+ const broken = checkStreamGraph(incoming);
29125
+ if (broken.length > 0)
29126
+ return fail6(
29127
+ "The graph does not hold together, so nothing was written:",
29128
+ broken
29129
+ );
29130
+ const written = writeReleaseStreams(incoming, scope);
29131
+ if (!written.ok)
29132
+ return fail6(
29133
+ "releases.streams does not validate, so nothing was written:",
29134
+ written.errors
29135
+ );
29136
+ reportWritten(incoming, written.target);
28875
29137
  }
28876
29138
 
28877
29139
  // src/commands/releases/releasesList.ts
@@ -28904,11 +29166,18 @@ function registerReleases(parent) {
28904
29166
  configHelp(
28905
29167
  releasesCommand,
28906
29168
  releasesConfigHelp,
28907
- "Streams are declared by 'assist releases configure <owner/repo>' or by hand in assist.yml, and rendered by the /releases page of the sessions dashboard."
29169
+ "Streams are declared by '/releases-configure', which derives them from the repo's workflows and writes them with 'assist releases configure', and rendered by the /releases page of the sessions dashboard."
28908
29170
  );
28909
29171
  releasesCommand.command("list").description("List the declared release streams, their nodes and edges").action(releasesList);
28910
- releasesCommand.command("configure <owner/repo>").description(
28911
- "Derive a repo's promotion topology with Claude and write it to releases.streams"
29172
+ releasesCommand.command("configure").description(
29173
+ "Validate release streams and write them to releases.streams for the current repo"
29174
+ ).requiredOption(
29175
+ "--streams <file>",
29176
+ "JSON or YAML array of streams to declare; '-' reads stdin"
29177
+ ).option(
29178
+ "--scope <project|repo>",
29179
+ "project assist.yml or ~/.assist.yml repo block",
29180
+ "project"
28912
29181
  ).action(releasesConfigure);
28913
29182
  }
28914
29183
 
@@ -29526,7 +29795,7 @@ function buildLimitsSegment(rateLimits) {
29526
29795
  }
29527
29796
 
29528
29797
  // src/commands/readGitBranch.ts
29529
- import { readFileSync as readFileSync47, statSync as statSync10 } from "fs";
29798
+ import { readFileSync as readFileSync48, statSync as statSync10 } from "fs";
29530
29799
  import { isAbsolute as isAbsolute5, join as join76, resolve as resolve20 } from "path";
29531
29800
  function resolveGitDir(cwd) {
29532
29801
  const dotGit = join76(cwd, ".git");
@@ -29541,7 +29810,7 @@ function resolveGitDir(cwd) {
29541
29810
  }
29542
29811
  let contents;
29543
29812
  try {
29544
- contents = readFileSync47(dotGit, "utf8");
29813
+ contents = readFileSync48(dotGit, "utf8");
29545
29814
  } catch {
29546
29815
  return null;
29547
29816
  }
@@ -29559,7 +29828,7 @@ function readGitBranch(cwd) {
29559
29828
  }
29560
29829
  let head;
29561
29830
  try {
29562
- head = readFileSync47(join76(gitDir, "HEAD"), "utf8");
29831
+ head = readFileSync48(join76(gitDir, "HEAD"), "utf8");
29563
29832
  } catch {
29564
29833
  return null;
29565
29834
  }
@@ -31453,47 +31722,6 @@ function coerceSupplied(key, supplied) {
31453
31722
  return coercion.value;
31454
31723
  }
31455
31724
 
31456
- // src/commands/config/applyConfigWrites.ts
31457
- function applyConfigWrites(base, writes, schema2) {
31458
- let updated2 = base;
31459
- for (const write of writes) {
31460
- updated2 = setNestedValue(updated2, write.key, write.value);
31461
- const validation = validateConfig(updated2, write.key, schema2);
31462
- if (!validation.ok) return validation;
31463
- }
31464
- return { ok: true, updated: updated2 };
31465
- }
31466
-
31467
- // src/commands/config/writeConfigKeys.ts
31468
- function writeConfigKeys(writes, scope, cwd = process.cwd(), globalConfigPath) {
31469
- const globalOnly = writes.filter((write) => isGlobalOnlyConfigKey(write.key));
31470
- if (globalOnly.length > 0) {
31471
- return {
31472
- ok: false,
31473
- errors: globalOnly.map(
31474
- (write) => `"${write.key}" is a global-only key. Set it with 'assist config set ${write.key} <value> -g'`
31475
- )
31476
- };
31477
- }
31478
- if (scope === "repo") return writeRepoBlock(writes, cwd, globalConfigPath);
31479
- const applied = applyConfigWrites(loadProjectConfig(cwd), writes);
31480
- if (!applied.ok) return applied;
31481
- saveConfig(applied.updated, cwd);
31482
- return { ok: true, target: "project assist.yml" };
31483
- }
31484
- function writeRepoBlock(writes, cwd, globalConfigPath) {
31485
- const { globalRaw, repos: repos2, label: label2, block } = resolveRepoConfigBlock(
31486
- void 0,
31487
- cwd,
31488
- globalConfigPath
31489
- );
31490
- const applied = applyConfigWrites(block, writes, repoConfigSchema);
31491
- if (!applied.ok) return applied;
31492
- repos2[label2] = applied.updated;
31493
- saveGlobalConfig({ ...globalRaw, repos: repos2 }, globalConfigPath);
31494
- return { ok: true, target: `~/.assist.yml, repo: ${label2}` };
31495
- }
31496
-
31497
31725
  // src/commands/config/configureConfigKeys.ts
31498
31726
  async function configureConfigKeys(questions, options2 = {}) {
31499
31727
  const scope = options2.scope ?? await promptConfigScope();
@@ -32102,7 +32330,7 @@ function fetchHighLevelPr(prNumber, repo) {
32102
32330
  }
32103
32331
 
32104
32332
  // src/commands/review/highLevel/loadHighLevelReview.ts
32105
- import { existsSync as existsSync64, readFileSync as readFileSync48 } from "fs";
32333
+ import { existsSync as existsSync64, readFileSync as readFileSync49 } from "fs";
32106
32334
 
32107
32335
  // src/commands/review/highLevel/highLevelReviewPath.ts
32108
32336
  import { join as join77 } from "path";
@@ -32123,7 +32351,7 @@ function loadHighLevelReview(repo, headRef, headSha) {
32123
32351
  const path91 = highLevelReviewPath(repo, headRef, headSha);
32124
32352
  if (!existsSync64(path91)) return void 0;
32125
32353
  try {
32126
- return JSON.parse(readFileSync48(path91, "utf8"));
32354
+ return JSON.parse(readFileSync49(path91, "utf8"));
32127
32355
  } catch {
32128
32356
  return void 0;
32129
32357
  }
@@ -32698,7 +32926,7 @@ function gatherContext() {
32698
32926
  }
32699
32927
 
32700
32928
  // src/commands/review/postReviewToPr.ts
32701
- import { readFileSync as readFileSync49 } from "fs";
32929
+ import { readFileSync as readFileSync50 } from "fs";
32702
32930
 
32703
32931
  // src/commands/review/carriedUnanchoredFindings.ts
32704
32932
  function carriedUnanchoredFindings(unanchored) {
@@ -33149,7 +33377,7 @@ async function confirmPost(prNumber, work, options2) {
33149
33377
  return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
33150
33378
  }
33151
33379
  async function postFindingsToPr(prInfo, synthesisPath, options2) {
33152
- const markdown = readFileSync49(synthesisPath, "utf8");
33380
+ const markdown = readFileSync50(synthesisPath, "utf8");
33153
33381
  const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
33154
33382
  const carried = carriedUnanchoredFindings(unanchored);
33155
33383
  if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
@@ -33737,8 +33965,8 @@ function formatToolSummary(input) {
33737
33965
  if (command) return truncate2(command);
33738
33966
  const url = getString(record, "url");
33739
33967
  if (url) return url;
33740
- const query2 = getString(record, "query");
33741
- if (query2) return truncate2(query2);
33968
+ const query = getString(record, "query");
33969
+ if (query) return truncate2(query);
33742
33970
  const description = getString(record, "description");
33743
33971
  if (description) return truncate2(description);
33744
33972
  return "";
@@ -34169,7 +34397,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
34169
34397
  }
34170
34398
 
34171
34399
  // src/commands/review/synthesise.ts
34172
- import { readFileSync as readFileSync50 } from "fs";
34400
+ import { readFileSync as readFileSync51 } from "fs";
34173
34401
 
34174
34402
  // src/commands/review/buildSynthesisStdin.ts
34175
34403
  var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
@@ -34234,7 +34462,7 @@ Files:
34234
34462
 
34235
34463
  // src/commands/review/synthesise.ts
34236
34464
  function printSummary2(synthesisPath) {
34237
- const markdown = readFileSync50(synthesisPath, "utf8");
34465
+ const markdown = readFileSync51(synthesisPath, "utf8");
34238
34466
  console.log("");
34239
34467
  console.log(buildReviewSummary(markdown));
34240
34468
  console.log("");
@@ -34547,7 +34775,7 @@ function registerReview(program2) {
34547
34775
  }
34548
34776
 
34549
34777
  // src/commands/rules/addRule.ts
34550
- import { existsSync as existsSync70, readFileSync as readFileSync54, writeFileSync as writeFileSync43 } from "fs";
34778
+ import { existsSync as existsSync70, readFileSync as readFileSync55, writeFileSync as writeFileSync43 } from "fs";
34551
34779
  import path73 from "path";
34552
34780
  import chalk229 from "chalk";
34553
34781
 
@@ -34572,7 +34800,7 @@ function insertRuleBullet(content, rule) {
34572
34800
  }
34573
34801
 
34574
34802
  // src/commands/rules/nextRuleCode.ts
34575
- import { readFileSync as readFileSync51 } from "fs";
34803
+ import { readFileSync as readFileSync52 } from "fs";
34576
34804
 
34577
34805
  // src/commands/rules/findClaudeFiles.ts
34578
34806
  import { readdirSync as readdirSync14 } from "fs";
@@ -34596,7 +34824,7 @@ function findClaudeFiles(dir) {
34596
34824
  var CODE_PREFIX = "R";
34597
34825
  function nextRuleCode(root) {
34598
34826
  const numbers = findClaudeFiles(root).flatMap(
34599
- (file) => parseRulesSection(readFileSync51(file, "utf8")).map(
34827
+ (file) => parseRulesSection(readFileSync52(file, "utf8")).map(
34600
34828
  (rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
34601
34829
  )
34602
34830
  );
@@ -34622,15 +34850,15 @@ function resolveRuleScope(target) {
34622
34850
  }
34623
34851
 
34624
34852
  // src/commands/rules/updateScopedRulesIndex.ts
34625
- import { existsSync as existsSync69, readFileSync as readFileSync53, writeFileSync as writeFileSync42 } from "fs";
34853
+ import { existsSync as existsSync69, readFileSync as readFileSync54, writeFileSync as writeFileSync42 } from "fs";
34626
34854
  import path72 from "path";
34627
34855
 
34628
34856
  // src/commands/rules/scopedRuleDirectories.ts
34629
- import { readFileSync as readFileSync52 } from "fs";
34857
+ import { readFileSync as readFileSync53 } from "fs";
34630
34858
  import path71 from "path";
34631
34859
  function scopedRuleDirectories(root) {
34632
34860
  return findClaudeFiles(root).filter(
34633
- (file) => path71.dirname(file) !== root && parseRulesSection(readFileSync52(file, "utf8")).length > 0
34861
+ (file) => path71.dirname(file) !== root && parseRulesSection(readFileSync53(file, "utf8")).length > 0
34634
34862
  ).map(
34635
34863
  (file) => `${path71.relative(root, path71.dirname(file)).split(path71.sep).join("/")}/`
34636
34864
  ).sort();
@@ -34672,7 +34900,7 @@ function upsertScopedRulesPointer(content, directories) {
34672
34900
  function updateScopedRulesIndex(root) {
34673
34901
  const directories = scopedRuleDirectories(root);
34674
34902
  const rootFile = path72.join(root, "CLAUDE.md");
34675
- const before = existsSync69(rootFile) ? readFileSync53(rootFile, "utf8") : "";
34903
+ const before = existsSync69(rootFile) ? readFileSync54(rootFile, "utf8") : "";
34676
34904
  const after = upsertScopedRulesPointer(before, directories);
34677
34905
  if (after !== before) writeFileSync42(rootFile, after);
34678
34906
  return directories;
@@ -34680,7 +34908,7 @@ function updateScopedRulesIndex(root) {
34680
34908
 
34681
34909
  // src/commands/rules/addRule.ts
34682
34910
  function read2(file) {
34683
- return existsSync70(file) ? readFileSync54(file, "utf8") : "";
34911
+ return existsSync70(file) ? readFileSync55(file, "utf8") : "";
34684
34912
  }
34685
34913
  function addRule(text18, options2) {
34686
34914
  const rule = text18.trim();
@@ -35144,12 +35372,12 @@ import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync45 } from "fs";
35144
35372
  import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync44 } from "fs";
35145
35373
 
35146
35374
  // src/commands/slack/readSlackParts.ts
35147
- import { readFileSync as readFileSync55 } from "fs";
35375
+ import { readFileSync as readFileSync56 } from "fs";
35148
35376
  function readSlackParts(files) {
35149
35377
  return files.map((file) => {
35150
35378
  let contents;
35151
35379
  try {
35152
- contents = readFileSync55(file, "utf8");
35380
+ contents = readFileSync56(file, "utf8");
35153
35381
  } catch {
35154
35382
  console.error(`Error: Part file not found: ${file}`);
35155
35383
  process.exit(1);
@@ -35463,8 +35691,8 @@ function isMutation(sql29) {
35463
35691
  }
35464
35692
 
35465
35693
  // src/commands/sql/sqlMutate.ts
35466
- async function sqlMutate(query2, connectionName) {
35467
- if (!isMutation(query2)) {
35694
+ async function sqlMutate(query, connectionName) {
35695
+ if (!isMutation(query)) {
35468
35696
  console.error(
35469
35697
  chalk242.red(
35470
35698
  "assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
@@ -35475,7 +35703,7 @@ async function sqlMutate(query2, connectionName) {
35475
35703
  const conn = resolveConnection3(connectionName);
35476
35704
  const pool = await sqlConnect(conn);
35477
35705
  try {
35478
- const result = await pool.request().query(query2);
35706
+ const result = await pool.request().query(query);
35479
35707
  console.log(chalk242.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
35480
35708
  } finally {
35481
35709
  await pool.close();
@@ -35484,8 +35712,8 @@ async function sqlMutate(query2, connectionName) {
35484
35712
 
35485
35713
  // src/commands/sql/sqlQuery.ts
35486
35714
  import chalk243 from "chalk";
35487
- async function sqlQuery(query2, connectionName) {
35488
- if (isMutation(query2)) {
35715
+ async function sqlQuery(query, connectionName) {
35716
+ if (isMutation(query)) {
35489
35717
  console.error(
35490
35718
  chalk243.red(
35491
35719
  "assist sql query refuses mutating statements. Use `assist sql mutate` instead."
@@ -35496,7 +35724,7 @@ async function sqlQuery(query2, connectionName) {
35496
35724
  const conn = resolveConnection3(connectionName);
35497
35725
  const pool = await sqlConnect(conn);
35498
35726
  try {
35499
- const result = await pool.request().query(query2);
35727
+ const result = await pool.request().query(query);
35500
35728
  const rows = result.recordset ?? [];
35501
35729
  if (result.recordset) {
35502
35730
  printTable(rows);
@@ -35546,12 +35774,12 @@ function registerSql(program2) {
35546
35774
  auth2.command("remove <name>").description("Remove a configured connection").action((name) => sqlAuth.remove(name));
35547
35775
  cmd.command("set-connection <name>").description("Set the default SQL connection").action((name) => sqlSetConnection(name));
35548
35776
  cmd.command("query <sql> [connection]").description("Execute a read-only SQL query (rejects mutating statements)").action(
35549
- (query2, connection) => sqlQuery(query2, connection)
35777
+ (query, connection) => sqlQuery(query, connection)
35550
35778
  );
35551
35779
  cmd.command("mutate <sql> [connection]").description(
35552
35780
  "Execute a mutating SQL statement (rejects non-mutating statements)"
35553
35781
  ).action(
35554
- (query2, connection) => sqlMutate(query2, connection)
35782
+ (query, connection) => sqlMutate(query, connection)
35555
35783
  );
35556
35784
  cmd.command("tables [connection]").description("List tables in the connected database").action((connection) => sqlTables(connection));
35557
35785
  cmd.command("columns <table> [connection]").description(
@@ -36225,9 +36453,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
36225
36453
  }
36226
36454
 
36227
36455
  // src/commands/transcript/convert/readCleanedCues.ts
36228
- import { readFileSync as readFileSync59 } from "fs";
36456
+ import { readFileSync as readFileSync60 } from "fs";
36229
36457
  function readCleanedCues(inputPath) {
36230
- return deduplicateCues(parseVtt(readFileSync59(inputPath, "utf8")));
36458
+ return deduplicateCues(parseVtt(readFileSync60(inputPath, "utf8")));
36231
36459
  }
36232
36460
 
36233
36461
  // src/commands/transcript/clean.ts
@@ -36533,7 +36761,7 @@ function widenAudience(passages) {
36533
36761
  }
36534
36762
 
36535
36763
  // src/commands/transcript/merge.ts
36536
- function readSource2(file) {
36764
+ function readSource3(file) {
36537
36765
  if (!existsSync78(file)) failTranscript(`VTT file not found: ${file}`);
36538
36766
  const cues = readCleanedCues(file);
36539
36767
  if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
@@ -36551,7 +36779,7 @@ async function readSelection(source) {
36551
36779
  return readJsonPayload(source, selectionSchema, "transcript selection");
36552
36780
  }
36553
36781
  async function merge(files, options2 = {}) {
36554
- const sources = files.map(readSource2);
36782
+ const sources = files.map(readSource3);
36555
36783
  const selection = await readSelection(options2.select);
36556
36784
  const selected = selection ? selectPassages(sources, selection) : wholePassages(sources);
36557
36785
  const passages = rebasePassages(
@@ -36739,14 +36967,14 @@ function devices() {
36739
36967
  }
36740
36968
 
36741
36969
  // src/commands/voice/logs.ts
36742
- import { existsSync as existsSync79, readFileSync as readFileSync60 } from "fs";
36970
+ import { existsSync as existsSync79, readFileSync as readFileSync61 } from "fs";
36743
36971
  function logs(options2) {
36744
36972
  if (!existsSync79(voicePaths.log)) {
36745
36973
  console.log("No voice log file found");
36746
36974
  return;
36747
36975
  }
36748
36976
  const count8 = Number.parseInt(options2.lines ?? "150", 10);
36749
- const content = readFileSync60(voicePaths.log, "utf8").trim();
36977
+ const content = readFileSync61(voicePaths.log, "utf8").trim();
36750
36978
  if (!content) {
36751
36979
  console.log("Voice log is empty");
36752
36980
  return;
@@ -36773,7 +37001,7 @@ import { join as join96 } from "path";
36773
37001
 
36774
37002
  // src/commands/voice/checkLockFile.ts
36775
37003
  import { execSync as execSync66 } from "child_process";
36776
- import { existsSync as existsSync80, mkdirSync as mkdirSync33, readFileSync as readFileSync61, writeFileSync as writeFileSync51 } from "fs";
37004
+ import { existsSync as existsSync80, mkdirSync as mkdirSync33, readFileSync as readFileSync62, writeFileSync as writeFileSync51 } from "fs";
36777
37005
  import { join as join95 } from "path";
36778
37006
  function isProcessAlive2(pid) {
36779
37007
  try {
@@ -36787,7 +37015,7 @@ function checkLockFile() {
36787
37015
  const lockFile = getLockFile();
36788
37016
  if (!existsSync80(lockFile)) return;
36789
37017
  try {
36790
- const lock2 = JSON.parse(readFileSync61(lockFile, "utf8"));
37018
+ const lock2 = JSON.parse(readFileSync62(lockFile, "utf8"));
36791
37019
  if (lock2.pid && isProcessAlive2(lock2.pid)) {
36792
37020
  console.error(
36793
37021
  `Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
@@ -36889,7 +37117,7 @@ function start2(options2) {
36889
37117
  }
36890
37118
 
36891
37119
  // src/commands/voice/status.ts
36892
- import { existsSync as existsSync81, readFileSync as readFileSync62 } from "fs";
37120
+ import { existsSync as existsSync81, readFileSync as readFileSync63 } from "fs";
36893
37121
  function isProcessAlive3(pid) {
36894
37122
  try {
36895
37123
  process.kill(pid, 0);
@@ -36900,7 +37128,7 @@ function isProcessAlive3(pid) {
36900
37128
  }
36901
37129
  function readRecentLogs(count8) {
36902
37130
  if (!existsSync81(voicePaths.log)) return [];
36903
- const lines2 = readFileSync62(voicePaths.log, "utf8").trim().split("\n");
37131
+ const lines2 = readFileSync63(voicePaths.log, "utf8").trim().split("\n");
36904
37132
  return lines2.slice(-count8);
36905
37133
  }
36906
37134
  function status2() {
@@ -36908,7 +37136,7 @@ function status2() {
36908
37136
  console.log("Voice daemon: not running (no PID file)");
36909
37137
  return;
36910
37138
  }
36911
- const pid = Number.parseInt(readFileSync62(voicePaths.pid, "utf8").trim(), 10);
37139
+ const pid = Number.parseInt(readFileSync63(voicePaths.pid, "utf8").trim(), 10);
36912
37140
  const alive = isProcessAlive3(pid);
36913
37141
  console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
36914
37142
  const recent = readRecentLogs(5);
@@ -36927,13 +37155,13 @@ function status2() {
36927
37155
  }
36928
37156
 
36929
37157
  // src/commands/voice/stop.ts
36930
- import { existsSync as existsSync82, readFileSync as readFileSync63, unlinkSync as unlinkSync21 } from "fs";
37158
+ import { existsSync as existsSync82, readFileSync as readFileSync64, unlinkSync as unlinkSync21 } from "fs";
36931
37159
  function stop2() {
36932
37160
  if (!existsSync82(voicePaths.pid)) {
36933
37161
  console.log("Voice daemon is not running (no PID file)");
36934
37162
  return;
36935
37163
  }
36936
- const pid = Number.parseInt(readFileSync63(voicePaths.pid, "utf8").trim(), 10);
37164
+ const pid = Number.parseInt(readFileSync64(voicePaths.pid, "utf8").trim(), 10);
36937
37165
  try {
36938
37166
  process.kill(pid, "SIGTERM");
36939
37167
  console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
@@ -37804,7 +38032,7 @@ async function auth() {
37804
38032
 
37805
38033
  // src/commands/roam/postRoamActivity.ts
37806
38034
  import { execFileSync as execFileSync23 } from "child_process";
37807
- import { readdirSync as readdirSync22, readFileSync as readFileSync64, statSync as statSync13 } from "fs";
38035
+ import { readdirSync as readdirSync22, readFileSync as readFileSync65, statSync as statSync13 } from "fs";
37808
38036
  import { join as join100 } from "path";
37809
38037
  function findPortFile(roamDir) {
37810
38038
  let entries;
@@ -37835,7 +38063,7 @@ function postRoamActivity(app, event) {
37835
38063
  if (!portFile) return;
37836
38064
  let port;
37837
38065
  try {
37838
- port = readFileSync64(portFile, "utf8").trim();
38066
+ port = readFileSync65(portFile, "utf8").trim();
37839
38067
  } catch {
37840
38068
  return;
37841
38069
  }
@@ -38203,11 +38431,11 @@ function applyLine(result, pending, line) {
38203
38431
  }
38204
38432
 
38205
38433
  // src/commands/sessions/daemon/readDaemonPidFile.ts
38206
- import { readFileSync as readFileSync65 } from "fs";
38434
+ import { readFileSync as readFileSync66 } from "fs";
38207
38435
  function readDaemonPidFile() {
38208
38436
  try {
38209
38437
  const pid = Number.parseInt(
38210
- readFileSync65(daemonPaths.pid, "utf8").trim(),
38438
+ readFileSync66(daemonPaths.pid, "utf8").trim(),
38211
38439
  10
38212
38440
  );
38213
38441
  return Number.isInteger(pid) ? pid : void 0;
@@ -42403,14 +42631,14 @@ async function defaultConnect() {
42403
42631
  }
42404
42632
 
42405
42633
  // src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
42406
- import { existsSync as existsSync98, readFileSync as readFileSync67 } from "fs";
42634
+ import { existsSync as existsSync98, readFileSync as readFileSync68 } from "fs";
42407
42635
  import { posix as posix3 } from "path";
42408
42636
  function hasPersistedWindowsSessions() {
42409
42637
  const sessionsFile = windowsSessionsFileFromWsl();
42410
42638
  if (!sessionsFile) return false;
42411
42639
  try {
42412
42640
  if (!existsSync98(sessionsFile)) return false;
42413
- const data = JSON.parse(readFileSync67(sessionsFile, "utf8"));
42641
+ const data = JSON.parse(readFileSync68(sessionsFile, "utf8"));
42414
42642
  return Array.isArray(data) && data.length > 0;
42415
42643
  } catch (error) {
42416
42644
  const message3 = error instanceof Error ? error.message : String(error);
@@ -43597,10 +43825,10 @@ async function parseTranscript(sessionId) {
43597
43825
  if (rollout) return readMessages(rollout, parseCodexTranscriptLines);
43598
43826
  return [];
43599
43827
  }
43600
- async function readMessages(filePath, parse4) {
43828
+ async function readMessages(filePath, parse5) {
43601
43829
  try {
43602
43830
  const raw = await fs55.promises.readFile(filePath, "utf8");
43603
- return parse4(raw.split("\n"));
43831
+ return parse5(raw.split("\n"));
43604
43832
  } catch {
43605
43833
  return [];
43606
43834
  }
@@ -43835,7 +44063,7 @@ function handleConnection(socket, manager) {
43835
44063
  import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync54 } from "fs";
43836
44064
 
43837
44065
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
43838
- import { readFileSync as readFileSync68 } from "fs";
44066
+ import { readFileSync as readFileSync69 } from "fs";
43839
44067
  var WATCHDOG_INTERVAL_MS = 5e3;
43840
44068
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
43841
44069
  const timer = setInterval(() => {
@@ -43846,7 +44074,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
43846
44074
  }
43847
44075
  function ownsPidFile() {
43848
44076
  try {
43849
- return readFileSync68(daemonPaths.pid, "utf8").trim() === String(process.pid);
44077
+ return readFileSync69(daemonPaths.pid, "utf8").trim() === String(process.pid);
43850
44078
  } catch {
43851
44079
  return false;
43852
44080
  }