@staff0rd/assist 0.1065.0 → 0.1065.2

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.1065.0",
9
+ version: "0.1065.2",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -2646,18 +2646,18 @@ function remap(item, newId, oldToNew) {
2646
2646
  };
2647
2647
  return remapped;
2648
2648
  }
2649
- async function importItemsRemapped(orm, items2, origin) {
2649
+ async function importItemsRemapped(orm, items3, origin) {
2650
2650
  return orm.transaction(async (tx) => {
2651
2651
  const oldToNew = /* @__PURE__ */ new Map();
2652
- for (const item of items2) {
2652
+ for (const item of items3) {
2653
2653
  oldToNew.set(item.id, await insertItem(tx, item, origin));
2654
2654
  }
2655
- for (const item of items2) {
2655
+ for (const item of items3) {
2656
2656
  const newId = oldToNew.get(item.id);
2657
2657
  if (newId === void 0) continue;
2658
2658
  await insertItemRelations(tx, remap(item, newId, oldToNew));
2659
2659
  }
2660
- return items2.length;
2660
+ return items3.length;
2661
2661
  });
2662
2662
  }
2663
2663
 
@@ -2990,16 +2990,16 @@ function parseBacklogJsonl(path109) {
2990
2990
  function jsonlPath(dir) {
2991
2991
  return join10(dir, ".assist", "backlog.jsonl");
2992
2992
  }
2993
- async function verifyImport(orm, origin, items2, imported) {
2993
+ async function verifyImport(orm, origin, items3, imported) {
2994
2994
  const reloaded = await loadAllItems(orm, origin);
2995
2995
  if (reloaded.length !== imported) {
2996
2996
  throw new Error(
2997
2997
  `backlog migrate: expected ${imported} item(s) for ${origin} after import but found ${reloaded.length}.`
2998
2998
  );
2999
2999
  }
3000
- if (items2.length > 0 && !reloaded.some((i) => i.name === items2[0].name)) {
3000
+ if (items3.length > 0 && !reloaded.some((i) => i.name === items3[0].name)) {
3001
3001
  throw new Error(
3002
- `backlog migrate: spot-check failed; "${items2[0].name}" not found after import.`
3002
+ `backlog migrate: spot-check failed; "${items3[0].name}" not found after import.`
3003
3003
  );
3004
3004
  }
3005
3005
  }
@@ -3016,9 +3016,9 @@ async function migrateLocalBacklog(orm, dir, origin) {
3016
3016
  return;
3017
3017
  }
3018
3018
  gitPullBacklog(dir);
3019
- const items2 = parseBacklogJsonl(jsonlPath(dir));
3020
- const imported = await importItemsRemapped(orm, items2, origin);
3021
- await verifyImport(orm, origin, items2, imported);
3019
+ const items3 = parseBacklogJsonl(jsonlPath(dir));
3020
+ const imported = await importItemsRemapped(orm, items3, origin);
3021
+ await verifyImport(orm, origin, items3, imported);
3022
3022
  const moved = backupLocalBacklogFiles(dir);
3023
3023
  console.error(
3024
3024
  chalk6.green(
@@ -4227,7 +4227,7 @@ import { z as z8 } from "zod";
4227
4227
  // src/commands/sessions/web/readJsonBody.ts
4228
4228
  async function readJsonBody(req) {
4229
4229
  const chunks = [];
4230
- for await (const chunk of req) chunks.push(chunk);
4230
+ for await (const chunk2 of req) chunks.push(chunk2);
4231
4231
  return JSON.parse(Buffer.concat(chunks).toString("utf8"));
4232
4232
  }
4233
4233
 
@@ -4311,8 +4311,8 @@ function isGithubAssistMode(mode) {
4311
4311
  // src/commands/sessions/daemon/readSocketLines.ts
4312
4312
  function readSocketLines(socket, onLine) {
4313
4313
  let buffer = "";
4314
- socket.on("data", (chunk) => {
4315
- buffer += chunk.toString("utf8");
4314
+ socket.on("data", (chunk2) => {
4315
+ buffer += chunk2.toString("utf8");
4316
4316
  let newline = buffer.indexOf("\n");
4317
4317
  while (newline !== -1) {
4318
4318
  onLine(buffer.slice(0, newline));
@@ -4481,8 +4481,8 @@ async function loadVisibleItems(req) {
4481
4481
  function readBody(req) {
4482
4482
  return new Promise((resolve34, reject) => {
4483
4483
  let body = "";
4484
- req.on("data", (chunk) => {
4485
- body += chunk.toString();
4484
+ req.on("data", (chunk2) => {
4485
+ body += chunk2.toString();
4486
4486
  });
4487
4487
  req.on("end", () => resolve34(body));
4488
4488
  req.on("error", reject);
@@ -4501,8 +4501,8 @@ async function parseStarBody(req) {
4501
4501
  // src/commands/backlog/web/shared.ts
4502
4502
  async function listItems(req, res) {
4503
4503
  applyCwdFromReq(req);
4504
- const items2 = await loadVisibleItems(req);
4505
- respondJson(res, 200, items2.slice().reverse());
4504
+ const items3 = await loadVisibleItems(req);
4505
+ respondJson(res, 200, items3.slice().reverse());
4506
4506
  }
4507
4507
  async function findItemOr404(res, id) {
4508
4508
  const { orm } = await getReady();
@@ -9272,22 +9272,22 @@ async function fetchFeeds(urls, onProgress) {
9272
9272
  const origin = new URL(url).origin;
9273
9273
  const res = await fetch(url);
9274
9274
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
9275
- const items3 = parseFeed(await res.text(), origin);
9275
+ const items4 = parseFeed(await res.text(), origin);
9276
9276
  done2++;
9277
9277
  onProgress?.(done2, urls.length);
9278
- return items3;
9278
+ return items4;
9279
9279
  })
9280
9280
  );
9281
- const items2 = [];
9281
+ const items3 = [];
9282
9282
  for (const result of results) {
9283
9283
  if (result.status === "fulfilled") {
9284
- items2.push(...result.value);
9284
+ items3.push(...result.value);
9285
9285
  }
9286
9286
  }
9287
- items2.sort(
9287
+ items3.sort(
9288
9288
  (a, b) => new Date(b.pubDate).getTime() - new Date(a.pubDate).getTime()
9289
9289
  );
9290
- return items2;
9290
+ return items3;
9291
9291
  }
9292
9292
 
9293
9293
  // src/commands/sessions/web/listNewsItems.ts
@@ -9299,10 +9299,10 @@ async function listNewsItems(_req, res) {
9299
9299
  const feedsKey = urls.join("\n");
9300
9300
  const now = Date.now();
9301
9301
  if (!cache3 || cache3.feedsKey !== feedsKey || cache3.expires <= now) {
9302
- const items2 = fetchFeeds(urls);
9303
- cache3 = { feedsKey, expires: now + CACHE_TTL_MS4, items: items2 };
9304
- items2.catch(() => {
9305
- if (cache3?.items === items2) cache3 = void 0;
9302
+ const items3 = fetchFeeds(urls);
9303
+ cache3 = { feedsKey, expires: now + CACHE_TTL_MS4, items: items3 };
9304
+ items3.catch(() => {
9305
+ if (cache3?.items === items3) cache3 = void 0;
9306
9306
  });
9307
9307
  }
9308
9308
  respondJson(res, 200, await cache3.items);
@@ -9703,15 +9703,15 @@ async function sectionAcross(repos2, load2, compare) {
9703
9703
  error: "No GitHub repo to read: set next.repos or select a repo with a GitHub origin."
9704
9704
  };
9705
9705
  const results = await Promise.allSettled(repos2.map((repo) => load2(repo)));
9706
- const items2 = /* @__PURE__ */ new Map();
9706
+ const items3 = /* @__PURE__ */ new Map();
9707
9707
  const errors = [];
9708
9708
  results.forEach((result, index3) => {
9709
9709
  if (result.status === "fulfilled")
9710
- for (const item of result.value) items2.set(item.url, item);
9710
+ for (const item of result.value) items3.set(item.url, item);
9711
9711
  else errors.push(`${repos2[index3]}: ${ghErrorText(result.reason)}`);
9712
9712
  });
9713
9713
  return {
9714
- items: [...items2.values()].sort(compare),
9714
+ items: [...items3.values()].sort(compare),
9715
9715
  error: errors.length > 0 ? errors.join("\n") : null
9716
9716
  };
9717
9717
  }
@@ -10527,8 +10527,8 @@ function flushBuffer(buffer, onLine) {
10527
10527
  }
10528
10528
  function attachLineParser(child, onLine) {
10529
10529
  let buffer = "";
10530
- child.stdout?.on("data", (chunk) => {
10531
- buffer += chunk.toString("utf8");
10530
+ child.stdout?.on("data", (chunk2) => {
10531
+ buffer += chunk2.toString("utf8");
10532
10532
  buffer = flushBuffer(buffer, onLine);
10533
10533
  });
10534
10534
  return () => {
@@ -10539,86 +10539,116 @@ function attachLineParser(child, onLine) {
10539
10539
  // src/commands/review/attachStderrCollector.ts
10540
10540
  function attachStderrCollector(child) {
10541
10541
  const state = { value: "" };
10542
- child.stderr?.on("data", (chunk) => {
10543
- state.value += chunk.toString("utf8");
10542
+ child.stderr?.on("data", (chunk2) => {
10543
+ state.value += chunk2.toString("utf8");
10544
10544
  });
10545
10545
  return state;
10546
10546
  }
10547
10547
 
10548
- // src/commands/inbox/buildInboxScanPrompt.ts
10549
- function buildInboxScanPrompt(since) {
10550
- const sinceUnix = Math.floor(since.getTime() / 1e3);
10551
- return [
10552
- "Triage my Gmail and Slack for messages a person wrote to me that look like they need my reply.",
10553
- "You are read-only: never label, mark read, react to, reply to or otherwise change any message.",
10554
- "",
10555
- "Gmail:",
10556
- '- Call search_threads with query "in:inbox is:unread" (page through all results).',
10557
- "- Call get_thread with messageFormat PLAIN_TEXT on each thread.",
10558
- "- Consider the latest unread message in each thread.",
10559
- "",
10560
- `Slack (only messages since ${since.toISOString()}, unix ${sinceUnix}):`,
10561
- `- Call slack_search_public_and_private with filters "is:dm" and after "${sinceUnix}".`,
10562
- `- Call slack_search_public_and_private with keywords ["<@MY_USER_ID>"] and after "${sinceUnix}", where MY_USER_ID is the logged-in user id from the tool description.`,
10563
- "- Skip messages I wrote myself.",
10564
- "- For a message in a thread, call slack_read_thread and skip it if I have replied in that thread after it.",
10565
- "",
10566
- "Do not flag anything from bots, apps, automated or notification systems (CI, calendars, ticketing, monitoring, no-reply addresses), newsletters or mailing lists.",
10567
- "Flag only messages a human wrote that ask me something, request something of me, or otherwise expect my response.",
10568
- "",
10569
- "For each flagged message return:",
10570
- '- source: "gmail" or "slack"',
10571
- "- messageId: the Gmail message id, or for Slack <channel_id>:<message ts>",
10572
- "- sender: the sender's name",
10573
- "- summary: one sentence on what they need from me",
10574
- "- link: the Gmail message viewUrl or the Slack permalink",
10575
- "- receivedAt: when it was sent, as an ISO 8601 timestamp",
10576
- "",
10577
- "Return an empty messages array when nothing needs a reply."
10578
- ].join("\n");
10548
+ // src/commands/inbox/inboxScanTools.ts
10549
+ var gmail = (tool) => `mcp__claude_ai_Gmail__${tool}`;
10550
+ var slack = (tool) => `mcp__claude_ai_Slack__${tool}`;
10551
+ var inboxScanTools = {
10552
+ gmailSearch: gmail("search_threads"),
10553
+ gmailGetThread: gmail("get_thread"),
10554
+ allowed: [
10555
+ gmail("search_threads"),
10556
+ gmail("get_thread"),
10557
+ slack("slack_search_public_and_private"),
10558
+ slack("slack_read_thread")
10559
+ ],
10560
+ denied: [
10561
+ ...[
10562
+ "apply_sensitive_message_label",
10563
+ "apply_sensitive_thread_label",
10564
+ "create_draft",
10565
+ "create_label",
10566
+ "delete_draft",
10567
+ "delete_label",
10568
+ "forward",
10569
+ "label_message",
10570
+ "label_thread",
10571
+ "mark_message_spam",
10572
+ "mark_thread_spam",
10573
+ "reply",
10574
+ "send_message",
10575
+ "trash_message",
10576
+ "trash_thread",
10577
+ "unlabel_message",
10578
+ "unlabel_thread",
10579
+ "unmark_message_spam",
10580
+ "unmark_thread_spam",
10581
+ "untrash_message",
10582
+ "untrash_thread",
10583
+ "update_draft",
10584
+ "update_label",
10585
+ "update_message_labels"
10586
+ ].map(gmail),
10587
+ ...[
10588
+ "slack_add_reaction",
10589
+ "slack_create_canvas",
10590
+ "slack_create_conversation",
10591
+ "slack_schedule_message",
10592
+ "slack_send_message",
10593
+ "slack_send_message_draft",
10594
+ "slack_update_canvas"
10595
+ ].map(slack)
10596
+ ]
10597
+ };
10598
+
10599
+ // src/commands/inbox/openedThreadId.ts
10600
+ var BODILESS_FORMATS = /* @__PURE__ */ new Set(["MINIMAL", "METADATA_ONLY"]);
10601
+ function openedThreadId(input) {
10602
+ const { threadId, messageFormat } = input ?? {};
10603
+ if (typeof threadId !== "string") return void 0;
10604
+ return typeof messageFormat === "string" && BODILESS_FORMATS.has(messageFormat) ? void 0 : threadId;
10579
10605
  }
10580
10606
 
10581
- // src/commands/inbox/describeInboxScanTool.ts
10582
- function pick(input, keys) {
10583
- return keys.map((key) => input[key]).filter(
10584
- (value) => typeof value === "string" || typeof value === "number"
10585
- ).map(String);
10607
+ // src/commands/inbox/searchResultThreadIds.ts
10608
+ function items2(value) {
10609
+ return Array.isArray(value) ? value : [];
10586
10610
  }
10587
- function toolLabel(name) {
10588
- const match = name.match(/^mcp__claude_ai_([^_]+)__(?:slack_)?(.+)$/);
10589
- return match ? `${match[1]} ${match[2]}` : name;
10611
+ function resultText2(content) {
10612
+ if (typeof content === "string") return content;
10613
+ return items2(content).map((block) => typeof block.text === "string" ? block.text : "").join("");
10590
10614
  }
10591
- function describeInboxScanTool(name, input) {
10592
- const record = input && typeof input === "object" ? input : {};
10593
- const detail = pick(record, [
10594
- "query",
10595
- "thread_id",
10596
- "threadId",
10597
- "channel_id",
10598
- "message_ts"
10599
- ]).join(" ");
10600
- return { label: toolLabel(name), detail };
10615
+ function searchResultThreadIds(content) {
10616
+ try {
10617
+ const { threads } = JSON.parse(resultText2(content));
10618
+ return items2(threads).map((thread) => thread.id).filter((id) => typeof id === "string");
10619
+ } catch {
10620
+ return [];
10621
+ }
10601
10622
  }
10602
10623
 
10603
- // src/commands/inbox/assistantScanEvents.ts
10604
- var MAX_TEXT = 500;
10605
- function truncate(text20) {
10606
- const trimmed = text20.trim();
10607
- return trimmed.length <= MAX_TEXT ? trimmed : `${trimmed.slice(0, MAX_TEXT - 1)}\u2026`;
10624
+ // src/commands/inbox/createGmailCoverage.ts
10625
+ function blocks(content) {
10626
+ return Array.isArray(content) ? content : [];
10608
10627
  }
10609
- function blockEvent(block) {
10610
- if (block.type === "tool_use") {
10611
- const name = typeof block.name === "string" ? block.name : "tool";
10612
- return { kind: "tool", ...describeInboxScanTool(name, block.input) };
10613
- }
10614
- if (block.type === "text" && typeof block.text === "string" && block.text.trim())
10615
- return { kind: "text", label: "Assistant", detail: truncate(block.text) };
10616
- return void 0;
10617
- }
10618
- function assistantScanEvents(content) {
10619
- if (!Array.isArray(content)) return [];
10620
- const at2 = (/* @__PURE__ */ new Date()).toISOString();
10621
- return content.map(blockEvent).filter((event) => event !== void 0).map((event) => ({ at: at2, ...event }));
10628
+ function createGmailCoverage() {
10629
+ const searches = /* @__PURE__ */ new Set();
10630
+ const found = /* @__PURE__ */ new Set();
10631
+ const opened = /* @__PURE__ */ new Set();
10632
+ const onToolUse = (block) => {
10633
+ if (block.name === inboxScanTools.gmailSearch)
10634
+ searches.add(String(block.id));
10635
+ else if (block.name === inboxScanTools.gmailGetThread) {
10636
+ const id = openedThreadId(block.input);
10637
+ if (id) opened.add(id);
10638
+ }
10639
+ };
10640
+ return {
10641
+ onAssistant(content) {
10642
+ for (const block of blocks(content))
10643
+ if (block.type === "tool_use") onToolUse(block);
10644
+ },
10645
+ onUser(content) {
10646
+ for (const block of blocks(content))
10647
+ if (searches.has(String(block.tool_use_id)))
10648
+ for (const id of searchResultThreadIds(block.content)) found.add(id);
10649
+ },
10650
+ current: () => ({ found: [...found], opened: [...opened] })
10651
+ };
10622
10652
  }
10623
10653
 
10624
10654
  // src/commands/review/parseTokenUsage.ts
@@ -10697,6 +10727,61 @@ function createScanUsageTracker() {
10697
10727
  };
10698
10728
  }
10699
10729
 
10730
+ // src/commands/inbox/describeInboxScanTool.ts
10731
+ function pick(input, keys) {
10732
+ return keys.map((key) => input[key]).filter(
10733
+ (value) => typeof value === "string" || typeof value === "number"
10734
+ ).map(String);
10735
+ }
10736
+ function toolLabel(name) {
10737
+ const match = name.match(/^mcp__claude_ai_([^_]+)__(?:slack_)?(.+)$/);
10738
+ return match ? `${match[1]} ${match[2]}` : name;
10739
+ }
10740
+ function describeInboxScanTool(name, input) {
10741
+ const record = input && typeof input === "object" ? input : {};
10742
+ const detail = pick(record, [
10743
+ "query",
10744
+ "thread_id",
10745
+ "threadId",
10746
+ "channel_id",
10747
+ "message_ts"
10748
+ ]).join(" ");
10749
+ return { label: toolLabel(name), detail };
10750
+ }
10751
+
10752
+ // src/commands/inbox/assistantScanEvents.ts
10753
+ var MAX_TEXT = 500;
10754
+ function truncate(text20) {
10755
+ const trimmed = text20.trim();
10756
+ return trimmed.length <= MAX_TEXT ? trimmed : `${trimmed.slice(0, MAX_TEXT - 1)}\u2026`;
10757
+ }
10758
+ function blockEvent(block) {
10759
+ if (block.type === "tool_use") {
10760
+ const name = typeof block.name === "string" ? block.name : "tool";
10761
+ return { kind: "tool", ...describeInboxScanTool(name, block.input) };
10762
+ }
10763
+ if (block.type === "text" && typeof block.text === "string" && block.text.trim())
10764
+ return { kind: "text", label: "Assistant", detail: truncate(block.text) };
10765
+ return void 0;
10766
+ }
10767
+ function assistantScanEvents(content) {
10768
+ if (!Array.isArray(content)) return [];
10769
+ const at2 = (/* @__PURE__ */ new Date()).toISOString();
10770
+ return content.map(blockEvent).filter((event) => event !== void 0).map((event) => ({ at: at2, ...event }));
10771
+ }
10772
+
10773
+ // src/commands/inbox/handleAssistantTurn.ts
10774
+ function handleAssistantTurn(message3, usage, { onEvent = () => {
10775
+ }, onUsage = () => {
10776
+ } }) {
10777
+ const counted = usage.addTurn(message3?.id, message3?.usage);
10778
+ for (const scanEvent of assistantScanEvents(message3?.content)) {
10779
+ const tokens = usage.takeTurnTokens();
10780
+ onEvent(tokens === void 0 ? scanEvent : { ...scanEvent, tokens });
10781
+ }
10782
+ if (counted) onUsage(usage.current());
10783
+ }
10784
+
10700
10785
  // src/commands/inbox/inboxScanSchema.ts
10701
10786
  import { z as z12 } from "zod";
10702
10787
  var flaggedMessageSchema = z12.object({
@@ -10729,31 +10814,23 @@ function parseScanStreamLine(line) {
10729
10814
  }
10730
10815
 
10731
10816
  // src/commands/inbox/createInboxScanParser.ts
10732
- function createInboxScanParser({
10733
- onEvent = () => {
10734
- },
10735
- onUsage = () => {
10736
- },
10737
- onModel = () => {
10738
- }
10739
- } = {}) {
10817
+ function createInboxScanParser(listener = {}) {
10818
+ const { onUsage = () => {
10819
+ }, onModel = () => {
10820
+ } } = listener;
10740
10821
  const usage = createScanUsageTracker();
10822
+ const coverage2 = createGmailCoverage();
10741
10823
  let resultLine;
10742
- const onAssistant = (message3) => {
10743
- const counted = usage.addTurn(message3?.id, message3?.usage);
10744
- for (const scanEvent of assistantScanEvents(message3?.content)) {
10745
- const tokens = usage.takeTurnTokens();
10746
- onEvent(tokens === void 0 ? scanEvent : { ...scanEvent, tokens });
10747
- }
10748
- if (counted) onUsage(usage.current());
10749
- };
10750
10824
  return {
10751
10825
  onLine(line) {
10752
10826
  const event = parseScanStreamLine(line);
10753
10827
  if (!event) return;
10754
10828
  if (event.type === "system" && typeof event.model === "string")
10755
10829
  onModel(event.model);
10756
- else if (event.type === "assistant") onAssistant(event.message);
10830
+ else if (event.type === "assistant") {
10831
+ coverage2.onAssistant(event.message?.content);
10832
+ handleAssistantTurn(event.message, usage, listener);
10833
+ } else if (event.type === "user") coverage2.onUser(event.message?.content);
10757
10834
  else if (event.type === "result") {
10758
10835
  resultLine = line;
10759
10836
  usage.finish(event);
@@ -10764,64 +10841,19 @@ function createInboxScanParser({
10764
10841
  if (!resultLine) throw new Error(`Inbox scan failed: ${failure}`);
10765
10842
  return {
10766
10843
  messages: parseInboxScanOutput(resultLine),
10767
- usage: usage.current()
10844
+ usage: usage.current(),
10845
+ threads: coverage2.current()
10768
10846
  };
10769
10847
  }
10770
10848
  };
10771
10849
  }
10772
10850
 
10773
- // src/commands/inbox/inboxScanTools.ts
10774
- var gmail = (tool) => `mcp__claude_ai_Gmail__${tool}`;
10775
- var slack = (tool) => `mcp__claude_ai_Slack__${tool}`;
10776
- var inboxScanTools = {
10777
- allowed: [
10778
- gmail("search_threads"),
10779
- gmail("get_thread"),
10780
- slack("slack_search_public_and_private"),
10781
- slack("slack_read_thread")
10782
- ],
10783
- denied: [
10784
- ...[
10785
- "apply_sensitive_message_label",
10786
- "apply_sensitive_thread_label",
10787
- "create_draft",
10788
- "create_label",
10789
- "delete_draft",
10790
- "delete_label",
10791
- "forward",
10792
- "label_message",
10793
- "label_thread",
10794
- "mark_message_spam",
10795
- "mark_thread_spam",
10796
- "reply",
10797
- "send_message",
10798
- "trash_message",
10799
- "trash_thread",
10800
- "unlabel_message",
10801
- "unlabel_thread",
10802
- "unmark_message_spam",
10803
- "unmark_thread_spam",
10804
- "untrash_message",
10805
- "untrash_thread",
10806
- "update_draft",
10807
- "update_label",
10808
- "update_message_labels"
10809
- ].map(gmail),
10810
- ...[
10811
- "slack_add_reaction",
10812
- "slack_create_canvas",
10813
- "slack_create_conversation",
10814
- "slack_schedule_message",
10815
- "slack_send_message",
10816
- "slack_send_message_draft",
10817
- "slack_update_canvas"
10818
- ].map(slack)
10819
- ]
10820
- };
10821
-
10822
10851
  // src/commands/inbox/runInboxScanClaude.ts
10823
10852
  var INBOX_SCAN_TIMEOUT_MS = 20 * 6e4;
10824
- function buildInboxScanArgs(since) {
10853
+ function buildInboxScanArgs({
10854
+ prompt,
10855
+ allowedTools
10856
+ }) {
10825
10857
  return [
10826
10858
  "-p",
10827
10859
  "--tools",
@@ -10829,7 +10861,7 @@ function buildInboxScanArgs(since) {
10829
10861
  "--permission-mode",
10830
10862
  "dontAsk",
10831
10863
  "--allowedTools",
10832
- ...inboxScanTools.allowed,
10864
+ ...allowedTools,
10833
10865
  "--disallowedTools",
10834
10866
  ...inboxScanTools.denied,
10835
10867
  "--no-session-persistence",
@@ -10839,14 +10871,14 @@ function buildInboxScanArgs(since) {
10839
10871
  "--json-schema",
10840
10872
  JSON.stringify(z13.toJSONSchema(inboxScanSchema, { target: "draft-07" })),
10841
10873
  "--",
10842
- buildInboxScanPrompt(since)
10874
+ prompt
10843
10875
  ];
10844
10876
  }
10845
10877
  function describeExit(code, signal) {
10846
10878
  return signal ? `claude was killed (${signal})` : `claude exited ${code}`;
10847
10879
  }
10848
- async function runInboxScanClaude(since, listener = {}) {
10849
- const child = spawn2("claude", buildInboxScanArgs(since), {
10880
+ async function runInboxScanClaude(pass, listener = {}) {
10881
+ const child = spawn2("claude", buildInboxScanArgs(pass), {
10850
10882
  stdio: ["ignore", "pipe", "pipe"],
10851
10883
  windowsHide: true,
10852
10884
  timeout: INBOX_SCAN_TIMEOUT_MS
@@ -13417,8 +13449,8 @@ async function readRequestBuffer(req, limit) {
13417
13449
  const chunks = [];
13418
13450
  let size = 0;
13419
13451
  let overLimit = false;
13420
- for await (const chunk of req) {
13421
- const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
13452
+ for await (const chunk2 of req) {
13453
+ const buf = Buffer.isBuffer(chunk2) ? chunk2 : Buffer.from(chunk2);
13422
13454
  size += buf.length;
13423
13455
  if (overLimit) continue;
13424
13456
  if (size > limit) {
@@ -13837,9 +13869,9 @@ function parseMenuKey(data, toggleKey) {
13837
13869
  // src/commands/sessions/web/restartMenu/createKeyHandler.ts
13838
13870
  function createKeyHandler(deps2) {
13839
13871
  const { menu, toggleKey, isBusy: isBusy2, activate, quit } = deps2;
13840
- return (chunk) => {
13872
+ return (chunk2) => {
13841
13873
  if (isBusy2()) return;
13842
- const { key, digit } = parseMenuKey(chunk, toggleKey);
13874
+ const { key, digit } = parseMenuKey(chunk2, toggleKey);
13843
13875
  if (key === "quit") return quit();
13844
13876
  if (key === "toggle") {
13845
13877
  if (menu.isOpen()) menu.close();
@@ -13856,21 +13888,21 @@ function createKeyHandler(deps2) {
13856
13888
  }
13857
13889
 
13858
13890
  // src/commands/sessions/web/restartMenu/nextIndex.ts
13859
- function nextIndex(items2, current2, direction) {
13860
- const n = items2.length;
13891
+ function nextIndex(items3, current2, direction) {
13892
+ const n = items3.length;
13861
13893
  if (n === 0) return current2;
13862
13894
  return (current2 + direction + n) % n;
13863
13895
  }
13864
- function firstEnabledIndex(items2) {
13865
- const idx = items2.findIndex((item) => !item.disabled);
13896
+ function firstEnabledIndex(items3) {
13897
+ const idx = items3.findIndex((item) => !item.disabled);
13866
13898
  return idx === -1 ? 0 : idx;
13867
13899
  }
13868
13900
 
13869
13901
  // src/commands/sessions/web/restartMenu/renderRestartMenu.ts
13870
13902
  import chalk13 from "chalk";
13871
- function renderRestartMenu(items2, selected) {
13903
+ function renderRestartMenu(items3, selected) {
13872
13904
  const lines2 = [chalk13.bold.cyan("assist \u2014 restart menu")];
13873
- items2.forEach((item, i) => {
13905
+ items3.forEach((item, i) => {
13874
13906
  const active = i === selected;
13875
13907
  const pointer = active ? chalk13.cyan("\u276F ") : " ";
13876
13908
  const number = chalk13.dim(`${i + 1}. `);
@@ -13885,15 +13917,15 @@ function renderRestartMenu(items2, selected) {
13885
13917
  }
13886
13918
 
13887
13919
  // src/commands/sessions/web/restartMenu/createMenuState.ts
13888
- function createMenuState(items2, log2) {
13920
+ function createMenuState(items3, log2) {
13889
13921
  let open = false;
13890
- let selected = firstEnabledIndex(items2);
13891
- const render2 = () => log2(renderRestartMenu(items2, selected));
13922
+ let selected = firstEnabledIndex(items3);
13923
+ const render2 = () => log2(renderRestartMenu(items3, selected));
13892
13924
  return {
13893
13925
  isOpen: () => open,
13894
13926
  open() {
13895
13927
  open = true;
13896
- selected = firstEnabledIndex(items2);
13928
+ selected = firstEnabledIndex(items3);
13897
13929
  render2();
13898
13930
  },
13899
13931
  close() {
@@ -13902,12 +13934,12 @@ function createMenuState(items2, log2) {
13902
13934
  log2.clear();
13903
13935
  },
13904
13936
  move(direction) {
13905
- selected = nextIndex(items2, selected, direction);
13937
+ selected = nextIndex(items3, selected, direction);
13906
13938
  render2();
13907
13939
  },
13908
- selectedItem: () => items2[selected],
13940
+ selectedItem: () => items3[selected],
13909
13941
  jumpTo(index3) {
13910
- const item = items2[index3];
13942
+ const item = items3[index3];
13911
13943
  if (!item) return false;
13912
13944
  selected = index3;
13913
13945
  render2();
@@ -13953,11 +13985,11 @@ function resolveOptions(options2) {
13953
13985
 
13954
13986
  // src/commands/sessions/web/restartMenu/installRestartMenu.ts
13955
13987
  function installRestartMenu(options2 = {}) {
13956
- const { stdin, out, toggleKey, exit, restartDaemonFn, reExecFn, items: items2 } = resolveOptions(options2);
13988
+ const { stdin, out, toggleKey, exit, restartDaemonFn, reExecFn, items: items3 } = resolveOptions(options2);
13957
13989
  if (!stdin.isTTY) return () => {
13958
13990
  };
13959
13991
  const log2 = createLogUpdate(out);
13960
- const menu = createMenuState(items2, log2);
13992
+ const menu = createMenuState(items3, log2);
13961
13993
  const reExec = () => reExecFn({ beforeExec: () => cleanup(), exit });
13962
13994
  const { isBusy: isBusy2, activate } = createActivate(menu, {
13963
13995
  runRestartDaemon: restartDaemonFn,
@@ -16351,8 +16383,8 @@ import { randomUUID as randomUUID3 } from "crypto";
16351
16383
  // src/commands/backlog/import/readStdinBuffer.ts
16352
16384
  async function readStdinBuffer() {
16353
16385
  const chunks = [];
16354
- for await (const chunk of process.stdin) {
16355
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
16386
+ for await (const chunk2 of process.stdin) {
16387
+ chunks.push(Buffer.isBuffer(chunk2) ? chunk2 : Buffer.from(chunk2));
16356
16388
  }
16357
16389
  return Buffer.concat(chunks);
16358
16390
  }
@@ -17308,8 +17340,8 @@ async function copyTableOut(client, table) {
17308
17340
  const sql33 = `COPY ${table.name} (${table.columns.join(", ")}) TO STDOUT`;
17309
17341
  const stream = client.query(copyTo(sql33));
17310
17342
  const chunks = [];
17311
- for await (const chunk of stream) {
17312
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
17343
+ for await (const chunk2 of stream) {
17344
+ chunks.push(Buffer.isBuffer(chunk2) ? chunk2 : Buffer.from(chunk2));
17313
17345
  }
17314
17346
  return Buffer.concat(chunks);
17315
17347
  }
@@ -18537,17 +18569,17 @@ function phaseLabel(item) {
18537
18569
  ` (phase ${item.currentPhase ?? 1}/${authoredPhases(item.plan).length})`
18538
18570
  );
18539
18571
  }
18540
- function isBlocked(item, items2) {
18572
+ function isBlocked(item, items3) {
18541
18573
  const deps2 = (item.links ?? []).filter((l) => l.type === "depends-on");
18542
18574
  return deps2.some((dep) => {
18543
- const target = items2.find((i) => i.id === dep.targetId);
18575
+ const target = items3.find((i) => i.id === dep.targetId);
18544
18576
  return target !== void 0 && target.status !== "done";
18545
18577
  });
18546
18578
  }
18547
- function dependencyLabel(item, items2) {
18579
+ function dependencyLabel(item, items3) {
18548
18580
  const deps2 = (item.links ?? []).filter((l) => l.type === "depends-on");
18549
18581
  if (deps2.length === 0) return "";
18550
- if (isBlocked(item, items2)) return chalk59.red(" [blocked]");
18582
+ if (isBlocked(item, items3)) return chalk59.red(" [blocked]");
18551
18583
  return chalk59.dim(` [${deps2.length} dep${deps2.length > 1 ? "s" : ""}]`);
18552
18584
  }
18553
18585
  function printVerboseDetails(item) {
@@ -18564,30 +18596,30 @@ function printVerboseDetails(item) {
18564
18596
  }
18565
18597
 
18566
18598
  // src/commands/backlog/list.ts
18567
- function filterItems(items2, options2) {
18568
- if (options2.status) return items2.filter((i) => i.status === options2.status);
18599
+ function filterItems(items3, options2) {
18600
+ if (options2.status) return items3.filter((i) => i.status === options2.status);
18569
18601
  if (!options2.all)
18570
- return items2.filter((i) => i.status !== "done" && i.status !== "wontdo");
18571
- return items2;
18602
+ return items3.filter((i) => i.status !== "done" && i.status !== "wontdo");
18603
+ return items3;
18572
18604
  }
18573
- function repoPrefixer(items2, allRepos) {
18605
+ function repoPrefixer(items3, allRepos) {
18574
18606
  if (!allRepos) return () => "";
18575
18607
  const labels = originDisplayLabels(
18576
- items2.flatMap((i) => i.origin ? [i.origin] : [])
18608
+ items3.flatMap((i) => i.origin ? [i.origin] : [])
18577
18609
  );
18578
18610
  const repoNameOf = (item) => item.origin ? labels.get(item.origin) ?? "" : "";
18579
- const width2 = Math.max(0, ...items2.map((i) => repoNameOf(i).length));
18611
+ const width2 = Math.max(0, ...items3.map((i) => repoNameOf(i).length));
18580
18612
  return (item) => `${chalk60.dim(repoNameOf(item).padEnd(width2))} `;
18581
18613
  }
18582
18614
  async function list(options2) {
18583
18615
  const allItems = await loadBacklog(options2.allRepos);
18584
- const items2 = filterItems(allItems, options2);
18585
- if (items2.length === 0) {
18616
+ const items3 = filterItems(allItems, options2);
18617
+ if (items3.length === 0) {
18586
18618
  console.log(chalk60.dim("Backlog is empty."));
18587
18619
  return;
18588
18620
  }
18589
- const prefixOf = repoPrefixer(items2, !!options2.allRepos);
18590
- for (const item of items2) {
18621
+ const prefixOf = repoPrefixer(items3, !!options2.allRepos);
18622
+ for (const item of items3) {
18591
18623
  console.log(
18592
18624
  `${prefixOf(item)}${statusIcon(item.status)} ${typeLabel(item.type)} ${chalk60.dim(formatItemId(item.id))} ${starMarker(item)}${item.name}${phaseLabel(item)}${dependencyLabel(item, allItems)}`
18593
18625
  );
@@ -19419,21 +19451,21 @@ function releaseLock(itemId2) {
19419
19451
  }
19420
19452
 
19421
19453
  // src/commands/backlog/findResumable.ts
19422
- function findResumable(items2) {
19423
- return items2.find(
19424
- (i) => i.status === "in-progress" && i.plan && !isLockedByOther(i.id) && !isBlocked(i, items2)
19454
+ function findResumable(items3) {
19455
+ return items3.find(
19456
+ (i) => i.status === "in-progress" && i.plan && !isLockedByOther(i.id) && !isBlocked(i, items3)
19425
19457
  );
19426
19458
  }
19427
19459
 
19428
19460
  // src/commands/backlog/findUnblockedTodos.ts
19429
19461
  import chalk72 from "chalk";
19430
- function findUnblockedTodos(items2) {
19431
- const todo = items2.filter((i) => i.status === "todo");
19462
+ function findUnblockedTodos(items3) {
19463
+ const todo = items3.filter((i) => i.status === "todo");
19432
19464
  if (todo.length === 0) {
19433
19465
  console.log(chalk72.green("All backlog items complete."));
19434
19466
  return void 0;
19435
19467
  }
19436
- const unblocked = todo.filter((i) => !isBlocked(i, items2));
19468
+ const unblocked = todo.filter((i) => !isBlocked(i, items3));
19437
19469
  if (unblocked.length === 0) {
19438
19470
  console.log(
19439
19471
  chalk72.yellow("All remaining todo items are blocked by dependencies.")
@@ -20666,23 +20698,23 @@ function logProgress({ plan: plan2, startPhase, item }) {
20666
20698
  }
20667
20699
 
20668
20700
  // src/commands/backlog/next.ts
20669
- function toChoice(item, items2) {
20701
+ function toChoice(item, items3) {
20670
20702
  const name = `${typeLabel(item.type)} ${formatItemId(item.id)}: ${item.name}`;
20671
- return isBlocked(item, items2) ? { name, disabled: chalk81.red("[blocked]") } : { name };
20703
+ return isBlocked(item, items3) ? { name, disabled: chalk81.red("[blocked]") } : { name };
20672
20704
  }
20673
- async function selectItem(todo, items2) {
20705
+ async function selectItem(todo, items3) {
20674
20706
  const { selected } = await exitOnCancel(
20675
20707
  enquirer6.prompt({
20676
20708
  type: "select",
20677
20709
  name: "selected",
20678
20710
  message: "Choose a backlog item to start:",
20679
- choices: todo.map((i) => toChoice(i, items2))
20711
+ choices: todo.map((i) => toChoice(i, items3))
20680
20712
  })
20681
20713
  );
20682
20714
  return selected.match(/(a\d+):/)?.[1] ?? "";
20683
20715
  }
20684
- function pickResumable(items2) {
20685
- const resumable = findResumable(items2);
20716
+ function pickResumable(items3) {
20717
+ const resumable = findResumable(items3);
20686
20718
  if (!resumable) return void 0;
20687
20719
  console.log(
20688
20720
  chalk81.bold(
@@ -20698,14 +20730,14 @@ function autoSelect(unblocked) {
20698
20730
  );
20699
20731
  return formatItemId(item.id);
20700
20732
  }
20701
- async function pickItem(items2, firstPick = false) {
20702
- const resumable = pickResumable(items2);
20733
+ async function pickItem(items3, firstPick = false) {
20734
+ const resumable = pickResumable(items3);
20703
20735
  if (resumable) return resumable;
20704
- const unblocked = findUnblockedTodos(items2);
20736
+ const unblocked = findUnblockedTodos(items3);
20705
20737
  if (!unblocked) return void 0;
20706
20738
  if (firstPick && unblocked.length === 1) return autoSelect(unblocked);
20707
- const todo = items2.filter((i) => i.status === "todo");
20708
- return selectItem(todo, items2);
20739
+ const todo = items3.filter((i) => i.status === "todo");
20740
+ return selectItem(todo, items3);
20709
20741
  }
20710
20742
  async function next(options2, startId) {
20711
20743
  await pullIfConfigured();
@@ -20841,19 +20873,19 @@ async function surfaceCreatedItems(slashCommand, ids) {
20841
20873
  const numericIds = parseValidIds(ids);
20842
20874
  if (numericIds.length === 0) return;
20843
20875
  const { orm } = await getReady();
20844
- const items2 = [];
20876
+ const items3 = [];
20845
20877
  for (const id of numericIds) {
20846
20878
  const item = await loadItem(orm, id);
20847
- if (item) items2.push(item);
20879
+ if (item) items3.push(item);
20848
20880
  }
20849
- const [first] = items2;
20881
+ const [first] = items3;
20850
20882
  if (!first) return;
20851
20883
  emitActivity({
20852
20884
  kind: "command",
20853
20885
  name: slashCommand,
20854
20886
  itemId: first.id,
20855
20887
  itemName: first.name,
20856
- ...items2.length > 1 && { itemIds: items2.map((item) => item.id) }
20888
+ ...items3.length > 1 && { itemIds: items3.map((item) => item.id) }
20857
20889
  });
20858
20890
  }
20859
20891
 
@@ -20961,8 +20993,8 @@ async function launchMode(slashCommand, options2) {
20961
20993
 
20962
20994
  // src/commands/backlog/refine.ts
20963
20995
  async function pickItemForRefine() {
20964
- const items2 = await loadBacklogSummaries();
20965
- const active = items2.filter(
20996
+ const items3 = await loadBacklogSummaries();
20997
+ const active = items3.filter(
20966
20998
  (i) => i.status === "todo" || i.status === "in-progress"
20967
20999
  );
20968
21000
  if (active.length === 0) {
@@ -21101,18 +21133,18 @@ function registerRunCommand(cmd) {
21101
21133
  // src/commands/backlog/search.ts
21102
21134
  import chalk90 from "chalk";
21103
21135
  async function search(query) {
21104
- const items2 = await searchBacklog(query);
21105
- if (items2.length === 0) {
21136
+ const items3 = await searchBacklog(query);
21137
+ if (items3.length === 0) {
21106
21138
  console.log(chalk90.dim(`No items matching "${query}".`));
21107
21139
  return;
21108
21140
  }
21109
21141
  console.log(
21110
21142
  chalk90.dim(
21111
- `${items2.length} item${items2.length === 1 ? "" : "s"} matching "${query}":
21143
+ `${items3.length} item${items3.length === 1 ? "" : "s"} matching "${query}":
21112
21144
  `
21113
21145
  )
21114
21146
  );
21115
- for (const item of items2) {
21147
+ for (const item of items3) {
21116
21148
  console.log(
21117
21149
  `${statusIcon(item.status)} ${typeLabel(item.type)} ${chalk90.dim(formatItemId(item.id))} ${item.name}`
21118
21150
  );
@@ -21463,7 +21495,7 @@ function hasListMutations(options2) {
21463
21495
  );
21464
21496
  }
21465
21497
  function applyListMutations(current2, options2, flags2) {
21466
- let items2 = [...current2];
21498
+ let items3 = [...current2];
21467
21499
  if (options2.edit) {
21468
21500
  const [rawIndex, ...textParts] = options2.edit;
21469
21501
  if (rawIndex === void 0 || textParts.length === 0) {
@@ -21474,25 +21506,25 @@ function applyListMutations(current2, options2, flags2) {
21474
21506
  }
21475
21507
  const parsed = parseListIndex(
21476
21508
  rawIndex,
21477
- items2.length,
21509
+ items3.length,
21478
21510
  `${flags2.edit} index`
21479
21511
  );
21480
21512
  if (!parsed.ok) return parsed;
21481
- items2[parsed.index - 1] = textParts.join(" ");
21513
+ items3[parsed.index - 1] = textParts.join(" ");
21482
21514
  }
21483
21515
  if (options2.remove) {
21484
21516
  const parsed = parseListIndex(
21485
21517
  options2.remove,
21486
- items2.length,
21518
+ items3.length,
21487
21519
  `${flags2.remove} index`
21488
21520
  );
21489
21521
  if (!parsed.ok) return parsed;
21490
- items2 = items2.filter((_, i) => i !== parsed.index - 1);
21522
+ items3 = items3.filter((_, i) => i !== parsed.index - 1);
21491
21523
  }
21492
21524
  if (options2.add) {
21493
- items2.push(...options2.add);
21525
+ items3.push(...options2.add);
21494
21526
  }
21495
- return { ok: true, items: items2 };
21527
+ return { ok: true, items: items3 };
21496
21528
  }
21497
21529
 
21498
21530
  // src/commands/backlog/update/resolveListUpdate.ts
@@ -23640,18 +23672,18 @@ function colorize(plainOutput) {
23640
23672
  }).join("\n");
23641
23673
  }
23642
23674
 
23643
- // src/commands/permitCliReads/mapAsync.ts
23644
- async function mapAsync(items2, concurrency, fn) {
23645
- const results = Array.from({ length: items2.length });
23675
+ // src/shared/mapAsync.ts
23676
+ async function mapAsync(items3, concurrency, fn) {
23677
+ const results = Array.from({ length: items3.length });
23646
23678
  let next3 = 0;
23647
23679
  async function worker() {
23648
- while (next3 < items2.length) {
23680
+ while (next3 < items3.length) {
23649
23681
  const idx = next3++;
23650
- results[idx] = await fn(items2[idx]);
23682
+ results[idx] = await fn(items3[idx]);
23651
23683
  }
23652
23684
  }
23653
23685
  const workers = Array.from(
23654
- { length: Math.min(concurrency, items2.length) },
23686
+ { length: Math.min(concurrency, items3.length) },
23655
23687
  () => worker()
23656
23688
  );
23657
23689
  await Promise.all(workers);
@@ -25483,13 +25515,13 @@ function cheatLine(entry, gitState) {
25483
25515
  ${chalk127.red("\u2717 You shrank existing lines in this file without creating a new file. That cannot clear the gate \u2014 extract a responsibility to a new file.")}`;
25484
25516
  }
25485
25517
  function printMaintainabilityFailure(failing, gitState) {
25486
- const blocks = failing.map((entry) => `${remediationLine(entry)}${cheatLine(entry, gitState)}`).join("\n");
25518
+ const blocks2 = failing.map((entry) => `${remediationLine(entry)}${cheatLine(entry, gitState)}`).join("\n");
25487
25519
  console.error(
25488
25520
  chalk127.red(
25489
25521
  `
25490
25522
  Fail: ${failing.length} file(s) below threshold \u2192 extract a responsibility to a new file.
25491
25523
 
25492
- ${blocks}
25524
+ ${blocks2}
25493
25525
 
25494
25526
  ${chalk127.bold("Diagnose and fix one file at a time.")} Only a new file (Write) or 'assist refactor extract' clears this gate \u2014 editing the existing lines does not.`
25495
25527
  )
@@ -30139,13 +30171,13 @@ function renderScreenshotsSection(attachments) {
30139
30171
  members.push(attachment);
30140
30172
  groups.set(attachment.group, members);
30141
30173
  }
30142
- const blocks = [...groups].flatMap(([group, members]) => [
30174
+ const blocks2 = [...groups].flatMap(([group, members]) => [
30143
30175
  `### ${group}`,
30144
30176
  ...renderScreenshotBlock(members)
30145
30177
  ]);
30146
30178
  return [
30147
30179
  "## Screenshots",
30148
- ...blocks,
30180
+ ...blocks2,
30149
30181
  ...ungrouped.map(screenshotReference)
30150
30182
  ].join("\n\n");
30151
30183
  }
@@ -30260,26 +30292,26 @@ function applyCreatedIssueMetadata(createOutput, metadata2) {
30260
30292
  function issuePreviewMetadata(resolved) {
30261
30293
  if (!resolved) return [];
30262
30294
  const { target, issueType, parent, project, labels, milestone } = resolved;
30263
- const items2 = [
30295
+ const items3 = [
30264
30296
  { label: "Repository", value: `${target.owner}/${target.repo}` }
30265
30297
  ];
30266
- if (issueType) items2.push({ label: "Type", value: issueType.name });
30298
+ if (issueType) items3.push({ label: "Type", value: issueType.name });
30267
30299
  if (parent)
30268
- items2.push({
30300
+ items3.push({
30269
30301
  label: "Parent",
30270
30302
  value: `${parent.owner}/${parent.repo}#${parent.number}`,
30271
30303
  url: `https://github.com/${parent.owner}/${parent.repo}/issues/${parent.number}`
30272
30304
  });
30273
30305
  if (project)
30274
- items2.push({
30306
+ items3.push({
30275
30307
  label: "Project",
30276
30308
  value: `${project.number} (${project.title})`
30277
30309
  });
30278
30310
  if (project?.status)
30279
- items2.push({ label: "Status", value: project.status.optionName });
30280
- if (labels?.length) items2.push({ label: "Labels", value: labels.join(", ") });
30281
- if (milestone) items2.push({ label: "Milestone", value: milestone });
30282
- return items2;
30311
+ items3.push({ label: "Status", value: project.status.optionName });
30312
+ if (labels?.length) items3.push({ label: "Labels", value: labels.join(", ") });
30313
+ if (milestone) items3.push({ label: "Milestone", value: milestone });
30314
+ return items3;
30283
30315
  }
30284
30316
 
30285
30317
  // src/commands/github/issue/hasCreateIssueMetadataOptions.ts
@@ -31050,8 +31082,8 @@ function toIssueProjectItem(node) {
31050
31082
  function parseIssueProjectItems(raw, label) {
31051
31083
  const issue = JSON.parse(raw).data?.repository?.issue;
31052
31084
  if (!issue?.id) throw new Error(`No issue ${label} could be read`);
31053
- const items2 = (issue.projectItems?.nodes ?? []).map(toIssueProjectItem).filter((item) => item !== void 0);
31054
- return { issueId: issue.id, items: items2 };
31085
+ const items3 = (issue.projectItems?.nodes ?? []).map(toIssueProjectItem).filter((item) => item !== void 0);
31086
+ return { issueId: issue.id, items: items3 };
31055
31087
  }
31056
31088
 
31057
31089
  // src/commands/github/issue/fetchIssueProjectItems.ts
@@ -31118,14 +31150,14 @@ function moveIssueToInProgress(target) {
31118
31150
  console.log(error instanceof Error ? error.message : String(error));
31119
31151
  return;
31120
31152
  }
31121
- const { items: items2 } = fetchIssueProjectItems(target);
31122
- if (items2.length === 0) {
31153
+ const { items: items3 } = fetchIssueProjectItems(target);
31154
+ if (items3.length === 0) {
31123
31155
  console.log(
31124
31156
  `${target.owner}/${target.repo}#${target.number} is on no project board, so there was nothing to move`
31125
31157
  );
31126
31158
  return;
31127
31159
  }
31128
- for (const item of items2) moveItem(item);
31160
+ for (const item of items3) moveItem(item);
31129
31161
  }
31130
31162
 
31131
31163
  // src/commands/github/issue/parseIssueTarget.ts
@@ -31292,6 +31324,151 @@ async function writeInboxLastScan(orm, at2) {
31292
31324
  await orm.insert(metadata).values({ key: INBOX_LAST_SCAN_KEY, value }).onConflictDoUpdate({ target: metadata.key, set: { value } });
31293
31325
  }
31294
31326
 
31327
+ // src/commands/inbox/addScanUsage.ts
31328
+ function sumNullable(a, b) {
31329
+ return a === null && b === null ? null : (a ?? 0) + (b ?? 0);
31330
+ }
31331
+ function addScanUsage(a, b) {
31332
+ return {
31333
+ input: a.input + b.input,
31334
+ output: a.output + b.output,
31335
+ cacheRead: a.cacheRead + b.cacheRead,
31336
+ cacheWrite: a.cacheWrite + b.cacheWrite,
31337
+ costUsd: sumNullable(a.costUsd, b.costUsd),
31338
+ durationMs: sumNullable(a.durationMs, b.durationMs)
31339
+ };
31340
+ }
31341
+
31342
+ // src/commands/inbox/inboxFlagInstructions.ts
31343
+ function inboxFlagInstructions() {
31344
+ return [
31345
+ "Do not flag anything from bots, apps, automated or notification systems (CI, calendars, ticketing, monitoring, no-reply addresses), newsletters or mailing lists.",
31346
+ "Flag messages a person wrote to me that need me to reply or act. That includes messages that hand me something to act on without asking a question, such as a credential or secret to retrieve, a document to review, or a deadline to meet.",
31347
+ "Judge each message on its full content, never on a search snippet alone.",
31348
+ "",
31349
+ "For each flagged message return:",
31350
+ '- source: "gmail" or "slack"',
31351
+ "- messageId: the Gmail message id, or for Slack <channel_id>:<message ts>",
31352
+ "- sender: the sender's name",
31353
+ "- summary: one sentence on the reply or action it needs from me",
31354
+ "- link: the Gmail message viewUrl or the Slack permalink",
31355
+ "- receivedAt: when it was sent, as an ISO 8601 timestamp",
31356
+ "",
31357
+ "Return an empty messages array when nothing needs my reply or action."
31358
+ ];
31359
+ }
31360
+
31361
+ // src/commands/inbox/buildInboxScanPrompt.ts
31362
+ function buildInboxScanPrompt(since) {
31363
+ const sinceUnix = Math.floor(since.getTime() / 1e3);
31364
+ return [
31365
+ "Triage my Gmail and Slack for messages a person wrote to me that need my reply or action.",
31366
+ "You are read-only: never label, mark read, react to, reply to or otherwise change any message.",
31367
+ "",
31368
+ "Gmail:",
31369
+ '- Call search_threads with query "in:inbox is:unread" (page through all results).',
31370
+ "- Call get_thread with messageFormat PLAIN_TEXT on each thread.",
31371
+ "- Consider the latest unread message in each thread.",
31372
+ "",
31373
+ `Slack (only messages since ${since.toISOString()}, unix ${sinceUnix}):`,
31374
+ `- Call slack_search_public_and_private with filters "is:dm" and after "${sinceUnix}".`,
31375
+ `- Call slack_search_public_and_private with keywords ["<@MY_USER_ID>"] and after "${sinceUnix}", where MY_USER_ID is the logged-in user id from the tool description.`,
31376
+ "- Skip messages I wrote myself.",
31377
+ "- For a message in a thread, call slack_read_thread and skip it if I have replied in that thread after it.",
31378
+ "",
31379
+ ...inboxFlagInstructions()
31380
+ ].join("\n");
31381
+ }
31382
+
31383
+ // src/commands/inbox/buildInboxThreadsPrompt.ts
31384
+ function buildInboxThreadsPrompt(threadIds) {
31385
+ return [
31386
+ "Triage these unread threads from my Gmail inbox for messages that need my reply or action.",
31387
+ "You are read-only: never label, mark read, reply to or otherwise change any message.",
31388
+ "",
31389
+ "Call get_thread with messageFormat PLAIN_TEXT on every one of these thread ids, and consider the latest unread message in each:",
31390
+ ...threadIds.map((id) => `- ${id}`),
31391
+ "",
31392
+ ...inboxFlagInstructions()
31393
+ ].join("\n");
31394
+ }
31395
+
31396
+ // src/commands/inbox/scanUnopenedThreads.ts
31397
+ var BATCH_SIZE = 25;
31398
+ var CONCURRENCY2 = 4;
31399
+ var MAX_ATTEMPTS = 2;
31400
+ function chunk(items3, size) {
31401
+ return Array.from(
31402
+ { length: Math.ceil(items3.length / size) },
31403
+ (_, i) => items3.slice(i * size, (i + 1) * size)
31404
+ );
31405
+ }
31406
+ function errorEvent(detail) {
31407
+ return {
31408
+ at: (/* @__PURE__ */ new Date()).toISOString(),
31409
+ kind: "error",
31410
+ label: "Gmail",
31411
+ detail
31412
+ };
31413
+ }
31414
+ async function scanUnopenedThreads(threadIds, scanThreads, onEvent = () => {
31415
+ }) {
31416
+ const messages = [];
31417
+ let pending = threadIds;
31418
+ for (let attempt2 = 0; attempt2 < MAX_ATTEMPTS && pending.length; attempt2++) {
31419
+ const results = await mapAsync(
31420
+ chunk(pending, BATCH_SIZE),
31421
+ CONCURRENCY2,
31422
+ (batch) => scanThreads(batch).catch((error) => {
31423
+ onEvent(
31424
+ errorEvent(error instanceof Error ? error.message : String(error))
31425
+ );
31426
+ return void 0;
31427
+ })
31428
+ );
31429
+ const opened = new Set(results.flatMap((r) => r?.threads.opened ?? []));
31430
+ messages.push(...results.flatMap((r) => r?.messages ?? []));
31431
+ pending = pending.filter((id) => !opened.has(id));
31432
+ }
31433
+ if (pending.length)
31434
+ onEvent(
31435
+ errorEvent(
31436
+ `${pending.length} unread thread(s) never opened: ${pending.join(" ")}`
31437
+ )
31438
+ );
31439
+ return messages;
31440
+ }
31441
+
31442
+ // src/commands/inbox/scanInboxWithCoverage.ts
31443
+ async function scanInboxWithCoverage(since, listener) {
31444
+ const runs = [];
31445
+ const total3 = () => runs.reduce(addScanUsage, emptyScanUsage());
31446
+ const run4 = (pass) => {
31447
+ const slot = runs.push(emptyScanUsage()) - 1;
31448
+ return runInboxScanClaude(pass, {
31449
+ ...listener,
31450
+ onUsage: (usage) => {
31451
+ runs[slot] = usage;
31452
+ listener.onUsage?.(total3());
31453
+ }
31454
+ });
31455
+ };
31456
+ const main = await run4({
31457
+ prompt: buildInboxScanPrompt(since),
31458
+ allowedTools: inboxScanTools.allowed
31459
+ });
31460
+ const opened = new Set(main.threads.opened);
31461
+ const followUp = await scanUnopenedThreads(
31462
+ main.threads.found.filter((id) => !opened.has(id)),
31463
+ (threadIds) => run4({
31464
+ prompt: buildInboxThreadsPrompt(threadIds),
31465
+ allowedTools: [inboxScanTools.gmailGetThread]
31466
+ }),
31467
+ listener.onEvent
31468
+ );
31469
+ return { messages: [...main.messages, ...followUp], usage: total3() };
31470
+ }
31471
+
31295
31472
  // src/shared/db/finishJobRun.ts
31296
31473
  import { eq as eq55 } from "drizzle-orm";
31297
31474
  async function finishJobRun(db, id, result) {
@@ -31372,7 +31549,7 @@ async function runInboxScan(orm, { trigger, wrap = (_since, run4) => run4(), ...
31372
31549
  const since = await readInboxLastScan(orm) ?? new Date(startedAt.getTime() - FIRST_SCAN_LOOKBACK_MS);
31373
31550
  const { messages, usage } = await wrap(
31374
31551
  since,
31375
- () => runInboxScanClaude(since, tracked)
31552
+ () => scanInboxWithCoverage(since, tracked)
31376
31553
  );
31377
31554
  const added = await upsertInboxMessages(orm, messages.map(toRow2));
31378
31555
  await writeInboxLastScan(orm, startedAt);
@@ -31922,9 +32099,33 @@ function persistedTreeRoots() {
31922
32099
  import { copyFileSync, existsSync as existsSync67, mkdirSync as mkdirSync24 } from "fs";
31923
32100
  import { dirname as dirname36, join as join81 } from "path";
31924
32101
 
31925
- // src/commands/sessions/daemon/worktree/runInstall.ts
32102
+ // src/commands/sessions/daemon/worktree/installPaths.ts
31926
32103
  import { resolve as resolve22 } from "path";
31927
32104
 
32105
+ // src/commands/sessions/daemon/worktree/enclosingPaths.ts
32106
+ import { isAbsolute as isAbsolute4, relative as relative8 } from "path";
32107
+ function isWithin(dir, parent) {
32108
+ const rel = relative8(parent, dir);
32109
+ return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
32110
+ }
32111
+ function enclosingPaths(dirs) {
32112
+ return dirs.map(
32113
+ (dir, i) => dirs.slice(0, i).flatMap((other, j) => isWithin(dir, other) ? [j] : [])
32114
+ );
32115
+ }
32116
+
32117
+ // src/commands/sessions/daemon/worktree/pendingPathAction.ts
32118
+ function pendingPathAction(enclosing, states, paths, stopped) {
32119
+ if (stopped) return { kind: "skip", reason: "install stopped" };
32120
+ const failed3 = enclosing.find(
32121
+ (j) => states[j] === "failed" || states[j] === "skipped"
32122
+ );
32123
+ if (failed3 !== void 0)
32124
+ return { kind: "skip", reason: `${paths[failed3]} failed` };
32125
+ if (enclosing.every((j) => states[j] === "ok")) return { kind: "start" };
32126
+ return { kind: "wait" };
32127
+ }
32128
+
31928
32129
  // src/commands/sessions/daemon/worktree/detectInstallCommand.ts
31929
32130
  import { existsSync as existsSync66 } from "fs";
31930
32131
  import { join as join80 } from "path";
@@ -31937,13 +32138,6 @@ function detectInstallCommand(dir) {
31937
32138
  return "npm install";
31938
32139
  }
31939
32140
 
31940
- // src/commands/sessions/daemon/worktree/resolveInstallCommand.ts
31941
- function resolveInstallCommand(repoRoot2, install) {
31942
- if (install === false) return null;
31943
- if (typeof install === "string") return install;
31944
- return detectInstallCommand(repoRoot2);
31945
- }
31946
-
31947
32141
  // src/commands/sessions/daemon/worktree/spawnInstall.ts
31948
32142
  import { spawn as spawn7 } from "child_process";
31949
32143
 
@@ -31974,21 +32168,26 @@ function quoteForPosixShell(value) {
31974
32168
  import { execFile as execFile12 } from "child_process";
31975
32169
  var running2 = /* @__PURE__ */ new Map();
31976
32170
  function trackInstall(worktreePath, child) {
31977
- running2.set(worktreePath, child);
32171
+ const children = running2.get(worktreePath) ?? /* @__PURE__ */ new Set();
32172
+ children.add(child);
32173
+ running2.set(worktreePath, children);
31978
32174
  }
31979
32175
  function untrackInstall(worktreePath, child) {
31980
- if (running2.get(worktreePath) !== child) return false;
31981
- running2.delete(worktreePath);
32176
+ const children = running2.get(worktreePath);
32177
+ if (!children?.delete(child)) return false;
32178
+ if (children.size === 0) running2.delete(worktreePath);
31982
32179
  return true;
31983
32180
  }
31984
32181
  function stopInstall(worktreePath) {
31985
- const child = running2.get(worktreePath);
32182
+ const children = running2.get(worktreePath);
31986
32183
  running2.delete(worktreePath);
31987
- if (!child?.pid) return;
31988
- daemonLog(
31989
- `worktree ${worktreePath} install still running at teardown; killing pid ${child.pid} so removal is not racing it`
31990
- );
31991
- killTree(child.pid);
32184
+ for (const child of children ?? []) {
32185
+ if (!child.pid) continue;
32186
+ daemonLog(
32187
+ `worktree ${worktreePath} install still running at teardown; killing pid ${child.pid} so removal is not racing it`
32188
+ );
32189
+ killTree(child.pid);
32190
+ }
31992
32191
  }
31993
32192
  function killTree(pid) {
31994
32193
  if (process.platform === "win32") {
@@ -32018,8 +32217,8 @@ function spawnInstall(worktreePath, cwd, command, where, onDone) {
32018
32217
  const child = spawn7(...installInvocation(cwd, command));
32019
32218
  trackInstall(worktreePath, child);
32020
32219
  let stderr = "";
32021
- child.stderr?.on("data", (chunk) => {
32022
- stderr = (stderr + chunk.toString()).slice(-STDERR_TAIL);
32220
+ child.stderr?.on("data", (chunk2) => {
32221
+ stderr = (stderr + chunk2.toString()).slice(-STDERR_TAIL);
32023
32222
  });
32024
32223
  let settled = false;
32025
32224
  const settle = (ok, outcome) => {
@@ -32042,6 +32241,66 @@ function spawnInstall(worktreePath, cwd, command, where, onDone) {
32042
32241
  );
32043
32242
  }
32044
32243
 
32244
+ // src/commands/sessions/daemon/worktree/startPathInstall.ts
32245
+ function startPathInstall(worktreePath, rel, dir, onDone) {
32246
+ const command = detectInstallCommand(dir);
32247
+ if (!command) {
32248
+ daemonLog(
32249
+ `worktree ${worktreePath} install in ${rel} failed: no package.json at ${dir}`
32250
+ );
32251
+ return "failed";
32252
+ }
32253
+ spawnInstall(
32254
+ worktreePath,
32255
+ dir,
32256
+ command,
32257
+ ` in ${rel}`,
32258
+ (outcome) => onDone(outcome.ok && !outcome.stopped, outcome.stopped)
32259
+ );
32260
+ return "running";
32261
+ }
32262
+
32263
+ // src/commands/sessions/daemon/worktree/installPaths.ts
32264
+ function installPaths(worktreePath, paths, onSeeded, onInstalling) {
32265
+ const dirs = paths.map((rel) => resolve22(worktreePath, rel));
32266
+ const enclosing = enclosingPaths(dirs);
32267
+ const states = paths.map(() => "pending");
32268
+ let stopped = false;
32269
+ const pump = () => {
32270
+ for (let i = 0; i < paths.length; i++) {
32271
+ if (states[i] !== "pending") continue;
32272
+ const action = pendingPathAction(enclosing[i], states, paths, stopped);
32273
+ if (action.kind === "start")
32274
+ states[i] = startPathInstall(
32275
+ worktreePath,
32276
+ paths[i],
32277
+ dirs[i],
32278
+ (ok, wasStopped) => {
32279
+ states[i] = ok ? "ok" : "failed";
32280
+ stopped ||= wasStopped;
32281
+ pump();
32282
+ }
32283
+ );
32284
+ if (action.kind !== "skip") continue;
32285
+ states[i] = "skipped";
32286
+ daemonLog(
32287
+ `worktree ${worktreePath} install skipping ${paths[i]}: ${action.reason}`
32288
+ );
32289
+ }
32290
+ const running3 = paths.filter((_, i) => states[i] === "running");
32291
+ if (running3.length > 0) onInstalling(running3.join(", "));
32292
+ else if (!states.includes("pending")) onSeeded();
32293
+ };
32294
+ pump();
32295
+ }
32296
+
32297
+ // src/commands/sessions/daemon/worktree/resolveInstallCommand.ts
32298
+ function resolveInstallCommand(repoRoot2, install) {
32299
+ if (install === false) return null;
32300
+ if (typeof install === "string") return install;
32301
+ return detectInstallCommand(repoRoot2);
32302
+ }
32303
+
32045
32304
  // src/commands/sessions/daemon/worktree/runInstall.ts
32046
32305
  function runInstall(worktreePath, clone, install, onSeeded, onInstalling = () => {
32047
32306
  }) {
@@ -32057,37 +32316,6 @@ function runInstall(worktreePath, clone, install, onSeeded, onInstalling = () =>
32057
32316
  onInstalling();
32058
32317
  spawnInstall(worktreePath, worktreePath, command, "", () => onSeeded());
32059
32318
  }
32060
- function installPaths(worktreePath, paths, onSeeded, onInstalling) {
32061
- const next3 = (index3) => {
32062
- const rel = paths[index3];
32063
- if (rel === void 0) {
32064
- onSeeded();
32065
- return;
32066
- }
32067
- const dir = resolve22(worktreePath, rel);
32068
- const command = detectInstallCommand(dir);
32069
- if (!command) {
32070
- daemonLog(
32071
- `worktree ${worktreePath} install in ${rel} failed: no package.json at ${dir}; skipping remaining paths`
32072
- );
32073
- onSeeded();
32074
- return;
32075
- }
32076
- onInstalling(rel);
32077
- spawnInstall(worktreePath, dir, command, ` in ${rel}`, (outcome) => {
32078
- if (outcome.ok && !outcome.stopped) {
32079
- next3(index3 + 1);
32080
- return;
32081
- }
32082
- if (index3 < paths.length - 1)
32083
- daemonLog(
32084
- `worktree ${worktreePath} install skipping remaining paths: ${paths.slice(index3 + 1).join(", ")}`
32085
- );
32086
- onSeeded();
32087
- });
32088
- };
32089
- next3(0);
32090
- }
32091
32319
 
32092
32320
  // src/commands/sessions/daemon/worktree/seedWorktree.ts
32093
32321
  function seedWorktree(worktreePath, clone, onSeeded = () => {
@@ -32601,26 +32829,26 @@ async function renderBlock(krokiUrl, source) {
32601
32829
  // src/commands/mermaid/exportFile.ts
32602
32830
  async function exportFile(file, outDir, krokiUrl, onlyIndex) {
32603
32831
  const content = readFileSync47(file, "utf8");
32604
- const blocks = extractMermaidBlocks(content);
32832
+ const blocks2 = extractMermaidBlocks(content);
32605
32833
  const stem = basename21(file, extname4(file));
32606
32834
  if (onlyIndex !== void 0) {
32607
- if (onlyIndex < 1 || onlyIndex > blocks.length) {
32835
+ if (onlyIndex < 1 || onlyIndex > blocks2.length) {
32608
32836
  console.error(
32609
32837
  chalk195.red(
32610
- `${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
32838
+ `${file}: --index ${onlyIndex} out of range (file has ${blocks2.length} diagram(s))`
32611
32839
  )
32612
32840
  );
32613
32841
  process.exit(1);
32614
32842
  }
32615
32843
  console.log(
32616
32844
  chalk195.gray(
32617
- `${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
32845
+ `${file} \u2014 rendering diagram ${onlyIndex} of ${blocks2.length}`
32618
32846
  )
32619
32847
  );
32620
32848
  } else {
32621
- console.log(chalk195.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
32849
+ console.log(chalk195.gray(`${file} \u2014 ${blocks2.length} diagram(s)`));
32622
32850
  }
32623
- for (const [i, source] of blocks.entries()) {
32851
+ for (const [i, source] of blocks2.entries()) {
32624
32852
  const idx = i + 1;
32625
32853
  if (onlyIndex !== void 0 && idx !== onlyIndex) continue;
32626
32854
  const outPath = resolve23(outDir, `${stem}-${idx}.svg`);
@@ -32711,9 +32939,9 @@ function anchorSource(options2) {
32711
32939
  function boardId(url) {
32712
32940
  return url ? /\/board\/([^/?]+)/.exec(url)?.[1] : void 0;
32713
32941
  }
32714
- function miroSource(items2, anchorId) {
32715
- const anchor = items2.find((item) => item.id === anchorId);
32716
- const ordered = anchor ? [anchor, ...items2] : items2;
32942
+ function miroSource(items3, anchorId) {
32943
+ const anchor = items3.find((item) => item.id === anchorId);
32944
+ const ordered = anchor ? [anchor, ...items3] : items3;
32717
32945
  return {
32718
32946
  board: boardId(ordered.find((item) => item.miro_url)?.miro_url),
32719
32947
  frame: ordered.find((item) => item.parent?.id)?.parent?.id
@@ -32765,18 +32993,18 @@ function emitExtract(out, header, texts) {
32765
32993
  }
32766
32994
 
32767
32995
  // src/commands/miro/resolveExtractPath.ts
32768
- import { isAbsolute as isAbsolute4, relative as relative8, resolve as resolve25 } from "path";
32996
+ import { isAbsolute as isAbsolute5, relative as relative9, resolve as resolve25 } from "path";
32769
32997
  function extractRoot(cwd) {
32770
32998
  return findConfigUp(cwd)?.rootDir ?? cwd;
32771
32999
  }
32772
33000
  function resolveExtractPath(value, cwd) {
32773
33001
  if (value === void 0) return void 0;
32774
- return isAbsolute4(value) ? value : resolve25(extractRoot(cwd), value);
33002
+ return isAbsolute5(value) ? value : resolve25(extractRoot(cwd), value);
32775
33003
  }
32776
33004
  function storedExtractPath(value, cwd) {
32777
33005
  if (value === void 0) return void 0;
32778
33006
  const absolute2 = resolve25(cwd, value);
32779
- const within2 = relative8(extractRoot(cwd), absolute2);
33007
+ const within2 = relative9(extractRoot(cwd), absolute2);
32780
33008
  return within2.startsWith("..") ? absolute2 : within2;
32781
33009
  }
32782
33010
 
@@ -32901,12 +33129,12 @@ function toItem(item) {
32901
33129
  bottom: y + halfHeight
32902
33130
  };
32903
33131
  }
32904
- function normaliseItems(items2) {
32905
- const rejected = items2.filter(
33132
+ function normaliseItems(items3) {
33133
+ const rejected = items3.filter(
32906
33134
  (item) => item.position?.relativeTo !== frameCoordinates
32907
33135
  );
32908
33136
  if (rejected.length > 0) throw coordinateSpaceError(rejected);
32909
- return items2.map(toItem);
33137
+ return items3.map(toItem);
32910
33138
  }
32911
33139
 
32912
33140
  // src/commands/miro/saveMiroExtract.ts
@@ -32969,21 +33197,21 @@ function isBox(item) {
32969
33197
  }
32970
33198
 
32971
33199
  // src/commands/miro/encodeMiroBoardPreview.ts
32972
- function encodeMiroBoardPreview(items2) {
32973
- const preview = { boxes: items2.filter(isBox) };
33200
+ function encodeMiroBoardPreview(items3) {
33201
+ const preview = { boxes: items3.filter(isBox) };
32974
33202
  return JSON.stringify(preview);
32975
33203
  }
32976
33204
 
32977
33205
  // src/commands/miro/pickAnchors.ts
32978
33206
  var skipAdvice = "Re-run with --top-left <id|link> --bottom-right <id|link> to skip the picker.";
32979
- async function pickAnchors(sessionId2, items2) {
33207
+ async function pickAnchors(sessionId2, items3) {
32980
33208
  const decision = await awaitPreviewApproval(
32981
33209
  "Miro anchor selection",
32982
33210
  {
32983
33211
  sessionId: sessionId2,
32984
33212
  requestId: randomUUID19(),
32985
33213
  title: "Pick the top-left then the bottom-right box",
32986
- body: encodeMiroBoardPreview(items2),
33214
+ body: encodeMiroBoardPreview(items3),
32987
33215
  prNumber: null,
32988
33216
  kind: "miro-board"
32989
33217
  },
@@ -33028,14 +33256,14 @@ function parsePages(raw, file) {
33028
33256
  return Array.isArray(parsed) ? parsed.map(toPage) : [toPage(parsed)];
33029
33257
  }
33030
33258
  function readMiroItems(file) {
33031
- const items2 = parsePages(readFileSync49(file, "utf8"), file).flatMap(
33259
+ const items3 = parsePages(readFileSync49(file, "utf8"), file).flatMap(
33032
33260
  (page) => page.data ?? []
33033
33261
  );
33034
- if (items2.length === 0)
33262
+ if (items3.length === 0)
33035
33263
  throw new MiroExtractError(
33036
33264
  `No board items found in ${file}. Dump the frame with board_list_items, paging until has_more is false.`
33037
33265
  );
33038
- return items2;
33266
+ return items3;
33039
33267
  }
33040
33268
 
33041
33269
  // src/commands/miro/resolveExtractOptions.ts
@@ -33122,8 +33350,8 @@ function resolveExtractOptions(name, options2, paths) {
33122
33350
  }
33123
33351
 
33124
33352
  // src/commands/miro/selectBoxes.ts
33125
- function findAnchor(items2, id) {
33126
- const anchor = items2.find((item) => item.id === id);
33353
+ function findAnchor(items3, id) {
33354
+ const anchor = items3.find((item) => item.id === id);
33127
33355
  if (!anchor)
33128
33356
  throw new MiroExtractError(
33129
33357
  `No item with id ${id} in the supplied items. Re-dump the frame so the anchor is included, then try again.`
@@ -33135,16 +33363,16 @@ function centreInside(rect, item) {
33135
33363
  const y = (item.top + item.bottom) / 2;
33136
33364
  return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
33137
33365
  }
33138
- function selectBoxes(items2, topLeftId, bottomRightId) {
33139
- const topLeft = findAnchor(items2, topLeftId);
33140
- const bottomRight = findAnchor(items2, bottomRightId);
33366
+ function selectBoxes(items3, topLeftId, bottomRightId) {
33367
+ const topLeft = findAnchor(items3, topLeftId);
33368
+ const bottomRight = findAnchor(items3, bottomRightId);
33141
33369
  const rect = {
33142
33370
  left: topLeft.left,
33143
33371
  top: topLeft.top,
33144
33372
  right: bottomRight.right,
33145
33373
  bottom: bottomRight.bottom
33146
33374
  };
33147
- const boxes = items2.filter((item) => isBox(item) && centreInside(rect, item)).sort((a, b) => a.left - b.left || a.top - b.top);
33375
+ const boxes = items3.filter((item) => isBox(item) && centreInside(rect, item)).sort((a, b) => a.left - b.left || a.top - b.top);
33148
33376
  return { rect, boxes };
33149
33377
  }
33150
33378
 
@@ -33161,9 +33389,9 @@ async function runExtract(name, options2, paths = {}) {
33161
33389
  const source = anchorSource(resolved);
33162
33390
  const itemsFile = requireItems(resolved.items);
33163
33391
  const raw = readMiroItems(itemsFile);
33164
- const items2 = normaliseItems(raw);
33165
- const [topLeft, bottomRight] = source.pick ? await pickAnchors(source.sessionId, items2) : [source.topLeft, source.bottomRight];
33166
- const selection = selectBoxes(items2, topLeft, bottomRight);
33392
+ const items3 = normaliseItems(raw);
33393
+ const [topLeft, bottomRight] = source.pick ? await pickAnchors(source.sessionId, items3) : [source.topLeft, source.bottomRight];
33394
+ const selection = selectBoxes(items3, topLeft, bottomRight);
33167
33395
  const board = boardSource(raw, topLeft, resolved);
33168
33396
  emitExtract(
33169
33397
  resolved.out,
@@ -33249,8 +33477,8 @@ function parseNetcapEntry(body) {
33249
33477
  // src/commands/netcap/handleNetcapPost.ts
33250
33478
  function handleNetcapPost(req, res, options2) {
33251
33479
  let body = "";
33252
- req.on("data", (chunk) => {
33253
- body += chunk;
33480
+ req.on("data", (chunk2) => {
33481
+ body += chunk2;
33254
33482
  });
33255
33483
  req.on("end", () => {
33256
33484
  const entry = parseNetcapEntry(body);
@@ -33363,7 +33591,7 @@ async function prepareExtensionForLoad(port, filter = "") {
33363
33591
  }
33364
33592
 
33365
33593
  // src/commands/netcap/resolveNetcapOutPath.ts
33366
- import { isAbsolute as isAbsolute5, join as join85, resolve as resolve26 } from "path";
33594
+ import { isAbsolute as isAbsolute6, join as join85, resolve as resolve26 } from "path";
33367
33595
 
33368
33596
  // src/commands/netcap/defaultCapturePath.ts
33369
33597
  import { homedir as homedir24 } from "os";
@@ -33375,7 +33603,7 @@ function defaultCapturePath() {
33375
33603
  // src/commands/netcap/resolveNetcapOutPath.ts
33376
33604
  function resolveNetcapOutPath(out) {
33377
33605
  if (!out) return defaultCapturePath();
33378
- const dir = isAbsolute5(out) ? out : resolve26(process.cwd(), out);
33606
+ const dir = isAbsolute6(out) ? out : resolve26(process.cwd(), out);
33379
33607
  return join85(dir, "capture.jsonl");
33380
33608
  }
33381
33609
 
@@ -36527,9 +36755,9 @@ function opExec(args) {
36527
36755
  }).trim();
36528
36756
  }
36529
36757
  function searchItems(search2) {
36530
- let items2;
36758
+ let items3;
36531
36759
  try {
36532
- items2 = JSON.parse(opExec("item list --format=json"));
36760
+ items3 = JSON.parse(opExec("item list --format=json"));
36533
36761
  } catch {
36534
36762
  console.error(
36535
36763
  chalk211.red(
@@ -36539,7 +36767,7 @@ function searchItems(search2) {
36539
36767
  process.exit(1);
36540
36768
  }
36541
36769
  const lower = search2.toLowerCase();
36542
- return items2.filter((i) => i.title.toLowerCase().includes(lower));
36770
+ return items3.filter((i) => i.title.toLowerCase().includes(lower));
36543
36771
  }
36544
36772
  function getItemFields(itemId2) {
36545
36773
  try {
@@ -36563,14 +36791,14 @@ async function selectOpSecret(searchTerm) {
36563
36791
  name: "search",
36564
36792
  message: "Search 1Password for API key item:"
36565
36793
  }).run();
36566
- const items2 = searchItems(search2);
36567
- if (items2.length === 0) {
36794
+ const items3 = searchItems(search2);
36795
+ if (items3.length === 0) {
36568
36796
  console.error(chalk212.red(`No items found matching "${search2}".`));
36569
36797
  process.exit(1);
36570
36798
  }
36571
36799
  const itemId2 = await selectOne(
36572
36800
  "Select item:",
36573
- items2.map((i) => ({ name: `${i.title} (${i.vault.name})`, value: i.id }))
36801
+ items3.map((i) => ({ name: `${i.title} (${i.vault.name})`, value: i.id }))
36574
36802
  );
36575
36803
  const fields = getItemFields(itemId2);
36576
36804
  if (fields.length === 0) {
@@ -37836,7 +38064,7 @@ function buildLimitsSegment(rateLimits) {
37836
38064
 
37837
38065
  // src/commands/readGitBranch.ts
37838
38066
  import { readFileSync as readFileSync54, statSync as statSync11 } from "fs";
37839
- import { isAbsolute as isAbsolute6, join as join91, resolve as resolve29 } from "path";
38067
+ import { isAbsolute as isAbsolute7, join as join91, resolve as resolve29 } from "path";
37840
38068
  function resolveGitDir(cwd) {
37841
38069
  const dotGit = join91(cwd, ".git");
37842
38070
  let stat5;
@@ -37859,7 +38087,7 @@ function resolveGitDir(cwd) {
37859
38087
  return null;
37860
38088
  }
37861
38089
  const gitDir = match[1].trim();
37862
- return isAbsolute6(gitDir) ? gitDir : resolve29(cwd, gitDir);
38090
+ return isAbsolute7(gitDir) ? gitDir : resolve29(cwd, gitDir);
37863
38091
  }
37864
38092
  function readGitBranch(cwd) {
37865
38093
  const gitDir = resolveGitDir(cwd);
@@ -40942,14 +41170,14 @@ function fetchHighLevelFiles(prNumber, repo) {
40942
41170
  import { execSync as execSync57 } from "child_process";
40943
41171
 
40944
41172
  // src/commands/review/highLevel/waitForMergeable.ts
40945
- var MAX_ATTEMPTS = 5;
41173
+ var MAX_ATTEMPTS2 = 5;
40946
41174
  var DELAY_MS = 2e3;
40947
41175
  function sleepSync2(ms) {
40948
41176
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
40949
41177
  }
40950
41178
  function waitForMergeable(initial, refetch, delayMs = DELAY_MS) {
40951
41179
  let mergeable = initial;
40952
- for (let attempt2 = 1; mergeable === "UNKNOWN" && attempt2 < MAX_ATTEMPTS; attempt2++) {
41180
+ for (let attempt2 = 1; mergeable === "UNKNOWN" && attempt2 < MAX_ATTEMPTS2; attempt2++) {
40953
41181
  sleepSync2(delayMs);
40954
41182
  mergeable = refetch();
40955
41183
  }
@@ -41739,13 +41967,13 @@ function formatItem(item) {
41739
41967
  const comment3 = item.comment.replace(/\n/g, "\n ");
41740
41968
  return `- ${statusMarkers[item.status]} **${item.title}** \u2014 ${comment3}`;
41741
41969
  }
41742
- function findings(items2) {
41743
- const lines2 = items2.map(formatItem).filter((line) => line !== void 0);
41970
+ function findings(items3) {
41971
+ const lines2 = items3.map(formatItem).filter((line) => line !== void 0);
41744
41972
  return lines2.length > 0 ? lines2.join("\n") : void 0;
41745
41973
  }
41746
- function sliceSections(items2) {
41974
+ function sliceSections(items3) {
41747
41975
  const bySlice = /* @__PURE__ */ new Map();
41748
- for (const item of items2)
41976
+ for (const item of items3)
41749
41977
  if (item.slice !== void 0)
41750
41978
  bySlice.set(item.slice, [...bySlice.get(item.slice) ?? [], item]);
41751
41979
  return [...bySlice].flatMap(([number, sliceItems]) => {
@@ -41757,11 +41985,11 @@ function sliceSections(items2) {
41757
41985
  ${lines2}`];
41758
41986
  });
41759
41987
  }
41760
- function formatHighLevelReviewBody(items2, reviewComments2 = []) {
41988
+ function formatHighLevelReviewBody(items3, reviewComments2 = []) {
41761
41989
  const sections = [];
41762
- const prWide = findings(items2.filter((item) => item.slice === void 0));
41990
+ const prWide = findings(items3.filter((item) => item.slice === void 0));
41763
41991
  if (prWide) sections.push(prWide);
41764
- sections.push(...sliceSections(items2));
41992
+ sections.push(...sliceSections(items3));
41765
41993
  if (reviewComments2.length > 0)
41766
41994
  sections.push(
41767
41995
  `**Comments**
@@ -43105,8 +43333,8 @@ import { spawn as spawn9 } from "child_process";
43105
43333
  // src/commands/review/attachStdoutTail.ts
43106
43334
  function attachStdoutTail(child, maxBytes = 8192) {
43107
43335
  const state = { value: "" };
43108
- child.stdout?.on("data", (chunk) => {
43109
- state.value += chunk.toString("utf8");
43336
+ child.stdout?.on("data", (chunk2) => {
43337
+ state.value += chunk2.toString("utf8");
43110
43338
  if (state.value.length > maxBytes) {
43111
43339
  state.value = state.value.slice(state.value.length - maxBytes);
43112
43340
  }
@@ -43820,12 +44048,12 @@ function formatThread(thread) {
43820
44048
  var INTRO = `The PR already has the review comments below (including resolved and outdated threads). Avoid re-raising findings that a prior comment substantively covers.`;
43821
44049
  function formatPriorComments(comments3) {
43822
44050
  if (comments3.length === 0) return "";
43823
- const blocks = groupIntoThreads(comments3).map(formatThread);
44051
+ const blocks2 = groupIntoThreads(comments3).map(formatThread);
43824
44052
  return `## Prior review comments
43825
44053
 
43826
44054
  ${INTRO}
43827
44055
 
43828
- ${blocks.join("\n\n")}`;
44056
+ ${blocks2.join("\n\n")}`;
43829
44057
  }
43830
44058
 
43831
44059
  // src/commands/review/buildRequest.ts
@@ -45273,10 +45501,10 @@ function referencePatterns(path109, { home, cwd }) {
45273
45501
  const underHome = within(file, normalise(home));
45274
45502
  if (underHome) forms.push(`~/${escapeRegExp2(underHome)}`);
45275
45503
  const patterns = forms.map((form) => new RegExp(`${form}${NOT_AFTER}`));
45276
- const relative9 = within(file, normalise(cwd));
45277
- if (relative9)
45504
+ const relative10 = within(file, normalise(cwd));
45505
+ if (relative10)
45278
45506
  patterns.push(
45279
- new RegExp(`${NOT_BEFORE_RELATIVE}${escapeRegExp2(relative9)}${NOT_AFTER}`)
45507
+ new RegExp(`${NOT_BEFORE_RELATIVE}${escapeRegExp2(relative10)}${NOT_AFTER}`)
45280
45508
  );
45281
45509
  return patterns;
45282
45510
  }
@@ -51297,8 +51525,8 @@ function runUpdateLap(cwd, onOutput) {
51297
51525
  child.kill();
51298
51526
  };
51299
51527
  process.on("exit", killWithDaemon);
51300
- child.stdout.on("data", (chunk) => onOutput(chunk.toString()));
51301
- child.stderr.on("data", (chunk) => onOutput(chunk.toString()));
51528
+ child.stdout.on("data", (chunk2) => onOutput(chunk2.toString()));
51529
+ child.stderr.on("data", (chunk2) => onOutput(chunk2.toString()));
51302
51530
  child.on("close", (code, signal) => {
51303
51531
  process.off("exit", killWithDaemon);
51304
51532
  resolve34({ code, signal });
@@ -52196,7 +52424,7 @@ function autoApprovePreview(sessions, waiters, notify2, session) {
52196
52424
  // src/commands/sessions/daemon/parsePreviewMetadata.ts
52197
52425
  function parsePreviewMetadata(value) {
52198
52426
  if (!Array.isArray(value)) return void 0;
52199
- const items2 = value.flatMap((entry) => {
52427
+ const items3 = value.flatMap((entry) => {
52200
52428
  const {
52201
52429
  label,
52202
52430
  value: text20,
@@ -52207,7 +52435,7 @@ function parsePreviewMetadata(value) {
52207
52435
  typeof url === "string" ? { label, value: text20, url } : { label, value: text20 }
52208
52436
  ];
52209
52437
  });
52210
- return items2.length > 0 ? items2 : void 0;
52438
+ return items3.length > 0 ? items3 : void 0;
52211
52439
  }
52212
52440
 
52213
52441
  // src/commands/sessions/daemon/buildPrPreview.ts
@@ -52874,13 +53102,13 @@ async function touchedSince(file, sinceMs) {
52874
53102
 
52875
53103
  // src/commands/sessions/daemon/bindCodexSession.ts
52876
53104
  var POLL_MS6 = 1e3;
52877
- var MAX_ATTEMPTS2 = 120;
53105
+ var MAX_ATTEMPTS3 = 120;
52878
53106
  var START_SLACK_MS = 5e3;
52879
53107
  function bindCodexSession(session, notify2) {
52880
53108
  const cwd = session.cwd;
52881
53109
  if (session.harness !== "codex" || !cwd || session.harnessSessionId) return;
52882
53110
  const since = session.startedAt - START_SLACK_MS;
52883
- let attemptsLeft = MAX_ATTEMPTS2;
53111
+ let attemptsLeft = MAX_ATTEMPTS3;
52884
53112
  const schedule = () => setTimeout(() => void poll(), POLL_MS6).unref();
52885
53113
  const poll = async () => {
52886
53114
  if (session.harnessSessionId) return;
@@ -57009,7 +57237,7 @@ function findTitleMatch(title, query) {
57009
57237
  }
57010
57238
 
57011
57239
  // src/commands/sessions/daemon/historySearch/searchHistory.ts
57012
- var BATCH_SIZE = 16;
57240
+ var BATCH_SIZE2 = 16;
57013
57241
  var MAX_RESULTS2 = 100;
57014
57242
  function inRepo(cwd) {
57015
57243
  const selectedKey = repoGroupForCwd(cwd)?.origin || cwd;
@@ -57031,9 +57259,9 @@ async function matchBatch(batch, query) {
57031
57259
  async function searchHistory(cwd, query) {
57032
57260
  const candidates = (await discoverHistoryEntries()).filter(inRepo(cwd));
57033
57261
  const hits = [];
57034
- for (let i = 0; i < candidates.length && hits.length < MAX_RESULTS2; i += BATCH_SIZE)
57262
+ for (let i = 0; i < candidates.length && hits.length < MAX_RESULTS2; i += BATCH_SIZE2)
57035
57263
  hits.push(
57036
- ...await matchBatch(candidates.slice(i, i + BATCH_SIZE), query)
57264
+ ...await matchBatch(candidates.slice(i, i + BATCH_SIZE2), query)
57037
57265
  );
57038
57266
  return withRepoGroups(hits.slice(0, MAX_RESULTS2));
57039
57267
  }