minicode-ai 0.26.0 → 0.28.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 (139) hide show
  1. package/cli/args.ts +120 -16
  2. package/cli/commands/acp.ts +38 -28
  3. package/cli/commands/auth.ts +17 -17
  4. package/cli/commands/config.ts +65 -66
  5. package/cli/commands/daemon.ts +44 -16
  6. package/cli/commands/doctor.ts +11 -12
  7. package/cli/commands/exec.ts +35 -73
  8. package/cli/commands/mcp.ts +25 -8
  9. package/cli/commands/memory.ts +16 -24
  10. package/cli/commands/openwork.ts +6 -2
  11. package/cli/commands/pricing.ts +14 -12
  12. package/cli/commands/providers.ts +36 -57
  13. package/cli/commands/sessions.ts +24 -18
  14. package/cli/commands/skills.ts +33 -18
  15. package/cli/commands/stats.ts +15 -30
  16. package/cli/commands.ts +96 -46
  17. package/cli/context-command-run.ts +171 -0
  18. package/cli/context-command.ts +87 -0
  19. package/cli/index.ts +96 -98
  20. package/cli/model-manager.ts +7 -2
  21. package/cli/provider-manager.ts +33 -18
  22. package/cli/router.ts +41 -12
  23. package/cli/setup.ts +246 -123
  24. package/cli/tui.ts +311 -109
  25. package/docs/TERMINAL_CONTRACT.md +254 -69
  26. package/docs/UI_RENDER_PIPELINE.md +9 -1
  27. package/docs/agents.md +2 -2
  28. package/docs/architecture.md +3 -3
  29. package/docs/choosing-mode.md +7 -9
  30. package/docs/cli.md +3 -5
  31. package/docs/config.md +16 -0
  32. package/docs/environment.md +3 -3
  33. package/docs/policy-sandbox.md +3 -3
  34. package/docs/repl.md +3 -2
  35. package/docs/tools.md +1 -1
  36. package/package.json +1 -1
  37. package/src/app/mentions.ts +60 -13
  38. package/src/app/rag-layer.ts +17 -20
  39. package/src/app/session.ts +119 -66
  40. package/src/app/tool-layer.ts +12 -17
  41. package/src/config.ts +64 -104
  42. package/src/constants.ts +23 -9
  43. package/src/daemon/capability.ts +8 -1
  44. package/src/daemon/control.ts +3 -2
  45. package/src/daemon/server.ts +57 -0
  46. package/src/hooks/run.ts +73 -41
  47. package/src/lib/db-path.ts +47 -0
  48. package/src/lib/process-tree.ts +62 -0
  49. package/src/lib/public-http.ts +88 -23
  50. package/src/lib/trusted-exec.ts +48 -1
  51. package/src/lsp/client.ts +62 -17
  52. package/src/mcp/client.ts +85 -38
  53. package/src/mcp/http-transport.ts +28 -16
  54. package/src/mcp/transport.ts +42 -6
  55. package/src/memory/files.ts +164 -134
  56. package/src/memory/vector.ts +371 -420
  57. package/src/policy/approval-binding.ts +122 -45
  58. package/src/policy/bash-guard.ts +18 -7
  59. package/src/policy/compaction.ts +51 -18
  60. package/src/policy/context-window.ts +109 -0
  61. package/src/policy/context.ts +78 -37
  62. package/src/policy/executor.ts +17 -7
  63. package/src/policy/microcompact.ts +4 -3
  64. package/src/policy/no-progress.ts +103 -22
  65. package/src/policy/permission.ts +36 -12
  66. package/src/policy/tool-contract.ts +74 -416
  67. package/src/policy/usage.ts +24 -2
  68. package/src/policy/verifier.ts +50 -2
  69. package/src/policy/work-mode.ts +28 -54
  70. package/src/presentation/adapter.ts +24 -16
  71. package/src/providers/guards.ts +41 -2
  72. package/src/providers/provision.ts +6 -60
  73. package/src/providers/responses.ts +1 -0
  74. package/src/repo/repomap.ts +180 -23
  75. package/src/runtime/execution-journal.ts +4 -29
  76. package/src/sandbox/docker.ts +58 -34
  77. package/src/sandbox/mask.ts +157 -0
  78. package/src/sandbox/os.ts +107 -73
  79. package/src/session/authority.ts +29 -10
  80. package/src/session/context-projection.ts +6 -5
  81. package/src/session/open-work.ts +26 -3
  82. package/src/session/persistence.ts +25 -58
  83. package/src/session/verification.ts +170 -20
  84. package/src/skills/loader.ts +31 -16
  85. package/src/task/production-scheduler.ts +13 -1
  86. package/src/task/store.ts +20 -37
  87. package/src/telemetry/trace.ts +27 -0
  88. package/src/tools/ask_user.ts +1 -13
  89. package/src/tools/bash.ts +27 -92
  90. package/src/tools/code_run.ts +1 -1
  91. package/src/tools/context.ts +133 -0
  92. package/src/tools/delete_file.ts +3 -2
  93. package/src/tools/edit.ts +37 -72
  94. package/src/tools/git.ts +86 -9
  95. package/src/tools/glob.ts +26 -51
  96. package/src/tools/grep.ts +67 -57
  97. package/src/tools/hashline.ts +4 -0
  98. package/src/tools/lsp.ts +11 -8
  99. package/src/tools/mcp_call.ts +9 -6
  100. package/src/tools/memory.ts +56 -33
  101. package/src/tools/move_file.ts +36 -10
  102. package/src/tools/patch.ts +13 -21
  103. package/src/tools/read_file.ts +18 -25
  104. package/src/tools/read_image.ts +35 -33
  105. package/src/tools/submit_result.ts +29 -8
  106. package/src/tools/task.ts +74 -17
  107. package/src/tools/todo.ts +181 -74
  108. package/src/tools/web_fetch.ts +42 -2
  109. package/src/tools/web_search.ts +47 -8
  110. package/src/ui/approval/prompt.ts +206 -47
  111. package/src/ui/assistant/turn-status.ts +14 -5
  112. package/src/ui/footer.ts +4 -4
  113. package/src/ui/i18n/en.ts +59 -23
  114. package/src/ui/i18n/id.ts +88 -51
  115. package/src/ui/input/input.ts +4 -3
  116. package/src/ui/input/prompt-engine.ts +35 -5
  117. package/src/ui/render/activity-panel.ts +4 -2
  118. package/src/ui/render/hint.ts +7 -4
  119. package/src/ui/render/list.ts +32 -0
  120. package/src/ui/render/markdown.ts +6 -3
  121. package/src/ui/render/notice.ts +19 -0
  122. package/src/ui/render/table-grid.ts +7 -8
  123. package/src/ui/render/theme.ts +113 -39
  124. package/src/ui/runtime/screen.ts +74 -10
  125. package/src/ui/runtime/spinner.ts +19 -6
  126. package/src/ui/screens/dialog.ts +19 -1
  127. package/src/ui/screens/form.ts +80 -35
  128. package/src/ui/screens/model-manager.ts +88 -62
  129. package/src/ui/screens/output-window.ts +263 -0
  130. package/src/ui/screens/picker.ts +94 -81
  131. package/src/ui/screens/provider-manager.ts +100 -69
  132. package/src/ui/screens/wizard.ts +117 -28
  133. package/src/ui/tui/app.ts +196 -33
  134. package/src/ui/tui/transcript.ts +154 -25
  135. package/vendor/minicore/src/core/executor.ts +2 -0
  136. package/vendor/minicore/src/core/loop.ts +17 -6
  137. package/vendor/minicore/src/core/session.ts +3 -0
  138. package/vendor/minicore/src/core/tool.ts +1 -0
  139. package/vendor/minicore/src/providers/openai-compat.ts +28 -19
@@ -10,11 +10,21 @@
10
10
 
11
11
  import { t } from "../i18n/locale.ts"
12
12
  import { askLine } from "../input/input.ts"
13
- import { createDecoderState, createKeyStreamPump } from "../input/prompt-engine.ts"
13
+ import {
14
+ applyKey,
15
+ createDecoderState,
16
+ createKeyStreamPump,
17
+ createState,
18
+ type PromptState,
19
+ toGraphemes,
20
+ } from "../input/prompt-engine.ts"
21
+ import { hintLine } from "../render/hint.ts"
22
+ import { listRow } from "../render/list.ts"
14
23
  import { sanitizeAnsiLine } from "../render/sanitize.ts"
15
- import { c, glyphs } from "../render/theme.ts"
16
- import { truncateToWidth } from "../render/width.ts"
17
- import { dialogBox, popupBoxWidth } from "../screens/dialog.ts"
24
+ import { c, glyphs, stripAnsi } from "../render/theme.ts"
25
+ import { displayWidth, truncateToWidth } from "../render/width.ts"
26
+ import { boxLeftPad, canRenderModal, dialogBox, popupBoxWidth } from "../screens/dialog.ts"
27
+ import { IDLE_CANCEL_MS, IDLE_WARN_MS } from "../screens/form.ts"
18
28
  import { createIdleTimer } from "../screens/lifecycle.ts"
19
29
  import { type ApprovalSink, getApprovalSink } from "../tui/transcript.ts"
20
30
 
@@ -62,6 +72,48 @@ function tierLabel(riskTier?: string): string | undefined {
62
72
  /** Keputusan approval. */
63
73
  type Decision = "allow" | "always" | "deny"
64
74
 
75
+ interface ModalRenderState {
76
+ sel: number
77
+ typed: string
78
+ cursor: number
79
+ warned: boolean
80
+ }
81
+
82
+ type ModalCursor =
83
+ | { kind: "choice"; selected: number }
84
+ | { kind: "line"; typed: string; cursor: number }
85
+
86
+ /**
87
+ * Potong jendela teks 1-baris mengikuti posisi kursor agar teks ketik panjang
88
+ * di promptAskText tetap terlihat dan kursor tidak keluar border kotak.
89
+ */
90
+ function windowLineInput(
91
+ typed: string,
92
+ cursor: number,
93
+ maxCols: number,
94
+ ): { visible: string; cursorOffsetCols: number } {
95
+ const safe = sanitizeAnsiLine(typed)
96
+ const pts = toGraphemes(safe)
97
+ const safeCursor = Math.max(0, Math.min(cursor, pts.length))
98
+ const budget = Math.max(6, maxCols)
99
+ let start = 0
100
+ while (start < safeCursor && displayWidth(pts.slice(start, safeCursor).join("")) > budget - 1) {
101
+ start++
102
+ }
103
+ const out: string[] = []
104
+ let w = 0
105
+ for (let i = start; i < pts.length; i++) {
106
+ const gw = displayWidth(pts[i] ?? "")
107
+ if (w + gw > budget) break
108
+ out.push(pts[i]!)
109
+ w += gw
110
+ }
111
+ return {
112
+ visible: out.join(""),
113
+ cursorOffsetCols: displayWidth(pts.slice(start, safeCursor).join("")),
114
+ }
115
+ }
116
+
65
117
  /**
66
118
  * Baca satu jawaban dari kotak modal. `line` = teks bebas; `choice` = daftar
67
119
  * dengan `↑↓`/home/end + Enter (I25) dan ketik-cepat huruf pertama (AUD-005).
@@ -69,7 +121,7 @@ type Decision = "allow" | "always" | "deny"
69
121
  */
70
122
  function readModalInput<T extends "line" | "choice">(
71
123
  mode: T,
72
- render: (state: { sel: number; typed: string }) => void,
124
+ render: (state: ModalRenderState) => void,
73
125
  opt: T extends "choice" ? { count: number; quick: Readonly<Record<string, number>> } : object,
74
126
  ): Promise<T extends "choice" ? number | null : string | null> {
75
127
  type R = T extends "choice" ? number | null : string | null
@@ -79,47 +131,85 @@ function readModalInput<T extends "line" | "choice">(
79
131
  const quick = o.quick ?? {}
80
132
  let done = false
81
133
  let sel = 0
82
- let typed = ""
134
+ let lineState: PromptState = createState()
135
+ let warned = false
83
136
  let onData!: (chunk: Buffer) => void
137
+ let onResize!: () => void
138
+ const redraw = () => {
139
+ try {
140
+ render({ sel, typed: lineState.line, cursor: lineState.cursor, warned })
141
+ } catch {}
142
+ }
84
143
  const pump = createKeyStreamPump({
85
144
  state: createDecoderState(),
86
145
  onKeys: (keys) => {
146
+ let changed = false
87
147
  for (const k of keys) {
88
148
  const key = k.key
89
- if (key.type === "enter") {
90
- finish((mode === "choice" ? sel : typed) as R)
149
+ if (key.type === "esc" || key.type === "ctrl-c" || key.type === "ctrl-d") {
150
+ finish(null as R)
91
151
  return true
92
152
  }
93
- if (key.type === "esc" || key.type === "ctrl-c") {
94
- finish(null as R)
153
+ // Layar menyusut di bawah ambang aman: cegah setujui/submit membuta;
154
+ // hanya Esc/Ctrl+C/Ctrl+D di atas yang keluar aman sampai dibesarkan.
155
+ if (!canRenderModal()) continue
156
+ if (key.type === "enter") {
157
+ finish((mode === "choice" ? sel : lineState.line) as R)
95
158
  return true
96
159
  }
97
160
  if (mode === "choice") {
98
- if (key.type === "up") sel = Math.max(0, sel - 1)
99
- else if (key.type === "down") sel = Math.min(count - 1, sel + 1)
100
- else if (key.type === "home") sel = 0
101
- else if (key.type === "end") sel = count - 1
102
- else if (key.type === "char") {
103
- // Ketik-cepat: huruf cocok langsung submit.
161
+ if (key.type === "up" || key.type === "wheelup") {
162
+ sel = Math.max(0, sel - 1)
163
+ changed = true
164
+ } else if (key.type === "down" || key.type === "wheeldown") {
165
+ sel = Math.min(count - 1, sel + 1)
166
+ changed = true
167
+ } else if (key.type === "home") {
168
+ sel = 0
169
+ changed = true
170
+ } else if (key.type === "end") {
171
+ sel = count - 1
172
+ changed = true
173
+ } else if (key.type === "char") {
174
+ // Ketik-cepat: huruf cocok langsung submit. Indeks -1 = sinonim
175
+ // tanpa opsi (mis. `s` saat Always disembunyikan) — abaikan,
176
+ // JANGAN menutup modal sebagai deny.
104
177
  const hit = quick[key.ch.toLowerCase()]
105
- if (hit != null && hit < count) {
178
+ if (hit != null && hit >= 0 && hit < count) {
106
179
  finish(hit as R)
107
180
  return true
108
181
  }
109
182
  }
110
- } else if (key.type === "char") typed += key.ch
111
- else if (key.type === "backspace") typed = typed.slice(0, -1)
183
+ } else {
184
+ if (key.type === "mouse" || key.type === "wheelup" || key.type === "wheeldown") {
185
+ continue
186
+ }
187
+ const safeKey =
188
+ key.type === "char"
189
+ ? { type: "char" as const, ch: key.ch.replace(/[\r\n]/g, " ") }
190
+ : key
191
+ const next = applyKey(lineState, safeKey, () => [])
192
+ if (next.action !== "none" || next.state !== lineState) {
193
+ lineState = next.state
194
+ changed = true
195
+ }
196
+ }
197
+ }
198
+ if (changed) {
199
+ warned = false
200
+ idle.reset()
201
+ redraw()
112
202
  }
113
- idle.reset()
114
- try {
115
- render({ sel, typed })
116
- } catch {}
117
203
  return false
118
204
  },
119
205
  })
120
206
  const idle = createIdleTimer({
121
- warnMs: 80_000,
122
- cancelMs: 10_000,
207
+ warnMs: IDLE_WARN_MS,
208
+ cancelMs: IDLE_CANCEL_MS,
209
+ onWarn: () => {
210
+ warned = true
211
+ redraw()
212
+ },
123
213
  onCancel: () => finish(null as R),
124
214
  })
125
215
  const finish = (v: R) => {
@@ -132,44 +222,88 @@ function readModalInput<T extends "line" | "choice">(
132
222
  try {
133
223
  process.stdin.removeListener("data", onData)
134
224
  } catch {}
225
+ try {
226
+ process.stdout.removeListener("resize", onResize)
227
+ } catch {}
135
228
  try {
136
229
  process.stdin.setRawMode(false)
137
230
  } catch {}
138
231
  resolve(v)
139
232
  }
140
233
  onData = (chunk: Buffer) => pump.push(new Uint8Array(chunk))
234
+ onResize = () => redraw()
141
235
  try {
142
236
  process.stdin.setRawMode(true)
143
237
  } catch {}
144
238
  process.stdin.on("data", onData)
145
- try {
146
- render({ sel: 0, typed: "" })
147
- } catch {}
239
+ process.stdout.on("resize", onResize)
240
+ // Timer HARUS mulai saat modal dibuka — bukan menunggu keypress pertama.
241
+ // Tanpa ini raw-mode bisa digenggam selamanya bila ConPTY berhenti mengirim
242
+ // input (kelas hang yang sama dengan picker/manager).
243
+ idle.reset()
244
+ redraw()
148
245
  })
149
246
  }
150
247
 
151
- /** Render kotak modal + baris ekstra (echo / daftar bersorot). */
248
+ /** Render kotak modal + baris ekstra (echo / daftar bersorot) + parkir kursor. */
152
249
  function paintModal(
153
250
  sink: ApprovalSink,
154
251
  spec: { title: string; body: string[]; footer?: string },
155
252
  extra: readonly string[],
253
+ cursor?: ModalCursor,
156
254
  ): void {
157
255
  if (!sink.paintRegion) return
158
256
  const cols = process.stdout.columns || 80
257
+ const rows = process.stdout.rows || 24
258
+ if (!canRenderModal(cols, rows)) {
259
+ sink.paintRegion([c.warning(truncateToWidth(t("tui.tooSmall"), Math.max(1, cols)))], 1)
260
+ return
261
+ }
262
+ const safeRows = Math.max(5, rows)
159
263
  // Lebar popup SERAGAM (AUD-007): dulu selebar layar, melanggar I20.
160
264
  const boxW = popupBoxWidth(cols)
265
+ const innerW = Math.max(10, Math.min(boxW - 4, Math.max(20, cols) - 6))
266
+ let modalExtra = extra
267
+ let lineCursorOffset = 0
268
+ if (cursor?.kind === "line") {
269
+ const win = windowLineInput(cursor.typed, cursor.cursor, innerW - 4)
270
+ modalExtra = [` ${c.dim(">")} ${c.info(win.visible)}`]
271
+ lineCursorOffset = win.cursorOffsetCols
272
+ }
273
+ const focusRow =
274
+ cursor?.kind === "choice"
275
+ ? spec.body.length + 1 + cursor.selected
276
+ : cursor?.kind === "line"
277
+ ? spec.body.length
278
+ : undefined
161
279
  const box = dialogBox(
162
280
  {
163
281
  title: spec.title,
164
- body: [...spec.body, ...extra],
282
+ body: [...spec.body, ...modalExtra],
165
283
  footer: spec.footer,
166
284
  minWidth: boxW,
167
285
  maxWidth: boxW,
286
+ ...(focusRow != null ? { focusRow } : {}),
168
287
  },
169
288
  Math.max(20, cols),
170
- Math.max(5, process.stdout.rows || 24),
289
+ safeRows,
171
290
  )
172
291
  sink.paintRegion(box.lines, box.topRow)
292
+ if (!cursor) return
293
+ const focus = cursor.kind === "choice" ? focusRow! : spec.body.length
294
+ const visible = focus - box.bodyStart
295
+ if (visible < 0 || box.bodyTop + visible >= box.lines.length) return
296
+ const row = box.topRow + box.bodyTop + visible
297
+ const stripped = stripAnsi(box.lines[box.bodyTop + visible] ?? "")
298
+ const leftPad = boxLeftPad(stripped)
299
+ let col = leftPad + 3
300
+ if (cursor.kind === "line") {
301
+ const maxCol = leftPad + 2 + innerW + 1
302
+ col = Math.min(maxCol, leftPad + 7 + lineCursorOffset)
303
+ }
304
+ try {
305
+ sink.moveCursor?.(row, Math.max(1, Math.min(cols, col)))
306
+ } catch {}
173
307
  }
174
308
 
175
309
  export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny" | "always"> {
@@ -192,7 +326,7 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
192
326
  // Sanitasi DULU, potong SESUDAH: `slice` mentah bisa membelah surrogate pair
193
327
  // dan memotong sekuens ANSI di tengah (audit 2026-11-12, MEDIUM-1).
194
328
  const summarize = (value: unknown, max: number): string =>
195
- truncateToWidth(sanitizeAnsiLine(String(value)), max, "…")
329
+ truncateToWidth(sanitizeAnsiLine(String(value)), max, glyphs.ellipsis)
196
330
  let actionSummary = ""
197
331
  if (args.command) actionSummary = `${t("appr.cmdLabel")} ${summarize(args.command, 100)}`
198
332
  else if (args.path) actionSummary = `${t("appr.fileLabel")} ${summarize(args.path, 100)}`
@@ -240,7 +374,12 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
240
374
  quickMap.s = choices.findIndex((ch) => ch.value === "always")
241
375
  quickMap.t = choices.findIndex((ch) => ch.value === "deny")
242
376
 
243
- const choiceHint = t("appr.keyHint")
377
+ const choiceHint = hintLine([
378
+ { key: glyphs.upDown, label: t("hint.move") },
379
+ { key: "Enter", label: t("hint.select") },
380
+ { key: "Esc", label: t("hint.cancel") },
381
+ ])
382
+ const idleHint = c.error(t("form.idleWarning", { s: Math.ceil(IDLE_CANCEL_MS / 1000) }))
244
383
  let pickedIndex: number | null = null
245
384
  if (sink) {
246
385
  sink.pushBlock(block)
@@ -249,14 +388,18 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
249
388
  try {
250
389
  pickedIndex = await readModalInput(
251
390
  "choice",
252
- ({ sel }) => {
253
- const rendered = choices.map((ch, i) =>
254
- i === sel ? ` ${c.accent(`${glyphs.check} ${ch.label}`)}` : ` ${c.dim(ch.label)}`,
391
+ ({ sel, warned }) => {
392
+ const rendered = choices.map((ch, i) => listRow(ch.label, i === sel))
393
+ paintModal(
394
+ sink,
395
+ {
396
+ title: t("appr.title"),
397
+ body: modalBody,
398
+ footer: warned ? idleHint : choiceHint,
399
+ },
400
+ ["", ...rendered],
401
+ { kind: "choice", selected: sel },
255
402
  )
256
- paintModal(sink, { title: t("appr.title"), body: modalBody, footer: choiceHint }, [
257
- "",
258
- ...rendered,
259
- ])
260
403
  },
261
404
  { count: choices.length, quick: quickMap },
262
405
  )
@@ -287,7 +430,7 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
287
430
  // Keputusan dicatat di transkrip (jejak audit); warisan mengandalkan
288
431
  // scrollback askLine yang terhapus repaint.
289
432
  if (sink) {
290
- sink.pushBlock([c.muted(` → ${decision}`)])
433
+ sink.pushBlock([c.muted(` ${glyphs.arrow} ${decision}`)])
291
434
  sink.repaint()
292
435
  }
293
436
  return decisionKey === "appr.decAlways"
@@ -308,12 +451,17 @@ export async function promptAskText(question: string, options?: string[]): Promi
308
451
  if (!textSink && !process.stdout.isTTY) return null
309
452
  // Potong SESUDAH sanitasi lewat truncateToWidth (bukan `slice`): `slice`
310
453
  // bisa menyisakan `\x1b[` menggantung di ekor potongan.
311
- const q = truncateToWidth(sanitizeAnsiLine(question), 2000, "…")
454
+ const q = truncateToWidth(sanitizeAnsiLine(question), 2000, glyphs.ellipsis)
312
455
  const optionLines = options?.length
313
456
  ? options.map((o, i) => ` ${c.dim(`${i + 1}.`)} ${sanitizeAnsiLine(o)}`)
314
457
  : []
315
458
  const block = [``, `${c.warning(c.bold(t("appr.askTitle")))}`, ` ${q}`, ...optionLines]
316
459
  const modalBody = [` ${q}`, ...optionLines]
460
+ const lineHint = hintLine([
461
+ { key: "Enter", label: t("hint.submit") },
462
+ { key: "Esc", label: t("hint.cancel") },
463
+ ])
464
+ const idleHint = c.error(t("form.idleWarning", { s: Math.ceil(IDLE_CANCEL_MS / 1000) }))
317
465
  const sink = textSink
318
466
  let ans: string | null = null
319
467
  if (sink) {
@@ -323,10 +471,17 @@ export async function promptAskText(question: string, options?: string[]): Promi
323
471
  try {
324
472
  ans = await readModalInput(
325
473
  "line",
326
- ({ typed }) =>
327
- paintModal(sink, { title: t("appr.askTitle"), body: modalBody }, [
328
- ` ${c.dim(">")} ${c.info(sanitizeAnsiLine(typed))}`,
329
- ]),
474
+ ({ typed, cursor, warned }) =>
475
+ paintModal(
476
+ sink,
477
+ {
478
+ title: t("appr.askTitle"),
479
+ body: modalBody,
480
+ footer: warned ? idleHint : lineHint,
481
+ },
482
+ [],
483
+ { kind: "line", typed, cursor },
484
+ ),
330
485
  {},
331
486
  )
332
487
  } finally {
@@ -348,7 +503,11 @@ export async function promptAskText(question: string, options?: string[]): Promi
348
503
  if (sink) {
349
504
  // Gema jawaban juga dipotong lewat truncateToWidth: `slice` bisa membelah
350
505
  // surrogate pair (emoji → U+FFFD) atau menyisakan escape menggantung.
351
- sink.pushBlock([c.muted(` → ${truncateToWidth(sanitizeAnsiLine(finalAnswer), 200, "…")}`)])
506
+ sink.pushBlock([
507
+ c.muted(
508
+ ` ${glyphs.arrow} ${truncateToWidth(sanitizeAnsiLine(finalAnswer), 200, glyphs.ellipsis)}`,
509
+ ),
510
+ ])
352
511
  sink.repaint()
353
512
  }
354
513
  return finalAnswer
@@ -31,11 +31,16 @@ import { acquireTransientPaint, paintWrite, registerStatusLine } from "../runtim
31
31
  // Kursor disembunyikan selama garis melukis agar tak terbaca sebagai bagian
32
32
  // indikator (pola spinner.ts). Didaftarkan sekali per proses — aman
33
33
  // dipanggil berulang karena tiap attach me-restore di stopPaint/endTurn.
34
- process.on("exit", () => {
35
- try {
36
- if (process.stderr.isTTY) process.stderr.write("\x1b[?25h")
37
- } catch {}
38
- })
34
+ let exitHookInstalled = false
35
+ function installExitHook(): void {
36
+ if (exitHookInstalled) return
37
+ exitHookInstalled = true
38
+ process.on("exit", () => {
39
+ try {
40
+ if (process.stderr.isTTY) process.stderr.write("\x1b[?25h")
41
+ } catch {}
42
+ })
43
+ }
39
44
 
40
45
  export interface TurnStatusHandle {
41
46
  detach(): void
@@ -192,11 +197,15 @@ export function attachTurnStatus(
192
197
  })
193
198
  // Sembunyikan kursor selama melukis agar tak terbaca sebagai bagian
194
199
  // indikator ("✦···|"); dikembalikan di stopPaint.
200
+ installExitHook()
195
201
  try {
196
202
  paintWrite("\x1b[?25l")
197
203
  } catch {}
198
204
  paint()
199
205
  intervalId = setInterval(paint, intervalMs)
206
+ try {
207
+ ;(intervalId as unknown as { unref?: () => void }).unref?.()
208
+ } catch {}
200
209
  } else paint()
201
210
  }
202
211
  const resetTurn = () => {
package/src/ui/footer.ts CHANGED
@@ -70,7 +70,6 @@ function workModeValue(workMode?: string): string {
70
70
  const normalized = (workMode || "DISCUSS").toUpperCase()
71
71
  if (normalized === "EXECUTE" || normalized === "BUILD") return "Build"
72
72
  if (normalized === "DISCUSS") return "Discuss"
73
- if (normalized === "PLAN") return "Plan"
74
73
  return titleCaseMode(workMode ?? "", "Build")
75
74
  }
76
75
 
@@ -82,7 +81,8 @@ export function paintWorkMode(workMode?: string, _style: ModeLabelStyle = "full"
82
81
  const value = workModeValue(workMode)
83
82
  const normalized = sanitizeAnsiLine(workMode || "DISCUSS").toUpperCase()
84
83
  const labelWidth = displayWidth(sanitizeAnsiLine(value))
85
- const colorValue = normalized === "DISCUSS" || normalized === "PLAN" ? c.warning : c.success
84
+ // Discuss = default sesi baru (biru aksen), Build = eksekusi penuh (hijau).
85
+ const colorValue = normalized === "DISCUSS" ? c.accent : c.success
86
86
  return `${colorValue(value)}${" ".repeat(Math.max(0, WORK_MODE_VALUE_WIDTH - labelWidth))}`
87
87
  }
88
88
 
@@ -304,11 +304,11 @@ function buildFooterLine(s: FooterStatus, cols: number): string {
304
304
  const baseWidth = displayWidth(modeOnly)
305
305
  const contextBudget = target - baseWidth - 2
306
306
  if (contextBudget > 0) {
307
- const shortenedContext = truncateToWidth(context, contextBudget, "…")
307
+ const shortenedContext = truncateToWidth(context, contextBudget, glyphs.ellipsis)
308
308
  const withContext = `${spark} ${shortWorkValue} ${c.gray(shortenedContext)} ${[permissionValue, strictValue].filter(Boolean).join(" ")}`
309
309
  if (displayWidth(withContext) <= target) return withContext
310
310
  }
311
311
  }
312
312
  if (displayWidth(modeOnly) <= target) return modeOnly
313
- return truncateToWidth(modeOnly, target, "…")
313
+ return truncateToWidth(modeOnly, target, glyphs.ellipsis)
314
314
  }
package/src/ui/i18n/en.ts CHANGED
@@ -2,13 +2,11 @@
2
2
  // memuat kunci yang sama persis — tsc yang mengawal (Record<MsgKey, string>).
3
3
  // Nilai memakai interpolasi `{nama}` sederhana (lihat t()).
4
4
  export const en = {
5
- "app.placeholder": "ask anything, / for commands… (Ctrl+D exits)",
6
5
  "app.newBelow": "↓ {n} new lines below · PgDn to bottom",
7
6
  "app.abortHint": "abort sent — press Esc again to quit",
8
- "app.working": "Working",
9
- "app.thinking": "Thinking",
10
- "app.running": "Running",
11
- "app.stopping": "Stopping",
7
+ "app.welcomeTitle": "minicode {dot} {model}",
8
+ "app.welcomeCwd": "{cwd}",
9
+ "app.welcomeHints": "Tab mode {dot} Shift+Tab permission {dot} / menu {dot} Ctrl+R history",
12
10
  "tui.selectionCopied": "selection copied to clipboard",
13
11
  "tui.selectionCopyFailed": "selection could not be copied (OSC 52 unavailable)",
14
12
  "tui.selectionTooLarge": "selection too large to copy",
@@ -25,11 +23,10 @@ export const en = {
25
23
  "appr.decAllow": "allow",
26
24
  "appr.decAlways": "always",
27
25
  "appr.decDeny": "deny",
28
- "appr.keyHint": "↑↓ move · Enter pick · Esc cancel",
29
26
  "appr.askTitle": "Agent asks",
30
27
  "appr.a11y": "[approval required: {name}]",
31
28
  "appr.answerPrompt": "Your answer (empty = cancel): ",
32
- "appr.risk": "Risk:",
29
+ "appr.risk": "Effect:",
33
30
  "appr.diff": "Diff:",
34
31
  "appr.tier.pure": "read-only",
35
32
  "appr.tier.workspace": "workspace edit",
@@ -57,29 +54,23 @@ export const en = {
57
54
  "ts.childGroup": "{n} child tools",
58
55
  "ts.turnSummary":
59
56
  "turn {turn} · {ok} ok · {failed} failed · {denied} denied · {cancelled} cancelled · {interrupted} interrupted · {files} files · ckpt {ckpt} · {secs}",
60
- "form.footerDefault": "Tab:{move} · Enter:{save} · Esc:{cancel}",
61
57
  "form.required": "required",
62
58
  "form.invalidUrl": "invalid URL",
63
59
  "form.httpOnly": "must be http(s)",
64
60
  "form.yes": "Yes",
65
61
  "form.no": "No",
66
- "verb.select": "select",
67
- "verb.add": "add",
68
- "verb.delete": "delete",
69
- "verb.edit": "edit",
70
- "verb.close": "close",
71
62
  "pick.noMatch": 'No matches for "{q}"',
72
63
  "pick.fail": "picker failed: {msg}",
73
64
  "pick.failOpen": "picker failed to open: {msg}",
74
65
  "model.empty": "No models configured",
75
66
  "model.noMatch": "No models match",
76
67
  "model.deleteTitle": "Delete model",
77
- "model.deleteFooter": "←/→/y/n select · Enter delete · Esc cancel",
78
68
  "model.delActive": 'Delete ACTIVE model "{id}"?',
79
69
  "model.del": 'Delete model "{id}"?',
80
70
  "model.failOpen": "model manager failed to open: {msg}",
81
71
  "effort.title": "Thinking effort",
82
72
  "effort.saved": "Thinking effort: {effort} (next session)",
73
+ "effort.noThinking": "this model has no thinking effort — nothing to set",
83
74
  "prov.empty": "No providers",
84
75
  "prov.addTitle": "Add provider",
85
76
  "prov.customUrl": "Custom URL",
@@ -93,7 +84,6 @@ export const en = {
93
84
  "prov.deleteLabel": '"{id}" ({n} models)',
94
85
  "prov.deleteActive": " — active ({model})",
95
86
  "prov.deleteAsk": " — delete?",
96
- "prov.deleteFooter": "←/→/y/n select · Enter delete · Esc cancel",
97
87
  "prov.failOpen": "provider manager failed to open: {msg}",
98
88
  "prov.reloadFail": "provider reload failed — restart to apply changes",
99
89
  "prov.detectFail": "Model detection failed: {msg}",
@@ -112,7 +102,7 @@ export const en = {
112
102
  "wiz.detecting": "Detecting models…",
113
103
  "wiz.done": "Setup complete.",
114
104
  "wiz.detectFail": "Model detection failed: {msg}",
115
- "wiz.canceled": "Setup canceled.",
105
+ "wiz.canceled": "Setup cancelled.",
116
106
  "wiz.keyLater": "Setup canceled. Set OPENAI_API_KEY later to continue.",
117
107
  "ntc.deleted": "deleted {id}",
118
108
  "ntc.saved": '"{id}" saved ({n} models, {scope}).',
@@ -131,6 +121,17 @@ export const en = {
131
121
  "st.workMode": " WorkMode: {v} (intent layer)",
132
122
  "st.permissionMode": " Permission: {v} (allow/deny authority)",
133
123
  "st.context": " Context: ~{v} tok (window estimate)",
124
+ "help.desc.context": "Show or set the context window",
125
+ "ctx.title": "Context window",
126
+ "ctx.colModel": "Model",
127
+ "ctx.colWindow": "Window",
128
+ "ctx.colOrigin": "Origin",
129
+ "ctx.empty": "no models configured — add a provider first",
130
+ "ctx.pickTitle": "Context window — effective {label} ({origin})",
131
+ "ctx.saved": "saved: {label} ({tokens} tokens) for the next turn",
132
+ "ctx.savedAuto": "back to automatic detection",
133
+ "ctx.saveFailed": "could not save the window: {msg}",
134
+ "ctx.usage": " /context <128k|1m|1024x1024|auto> -> set for the active model",
134
135
  "st.turn": " Turn: {v} (last turn only)",
135
136
  "st.input": " Input: {v} (provider usage)",
136
137
  "st.output": " Output: {v} (provider usage)",
@@ -143,12 +144,22 @@ export const en = {
143
144
  "help.keysLine": "Mouse wheel/PgUp/PgDn scroll (Shift = half) · /help keys = all shortcuts",
144
145
  "hint.move": "move",
145
146
  "hint.select": "select",
146
- "hint.close": "close",
147
- "hint.filter": "filter",
147
+ "hint.save": "save",
148
+ "hint.cancel": "cancel",
149
+ "hint.submit": "submit",
150
+ "hint.back": "back",
151
+ "hint.clear": "clear",
152
+ "hint.scroll": "scroll",
148
153
  "hint.delete": "delete",
149
154
  "hint.edit": "edit",
150
155
  "hint.add": "add",
151
156
  "hint.effort": "effort",
157
+ "hint.copy": "copy",
158
+ "hint.close": "close",
159
+ "state.compact": "compact",
160
+ "state.expanded": "expanded",
161
+ "state.minimized": "minimized",
162
+ "state.folded": "folded",
152
163
  "help.cHead": "Commands:",
153
164
  "help.cKeys":
154
165
  "Keys: Tab work-mode · Shift+Tab permission · ↑↓ history · Mouse wheel/PgUp/PgDn scroll · Ctrl+R search · Ctrl+D exit",
@@ -161,8 +172,7 @@ export const en = {
161
172
  "help.gTask": "Task",
162
173
  "help.kHead": "Keyboard:",
163
174
  "help.k.submit": "submit",
164
- "help.k.cycleMode": "cycle work mode",
165
- "help.k.workMode": "cycle work mode (Build/Plan/Discuss)",
175
+ "help.k.workMode": "cycle work mode (Build/Discuss)",
166
176
  "help.k.permission": "cycle permission mode (Auto/Ask)",
167
177
  "help.k.history": "prompt history (in picker: navigate)",
168
178
  "help.k.mouse": "scroll transcript with mouse wheel",
@@ -198,6 +208,20 @@ export const en = {
198
208
  "help.desc.copy": "Copy the last 1–10 turns to clipboard (OSC 52)",
199
209
  "help.desc.history": "Show recent prompt history",
200
210
  "help.desc.scheduler": "Trigger / inspect / stop the scheduler",
211
+ "help.desc.compact": "Toggle compact tool output",
212
+ "help.desc.thinking": "Toggle thinking output visibility",
213
+ "help.desc.expand": "Reopen collapsed content",
214
+ "help.desc.minimize": "Minimize tool output and answers",
215
+ "help.desc.fold": "Toggle the activity panel",
216
+ "out.titleHelp": "Help",
217
+ "out.titleStatus": "Status",
218
+ "out.titleHistory": "History",
219
+ "out.titleSync": "Sync",
220
+ "out.titleInit": "Init",
221
+ "out.titleExpand": "Expand",
222
+ "out.titleModels": "Models",
223
+ "out.titleProviders": "Providers",
224
+ "out.titleCommand": "Command",
201
225
 
202
226
  // [PHASE 6AB] Operator strings for `/scheduler`. The STATE line itself is
203
227
  // deliberately not localised - see `describeOperatorState`, which the
@@ -253,25 +277,30 @@ export const en = {
253
277
  "tui.modeLine": "mode: {m}",
254
278
  "tui.workModeUnknown": "unknown work mode: {a} — choices: {modes}",
255
279
  "tui.workModeLine": "work mode: {m}",
256
- "tui.workModeUsage": "usage: /work-mode <DISCUSS|PLAN|BUILD> — current: {m}",
280
+ "tui.workModeUsage": "usage: /work-mode <DISCUSS|BUILD> — current: {m}",
257
281
  "tui.workModeUnavailable": "work mode is not available in this session",
282
+ "tui.undoInDiscuss":
283
+ "undo/redo unavailable in DISCUSS mode — switch to BUILD (/work-mode BUILD) first",
284
+ "tui.unrestrictedUsage": "usage: /unrestrict [on|off]",
258
285
  "tui.unrestrictedOn": "unrestricted mode enabled - full access",
259
286
  "tui.unrestrictedOff": "unrestricted disabled — permission mode restored to {m}",
260
287
  "tui.bgFinished": "background job {id} finished (exit {code})",
261
288
  "tui.bgFinishedAuto":
262
289
  "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.",
263
290
  "tui.langLine": "lang: {v}",
264
- "tui.toolCall": "tool call: {v}",
291
+ "tui.compactLine": "tool output: {v}",
265
292
  "tui.modelSet": "model: {v}",
266
293
  "tui.thinkingSet": "thinking: {v}",
267
294
  "tui.activityFold": "activity: {v}",
268
295
  "tui.sectionsMin": "sections: minimized",
269
296
  "tui.sectionsExp": "sections: expanded",
270
297
  "tui.minUse": "usage: /minimize [on|off]",
298
+ "tui.toggleUse": "usage: /{cmd} [on|off]",
271
299
  "tui.unknownCmd": "Unknown command: /{name}.{tail}",
272
300
  "tui.didYou": " Did you mean /{hint}?",
273
301
  "tui.tryHelp": " Try /help.",
274
302
  "tui.expandEmpty": "(nothing to expand — all sections were visible)",
303
+ "tui.expandNotFound": "(no truncated content for id: {id})",
275
304
  "tui.expandContent": "content",
276
305
  "tui.expandRetention":
277
306
  "(content outside retention — see .minicode/step-traces.jsonl / session sqlite)",
@@ -289,6 +318,13 @@ export const en = {
289
318
  "cmd.nothingUpdated": " Nothing updated — check API keys and network above, then retry /sync.",
290
319
  "cmd.initExists": "AGENTS.md already exists - not overwritten.",
291
320
  "cmd.initCreated": "AGENTS.md created: {t}",
321
+ "cmd.initInDiscuss":
322
+ "init unavailable in DISCUSS mode — switch to BUILD (/work-mode BUILD) first",
323
+ "cmd.initBodyDesc": "Instructions for agents working in this repository.",
324
+ "cmd.initBodyMap": "## Structure (repo-map)",
325
+ "cmd.initBodyEmpty": "(empty repo-map)",
326
+ "cmd.initBodyConv":
327
+ "## Conventions\n- Follow existing code style.\n- Run typecheck/tests before finishing.",
292
328
  "cmd.noSessions": "No sessions.",
293
329
  "ask.search": "(reverse-i-search)`{q}': ",
294
330
  "ask.searchFail": "(failed reverse-i-search)`{q}': ",
@@ -310,7 +346,7 @@ export const en = {
310
346
  "one.contentBlocked": "\n! Content filter blocked\n",
311
347
  "one.step": " Step {i}: {calls}\n",
312
348
  "hl.moreLines": " ... ({n} more lines)",
313
- "common.canceled": "Canceled",
349
+ "common.canceled": "Cancelled",
314
350
  "err.rateLimit": "Provider is rate-limiting requests",
315
351
  "err.rateLimitFix": "Wait a moment and try again, or use --ratelimit to throttle requests.",
316
352
  "err.balance": "API key balance or quota is exhausted",