minicode-ai 0.15.0 → 0.21.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/auto-update.ts +24 -15
- package/cli/commands/exec.ts +3 -2
- package/cli/commands/openwork.ts +1 -1
- package/cli/commands.ts +6 -6
- package/cli/index.ts +61 -22
- package/cli/model-manager.ts +1 -1
- package/cli/setup.ts +119 -62
- package/cli/tui.ts +128 -13
- package/docs/CONTROL-PLANE-MAP.md +6 -4
- 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 +74 -11
- package/docs/UI_RENDER_PIPELINE.md +53 -11
- package/docs/agents.md +1 -1
- package/docs/architecture.md +9 -8
- package/docs/autonomous-scheduler.md +142 -0
- package/docs/choosing-mode.md +2 -2
- package/docs/cli.md +4 -4
- package/docs/concepts.md +5 -5
- package/docs/config-providers.md +3 -3
- package/docs/contributing.md +7 -9
- package/docs/environment.md +6 -4
- package/docs/getting-started.md +4 -4
- package/docs/mcp-lsp.md +2 -2
- package/docs/memory-sessions.md +1 -1
- package/docs/policy-sandbox.md +7 -4
- package/docs/pricing-budget.md +3 -3
- package/docs/quickstart.md +1 -1
- package/docs/repl.md +5 -5
- package/docs/security-model.md +1 -1
- 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/src/app/session.ts +40 -7
- package/src/constants.ts +31 -0
- package/src/hooks/run.ts +5 -6
- package/src/mcp/http-transport.ts +1 -1
- package/src/policy/bash-guard.ts +26 -6
- package/src/policy/compaction.ts +107 -17
- package/src/policy/consequence-engine.ts +3 -3
- package/src/policy/context-window.ts +24 -1
- package/src/policy/context.ts +16 -4
- package/src/policy/permission.ts +219 -4
- package/src/policy/update-check.ts +6 -4
- package/src/presentation/adapter.ts +1 -1
- package/src/presentation/events.ts +2 -2
- package/src/presentation/label.ts +3 -3
- package/src/presentation/model.ts +4 -0
- package/src/presentation/store.ts +2 -2
- package/src/runtime/child-execution.ts +1 -1
- package/src/runtime/composition.ts +5 -5
- package/src/runtime/execution-registry.ts +1 -1
- package/src/runtime/production-execution.ts +3 -3
- 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/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 +1 -1
- package/src/task/autonomous-context.ts +2 -2
- 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.ts +3 -2
- package/src/task/scheduling-policy.ts +2 -1
- package/src/task/trigger.ts +5 -5
- package/src/tools/read_image.ts +2 -1
- package/src/tools/task.ts +1 -1
- package/src/ui/assistant/simple.ts +47 -30
- package/src/ui/footer.ts +48 -9
- package/src/ui/i18n/en.ts +21 -0
- package/src/ui/i18n/id.ts +21 -0
- package/src/ui/input/prompt-engine.ts +36 -10
- package/src/ui/render/activity-group.ts +53 -0
- package/src/ui/render/activity-panel.ts +91 -0
- package/src/ui/render/cells.ts +347 -0
- package/src/ui/render/composer-wrap.ts +73 -0
- package/src/ui/render/detail.ts +2 -2
- package/src/ui/render/diff.ts +7 -0
- package/src/ui/render/ledger.ts +47 -0
- package/src/ui/render/markdown.ts +6 -1
- package/src/ui/render/session-summary.ts +7 -2
- package/src/ui/render/theme.ts +40 -4
- package/src/ui/render/width.ts +2 -2
- package/src/ui/render/wrap.ts +5 -3
- package/src/ui/runtime/loading-bar.ts +125 -0
- package/src/ui/runtime/screen.ts +84 -7
- package/src/ui/runtime/statusline.ts +26 -0
- package/src/ui/screens/model-manager.ts +1 -1
- package/src/ui/session-state.ts +22 -0
- package/src/ui/tui/app.ts +336 -65
- package/src/ui/tui/transcript.ts +407 -106
- package/vendor/minicore/VENDOR.md +15 -11
- package/vendor/minicore/src/core/events.ts +1 -0
- package/vendor/minicore/src/core/loop.ts +10 -0
- 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/auto-update.ts
CHANGED
|
@@ -45,7 +45,14 @@ export function waitChildExit(child: ChildProcess): Promise<number | null> {
|
|
|
45
45
|
export async function maybeAutoUpdate(
|
|
46
46
|
version: string,
|
|
47
47
|
signal?: AbortSignal,
|
|
48
|
-
opts?: {
|
|
48
|
+
opts?: {
|
|
49
|
+
onLongOp?: () => void
|
|
50
|
+
getInstalledVersion?: () => string
|
|
51
|
+
/** Fase progres untuk bar loading: "check" | "install" | "restart". */
|
|
52
|
+
onPhase?: (phase: "check" | "install" | "restart") => void
|
|
53
|
+
/** Sink pesan proses (deferred ke transcript saat bar aktif). */
|
|
54
|
+
onNotice?: (line: string) => void
|
|
55
|
+
},
|
|
49
56
|
): Promise<void> {
|
|
50
57
|
let decision: ReturnType<typeof shouldAutoUpdate>
|
|
51
58
|
try {
|
|
@@ -58,6 +65,7 @@ export async function maybeAutoUpdate(
|
|
|
58
65
|
}
|
|
59
66
|
if (!decision.run) return
|
|
60
67
|
if (signal?.aborted) return
|
|
68
|
+
opts?.onPhase?.("check")
|
|
61
69
|
let latest: string | null
|
|
62
70
|
try {
|
|
63
71
|
latest = await checkForUpdateFresh(version, signal)
|
|
@@ -66,16 +74,16 @@ export async function maybeAutoUpdate(
|
|
|
66
74
|
}
|
|
67
75
|
if (signal?.aborted) return
|
|
68
76
|
if (!latest) return
|
|
69
|
-
// Fase panjang dimulai (install + restart): minta pemanggil
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
// terlihat hang di Windows Terminal.
|
|
77
|
+
// Fase panjang dimulai (install + restart): minta pemanggil menghentikan
|
|
78
|
+
// bar transient-nya DULU. Output anak (npm/respawn) kini dipipe dan
|
|
79
|
+
// disembunyikan (stdio: "pipe") sehingga tidak mengotori bar — pewarisan
|
|
80
|
+
// `inherit` lama membuat output npm mentah menimpa spinner/bar.
|
|
74
81
|
try {
|
|
75
82
|
opts?.onLongOp?.()
|
|
76
83
|
} catch {}
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
opts?.onPhase?.("install")
|
|
85
|
+
opts?.onNotice?.(`${c.yellow(formatUpdateMessage(version, latest))}\n`)
|
|
86
|
+
opts?.onNotice?.(c.dim("Menginstall pembaruan otomatis…\n"))
|
|
79
87
|
let ok = false
|
|
80
88
|
try {
|
|
81
89
|
ok = installUpdate(latest)
|
|
@@ -83,7 +91,7 @@ export async function maybeAutoUpdate(
|
|
|
83
91
|
ok = false
|
|
84
92
|
}
|
|
85
93
|
if (!ok) {
|
|
86
|
-
|
|
94
|
+
opts?.onNotice?.(
|
|
87
95
|
c.yellow(
|
|
88
96
|
`Auto-update gagal — lanjut versi ${version}. Update manual: npm update -g minicode-ai\n`,
|
|
89
97
|
),
|
|
@@ -95,7 +103,7 @@ export async function maybeAutoUpdate(
|
|
|
95
103
|
return verifyInstalledVersion(expected, opts.getInstalledVersion)
|
|
96
104
|
}
|
|
97
105
|
if (!installedMatches(latest)) {
|
|
98
|
-
|
|
106
|
+
opts?.onNotice?.(
|
|
99
107
|
c.yellow(
|
|
100
108
|
`Versi terpasang tidak cocok dengan target ${latest}; mencoba memulihkan ${version}…\n`,
|
|
101
109
|
),
|
|
@@ -107,11 +115,11 @@ export async function maybeAutoUpdate(
|
|
|
107
115
|
restored = false
|
|
108
116
|
}
|
|
109
117
|
if (restored) {
|
|
110
|
-
|
|
111
|
-
c.yellow(`Auto-update dibatalkan; versi ${version} berhasil dipulihkan.\n`),
|
|
112
|
-
)
|
|
118
|
+
opts?.onNotice?.(c.yellow(`Auto-update dibatalkan; versi ${version} berhasil dipulihkan.\n`))
|
|
113
119
|
return
|
|
114
120
|
}
|
|
121
|
+
// Gagal tidak dapat dipulihkan: fatal — tetap cetak + keluar (tidak
|
|
122
|
+
// didefer; proses akan mati).
|
|
115
123
|
process.stderr.write(
|
|
116
124
|
c.error(
|
|
117
125
|
`Auto-update tidak dapat memverifikasi atau memulihkan instalasi. Keluar; pulihkan dengan: npm install -g minicode-ai@${version}\n`,
|
|
@@ -121,8 +129,9 @@ export async function maybeAutoUpdate(
|
|
|
121
129
|
}
|
|
122
130
|
// Restart ke kode baru dengan argv identik; guard env cegah loop bila
|
|
123
131
|
// versi ter-install ternyata masih dilaporkan lebih tua.
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
opts?.onPhase?.("restart")
|
|
133
|
+
opts?.onNotice?.(c.dim(`Restart ke versi ${latest}…\n`))
|
|
134
|
+
// Pastikan bar induk mati sebelum anak hidup (idempoten — onLongOp
|
|
126
135
|
// sudah dipanggil sebelum install, tapi install bisa gagal-skip jalur ini
|
|
127
136
|
// bila dipanggil ulang di masa depan).
|
|
128
137
|
try {
|
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)
|
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.
|
|
@@ -205,8 +205,8 @@ function pad(text: string, width: number): string {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
* Isi readout /status sebagai data (tanpa dekorasi cetak) — dipakai
|
|
209
|
-
*
|
|
208
|
+
* Isi readout /status sebagai data (tanpa dekorasi cetak) — dipakai jalur cetak
|
|
209
|
+
* (non-TTY) via `printStatus` yang formatnya harus identik dengan TUI.
|
|
210
210
|
*/
|
|
211
211
|
function statusLines(ctx: CommandContext): string[] {
|
|
212
212
|
// Kumulatif sesi, bukan turn terakhir — judulnya menjanjikan "biaya sesi".
|
|
@@ -244,7 +244,7 @@ function statusLines(ctx: CommandContext): string[] {
|
|
|
244
244
|
]
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
/** Cetak /status
|
|
247
|
+
/** Cetak /status (jalur non-TTY + TUI). Struktur panggilan
|
|
248
248
|
* dipertahankan (satu console.log per baris): helper test captureOutput
|
|
249
249
|
* mencatat per panggilan, bukan per baris newline. */
|
|
250
250
|
function printStatus(ctx: CommandContext): void {
|
package/cli/index.ts
CHANGED
|
@@ -19,8 +19,10 @@ import { GATE_ENABLED, resolveSchedulerGate } from "../src/task/production-sched
|
|
|
19
19
|
import { writeTrace } from "../src/telemetry/trace.ts"
|
|
20
20
|
import { setSubAgentSessionFactory } from "../src/tools/task.ts"
|
|
21
21
|
import { formatError } from "../src/ui/assistant/simple.ts"
|
|
22
|
+
import { type MsgKey, t } from "../src/ui/i18n/locale.ts"
|
|
22
23
|
import { formatUsd } from "../src/ui/render/money.ts"
|
|
23
24
|
import { c, glyphs } from "../src/ui/render/theme.ts"
|
|
25
|
+
import { motionReduced } from "../src/ui/runtime/motion.ts"
|
|
24
26
|
import {
|
|
25
27
|
allowLocalConfig,
|
|
26
28
|
displayWorkMode,
|
|
@@ -73,10 +75,10 @@ Options:
|
|
|
73
75
|
--allowlist bash allowlist only (see MINICODE_BASH_ALLOWLIST)
|
|
74
76
|
--max-steps <n> max tool steps (default 50)
|
|
75
77
|
--context-window <n> context window tokens
|
|
76
|
-
--timeout <ms> hard deadline per run (default
|
|
78
|
+
--timeout <ms> hard deadline per run (default 3600000 = 1h, 0 = off)
|
|
77
79
|
--interactive interactive TUI (default bila tanpa prompt di TTY)
|
|
78
80
|
--verify auto-verify + self-heal (typecheck/test/tsconfig)
|
|
79
|
-
--sandbox <mode> bash sandbox: docker (ephemeral, no network)
|
|
81
|
+
--sandbox <mode> bash sandbox: docker (ephemeral, no network) | os (bwrap/seatbelt)
|
|
80
82
|
--ratelimit <rpm> LLM requests per minute
|
|
81
83
|
--budget <usd> session cost limit
|
|
82
84
|
--budget-strict unknown cost + spend counts as over budget (fail-closed default)
|
|
@@ -254,7 +256,7 @@ if (args.includes("-h") || args.includes("--help")) {
|
|
|
254
256
|
{ flag: "--context-window <n>", desc: "context window tokens" },
|
|
255
257
|
{
|
|
256
258
|
flag: "--timeout <ms>",
|
|
257
|
-
desc: "hard deadline per run (default
|
|
259
|
+
desc: "hard deadline per run (default 3600000 = 60min; 0 = Infinity)",
|
|
258
260
|
},
|
|
259
261
|
{ flag: "--allow-all", desc: "allow all tools (privileged access profile)" },
|
|
260
262
|
{ flag: "--ask", desc: "ask per tool (human-supervised)" },
|
|
@@ -471,26 +473,38 @@ const enterRepl = interactive || (!prompt && process.stdin.isTTY)
|
|
|
471
473
|
// di-commit sebagai baris permanen, dan frame spinner tak menghapus baris layar
|
|
472
474
|
// interaktif saat wizard setup pertama aktif (statusline.beginInteractiveScreen
|
|
473
475
|
// menahan paintWrite).
|
|
474
|
-
const {
|
|
476
|
+
const { createLoadingBar } = await import("../src/ui/runtime/loading-bar.ts")
|
|
477
|
+
type LoadingBar = NonNullable<ReturnType<typeof createLoadingBar>>
|
|
478
|
+
let startupBar: LoadingBar | null = null
|
|
475
479
|
if (enterRepl) {
|
|
480
|
+
startupBar = createLoadingBar("", { delayMs: 120 })
|
|
476
481
|
const ctrl = new AbortController()
|
|
477
482
|
const to = setTimeout(() => ctrl.abort(), 1800)
|
|
478
|
-
//
|
|
479
|
-
//
|
|
480
|
-
const spin = createSpinner("Checking for updates…", { delayMs: 120, intervalMs: 80 })
|
|
483
|
+
// Fase update: 0–12% (cek) → 35% (install) → 95% (restart). Tidak pernah
|
|
484
|
+
// menembus target fase — 100% hanya ketika REPL benar-benar siap.
|
|
481
485
|
try {
|
|
482
486
|
const { maybeAutoUpdate } = await import("./auto-update.ts")
|
|
483
|
-
// Dipanggil auto-update SEBELUM fase panjang (install npm + respawn anak):
|
|
484
|
-
// matikan spinner agar tak menulis ke stderr yang sama dengan anak selama
|
|
485
|
-
// berjam-jam (stdio inherit) — itu yang terlihat sebagai hang/flicker.
|
|
486
|
-
// Idempoten: aman dipanggil dua kali (sebelum install, sebelum restart).
|
|
487
487
|
await maybeAutoUpdate(readVersion(), ctrl.signal, {
|
|
488
|
-
onLongOp: () =>
|
|
488
|
+
onLongOp: () => startupBar?.stop(),
|
|
489
489
|
getInstalledVersion: readVersion,
|
|
490
|
+
onPhase: (phase) => {
|
|
491
|
+
if (phase === "check") startupBar?.update(t("loading.checking"), 6)
|
|
492
|
+
else if (phase === "install") startupBar?.update(t("loading.installing"), 35)
|
|
493
|
+
else if (phase === "restart") startupBar?.update(t("loading.restarting"), 95)
|
|
494
|
+
},
|
|
495
|
+
onNotice: (line) => {
|
|
496
|
+
// Bar sedang dihentikan selama install/restart — pesan proses tetap
|
|
497
|
+
// dikirim ke stderr (append-only, tersembunyi di balik bar).
|
|
498
|
+
process.stderr.write(line)
|
|
499
|
+
},
|
|
490
500
|
})
|
|
491
501
|
} catch {}
|
|
492
502
|
clearTimeout(to)
|
|
493
|
-
|
|
503
|
+
// Jalur tanpa update (kasus paling umum): hentikan bar update agar tidak
|
|
504
|
+
// bertabrakan dengan bar setup di bawah (satu painter transient pada satu
|
|
505
|
+
// waktu — kind sama, tanpa warning, tapi dua klaim hidup bersamaan).
|
|
506
|
+
startupBar?.stop()
|
|
507
|
+
startupBar = null
|
|
494
508
|
}
|
|
495
509
|
if (!prompt && !enterRepl) {
|
|
496
510
|
process.stderr.write('usage: minicode "prompt" | minicode (interactive mode)\n')
|
|
@@ -516,18 +530,27 @@ try {
|
|
|
516
530
|
|
|
517
531
|
// -- build session --
|
|
518
532
|
// Session setup (provider/RAG/MCP/session) bisa makan detik (network + spawn)
|
|
519
|
-
// TANPA output — user melihat kursor mati.
|
|
520
|
-
// setup, dibersihkan sebelum
|
|
521
|
-
//
|
|
522
|
-
//
|
|
523
|
-
//
|
|
533
|
+
// TANPA output — user melihat kursor mati. Bar loading transient TTY-only
|
|
534
|
+
// selama setup, dibersihkan sebelum TUI agar tak ada jejak.
|
|
535
|
+
// Bar berjalan di atas createCliSession — termasuk saat wizard setup pertama
|
|
536
|
+
// (picker gateway + prompt API key) memegang terminal. Lewat paintWrite,
|
|
537
|
+
// lukisannya otomatis BERHENTI selama layar interaktif aktif
|
|
524
538
|
// (statusline.beginInteractiveScreen di openAltScreen): dulu tulis mentah
|
|
525
539
|
// `\r\x1b[2K` menghapus baris prompt wizard, sehingga user baru hanya melihat
|
|
526
540
|
// "Menyiapkan sesi…" tanpa cara menyelesaikan setup (laporan: minicode dari
|
|
527
541
|
// home selalu macet).
|
|
528
|
-
|
|
542
|
+
let setupBar: LoadingBar | null = null
|
|
543
|
+
const setupBarPhases: Record<string, { pct: number; label: MsgKey }> = {
|
|
544
|
+
"provider-layer": { pct: 55, label: "loading.provider" },
|
|
545
|
+
"rag-layer": { pct: 75, label: "loading.rag" },
|
|
546
|
+
"tool-layer": { pct: 90, label: "loading.session" },
|
|
547
|
+
"kernel-session": { pct: 98, label: "loading.session" },
|
|
548
|
+
}
|
|
549
|
+
if (enterRepl) {
|
|
550
|
+
setupBar = createLoadingBar(t("loading.session"), { delayMs: 120 })
|
|
551
|
+
}
|
|
529
552
|
// finally: createCliSession yang melempar (provider/MCP gagal) tak boleh
|
|
530
|
-
// membocorkan
|
|
553
|
+
// membocorkan painter — tanpa ini bar menulis ke stderr selamanya dan
|
|
531
554
|
// proses tak pernah exit (terlihat hang).
|
|
532
555
|
let ctx: Awaited<ReturnType<typeof createCliSession>>
|
|
533
556
|
try {
|
|
@@ -565,6 +588,11 @@ try {
|
|
|
565
588
|
timeoutMs,
|
|
566
589
|
rateLimiter,
|
|
567
590
|
sandboxNotice: requestedSandbox ? sandbox.notice : undefined,
|
|
591
|
+
onPhase: (name) => {
|
|
592
|
+
if (!enterRepl) return
|
|
593
|
+
const phase = setupBarPhases[name]
|
|
594
|
+
if (phase !== undefined) setupBar?.update(t(phase.label), phase.pct)
|
|
595
|
+
},
|
|
568
596
|
})
|
|
569
597
|
} catch (e) {
|
|
570
598
|
// Tanpa provider = setup gagal sebelum sesi ada. Pesan + exit(1) sama
|
|
@@ -586,12 +614,23 @@ try {
|
|
|
586
614
|
}
|
|
587
615
|
throw e
|
|
588
616
|
} finally {
|
|
589
|
-
|
|
617
|
+
setupBar?.stop()
|
|
590
618
|
}
|
|
591
619
|
|
|
592
620
|
if (enterRepl) {
|
|
593
621
|
// Satu-satunya tampilan interaktif = TUI fullscreen (REPL linier dihapus).
|
|
594
622
|
// One-shot/exec tak tersentuh (cabang else di bawah).
|
|
623
|
+
if (setupBar) {
|
|
624
|
+
setupBar.update(t("loading.finalize"), 100)
|
|
625
|
+
// Beri jeda satu frame agar cap 100% benar-benar terlihat sebelum baris
|
|
626
|
+
// dibersihkan; tanpa ini update+stop di tick yang sama membuat bar tak
|
|
627
|
+
// pernah tampak mencapai 100%. Dilewati pada non-TTY/motion-reduced.
|
|
628
|
+
if (process.stderr.isTTY && !motionReduced()) {
|
|
629
|
+
await new Promise((r) => setTimeout(r, 80))
|
|
630
|
+
}
|
|
631
|
+
setupBar.stop()
|
|
632
|
+
setupBar = null
|
|
633
|
+
}
|
|
595
634
|
const { runTui } = await import("./tui.ts")
|
|
596
635
|
const replStart = Date.now()
|
|
597
636
|
try {
|
|
@@ -711,7 +750,7 @@ if (enterRepl) {
|
|
|
711
750
|
})
|
|
712
751
|
} catch (e) {
|
|
713
752
|
// Error provider biasanya sudah dirender ramah oleh event handler
|
|
714
|
-
// (takePendingError) — cetak sekali saja, jangan dua blok
|
|
753
|
+
// (takePendingError) — cetak sekali saja, jangan dua blok error.
|
|
715
754
|
const shown = ctx.uiState.takePendingError()
|
|
716
755
|
process.stderr.write(`\n${c.red(glyphs.cross)} ${shown ?? formatError(e)}\n`)
|
|
717
756
|
// 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,
|