minicode-ai 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/cli/tui.ts +28 -2
- package/docs/README.md +2 -2
- package/docs/SUMMARY.md +10 -19
- package/docs/TERMINAL_CONTRACT.md +82 -28
- package/docs/architecture.md +1 -1
- package/docs/autonomous-scheduler.md +283 -2
- package/docs/choosing-mode.md +4 -4
- package/docs/concepts.md +39 -3
- package/docs/config.md +90 -4
- package/docs/environment.md +3 -0
- package/docs/getting-started.md +58 -2
- package/docs/repl.md +1 -1
- package/docs/security.md +49 -2
- package/docs/tools.md +2 -1
- package/package.json +2 -36
- package/src/app/provider-layer.ts +1 -1
- package/src/config.ts +2 -0
- package/src/constants.ts +3 -0
- package/src/lib/safe-open.ts +21 -12
- package/src/memory/vector.ts +0 -31
- package/src/policy/context-window.ts +0 -33
- package/src/policy/no-progress.ts +1 -1
- package/src/policy/permission.ts +5 -0
- package/src/policy/scrub.ts +15 -2
- package/src/policy/tool-contract.ts +11 -9
- package/src/presentation/reducer.ts +1 -0
- package/src/providers/anthropic.ts +3 -3
- package/src/providers/detect.ts +27 -0
- package/src/providers/provision.ts +15 -1
- package/src/task/autonomous-policy.ts +7 -0
- package/src/task/graph-validate.ts +1 -1
- package/src/task/session-authority.ts +0 -5
- package/src/task/store.ts +0 -4
- package/src/tools/ask_user.ts +14 -1
- package/src/tools/bash.ts +57 -9
- package/src/tools/context.ts +10 -0
- package/src/tools/delete_file.ts +3 -2
- package/src/tools/edit.ts +5 -4
- package/src/tools/git.ts +70 -12
- package/src/tools/glob.ts +13 -5
- package/src/tools/grep.ts +26 -10
- package/src/tools/index.ts +3 -2
- package/src/tools/lsp.ts +15 -9
- package/src/tools/move_file.ts +4 -3
- package/src/tools/patch.ts +5 -4
- package/src/tools/read_file.ts +3 -2
- package/src/tools/read_image.ts +3 -2
- package/src/tools/task.ts +1 -0
- package/src/tools/todo.ts +4 -8
- package/src/tools/write_file.ts +4 -3
- package/src/ui/approval/prompt.ts +226 -77
- package/src/ui/footer.ts +41 -29
- package/src/ui/i18n/en.ts +4 -0
- package/src/ui/i18n/id.ts +4 -0
- package/src/ui/render/activity-group.ts +1 -0
- package/src/ui/render/ledger.ts +1 -9
- package/src/ui/render/logo.ts +0 -5
- package/src/ui/render/markdown-table.ts +0 -3
- package/src/ui/render/table-grid.ts +0 -3
- package/src/ui/render/theme.ts +31 -5
- package/src/ui/runtime/screen.ts +7 -1
- package/src/ui/screens/dialog.ts +45 -81
- package/src/ui/screens/form.ts +10 -10
- package/src/ui/screens/model-manager.ts +7 -10
- package/src/ui/screens/picker.ts +8 -11
- package/src/ui/screens/provider-manager.ts +9 -13
- package/src/ui/tui/app.ts +92 -9
- package/src/ui/tui/transcript.ts +4 -0
- package/docs/P14_OPEN_WORK.md +0 -290
- package/docs/config-providers.md +0 -87
- package/docs/glossary.md +0 -39
- package/docs/quickstart.md +0 -60
- package/docs/security-model.md +0 -96
- package/docs/terminal.md +0 -91
package/src/tools/bash.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { resolve as resolvePath } from "node:path"
|
|
|
4
4
|
import type { Tool, ToolContext } from "#minicore"
|
|
5
5
|
import { LIMITS } from "../constants.ts"
|
|
6
6
|
import { isCwdOutsideRoot, isPathOutsideRoot } from "../policy/jail.ts"
|
|
7
|
-
import { requireToolCwd } from "./context.ts"
|
|
7
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
8
8
|
|
|
9
9
|
// re-export untuk backward compat (helper kini terpusat di policy/scrub)
|
|
10
10
|
export { SECRET_ENV_RE, sanitizeSpawnEnv, stripSecretsEnv } from "../policy/scrub.ts"
|
|
@@ -88,6 +88,34 @@ interface BackgroundJob {
|
|
|
88
88
|
|
|
89
89
|
const jobs = new Map<string, BackgroundJob>()
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Pendengar selesainya job background: lapisan cli memakainya untuk repaint
|
|
93
|
+
* badge footer + satu auto-resume terbatas. Tool hanya mengumumkan fakta
|
|
94
|
+
* "job X selesai dengan exit N" — tak tahu apa pun soal UI/prompt. Set agar
|
|
95
|
+
* unsubscribe idempoten dan aman saat listener menghapus dirinya saat emit.
|
|
96
|
+
*/
|
|
97
|
+
const finishListeners = new Set<(id: string, code: number | null) => void>()
|
|
98
|
+
|
|
99
|
+
/** Daftarkan pendengar selesai job. Return = fungsi unsubscribe (idempoten). */
|
|
100
|
+
export function onBackgroundJobFinished(
|
|
101
|
+
listener: (id: string, code: number | null) => void,
|
|
102
|
+
): () => void {
|
|
103
|
+
finishListeners.add(listener)
|
|
104
|
+
return () => {
|
|
105
|
+
finishListeners.delete(listener)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function emitBackgroundJobFinished(id: string, code: number | null): void {
|
|
110
|
+
// Satu listener yang melempar tak boleh menahan listener lain ATAU
|
|
111
|
+
// menggagalkan handler `close` proses anak.
|
|
112
|
+
for (const listener of [...finishListeners]) {
|
|
113
|
+
try {
|
|
114
|
+
listener(id, code)
|
|
115
|
+
} catch {}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
91
119
|
// F-03 (P5 §C2): gerbang akses job. Hanya pemilik (sid sama, null==null untuk
|
|
92
120
|
// jalur legacy) yang boleh inspect/cancel. Kegagalan karena kepemilikan
|
|
93
121
|
// menghasilkan TIDAK ADA — pemanggil tak bisa membedakan "job milik sesi lain"
|
|
@@ -221,7 +249,12 @@ export function listBackgroundJobs(): { id: string; cmd: string; done: boolean }
|
|
|
221
249
|
return [...jobs.values()].map((j) => ({ id: j.id, cmd: j.cmd, done: j.done }))
|
|
222
250
|
}
|
|
223
251
|
|
|
224
|
-
function startBackground(
|
|
252
|
+
function startBackground(
|
|
253
|
+
cmd: string,
|
|
254
|
+
cwd: string | undefined,
|
|
255
|
+
ownerSid: string | null,
|
|
256
|
+
relaxed = false,
|
|
257
|
+
): string {
|
|
225
258
|
reapFinishedJobs()
|
|
226
259
|
const live = [...jobs.values()].filter((j) => !j.done).length
|
|
227
260
|
if (live >= LIMITS.BASH_BACKGROUND_MAX_JOBS) {
|
|
@@ -233,7 +266,7 @@ function startBackground(cmd: string, cwd: string | undefined, ownerSid: string
|
|
|
233
266
|
const proc = spawn(cmd, {
|
|
234
267
|
shell: true,
|
|
235
268
|
cwd,
|
|
236
|
-
env: sanitizeSpawnEnv(process.env),
|
|
269
|
+
env: sanitizeSpawnEnv(process.env, undefined, relaxed),
|
|
237
270
|
stdio: ["ignore", "pipe", "pipe"],
|
|
238
271
|
// detached agar shell jadi group leader → killTree bisa menutup SELURUH
|
|
239
272
|
// grup (POSIX kill(-pid)). Tanpa ini yang bisa dibunuh cuma wrapper shell
|
|
@@ -260,13 +293,23 @@ function startBackground(cmd: string, cwd: string | undefined, ownerSid: string
|
|
|
260
293
|
const piece = job.buffer.append("err", d)
|
|
261
294
|
if (piece) job.chunks.push(scrubSecrets(piece))
|
|
262
295
|
})
|
|
296
|
+
// Emit sekali per job: `error` biasanya disusul `close` (emit ganda =
|
|
297
|
+
// dua auto-resume). Guard lokal cukup — kedua handler berbagi closure.
|
|
298
|
+
let emitted = false
|
|
299
|
+
const emitOnce = (code: number | null): void => {
|
|
300
|
+
if (emitted) return
|
|
301
|
+
emitted = true
|
|
302
|
+
emitBackgroundJobFinished(id, code)
|
|
303
|
+
}
|
|
263
304
|
proc.on("error", (e) => {
|
|
264
305
|
job.chunks.push(`[error] ${e.message}`)
|
|
265
306
|
job.done = true
|
|
307
|
+
emitOnce(null)
|
|
266
308
|
})
|
|
267
309
|
proc.on("close", (code) => {
|
|
268
310
|
job.exitCode = code
|
|
269
311
|
job.done = true
|
|
312
|
+
emitOnce(code)
|
|
270
313
|
})
|
|
271
314
|
jobs.set(id, job)
|
|
272
315
|
return id
|
|
@@ -300,8 +343,9 @@ function makeBashTool(ownerSid: string | null): Tool {
|
|
|
300
343
|
},
|
|
301
344
|
async execute({ cmd, cwd, timeoutMs, background }, ctx) {
|
|
302
345
|
const sessionRoot = requireToolCwd(ctx)
|
|
346
|
+
const relaxed = contextUnrestricted(ctx)
|
|
303
347
|
const c = cwd as string | undefined
|
|
304
|
-
if (c && (isCwdOutsideRoot(c, sessionRoot) || isPathOutsideRoot(c, sessionRoot)))
|
|
348
|
+
if (!relaxed && c && (isCwdOutsideRoot(c, sessionRoot) || isPathOutsideRoot(c, sessionRoot)))
|
|
305
349
|
throw new Error(`cwd outside workspace: ${c}`)
|
|
306
350
|
const resolvedCwd = c ? resolvePath(sessionRoot, c) : undefined
|
|
307
351
|
const effectiveCwd = resolvedCwd ?? sessionRoot
|
|
@@ -313,7 +357,11 @@ function makeBashTool(ownerSid: string | null): Tool {
|
|
|
313
357
|
// symlink — tak bisa ditutup murah dari sini (shell mengikuti symlink by
|
|
314
358
|
// design; safe-open O_NOFOLLOW hanya untuk tool file). Mitigasi: --sandbox
|
|
315
359
|
// untuk isolasi penuh; lihat permission.ts jail + safe-open.ts.
|
|
316
|
-
|
|
360
|
+
// Unrestricted: default timeout jauh lebih lega; timeoutMs eksplisit
|
|
361
|
+
// tetap menang.
|
|
362
|
+
const timeout =
|
|
363
|
+
timeoutMs ??
|
|
364
|
+
(relaxed ? LIMITS.UNRESTRICTED_BASH_TIMEOUT_MS : LIMITS.BASH_DEFAULT_TIMEOUT_MS)
|
|
317
365
|
|
|
318
366
|
if (background === true) {
|
|
319
367
|
// Sandbox tidak diterapkan di jalur background: container/namespace
|
|
@@ -324,7 +372,7 @@ function makeBashTool(ownerSid: string | null): Tool {
|
|
|
324
372
|
"background:true is not supported while --sandbox is active (the process must outlive the turn)",
|
|
325
373
|
)
|
|
326
374
|
}
|
|
327
|
-
const id = startBackground(cmd as string, resolvedCwd, ownerSid)
|
|
375
|
+
const id = startBackground(cmd as string, resolvedCwd, ownerSid, relaxed)
|
|
328
376
|
// F-07: echo perintah di-scrub seperti output foreground — command line
|
|
329
377
|
// bisa membawa secret (`curl -H "Authorization: Bearer …"`), dan versi
|
|
330
378
|
// lama menaruhnya mentah ke konteks model.
|
|
@@ -336,7 +384,7 @@ function makeBashTool(ownerSid: string | null): Tool {
|
|
|
336
384
|
if (dockerAvailable()) {
|
|
337
385
|
const res = await runInDocker(cmd as string, effectiveCwd, {
|
|
338
386
|
timeoutMs: timeout,
|
|
339
|
-
env: sanitizeSpawnEnv(process.env) as Record<string, string>,
|
|
387
|
+
env: sanitizeSpawnEnv(process.env, undefined, relaxed) as Record<string, string>,
|
|
340
388
|
signal: ctx.signal,
|
|
341
389
|
})
|
|
342
390
|
ctx.signal.throwIfAborted()
|
|
@@ -363,7 +411,7 @@ function makeBashTool(ownerSid: string | null): Tool {
|
|
|
363
411
|
if (osSandboxAvailable()) {
|
|
364
412
|
const res = await runInOsSandbox(cmd as string, effectiveCwd, {
|
|
365
413
|
timeoutMs: timeout,
|
|
366
|
-
env: sanitizeSpawnEnv(process.env) as Record<string, string>,
|
|
414
|
+
env: sanitizeSpawnEnv(process.env, undefined, relaxed) as Record<string, string>,
|
|
367
415
|
})
|
|
368
416
|
const text = scrubSecrets(res.output)
|
|
369
417
|
if (res.code !== 0 && res.code !== null)
|
|
@@ -394,7 +442,7 @@ function makeBashTool(ownerSid: string | null): Tool {
|
|
|
394
442
|
// undefined (= inherit process.cwd()). Jail/permission dievaluasi
|
|
395
443
|
// terhadap sessionRoot — eksekusi harus di direktori yang sama.
|
|
396
444
|
cwd: effectiveCwd,
|
|
397
|
-
env: sanitizeSpawnEnv(process.env),
|
|
445
|
+
env: sanitizeSpawnEnv(process.env, undefined, relaxed),
|
|
398
446
|
signal: ctx.signal,
|
|
399
447
|
// detached agar shell jadi group leader → killTree bisa bunuh
|
|
400
448
|
// seluruh grup (POSIX kill(-pid)). Tanpa ini cucu yatim menahan pipe.
|
package/src/tools/context.ts
CHANGED
|
@@ -6,3 +6,13 @@ export function requireToolCwd(context: unknown): string {
|
|
|
6
6
|
}
|
|
7
7
|
return cwd
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* True hanya di mode `unrestricted`. Sumber: `ToolContext.permissionMode`,
|
|
12
|
+
* di-resolve LIVE per-turn oleh kernel — `/unrestric` saat runtime langsung
|
|
13
|
+
* tercermin tanpa patch vendor. Fail-closed: selain string "unrestricted"
|
|
14
|
+
* (termasuk undefined pada pemanggil library/test) = false.
|
|
15
|
+
*/
|
|
16
|
+
export function contextUnrestricted(context: unknown): boolean {
|
|
17
|
+
return (context as { permissionMode?: unknown } | null)?.permissionMode === "unrestricted"
|
|
18
|
+
}
|
package/src/tools/delete_file.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { stat } from "node:fs/promises"
|
|
|
2
2
|
import type { Tool } from "#minicore"
|
|
3
3
|
import { resolveSafePath } from "../lib/safe-open.ts"
|
|
4
4
|
import { trashFile } from "../lib/trash.ts"
|
|
5
|
-
import { requireToolCwd } from "./context.ts"
|
|
5
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
6
6
|
|
|
7
7
|
export const deleteFileTool: Tool = {
|
|
8
8
|
name: "delete_file",
|
|
@@ -20,8 +20,9 @@ export const deleteFileTool: Tool = {
|
|
|
20
20
|
ctx.signal.throwIfAborted()
|
|
21
21
|
const p = path as string
|
|
22
22
|
const root = requireToolCwd(ctx)
|
|
23
|
+
const relaxed = contextUnrestricted(ctx)
|
|
23
24
|
// Verifikasi path terpusat (logis + target nyata) — detail di safe-open.ts.
|
|
24
|
-
const { abs, real } = await resolveSafePath(p, root)
|
|
25
|
+
const { abs, real } = await resolveSafePath(p, root, relaxed)
|
|
25
26
|
const st = await stat(real).catch(() => null)
|
|
26
27
|
if (!st) throw new Error(`file not found: ${p}`)
|
|
27
28
|
if (st.isDirectory()) throw new Error(`path is directory, use bash rm -r: ${p}`)
|
package/src/tools/edit.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { LIMITS } from "../constants.ts"
|
|
|
3
3
|
import { atomicWriteText } from "../lib/atomic-write.ts"
|
|
4
4
|
import { assertSafeWriteTarget, resolveSafePath, safeReadFile } from "../lib/safe-open.ts"
|
|
5
5
|
import { appendLspDiagnostics } from "../policy/verifier.ts"
|
|
6
|
-
import { requireToolCwd } from "./context.ts"
|
|
6
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
7
7
|
import { applyHashline } from "./hashline.ts"
|
|
8
8
|
|
|
9
9
|
function normalizeLf(s: string): string {
|
|
@@ -147,11 +147,12 @@ export const editTool: Tool = {
|
|
|
147
147
|
ctx.signal.throwIfAborted()
|
|
148
148
|
const p = path as string
|
|
149
149
|
const root = requireToolCwd(ctx)
|
|
150
|
+
const relaxed = contextUnrestricted(ctx)
|
|
150
151
|
// Verifikasi path terpusat (logis + target nyata, induk symlink ikut
|
|
151
152
|
// ter-resolusi) — symlink internal tetap bisa diedit, targetnya yang dicek.
|
|
152
|
-
const { abs, real: realAbs } = await resolveSafePath(p, root)
|
|
153
|
+
const { abs, real: realAbs } = await resolveSafePath(p, root, relaxed)
|
|
153
154
|
// Tolak menimpa symlink final (swap antara cek dan tulis gagal tutup).
|
|
154
|
-
await assertSafeWriteTarget(abs, root)
|
|
155
|
+
await assertSafeWriteTarget(abs, root, relaxed)
|
|
155
156
|
// Cek ukuran sebelum baca penuh — hindari OOM 1GB via safeReadFile.
|
|
156
157
|
// Pakai byte length via stat pada realAbs (handle belum ada), fallback ke content length.
|
|
157
158
|
const { stat } = await import("node:fs/promises")
|
|
@@ -159,7 +160,7 @@ export const editTool: Tool = {
|
|
|
159
160
|
if (!st) throw new Error(`file not found: ${p}`)
|
|
160
161
|
if (st.size > LIMITS.READ_FILE_MAX_BYTES) throw new Error(`file too large: ${p} (${st.size})`)
|
|
161
162
|
// Baca via safeReadFile (O_NOFOLLOW) agar TOCTOU swap gagal ELOOP, bukan baca luar.
|
|
162
|
-
const content = await safeReadFile(abs, root).catch(() => {
|
|
163
|
+
const content = await safeReadFile(abs, root, relaxed).catch(() => {
|
|
163
164
|
throw new Error(`file not found: ${p}`)
|
|
164
165
|
})
|
|
165
166
|
const oldS = oldString as string
|
package/src/tools/git.ts
CHANGED
|
@@ -20,13 +20,14 @@ import {
|
|
|
20
20
|
isSensitive,
|
|
21
21
|
} from "../policy/jail.ts"
|
|
22
22
|
import { sanitizeSpawnEnv, scrubSecrets } from "../policy/scrub.ts"
|
|
23
|
-
import { requireToolCwd } from "./context.ts"
|
|
23
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
24
24
|
|
|
25
25
|
function runGit(
|
|
26
26
|
args: string[],
|
|
27
27
|
cwd: string | undefined,
|
|
28
28
|
signal: AbortSignal,
|
|
29
29
|
envPatch?: Record<string, string>,
|
|
30
|
+
relaxed = false,
|
|
30
31
|
): Promise<string> {
|
|
31
32
|
return new Promise((resolve, reject) => {
|
|
32
33
|
// Audit #10 P0: SEMUA pemanggilan git lewat sini membawa netralisasi
|
|
@@ -36,10 +37,12 @@ function runGit(
|
|
|
36
37
|
const p = spawn(resolveTrustedExecutable("git"), [...GIT_SAFE_BASE, ...args], {
|
|
37
38
|
cwd,
|
|
38
39
|
// Repo hooks (pre-commit/commit-msg/...) berjalan sebagai child dengan
|
|
39
|
-
//
|
|
40
|
+
// Secara default kredensial (API_KEY/TOKEN/...) di-strip agar hook nakal tak
|
|
40
41
|
// bisa memanen secret dari env. Auth tetap via credential helper / agen
|
|
41
42
|
// SSH (SSH_AUTH_SOCK bukan pola secret) — lihat policy/scrub.ts.
|
|
42
|
-
|
|
43
|
+
// Unrestricted: kredensial git SEMPIT (GH_TOKEN/GITHUB_TOKEN/SSH_AUTH_SOCK)
|
|
44
|
+
// dilewatkan untuk `git push`/remote.
|
|
45
|
+
env: sanitizeSpawnEnv(process.env, envPatch, relaxed),
|
|
43
46
|
// Timeout dari LIMITS, bukan hardcode: `git_commit` menjalankan beberapa
|
|
44
47
|
// operasi berurutan (rev-parse → add → commit → log), dan di mesin yang
|
|
45
48
|
// sibuk (mis. CI menjalankan test dengan coverage) spawn git bisa jauh
|
|
@@ -102,8 +105,8 @@ async function withGitCommitLock<T>(cwd: string, operation: () => Promise<T>): P
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
/** cwd tool harus di dalam workspace — sama seperti bash/glob/grep. */
|
|
105
|
-
function assertCwd(cwd: string | undefined, sessionRoot: string): void {
|
|
106
|
-
if (!cwd) return
|
|
108
|
+
function assertCwd(cwd: string | undefined, sessionRoot: string, relaxed = false): void {
|
|
109
|
+
if (!cwd || relaxed) return
|
|
107
110
|
const abs = resolve(sessionRoot, cwd)
|
|
108
111
|
if (isCwdOutsideRoot(abs, sessionRoot) || isPathOutsideRoot(abs, sessionRoot)) {
|
|
109
112
|
throw new Error(`cwd outside workspace: ${cwd}`)
|
|
@@ -132,7 +135,7 @@ export const gitStatusTool: Tool = {
|
|
|
132
135
|
async execute({ cwd }, ctx) {
|
|
133
136
|
const c = cwd as string | undefined
|
|
134
137
|
const sessionRoot = requireToolCwd(ctx)
|
|
135
|
-
assertCwd(c, sessionRoot)
|
|
138
|
+
assertCwd(c, sessionRoot, contextUnrestricted(ctx))
|
|
136
139
|
const resolvedCwd = c ? resolve(sessionRoot, c) : sessionRoot
|
|
137
140
|
if (!(await isGitRepo(resolvedCwd, ctx.signal))) return "not a git repository"
|
|
138
141
|
// Audit #10 P0: `git diff` menjalankan clean filter pada berkas dirty
|
|
@@ -171,7 +174,7 @@ export const gitDiffTool: Tool = {
|
|
|
171
174
|
},
|
|
172
175
|
async execute({ cwd, staged }, ctx) {
|
|
173
176
|
const sessionRoot = requireToolCwd(ctx)
|
|
174
|
-
assertCwd(cwd as string | undefined, sessionRoot)
|
|
177
|
+
assertCwd(cwd as string | undefined, sessionRoot, contextUnrestricted(ctx))
|
|
175
178
|
const resolvedCwd = (cwd as string | undefined)
|
|
176
179
|
? resolve(sessionRoot, cwd as string)
|
|
177
180
|
: sessionRoot
|
|
@@ -200,7 +203,7 @@ export const gitLogTool: Tool = {
|
|
|
200
203
|
},
|
|
201
204
|
async execute({ cwd, limit }, ctx) {
|
|
202
205
|
const sessionRoot = requireToolCwd(ctx)
|
|
203
|
-
assertCwd(cwd as string | undefined, sessionRoot)
|
|
206
|
+
assertCwd(cwd as string | undefined, sessionRoot, contextUnrestricted(ctx))
|
|
204
207
|
const resolvedCwd = (cwd as string | undefined)
|
|
205
208
|
? resolve(sessionRoot, cwd as string)
|
|
206
209
|
: sessionRoot
|
|
@@ -223,14 +226,19 @@ export const gitLogTool: Tool = {
|
|
|
223
226
|
// yang tidak bisa menilai konteksnya.
|
|
224
227
|
|
|
225
228
|
/** Nama file di argumen `paths` harus di dalam workspace. */
|
|
226
|
-
function assertPaths(
|
|
229
|
+
function assertPaths(
|
|
230
|
+
paths: unknown,
|
|
231
|
+
cwd: string | undefined,
|
|
232
|
+
sessionRoot: string,
|
|
233
|
+
relaxed = false,
|
|
234
|
+
): string[] {
|
|
227
235
|
if (paths == null) return []
|
|
228
236
|
if (!Array.isArray(paths)) throw new Error("paths must be an array of strings")
|
|
229
237
|
const root = cwd ? resolve(sessionRoot, cwd) : sessionRoot
|
|
230
238
|
const out: string[] = []
|
|
231
239
|
for (const p of paths) {
|
|
232
240
|
if (typeof p !== "string" || !p.trim()) continue
|
|
233
|
-
if (isPathOutsideRoot(p, root) || isRealPathOutsideRoot(p, root))
|
|
241
|
+
if (!relaxed && (isPathOutsideRoot(p, root) || isRealPathOutsideRoot(p, root)))
|
|
234
242
|
throw new Error(`path outside workspace: ${p}`)
|
|
235
243
|
const abs = resolve(root, p)
|
|
236
244
|
if (isSensitive(p) || isSensitive(abs)) throw new Error(`blocked sensitive file: ${p}`)
|
|
@@ -267,13 +275,14 @@ export const gitCommitTool: Tool = {
|
|
|
267
275
|
ctx.signal.throwIfAborted()
|
|
268
276
|
const c = cwd as string | undefined
|
|
269
277
|
const sessionRoot = requireToolCwd(ctx)
|
|
270
|
-
|
|
278
|
+
const relaxed = contextUnrestricted(ctx)
|
|
279
|
+
assertCwd(c, sessionRoot, relaxed)
|
|
271
280
|
const resolvedCwd = c ? resolve(sessionRoot, c) : sessionRoot
|
|
272
281
|
const msg = String(message ?? "").trim()
|
|
273
282
|
if (!msg) throw new Error("message is required")
|
|
274
283
|
if (msg.length > 4000) throw new Error("message terlalu panjang (max 4000 char)")
|
|
275
284
|
|
|
276
|
-
const files = assertPaths(paths, c, sessionRoot)
|
|
285
|
+
const files = assertPaths(paths, c, sessionRoot, relaxed)
|
|
277
286
|
if (files.length === 0 && all !== true) {
|
|
278
287
|
throw new Error(
|
|
279
288
|
"provide `paths` (specific files) or `all: true` — an empty commit is useless",
|
|
@@ -391,3 +400,52 @@ export const gitCommitTool: Tool = {
|
|
|
391
400
|
})
|
|
392
401
|
},
|
|
393
402
|
}
|
|
403
|
+
|
|
404
|
+
export const gitPushTool: Tool = {
|
|
405
|
+
name: "git_push",
|
|
406
|
+
description:
|
|
407
|
+
"Push a local branch to a remote (git push; hardened: repo hooks/filters neutralized). Gated like git_commit. In unrestricted mode git credentials (GH_TOKEN/GITHUB_TOKEN/SSH agent) are passed through.",
|
|
408
|
+
parameters: {
|
|
409
|
+
type: "object",
|
|
410
|
+
properties: {
|
|
411
|
+
remote: { type: "string", description: "remote name (default: git config)" },
|
|
412
|
+
branch: { type: "string", description: "branch to push (default: current upstream)" },
|
|
413
|
+
setUpstream: {
|
|
414
|
+
type: "boolean",
|
|
415
|
+
description: "set the pushed branch as the upstream tracking branch (-u)",
|
|
416
|
+
},
|
|
417
|
+
cwd: { type: "string" },
|
|
418
|
+
},
|
|
419
|
+
required: [],
|
|
420
|
+
additionalProperties: false,
|
|
421
|
+
},
|
|
422
|
+
async execute({ remote, branch, setUpstream, cwd }, ctx) {
|
|
423
|
+
ctx.signal.throwIfAborted()
|
|
424
|
+
const c = cwd as string | undefined
|
|
425
|
+
const sessionRoot = requireToolCwd(ctx)
|
|
426
|
+
const relaxed = contextUnrestricted(ctx)
|
|
427
|
+
assertCwd(c, sessionRoot, relaxed)
|
|
428
|
+
const resolvedCwd = c ? resolve(sessionRoot, c) : sessionRoot
|
|
429
|
+
// Tolak nilai berawalan "-" (mis. `--receive-pack=...`): argv diteruskan
|
|
430
|
+
// apa adanya ke git, jadi opsi dari argumen model = eksekusi di remote.
|
|
431
|
+
const refArg = (v: unknown, field: string): string | undefined => {
|
|
432
|
+
const s = typeof v === "string" ? v.trim() : ""
|
|
433
|
+
if (!s) return undefined
|
|
434
|
+
if (s.startsWith("-") || s.includes("\0")) throw new Error(`${field} must not start with '-'`)
|
|
435
|
+
return s
|
|
436
|
+
}
|
|
437
|
+
const remoteName = refArg(remote, "remote")
|
|
438
|
+
const branchName = refArg(branch, "branch")
|
|
439
|
+
if (!(await isGitRepo(resolvedCwd, ctx.signal))) return "not a git repository"
|
|
440
|
+
// Netralisasi hook: pre-push repo tak boleh dieksekusi. Kredensial hanya
|
|
441
|
+
// lewat saat unrestricted (relaxed).
|
|
442
|
+
const neutral = await gitFilterNeutralizers(resolvedCwd)
|
|
443
|
+
const args: string[] = [...neutral, "push"]
|
|
444
|
+
if (remoteName) args.push(remoteName)
|
|
445
|
+
if (branchName) args.push(branchName)
|
|
446
|
+
else if (setUpstream === true) throw new Error("branch is required when setUpstream:true")
|
|
447
|
+
if (setUpstream === true) args.push("--set-upstream")
|
|
448
|
+
const out = await runGit(args, resolvedCwd, ctx.signal, undefined, relaxed)
|
|
449
|
+
return out.trim() || "(push finished)"
|
|
450
|
+
},
|
|
451
|
+
}
|
package/src/tools/glob.ts
CHANGED
|
@@ -4,7 +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
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
8
8
|
|
|
9
9
|
async function walk(
|
|
10
10
|
dir: string,
|
|
@@ -14,6 +14,7 @@ async function walk(
|
|
|
14
14
|
limit: number,
|
|
15
15
|
signal: AbortSignal,
|
|
16
16
|
ignoreMatchers: ((rel: string) => boolean)[],
|
|
17
|
+
relaxed = false,
|
|
17
18
|
) {
|
|
18
19
|
if (signal.aborted) throw new Error("aborted")
|
|
19
20
|
if (out.length >= limit) return
|
|
@@ -26,10 +27,15 @@ async function walk(
|
|
|
26
27
|
// Hormati .gitignore subset (bukan hard-coded saja).
|
|
27
28
|
if (isIgnored(rel, ignoreMatchers)) continue
|
|
28
29
|
if (e.isDirectory()) {
|
|
29
|
-
await walk(full, pattern, out, root, limit, signal, ignoreMatchers)
|
|
30
|
+
await walk(full, pattern, out, root, limit, signal, ignoreMatchers, relaxed)
|
|
30
31
|
} else if (pattern.test(rel) || pattern.test(e.name)) {
|
|
31
32
|
const real = await realpath(full).catch(() => full)
|
|
32
|
-
if (
|
|
33
|
+
if (
|
|
34
|
+
(!relaxed && isPathOutsideRoot(real, resolve(root))) ||
|
|
35
|
+
isSensitive(real) ||
|
|
36
|
+
isSensitive(rel)
|
|
37
|
+
)
|
|
38
|
+
continue
|
|
33
39
|
out.push(rel)
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -80,9 +86,11 @@ export const globTool: Tool = {
|
|
|
80
86
|
},
|
|
81
87
|
async execute({ pattern, cwd, limit }, ctx) {
|
|
82
88
|
const sessionRoot = requireToolCwd(ctx)
|
|
89
|
+
const relaxed = contextUnrestricted(ctx)
|
|
83
90
|
const rawRoot = (cwd as string) ?? "."
|
|
84
91
|
const root = resolve(sessionRoot, rawRoot)
|
|
85
|
-
if (isPathOutsideRoot(root, sessionRoot))
|
|
92
|
+
if (!relaxed && isPathOutsideRoot(root, sessionRoot))
|
|
93
|
+
throw new Error(`cwd outside workspace: ${rawRoot}`)
|
|
86
94
|
const rawLim = limit as number | undefined
|
|
87
95
|
const lim = Number.isFinite(rawLim)
|
|
88
96
|
? Math.min(Math.max(Math.floor(rawLim!), 1), LIMITS.SEARCH_MAX_LIMIT)
|
|
@@ -90,7 +98,7 @@ export const globTool: Tool = {
|
|
|
90
98
|
const re = globToRegExp(pattern as string)
|
|
91
99
|
const ignoreMatchers = await loadIgnoreMatchers(root)
|
|
92
100
|
const out: string[] = []
|
|
93
|
-
await walk(root, re, out, root, lim, ctx.signal, ignoreMatchers)
|
|
101
|
+
await walk(root, re, out, root, lim, ctx.signal, ignoreMatchers, relaxed)
|
|
94
102
|
const st = await stat(root).catch(() => null)
|
|
95
103
|
if (!st) return `cwd not found: ${rawRoot}`
|
|
96
104
|
if (out.length === 0) return `no files match ${pattern} in ${rawRoot}`
|
package/src/tools/grep.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { safeReadFile } from "../lib/safe-open.ts"
|
|
|
8
8
|
import { resolveTrustedExecutable } from "../lib/trusted-exec.ts"
|
|
9
9
|
import { isPathOutsideRoot, isSensitive } from "../policy/jail.ts"
|
|
10
10
|
import { sanitizeSpawnEnv, scrubSecrets } from "../policy/scrub.ts"
|
|
11
|
-
import { requireToolCwd } from "./context.ts"
|
|
11
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
12
12
|
|
|
13
13
|
async function walkGrep(
|
|
14
14
|
dir: string,
|
|
@@ -19,6 +19,7 @@ async function walkGrep(
|
|
|
19
19
|
signal: AbortSignal,
|
|
20
20
|
includeRe?: RegExp | null,
|
|
21
21
|
ignoreMatchers: ((rel: string) => boolean)[] = [],
|
|
22
|
+
relaxed = false,
|
|
22
23
|
) {
|
|
23
24
|
if (signal.aborted) throw new Error("aborted")
|
|
24
25
|
if (out.length >= limit) return
|
|
@@ -30,20 +31,25 @@ async function walkGrep(
|
|
|
30
31
|
const rel = relative(root, full).replace(/\\/g, "/")
|
|
31
32
|
if (isIgnored(rel, ignoreMatchers)) continue
|
|
32
33
|
if (e.isDirectory()) {
|
|
33
|
-
await walkGrep(full, re, out, root, limit, signal, includeRe, ignoreMatchers)
|
|
34
|
+
await walkGrep(full, re, out, root, limit, signal, includeRe, ignoreMatchers, relaxed)
|
|
34
35
|
} else {
|
|
35
36
|
if (includeRe && !includeRe.test(rel) && !includeRe.test(e.name)) continue
|
|
36
37
|
if (/\.(png|jpg|jpeg|gif|webp|pdf|zip|exe|dll|bin)$/i.test(e.name)) continue
|
|
37
38
|
// symlink file escape check — resolve realpath and jail
|
|
38
39
|
const real = await realpath(full).catch(() => full)
|
|
39
|
-
if (
|
|
40
|
+
if (
|
|
41
|
+
(!relaxed && isPathOutsideRoot(real, resolve(root))) ||
|
|
42
|
+
isSensitive(real) ||
|
|
43
|
+
isSensitive(rel)
|
|
44
|
+
)
|
|
45
|
+
continue
|
|
40
46
|
// also skip if symlink points outside (already covered) or sensitive
|
|
41
47
|
const st = await stat(real).catch(() => null)
|
|
42
48
|
if (!st || st.size > LIMITS.GREP_FILE_MAX_BYTES) continue
|
|
43
49
|
// Baca via safeReadFile (O_NOFOLLOW + verifikasi ulang target saat
|
|
44
50
|
// open): swap symlink antara realpath di atas dan read di bawah tak
|
|
45
51
|
// lagi bisa menyelundupkan konten luar/sensitif. Gagal = lewati berkas.
|
|
46
|
-
const text = (await safeReadFile(real, root).catch(() => null)) ?? ""
|
|
52
|
+
const text = (await safeReadFile(real, root, relaxed).catch(() => null)) ?? ""
|
|
47
53
|
if (text.includes("\0")) continue
|
|
48
54
|
const lines = text.split("\n")
|
|
49
55
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -110,7 +116,7 @@ export function ripgrepAvailable(): boolean {
|
|
|
110
116
|
* cap panjang. Return null bila baris harus dibuang (sensitif / tak terparse).
|
|
111
117
|
* Diekspor untuk test.
|
|
112
118
|
*/
|
|
113
|
-
export function normalizeRgLine(line: string, root: string): string | null {
|
|
119
|
+
export function normalizeRgLine(line: string, root: string, relaxed = false): string | null {
|
|
114
120
|
// path bisa memuat ':' di Windows (C:\...), jadi cari dua ':' terakhir yang
|
|
115
121
|
// diikuti angka — bukan split(':') naif.
|
|
116
122
|
const m = /^(.*?):(\d+):(\d+):([\s\S]*)$/.exec(line)
|
|
@@ -120,7 +126,7 @@ export function normalizeRgLine(line: string, root: string): string | null {
|
|
|
120
126
|
if (!rel) return null
|
|
121
127
|
// Defense-in-depth: rg sudah dibatasi ke cwd, tapi jail tetap diterapkan
|
|
122
128
|
// supaya hasil identik dengan fallback (symlink/sensitive tetap dibuang).
|
|
123
|
-
if (isPathOutsideRoot(rel, resolve(root)) || isSensitive(rel)) return null
|
|
129
|
+
if ((!relaxed && isPathOutsideRoot(rel, resolve(root))) || isSensitive(rel)) return null
|
|
124
130
|
const body = text ?? ""
|
|
125
131
|
const cut = body.length > LIMITS.GREP_MATCH_MAX_CHARS
|
|
126
132
|
return `${rel}:${lineNo}: ${scrubSecrets(cut ? `${body.slice(0, LIMITS.GREP_MATCH_MAX_CHARS)}…` : body)}`
|
|
@@ -132,6 +138,7 @@ function runRipgrep(
|
|
|
132
138
|
limit: number,
|
|
133
139
|
signal: AbortSignal,
|
|
134
140
|
include?: string,
|
|
141
|
+
relaxed = false,
|
|
135
142
|
): Promise<string[]> {
|
|
136
143
|
const args = [
|
|
137
144
|
"--no-config", // config ripgrep dapat menjalankan --pre pada berkas workspace
|
|
@@ -198,7 +205,7 @@ function runRipgrep(
|
|
|
198
205
|
while (idx >= 0) {
|
|
199
206
|
const line = buf.slice(0, idx).replace(/\r$/, "")
|
|
200
207
|
buf = buf.slice(idx + 1)
|
|
201
|
-
const norm = normalizeRgLine(line, root)
|
|
208
|
+
const norm = normalizeRgLine(line, root, relaxed)
|
|
202
209
|
if (norm) out.push(norm)
|
|
203
210
|
if (out.length >= limit) {
|
|
204
211
|
p.kill("SIGTERM")
|
|
@@ -245,9 +252,11 @@ export const grepTool: Tool = {
|
|
|
245
252
|
},
|
|
246
253
|
async execute({ pattern, cwd, include, limit }, ctx) {
|
|
247
254
|
const sessionRoot = requireToolCwd(ctx)
|
|
255
|
+
const relaxed = contextUnrestricted(ctx)
|
|
248
256
|
const rawRoot = (cwd as string) ?? "."
|
|
249
257
|
const root = resolve(sessionRoot, rawRoot)
|
|
250
|
-
if (isPathOutsideRoot(root, sessionRoot))
|
|
258
|
+
if (!relaxed && isPathOutsideRoot(root, sessionRoot))
|
|
259
|
+
throw new Error(`cwd outside workspace: ${rawRoot}`)
|
|
251
260
|
const rawLim = limit as number | undefined
|
|
252
261
|
const lim = Number.isFinite(rawLim)
|
|
253
262
|
? Math.min(Math.max(Math.floor(rawLim!), 1), LIMITS.SEARCH_MAX_LIMIT)
|
|
@@ -270,7 +279,14 @@ export const grepTool: Tool = {
|
|
|
270
279
|
const want = lim + 1
|
|
271
280
|
if (process.env.MINICODE_GREP_ENGINE !== "js" && ripgrepAvailable()) {
|
|
272
281
|
try {
|
|
273
|
-
const hits = await runRipgrep(
|
|
282
|
+
const hits = await runRipgrep(
|
|
283
|
+
pat,
|
|
284
|
+
root,
|
|
285
|
+
want,
|
|
286
|
+
ctx.signal,
|
|
287
|
+
include as string | undefined,
|
|
288
|
+
relaxed,
|
|
289
|
+
)
|
|
274
290
|
if (hits.length === 0) return noMatch()
|
|
275
291
|
// runRipgrep tandai timeout via suffix khusus di elemen terakhir (bila timedOut)
|
|
276
292
|
return withCapMark(hits, lim)
|
|
@@ -286,7 +302,7 @@ export const grepTool: Tool = {
|
|
|
286
302
|
const incRe = include ? includeToRegExp(include as string) : null
|
|
287
303
|
const ignoreMatchers = await loadIgnoreMatchers(root)
|
|
288
304
|
const out: string[] = []
|
|
289
|
-
await walkGrep(root, re, out, root, want, ctx.signal, incRe, ignoreMatchers)
|
|
305
|
+
await walkGrep(root, re, out, root, want, ctx.signal, incRe, ignoreMatchers, relaxed)
|
|
290
306
|
return out.length === 0 ? noMatch() : withCapMark(out, lim)
|
|
291
307
|
},
|
|
292
308
|
}
|
package/src/tools/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { bashKillTool, bashOutputTool, bashTool } from "./bash.ts"
|
|
|
3
3
|
export { codeRunTool } from "./code_run.ts"
|
|
4
4
|
export { deleteFileTool } from "./delete_file.ts"
|
|
5
5
|
export { editTool } from "./edit.ts"
|
|
6
|
-
export { gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool } from "./git.ts"
|
|
6
|
+
export { gitCommitTool, gitDiffTool, gitLogTool, gitPushTool, gitStatusTool } from "./git.ts"
|
|
7
7
|
export { globTool } from "./glob.ts"
|
|
8
8
|
export { grepTool } from "./grep.ts"
|
|
9
9
|
export {
|
|
@@ -32,7 +32,7 @@ import { bashKillTool, bashOutputTool, bashTool } from "./bash.ts"
|
|
|
32
32
|
import { codeRunTool } from "./code_run.ts"
|
|
33
33
|
import { deleteFileTool } from "./delete_file.ts"
|
|
34
34
|
import { editTool } from "./edit.ts"
|
|
35
|
-
import { gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool } from "./git.ts"
|
|
35
|
+
import { gitCommitTool, gitDiffTool, gitLogTool, gitPushTool, gitStatusTool } from "./git.ts"
|
|
36
36
|
import { globTool } from "./glob.ts"
|
|
37
37
|
import { grepTool } from "./grep.ts"
|
|
38
38
|
import {
|
|
@@ -70,6 +70,7 @@ export const allTools: Tool[] = [
|
|
|
70
70
|
gitDiffTool,
|
|
71
71
|
gitLogTool,
|
|
72
72
|
gitCommitTool,
|
|
73
|
+
gitPushTool,
|
|
73
74
|
webFetchTool,
|
|
74
75
|
webSearchTool,
|
|
75
76
|
readMemoryTool,
|
package/src/tools/lsp.ts
CHANGED
|
@@ -12,7 +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
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
16
16
|
|
|
17
17
|
const SEVERITY = ["Error", "Warn", "Info", "Hint"]
|
|
18
18
|
|
|
@@ -37,16 +37,21 @@ function toUri(abs: string): string {
|
|
|
37
37
|
return pathToFileURL(abs).href
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async function readTarget(
|
|
41
|
-
|
|
40
|
+
async function readTarget(
|
|
41
|
+
file: string,
|
|
42
|
+
cwd: string,
|
|
43
|
+
relaxed = false,
|
|
44
|
+
): Promise<{ abs: string; text: string }> {
|
|
45
|
+
if (!relaxed && isPathOutsideRoot(file, cwd)) throw new Error(`path outside workspace: ${file}`)
|
|
42
46
|
if (isSensitive(file)) throw new Error(`blocked sensitive file: ${file}`)
|
|
43
47
|
const abs = isAbsolute(file) ? resolvePath(file) : resolvePath(cwd, file)
|
|
44
|
-
if (isRealPathOutsideRoot(abs, cwd))
|
|
48
|
+
if (!relaxed && isRealPathOutsideRoot(abs, cwd))
|
|
49
|
+
throw new Error(`path outside workspace: ${file}`)
|
|
45
50
|
// Baca via safeReadFile (O_NOFOLLOW + verifikasi ulang target saat open):
|
|
46
51
|
// readFile biasa membuka hasil realpath LAMA sehingga swap symlink di
|
|
47
52
|
// antara cek dan baca lolos + membaca target sensitif. relevan ganda di
|
|
48
53
|
// jalur MCP yang permission handler-nya minim (tanpa pre-check jail).
|
|
49
|
-
const text = await safeReadFile(abs, cwd)
|
|
54
|
+
const text = await safeReadFile(abs, cwd, relaxed)
|
|
50
55
|
return { abs, text }
|
|
51
56
|
}
|
|
52
57
|
|
|
@@ -74,10 +79,11 @@ interface PosArgs {
|
|
|
74
79
|
async function resolvePosition(
|
|
75
80
|
args: PosArgs,
|
|
76
81
|
cwd: string,
|
|
82
|
+
relaxed = false,
|
|
77
83
|
): Promise<{ abs: string; text: string; position: { line: number; character: number } } | string> {
|
|
78
84
|
if (getConfiguredExts().length === 0)
|
|
79
85
|
return "(no LSP servers configured — add via minicode config lsp add)"
|
|
80
|
-
const { abs, text } = await readTarget(args.file, cwd)
|
|
86
|
+
const { abs, text } = await readTarget(args.file, cwd, relaxed)
|
|
81
87
|
let position: { line: number; character: number } | null = null
|
|
82
88
|
if (args.line != null) position = { line: args.line, character: args.character ?? 0 }
|
|
83
89
|
else if (args.symbol) position = findSymbolPosition(text, args.symbol)
|
|
@@ -131,7 +137,7 @@ function posTool(
|
|
|
131
137
|
ctx.signal.throwIfAborted()
|
|
132
138
|
const cwd = requireToolCwd(ctx)
|
|
133
139
|
try {
|
|
134
|
-
const resolved = await resolvePosition(args as PosArgs, cwd)
|
|
140
|
+
const resolved = await resolvePosition(args as PosArgs, cwd, contextUnrestricted(ctx))
|
|
135
141
|
if (typeof resolved === "string") return resolved
|
|
136
142
|
const { abs, text, position } = resolved
|
|
137
143
|
const result = await raceAbort(
|
|
@@ -173,7 +179,7 @@ export const lspDiagnosticsTool: Tool = {
|
|
|
173
179
|
ctx.signal.throwIfAborted()
|
|
174
180
|
const cwd = requireToolCwd(ctx)
|
|
175
181
|
try {
|
|
176
|
-
const { abs, text } = await readTarget(String(file), cwd)
|
|
182
|
+
const { abs, text } = await readTarget(String(file), cwd, contextUnrestricted(ctx))
|
|
177
183
|
const { items } = await raceAbort(lspDiagnostics(abs, text, undefined, cwd), ctx.signal)
|
|
178
184
|
if (!items.length) return "(no diagnostics)"
|
|
179
185
|
return scrubSecrets(
|
|
@@ -230,7 +236,7 @@ export const lspSymbolsTool: Tool = {
|
|
|
230
236
|
ctx.signal.throwIfAborted()
|
|
231
237
|
const cwd = requireToolCwd(ctx)
|
|
232
238
|
try {
|
|
233
|
-
const { abs, text } = await readTarget(String(file), cwd)
|
|
239
|
+
const { abs, text } = await readTarget(String(file), cwd, contextUnrestricted(ctx))
|
|
234
240
|
const result = await raceAbort(
|
|
235
241
|
lspCall(
|
|
236
242
|
abs,
|