minicode-ai 0.14.1 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/cli/auto-update.ts +32 -2
  3. package/cli/index.ts +10 -2
  4. package/cli/setup.ts +8 -3
  5. package/cli/tui.ts +18 -15
  6. package/docs/OUTPUT_PROTOCOL_SPEC.md +6 -0
  7. package/docs/OUTPUT_RENDERING_SPEC.md +28 -4
  8. package/docs/README.md +2 -2
  9. package/docs/TERMINAL_CONTRACT.md +52 -26
  10. package/docs/getting-started.md +14 -12
  11. package/docs/glossary.md +1 -1
  12. package/docs/mcp-lsp.md +1 -1
  13. package/docs/policy-sandbox.md +7 -1
  14. package/docs/security-model.md +2 -2
  15. package/docs/security.md +7 -1
  16. package/docs/tools.md +4 -4
  17. package/docs/verify-benchmark.md +16 -0
  18. package/package.json +1 -3
  19. package/src/app/mentions.ts +4 -3
  20. package/src/app/session.ts +13 -9
  21. package/src/app/tool-layer.ts +6 -0
  22. package/src/constants.ts +17 -0
  23. package/src/lib/git-hardening.ts +27 -22
  24. package/src/lib/safe-open.ts +73 -19
  25. package/src/lib/trusted-exec.ts +7 -4
  26. package/src/mcp/client.ts +34 -9
  27. package/src/mcp/transport.ts +96 -42
  28. package/src/memory/files.ts +15 -4
  29. package/src/memory/vector.ts +5 -1
  30. package/src/policy/context.ts +21 -13
  31. package/src/policy/tool-contract.ts +4 -10
  32. package/src/policy/update-check.ts +83 -6
  33. package/src/policy/usage.ts +17 -7
  34. package/src/presentation/adapter.ts +64 -2
  35. package/src/presentation/events.ts +6 -0
  36. package/src/presentation/model.ts +1 -0
  37. package/src/presentation/projection.ts +2 -0
  38. package/src/presentation/reducer.ts +1 -0
  39. package/src/providers/anthropic.ts +52 -19
  40. package/src/providers/guards.ts +98 -13
  41. package/src/providers/responses.ts +61 -23
  42. package/src/providers/sse-bounds.ts +170 -0
  43. package/src/repo/repomap.ts +10 -11
  44. package/src/runtime/execution-backend.ts +7 -8
  45. package/src/sandbox/docker.ts +113 -9
  46. package/src/session/checkpoint.ts +9 -2
  47. package/src/session/persistence.ts +5 -2
  48. package/src/session/verification.ts +55 -16
  49. package/src/skills/loader.ts +16 -3
  50. package/src/tools/bash.ts +6 -3
  51. package/src/tools/code_run.ts +6 -5
  52. package/src/tools/context.ts +8 -0
  53. package/src/tools/delete_file.ts +2 -1
  54. package/src/tools/edit.ts +2 -1
  55. package/src/tools/git.ts +128 -54
  56. package/src/tools/glob.ts +2 -1
  57. package/src/tools/grep.ts +31 -6
  58. package/src/tools/lsp.ts +5 -4
  59. package/src/tools/mcp_call.ts +3 -1
  60. package/src/tools/memory.ts +175 -180
  61. package/src/tools/move_file.ts +2 -1
  62. package/src/tools/patch.ts +2 -1
  63. package/src/tools/read_file.ts +94 -1
  64. package/src/tools/read_image.ts +2 -1
  65. package/src/tools/task.ts +2 -1
  66. package/src/tools/todo.ts +4 -5
  67. package/src/tools/web_fetch.ts +28 -12
  68. package/src/tools/web_search.ts +28 -9
  69. package/src/tools/write_file.ts +2 -1
  70. package/src/ui/assistant/simple.ts +72 -3
  71. package/src/ui/i18n/en.ts +3 -0
  72. package/src/ui/i18n/id.ts +3 -0
  73. package/src/ui/render/width.ts +107 -79
  74. package/src/ui/runtime/screen.ts +49 -37
  75. package/src/ui/tui/app.ts +255 -205
  76. package/src/ui/tui/transcript.ts +39 -0
  77. package/CHANGELOG.md +0 -1185
  78. package/docs/PLAN_UIUX_V6.md +0 -209
  79. package/docs/changelog.md +0 -3
package/src/tools/git.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { spawn } from "node:child_process"
2
- import { resolve } from "node:path"
2
+ import { mkdtemp, rm } from "node:fs/promises"
3
+ import { tmpdir } from "node:os"
4
+ import { join, resolve } from "node:path"
3
5
  import type { Tool } from "#minicore"
4
6
  import { LIMITS } from "../constants.ts"
5
7
  import {
@@ -11,8 +13,14 @@ import {
11
13
  import { resolveTrustedExecutable } from "../lib/trusted-exec.ts"
12
14
  import { isCwdOutsideRoot, isPathOutsideRoot } from "../policy/jail.ts"
13
15
  import { sanitizeSpawnEnv, scrubSecrets } from "../policy/scrub.ts"
16
+ import { requireToolCwd } from "./context.ts"
14
17
 
15
- function runGit(args: string[], cwd: string | undefined, signal: AbortSignal): Promise<string> {
18
+ function runGit(
19
+ args: string[],
20
+ cwd: string | undefined,
21
+ signal: AbortSignal,
22
+ envPatch?: Record<string, string>,
23
+ ): Promise<string> {
16
24
  return new Promise((resolve, reject) => {
17
25
  // Audit #10 P0: SEMUA pemanggilan git lewat sini membawa netralisasi
18
26
  // repo-controlled execution (hooks/fsmonitor/pager via GIT_SAFE_BASE).
@@ -24,7 +32,7 @@ function runGit(args: string[], cwd: string | undefined, signal: AbortSignal): P
24
32
  // env ini — kredensial (API_KEY/TOKEN/...) di-strip agar hook nakal tak
25
33
  // bisa memanen secret dari env. Auth tetap via credential helper / agen
26
34
  // SSH (SSH_AUTH_SOCK bukan pola secret) — lihat policy/scrub.ts.
27
- env: sanitizeSpawnEnv(process.env),
35
+ env: sanitizeSpawnEnv(process.env, envPatch),
28
36
  // Timeout dari LIMITS, bukan hardcode: `git_commit` menjalankan beberapa
29
37
  // operasi berurutan (rev-parse → add → commit → log), dan di mesin yang
30
38
  // sibuk (mis. CI menjalankan test dengan coverage) spawn git bisa jauh
@@ -62,6 +70,24 @@ function runGit(args: string[], cwd: string | undefined, signal: AbortSignal): P
62
70
  })
63
71
  }
64
72
 
73
+ const gitCommitLocks = new Map<string, Promise<void>>()
74
+
75
+ async function withGitCommitLock<T>(cwd: string, operation: () => Promise<T>): Promise<T> {
76
+ const key = resolve(cwd)
77
+ const previous = gitCommitLocks.get(key) ?? Promise.resolve()
78
+ let release!: () => void
79
+ const current = new Promise<void>((resolvePromise) => (release = resolvePromise))
80
+ const queued = previous.then(() => current)
81
+ gitCommitLocks.set(key, queued)
82
+ await previous
83
+ try {
84
+ return await operation()
85
+ } finally {
86
+ release()
87
+ if (gitCommitLocks.get(key) === queued) gitCommitLocks.delete(key)
88
+ }
89
+ }
90
+
65
91
  /** cwd tool harus di dalam workspace — sama seperti bash/glob/grep. */
66
92
  function assertCwd(cwd: string | undefined, sessionRoot: string): void {
67
93
  if (!cwd) return
@@ -92,7 +118,7 @@ export const gitStatusTool: Tool = {
92
118
  },
93
119
  async execute({ cwd }, ctx) {
94
120
  const c = cwd as string | undefined
95
- const sessionRoot = ctx.cwd ?? process.cwd()
121
+ const sessionRoot = requireToolCwd(ctx)
96
122
  assertCwd(c, sessionRoot)
97
123
  const resolvedCwd = c ? resolve(sessionRoot, c) : sessionRoot
98
124
  if (!(await isGitRepo(resolvedCwd, ctx.signal))) return "not a git repository"
@@ -131,7 +157,7 @@ export const gitDiffTool: Tool = {
131
157
  additionalProperties: false,
132
158
  },
133
159
  async execute({ cwd, staged }, ctx) {
134
- const sessionRoot = ctx.cwd ?? process.cwd()
160
+ const sessionRoot = requireToolCwd(ctx)
135
161
  assertCwd(cwd as string | undefined, sessionRoot)
136
162
  const resolvedCwd = (cwd as string | undefined)
137
163
  ? resolve(sessionRoot, cwd as string)
@@ -160,7 +186,7 @@ export const gitLogTool: Tool = {
160
186
  additionalProperties: false,
161
187
  },
162
188
  async execute({ cwd, limit }, ctx) {
163
- const sessionRoot = ctx.cwd ?? process.cwd()
189
+ const sessionRoot = requireToolCwd(ctx)
164
190
  assertCwd(cwd as string | undefined, sessionRoot)
165
191
  const resolvedCwd = (cwd as string | undefined)
166
192
  ? resolve(sessionRoot, cwd as string)
@@ -200,7 +226,7 @@ function assertPaths(paths: unknown, cwd: string | undefined, sessionRoot: strin
200
226
  export const gitCommitTool: Tool = {
201
227
  name: "git_commit",
202
228
  description:
203
- "Create a git commit. Stage specific paths (paths) or all tracked changes (all:true). Does not support push/amend/reset — that is beyond the agent's authority. Never runs repository hooks (--no-verify + isolated hooks path), unlike terminal git commit.",
229
+ "Create a git commit. Stage specific paths (paths) or all tracked changes (all:true). Does not support push/amend/reset — that is beyond the agent's authority. Never runs repository hooks and refuses configured custom filters before staging; use manual Git only after reviewing trusted filters.",
204
230
  parameters: {
205
231
  type: "object",
206
232
  properties: {
@@ -222,7 +248,7 @@ export const gitCommitTool: Tool = {
222
248
  async execute({ message, paths, all, cwd }, ctx) {
223
249
  ctx.signal.throwIfAborted()
224
250
  const c = cwd as string | undefined
225
- const sessionRoot = ctx.cwd ?? process.cwd()
251
+ const sessionRoot = requireToolCwd(ctx)
226
252
  assertCwd(c, sessionRoot)
227
253
  const resolvedCwd = c ? resolve(sessionRoot, c) : sessionRoot
228
254
  const msg = String(message ?? "").trim()
@@ -244,58 +270,106 @@ export const gitCommitTool: Tool = {
244
270
  ).catch(() => "")
245
271
  if (!inside.startsWith("true")) throw new Error("not a git repository (git rev-parse failed)")
246
272
 
247
- if (files.length > 0) {
248
- // `--` memisahkan path dari opsi: nama file bernama `-f` tak jadi flag.
249
- await runGit(["add", "--", ...files], resolvedCwd, ctx.signal)
250
- }
251
- // F-04: clean/smudge TIDAK dinetralkan di add/commit — semantik clean
252
- // milik user (LFS), lihat git-hardening.ts. Sebagai gantinya, staging yang
253
- // melewati filter repo yang DITEMUKAN dilaporkan eksplisit di hasil (bukan
254
- // diam-diam): approval gate permission + peringatan ini adalah kontrolnya.
255
- // Berlaku untuk paths MAUPUN all:true (`commit -a` juga menjalankan clean).
256
- let filterWarning = ""
257
- try {
273
+ return await withGitCommitLock(resolvedCwd, async () => {
274
+ ctx.signal.throwIfAborted()
275
+ // Tool authority tidak mencakup eksekusi command dari filter repo.
276
+ // Discovery juga fail-closed: kegagalan membaca config berhenti sebelum
277
+ // temporary index dibuat atau `git add` dapat menjalankan filter.
258
278
  const drivers = await discoverFilterDrivers(resolvedCwd)
259
279
  if (drivers.length > 0) {
260
280
  const names = drivers.map((d) => `filter.${d.name}`).join(", ")
261
- filterWarning =
262
- `\n\n[warn] repo defines custom git filters (${names}) that ran during staging — ` +
263
- `review .gitattributes/.git/config in untrusted repos before committing.`
281
+ throw new Error(
282
+ `git_commit blocked before staging: repository Git filters are configured (${names}). ` +
283
+ "Review .gitattributes and Git config, then perform the commit manually if the filters are trusted.",
284
+ )
264
285
  }
265
- } catch {}
266
-
267
- // `-m` dengan pesan sebagai satu argumen: tak ada shell yang menginterpretasi
268
- // isinya, jadi backtick/`$()` di pesan commit tidak dieksekusi.
269
- // Audit #10 P0: `--no-verify` mematikan pre-commit/commit-msg repo;
270
- // post-commit (+ override hooksPath repo) dimatikan GIT_SAFE_BASE di
271
- // runGit. Commit agen tak pernah menjalankan kode repo — bedakan dari
272
- // `git commit` terminal yang menjalankan hooks.
273
- const args = ["commit", "--no-verify", "-m", msg]
274
- if (files.length === 0 && all === true) args.push("-a")
275
286
 
276
- const out = await runGit(args, resolvedCwd, ctx.signal)
277
- // `git commit` keluar non-zero saat tak ada perubahan; runGit sudah
278
- // meneruskan teksnya, jadi model membaca alasan sebenarnya.
279
- if (/nothing to commit|no changes added/i.test(out)) {
280
- // Audit #08 P1 (retry setelah sukses-yang-responsnya-hilang): tree
281
- // bersih + subjek HEAD sama dengan pesan yang diminta = commit pertama
282
- // sudah durable. Kembalikan SHA-nya (tanpa commit baru) agar pemanggil
283
- // tak mengira tak ada yang ter-commit. Beda subjek = kondisi orang
284
- // lain yang commit duluan → perilaku lama (tanpa klaim palsu).
287
+ const tempIndexDir = await mkdtemp(join(tmpdir(), "minicode-git-index-"))
288
+ const indexEnv = { GIT_INDEX_FILE: join(tempIndexDir, "index") }
285
289
  try {
286
- const subject = (
287
- await runGit(["log", "-1", "--format=%s"], resolvedCwd, ctx.signal).catch(() => "")
288
- ).trim()
289
- if (subject && subject === msg.split("\n")[0]?.trim()) {
290
- const head = await runGit(["log", "--oneline", "-1"], resolvedCwd, ctx.signal).catch(
291
- () => "",
292
- )
293
- return `already committed (retry aman — tanpa commit baru):\n${out}${head ? `\n\nHEAD: ${head}` : ""}${filterWarning}`
290
+ // Seed a private index from HEAD. Existing staged changes stay in the
291
+ // user's index and can never leak into this scoped commit.
292
+ const headRef = await runGit(
293
+ ["rev-parse", "--verify", "HEAD"],
294
+ resolvedCwd,
295
+ ctx.signal,
296
+ ).catch(() => "")
297
+ await runGit(
298
+ ["read-tree", headRef.trim() ? "HEAD" : "--empty"],
299
+ resolvedCwd,
300
+ ctx.signal,
301
+ indexEnv,
302
+ )
303
+ if (files.length > 0) {
304
+ // `--` memisahkan path dari opsi: nama file bernama `-f` tak jadi flag.
305
+ await runGit(["add", "--", ...files], resolvedCwd, ctx.signal, indexEnv)
294
306
  }
295
- } catch {}
296
- return `nothing to commit:\n${out}${filterWarning}`
297
- }
298
- const head = await runGit(["log", "--oneline", "-1"], resolvedCwd, ctx.signal).catch(() => "")
299
- return `${out}${head ? `\n\nHEAD: ${head}` : ""}${filterWarning}`
307
+
308
+ // `-m` satu argumen; --no-verify menonaktifkan hook yang sudah
309
+ // dinetralkan GIT_SAFE_BASE. `-a` hanya berlaku pada index privat.
310
+ const args = ["commit", "--no-verify", "-m", msg]
311
+ if (files.length === 0 && all === true) args.push("-a")
312
+ const out = await runGit(args, resolvedCwd, ctx.signal, indexEnv)
313
+ if (/nothing to commit|no changes added/i.test(out)) {
314
+ try {
315
+ const subject = (
316
+ await runGit(["log", "-1", "--format=%s"], resolvedCwd, ctx.signal).catch(() => "")
317
+ ).trim()
318
+ if (subject && subject === msg.split("\n")[0]?.trim()) {
319
+ const head = await runGit(["log", "--oneline", "-1"], resolvedCwd, ctx.signal).catch(
320
+ () => "",
321
+ )
322
+ return `already committed (retry aman — tanpa commit baru):\n${out}${head ? `\n\nHEAD: ${head}` : ""}`
323
+ }
324
+ } catch {}
325
+ return `nothing to commit:\n${out}`
326
+ }
327
+ let indexWarning = ""
328
+ const newHead = await runGit(
329
+ ["rev-parse", "--verify", "HEAD"],
330
+ resolvedCwd,
331
+ ctx.signal,
332
+ ).catch(() => "")
333
+ if (newHead.trim() && newHead.trim() !== headRef.trim()) {
334
+ try {
335
+ const committedPaths = await runGit(
336
+ [
337
+ "--literal-pathspecs",
338
+ "diff-tree",
339
+ "--root",
340
+ "--no-renames",
341
+ "--no-commit-id",
342
+ "--name-only",
343
+ "-r",
344
+ "-z",
345
+ "HEAD",
346
+ ],
347
+ resolvedCwd,
348
+ ctx.signal,
349
+ )
350
+ const paths = committedPaths.split("\0").filter(Boolean)
351
+ if (paths.length > 0) {
352
+ // Reconcile only committed entries in the shared index. This
353
+ // leaves unrelated staged paths intact while keeping the normal
354
+ // post-commit status clean for files this operation authorized.
355
+ await runGit(
356
+ ["--literal-pathspecs", "reset", "--quiet", "HEAD", "--", ...paths],
357
+ resolvedCwd,
358
+ ctx.signal,
359
+ )
360
+ }
361
+ } catch {
362
+ indexWarning =
363
+ "\n\n[warn] commit succeeded, but the shared index could not be reconciled; review `git status` before the next commit."
364
+ }
365
+ }
366
+ const head = await runGit(["log", "--oneline", "-1"], resolvedCwd, ctx.signal).catch(
367
+ () => "",
368
+ )
369
+ return `${out}${head ? `\n\nHEAD: ${head}` : ""}${indexWarning}`
370
+ } finally {
371
+ await rm(tempIndexDir, { recursive: true, force: true }).catch(() => {})
372
+ }
373
+ })
300
374
  },
301
375
  }
package/src/tools/glob.ts CHANGED
@@ -4,6 +4,7 @@ import type { Tool } from "#minicore"
4
4
  import { LIMITS } from "../constants.ts"
5
5
  import { isIgnored, loadIgnoreMatchers } from "../lib/ignore.ts"
6
6
  import { isPathOutsideRoot, isSensitive } from "../policy/jail.ts"
7
+ import { requireToolCwd } from "./context.ts"
7
8
 
8
9
  async function walk(
9
10
  dir: string,
@@ -78,7 +79,7 @@ export const globTool: Tool = {
78
79
  additionalProperties: false,
79
80
  },
80
81
  async execute({ pattern, cwd, limit }, ctx) {
81
- const sessionRoot = ctx.cwd ?? process.cwd()
82
+ const sessionRoot = requireToolCwd(ctx)
82
83
  const rawRoot = (cwd as string) ?? "."
83
84
  const root = resolve(sessionRoot, rawRoot)
84
85
  if (isPathOutsideRoot(root, sessionRoot)) throw new Error(`cwd outside workspace: ${rawRoot}`)
package/src/tools/grep.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import { spawn, spawnSync } from "node:child_process"
2
2
  import { readdir, realpath, stat } from "node:fs/promises"
3
- import { join, relative, resolve } from "node:path"
3
+ import { isAbsolute, join, relative, resolve } from "node:path"
4
4
  import type { Tool } from "#minicore"
5
5
  import { LIMITS } from "../constants.ts"
6
6
  import { isIgnored, loadIgnoreMatchers } from "../lib/ignore.ts"
7
7
  import { safeReadFile } from "../lib/safe-open.ts"
8
+ import { resolveTrustedExecutable } from "../lib/trusted-exec.ts"
8
9
  import { isPathOutsideRoot, isSensitive } from "../policy/jail.ts"
9
- import { scrubSecrets } from "../policy/scrub.ts"
10
+ import { sanitizeSpawnEnv, scrubSecrets } from "../policy/scrub.ts"
11
+ import { requireToolCwd } from "./context.ts"
10
12
 
11
13
  async function walkGrep(
12
14
  dir: string,
@@ -80,8 +82,22 @@ let rgPath: string | null | undefined
80
82
  export function ripgrepAvailable(): boolean {
81
83
  if (rgPath !== undefined) return rgPath !== null
82
84
  try {
83
- const r = spawnSync("rg", ["--version"], { stdio: "ignore", timeout: 3000 })
84
- rgPath = r.status === 0 ? "rg" : null
85
+ const executable = resolveTrustedExecutable("rg")
86
+ // Resolver fallback berupa nama telanjang tidak aman untuk workspace
87
+ // Windows: CreateProcess dapat mencari executable bernama sama di cwd.
88
+ // Tanpa PATH tepercaya, gunakan walker JS alih-alih mencari ulang dari cwd.
89
+ if (!isAbsolute(executable)) {
90
+ rgPath = null
91
+ return false
92
+ }
93
+ const env = sanitizeSpawnEnv(process.env)
94
+ delete env.RIPGREP_CONFIG_PATH
95
+ const r = spawnSync(executable, ["--no-config", "--version"], {
96
+ stdio: "ignore",
97
+ timeout: 3000,
98
+ env,
99
+ })
100
+ rgPath = r.status === 0 ? executable : null
85
101
  } catch {
86
102
  rgPath = null
87
103
  }
@@ -118,6 +134,7 @@ function runRipgrep(
118
134
  include?: string,
119
135
  ): Promise<string[]> {
120
136
  const args = [
137
+ "--no-config", // config ripgrep dapat menjalankan --pre pada berkas workspace
121
138
  "--vimgrep", // path:line:col:text
122
139
  "--no-heading",
123
140
  "--color=never",
@@ -138,7 +155,15 @@ function runRipgrep(
138
155
  args.push("--regexp", pattern, "--", ".")
139
156
 
140
157
  return new Promise((resolveOut, reject) => {
141
- const p = spawn("rg", args, { cwd: root, stdio: ["ignore", "pipe", "pipe"] })
158
+ const env = sanitizeSpawnEnv(process.env)
159
+ // Config pengguna tidak ikut diterapkan pada operasi pencarian agent.
160
+ // --no-config tetap dipasang sebagai pagar kedua pada argv ripgrep.
161
+ delete env.RIPGREP_CONFIG_PATH
162
+ const p = spawn(resolveTrustedExecutable("rg"), args, {
163
+ cwd: root,
164
+ stdio: ["ignore", "pipe", "pipe"],
165
+ env,
166
+ })
142
167
  const out: string[] = []
143
168
  let buf = ""
144
169
  let stderr = ""
@@ -219,7 +244,7 @@ export const grepTool: Tool = {
219
244
  additionalProperties: false,
220
245
  },
221
246
  async execute({ pattern, cwd, include, limit }, ctx) {
222
- const sessionRoot = ctx.cwd ?? process.cwd()
247
+ const sessionRoot = requireToolCwd(ctx)
223
248
  const rawRoot = (cwd as string) ?? "."
224
249
  const root = resolve(sessionRoot, rawRoot)
225
250
  if (isPathOutsideRoot(root, sessionRoot)) throw new Error(`cwd outside workspace: ${rawRoot}`)
package/src/tools/lsp.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  } from "../lsp/client.ts"
13
13
  import { isPathOutsideRoot, isRealPathOutsideRoot, isSensitive } from "../policy/jail.ts"
14
14
  import { scrubSecrets } from "../policy/scrub.ts"
15
+ import { requireToolCwd } from "./context.ts"
15
16
 
16
17
  const SEVERITY = ["Error", "Warn", "Info", "Hint"]
17
18
 
@@ -126,7 +127,7 @@ function posTool(
126
127
  },
127
128
  async execute(args, ctx) {
128
129
  ctx.signal.throwIfAborted()
129
- const cwd = ctx.cwd ?? process.cwd()
130
+ const cwd = requireToolCwd(ctx)
130
131
  try {
131
132
  const resolved = await resolvePosition(args as PosArgs, cwd)
132
133
  if (typeof resolved === "string") return resolved
@@ -168,7 +169,7 @@ export const lspDiagnosticsTool: Tool = {
168
169
  },
169
170
  async execute({ file }, ctx) {
170
171
  ctx.signal.throwIfAborted()
171
- const cwd = ctx.cwd ?? process.cwd()
172
+ const cwd = requireToolCwd(ctx)
172
173
  try {
173
174
  const { abs, text } = await readTarget(String(file), cwd)
174
175
  const { items } = await raceAbort(lspDiagnostics(abs, text, undefined, cwd), ctx.signal)
@@ -225,7 +226,7 @@ export const lspSymbolsTool: Tool = {
225
226
  },
226
227
  async execute({ file }, ctx) {
227
228
  ctx.signal.throwIfAborted()
228
- const cwd = ctx.cwd ?? process.cwd()
229
+ const cwd = requireToolCwd(ctx)
229
230
  try {
230
231
  const { abs, text } = await readTarget(String(file), cwd)
231
232
  const result = await raceAbort(
@@ -273,7 +274,7 @@ export const lspWorkspaceSymbolsTool: Tool = {
273
274
  if (getConfiguredExts().length === 0)
274
275
  return "(no LSP servers configured — add via minicode config lsp add)"
275
276
  try {
276
- const cwd = ctx.cwd ?? process.cwd()
277
+ const cwd = requireToolCwd(ctx)
277
278
  const symbols = await raceAbort(
278
279
  workspaceSymbols((query as string) ?? "", 5000, cwd),
279
280
  ctx.signal,
@@ -5,6 +5,7 @@ import {
5
5
  extractMcpText,
6
6
  getMcpPrompt,
7
7
  getMcpServerIds,
8
+ McpCallOutcomeUnknownError,
8
9
  mcpInventory,
9
10
  readMcpResource,
10
11
  } from "../mcp/client.ts"
@@ -50,7 +51,7 @@ export const mcpCallTool: Tool = {
50
51
  description:
51
52
  "Call a tool on a connected MCP server. Parameters: server id, tool name, and arguments. " +
52
53
  "The server runs OUTSIDE minicode policy: a call may read/write files, network, or processes " +
53
- "on the server side — one approval covers one server+tool+args call only.",
54
+ "on the server side — one approval covers one server+tool+args call only. If transport aborts after dispatch, the outcome is unknown; inspect remote state before retrying.",
54
55
  parameters: {
55
56
  type: "object",
56
57
  properties: {
@@ -91,6 +92,7 @@ export const mcpCallTool: Tool = {
91
92
  ? capped
92
93
  : fenceUntrustedToolOutput(`mcp_call:${sid}.${tn}`, capped)
93
94
  } catch (e) {
95
+ if (e instanceof McpCallOutcomeUnknownError) throw e
94
96
  return `[mcp] error: ${scrubSecrets((e as Error).message)}`
95
97
  }
96
98
  },