@staff0rd/assist 0.457.0 → 0.458.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/commands/sessions/web/bundle.js +386 -386
- package/dist/index.js +151 -136
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.458.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -950,7 +950,7 @@ import { sql } from "drizzle-orm";
|
|
|
950
950
|
|
|
951
951
|
// src/shared/db/applyReading.ts
|
|
952
952
|
import { and, eq, gt } from "drizzle-orm";
|
|
953
|
-
var RESET_DROP_THRESHOLD =
|
|
953
|
+
var RESET_DROP_THRESHOLD = 3;
|
|
954
954
|
var at = ({ window, resetsAt }, segment) => segment === void 0 ? and(eq(usagePeaks.window, window), eq(usagePeaks.resetsAt, resetsAt)) : and(
|
|
955
955
|
eq(usagePeaks.window, window),
|
|
956
956
|
eq(usagePeaks.resetsAt, resetsAt),
|
|
@@ -4835,13 +4835,13 @@ async function activity(options2) {
|
|
|
4835
4835
|
const activeDays = data.filter((d) => d.count > 0).length;
|
|
4836
4836
|
console.log(`${total} commits across ${activeDays} active days.`);
|
|
4837
4837
|
const weekly = /* @__PURE__ */ new Map();
|
|
4838
|
-
for (const { date, count:
|
|
4838
|
+
for (const { date, count: count8 } of data) {
|
|
4839
4839
|
const d = new Date(date);
|
|
4840
4840
|
d.setDate(d.getDate() - d.getDay());
|
|
4841
4841
|
const weekStart = d.toISOString().slice(0, 10);
|
|
4842
|
-
weekly.set(weekStart, (weekly.get(weekStart) ?? 0) +
|
|
4842
|
+
weekly.set(weekStart, (weekly.get(weekStart) ?? 0) + count8);
|
|
4843
4843
|
}
|
|
4844
|
-
const weeklyData = [...weekly.entries()].map(([date,
|
|
4844
|
+
const weeklyData = [...weekly.entries()].map(([date, count8]) => ({ date, count: count8 })).sort((a, b) => a.date.localeCompare(b.date));
|
|
4845
4845
|
const until = data[data.length - 1].date;
|
|
4846
4846
|
activityChart(weeklyData, { since, until });
|
|
4847
4847
|
}
|
|
@@ -9735,17 +9735,32 @@ async function listNewsItems(_req, res) {
|
|
|
9735
9735
|
respondJson(res, 200, cachedItems);
|
|
9736
9736
|
}
|
|
9737
9737
|
|
|
9738
|
+
// src/shared/db/countUsagePeaks.ts
|
|
9739
|
+
import { count, eq as eq18 } from "drizzle-orm";
|
|
9740
|
+
async function countUsagePeaks(db, window) {
|
|
9741
|
+
const [row] = await db.select({ value: count() }).from(usagePeaks).where(window ? eq18(usagePeaks.window, window) : void 0);
|
|
9742
|
+
return row?.value ?? 0;
|
|
9743
|
+
}
|
|
9744
|
+
|
|
9738
9745
|
// src/shared/db/listUsagePeaks.ts
|
|
9739
|
-
import { and as and8,
|
|
9740
|
-
|
|
9741
|
-
|
|
9746
|
+
import { and as and8, desc as desc2, eq as eq19, getTableColumns } from "drizzle-orm";
|
|
9747
|
+
|
|
9748
|
+
// src/shared/db/avgContextPerCycle.ts
|
|
9749
|
+
import { count as count2, sql as sql16 } from "drizzle-orm";
|
|
9750
|
+
function avgContextPerCycle(db) {
|
|
9751
|
+
return db.select({
|
|
9742
9752
|
window: phaseCycleContext.window,
|
|
9743
9753
|
resetsAt: phaseCycleContext.resetsAt,
|
|
9744
9754
|
avgContextPct: sql16`cast(avg(${phaseCycleContext.peakContextPct}) as double precision)`.as(
|
|
9745
9755
|
"avg_context_pct"
|
|
9746
9756
|
),
|
|
9747
|
-
phaseCount:
|
|
9757
|
+
phaseCount: count2().as("phase_count")
|
|
9748
9758
|
}).from(phaseCycleContext).groupBy(phaseCycleContext.window, phaseCycleContext.resetsAt).as("avg_context");
|
|
9759
|
+
}
|
|
9760
|
+
|
|
9761
|
+
// src/shared/db/listUsagePeaks.ts
|
|
9762
|
+
async function listUsagePeaks(db, options2) {
|
|
9763
|
+
const avgContext = avgContextPerCycle(db);
|
|
9749
9764
|
const query = db.select({
|
|
9750
9765
|
...getTableColumns(usagePeaks),
|
|
9751
9766
|
avgContextPct: avgContext.avgContextPct,
|
|
@@ -9753,35 +9768,35 @@ async function listUsagePeaks(db, paging) {
|
|
|
9753
9768
|
}).from(usagePeaks).leftJoin(
|
|
9754
9769
|
avgContext,
|
|
9755
9770
|
and8(
|
|
9756
|
-
|
|
9757
|
-
|
|
9771
|
+
eq19(usagePeaks.window, avgContext.window),
|
|
9772
|
+
eq19(usagePeaks.resetsAt, avgContext.resetsAt)
|
|
9758
9773
|
)
|
|
9759
|
-
).orderBy(
|
|
9774
|
+
).where(options2?.window ? eq19(usagePeaks.window, options2.window) : void 0).orderBy(
|
|
9760
9775
|
desc2(usagePeaks.resetsAt),
|
|
9761
9776
|
usagePeaks.window,
|
|
9762
9777
|
desc2(usagePeaks.createdAt),
|
|
9763
9778
|
desc2(usagePeaks.segment)
|
|
9764
9779
|
);
|
|
9765
|
-
if (
|
|
9766
|
-
return query.limit(
|
|
9780
|
+
if (options2?.limit !== void 0) {
|
|
9781
|
+
return query.limit(options2.limit).offset(options2.offset ?? 0);
|
|
9767
9782
|
}
|
|
9768
9783
|
return query;
|
|
9769
9784
|
}
|
|
9770
|
-
async function countUsagePeaks(db) {
|
|
9771
|
-
const [row] = await db.select({ value: count() }).from(usagePeaks);
|
|
9772
|
-
return row?.value ?? 0;
|
|
9773
|
-
}
|
|
9774
9785
|
|
|
9775
9786
|
// src/commands/sessions/web/listUsageHistory.ts
|
|
9776
9787
|
var DEFAULT_PAGE_SIZE = 30;
|
|
9788
|
+
function parseWindow(value) {
|
|
9789
|
+
return value === "five_hour" || value === "seven_day" ? value : void 0;
|
|
9790
|
+
}
|
|
9777
9791
|
async function listUsageHistory(req, res) {
|
|
9778
9792
|
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
9779
9793
|
const page = Math.max(0, Number(params.get("page")) || 0);
|
|
9780
9794
|
const pageSize = Number(params.get("pageSize")) || DEFAULT_PAGE_SIZE;
|
|
9795
|
+
const window = parseWindow(params.get("window"));
|
|
9781
9796
|
const db = await getDb();
|
|
9782
9797
|
const [rows, total] = await Promise.all([
|
|
9783
|
-
listUsagePeaks(db, { limit: pageSize, offset: page * pageSize }),
|
|
9784
|
-
countUsagePeaks(db)
|
|
9798
|
+
listUsagePeaks(db, { limit: pageSize, offset: page * pageSize, window }),
|
|
9799
|
+
countUsagePeaks(db, window)
|
|
9785
9800
|
]);
|
|
9786
9801
|
respondJson(res, 200, { rows, total });
|
|
9787
9802
|
}
|
|
@@ -10884,11 +10899,11 @@ function registerActivityCommands(cmd) {
|
|
|
10884
10899
|
|
|
10885
10900
|
// src/commands/backlog/associate-github/index.ts
|
|
10886
10901
|
import chalk64 from "chalk";
|
|
10887
|
-
import { eq as
|
|
10902
|
+
import { eq as eq21 } from "drizzle-orm";
|
|
10888
10903
|
|
|
10889
10904
|
// src/commands/backlog/beginAssociation.ts
|
|
10890
10905
|
import chalk63 from "chalk";
|
|
10891
|
-
import { eq as
|
|
10906
|
+
import { eq as eq20 } from "drizzle-orm";
|
|
10892
10907
|
async function beginAssociation(id, options2, clearPatch, label2) {
|
|
10893
10908
|
const found = await findOneItem(id);
|
|
10894
10909
|
if (!found) {
|
|
@@ -10898,7 +10913,7 @@ async function beginAssociation(id, options2, clearPatch, label2) {
|
|
|
10898
10913
|
const { orm } = found;
|
|
10899
10914
|
const itemId2 = found.item.id;
|
|
10900
10915
|
if (options2.clear) {
|
|
10901
|
-
await orm.update(items).set(clearPatch).where(
|
|
10916
|
+
await orm.update(items).set(clearPatch).where(eq20(items.id, itemId2));
|
|
10902
10917
|
console.log(
|
|
10903
10918
|
chalk63.green(
|
|
10904
10919
|
`Cleared ${label2} association on item ${formatItemId(itemId2)}.`
|
|
@@ -10966,7 +10981,7 @@ async function associateGithub(id, issue, options2) {
|
|
|
10966
10981
|
return;
|
|
10967
10982
|
}
|
|
10968
10983
|
const title = fetchGithubIssueTitle(normalized);
|
|
10969
|
-
await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(
|
|
10984
|
+
await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(eq21(items.id, itemId2));
|
|
10970
10985
|
console.log(
|
|
10971
10986
|
chalk64.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
|
|
10972
10987
|
title ? chalk64.dim(`(${title})`) : ""
|
|
@@ -10980,7 +10995,7 @@ function registerAssociateGithubCommand(cmd) {
|
|
|
10980
10995
|
|
|
10981
10996
|
// src/commands/backlog/associate-jira/index.ts
|
|
10982
10997
|
import chalk66 from "chalk";
|
|
10983
|
-
import { eq as
|
|
10998
|
+
import { eq as eq22 } from "drizzle-orm";
|
|
10984
10999
|
|
|
10985
11000
|
// src/commands/jira/fetchIssue.ts
|
|
10986
11001
|
import { execSync as execSync33 } from "child_process";
|
|
@@ -11045,7 +11060,7 @@ async function associateJira(id, key, options2) {
|
|
|
11045
11060
|
const parsed = fetchIssue(normalized, "summary");
|
|
11046
11061
|
const fields = parsed?.fields;
|
|
11047
11062
|
const summary = fields?.summary;
|
|
11048
|
-
await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(
|
|
11063
|
+
await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq22(items.id, itemId2));
|
|
11049
11064
|
console.log(
|
|
11050
11065
|
chalk66.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
|
|
11051
11066
|
summary ? chalk66.dim(`(${summary})`) : ""
|
|
@@ -11423,15 +11438,15 @@ function isClaudeCode() {
|
|
|
11423
11438
|
}
|
|
11424
11439
|
|
|
11425
11440
|
// src/commands/backlog/insertPhaseAt.ts
|
|
11426
|
-
import { eq as
|
|
11441
|
+
import { eq as eq24 } from "drizzle-orm";
|
|
11427
11442
|
|
|
11428
11443
|
// src/commands/backlog/shiftPhasesUp.ts
|
|
11429
|
-
import { and as and9, desc as desc3, eq as
|
|
11444
|
+
import { and as and9, desc as desc3, eq as eq23, gte } from "drizzle-orm";
|
|
11430
11445
|
async function shiftPhasesUp(db, itemId2, fromIdx) {
|
|
11431
|
-
const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(and9(
|
|
11446
|
+
const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(and9(eq23(planPhases.itemId, itemId2), gte(planPhases.idx, fromIdx))).orderBy(desc3(planPhases.idx));
|
|
11432
11447
|
for (const p of toShift) {
|
|
11433
|
-
await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(and9(
|
|
11434
|
-
await db.update(planPhases).set({ idx: p.idx + 1 }).where(and9(
|
|
11448
|
+
await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(and9(eq23(planTasks.itemId, itemId2), eq23(planTasks.phaseIdx, p.idx)));
|
|
11449
|
+
await db.update(planPhases).set({ idx: p.idx + 1 }).where(and9(eq23(planPhases.itemId, itemId2), eq23(planPhases.idx, p.idx)));
|
|
11435
11450
|
}
|
|
11436
11451
|
}
|
|
11437
11452
|
|
|
@@ -11444,7 +11459,7 @@ async function insertPhaseAt(orm, itemId2, phaseIdx, name, tasks, manualChecks,
|
|
|
11444
11459
|
await tx.insert(planTasks).values(tasks.map((task, i) => ({ itemId: itemId2, phaseIdx, idx: i, task })));
|
|
11445
11460
|
}
|
|
11446
11461
|
if (currentPhase !== void 0 && currentPhase - 1 >= phaseIdx) {
|
|
11447
|
-
await tx.update(items).set({ currentPhase: phaseIdx + 1 }).where(
|
|
11462
|
+
await tx.update(items).set({ currentPhase: phaseIdx + 1 }).where(eq24(items.id, itemId2));
|
|
11448
11463
|
}
|
|
11449
11464
|
});
|
|
11450
11465
|
}
|
|
@@ -11616,9 +11631,9 @@ import chalk76 from "chalk";
|
|
|
11616
11631
|
|
|
11617
11632
|
// src/commands/backlog/resolveInsertPosition.ts
|
|
11618
11633
|
import chalk75 from "chalk";
|
|
11619
|
-
import { count as
|
|
11634
|
+
import { count as count3, eq as eq25 } from "drizzle-orm";
|
|
11620
11635
|
async function resolveInsertPosition(orm, itemId2, position) {
|
|
11621
|
-
const [row] = await orm.select({ cnt:
|
|
11636
|
+
const [row] = await orm.select({ cnt: count3() }).from(planPhases).where(eq25(planPhases.itemId, itemId2));
|
|
11622
11637
|
const phaseCount = row?.cnt ?? 0;
|
|
11623
11638
|
if (position === void 0) return phaseCount;
|
|
11624
11639
|
const pos = Number.parseInt(position, 10);
|
|
@@ -11974,9 +11989,9 @@ function hasCycle(adjacency, fromId, toId) {
|
|
|
11974
11989
|
}
|
|
11975
11990
|
|
|
11976
11991
|
// src/commands/backlog/loadDependencyGraph.ts
|
|
11977
|
-
import { eq as
|
|
11992
|
+
import { eq as eq26 } from "drizzle-orm";
|
|
11978
11993
|
async function loadDependencyGraph(orm) {
|
|
11979
|
-
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(
|
|
11994
|
+
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq26(links.type, "depends-on"));
|
|
11980
11995
|
const graph = /* @__PURE__ */ new Map();
|
|
11981
11996
|
for (const { itemId: itemId2, targetId } of rows) {
|
|
11982
11997
|
const bucket = graph.get(itemId2);
|
|
@@ -12043,7 +12058,7 @@ async function link(fromId, toId, opts) {
|
|
|
12043
12058
|
|
|
12044
12059
|
// src/commands/backlog/unlink.ts
|
|
12045
12060
|
import chalk82 from "chalk";
|
|
12046
|
-
import { and as and10, eq as
|
|
12061
|
+
import { and as and10, eq as eq27 } from "drizzle-orm";
|
|
12047
12062
|
async function unlink(fromId, toId) {
|
|
12048
12063
|
const fromNum = parseItemId(fromId);
|
|
12049
12064
|
const toNum = parseItemId(toId);
|
|
@@ -12067,7 +12082,7 @@ async function unlink(fromId, toId) {
|
|
|
12067
12082
|
);
|
|
12068
12083
|
return;
|
|
12069
12084
|
}
|
|
12070
|
-
await orm.delete(links).where(and10(
|
|
12085
|
+
await orm.delete(links).where(and10(eq27(links.itemId, fromNum), eq27(links.targetId, toNum)));
|
|
12071
12086
|
console.log(
|
|
12072
12087
|
chalk82.green(
|
|
12073
12088
|
`Removed link from ${formatItemId(fromNum)} to ${formatItemId(toNum)}.`
|
|
@@ -12087,7 +12102,7 @@ function registerLinkCommands(cmd) {
|
|
|
12087
12102
|
|
|
12088
12103
|
// src/commands/backlog/move-repo/index.ts
|
|
12089
12104
|
import chalk84 from "chalk";
|
|
12090
|
-
import { eq as
|
|
12105
|
+
import { eq as eq29 } from "drizzle-orm";
|
|
12091
12106
|
|
|
12092
12107
|
// src/commands/backlog/move-repo/confirmMove.ts
|
|
12093
12108
|
import chalk83 from "chalk";
|
|
@@ -12102,9 +12117,9 @@ async function confirmMove(cnt, oldOrigin, newOrigin) {
|
|
|
12102
12117
|
}
|
|
12103
12118
|
|
|
12104
12119
|
// src/commands/backlog/move-repo/countByOrigin.ts
|
|
12105
|
-
import { count as
|
|
12120
|
+
import { count as count4, eq as eq28 } from "drizzle-orm";
|
|
12106
12121
|
async function countByOrigin(orm, origin) {
|
|
12107
|
-
const [{ cnt }] = await orm.select({ cnt:
|
|
12122
|
+
const [{ cnt }] = await orm.select({ cnt: count4() }).from(items).where(eq28(items.origin, origin));
|
|
12108
12123
|
return cnt;
|
|
12109
12124
|
}
|
|
12110
12125
|
|
|
@@ -12147,7 +12162,7 @@ async function moveRepo(oldOriginRaw, newOriginRaw, options2 = {}) {
|
|
|
12147
12162
|
console.log(chalk84.yellow("Move cancelled; no changes made."));
|
|
12148
12163
|
return;
|
|
12149
12164
|
}
|
|
12150
|
-
await orm.update(items).set({ origin: newOrigin }).where(
|
|
12165
|
+
await orm.update(items).set({ origin: newOrigin }).where(eq29(items.origin, oldOrigin));
|
|
12151
12166
|
console.log(
|
|
12152
12167
|
chalk84.green(
|
|
12153
12168
|
`Moved ${pluralItems(cnt)} from "${oldOrigin}" to "${newOrigin}".`
|
|
@@ -12564,10 +12579,10 @@ async function start(id) {
|
|
|
12564
12579
|
|
|
12565
12580
|
// src/commands/backlog/stop/index.ts
|
|
12566
12581
|
import chalk96 from "chalk";
|
|
12567
|
-
import { and as and11, eq as
|
|
12582
|
+
import { and as and11, eq as eq30 } from "drizzle-orm";
|
|
12568
12583
|
async function stop() {
|
|
12569
12584
|
const { orm } = await getReady();
|
|
12570
|
-
const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and11(
|
|
12585
|
+
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 });
|
|
12571
12586
|
if (stopped.length === 0) {
|
|
12572
12587
|
console.log(chalk96.yellow("No in-progress items to stop."));
|
|
12573
12588
|
return;
|
|
@@ -12684,13 +12699,13 @@ async function findSubtask(id, index3) {
|
|
|
12684
12699
|
}
|
|
12685
12700
|
|
|
12686
12701
|
// src/commands/backlog/updateSubtask.ts
|
|
12687
|
-
import { and as and12, eq as
|
|
12702
|
+
import { and as and12, eq as eq31 } from "drizzle-orm";
|
|
12688
12703
|
async function updateSubtask(orm, itemId2, idx, fields) {
|
|
12689
12704
|
const set = {};
|
|
12690
12705
|
if (fields.title !== void 0) set.title = fields.title;
|
|
12691
12706
|
if (fields.description !== void 0) set.description = fields.description;
|
|
12692
12707
|
if (fields.status !== void 0) set.status = fields.status;
|
|
12693
|
-
const [row] = await orm.update(itemSubtasks).set(set).where(and12(
|
|
12708
|
+
const [row] = await orm.update(itemSubtasks).set(set).where(and12(eq31(itemSubtasks.itemId, itemId2), eq31(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
12694
12709
|
return row?.title;
|
|
12695
12710
|
}
|
|
12696
12711
|
|
|
@@ -12745,16 +12760,16 @@ async function editSubtask(id, index3, options2) {
|
|
|
12745
12760
|
import chalk102 from "chalk";
|
|
12746
12761
|
|
|
12747
12762
|
// src/commands/backlog/deleteSubtask.ts
|
|
12748
|
-
import { and as and13, asc as asc8, eq as
|
|
12763
|
+
import { and as and13, asc as asc8, eq as eq32 } from "drizzle-orm";
|
|
12749
12764
|
async function deleteSubtask(orm, itemId2, idx) {
|
|
12750
|
-
const [row] = await orm.delete(itemSubtasks).where(and13(
|
|
12765
|
+
const [row] = await orm.delete(itemSubtasks).where(and13(eq32(itemSubtasks.itemId, itemId2), eq32(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
12751
12766
|
if (!row) return void 0;
|
|
12752
|
-
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(
|
|
12767
|
+
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq32(itemSubtasks.itemId, itemId2)).orderBy(asc8(itemSubtasks.idx));
|
|
12753
12768
|
for (let i = 0; i < remaining.length; i++) {
|
|
12754
12769
|
const oldIdx = remaining[i].idx;
|
|
12755
12770
|
if (oldIdx === i) continue;
|
|
12756
12771
|
await orm.update(itemSubtasks).set({ idx: i }).where(
|
|
12757
|
-
and13(
|
|
12772
|
+
and13(eq32(itemSubtasks.itemId, itemId2), eq32(itemSubtasks.idx, oldIdx))
|
|
12758
12773
|
);
|
|
12759
12774
|
}
|
|
12760
12775
|
return row.title;
|
|
@@ -12823,20 +12838,20 @@ function registerSubtaskCommands(cmd) {
|
|
|
12823
12838
|
|
|
12824
12839
|
// src/commands/backlog/movePhase.ts
|
|
12825
12840
|
import chalk104 from "chalk";
|
|
12826
|
-
import { count as
|
|
12841
|
+
import { count as count6, eq as eq35 } from "drizzle-orm";
|
|
12827
12842
|
|
|
12828
12843
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
12829
|
-
import { and as and15, asc as asc10, eq as
|
|
12844
|
+
import { and as and15, asc as asc10, eq as eq34 } from "drizzle-orm";
|
|
12830
12845
|
|
|
12831
12846
|
// src/commands/backlog/reindexPhases.ts
|
|
12832
|
-
import { and as and14, asc as asc9, count as
|
|
12847
|
+
import { and as and14, asc as asc9, count as count5, eq as eq33 } from "drizzle-orm";
|
|
12833
12848
|
async function reindexPhases(db, itemId2) {
|
|
12834
|
-
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(
|
|
12849
|
+
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq33(planPhases.itemId, itemId2)).orderBy(asc9(planPhases.idx));
|
|
12835
12850
|
for (let i = 0; i < remaining.length; i++) {
|
|
12836
12851
|
const oldIdx = remaining[i].idx;
|
|
12837
12852
|
if (oldIdx === i) continue;
|
|
12838
|
-
await db.update(planTasks).set({ phaseIdx: i }).where(and14(
|
|
12839
|
-
await db.update(planPhases).set({ idx: i }).where(and14(
|
|
12853
|
+
await db.update(planTasks).set({ phaseIdx: i }).where(and14(eq33(planTasks.itemId, itemId2), eq33(planTasks.phaseIdx, oldIdx)));
|
|
12854
|
+
await db.update(planPhases).set({ idx: i }).where(and14(eq33(planPhases.itemId, itemId2), eq33(planPhases.idx, oldIdx)));
|
|
12840
12855
|
}
|
|
12841
12856
|
}
|
|
12842
12857
|
async function adjustCurrentPhase(db, item, removedIdx) {
|
|
@@ -12844,24 +12859,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
|
|
|
12844
12859
|
if (currentPhase === void 0) return;
|
|
12845
12860
|
const currentIdx = currentPhase - 1;
|
|
12846
12861
|
if (removedIdx < currentIdx) {
|
|
12847
|
-
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(
|
|
12862
|
+
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq33(items.id, item.id));
|
|
12848
12863
|
return;
|
|
12849
12864
|
}
|
|
12850
12865
|
if (removedIdx !== currentIdx) return;
|
|
12851
|
-
const [row] = await db.select({ cnt:
|
|
12866
|
+
const [row] = await db.select({ cnt: count5() }).from(planPhases).where(eq33(planPhases.itemId, item.id));
|
|
12852
12867
|
const cnt = row?.cnt ?? 0;
|
|
12853
|
-
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(
|
|
12868
|
+
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq33(items.id, item.id));
|
|
12854
12869
|
}
|
|
12855
12870
|
|
|
12856
12871
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
12857
12872
|
async function reorderPhaseRows(orm, itemId2, fromIdx, toIdx) {
|
|
12858
12873
|
await orm.transaction(async (tx) => {
|
|
12859
|
-
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and15(
|
|
12860
|
-
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and15(
|
|
12874
|
+
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and15(eq34(planPhases.itemId, itemId2), eq34(planPhases.idx, fromIdx)));
|
|
12875
|
+
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));
|
|
12861
12876
|
await tx.delete(planTasks).where(
|
|
12862
|
-
and15(
|
|
12877
|
+
and15(eq34(planTasks.itemId, itemId2), eq34(planTasks.phaseIdx, fromIdx))
|
|
12863
12878
|
);
|
|
12864
|
-
await tx.delete(planPhases).where(and15(
|
|
12879
|
+
await tx.delete(planPhases).where(and15(eq34(planPhases.itemId, itemId2), eq34(planPhases.idx, fromIdx)));
|
|
12865
12880
|
await reindexPhases(tx, itemId2);
|
|
12866
12881
|
await shiftPhasesUp(tx, itemId2, toIdx);
|
|
12867
12882
|
await tx.insert(planPhases).values({
|
|
@@ -12902,7 +12917,7 @@ async function movePhase(id, from, to) {
|
|
|
12902
12917
|
if (!found) return;
|
|
12903
12918
|
const { orm, item } = found;
|
|
12904
12919
|
const itemId2 = item.id;
|
|
12905
|
-
const [row] = await orm.select({ cnt:
|
|
12920
|
+
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(eq35(planPhases.itemId, itemId2));
|
|
12906
12921
|
const phaseCount = row?.cnt ?? 0;
|
|
12907
12922
|
const fromIdx = toIndex(from, phaseCount);
|
|
12908
12923
|
if (fromIdx === void 0) return;
|
|
@@ -12918,22 +12933,22 @@ async function movePhase(id, from, to) {
|
|
|
12918
12933
|
import chalk106 from "chalk";
|
|
12919
12934
|
|
|
12920
12935
|
// src/commands/backlog/applyPhaseUpdate.ts
|
|
12921
|
-
import { and as and16, eq as
|
|
12936
|
+
import { and as and16, eq as eq36 } from "drizzle-orm";
|
|
12922
12937
|
async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
|
|
12923
12938
|
await orm.transaction(async (tx) => {
|
|
12924
12939
|
if (fields.name) {
|
|
12925
12940
|
await tx.update(planPhases).set({ name: fields.name }).where(
|
|
12926
|
-
and16(
|
|
12941
|
+
and16(eq36(planPhases.itemId, itemId2), eq36(planPhases.idx, phaseIdx))
|
|
12927
12942
|
);
|
|
12928
12943
|
}
|
|
12929
12944
|
if (fields.manualCheck) {
|
|
12930
12945
|
await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
|
|
12931
|
-
and16(
|
|
12946
|
+
and16(eq36(planPhases.itemId, itemId2), eq36(planPhases.idx, phaseIdx))
|
|
12932
12947
|
);
|
|
12933
12948
|
}
|
|
12934
12949
|
if (fields.task) {
|
|
12935
12950
|
await tx.delete(planTasks).where(
|
|
12936
|
-
and16(
|
|
12951
|
+
and16(eq36(planTasks.itemId, itemId2), eq36(planTasks.phaseIdx, phaseIdx))
|
|
12937
12952
|
);
|
|
12938
12953
|
if (fields.task.length) {
|
|
12939
12954
|
await tx.insert(planTasks).values(
|
|
@@ -12951,14 +12966,14 @@ async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
|
|
|
12951
12966
|
|
|
12952
12967
|
// src/commands/backlog/findPhase.ts
|
|
12953
12968
|
import chalk105 from "chalk";
|
|
12954
|
-
import { and as and17, count as
|
|
12969
|
+
import { and as and17, count as count7, eq as eq37 } from "drizzle-orm";
|
|
12955
12970
|
async function findPhase(id, phase) {
|
|
12956
12971
|
const found = await findOneItem(id);
|
|
12957
12972
|
if (!found) return void 0;
|
|
12958
12973
|
const { orm, item } = found;
|
|
12959
12974
|
const itemId2 = item.id;
|
|
12960
12975
|
const phaseIdx = Number.parseInt(phase, 10) - 1;
|
|
12961
|
-
const [row] = await orm.select({ cnt:
|
|
12976
|
+
const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(and17(eq37(planPhases.itemId, itemId2), eq37(planPhases.idx, phaseIdx)));
|
|
12962
12977
|
if (!row || row.cnt === 0) {
|
|
12963
12978
|
console.log(
|
|
12964
12979
|
chalk105.red(
|
|
@@ -13131,16 +13146,16 @@ function registerUpdatePhaseCommand(cmd) {
|
|
|
13131
13146
|
|
|
13132
13147
|
// src/commands/backlog/removePhase.ts
|
|
13133
13148
|
import chalk107 from "chalk";
|
|
13134
|
-
import { and as and18, eq as
|
|
13149
|
+
import { and as and18, eq as eq38 } from "drizzle-orm";
|
|
13135
13150
|
async function removePhase(id, phase) {
|
|
13136
13151
|
const found = await findPhase(id, phase);
|
|
13137
13152
|
if (!found) return;
|
|
13138
13153
|
const { item, orm, itemId: itemId2, phaseIdx } = found;
|
|
13139
13154
|
await orm.transaction(async (tx) => {
|
|
13140
13155
|
await tx.delete(planTasks).where(
|
|
13141
|
-
and18(
|
|
13156
|
+
and18(eq38(planTasks.itemId, itemId2), eq38(planTasks.phaseIdx, phaseIdx))
|
|
13142
13157
|
);
|
|
13143
|
-
await tx.delete(planPhases).where(and18(
|
|
13158
|
+
await tx.delete(planPhases).where(and18(eq38(planPhases.itemId, itemId2), eq38(planPhases.idx, phaseIdx)));
|
|
13144
13159
|
await reindexPhases(tx, itemId2);
|
|
13145
13160
|
await adjustCurrentPhase(tx, item, phaseIdx);
|
|
13146
13161
|
});
|
|
@@ -13153,7 +13168,7 @@ async function removePhase(id, phase) {
|
|
|
13153
13168
|
|
|
13154
13169
|
// src/commands/backlog/update/update.ts
|
|
13155
13170
|
import chalk111 from "chalk";
|
|
13156
|
-
import { eq as
|
|
13171
|
+
import { eq as eq39 } from "drizzle-orm";
|
|
13157
13172
|
|
|
13158
13173
|
// src/commands/backlog/update/buildUpdateValues.ts
|
|
13159
13174
|
import chalk108 from "chalk";
|
|
@@ -13264,7 +13279,7 @@ async function update(id, options2) {
|
|
|
13264
13279
|
if (!built) return;
|
|
13265
13280
|
const { orm } = found;
|
|
13266
13281
|
const itemId2 = found.item.id;
|
|
13267
|
-
await orm.update(items).set(built.set).where(
|
|
13282
|
+
await orm.update(items).set(built.set).where(eq39(items.id, itemId2));
|
|
13268
13283
|
console.log(
|
|
13269
13284
|
chalk111.green(`Updated ${built.fields} on item ${formatItemId(itemId2)}.`)
|
|
13270
13285
|
);
|
|
@@ -14941,7 +14956,7 @@ function calculateHalstead(node) {
|
|
|
14941
14956
|
// src/commands/complexity/shared/countSloc.ts
|
|
14942
14957
|
function countSloc(content) {
|
|
14943
14958
|
let inMultiLineComment = false;
|
|
14944
|
-
let
|
|
14959
|
+
let count8 = 0;
|
|
14945
14960
|
for (const line of content.split("\n")) {
|
|
14946
14961
|
const trimmed = line.trim();
|
|
14947
14962
|
if (inMultiLineComment) {
|
|
@@ -14949,7 +14964,7 @@ function countSloc(content) {
|
|
|
14949
14964
|
inMultiLineComment = false;
|
|
14950
14965
|
const afterComment = trimmed.substring(trimmed.indexOf("*/") + 2);
|
|
14951
14966
|
if (afterComment.trim().length > 0) {
|
|
14952
|
-
|
|
14967
|
+
count8++;
|
|
14953
14968
|
}
|
|
14954
14969
|
}
|
|
14955
14970
|
continue;
|
|
@@ -14961,7 +14976,7 @@ function countSloc(content) {
|
|
|
14961
14976
|
if (trimmed.includes("*/")) {
|
|
14962
14977
|
const afterComment = trimmed.substring(trimmed.indexOf("*/") + 2);
|
|
14963
14978
|
if (afterComment.trim().length > 0) {
|
|
14964
|
-
|
|
14979
|
+
count8++;
|
|
14965
14980
|
}
|
|
14966
14981
|
} else {
|
|
14967
14982
|
inMultiLineComment = true;
|
|
@@ -14969,10 +14984,10 @@ function countSloc(content) {
|
|
|
14969
14984
|
continue;
|
|
14970
14985
|
}
|
|
14971
14986
|
if (trimmed.length > 0) {
|
|
14972
|
-
|
|
14987
|
+
count8++;
|
|
14973
14988
|
}
|
|
14974
14989
|
}
|
|
14975
|
-
return
|
|
14990
|
+
return count8;
|
|
14976
14991
|
}
|
|
14977
14992
|
|
|
14978
14993
|
// src/commands/complexity/shared/index.ts
|
|
@@ -17342,9 +17357,9 @@ function registerGithub(program2) {
|
|
|
17342
17357
|
}
|
|
17343
17358
|
|
|
17344
17359
|
// src/commands/handover/countPendingHandovers.ts
|
|
17345
|
-
import { and as and19, eq as
|
|
17360
|
+
import { and as and19, eq as eq40, isNull, sql as sql18 } from "drizzle-orm";
|
|
17346
17361
|
async function countPendingHandovers(orm, origin) {
|
|
17347
|
-
const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(and19(
|
|
17362
|
+
const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(and19(eq40(handovers.origin, origin), isNull(handovers.recalledAt)));
|
|
17348
17363
|
return row?.count ?? 0;
|
|
17349
17364
|
}
|
|
17350
17365
|
|
|
@@ -17459,9 +17474,9 @@ function resolveLoadOptions(options2) {
|
|
|
17459
17474
|
}
|
|
17460
17475
|
|
|
17461
17476
|
// src/commands/handover/load.ts
|
|
17462
|
-
function advisory(
|
|
17463
|
-
const noun =
|
|
17464
|
-
return `${
|
|
17477
|
+
function advisory(count8) {
|
|
17478
|
+
const noun = count8 === 1 ? "handover" : "handovers";
|
|
17479
|
+
return `${count8} unrecalled ${noun} for this repo. Run /recall to load.`;
|
|
17465
17480
|
}
|
|
17466
17481
|
function emit2(message2) {
|
|
17467
17482
|
const json = JSON.stringify({
|
|
@@ -17478,19 +17493,19 @@ async function load2(options2 = {}) {
|
|
|
17478
17493
|
const origin = getCurrentOrigin(cwd);
|
|
17479
17494
|
const orm = options2.orm ?? await getDb();
|
|
17480
17495
|
await migrateDiskHandovers(orm, origin, cwd);
|
|
17481
|
-
const
|
|
17482
|
-
if (
|
|
17483
|
-
return emit2(advisory(
|
|
17496
|
+
const count8 = await countPendingHandovers(orm, origin);
|
|
17497
|
+
if (count8 === 0) return null;
|
|
17498
|
+
return emit2(advisory(count8));
|
|
17484
17499
|
}
|
|
17485
17500
|
|
|
17486
17501
|
// src/commands/handover/listPendingHandovers.ts
|
|
17487
|
-
import { and as and20, desc as desc4, eq as
|
|
17502
|
+
import { and as and20, desc as desc4, eq as eq41, isNull as isNull2 } from "drizzle-orm";
|
|
17488
17503
|
async function listPendingHandovers(orm, origin) {
|
|
17489
17504
|
return orm.select({
|
|
17490
17505
|
id: handovers.id,
|
|
17491
17506
|
summary: handovers.summary,
|
|
17492
17507
|
createdAt: handovers.createdAt
|
|
17493
|
-
}).from(handovers).where(and20(
|
|
17508
|
+
}).from(handovers).where(and20(eq41(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
|
|
17494
17509
|
}
|
|
17495
17510
|
|
|
17496
17511
|
// src/commands/handover/printPendingHandovers.ts
|
|
@@ -17503,17 +17518,17 @@ async function printPendingHandovers() {
|
|
|
17503
17518
|
}
|
|
17504
17519
|
|
|
17505
17520
|
// src/commands/handover/recallHandover.ts
|
|
17506
|
-
import { and as and21, desc as desc5, eq as
|
|
17521
|
+
import { and as and21, desc as desc5, eq as eq42, isNull as isNull3 } from "drizzle-orm";
|
|
17507
17522
|
async function recallHandover(orm, origin, id) {
|
|
17508
17523
|
const [row] = await orm.select().from(handovers).where(
|
|
17509
17524
|
and21(
|
|
17510
|
-
|
|
17525
|
+
eq42(handovers.origin, origin),
|
|
17511
17526
|
isNull3(handovers.recalledAt),
|
|
17512
|
-
...id === void 0 ? [] : [
|
|
17527
|
+
...id === void 0 ? [] : [eq42(handovers.id, id)]
|
|
17513
17528
|
)
|
|
17514
17529
|
).orderBy(desc5(handovers.createdAt), desc5(handovers.id)).limit(1);
|
|
17515
17530
|
if (!row) return void 0;
|
|
17516
|
-
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(
|
|
17531
|
+
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq42(handovers.id, row.id));
|
|
17517
17532
|
return row.content;
|
|
17518
17533
|
}
|
|
17519
17534
|
|
|
@@ -18507,14 +18522,14 @@ async function netcap(options2) {
|
|
|
18507
18522
|
const filter = options2.filter ?? "";
|
|
18508
18523
|
await mkdir4(dirname26(outPath), { recursive: true });
|
|
18509
18524
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
18510
|
-
let
|
|
18525
|
+
let count8 = 0;
|
|
18511
18526
|
const handler = createNetcapHandler({
|
|
18512
18527
|
outPath,
|
|
18513
18528
|
onPing: () => console.log(chalk160.dim("ping from extension")),
|
|
18514
18529
|
onCapture: (entry) => {
|
|
18515
|
-
|
|
18530
|
+
count8 += 1;
|
|
18516
18531
|
console.log(
|
|
18517
|
-
chalk160.green(`captured #${
|
|
18532
|
+
chalk160.green(`captured #${count8}`),
|
|
18518
18533
|
chalk160.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
18519
18534
|
);
|
|
18520
18535
|
}
|
|
@@ -18535,7 +18550,7 @@ async function netcap(options2) {
|
|
|
18535
18550
|
console.log(
|
|
18536
18551
|
chalk160.bold(
|
|
18537
18552
|
`
|
|
18538
|
-
netcap stopped \u2014 captured ${
|
|
18553
|
+
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
18539
18554
|
)
|
|
18540
18555
|
);
|
|
18541
18556
|
process.exit(0);
|
|
@@ -19108,11 +19123,11 @@ function printPromptsTable(rows) {
|
|
|
19108
19123
|
console.log(chalk163.dim(header));
|
|
19109
19124
|
console.log(chalk163.dim("-".repeat(header.length)));
|
|
19110
19125
|
for (const row of rows) {
|
|
19111
|
-
const
|
|
19126
|
+
const count8 = String(row.count).padStart(countWidth);
|
|
19112
19127
|
const tool = row.tool.padEnd(toolWidth);
|
|
19113
19128
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
19114
19129
|
console.log(
|
|
19115
|
-
`${chalk163.yellow(
|
|
19130
|
+
`${chalk163.yellow(count8)} ${tool} ${command} ${chalk163.dim(row.repos)}`
|
|
19116
19131
|
);
|
|
19117
19132
|
}
|
|
19118
19133
|
}
|
|
@@ -19857,8 +19872,8 @@ async function promptNavigation(currentPage, totalPages) {
|
|
|
19857
19872
|
});
|
|
19858
19873
|
return parseAction(action);
|
|
19859
19874
|
}
|
|
19860
|
-
function computeTotalPages(
|
|
19861
|
-
return Math.ceil(
|
|
19875
|
+
function computeTotalPages(count8) {
|
|
19876
|
+
return Math.ceil(count8 / PAGE_SIZE);
|
|
19862
19877
|
}
|
|
19863
19878
|
async function navigateAndDisplay(pullRequests, totalPages, currentPage) {
|
|
19864
19879
|
const delta = await promptNavigation(currentPage, totalPages);
|
|
@@ -20969,16 +20984,16 @@ import {
|
|
|
20969
20984
|
} from "ts-morph";
|
|
20970
20985
|
var suppressionPattern = /^\s*(\/\/|\/\*)\s*oxlint-disable\b/;
|
|
20971
20986
|
function countLeadingSuppressions(sourceFile) {
|
|
20972
|
-
let
|
|
20987
|
+
let count8 = 0;
|
|
20973
20988
|
for (const stmt of sourceFile.getStatementsWithComments()) {
|
|
20974
20989
|
const kind = stmt.getKind();
|
|
20975
20990
|
if ((kind === SyntaxKind2.SingleLineCommentTrivia || kind === SyntaxKind2.MultiLineCommentTrivia) && suppressionPattern.test(stmt.getText())) {
|
|
20976
|
-
|
|
20991
|
+
count8++;
|
|
20977
20992
|
} else {
|
|
20978
20993
|
break;
|
|
20979
20994
|
}
|
|
20980
20995
|
}
|
|
20981
|
-
return
|
|
20996
|
+
return count8;
|
|
20982
20997
|
}
|
|
20983
20998
|
function addImportPreservingSuppressions(sourceFile, structure) {
|
|
20984
20999
|
if (sourceFile.getImportDeclarations().length > 0) {
|
|
@@ -23022,9 +23037,9 @@ function warnUnlocated(unlocated) {
|
|
|
23022
23037
|
}
|
|
23023
23038
|
|
|
23024
23039
|
// src/commands/review/postReviewToPr.ts
|
|
23025
|
-
async function confirmPost(prNumber,
|
|
23040
|
+
async function confirmPost(prNumber, count8, options2) {
|
|
23026
23041
|
if (!options2.prompt) return true;
|
|
23027
|
-
return promptConfirm(`Post ${
|
|
23042
|
+
return promptConfirm(`Post ${count8} comment(s) to PR #${prNumber}?`, false);
|
|
23028
23043
|
}
|
|
23029
23044
|
async function postReviewToPr(synthesisPath, options2) {
|
|
23030
23045
|
const prInfo = fetchPrDiffInfo();
|
|
@@ -24071,9 +24086,9 @@ async function runReviewPipeline(paths, options2) {
|
|
|
24071
24086
|
}
|
|
24072
24087
|
|
|
24073
24088
|
// src/commands/review/reviewPr.ts
|
|
24074
|
-
function logPriorComments(
|
|
24075
|
-
if (
|
|
24076
|
-
console.log(`Including ${
|
|
24089
|
+
function logPriorComments(count8) {
|
|
24090
|
+
if (count8 === 0) return;
|
|
24091
|
+
console.log(`Including ${count8} prior review comment(s) in request.md.`);
|
|
24077
24092
|
}
|
|
24078
24093
|
function gatherChangedContext() {
|
|
24079
24094
|
const context = gatherContext();
|
|
@@ -24277,16 +24292,16 @@ function filterToSql(filter) {
|
|
|
24277
24292
|
}
|
|
24278
24293
|
|
|
24279
24294
|
// src/commands/seq/fetchSeqData.ts
|
|
24280
|
-
function buildDataParams(filter,
|
|
24295
|
+
function buildDataParams(filter, count8, from, to) {
|
|
24281
24296
|
const sqlFilter = filterToSql(filter);
|
|
24282
|
-
const sql25 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${
|
|
24297
|
+
const sql25 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${count8}`;
|
|
24283
24298
|
const params = new URLSearchParams({ q: sql25 });
|
|
24284
24299
|
if (from) params.set("rangeStartUtc", from);
|
|
24285
24300
|
if (to) params.set("rangeEndUtc", to);
|
|
24286
24301
|
return params;
|
|
24287
24302
|
}
|
|
24288
|
-
async function fetchSeqData(conn, filter,
|
|
24289
|
-
const params = buildDataParams(filter,
|
|
24303
|
+
async function fetchSeqData(conn, filter, count8, from, to) {
|
|
24304
|
+
const params = buildDataParams(filter, count8, from, to);
|
|
24290
24305
|
const response = await fetchSeq(conn, "/api/data", params);
|
|
24291
24306
|
const data = await response.json();
|
|
24292
24307
|
return mapDataToEvents(data);
|
|
@@ -24453,12 +24468,12 @@ function resolveConnection2(name) {
|
|
|
24453
24468
|
async function seqQuery(filter, options2) {
|
|
24454
24469
|
rejectTimestampFilter(filter);
|
|
24455
24470
|
const conn = resolveConnection2(options2.connection);
|
|
24456
|
-
const
|
|
24471
|
+
const count8 = Number.parseInt(options2.count ?? "1000", 10);
|
|
24457
24472
|
const from = options2.from ? parseRelativeTime(options2.from) : void 0;
|
|
24458
24473
|
const to = options2.to ? parseRelativeTime(options2.to) : void 0;
|
|
24459
|
-
const events = from || to ? await fetchSeqData(conn, filter,
|
|
24474
|
+
const events = from || to ? await fetchSeqData(conn, filter, count8, from, to) : await fetchSeqEvents(
|
|
24460
24475
|
conn,
|
|
24461
|
-
new URLSearchParams({ filter, count: String(
|
|
24476
|
+
new URLSearchParams({ filter, count: String(count8) })
|
|
24462
24477
|
);
|
|
24463
24478
|
if (events.length === 0) {
|
|
24464
24479
|
console.log(chalk197.yellow("No events found."));
|
|
@@ -24474,10 +24489,10 @@ async function seqQuery(filter, options2) {
|
|
|
24474
24489
|
}
|
|
24475
24490
|
console.log(chalk197.dim(`
|
|
24476
24491
|
${events.length} events`));
|
|
24477
|
-
if (events.length >=
|
|
24492
|
+
if (events.length >= count8) {
|
|
24478
24493
|
console.log(
|
|
24479
24494
|
chalk197.yellow(
|
|
24480
|
-
`Results limited to ${
|
|
24495
|
+
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
24481
24496
|
)
|
|
24482
24497
|
);
|
|
24483
24498
|
}
|
|
@@ -25309,13 +25324,13 @@ function logs(options2) {
|
|
|
25309
25324
|
console.log("No voice log file found");
|
|
25310
25325
|
return;
|
|
25311
25326
|
}
|
|
25312
|
-
const
|
|
25327
|
+
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
25313
25328
|
const content = readFileSync43(voicePaths.log, "utf8").trim();
|
|
25314
25329
|
if (!content) {
|
|
25315
25330
|
console.log("Voice log is empty");
|
|
25316
25331
|
return;
|
|
25317
25332
|
}
|
|
25318
|
-
const lines = content.split("\n").slice(-
|
|
25333
|
+
const lines = content.split("\n").slice(-count8);
|
|
25319
25334
|
for (const line of lines) {
|
|
25320
25335
|
try {
|
|
25321
25336
|
const event = JSON.parse(line);
|
|
@@ -25462,10 +25477,10 @@ function isProcessAlive3(pid) {
|
|
|
25462
25477
|
return false;
|
|
25463
25478
|
}
|
|
25464
25479
|
}
|
|
25465
|
-
function readRecentLogs(
|
|
25480
|
+
function readRecentLogs(count8) {
|
|
25466
25481
|
if (!existsSync56(voicePaths.log)) return [];
|
|
25467
25482
|
const lines = readFileSync45(voicePaths.log, "utf8").trim().split("\n");
|
|
25468
|
-
return lines.slice(-
|
|
25483
|
+
return lines.slice(-count8);
|
|
25469
25484
|
}
|
|
25470
25485
|
function status2() {
|
|
25471
25486
|
if (!existsSync56(voicePaths.pid)) {
|
|
@@ -25699,10 +25714,10 @@ function fetchQuietly(cwd, timeoutMs) {
|
|
|
25699
25714
|
}
|
|
25700
25715
|
|
|
25701
25716
|
// src/commands/watch/detectMovement.ts
|
|
25702
|
-
function detectMovement(from, to,
|
|
25717
|
+
function detectMovement(from, to, count8) {
|
|
25703
25718
|
if (from === to) return void 0;
|
|
25704
|
-
if (!Number.isFinite(
|
|
25705
|
-
return { from, to, count:
|
|
25719
|
+
if (!Number.isFinite(count8) || count8 <= 0) return void 0;
|
|
25720
|
+
return { from, to, count: count8 };
|
|
25706
25721
|
}
|
|
25707
25722
|
|
|
25708
25723
|
// src/commands/watch/readMovement.ts
|
|
@@ -25710,8 +25725,8 @@ function readMovement(cwd) {
|
|
|
25710
25725
|
try {
|
|
25711
25726
|
const from = runGit2(["rev-parse", "@"], cwd);
|
|
25712
25727
|
const to = runGit2(["rev-parse", "@{u}"], cwd);
|
|
25713
|
-
const
|
|
25714
|
-
return detectMovement(from, to,
|
|
25728
|
+
const count8 = Number(runGit2(["rev-list", "--count", "@..@{u}"], cwd));
|
|
25729
|
+
return detectMovement(from, to, count8);
|
|
25715
25730
|
} catch {
|
|
25716
25731
|
return void 0;
|
|
25717
25732
|
}
|
|
@@ -26838,9 +26853,9 @@ async function drainDaemon(options2 = {}) {
|
|
|
26838
26853
|
return;
|
|
26839
26854
|
}
|
|
26840
26855
|
}
|
|
26841
|
-
const
|
|
26856
|
+
const count8 = await requestDrain(socket, lines);
|
|
26842
26857
|
socket.destroy();
|
|
26843
|
-
console.log(`Drained ${
|
|
26858
|
+
console.log(`Drained ${count8} session(s)`);
|
|
26844
26859
|
}
|
|
26845
26860
|
function reportLive(live) {
|
|
26846
26861
|
console.log(`${live.length} live session(s) would be closed:`);
|
|
@@ -27799,10 +27814,10 @@ function applyReviewPause(session, activity2) {
|
|
|
27799
27814
|
}
|
|
27800
27815
|
|
|
27801
27816
|
// src/shared/db/getPhaseActiveMs.ts
|
|
27802
|
-
import { and as and22, eq as
|
|
27817
|
+
import { and as and22, eq as eq43 } from "drizzle-orm";
|
|
27803
27818
|
async function getPhaseActiveMs(db, itemId2, phaseIdx) {
|
|
27804
27819
|
const [row] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
27805
|
-
and22(
|
|
27820
|
+
and22(eq43(phaseUsage.itemId, itemId2), eq43(phaseUsage.phaseIdx, phaseIdx))
|
|
27806
27821
|
);
|
|
27807
27822
|
return row?.activeMs ?? 0;
|
|
27808
27823
|
}
|
|
@@ -28313,7 +28328,7 @@ async function recordPhaseTranscriptUsage(db, itemId2, phaseIdx, responses) {
|
|
|
28313
28328
|
}
|
|
28314
28329
|
|
|
28315
28330
|
// src/shared/db/recordWindowTokens.ts
|
|
28316
|
-
import { and as and23, eq as
|
|
28331
|
+
import { and as and23, eq as eq44, sql as sql24 } from "drizzle-orm";
|
|
28317
28332
|
async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
|
|
28318
28333
|
if (tokensUp <= 0 && tokensDown <= 0) return;
|
|
28319
28334
|
await db.update(usagePeaks).set({
|
|
@@ -28321,9 +28336,9 @@ async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
|
|
|
28321
28336
|
tokensDown: sql24`${usagePeaks.tokensDown} + ${tokensDown}`
|
|
28322
28337
|
}).where(
|
|
28323
28338
|
and23(
|
|
28324
|
-
|
|
28325
|
-
|
|
28326
|
-
|
|
28339
|
+
eq44(usagePeaks.window, window),
|
|
28340
|
+
eq44(usagePeaks.resetsAt, resetsAt),
|
|
28341
|
+
eq44(usagePeaks.segment, 0)
|
|
28327
28342
|
)
|
|
28328
28343
|
);
|
|
28329
28344
|
}
|