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
package/src/ui/tui/transcript.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
UiToolStatus,
|
|
17
17
|
} from "../contract.ts"
|
|
18
18
|
import { t } from "../i18n/locale.ts"
|
|
19
|
+
import { renderActivityPanel } from "../render/activity-panel.ts"
|
|
19
20
|
import { paintLedger, runMarker, statusGlyph, statusWord } from "../render/ledger.ts"
|
|
20
21
|
import { parseFence, renderInline } from "../render/markdown.ts"
|
|
21
22
|
import { type MarkdownTable, parseMarkdownBlocks } from "../render/markdown-table.ts"
|
|
@@ -32,6 +33,8 @@ import { defaultUiState, type UiSessionState } from "../session-state.ts"
|
|
|
32
33
|
// substansi berbeda (viewport vs riwayat yang bisa di-replay).
|
|
33
34
|
export const TRANSCRIPT_CAP = 5000
|
|
34
35
|
export const TRANSCRIPT_TEXT_MAX_CHARS = 1_000_000
|
|
36
|
+
/** Baris thinking yang terlihat di area live (Fase 3). */
|
|
37
|
+
const MAX_THINKING_ROWS = 10
|
|
35
38
|
const TRANSCRIPT_TRUNCATION_MARKER = "… [transcript truncated: turn cap exceeded]"
|
|
36
39
|
/**
|
|
37
40
|
* Sink approval TUI: pemilik layar (cli/tui.ts) mendaftarkan transkrip +
|
|
@@ -228,6 +231,9 @@ export class Transcript {
|
|
|
228
231
|
* expanded: mengalir redup seperti teks. */
|
|
229
232
|
private thinkingBuf = ""
|
|
230
233
|
private thinkingTail = ""
|
|
234
|
+
/** Baris thinking turn berjalan (mode AREA, Fase 3): dirender sebagai blok
|
|
235
|
+
* live maks 10 baris, bukan di-commit per baris. Diringkas saat turn selesai. */
|
|
236
|
+
private thinkingArea: string[] = []
|
|
231
237
|
private meta: TranscriptMeta[] = []
|
|
232
238
|
private evicted = 0
|
|
233
239
|
private hasEvictMarker = false
|
|
@@ -371,6 +377,7 @@ export class Transcript {
|
|
|
371
377
|
// diberi marker append-only di bawah.
|
|
372
378
|
this.thinkingBuf = ""
|
|
373
379
|
this.thinkingTail = ""
|
|
380
|
+
this.thinkingArea = []
|
|
374
381
|
if (data.hadVisibleOutput === true) {
|
|
375
382
|
this.push(c.warning(t("ts.providerAttemptDiscarded", { attempt: id })), {
|
|
376
383
|
kind: "diagnostic",
|
|
@@ -384,28 +391,69 @@ export class Transcript {
|
|
|
384
391
|
if (!text) return
|
|
385
392
|
const clean = sanitizeAnsi(text)
|
|
386
393
|
if (this.uiState.reasoningVisible) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
this.
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
if (this.thinkingAreaMode()) {
|
|
395
|
+
// Mode AREA (Fase 3): tahan baris di buffer, dirender sebagai blok live
|
|
396
|
+
// terbatas (projectAll). JANGAN di-commit per baris — area yang
|
|
397
|
+
// menggantikannya + ringkasan saat turn selesai.
|
|
398
|
+
this.thinkingTail += clean
|
|
399
|
+
const parts = this.thinkingTail.split("\n")
|
|
400
|
+
for (let i = 0; i < parts.length - 1; i++) this.thinkingArea.push(parts[i] ?? "")
|
|
401
|
+
// Batasi memori; detail penuh sudah dipangkas per turn saat ringkasan.
|
|
402
|
+
if (this.thinkingArea.length > 2000)
|
|
403
|
+
this.thinkingArea.splice(0, this.thinkingArea.length - 2000)
|
|
404
|
+
this.thinkingTail = parts[parts.length - 1] ?? ""
|
|
405
|
+
} else {
|
|
406
|
+
// Legacy (panel off): alir per baris dengan indentasi 2 kolom
|
|
407
|
+
// (line-buffered, ekor hidup) — membedakan thinking dari jawaban model.
|
|
408
|
+
this.thinkingTail += clean
|
|
409
|
+
const parts = this.thinkingTail.split("\n")
|
|
410
|
+
for (let i = 0; i < parts.length - 1; i++)
|
|
411
|
+
this.append(c.thinking(` ${parts[i] ?? ""}`), { kind: "diagnostic" })
|
|
412
|
+
|
|
413
|
+
this.thinkingTail = parts[parts.length - 1] ?? ""
|
|
414
|
+
}
|
|
395
415
|
} else {
|
|
396
416
|
// Minimized: penanda hidup; isi disimpan di collapsed view linear.
|
|
397
417
|
this.thinkingBuf = (this.thinkingBuf + clean).slice(-20000)
|
|
398
418
|
}
|
|
399
419
|
}
|
|
400
420
|
|
|
401
|
-
/**
|
|
402
|
-
*
|
|
421
|
+
/** Mode area thinking aktif? Panel aktivitas ON + reasoning terlihat.
|
|
422
|
+
* Panel off = perilaku legacy (stream per baris) agar `/fold` benar-benar
|
|
423
|
+
* mengembalikan tampilan mentah. */
|
|
424
|
+
private thinkingAreaMode(): boolean {
|
|
425
|
+
return this.uiState.reasoningVisible && this.uiState.activityPanel
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** Selesaikan fase thinking.
|
|
429
|
+
* - Mode area: ringkas jadi SATU baris (detail penuh di `/expand`).
|
|
430
|
+
* - Legacy: flush ekor berindentasi.
|
|
431
|
+
* - Minimized: penanda hilang. */
|
|
403
432
|
private commitThinking(): void {
|
|
433
|
+
if (this.thinkingAreaMode()) {
|
|
434
|
+
const lines = [...this.thinkingArea]
|
|
435
|
+
if (this.thinkingTail) {
|
|
436
|
+
lines.push(this.thinkingTail)
|
|
437
|
+
this.thinkingTail = ""
|
|
438
|
+
}
|
|
439
|
+
this.thinkingArea = []
|
|
440
|
+
this.thinkingBuf = ""
|
|
441
|
+
if (lines.length > 0) {
|
|
442
|
+
// Detail penuh tidak hilang: masuk buffer `/expand`.
|
|
443
|
+
this.uiState.rememberCollapsedSection("thinking", lines.join("\n"))
|
|
444
|
+
this.append(
|
|
445
|
+
c.thinking(` + ${t("panel.thinking")} · ${t("panel.lines", { n: lines.length })}`),
|
|
446
|
+
{ kind: "diagnostic" },
|
|
447
|
+
)
|
|
448
|
+
}
|
|
449
|
+
return
|
|
450
|
+
}
|
|
404
451
|
if (this.thinkingTail) {
|
|
405
452
|
this.append(c.thinking(` ${this.thinkingTail}`), { kind: "diagnostic" })
|
|
406
453
|
this.thinkingTail = ""
|
|
407
454
|
}
|
|
408
455
|
this.thinkingBuf = ""
|
|
456
|
+
this.thinkingArea = []
|
|
409
457
|
}
|
|
410
458
|
|
|
411
459
|
/** Dorong baris logis (sudah final, mis. gema prompt user). */
|
|
@@ -466,6 +514,7 @@ export class Transcript {
|
|
|
466
514
|
this.activeProviderAttempt = null
|
|
467
515
|
this.thinkingBuf = ""
|
|
468
516
|
this.thinkingTail = ""
|
|
517
|
+
this.thinkingArea = []
|
|
469
518
|
this.evicted = 0
|
|
470
519
|
this.hasEvictMarker = false
|
|
471
520
|
this.runningMemo = null
|
|
@@ -609,14 +658,77 @@ export class Transcript {
|
|
|
609
658
|
}
|
|
610
659
|
}
|
|
611
660
|
|
|
661
|
+
/** Baris live area thinking (mode area): header `+ berpikir` + maks 10 baris
|
|
662
|
+
* visual terakhir dari turn berjalan. Baris panjang dibungkus (bukan
|
|
663
|
+
* dipotong). Kosong bila mode area off / belum ada thinking. */
|
|
664
|
+
private thinkingRows(w: number): TranscriptRow[] {
|
|
665
|
+
if (!this.thinkingAreaMode()) return []
|
|
666
|
+
const logical = [...this.thinkingArea]
|
|
667
|
+
if (this.thinkingTail) logical.push(this.thinkingTail)
|
|
668
|
+
if (logical.length === 0) return []
|
|
669
|
+
const visual: string[] = []
|
|
670
|
+
for (const line of logical) {
|
|
671
|
+
if (line === "") visual.push("")
|
|
672
|
+
else visual.push(...wrapByWidth(line, w))
|
|
673
|
+
}
|
|
674
|
+
const shown = visual.slice(-MAX_THINKING_ROWS)
|
|
675
|
+
const hidden = visual.length - shown.length
|
|
676
|
+
const out: TranscriptRow[] = []
|
|
677
|
+
const push = (raw: string) => {
|
|
678
|
+
out.push({
|
|
679
|
+
text: c.thinking(raw),
|
|
680
|
+
sourceId: -1,
|
|
681
|
+
sourceStart: 0,
|
|
682
|
+
sourceEnd: 0,
|
|
683
|
+
displayStart: 0,
|
|
684
|
+
displayEnd: displayWidth(raw),
|
|
685
|
+
selectable: false,
|
|
686
|
+
})
|
|
687
|
+
}
|
|
688
|
+
push(
|
|
689
|
+
hidden > 0
|
|
690
|
+
? ` + ${t("panel.thinking")} · ${t("panel.moreLines", { n: hidden })}`
|
|
691
|
+
: ` + ${t("panel.thinking")}`,
|
|
692
|
+
)
|
|
693
|
+
for (const row of shown) push(` ${row}`)
|
|
694
|
+
return out
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** Proyeksi panel aktivitas (Fase 2): baris grup dari tool TURN BERJALAN.
|
|
698
|
+
* Sumber = `activityFold` (dikumpulkan per turn oleh event tool), BUKAN
|
|
699
|
+
* snapshot sesi — snapshot bersifat kumulatif sampai cap, jadi akan
|
|
700
|
+
* menampilkan tool dari turn lama. Kosong bila panel off / belum ada tool. */
|
|
701
|
+
private panelRows(): TranscriptRow[] {
|
|
702
|
+
if (!this.uiState.activityPanel) return []
|
|
703
|
+
if (this.activityFold.length === 0) return []
|
|
704
|
+
const activities = this.activityFold.map((e) => ({
|
|
705
|
+
toolCallId: "",
|
|
706
|
+
name: e.name,
|
|
707
|
+
status: e.status as UiToolStatus,
|
|
708
|
+
tsStart: 0,
|
|
709
|
+
}))
|
|
710
|
+
const lines = renderActivityPanel(activities, { maxRows: 10 })
|
|
711
|
+
return lines.map((line) => ({
|
|
712
|
+
text: line,
|
|
713
|
+
sourceId: -1,
|
|
714
|
+
sourceStart: 0,
|
|
715
|
+
sourceEnd: 0,
|
|
716
|
+
displayStart: 0,
|
|
717
|
+
displayEnd: displayWidth(line),
|
|
718
|
+
selectable: false,
|
|
719
|
+
}))
|
|
720
|
+
}
|
|
721
|
+
|
|
612
722
|
private projectAll(width: number): TranscriptRow[] {
|
|
613
723
|
const w = Math.max(10, width)
|
|
724
|
+
const thinking = this.thinkingRows(w)
|
|
614
725
|
const running = this.runningRows()
|
|
726
|
+
const panel = this.panelRows()
|
|
615
727
|
// Kasus umum (idle ketik/scroll — thinking tau cara running kosong):
|
|
616
728
|
// kembalikan gabungan committed+pending yang ter-cache TANPA menyalin ulang.
|
|
617
729
|
// Ini memberantas biaya concat O(N) pada setiap paint (biaya yang TUMBUH
|
|
618
730
|
// seiring transkrip menumpuk — tepat gejala "mengetik berat saat history penuh").
|
|
619
|
-
if (!this.thinkingTail && running.length === 0) {
|
|
731
|
+
if (!this.thinkingTail && thinking.length === 0 && running.length === 0 && panel.length === 0) {
|
|
620
732
|
if (
|
|
621
733
|
this.projectedBase &&
|
|
622
734
|
this.projectedBase.width === w &&
|
|
@@ -639,7 +751,7 @@ export class Transcript {
|
|
|
639
751
|
// thinking/running aktif: bangun segar (jarang — hanya saat turn berjalan,
|
|
640
752
|
// dan repaint-nya sudah dicoalesce 30ms, bukan per-keypress).
|
|
641
753
|
const rows: TranscriptRow[] = [...this.committedRows(w), ...this.pendingRows(w)]
|
|
642
|
-
if (this.thinkingTail) {
|
|
754
|
+
if (!this.thinkingAreaMode() && this.thinkingTail) {
|
|
643
755
|
for (const chunk of this.thinkingTail.split("\n")) {
|
|
644
756
|
const chunkRows = chunk === "" ? [""] : wrapByWidth(chunk, w)
|
|
645
757
|
for (const row of chunkRows) {
|
|
@@ -655,6 +767,12 @@ export class Transcript {
|
|
|
655
767
|
}
|
|
656
768
|
}
|
|
657
769
|
}
|
|
770
|
+
// Area thinking (Fase 3): blok live maks 10 baris terakhir (mode area).
|
|
771
|
+
// Mode legacy sudah menaruh thinking-nya di atas (stream per baris).
|
|
772
|
+
rows.push(...thinking)
|
|
773
|
+
// Baris tool yang SEDANG berjalan (dari snapshot). Panel aktivitas hanya
|
|
774
|
+
// memuat tool TERMINAL (fold), jadi running tetap punya barisnya sendiri —
|
|
775
|
+
// tak ada duplikasi, dan tool yang belum selesai tidak pernah hilang.
|
|
658
776
|
for (const row of running) {
|
|
659
777
|
rows.push({
|
|
660
778
|
text: row,
|
|
@@ -666,6 +784,9 @@ export class Transcript {
|
|
|
666
784
|
selectable: false,
|
|
667
785
|
})
|
|
668
786
|
}
|
|
787
|
+
// Panel aktivitas (Fase 2): baris grup tool terminal — tampil di bawah
|
|
788
|
+
// running, di atas transkrip. Hanya saat ada activity.
|
|
789
|
+
rows.push(...panel)
|
|
669
790
|
return rows
|
|
670
791
|
}
|
|
671
792
|
|
|
@@ -975,9 +1096,11 @@ export class Transcript {
|
|
|
975
1096
|
if (event.type === "turn.completed") {
|
|
976
1097
|
this.commit()
|
|
977
1098
|
this.commitThinking()
|
|
978
|
-
// minimizeActivity ON → fold meringkas sendiri (nama
|
|
979
|
-
// turnSummary (turn · files · durasi) dilewati agar
|
|
980
|
-
|
|
1099
|
+
// minimizeActivity ON / activityPanel ON → fold meringkas sendiri (nama
|
|
1100
|
+
// tool + ok/gagal); turnSummary (turn · files · durasi) dilewati agar
|
|
1101
|
+
// tidak ada dua ringkasan.
|
|
1102
|
+
if (!this.uiState.minimizeActivity && !this.uiState.activityPanel)
|
|
1103
|
+
this.turnSummary(event.summary, event)
|
|
981
1104
|
this.flushActivityFold()
|
|
982
1105
|
return
|
|
983
1106
|
}
|
|
@@ -1098,10 +1221,11 @@ export class Transcript {
|
|
|
1098
1221
|
? `: ${truncateToWidth(sanitizeAnsi(denyReason), 200, "…").split("\n")[0] ?? ""}`
|
|
1099
1222
|
: ""
|
|
1100
1223
|
const line = ` ${statusGlyph(status)} ${name}${targetText} ${statusWord(status)}${retry}${child}${verificationMark}${provenanceMark}${message}`
|
|
1101
|
-
// Lipat aktivitas (opencode-like): saat minimizeActivity
|
|
1102
|
-
// per-tool TIDAK boleh menghilang diam-diam
|
|
1103
|
-
//
|
|
1104
|
-
|
|
1224
|
+
// Lipat aktivitas (opencode-like): saat minimizeActivity ATAU panel
|
|
1225
|
+
// aktivitas aktif, baris ledger per-tool TIDAK boleh menghilang diam-diam
|
|
1226
|
+
// — ditahan lalu dirangkum saat turn selesai (panel: per keluarga tool;
|
|
1227
|
+
// minimize: satu baris nama+hitungan). Detail via /expand.
|
|
1228
|
+
if (this.uiState.minimizeActivity || this.uiState.activityPanel) {
|
|
1105
1229
|
this.activityFold.push({ name, status, line })
|
|
1106
1230
|
return
|
|
1107
1231
|
}
|
|
@@ -1314,11 +1438,29 @@ export class Transcript {
|
|
|
1314
1438
|
|
|
1315
1439
|
/** Flush lipatan aktivitas (minimizeActivity) menjadi SATU baris ringkas
|
|
1316
1440
|
* (opencode-like) + buffer detail untuk /expand. Tidak menghilangkan isi
|
|
1317
|
-
* diam-diam: nama tool + hitung ok/gagal tetap terlihat.
|
|
1441
|
+
* diam-diam: nama tool + hitung ok/gagal tetap terlihat.
|
|
1442
|
+
*
|
|
1443
|
+
* Saat activityPanel ON, ringkasan memakai KELUARGA tool (satu baris per
|
|
1444
|
+
* grup — `+ explore · 3 tools · 2 ok`) alih-alih daftar nama rata.
|
|
1445
|
+
* Detail penuh tetap masuk /expand. */
|
|
1318
1446
|
private flushActivityFold(): void {
|
|
1319
1447
|
const fold = this.activityFold
|
|
1320
1448
|
this.activityFold = []
|
|
1321
1449
|
if (fold.length === 0) return
|
|
1450
|
+
// Panel ON: render per-grup (sumber: event tool yang sudah dikumpulkan).
|
|
1451
|
+
if (this.uiState.activityPanel) {
|
|
1452
|
+
const activities = fold.map((e) => ({
|
|
1453
|
+
toolCallId: "",
|
|
1454
|
+
name: e.name,
|
|
1455
|
+
status: e.status as UiToolStatus,
|
|
1456
|
+
tsStart: 0,
|
|
1457
|
+
}))
|
|
1458
|
+
const lines = renderActivityPanel(activities, { maxRows: 10 })
|
|
1459
|
+
if (lines.length === 0) return
|
|
1460
|
+
this.uiState.rememberCollapsedSection("activity", fold.map((e) => e.line).join("\n"))
|
|
1461
|
+
for (const line of lines) this.append(line, { kind: "activity" })
|
|
1462
|
+
return
|
|
1463
|
+
}
|
|
1322
1464
|
const count = (status: string) => fold.reduce((n, e) => n + (e.status === status ? 1 : 0), 0)
|
|
1323
1465
|
const ok = count("completed")
|
|
1324
1466
|
const failed = count("failed")
|