@staff0rd/assist 0.449.0 → 0.451.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/README.md +2 -2
- package/dist/commands/sessions/web/bundle.js +360 -360
- package/dist/index.js +224 -112
- 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.451.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1770,6 +1770,8 @@ function collectCommitRefs(message2) {
|
|
|
1770
1770
|
const subject = message2.split("\n", 1)[0];
|
|
1771
1771
|
if (subject) ref.title = subject;
|
|
1772
1772
|
refs.push(ref);
|
|
1773
|
+
const parent = git("rev-parse HEAD^");
|
|
1774
|
+
if (parent) refs.push({ kind: "commit-parent", ref: parent });
|
|
1773
1775
|
}
|
|
1774
1776
|
return refs;
|
|
1775
1777
|
}
|
|
@@ -3715,9 +3717,9 @@ function forbiddenStrings() {
|
|
|
3715
3717
|
console.log("No forbidden-strings rules configured.");
|
|
3716
3718
|
process.exit(0);
|
|
3717
3719
|
}
|
|
3718
|
-
const
|
|
3720
|
+
const cache4 = /* @__PURE__ */ new Map();
|
|
3719
3721
|
const readJson = (file) => {
|
|
3720
|
-
if (
|
|
3722
|
+
if (cache4.has(file)) return cache4.get(file);
|
|
3721
3723
|
if (!existsSync12(file)) {
|
|
3722
3724
|
console.log(`Forbidden-strings file not found: ${file}`);
|
|
3723
3725
|
process.exit(1);
|
|
@@ -3729,7 +3731,7 @@ function forbiddenStrings() {
|
|
|
3729
3731
|
console.log(`Could not parse ${file}: ${error.message}`);
|
|
3730
3732
|
process.exit(1);
|
|
3731
3733
|
}
|
|
3732
|
-
|
|
3734
|
+
cache4.set(file, parsed);
|
|
3733
3735
|
return parsed;
|
|
3734
3736
|
};
|
|
3735
3737
|
const violations = findForbiddenStrings(rules, readJson);
|
|
@@ -5190,6 +5192,14 @@ function pullIfConfigured() {
|
|
|
5190
5192
|
);
|
|
5191
5193
|
return;
|
|
5192
5194
|
}
|
|
5195
|
+
if (!hasUpstream()) {
|
|
5196
|
+
console.warn(
|
|
5197
|
+
chalk32.yellow(
|
|
5198
|
+
"git pull skipped: the current branch has no upstream. Continuing."
|
|
5199
|
+
)
|
|
5200
|
+
);
|
|
5201
|
+
return;
|
|
5202
|
+
}
|
|
5193
5203
|
try {
|
|
5194
5204
|
execSync24("git pull --ff-only", { stdio: "inherit" });
|
|
5195
5205
|
} catch {
|
|
@@ -5197,6 +5207,17 @@ function pullIfConfigured() {
|
|
|
5197
5207
|
process.exit(1);
|
|
5198
5208
|
}
|
|
5199
5209
|
}
|
|
5210
|
+
function hasUpstream() {
|
|
5211
|
+
try {
|
|
5212
|
+
execSync24("git rev-parse --abbrev-ref --symbolic-full-name @{upstream}", {
|
|
5213
|
+
encoding: "utf8",
|
|
5214
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
5215
|
+
});
|
|
5216
|
+
return true;
|
|
5217
|
+
} catch {
|
|
5218
|
+
return false;
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5200
5221
|
function hasLocalChanges() {
|
|
5201
5222
|
try {
|
|
5202
5223
|
const status3 = execSync24("git status --porcelain", {
|
|
@@ -6091,7 +6112,13 @@ var backlogCommentSchema = z3.strictObject({
|
|
|
6091
6112
|
timestamp: z3.string(),
|
|
6092
6113
|
type: backlogCommentTypeSchema
|
|
6093
6114
|
});
|
|
6094
|
-
var gitRefKindSchema = z3.enum([
|
|
6115
|
+
var gitRefKindSchema = z3.enum([
|
|
6116
|
+
"branch",
|
|
6117
|
+
"commit",
|
|
6118
|
+
"commit-parent",
|
|
6119
|
+
"pr",
|
|
6120
|
+
"slack"
|
|
6121
|
+
]);
|
|
6095
6122
|
var gitRefSchema = z3.strictObject({
|
|
6096
6123
|
kind: gitRefKindSchema,
|
|
6097
6124
|
ref: z3.string(),
|
|
@@ -8372,19 +8399,19 @@ import { dirname as dirname19, join as join23 } from "path";
|
|
|
8372
8399
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
8373
8400
|
function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
|
|
8374
8401
|
const file = join23(dirname19(fileURLToPath4(importMetaUrl)), bundlePath);
|
|
8375
|
-
let
|
|
8402
|
+
let cache4;
|
|
8376
8403
|
return (req, res) => {
|
|
8377
8404
|
const mtimeMs = statSync2(file).mtimeMs;
|
|
8378
|
-
if (
|
|
8405
|
+
if (cache4?.mtimeMs !== mtimeMs) {
|
|
8379
8406
|
const body = readFileSync19(file, "utf8");
|
|
8380
8407
|
const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
8381
|
-
|
|
8408
|
+
cache4 = { body, etag, mtimeMs };
|
|
8382
8409
|
}
|
|
8383
8410
|
const headers = {
|
|
8384
|
-
ETag:
|
|
8411
|
+
ETag: cache4.etag,
|
|
8385
8412
|
"Cache-Control": "no-cache"
|
|
8386
8413
|
};
|
|
8387
|
-
if (req.headers["if-none-match"] ===
|
|
8414
|
+
if (req.headers["if-none-match"] === cache4.etag) {
|
|
8388
8415
|
res.writeHead(304, headers);
|
|
8389
8416
|
res.end();
|
|
8390
8417
|
return;
|
|
@@ -8393,7 +8420,7 @@ function createBundleHandler(importMetaUrl, bundlePath, contentType = "applicati
|
|
|
8393
8420
|
"Content-Type": contentType,
|
|
8394
8421
|
...headers
|
|
8395
8422
|
});
|
|
8396
|
-
res.end(
|
|
8423
|
+
res.end(cache4.body);
|
|
8397
8424
|
};
|
|
8398
8425
|
}
|
|
8399
8426
|
|
|
@@ -8881,6 +8908,73 @@ function getCwdParam(req, res) {
|
|
|
8881
8908
|
return cwd;
|
|
8882
8909
|
}
|
|
8883
8910
|
|
|
8911
|
+
// src/commands/sessions/web/getSessionParam.ts
|
|
8912
|
+
function getSessionParam(req) {
|
|
8913
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
8914
|
+
return url.searchParams.get("session") ?? void 0;
|
|
8915
|
+
}
|
|
8916
|
+
|
|
8917
|
+
// src/shared/db/findCommitAnchor.ts
|
|
8918
|
+
import { and as and7, asc as asc6, eq as eq16, inArray as inArray3 } from "drizzle-orm";
|
|
8919
|
+
async function findCommitAnchor(db, itemId2) {
|
|
8920
|
+
const rows = await db.select({ kind: itemGitRefs.kind, ref: itemGitRefs.ref }).from(itemGitRefs).where(
|
|
8921
|
+
and7(
|
|
8922
|
+
eq16(itemGitRefs.itemId, itemId2),
|
|
8923
|
+
inArray3(itemGitRefs.kind, ["commit", "commit-parent"])
|
|
8924
|
+
)
|
|
8925
|
+
).orderBy(asc6(itemGitRefs.createdAt));
|
|
8926
|
+
const anchor = {};
|
|
8927
|
+
for (const row of rows) {
|
|
8928
|
+
if (row.kind === "commit") anchor.commit ??= row.ref;
|
|
8929
|
+
else anchor.parent ??= row.ref;
|
|
8930
|
+
}
|
|
8931
|
+
return anchor;
|
|
8932
|
+
}
|
|
8933
|
+
|
|
8934
|
+
// src/shared/db/findItemBySessionId.ts
|
|
8935
|
+
import { asc as asc7, eq as eq17 } from "drizzle-orm";
|
|
8936
|
+
async function findItemBySessionId(db, claudeSessionId) {
|
|
8937
|
+
const rows = await db.select({ itemId: phaseUsage.itemId }).from(phaseUsage).where(eq17(phaseUsage.claudeSessionId, claudeSessionId)).orderBy(asc7(phaseUsage.itemId), asc7(phaseUsage.phaseIdx)).limit(1);
|
|
8938
|
+
return rows[0]?.itemId;
|
|
8939
|
+
}
|
|
8940
|
+
|
|
8941
|
+
// src/commands/sessions/web/sessionCommitAnchor.ts
|
|
8942
|
+
var EMPTY_TTL_MS = 3e4;
|
|
8943
|
+
var cache3 = /* @__PURE__ */ new Map();
|
|
8944
|
+
var inFlight = /* @__PURE__ */ new Map();
|
|
8945
|
+
async function sessionCommitAnchor(sessionId) {
|
|
8946
|
+
const cached = cache3.get(sessionId);
|
|
8947
|
+
if (cached && cached.expiresAt > Date.now()) return cached.anchor;
|
|
8948
|
+
const pending = inFlight.get(sessionId);
|
|
8949
|
+
if (pending) return pending;
|
|
8950
|
+
const lookup = loadAnchor(sessionId).finally(
|
|
8951
|
+
() => inFlight.delete(sessionId)
|
|
8952
|
+
);
|
|
8953
|
+
inFlight.set(sessionId, lookup);
|
|
8954
|
+
return lookup;
|
|
8955
|
+
}
|
|
8956
|
+
async function loadAnchor(sessionId) {
|
|
8957
|
+
const anchor = await queryAnchor(sessionId);
|
|
8958
|
+
const found = Boolean(anchor.commit || anchor.parent);
|
|
8959
|
+
cache3.set(sessionId, {
|
|
8960
|
+
anchor,
|
|
8961
|
+
expiresAt: found ? Number.POSITIVE_INFINITY : Date.now() + EMPTY_TTL_MS
|
|
8962
|
+
});
|
|
8963
|
+
return anchor;
|
|
8964
|
+
}
|
|
8965
|
+
async function queryAnchor(sessionId) {
|
|
8966
|
+
try {
|
|
8967
|
+
if (!process.env.ASSIST_DATABASE_URL && !loadConfig().database.url)
|
|
8968
|
+
return {};
|
|
8969
|
+
const db = await getDb();
|
|
8970
|
+
const itemId2 = await findItemBySessionId(db, sessionId);
|
|
8971
|
+
if (itemId2 === void 0) return {};
|
|
8972
|
+
return await findCommitAnchor(db, itemId2);
|
|
8973
|
+
} catch {
|
|
8974
|
+
return {};
|
|
8975
|
+
}
|
|
8976
|
+
}
|
|
8977
|
+
|
|
8884
8978
|
// src/commands/sessions/web/windowsCwdToWslPath.ts
|
|
8885
8979
|
function windowsCwdToWslPath(cwd) {
|
|
8886
8980
|
const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
|
|
@@ -8914,7 +9008,13 @@ async function refExists2(cwd, ref) {
|
|
|
8914
9008
|
return false;
|
|
8915
9009
|
}
|
|
8916
9010
|
}
|
|
8917
|
-
async function
|
|
9011
|
+
async function anchoredBase(cwd, sessionId) {
|
|
9012
|
+
const { commit: commit2, parent } = await sessionCommitAnchor(sessionId);
|
|
9013
|
+
if (parent && await refExists2(cwd, parent)) return parent;
|
|
9014
|
+
if (commit2 && await refExists2(cwd, `${commit2}^`)) return `${commit2}^`;
|
|
9015
|
+
return void 0;
|
|
9016
|
+
}
|
|
9017
|
+
async function resolveDiffBase(cwd, sessionId) {
|
|
8918
9018
|
let defaultBranch;
|
|
8919
9019
|
try {
|
|
8920
9020
|
const config = loadConfigFrom(toGitCwd(cwd));
|
|
@@ -8923,6 +9023,10 @@ async function resolveDiffBase(cwd) {
|
|
|
8923
9023
|
} catch {
|
|
8924
9024
|
return "HEAD";
|
|
8925
9025
|
}
|
|
9026
|
+
if (sessionId) {
|
|
9027
|
+
const anchored = await anchoredBase(cwd, sessionId);
|
|
9028
|
+
if (anchored) return anchored;
|
|
9029
|
+
}
|
|
8926
9030
|
for (const candidate of baseCandidates(defaultBranch)) {
|
|
8927
9031
|
if (!await refExists2(cwd, candidate)) continue;
|
|
8928
9032
|
try {
|
|
@@ -8960,7 +9064,7 @@ async function diff2(req, res) {
|
|
|
8960
9064
|
const cwd = getCwdParam(req, res);
|
|
8961
9065
|
if (!cwd) return;
|
|
8962
9066
|
try {
|
|
8963
|
-
const base = await resolveDiffBase(cwd);
|
|
9067
|
+
const base = await resolveDiffBase(cwd, getSessionParam(req));
|
|
8964
9068
|
const tracked = await execGit(cwd, ["diff", base], {
|
|
8965
9069
|
maxBuffer: MAX_DIFF_BYTES
|
|
8966
9070
|
});
|
|
@@ -9280,7 +9384,7 @@ async function gitStatus(req, res) {
|
|
|
9280
9384
|
const cwd = getCwdParam(req, res);
|
|
9281
9385
|
if (!cwd) return;
|
|
9282
9386
|
try {
|
|
9283
|
-
const base = await resolveDiffBase(cwd);
|
|
9387
|
+
const base = await resolveDiffBase(cwd, getSessionParam(req));
|
|
9284
9388
|
respondJson(
|
|
9285
9389
|
res,
|
|
9286
9390
|
200,
|
|
@@ -9569,7 +9673,7 @@ async function listNewsItems(_req, res) {
|
|
|
9569
9673
|
}
|
|
9570
9674
|
|
|
9571
9675
|
// src/shared/db/listUsagePeaks.ts
|
|
9572
|
-
import { and as
|
|
9676
|
+
import { and as and8, count, desc as desc2, eq as eq18, getTableColumns, sql as sql16 } from "drizzle-orm";
|
|
9573
9677
|
async function listUsagePeaks(db, paging) {
|
|
9574
9678
|
const avgContext = db.select({
|
|
9575
9679
|
window: phaseCycleContext.window,
|
|
@@ -9585,9 +9689,9 @@ async function listUsagePeaks(db, paging) {
|
|
|
9585
9689
|
phaseCount: avgContext.phaseCount
|
|
9586
9690
|
}).from(usagePeaks).leftJoin(
|
|
9587
9691
|
avgContext,
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9692
|
+
and8(
|
|
9693
|
+
eq18(usagePeaks.window, avgContext.window),
|
|
9694
|
+
eq18(usagePeaks.resetsAt, avgContext.resetsAt)
|
|
9591
9695
|
)
|
|
9592
9696
|
).orderBy(
|
|
9593
9697
|
desc2(usagePeaks.resetsAt),
|
|
@@ -9644,11 +9748,11 @@ var execFileAsync4 = promisify5(execFile5);
|
|
|
9644
9748
|
var CACHE_TTL_MS2 = 3e4;
|
|
9645
9749
|
function createCachedGhJson(args, parse3, fallback, options2 = {}) {
|
|
9646
9750
|
const { cacheFallback = true } = options2;
|
|
9647
|
-
const
|
|
9751
|
+
const cache4 = /* @__PURE__ */ new Map();
|
|
9648
9752
|
return async (cwd, extraArgs = []) => {
|
|
9649
9753
|
const key = extraArgs.length ? `${cwd}\0${extraArgs.join("\0")}` : cwd;
|
|
9650
9754
|
const now = Date.now();
|
|
9651
|
-
const cached =
|
|
9755
|
+
const cached = cache4.get(key);
|
|
9652
9756
|
if (cached && cached.expires > now) return cached.value;
|
|
9653
9757
|
let value = fallback;
|
|
9654
9758
|
try {
|
|
@@ -9661,7 +9765,7 @@ function createCachedGhJson(args, parse3, fallback, options2 = {}) {
|
|
|
9661
9765
|
value = fallback;
|
|
9662
9766
|
}
|
|
9663
9767
|
if (cacheFallback || value !== fallback)
|
|
9664
|
-
|
|
9768
|
+
cache4.set(key, { value, expires: now + CACHE_TTL_MS2 });
|
|
9665
9769
|
return value;
|
|
9666
9770
|
};
|
|
9667
9771
|
}
|
|
@@ -10172,22 +10276,22 @@ import { readFileSync as readFileSync21 } from "fs";
|
|
|
10172
10276
|
import { createRequire as createRequire2 } from "module";
|
|
10173
10277
|
var require3 = createRequire2(import.meta.url);
|
|
10174
10278
|
function createCssHandler(packageEntry) {
|
|
10175
|
-
let
|
|
10279
|
+
let cache4;
|
|
10176
10280
|
return (req, res) => {
|
|
10177
|
-
if (!
|
|
10281
|
+
if (!cache4) {
|
|
10178
10282
|
const resolved = require3.resolve(packageEntry);
|
|
10179
10283
|
const body = readFileSync21(resolved, "utf8");
|
|
10180
10284
|
const etag = `"${createHash2("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
10181
|
-
|
|
10285
|
+
cache4 = { body, etag };
|
|
10182
10286
|
}
|
|
10183
|
-
const headers = { ETag:
|
|
10184
|
-
if (req.headers["if-none-match"] ===
|
|
10287
|
+
const headers = { ETag: cache4.etag, "Cache-Control": "no-cache" };
|
|
10288
|
+
if (req.headers["if-none-match"] === cache4.etag) {
|
|
10185
10289
|
res.writeHead(304, headers);
|
|
10186
10290
|
res.end();
|
|
10187
10291
|
return;
|
|
10188
10292
|
}
|
|
10189
10293
|
res.writeHead(200, { "Content-Type": "text/css", ...headers });
|
|
10190
|
-
res.end(
|
|
10294
|
+
res.end(cache4.body);
|
|
10191
10295
|
};
|
|
10192
10296
|
}
|
|
10193
10297
|
|
|
@@ -10685,11 +10789,11 @@ function registerActivityCommands(cmd) {
|
|
|
10685
10789
|
|
|
10686
10790
|
// src/commands/backlog/associate-github/index.ts
|
|
10687
10791
|
import chalk64 from "chalk";
|
|
10688
|
-
import { eq as
|
|
10792
|
+
import { eq as eq20 } from "drizzle-orm";
|
|
10689
10793
|
|
|
10690
10794
|
// src/commands/backlog/beginAssociation.ts
|
|
10691
10795
|
import chalk63 from "chalk";
|
|
10692
|
-
import { eq as
|
|
10796
|
+
import { eq as eq19 } from "drizzle-orm";
|
|
10693
10797
|
async function beginAssociation(id, options2, clearPatch, label2) {
|
|
10694
10798
|
const found = await findOneItem(id);
|
|
10695
10799
|
if (!found) {
|
|
@@ -10699,7 +10803,7 @@ async function beginAssociation(id, options2, clearPatch, label2) {
|
|
|
10699
10803
|
const { orm } = found;
|
|
10700
10804
|
const itemId2 = found.item.id;
|
|
10701
10805
|
if (options2.clear) {
|
|
10702
|
-
await orm.update(items).set(clearPatch).where(
|
|
10806
|
+
await orm.update(items).set(clearPatch).where(eq19(items.id, itemId2));
|
|
10703
10807
|
console.log(
|
|
10704
10808
|
chalk63.green(
|
|
10705
10809
|
`Cleared ${label2} association on item ${formatItemId(itemId2)}.`
|
|
@@ -10767,7 +10871,7 @@ async function associateGithub(id, issue, options2) {
|
|
|
10767
10871
|
return;
|
|
10768
10872
|
}
|
|
10769
10873
|
const title = fetchGithubIssueTitle(normalized);
|
|
10770
|
-
await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(
|
|
10874
|
+
await orm.update(items).set({ githubIssue: normalized, jiraKey: null }).where(eq20(items.id, itemId2));
|
|
10771
10875
|
console.log(
|
|
10772
10876
|
chalk64.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
|
|
10773
10877
|
title ? chalk64.dim(`(${title})`) : ""
|
|
@@ -10781,7 +10885,7 @@ function registerAssociateGithubCommand(cmd) {
|
|
|
10781
10885
|
|
|
10782
10886
|
// src/commands/backlog/associate-jira/index.ts
|
|
10783
10887
|
import chalk66 from "chalk";
|
|
10784
|
-
import { eq as
|
|
10888
|
+
import { eq as eq21 } from "drizzle-orm";
|
|
10785
10889
|
|
|
10786
10890
|
// src/commands/jira/fetchIssue.ts
|
|
10787
10891
|
import { execSync as execSync32 } from "child_process";
|
|
@@ -10846,7 +10950,7 @@ async function associateJira(id, key, options2) {
|
|
|
10846
10950
|
const parsed = fetchIssue(normalized, "summary");
|
|
10847
10951
|
const fields = parsed?.fields;
|
|
10848
10952
|
const summary = fields?.summary;
|
|
10849
|
-
await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(
|
|
10953
|
+
await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq21(items.id, itemId2));
|
|
10850
10954
|
console.log(
|
|
10851
10955
|
chalk66.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
|
|
10852
10956
|
summary ? chalk66.dim(`(${summary})`) : ""
|
|
@@ -11219,15 +11323,15 @@ function registerImportCommand(cmd) {
|
|
|
11219
11323
|
import chalk74 from "chalk";
|
|
11220
11324
|
|
|
11221
11325
|
// src/commands/backlog/insertPhaseAt.ts
|
|
11222
|
-
import { eq as
|
|
11326
|
+
import { eq as eq23 } from "drizzle-orm";
|
|
11223
11327
|
|
|
11224
11328
|
// src/commands/backlog/shiftPhasesUp.ts
|
|
11225
|
-
import { and as
|
|
11329
|
+
import { and as and9, desc as desc3, eq as eq22, gte } from "drizzle-orm";
|
|
11226
11330
|
async function shiftPhasesUp(db, itemId2, fromIdx) {
|
|
11227
|
-
const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(
|
|
11331
|
+
const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(and9(eq22(planPhases.itemId, itemId2), gte(planPhases.idx, fromIdx))).orderBy(desc3(planPhases.idx));
|
|
11228
11332
|
for (const p of toShift) {
|
|
11229
|
-
await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(
|
|
11230
|
-
await db.update(planPhases).set({ idx: p.idx + 1 }).where(
|
|
11333
|
+
await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(and9(eq22(planTasks.itemId, itemId2), eq22(planTasks.phaseIdx, p.idx)));
|
|
11334
|
+
await db.update(planPhases).set({ idx: p.idx + 1 }).where(and9(eq22(planPhases.itemId, itemId2), eq22(planPhases.idx, p.idx)));
|
|
11231
11335
|
}
|
|
11232
11336
|
}
|
|
11233
11337
|
|
|
@@ -11240,7 +11344,7 @@ async function insertPhaseAt(orm, itemId2, phaseIdx, name, tasks, manualChecks,
|
|
|
11240
11344
|
await tx.insert(planTasks).values(tasks.map((task, i) => ({ itemId: itemId2, phaseIdx, idx: i, task })));
|
|
11241
11345
|
}
|
|
11242
11346
|
if (currentPhase !== void 0 && currentPhase - 1 >= phaseIdx) {
|
|
11243
|
-
await tx.update(items).set({ currentPhase: phaseIdx + 1 }).where(
|
|
11347
|
+
await tx.update(items).set({ currentPhase: phaseIdx + 1 }).where(eq23(items.id, itemId2));
|
|
11244
11348
|
}
|
|
11245
11349
|
});
|
|
11246
11350
|
}
|
|
@@ -11403,9 +11507,9 @@ import chalk76 from "chalk";
|
|
|
11403
11507
|
|
|
11404
11508
|
// src/commands/backlog/resolveInsertPosition.ts
|
|
11405
11509
|
import chalk75 from "chalk";
|
|
11406
|
-
import { count as count2, eq as
|
|
11510
|
+
import { count as count2, eq as eq24 } from "drizzle-orm";
|
|
11407
11511
|
async function resolveInsertPosition(orm, itemId2, position) {
|
|
11408
|
-
const [row] = await orm.select({ cnt: count2() }).from(planPhases).where(
|
|
11512
|
+
const [row] = await orm.select({ cnt: count2() }).from(planPhases).where(eq24(planPhases.itemId, itemId2));
|
|
11409
11513
|
const phaseCount = row?.cnt ?? 0;
|
|
11410
11514
|
if (position === void 0) return phaseCount;
|
|
11411
11515
|
const pos = Number.parseInt(position, 10);
|
|
@@ -11734,9 +11838,9 @@ function hasCycle(adjacency, fromId, toId) {
|
|
|
11734
11838
|
}
|
|
11735
11839
|
|
|
11736
11840
|
// src/commands/backlog/loadDependencyGraph.ts
|
|
11737
|
-
import { eq as
|
|
11841
|
+
import { eq as eq25 } from "drizzle-orm";
|
|
11738
11842
|
async function loadDependencyGraph(orm) {
|
|
11739
|
-
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(
|
|
11843
|
+
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq25(links.type, "depends-on"));
|
|
11740
11844
|
const graph = /* @__PURE__ */ new Map();
|
|
11741
11845
|
for (const { itemId: itemId2, targetId } of rows) {
|
|
11742
11846
|
const bucket = graph.get(itemId2);
|
|
@@ -11803,7 +11907,7 @@ async function link(fromId, toId, opts) {
|
|
|
11803
11907
|
|
|
11804
11908
|
// src/commands/backlog/unlink.ts
|
|
11805
11909
|
import chalk82 from "chalk";
|
|
11806
|
-
import { and as
|
|
11910
|
+
import { and as and10, eq as eq26 } from "drizzle-orm";
|
|
11807
11911
|
async function unlink(fromId, toId) {
|
|
11808
11912
|
const fromNum = parseItemId(fromId);
|
|
11809
11913
|
const toNum = parseItemId(toId);
|
|
@@ -11827,7 +11931,7 @@ async function unlink(fromId, toId) {
|
|
|
11827
11931
|
);
|
|
11828
11932
|
return;
|
|
11829
11933
|
}
|
|
11830
|
-
await orm.delete(links).where(
|
|
11934
|
+
await orm.delete(links).where(and10(eq26(links.itemId, fromNum), eq26(links.targetId, toNum)));
|
|
11831
11935
|
console.log(
|
|
11832
11936
|
chalk82.green(
|
|
11833
11937
|
`Removed link from ${formatItemId(fromNum)} to ${formatItemId(toNum)}.`
|
|
@@ -11847,7 +11951,7 @@ function registerLinkCommands(cmd) {
|
|
|
11847
11951
|
|
|
11848
11952
|
// src/commands/backlog/move-repo/index.ts
|
|
11849
11953
|
import chalk84 from "chalk";
|
|
11850
|
-
import { eq as
|
|
11954
|
+
import { eq as eq28 } from "drizzle-orm";
|
|
11851
11955
|
|
|
11852
11956
|
// src/commands/backlog/move-repo/confirmMove.ts
|
|
11853
11957
|
import chalk83 from "chalk";
|
|
@@ -11862,9 +11966,9 @@ async function confirmMove(cnt, oldOrigin, newOrigin) {
|
|
|
11862
11966
|
}
|
|
11863
11967
|
|
|
11864
11968
|
// src/commands/backlog/move-repo/countByOrigin.ts
|
|
11865
|
-
import { count as count3, eq as
|
|
11969
|
+
import { count as count3, eq as eq27 } from "drizzle-orm";
|
|
11866
11970
|
async function countByOrigin(orm, origin) {
|
|
11867
|
-
const [{ cnt }] = await orm.select({ cnt: count3() }).from(items).where(
|
|
11971
|
+
const [{ cnt }] = await orm.select({ cnt: count3() }).from(items).where(eq27(items.origin, origin));
|
|
11868
11972
|
return cnt;
|
|
11869
11973
|
}
|
|
11870
11974
|
|
|
@@ -11907,7 +12011,7 @@ async function moveRepo(oldOriginRaw, newOriginRaw, options2 = {}) {
|
|
|
11907
12011
|
console.log(chalk84.yellow("Move cancelled; no changes made."));
|
|
11908
12012
|
return;
|
|
11909
12013
|
}
|
|
11910
|
-
await orm.update(items).set({ origin: newOrigin }).where(
|
|
12014
|
+
await orm.update(items).set({ origin: newOrigin }).where(eq28(items.origin, oldOrigin));
|
|
11911
12015
|
console.log(
|
|
11912
12016
|
chalk84.green(
|
|
11913
12017
|
`Moved ${pluralItems(cnt)} from "${oldOrigin}" to "${newOrigin}".`
|
|
@@ -12324,10 +12428,10 @@ async function start(id) {
|
|
|
12324
12428
|
|
|
12325
12429
|
// src/commands/backlog/stop/index.ts
|
|
12326
12430
|
import chalk96 from "chalk";
|
|
12327
|
-
import { and as
|
|
12431
|
+
import { and as and11, eq as eq29 } from "drizzle-orm";
|
|
12328
12432
|
async function stop() {
|
|
12329
12433
|
const { orm } = await getReady();
|
|
12330
|
-
const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(
|
|
12434
|
+
const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and11(eq29(items.status, "in-progress"), eq29(items.origin, getOrigin()))).returning({ id: items.id, name: items.name });
|
|
12331
12435
|
if (stopped.length === 0) {
|
|
12332
12436
|
console.log(chalk96.yellow("No in-progress items to stop."));
|
|
12333
12437
|
return;
|
|
@@ -12444,13 +12548,13 @@ async function findSubtask(id, index3) {
|
|
|
12444
12548
|
}
|
|
12445
12549
|
|
|
12446
12550
|
// src/commands/backlog/updateSubtask.ts
|
|
12447
|
-
import { and as
|
|
12551
|
+
import { and as and12, eq as eq30 } from "drizzle-orm";
|
|
12448
12552
|
async function updateSubtask(orm, itemId2, idx, fields) {
|
|
12449
12553
|
const set = {};
|
|
12450
12554
|
if (fields.title !== void 0) set.title = fields.title;
|
|
12451
12555
|
if (fields.description !== void 0) set.description = fields.description;
|
|
12452
12556
|
if (fields.status !== void 0) set.status = fields.status;
|
|
12453
|
-
const [row] = await orm.update(itemSubtasks).set(set).where(
|
|
12557
|
+
const [row] = await orm.update(itemSubtasks).set(set).where(and12(eq30(itemSubtasks.itemId, itemId2), eq30(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
12454
12558
|
return row?.title;
|
|
12455
12559
|
}
|
|
12456
12560
|
|
|
@@ -12505,16 +12609,16 @@ async function editSubtask(id, index3, options2) {
|
|
|
12505
12609
|
import chalk102 from "chalk";
|
|
12506
12610
|
|
|
12507
12611
|
// src/commands/backlog/deleteSubtask.ts
|
|
12508
|
-
import { and as
|
|
12612
|
+
import { and as and13, asc as asc8, eq as eq31 } from "drizzle-orm";
|
|
12509
12613
|
async function deleteSubtask(orm, itemId2, idx) {
|
|
12510
|
-
const [row] = await orm.delete(itemSubtasks).where(
|
|
12614
|
+
const [row] = await orm.delete(itemSubtasks).where(and13(eq31(itemSubtasks.itemId, itemId2), eq31(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
12511
12615
|
if (!row) return void 0;
|
|
12512
|
-
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(
|
|
12616
|
+
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq31(itemSubtasks.itemId, itemId2)).orderBy(asc8(itemSubtasks.idx));
|
|
12513
12617
|
for (let i = 0; i < remaining.length; i++) {
|
|
12514
12618
|
const oldIdx = remaining[i].idx;
|
|
12515
12619
|
if (oldIdx === i) continue;
|
|
12516
12620
|
await orm.update(itemSubtasks).set({ idx: i }).where(
|
|
12517
|
-
|
|
12621
|
+
and13(eq31(itemSubtasks.itemId, itemId2), eq31(itemSubtasks.idx, oldIdx))
|
|
12518
12622
|
);
|
|
12519
12623
|
}
|
|
12520
12624
|
return row.title;
|
|
@@ -12583,20 +12687,20 @@ function registerSubtaskCommands(cmd) {
|
|
|
12583
12687
|
|
|
12584
12688
|
// src/commands/backlog/movePhase.ts
|
|
12585
12689
|
import chalk104 from "chalk";
|
|
12586
|
-
import { count as count5, eq as
|
|
12690
|
+
import { count as count5, eq as eq34 } from "drizzle-orm";
|
|
12587
12691
|
|
|
12588
12692
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
12589
|
-
import { and as
|
|
12693
|
+
import { and as and15, asc as asc10, eq as eq33 } from "drizzle-orm";
|
|
12590
12694
|
|
|
12591
12695
|
// src/commands/backlog/reindexPhases.ts
|
|
12592
|
-
import { and as
|
|
12696
|
+
import { and as and14, asc as asc9, count as count4, eq as eq32 } from "drizzle-orm";
|
|
12593
12697
|
async function reindexPhases(db, itemId2) {
|
|
12594
|
-
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(
|
|
12698
|
+
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq32(planPhases.itemId, itemId2)).orderBy(asc9(planPhases.idx));
|
|
12595
12699
|
for (let i = 0; i < remaining.length; i++) {
|
|
12596
12700
|
const oldIdx = remaining[i].idx;
|
|
12597
12701
|
if (oldIdx === i) continue;
|
|
12598
|
-
await db.update(planTasks).set({ phaseIdx: i }).where(
|
|
12599
|
-
await db.update(planPhases).set({ idx: i }).where(
|
|
12702
|
+
await db.update(planTasks).set({ phaseIdx: i }).where(and14(eq32(planTasks.itemId, itemId2), eq32(planTasks.phaseIdx, oldIdx)));
|
|
12703
|
+
await db.update(planPhases).set({ idx: i }).where(and14(eq32(planPhases.itemId, itemId2), eq32(planPhases.idx, oldIdx)));
|
|
12600
12704
|
}
|
|
12601
12705
|
}
|
|
12602
12706
|
async function adjustCurrentPhase(db, item, removedIdx) {
|
|
@@ -12604,24 +12708,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
|
|
|
12604
12708
|
if (currentPhase === void 0) return;
|
|
12605
12709
|
const currentIdx = currentPhase - 1;
|
|
12606
12710
|
if (removedIdx < currentIdx) {
|
|
12607
|
-
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(
|
|
12711
|
+
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq32(items.id, item.id));
|
|
12608
12712
|
return;
|
|
12609
12713
|
}
|
|
12610
12714
|
if (removedIdx !== currentIdx) return;
|
|
12611
|
-
const [row] = await db.select({ cnt: count4() }).from(planPhases).where(
|
|
12715
|
+
const [row] = await db.select({ cnt: count4() }).from(planPhases).where(eq32(planPhases.itemId, item.id));
|
|
12612
12716
|
const cnt = row?.cnt ?? 0;
|
|
12613
|
-
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(
|
|
12717
|
+
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq32(items.id, item.id));
|
|
12614
12718
|
}
|
|
12615
12719
|
|
|
12616
12720
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
12617
12721
|
async function reorderPhaseRows(orm, itemId2, fromIdx, toIdx) {
|
|
12618
12722
|
await orm.transaction(async (tx) => {
|
|
12619
|
-
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(
|
|
12620
|
-
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(
|
|
12723
|
+
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and15(eq33(planPhases.itemId, itemId2), eq33(planPhases.idx, fromIdx)));
|
|
12724
|
+
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and15(eq33(planTasks.itemId, itemId2), eq33(planTasks.phaseIdx, fromIdx))).orderBy(asc10(planTasks.idx));
|
|
12621
12725
|
await tx.delete(planTasks).where(
|
|
12622
|
-
|
|
12726
|
+
and15(eq33(planTasks.itemId, itemId2), eq33(planTasks.phaseIdx, fromIdx))
|
|
12623
12727
|
);
|
|
12624
|
-
await tx.delete(planPhases).where(
|
|
12728
|
+
await tx.delete(planPhases).where(and15(eq33(planPhases.itemId, itemId2), eq33(planPhases.idx, fromIdx)));
|
|
12625
12729
|
await reindexPhases(tx, itemId2);
|
|
12626
12730
|
await shiftPhasesUp(tx, itemId2, toIdx);
|
|
12627
12731
|
await tx.insert(planPhases).values({
|
|
@@ -12662,7 +12766,7 @@ async function movePhase(id, from, to) {
|
|
|
12662
12766
|
if (!found) return;
|
|
12663
12767
|
const { orm, item } = found;
|
|
12664
12768
|
const itemId2 = item.id;
|
|
12665
|
-
const [row] = await orm.select({ cnt: count5() }).from(planPhases).where(
|
|
12769
|
+
const [row] = await orm.select({ cnt: count5() }).from(planPhases).where(eq34(planPhases.itemId, itemId2));
|
|
12666
12770
|
const phaseCount = row?.cnt ?? 0;
|
|
12667
12771
|
const fromIdx = toIndex(from, phaseCount);
|
|
12668
12772
|
if (fromIdx === void 0) return;
|
|
@@ -12678,22 +12782,22 @@ async function movePhase(id, from, to) {
|
|
|
12678
12782
|
import chalk106 from "chalk";
|
|
12679
12783
|
|
|
12680
12784
|
// src/commands/backlog/applyPhaseUpdate.ts
|
|
12681
|
-
import { and as
|
|
12785
|
+
import { and as and16, eq as eq35 } from "drizzle-orm";
|
|
12682
12786
|
async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
|
|
12683
12787
|
await orm.transaction(async (tx) => {
|
|
12684
12788
|
if (fields.name) {
|
|
12685
12789
|
await tx.update(planPhases).set({ name: fields.name }).where(
|
|
12686
|
-
|
|
12790
|
+
and16(eq35(planPhases.itemId, itemId2), eq35(planPhases.idx, phaseIdx))
|
|
12687
12791
|
);
|
|
12688
12792
|
}
|
|
12689
12793
|
if (fields.manualCheck) {
|
|
12690
12794
|
await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
|
|
12691
|
-
|
|
12795
|
+
and16(eq35(planPhases.itemId, itemId2), eq35(planPhases.idx, phaseIdx))
|
|
12692
12796
|
);
|
|
12693
12797
|
}
|
|
12694
12798
|
if (fields.task) {
|
|
12695
12799
|
await tx.delete(planTasks).where(
|
|
12696
|
-
|
|
12800
|
+
and16(eq35(planTasks.itemId, itemId2), eq35(planTasks.phaseIdx, phaseIdx))
|
|
12697
12801
|
);
|
|
12698
12802
|
if (fields.task.length) {
|
|
12699
12803
|
await tx.insert(planTasks).values(
|
|
@@ -12711,14 +12815,14 @@ async function applyPhaseUpdate(orm, itemId2, phaseIdx, fields) {
|
|
|
12711
12815
|
|
|
12712
12816
|
// src/commands/backlog/findPhase.ts
|
|
12713
12817
|
import chalk105 from "chalk";
|
|
12714
|
-
import { and as
|
|
12818
|
+
import { and as and17, count as count6, eq as eq36 } from "drizzle-orm";
|
|
12715
12819
|
async function findPhase(id, phase) {
|
|
12716
12820
|
const found = await findOneItem(id);
|
|
12717
12821
|
if (!found) return void 0;
|
|
12718
12822
|
const { orm, item } = found;
|
|
12719
12823
|
const itemId2 = item.id;
|
|
12720
12824
|
const phaseIdx = Number.parseInt(phase, 10) - 1;
|
|
12721
|
-
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(
|
|
12825
|
+
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(and17(eq36(planPhases.itemId, itemId2), eq36(planPhases.idx, phaseIdx)));
|
|
12722
12826
|
if (!row || row.cnt === 0) {
|
|
12723
12827
|
console.log(
|
|
12724
12828
|
chalk105.red(
|
|
@@ -12891,16 +12995,16 @@ function registerUpdatePhaseCommand(cmd) {
|
|
|
12891
12995
|
|
|
12892
12996
|
// src/commands/backlog/removePhase.ts
|
|
12893
12997
|
import chalk107 from "chalk";
|
|
12894
|
-
import { and as
|
|
12998
|
+
import { and as and18, eq as eq37 } from "drizzle-orm";
|
|
12895
12999
|
async function removePhase(id, phase) {
|
|
12896
13000
|
const found = await findPhase(id, phase);
|
|
12897
13001
|
if (!found) return;
|
|
12898
13002
|
const { item, orm, itemId: itemId2, phaseIdx } = found;
|
|
12899
13003
|
await orm.transaction(async (tx) => {
|
|
12900
13004
|
await tx.delete(planTasks).where(
|
|
12901
|
-
|
|
13005
|
+
and18(eq37(planTasks.itemId, itemId2), eq37(planTasks.phaseIdx, phaseIdx))
|
|
12902
13006
|
);
|
|
12903
|
-
await tx.delete(planPhases).where(
|
|
13007
|
+
await tx.delete(planPhases).where(and18(eq37(planPhases.itemId, itemId2), eq37(planPhases.idx, phaseIdx)));
|
|
12904
13008
|
await reindexPhases(tx, itemId2);
|
|
12905
13009
|
await adjustCurrentPhase(tx, item, phaseIdx);
|
|
12906
13010
|
});
|
|
@@ -12913,7 +13017,7 @@ async function removePhase(id, phase) {
|
|
|
12913
13017
|
|
|
12914
13018
|
// src/commands/backlog/update/update.ts
|
|
12915
13019
|
import chalk111 from "chalk";
|
|
12916
|
-
import { eq as
|
|
13020
|
+
import { eq as eq38 } from "drizzle-orm";
|
|
12917
13021
|
|
|
12918
13022
|
// src/commands/backlog/update/buildUpdateValues.ts
|
|
12919
13023
|
import chalk108 from "chalk";
|
|
@@ -13024,7 +13128,7 @@ async function update(id, options2) {
|
|
|
13024
13128
|
if (!built) return;
|
|
13025
13129
|
const { orm } = found;
|
|
13026
13130
|
const itemId2 = found.item.id;
|
|
13027
|
-
await orm.update(items).set(built.set).where(
|
|
13131
|
+
await orm.update(items).set(built.set).where(eq38(items.id, itemId2));
|
|
13028
13132
|
console.log(
|
|
13029
13133
|
chalk111.green(`Updated ${built.fields} on item ${formatItemId(itemId2)}.`)
|
|
13030
13134
|
);
|
|
@@ -17107,9 +17211,9 @@ function registerGithub(program2) {
|
|
|
17107
17211
|
}
|
|
17108
17212
|
|
|
17109
17213
|
// src/commands/handover/countPendingHandovers.ts
|
|
17110
|
-
import { and as
|
|
17214
|
+
import { and as and19, eq as eq39, isNull, sql as sql18 } from "drizzle-orm";
|
|
17111
17215
|
async function countPendingHandovers(orm, origin) {
|
|
17112
|
-
const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(
|
|
17216
|
+
const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(and19(eq39(handovers.origin, origin), isNull(handovers.recalledAt)));
|
|
17113
17217
|
return row?.count ?? 0;
|
|
17114
17218
|
}
|
|
17115
17219
|
|
|
@@ -17249,13 +17353,13 @@ async function load2(options2 = {}) {
|
|
|
17249
17353
|
}
|
|
17250
17354
|
|
|
17251
17355
|
// src/commands/handover/listPendingHandovers.ts
|
|
17252
|
-
import { and as
|
|
17356
|
+
import { and as and20, desc as desc4, eq as eq40, isNull as isNull2 } from "drizzle-orm";
|
|
17253
17357
|
async function listPendingHandovers(orm, origin) {
|
|
17254
17358
|
return orm.select({
|
|
17255
17359
|
id: handovers.id,
|
|
17256
17360
|
summary: handovers.summary,
|
|
17257
17361
|
createdAt: handovers.createdAt
|
|
17258
|
-
}).from(handovers).where(
|
|
17362
|
+
}).from(handovers).where(and20(eq40(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
|
|
17259
17363
|
}
|
|
17260
17364
|
|
|
17261
17365
|
// src/commands/handover/printPendingHandovers.ts
|
|
@@ -17268,17 +17372,17 @@ async function printPendingHandovers() {
|
|
|
17268
17372
|
}
|
|
17269
17373
|
|
|
17270
17374
|
// src/commands/handover/recallHandover.ts
|
|
17271
|
-
import { and as
|
|
17375
|
+
import { and as and21, desc as desc5, eq as eq41, isNull as isNull3 } from "drizzle-orm";
|
|
17272
17376
|
async function recallHandover(orm, origin, id) {
|
|
17273
17377
|
const [row] = await orm.select().from(handovers).where(
|
|
17274
|
-
|
|
17275
|
-
|
|
17378
|
+
and21(
|
|
17379
|
+
eq41(handovers.origin, origin),
|
|
17276
17380
|
isNull3(handovers.recalledAt),
|
|
17277
|
-
...id === void 0 ? [] : [
|
|
17381
|
+
...id === void 0 ? [] : [eq41(handovers.id, id)]
|
|
17278
17382
|
)
|
|
17279
17383
|
).orderBy(desc5(handovers.createdAt), desc5(handovers.id)).limit(1);
|
|
17280
17384
|
if (!row) return void 0;
|
|
17281
|
-
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(
|
|
17385
|
+
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq41(handovers.id, row.id));
|
|
17282
17386
|
return row.content;
|
|
17283
17387
|
}
|
|
17284
17388
|
|
|
@@ -17861,7 +17965,7 @@ function runInstall(worktreePath, clone, install, onSeeded) {
|
|
|
17861
17965
|
}
|
|
17862
17966
|
const windows = /^[A-Za-z]:[\\/]/.test(worktreePath);
|
|
17863
17967
|
const shell = windows ? "cmd.exe" : process.env.SHELL ?? "bash";
|
|
17864
|
-
const shellArgs = windows ? ["/c", command] : ["-l", "-c", command];
|
|
17968
|
+
const shellArgs = windows ? ["/c", `cd /d ${quoteForCmd(worktreePath)} && ${command}`] : ["-l", "-c", `cd ${quoteForPosixShell(worktreePath)} && ${command}`];
|
|
17865
17969
|
daemonLog(`worktree ${worktreePath} installing deps: ${command}`);
|
|
17866
17970
|
execFile8(shell, shellArgs, { cwd: worktreePath }, (error) => {
|
|
17867
17971
|
daemonLog(
|
|
@@ -17870,6 +17974,12 @@ function runInstall(worktreePath, clone, install, onSeeded) {
|
|
|
17870
17974
|
onSeeded();
|
|
17871
17975
|
});
|
|
17872
17976
|
}
|
|
17977
|
+
function quoteForPosixShell(value) {
|
|
17978
|
+
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
17979
|
+
}
|
|
17980
|
+
function quoteForCmd(value) {
|
|
17981
|
+
return `"${value.replaceAll('"', "")}"`;
|
|
17982
|
+
}
|
|
17873
17983
|
function message(error) {
|
|
17874
17984
|
return error instanceof Error ? error.message : String(error);
|
|
17875
17985
|
}
|
|
@@ -19281,20 +19391,20 @@ function resolveThread(threadId) {
|
|
|
19281
19391
|
}
|
|
19282
19392
|
}
|
|
19283
19393
|
function requireCache(prNumber) {
|
|
19284
|
-
const
|
|
19285
|
-
if (!
|
|
19394
|
+
const cache4 = loadCommentsCache(prNumber);
|
|
19395
|
+
if (!cache4) {
|
|
19286
19396
|
console.error(
|
|
19287
19397
|
`Error: No cached comments found for PR #${prNumber}. Run "assist prs list-comments" first.`
|
|
19288
19398
|
);
|
|
19289
19399
|
process.exit(1);
|
|
19290
19400
|
}
|
|
19291
|
-
return
|
|
19401
|
+
return cache4;
|
|
19292
19402
|
}
|
|
19293
19403
|
function findLineComment(comments3, commentId) {
|
|
19294
19404
|
return comments3.find((c) => c.type === "line" && c.id === commentId);
|
|
19295
19405
|
}
|
|
19296
|
-
function requireLineComment(
|
|
19297
|
-
const comment3 = findLineComment(
|
|
19406
|
+
function requireLineComment(cache4, commentId) {
|
|
19407
|
+
const comment3 = findLineComment(cache4.comments, commentId);
|
|
19298
19408
|
if (!comment3 || comment3.type !== "line" || !comment3.threadId) {
|
|
19299
19409
|
console.error(
|
|
19300
19410
|
`Error: Comment #${commentId} not found or has no thread ID.`
|
|
@@ -19303,8 +19413,8 @@ function requireLineComment(cache3, commentId) {
|
|
|
19303
19413
|
}
|
|
19304
19414
|
return comment3;
|
|
19305
19415
|
}
|
|
19306
|
-
function cleanupCacheIfDone(
|
|
19307
|
-
const hasRemaining =
|
|
19416
|
+
function cleanupCacheIfDone(cache4, prNumber, commentId) {
|
|
19417
|
+
const hasRemaining = cache4.comments.some(
|
|
19308
19418
|
(c) => c.type === "line" && c.id !== commentId
|
|
19309
19419
|
);
|
|
19310
19420
|
if (!hasRemaining) deleteCommentsCache(prNumber);
|
|
@@ -19312,13 +19422,13 @@ function cleanupCacheIfDone(cache3, prNumber, commentId) {
|
|
|
19312
19422
|
function resolveCommentWithReply(commentId, message2) {
|
|
19313
19423
|
const prNumber = getCurrentPrNumber();
|
|
19314
19424
|
const { org, repo } = getRepoInfo();
|
|
19315
|
-
const
|
|
19316
|
-
const comment3 = requireLineComment(
|
|
19425
|
+
const cache4 = requireCache(prNumber);
|
|
19426
|
+
const comment3 = requireLineComment(cache4, commentId);
|
|
19317
19427
|
replyToComment(org, repo, prNumber, commentId, message2);
|
|
19318
19428
|
console.log("Reply posted successfully.");
|
|
19319
19429
|
resolveThread(comment3.threadId);
|
|
19320
19430
|
console.log("Thread resolved successfully.");
|
|
19321
|
-
cleanupCacheIfDone(
|
|
19431
|
+
cleanupCacheIfDone(cache4, prNumber, commentId);
|
|
19322
19432
|
}
|
|
19323
19433
|
|
|
19324
19434
|
// src/commands/prs/fixed.ts
|
|
@@ -19739,7 +19849,7 @@ async function recordPrActivity() {
|
|
|
19739
19849
|
}
|
|
19740
19850
|
|
|
19741
19851
|
// src/commands/prs/placePr.ts
|
|
19742
|
-
function
|
|
19852
|
+
function hasUpstream2() {
|
|
19743
19853
|
try {
|
|
19744
19854
|
execFileSync8(
|
|
19745
19855
|
"git",
|
|
@@ -19752,7 +19862,7 @@ function hasUpstream() {
|
|
|
19752
19862
|
}
|
|
19753
19863
|
}
|
|
19754
19864
|
function ensureBranchPushed() {
|
|
19755
|
-
const args =
|
|
19865
|
+
const args = hasUpstream2() ? ["push"] : ["push", "--set-upstream", "origin", "HEAD"];
|
|
19756
19866
|
execFileSync8("git", args, { stdio: "inherit" });
|
|
19757
19867
|
}
|
|
19758
19868
|
async function placePr(prNumber, title, body, options2) {
|
|
@@ -26478,6 +26588,7 @@ function toSessionInfo({
|
|
|
26478
26588
|
serverOrigin,
|
|
26479
26589
|
assistArgs,
|
|
26480
26590
|
cwd,
|
|
26591
|
+
claudeSessionId,
|
|
26481
26592
|
restored,
|
|
26482
26593
|
error,
|
|
26483
26594
|
activity: activity2,
|
|
@@ -26508,6 +26619,7 @@ function toSessionInfo({
|
|
|
26508
26619
|
remoteOrigin: serverOrigin ?? originForCwd(cwd),
|
|
26509
26620
|
assistArgs,
|
|
26510
26621
|
cwd,
|
|
26622
|
+
claudeSessionId,
|
|
26511
26623
|
repoGroup: repoGroupForCwd(cwd),
|
|
26512
26624
|
restored,
|
|
26513
26625
|
error,
|
|
@@ -27296,10 +27408,10 @@ function applyReviewPause(session, activity2) {
|
|
|
27296
27408
|
}
|
|
27297
27409
|
|
|
27298
27410
|
// src/shared/db/getPhaseActiveMs.ts
|
|
27299
|
-
import { and as
|
|
27411
|
+
import { and as and22, eq as eq42 } from "drizzle-orm";
|
|
27300
27412
|
async function getPhaseActiveMs(db, itemId2, phaseIdx) {
|
|
27301
27413
|
const [row] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
27302
|
-
|
|
27414
|
+
and22(eq42(phaseUsage.itemId, itemId2), eq42(phaseUsage.phaseIdx, phaseIdx))
|
|
27303
27415
|
);
|
|
27304
27416
|
return row?.activeMs ?? 0;
|
|
27305
27417
|
}
|
|
@@ -27810,17 +27922,17 @@ async function recordPhaseTranscriptUsage(db, itemId2, phaseIdx, responses) {
|
|
|
27810
27922
|
}
|
|
27811
27923
|
|
|
27812
27924
|
// src/shared/db/recordWindowTokens.ts
|
|
27813
|
-
import { and as
|
|
27925
|
+
import { and as and23, eq as eq43, sql as sql24 } from "drizzle-orm";
|
|
27814
27926
|
async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
|
|
27815
27927
|
if (tokensUp <= 0 && tokensDown <= 0) return;
|
|
27816
27928
|
await db.update(usagePeaks).set({
|
|
27817
27929
|
tokensUp: sql24`${usagePeaks.tokensUp} + ${tokensUp}`,
|
|
27818
27930
|
tokensDown: sql24`${usagePeaks.tokensDown} + ${tokensDown}`
|
|
27819
27931
|
}).where(
|
|
27820
|
-
|
|
27821
|
-
|
|
27822
|
-
|
|
27823
|
-
|
|
27932
|
+
and23(
|
|
27933
|
+
eq43(usagePeaks.window, window),
|
|
27934
|
+
eq43(usagePeaks.resetsAt, resetsAt),
|
|
27935
|
+
eq43(usagePeaks.segment, 0)
|
|
27824
27936
|
)
|
|
27825
27937
|
);
|
|
27826
27938
|
}
|
|
@@ -30278,7 +30390,7 @@ var sessionsConfigHelp = [
|
|
|
30278
30390
|
{
|
|
30279
30391
|
key: "sessions.includeCommittedChanges",
|
|
30280
30392
|
setter: "assist config set sessions.includeCommittedChanges true -g",
|
|
30281
|
-
note: "session card counts and /diff span the whole
|
|
30393
|
+
note: "session card counts and /diff span the whole session (its first commit's parent, else merge-base with the default branch) instead of just uncommitted work (default off)"
|
|
30282
30394
|
},
|
|
30283
30395
|
{
|
|
30284
30396
|
key: "worktree.enabled",
|