@staff0rd/assist 0.1046.0 → 0.1047.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.1047.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1275,7 +1275,8 @@ var assistConfigShape = {
|
|
|
1275
1275
|
uiPaths: z6.array(z6.string()).default([]),
|
|
1276
1276
|
descriptionWordCap: z6.number().int().positive().default(300),
|
|
1277
1277
|
testPaths: z6.array(z6.string()).default(["**/*.{test,spec}.{ts,tsx,js,jsx}"]),
|
|
1278
|
-
collapsedPaths: z6.array(z6.string()).default(["**/*.test.*", "**/generated/**"])
|
|
1278
|
+
collapsedPaths: z6.array(z6.string()).default(["**/*.test.*", "**/generated/**"]),
|
|
1279
|
+
slices: z6.boolean().default(false)
|
|
1279
1280
|
}).optional()
|
|
1280
1281
|
}).optional(),
|
|
1281
1282
|
readTime: z6.strictObject({
|
|
@@ -4682,12 +4683,12 @@ async function listCommitRefs(db, itemId2) {
|
|
|
4682
4683
|
}
|
|
4683
4684
|
|
|
4684
4685
|
// src/commands/sessions/web/itemCommits.ts
|
|
4685
|
-
async function itemCommits(
|
|
4686
|
+
async function itemCommits(sessionId2) {
|
|
4686
4687
|
try {
|
|
4687
4688
|
if (!process.env.ASSIST_DATABASE_URL && !loadConfig().database.url)
|
|
4688
4689
|
return [];
|
|
4689
4690
|
const db = await getDb();
|
|
4690
|
-
const itemId2 = await findItemBySessionId(db,
|
|
4691
|
+
const itemId2 = await findItemBySessionId(db, sessionId2);
|
|
4691
4692
|
if (itemId2 === void 0) return [];
|
|
4692
4693
|
return await listCommitRefs(db, itemId2);
|
|
4693
4694
|
} catch {
|
|
@@ -4850,8 +4851,8 @@ async function headCommit(cwd, sha) {
|
|
|
4850
4851
|
return void 0;
|
|
4851
4852
|
}
|
|
4852
4853
|
}
|
|
4853
|
-
async function transcriptCommits(cwd,
|
|
4854
|
-
const transcriptPath2 = findTranscriptPathSync(cwd,
|
|
4854
|
+
async function transcriptCommits(cwd, sessionId2) {
|
|
4855
|
+
const transcriptPath2 = findTranscriptPathSync(cwd, sessionId2);
|
|
4855
4856
|
if (!transcriptPath2) return [];
|
|
4856
4857
|
let transcript;
|
|
4857
4858
|
try {
|
|
@@ -4871,22 +4872,22 @@ async function transcriptCommits(cwd, sessionId) {
|
|
|
4871
4872
|
var cache = /* @__PURE__ */ new Map();
|
|
4872
4873
|
var inFlight = /* @__PURE__ */ new Map();
|
|
4873
4874
|
var CACHE_TTL_MS = 1e4;
|
|
4874
|
-
async function committedPaths(cwd,
|
|
4875
|
-
const key = `${cwd} ${
|
|
4875
|
+
async function committedPaths(cwd, sessionId2) {
|
|
4876
|
+
const key = `${cwd} ${sessionId2}`;
|
|
4876
4877
|
const cached2 = cache.get(key);
|
|
4877
4878
|
if (cached2 && cached2.expiresAt > Date.now()) return cached2.value;
|
|
4878
4879
|
const pending = inFlight.get(key);
|
|
4879
4880
|
if (pending) return pending;
|
|
4880
|
-
const lookup = loadCommittedPaths(cwd,
|
|
4881
|
+
const lookup = loadCommittedPaths(cwd, sessionId2).then((value) => {
|
|
4881
4882
|
cache.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS });
|
|
4882
4883
|
return value;
|
|
4883
4884
|
}).finally(() => inFlight.delete(key));
|
|
4884
4885
|
inFlight.set(key, lookup);
|
|
4885
4886
|
return lookup;
|
|
4886
4887
|
}
|
|
4887
|
-
async function loadCommittedPaths(cwd,
|
|
4888
|
-
const itemCommitRefs = await itemCommits(
|
|
4889
|
-
const commits2 = itemCommitRefs.length > 0 ? itemCommitRefs : await transcriptCommits(cwd,
|
|
4888
|
+
async function loadCommittedPaths(cwd, sessionId2) {
|
|
4889
|
+
const itemCommitRefs = await itemCommits(sessionId2);
|
|
4890
|
+
const commits2 = itemCommitRefs.length > 0 ? itemCommitRefs : await transcriptCommits(cwd, sessionId2);
|
|
4890
4891
|
const bases = /* @__PURE__ */ new Map();
|
|
4891
4892
|
for (const commit2 of commits2) {
|
|
4892
4893
|
const resolved = await resolveCommit(cwd, commit2.sha);
|
|
@@ -4908,28 +4909,28 @@ function includesCommittedChanges(cwd) {
|
|
|
4908
4909
|
}
|
|
4909
4910
|
|
|
4910
4911
|
// src/commands/sessions/web/itemScopeCommits.ts
|
|
4911
|
-
async function itemScopeCommits(cwd,
|
|
4912
|
-
if (!
|
|
4913
|
-
return (await committedPaths(cwd,
|
|
4912
|
+
async function itemScopeCommits(cwd, sessionId2) {
|
|
4913
|
+
if (!sessionId2 || !includesCommittedChanges(cwd)) return [];
|
|
4914
|
+
return (await committedPaths(cwd, sessionId2)).commits;
|
|
4914
4915
|
}
|
|
4915
4916
|
|
|
4916
4917
|
// src/commands/sessions/web/resolveDiffScope.ts
|
|
4917
|
-
async function resolveDiffScope(cwd,
|
|
4918
|
+
async function resolveDiffScope(cwd, sessionId2, scope) {
|
|
4918
4919
|
if (!scope || scope === "all") return { kind: "all" };
|
|
4919
4920
|
if (scope === "uncommitted") return { kind: "uncommitted" };
|
|
4920
4921
|
if (scope === "branch") {
|
|
4921
4922
|
const base = await branchDiffBase(cwd);
|
|
4922
4923
|
return base ? { kind: "branch", base } : void 0;
|
|
4923
4924
|
}
|
|
4924
|
-
const commits2 = await itemScopeCommits(cwd,
|
|
4925
|
+
const commits2 = await itemScopeCommits(cwd, sessionId2);
|
|
4925
4926
|
if (!commits2.some((commit2) => commit2.sha === scope)) return void 0;
|
|
4926
4927
|
return { kind: "commit", sha: scope };
|
|
4927
4928
|
}
|
|
4928
4929
|
|
|
4929
4930
|
// src/commands/sessions/web/itemChangeSet.ts
|
|
4930
|
-
async function itemChangeSet(cwd,
|
|
4931
|
-
if (!
|
|
4932
|
-
const { commits: commits2, bases } = await committedPaths(cwd,
|
|
4931
|
+
async function itemChangeSet(cwd, sessionId2) {
|
|
4932
|
+
if (!sessionId2 || !includesCommittedChanges(cwd)) return void 0;
|
|
4933
|
+
const { commits: commits2, bases } = await committedPaths(cwd, sessionId2);
|
|
4933
4934
|
if (bases.size === 0) return void 0;
|
|
4934
4935
|
const groups = groupByBase(bases);
|
|
4935
4936
|
const dirty = await dirtyPaths(cwd, bases);
|
|
@@ -5033,9 +5034,9 @@ async function diff(req, res) {
|
|
|
5033
5034
|
}
|
|
5034
5035
|
|
|
5035
5036
|
// src/commands/sessions/web/diffScopes.ts
|
|
5036
|
-
async function scopeCommits(cwd,
|
|
5037
|
+
async function scopeCommits(cwd, sessionId2) {
|
|
5037
5038
|
try {
|
|
5038
|
-
return await itemScopeCommits(cwd,
|
|
5039
|
+
return await itemScopeCommits(cwd, sessionId2);
|
|
5039
5040
|
} catch {
|
|
5040
5041
|
return [];
|
|
5041
5042
|
}
|
|
@@ -5282,12 +5283,12 @@ function requestSession(message3) {
|
|
|
5282
5283
|
return new Promise((resolve33, reject) => {
|
|
5283
5284
|
connectToDaemon().then((socket) => {
|
|
5284
5285
|
let settled = false;
|
|
5285
|
-
const finish2 = (error,
|
|
5286
|
+
const finish2 = (error, sessionId2) => {
|
|
5286
5287
|
if (settled) return;
|
|
5287
5288
|
settled = true;
|
|
5288
5289
|
socket.destroy();
|
|
5289
5290
|
if (error) reject(error);
|
|
5290
|
-
else resolve33(
|
|
5291
|
+
else resolve33(sessionId2);
|
|
5291
5292
|
};
|
|
5292
5293
|
readSocketLines(socket, (line) => {
|
|
5293
5294
|
const incoming = parseIncoming(line, message3.type);
|
|
@@ -5333,8 +5334,8 @@ async function launchFromGithub(req, res, plan2, launch) {
|
|
|
5333
5334
|
return;
|
|
5334
5335
|
}
|
|
5335
5336
|
try {
|
|
5336
|
-
const
|
|
5337
|
-
respondJson(res, 200, { sessionId, cwd: planned.cwd });
|
|
5337
|
+
const sessionId2 = await launch(planned);
|
|
5338
|
+
respondJson(res, 200, { sessionId: sessionId2, cwd: planned.cwd });
|
|
5338
5339
|
} catch (error) {
|
|
5339
5340
|
respondJson(res, 500, {
|
|
5340
5341
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -6576,6 +6577,11 @@ var reviewConfigHelp = [
|
|
|
6576
6577
|
key: "review.highLevel.collapsedPaths",
|
|
6577
6578
|
setter: 'assist config set review.highLevel.collapsedPaths "**/*.test.*,**/generated/**"',
|
|
6578
6579
|
note: "comma-separated globs whose files start collapsed in the high-level changed-files tree; every other file starts expanded (default **/*.test.*,**/generated/**)"
|
|
6580
|
+
},
|
|
6581
|
+
{
|
|
6582
|
+
key: "review.highLevel.slices",
|
|
6583
|
+
setter: "assist config set review.highLevel.slices true",
|
|
6584
|
+
note: "experimental; in an assist session, --high-level has the session agent split the PR into slices (via --slices) and groups the Structure item by slice (default false)"
|
|
6579
6585
|
}
|
|
6580
6586
|
];
|
|
6581
6587
|
|
|
@@ -7866,11 +7872,11 @@ function getOwnerPath(itemId2) {
|
|
|
7866
7872
|
return join19(homedir8(), ".assist", "signals", `owner-${itemId2}.json`);
|
|
7867
7873
|
}
|
|
7868
7874
|
function recordSignalOwner(itemId2) {
|
|
7869
|
-
const
|
|
7870
|
-
if (!
|
|
7875
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
7876
|
+
if (!sessionId2) return;
|
|
7871
7877
|
const path109 = getOwnerPath(itemId2);
|
|
7872
7878
|
mkdirSync4(dirname8(path109), { recursive: true });
|
|
7873
|
-
writeFileSync3(path109, JSON.stringify({ sessionId }));
|
|
7879
|
+
writeFileSync3(path109, JSON.stringify({ sessionId: sessionId2 }));
|
|
7874
7880
|
}
|
|
7875
7881
|
function readSignalOwner(itemId2) {
|
|
7876
7882
|
const path109 = getOwnerPath(itemId2);
|
|
@@ -7891,9 +7897,9 @@ function clearSignalOwner(itemId2) {
|
|
|
7891
7897
|
}
|
|
7892
7898
|
|
|
7893
7899
|
// src/commands/backlog/writeSignal.ts
|
|
7894
|
-
function getSignalPath(
|
|
7895
|
-
if (!
|
|
7896
|
-
return join20(homedir9(), ".assist", "signals", `signal-${
|
|
7900
|
+
function getSignalPath(sessionId2 = process.env.ASSIST_SESSION_ID) {
|
|
7901
|
+
if (!sessionId2) return void 0;
|
|
7902
|
+
return join20(homedir9(), ".assist", "signals", `signal-${sessionId2}.json`);
|
|
7897
7903
|
}
|
|
7898
7904
|
function resolveSignalTarget(event, data) {
|
|
7899
7905
|
const caller = process.env.ASSIST_SESSION_ID;
|
|
@@ -8231,7 +8237,7 @@ import * as fs6 from "fs";
|
|
|
8231
8237
|
|
|
8232
8238
|
// src/commands/sessions/shared/extractSessionMeta.ts
|
|
8233
8239
|
function extractSessionMeta(lines2) {
|
|
8234
|
-
let
|
|
8240
|
+
let sessionId2 = "";
|
|
8235
8241
|
let cwd = "";
|
|
8236
8242
|
let timestamp9 = "";
|
|
8237
8243
|
let name = "";
|
|
@@ -8240,7 +8246,7 @@ function extractSessionMeta(lines2) {
|
|
|
8240
8246
|
for (const line of lines2) {
|
|
8241
8247
|
const entry = safeParse(line);
|
|
8242
8248
|
if (!entry) continue;
|
|
8243
|
-
|
|
8249
|
+
sessionId2 ||= strField(entry, "sessionId");
|
|
8244
8250
|
timestamp9 ||= strField(entry, "timestamp");
|
|
8245
8251
|
cwd ||= strField(entry, "cwd");
|
|
8246
8252
|
if (entry.type === "user" && !entry.isMeta) {
|
|
@@ -8248,7 +8254,7 @@ function extractSessionMeta(lines2) {
|
|
|
8248
8254
|
break;
|
|
8249
8255
|
}
|
|
8250
8256
|
}
|
|
8251
|
-
return { sessionId, cwd, timestamp: timestamp9, name, commandName, commandArgs };
|
|
8257
|
+
return { sessionId: sessionId2, cwd, timestamp: timestamp9, name, commandName, commandArgs };
|
|
8252
8258
|
}
|
|
8253
8259
|
function parseFirstUserEntry(entry) {
|
|
8254
8260
|
const raw = messageText(entry);
|
|
@@ -8405,9 +8411,9 @@ async function itemConversations(item) {
|
|
|
8405
8411
|
});
|
|
8406
8412
|
}
|
|
8407
8413
|
for (const session of item.phaseSessions ?? []) {
|
|
8408
|
-
const { claudeSessionId:
|
|
8409
|
-
if (byId.has(
|
|
8410
|
-
byId.set(
|
|
8414
|
+
const { claudeSessionId: sessionId2, createdAt } = session;
|
|
8415
|
+
if (byId.has(sessionId2)) continue;
|
|
8416
|
+
byId.set(sessionId2, { sessionId: sessionId2, ...createdAt && { createdAt } });
|
|
8411
8417
|
}
|
|
8412
8418
|
if (byId.size === 0) return [];
|
|
8413
8419
|
const transcripts = await lookupSessionsById([...byId.keys()]);
|
|
@@ -14879,8 +14885,8 @@ async function init5() {
|
|
|
14879
14885
|
|
|
14880
14886
|
// src/commands/sessions/signalVerifying.ts
|
|
14881
14887
|
function signalVerifying() {
|
|
14882
|
-
const
|
|
14883
|
-
if (!
|
|
14888
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
14889
|
+
if (!sessionId2) return () => {
|
|
14884
14890
|
};
|
|
14885
14891
|
let socket;
|
|
14886
14892
|
let released = false;
|
|
@@ -14891,7 +14897,7 @@ function signalVerifying() {
|
|
|
14891
14897
|
});
|
|
14892
14898
|
connected.unref();
|
|
14893
14899
|
connected.write(
|
|
14894
|
-
`${JSON.stringify({ type: "verify-started", sessionId })}
|
|
14900
|
+
`${JSON.stringify({ type: "verify-started", sessionId: sessionId2 })}
|
|
14895
14901
|
`
|
|
14896
14902
|
);
|
|
14897
14903
|
}, ignoreUnreachableDaemon);
|
|
@@ -16163,15 +16169,15 @@ async function ask(options2) {
|
|
|
16163
16169
|
console.error("Error: --body is empty; there is nothing to ask about.");
|
|
16164
16170
|
process.exit(1);
|
|
16165
16171
|
}
|
|
16166
|
-
const
|
|
16167
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
16172
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
16173
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) {
|
|
16168
16174
|
console.log(body);
|
|
16169
16175
|
return;
|
|
16170
16176
|
}
|
|
16171
16177
|
const decision = await awaitPreviewApproval(
|
|
16172
16178
|
options2.title,
|
|
16173
16179
|
{
|
|
16174
|
-
sessionId,
|
|
16180
|
+
sessionId: sessionId2,
|
|
16175
16181
|
requestId: randomUUID3(),
|
|
16176
16182
|
title: options2.title,
|
|
16177
16183
|
body,
|
|
@@ -16297,9 +16303,9 @@ ${issues}`);
|
|
|
16297
16303
|
|
|
16298
16304
|
// src/commands/sessions/shared/isLiveDaemonSession.ts
|
|
16299
16305
|
var LIVE_TIMEOUT_MS = 1e3;
|
|
16300
|
-
async function isLiveDaemonSession(
|
|
16306
|
+
async function isLiveDaemonSession(sessionId2) {
|
|
16301
16307
|
const reply2 = await requestDaemonReply(
|
|
16302
|
-
{ type: "session-live", sessionId },
|
|
16308
|
+
{ type: "session-live", sessionId: sessionId2 },
|
|
16303
16309
|
"session-live",
|
|
16304
16310
|
LIVE_TIMEOUT_MS
|
|
16305
16311
|
);
|
|
@@ -16320,19 +16326,19 @@ async function askCheck(options2) {
|
|
|
16320
16326
|
"manual check"
|
|
16321
16327
|
);
|
|
16322
16328
|
rejectLongCheck(check2);
|
|
16323
|
-
const
|
|
16324
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
16329
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
16330
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2)
|
|
16325
16331
|
askInChat("not running in an assist session");
|
|
16326
16332
|
if (!loadConfig().sessions?.askQuestion)
|
|
16327
16333
|
askInChat("assist ask-check is disabled (sessions.askQuestion)");
|
|
16328
|
-
if (!await isLiveDaemonSession(
|
|
16334
|
+
if (!await isLiveDaemonSession(sessionId2))
|
|
16329
16335
|
askInChat(
|
|
16330
|
-
`session ${
|
|
16336
|
+
`session ${sessionId2} is not live in the assist daemon, so no preview pane can show the check`
|
|
16331
16337
|
);
|
|
16332
16338
|
const decision = await awaitPreviewApproval(
|
|
16333
16339
|
check2.title,
|
|
16334
16340
|
{
|
|
16335
|
-
sessionId,
|
|
16341
|
+
sessionId: sessionId2,
|
|
16336
16342
|
requestId: randomUUID4(),
|
|
16337
16343
|
title: check2.title,
|
|
16338
16344
|
body: JSON.stringify(check2),
|
|
@@ -16371,9 +16377,9 @@ import { randomUUID as randomUUID5 } from "crypto";
|
|
|
16371
16377
|
|
|
16372
16378
|
// src/commands/askDesign/designReviewSessionId.ts
|
|
16373
16379
|
async function designReviewSessionId() {
|
|
16374
|
-
const
|
|
16375
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
16376
|
-
return await isLiveDaemonSession(
|
|
16380
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
16381
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return void 0;
|
|
16382
|
+
return await isLiveDaemonSession(sessionId2) ? sessionId2 : void 0;
|
|
16377
16383
|
}
|
|
16378
16384
|
|
|
16379
16385
|
// src/commands/askDesign/isArtifactUrl.ts
|
|
@@ -16398,8 +16404,8 @@ async function askDesign(options2) {
|
|
|
16398
16404
|
process.exit(1);
|
|
16399
16405
|
}
|
|
16400
16406
|
const body = options2.body === void 0 ? "" : (await readBodyArgument(options2.body)).trim();
|
|
16401
|
-
const
|
|
16402
|
-
if (!
|
|
16407
|
+
const sessionId2 = await designReviewSessionId();
|
|
16408
|
+
if (!sessionId2) {
|
|
16403
16409
|
console.log(`Design: ${options2.url}`);
|
|
16404
16410
|
if (body) console.log(`
|
|
16405
16411
|
${body}`);
|
|
@@ -16408,7 +16414,7 @@ ${body}`);
|
|
|
16408
16414
|
const decision = await awaitPreviewApproval(
|
|
16409
16415
|
options2.title,
|
|
16410
16416
|
{
|
|
16411
|
-
sessionId,
|
|
16417
|
+
sessionId: sessionId2,
|
|
16412
16418
|
requestId: randomUUID5(),
|
|
16413
16419
|
title: options2.title,
|
|
16414
16420
|
body: body || DEFAULT_BODY,
|
|
@@ -16498,20 +16504,20 @@ async function askQuestion(options2) {
|
|
|
16498
16504
|
"AskUserQuestion input"
|
|
16499
16505
|
);
|
|
16500
16506
|
rejectLongQuestions(questions);
|
|
16501
|
-
const
|
|
16502
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
16507
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
16508
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2)
|
|
16503
16509
|
useBuiltIn("not running in an assist session");
|
|
16504
16510
|
if (!loadConfig().sessions?.askQuestion)
|
|
16505
16511
|
useBuiltIn("assist ask-question is disabled (sessions.askQuestion)");
|
|
16506
|
-
if (!await isLiveDaemonSession(
|
|
16512
|
+
if (!await isLiveDaemonSession(sessionId2))
|
|
16507
16513
|
useBuiltIn(
|
|
16508
|
-
`session ${
|
|
16514
|
+
`session ${sessionId2} is not live in the assist daemon, so no preview pane can show the form`
|
|
16509
16515
|
);
|
|
16510
16516
|
const title = questions.length === 1 ? "Claude is asking a question" : `Claude is asking ${questions.length} questions`;
|
|
16511
16517
|
const decision = await awaitPreviewApproval(
|
|
16512
16518
|
title,
|
|
16513
16519
|
{
|
|
16514
|
-
sessionId,
|
|
16520
|
+
sessionId: sessionId2,
|
|
16515
16521
|
requestId: randomUUID6(),
|
|
16516
16522
|
title,
|
|
16517
16523
|
body: JSON.stringify({ questions }),
|
|
@@ -17075,14 +17081,14 @@ function readTranscriptHead(filePath, maxBytes = 65536) {
|
|
|
17075
17081
|
|
|
17076
17082
|
// src/commands/sessions/shared/resolveSessionTranscript.ts
|
|
17077
17083
|
var MAX_PROMPT_LENGTH = 80;
|
|
17078
|
-
function resolveSessionTranscript(
|
|
17079
|
-
const filePath = findTranscriptFile(
|
|
17084
|
+
function resolveSessionTranscript(sessionId2, projectsRoot = claudeProjectsRoot()) {
|
|
17085
|
+
const filePath = findTranscriptFile(sessionId2, projectsRoot);
|
|
17080
17086
|
if (!filePath) return void 0;
|
|
17081
17087
|
const head = readTranscriptHead(filePath);
|
|
17082
17088
|
const meta = extractSessionMeta(head ? head.split("\n").filter(Boolean) : []);
|
|
17083
17089
|
return { path: filePath, prompt: promptOf(meta) };
|
|
17084
17090
|
}
|
|
17085
|
-
function findTranscriptFile(
|
|
17091
|
+
function findTranscriptFile(sessionId2, projectsRoot) {
|
|
17086
17092
|
let projectDirs;
|
|
17087
17093
|
try {
|
|
17088
17094
|
projectDirs = fs16.readdirSync(projectsRoot);
|
|
@@ -17090,7 +17096,7 @@ function findTranscriptFile(sessionId, projectsRoot) {
|
|
|
17090
17096
|
return void 0;
|
|
17091
17097
|
}
|
|
17092
17098
|
for (const dir of projectDirs) {
|
|
17093
|
-
const candidate = path28.join(projectsRoot, dir, `${
|
|
17099
|
+
const candidate = path28.join(projectsRoot, dir, `${sessionId2}.jsonl`);
|
|
17094
17100
|
if (fs16.existsSync(candidate)) return candidate;
|
|
17095
17101
|
}
|
|
17096
17102
|
return void 0;
|
|
@@ -17923,11 +17929,11 @@ function renderPhaseSection(phase, idx) {
|
|
|
17923
17929
|
|
|
17924
17930
|
// src/commands/backlog/addPhase/reviewProposedPhase.ts
|
|
17925
17931
|
async function reviewProposedPhase(item, phaseIdx, phase) {
|
|
17926
|
-
const
|
|
17927
|
-
if (!isClaudeCode() || process.env.ASSIST_SESSION !== "1" || !
|
|
17932
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
17933
|
+
if (!isClaudeCode() || process.env.ASSIST_SESSION !== "1" || !sessionId2)
|
|
17928
17934
|
return;
|
|
17929
17935
|
await awaitPreviewApproval("Backlog phase preview", {
|
|
17930
|
-
sessionId,
|
|
17936
|
+
sessionId: sessionId2,
|
|
17931
17937
|
requestId: randomUUID7(),
|
|
17932
17938
|
title: `Add a phase to ${formatItemId(item.id)}: ${item.name}`,
|
|
17933
17939
|
body: renderPhaseSection(phase, phaseIdx),
|
|
@@ -18130,11 +18136,11 @@ function renderProposedItem(item) {
|
|
|
18130
18136
|
}
|
|
18131
18137
|
|
|
18132
18138
|
// src/commands/backlog/propose/reviewProposal.ts
|
|
18133
|
-
async function reviewProposal(item,
|
|
18139
|
+
async function reviewProposal(item, sessionId2, confirmed, revises) {
|
|
18134
18140
|
const body = renderProposedItem(item);
|
|
18135
|
-
if (
|
|
18141
|
+
if (sessionId2) {
|
|
18136
18142
|
const decision = await awaitPreviewApproval("Backlog item preview", {
|
|
18137
|
-
sessionId,
|
|
18143
|
+
sessionId: sessionId2,
|
|
18138
18144
|
requestId: randomUUID8(),
|
|
18139
18145
|
title: revises === void 0 ? item.name : `Update ${formatItemId(revises)}: ${item.name}`,
|
|
18140
18146
|
body,
|
|
@@ -18306,14 +18312,14 @@ async function findPredecessor(path109, token, startedAt) {
|
|
|
18306
18312
|
// src/commands/backlog/propose/proposalLedgerPath.ts
|
|
18307
18313
|
import { homedir as homedir14 } from "os";
|
|
18308
18314
|
import { join as join49 } from "path";
|
|
18309
|
-
function proposalLedgerPath(
|
|
18310
|
-
return join49(homedir14(), ".assist", "proposals", `session-${
|
|
18315
|
+
function proposalLedgerPath(sessionId2) {
|
|
18316
|
+
return join49(homedir14(), ".assist", "proposals", `session-${sessionId2}.json`);
|
|
18311
18317
|
}
|
|
18312
18318
|
|
|
18313
18319
|
// src/commands/backlog/propose/trackProposal.ts
|
|
18314
18320
|
var STALE_OPEN_MS = 60 * 6e4;
|
|
18315
|
-
function trackProposal(
|
|
18316
|
-
const path109 = proposalLedgerPath(
|
|
18321
|
+
function trackProposal(sessionId2) {
|
|
18322
|
+
const path109 = proposalLedgerPath(sessionId2);
|
|
18317
18323
|
const token = randomUUID9();
|
|
18318
18324
|
const startedAt = Date.now();
|
|
18319
18325
|
mutateLedger(path109, (ledger) => {
|
|
@@ -18345,8 +18351,8 @@ function trackProposal(sessionId) {
|
|
|
18345
18351
|
// src/commands/backlog/propose.ts
|
|
18346
18352
|
async function propose(options2) {
|
|
18347
18353
|
if (!ensureRemoteOrigin()) return;
|
|
18348
|
-
const
|
|
18349
|
-
if (
|
|
18354
|
+
const sessionId2 = process.env.ASSIST_SESSION === "1" ? process.env.ASSIST_SESSION_ID : void 0;
|
|
18355
|
+
if (sessionId2 && options2.confirmed) {
|
|
18350
18356
|
console.error(
|
|
18351
18357
|
chalk63.red(
|
|
18352
18358
|
"Error: --confirmed cannot be used in a web session. The preview pane is the gate \u2014 run 'assist backlog propose --json <file|->' without --confirmed and the item is created on approval."
|
|
@@ -18356,11 +18362,11 @@ async function propose(options2) {
|
|
|
18356
18362
|
return;
|
|
18357
18363
|
}
|
|
18358
18364
|
const item = await readProposedItem(options2.json);
|
|
18359
|
-
const tracker =
|
|
18365
|
+
const tracker = sessionId2 ? trackProposal(sessionId2) : void 0;
|
|
18360
18366
|
try {
|
|
18361
18367
|
const approval = await reviewProposal(
|
|
18362
18368
|
item,
|
|
18363
|
-
|
|
18369
|
+
sessionId2,
|
|
18364
18370
|
options2.confirmed === true,
|
|
18365
18371
|
tracker?.knownPredecessor()
|
|
18366
18372
|
);
|
|
@@ -19415,21 +19421,21 @@ async function readHookClaudeSessionId() {
|
|
|
19415
19421
|
var RELIABLE_ATTEMPTS = 3;
|
|
19416
19422
|
var RETRY_DELAY_MS2 = 100;
|
|
19417
19423
|
async function setSessionStatus(status2, opts = {}) {
|
|
19418
|
-
const
|
|
19419
|
-
logHookFired(status2,
|
|
19420
|
-
if (!
|
|
19424
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
19425
|
+
logHookFired(status2, sessionId2, opts.source);
|
|
19426
|
+
if (!sessionId2) return;
|
|
19421
19427
|
const payload = buildPayload(
|
|
19422
|
-
|
|
19428
|
+
sessionId2,
|
|
19423
19429
|
status2,
|
|
19424
19430
|
opts.source,
|
|
19425
19431
|
await readHookClaudeSessionId()
|
|
19426
19432
|
);
|
|
19427
|
-
await deliver(
|
|
19433
|
+
await deliver(sessionId2, status2, payload, opts.ack ? RELIABLE_ATTEMPTS : 1);
|
|
19428
19434
|
}
|
|
19429
|
-
function buildPayload(
|
|
19435
|
+
function buildPayload(sessionId2, status2, source, claudeSessionId) {
|
|
19430
19436
|
const payload = {
|
|
19431
19437
|
type: "set-status",
|
|
19432
|
-
sessionId,
|
|
19438
|
+
sessionId: sessionId2,
|
|
19433
19439
|
status: status2
|
|
19434
19440
|
};
|
|
19435
19441
|
if (claudeSessionId) payload.claudeSessionId = claudeSessionId;
|
|
@@ -19437,7 +19443,7 @@ function buildPayload(sessionId, status2, source, claudeSessionId) {
|
|
|
19437
19443
|
payload.ack = true;
|
|
19438
19444
|
return payload;
|
|
19439
19445
|
}
|
|
19440
|
-
async function deliver(
|
|
19446
|
+
async function deliver(sessionId2, status2, payload, attempts) {
|
|
19441
19447
|
for (let attempt2 = 1; attempt2 <= attempts; attempt2++) {
|
|
19442
19448
|
try {
|
|
19443
19449
|
await sendToDaemonAwaitAck(payload);
|
|
@@ -19448,7 +19454,7 @@ async function deliver(sessionId, status2, payload, attempts) {
|
|
|
19448
19454
|
continue;
|
|
19449
19455
|
}
|
|
19450
19456
|
appendDaemonLog(
|
|
19451
|
-
`set-status delivery failed after ${attempts} attempt${attempts === 1 ? "" : "s"}: id=${
|
|
19457
|
+
`set-status delivery failed after ${attempts} attempt${attempts === 1 ? "" : "s"}: id=${sessionId2} status=${status2}${payload.source ? ` source=${payload.source}` : ""}: ${describeError(error)}`
|
|
19452
19458
|
);
|
|
19453
19459
|
}
|
|
19454
19460
|
}
|
|
@@ -19459,9 +19465,9 @@ function sleep(ms) {
|
|
|
19459
19465
|
function describeError(error) {
|
|
19460
19466
|
return error instanceof Error ? error.message : String(error);
|
|
19461
19467
|
}
|
|
19462
|
-
function logHookFired(status2,
|
|
19468
|
+
function logHookFired(status2, sessionId2, source) {
|
|
19463
19469
|
appendDaemonLog(
|
|
19464
|
-
`set-status hook fired: id=${
|
|
19470
|
+
`set-status hook fired: id=${sessionId2 ?? "none"} status=${status2}${source ? ` source=${source}` : ""}`
|
|
19465
19471
|
);
|
|
19466
19472
|
}
|
|
19467
19473
|
|
|
@@ -19767,13 +19773,13 @@ var activitySchema = z16.object({
|
|
|
19767
19773
|
watchState: z16.enum(["waiting", "updating"]).optional(),
|
|
19768
19774
|
startedAt: z16.number()
|
|
19769
19775
|
});
|
|
19770
|
-
function activityPath(
|
|
19771
|
-
return join52(homedir17(), ".assist", "activity", `activity-${
|
|
19776
|
+
function activityPath(sessionId2) {
|
|
19777
|
+
return join52(homedir17(), ".assist", "activity", `activity-${sessionId2}.json`);
|
|
19772
19778
|
}
|
|
19773
19779
|
function emitActivity(activity2) {
|
|
19774
|
-
const
|
|
19775
|
-
if (!
|
|
19776
|
-
const path109 = activityPath(
|
|
19780
|
+
const sessionId2 = process.env.ASSIST_ACTIVITY_ID;
|
|
19781
|
+
if (!sessionId2) return;
|
|
19782
|
+
const path109 = activityPath(sessionId2);
|
|
19777
19783
|
mkdirSync14(dirname28(path109), { recursive: true });
|
|
19778
19784
|
writeFileSync23(path109, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
19779
19785
|
}
|
|
@@ -19784,17 +19790,17 @@ function readActivity(path109) {
|
|
|
19784
19790
|
return void 0;
|
|
19785
19791
|
}
|
|
19786
19792
|
}
|
|
19787
|
-
function reconcileActivity(
|
|
19793
|
+
function reconcileActivity(sessionId2, activity2) {
|
|
19788
19794
|
if (!activity2) {
|
|
19789
|
-
removeActivity(
|
|
19795
|
+
removeActivity(sessionId2);
|
|
19790
19796
|
return;
|
|
19791
19797
|
}
|
|
19792
|
-
const path109 = activityPath(
|
|
19798
|
+
const path109 = activityPath(sessionId2);
|
|
19793
19799
|
mkdirSync14(dirname28(path109), { recursive: true });
|
|
19794
19800
|
writeFileSync23(path109, JSON.stringify(activity2));
|
|
19795
19801
|
}
|
|
19796
|
-
function writeActivityIfAbsent(
|
|
19797
|
-
const path109 = activityPath(
|
|
19802
|
+
function writeActivityIfAbsent(sessionId2, activity2) {
|
|
19803
|
+
const path109 = activityPath(sessionId2);
|
|
19798
19804
|
mkdirSync14(dirname28(path109), { recursive: true });
|
|
19799
19805
|
try {
|
|
19800
19806
|
writeFileSync23(path109, JSON.stringify(activity2), { flag: "wx" });
|
|
@@ -19804,9 +19810,9 @@ function writeActivityIfAbsent(sessionId, activity2) {
|
|
|
19804
19810
|
throw error;
|
|
19805
19811
|
}
|
|
19806
19812
|
}
|
|
19807
|
-
function removeActivity(
|
|
19813
|
+
function removeActivity(sessionId2) {
|
|
19808
19814
|
try {
|
|
19809
|
-
rmSync4(activityPath(
|
|
19815
|
+
rmSync4(activityPath(sessionId2));
|
|
19810
19816
|
} catch {
|
|
19811
19817
|
}
|
|
19812
19818
|
}
|
|
@@ -19843,15 +19849,15 @@ import chalk77 from "chalk";
|
|
|
19843
19849
|
|
|
19844
19850
|
// src/commands/sessions/shared/findSessionJsonlPath.ts
|
|
19845
19851
|
import * as path29 from "path";
|
|
19846
|
-
async function findSessionJsonlPath(
|
|
19852
|
+
async function findSessionJsonlPath(sessionId2) {
|
|
19847
19853
|
const paths = await discoverSessionJsonlPaths();
|
|
19848
19854
|
const direct = paths.find(
|
|
19849
|
-
(p) => path29.basename(p.path, ".jsonl") ===
|
|
19855
|
+
(p) => path29.basename(p.path, ".jsonl") === sessionId2
|
|
19850
19856
|
);
|
|
19851
19857
|
if (direct) return direct.path;
|
|
19852
19858
|
for (const p of paths) {
|
|
19853
19859
|
const meta = await parseSessionFile(p.path, p.origin);
|
|
19854
|
-
if (meta?.sessionId ===
|
|
19860
|
+
if (meta?.sessionId === sessionId2) return p.path;
|
|
19855
19861
|
}
|
|
19856
19862
|
return null;
|
|
19857
19863
|
}
|
|
@@ -21330,10 +21336,10 @@ function renderPlanUpdate(item, phases) {
|
|
|
21330
21336
|
// src/commands/backlog/updatePlan/reviewPlanUpdate.ts
|
|
21331
21337
|
async function reviewPlanUpdate(item, phases) {
|
|
21332
21338
|
const body = renderPlanUpdate(item, phases);
|
|
21333
|
-
const
|
|
21334
|
-
if (process.env.ASSIST_SESSION === "1" &&
|
|
21339
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
21340
|
+
if (process.env.ASSIST_SESSION === "1" && sessionId2) {
|
|
21335
21341
|
const decision = await awaitPreviewApproval("Plan update preview", {
|
|
21336
|
-
sessionId,
|
|
21342
|
+
sessionId: sessionId2,
|
|
21337
21343
|
requestId: randomUUID12(),
|
|
21338
21344
|
title: `Update the plan for ${formatItemId(item.id)}: ${item.name}`,
|
|
21339
21345
|
body,
|
|
@@ -23621,11 +23627,11 @@ function showNotification(options2) {
|
|
|
23621
23627
|
// src/commands/notify/deliverPinNotification.ts
|
|
23622
23628
|
var ROUTE_TIMEOUT_MS = 1e4;
|
|
23623
23629
|
async function relayToViewerNode(notification) {
|
|
23624
|
-
const
|
|
23625
|
-
if (!
|
|
23630
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
23631
|
+
if (!sessionId2) return void 0;
|
|
23626
23632
|
const requestId = randomUUID13();
|
|
23627
23633
|
const reply2 = await requestDaemonReply(
|
|
23628
|
-
{ type: "notify-pin", sessionId, requestId, ...notification },
|
|
23634
|
+
{ type: "notify-pin", sessionId: sessionId2, requestId, ...notification },
|
|
23629
23635
|
"notify-pin-result",
|
|
23630
23636
|
ROUTE_TIMEOUT_MS
|
|
23631
23637
|
);
|
|
@@ -23748,18 +23754,18 @@ function parseCodexHookInput(raw) {
|
|
|
23748
23754
|
// src/commands/codexHook/relayCodexUsage.ts
|
|
23749
23755
|
var USAGE_EVENTS = /* @__PURE__ */ new Set(["PostToolUse", "Stop"]);
|
|
23750
23756
|
async function relayCodexUsage(event, transcriptPath2) {
|
|
23751
|
-
const
|
|
23752
|
-
if (!
|
|
23757
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
23758
|
+
if (!sessionId2 || !transcriptPath2 || !USAGE_EVENTS.has(event)) return;
|
|
23753
23759
|
try {
|
|
23754
23760
|
await sendToDaemonAwaitAck({
|
|
23755
23761
|
type: "codex-usage",
|
|
23756
|
-
sessionId,
|
|
23762
|
+
sessionId: sessionId2,
|
|
23757
23763
|
transcriptPath: transcriptPath2,
|
|
23758
23764
|
ack: true
|
|
23759
23765
|
});
|
|
23760
23766
|
} catch (error) {
|
|
23761
23767
|
appendDaemonLog(
|
|
23762
|
-
`codex-usage relay failed: id=${
|
|
23768
|
+
`codex-usage relay failed: id=${sessionId2}: ${error instanceof Error ? error.message : String(error)}`
|
|
23763
23769
|
);
|
|
23764
23770
|
}
|
|
23765
23771
|
}
|
|
@@ -29411,10 +29417,10 @@ function validateProposedContent(labels, title, body) {
|
|
|
29411
29417
|
// src/commands/github/issue/reviewProposedIssueComment.ts
|
|
29412
29418
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
29413
29419
|
async function reviewProposedIssueComment(title, body) {
|
|
29414
|
-
const
|
|
29415
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
29420
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
29421
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return;
|
|
29416
29422
|
await awaitPreviewApproval("GitHub issue comment preview", {
|
|
29417
|
-
sessionId,
|
|
29423
|
+
sessionId: sessionId2,
|
|
29418
29424
|
requestId: randomUUID14(),
|
|
29419
29425
|
title,
|
|
29420
29426
|
body,
|
|
@@ -29935,10 +29941,10 @@ function resolveCreateIssueMetadata(options2) {
|
|
|
29935
29941
|
// src/commands/github/issue/reviewProposedIssue.ts
|
|
29936
29942
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
29937
29943
|
async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
29938
|
-
const
|
|
29939
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
29944
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
29945
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return void 0;
|
|
29940
29946
|
return await awaitPreviewApproval("GitHub issue preview", {
|
|
29941
|
-
sessionId,
|
|
29947
|
+
sessionId: sessionId2,
|
|
29942
29948
|
requestId: randomUUID15(),
|
|
29943
29949
|
title,
|
|
29944
29950
|
body,
|
|
@@ -30241,12 +30247,12 @@ function pushUnchangedIssue(number, repo, target, fetchedAt, bodyPath) {
|
|
|
30241
30247
|
// src/commands/github/issue/reviewProposedIssueEdit.ts
|
|
30242
30248
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
30243
30249
|
async function reviewProposedIssueEdit(title, body, working) {
|
|
30244
|
-
const
|
|
30245
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
30250
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
30251
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return body;
|
|
30246
30252
|
const decision = await awaitPreviewApproval(
|
|
30247
30253
|
"GitHub issue edit preview",
|
|
30248
30254
|
{
|
|
30249
|
-
sessionId,
|
|
30255
|
+
sessionId: sessionId2,
|
|
30250
30256
|
requestId: randomUUID16(),
|
|
30251
30257
|
title,
|
|
30252
30258
|
body,
|
|
@@ -31625,12 +31631,12 @@ function sendToDaemon(message3) {
|
|
|
31625
31631
|
// src/commands/review/reportCwdToDaemon.ts
|
|
31626
31632
|
async function reportCwdToDaemon(cwd) {
|
|
31627
31633
|
if (!inWebSession()) return;
|
|
31628
|
-
const
|
|
31634
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
31629
31635
|
try {
|
|
31630
|
-
await sendToDaemon({ type: "set-cwd", sessionId, cwd });
|
|
31636
|
+
await sendToDaemon({ type: "set-cwd", sessionId: sessionId2, cwd });
|
|
31631
31637
|
} catch (error) {
|
|
31632
31638
|
appendDaemonLog(
|
|
31633
|
-
`set-cwd send failed: id=${
|
|
31639
|
+
`set-cwd send failed: id=${sessionId2}: ${error instanceof Error ? error.message : String(error)}`
|
|
31634
31640
|
);
|
|
31635
31641
|
}
|
|
31636
31642
|
}
|
|
@@ -32090,12 +32096,12 @@ function anchorSource(options2) {
|
|
|
32090
32096
|
topLeft: parseAnchorId(options2.topLeft),
|
|
32091
32097
|
bottomRight: parseAnchorId(options2.bottomRight)
|
|
32092
32098
|
};
|
|
32093
|
-
const
|
|
32094
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
32099
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
32100
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2)
|
|
32095
32101
|
throw new MiroExtractError(
|
|
32096
32102
|
"Both --top-left <id|link> and --bottom-right <id|link> are required: there is no assist session to host the picker pane."
|
|
32097
32103
|
);
|
|
32098
|
-
return { pick: true, sessionId };
|
|
32104
|
+
return { pick: true, sessionId: sessionId2 };
|
|
32099
32105
|
}
|
|
32100
32106
|
|
|
32101
32107
|
// src/commands/miro/miroSource.ts
|
|
@@ -32367,11 +32373,11 @@ function encodeMiroBoardPreview(items2) {
|
|
|
32367
32373
|
|
|
32368
32374
|
// src/commands/miro/pickAnchors.ts
|
|
32369
32375
|
var skipAdvice = "Re-run with --top-left <id|link> --bottom-right <id|link> to skip the picker.";
|
|
32370
|
-
async function pickAnchors(
|
|
32376
|
+
async function pickAnchors(sessionId2, items2) {
|
|
32371
32377
|
const decision = await awaitPreviewApproval(
|
|
32372
32378
|
"Miro anchor selection",
|
|
32373
32379
|
{
|
|
32374
|
-
sessionId,
|
|
32380
|
+
sessionId: sessionId2,
|
|
32375
32381
|
requestId: randomUUID19(),
|
|
32376
32382
|
title: "Pick the top-left then the bottom-right box",
|
|
32377
32383
|
body: encodeMiroBoardPreview(items2),
|
|
@@ -33605,10 +33611,10 @@ function postReviewComment(vars) {
|
|
|
33605
33611
|
// src/commands/prs/reviewProposedPrComment.ts
|
|
33606
33612
|
import { randomUUID as randomUUID20 } from "crypto";
|
|
33607
33613
|
async function reviewProposedPrComment(title, body, prNumber) {
|
|
33608
|
-
const
|
|
33609
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
33614
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
33615
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return;
|
|
33610
33616
|
await awaitPreviewApproval("PR comment preview", {
|
|
33611
|
-
sessionId,
|
|
33617
|
+
sessionId: sessionId2,
|
|
33612
33618
|
requestId: randomUUID20(),
|
|
33613
33619
|
title,
|
|
33614
33620
|
body,
|
|
@@ -34755,10 +34761,10 @@ async function edit(options2) {
|
|
|
34755
34761
|
const { number, title, body } = getCurrentPr();
|
|
34756
34762
|
const newBody = editPrBody(body, options2);
|
|
34757
34763
|
validatePrContent(options2.title ?? "", newBody);
|
|
34758
|
-
const
|
|
34759
|
-
if (process.env.ASSIST_SESSION === "1" &&
|
|
34764
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
34765
|
+
if (process.env.ASSIST_SESSION === "1" && sessionId2) {
|
|
34760
34766
|
await previewAndApplyEdit({
|
|
34761
|
-
sessionId,
|
|
34767
|
+
sessionId: sessionId2,
|
|
34762
34768
|
number,
|
|
34763
34769
|
title: options2.title,
|
|
34764
34770
|
currentTitle: title,
|
|
@@ -35106,10 +35112,10 @@ async function raise(options2, command) {
|
|
|
35106
35112
|
const { title, body } = buildValidatedBody(options2, USAGE7);
|
|
35107
35113
|
const resolved = { ...options2, draft: resolveDraftState(options2, command) };
|
|
35108
35114
|
const existing = findOpenPrNumber();
|
|
35109
|
-
const
|
|
35110
|
-
if (process.env.ASSIST_SESSION === "1" &&
|
|
35115
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
35116
|
+
if (process.env.ASSIST_SESSION === "1" && sessionId2) {
|
|
35111
35117
|
await previewAndPlace({
|
|
35112
|
-
sessionId,
|
|
35118
|
+
sessionId: sessionId2,
|
|
35113
35119
|
title,
|
|
35114
35120
|
body,
|
|
35115
35121
|
prNumber: existing,
|
|
@@ -39886,7 +39892,8 @@ function resolveHighLevelConfig(config) {
|
|
|
39886
39892
|
uiPaths: highLevel?.uiPaths ?? [],
|
|
39887
39893
|
descriptionWordCap: highLevel?.descriptionWordCap ?? DEFAULT_DESCRIPTION_WORD_CAP,
|
|
39888
39894
|
testPaths: highLevel?.testPaths ?? DEFAULT_TEST_PATHS,
|
|
39889
|
-
collapsedPaths: highLevel?.collapsedPaths ?? DEFAULT_COLLAPSED_PATHS
|
|
39895
|
+
collapsedPaths: highLevel?.collapsedPaths ?? DEFAULT_COLLAPSED_PATHS,
|
|
39896
|
+
slices: highLevel?.slices ?? false
|
|
39890
39897
|
};
|
|
39891
39898
|
}
|
|
39892
39899
|
|
|
@@ -40031,7 +40038,7 @@ function buildHighLevelStructure(files) {
|
|
|
40031
40038
|
// src/commands/review/highLevel/capHighLevelPatches.ts
|
|
40032
40039
|
import { minimatch as minimatch5 } from "minimatch";
|
|
40033
40040
|
|
|
40034
|
-
// src/commands/review/highLevel/
|
|
40041
|
+
// src/commands/review/highLevel/hunksOf.ts
|
|
40035
40042
|
function hunksOf(patch2) {
|
|
40036
40043
|
const hunks = [];
|
|
40037
40044
|
for (const line of patch2.split("\n")) {
|
|
@@ -40042,6 +40049,8 @@ ${line}`;
|
|
|
40042
40049
|
}
|
|
40043
40050
|
return hunks;
|
|
40044
40051
|
}
|
|
40052
|
+
|
|
40053
|
+
// src/commands/review/highLevel/capPatchToBudget.ts
|
|
40045
40054
|
function capPatchToBudget(patch2, budget) {
|
|
40046
40055
|
const kept = [];
|
|
40047
40056
|
let lines2 = 0;
|
|
@@ -40088,219 +40097,6 @@ function capHighLevelPatches(files, criticalPaths) {
|
|
|
40088
40097
|
return files.map((file) => byPath.get(file.path) ?? file);
|
|
40089
40098
|
}
|
|
40090
40099
|
|
|
40091
|
-
// src/commands/review/highLevel/testChangeExcerpts.ts
|
|
40092
|
-
var CONTEXT_LINES = 3;
|
|
40093
|
-
function testChangeExcerpts(source, line, changedLines2) {
|
|
40094
|
-
const lines2 = source.split("\n");
|
|
40095
|
-
const windows = [];
|
|
40096
|
-
for (const changed of [...changedLines2].sort((a, b) => a - b)) {
|
|
40097
|
-
const start2 = Math.max(0, changed - line - CONTEXT_LINES);
|
|
40098
|
-
const end = Math.min(lines2.length - 1, changed - line + CONTEXT_LINES);
|
|
40099
|
-
const last = windows.at(-1);
|
|
40100
|
-
if (last && start2 <= last.end + 1) last.end = Math.max(last.end, end);
|
|
40101
|
-
else windows.push({ start: start2, end });
|
|
40102
|
-
}
|
|
40103
|
-
return windows.map(({ start: start2, end }) => ({
|
|
40104
|
-
line: line + start2,
|
|
40105
|
-
source: lines2.slice(start2, end + 1).join("\n")
|
|
40106
|
-
}));
|
|
40107
|
-
}
|
|
40108
|
-
|
|
40109
|
-
// src/commands/review/highLevel/shownForm.ts
|
|
40110
|
-
var MAX_TEST_SOURCE_LINES = 200;
|
|
40111
|
-
function shownForm(test) {
|
|
40112
|
-
const { source, changedLines: changedLines2, ...rest } = test;
|
|
40113
|
-
if (source === void 0) return void 0;
|
|
40114
|
-
const lines2 = lineCount(source);
|
|
40115
|
-
if (lines2 <= MAX_TEST_SOURCE_LINES)
|
|
40116
|
-
return { lines: lines2, shown: { ...rest, source } };
|
|
40117
|
-
if (!changedLines2) return void 0;
|
|
40118
|
-
const excerpts = testChangeExcerpts(source, test.line, changedLines2);
|
|
40119
|
-
const excerptLines = excerpts.reduce(
|
|
40120
|
-
(sum3, excerpt2) => sum3 + lineCount(excerpt2.source),
|
|
40121
|
-
0
|
|
40122
|
-
);
|
|
40123
|
-
return excerptLines <= MAX_TEST_SOURCE_LINES ? { lines: excerptLines, shown: { ...rest, excerpts } } : void 0;
|
|
40124
|
-
}
|
|
40125
|
-
function lineCount(text20) {
|
|
40126
|
-
return text20.split("\n").length;
|
|
40127
|
-
}
|
|
40128
|
-
|
|
40129
|
-
// src/commands/review/highLevel/capHighLevelTestSources.ts
|
|
40130
|
-
var MAX_TOTAL_SOURCE_LINES = 5e3;
|
|
40131
|
-
function collectCases(nodes) {
|
|
40132
|
-
return nodes.flatMap(
|
|
40133
|
-
(node) => node.kind === "it" ? [node] : collectCases(node.children)
|
|
40134
|
-
);
|
|
40135
|
-
}
|
|
40136
|
-
function shippedForms(files) {
|
|
40137
|
-
const sized = files.flatMap((file) => collectCases(file.tests)).flatMap((test) => {
|
|
40138
|
-
const form = shownForm(test);
|
|
40139
|
-
return form ? [{ test, form }] : [];
|
|
40140
|
-
}).sort((a, b) => a.form.lines - b.form.lines);
|
|
40141
|
-
const shipped = /* @__PURE__ */ new Map();
|
|
40142
|
-
let remaining = MAX_TOTAL_SOURCE_LINES;
|
|
40143
|
-
for (const { test, form } of sized) {
|
|
40144
|
-
if (form.lines > remaining) break;
|
|
40145
|
-
remaining -= form.lines;
|
|
40146
|
-
shipped.set(test, form);
|
|
40147
|
-
}
|
|
40148
|
-
return shipped;
|
|
40149
|
-
}
|
|
40150
|
-
function capHighLevelTestSources(files) {
|
|
40151
|
-
const shipped = shippedForms(files);
|
|
40152
|
-
const capCase = (test) => {
|
|
40153
|
-
const form = shipped.get(test);
|
|
40154
|
-
if (form) return form.shown;
|
|
40155
|
-
const { source, changedLines: _changedLines, ...rest } = test;
|
|
40156
|
-
if (source === void 0) return rest;
|
|
40157
|
-
return shownForm(test) ? { ...rest, overBudget: true } : { ...rest, truncated: true };
|
|
40158
|
-
};
|
|
40159
|
-
const capNode = (node) => node.kind === "it" ? capCase(node) : { ...node, children: node.children.map(capNode) };
|
|
40160
|
-
return files.map((file) => ({ ...file, tests: file.tests.map(capNode) }));
|
|
40161
|
-
}
|
|
40162
|
-
|
|
40163
|
-
// src/commands/review/highLevel/collectHighLevelTests.ts
|
|
40164
|
-
import { minimatch as minimatch6 } from "minimatch";
|
|
40165
|
-
|
|
40166
|
-
// src/commands/review/highLevel/extractTestHierarchy.ts
|
|
40167
|
-
import { Node as Node4, Project as Project5 } from "ts-morph";
|
|
40168
|
-
|
|
40169
|
-
// src/commands/review/highLevel/classifyTestCall.ts
|
|
40170
|
-
import { Node as Node2 } from "ts-morph";
|
|
40171
|
-
var SUITE_ROOTS = /* @__PURE__ */ new Set(["describe", "context", "suite"]);
|
|
40172
|
-
var CASE_ROOTS = /* @__PURE__ */ new Set(["it", "test", "specify"]);
|
|
40173
|
-
function calleeChain(expression) {
|
|
40174
|
-
if (Node2.isIdentifier(expression)) return [expression.getText()];
|
|
40175
|
-
if (Node2.isPropertyAccessExpression(expression))
|
|
40176
|
-
return [...calleeChain(expression.getExpression()), expression.getName()];
|
|
40177
|
-
if (Node2.isCallExpression(expression))
|
|
40178
|
-
return calleeChain(expression.getExpression());
|
|
40179
|
-
return [];
|
|
40180
|
-
}
|
|
40181
|
-
function hasName(call) {
|
|
40182
|
-
const [first] = call.getArguments();
|
|
40183
|
-
return first !== void 0 && !Node2.isFunctionLikeDeclaration(first) && !Node2.isObjectLiteralExpression(first);
|
|
40184
|
-
}
|
|
40185
|
-
function classifyTestCall(call) {
|
|
40186
|
-
const [root2, ...rest] = calleeChain(call.getExpression());
|
|
40187
|
-
if (root2 === void 0 || !hasName(call)) return void 0;
|
|
40188
|
-
if (SUITE_ROOTS.has(root2) || rest.includes("describe")) return "describe";
|
|
40189
|
-
if (CASE_ROOTS.has(root2)) return "it";
|
|
40190
|
-
return void 0;
|
|
40191
|
-
}
|
|
40192
|
-
|
|
40193
|
-
// src/commands/review/highLevel/testName.ts
|
|
40194
|
-
import { Node as Node3 } from "ts-morph";
|
|
40195
|
-
function testName(call) {
|
|
40196
|
-
const [first] = call.getArguments();
|
|
40197
|
-
if (Node3.isStringLiteral(first) || Node3.isNoSubstitutionTemplateLiteral(first))
|
|
40198
|
-
return first.getLiteralValue();
|
|
40199
|
-
if (Node3.isTemplateExpression(first)) return first.getText().slice(1, -1);
|
|
40200
|
-
return first?.getText() ?? "";
|
|
40201
|
-
}
|
|
40202
|
-
|
|
40203
|
-
// src/commands/review/highLevel/dedentedSource.ts
|
|
40204
|
-
function dedentedSource(call) {
|
|
40205
|
-
const text20 = call.getSourceFile().getFullText();
|
|
40206
|
-
const lineStart = text20.lastIndexOf("\n", call.getStart()) + 1;
|
|
40207
|
-
const indent4 = /^\s*/.exec(text20.slice(lineStart, call.getStart()))?.[0] ?? "";
|
|
40208
|
-
return call.getText().split("\n").map((line) => line.startsWith(indent4) ? line.slice(indent4.length) : line).join("\n");
|
|
40209
|
-
}
|
|
40210
|
-
|
|
40211
|
-
// src/commands/review/highLevel/visitCase.ts
|
|
40212
|
-
function visitCase(call, context) {
|
|
40213
|
-
if (!context.changed) return [toCase(call, context)];
|
|
40214
|
-
const lines2 = changedLines(call, context.changed);
|
|
40215
|
-
if (lines2.length === 0) return [];
|
|
40216
|
-
const total3 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
|
|
40217
|
-
return [
|
|
40218
|
-
toCase(
|
|
40219
|
-
call,
|
|
40220
|
-
context,
|
|
40221
|
-
lines2.length === total3 ? { change: "added" } : { change: "modified", changedLines: lines2 }
|
|
40222
|
-
)
|
|
40223
|
-
];
|
|
40224
|
-
}
|
|
40225
|
-
function toCase(call, context, change = {}) {
|
|
40226
|
-
const line = call.getStartLineNumber();
|
|
40227
|
-
return {
|
|
40228
|
-
kind: "it",
|
|
40229
|
-
id: `${context.path}:${line}`,
|
|
40230
|
-
name: testName(call),
|
|
40231
|
-
line,
|
|
40232
|
-
...change,
|
|
40233
|
-
source: dedentedSource(call)
|
|
40234
|
-
};
|
|
40235
|
-
}
|
|
40236
|
-
function changedLines(call, changed) {
|
|
40237
|
-
const lines2 = [];
|
|
40238
|
-
for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
|
|
40239
|
-
if (changed.has(line)) lines2.push(line);
|
|
40240
|
-
return lines2;
|
|
40241
|
-
}
|
|
40242
|
-
|
|
40243
|
-
// src/commands/review/highLevel/extractTestHierarchy.ts
|
|
40244
|
-
function collect7(node, context) {
|
|
40245
|
-
const found = [];
|
|
40246
|
-
node.forEachChild((child) => {
|
|
40247
|
-
found.push(...visit(child, context));
|
|
40248
|
-
});
|
|
40249
|
-
return found;
|
|
40250
|
-
}
|
|
40251
|
-
function visit(node, context) {
|
|
40252
|
-
if (!Node4.isCallExpression(node)) return collect7(node, context);
|
|
40253
|
-
const kind = classifyTestCall(node);
|
|
40254
|
-
if (kind === "it") return visitCase(node, context);
|
|
40255
|
-
if (kind === void 0) return collect7(node, context);
|
|
40256
|
-
const children = node.getArguments().slice(1).flatMap((argument) => visit(argument, context));
|
|
40257
|
-
if (children.length === 0) return [];
|
|
40258
|
-
return [
|
|
40259
|
-
{
|
|
40260
|
-
kind: "describe",
|
|
40261
|
-
name: testName(node),
|
|
40262
|
-
line: node.getStartLineNumber(),
|
|
40263
|
-
children
|
|
40264
|
-
}
|
|
40265
|
-
];
|
|
40266
|
-
}
|
|
40267
|
-
function extractTestHierarchy(path109, text20, changed) {
|
|
40268
|
-
const project = new Project5({
|
|
40269
|
-
useInMemoryFileSystem: true,
|
|
40270
|
-
compilerOptions: { allowJs: true }
|
|
40271
|
-
});
|
|
40272
|
-
const source = project.createSourceFile(`/${path109}`, text20);
|
|
40273
|
-
return collect7(source, { path: path109, ...changed ? { changed } : {} });
|
|
40274
|
-
}
|
|
40275
|
-
|
|
40276
|
-
// src/commands/review/highLevel/patchAddedLines.ts
|
|
40277
|
-
var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)/;
|
|
40278
|
-
function patchAddedLines(patch2) {
|
|
40279
|
-
const added = /* @__PURE__ */ new Set();
|
|
40280
|
-
let next3 = 0;
|
|
40281
|
-
for (const line of patch2.split("\n")) {
|
|
40282
|
-
const header = HUNK_HEADER.exec(line);
|
|
40283
|
-
if (header) next3 = Number(header[1]);
|
|
40284
|
-
else if (line.startsWith("+")) added.add(next3++);
|
|
40285
|
-
else if (!line.startsWith("-") && !line.startsWith("\\")) next3++;
|
|
40286
|
-
}
|
|
40287
|
-
return added;
|
|
40288
|
-
}
|
|
40289
|
-
|
|
40290
|
-
// src/commands/review/highLevel/collectHighLevelTests.ts
|
|
40291
|
-
function testFile(file, readSource4) {
|
|
40292
|
-
const changed = file.patch === void 0 ? void 0 : patchAddedLines(file.patch);
|
|
40293
|
-
const tests = extractTestHierarchy(file.path, readSource4(file.path), changed);
|
|
40294
|
-
if (tests.length === 0) return [];
|
|
40295
|
-
const { path: path109, status: status2, additions, deletions, diffUrl: diffUrl2 } = file;
|
|
40296
|
-
return [{ path: path109, status: status2, additions, deletions, diffUrl: diffUrl2, tests }];
|
|
40297
|
-
}
|
|
40298
|
-
function collectHighLevelTests(files, testPaths, readSource4) {
|
|
40299
|
-
return files.filter(
|
|
40300
|
-
(file) => file.status !== "removed" && testPaths.some((glob) => minimatch6(file.path, glob))
|
|
40301
|
-
).flatMap((file) => testFile(file, readSource4));
|
|
40302
|
-
}
|
|
40303
|
-
|
|
40304
40100
|
// src/commands/review/highLevel/checkDescriptionLinksIssue.ts
|
|
40305
40101
|
var ISSUE_URL_PATTERN = /https?:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+/g;
|
|
40306
40102
|
var CROSS_REPO_PATTERN = /\b[\w.-]+\/[\w.-]+#\d+/g;
|
|
@@ -40378,7 +40174,7 @@ function checkNoMergeConflicts(mergeable, baseRef) {
|
|
|
40378
40174
|
}
|
|
40379
40175
|
|
|
40380
40176
|
// src/commands/review/highLevel/checkUiEvidence.ts
|
|
40381
|
-
import { minimatch as
|
|
40177
|
+
import { minimatch as minimatch6 } from "minimatch";
|
|
40382
40178
|
var EVIDENCE_PATTERNS = [
|
|
40383
40179
|
/!\[[^\]]*\]\([^)]+\)/g,
|
|
40384
40180
|
/<(?:img|video)\b[^>]*>/gi,
|
|
@@ -40401,7 +40197,7 @@ function checkUiEvidence(body, changedFiles2, uiPaths) {
|
|
|
40401
40197
|
reason: "review.highLevel.uiPaths is unset, so no UI evidence is required"
|
|
40402
40198
|
};
|
|
40403
40199
|
const touched = changedFiles2.filter(
|
|
40404
|
-
(file) => uiPaths.some((glob) =>
|
|
40200
|
+
(file) => uiPaths.some((glob) => minimatch6(file, glob))
|
|
40405
40201
|
);
|
|
40406
40202
|
if (touched.length === 0)
|
|
40407
40203
|
return {
|
|
@@ -40499,34 +40295,8 @@ function evaluateHighLevelChecks(subject) {
|
|
|
40499
40295
|
});
|
|
40500
40296
|
}
|
|
40501
40297
|
|
|
40502
|
-
// src/commands/review/highLevel/fetchFileAtSha.ts
|
|
40503
|
-
import { execFileSync as execFileSync27 } from "child_process";
|
|
40504
|
-
function fetchFileAtSha(repo, sha, path109) {
|
|
40505
|
-
const encodedPath = path109.split("/").map(encodeURIComponent).join("/");
|
|
40506
|
-
try {
|
|
40507
|
-
return execFileSync27(
|
|
40508
|
-
"gh",
|
|
40509
|
-
[
|
|
40510
|
-
"api",
|
|
40511
|
-
"-H",
|
|
40512
|
-
"Accept: application/vnd.github.raw",
|
|
40513
|
-
`repos/${repo}/contents/${encodedPath}?ref=${sha}`
|
|
40514
|
-
],
|
|
40515
|
-
{
|
|
40516
|
-
encoding: "utf8",
|
|
40517
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
40518
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
40519
|
-
}
|
|
40520
|
-
);
|
|
40521
|
-
} catch (error) {
|
|
40522
|
-
throw new Error(
|
|
40523
|
-
`Could not read ${path109} at PR head ${sha.slice(0, 7)}: ${ghFailure(error)}`
|
|
40524
|
-
);
|
|
40525
|
-
}
|
|
40526
|
-
}
|
|
40527
|
-
|
|
40528
40298
|
// src/commands/review/highLevel/fetchHighLevelFiles.ts
|
|
40529
|
-
import { execFileSync as
|
|
40299
|
+
import { execFileSync as execFileSync27 } from "child_process";
|
|
40530
40300
|
import { createHash as createHash4 } from "crypto";
|
|
40531
40301
|
var JQ = ".[] | {filename,status,additions,deletions,patch} | @json";
|
|
40532
40302
|
function toStatus(status2) {
|
|
@@ -40539,7 +40309,7 @@ function diffUrl(repo, prNumber, path109) {
|
|
|
40539
40309
|
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
40540
40310
|
}
|
|
40541
40311
|
function fetchHighLevelFiles(prNumber, repo) {
|
|
40542
|
-
const out =
|
|
40312
|
+
const out = execFileSync27(
|
|
40543
40313
|
"gh",
|
|
40544
40314
|
["api", `repos/${repo}/pulls/${prNumber}/files`, "--paginate", "--jq", JQ],
|
|
40545
40315
|
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
@@ -40605,6 +40375,35 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
40605
40375
|
};
|
|
40606
40376
|
}
|
|
40607
40377
|
|
|
40378
|
+
// src/commands/review/highLevel/gatherHighLevelSlices.ts
|
|
40379
|
+
import { readFileSync as readFileSync54 } from "fs";
|
|
40380
|
+
|
|
40381
|
+
// src/commands/review/highLevel/formatSlicingRequest.ts
|
|
40382
|
+
var RULES = [
|
|
40383
|
+
"Each slice is a single coherent change a reviewer can check in one sitting, smaller than a whole feature.",
|
|
40384
|
+
"A hunk may appear in more than one slice.",
|
|
40385
|
+
"Tests go in the same slice as the code they test, and get their own slice only when they stand alone.",
|
|
40386
|
+
"Generated files such as lockfiles get their own slice unless they belong with a specific change.",
|
|
40387
|
+
"List slices in reading order."
|
|
40388
|
+
];
|
|
40389
|
+
function formatSlicingRequest(hunks) {
|
|
40390
|
+
return [
|
|
40391
|
+
"Slicing required: review.highLevel.slices is on, so this PR must be split into slices before the review opens.",
|
|
40392
|
+
"",
|
|
40393
|
+
"Write a JSON array of slices to a scratch file, then re-run this command with the same arguments plus `--slices <file>`:",
|
|
40394
|
+
"",
|
|
40395
|
+
' [{"title": "Short imperative title", "summary": "One or two sentences on what the slice changes.", "hunks": ["path/to/file.ts#0"]}]',
|
|
40396
|
+
"",
|
|
40397
|
+
'Refer to hunks by the `path#index` labels below. Unknown refs are dropped, and every hunk no slice claims goes into an "Everything else" slice.',
|
|
40398
|
+
"",
|
|
40399
|
+
"Slicing rules:",
|
|
40400
|
+
...RULES.map((rule) => `- ${rule}`),
|
|
40401
|
+
"",
|
|
40402
|
+
`Hunks (${hunks.length}):`,
|
|
40403
|
+
...hunks.flatMap((hunk) => ["", `### ${hunk.ref}`, hunk.text])
|
|
40404
|
+
].join("\n");
|
|
40405
|
+
}
|
|
40406
|
+
|
|
40608
40407
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
40609
40408
|
import { join as join91 } from "path";
|
|
40610
40409
|
function slug(value) {
|
|
@@ -40619,14 +40418,44 @@ function highLevelReviewPath(repo, headRef, headSha) {
|
|
|
40619
40418
|
);
|
|
40620
40419
|
}
|
|
40621
40420
|
|
|
40622
|
-
// src/commands/review/highLevel/
|
|
40623
|
-
function
|
|
40421
|
+
// src/commands/review/highLevel/highLevelSlicesPath.ts
|
|
40422
|
+
function highLevelSlicesPath(repo, headRef, headSha) {
|
|
40624
40423
|
return highLevelReviewPath(repo, headRef, headSha).replace(
|
|
40625
40424
|
/\.json$/,
|
|
40626
|
-
".
|
|
40425
|
+
".slices.json"
|
|
40627
40426
|
);
|
|
40628
40427
|
}
|
|
40629
40428
|
|
|
40429
|
+
// src/commands/review/highLevel/listHighLevelHunks.ts
|
|
40430
|
+
function countLines2(text20, prefix2) {
|
|
40431
|
+
return text20.split("\n").filter((line) => line.startsWith(prefix2)).length;
|
|
40432
|
+
}
|
|
40433
|
+
function hunksOfFile(file) {
|
|
40434
|
+
const texts = hunksOf(file.patch ?? "").filter(
|
|
40435
|
+
(text20) => text20.startsWith("@@")
|
|
40436
|
+
);
|
|
40437
|
+
if (texts.length === 0)
|
|
40438
|
+
return [
|
|
40439
|
+
{
|
|
40440
|
+
ref: `${file.path}#0`,
|
|
40441
|
+
path: file.path,
|
|
40442
|
+
text: `(no patch shown: binary, too large or over the review budget; ${file.status}, +${file.additions} \u2212${file.deletions})`,
|
|
40443
|
+
additions: file.additions,
|
|
40444
|
+
deletions: file.deletions
|
|
40445
|
+
}
|
|
40446
|
+
];
|
|
40447
|
+
return texts.map((text20, index3) => ({
|
|
40448
|
+
ref: `${file.path}#${index3}`,
|
|
40449
|
+
path: file.path,
|
|
40450
|
+
text: text20,
|
|
40451
|
+
additions: countLines2(text20, "+"),
|
|
40452
|
+
deletions: countLines2(text20, "-")
|
|
40453
|
+
}));
|
|
40454
|
+
}
|
|
40455
|
+
function listHighLevelHunks(files) {
|
|
40456
|
+
return files.flatMap(hunksOfFile);
|
|
40457
|
+
}
|
|
40458
|
+
|
|
40630
40459
|
// src/commands/review/highLevel/readJsonFile.ts
|
|
40631
40460
|
import { existsSync as existsSync68, readFileSync as readFileSync53 } from "fs";
|
|
40632
40461
|
function readJsonFile(path109) {
|
|
@@ -40638,6 +40467,358 @@ function readJsonFile(path109) {
|
|
|
40638
40467
|
}
|
|
40639
40468
|
}
|
|
40640
40469
|
|
|
40470
|
+
// src/commands/review/highLevel/parseHighLevelSlicesInput.ts
|
|
40471
|
+
import { z as z20 } from "zod";
|
|
40472
|
+
var slicesInputSchema = z20.array(
|
|
40473
|
+
z20.object({
|
|
40474
|
+
title: z20.string().min(1),
|
|
40475
|
+
summary: z20.string(),
|
|
40476
|
+
hunks: z20.array(z20.string())
|
|
40477
|
+
})
|
|
40478
|
+
);
|
|
40479
|
+
function parseHighLevelSlicesInput(raw) {
|
|
40480
|
+
const parsed = slicesInputSchema.safeParse(raw);
|
|
40481
|
+
if (!parsed.success)
|
|
40482
|
+
throw new Error(
|
|
40483
|
+
`slices must be a JSON array of {title, summary, hunks[]}: ${parsed.error.message}`
|
|
40484
|
+
);
|
|
40485
|
+
return parsed.data;
|
|
40486
|
+
}
|
|
40487
|
+
|
|
40488
|
+
// src/commands/review/highLevel/sliceTotals.ts
|
|
40489
|
+
function sliceTotals(refs, byRef) {
|
|
40490
|
+
let additions = 0;
|
|
40491
|
+
let deletions = 0;
|
|
40492
|
+
for (const ref of refs) {
|
|
40493
|
+
const hunk = byRef.get(ref);
|
|
40494
|
+
additions += hunk?.additions ?? 0;
|
|
40495
|
+
deletions += hunk?.deletions ?? 0;
|
|
40496
|
+
}
|
|
40497
|
+
return { additions, deletions };
|
|
40498
|
+
}
|
|
40499
|
+
|
|
40500
|
+
// src/commands/review/highLevel/resolveHighLevelSlices.ts
|
|
40501
|
+
function knownRefs(input, byRef, warnings) {
|
|
40502
|
+
return [...new Set(input.hunks)].filter((ref) => {
|
|
40503
|
+
if (byRef.has(ref)) return true;
|
|
40504
|
+
warnings.push(`Dropped unknown hunk ${ref} from "${input.title}".`);
|
|
40505
|
+
return false;
|
|
40506
|
+
});
|
|
40507
|
+
}
|
|
40508
|
+
function resolveHighLevelSlices(raw, hunks) {
|
|
40509
|
+
const byRef = new Map(hunks.map((hunk) => [hunk.ref, hunk]));
|
|
40510
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
40511
|
+
const warnings = [];
|
|
40512
|
+
const slices = [];
|
|
40513
|
+
const add5 = (title, summary, refs) => slices.push({ title, summary, hunks: refs, ...sliceTotals(refs, byRef) });
|
|
40514
|
+
for (const input of parseHighLevelSlicesInput(raw)) {
|
|
40515
|
+
const known = knownRefs(input, byRef, warnings);
|
|
40516
|
+
if (known.length === 0)
|
|
40517
|
+
warnings.push(`Dropped slice "${input.title}": it has no known hunks.`);
|
|
40518
|
+
else add5(input.title, input.summary, known);
|
|
40519
|
+
for (const ref of known) claimed.add(ref);
|
|
40520
|
+
}
|
|
40521
|
+
const rest = [...byRef.keys()].filter((ref) => !claimed.has(ref));
|
|
40522
|
+
if (rest.length > 0) add5("Everything else", "Hunks no slice claimed.", rest);
|
|
40523
|
+
return { slices, warnings };
|
|
40524
|
+
}
|
|
40525
|
+
|
|
40526
|
+
// src/commands/review/highLevel/writeJsonFile.ts
|
|
40527
|
+
import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync42 } from "fs";
|
|
40528
|
+
import { dirname as dirname42 } from "path";
|
|
40529
|
+
function writeJsonFile(path109, data) {
|
|
40530
|
+
mkdirSync28(dirname42(path109), { recursive: true });
|
|
40531
|
+
writeFileSync42(path109, `${JSON.stringify(data, null, 2)}
|
|
40532
|
+
`);
|
|
40533
|
+
return path109;
|
|
40534
|
+
}
|
|
40535
|
+
|
|
40536
|
+
// src/commands/review/highLevel/gatherHighLevelSlices.ts
|
|
40537
|
+
function readSlicesFile(file) {
|
|
40538
|
+
try {
|
|
40539
|
+
return JSON.parse(readFileSync54(file, "utf8"));
|
|
40540
|
+
} catch (error) {
|
|
40541
|
+
throw new Error(
|
|
40542
|
+
`could not read slices from ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
40543
|
+
);
|
|
40544
|
+
}
|
|
40545
|
+
}
|
|
40546
|
+
function sliceFromFile(file, files, path109) {
|
|
40547
|
+
const { slices, warnings } = resolveHighLevelSlices(
|
|
40548
|
+
readSlicesFile(file),
|
|
40549
|
+
listHighLevelHunks(files)
|
|
40550
|
+
);
|
|
40551
|
+
for (const warning of warnings) console.warn(`Warning: ${warning}`);
|
|
40552
|
+
writeJsonFile(path109, slices);
|
|
40553
|
+
return slices;
|
|
40554
|
+
}
|
|
40555
|
+
function gatherHighLevelSlices(head, files, slicing) {
|
|
40556
|
+
const path109 = highLevelSlicesPath(head.repo, head.headRef, head.headSha);
|
|
40557
|
+
if (slicing.slicesFile) return sliceFromFile(slicing.slicesFile, files, path109);
|
|
40558
|
+
const saved = slicing.force ? void 0 : readJsonFile(path109);
|
|
40559
|
+
if (saved) return saved;
|
|
40560
|
+
console.log(formatSlicingRequest(listHighLevelHunks(files)));
|
|
40561
|
+
process.exit(2);
|
|
40562
|
+
}
|
|
40563
|
+
|
|
40564
|
+
// src/commands/review/highLevel/testChangeExcerpts.ts
|
|
40565
|
+
var CONTEXT_LINES = 3;
|
|
40566
|
+
function testChangeExcerpts(source, line, changedLines2) {
|
|
40567
|
+
const lines2 = source.split("\n");
|
|
40568
|
+
const windows = [];
|
|
40569
|
+
for (const changed of [...changedLines2].sort((a, b) => a - b)) {
|
|
40570
|
+
const start2 = Math.max(0, changed - line - CONTEXT_LINES);
|
|
40571
|
+
const end = Math.min(lines2.length - 1, changed - line + CONTEXT_LINES);
|
|
40572
|
+
const last = windows.at(-1);
|
|
40573
|
+
if (last && start2 <= last.end + 1) last.end = Math.max(last.end, end);
|
|
40574
|
+
else windows.push({ start: start2, end });
|
|
40575
|
+
}
|
|
40576
|
+
return windows.map(({ start: start2, end }) => ({
|
|
40577
|
+
line: line + start2,
|
|
40578
|
+
source: lines2.slice(start2, end + 1).join("\n")
|
|
40579
|
+
}));
|
|
40580
|
+
}
|
|
40581
|
+
|
|
40582
|
+
// src/commands/review/highLevel/shownForm.ts
|
|
40583
|
+
var MAX_TEST_SOURCE_LINES = 200;
|
|
40584
|
+
function shownForm(test) {
|
|
40585
|
+
const { source, changedLines: changedLines2, ...rest } = test;
|
|
40586
|
+
if (source === void 0) return void 0;
|
|
40587
|
+
const lines2 = lineCount(source);
|
|
40588
|
+
if (lines2 <= MAX_TEST_SOURCE_LINES)
|
|
40589
|
+
return { lines: lines2, shown: { ...rest, source } };
|
|
40590
|
+
if (!changedLines2) return void 0;
|
|
40591
|
+
const excerpts = testChangeExcerpts(source, test.line, changedLines2);
|
|
40592
|
+
const excerptLines = excerpts.reduce(
|
|
40593
|
+
(sum3, excerpt2) => sum3 + lineCount(excerpt2.source),
|
|
40594
|
+
0
|
|
40595
|
+
);
|
|
40596
|
+
return excerptLines <= MAX_TEST_SOURCE_LINES ? { lines: excerptLines, shown: { ...rest, excerpts } } : void 0;
|
|
40597
|
+
}
|
|
40598
|
+
function lineCount(text20) {
|
|
40599
|
+
return text20.split("\n").length;
|
|
40600
|
+
}
|
|
40601
|
+
|
|
40602
|
+
// src/commands/review/highLevel/capHighLevelTestSources.ts
|
|
40603
|
+
var MAX_TOTAL_SOURCE_LINES = 5e3;
|
|
40604
|
+
function collectCases(nodes) {
|
|
40605
|
+
return nodes.flatMap(
|
|
40606
|
+
(node) => node.kind === "it" ? [node] : collectCases(node.children)
|
|
40607
|
+
);
|
|
40608
|
+
}
|
|
40609
|
+
function shippedForms(files) {
|
|
40610
|
+
const sized = files.flatMap((file) => collectCases(file.tests)).flatMap((test) => {
|
|
40611
|
+
const form = shownForm(test);
|
|
40612
|
+
return form ? [{ test, form }] : [];
|
|
40613
|
+
}).sort((a, b) => a.form.lines - b.form.lines);
|
|
40614
|
+
const shipped = /* @__PURE__ */ new Map();
|
|
40615
|
+
let remaining = MAX_TOTAL_SOURCE_LINES;
|
|
40616
|
+
for (const { test, form } of sized) {
|
|
40617
|
+
if (form.lines > remaining) break;
|
|
40618
|
+
remaining -= form.lines;
|
|
40619
|
+
shipped.set(test, form);
|
|
40620
|
+
}
|
|
40621
|
+
return shipped;
|
|
40622
|
+
}
|
|
40623
|
+
function capHighLevelTestSources(files) {
|
|
40624
|
+
const shipped = shippedForms(files);
|
|
40625
|
+
const capCase = (test) => {
|
|
40626
|
+
const form = shipped.get(test);
|
|
40627
|
+
if (form) return form.shown;
|
|
40628
|
+
const { source, changedLines: _changedLines, ...rest } = test;
|
|
40629
|
+
if (source === void 0) return rest;
|
|
40630
|
+
return shownForm(test) ? { ...rest, overBudget: true } : { ...rest, truncated: true };
|
|
40631
|
+
};
|
|
40632
|
+
const capNode = (node) => node.kind === "it" ? capCase(node) : { ...node, children: node.children.map(capNode) };
|
|
40633
|
+
return files.map((file) => ({ ...file, tests: file.tests.map(capNode) }));
|
|
40634
|
+
}
|
|
40635
|
+
|
|
40636
|
+
// src/commands/review/highLevel/collectHighLevelTests.ts
|
|
40637
|
+
import { minimatch as minimatch7 } from "minimatch";
|
|
40638
|
+
|
|
40639
|
+
// src/commands/review/highLevel/extractTestHierarchy.ts
|
|
40640
|
+
import { Node as Node4, Project as Project5 } from "ts-morph";
|
|
40641
|
+
|
|
40642
|
+
// src/commands/review/highLevel/classifyTestCall.ts
|
|
40643
|
+
import { Node as Node2 } from "ts-morph";
|
|
40644
|
+
var SUITE_ROOTS = /* @__PURE__ */ new Set(["describe", "context", "suite"]);
|
|
40645
|
+
var CASE_ROOTS = /* @__PURE__ */ new Set(["it", "test", "specify"]);
|
|
40646
|
+
function calleeChain(expression) {
|
|
40647
|
+
if (Node2.isIdentifier(expression)) return [expression.getText()];
|
|
40648
|
+
if (Node2.isPropertyAccessExpression(expression))
|
|
40649
|
+
return [...calleeChain(expression.getExpression()), expression.getName()];
|
|
40650
|
+
if (Node2.isCallExpression(expression))
|
|
40651
|
+
return calleeChain(expression.getExpression());
|
|
40652
|
+
return [];
|
|
40653
|
+
}
|
|
40654
|
+
function hasName(call) {
|
|
40655
|
+
const [first] = call.getArguments();
|
|
40656
|
+
return first !== void 0 && !Node2.isFunctionLikeDeclaration(first) && !Node2.isObjectLiteralExpression(first);
|
|
40657
|
+
}
|
|
40658
|
+
function classifyTestCall(call) {
|
|
40659
|
+
const [root2, ...rest] = calleeChain(call.getExpression());
|
|
40660
|
+
if (root2 === void 0 || !hasName(call)) return void 0;
|
|
40661
|
+
if (SUITE_ROOTS.has(root2) || rest.includes("describe")) return "describe";
|
|
40662
|
+
if (CASE_ROOTS.has(root2)) return "it";
|
|
40663
|
+
return void 0;
|
|
40664
|
+
}
|
|
40665
|
+
|
|
40666
|
+
// src/commands/review/highLevel/testName.ts
|
|
40667
|
+
import { Node as Node3 } from "ts-morph";
|
|
40668
|
+
function testName(call) {
|
|
40669
|
+
const [first] = call.getArguments();
|
|
40670
|
+
if (Node3.isStringLiteral(first) || Node3.isNoSubstitutionTemplateLiteral(first))
|
|
40671
|
+
return first.getLiteralValue();
|
|
40672
|
+
if (Node3.isTemplateExpression(first)) return first.getText().slice(1, -1);
|
|
40673
|
+
return first?.getText() ?? "";
|
|
40674
|
+
}
|
|
40675
|
+
|
|
40676
|
+
// src/commands/review/highLevel/dedentedSource.ts
|
|
40677
|
+
function dedentedSource(call) {
|
|
40678
|
+
const text20 = call.getSourceFile().getFullText();
|
|
40679
|
+
const lineStart = text20.lastIndexOf("\n", call.getStart()) + 1;
|
|
40680
|
+
const indent4 = /^\s*/.exec(text20.slice(lineStart, call.getStart()))?.[0] ?? "";
|
|
40681
|
+
return call.getText().split("\n").map((line) => line.startsWith(indent4) ? line.slice(indent4.length) : line).join("\n");
|
|
40682
|
+
}
|
|
40683
|
+
|
|
40684
|
+
// src/commands/review/highLevel/visitCase.ts
|
|
40685
|
+
function visitCase(call, context) {
|
|
40686
|
+
if (!context.changed) return [toCase(call, context)];
|
|
40687
|
+
const lines2 = changedLines(call, context.changed);
|
|
40688
|
+
if (lines2.length === 0) return [];
|
|
40689
|
+
const total3 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
|
|
40690
|
+
return [
|
|
40691
|
+
toCase(
|
|
40692
|
+
call,
|
|
40693
|
+
context,
|
|
40694
|
+
lines2.length === total3 ? { change: "added" } : { change: "modified", changedLines: lines2 }
|
|
40695
|
+
)
|
|
40696
|
+
];
|
|
40697
|
+
}
|
|
40698
|
+
function toCase(call, context, change = {}) {
|
|
40699
|
+
const line = call.getStartLineNumber();
|
|
40700
|
+
return {
|
|
40701
|
+
kind: "it",
|
|
40702
|
+
id: `${context.path}:${line}`,
|
|
40703
|
+
name: testName(call),
|
|
40704
|
+
line,
|
|
40705
|
+
...change,
|
|
40706
|
+
source: dedentedSource(call)
|
|
40707
|
+
};
|
|
40708
|
+
}
|
|
40709
|
+
function changedLines(call, changed) {
|
|
40710
|
+
const lines2 = [];
|
|
40711
|
+
for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
|
|
40712
|
+
if (changed.has(line)) lines2.push(line);
|
|
40713
|
+
return lines2;
|
|
40714
|
+
}
|
|
40715
|
+
|
|
40716
|
+
// src/commands/review/highLevel/extractTestHierarchy.ts
|
|
40717
|
+
function collect7(node, context) {
|
|
40718
|
+
const found = [];
|
|
40719
|
+
node.forEachChild((child) => {
|
|
40720
|
+
found.push(...visit(child, context));
|
|
40721
|
+
});
|
|
40722
|
+
return found;
|
|
40723
|
+
}
|
|
40724
|
+
function visit(node, context) {
|
|
40725
|
+
if (!Node4.isCallExpression(node)) return collect7(node, context);
|
|
40726
|
+
const kind = classifyTestCall(node);
|
|
40727
|
+
if (kind === "it") return visitCase(node, context);
|
|
40728
|
+
if (kind === void 0) return collect7(node, context);
|
|
40729
|
+
const children = node.getArguments().slice(1).flatMap((argument) => visit(argument, context));
|
|
40730
|
+
if (children.length === 0) return [];
|
|
40731
|
+
return [
|
|
40732
|
+
{
|
|
40733
|
+
kind: "describe",
|
|
40734
|
+
name: testName(node),
|
|
40735
|
+
line: node.getStartLineNumber(),
|
|
40736
|
+
children
|
|
40737
|
+
}
|
|
40738
|
+
];
|
|
40739
|
+
}
|
|
40740
|
+
function extractTestHierarchy(path109, text20, changed) {
|
|
40741
|
+
const project = new Project5({
|
|
40742
|
+
useInMemoryFileSystem: true,
|
|
40743
|
+
compilerOptions: { allowJs: true }
|
|
40744
|
+
});
|
|
40745
|
+
const source = project.createSourceFile(`/${path109}`, text20);
|
|
40746
|
+
return collect7(source, { path: path109, ...changed ? { changed } : {} });
|
|
40747
|
+
}
|
|
40748
|
+
|
|
40749
|
+
// src/commands/review/highLevel/patchAddedLines.ts
|
|
40750
|
+
var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)/;
|
|
40751
|
+
function patchAddedLines(patch2) {
|
|
40752
|
+
const added = /* @__PURE__ */ new Set();
|
|
40753
|
+
let next3 = 0;
|
|
40754
|
+
for (const line of patch2.split("\n")) {
|
|
40755
|
+
const header = HUNK_HEADER.exec(line);
|
|
40756
|
+
if (header) next3 = Number(header[1]);
|
|
40757
|
+
else if (line.startsWith("+")) added.add(next3++);
|
|
40758
|
+
else if (!line.startsWith("-") && !line.startsWith("\\")) next3++;
|
|
40759
|
+
}
|
|
40760
|
+
return added;
|
|
40761
|
+
}
|
|
40762
|
+
|
|
40763
|
+
// src/commands/review/highLevel/collectHighLevelTests.ts
|
|
40764
|
+
function testFile(file, readSource4) {
|
|
40765
|
+
const changed = file.patch === void 0 ? void 0 : patchAddedLines(file.patch);
|
|
40766
|
+
const tests = extractTestHierarchy(file.path, readSource4(file.path), changed);
|
|
40767
|
+
if (tests.length === 0) return [];
|
|
40768
|
+
const { path: path109, status: status2, additions, deletions, diffUrl: diffUrl2 } = file;
|
|
40769
|
+
return [{ path: path109, status: status2, additions, deletions, diffUrl: diffUrl2, tests }];
|
|
40770
|
+
}
|
|
40771
|
+
function collectHighLevelTests(files, testPaths, readSource4) {
|
|
40772
|
+
return files.filter(
|
|
40773
|
+
(file) => file.status !== "removed" && testPaths.some((glob) => minimatch7(file.path, glob))
|
|
40774
|
+
).flatMap((file) => testFile(file, readSource4));
|
|
40775
|
+
}
|
|
40776
|
+
|
|
40777
|
+
// src/commands/review/highLevel/fetchFileAtSha.ts
|
|
40778
|
+
import { execFileSync as execFileSync28 } from "child_process";
|
|
40779
|
+
function fetchFileAtSha(repo, sha, path109) {
|
|
40780
|
+
const encodedPath = path109.split("/").map(encodeURIComponent).join("/");
|
|
40781
|
+
try {
|
|
40782
|
+
return execFileSync28(
|
|
40783
|
+
"gh",
|
|
40784
|
+
[
|
|
40785
|
+
"api",
|
|
40786
|
+
"-H",
|
|
40787
|
+
"Accept: application/vnd.github.raw",
|
|
40788
|
+
`repos/${repo}/contents/${encodedPath}?ref=${sha}`
|
|
40789
|
+
],
|
|
40790
|
+
{
|
|
40791
|
+
encoding: "utf8",
|
|
40792
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
40793
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
40794
|
+
}
|
|
40795
|
+
);
|
|
40796
|
+
} catch (error) {
|
|
40797
|
+
throw new Error(
|
|
40798
|
+
`Could not read ${path109} at PR head ${sha.slice(0, 7)}: ${ghFailure(error)}`
|
|
40799
|
+
);
|
|
40800
|
+
}
|
|
40801
|
+
}
|
|
40802
|
+
|
|
40803
|
+
// src/commands/review/highLevel/gatherHighLevelTests.ts
|
|
40804
|
+
function gatherHighLevelTests(files, testPaths, repo, headSha) {
|
|
40805
|
+
return capHighLevelTestSources(
|
|
40806
|
+
collectHighLevelTests(
|
|
40807
|
+
files,
|
|
40808
|
+
testPaths,
|
|
40809
|
+
(path109) => fetchFileAtSha(repo, headSha, path109)
|
|
40810
|
+
)
|
|
40811
|
+
);
|
|
40812
|
+
}
|
|
40813
|
+
|
|
40814
|
+
// src/commands/review/highLevel/highLevelDraftPath.ts
|
|
40815
|
+
function highLevelDraftPath(repo, headRef, headSha) {
|
|
40816
|
+
return highLevelReviewPath(repo, headRef, headSha).replace(
|
|
40817
|
+
/\.json$/,
|
|
40818
|
+
".draft.json"
|
|
40819
|
+
);
|
|
40820
|
+
}
|
|
40821
|
+
|
|
40641
40822
|
// src/commands/review/highLevel/loadHighLevelDraft.ts
|
|
40642
40823
|
function loadHighLevelDraft(repo, headRef, headSha) {
|
|
40643
40824
|
return readJsonFile(highLevelDraftPath(repo, headRef, headSha));
|
|
@@ -40676,39 +40857,31 @@ function selectCriticalDiffs(files, criticalPaths) {
|
|
|
40676
40857
|
}
|
|
40677
40858
|
|
|
40678
40859
|
// src/commands/review/highLevel/gatherHighLevelSubject.ts
|
|
40679
|
-
function gatherHighLevelSubject(prNumber, force) {
|
|
40860
|
+
function gatherHighLevelSubject(prNumber, force, slicing) {
|
|
40680
40861
|
const { org, repo } = getRepoInfo();
|
|
40681
40862
|
const slug2 = `${org}/${repo}`;
|
|
40682
40863
|
const pr = fetchHighLevelPr(prNumber, { org, repo });
|
|
40683
40864
|
const config = resolveHighLevelConfig(loadConfig());
|
|
40684
40865
|
const fetched = fetchHighLevelFiles(prNumber, slug2);
|
|
40685
40866
|
const files = capHighLevelPatches(fetched, config.criticalPaths);
|
|
40867
|
+
const head = { repo: slug2, headRef: pr.headRef, headSha: pr.headSha };
|
|
40868
|
+
const slices = slicing && config.slices ? gatherHighLevelSlices(head, files, slicing) : void 0;
|
|
40686
40869
|
return {
|
|
40687
|
-
|
|
40870
|
+
...head,
|
|
40688
40871
|
prNumber,
|
|
40689
40872
|
title: pr.title,
|
|
40690
|
-
headRef: pr.headRef,
|
|
40691
|
-
headSha: pr.headSha,
|
|
40692
40873
|
checks: evaluateHighLevelChecks({
|
|
40693
|
-
|
|
40694
|
-
linkedIssues: pr.linkedIssues,
|
|
40695
|
-
mergeable: pr.mergeable,
|
|
40696
|
-
baseRef: pr.baseRef,
|
|
40874
|
+
...pr,
|
|
40697
40875
|
changedFiles: files.map((file) => file.path),
|
|
40698
40876
|
config
|
|
40699
40877
|
}),
|
|
40700
40878
|
structure: buildHighLevelStructure(files),
|
|
40701
40879
|
criticalDiffs: selectCriticalDiffs(files, config.criticalPaths),
|
|
40702
40880
|
criticalPaths: config.criticalPaths,
|
|
40703
|
-
tests:
|
|
40704
|
-
collectHighLevelTests(
|
|
40705
|
-
fetched,
|
|
40706
|
-
config.testPaths,
|
|
40707
|
-
(path109) => fetchFileAtSha(slug2, pr.headSha, path109)
|
|
40708
|
-
)
|
|
40709
|
-
),
|
|
40881
|
+
tests: gatherHighLevelTests(fetched, config.testPaths, slug2, pr.headSha),
|
|
40710
40882
|
testPaths: config.testPaths,
|
|
40711
40883
|
collapsedPaths: config.collapsedPaths,
|
|
40884
|
+
...slices ? { slices } : {},
|
|
40712
40885
|
...force ? {} : loadReopenedReview(slug2, pr.headRef, pr.headSha)
|
|
40713
40886
|
};
|
|
40714
40887
|
}
|
|
@@ -40782,16 +40955,6 @@ function clearHighLevelDraft(repo, headRef, headSha) {
|
|
|
40782
40955
|
rmSync7(highLevelDraftPath(repo, headRef, headSha), { force: true });
|
|
40783
40956
|
}
|
|
40784
40957
|
|
|
40785
|
-
// src/commands/review/highLevel/writeJsonFile.ts
|
|
40786
|
-
import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync42 } from "fs";
|
|
40787
|
-
import { dirname as dirname42 } from "path";
|
|
40788
|
-
function writeJsonFile(path109, data) {
|
|
40789
|
-
mkdirSync28(dirname42(path109), { recursive: true });
|
|
40790
|
-
writeFileSync42(path109, `${JSON.stringify(data, null, 2)}
|
|
40791
|
-
`);
|
|
40792
|
-
return path109;
|
|
40793
|
-
}
|
|
40794
|
-
|
|
40795
40958
|
// src/commands/review/highLevel/saveHighLevelDraft.ts
|
|
40796
40959
|
function saveHighLevelDraft(draft) {
|
|
40797
40960
|
return writeJsonFile(
|
|
@@ -40826,6 +40989,7 @@ function highLevelPreviewPayload(subject) {
|
|
|
40826
40989
|
tests,
|
|
40827
40990
|
testPaths,
|
|
40828
40991
|
collapsedPaths,
|
|
40992
|
+
slices,
|
|
40829
40993
|
saved,
|
|
40830
40994
|
draft
|
|
40831
40995
|
} = subject;
|
|
@@ -40840,6 +41004,7 @@ function highLevelPreviewPayload(subject) {
|
|
|
40840
41004
|
tests,
|
|
40841
41005
|
testPaths,
|
|
40842
41006
|
collapsedPaths,
|
|
41007
|
+
...slices ? { slices } : {},
|
|
40843
41008
|
...saved ? { saved } : {},
|
|
40844
41009
|
...draft ? { draft } : {}
|
|
40845
41010
|
};
|
|
@@ -41009,11 +41174,11 @@ function submitHighLevelReview(record) {
|
|
|
41009
41174
|
}
|
|
41010
41175
|
|
|
41011
41176
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
41012
|
-
async function openHighLevelOverlay(
|
|
41177
|
+
async function openHighLevelOverlay(sessionId2, subject) {
|
|
41013
41178
|
const decision = await awaitPreviewApproval(
|
|
41014
41179
|
"High-level review",
|
|
41015
41180
|
{
|
|
41016
|
-
sessionId,
|
|
41181
|
+
sessionId: sessionId2,
|
|
41017
41182
|
requestId: randomUUID24(),
|
|
41018
41183
|
title: `${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`,
|
|
41019
41184
|
body: JSON.stringify(highLevelPreviewPayload(subject)),
|
|
@@ -41217,9 +41382,9 @@ function resolvePrNumber2(number) {
|
|
|
41217
41382
|
}
|
|
41218
41383
|
return parsed;
|
|
41219
41384
|
}
|
|
41220
|
-
function gatherSubject(prNumber, force) {
|
|
41385
|
+
function gatherSubject(prNumber, force, slicing) {
|
|
41221
41386
|
try {
|
|
41222
|
-
return gatherHighLevelSubject(prNumber, force);
|
|
41387
|
+
return gatherHighLevelSubject(prNumber, force, slicing);
|
|
41223
41388
|
} catch (error) {
|
|
41224
41389
|
console.error(
|
|
41225
41390
|
`Error: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -41227,21 +41392,25 @@ function gatherSubject(prNumber, force) {
|
|
|
41227
41392
|
process.exit(1);
|
|
41228
41393
|
}
|
|
41229
41394
|
}
|
|
41395
|
+
function sessionId() {
|
|
41396
|
+
const id = process.env.ASSIST_SESSION_ID;
|
|
41397
|
+
return process.env.ASSIST_SESSION === "1" && id ? id : void 0;
|
|
41398
|
+
}
|
|
41230
41399
|
async function runHighLevelReview(number, options2 = {}) {
|
|
41231
41400
|
const force = options2.force === true;
|
|
41232
|
-
const
|
|
41401
|
+
const session = sessionId();
|
|
41402
|
+
const slicing = session ? { force, ...options2.slices ? { slicesFile: options2.slices } : {} } : void 0;
|
|
41403
|
+
const subject = gatherSubject(resolvePrNumber2(number), force, slicing);
|
|
41233
41404
|
announceSavedReview(subject, force);
|
|
41234
|
-
|
|
41235
|
-
|
|
41236
|
-
return printHighLevelChecklist(subject);
|
|
41237
|
-
await openHighLevelOverlay(sessionId, subject);
|
|
41405
|
+
if (!session) return printHighLevelChecklist(subject);
|
|
41406
|
+
await openHighLevelOverlay(session, subject);
|
|
41238
41407
|
}
|
|
41239
41408
|
|
|
41240
41409
|
// src/commands/review/reviewPr.ts
|
|
41241
41410
|
import { basename as basename26 } from "path";
|
|
41242
41411
|
|
|
41243
41412
|
// src/commands/review/ci/writeJobSummary.ts
|
|
41244
|
-
import { appendFileSync as appendFileSync3, readFileSync as
|
|
41413
|
+
import { appendFileSync as appendFileSync3, readFileSync as readFileSync55 } from "fs";
|
|
41245
41414
|
|
|
41246
41415
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
41247
41416
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -41623,7 +41792,7 @@ function buildTokenUsageTable(usages) {
|
|
|
41623
41792
|
// src/commands/review/ci/writeJobSummary.ts
|
|
41624
41793
|
function writeJobSummary(synthesisPath, prInfo, summaryPath, slots) {
|
|
41625
41794
|
if (!summaryPath) return;
|
|
41626
|
-
const markdown =
|
|
41795
|
+
const markdown = readFileSync55(synthesisPath, "utf8");
|
|
41627
41796
|
const { unanchored } = selectPostableFindings(markdown, prInfo);
|
|
41628
41797
|
const usageTable = buildTokenUsageTable(slots.map((slot) => slot.usage));
|
|
41629
41798
|
appendFileSync3(
|
|
@@ -42630,7 +42799,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
42630
42799
|
import { existsSync as existsSync70, unlinkSync as unlinkSync18 } from "fs";
|
|
42631
42800
|
|
|
42632
42801
|
// src/commands/review/synthesise.ts
|
|
42633
|
-
import { readFileSync as
|
|
42802
|
+
import { readFileSync as readFileSync56 } from "fs";
|
|
42634
42803
|
|
|
42635
42804
|
// src/commands/review/buildSynthesisStdin.ts
|
|
42636
42805
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -42699,7 +42868,7 @@ Files:
|
|
|
42699
42868
|
|
|
42700
42869
|
// src/commands/review/synthesise.ts
|
|
42701
42870
|
function printSummary2(synthesisPath) {
|
|
42702
|
-
const markdown =
|
|
42871
|
+
const markdown = readFileSync56(synthesisPath, "utf8");
|
|
42703
42872
|
console.log("");
|
|
42704
42873
|
console.log(buildReviewSummary(markdown));
|
|
42705
42874
|
console.log("");
|
|
@@ -43144,7 +43313,7 @@ function gatherChangedContext() {
|
|
|
43144
43313
|
}
|
|
43145
43314
|
|
|
43146
43315
|
// src/commands/review/postReviewToPr.ts
|
|
43147
|
-
import { readFileSync as
|
|
43316
|
+
import { readFileSync as readFileSync57 } from "fs";
|
|
43148
43317
|
|
|
43149
43318
|
// src/commands/review/chainAddressComments.ts
|
|
43150
43319
|
function chainAddressComments(prNumber, announce) {
|
|
@@ -43326,7 +43495,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
43326
43495
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
43327
43496
|
}
|
|
43328
43497
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
43329
|
-
const markdown =
|
|
43498
|
+
const markdown = readFileSync57(synthesisPath, "utf8");
|
|
43330
43499
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
43331
43500
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
43332
43501
|
if (inDiff.length === 0 && carried.length === 0)
|
|
@@ -43556,6 +43725,12 @@ function validateCheckoutOnly(options2) {
|
|
|
43556
43725
|
}
|
|
43557
43726
|
}
|
|
43558
43727
|
function validateHighLevel(options2) {
|
|
43728
|
+
if (options2.slices && (!options2.highLevel || options2.configure)) {
|
|
43729
|
+
console.error(
|
|
43730
|
+
"Error: --slices requires --high-level and cannot be combined with --configure."
|
|
43731
|
+
);
|
|
43732
|
+
process.exit(1);
|
|
43733
|
+
}
|
|
43559
43734
|
if (!options2.highLevel) return;
|
|
43560
43735
|
if (options2.refine || options2.apply || options2.backlog || options2.submit || options2.checkoutOnly) {
|
|
43561
43736
|
console.error(
|
|
@@ -43589,11 +43764,12 @@ async function review(options2 = {}) {
|
|
|
43589
43764
|
`/review-high-level ${options2.number}${options2.force ? " --force" : ""}`
|
|
43590
43765
|
);
|
|
43591
43766
|
emitActivity({ kind: "command", name: "review" });
|
|
43767
|
+
const highLevelOptions = { force: options2.force, slices: options2.slices };
|
|
43592
43768
|
if (!options2.number)
|
|
43593
|
-
return options2.highLevel ? runHighLevelReview(void 0,
|
|
43769
|
+
return options2.highLevel ? runHighLevelReview(void 0, highLevelOptions) : reviewPr(invokedIn, options2);
|
|
43594
43770
|
await checkoutPr(options2.number);
|
|
43595
43771
|
if (options2.highLevel)
|
|
43596
|
-
return runHighLevelReview(options2.number,
|
|
43772
|
+
return runHighLevelReview(options2.number, highLevelOptions);
|
|
43597
43773
|
return reviewPr(resolveRepoRoot(), options2);
|
|
43598
43774
|
}
|
|
43599
43775
|
|
|
@@ -43605,6 +43781,9 @@ function addReviewModeOptions(command) {
|
|
|
43605
43781
|
).option(
|
|
43606
43782
|
"--high-level",
|
|
43607
43783
|
"Check the PR out and open the high-level review checklist in the web UI preview pane, then post it to the PR as an Approve, Comment or Request changes review. Outside a Claude session it starts one running /review-high-level <number>. A review saved for the same head SHA is reopened unless --force is passed. Cannot be combined with --refine, --apply, --backlog, --submit or --checkout-only"
|
|
43784
|
+
).option(
|
|
43785
|
+
"--slices <file>",
|
|
43786
|
+
`With --high-level and review.highLevel.slices on, in an assist session: read the PR's slices from a JSON file of [{title, summary, hunks[]}], where hunks are the path#index labels printed when the command refuses without slices. Unknown refs are dropped with a warning, unclaimed hunks go into an "Everything else" slice, and the slices are saved for this head SHA so a reopen reuses them unless --force is passed`
|
|
43608
43787
|
).option(
|
|
43609
43788
|
"--configure",
|
|
43610
43789
|
"With --high-level: review nothing and instead ask for review.highLevel.criticalPaths, uiPaths and descriptionWordCap one at a time, each prefilled with its current value or, when unset, globs Claude proposes from this repo's own tree (for criticalPaths, merged with its defaults), then write the answers in one pass to either this repo's override in the shared assist database or the project assist.yml. A blank answer leaves that key unset"
|
|
@@ -43680,11 +43859,11 @@ import path88 from "path";
|
|
|
43680
43859
|
import chalk261 from "chalk";
|
|
43681
43860
|
|
|
43682
43861
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
43683
|
-
import { existsSync as existsSync72, readFileSync as
|
|
43862
|
+
import { existsSync as existsSync72, readFileSync as readFileSync59, writeFileSync as writeFileSync45 } from "fs";
|
|
43684
43863
|
import path87 from "path";
|
|
43685
43864
|
|
|
43686
43865
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
43687
|
-
import { readFileSync as
|
|
43866
|
+
import { readFileSync as readFileSync58 } from "fs";
|
|
43688
43867
|
import path86 from "path";
|
|
43689
43868
|
|
|
43690
43869
|
// src/commands/rules/findClaudeFiles.ts
|
|
@@ -43708,7 +43887,7 @@ function findClaudeFiles(dir) {
|
|
|
43708
43887
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
43709
43888
|
function scopedRuleDirectories(root2) {
|
|
43710
43889
|
return findClaudeFiles(root2).filter(
|
|
43711
|
-
(file) => path86.dirname(file) !== root2 && parseRulesSection(
|
|
43890
|
+
(file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync58(file, "utf8")).length > 0
|
|
43712
43891
|
).map(
|
|
43713
43892
|
(file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
|
|
43714
43893
|
).sort();
|
|
@@ -43750,7 +43929,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
43750
43929
|
function updateScopedRulesIndex(root2) {
|
|
43751
43930
|
const directories = scopedRuleDirectories(root2);
|
|
43752
43931
|
const rootFile = path87.join(root2, "CLAUDE.md");
|
|
43753
|
-
const before = existsSync72(rootFile) ?
|
|
43932
|
+
const before = existsSync72(rootFile) ? readFileSync59(rootFile, "utf8") : "";
|
|
43754
43933
|
const after = upsertScopedRulesPointer(before, directories);
|
|
43755
43934
|
if (after !== before) writeFileSync45(rootFile, after);
|
|
43756
43935
|
return directories;
|
|
@@ -43803,7 +43982,7 @@ function listRules(target, options2 = {}) {
|
|
|
43803
43982
|
}
|
|
43804
43983
|
|
|
43805
43984
|
// src/commands/rules/addRule.ts
|
|
43806
|
-
import { existsSync as existsSync74, readFileSync as
|
|
43985
|
+
import { existsSync as existsSync74, readFileSync as readFileSync61, writeFileSync as writeFileSync46 } from "fs";
|
|
43807
43986
|
import path91 from "path";
|
|
43808
43987
|
import chalk263 from "chalk";
|
|
43809
43988
|
|
|
@@ -43828,11 +44007,11 @@ function insertRuleBullet(content, rule) {
|
|
|
43828
44007
|
}
|
|
43829
44008
|
|
|
43830
44009
|
// src/commands/rules/nextRuleCode.ts
|
|
43831
|
-
import { readFileSync as
|
|
44010
|
+
import { readFileSync as readFileSync60 } from "fs";
|
|
43832
44011
|
var CODE_PREFIX = "R";
|
|
43833
44012
|
function nextRuleCode(root2) {
|
|
43834
44013
|
const numbers = findClaudeFiles(root2).flatMap(
|
|
43835
|
-
(file) => parseRulesSection(
|
|
44014
|
+
(file) => parseRulesSection(readFileSync60(file, "utf8")).map(
|
|
43836
44015
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
43837
44016
|
)
|
|
43838
44017
|
);
|
|
@@ -43859,7 +44038,7 @@ function resolveRuleScope(target) {
|
|
|
43859
44038
|
|
|
43860
44039
|
// src/commands/rules/addRule.ts
|
|
43861
44040
|
function read2(file) {
|
|
43862
|
-
return existsSync74(file) ?
|
|
44041
|
+
return existsSync74(file) ? readFileSync61(file, "utf8") : "";
|
|
43863
44042
|
}
|
|
43864
44043
|
function addRule(text20, options2) {
|
|
43865
44044
|
const rule = text20.trim();
|
|
@@ -44382,7 +44561,7 @@ function findShownSessionFiles(body, writtenPaths, locations) {
|
|
|
44382
44561
|
}
|
|
44383
44562
|
|
|
44384
44563
|
// src/commands/show/sessionWrittenPaths.ts
|
|
44385
|
-
import { readFileSync as
|
|
44564
|
+
import { readFileSync as readFileSync62 } from "fs";
|
|
44386
44565
|
|
|
44387
44566
|
// src/commands/sessions/shared/asRecord.ts
|
|
44388
44567
|
function asRecord(value) {
|
|
@@ -44410,7 +44589,7 @@ function writtenFilePaths(entry) {
|
|
|
44410
44589
|
function sessionWrittenPaths(transcriptPath2) {
|
|
44411
44590
|
let text20;
|
|
44412
44591
|
try {
|
|
44413
|
-
text20 =
|
|
44592
|
+
text20 = readFileSync62(transcriptPath2, "utf8");
|
|
44414
44593
|
} catch {
|
|
44415
44594
|
return [];
|
|
44416
44595
|
}
|
|
@@ -44455,14 +44634,14 @@ async function show3(options2) {
|
|
|
44455
44634
|
process.exit(1);
|
|
44456
44635
|
}
|
|
44457
44636
|
refuseSessionFiles(body);
|
|
44458
|
-
const
|
|
44459
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
44637
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
44638
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) {
|
|
44460
44639
|
console.log(body);
|
|
44461
44640
|
return;
|
|
44462
44641
|
}
|
|
44463
44642
|
try {
|
|
44464
44643
|
await sendShowPreview({
|
|
44465
|
-
sessionId,
|
|
44644
|
+
sessionId: sessionId2,
|
|
44466
44645
|
requestId: randomUUID25(),
|
|
44467
44646
|
title: options2.title ?? "Show",
|
|
44468
44647
|
body
|
|
@@ -44529,12 +44708,12 @@ import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync48 } from "fs";
|
|
|
44529
44708
|
import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync47 } from "fs";
|
|
44530
44709
|
|
|
44531
44710
|
// src/commands/slack/readSlackParts.ts
|
|
44532
|
-
import { readFileSync as
|
|
44711
|
+
import { readFileSync as readFileSync63 } from "fs";
|
|
44533
44712
|
function readSlackParts(files) {
|
|
44534
44713
|
return files.map((file) => {
|
|
44535
44714
|
let contents;
|
|
44536
44715
|
try {
|
|
44537
|
-
contents =
|
|
44716
|
+
contents = readFileSync63(file, "utf8");
|
|
44538
44717
|
} catch {
|
|
44539
44718
|
console.error(`Error: Part file not found: ${file}`);
|
|
44540
44719
|
process.exit(1);
|
|
@@ -44551,14 +44730,14 @@ function readSlackParts(files) {
|
|
|
44551
44730
|
// src/commands/slack/reviewProposedSlackMessage.ts
|
|
44552
44731
|
import { randomUUID as randomUUID26 } from "crypto";
|
|
44553
44732
|
async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
44554
|
-
const
|
|
44555
|
-
if (process.env.ASSIST_SESSION !== "1" || !
|
|
44733
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
44734
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return;
|
|
44556
44735
|
const { channel, threadTs, part } = target;
|
|
44557
44736
|
const destination = threadTs ? `Reply in ${channel} thread ${threadTs}` : `Post to ${channel}`;
|
|
44558
44737
|
await awaitPreviewApproval(
|
|
44559
44738
|
part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
|
|
44560
44739
|
{
|
|
44561
|
-
sessionId,
|
|
44740
|
+
sessionId: sessionId2,
|
|
44562
44741
|
requestId: randomUUID26(),
|
|
44563
44742
|
title: part ? `${destination} (${part.index}/${part.total})` : destination,
|
|
44564
44743
|
body,
|
|
@@ -45648,9 +45827,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
45648
45827
|
}
|
|
45649
45828
|
|
|
45650
45829
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
45651
|
-
import { readFileSync as
|
|
45830
|
+
import { readFileSync as readFileSync68 } from "fs";
|
|
45652
45831
|
function readCleanedCues(inputPath) {
|
|
45653
|
-
return deduplicateCues(parseVtt(
|
|
45832
|
+
return deduplicateCues(parseVtt(readFileSync68(inputPath, "utf8")));
|
|
45654
45833
|
}
|
|
45655
45834
|
|
|
45656
45835
|
// src/commands/transcript/clean.ts
|
|
@@ -45923,16 +46102,16 @@ function selectPassages(sources, selection) {
|
|
|
45923
46102
|
}
|
|
45924
46103
|
|
|
45925
46104
|
// src/commands/transcript/selectionSchema.ts
|
|
45926
|
-
import { z as
|
|
45927
|
-
var selectionSchema =
|
|
45928
|
-
keep:
|
|
45929
|
-
|
|
45930
|
-
file:
|
|
45931
|
-
from:
|
|
45932
|
-
to:
|
|
46105
|
+
import { z as z21 } from "zod";
|
|
46106
|
+
var selectionSchema = z21.strictObject({
|
|
46107
|
+
keep: z21.array(
|
|
46108
|
+
z21.strictObject({
|
|
46109
|
+
file: z21.string().trim().min(1, "file is required"),
|
|
46110
|
+
from: z21.string().trim().min(1, "from is required"),
|
|
46111
|
+
to: z21.string().trim().min(1, "to is required")
|
|
45933
46112
|
})
|
|
45934
46113
|
).min(1, "a selection needs at least one keep range"),
|
|
45935
|
-
removed:
|
|
46114
|
+
removed: z21.array(z21.string().trim().min(1)).default([])
|
|
45936
46115
|
});
|
|
45937
46116
|
|
|
45938
46117
|
// src/commands/transcript/widenAudienceInText.ts
|
|
@@ -46430,7 +46609,7 @@ function configKeys2() {
|
|
|
46430
46609
|
}
|
|
46431
46610
|
|
|
46432
46611
|
// src/commands/verify/forbiddenStrings.ts
|
|
46433
|
-
import { existsSync as existsSync83, readFileSync as
|
|
46612
|
+
import { existsSync as existsSync83, readFileSync as readFileSync69 } from "fs";
|
|
46434
46613
|
|
|
46435
46614
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
46436
46615
|
import { minimatch as minimatch10 } from "minimatch";
|
|
@@ -46477,7 +46656,7 @@ function forbiddenStrings() {
|
|
|
46477
46656
|
}
|
|
46478
46657
|
let parsed;
|
|
46479
46658
|
try {
|
|
46480
|
-
parsed = JSON.parse(
|
|
46659
|
+
parsed = JSON.parse(readFileSync69(file, "utf8"));
|
|
46481
46660
|
} catch (error) {
|
|
46482
46661
|
console.log(`Could not parse ${file}: ${error.message}`);
|
|
46483
46662
|
process.exit(1);
|
|
@@ -46549,7 +46728,7 @@ Total: ${lines2.length} hardcoded color(s)`);
|
|
|
46549
46728
|
}
|
|
46550
46729
|
|
|
46551
46730
|
// src/commands/verify/migrations.ts
|
|
46552
|
-
import { readFileSync as
|
|
46731
|
+
import { readFileSync as readFileSync70 } from "fs";
|
|
46553
46732
|
import path105 from "path";
|
|
46554
46733
|
|
|
46555
46734
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
@@ -46714,7 +46893,7 @@ function migrations2() {
|
|
|
46714
46893
|
if (ref) {
|
|
46715
46894
|
const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
|
|
46716
46895
|
const current = new Map(
|
|
46717
|
-
files.map((file) => [file,
|
|
46896
|
+
files.map((file) => [file, readFileSync70(path105.join(dir, file), "utf8")])
|
|
46718
46897
|
);
|
|
46719
46898
|
for (const finding of checkAppendOnly(baseline, current)) {
|
|
46720
46899
|
problems.push(
|
|
@@ -47635,7 +47814,7 @@ function registerWatch(program) {
|
|
|
47635
47814
|
|
|
47636
47815
|
// src/commands/roam/postRoamActivity.ts
|
|
47637
47816
|
import { execFileSync as execFileSync31 } from "child_process";
|
|
47638
|
-
import { readdirSync as readdirSync25, readFileSync as
|
|
47817
|
+
import { readdirSync as readdirSync25, readFileSync as readFileSync71, statSync as statSync13 } from "fs";
|
|
47639
47818
|
import { join as join108 } from "path";
|
|
47640
47819
|
function findPortFile(roamDir) {
|
|
47641
47820
|
let entries;
|
|
@@ -47666,7 +47845,7 @@ function postRoamActivity(app, event) {
|
|
|
47666
47845
|
if (!portFile) return;
|
|
47667
47846
|
let port;
|
|
47668
47847
|
try {
|
|
47669
|
-
port =
|
|
47848
|
+
port = readFileSync71(portFile, "utf8").trim();
|
|
47670
47849
|
} catch {
|
|
47671
47850
|
return;
|
|
47672
47851
|
}
|
|
@@ -48287,11 +48466,11 @@ function applyLine(result, pending, line) {
|
|
|
48287
48466
|
}
|
|
48288
48467
|
|
|
48289
48468
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
48290
|
-
import { readFileSync as
|
|
48469
|
+
import { readFileSync as readFileSync72 } from "fs";
|
|
48291
48470
|
function readDaemonPidFile() {
|
|
48292
48471
|
try {
|
|
48293
48472
|
const pid = Number.parseInt(
|
|
48294
|
-
|
|
48473
|
+
readFileSync72(daemonPaths.pid, "utf8").trim(),
|
|
48295
48474
|
10
|
|
48296
48475
|
);
|
|
48297
48476
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -48770,9 +48949,9 @@ async function refreshRepoConfigCacheOnStart() {
|
|
|
48770
48949
|
}
|
|
48771
48950
|
|
|
48772
48951
|
// src/commands/sessions/daemon/loadActiveSelection.ts
|
|
48773
|
-
import { z as
|
|
48952
|
+
import { z as z22 } from "zod";
|
|
48774
48953
|
var ACTIVE_FILE = "active.json";
|
|
48775
|
-
var activeSelectionSchema =
|
|
48954
|
+
var activeSelectionSchema = z22.record(z22.string(), z22.string());
|
|
48776
48955
|
function loadActiveSelection() {
|
|
48777
48956
|
const parsed = activeSelectionSchema.safeParse(
|
|
48778
48957
|
loadJson(ACTIVE_FILE)
|
|
@@ -48790,23 +48969,23 @@ var ActiveSelection = class {
|
|
|
48790
48969
|
this.onChange = onChange;
|
|
48791
48970
|
}
|
|
48792
48971
|
byRepo = /* @__PURE__ */ new Map();
|
|
48793
|
-
set(cwd,
|
|
48972
|
+
set(cwd, sessionId2) {
|
|
48794
48973
|
if (!cwd) return;
|
|
48795
|
-
if (this.isAlreadySelected(cwd,
|
|
48974
|
+
if (this.isAlreadySelected(cwd, sessionId2)) return;
|
|
48796
48975
|
this.byRepo.delete(cwd);
|
|
48797
|
-
this.byRepo.set(cwd,
|
|
48798
|
-
daemonLog(`set-active: cwd=${cwd} id=${
|
|
48976
|
+
this.byRepo.set(cwd, sessionId2);
|
|
48977
|
+
daemonLog(`set-active: cwd=${cwd} id=${sessionId2}`);
|
|
48799
48978
|
saveActiveSelection(this.toJSON());
|
|
48800
48979
|
this.onChange();
|
|
48801
48980
|
}
|
|
48802
|
-
isAlreadySelected(cwd,
|
|
48803
|
-
if (this.byRepo.get(cwd) !==
|
|
48981
|
+
isAlreadySelected(cwd, sessionId2) {
|
|
48982
|
+
if (this.byRepo.get(cwd) !== sessionId2) return false;
|
|
48804
48983
|
return [...this.byRepo.keys()].at(-1) === cwd;
|
|
48805
48984
|
}
|
|
48806
48985
|
// why: on daemon restart, reload persisted selections but drop any whose session was not restored
|
|
48807
48986
|
restore(isLive2) {
|
|
48808
|
-
for (const [cwd,
|
|
48809
|
-
if (isLive2(
|
|
48987
|
+
for (const [cwd, sessionId2] of Object.entries(loadActiveSelection()))
|
|
48988
|
+
if (isLive2(sessionId2)) this.byRepo.set(cwd, sessionId2);
|
|
48810
48989
|
}
|
|
48811
48990
|
toJSON() {
|
|
48812
48991
|
return Object.fromEntries(this.byRepo);
|
|
@@ -49134,7 +49313,7 @@ function sendResizeSnapshot(s, send) {
|
|
|
49134
49313
|
}
|
|
49135
49314
|
|
|
49136
49315
|
// src/commands/sessions/daemon/viewerSize.ts
|
|
49137
|
-
import { readFileSync as
|
|
49316
|
+
import { readFileSync as readFileSync73, writeFileSync as writeFileSync58 } from "fs";
|
|
49138
49317
|
var DEFAULT_SIZE = { cols: 120, rows: 30 };
|
|
49139
49318
|
var remembered;
|
|
49140
49319
|
function rememberViewerSize(cols, rows) {
|
|
@@ -49156,7 +49335,7 @@ function viewerSize() {
|
|
|
49156
49335
|
function readSavedSize() {
|
|
49157
49336
|
try {
|
|
49158
49337
|
const { cols, rows } = JSON.parse(
|
|
49159
|
-
|
|
49338
|
+
readFileSync73(daemonPaths.viewerSize, "utf8")
|
|
49160
49339
|
);
|
|
49161
49340
|
if (typeof cols === "number" && typeof rows === "number" && cols > 0)
|
|
49162
49341
|
return { cols, rows };
|
|
@@ -49201,9 +49380,9 @@ function bracketedPaste(text20) {
|
|
|
49201
49380
|
|
|
49202
49381
|
// src/commands/sessions/shared/pasteAndSubmit.ts
|
|
49203
49382
|
var SUBMIT_DELAY_MS = 150;
|
|
49204
|
-
function pasteAndSubmit(sendInput,
|
|
49205
|
-
sendInput(
|
|
49206
|
-
setTimeout(() => sendInput(
|
|
49383
|
+
function pasteAndSubmit(sendInput, sessionId2, text20) {
|
|
49384
|
+
sendInput(sessionId2, bracketedPaste(text20));
|
|
49385
|
+
setTimeout(() => sendInput(sessionId2, SUBMIT), SUBMIT_DELAY_MS);
|
|
49207
49386
|
}
|
|
49208
49387
|
|
|
49209
49388
|
// src/commands/sessions/daemon/flushPendingPrompts.ts
|
|
@@ -49699,8 +49878,8 @@ var MissingCwdError = class extends Error {
|
|
|
49699
49878
|
this.name = "MissingCwdError";
|
|
49700
49879
|
}
|
|
49701
49880
|
};
|
|
49702
|
-
function spawnPty(args, cwd,
|
|
49703
|
-
refuseMissingCwd(cwd,
|
|
49881
|
+
function spawnPty(args, cwd, sessionId2, extraEnv) {
|
|
49882
|
+
refuseMissingCwd(cwd, sessionId2);
|
|
49704
49883
|
ensureSpawnHelperExecutable();
|
|
49705
49884
|
const command = resolvePtyCommand(args);
|
|
49706
49885
|
const {
|
|
@@ -49715,18 +49894,18 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
49715
49894
|
env: {
|
|
49716
49895
|
...parentEnv,
|
|
49717
49896
|
ASSIST_SESSION: "1",
|
|
49718
|
-
...
|
|
49719
|
-
ASSIST_SESSION_ID:
|
|
49720
|
-
ASSIST_ACTIVITY_ID:
|
|
49897
|
+
...sessionId2 && {
|
|
49898
|
+
ASSIST_SESSION_ID: sessionId2,
|
|
49899
|
+
ASSIST_ACTIVITY_ID: sessionId2
|
|
49721
49900
|
},
|
|
49722
49901
|
...extraEnv
|
|
49723
49902
|
}
|
|
49724
49903
|
});
|
|
49725
49904
|
}
|
|
49726
|
-
function refuseMissingCwd(cwd,
|
|
49905
|
+
function refuseMissingCwd(cwd, sessionId2) {
|
|
49727
49906
|
if (!cwd || existsSync91(cwd)) return;
|
|
49728
49907
|
daemonLog(
|
|
49729
|
-
`${
|
|
49908
|
+
`${sessionId2 ? `session ${sessionId2}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
49730
49909
|
);
|
|
49731
49910
|
throw new MissingCwdError(cwd);
|
|
49732
49911
|
}
|
|
@@ -49976,18 +50155,18 @@ async function backOff(reason4, deps2) {
|
|
|
49976
50155
|
|
|
49977
50156
|
// src/commands/sessions/daemon/autoUpdate/holdForEscalation.ts
|
|
49978
50157
|
var ESCALATION_POLL_MS = 5e3;
|
|
49979
|
-
async function holdForEscalation(
|
|
50158
|
+
async function holdForEscalation(sessionId2, deps2) {
|
|
49980
50159
|
deps2.takeHoldRelease();
|
|
49981
|
-
deps2.enter("diverged", { escalationId:
|
|
49982
|
-
deps2.note(`paused while session ${
|
|
49983
|
-
while (deps2.isLive(
|
|
50160
|
+
deps2.enter("diverged", { escalationId: sessionId2 });
|
|
50161
|
+
deps2.note(`paused while session ${sessionId2} reconciles the divergence`);
|
|
50162
|
+
while (deps2.isLive(sessionId2)) {
|
|
49984
50163
|
await deps2.sleep(ESCALATION_POLL_MS);
|
|
49985
50164
|
if (deps2.takeHoldRelease()) {
|
|
49986
|
-
deps2.note(`check requested while session ${
|
|
50165
|
+
deps2.note(`check requested while session ${sessionId2} is open; resuming`);
|
|
49987
50166
|
return;
|
|
49988
50167
|
}
|
|
49989
50168
|
}
|
|
49990
|
-
deps2.note(`session ${
|
|
50169
|
+
deps2.note(`session ${sessionId2} ended; resuming`);
|
|
49991
50170
|
}
|
|
49992
50171
|
|
|
49993
50172
|
// src/commands/sessions/daemon/autoUpdate/runLapCapturingTail.ts
|
|
@@ -50041,14 +50220,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
|
|
|
50041
50220
|
}
|
|
50042
50221
|
|
|
50043
50222
|
// src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
|
|
50044
|
-
import { readFileSync as
|
|
50223
|
+
import { readFileSync as readFileSync75, writeFileSync as writeFileSync60 } from "fs";
|
|
50045
50224
|
var KEEP_TAIL = 256 * 1024;
|
|
50046
50225
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
50047
50226
|
function trimWatcherLog(cwd) {
|
|
50048
50227
|
const path109 = watcherLogPath(cwd);
|
|
50049
50228
|
let log2;
|
|
50050
50229
|
try {
|
|
50051
|
-
log2 =
|
|
50230
|
+
log2 = readFileSync75(path109, "utf8");
|
|
50052
50231
|
} catch {
|
|
50053
50232
|
return;
|
|
50054
50233
|
}
|
|
@@ -50375,8 +50554,8 @@ function loopDeps(installDir, ctx) {
|
|
|
50375
50554
|
enter: autoUpdateState.enter,
|
|
50376
50555
|
liveEscalation: () => liveEscalationIn(ctx().sessions, clone)?.id,
|
|
50377
50556
|
escalate: (output) => escalateDivergence(ctx(), installDir, output),
|
|
50378
|
-
isLive: (
|
|
50379
|
-
const status2 = ctx().sessions.get(
|
|
50557
|
+
isLive: (sessionId2) => {
|
|
50558
|
+
const status2 = ctx().sessions.get(sessionId2)?.status;
|
|
50380
50559
|
return status2 !== void 0 && status2 !== "done" && status2 !== "error";
|
|
50381
50560
|
},
|
|
50382
50561
|
takeHoldRelease: autoUpdateControl.takeHoldRelease,
|
|
@@ -50832,7 +51011,7 @@ function pidList(pids) {
|
|
|
50832
51011
|
}
|
|
50833
51012
|
|
|
50834
51013
|
// src/commands/sessions/daemon/worktree/readOccupant.ts
|
|
50835
|
-
import { readFileSync as
|
|
51014
|
+
import { readFileSync as readFileSync76 } from "fs";
|
|
50836
51015
|
var VSCODE_PATHS = [
|
|
50837
51016
|
"/.vscode-server/",
|
|
50838
51017
|
"/.vscode-server-insiders/",
|
|
@@ -50867,7 +51046,7 @@ function parentPid(stat5) {
|
|
|
50867
51046
|
}
|
|
50868
51047
|
function readProc(procRoot, pid, file) {
|
|
50869
51048
|
try {
|
|
50870
|
-
return
|
|
51049
|
+
return readFileSync76(`${procRoot}/${pid}/${file}`, "utf8");
|
|
50871
51050
|
} catch {
|
|
50872
51051
|
return void 0;
|
|
50873
51052
|
}
|
|
@@ -50882,12 +51061,12 @@ function liveOccupantReason(treePath) {
|
|
|
50882
51061
|
}
|
|
50883
51062
|
|
|
50884
51063
|
// src/commands/sessions/daemon/worktree/closeBlockReason.ts
|
|
50885
|
-
async function closeBlockReason(
|
|
51064
|
+
async function closeBlockReason(sessionId2, tree) {
|
|
50886
51065
|
const durability = await checkDurability(tree.path);
|
|
50887
51066
|
if (!durability.durable) return { reason: durability.reason, live: false };
|
|
50888
51067
|
if (durability.gone) {
|
|
50889
51068
|
daemonLog(
|
|
50890
|
-
`session ${
|
|
51069
|
+
`session ${sessionId2} closing: worktree ${tree.path} is gone from disk \u2014 released with nothing to land, not landed work`
|
|
50891
51070
|
);
|
|
50892
51071
|
return void 0;
|
|
50893
51072
|
}
|
|
@@ -51496,9 +51675,9 @@ function buildPrompt5(prompt) {
|
|
|
51496
51675
|
}
|
|
51497
51676
|
|
|
51498
51677
|
// src/commands/sessions/shared/loadSessionTitles.ts
|
|
51499
|
-
import { z as
|
|
51678
|
+
import { z as z23 } from "zod";
|
|
51500
51679
|
var TITLES_FILE = "session-titles.json";
|
|
51501
|
-
var sessionTitlesSchema =
|
|
51680
|
+
var sessionTitlesSchema = z23.record(z23.string(), z23.string());
|
|
51502
51681
|
function loadSessionTitles() {
|
|
51503
51682
|
const parsed = sessionTitlesSchema.safeParse(
|
|
51504
51683
|
loadJson(TITLES_FILE)
|
|
@@ -51901,13 +52080,13 @@ function bindCodexSession(session, notify2) {
|
|
|
51901
52080
|
const schedule = () => setTimeout(() => void poll(), POLL_MS5).unref();
|
|
51902
52081
|
const poll = async () => {
|
|
51903
52082
|
if (session.harnessSessionId) return;
|
|
51904
|
-
const
|
|
51905
|
-
if (!
|
|
52083
|
+
const sessionId2 = await resolveCodexSessionId(cwd, since);
|
|
52084
|
+
if (!sessionId2) {
|
|
51906
52085
|
if (--attemptsLeft > 0) schedule();
|
|
51907
52086
|
return;
|
|
51908
52087
|
}
|
|
51909
|
-
session.harnessSessionId =
|
|
51910
|
-
daemonLog(`session ${session.id} bound to codex conversation ${
|
|
52088
|
+
session.harnessSessionId = sessionId2;
|
|
52089
|
+
daemonLog(`session ${session.id} bound to codex conversation ${sessionId2}`);
|
|
51911
52090
|
rememberSessionTitle(session);
|
|
51912
52091
|
notify2();
|
|
51913
52092
|
};
|
|
@@ -51919,13 +52098,13 @@ import { watch as watch3 } from "fs";
|
|
|
51919
52098
|
|
|
51920
52099
|
// src/commands/sessions/daemon/ensureProjectDirExists.ts
|
|
51921
52100
|
import { mkdirSync as mkdirSync42 } from "fs";
|
|
51922
|
-
function ensureProjectDirExists(dir,
|
|
52101
|
+
function ensureProjectDirExists(dir, sessionId2) {
|
|
51923
52102
|
try {
|
|
51924
52103
|
mkdirSync42(dir, { recursive: true });
|
|
51925
52104
|
return true;
|
|
51926
52105
|
} catch (error) {
|
|
51927
52106
|
daemonLog(
|
|
51928
|
-
`session ${
|
|
52107
|
+
`session ${sessionId2} transcript dir unavailable: ${error instanceof Error ? error.message : String(error)}`
|
|
51929
52108
|
);
|
|
51930
52109
|
return false;
|
|
51931
52110
|
}
|
|
@@ -52710,7 +52889,7 @@ function backlogRunArgs(session) {
|
|
|
52710
52889
|
}
|
|
52711
52890
|
|
|
52712
52891
|
// src/commands/sessions/daemon/transfer/launchOnTarget.ts
|
|
52713
|
-
function launchOnTarget(
|
|
52892
|
+
function launchOnTarget(links2, request) {
|
|
52714
52893
|
return new Promise((resolve33) => {
|
|
52715
52894
|
const capture = {
|
|
52716
52895
|
send: (raw) => {
|
|
@@ -52721,8 +52900,15 @@ function launchOnTarget(route, request) {
|
|
|
52721
52900
|
resolve33({ ok: false, error: String(msg.message) });
|
|
52722
52901
|
}
|
|
52723
52902
|
};
|
|
52724
|
-
|
|
52725
|
-
|
|
52903
|
+
try {
|
|
52904
|
+
if (!links2.route(capture, request))
|
|
52905
|
+
resolve33({ ok: false, error: `${request.node} is not a linked node` });
|
|
52906
|
+
} catch (error) {
|
|
52907
|
+
resolve33({
|
|
52908
|
+
ok: false,
|
|
52909
|
+
error: error instanceof Error ? error.message : String(error)
|
|
52910
|
+
});
|
|
52911
|
+
}
|
|
52726
52912
|
});
|
|
52727
52913
|
}
|
|
52728
52914
|
|
|
@@ -52745,15 +52931,14 @@ function settleTransfer(client, deps2, s, outcome, traceId) {
|
|
|
52745
52931
|
`session ${s.id} transferred to ${target} as ${outcome.sessionId} trace=${traceId}; closing source`
|
|
52746
52932
|
);
|
|
52747
52933
|
s.transfer = void 0;
|
|
52934
|
+
deps2.stop(s.id);
|
|
52748
52935
|
deps2.discard(s.id);
|
|
52749
52936
|
sendTo(client, { type: "notice", message: `Transferred to ${target}` });
|
|
52750
52937
|
}
|
|
52751
52938
|
|
|
52752
52939
|
// src/commands/sessions/daemon/transfer/handOffToTarget.ts
|
|
52753
52940
|
async function handOffToTarget(client, deps2, s, { args, target, cwd, traceId, snapshot }) {
|
|
52754
|
-
deps2.
|
|
52755
|
-
deps2.notify();
|
|
52756
|
-
const outcome = await launchOnTarget(deps2.links.route, {
|
|
52941
|
+
const outcome = await launchOnTarget(deps2.links, {
|
|
52757
52942
|
type: "create-assist",
|
|
52758
52943
|
assistArgs: args,
|
|
52759
52944
|
cwd,
|
|
@@ -54458,31 +54643,31 @@ var VerifyTracker = class {
|
|
|
54458
54643
|
this.notify = notify2;
|
|
54459
54644
|
}
|
|
54460
54645
|
sessionByClient = /* @__PURE__ */ new Map();
|
|
54461
|
-
start(client,
|
|
54462
|
-
const session = this.sessions.get(
|
|
54646
|
+
start(client, sessionId2) {
|
|
54647
|
+
const session = this.sessions.get(sessionId2);
|
|
54463
54648
|
if (!session) {
|
|
54464
54649
|
daemonLog(
|
|
54465
|
-
`verify-started for unknown session id=${
|
|
54650
|
+
`verify-started for unknown session id=${sessionId2} (ignoring)`
|
|
54466
54651
|
);
|
|
54467
54652
|
return;
|
|
54468
54653
|
}
|
|
54469
|
-
daemonLog(`verify-started received: id=${
|
|
54470
|
-
this.sessionByClient.set(client,
|
|
54654
|
+
daemonLog(`verify-started received: id=${sessionId2}`);
|
|
54655
|
+
this.sessionByClient.set(client, sessionId2);
|
|
54471
54656
|
session.verifying = true;
|
|
54472
54657
|
this.notify();
|
|
54473
54658
|
}
|
|
54474
54659
|
clear(client) {
|
|
54475
|
-
const
|
|
54476
|
-
if (!
|
|
54660
|
+
const sessionId2 = this.sessionByClient.get(client);
|
|
54661
|
+
if (!sessionId2) return;
|
|
54477
54662
|
this.sessionByClient.delete(client);
|
|
54478
|
-
if (this.stillVerifying(
|
|
54479
|
-
daemonLog(`verify connection closed: id=${
|
|
54480
|
-
const session = this.sessions.get(
|
|
54663
|
+
if (this.stillVerifying(sessionId2)) return;
|
|
54664
|
+
daemonLog(`verify connection closed: id=${sessionId2}`);
|
|
54665
|
+
const session = this.sessions.get(sessionId2);
|
|
54481
54666
|
if (session) session.verifying = false;
|
|
54482
54667
|
this.notify();
|
|
54483
54668
|
}
|
|
54484
|
-
stillVerifying(
|
|
54485
|
-
return [...this.sessionByClient.values()].includes(
|
|
54669
|
+
stillVerifying(sessionId2) {
|
|
54670
|
+
return [...this.sessionByClient.values()].includes(sessionId2);
|
|
54486
54671
|
}
|
|
54487
54672
|
};
|
|
54488
54673
|
|
|
@@ -54683,18 +54868,18 @@ function resetRelayState(state, reason4) {
|
|
|
54683
54868
|
state.scrollback.clear();
|
|
54684
54869
|
}
|
|
54685
54870
|
function replayLinkScrollback(state, client) {
|
|
54686
|
-
for (const [
|
|
54871
|
+
for (const [sessionId2, data] of state.scrollback)
|
|
54687
54872
|
if (data)
|
|
54688
54873
|
sendTo(client, {
|
|
54689
54874
|
type: "output",
|
|
54690
|
-
sessionId,
|
|
54875
|
+
sessionId: sessionId2,
|
|
54691
54876
|
data: stripReplayQueries(data)
|
|
54692
54877
|
});
|
|
54693
54878
|
}
|
|
54694
|
-
function appendScrollback(state,
|
|
54695
|
-
const next3 = (state.scrollback.get(
|
|
54879
|
+
function appendScrollback(state, sessionId2, data) {
|
|
54880
|
+
const next3 = (state.scrollback.get(sessionId2) ?? "") + data;
|
|
54696
54881
|
state.scrollback.set(
|
|
54697
|
-
|
|
54882
|
+
sessionId2,
|
|
54698
54883
|
next3.length > MAX_SCROLLBACK2 ? next3.slice(-MAX_SCROLLBACK2) : next3
|
|
54699
54884
|
);
|
|
54700
54885
|
}
|
|
@@ -54931,9 +55116,9 @@ function relayToCreator(label) {
|
|
|
54931
55116
|
// src/commands/sessions/daemon/links/relayLinkMessage.ts
|
|
54932
55117
|
var nsId = (state, msg) => toNodeSessionId(state.node, msg.sessionId);
|
|
54933
55118
|
var relayOutput = (state, msg) => {
|
|
54934
|
-
const
|
|
54935
|
-
appendScrollback(state,
|
|
54936
|
-
broadcastToViewers(state, { type: "output", sessionId, data: msg.data });
|
|
55119
|
+
const sessionId2 = nsId(state, msg);
|
|
55120
|
+
appendScrollback(state, sessionId2, msg.data);
|
|
55121
|
+
broadcastToViewers(state, { type: "output", sessionId: sessionId2, data: msg.data });
|
|
54937
55122
|
};
|
|
54938
55123
|
var relayHistory = (state, msg) => {
|
|
54939
55124
|
const sessions = (msg.sessions ?? []).map((s) => ({
|
|
@@ -55438,12 +55623,12 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
|
|
|
55438
55623
|
import { existsSync as existsSync103 } from "fs";
|
|
55439
55624
|
|
|
55440
55625
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
55441
|
-
function resumeSession(id,
|
|
55626
|
+
function resumeSession(id, sessionId2, cwd, name, holdPty, harness) {
|
|
55442
55627
|
const startedAt = Date.now();
|
|
55443
55628
|
const codex = resolveHarness(harness) === "codex";
|
|
55444
55629
|
return {
|
|
55445
55630
|
id,
|
|
55446
|
-
name: name ? `${name.slice(0, 36)} (R)` : `Resume ${
|
|
55631
|
+
name: name ? `${name.slice(0, 36)} (R)` : `Resume ${sessionId2.slice(0, 8)}`,
|
|
55447
55632
|
commandType: "claude",
|
|
55448
55633
|
harness,
|
|
55449
55634
|
status: "waiting",
|
|
@@ -55452,7 +55637,7 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
55452
55637
|
runningSince: null,
|
|
55453
55638
|
waitingSince: startedAt,
|
|
55454
55639
|
...startOrHoldPty(
|
|
55455
|
-
() => codex ? spawnCodex2({ resumeSessionId:
|
|
55640
|
+
() => codex ? spawnCodex2({ resumeSessionId: sessionId2, cwd, sessionId: id }) : spawnClaude2({ resumeSessionId: sessionId2, cwd, sessionId: id }),
|
|
55456
55641
|
holdPty
|
|
55457
55642
|
),
|
|
55458
55643
|
scrollback: "",
|
|
@@ -55460,8 +55645,8 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
55460
55645
|
/* why: bind the card to the conversation it is resuming so a daemon restart
|
|
55461
55646
|
* re-resumes this same transcript, not whichever .jsonl a cwd poller would
|
|
55462
55647
|
* have re-discovered (#413). */
|
|
55463
|
-
claudeSessionId: codex ? void 0 :
|
|
55464
|
-
harnessSessionId: codex ?
|
|
55648
|
+
claudeSessionId: codex ? void 0 : sessionId2,
|
|
55649
|
+
harnessSessionId: codex ? sessionId2 : void 0
|
|
55465
55650
|
};
|
|
55466
55651
|
}
|
|
55467
55652
|
|
|
@@ -55539,13 +55724,13 @@ function cloneForReapedTree(missingCwd) {
|
|
|
55539
55724
|
}
|
|
55540
55725
|
|
|
55541
55726
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
55542
|
-
function resumeInTree(ctx,
|
|
55727
|
+
function resumeInTree(ctx, sessionId2, cwd, name, harness) {
|
|
55543
55728
|
if (!existsSync103(cwd))
|
|
55544
|
-
return resumeInReplacementTree(ctx,
|
|
55729
|
+
return resumeInReplacementTree(ctx, sessionId2, cwd, name, harness);
|
|
55545
55730
|
const id = ctx.spawnWith(
|
|
55546
|
-
(sid) => resumeSession(sid,
|
|
55731
|
+
(sid) => resumeSession(sid, sessionId2, cwd, name, void 0, harness)
|
|
55547
55732
|
);
|
|
55548
|
-
daemonLog(`session ${id} resuming ${
|
|
55733
|
+
daemonLog(`session ${id} resuming ${sessionId2} in ${cwd}`);
|
|
55549
55734
|
bindResumedWorktree(ctx.sessions.get(id), cwd, ctx.notify);
|
|
55550
55735
|
return id;
|
|
55551
55736
|
}
|
|
@@ -55629,8 +55814,8 @@ var SessionManager = class {
|
|
|
55629
55814
|
spawnAssist(assistArgs, cwd, meta, context) {
|
|
55630
55815
|
return spawnAssistInTree(this.treeCtx(), assistArgs, cwd, meta, context);
|
|
55631
55816
|
}
|
|
55632
|
-
resume(
|
|
55633
|
-
return resumeInTree(this.treeCtx(),
|
|
55817
|
+
resume(sessionId2, cwd, name, harness) {
|
|
55818
|
+
return resumeInTree(this.treeCtx(), sessionId2, cwd, name, harness);
|
|
55634
55819
|
}
|
|
55635
55820
|
onStatusChange = makeManagerStatusHandler(
|
|
55636
55821
|
this.sessions,
|
|
@@ -56166,8 +56351,8 @@ function tokenCountPayload(entry) {
|
|
|
56166
56351
|
}
|
|
56167
56352
|
|
|
56168
56353
|
// src/commands/sessions/daemon/applyCodexUsage.ts
|
|
56169
|
-
function applyCodexUsage(sessions,
|
|
56170
|
-
const session = sessions.get(
|
|
56354
|
+
function applyCodexUsage(sessions, sessionId2, usage, windows) {
|
|
56355
|
+
const session = sessions.get(sessionId2);
|
|
56171
56356
|
if (!session) return false;
|
|
56172
56357
|
if (usage.usedPct !== void 0) session.usedPct = usage.usedPct;
|
|
56173
56358
|
const phase = sessionBacklogPhase(session);
|
|
@@ -56186,19 +56371,19 @@ function applyCodexUsage(sessions, sessionId, usage, windows) {
|
|
|
56186
56371
|
// src/commands/sessions/daemon/handleCodexUsage.ts
|
|
56187
56372
|
var handleCodexUsage = (client, m, d) => {
|
|
56188
56373
|
if (m.links.route(client, d)) return;
|
|
56189
|
-
const
|
|
56190
|
-
daemonLog(`codex-usage received: id=${
|
|
56191
|
-
if (d.ack) sendTo(client, { type: "ack", sessionId });
|
|
56374
|
+
const sessionId2 = d.sessionId;
|
|
56375
|
+
daemonLog(`codex-usage received: id=${sessionId2}`);
|
|
56376
|
+
if (d.ack) sendTo(client, { type: "ack", sessionId: sessionId2 });
|
|
56192
56377
|
void readCodexRolloutUsage(d.transcriptPath).then(
|
|
56193
56378
|
(usage) => {
|
|
56194
56379
|
if (usage.rateLimits)
|
|
56195
56380
|
m.clients.updateHarnessLimits("codex", usage.rateLimits);
|
|
56196
56381
|
const windows = usage.rateLimits ? m.clients.currentWindows("codex") : [];
|
|
56197
56382
|
daemonLog(
|
|
56198
|
-
`codex-usage applied: id=${
|
|
56383
|
+
`codex-usage applied: id=${sessionId2} responses=${usage.responses.length} usedPct=${usage.usedPct ?? "none"} windows=${windows.length}`
|
|
56199
56384
|
);
|
|
56200
56385
|
m.update(
|
|
56201
|
-
(sessions) => applyCodexUsage(sessions,
|
|
56386
|
+
(sessions) => applyCodexUsage(sessions, sessionId2, usage, windows)
|
|
56202
56387
|
);
|
|
56203
56388
|
},
|
|
56204
56389
|
(error) => daemonLog(`codex-usage read failed: ${String(error)}`)
|
|
@@ -56300,22 +56485,22 @@ var handleOutputRequest = (client, m, d) => {
|
|
|
56300
56485
|
sendTo(client, { type: "session-output", error: target.error });
|
|
56301
56486
|
return;
|
|
56302
56487
|
}
|
|
56303
|
-
const { sessionId, exited } = target;
|
|
56488
|
+
const { sessionId: sessionId2, exited } = target;
|
|
56304
56489
|
let scrollback;
|
|
56305
56490
|
m.update((sessions) => {
|
|
56306
|
-
scrollback = sessions.get(
|
|
56491
|
+
scrollback = sessions.get(sessionId2)?.scrollback;
|
|
56307
56492
|
return false;
|
|
56308
56493
|
});
|
|
56309
56494
|
daemonLog(
|
|
56310
|
-
`output requested: id=${
|
|
56495
|
+
`output requested: id=${sessionId2}${exited ? ` (exited: ${exited})` : ""} ${scrollback === void 0 ? "unknown session" : `${scrollback.length} chars`}`
|
|
56311
56496
|
);
|
|
56312
56497
|
sendTo(
|
|
56313
56498
|
client,
|
|
56314
56499
|
scrollback === void 0 ? {
|
|
56315
56500
|
type: "session-output",
|
|
56316
|
-
sessionId,
|
|
56317
|
-
error: `No session ${
|
|
56318
|
-
} : { type: "session-output", sessionId, scrollback, exited }
|
|
56501
|
+
sessionId: sessionId2,
|
|
56502
|
+
error: `No session ${sessionId2} on this node`
|
|
56503
|
+
} : { type: "session-output", sessionId: sessionId2, scrollback, exited }
|
|
56319
56504
|
);
|
|
56320
56505
|
};
|
|
56321
56506
|
|
|
@@ -56373,18 +56558,18 @@ import * as fs58 from "fs";
|
|
|
56373
56558
|
|
|
56374
56559
|
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
56375
56560
|
import * as path108 from "path";
|
|
56376
|
-
async function findCodexRolloutPath(
|
|
56377
|
-
if (!
|
|
56561
|
+
async function findCodexRolloutPath(sessionId2) {
|
|
56562
|
+
if (!sessionId2) return null;
|
|
56378
56563
|
const paths = await discoverCodexRolloutPaths();
|
|
56379
|
-
const suffix = `-${
|
|
56564
|
+
const suffix = `-${sessionId2}.jsonl`;
|
|
56380
56565
|
return paths.find((file) => path108.basename(file).endsWith(suffix)) ?? null;
|
|
56381
56566
|
}
|
|
56382
56567
|
|
|
56383
56568
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
56384
|
-
async function parseTranscript(
|
|
56385
|
-
const filePath = await findSessionJsonlPath(
|
|
56569
|
+
async function parseTranscript(sessionId2) {
|
|
56570
|
+
const filePath = await findSessionJsonlPath(sessionId2);
|
|
56386
56571
|
if (filePath) return readMessages(filePath, parseTranscriptLines);
|
|
56387
|
-
const rollout = await findCodexRolloutPath(
|
|
56572
|
+
const rollout = await findCodexRolloutPath(sessionId2);
|
|
56388
56573
|
if (rollout) return readMessages(rollout, parseCodexTranscriptLines);
|
|
56389
56574
|
return [];
|
|
56390
56575
|
}
|
|
@@ -56433,15 +56618,15 @@ function findSession(manager, id) {
|
|
|
56433
56618
|
return found;
|
|
56434
56619
|
}
|
|
56435
56620
|
async function handleFetchUserMessages(client, manager, data) {
|
|
56436
|
-
const
|
|
56437
|
-
const session = findSession(manager,
|
|
56621
|
+
const sessionId2 = data.sessionId;
|
|
56622
|
+
const session = findSession(manager, sessionId2);
|
|
56438
56623
|
const filePath = session ? await resolveTranscriptPath(session) : null;
|
|
56439
56624
|
const entries = filePath ? await readTranscriptTail(filePath, Number.POSITIVE_INFINITY) : [];
|
|
56440
56625
|
const messages = extractUserMessages(entries);
|
|
56441
56626
|
daemonLog(
|
|
56442
|
-
`session ${
|
|
56627
|
+
`session ${sessionId2} user messages: ${messages.length} from ${filePath ?? "no transcript"}`
|
|
56443
56628
|
);
|
|
56444
|
-
sendTo(client, { type: "user-messages", sessionId, messages });
|
|
56629
|
+
sendTo(client, { type: "user-messages", sessionId: sessionId2, messages });
|
|
56445
56630
|
}
|
|
56446
56631
|
|
|
56447
56632
|
// src/commands/sessions/daemon/lifecycleHandlers.ts
|
|
@@ -56450,9 +56635,9 @@ async function handleHistory(client, manager) {
|
|
|
56450
56635
|
sendTo(client, { type: "history", sessions: await collectHistory(linked) });
|
|
56451
56636
|
}
|
|
56452
56637
|
function handleFetchTranscript(client, _manager, data) {
|
|
56453
|
-
const
|
|
56454
|
-
parseTranscript(
|
|
56455
|
-
(messages) => sendTo(client, { type: "transcript", sessionId, messages })
|
|
56638
|
+
const sessionId2 = data.sessionId;
|
|
56639
|
+
parseTranscript(sessionId2).then(
|
|
56640
|
+
(messages) => sendTo(client, { type: "transcript", sessionId: sessionId2, messages })
|
|
56456
56641
|
);
|
|
56457
56642
|
}
|
|
56458
56643
|
async function handleShutdown(client, manager) {
|
|
@@ -56490,28 +56675,28 @@ function pinNotificationTarget(viewerNode, localNode, peerFor) {
|
|
|
56490
56675
|
// src/commands/sessions/daemon/pins/handleNotifyPin.ts
|
|
56491
56676
|
var DELIVERY_TIMEOUT_MS = 5e3;
|
|
56492
56677
|
var handleNotifyPin = (client, m, d) => {
|
|
56493
|
-
const { sessionId, requestId, area } = d;
|
|
56678
|
+
const { sessionId: sessionId2, requestId, area } = d;
|
|
56494
56679
|
const reply2 = (node) => sendTo(client, { type: "notify-pin-result", requestId, node });
|
|
56495
56680
|
const target = pinNotificationTarget(
|
|
56496
|
-
m.localSessions().find((s) => s.id ===
|
|
56681
|
+
m.localSessions().find((s) => s.id === sessionId2)?.activeViewerNode,
|
|
56497
56682
|
m.links.localNode(),
|
|
56498
56683
|
(node) => m.clients.peerFor(node)
|
|
56499
56684
|
);
|
|
56500
56685
|
if (target.kind === "local") {
|
|
56501
56686
|
daemonLog(
|
|
56502
|
-
`notify-pin: session ${
|
|
56687
|
+
`notify-pin: session ${sessionId2} ${target.reason}; ${area} PIN notifies locally`
|
|
56503
56688
|
);
|
|
56504
56689
|
return reply2();
|
|
56505
56690
|
}
|
|
56506
56691
|
daemonLog(
|
|
56507
|
-
`notify-pin: session ${
|
|
56692
|
+
`notify-pin: session ${sessionId2} relaying ${area} PIN notification to ${target.node}`
|
|
56508
56693
|
);
|
|
56509
56694
|
m.links.pins.awaitDelivery(
|
|
56510
56695
|
String(requestId),
|
|
56511
56696
|
DELIVERY_TIMEOUT_MS,
|
|
56512
56697
|
(delivered) => {
|
|
56513
56698
|
daemonLog(
|
|
56514
|
-
`notify-pin: session ${
|
|
56699
|
+
`notify-pin: session ${sessionId2} ${area} PIN ${delivered ? `shown on ${target.node}` : `not shown on ${target.node}; notifying locally`}`
|
|
56515
56700
|
);
|
|
56516
56701
|
reply2(delivered ? target.node : void 0);
|
|
56517
56702
|
}
|
|
@@ -56535,17 +56720,17 @@ var pinHandlers = {
|
|
|
56535
56720
|
|
|
56536
56721
|
// src/commands/sessions/daemon/handleSnapshotRequest.ts
|
|
56537
56722
|
var handleSnapshotRequest = (client, m, d) => {
|
|
56538
|
-
const
|
|
56723
|
+
const sessionId2 = d.sessionId;
|
|
56539
56724
|
let data;
|
|
56540
56725
|
m.update((sessions) => {
|
|
56541
|
-
const s = sessions.get(
|
|
56726
|
+
const s = sessions.get(sessionId2);
|
|
56542
56727
|
if (s) data = sessionSnapshot(s);
|
|
56543
56728
|
return false;
|
|
56544
56729
|
});
|
|
56545
56730
|
daemonLog(
|
|
56546
|
-
`snapshot requested: id=${
|
|
56731
|
+
`snapshot requested: id=${sessionId2} ${data === void 0 ? "not local" : `${data.length} chars`}`
|
|
56547
56732
|
);
|
|
56548
|
-
if (data !== void 0) sendTo(client, { type: "snapshot", sessionId, data });
|
|
56733
|
+
if (data !== void 0) sendTo(client, { type: "snapshot", sessionId: sessionId2, data });
|
|
56549
56734
|
};
|
|
56550
56735
|
|
|
56551
56736
|
// src/commands/sessions/daemon/viewed.ts
|
|
@@ -56569,15 +56754,15 @@ var viewerHandlers = {
|
|
|
56569
56754
|
),
|
|
56570
56755
|
resize: viewed(
|
|
56571
56756
|
routed((client, m, d) => {
|
|
56572
|
-
const
|
|
56757
|
+
const sessionId2 = d.sessionId;
|
|
56573
56758
|
const claim = d.claim === true;
|
|
56574
56759
|
const refresh = d.refresh === true;
|
|
56575
56760
|
const localViewer = d.viewerNode === m.links.localNode();
|
|
56576
|
-
m.io.resize(
|
|
56761
|
+
m.io.resize(sessionId2, d.cols, d.rows, {
|
|
56577
56762
|
...viewerOf(d),
|
|
56578
56763
|
claim,
|
|
56579
56764
|
refresh,
|
|
56580
|
-
sendSnapshot: localViewer ? (data) => sendTo(client, { type: "snapshot", sessionId, data }) : void 0
|
|
56765
|
+
sendSnapshot: localViewer ? (data) => sendTo(client, { type: "snapshot", sessionId: sessionId2, data }) : void 0
|
|
56581
56766
|
});
|
|
56582
56767
|
})
|
|
56583
56768
|
),
|
|
@@ -56999,7 +57184,7 @@ function handleConnection(socket, manager) {
|
|
|
56999
57184
|
import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync62 } from "fs";
|
|
57000
57185
|
|
|
57001
57186
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
57002
|
-
import { readFileSync as
|
|
57187
|
+
import { readFileSync as readFileSync77 } from "fs";
|
|
57003
57188
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
57004
57189
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
57005
57190
|
const timer = setInterval(() => {
|
|
@@ -57010,7 +57195,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
57010
57195
|
}
|
|
57011
57196
|
function ownsPidFile() {
|
|
57012
57197
|
try {
|
|
57013
|
-
return
|
|
57198
|
+
return readFileSync77(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
57014
57199
|
} catch {
|
|
57015
57200
|
return false;
|
|
57016
57201
|
}
|
|
@@ -57157,12 +57342,12 @@ async function closeSession2() {
|
|
|
57157
57342
|
console.log("No daemon-managed session to close.");
|
|
57158
57343
|
return;
|
|
57159
57344
|
}
|
|
57160
|
-
const
|
|
57345
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
57161
57346
|
try {
|
|
57162
|
-
await sendToDaemon({ type: "dismiss", sessionId, closeServerRuns: true });
|
|
57347
|
+
await sendToDaemon({ type: "dismiss", sessionId: sessionId2, closeServerRuns: true });
|
|
57163
57348
|
} catch (error) {
|
|
57164
57349
|
appendDaemonLog(
|
|
57165
|
-
`close send failed: id=${
|
|
57350
|
+
`close send failed: id=${sessionId2}: ${error instanceof Error ? error.message : String(error)}`
|
|
57166
57351
|
);
|
|
57167
57352
|
}
|
|
57168
57353
|
}
|
|
@@ -57524,7 +57709,7 @@ function withTimeout(promise, ms, what) {
|
|
|
57524
57709
|
}
|
|
57525
57710
|
async function updateOverLink(name, action) {
|
|
57526
57711
|
try {
|
|
57527
|
-
const
|
|
57712
|
+
const sessionId2 = await withTimeout(
|
|
57528
57713
|
requestSession({
|
|
57529
57714
|
type: "create-assist",
|
|
57530
57715
|
assistArgs: ["update"],
|
|
@@ -57533,7 +57718,7 @@ async function updateOverLink(name, action) {
|
|
|
57533
57718
|
CREATE_TIMEOUT_MS,
|
|
57534
57719
|
"create-assist"
|
|
57535
57720
|
);
|
|
57536
|
-
console.log(`Running assist update on ${name} (session ${
|
|
57721
|
+
console.log(`Running assist update on ${name} (session ${sessionId2})\u2026`);
|
|
57537
57722
|
} catch (error) {
|
|
57538
57723
|
throw await action.fail(`Update ${name} failed`, error);
|
|
57539
57724
|
}
|
|
@@ -57638,9 +57823,9 @@ async function requestSessionOutput(target) {
|
|
|
57638
57823
|
);
|
|
57639
57824
|
socket.write(`${JSON.stringify({ type: "output", ...target })}
|
|
57640
57825
|
`);
|
|
57641
|
-
const { sessionId, scrollback, exited, error } = await reply2;
|
|
57826
|
+
const { sessionId: sessionId2, scrollback, exited, error } = await reply2;
|
|
57642
57827
|
if (scrollback === void 0) throw new Error(error);
|
|
57643
|
-
return { sessionId, scrollback, exited };
|
|
57828
|
+
return { sessionId: sessionId2, scrollback, exited };
|
|
57644
57829
|
} finally {
|
|
57645
57830
|
socket.destroy();
|
|
57646
57831
|
}
|
|
@@ -57654,8 +57839,8 @@ function lastLines(scrollback, count11) {
|
|
|
57654
57839
|
}
|
|
57655
57840
|
|
|
57656
57841
|
// src/commands/sessions/sessionOutput.ts
|
|
57657
|
-
function resolveTarget4(
|
|
57658
|
-
if (
|
|
57842
|
+
function resolveTarget4(sessionId2, server) {
|
|
57843
|
+
if (sessionId2 && server)
|
|
57659
57844
|
return "Pass either a session id or --server, not both";
|
|
57660
57845
|
if (server)
|
|
57661
57846
|
return {
|
|
@@ -57664,16 +57849,16 @@ function resolveTarget4(sessionId, server) {
|
|
|
57664
57849
|
group: server === true ? "default" : server
|
|
57665
57850
|
}
|
|
57666
57851
|
};
|
|
57667
|
-
if (!
|
|
57668
|
-
if (
|
|
57669
|
-
return `Session ${
|
|
57670
|
-
return { sessionId };
|
|
57852
|
+
if (!sessionId2) return "Pass a session id or --server [group]";
|
|
57853
|
+
if (sessionId2.includes(":"))
|
|
57854
|
+
return `Session ${sessionId2} is on a linked node; reading linked-node sessions is not supported yet`;
|
|
57855
|
+
return { sessionId: sessionId2 };
|
|
57671
57856
|
}
|
|
57672
|
-
async function sessionOutput(
|
|
57857
|
+
async function sessionOutput(sessionId2, options2) {
|
|
57673
57858
|
const count11 = Number.parseInt(options2.lines, 10);
|
|
57674
57859
|
if (!Number.isInteger(count11) || count11 < 1)
|
|
57675
57860
|
return fail12(`-n must be a positive integer, got ${options2.lines}`);
|
|
57676
|
-
const target = resolveTarget4(
|
|
57861
|
+
const target = resolveTarget4(sessionId2, options2.server);
|
|
57677
57862
|
if (typeof target === "string") return fail12(target);
|
|
57678
57863
|
try {
|
|
57679
57864
|
const {
|
|
@@ -57732,12 +57917,12 @@ async function renameSession(title) {
|
|
|
57732
57917
|
console.log("No daemon-managed session to rename.");
|
|
57733
57918
|
return;
|
|
57734
57919
|
}
|
|
57735
|
-
const
|
|
57920
|
+
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
57736
57921
|
try {
|
|
57737
|
-
await sendToDaemon({ type: "rename", sessionId, title });
|
|
57922
|
+
await sendToDaemon({ type: "rename", sessionId: sessionId2, title });
|
|
57738
57923
|
} catch (error) {
|
|
57739
57924
|
appendDaemonLog(
|
|
57740
|
-
`rename send failed: id=${
|
|
57925
|
+
`rename send failed: id=${sessionId2}: ${error instanceof Error ? error.message : String(error)}`
|
|
57741
57926
|
);
|
|
57742
57927
|
}
|
|
57743
57928
|
}
|