@staff0rd/assist 0.1046.1 → 0.1048.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.1046.1",
9
+ version: "0.1048.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(sessionId) {
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, sessionId);
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, sessionId) {
4854
- const transcriptPath2 = findTranscriptPathSync(cwd, sessionId);
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, sessionId) {
4875
- const key = `${cwd} ${sessionId}`;
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, sessionId).then((value) => {
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, sessionId) {
4888
- const itemCommitRefs = await itemCommits(sessionId);
4889
- const commits2 = itemCommitRefs.length > 0 ? itemCommitRefs : await transcriptCommits(cwd, sessionId);
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, sessionId) {
4912
- if (!sessionId || !includesCommittedChanges(cwd)) return [];
4913
- return (await committedPaths(cwd, sessionId)).commits;
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, sessionId, scope) {
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, sessionId);
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, sessionId) {
4931
- if (!sessionId || !includesCommittedChanges(cwd)) return void 0;
4932
- const { commits: commits2, bases } = await committedPaths(cwd, sessionId);
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, sessionId) {
5037
+ async function scopeCommits(cwd, sessionId2) {
5037
5038
  try {
5038
- return await itemScopeCommits(cwd, sessionId);
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, sessionId) => {
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(sessionId);
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 sessionId = await launch(planned);
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 sessionId = process.env.ASSIST_SESSION_ID;
7870
- if (!sessionId) return;
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(sessionId = process.env.ASSIST_SESSION_ID) {
7895
- if (!sessionId) return void 0;
7896
- return join20(homedir9(), ".assist", "signals", `signal-${sessionId}.json`);
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 sessionId = "";
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
- sessionId ||= strField(entry, "sessionId");
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: sessionId, createdAt } = session;
8409
- if (byId.has(sessionId)) continue;
8410
- byId.set(sessionId, { sessionId, ...createdAt && { createdAt } });
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 sessionId = process.env.ASSIST_SESSION_ID;
14883
- if (!sessionId) return () => {
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 sessionId = process.env.ASSIST_SESSION_ID;
16167
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) {
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(sessionId) {
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 sessionId = process.env.ASSIST_SESSION_ID;
16324
- if (process.env.ASSIST_SESSION !== "1" || !sessionId)
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(sessionId))
16334
+ if (!await isLiveDaemonSession(sessionId2))
16329
16335
  askInChat(
16330
- `session ${sessionId} is not live in the assist daemon, so no preview pane can show the check`
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 sessionId = process.env.ASSIST_SESSION_ID;
16375
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) return void 0;
16376
- return await isLiveDaemonSession(sessionId) ? sessionId : void 0;
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 sessionId = await designReviewSessionId();
16402
- if (!sessionId) {
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 sessionId = process.env.ASSIST_SESSION_ID;
16502
- if (process.env.ASSIST_SESSION !== "1" || !sessionId)
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(sessionId))
16512
+ if (!await isLiveDaemonSession(sessionId2))
16507
16513
  useBuiltIn(
16508
- `session ${sessionId} is not live in the assist daemon, so no preview pane can show the form`
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(sessionId, projectsRoot = claudeProjectsRoot()) {
17079
- const filePath = findTranscriptFile(sessionId, projectsRoot);
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(sessionId, projectsRoot) {
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, `${sessionId}.jsonl`);
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 sessionId = process.env.ASSIST_SESSION_ID;
17927
- if (!isClaudeCode() || process.env.ASSIST_SESSION !== "1" || !sessionId)
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, sessionId, confirmed, revises) {
18139
+ async function reviewProposal(item, sessionId2, confirmed, revises) {
18134
18140
  const body = renderProposedItem(item);
18135
- if (sessionId) {
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(sessionId) {
18310
- return join49(homedir14(), ".assist", "proposals", `session-${sessionId}.json`);
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(sessionId) {
18316
- const path109 = proposalLedgerPath(sessionId);
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 sessionId = process.env.ASSIST_SESSION === "1" ? process.env.ASSIST_SESSION_ID : void 0;
18349
- if (sessionId && options2.confirmed) {
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 = sessionId ? trackProposal(sessionId) : void 0;
18365
+ const tracker = sessionId2 ? trackProposal(sessionId2) : void 0;
18360
18366
  try {
18361
18367
  const approval = await reviewProposal(
18362
18368
  item,
18363
- sessionId,
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 sessionId = process.env.ASSIST_SESSION_ID;
19419
- logHookFired(status2, sessionId, opts.source);
19420
- if (!sessionId) return;
19424
+ const sessionId2 = process.env.ASSIST_SESSION_ID;
19425
+ logHookFired(status2, sessionId2, opts.source);
19426
+ if (!sessionId2) return;
19421
19427
  const payload = buildPayload(
19422
- sessionId,
19428
+ sessionId2,
19423
19429
  status2,
19424
19430
  opts.source,
19425
19431
  await readHookClaudeSessionId()
19426
19432
  );
19427
- await deliver(sessionId, status2, payload, opts.ack ? RELIABLE_ATTEMPTS : 1);
19433
+ await deliver(sessionId2, status2, payload, opts.ack ? RELIABLE_ATTEMPTS : 1);
19428
19434
  }
19429
- function buildPayload(sessionId, status2, source, claudeSessionId) {
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(sessionId, status2, payload, attempts) {
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=${sessionId} status=${status2}${payload.source ? ` source=${payload.source}` : ""}: ${describeError(error)}`
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, sessionId, source) {
19468
+ function logHookFired(status2, sessionId2, source) {
19463
19469
  appendDaemonLog(
19464
- `set-status hook fired: id=${sessionId ?? "none"} status=${status2}${source ? ` source=${source}` : ""}`
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(sessionId) {
19771
- return join52(homedir17(), ".assist", "activity", `activity-${sessionId}.json`);
19776
+ function activityPath(sessionId2) {
19777
+ return join52(homedir17(), ".assist", "activity", `activity-${sessionId2}.json`);
19772
19778
  }
19773
19779
  function emitActivity(activity2) {
19774
- const sessionId = process.env.ASSIST_ACTIVITY_ID;
19775
- if (!sessionId) return;
19776
- const path109 = activityPath(sessionId);
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(sessionId, activity2) {
19793
+ function reconcileActivity(sessionId2, activity2) {
19788
19794
  if (!activity2) {
19789
- removeActivity(sessionId);
19795
+ removeActivity(sessionId2);
19790
19796
  return;
19791
19797
  }
19792
- const path109 = activityPath(sessionId);
19798
+ const path109 = activityPath(sessionId2);
19793
19799
  mkdirSync14(dirname28(path109), { recursive: true });
19794
19800
  writeFileSync23(path109, JSON.stringify(activity2));
19795
19801
  }
19796
- function writeActivityIfAbsent(sessionId, activity2) {
19797
- const path109 = activityPath(sessionId);
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(sessionId) {
19813
+ function removeActivity(sessionId2) {
19808
19814
  try {
19809
- rmSync4(activityPath(sessionId));
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(sessionId) {
19852
+ async function findSessionJsonlPath(sessionId2) {
19847
19853
  const paths = await discoverSessionJsonlPaths();
19848
19854
  const direct = paths.find(
19849
- (p) => path29.basename(p.path, ".jsonl") === sessionId
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 === sessionId) return p.path;
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 sessionId = process.env.ASSIST_SESSION_ID;
21334
- if (process.env.ASSIST_SESSION === "1" && sessionId) {
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 sessionId = process.env.ASSIST_SESSION_ID;
23625
- if (!sessionId) return void 0;
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 sessionId = process.env.ASSIST_SESSION_ID;
23752
- if (!sessionId || !transcriptPath2 || !USAGE_EVENTS.has(event)) return;
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=${sessionId}: ${error instanceof Error ? error.message : String(error)}`
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 sessionId = process.env.ASSIST_SESSION_ID;
29415
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
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 sessionId = process.env.ASSIST_SESSION_ID;
29939
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) return void 0;
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 sessionId = process.env.ASSIST_SESSION_ID;
30245
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) return body;
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 sessionId = process.env.ASSIST_SESSION_ID;
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=${sessionId}: ${error instanceof Error ? error.message : String(error)}`
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 sessionId = process.env.ASSIST_SESSION_ID;
32094
- if (process.env.ASSIST_SESSION !== "1" || !sessionId)
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(sessionId, items2) {
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 sessionId = process.env.ASSIST_SESSION_ID;
33609
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
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 sessionId = process.env.ASSIST_SESSION_ID;
34759
- if (process.env.ASSIST_SESSION === "1" && sessionId) {
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 sessionId = process.env.ASSIST_SESSION_ID;
35110
- if (process.env.ASSIST_SESSION === "1" && sessionId) {
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/capPatchToBudget.ts
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 minimatch7 } from "minimatch";
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) => minimatch7(file, 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 execFileSync28 } from "child_process";
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 = execFileSync28(
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,49 @@ function highLevelReviewPath(repo, headRef, headSha) {
40619
40418
  );
40620
40419
  }
40621
40420
 
40622
- // src/commands/review/highLevel/highLevelDraftPath.ts
40623
- function highLevelDraftPath(repo, headRef, headSha) {
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
- ".draft.json"
40425
+ ".slices.json"
40627
40426
  );
40628
40427
  }
40629
40428
 
40429
+ // src/commands/review/highLevel/countHunkLines.ts
40430
+ function countHunkLines(text20, prefix2) {
40431
+ return text20.split("\n").filter((line) => line.startsWith(prefix2)).length;
40432
+ }
40433
+
40434
+ // src/commands/review/highLevel/hunkTextsOf.ts
40435
+ function hunkTextsOf(patch2) {
40436
+ return hunksOf(patch2 ?? "").filter((text20) => text20.startsWith("@@"));
40437
+ }
40438
+
40439
+ // src/commands/review/highLevel/listHighLevelHunks.ts
40440
+ function hunksOfFile(file) {
40441
+ const texts = hunkTextsOf(file.patch);
40442
+ if (texts.length === 0)
40443
+ return [
40444
+ {
40445
+ ref: `${file.path}#0`,
40446
+ path: file.path,
40447
+ text: `(no patch shown: binary, too large or over the review budget; ${file.status}, +${file.additions} \u2212${file.deletions})`,
40448
+ additions: file.additions,
40449
+ deletions: file.deletions
40450
+ }
40451
+ ];
40452
+ return texts.map((text20, index3) => ({
40453
+ ref: `${file.path}#${index3}`,
40454
+ path: file.path,
40455
+ text: text20,
40456
+ additions: countHunkLines(text20, "+"),
40457
+ deletions: countHunkLines(text20, "-")
40458
+ }));
40459
+ }
40460
+ function listHighLevelHunks(files) {
40461
+ return files.flatMap(hunksOfFile);
40462
+ }
40463
+
40630
40464
  // src/commands/review/highLevel/readJsonFile.ts
40631
40465
  import { existsSync as existsSync68, readFileSync as readFileSync53 } from "fs";
40632
40466
  function readJsonFile(path109) {
@@ -40638,6 +40472,358 @@ function readJsonFile(path109) {
40638
40472
  }
40639
40473
  }
40640
40474
 
40475
+ // src/commands/review/highLevel/parseHighLevelSlicesInput.ts
40476
+ import { z as z20 } from "zod";
40477
+ var slicesInputSchema = z20.array(
40478
+ z20.object({
40479
+ title: z20.string().min(1),
40480
+ summary: z20.string(),
40481
+ hunks: z20.array(z20.string())
40482
+ })
40483
+ );
40484
+ function parseHighLevelSlicesInput(raw) {
40485
+ const parsed = slicesInputSchema.safeParse(raw);
40486
+ if (!parsed.success)
40487
+ throw new Error(
40488
+ `slices must be a JSON array of {title, summary, hunks[]}: ${parsed.error.message}`
40489
+ );
40490
+ return parsed.data;
40491
+ }
40492
+
40493
+ // src/commands/review/highLevel/sliceTotals.ts
40494
+ function sliceTotals(refs, byRef) {
40495
+ let additions = 0;
40496
+ let deletions = 0;
40497
+ for (const ref of refs) {
40498
+ const hunk = byRef.get(ref);
40499
+ additions += hunk?.additions ?? 0;
40500
+ deletions += hunk?.deletions ?? 0;
40501
+ }
40502
+ return { additions, deletions };
40503
+ }
40504
+
40505
+ // src/commands/review/highLevel/resolveHighLevelSlices.ts
40506
+ function knownRefs(input, byRef, warnings) {
40507
+ return [...new Set(input.hunks)].filter((ref) => {
40508
+ if (byRef.has(ref)) return true;
40509
+ warnings.push(`Dropped unknown hunk ${ref} from "${input.title}".`);
40510
+ return false;
40511
+ });
40512
+ }
40513
+ function resolveHighLevelSlices(raw, hunks) {
40514
+ const byRef = new Map(hunks.map((hunk) => [hunk.ref, hunk]));
40515
+ const claimed = /* @__PURE__ */ new Set();
40516
+ const warnings = [];
40517
+ const slices = [];
40518
+ const add5 = (title, summary, refs) => slices.push({ title, summary, hunks: refs, ...sliceTotals(refs, byRef) });
40519
+ for (const input of parseHighLevelSlicesInput(raw)) {
40520
+ const known = knownRefs(input, byRef, warnings);
40521
+ if (known.length === 0)
40522
+ warnings.push(`Dropped slice "${input.title}": it has no known hunks.`);
40523
+ else add5(input.title, input.summary, known);
40524
+ for (const ref of known) claimed.add(ref);
40525
+ }
40526
+ const rest = [...byRef.keys()].filter((ref) => !claimed.has(ref));
40527
+ if (rest.length > 0) add5("Everything else", "Hunks no slice claimed.", rest);
40528
+ return { slices, warnings };
40529
+ }
40530
+
40531
+ // src/commands/review/highLevel/writeJsonFile.ts
40532
+ import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync42 } from "fs";
40533
+ import { dirname as dirname42 } from "path";
40534
+ function writeJsonFile(path109, data) {
40535
+ mkdirSync28(dirname42(path109), { recursive: true });
40536
+ writeFileSync42(path109, `${JSON.stringify(data, null, 2)}
40537
+ `);
40538
+ return path109;
40539
+ }
40540
+
40541
+ // src/commands/review/highLevel/gatherHighLevelSlices.ts
40542
+ function readSlicesFile(file) {
40543
+ try {
40544
+ return JSON.parse(readFileSync54(file, "utf8"));
40545
+ } catch (error) {
40546
+ throw new Error(
40547
+ `could not read slices from ${file}: ${error instanceof Error ? error.message : String(error)}`
40548
+ );
40549
+ }
40550
+ }
40551
+ function sliceFromFile(file, files, path109) {
40552
+ const { slices, warnings } = resolveHighLevelSlices(
40553
+ readSlicesFile(file),
40554
+ listHighLevelHunks(files)
40555
+ );
40556
+ for (const warning of warnings) console.warn(`Warning: ${warning}`);
40557
+ writeJsonFile(path109, slices);
40558
+ return slices;
40559
+ }
40560
+ function gatherHighLevelSlices(head, files, slicing) {
40561
+ const path109 = highLevelSlicesPath(head.repo, head.headRef, head.headSha);
40562
+ if (slicing.slicesFile) return sliceFromFile(slicing.slicesFile, files, path109);
40563
+ const saved = slicing.force ? void 0 : readJsonFile(path109);
40564
+ if (saved) return saved;
40565
+ console.log(formatSlicingRequest(listHighLevelHunks(files)));
40566
+ process.exit(2);
40567
+ }
40568
+
40569
+ // src/commands/review/highLevel/testChangeExcerpts.ts
40570
+ var CONTEXT_LINES = 3;
40571
+ function testChangeExcerpts(source, line, changedLines2) {
40572
+ const lines2 = source.split("\n");
40573
+ const windows = [];
40574
+ for (const changed of [...changedLines2].sort((a, b) => a - b)) {
40575
+ const start2 = Math.max(0, changed - line - CONTEXT_LINES);
40576
+ const end = Math.min(lines2.length - 1, changed - line + CONTEXT_LINES);
40577
+ const last = windows.at(-1);
40578
+ if (last && start2 <= last.end + 1) last.end = Math.max(last.end, end);
40579
+ else windows.push({ start: start2, end });
40580
+ }
40581
+ return windows.map(({ start: start2, end }) => ({
40582
+ line: line + start2,
40583
+ source: lines2.slice(start2, end + 1).join("\n")
40584
+ }));
40585
+ }
40586
+
40587
+ // src/commands/review/highLevel/shownForm.ts
40588
+ var MAX_TEST_SOURCE_LINES = 200;
40589
+ function shownForm(test) {
40590
+ const { source, changedLines: changedLines2, ...rest } = test;
40591
+ if (source === void 0) return void 0;
40592
+ const lines2 = lineCount(source);
40593
+ if (lines2 <= MAX_TEST_SOURCE_LINES)
40594
+ return { lines: lines2, shown: { ...rest, source } };
40595
+ if (!changedLines2) return void 0;
40596
+ const excerpts = testChangeExcerpts(source, test.line, changedLines2);
40597
+ const excerptLines = excerpts.reduce(
40598
+ (sum3, excerpt2) => sum3 + lineCount(excerpt2.source),
40599
+ 0
40600
+ );
40601
+ return excerptLines <= MAX_TEST_SOURCE_LINES ? { lines: excerptLines, shown: { ...rest, excerpts } } : void 0;
40602
+ }
40603
+ function lineCount(text20) {
40604
+ return text20.split("\n").length;
40605
+ }
40606
+
40607
+ // src/commands/review/highLevel/capHighLevelTestSources.ts
40608
+ var MAX_TOTAL_SOURCE_LINES = 5e3;
40609
+ function collectCases(nodes) {
40610
+ return nodes.flatMap(
40611
+ (node) => node.kind === "it" ? [node] : collectCases(node.children)
40612
+ );
40613
+ }
40614
+ function shippedForms(files) {
40615
+ const sized = files.flatMap((file) => collectCases(file.tests)).flatMap((test) => {
40616
+ const form = shownForm(test);
40617
+ return form ? [{ test, form }] : [];
40618
+ }).sort((a, b) => a.form.lines - b.form.lines);
40619
+ const shipped = /* @__PURE__ */ new Map();
40620
+ let remaining = MAX_TOTAL_SOURCE_LINES;
40621
+ for (const { test, form } of sized) {
40622
+ if (form.lines > remaining) break;
40623
+ remaining -= form.lines;
40624
+ shipped.set(test, form);
40625
+ }
40626
+ return shipped;
40627
+ }
40628
+ function capHighLevelTestSources(files) {
40629
+ const shipped = shippedForms(files);
40630
+ const capCase = (test) => {
40631
+ const form = shipped.get(test);
40632
+ if (form) return form.shown;
40633
+ const { source, changedLines: _changedLines, ...rest } = test;
40634
+ if (source === void 0) return rest;
40635
+ return shownForm(test) ? { ...rest, overBudget: true } : { ...rest, truncated: true };
40636
+ };
40637
+ const capNode = (node) => node.kind === "it" ? capCase(node) : { ...node, children: node.children.map(capNode) };
40638
+ return files.map((file) => ({ ...file, tests: file.tests.map(capNode) }));
40639
+ }
40640
+
40641
+ // src/commands/review/highLevel/collectHighLevelTests.ts
40642
+ import { minimatch as minimatch7 } from "minimatch";
40643
+
40644
+ // src/commands/review/highLevel/extractTestHierarchy.ts
40645
+ import { Node as Node4, Project as Project5 } from "ts-morph";
40646
+
40647
+ // src/commands/review/highLevel/classifyTestCall.ts
40648
+ import { Node as Node2 } from "ts-morph";
40649
+ var SUITE_ROOTS = /* @__PURE__ */ new Set(["describe", "context", "suite"]);
40650
+ var CASE_ROOTS = /* @__PURE__ */ new Set(["it", "test", "specify"]);
40651
+ function calleeChain(expression) {
40652
+ if (Node2.isIdentifier(expression)) return [expression.getText()];
40653
+ if (Node2.isPropertyAccessExpression(expression))
40654
+ return [...calleeChain(expression.getExpression()), expression.getName()];
40655
+ if (Node2.isCallExpression(expression))
40656
+ return calleeChain(expression.getExpression());
40657
+ return [];
40658
+ }
40659
+ function hasName(call) {
40660
+ const [first] = call.getArguments();
40661
+ return first !== void 0 && !Node2.isFunctionLikeDeclaration(first) && !Node2.isObjectLiteralExpression(first);
40662
+ }
40663
+ function classifyTestCall(call) {
40664
+ const [root2, ...rest] = calleeChain(call.getExpression());
40665
+ if (root2 === void 0 || !hasName(call)) return void 0;
40666
+ if (SUITE_ROOTS.has(root2) || rest.includes("describe")) return "describe";
40667
+ if (CASE_ROOTS.has(root2)) return "it";
40668
+ return void 0;
40669
+ }
40670
+
40671
+ // src/commands/review/highLevel/testName.ts
40672
+ import { Node as Node3 } from "ts-morph";
40673
+ function testName(call) {
40674
+ const [first] = call.getArguments();
40675
+ if (Node3.isStringLiteral(first) || Node3.isNoSubstitutionTemplateLiteral(first))
40676
+ return first.getLiteralValue();
40677
+ if (Node3.isTemplateExpression(first)) return first.getText().slice(1, -1);
40678
+ return first?.getText() ?? "";
40679
+ }
40680
+
40681
+ // src/commands/review/highLevel/dedentedSource.ts
40682
+ function dedentedSource(call) {
40683
+ const text20 = call.getSourceFile().getFullText();
40684
+ const lineStart = text20.lastIndexOf("\n", call.getStart()) + 1;
40685
+ const indent4 = /^\s*/.exec(text20.slice(lineStart, call.getStart()))?.[0] ?? "";
40686
+ return call.getText().split("\n").map((line) => line.startsWith(indent4) ? line.slice(indent4.length) : line).join("\n");
40687
+ }
40688
+
40689
+ // src/commands/review/highLevel/visitCase.ts
40690
+ function visitCase(call, context) {
40691
+ if (!context.changed) return [toCase(call, context)];
40692
+ const lines2 = changedLines(call, context.changed);
40693
+ if (lines2.length === 0) return [];
40694
+ const total3 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
40695
+ return [
40696
+ toCase(
40697
+ call,
40698
+ context,
40699
+ lines2.length === total3 ? { change: "added" } : { change: "modified", changedLines: lines2 }
40700
+ )
40701
+ ];
40702
+ }
40703
+ function toCase(call, context, change = {}) {
40704
+ const line = call.getStartLineNumber();
40705
+ return {
40706
+ kind: "it",
40707
+ id: `${context.path}:${line}`,
40708
+ name: testName(call),
40709
+ line,
40710
+ ...change,
40711
+ source: dedentedSource(call)
40712
+ };
40713
+ }
40714
+ function changedLines(call, changed) {
40715
+ const lines2 = [];
40716
+ for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
40717
+ if (changed.has(line)) lines2.push(line);
40718
+ return lines2;
40719
+ }
40720
+
40721
+ // src/commands/review/highLevel/extractTestHierarchy.ts
40722
+ function collect7(node, context) {
40723
+ const found = [];
40724
+ node.forEachChild((child) => {
40725
+ found.push(...visit(child, context));
40726
+ });
40727
+ return found;
40728
+ }
40729
+ function visit(node, context) {
40730
+ if (!Node4.isCallExpression(node)) return collect7(node, context);
40731
+ const kind = classifyTestCall(node);
40732
+ if (kind === "it") return visitCase(node, context);
40733
+ if (kind === void 0) return collect7(node, context);
40734
+ const children = node.getArguments().slice(1).flatMap((argument) => visit(argument, context));
40735
+ if (children.length === 0) return [];
40736
+ return [
40737
+ {
40738
+ kind: "describe",
40739
+ name: testName(node),
40740
+ line: node.getStartLineNumber(),
40741
+ children
40742
+ }
40743
+ ];
40744
+ }
40745
+ function extractTestHierarchy(path109, text20, changed) {
40746
+ const project = new Project5({
40747
+ useInMemoryFileSystem: true,
40748
+ compilerOptions: { allowJs: true }
40749
+ });
40750
+ const source = project.createSourceFile(`/${path109}`, text20);
40751
+ return collect7(source, { path: path109, ...changed ? { changed } : {} });
40752
+ }
40753
+
40754
+ // src/commands/review/highLevel/patchAddedLines.ts
40755
+ var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)/;
40756
+ function patchAddedLines(patch2) {
40757
+ const added = /* @__PURE__ */ new Set();
40758
+ let next3 = 0;
40759
+ for (const line of patch2.split("\n")) {
40760
+ const header = HUNK_HEADER.exec(line);
40761
+ if (header) next3 = Number(header[1]);
40762
+ else if (line.startsWith("+")) added.add(next3++);
40763
+ else if (!line.startsWith("-") && !line.startsWith("\\")) next3++;
40764
+ }
40765
+ return added;
40766
+ }
40767
+
40768
+ // src/commands/review/highLevel/collectHighLevelTests.ts
40769
+ function testFile(file, readSource4) {
40770
+ const changed = file.patch === void 0 ? void 0 : patchAddedLines(file.patch);
40771
+ const tests = extractTestHierarchy(file.path, readSource4(file.path), changed);
40772
+ if (tests.length === 0) return [];
40773
+ const { path: path109, status: status2, additions, deletions, diffUrl: diffUrl2 } = file;
40774
+ return [{ path: path109, status: status2, additions, deletions, diffUrl: diffUrl2, tests }];
40775
+ }
40776
+ function collectHighLevelTests(files, testPaths, readSource4) {
40777
+ return files.filter(
40778
+ (file) => file.status !== "removed" && testPaths.some((glob) => minimatch7(file.path, glob))
40779
+ ).flatMap((file) => testFile(file, readSource4));
40780
+ }
40781
+
40782
+ // src/commands/review/highLevel/fetchFileAtSha.ts
40783
+ import { execFileSync as execFileSync28 } from "child_process";
40784
+ function fetchFileAtSha(repo, sha, path109) {
40785
+ const encodedPath = path109.split("/").map(encodeURIComponent).join("/");
40786
+ try {
40787
+ return execFileSync28(
40788
+ "gh",
40789
+ [
40790
+ "api",
40791
+ "-H",
40792
+ "Accept: application/vnd.github.raw",
40793
+ `repos/${repo}/contents/${encodedPath}?ref=${sha}`
40794
+ ],
40795
+ {
40796
+ encoding: "utf8",
40797
+ maxBuffer: 64 * 1024 * 1024,
40798
+ stdio: ["ignore", "pipe", "pipe"]
40799
+ }
40800
+ );
40801
+ } catch (error) {
40802
+ throw new Error(
40803
+ `Could not read ${path109} at PR head ${sha.slice(0, 7)}: ${ghFailure(error)}`
40804
+ );
40805
+ }
40806
+ }
40807
+
40808
+ // src/commands/review/highLevel/gatherHighLevelTests.ts
40809
+ function gatherHighLevelTests(files, testPaths, repo, headSha) {
40810
+ return capHighLevelTestSources(
40811
+ collectHighLevelTests(
40812
+ files,
40813
+ testPaths,
40814
+ (path109) => fetchFileAtSha(repo, headSha, path109)
40815
+ )
40816
+ );
40817
+ }
40818
+
40819
+ // src/commands/review/highLevel/highLevelDraftPath.ts
40820
+ function highLevelDraftPath(repo, headRef, headSha) {
40821
+ return highLevelReviewPath(repo, headRef, headSha).replace(
40822
+ /\.json$/,
40823
+ ".draft.json"
40824
+ );
40825
+ }
40826
+
40641
40827
  // src/commands/review/highLevel/loadHighLevelDraft.ts
40642
40828
  function loadHighLevelDraft(repo, headRef, headSha) {
40643
40829
  return readJsonFile(highLevelDraftPath(repo, headRef, headSha));
@@ -40676,39 +40862,31 @@ function selectCriticalDiffs(files, criticalPaths) {
40676
40862
  }
40677
40863
 
40678
40864
  // src/commands/review/highLevel/gatherHighLevelSubject.ts
40679
- function gatherHighLevelSubject(prNumber, force) {
40865
+ function gatherHighLevelSubject(prNumber, force, slicing) {
40680
40866
  const { org, repo } = getRepoInfo();
40681
40867
  const slug2 = `${org}/${repo}`;
40682
40868
  const pr = fetchHighLevelPr(prNumber, { org, repo });
40683
40869
  const config = resolveHighLevelConfig(loadConfig());
40684
40870
  const fetched = fetchHighLevelFiles(prNumber, slug2);
40685
40871
  const files = capHighLevelPatches(fetched, config.criticalPaths);
40872
+ const head = { repo: slug2, headRef: pr.headRef, headSha: pr.headSha };
40873
+ const slices = slicing && config.slices ? gatherHighLevelSlices(head, files, slicing) : void 0;
40686
40874
  return {
40687
- repo: slug2,
40875
+ ...head,
40688
40876
  prNumber,
40689
40877
  title: pr.title,
40690
- headRef: pr.headRef,
40691
- headSha: pr.headSha,
40692
40878
  checks: evaluateHighLevelChecks({
40693
- body: pr.body,
40694
- linkedIssues: pr.linkedIssues,
40695
- mergeable: pr.mergeable,
40696
- baseRef: pr.baseRef,
40879
+ ...pr,
40697
40880
  changedFiles: files.map((file) => file.path),
40698
40881
  config
40699
40882
  }),
40700
40883
  structure: buildHighLevelStructure(files),
40701
40884
  criticalDiffs: selectCriticalDiffs(files, config.criticalPaths),
40702
40885
  criticalPaths: config.criticalPaths,
40703
- tests: capHighLevelTestSources(
40704
- collectHighLevelTests(
40705
- fetched,
40706
- config.testPaths,
40707
- (path109) => fetchFileAtSha(slug2, pr.headSha, path109)
40708
- )
40709
- ),
40886
+ tests: gatherHighLevelTests(fetched, config.testPaths, slug2, pr.headSha),
40710
40887
  testPaths: config.testPaths,
40711
40888
  collapsedPaths: config.collapsedPaths,
40889
+ ...slices ? { slices } : {},
40712
40890
  ...force ? {} : loadReopenedReview(slug2, pr.headRef, pr.headSha)
40713
40891
  };
40714
40892
  }
@@ -40782,16 +40960,6 @@ function clearHighLevelDraft(repo, headRef, headSha) {
40782
40960
  rmSync7(highLevelDraftPath(repo, headRef, headSha), { force: true });
40783
40961
  }
40784
40962
 
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
40963
  // src/commands/review/highLevel/saveHighLevelDraft.ts
40796
40964
  function saveHighLevelDraft(draft) {
40797
40965
  return writeJsonFile(
@@ -40826,6 +40994,7 @@ function highLevelPreviewPayload(subject) {
40826
40994
  tests,
40827
40995
  testPaths,
40828
40996
  collapsedPaths,
40997
+ slices,
40829
40998
  saved,
40830
40999
  draft
40831
41000
  } = subject;
@@ -40840,6 +41009,7 @@ function highLevelPreviewPayload(subject) {
40840
41009
  tests,
40841
41010
  testPaths,
40842
41011
  collapsedPaths,
41012
+ ...slices ? { slices } : {},
40843
41013
  ...saved ? { saved } : {},
40844
41014
  ...draft ? { draft } : {}
40845
41015
  };
@@ -41009,11 +41179,11 @@ function submitHighLevelReview(record) {
41009
41179
  }
41010
41180
 
41011
41181
  // src/commands/review/highLevel/openHighLevelOverlay.ts
41012
- async function openHighLevelOverlay(sessionId, subject) {
41182
+ async function openHighLevelOverlay(sessionId2, subject) {
41013
41183
  const decision = await awaitPreviewApproval(
41014
41184
  "High-level review",
41015
41185
  {
41016
- sessionId,
41186
+ sessionId: sessionId2,
41017
41187
  requestId: randomUUID24(),
41018
41188
  title: `${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`,
41019
41189
  body: JSON.stringify(highLevelPreviewPayload(subject)),
@@ -41217,9 +41387,9 @@ function resolvePrNumber2(number) {
41217
41387
  }
41218
41388
  return parsed;
41219
41389
  }
41220
- function gatherSubject(prNumber, force) {
41390
+ function gatherSubject(prNumber, force, slicing) {
41221
41391
  try {
41222
- return gatherHighLevelSubject(prNumber, force);
41392
+ return gatherHighLevelSubject(prNumber, force, slicing);
41223
41393
  } catch (error) {
41224
41394
  console.error(
41225
41395
  `Error: ${error instanceof Error ? error.message : String(error)}`
@@ -41227,21 +41397,25 @@ function gatherSubject(prNumber, force) {
41227
41397
  process.exit(1);
41228
41398
  }
41229
41399
  }
41400
+ function sessionId() {
41401
+ const id = process.env.ASSIST_SESSION_ID;
41402
+ return process.env.ASSIST_SESSION === "1" && id ? id : void 0;
41403
+ }
41230
41404
  async function runHighLevelReview(number, options2 = {}) {
41231
41405
  const force = options2.force === true;
41232
- const subject = gatherSubject(resolvePrNumber2(number), force);
41406
+ const session = sessionId();
41407
+ const slicing = session ? { force, ...options2.slices ? { slicesFile: options2.slices } : {} } : void 0;
41408
+ const subject = gatherSubject(resolvePrNumber2(number), force, slicing);
41233
41409
  announceSavedReview(subject, force);
41234
- const sessionId = process.env.ASSIST_SESSION_ID;
41235
- if (process.env.ASSIST_SESSION !== "1" || !sessionId)
41236
- return printHighLevelChecklist(subject);
41237
- await openHighLevelOverlay(sessionId, subject);
41410
+ if (!session) return printHighLevelChecklist(subject);
41411
+ await openHighLevelOverlay(session, subject);
41238
41412
  }
41239
41413
 
41240
41414
  // src/commands/review/reviewPr.ts
41241
41415
  import { basename as basename26 } from "path";
41242
41416
 
41243
41417
  // src/commands/review/ci/writeJobSummary.ts
41244
- import { appendFileSync as appendFileSync3, readFileSync as readFileSync54 } from "fs";
41418
+ import { appendFileSync as appendFileSync3, readFileSync as readFileSync55 } from "fs";
41245
41419
 
41246
41420
  // src/commands/review/carriedUnanchoredFindings.ts
41247
41421
  function carriedUnanchoredFindings(unanchored) {
@@ -41623,7 +41797,7 @@ function buildTokenUsageTable(usages) {
41623
41797
  // src/commands/review/ci/writeJobSummary.ts
41624
41798
  function writeJobSummary(synthesisPath, prInfo, summaryPath, slots) {
41625
41799
  if (!summaryPath) return;
41626
- const markdown = readFileSync54(synthesisPath, "utf8");
41800
+ const markdown = readFileSync55(synthesisPath, "utf8");
41627
41801
  const { unanchored } = selectPostableFindings(markdown, prInfo);
41628
41802
  const usageTable = buildTokenUsageTable(slots.map((slot) => slot.usage));
41629
41803
  appendFileSync3(
@@ -42630,7 +42804,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
42630
42804
  import { existsSync as existsSync70, unlinkSync as unlinkSync18 } from "fs";
42631
42805
 
42632
42806
  // src/commands/review/synthesise.ts
42633
- import { readFileSync as readFileSync55 } from "fs";
42807
+ import { readFileSync as readFileSync56 } from "fs";
42634
42808
 
42635
42809
  // src/commands/review/buildSynthesisStdin.ts
42636
42810
  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 +42873,7 @@ Files:
42699
42873
 
42700
42874
  // src/commands/review/synthesise.ts
42701
42875
  function printSummary2(synthesisPath) {
42702
- const markdown = readFileSync55(synthesisPath, "utf8");
42876
+ const markdown = readFileSync56(synthesisPath, "utf8");
42703
42877
  console.log("");
42704
42878
  console.log(buildReviewSummary(markdown));
42705
42879
  console.log("");
@@ -43144,7 +43318,7 @@ function gatherChangedContext() {
43144
43318
  }
43145
43319
 
43146
43320
  // src/commands/review/postReviewToPr.ts
43147
- import { readFileSync as readFileSync56 } from "fs";
43321
+ import { readFileSync as readFileSync57 } from "fs";
43148
43322
 
43149
43323
  // src/commands/review/chainAddressComments.ts
43150
43324
  function chainAddressComments(prNumber, announce) {
@@ -43326,7 +43500,7 @@ async function confirmPost(prNumber, work, options2) {
43326
43500
  return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
43327
43501
  }
43328
43502
  async function postFindingsToPr(prInfo, synthesisPath, options2) {
43329
- const markdown = readFileSync56(synthesisPath, "utf8");
43503
+ const markdown = readFileSync57(synthesisPath, "utf8");
43330
43504
  const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
43331
43505
  const carried = carriedUnanchoredFindings(unanchored);
43332
43506
  if (inDiff.length === 0 && carried.length === 0)
@@ -43556,6 +43730,12 @@ function validateCheckoutOnly(options2) {
43556
43730
  }
43557
43731
  }
43558
43732
  function validateHighLevel(options2) {
43733
+ if (options2.slices && (!options2.highLevel || options2.configure)) {
43734
+ console.error(
43735
+ "Error: --slices requires --high-level and cannot be combined with --configure."
43736
+ );
43737
+ process.exit(1);
43738
+ }
43559
43739
  if (!options2.highLevel) return;
43560
43740
  if (options2.refine || options2.apply || options2.backlog || options2.submit || options2.checkoutOnly) {
43561
43741
  console.error(
@@ -43589,11 +43769,12 @@ async function review(options2 = {}) {
43589
43769
  `/review-high-level ${options2.number}${options2.force ? " --force" : ""}`
43590
43770
  );
43591
43771
  emitActivity({ kind: "command", name: "review" });
43772
+ const highLevelOptions = { force: options2.force, slices: options2.slices };
43592
43773
  if (!options2.number)
43593
- return options2.highLevel ? runHighLevelReview(void 0, { force: options2.force }) : reviewPr(invokedIn, options2);
43774
+ return options2.highLevel ? runHighLevelReview(void 0, highLevelOptions) : reviewPr(invokedIn, options2);
43594
43775
  await checkoutPr(options2.number);
43595
43776
  if (options2.highLevel)
43596
- return runHighLevelReview(options2.number, { force: options2.force });
43777
+ return runHighLevelReview(options2.number, highLevelOptions);
43597
43778
  return reviewPr(resolveRepoRoot(), options2);
43598
43779
  }
43599
43780
 
@@ -43605,6 +43786,9 @@ function addReviewModeOptions(command) {
43605
43786
  ).option(
43606
43787
  "--high-level",
43607
43788
  "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"
43789
+ ).option(
43790
+ "--slices <file>",
43791
+ `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
43792
  ).option(
43609
43793
  "--configure",
43610
43794
  "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 +43864,11 @@ import path88 from "path";
43680
43864
  import chalk261 from "chalk";
43681
43865
 
43682
43866
  // src/commands/rules/updateScopedRulesIndex.ts
43683
- import { existsSync as existsSync72, readFileSync as readFileSync58, writeFileSync as writeFileSync45 } from "fs";
43867
+ import { existsSync as existsSync72, readFileSync as readFileSync59, writeFileSync as writeFileSync45 } from "fs";
43684
43868
  import path87 from "path";
43685
43869
 
43686
43870
  // src/commands/rules/scopedRuleDirectories.ts
43687
- import { readFileSync as readFileSync57 } from "fs";
43871
+ import { readFileSync as readFileSync58 } from "fs";
43688
43872
  import path86 from "path";
43689
43873
 
43690
43874
  // src/commands/rules/findClaudeFiles.ts
@@ -43708,7 +43892,7 @@ function findClaudeFiles(dir) {
43708
43892
  // src/commands/rules/scopedRuleDirectories.ts
43709
43893
  function scopedRuleDirectories(root2) {
43710
43894
  return findClaudeFiles(root2).filter(
43711
- (file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync57(file, "utf8")).length > 0
43895
+ (file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync58(file, "utf8")).length > 0
43712
43896
  ).map(
43713
43897
  (file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
43714
43898
  ).sort();
@@ -43750,7 +43934,7 @@ function upsertScopedRulesPointer(content, directories) {
43750
43934
  function updateScopedRulesIndex(root2) {
43751
43935
  const directories = scopedRuleDirectories(root2);
43752
43936
  const rootFile = path87.join(root2, "CLAUDE.md");
43753
- const before = existsSync72(rootFile) ? readFileSync58(rootFile, "utf8") : "";
43937
+ const before = existsSync72(rootFile) ? readFileSync59(rootFile, "utf8") : "";
43754
43938
  const after = upsertScopedRulesPointer(before, directories);
43755
43939
  if (after !== before) writeFileSync45(rootFile, after);
43756
43940
  return directories;
@@ -43803,7 +43987,7 @@ function listRules(target, options2 = {}) {
43803
43987
  }
43804
43988
 
43805
43989
  // src/commands/rules/addRule.ts
43806
- import { existsSync as existsSync74, readFileSync as readFileSync60, writeFileSync as writeFileSync46 } from "fs";
43990
+ import { existsSync as existsSync74, readFileSync as readFileSync61, writeFileSync as writeFileSync46 } from "fs";
43807
43991
  import path91 from "path";
43808
43992
  import chalk263 from "chalk";
43809
43993
 
@@ -43828,11 +44012,11 @@ function insertRuleBullet(content, rule) {
43828
44012
  }
43829
44013
 
43830
44014
  // src/commands/rules/nextRuleCode.ts
43831
- import { readFileSync as readFileSync59 } from "fs";
44015
+ import { readFileSync as readFileSync60 } from "fs";
43832
44016
  var CODE_PREFIX = "R";
43833
44017
  function nextRuleCode(root2) {
43834
44018
  const numbers = findClaudeFiles(root2).flatMap(
43835
- (file) => parseRulesSection(readFileSync59(file, "utf8")).map(
44019
+ (file) => parseRulesSection(readFileSync60(file, "utf8")).map(
43836
44020
  (rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
43837
44021
  )
43838
44022
  );
@@ -43859,7 +44043,7 @@ function resolveRuleScope(target) {
43859
44043
 
43860
44044
  // src/commands/rules/addRule.ts
43861
44045
  function read2(file) {
43862
- return existsSync74(file) ? readFileSync60(file, "utf8") : "";
44046
+ return existsSync74(file) ? readFileSync61(file, "utf8") : "";
43863
44047
  }
43864
44048
  function addRule(text20, options2) {
43865
44049
  const rule = text20.trim();
@@ -44382,7 +44566,7 @@ function findShownSessionFiles(body, writtenPaths, locations) {
44382
44566
  }
44383
44567
 
44384
44568
  // src/commands/show/sessionWrittenPaths.ts
44385
- import { readFileSync as readFileSync61 } from "fs";
44569
+ import { readFileSync as readFileSync62 } from "fs";
44386
44570
 
44387
44571
  // src/commands/sessions/shared/asRecord.ts
44388
44572
  function asRecord(value) {
@@ -44410,7 +44594,7 @@ function writtenFilePaths(entry) {
44410
44594
  function sessionWrittenPaths(transcriptPath2) {
44411
44595
  let text20;
44412
44596
  try {
44413
- text20 = readFileSync61(transcriptPath2, "utf8");
44597
+ text20 = readFileSync62(transcriptPath2, "utf8");
44414
44598
  } catch {
44415
44599
  return [];
44416
44600
  }
@@ -44455,14 +44639,14 @@ async function show3(options2) {
44455
44639
  process.exit(1);
44456
44640
  }
44457
44641
  refuseSessionFiles(body);
44458
- const sessionId = process.env.ASSIST_SESSION_ID;
44459
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) {
44642
+ const sessionId2 = process.env.ASSIST_SESSION_ID;
44643
+ if (process.env.ASSIST_SESSION !== "1" || !sessionId2) {
44460
44644
  console.log(body);
44461
44645
  return;
44462
44646
  }
44463
44647
  try {
44464
44648
  await sendShowPreview({
44465
- sessionId,
44649
+ sessionId: sessionId2,
44466
44650
  requestId: randomUUID25(),
44467
44651
  title: options2.title ?? "Show",
44468
44652
  body
@@ -44529,12 +44713,12 @@ import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync48 } from "fs";
44529
44713
  import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync47 } from "fs";
44530
44714
 
44531
44715
  // src/commands/slack/readSlackParts.ts
44532
- import { readFileSync as readFileSync62 } from "fs";
44716
+ import { readFileSync as readFileSync63 } from "fs";
44533
44717
  function readSlackParts(files) {
44534
44718
  return files.map((file) => {
44535
44719
  let contents;
44536
44720
  try {
44537
- contents = readFileSync62(file, "utf8");
44721
+ contents = readFileSync63(file, "utf8");
44538
44722
  } catch {
44539
44723
  console.error(`Error: Part file not found: ${file}`);
44540
44724
  process.exit(1);
@@ -44551,14 +44735,14 @@ function readSlackParts(files) {
44551
44735
  // src/commands/slack/reviewProposedSlackMessage.ts
44552
44736
  import { randomUUID as randomUUID26 } from "crypto";
44553
44737
  async function reviewProposedSlackMessage(target, body, workingPath) {
44554
- const sessionId = process.env.ASSIST_SESSION_ID;
44555
- if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
44738
+ const sessionId2 = process.env.ASSIST_SESSION_ID;
44739
+ if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return;
44556
44740
  const { channel, threadTs, part } = target;
44557
44741
  const destination = threadTs ? `Reply in ${channel} thread ${threadTs}` : `Post to ${channel}`;
44558
44742
  await awaitPreviewApproval(
44559
44743
  part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
44560
44744
  {
44561
- sessionId,
44745
+ sessionId: sessionId2,
44562
44746
  requestId: randomUUID26(),
44563
44747
  title: part ? `${destination} (${part.index}/${part.total})` : destination,
44564
44748
  body,
@@ -45648,9 +45832,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
45648
45832
  }
45649
45833
 
45650
45834
  // src/commands/transcript/convert/readCleanedCues.ts
45651
- import { readFileSync as readFileSync67 } from "fs";
45835
+ import { readFileSync as readFileSync68 } from "fs";
45652
45836
  function readCleanedCues(inputPath) {
45653
- return deduplicateCues(parseVtt(readFileSync67(inputPath, "utf8")));
45837
+ return deduplicateCues(parseVtt(readFileSync68(inputPath, "utf8")));
45654
45838
  }
45655
45839
 
45656
45840
  // src/commands/transcript/clean.ts
@@ -45923,16 +46107,16 @@ function selectPassages(sources, selection) {
45923
46107
  }
45924
46108
 
45925
46109
  // src/commands/transcript/selectionSchema.ts
45926
- import { z as z20 } from "zod";
45927
- var selectionSchema = z20.strictObject({
45928
- keep: z20.array(
45929
- z20.strictObject({
45930
- file: z20.string().trim().min(1, "file is required"),
45931
- from: z20.string().trim().min(1, "from is required"),
45932
- to: z20.string().trim().min(1, "to is required")
46110
+ import { z as z21 } from "zod";
46111
+ var selectionSchema = z21.strictObject({
46112
+ keep: z21.array(
46113
+ z21.strictObject({
46114
+ file: z21.string().trim().min(1, "file is required"),
46115
+ from: z21.string().trim().min(1, "from is required"),
46116
+ to: z21.string().trim().min(1, "to is required")
45933
46117
  })
45934
46118
  ).min(1, "a selection needs at least one keep range"),
45935
- removed: z20.array(z20.string().trim().min(1)).default([])
46119
+ removed: z21.array(z21.string().trim().min(1)).default([])
45936
46120
  });
45937
46121
 
45938
46122
  // src/commands/transcript/widenAudienceInText.ts
@@ -46430,7 +46614,7 @@ function configKeys2() {
46430
46614
  }
46431
46615
 
46432
46616
  // src/commands/verify/forbiddenStrings.ts
46433
- import { existsSync as existsSync83, readFileSync as readFileSync68 } from "fs";
46617
+ import { existsSync as existsSync83, readFileSync as readFileSync69 } from "fs";
46434
46618
 
46435
46619
  // src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
46436
46620
  import { minimatch as minimatch10 } from "minimatch";
@@ -46477,7 +46661,7 @@ function forbiddenStrings() {
46477
46661
  }
46478
46662
  let parsed;
46479
46663
  try {
46480
- parsed = JSON.parse(readFileSync68(file, "utf8"));
46664
+ parsed = JSON.parse(readFileSync69(file, "utf8"));
46481
46665
  } catch (error) {
46482
46666
  console.log(`Could not parse ${file}: ${error.message}`);
46483
46667
  process.exit(1);
@@ -46549,7 +46733,7 @@ Total: ${lines2.length} hardcoded color(s)`);
46549
46733
  }
46550
46734
 
46551
46735
  // src/commands/verify/migrations.ts
46552
- import { readFileSync as readFileSync69 } from "fs";
46736
+ import { readFileSync as readFileSync70 } from "fs";
46553
46737
  import path105 from "path";
46554
46738
 
46555
46739
  // src/commands/verify/migrations/checkAppendOnly.ts
@@ -46714,7 +46898,7 @@ function migrations2() {
46714
46898
  if (ref) {
46715
46899
  const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
46716
46900
  const current = new Map(
46717
- files.map((file) => [file, readFileSync69(path105.join(dir, file), "utf8")])
46901
+ files.map((file) => [file, readFileSync70(path105.join(dir, file), "utf8")])
46718
46902
  );
46719
46903
  for (const finding of checkAppendOnly(baseline, current)) {
46720
46904
  problems.push(
@@ -47635,7 +47819,7 @@ function registerWatch(program) {
47635
47819
 
47636
47820
  // src/commands/roam/postRoamActivity.ts
47637
47821
  import { execFileSync as execFileSync31 } from "child_process";
47638
- import { readdirSync as readdirSync25, readFileSync as readFileSync70, statSync as statSync13 } from "fs";
47822
+ import { readdirSync as readdirSync25, readFileSync as readFileSync71, statSync as statSync13 } from "fs";
47639
47823
  import { join as join108 } from "path";
47640
47824
  function findPortFile(roamDir) {
47641
47825
  let entries;
@@ -47666,7 +47850,7 @@ function postRoamActivity(app, event) {
47666
47850
  if (!portFile) return;
47667
47851
  let port;
47668
47852
  try {
47669
- port = readFileSync70(portFile, "utf8").trim();
47853
+ port = readFileSync71(portFile, "utf8").trim();
47670
47854
  } catch {
47671
47855
  return;
47672
47856
  }
@@ -48287,11 +48471,11 @@ function applyLine(result, pending, line) {
48287
48471
  }
48288
48472
 
48289
48473
  // src/commands/sessions/daemon/readDaemonPidFile.ts
48290
- import { readFileSync as readFileSync71 } from "fs";
48474
+ import { readFileSync as readFileSync72 } from "fs";
48291
48475
  function readDaemonPidFile() {
48292
48476
  try {
48293
48477
  const pid = Number.parseInt(
48294
- readFileSync71(daemonPaths.pid, "utf8").trim(),
48478
+ readFileSync72(daemonPaths.pid, "utf8").trim(),
48295
48479
  10
48296
48480
  );
48297
48481
  return Number.isInteger(pid) ? pid : void 0;
@@ -48770,9 +48954,9 @@ async function refreshRepoConfigCacheOnStart() {
48770
48954
  }
48771
48955
 
48772
48956
  // src/commands/sessions/daemon/loadActiveSelection.ts
48773
- import { z as z21 } from "zod";
48957
+ import { z as z22 } from "zod";
48774
48958
  var ACTIVE_FILE = "active.json";
48775
- var activeSelectionSchema = z21.record(z21.string(), z21.string());
48959
+ var activeSelectionSchema = z22.record(z22.string(), z22.string());
48776
48960
  function loadActiveSelection() {
48777
48961
  const parsed = activeSelectionSchema.safeParse(
48778
48962
  loadJson(ACTIVE_FILE)
@@ -48790,23 +48974,23 @@ var ActiveSelection = class {
48790
48974
  this.onChange = onChange;
48791
48975
  }
48792
48976
  byRepo = /* @__PURE__ */ new Map();
48793
- set(cwd, sessionId) {
48977
+ set(cwd, sessionId2) {
48794
48978
  if (!cwd) return;
48795
- if (this.isAlreadySelected(cwd, sessionId)) return;
48979
+ if (this.isAlreadySelected(cwd, sessionId2)) return;
48796
48980
  this.byRepo.delete(cwd);
48797
- this.byRepo.set(cwd, sessionId);
48798
- daemonLog(`set-active: cwd=${cwd} id=${sessionId}`);
48981
+ this.byRepo.set(cwd, sessionId2);
48982
+ daemonLog(`set-active: cwd=${cwd} id=${sessionId2}`);
48799
48983
  saveActiveSelection(this.toJSON());
48800
48984
  this.onChange();
48801
48985
  }
48802
- isAlreadySelected(cwd, sessionId) {
48803
- if (this.byRepo.get(cwd) !== sessionId) return false;
48986
+ isAlreadySelected(cwd, sessionId2) {
48987
+ if (this.byRepo.get(cwd) !== sessionId2) return false;
48804
48988
  return [...this.byRepo.keys()].at(-1) === cwd;
48805
48989
  }
48806
48990
  // why: on daemon restart, reload persisted selections but drop any whose session was not restored
48807
48991
  restore(isLive2) {
48808
- for (const [cwd, sessionId] of Object.entries(loadActiveSelection()))
48809
- if (isLive2(sessionId)) this.byRepo.set(cwd, sessionId);
48992
+ for (const [cwd, sessionId2] of Object.entries(loadActiveSelection()))
48993
+ if (isLive2(sessionId2)) this.byRepo.set(cwd, sessionId2);
48810
48994
  }
48811
48995
  toJSON() {
48812
48996
  return Object.fromEntries(this.byRepo);
@@ -49134,7 +49318,7 @@ function sendResizeSnapshot(s, send) {
49134
49318
  }
49135
49319
 
49136
49320
  // src/commands/sessions/daemon/viewerSize.ts
49137
- import { readFileSync as readFileSync72, writeFileSync as writeFileSync58 } from "fs";
49321
+ import { readFileSync as readFileSync73, writeFileSync as writeFileSync58 } from "fs";
49138
49322
  var DEFAULT_SIZE = { cols: 120, rows: 30 };
49139
49323
  var remembered;
49140
49324
  function rememberViewerSize(cols, rows) {
@@ -49156,7 +49340,7 @@ function viewerSize() {
49156
49340
  function readSavedSize() {
49157
49341
  try {
49158
49342
  const { cols, rows } = JSON.parse(
49159
- readFileSync72(daemonPaths.viewerSize, "utf8")
49343
+ readFileSync73(daemonPaths.viewerSize, "utf8")
49160
49344
  );
49161
49345
  if (typeof cols === "number" && typeof rows === "number" && cols > 0)
49162
49346
  return { cols, rows };
@@ -49201,9 +49385,9 @@ function bracketedPaste(text20) {
49201
49385
 
49202
49386
  // src/commands/sessions/shared/pasteAndSubmit.ts
49203
49387
  var SUBMIT_DELAY_MS = 150;
49204
- function pasteAndSubmit(sendInput, sessionId, text20) {
49205
- sendInput(sessionId, bracketedPaste(text20));
49206
- setTimeout(() => sendInput(sessionId, SUBMIT), SUBMIT_DELAY_MS);
49388
+ function pasteAndSubmit(sendInput, sessionId2, text20) {
49389
+ sendInput(sessionId2, bracketedPaste(text20));
49390
+ setTimeout(() => sendInput(sessionId2, SUBMIT), SUBMIT_DELAY_MS);
49207
49391
  }
49208
49392
 
49209
49393
  // src/commands/sessions/daemon/flushPendingPrompts.ts
@@ -49699,8 +49883,8 @@ var MissingCwdError = class extends Error {
49699
49883
  this.name = "MissingCwdError";
49700
49884
  }
49701
49885
  };
49702
- function spawnPty(args, cwd, sessionId, extraEnv) {
49703
- refuseMissingCwd(cwd, sessionId);
49886
+ function spawnPty(args, cwd, sessionId2, extraEnv) {
49887
+ refuseMissingCwd(cwd, sessionId2);
49704
49888
  ensureSpawnHelperExecutable();
49705
49889
  const command = resolvePtyCommand(args);
49706
49890
  const {
@@ -49715,18 +49899,18 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
49715
49899
  env: {
49716
49900
  ...parentEnv,
49717
49901
  ASSIST_SESSION: "1",
49718
- ...sessionId && {
49719
- ASSIST_SESSION_ID: sessionId,
49720
- ASSIST_ACTIVITY_ID: sessionId
49902
+ ...sessionId2 && {
49903
+ ASSIST_SESSION_ID: sessionId2,
49904
+ ASSIST_ACTIVITY_ID: sessionId2
49721
49905
  },
49722
49906
  ...extraEnv
49723
49907
  }
49724
49908
  });
49725
49909
  }
49726
- function refuseMissingCwd(cwd, sessionId) {
49910
+ function refuseMissingCwd(cwd, sessionId2) {
49727
49911
  if (!cwd || existsSync91(cwd)) return;
49728
49912
  daemonLog(
49729
- `${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
49913
+ `${sessionId2 ? `session ${sessionId2}` : "pty"} not spawned: working directory ${cwd} no longer exists`
49730
49914
  );
49731
49915
  throw new MissingCwdError(cwd);
49732
49916
  }
@@ -49976,18 +50160,18 @@ async function backOff(reason4, deps2) {
49976
50160
 
49977
50161
  // src/commands/sessions/daemon/autoUpdate/holdForEscalation.ts
49978
50162
  var ESCALATION_POLL_MS = 5e3;
49979
- async function holdForEscalation(sessionId, deps2) {
50163
+ async function holdForEscalation(sessionId2, deps2) {
49980
50164
  deps2.takeHoldRelease();
49981
- deps2.enter("diverged", { escalationId: sessionId });
49982
- deps2.note(`paused while session ${sessionId} reconciles the divergence`);
49983
- while (deps2.isLive(sessionId)) {
50165
+ deps2.enter("diverged", { escalationId: sessionId2 });
50166
+ deps2.note(`paused while session ${sessionId2} reconciles the divergence`);
50167
+ while (deps2.isLive(sessionId2)) {
49984
50168
  await deps2.sleep(ESCALATION_POLL_MS);
49985
50169
  if (deps2.takeHoldRelease()) {
49986
- deps2.note(`check requested while session ${sessionId} is open; resuming`);
50170
+ deps2.note(`check requested while session ${sessionId2} is open; resuming`);
49987
50171
  return;
49988
50172
  }
49989
50173
  }
49990
- deps2.note(`session ${sessionId} ended; resuming`);
50174
+ deps2.note(`session ${sessionId2} ended; resuming`);
49991
50175
  }
49992
50176
 
49993
50177
  // src/commands/sessions/daemon/autoUpdate/runLapCapturingTail.ts
@@ -50041,14 +50225,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
50041
50225
  }
50042
50226
 
50043
50227
  // src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
50044
- import { readFileSync as readFileSync74, writeFileSync as writeFileSync60 } from "fs";
50228
+ import { readFileSync as readFileSync75, writeFileSync as writeFileSync60 } from "fs";
50045
50229
  var KEEP_TAIL = 256 * 1024;
50046
50230
  var MAX_LOG_SIZE = 4 * 1024 * 1024;
50047
50231
  function trimWatcherLog(cwd) {
50048
50232
  const path109 = watcherLogPath(cwd);
50049
50233
  let log2;
50050
50234
  try {
50051
- log2 = readFileSync74(path109, "utf8");
50235
+ log2 = readFileSync75(path109, "utf8");
50052
50236
  } catch {
50053
50237
  return;
50054
50238
  }
@@ -50375,8 +50559,8 @@ function loopDeps(installDir, ctx) {
50375
50559
  enter: autoUpdateState.enter,
50376
50560
  liveEscalation: () => liveEscalationIn(ctx().sessions, clone)?.id,
50377
50561
  escalate: (output) => escalateDivergence(ctx(), installDir, output),
50378
- isLive: (sessionId) => {
50379
- const status2 = ctx().sessions.get(sessionId)?.status;
50562
+ isLive: (sessionId2) => {
50563
+ const status2 = ctx().sessions.get(sessionId2)?.status;
50380
50564
  return status2 !== void 0 && status2 !== "done" && status2 !== "error";
50381
50565
  },
50382
50566
  takeHoldRelease: autoUpdateControl.takeHoldRelease,
@@ -50832,7 +51016,7 @@ function pidList(pids) {
50832
51016
  }
50833
51017
 
50834
51018
  // src/commands/sessions/daemon/worktree/readOccupant.ts
50835
- import { readFileSync as readFileSync75 } from "fs";
51019
+ import { readFileSync as readFileSync76 } from "fs";
50836
51020
  var VSCODE_PATHS = [
50837
51021
  "/.vscode-server/",
50838
51022
  "/.vscode-server-insiders/",
@@ -50867,7 +51051,7 @@ function parentPid(stat5) {
50867
51051
  }
50868
51052
  function readProc(procRoot, pid, file) {
50869
51053
  try {
50870
- return readFileSync75(`${procRoot}/${pid}/${file}`, "utf8");
51054
+ return readFileSync76(`${procRoot}/${pid}/${file}`, "utf8");
50871
51055
  } catch {
50872
51056
  return void 0;
50873
51057
  }
@@ -50882,12 +51066,12 @@ function liveOccupantReason(treePath) {
50882
51066
  }
50883
51067
 
50884
51068
  // src/commands/sessions/daemon/worktree/closeBlockReason.ts
50885
- async function closeBlockReason(sessionId, tree) {
51069
+ async function closeBlockReason(sessionId2, tree) {
50886
51070
  const durability = await checkDurability(tree.path);
50887
51071
  if (!durability.durable) return { reason: durability.reason, live: false };
50888
51072
  if (durability.gone) {
50889
51073
  daemonLog(
50890
- `session ${sessionId} closing: worktree ${tree.path} is gone from disk \u2014 released with nothing to land, not landed work`
51074
+ `session ${sessionId2} closing: worktree ${tree.path} is gone from disk \u2014 released with nothing to land, not landed work`
50891
51075
  );
50892
51076
  return void 0;
50893
51077
  }
@@ -51496,9 +51680,9 @@ function buildPrompt5(prompt) {
51496
51680
  }
51497
51681
 
51498
51682
  // src/commands/sessions/shared/loadSessionTitles.ts
51499
- import { z as z22 } from "zod";
51683
+ import { z as z23 } from "zod";
51500
51684
  var TITLES_FILE = "session-titles.json";
51501
- var sessionTitlesSchema = z22.record(z22.string(), z22.string());
51685
+ var sessionTitlesSchema = z23.record(z23.string(), z23.string());
51502
51686
  function loadSessionTitles() {
51503
51687
  const parsed = sessionTitlesSchema.safeParse(
51504
51688
  loadJson(TITLES_FILE)
@@ -51901,13 +52085,13 @@ function bindCodexSession(session, notify2) {
51901
52085
  const schedule = () => setTimeout(() => void poll(), POLL_MS5).unref();
51902
52086
  const poll = async () => {
51903
52087
  if (session.harnessSessionId) return;
51904
- const sessionId = await resolveCodexSessionId(cwd, since);
51905
- if (!sessionId) {
52088
+ const sessionId2 = await resolveCodexSessionId(cwd, since);
52089
+ if (!sessionId2) {
51906
52090
  if (--attemptsLeft > 0) schedule();
51907
52091
  return;
51908
52092
  }
51909
- session.harnessSessionId = sessionId;
51910
- daemonLog(`session ${session.id} bound to codex conversation ${sessionId}`);
52093
+ session.harnessSessionId = sessionId2;
52094
+ daemonLog(`session ${session.id} bound to codex conversation ${sessionId2}`);
51911
52095
  rememberSessionTitle(session);
51912
52096
  notify2();
51913
52097
  };
@@ -51919,13 +52103,13 @@ import { watch as watch3 } from "fs";
51919
52103
 
51920
52104
  // src/commands/sessions/daemon/ensureProjectDirExists.ts
51921
52105
  import { mkdirSync as mkdirSync42 } from "fs";
51922
- function ensureProjectDirExists(dir, sessionId) {
52106
+ function ensureProjectDirExists(dir, sessionId2) {
51923
52107
  try {
51924
52108
  mkdirSync42(dir, { recursive: true });
51925
52109
  return true;
51926
52110
  } catch (error) {
51927
52111
  daemonLog(
51928
- `session ${sessionId} transcript dir unavailable: ${error instanceof Error ? error.message : String(error)}`
52112
+ `session ${sessionId2} transcript dir unavailable: ${error instanceof Error ? error.message : String(error)}`
51929
52113
  );
51930
52114
  return false;
51931
52115
  }
@@ -54464,31 +54648,31 @@ var VerifyTracker = class {
54464
54648
  this.notify = notify2;
54465
54649
  }
54466
54650
  sessionByClient = /* @__PURE__ */ new Map();
54467
- start(client, sessionId) {
54468
- const session = this.sessions.get(sessionId);
54651
+ start(client, sessionId2) {
54652
+ const session = this.sessions.get(sessionId2);
54469
54653
  if (!session) {
54470
54654
  daemonLog(
54471
- `verify-started for unknown session id=${sessionId} (ignoring)`
54655
+ `verify-started for unknown session id=${sessionId2} (ignoring)`
54472
54656
  );
54473
54657
  return;
54474
54658
  }
54475
- daemonLog(`verify-started received: id=${sessionId}`);
54476
- this.sessionByClient.set(client, sessionId);
54659
+ daemonLog(`verify-started received: id=${sessionId2}`);
54660
+ this.sessionByClient.set(client, sessionId2);
54477
54661
  session.verifying = true;
54478
54662
  this.notify();
54479
54663
  }
54480
54664
  clear(client) {
54481
- const sessionId = this.sessionByClient.get(client);
54482
- if (!sessionId) return;
54665
+ const sessionId2 = this.sessionByClient.get(client);
54666
+ if (!sessionId2) return;
54483
54667
  this.sessionByClient.delete(client);
54484
- if (this.stillVerifying(sessionId)) return;
54485
- daemonLog(`verify connection closed: id=${sessionId}`);
54486
- const session = this.sessions.get(sessionId);
54668
+ if (this.stillVerifying(sessionId2)) return;
54669
+ daemonLog(`verify connection closed: id=${sessionId2}`);
54670
+ const session = this.sessions.get(sessionId2);
54487
54671
  if (session) session.verifying = false;
54488
54672
  this.notify();
54489
54673
  }
54490
- stillVerifying(sessionId) {
54491
- return [...this.sessionByClient.values()].includes(sessionId);
54674
+ stillVerifying(sessionId2) {
54675
+ return [...this.sessionByClient.values()].includes(sessionId2);
54492
54676
  }
54493
54677
  };
54494
54678
 
@@ -54689,18 +54873,18 @@ function resetRelayState(state, reason4) {
54689
54873
  state.scrollback.clear();
54690
54874
  }
54691
54875
  function replayLinkScrollback(state, client) {
54692
- for (const [sessionId, data] of state.scrollback)
54876
+ for (const [sessionId2, data] of state.scrollback)
54693
54877
  if (data)
54694
54878
  sendTo(client, {
54695
54879
  type: "output",
54696
- sessionId,
54880
+ sessionId: sessionId2,
54697
54881
  data: stripReplayQueries(data)
54698
54882
  });
54699
54883
  }
54700
- function appendScrollback(state, sessionId, data) {
54701
- const next3 = (state.scrollback.get(sessionId) ?? "") + data;
54884
+ function appendScrollback(state, sessionId2, data) {
54885
+ const next3 = (state.scrollback.get(sessionId2) ?? "") + data;
54702
54886
  state.scrollback.set(
54703
- sessionId,
54887
+ sessionId2,
54704
54888
  next3.length > MAX_SCROLLBACK2 ? next3.slice(-MAX_SCROLLBACK2) : next3
54705
54889
  );
54706
54890
  }
@@ -54937,9 +55121,9 @@ function relayToCreator(label) {
54937
55121
  // src/commands/sessions/daemon/links/relayLinkMessage.ts
54938
55122
  var nsId = (state, msg) => toNodeSessionId(state.node, msg.sessionId);
54939
55123
  var relayOutput = (state, msg) => {
54940
- const sessionId = nsId(state, msg);
54941
- appendScrollback(state, sessionId, msg.data);
54942
- broadcastToViewers(state, { type: "output", sessionId, data: msg.data });
55124
+ const sessionId2 = nsId(state, msg);
55125
+ appendScrollback(state, sessionId2, msg.data);
55126
+ broadcastToViewers(state, { type: "output", sessionId: sessionId2, data: msg.data });
54943
55127
  };
54944
55128
  var relayHistory = (state, msg) => {
54945
55129
  const sessions = (msg.sessions ?? []).map((s) => ({
@@ -55444,12 +55628,12 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
55444
55628
  import { existsSync as existsSync103 } from "fs";
55445
55629
 
55446
55630
  // src/commands/sessions/daemon/resumeSession.ts
55447
- function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
55631
+ function resumeSession(id, sessionId2, cwd, name, holdPty, harness) {
55448
55632
  const startedAt = Date.now();
55449
55633
  const codex = resolveHarness(harness) === "codex";
55450
55634
  return {
55451
55635
  id,
55452
- name: name ? `${name.slice(0, 36)} (R)` : `Resume ${sessionId.slice(0, 8)}`,
55636
+ name: name ? `${name.slice(0, 36)} (R)` : `Resume ${sessionId2.slice(0, 8)}`,
55453
55637
  commandType: "claude",
55454
55638
  harness,
55455
55639
  status: "waiting",
@@ -55458,7 +55642,7 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
55458
55642
  runningSince: null,
55459
55643
  waitingSince: startedAt,
55460
55644
  ...startOrHoldPty(
55461
- () => codex ? spawnCodex2({ resumeSessionId: sessionId, cwd, sessionId: id }) : spawnClaude2({ resumeSessionId: sessionId, cwd, sessionId: id }),
55645
+ () => codex ? spawnCodex2({ resumeSessionId: sessionId2, cwd, sessionId: id }) : spawnClaude2({ resumeSessionId: sessionId2, cwd, sessionId: id }),
55462
55646
  holdPty
55463
55647
  ),
55464
55648
  scrollback: "",
@@ -55466,8 +55650,8 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
55466
55650
  /* why: bind the card to the conversation it is resuming so a daemon restart
55467
55651
  * re-resumes this same transcript, not whichever .jsonl a cwd poller would
55468
55652
  * have re-discovered (#413). */
55469
- claudeSessionId: codex ? void 0 : sessionId,
55470
- harnessSessionId: codex ? sessionId : void 0
55653
+ claudeSessionId: codex ? void 0 : sessionId2,
55654
+ harnessSessionId: codex ? sessionId2 : void 0
55471
55655
  };
55472
55656
  }
55473
55657
 
@@ -55545,13 +55729,13 @@ function cloneForReapedTree(missingCwd) {
55545
55729
  }
55546
55730
 
55547
55731
  // src/commands/sessions/daemon/worktree/resumeInTree.ts
55548
- function resumeInTree(ctx, sessionId, cwd, name, harness) {
55732
+ function resumeInTree(ctx, sessionId2, cwd, name, harness) {
55549
55733
  if (!existsSync103(cwd))
55550
- return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
55734
+ return resumeInReplacementTree(ctx, sessionId2, cwd, name, harness);
55551
55735
  const id = ctx.spawnWith(
55552
- (sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
55736
+ (sid) => resumeSession(sid, sessionId2, cwd, name, void 0, harness)
55553
55737
  );
55554
- daemonLog(`session ${id} resuming ${sessionId} in ${cwd}`);
55738
+ daemonLog(`session ${id} resuming ${sessionId2} in ${cwd}`);
55555
55739
  bindResumedWorktree(ctx.sessions.get(id), cwd, ctx.notify);
55556
55740
  return id;
55557
55741
  }
@@ -55635,8 +55819,8 @@ var SessionManager = class {
55635
55819
  spawnAssist(assistArgs, cwd, meta, context) {
55636
55820
  return spawnAssistInTree(this.treeCtx(), assistArgs, cwd, meta, context);
55637
55821
  }
55638
- resume(sessionId, cwd, name, harness) {
55639
- return resumeInTree(this.treeCtx(), sessionId, cwd, name, harness);
55822
+ resume(sessionId2, cwd, name, harness) {
55823
+ return resumeInTree(this.treeCtx(), sessionId2, cwd, name, harness);
55640
55824
  }
55641
55825
  onStatusChange = makeManagerStatusHandler(
55642
55826
  this.sessions,
@@ -56172,8 +56356,8 @@ function tokenCountPayload(entry) {
56172
56356
  }
56173
56357
 
56174
56358
  // src/commands/sessions/daemon/applyCodexUsage.ts
56175
- function applyCodexUsage(sessions, sessionId, usage, windows) {
56176
- const session = sessions.get(sessionId);
56359
+ function applyCodexUsage(sessions, sessionId2, usage, windows) {
56360
+ const session = sessions.get(sessionId2);
56177
56361
  if (!session) return false;
56178
56362
  if (usage.usedPct !== void 0) session.usedPct = usage.usedPct;
56179
56363
  const phase = sessionBacklogPhase(session);
@@ -56192,19 +56376,19 @@ function applyCodexUsage(sessions, sessionId, usage, windows) {
56192
56376
  // src/commands/sessions/daemon/handleCodexUsage.ts
56193
56377
  var handleCodexUsage = (client, m, d) => {
56194
56378
  if (m.links.route(client, d)) return;
56195
- const sessionId = d.sessionId;
56196
- daemonLog(`codex-usage received: id=${sessionId}`);
56197
- if (d.ack) sendTo(client, { type: "ack", sessionId });
56379
+ const sessionId2 = d.sessionId;
56380
+ daemonLog(`codex-usage received: id=${sessionId2}`);
56381
+ if (d.ack) sendTo(client, { type: "ack", sessionId: sessionId2 });
56198
56382
  void readCodexRolloutUsage(d.transcriptPath).then(
56199
56383
  (usage) => {
56200
56384
  if (usage.rateLimits)
56201
56385
  m.clients.updateHarnessLimits("codex", usage.rateLimits);
56202
56386
  const windows = usage.rateLimits ? m.clients.currentWindows("codex") : [];
56203
56387
  daemonLog(
56204
- `codex-usage applied: id=${sessionId} responses=${usage.responses.length} usedPct=${usage.usedPct ?? "none"} windows=${windows.length}`
56388
+ `codex-usage applied: id=${sessionId2} responses=${usage.responses.length} usedPct=${usage.usedPct ?? "none"} windows=${windows.length}`
56205
56389
  );
56206
56390
  m.update(
56207
- (sessions) => applyCodexUsage(sessions, sessionId, usage, windows)
56391
+ (sessions) => applyCodexUsage(sessions, sessionId2, usage, windows)
56208
56392
  );
56209
56393
  },
56210
56394
  (error) => daemonLog(`codex-usage read failed: ${String(error)}`)
@@ -56306,22 +56490,22 @@ var handleOutputRequest = (client, m, d) => {
56306
56490
  sendTo(client, { type: "session-output", error: target.error });
56307
56491
  return;
56308
56492
  }
56309
- const { sessionId, exited } = target;
56493
+ const { sessionId: sessionId2, exited } = target;
56310
56494
  let scrollback;
56311
56495
  m.update((sessions) => {
56312
- scrollback = sessions.get(sessionId)?.scrollback;
56496
+ scrollback = sessions.get(sessionId2)?.scrollback;
56313
56497
  return false;
56314
56498
  });
56315
56499
  daemonLog(
56316
- `output requested: id=${sessionId}${exited ? ` (exited: ${exited})` : ""} ${scrollback === void 0 ? "unknown session" : `${scrollback.length} chars`}`
56500
+ `output requested: id=${sessionId2}${exited ? ` (exited: ${exited})` : ""} ${scrollback === void 0 ? "unknown session" : `${scrollback.length} chars`}`
56317
56501
  );
56318
56502
  sendTo(
56319
56503
  client,
56320
56504
  scrollback === void 0 ? {
56321
56505
  type: "session-output",
56322
- sessionId,
56323
- error: `No session ${sessionId} on this node`
56324
- } : { type: "session-output", sessionId, scrollback, exited }
56506
+ sessionId: sessionId2,
56507
+ error: `No session ${sessionId2} on this node`
56508
+ } : { type: "session-output", sessionId: sessionId2, scrollback, exited }
56325
56509
  );
56326
56510
  };
56327
56511
 
@@ -56379,18 +56563,18 @@ import * as fs58 from "fs";
56379
56563
 
56380
56564
  // src/commands/sessions/shared/codex/findCodexRolloutPath.ts
56381
56565
  import * as path108 from "path";
56382
- async function findCodexRolloutPath(sessionId) {
56383
- if (!sessionId) return null;
56566
+ async function findCodexRolloutPath(sessionId2) {
56567
+ if (!sessionId2) return null;
56384
56568
  const paths = await discoverCodexRolloutPaths();
56385
- const suffix = `-${sessionId}.jsonl`;
56569
+ const suffix = `-${sessionId2}.jsonl`;
56386
56570
  return paths.find((file) => path108.basename(file).endsWith(suffix)) ?? null;
56387
56571
  }
56388
56572
 
56389
56573
  // src/commands/sessions/shared/parseTranscript.ts
56390
- async function parseTranscript(sessionId) {
56391
- const filePath = await findSessionJsonlPath(sessionId);
56574
+ async function parseTranscript(sessionId2) {
56575
+ const filePath = await findSessionJsonlPath(sessionId2);
56392
56576
  if (filePath) return readMessages(filePath, parseTranscriptLines);
56393
- const rollout = await findCodexRolloutPath(sessionId);
56577
+ const rollout = await findCodexRolloutPath(sessionId2);
56394
56578
  if (rollout) return readMessages(rollout, parseCodexTranscriptLines);
56395
56579
  return [];
56396
56580
  }
@@ -56439,15 +56623,15 @@ function findSession(manager, id) {
56439
56623
  return found;
56440
56624
  }
56441
56625
  async function handleFetchUserMessages(client, manager, data) {
56442
- const sessionId = data.sessionId;
56443
- const session = findSession(manager, sessionId);
56626
+ const sessionId2 = data.sessionId;
56627
+ const session = findSession(manager, sessionId2);
56444
56628
  const filePath = session ? await resolveTranscriptPath(session) : null;
56445
56629
  const entries = filePath ? await readTranscriptTail(filePath, Number.POSITIVE_INFINITY) : [];
56446
56630
  const messages = extractUserMessages(entries);
56447
56631
  daemonLog(
56448
- `session ${sessionId} user messages: ${messages.length} from ${filePath ?? "no transcript"}`
56632
+ `session ${sessionId2} user messages: ${messages.length} from ${filePath ?? "no transcript"}`
56449
56633
  );
56450
- sendTo(client, { type: "user-messages", sessionId, messages });
56634
+ sendTo(client, { type: "user-messages", sessionId: sessionId2, messages });
56451
56635
  }
56452
56636
 
56453
56637
  // src/commands/sessions/daemon/lifecycleHandlers.ts
@@ -56456,9 +56640,9 @@ async function handleHistory(client, manager) {
56456
56640
  sendTo(client, { type: "history", sessions: await collectHistory(linked) });
56457
56641
  }
56458
56642
  function handleFetchTranscript(client, _manager, data) {
56459
- const sessionId = data.sessionId;
56460
- parseTranscript(sessionId).then(
56461
- (messages) => sendTo(client, { type: "transcript", sessionId, messages })
56643
+ const sessionId2 = data.sessionId;
56644
+ parseTranscript(sessionId2).then(
56645
+ (messages) => sendTo(client, { type: "transcript", sessionId: sessionId2, messages })
56462
56646
  );
56463
56647
  }
56464
56648
  async function handleShutdown(client, manager) {
@@ -56496,28 +56680,28 @@ function pinNotificationTarget(viewerNode, localNode, peerFor) {
56496
56680
  // src/commands/sessions/daemon/pins/handleNotifyPin.ts
56497
56681
  var DELIVERY_TIMEOUT_MS = 5e3;
56498
56682
  var handleNotifyPin = (client, m, d) => {
56499
- const { sessionId, requestId, area } = d;
56683
+ const { sessionId: sessionId2, requestId, area } = d;
56500
56684
  const reply2 = (node) => sendTo(client, { type: "notify-pin-result", requestId, node });
56501
56685
  const target = pinNotificationTarget(
56502
- m.localSessions().find((s) => s.id === sessionId)?.activeViewerNode,
56686
+ m.localSessions().find((s) => s.id === sessionId2)?.activeViewerNode,
56503
56687
  m.links.localNode(),
56504
56688
  (node) => m.clients.peerFor(node)
56505
56689
  );
56506
56690
  if (target.kind === "local") {
56507
56691
  daemonLog(
56508
- `notify-pin: session ${sessionId} ${target.reason}; ${area} PIN notifies locally`
56692
+ `notify-pin: session ${sessionId2} ${target.reason}; ${area} PIN notifies locally`
56509
56693
  );
56510
56694
  return reply2();
56511
56695
  }
56512
56696
  daemonLog(
56513
- `notify-pin: session ${sessionId} relaying ${area} PIN notification to ${target.node}`
56697
+ `notify-pin: session ${sessionId2} relaying ${area} PIN notification to ${target.node}`
56514
56698
  );
56515
56699
  m.links.pins.awaitDelivery(
56516
56700
  String(requestId),
56517
56701
  DELIVERY_TIMEOUT_MS,
56518
56702
  (delivered) => {
56519
56703
  daemonLog(
56520
- `notify-pin: session ${sessionId} ${area} PIN ${delivered ? `shown on ${target.node}` : `not shown on ${target.node}; notifying locally`}`
56704
+ `notify-pin: session ${sessionId2} ${area} PIN ${delivered ? `shown on ${target.node}` : `not shown on ${target.node}; notifying locally`}`
56521
56705
  );
56522
56706
  reply2(delivered ? target.node : void 0);
56523
56707
  }
@@ -56541,17 +56725,17 @@ var pinHandlers = {
56541
56725
 
56542
56726
  // src/commands/sessions/daemon/handleSnapshotRequest.ts
56543
56727
  var handleSnapshotRequest = (client, m, d) => {
56544
- const sessionId = d.sessionId;
56728
+ const sessionId2 = d.sessionId;
56545
56729
  let data;
56546
56730
  m.update((sessions) => {
56547
- const s = sessions.get(sessionId);
56731
+ const s = sessions.get(sessionId2);
56548
56732
  if (s) data = sessionSnapshot(s);
56549
56733
  return false;
56550
56734
  });
56551
56735
  daemonLog(
56552
- `snapshot requested: id=${sessionId} ${data === void 0 ? "not local" : `${data.length} chars`}`
56736
+ `snapshot requested: id=${sessionId2} ${data === void 0 ? "not local" : `${data.length} chars`}`
56553
56737
  );
56554
- if (data !== void 0) sendTo(client, { type: "snapshot", sessionId, data });
56738
+ if (data !== void 0) sendTo(client, { type: "snapshot", sessionId: sessionId2, data });
56555
56739
  };
56556
56740
 
56557
56741
  // src/commands/sessions/daemon/viewed.ts
@@ -56575,15 +56759,15 @@ var viewerHandlers = {
56575
56759
  ),
56576
56760
  resize: viewed(
56577
56761
  routed((client, m, d) => {
56578
- const sessionId = d.sessionId;
56762
+ const sessionId2 = d.sessionId;
56579
56763
  const claim = d.claim === true;
56580
56764
  const refresh = d.refresh === true;
56581
56765
  const localViewer = d.viewerNode === m.links.localNode();
56582
- m.io.resize(sessionId, d.cols, d.rows, {
56766
+ m.io.resize(sessionId2, d.cols, d.rows, {
56583
56767
  ...viewerOf(d),
56584
56768
  claim,
56585
56769
  refresh,
56586
- sendSnapshot: localViewer ? (data) => sendTo(client, { type: "snapshot", sessionId, data }) : void 0
56770
+ sendSnapshot: localViewer ? (data) => sendTo(client, { type: "snapshot", sessionId: sessionId2, data }) : void 0
56587
56771
  });
56588
56772
  })
56589
56773
  ),
@@ -57005,7 +57189,7 @@ function handleConnection(socket, manager) {
57005
57189
  import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync62 } from "fs";
57006
57190
 
57007
57191
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
57008
- import { readFileSync as readFileSync76 } from "fs";
57192
+ import { readFileSync as readFileSync77 } from "fs";
57009
57193
  var WATCHDOG_INTERVAL_MS = 5e3;
57010
57194
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
57011
57195
  const timer = setInterval(() => {
@@ -57016,7 +57200,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
57016
57200
  }
57017
57201
  function ownsPidFile() {
57018
57202
  try {
57019
- return readFileSync76(daemonPaths.pid, "utf8").trim() === String(process.pid);
57203
+ return readFileSync77(daemonPaths.pid, "utf8").trim() === String(process.pid);
57020
57204
  } catch {
57021
57205
  return false;
57022
57206
  }
@@ -57163,12 +57347,12 @@ async function closeSession2() {
57163
57347
  console.log("No daemon-managed session to close.");
57164
57348
  return;
57165
57349
  }
57166
- const sessionId = process.env.ASSIST_SESSION_ID;
57350
+ const sessionId2 = process.env.ASSIST_SESSION_ID;
57167
57351
  try {
57168
- await sendToDaemon({ type: "dismiss", sessionId, closeServerRuns: true });
57352
+ await sendToDaemon({ type: "dismiss", sessionId: sessionId2, closeServerRuns: true });
57169
57353
  } catch (error) {
57170
57354
  appendDaemonLog(
57171
- `close send failed: id=${sessionId}: ${error instanceof Error ? error.message : String(error)}`
57355
+ `close send failed: id=${sessionId2}: ${error instanceof Error ? error.message : String(error)}`
57172
57356
  );
57173
57357
  }
57174
57358
  }
@@ -57530,7 +57714,7 @@ function withTimeout(promise, ms, what) {
57530
57714
  }
57531
57715
  async function updateOverLink(name, action) {
57532
57716
  try {
57533
- const sessionId = await withTimeout(
57717
+ const sessionId2 = await withTimeout(
57534
57718
  requestSession({
57535
57719
  type: "create-assist",
57536
57720
  assistArgs: ["update"],
@@ -57539,7 +57723,7 @@ async function updateOverLink(name, action) {
57539
57723
  CREATE_TIMEOUT_MS,
57540
57724
  "create-assist"
57541
57725
  );
57542
- console.log(`Running assist update on ${name} (session ${sessionId})\u2026`);
57726
+ console.log(`Running assist update on ${name} (session ${sessionId2})\u2026`);
57543
57727
  } catch (error) {
57544
57728
  throw await action.fail(`Update ${name} failed`, error);
57545
57729
  }
@@ -57644,9 +57828,9 @@ async function requestSessionOutput(target) {
57644
57828
  );
57645
57829
  socket.write(`${JSON.stringify({ type: "output", ...target })}
57646
57830
  `);
57647
- const { sessionId, scrollback, exited, error } = await reply2;
57831
+ const { sessionId: sessionId2, scrollback, exited, error } = await reply2;
57648
57832
  if (scrollback === void 0) throw new Error(error);
57649
- return { sessionId, scrollback, exited };
57833
+ return { sessionId: sessionId2, scrollback, exited };
57650
57834
  } finally {
57651
57835
  socket.destroy();
57652
57836
  }
@@ -57660,8 +57844,8 @@ function lastLines(scrollback, count11) {
57660
57844
  }
57661
57845
 
57662
57846
  // src/commands/sessions/sessionOutput.ts
57663
- function resolveTarget4(sessionId, server) {
57664
- if (sessionId && server)
57847
+ function resolveTarget4(sessionId2, server) {
57848
+ if (sessionId2 && server)
57665
57849
  return "Pass either a session id or --server, not both";
57666
57850
  if (server)
57667
57851
  return {
@@ -57670,16 +57854,16 @@ function resolveTarget4(sessionId, server) {
57670
57854
  group: server === true ? "default" : server
57671
57855
  }
57672
57856
  };
57673
- if (!sessionId) return "Pass a session id or --server [group]";
57674
- if (sessionId.includes(":"))
57675
- return `Session ${sessionId} is on a linked node; reading linked-node sessions is not supported yet`;
57676
- return { sessionId };
57857
+ if (!sessionId2) return "Pass a session id or --server [group]";
57858
+ if (sessionId2.includes(":"))
57859
+ return `Session ${sessionId2} is on a linked node; reading linked-node sessions is not supported yet`;
57860
+ return { sessionId: sessionId2 };
57677
57861
  }
57678
- async function sessionOutput(sessionId, options2) {
57862
+ async function sessionOutput(sessionId2, options2) {
57679
57863
  const count11 = Number.parseInt(options2.lines, 10);
57680
57864
  if (!Number.isInteger(count11) || count11 < 1)
57681
57865
  return fail12(`-n must be a positive integer, got ${options2.lines}`);
57682
- const target = resolveTarget4(sessionId, options2.server);
57866
+ const target = resolveTarget4(sessionId2, options2.server);
57683
57867
  if (typeof target === "string") return fail12(target);
57684
57868
  try {
57685
57869
  const {
@@ -57738,12 +57922,12 @@ async function renameSession(title) {
57738
57922
  console.log("No daemon-managed session to rename.");
57739
57923
  return;
57740
57924
  }
57741
- const sessionId = process.env.ASSIST_SESSION_ID;
57925
+ const sessionId2 = process.env.ASSIST_SESSION_ID;
57742
57926
  try {
57743
- await sendToDaemon({ type: "rename", sessionId, title });
57927
+ await sendToDaemon({ type: "rename", sessionId: sessionId2, title });
57744
57928
  } catch (error) {
57745
57929
  appendDaemonLog(
57746
- `rename send failed: id=${sessionId}: ${error instanceof Error ? error.message : String(error)}`
57930
+ `rename send failed: id=${sessionId2}: ${error instanceof Error ? error.message : String(error)}`
57747
57931
  );
57748
57932
  }
57749
57933
  }