minicode-ai 0.10.0 → 0.11.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 (128) hide show
  1. package/AGENTS.md +45 -0
  2. package/CHANGELOG.md +59 -4
  3. package/PLAN.md +491 -0
  4. package/README.md +2 -2
  5. package/cli/commands/acp.ts +485 -0
  6. package/cli/commands/auth.ts +7 -4
  7. package/cli/commands/config.ts +41 -27
  8. package/cli/commands/exec.ts +33 -12
  9. package/cli/commands/mcp.ts +3 -2
  10. package/cli/commands/memory.ts +1 -1
  11. package/cli/commands/pricing.ts +6 -4
  12. package/cli/commands/providers.ts +18 -8
  13. package/cli/commands/sessions.ts +11 -4
  14. package/cli/commands/skills.ts +3 -3
  15. package/cli/commands/stats.ts +3 -1
  16. package/cli/commands.ts +6 -0
  17. package/cli/index.ts +82 -57
  18. package/cli/model-manager.ts +6 -1
  19. package/cli/router.ts +7 -0
  20. package/cli/setup.ts +341 -5
  21. package/cli/tui.ts +54 -18
  22. package/docs/ARCHITECTURE.html +29 -22
  23. package/docs/CONTROL-PLANE-MAP.md +139 -0
  24. package/docs/HARNESS.md +150 -0
  25. package/docs/PLAN_UIUX_V6.md +209 -0
  26. package/docs/README.md +1 -1
  27. package/docs/SUMMARY.md +52 -0
  28. package/docs/TERMINAL_CONTRACT.md +367 -0
  29. package/docs/UI_RENDER_PIPELINE.md +165 -0
  30. package/docs/USAGE.md +11 -0
  31. package/docs/agents.md +31 -0
  32. package/docs/architecture.md +3 -3
  33. package/docs/choosing-mode.md +34 -0
  34. package/docs/cli.md +130 -0
  35. package/docs/concepts.md +53 -0
  36. package/docs/config-providers.md +87 -0
  37. package/docs/config.md +63 -0
  38. package/docs/contributing.md +79 -0
  39. package/docs/environment.md +95 -0
  40. package/docs/exec.md +73 -0
  41. package/docs/getting-started.md +102 -0
  42. package/docs/glossary.md +37 -0
  43. package/docs/mcp-lsp.md +54 -0
  44. package/docs/memory-sessions.md +63 -0
  45. package/docs/policy-sandbox.md +72 -0
  46. package/docs/pricing-budget.md +49 -0
  47. package/docs/quickstart.md +60 -0
  48. package/docs/repl.md +67 -0
  49. package/docs/security-model.md +95 -0
  50. package/docs/security.md +91 -0
  51. package/docs/skills.md +48 -0
  52. package/docs/terminal.md +79 -0
  53. package/docs/tools.md +123 -0
  54. package/docs/troubleshooting.md +40 -0
  55. package/docs/verify-benchmark.md +58 -0
  56. package/package.json +8 -5
  57. package/src/app/provider-layer.ts +12 -4
  58. package/src/app/session.ts +6 -0
  59. package/src/app/tool-layer.ts +2 -1
  60. package/src/constants.ts +35 -0
  61. package/src/lib/net.ts +6 -1
  62. package/src/lsp/client.ts +41 -8
  63. package/src/mcp/http-transport.ts +52 -15
  64. package/src/mcp/transport.ts +32 -1
  65. package/src/memory/files.ts +6 -5
  66. package/src/policy/allowlist.ts +1 -1
  67. package/src/policy/bash-guard.ts +154 -14
  68. package/src/policy/compaction.ts +57 -3
  69. package/src/policy/context.ts +4 -0
  70. package/src/policy/jail.ts +49 -4
  71. package/src/policy/permission.ts +152 -12
  72. package/src/policy/pricing.ts +12 -9
  73. package/src/presentation/adapter.ts +721 -0
  74. package/src/presentation/events.ts +324 -0
  75. package/src/presentation/label.ts +140 -0
  76. package/src/presentation/model.ts +172 -0
  77. package/src/presentation/reducer.ts +486 -0
  78. package/src/presentation/store.ts +256 -0
  79. package/src/providers/anthropic.ts +22 -4
  80. package/src/providers/detect.ts +2 -1
  81. package/src/providers/router.ts +13 -0
  82. package/src/repo/repomap.ts +2 -29
  83. package/src/session/checkpoint.ts +27 -9
  84. package/src/session/journal.ts +27 -5
  85. package/src/skills/loader.ts +88 -5
  86. package/src/telemetry/trace.ts +36 -15
  87. package/src/tools/ask_user.ts +73 -4
  88. package/src/tools/bash.ts +15 -17
  89. package/src/tools/glob.ts +10 -11
  90. package/src/tools/lsp.ts +3 -56
  91. package/src/tools/memory.ts +13 -12
  92. package/src/tools/task.ts +1 -0
  93. package/src/ui/approval/prompt.ts +14 -6
  94. package/src/ui/assistant/simple.ts +137 -26
  95. package/src/ui/assistant/turn-status.ts +16 -3
  96. package/src/ui/contract.ts +119 -0
  97. package/src/ui/footer.ts +21 -2
  98. package/src/ui/i18n/en.ts +34 -6
  99. package/src/ui/i18n/id.ts +34 -6
  100. package/src/ui/i18n/locale.ts +3 -1
  101. package/src/ui/input/input.ts +51 -4
  102. package/src/ui/input/prompt-engine.ts +46 -4
  103. package/src/ui/render/collapse.ts +13 -13
  104. package/src/ui/render/diff.ts +7 -2
  105. package/src/ui/render/format.ts +16 -8
  106. package/src/ui/render/highlight.ts +7 -3
  107. package/src/ui/render/markdown.ts +5 -1
  108. package/src/ui/render/sanitize.ts +29 -2
  109. package/src/ui/render/table.ts +8 -5
  110. package/src/ui/render/theme.ts +18 -4
  111. package/src/ui/render/width.ts +89 -10
  112. package/src/ui/runtime/motion.ts +16 -0
  113. package/src/ui/runtime/screen.ts +45 -0
  114. package/src/ui/runtime/spinner.ts +50 -4
  115. package/src/ui/runtime/statusline.ts +50 -1
  116. package/src/ui/screens/form.ts +42 -15
  117. package/src/ui/screens/model-manager.ts +26 -18
  118. package/src/ui/screens/picker.ts +47 -23
  119. package/src/ui/screens/provider-manager.ts +18 -12
  120. package/src/ui/screens/wizard.ts +24 -8
  121. package/src/ui/tui/app.ts +233 -27
  122. package/src/ui/tui/transcript.ts +269 -65
  123. package/vendor/minicore/LICENSE +21 -0
  124. package/vendor/minicore/VENDOR.md +6 -3
  125. package/vendor/minicore/package.json +6 -3
  126. package/vendor/minicore/src/core/loop.ts +12 -2
  127. package/vendor/minicore/src/core/snapshot.ts +4 -0
  128. package/vendor/minicore/src/providers/openai-compat.ts +76 -25
@@ -3,12 +3,18 @@
3
3
  // inline dan EXPANDED by default (transparansi shell); mode compact via
4
4
  // MINICODE_COMPACT=1 atau setCompactMode (/compact).
5
5
  import { Buffer } from "node:buffer"
6
- import type { UiBus, UiStep } from "../contract.ts"
6
+ import type {
7
+ UiBus,
8
+ UiPresentationActivity,
9
+ UiPresentationEvent,
10
+ UiPresentationSnapshot,
11
+ UiStep,
12
+ } from "../contract.ts"
7
13
  import { t } from "../i18n/locale.ts"
8
14
  import {
9
- bufferSection,
15
+ clearCollapsedSections,
10
16
  collapse,
11
- resetBufferedSections,
17
+ rememberCollapsedSection,
12
18
  sectionMinimized,
13
19
  } from "../render/collapse.ts"
14
20
  import { detail } from "../render/detail.ts"
@@ -34,11 +40,13 @@ export interface SimpleOptions {
34
40
  verbose?: boolean
35
41
  /**
36
42
  * Mode senyap untuk TUI fullscreen: semua tulis ke stdout/stderr DITEKAN,
37
- * tapi state tetap jalan (rememberTurn untuk /copy, bufferSection untuk
43
+ * tapi state tetap jalan (rememberTurn untuk /copy, rememberCollapsedSection untuk
38
44
  * /expand, pendingError untuk driver). Tanpa ini printer linier mengotori
39
45
  * alt-screen di sela repaint App — kontrak I3 (App penulis tunggal layar).
40
46
  */
41
47
  quiet?: boolean
48
+ getSnapshot?: () => UiPresentationSnapshot | null
49
+ onPresentationEvent?: (handler: (event: UiPresentationEvent) => void) => () => void
42
50
  }
43
51
 
44
52
  // Buffer output turn terakhir untuk /copy: teks model (sudah sanitize, sama
@@ -120,7 +128,7 @@ function patchBlocks(patches: unknown): [string, string] {
120
128
 
121
129
  export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () => void {
122
130
  // Shadow module-level wOut/wErr: saat quiet, paint ditekan tapi SEMUA state
123
- // (rememberTurn, bufferSection, pendingError, sanitizer) tetap jalan.
131
+ // (rememberTurn, rememberCollapsedSection, pendingError, sanitizer) tetap jalan.
124
132
  // Shadowing disengaja agar ~20 call-site tak perlu diubah satu per satu.
125
133
  const wOut = opts.quiet ? (_: string) => {} : wOutDirect
126
134
  const wErr = opts.quiet ? (_: string) => {} : wErrDirect
@@ -203,7 +211,11 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
203
211
  }
204
212
 
205
213
  /** Label satu-baris ringkas per tool (bukan dump JSON argumen). */
206
- const toolSummary = (name: string, args: Record<string, unknown>, target?: string): string => {
214
+ const fallbackToolLabel = (
215
+ name: string,
216
+ args: Record<string, unknown>,
217
+ target?: string,
218
+ ): string => {
207
219
  if (name === "todo_write" || name === "todo_read") {
208
220
  const list = args.todos
209
221
  const n = Array.isArray(list) ? list.length : 0
@@ -242,7 +254,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
242
254
  // Petunjuk /expand WAJIB di baris ini: tanpa itu jawaban yang dikecilkan
243
255
  // terlihat "bisu" (tak ada cara membuka yang bisa ditemukan user).
244
256
  wErr(c.info(t("one.answerMin", { n, cap })))
245
- bufferSection("answer", answerBuf, "stdout")
257
+ rememberCollapsedSection("answer", answerBuf, "stdout")
246
258
  answerBuf = ""
247
259
  answerTruncated = false
248
260
  }
@@ -250,7 +262,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
250
262
  const flushThinking = () => {
251
263
  flushReasoningTail()
252
264
  if (thinkState === "min" && thinkingBuf) {
253
- bufferSection("thinking", thinkingBuf)
265
+ rememberCollapsedSection("thinking", thinkingBuf)
254
266
  thinkingBuf = ""
255
267
  }
256
268
  thinkState = "off"
@@ -284,7 +296,80 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
284
296
  streamBuffer = parts[parts.length - 1] ?? ""
285
297
  }
286
298
 
299
+ const presentationEnabled = !!opts.getSnapshot
300
+ const presentedTerminals = new Set<string>()
301
+ const presentationSnapshot = (): UiPresentationSnapshot | null => {
302
+ if (!presentationEnabled || !opts.getSnapshot) return null
303
+ try {
304
+ return opts.getSnapshot()
305
+ } catch {
306
+ return null
307
+ }
308
+ }
309
+ const presentationActivity = (toolCallId: string | undefined) => {
310
+ if (!toolCallId) return undefined
311
+ return presentationSnapshot()?.activities.find((activity) => activity.toolCallId === toolCallId)
312
+ }
313
+ const statusWord = (status: UiPresentationActivity["status"]): string => {
314
+ if (status === "completed") return t("ts.statusCompleted")
315
+ if (status === "failed") return t("ts.statusFailed")
316
+ if (status === "denied") return t("ts.statusDenied")
317
+ if (status === "cancelled") return t("ts.statusCancelled")
318
+ if (status === "interrupted") return t("ts.statusInterrupted")
319
+ return t("ts.statusRunning")
320
+ }
321
+ const linearSuffix = (activity: UiPresentationActivity | undefined): string => {
322
+ if (!activity) return ""
323
+ const parts: string[] = [statusWord(activity.status)]
324
+ if (activity.durationMs !== undefined)
325
+ parts.push(t("one.duration", { v: Math.max(0, Math.round(activity.durationMs)) }))
326
+ if (activity.denyReason)
327
+ parts.push(t("one.denyReason", { reason: sanitizeAnsiLine(activity.denyReason) }))
328
+ const paths = activity.receipt?.paths ?? []
329
+ if (paths.length > 0) {
330
+ const cleanPaths = paths
331
+ .map((path) => truncateToWidth(sanitizeAnsiLine(path), 80, ""))
332
+ .join(", ")
333
+ parts.push(t("one.receipt", { paths: cleanPaths }))
334
+ }
335
+ if (activity.supersedes) parts.push(t("ts.retry"))
336
+ return parts.length > 0 ? ` ${c.muted(`[${parts.join(" · ")}]`)}` : ""
337
+ }
338
+ const paintTerminal = (status: UiPresentationActivity["status"], line: string): string => {
339
+ if (status === "failed") return c.error(line)
340
+ if (status === "denied") return c.warning(line)
341
+ if (status === "completed") return c.success(line)
342
+ return c.muted(line)
343
+ }
344
+ const writePresentationTerminal = (event: UiPresentationEvent): void => {
345
+ if (!presentationEnabled) return
346
+ if (
347
+ event.type !== "tool.failed" &&
348
+ event.type !== "tool.denied" &&
349
+ event.type !== "tool.cancelled"
350
+ ) {
351
+ return
352
+ }
353
+ if (!event.toolCallId) return
354
+ if (presentedTerminals.has(event.toolCallId)) return
355
+ presentedTerminals.add(event.toolCallId)
356
+ const activity = presentationActivity(event.toolCallId)
357
+ const name = sanitizeAnsiLine(activity?.name ?? event.name ?? "tool")
358
+ const target = activity?.target ?? event.target
359
+ const targetText = target ? ` ${truncateToWidth(sanitizeAnsiLine(target), 120, "")}` : ""
360
+ const status = activity?.status ?? event.status ?? "failed"
361
+ const message = event.message ?? activity?.error?.message
362
+ const detail = message
363
+ ? `: ${truncateToWidth(sanitizeAnsi(String(message)), 200, "…").split("\n")[0] ?? ""}`
364
+ : ""
365
+ const line = ` ${glyphs.arrow} ${name}${targetText}${linearSuffix(activity)}${detail}`
366
+ wErr(paintTerminal(status, `${line}\n`))
367
+ }
368
+
287
369
  const offs: (() => void)[] = []
370
+ if (opts.onPresentationEvent) {
371
+ offs.push(opts.onPresentationEvent((event) => writePresentationTerminal(event)))
372
+ }
288
373
  offs.push(
289
374
  bus.on("turn:started", (e) => {
290
375
  // Turn baru: buffer turn sebelumnya dibuang (lihat /copy yang juga
@@ -294,10 +379,12 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
294
379
  reasoningLine = ""
295
380
  answerBuf = ""
296
381
  answerTruncated = false
297
- resetBufferedSections()
382
+ clearCollapsedSections()
298
383
  collapse.setActiveSection(null)
299
384
  lastTurnText = ""
300
385
  pendingError = null
386
+ presentedTerminals.clear()
387
+
301
388
  if (opts.verbose) wErr(c.muted(t("one.turnHead", { n: e.turn })))
302
389
  }),
303
390
  )
@@ -386,7 +473,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
386
473
  thinkingBuf += cleanUntrusted(reasoningSan.push(text), !!process.stdout.isTTY)
387
474
  if (thinkingBuf.length > THINKING_BUF_MAX) {
388
475
  // Total ber-marker dibatasi THINKING_BUF_MAX (= cap per-entry
389
- // bufferSection) agar tak ada pemotongan diam-diam kedua di hilir.
476
+ // rememberCollapsedSection) agar tak ada pemotongan diam-diam kedua di hilir.
390
477
  // Tail-slice jangan mulai di tengah surrogate pair: trail
391
478
  // yatim di awal tampil sebagai U+FFFD saat /expand.
392
479
  const body = thinkingBuf.startsWith(THINKING_TRUNCATED_MARKER)
@@ -458,20 +545,27 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
458
545
  )
459
546
  offs.push(
460
547
  bus.on("execution:completed", (e) => {
548
+ const callId = e.execution.call.id
549
+ const activity = presentationActivity(callId)
550
+ if (activity && activity.status !== "completed" && callId && presentedTerminals.has(callId)) {
551
+ return
552
+ }
461
553
  const r = e.execution.result
462
554
  const name = e.execution.call.name
463
555
  const args = (e.execution.call.args ?? {}) as Record<string, unknown>
556
+ const suffix = linearSuffix(activity)
557
+ const isError = activity ? activity.status !== "completed" : r.isError === true
464
558
  // Hasil string ikut ke buffer /copy (versi sanitize, cap per-add agar
465
559
  // satu read_file raksasa tak langsung memenuhi buffer sendirian).
466
- if (!r.isError && typeof r.content === "string")
560
+ if (!isError && typeof r.content === "string")
467
561
  rememberTurn(truncateToWidth(sanitizeAnsi(r.content), 20000, ""))
468
- if (r.isError) {
562
+ if (isError) {
469
563
  // Error tool ditampilkan ringkas per baris (cap 200 kolom + marker) —
470
564
  // tanpa marker user tak bisa bedakan "pesan 200 kolom" vs "terpotong".
471
565
  collapse.setActiveSection(null)
472
566
  wErr(
473
567
  c.error(
474
- ` ${glyphs.arrow} ${sanitizeAnsiLine(name)}: ${truncateToWidth(sanitizeAnsi(String(r.content)), 200, "…")}\n`,
568
+ ` ${glyphs.arrow} ${sanitizeAnsiLine(name)}${suffix}: ${truncateToWidth(sanitizeAnsi(String(r.content)), 200, "…")}\n`,
475
569
  ),
476
570
  )
477
571
  return
@@ -482,9 +576,11 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
482
576
  // pencetakan isi (bash/edit/diff/content tool), bukan marker.
483
577
  if (sectionMinimized("tool")) {
484
578
  collapse.setActiveSection(null)
485
- const label = toolSummary(name, args, target)
486
- wErr(c.info(` + ${label}\n`))
487
- bufferSection(label, sanitizeAnsi(String(r.content ?? "")).trim())
579
+ const label = activity?.summary
580
+ ? sanitizeAnsiLine(activity.summary)
581
+ : fallbackToolLabel(name, args, target)
582
+ wErr(c.info(` + ${label}${suffix}\n`))
583
+ rememberCollapsedSection(label, sanitizeAnsi(String(r.content ?? "")).trim())
488
584
  return
489
585
  }
490
586
  if (name === "write_file" && target) {
@@ -494,7 +590,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
494
590
  const cleanTarget = sanitizeAnsiLine(target)
495
591
  wOut(
496
592
  c.success(
497
- ` ${glyphs.arrow} write_file ${cleanTarget}${size ? c.muted(` (${size})`) : ""}\n`,
593
+ ` ${glyphs.arrow} write_file ${cleanTarget}${size ? c.muted(` (${size})`) : ""}${suffix}\n`,
498
594
  ),
499
595
  )
500
596
  return
@@ -514,7 +610,11 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
514
610
  )
515
611
  return
516
612
  }
517
- wOut(c.success(` ${glyphs.arrow} ${sanitizeAnsiLine(name)} ${sanitizeAnsiLine(target)}\n`))
613
+ wOut(
614
+ c.success(
615
+ ` ${glyphs.arrow} ${sanitizeAnsiLine(name)} ${sanitizeAnsiLine(target)}${suffix}\n`,
616
+ ),
617
+ )
518
618
  return
519
619
  }
520
620
  // todo_write: tampilkan daftarnya utuh — ini rencana kerja, bukan noise.
@@ -523,7 +623,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
523
623
  // lain agar ESC[2J/OSC tak lolos via label.
524
624
  const cleanName = sanitizeAnsiLine(name)
525
625
  wErr(
526
- c.success(` ${glyphs.arrow} ${cleanName}\n`) +
626
+ c.success(` ${glyphs.arrow} ${cleanName}${suffix}\n`) +
527
627
  c.muted(`${sanitizeAnsi(String(r.content))}\n`),
528
628
  )
529
629
  return
@@ -540,7 +640,9 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
540
640
  lines.length > 3
541
641
  ? lines.slice(0, 3).join("\n ") + c.muted(t("one.more3", { n: lines.length - 3 }))
542
642
  : lines.join("\n ")
543
- wErr(c.success(` ${glyphs.arrow} $ ${cmdLabel}\n`) + c.muted(` ${preview}\n`))
643
+ wErr(
644
+ c.success(` ${glyphs.arrow} $ ${cmdLabel}${suffix}\n`) + c.muted(` ${preview}\n`),
645
+ )
544
646
  return
545
647
  }
546
648
  const maxLines = TOOL_OUT_MAX_LINES()
@@ -548,7 +650,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
548
650
  const more =
549
651
  lines.length > maxLines ? c.muted(t("one.moreLines", { n: lines.length - maxLines })) : ""
550
652
  wErr(
551
- c.success(` ${glyphs.arrow} $ ${cmdLabel}\n`) +
653
+ c.success(` ${glyphs.arrow} $ ${cmdLabel}${suffix}\n`) +
552
654
  (shown.length ? `${c.muted(shown.join("\n")) + more}\n` : ""),
553
655
  )
554
656
  return
@@ -557,8 +659,15 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
557
659
  // satu baris › + target — isinya milik model untuk dibaca, bukan untuk
558
660
  // membanjiri scrollback pengguna. Konten tetap bisa dilihat via expanded.
559
661
  if (detail.compact && CONTENT_TOOLS.has(name)) {
560
- const label = truncateWords(sanitizeAnsiLine(target ?? formatArgsPreview(args)), 120)
561
- wErr(c.success(` ${glyphs.arrow} ${sanitizeAnsiLine(name)}${label ? ` ${label}` : ""}\n`))
662
+ const label = activity?.summary
663
+ ? sanitizeAnsiLine(activity.summary)
664
+ : truncateWords(sanitizeAnsiLine(target ?? formatArgsPreview(args)), 120)
665
+
666
+ wErr(
667
+ c.success(
668
+ ` ${glyphs.arrow} ${sanitizeAnsiLine(name)}${label ? ` ${label}` : ""}${suffix}\n`,
669
+ ),
670
+ )
562
671
  return
563
672
  }
564
673
  if (!detail.compact && CONTENT_TOOLS.has(name)) {
@@ -583,19 +692,21 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
583
692
  }
584
693
  // Sisa tool (compact & expanded): satu baris › + label. WAJIB diakhiri
585
694
  // newline — tanpa itu baris berikutnya menempel (overlap di stderr log).
586
- const label = truncateWords(sanitizeAnsiLine(target ?? formatArgsPreview(args)), 120)
695
+ const label = activity?.summary
696
+ ? sanitizeAnsiLine(activity.summary)
697
+ : truncateWords(sanitizeAnsiLine(target ?? formatArgsPreview(args)), 120)
587
698
  const first = sanitizeAnsi(String(r.content)).trim().split("\n")[0] ?? ""
588
699
  const preview = truncateToWidth(first, 80, "")
589
700
  const cleanName = sanitizeAnsiLine(name)
590
701
  if (!detail.compact && preview) {
591
702
  wErr(
592
703
  c.success(
593
- ` ${glyphs.arrow} ${cleanName}${label ? ` ${label}` : ""} ${c.muted(preview)}\n`,
704
+ ` ${glyphs.arrow} ${cleanName}${label ? ` ${label}` : ""}${suffix} ${c.muted(preview)}\n`,
594
705
  ),
595
706
  )
596
707
  return
597
708
  }
598
- wErr(c.success(` ${glyphs.arrow} ${cleanName}${label ? ` ${label}` : ""}\n`))
709
+ wErr(c.success(` ${glyphs.arrow} ${cleanName}${label ? ` ${label}` : ""}${suffix}\n`))
599
710
  }),
600
711
  )
601
712
  offs.push(
@@ -95,6 +95,7 @@ export function attachTurnStatus(
95
95
  // Interval animasi mengikuti — cepat bila model berpikir cepat.
96
96
  let intervalMs = 150
97
97
  let lastReasoningMs: number | null = null
98
+ let toolStartMs: number | null = null
98
99
  const recentDeltas: number[] = []
99
100
  // Kepemilikan transient stderr selama interval hidup — lihat statusline.ts.
100
101
  let owned: { release(): void } | null = null
@@ -124,10 +125,17 @@ export function attachTurnStatus(
124
125
  // Sinyal "alive" (spark pulse) kini MILIK FOOTER, bukan thinking line:
125
126
  // satu sumber agar tak ada dua denyut. Thinking = titik saja; tool line
126
127
  // tetap pakai spinner braille (itu progres, bukan spark).
128
+ let elapsedText = ""
129
+ if (label !== "Thinking" && toolStartMs !== null) {
130
+ const elapsed = Date.now() - toolStartMs
131
+ if (elapsed >= 2000) {
132
+ elapsedText = ` ${c.faint(`(${formatElapsed(elapsed)})`)}`
133
+ }
134
+ }
127
135
  const body =
128
136
  label === "Thinking"
129
137
  ? `${dots}`
130
- : `${c.info(glyphs.spinnerFrames[fi % glyphs.spinnerFrames.length]!)} ${label} ${dots}`
138
+ : `${c.info(glyphs.spinnerFrames[fi % glyphs.spinnerFrames.length]!)} ${label} ${dots}${elapsedText}`
131
139
  const full = body + extra
132
140
  // Terminal sangat sempit: potongan label bisa tinggal 1 huruf ("t") —
133
141
  // dalam kasus itu tampilkan titiknya saja daripada label rusak.
@@ -189,6 +197,7 @@ export function attachTurnStatus(
189
197
  turnOn = false
190
198
  textOn = false
191
199
  textSeen = false
200
+ toolStartMs = null
192
201
  label = "Thinking"
193
202
  intervalMs = 150
194
203
  lastReasoningMs = null
@@ -214,7 +223,9 @@ export function attachTurnStatus(
214
223
  }
215
224
  registerStatusLine(handle)
216
225
 
217
- const toolLabel = (e: { execution: { call: { name: string; args?: unknown } } }): string => {
226
+ const statusToolLabel = (e: {
227
+ execution: { call: { name: string; args?: unknown } }
228
+ }): string => {
218
229
  const name = e.execution.call.name
219
230
  const args = (e.execution.call.args ?? {}) as Record<string, unknown>
220
231
  let target = ""
@@ -291,10 +302,12 @@ export function attachTurnStatus(
291
302
  // Fase kerja baru: latch teks dibuka lagi (thinking antar-tool tampil).
292
303
  textOn = false
293
304
  textSeen = false
294
- startPaint(toolLabel(e))
305
+ toolStartMs = Date.now()
306
+ startPaint(statusToolLabel(e))
295
307
  }),
296
308
  bus.on("execution:completed", () => {
297
309
  // Tool selesai: kembali ke "Thinking" selama model belum mengeluarkan teks.
310
+ toolStartMs = null
298
311
  textSeen = false
299
312
  if (shouldPaint()) startPaint("Thinking")
300
313
  }),
@@ -11,13 +11,29 @@
11
11
  // menyerahkan bus kernel apa adanya tanpa adapter runtime.
12
12
 
13
13
  export interface UiToolCallRef {
14
+ /**
15
+ * toolCallId dari provider (ToolCall.id) — diaditif Fase 2 Presentasi V2.1.
16
+ * Opsional agar subscriber lama yang hanya butuh name/args tidak rusak;
17
+ * kernel selalu mengisi ini (snapshotToolCall), cast `as unknown` di
18
+ * cli/tui.ts tidak lagi buta terhadap identitas.
19
+ */
20
+ id?: string
14
21
  name: string
15
22
  args?: unknown
16
23
  }
17
24
 
25
+ /** Hasil tool ringkas di step (Fase 2) — bukan payload penuh ToolResult. */
26
+ export interface UiStepResultRef {
27
+ toolCallId?: string
28
+ isError?: boolean
29
+ content?: unknown
30
+ }
31
+
18
32
  export interface UiStep {
19
33
  index: number
20
34
  toolCalls: readonly UiToolCallRef[]
35
+ /** Opsional: ringkas results (kernel step:completed membawa ini penuh). */
36
+ results?: readonly UiStepResultRef[]
21
37
  }
22
38
 
23
39
  export interface UiExecution {
@@ -53,3 +69,106 @@ export type UiEventType = UiEvent["type"]
53
69
  export interface UiBus {
54
70
  on(type: UiEventType, handler: (event: any) => void): () => void
55
71
  }
72
+
73
+ export type UiToolStatus =
74
+ | "running"
75
+ | "completed"
76
+ | "failed"
77
+ | "denied"
78
+ | "cancelled"
79
+ | "interrupted"
80
+
81
+ export interface UiTurnSummary {
82
+ toolsOk: number
83
+ toolsFailed: number
84
+ toolsDenied: number
85
+ toolsCancelled: number
86
+ toolsInterrupted: number
87
+ filesChanged: number
88
+ checkpointId?: string
89
+ durationMs: number
90
+ }
91
+
92
+ export interface UiPresentationError {
93
+ cause?: string
94
+ message: string
95
+ hint?: string
96
+ }
97
+
98
+ export interface UiPresentationReceipt {
99
+ paths?: string[]
100
+ checkpointId?: string
101
+ stats?: { added?: number; removed?: number }
102
+ test?: { passed: number; failed: number; summary: string }
103
+ cmd?: { exit?: number }
104
+ }
105
+
106
+ export interface UiPresentationActivity {
107
+ seq?: number
108
+ turnId?: number
109
+ sessionId?: string
110
+ toolCallId: string
111
+ name: string
112
+ qualified?: string
113
+ target?: string
114
+ status: UiToolStatus
115
+ tsStart: number
116
+ tsEnd?: number
117
+ durationMs?: number
118
+ summary?: string
119
+ error?: UiPresentationError
120
+ denyReason?: string
121
+ receipt?: UiPresentationReceipt
122
+ parentToolCallId?: string
123
+ supersedes?: string
124
+ expandRef?: { toolCallId: string; idx: number }
125
+ }
126
+
127
+ export interface UiPresentationTurn {
128
+ turnId: number
129
+ status: "running" | "completed" | "failed" | "cancelled" | "interrupted"
130
+ summary?: UiTurnSummary
131
+ }
132
+
133
+ export interface UiPresentationSnapshot {
134
+ activities: UiPresentationActivity[]
135
+ turns: UiPresentationTurn[]
136
+ }
137
+
138
+ export interface UiApprovalOutcome {
139
+ decision: "allow" | "allow-always" | "deny" | "cancelled"
140
+ by: "user" | "system"
141
+ reason?: string
142
+ }
143
+
144
+ export interface UiPresentationEvent {
145
+ type:
146
+ | "turn.started"
147
+ | "turn.completed"
148
+ | "turn.failed"
149
+ | "turn.cancelled"
150
+ | "tool.started"
151
+ | "tool.completed"
152
+ | "tool.failed"
153
+ | "tool.denied"
154
+ | "tool.cancelled"
155
+ | "approval.requested"
156
+ | "approval.settled"
157
+ seq?: number
158
+ turnId?: number
159
+ toolCallId?: string
160
+ approvalId?: string
161
+ name?: string
162
+ qualified?: string
163
+ target?: string
164
+ status?: UiToolStatus
165
+ tsStart?: number
166
+ durationMs?: number
167
+ message?: string
168
+ cause?: string
169
+ reason?: string
170
+ error?: string
171
+ outcome?: UiApprovalOutcome
172
+ via?: "prompt" | "system"
173
+ summary?: UiTurnSummary
174
+ }
package/src/ui/footer.ts CHANGED
@@ -59,6 +59,22 @@ function sparkGlyph(frame: number): string {
59
59
  return frame % 2 === 0 ? c.white(g) : c.gray(g)
60
60
  }
61
61
 
62
+ /**
63
+ * Perpendek path agar muat di terminal sedang tanpa membuang CWD sepenuhnya.
64
+ * Mis. "D:\git\minicode\src\ui" -> "...\src\ui"
65
+ * atau "/home/user/projects/minicode/src" -> ".../minicode/src"
66
+ */
67
+ export function shortenPath(p: string, maxSegments = 2): string {
68
+ if (!p) return ""
69
+ const isWin = p.includes("\\")
70
+ const sep = isWin ? "\\" : "/"
71
+ const clean = p.replace(/[\\/]+$/, "")
72
+ const parts = clean.split(/[\\/]+/).filter(Boolean)
73
+ if (parts.length <= maxSegments) return clean
74
+ const tail = parts.slice(-maxSegments).join(sep)
75
+ return `...${sep}${tail}`
76
+ }
77
+
62
78
  /**
63
79
  * Render 1 baris footer untuk lebar `columns` (+ 1 baris kosong di atasnya
64
80
  * bila dilukis lengket). Tanpa garis separator — clean (keputusan user).
@@ -76,8 +92,10 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
76
92
  // \n = 0 sehingga align mengira muat).
77
93
  const model = c.gray(sanitizeAnsiLine(shortModel(s.model)))
78
94
  const cwdTxt = c.gray(sanitizeAnsiLine(s.cwd))
95
+ const shortCwdTxt = c.gray(sanitizeAnsiLine(shortenPath(s.cwd)))
79
96
 
80
97
  const full = `${spark} ${mode}${sep}${model}${sep}${cwdTxt}`
98
+ const shortened = `${spark} ${mode}${sep}${model}${sep}${shortCwdTxt}`
81
99
  const mid = `${spark} ${mode}${sep}${model}`
82
100
  const lean = `${spark} ${mode}`
83
101
 
@@ -97,8 +115,9 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
97
115
  return `${left}${" ".repeat(gap)}${c.gray(ctx)}`
98
116
  }
99
117
 
100
- // Tangga prioritas buang saat sempit: cwd → model (spark+mode+context kekal).
101
- for (const left of [full, mid, lean]) {
118
+ // Tangga prioritas buang saat sempit: cwd penuh → cwd diperpendek → model (spark+mode+context kekal).
119
+ const candidates = shortCwdTxt !== cwdTxt ? [full, shortened, mid, lean] : [full, mid, lean]
120
+ for (const left of candidates) {
102
121
  const line = align(left)
103
122
  if (displayWidth(line) <= target) return [line]
104
123
  }
package/src/ui/i18n/en.ts CHANGED
@@ -6,8 +6,14 @@ export const en = {
6
6
  "app.menuHeader": "─ commands ─",
7
7
  "app.moreLines": " … {n} more",
8
8
  "app.newBelow": "↓ {n} new lines below · PgDn to bottom",
9
+ "app.abortHint": "abort sent — press Esc/Ctrl+C again to quit",
10
+ "form.idleWarning": "idle — canceling in {s}s (press any key to keep editing)",
9
11
  "appr.title": "Approval required",
10
12
  "appr.tool": "Tool:",
13
+ "appr.cmdLabel": "Command:",
14
+ "appr.fileLabel": "File:",
15
+ "appr.queryLabel": "Query:",
16
+ "appr.argsLabel": "Args:",
11
17
  "appr.allowOnce": "[y] Allow once",
12
18
  "appr.always": "[a] Always",
13
19
  "appr.deny": "[n] Deny",
@@ -20,7 +26,18 @@ export const en = {
20
26
  "dlg.more": "… {n} more",
21
27
  "ts.compacted": "… compacted: {reason}",
22
28
  "ts.thinking": "… thinking",
23
- "form.footerDefault": "Tab move · Enter save · Esc cancel",
29
+ "ts.evictMarker": "… {n} early lines outside viewport — full history in model",
30
+ "ts.statusRunning": "running",
31
+ "ts.statusCompleted": "completed",
32
+ "ts.statusFailed": "failed",
33
+ "ts.statusDenied": "denied",
34
+ "ts.statusCancelled": "cancelled",
35
+ "ts.statusInterrupted": "interrupted",
36
+ "ts.retry": "↻ retry",
37
+ "ts.childGroup": "{n} child tools",
38
+ "ts.turnSummary":
39
+ "turn {turn} · {ok} ok · {failed} failed · {denied} denied · {cancelled} cancelled · {interrupted} interrupted · {files} files · ckpt {ckpt} · {secs}",
40
+ "form.footerDefault": "Tab:{move} · Enter:{save} · Esc:{cancel}",
24
41
  "form.required": "required",
25
42
  "form.invalidUrl": "invalid URL",
26
43
  "form.httpOnly": "must be http(s)",
@@ -35,7 +52,7 @@ export const en = {
35
52
  "pick.placeholder": "type to filter",
36
53
  "pick.noMatch": 'No matches for "{q}"',
37
54
  "pick.matches": "{n}/{total} matches",
38
- "pick.hint": "type to filter · ↑↓ select · Enter confirm · Esc back",
55
+ "pick.hint": "↑↓:{select} · Enter:{confirm} · Esc:{back}",
39
56
  "pick.fail": "picker failed: {msg}",
40
57
  "pick.failOpen": "picker failed to open: {msg}",
41
58
  "model.empty": "No models configured",
@@ -51,7 +68,7 @@ export const en = {
51
68
  "effort.saved": "Thinking: {effort} (next session)",
52
69
  "prov.title": "Providers",
53
70
  "prov.empty": "No providers",
54
- "prov.hint": "Enter:{select} a:{add} d:{delete} e:{edit} Esc:{close}",
71
+ "prov.hint": "Enter:{select} · a:{add} · d:{delete} · e:{edit} · Esc:{close}",
55
72
  "prov.addTitle": "Add provider",
56
73
  "prov.customUrl": "Custom URL",
57
74
  "prov.editTitle": 'Edit "{id}"',
@@ -75,7 +92,9 @@ export const en = {
75
92
  "sess.listHead": "Sessions",
76
93
  "sess.listHint": " Select a session to resume.",
77
94
  "sess.notFound": 'Session "{id}" not found or empty.',
78
- "wiz.gateway": "Minicode setup — Select gateway",
95
+ "wiz.gateway": "Minicode setup [1/3] — Select gateway",
96
+ "wiz.stepUrl": "Minicode setup [2/3] — Base URL",
97
+ "wiz.stepKey": "Minicode setup [3/3] — API key",
79
98
  "wiz.title": "Minicode setup",
80
99
  "wiz.urlLabel": "Base URL",
81
100
  "wiz.keyLabel": "API key for {url}",
@@ -99,6 +118,7 @@ export const en = {
99
118
  "st.provider": " Provider: {v}",
100
119
  "st.tools": " Tools: {v}",
101
120
  "st.context": " Context: ~{v} tok (window estimate)",
121
+ "st.turn": " Turn: {v} (last turn only)",
102
122
  "st.input": " Input: {v} (provider usage)",
103
123
  "st.output": " Output: {v} (provider usage)",
104
124
  "st.total": " Total: {v} (session cumulative)",
@@ -106,7 +126,7 @@ export const en = {
106
126
  "st.budget": " Budget: {v}{extra}",
107
127
  "st.costUnknown": " (cost unknown — model without pricing)",
108
128
  "help.head": "Commands:",
109
- "help.keysLine": "Enter · Tab/Shift+Tab mode · Ctrl+R search · PgUp/PgDn scroll · Ctrl+D exit",
129
+ "help.keysLine": "PgUp/PgDn scroll (Shift = half) · /help keys = all shortcuts",
110
130
  "help.cHead": "Commands:",
111
131
  "help.cKeys": "Keys: Tab mode · ↑↓ history · PgUp/PgDn scroll · Ctrl+R search · Ctrl+D exit",
112
132
  "help.cMore": " /help keys = all shortcuts",
@@ -114,7 +134,8 @@ export const en = {
114
134
  "help.k.submit": "submit",
115
135
  "help.k.cycleMode": "cycle permission mode",
116
136
  "help.k.history": "prompt history (in picker: navigate)",
117
- "help.k.scroll": "scroll transcript",
137
+ "help.k.scroll": "scroll transcript (Shift+ = half page)",
138
+ "help.k.jumpTop": "jump to transcript top / back to tail (empty prompt only)",
118
139
  "help.k.move": "move cursor",
119
140
  "help.k.jump": "jump to line start / end",
120
141
  "help.k.delChar": "delete character at cursor",
@@ -165,6 +186,10 @@ export const en = {
165
186
  "tui.didYou": " Did you mean /{hint}?",
166
187
  "tui.tryHelp": " Try /help.",
167
188
  "tui.expandEmpty": "(nothing to expand — all sections were visible)",
189
+ "tui.expandContent": "content",
190
+ "tui.expandRetention":
191
+ "(content outside retention — see .minicode/step-traces.jsonl / session sqlite)",
192
+ "tui.expandDurable": "durable",
168
193
  "tui.historyEmpty": "(empty history)",
169
194
  "tui.langUnknown": "unknown lang: {a} — choices: en, id",
170
195
  "tui.noTty": "Terminal does not support fullscreen TUI — interactive needs a TTY with ≥10 rows.",
@@ -191,6 +216,9 @@ export const en = {
191
216
  "one.thinkMin": " + thinking\n",
192
217
  "one.more3": "\n ... ({n} more)",
193
218
  "one.moreLines": "\n … ({n} more lines)",
219
+ "one.duration": "{v}ms",
220
+ "one.denyReason": "deny:{reason}",
221
+ "one.receipt": "receipt {paths}",
194
222
  "one.contentBlocked": "\n! Content filter blocked\n",
195
223
  "one.step": " Step {i}: {calls}\n",
196
224
  "hl.moreLines": " ... ({n} more lines)",