minicode-ai 0.10.0 → 0.11.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/AGENTS.md +45 -0
- package/CHANGELOG.md +59 -4
- package/PLAN.md +491 -0
- package/README.md +2 -2
- package/cli/commands/acp.ts +485 -0
- package/cli/commands/auth.ts +7 -4
- package/cli/commands/config.ts +41 -27
- package/cli/commands/exec.ts +33 -12
- package/cli/commands/mcp.ts +3 -2
- package/cli/commands/memory.ts +1 -1
- package/cli/commands/pricing.ts +6 -4
- package/cli/commands/providers.ts +18 -8
- package/cli/commands/sessions.ts +11 -4
- package/cli/commands/skills.ts +3 -3
- package/cli/commands/stats.ts +3 -1
- package/cli/commands.ts +6 -0
- package/cli/index.ts +82 -57
- package/cli/model-manager.ts +6 -1
- package/cli/router.ts +7 -0
- package/cli/setup.ts +341 -5
- package/cli/tui.ts +54 -18
- package/docs/ARCHITECTURE.html +29 -22
- package/docs/CONTROL-PLANE-MAP.md +139 -0
- package/docs/HARNESS.md +150 -0
- package/docs/PLAN_UIUX_V6.md +209 -0
- package/docs/README.md +1 -1
- package/docs/SUMMARY.md +52 -0
- package/docs/TERMINAL_CONTRACT.md +367 -0
- package/docs/UI_RENDER_PIPELINE.md +165 -0
- package/docs/USAGE.md +11 -0
- package/docs/agents.md +31 -0
- package/docs/architecture.md +3 -3
- package/docs/choosing-mode.md +34 -0
- package/docs/cli.md +130 -0
- package/docs/concepts.md +53 -0
- package/docs/config-providers.md +87 -0
- package/docs/config.md +63 -0
- package/docs/contributing.md +79 -0
- package/docs/environment.md +95 -0
- package/docs/exec.md +73 -0
- package/docs/getting-started.md +102 -0
- package/docs/glossary.md +37 -0
- package/docs/mcp-lsp.md +54 -0
- package/docs/memory-sessions.md +63 -0
- package/docs/policy-sandbox.md +72 -0
- package/docs/pricing-budget.md +49 -0
- package/docs/quickstart.md +60 -0
- package/docs/repl.md +67 -0
- package/docs/security-model.md +95 -0
- package/docs/security.md +91 -0
- package/docs/skills.md +48 -0
- package/docs/terminal.md +79 -0
- package/docs/tools.md +123 -0
- package/docs/troubleshooting.md +40 -0
- package/docs/verify-benchmark.md +58 -0
- package/package.json +8 -5
- package/src/app/provider-layer.ts +12 -4
- package/src/app/session.ts +6 -0
- package/src/app/tool-layer.ts +2 -1
- package/src/constants.ts +35 -0
- package/src/lib/net.ts +6 -1
- package/src/lsp/client.ts +41 -8
- package/src/mcp/http-transport.ts +52 -15
- package/src/mcp/transport.ts +32 -1
- package/src/memory/files.ts +6 -5
- package/src/policy/allowlist.ts +1 -1
- package/src/policy/bash-guard.ts +154 -14
- package/src/policy/compaction.ts +57 -3
- package/src/policy/context.ts +4 -0
- package/src/policy/jail.ts +49 -4
- package/src/policy/permission.ts +152 -12
- package/src/policy/pricing.ts +12 -9
- package/src/presentation/adapter.ts +721 -0
- package/src/presentation/events.ts +324 -0
- package/src/presentation/label.ts +140 -0
- package/src/presentation/model.ts +172 -0
- package/src/presentation/reducer.ts +486 -0
- package/src/presentation/store.ts +256 -0
- package/src/providers/anthropic.ts +22 -4
- package/src/providers/detect.ts +2 -1
- package/src/providers/router.ts +13 -0
- package/src/repo/repomap.ts +2 -29
- package/src/session/checkpoint.ts +27 -9
- package/src/session/journal.ts +27 -5
- package/src/skills/loader.ts +88 -5
- package/src/telemetry/trace.ts +36 -15
- package/src/tools/ask_user.ts +73 -4
- package/src/tools/bash.ts +15 -17
- package/src/tools/glob.ts +10 -11
- package/src/tools/lsp.ts +3 -56
- package/src/tools/memory.ts +13 -12
- package/src/tools/task.ts +1 -0
- package/src/ui/approval/prompt.ts +14 -6
- package/src/ui/assistant/simple.ts +137 -26
- package/src/ui/assistant/turn-status.ts +16 -3
- package/src/ui/contract.ts +119 -0
- package/src/ui/footer.ts +21 -2
- package/src/ui/i18n/en.ts +34 -6
- package/src/ui/i18n/id.ts +34 -6
- package/src/ui/i18n/locale.ts +3 -1
- package/src/ui/input/input.ts +51 -4
- package/src/ui/input/prompt-engine.ts +46 -4
- package/src/ui/render/collapse.ts +13 -13
- package/src/ui/render/diff.ts +7 -2
- package/src/ui/render/format.ts +16 -8
- package/src/ui/render/highlight.ts +7 -3
- package/src/ui/render/markdown.ts +5 -1
- package/src/ui/render/sanitize.ts +29 -2
- package/src/ui/render/table.ts +8 -5
- package/src/ui/render/theme.ts +18 -4
- package/src/ui/render/width.ts +89 -10
- package/src/ui/runtime/motion.ts +16 -0
- package/src/ui/runtime/screen.ts +45 -0
- package/src/ui/runtime/spinner.ts +50 -4
- package/src/ui/runtime/statusline.ts +50 -1
- package/src/ui/screens/form.ts +42 -15
- package/src/ui/screens/model-manager.ts +26 -18
- package/src/ui/screens/picker.ts +47 -23
- package/src/ui/screens/provider-manager.ts +18 -12
- package/src/ui/screens/wizard.ts +24 -8
- package/src/ui/tui/app.ts +233 -27
- package/src/ui/tui/transcript.ts +269 -65
- package/vendor/minicore/LICENSE +21 -0
- package/vendor/minicore/VENDOR.md +6 -3
- package/vendor/minicore/package.json +6 -3
- package/vendor/minicore/src/core/loop.ts +12 -2
- package/vendor/minicore/src/core/snapshot.ts +4 -0
- package/vendor/minicore/src/providers/openai-compat.ts +76 -25
package/src/telemetry/trace.ts
CHANGED
|
@@ -45,6 +45,10 @@ export interface StepTrace {
|
|
|
45
45
|
errors?: number
|
|
46
46
|
/** mode sandbox saat step berjalan — isolasi apa yang sebenarnya aktif. */
|
|
47
47
|
sandbox?: string
|
|
48
|
+
/** F1.2: token kumulatif SESI saat baris ditulis (usage.getSession()).
|
|
49
|
+
* Monoton naik per sesi — replay file menghasilkan kurva token tanpa
|
|
50
|
+
* perlu join ke traces.jsonl. Opsional: baris lama tak memilikinya. */
|
|
51
|
+
totalTokens?: number
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
// Kunci argumen yang aman diringkas; `content`/`code`/body lain SENGAJA
|
|
@@ -127,6 +131,24 @@ function telemetryEnabled(): boolean {
|
|
|
127
131
|
return v !== "0" && v !== "false" && v !== "off"
|
|
128
132
|
}
|
|
129
133
|
|
|
134
|
+
// Mutex per-file untuk mencegah race condition pada rotasi konkuren (A6-fix).
|
|
135
|
+
const rotationLocks = new Map<string, Promise<void>>()
|
|
136
|
+
|
|
137
|
+
async function rotateFile(file: string): Promise<void> {
|
|
138
|
+
const currentLock = rotationLocks.get(file) ?? Promise.resolve()
|
|
139
|
+
const nextLock = currentLock.then(async () => {
|
|
140
|
+
try {
|
|
141
|
+
const txt = await readFile(file, "utf8")
|
|
142
|
+
const lines = txt.split("\n").filter(Boolean)
|
|
143
|
+
if (lines.length > LIMITS.TRACE_MAX_LINES) {
|
|
144
|
+
await atomicWriteText(file, `${lines.slice(-LIMITS.TRACE_MAX_LINES).join("\n")}\n`)
|
|
145
|
+
}
|
|
146
|
+
} catch {}
|
|
147
|
+
})
|
|
148
|
+
rotationLocks.set(file, nextLock)
|
|
149
|
+
await nextLock
|
|
150
|
+
}
|
|
151
|
+
|
|
130
152
|
// Telemetry ringan: satu baris JSON per run di .minicode/traces.jsonl.
|
|
131
153
|
// Tanpa OTel — cukup untuk agregasi manual / metrik sederhana.
|
|
132
154
|
export async function writeTrace(cwd: string | undefined, trace: RunTrace): Promise<void> {
|
|
@@ -144,14 +166,8 @@ export async function writeTrace(cwd: string | undefined, trace: RunTrace): Prom
|
|
|
144
166
|
}
|
|
145
167
|
await appendFile(file, `${JSON.stringify(safe)}\n`, "utf8")
|
|
146
168
|
await chmod(file, 0o600).catch(() => {})
|
|
147
|
-
// Rotate: keep TRACE_MAX_LINES baris terakhir (
|
|
148
|
-
|
|
149
|
-
const txt = await readFile(file, "utf8")
|
|
150
|
-
const lines = txt.split("\n").filter(Boolean)
|
|
151
|
-
if (lines.length > LIMITS.TRACE_MAX_LINES) {
|
|
152
|
-
await atomicWriteText(file, `${lines.slice(-LIMITS.TRACE_MAX_LINES).join("\n")}\n`)
|
|
153
|
-
}
|
|
154
|
-
} catch {}
|
|
169
|
+
// Rotate: keep TRACE_MAX_LINES baris terakhir (serialized via rotateFile)
|
|
170
|
+
await rotateFile(file)
|
|
155
171
|
} catch {}
|
|
156
172
|
}
|
|
157
173
|
|
|
@@ -164,13 +180,7 @@ export async function writeStepTrace(cwd: string | undefined, step: StepTrace):
|
|
|
164
180
|
const safe: StepTrace = { ...step, ...(step.args ? { args: scrubSecrets(step.args) } : {}) }
|
|
165
181
|
await appendFile(file, `${JSON.stringify(safe)}\n`, "utf8")
|
|
166
182
|
await chmod(file, 0o600).catch(() => {})
|
|
167
|
-
|
|
168
|
-
const txt = await readFile(file, "utf8")
|
|
169
|
-
const lines = txt.split("\n").filter(Boolean)
|
|
170
|
-
if (lines.length > LIMITS.TRACE_MAX_LINES) {
|
|
171
|
-
await atomicWriteText(file, `${lines.slice(-LIMITS.TRACE_MAX_LINES).join("\n")}\n`)
|
|
172
|
-
}
|
|
173
|
-
} catch {}
|
|
183
|
+
await rotateFile(file)
|
|
174
184
|
} catch {}
|
|
175
185
|
}
|
|
176
186
|
|
|
@@ -234,6 +244,9 @@ export interface StepSummary {
|
|
|
234
244
|
topErrors: { tool: string; n: number }[]
|
|
235
245
|
sandboxes: string[]
|
|
236
246
|
topDenyReasons: { reason: string; n: number }[]
|
|
247
|
+
/** F1.2: max totalTokens antar baris = taksiran akhir kumulatif sesi.
|
|
248
|
+
* 0 bila tak ada baris bertoken (format lama). */
|
|
249
|
+
peakTotalTokens: number
|
|
237
250
|
}
|
|
238
251
|
|
|
239
252
|
export function summarizeStepTraces(rows: StepTrace[]): StepSummary {
|
|
@@ -245,6 +258,7 @@ export function summarizeStepTraces(rows: StepTrace[]): StepSummary {
|
|
|
245
258
|
const errBy = new Map<string, number>()
|
|
246
259
|
const reasonBy = new Map<string, number>()
|
|
247
260
|
const sandboxes = new Set<string>()
|
|
261
|
+
let peakTotalTokens = 0
|
|
248
262
|
for (const t of tools) {
|
|
249
263
|
const name = t.tool ?? "?"
|
|
250
264
|
if (t.denied) {
|
|
@@ -269,6 +283,12 @@ export function summarizeStepTraces(rows: StepTrace[]): StepSummary {
|
|
|
269
283
|
.sort((a, b) => b[1] - a[1])
|
|
270
284
|
.slice(0, 3)
|
|
271
285
|
.map(([reason, n]) => ({ reason, n }))
|
|
286
|
+
// Peak dihitung dari SEMUA baris (tool + step) — baris step-kind juga
|
|
287
|
+
// membawa totalTokens kumulatif; baris lama (tanpa field) diabaikan.
|
|
288
|
+
for (const t of rows) {
|
|
289
|
+
const v = t.totalTokens
|
|
290
|
+
if (typeof v === "number" && Number.isFinite(v) && v > peakTotalTokens) peakTotalTokens = v
|
|
291
|
+
}
|
|
272
292
|
return {
|
|
273
293
|
tools: tools.length,
|
|
274
294
|
ok,
|
|
@@ -279,5 +299,6 @@ export function summarizeStepTraces(rows: StepTrace[]): StepSummary {
|
|
|
279
299
|
topErrors: top(errBy),
|
|
280
300
|
sandboxes: [...sandboxes],
|
|
281
301
|
topDenyReasons: topReason,
|
|
302
|
+
peakTotalTokens,
|
|
282
303
|
}
|
|
283
304
|
}
|
package/src/tools/ask_user.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Tool } from "#minicore"
|
|
2
|
+
import type { ApprovalEventHook, ApprovalHookEvent } from "../presentation/events.ts"
|
|
2
3
|
|
|
3
4
|
// Tanya user di tengah run — untuk pilihan yang tidak bisa diputuskan model
|
|
4
5
|
// sendiri (ambiguitas kebutuhan, kredensial, "lanjut/tidak").
|
|
@@ -16,6 +17,26 @@ export function setAskTextFn(fn: AskTextFn | undefined): void {
|
|
|
16
17
|
askTextFn = fn
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
// Hook observability Fase 1 (pola sama seperti setAskTextFn): pertanyaan dan
|
|
21
|
+
// hasilnya dilaporkan sebagai approval.requested/settled TANPA mengubah
|
|
22
|
+
// perilaku fail-closed tool. toolCallId absen di sini — ToolContext kernel
|
|
23
|
+
// tidak membawa id call sendiri, dan pertanyaan ini memang ditujukan ke user
|
|
24
|
+
// langsung, bukan gate atas tool lain.
|
|
25
|
+
let askApprovalHook: ApprovalEventHook | undefined
|
|
26
|
+
let askApprovalCounter = 0
|
|
27
|
+
|
|
28
|
+
export function setAskApprovalHook(fn: ApprovalEventHook | undefined): void {
|
|
29
|
+
askApprovalHook = fn
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function emitAskApproval(e: ApprovalHookEvent): void {
|
|
33
|
+
try {
|
|
34
|
+
askApprovalHook?.(e)
|
|
35
|
+
} catch {
|
|
36
|
+
// Observability tak boleh menggagalkan tool.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
19
40
|
export const askUserTool: Tool = {
|
|
20
41
|
name: "ask_user",
|
|
21
42
|
description:
|
|
@@ -44,11 +65,59 @@ export const askUserTool: Tool = {
|
|
|
44
65
|
: undefined
|
|
45
66
|
// Tanpa view ter-inject atau di luar TTY: tolak, jangan gantung.
|
|
46
67
|
// Model harus melanjutkan dengan asumsi paling aman, bukan menunggu.
|
|
47
|
-
|
|
68
|
+
const approvalId = `ap_${++askApprovalCounter}`
|
|
69
|
+
const callInfo = { name: "ask_user", args: { question: q, options: opts } }
|
|
70
|
+
if (!askTextFn) {
|
|
71
|
+
emitAskApproval({ kind: "requested", approvalId, call: callInfo, via: "system" })
|
|
72
|
+
emitAskApproval({
|
|
73
|
+
kind: "settled",
|
|
74
|
+
approvalId,
|
|
75
|
+
call: callInfo,
|
|
76
|
+
outcome: { decision: "deny", by: "system", reason: "no-view" },
|
|
77
|
+
})
|
|
48
78
|
throw new Error("ask_user unavailable: no question view injected (headless run?)")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
}
|
|
80
|
+
if (!process.stdin.isTTY) {
|
|
81
|
+
emitAskApproval({ kind: "requested", approvalId, call: callInfo, via: "system" })
|
|
82
|
+
emitAskApproval({
|
|
83
|
+
kind: "settled",
|
|
84
|
+
approvalId,
|
|
85
|
+
call: callInfo,
|
|
86
|
+
outcome: { decision: "deny", by: "system", reason: "headless" },
|
|
87
|
+
})
|
|
88
|
+
throw new Error("ask_user unavailable: needs an interactive terminal")
|
|
89
|
+
}
|
|
90
|
+
emitAskApproval({ kind: "requested", approvalId, call: callInfo, via: "prompt" })
|
|
91
|
+
let answer: string | null
|
|
92
|
+
try {
|
|
93
|
+
answer = await askTextFn(q, opts)
|
|
94
|
+
} catch (e) {
|
|
95
|
+
const aborted = (e instanceof Error && e.name === "AbortError") || ctx.signal.aborted
|
|
96
|
+
emitAskApproval({
|
|
97
|
+
kind: "settled",
|
|
98
|
+
approvalId,
|
|
99
|
+
call: callInfo,
|
|
100
|
+
outcome: aborted
|
|
101
|
+
? { decision: "cancelled", by: "system", reason: "parent-aborted" }
|
|
102
|
+
: { decision: "deny", by: "system", reason: "prompt-error" },
|
|
103
|
+
})
|
|
104
|
+
throw e
|
|
105
|
+
}
|
|
106
|
+
if (answer == null || !answer.trim()) {
|
|
107
|
+
emitAskApproval({
|
|
108
|
+
kind: "settled",
|
|
109
|
+
approvalId,
|
|
110
|
+
call: callInfo,
|
|
111
|
+
outcome: { decision: "deny", by: "user", reason: "declined" },
|
|
112
|
+
})
|
|
113
|
+
throw new Error("ask_user cancelled (empty answer)")
|
|
114
|
+
}
|
|
115
|
+
emitAskApproval({
|
|
116
|
+
kind: "settled",
|
|
117
|
+
approvalId,
|
|
118
|
+
call: callInfo,
|
|
119
|
+
outcome: { decision: "allow", by: "user" },
|
|
120
|
+
})
|
|
52
121
|
return answer.trim().slice(0, 4000)
|
|
53
122
|
},
|
|
54
123
|
}
|
package/src/tools/bash.ts
CHANGED
|
@@ -247,8 +247,8 @@ export const bashTool: Tool = {
|
|
|
247
247
|
})
|
|
248
248
|
const text = scrubSecrets(res.output)
|
|
249
249
|
if (res.code !== 0 && res.code !== null)
|
|
250
|
-
return `exit ${res.code}\n${capMarked(text,
|
|
251
|
-
return capMarked(text,
|
|
250
|
+
return `exit ${res.code}\n${capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)}`
|
|
251
|
+
return capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)
|
|
252
252
|
}
|
|
253
253
|
if (sandboxStrict() || !sandboxExplicitFallbackAllowed()) {
|
|
254
254
|
throw new Error(
|
|
@@ -272,8 +272,8 @@ export const bashTool: Tool = {
|
|
|
272
272
|
})
|
|
273
273
|
const text = scrubSecrets(res.output)
|
|
274
274
|
if (res.code !== 0 && res.code !== null)
|
|
275
|
-
return `exit ${res.code}\n${capMarked(text,
|
|
276
|
-
return capMarked(text,
|
|
275
|
+
return `exit ${res.code}\n${capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)}`
|
|
276
|
+
return capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)
|
|
277
277
|
}
|
|
278
278
|
if (sandboxStrict() || !sandboxExplicitFallbackAllowed()) {
|
|
279
279
|
throw new Error(
|
|
@@ -331,20 +331,18 @@ export const bashTool: Tool = {
|
|
|
331
331
|
killTree(p)
|
|
332
332
|
}, 2000)
|
|
333
333
|
}, timeout)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
()
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
},
|
|
345
|
-
{ once: true },
|
|
346
|
-
)
|
|
334
|
+
const onAbort = () => {
|
|
335
|
+
clearTimeout(t)
|
|
336
|
+
if (killTimer) clearTimeout(killTimer)
|
|
337
|
+
if (process.platform === "win32") killTree(p)
|
|
338
|
+
else p.kill("SIGTERM")
|
|
339
|
+
killTimer = setTimeout(() => {
|
|
340
|
+
killTree(p)
|
|
341
|
+
}, 1000)
|
|
342
|
+
}
|
|
343
|
+
ctx.signal.addEventListener("abort", onAbort, { once: true })
|
|
347
344
|
p.on("close", () => {
|
|
345
|
+
ctx.signal.removeEventListener("abort", onAbort)
|
|
348
346
|
clearTimeout(t)
|
|
349
347
|
if (killTimer) clearTimeout(killTimer)
|
|
350
348
|
})
|
package/src/tools/glob.ts
CHANGED
|
@@ -34,17 +34,16 @@ async function walk(
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function globToRegExp(glob: string): RegExp {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)
|
|
37
|
+
export function globToRegExp(glob: string): RegExp {
|
|
38
|
+
// Tangani brace expansion {a,b} tanpa double-escape
|
|
39
|
+
const str = glob.replace(/\{([^{}]+)\}/g, (_m, inner: string) => {
|
|
40
|
+
const alts = inner.split(",").map((s) => s.trim())
|
|
41
|
+
return `\0BRACE_START\0${alts.join("\0BRACE_OR\0")}\0BRACE_END\0`
|
|
42
|
+
})
|
|
43
|
+
let esc = str.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
44
|
+
esc = esc.replace(/\0BRACE_START\0/g, "(")
|
|
45
|
+
esc = esc.replace(/\0BRACE_OR\0/g, "|")
|
|
46
|
+
esc = esc.replace(/\0BRACE_END\0/g, ")")
|
|
48
47
|
esc = esc.replace(/\*\*/g, "§§")
|
|
49
48
|
// **/ di awal/pola rekursif harus cocok file root juga: **/* sekarang jadi
|
|
50
49
|
// (.*/)?[^/]*, bukan .*/[^/]* yang butuh slash dan membuat root kosong.
|
package/src/tools/lsp.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isAbsolute, resolve as resolvePath } from "node:path"
|
|
2
2
|
import { pathToFileURL } from "node:url"
|
|
3
3
|
import type { Tool } from "#minicore"
|
|
4
|
+
import { LSP_SYMBOL_KINDS } from "../constants.ts"
|
|
4
5
|
import { safeReadFile } from "../lib/safe-open.ts"
|
|
5
6
|
import {
|
|
6
7
|
findSymbolPosition,
|
|
@@ -240,34 +241,7 @@ export const lspSymbolsTool: Tool = {
|
|
|
240
241
|
ctx.signal,
|
|
241
242
|
)
|
|
242
243
|
if (!result || !Array.isArray(result) || result.length === 0) return "(no symbols)"
|
|
243
|
-
const KIND =
|
|
244
|
-
"File",
|
|
245
|
-
"Module",
|
|
246
|
-
"Namespace",
|
|
247
|
-
"Package",
|
|
248
|
-
"Class",
|
|
249
|
-
"Method",
|
|
250
|
-
"Property",
|
|
251
|
-
"Field",
|
|
252
|
-
"Constructor",
|
|
253
|
-
"Enum",
|
|
254
|
-
"Interface",
|
|
255
|
-
"Function",
|
|
256
|
-
"Variable",
|
|
257
|
-
"Constant",
|
|
258
|
-
"String",
|
|
259
|
-
"Number",
|
|
260
|
-
"Boolean",
|
|
261
|
-
"Array",
|
|
262
|
-
"Object",
|
|
263
|
-
"Key",
|
|
264
|
-
"Null",
|
|
265
|
-
"EnumMember",
|
|
266
|
-
"Struct",
|
|
267
|
-
"Event",
|
|
268
|
-
"Operator",
|
|
269
|
-
"TypeParameter",
|
|
270
|
-
]
|
|
244
|
+
const KIND = LSP_SYMBOL_KINDS
|
|
271
245
|
return scrubSecrets(
|
|
272
246
|
result
|
|
273
247
|
.map((s) => {
|
|
@@ -305,34 +279,7 @@ export const lspWorkspaceSymbolsTool: Tool = {
|
|
|
305
279
|
ctx.signal,
|
|
306
280
|
)
|
|
307
281
|
if (!symbols.length) return "(no symbols)"
|
|
308
|
-
const KIND =
|
|
309
|
-
"File",
|
|
310
|
-
"Module",
|
|
311
|
-
"Namespace",
|
|
312
|
-
"Package",
|
|
313
|
-
"Class",
|
|
314
|
-
"Method",
|
|
315
|
-
"Property",
|
|
316
|
-
"Field",
|
|
317
|
-
"Constructor",
|
|
318
|
-
"Enum",
|
|
319
|
-
"Interface",
|
|
320
|
-
"Function",
|
|
321
|
-
"Variable",
|
|
322
|
-
"Constant",
|
|
323
|
-
"String",
|
|
324
|
-
"Number",
|
|
325
|
-
"Boolean",
|
|
326
|
-
"Array",
|
|
327
|
-
"Object",
|
|
328
|
-
"Key",
|
|
329
|
-
"Null",
|
|
330
|
-
"EnumMember",
|
|
331
|
-
"Struct",
|
|
332
|
-
"Event",
|
|
333
|
-
"Operator",
|
|
334
|
-
"TypeParameter",
|
|
335
|
-
]
|
|
282
|
+
const KIND = LSP_SYMBOL_KINDS
|
|
336
283
|
const rows = symbols.map((s) => {
|
|
337
284
|
const kind = KIND[(s.kind ?? 1) - 1] ?? "?"
|
|
338
285
|
const uri = s.location.uri ?? "?"
|
package/src/tools/memory.ts
CHANGED
|
@@ -96,18 +96,19 @@ export const writeMemoryTool: Tool = {
|
|
|
96
96
|
const cat = (category as string) ?? "fact"
|
|
97
97
|
const tagArr = Array.isArray(tags) ? (tags as string[]) : undefined
|
|
98
98
|
// also add to vector (hybrid) — pass cwd so local vector.db is used
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
const baseUrl = process.env.AGENT_BASE_URL ?? "https://api.openai.com/v1"
|
|
100
|
+
const apiKey =
|
|
101
|
+
process.env.DEEPSEEK_API_KEY ?? process.env.OPENAI_API_KEY ?? process.env.AGENT_API_KEY ?? ""
|
|
102
|
+
let added = false
|
|
103
|
+
if (apiKey) {
|
|
104
|
+
try {
|
|
105
|
+
await addMemory(t, { baseUrl, apiKey, cwd, category: cat, tags: tagArr })
|
|
106
|
+
added = true
|
|
107
|
+
} catch (e) {
|
|
108
|
+
process.stderr.write(`[warn] memory vector embedding failed: ${(e as Error).message}\n`)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!added) {
|
|
111
112
|
try {
|
|
112
113
|
await addMemory(t, { cwd, category: cat, tags: tagArr })
|
|
113
114
|
} catch (e2) {
|
package/src/tools/task.ts
CHANGED
|
@@ -23,6 +23,11 @@ export interface ApprovalRequest {
|
|
|
23
23
|
|
|
24
24
|
export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny" | "always"> {
|
|
25
25
|
if (!process.stdin.isTTY) return "deny"
|
|
26
|
+
const sink = getApprovalSink()
|
|
27
|
+
// Tanpa sink (one-shot/exec) + stdout di-pipe: prompt tak terlihat user DAN
|
|
28
|
+
// askLine/blok akan mencemari stdout (kontrak: stdout = output PROGRAM).
|
|
29
|
+
// Fail-closed: tolak daripada mencemari pipe (kontrak I23).
|
|
30
|
+
if (!sink && !process.stdout.isTTY) return "deny"
|
|
26
31
|
// Non-visual feedback bisa dimatikan untuk aksesibilitas/recording.
|
|
27
32
|
// Bell hanya bila stdout TTY: byte `\x07` di stdout pipe mengotori output
|
|
28
33
|
// program (kontrak: stdout = output PROGRAM, bukan diagnostik).
|
|
@@ -39,9 +44,9 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
|
|
|
39
44
|
const args = (call.args ?? {}) as Record<string, unknown>
|
|
40
45
|
|
|
41
46
|
let actionSummary = ""
|
|
42
|
-
if (args.command) actionSummary =
|
|
43
|
-
else if (args.path) actionSummary =
|
|
44
|
-
else if (args.query) actionSummary =
|
|
47
|
+
if (args.command) actionSummary = `${t("appr.cmdLabel")} ${String(args.command).slice(0, 100)}`
|
|
48
|
+
else if (args.path) actionSummary = `${t("appr.fileLabel")} ${String(args.path)}`
|
|
49
|
+
else if (args.query) actionSummary = `${t("appr.queryLabel")} ${String(args.query)}`
|
|
45
50
|
else {
|
|
46
51
|
let json = ""
|
|
47
52
|
try {
|
|
@@ -49,7 +54,7 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
|
|
|
49
54
|
} catch {
|
|
50
55
|
json = String(args)
|
|
51
56
|
}
|
|
52
|
-
actionSummary =
|
|
57
|
+
actionSummary = `${t("appr.argsLabel")} ${json.slice(0, 100)}`
|
|
53
58
|
}
|
|
54
59
|
actionSummary = sanitizeAnsiLine(actionSummary)
|
|
55
60
|
|
|
@@ -59,7 +64,6 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
|
|
|
59
64
|
` ${c.bold(t("appr.tool"))} ${c.info(toolName)}`,
|
|
60
65
|
` ${actionSummary}`,
|
|
61
66
|
]
|
|
62
|
-
const sink = getApprovalSink()
|
|
63
67
|
if (sink) {
|
|
64
68
|
sink.pushBlock(block)
|
|
65
69
|
sink.repaint()
|
|
@@ -109,6 +113,10 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
|
|
|
109
113
|
* bila user membatalkan (Esc/Ctrl+C → askLine null) atau jawaban kosong. */
|
|
110
114
|
export async function promptAskText(question: string, options?: string[]): Promise<string | null> {
|
|
111
115
|
if (!process.stdin.isTTY) return null
|
|
116
|
+
const textSink = getApprovalSink()
|
|
117
|
+
// Paritas promptAsk: tanpa sink + stdout pipe = jawab tak terlihat & pipe
|
|
118
|
+
// tercemar → batal fail-closed.
|
|
119
|
+
if (!textSink && !process.stdout.isTTY) return null
|
|
112
120
|
const q = sanitizeAnsiLine(question).slice(0, 2000)
|
|
113
121
|
const block = [
|
|
114
122
|
``,
|
|
@@ -118,7 +126,7 @@ export async function promptAskText(question: string, options?: string[]): Promi
|
|
|
118
126
|
? options.map((o, i) => ` ${c.dim(`${i + 1}.`)} ${sanitizeAnsiLine(o)}`)
|
|
119
127
|
: []),
|
|
120
128
|
]
|
|
121
|
-
const sink =
|
|
129
|
+
const sink = textSink
|
|
122
130
|
if (sink) {
|
|
123
131
|
sink.pushBlock(block)
|
|
124
132
|
sink.repaint()
|