minicode-ai 0.14.6 โ 0.15.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/cli/args.ts +20 -8
- package/cli/commands/exec.ts +14 -12
- package/cli/commands.ts +33 -17
- package/cli/index.ts +25 -3
- package/cli/router.ts +22 -9
- package/cli/setup.ts +20 -5
- package/cli/tui.ts +73 -14
- package/docs/CONTROL-PLANE-MAP.md +1 -1
- package/docs/SUMMARY.md +1 -1
- package/docs/TERMINAL_CONTRACT.md +37 -12
- package/docs/architecture.md +1 -0
- package/docs/choosing-mode.md +3 -1
- package/docs/cli.md +7 -5
- package/docs/config.md +1 -1
- package/docs/environment.md +3 -1
- package/docs/getting-started.md +1 -1
- package/docs/memory-sessions.md +2 -2
- package/docs/repl.md +6 -3
- package/docs/security-model.md +3 -1
- package/package.json +1 -1
- package/scripts/vendor-overlays/minicode-context.patch +1 -1
- package/src/app/mentions.ts +1 -1
- package/src/app/rag-layer.ts +11 -2
- package/src/app/session.ts +92 -7
- package/src/constants.ts +1 -1
- package/src/daemon/client.ts +11 -6
- package/src/daemon/control.ts +2 -9
- package/src/daemon/resource.ts +5 -4
- package/src/lib/keystore.ts +11 -9
- package/src/lib/net.ts +8 -3
- package/src/lib/safe-open.ts +29 -5
- package/src/lib/trusted-exec.ts +4 -1
- package/src/lsp/client.ts +9 -10
- package/src/mcp/server.ts +17 -7
- package/src/memory/files.ts +2 -1
- package/src/memory/vector.ts +25 -16
- package/src/policy/bash-guard.ts +33 -11
- package/src/policy/bpe.ts +110 -0
- package/src/policy/compaction.ts +33 -6
- package/src/policy/context-window.ts +19 -0
- package/src/policy/context.ts +34 -8
- package/src/policy/jail.ts +48 -3
- package/src/policy/no-progress.ts +15 -8
- package/src/policy/permission.ts +24 -1
- package/src/policy/tokenizer-registry.ts +104 -0
- package/src/policy/usage.ts +20 -13
- package/src/policy/verifier.ts +7 -4
- package/src/policy/work-mode.ts +9 -5
- package/src/presentation/adapter.ts +7 -3
- package/src/presentation/projection.ts +10 -2
- package/src/providers/anthropic.ts +13 -3
- package/src/providers/responses.ts +16 -6
- package/src/runtime/capability.ts +22 -4
- package/src/runtime/execution-journal.ts +13 -7
- package/src/runtime/production-execution.ts +4 -3
- package/src/sandbox/os.ts +4 -3
- package/src/session/checkpoint.ts +29 -4
- package/src/session/persistence.ts +21 -10
- package/src/task/autonomous-context.ts +0 -1
- package/src/task/scheduler-observability.ts +1 -0
- package/src/tools/git.ts +22 -4
- package/src/tools/lsp.ts +10 -8
- package/src/tools/web_fetch.ts +6 -2
- package/src/tools/web_search.ts +2 -1
- package/src/ui/assistant/simple.ts +9 -3
- package/src/ui/contract.ts +4 -0
- package/src/ui/footer.ts +18 -6
- package/src/ui/i18n/en.ts +13 -2
- package/src/ui/i18n/id.ts +13 -2
- package/src/ui/render/diff.ts +14 -5
- package/src/ui/render/highlight.ts +4 -4
- package/src/ui/render/markdown.ts +12 -5
- package/src/ui/render/session-summary.ts +50 -0
- package/src/ui/render/table-grid.ts +134 -6
- package/src/ui/render/theme.ts +17 -0
- package/src/ui/render/width.ts +89 -2
- package/src/ui/runtime/screen.ts +16 -15
- package/src/ui/session-state.ts +27 -1
- package/src/ui/tui/transcript.ts +90 -18
- package/vendor/minicore/VENDOR.md +3 -3
- package/vendor/minicore/src/core/loop.ts +1 -1
|
@@ -407,14 +407,16 @@ export function openExecutionJournal(
|
|
|
407
407
|
const checkpointFn = opts?.checkpoint
|
|
408
408
|
let db: Database | null = null
|
|
409
409
|
let openError: JournalError | null = null
|
|
410
|
-
// Statement
|
|
411
|
-
//
|
|
412
|
-
//
|
|
413
|
-
const
|
|
410
|
+
// Statement cache di scope fungsi (bukan blok try): satu prepared statement
|
|
411
|
+
// per SQL string agar tidak bocor ribuan handle pada jurnal berumur panjang,
|
|
412
|
+
// dan close() mem-finalize semuanya agar Windows file lock lepas.
|
|
413
|
+
const statementMap = new Map<string, Statement>()
|
|
414
414
|
const prep = (sql: string): Statement => {
|
|
415
415
|
if (!db) throw new Error("journal closed")
|
|
416
|
+
const cached = statementMap.get(sql)
|
|
417
|
+
if (cached) return cached
|
|
416
418
|
const stmt = db.prepare(sql)
|
|
417
|
-
|
|
419
|
+
statementMap.set(sql, stmt)
|
|
418
420
|
return stmt
|
|
419
421
|
}
|
|
420
422
|
try {
|
|
@@ -882,13 +884,16 @@ export function openExecutionJournal(
|
|
|
882
884
|
|
|
883
885
|
integrityCheck(): { checked: number; mismatched: number[] } {
|
|
884
886
|
// Mismatch dilaporkan (seq list), TAK PERNAH dibuang diam-diam.
|
|
885
|
-
// Reuse storedEventContent agar definisi konten tunggal
|
|
887
|
+
// Reuse storedEventContent + storedIntentContent agar definisi konten tunggal.
|
|
886
888
|
const records = api.readAll()
|
|
887
889
|
const mismatched: number[] = []
|
|
888
890
|
for (const rec of records) {
|
|
889
891
|
if (rec.kind === "event") {
|
|
890
892
|
if (hashRecord(storedEventContent(rec)) !== rec.recordHash)
|
|
891
893
|
mismatched.push(rec.journalSequence)
|
|
894
|
+
} else if (rec.kind === "intent") {
|
|
895
|
+
if (hashRecord(storedIntentContent(rec)) !== rec.recordHash)
|
|
896
|
+
mismatched.push(rec.journalSequence)
|
|
892
897
|
}
|
|
893
898
|
}
|
|
894
899
|
return { checked: records.length, mismatched }
|
|
@@ -901,11 +906,12 @@ export function openExecutionJournal(
|
|
|
901
906
|
close(): void {
|
|
902
907
|
// Idempoten: ganda aman; post-close append = already-closed eksplisit.
|
|
903
908
|
// Finalize statements DULU (Windows file lock), baru db.close().
|
|
904
|
-
for (const stmt of
|
|
909
|
+
for (const stmt of statementMap.values()) {
|
|
905
910
|
try {
|
|
906
911
|
stmt.finalize()
|
|
907
912
|
} catch {}
|
|
908
913
|
}
|
|
914
|
+
statementMap.clear()
|
|
909
915
|
if (db) {
|
|
910
916
|
try {
|
|
911
917
|
db.close()
|
|
@@ -324,9 +324,6 @@ export function createProductionExecutionRunner(deps: {
|
|
|
324
324
|
}
|
|
325
325
|
const executionId = record.executionId
|
|
326
326
|
m.admitted++
|
|
327
|
-
// Parent lineage (M7): turn anak WAJIB menunjuk turn ini sebagai
|
|
328
|
-
// parentExecutionId, bukan menjadi akar sendiri.
|
|
329
|
-
if (request.kind === "turn") currentParentExecutionId.value = executionId
|
|
330
327
|
|
|
331
328
|
// Bukti durable: intent dispatch ditulis SETELAH admission sukses dan
|
|
332
329
|
// DITUNGGU, jadi redelivery lintas proses bisa dibuktikan (bukan
|
|
@@ -365,6 +362,10 @@ export function createProductionExecutionRunner(deps: {
|
|
|
365
362
|
record,
|
|
366
363
|
)
|
|
367
364
|
}
|
|
365
|
+
// Parent lineage (M7): catat sebagai parentExecutionId hanya SETELAH
|
|
366
|
+
// transisi RUNNING komit, agar turn yang ditolak RUNNING tidak menimpa
|
|
367
|
+
// parentExecutionId aktif milik turn sebelumnya.
|
|
368
|
+
if (request.kind === "turn") currentParentExecutionId.value = executionId
|
|
368
369
|
|
|
369
370
|
// track() menutup utang M14: pekerjaan yang masih berjalan saat shutdown
|
|
370
371
|
// HARUS terdaftar, supaya flush jurnal tak mendahului event terakhirnya.
|
package/src/sandbox/os.ts
CHANGED
|
@@ -87,11 +87,12 @@ export function runInOsSandbox(
|
|
|
87
87
|
const timeout = opts.timeoutMs ?? LIMITS.DOCKER_TIMEOUT_MS
|
|
88
88
|
|
|
89
89
|
if (type === "seatbelt") {
|
|
90
|
-
// macOS seatbelt - simple deny network profile
|
|
90
|
+
// macOS seatbelt - simple deny network profile (escape \ dan " pada path)
|
|
91
|
+
const escapedAbs = abs.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
|
|
91
92
|
const profile = `(version 1)
|
|
92
93
|
(deny default)
|
|
93
94
|
(allow process-exec)
|
|
94
|
-
(allow file-read* file-write* (subpath "${
|
|
95
|
+
(allow file-read* file-write* (subpath "${escapedAbs}"))
|
|
95
96
|
(allow file-read* (subpath "/usr") (subpath "/bin") (subpath "/private/tmp"))
|
|
96
97
|
(allow sysctl-read)
|
|
97
98
|
(deny network*)
|
|
@@ -111,7 +112,7 @@ export function runInOsSandbox(
|
|
|
111
112
|
"--ro-bind",
|
|
112
113
|
"/lib",
|
|
113
114
|
"/lib",
|
|
114
|
-
"--ro-bind",
|
|
115
|
+
"--ro-bind-try",
|
|
115
116
|
"/lib64",
|
|
116
117
|
"/lib64",
|
|
117
118
|
"--proc",
|
|
@@ -6,7 +6,12 @@ import { LIMITS } from "../constants.ts"
|
|
|
6
6
|
import { atomicWriteText } from "../lib/atomic-write.ts"
|
|
7
7
|
import { GIT_SAFE_BASE } from "../lib/git-hardening.ts"
|
|
8
8
|
import { sanitizeSessionPart } from "../lib/session-id.ts"
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
isOwnedState,
|
|
11
|
+
isPathOutsideRoot,
|
|
12
|
+
isRealPathOutsideRoot,
|
|
13
|
+
isSensitive,
|
|
14
|
+
} from "../policy/jail.ts"
|
|
10
15
|
import { appendUndoMarker, loadJournal } from "./journal.ts"
|
|
11
16
|
import { diffTrees, ephemeralTree, isGitRepo, restoreTree, snapshotTree } from "./shadow-git.ts"
|
|
12
17
|
|
|
@@ -308,7 +313,23 @@ export async function snapshotWorkspace(
|
|
|
308
313
|
.slice(0, limit)
|
|
309
314
|
if (dirty.length > 0) {
|
|
310
315
|
const snaps: FileSnapshot[] = []
|
|
311
|
-
|
|
316
|
+
const seen = new Set<string>()
|
|
317
|
+
for (const f of dirty) {
|
|
318
|
+
const snap = await captureFileSnapshot(resolve(cwd, f), cwd)
|
|
319
|
+
seen.add(snap.path)
|
|
320
|
+
snaps.push(snap)
|
|
321
|
+
}
|
|
322
|
+
if (snaps.length < limit) {
|
|
323
|
+
const extra: string[] = []
|
|
324
|
+
await walkFiles(cwd, "", extra, limit)
|
|
325
|
+
for (const f of extra) {
|
|
326
|
+
if (snaps.length >= limit) break
|
|
327
|
+
const snap = await captureFileSnapshot(resolve(cwd, f), cwd)
|
|
328
|
+
if (seen.has(snap.path)) continue
|
|
329
|
+
seen.add(snap.path)
|
|
330
|
+
snaps.push(snap)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
312
333
|
return snaps
|
|
313
334
|
}
|
|
314
335
|
}
|
|
@@ -441,16 +462,20 @@ export async function recordCheckpointFromSnapshots(
|
|
|
441
462
|
})
|
|
442
463
|
}
|
|
443
464
|
|
|
444
|
-
// Terapkan snapshot dengan jail path: path di luar workspace dilewati.
|
|
465
|
+
// Terapkan snapshot dengan jail path: path di luar workspace atau sensitif dilewati.
|
|
445
466
|
async function applySnapshots(snapshots: FileSnapshot[], cwd: string): Promise<string[]> {
|
|
446
467
|
const root = resolve(cwd)
|
|
447
468
|
const applied: string[] = []
|
|
448
469
|
for (const snap of snapshots) {
|
|
449
470
|
const absPath = resolve(root, snap.path)
|
|
450
|
-
if (isPathOutsideRoot(absPath, root)) {
|
|
471
|
+
if (isPathOutsideRoot(absPath, root) || isRealPathOutsideRoot(absPath, root)) {
|
|
451
472
|
applied.push(`${snap.path} (skipped: outside workspace)`)
|
|
452
473
|
continue
|
|
453
474
|
}
|
|
475
|
+
if (isSensitive(absPath) || isOwnedState(absPath)) {
|
|
476
|
+
applied.push(`${snap.path} (skipped: protected path)`)
|
|
477
|
+
continue
|
|
478
|
+
}
|
|
454
479
|
if (snap.content === null) {
|
|
455
480
|
if (existsSync(absPath)) {
|
|
456
481
|
await rm(absPath, { force: true }).catch(() => {})
|
|
@@ -1344,16 +1344,27 @@ export function purgeExpired(db: Database, now = Date.now()): number {
|
|
|
1344
1344
|
// than duplicated for exactly that reason: 6O ADR-9's rule is ONE deletion
|
|
1345
1345
|
// architecture, so the ordering cannot drift between these two entry points.
|
|
1346
1346
|
const expiring = db
|
|
1347
|
-
.prepare(`SELECT id FROM sessions WHERE COALESCE(updated_at, created_at) < ?`)
|
|
1348
|
-
.all(cutoff) as { id: string }[]
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1347
|
+
.prepare(`SELECT id, cwd FROM sessions WHERE COALESCE(updated_at, created_at) < ?`)
|
|
1348
|
+
.all(cutoff) as { id: string; cwd?: string | null }[]
|
|
1349
|
+
|
|
1350
|
+
if (expiring.length > 0) {
|
|
1351
|
+
const { TaskStore } = require("../task/store.ts") as typeof import("../task/store.ts")
|
|
1352
|
+
const fallbackCwd = sessionCwdOf(db, expiring)
|
|
1353
|
+
const byCwd = new Map<string | undefined, string[]>()
|
|
1354
|
+
for (const row of expiring) {
|
|
1355
|
+
const key = row.cwd || fallbackCwd
|
|
1356
|
+
const list = byCwd.get(key) ?? []
|
|
1357
|
+
list.push(row.id)
|
|
1358
|
+
byCwd.set(key, list)
|
|
1359
|
+
}
|
|
1360
|
+
for (const [cwd, ids] of byCwd) {
|
|
1361
|
+
const tasks = new TaskStore(cwd)
|
|
1362
|
+
for (const sid of ids) {
|
|
1363
|
+
// 1. invalidate in-flight executions, 2. remove task rows.
|
|
1364
|
+
tasks.bumpSessionIncarnation(sid)
|
|
1365
|
+
tasks.deleteSessionTasks(sid)
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1357
1368
|
}
|
|
1358
1369
|
|
|
1359
1370
|
const gone = db
|
|
@@ -403,7 +403,6 @@ export class AutonomousExecutionContext {
|
|
|
403
403
|
if (this.session === null) await this.initialize()
|
|
404
404
|
const session = this.session!
|
|
405
405
|
this.state = "executing"
|
|
406
|
-
this.emit({ kind: "turn:started", childSessionId: this.childSessionId })
|
|
407
406
|
|
|
408
407
|
const settle = (r: AutonomousTurnResult): AutonomousTurnResult => {
|
|
409
408
|
this.state = "settled"
|
package/src/tools/git.ts
CHANGED
|
@@ -11,7 +11,14 @@ import {
|
|
|
11
11
|
gitFilterNeutralizers,
|
|
12
12
|
} from "../lib/git-hardening.ts"
|
|
13
13
|
import { resolveTrustedExecutable } from "../lib/trusted-exec.ts"
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
isCwdOutsideRoot,
|
|
16
|
+
isOwnedState,
|
|
17
|
+
isOwnedStateReal,
|
|
18
|
+
isPathOutsideRoot,
|
|
19
|
+
isRealPathOutsideRoot,
|
|
20
|
+
isSensitive,
|
|
21
|
+
} from "../policy/jail.ts"
|
|
15
22
|
import { sanitizeSpawnEnv, scrubSecrets } from "../policy/scrub.ts"
|
|
16
23
|
import { requireToolCwd } from "./context.ts"
|
|
17
24
|
|
|
@@ -57,16 +64,22 @@ function runGit(
|
|
|
57
64
|
if (s.length > room) truncated = true
|
|
58
65
|
return cur + s.slice(0, Math.max(0, room))
|
|
59
66
|
}
|
|
67
|
+
const onAbort = () => p.kill("SIGTERM")
|
|
60
68
|
p.stdout.on("data", (d) => (out = push(out, d)))
|
|
61
69
|
p.stderr.on("data", (d) => (err = push(err, d)))
|
|
62
|
-
p.on("error",
|
|
70
|
+
p.on("error", (e) => {
|
|
71
|
+
signal.removeEventListener("abort", onAbort)
|
|
72
|
+
reject(e)
|
|
73
|
+
})
|
|
63
74
|
p.on("close", (code) => {
|
|
75
|
+
signal.removeEventListener("abort", onAbort)
|
|
64
76
|
const text = scrubSecrets((out + (err ? `\n${err}` : "")).trim())
|
|
65
77
|
const marked = truncated ? `${text}\nโฆ [git output truncated]` : text
|
|
66
78
|
if (code !== 0 && !marked) reject(new Error(`git ${args.join(" ")} exit ${code}`))
|
|
67
79
|
else resolve(marked || `(exit ${code})`)
|
|
68
80
|
})
|
|
69
|
-
signal.
|
|
81
|
+
if (signal.aborted) onAbort()
|
|
82
|
+
else signal.addEventListener("abort", onAbort, { once: true })
|
|
70
83
|
})
|
|
71
84
|
}
|
|
72
85
|
|
|
@@ -217,7 +230,12 @@ function assertPaths(paths: unknown, cwd: string | undefined, sessionRoot: strin
|
|
|
217
230
|
const out: string[] = []
|
|
218
231
|
for (const p of paths) {
|
|
219
232
|
if (typeof p !== "string" || !p.trim()) continue
|
|
220
|
-
if (isPathOutsideRoot(p, root)
|
|
233
|
+
if (isPathOutsideRoot(p, root) || isRealPathOutsideRoot(p, root))
|
|
234
|
+
throw new Error(`path outside workspace: ${p}`)
|
|
235
|
+
const abs = resolve(root, p)
|
|
236
|
+
if (isSensitive(p) || isSensitive(abs)) throw new Error(`blocked sensitive file: ${p}`)
|
|
237
|
+
if (isOwnedState(p) || isOwnedState(abs) || isOwnedStateReal(p, root))
|
|
238
|
+
throw new Error(`blocked owned state: ${p}`)
|
|
221
239
|
out.push(p)
|
|
222
240
|
}
|
|
223
241
|
return out
|
package/src/tools/lsp.ts
CHANGED
|
@@ -21,14 +21,16 @@ const SEVERITY = ["Error", "Warn", "Info", "Hint"]
|
|
|
21
21
|
// success ke turn yang sudah dibatalkan.
|
|
22
22
|
function raceAbort<T>(p: Promise<T>, signal: AbortSignal): Promise<T> {
|
|
23
23
|
if (signal.aborted) return Promise.reject(signal.reason ?? new Error("aborted"))
|
|
24
|
+
let onAbort: (() => void) | undefined
|
|
24
25
|
return Promise.race([
|
|
25
26
|
p,
|
|
26
|
-
new Promise<never>((_, rej) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
new Promise<never>((_, rej) => {
|
|
28
|
+
onAbort = () => rej(signal.reason ?? new Error("aborted"))
|
|
29
|
+
signal.addEventListener("abort", onAbort, { once: true })
|
|
30
|
+
}),
|
|
31
|
+
]).finally(() => {
|
|
32
|
+
if (onAbort) signal.removeEventListener("abort", onAbort)
|
|
33
|
+
})
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
function toUri(abs: string): string {
|
|
@@ -286,9 +288,9 @@ export const lspWorkspaceSymbolsTool: Tool = {
|
|
|
286
288
|
const uri = s.location.uri ?? "?"
|
|
287
289
|
return `[${kind}] ${s.name}${s.containerName ? ` (${s.containerName})` : ""} โ ${uri}`
|
|
288
290
|
})
|
|
289
|
-
return capLocations(rows, 50)
|
|
291
|
+
return scrubSecrets(capLocations(rows, 50))
|
|
290
292
|
} catch (e) {
|
|
291
|
-
return `[lsp] ${(e as Error).message}`
|
|
293
|
+
return scrubSecrets(`[lsp] ${(e as Error).message}`)
|
|
292
294
|
}
|
|
293
295
|
},
|
|
294
296
|
}
|
package/src/tools/web_fetch.ts
CHANGED
|
@@ -77,7 +77,7 @@ export const webFetchTool: Tool = {
|
|
|
77
77
|
type: "object",
|
|
78
78
|
properties: {
|
|
79
79
|
url: { type: "string", description: "https:// URL to fetch" },
|
|
80
|
-
maxChars: { type: "number", description: "max chars to return (default
|
|
80
|
+
maxChars: { type: "number", description: "max chars to return (default 8000, max 50000)" },
|
|
81
81
|
},
|
|
82
82
|
required: ["url"],
|
|
83
83
|
additionalProperties: false,
|
|
@@ -92,7 +92,11 @@ export const webFetchTool: Tool = {
|
|
|
92
92
|
throw new Error(`invalid url: ${u}`)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
// Default 8000 (bukan 20000): hasil web rakus konteks โ satu fetch `README`
|
|
96
|
+
// /halaman GitHub bisa 17 KB yang menggelembungkan jendela konteks hingga
|
|
97
|
+
// melampaui batas model. 8000 tetap cukup utk membaca section, jauh lebih
|
|
98
|
+
// hemat agar beberapa fetch beruntun tidak menumpuk jadi ~1M token.
|
|
99
|
+
const limit = Math.min(Math.max(Number(maxChars) || 8000, 1000), 50000)
|
|
96
100
|
const controller = new AbortController()
|
|
97
101
|
const timeout = setTimeout(() => controller.abort(new Error("fetch timeout 10s")), 10_000)
|
|
98
102
|
// Link parent signal โ selalu pasang listener dulu, cek aborted setelahnya
|
package/src/tools/web_search.ts
CHANGED
|
@@ -40,7 +40,8 @@ export const webSearchTool: Tool = {
|
|
|
40
40
|
const controller = new AbortController()
|
|
41
41
|
const t = setTimeout(() => controller.abort(), 8000)
|
|
42
42
|
const onAbort = () => controller.abort(ctx.signal.reason)
|
|
43
|
-
ctx.signal.
|
|
43
|
+
if (ctx.signal.aborted) onAbort()
|
|
44
|
+
else ctx.signal.addEventListener("abort", onAbort, { once: true })
|
|
44
45
|
try {
|
|
45
46
|
const res = await fetch("https://api.tavily.com/search", {
|
|
46
47
|
method: "POST",
|
|
@@ -279,9 +279,15 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
279
279
|
return sanitizeAnsiLine(tagged)
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
const indentThinking = (text: string): string =>
|
|
283
|
+
text
|
|
284
|
+
.split("\n")
|
|
285
|
+
.map((line) => (line ? ` ${line}` : line))
|
|
286
|
+
.join("\n")
|
|
287
|
+
|
|
282
288
|
const flushReasoningTail = () => {
|
|
283
289
|
if (reasoningLine) {
|
|
284
|
-
wErr(c.
|
|
290
|
+
wErr(c.thinking(` ${reasoningLine}\n`))
|
|
285
291
|
reasoningLine = ""
|
|
286
292
|
}
|
|
287
293
|
}
|
|
@@ -695,7 +701,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
695
701
|
thinkState = "exp"
|
|
696
702
|
wErr(c.muted(t("one.thinkOpen")))
|
|
697
703
|
if (thinkingBuf) {
|
|
698
|
-
wErr(c.
|
|
704
|
+
wErr(c.thinking(indentThinking(thinkingBuf)))
|
|
699
705
|
thinkingBuf = ""
|
|
700
706
|
}
|
|
701
707
|
}
|
|
@@ -707,7 +713,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
707
713
|
// Sadar-stream (F1) + kebijakan pipa (F2) seperti teks model.
|
|
708
714
|
reasoningLine += cleanUntrusted(reasoningSan.push(text), !!process.stdout.isTTY)
|
|
709
715
|
const parts = reasoningLine.split("\n")
|
|
710
|
-
for (let i = 0; i < parts.length - 1; i++) wErr(c.
|
|
716
|
+
for (let i = 0; i < parts.length - 1; i++) wErr(c.thinking(` ${parts[i]}\n`))
|
|
711
717
|
reasoningLine = parts[parts.length - 1] ?? ""
|
|
712
718
|
}
|
|
713
719
|
} else {
|
package/src/ui/contract.ts
CHANGED
|
@@ -273,6 +273,10 @@ export interface PresentationPolicy {
|
|
|
273
273
|
) => ActivityPolicyDescription
|
|
274
274
|
matchTurn: (turns: UiPresentationTurn[], summary: UiTurnSummary) => UiPresentationTurn | undefined
|
|
275
275
|
elapsedVisible: (tsStart: number, now: number) => boolean
|
|
276
|
+
/** Marker display status verifikasi โ keputusan policy (ASCII aman). */
|
|
277
|
+
verificationMark: (verification: UiVerificationDisplay | undefined) => string
|
|
278
|
+
/** Marker display provenans (hanya non-live dirender). */
|
|
279
|
+
provenanceMark: (provenance: UiProvenance | undefined) => string
|
|
276
280
|
}
|
|
277
281
|
|
|
278
282
|
export interface UiPresentationSnapshot {
|
package/src/ui/footer.ts
CHANGED
|
@@ -91,17 +91,25 @@ export function paintWorkMode(workMode?: string, style: ModeLabelStyle = "full")
|
|
|
91
91
|
)}`
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
/** Permission Mode selalu cyan agar terpisah secara visual dari Work Mode.
|
|
94
|
+
/** Permission Mode selalu cyan agar terpisah secara visual dari Work Mode.
|
|
95
|
+
* `unrestricted` (full akses, /unrestric): label disembunyikan โ cukup gembok
|
|
96
|
+
* terbuka ๐ sebagai indikator satu-satunya (lihat paintBashStrict). */
|
|
95
97
|
export function paintPermissionMode(mode: string, style: ModeLabelStyle = "full"): string {
|
|
98
|
+
if (mode === "unrestricted") return ""
|
|
96
99
|
const value = titleCaseMode(mode, "Auto")
|
|
97
100
|
if (style === "value") return c.info(value)
|
|
98
101
|
const prefix = style === "full" ? "Permission Mode: " : "Permission: "
|
|
99
102
|
return `${c.gray(prefix)}${c.info(value)}`
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
/** Badge
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
/** Badge pembatas bash allow-list: gembok selalu tampil โ terang saat aktif,
|
|
106
|
+
* redup saat nonaktif (lapis kapabilitas, terpisah dari mode persetujuan).
|
|
107
|
+
* Saat `unrestricted` aktif, gembok jadi TERBUKA (๐) โ satu-satunya penanda,
|
|
108
|
+
* jadi dirender jelas (bukan redup). */
|
|
109
|
+
export function paintBashStrict(strictBash?: boolean, unrestricted = false): string {
|
|
110
|
+
if (unrestricted) return c.info("๐")
|
|
111
|
+
const lock = "๐"
|
|
112
|
+
return strictBash ? c.yellow(lock) : c.faint(lock)
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
/** Spark glyph: redup saat idle, pulse putihโabu saat busy (frame genap/ganjil). */
|
|
@@ -180,7 +188,11 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
|
|
|
180
188
|
return `${lead}${paintWorkMode(s.workMode, style)}`
|
|
181
189
|
}
|
|
182
190
|
const rightFor = (style: ModeLabelStyle): string =>
|
|
183
|
-
[
|
|
191
|
+
[
|
|
192
|
+
...contextParts,
|
|
193
|
+
paintPermissionMode(s.mode, style),
|
|
194
|
+
paintBashStrict(s.strictBash, s.mode === "unrestricted"),
|
|
195
|
+
]
|
|
184
196
|
.filter(Boolean)
|
|
185
197
|
.join(fieldGap)
|
|
186
198
|
const align = (left: string, right: string): string | undefined => {
|
|
@@ -233,7 +245,7 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
|
|
|
233
245
|
// timer/model/CWD/label sebelum konteks; potong konteks lebih dahulu.
|
|
234
246
|
const workValue = paintWorkMode(s.workMode, "value")
|
|
235
247
|
const permissionValue = paintPermissionMode(s.mode, "value")
|
|
236
|
-
const strictValue = paintBashStrict(s.strictBash)
|
|
248
|
+
const strictValue = paintBashStrict(s.strictBash, s.mode === "unrestricted")
|
|
237
249
|
const shortWorkValue = workValue.trimEnd()
|
|
238
250
|
const modeOnly = `${spark} ${shortWorkValue} ${[permissionValue, strictValue].filter(Boolean).join(" ")}`
|
|
239
251
|
if (ctx || metrics) {
|
package/src/ui/i18n/en.ts
CHANGED
|
@@ -137,9 +137,17 @@ export const en = {
|
|
|
137
137
|
"help.cKeys":
|
|
138
138
|
"Keys: Tab work-mode ยท Shift+Tab permission ยท โโ history ยท Mouse wheel/PgUp/PgDn scroll ยท Ctrl+R search ยท Ctrl+D exit",
|
|
139
139
|
"help.cMore": " /help keys = all shortcuts",
|
|
140
|
+
"help.gGeneral": "General",
|
|
141
|
+
"help.gSession": "Session",
|
|
142
|
+
"help.gModel": "Model",
|
|
143
|
+
"help.gMode": "Mode",
|
|
144
|
+
"help.gView": "View",
|
|
145
|
+
"help.gTask": "Task",
|
|
140
146
|
"help.kHead": "Keyboard:",
|
|
141
147
|
"help.k.submit": "submit",
|
|
142
148
|
"help.k.cycleMode": "cycle work mode",
|
|
149
|
+
"help.k.workMode": "cycle work mode (Build/Plan/Discuss)",
|
|
150
|
+
"help.k.permission": "cycle permission mode (Auto/Ask)",
|
|
143
151
|
"help.k.history": "prompt history (in picker: navigate)",
|
|
144
152
|
"help.k.mouse": "scroll transcript with mouse wheel",
|
|
145
153
|
"help.k.scroll": "scroll transcript with PgUp/PgDn (Shift+ = half page)",
|
|
@@ -155,7 +163,7 @@ export const en = {
|
|
|
155
163
|
"help.k.compact": "toggle compact/expanded tool output",
|
|
156
164
|
"help.k.thinking": "toggle expand/minimize thinking output",
|
|
157
165
|
"help.k.esc": "close dropdown / picker / clear line (busy: abort turn)",
|
|
158
|
-
"help.k.ctrlC": "
|
|
166
|
+
"help.k.ctrlC": "copy selected text / cancel",
|
|
159
167
|
"help.k.ctrlD": "exit on empty line",
|
|
160
168
|
"help.desc.help": "Show commands",
|
|
161
169
|
"help.desc.provider": "Manage providers",
|
|
@@ -173,7 +181,7 @@ export const en = {
|
|
|
173
181
|
"help.desc.clear": "Clear transcript",
|
|
174
182
|
"help.desc.copy": "Copy the last 1โ10 turns to clipboard (OSC 52)",
|
|
175
183
|
"help.desc.history": "Show recent prompt history",
|
|
176
|
-
"help.desc.scheduler": "
|
|
184
|
+
"help.desc.scheduler": "Trigger / inspect / stop the scheduler",
|
|
177
185
|
|
|
178
186
|
// [PHASE 6AB] Operator strings for `/scheduler`. The STATE line itself is
|
|
179
187
|
// deliberately not localised - see `describeOperatorState`, which the
|
|
@@ -230,10 +238,13 @@ export const en = {
|
|
|
230
238
|
"tui.workModeLine": "work mode: {m}",
|
|
231
239
|
"tui.workModeUsage": "usage: /work-mode <DISCUSS|PLAN|BUILD> โ current: {m}",
|
|
232
240
|
"tui.workModeUnavailable": "work mode is not available in this session",
|
|
241
|
+
"tui.unrestrictedOn": "๐ unrestricted mode enabled - full access",
|
|
242
|
+
"tui.unrestrictedOff": "๐ unrestricted disabled โ permission mode restored to {m}",
|
|
233
243
|
"tui.langLine": "lang: {v}",
|
|
234
244
|
"tui.toolCall": "tool call: {v}",
|
|
235
245
|
"tui.modelSet": "model: {v}",
|
|
236
246
|
"tui.thinkingSet": "thinking: {v}",
|
|
247
|
+
"tui.activityFold": "activity: {v}",
|
|
237
248
|
"tui.sectionsMin": "sections: minimized",
|
|
238
249
|
"tui.sectionsExp": "sections: expanded",
|
|
239
250
|
"tui.minUse": "usage: /minimize [on|off]",
|
package/src/ui/i18n/id.ts
CHANGED
|
@@ -138,9 +138,17 @@ export const id: Record<MsgKey, string> = {
|
|
|
138
138
|
"help.cKeys":
|
|
139
139
|
"Tombol: Tab work-mode ยท Shift+Tab izin ยท โโ riwayat ยท Mouse wheel/PgUp/PgDn gulir ยท Ctrl+R cari ยท Ctrl+D keluar",
|
|
140
140
|
"help.cMore": " /help tombol = semua pintasan",
|
|
141
|
+
"help.gGeneral": "Umum",
|
|
142
|
+
"help.gSession": "Sesi",
|
|
143
|
+
"help.gModel": "Model",
|
|
144
|
+
"help.gMode": "Mode",
|
|
145
|
+
"help.gView": "Tampilan",
|
|
146
|
+
"help.gTask": "Tugas",
|
|
141
147
|
"help.kHead": "Papan tombol:",
|
|
142
148
|
"help.k.submit": "kirim",
|
|
143
149
|
"help.k.cycleMode": "putar work mode",
|
|
150
|
+
"help.k.workMode": "putar work mode (Build/Plan/Discuss)",
|
|
151
|
+
"help.k.permission": "putar mode izin (Auto/Ask)",
|
|
144
152
|
"help.k.history": "riwayat prompt (di picker: navigasi)",
|
|
145
153
|
"help.k.mouse": "gulir transkrip dengan mouse wheel",
|
|
146
154
|
"help.k.scroll": "gulir transkrip dengan PgUp/PgDn (Shift+ = setengah halaman)",
|
|
@@ -156,7 +164,7 @@ export const id: Record<MsgKey, string> = {
|
|
|
156
164
|
"help.k.compact": "alihkan output tool ringkas/penuh",
|
|
157
165
|
"help.k.thinking": "alihkan thinking bentang/ringkas",
|
|
158
166
|
"help.k.esc": "tutup dropdown/picker/hapus baris (busy: batalkan turn)",
|
|
159
|
-
"help.k.ctrlC": "
|
|
167
|
+
"help.k.ctrlC": "salin teks terpilih / batalkan",
|
|
160
168
|
"help.k.ctrlD": "keluar saat baris kosong",
|
|
161
169
|
"help.desc.help": "Tampilkan perintah",
|
|
162
170
|
"help.desc.provider": "Kelola penyedia",
|
|
@@ -174,7 +182,7 @@ export const id: Record<MsgKey, string> = {
|
|
|
174
182
|
"help.desc.clear": "Bersihkan transkrip",
|
|
175
183
|
"help.desc.copy": "Salin 1โ10 turn terakhir ke clipboard (OSC 52)",
|
|
176
184
|
"help.desc.history": "Tampilkan riwayat prompt",
|
|
177
|
-
"help.desc.scheduler": "
|
|
185
|
+
"help.desc.scheduler": "Picu / periksa / hentikan scheduler",
|
|
178
186
|
|
|
179
187
|
// [PHASE 6AB] Operator strings for `/scheduler`.
|
|
180
188
|
"sched.usage": "pakai: /scheduler [status|run|stop]",
|
|
@@ -231,10 +239,13 @@ export const id: Record<MsgKey, string> = {
|
|
|
231
239
|
"tui.workModeLine": "mode kerja: {m}",
|
|
232
240
|
"tui.workModeUsage": "pemakaian: /work-mode <DISCUSS|PLAN|BUILD> โ aktif: {m}",
|
|
233
241
|
"tui.workModeUnavailable": "work mode tidak tersedia di sesi ini",
|
|
242
|
+
"tui.unrestrictedOn": "๐ mode unrestricted aktif - akses penuh",
|
|
243
|
+
"tui.unrestrictedOff": "๐ unrestricted nonaktif โ mode izin kembali ke {m}",
|
|
234
244
|
"tui.langLine": "lang: {v}",
|
|
235
245
|
"tui.toolCall": "pemanggilan tool: {v}",
|
|
236
246
|
"tui.modelSet": "model: {v}",
|
|
237
247
|
"tui.thinkingSet": "thinking: {v}",
|
|
248
|
+
"tui.activityFold": "aktivitas: {v}",
|
|
238
249
|
"tui.sectionsMin": "bagian: diminimalkan",
|
|
239
250
|
"tui.sectionsExp": "bagian: dibuka",
|
|
240
251
|
"tui.minUse": "pakai: /minimize [on|off]",
|
package/src/ui/render/diff.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Diff renderer - Ubuntu Server style: indentasi + warna, tanpa border.
|
|
2
2
|
import { sanitizeAnsi, sanitizeAnsiLine } from "./sanitize.ts"
|
|
3
3
|
import { c } from "./theme.ts"
|
|
4
|
-
import { truncateToWidth } from "./width.ts"
|
|
4
|
+
import { truncateToWidth, wrapByWidth } from "./width.ts"
|
|
5
5
|
|
|
6
6
|
export interface DiffLine {
|
|
7
7
|
type: "add" | "delete" | "context"
|
|
@@ -147,9 +147,18 @@ export function renderDiffCard(
|
|
|
147
147
|
const max = opts.maxLines ?? 12
|
|
148
148
|
// Baris diff bisa sepanjang baris kode aslinya. Tanpa batas, satu baris 300
|
|
149
149
|
// karakter membungkus sendiri di terminal dan merusak frame TUI yang
|
|
150
|
-
// menghitung tinggi per baris. Default mengikuti lebar terminal.
|
|
150
|
+
// menghitung tinggi per baris. Default mengikuti lebar terminal. Baris isi
|
|
151
|
+
// di-WRAP (bukan truncate) agar perubahan tidak hilang โ hanya path header
|
|
152
|
+
// yang dipotong dengan ellipsis (label pendek, semantik satu baris).
|
|
151
153
|
const width = opts.width ?? (process.stdout.columns || 80)
|
|
152
154
|
const cut = (s: string) => truncateToWidth(s, Math.max(8, width - 1))
|
|
155
|
+
const wrapDiffLine = (prefix: string, body: string, paint: (s: string) => string): string[] => {
|
|
156
|
+
const bodyWidth = Math.max(6, width - prefix.length)
|
|
157
|
+
const parts = wrapByWidth(body, bodyWidth)
|
|
158
|
+
return parts.map((p, i) =>
|
|
159
|
+
i === 0 ? paint(`${prefix}${p}`) : paint(`${" ".repeat(prefix.length)}${p}`),
|
|
160
|
+
)
|
|
161
|
+
}
|
|
153
162
|
|
|
154
163
|
const lines: string[] = [c.accent(c.bold(cut(` ${safePath}`)))]
|
|
155
164
|
// collect indices of changes plus 1 context line before/after
|
|
@@ -174,12 +183,12 @@ export function renderDiffCard(
|
|
|
174
183
|
if (d.type === "add") {
|
|
175
184
|
const mask = wordMask.get(i)
|
|
176
185
|
const body = mask ? paintWords(d.content, mask, (s) => c.bold(s)) : d.content
|
|
177
|
-
lines.push(
|
|
186
|
+
lines.push(...wrapDiffLine(" + ", body, (s) => c.success(s)))
|
|
178
187
|
} else if (d.type === "delete") {
|
|
179
188
|
const mask = wordMask.get(i)
|
|
180
189
|
const body = mask ? paintWords(d.content, mask, (s) => c.bold(s)) : d.content
|
|
181
|
-
lines.push(
|
|
182
|
-
} else lines.push(
|
|
190
|
+
lines.push(...wrapDiffLine(" - ", body, (s) => c.error(s)))
|
|
191
|
+
} else lines.push(...wrapDiffLine(" ", d.content, (s) => c.dim(s)))
|
|
183
192
|
count++
|
|
184
193
|
}
|
|
185
194
|
return lines.join("\n")
|
|
@@ -188,7 +188,7 @@ function highlightTsTokens(text: string): string {
|
|
|
188
188
|
/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|\b\d+(?:\.\d+)?\b|\b[A-Za-z_$][A-Za-z0-9_$]*\b|[{}()[\];:,.<>=+\-*/%!&|^~?]+|\s+)/g
|
|
189
189
|
return text.replace(tokenRe, (token) => {
|
|
190
190
|
if (token.startsWith('"') || token.startsWith("'") || token.startsWith("`")) {
|
|
191
|
-
return c.
|
|
191
|
+
return c.string(token)
|
|
192
192
|
}
|
|
193
193
|
if (/^\d+(?:\.\d+)?$/.test(token)) {
|
|
194
194
|
return c.brightYellow(token)
|
|
@@ -223,7 +223,7 @@ function highlightPythonTokens(text: string): string {
|
|
|
223
223
|
/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b\d+(?:\.\d+)?\b|\b[A-Za-z_][A-Za-z0-9_]*\b|[{}()[\];:,.<>=+\-*/%!&|^~?]+|\s+)/g
|
|
224
224
|
return text.replace(tokenRe, (token) => {
|
|
225
225
|
if (token.startsWith('"') || token.startsWith("'")) {
|
|
226
|
-
return c.
|
|
226
|
+
return c.string(token)
|
|
227
227
|
}
|
|
228
228
|
if (/^\d+/.test(token)) return c.brightYellow(token)
|
|
229
229
|
if (PY_KEYWORDS.has(token)) return c.brightMagenta(c.bold(token))
|
|
@@ -239,7 +239,7 @@ function highlightJsonLine(line: string): string {
|
|
|
239
239
|
(match, str, colon, bool, num) => {
|
|
240
240
|
if (str) {
|
|
241
241
|
if (colon) return c.brightCyan(str) + colon
|
|
242
|
-
return c.
|
|
242
|
+
return c.string(str)
|
|
243
243
|
}
|
|
244
244
|
if (bool) return c.yellow(bool)
|
|
245
245
|
if (num) return c.brightYellow(num)
|
|
@@ -264,7 +264,7 @@ function highlightShellTokens(text: string): string {
|
|
|
264
264
|
return text.replace(
|
|
265
265
|
/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\$[A-Za-z0-9_]+|-{1,2}[A-Za-z0-9][A-Za-z0-9_-]*|\b[A-Za-z_][A-Za-z0-9_-]*\b|\s+)/g,
|
|
266
266
|
(token) => {
|
|
267
|
-
if (token.startsWith('"') || token.startsWith("'")) return c.
|
|
267
|
+
if (token.startsWith('"') || token.startsWith("'")) return c.string(token)
|
|
268
268
|
if (token.startsWith("$")) return c.brightCyan(token)
|
|
269
269
|
if (SH_KEYWORDS.has(token)) return c.brightMagenta(c.bold(token))
|
|
270
270
|
if (token.startsWith("-")) return c.yellow(token)
|