minicode-ai 0.20.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/cli/auto-update.ts +24 -15
- package/cli/index.ts +57 -18
- package/cli/setup.ts +64 -34
- package/cli/tui.ts +22 -2
- package/docs/TERMINAL_CONTRACT.md +20 -4
- package/docs/UI_RENDER_PIPELINE.md +6 -3
- package/docs/architecture.md +1 -1
- package/docs/contributing.md +2 -2
- package/docs/environment.md +1 -0
- package/package.json +1 -1
- package/src/policy/update-check.ts +6 -4
- package/src/ui/assistant/simple.ts +14 -0
- package/src/ui/i18n/en.ts +20 -0
- package/src/ui/i18n/id.ts +20 -0
- package/src/ui/render/activity-group.ts +53 -0
- package/src/ui/render/activity-panel.ts +91 -0
- package/src/ui/render/cells.ts +33 -6
- package/src/ui/render/diff.ts +7 -0
- package/src/ui/render/markdown.ts +6 -1
- package/src/ui/render/session-summary.ts +7 -2
- package/src/ui/render/theme.ts +8 -0
- package/src/ui/runtime/loading-bar.ts +125 -0
- package/src/ui/session-state.ts +22 -0
- package/src/ui/tui/transcript.ts +162 -20
|
@@ -82,7 +82,10 @@ Tahap H — primitif render `src/ui/render/`: `sanitize.ts` (hanya SGR lolos),
|
|
|
82
82
|
per baris → aman resize), `theme.ts` (getter warna/glyph, jangan di-`const`),
|
|
83
83
|
`errors.ts` (pesan actionable + redact), `collapse.ts` (buffer `/expand`
|
|
84
84
|
200KB/entry, 500KB total), `markdown-table.ts`/`table-grid.ts` (pipe-table
|
|
85
|
-
model), `diff.ts`/`table.ts`/`money.ts`/`format.ts
|
|
85
|
+
model), `diff.ts`/`table.ts`/`money.ts`/`format.ts`,
|
|
86
|
+
`activity-group.ts`/`activity-panel.ts` (panel aktivitas: klasifikasi tool →
|
|
87
|
+
keluarga `explore|edit|execute|feed|other` + satu baris ringkas per keluarga,
|
|
88
|
+
maks 10 baris; murni, dipakai TUI + linear).
|
|
86
89
|
|
|
87
90
|
Tahap H2 — tabel Markdown model: `src/ui/render/markdown-table.ts` memvalidasi
|
|
88
91
|
header/delimiter, escaped pipe, code span, alignment, dan fence; stream block
|
|
@@ -104,8 +107,8 @@ I = bisa diinterupsi, L = bisa tiba setelah completion.
|
|
|
104
107
|
|---|---|---|---|---|---|---|---|
|
|
105
108
|
| assistant text | provider stream | stdout wrap + fence 2-spasi; pipe-table-aligned di TTY, source sanitized di non-TTY | ya | tidak (E1) | tidak | ya (abort) | tidak (detach flush 1x, E6) |
|
|
106
109
|
| tool call | model → kernel | `› nama target` muted (compact: diam) | tidak | tidak | tidak | ya | tidak |
|
|
107
|
-
| tool result | tool → executor | ledger hijau/merah; minimize → `+ label` + buffer | tidak | tidak | tidak | ya | tidak |
|
|
108
|
-
| reasoning | provider extension | TUI composer: dots clock
|
|
110
|
+
| tool result | tool → executor | ledger hijau/merah; minimize → `+ label` + buffer; panel aktivitas ON → baris grup per keluarga tool (`+ explore · N tools · N ok`) | tidak | tidak | tidak | ya | tidak |
|
|
111
|
+
| reasoning | provider extension | TUI composer: dots clock; panel aktivitas ON → AREA thinking live maks 10 baris (`+ thinking`, ringkas 1 baris saat turn selesai, detail di `/expand`); panel OFF → alir per baris; minimized → buffer `/expand` | ya | tidak | tidak | ya | tidak |
|
|
109
112
|
| thinking effort | picker `/model` | badge + level per model | tidak | tidak | tidak | tidak | tidak |
|
|
110
113
|
| usage | provider extension | verbose saja; masuk budget watcher | ya | tidak | ya (tail pasca-finish) | ya | ya (diabaikan aman) |
|
|
111
114
|
| compaction | kernel loop | `── compacted: <reason>` kuning, reason verbatim | tidak | tidak | tidak | tidak | tidak |
|
package/docs/architecture.md
CHANGED
|
@@ -120,7 +120,7 @@ Sesi interaktif (`minicode` di TTY mampu) SELALU membuka TUI **fullscreen altern
|
|
|
120
120
|
| stderr | Progress/diagnostik: ledger tool (`› …` hijau/merah), reasoning (verbose), warning, error. Boleh transient bila TTY |
|
|
121
121
|
| Keduanya | Warna hanya bila TTY (`stdout.isTTY`); `NO_COLOR` menang; `TERM`/`COLORTERM` tidak menyalakan warna di pipe |
|
|
122
122
|
|
|
123
|
-
Satu-satunya arbitrator transient: `src/ui/runtime/statusline.ts` (`acquireTransientPaint` + `paintWrite`). Painter aktif (garis status turn vs spinner wizard) mutually exclusive; overlap = signal `[transient-paint]`, bukan crash. Foreign stderr writer (non-UI) boleh mentah — arbitrator mengkomitnya sebagai baris permanen bersih. `beginInteractiveScreen` menahan semua painter itu selama layar interaktif memegang terminal; tulis asing saat alt-screen hidup juga menandai terminal "kotor" (`consumeScreenDrift`) agar layar memaksa repaint penuh pada paint berikutnya. 35 invariant (I1–I35) + peta test (`tui-app`, `screen-buffer`, `tui-popup`, `transient-arbitration`, `input-resize`, `exit-codes`, `acp`, `ui-boundary`) ada di `TERMINAL_CONTRACT.md`. Kontrak itu juga memuat **peta gap proteksi** — klaim yang implementasinya benar tetapi belum punya assertion penjaga; itu daftar pekerjaan, bukan daftargreens.
|
|
123
|
+
Satu-satunya arbitrator transient: `src/ui/runtime/statusline.ts` (`acquireTransientPaint` + `paintWrite`). Painter aktif (garis status turn vs spinner wizard vs bar loading) mutually exclusive; overlap = signal `[transient-paint]`, bukan crash. Foreign stderr writer (non-UI) boleh mentah — arbitrator mengkomitnya sebagai baris permanen bersih. `beginInteractiveScreen` menahan semua painter itu selama layar interaktif memegang terminal; tulis asing saat alt-screen hidup juga menandai terminal "kotor" (`consumeScreenDrift`) agar layar memaksa repaint penuh pada paint berikutnya. Bar loading startup (`src/ui/runtime/loading-bar.ts`) adalah painter transient jenis kedua: single-line blok `▓░` + persen + label, digambar ulang hanya saat `update(label, percent)` dipanggil, TTY-only (non-TTY = no-op nol byte), label disanitasi. Diagnostik fase startup (identity/writer/resume/recovery/context) didefer saat REPL ke `ctx.startupNotices` dan di-flush ke transcript TUI; non-interaktif tetap mencetak langsung. 35 invariant (I1–I35) + peta test (`tui-app`, `screen-buffer`, `tui-popup`, `transient-arbitration`, `loading-bar`, `input-resize`, `exit-codes`, `acp`, `ui-boundary`) ada di `TERMINAL_CONTRACT.md`. Kontrak itu juga memuat **peta gap proteksi** — klaim yang implementasinya benar tetapi belum punya assertion penjaga; itu daftar pekerjaan, bukan daftargreens.
|
|
124
124
|
|
|
125
125
|
Enam primitif tampilan (semuanya di dalam TUI fullscreen saat interaktif): transkrip `minicode ›` tampil saat boot/idle dan kembali otomatis setelah turn selesai + jawaban model + ledger ` › name target` hijau / ` › name: …` merah; status bar satu baris (`✦ 00.00.00 Work Mode: Discuss model cwd … context Permission Mode: Auto`) dengan sesi baru `DISCUSS`+`AUTO`, pilihan Work Mode hanya Discuss/Plan/Build dan Permission Mode hanya Auto/Ask; Work Mode di kiri dan Permission Mode cyan rata kanan dekat konteks (label dipadatkan pada terminal sempit; timer redup idle, saat aktif hanya detik putih, menit ikut terang setelah 60 dtk, jam setelah 1 jam; sparkle proses; tanpa bullet separator; `src/ui/tui/app.ts` merender composer dots dan satu spacer di atas footer per frame); popup komposit satu kotak (`/model`, `/provider`, `/sessions`, form, approval) via `openAltScreen`/`paintRegion`; thinking redup tanpa marker transcript (composer dots; isi via `/expand`); error `pesan actionable` berwarna merah sekali per kegagalan (`takePendingError`). Status/konfirmasi perintah (sync, auth, config, spinner) memakai warna saja tanpa icon.
|
|
126
126
|
|
package/docs/contributing.md
CHANGED
|
@@ -45,9 +45,9 @@ Gerbang lambat/stokastik (docker sandbox) tinggal di `slow.yml` — kegagalannya
|
|
|
45
45
|
|
|
46
46
|
### Budget ukuran paket (3.968 KiB)
|
|
47
47
|
|
|
48
|
-
`bun run gate:pack` mengukur ukuran tarball (`npm pack --dry-run`, KiB) dan menolak bila **melebihi
|
|
48
|
+
`bun run gate:pack` mengukur ukuran tarball (`npm pack --dry-run`, KiB) dan menolak bila **melebihi 4.096 KiB (4,0 MiB)**. Angka tunggalnya ada di `scripts/pack-budget.ts` — satu sumber untuk gate dan tes, jadi keduanya tak bisa menyimpang. Batas ini **alarm regresi** (menangkap `node_modules`/`test` ikut terbawa), bukan target ukuran yang perlu dikejar.
|
|
49
49
|
|
|
50
|
-
Batas
|
|
50
|
+
Batas 4.096 KiB disetujui pemilik pada 2026-11-11 untuk rilis v0.21.0. Jangan menaikkan anggaran tanpa bukti baru dan persetujuan pemilik; ukur dulu runtime serta berkas non-runtime yang dapat dipangkas.
|
|
51
51
|
|
|
52
52
|
Gerbang lain:
|
|
53
53
|
|
package/docs/environment.md
CHANGED
|
@@ -86,6 +86,7 @@ Variabel yang paling menentukan perilaku (sisanya referensi di bawah):
|
|
|
86
86
|
| `MINICODE_A11Y` | `1` → live-region approval untuk screen reader (baris polos tanpa ANSI) |
|
|
87
87
|
| `MINICODE_SHOW_THINKING` | reasoning model terlihat SECARA DEFAULT; `0` → minimized (hanya penanda), `1` → paksa terlihat |
|
|
88
88
|
| `MINICODE_MINIMIZE_ACTIVITY` | ON secara default di TUI; `0` → transparan (baris per-tool). Lipat aktivitas tool per turn jadi satu ringkasan (detail via `/expand`) |
|
|
89
|
+
| `MINICODE_ACTIVITY_PANEL` | `0` → matikan panel aktivitas (default AKTIF di TUI; `/fold` toggle); `1` → paksa aktif juga di jalur linear/one-shot |
|
|
89
90
|
| `MINICORE_THINKING` | `off` → kirim `enable_thinking:false` ke OpenAI-compat (DeepSeek). Alias lama `MINICODE_THINKING` masih dihormati |
|
|
90
91
|
| `NO_COLOR` | Set apa pun selain `0` → matikan seluruh warna |
|
|
91
92
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minicode-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Open-source terminal coding agent on a frozen zero-dependency MiniCore kernel — layered permissions, path jail, sandboxing, MCP/LSP, and durable shadow-git checkpoints",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -208,14 +208,16 @@ export function installUpdate(version: string, runner?: InstallRunner): boolean
|
|
|
208
208
|
const run: InstallRunner =
|
|
209
209
|
runner ??
|
|
210
210
|
((cmd, args, opts) => {
|
|
211
|
-
// Windows: npm adalah .cmd → butuh shell
|
|
212
|
-
//
|
|
211
|
+
// Windows: npm adalah .cmd → butuh shell. Output npm dipipe dan
|
|
212
|
+
// dibuang — auto-update kini berjalan di belakang bar loading, jadi
|
|
213
|
+
// progres raw npm malah mengotori baris bar (sebelumnya stdio
|
|
214
|
+
// inherit menimpa spinner).
|
|
213
215
|
// Timeout 120 dtk: tanpa ini spawnSync memblokir event-loop selamanya
|
|
214
216
|
// saat npm lambat (AV/UAC di Windows 15–60 dtk) — timer abort 1.8 dtk
|
|
215
|
-
// dan
|
|
217
|
+
// dan bar ikut beku sehingga terlihat hang. Timeout = gagal jujur
|
|
216
218
|
// lalu lanjut versi lama, bukan gantung.
|
|
217
219
|
const r = spawnSync(cmd, args, {
|
|
218
|
-
stdio: "
|
|
220
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
219
221
|
shell: process.platform === "win32",
|
|
220
222
|
...(opts?.cwd ? { cwd: opts.cwd } : {}),
|
|
221
223
|
timeout: 120_000,
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
UiStep,
|
|
13
13
|
} from "../contract.ts"
|
|
14
14
|
import { t } from "../i18n/locale.ts"
|
|
15
|
+
import { renderActivityPanel } from "../render/activity-panel.ts"
|
|
15
16
|
import { renderDiffCard } from "../render/diff.ts"
|
|
16
17
|
import { formatArgsPreview, formatProviderError, formatUsage } from "../render/format.ts"
|
|
17
18
|
import { highlightCode } from "../render/highlight.ts"
|
|
@@ -605,6 +606,19 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
605
606
|
bashSan.flush()
|
|
606
607
|
flushThinking()
|
|
607
608
|
finalizeAnswer()
|
|
609
|
+
// [Fase 2] Panel aktivitas di jalur linear: satu blok ringkas per
|
|
610
|
+
// keluarga tool saat turn selesai (append-only — detail per-tool tetap
|
|
611
|
+
// lewat /expand). Opt-in via MINICODE_ACTIVITY_PANEL=1 / ui.activityPanel.
|
|
612
|
+
if (ui.activityPanel && opts.getSnapshot) {
|
|
613
|
+
const snap = presentationSnapshot()
|
|
614
|
+
if (snap) {
|
|
615
|
+
const lines = renderActivityPanel(snap.activities, { maxRows: 10 })
|
|
616
|
+
if (lines.length > 0) {
|
|
617
|
+
wErr(c.muted(`${t("panel.header")}\n`))
|
|
618
|
+
for (const line of lines) wErr(c.muted(`${line}\n`))
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
608
622
|
if (opts.verbose) wErr(c.muted(t("one.done")))
|
|
609
623
|
}),
|
|
610
624
|
)
|
package/src/ui/i18n/en.ts
CHANGED
|
@@ -319,4 +319,24 @@ export const en = {
|
|
|
319
319
|
"err.busyFix": "Wait for the current run to finish.",
|
|
320
320
|
"err.aborted": "Run was aborted",
|
|
321
321
|
"common.active": "active",
|
|
322
|
+
"panel.group.explore": "explore",
|
|
323
|
+
"panel.group.edit": "edit",
|
|
324
|
+
"panel.group.execute": "execute",
|
|
325
|
+
"panel.group.feed": "feed",
|
|
326
|
+
"panel.group.other": "other",
|
|
327
|
+
"panel.tools": "{n} tools",
|
|
328
|
+
"panel.ok": "{n} ok",
|
|
329
|
+
"panel.failed": "{n} failed",
|
|
330
|
+
"panel.running": "{n} running",
|
|
331
|
+
"panel.thinking": "thinking",
|
|
332
|
+
"panel.lines": "{n} lines",
|
|
333
|
+
"panel.moreLines": "… {n} more lines",
|
|
334
|
+
"panel.header": "activity",
|
|
335
|
+
"loading.checking": "checking for updates",
|
|
336
|
+
"loading.installing": "installing update",
|
|
337
|
+
"loading.restarting": "restarting",
|
|
338
|
+
"loading.provider": "configuring provider",
|
|
339
|
+
"loading.rag": "loading context",
|
|
340
|
+
"loading.session": "preparing session",
|
|
341
|
+
"loading.finalize": "finalizing",
|
|
322
342
|
} as const
|
package/src/ui/i18n/id.ts
CHANGED
|
@@ -321,4 +321,24 @@ export const id: Record<MsgKey, string> = {
|
|
|
321
321
|
"err.busyFix": "Tunggu run berjalan selesai.",
|
|
322
322
|
"err.aborted": "Run dibatalkan",
|
|
323
323
|
"common.active": "aktif",
|
|
324
|
+
"panel.group.explore": "jelajah",
|
|
325
|
+
"panel.group.edit": "ubah",
|
|
326
|
+
"panel.group.execute": "jalankan",
|
|
327
|
+
"panel.group.feed": "sumber",
|
|
328
|
+
"panel.group.other": "lainnya",
|
|
329
|
+
"panel.tools": "{n} tool",
|
|
330
|
+
"panel.ok": "{n} sukses",
|
|
331
|
+
"panel.failed": "{n} gagal",
|
|
332
|
+
"panel.running": "{n} berjalan",
|
|
333
|
+
"panel.thinking": "berpikir",
|
|
334
|
+
"panel.lines": "{n} baris",
|
|
335
|
+
"panel.moreLines": "… {n} baris lagi",
|
|
336
|
+
"panel.header": "aktivitas",
|
|
337
|
+
"loading.checking": "memeriksa pembaruan",
|
|
338
|
+
"loading.installing": "memasang pembaruan",
|
|
339
|
+
"loading.restarting": "memulai ulang",
|
|
340
|
+
"loading.provider": "menyiapkan provider",
|
|
341
|
+
"loading.rag": "memuat konteks",
|
|
342
|
+
"loading.session": "menyiapkan sesi",
|
|
343
|
+
"loading.finalize": "menyelesaikan",
|
|
324
344
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Klasifikasi tool → keluarga panel aktivitas (Fase 2). Murni & tanpa IO:
|
|
2
|
+
// hanya memetakan nama tool ke label keluarga (group) yang dipakai panel
|
|
3
|
+
// TUI (transcript.ts) dan blok ringkas linear (simple.ts). Satu sumber
|
|
4
|
+
// kebenaran supaya kedua renderer tidak divergen.
|
|
5
|
+
//
|
|
6
|
+
// Keluarga disandikan sebagai kunci i18n (`panel.group.*`) — modul ini tidak
|
|
7
|
+
// menyentuh teks render, hanya kunci. Fallback: tool yang tak dikenal tetap
|
|
8
|
+
// tampil dengan nama aslinya (tanpa dikelompokkan).
|
|
9
|
+
|
|
10
|
+
export type ActivityGroupKind = "explore" | "edit" | "execute" | "feed" | "other"
|
|
11
|
+
|
|
12
|
+
/** Peta nama tool → keluarga. Kunci nama tool (input tak-terpercaya) — renderer
|
|
13
|
+
* tetap wajib sanitasi sebelum tampil (aturan repo). */
|
|
14
|
+
const GROUP_BY_TOOL: Readonly<Record<string, ActivityGroupKind>> = {
|
|
15
|
+
// ── explore: membaca workspace / mencari informasi ──
|
|
16
|
+
read_file: "explore",
|
|
17
|
+
read_image: "explore",
|
|
18
|
+
glob: "explore",
|
|
19
|
+
grep: "explore",
|
|
20
|
+
lsp_diagnostics: "explore",
|
|
21
|
+
lsp_symbols: "explore",
|
|
22
|
+
lsp_workspace_symbols: "explore",
|
|
23
|
+
// ── edit: mengubah file / working tree ──
|
|
24
|
+
edit: "edit",
|
|
25
|
+
apply_patch: "edit",
|
|
26
|
+
write_file: "edit",
|
|
27
|
+
delete_file: "edit",
|
|
28
|
+
move_file: "edit",
|
|
29
|
+
// ── execute: menjalankan proses / perintah ──
|
|
30
|
+
bash: "execute",
|
|
31
|
+
code_run: "execute",
|
|
32
|
+
git_status: "execute",
|
|
33
|
+
git_diff: "execute",
|
|
34
|
+
git_log: "execute",
|
|
35
|
+
git_commit: "execute",
|
|
36
|
+
mcp_list: "execute",
|
|
37
|
+
mcp_call: "execute",
|
|
38
|
+
mcp_read: "execute",
|
|
39
|
+
mcp_prompt: "execute",
|
|
40
|
+
ask_user: "execute",
|
|
41
|
+
// ── feed: sumber informasi eksternal / memori ──
|
|
42
|
+
web_search: "feed",
|
|
43
|
+
web_fetch: "feed",
|
|
44
|
+
read_memory: "feed",
|
|
45
|
+
write_memory: "feed",
|
|
46
|
+
forget_memory: "feed",
|
|
47
|
+
delegate_task: "feed",
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Keluarga tool (kunci i18n). Kunci `other` untuk yang tak dikenal. */
|
|
51
|
+
export function activityGroup(name: string): ActivityGroupKind {
|
|
52
|
+
return GROUP_BY_TOOL[name] ?? "other"
|
|
53
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Render panel aktivitas (Fase 2): satu baris per KELUARGA tool + state
|
|
2
|
+
// thinking. Murni (input → string[]), tanpa IO — pemanggil (transcript TUI /
|
|
3
|
+
// simple linear) yang memutuskan kapan & di mana mencetaknya.
|
|
4
|
+
//
|
|
5
|
+
// Semua teks yang datang dari model/tool (nama tool, target) adalah input
|
|
6
|
+
// tak-terpercaya: wajib sanitasi di sini sebelum dirender. Label keluarga
|
|
7
|
+
// berasal dari i18n (terpercaya).
|
|
8
|
+
|
|
9
|
+
import type { UiPresentationActivity } from "../contract.ts"
|
|
10
|
+
import { t } from "../i18n/locale.ts"
|
|
11
|
+
import { activityGroup } from "./activity-group.ts"
|
|
12
|
+
import { sanitizeAnsiLine, stripSgr } from "./sanitize.ts"
|
|
13
|
+
import { truncateToWidth } from "./width.ts"
|
|
14
|
+
/** Satu grup teragregasi (dipakai renderer + /expand buffer). */
|
|
15
|
+
export interface ActivityGroupView {
|
|
16
|
+
kind: string
|
|
17
|
+
/** Jumlah tool dalam grup. */
|
|
18
|
+
count: number
|
|
19
|
+
ok: number
|
|
20
|
+
failed: number
|
|
21
|
+
running: number
|
|
22
|
+
denied: number
|
|
23
|
+
/** Nama tool pertama (indikator; sudah tersanitasi & terpotong). */
|
|
24
|
+
names: string[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const MAX_PANEL_LABEL = 40
|
|
28
|
+
|
|
29
|
+
/** Agregasi activity → grup. Hanya activity yang statusnya terminal/running
|
|
30
|
+
* masuk; child (parentToolCallId) dihitung ke grup orang tuanya. */
|
|
31
|
+
export function groupActivities(
|
|
32
|
+
activities: readonly UiPresentationActivity[],
|
|
33
|
+
): Map<string, ActivityGroupView> {
|
|
34
|
+
const groups = new Map<string, ActivityGroupView>()
|
|
35
|
+
for (const a of activities) {
|
|
36
|
+
const kind = activityGroup(a.name)
|
|
37
|
+
let g = groups.get(kind)
|
|
38
|
+
if (!g) {
|
|
39
|
+
g = { kind, count: 0, ok: 0, failed: 0, running: 0, denied: 0, names: [] }
|
|
40
|
+
groups.set(kind, g)
|
|
41
|
+
}
|
|
42
|
+
g.count++
|
|
43
|
+
const status = a.status
|
|
44
|
+
if (status === "completed") g.ok++
|
|
45
|
+
else if (status === "failed") g.failed++
|
|
46
|
+
else if (status === "running") g.running++
|
|
47
|
+
else if (status === "denied") g.denied++
|
|
48
|
+
// Nama tool dari model/provider = input tak-terpercaya: buang SEMUA ANSI
|
|
49
|
+
// (termasuk SGR) saat masuk — styling ditambahkan renderer sendiri.
|
|
50
|
+
const cleanName = stripSgr(sanitizeAnsiLine(a.name))
|
|
51
|
+
if (g.names.length < 3 && !g.names.includes(cleanName)) g.names.push(cleanName)
|
|
52
|
+
}
|
|
53
|
+
return groups
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Satu baris grup (`+ explore · 3 tools · 2 ok · 1 failed`). */
|
|
57
|
+
export function groupLine(g: ActivityGroupView): string {
|
|
58
|
+
// Kunci i18n literal (bukan template) — MsgKey adalah union, bukan string.
|
|
59
|
+
const key:
|
|
60
|
+
| "panel.group.explore"
|
|
61
|
+
| "panel.group.edit"
|
|
62
|
+
| "panel.group.execute"
|
|
63
|
+
| "panel.group.feed"
|
|
64
|
+
| "panel.group.other" = `panel.group.${g.kind}` as never
|
|
65
|
+
const label = sanitizeAnsiLine(t(key))
|
|
66
|
+
const parts: string[] = [`+ ${truncateToWidth(label, MAX_PANEL_LABEL, "")}`]
|
|
67
|
+
parts.push(t("panel.tools", { n: g.count }))
|
|
68
|
+
if (g.ok > 0) parts.push(t("panel.ok", { n: g.ok }))
|
|
69
|
+
if (g.failed > 0) parts.push(t("panel.failed", { n: g.failed }))
|
|
70
|
+
if (g.running > 0) parts.push(t("panel.running", { n: g.running }))
|
|
71
|
+
const names = g.names.map((n) => sanitizeAnsiLine(n)).join(", ")
|
|
72
|
+
if (names) parts.push(`· ${truncateToWidth(names, MAX_PANEL_LABEL, "…")}`)
|
|
73
|
+
return parts.join(" ")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Baris panel lengkap (header + satu baris per grup). Kosong bila tak ada
|
|
77
|
+
* activity — pemanggil boleh tak menampilkan apa pun. */
|
|
78
|
+
export function renderActivityPanel(
|
|
79
|
+
activities: readonly UiPresentationActivity[],
|
|
80
|
+
opts: { maxRows?: number } = {},
|
|
81
|
+
): string[] {
|
|
82
|
+
const max = Math.max(1, opts.maxRows ?? 10)
|
|
83
|
+
const groups = groupActivities(activities)
|
|
84
|
+
const out: string[] = []
|
|
85
|
+
if (groups.size === 0) return out
|
|
86
|
+
for (const g of groups.values()) {
|
|
87
|
+
if (out.length >= max) break
|
|
88
|
+
out.push(groupLine(g))
|
|
89
|
+
}
|
|
90
|
+
return out
|
|
91
|
+
}
|
package/src/ui/render/cells.ts
CHANGED
|
@@ -40,19 +40,25 @@ function isSgr(seq: string): boolean {
|
|
|
40
40
|
return true
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/** Urutan serialisasi kanonik — hasil sama apa pun urutan SGR masukannya.
|
|
44
|
-
|
|
43
|
+
/** Urutan serialisasi kanonik — hasil sama apa pun urutan SGR masukannya.
|
|
44
|
+
* Termasuk atribut yang jarang dipakai: 21 double-underline (u2), 53
|
|
45
|
+
* overline (ov), 58 underline-color (uc) — sebelumnya jatuh ke `raw:*` dan
|
|
46
|
+
* hilang saat serialisasi (audit render #1). */
|
|
47
|
+
const SGR_ORDER: readonly string[] = [
|
|
45
48
|
"bold",
|
|
46
49
|
"dim",
|
|
47
50
|
"italic",
|
|
48
51
|
"underline",
|
|
52
|
+
"u2",
|
|
53
|
+
"ov",
|
|
49
54
|
"blink",
|
|
50
55
|
"inverse",
|
|
51
56
|
"conceal",
|
|
52
57
|
"strike",
|
|
53
58
|
"fg",
|
|
54
59
|
"bg",
|
|
55
|
-
|
|
60
|
+
"uc",
|
|
61
|
+
]
|
|
56
62
|
|
|
57
63
|
interface SgrState {
|
|
58
64
|
values: Map<string, string>
|
|
@@ -70,6 +76,12 @@ function serializeSgr(state: SgrState): string {
|
|
|
70
76
|
const value = state.values.get(group)
|
|
71
77
|
if (value !== undefined) parts.push(value)
|
|
72
78
|
}
|
|
79
|
+
// Parameter tak dikenal (`raw:<token>`: 21, 53, 58, dst.) ikut
|
|
80
|
+
// diserialisasi — jangan dibuang (audit render #1). Urutan stabil
|
|
81
|
+
// (insertion order Map) supaya serialize idempoten.
|
|
82
|
+
for (const [group, value] of state.values) {
|
|
83
|
+
if (!SGR_ORDER.includes(group)) parts.push(value)
|
|
84
|
+
}
|
|
73
85
|
return `\x1b[${parts.join(";")}m`
|
|
74
86
|
}
|
|
75
87
|
|
|
@@ -109,8 +121,9 @@ function applySgrTo(state: SgrState, seq: string): void {
|
|
|
109
121
|
const colon = token.indexOf(":")
|
|
110
122
|
if (colon >= 0) {
|
|
111
123
|
const head = token.slice(0, colon)
|
|
112
|
-
if (head === "38"
|
|
124
|
+
if (head === "38") setGroup(state, "fg", token)
|
|
113
125
|
else if (head === "48") setGroup(state, "bg", token)
|
|
126
|
+
else if (head === "58") setGroup(state, "uc", token)
|
|
114
127
|
else setGroup(state, `raw:${head}`, token)
|
|
115
128
|
continue
|
|
116
129
|
}
|
|
@@ -123,13 +136,14 @@ function applySgrTo(state: SgrState, seq: string): void {
|
|
|
123
136
|
state.values.clear()
|
|
124
137
|
continue
|
|
125
138
|
}
|
|
126
|
-
if (n === 38 || n === 48) {
|
|
139
|
+
if (n === 38 || n === 48 || n === 58) {
|
|
127
140
|
const extended = readExtended(tokens, i, n)
|
|
128
141
|
if (!extended) {
|
|
129
142
|
setGroup(state, `raw:${n}`, token)
|
|
130
143
|
continue
|
|
131
144
|
}
|
|
132
|
-
|
|
145
|
+
if (n === 58) setGroup(state, "uc", extended.value)
|
|
146
|
+
else setGroup(state, n === 38 ? "fg" : "bg", extended.value)
|
|
133
147
|
i = extended.next
|
|
134
148
|
continue
|
|
135
149
|
}
|
|
@@ -153,8 +167,21 @@ function applySgrTo(state: SgrState, seq: string): void {
|
|
|
153
167
|
case 4:
|
|
154
168
|
setGroup(state, "underline", "4")
|
|
155
169
|
break
|
|
170
|
+
case 21:
|
|
171
|
+
setGroup(state, "u2", "21")
|
|
172
|
+
break
|
|
156
173
|
case 24:
|
|
157
174
|
setGroup(state, "underline", null)
|
|
175
|
+
setGroup(state, "u2", null)
|
|
176
|
+
break
|
|
177
|
+
case 53:
|
|
178
|
+
setGroup(state, "ov", "53")
|
|
179
|
+
break
|
|
180
|
+
case 54:
|
|
181
|
+
setGroup(state, "ov", null)
|
|
182
|
+
break
|
|
183
|
+
case 59:
|
|
184
|
+
setGroup(state, "uc", null)
|
|
158
185
|
break
|
|
159
186
|
case 5:
|
|
160
187
|
case 6:
|
package/src/ui/render/diff.ts
CHANGED
|
@@ -24,6 +24,13 @@ export interface DiffLine {
|
|
|
24
24
|
export function computeLineDiff(oldText: string, newText: string): DiffLine[] {
|
|
25
25
|
const oldLines = oldText.split("\n")
|
|
26
26
|
const newLines = newText.split("\n")
|
|
27
|
+
// Pop SATU elemen kosong di ekor tiap sisi. Elemen itu artefak newline
|
|
28
|
+
// penutup (`"a\n".split("\n")` → `["a",""]`), bukan baris nyata — tanpa
|
|
29
|
+
// ini `computeLineDiff("", "baru")` dan `"a\n"` vs `"a"` memancarkan
|
|
30
|
+
// delete/context baris kosong spurious. Baris kosong nyata di tengah tetap
|
|
31
|
+
// dipertahankan; hanya ekor artifisial yang dibuang.
|
|
32
|
+
if (oldLines[oldLines.length - 1] === "") oldLines.pop()
|
|
33
|
+
if (newLines[newLines.length - 1] === "") newLines.pop()
|
|
27
34
|
const result: DiffLine[] = []
|
|
28
35
|
let i = 0,
|
|
29
36
|
j = 0,
|
|
@@ -25,7 +25,12 @@ export interface FenceMatch {
|
|
|
25
25
|
* sehingga fence berbahasa kehilangan highlight dan state desync.
|
|
26
26
|
*/
|
|
27
27
|
export function parseFence(line: string): FenceMatch | null {
|
|
28
|
-
|
|
28
|
+
// Info-string setelah bahasa diperbolehkan (````ts title="demo"` atau
|
|
29
|
+
// ` ```js #tag `). Hanya token pertama (non-spasi) yang dibaca sebagai
|
|
30
|
+
// bahasa — sisanya adalah metadata yang tak memengaruhi highlight. Regex
|
|
31
|
+
// lama menolak seluruh baris ber-info-string sehingga kode jatuh ke dekorasi
|
|
32
|
+
// inline (`const x = *a*` jadi `const x = a`).
|
|
33
|
+
const m = /^\s*(```+|~~~+)([A-Za-z0-9_+.-]*)(?:\s+[^\r\n]*)?\s*$/.exec(line)
|
|
29
34
|
if (!m) return null
|
|
30
35
|
return { char: m[1]![0]!, len: m[1]!.length, lang: m[2] ?? "" }
|
|
31
36
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// via `c` menjamin selalu terlihat + hormati NO_COLOR.
|
|
10
10
|
|
|
11
11
|
import { formatUsd } from "./money.ts"
|
|
12
|
+
import { sanitizeAnsiLine, stripSgr } from "./sanitize.ts"
|
|
12
13
|
import { c } from "./theme.ts"
|
|
13
14
|
|
|
14
15
|
const WORDMARK = "minicode"
|
|
@@ -37,10 +38,14 @@ export function formatDuration(ms: number): string {
|
|
|
37
38
|
export function renderSessionSummary(s: SessionSummary): string {
|
|
38
39
|
const label = (t: string): string => c.muted(t.padEnd(7))
|
|
39
40
|
const cost = s.cost != null ? formatUsd(s.cost) : null
|
|
41
|
+
// sessionId/model = input tak-terpercaya (config/network): buang SEMUA ANSI
|
|
42
|
+
// (termasuk SGR) sebelum dibungkus style — nilai mentah hanya boleh muncul
|
|
43
|
+
// sebagai teks polos, styling ditambahkan pemanggil (aturan repo).
|
|
44
|
+
const clean = (v: string): string => stripSgr(sanitizeAnsiLine(v))
|
|
40
45
|
return `${[
|
|
41
46
|
paintWordmark(),
|
|
42
|
-
`${label("Session")} ${c.gray(s.sessionId)}`,
|
|
43
|
-
`${label("Model")} ${c.gray(s.model)}`,
|
|
47
|
+
`${label("Session")} ${c.gray(clean(s.sessionId))}`,
|
|
48
|
+
`${label("Model")} ${c.gray(clean(s.model))}`,
|
|
44
49
|
`${label("Usage")} ${s.totalTokens.toLocaleString()} tokens${
|
|
45
50
|
cost != null ? ` · ${cost}` : ""
|
|
46
51
|
} · ${formatDuration(s.durationMs)}`,
|
package/src/ui/render/theme.ts
CHANGED
|
@@ -345,6 +345,14 @@ export const glyphs = {
|
|
|
345
345
|
get spinnerFrames() {
|
|
346
346
|
return supportsUtf8() ? ["·", "··", "···"] : [".", "..", "..."]
|
|
347
347
|
},
|
|
348
|
+
// Blok progress bar loading (baris tunggal). Fallback ASCII untuk terminal
|
|
349
|
+
// tanpa UTF-8 (MINICODE_ASCII / konsol Windows legacy).
|
|
350
|
+
get blockFilled() {
|
|
351
|
+
return supportsUtf8() ? "▓" : "#"
|
|
352
|
+
},
|
|
353
|
+
get blockEmpty() {
|
|
354
|
+
return supportsUtf8() ? "░" : "-"
|
|
355
|
+
},
|
|
348
356
|
get thinkingIcon() {
|
|
349
357
|
// Sparkle ✦ (bintang) — indikator thinking yang "kelip-kelip": glyph
|
|
350
358
|
// monokrom, jadi warna ANSI (putih ↔ abu di turn-status) terlihat.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Bar loading startup — baris tunggal blok progres (`▓░`) + persen + label
|
|
2
|
+
// di stderr, menggantikan teks proses verbose saat REPL dibuka. Fase startup
|
|
3
|
+
// memanggil `update(label, percent)`; bar melukis via `paintWrite` sehingga
|
|
4
|
+
// otomatis tunduk pada arbitrase statusline.ts (wizard interaktif menahannya,
|
|
5
|
+
// tulis asing di-commit sebagai baris permanen, non-TTY = nol byte).
|
|
6
|
+
//
|
|
7
|
+
// Fase hanyalah sinyal, bukan animasi loop: frame digambar ulang TIDAK pada
|
|
8
|
+
// interval, melainkan saat `update()` dipanggil. Dengan begitu bar tidak
|
|
9
|
+
// berkedip pada startup yang sangat cepat (delay pertama 120ms) dan tidak
|
|
10
|
+
// melukis apa pun bila tidak ada fase yang melaporkan progres.
|
|
11
|
+
|
|
12
|
+
import { sanitizeAnsiLine } from "../render/sanitize.ts"
|
|
13
|
+
import { c, glyphs } from "../render/theme.ts"
|
|
14
|
+
import { truncateToWidth } from "../render/width.ts"
|
|
15
|
+
import { motionReduced } from "./motion.ts"
|
|
16
|
+
import { acquireTransientPaint, paintWrite } from "./statusline.ts"
|
|
17
|
+
|
|
18
|
+
// Jaga agar kursor terminal selalu ter-restore meski proses dihentikan (SIGINT/dll).
|
|
19
|
+
process.on("exit", () => {
|
|
20
|
+
if (process.stderr.isTTY) process.stderr.write("\x1b[?25h")
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export interface LoadingBar {
|
|
24
|
+
/** Ganti label + persen (0..100). Tak pernah melampaui target yang diberikan. */
|
|
25
|
+
update: (label: string, percent: number) => void
|
|
26
|
+
/** Hapus baris + restore kursor. Idempoten. */
|
|
27
|
+
stop: () => void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface LoadingBarOptions {
|
|
31
|
+
/** Tunda frame pertama (ms). Default 120 — fase cepat tak berkedip. */
|
|
32
|
+
delayMs?: number
|
|
33
|
+
/** Lebar maks kolom bar (default 40). */
|
|
34
|
+
barWidth?: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createLoadingBar(
|
|
38
|
+
initialLabel = "",
|
|
39
|
+
opts: LoadingBarOptions = {},
|
|
40
|
+
): LoadingBar | null {
|
|
41
|
+
// Non-TTY/pipe/CI: tanpa animasi/ANSI (kontrak terminal) — bar jadi no-op.
|
|
42
|
+
if (!process.stderr.isTTY) return null
|
|
43
|
+
// Preferensi gerak dikurangi: tetap tampilkan progres (informatif), tapi
|
|
44
|
+
// tanpa menyembunyikan kursor dan tanpa delay (tak ada sensasi animasi).
|
|
45
|
+
const reduced = motionReduced()
|
|
46
|
+
const delayMs = reduced ? 0 : (opts.delayMs ?? 120)
|
|
47
|
+
const barWidthMax = Math.max(8, Math.min(40, opts.barWidth ?? 40))
|
|
48
|
+
let label = sanitizeAnsiLine(initialLabel)
|
|
49
|
+
let percent = 0
|
|
50
|
+
let owned: { release(): void } | null = null
|
|
51
|
+
let delayTimer: ReturnType<typeof setTimeout> | undefined
|
|
52
|
+
let started = false
|
|
53
|
+
let stopped = false
|
|
54
|
+
|
|
55
|
+
const frame = (): string => {
|
|
56
|
+
// Lebar terminal = kolom (bukan karakter). Bar dihitung dari `columns`;
|
|
57
|
+
// sisa kolom untuk label (displayWidth-aware via truncateToWidth).
|
|
58
|
+
const cols = process.stderr.columns ?? process.stdout.columns ?? 80
|
|
59
|
+
const w = Math.min(barWidthMax, Math.max(8, cols - 20))
|
|
60
|
+
const filled = Math.round((percent / 100) * w)
|
|
61
|
+
const blocks = glyphs.blockFilled.repeat(filled) + glyphs.blockEmpty.repeat(w - filled)
|
|
62
|
+
const pct = `${Math.round(percent)}%`.padStart(4)
|
|
63
|
+
const labelPart = truncateToWidth(label, Math.max(4, cols - w - 14))
|
|
64
|
+
return `\r${c.dim(blocks)} ${pct} ${labelPart}\x1b[K`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const paint = (): void => {
|
|
68
|
+
paintWrite(frame())
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const start = (): void => {
|
|
72
|
+
if (stopped || started) return
|
|
73
|
+
started = true
|
|
74
|
+
// Sembunyikan kursor hanya saat animasi normal; mode gerak-dikurangi
|
|
75
|
+
// cukup melukis baris tanpa mengubah visibilitas kursor.
|
|
76
|
+
if (!reduced) paintWrite("\x1b[?25l")
|
|
77
|
+
owned = acquireTransientPaint("loading-bar", paint)
|
|
78
|
+
paint()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const scheduleStart = (): void => {
|
|
82
|
+
if (delayMs > 0) {
|
|
83
|
+
delayTimer = setTimeout(() => {
|
|
84
|
+
delayTimer = undefined
|
|
85
|
+
start()
|
|
86
|
+
}, delayMs)
|
|
87
|
+
// Jangan tahan process hidup hanya karena delay tampil.
|
|
88
|
+
try {
|
|
89
|
+
;(delayTimer as unknown as { unref?: () => void }).unref?.()
|
|
90
|
+
} catch {}
|
|
91
|
+
} else {
|
|
92
|
+
start()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
scheduleStart()
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
update(newLabel: string, newPercent: number) {
|
|
100
|
+
if (stopped) return
|
|
101
|
+
label = sanitizeAnsiLine(newLabel)
|
|
102
|
+
percent = Math.max(0, Math.min(100, newPercent))
|
|
103
|
+
// Sebelum delay habis, bar belum melukis apa pun — cukup simpan label/
|
|
104
|
+
// percent terbaru. `start()` (dari timer delay) memakai nilai ini, jadi
|
|
105
|
+
// fase yang cepat selesai sebelum delay tidak menampilkan frame kosong.
|
|
106
|
+
if (started) paint()
|
|
107
|
+
},
|
|
108
|
+
stop() {
|
|
109
|
+
if (stopped) return
|
|
110
|
+
stopped = true
|
|
111
|
+
if (delayTimer) {
|
|
112
|
+
clearTimeout(delayTimer)
|
|
113
|
+
delayTimer = undefined
|
|
114
|
+
}
|
|
115
|
+
if (owned) {
|
|
116
|
+
owned.release()
|
|
117
|
+
owned = null
|
|
118
|
+
}
|
|
119
|
+
if (started) {
|
|
120
|
+
paintWrite(reduced ? "\r\x1b[K" : "\r\x1b[K\x1b[?25h")
|
|
121
|
+
}
|
|
122
|
+
started = false
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
}
|
package/src/ui/session-state.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface UiSessionStateOptions {
|
|
|
41
41
|
compact?: boolean
|
|
42
42
|
reasoningVisible?: boolean
|
|
43
43
|
minimizeActivity?: boolean
|
|
44
|
+
activityPanel?: boolean
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
/**
|
|
@@ -56,6 +57,7 @@ export class UiSessionState {
|
|
|
56
57
|
#compact: boolean
|
|
57
58
|
#reasoningVisible: boolean
|
|
58
59
|
#minimizeActivity: boolean
|
|
60
|
+
#activityPanel: boolean
|
|
59
61
|
#views: CollapsedSectionView[] = []
|
|
60
62
|
|
|
61
63
|
// Buffer /copy + error tertunda (logger linier). Berlifecycle per sesi:
|
|
@@ -78,6 +80,9 @@ export class UiSessionState {
|
|
|
78
80
|
// ditahan, diganti satu ringkasan turn. Opt-in (`MINICODE_MINIMIZE_ACTIVITY=1`),
|
|
79
81
|
// default transparan sesuai filosofi "agentic Unix shell".
|
|
80
82
|
this.#minimizeActivity = opts.minimizeActivity ?? process.env.MINICODE_MINIMIZE_ACTIVITY === "1"
|
|
83
|
+
// Panel aktivitas (Fase 2): default OFF — opt-in. TUI (cli/tui.ts)
|
|
84
|
+
// menyalakannya secara eksplisit; env bisa meng-override bootstrap.
|
|
85
|
+
this.#activityPanel = opts.activityPanel ?? process.env.MINICODE_ACTIVITY_PANEL === "1"
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
// ── Collapse ────────────────────────────────────────────────────────────
|
|
@@ -197,6 +202,23 @@ export class UiSessionState {
|
|
|
197
202
|
return nextVal
|
|
198
203
|
}
|
|
199
204
|
|
|
205
|
+
// ── Panel aktivitas (Fase 2: thinking + grup tool) ──────────────────────
|
|
206
|
+
|
|
207
|
+
get activityPanel(): boolean {
|
|
208
|
+
return this.#activityPanel
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
set activityPanel(v: boolean) {
|
|
212
|
+
this.#activityPanel = v
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Set eksplisit (on/off) atau toggle bila `next` tidak diberikan. */
|
|
216
|
+
setActivityPanel(next?: boolean): boolean {
|
|
217
|
+
const nextVal = next ?? !this.#activityPanel
|
|
218
|
+
this.#activityPanel = nextVal
|
|
219
|
+
return nextVal
|
|
220
|
+
}
|
|
221
|
+
|
|
200
222
|
// ── Buffer /copy (logger linier) ────────────────────────────────────────
|
|
201
223
|
|
|
202
224
|
/** Isi output turn terakhir (teks model + hasil tool). */
|