@dev.fast/whiteboard 0.2.5-preview.20261015.119 → 0.2.5-preview.20261016.121

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.
Files changed (69) hide show
  1. package/dist/{account-alias-C1ixP6bt.js → account-alias-CwNaMOwU.js} +372 -85
  2. package/dist/agent-cli-NWQPsL0W.js +2 -0
  3. package/dist/{agent-cli-CPSnWc9V.js → agent-cli-S0bt9I7V.js} +7 -7
  4. package/dist/{agent-client-Dogh8I83.js → agent-client-DjXQy6CL.js} +5 -6
  5. package/dist/{authoring-tools-CtsslOEf.js → authoring-tools-CjFAGHBa.js} +5 -4
  6. package/dist/{background-server-BKR_lpYb.js → background-server-CVL7QpsL.js} +1 -1
  7. package/dist/{background-server-DJT0CnYH.js → background-server-ONy-xKJ1.js} +4 -4
  8. package/dist/build-info.json +1 -1
  9. package/dist/{cli-Df6p-C19.js → cli-Cko4zfif.js} +1 -1
  10. package/dist/{cli-runner-ZktCwlLk.js → cli-runner-BhBnAC_R.js} +51 -187
  11. package/dist/cli.js +2 -2
  12. package/dist/{client-_ltX1mah.js → client-CLqKkzOc.js} +4 -4
  13. package/dist/fuzzy-match-DFPKdSLR.js +335 -0
  14. package/dist/{headless-host-Pj2xfGAo.js → headless-host-BNF-TR3x.js} +1 -1
  15. package/dist/{headless-host-ZNZ_6ZRo.js → headless-host-mg9sQG6H.js} +53 -345
  16. package/dist/{local-data-D_9S--yI.js → local-data-DN-A5p0K.js} +57 -415
  17. package/dist/{mcp-Blb7rzGw.js → mcp-BY4ExeMQ.js} +3 -3
  18. package/dist/{package-paths-BsuI4WUf.js → package-paths-jMg6JxDP.js} +1 -1
  19. package/dist/profile-BBw-jMW3.js +2 -0
  20. package/dist/{profile-CKSB6UDi.js → profile-Dm6irjbg.js} +2 -2
  21. package/dist/{remote-attach-CiOwonJ3.js → remote-attach-DJxW9402.js} +4 -4
  22. package/dist/{remote-extensions-D_4DSOhO.js → remote-extensions-BCAbQZTv.js} +2 -2
  23. package/dist/{remote-extensions-ByiuSl1D.js → remote-extensions-Cf3L-ZGG.js} +1 -1
  24. package/dist/{remote-language-server-BQjBk81F.js → remote-language-server-CGsCaqro.js} +4 -4
  25. package/dist/{remote-uninstall-pzHb-Hfd.js → remote-uninstall-DYmNOetF.js} +5 -5
  26. package/dist/{request-origin-C-V9f3Fr.js → request-origin-D1RNVSeK.js} +2 -7
  27. package/dist/{review-app-launcher-S2FZBY4W.js → review-app-launcher-i1hmxOZA.js} +2 -2
  28. package/dist/{review-home-paths-zwevIq4I.js → review-home-paths-Lc02WFuX.js} +1 -1
  29. package/dist/{review-telemetry-9ceqh4wz.js → review-telemetry-DnQNwgR1.js} +4 -4
  30. package/dist/server/desktop-host.js +99 -445
  31. package/dist/{server-discovery-CqRxbsER.js → server-discovery-DVqrcIDT.js} +2 -2
  32. package/dist/sharing/index.d.ts +17 -13
  33. package/dist/sharing/index.js +1 -1
  34. package/dist/{src-HnIPjtjx.js → src-DZG1xAqW.js} +4 -1
  35. package/dist/{stored-document-migration-DenDEYdI.js → stored-document-migration-DLBhkSfp.js} +46 -6
  36. package/dist/thread-state-CaQ2lGdj.js +400 -0
  37. package/dist/{tool-failure-aSYcHDxP.js → tool-failure-CVJrfi5s.js} +1 -1
  38. package/package.json +3 -3
  39. package/src/agent-connect.ts +29 -106
  40. package/src/cli-install.ts +13 -11
  41. package/src/cli-runner.ts +51 -24
  42. package/src/connect-prompts.ts +135 -71
  43. package/src/review-api/README.md +1 -1
  44. package/src/review-api/azure-devops-provider.ts +4 -0
  45. package/src/review-api/blocks/definition.ts +3 -1
  46. package/src/review-api/blocks/index.ts +19 -0
  47. package/src/review-api/blocks/sequence.ts +80 -2
  48. package/src/review-api/comparison-coverage.ts +0 -13
  49. package/src/review-api/component-reference.ts +2 -1
  50. package/src/review-api/document-text.ts +7 -2
  51. package/src/review-api/document.ts +13 -9
  52. package/src/review-api/github-provider.ts +21 -3
  53. package/src/review-api/http.ts +22 -41
  54. package/src/review-api/local-data.ts +22 -27
  55. package/src/review-api/pull-request.ts +2 -0
  56. package/src/review-api/review-progress.ts +6 -8
  57. package/src/review-api/store.ts +36 -25
  58. package/src/review-stack.ts +3 -2
  59. package/src/server/review-gateway-hosts.ts +8 -1
  60. package/src/server/review-gateway-list.ts +4 -10
  61. package/src/server/review-gateway-memory.ts +6 -19
  62. package/src/server/review-gateway-streams.ts +32 -46
  63. package/src/sharing/import.ts +2 -2
  64. package/src/ui-telemetry-events.ts +1 -2
  65. package/dist/agent-cli-CGapivA1.js +0 -2
  66. package/dist/fs-utils-BMPLt0cr.js +0 -22
  67. package/dist/fuzzy-match-BoAmcyak.js +0 -30
  68. package/dist/profile-BUoTujrK.js +0 -2
  69. package/src/connect-agents.ts +0 -285
@@ -1,332 +1,39 @@
1
1
  import { d as git, r as defaultBranch } from "./src-BMPuxWv4.js";
2
2
  import { c as jsonString, m as isStringValue, n as isJsonObject, p as isObjectValue, u as parseJsonText } from "./src-X9phtB2j.js";
3
- import { a as sharedReviewId, c as verifyShareRepository, d as StreamLimitError, f as readBoundedStream, l as exportShare, m as shareIdSchema, n as ShareClient, p as parseShareLink, r as SharePreflightError, s as readShareRepository, t as ShareAuthError, u as validateShareSources } from "./client-_ltX1mah.js";
4
- import { a as inspectSnapshot, b as diffrMissingError, c as askAgentIds, d as askPicksSchema, f as askQuestionSchema, i as commandSchema, l as askChoiceKinds, m as selectionMarkdown, p as AgentSelectionSchema, r as SCRATCHPAD_ID, s as applyAskChange, u as askPermissionsSchema, v as invalidateStructuralComparisons, y as diffrExecutable } from "./local-data-D_9S--yI.js";
5
- import { A as reviewDiffrSummarizerInputSchema, D as ReviewOnboardingRunRequestSchema, a as parseReviewVerbRequest, g as REVIEW_HOST_HEADER, i as parseReviewDesktopVerbResult, j as decodeStructuralDiffEvent } from "./src-HnIPjtjx.js";
6
- import { B as TraceStorageDeniedError, D as listReviewTraceSessions, I as isTraceStorageConfigured, O as loadReviewAgentTrace, R as resolveTraceStorage, T as traceMachineEnabled, at as clearStoreAuth, ct as runStoreLogin, it as DEFAULT_STORE_ORIGIN, ot as openUrlInBrowser, st as readStoreAuth, tt as shellQuote, z as selectTraceStorage } from "./review-home-paths-zwevIq4I.js";
7
- import { $ as subtractIntervals, A as UNCATEGORIZED_LENS_ID, E as selectionReferences, G as resolveDiffSelection, H as anchorSelection, K as selectionKey, L as fileLineRangeSchema, P as lensSelections, Q as scopedCoverage, U as comparisonKey, W as formatAnchor, X as emptyCoverage, Y as coverageSources, et as unionIntervals, h as elements, u as anchorPins } from "./stored-document-migration-DenDEYdI.js";
3
+ import { a as sharedReviewId, c as verifyShareRepository, d as StreamLimitError, f as readBoundedStream, l as exportShare, m as shareIdSchema, n as ShareClient, p as parseShareLink, r as SharePreflightError, s as readShareRepository, t as ShareAuthError, u as validateShareSources } from "./client-CLqKkzOc.js";
4
+ import { a as inspectSnapshot, d as diffrExecutable, f as diffrMissingError, i as commandSchema, r as SCRATCHPAD_ID, u as invalidateStructuralComparisons } from "./local-data-DN-A5p0K.js";
5
+ import { A as reviewDiffrSummarizerInputSchema, D as ReviewOnboardingRunRequestSchema, a as parseReviewVerbRequest, g as REVIEW_HOST_HEADER, i as parseReviewDesktopVerbResult, j as decodeStructuralDiffEvent } from "./src-DZG1xAqW.js";
6
+ import { B as TraceStorageDeniedError, D as listReviewTraceSessions, I as isTraceStorageConfigured, O as loadReviewAgentTrace, R as resolveTraceStorage, T as traceMachineEnabled, at as openUrlInBrowser, et as shellQuote, it as clearStoreAuth, ot as readStoreAuth, rt as DEFAULT_STORE_ORIGIN, st as runStoreLogin, z as selectTraceStorage } from "./review-home-paths-Lc02WFuX.js";
7
+ import { E as selectionReferences, G as comparisonKey, I as lensSelections, J as selectionKey, K as formatAnchor, M as UNCATEGORIZED_LENS_ID, Q as emptyCoverage, W as anchorSelection, Z as coverageSources, et as scopedCoverage, h as elements, j as stepSources, nt as unionIntervals, q as resolveDiffSelection, tt as subtractIntervals, u as anchorPins, z as fileLineRangeSchema } from "./stored-document-migration-DLBhkSfp.js";
8
8
  import { t as ReviewInputError } from "./input-error-OLgB_h31.js";
9
9
  import { A as withFileLock, I as writePrivateJsonAtomic, M as devReviewHome, h as TraceConfigurationError, i as isS3MockMode } from "./s3-config-DDWWMh5x.js";
10
10
  import { t as errorMessage } from "./error-message-OtiDonty.js";
11
- import { i as readReviewPackageVersion, n as readBuildCommit, t as findReviewPackageRoot } from "./package-paths-BsuI4WUf.js";
12
- import { i as readReviewServerDiscovery, n as desktopOwnsHome, o as reviewServerDiscoveryPath, p as desktopUsesHome, r as headlessServerLockPath, t as DESKTOP_TAKEOVER_SIGNAL } from "./server-discovery-CqRxbsER.js";
13
- import { t as openReviewProfile } from "./profile-CKSB6UDi.js";
14
- import { a as REVIEW_APP_SESSION_ID_HEADER, c as sanitizeUiTelemetryEvent, i as BUNDLE_FRAME_PATTERN, l as cleanTelemetryText, r as reviewRequestOrigin, s as isReportableCleanedMessage } from "./request-origin-C-V9f3Fr.js";
15
- import { a as scratchpadAvailable, c as readQuerySchemas, i as renderInstructions, o as inspectQuerySchema, r as instructionsQuerySchema, s as queryAnchor, t as authoringTools } from "./authoring-tools-CtsslOEf.js";
16
- import { t as fuzzyRank } from "./fuzzy-match-BoAmcyak.js";
17
- import { a as headlessServerOwner, c as stopBackgroundServer } from "./background-server-DJT0CnYH.js";
18
- import { createRequire } from "node:module";
11
+ import { i as readReviewPackageVersion, n as readBuildCommit, t as findReviewPackageRoot } from "./package-paths-jMg6JxDP.js";
12
+ import { i as readReviewServerDiscovery, n as desktopOwnsHome, o as reviewServerDiscoveryPath, p as desktopUsesHome, r as headlessServerLockPath, t as DESKTOP_TAKEOVER_SIGNAL } from "./server-discovery-DVqrcIDT.js";
13
+ import { c as askPicksSchema, d as selectionMarkdown, l as askQuestionSchema, n as askAgentIds, r as askChoiceKinds, s as askPermissionsSchema, t as applyAskChange, u as AgentSelectionSchema } from "./thread-state-CaQ2lGdj.js";
14
+ import { t as openReviewProfile } from "./profile-Dm6irjbg.js";
15
+ import { a as REVIEW_APP_SESSION_ID_HEADER, c as sanitizeUiTelemetryEvent, i as BUNDLE_FRAME_PATTERN, l as cleanTelemetryText, r as reviewRequestOrigin, s as isReportableCleanedMessage } from "./request-origin-D1RNVSeK.js";
16
+ import { a as defaultAskPermissions, c as launchAskAgent, i as askAgents, n as askAgentSettings, o as detectAskAgents, r as askAgentTakesMcp, t as fuzzyRank } from "./fuzzy-match-DFPKdSLR.js";
17
+ import { a as scratchpadAvailable, c as readQuerySchemas, i as renderInstructions, o as inspectQuerySchema, r as instructionsQuerySchema, s as queryAnchor, t as authoringTools } from "./authoring-tools-CjFAGHBa.js";
18
+ import { a as headlessServerOwner, c as stopBackgroundServer } from "./background-server-ONy-xKJ1.js";
19
19
  import crypto$1, { createHash, randomBytes, randomUUID } from "node:crypto";
20
20
  import { z } from "zod";
21
- import { constants, existsSync, mkdirSync, writeFileSync } from "node:fs";
22
- import { access, chmod, mkdir, mkdtemp, readFile, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
21
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
22
+ import { mkdir, mkdtemp, readFile, realpath, rm, stat, writeFile } from "node:fs/promises";
23
23
  import path, { join, posix } from "node:path";
24
- import os, { homedir, tmpdir } from "node:os";
24
+ import os, { tmpdir } from "node:os";
25
25
  import { execFile, spawn } from "node:child_process";
26
26
  import { promisify } from "node:util";
27
27
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
28
28
  import { fileURLToPath, pathToFileURL } from "node:url";
29
- import { Readable, Writable } from "node:stream";
29
+ import { Writable } from "node:stream";
30
30
  import { createServer } from "node:http";
31
- import { PROTOCOL_VERSION, RequestError, client, methods, ndJsonStream } from "@agentclientprotocol/sdk";
31
+ import { PROTOCOL_VERSION, RequestError, client, methods } from "@agentclientprotocol/sdk";
32
32
  import { Hono } from "hono";
33
33
  import { stringify } from "smol-toml";
34
34
  import { getRequestListener } from "@hono/node-server";
35
35
  import { streamSSE } from "hono/streaming";
36
36
  import { once } from "node:events";
37
- //#region src/ask/pi-mcp.ts
38
- /**
39
- * pi-acp keeps the MCP servers a session is given without passing them to
40
- * Pi. Pi 0.99.0 and later take them from an extension, so Ask starts Pi
41
- * through a wrapper that loads one, registering the servers for that session
42
- * only. Older Pi, and Windows, which would need a different wrapper, answer
43
- * without them.
44
- */
45
- /** The first Pi with `pi.registerMcpServer()`. */
46
- const PI_MCP_VERSION = [
47
- 0,
48
- 99,
49
- 0
50
- ];
51
- /** How long a version read is trusted: a session's first prompt and its
52
- * launch ask moments apart, and an update during a review is seen soon. */
53
- const VERSION_TTL_MS = 3e4;
54
- const SERVERS_ENV = "WHITEBOARD_ASK_MCP";
55
- const PI_ENV = "WHITEBOARD_ASK_PI";
56
- const EXTENSION_ENV = "WHITEBOARD_ASK_PI_EXTENSION";
57
- const EXTENSION = `// Managed by Whiteboard: gives a Pi session that Ask starts the MCP servers
58
- // Whiteboard hands it. Do not edit.
59
- export default function (pi: {
60
- registerMcpServer(name: string, config: object): void;
61
- }) {
62
- const servers = JSON.parse(process.env.${SERVERS_ENV} ?? "{}");
63
-
64
- for (const [name, config] of Object.entries(servers))
65
- pi.registerMcpServer(name, config as object);
66
- }
67
- `;
68
- const WRAPPER = `#!/bin/sh
69
- # Managed by Whiteboard: starts Pi for Ask with Whiteboard's extension.
70
- exec "$${PI_ENV}" -e "$${EXTENSION_ENV}" "$@"
71
- `;
72
- const versions = /* @__PURE__ */ new Map();
73
- function piVersion(executable, env) {
74
- const cached = versions.get(executable);
75
- if (cached && Date.now() - cached.read < VERSION_TTL_MS) return cached.version;
76
- const version = promisify(execFile)(executable, ["--version"], {
77
- env,
78
- timeout: 5e3
79
- }).then(({ stdout }) => /(\d+)\.(\d+)\.(\d+)/u.exec(stdout)?.slice(1).map(Number)).catch(() => void 0);
80
- versions.set(executable, {
81
- read: Date.now(),
82
- version
83
- });
84
- return version;
85
- }
86
- /** Whether this Pi can be given MCP servers. */
87
- async function piTakesMcp(executable, env) {
88
- if (process.platform === "win32") return false;
89
- const version = await piVersion(executable, env);
90
- if (!version) return false;
91
- for (const [index, least] of PI_MCP_VERSION.entries()) {
92
- const part = version[index] ?? 0;
93
- if (part !== least) return part > least;
94
- }
95
- return true;
96
- }
97
- /** Writes a file only when it changed, replacing it whole, since another
98
- * Ask session may be running it. */
99
- async function keep(file, content, mode) {
100
- if (await readFile(file, "utf8").catch(() => void 0) === content) return;
101
- const staged = `${file}.${process.pid}.tmp`;
102
- await writeFile(staged, content, { mode });
103
- await chmod(staged, mode);
104
- await rename(staged, file);
105
- }
106
- function piServers(servers) {
107
- const piServers = {};
108
- const record = (pairs) => Object.fromEntries(pairs.map(({ name, value }) => [name, value]));
109
- for (const server of servers) if ("command" in server) piServers[server.name] = {
110
- command: server.command,
111
- args: server.args,
112
- env: record(server.env),
113
- exposure: "direct"
114
- };
115
- else if (server.type === "http") piServers[server.name] = {
116
- url: server.url,
117
- headers: record(server.headers),
118
- exposure: "direct"
119
- };
120
- return piServers;
121
- }
122
- /** The command pi-acp runs in place of Pi: Pi with the extension that
123
- * registers `servers`, which go to it in `env`. */
124
- async function piWithMcp(executable, servers, env) {
125
- const directory = path.join(devReviewHome(), "ask", "pi");
126
- const extension = path.join(directory, "whiteboard-mcp.ts");
127
- const wrapper = path.join(directory, "pi");
128
- await mkdir(directory, { recursive: true });
129
- await keep(extension, EXTENSION, 420);
130
- await keep(wrapper, WRAPPER, 493);
131
- env[PI_ENV] = executable;
132
- env[EXTENSION_ENV] = extension;
133
- env[SERVERS_ENV] = JSON.stringify(piServers(servers));
134
- return wrapper;
135
- }
136
- //#endregion
137
- //#region src/ask/agents.ts
138
- /** The mode, session settings and process settings an agent runs with. */
139
- function askAgentSettings(agent, permissions) {
140
- const spec = askAgents[agent];
141
- const own = permissions === "read-only" ? { mode: spec.readOnlyMode } : spec[permissions];
142
- return {
143
- mode: own?.mode,
144
- sessionMeta: own?.sessionMeta ?? spec.sessionMeta,
145
- env: own?.env ?? spec.env
146
- };
147
- }
148
- /** What a new conversation may do: decide for itself where the agent can,
149
- * else read only. */
150
- function defaultAskPermissions(agent) {
151
- return askAgents[agent].auto ? "auto" : "read-only";
152
- }
153
- const askAgents = {
154
- claude: {
155
- name: "Claude Code",
156
- commands: ["claude"],
157
- launch: {
158
- adapter: "@agentclientprotocol/claude-agent-acp/dist/index.js",
159
- executableEnv: "CLAUDE_CODE_EXECUTABLE"
160
- },
161
- signIn: "claude auth login",
162
- steers: true,
163
- readOnlyMode: "default",
164
- sessionMeta: { claudeCode: { options: {
165
- disallowedTools: [
166
- "Edit",
167
- "MultiEdit",
168
- "Write",
169
- "NotebookEdit",
170
- "EnterPlanMode",
171
- "ExitPlanMode"
172
- ],
173
- allowDangerouslySkipPermissions: false
174
- } } },
175
- auto: { mode: "auto" },
176
- bypass: {
177
- mode: "bypassPermissions",
178
- sessionMeta: { claudeCode: { options: { disallowedTools: ["EnterPlanMode", "ExitPlanMode"] } } }
179
- }
180
- },
181
- codex: {
182
- name: "Codex",
183
- commands: ["codex"],
184
- launch: {
185
- adapter: "@agentclientprotocol/codex-acp/dist/index.js",
186
- executableEnv: "CODEX_PATH"
187
- },
188
- signIn: "codex login",
189
- readOnlyMode: "read-only",
190
- auto: { mode: "agent" },
191
- bypass: { mode: "agent-full-access" }
192
- },
193
- cursor: {
194
- name: "Cursor",
195
- commands: ["cursor-agent"],
196
- installDirs: [".local/bin"],
197
- launch: { args: ["acp"] },
198
- signIn: "cursor-agent login",
199
- readOnlyMode: "ask",
200
- bypass: { mode: "agent" }
201
- },
202
- opencode: {
203
- name: "OpenCode",
204
- commands: ["opencode"],
205
- installDirs: [".opencode/bin"],
206
- launch: { args: ["acp"] },
207
- signIn: "opencode auth login",
208
- readOnlyMode: "build",
209
- env: { OPENCODE_CONFIG_CONTENT: JSON.stringify({ permission: {
210
- edit: "deny",
211
- bash: "ask",
212
- webfetch: "ask"
213
- } }) },
214
- bypass: {
215
- mode: "build",
216
- env: { OPENCODE_CONFIG_CONTENT: JSON.stringify({ permission: {
217
- edit: "allow",
218
- bash: "allow",
219
- webfetch: "allow"
220
- } }) }
221
- }
222
- },
223
- pi: {
224
- name: "Pi",
225
- commands: ["pi"],
226
- launch: {
227
- adapter: "pi-acp/dist/index.js",
228
- executableEnv: "PI_ACP_PI_COMMAND"
229
- },
230
- signIn: "pi",
231
- mcp: {
232
- supported: piTakesMcp,
233
- launch: piWithMcp
234
- }
235
- }
236
- };
237
- /** Desktop inherits the login shell's PATH, so this sees what a terminal sees.
238
- * Package-manager bin directories are skipped: the adapters' own dependencies
239
- * put `codex` there, and that is not the user's install. */
240
- async function findExecutable(command, env = process.env) {
241
- for (const directory of (env.PATH ?? "").split(path.delimiter)) {
242
- if (!directory || directory.split(path.sep).includes("node_modules")) continue;
243
- const candidate = path.join(directory, command);
244
- try {
245
- if (!(await stat(candidate)).isFile()) continue;
246
- await access(candidate, constants.X_OK);
247
- return candidate;
248
- } catch {}
249
- }
250
- }
251
- /** The user's install of an agent's CLI: on PATH, else where its installer
252
- * puts it. */
253
- async function findAgent(spec, env = process.env) {
254
- const installed = (spec.installDirs ?? []).map((directory) => path.join(homedir(), directory));
255
- for (const command of spec.commands) {
256
- const found = await findExecutable(command, env) ?? await findExecutable(command, { PATH: installed.join(path.delimiter) });
257
- if (found) return found;
258
- }
259
- }
260
- /** Whether the agent's model gets the MCP servers its sessions are given. */
261
- async function askAgentTakesMcp(agent, env = process.env) {
262
- const spec = askAgents[agent];
263
- if (!spec.mcp) return true;
264
- const executable = await findAgent(spec, env);
265
- return executable !== void 0 && spec.mcp.supported(executable, env);
266
- }
267
- async function detectAskAgents(env = process.env) {
268
- return Promise.all(askAgentIds.map(async (id) => ({
269
- id,
270
- name: askAgents[id].name,
271
- available: await findAgent(askAgents[id], env) !== void 0,
272
- readOnly: askAgents[id].readOnlyMode !== void 0,
273
- auto: askAgents[id].auto !== void 0,
274
- bypass: askAgents[id].bypass !== void 0
275
- })));
276
- }
277
- /** Runs an adapter with this server's runtime, Desktop's being Electron, or
278
- * the user's CLI itself. */
279
- const launchAskAgent = async (agent, cwd, { permissions = "read-only", mcpServers = [], env: base = process.env } = {}) => {
280
- const spec = askAgents[agent];
281
- const executable = await findAgent(spec, base);
282
- if (!executable) throw new Error(`${spec.name} is not installed.`);
283
- const env = {
284
- ...base,
285
- ...askAgentSettings(agent, permissions).env
286
- };
287
- delete env.CLAUDECODE;
288
- delete env.CLAUDE_CODE_ENTRYPOINT;
289
- const { launch } = spec;
290
- let command = executable;
291
- let args;
292
- if ("adapter" in launch) {
293
- env[launch.executableEnv] = spec.mcp && mcpServers.length && await spec.mcp.supported(executable, env) ? await spec.mcp.launch(executable, mcpServers, env) : executable;
294
- if (process.versions.electron) env.ELECTRON_RUN_AS_NODE = "1";
295
- command = process.execPath;
296
- args = [createRequire(import.meta.url).resolve(launch.adapter)];
297
- } else args = launch.args;
298
- const child = spawn(command, args, {
299
- cwd,
300
- env,
301
- stdio: [
302
- "pipe",
303
- "pipe",
304
- "pipe"
305
- ]
306
- });
307
- let stderr = "";
308
- child.stderr.setEncoding("utf8");
309
- child.stderr.on("data", (chunk) => {
310
- stderr = (stderr + chunk).slice(-8e3);
311
- });
312
- await new Promise((resolve, reject) => {
313
- child.once("spawn", resolve);
314
- child.once("error", reject);
315
- });
316
- const stream = ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout));
317
- return {
318
- connect: (client) => {
319
- const connection = client.connect(stream);
320
- child.once("exit", () => connection.close());
321
- return connection;
322
- },
323
- diagnostics: () => stderr,
324
- stop: () => {
325
- if (child.exitCode === null) child.kill();
326
- }
327
- };
328
- };
329
- //#endregion
330
37
  //#region src/ask/protocol.ts
331
38
  /** Claude's adapter names the MCP server behind an `mcp__*` permission here. */
332
39
  const claudeMcpMetaSchema = z.object({ claudeCode: z.object({ mcpServer: z.object({ name: z.string() }) }) });
@@ -2491,9 +2198,10 @@ function matchesFileLens(patterns, file) {
2491
2198
  }
2492
2199
  //#endregion
2493
2200
  //#region src/review-api/review-progress.ts
2494
- const coverageModeSchema = z.enum(["structural", "textual"]).default("structural");
2201
+ /** Older clients still send `mode`. */
2202
+ const legacyModeSchema = z.unknown().optional();
2495
2203
  const progressUpdateSchema = z.strictObject({
2496
- mode: coverageModeSchema,
2204
+ mode: legacyModeSchema,
2497
2205
  version: z.number().int().nonnegative(),
2498
2206
  files: z.array(z.strictObject({
2499
2207
  path: z.string(),
@@ -2503,10 +2211,10 @@ const progressUpdateSchema = z.strictObject({
2503
2211
  viewed: z.boolean()
2504
2212
  });
2505
2213
  /** Coverage survives new pins only when both complete file contents are unchanged. */
2506
- async function reviewProgress(store, data, snapshot, signal = new AbortController().signal, mode = "structural", partial) {
2214
+ async function reviewProgress(store, data, snapshot, signal = new AbortController().signal, partial) {
2507
2215
  const marks = snapshot.shared ? /* @__PURE__ */ new Map() : store.viewedCoverage(snapshot.reviewId);
2508
2216
  const pins = snapshot.pins ? (await data.resolveSource(snapshot)).pins : void 0;
2509
- const comparison = pins ? partial ?? await data.coverage(snapshot.reviewId, pins, mode) : {
2217
+ const comparison = pins ? partial ?? await data.coverage(snapshot.reviewId, pins) : {
2510
2218
  counted: true,
2511
2219
  files: [],
2512
2220
  fileSources: /* @__PURE__ */ new Map(),
@@ -2522,10 +2230,10 @@ async function reviewProgress(store, data, snapshot, signal = new AbortControlle
2522
2230
  let loading = comparisons.get(key);
2523
2231
  if (loading) return loading;
2524
2232
  if (partial) {
2525
- const state = data.coverageSnapshot(snapshot.reviewId, own, mode);
2233
+ const state = data.coverageSnapshot(snapshot.reviewId, own);
2526
2234
  if (state.pending) return state.comparison.counted ? Promise.resolve(state.comparison) : void 0;
2527
2235
  }
2528
- loading = data.coverage(snapshot.reviewId, own, mode);
2236
+ loading = data.coverage(snapshot.reviewId, own);
2529
2237
  comparisons.set(key, loading);
2530
2238
  return loading;
2531
2239
  };
@@ -2923,8 +2631,8 @@ async function localStack(subject, reviews, repositoryPath) {
2923
2631
  if (branches.length < 2) return [];
2924
2632
  return branches.map((branch) => ({
2925
2633
  branch,
2926
- pullRequestNumber: null,
2927
- pullRequestUrl: null,
2634
+ pullRequestNumber: latest("branch", branch)?.origin?.pullRequestNumber ?? null,
2635
+ pullRequestUrl: latest("branch", branch)?.origin?.pullRequestUrl ?? null,
2928
2636
  base: branch === bottom && start?.base || null,
2929
2637
  subject: branch === bottom && start?.subject || null,
2930
2638
  current: branch === current,
@@ -3251,7 +2959,7 @@ function documentText(snapshot, targetId, full = false) {
3251
2959
  break;
3252
2960
  case "step":
3253
2961
  detail(`${element.from} → ${element.to}: ${element.label} (${element.style})`);
3254
- if (element.source) detail(element.source);
2962
+ for (const source of stepSources(element)) detail(source);
3255
2963
  if (detailed && element.explanation) detail(element.explanation);
3256
2964
  if (detailed && element.code) code(depth + 1, element.code);
3257
2965
  break;
@@ -3844,13 +3552,13 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
3844
3552
  if (!snapshot || version !== void 0 && version !== snapshot.version) throw new ReviewInputError("Shared review version is unavailable.", 404);
3845
3553
  return snapshot;
3846
3554
  };
3847
- const catalog = (mode = "structural") => {
3848
- const local = store.list(mode);
3849
- return [...scratchpadEnabled() ? local : local.filter((summary) => summary.kind !== "scratchpad"), ...shared?.list(mode) ?? []];
3555
+ const catalog = () => {
3556
+ const local = store.list();
3557
+ return [...scratchpadEnabled() ? local : local.filter((summary) => summary.kind !== "scratchpad"), ...shared?.list() ?? []];
3850
3558
  };
3851
3559
  app.get("/", async (context) => {
3852
3560
  await ensureScratchpad();
3853
- return context.json(catalog(coverageModeSchema.parse(context.req.query("mode"))));
3561
+ return context.json(catalog());
3854
3562
  });
3855
3563
  const instructionContext = async () => ({
3856
3564
  desktopAvailable: Boolean(open),
@@ -3868,16 +3576,16 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
3868
3576
  app.get("/:id/progress", async (context) => {
3869
3577
  if (!data) throw new ReviewInputError("Source data is unavailable.", 409);
3870
3578
  const query = readQuerySchemas.get.pick({ version: true }).extend({
3871
- mode: coverageModeSchema,
3579
+ mode: legacyModeSchema,
3872
3580
  wait: z.enum(["false", "true"]).default("true")
3873
3581
  }).parse(context.req.query());
3874
3582
  const snapshot = readReview(context.req.param("id"), query.version);
3875
3583
  const documentPins = query.wait === "false" && snapshot.pins ? (await data.resolveSource(snapshot)).pins : void 0;
3876
3584
  if (documentPins) {
3877
- const state = data.coverageSnapshot(snapshot.reviewId, documentPins, query.mode);
3878
- if (state.pending) return context.json(await reviewProgress(store, data, snapshot, context.req.raw.signal, query.mode, state.comparison), 202);
3585
+ const state = data.coverageSnapshot(snapshot.reviewId, documentPins);
3586
+ if (state.pending) return context.json(await reviewProgress(store, data, snapshot, context.req.raw.signal, state.comparison), 202);
3879
3587
  }
3880
- return context.json(await reviewProgress(store, data, snapshot, context.req.raw.signal, query.mode));
3588
+ return context.json(await reviewProgress(store, data, snapshot, context.req.raw.signal));
3881
3589
  });
3882
3590
  app.post("/:id/progress", reviewAccess("edit"), async (context) => {
3883
3591
  if (!data) throw new ReviewInputError("Source data is unavailable.", 409);
@@ -3885,9 +3593,9 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
3885
3593
  const id = context.req.param("id");
3886
3594
  const snapshot = store.read(id);
3887
3595
  const pins = snapshot.pins ? (await data.resolveSource(snapshot)).pins : void 0;
3888
- const coverage = pins && data.coverageSnapshot(id, pins, input.mode);
3596
+ const coverage = pins && data.coverageSnapshot(id, pins);
3889
3597
  const partial = coverage && coverage.pending ? coverage.comparison : void 0;
3890
- const progress = await reviewProgress(store, data, snapshot, context.req.raw.signal, input.mode, partial);
3598
+ const progress = await reviewProgress(store, data, snapshot, context.req.raw.signal, partial);
3891
3599
  const files = input.files.map((update) => {
3892
3600
  const file = progress.files.find((file) => file.path === update.path);
3893
3601
  if (!file || file.fingerprint !== update.fingerprint) throw new ReviewInputError("This file changed. Reload before marking it viewed.", 409);
@@ -3899,7 +3607,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
3899
3607
  });
3900
3608
  if (store.read(id).version !== snapshot.version) throw new ReviewInputError("Review changed during this update. Try again.", 409);
3901
3609
  store.updateViewedCoverage(id, files, input.viewed);
3902
- return context.json(await reviewProgress(store, data, store.read(id, input.version), context.req.raw.signal, input.mode, partial));
3610
+ return context.json(await reviewProgress(store, data, store.read(id, input.version), context.req.raw.signal, partial));
3903
3611
  });
3904
3612
  app.get("/:id/lenses", async (context) => {
3905
3613
  if (!data) throw new ReviewInputError("Source data is unavailable.", 409);
@@ -3947,13 +3655,13 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
3947
3655
  }
3948
3656
  const subscriptions = z.array(z.strictObject({
3949
3657
  reviewId: z.string().min(1).nullable(),
3950
- mode: coverageModeSchema
3658
+ mode: legacyModeSchema
3951
3659
  })).parse(input);
3952
- const modes = new Set(subscriptions.flatMap((item) => item.reviewId === null ? [item.mode] : []));
3660
+ const lists = subscriptions.some((item) => item.reviewId === null);
3953
3661
  const reviewIds = new Set(subscriptions.flatMap((item) => item.reviewId ?? []));
3954
- const dirtyModes = new Set(modes);
3662
+ let dirtyList = lists;
3955
3663
  const dirtyReviews = new Set(reviewIds);
3956
- const sentLists = /* @__PURE__ */ new Map();
3664
+ let sentList;
3957
3665
  const readReviewLine = (reviewId) => {
3958
3666
  try {
3959
3667
  return {
@@ -3975,17 +3683,17 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
3975
3683
  };
3976
3684
  const lines = () => {
3977
3685
  const pending = [];
3978
- for (const mode of dirtyModes) {
3686
+ if (dirtyList) {
3979
3687
  const line = JSON.stringify({
3980
3688
  kind: "list",
3981
- mode,
3982
- reviews: catalog(mode)
3689
+ mode: "structural",
3690
+ reviews: catalog()
3983
3691
  });
3984
- if (sentLists.get(mode) !== line) pending.push(line);
3985
- sentLists.set(mode, line);
3692
+ if (sentList !== line) pending.push(line);
3693
+ sentList = line;
3986
3694
  }
3987
3695
  for (const reviewId of dirtyReviews) pending.push(JSON.stringify(readReviewLine(reviewId)));
3988
- dirtyModes.clear();
3696
+ dirtyList = false;
3989
3697
  dirtyReviews.clear();
3990
3698
  return pending;
3991
3699
  };
@@ -3995,8 +3703,8 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
3995
3703
  return true;
3996
3704
  };
3997
3705
  const markLists = () => {
3998
- modes.forEach((mode) => dirtyModes.add(mode));
3999
- return modes.size > 0;
3706
+ dirtyList ||= lists;
3707
+ return lists;
4000
3708
  };
4001
3709
  return watch(lines, (notify) => {
4002
3710
  const stops = [
@@ -4242,7 +3950,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
4242
3950
  });
4243
3951
  }
4244
3952
  app.post("/:id/copy-context", reviewAccess("read"), async (context) => {
4245
- const query = readQuerySchemas.get.pick({ version: true }).extend({ mode: coverageModeSchema }).parse(context.req.query());
3953
+ const query = readQuerySchemas.get.pick({ version: true }).extend({ mode: legacyModeSchema }).parse(context.req.query());
4246
3954
  const selection = AgentSelectionSchema.parse(await readBoundedRequestJson(context.req.raw));
4247
3955
  return context.json({ text: await selectionContext(context.req.param("id"), selection, query.version) });
4248
3956
  });
@@ -5188,4 +4896,4 @@ async function serve(input) {
5188
4896
  }
5189
4897
  }
5190
4898
  //#endregion
5191
- export { saveDiffrSummarizer as C, findExecutable as D, cliAskTools as E, readDiffrConfig as S, testDiffrSummarizer as T, DEFAULT_MAX_REQUEST_BYTES as _, drainServerCrashReport as a, GlobalReviewDesktopVerbRelay as b, answerErrorsAsJson as c, coverageModeSchema as d, captureSanitizedUiTelemetry as f, readBoundedRequestJson as g, createNodeRequestListener as h, withHeadlessServerLock as i, createWhiteboardCore as l, recordClientError as m, runHeadlessServer as n, installProcessErrorTelemetry as o, clientErrorsForSession as p, takeOverServerHome as r, serverCrashReportPath as s, HeadlessServerBusyError as t, serverJson as u, HttpJsonError as v, setDiffrConfigValue as w, migrateDiffrConfig as x, ReviewServerError as y };
4899
+ export { saveDiffrSummarizer as C, cliAskTools as E, readDiffrConfig as S, testDiffrSummarizer as T, DEFAULT_MAX_REQUEST_BYTES as _, drainServerCrashReport as a, GlobalReviewDesktopVerbRelay as b, answerErrorsAsJson as c, legacyModeSchema as d, captureSanitizedUiTelemetry as f, readBoundedRequestJson as g, createNodeRequestListener as h, withHeadlessServerLock as i, createWhiteboardCore as l, recordClientError as m, runHeadlessServer as n, installProcessErrorTelemetry as o, clientErrorsForSession as p, takeOverServerHome as r, serverCrashReportPath as s, HeadlessServerBusyError as t, serverJson as u, HttpJsonError as v, setDiffrConfigValue as w, migrateDiffrConfig as x, ReviewServerError as y };