@staff0rd/assist 0.969.1 → 0.971.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 +431 -431
- package/dist/index.js +253 -175
- 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.971.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -3782,13 +3782,29 @@ function storyEntry(story) {
|
|
|
3782
3782
|
}
|
|
3783
3783
|
function buildDocsRefreshDescription(stories) {
|
|
3784
3784
|
return [
|
|
3785
|
-
"Update the docs pages under `docs/src/content/docs/` from what these done stories shipped. Stories
|
|
3785
|
+
"Update the docs pages under `docs/src/content/docs/` from what these done stories shipped. Stories leave docs alone during development, so this item owns both the prose (wording, new behaviour on existing pages, removed features) and the `covers` entries that document new commands, skills, config keys and routes.",
|
|
3786
3786
|
"For detail on a story, run `assist backlog view <id>` (description, acceptance criteria, summaries and activity) and `git show <sha>` on its commits.",
|
|
3787
3787
|
"## Covered stories",
|
|
3788
3788
|
...stories.map(storyEntry)
|
|
3789
3789
|
].join("\n\n");
|
|
3790
3790
|
}
|
|
3791
3791
|
|
|
3792
|
+
// src/shared/isRunLink.ts
|
|
3793
|
+
function isRunLink(entry) {
|
|
3794
|
+
return "link" in entry;
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
// src/commands/backlog/hasDocsCoverageRun.ts
|
|
3798
|
+
function hasDocsCoverageRun() {
|
|
3799
|
+
try {
|
|
3800
|
+
return (loadConfigFrom(getBacklogDir()).run ?? []).some(
|
|
3801
|
+
(entry) => !isRunLink(entry) && entry.name === "docs:coverage"
|
|
3802
|
+
);
|
|
3803
|
+
} catch {
|
|
3804
|
+
return false;
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3792
3808
|
// src/commands/backlog/insertPhaseAt.ts
|
|
3793
3809
|
import { eq as eq12 } from "drizzle-orm";
|
|
3794
3810
|
|
|
@@ -3837,7 +3853,7 @@ async function loadDocsRefreshStories(orm, ids) {
|
|
|
3837
3853
|
}
|
|
3838
3854
|
|
|
3839
3855
|
// src/commands/backlog/createDocsRefreshItem.ts
|
|
3840
|
-
async function createDocsRefreshItem(orm, origin, storyIds) {
|
|
3856
|
+
async function createDocsRefreshItem(orm, origin, storyIds, coverageCheck = hasDocsCoverageRun()) {
|
|
3841
3857
|
const stories = await loadDocsRefreshStories(orm, storyIds);
|
|
3842
3858
|
const storyList = storyIds.map(formatItemId).join(", ");
|
|
3843
3859
|
const id = await insertItem(
|
|
@@ -3863,7 +3879,10 @@ async function createDocsRefreshItem(orm, origin, storyIds) {
|
|
|
3863
3879
|
[
|
|
3864
3880
|
`Walk each covered story (${storyList}): read it with \`assist backlog view <id>\` and its commits with \`git show <sha>\`, and note what it changed for users`,
|
|
3865
3881
|
"Skip stories with no user-facing change and leave their pages untouched",
|
|
3866
|
-
"For the rest, update the affected pages under `docs/src/content/docs/` (wording, new behaviour on existing pages, removed features) following the rules in `docs/CLAUDE.md`"
|
|
3882
|
+
"For the rest, update the affected pages under `docs/src/content/docs/` (wording, new behaviour on existing pages, removed features) following the rules in `docs/CLAUDE.md`",
|
|
3883
|
+
...coverageCheck ? [
|
|
3884
|
+
"Run `assist run docs:coverage`; while it fails, list the gaps with `assist run docs:coverage --report` and add `covers` entries to the pages that document them (or new pages) until it passes"
|
|
3885
|
+
] : []
|
|
3867
3886
|
],
|
|
3868
3887
|
null,
|
|
3869
3888
|
void 0
|
|
@@ -5789,7 +5808,7 @@ var inboxConfigHelp = [
|
|
|
5789
5808
|
{
|
|
5790
5809
|
key: "inbox.intervalMinutes",
|
|
5791
5810
|
setter: "assist config set inbox.intervalMinutes <n> --node",
|
|
5792
|
-
note: "minutes between scheduled inbox scans run by this machine's daemon (
|
|
5811
|
+
note: "minutes between scheduled inbox scans run by this machine's daemon (picked up within a minute); read from ~/.assist.yml only, so a repo's assist.yml or shared overrides can't enable it. Unset by default: no scheduled scans"
|
|
5793
5812
|
}
|
|
5794
5813
|
];
|
|
5795
5814
|
|
|
@@ -6707,11 +6726,6 @@ function findLinkedConfigPath(linkPath, fromDir) {
|
|
|
6707
6726
|
throw new Error(`No assist.yml found in linked project: ${resolved}`);
|
|
6708
6727
|
}
|
|
6709
6728
|
|
|
6710
|
-
// src/shared/isRunLink.ts
|
|
6711
|
-
function isRunLink(entry) {
|
|
6712
|
-
return "link" in entry;
|
|
6713
|
-
}
|
|
6714
|
-
|
|
6715
6729
|
// src/shared/loadLinkedEntries.ts
|
|
6716
6730
|
import { resolve as resolve6 } from "path";
|
|
6717
6731
|
function loadLinkedEntries(configPath, visited) {
|
|
@@ -8328,6 +8342,32 @@ async function historySearch(req, res) {
|
|
|
8328
8342
|
respondJson(res, 200, { sessions: reply2.sessions ?? [] });
|
|
8329
8343
|
}
|
|
8330
8344
|
|
|
8345
|
+
// src/shared/db/readInboxLastScan.ts
|
|
8346
|
+
import { eq as eq21 } from "drizzle-orm";
|
|
8347
|
+
var INBOX_LAST_SCAN_KEY = "inbox.lastScanAt";
|
|
8348
|
+
async function readInboxLastScan(orm) {
|
|
8349
|
+
const [row3] = await orm.select().from(metadata).where(eq21(metadata.key, INBOX_LAST_SCAN_KEY));
|
|
8350
|
+
return row3 ? new Date(row3.value) : void 0;
|
|
8351
|
+
}
|
|
8352
|
+
|
|
8353
|
+
// src/commands/sessions/web/inbox/inboxStatus.ts
|
|
8354
|
+
async function inboxStatus(_req, res) {
|
|
8355
|
+
const [reply2, lastScanAt] = await Promise.all([
|
|
8356
|
+
requestDaemonReply({ type: "inbox-status" }, "inbox-status"),
|
|
8357
|
+
readInboxLastScan(await getDb())
|
|
8358
|
+
]);
|
|
8359
|
+
if (!reply2) {
|
|
8360
|
+
respondJson(res, 503, { error: "Daemon not reachable" });
|
|
8361
|
+
return;
|
|
8362
|
+
}
|
|
8363
|
+
respondJson(res, 200, {
|
|
8364
|
+
scanning: reply2.scanning,
|
|
8365
|
+
intervalMinutes: reply2.intervalMinutes,
|
|
8366
|
+
lastError: reply2.lastError,
|
|
8367
|
+
lastScanAt: lastScanAt?.toISOString() ?? null
|
|
8368
|
+
});
|
|
8369
|
+
}
|
|
8370
|
+
|
|
8331
8371
|
// src/shared/db/listInboxMessages.ts
|
|
8332
8372
|
import { desc as desc3, isNull as isNull2, sql as sql17 } from "drizzle-orm";
|
|
8333
8373
|
function listInboxMessages(orm) {
|
|
@@ -8355,6 +8395,25 @@ async function listInbox(_req, res) {
|
|
|
8355
8395
|
);
|
|
8356
8396
|
}
|
|
8357
8397
|
|
|
8398
|
+
// src/commands/sessions/web/linkedRequester.ts
|
|
8399
|
+
function linkedRequester(req) {
|
|
8400
|
+
return `from=${req.headers["x-assist-linked-from"] ?? "local"} trace=${req.headers[TRACE_HEADER] ?? "none"}`;
|
|
8401
|
+
}
|
|
8402
|
+
|
|
8403
|
+
// src/commands/sessions/web/inbox/scanInbox.ts
|
|
8404
|
+
async function scanInbox(req, res) {
|
|
8405
|
+
console.log(`inbox scan requested ${linkedRequester(req)}`);
|
|
8406
|
+
const reply2 = await requestDaemonReply(
|
|
8407
|
+
{ type: "inbox-scan" },
|
|
8408
|
+
"inbox-scan"
|
|
8409
|
+
);
|
|
8410
|
+
if (!reply2) {
|
|
8411
|
+
respondJson(res, 503, { error: "Daemon not reachable" });
|
|
8412
|
+
return;
|
|
8413
|
+
}
|
|
8414
|
+
respondJson(res, 200, { started: reply2.started });
|
|
8415
|
+
}
|
|
8416
|
+
|
|
8358
8417
|
// src/shared/hotkeys/resolveHotkeys.ts
|
|
8359
8418
|
function resolveHotkeys(overrides) {
|
|
8360
8419
|
const bindings = { ...defaultHotkeys };
|
|
@@ -9469,14 +9528,14 @@ function listScopedRules(req, res) {
|
|
|
9469
9528
|
}
|
|
9470
9529
|
|
|
9471
9530
|
// src/shared/db/countUsagePeaks.ts
|
|
9472
|
-
import { count, eq as
|
|
9531
|
+
import { count, eq as eq22 } from "drizzle-orm";
|
|
9473
9532
|
async function countUsagePeaks(db, window) {
|
|
9474
|
-
const [row3] = await db.select({ value: count() }).from(usagePeaks).where(window ?
|
|
9533
|
+
const [row3] = await db.select({ value: count() }).from(usagePeaks).where(window ? eq22(usagePeaks.window, window) : void 0);
|
|
9475
9534
|
return row3?.value ?? 0;
|
|
9476
9535
|
}
|
|
9477
9536
|
|
|
9478
9537
|
// src/shared/db/listUsagePeaks.ts
|
|
9479
|
-
import { and as and10, desc as desc4, eq as
|
|
9538
|
+
import { and as and10, desc as desc4, eq as eq23, getTableColumns } from "drizzle-orm";
|
|
9480
9539
|
|
|
9481
9540
|
// src/shared/db/avgContextPerCycle.ts
|
|
9482
9541
|
import { count as count2, sql as sql18 } from "drizzle-orm";
|
|
@@ -9501,10 +9560,10 @@ async function listUsagePeaks(db, options2) {
|
|
|
9501
9560
|
}).from(usagePeaks).leftJoin(
|
|
9502
9561
|
avgContext,
|
|
9503
9562
|
and10(
|
|
9504
|
-
|
|
9505
|
-
|
|
9563
|
+
eq23(usagePeaks.window, avgContext.window),
|
|
9564
|
+
eq23(usagePeaks.resetsAt, avgContext.resetsAt)
|
|
9506
9565
|
)
|
|
9507
|
-
).where(options2?.window ?
|
|
9566
|
+
).where(options2?.window ? eq23(usagePeaks.window, options2.window) : void 0).orderBy(
|
|
9508
9567
|
desc4(usagePeaks.resetsAt),
|
|
9509
9568
|
usagePeaks.window,
|
|
9510
9569
|
desc4(usagePeaks.createdAt),
|
|
@@ -9573,26 +9632,26 @@ function listUsageHistory(req, res) {
|
|
|
9573
9632
|
}
|
|
9574
9633
|
|
|
9575
9634
|
// src/shared/db/countItemUsageByOrigin.ts
|
|
9576
|
-
import { asc as asc9, desc as desc5, eq as
|
|
9635
|
+
import { asc as asc9, desc as desc5, eq as eq24, sql as sql19 } from "drizzle-orm";
|
|
9577
9636
|
async function countItemUsageByOrigin(db) {
|
|
9578
9637
|
const count10 = sql19`count(distinct ${phaseUsage.itemId})::int`;
|
|
9579
|
-
const rows = await db.select({ origin: items.origin, count: count10 }).from(items).innerJoin(phaseUsage,
|
|
9638
|
+
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));
|
|
9580
9639
|
return rows.map((row3) => ({ origin: row3.origin, count: Number(row3.count) }));
|
|
9581
9640
|
}
|
|
9582
9641
|
|
|
9583
9642
|
// src/shared/db/itemUsageWhere.ts
|
|
9584
|
-
import { and as and11, eq as
|
|
9643
|
+
import { and as and11, eq as eq25, notInArray } from "drizzle-orm";
|
|
9585
9644
|
function parseItemUsageStatus(value) {
|
|
9586
9645
|
return value === "done" || value === "running" ? value : void 0;
|
|
9587
9646
|
}
|
|
9588
9647
|
function statusClause(status2) {
|
|
9589
|
-
if (status2 === "done") return
|
|
9648
|
+
if (status2 === "done") return eq25(items.status, "done");
|
|
9590
9649
|
if (status2 === "running") return notInArray(items.status, ["done", "wontdo"]);
|
|
9591
9650
|
return void 0;
|
|
9592
9651
|
}
|
|
9593
9652
|
function itemUsageWhere(filter) {
|
|
9594
9653
|
return and11(
|
|
9595
|
-
filter?.origin ?
|
|
9654
|
+
filter?.origin ? eq25(items.origin, filter.origin) : void 0,
|
|
9596
9655
|
statusClause(filter?.status)
|
|
9597
9656
|
);
|
|
9598
9657
|
}
|
|
@@ -9617,7 +9676,7 @@ function parseItemUsageSort(field, direction) {
|
|
|
9617
9676
|
}
|
|
9618
9677
|
|
|
9619
9678
|
// src/shared/db/itemUsageStats.ts
|
|
9620
|
-
import { eq as
|
|
9679
|
+
import { eq as eq26, sql as sql20 } from "drizzle-orm";
|
|
9621
9680
|
function median(value) {
|
|
9622
9681
|
return sql20`coalesce(percentile_cont(0.5) within group (order by (${value})::double precision), 0)`;
|
|
9623
9682
|
}
|
|
@@ -9633,7 +9692,7 @@ async function itemUsageStats(db, options2) {
|
|
|
9633
9692
|
),
|
|
9634
9693
|
medianActiveMs: median(totals.activeMs),
|
|
9635
9694
|
medianTokens: median(sql20`${totals.tokensUp} + ${totals.tokensDown}`)
|
|
9636
|
-
}).from(items).innerJoin(totals,
|
|
9695
|
+
}).from(items).innerJoin(totals, eq26(totals.itemId, items.id)).leftJoin(planned, eq26(planned.itemId, items.id)).where(itemUsageWhere(options2));
|
|
9637
9696
|
return {
|
|
9638
9697
|
itemCount: Number(row3?.itemCount ?? 0),
|
|
9639
9698
|
doneCount: Number(row3?.doneCount ?? 0),
|
|
@@ -9645,7 +9704,7 @@ async function itemUsageStats(db, options2) {
|
|
|
9645
9704
|
}
|
|
9646
9705
|
|
|
9647
9706
|
// src/shared/db/listItemUsageSummaries.ts
|
|
9648
|
-
import { eq as
|
|
9707
|
+
import { eq as eq27 } from "drizzle-orm";
|
|
9649
9708
|
|
|
9650
9709
|
// src/shared/db/itemUsageOrderBy.ts
|
|
9651
9710
|
import { desc as desc6, sql as sql21 } from "drizzle-orm";
|
|
@@ -9706,7 +9765,7 @@ async function listItemUsageSummaries(db, options2) {
|
|
|
9706
9765
|
activeMs: totals.activeMs,
|
|
9707
9766
|
peakContextPct: totals.peakContextPct,
|
|
9708
9767
|
lastPhaseAt: lastPhase.atIso
|
|
9709
|
-
}).from(items).innerJoin(totals,
|
|
9768
|
+
}).from(items).innerJoin(totals, eq27(totals.itemId, items.id)).leftJoin(planned, eq27(planned.itemId, items.id)).leftJoin(lastPhase, eq27(lastPhase.itemId, items.id)).where(itemUsageWhere(options2)).orderBy(
|
|
9710
9769
|
...itemUsageOrderBy({ totals, planned, lastPhase }, options2?.sort)
|
|
9711
9770
|
);
|
|
9712
9771
|
const rows = options2?.limit === void 0 ? await query : await query.limit(options2.limit).offset(options2.offset ?? 0);
|
|
@@ -10522,11 +10581,6 @@ async function restartDaemon() {
|
|
|
10522
10581
|
);
|
|
10523
10582
|
}
|
|
10524
10583
|
|
|
10525
|
-
// src/commands/sessions/web/linkedRequester.ts
|
|
10526
|
-
function linkedRequester(req) {
|
|
10527
|
-
return `from=${req.headers["x-assist-linked-from"] ?? "local"} trace=${req.headers[TRACE_HEADER] ?? "none"}`;
|
|
10528
|
-
}
|
|
10529
|
-
|
|
10530
10584
|
// src/commands/sessions/web/restartMenu/reExecWebServer.ts
|
|
10531
10585
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
10532
10586
|
|
|
@@ -11499,10 +11553,10 @@ function currentRepoLabel(shared, origin) {
|
|
|
11499
11553
|
}
|
|
11500
11554
|
|
|
11501
11555
|
// src/shared/db/saveRepoConfig.ts
|
|
11502
|
-
import { eq as
|
|
11556
|
+
import { eq as eq28 } from "drizzle-orm";
|
|
11503
11557
|
async function saveRepoConfig(orm, repoKey, config) {
|
|
11504
11558
|
if (Object.keys(config).length === 0) {
|
|
11505
|
-
await orm.delete(repoConfigs).where(
|
|
11559
|
+
await orm.delete(repoConfigs).where(eq28(repoConfigs.repoKey, repoKey));
|
|
11506
11560
|
return;
|
|
11507
11561
|
}
|
|
11508
11562
|
await orm.insert(repoConfigs).values({ repoKey, config }).onConflictDoUpdate({
|
|
@@ -11561,14 +11615,14 @@ async function applySharedRepoConfigSet(key, coerced, repoName, cwd = process.cw
|
|
|
11561
11615
|
}
|
|
11562
11616
|
|
|
11563
11617
|
// src/shared/db/updateUserConfig.ts
|
|
11564
|
-
import { eq as
|
|
11618
|
+
import { eq as eq29 } from "drizzle-orm";
|
|
11565
11619
|
async function updateUserConfig(orm, update4) {
|
|
11566
11620
|
return orm.transaction(async (tx) => {
|
|
11567
|
-
const [row3] = await tx.select().from(userConfig).where(
|
|
11621
|
+
const [row3] = await tx.select().from(userConfig).where(eq29(userConfig.id, 1)).for("update");
|
|
11568
11622
|
const outcome = update4(row3?.config ?? {});
|
|
11569
11623
|
if (!outcome.ok) return outcome;
|
|
11570
11624
|
if (Object.keys(outcome.config).length === 0) {
|
|
11571
|
-
await tx.delete(userConfig).where(
|
|
11625
|
+
await tx.delete(userConfig).where(eq29(userConfig.id, 1));
|
|
11572
11626
|
return outcome;
|
|
11573
11627
|
}
|
|
11574
11628
|
await tx.insert(userConfig).values({ id: 1, config: outcome.config }).onConflictDoUpdate({
|
|
@@ -12460,6 +12514,8 @@ var routes2 = {
|
|
|
12460
12514
|
"GET /api/next": nextItems,
|
|
12461
12515
|
"POST /api/next/pickup": nextPickup,
|
|
12462
12516
|
"GET /api/inbox": listInbox,
|
|
12517
|
+
"GET /api/inbox/status": inboxStatus,
|
|
12518
|
+
"POST /api/inbox/scan": scanInbox,
|
|
12463
12519
|
"GET /api/news/items": listNewsItems,
|
|
12464
12520
|
"GET /api/news/nav": newsNavConfig,
|
|
12465
12521
|
"GET /api/releases/state": releasesState,
|
|
@@ -15957,11 +16013,11 @@ function registerActivityCommands(cmd) {
|
|
|
15957
16013
|
|
|
15958
16014
|
// src/commands/backlog/associateGithub.ts
|
|
15959
16015
|
import chalk45 from "chalk";
|
|
15960
|
-
import { eq as
|
|
16016
|
+
import { eq as eq31 } from "drizzle-orm";
|
|
15961
16017
|
|
|
15962
16018
|
// src/commands/backlog/beginAssociation.ts
|
|
15963
16019
|
import chalk44 from "chalk";
|
|
15964
|
-
import { eq as
|
|
16020
|
+
import { eq as eq30 } from "drizzle-orm";
|
|
15965
16021
|
async function beginAssociation(id, options2, clearPatch, label) {
|
|
15966
16022
|
const found = await findOneItem(id);
|
|
15967
16023
|
if (!found) {
|
|
@@ -15971,7 +16027,7 @@ async function beginAssociation(id, options2, clearPatch, label) {
|
|
|
15971
16027
|
const { orm } = found;
|
|
15972
16028
|
const itemId2 = found.item.id;
|
|
15973
16029
|
if (options2.clear) {
|
|
15974
|
-
await orm.update(items).set(clearPatch).where(
|
|
16030
|
+
await orm.update(items).set(clearPatch).where(eq30(items.id, itemId2));
|
|
15975
16031
|
console.log(
|
|
15976
16032
|
chalk44.green(
|
|
15977
16033
|
`Cleared ${label} association on item ${formatItemId(itemId2)}.`
|
|
@@ -16039,7 +16095,7 @@ async function associateGithub(id, issue, options2) {
|
|
|
16039
16095
|
return;
|
|
16040
16096
|
}
|
|
16041
16097
|
const title = fetchGithubIssueTitle(normalized);
|
|
16042
|
-
await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(
|
|
16098
|
+
await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(eq31(items.id, itemId2));
|
|
16043
16099
|
console.log(
|
|
16044
16100
|
chalk45.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
|
|
16045
16101
|
title ? chalk45.dim(`(${title})`) : ""
|
|
@@ -16053,7 +16109,7 @@ function registerAssociateGithubCommand(cmd) {
|
|
|
16053
16109
|
|
|
16054
16110
|
// src/commands/backlog/associateJira.ts
|
|
16055
16111
|
import chalk47 from "chalk";
|
|
16056
|
-
import { eq as
|
|
16112
|
+
import { eq as eq32 } from "drizzle-orm";
|
|
16057
16113
|
|
|
16058
16114
|
// src/commands/jira/fetchIssue.ts
|
|
16059
16115
|
import { execSync as execSync17 } from "child_process";
|
|
@@ -16118,7 +16174,7 @@ async function associateJira(id, key, options2) {
|
|
|
16118
16174
|
const parsed = fetchIssue(normalized, "summary");
|
|
16119
16175
|
const fields = parsed?.fields;
|
|
16120
16176
|
const summary = fields?.summary;
|
|
16121
|
-
await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(
|
|
16177
|
+
await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq32(items.id, itemId2));
|
|
16122
16178
|
console.log(
|
|
16123
16179
|
chalk47.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
|
|
16124
16180
|
summary ? chalk47.dim(`(${summary})`) : ""
|
|
@@ -16654,9 +16710,9 @@ import chalk58 from "chalk";
|
|
|
16654
16710
|
|
|
16655
16711
|
// src/commands/backlog/resolveInsertPosition.ts
|
|
16656
16712
|
import chalk57 from "chalk";
|
|
16657
|
-
import { count as count3, eq as
|
|
16713
|
+
import { count as count3, eq as eq33 } from "drizzle-orm";
|
|
16658
16714
|
async function resolveInsertPosition(orm, itemId2, position) {
|
|
16659
|
-
const [row3] = await orm.select({ cnt: count3() }).from(planPhases).where(
|
|
16715
|
+
const [row3] = await orm.select({ cnt: count3() }).from(planPhases).where(eq33(planPhases.itemId, itemId2));
|
|
16660
16716
|
const phaseCount = row3?.cnt ?? 0;
|
|
16661
16717
|
if (position === void 0) return phaseCount;
|
|
16662
16718
|
const pos = Number.parseInt(position, 10);
|
|
@@ -17039,9 +17095,9 @@ function hasCycle(adjacency, fromId, toId) {
|
|
|
17039
17095
|
}
|
|
17040
17096
|
|
|
17041
17097
|
// src/commands/backlog/loadDependencyGraph.ts
|
|
17042
|
-
import { eq as
|
|
17098
|
+
import { eq as eq34 } from "drizzle-orm";
|
|
17043
17099
|
async function loadDependencyGraph(orm) {
|
|
17044
|
-
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(
|
|
17100
|
+
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq34(links.type, "depends-on"));
|
|
17045
17101
|
const graph = /* @__PURE__ */ new Map();
|
|
17046
17102
|
for (const { itemId: itemId2, targetId } of rows) {
|
|
17047
17103
|
const bucket = graph.get(itemId2);
|
|
@@ -17108,7 +17164,7 @@ async function link(fromId, toId, opts) {
|
|
|
17108
17164
|
|
|
17109
17165
|
// src/commands/backlog/unlink.ts
|
|
17110
17166
|
import chalk65 from "chalk";
|
|
17111
|
-
import { and as and12, eq as
|
|
17167
|
+
import { and as and12, eq as eq35 } from "drizzle-orm";
|
|
17112
17168
|
async function unlink(fromId, toId) {
|
|
17113
17169
|
const fromNum = parseItemId(fromId);
|
|
17114
17170
|
const toNum = parseItemId(toId);
|
|
@@ -17132,7 +17188,7 @@ async function unlink(fromId, toId) {
|
|
|
17132
17188
|
);
|
|
17133
17189
|
return;
|
|
17134
17190
|
}
|
|
17135
|
-
await orm.delete(links).where(and12(
|
|
17191
|
+
await orm.delete(links).where(and12(eq35(links.itemId, fromNum), eq35(links.targetId, toNum)));
|
|
17136
17192
|
console.log(
|
|
17137
17193
|
chalk65.green(
|
|
17138
17194
|
`Removed link from ${formatItemId(fromNum)} to ${formatItemId(toNum)}.`
|
|
@@ -17152,7 +17208,7 @@ function registerLinkCommands(cmd) {
|
|
|
17152
17208
|
|
|
17153
17209
|
// src/commands/backlog/moveRepo.ts
|
|
17154
17210
|
import chalk67 from "chalk";
|
|
17155
|
-
import { eq as
|
|
17211
|
+
import { eq as eq37 } from "drizzle-orm";
|
|
17156
17212
|
|
|
17157
17213
|
// src/commands/backlog/move-repo/confirmMove.ts
|
|
17158
17214
|
import chalk66 from "chalk";
|
|
@@ -17167,9 +17223,9 @@ async function confirmMove(cnt, oldOrigin, newOrigin) {
|
|
|
17167
17223
|
}
|
|
17168
17224
|
|
|
17169
17225
|
// src/commands/backlog/move-repo/countByOrigin.ts
|
|
17170
|
-
import { count as count4, eq as
|
|
17226
|
+
import { count as count4, eq as eq36 } from "drizzle-orm";
|
|
17171
17227
|
async function countByOrigin(orm, origin) {
|
|
17172
|
-
const [{ cnt }] = await orm.select({ cnt: count4() }).from(items).where(
|
|
17228
|
+
const [{ cnt }] = await orm.select({ cnt: count4() }).from(items).where(eq36(items.origin, origin));
|
|
17173
17229
|
return cnt;
|
|
17174
17230
|
}
|
|
17175
17231
|
|
|
@@ -17212,7 +17268,7 @@ async function moveRepo(oldOriginRaw, newOriginRaw, options2 = {}) {
|
|
|
17212
17268
|
console.log(chalk67.yellow("Move cancelled; no changes made."));
|
|
17213
17269
|
return;
|
|
17214
17270
|
}
|
|
17215
|
-
await orm.update(items).set({ origin: newOrigin }).where(
|
|
17271
|
+
await orm.update(items).set({ origin: newOrigin }).where(eq37(items.origin, oldOrigin));
|
|
17216
17272
|
console.log(
|
|
17217
17273
|
chalk67.green(
|
|
17218
17274
|
`Moved ${pluralItems(cnt)} from "${oldOrigin}" to "${newOrigin}".`
|
|
@@ -17684,12 +17740,12 @@ function message(error) {
|
|
|
17684
17740
|
import chalk71 from "chalk";
|
|
17685
17741
|
|
|
17686
17742
|
// src/shared/db/findPhaseBySessionId.ts
|
|
17687
|
-
import { and as and13, eq as
|
|
17743
|
+
import { and as and13, eq as eq38 } from "drizzle-orm";
|
|
17688
17744
|
async function findPhaseBySessionId(db, itemId2, claudeSessionId) {
|
|
17689
17745
|
const rows = await db.select({ phaseIdx: phaseUsage.phaseIdx }).from(phaseUsage).where(
|
|
17690
17746
|
and13(
|
|
17691
|
-
|
|
17692
|
-
|
|
17747
|
+
eq38(phaseUsage.itemId, itemId2),
|
|
17748
|
+
eq38(phaseUsage.claudeSessionId, claudeSessionId)
|
|
17693
17749
|
)
|
|
17694
17750
|
).limit(1);
|
|
17695
17751
|
return rows[0]?.phaseIdx;
|
|
@@ -19169,10 +19225,10 @@ async function start(id) {
|
|
|
19169
19225
|
|
|
19170
19226
|
// src/commands/backlog/stop.ts
|
|
19171
19227
|
import chalk94 from "chalk";
|
|
19172
|
-
import { and as and14, eq as
|
|
19228
|
+
import { and as and14, eq as eq39 } from "drizzle-orm";
|
|
19173
19229
|
async function stop() {
|
|
19174
19230
|
const { orm } = await getReady();
|
|
19175
|
-
const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and14(
|
|
19231
|
+
const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and14(eq39(items.status, "in-progress"), eq39(items.origin, getOrigin()))).returning({ id: items.id, name: items.name });
|
|
19176
19232
|
if (stopped.length === 0) {
|
|
19177
19233
|
console.log(chalk94.yellow("No in-progress items to stop."));
|
|
19178
19234
|
return;
|
|
@@ -19230,20 +19286,20 @@ function registerStatusCommands(cmd) {
|
|
|
19230
19286
|
|
|
19231
19287
|
// src/commands/backlog/movePhase.ts
|
|
19232
19288
|
import chalk97 from "chalk";
|
|
19233
|
-
import { count as count6, eq as
|
|
19289
|
+
import { count as count6, eq as eq42 } from "drizzle-orm";
|
|
19234
19290
|
|
|
19235
19291
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
19236
|
-
import { and as and16, asc as asc11, eq as
|
|
19292
|
+
import { and as and16, asc as asc11, eq as eq41 } from "drizzle-orm";
|
|
19237
19293
|
|
|
19238
19294
|
// src/commands/backlog/reindexPhases.ts
|
|
19239
|
-
import { and as and15, asc as asc10, count as count5, eq as
|
|
19295
|
+
import { and as and15, asc as asc10, count as count5, eq as eq40 } from "drizzle-orm";
|
|
19240
19296
|
async function reindexPhases(db, itemId2) {
|
|
19241
|
-
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(
|
|
19297
|
+
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq40(planPhases.itemId, itemId2)).orderBy(asc10(planPhases.idx));
|
|
19242
19298
|
for (let i = 0; i < remaining.length; i++) {
|
|
19243
19299
|
const oldIdx = remaining[i].idx;
|
|
19244
19300
|
if (oldIdx === i) continue;
|
|
19245
|
-
await db.update(planTasks).set({ phaseIdx: i }).where(and15(
|
|
19246
|
-
await db.update(planPhases).set({ idx: i }).where(and15(
|
|
19301
|
+
await db.update(planTasks).set({ phaseIdx: i }).where(and15(eq40(planTasks.itemId, itemId2), eq40(planTasks.phaseIdx, oldIdx)));
|
|
19302
|
+
await db.update(planPhases).set({ idx: i }).where(and15(eq40(planPhases.itemId, itemId2), eq40(planPhases.idx, oldIdx)));
|
|
19247
19303
|
}
|
|
19248
19304
|
}
|
|
19249
19305
|
async function adjustCurrentPhase(db, item, removedIdx) {
|
|
@@ -19251,24 +19307,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
|
|
|
19251
19307
|
if (currentPhase === void 0) return;
|
|
19252
19308
|
const currentIdx = currentPhase - 1;
|
|
19253
19309
|
if (removedIdx < currentIdx) {
|
|
19254
|
-
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(
|
|
19310
|
+
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq40(items.id, item.id));
|
|
19255
19311
|
return;
|
|
19256
19312
|
}
|
|
19257
19313
|
if (removedIdx !== currentIdx) return;
|
|
19258
|
-
const [row3] = await db.select({ cnt: count5() }).from(planPhases).where(
|
|
19314
|
+
const [row3] = await db.select({ cnt: count5() }).from(planPhases).where(eq40(planPhases.itemId, item.id));
|
|
19259
19315
|
const cnt = row3?.cnt ?? 0;
|
|
19260
|
-
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(
|
|
19316
|
+
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq40(items.id, item.id));
|
|
19261
19317
|
}
|
|
19262
19318
|
|
|
19263
19319
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
19264
19320
|
async function reorderPhaseRows(orm, itemId2, fromIdx, toIdx) {
|
|
19265
19321
|
await orm.transaction(async (tx) => {
|
|
19266
|
-
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and16(
|
|
19267
|
-
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and16(
|
|
19322
|
+
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and16(eq41(planPhases.itemId, itemId2), eq41(planPhases.idx, fromIdx)));
|
|
19323
|
+
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and16(eq41(planTasks.itemId, itemId2), eq41(planTasks.phaseIdx, fromIdx))).orderBy(asc11(planTasks.idx));
|
|
19268
19324
|
await tx.delete(planTasks).where(
|
|
19269
|
-
and16(
|
|
19325
|
+
and16(eq41(planTasks.itemId, itemId2), eq41(planTasks.phaseIdx, fromIdx))
|
|
19270
19326
|
);
|
|
19271
|
-
await tx.delete(planPhases).where(and16(
|
|
19327
|
+
await tx.delete(planPhases).where(and16(eq41(planPhases.itemId, itemId2), eq41(planPhases.idx, fromIdx)));
|
|
19272
19328
|
await reindexPhases(tx, itemId2);
|
|
19273
19329
|
await shiftPhasesUp(tx, itemId2, toIdx);
|
|
19274
19330
|
await tx.insert(planPhases).values({
|
|
@@ -19309,7 +19365,7 @@ async function movePhase(id, from, to) {
|
|
|
19309
19365
|
if (!found) return;
|
|
19310
19366
|
const { orm, item } = found;
|
|
19311
19367
|
const itemId2 = item.id;
|
|
19312
|
-
const [row3] = await orm.select({ cnt: count6() }).from(planPhases).where(
|
|
19368
|
+
const [row3] = await orm.select({ cnt: count6() }).from(planPhases).where(eq42(planPhases.itemId, itemId2));
|
|
19313
19369
|
const phaseCount = row3?.cnt ?? 0;
|
|
19314
19370
|
const fromIdx = toIndex2(from, phaseCount);
|
|
19315
19371
|
if (fromIdx === void 0) return;
|
|
@@ -19325,22 +19381,22 @@ async function movePhase(id, from, to) {
|
|
|
19325
19381
|
import chalk99 from "chalk";
|
|
19326
19382
|
|
|
19327
19383
|
// src/commands/backlog/applyPhaseUpdate.ts
|
|
19328
|
-
import { and as and17, eq as
|
|
19384
|
+
import { and as and17, eq as eq43 } from "drizzle-orm";
|
|
19329
19385
|
async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
|
|
19330
19386
|
await orm.transaction(async (tx) => {
|
|
19331
19387
|
if (fields.name) {
|
|
19332
19388
|
await tx.update(planPhases).set({ name: fields.name }).where(
|
|
19333
|
-
and17(
|
|
19389
|
+
and17(eq43(planPhases.itemId, itemId2), eq43(planPhases.idx, phaseIdx))
|
|
19334
19390
|
);
|
|
19335
19391
|
}
|
|
19336
19392
|
if (fields.manualCheck) {
|
|
19337
19393
|
await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
|
|
19338
|
-
and17(
|
|
19394
|
+
and17(eq43(planPhases.itemId, itemId2), eq43(planPhases.idx, phaseIdx))
|
|
19339
19395
|
);
|
|
19340
19396
|
}
|
|
19341
19397
|
if (fields.task) {
|
|
19342
19398
|
await tx.delete(planTasks).where(
|
|
19343
|
-
and17(
|
|
19399
|
+
and17(eq43(planTasks.itemId, itemId2), eq43(planTasks.phaseIdx, phaseIdx))
|
|
19344
19400
|
);
|
|
19345
19401
|
if (fields.task.length) {
|
|
19346
19402
|
await tx.insert(planTasks).values(
|
|
@@ -19358,14 +19414,14 @@ async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
|
|
|
19358
19414
|
|
|
19359
19415
|
// src/commands/backlog/findPhase.ts
|
|
19360
19416
|
import chalk98 from "chalk";
|
|
19361
|
-
import { and as and18, count as count7, eq as
|
|
19417
|
+
import { and as and18, count as count7, eq as eq44 } from "drizzle-orm";
|
|
19362
19418
|
async function findPhase(id, phase) {
|
|
19363
19419
|
const found = await findOneItem(id);
|
|
19364
19420
|
if (!found) return void 0;
|
|
19365
19421
|
const { orm, item } = found;
|
|
19366
19422
|
const itemId2 = item.id;
|
|
19367
19423
|
const phaseIdx = Number.parseInt(phase, 10) - 1;
|
|
19368
|
-
const [row3] = await orm.select({ cnt: count7() }).from(planPhases).where(and18(
|
|
19424
|
+
const [row3] = await orm.select({ cnt: count7() }).from(planPhases).where(and18(eq44(planPhases.itemId, itemId2), eq44(planPhases.idx, phaseIdx)));
|
|
19369
19425
|
if (!row3 || row3.cnt === 0) {
|
|
19370
19426
|
console.log(
|
|
19371
19427
|
chalk98.red(
|
|
@@ -19538,16 +19594,16 @@ function registerUpdatePhaseCommand(cmd) {
|
|
|
19538
19594
|
|
|
19539
19595
|
// src/commands/backlog/removePhase.ts
|
|
19540
19596
|
import chalk100 from "chalk";
|
|
19541
|
-
import { and as and19, eq as
|
|
19597
|
+
import { and as and19, eq as eq45 } from "drizzle-orm";
|
|
19542
19598
|
async function removePhase(id, phase) {
|
|
19543
19599
|
const found = await findPhase(id, phase);
|
|
19544
19600
|
if (!found) return;
|
|
19545
19601
|
const { item, orm, itemId: itemId2, phaseIdx } = found;
|
|
19546
19602
|
await orm.transaction(async (tx) => {
|
|
19547
19603
|
await tx.delete(planTasks).where(
|
|
19548
|
-
and19(
|
|
19604
|
+
and19(eq45(planTasks.itemId, itemId2), eq45(planTasks.phaseIdx, phaseIdx))
|
|
19549
19605
|
);
|
|
19550
|
-
await tx.delete(planPhases).where(and19(
|
|
19606
|
+
await tx.delete(planPhases).where(and19(eq45(planPhases.itemId, itemId2), eq45(planPhases.idx, phaseIdx)));
|
|
19551
19607
|
await reindexPhases(tx, itemId2);
|
|
19552
19608
|
await adjustCurrentPhase(tx, item, phaseIdx);
|
|
19553
19609
|
});
|
|
@@ -19560,7 +19616,7 @@ async function removePhase(id, phase) {
|
|
|
19560
19616
|
|
|
19561
19617
|
// src/commands/backlog/update/update.ts
|
|
19562
19618
|
import chalk104 from "chalk";
|
|
19563
|
-
import { eq as
|
|
19619
|
+
import { eq as eq46 } from "drizzle-orm";
|
|
19564
19620
|
|
|
19565
19621
|
// src/commands/backlog/update/buildUpdateValues.ts
|
|
19566
19622
|
import chalk101 from "chalk";
|
|
@@ -19671,7 +19727,7 @@ async function update(id, options2) {
|
|
|
19671
19727
|
if (!built) return;
|
|
19672
19728
|
const { orm } = found;
|
|
19673
19729
|
const itemId2 = found.item.id;
|
|
19674
|
-
await orm.update(items).set(built.set).where(
|
|
19730
|
+
await orm.update(items).set(built.set).where(eq46(items.id, itemId2));
|
|
19675
19731
|
console.log(
|
|
19676
19732
|
chalk104.green(`Updated ${built.fields} on item ${formatItemId(itemId2)}.`)
|
|
19677
19733
|
);
|
|
@@ -19717,7 +19773,7 @@ function readPlanUpdate(source) {
|
|
|
19717
19773
|
}
|
|
19718
19774
|
|
|
19719
19775
|
// src/commands/backlog/updatePlan/replacePlan.ts
|
|
19720
|
-
import { eq as
|
|
19776
|
+
import { eq as eq47 } from "drizzle-orm";
|
|
19721
19777
|
|
|
19722
19778
|
// src/commands/backlog/updatePlan/clampCurrentPhase.ts
|
|
19723
19779
|
function clampCurrentPhase(currentPhase, phaseCount) {
|
|
@@ -19728,8 +19784,8 @@ function clampCurrentPhase(currentPhase, phaseCount) {
|
|
|
19728
19784
|
// src/commands/backlog/updatePlan/replacePlan.ts
|
|
19729
19785
|
async function replacePlan(orm, itemId2, phases, currentPhase) {
|
|
19730
19786
|
await orm.transaction(async (tx) => {
|
|
19731
|
-
await tx.delete(planTasks).where(
|
|
19732
|
-
await tx.delete(planPhases).where(
|
|
19787
|
+
await tx.delete(planTasks).where(eq47(planTasks.itemId, itemId2));
|
|
19788
|
+
await tx.delete(planPhases).where(eq47(planPhases.itemId, itemId2));
|
|
19733
19789
|
if (phases.length > 0) {
|
|
19734
19790
|
await tx.insert(planPhases).values(
|
|
19735
19791
|
phases.map((phase, idx) => ({
|
|
@@ -19747,7 +19803,7 @@ async function replacePlan(orm, itemId2, phases, currentPhase) {
|
|
|
19747
19803
|
if (currentPhase === void 0) return;
|
|
19748
19804
|
const clamped = clampCurrentPhase(currentPhase, phases.length);
|
|
19749
19805
|
if (clamped === currentPhase) return;
|
|
19750
|
-
await tx.update(items).set({ currentPhase: clamped }).where(
|
|
19806
|
+
await tx.update(items).set({ currentPhase: clamped }).where(eq47(items.id, itemId2));
|
|
19751
19807
|
});
|
|
19752
19808
|
}
|
|
19753
19809
|
|
|
@@ -28379,14 +28435,6 @@ async function list3() {
|
|
|
28379
28435
|
// src/commands/inbox/scan.ts
|
|
28380
28436
|
import chalk177 from "chalk";
|
|
28381
28437
|
|
|
28382
|
-
// src/shared/db/readInboxLastScan.ts
|
|
28383
|
-
import { eq as eq47 } from "drizzle-orm";
|
|
28384
|
-
var INBOX_LAST_SCAN_KEY = "inbox.lastScanAt";
|
|
28385
|
-
async function readInboxLastScan(orm) {
|
|
28386
|
-
const [row3] = await orm.select().from(metadata).where(eq47(metadata.key, INBOX_LAST_SCAN_KEY));
|
|
28387
|
-
return row3 ? new Date(row3.value) : void 0;
|
|
28388
|
-
}
|
|
28389
|
-
|
|
28390
28438
|
// src/shared/db/upsertInboxMessages.ts
|
|
28391
28439
|
async function upsertInboxMessages(orm, messages) {
|
|
28392
28440
|
if (messages.length === 0) return 0;
|
|
@@ -33856,10 +33904,10 @@ async function getAccessToken(apiKey) {
|
|
|
33856
33904
|
}
|
|
33857
33905
|
});
|
|
33858
33906
|
if (!response.ok) {
|
|
33859
|
-
const
|
|
33907
|
+
const errorText = await response.text();
|
|
33860
33908
|
throw new Error(
|
|
33861
33909
|
`Failed to get access token: ${response.status} ${response.statusText}
|
|
33862
|
-
${
|
|
33910
|
+
${errorText}`
|
|
33863
33911
|
);
|
|
33864
33912
|
}
|
|
33865
33913
|
const tokenData = await response.json();
|
|
@@ -46063,6 +46111,104 @@ function createAutoExit(exit, graceMs = DEFAULT_GRACE_MS) {
|
|
|
46063
46111
|
};
|
|
46064
46112
|
}
|
|
46065
46113
|
|
|
46114
|
+
// src/commands/sessions/daemon/inbox/isInboxScanDue.ts
|
|
46115
|
+
async function isInboxScanDue(intervalMinutes) {
|
|
46116
|
+
const last = await readInboxLastScan(await getDb());
|
|
46117
|
+
return !last || Date.now() - last.getTime() >= intervalMinutes * 6e4;
|
|
46118
|
+
}
|
|
46119
|
+
|
|
46120
|
+
// src/commands/inbox/readInboxIntervalMinutes.ts
|
|
46121
|
+
function readInboxIntervalMinutes(globalConfigPath) {
|
|
46122
|
+
const raw = loadGlobalConfigRaw(globalConfigPath);
|
|
46123
|
+
return assistConfigSchema.shape.inbox.parse(raw.inbox)?.intervalMinutes;
|
|
46124
|
+
}
|
|
46125
|
+
|
|
46126
|
+
// src/commands/sessions/daemon/inbox/readInboxSchedule.ts
|
|
46127
|
+
function readInboxSchedule() {
|
|
46128
|
+
let minutes;
|
|
46129
|
+
try {
|
|
46130
|
+
minutes = readInboxIntervalMinutes();
|
|
46131
|
+
} catch (error) {
|
|
46132
|
+
const reason4 = error instanceof Error ? error.message : String(error);
|
|
46133
|
+
return { description: `off (invalid inbox.intervalMinutes: ${reason4})` };
|
|
46134
|
+
}
|
|
46135
|
+
if (!minutes) return { description: "off (inbox.intervalMinutes unset)" };
|
|
46136
|
+
if (!process.env.ASSIST_DATABASE_URL && !loadConfig().database.url)
|
|
46137
|
+
return { description: "off (no database configured)" };
|
|
46138
|
+
return {
|
|
46139
|
+
intervalMinutes: minutes,
|
|
46140
|
+
description: `every ${minutes} minute(s)`
|
|
46141
|
+
};
|
|
46142
|
+
}
|
|
46143
|
+
|
|
46144
|
+
// src/commands/sessions/daemon/inbox/runLoggedInboxScan.ts
|
|
46145
|
+
async function runLoggedInboxScan(reason4) {
|
|
46146
|
+
daemonLog(`inbox: scan started (${reason4})`);
|
|
46147
|
+
try {
|
|
46148
|
+
const { flagged, added } = await runInboxScan(await getDb());
|
|
46149
|
+
daemonLog(`inbox: scan flagged ${flagged} message(s), ${added} new`);
|
|
46150
|
+
return void 0;
|
|
46151
|
+
} catch (error) {
|
|
46152
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
46153
|
+
daemonLog(`inbox: scan failed: ${message3}`);
|
|
46154
|
+
return message3;
|
|
46155
|
+
}
|
|
46156
|
+
}
|
|
46157
|
+
|
|
46158
|
+
// src/commands/sessions/daemon/inbox/createInboxScanner.ts
|
|
46159
|
+
var CHECK_MS = 6e4;
|
|
46160
|
+
function createInboxScanner() {
|
|
46161
|
+
let scanning = false;
|
|
46162
|
+
let lastError;
|
|
46163
|
+
let schedule = { description: "not started" };
|
|
46164
|
+
let notify2 = () => {
|
|
46165
|
+
};
|
|
46166
|
+
const scan2 = async (reason4) => {
|
|
46167
|
+
scanning = true;
|
|
46168
|
+
notify2();
|
|
46169
|
+
lastError = await runLoggedInboxScan(reason4);
|
|
46170
|
+
scanning = false;
|
|
46171
|
+
notify2();
|
|
46172
|
+
};
|
|
46173
|
+
const tick = async () => {
|
|
46174
|
+
const next3 = readInboxSchedule();
|
|
46175
|
+
if (next3.description !== schedule.description)
|
|
46176
|
+
daemonLog(`inbox: scheduled scans ${next3.description}`);
|
|
46177
|
+
schedule = next3;
|
|
46178
|
+
if (!schedule.intervalMinutes || scanning) return;
|
|
46179
|
+
try {
|
|
46180
|
+
if (await isInboxScanDue(schedule.intervalMinutes))
|
|
46181
|
+
await scan2("scheduled");
|
|
46182
|
+
} catch (error) {
|
|
46183
|
+
daemonLog(`inbox: reading the last scan time failed: ${String(error)}`);
|
|
46184
|
+
}
|
|
46185
|
+
};
|
|
46186
|
+
return {
|
|
46187
|
+
start(onChange) {
|
|
46188
|
+
notify2 = onChange;
|
|
46189
|
+
void tick();
|
|
46190
|
+
const timer = setInterval(() => void tick(), CHECK_MS);
|
|
46191
|
+
timer.unref();
|
|
46192
|
+
return () => clearInterval(timer);
|
|
46193
|
+
},
|
|
46194
|
+
scanNow() {
|
|
46195
|
+
if (scanning) return false;
|
|
46196
|
+
void scan2("requested");
|
|
46197
|
+
return true;
|
|
46198
|
+
},
|
|
46199
|
+
status() {
|
|
46200
|
+
return {
|
|
46201
|
+
scanning,
|
|
46202
|
+
intervalMinutes: schedule.intervalMinutes ?? null,
|
|
46203
|
+
lastError: lastError ?? null
|
|
46204
|
+
};
|
|
46205
|
+
}
|
|
46206
|
+
};
|
|
46207
|
+
}
|
|
46208
|
+
|
|
46209
|
+
// src/commands/sessions/daemon/inbox/inboxScanner.ts
|
|
46210
|
+
var inboxScanner = createInboxScanner();
|
|
46211
|
+
|
|
46066
46212
|
// src/commands/sessions/daemon/pollRepoConfigCache.ts
|
|
46067
46213
|
var POLL_MS = 6e4;
|
|
46068
46214
|
function cacheSnapshot() {
|
|
@@ -53110,6 +53256,16 @@ var handleTypePromptToWriter = (client, m, d) => {
|
|
|
53110
53256
|
});
|
|
53111
53257
|
};
|
|
53112
53258
|
|
|
53259
|
+
// src/commands/sessions/daemon/inbox/inboxHandlers.ts
|
|
53260
|
+
var inboxHandlers = {
|
|
53261
|
+
"inbox-status": (client) => sendTo(client, { type: "inbox-status", ...inboxScanner.status() }),
|
|
53262
|
+
"inbox-scan": (client) => {
|
|
53263
|
+
const started = inboxScanner.scanNow();
|
|
53264
|
+
if (!started) daemonLog("inbox: scan requested while one is running");
|
|
53265
|
+
sendTo(client, { type: "inbox-scan", started });
|
|
53266
|
+
}
|
|
53267
|
+
};
|
|
53268
|
+
|
|
53113
53269
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
53114
53270
|
import * as fs56 from "fs";
|
|
53115
53271
|
|
|
@@ -53432,6 +53588,7 @@ var messageHandlers = {
|
|
|
53432
53588
|
"auto-update": (client) => sendTo(client, autoUpdateReply()),
|
|
53433
53589
|
"auto-update-control": handleAutoUpdateControl,
|
|
53434
53590
|
"search-history": (client, _m, d) => handleSearchHistory(client, d),
|
|
53591
|
+
...inboxHandlers,
|
|
53435
53592
|
"reload-links": (client, m) => {
|
|
53436
53593
|
daemonLog("reload-links received");
|
|
53437
53594
|
m.links.reload();
|
|
@@ -53647,85 +53804,6 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
53647
53804
|
listenWithSingleOnListening(server, manager, checkAutoExit);
|
|
53648
53805
|
}
|
|
53649
53806
|
|
|
53650
|
-
// src/commands/sessions/daemon/inbox/firstDelayMs.ts
|
|
53651
|
-
async function firstDelayMs(intervalMs) {
|
|
53652
|
-
try {
|
|
53653
|
-
const last = await readInboxLastScan(await getDb());
|
|
53654
|
-
if (!last) return 0;
|
|
53655
|
-
return Math.max(0, last.getTime() + intervalMs - Date.now());
|
|
53656
|
-
} catch (error) {
|
|
53657
|
-
daemonLog(`inbox: reading the last scan time failed: ${errorText(error)}`);
|
|
53658
|
-
return intervalMs;
|
|
53659
|
-
}
|
|
53660
|
-
}
|
|
53661
|
-
function errorText(error) {
|
|
53662
|
-
return error instanceof Error ? error.message : String(error);
|
|
53663
|
-
}
|
|
53664
|
-
|
|
53665
|
-
// src/commands/inbox/readInboxIntervalMinutes.ts
|
|
53666
|
-
function readInboxIntervalMinutes(globalConfigPath) {
|
|
53667
|
-
const raw = loadGlobalConfigRaw(globalConfigPath);
|
|
53668
|
-
return assistConfigSchema.shape.inbox.parse(raw.inbox)?.intervalMinutes;
|
|
53669
|
-
}
|
|
53670
|
-
|
|
53671
|
-
// src/commands/sessions/daemon/inbox/intervalMinutes.ts
|
|
53672
|
-
function intervalMinutes() {
|
|
53673
|
-
try {
|
|
53674
|
-
return readInboxIntervalMinutes();
|
|
53675
|
-
} catch (error) {
|
|
53676
|
-
daemonLog(
|
|
53677
|
-
`inbox: ignoring invalid inbox.intervalMinutes: ${errorText2(error)}`
|
|
53678
|
-
);
|
|
53679
|
-
return void 0;
|
|
53680
|
-
}
|
|
53681
|
-
}
|
|
53682
|
-
function errorText2(error) {
|
|
53683
|
-
return error instanceof Error ? error.message : String(error);
|
|
53684
|
-
}
|
|
53685
|
-
|
|
53686
|
-
// src/commands/sessions/daemon/startInboxScans.ts
|
|
53687
|
-
function errorText3(error) {
|
|
53688
|
-
return error instanceof Error ? error.message : String(error);
|
|
53689
|
-
}
|
|
53690
|
-
function startInboxScans(onAdded) {
|
|
53691
|
-
const minutes = intervalMinutes();
|
|
53692
|
-
if (!minutes) {
|
|
53693
|
-
daemonLog("inbox: scheduled scans off (inbox.intervalMinutes unset)");
|
|
53694
|
-
return () => {
|
|
53695
|
-
};
|
|
53696
|
-
}
|
|
53697
|
-
if (!process.env.ASSIST_DATABASE_URL && !loadConfig().database.url) {
|
|
53698
|
-
daemonLog("inbox: scheduled scans off (no database configured)");
|
|
53699
|
-
return () => {
|
|
53700
|
-
};
|
|
53701
|
-
}
|
|
53702
|
-
const intervalMs = minutes * 6e4;
|
|
53703
|
-
let timer;
|
|
53704
|
-
let stopped = false;
|
|
53705
|
-
const schedule = (delayMs) => {
|
|
53706
|
-
if (stopped) return;
|
|
53707
|
-
timer = setTimeout(() => void tick(), delayMs);
|
|
53708
|
-
timer.unref();
|
|
53709
|
-
};
|
|
53710
|
-
const tick = async () => {
|
|
53711
|
-
daemonLog("inbox: scan started");
|
|
53712
|
-
try {
|
|
53713
|
-
const { flagged, added } = await runInboxScan(await getDb());
|
|
53714
|
-
daemonLog(`inbox: scan flagged ${flagged} message(s), ${added} new`);
|
|
53715
|
-
if (added > 0) onAdded();
|
|
53716
|
-
} catch (error) {
|
|
53717
|
-
daemonLog(`inbox: scan failed: ${errorText3(error)}`);
|
|
53718
|
-
}
|
|
53719
|
-
schedule(intervalMs);
|
|
53720
|
-
};
|
|
53721
|
-
daemonLog(`inbox: scanning every ${minutes} minute(s)`);
|
|
53722
|
-
void firstDelayMs(intervalMs).then(schedule);
|
|
53723
|
-
return () => {
|
|
53724
|
-
stopped = true;
|
|
53725
|
-
clearTimeout(timer);
|
|
53726
|
-
};
|
|
53727
|
-
}
|
|
53728
|
-
|
|
53729
53807
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
53730
53808
|
async function runDaemon() {
|
|
53731
53809
|
mkdirSync41(daemonPaths.dir, { recursive: true });
|
|
@@ -53745,7 +53823,7 @@ async function runDaemon() {
|
|
|
53745
53823
|
setDaemonLogSink(manager.clients.emitLog);
|
|
53746
53824
|
startDaemonLogTrimmer();
|
|
53747
53825
|
pollRepoConfigCache();
|
|
53748
|
-
|
|
53826
|
+
inboxScanner.start(() => broadcast(manager.clients, { type: "inbox" }));
|
|
53749
53827
|
await startDaemonServer(manager, checkAutoExit);
|
|
53750
53828
|
await refreshRepoConfigCacheOnStart();
|
|
53751
53829
|
}
|