@staff0rd/assist 0.474.0 → 0.475.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.474.0",
9
+ version: "0.475.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -3887,9 +3887,9 @@ function forbiddenStrings() {
3887
3887
  console.log("No forbidden-strings rules configured.");
3888
3888
  process.exit(0);
3889
3889
  }
3890
- const cache5 = /* @__PURE__ */ new Map();
3890
+ const cache4 = /* @__PURE__ */ new Map();
3891
3891
  const readJson = (file) => {
3892
- if (cache5.has(file)) return cache5.get(file);
3892
+ if (cache4.has(file)) return cache4.get(file);
3893
3893
  if (!existsSync12(file)) {
3894
3894
  console.log(`Forbidden-strings file not found: ${file}`);
3895
3895
  process.exit(1);
@@ -3901,7 +3901,7 @@ function forbiddenStrings() {
3901
3901
  console.log(`Could not parse ${file}: ${error.message}`);
3902
3902
  process.exit(1);
3903
3903
  }
3904
- cache5.set(file, parsed);
3904
+ cache4.set(file, parsed);
3905
3905
  return parsed;
3906
3906
  };
3907
3907
  const violations = findForbiddenStrings(rules, readJson);
@@ -8570,19 +8570,19 @@ import { dirname as dirname19, join as join23 } from "path";
8570
8570
  import { fileURLToPath as fileURLToPath4 } from "url";
8571
8571
  function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
8572
8572
  const file = join23(dirname19(fileURLToPath4(importMetaUrl)), bundlePath);
8573
- let cache5;
8573
+ let cache4;
8574
8574
  return (req, res) => {
8575
8575
  const mtimeMs = statSync2(file).mtimeMs;
8576
- if (cache5?.mtimeMs !== mtimeMs) {
8576
+ if (cache4?.mtimeMs !== mtimeMs) {
8577
8577
  const body = readFileSync19(file, "utf8");
8578
8578
  const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
8579
- cache5 = { body, etag, mtimeMs };
8579
+ cache4 = { body, etag, mtimeMs };
8580
8580
  }
8581
8581
  const headers = {
8582
- ETag: cache5.etag,
8582
+ ETag: cache4.etag,
8583
8583
  "Cache-Control": "no-cache"
8584
8584
  };
8585
- if (req.headers["if-none-match"] === cache5.etag) {
8585
+ if (req.headers["if-none-match"] === cache4.etag) {
8586
8586
  res.writeHead(304, headers);
8587
8587
  res.end();
8588
8588
  return;
@@ -8591,7 +8591,7 @@ function createBundleHandler(importMetaUrl, bundlePath, contentType = "applicati
8591
8591
  "Content-Type": contentType,
8592
8592
  ...headers
8593
8593
  });
8594
- res.end(cache5.body);
8594
+ res.end(cache4.body);
8595
8595
  };
8596
8596
  }
8597
8597
 
@@ -9723,111 +9723,6 @@ function parseGitStatus(output) {
9723
9723
  return result;
9724
9724
  }
9725
9725
 
9726
- // src/shared/db/findCommitAnchor.ts
9727
- import { and as and8, asc as asc8, eq as eq18, inArray as inArray3 } from "drizzle-orm";
9728
- async function findCommitAnchor(db, itemId2) {
9729
- const rows = await db.select({ kind: itemGitRefs.kind, ref: itemGitRefs.ref }).from(itemGitRefs).where(
9730
- and8(
9731
- eq18(itemGitRefs.itemId, itemId2),
9732
- inArray3(itemGitRefs.kind, ["commit", "commit-parent"])
9733
- )
9734
- ).orderBy(asc8(itemGitRefs.createdAt));
9735
- const anchor = {};
9736
- for (const row of rows) {
9737
- if (row.kind === "commit") anchor.commit ??= row.ref;
9738
- else anchor.parent ??= row.ref;
9739
- }
9740
- return anchor;
9741
- }
9742
-
9743
- // src/commands/sessions/web/sessionCommitAnchor.ts
9744
- var EMPTY_TTL_MS = 3e4;
9745
- var cache4 = /* @__PURE__ */ new Map();
9746
- var inFlight2 = /* @__PURE__ */ new Map();
9747
- async function sessionCommitAnchor(sessionId) {
9748
- const cached = cache4.get(sessionId);
9749
- if (cached && cached.expiresAt > Date.now()) return cached.anchor;
9750
- const pending = inFlight2.get(sessionId);
9751
- if (pending) return pending;
9752
- const lookup = loadAnchor(sessionId).finally(
9753
- () => inFlight2.delete(sessionId)
9754
- );
9755
- inFlight2.set(sessionId, lookup);
9756
- return lookup;
9757
- }
9758
- async function loadAnchor(sessionId) {
9759
- const anchor = await queryAnchor(sessionId);
9760
- const found = Boolean(anchor.commit || anchor.parent);
9761
- cache4.set(sessionId, {
9762
- anchor,
9763
- expiresAt: found ? Number.POSITIVE_INFINITY : Date.now() + EMPTY_TTL_MS
9764
- });
9765
- return anchor;
9766
- }
9767
- async function queryAnchor(sessionId) {
9768
- try {
9769
- if (!process.env.ASSIST_DATABASE_URL && !loadConfig().database.url)
9770
- return {};
9771
- const db = await getDb();
9772
- const itemId2 = await findItemBySessionId(db, sessionId);
9773
- if (itemId2 === void 0) return {};
9774
- return await findCommitAnchor(db, itemId2);
9775
- } catch {
9776
- return {};
9777
- }
9778
- }
9779
-
9780
- // src/commands/sessions/web/resolveDiffBase.ts
9781
- function baseCandidates(defaultBranch) {
9782
- return [
9783
- defaultBranch && `origin/${defaultBranch}`,
9784
- defaultBranch,
9785
- "origin/main",
9786
- "origin/master",
9787
- "main",
9788
- "master"
9789
- ].filter((candidate) => Boolean(candidate));
9790
- }
9791
- async function refExists2(cwd, ref) {
9792
- try {
9793
- await execGit(cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
9794
- return true;
9795
- } catch {
9796
- return false;
9797
- }
9798
- }
9799
- async function anchoredBase(cwd, sessionId) {
9800
- const { commit: commit2, parent } = await sessionCommitAnchor(sessionId);
9801
- if (parent && await refExists2(cwd, parent)) return parent;
9802
- if (commit2 && await refExists2(cwd, `${commit2}^`)) return `${commit2}^`;
9803
- return void 0;
9804
- }
9805
- async function resolveDiffBase(cwd, sessionId) {
9806
- let defaultBranch;
9807
- try {
9808
- const config = loadConfigFrom(toGitCwd(cwd));
9809
- if (!config.sessions?.includeCommittedChanges) return "HEAD";
9810
- defaultBranch = config.branch?.defaultBranch;
9811
- } catch {
9812
- return "HEAD";
9813
- }
9814
- if (sessionId) {
9815
- const anchored = await anchoredBase(cwd, sessionId);
9816
- if (anchored) return anchored;
9817
- }
9818
- for (const candidate of baseCandidates(defaultBranch)) {
9819
- if (!await refExists2(cwd, candidate)) continue;
9820
- try {
9821
- const base = await execGit(cwd, ["merge-base", "HEAD", candidate]);
9822
- const sha = base.trim();
9823
- if (sha) return sha;
9824
- } catch {
9825
- }
9826
- return "HEAD";
9827
- }
9828
- return "HEAD";
9829
- }
9830
-
9831
9726
  // src/commands/sessions/web/gitStatus.ts
9832
9727
  async function untrackedPaths(cwd) {
9833
9728
  const list5 = await execGit(cwd, [
@@ -9837,9 +9732,13 @@ async function untrackedPaths(cwd) {
9837
9732
  ]);
9838
9733
  return list5.split("\n").filter(Boolean);
9839
9734
  }
9840
- async function branchCounts(cwd, base) {
9841
- const output = await execGit(cwd, ["diff", "--name-status", base]);
9842
- const counts = parseDiffNameStatus(output);
9735
+ async function groupedCounts(cwd, groups) {
9736
+ const outputs = await Promise.all(
9737
+ groups.map(
9738
+ (group) => execGit(cwd, ["diff", "--name-status", group.base, "--", ...group.paths])
9739
+ )
9740
+ );
9741
+ const counts = parseDiffNameStatus(outputs.join(""));
9843
9742
  counts.new.push(...await untrackedPaths(cwd));
9844
9743
  return counts;
9845
9744
  }
@@ -9855,12 +9754,22 @@ async function gitStatus(req, res) {
9855
9754
  const cwd = getCwdParam(req, res);
9856
9755
  if (!cwd) return;
9857
9756
  try {
9858
- const base = await resolveDiffBase(cwd, getSessionParam(req));
9859
- respondJson(
9860
- res,
9861
- 200,
9862
- base === "HEAD" ? await workingTreeCounts(cwd) : await branchCounts(cwd, base)
9757
+ const changeSet = await itemChangeSet(cwd, getSessionParam(req)).catch(
9758
+ () => void 0
9863
9759
  );
9760
+ if (!changeSet) {
9761
+ respondJson(res, 200, await workingTreeCounts(cwd));
9762
+ return;
9763
+ }
9764
+ const [counts, uncommitted] = await Promise.all([
9765
+ groupedCounts(cwd, changeSet.groups),
9766
+ workingTreeCounts(cwd)
9767
+ ]);
9768
+ respondJson(res, 200, {
9769
+ ...counts,
9770
+ uncommitted,
9771
+ hasCommits: changeSet.commits.length > 0
9772
+ });
9864
9773
  } catch {
9865
9774
  respondJson(res, 200, { new: [], modified: [], deleted: [] });
9866
9775
  }
@@ -10144,14 +10053,14 @@ async function listNewsItems(_req, res) {
10144
10053
  }
10145
10054
 
10146
10055
  // src/shared/db/countUsagePeaks.ts
10147
- import { count, eq as eq19 } from "drizzle-orm";
10056
+ import { count, eq as eq18 } from "drizzle-orm";
10148
10057
  async function countUsagePeaks(db, window) {
10149
- const [row] = await db.select({ value: count() }).from(usagePeaks).where(window ? eq19(usagePeaks.window, window) : void 0);
10058
+ const [row] = await db.select({ value: count() }).from(usagePeaks).where(window ? eq18(usagePeaks.window, window) : void 0);
10150
10059
  return row?.value ?? 0;
10151
10060
  }
10152
10061
 
10153
10062
  // src/shared/db/listUsagePeaks.ts
10154
- import { and as and9, desc as desc2, eq as eq20, getTableColumns } from "drizzle-orm";
10063
+ import { and as and8, desc as desc2, eq as eq19, getTableColumns } from "drizzle-orm";
10155
10064
 
10156
10065
  // src/shared/db/avgContextPerCycle.ts
10157
10066
  import { count as count2, sql as sql16 } from "drizzle-orm";
@@ -10175,11 +10084,11 @@ async function listUsagePeaks(db, options2) {
10175
10084
  phaseCount: avgContext.phaseCount
10176
10085
  }).from(usagePeaks).leftJoin(
10177
10086
  avgContext,
10178
- and9(
10179
- eq20(usagePeaks.window, avgContext.window),
10180
- eq20(usagePeaks.resetsAt, avgContext.resetsAt)
10087
+ and8(
10088
+ eq19(usagePeaks.window, avgContext.window),
10089
+ eq19(usagePeaks.resetsAt, avgContext.resetsAt)
10181
10090
  )
10182
- ).where(options2?.window ? eq20(usagePeaks.window, options2.window) : void 0).orderBy(
10091
+ ).where(options2?.window ? eq19(usagePeaks.window, options2.window) : void 0).orderBy(
10183
10092
  desc2(usagePeaks.resetsAt),
10184
10093
  usagePeaks.window,
10185
10094
  desc2(usagePeaks.createdAt),
@@ -10234,11 +10143,11 @@ var execFileAsync4 = promisify5(execFile5);
10234
10143
  var CACHE_TTL_MS3 = 3e4;
10235
10144
  function createCachedGhJson(args, parse3, fallback, options2 = {}) {
10236
10145
  const { cacheFallback = true } = options2;
10237
- const cache5 = /* @__PURE__ */ new Map();
10146
+ const cache4 = /* @__PURE__ */ new Map();
10238
10147
  return async (cwd, extraArgs = []) => {
10239
10148
  const key = extraArgs.length ? `${cwd}\0${extraArgs.join("\0")}` : cwd;
10240
10149
  const now = Date.now();
10241
- const cached = cache5.get(key);
10150
+ const cached = cache4.get(key);
10242
10151
  if (cached && cached.expires > now) return cached.value;
10243
10152
  let value = fallback;
10244
10153
  try {
@@ -10251,7 +10160,7 @@ function createCachedGhJson(args, parse3, fallback, options2 = {}) {
10251
10160
  value = fallback;
10252
10161
  }
10253
10162
  if (cacheFallback || value !== fallback)
10254
- cache5.set(key, { value, expires: now + CACHE_TTL_MS3 });
10163
+ cache4.set(key, { value, expires: now + CACHE_TTL_MS3 });
10255
10164
  return value;
10256
10165
  };
10257
10166
  }
@@ -10950,22 +10859,22 @@ import { readFileSync as readFileSync21 } from "fs";
10950
10859
  import { createRequire as createRequire2 } from "module";
10951
10860
  var require3 = createRequire2(import.meta.url);
10952
10861
  function createCssHandler(packageEntry) {
10953
- let cache5;
10862
+ let cache4;
10954
10863
  return (req, res) => {
10955
- if (!cache5) {
10864
+ if (!cache4) {
10956
10865
  const resolved = require3.resolve(packageEntry);
10957
10866
  const body = readFileSync21(resolved, "utf8");
10958
10867
  const etag = `"${createHash2("sha256").update(body).digest("hex").slice(0, 16)}"`;
10959
- cache5 = { body, etag };
10868
+ cache4 = { body, etag };
10960
10869
  }
10961
- const headers = { ETag: cache5.etag, "Cache-Control": "no-cache" };
10962
- if (req.headers["if-none-match"] === cache5.etag) {
10870
+ const headers = { ETag: cache4.etag, "Cache-Control": "no-cache" };
10871
+ if (req.headers["if-none-match"] === cache4.etag) {
10963
10872
  res.writeHead(304, headers);
10964
10873
  res.end();
10965
10874
  return;
10966
10875
  }
10967
10876
  res.writeHead(200, { "Content-Type": "text/css", ...headers });
10968
- res.end(cache5.body);
10877
+ res.end(cache4.body);
10969
10878
  };
10970
10879
  }
10971
10880
 
@@ -11467,11 +11376,11 @@ function registerActivityCommands(cmd) {
11467
11376
 
11468
11377
  // src/commands/backlog/associate-github/index.ts
11469
11378
  import chalk64 from "chalk";
11470
- import { eq as eq22 } from "drizzle-orm";
11379
+ import { eq as eq21 } from "drizzle-orm";
11471
11380
 
11472
11381
  // src/commands/backlog/beginAssociation.ts
11473
11382
  import chalk63 from "chalk";
11474
- import { eq as eq21 } from "drizzle-orm";
11383
+ import { eq as eq20 } from "drizzle-orm";
11475
11384
  async function beginAssociation(id, options2, clearPatch, label2) {
11476
11385
  const found = await findOneItem(id);
11477
11386
  if (!found) {
@@ -11481,7 +11390,7 @@ async function beginAssociation(id, options2, clearPatch, label2) {
11481
11390
  const { orm } = found;
11482
11391
  const itemId2 = found.item.id;
11483
11392
  if (options2.clear) {
11484
- await orm.update(items).set(clearPatch).where(eq21(items.id, itemId2));
11393
+ await orm.update(items).set(clearPatch).where(eq20(items.id, itemId2));
11485
11394
  console.log(
11486
11395
  chalk63.green(
11487
11396
  `Cleared ${label2} association on item ${formatItemId(itemId2)}.`
@@ -11549,7 +11458,7 @@ async function associateGithub(id, issue, options2) {
11549
11458
  return;
11550
11459
  }
11551
11460
  const title = fetchGithubIssueTitle(normalized);
11552
- await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(eq22(items.id, itemId2));
11461
+ await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(eq21(items.id, itemId2));
11553
11462
  console.log(
11554
11463
  chalk64.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
11555
11464
  title ? chalk64.dim(`(${title})`) : ""
@@ -11563,7 +11472,7 @@ function registerAssociateGithubCommand(cmd) {
11563
11472
 
11564
11473
  // src/commands/backlog/associate-jira/index.ts
11565
11474
  import chalk66 from "chalk";
11566
- import { eq as eq23 } from "drizzle-orm";
11475
+ import { eq as eq22 } from "drizzle-orm";
11567
11476
 
11568
11477
  // src/commands/jira/fetchIssue.ts
11569
11478
  import { execSync as execSync33 } from "child_process";
@@ -11628,7 +11537,7 @@ async function associateJira(id, key, options2) {
11628
11537
  const parsed = fetchIssue(normalized, "summary");
11629
11538
  const fields = parsed?.fields;
11630
11539
  const summary = fields?.summary;
11631
- await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq23(items.id, itemId2));
11540
+ await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq22(items.id, itemId2));
11632
11541
  console.log(
11633
11542
  chalk66.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
11634
11543
  summary ? chalk66.dim(`(${summary})`) : ""
@@ -12006,15 +11915,15 @@ function isClaudeCode() {
12006
11915
  }
12007
11916
 
12008
11917
  // src/commands/backlog/insertPhaseAt.ts
12009
- import { eq as eq25 } from "drizzle-orm";
11918
+ import { eq as eq24 } from "drizzle-orm";
12010
11919
 
12011
11920
  // src/commands/backlog/shiftPhasesUp.ts
12012
- import { and as and10, desc as desc3, eq as eq24, gte } from "drizzle-orm";
11921
+ import { and as and9, desc as desc3, eq as eq23, gte } from "drizzle-orm";
12013
11922
  async function shiftPhasesUp(db, itemId2, fromIdx) {
12014
- const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(and10(eq24(planPhases.itemId, itemId2), gte(planPhases.idx, fromIdx))).orderBy(desc3(planPhases.idx));
11923
+ const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(and9(eq23(planPhases.itemId, itemId2), gte(planPhases.idx, fromIdx))).orderBy(desc3(planPhases.idx));
12015
11924
  for (const p of toShift) {
12016
- await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(and10(eq24(planTasks.itemId, itemId2), eq24(planTasks.phaseIdx, p.idx)));
12017
- await db.update(planPhases).set({ idx: p.idx + 1 }).where(and10(eq24(planPhases.itemId, itemId2), eq24(planPhases.idx, p.idx)));
11925
+ await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(and9(eq23(planTasks.itemId, itemId2), eq23(planTasks.phaseIdx, p.idx)));
11926
+ await db.update(planPhases).set({ idx: p.idx + 1 }).where(and9(eq23(planPhases.itemId, itemId2), eq23(planPhases.idx, p.idx)));
12018
11927
  }
12019
11928
  }
12020
11929
 
@@ -12027,7 +11936,7 @@ async function insertPhaseAt(orm, itemId2, phaseIdx, name, tasks, manualChecks,
12027
11936
  await tx.insert(planTasks).values(tasks.map((task, i) => ({ itemId: itemId2, phaseIdx, idx: i, task })));
12028
11937
  }
12029
11938
  if (currentPhase !== void 0 && currentPhase - 1 >= phaseIdx) {
12030
- await tx.update(items).set({ currentPhase: phaseIdx + 1 }).where(eq25(items.id, itemId2));
11939
+ await tx.update(items).set({ currentPhase: phaseIdx + 1 }).where(eq24(items.id, itemId2));
12031
11940
  }
12032
11941
  });
12033
11942
  }
@@ -12199,9 +12108,9 @@ import chalk76 from "chalk";
12199
12108
 
12200
12109
  // src/commands/backlog/resolveInsertPosition.ts
12201
12110
  import chalk75 from "chalk";
12202
- import { count as count3, eq as eq26 } from "drizzle-orm";
12111
+ import { count as count3, eq as eq25 } from "drizzle-orm";
12203
12112
  async function resolveInsertPosition(orm, itemId2, position) {
12204
- const [row] = await orm.select({ cnt: count3() }).from(planPhases).where(eq26(planPhases.itemId, itemId2));
12113
+ const [row] = await orm.select({ cnt: count3() }).from(planPhases).where(eq25(planPhases.itemId, itemId2));
12205
12114
  const phaseCount = row?.cnt ?? 0;
12206
12115
  if (position === void 0) return phaseCount;
12207
12116
  const pos = Number.parseInt(position, 10);
@@ -12560,9 +12469,9 @@ function hasCycle(adjacency, fromId, toId) {
12560
12469
  }
12561
12470
 
12562
12471
  // src/commands/backlog/loadDependencyGraph.ts
12563
- import { eq as eq27 } from "drizzle-orm";
12472
+ import { eq as eq26 } from "drizzle-orm";
12564
12473
  async function loadDependencyGraph(orm) {
12565
- const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq27(links.type, "depends-on"));
12474
+ const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq26(links.type, "depends-on"));
12566
12475
  const graph = /* @__PURE__ */ new Map();
12567
12476
  for (const { itemId: itemId2, targetId } of rows) {
12568
12477
  const bucket = graph.get(itemId2);
@@ -12629,7 +12538,7 @@ async function link(fromId, toId, opts) {
12629
12538
 
12630
12539
  // src/commands/backlog/unlink.ts
12631
12540
  import chalk82 from "chalk";
12632
- import { and as and11, eq as eq28 } from "drizzle-orm";
12541
+ import { and as and10, eq as eq27 } from "drizzle-orm";
12633
12542
  async function unlink(fromId, toId) {
12634
12543
  const fromNum = parseItemId(fromId);
12635
12544
  const toNum = parseItemId(toId);
@@ -12653,7 +12562,7 @@ async function unlink(fromId, toId) {
12653
12562
  );
12654
12563
  return;
12655
12564
  }
12656
- await orm.delete(links).where(and11(eq28(links.itemId, fromNum), eq28(links.targetId, toNum)));
12565
+ await orm.delete(links).where(and10(eq27(links.itemId, fromNum), eq27(links.targetId, toNum)));
12657
12566
  console.log(
12658
12567
  chalk82.green(
12659
12568
  `Removed link from ${formatItemId(fromNum)} to ${formatItemId(toNum)}.`
@@ -12673,7 +12582,7 @@ function registerLinkCommands(cmd) {
12673
12582
 
12674
12583
  // src/commands/backlog/move-repo/index.ts
12675
12584
  import chalk84 from "chalk";
12676
- import { eq as eq30 } from "drizzle-orm";
12585
+ import { eq as eq29 } from "drizzle-orm";
12677
12586
 
12678
12587
  // src/commands/backlog/move-repo/confirmMove.ts
12679
12588
  import chalk83 from "chalk";
@@ -12688,9 +12597,9 @@ async function confirmMove(cnt, oldOrigin, newOrigin) {
12688
12597
  }
12689
12598
 
12690
12599
  // src/commands/backlog/move-repo/countByOrigin.ts
12691
- import { count as count4, eq as eq29 } from "drizzle-orm";
12600
+ import { count as count4, eq as eq28 } from "drizzle-orm";
12692
12601
  async function countByOrigin(orm, origin) {
12693
- const [{ cnt }] = await orm.select({ cnt: count4() }).from(items).where(eq29(items.origin, origin));
12602
+ const [{ cnt }] = await orm.select({ cnt: count4() }).from(items).where(eq28(items.origin, origin));
12694
12603
  return cnt;
12695
12604
  }
12696
12605
 
@@ -12733,7 +12642,7 @@ async function moveRepo(oldOriginRaw, newOriginRaw, options2 = {}) {
12733
12642
  console.log(chalk84.yellow("Move cancelled; no changes made."));
12734
12643
  return;
12735
12644
  }
12736
- await orm.update(items).set({ origin: newOrigin }).where(eq30(items.origin, oldOrigin));
12645
+ await orm.update(items).set({ origin: newOrigin }).where(eq29(items.origin, oldOrigin));
12737
12646
  console.log(
12738
12647
  chalk84.green(
12739
12648
  `Moved ${pluralItems(cnt)} from "${oldOrigin}" to "${newOrigin}".`
@@ -13150,10 +13059,10 @@ async function start(id) {
13150
13059
 
13151
13060
  // src/commands/backlog/stop/index.ts
13152
13061
  import chalk96 from "chalk";
13153
- import { and as and12, eq as eq31 } from "drizzle-orm";
13062
+ import { and as and11, eq as eq30 } from "drizzle-orm";
13154
13063
  async function stop() {
13155
13064
  const { orm } = await getReady();
13156
- const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and12(eq31(items.status, "in-progress"), eq31(items.origin, getOrigin()))).returning({ id: items.id, name: items.name });
13065
+ const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and11(eq30(items.status, "in-progress"), eq30(items.origin, getOrigin()))).returning({ id: items.id, name: items.name });
13157
13066
  if (stopped.length === 0) {
13158
13067
  console.log(chalk96.yellow("No in-progress items to stop."));
13159
13068
  return;
@@ -13270,13 +13179,13 @@ async function findSubtask(id, index3) {
13270
13179
  }
13271
13180
 
13272
13181
  // src/commands/backlog/updateSubtask.ts
13273
- import { and as and13, eq as eq32 } from "drizzle-orm";
13182
+ import { and as and12, eq as eq31 } from "drizzle-orm";
13274
13183
  async function updateSubtask(orm, itemId2, idx, fields) {
13275
13184
  const set = {};
13276
13185
  if (fields.title !== void 0) set.title = fields.title;
13277
13186
  if (fields.description !== void 0) set.description = fields.description;
13278
13187
  if (fields.status !== void 0) set.status = fields.status;
13279
- const [row] = await orm.update(itemSubtasks).set(set).where(and13(eq32(itemSubtasks.itemId, itemId2), eq32(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
13188
+ const [row] = await orm.update(itemSubtasks).set(set).where(and12(eq31(itemSubtasks.itemId, itemId2), eq31(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
13280
13189
  return row?.title;
13281
13190
  }
13282
13191
 
@@ -13331,16 +13240,16 @@ async function editSubtask(id, index3, options2) {
13331
13240
  import chalk102 from "chalk";
13332
13241
 
13333
13242
  // src/commands/backlog/deleteSubtask.ts
13334
- import { and as and14, asc as asc9, eq as eq33 } from "drizzle-orm";
13243
+ import { and as and13, asc as asc8, eq as eq32 } from "drizzle-orm";
13335
13244
  async function deleteSubtask(orm, itemId2, idx) {
13336
- const [row] = await orm.delete(itemSubtasks).where(and14(eq33(itemSubtasks.itemId, itemId2), eq33(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
13245
+ const [row] = await orm.delete(itemSubtasks).where(and13(eq32(itemSubtasks.itemId, itemId2), eq32(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
13337
13246
  if (!row) return void 0;
13338
- const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq33(itemSubtasks.itemId, itemId2)).orderBy(asc9(itemSubtasks.idx));
13247
+ const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq32(itemSubtasks.itemId, itemId2)).orderBy(asc8(itemSubtasks.idx));
13339
13248
  for (let i = 0; i < remaining.length; i++) {
13340
13249
  const oldIdx = remaining[i].idx;
13341
13250
  if (oldIdx === i) continue;
13342
13251
  await orm.update(itemSubtasks).set({ idx: i }).where(
13343
- and14(eq33(itemSubtasks.itemId, itemId2), eq33(itemSubtasks.idx, oldIdx))
13252
+ and13(eq32(itemSubtasks.itemId, itemId2), eq32(itemSubtasks.idx, oldIdx))
13344
13253
  );
13345
13254
  }
13346
13255
  return row.title;
@@ -13409,20 +13318,20 @@ function registerSubtaskCommands(cmd) {
13409
13318
 
13410
13319
  // src/commands/backlog/movePhase.ts
13411
13320
  import chalk104 from "chalk";
13412
- import { count as count6, eq as eq36 } from "drizzle-orm";
13321
+ import { count as count6, eq as eq35 } from "drizzle-orm";
13413
13322
 
13414
13323
  // src/commands/backlog/reorderPhaseRows.ts
13415
- import { and as and16, asc as asc11, eq as eq35 } from "drizzle-orm";
13324
+ import { and as and15, asc as asc10, eq as eq34 } from "drizzle-orm";
13416
13325
 
13417
13326
  // src/commands/backlog/reindexPhases.ts
13418
- import { and as and15, asc as asc10, count as count5, eq as eq34 } from "drizzle-orm";
13327
+ import { and as and14, asc as asc9, count as count5, eq as eq33 } from "drizzle-orm";
13419
13328
  async function reindexPhases(db, itemId2) {
13420
- const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq34(planPhases.itemId, itemId2)).orderBy(asc10(planPhases.idx));
13329
+ const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq33(planPhases.itemId, itemId2)).orderBy(asc9(planPhases.idx));
13421
13330
  for (let i = 0; i < remaining.length; i++) {
13422
13331
  const oldIdx = remaining[i].idx;
13423
13332
  if (oldIdx === i) continue;
13424
- await db.update(planTasks).set({ phaseIdx: i }).where(and15(eq34(planTasks.itemId, itemId2), eq34(planTasks.phaseIdx, oldIdx)));
13425
- await db.update(planPhases).set({ idx: i }).where(and15(eq34(planPhases.itemId, itemId2), eq34(planPhases.idx, oldIdx)));
13333
+ await db.update(planTasks).set({ phaseIdx: i }).where(and14(eq33(planTasks.itemId, itemId2), eq33(planTasks.phaseIdx, oldIdx)));
13334
+ await db.update(planPhases).set({ idx: i }).where(and14(eq33(planPhases.itemId, itemId2), eq33(planPhases.idx, oldIdx)));
13426
13335
  }
13427
13336
  }
13428
13337
  async function adjustCurrentPhase(db, item, removedIdx) {
@@ -13430,24 +13339,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
13430
13339
  if (currentPhase === void 0) return;
13431
13340
  const currentIdx = currentPhase - 1;
13432
13341
  if (removedIdx < currentIdx) {
13433
- await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq34(items.id, item.id));
13342
+ await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq33(items.id, item.id));
13434
13343
  return;
13435
13344
  }
13436
13345
  if (removedIdx !== currentIdx) return;
13437
- const [row] = await db.select({ cnt: count5() }).from(planPhases).where(eq34(planPhases.itemId, item.id));
13346
+ const [row] = await db.select({ cnt: count5() }).from(planPhases).where(eq33(planPhases.itemId, item.id));
13438
13347
  const cnt = row?.cnt ?? 0;
13439
- await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq34(items.id, item.id));
13348
+ await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq33(items.id, item.id));
13440
13349
  }
13441
13350
 
13442
13351
  // src/commands/backlog/reorderPhaseRows.ts
13443
13352
  async function reorderPhaseRows(orm, itemId2, fromIdx, toIdx) {
13444
13353
  await orm.transaction(async (tx) => {
13445
- const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and16(eq35(planPhases.itemId, itemId2), eq35(planPhases.idx, fromIdx)));
13446
- const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and16(eq35(planTasks.itemId, itemId2), eq35(planTasks.phaseIdx, fromIdx))).orderBy(asc11(planTasks.idx));
13354
+ const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and15(eq34(planPhases.itemId, itemId2), eq34(planPhases.idx, fromIdx)));
13355
+ const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and15(eq34(planTasks.itemId, itemId2), eq34(planTasks.phaseIdx, fromIdx))).orderBy(asc10(planTasks.idx));
13447
13356
  await tx.delete(planTasks).where(
13448
- and16(eq35(planTasks.itemId, itemId2), eq35(planTasks.phaseIdx, fromIdx))
13357
+ and15(eq34(planTasks.itemId, itemId2), eq34(planTasks.phaseIdx, fromIdx))
13449
13358
  );
13450
- await tx.delete(planPhases).where(and16(eq35(planPhases.itemId, itemId2), eq35(planPhases.idx, fromIdx)));
13359
+ await tx.delete(planPhases).where(and15(eq34(planPhases.itemId, itemId2), eq34(planPhases.idx, fromIdx)));
13451
13360
  await reindexPhases(tx, itemId2);
13452
13361
  await shiftPhasesUp(tx, itemId2, toIdx);
13453
13362
  await tx.insert(planPhases).values({
@@ -13488,7 +13397,7 @@ async function movePhase(id, from, to) {
13488
13397
  if (!found) return;
13489
13398
  const { orm, item } = found;
13490
13399
  const itemId2 = item.id;
13491
- const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(eq36(planPhases.itemId, itemId2));
13400
+ const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(eq35(planPhases.itemId, itemId2));
13492
13401
  const phaseCount = row?.cnt ?? 0;
13493
13402
  const fromIdx = toIndex2(from, phaseCount);
13494
13403
  if (fromIdx === void 0) return;
@@ -13504,22 +13413,22 @@ async function movePhase(id, from, to) {
13504
13413
  import chalk106 from "chalk";
13505
13414
 
13506
13415
  // src/commands/backlog/applyPhaseUpdate.ts
13507
- import { and as and17, eq as eq37 } from "drizzle-orm";
13416
+ import { and as and16, eq as eq36 } from "drizzle-orm";
13508
13417
  async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
13509
13418
  await orm.transaction(async (tx) => {
13510
13419
  if (fields.name) {
13511
13420
  await tx.update(planPhases).set({ name: fields.name }).where(
13512
- and17(eq37(planPhases.itemId, itemId2), eq37(planPhases.idx, phaseIdx))
13421
+ and16(eq36(planPhases.itemId, itemId2), eq36(planPhases.idx, phaseIdx))
13513
13422
  );
13514
13423
  }
13515
13424
  if (fields.manualCheck) {
13516
13425
  await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
13517
- and17(eq37(planPhases.itemId, itemId2), eq37(planPhases.idx, phaseIdx))
13426
+ and16(eq36(planPhases.itemId, itemId2), eq36(planPhases.idx, phaseIdx))
13518
13427
  );
13519
13428
  }
13520
13429
  if (fields.task) {
13521
13430
  await tx.delete(planTasks).where(
13522
- and17(eq37(planTasks.itemId, itemId2), eq37(planTasks.phaseIdx, phaseIdx))
13431
+ and16(eq36(planTasks.itemId, itemId2), eq36(planTasks.phaseIdx, phaseIdx))
13523
13432
  );
13524
13433
  if (fields.task.length) {
13525
13434
  await tx.insert(planTasks).values(
@@ -13537,14 +13446,14 @@ async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
13537
13446
 
13538
13447
  // src/commands/backlog/findPhase.ts
13539
13448
  import chalk105 from "chalk";
13540
- import { and as and18, count as count7, eq as eq38 } from "drizzle-orm";
13449
+ import { and as and17, count as count7, eq as eq37 } from "drizzle-orm";
13541
13450
  async function findPhase(id, phase) {
13542
13451
  const found = await findOneItem(id);
13543
13452
  if (!found) return void 0;
13544
13453
  const { orm, item } = found;
13545
13454
  const itemId2 = item.id;
13546
13455
  const phaseIdx = Number.parseInt(phase, 10) - 1;
13547
- const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(and18(eq38(planPhases.itemId, itemId2), eq38(planPhases.idx, phaseIdx)));
13456
+ const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(and17(eq37(planPhases.itemId, itemId2), eq37(planPhases.idx, phaseIdx)));
13548
13457
  if (!row || row.cnt === 0) {
13549
13458
  console.log(
13550
13459
  chalk105.red(
@@ -13717,16 +13626,16 @@ function registerUpdatePhaseCommand(cmd) {
13717
13626
 
13718
13627
  // src/commands/backlog/removePhase.ts
13719
13628
  import chalk107 from "chalk";
13720
- import { and as and19, eq as eq39 } from "drizzle-orm";
13629
+ import { and as and18, eq as eq38 } from "drizzle-orm";
13721
13630
  async function removePhase(id, phase) {
13722
13631
  const found = await findPhase(id, phase);
13723
13632
  if (!found) return;
13724
13633
  const { item, orm, itemId: itemId2, phaseIdx } = found;
13725
13634
  await orm.transaction(async (tx) => {
13726
13635
  await tx.delete(planTasks).where(
13727
- and19(eq39(planTasks.itemId, itemId2), eq39(planTasks.phaseIdx, phaseIdx))
13636
+ and18(eq38(planTasks.itemId, itemId2), eq38(planTasks.phaseIdx, phaseIdx))
13728
13637
  );
13729
- await tx.delete(planPhases).where(and19(eq39(planPhases.itemId, itemId2), eq39(planPhases.idx, phaseIdx)));
13638
+ await tx.delete(planPhases).where(and18(eq38(planPhases.itemId, itemId2), eq38(planPhases.idx, phaseIdx)));
13730
13639
  await reindexPhases(tx, itemId2);
13731
13640
  await adjustCurrentPhase(tx, item, phaseIdx);
13732
13641
  });
@@ -13739,7 +13648,7 @@ async function removePhase(id, phase) {
13739
13648
 
13740
13649
  // src/commands/backlog/update/update.ts
13741
13650
  import chalk111 from "chalk";
13742
- import { eq as eq40 } from "drizzle-orm";
13651
+ import { eq as eq39 } from "drizzle-orm";
13743
13652
 
13744
13653
  // src/commands/backlog/update/buildUpdateValues.ts
13745
13654
  import chalk108 from "chalk";
@@ -13850,7 +13759,7 @@ async function update(id, options2) {
13850
13759
  if (!built) return;
13851
13760
  const { orm } = found;
13852
13761
  const itemId2 = found.item.id;
13853
- await orm.update(items).set(built.set).where(eq40(items.id, itemId2));
13762
+ await orm.update(items).set(built.set).where(eq39(items.id, itemId2));
13854
13763
  console.log(
13855
13764
  chalk111.green(`Updated ${built.fields} on item ${formatItemId(itemId2)}.`)
13856
13765
  );
@@ -13871,7 +13780,7 @@ function readPlanUpdate(source) {
13871
13780
  }
13872
13781
 
13873
13782
  // src/commands/backlog/updatePlan/replacePlan.ts
13874
- import { eq as eq41 } from "drizzle-orm";
13783
+ import { eq as eq40 } from "drizzle-orm";
13875
13784
 
13876
13785
  // src/commands/backlog/updatePlan/clampCurrentPhase.ts
13877
13786
  function clampCurrentPhase(currentPhase, phaseCount) {
@@ -13882,8 +13791,8 @@ function clampCurrentPhase(currentPhase, phaseCount) {
13882
13791
  // src/commands/backlog/updatePlan/replacePlan.ts
13883
13792
  async function replacePlan(orm, itemId2, phases, currentPhase) {
13884
13793
  await orm.transaction(async (tx) => {
13885
- await tx.delete(planTasks).where(eq41(planTasks.itemId, itemId2));
13886
- await tx.delete(planPhases).where(eq41(planPhases.itemId, itemId2));
13794
+ await tx.delete(planTasks).where(eq40(planTasks.itemId, itemId2));
13795
+ await tx.delete(planPhases).where(eq40(planPhases.itemId, itemId2));
13887
13796
  if (phases.length > 0) {
13888
13797
  await tx.insert(planPhases).values(
13889
13798
  phases.map((phase, idx) => ({
@@ -13901,7 +13810,7 @@ async function replacePlan(orm, itemId2, phases, currentPhase) {
13901
13810
  if (currentPhase === void 0) return;
13902
13811
  const clamped = clampCurrentPhase(currentPhase, phases.length);
13903
13812
  if (clamped === currentPhase) return;
13904
- await tx.update(items).set({ currentPhase: clamped }).where(eq41(items.id, itemId2));
13813
+ await tx.update(items).set({ currentPhase: clamped }).where(eq40(items.id, itemId2));
13905
13814
  });
13906
13815
  }
13907
13816
 
@@ -18184,9 +18093,9 @@ function registerGithub(program2) {
18184
18093
  }
18185
18094
 
18186
18095
  // src/commands/handover/countPendingHandovers.ts
18187
- import { and as and20, eq as eq42, isNull, sql as sql18 } from "drizzle-orm";
18096
+ import { and as and19, eq as eq41, isNull, sql as sql18 } from "drizzle-orm";
18188
18097
  async function countPendingHandovers(orm, origin) {
18189
- const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(and20(eq42(handovers.origin, origin), isNull(handovers.recalledAt)));
18098
+ const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(and19(eq41(handovers.origin, origin), isNull(handovers.recalledAt)));
18190
18099
  return row?.count ?? 0;
18191
18100
  }
18192
18101
 
@@ -18326,13 +18235,13 @@ async function load2(options2 = {}) {
18326
18235
  }
18327
18236
 
18328
18237
  // src/commands/handover/listPendingHandovers.ts
18329
- import { and as and21, desc as desc4, eq as eq43, isNull as isNull2 } from "drizzle-orm";
18238
+ import { and as and20, desc as desc4, eq as eq42, isNull as isNull2 } from "drizzle-orm";
18330
18239
  async function listPendingHandovers(orm, origin) {
18331
18240
  return orm.select({
18332
18241
  id: handovers.id,
18333
18242
  summary: handovers.summary,
18334
18243
  createdAt: handovers.createdAt
18335
- }).from(handovers).where(and21(eq43(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
18244
+ }).from(handovers).where(and20(eq42(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
18336
18245
  }
18337
18246
 
18338
18247
  // src/commands/handover/printPendingHandovers.ts
@@ -18345,17 +18254,17 @@ async function printPendingHandovers() {
18345
18254
  }
18346
18255
 
18347
18256
  // src/commands/handover/recallHandover.ts
18348
- import { and as and22, desc as desc5, eq as eq44, isNull as isNull3 } from "drizzle-orm";
18257
+ import { and as and21, desc as desc5, eq as eq43, isNull as isNull3 } from "drizzle-orm";
18349
18258
  async function recallHandover(orm, origin, id) {
18350
18259
  const [row] = await orm.select().from(handovers).where(
18351
- and22(
18352
- eq44(handovers.origin, origin),
18260
+ and21(
18261
+ eq43(handovers.origin, origin),
18353
18262
  isNull3(handovers.recalledAt),
18354
- ...id === void 0 ? [] : [eq44(handovers.id, id)]
18263
+ ...id === void 0 ? [] : [eq43(handovers.id, id)]
18355
18264
  )
18356
18265
  ).orderBy(desc5(handovers.createdAt), desc5(handovers.id)).limit(1);
18357
18266
  if (!row) return void 0;
18358
- await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq44(handovers.id, row.id));
18267
+ await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq43(handovers.id, row.id));
18359
18268
  return row.content;
18360
18269
  }
18361
18270
 
@@ -20373,20 +20282,20 @@ function resolveThread(threadId) {
20373
20282
  }
20374
20283
  }
20375
20284
  function requireCache(prNumber) {
20376
- const cache5 = loadCommentsCache(prNumber);
20377
- if (!cache5) {
20285
+ const cache4 = loadCommentsCache(prNumber);
20286
+ if (!cache4) {
20378
20287
  console.error(
20379
20288
  `Error: No cached comments found for PR #${prNumber}. Run "assist prs list-comments" first.`
20380
20289
  );
20381
20290
  process.exit(1);
20382
20291
  }
20383
- return cache5;
20292
+ return cache4;
20384
20293
  }
20385
20294
  function findLineComment(comments3, commentId) {
20386
20295
  return comments3.find((c) => c.type === "line" && c.id === commentId);
20387
20296
  }
20388
- function requireLineComment(cache5, commentId) {
20389
- const comment3 = findLineComment(cache5.comments, commentId);
20297
+ function requireLineComment(cache4, commentId) {
20298
+ const comment3 = findLineComment(cache4.comments, commentId);
20390
20299
  if (!comment3 || comment3.type !== "line" || !comment3.threadId) {
20391
20300
  console.error(
20392
20301
  `Error: Comment #${commentId} not found or has no thread ID.`
@@ -20395,8 +20304,8 @@ function requireLineComment(cache5, commentId) {
20395
20304
  }
20396
20305
  return comment3;
20397
20306
  }
20398
- function cleanupCacheIfDone(cache5, prNumber, commentId) {
20399
- const hasRemaining = cache5.comments.some(
20307
+ function cleanupCacheIfDone(cache4, prNumber, commentId) {
20308
+ const hasRemaining = cache4.comments.some(
20400
20309
  (c) => c.type === "line" && c.id !== commentId
20401
20310
  );
20402
20311
  if (!hasRemaining) deleteCommentsCache(prNumber);
@@ -20404,13 +20313,13 @@ function cleanupCacheIfDone(cache5, prNumber, commentId) {
20404
20313
  function resolveCommentWithReply(commentId, message2) {
20405
20314
  const prNumber = getCurrentPrNumber();
20406
20315
  const { org, repo } = getRepoInfo();
20407
- const cache5 = requireCache(prNumber);
20408
- const comment3 = requireLineComment(cache5, commentId);
20316
+ const cache4 = requireCache(prNumber);
20317
+ const comment3 = requireLineComment(cache4, commentId);
20409
20318
  replyToComment(org, repo, prNumber, commentId, message2);
20410
20319
  console.log("Reply posted successfully.");
20411
20320
  resolveThread(comment3.threadId);
20412
20321
  console.log("Thread resolved successfully.");
20413
- cleanupCacheIfDone(cache5, prNumber, commentId);
20322
+ cleanupCacheIfDone(cache4, prNumber, commentId);
20414
20323
  }
20415
20324
 
20416
20325
  // src/commands/prs/fixed.ts
@@ -28732,10 +28641,10 @@ function applyReviewPause(session, activity2) {
28732
28641
  }
28733
28642
 
28734
28643
  // src/shared/db/getPhaseActiveMs.ts
28735
- import { and as and23, eq as eq45 } from "drizzle-orm";
28644
+ import { and as and22, eq as eq44 } from "drizzle-orm";
28736
28645
  async function getPhaseActiveMs(db, itemId2, phaseIdx) {
28737
28646
  const [row] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
28738
- and23(eq45(phaseUsage.itemId, itemId2), eq45(phaseUsage.phaseIdx, phaseIdx))
28647
+ and22(eq44(phaseUsage.itemId, itemId2), eq44(phaseUsage.phaseIdx, phaseIdx))
28739
28648
  );
28740
28649
  return row?.activeMs ?? 0;
28741
28650
  }
@@ -29281,17 +29190,17 @@ async function recordPhaseTranscriptUsage(db, itemId2, phaseIdx, responses) {
29281
29190
  }
29282
29191
 
29283
29192
  // src/shared/db/recordWindowTokens.ts
29284
- import { and as and24, eq as eq46, sql as sql24 } from "drizzle-orm";
29193
+ import { and as and23, eq as eq45, sql as sql24 } from "drizzle-orm";
29285
29194
  async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
29286
29195
  if (tokensUp <= 0 && tokensDown <= 0) return;
29287
29196
  await db.update(usagePeaks).set({
29288
29197
  tokensUp: sql24`${usagePeaks.tokensUp} + ${tokensUp}`,
29289
29198
  tokensDown: sql24`${usagePeaks.tokensDown} + ${tokensDown}`
29290
29199
  }).where(
29291
- and24(
29292
- eq46(usagePeaks.window, window),
29293
- eq46(usagePeaks.resetsAt, resetsAt),
29294
- eq46(usagePeaks.segment, 0)
29200
+ and23(
29201
+ eq45(usagePeaks.window, window),
29202
+ eq45(usagePeaks.resetsAt, resetsAt),
29203
+ eq45(usagePeaks.segment, 0)
29295
29204
  )
29296
29205
  );
29297
29206
  }