minicode-ai 0.14.6 → 0.20.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 +6 -4
- package/cli/args.ts +20 -8
- package/cli/commands/exec.ts +17 -14
- package/cli/commands/openwork.ts +1 -1
- package/cli/commands.ts +39 -23
- package/cli/index.ts +29 -7
- package/cli/model-manager.ts +1 -1
- package/cli/router.ts +22 -9
- package/cli/setup.ts +77 -35
- package/cli/tui.ts +179 -25
- package/docs/CONTROL-PLANE-MAP.md +7 -5
- package/docs/OUTPUT_EVENT_MODEL.md +4 -3
- package/docs/OUTPUT_PROTOCOL_SPEC.md +1 -1
- package/docs/OUTPUT_RENDERING_SPEC.md +16 -4
- package/docs/OUTPUT_UX_RULES.md +38 -32
- package/docs/P14_OPEN_WORK.md +290 -0
- package/docs/README.md +1 -1
- package/docs/SUMMARY.md +36 -22
- package/docs/TERMINAL_CONTRACT.md +89 -17
- package/docs/UI_RENDER_PIPELINE.md +47 -8
- package/docs/agents.md +1 -1
- package/docs/architecture.md +10 -8
- package/docs/autonomous-scheduler.md +142 -0
- package/docs/choosing-mode.md +4 -2
- package/docs/cli.md +11 -9
- package/docs/concepts.md +5 -5
- package/docs/config-providers.md +3 -3
- package/docs/config.md +1 -1
- package/docs/contributing.md +7 -9
- package/docs/environment.md +8 -5
- package/docs/getting-started.md +5 -5
- package/docs/mcp-lsp.md +2 -2
- package/docs/memory-sessions.md +3 -3
- package/docs/policy-sandbox.md +7 -4
- package/docs/pricing-budget.md +3 -3
- package/docs/quickstart.md +1 -1
- package/docs/repl.md +11 -8
- package/docs/security-model.md +4 -2
- package/docs/security.md +9 -8
- package/docs/skills.md +2 -2
- package/docs/terminal.md +10 -2
- package/docs/tools.md +4 -4
- package/docs/troubleshooting.md +3 -3
- package/docs/verify-benchmark.md +0 -3
- package/package.json +9 -18
- 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 +128 -10
- package/src/constants.ts +32 -1
- package/src/daemon/client.ts +11 -6
- package/src/daemon/control.ts +2 -9
- package/src/daemon/resource.ts +5 -4
- package/src/hooks/run.ts +5 -6
- 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/http-transport.ts +1 -1
- 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 +58 -16
- package/src/policy/bpe.ts +110 -0
- package/src/policy/compaction.ts +139 -22
- package/src/policy/consequence-engine.ts +3 -3
- package/src/policy/context-window.ts +43 -1
- package/src/policy/context.ts +50 -12
- package/src/policy/jail.ts +48 -3
- package/src/policy/no-progress.ts +15 -8
- package/src/policy/permission.ts +243 -5
- 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 +8 -4
- package/src/presentation/events.ts +2 -2
- package/src/presentation/label.ts +3 -3
- package/src/presentation/model.ts +4 -0
- package/src/presentation/projection.ts +10 -2
- package/src/presentation/store.ts +2 -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/child-execution.ts +1 -1
- package/src/runtime/composition.ts +5 -5
- package/src/runtime/execution-journal.ts +13 -7
- package/src/runtime/execution-registry.ts +1 -1
- package/src/runtime/production-execution.ts +7 -6
- package/src/runtime/production-runtime.ts +2 -2
- package/src/runtime/runtime-capabilities.ts +1 -1
- package/src/runtime/runtime-status-facts.ts +1 -1
- package/src/runtime/runtime-task-admission.ts +2 -2
- package/src/sandbox/os.ts +4 -3
- package/src/session/checkpoint.ts +29 -4
- package/src/session/context-assembly.ts +8 -1
- package/src/session/context-identity.ts +2 -2
- package/src/session/context-projection.ts +36 -11
- package/src/session/persistence.ts +22 -11
- package/src/task/autonomous-context.ts +2 -3
- package/src/task/autonomous-policy.ts +3 -3
- package/src/task/model.ts +2 -2
- package/src/task/production-scheduler.ts +2 -2
- package/src/task/scheduler-observability.ts +1 -0
- package/src/task/scheduler.ts +3 -2
- package/src/task/scheduling-policy.ts +2 -1
- package/src/task/trigger.ts +5 -5
- package/src/tools/git.ts +22 -4
- package/src/tools/lsp.ts +10 -8
- package/src/tools/read_image.ts +2 -1
- package/src/tools/task.ts +1 -1
- package/src/tools/web_fetch.ts +6 -2
- package/src/tools/web_search.ts +2 -1
- package/src/ui/assistant/simple.ts +42 -33
- package/src/ui/contract.ts +4 -0
- package/src/ui/footer.ts +63 -12
- package/src/ui/i18n/en.ts +14 -2
- package/src/ui/i18n/id.ts +14 -2
- package/src/ui/input/prompt-engine.ts +36 -10
- package/src/ui/render/cells.ts +320 -0
- package/src/ui/render/composer-wrap.ts +73 -0
- package/src/ui/render/detail.ts +2 -2
- package/src/ui/render/diff.ts +14 -5
- package/src/ui/render/highlight.ts +4 -4
- package/src/ui/render/ledger.ts +47 -0
- 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 +49 -4
- package/src/ui/render/width.ts +91 -4
- package/src/ui/render/wrap.ts +5 -3
- package/src/ui/runtime/screen.ts +100 -22
- package/src/ui/runtime/statusline.ts +26 -0
- package/src/ui/screens/model-manager.ts +1 -1
- package/src/ui/session-state.ts +27 -1
- package/src/ui/tui/app.ts +336 -65
- package/src/ui/tui/transcript.ts +335 -104
- package/vendor/minicore/VENDOR.md +16 -12
- package/vendor/minicore/src/core/events.ts +1 -0
- package/vendor/minicore/src/core/loop.ts +11 -1
- package/vendor/minicore/src/core/session.ts +39 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# MiniCode
|
|
2
2
|
|
|
3
|
-
MiniCode is
|
|
3
|
+
MiniCode is an open-source terminal coding agent built on the frozen MiniCore kernel. It is zero-dependency (Bun is the only runtime). It inspects and edits a workspace, runs local tools, and connects to the AI providers and MCP/LSP servers you configure.
|
|
4
4
|
|
|
5
|
-
Interactive sessions
|
|
5
|
+
Interactive sessions run as a fullscreen TUI; one-shot and automation runs flow to the shell scrollback or a machine-readable JSONL stream. Every tool action is visible in the ledger, file changes are jailed to the workspace, and sensitive actions are gated behind your permission. Prompts and relevant workspace context are sent to the provider you configure; MCP and LSP servers may receive data or perform external effects. MiniCode itself sends no telemetry — traces are local-only (`MINICODE_TELEMETRY=0` to disable).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ minicode
|
|
|
16
16
|
To run from a clone:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
git clone https://github.com/
|
|
19
|
+
git clone https://github.com/minilabs-id/minicode.git
|
|
20
20
|
cd minicode
|
|
21
21
|
bun install
|
|
22
22
|
bun run dev
|
|
@@ -36,12 +36,14 @@ WorkMode controls how the agent works (`DISCUSS`, `PLAN`, or `BUILD`); permissio
|
|
|
36
36
|
|
|
37
37
|
## Documentation
|
|
38
38
|
|
|
39
|
+
The full manual lives in [`docs/`](docs/) and is rendered at [minilabs.id/projects/minicode/docs](https://minilabs.id/projects/minicode/docs/). Quick links:
|
|
40
|
+
|
|
39
41
|
- [Documentation index](docs/README.md) and [full navigation](docs/SUMMARY.md)
|
|
40
42
|
- [Installation](docs/getting-started.md) · [Quickstart](docs/quickstart.md) · [CLI](docs/cli.md) · [TUI](docs/repl.md)
|
|
41
43
|
- [Configuration and providers](docs/config.md) · [Environment variables](docs/environment.md) · [Tools](docs/tools.md)
|
|
42
44
|
- [Security model](docs/security-model.md) · [Policy and sandbox](docs/policy-sandbox.md)
|
|
43
45
|
- [Architecture and repository map](docs/architecture.md)
|
|
44
|
-
- [Contributing](docs/contributing.md) · [Release history](https://github.com/
|
|
46
|
+
- [Contributing](docs/contributing.md) · [Release history](https://github.com/minilabs-id/minicode/releases)
|
|
45
47
|
|
|
46
48
|
## Development checks
|
|
47
49
|
|
package/cli/args.ts
CHANGED
|
@@ -271,24 +271,36 @@ export function readPrompt(): Promise<string> {
|
|
|
271
271
|
return new Promise((resolve) => {
|
|
272
272
|
let data = ""
|
|
273
273
|
let done = false
|
|
274
|
+
const onData = (c: string | Buffer) => {
|
|
275
|
+
data += String(c)
|
|
276
|
+
}
|
|
277
|
+
const onEnd = () => {
|
|
278
|
+
if (!done) {
|
|
279
|
+
done = true
|
|
280
|
+
clearTimeout(t)
|
|
281
|
+
cleanup()
|
|
282
|
+
resolve(data.trim())
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const cleanup = () => {
|
|
286
|
+
process.stdin.off("data", onData)
|
|
287
|
+
process.stdin.off("end", onEnd)
|
|
288
|
+
}
|
|
274
289
|
const t = setTimeout(() => {
|
|
275
290
|
if (!done) {
|
|
276
291
|
done = true
|
|
292
|
+
cleanup()
|
|
277
293
|
resolve("")
|
|
278
294
|
}
|
|
279
295
|
}, 500)
|
|
280
296
|
process.stdin.setEncoding("utf8")
|
|
281
|
-
process.stdin.on("data",
|
|
282
|
-
process.stdin.on("end",
|
|
283
|
-
if (!done) {
|
|
284
|
-
done = true
|
|
285
|
-
clearTimeout(t)
|
|
286
|
-
resolve(data.trim())
|
|
287
|
-
}
|
|
288
|
-
})
|
|
297
|
+
process.stdin.on("data", onData)
|
|
298
|
+
process.stdin.on("end", onEnd)
|
|
289
299
|
// if stdin already ended
|
|
290
300
|
if (process.stdin.readableEnded) {
|
|
301
|
+
done = true
|
|
291
302
|
clearTimeout(t)
|
|
303
|
+
cleanup()
|
|
292
304
|
resolve("")
|
|
293
305
|
}
|
|
294
306
|
})
|
package/cli/commands/exec.ts
CHANGED
|
@@ -178,12 +178,13 @@ export async function handleExec(
|
|
|
178
178
|
`[warn] MINICODE_COMPACT_KEEP_TURNS requires an integer >= 1, ignoring "${keepTurnsRaw}"\n`,
|
|
179
179
|
)
|
|
180
180
|
const timeoutRaw = getArg("--timeout")
|
|
181
|
-
|
|
181
|
+
// exec (one-shot/CI) default 15 menit — lebih konservatif dari interaktif (1 jam).
|
|
182
|
+
let timeoutMs = timeoutRaw ? Number(timeoutRaw) : 900_000
|
|
182
183
|
if (timeoutRaw && (!Number.isFinite(timeoutMs) || (timeoutMs as number) < 0)) {
|
|
183
184
|
process.stderr.write(
|
|
184
185
|
`[warn] --timeout requires a non-negative number, ignoring "${timeoutRaw}"\n`,
|
|
185
186
|
)
|
|
186
|
-
timeoutMs =
|
|
187
|
+
timeoutMs = 900_000
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
const ignoredFlags = flagsAfterPromptBoundary(subArgs)
|
|
@@ -314,6 +315,20 @@ export async function handleExec(
|
|
|
314
315
|
else process.stderr.write(`${msg}\n`)
|
|
315
316
|
process.exit(1)
|
|
316
317
|
}
|
|
318
|
+
unsubMachine()
|
|
319
|
+
unsubText()
|
|
320
|
+
await ctx.persistCurrent(ue)
|
|
321
|
+
// P2.2: histori yang tak durable = kegagalan jujur (bukan exit 0). Diperiksa
|
|
322
|
+
// SEBELUM menulis machineSummary(true) agar stdout JSONL tidak pernah
|
|
323
|
+
// memancarkan dua summary terminal yang saling bertentangan (ok:true lalu ok:false).
|
|
324
|
+
if (ctx.isWriterStale()) {
|
|
325
|
+
const msg = `[writer] stale writer, history NOT durable: ${ctx.writerStaleNote()}`
|
|
326
|
+
if (jsonMode)
|
|
327
|
+
writeMachineLine(JSON.stringify(machineFailure(effectivePrompt, new Error(msg))))
|
|
328
|
+
else process.stderr.write(`${msg}\n`)
|
|
329
|
+
await ctx.close()
|
|
330
|
+
process.exit(1)
|
|
331
|
+
}
|
|
317
332
|
// Ringkasan memakai total SESI (ue), bukan turn terakhir: dengan --verify
|
|
318
333
|
// (multi-turn + reset antar-siklus) angka turn mengecilkan pemakaian nyata.
|
|
319
334
|
if (jsonMode) {
|
|
@@ -363,18 +378,6 @@ export async function handleExec(
|
|
|
363
378
|
`\n[exec] done model=${ctx.modelRef.current} steps=${ctx.session.state.stepCount} tokens=${ue.totalTokens} ${Date.now() - t0}ms\n`,
|
|
364
379
|
)
|
|
365
380
|
}
|
|
366
|
-
unsubMachine()
|
|
367
|
-
unsubText()
|
|
368
|
-
await ctx.persistCurrent(ue)
|
|
369
|
-
// P2.2: histori yang tak durable = kegagalan jujur (bukan exit 0).
|
|
370
|
-
if (ctx.isWriterStale()) {
|
|
371
|
-
const msg = `[writer] stale writer, history NOT durable: ${ctx.writerStaleNote()}`
|
|
372
|
-
if (jsonMode)
|
|
373
|
-
writeMachineLine(JSON.stringify(machineFailure(effectivePrompt, new Error(msg))))
|
|
374
|
-
else process.stderr.write(`${msg}\n`)
|
|
375
|
-
await ctx.close()
|
|
376
|
-
process.exit(1)
|
|
377
|
-
}
|
|
378
381
|
await ctx.close()
|
|
379
382
|
process.exit(0)
|
|
380
383
|
} catch (e) {
|
package/cli/commands/openwork.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// kebijakan (termasuk kegagalan tulis ekspor) · 2 salah pakai.
|
|
20
20
|
//
|
|
21
21
|
// Teks tak-terpercaya (judul task, ringkasan intent, evidence operator, id
|
|
22
|
-
// sesi dari DB) tidak pernah dicetak mentah di luar tabel:
|
|
22
|
+
// sesi dari DB) tidak pernah dicetak mentah di luar tabel: renderListHuman
|
|
23
23
|
// menyani tiap sel, dan baris bebas (ringkasan merge, refusal, ekspor MD)
|
|
24
24
|
// lewat sanitizeAnsi eksplisit.
|
|
25
25
|
//
|
package/cli/commands.ts
CHANGED
|
@@ -40,9 +40,9 @@ export interface CommandContext {
|
|
|
40
40
|
workMode?: string
|
|
41
41
|
permissionMode?: string
|
|
42
42
|
setModelOverride: (model: string) => void
|
|
43
|
-
/** Dipanggil sebelum spawn anak stdio-inherit — composition root (tui.ts)
|
|
44
|
-
* mengisinya
|
|
45
|
-
*
|
|
43
|
+
/** Dipanggil sebelum spawn anak stdio-inherit — composition root (cli/tui.ts)
|
|
44
|
+
* mengisinya untuk melepas terminal alt-screen + raw mode. Tanpa injeksi
|
|
45
|
+
* tetap jalan (no-op). */
|
|
46
46
|
onBeforeSpawn?: () => void
|
|
47
47
|
/** Kontrak control-plane (Phase 6): angka konteks SAAT INI dari sumber
|
|
48
48
|
* kebenaran kernel (estimateSessionContext) — bukan usage kumulatif.
|
|
@@ -163,14 +163,28 @@ export const DRIVER_HELP_COMMANDS: BuiltinCommand[] = [
|
|
|
163
163
|
{ name: "scheduler", args: "[status|run|stop]", descKey: "help.desc.scheduler" },
|
|
164
164
|
]
|
|
165
165
|
|
|
166
|
-
/**
|
|
166
|
+
/** Grup kurasi untuk /help: kategori semantik (bukan urutan registrasi). Dipakai
|
|
167
|
+
* render full help supaya mudah dipindai; nama di sini harus 1:1 dengan isi
|
|
168
|
+
* BUILTIN_COMMANDS + DRIVER_HELP_COMMANDS. */
|
|
169
|
+
const HELP_GROUPS: readonly { key: MsgKey; names: readonly string[] }[] = [
|
|
170
|
+
{
|
|
171
|
+
key: "help.gGeneral",
|
|
172
|
+
names: ["help", "status", "sessions", "history", "clear", "copy", "init", "exit"],
|
|
173
|
+
},
|
|
174
|
+
{ key: "help.gModel", names: ["model", "provider", "sync"] },
|
|
175
|
+
{ key: "help.gMode", names: ["mode", "work-mode", "undo", "redo", "lang"] },
|
|
176
|
+
{ key: "help.gTask", names: ["scheduler"] },
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
/** Pintasan papan tombol TUI — didokumentasikan di /help keys, bukan hanya kode. */
|
|
167
180
|
const KEYBOARD_HELP: [string, MsgKey][] = [
|
|
168
181
|
["enter", "help.k.submit"],
|
|
169
|
-
["tab
|
|
182
|
+
["tab", "help.k.workMode"],
|
|
183
|
+
["shift+tab", "help.k.permission"],
|
|
170
184
|
["up / down", "help.k.history"],
|
|
171
185
|
["mouse wheel", "help.k.mouse"],
|
|
172
186
|
["pgup / pgdn", "help.k.scroll"],
|
|
173
|
-
["home / end (prompt)", "help.k.jumpTop"],
|
|
187
|
+
["home / end (empty prompt)", "help.k.jumpTop"],
|
|
174
188
|
["left / right", "help.k.move"],
|
|
175
189
|
["home / end", "help.k.jump"],
|
|
176
190
|
["delete", "help.k.delChar"],
|
|
@@ -191,8 +205,8 @@ function pad(text: string, width: number): string {
|
|
|
191
205
|
}
|
|
192
206
|
|
|
193
207
|
/**
|
|
194
|
-
* Isi readout /status sebagai data (tanpa dekorasi cetak) — dipakai
|
|
195
|
-
*
|
|
208
|
+
* Isi readout /status sebagai data (tanpa dekorasi cetak) — dipakai jalur cetak
|
|
209
|
+
* (non-TTY) via `printStatus` yang formatnya harus identik dengan TUI.
|
|
196
210
|
*/
|
|
197
211
|
function statusLines(ctx: CommandContext): string[] {
|
|
198
212
|
// Kumulatif sesi, bukan turn terakhir — judulnya menjanjikan "biaya sesi".
|
|
@@ -230,7 +244,7 @@ function statusLines(ctx: CommandContext): string[] {
|
|
|
230
244
|
]
|
|
231
245
|
}
|
|
232
246
|
|
|
233
|
-
/** Cetak /status
|
|
247
|
+
/** Cetak /status (jalur non-TTY + TUI). Struktur panggilan
|
|
234
248
|
* dipertahankan (satu console.log per baris): helper test captureOutput
|
|
235
249
|
* mencatat per panggilan, bukan per baris newline. */
|
|
236
250
|
function printStatus(ctx: CommandContext): void {
|
|
@@ -463,28 +477,30 @@ export async function handleBuiltinCommand(
|
|
|
463
477
|
|
|
464
478
|
switch (cmd) {
|
|
465
479
|
case "help": {
|
|
466
|
-
//
|
|
467
|
-
// /help
|
|
468
|
-
//
|
|
469
|
-
|
|
470
|
-
|
|
480
|
+
// /help keys|tombol = pintasan keyboard; selain itu (termasuk /help full,
|
|
481
|
+
// /help all, atau /help kosong dari non-TTY) = full help terkelompok.
|
|
482
|
+
// Satu pemanggilan cetak PER BARIS: TUI (runBuiltin) menangkap panggilan
|
|
483
|
+
// per baris, dan test juga menangkap per panggilan — inventory writer
|
|
484
|
+
// menghitung literal cetak ini (+1 untuk header grup).
|
|
485
|
+
if (/^(tombol|keys?|keyboard)$/i.test(args.trim())) {
|
|
471
486
|
console.log(`\n${t("help.kHead")}`)
|
|
472
487
|
for (const [key, keyDesc] of KEYBOARD_HELP) {
|
|
473
|
-
console.log(` ${pad(key,
|
|
488
|
+
console.log(` ${pad(key, 24)}${t(keyDesc)}`)
|
|
474
489
|
}
|
|
475
490
|
console.log("")
|
|
476
491
|
return { handled: true }
|
|
477
492
|
}
|
|
493
|
+
const all = new Map([...BUILTIN_COMMANDS, ...DRIVER_HELP_COMMANDS].map((b) => [b.name, b]))
|
|
478
494
|
console.log(`\n${t("help.head")}`)
|
|
479
|
-
for (const
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
|
|
495
|
+
for (const group of HELP_GROUPS) {
|
|
496
|
+
console.log(` ${t(group.key)}`)
|
|
497
|
+
for (const name of group.names) {
|
|
498
|
+
const b = all.get(name)
|
|
499
|
+
if (!b || b.hidden) continue
|
|
500
|
+
const withArgs = b.args ? `${b.name} ${b.args}` : b.name
|
|
501
|
+
console.log(` ${pad(`/${withArgs}`, 26)} ${t(b.descKey)}`)
|
|
502
|
+
}
|
|
483
503
|
}
|
|
484
|
-
// Ringkas: perintah utama + skill + pintasan yang paling sering dipakai.
|
|
485
|
-
// Panjang baris di bawah ≤80 kolom (dijaga test) dan tak boleh menyebut
|
|
486
|
-
// /help tombol (juga dijaga test) — Ctrl+R satu-satunya yang paling
|
|
487
|
-
// sering dicari yang muat setelah Enter/Tab/Shift+Tab.
|
|
488
504
|
console.log(`\n${t("help.keysLine")}\n`)
|
|
489
505
|
return { handled: true }
|
|
490
506
|
}
|
package/cli/index.ts
CHANGED
|
@@ -73,10 +73,10 @@ Options:
|
|
|
73
73
|
--allowlist bash allowlist only (see MINICODE_BASH_ALLOWLIST)
|
|
74
74
|
--max-steps <n> max tool steps (default 50)
|
|
75
75
|
--context-window <n> context window tokens
|
|
76
|
-
--timeout <ms> hard deadline per run (default
|
|
76
|
+
--timeout <ms> hard deadline per run (default 3600000 = 1h, 0 = off)
|
|
77
77
|
--interactive interactive TUI (default bila tanpa prompt di TTY)
|
|
78
78
|
--verify auto-verify + self-heal (typecheck/test/tsconfig)
|
|
79
|
-
--sandbox <mode> bash sandbox: docker (ephemeral, no network)
|
|
79
|
+
--sandbox <mode> bash sandbox: docker (ephemeral, no network) | os (bwrap/seatbelt)
|
|
80
80
|
--ratelimit <rpm> LLM requests per minute
|
|
81
81
|
--budget <usd> session cost limit
|
|
82
82
|
--budget-strict unknown cost + spend counts as over budget (fail-closed default)
|
|
@@ -254,7 +254,7 @@ if (args.includes("-h") || args.includes("--help")) {
|
|
|
254
254
|
{ flag: "--context-window <n>", desc: "context window tokens" },
|
|
255
255
|
{
|
|
256
256
|
flag: "--timeout <ms>",
|
|
257
|
-
desc: "hard deadline per run (default
|
|
257
|
+
desc: "hard deadline per run (default 3600000 = 60min; 0 = Infinity)",
|
|
258
258
|
},
|
|
259
259
|
{ flag: "--allow-all", desc: "allow all tools (privileged access profile)" },
|
|
260
260
|
{ flag: "--ask", desc: "ask per tool (human-supervised)" },
|
|
@@ -467,9 +467,10 @@ const enterRepl = interactive || (!prompt && process.stdin.isTTY)
|
|
|
467
467
|
// versi baru (tak pernah kembali bila restart). Tampilkan spinner 1.8 dtk
|
|
468
468
|
// agar tidak terlihat hang — budget tetap, hanya UX.
|
|
469
469
|
// Spinner transient HANYA lewat ownership tunggal (src/ui/runtime/spinner) —
|
|
470
|
-
// tulis mentah ke stderr
|
|
471
|
-
//
|
|
472
|
-
// interaktif
|
|
470
|
+
// tulis mentah ke stderr lewat arbitrase statusline.ts: pesan [warn] lain
|
|
471
|
+
// di-commit sebagai baris permanen, dan frame spinner tak menghapus baris layar
|
|
472
|
+
// interaktif saat wizard setup pertama aktif (statusline.beginInteractiveScreen
|
|
473
|
+
// menahan paintWrite).
|
|
473
474
|
const { createSpinner } = await import("../src/ui/runtime/spinner.ts")
|
|
474
475
|
if (enterRepl) {
|
|
475
476
|
const ctrl = new AbortController()
|
|
@@ -592,12 +593,33 @@ if (enterRepl) {
|
|
|
592
593
|
// Satu-satunya tampilan interaktif = TUI fullscreen (REPL linier dihapus).
|
|
593
594
|
// One-shot/exec tak tersentuh (cabang else di bawah).
|
|
594
595
|
const { runTui } = await import("./tui.ts")
|
|
596
|
+
const replStart = Date.now()
|
|
595
597
|
try {
|
|
596
598
|
await runTui(ctx)
|
|
597
599
|
} catch (error) {
|
|
598
600
|
process.stderr.write(`[error] ${formatError(error)}\n`)
|
|
599
601
|
process.exitCode = 1
|
|
600
602
|
}
|
|
603
|
+
// Kop ringkasan sesi saat exit (logo + detail). HANYA untuk sesi interaktif
|
|
604
|
+
// nyata (stdout TTY): `--interactive` lewat pipe/paksa TUI tanpa terminal
|
|
605
|
+
// harus TIDAK menulis apa pun ke stdout (dicek test startup-failure).
|
|
606
|
+
// Clear screen + home digabung SATU write dengan summary (OAP-008: writer
|
|
607
|
+
// count per berkas dibatasi) — keluar alternate-screen tak selalu kembalikan
|
|
608
|
+
// kursor ke baris bersih (ConPTY), jadi clear mencegah tumpang-tindih teks.
|
|
609
|
+
if (process.stdout.isTTY) {
|
|
610
|
+
try {
|
|
611
|
+
const u = ctx.usage.getSession(ctx.modelRef.current)
|
|
612
|
+
const { renderSessionSummary } = await import("../src/ui/render/session-summary.ts")
|
|
613
|
+
const summary = renderSessionSummary({
|
|
614
|
+
sessionId: ctx.sessionId,
|
|
615
|
+
model: ctx.modelRef.current ?? "default",
|
|
616
|
+
totalTokens: u.totalTokens,
|
|
617
|
+
...(u.cost != null ? { cost: u.cost } : {}),
|
|
618
|
+
durationMs: Date.now() - replStart,
|
|
619
|
+
})
|
|
620
|
+
process.stdout.write(`\x1b[2J\x1b[H${summary}`)
|
|
621
|
+
} catch {}
|
|
622
|
+
}
|
|
601
623
|
} else {
|
|
602
624
|
// P12 S2.2 (F-DISCUSS-4) + P0.2: one-shot linear memakai `ctx.workMode`
|
|
603
625
|
// efektif (termasuk hasil pulihan `--resume`).
|
|
@@ -689,7 +711,7 @@ if (enterRepl) {
|
|
|
689
711
|
})
|
|
690
712
|
} catch (e) {
|
|
691
713
|
// Error provider biasanya sudah dirender ramah oleh event handler
|
|
692
|
-
// (takePendingError) — cetak sekali saja, jangan dua blok
|
|
714
|
+
// (takePendingError) — cetak sekali saja, jangan dua blok error.
|
|
693
715
|
const shown = ctx.uiState.takePendingError()
|
|
694
716
|
process.stderr.write(`\n${c.red(glyphs.cross)} ${shown ?? formatError(e)}\n`)
|
|
695
717
|
// Audit #04 P1: sama seperti REPL — turn gagal setelah delegasi
|
package/cli/model-manager.ts
CHANGED
|
@@ -51,7 +51,7 @@ export async function runModelManager(opts: {
|
|
|
51
51
|
// scope asal jadi tak terlihat ("balik lagi"). SEMUA salinan diupdate (bila
|
|
52
52
|
// duplikat lintas file sudah terlanjur ada) agar tak ada yang menghidupkan
|
|
53
53
|
// data basi. Lempar bila provider tak ada di scope mana pun — view
|
|
54
|
-
// menampilkan
|
|
54
|
+
// menampilkan pesan error berwarna (dulu ditelan diam-diam).
|
|
55
55
|
const updateProviderInScopes = async (
|
|
56
56
|
id: string,
|
|
57
57
|
mutate: (p: ProviderEntry) => void,
|
package/cli/router.ts
CHANGED
|
@@ -58,6 +58,7 @@ export async function dispatch(
|
|
|
58
58
|
for (let i = 0; i < subArgv.length; i++) {
|
|
59
59
|
const a = subArgv[i]
|
|
60
60
|
if (a === undefined) continue
|
|
61
|
+
if (a === "--") break
|
|
61
62
|
if (a === name) {
|
|
62
63
|
const v = subArgv[i + 1]
|
|
63
64
|
if (v !== undefined && (v === "-" || !v.startsWith("-") || /^-?\d+(\.\d+)?$/.test(v)))
|
|
@@ -70,6 +71,16 @@ export async function dispatch(
|
|
|
70
71
|
return found
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
// P11.x — argv scoped untuk SEMUA handler subcommand: kecuali yang sudah
|
|
75
|
+
// memakai pola own-scoped (openwork/exec/daemon), handler lain mengindeks
|
|
76
|
+
// `args[0]`/`args[1]` sebagai token subcommand. `args` di sini adalah argv
|
|
77
|
+
// PENUH, jadi flag global yang mendahului subcommand (mis. `--cwd X sessions
|
|
78
|
+
// list` atau `--json pricing status`) membuat `args[1]` menyimpan NILAI flag,
|
|
79
|
+
// bukan sub-aksi — handler mencetak "unknown subcommand: <path>" atau diam
|
|
80
|
+
// (providers exit 0). `args.slice(cmdIndex)` menempatkan kembali token
|
|
81
|
+
// subcommand di indeks 0; flag global tetap terbaca lewat `subGetArg`
|
|
82
|
+
// (berbasis subArgv yang sudah memuat flag global + argv dari cmd).
|
|
83
|
+
const scoped = args.slice(cmdIndex)
|
|
73
84
|
if (cmd === "stats") {
|
|
74
85
|
const { handleStats } = await import("./commands/stats.ts")
|
|
75
86
|
await handleStats(subGetArg)
|
|
@@ -77,44 +88,46 @@ export async function dispatch(
|
|
|
77
88
|
}
|
|
78
89
|
if (cmd === "sessions") {
|
|
79
90
|
const { handleSessions } = await import("./commands/sessions.ts")
|
|
80
|
-
await handleSessions(
|
|
91
|
+
await handleSessions(scoped, subGetArg)
|
|
81
92
|
return true
|
|
82
93
|
}
|
|
83
94
|
if (cmd === "openwork") {
|
|
84
95
|
// [P14.4] Portofolio open-work lintas sesi (read-only) + merge dedup
|
|
85
96
|
// eksplisit (P14.3). Handler process.exit sendiri (kontrak I28).
|
|
97
|
+
// openwork memakai `args.indexOf("openwork")` (actionAfter), jadi ia tetap
|
|
98
|
+
// menerima argv penuh agar token "openwork" tetap ditemukan.
|
|
86
99
|
const { handleOpenwork } = await import("./commands/openwork.ts")
|
|
87
100
|
await handleOpenwork(args, subGetArg)
|
|
88
101
|
return true
|
|
89
102
|
}
|
|
90
103
|
if (cmd === "mcp") {
|
|
91
104
|
const { handleMcp } = await import("./commands/mcp.ts")
|
|
92
|
-
await handleMcp(
|
|
105
|
+
await handleMcp(scoped, subGetArg, HELP)
|
|
93
106
|
return true
|
|
94
107
|
}
|
|
95
108
|
if (cmd === "config") {
|
|
96
109
|
const { handleConfig } = await import("./commands/config.ts")
|
|
97
|
-
await handleConfig(
|
|
110
|
+
await handleConfig(scoped, subGetArg, HELP)
|
|
98
111
|
return true
|
|
99
112
|
}
|
|
100
113
|
if (cmd === "skills") {
|
|
101
114
|
const { handleSkills } = await import("./commands/skills.ts")
|
|
102
|
-
await handleSkills(
|
|
115
|
+
await handleSkills(scoped, subGetArg)
|
|
103
116
|
return true
|
|
104
117
|
}
|
|
105
118
|
if (cmd === "providers" || cmd === "models" || cmd === "sync") {
|
|
106
119
|
const { handleProviders } = await import("./commands/providers.ts")
|
|
107
|
-
await handleProviders(
|
|
120
|
+
await handleProviders(scoped, subGetArg)
|
|
108
121
|
return true
|
|
109
122
|
}
|
|
110
123
|
if (cmd === "auth") {
|
|
111
124
|
const { handleAuth } = await import("./commands/auth.ts")
|
|
112
|
-
await handleAuth(
|
|
125
|
+
await handleAuth(scoped)
|
|
113
126
|
return true
|
|
114
127
|
}
|
|
115
128
|
if (cmd === "pricing") {
|
|
116
129
|
const { handlePricing } = await import("./commands/pricing.ts")
|
|
117
|
-
await handlePricing(
|
|
130
|
+
await handlePricing(scoped)
|
|
118
131
|
return true
|
|
119
132
|
}
|
|
120
133
|
if (cmd === "exec") {
|
|
@@ -150,12 +163,12 @@ export async function dispatch(
|
|
|
150
163
|
}
|
|
151
164
|
if (cmd === "memory") {
|
|
152
165
|
const { handleMemory } = await import("./commands/memory.ts")
|
|
153
|
-
await handleMemory(
|
|
166
|
+
await handleMemory(scoped, subGetArg)
|
|
154
167
|
return true
|
|
155
168
|
}
|
|
156
169
|
if (cmd === "doctor") {
|
|
157
170
|
const { handleDoctor } = await import("./commands/doctor.ts")
|
|
158
|
-
await handleDoctor(
|
|
171
|
+
await handleDoctor(scoped, subGetArg)
|
|
159
172
|
return true
|
|
160
173
|
}
|
|
161
174
|
return false
|