@staff0rd/assist 0.1049.0 → 0.1050.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.1049.0",
9
+ version: "0.1050.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -7655,12 +7655,13 @@ function buildManualCheckLines(manualChecks, commitBeforePhaseEnd, askCheck2 = f
7655
7655
  return [
7656
7656
  "",
7657
7657
  "Once verify passes, run /commit to commit the work before asking the user to perform the manual checks below.",
7658
- "Then raise each manual check with `assist ask-check --json - < <file>` as a background task, one check at a time, doing no other work until it returns (see the 'Asking for a manual check' advice for the payload). If it exits non-zero before opening, ask for that check in chat instead.",
7658
+ "Then raise each manual check with `assist ask-check --check <n> --json - < <file>` as a background task, where <n> is the check's number in the list below, one check at a time, doing no other work until it returns (see the 'Asking for a manual check' advice for the payload). If it exits non-zero before opening, ask for that check in chat instead.",
7659
7659
  "Keep your chat summary to a few lines; the check itself carries the steps.",
7660
7660
  "Manual checks:",
7661
- ...manualChecks.map((c) => `- ${c}`),
7661
+ ...manualChecks.map((c, i) => `${i + 1}. ${c}`),
7662
7662
  "",
7663
- "Wait for every manual check to come back works before proceeding; if one doesn't work, fix it and raise it again."
7663
+ "Wait for every manual check to come back works before proceeding; if one doesn't work, fix it and raise it again.",
7664
+ 'If a check comes back "moved to phase <m>", the user moved it to that later phase: treat it as resolved for this phase and do not raise it again. Moving a check renumbers the checks after it down by one, so pass their new <n>.'
7664
7665
  ];
7665
7666
  }
7666
7667
  if (manualChecks.length > 0) {
@@ -7754,6 +7755,46 @@ function buildStartedLines(item, phaseNumber) {
7754
7755
  ];
7755
7756
  }
7756
7757
 
7758
+ // src/commands/backlog/buildReviewCheckLines.ts
7759
+ function buildReviewCheckLines(manualChecks, askCheck2) {
7760
+ if (manualChecks.length === 0) return [];
7761
+ const list7 = manualChecks.map((c, i) => `${i + 1}. ${c}`);
7762
+ if (askCheck2) {
7763
+ return [
7764
+ "Manual checks moved to this Review phase:",
7765
+ ...list7,
7766
+ "",
7767
+ "Raise each of these with `assist ask-check --json - < <file>` as a background task, one check at a time, doing no other work until it returns (see the 'Asking for a manual check' advice for the payload). If it exits non-zero before opening, ask for that check in chat instead. Wait for every one to come back works; if one doesn't work, fix it and raise it again.",
7768
+ ""
7769
+ ];
7770
+ }
7771
+ return [
7772
+ "Manual checks moved to this Review phase \u2014 ask the user to perform each one and wait for them to confirm it passes:",
7773
+ ...list7,
7774
+ ""
7775
+ ];
7776
+ }
7777
+
7778
+ // src/commands/backlog/buildReviewCompletionLines.ts
7779
+ function buildReviewCompletionLines(itemId2, phaseNumber) {
7780
+ return [
7781
+ "What counts as a completion confirmation \u2014 read carefully:",
7782
+ "- Marking the item done/phase-done requires an explicit, unambiguous instruction to complete it (e.g. the user says the item is done/accepted or tells you to mark it complete). Nothing else counts.",
7783
+ "- Approving or running an unrelated action is NOT a completion signal. In particular, approving a `/pr`, raising a PR, or posting it to Slack via `/prs-slack` does not mean the item is complete \u2014 raising and announcing a PR is not confirmation that the story is done. Never run `done`/`phase-done` as a side effect of those actions.",
7784
+ "- If it is unclear whether the user's message is a completion confirmation, ask them explicitly before running done/phase-done.",
7785
+ "",
7786
+ "Once the user gives that explicit completion instruction:",
7787
+ "1. Run: /commit",
7788
+ `2. Run: assist backlog done ${itemId2} "<summary>"`,
7789
+ `3. Run: assist backlog phase-done ${itemId2} ${phaseNumber} "done"`,
7790
+ "",
7791
+ "Precedence rules \u2014 read carefully:",
7792
+ "- An explicit completion instruction plus a successful commit means the work is complete. Always finish with done + phase-done; never rewind already-approved, committed work as an automatic response.",
7793
+ "- If the implementation has diverged from the recorded acceptance criteria but the user has approved it, the default is still to complete the item. You may optionally offer to update the acceptance criteria, but stale criteria are not a reason to rewind.",
7794
+ `- Rewinding is a confirm-first exception, not the normal path. If you believe a criterion genuinely no longer fits and the work should return to an earlier phase, you must ask the user and get explicit confirmation first. Only after they confirm may you run \`assist backlog rewind ${itemId2} <phase> --reason "<reason>"\`. Never rewind silently.`
7795
+ ];
7796
+ }
7797
+
7757
7798
  // src/commands/backlog/buildReviewPrompt.ts
7758
7799
  function buildReviewPrompt(item, phaseNumber, options2 = {
7759
7800
  commitBeforePhaseEnd: false
@@ -7780,24 +7821,15 @@ function buildReviewPrompt(item, phaseNumber, options2 = {
7780
7821
  "Before asking the user to confirm manual checks, run /commit to commit the work (it is fine if there is nothing new to commit).",
7781
7822
  ""
7782
7823
  ] : [],
7824
+ ...buildReviewCheckLines(
7825
+ options2.manualChecks ?? [],
7826
+ options2.askCheck === true
7827
+ ),
7783
7828
  "After all criteria pass, ask the user to confirm any manual checks",
7784
7829
  "(e.g. end-to-end behaviour they need to verify themselves).",
7785
7830
  "Wait for the user to confirm before proceeding.",
7786
7831
  "",
7787
- "What counts as a completion confirmation \u2014 read carefully:",
7788
- "- Marking the item done/phase-done requires an explicit, unambiguous instruction to complete it (e.g. the user says the item is done/accepted or tells you to mark it complete). Nothing else counts.",
7789
- "- Approving or running an unrelated action is NOT a completion signal. In particular, approving a `/pr`, raising a PR, or posting it to Slack via `/prs-slack` does not mean the item is complete \u2014 raising and announcing a PR is not confirmation that the story is done. Never run `done`/`phase-done` as a side effect of those actions.",
7790
- "- If it is unclear whether the user's message is a completion confirmation, ask them explicitly before running done/phase-done.",
7791
- "",
7792
- "Once the user gives that explicit completion instruction:",
7793
- "1. Run: /commit",
7794
- `2. Run: assist backlog done ${itemId2} "<summary>"`,
7795
- `3. Run: assist backlog phase-done ${itemId2} ${phaseNumber} "done"`,
7796
- "",
7797
- "Precedence rules \u2014 read carefully:",
7798
- "- An explicit completion instruction plus a successful commit means the work is complete. Always finish with done + phase-done; never rewind already-approved, committed work as an automatic response.",
7799
- "- If the implementation has diverged from the recorded acceptance criteria but the user has approved it, the default is still to complete the item. You may optionally offer to update the acceptance criteria, but stale criteria are not a reason to rewind.",
7800
- `- Rewinding is a confirm-first exception, not the normal path. If you believe a criterion genuinely no longer fits and the work should return to an earlier phase, you must ask the user and get explicit confirmation first. Only after they confirm may you run \`assist backlog rewind ${itemId2} <phase> --reason "<reason>"\`. Never rewind silently.`
7832
+ ...buildReviewCompletionLines(itemId2, phaseNumber)
7801
7833
  ].filter((line) => line !== void 0).join("\n");
7802
7834
  }
7803
7835
 
@@ -7807,15 +7839,39 @@ function buildPhasePrompt(item, phaseNumber, phase) {
7807
7839
  const config = loadConfig();
7808
7840
  const worktree = config.worktree;
7809
7841
  const commitBeforePhaseEnd = worktree?.commitBeforePhaseEnd ?? worktree?.commitBeforeManualChecks ?? false;
7842
+ const askCheck2 = config.sessions?.askQuestion === true;
7810
7843
  if (phase.name === REVIEW_PHASE_NAME) {
7811
- return buildReviewPrompt(item, phaseNumber, { commitBeforePhaseEnd });
7844
+ return buildReviewPrompt(item, phaseNumber, {
7845
+ commitBeforePhaseEnd,
7846
+ askCheck: askCheck2,
7847
+ manualChecks: phase.manualChecks
7848
+ });
7812
7849
  }
7813
7850
  return buildAuthoredPhasePrompt(item, phaseNumber, phase, {
7814
7851
  commitBeforePhaseEnd,
7815
- askCheck: config.sessions?.askQuestion === true
7852
+ askCheck: askCheck2
7816
7853
  });
7817
7854
  }
7818
7855
 
7856
+ // src/commands/backlog/authoredPhases.ts
7857
+ function authoredPhases(plan2) {
7858
+ return plan2.at(-1)?.name === REVIEW_PHASE_NAME ? plan2.slice(0, -1) : plan2;
7859
+ }
7860
+
7861
+ // src/commands/backlog/resolvePlan.ts
7862
+ function resolvePlan(item) {
7863
+ const authored = authoredPhases(item.plan ?? []);
7864
+ if (authored.length > 0) {
7865
+ return authored;
7866
+ }
7867
+ return [
7868
+ {
7869
+ name: "Implement",
7870
+ tasks: item.acceptanceCriteria.map((ac) => ({ task: ac }))
7871
+ }
7872
+ ];
7873
+ }
7874
+
7819
7875
  // src/commands/backlog/buildReviewPhase.ts
7820
7876
  function buildReviewPhase() {
7821
7877
  return {
@@ -7828,28 +7884,15 @@ function buildReviewPhase() {
7828
7884
  };
7829
7885
  }
7830
7886
 
7831
- // src/commands/backlog/appendReviewPhase.ts
7832
- function appendReviewPhase(plan2) {
7833
- if (plan2.at(-1)?.name === REVIEW_PHASE_NAME) return plan2;
7834
- return [...plan2, buildReviewPhase()];
7835
- }
7836
-
7837
- // src/commands/backlog/resolvePlan.ts
7838
- function resolvePlan(item) {
7839
- if (item.plan && item.plan.length > 0) {
7840
- return item.plan;
7841
- }
7842
- return [
7843
- {
7844
- name: "Implement",
7845
- tasks: item.acceptanceCriteria.map((ac) => ({ task: ac }))
7846
- }
7847
- ];
7887
+ // src/commands/backlog/resolveReviewPhase.ts
7888
+ function resolveReviewPhase(item) {
7889
+ const stored = item.plan?.at(-1);
7890
+ return stored?.name === REVIEW_PHASE_NAME ? stored : buildReviewPhase();
7848
7891
  }
7849
7892
 
7850
7893
  // src/commands/backlog/resolveRewindPlan.ts
7851
7894
  function resolveRewindPlan(item) {
7852
- return appendReviewPhase(resolvePlan(item));
7895
+ return [...resolvePlan(item), resolveReviewPhase(item)];
7853
7896
  }
7854
7897
 
7855
7898
  // src/commands/backlog/writeSignal.ts
@@ -10111,8 +10154,8 @@ function listUsageHistory(req, res) {
10111
10154
  // src/shared/db/countItemUsageByOrigin.ts
10112
10155
  import { asc as asc9, desc as desc5, eq as eq24, sql as sql20 } from "drizzle-orm";
10113
10156
  async function countItemUsageByOrigin(db) {
10114
- const count11 = sql20`count(distinct ${phaseUsage.itemId})::int`;
10115
- const rows = await db.select({ origin: items.origin, count: count11 }).from(items).innerJoin(phaseUsage, eq24(phaseUsage.itemId, items.id)).groupBy(items.origin).orderBy(desc5(count11), asc9(items.origin));
10157
+ const count10 = sql20`count(distinct ${phaseUsage.itemId})::int`;
10158
+ const rows = await db.select({ origin: items.origin, count: count10 }).from(items).innerJoin(phaseUsage, eq24(phaseUsage.itemId, items.id)).groupBy(items.origin).orderBy(desc5(count10), asc9(items.origin));
10116
10159
  return rows.map((row3) => ({ origin: row3.origin, count: Number(row3.count) }));
10117
10160
  }
10118
10161
 
@@ -11124,8 +11167,8 @@ async function commitsBehind(cwd, repo, base, shas) {
11124
11167
  ]);
11125
11168
  const ref = response.data?.repository?.ref;
11126
11169
  for (const [index3, sha] of shas.entries()) {
11127
- const count11 = ref?.[`c${index3}`]?.behindBy;
11128
- behind.set(sha, typeof count11 === "number" ? count11 : null);
11170
+ const count10 = ref?.[`c${index3}`]?.behindBy;
11171
+ behind.set(sha, typeof count10 === "number" ? count10 : null);
11129
11172
  }
11130
11173
  } catch {
11131
11174
  return behind;
@@ -11242,9 +11285,9 @@ function deploymentsQuery(environments) {
11242
11285
  function headCommit3(node) {
11243
11286
  return node?.oid ? releaseCommit(node.oid, node) : null;
11244
11287
  }
11245
- function environmentNodes(repository, count11) {
11288
+ function environmentNodes(repository, count10) {
11246
11289
  return Array.from(
11247
- { length: count11 },
11290
+ { length: count10 },
11248
11291
  (_, index3) => repository[deploymentsAlias(index3)]?.nodes ?? []
11249
11292
  ).flat();
11250
11293
  }
@@ -15603,13 +15646,13 @@ async function activity(options2) {
15603
15646
  const activeDays = data.filter((d) => d.count > 0).length;
15604
15647
  console.log(`${total3} commits across ${activeDays} active days.`);
15605
15648
  const weekly = /* @__PURE__ */ new Map();
15606
- for (const { date, count: count11 } of data) {
15649
+ for (const { date, count: count10 } of data) {
15607
15650
  const d = new Date(date);
15608
15651
  d.setDate(d.getDate() - d.getDay());
15609
15652
  const weekStart = d.toISOString().slice(0, 10);
15610
- weekly.set(weekStart, (weekly.get(weekStart) ?? 0) + count11);
15653
+ weekly.set(weekStart, (weekly.get(weekStart) ?? 0) + count10);
15611
15654
  }
15612
- const weeklyData = [...weekly.entries()].map(([date, count11]) => ({ date, count: count11 })).sort((a, b) => a.date.localeCompare(b.date));
15655
+ const weeklyData = [...weekly.entries()].map(([date, count10]) => ({ date, count: count10 })).sort((a, b) => a.date.localeCompare(b.date));
15613
15656
  const until = data[data.length - 1].date;
15614
15657
  renderLineChart({
15615
15658
  title: "Commit Activity",
@@ -16207,6 +16250,44 @@ function registerAsk(program) {
16207
16250
  // src/commands/askCheck.ts
16208
16251
  import { randomUUID as randomUUID4 } from "crypto";
16209
16252
 
16253
+ // src/commands/backlog/moveManualCheck.ts
16254
+ import { and as and15, eq as eq33 } from "drizzle-orm";
16255
+ function setManualChecks(tx, itemId2, phaseIdx, checks2) {
16256
+ return tx.update(planPhases).set({ manualChecks: serializeManualChecks(checks2) }).where(and15(eq33(planPhases.itemId, itemId2), eq33(planPhases.idx, phaseIdx)));
16257
+ }
16258
+ async function moveManualCheck(orm, item, fromIdx, checkIdx, toIdx) {
16259
+ const plan2 = item.plan ?? [];
16260
+ const from = [...plan2[fromIdx]?.manualChecks ?? []];
16261
+ const [check2] = from.splice(checkIdx, 1);
16262
+ if (check2 === void 0) throw new Error(`No manual check ${checkIdx + 1}`);
16263
+ await orm.transaction(async (tx) => {
16264
+ await setManualChecks(tx, item.id, fromIdx, from);
16265
+ const target = plan2[toIdx];
16266
+ if (target) {
16267
+ await setManualChecks(tx, item.id, toIdx, [
16268
+ ...target.manualChecks ?? [],
16269
+ check2
16270
+ ]);
16271
+ return;
16272
+ }
16273
+ const review2 = buildReviewPhase();
16274
+ await tx.insert(planPhases).values({
16275
+ itemId: item.id,
16276
+ idx: toIdx,
16277
+ name: review2.name,
16278
+ manualChecks: serializeManualChecks([check2])
16279
+ });
16280
+ await tx.insert(planTasks).values(
16281
+ review2.tasks.map(({ task }, i) => ({
16282
+ itemId: item.id,
16283
+ phaseIdx: toIdx,
16284
+ idx: i,
16285
+ task
16286
+ }))
16287
+ );
16288
+ });
16289
+ }
16290
+
16210
16291
  // src/commands/sessions/shared/askCheckInputSchema.ts
16211
16292
  import { z as z13 } from "zod";
16212
16293
  var text17 = z13.string().trim().min(1);
@@ -16218,6 +16299,33 @@ var askCheckInputSchema = z13.object({
16218
16299
  });
16219
16300
  var CHECK_RESULT_KEY = "result";
16220
16301
  var CHECK_NOTE_KEY = "note";
16302
+ var CHECK_PHASE_KEY = "phase";
16303
+
16304
+ // src/commands/askCheck/applyCheckBump.ts
16305
+ function failBump(message3) {
16306
+ console.error(`Error: ${message3} The check was not moved.`);
16307
+ process.exit(1);
16308
+ }
16309
+ async function applyCheckBump(bump, title, answers) {
16310
+ const targetNumber = Number(answers[CHECK_PHASE_KEY]);
16311
+ const target = bump.laterPhases.find((p) => p.number === targetNumber);
16312
+ if (!target)
16313
+ failBump(
16314
+ `the pane answered "later" without a valid later phase (${answers[CHECK_PHASE_KEY] ?? "none"}).`
16315
+ );
16316
+ const { orm } = await getReady();
16317
+ const item = await loadItem(orm, bump.itemId);
16318
+ if (!item || (item.currentPhase ?? 1) !== bump.phaseNumber)
16319
+ failBump(`the item moved on from phase ${bump.phaseNumber}.`);
16320
+ await moveManualCheck(
16321
+ orm,
16322
+ item,
16323
+ bump.phaseNumber - 1,
16324
+ bump.checkIdx,
16325
+ target.number - 1
16326
+ );
16327
+ return `Manual check "${title}": moved to phase ${target.number} (${target.name})`;
16328
+ }
16221
16329
 
16222
16330
  // src/commands/askCheck/formatAskCheckAnswer.ts
16223
16331
  function formatAskCheckAnswer(title, answers) {
@@ -16264,6 +16372,72 @@ function rejectLongCheck(check2) {
16264
16372
  process.exit(1);
16265
16373
  }
16266
16374
 
16375
+ // src/commands/sessions/shared/isLiveDaemonSession.ts
16376
+ var LIVE_TIMEOUT_MS = 1e3;
16377
+ async function isLiveDaemonSession(sessionId2) {
16378
+ const reply2 = await requestDaemonReply(
16379
+ { type: "session-live", sessionId: sessionId2 },
16380
+ "session-live",
16381
+ LIVE_TIMEOUT_MS
16382
+ );
16383
+ return reply2?.live === true;
16384
+ }
16385
+
16386
+ // src/commands/askCheck/requireCheckSession.ts
16387
+ function askInChat(reason4) {
16388
+ console.error(
16389
+ `Error: ${reason4}; ask the user to perform the check in chat instead.`
16390
+ );
16391
+ process.exit(1);
16392
+ }
16393
+ async function requireCheckSession() {
16394
+ const sessionId2 = process.env.ASSIST_SESSION_ID;
16395
+ if (process.env.ASSIST_SESSION !== "1" || !sessionId2)
16396
+ askInChat("not running in an assist session");
16397
+ if (!loadConfig().sessions?.askQuestion)
16398
+ askInChat("assist ask-check is disabled (sessions.askQuestion)");
16399
+ if (!await isLiveDaemonSession(sessionId2))
16400
+ askInChat(
16401
+ `session ${sessionId2} is not live in the assist daemon, so no preview pane can show the check`
16402
+ );
16403
+ return sessionId2;
16404
+ }
16405
+
16406
+ // src/shared/resolveSessionItemId.ts
16407
+ var ITEM_ID_ENV = "ASSIST_BACKLOG_ITEM_ID";
16408
+ function resolveSessionItemId() {
16409
+ const raw = process.env[ITEM_ID_ENV];
16410
+ if (!raw) return null;
16411
+ const id = Number.parseInt(raw, 10);
16412
+ return Number.isInteger(id) && id > 0 ? id : null;
16413
+ }
16414
+
16415
+ // src/commands/askCheck/resolveCheckBump.ts
16416
+ function rejectCheckIndex(message3) {
16417
+ console.error(`Error: ${message3}`);
16418
+ process.exit(1);
16419
+ }
16420
+ async function resolveCheckBump(check2) {
16421
+ if (check2 === void 0) return void 0;
16422
+ const checkNumber = Number(check2);
16423
+ if (!Number.isInteger(checkNumber) || checkNumber < 1)
16424
+ rejectCheckIndex(`--check must be a 1-based index, got "${check2}".`);
16425
+ const itemId2 = resolveSessionItemId();
16426
+ if (itemId2 === null) return void 0;
16427
+ const { orm } = await getReady();
16428
+ const item = await loadItem(orm, itemId2);
16429
+ if (!item) return void 0;
16430
+ const phaseNumber = item.currentPhase ?? 1;
16431
+ const laterPhases = resolveRewindPlan(item).slice(phaseNumber).map((phase, i) => ({ number: phaseNumber + i + 1, name: phase.name }));
16432
+ if (laterPhases.length === 0) return void 0;
16433
+ const checkCount = item.plan?.[phaseNumber - 1]?.manualChecks?.length ?? 0;
16434
+ if (checkNumber > checkCount)
16435
+ rejectCheckIndex(
16436
+ `phase ${phaseNumber} has ${checkCount} manual check(s), so --check ${checkNumber} matches none. Pass the check's 1-based index from the phase prompt.`
16437
+ );
16438
+ return { itemId: itemId2, phaseNumber, checkIdx: checkNumber - 1, laterPhases };
16439
+ }
16440
+
16267
16441
  // src/commands/backlog/readJsonPayload.ts
16268
16442
  import { readFileSync as readFileSync21 } from "fs";
16269
16443
  import chalk38 from "chalk";
@@ -16301,24 +16475,7 @@ ${issues}`);
16301
16475
  return parsed.data;
16302
16476
  }
16303
16477
 
16304
- // src/commands/sessions/shared/isLiveDaemonSession.ts
16305
- var LIVE_TIMEOUT_MS = 1e3;
16306
- async function isLiveDaemonSession(sessionId2) {
16307
- const reply2 = await requestDaemonReply(
16308
- { type: "session-live", sessionId: sessionId2 },
16309
- "session-live",
16310
- LIVE_TIMEOUT_MS
16311
- );
16312
- return reply2?.live === true;
16313
- }
16314
-
16315
16478
  // src/commands/askCheck.ts
16316
- function askInChat(reason4) {
16317
- console.error(
16318
- `Error: ${reason4}; ask the user to perform the check in chat instead.`
16319
- );
16320
- process.exit(1);
16321
- }
16322
16479
  async function askCheck(options2) {
16323
16480
  const check2 = await readJsonPayload(
16324
16481
  options2.json,
@@ -16326,22 +16483,17 @@ async function askCheck(options2) {
16326
16483
  "manual check"
16327
16484
  );
16328
16485
  rejectLongCheck(check2);
16329
- const sessionId2 = process.env.ASSIST_SESSION_ID;
16330
- if (process.env.ASSIST_SESSION !== "1" || !sessionId2)
16331
- askInChat("not running in an assist session");
16332
- if (!loadConfig().sessions?.askQuestion)
16333
- askInChat("assist ask-check is disabled (sessions.askQuestion)");
16334
- if (!await isLiveDaemonSession(sessionId2))
16335
- askInChat(
16336
- `session ${sessionId2} is not live in the assist daemon, so no preview pane can show the check`
16337
- );
16486
+ const sessionId2 = await requireCheckSession();
16487
+ const bump = await resolveCheckBump(options2.check);
16338
16488
  const decision = await awaitPreviewApproval(
16339
16489
  check2.title,
16340
16490
  {
16341
16491
  sessionId: sessionId2,
16342
16492
  requestId: randomUUID4(),
16343
16493
  title: check2.title,
16344
- body: JSON.stringify(check2),
16494
+ body: JSON.stringify(
16495
+ bump ? { ...check2, laterPhases: bump.laterPhases } : check2
16496
+ ),
16345
16497
  prNumber: null,
16346
16498
  kind: "check"
16347
16499
  },
@@ -16353,7 +16505,10 @@ async function askCheck(options2) {
16353
16505
  );
16354
16506
  process.exit(1);
16355
16507
  }
16356
- console.log(formatAskCheckAnswer(check2.title, decision.answers ?? {}));
16508
+ const answers = decision.answers ?? {};
16509
+ console.log(
16510
+ bump && answers[CHECK_RESULT_KEY] === "later" ? await applyCheckBump(bump, check2.title, answers) : formatAskCheckAnswer(check2.title, answers)
16511
+ );
16357
16512
  }
16358
16513
 
16359
16514
  // src/commands/registerAskCheck.ts
@@ -16365,6 +16520,9 @@ function registerAskCheck(program) {
16365
16520
  ).requiredOption(
16366
16521
  "--json <file|->",
16367
16522
  "Check JSON ({title, steps, before?, changed?}): title \u226460 chars, 1-4 steps \u226490 chars each, \u22644 before chips, changed \u2264160 chars; or - for stdin"
16523
+ ).option(
16524
+ "--check <n>",
16525
+ "1-based index of the current backlog phase's manual check this covers; lets the user move it to a later phase"
16368
16526
  ).action(askCheck),
16369
16527
  askQuestionConfigHelp
16370
16528
  ),
@@ -17150,15 +17308,6 @@ async function addActivity(id, kind, ref, options2) {
17150
17308
  // src/commands/backlog/recordSlack.ts
17151
17309
  import chalk43 from "chalk";
17152
17310
 
17153
- // src/shared/resolveSessionItemId.ts
17154
- var ITEM_ID_ENV = "ASSIST_BACKLOG_ITEM_ID";
17155
- function resolveSessionItemId() {
17156
- const raw = process.env[ITEM_ID_ENV];
17157
- if (!raw) return null;
17158
- const id = Number.parseInt(raw, 10);
17159
- return Number.isInteger(id) && id > 0 ? id : null;
17160
- }
17161
-
17162
17311
  // src/shared/db/recordSessionRefs.ts
17163
17312
  async function recordSessionRefs(refs) {
17164
17313
  const itemId2 = resolveSessionItemId();
@@ -17233,11 +17382,11 @@ function registerActivityCommands(cmd) {
17233
17382
 
17234
17383
  // src/commands/backlog/associateGithub.ts
17235
17384
  import chalk45 from "chalk";
17236
- import { eq as eq34 } from "drizzle-orm";
17385
+ import { eq as eq35 } from "drizzle-orm";
17237
17386
 
17238
17387
  // src/commands/backlog/beginAssociation.ts
17239
17388
  import chalk44 from "chalk";
17240
- import { eq as eq33 } from "drizzle-orm";
17389
+ import { eq as eq34 } from "drizzle-orm";
17241
17390
  async function beginAssociation(id, options2, clearPatch, label) {
17242
17391
  const found = await findOneItem(id);
17243
17392
  if (!found) {
@@ -17247,7 +17396,7 @@ async function beginAssociation(id, options2, clearPatch, label) {
17247
17396
  const { orm } = found;
17248
17397
  const itemId2 = found.item.id;
17249
17398
  if (options2.clear) {
17250
- await orm.update(items).set(clearPatch).where(eq33(items.id, itemId2));
17399
+ await orm.update(items).set(clearPatch).where(eq34(items.id, itemId2));
17251
17400
  console.log(
17252
17401
  chalk44.green(
17253
17402
  `Cleared ${label} association on item ${formatItemId(itemId2)}.`
@@ -17315,7 +17464,7 @@ async function associateGithub(id, issue, options2) {
17315
17464
  return;
17316
17465
  }
17317
17466
  const title = fetchGithubIssueTitle(normalized);
17318
- await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(eq34(items.id, itemId2));
17467
+ await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(eq35(items.id, itemId2));
17319
17468
  console.log(
17320
17469
  chalk45.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
17321
17470
  title ? chalk45.dim(`(${title})`) : ""
@@ -17329,7 +17478,7 @@ function registerAssociateGithubCommand(cmd) {
17329
17478
 
17330
17479
  // src/commands/backlog/associateJira.ts
17331
17480
  import chalk47 from "chalk";
17332
- import { eq as eq35 } from "drizzle-orm";
17481
+ import { eq as eq36 } from "drizzle-orm";
17333
17482
 
17334
17483
  // src/commands/jira/fetchIssue.ts
17335
17484
  import { execSync as execSync17 } from "child_process";
@@ -17394,7 +17543,7 @@ async function associateJira(id, key, options2) {
17394
17543
  const parsed = fetchIssue(normalized, "summary");
17395
17544
  const fields = parsed?.fields;
17396
17545
  const summary = fields?.summary;
17397
- await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq35(items.id, itemId2));
17546
+ await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq36(items.id, itemId2));
17398
17547
  console.log(
17399
17548
  chalk47.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
17400
17549
  summary ? chalk47.dim(`(${summary})`) : ""
@@ -17891,10 +18040,11 @@ import chalk58 from "chalk";
17891
18040
 
17892
18041
  // src/commands/backlog/resolveInsertPosition.ts
17893
18042
  import chalk57 from "chalk";
17894
- import { count as count5, eq as eq36 } from "drizzle-orm";
18043
+ import { asc as asc10, eq as eq37 } from "drizzle-orm";
17895
18044
  async function resolveInsertPosition(orm, itemId2, position) {
17896
- const [row3] = await orm.select({ cnt: count5() }).from(planPhases).where(eq36(planPhases.itemId, itemId2));
17897
- const phaseCount = row3?.cnt ?? 0;
18045
+ const rows = await orm.select({ name: planPhases.name }).from(planPhases).where(eq37(planPhases.itemId, itemId2)).orderBy(asc10(planPhases.idx));
18046
+ const storedReviewStaysLast = rows.at(-1)?.name === REVIEW_PHASE_NAME;
18047
+ const phaseCount = storedReviewStaysLast ? rows.length - 1 : rows.length;
17898
18048
  if (position === void 0) return phaseCount;
17899
18049
  const pos = Number.parseInt(position, 10);
17900
18050
  if (pos < 1 || pos > phaseCount + 1) {
@@ -18010,7 +18160,9 @@ function typeLabel(type) {
18010
18160
  }
18011
18161
  function phaseLabel(item) {
18012
18162
  if (!item.plan) return "";
18013
- return chalk59.dim(` (phase ${item.currentPhase ?? 1}/${item.plan.length})`);
18163
+ return chalk59.dim(
18164
+ ` (phase ${item.currentPhase ?? 1}/${authoredPhases(item.plan).length})`
18165
+ );
18014
18166
  }
18015
18167
  function isBlocked(item, items2) {
18016
18168
  const deps2 = (item.links ?? []).filter((l) => l.type === "depends-on");
@@ -18167,10 +18319,10 @@ async function reviewProposal(item, sessionId2, confirmed, revises) {
18167
18319
  import chalk62 from "chalk";
18168
18320
 
18169
18321
  // src/commands/backlog/propose/reviseProposedItem.ts
18170
- import { eq as eq38 } from "drizzle-orm";
18322
+ import { eq as eq39 } from "drizzle-orm";
18171
18323
 
18172
18324
  // src/commands/backlog/updatePlan/replacePlan.ts
18173
- import { eq as eq37 } from "drizzle-orm";
18325
+ import { eq as eq38 } from "drizzle-orm";
18174
18326
 
18175
18327
  // src/commands/backlog/updatePlan/clampCurrentPhase.ts
18176
18328
  function clampCurrentPhase(currentPhase, phaseCount) {
@@ -18181,8 +18333,8 @@ function clampCurrentPhase(currentPhase, phaseCount) {
18181
18333
  // src/commands/backlog/updatePlan/replacePlan.ts
18182
18334
  async function replacePlan(orm, itemId2, phases, currentPhase) {
18183
18335
  await orm.transaction(async (tx) => {
18184
- await tx.delete(planTasks).where(eq37(planTasks.itemId, itemId2));
18185
- await tx.delete(planPhases).where(eq37(planPhases.itemId, itemId2));
18336
+ await tx.delete(planTasks).where(eq38(planTasks.itemId, itemId2));
18337
+ await tx.delete(planPhases).where(eq38(planPhases.itemId, itemId2));
18186
18338
  if (phases.length > 0) {
18187
18339
  await tx.insert(planPhases).values(
18188
18340
  phases.map((phase, idx) => ({
@@ -18200,7 +18352,7 @@ async function replacePlan(orm, itemId2, phases, currentPhase) {
18200
18352
  if (currentPhase === void 0) return;
18201
18353
  const clamped = clampCurrentPhase(currentPhase, phases.length);
18202
18354
  if (clamped === currentPhase) return;
18203
- await tx.update(items).set({ currentPhase: clamped }).where(eq37(items.id, itemId2));
18355
+ await tx.update(items).set({ currentPhase: clamped }).where(eq38(items.id, itemId2));
18204
18356
  });
18205
18357
  }
18206
18358
 
@@ -18210,14 +18362,14 @@ var BUG_DEFAULT_PLAN = [
18210
18362
  ];
18211
18363
  async function reviseProposedItem(itemId2, item) {
18212
18364
  const orm = await getDb();
18213
- const [existing] = await orm.select({ currentPhase: items.currentPhase }).from(items).where(eq38(items.id, itemId2));
18365
+ const [existing] = await orm.select({ currentPhase: items.currentPhase }).from(items).where(eq39(items.id, itemId2));
18214
18366
  if (!existing) return false;
18215
18367
  await orm.update(items).set({
18216
18368
  type: item.type,
18217
18369
  name: item.name,
18218
18370
  description: item.description || null,
18219
18371
  acceptanceCriteria: JSON.stringify(item.acceptanceCriteria)
18220
- }).where(eq38(items.id, itemId2));
18372
+ }).where(eq39(items.id, itemId2));
18221
18373
  const phases = item.phases.length > 0 || item.type !== "bug" ? item.phases : BUG_DEFAULT_PLAN;
18222
18374
  await replacePlan(orm, itemId2, phases, existing.currentPhase ?? void 0);
18223
18375
  return true;
@@ -18444,9 +18596,9 @@ function hasCycle(adjacency, fromId, toId) {
18444
18596
  }
18445
18597
 
18446
18598
  // src/commands/backlog/loadDependencyGraph.ts
18447
- import { eq as eq39 } from "drizzle-orm";
18599
+ import { eq as eq40 } from "drizzle-orm";
18448
18600
  async function loadDependencyGraph(orm) {
18449
- const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq39(links.type, "depends-on"));
18601
+ const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq40(links.type, "depends-on"));
18450
18602
  const graph = /* @__PURE__ */ new Map();
18451
18603
  for (const { itemId: itemId2, targetId } of rows) {
18452
18604
  const bucket = graph.get(itemId2);
@@ -18513,7 +18665,7 @@ async function link(fromId, toId, opts) {
18513
18665
 
18514
18666
  // src/commands/backlog/unlink.ts
18515
18667
  import chalk66 from "chalk";
18516
- import { and as and15, eq as eq40 } from "drizzle-orm";
18668
+ import { and as and16, eq as eq41 } from "drizzle-orm";
18517
18669
  async function unlink(fromId, toId) {
18518
18670
  const fromNum = parseItemId(fromId);
18519
18671
  const toNum = parseItemId(toId);
@@ -18537,7 +18689,7 @@ async function unlink(fromId, toId) {
18537
18689
  );
18538
18690
  return;
18539
18691
  }
18540
- await orm.delete(links).where(and15(eq40(links.itemId, fromNum), eq40(links.targetId, toNum)));
18692
+ await orm.delete(links).where(and16(eq41(links.itemId, fromNum), eq41(links.targetId, toNum)));
18541
18693
  console.log(
18542
18694
  chalk66.green(
18543
18695
  `Removed link from ${formatItemId(fromNum)} to ${formatItemId(toNum)}.`
@@ -18557,7 +18709,7 @@ function registerLinkCommands(cmd) {
18557
18709
 
18558
18710
  // src/commands/backlog/moveRepo.ts
18559
18711
  import chalk68 from "chalk";
18560
- import { eq as eq42 } from "drizzle-orm";
18712
+ import { eq as eq43 } from "drizzle-orm";
18561
18713
 
18562
18714
  // src/commands/backlog/move-repo/confirmMove.ts
18563
18715
  import chalk67 from "chalk";
@@ -18572,9 +18724,9 @@ async function confirmMove(cnt, oldOrigin, newOrigin) {
18572
18724
  }
18573
18725
 
18574
18726
  // src/commands/backlog/move-repo/countByOrigin.ts
18575
- import { count as count6, eq as eq41 } from "drizzle-orm";
18727
+ import { count as count5, eq as eq42 } from "drizzle-orm";
18576
18728
  async function countByOrigin(orm, origin) {
18577
- const [{ cnt }] = await orm.select({ cnt: count6() }).from(items).where(eq41(items.origin, origin));
18729
+ const [{ cnt }] = await orm.select({ cnt: count5() }).from(items).where(eq42(items.origin, origin));
18578
18730
  return cnt;
18579
18731
  }
18580
18732
 
@@ -18617,7 +18769,7 @@ async function moveRepo(oldOriginRaw, newOriginRaw, options2 = {}) {
18617
18769
  console.log(chalk68.yellow("Move cancelled; no changes made."));
18618
18770
  return;
18619
18771
  }
18620
- await orm.update(items).set({ origin: newOrigin }).where(eq42(items.origin, oldOrigin));
18772
+ await orm.update(items).set({ origin: newOrigin }).where(eq43(items.origin, oldOrigin));
18621
18773
  console.log(
18622
18774
  chalk68.green(
18623
18775
  `Moved ${pluralItems(cnt)} from "${oldOrigin}" to "${newOrigin}".`
@@ -19089,12 +19241,12 @@ function message(error) {
19089
19241
  import chalk72 from "chalk";
19090
19242
 
19091
19243
  // src/shared/db/findPhaseBySessionId.ts
19092
- import { and as and16, eq as eq43 } from "drizzle-orm";
19244
+ import { and as and17, eq as eq44 } from "drizzle-orm";
19093
19245
  async function findPhaseBySessionId(db, itemId2, claudeSessionId) {
19094
19246
  const rows = await db.select({ phaseIdx: phaseUsage.phaseIdx }).from(phaseUsage).where(
19095
- and16(
19096
- eq43(phaseUsage.itemId, itemId2),
19097
- eq43(phaseUsage.claudeSessionId, claudeSessionId)
19247
+ and17(
19248
+ eq44(phaseUsage.itemId, itemId2),
19249
+ eq44(phaseUsage.claudeSessionId, claudeSessionId)
19098
19250
  )
19099
19251
  ).limit(1);
19100
19252
  return rows[0]?.phaseIdx;
@@ -19983,10 +20135,16 @@ async function runPhases(item, startPhase, plan2, spawnOptions) {
19983
20135
  return { kind: "completed" };
19984
20136
  }
19985
20137
 
20138
+ // src/commands/backlog/reloadReviewPhase.ts
20139
+ async function reloadReviewPhase(id) {
20140
+ const found = await findOneItem(String(id));
20141
+ return found ? resolveReviewPhase(found.item) : buildReviewPhase();
20142
+ }
20143
+
19986
20144
  // src/commands/backlog/runReview.ts
19987
20145
  async function runReview(item, fallbackPlan, spawnOptions) {
19988
20146
  const plan2 = await reloadPlan(item.id) ?? fallbackPlan;
19989
- const allPhases = appendReviewPhase(plan2);
20147
+ const allPhases = [...plan2, await reloadReviewPhase(item.id)];
19990
20148
  let reviewOptions = spawnOptions;
19991
20149
  while (true) {
19992
20150
  const outcome = await executePhase(
@@ -20546,7 +20704,7 @@ async function done(id, summary) {
20546
20704
  const { orm, item } = found;
20547
20705
  if (item.plan && item.plan.length > 0) {
20548
20706
  const completedCount = (item.currentPhase ?? 1) - 1;
20549
- const pending = item.plan.slice(completedCount);
20707
+ const pending = authoredPhases(item.plan).slice(completedCount);
20550
20708
  if (pending.length > 0) {
20551
20709
  console.log(
20552
20710
  chalk91.red(
@@ -20635,10 +20793,10 @@ async function start(id) {
20635
20793
 
20636
20794
  // src/commands/backlog/stop.ts
20637
20795
  import chalk96 from "chalk";
20638
- import { and as and17, eq as eq44 } from "drizzle-orm";
20796
+ import { and as and18, eq as eq45 } from "drizzle-orm";
20639
20797
  async function stop() {
20640
20798
  const { orm } = await getReady();
20641
- const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and17(eq44(items.status, "in-progress"), eq44(items.origin, getOrigin()))).returning({ id: items.id, name: items.name });
20799
+ const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and18(eq45(items.status, "in-progress"), eq45(items.origin, getOrigin()))).returning({ id: items.id, name: items.name });
20642
20800
  if (stopped.length === 0) {
20643
20801
  console.log(chalk96.yellow("No in-progress items to stop."));
20644
20802
  return;
@@ -20696,20 +20854,20 @@ function registerStatusCommands(cmd) {
20696
20854
 
20697
20855
  // src/commands/backlog/movePhase.ts
20698
20856
  import chalk99 from "chalk";
20699
- import { count as count8, eq as eq47 } from "drizzle-orm";
20857
+ import { count as count7, eq as eq48 } from "drizzle-orm";
20700
20858
 
20701
20859
  // src/commands/backlog/reorderPhaseRows.ts
20702
- import { and as and19, asc as asc11, eq as eq46 } from "drizzle-orm";
20860
+ import { and as and20, asc as asc12, eq as eq47 } from "drizzle-orm";
20703
20861
 
20704
20862
  // src/commands/backlog/reindexPhases.ts
20705
- import { and as and18, asc as asc10, count as count7, eq as eq45 } from "drizzle-orm";
20863
+ import { and as and19, asc as asc11, count as count6, eq as eq46 } from "drizzle-orm";
20706
20864
  async function reindexPhases(db, itemId2) {
20707
- const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq45(planPhases.itemId, itemId2)).orderBy(asc10(planPhases.idx));
20865
+ const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq46(planPhases.itemId, itemId2)).orderBy(asc11(planPhases.idx));
20708
20866
  for (let i = 0; i < remaining.length; i++) {
20709
20867
  const oldIdx = remaining[i].idx;
20710
20868
  if (oldIdx === i) continue;
20711
- await db.update(planTasks).set({ phaseIdx: i }).where(and18(eq45(planTasks.itemId, itemId2), eq45(planTasks.phaseIdx, oldIdx)));
20712
- await db.update(planPhases).set({ idx: i }).where(and18(eq45(planPhases.itemId, itemId2), eq45(planPhases.idx, oldIdx)));
20869
+ await db.update(planTasks).set({ phaseIdx: i }).where(and19(eq46(planTasks.itemId, itemId2), eq46(planTasks.phaseIdx, oldIdx)));
20870
+ await db.update(planPhases).set({ idx: i }).where(and19(eq46(planPhases.itemId, itemId2), eq46(planPhases.idx, oldIdx)));
20713
20871
  }
20714
20872
  }
20715
20873
  async function adjustCurrentPhase(db, item, removedIdx) {
@@ -20717,24 +20875,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
20717
20875
  if (currentPhase === void 0) return;
20718
20876
  const currentIdx = currentPhase - 1;
20719
20877
  if (removedIdx < currentIdx) {
20720
- await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq45(items.id, item.id));
20878
+ await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq46(items.id, item.id));
20721
20879
  return;
20722
20880
  }
20723
20881
  if (removedIdx !== currentIdx) return;
20724
- const [row3] = await db.select({ cnt: count7() }).from(planPhases).where(eq45(planPhases.itemId, item.id));
20882
+ const [row3] = await db.select({ cnt: count6() }).from(planPhases).where(eq46(planPhases.itemId, item.id));
20725
20883
  const cnt = row3?.cnt ?? 0;
20726
- await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq45(items.id, item.id));
20884
+ await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq46(items.id, item.id));
20727
20885
  }
20728
20886
 
20729
20887
  // src/commands/backlog/reorderPhaseRows.ts
20730
20888
  async function reorderPhaseRows(orm, itemId2, fromIdx, toIdx) {
20731
20889
  await orm.transaction(async (tx) => {
20732
- const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and19(eq46(planPhases.itemId, itemId2), eq46(planPhases.idx, fromIdx)));
20733
- const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and19(eq46(planTasks.itemId, itemId2), eq46(planTasks.phaseIdx, fromIdx))).orderBy(asc11(planTasks.idx));
20890
+ const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and20(eq47(planPhases.itemId, itemId2), eq47(planPhases.idx, fromIdx)));
20891
+ const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and20(eq47(planTasks.itemId, itemId2), eq47(planTasks.phaseIdx, fromIdx))).orderBy(asc12(planTasks.idx));
20734
20892
  await tx.delete(planTasks).where(
20735
- and19(eq46(planTasks.itemId, itemId2), eq46(planTasks.phaseIdx, fromIdx))
20893
+ and20(eq47(planTasks.itemId, itemId2), eq47(planTasks.phaseIdx, fromIdx))
20736
20894
  );
20737
- await tx.delete(planPhases).where(and19(eq46(planPhases.itemId, itemId2), eq46(planPhases.idx, fromIdx)));
20895
+ await tx.delete(planPhases).where(and20(eq47(planPhases.itemId, itemId2), eq47(planPhases.idx, fromIdx)));
20738
20896
  await reindexPhases(tx, itemId2);
20739
20897
  await shiftPhasesUp(tx, itemId2, toIdx);
20740
20898
  await tx.insert(planPhases).values({
@@ -20775,7 +20933,7 @@ async function movePhase(id, from, to) {
20775
20933
  if (!found) return;
20776
20934
  const { orm, item } = found;
20777
20935
  const itemId2 = item.id;
20778
- const [row3] = await orm.select({ cnt: count8() }).from(planPhases).where(eq47(planPhases.itemId, itemId2));
20936
+ const [row3] = await orm.select({ cnt: count7() }).from(planPhases).where(eq48(planPhases.itemId, itemId2));
20779
20937
  const phaseCount = row3?.cnt ?? 0;
20780
20938
  const fromIdx = toIndex2(from, phaseCount);
20781
20939
  if (fromIdx === void 0) return;
@@ -20791,22 +20949,22 @@ async function movePhase(id, from, to) {
20791
20949
  import chalk101 from "chalk";
20792
20950
 
20793
20951
  // src/commands/backlog/applyPhaseUpdate.ts
20794
- import { and as and20, eq as eq48 } from "drizzle-orm";
20952
+ import { and as and21, eq as eq49 } from "drizzle-orm";
20795
20953
  async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
20796
20954
  await orm.transaction(async (tx) => {
20797
20955
  if (fields.name) {
20798
20956
  await tx.update(planPhases).set({ name: fields.name }).where(
20799
- and20(eq48(planPhases.itemId, itemId2), eq48(planPhases.idx, phaseIdx))
20957
+ and21(eq49(planPhases.itemId, itemId2), eq49(planPhases.idx, phaseIdx))
20800
20958
  );
20801
20959
  }
20802
20960
  if (fields.manualCheck) {
20803
20961
  await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
20804
- and20(eq48(planPhases.itemId, itemId2), eq48(planPhases.idx, phaseIdx))
20962
+ and21(eq49(planPhases.itemId, itemId2), eq49(planPhases.idx, phaseIdx))
20805
20963
  );
20806
20964
  }
20807
20965
  if (fields.task) {
20808
20966
  await tx.delete(planTasks).where(
20809
- and20(eq48(planTasks.itemId, itemId2), eq48(planTasks.phaseIdx, phaseIdx))
20967
+ and21(eq49(planTasks.itemId, itemId2), eq49(planTasks.phaseIdx, phaseIdx))
20810
20968
  );
20811
20969
  if (fields.task.length) {
20812
20970
  await tx.insert(planTasks).values(
@@ -20824,14 +20982,14 @@ async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
20824
20982
 
20825
20983
  // src/commands/backlog/findPhase.ts
20826
20984
  import chalk100 from "chalk";
20827
- import { and as and21, count as count9, eq as eq49 } from "drizzle-orm";
20985
+ import { and as and22, count as count8, eq as eq50 } from "drizzle-orm";
20828
20986
  async function findPhase(id, phase) {
20829
20987
  const found = await findOneItem(id);
20830
20988
  if (!found) return void 0;
20831
20989
  const { orm, item } = found;
20832
20990
  const itemId2 = item.id;
20833
20991
  const phaseIdx = Number.parseInt(phase, 10) - 1;
20834
- const [row3] = await orm.select({ cnt: count9() }).from(planPhases).where(and21(eq49(planPhases.itemId, itemId2), eq49(planPhases.idx, phaseIdx)));
20992
+ const [row3] = await orm.select({ cnt: count8() }).from(planPhases).where(and22(eq50(planPhases.itemId, itemId2), eq50(planPhases.idx, phaseIdx)));
20835
20993
  if (!row3 || row3.cnt === 0) {
20836
20994
  console.log(
20837
20995
  chalk100.red(
@@ -21004,16 +21162,16 @@ function registerUpdatePhaseCommand(cmd) {
21004
21162
 
21005
21163
  // src/commands/backlog/removePhase.ts
21006
21164
  import chalk102 from "chalk";
21007
- import { and as and22, eq as eq50 } from "drizzle-orm";
21165
+ import { and as and23, eq as eq51 } from "drizzle-orm";
21008
21166
  async function removePhase(id, phase) {
21009
21167
  const found = await findPhase(id, phase);
21010
21168
  if (!found) return;
21011
21169
  const { item, orm, itemId: itemId2, phaseIdx } = found;
21012
21170
  await orm.transaction(async (tx) => {
21013
21171
  await tx.delete(planTasks).where(
21014
- and22(eq50(planTasks.itemId, itemId2), eq50(planTasks.phaseIdx, phaseIdx))
21172
+ and23(eq51(planTasks.itemId, itemId2), eq51(planTasks.phaseIdx, phaseIdx))
21015
21173
  );
21016
- await tx.delete(planPhases).where(and22(eq50(planPhases.itemId, itemId2), eq50(planPhases.idx, phaseIdx)));
21174
+ await tx.delete(planPhases).where(and23(eq51(planPhases.itemId, itemId2), eq51(planPhases.idx, phaseIdx)));
21017
21175
  await reindexPhases(tx, itemId2);
21018
21176
  await adjustCurrentPhase(tx, item, phaseIdx);
21019
21177
  });
@@ -21026,7 +21184,7 @@ async function removePhase(id, phase) {
21026
21184
 
21027
21185
  // src/commands/backlog/update/update.ts
21028
21186
  import chalk106 from "chalk";
21029
- import { eq as eq51 } from "drizzle-orm";
21187
+ import { eq as eq52 } from "drizzle-orm";
21030
21188
 
21031
21189
  // src/commands/backlog/update/buildUpdateValues.ts
21032
21190
  import chalk103 from "chalk";
@@ -21137,7 +21295,7 @@ async function update(id, options2) {
21137
21295
  if (!built) return;
21138
21296
  const { orm } = found;
21139
21297
  const itemId2 = found.item.id;
21140
- await orm.update(items).set(built.set).where(eq51(items.id, itemId2));
21298
+ await orm.update(items).set(built.set).where(eq52(items.id, itemId2));
21141
21299
  console.log(
21142
21300
  chalk106.green(`Updated ${built.fields} on item ${formatItemId(itemId2)}.`)
21143
21301
  );
@@ -21777,17 +21935,17 @@ function registerBranch(program) {
21777
21935
  import { basename as basename15 } from "path";
21778
21936
 
21779
21937
  // src/commands/backlog/isDocsLocked.ts
21780
- import { and as and24, eq as eq53 } from "drizzle-orm";
21938
+ import { and as and25, eq as eq54 } from "drizzle-orm";
21781
21939
 
21782
21940
  // src/commands/backlog/hasOpenPhaseUnlock.ts
21783
- import { and as and23, eq as eq52, notInArray as notInArray2, sql as sql26 } from "drizzle-orm";
21941
+ import { and as and24, eq as eq53, notInArray as notInArray2, sql as sql26 } from "drizzle-orm";
21784
21942
  async function hasOpenPhaseUnlock(itemId2, kind) {
21785
21943
  const orm = await getDb();
21786
- const [row3] = await orm.select({ itemId: itemGitRefs.itemId }).from(itemGitRefs).innerJoin(items, eq52(items.id, itemGitRefs.itemId)).where(
21787
- and23(
21788
- eq52(itemGitRefs.itemId, itemId2),
21789
- eq52(itemGitRefs.kind, kind),
21790
- eq52(
21944
+ const [row3] = await orm.select({ itemId: itemGitRefs.itemId }).from(itemGitRefs).innerJoin(items, eq53(items.id, itemGitRefs.itemId)).where(
21945
+ and24(
21946
+ eq53(itemGitRefs.itemId, itemId2),
21947
+ eq53(itemGitRefs.kind, kind),
21948
+ eq53(
21791
21949
  itemGitRefs.ref,
21792
21950
  sql26`'phase-' || coalesce(${items.currentPhase}, 1)`
21793
21951
  ),
@@ -21800,7 +21958,7 @@ async function hasOpenPhaseUnlock(itemId2, kind) {
21800
21958
  // src/commands/backlog/isDocsLocked.ts
21801
21959
  async function isDocsRefreshItem(itemId2) {
21802
21960
  const orm = await getDb();
21803
- const [row3] = await orm.select({ itemId: links.itemId }).from(links).where(and24(eq53(links.itemId, itemId2), eq53(links.type, "docs-refresh"))).limit(1);
21961
+ const [row3] = await orm.select({ itemId: links.itemId }).from(links).where(and25(eq54(links.itemId, itemId2), eq54(links.type, "docs-refresh"))).limit(1);
21804
21962
  return row3 !== void 0;
21805
21963
  }
21806
21964
  async function isDocsLocked() {
@@ -24609,7 +24767,7 @@ function calculateHalstead(node) {
24609
24767
  // src/commands/complexity/shared/countSloc.ts
24610
24768
  function countSloc(content) {
24611
24769
  let inMultiLineComment = false;
24612
- let count11 = 0;
24770
+ let count10 = 0;
24613
24771
  for (const line of content.split("\n")) {
24614
24772
  const trimmed = line.trim();
24615
24773
  if (inMultiLineComment) {
@@ -24617,7 +24775,7 @@ function countSloc(content) {
24617
24775
  inMultiLineComment = false;
24618
24776
  const afterComment = trimmed.substring(trimmed.indexOf("*/") + 2);
24619
24777
  if (afterComment.trim().length > 0) {
24620
- count11++;
24778
+ count10++;
24621
24779
  }
24622
24780
  }
24623
24781
  continue;
@@ -24629,7 +24787,7 @@ function countSloc(content) {
24629
24787
  if (trimmed.includes("*/")) {
24630
24788
  const afterComment = trimmed.substring(trimmed.indexOf("*/") + 2);
24631
24789
  if (afterComment.trim().length > 0) {
24632
- count11++;
24790
+ count10++;
24633
24791
  }
24634
24792
  } else {
24635
24793
  inMultiLineComment = true;
@@ -24637,10 +24795,10 @@ function countSloc(content) {
24637
24795
  continue;
24638
24796
  }
24639
24797
  if (trimmed.length > 0) {
24640
- count11++;
24798
+ count10++;
24641
24799
  }
24642
24800
  }
24643
- return count11;
24801
+ return count10;
24644
24802
  }
24645
24803
 
24646
24804
  // src/commands/complexity/shared.ts
@@ -26142,10 +26300,10 @@ async function findRetiredTables(exec3) {
26142
26300
  const found = [];
26143
26301
  for (const row3 of present) {
26144
26302
  const name = String(row3.table_name);
26145
- const [count11] = await exec3.query(
26303
+ const [count10] = await exec3.query(
26146
26304
  `SELECT count(*)::int AS rows FROM "${name}"`
26147
26305
  );
26148
- found.push({ name, rows: Number(count11.rows) });
26306
+ found.push({ name, rows: Number(count10.rows) });
26149
26307
  }
26150
26308
  return found;
26151
26309
  }
@@ -29210,8 +29368,8 @@ function annotate(entry) {
29210
29368
  }
29211
29369
  return notes;
29212
29370
  }
29213
- function formatCount(count11, noun) {
29214
- return `${count11} ${noun}${count11 === 1 ? "" : "s"}`;
29371
+ function formatCount(count10, noun) {
29372
+ return `${count10} ${noun}${count10 === 1 ? "" : "s"}`;
29215
29373
  }
29216
29374
  function printFixStructurePlan(plan2, chain2, apply) {
29217
29375
  writeLineNow(chalk184.dim(`chain: ${chain2.join(" > ")}`));
@@ -30690,9 +30848,9 @@ async function writeInboxLastScan(orm, at2) {
30690
30848
  }
30691
30849
 
30692
30850
  // src/shared/db/finishJobRun.ts
30693
- import { eq as eq54 } from "drizzle-orm";
30851
+ import { eq as eq55 } from "drizzle-orm";
30694
30852
  async function finishJobRun(db, id, result) {
30695
- await db.update(jobRuns).set(result).where(eq54(jobRuns.id, id));
30853
+ await db.update(jobRuns).set(result).where(eq55(jobRuns.id, id));
30696
30854
  }
30697
30855
 
30698
30856
  // src/shared/db/startJobRun.ts
@@ -32783,14 +32941,14 @@ async function netcap(options2) {
32783
32941
  const filter = options2.filter ?? "";
32784
32942
  await mkdir6(dirname38(outPath), { recursive: true });
32785
32943
  const extensionPath = await prepareExtensionForLoad(port, filter);
32786
- let count11 = 0;
32944
+ let count10 = 0;
32787
32945
  const handler = createNetcapHandler({
32788
32946
  outPath,
32789
32947
  onPing: () => console.log(chalk198.dim("ping from extension")),
32790
32948
  onCapture: (entry) => {
32791
- count11 += 1;
32949
+ count10 += 1;
32792
32950
  console.log(
32793
- chalk198.green(`captured #${count11}`),
32951
+ chalk198.green(`captured #${count10}`),
32794
32952
  chalk198.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
32795
32953
  );
32796
32954
  }
@@ -32811,7 +32969,7 @@ async function netcap(options2) {
32811
32969
  console.log(
32812
32970
  chalk198.bold(
32813
32971
  `
32814
- netcap stopped \u2014 captured ${count11} ${count11 === 1 ? "entry" : "entries"} to ${outPath}`
32972
+ netcap stopped \u2014 captured ${count10} ${count10 === 1 ? "entry" : "entries"} to ${outPath}`
32815
32973
  )
32816
32974
  );
32817
32975
  process.exit(0);
@@ -33333,9 +33491,9 @@ async function list4() {
33333
33491
  import chalk202 from "chalk";
33334
33492
 
33335
33493
  // src/commands/backlog/removeFeed.ts
33336
- import { eq as eq55 } from "drizzle-orm";
33494
+ import { eq as eq56 } from "drizzle-orm";
33337
33495
  async function removeFeed(db, url) {
33338
- const deleted = await db.delete(feeds).where(eq55(feeds.url, url)).returning({ id: feeds.id });
33496
+ const deleted = await db.delete(feeds).where(eq56(feeds.url, url)).returning({ id: feeds.id });
33339
33497
  return deleted.length > 0;
33340
33498
  }
33341
33499
 
@@ -33420,11 +33578,11 @@ function printPromptsTable(rows) {
33420
33578
  console.log(chalk203.dim(header));
33421
33579
  console.log(chalk203.dim("-".repeat(header.length)));
33422
33580
  for (const row3 of rows) {
33423
- const count11 = String(row3.count).padStart(countWidth);
33581
+ const count10 = String(row3.count).padStart(countWidth);
33424
33582
  const tool = row3.tool.padEnd(toolWidth);
33425
33583
  const command = truncate2(row3.command, 60).padEnd(commandWidth);
33426
33584
  console.log(
33427
- `${chalk203.yellow(count11)} ${tool} ${command} ${chalk203.dim(row3.repos)}`
33585
+ `${chalk203.yellow(count10)} ${tool} ${command} ${chalk203.dim(row3.repos)}`
33428
33586
  );
33429
33587
  }
33430
33588
  }
@@ -33537,8 +33695,8 @@ async function promptNavigation(currentPage, totalPages) {
33537
33695
  });
33538
33696
  return parseAction(action);
33539
33697
  }
33540
- function computeTotalPages(count11) {
33541
- return Math.ceil(count11 / PAGE_SIZE2);
33698
+ function computeTotalPages(count10) {
33699
+ return Math.ceil(count10 / PAGE_SIZE2);
33542
33700
  }
33543
33701
  async function navigateAndDisplay(pullRequests, totalPages, currentPage) {
33544
33702
  const delta = await promptNavigation(currentPage, totalPages);
@@ -34109,9 +34267,9 @@ function renderResolvedIndex(threads, style) {
34109
34267
  for (const thread of threads) {
34110
34268
  const first = thread.comments[0];
34111
34269
  if (!first) continue;
34112
- const count11 = thread.comments.length > 1 ? ` (${thread.comments.length} comments)` : "";
34270
+ const count10 = thread.comments.length > 1 ? ` (${thread.comments.length} comments)` : "";
34113
34271
  lines2.push(
34114
- ` ${style.bold(threadLocation(first))} ${first.user}: ${firstLine(first.body)}${count11}`
34272
+ ` ${style.bold(threadLocation(first))} ${first.user}: ${firstLine(first.body)}${count10}`
34115
34273
  );
34116
34274
  }
34117
34275
  lines2.push("");
@@ -35607,12 +35765,12 @@ function printPrStatus(pr) {
35607
35765
  // src/commands/prs/status/printPrsStatus.ts
35608
35766
  function printPrsStatus(report) {
35609
35767
  for (const repo of report.repos) {
35610
- const count11 = repo.pullRequests.length;
35611
- console.log(`${chalk207.bold(repo.repo)} ${chalk207.dim(`(${count11} open)`)}`);
35768
+ const count10 = repo.pullRequests.length;
35769
+ console.log(`${chalk207.bold(repo.repo)} ${chalk207.dim(`(${count10} open)`)}`);
35612
35770
  for (const pr of repo.pullRequests) {
35613
35771
  printPrStatus(pr);
35614
35772
  }
35615
- if (count11 === 0) console.log(chalk207.dim(" no open pull requests"));
35773
+ if (count10 === 0) console.log(chalk207.dim(" no open pull requests"));
35616
35774
  console.log();
35617
35775
  }
35618
35776
  if (report.errors.length === 0) return;
@@ -37658,16 +37816,16 @@ import {
37658
37816
  } from "ts-morph";
37659
37817
  var suppressionPattern = /^\s*(\/\/|\/\*)\s*oxlint-disable\b/;
37660
37818
  function countLeadingSuppressions(sourceFile) {
37661
- let count11 = 0;
37819
+ let count10 = 0;
37662
37820
  for (const stmt of sourceFile.getStatementsWithComments()) {
37663
37821
  const kind = stmt.getKind();
37664
37822
  if ((kind === SyntaxKind6.SingleLineCommentTrivia || kind === SyntaxKind6.MultiLineCommentTrivia) && suppressionPattern.test(stmt.getText())) {
37665
- count11++;
37823
+ count10++;
37666
37824
  } else {
37667
37825
  break;
37668
37826
  }
37669
37827
  }
37670
- return count11;
37828
+ return count10;
37671
37829
  }
37672
37830
  function addImportPreservingSuppressions(sourceFile, structure) {
37673
37831
  if (sourceFile.getImportDeclarations().length > 0) {
@@ -39818,7 +39976,7 @@ function summariseRepoTree(cwd = process.cwd()) {
39818
39976
  return [...directories.entries()].map(([directory, extensions]) => ({
39819
39977
  directory,
39820
39978
  extensions: [...extensions.entries()].sort((a, b) => b[1] - a[1]),
39821
- total: [...extensions.values()].reduce((sum3, count11) => sum3 + count11, 0)
39979
+ total: [...extensions.values()].reduce((sum3, count10) => sum3 + count10, 0)
39822
39980
  })).sort((a, b) => b.total - a.total || a.directory.localeCompare(b.directory)).slice(0, MAX_DIRECTORIES).map(
39823
39981
  (entry) => `${entry.directory} \u2014 ${entry.total} files: ${formatExtensions(entry.extensions)}`
39824
39982
  ).join("\n");
@@ -39846,7 +40004,7 @@ function countByDirectory(files) {
39846
40004
  return directories;
39847
40005
  }
39848
40006
  function formatExtensions(extensions) {
39849
- return extensions.slice(0, MAX_EXTENSIONS_PER_DIRECTORY).map(([extension2, count11]) => `${extension2}(${count11})`).join(", ");
40007
+ return extensions.slice(0, MAX_EXTENSIONS_PER_DIRECTORY).map(([extension2, count10]) => `${extension2}(${count10})`).join(", ");
39850
40008
  }
39851
40009
 
39852
40010
  // src/commands/review/highLevel/proposeHighLevelGlobs.ts
@@ -40187,8 +40345,8 @@ function countEvidence(body) {
40187
40345
  0
40188
40346
  );
40189
40347
  }
40190
- function plural(count11, noun) {
40191
- return `${count11} ${noun}${count11 === 1 ? "" : "s"}`;
40348
+ function plural(count10, noun) {
40349
+ return `${count10} ${noun}${count10 === 1 ? "" : "s"}`;
40192
40350
  }
40193
40351
  function checkUiEvidence(body, changedFiles2, uiPaths) {
40194
40352
  if (uiPaths.length === 0)
@@ -43223,9 +43381,9 @@ function setupReviewDir(repoRoot2, context, force) {
43223
43381
  console.log(`Review folder: ${paths.reviewDir}`);
43224
43382
  return paths;
43225
43383
  }
43226
- function logPriorComments(count11) {
43227
- if (count11 === 0) return;
43228
- console.log(`Including ${count11} prior review comment(s) in request.md.`);
43384
+ function logPriorComments(count10) {
43385
+ if (count10 === 0) return;
43386
+ console.log(`Including ${count10} prior review comment(s) in request.md.`);
43229
43387
  }
43230
43388
 
43231
43389
  // src/commands/review/gatherContext.ts
@@ -44249,16 +44407,16 @@ function filterToSql(filter) {
44249
44407
  }
44250
44408
 
44251
44409
  // src/commands/seq/fetchSeqData.ts
44252
- function buildDataParams(filter, count11, from, to) {
44410
+ function buildDataParams(filter, count10, from, to) {
44253
44411
  const sqlFilter = filterToSql(filter);
44254
- const sql33 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${count11}`;
44412
+ const sql33 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${count10}`;
44255
44413
  const params = new URLSearchParams({ q: sql33 });
44256
44414
  if (from) params.set("rangeStartUtc", from);
44257
44415
  if (to) params.set("rangeEndUtc", to);
44258
44416
  return params;
44259
44417
  }
44260
- async function fetchSeqData(conn, filter, count11, from, to) {
44261
- const params = buildDataParams(filter, count11, from, to);
44418
+ async function fetchSeqData(conn, filter, count10, from, to) {
44419
+ const params = buildDataParams(filter, count10, from, to);
44262
44420
  const response = await fetchSeq(conn, "/api/data", params);
44263
44421
  const data = await response.json();
44264
44422
  return mapDataToEvents(data);
@@ -44425,12 +44583,12 @@ function resolveConnection2(name) {
44425
44583
  async function seqQuery(filter, options2) {
44426
44584
  rejectTimestampFilter(filter);
44427
44585
  const conn = resolveConnection2(options2.connection);
44428
- const count11 = Number.parseInt(options2.count ?? "1000", 10);
44586
+ const count10 = Number.parseInt(options2.count ?? "1000", 10);
44429
44587
  const from = options2.from ? parseRelativeTime(options2.from) : void 0;
44430
44588
  const to = options2.to ? parseRelativeTime(options2.to) : void 0;
44431
- const events = from || to ? await fetchSeqData(conn, filter, count11, from, to) : await fetchSeqEvents(
44589
+ const events = from || to ? await fetchSeqData(conn, filter, count10, from, to) : await fetchSeqEvents(
44432
44590
  conn,
44433
- new URLSearchParams({ filter, count: String(count11) })
44591
+ new URLSearchParams({ filter, count: String(count10) })
44434
44592
  );
44435
44593
  if (events.length === 0) {
44436
44594
  console.log(chalk270.yellow("No events found."));
@@ -44446,10 +44604,10 @@ async function seqQuery(filter, options2) {
44446
44604
  }
44447
44605
  console.log(chalk270.dim(`
44448
44606
  ${events.length} events`));
44449
- if (events.length >= count11) {
44607
+ if (events.length >= count10) {
44450
44608
  console.log(
44451
44609
  chalk270.yellow(
44452
- `Results limited to ${count11}. Use --count to retrieve more.`
44610
+ `Results limited to ${count10}. Use --count to retrieve more.`
44453
44611
  )
44454
44612
  );
44455
44613
  }
@@ -46343,10 +46501,10 @@ function closesBlock(trimmed, from) {
46343
46501
  }
46344
46502
  function csharpHeaderLineCount(content) {
46345
46503
  const lines2 = content.split("\n");
46346
- let count11 = 0;
46504
+ let count10 = 0;
46347
46505
  let inBlock = false;
46348
- while (count11 < lines2.length) {
46349
- const trimmed = lines2[count11].trim();
46506
+ while (count10 < lines2.length) {
46507
+ const trimmed = lines2[count10].trim();
46350
46508
  if (inBlock) {
46351
46509
  inBlock = !closesBlock(trimmed, 0);
46352
46510
  } else if (trimmed.startsWith("/*")) {
@@ -46354,9 +46512,9 @@ function csharpHeaderLineCount(content) {
46354
46512
  } else if (trimmed !== "" && !trimmed.startsWith("//")) {
46355
46513
  break;
46356
46514
  }
46357
- count11++;
46515
+ count10++;
46358
46516
  }
46359
- return count11;
46517
+ return count10;
46360
46518
  }
46361
46519
 
46362
46520
  // src/commands/verify/blockCodeComments/collectCsharpComments.ts
@@ -47095,9 +47253,9 @@ function parseWatchDurations(interval, timeout) {
47095
47253
  }
47096
47254
 
47097
47255
  // src/commands/watch/readRecentCommits.ts
47098
- function readRecentCommits(count11 = 10, cwd) {
47256
+ function readRecentCommits(count10 = 10, cwd) {
47099
47257
  const output = runGit3(
47100
- ["log", `-${count11}`, "--pretty=format:%H%x09%h%x09%ar%x09%s"],
47258
+ ["log", `-${count10}`, "--pretty=format:%H%x09%h%x09%ar%x09%s"],
47101
47259
  cwd
47102
47260
  );
47103
47261
  if (!output) return [];
@@ -47583,10 +47741,10 @@ function fetchQuietly(cwd, intervalMs) {
47583
47741
  }
47584
47742
 
47585
47743
  // src/commands/watch/detectMovement.ts
47586
- function detectMovement(from, to, count11) {
47744
+ function detectMovement(from, to, count10) {
47587
47745
  if (from === to) return void 0;
47588
- if (!Number.isFinite(count11) || count11 <= 0) return void 0;
47589
- return { from, to, count: count11 };
47746
+ if (!Number.isFinite(count10) || count10 <= 0) return void 0;
47747
+ return { from, to, count: count10 };
47590
47748
  }
47591
47749
 
47592
47750
  // src/commands/watch/readMovement.ts
@@ -47594,8 +47752,8 @@ function readMovement(cwd) {
47594
47752
  try {
47595
47753
  const from = runGit3(["rev-parse", "@"], cwd);
47596
47754
  const to = runGit3(["rev-parse", "@{u}"], cwd);
47597
- const count11 = Number(runGit3(["rev-list", "--count", "@..@{u}"], cwd));
47598
- return detectMovement(from, to, count11);
47755
+ const count10 = Number(runGit3(["rev-list", "--count", "@..@{u}"], cwd));
47756
+ return detectMovement(from, to, count10);
47599
47757
  } catch {
47600
47758
  return void 0;
47601
47759
  }
@@ -48107,12 +48265,12 @@ function parseEnvPairs(pairs) {
48107
48265
  if (pairs.length === 0) return void 0;
48108
48266
  const env = {};
48109
48267
  for (const pair of pairs) {
48110
- const eq59 = pair.indexOf("=");
48111
- if (eq59 <= 0) {
48268
+ const eq60 = pair.indexOf("=");
48269
+ if (eq60 <= 0) {
48112
48270
  console.error(`--env must be KEY=VALUE, got "${pair}"`);
48113
48271
  process.exit(1);
48114
48272
  }
48115
- env[pair.slice(0, eq59)] = pair.slice(eq59 + 1);
48273
+ env[pair.slice(0, eq60)] = pair.slice(eq60 + 1);
48116
48274
  }
48117
48275
  return env;
48118
48276
  }
@@ -48125,11 +48283,11 @@ function fail11(spec) {
48125
48283
  process.exit(1);
48126
48284
  }
48127
48285
  function parseParamSpec(spec) {
48128
- const eq59 = spec.indexOf("=");
48129
- const name = eq59 === -1 ? spec : spec.slice(0, eq59);
48130
- if (eq59 !== -1) {
48131
- if (eq59 === 0 || name.endsWith("!")) fail11(spec);
48132
- return { name, default: spec.slice(eq59 + 1) };
48286
+ const eq60 = spec.indexOf("=");
48287
+ const name = eq60 === -1 ? spec : spec.slice(0, eq60);
48288
+ if (eq60 !== -1) {
48289
+ if (eq60 === 0 || name.endsWith("!")) fail11(spec);
48290
+ return { name, default: spec.slice(eq60 + 1) };
48133
48291
  }
48134
48292
  if (name.endsWith("!")) {
48135
48293
  if (name.length === 1) fail11(spec);
@@ -48598,9 +48756,9 @@ async function drainDaemon(options2 = {}) {
48598
48756
  return;
48599
48757
  }
48600
48758
  }
48601
- const count11 = await requestDrain(socket, lines2);
48759
+ const count10 = await requestDrain(socket, lines2);
48602
48760
  socket.destroy();
48603
- console.log(`Drained ${count11} session(s)`);
48761
+ console.log(`Drained ${count10} session(s)`);
48604
48762
  }
48605
48763
  function reportLive(live) {
48606
48764
  console.log(`${live.length} live session(s) would be closed:`);
@@ -48698,10 +48856,10 @@ function createActivityThrottle(onActivity) {
48698
48856
  }
48699
48857
 
48700
48858
  // src/shared/db/readInboxLastRun.ts
48701
- import { eq as eq56 } from "drizzle-orm";
48859
+ import { eq as eq57 } from "drizzle-orm";
48702
48860
  var INBOX_LAST_RUN_KEY = "inbox.lastRun";
48703
48861
  async function readInboxLastRun(orm) {
48704
- const [row3] = await orm.select().from(metadata).where(eq56(metadata.key, INBOX_LAST_RUN_KEY));
48862
+ const [row3] = await orm.select().from(metadata).where(eq57(metadata.key, INBOX_LAST_RUN_KEY));
48705
48863
  return row3 ? JSON.parse(row3.value) : void 0;
48706
48864
  }
48707
48865
 
@@ -48928,11 +49086,11 @@ function pollRepoConfigCache(intervalMs = POLL_MS2) {
48928
49086
  inFlight2 = true;
48929
49087
  try {
48930
49088
  const before = cacheSnapshot();
48931
- const count11 = await refreshRepoConfigCache();
49089
+ const count10 = await refreshRepoConfigCache();
48932
49090
  if (failing) daemonLog("repo config cache poll recovered");
48933
49091
  failing = false;
48934
49092
  if (cacheSnapshot() !== before)
48935
- daemonLog(`repo config cache updated (${count11} repos)`);
49093
+ daemonLog(`repo config cache updated (${count10} repos)`);
48936
49094
  } catch (error) {
48937
49095
  if (!failing)
48938
49096
  daemonLog(
@@ -48951,8 +49109,8 @@ function pollRepoConfigCache(intervalMs = POLL_MS2) {
48951
49109
  // src/commands/sessions/daemon/refreshRepoConfigCacheOnStart.ts
48952
49110
  async function refreshRepoConfigCacheOnStart() {
48953
49111
  try {
48954
- const count11 = await refreshRepoConfigCache();
48955
- daemonLog(`repo config cache refreshed (${count11} repos)`);
49112
+ const count10 = await refreshRepoConfigCache();
49113
+ daemonLog(`repo config cache refreshed (${count10} repos)`);
48956
49114
  } catch (error) {
48957
49115
  daemonLog(
48958
49116
  `repo config cache refresh failed; keeping the last snapshot: ${String(error)}`
@@ -51330,12 +51488,12 @@ function closeSessionPreviews(session, waiters, reason4) {
51330
51488
  }
51331
51489
 
51332
51490
  // src/commands/sessions/daemon/logPrDecision.ts
51333
- function count10(value) {
51491
+ function count9(value) {
51334
51492
  return Array.isArray(value) ? value.length : 0;
51335
51493
  }
51336
51494
  function logPrDecision(id, requestId, d) {
51337
51495
  daemonLog(
51338
- `pr-decision received: id=${id} requestId=${requestId} decision=${d.decision} comments=${count10(d.comments)} screenshots=${count10(d.screenshots)} checklist=${count10(d.checklist)} reviewEvent=${d.reviewEvent} reviewComments=${count10(d.reviewComments)} reviewAfter=${d.reviewAfter === true} announceAfter=${d.announceAfter === true} draft=${d.draft} autoMerge=${d.autoMerge === true} autostart=${d.autostart === true} answers=${d.answers && typeof d.answers === "object" ? Object.keys(d.answers).length : 0}`
51496
+ `pr-decision received: id=${id} requestId=${requestId} decision=${d.decision} comments=${count9(d.comments)} screenshots=${count9(d.screenshots)} checklist=${count9(d.checklist)} reviewEvent=${d.reviewEvent} reviewComments=${count9(d.reviewComments)} reviewAfter=${d.reviewAfter === true} announceAfter=${d.announceAfter === true} draft=${d.draft} autoMerge=${d.autoMerge === true} autostart=${d.autostart === true} answers=${d.answers && typeof d.answers === "object" ? Object.keys(d.answers).length : 0}`
51339
51497
  );
51340
51498
  }
51341
51499
 
@@ -51902,10 +52060,10 @@ function applyReviewPause(session, activity2) {
51902
52060
  }
51903
52061
 
51904
52062
  // src/shared/db/getPhaseActiveMs.ts
51905
- import { and as and25, eq as eq57 } from "drizzle-orm";
52063
+ import { and as and26, eq as eq58 } from "drizzle-orm";
51906
52064
  async function getPhaseActiveMs(db, itemId2, phaseIdx) {
51907
52065
  const [row3] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
51908
- and25(eq57(phaseUsage.itemId, itemId2), eq57(phaseUsage.phaseIdx, phaseIdx))
52066
+ and26(eq58(phaseUsage.itemId, itemId2), eq58(phaseUsage.phaseIdx, phaseIdx))
51909
52067
  );
51910
52068
  return row3?.activeMs ?? 0;
51911
52069
  }
@@ -52718,17 +52876,17 @@ async function recordPhaseTranscriptUsage(db, itemId2, phaseIdx, responses) {
52718
52876
  }
52719
52877
 
52720
52878
  // src/shared/db/recordWindowTokens.ts
52721
- import { and as and26, eq as eq58, sql as sql32 } from "drizzle-orm";
52879
+ import { and as and27, eq as eq59, sql as sql32 } from "drizzle-orm";
52722
52880
  async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
52723
52881
  if (tokensUp <= 0 && tokensDown <= 0) return;
52724
52882
  await db.update(usagePeaks).set({
52725
52883
  tokensUp: sql32`${usagePeaks.tokensUp} + ${tokensUp}`,
52726
52884
  tokensDown: sql32`${usagePeaks.tokensDown} + ${tokensDown}`
52727
52885
  }).where(
52728
- and26(
52729
- eq58(usagePeaks.window, window),
52730
- eq58(usagePeaks.resetsAt, resetsAt),
52731
- eq58(usagePeaks.segment, 0)
52886
+ and27(
52887
+ eq59(usagePeaks.window, window),
52888
+ eq59(usagePeaks.resetsAt, resetsAt),
52889
+ eq59(usagePeaks.segment, 0)
52732
52890
  )
52733
52891
  );
52734
52892
  }
@@ -57844,10 +58002,10 @@ async function requestSessionOutput(target) {
57844
58002
  }
57845
58003
 
57846
58004
  // src/commands/sessions/lastLines.ts
57847
- function lastLines(scrollback, count11) {
58005
+ function lastLines(scrollback, count10) {
57848
58006
  const lines2 = stripAnsi(scrollback).split(/\r?\n/);
57849
58007
  if (lines2.at(-1) === "") lines2.pop();
57850
- return lines2.slice(-count11);
58008
+ return lines2.slice(-count10);
57851
58009
  }
57852
58010
 
57853
58011
  // src/commands/sessions/sessionOutput.ts
@@ -57867,8 +58025,8 @@ function resolveTarget4(sessionId2, server) {
57867
58025
  return { sessionId: sessionId2 };
57868
58026
  }
57869
58027
  async function sessionOutput(sessionId2, options2) {
57870
- const count11 = Number.parseInt(options2.lines, 10);
57871
- if (!Number.isInteger(count11) || count11 < 1)
58028
+ const count10 = Number.parseInt(options2.lines, 10);
58029
+ if (!Number.isInteger(count10) || count10 < 1)
57872
58030
  return fail12(`-n must be a positive integer, got ${options2.lines}`);
57873
58031
  const target = resolveTarget4(sessionId2, options2.server);
57874
58032
  if (typeof target === "string") return fail12(target);
@@ -57882,7 +58040,7 @@ async function sessionOutput(sessionId2, options2) {
57882
58040
  console.log(
57883
58041
  `Server run ${id} is not live (${exited === "error" ? "crashed" : "exited"}); showing its final output.`
57884
58042
  );
57885
- for (const line of lastLines(scrollback, count11)) console.log(line);
58043
+ for (const line of lastLines(scrollback, count10)) console.log(line);
57886
58044
  } catch (error) {
57887
58045
  fail12(error instanceof Error ? error.message : String(error));
57888
58046
  }