minicode-ai 0.23.0 → 0.26.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.
Files changed (104) hide show
  1. package/README.md +5 -3
  2. package/cli/commands/config.ts +123 -0
  3. package/cli/setup.ts +107 -8
  4. package/cli/tui.ts +28 -2
  5. package/docs/README.md +2 -2
  6. package/docs/SUMMARY.md +10 -19
  7. package/docs/TERMINAL_CONTRACT.md +113 -28
  8. package/docs/architecture.md +1 -1
  9. package/docs/autonomous-scheduler.md +283 -2
  10. package/docs/choosing-mode.md +4 -4
  11. package/docs/concepts.md +39 -3
  12. package/docs/config.md +103 -5
  13. package/docs/environment.md +4 -0
  14. package/docs/getting-started.md +69 -5
  15. package/docs/repl.md +1 -1
  16. package/docs/security.md +49 -2
  17. package/docs/tools.md +2 -1
  18. package/package.json +2 -36
  19. package/src/app/provider-layer.ts +1 -1
  20. package/src/app/session.ts +187 -17
  21. package/src/config.ts +21 -8
  22. package/src/constants.ts +17 -1
  23. package/src/lib/net.ts +6 -15
  24. package/src/lib/public-http.ts +128 -0
  25. package/src/lib/safe-open.ts +21 -12
  26. package/src/memory/vector.ts +0 -31
  27. package/src/policy/auto-resume.ts +63 -0
  28. package/src/policy/compaction.ts +354 -70
  29. package/src/policy/context-budget.ts +4 -6
  30. package/src/policy/context-window-assign.ts +114 -0
  31. package/src/policy/context-window-catalog.ts +4 -1
  32. package/src/policy/context-window-presets.ts +165 -0
  33. package/src/policy/context-window.ts +19 -37
  34. package/src/policy/context.ts +11 -9
  35. package/src/policy/executor.ts +69 -27
  36. package/src/policy/microcompact.ts +76 -15
  37. package/src/policy/no-progress.ts +1 -1
  38. package/src/policy/permission.ts +5 -0
  39. package/src/policy/recovery-budget.ts +281 -0
  40. package/src/policy/scrub.ts +15 -2
  41. package/src/policy/step-escalation.ts +82 -0
  42. package/src/policy/tokenizer-registry.ts +1 -0
  43. package/src/policy/tool-contract.ts +11 -9
  44. package/src/presentation/reducer.ts +1 -0
  45. package/src/providers/anthropic.ts +3 -3
  46. package/src/providers/detect.ts +40 -7
  47. package/src/providers/provision.ts +23 -1
  48. package/src/runtime/child-execution.ts +4 -2
  49. package/src/runtime/execution-backend.ts +3 -0
  50. package/src/sandbox/os.ts +53 -9
  51. package/src/session/context-assembly.ts +11 -7
  52. package/src/session/persistence.ts +19 -3
  53. package/src/task/autonomous-policy.ts +7 -0
  54. package/src/task/graph-validate.ts +1 -1
  55. package/src/task/session-authority.ts +0 -5
  56. package/src/task/store.ts +0 -4
  57. package/src/tools/ask_user.ts +14 -1
  58. package/src/tools/bash.ts +68 -17
  59. package/src/tools/code_run.ts +19 -20
  60. package/src/tools/context.ts +10 -0
  61. package/src/tools/delete_file.ts +3 -2
  62. package/src/tools/edit.ts +5 -4
  63. package/src/tools/git.ts +70 -12
  64. package/src/tools/glob.ts +13 -5
  65. package/src/tools/grep.ts +26 -10
  66. package/src/tools/index.ts +3 -2
  67. package/src/tools/lsp.ts +15 -9
  68. package/src/tools/move_file.ts +4 -3
  69. package/src/tools/patch.ts +5 -4
  70. package/src/tools/read_file.ts +3 -2
  71. package/src/tools/read_image.ts +3 -2
  72. package/src/tools/task.ts +5 -1
  73. package/src/tools/todo.ts +4 -8
  74. package/src/tools/web_fetch.ts +13 -19
  75. package/src/tools/write_file.ts +4 -3
  76. package/src/ui/approval/prompt.ts +226 -77
  77. package/src/ui/assistant/simple.ts +61 -10
  78. package/src/ui/footer.ts +41 -29
  79. package/src/ui/i18n/en.ts +7 -0
  80. package/src/ui/i18n/id.ts +7 -0
  81. package/src/ui/input/prompt-engine.ts +53 -21
  82. package/src/ui/render/activity-group.ts +9 -0
  83. package/src/ui/render/activity-panel.ts +20 -2
  84. package/src/ui/render/ledger.ts +1 -9
  85. package/src/ui/render/logo.ts +0 -5
  86. package/src/ui/render/markdown-table.ts +0 -3
  87. package/src/ui/render/table-grid.ts +0 -3
  88. package/src/ui/render/theme.ts +31 -5
  89. package/src/ui/runtime/screen.ts +7 -1
  90. package/src/ui/screens/dialog.ts +45 -81
  91. package/src/ui/screens/form.ts +10 -10
  92. package/src/ui/screens/model-manager.ts +7 -10
  93. package/src/ui/screens/picker.ts +8 -11
  94. package/src/ui/screens/provider-manager.ts +9 -13
  95. package/src/ui/tui/app.ts +118 -20
  96. package/src/ui/tui/transcript.ts +179 -29
  97. package/vendor/minicore/src/core/loop.ts +20 -1
  98. package/vendor/minicore/src/core/session.ts +6 -0
  99. package/docs/P14_OPEN_WORK.md +0 -290
  100. package/docs/config-providers.md +0 -87
  101. package/docs/glossary.md +0 -39
  102. package/docs/quickstart.md +0 -60
  103. package/docs/security-model.md +0 -96
  104. package/docs/terminal.md +0 -91
package/src/ui/footer.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  // dengan spasi dan warna, tanpa bullet separator. Work Mode ada di kiri;
9
9
  // Permission Mode berwarna cyan di sisi kanan, dekat penggunaan konteks.
10
10
  import { sanitizeAnsiLine } from "./render/sanitize.ts"
11
- import { c, glyphs, themeCapabilityKey } from "./render/theme.ts"
11
+ import { c, glyphs, supportsUtf8, themeCapabilityKey } from "./render/theme.ts"
12
12
  import { displayWidth, truncateToWidth } from "./render/width.ts"
13
13
 
14
14
  export type TimerHighlight = "seconds" | "minutes" | "hours"
@@ -36,6 +36,11 @@ export interface FooterStatus {
36
36
  * memetakan frame → glyph berwarna.
37
37
  */
38
38
  sparkFrame?: number
39
+ /** Jumlah job bash background hidup (dihitung di cli — batas lapisan).
40
+ * >= 1 = badge `◷ N` berputar; 0/undefined = tanpa badge. */
41
+ backgroundJobs?: number
42
+ /** Frame animasi badge job (dinaikkan clock idle di app.ts, bukan turn). */
43
+ backgroundFrame?: number
39
44
  activity?: string
40
45
  timer?: string
41
46
  timerActive?: boolean
@@ -43,8 +48,6 @@ export interface FooterStatus {
43
48
  }
44
49
 
45
50
  /** Lebar tetap kolom agar perubahan WorkMode tidak menggeser model/CWD. */
46
- const WORK_MODE_WIDTH = 18
47
- const WORK_MODE_COMPACT_WIDTH = 13
48
51
  const WORK_MODE_VALUE_WIDTH = 7
49
52
 
50
53
  /** Buang prefix provider (`acme::deepseek-v4` → `deepseek-v4`). */
@@ -73,41 +76,30 @@ function workModeValue(workMode?: string): string {
73
76
 
74
77
  type ModeLabelStyle = "full" | "compact" | "value"
75
78
 
76
- /** Work Mode memakai warna semantik; label/nilai memakai title case. */
77
- export function paintWorkMode(workMode?: string, style: ModeLabelStyle = "full"): string {
79
+ /** Work Mode memakai warna semantik; nilai title case tanpa label (v0.24:
80
+ * footer lebih lega — nilai saja, pembeda sumbu = warna). */
81
+ export function paintWorkMode(workMode?: string, _style: ModeLabelStyle = "full"): string {
78
82
  const value = workModeValue(workMode)
79
83
  const normalized = sanitizeAnsiLine(workMode || "DISCUSS").toUpperCase()
80
- const prefix = style === "full" ? "Work Mode: " : style === "compact" ? "Work: " : ""
81
- const width =
82
- style === "full"
83
- ? WORK_MODE_WIDTH
84
- : style === "compact"
85
- ? WORK_MODE_COMPACT_WIDTH
86
- : WORK_MODE_VALUE_WIDTH
87
- const labelWidth = displayWidth(sanitizeAnsiLine(`${prefix}${value}`))
84
+ const labelWidth = displayWidth(sanitizeAnsiLine(value))
88
85
  const colorValue = normalized === "DISCUSS" || normalized === "PLAN" ? c.warning : c.success
89
- return `${prefix ? c.gray(prefix) : ""}${colorValue(value)}${" ".repeat(
90
- Math.max(0, width - labelWidth),
91
- )}`
86
+ return `${colorValue(value)}${" ".repeat(Math.max(0, WORK_MODE_VALUE_WIDTH - labelWidth))}`
92
87
  }
93
88
 
94
- /** Permission Mode selalu cyan agar terpisah secara visual dari Work Mode.
95
- * `unrestricted` (full akses, /unrestric): label disembunyikan — cukup gembok
96
- * terbuka 🔓 sebagai indikator satu-satunya (lihat paintBashStrict). */
97
- export function paintPermissionMode(mode: string, style: ModeLabelStyle = "full"): string {
89
+ /** Permission Mode selalu cyan agar terpisah dari Work Mode. `unrestricted`:
90
+ * label disembunyikan — cukup titik terbuka ○ (lihat paintBashStrict). */
91
+ export function paintPermissionMode(mode: string, _style: ModeLabelStyle = "full"): string {
98
92
  if (mode === "unrestricted") return ""
99
93
  const value = titleCaseMode(mode, "Auto")
100
- if (style === "value") return c.info(value)
101
- const prefix = style === "full" ? "Permission Mode: " : "Permission: "
102
- return `${c.gray(prefix)}${c.info(value)}`
94
+ return c.info(value)
103
95
  }
104
96
 
105
- /** Badge pembatas bash allow-list: gembok selalu tampil — terang saat aktif,
106
- * redup saat nonaktif (lapis kapabilitas, terpisah dari mode persetujuan).
107
- * Saat `unrestricted` aktif, gembok jadi TERBUKA (🔓) — satu-satunya penanda,
108
- * jadi dirender jelas (bukan redup). */
97
+ /** Badge pembatas bash allow-list: titik selalu tampil — terang/kuning saat
98
+ * aktif, redup/abu saat nonaktif (lapis kapabilitas, terpisah dari mode
99
+ * persetujuan). Saat `unrestricted` aktif, titik jadi ○ MERAH — satu-satunya
100
+ * penanda mode itu, jadi dirender jelas (bukan redup). */
109
101
  export function paintBashStrict(strictBash?: boolean, unrestricted = false): string {
110
- if (unrestricted) return c.info(glyphs.unlock)
102
+ if (unrestricted) return c.red(glyphs.unlock)
111
103
  return strictBash ? c.yellow(glyphs.lock) : c.gray(glyphs.lock)
112
104
  }
113
105
 
@@ -118,6 +110,20 @@ function sparkGlyph(frame: number): string {
118
110
  return frame % 2 === 0 ? c.white(g) : c.gray(g)
119
111
  }
120
112
 
113
+ // Badge job background: jam flat berputar PELAN (fase beda dari spark),
114
+ // monokrom; fallback ASCII `[BG:n]`.
115
+ const WAITING_GLYPHS = ["◷", "◶", "◵", "◴"] as const
116
+ const WAITING_ASCII = ["[BG:", "|", "/", "-"] as const
117
+
118
+ /** Frame -> glyph badge tunggu. `count` = jumlah job hidup; 0 = string kosong. */
119
+ export function waitingGlyph(count: number, frame = 0): string {
120
+ if (count <= 0) return ""
121
+ const n = Math.max(1, Math.floor(count))
122
+ if (!supportsUtf8()) return `${WAITING_ASCII[0]}${n}]`
123
+ const phase = Math.abs(Math.floor(frame)) % WAITING_GLYPHS.length
124
+ return `${WAITING_GLYPHS[phase]} ${n}`
125
+ }
126
+
121
127
  function paintTimer(text: string, active: boolean, highlight: TimerHighlight = "seconds"): string {
122
128
  if (!active) return c.gray(text)
123
129
  const parts = text.split(".")
@@ -168,6 +174,8 @@ function footerCacheKey(s: FooterStatus, cols: number): string {
168
174
  s.context ?? "",
169
175
  s.metrics ?? "",
170
176
  s.sparkFrame ?? 0,
177
+ s.backgroundJobs ?? 0,
178
+ s.backgroundFrame ?? 0,
171
179
  s.activity ?? "",
172
180
  s.timer ?? "",
173
181
  s.timerActive === true,
@@ -194,11 +202,15 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
194
202
 
195
203
  function buildFooterLine(s: FooterStatus, cols: number): string {
196
204
  const spark = sparkGlyph(s.sparkFrame ?? 0)
205
+ const badge =
206
+ s.backgroundJobs != null && s.backgroundJobs >= 1
207
+ ? `${c.muted(waitingGlyph(s.backgroundJobs, s.backgroundFrame ?? 0))} `
208
+ : ""
197
209
  const timerText = s.timer ? sanitizeAnsiLine(s.timer) : ""
198
210
  const timer = timerText
199
211
  ? `${paintTimer(timerText, s.timerActive === true, s.timerHighlight)} `
200
212
  : ""
201
- const lead = `${spark} ${timer}`
213
+ const lead = `${spark} ${badge}${timer}`
202
214
  const fieldGap = " "
203
215
  // Satu-baris: cwd/model bisa berisi newline (nama dir) — sanitizeAnsiLine
204
216
  // agar \n tak memecah frame lengket ke scrollback (displayWidth menghitung
package/src/ui/i18n/en.ts CHANGED
@@ -25,6 +25,7 @@ export const en = {
25
25
  "appr.decAllow": "allow",
26
26
  "appr.decAlways": "always",
27
27
  "appr.decDeny": "deny",
28
+ "appr.keyHint": "↑↓ move · Enter pick · Esc cancel",
28
29
  "appr.askTitle": "Agent asks",
29
30
  "appr.a11y": "[approval required: {name}]",
30
31
  "appr.answerPrompt": "Your answer (empty = cancel): ",
@@ -256,6 +257,9 @@ export const en = {
256
257
  "tui.workModeUnavailable": "work mode is not available in this session",
257
258
  "tui.unrestrictedOn": "unrestricted mode enabled - full access",
258
259
  "tui.unrestrictedOff": "unrestricted disabled — permission mode restored to {m}",
260
+ "tui.bgFinished": "background job {id} finished (exit {code})",
261
+ "tui.bgFinishedAuto":
262
+ "background job {id} finished with exit code {code}. Continue the work you were doing before without waiting for me: collect the job output with bash_output if relevant, verify the result, then finish the remaining tasks.",
259
263
  "tui.langLine": "lang: {v}",
260
264
  "tui.toolCall": "tool call: {v}",
261
265
  "tui.modelSet": "model: {v}",
@@ -342,6 +346,9 @@ export const en = {
342
346
  "panel.tools": "{n} tools",
343
347
  "panel.ok": "{n} ok",
344
348
  "panel.failed": "{n} failed",
349
+ "panel.denied": "{n} denied",
350
+ "panel.cancelled": "{n} cancelled",
351
+ "panel.interrupted": "{n} interrupted",
345
352
  "panel.running": "{n} running",
346
353
  "panel.thinking": "thinking",
347
354
  "panel.lines": "{n} lines",
package/src/ui/i18n/id.ts CHANGED
@@ -26,6 +26,7 @@ export const id: Record<MsgKey, string> = {
26
26
  "appr.decAllow": "izinkan",
27
27
  "appr.decAlways": "selalu",
28
28
  "appr.decDeny": "tolak",
29
+ "appr.keyHint": "↑↓ pindah · Enter pilih · Esc batal",
29
30
  "appr.askTitle": "Agen bertanya",
30
31
  "appr.a11y": "[butuh persetujuan: {name}]",
31
32
  "appr.answerPrompt": "Jawaban (kosong = batal): ",
@@ -259,6 +260,9 @@ export const id: Record<MsgKey, string> = {
259
260
  "tui.workModeUnavailable": "work mode tidak tersedia di sesi ini",
260
261
  "tui.unrestrictedOn": "mode unrestricted aktif - akses penuh",
261
262
  "tui.unrestrictedOff": "unrestricted nonaktif — mode izin kembali ke {m}",
263
+ "tui.bgFinished": "job background {id} selesai (exit {code})",
264
+ "tui.bgFinishedAuto":
265
+ "job background {id} selesai dengan exit code {code}. Lanjutkan pekerjaan yang tadi tanpa menunggu saya: ambil output job lewat bash_output bila relevan, verifikasi hasilnya, lalu selesaikan tugas yang tersisa.",
262
266
  "tui.langLine": "lang: {v}",
263
267
  "tui.toolCall": "pemanggilan tool: {v}",
264
268
  "tui.modelSet": "model: {v}",
@@ -346,6 +350,9 @@ export const id: Record<MsgKey, string> = {
346
350
  "panel.tools": "{n} tool",
347
351
  "panel.ok": "{n} sukses",
348
352
  "panel.failed": "{n} gagal",
353
+ "panel.denied": "{n} ditolak",
354
+ "panel.cancelled": "{n} dibatalkan",
355
+ "panel.interrupted": "{n} terhenti",
349
356
  "panel.running": "{n} berjalan",
350
357
  "panel.thinking": "berpikir",
351
358
  "panel.lines": "{n} baris",
@@ -403,12 +403,17 @@ export interface DecodedKey {
403
403
  export interface DecoderState {
404
404
  /** Byte yang belum lengkap jadi satu key (tail dari chunk sebelumnya). */
405
405
  pending: number[]
406
+ /** Overlong sequences retain only their termination rule, never their payload. */
407
+ discard?: "csi" | "sgr"
406
408
  }
407
409
 
408
410
  export function createDecoderState(): DecoderState {
409
411
  return { pending: [] }
410
412
  }
411
413
 
414
+ // Bound incomplete control sequences independently of bracketed paste payloads.
415
+ const MAX_CONTROL_SEQUENCE_BYTES = 64
416
+
412
417
  function isCsiParam(b: number): boolean {
413
418
  return b >= 0x30 && b <= 0x3f
414
419
  }
@@ -480,6 +485,17 @@ export function decodeKeysStream(chunk: Uint8Array, state: DecoderState): Decode
480
485
  let i = 0
481
486
  while (i < buf.length) {
482
487
  const b = buf[i]!
488
+ if (state.discard) {
489
+ if (b < 0x20 || b >= 0x7f) {
490
+ // Recover at an independent byte without consuming it (including ESC).
491
+ state.discard = undefined
492
+ } else {
493
+ const final = state.discard === "sgr" ? b === 0x4d || b === 0x6d : isCsiFinal(b)
494
+ if (final) state.discard = undefined
495
+ i++
496
+ continue
497
+ }
498
+ }
483
499
  if (b === 0x1b) {
484
500
  const n1 = buf[i + 1]
485
501
  // ESC di ujung chunk = awal sekuens yang terbelah (panah ESC[A jadi
@@ -531,13 +547,26 @@ export function decodeKeysStream(chunk: Uint8Array, state: DecoderState): Decode
531
547
  }
532
548
  if (n1 === 0x5b && buf[i + 2] === 0x3c) {
533
549
  let j = i + 3
534
- while (j < buf.length && buf[j] !== 0x4d && buf[j] !== 0x6d) j++
535
- if (j >= buf.length) {
536
- if (buf.length - i <= MAX_MOUSE_REPORT_BYTES) break
537
- out.push({ key: { type: "ignore" }, width: MAX_MOUSE_REPORT_BYTES })
538
- i += MAX_MOUSE_REPORT_BYTES
550
+ while (
551
+ j < buf.length &&
552
+ j - i < MAX_CONTROL_SEQUENCE_BYTES &&
553
+ buf[j]! >= 0x20 &&
554
+ buf[j]! < 0x7f &&
555
+ buf[j] !== 0x4d &&
556
+ buf[j] !== 0x6d
557
+ ) {
558
+ j++
559
+ }
560
+ if (
561
+ j - i >= MAX_CONTROL_SEQUENCE_BYTES ||
562
+ (j < buf.length && (buf[j]! < 0x20 || buf[j]! >= 0x7f))
563
+ ) {
564
+ if (j - i >= MAX_CONTROL_SEQUENCE_BYTES) state.discard = "sgr"
565
+ out.push({ key: { type: "ignore" }, width: j - i })
566
+ i = j
539
567
  continue
540
568
  }
569
+ if (j >= buf.length) break
541
570
  const first = buf.indexOf(0x3b, i + 3)
542
571
  const second = first >= 0 ? buf.indexOf(0x3b, first + 1) : -1
543
572
  const valid =
@@ -561,11 +590,18 @@ export function decodeKeysStream(chunk: Uint8Array, state: DecoderState): Decode
561
590
  let j = i + 2
562
591
  while (
563
592
  j < buf.length &&
593
+ j - i < MAX_CONTROL_SEQUENCE_BYTES &&
564
594
  !isCsiFinal(buf[j]!) &&
565
595
  (isCsiParam(buf[j]!) || (buf[j]! >= 0x20 && buf[j]! <= 0x2f))
566
596
  ) {
567
597
  j++
568
598
  }
599
+ if (j - i >= MAX_CONTROL_SEQUENCE_BYTES) {
600
+ state.discard = "csi"
601
+ out.push({ key: { type: "ignore" }, width: j - i })
602
+ i = j
603
+ continue
604
+ }
569
605
  if (j < buf.length && isCsiFinal(buf[j]!)) {
570
606
  const seq = String.fromCharCode(...buf.slice(i, j + 1))
571
607
  const d = decodeKey(seq, 0)
@@ -573,14 +609,12 @@ export function decodeKeysStream(chunk: Uint8Array, state: DecoderState): Decode
573
609
  i = j + 1
574
610
  continue
575
611
  }
576
- if (j === i + 2) {
577
- // "ESC["/"ESC O" di ujung chunk = CSI belum lengkap (final di chunk
578
- // berikut), BUKAN Esc biasa. Tahan agar panah split tak jadi esc.
579
- // (ESC[ yang benar-benar lengkap selalu punya byte final dan sudah
580
- // ditangani di atas.)
581
- break
582
- }
583
- break // ada parameter tapi belum ada byte final — tahan
612
+ if (j === buf.length) break // Valid incomplete prefix: wait for the next chunk.
613
+ // Drop only the malformed prefix; decode the independent byte next
614
+ // (especially Ctrl+C, Enter, or ESC starting a fresh sequence).
615
+ out.push({ key: { type: "ignore" }, width: j - i })
616
+ i = j
617
+ continue
584
618
  }
585
619
  // ESC + byte lain: ESC tunggal (lengkap, tidak menunggu apa pun).
586
620
  out.push({ key: { type: "esc" }, width: 0 })
@@ -734,8 +768,6 @@ function parseDecimalBytes(bytes: number[], from: number, to: number): number |
734
768
  return value
735
769
  }
736
770
 
737
- const MAX_MOUSE_REPORT_BYTES = 64
738
-
739
771
  export function decodeKey(s: string, i: number): DecodedKey | null {
740
772
  const c = s[i]!
741
773
  const code = c.charCodeAt(0)
@@ -796,7 +828,7 @@ export function decodeKey(s: string, i: number): DecodedKey | null {
796
828
  // Dua varian sah: polos ESC[5~ (4 byte) dan bermodifier ESC[5;<m>~
797
829
  // (modifier bisa multi-digit: 2=shift, 5=ctrl, 3=alt, kombinasi >9
798
830
  // seperti 23). HANYA terminator '~' yang dianggap PgUp/PgDn — response
799
- // DSR kursor (ESC[5;34R) dsb. harus jatuh ke catch-all esc di bawah;
831
+ // DSR kursor (ESC[5;34R) dsb. harus jatuh ke catch-all ignore di bawah;
800
832
  // tanpa guard ini, response DSR baris-5/6 dibajak jadi pageup + residu
801
833
  // char bocor ke prompt (bug ditemukan audit typing, probe ESC[5;34R).
802
834
  // Width dihitung dari posisi terminator — width tetap 5 membuat sisa
@@ -816,14 +848,14 @@ export function decodeKey(s: string, i: number): DecodedKey | null {
816
848
  return { key: { type, modifier: mod }, width: j + 1 - i }
817
849
  }
818
850
  }
819
- // selain itu (ESC[5;34R, ESC[5x, …) → catch-all esc di bawah
851
+ // selain itu (ESC[5;34R, ESC[5x, …) → catch-all ignore di bawah
820
852
  }
821
853
  // Shift+Tab (backtab) ESC [ Z — dipakai TUI untuk toggle permission mode.
822
854
  // Tanpa cabang eksplisit ini ia jatuh ke catch-all "esc" di bawah,
823
855
  // sehingga tipe "shift-tab" tidak pernah dihasilkan decodeKeys.
824
856
  if (kind === "Z") return { key: { type: "shift-tab" }, width: 3 }
825
857
  // ESC [ … lainnya -> konsumsi saja
826
- return { key: { type: "esc" }, width: Math.max(3, scanCsi(s, i)) }
858
+ return { key: { type: "ignore" }, width: scanCsi(s, i) }
827
859
  }
828
860
  return { key: { type: "esc" }, width: 1 }
829
861
  }
@@ -858,8 +890,8 @@ export function decodeKey(s: string, i: number): DecodedKey | null {
858
890
  }
859
891
 
860
892
  function scanCsi(s: string, i: number): number {
861
- // konsumsi sampai huruf final (mis. ESC [ 1 ; 5 A)
893
+ // CSI finals include punctuation such as '~', not only letters.
862
894
  let j = i + 2
863
- while (j < s.length && !/[a-zA-Z]/.test(s[j]!)) j++
864
- return j - i + 1
895
+ while (j < s.length && !isCsiFinal(s.charCodeAt(j))) j++
896
+ return Math.min(j + 1, s.length) - i
865
897
  }
@@ -20,6 +20,14 @@ const GROUP_BY_TOOL: Readonly<Record<string, ActivityGroupKind>> = {
20
20
  lsp_diagnostics: "explore",
21
21
  lsp_symbols: "explore",
22
22
  lsp_workspace_symbols: "explore",
23
+ lsp_definition: "explore",
24
+ lsp_references: "explore",
25
+ lsp_hover: "explore",
26
+ todo_read: "explore",
27
+ todo_write: "edit",
28
+ bash_output: "execute",
29
+ bash_kill: "execute",
30
+ submit_result: "execute",
23
31
  // ── edit: mengubah file / working tree ──
24
32
  edit: "edit",
25
33
  apply_patch: "edit",
@@ -33,6 +41,7 @@ const GROUP_BY_TOOL: Readonly<Record<string, ActivityGroupKind>> = {
33
41
  git_diff: "execute",
34
42
  git_log: "execute",
35
43
  git_commit: "execute",
44
+ git_push: "execute",
36
45
  mcp_list: "execute",
37
46
  mcp_call: "execute",
38
47
  mcp_read: "execute",
@@ -21,6 +21,8 @@ export interface ActivityGroupView {
21
21
  failed: number
22
22
  running: number
23
23
  denied: number
24
+ cancelled: number
25
+ interrupted: number
24
26
  /** Nama tool pertama (indikator; sudah tersanitasi & terpotong). */
25
27
  names: string[]
26
28
  /** Total nama tool unik (sebelum dibatasi 3) untuk penanda `+N`. */
@@ -41,7 +43,18 @@ export function groupActivities(
41
43
  const kind = activityGroup(a.name)
42
44
  let g = groups.get(kind)
43
45
  if (!g) {
44
- g = { kind, count: 0, ok: 0, failed: 0, running: 0, denied: 0, names: [], nameTotal: 0 }
46
+ g = {
47
+ kind,
48
+ count: 0,
49
+ ok: 0,
50
+ failed: 0,
51
+ running: 0,
52
+ denied: 0,
53
+ cancelled: 0,
54
+ interrupted: 0,
55
+ names: [],
56
+ nameTotal: 0,
57
+ }
45
58
  groups.set(kind, g)
46
59
  uniqueNames.set(kind, new Set())
47
60
  }
@@ -51,6 +64,8 @@ export function groupActivities(
51
64
  else if (status === "failed") g.failed++
52
65
  else if (status === "running") g.running++
53
66
  else if (status === "denied") g.denied++
67
+ else if (status === "cancelled") g.cancelled++
68
+ else if (status === "interrupted") g.interrupted++
54
69
  // Nama tool dari model/provider = input tak-terpercaya: buang SEMUA ANSI
55
70
  // (termasuk SGR) saat masuk — styling ditambahkan renderer sendiri.
56
71
  const cleanName = stripSgr(sanitizeAnsiLine(a.name))
@@ -65,7 +80,7 @@ export function groupActivities(
65
80
  /** Warna grup: gagal → merah, ditolak → kuning, sisanya → redup (tenang). */
66
81
  function groupPaint(g: ActivityGroupView): (s: string) => string {
67
82
  if (g.failed > 0) return c.error
68
- if (g.denied > 0) return c.warning
83
+ if (g.denied > 0 || g.cancelled > 0 || g.interrupted > 0) return c.warning
69
84
  return c.muted
70
85
  }
71
86
 
@@ -84,6 +99,9 @@ export function groupLine(g: ActivityGroupView): string {
84
99
  if (g.ok > 0) parts.push(t("panel.ok", { n: g.ok }))
85
100
  if (g.failed > 0) parts.push(t("panel.failed", { n: g.failed }))
86
101
  if (g.running > 0) parts.push(t("panel.running", { n: g.running }))
102
+ if (g.denied > 0) parts.push(t("panel.denied", { n: g.denied }))
103
+ if (g.cancelled > 0) parts.push(t("panel.cancelled", { n: g.cancelled }))
104
+ if (g.interrupted > 0) parts.push(t("panel.interrupted", { n: g.interrupted }))
87
105
  const names = g.names.map((n) => sanitizeAnsiLine(n)).join(", ")
88
106
  const more = Math.max(0, g.nameTotal - g.names.length)
89
107
  if (names)
@@ -7,7 +7,7 @@
7
7
  // pemotongan lebar tetap di sisi pemanggil.
8
8
  import type { UiToolStatus } from "../contract.ts"
9
9
  import { t } from "../i18n/locale.ts"
10
- import { c, glyphs } from "./theme.ts"
10
+ import { c } from "./theme.ts"
11
11
 
12
12
  /** Kata status lokal ("completed"/"failed"/dst.) — fallback non-warna. */
13
13
  export function statusWord(status: UiToolStatus): string {
@@ -19,14 +19,6 @@ export function statusWord(status: UiToolStatus): string {
19
19
  return t("ts.statusRunning")
20
20
  }
21
21
 
22
- /** Glyph status (ASCII-aman via `glyphs`). */
23
- export function statusGlyph(status: UiToolStatus): string {
24
- if (status === "completed") return glyphs.check
25
- if (status === "failed") return glyphs.cross
26
- if (status === "denied") return glyphs.denied
27
- return glyphs.circle
28
- }
29
-
30
22
  /** Warna baris ledger berdasar status terminal (sukses/error/denied/lain). */
31
23
  export function paintLedger(status: UiToolStatus, line: string): string {
32
24
  if (status === "failed") return c.error(line)
@@ -84,8 +84,3 @@ export function renderLogoRows(): string[] {
84
84
  }
85
85
  return out
86
86
  }
87
-
88
- /** Jumlah baris hasil render (bukan tinggi grid logis). */
89
- export function renderLogoLineCount(): number {
90
- return supportsUtf8() ? Math.ceil(LOGO_HEIGHT / 2) : LOGO_HEIGHT
91
- }
@@ -294,9 +294,6 @@ export function parseMarkdownTable(
294
294
  return parseMarkdownBlocks(source).find((block) => block.type === "table")?.table ?? null
295
295
  }
296
296
 
297
- export const parsePipeTable = parseMarkdownTable
298
- export const parseMarkdownPipeTable = parseMarkdownTable
299
-
300
297
  export function parseMarkdownTables(input: string): MarkdownTable[] {
301
298
  return parseMarkdownBlocks(input)
302
299
  .filter((block): block is Extract<MarkdownBlock, { type: "table" }> => block.type === "table")
@@ -394,9 +394,6 @@ export function renderGridTable(table: GridTable, options: GridRenderOptions = {
394
394
  return [separator, header.join(" "), ...rows.map((row) => row.join(" "))].join("\n")
395
395
  }
396
396
 
397
- export const renderTableGrid = renderGridTable
398
- export const renderGrid = renderGridTable
399
-
400
397
  export function renderMarkdownTable(
401
398
  table: MarkdownTable,
402
399
  width = getTerminalWidth(),
@@ -47,12 +47,37 @@ function colorLevel(): number {
47
47
  // Determinisme Unix: output ke pipe/redirect/file tidak boleh memuat ANSI,
48
48
  // apa pun TERM/COLORTERM di env (env sesi interaktif sering bocor ke proses
49
49
  // yang di-pipe). Warna hanya untuk stdout yang benar-benar terminal.
50
- if (!process.stdout.isTTY) return 0
50
+ if (!process.stdout.isTTY || process.env.TERM?.toLowerCase() === "dumb") return 0
51
51
  if (hasTruecolorEnv()) return 3
52
52
  if (process.env.TERM?.includes("256color")) return 2
53
+ // Terminal/ConPTY sering tak mengisi TERM; env eksplisit di atas tetap menang.
54
+ try {
55
+ const depth = (
56
+ process.stdout as NodeJS.WriteStream & { getColorDepth?: () => number }
57
+ ).getColorDepth?.()
58
+ if (depth != null && depth >= 24) return 3
59
+ if (depth != null && depth >= 8) return 2
60
+ } catch {}
53
61
  return 1
54
62
  }
55
63
 
64
+ export type ScrimMode = "bg" | "faint" | "none"
65
+
66
+ /** Mode scrim (lazy); tak menambah byte di pipe. */
67
+ export function scrimMode(): ScrimMode {
68
+ if (noColorEnv() || !process.stdout.isTTY || process.env.TERM?.toLowerCase() === "dumb")
69
+ return "none"
70
+ if (process.env.MINICODE_SCRIM === "none") return "faint"
71
+ return colorLevel() >= 2 ? "bg" : colorLevel() === 1 ? "faint" : "none"
72
+ }
73
+
74
+ /** SGR pembuka scrim; pemanggil menjaga efek tetap hidup melewati reset konten. */
75
+ export function scrimSgr(mode: ScrimMode): string {
76
+ if (mode === "bg") return "\x1b[2;48;5;236m"
77
+ if (mode === "faint") return "\x1b[2m"
78
+ return ""
79
+ }
80
+
56
81
  /**
57
82
  * Kunci kapabilitas tampilan (level warna + glyph UTF-8) untuk cache render.
58
83
  *
@@ -364,13 +389,14 @@ export const glyphs = {
364
389
  // Fallback * untuk terminal tanpa UTF-8.
365
390
  return supportsUtf8() ? "✦" : "*"
366
391
  },
367
- // Gembok bash allow-list (footer): fallback teks agar status kapabilitas
368
- // tetap terbaca di terminal tanpa emoji (MINICODE_ASCII/legacy Windows).
392
+ // Badge bash allow-list (footer): titik monokrom, bukan emoji gembok —
393
+ // emoji berwarna dan lebarnya beda antar-font (kolom footer bergeser).
394
+ // ●/○ satu kolom dan tetap terbaca saat diwarnai; fallback teks ASCII.
369
395
  get lock() {
370
- return supportsUtf8() ? "🔒" : "[LOCK]"
396
+ return supportsUtf8() ? "●" : "[LOCK]"
371
397
  },
372
398
  get unlock() {
373
- return supportsUtf8() ? "🔓" : "[OPEN]"
399
+ return supportsUtf8() ? "○" : "[OPEN]"
374
400
  },
375
401
  }
376
402
 
@@ -10,6 +10,7 @@
10
10
  // Refcount menutup modal nested (effort-picker di dalam manager): tulis
11
11
  // enter/exit fisik hanya di lapis terluar; handle dalam = no-op paint-through.
12
12
  import { type Cell, diffCellLine, parseCells } from "../render/cells.ts"
13
+ import { truncateToWidth } from "../render/width.ts"
13
14
  import {
14
15
  __resetTransientForTest,
15
16
  beginInteractiveScreen,
@@ -252,7 +253,12 @@ export function openAltScreen(): AltScreen {
252
253
  const i = r - top
253
254
  // Baris diasumsi satu-baris-tersanitasi dari dialogBox (tanpa \n —
254
255
  // \n akan menggeser kursor dan merusak baris berikut; split defensif).
255
- const row = i >= 0 && i < h ? ((lines[i] ?? "").split("\n")[0] ?? "") : ""
256
+ // Clamp ke lebar layar: baris lebih lebar memicu auto-wrap dan
257
+ // menggeser seluruh region (AUD-009).
258
+ const row = truncateToWidth(
259
+ i >= 0 && i < h ? ((lines[i] ?? "").split("\n")[0] ?? "") : "",
260
+ this.cols,
261
+ )
256
262
  out += `\x1b[${r};1H\x1b[2K${row}`
257
263
  }
258
264
  out += SYNC_END