@staff0rd/assist 0.1127.3 → 0.1128.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.1127.3",
9
+ version: "0.1128.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -179,13 +179,13 @@ var stagedAttachmentsDir = join(homedir(), ".assist", "attachments");
179
179
  // src/shared/sweepStagedAttachments.ts
180
180
  var PANE_PERSIST_TTL_MS = 24 * 60 * 60 * 1e3;
181
181
  function sweepStagedAttachments(dir = stagedAttachmentsDir, now = Date.now()) {
182
- let entries;
182
+ let entries2;
183
183
  try {
184
- entries = readdirSync(dir);
184
+ entries2 = readdirSync(dir);
185
185
  } catch {
186
186
  return;
187
187
  }
188
- for (const name2 of entries) {
188
+ for (const name2 of entries2) {
189
189
  if (!name2.startsWith("upload-")) continue;
190
190
  const path128 = join2(dir, name2);
191
191
  try {
@@ -1405,9 +1405,9 @@ function matchRepoConfigKey(globalRaw, origin, source = "~/.assist.yml") {
1405
1405
  const repos2 = globalRaw.repos;
1406
1406
  if (!repos2 || typeof repos2 !== "object" || Array.isArray(repos2))
1407
1407
  return void 0;
1408
- const entries = repos2;
1408
+ const entries2 = repos2;
1409
1409
  const candidates = originKeyCandidates(origin);
1410
- const matches = Object.keys(entries).filter((key) => candidates.has(key));
1410
+ const matches = Object.keys(entries2).filter((key) => candidates.has(key));
1411
1411
  if (matches.length === 0) return void 0;
1412
1412
  if (matches.length > 1) {
1413
1413
  throw new AmbiguousRepoConfigError(
@@ -5558,13 +5558,13 @@ async function discoverSessionJsonlPaths() {
5558
5558
  await Promise.all(
5559
5559
  projectDirs.map(async (dirName) => {
5560
5560
  const dirPath = path6.join(dir, dirName);
5561
- let entries;
5561
+ let entries2;
5562
5562
  try {
5563
- entries = await fs3.promises.readdir(dirPath);
5563
+ entries2 = await fs3.promises.readdir(dirPath);
5564
5564
  } catch {
5565
5565
  return;
5566
5566
  }
5567
- for (const file of entries) {
5567
+ for (const file of entries2) {
5568
5568
  if (file.endsWith(".jsonl"))
5569
5569
  results.push({ path: path6.join(dirPath, file), origin });
5570
5570
  }
@@ -5725,18 +5725,18 @@ function claudeConnectorProbe(connector) {
5725
5725
  import * as fs4 from "fs";
5726
5726
  var DEFAULT_MAX_BYTES = 256 * 1024;
5727
5727
  function parseTailEntries(raw) {
5728
- const entries = [];
5728
+ const entries2 = [];
5729
5729
  for (const line of raw.split("\n")) {
5730
5730
  const trimmed = line.trim();
5731
5731
  if (!trimmed) continue;
5732
5732
  try {
5733
5733
  const parsed = JSON.parse(trimmed);
5734
5734
  if (parsed && typeof parsed === "object")
5735
- entries.push(parsed);
5735
+ entries2.push(parsed);
5736
5736
  } catch {
5737
5737
  }
5738
5738
  }
5739
- return entries;
5739
+ return entries2;
5740
5740
  }
5741
5741
  function dropPartialFirstLine(raw, sliced) {
5742
5742
  if (!sliced) return raw;
@@ -5825,23 +5825,23 @@ function taskNotificationText(entry) {
5825
5825
 
5826
5826
  // src/commands/sessions/shared/unfinishedBackgroundTasks.ts
5827
5827
  var KILLED_STATUSES = /* @__PURE__ */ new Set(["killed", "stopped"]);
5828
- function unfinishedBackgroundTasks(entries) {
5829
- const inFlight2 = /* @__PURE__ */ new Set();
5828
+ function unfinishedBackgroundTasks(entries2) {
5829
+ const inFlight3 = /* @__PURE__ */ new Set();
5830
5830
  const killedAwaitingTurn = /* @__PURE__ */ new Set();
5831
- for (const entry of entries) {
5831
+ for (const entry of entries2) {
5832
5832
  const started2 = startedTaskId(entry);
5833
- if (started2) inFlight2.add(started2);
5833
+ if (started2) inFlight3.add(started2);
5834
5834
  for (const finished2 of selfFinishedTaskIds(entry))
5835
- inFlight2.delete(finished2);
5835
+ inFlight3.delete(finished2);
5836
5836
  for (const killed of killedTaskIds(entry)) killedAwaitingTurn.add(killed);
5837
5837
  for (const stopped of deliberatelyStoppedTaskIds(entry))
5838
- inFlight2.delete(stopped);
5838
+ inFlight3.delete(stopped);
5839
5839
  if (entry.type === "assistant") {
5840
- for (const handled of killedAwaitingTurn) inFlight2.delete(handled);
5840
+ for (const handled of killedAwaitingTurn) inFlight3.delete(handled);
5841
5841
  killedAwaitingTurn.clear();
5842
5842
  }
5843
5843
  }
5844
- return [...inFlight2];
5844
+ return [...inFlight3];
5845
5845
  }
5846
5846
  function killedTaskIds(entry) {
5847
5847
  return notifiedTasks(entry).filter(({ status: status2 }) => status2 && KILLED_STATUSES.has(status2)).map(({ id }) => id);
@@ -5936,8 +5936,8 @@ function isInterruptText(value) {
5936
5936
  }
5937
5937
 
5938
5938
  // src/commands/sessions/shared/normalizeTranscriptEvents.ts
5939
- function normalizeTranscriptEvents(entries) {
5940
- return entries.map(normalizeEntry).filter((event) => event !== null);
5939
+ function normalizeTranscriptEvents(entries2) {
5940
+ return entries2.map(normalizeEntry).filter((event) => event !== null);
5941
5941
  }
5942
5942
  function normalizeEntry(entry) {
5943
5943
  if (entry.isSidechain || entry.isMeta) return null;
@@ -5967,10 +5967,10 @@ function asRecord3(value) {
5967
5967
 
5968
5968
  // src/commands/sessions/shared/pendingAskQuestionTasks.ts
5969
5969
  var ASK_QUESTION_COMMAND = /\bassist ask-(question|check)\b/;
5970
- function pendingAskQuestionTasks(entries) {
5970
+ function pendingAskQuestionTasks(entries2) {
5971
5971
  const askQuestionToolUses = /* @__PURE__ */ new Set();
5972
5972
  const askQuestionTasks = /* @__PURE__ */ new Set();
5973
- for (const entry of entries) {
5973
+ for (const entry of entries2) {
5974
5974
  for (const block of contentBlocks(entry)) {
5975
5975
  const input = asRecord(block.input);
5976
5976
  if (block.type === "tool_use" && typeof block.id === "string" && typeof input?.command === "string" && ASK_QUESTION_COMMAND.test(input.command))
@@ -5981,7 +5981,7 @@ function pendingAskQuestionTasks(entries) {
5981
5981
  }
5982
5982
  }
5983
5983
  }
5984
- return unfinishedBackgroundTasks(entries).filter(
5984
+ return unfinishedBackgroundTasks(entries2).filter(
5985
5985
  (id) => askQuestionTasks.has(id)
5986
5986
  );
5987
5987
  }
@@ -5992,15 +5992,15 @@ function contentBlocks(entry) {
5992
5992
  }
5993
5993
 
5994
5994
  // src/commands/sessions/shared/awaitsQuestionAnswer.ts
5995
- function awaitsQuestionAnswer(entries) {
5996
- const events = normalizeTranscriptEvents(entries);
5997
- return hasPendingAskUserQuestion(events, lastDecisiveIndex(events)) || pendingAskQuestionTasks(entries).length > 0;
5995
+ function awaitsQuestionAnswer(entries2) {
5996
+ const events = normalizeTranscriptEvents(entries2);
5997
+ return hasPendingAskUserQuestion(events, lastDecisiveIndex(events)) || pendingAskQuestionTasks(entries2).length > 0;
5998
5998
  }
5999
5999
 
6000
6000
  // src/commands/sessions/shared/deriveTranscriptStatus.ts
6001
6001
  var TURN_END_STOP_REASONS = /* @__PURE__ */ new Set(["end_turn", "stop_sequence"]);
6002
- function deriveTranscriptStatus(entries, opts = {}) {
6003
- const events = normalizeTranscriptEvents(entries);
6002
+ function deriveTranscriptStatus(entries2, opts = {}) {
6003
+ const events = normalizeTranscriptEvents(entries2);
6004
6004
  const lastIdx = lastDecisiveIndex(events);
6005
6005
  if (lastIdx === -1) return null;
6006
6006
  const ev = events[lastIdx];
@@ -6016,9 +6016,9 @@ function deriveTranscriptStatus(entries, opts = {}) {
6016
6016
 
6017
6017
  // src/commands/sessions/shared/transcriptTailFingerprint.ts
6018
6018
  var CONVERSATION_TYPES = /* @__PURE__ */ new Set(["user", "assistant"]);
6019
- function transcriptTailFingerprint(entries) {
6020
- for (let i = entries.length - 1; i >= 0; i--) {
6021
- const entry = entries[i];
6019
+ function transcriptTailFingerprint(entries2) {
6020
+ for (let i = entries2.length - 1; i >= 0; i--) {
6021
+ const entry = entries2[i];
6022
6022
  if (entry.isSidechain || entry.isMeta) continue;
6023
6023
  if (typeof entry.type !== "string" || !CONVERSATION_TYPES.has(entry.type))
6024
6024
  continue;
@@ -6250,8 +6250,8 @@ function blockShapes(entry, known) {
6250
6250
  if (!Array.isArray(content)) return [`${String(entry.type)}/content`];
6251
6251
  return claudeContentBlocksOf(content).map((block) => String(block.type)).filter((type) => !known.has(type)).map((type) => `${String(entry.type)}/${type}`);
6252
6252
  }
6253
- function claudeUnrecognisedShapes(entries) {
6254
- const shapes = entries.flatMap((entry) => {
6253
+ function claudeUnrecognisedShapes(entries2) {
6254
+ const shapes = entries2.flatMap((entry) => {
6255
6255
  const type = String(entry.type);
6256
6256
  const known = BLOCK_TYPES.get(type);
6257
6257
  if (known) return blockShapes(entry, known);
@@ -6265,10 +6265,10 @@ var claudeConversationReader = {
6265
6265
  headBytes: 65536,
6266
6266
  locate: ({ cwd, claudeSessionId }) => cwd && claudeSessionId ? findTranscriptPathSync(cwd, claudeSessionId) : null,
6267
6267
  watchTarget: ({ cwd, claudeSessionId }) => cwd && claudeSessionId ? { dir: projectDirForCwd(cwd), file: `${claudeSessionId}.jsonl` } : null,
6268
- events: (entries) => entries.flatMap(claudeEntryEvents),
6269
- lifecycle: (entries, options2) => ({
6270
- status: deriveTranscriptStatus(entries, options2),
6271
- asking: awaitsQuestionAnswer(entries)
6268
+ events: (entries2) => entries2.flatMap(claudeEntryEvents),
6269
+ lifecycle: (entries2, options2) => ({
6270
+ status: deriveTranscriptStatus(entries2, options2),
6271
+ asking: awaitsQuestionAnswer(entries2)
6272
6272
  }),
6273
6273
  fingerprint: transcriptTailFingerprint,
6274
6274
  unrecognised: claudeUnrecognisedShapes
@@ -7571,14 +7571,14 @@ async function discoverCodexRolloutPaths() {
7571
7571
  return collect(codexSessionsDir(), DATE_DEPTH);
7572
7572
  }
7573
7573
  async function collect(dir, depth) {
7574
- let entries;
7574
+ let entries2;
7575
7575
  try {
7576
- entries = await fs8.promises.readdir(dir, { withFileTypes: true });
7576
+ entries2 = await fs8.promises.readdir(dir, { withFileTypes: true });
7577
7577
  } catch {
7578
7578
  return [];
7579
7579
  }
7580
7580
  const nested = await Promise.all(
7581
- entries.map((entry) => collectEntry(dir, entry, depth))
7581
+ entries2.map((entry) => collectEntry(dir, entry, depth))
7582
7582
  );
7583
7583
  return nested.flat();
7584
7584
  }
@@ -7605,13 +7605,13 @@ function findCodexRolloutPathSync(sessionId2) {
7605
7605
  return findRollout(codexSessionsDir(), DATE_DEPTH2, `-${sessionId2}.jsonl`);
7606
7606
  }
7607
7607
  function findRollout(dir, depth, suffix) {
7608
- let entries;
7608
+ let entries2;
7609
7609
  try {
7610
- entries = fs9.readdirSync(dir, { withFileTypes: true });
7610
+ entries2 = fs9.readdirSync(dir, { withFileTypes: true });
7611
7611
  } catch {
7612
7612
  return null;
7613
7613
  }
7614
- for (const entry of entries) {
7614
+ for (const entry of entries2) {
7615
7615
  const full = path14.join(dir, entry.name);
7616
7616
  if (entry.isDirectory()) {
7617
7617
  const found = depth > 0 ? findRollout(full, depth - 1, suffix) : null;
@@ -7754,15 +7754,15 @@ function turnEvent(entry) {
7754
7754
  if (kind === "task_started") return "started";
7755
7755
  return typeof kind === "string" && TURN_END_EVENTS.has(kind) ? "ended" : null;
7756
7756
  }
7757
- function hasAgentActivity(entries) {
7758
- return entries.some((entry) => entry.type === "response_item");
7757
+ function hasAgentActivity(entries2) {
7758
+ return entries2.some((entry) => entry.type === "response_item");
7759
7759
  }
7760
- function deriveCodexRolloutStatus(entries) {
7761
- for (let i = entries.length - 1; i >= 0; i--) {
7762
- const event = turnEvent(entries[i]);
7760
+ function deriveCodexRolloutStatus(entries2) {
7761
+ for (let i = entries2.length - 1; i >= 0; i--) {
7762
+ const event = turnEvent(entries2[i]);
7763
7763
  if (event) return event === "started" ? "running" : "waiting";
7764
7764
  }
7765
- return hasAgentActivity(entries) ? "running" : null;
7765
+ return hasAgentActivity(entries2) ? "running" : null;
7766
7766
  }
7767
7767
 
7768
7768
  // src/shared/harnessAdapters/codexCompletedToolEvents.ts
@@ -8056,10 +8056,10 @@ function codexEntryShape(entry) {
8056
8056
  }
8057
8057
 
8058
8058
  // src/shared/harnessAdapters/codexUnrecognisedShapes.ts
8059
- function codexUnrecognisedShapes(entries) {
8059
+ function codexUnrecognisedShapes(entries2) {
8060
8060
  return [
8061
8061
  ...new Set(
8062
- entries.map(codexEntryShape).filter((shape) => shape !== void 0)
8062
+ entries2.map(codexEntryShape).filter((shape) => shape !== void 0)
8063
8063
  )
8064
8064
  ];
8065
8065
  }
@@ -8072,9 +8072,9 @@ function entryEvents(entry) {
8072
8072
  if (entry.type === "response_item") return codexToolEvents(payload, at2);
8073
8073
  return [];
8074
8074
  }
8075
- function fingerprint2(entries) {
8076
- for (let i = entries.length - 1; i >= 0; i--) {
8077
- const entry = entries[i];
8075
+ function fingerprint2(entries2) {
8076
+ for (let i = entries2.length - 1; i >= 0; i--) {
8077
+ const entry = entries2[i];
8078
8078
  if (entry.type !== "event_msg" && entry.type !== "response_item") continue;
8079
8079
  const payload = rolloutPayload(entry);
8080
8080
  return [
@@ -8092,9 +8092,9 @@ var codexConversationReader = {
8092
8092
  const path128 = codexConversationReader.locate(ref);
8093
8093
  return path128 ? { dir: dirname8(path128), file: basename6(path128) } : null;
8094
8094
  },
8095
- events: (entries) => entries.flatMap(entryEvents),
8096
- lifecycle: (entries) => ({
8097
- status: deriveCodexRolloutStatus(entries),
8095
+ events: (entries2) => entries2.flatMap(entryEvents),
8096
+ lifecycle: (entries2) => ({
8097
+ status: deriveCodexRolloutStatus(entries2),
8098
8098
  asking: false
8099
8099
  }),
8100
8100
  fingerprint: fingerprint2,
@@ -8870,8 +8870,8 @@ async function targetConversationEvents(cwd, target) {
8870
8870
  if (!lookup.readable || !lookup.conversation) return [];
8871
8871
  const filePath = lookup.reader.locate(ref) ?? await adapter.conversation.locate(target.conversationId);
8872
8872
  if (!filePath) return [];
8873
- const entries = await readTranscriptTail(filePath, Number.POSITIVE_INFINITY);
8874
- return lookup.reader.events(entries);
8873
+ const entries2 = await readTranscriptTail(filePath, Number.POSITIVE_INFINITY);
8874
+ return lookup.reader.events(entries2);
8875
8875
  }
8876
8876
 
8877
8877
  // src/commands/sessions/web/parseTranscriptCommitShas.ts
@@ -10026,9 +10026,9 @@ function scalarConfigNode(inner, base) {
10026
10026
  };
10027
10027
  }
10028
10028
  function enumValues(node) {
10029
- const entries = node.def?.entries;
10030
- if (!entries) return void 0;
10031
- return Object.values(entries).filter(
10029
+ const entries2 = node.def?.entries;
10030
+ if (!entries2) return void 0;
10031
+ return Object.values(entries2).filter(
10032
10032
  (value) => typeof value === "string"
10033
10033
  );
10034
10034
  }
@@ -11159,14 +11159,18 @@ function isGlobalOnlyConfigKey(key) {
11159
11159
  }
11160
11160
 
11161
11161
  // src/commands/config/isNodeOnlyConfigKey.ts
11162
+ var NODE_ONLY_KEYS = ["inbox.intervalMinutes"];
11163
+ var NODE_ONLY_ROOTS = ["database", "repos"];
11162
11164
  function isNodeOnlyConfigKey(key) {
11163
- return isGlobalOnlyConfigKey(key) || key.split(".")[0] === "repos";
11165
+ return NODE_ONLY_KEYS.some((k) => key.startsWith(k)) || NODE_ONLY_ROOTS.includes(key.split(".")[0]);
11164
11166
  }
11165
11167
 
11166
11168
  // src/commands/config/configWritableScopes.ts
11167
11169
  function configWritableScopes(key) {
11168
- if (isGlobalOnlyConfigKey(key)) return ["global"];
11169
- if (isNodeOnlyConfigKey(key)) return ["project", "repo", "global"];
11170
+ const nodeOnly = isNodeOnlyConfigKey(key);
11171
+ if (isGlobalOnlyConfigKey(key))
11172
+ return nodeOnly ? ["global"] : ["global", "user"];
11173
+ if (nodeOnly) return ["project", "repo", "global"];
11170
11174
  return void 0;
11171
11175
  }
11172
11176
 
@@ -11323,11 +11327,11 @@ function dbBackedEntry(entry, value) {
11323
11327
  writableScopes: ["user"]
11324
11328
  };
11325
11329
  }
11326
- async function withDbBackedConfigEntries(entries) {
11327
- if (dbBackedKeysIn().length === 0) return entries;
11330
+ async function withDbBackedConfigEntries(entries2) {
11331
+ if (dbBackedKeysIn().length === 0) return entries2;
11328
11332
  const db = await getDb();
11329
11333
  return Promise.all(
11330
- entries.map(
11334
+ entries2.map(
11331
11335
  async (entry) => isDbBackedConfigKey(entry.key) ? dbBackedEntry(entry, await dbBackedConfigKeys[entry.key].read(db)) : entry
11332
11336
  )
11333
11337
  );
@@ -11435,9 +11439,9 @@ function loadLinkedEntries(configPath, visited) {
11435
11439
  }
11436
11440
 
11437
11441
  // src/shared/resolveRunConfigs.ts
11438
- function resolveRunConfigs(entries, configDir) {
11442
+ function resolveRunConfigs(entries2, configDir) {
11439
11443
  const ctx = { rootConfigDir: configDir, visited: /* @__PURE__ */ new Set() };
11440
- return resolveRecursive(entries, configDir, ctx);
11444
+ return resolveRecursive(entries2, configDir, ctx);
11441
11445
  }
11442
11446
  function applyPrefix(configs, prefix2) {
11443
11447
  return configs.map((c) => ({ ...c, name: `${prefix2}:${c.name}` }));
@@ -11450,10 +11454,10 @@ function relativeToRoot(ctx, absolute2) {
11450
11454
  }
11451
11455
  function loadAndResolveLink(linkPath, configDir, ctx) {
11452
11456
  const configPath = findLinkedConfigPath(linkPath, configDir);
11453
- const entries = loadLinkedEntries(configPath, ctx.visited);
11457
+ const entries2 = loadLinkedEntries(configPath, ctx.visited);
11454
11458
  const defaultCwd = relativeToRoot(ctx, resolve7(configDir, linkPath));
11455
11459
  return setDefaultCwd(
11456
- resolveRecursive(entries, dirname10(configPath), ctx),
11460
+ resolveRecursive(entries2, dirname10(configPath), ctx),
11457
11461
  defaultCwd
11458
11462
  );
11459
11463
  }
@@ -11465,9 +11469,9 @@ function resolveEntry(entry, configDir, ctx) {
11465
11469
  if (isRunLink(entry)) return resolveLink(entry, configDir, ctx);
11466
11470
  return [resolveLocalCwd(entry, configDir, ctx)];
11467
11471
  }
11468
- function resolveRecursive(entries, configDir, ctx) {
11469
- if (!entries || entries.length === 0) return [];
11470
- const result = entries.flatMap((e) => resolveEntry(e, configDir, ctx));
11472
+ function resolveRecursive(entries2, configDir, ctx) {
11473
+ if (!entries2 || entries2.length === 0) return [];
11474
+ const result = entries2.flatMap((e) => resolveEntry(e, configDir, ctx));
11471
11475
  assertNoDuplicateRunNames(result);
11472
11476
  return result;
11473
11477
  }
@@ -13265,6 +13269,170 @@ function jiraSite(_req, res) {
13265
13269
  respondJson(res, 200, { site: config.site ?? null });
13266
13270
  }
13267
13271
 
13272
+ // src/commands/sessions/web/linkStatus/linkStatusSchema.ts
13273
+ import { z as z12 } from "zod";
13274
+ var NAME = /^[A-Za-z0-9_.-]+$/;
13275
+ var linkStatusSchema = z12.object({
13276
+ refs: z12.array(
13277
+ z12.object({
13278
+ owner: z12.string().regex(NAME),
13279
+ repo: z12.string().regex(NAME),
13280
+ number: z12.number().int().positive()
13281
+ })
13282
+ ).max(1e3)
13283
+ });
13284
+
13285
+ // src/commands/sessions/web/linkStatus/linkRefKey.ts
13286
+ function linkRefKey({ owner, repo, number }) {
13287
+ return `${owner}/${repo}#${number}`.toLowerCase();
13288
+ }
13289
+
13290
+ // src/commands/sessions/web/linkStatus/linkStateCache.ts
13291
+ var CACHE_TTL_MS3 = 5 * 6e4;
13292
+ var entries = /* @__PURE__ */ new Map();
13293
+ var linkStateCache = {
13294
+ get(key) {
13295
+ const hit = entries.get(key);
13296
+ if (!hit) return void 0;
13297
+ if (Date.now() - hit.at < CACHE_TTL_MS3) return hit.state;
13298
+ entries.delete(key);
13299
+ return void 0;
13300
+ },
13301
+ set(key, state) {
13302
+ entries.set(key, { at: Date.now(), state });
13303
+ },
13304
+ clear() {
13305
+ entries.clear();
13306
+ }
13307
+ };
13308
+
13309
+ // src/commands/sessions/web/linkStatus/fetchLinkStateChunks.ts
13310
+ var CHUNK_SIZE = 100;
13311
+ async function fetchLinkStateChunks(refs, query) {
13312
+ const resolved = /* @__PURE__ */ new Map();
13313
+ for (let start2 = 0; start2 < refs.length; start2 += CHUNK_SIZE) {
13314
+ const chunk2 = refs.slice(start2, start2 + CHUNK_SIZE);
13315
+ const states2 = await query(chunk2).catch(() => void 0);
13316
+ if (!states2) continue;
13317
+ chunk2.forEach((ref, i) => {
13318
+ const key = linkRefKey(ref);
13319
+ const state = states2[i] ?? null;
13320
+ resolved.set(key, state);
13321
+ linkStateCache.set(key, state);
13322
+ });
13323
+ }
13324
+ return resolved;
13325
+ }
13326
+
13327
+ // src/commands/sessions/web/linkStatus/queryLinkStates.ts
13328
+ import { execFile as execFile8 } from "child_process";
13329
+
13330
+ // src/commands/sessions/web/linkStatus/linkItemState.ts
13331
+ function issueState({ state, stateReason }) {
13332
+ if (state === "OPEN") return "issue-open";
13333
+ return stateReason === "NOT_PLANNED" || stateReason === "DUPLICATE" ? "issue-not-planned" : "issue-completed";
13334
+ }
13335
+ function pullState({ state, isDraft }) {
13336
+ if (state === "MERGED") return "pr-merged";
13337
+ if (state === "CLOSED") return "pr-closed";
13338
+ return isDraft ? "pr-draft" : "pr-open";
13339
+ }
13340
+ function linkItemState(item) {
13341
+ if (item?.__typename === "Issue") return issueState(item);
13342
+ if (item?.__typename === "PullRequest") return pullState(item);
13343
+ return null;
13344
+ }
13345
+
13346
+ // src/commands/sessions/web/linkStatus/linkStatusQuery.ts
13347
+ var ITEM_FIELDS = "__typename ... on Issue { state stateReason } ... on PullRequest { state isDraft }";
13348
+ function linkStatusQuery(refs) {
13349
+ const params = [];
13350
+ const fields = [];
13351
+ const variables = {};
13352
+ refs.forEach((ref, i) => {
13353
+ params.push(`$o${i}: String!, $r${i}: String!, $n${i}: Int!`);
13354
+ fields.push(
13355
+ `i${i}: repository(owner: $o${i}, name: $r${i}) { issueOrPullRequest(number: $n${i}) { ${ITEM_FIELDS} } }`
13356
+ );
13357
+ variables[`o${i}`] = ref.owner;
13358
+ variables[`r${i}`] = ref.repo;
13359
+ variables[`n${i}`] = ref.number;
13360
+ });
13361
+ return {
13362
+ query: `query(${params.join(", ")}) { ${fields.join(" ")} }`,
13363
+ variables
13364
+ };
13365
+ }
13366
+
13367
+ // src/commands/sessions/web/linkStatus/queryLinkStates.ts
13368
+ function runGraphql(input) {
13369
+ return new Promise((resolve36, reject) => {
13370
+ const child2 = execFile8(
13371
+ "gh",
13372
+ ["api", "graphql", "--input", "-"],
13373
+ { encoding: "utf8", windowsHide: true, maxBuffer: 16 * 1024 * 1024 },
13374
+ (error, stdout, stderr) => {
13375
+ try {
13376
+ const parsed = JSON.parse(stdout);
13377
+ if (parsed.data) return resolve36(parsed);
13378
+ } catch {
13379
+ }
13380
+ reject(error ?? new Error(stderr || "gh api graphql returned no data"));
13381
+ }
13382
+ );
13383
+ child2.stdin?.end(input);
13384
+ });
13385
+ }
13386
+ async function queryLinkStates(refs) {
13387
+ const response = await runGraphql(JSON.stringify(linkStatusQuery(refs)));
13388
+ return refs.map(
13389
+ (_, i) => linkItemState(response.data?.[`i${i}`]?.issueOrPullRequest)
13390
+ );
13391
+ }
13392
+
13393
+ // src/commands/sessions/web/linkStatus/resolveLinkStates.ts
13394
+ var inFlight2 = /* @__PURE__ */ new Map();
13395
+ function startFetch(refs, query) {
13396
+ if (refs.length === 0) return;
13397
+ const batch = fetchLinkStateChunks(refs, query);
13398
+ for (const ref of refs) {
13399
+ const key = linkRefKey(ref);
13400
+ const pending = batch.then((resolved) => resolved.get(key) ?? null);
13401
+ inFlight2.set(key, pending);
13402
+ void pending.finally(() => {
13403
+ if (inFlight2.get(key) === pending) inFlight2.delete(key);
13404
+ });
13405
+ }
13406
+ }
13407
+ async function resolveLinkStates(refs, query = queryLinkStates) {
13408
+ const unique = new Map(refs.map((ref) => [linkRefKey(ref), ref]));
13409
+ const toFetch = [...unique].filter(
13410
+ ([key]) => linkStateCache.get(key) === void 0 && !inFlight2.has(key)
13411
+ ).map(([, ref]) => ref);
13412
+ startFetch(toFetch, query);
13413
+ const states2 = {};
13414
+ await Promise.all(
13415
+ [...unique.keys()].map(async (key) => {
13416
+ const state = linkStateCache.get(key) ?? await inFlight2.get(key) ?? null;
13417
+ if (state) states2[key] = state;
13418
+ })
13419
+ );
13420
+ return states2;
13421
+ }
13422
+
13423
+ // src/commands/sessions/web/linkStatus/linkStatus.ts
13424
+ async function linkStatus(req, res) {
13425
+ allowExtensionOrigin(req, res);
13426
+ const parsed = linkStatusSchema.safeParse(
13427
+ await readJsonBody(req).catch(() => void 0)
13428
+ );
13429
+ if (!parsed.success) {
13430
+ respondJson(res, 400, { error: "Invalid link status body" });
13431
+ return;
13432
+ }
13433
+ respondJson(res, 200, { states: await resolveLinkStates(parsed.data.refs) });
13434
+ }
13435
+
13268
13436
  // src/commands/sessions/web/scoreFilePath.ts
13269
13437
  var BASENAME_WEIGHT = 1e3;
13270
13438
  var START_BONUS = 15;
@@ -13317,7 +13485,7 @@ function rankFilePaths(paths, query, limit) {
13317
13485
 
13318
13486
  // src/commands/sessions/web/listFiles.ts
13319
13487
  var MAX_RESULTS = 20;
13320
- var CACHE_TTL_MS3 = 5e3;
13488
+ var CACHE_TTL_MS4 = 5e3;
13321
13489
  var LS_FILES_MAX_BUFFER = 32 * 1024 * 1024;
13322
13490
  var fileListCache = /* @__PURE__ */ new Map();
13323
13491
  async function repoFiles(cwd) {
@@ -13329,7 +13497,7 @@ async function repoFiles(cwd) {
13329
13497
  { maxBuffer: LS_FILES_MAX_BUFFER }
13330
13498
  );
13331
13499
  const files = [...new Set(output.split(/\r?\n/).filter(Boolean))];
13332
- fileListCache.set(cwd, { files, expires: Date.now() + CACHE_TTL_MS3 });
13500
+ fileListCache.set(cwd, { files, expires: Date.now() + CACHE_TTL_MS4 });
13333
13501
  return files;
13334
13502
  }
13335
13503
  async function listFiles(req, res) {
@@ -13454,7 +13622,7 @@ async function fetchFeeds(urls, onProgress) {
13454
13622
  }
13455
13623
 
13456
13624
  // src/commands/sessions/web/listNewsItems.ts
13457
- var CACHE_TTL_MS4 = 15 * 6e4;
13625
+ var CACHE_TTL_MS5 = 15 * 6e4;
13458
13626
  var cache3;
13459
13627
  async function listNewsItems(_req, res) {
13460
13628
  const { orm } = await getReady();
@@ -13463,7 +13631,7 @@ async function listNewsItems(_req, res) {
13463
13631
  const now = Date.now();
13464
13632
  if (!cache3 || cache3.feedsKey !== feedsKey || cache3.expires <= now) {
13465
13633
  const items3 = fetchFeeds(urls);
13466
- cache3 = { feedsKey, expires: now + CACHE_TTL_MS4, items: items3 };
13634
+ cache3 = { feedsKey, expires: now + CACHE_TTL_MS5, items: items3 };
13467
13635
  items3.catch(() => {
13468
13636
  if (cache3?.items === items3) cache3 = void 0;
13469
13637
  });
@@ -13478,10 +13646,10 @@ function newsNavConfig(_req, res) {
13478
13646
  }
13479
13647
 
13480
13648
  // src/commands/sessions/web/releases/ghJson.ts
13481
- import { execFile as execFile8 } from "child_process";
13649
+ import { execFile as execFile9 } from "child_process";
13482
13650
  import { promisify as promisify8 } from "util";
13483
- var execFileAsync8 = promisify8(execFile8);
13484
- var CACHE_TTL_MS5 = 3e4;
13651
+ var execFileAsync8 = promisify8(execFile9);
13652
+ var CACHE_TTL_MS6 = 3e4;
13485
13653
  var cache4 = /* @__PURE__ */ new Map();
13486
13654
  function partialGraphqlData(error) {
13487
13655
  const stdout = error.stdout;
@@ -13511,7 +13679,7 @@ async function runGh(cwd, args) {
13511
13679
  function ghJson(cwd, args) {
13512
13680
  const key = [cwd, ...args].join("\0");
13513
13681
  const hit = cache4.get(key);
13514
- if (hit && Date.now() - hit.at < CACHE_TTL_MS5)
13682
+ if (hit && Date.now() - hit.at < CACHE_TTL_MS6)
13515
13683
  return hit.result;
13516
13684
  const result = runGh(cwd, args);
13517
13685
  cache4.set(key, { at: Date.now(), result });
@@ -14741,20 +14909,20 @@ async function failStaleJobRuns(db, { startedBefore, detail }) {
14741
14909
  }
14742
14910
 
14743
14911
  // src/commands/inbox/inboxConnectorRun.ts
14744
- import { z as z13 } from "zod";
14912
+ import { z as z14 } from "zod";
14745
14913
 
14746
14914
  // src/commands/inbox/inboxScanSchema.ts
14747
- import { z as z12 } from "zod";
14748
- var flaggedMessageSchema = z12.object({
14749
- source: z12.enum(["gmail", "slack"]),
14750
- messageId: z12.string().min(1),
14751
- sender: z12.string().min(1),
14752
- summary: z12.string().min(1),
14753
- link: z12.string().min(1),
14754
- receivedAt: z12.string().optional()
14915
+ import { z as z13 } from "zod";
14916
+ var flaggedMessageSchema = z13.object({
14917
+ source: z13.enum(["gmail", "slack"]),
14918
+ messageId: z13.string().min(1),
14919
+ sender: z13.string().min(1),
14920
+ summary: z13.string().min(1),
14921
+ link: z13.string().min(1),
14922
+ receivedAt: z13.string().optional()
14755
14923
  });
14756
- var inboxScanSchema = z12.object({
14757
- messages: z12.array(flaggedMessageSchema)
14924
+ var inboxScanSchema = z13.object({
14925
+ messages: z13.array(flaggedMessageSchema)
14758
14926
  });
14759
14927
 
14760
14928
  // src/commands/inbox/inboxConnectorRun.ts
@@ -14763,7 +14931,7 @@ async function inboxConnectorRun(adapter, prompt, tools, onEvent) {
14763
14931
  try {
14764
14932
  return await adapter.connectorRun({
14765
14933
  prompt,
14766
- schema: z13.toJSONSchema(inboxScanSchema, { target: "draft-07" }),
14934
+ schema: z14.toJSONSchema(inboxScanSchema, { target: "draft-07" }),
14767
14935
  tools,
14768
14936
  timeoutMs: INBOX_SCAN_TIMEOUT_MS,
14769
14937
  onEvent
@@ -14827,10 +14995,10 @@ async function openInCode(req, res) {
14827
14995
  }
14828
14996
 
14829
14997
  // src/commands/sessions/web/createCachedGhJson.ts
14830
- import { execFile as execFile9 } from "child_process";
14998
+ import { execFile as execFile10 } from "child_process";
14831
14999
  import { promisify as promisify10 } from "util";
14832
- var execFileAsync9 = promisify10(execFile9);
14833
- var CACHE_TTL_MS6 = 3e4;
15000
+ var execFileAsync9 = promisify10(execFile10);
15001
+ var CACHE_TTL_MS7 = 3e4;
14834
15002
  function createCachedGhJson(args, parse5, fallback, options2 = {}) {
14835
15003
  const { cacheFallback = true } = options2;
14836
15004
  const cache7 = /* @__PURE__ */ new Map();
@@ -14851,7 +15019,7 @@ function createCachedGhJson(args, parse5, fallback, options2 = {}) {
14851
15019
  value = fallback;
14852
15020
  }
14853
15021
  if (cacheFallback || value !== fallback)
14854
- cache7.set(key, { value, expires: now + CACHE_TTL_MS6 });
15022
+ cache7.set(key, { value, expires: now + CACHE_TTL_MS7 });
14855
15023
  return value;
14856
15024
  };
14857
15025
  }
@@ -14941,9 +15109,9 @@ async function previewImage(req, res) {
14941
15109
  }
14942
15110
 
14943
15111
  // src/commands/sessions/web/getCurrentBranch.ts
14944
- import { execFile as execFile10 } from "child_process";
15112
+ import { execFile as execFile11 } from "child_process";
14945
15113
  import { promisify as promisify11 } from "util";
14946
- var execFileAsync10 = promisify11(execFile10);
15114
+ var execFileAsync10 = promisify11(execFile11);
14947
15115
  async function getCurrentBranch(cwd) {
14948
15116
  try {
14949
15117
  const { stdout } = await execFileAsync10(
@@ -16766,7 +16934,7 @@ async function findAppId(client, bundleId) {
16766
16934
  }
16767
16935
 
16768
16936
  // src/commands/testflight/runOp.ts
16769
- import { execFile as execFile11 } from "child_process";
16937
+ import { execFile as execFile12 } from "child_process";
16770
16938
  import { promisify as promisify12 } from "util";
16771
16939
 
16772
16940
  // src/commands/testflight/cleanOpStderr.ts
@@ -16780,7 +16948,7 @@ function cleanOpStderr(stderr) {
16780
16948
  }
16781
16949
 
16782
16950
  // src/commands/testflight/runOp.ts
16783
- var run = promisify12(execFile11);
16951
+ var run = promisify12(execFile12);
16784
16952
  var runOp = async (args) => {
16785
16953
  try {
16786
16954
  const { stdout } = await run("op", args, { maxBuffer: 10 * 1024 * 1024 });
@@ -17169,14 +17337,18 @@ function restoreConfigWriteSecrets(key, value, cwd, globalConfigPath) {
17169
17337
  return restoreConfigSecrets(value, getNestedValue(stored, key), node);
17170
17338
  }
17171
17339
 
17340
+ // src/commands/config/notPerRepoKeyMessage.ts
17341
+ function notPerRepoKeyMessage(key, verb) {
17342
+ const where = isNodeOnlyConfigKey(key) ? "in user (node) with --node" : "in user (node) with --node or in user (db) with --user";
17343
+ return `"${key}" can't be stored per repo. ${verb} it ${where}`;
17344
+ }
17345
+
17172
17346
  // src/commands/config/applyConfigSet.ts
17173
17347
  function applyConfigSet(key, coerced, global, cwd = process.cwd(), globalConfigPath) {
17174
17348
  if (!global && isGlobalOnlyConfigKey(key)) {
17175
17349
  return {
17176
17350
  ok: false,
17177
- errors: [
17178
- `"${key}" is a user (node)-only key. Use --node to set it in ~/.assist.yml`
17179
- ]
17351
+ errors: [notPerRepoKeyMessage(key, "Set")]
17180
17352
  };
17181
17353
  }
17182
17354
  const raw = global ? loadGlobalConfigRaw(globalConfigPath) : loadProjectConfig(cwd);
@@ -17196,9 +17368,7 @@ function globalOnlyRepoKeyError(key, verb) {
17196
17368
  if (!isGlobalOnlyConfigKey(key)) return void 0;
17197
17369
  return {
17198
17370
  ok: false,
17199
- errors: [
17200
- `"${key}" is a user (node)-only key. ${verb} it in ~/.assist.yml with --node rather than in repo (db)`
17201
- ]
17371
+ errors: [notPerRepoKeyMessage(key, verb)]
17202
17372
  };
17203
17373
  }
17204
17374
 
@@ -17214,9 +17384,9 @@ var UnknownRepoConfigError = class extends Error {
17214
17384
  };
17215
17385
  function resolveNamedRepoWriteLabel(globalRaw, name2, source = "~/.assist.yml") {
17216
17386
  const repos2 = globalRaw.repos;
17217
- const entries = repos2 && typeof repos2 === "object" && !Array.isArray(repos2) ? repos2 : {};
17387
+ const entries2 = repos2 && typeof repos2 === "object" && !Array.isArray(repos2) ? repos2 : {};
17218
17388
  const candidates = originKeyCandidates(name2);
17219
- const matches = Object.keys(entries).filter((key) => candidates.has(key));
17389
+ const matches = Object.keys(entries2).filter((key) => candidates.has(key));
17220
17390
  if (matches.length === 0) {
17221
17391
  throw new UnknownRepoConfigError(
17222
17392
  `No repo in ${source} matches "${name2}". Use an existing repos key (full origin, org/repo, or bare repo name).`
@@ -17640,9 +17810,7 @@ function applyConfigUnset(key, global, cwd = process.cwd(), globalConfigPath) {
17640
17810
  if (!global && isGlobalOnlyConfigKey(key)) {
17641
17811
  return {
17642
17812
  ok: false,
17643
- errors: [
17644
- `"${key}" is a user (node)-only key. Use --node to unset it in ~/.assist.yml`
17645
- ]
17813
+ errors: [notPerRepoKeyMessage(key, "Unset")]
17646
17814
  };
17647
17815
  }
17648
17816
  const target = global ? "global" : "project";
@@ -18242,11 +18410,11 @@ async function uploadPrImage(req, res) {
18242
18410
  import { readFile as readFile3, stat as stat3, writeFile as writeFile2 } from "fs/promises";
18243
18411
 
18244
18412
  // src/commands/sessions/web/formatWithOxfmt.ts
18245
- import { execFile as execFile12 } from "child_process";
18413
+ import { execFile as execFile13 } from "child_process";
18246
18414
  import { existsSync as existsSync34 } from "fs";
18247
18415
  import { dirname as dirname18, join as join43 } from "path";
18248
18416
  import { promisify as promisify13 } from "util";
18249
- var execFileAsync11 = promisify13(execFile12);
18417
+ var execFileAsync11 = promisify13(execFile13);
18250
18418
  var TIMEOUT_MS2 = 15e3;
18251
18419
  function findOxfmtScript(root2) {
18252
18420
  let dir = root2;
@@ -18438,6 +18606,8 @@ var routes2 = {
18438
18606
  "OPTIONS /api/sessions/review-from-github": sessionFromGithubPreflight,
18439
18607
  "POST /api/sessions/docs-feedback": docsFeedback,
18440
18608
  "OPTIONS /api/sessions/docs-feedback": sessionFromGithubPreflight,
18609
+ "POST /api/link-status": linkStatus,
18610
+ "OPTIONS /api/link-status": sessionFromGithubPreflight,
18441
18611
  "POST /api/browser": browserRelay,
18442
18612
  "POST /api/client-errors": clientErrors,
18443
18613
  "POST /api/open-in-code": openInCode,
@@ -18999,7 +19169,7 @@ function repoDirExists(cwd) {
18999
19169
  }
19000
19170
 
19001
19171
  // src/commands/sessions/daemon/worktree/git.ts
19002
- import { execFile as execFile13, execFileSync as execFileSync6 } from "child_process";
19172
+ import { execFile as execFile14, execFileSync as execFileSync6 } from "child_process";
19003
19173
  function isWindowsPath(cwd) {
19004
19174
  return /^[A-Za-z]:[\\/]/.test(cwd);
19005
19175
  }
@@ -19019,7 +19189,7 @@ function gitInvocation(cwd, args) {
19019
19189
  function git2(cwd, args, timeout) {
19020
19190
  const { file, argv, options: options2 } = gitInvocation(cwd, args);
19021
19191
  return new Promise((resolve36, reject) => {
19022
- execFile13(file, argv, { ...options2, timeout }, (error, stdout) => {
19192
+ execFile14(file, argv, { ...options2, timeout }, (error, stdout) => {
19023
19193
  if (error) reject(error);
19024
19194
  else resolve36(stdout.toString());
19025
19195
  });
@@ -19342,8 +19512,8 @@ function toolStatus(pkg, scriptName, hasPackage, configScriptNames) {
19342
19512
  };
19343
19513
  }
19344
19514
  function loadConfigScriptNames() {
19345
- const entries = loadConfig().run ?? [];
19346
- return new Set(entries.flatMap((r) => "name" in r ? [r.name] : []));
19515
+ const entries2 = loadConfig().run ?? [];
19516
+ return new Set(entries2.flatMap((r) => "name" in r ? [r.name] : []));
19347
19517
  }
19348
19518
  function buildToolStatuses(pkg, configScriptNames) {
19349
19519
  const status2 = (script, has) => toolStatus(pkg, script, has, configScriptNames);
@@ -20159,11 +20329,11 @@ function matchesChangedFiles(entry, changedFiles2) {
20159
20329
  );
20160
20330
  return true;
20161
20331
  }
20162
- function filterByChangedFiles(entries) {
20332
+ function filterByChangedFiles(entries2) {
20163
20333
  const isGated = (e) => !!(e.filter || e.outsideRoots);
20164
- if (!entries.some(isGated)) return entries;
20334
+ if (!entries2.some(isGated)) return entries2;
20165
20335
  const changedFiles2 = getChangedFiles();
20166
- return entries.filter(
20336
+ return entries2.filter(
20167
20337
  (entry) => !isGated(entry) || matchesChangedFiles(entry, changedFiles2)
20168
20338
  );
20169
20339
  }
@@ -20254,12 +20424,12 @@ function resolveVerifyMode() {
20254
20424
 
20255
20425
  // src/commands/verify/run/selectEntriesForMode.ts
20256
20426
  var FIX_SUFFIX = ":fix";
20257
- function selectEntriesForMode(entries, mode) {
20427
+ function selectEntriesForMode(entries2, mode) {
20258
20428
  if (mode === "check") {
20259
- return entries.filter((e) => !e.name.endsWith(FIX_SUFFIX));
20429
+ return entries2.filter((e) => !e.name.endsWith(FIX_SUFFIX));
20260
20430
  }
20261
- const names = new Set(entries.map((e) => e.name));
20262
- return entries.filter((e) => !names.has(`${e.name}${FIX_SUFFIX}`));
20431
+ const names = new Set(entries2.map((e) => e.name));
20432
+ return entries2.filter((e) => !names.has(`${e.name}${FIX_SUFFIX}`));
20263
20433
  }
20264
20434
 
20265
20435
  // src/commands/verify/run/resolveEntries.ts
@@ -20380,9 +20550,9 @@ function exitIfFailed(failed3) {
20380
20550
  logFailedScripts(failed3);
20381
20551
  process.exit(1);
20382
20552
  }
20383
- async function runAllEntries(entries) {
20553
+ async function runAllEntries(entries2) {
20384
20554
  const startTime = Date.now();
20385
- const results = await Promise.all(entries.map((entry) => runEntry(entry)));
20555
+ const results = await Promise.all(entries2.map((entry) => runEntry(entry)));
20386
20556
  return { results, totalMs: Date.now() - startTime };
20387
20557
  }
20388
20558
  function handleResults(results, totalCount) {
@@ -20392,32 +20562,32 @@ All ${totalCount} verify command(s) passed`);
20392
20562
  }
20393
20563
 
20394
20564
  // src/commands/verify/run.ts
20395
- function printEntryList(entries) {
20396
- console.log(`Running ${entries.length} verify command(s) in parallel:`);
20397
- for (const entry of entries) {
20565
+ function printEntryList(entries2) {
20566
+ console.log(`Running ${entries2.length} verify command(s) in parallel:`);
20567
+ for (const entry of entries2) {
20398
20568
  console.log(` - ${entry.name}`);
20399
20569
  }
20400
20570
  }
20401
20571
  async function run2(options2 = {}) {
20402
20572
  setVerbose(!!options2.verbose);
20403
20573
  const allEntries = resolveEntries();
20404
- const entries = options2.all ? allEntries : filterByChangedFiles(allEntries);
20574
+ const entries2 = options2.all ? allEntries : filterByChangedFiles(allEntries);
20405
20575
  if (allEntries.length === 0) {
20406
20576
  console.log("No verify commands found");
20407
20577
  return;
20408
20578
  }
20409
- if (entries.length === 0) {
20579
+ if (entries2.length === 0) {
20410
20580
  console.log("No verify commands matched changed files \u2014 skipping");
20411
20581
  return;
20412
20582
  }
20413
- printEntryList(entries);
20583
+ printEntryList(entries2);
20414
20584
  const releaseVerifying = signalVerifying();
20415
20585
  try {
20416
- const { results, totalMs } = await runAllEntries(entries);
20586
+ const { results, totalMs } = await runAllEntries(entries2);
20417
20587
  if (options2.measure) {
20418
20588
  printMeasureTable(results, totalMs);
20419
20589
  }
20420
- handleResults(results, entries.length);
20590
+ handleResults(results, entries2.length);
20421
20591
  } finally {
20422
20592
  releaseVerifying();
20423
20593
  }
@@ -20807,19 +20977,19 @@ var documentedKeys = /* @__PURE__ */ new Set();
20807
20977
  function getDocumentedConfigKeys() {
20808
20978
  return documentedKeys;
20809
20979
  }
20810
- function renderConfigHelp(entries, preamble) {
20811
- const width2 = Math.max(...entries.map((entry) => entry.setter.length));
20812
- const lines = entries.map(
20980
+ function renderConfigHelp(entries2, preamble) {
20981
+ const width2 = Math.max(...entries2.map((entry) => entry.setter.length));
20982
+ const lines = entries2.map(
20813
20983
  (entry) => ` ${entry.setter.padEnd(width2)} # ${entry.note}`
20814
20984
  );
20815
20985
  const body = preamble ? ["", preamble, "", "Config:", ...lines] : ["", "Config:", ...lines];
20816
20986
  return body.join("\n");
20817
20987
  }
20818
- function configHelp(command, entries, preamble) {
20819
- for (const entry of entries) documentedKeys.add(entry.key);
20988
+ function configHelp(command, entries2, preamble) {
20989
+ for (const entry of entries2) documentedKeys.add(entry.key);
20820
20990
  return command.addHelpText(
20821
20991
  "after",
20822
- () => renderConfigHelp(entries, preamble)
20992
+ () => renderConfigHelp(entries2, preamble)
20823
20993
  );
20824
20994
  }
20825
20995
 
@@ -21433,12 +21603,12 @@ async function moveManualCheck(orm, item, fromIdx, checkIdx, toIdx) {
21433
21603
  }
21434
21604
 
21435
21605
  // src/commands/sessions/shared/askCheckInputSchema.ts
21436
- import { z as z14 } from "zod";
21437
- var text17 = z14.string().trim().min(1);
21438
- var askCheckInputSchema = z14.object({
21606
+ import { z as z15 } from "zod";
21607
+ var text17 = z15.string().trim().min(1);
21608
+ var askCheckInputSchema = z15.object({
21439
21609
  title: text17,
21440
- steps: z14.array(text17).min(1, "Give at least 1 step"),
21441
- before: z14.array(text17).optional(),
21610
+ steps: z15.array(text17).min(1, "Give at least 1 step"),
21611
+ before: z15.array(text17).optional(),
21442
21612
  changed: text17.optional()
21443
21613
  });
21444
21614
  var CHECK_RESULT_KEY = "result";
@@ -21829,23 +21999,23 @@ async function requireQuestionSession() {
21829
21999
  }
21830
22000
 
21831
22001
  // src/commands/sessions/shared/askQuestionInputSchema.ts
21832
- import { z as z15 } from "zod";
21833
- var askQuestionOptionSchema = z15.object({
21834
- label: z15.string().min(1),
21835
- description: z15.string(),
21836
- preview: z15.string().optional()
22002
+ import { z as z16 } from "zod";
22003
+ var askQuestionOptionSchema = z16.object({
22004
+ label: z16.string().min(1),
22005
+ description: z16.string(),
22006
+ preview: z16.string().optional()
21837
22007
  });
21838
- var askQuestionSchema = z15.object({
21839
- question: z15.string().min(1),
21840
- header: z15.string().min(1),
21841
- multiSelect: z15.boolean(),
21842
- options: z15.array(askQuestionOptionSchema).min(2, "Each question needs at least 2 options").max(4, "Each question allows at most 4 options").refine(
22008
+ var askQuestionSchema = z16.object({
22009
+ question: z16.string().min(1),
22010
+ header: z16.string().min(1),
22011
+ multiSelect: z16.boolean(),
22012
+ options: z16.array(askQuestionOptionSchema).min(2, "Each question needs at least 2 options").max(4, "Each question allows at most 4 options").refine(
21843
22013
  (options2) => new Set(options2.map((option) => option.label)).size === options2.length,
21844
22014
  "Option labels must be unique within a question"
21845
22015
  )
21846
22016
  });
21847
- var askQuestionInputSchema = z15.object({
21848
- questions: z15.array(askQuestionSchema).min(1, "Ask at least 1 question").max(4, "Ask at most 4 questions").refine(
22017
+ var askQuestionInputSchema = z16.object({
22018
+ questions: z16.array(askQuestionSchema).min(1, "Ask at least 1 question").max(4, "Ask at most 4 questions").refine(
21849
22019
  (questions) => new Set(questions.map((q) => q.question)).size === questions.length,
21850
22020
  "Question texts must be unique"
21851
22021
  )
@@ -22160,13 +22330,13 @@ function buildGraph(names, edges) {
22160
22330
  function nextReady(names, emitted, indegree) {
22161
22331
  return names.find((n) => !emitted.has(n) && (indegree.get(n) ?? 0) === 0);
22162
22332
  }
22163
- function topoSort(entries, edges) {
22164
- const names = entries.map((e) => e.raw);
22333
+ function topoSort(entries2, edges) {
22334
+ const names = entries2.map((e) => e.raw);
22165
22335
  const { indegree, children } = buildGraph(names, edges);
22166
- const byRaw = new Map(entries.map((e) => [e.raw, e.table]));
22336
+ const byRaw = new Map(entries2.map((e) => [e.raw, e.table]));
22167
22337
  const ordered = [];
22168
22338
  const emitted = /* @__PURE__ */ new Set();
22169
- while (ordered.length < entries.length) {
22339
+ while (ordered.length < entries2.length) {
22170
22340
  const next3 = nextReady(names, emitted, indegree);
22171
22341
  if (!next3)
22172
22342
  throw new Error("Cannot dump: foreign-key cycle between tables.");
@@ -22439,11 +22609,11 @@ async function locateConversation(conversationId) {
22439
22609
 
22440
22610
  // src/commands/sessions/shared/transcriptMessages.ts
22441
22611
  function transcriptMessages(reader, lines) {
22442
- const entries = lines.flatMap((line) => {
22612
+ const entries2 = lines.flatMap((line) => {
22443
22613
  const entry = line.trim() ? parseRolloutEntry(line) : null;
22444
22614
  return entry ? [entry] : [];
22445
22615
  });
22446
- return reader.events(entries).flatMap((event) => {
22616
+ return reader.events(entries2).flatMap((event) => {
22447
22617
  if (event.kind === "message")
22448
22618
  return [{ role: event.role, text: event.text }];
22449
22619
  if (event.kind === "tool")
@@ -22856,8 +23026,8 @@ async function comments2(id) {
22856
23026
  const found = await findOneItem(id);
22857
23027
  if (!found) process.exit(1);
22858
23028
  const { item } = found;
22859
- const entries = item.comments ?? [];
22860
- if (entries.length === 0) {
23029
+ const entries2 = item.comments ?? [];
23030
+ if (entries2.length === 0) {
22861
23031
  console.log(chalk52.dim(`No comments on item ${formatItemId(item.id)}.`));
22862
23032
  return;
22863
23033
  }
@@ -22865,7 +23035,7 @@ async function comments2(id) {
22865
23035
  chalk52.bold(`Comments for ${formatItemId(item.id)}: ${item.name}
22866
23036
  `)
22867
23037
  );
22868
- for (const entry of entries) {
23038
+ for (const entry of entries2) {
22869
23039
  console.log(`${formatComment(entry)}
22870
23040
  `);
22871
23041
  }
@@ -23430,21 +23600,21 @@ async function list(options2) {
23430
23600
  import chalk64 from "chalk";
23431
23601
 
23432
23602
  // src/commands/backlog/propose/proposedItemSchema.ts
23433
- import { z as z16 } from "zod";
23434
- var proposedPhaseSchema = z16.strictObject({
23435
- name: z16.string().trim().min(1, "phase name is required").refine(
23603
+ import { z as z17 } from "zod";
23604
+ var proposedPhaseSchema = z17.strictObject({
23605
+ name: z17.string().trim().min(1, "phase name is required").refine(
23436
23606
  (name2) => name2.toLowerCase() !== REVIEW_PHASE_NAME.toLowerCase(),
23437
23607
  `"${REVIEW_PHASE_NAME}" is owned by the runner and appended to every plan automatically \u2014 remove this phase`
23438
23608
  ),
23439
- tasks: z16.array(z16.string().trim().min(1)).min(1, "a phase needs at least one task"),
23440
- manualChecks: z16.array(z16.string().trim().min(1)).default([])
23609
+ tasks: z17.array(z17.string().trim().min(1)).min(1, "a phase needs at least one task"),
23610
+ manualChecks: z17.array(z17.string().trim().min(1)).default([])
23441
23611
  });
23442
- var proposedItemSchema = z16.strictObject({
23443
- name: z16.string().trim().min(1, "name is required"),
23444
- type: z16.enum(["story", "bug"]),
23445
- description: z16.string().optional(),
23446
- acceptanceCriteria: z16.array(z16.string().trim().min(1)).default([]),
23447
- phases: z16.array(proposedPhaseSchema).default([])
23612
+ var proposedItemSchema = z17.strictObject({
23613
+ name: z17.string().trim().min(1, "name is required"),
23614
+ type: z17.enum(["story", "bug"]),
23615
+ description: z17.string().optional(),
23616
+ acceptanceCriteria: z17.array(z17.string().trim().min(1)).default([]),
23617
+ phases: z17.array(proposedPhaseSchema).default([])
23448
23618
  });
23449
23619
 
23450
23620
  // src/commands/backlog/propose/readProposedItem.ts
@@ -25031,21 +25201,21 @@ async function persistPhaseSessionId(itemId2, phaseIdx, claudeSessionId) {
25031
25201
  import { mkdirSync as mkdirSync18, readFileSync as readFileSync36, rmSync as rmSync4, writeFileSync as writeFileSync27 } from "fs";
25032
25202
  import { homedir as homedir18 } from "os";
25033
25203
  import { dirname as dirname31, join as join63 } from "path";
25034
- import { z as z17 } from "zod";
25035
- var activitySchema = z17.object({
25036
- kind: z17.enum(["command", "backlog"]),
25037
- harness: z17.enum(["claude", "codex", "pi"]).optional(),
25038
- name: z17.string().optional(),
25039
- itemId: z17.number().optional(),
25040
- itemName: z17.string().optional(),
25041
- itemIds: z17.array(z17.number()).optional(),
25042
- phase: z17.number().optional(),
25043
- phaseName: z17.string().optional(),
25044
- totalPhases: z17.number().optional(),
25045
- claudeSessionId: z17.string().optional(),
25046
- harnessSessionId: z17.string().optional(),
25047
- watchState: z17.enum(["waiting", "updating"]).optional(),
25048
- startedAt: z17.number()
25204
+ import { z as z18 } from "zod";
25205
+ var activitySchema = z18.object({
25206
+ kind: z18.enum(["command", "backlog"]),
25207
+ harness: z18.enum(["claude", "codex", "pi"]).optional(),
25208
+ name: z18.string().optional(),
25209
+ itemId: z18.number().optional(),
25210
+ itemName: z18.string().optional(),
25211
+ itemIds: z18.array(z18.number()).optional(),
25212
+ phase: z18.number().optional(),
25213
+ phaseName: z18.string().optional(),
25214
+ totalPhases: z18.number().optional(),
25215
+ claudeSessionId: z18.string().optional(),
25216
+ harnessSessionId: z18.string().optional(),
25217
+ watchState: z18.enum(["waiting", "updating"]).optional(),
25218
+ startedAt: z18.number()
25049
25219
  });
25050
25220
  function activityPath(sessionId2) {
25051
25221
  return join63(homedir18(), ".assist", "activity", `activity-${sessionId2}.json`);
@@ -26495,9 +26665,9 @@ function registerUpdateFieldCommand(cmd) {
26495
26665
  import chalk114 from "chalk";
26496
26666
 
26497
26667
  // src/commands/backlog/updatePlan/planUpdateSchema.ts
26498
- import { z as z18 } from "zod";
26499
- var planUpdateSchema = z18.strictObject({
26500
- phases: z18.array(proposedPhaseSchema).min(1, "a plan needs at least one phase")
26668
+ import { z as z19 } from "zod";
26669
+ var planUpdateSchema = z19.strictObject({
26670
+ phases: z19.array(proposedPhaseSchema).min(1, "a plan needs at least one phase")
26501
26671
  });
26502
26672
 
26503
26673
  // src/commands/backlog/updatePlan/readPlanUpdate.ts
@@ -26983,10 +27153,10 @@ function printAcceptanceCriteria(criteria) {
26983
27153
  console.log();
26984
27154
  }
26985
27155
  function printComments(item) {
26986
- const entries = item.comments ?? [];
26987
- if (entries.length === 0) return;
27156
+ const entries2 = item.comments ?? [];
27157
+ if (entries2.length === 0) return;
26988
27158
  console.log(chalk120.bold("Comments"));
26989
- for (const entry of entries) {
27159
+ for (const entry of entries2) {
26990
27160
  console.log(` ${formatComment(entry)}`);
26991
27161
  }
26992
27162
  console.log();
@@ -27872,14 +28042,14 @@ function readSettingsPerms(key) {
27872
28042
  join64(process.cwd(), ".claude", "settings.json"),
27873
28043
  join64(process.cwd(), ".claude", "settings.local.json")
27874
28044
  ];
27875
- const entries = [];
28045
+ const entries2 = [];
27876
28046
  for (const p of paths) {
27877
- entries.push(...readPermissionArray(p, key));
28047
+ entries2.push(...readPermissionArray(p, key));
27878
28048
  }
27879
28049
  const harness = activeHarness();
27880
28050
  if (harness)
27881
- entries.push(...harnessAdapter(harness).permissionRules?.(key) ?? []);
27882
- return entries;
28051
+ entries2.push(...harnessAdapter(harness).permissionRules?.(key) ?? []);
28052
+ return entries2;
27883
28053
  }
27884
28054
  function readPermissionArray(filePath, key) {
27885
28055
  if (!existsSync56(filePath)) return [];
@@ -27912,9 +28082,9 @@ function shellEntries(map, toolName) {
27912
28082
  function normCmd(cmd) {
27913
28083
  return cmd.replace(FD_DEVNULL_RE2, "").replace(FD_REDIRECT_RE2, "").trim().replace(DOTSLASH_RE, "");
27914
28084
  }
27915
- function findMatch2(entries, command) {
28085
+ function findMatch2(entries2, command) {
27916
28086
  const norm = normCmd(command);
27917
- return entries.find(
28087
+ return entries2.find(
27918
28088
  (e) => e.wildcard ? norm === e.command || norm.startsWith(`${e.command} `) : norm === e.command
27919
28089
  )?.command;
27920
28090
  }
@@ -27926,9 +28096,9 @@ function matchesDeny(toolName, command) {
27926
28096
  if (!denyCache) denyCache = loadPerms("deny");
27927
28097
  return findMatch2(shellEntries(denyCache, toolName), command);
27928
28098
  }
27929
- function parsePerms(entries) {
28099
+ function parsePerms(entries2) {
27930
28100
  const map = /* @__PURE__ */ new Map();
27931
- for (const entry of entries) {
28101
+ for (const entry of entries2) {
27932
28102
  const m = entry.match(TOOL_RE);
27933
28103
  if (m) {
27934
28104
  const tool = m[1];
@@ -28925,14 +29095,14 @@ import { readdirSync as readdirSync11, statSync as statSync11, unlinkSync as unl
28925
29095
  import { join as join69 } from "path";
28926
29096
  var STALE_AFTER_MS = 30 * 60 * 1e3;
28927
29097
  function sweepRestrictedDir(dir = getRestrictedDir()) {
28928
- let entries;
29098
+ let entries2;
28929
29099
  try {
28930
- entries = readdirSync11(dir);
29100
+ entries2 = readdirSync11(dir);
28931
29101
  } catch {
28932
29102
  return;
28933
29103
  }
28934
29104
  const cutoff = Date.now() - STALE_AFTER_MS;
28935
- for (const entry of entries) {
29105
+ for (const entry of entries2) {
28936
29106
  const path128 = join69(dir, entry);
28937
29107
  try {
28938
29108
  if (statSync11(path128).mtimeMs < cutoff) unlinkSync8(path128);
@@ -30149,8 +30319,8 @@ function walkSourceFiles(dir, results) {
30149
30319
  return;
30150
30320
  }
30151
30321
  const extensions = [".ts", ".tsx"];
30152
- const entries = fs29.readdirSync(dir, { withFileTypes: true });
30153
- for (const entry of entries) {
30322
+ const entries2 = fs29.readdirSync(dir, { withFileTypes: true });
30323
+ for (const entry of entries2) {
30154
30324
  const fullPath = path44.join(dir, entry.name);
30155
30325
  if (entry.isDirectory()) {
30156
30326
  if (entry.name !== "node_modules" && entry.name !== ".git") {
@@ -31568,14 +31738,14 @@ function formatTime(time) {
31568
31738
  var indent2 = (text18, prefix2) => text18.split("\n").map((line) => `${prefix2}${line}`);
31569
31739
  function formatConsoleEntries({
31570
31740
  recording,
31571
- entries
31741
+ entries: entries2
31572
31742
  }) {
31573
31743
  if (!recording)
31574
31744
  return [
31575
31745
  `console recording is off; tick "Record console warnings and errors" on the assist extension's options page`
31576
31746
  ];
31577
- if (entries.length === 0) return ["no console entries match"];
31578
- return entries.flatMap((entry) => [
31747
+ if (entries2.length === 0) return ["no console entries match"];
31748
+ return entries2.flatMap((entry) => [
31579
31749
  `${formatTime(entry.time)} ${entry.level} ${entry.url}`,
31580
31750
  ...indent2(entry.message, " "),
31581
31751
  ...entry.stack ? indent2(entry.stack, " ") : []
@@ -32921,30 +33091,30 @@ import { dirname as dirname36 } from "path";
32921
33091
  import chalk172 from "chalk";
32922
33092
 
32923
33093
  // src/commands/devlog/write/devEntryInputSchema.ts
32924
- import { z as z19 } from "zod";
32925
- var oneLine = z19.string().trim().min(1).refine((value) => !value.includes("\n"), "must be a single line");
32926
- var isoDate = z19.string().regex(/^\d{4}-\d{2}-\d{2}$/, "must be a date like 2026-08-10");
33094
+ import { z as z20 } from "zod";
33095
+ var oneLine = z20.string().trim().min(1).refine((value) => !value.includes("\n"), "must be a single line");
33096
+ var isoDate = z20.string().regex(/^\d{4}-\d{2}-\d{2}$/, "must be a date like 2026-08-10");
32927
33097
  var MAX_ITEM_LENGTH = 80;
32928
33098
  var itemText = oneLine.refine(
32929
33099
  (value) => value.length <= MAX_ITEM_LENGTH,
32930
33100
  `must be a short changelog phrase (at most ${MAX_ITEM_LENGTH} characters)`
32931
33101
  );
32932
- var changeItems = z19.array(z19.object({ text: itemText, version: oneLine.optional() }).strict()).default([]);
33102
+ var changeItems = z20.array(z20.object({ text: itemText, version: oneLine.optional() }).strict()).default([]);
32933
33103
  function datesWithinWeek(week, dates) {
32934
33104
  if (!isValidWeek(week)) return true;
32935
33105
  const { start: start2, end } = isoWeekRange(week);
32936
33106
  return start2 <= dates.first && dates.first <= dates.last && dates.last <= end;
32937
33107
  }
32938
- var devEntryInputSchema = z19.object({
32939
- week: z19.string().refine(isValidWeek, "must be an ISO week like 2026-W33"),
33108
+ var devEntryInputSchema = z20.object({
33109
+ week: z20.string().refine(isValidWeek, "must be an ISO week like 2026-W33"),
32940
33110
  title: oneLine,
32941
- dates: z19.object({ first: isoDate, last: isoDate }).strict(),
32942
- versions: z19.object({ first: oneLine, last: oneLine }).strict().optional(),
33111
+ dates: z20.object({ first: isoDate, last: isoDate }).strict(),
33112
+ versions: z20.object({ first: oneLine, last: oneLine }).strict().optional(),
32943
33113
  aiGenerated: oneLine,
32944
33114
  added: changeItems,
32945
33115
  changed: changeItems,
32946
33116
  fixed: changeItems,
32947
- lede: z19.string().trim().min(1)
33117
+ lede: z20.string().trim().min(1)
32948
33118
  }).strict().refine((entry) => datesWithinWeek(entry.week, entry.dates), {
32949
33119
  message: "first and last must be in order and within the week",
32950
33120
  path: ["dates"]
@@ -33582,17 +33752,17 @@ function isLockedDll(debugDir) {
33582
33752
  return null;
33583
33753
  }
33584
33754
  function findFirstLockedDll(dir) {
33585
- let entries;
33755
+ let entries2;
33586
33756
  try {
33587
- entries = readdirSync14(dir);
33757
+ entries2 = readdirSync14(dir);
33588
33758
  } catch {
33589
33759
  return null;
33590
33760
  }
33591
- if (entries.includes("bin")) {
33761
+ if (entries2.includes("bin")) {
33592
33762
  const locked = isLockedDll(join85(dir, "bin", "Debug"));
33593
33763
  if (locked) return locked;
33594
33764
  }
33595
- for (const entry of entries) {
33765
+ for (const entry of entries2) {
33596
33766
  if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
33597
33767
  continue;
33598
33768
  const found = findFirstLockedDll(join85(dir, entry));
@@ -33669,13 +33839,13 @@ import path49 from "path";
33669
33839
  function findSlnFiles(dir, maxDepth, depth = 0) {
33670
33840
  if (depth > maxDepth) return [];
33671
33841
  const results = [];
33672
- let entries;
33842
+ let entries2;
33673
33843
  try {
33674
- entries = readdirSync15(dir);
33844
+ entries2 = readdirSync15(dir);
33675
33845
  } catch {
33676
33846
  return results;
33677
33847
  }
33678
- for (const entry of entries) {
33848
+ for (const entry of entries2) {
33679
33849
  if (entry.startsWith(".") || entry === "node_modules" || entry === "packages")
33680
33850
  continue;
33681
33851
  const full = path49.join(dir, entry);
@@ -35386,11 +35556,11 @@ function orderDepthFirst(issues) {
35386
35556
  function buildFixStructurePlan(issues, options2) {
35387
35557
  const context = { ...options2, stripLabels: options2.stripLabels ?? [] };
35388
35558
  const byId = new Map(issues.map((issue) => [issue.id, issue]));
35389
- const entries = [];
35559
+ const entries2 = [];
35390
35560
  const tooDeep = [];
35391
35561
  for (const issue of orderDepthFirst(issues)) {
35392
35562
  const entry = buildPlanEntry(issue, context);
35393
- entries.push(entry);
35563
+ entries2.push(entry);
35394
35564
  if (entry.level === null) {
35395
35565
  tooDeep.push({
35396
35566
  issue,
@@ -35399,10 +35569,10 @@ function buildFixStructurePlan(issues, options2) {
35399
35569
  }
35400
35570
  }
35401
35571
  return {
35402
- entries,
35572
+ entries: entries2,
35403
35573
  tooDeep,
35404
- typeChangeCount: entries.filter((entry) => entry.typeChange).length,
35405
- labelRemovalCount: entries.reduce(
35574
+ typeChangeCount: entries2.filter((entry) => entry.typeChange).length,
35575
+ labelRemovalCount: entries2.reduce(
35406
35576
  (total2, entry) => total2 + entry.labelRemovals.length,
35407
35577
  0
35408
35578
  )
@@ -37163,12 +37333,12 @@ function truncate2(text18) {
37163
37333
  }
37164
37334
 
37165
37335
  // src/commands/inbox/parseInboxScanOutput.ts
37166
- import { z as z20 } from "zod";
37336
+ import { z as z21 } from "zod";
37167
37337
  function parseInboxScanOutput(output) {
37168
37338
  const parsed = inboxScanSchema.safeParse(output);
37169
37339
  if (!parsed.success)
37170
37340
  throw new Error(
37171
- `Inbox scan returned malformed output: ${z20.prettifyError(parsed.error)}`
37341
+ `Inbox scan returned malformed output: ${z21.prettifyError(parsed.error)}`
37172
37342
  );
37173
37343
  return parsed.data.messages;
37174
37344
  }
@@ -37771,41 +37941,41 @@ function stringOrUndefined(value) {
37771
37941
  }
37772
37942
 
37773
37943
  // src/commands/sessions/daemon/persistedSessionSchema.ts
37774
- import { z as z21 } from "zod";
37775
- var persistedSessionSchema = z21.object({
37776
- id: z21.string().optional(),
37777
- name: z21.string(),
37778
- title: z21.string().optional(),
37779
- generatedTitle: z21.string().optional(),
37780
- subtitle: z21.string().optional(),
37781
- commandType: z21.enum(["claude", "run", "assist"]),
37782
- harness: z21.enum(["claude", "codex", "pi"]).optional(),
37783
- status: z21.enum(["running", "waiting", "done", "error", "stopped"]).optional(),
37784
- error: z21.string().optional(),
37785
- cwd: z21.string(),
37786
- startedAt: z21.number(),
37787
- runningMs: z21.number().optional(),
37788
- claudeSessionId: z21.string().optional(),
37789
- harnessSessionId: z21.string().optional(),
37790
- initialPrompt: z21.string().optional(),
37791
- runName: z21.string().optional(),
37792
- runArgs: z21.array(z21.string()).optional(),
37793
- assistArgs: z21.array(z21.string()).optional(),
37944
+ import { z as z22 } from "zod";
37945
+ var persistedSessionSchema = z22.object({
37946
+ id: z22.string().optional(),
37947
+ name: z22.string(),
37948
+ title: z22.string().optional(),
37949
+ generatedTitle: z22.string().optional(),
37950
+ subtitle: z22.string().optional(),
37951
+ commandType: z22.enum(["claude", "run", "assist"]),
37952
+ harness: z22.enum(["claude", "codex", "pi"]).optional(),
37953
+ status: z22.enum(["running", "waiting", "done", "error", "stopped"]).optional(),
37954
+ error: z22.string().optional(),
37955
+ cwd: z22.string(),
37956
+ startedAt: z22.number(),
37957
+ runningMs: z22.number().optional(),
37958
+ claudeSessionId: z22.string().optional(),
37959
+ harnessSessionId: z22.string().optional(),
37960
+ initialPrompt: z22.string().optional(),
37961
+ runName: z22.string().optional(),
37962
+ runArgs: z22.array(z22.string()).optional(),
37963
+ assistArgs: z22.array(z22.string()).optional(),
37794
37964
  activity: activitySchema.optional(),
37795
- starred: z21.boolean().optional(),
37796
- watcher: z21.boolean().optional(),
37797
- divergenceEscalation: z21.boolean().optional(),
37798
- design: z21.boolean().optional(),
37799
- auto: z21.boolean().optional(),
37800
- model: z21.string().optional(),
37801
- autoAdvance: z21.boolean().optional(),
37802
- autoApprove: z21.boolean().optional(),
37803
- reviewStarted: z21.boolean().optional(),
37804
- launchedFrom: z21.string().optional(),
37805
- pendingPrompts: z21.array(z21.string()).optional(),
37806
- interrupted: z21.object({ reason: z21.string(), at: z21.number() }).optional(),
37807
- awaitingSeed: z21.boolean().optional(),
37808
- undurable: z21.object({ reason: z21.string(), removesTree: z21.boolean().optional() }).optional()
37965
+ starred: z22.boolean().optional(),
37966
+ watcher: z22.boolean().optional(),
37967
+ divergenceEscalation: z22.boolean().optional(),
37968
+ design: z22.boolean().optional(),
37969
+ auto: z22.boolean().optional(),
37970
+ model: z22.string().optional(),
37971
+ autoAdvance: z22.boolean().optional(),
37972
+ autoApprove: z22.boolean().optional(),
37973
+ reviewStarted: z22.boolean().optional(),
37974
+ launchedFrom: z22.string().optional(),
37975
+ pendingPrompts: z22.array(z22.string()).optional(),
37976
+ interrupted: z22.object({ reason: z22.string(), at: z22.number() }).optional(),
37977
+ awaitingSeed: z22.boolean().optional(),
37978
+ undurable: z22.object({ reason: z22.string(), removesTree: z22.boolean().optional() }).optional()
37809
37979
  });
37810
37980
 
37811
37981
  // src/commands/sessions/daemon/toPersistedSession.ts
@@ -37977,7 +38147,7 @@ function quoteForPosixShell(value) {
37977
38147
  }
37978
38148
 
37979
38149
  // src/commands/sessions/daemon/worktree/stopInstall.ts
37980
- import { execFile as execFile14 } from "child_process";
38150
+ import { execFile as execFile15 } from "child_process";
37981
38151
  var running2 = /* @__PURE__ */ new Map();
37982
38152
  function trackInstall(worktreePath, child2) {
37983
38153
  const children = running2.get(worktreePath) ?? /* @__PURE__ */ new Set();
@@ -38003,7 +38173,7 @@ function stopInstall(worktreePath) {
38003
38173
  }
38004
38174
  function killTree(pid) {
38005
38175
  if (process.platform === "win32") {
38006
- execFile14(
38176
+ execFile15(
38007
38177
  "taskkill",
38008
38178
  ["/T", "/F", "/PID", String(pid)],
38009
38179
  { windowsHide: true },
@@ -38911,11 +39081,11 @@ function uniqueTexts(boxes) {
38911
39081
  // src/commands/miro/keptTexts.ts
38912
39082
  function warnUnmatched(file, unmatched) {
38913
39083
  if (unmatched.length === 0) return;
38914
- const entries = unmatched.map((entry) => ` - ${entry}`).join("\n");
39084
+ const entries2 = unmatched.map((entry) => ` - ${entry}`).join("\n");
38915
39085
  console.error(
38916
39086
  chalk208.yellow(
38917
39087
  `${unmatched.length} ${unmatched.length === 1 ? "entry" : "entries"} in ${file} matched no box text:
38918
- ${entries}`
39088
+ ${entries2}`
38919
39089
  )
38920
39090
  );
38921
39091
  }
@@ -39899,7 +40069,7 @@ function extractVoyagerPosts(body) {
39899
40069
  // src/commands/netcap/extractPostsFromCapture.ts
39900
40070
  function captureEntries(captureFile) {
39901
40071
  const lines = readFileSync62(captureFile, "utf8").split("\n").filter(Boolean);
39902
- const entries = [];
40072
+ const entries2 = [];
39903
40073
  for (const line of lines) {
39904
40074
  let entry;
39905
40075
  try {
@@ -39909,9 +40079,9 @@ function captureEntries(captureFile) {
39909
40079
  }
39910
40080
  if (typeof entry.url !== "string" || typeof entry.responseBody !== "string")
39911
40081
  continue;
39912
- entries.push({ url: entry.url, responseBody: entry.responseBody });
40082
+ entries2.push({ url: entry.url, responseBody: entry.responseBody });
39913
40083
  }
39914
- return entries;
40084
+ return entries2;
39915
40085
  }
39916
40086
  function dedupeByActivity(posts) {
39917
40087
  const byUrn = /* @__PURE__ */ new Map();
@@ -39928,9 +40098,9 @@ function dedupeByActivity(posts) {
39928
40098
  return [...byUrn.values(), ...noUrn];
39929
40099
  }
39930
40100
  function extractPostsFromCapture(captureFile) {
39931
- const entries = captureEntries(captureFile);
39932
- const rscBodies = entries.filter((e) => /rsc-action/.test(e.url)).map((e) => e.responseBody);
39933
- const voyagerBodies = entries.filter((e) => /voyagerFeedDashProfileUpdates/.test(e.url)).map((e) => e.responseBody);
40101
+ const entries2 = captureEntries(captureFile);
40102
+ const rscBodies = entries2.filter((e) => /rsc-action/.test(e.url)).map((e) => e.responseBody);
40103
+ const voyagerBodies = entries2.filter((e) => /voyagerFeedDashProfileUpdates/.test(e.url)).map((e) => e.responseBody);
39934
40104
  const author = rscBodies.map(findAuthorSlug).find(Boolean);
39935
40105
  const all = [
39936
40106
  ...rscBodies.flatMap((body) => extractLinkedInPosts(body, author)),
@@ -40381,13 +40551,13 @@ import { join as join98 } from "path";
40381
40551
  var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
40382
40552
  function removeStaleCommentsCaches(cwd = process.cwd()) {
40383
40553
  const dir = join98(cwd, ".assist");
40384
- let entries;
40554
+ let entries2;
40385
40555
  try {
40386
- entries = readdirSync18(dir);
40556
+ entries2 = readdirSync18(dir);
40387
40557
  } catch {
40388
40558
  return;
40389
40559
  }
40390
- for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
40560
+ for (const entry of entries2.filter((e) => STALE_PATTERN.test(e))) {
40391
40561
  unlinkSync16(join98(dir, entry));
40392
40562
  }
40393
40563
  }
@@ -43067,9 +43237,7 @@ async function writeConfigKeys(writes, scope, cwd = process.cwd()) {
43067
43237
  if (globalOnly.length > 0) {
43068
43238
  return {
43069
43239
  ok: false,
43070
- errors: globalOnly.map(
43071
- (write2) => `"${write2.key}" is a user (node)-only key. Set it with 'assist config set ${write2.key} <value> --node'`
43072
- )
43240
+ errors: globalOnly.map((write2) => notPerRepoKeyMessage(write2.key, "Set"))
43073
43241
  };
43074
43242
  }
43075
43243
  if (scope === "repo") return writeRepoBlock(writes, cwd);
@@ -43244,8 +43412,8 @@ function findSourceFiles2(dir, options2 = {}) {
43244
43412
  if (!fs35.existsSync(dir)) {
43245
43413
  return results;
43246
43414
  }
43247
- const entries = fs35.readdirSync(dir, { withFileTypes: true });
43248
- for (const entry of entries) {
43415
+ const entries2 = fs35.readdirSync(dir, { withFileTypes: true });
43416
+ for (const entry of entries2) {
43249
43417
  const fullPath = path54.join(dir, entry.name);
43250
43418
  if (entry.isDirectory() && entry.name !== "node_modules") {
43251
43419
  results.push(...findSourceFiles2(fullPath, options2));
@@ -44195,14 +44363,14 @@ function parseRefactorYml() {
44195
44363
  return [];
44196
44364
  }
44197
44365
  const content = fs42.readFileSync(REFACTOR_YML_PATH, "utf8");
44198
- const entries = [];
44366
+ const entries2 = [];
44199
44367
  const lines = content.split("\n");
44200
44368
  let currentEntry = {};
44201
44369
  for (const line of lines) {
44202
44370
  const trimmed = line.trim();
44203
44371
  if (trimmed.startsWith("- file:")) {
44204
44372
  if (currentEntry.file) {
44205
- entries.push(currentEntry);
44373
+ entries2.push(currentEntry);
44206
44374
  }
44207
44375
  currentEntry = { file: trimmed.replace("- file:", "").trim() };
44208
44376
  } else if (trimmed.startsWith("maxLines:")) {
@@ -44213,13 +44381,13 @@ function parseRefactorYml() {
44213
44381
  }
44214
44382
  }
44215
44383
  if (currentEntry.file) {
44216
- entries.push(currentEntry);
44384
+ entries2.push(currentEntry);
44217
44385
  }
44218
- return entries;
44386
+ return entries2;
44219
44387
  }
44220
44388
  function getIgnoredFiles() {
44221
- const entries = parseRefactorYml();
44222
- return new Map(entries.map((e) => [e.file, e.maxLines]));
44389
+ const entries2 = parseRefactorYml();
44390
+ return new Map(entries2.map((e) => [e.file, e.maxLines]));
44223
44391
  }
44224
44392
 
44225
44393
  // src/commands/refactor/check/getViolations.ts
@@ -46139,11 +46307,11 @@ function insert(root2, parts2) {
46139
46307
  }
46140
46308
  }
46141
46309
  function render(node, indent4, lines) {
46142
- const entries = [...node].sort(([a, ca], [b, cb]) => {
46310
+ const entries2 = [...node].sort(([a, ca], [b, cb]) => {
46143
46311
  const dirFirst = Number(cb.size > 0) - Number(ca.size > 0);
46144
46312
  return dirFirst || a.localeCompare(b);
46145
46313
  });
46146
- for (const [name2, child2] of entries) {
46314
+ for (const [name2, child2] of entries2) {
46147
46315
  lines.push(`${indent4}${name2}${child2.size > 0 ? "/" : ""}`);
46148
46316
  render(child2, `${indent4} `, lines);
46149
46317
  }
@@ -47190,21 +47358,21 @@ function readJsonFile(path128) {
47190
47358
  }
47191
47359
 
47192
47360
  // src/commands/review/highLevel/parseHighLevelSlicesInput.ts
47193
- import { z as z22 } from "zod";
47194
- var slicesSchema = z22.array(
47195
- z22.object({
47196
- title: z22.string().min(1),
47197
- summary: z22.string(),
47198
- hunks: z22.array(z22.string())
47361
+ import { z as z23 } from "zod";
47362
+ var slicesSchema = z23.array(
47363
+ z23.object({
47364
+ title: z23.string().min(1),
47365
+ summary: z23.string(),
47366
+ hunks: z23.array(z23.string())
47199
47367
  })
47200
47368
  );
47201
- var manualTestingSchema = z22.object({
47202
- setup: z22.array(z22.string()),
47203
- steps: z22.array(z22.object({ action: z22.string(), expect: z22.string() }))
47369
+ var manualTestingSchema = z23.object({
47370
+ setup: z23.array(z23.string()),
47371
+ steps: z23.array(z23.object({ action: z23.string(), expect: z23.string() }))
47204
47372
  });
47205
- var slicesInputSchema = z22.union([
47373
+ var slicesInputSchema = z23.union([
47206
47374
  slicesSchema.transform((slices) => ({ slices })),
47207
- z22.object({ slices: slicesSchema, manualTesting: manualTestingSchema })
47375
+ z23.object({ slices: slicesSchema, manualTesting: manualTestingSchema })
47208
47376
  ]);
47209
47377
  function parseHighLevelSlicesInput(raw) {
47210
47378
  const parsed = slicesInputSchema.safeParse(raw);
@@ -48272,8 +48440,8 @@ function refreshElapsedText(entry) {
48272
48440
  const seconds = Math.round((Date.now() - entry.elapsedStart) / 1e3);
48273
48441
  entry.text = `${entry.elapsedPrefix ?? "elapsed"}: ${seconds}s`;
48274
48442
  }
48275
- function renderEntries(entries, frame) {
48276
- const sorted2 = [...entries].sort(
48443
+ function renderEntries(entries2, frame) {
48444
+ const sorted2 = [...entries2].sort(
48277
48445
  (a, b) => Number(Boolean(a.footer)) - Number(Boolean(b.footer))
48278
48446
  );
48279
48447
  for (const entry of sorted2) refreshElapsedText(entry);
@@ -51427,10 +51595,10 @@ function pruneSkills(targetDir, skillNames, options2) {
51427
51595
  }
51428
51596
  function unexpectedContent(skillDir) {
51429
51597
  if (!fs58.statSync(skillDir).isDirectory()) return void 0;
51430
- const entries = fs58.readdirSync(skillDir);
51431
- const others = entries.filter((entry) => entry !== "SKILL.md");
51598
+ const entries2 = fs58.readdirSync(skillDir);
51599
+ const others = entries2.filter((entry) => entry !== "SKILL.md");
51432
51600
  if (others.length > 0) return `contains ${others.sort().join(", ")}`;
51433
- return entries.length === 0 ? "no SKILL.md" : void 0;
51601
+ return entries2.length === 0 ? "no SKILL.md" : void 0;
51434
51602
  }
51435
51603
 
51436
51604
  // src/commands/sync/reportPrune.ts
@@ -51751,10 +51919,10 @@ function syncDesign(agentDir, targetBase, files) {
51751
51919
  );
51752
51920
  const skillsSource = path120.join(agentDir, "skills");
51753
51921
  const skillsTarget = path120.join(targetBase, "skills");
51754
- const entries = fs66.readdirSync(skillsSource, { withFileTypes: true }).filter(
51922
+ const entries2 = fs66.readdirSync(skillsSource, { withFileTypes: true }).filter(
51755
51923
  (entry) => !entry.isDirectory() || fs66.existsSync(path120.join(skillsSource, entry.name, "SKILL.md"))
51756
51924
  );
51757
- for (const entry of entries) {
51925
+ for (const entry of entries2) {
51758
51926
  const source = path120.join(skillsSource, entry.name);
51759
51927
  const target = path120.join(skillsTarget, entry.name);
51760
51928
  if (entry.isDirectory()) {
@@ -51763,8 +51931,8 @@ function syncDesign(agentDir, targetBase, files) {
51763
51931
  files.write(target, fs66.readFileSync(source, "utf8"));
51764
51932
  }
51765
51933
  }
51766
- console.log(`Synced ${entries.length} skill(s) to ~/.claude/skills`);
51767
- return entries.map((entry) => entry.name);
51934
+ console.log(`Synced ${entries2.length} skill(s) to ~/.claude/skills`);
51935
+ return entries2.map((entry) => entry.name);
51768
51936
  }
51769
51937
 
51770
51938
  // src/commands/sync/syncPi.ts
@@ -51819,16 +51987,20 @@ import * as fs68 from "fs";
51819
51987
  import * as path123 from "path";
51820
51988
  import chalk295 from "chalk";
51821
51989
 
51822
- // src/commands/sync/mergeSettings.ts
51990
+ // src/commands/sync/isPlainObject.ts
51823
51991
  function isPlainObject7(value) {
51824
51992
  return typeof value === "object" && value !== null && !Array.isArray(value);
51825
51993
  }
51994
+
51995
+ // src/commands/sync/canonical.ts
51826
51996
  function canonical(value) {
51827
51997
  if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
51828
51998
  if (isPlainObject7(value))
51829
51999
  return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
51830
52000
  return JSON.stringify(value);
51831
52001
  }
52002
+
52003
+ // src/commands/sync/mergeSettings.ts
51832
52004
  function unionArrays(user, assist) {
51833
52005
  const seen = new Set(user.map(canonical));
51834
52006
  const merged = [...user];
@@ -51854,6 +52026,33 @@ function mergeSettings(user, assist) {
51854
52026
  return merged;
51855
52027
  }
51856
52028
 
52029
+ // src/commands/sync/pruneStaleAssistHooks.ts
52030
+ function entryCommands(entry) {
52031
+ const hooks = entry?.hooks;
52032
+ if (!Array.isArray(hooks)) return [];
52033
+ return hooks.map((hook) => hook?.command).filter((command) => typeof command === "string");
52034
+ }
52035
+ function isStale(entry, assistCommands, assistEntries) {
52036
+ const commands = entryCommands(entry);
52037
+ return commands.length > 0 && commands.every((command) => assistCommands.has(command)) && !assistEntries.has(canonical(entry));
52038
+ }
52039
+ function pruneEvent(user, assist) {
52040
+ if (!Array.isArray(user) || !Array.isArray(assist)) return user;
52041
+ const assistCommands = new Set(assist.flatMap(entryCommands));
52042
+ const assistEntries = new Set(assist.map(canonical));
52043
+ return user.filter((entry) => !isStale(entry, assistCommands, assistEntries));
52044
+ }
52045
+ function pruneStaleAssistHooks(user, assist) {
52046
+ const userHooks = user.hooks;
52047
+ const assistHooks = assist.hooks;
52048
+ if (!isPlainObject7(userHooks) || !isPlainObject7(assistHooks)) return user;
52049
+ const hooks = { ...userHooks };
52050
+ for (const event of Object.keys(assistHooks))
52051
+ if (event in hooks)
52052
+ hooks[event] = pruneEvent(hooks[event], assistHooks[event]);
52053
+ return { ...user, hooks };
52054
+ }
52055
+
51857
52056
  // src/commands/sync/readSourceSettings.ts
51858
52057
  import * as fs67 from "fs";
51859
52058
  import * as path122 from "path";
@@ -51877,7 +52076,10 @@ async function syncSettings(claudeDir, targetBase, options2) {
51877
52076
  const targetContent = targetExists ? fs68.readFileSync(target, "utf8") : "";
51878
52077
  const preservedUserSettings = targetExists ? JSON.parse(targetContent) : {};
51879
52078
  const mergedContent = JSON.stringify(
51880
- mergeSettings(preservedUserSettings, sourceSettings),
52079
+ mergeSettings(
52080
+ pruneStaleAssistHooks(preservedUserSettings, sourceSettings),
52081
+ sourceSettings
52082
+ ),
51881
52083
  null,
51882
52084
  " "
51883
52085
  );
@@ -52512,16 +52714,16 @@ function selectPassages(sources, selection) {
52512
52714
  }
52513
52715
 
52514
52716
  // src/commands/transcript/selectionSchema.ts
52515
- import { z as z23 } from "zod";
52516
- var selectionSchema = z23.strictObject({
52517
- keep: z23.array(
52518
- z23.strictObject({
52519
- file: z23.string().trim().min(1, "file is required"),
52520
- from: z23.string().trim().min(1, "from is required"),
52521
- to: z23.string().trim().min(1, "to is required")
52717
+ import { z as z24 } from "zod";
52718
+ var selectionSchema = z24.strictObject({
52719
+ keep: z24.array(
52720
+ z24.strictObject({
52721
+ file: z24.string().trim().min(1, "file is required"),
52722
+ from: z24.string().trim().min(1, "from is required"),
52723
+ to: z24.string().trim().min(1, "to is required")
52522
52724
  })
52523
52725
  ).min(1, "a selection needs at least one keep range"),
52524
- removed: z23.array(z23.string().trim().min(1)).default([])
52726
+ removed: z24.array(z24.string().trim().min(1)).default([])
52525
52727
  });
52526
52728
 
52527
52729
  // src/commands/transcript/widenAudienceInText.ts
@@ -52651,9 +52853,9 @@ function registerTranscript(program) {
52651
52853
  }
52652
52854
 
52653
52855
  // src/commands/verify/reportVerifyProblems.ts
52654
- function verifySection(label, entries) {
52655
- if (entries.length === 0) return void 0;
52656
- const list7 = entries.sort().map((entry) => ` ${entry}`).join("\n");
52856
+ function verifySection(label, entries2) {
52857
+ if (entries2.length === 0) return void 0;
52858
+ const list7 = entries2.sort().map((entry) => ` ${entry}`).join("\n");
52657
52859
  return `${label}:
52658
52860
  ${list7}`;
52659
52861
  }
@@ -53452,12 +53654,12 @@ function registerVerifyChecks(verifyCommand) {
53452
53654
 
53453
53655
  // src/commands/verify/list.ts
53454
53656
  function list6() {
53455
- const entries = resolveEntries();
53456
- if (entries.length === 0) {
53657
+ const entries2 = resolveEntries();
53658
+ if (entries2.length === 0) {
53457
53659
  console.error("No verify commands found");
53458
53660
  process.exit(1);
53459
53661
  }
53460
- for (const entry of entries) {
53662
+ for (const entry of entries2) {
53461
53663
  console.log(`${entry.name}: ${entry.fullCommand}`);
53462
53664
  }
53463
53665
  }
@@ -54330,13 +54532,13 @@ import { execFileSync as execFileSync32 } from "child_process";
54330
54532
  import { readdirSync as readdirSync27, readFileSync as readFileSync86, statSync as statSync18 } from "fs";
54331
54533
  import { join as join123 } from "path";
54332
54534
  function findPortFile(roamDir) {
54333
- let entries;
54535
+ let entries2;
54334
54536
  try {
54335
- entries = readdirSync27(roamDir);
54537
+ entries2 = readdirSync27(roamDir);
54336
54538
  } catch {
54337
54539
  return void 0;
54338
54540
  }
54339
- const candidates = entries.filter((name2) => /^roam-local-api(-[^.]+)?\.port$/.test(name2)).map((name2) => {
54541
+ const candidates = entries2.filter((name2) => /^roam-local-api(-[^.]+)?\.port$/.test(name2)).map((name2) => {
54340
54542
  const path128 = join123(roamDir, name2);
54341
54543
  try {
54342
54544
  return { path: path128, mtimeMs: statSync18(path128).mtimeMs };
@@ -54405,8 +54607,8 @@ function registerRoam(program) {
54405
54607
 
54406
54608
  // src/commands/run/formatConfiguredCommands.ts
54407
54609
  function formatConfiguredCommands() {
54408
- const { run: entries } = loadConfig();
54409
- const configs = resolveRunConfigs(entries, runConfigBaseDir());
54610
+ const { run: entries2 } = loadConfig();
54611
+ const configs = resolveRunConfigs(entries2, runConfigBaseDir());
54410
54612
  if (configs.length === 0) return "\nNo configured commands";
54411
54613
  const names = configs.map((r) => ` ${r.name}`).join("\n");
54412
54614
  return `
@@ -55456,11 +55658,11 @@ function cacheSnapshot() {
55456
55658
  return JSON.stringify([readRepoConfigCache(), readUserConfigCache()]);
55457
55659
  }
55458
55660
  function pollRepoConfigCache(intervalMs = POLL_MS3) {
55459
- let inFlight2 = false;
55661
+ let inFlight3 = false;
55460
55662
  let failing = false;
55461
55663
  const tick = async () => {
55462
- if (inFlight2) return;
55463
- inFlight2 = true;
55664
+ if (inFlight3) return;
55665
+ inFlight3 = true;
55464
55666
  try {
55465
55667
  const before = cacheSnapshot();
55466
55668
  const count10 = await refreshRepoConfigCache();
@@ -55475,7 +55677,7 @@ function pollRepoConfigCache(intervalMs = POLL_MS3) {
55475
55677
  );
55476
55678
  failing = true;
55477
55679
  } finally {
55478
- inFlight2 = false;
55680
+ inFlight3 = false;
55479
55681
  }
55480
55682
  };
55481
55683
  const timer = setInterval(() => void tick(), intervalMs);
@@ -55496,9 +55698,9 @@ async function refreshRepoConfigCacheOnStart() {
55496
55698
  }
55497
55699
 
55498
55700
  // src/commands/sessions/daemon/loadActiveSelection.ts
55499
- import { z as z24 } from "zod";
55701
+ import { z as z25 } from "zod";
55500
55702
  var ACTIVE_FILE = "active.json";
55501
- var activeSelectionSchema = z24.record(z24.string(), z24.string());
55703
+ var activeSelectionSchema = z25.record(z25.string(), z25.string());
55502
55704
  function loadActiveSelection() {
55503
55705
  const parsed = activeSelectionSchema.safeParse(
55504
55706
  loadJson(ACTIVE_FILE)
@@ -55792,13 +55994,13 @@ async function sessionWrites(session, target) {
55792
55994
  const reader = conversationOf(session)?.reader;
55793
55995
  const transcript = reader ? await resolveTranscriptPath(session) : null;
55794
55996
  if (!reader || !transcript) return { id: session.id };
55795
- const entries = await readTranscriptTail(
55997
+ const entries2 = await readTranscriptTail(
55796
55998
  transcript,
55797
55999
  Number.POSITIVE_INFINITY
55798
56000
  );
55799
56001
  return {
55800
56002
  id: session.id,
55801
- ...lastWriteTimes(reader.events(entries), target, session.cwd)
56003
+ ...lastWriteTimes(reader.events(entries2), target, session.cwd)
55802
56004
  };
55803
56005
  }
55804
56006
  async function findLastWriter(sessions, target) {
@@ -56027,8 +56229,8 @@ async function turnStarted(session, fingerprint3) {
56027
56229
  if (!lookup.readable) return true;
56028
56230
  const filePath = await resolveTranscriptPath(session);
56029
56231
  if (!filePath) return true;
56030
- const entries = await readTranscriptTail(filePath);
56031
- return (lookup.reader.fingerprint(entries) ?? void 0) !== fingerprint3;
56232
+ const entries2 = await readTranscriptTail(filePath);
56233
+ return (lookup.reader.fingerprint(entries2) ?? void 0) !== fingerprint3;
56032
56234
  }
56033
56235
  function clearPendingSubmit(session) {
56034
56236
  session.pendingSubmit?.cancel();
@@ -57408,14 +57610,14 @@ function isCodexAppServer(pid, procRoot = "/proc") {
57408
57610
 
57409
57611
  // src/commands/sessions/daemon/worktree/liveProcessesInTree.ts
57410
57612
  function liveProcessesInTree(treePath, procRoot = "/proc") {
57411
- let entries;
57613
+ let entries2;
57412
57614
  try {
57413
- entries = readdirSync29(procRoot);
57615
+ entries2 = readdirSync29(procRoot);
57414
57616
  } catch {
57415
57617
  return [];
57416
57618
  }
57417
57619
  const pids = [];
57418
- for (const entry of entries) {
57620
+ for (const entry of entries2) {
57419
57621
  const pid = Number(entry);
57420
57622
  if (!Number.isInteger(pid) || pid === process.pid) continue;
57421
57623
  const cwd = processCwd(`${procRoot}/${entry}/cwd`);
@@ -58151,9 +58353,9 @@ function buildPrompt3(prompt) {
58151
58353
  }
58152
58354
 
58153
58355
  // src/commands/sessions/shared/loadSessionTitles.ts
58154
- import { z as z25 } from "zod";
58356
+ import { z as z26 } from "zod";
58155
58357
  var TITLES_FILE = "session-titles.json";
58156
- var sessionTitlesSchema = z25.record(z25.string(), z25.string());
58358
+ var sessionTitlesSchema = z26.record(z26.string(), z26.string());
58157
58359
  function loadSessionTitles() {
58158
58360
  const parsed = sessionTitlesSchema.safeParse(
58159
58361
  loadJson(TITLES_FILE)
@@ -58691,8 +58893,8 @@ function ensureProjectDirExists(dir, sessionId2) {
58691
58893
 
58692
58894
  // src/commands/sessions/daemon/reportUnrecognisedShapes.ts
58693
58895
  var reported = /* @__PURE__ */ new WeakMap();
58694
- function reportUnrecognisedShapes(session, reader, entries) {
58695
- const shapes = reader.unrecognised?.(entries) ?? [];
58896
+ function reportUnrecognisedShapes(session, reader, entries2) {
58897
+ const shapes = reader.unrecognised?.(entries2) ?? [];
58696
58898
  if (shapes.length === 0) return;
58697
58899
  const seen = reported.get(session) ?? /* @__PURE__ */ new Set();
58698
58900
  reported.set(session, seen);
@@ -58758,15 +58960,15 @@ async function reconcileTranscriptStatus(session, onStatusChange, notify2) {
58758
58960
  const { reader } = lookup;
58759
58961
  const filePath = await resolveTranscriptPath(session);
58760
58962
  if (!filePath) return;
58761
- const entries = await readTranscriptTail(filePath);
58762
- const fingerprint3 = reader.fingerprint(entries);
58963
+ const entries2 = await readTranscriptTail(filePath);
58964
+ const fingerprint3 = reader.fingerprint(entries2);
58763
58965
  if (fingerprint3 !== null && fingerprint3 === session.transcriptFingerprint)
58764
58966
  return;
58765
58967
  session.transcriptFingerprint = fingerprint3 ?? void 0;
58766
- reportUnrecognisedShapes(session, reader, entries);
58767
- updateLastMessages(session, reader.events(entries), notify2);
58968
+ reportUnrecognisedShapes(session, reader, entries2);
58969
+ updateLastMessages(session, reader.events(entries2), notify2);
58768
58970
  if (isFinished(session)) return;
58769
- const derived = reader.lifecycle(entries, {
58971
+ const derived = reader.lifecycle(entries2, {
58770
58972
  permissionActive: session.permissionActive
58771
58973
  }).status;
58772
58974
  if (!derived) return;
@@ -60997,23 +61199,23 @@ async function discoverCodexHistoryEntries() {
60997
61199
  // src/commands/sessions/shared/discoverHistoryEntries.ts
60998
61200
  async function discoverHistoryEntries() {
60999
61201
  const paths = await discoverSessionJsonlPaths();
61000
- const entries = [];
61202
+ const entries2 = [];
61001
61203
  await Promise.all(
61002
61204
  paths.map(async ({ path: filePath, origin }) => {
61003
61205
  const session = await parseSessionFile(filePath, origin);
61004
- if (session) entries.push({ session, filePath });
61206
+ if (session) entries2.push({ session, filePath });
61005
61207
  })
61006
61208
  );
61007
- entries.push(...await discoverCodexHistoryEntries());
61209
+ entries2.push(...await discoverCodexHistoryEntries());
61008
61210
  const titles2 = loadSessionTitles();
61009
- for (const { session } of entries) {
61211
+ for (const { session } of entries2) {
61010
61212
  const title = titles2[session.sessionId];
61011
61213
  if (title) session.title = title;
61012
61214
  }
61013
- entries.sort(
61215
+ entries2.sort(
61014
61216
  (a, b) => new Date(b.session.timestamp).getTime() - new Date(a.session.timestamp).getTime()
61015
61217
  );
61016
- return entries;
61218
+ return entries2;
61017
61219
  }
61018
61220
 
61019
61221
  // src/commands/sessions/shared/discoverSessions.ts
@@ -61484,6 +61686,10 @@ var relays = {
61484
61686
  history: relayHistory,
61485
61687
  "auto-update": relayReply,
61486
61688
  "restart-webserver": relayReply,
61689
+ "session-output": (state, msg) => relayReply(state, {
61690
+ ...msg,
61691
+ sessionId: typeof msg.sessionId === "string" ? nsId(state, msg) : void 0
61692
+ }),
61487
61693
  "user-messages": (state, msg) => broadcastToViewers(state, { ...msg, sessionId: nsId(state, msg) }),
61488
61694
  limits: (state, msg) => state.onLimits(
61489
61695
  msg.harness,
@@ -62796,6 +63002,35 @@ var handleDismiss = routed((_client, m, d) => {
62796
63002
  m.dismissSession(d.sessionId, closeServerRuns);
62797
63003
  });
62798
63004
 
63005
+ // src/commands/sessions/daemon/links/routeOutputToLink.ts
63006
+ import { randomUUID as randomUUID25 } from "crypto";
63007
+ function unavailable(links2, node) {
63008
+ const status2 = links2.nodes().links.find((link3) => link3.name === node);
63009
+ if (!status2)
63010
+ return `${node} is not a linked node (link state: unknown); see assist sessions nodes`;
63011
+ if (status2.state === "connected") return void 0;
63012
+ const detail = status2.error ? `: ${status2.error}` : "";
63013
+ return `${node} link is ${status2.state}${detail}; run assist sessions nodes doctor ${node}`;
63014
+ }
63015
+ function routeOutputToLink(client, links2, data) {
63016
+ const sessionId2 = data.sessionId;
63017
+ const split = typeof sessionId2 === "string" ? splitNodeSessionId(sessionId2) : void 0;
63018
+ if (!split) return data;
63019
+ if (split.node === links2.localNode()) return { ...data, sessionId: split.id };
63020
+ const reason4 = unavailable(links2, split.node);
63021
+ if (reason4) {
63022
+ daemonLog(`output requested: id=${sessionId2} ${reason4}`);
63023
+ sendTo(client, {
63024
+ type: "session-output",
63025
+ sessionId: sessionId2,
63026
+ error: `Cannot read session ${sessionId2}: ${reason4}`
63027
+ });
63028
+ return void 0;
63029
+ }
63030
+ links2.route(client, { ...data, requestId: data.requestId ?? randomUUID25() });
63031
+ return void 0;
63032
+ }
63033
+
62799
63034
  // src/commands/sessions/daemon/latestServerRun.ts
62800
63035
  function latestServerRun(sessions, origin, group) {
62801
63036
  const live = liveServerRun(sessions, { server: true, origin, group });
@@ -62809,8 +63044,8 @@ function latestServerRun(sessions, origin, group) {
62809
63044
  return latest2;
62810
63045
  }
62811
63046
 
62812
- // src/commands/sessions/daemon/handleOutputRequest.ts
62813
- function resolveTarget3(m, d) {
63047
+ // src/commands/sessions/daemon/resolveOutputTarget.ts
63048
+ function resolveOutputTarget(m, d) {
62814
63049
  const server = d.server;
62815
63050
  if (!server) return { sessionId: d.sessionId };
62816
63051
  let run5;
@@ -62824,11 +63059,20 @@ function resolveTarget3(m, d) {
62824
63059
  };
62825
63060
  return run5.status === "done" || run5.status === "error" ? { sessionId: run5.id, exited: run5.status } : { sessionId: run5.id };
62826
63061
  }
62827
- var handleOutputRequest = (client, m, d) => {
62828
- const target = resolveTarget3(m, d);
63062
+
63063
+ // src/commands/sessions/daemon/handleOutputRequest.ts
63064
+ var handleOutputRequest = (client, m, request) => {
63065
+ const d = routeOutputToLink(client, m.links, request);
63066
+ if (!d) return;
63067
+ const target = resolveOutputTarget(m, d);
63068
+ const requestId = d.requestId;
62829
63069
  if ("error" in target) {
62830
63070
  daemonLog(`output requested: ${target.error}`);
62831
- sendTo(client, { type: "session-output", error: target.error });
63071
+ sendTo(client, {
63072
+ type: "session-output",
63073
+ error: target.error,
63074
+ requestId
63075
+ });
62832
63076
  return;
62833
63077
  }
62834
63078
  const { sessionId: sessionId2, exited } = target;
@@ -62845,8 +63089,9 @@ var handleOutputRequest = (client, m, d) => {
62845
63089
  scrollback === void 0 ? {
62846
63090
  type: "session-output",
62847
63091
  sessionId: sessionId2,
62848
- error: `No session ${sessionId2} on this node`
62849
- } : { type: "session-output", sessionId: sessionId2, scrollback, exited }
63092
+ error: `No session ${sessionId2} on this node`,
63093
+ requestId
63094
+ } : { type: "session-output", sessionId: sessionId2, scrollback, exited, requestId }
62850
63095
  );
62851
63096
  };
62852
63097
 
@@ -62963,8 +63208,8 @@ async function handleFetchUserMessages(client, manager, data) {
62963
63208
  const session = findSession(manager, sessionId2);
62964
63209
  const reader = session ? conversationOf(session)?.reader : void 0;
62965
63210
  const filePath = session && reader ? await resolveTranscriptPath(session) : null;
62966
- const entries = reader && filePath ? await readTranscriptTail(filePath, Number.POSITIVE_INFINITY) : [];
62967
- const messages2 = reader ? userMessageTexts(reader.events(entries)) : [];
63211
+ const entries2 = reader && filePath ? await readTranscriptTail(filePath, Number.POSITIVE_INFINITY) : [];
63212
+ const messages2 = reader ? userMessageTexts(reader.events(entries2)) : [];
62968
63213
  daemonLog(
62969
63214
  `session ${sessionId2} user messages: ${messages2.length} from ${filePath ?? "no transcript"}`
62970
63215
  );
@@ -63353,12 +63598,12 @@ function isPrCheckoutArgs(args) {
63353
63598
  }
63354
63599
 
63355
63600
  // src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
63356
- import { execFile as execFile15 } from "child_process";
63601
+ import { execFile as execFile16 } from "child_process";
63357
63602
  import { existsSync as existsSync115 } from "fs";
63358
63603
  function prHeadBranch2(number, cwd) {
63359
63604
  const { headBranch } = prCliCommands(number, cwd);
63360
63605
  return new Promise((resolve36) => {
63361
- execFile15(
63606
+ execFile16(
63362
63607
  headBranch.file,
63363
63608
  headBranch.args,
63364
63609
  { cwd, encoding: "utf8", windowsHide: true },
@@ -63983,7 +64228,7 @@ function registerLinkCommand(nodes) {
63983
64228
  // src/commands/sessions/nodes/awaitLinkReturn.ts
63984
64229
  var POLL_MS8 = 1e3;
63985
64230
  var wait = (ms) => new Promise((r) => setTimeout(r, ms));
63986
- async function linkStatus(name2, query = queryNodes) {
64231
+ async function linkStatus2(name2, query = queryNodes) {
63987
64232
  return (await query())?.links.find((l) => l.name === name2);
63988
64233
  }
63989
64234
  async function awaitLinkReturn(name2, options2, deps2 = {}) {
@@ -63991,7 +64236,7 @@ async function awaitLinkReturn(name2, options2, deps2 = {}) {
63991
64236
  const deadline = now() + options2.timeoutMs;
63992
64237
  let sawDown = options2.sawDown;
63993
64238
  while (now() < deadline) {
63994
- const link3 = await linkStatus(name2, query);
64239
+ const link3 = await linkStatus2(name2, query);
63995
64240
  if (link3?.state !== "connected") sawDown = true;
63996
64241
  else if (sawDown) return link3;
63997
64242
  await sleep2(POLL_MS8);
@@ -64054,7 +64299,7 @@ async function restartNode(name2, options2) {
64054
64299
  `--target must be one of ${TARGETS2.join(", ")}, got ${target}`
64055
64300
  );
64056
64301
  const action = startPeerAction(name2, `restart ${target}`);
64057
- const before = await linkStatus(name2);
64302
+ const before = await linkStatus2(name2);
64058
64303
  try {
64059
64304
  await postToPeer(
64060
64305
  action.spec.url,
@@ -64127,7 +64372,7 @@ async function selfUpdate2(name2, action) {
64127
64372
  }
64128
64373
  async function updateNode(name2) {
64129
64374
  const action = startPeerAction(name2, "update");
64130
- const connected = (await linkStatus(name2))?.state === "connected";
64375
+ const connected = (await linkStatus2(name2))?.state === "connected";
64131
64376
  const link3 = connected ? await updateOverLink(name2, action) : await selfUpdate2(name2, action);
64132
64377
  console.log(`${name2} updated to v${link3.peerVersion ?? "unknown"}`);
64133
64378
  }
@@ -64214,7 +64459,7 @@ function lastLines(scrollback, count10) {
64214
64459
  }
64215
64460
 
64216
64461
  // src/commands/sessions/sessionOutput.ts
64217
- function resolveTarget4(sessionId2, server) {
64462
+ function resolveTarget3(sessionId2, server) {
64218
64463
  if (sessionId2 && server)
64219
64464
  return "Pass either a session id or --server, not both";
64220
64465
  if (server)
@@ -64225,15 +64470,13 @@ function resolveTarget4(sessionId2, server) {
64225
64470
  }
64226
64471
  };
64227
64472
  if (!sessionId2) return "Pass a session id or --server [group]";
64228
- if (sessionId2.includes(":"))
64229
- return `Session ${sessionId2} is on a linked node; reading linked-node sessions is not supported yet`;
64230
64473
  return { sessionId: sessionId2 };
64231
64474
  }
64232
64475
  async function sessionOutput(sessionId2, options2) {
64233
64476
  const count10 = Number.parseInt(options2.lines, 10);
64234
64477
  if (!Number.isInteger(count10) || count10 < 1)
64235
64478
  return fail13(`-n must be a positive integer, got ${options2.lines}`);
64236
- const target = resolveTarget4(sessionId2, options2.server);
64479
+ const target = resolveTarget3(sessionId2, options2.server);
64237
64480
  if (typeof target === "string") return fail13(target);
64238
64481
  try {
64239
64482
  const {