minicode-ai 0.23.0 → 0.26.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 +5 -3
- package/cli/commands/config.ts +123 -0
- package/cli/setup.ts +107 -8
- package/cli/tui.ts +28 -2
- package/docs/README.md +2 -2
- package/docs/SUMMARY.md +10 -19
- package/docs/TERMINAL_CONTRACT.md +113 -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 +103 -5
- package/docs/environment.md +4 -0
- package/docs/getting-started.md +69 -5
- 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/app/session.ts +187 -17
- package/src/config.ts +21 -8
- package/src/constants.ts +17 -1
- package/src/lib/net.ts +6 -15
- package/src/lib/public-http.ts +128 -0
- package/src/lib/safe-open.ts +21 -12
- package/src/memory/vector.ts +0 -31
- package/src/policy/auto-resume.ts +63 -0
- package/src/policy/compaction.ts +354 -70
- package/src/policy/context-budget.ts +4 -6
- package/src/policy/context-window-assign.ts +114 -0
- package/src/policy/context-window-catalog.ts +4 -1
- package/src/policy/context-window-presets.ts +165 -0
- package/src/policy/context-window.ts +19 -37
- package/src/policy/context.ts +11 -9
- package/src/policy/executor.ts +69 -27
- package/src/policy/microcompact.ts +76 -15
- package/src/policy/no-progress.ts +1 -1
- package/src/policy/permission.ts +5 -0
- package/src/policy/recovery-budget.ts +281 -0
- package/src/policy/scrub.ts +15 -2
- package/src/policy/step-escalation.ts +82 -0
- package/src/policy/tokenizer-registry.ts +1 -0
- 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 +40 -7
- package/src/providers/provision.ts +23 -1
- package/src/runtime/child-execution.ts +4 -2
- package/src/runtime/execution-backend.ts +3 -0
- package/src/sandbox/os.ts +53 -9
- package/src/session/context-assembly.ts +11 -7
- package/src/session/persistence.ts +19 -3
- 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 +68 -17
- package/src/tools/code_run.ts +19 -20
- 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 +5 -1
- package/src/tools/todo.ts +4 -8
- package/src/tools/web_fetch.ts +13 -19
- package/src/tools/write_file.ts +4 -3
- package/src/ui/approval/prompt.ts +226 -77
- package/src/ui/assistant/simple.ts +61 -10
- package/src/ui/footer.ts +41 -29
- package/src/ui/i18n/en.ts +7 -0
- package/src/ui/i18n/id.ts +7 -0
- package/src/ui/input/prompt-engine.ts +53 -21
- package/src/ui/render/activity-group.ts +9 -0
- package/src/ui/render/activity-panel.ts +20 -2
- 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 +118 -20
- package/src/ui/tui/transcript.ts +179 -29
- package/vendor/minicore/src/core/loop.ts +20 -1
- package/vendor/minicore/src/core/session.ts +6 -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/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,
|
package/src/tools/move_file.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { dirname } from "node:path"
|
|
|
3
3
|
import type { Tool } from "#minicore"
|
|
4
4
|
import { resolveSafePath } from "../lib/safe-open.ts"
|
|
5
5
|
import { trashFile } from "../lib/trash.ts"
|
|
6
|
-
import { requireToolCwd } from "./context.ts"
|
|
6
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
7
7
|
|
|
8
8
|
export const moveFileTool: Tool = {
|
|
9
9
|
name: "move_file",
|
|
@@ -21,16 +21,17 @@ export const moveFileTool: Tool = {
|
|
|
21
21
|
async execute({ from, to }, ctx) {
|
|
22
22
|
ctx.signal.throwIfAborted()
|
|
23
23
|
const root = requireToolCwd(ctx)
|
|
24
|
+
const relaxed = contextUnrestricted(ctx)
|
|
24
25
|
const f = from as string
|
|
25
26
|
const t = to as string
|
|
26
27
|
// Verifikasi kedua ujung via pemilik tunggal (logis + target nyata) —
|
|
27
28
|
// detail di safe-open.ts. Beda dengan tool satu-berkas hanya karena
|
|
28
29
|
// move punya dua ujung; substring pesan ("outside workspace",
|
|
29
30
|
// "blocked sensitive file") dipertahankan agar test regex tetap hijau.
|
|
30
|
-
const { abs: absFrom, real: realFrom } = await resolveSafePath(f, root)
|
|
31
|
+
const { abs: absFrom, real: realFrom } = await resolveSafePath(f, root, relaxed)
|
|
31
32
|
const st = await stat(realFrom).catch(() => null)
|
|
32
33
|
if (!st) throw new Error(`source not found: ${f}`)
|
|
33
|
-
const { abs: absTo } = await resolveSafePath(t, root)
|
|
34
|
+
const { abs: absTo } = await resolveSafePath(t, root, relaxed)
|
|
34
35
|
await mkdir(dirname(absTo), { recursive: true, mode: 0o700 }).catch(() => {})
|
|
35
36
|
// S3 — dest yang sudah ada dibackup ke trash dulu (jangan timpa diam-diam).
|
|
36
37
|
// absTo sudah terverifikasi nyata oleh resolveSafePath, jadi tak perlu
|
package/src/tools/patch.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Tool } from "#minicore"
|
|
|
3
3
|
import { LIMITS } from "../constants.ts"
|
|
4
4
|
import { atomicWriteText } from "../lib/atomic-write.ts"
|
|
5
5
|
import { assertSafeWriteTarget, resolveSafePath, safeReadFile } from "../lib/safe-open.ts"
|
|
6
|
-
import { requireToolCwd } from "./context.ts"
|
|
6
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
7
7
|
import { flexibleMatch } from "./edit.ts"
|
|
8
8
|
|
|
9
9
|
// Apply SEARCH/REPLACE block (a la Aider) ke file. Search block harus match
|
|
@@ -40,16 +40,17 @@ export const applyPatchTool: Tool = {
|
|
|
40
40
|
ctx.signal.throwIfAborted()
|
|
41
41
|
const p = path as string
|
|
42
42
|
const root = requireToolCwd(ctx)
|
|
43
|
+
const relaxed = contextUnrestricted(ctx)
|
|
43
44
|
// Verifikasi path terpusat (logis + target nyata) — detail di safe-open.ts.
|
|
44
|
-
const { abs, real: realAbs } = await resolveSafePath(p, root)
|
|
45
|
+
const { abs, real: realAbs } = await resolveSafePath(p, root, relaxed)
|
|
45
46
|
// Tolak menimpa symlink final (swap antara cek dan tulis gagal tutup).
|
|
46
|
-
await assertSafeWriteTarget(abs, root)
|
|
47
|
+
await assertSafeWriteTarget(abs, root, relaxed)
|
|
47
48
|
const st = await stat(realAbs).catch(() => null)
|
|
48
49
|
if (!st) throw new Error(`file not found: ${p}`)
|
|
49
50
|
if (st.size > LIMITS.READ_FILE_MAX_BYTES) throw new Error(`file too large: ${p} (${st.size})`)
|
|
50
51
|
|
|
51
52
|
// Pakai safeReadFile (O_NOFOLLOW) agar swap symlink di antara cek dan baca gagal ELOOP.
|
|
52
|
-
let content = await safeReadFile(abs, root)
|
|
53
|
+
let content = await safeReadFile(abs, root, relaxed)
|
|
53
54
|
const patchList = patches as { search: string; replace: string }[]
|
|
54
55
|
if (patchList.length > 50) throw new Error(`too many patches: ${patchList.length} (max 50)`)
|
|
55
56
|
const applied: string[] = []
|
package/src/tools/read_file.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Tool } from "#minicore"
|
|
|
4
4
|
import { LIMITS } from "../constants.ts"
|
|
5
5
|
import { safeOpenRead } from "../lib/safe-open.ts"
|
|
6
6
|
import { scrubSecrets } from "../policy/scrub.ts"
|
|
7
|
-
import { requireToolCwd } from "./context.ts"
|
|
7
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
8
8
|
|
|
9
9
|
// defense-in-depth: also jail inside tool (permission layer is primary)
|
|
10
10
|
|
|
@@ -168,13 +168,14 @@ export const readFileTool: Tool = {
|
|
|
168
168
|
ctx.signal.throwIfAborted()
|
|
169
169
|
const p = path as string
|
|
170
170
|
const root = requireToolCwd(ctx)
|
|
171
|
+
const relaxed = contextUnrestricted(ctx)
|
|
171
172
|
const abs = isAbsolute(p) ? resolve(p) : resolve(root, p)
|
|
172
173
|
// Semua verifikasi path (jail + sensitif + O_NOFOLLOW) terjadi di SATU
|
|
173
174
|
// titik saat open — detail di safe-open.ts. Tidak ada resolve/stat
|
|
174
175
|
// terpisah: handle dipakai untuk stat (cap ukuran) lalu baca.
|
|
175
176
|
let handle: Awaited<ReturnType<typeof safeOpenRead>>["handle"]
|
|
176
177
|
try {
|
|
177
|
-
;({ handle } = await safeOpenRead(abs, root))
|
|
178
|
+
;({ handle } = await safeOpenRead(abs, root, relaxed))
|
|
178
179
|
} catch (e) {
|
|
179
180
|
// ENOENT → pesan seragam; sisanya (jail/sensitif/ELOOP/raw IO) apa adanya
|
|
180
181
|
const msg = (e as Error).message ?? ""
|
package/src/tools/read_image.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Tool } from "#minicore"
|
|
|
3
3
|
import { LIMITS } from "../constants.ts"
|
|
4
4
|
import { safeOpenRead } from "../lib/safe-open.ts"
|
|
5
5
|
import { estimateImageTokens } from "../policy/context.ts"
|
|
6
|
-
import { requireToolCwd } from "./context.ts"
|
|
6
|
+
import { contextUnrestricted, requireToolCwd } from "./context.ts"
|
|
7
7
|
|
|
8
8
|
// Batas b64 = batas truncate kernel yang sebenarnya: toolResultMaxTokens
|
|
9
9
|
// (default 4096) × DEFAULT_CHARS_PER_TOKEN (4) = 16.384 chars, dengan margin
|
|
@@ -27,13 +27,14 @@ export const readImageTool: Tool = {
|
|
|
27
27
|
ctx.signal.throwIfAborted()
|
|
28
28
|
const p = path as string
|
|
29
29
|
const root = requireToolCwd(ctx)
|
|
30
|
+
const relaxed = contextUnrestricted(ctx)
|
|
30
31
|
const abs = isAbsolute(p) ? resolve(p) : resolve(root, p)
|
|
31
32
|
// TOCTOU-safe: safeOpenRead = realpath(abs) → cek jail+sensitif di dalam
|
|
32
33
|
// root → open(preReal, O_NOFOLLOW). Bukan open(abs) yang bisa di-swap jadi
|
|
33
34
|
// symlink luar di antara cek dan open — semua verifikasi ada di titik ini.
|
|
34
35
|
let handle: Awaited<ReturnType<typeof safeOpenRead>>["handle"]
|
|
35
36
|
try {
|
|
36
|
-
;({ handle } = await safeOpenRead(abs, root))
|
|
37
|
+
;({ handle } = await safeOpenRead(abs, root, relaxed))
|
|
37
38
|
} catch (e) {
|
|
38
39
|
// ENOENT → pesan seragam; sisanya (jail/sensitif/ELOOP/raw IO) apa adanya
|
|
39
40
|
const msg = (e as Error).message ?? ""
|
package/src/tools/task.ts
CHANGED
|
@@ -294,9 +294,12 @@ export const delegateTaskTool: Tool = {
|
|
|
294
294
|
// Jalur autonomous TIDAK memakai M7: mode-less (readonly tetap) + default 8
|
|
295
295
|
// tak representable tanpa mengarang mode/grant. Kontrak dipin test
|
|
296
296
|
// `test/p9-admission-boundaries.test.ts`; jangan menyeragamkan tanpa ADR.
|
|
297
|
+
// [T-008] Cap eksplisit sub-agent memakai konstanta SENDIRI (50), bukan
|
|
298
|
+
// `DEFAULT_MAX_STEPS` sesi utama (200). Menyamakannya = memperluas
|
|
299
|
+
// kewenangan delegasi diam-diam saat default sesi utama naik.
|
|
297
300
|
const cap =
|
|
298
301
|
Number.isFinite(requested) && requested > 0
|
|
299
|
-
? Math.min(Math.floor(requested), LIMITS.
|
|
302
|
+
? Math.min(Math.floor(requested), LIMITS.SUB_AGENT_MAX_STEPS)
|
|
300
303
|
: m === "explore"
|
|
301
304
|
? LIMITS.SUB_AGENT_BUDGET_EXPLORE
|
|
302
305
|
: LIMITS.SUB_AGENT_BUDGET_PLAN
|
|
@@ -316,6 +319,7 @@ export const delegateTaskTool: Tool = {
|
|
|
316
319
|
"bash_output",
|
|
317
320
|
"bash_kill",
|
|
318
321
|
"git_commit",
|
|
322
|
+
"git_push",
|
|
319
323
|
"submit_result",
|
|
320
324
|
].includes(t.name),
|
|
321
325
|
)
|
package/src/tools/todo.ts
CHANGED
|
@@ -416,7 +416,7 @@ export function renderTodos(todos: TodoItem[]): string {
|
|
|
416
416
|
* kebenaran; kebijakan hanya berlaku di jalur tulis (`todo_write`) dan di
|
|
417
417
|
* rekonsiliasi eksplisit (`reconcileCompletionEvidence`) yang menulis balik.
|
|
418
418
|
*/
|
|
419
|
-
export async function loadTodos(sessionId: string, cwd
|
|
419
|
+
export async function loadTodos(sessionId: string, cwd: string): Promise<TodoItem[]> {
|
|
420
420
|
// N2: try the canonical name first, then the legacy name. A file written by an
|
|
421
421
|
// older process only exists at the legacy path, so without this fallback a
|
|
422
422
|
// workspace that was upgraded but never ran `todo_write` again would lose its
|
|
@@ -479,11 +479,7 @@ export async function reconcileCompletionEvidence(
|
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
export async function saveTodos(
|
|
483
|
-
sessionId: string,
|
|
484
|
-
todos: TodoItem[],
|
|
485
|
-
cwd = process.cwd(),
|
|
486
|
-
): Promise<void> {
|
|
482
|
+
export async function saveTodos(sessionId: string, todos: TodoItem[], cwd: string): Promise<void> {
|
|
487
483
|
const p = todoPath(sessionId, cwd)
|
|
488
484
|
await mkdir(resolve(cwd, ".minicode", "todos"), { recursive: true }).catch(() => {})
|
|
489
485
|
await atomicWriteText(p, JSON.stringify({ sessionId, updatedAt: Date.now(), todos }, null, 2))
|
|
@@ -527,7 +523,7 @@ export function renderPlan(sessionId: string, todos: TodoItem[]): string {
|
|
|
527
523
|
export async function savePlanSnapshot(
|
|
528
524
|
sessionId: string,
|
|
529
525
|
todos: TodoItem[],
|
|
530
|
-
cwd
|
|
526
|
+
cwd: string,
|
|
531
527
|
): Promise<string> {
|
|
532
528
|
const p = planPath(sessionId, cwd)
|
|
533
529
|
await mkdir(resolve(cwd, ".minicode", "plans"), { recursive: true }).catch(() => {})
|
|
@@ -535,7 +531,7 @@ export async function savePlanSnapshot(
|
|
|
535
531
|
return p
|
|
536
532
|
}
|
|
537
533
|
|
|
538
|
-
export async function loadPlan(sessionId: string, cwd
|
|
534
|
+
export async function loadPlan(sessionId: string, cwd: string): Promise<string | null> {
|
|
539
535
|
try {
|
|
540
536
|
return await readFile(planPath(sessionId, cwd), "utf8")
|
|
541
537
|
} catch {
|