@staff0rd/assist 0.1065.0 → 0.1065.1
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/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +507 -330
- package/package.json +1 -1
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.
|
|
9
|
+
version: "0.1065.1",
|
|
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,
|
|
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
|
|
2652
|
+
for (const item of items3) {
|
|
2653
2653
|
oldToNew.set(item.id, await insertItem(tx, item, origin));
|
|
2654
2654
|
}
|
|
2655
|
-
for (const item of
|
|
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
|
|
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,
|
|
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 (
|
|
3000
|
+
if (items3.length > 0 && !reloaded.some((i) => i.name === items3[0].name)) {
|
|
3001
3001
|
throw new Error(
|
|
3002
|
-
`backlog migrate: spot-check failed; "${
|
|
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
|
|
3020
|
-
const imported = await importItemsRemapped(orm,
|
|
3021
|
-
await verifyImport(orm, origin,
|
|
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
|
|
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", (
|
|
4315
|
-
buffer +=
|
|
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", (
|
|
4485
|
-
body +=
|
|
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
|
|
4505
|
-
respondJson(res, 200,
|
|
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
|
|
9275
|
+
const items4 = parseFeed(await res.text(), origin);
|
|
9276
9276
|
done2++;
|
|
9277
9277
|
onProgress?.(done2, urls.length);
|
|
9278
|
-
return
|
|
9278
|
+
return items4;
|
|
9279
9279
|
})
|
|
9280
9280
|
);
|
|
9281
|
-
const
|
|
9281
|
+
const items3 = [];
|
|
9282
9282
|
for (const result of results) {
|
|
9283
9283
|
if (result.status === "fulfilled") {
|
|
9284
|
-
|
|
9284
|
+
items3.push(...result.value);
|
|
9285
9285
|
}
|
|
9286
9286
|
}
|
|
9287
|
-
|
|
9287
|
+
items3.sort(
|
|
9288
9288
|
(a, b) => new Date(b.pubDate).getTime() - new Date(a.pubDate).getTime()
|
|
9289
9289
|
);
|
|
9290
|
-
return
|
|
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
|
|
9303
|
-
cache3 = { feedsKey, expires: now + CACHE_TTL_MS4, items:
|
|
9304
|
-
|
|
9305
|
-
if (cache3?.items ===
|
|
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
|
|
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)
|
|
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: [...
|
|
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", (
|
|
10531
|
-
buffer +=
|
|
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", (
|
|
10543
|
-
state.value +=
|
|
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/
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
"
|
|
10556
|
-
|
|
10557
|
-
"
|
|
10558
|
-
"
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
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/
|
|
10582
|
-
function
|
|
10583
|
-
return
|
|
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
|
|
10588
|
-
|
|
10589
|
-
return
|
|
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
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
"
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
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/
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
const trimmed = text20.trim();
|
|
10607
|
-
return trimmed.length <= MAX_TEXT ? trimmed : `${trimmed.slice(0, MAX_TEXT - 1)}\u2026`;
|
|
10608
|
-
}
|
|
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;
|
|
10624
|
+
// src/commands/inbox/createGmailCoverage.ts
|
|
10625
|
+
function blocks(content) {
|
|
10626
|
+
return Array.isArray(content) ? content : [];
|
|
10617
10627
|
}
|
|
10618
|
-
function
|
|
10619
|
-
|
|
10620
|
-
const
|
|
10621
|
-
|
|
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
|
-
|
|
10734
|
-
},
|
|
10735
|
-
|
|
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")
|
|
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(
|
|
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
|
-
...
|
|
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
|
-
|
|
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(
|
|
10849
|
-
const child = spawn2("claude", buildInboxScanArgs(
|
|
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
|
|
13421
|
-
const buf = Buffer.isBuffer(
|
|
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 (
|
|
13872
|
+
return (chunk2) => {
|
|
13841
13873
|
if (isBusy2()) return;
|
|
13842
|
-
const { key, digit } = parseMenuKey(
|
|
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(
|
|
13860
|
-
const n =
|
|
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(
|
|
13865
|
-
const idx =
|
|
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(
|
|
13903
|
+
function renderRestartMenu(items3, selected) {
|
|
13872
13904
|
const lines2 = [chalk13.bold.cyan("assist \u2014 restart menu")];
|
|
13873
|
-
|
|
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(
|
|
13920
|
+
function createMenuState(items3, log2) {
|
|
13889
13921
|
let open = false;
|
|
13890
|
-
let selected = firstEnabledIndex(
|
|
13891
|
-
const render2 = () => log2(renderRestartMenu(
|
|
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(
|
|
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(
|
|
13937
|
+
selected = nextIndex(items3, selected, direction);
|
|
13906
13938
|
render2();
|
|
13907
13939
|
},
|
|
13908
|
-
selectedItem: () =>
|
|
13940
|
+
selectedItem: () => items3[selected],
|
|
13909
13941
|
jumpTo(index3) {
|
|
13910
|
-
const item =
|
|
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:
|
|
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(
|
|
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
|
|
16355
|
-
chunks.push(Buffer.isBuffer(
|
|
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
|
|
17312
|
-
chunks.push(Buffer.isBuffer(
|
|
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,
|
|
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 =
|
|
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,
|
|
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,
|
|
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(
|
|
18568
|
-
if (options2.status) return
|
|
18599
|
+
function filterItems(items3, options2) {
|
|
18600
|
+
if (options2.status) return items3.filter((i) => i.status === options2.status);
|
|
18569
18601
|
if (!options2.all)
|
|
18570
|
-
return
|
|
18571
|
-
return
|
|
18602
|
+
return items3.filter((i) => i.status !== "done" && i.status !== "wontdo");
|
|
18603
|
+
return items3;
|
|
18572
18604
|
}
|
|
18573
|
-
function repoPrefixer(
|
|
18605
|
+
function repoPrefixer(items3, allRepos) {
|
|
18574
18606
|
if (!allRepos) return () => "";
|
|
18575
18607
|
const labels = originDisplayLabels(
|
|
18576
|
-
|
|
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, ...
|
|
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
|
|
18585
|
-
if (
|
|
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(
|
|
18590
|
-
for (const item of
|
|
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(
|
|
19423
|
-
return
|
|
19424
|
-
(i) => i.status === "in-progress" && i.plan && !isLockedByOther(i.id) && !isBlocked(i,
|
|
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(
|
|
19431
|
-
const 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,
|
|
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,
|
|
20701
|
+
function toChoice(item, items3) {
|
|
20670
20702
|
const name = `${typeLabel(item.type)} ${formatItemId(item.id)}: ${item.name}`;
|
|
20671
|
-
return isBlocked(item,
|
|
20703
|
+
return isBlocked(item, items3) ? { name, disabled: chalk81.red("[blocked]") } : { name };
|
|
20672
20704
|
}
|
|
20673
|
-
async function selectItem(todo,
|
|
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,
|
|
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(
|
|
20685
|
-
const resumable = findResumable(
|
|
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(
|
|
20702
|
-
const resumable = pickResumable(
|
|
20733
|
+
async function pickItem(items3, firstPick = false) {
|
|
20734
|
+
const resumable = pickResumable(items3);
|
|
20703
20735
|
if (resumable) return resumable;
|
|
20704
|
-
const unblocked = findUnblockedTodos(
|
|
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 =
|
|
20708
|
-
return selectItem(todo,
|
|
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
|
|
20876
|
+
const items3 = [];
|
|
20845
20877
|
for (const id of numericIds) {
|
|
20846
20878
|
const item = await loadItem(orm, id);
|
|
20847
|
-
if (item)
|
|
20879
|
+
if (item) items3.push(item);
|
|
20848
20880
|
}
|
|
20849
|
-
const [first] =
|
|
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
|
-
...
|
|
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
|
|
20965
|
-
const active =
|
|
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
|
|
21105
|
-
if (
|
|
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
|
-
`${
|
|
21143
|
+
`${items3.length} item${items3.length === 1 ? "" : "s"} matching "${query}":
|
|
21112
21144
|
`
|
|
21113
21145
|
)
|
|
21114
21146
|
);
|
|
21115
|
-
for (const item of
|
|
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
|
|
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
|
-
|
|
21509
|
+
items3.length,
|
|
21478
21510
|
`${flags2.edit} index`
|
|
21479
21511
|
);
|
|
21480
21512
|
if (!parsed.ok) return parsed;
|
|
21481
|
-
|
|
21513
|
+
items3[parsed.index - 1] = textParts.join(" ");
|
|
21482
21514
|
}
|
|
21483
21515
|
if (options2.remove) {
|
|
21484
21516
|
const parsed = parseListIndex(
|
|
21485
21517
|
options2.remove,
|
|
21486
|
-
|
|
21518
|
+
items3.length,
|
|
21487
21519
|
`${flags2.remove} index`
|
|
21488
21520
|
);
|
|
21489
21521
|
if (!parsed.ok) return parsed;
|
|
21490
|
-
|
|
21522
|
+
items3 = items3.filter((_, i) => i !== parsed.index - 1);
|
|
21491
21523
|
}
|
|
21492
21524
|
if (options2.add) {
|
|
21493
|
-
|
|
21525
|
+
items3.push(...options2.add);
|
|
21494
21526
|
}
|
|
21495
|
-
return { ok: true, items:
|
|
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/
|
|
23644
|
-
async function mapAsync(
|
|
23645
|
-
const results = Array.from({ 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 <
|
|
23680
|
+
while (next3 < items3.length) {
|
|
23649
23681
|
const idx = next3++;
|
|
23650
|
-
results[idx] = await fn(
|
|
23682
|
+
results[idx] = await fn(items3[idx]);
|
|
23651
23683
|
}
|
|
23652
23684
|
}
|
|
23653
23685
|
const workers = Array.from(
|
|
23654
|
-
{ length: Math.min(concurrency,
|
|
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
|
|
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
|
-
${
|
|
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
|
|
30174
|
+
const blocks2 = [...groups].flatMap(([group, members]) => [
|
|
30143
30175
|
`### ${group}`,
|
|
30144
30176
|
...renderScreenshotBlock(members)
|
|
30145
30177
|
]);
|
|
30146
30178
|
return [
|
|
30147
30179
|
"## Screenshots",
|
|
30148
|
-
...
|
|
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
|
|
30295
|
+
const items3 = [
|
|
30264
30296
|
{ label: "Repository", value: `${target.owner}/${target.repo}` }
|
|
30265
30297
|
];
|
|
30266
|
-
if (issueType)
|
|
30298
|
+
if (issueType) items3.push({ label: "Type", value: issueType.name });
|
|
30267
30299
|
if (parent)
|
|
30268
|
-
|
|
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
|
-
|
|
30306
|
+
items3.push({
|
|
30275
30307
|
label: "Project",
|
|
30276
30308
|
value: `${project.number} (${project.title})`
|
|
30277
30309
|
});
|
|
30278
30310
|
if (project?.status)
|
|
30279
|
-
|
|
30280
|
-
if (labels?.length)
|
|
30281
|
-
if (milestone)
|
|
30282
|
-
return
|
|
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
|
|
31054
|
-
return { issueId: issue.id, items:
|
|
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:
|
|
31122
|
-
if (
|
|
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
|
|
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
|
-
() =>
|
|
31552
|
+
() => scanInboxWithCoverage(since, tracked)
|
|
31376
31553
|
);
|
|
31377
31554
|
const added = await upsertInboxMessages(orm, messages.map(toRow2));
|
|
31378
31555
|
await writeInboxLastScan(orm, startedAt);
|
|
@@ -32018,8 +32195,8 @@ function spawnInstall(worktreePath, cwd, command, where, onDone) {
|
|
|
32018
32195
|
const child = spawn7(...installInvocation(cwd, command));
|
|
32019
32196
|
trackInstall(worktreePath, child);
|
|
32020
32197
|
let stderr = "";
|
|
32021
|
-
child.stderr?.on("data", (
|
|
32022
|
-
stderr = (stderr +
|
|
32198
|
+
child.stderr?.on("data", (chunk2) => {
|
|
32199
|
+
stderr = (stderr + chunk2.toString()).slice(-STDERR_TAIL);
|
|
32023
32200
|
});
|
|
32024
32201
|
let settled = false;
|
|
32025
32202
|
const settle = (ok, outcome) => {
|
|
@@ -32601,26 +32778,26 @@ async function renderBlock(krokiUrl, source) {
|
|
|
32601
32778
|
// src/commands/mermaid/exportFile.ts
|
|
32602
32779
|
async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
32603
32780
|
const content = readFileSync47(file, "utf8");
|
|
32604
|
-
const
|
|
32781
|
+
const blocks2 = extractMermaidBlocks(content);
|
|
32605
32782
|
const stem = basename21(file, extname4(file));
|
|
32606
32783
|
if (onlyIndex !== void 0) {
|
|
32607
|
-
if (onlyIndex < 1 || onlyIndex >
|
|
32784
|
+
if (onlyIndex < 1 || onlyIndex > blocks2.length) {
|
|
32608
32785
|
console.error(
|
|
32609
32786
|
chalk195.red(
|
|
32610
|
-
`${file}: --index ${onlyIndex} out of range (file has ${
|
|
32787
|
+
`${file}: --index ${onlyIndex} out of range (file has ${blocks2.length} diagram(s))`
|
|
32611
32788
|
)
|
|
32612
32789
|
);
|
|
32613
32790
|
process.exit(1);
|
|
32614
32791
|
}
|
|
32615
32792
|
console.log(
|
|
32616
32793
|
chalk195.gray(
|
|
32617
|
-
`${file} \u2014 rendering diagram ${onlyIndex} of ${
|
|
32794
|
+
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks2.length}`
|
|
32618
32795
|
)
|
|
32619
32796
|
);
|
|
32620
32797
|
} else {
|
|
32621
|
-
console.log(chalk195.gray(`${file} \u2014 ${
|
|
32798
|
+
console.log(chalk195.gray(`${file} \u2014 ${blocks2.length} diagram(s)`));
|
|
32622
32799
|
}
|
|
32623
|
-
for (const [i, source] of
|
|
32800
|
+
for (const [i, source] of blocks2.entries()) {
|
|
32624
32801
|
const idx = i + 1;
|
|
32625
32802
|
if (onlyIndex !== void 0 && idx !== onlyIndex) continue;
|
|
32626
32803
|
const outPath = resolve23(outDir, `${stem}-${idx}.svg`);
|
|
@@ -32711,9 +32888,9 @@ function anchorSource(options2) {
|
|
|
32711
32888
|
function boardId(url) {
|
|
32712
32889
|
return url ? /\/board\/([^/?]+)/.exec(url)?.[1] : void 0;
|
|
32713
32890
|
}
|
|
32714
|
-
function miroSource(
|
|
32715
|
-
const anchor =
|
|
32716
|
-
const ordered = anchor ? [anchor, ...
|
|
32891
|
+
function miroSource(items3, anchorId) {
|
|
32892
|
+
const anchor = items3.find((item) => item.id === anchorId);
|
|
32893
|
+
const ordered = anchor ? [anchor, ...items3] : items3;
|
|
32717
32894
|
return {
|
|
32718
32895
|
board: boardId(ordered.find((item) => item.miro_url)?.miro_url),
|
|
32719
32896
|
frame: ordered.find((item) => item.parent?.id)?.parent?.id
|
|
@@ -32901,12 +33078,12 @@ function toItem(item) {
|
|
|
32901
33078
|
bottom: y + halfHeight
|
|
32902
33079
|
};
|
|
32903
33080
|
}
|
|
32904
|
-
function normaliseItems(
|
|
32905
|
-
const rejected =
|
|
33081
|
+
function normaliseItems(items3) {
|
|
33082
|
+
const rejected = items3.filter(
|
|
32906
33083
|
(item) => item.position?.relativeTo !== frameCoordinates
|
|
32907
33084
|
);
|
|
32908
33085
|
if (rejected.length > 0) throw coordinateSpaceError(rejected);
|
|
32909
|
-
return
|
|
33086
|
+
return items3.map(toItem);
|
|
32910
33087
|
}
|
|
32911
33088
|
|
|
32912
33089
|
// src/commands/miro/saveMiroExtract.ts
|
|
@@ -32969,21 +33146,21 @@ function isBox(item) {
|
|
|
32969
33146
|
}
|
|
32970
33147
|
|
|
32971
33148
|
// src/commands/miro/encodeMiroBoardPreview.ts
|
|
32972
|
-
function encodeMiroBoardPreview(
|
|
32973
|
-
const preview = { boxes:
|
|
33149
|
+
function encodeMiroBoardPreview(items3) {
|
|
33150
|
+
const preview = { boxes: items3.filter(isBox) };
|
|
32974
33151
|
return JSON.stringify(preview);
|
|
32975
33152
|
}
|
|
32976
33153
|
|
|
32977
33154
|
// src/commands/miro/pickAnchors.ts
|
|
32978
33155
|
var skipAdvice = "Re-run with --top-left <id|link> --bottom-right <id|link> to skip the picker.";
|
|
32979
|
-
async function pickAnchors(sessionId2,
|
|
33156
|
+
async function pickAnchors(sessionId2, items3) {
|
|
32980
33157
|
const decision = await awaitPreviewApproval(
|
|
32981
33158
|
"Miro anchor selection",
|
|
32982
33159
|
{
|
|
32983
33160
|
sessionId: sessionId2,
|
|
32984
33161
|
requestId: randomUUID19(),
|
|
32985
33162
|
title: "Pick the top-left then the bottom-right box",
|
|
32986
|
-
body: encodeMiroBoardPreview(
|
|
33163
|
+
body: encodeMiroBoardPreview(items3),
|
|
32987
33164
|
prNumber: null,
|
|
32988
33165
|
kind: "miro-board"
|
|
32989
33166
|
},
|
|
@@ -33028,14 +33205,14 @@ function parsePages(raw, file) {
|
|
|
33028
33205
|
return Array.isArray(parsed) ? parsed.map(toPage) : [toPage(parsed)];
|
|
33029
33206
|
}
|
|
33030
33207
|
function readMiroItems(file) {
|
|
33031
|
-
const
|
|
33208
|
+
const items3 = parsePages(readFileSync49(file, "utf8"), file).flatMap(
|
|
33032
33209
|
(page) => page.data ?? []
|
|
33033
33210
|
);
|
|
33034
|
-
if (
|
|
33211
|
+
if (items3.length === 0)
|
|
33035
33212
|
throw new MiroExtractError(
|
|
33036
33213
|
`No board items found in ${file}. Dump the frame with board_list_items, paging until has_more is false.`
|
|
33037
33214
|
);
|
|
33038
|
-
return
|
|
33215
|
+
return items3;
|
|
33039
33216
|
}
|
|
33040
33217
|
|
|
33041
33218
|
// src/commands/miro/resolveExtractOptions.ts
|
|
@@ -33122,8 +33299,8 @@ function resolveExtractOptions(name, options2, paths) {
|
|
|
33122
33299
|
}
|
|
33123
33300
|
|
|
33124
33301
|
// src/commands/miro/selectBoxes.ts
|
|
33125
|
-
function findAnchor(
|
|
33126
|
-
const anchor =
|
|
33302
|
+
function findAnchor(items3, id) {
|
|
33303
|
+
const anchor = items3.find((item) => item.id === id);
|
|
33127
33304
|
if (!anchor)
|
|
33128
33305
|
throw new MiroExtractError(
|
|
33129
33306
|
`No item with id ${id} in the supplied items. Re-dump the frame so the anchor is included, then try again.`
|
|
@@ -33135,16 +33312,16 @@ function centreInside(rect, item) {
|
|
|
33135
33312
|
const y = (item.top + item.bottom) / 2;
|
|
33136
33313
|
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
|
33137
33314
|
}
|
|
33138
|
-
function selectBoxes(
|
|
33139
|
-
const topLeft = findAnchor(
|
|
33140
|
-
const bottomRight = findAnchor(
|
|
33315
|
+
function selectBoxes(items3, topLeftId, bottomRightId) {
|
|
33316
|
+
const topLeft = findAnchor(items3, topLeftId);
|
|
33317
|
+
const bottomRight = findAnchor(items3, bottomRightId);
|
|
33141
33318
|
const rect = {
|
|
33142
33319
|
left: topLeft.left,
|
|
33143
33320
|
top: topLeft.top,
|
|
33144
33321
|
right: bottomRight.right,
|
|
33145
33322
|
bottom: bottomRight.bottom
|
|
33146
33323
|
};
|
|
33147
|
-
const boxes =
|
|
33324
|
+
const boxes = items3.filter((item) => isBox(item) && centreInside(rect, item)).sort((a, b) => a.left - b.left || a.top - b.top);
|
|
33148
33325
|
return { rect, boxes };
|
|
33149
33326
|
}
|
|
33150
33327
|
|
|
@@ -33161,9 +33338,9 @@ async function runExtract(name, options2, paths = {}) {
|
|
|
33161
33338
|
const source = anchorSource(resolved);
|
|
33162
33339
|
const itemsFile = requireItems(resolved.items);
|
|
33163
33340
|
const raw = readMiroItems(itemsFile);
|
|
33164
|
-
const
|
|
33165
|
-
const [topLeft, bottomRight] = source.pick ? await pickAnchors(source.sessionId,
|
|
33166
|
-
const selection = selectBoxes(
|
|
33341
|
+
const items3 = normaliseItems(raw);
|
|
33342
|
+
const [topLeft, bottomRight] = source.pick ? await pickAnchors(source.sessionId, items3) : [source.topLeft, source.bottomRight];
|
|
33343
|
+
const selection = selectBoxes(items3, topLeft, bottomRight);
|
|
33167
33344
|
const board = boardSource(raw, topLeft, resolved);
|
|
33168
33345
|
emitExtract(
|
|
33169
33346
|
resolved.out,
|
|
@@ -33249,8 +33426,8 @@ function parseNetcapEntry(body) {
|
|
|
33249
33426
|
// src/commands/netcap/handleNetcapPost.ts
|
|
33250
33427
|
function handleNetcapPost(req, res, options2) {
|
|
33251
33428
|
let body = "";
|
|
33252
|
-
req.on("data", (
|
|
33253
|
-
body +=
|
|
33429
|
+
req.on("data", (chunk2) => {
|
|
33430
|
+
body += chunk2;
|
|
33254
33431
|
});
|
|
33255
33432
|
req.on("end", () => {
|
|
33256
33433
|
const entry = parseNetcapEntry(body);
|
|
@@ -36527,9 +36704,9 @@ function opExec(args) {
|
|
|
36527
36704
|
}).trim();
|
|
36528
36705
|
}
|
|
36529
36706
|
function searchItems(search2) {
|
|
36530
|
-
let
|
|
36707
|
+
let items3;
|
|
36531
36708
|
try {
|
|
36532
|
-
|
|
36709
|
+
items3 = JSON.parse(opExec("item list --format=json"));
|
|
36533
36710
|
} catch {
|
|
36534
36711
|
console.error(
|
|
36535
36712
|
chalk211.red(
|
|
@@ -36539,7 +36716,7 @@ function searchItems(search2) {
|
|
|
36539
36716
|
process.exit(1);
|
|
36540
36717
|
}
|
|
36541
36718
|
const lower = search2.toLowerCase();
|
|
36542
|
-
return
|
|
36719
|
+
return items3.filter((i) => i.title.toLowerCase().includes(lower));
|
|
36543
36720
|
}
|
|
36544
36721
|
function getItemFields(itemId2) {
|
|
36545
36722
|
try {
|
|
@@ -36563,14 +36740,14 @@ async function selectOpSecret(searchTerm) {
|
|
|
36563
36740
|
name: "search",
|
|
36564
36741
|
message: "Search 1Password for API key item:"
|
|
36565
36742
|
}).run();
|
|
36566
|
-
const
|
|
36567
|
-
if (
|
|
36743
|
+
const items3 = searchItems(search2);
|
|
36744
|
+
if (items3.length === 0) {
|
|
36568
36745
|
console.error(chalk212.red(`No items found matching "${search2}".`));
|
|
36569
36746
|
process.exit(1);
|
|
36570
36747
|
}
|
|
36571
36748
|
const itemId2 = await selectOne(
|
|
36572
36749
|
"Select item:",
|
|
36573
|
-
|
|
36750
|
+
items3.map((i) => ({ name: `${i.title} (${i.vault.name})`, value: i.id }))
|
|
36574
36751
|
);
|
|
36575
36752
|
const fields = getItemFields(itemId2);
|
|
36576
36753
|
if (fields.length === 0) {
|
|
@@ -40942,14 +41119,14 @@ function fetchHighLevelFiles(prNumber, repo) {
|
|
|
40942
41119
|
import { execSync as execSync57 } from "child_process";
|
|
40943
41120
|
|
|
40944
41121
|
// src/commands/review/highLevel/waitForMergeable.ts
|
|
40945
|
-
var
|
|
41122
|
+
var MAX_ATTEMPTS2 = 5;
|
|
40946
41123
|
var DELAY_MS = 2e3;
|
|
40947
41124
|
function sleepSync2(ms) {
|
|
40948
41125
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
40949
41126
|
}
|
|
40950
41127
|
function waitForMergeable(initial, refetch, delayMs = DELAY_MS) {
|
|
40951
41128
|
let mergeable = initial;
|
|
40952
|
-
for (let attempt2 = 1; mergeable === "UNKNOWN" && attempt2 <
|
|
41129
|
+
for (let attempt2 = 1; mergeable === "UNKNOWN" && attempt2 < MAX_ATTEMPTS2; attempt2++) {
|
|
40953
41130
|
sleepSync2(delayMs);
|
|
40954
41131
|
mergeable = refetch();
|
|
40955
41132
|
}
|
|
@@ -41739,13 +41916,13 @@ function formatItem(item) {
|
|
|
41739
41916
|
const comment3 = item.comment.replace(/\n/g, "\n ");
|
|
41740
41917
|
return `- ${statusMarkers[item.status]} **${item.title}** \u2014 ${comment3}`;
|
|
41741
41918
|
}
|
|
41742
|
-
function findings(
|
|
41743
|
-
const lines2 =
|
|
41919
|
+
function findings(items3) {
|
|
41920
|
+
const lines2 = items3.map(formatItem).filter((line) => line !== void 0);
|
|
41744
41921
|
return lines2.length > 0 ? lines2.join("\n") : void 0;
|
|
41745
41922
|
}
|
|
41746
|
-
function sliceSections(
|
|
41923
|
+
function sliceSections(items3) {
|
|
41747
41924
|
const bySlice = /* @__PURE__ */ new Map();
|
|
41748
|
-
for (const item of
|
|
41925
|
+
for (const item of items3)
|
|
41749
41926
|
if (item.slice !== void 0)
|
|
41750
41927
|
bySlice.set(item.slice, [...bySlice.get(item.slice) ?? [], item]);
|
|
41751
41928
|
return [...bySlice].flatMap(([number, sliceItems]) => {
|
|
@@ -41757,11 +41934,11 @@ function sliceSections(items2) {
|
|
|
41757
41934
|
${lines2}`];
|
|
41758
41935
|
});
|
|
41759
41936
|
}
|
|
41760
|
-
function formatHighLevelReviewBody(
|
|
41937
|
+
function formatHighLevelReviewBody(items3, reviewComments2 = []) {
|
|
41761
41938
|
const sections = [];
|
|
41762
|
-
const prWide = findings(
|
|
41939
|
+
const prWide = findings(items3.filter((item) => item.slice === void 0));
|
|
41763
41940
|
if (prWide) sections.push(prWide);
|
|
41764
|
-
sections.push(...sliceSections(
|
|
41941
|
+
sections.push(...sliceSections(items3));
|
|
41765
41942
|
if (reviewComments2.length > 0)
|
|
41766
41943
|
sections.push(
|
|
41767
41944
|
`**Comments**
|
|
@@ -43105,8 +43282,8 @@ import { spawn as spawn9 } from "child_process";
|
|
|
43105
43282
|
// src/commands/review/attachStdoutTail.ts
|
|
43106
43283
|
function attachStdoutTail(child, maxBytes = 8192) {
|
|
43107
43284
|
const state = { value: "" };
|
|
43108
|
-
child.stdout?.on("data", (
|
|
43109
|
-
state.value +=
|
|
43285
|
+
child.stdout?.on("data", (chunk2) => {
|
|
43286
|
+
state.value += chunk2.toString("utf8");
|
|
43110
43287
|
if (state.value.length > maxBytes) {
|
|
43111
43288
|
state.value = state.value.slice(state.value.length - maxBytes);
|
|
43112
43289
|
}
|
|
@@ -43820,12 +43997,12 @@ function formatThread(thread) {
|
|
|
43820
43997
|
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
43998
|
function formatPriorComments(comments3) {
|
|
43822
43999
|
if (comments3.length === 0) return "";
|
|
43823
|
-
const
|
|
44000
|
+
const blocks2 = groupIntoThreads(comments3).map(formatThread);
|
|
43824
44001
|
return `## Prior review comments
|
|
43825
44002
|
|
|
43826
44003
|
${INTRO}
|
|
43827
44004
|
|
|
43828
|
-
${
|
|
44005
|
+
${blocks2.join("\n\n")}`;
|
|
43829
44006
|
}
|
|
43830
44007
|
|
|
43831
44008
|
// src/commands/review/buildRequest.ts
|
|
@@ -51297,8 +51474,8 @@ function runUpdateLap(cwd, onOutput) {
|
|
|
51297
51474
|
child.kill();
|
|
51298
51475
|
};
|
|
51299
51476
|
process.on("exit", killWithDaemon);
|
|
51300
|
-
child.stdout.on("data", (
|
|
51301
|
-
child.stderr.on("data", (
|
|
51477
|
+
child.stdout.on("data", (chunk2) => onOutput(chunk2.toString()));
|
|
51478
|
+
child.stderr.on("data", (chunk2) => onOutput(chunk2.toString()));
|
|
51302
51479
|
child.on("close", (code, signal) => {
|
|
51303
51480
|
process.off("exit", killWithDaemon);
|
|
51304
51481
|
resolve34({ code, signal });
|
|
@@ -52196,7 +52373,7 @@ function autoApprovePreview(sessions, waiters, notify2, session) {
|
|
|
52196
52373
|
// src/commands/sessions/daemon/parsePreviewMetadata.ts
|
|
52197
52374
|
function parsePreviewMetadata(value) {
|
|
52198
52375
|
if (!Array.isArray(value)) return void 0;
|
|
52199
|
-
const
|
|
52376
|
+
const items3 = value.flatMap((entry) => {
|
|
52200
52377
|
const {
|
|
52201
52378
|
label,
|
|
52202
52379
|
value: text20,
|
|
@@ -52207,7 +52384,7 @@ function parsePreviewMetadata(value) {
|
|
|
52207
52384
|
typeof url === "string" ? { label, value: text20, url } : { label, value: text20 }
|
|
52208
52385
|
];
|
|
52209
52386
|
});
|
|
52210
|
-
return
|
|
52387
|
+
return items3.length > 0 ? items3 : void 0;
|
|
52211
52388
|
}
|
|
52212
52389
|
|
|
52213
52390
|
// src/commands/sessions/daemon/buildPrPreview.ts
|
|
@@ -52874,13 +53051,13 @@ async function touchedSince(file, sinceMs) {
|
|
|
52874
53051
|
|
|
52875
53052
|
// src/commands/sessions/daemon/bindCodexSession.ts
|
|
52876
53053
|
var POLL_MS6 = 1e3;
|
|
52877
|
-
var
|
|
53054
|
+
var MAX_ATTEMPTS3 = 120;
|
|
52878
53055
|
var START_SLACK_MS = 5e3;
|
|
52879
53056
|
function bindCodexSession(session, notify2) {
|
|
52880
53057
|
const cwd = session.cwd;
|
|
52881
53058
|
if (session.harness !== "codex" || !cwd || session.harnessSessionId) return;
|
|
52882
53059
|
const since = session.startedAt - START_SLACK_MS;
|
|
52883
|
-
let attemptsLeft =
|
|
53060
|
+
let attemptsLeft = MAX_ATTEMPTS3;
|
|
52884
53061
|
const schedule = () => setTimeout(() => void poll(), POLL_MS6).unref();
|
|
52885
53062
|
const poll = async () => {
|
|
52886
53063
|
if (session.harnessSessionId) return;
|
|
@@ -57009,7 +57186,7 @@ function findTitleMatch(title, query) {
|
|
|
57009
57186
|
}
|
|
57010
57187
|
|
|
57011
57188
|
// src/commands/sessions/daemon/historySearch/searchHistory.ts
|
|
57012
|
-
var
|
|
57189
|
+
var BATCH_SIZE2 = 16;
|
|
57013
57190
|
var MAX_RESULTS2 = 100;
|
|
57014
57191
|
function inRepo(cwd) {
|
|
57015
57192
|
const selectedKey = repoGroupForCwd(cwd)?.origin || cwd;
|
|
@@ -57031,9 +57208,9 @@ async function matchBatch(batch, query) {
|
|
|
57031
57208
|
async function searchHistory(cwd, query) {
|
|
57032
57209
|
const candidates = (await discoverHistoryEntries()).filter(inRepo(cwd));
|
|
57033
57210
|
const hits = [];
|
|
57034
|
-
for (let i = 0; i < candidates.length && hits.length < MAX_RESULTS2; i +=
|
|
57211
|
+
for (let i = 0; i < candidates.length && hits.length < MAX_RESULTS2; i += BATCH_SIZE2)
|
|
57035
57212
|
hits.push(
|
|
57036
|
-
...await matchBatch(candidates.slice(i, i +
|
|
57213
|
+
...await matchBatch(candidates.slice(i, i + BATCH_SIZE2), query)
|
|
57037
57214
|
);
|
|
57038
57215
|
return withRepoGroups(hits.slice(0, MAX_RESULTS2));
|
|
57039
57216
|
}
|