@staff0rd/assist 0.1127.2 → 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.2",
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
@@ -7152,11 +7152,8 @@ var harnessCapabilityDeclarations = {
7152
7152
  "the shared policy still applies the allowlist, restricted paths and docs/schema locks; run work that must keep those guards on Claude",
7153
7153
  "a1592"
7154
7154
  ),
7155
- "intercept.question": unsupported(
7156
- "Codex hooks are not verified to report its native request_user_input question tool",
7157
- "Codex asks its questions in chat; a native Codex question is answered in the terminal",
7158
- "a1563"
7159
- ),
7155
+ // codex-cli 0.167.1 reports request_user_input via PreToolUse; captured in codexQuestionHook.json and replayed through codexHook.
7156
+ "intercept.question": supported,
7160
7157
  "slashCommands.suggest": unsupported(
7161
7158
  "assist reads skills and commands only from Claude's home and project dirs",
7162
7159
  "type the Codex skill name in full in the phone reply bar"
@@ -7574,14 +7571,14 @@ async function discoverCodexRolloutPaths() {
7574
7571
  return collect(codexSessionsDir(), DATE_DEPTH);
7575
7572
  }
7576
7573
  async function collect(dir, depth) {
7577
- let entries;
7574
+ let entries2;
7578
7575
  try {
7579
- entries = await fs8.promises.readdir(dir, { withFileTypes: true });
7576
+ entries2 = await fs8.promises.readdir(dir, { withFileTypes: true });
7580
7577
  } catch {
7581
7578
  return [];
7582
7579
  }
7583
7580
  const nested = await Promise.all(
7584
- entries.map((entry) => collectEntry(dir, entry, depth))
7581
+ entries2.map((entry) => collectEntry(dir, entry, depth))
7585
7582
  );
7586
7583
  return nested.flat();
7587
7584
  }
@@ -7608,13 +7605,13 @@ function findCodexRolloutPathSync(sessionId2) {
7608
7605
  return findRollout(codexSessionsDir(), DATE_DEPTH2, `-${sessionId2}.jsonl`);
7609
7606
  }
7610
7607
  function findRollout(dir, depth, suffix) {
7611
- let entries;
7608
+ let entries2;
7612
7609
  try {
7613
- entries = fs9.readdirSync(dir, { withFileTypes: true });
7610
+ entries2 = fs9.readdirSync(dir, { withFileTypes: true });
7614
7611
  } catch {
7615
7612
  return null;
7616
7613
  }
7617
- for (const entry of entries) {
7614
+ for (const entry of entries2) {
7618
7615
  const full = path14.join(dir, entry.name);
7619
7616
  if (entry.isDirectory()) {
7620
7617
  const found = depth > 0 ? findRollout(full, depth - 1, suffix) : null;
@@ -7757,15 +7754,15 @@ function turnEvent(entry) {
7757
7754
  if (kind === "task_started") return "started";
7758
7755
  return typeof kind === "string" && TURN_END_EVENTS.has(kind) ? "ended" : null;
7759
7756
  }
7760
- function hasAgentActivity(entries) {
7761
- return entries.some((entry) => entry.type === "response_item");
7757
+ function hasAgentActivity(entries2) {
7758
+ return entries2.some((entry) => entry.type === "response_item");
7762
7759
  }
7763
- function deriveCodexRolloutStatus(entries) {
7764
- for (let i = entries.length - 1; i >= 0; i--) {
7765
- 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]);
7766
7763
  if (event) return event === "started" ? "running" : "waiting";
7767
7764
  }
7768
- return hasAgentActivity(entries) ? "running" : null;
7765
+ return hasAgentActivity(entries2) ? "running" : null;
7769
7766
  }
7770
7767
 
7771
7768
  // src/shared/harnessAdapters/codexCompletedToolEvents.ts
@@ -7892,9 +7889,17 @@ function parseApplyPatch(patch2) {
7892
7889
  }));
7893
7890
  }
7894
7891
 
7895
- // src/shared/harnessAdapters/codexToolOperations.ts
7896
- var COMMAND_TOOLS2 = /* @__PURE__ */ new Set(["Bash", "PowerShell"]);
7897
- var PATCH_TOOLS = /* @__PURE__ */ new Set(["apply_patch", "Edit", "Write"]);
7892
+ // src/shared/harnessAdapters/patchWrites.ts
7893
+ function patchWrites(tool, patch2) {
7894
+ return parseApplyPatch(patch2).map(({ path: path128, contents }) => ({
7895
+ kind: "fileWrite",
7896
+ tool,
7897
+ path: path128,
7898
+ contents
7899
+ }));
7900
+ }
7901
+
7902
+ // src/shared/harnessAdapters/patchText.ts
7898
7903
  var PATCH_MARKER = "*** Begin Patch";
7899
7904
  function patchText(input) {
7900
7905
  const candidates = [
@@ -7907,25 +7912,39 @@ function patchText(input) {
7907
7912
  (value) => typeof value === "string" && value.includes(PATCH_MARKER)
7908
7913
  );
7909
7914
  }
7910
- function patchWrites(tool, patch2) {
7911
- return parseApplyPatch(patch2).map(({ path: path128, contents }) => ({
7912
- kind: "fileWrite",
7913
- tool,
7914
- path: path128,
7915
- contents
7916
- }));
7917
- }
7915
+
7916
+ // src/shared/harnessAdapters/codexToolOperations.ts
7917
+ var COMMAND_TOOLS2 = /* @__PURE__ */ new Set(["Bash", "PowerShell"]);
7918
+ var PATCH_TOOLS = /* @__PURE__ */ new Set(["apply_patch", "Edit", "Write"]);
7919
+ var PATCH_MARKER2 = "*** Begin Patch";
7918
7920
  function codexToolOperations({
7919
7921
  toolName,
7920
7922
  toolInput
7921
7923
  }) {
7924
+ if (toolName === "request_user_input" && Array.isArray(toolInput.questions))
7925
+ return [
7926
+ {
7927
+ kind: "question",
7928
+ tool: toolName,
7929
+ questionsJson: JSON.stringify({
7930
+ questions: toolInput.questions.map(
7931
+ ({ question, header, options: options2 }) => ({
7932
+ question,
7933
+ header,
7934
+ options: options2,
7935
+ multiSelect: false
7936
+ })
7937
+ )
7938
+ })
7939
+ }
7940
+ ];
7922
7941
  if (COMMAND_TOOLS2.has(toolName)) {
7923
7942
  const { command } = toolInput;
7924
7943
  if (typeof command !== "string" || !command.trim()) return [];
7925
7944
  const operations2 = [
7926
7945
  { kind: "command", tool: toolName, command: command.trim() }
7927
7946
  ];
7928
- return command.includes(PATCH_MARKER) ? [...operations2, ...patchWrites(toolName, command)] : operations2;
7947
+ return command.includes(PATCH_MARKER2) ? [...operations2, ...patchWrites(toolName, command)] : operations2;
7929
7948
  }
7930
7949
  if (!PATCH_TOOLS.has(toolName)) return [];
7931
7950
  const patch2 = patchText(toolInput);
@@ -8037,10 +8056,10 @@ function codexEntryShape(entry) {
8037
8056
  }
8038
8057
 
8039
8058
  // src/shared/harnessAdapters/codexUnrecognisedShapes.ts
8040
- function codexUnrecognisedShapes(entries) {
8059
+ function codexUnrecognisedShapes(entries2) {
8041
8060
  return [
8042
8061
  ...new Set(
8043
- entries.map(codexEntryShape).filter((shape) => shape !== void 0)
8062
+ entries2.map(codexEntryShape).filter((shape) => shape !== void 0)
8044
8063
  )
8045
8064
  ];
8046
8065
  }
@@ -8053,9 +8072,9 @@ function entryEvents(entry) {
8053
8072
  if (entry.type === "response_item") return codexToolEvents(payload, at2);
8054
8073
  return [];
8055
8074
  }
8056
- function fingerprint2(entries) {
8057
- for (let i = entries.length - 1; i >= 0; i--) {
8058
- const entry = entries[i];
8075
+ function fingerprint2(entries2) {
8076
+ for (let i = entries2.length - 1; i >= 0; i--) {
8077
+ const entry = entries2[i];
8059
8078
  if (entry.type !== "event_msg" && entry.type !== "response_item") continue;
8060
8079
  const payload = rolloutPayload(entry);
8061
8080
  return [
@@ -8073,9 +8092,9 @@ var codexConversationReader = {
8073
8092
  const path128 = codexConversationReader.locate(ref);
8074
8093
  return path128 ? { dir: dirname8(path128), file: basename6(path128) } : null;
8075
8094
  },
8076
- events: (entries) => entries.flatMap(entryEvents),
8077
- lifecycle: (entries) => ({
8078
- status: deriveCodexRolloutStatus(entries),
8095
+ events: (entries2) => entries2.flatMap(entryEvents),
8096
+ lifecycle: (entries2) => ({
8097
+ status: deriveCodexRolloutStatus(entries2),
8079
8098
  asking: false
8080
8099
  }),
8081
8100
  fingerprint: fingerprint2,
@@ -8851,8 +8870,8 @@ async function targetConversationEvents(cwd, target) {
8851
8870
  if (!lookup.readable || !lookup.conversation) return [];
8852
8871
  const filePath = lookup.reader.locate(ref) ?? await adapter.conversation.locate(target.conversationId);
8853
8872
  if (!filePath) return [];
8854
- const entries = await readTranscriptTail(filePath, Number.POSITIVE_INFINITY);
8855
- return lookup.reader.events(entries);
8873
+ const entries2 = await readTranscriptTail(filePath, Number.POSITIVE_INFINITY);
8874
+ return lookup.reader.events(entries2);
8856
8875
  }
8857
8876
 
8858
8877
  // src/commands/sessions/web/parseTranscriptCommitShas.ts
@@ -10007,9 +10026,9 @@ function scalarConfigNode(inner, base) {
10007
10026
  };
10008
10027
  }
10009
10028
  function enumValues(node) {
10010
- const entries = node.def?.entries;
10011
- if (!entries) return void 0;
10012
- return Object.values(entries).filter(
10029
+ const entries2 = node.def?.entries;
10030
+ if (!entries2) return void 0;
10031
+ return Object.values(entries2).filter(
10013
10032
  (value) => typeof value === "string"
10014
10033
  );
10015
10034
  }
@@ -11140,14 +11159,18 @@ function isGlobalOnlyConfigKey(key) {
11140
11159
  }
11141
11160
 
11142
11161
  // src/commands/config/isNodeOnlyConfigKey.ts
11162
+ var NODE_ONLY_KEYS = ["inbox.intervalMinutes"];
11163
+ var NODE_ONLY_ROOTS = ["database", "repos"];
11143
11164
  function isNodeOnlyConfigKey(key) {
11144
- return isGlobalOnlyConfigKey(key) || key.split(".")[0] === "repos";
11165
+ return NODE_ONLY_KEYS.some((k) => key.startsWith(k)) || NODE_ONLY_ROOTS.includes(key.split(".")[0]);
11145
11166
  }
11146
11167
 
11147
11168
  // src/commands/config/configWritableScopes.ts
11148
11169
  function configWritableScopes(key) {
11149
- if (isGlobalOnlyConfigKey(key)) return ["global"];
11150
- 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"];
11151
11174
  return void 0;
11152
11175
  }
11153
11176
 
@@ -11304,11 +11327,11 @@ function dbBackedEntry(entry, value) {
11304
11327
  writableScopes: ["user"]
11305
11328
  };
11306
11329
  }
11307
- async function withDbBackedConfigEntries(entries) {
11308
- if (dbBackedKeysIn().length === 0) return entries;
11330
+ async function withDbBackedConfigEntries(entries2) {
11331
+ if (dbBackedKeysIn().length === 0) return entries2;
11309
11332
  const db = await getDb();
11310
11333
  return Promise.all(
11311
- entries.map(
11334
+ entries2.map(
11312
11335
  async (entry) => isDbBackedConfigKey(entry.key) ? dbBackedEntry(entry, await dbBackedConfigKeys[entry.key].read(db)) : entry
11313
11336
  )
11314
11337
  );
@@ -11416,9 +11439,9 @@ function loadLinkedEntries(configPath, visited) {
11416
11439
  }
11417
11440
 
11418
11441
  // src/shared/resolveRunConfigs.ts
11419
- function resolveRunConfigs(entries, configDir) {
11442
+ function resolveRunConfigs(entries2, configDir) {
11420
11443
  const ctx = { rootConfigDir: configDir, visited: /* @__PURE__ */ new Set() };
11421
- return resolveRecursive(entries, configDir, ctx);
11444
+ return resolveRecursive(entries2, configDir, ctx);
11422
11445
  }
11423
11446
  function applyPrefix(configs, prefix2) {
11424
11447
  return configs.map((c) => ({ ...c, name: `${prefix2}:${c.name}` }));
@@ -11431,10 +11454,10 @@ function relativeToRoot(ctx, absolute2) {
11431
11454
  }
11432
11455
  function loadAndResolveLink(linkPath, configDir, ctx) {
11433
11456
  const configPath = findLinkedConfigPath(linkPath, configDir);
11434
- const entries = loadLinkedEntries(configPath, ctx.visited);
11457
+ const entries2 = loadLinkedEntries(configPath, ctx.visited);
11435
11458
  const defaultCwd = relativeToRoot(ctx, resolve7(configDir, linkPath));
11436
11459
  return setDefaultCwd(
11437
- resolveRecursive(entries, dirname10(configPath), ctx),
11460
+ resolveRecursive(entries2, dirname10(configPath), ctx),
11438
11461
  defaultCwd
11439
11462
  );
11440
11463
  }
@@ -11446,9 +11469,9 @@ function resolveEntry(entry, configDir, ctx) {
11446
11469
  if (isRunLink(entry)) return resolveLink(entry, configDir, ctx);
11447
11470
  return [resolveLocalCwd(entry, configDir, ctx)];
11448
11471
  }
11449
- function resolveRecursive(entries, configDir, ctx) {
11450
- if (!entries || entries.length === 0) return [];
11451
- 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));
11452
11475
  assertNoDuplicateRunNames(result);
11453
11476
  return result;
11454
11477
  }
@@ -13246,6 +13269,170 @@ function jiraSite(_req, res) {
13246
13269
  respondJson(res, 200, { site: config.site ?? null });
13247
13270
  }
13248
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
+
13249
13436
  // src/commands/sessions/web/scoreFilePath.ts
13250
13437
  var BASENAME_WEIGHT = 1e3;
13251
13438
  var START_BONUS = 15;
@@ -13298,7 +13485,7 @@ function rankFilePaths(paths, query, limit) {
13298
13485
 
13299
13486
  // src/commands/sessions/web/listFiles.ts
13300
13487
  var MAX_RESULTS = 20;
13301
- var CACHE_TTL_MS3 = 5e3;
13488
+ var CACHE_TTL_MS4 = 5e3;
13302
13489
  var LS_FILES_MAX_BUFFER = 32 * 1024 * 1024;
13303
13490
  var fileListCache = /* @__PURE__ */ new Map();
13304
13491
  async function repoFiles(cwd) {
@@ -13310,7 +13497,7 @@ async function repoFiles(cwd) {
13310
13497
  { maxBuffer: LS_FILES_MAX_BUFFER }
13311
13498
  );
13312
13499
  const files = [...new Set(output.split(/\r?\n/).filter(Boolean))];
13313
- fileListCache.set(cwd, { files, expires: Date.now() + CACHE_TTL_MS3 });
13500
+ fileListCache.set(cwd, { files, expires: Date.now() + CACHE_TTL_MS4 });
13314
13501
  return files;
13315
13502
  }
13316
13503
  async function listFiles(req, res) {
@@ -13435,7 +13622,7 @@ async function fetchFeeds(urls, onProgress) {
13435
13622
  }
13436
13623
 
13437
13624
  // src/commands/sessions/web/listNewsItems.ts
13438
- var CACHE_TTL_MS4 = 15 * 6e4;
13625
+ var CACHE_TTL_MS5 = 15 * 6e4;
13439
13626
  var cache3;
13440
13627
  async function listNewsItems(_req, res) {
13441
13628
  const { orm } = await getReady();
@@ -13444,7 +13631,7 @@ async function listNewsItems(_req, res) {
13444
13631
  const now = Date.now();
13445
13632
  if (!cache3 || cache3.feedsKey !== feedsKey || cache3.expires <= now) {
13446
13633
  const items3 = fetchFeeds(urls);
13447
- cache3 = { feedsKey, expires: now + CACHE_TTL_MS4, items: items3 };
13634
+ cache3 = { feedsKey, expires: now + CACHE_TTL_MS5, items: items3 };
13448
13635
  items3.catch(() => {
13449
13636
  if (cache3?.items === items3) cache3 = void 0;
13450
13637
  });
@@ -13459,10 +13646,10 @@ function newsNavConfig(_req, res) {
13459
13646
  }
13460
13647
 
13461
13648
  // src/commands/sessions/web/releases/ghJson.ts
13462
- import { execFile as execFile8 } from "child_process";
13649
+ import { execFile as execFile9 } from "child_process";
13463
13650
  import { promisify as promisify8 } from "util";
13464
- var execFileAsync8 = promisify8(execFile8);
13465
- var CACHE_TTL_MS5 = 3e4;
13651
+ var execFileAsync8 = promisify8(execFile9);
13652
+ var CACHE_TTL_MS6 = 3e4;
13466
13653
  var cache4 = /* @__PURE__ */ new Map();
13467
13654
  function partialGraphqlData(error) {
13468
13655
  const stdout = error.stdout;
@@ -13492,7 +13679,7 @@ async function runGh(cwd, args) {
13492
13679
  function ghJson(cwd, args) {
13493
13680
  const key = [cwd, ...args].join("\0");
13494
13681
  const hit = cache4.get(key);
13495
- if (hit && Date.now() - hit.at < CACHE_TTL_MS5)
13682
+ if (hit && Date.now() - hit.at < CACHE_TTL_MS6)
13496
13683
  return hit.result;
13497
13684
  const result = runGh(cwd, args);
13498
13685
  cache4.set(key, { at: Date.now(), result });
@@ -14722,20 +14909,20 @@ async function failStaleJobRuns(db, { startedBefore, detail }) {
14722
14909
  }
14723
14910
 
14724
14911
  // src/commands/inbox/inboxConnectorRun.ts
14725
- import { z as z13 } from "zod";
14912
+ import { z as z14 } from "zod";
14726
14913
 
14727
14914
  // src/commands/inbox/inboxScanSchema.ts
14728
- import { z as z12 } from "zod";
14729
- var flaggedMessageSchema = z12.object({
14730
- source: z12.enum(["gmail", "slack"]),
14731
- messageId: z12.string().min(1),
14732
- sender: z12.string().min(1),
14733
- summary: z12.string().min(1),
14734
- link: z12.string().min(1),
14735
- 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()
14736
14923
  });
14737
- var inboxScanSchema = z12.object({
14738
- messages: z12.array(flaggedMessageSchema)
14924
+ var inboxScanSchema = z13.object({
14925
+ messages: z13.array(flaggedMessageSchema)
14739
14926
  });
14740
14927
 
14741
14928
  // src/commands/inbox/inboxConnectorRun.ts
@@ -14744,7 +14931,7 @@ async function inboxConnectorRun(adapter, prompt, tools, onEvent) {
14744
14931
  try {
14745
14932
  return await adapter.connectorRun({
14746
14933
  prompt,
14747
- schema: z13.toJSONSchema(inboxScanSchema, { target: "draft-07" }),
14934
+ schema: z14.toJSONSchema(inboxScanSchema, { target: "draft-07" }),
14748
14935
  tools,
14749
14936
  timeoutMs: INBOX_SCAN_TIMEOUT_MS,
14750
14937
  onEvent
@@ -14808,10 +14995,10 @@ async function openInCode(req, res) {
14808
14995
  }
14809
14996
 
14810
14997
  // src/commands/sessions/web/createCachedGhJson.ts
14811
- import { execFile as execFile9 } from "child_process";
14998
+ import { execFile as execFile10 } from "child_process";
14812
14999
  import { promisify as promisify10 } from "util";
14813
- var execFileAsync9 = promisify10(execFile9);
14814
- var CACHE_TTL_MS6 = 3e4;
15000
+ var execFileAsync9 = promisify10(execFile10);
15001
+ var CACHE_TTL_MS7 = 3e4;
14815
15002
  function createCachedGhJson(args, parse5, fallback, options2 = {}) {
14816
15003
  const { cacheFallback = true } = options2;
14817
15004
  const cache7 = /* @__PURE__ */ new Map();
@@ -14832,7 +15019,7 @@ function createCachedGhJson(args, parse5, fallback, options2 = {}) {
14832
15019
  value = fallback;
14833
15020
  }
14834
15021
  if (cacheFallback || value !== fallback)
14835
- cache7.set(key, { value, expires: now + CACHE_TTL_MS6 });
15022
+ cache7.set(key, { value, expires: now + CACHE_TTL_MS7 });
14836
15023
  return value;
14837
15024
  };
14838
15025
  }
@@ -14922,9 +15109,9 @@ async function previewImage(req, res) {
14922
15109
  }
14923
15110
 
14924
15111
  // src/commands/sessions/web/getCurrentBranch.ts
14925
- import { execFile as execFile10 } from "child_process";
15112
+ import { execFile as execFile11 } from "child_process";
14926
15113
  import { promisify as promisify11 } from "util";
14927
- var execFileAsync10 = promisify11(execFile10);
15114
+ var execFileAsync10 = promisify11(execFile11);
14928
15115
  async function getCurrentBranch(cwd) {
14929
15116
  try {
14930
15117
  const { stdout } = await execFileAsync10(
@@ -16747,7 +16934,7 @@ async function findAppId(client, bundleId) {
16747
16934
  }
16748
16935
 
16749
16936
  // src/commands/testflight/runOp.ts
16750
- import { execFile as execFile11 } from "child_process";
16937
+ import { execFile as execFile12 } from "child_process";
16751
16938
  import { promisify as promisify12 } from "util";
16752
16939
 
16753
16940
  // src/commands/testflight/cleanOpStderr.ts
@@ -16761,7 +16948,7 @@ function cleanOpStderr(stderr) {
16761
16948
  }
16762
16949
 
16763
16950
  // src/commands/testflight/runOp.ts
16764
- var run = promisify12(execFile11);
16951
+ var run = promisify12(execFile12);
16765
16952
  var runOp = async (args) => {
16766
16953
  try {
16767
16954
  const { stdout } = await run("op", args, { maxBuffer: 10 * 1024 * 1024 });
@@ -17150,14 +17337,18 @@ function restoreConfigWriteSecrets(key, value, cwd, globalConfigPath) {
17150
17337
  return restoreConfigSecrets(value, getNestedValue(stored, key), node);
17151
17338
  }
17152
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
+
17153
17346
  // src/commands/config/applyConfigSet.ts
17154
17347
  function applyConfigSet(key, coerced, global, cwd = process.cwd(), globalConfigPath) {
17155
17348
  if (!global && isGlobalOnlyConfigKey(key)) {
17156
17349
  return {
17157
17350
  ok: false,
17158
- errors: [
17159
- `"${key}" is a user (node)-only key. Use --node to set it in ~/.assist.yml`
17160
- ]
17351
+ errors: [notPerRepoKeyMessage(key, "Set")]
17161
17352
  };
17162
17353
  }
17163
17354
  const raw = global ? loadGlobalConfigRaw(globalConfigPath) : loadProjectConfig(cwd);
@@ -17177,9 +17368,7 @@ function globalOnlyRepoKeyError(key, verb) {
17177
17368
  if (!isGlobalOnlyConfigKey(key)) return void 0;
17178
17369
  return {
17179
17370
  ok: false,
17180
- errors: [
17181
- `"${key}" is a user (node)-only key. ${verb} it in ~/.assist.yml with --node rather than in repo (db)`
17182
- ]
17371
+ errors: [notPerRepoKeyMessage(key, verb)]
17183
17372
  };
17184
17373
  }
17185
17374
 
@@ -17195,9 +17384,9 @@ var UnknownRepoConfigError = class extends Error {
17195
17384
  };
17196
17385
  function resolveNamedRepoWriteLabel(globalRaw, name2, source = "~/.assist.yml") {
17197
17386
  const repos2 = globalRaw.repos;
17198
- const entries = repos2 && typeof repos2 === "object" && !Array.isArray(repos2) ? repos2 : {};
17387
+ const entries2 = repos2 && typeof repos2 === "object" && !Array.isArray(repos2) ? repos2 : {};
17199
17388
  const candidates = originKeyCandidates(name2);
17200
- const matches = Object.keys(entries).filter((key) => candidates.has(key));
17389
+ const matches = Object.keys(entries2).filter((key) => candidates.has(key));
17201
17390
  if (matches.length === 0) {
17202
17391
  throw new UnknownRepoConfigError(
17203
17392
  `No repo in ${source} matches "${name2}". Use an existing repos key (full origin, org/repo, or bare repo name).`
@@ -17621,9 +17810,7 @@ function applyConfigUnset(key, global, cwd = process.cwd(), globalConfigPath) {
17621
17810
  if (!global && isGlobalOnlyConfigKey(key)) {
17622
17811
  return {
17623
17812
  ok: false,
17624
- errors: [
17625
- `"${key}" is a user (node)-only key. Use --node to unset it in ~/.assist.yml`
17626
- ]
17813
+ errors: [notPerRepoKeyMessage(key, "Unset")]
17627
17814
  };
17628
17815
  }
17629
17816
  const target = global ? "global" : "project";
@@ -18223,11 +18410,11 @@ async function uploadPrImage(req, res) {
18223
18410
  import { readFile as readFile3, stat as stat3, writeFile as writeFile2 } from "fs/promises";
18224
18411
 
18225
18412
  // src/commands/sessions/web/formatWithOxfmt.ts
18226
- import { execFile as execFile12 } from "child_process";
18413
+ import { execFile as execFile13 } from "child_process";
18227
18414
  import { existsSync as existsSync34 } from "fs";
18228
18415
  import { dirname as dirname18, join as join43 } from "path";
18229
18416
  import { promisify as promisify13 } from "util";
18230
- var execFileAsync11 = promisify13(execFile12);
18417
+ var execFileAsync11 = promisify13(execFile13);
18231
18418
  var TIMEOUT_MS2 = 15e3;
18232
18419
  function findOxfmtScript(root2) {
18233
18420
  let dir = root2;
@@ -18419,6 +18606,8 @@ var routes2 = {
18419
18606
  "OPTIONS /api/sessions/review-from-github": sessionFromGithubPreflight,
18420
18607
  "POST /api/sessions/docs-feedback": docsFeedback,
18421
18608
  "OPTIONS /api/sessions/docs-feedback": sessionFromGithubPreflight,
18609
+ "POST /api/link-status": linkStatus,
18610
+ "OPTIONS /api/link-status": sessionFromGithubPreflight,
18422
18611
  "POST /api/browser": browserRelay,
18423
18612
  "POST /api/client-errors": clientErrors,
18424
18613
  "POST /api/open-in-code": openInCode,
@@ -18980,7 +19169,7 @@ function repoDirExists(cwd) {
18980
19169
  }
18981
19170
 
18982
19171
  // src/commands/sessions/daemon/worktree/git.ts
18983
- import { execFile as execFile13, execFileSync as execFileSync6 } from "child_process";
19172
+ import { execFile as execFile14, execFileSync as execFileSync6 } from "child_process";
18984
19173
  function isWindowsPath(cwd) {
18985
19174
  return /^[A-Za-z]:[\\/]/.test(cwd);
18986
19175
  }
@@ -19000,7 +19189,7 @@ function gitInvocation(cwd, args) {
19000
19189
  function git2(cwd, args, timeout) {
19001
19190
  const { file, argv, options: options2 } = gitInvocation(cwd, args);
19002
19191
  return new Promise((resolve36, reject) => {
19003
- execFile13(file, argv, { ...options2, timeout }, (error, stdout) => {
19192
+ execFile14(file, argv, { ...options2, timeout }, (error, stdout) => {
19004
19193
  if (error) reject(error);
19005
19194
  else resolve36(stdout.toString());
19006
19195
  });
@@ -19323,8 +19512,8 @@ function toolStatus(pkg, scriptName, hasPackage, configScriptNames) {
19323
19512
  };
19324
19513
  }
19325
19514
  function loadConfigScriptNames() {
19326
- const entries = loadConfig().run ?? [];
19327
- 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] : []));
19328
19517
  }
19329
19518
  function buildToolStatuses(pkg, configScriptNames) {
19330
19519
  const status2 = (script, has) => toolStatus(pkg, script, has, configScriptNames);
@@ -20140,11 +20329,11 @@ function matchesChangedFiles(entry, changedFiles2) {
20140
20329
  );
20141
20330
  return true;
20142
20331
  }
20143
- function filterByChangedFiles(entries) {
20332
+ function filterByChangedFiles(entries2) {
20144
20333
  const isGated = (e) => !!(e.filter || e.outsideRoots);
20145
- if (!entries.some(isGated)) return entries;
20334
+ if (!entries2.some(isGated)) return entries2;
20146
20335
  const changedFiles2 = getChangedFiles();
20147
- return entries.filter(
20336
+ return entries2.filter(
20148
20337
  (entry) => !isGated(entry) || matchesChangedFiles(entry, changedFiles2)
20149
20338
  );
20150
20339
  }
@@ -20235,12 +20424,12 @@ function resolveVerifyMode() {
20235
20424
 
20236
20425
  // src/commands/verify/run/selectEntriesForMode.ts
20237
20426
  var FIX_SUFFIX = ":fix";
20238
- function selectEntriesForMode(entries, mode) {
20427
+ function selectEntriesForMode(entries2, mode) {
20239
20428
  if (mode === "check") {
20240
- return entries.filter((e) => !e.name.endsWith(FIX_SUFFIX));
20429
+ return entries2.filter((e) => !e.name.endsWith(FIX_SUFFIX));
20241
20430
  }
20242
- const names = new Set(entries.map((e) => e.name));
20243
- 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}`));
20244
20433
  }
20245
20434
 
20246
20435
  // src/commands/verify/run/resolveEntries.ts
@@ -20361,9 +20550,9 @@ function exitIfFailed(failed3) {
20361
20550
  logFailedScripts(failed3);
20362
20551
  process.exit(1);
20363
20552
  }
20364
- async function runAllEntries(entries) {
20553
+ async function runAllEntries(entries2) {
20365
20554
  const startTime = Date.now();
20366
- const results = await Promise.all(entries.map((entry) => runEntry(entry)));
20555
+ const results = await Promise.all(entries2.map((entry) => runEntry(entry)));
20367
20556
  return { results, totalMs: Date.now() - startTime };
20368
20557
  }
20369
20558
  function handleResults(results, totalCount) {
@@ -20373,32 +20562,32 @@ All ${totalCount} verify command(s) passed`);
20373
20562
  }
20374
20563
 
20375
20564
  // src/commands/verify/run.ts
20376
- function printEntryList(entries) {
20377
- console.log(`Running ${entries.length} verify command(s) in parallel:`);
20378
- 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) {
20379
20568
  console.log(` - ${entry.name}`);
20380
20569
  }
20381
20570
  }
20382
20571
  async function run2(options2 = {}) {
20383
20572
  setVerbose(!!options2.verbose);
20384
20573
  const allEntries = resolveEntries();
20385
- const entries = options2.all ? allEntries : filterByChangedFiles(allEntries);
20574
+ const entries2 = options2.all ? allEntries : filterByChangedFiles(allEntries);
20386
20575
  if (allEntries.length === 0) {
20387
20576
  console.log("No verify commands found");
20388
20577
  return;
20389
20578
  }
20390
- if (entries.length === 0) {
20579
+ if (entries2.length === 0) {
20391
20580
  console.log("No verify commands matched changed files \u2014 skipping");
20392
20581
  return;
20393
20582
  }
20394
- printEntryList(entries);
20583
+ printEntryList(entries2);
20395
20584
  const releaseVerifying = signalVerifying();
20396
20585
  try {
20397
- const { results, totalMs } = await runAllEntries(entries);
20586
+ const { results, totalMs } = await runAllEntries(entries2);
20398
20587
  if (options2.measure) {
20399
20588
  printMeasureTable(results, totalMs);
20400
20589
  }
20401
- handleResults(results, entries.length);
20590
+ handleResults(results, entries2.length);
20402
20591
  } finally {
20403
20592
  releaseVerifying();
20404
20593
  }
@@ -20788,19 +20977,19 @@ var documentedKeys = /* @__PURE__ */ new Set();
20788
20977
  function getDocumentedConfigKeys() {
20789
20978
  return documentedKeys;
20790
20979
  }
20791
- function renderConfigHelp(entries, preamble) {
20792
- const width2 = Math.max(...entries.map((entry) => entry.setter.length));
20793
- 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(
20794
20983
  (entry) => ` ${entry.setter.padEnd(width2)} # ${entry.note}`
20795
20984
  );
20796
20985
  const body = preamble ? ["", preamble, "", "Config:", ...lines] : ["", "Config:", ...lines];
20797
20986
  return body.join("\n");
20798
20987
  }
20799
- function configHelp(command, entries, preamble) {
20800
- 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);
20801
20990
  return command.addHelpText(
20802
20991
  "after",
20803
- () => renderConfigHelp(entries, preamble)
20992
+ () => renderConfigHelp(entries2, preamble)
20804
20993
  );
20805
20994
  }
20806
20995
 
@@ -21414,12 +21603,12 @@ async function moveManualCheck(orm, item, fromIdx, checkIdx, toIdx) {
21414
21603
  }
21415
21604
 
21416
21605
  // src/commands/sessions/shared/askCheckInputSchema.ts
21417
- import { z as z14 } from "zod";
21418
- var text17 = z14.string().trim().min(1);
21419
- var askCheckInputSchema = z14.object({
21606
+ import { z as z15 } from "zod";
21607
+ var text17 = z15.string().trim().min(1);
21608
+ var askCheckInputSchema = z15.object({
21420
21609
  title: text17,
21421
- steps: z14.array(text17).min(1, "Give at least 1 step"),
21422
- before: z14.array(text17).optional(),
21610
+ steps: z15.array(text17).min(1, "Give at least 1 step"),
21611
+ before: z15.array(text17).optional(),
21423
21612
  changed: text17.optional()
21424
21613
  });
21425
21614
  var CHECK_RESULT_KEY = "result";
@@ -21810,23 +21999,23 @@ async function requireQuestionSession() {
21810
21999
  }
21811
22000
 
21812
22001
  // src/commands/sessions/shared/askQuestionInputSchema.ts
21813
- import { z as z15 } from "zod";
21814
- var askQuestionOptionSchema = z15.object({
21815
- label: z15.string().min(1),
21816
- description: z15.string(),
21817
- 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()
21818
22007
  });
21819
- var askQuestionSchema = z15.object({
21820
- question: z15.string().min(1),
21821
- header: z15.string().min(1),
21822
- multiSelect: z15.boolean(),
21823
- 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(
21824
22013
  (options2) => new Set(options2.map((option) => option.label)).size === options2.length,
21825
22014
  "Option labels must be unique within a question"
21826
22015
  )
21827
22016
  });
21828
- var askQuestionInputSchema = z15.object({
21829
- 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(
21830
22019
  (questions) => new Set(questions.map((q) => q.question)).size === questions.length,
21831
22020
  "Question texts must be unique"
21832
22021
  )
@@ -22141,13 +22330,13 @@ function buildGraph(names, edges) {
22141
22330
  function nextReady(names, emitted, indegree) {
22142
22331
  return names.find((n) => !emitted.has(n) && (indegree.get(n) ?? 0) === 0);
22143
22332
  }
22144
- function topoSort(entries, edges) {
22145
- const names = entries.map((e) => e.raw);
22333
+ function topoSort(entries2, edges) {
22334
+ const names = entries2.map((e) => e.raw);
22146
22335
  const { indegree, children } = buildGraph(names, edges);
22147
- const byRaw = new Map(entries.map((e) => [e.raw, e.table]));
22336
+ const byRaw = new Map(entries2.map((e) => [e.raw, e.table]));
22148
22337
  const ordered = [];
22149
22338
  const emitted = /* @__PURE__ */ new Set();
22150
- while (ordered.length < entries.length) {
22339
+ while (ordered.length < entries2.length) {
22151
22340
  const next3 = nextReady(names, emitted, indegree);
22152
22341
  if (!next3)
22153
22342
  throw new Error("Cannot dump: foreign-key cycle between tables.");
@@ -22420,11 +22609,11 @@ async function locateConversation(conversationId) {
22420
22609
 
22421
22610
  // src/commands/sessions/shared/transcriptMessages.ts
22422
22611
  function transcriptMessages(reader, lines) {
22423
- const entries = lines.flatMap((line) => {
22612
+ const entries2 = lines.flatMap((line) => {
22424
22613
  const entry = line.trim() ? parseRolloutEntry(line) : null;
22425
22614
  return entry ? [entry] : [];
22426
22615
  });
22427
- return reader.events(entries).flatMap((event) => {
22616
+ return reader.events(entries2).flatMap((event) => {
22428
22617
  if (event.kind === "message")
22429
22618
  return [{ role: event.role, text: event.text }];
22430
22619
  if (event.kind === "tool")
@@ -22837,8 +23026,8 @@ async function comments2(id) {
22837
23026
  const found = await findOneItem(id);
22838
23027
  if (!found) process.exit(1);
22839
23028
  const { item } = found;
22840
- const entries = item.comments ?? [];
22841
- if (entries.length === 0) {
23029
+ const entries2 = item.comments ?? [];
23030
+ if (entries2.length === 0) {
22842
23031
  console.log(chalk52.dim(`No comments on item ${formatItemId(item.id)}.`));
22843
23032
  return;
22844
23033
  }
@@ -22846,7 +23035,7 @@ async function comments2(id) {
22846
23035
  chalk52.bold(`Comments for ${formatItemId(item.id)}: ${item.name}
22847
23036
  `)
22848
23037
  );
22849
- for (const entry of entries) {
23038
+ for (const entry of entries2) {
22850
23039
  console.log(`${formatComment(entry)}
22851
23040
  `);
22852
23041
  }
@@ -23411,21 +23600,21 @@ async function list(options2) {
23411
23600
  import chalk64 from "chalk";
23412
23601
 
23413
23602
  // src/commands/backlog/propose/proposedItemSchema.ts
23414
- import { z as z16 } from "zod";
23415
- var proposedPhaseSchema = z16.strictObject({
23416
- 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(
23417
23606
  (name2) => name2.toLowerCase() !== REVIEW_PHASE_NAME.toLowerCase(),
23418
23607
  `"${REVIEW_PHASE_NAME}" is owned by the runner and appended to every plan automatically \u2014 remove this phase`
23419
23608
  ),
23420
- tasks: z16.array(z16.string().trim().min(1)).min(1, "a phase needs at least one task"),
23421
- 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([])
23422
23611
  });
23423
- var proposedItemSchema = z16.strictObject({
23424
- name: z16.string().trim().min(1, "name is required"),
23425
- type: z16.enum(["story", "bug"]),
23426
- description: z16.string().optional(),
23427
- acceptanceCriteria: z16.array(z16.string().trim().min(1)).default([]),
23428
- 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([])
23429
23618
  });
23430
23619
 
23431
23620
  // src/commands/backlog/propose/readProposedItem.ts
@@ -25012,21 +25201,21 @@ async function persistPhaseSessionId(itemId2, phaseIdx, claudeSessionId) {
25012
25201
  import { mkdirSync as mkdirSync18, readFileSync as readFileSync36, rmSync as rmSync4, writeFileSync as writeFileSync27 } from "fs";
25013
25202
  import { homedir as homedir18 } from "os";
25014
25203
  import { dirname as dirname31, join as join63 } from "path";
25015
- import { z as z17 } from "zod";
25016
- var activitySchema = z17.object({
25017
- kind: z17.enum(["command", "backlog"]),
25018
- harness: z17.enum(["claude", "codex", "pi"]).optional(),
25019
- name: z17.string().optional(),
25020
- itemId: z17.number().optional(),
25021
- itemName: z17.string().optional(),
25022
- itemIds: z17.array(z17.number()).optional(),
25023
- phase: z17.number().optional(),
25024
- phaseName: z17.string().optional(),
25025
- totalPhases: z17.number().optional(),
25026
- claudeSessionId: z17.string().optional(),
25027
- harnessSessionId: z17.string().optional(),
25028
- watchState: z17.enum(["waiting", "updating"]).optional(),
25029
- 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()
25030
25219
  });
25031
25220
  function activityPath(sessionId2) {
25032
25221
  return join63(homedir18(), ".assist", "activity", `activity-${sessionId2}.json`);
@@ -26476,9 +26665,9 @@ function registerUpdateFieldCommand(cmd) {
26476
26665
  import chalk114 from "chalk";
26477
26666
 
26478
26667
  // src/commands/backlog/updatePlan/planUpdateSchema.ts
26479
- import { z as z18 } from "zod";
26480
- var planUpdateSchema = z18.strictObject({
26481
- 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")
26482
26671
  });
26483
26672
 
26484
26673
  // src/commands/backlog/updatePlan/readPlanUpdate.ts
@@ -26964,10 +27153,10 @@ function printAcceptanceCriteria(criteria) {
26964
27153
  console.log();
26965
27154
  }
26966
27155
  function printComments(item) {
26967
- const entries = item.comments ?? [];
26968
- if (entries.length === 0) return;
27156
+ const entries2 = item.comments ?? [];
27157
+ if (entries2.length === 0) return;
26969
27158
  console.log(chalk120.bold("Comments"));
26970
- for (const entry of entries) {
27159
+ for (const entry of entries2) {
26971
27160
  console.log(` ${formatComment(entry)}`);
26972
27161
  }
26973
27162
  console.log();
@@ -27853,14 +28042,14 @@ function readSettingsPerms(key) {
27853
28042
  join64(process.cwd(), ".claude", "settings.json"),
27854
28043
  join64(process.cwd(), ".claude", "settings.local.json")
27855
28044
  ];
27856
- const entries = [];
28045
+ const entries2 = [];
27857
28046
  for (const p of paths) {
27858
- entries.push(...readPermissionArray(p, key));
28047
+ entries2.push(...readPermissionArray(p, key));
27859
28048
  }
27860
28049
  const harness = activeHarness();
27861
28050
  if (harness)
27862
- entries.push(...harnessAdapter(harness).permissionRules?.(key) ?? []);
27863
- return entries;
28051
+ entries2.push(...harnessAdapter(harness).permissionRules?.(key) ?? []);
28052
+ return entries2;
27864
28053
  }
27865
28054
  function readPermissionArray(filePath, key) {
27866
28055
  if (!existsSync56(filePath)) return [];
@@ -27893,9 +28082,9 @@ function shellEntries(map, toolName) {
27893
28082
  function normCmd(cmd) {
27894
28083
  return cmd.replace(FD_DEVNULL_RE2, "").replace(FD_REDIRECT_RE2, "").trim().replace(DOTSLASH_RE, "");
27895
28084
  }
27896
- function findMatch2(entries, command) {
28085
+ function findMatch2(entries2, command) {
27897
28086
  const norm = normCmd(command);
27898
- return entries.find(
28087
+ return entries2.find(
27899
28088
  (e) => e.wildcard ? norm === e.command || norm.startsWith(`${e.command} `) : norm === e.command
27900
28089
  )?.command;
27901
28090
  }
@@ -27907,9 +28096,9 @@ function matchesDeny(toolName, command) {
27907
28096
  if (!denyCache) denyCache = loadPerms("deny");
27908
28097
  return findMatch2(shellEntries(denyCache, toolName), command);
27909
28098
  }
27910
- function parsePerms(entries) {
28099
+ function parsePerms(entries2) {
27911
28100
  const map = /* @__PURE__ */ new Map();
27912
- for (const entry of entries) {
28101
+ for (const entry of entries2) {
27913
28102
  const m = entry.match(TOOL_RE);
27914
28103
  if (m) {
27915
28104
  const tool = m[1];
@@ -28906,14 +29095,14 @@ import { readdirSync as readdirSync11, statSync as statSync11, unlinkSync as unl
28906
29095
  import { join as join69 } from "path";
28907
29096
  var STALE_AFTER_MS = 30 * 60 * 1e3;
28908
29097
  function sweepRestrictedDir(dir = getRestrictedDir()) {
28909
- let entries;
29098
+ let entries2;
28910
29099
  try {
28911
- entries = readdirSync11(dir);
29100
+ entries2 = readdirSync11(dir);
28912
29101
  } catch {
28913
29102
  return;
28914
29103
  }
28915
29104
  const cutoff = Date.now() - STALE_AFTER_MS;
28916
- for (const entry of entries) {
29105
+ for (const entry of entries2) {
28917
29106
  const path128 = join69(dir, entry);
28918
29107
  try {
28919
29108
  if (statSync11(path128).mtimeMs < cutoff) unlinkSync8(path128);
@@ -30130,8 +30319,8 @@ function walkSourceFiles(dir, results) {
30130
30319
  return;
30131
30320
  }
30132
30321
  const extensions = [".ts", ".tsx"];
30133
- const entries = fs29.readdirSync(dir, { withFileTypes: true });
30134
- for (const entry of entries) {
30322
+ const entries2 = fs29.readdirSync(dir, { withFileTypes: true });
30323
+ for (const entry of entries2) {
30135
30324
  const fullPath = path44.join(dir, entry.name);
30136
30325
  if (entry.isDirectory()) {
30137
30326
  if (entry.name !== "node_modules" && entry.name !== ".git") {
@@ -31549,14 +31738,14 @@ function formatTime(time) {
31549
31738
  var indent2 = (text18, prefix2) => text18.split("\n").map((line) => `${prefix2}${line}`);
31550
31739
  function formatConsoleEntries({
31551
31740
  recording,
31552
- entries
31741
+ entries: entries2
31553
31742
  }) {
31554
31743
  if (!recording)
31555
31744
  return [
31556
31745
  `console recording is off; tick "Record console warnings and errors" on the assist extension's options page`
31557
31746
  ];
31558
- if (entries.length === 0) return ["no console entries match"];
31559
- return entries.flatMap((entry) => [
31747
+ if (entries2.length === 0) return ["no console entries match"];
31748
+ return entries2.flatMap((entry) => [
31560
31749
  `${formatTime(entry.time)} ${entry.level} ${entry.url}`,
31561
31750
  ...indent2(entry.message, " "),
31562
31751
  ...entry.stack ? indent2(entry.stack, " ") : []
@@ -32902,30 +33091,30 @@ import { dirname as dirname36 } from "path";
32902
33091
  import chalk172 from "chalk";
32903
33092
 
32904
33093
  // src/commands/devlog/write/devEntryInputSchema.ts
32905
- import { z as z19 } from "zod";
32906
- var oneLine = z19.string().trim().min(1).refine((value) => !value.includes("\n"), "must be a single line");
32907
- 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");
32908
33097
  var MAX_ITEM_LENGTH = 80;
32909
33098
  var itemText = oneLine.refine(
32910
33099
  (value) => value.length <= MAX_ITEM_LENGTH,
32911
33100
  `must be a short changelog phrase (at most ${MAX_ITEM_LENGTH} characters)`
32912
33101
  );
32913
- 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([]);
32914
33103
  function datesWithinWeek(week, dates) {
32915
33104
  if (!isValidWeek(week)) return true;
32916
33105
  const { start: start2, end } = isoWeekRange(week);
32917
33106
  return start2 <= dates.first && dates.first <= dates.last && dates.last <= end;
32918
33107
  }
32919
- var devEntryInputSchema = z19.object({
32920
- 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"),
32921
33110
  title: oneLine,
32922
- dates: z19.object({ first: isoDate, last: isoDate }).strict(),
32923
- 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(),
32924
33113
  aiGenerated: oneLine,
32925
33114
  added: changeItems,
32926
33115
  changed: changeItems,
32927
33116
  fixed: changeItems,
32928
- lede: z19.string().trim().min(1)
33117
+ lede: z20.string().trim().min(1)
32929
33118
  }).strict().refine((entry) => datesWithinWeek(entry.week, entry.dates), {
32930
33119
  message: "first and last must be in order and within the week",
32931
33120
  path: ["dates"]
@@ -33563,17 +33752,17 @@ function isLockedDll(debugDir) {
33563
33752
  return null;
33564
33753
  }
33565
33754
  function findFirstLockedDll(dir) {
33566
- let entries;
33755
+ let entries2;
33567
33756
  try {
33568
- entries = readdirSync14(dir);
33757
+ entries2 = readdirSync14(dir);
33569
33758
  } catch {
33570
33759
  return null;
33571
33760
  }
33572
- if (entries.includes("bin")) {
33761
+ if (entries2.includes("bin")) {
33573
33762
  const locked = isLockedDll(join85(dir, "bin", "Debug"));
33574
33763
  if (locked) return locked;
33575
33764
  }
33576
- for (const entry of entries) {
33765
+ for (const entry of entries2) {
33577
33766
  if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
33578
33767
  continue;
33579
33768
  const found = findFirstLockedDll(join85(dir, entry));
@@ -33650,13 +33839,13 @@ import path49 from "path";
33650
33839
  function findSlnFiles(dir, maxDepth, depth = 0) {
33651
33840
  if (depth > maxDepth) return [];
33652
33841
  const results = [];
33653
- let entries;
33842
+ let entries2;
33654
33843
  try {
33655
- entries = readdirSync15(dir);
33844
+ entries2 = readdirSync15(dir);
33656
33845
  } catch {
33657
33846
  return results;
33658
33847
  }
33659
- for (const entry of entries) {
33848
+ for (const entry of entries2) {
33660
33849
  if (entry.startsWith(".") || entry === "node_modules" || entry === "packages")
33661
33850
  continue;
33662
33851
  const full = path49.join(dir, entry);
@@ -35367,11 +35556,11 @@ function orderDepthFirst(issues) {
35367
35556
  function buildFixStructurePlan(issues, options2) {
35368
35557
  const context = { ...options2, stripLabels: options2.stripLabels ?? [] };
35369
35558
  const byId = new Map(issues.map((issue) => [issue.id, issue]));
35370
- const entries = [];
35559
+ const entries2 = [];
35371
35560
  const tooDeep = [];
35372
35561
  for (const issue of orderDepthFirst(issues)) {
35373
35562
  const entry = buildPlanEntry(issue, context);
35374
- entries.push(entry);
35563
+ entries2.push(entry);
35375
35564
  if (entry.level === null) {
35376
35565
  tooDeep.push({
35377
35566
  issue,
@@ -35380,10 +35569,10 @@ function buildFixStructurePlan(issues, options2) {
35380
35569
  }
35381
35570
  }
35382
35571
  return {
35383
- entries,
35572
+ entries: entries2,
35384
35573
  tooDeep,
35385
- typeChangeCount: entries.filter((entry) => entry.typeChange).length,
35386
- labelRemovalCount: entries.reduce(
35574
+ typeChangeCount: entries2.filter((entry) => entry.typeChange).length,
35575
+ labelRemovalCount: entries2.reduce(
35387
35576
  (total2, entry) => total2 + entry.labelRemovals.length,
35388
35577
  0
35389
35578
  )
@@ -37144,12 +37333,12 @@ function truncate2(text18) {
37144
37333
  }
37145
37334
 
37146
37335
  // src/commands/inbox/parseInboxScanOutput.ts
37147
- import { z as z20 } from "zod";
37336
+ import { z as z21 } from "zod";
37148
37337
  function parseInboxScanOutput(output) {
37149
37338
  const parsed = inboxScanSchema.safeParse(output);
37150
37339
  if (!parsed.success)
37151
37340
  throw new Error(
37152
- `Inbox scan returned malformed output: ${z20.prettifyError(parsed.error)}`
37341
+ `Inbox scan returned malformed output: ${z21.prettifyError(parsed.error)}`
37153
37342
  );
37154
37343
  return parsed.data.messages;
37155
37344
  }
@@ -37752,41 +37941,41 @@ function stringOrUndefined(value) {
37752
37941
  }
37753
37942
 
37754
37943
  // src/commands/sessions/daemon/persistedSessionSchema.ts
37755
- import { z as z21 } from "zod";
37756
- var persistedSessionSchema = z21.object({
37757
- id: z21.string().optional(),
37758
- name: z21.string(),
37759
- title: z21.string().optional(),
37760
- generatedTitle: z21.string().optional(),
37761
- subtitle: z21.string().optional(),
37762
- commandType: z21.enum(["claude", "run", "assist"]),
37763
- harness: z21.enum(["claude", "codex", "pi"]).optional(),
37764
- status: z21.enum(["running", "waiting", "done", "error", "stopped"]).optional(),
37765
- error: z21.string().optional(),
37766
- cwd: z21.string(),
37767
- startedAt: z21.number(),
37768
- runningMs: z21.number().optional(),
37769
- claudeSessionId: z21.string().optional(),
37770
- harnessSessionId: z21.string().optional(),
37771
- initialPrompt: z21.string().optional(),
37772
- runName: z21.string().optional(),
37773
- runArgs: z21.array(z21.string()).optional(),
37774
- 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(),
37775
37964
  activity: activitySchema.optional(),
37776
- starred: z21.boolean().optional(),
37777
- watcher: z21.boolean().optional(),
37778
- divergenceEscalation: z21.boolean().optional(),
37779
- design: z21.boolean().optional(),
37780
- auto: z21.boolean().optional(),
37781
- model: z21.string().optional(),
37782
- autoAdvance: z21.boolean().optional(),
37783
- autoApprove: z21.boolean().optional(),
37784
- reviewStarted: z21.boolean().optional(),
37785
- launchedFrom: z21.string().optional(),
37786
- pendingPrompts: z21.array(z21.string()).optional(),
37787
- interrupted: z21.object({ reason: z21.string(), at: z21.number() }).optional(),
37788
- awaitingSeed: z21.boolean().optional(),
37789
- 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()
37790
37979
  });
37791
37980
 
37792
37981
  // src/commands/sessions/daemon/toPersistedSession.ts
@@ -37958,7 +38147,7 @@ function quoteForPosixShell(value) {
37958
38147
  }
37959
38148
 
37960
38149
  // src/commands/sessions/daemon/worktree/stopInstall.ts
37961
- import { execFile as execFile14 } from "child_process";
38150
+ import { execFile as execFile15 } from "child_process";
37962
38151
  var running2 = /* @__PURE__ */ new Map();
37963
38152
  function trackInstall(worktreePath, child2) {
37964
38153
  const children = running2.get(worktreePath) ?? /* @__PURE__ */ new Set();
@@ -37984,7 +38173,7 @@ function stopInstall(worktreePath) {
37984
38173
  }
37985
38174
  function killTree(pid) {
37986
38175
  if (process.platform === "win32") {
37987
- execFile14(
38176
+ execFile15(
37988
38177
  "taskkill",
37989
38178
  ["/T", "/F", "/PID", String(pid)],
37990
38179
  { windowsHide: true },
@@ -38892,11 +39081,11 @@ function uniqueTexts(boxes) {
38892
39081
  // src/commands/miro/keptTexts.ts
38893
39082
  function warnUnmatched(file, unmatched) {
38894
39083
  if (unmatched.length === 0) return;
38895
- const entries = unmatched.map((entry) => ` - ${entry}`).join("\n");
39084
+ const entries2 = unmatched.map((entry) => ` - ${entry}`).join("\n");
38896
39085
  console.error(
38897
39086
  chalk208.yellow(
38898
39087
  `${unmatched.length} ${unmatched.length === 1 ? "entry" : "entries"} in ${file} matched no box text:
38899
- ${entries}`
39088
+ ${entries2}`
38900
39089
  )
38901
39090
  );
38902
39091
  }
@@ -39880,7 +40069,7 @@ function extractVoyagerPosts(body) {
39880
40069
  // src/commands/netcap/extractPostsFromCapture.ts
39881
40070
  function captureEntries(captureFile) {
39882
40071
  const lines = readFileSync62(captureFile, "utf8").split("\n").filter(Boolean);
39883
- const entries = [];
40072
+ const entries2 = [];
39884
40073
  for (const line of lines) {
39885
40074
  let entry;
39886
40075
  try {
@@ -39890,9 +40079,9 @@ function captureEntries(captureFile) {
39890
40079
  }
39891
40080
  if (typeof entry.url !== "string" || typeof entry.responseBody !== "string")
39892
40081
  continue;
39893
- entries.push({ url: entry.url, responseBody: entry.responseBody });
40082
+ entries2.push({ url: entry.url, responseBody: entry.responseBody });
39894
40083
  }
39895
- return entries;
40084
+ return entries2;
39896
40085
  }
39897
40086
  function dedupeByActivity(posts) {
39898
40087
  const byUrn = /* @__PURE__ */ new Map();
@@ -39909,9 +40098,9 @@ function dedupeByActivity(posts) {
39909
40098
  return [...byUrn.values(), ...noUrn];
39910
40099
  }
39911
40100
  function extractPostsFromCapture(captureFile) {
39912
- const entries = captureEntries(captureFile);
39913
- const rscBodies = entries.filter((e) => /rsc-action/.test(e.url)).map((e) => e.responseBody);
39914
- 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);
39915
40104
  const author = rscBodies.map(findAuthorSlug).find(Boolean);
39916
40105
  const all = [
39917
40106
  ...rscBodies.flatMap((body) => extractLinkedInPosts(body, author)),
@@ -40362,13 +40551,13 @@ import { join as join98 } from "path";
40362
40551
  var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
40363
40552
  function removeStaleCommentsCaches(cwd = process.cwd()) {
40364
40553
  const dir = join98(cwd, ".assist");
40365
- let entries;
40554
+ let entries2;
40366
40555
  try {
40367
- entries = readdirSync18(dir);
40556
+ entries2 = readdirSync18(dir);
40368
40557
  } catch {
40369
40558
  return;
40370
40559
  }
40371
- for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
40560
+ for (const entry of entries2.filter((e) => STALE_PATTERN.test(e))) {
40372
40561
  unlinkSync16(join98(dir, entry));
40373
40562
  }
40374
40563
  }
@@ -43048,9 +43237,7 @@ async function writeConfigKeys(writes, scope, cwd = process.cwd()) {
43048
43237
  if (globalOnly.length > 0) {
43049
43238
  return {
43050
43239
  ok: false,
43051
- errors: globalOnly.map(
43052
- (write2) => `"${write2.key}" is a user (node)-only key. Set it with 'assist config set ${write2.key} <value> --node'`
43053
- )
43240
+ errors: globalOnly.map((write2) => notPerRepoKeyMessage(write2.key, "Set"))
43054
43241
  };
43055
43242
  }
43056
43243
  if (scope === "repo") return writeRepoBlock(writes, cwd);
@@ -43225,8 +43412,8 @@ function findSourceFiles2(dir, options2 = {}) {
43225
43412
  if (!fs35.existsSync(dir)) {
43226
43413
  return results;
43227
43414
  }
43228
- const entries = fs35.readdirSync(dir, { withFileTypes: true });
43229
- for (const entry of entries) {
43415
+ const entries2 = fs35.readdirSync(dir, { withFileTypes: true });
43416
+ for (const entry of entries2) {
43230
43417
  const fullPath = path54.join(dir, entry.name);
43231
43418
  if (entry.isDirectory() && entry.name !== "node_modules") {
43232
43419
  results.push(...findSourceFiles2(fullPath, options2));
@@ -44176,14 +44363,14 @@ function parseRefactorYml() {
44176
44363
  return [];
44177
44364
  }
44178
44365
  const content = fs42.readFileSync(REFACTOR_YML_PATH, "utf8");
44179
- const entries = [];
44366
+ const entries2 = [];
44180
44367
  const lines = content.split("\n");
44181
44368
  let currentEntry = {};
44182
44369
  for (const line of lines) {
44183
44370
  const trimmed = line.trim();
44184
44371
  if (trimmed.startsWith("- file:")) {
44185
44372
  if (currentEntry.file) {
44186
- entries.push(currentEntry);
44373
+ entries2.push(currentEntry);
44187
44374
  }
44188
44375
  currentEntry = { file: trimmed.replace("- file:", "").trim() };
44189
44376
  } else if (trimmed.startsWith("maxLines:")) {
@@ -44194,13 +44381,13 @@ function parseRefactorYml() {
44194
44381
  }
44195
44382
  }
44196
44383
  if (currentEntry.file) {
44197
- entries.push(currentEntry);
44384
+ entries2.push(currentEntry);
44198
44385
  }
44199
- return entries;
44386
+ return entries2;
44200
44387
  }
44201
44388
  function getIgnoredFiles() {
44202
- const entries = parseRefactorYml();
44203
- 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]));
44204
44391
  }
44205
44392
 
44206
44393
  // src/commands/refactor/check/getViolations.ts
@@ -46120,11 +46307,11 @@ function insert(root2, parts2) {
46120
46307
  }
46121
46308
  }
46122
46309
  function render(node, indent4, lines) {
46123
- const entries = [...node].sort(([a, ca], [b, cb]) => {
46310
+ const entries2 = [...node].sort(([a, ca], [b, cb]) => {
46124
46311
  const dirFirst = Number(cb.size > 0) - Number(ca.size > 0);
46125
46312
  return dirFirst || a.localeCompare(b);
46126
46313
  });
46127
- for (const [name2, child2] of entries) {
46314
+ for (const [name2, child2] of entries2) {
46128
46315
  lines.push(`${indent4}${name2}${child2.size > 0 ? "/" : ""}`);
46129
46316
  render(child2, `${indent4} `, lines);
46130
46317
  }
@@ -47171,21 +47358,21 @@ function readJsonFile(path128) {
47171
47358
  }
47172
47359
 
47173
47360
  // src/commands/review/highLevel/parseHighLevelSlicesInput.ts
47174
- import { z as z22 } from "zod";
47175
- var slicesSchema = z22.array(
47176
- z22.object({
47177
- title: z22.string().min(1),
47178
- summary: z22.string(),
47179
- 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())
47180
47367
  })
47181
47368
  );
47182
- var manualTestingSchema = z22.object({
47183
- setup: z22.array(z22.string()),
47184
- 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() }))
47185
47372
  });
47186
- var slicesInputSchema = z22.union([
47373
+ var slicesInputSchema = z23.union([
47187
47374
  slicesSchema.transform((slices) => ({ slices })),
47188
- z22.object({ slices: slicesSchema, manualTesting: manualTestingSchema })
47375
+ z23.object({ slices: slicesSchema, manualTesting: manualTestingSchema })
47189
47376
  ]);
47190
47377
  function parseHighLevelSlicesInput(raw) {
47191
47378
  const parsed = slicesInputSchema.safeParse(raw);
@@ -48253,8 +48440,8 @@ function refreshElapsedText(entry) {
48253
48440
  const seconds = Math.round((Date.now() - entry.elapsedStart) / 1e3);
48254
48441
  entry.text = `${entry.elapsedPrefix ?? "elapsed"}: ${seconds}s`;
48255
48442
  }
48256
- function renderEntries(entries, frame) {
48257
- const sorted2 = [...entries].sort(
48443
+ function renderEntries(entries2, frame) {
48444
+ const sorted2 = [...entries2].sort(
48258
48445
  (a, b) => Number(Boolean(a.footer)) - Number(Boolean(b.footer))
48259
48446
  );
48260
48447
  for (const entry of sorted2) refreshElapsedText(entry);
@@ -51408,10 +51595,10 @@ function pruneSkills(targetDir, skillNames, options2) {
51408
51595
  }
51409
51596
  function unexpectedContent(skillDir) {
51410
51597
  if (!fs58.statSync(skillDir).isDirectory()) return void 0;
51411
- const entries = fs58.readdirSync(skillDir);
51412
- const others = entries.filter((entry) => entry !== "SKILL.md");
51598
+ const entries2 = fs58.readdirSync(skillDir);
51599
+ const others = entries2.filter((entry) => entry !== "SKILL.md");
51413
51600
  if (others.length > 0) return `contains ${others.sort().join(", ")}`;
51414
- return entries.length === 0 ? "no SKILL.md" : void 0;
51601
+ return entries2.length === 0 ? "no SKILL.md" : void 0;
51415
51602
  }
51416
51603
 
51417
51604
  // src/commands/sync/reportPrune.ts
@@ -51732,10 +51919,10 @@ function syncDesign(agentDir, targetBase, files) {
51732
51919
  );
51733
51920
  const skillsSource = path120.join(agentDir, "skills");
51734
51921
  const skillsTarget = path120.join(targetBase, "skills");
51735
- const entries = fs66.readdirSync(skillsSource, { withFileTypes: true }).filter(
51922
+ const entries2 = fs66.readdirSync(skillsSource, { withFileTypes: true }).filter(
51736
51923
  (entry) => !entry.isDirectory() || fs66.existsSync(path120.join(skillsSource, entry.name, "SKILL.md"))
51737
51924
  );
51738
- for (const entry of entries) {
51925
+ for (const entry of entries2) {
51739
51926
  const source = path120.join(skillsSource, entry.name);
51740
51927
  const target = path120.join(skillsTarget, entry.name);
51741
51928
  if (entry.isDirectory()) {
@@ -51744,8 +51931,8 @@ function syncDesign(agentDir, targetBase, files) {
51744
51931
  files.write(target, fs66.readFileSync(source, "utf8"));
51745
51932
  }
51746
51933
  }
51747
- console.log(`Synced ${entries.length} skill(s) to ~/.claude/skills`);
51748
- return entries.map((entry) => entry.name);
51934
+ console.log(`Synced ${entries2.length} skill(s) to ~/.claude/skills`);
51935
+ return entries2.map((entry) => entry.name);
51749
51936
  }
51750
51937
 
51751
51938
  // src/commands/sync/syncPi.ts
@@ -51800,16 +51987,20 @@ import * as fs68 from "fs";
51800
51987
  import * as path123 from "path";
51801
51988
  import chalk295 from "chalk";
51802
51989
 
51803
- // src/commands/sync/mergeSettings.ts
51990
+ // src/commands/sync/isPlainObject.ts
51804
51991
  function isPlainObject7(value) {
51805
51992
  return typeof value === "object" && value !== null && !Array.isArray(value);
51806
51993
  }
51994
+
51995
+ // src/commands/sync/canonical.ts
51807
51996
  function canonical(value) {
51808
51997
  if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
51809
51998
  if (isPlainObject7(value))
51810
51999
  return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
51811
52000
  return JSON.stringify(value);
51812
52001
  }
52002
+
52003
+ // src/commands/sync/mergeSettings.ts
51813
52004
  function unionArrays(user, assist) {
51814
52005
  const seen = new Set(user.map(canonical));
51815
52006
  const merged = [...user];
@@ -51835,6 +52026,33 @@ function mergeSettings(user, assist) {
51835
52026
  return merged;
51836
52027
  }
51837
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
+
51838
52056
  // src/commands/sync/readSourceSettings.ts
51839
52057
  import * as fs67 from "fs";
51840
52058
  import * as path122 from "path";
@@ -51858,7 +52076,10 @@ async function syncSettings(claudeDir, targetBase, options2) {
51858
52076
  const targetContent = targetExists ? fs68.readFileSync(target, "utf8") : "";
51859
52077
  const preservedUserSettings = targetExists ? JSON.parse(targetContent) : {};
51860
52078
  const mergedContent = JSON.stringify(
51861
- mergeSettings(preservedUserSettings, sourceSettings),
52079
+ mergeSettings(
52080
+ pruneStaleAssistHooks(preservedUserSettings, sourceSettings),
52081
+ sourceSettings
52082
+ ),
51862
52083
  null,
51863
52084
  " "
51864
52085
  );
@@ -52493,16 +52714,16 @@ function selectPassages(sources, selection) {
52493
52714
  }
52494
52715
 
52495
52716
  // src/commands/transcript/selectionSchema.ts
52496
- import { z as z23 } from "zod";
52497
- var selectionSchema = z23.strictObject({
52498
- keep: z23.array(
52499
- z23.strictObject({
52500
- file: z23.string().trim().min(1, "file is required"),
52501
- from: z23.string().trim().min(1, "from is required"),
52502
- 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")
52503
52724
  })
52504
52725
  ).min(1, "a selection needs at least one keep range"),
52505
- removed: z23.array(z23.string().trim().min(1)).default([])
52726
+ removed: z24.array(z24.string().trim().min(1)).default([])
52506
52727
  });
52507
52728
 
52508
52729
  // src/commands/transcript/widenAudienceInText.ts
@@ -52632,9 +52853,9 @@ function registerTranscript(program) {
52632
52853
  }
52633
52854
 
52634
52855
  // src/commands/verify/reportVerifyProblems.ts
52635
- function verifySection(label, entries) {
52636
- if (entries.length === 0) return void 0;
52637
- 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");
52638
52859
  return `${label}:
52639
52860
  ${list7}`;
52640
52861
  }
@@ -53433,12 +53654,12 @@ function registerVerifyChecks(verifyCommand) {
53433
53654
 
53434
53655
  // src/commands/verify/list.ts
53435
53656
  function list6() {
53436
- const entries = resolveEntries();
53437
- if (entries.length === 0) {
53657
+ const entries2 = resolveEntries();
53658
+ if (entries2.length === 0) {
53438
53659
  console.error("No verify commands found");
53439
53660
  process.exit(1);
53440
53661
  }
53441
- for (const entry of entries) {
53662
+ for (const entry of entries2) {
53442
53663
  console.log(`${entry.name}: ${entry.fullCommand}`);
53443
53664
  }
53444
53665
  }
@@ -54311,13 +54532,13 @@ import { execFileSync as execFileSync32 } from "child_process";
54311
54532
  import { readdirSync as readdirSync27, readFileSync as readFileSync86, statSync as statSync18 } from "fs";
54312
54533
  import { join as join123 } from "path";
54313
54534
  function findPortFile(roamDir) {
54314
- let entries;
54535
+ let entries2;
54315
54536
  try {
54316
- entries = readdirSync27(roamDir);
54537
+ entries2 = readdirSync27(roamDir);
54317
54538
  } catch {
54318
54539
  return void 0;
54319
54540
  }
54320
- 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) => {
54321
54542
  const path128 = join123(roamDir, name2);
54322
54543
  try {
54323
54544
  return { path: path128, mtimeMs: statSync18(path128).mtimeMs };
@@ -54386,8 +54607,8 @@ function registerRoam(program) {
54386
54607
 
54387
54608
  // src/commands/run/formatConfiguredCommands.ts
54388
54609
  function formatConfiguredCommands() {
54389
- const { run: entries } = loadConfig();
54390
- const configs = resolveRunConfigs(entries, runConfigBaseDir());
54610
+ const { run: entries2 } = loadConfig();
54611
+ const configs = resolveRunConfigs(entries2, runConfigBaseDir());
54391
54612
  if (configs.length === 0) return "\nNo configured commands";
54392
54613
  const names = configs.map((r) => ` ${r.name}`).join("\n");
54393
54614
  return `
@@ -55437,11 +55658,11 @@ function cacheSnapshot() {
55437
55658
  return JSON.stringify([readRepoConfigCache(), readUserConfigCache()]);
55438
55659
  }
55439
55660
  function pollRepoConfigCache(intervalMs = POLL_MS3) {
55440
- let inFlight2 = false;
55661
+ let inFlight3 = false;
55441
55662
  let failing = false;
55442
55663
  const tick = async () => {
55443
- if (inFlight2) return;
55444
- inFlight2 = true;
55664
+ if (inFlight3) return;
55665
+ inFlight3 = true;
55445
55666
  try {
55446
55667
  const before = cacheSnapshot();
55447
55668
  const count10 = await refreshRepoConfigCache();
@@ -55456,7 +55677,7 @@ function pollRepoConfigCache(intervalMs = POLL_MS3) {
55456
55677
  );
55457
55678
  failing = true;
55458
55679
  } finally {
55459
- inFlight2 = false;
55680
+ inFlight3 = false;
55460
55681
  }
55461
55682
  };
55462
55683
  const timer = setInterval(() => void tick(), intervalMs);
@@ -55477,9 +55698,9 @@ async function refreshRepoConfigCacheOnStart() {
55477
55698
  }
55478
55699
 
55479
55700
  // src/commands/sessions/daemon/loadActiveSelection.ts
55480
- import { z as z24 } from "zod";
55701
+ import { z as z25 } from "zod";
55481
55702
  var ACTIVE_FILE = "active.json";
55482
- var activeSelectionSchema = z24.record(z24.string(), z24.string());
55703
+ var activeSelectionSchema = z25.record(z25.string(), z25.string());
55483
55704
  function loadActiveSelection() {
55484
55705
  const parsed = activeSelectionSchema.safeParse(
55485
55706
  loadJson(ACTIVE_FILE)
@@ -55773,13 +55994,13 @@ async function sessionWrites(session, target) {
55773
55994
  const reader = conversationOf(session)?.reader;
55774
55995
  const transcript = reader ? await resolveTranscriptPath(session) : null;
55775
55996
  if (!reader || !transcript) return { id: session.id };
55776
- const entries = await readTranscriptTail(
55997
+ const entries2 = await readTranscriptTail(
55777
55998
  transcript,
55778
55999
  Number.POSITIVE_INFINITY
55779
56000
  );
55780
56001
  return {
55781
56002
  id: session.id,
55782
- ...lastWriteTimes(reader.events(entries), target, session.cwd)
56003
+ ...lastWriteTimes(reader.events(entries2), target, session.cwd)
55783
56004
  };
55784
56005
  }
55785
56006
  async function findLastWriter(sessions, target) {
@@ -56008,8 +56229,8 @@ async function turnStarted(session, fingerprint3) {
56008
56229
  if (!lookup.readable) return true;
56009
56230
  const filePath = await resolveTranscriptPath(session);
56010
56231
  if (!filePath) return true;
56011
- const entries = await readTranscriptTail(filePath);
56012
- return (lookup.reader.fingerprint(entries) ?? void 0) !== fingerprint3;
56232
+ const entries2 = await readTranscriptTail(filePath);
56233
+ return (lookup.reader.fingerprint(entries2) ?? void 0) !== fingerprint3;
56013
56234
  }
56014
56235
  function clearPendingSubmit(session) {
56015
56236
  session.pendingSubmit?.cancel();
@@ -57389,14 +57610,14 @@ function isCodexAppServer(pid, procRoot = "/proc") {
57389
57610
 
57390
57611
  // src/commands/sessions/daemon/worktree/liveProcessesInTree.ts
57391
57612
  function liveProcessesInTree(treePath, procRoot = "/proc") {
57392
- let entries;
57613
+ let entries2;
57393
57614
  try {
57394
- entries = readdirSync29(procRoot);
57615
+ entries2 = readdirSync29(procRoot);
57395
57616
  } catch {
57396
57617
  return [];
57397
57618
  }
57398
57619
  const pids = [];
57399
- for (const entry of entries) {
57620
+ for (const entry of entries2) {
57400
57621
  const pid = Number(entry);
57401
57622
  if (!Number.isInteger(pid) || pid === process.pid) continue;
57402
57623
  const cwd = processCwd(`${procRoot}/${entry}/cwd`);
@@ -58132,9 +58353,9 @@ function buildPrompt3(prompt) {
58132
58353
  }
58133
58354
 
58134
58355
  // src/commands/sessions/shared/loadSessionTitles.ts
58135
- import { z as z25 } from "zod";
58356
+ import { z as z26 } from "zod";
58136
58357
  var TITLES_FILE = "session-titles.json";
58137
- var sessionTitlesSchema = z25.record(z25.string(), z25.string());
58358
+ var sessionTitlesSchema = z26.record(z26.string(), z26.string());
58138
58359
  function loadSessionTitles() {
58139
58360
  const parsed = sessionTitlesSchema.safeParse(
58140
58361
  loadJson(TITLES_FILE)
@@ -58672,8 +58893,8 @@ function ensureProjectDirExists(dir, sessionId2) {
58672
58893
 
58673
58894
  // src/commands/sessions/daemon/reportUnrecognisedShapes.ts
58674
58895
  var reported = /* @__PURE__ */ new WeakMap();
58675
- function reportUnrecognisedShapes(session, reader, entries) {
58676
- const shapes = reader.unrecognised?.(entries) ?? [];
58896
+ function reportUnrecognisedShapes(session, reader, entries2) {
58897
+ const shapes = reader.unrecognised?.(entries2) ?? [];
58677
58898
  if (shapes.length === 0) return;
58678
58899
  const seen = reported.get(session) ?? /* @__PURE__ */ new Set();
58679
58900
  reported.set(session, seen);
@@ -58739,15 +58960,15 @@ async function reconcileTranscriptStatus(session, onStatusChange, notify2) {
58739
58960
  const { reader } = lookup;
58740
58961
  const filePath = await resolveTranscriptPath(session);
58741
58962
  if (!filePath) return;
58742
- const entries = await readTranscriptTail(filePath);
58743
- const fingerprint3 = reader.fingerprint(entries);
58963
+ const entries2 = await readTranscriptTail(filePath);
58964
+ const fingerprint3 = reader.fingerprint(entries2);
58744
58965
  if (fingerprint3 !== null && fingerprint3 === session.transcriptFingerprint)
58745
58966
  return;
58746
58967
  session.transcriptFingerprint = fingerprint3 ?? void 0;
58747
- reportUnrecognisedShapes(session, reader, entries);
58748
- updateLastMessages(session, reader.events(entries), notify2);
58968
+ reportUnrecognisedShapes(session, reader, entries2);
58969
+ updateLastMessages(session, reader.events(entries2), notify2);
58749
58970
  if (isFinished(session)) return;
58750
- const derived = reader.lifecycle(entries, {
58971
+ const derived = reader.lifecycle(entries2, {
58751
58972
  permissionActive: session.permissionActive
58752
58973
  }).status;
58753
58974
  if (!derived) return;
@@ -60978,23 +61199,23 @@ async function discoverCodexHistoryEntries() {
60978
61199
  // src/commands/sessions/shared/discoverHistoryEntries.ts
60979
61200
  async function discoverHistoryEntries() {
60980
61201
  const paths = await discoverSessionJsonlPaths();
60981
- const entries = [];
61202
+ const entries2 = [];
60982
61203
  await Promise.all(
60983
61204
  paths.map(async ({ path: filePath, origin }) => {
60984
61205
  const session = await parseSessionFile(filePath, origin);
60985
- if (session) entries.push({ session, filePath });
61206
+ if (session) entries2.push({ session, filePath });
60986
61207
  })
60987
61208
  );
60988
- entries.push(...await discoverCodexHistoryEntries());
61209
+ entries2.push(...await discoverCodexHistoryEntries());
60989
61210
  const titles2 = loadSessionTitles();
60990
- for (const { session } of entries) {
61211
+ for (const { session } of entries2) {
60991
61212
  const title = titles2[session.sessionId];
60992
61213
  if (title) session.title = title;
60993
61214
  }
60994
- entries.sort(
61215
+ entries2.sort(
60995
61216
  (a, b) => new Date(b.session.timestamp).getTime() - new Date(a.session.timestamp).getTime()
60996
61217
  );
60997
- return entries;
61218
+ return entries2;
60998
61219
  }
60999
61220
 
61000
61221
  // src/commands/sessions/shared/discoverSessions.ts
@@ -61465,6 +61686,10 @@ var relays = {
61465
61686
  history: relayHistory,
61466
61687
  "auto-update": relayReply,
61467
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
+ }),
61468
61693
  "user-messages": (state, msg) => broadcastToViewers(state, { ...msg, sessionId: nsId(state, msg) }),
61469
61694
  limits: (state, msg) => state.onLimits(
61470
61695
  msg.harness,
@@ -62777,6 +63002,35 @@ var handleDismiss = routed((_client, m, d) => {
62777
63002
  m.dismissSession(d.sessionId, closeServerRuns);
62778
63003
  });
62779
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
+
62780
63034
  // src/commands/sessions/daemon/latestServerRun.ts
62781
63035
  function latestServerRun(sessions, origin, group) {
62782
63036
  const live = liveServerRun(sessions, { server: true, origin, group });
@@ -62790,8 +63044,8 @@ function latestServerRun(sessions, origin, group) {
62790
63044
  return latest2;
62791
63045
  }
62792
63046
 
62793
- // src/commands/sessions/daemon/handleOutputRequest.ts
62794
- function resolveTarget3(m, d) {
63047
+ // src/commands/sessions/daemon/resolveOutputTarget.ts
63048
+ function resolveOutputTarget(m, d) {
62795
63049
  const server = d.server;
62796
63050
  if (!server) return { sessionId: d.sessionId };
62797
63051
  let run5;
@@ -62805,11 +63059,20 @@ function resolveTarget3(m, d) {
62805
63059
  };
62806
63060
  return run5.status === "done" || run5.status === "error" ? { sessionId: run5.id, exited: run5.status } : { sessionId: run5.id };
62807
63061
  }
62808
- var handleOutputRequest = (client, m, d) => {
62809
- 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;
62810
63069
  if ("error" in target) {
62811
63070
  daemonLog(`output requested: ${target.error}`);
62812
- sendTo(client, { type: "session-output", error: target.error });
63071
+ sendTo(client, {
63072
+ type: "session-output",
63073
+ error: target.error,
63074
+ requestId
63075
+ });
62813
63076
  return;
62814
63077
  }
62815
63078
  const { sessionId: sessionId2, exited } = target;
@@ -62826,8 +63089,9 @@ var handleOutputRequest = (client, m, d) => {
62826
63089
  scrollback === void 0 ? {
62827
63090
  type: "session-output",
62828
63091
  sessionId: sessionId2,
62829
- error: `No session ${sessionId2} on this node`
62830
- } : { 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 }
62831
63095
  );
62832
63096
  };
62833
63097
 
@@ -62944,8 +63208,8 @@ async function handleFetchUserMessages(client, manager, data) {
62944
63208
  const session = findSession(manager, sessionId2);
62945
63209
  const reader = session ? conversationOf(session)?.reader : void 0;
62946
63210
  const filePath = session && reader ? await resolveTranscriptPath(session) : null;
62947
- const entries = reader && filePath ? await readTranscriptTail(filePath, Number.POSITIVE_INFINITY) : [];
62948
- 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)) : [];
62949
63213
  daemonLog(
62950
63214
  `session ${sessionId2} user messages: ${messages2.length} from ${filePath ?? "no transcript"}`
62951
63215
  );
@@ -63334,12 +63598,12 @@ function isPrCheckoutArgs(args) {
63334
63598
  }
63335
63599
 
63336
63600
  // src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
63337
- import { execFile as execFile15 } from "child_process";
63601
+ import { execFile as execFile16 } from "child_process";
63338
63602
  import { existsSync as existsSync115 } from "fs";
63339
63603
  function prHeadBranch2(number, cwd) {
63340
63604
  const { headBranch } = prCliCommands(number, cwd);
63341
63605
  return new Promise((resolve36) => {
63342
- execFile15(
63606
+ execFile16(
63343
63607
  headBranch.file,
63344
63608
  headBranch.args,
63345
63609
  { cwd, encoding: "utf8", windowsHide: true },
@@ -63964,7 +64228,7 @@ function registerLinkCommand(nodes) {
63964
64228
  // src/commands/sessions/nodes/awaitLinkReturn.ts
63965
64229
  var POLL_MS8 = 1e3;
63966
64230
  var wait = (ms) => new Promise((r) => setTimeout(r, ms));
63967
- async function linkStatus(name2, query = queryNodes) {
64231
+ async function linkStatus2(name2, query = queryNodes) {
63968
64232
  return (await query())?.links.find((l) => l.name === name2);
63969
64233
  }
63970
64234
  async function awaitLinkReturn(name2, options2, deps2 = {}) {
@@ -63972,7 +64236,7 @@ async function awaitLinkReturn(name2, options2, deps2 = {}) {
63972
64236
  const deadline = now() + options2.timeoutMs;
63973
64237
  let sawDown = options2.sawDown;
63974
64238
  while (now() < deadline) {
63975
- const link3 = await linkStatus(name2, query);
64239
+ const link3 = await linkStatus2(name2, query);
63976
64240
  if (link3?.state !== "connected") sawDown = true;
63977
64241
  else if (sawDown) return link3;
63978
64242
  await sleep2(POLL_MS8);
@@ -64035,7 +64299,7 @@ async function restartNode(name2, options2) {
64035
64299
  `--target must be one of ${TARGETS2.join(", ")}, got ${target}`
64036
64300
  );
64037
64301
  const action = startPeerAction(name2, `restart ${target}`);
64038
- const before = await linkStatus(name2);
64302
+ const before = await linkStatus2(name2);
64039
64303
  try {
64040
64304
  await postToPeer(
64041
64305
  action.spec.url,
@@ -64108,7 +64372,7 @@ async function selfUpdate2(name2, action) {
64108
64372
  }
64109
64373
  async function updateNode(name2) {
64110
64374
  const action = startPeerAction(name2, "update");
64111
- const connected = (await linkStatus(name2))?.state === "connected";
64375
+ const connected = (await linkStatus2(name2))?.state === "connected";
64112
64376
  const link3 = connected ? await updateOverLink(name2, action) : await selfUpdate2(name2, action);
64113
64377
  console.log(`${name2} updated to v${link3.peerVersion ?? "unknown"}`);
64114
64378
  }
@@ -64195,7 +64459,7 @@ function lastLines(scrollback, count10) {
64195
64459
  }
64196
64460
 
64197
64461
  // src/commands/sessions/sessionOutput.ts
64198
- function resolveTarget4(sessionId2, server) {
64462
+ function resolveTarget3(sessionId2, server) {
64199
64463
  if (sessionId2 && server)
64200
64464
  return "Pass either a session id or --server, not both";
64201
64465
  if (server)
@@ -64206,15 +64470,13 @@ function resolveTarget4(sessionId2, server) {
64206
64470
  }
64207
64471
  };
64208
64472
  if (!sessionId2) return "Pass a session id or --server [group]";
64209
- if (sessionId2.includes(":"))
64210
- return `Session ${sessionId2} is on a linked node; reading linked-node sessions is not supported yet`;
64211
64473
  return { sessionId: sessionId2 };
64212
64474
  }
64213
64475
  async function sessionOutput(sessionId2, options2) {
64214
64476
  const count10 = Number.parseInt(options2.lines, 10);
64215
64477
  if (!Number.isInteger(count10) || count10 < 1)
64216
64478
  return fail13(`-n must be a positive integer, got ${options2.lines}`);
64217
- const target = resolveTarget4(sessionId2, options2.server);
64479
+ const target = resolveTarget3(sessionId2, options2.server);
64218
64480
  if (typeof target === "string") return fail13(target);
64219
64481
  try {
64220
64482
  const {