minicode-ai 0.9.29 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/cli/args.ts +1 -0
- package/cli/commands.ts +219 -103
- package/cli/index.ts +8 -6
- package/cli/model-manager.ts +2 -7
- package/cli/provider-manager.ts +13 -13
- package/cli/setup.ts +10 -1
- package/cli/tui.ts +506 -0
- package/cli/wizard.ts +2 -1
- package/docs/ARCHITECTURE.html +41 -22
- package/package.json +1 -1
- package/src/app/rag-layer.ts +7 -2
- package/src/config.ts +30 -1
- package/src/policy/bash-guard.ts +64 -8
- package/src/policy/update-check.ts +4 -1
- package/src/tools/bash.ts +8 -0
- package/src/tools/task.ts +6 -1
- package/src/tools/web_fetch.ts +11 -2
- package/src/tools/web_search.ts +4 -1
- package/src/ui/approval/prompt.ts +84 -18
- package/src/ui/assistant/simple.ts +55 -22
- package/src/ui/assistant/turn-status.ts +16 -7
- package/src/ui/footer.ts +14 -12
- package/src/ui/i18n/en.ts +225 -0
- package/src/ui/i18n/id.ts +227 -0
- package/src/ui/i18n/locale.ts +66 -0
- package/src/ui/input/input.ts +138 -77
- package/src/ui/input/prompt-engine.ts +97 -4
- package/src/ui/render/collapse.ts +8 -1
- package/src/ui/render/errors.ts +75 -50
- package/src/ui/render/format.ts +15 -5
- package/src/ui/render/highlight.ts +5 -2
- package/src/ui/render/table.ts +7 -4
- package/src/ui/render/theme.ts +8 -3
- package/src/ui/render/width.ts +17 -9
- package/src/ui/runtime/screen.ts +197 -0
- package/src/ui/screens/dialog.ts +174 -0
- package/src/ui/screens/form.ts +459 -0
- package/src/ui/screens/model-manager.ts +274 -127
- package/src/ui/screens/picker.ts +229 -98
- package/src/ui/screens/provider-manager.ts +371 -164
- package/src/ui/screens/wizard.ts +149 -102
- package/src/ui/tui/app.ts +745 -0
- package/src/ui/tui/transcript.ts +271 -0
- package/cli/repl.ts +0 -740
- package/src/ui/runtime/chrome.ts +0 -369
- package/src/ui/screens/overlay.ts +0 -61
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
// View persetujuan tool —
|
|
1
|
+
// View persetujuan tool — murni presentasi.
|
|
2
2
|
// Lapisan policy tidak mengimpor file ini; ia di-inject sebagai callback dari
|
|
3
3
|
// composition root (cli/setup.ts -> createMinicodeSession -> permission).
|
|
4
|
+
//
|
|
5
|
+
// Warga TUI: bila approval sink terdaftar (cli/tui.ts saat App aktif), blok
|
|
6
|
+
// pertanyaan dicatat ke transkrip + layar di-repaint SEBELUM user menjawab
|
|
7
|
+
// (jejak keputusan permanen, terlihat saat menjawab). Tanpa sink = tulis
|
|
8
|
+
// langsung warisan (one-shot/exec). Input jawaban tetap askLine inline di
|
|
9
|
+
// baris kursor — aman dari App karena input App dibekukan saat busy (hanya
|
|
10
|
+
// abort yang lolos; Esc/Ctrl+C di sini = abort turn + deny, fail-closed).
|
|
11
|
+
|
|
12
|
+
import { t } from "../i18n/locale.ts"
|
|
4
13
|
import { askLine } from "../input/input.ts"
|
|
5
14
|
import { sanitizeAnsiLine } from "../render/sanitize.ts"
|
|
6
15
|
import { c } from "../render/theme.ts"
|
|
16
|
+
import { getApprovalSink } from "../tui/transcript.ts"
|
|
7
17
|
|
|
8
18
|
/** Subset struktural tool call yang dibutuhkan view — tanpa tipe kernel. */
|
|
9
19
|
export interface ApprovalRequest {
|
|
@@ -20,7 +30,7 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
|
|
|
20
30
|
// Live-region untuk screen reader: baris polos tanpa ANSI agar terbaca
|
|
21
31
|
// sebagai teks, bukan escape mentah. Bell saja mengganggu tanpa informasi.
|
|
22
32
|
if (process.env.MINICODE_A11Y === "1")
|
|
23
|
-
process.stderr.write(
|
|
33
|
+
process.stderr.write(`${t("appr.a11y", { name: sanitizeAnsiLine(call.name) })}\n`)
|
|
24
34
|
|
|
25
35
|
// toolName/actionSummary berasal dari model/MCP (tidak terpercaya). Tanpa
|
|
26
36
|
// sanitasi, `\x1b[2J\x1b[H` di dalam args.command akan membersihkan layar
|
|
@@ -43,17 +53,54 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
|
|
|
43
53
|
}
|
|
44
54
|
actionSummary = sanitizeAnsiLine(actionSummary)
|
|
45
55
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
const block = [
|
|
57
|
+
``,
|
|
58
|
+
`${c.warning(c.bold(t("appr.title")))}`,
|
|
59
|
+
` ${c.bold(t("appr.tool"))} ${c.info(toolName)}`,
|
|
60
|
+
` ${actionSummary}`,
|
|
61
|
+
]
|
|
62
|
+
const sink = getApprovalSink()
|
|
63
|
+
if (sink) {
|
|
64
|
+
sink.pushBlock(block)
|
|
65
|
+
sink.repaint()
|
|
66
|
+
// Bekukan App selama menunggu jawaban (pola popup komposit): tanpa ini
|
|
67
|
+
// listener App + repaint live berlomba dengan askLine — prompt tak
|
|
68
|
+
// terlihat, user mengetik buta. Esc/Ctrl+C di sini = deny (batal hanya
|
|
69
|
+
// tool ini), BUKAN abort turn — turn lanjut dengan tool lain.
|
|
70
|
+
sink.suspend()
|
|
71
|
+
} else {
|
|
72
|
+
for (const l of block) process.stdout.write(`${l}\n`)
|
|
73
|
+
}
|
|
49
74
|
|
|
50
|
-
const promptText = `${c.bold("
|
|
51
|
-
|
|
75
|
+
const promptText = `${c.bold(t("appr.allowOnce"))} ${c.bold(t("appr.always"))} ${c.bold(t("appr.deny"))}: `
|
|
76
|
+
let ans: string | null
|
|
77
|
+
try {
|
|
78
|
+
ans = (await askLine({ prompt: promptText })) ?? ""
|
|
79
|
+
} finally {
|
|
80
|
+
if (sink) sink.resume()
|
|
81
|
+
}
|
|
52
82
|
|
|
83
|
+
// Terima jawaban dwibahasa (prompt tampil per locale): y/yes/ya,
|
|
84
|
+
// n/no/tidak/t, a/always/selalu/s. Selain itu = deny (fail-closed).
|
|
53
85
|
const a = ans.trim().toLowerCase()
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
86
|
+
const decisionKey =
|
|
87
|
+
a === "a" || a === "always" || a === "selalu" || a === "s"
|
|
88
|
+
? ("appr.decAlways" as const)
|
|
89
|
+
: a === "y" || a === "yes" || a === "ya"
|
|
90
|
+
? ("appr.decAllow" as const)
|
|
91
|
+
: ("appr.decDeny" as const)
|
|
92
|
+
const decision = t(decisionKey)
|
|
93
|
+
// Keputusan dicatat di transkrip (jejak audit); warisan mengandalkan
|
|
94
|
+
// scrollback askLine yang terhapus repaint.
|
|
95
|
+
if (sink) {
|
|
96
|
+
sink.pushBlock([c.muted(` → ${decision}`)])
|
|
97
|
+
sink.repaint()
|
|
98
|
+
}
|
|
99
|
+
return decisionKey === "appr.decAlways"
|
|
100
|
+
? "always"
|
|
101
|
+
: decisionKey === "appr.decAllow"
|
|
102
|
+
? "allow"
|
|
103
|
+
: "deny"
|
|
57
104
|
}
|
|
58
105
|
|
|
59
106
|
/** View pertanyaan ask_user — di-inject ke src/tools/ask_user.ts dari cli/setup.ts.
|
|
@@ -63,14 +110,33 @@ export async function promptAsk(call: ApprovalRequest): Promise<"allow" | "deny"
|
|
|
63
110
|
export async function promptAskText(question: string, options?: string[]): Promise<string | null> {
|
|
64
111
|
if (!process.stdin.isTTY) return null
|
|
65
112
|
const q = sanitizeAnsiLine(question).slice(0, 2000)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
113
|
+
const block = [
|
|
114
|
+
``,
|
|
115
|
+
`${c.warning(c.bold(t("appr.askTitle")))}`,
|
|
116
|
+
` ${q}`,
|
|
117
|
+
...(options?.length
|
|
118
|
+
? options.map((o, i) => ` ${c.dim(`${i + 1}.`)} ${sanitizeAnsiLine(o)}`)
|
|
119
|
+
: []),
|
|
120
|
+
]
|
|
121
|
+
const sink = getApprovalSink()
|
|
122
|
+
if (sink) {
|
|
123
|
+
sink.pushBlock(block)
|
|
124
|
+
sink.repaint()
|
|
125
|
+
sink.suspend()
|
|
126
|
+
} else {
|
|
127
|
+
for (const l of block) process.stdout.write(`${l}\n`)
|
|
128
|
+
}
|
|
129
|
+
let ans: string | null
|
|
130
|
+
try {
|
|
131
|
+
ans = await askLine({ prompt: `${c.bold(t("appr.answerPrompt"))}` })
|
|
132
|
+
} finally {
|
|
133
|
+
if (sink) sink.resume()
|
|
72
134
|
}
|
|
73
|
-
const ans = await askLine({ prompt: `${c.bold("Your answer")} (empty = cancel): ` })
|
|
74
135
|
if (ans == null || !ans.trim()) return null
|
|
75
|
-
|
|
136
|
+
const out = ans.trim()
|
|
137
|
+
if (sink) {
|
|
138
|
+
sink.pushBlock([c.muted(` → ${sanitizeAnsiLine(out).slice(0, 200)}`)])
|
|
139
|
+
sink.repaint()
|
|
140
|
+
}
|
|
141
|
+
return out
|
|
76
142
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// MINICODE_COMPACT=1 atau setCompactMode (/compact).
|
|
5
5
|
import { Buffer } from "node:buffer"
|
|
6
6
|
import type { UiBus, UiStep } from "../contract.ts"
|
|
7
|
+
import { t } from "../i18n/locale.ts"
|
|
7
8
|
import {
|
|
8
9
|
bufferSection,
|
|
9
10
|
collapse,
|
|
@@ -31,6 +32,13 @@ import { runWithoutStatus } from "../runtime/statusline.ts"
|
|
|
31
32
|
|
|
32
33
|
export interface SimpleOptions {
|
|
33
34
|
verbose?: boolean
|
|
35
|
+
/**
|
|
36
|
+
* Mode senyap untuk TUI fullscreen: semua tulis ke stdout/stderr DITEKAN,
|
|
37
|
+
* tapi state tetap jalan (rememberTurn untuk /copy, bufferSection untuk
|
|
38
|
+
* /expand, pendingError untuk driver). Tanpa ini printer linier mengotori
|
|
39
|
+
* alt-screen di sela repaint App — kontrak I3 (App penulis tunggal layar).
|
|
40
|
+
*/
|
|
41
|
+
quiet?: boolean
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
// Buffer output turn terakhir untuk /copy: teks model (sudah sanitize, sama
|
|
@@ -67,9 +75,9 @@ export function writeClipboardOsc52(text: string): boolean {
|
|
|
67
75
|
return true
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
const
|
|
78
|
+
const wOutDirect = (s: string) =>
|
|
71
79
|
runWithoutStatus(() => process.stdout.write(process.stdout.isTTY ? s : stripSgr(s)))
|
|
72
|
-
const
|
|
80
|
+
const wErrDirect = (s: string) =>
|
|
73
81
|
runWithoutStatus(() => process.stderr.write(process.stdout.isTTY ? s : stripSgr(s)))
|
|
74
82
|
|
|
75
83
|
// Error provider terakhir turn ini — diingat, BUKAN dicetak langsung.
|
|
@@ -111,6 +119,11 @@ function patchBlocks(patches: unknown): [string, string] {
|
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () => void {
|
|
122
|
+
// Shadow module-level wOut/wErr: saat quiet, paint ditekan tapi SEMUA state
|
|
123
|
+
// (rememberTurn, bufferSection, pendingError, sanitizer) tetap jalan.
|
|
124
|
+
// Shadowing disengaja agar ~20 call-site tak perlu diubah satu per satu.
|
|
125
|
+
const wOut = opts.quiet ? (_: string) => {} : wOutDirect
|
|
126
|
+
const wErr = opts.quiet ? (_: string) => {} : wErrDirect
|
|
114
127
|
let streamBuffer = ""
|
|
115
128
|
// Sanitizer sadar-stream per aliran teks (temuan F1): ekor escape yang
|
|
116
129
|
// terpotong di batas chunk ditahan dan disambung ke chunk berikut SEBELUM
|
|
@@ -159,7 +172,12 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
159
172
|
return
|
|
160
173
|
}
|
|
161
174
|
if (answerBuf.length < ANSWER_BUF_MAX) {
|
|
162
|
-
|
|
175
|
+
// Jangan belah surrogate pair di batas cap: slice mentah bisa
|
|
176
|
+
// menyisakan lead-surrogate yatim yang tampil sebagai U+FFFD di /expand.
|
|
177
|
+
let chunk = s.slice(0, ANSWER_BUF_MAX - answerBuf.length)
|
|
178
|
+
const last = chunk.charCodeAt(chunk.length - 1)
|
|
179
|
+
if (chunk.length > 0 && last >= 0xd800 && last <= 0xdbff) chunk = chunk.slice(0, -1)
|
|
180
|
+
answerBuf += chunk
|
|
163
181
|
if (answerBuf.length >= ANSWER_BUF_MAX) answerTruncated = true
|
|
164
182
|
} else {
|
|
165
183
|
answerTruncated = true
|
|
@@ -217,11 +235,13 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
217
235
|
// menghilangkan konten diam-diam (perilaku lama menampilkannya live).
|
|
218
236
|
const finalizeAnswer = () => {
|
|
219
237
|
if (answerBuf.length === 0) return
|
|
220
|
-
|
|
221
|
-
|
|
238
|
+
// Hitung per code point (bukan UTF-16 unit): emoji surrogate dihitung 1,
|
|
239
|
+
// konsisten dengan label "chars" dan tak menggandakan di /expand.
|
|
240
|
+
const n = Array.from(stripAnsi(answerBuf)).length
|
|
241
|
+
const cap = answerTruncated ? t("one.answerCap") : ""
|
|
222
242
|
// Petunjuk /expand WAJIB di baris ini: tanpa itu jawaban yang dikecilkan
|
|
223
243
|
// terlihat "bisu" (tak ada cara membuka yang bisa ditemukan user).
|
|
224
|
-
wErr(c.info(
|
|
244
|
+
wErr(c.info(t("one.answerMin", { n, cap })))
|
|
225
245
|
bufferSection("answer", answerBuf, "stdout")
|
|
226
246
|
answerBuf = ""
|
|
227
247
|
answerTruncated = false
|
|
@@ -278,7 +298,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
278
298
|
collapse.setActiveSection(null)
|
|
279
299
|
lastTurnText = ""
|
|
280
300
|
pendingError = null
|
|
281
|
-
if (opts.verbose) wErr(c.muted(
|
|
301
|
+
if (opts.verbose) wErr(c.muted(t("one.turnHead", { n: e.turn })))
|
|
282
302
|
}),
|
|
283
303
|
)
|
|
284
304
|
offs.push(
|
|
@@ -295,7 +315,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
295
315
|
bashSan.flush()
|
|
296
316
|
flushThinking()
|
|
297
317
|
finalizeAnswer()
|
|
298
|
-
if (opts.verbose) wErr(c.muted(
|
|
318
|
+
if (opts.verbose) wErr(c.muted(t("one.done")))
|
|
299
319
|
}),
|
|
300
320
|
)
|
|
301
321
|
offs.push(
|
|
@@ -308,7 +328,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
308
328
|
flushThinking()
|
|
309
329
|
collapse.setActiveSection("answer")
|
|
310
330
|
if (!answerHidden() && answerBuf.length > 0) {
|
|
311
|
-
wErr(c.muted("
|
|
331
|
+
wErr(c.muted(t("one.answerOpen")))
|
|
312
332
|
wOut(answerBuf)
|
|
313
333
|
answerBuf = ""
|
|
314
334
|
answerTruncated = false
|
|
@@ -334,7 +354,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
334
354
|
if (expanded) {
|
|
335
355
|
if (thinkState !== "exp") {
|
|
336
356
|
thinkState = "exp"
|
|
337
|
-
wErr(c.muted(
|
|
357
|
+
wErr(c.muted(t("one.thinkOpen")))
|
|
338
358
|
if (thinkingBuf) {
|
|
339
359
|
wErr(c.muted(thinkingBuf))
|
|
340
360
|
thinkingBuf = ""
|
|
@@ -357,7 +377,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
357
377
|
// Sisa baris expanded yang belum selesai dicetak dulu (terlihat),
|
|
358
378
|
// baru header minimize — konten tak hilang, tak menempel.
|
|
359
379
|
flushReasoningTail()
|
|
360
|
-
wErr(c.info(
|
|
380
|
+
wErr(c.info(t("one.thinkMin")))
|
|
361
381
|
}
|
|
362
382
|
if (text) {
|
|
363
383
|
// Sama: buffer thinking ikut tercemar bila mentah (flush expanded
|
|
@@ -367,12 +387,15 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
367
387
|
if (thinkingBuf.length > THINKING_BUF_MAX) {
|
|
368
388
|
// Total ber-marker dibatasi THINKING_BUF_MAX (= cap per-entry
|
|
369
389
|
// bufferSection) agar tak ada pemotongan diam-diam kedua di hilir.
|
|
390
|
+
// Tail-slice jangan mulai di tengah surrogate pair: trail
|
|
391
|
+
// yatim di awal tampil sebagai U+FFFD saat /expand.
|
|
370
392
|
const body = thinkingBuf.startsWith(THINKING_TRUNCATED_MARKER)
|
|
371
393
|
? thinkingBuf.slice(THINKING_TRUNCATED_MARKER.length)
|
|
372
394
|
: thinkingBuf
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
395
|
+
let tail = body.slice(-(THINKING_BUF_MAX - THINKING_TRUNCATED_MARKER.length))
|
|
396
|
+
const first = tail.charCodeAt(0)
|
|
397
|
+
if (tail.length > 0 && first >= 0xdc00 && first <= 0xdfff) tail = tail.slice(1)
|
|
398
|
+
thinkingBuf = THINKING_TRUNCATED_MARKER + tail
|
|
376
399
|
}
|
|
377
400
|
}
|
|
378
401
|
}
|
|
@@ -392,7 +415,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
392
415
|
const d = e.data as { message?: string; category?: string }
|
|
393
416
|
pendingError = formatProviderError(d)
|
|
394
417
|
} else if (e.kind === "content_filter") {
|
|
395
|
-
wErr(c.warning(
|
|
418
|
+
wErr(c.warning(t("one.contentBlocked")))
|
|
396
419
|
}
|
|
397
420
|
}),
|
|
398
421
|
)
|
|
@@ -406,7 +429,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
406
429
|
`${c.info(sanitizeAnsiLine(tc.name))}(${c.muted(sanitizeAnsiLine(formatArgsPreview(tc.args)))})`,
|
|
407
430
|
)
|
|
408
431
|
.join(", ")
|
|
409
|
-
wErr(c.muted(
|
|
432
|
+
wErr(c.muted(t("one.step", { i: e.step.index, calls })))
|
|
410
433
|
}),
|
|
411
434
|
)
|
|
412
435
|
offs.push(
|
|
@@ -443,11 +466,12 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
443
466
|
if (!r.isError && typeof r.content === "string")
|
|
444
467
|
rememberTurn(truncateToWidth(sanitizeAnsi(r.content), 20000, ""))
|
|
445
468
|
if (r.isError) {
|
|
446
|
-
// Error tool
|
|
469
|
+
// Error tool ditampilkan ringkas per baris (cap 200 kolom + marker) —
|
|
470
|
+
// tanpa marker user tak bisa bedakan "pesan 200 kolom" vs "terpotong".
|
|
447
471
|
collapse.setActiveSection(null)
|
|
448
472
|
wErr(
|
|
449
473
|
c.error(
|
|
450
|
-
` ${glyphs.arrow} ${sanitizeAnsiLine(name)}: ${truncateToWidth(sanitizeAnsi(String(r.content)), 200, "")}\n`,
|
|
474
|
+
` ${glyphs.arrow} ${sanitizeAnsiLine(name)}: ${truncateToWidth(sanitizeAnsi(String(r.content)), 200, "…")}\n`,
|
|
451
475
|
),
|
|
452
476
|
)
|
|
453
477
|
return
|
|
@@ -495,8 +519,11 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
495
519
|
}
|
|
496
520
|
// todo_write: tampilkan daftarnya utuh — ini rencana kerja, bukan noise.
|
|
497
521
|
if (name === "todo_write" || name === "todo_read") {
|
|
522
|
+
// Nama tool dari event model (tak terpercaya): sanitasi seperti cabang
|
|
523
|
+
// lain agar ESC[2J/OSC tak lolos via label.
|
|
524
|
+
const cleanName = sanitizeAnsiLine(name)
|
|
498
525
|
wErr(
|
|
499
|
-
c.success(` ${glyphs.arrow} ${
|
|
526
|
+
c.success(` ${glyphs.arrow} ${cleanName}\n`) +
|
|
500
527
|
c.muted(`${sanitizeAnsi(String(r.content))}\n`),
|
|
501
528
|
)
|
|
502
529
|
return
|
|
@@ -511,7 +538,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
511
538
|
if (detail.compact) {
|
|
512
539
|
const preview =
|
|
513
540
|
lines.length > 3
|
|
514
|
-
? lines.slice(0, 3).join("\n ") + c.muted(
|
|
541
|
+
? lines.slice(0, 3).join("\n ") + c.muted(t("one.more3", { n: lines.length - 3 }))
|
|
515
542
|
: lines.join("\n ")
|
|
516
543
|
wErr(c.success(` ${glyphs.arrow} $ ${cmdLabel}\n`) + c.muted(` ${preview}\n`))
|
|
517
544
|
return
|
|
@@ -519,7 +546,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
519
546
|
const maxLines = TOOL_OUT_MAX_LINES()
|
|
520
547
|
const shown = lines.slice(0, maxLines).map((l) => ` ${sanitizeAnsi(l)}`)
|
|
521
548
|
const more =
|
|
522
|
-
lines.length > maxLines ? c.muted(
|
|
549
|
+
lines.length > maxLines ? c.muted(t("one.moreLines", { n: lines.length - maxLines })) : ""
|
|
523
550
|
wErr(
|
|
524
551
|
c.success(` ${glyphs.arrow} $ ${cmdLabel}\n`) +
|
|
525
552
|
(shown.length ? `${c.muted(shown.join("\n")) + more}\n` : ""),
|
|
@@ -571,7 +598,13 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
|
|
|
571
598
|
wErr(c.success(` ${glyphs.arrow} ${cleanName}${label ? ` ${label}` : ""}\n`))
|
|
572
599
|
}),
|
|
573
600
|
)
|
|
574
|
-
offs.push(
|
|
601
|
+
offs.push(
|
|
602
|
+
bus.on("context:compacted", (e) =>
|
|
603
|
+
wErr(
|
|
604
|
+
c.warning(`${t("ts.compacted", { reason: sanitizeAnsiLine(String(e.reason ?? "")) })}\n`),
|
|
605
|
+
),
|
|
606
|
+
),
|
|
607
|
+
)
|
|
575
608
|
|
|
576
609
|
return () => {
|
|
577
610
|
// Sisa parsal di-flush dulu (jangan hilang diam-diam), baru lepas.
|
|
@@ -117,7 +117,10 @@ export function attachTurnStatus(
|
|
|
117
117
|
const dots = Array(1 + (tickGroup % 3))
|
|
118
118
|
.fill(glyphs.dot)
|
|
119
119
|
.join(" ")
|
|
120
|
-
|
|
120
|
+
// Garis dilukis ke stderr via paintWrite — ukur dari stderr (jatuh ke
|
|
121
|
+
// stdout bila tak ada). stdout|pipe + stderr TTY memakai fallback 80 yang
|
|
122
|
+
// salah: terminal 120 terpotong berlebih, terminal 40 wrap sendiri.
|
|
123
|
+
const cols = process.stderr.columns ?? process.stdout.columns ?? 80
|
|
121
124
|
// Sinyal "alive" (spark pulse) kini MILIK FOOTER, bukan thinking line:
|
|
122
125
|
// satu sumber agar tak ada dua denyut. Thinking = titik saja; tool line
|
|
123
126
|
// tetap pakai spinner braille (itu progres, bukan spark).
|
|
@@ -217,15 +220,21 @@ export function attachTurnStatus(
|
|
|
217
220
|
let target = ""
|
|
218
221
|
if (typeof args.path === "string") target = args.path
|
|
219
222
|
else if (typeof args.file === "string") target = args.file
|
|
220
|
-
else if (typeof args.cmd === "string") target = args.cmd
|
|
221
|
-
else if (typeof args.command === "string") target = args.command
|
|
222
|
-
// Potong panjang (
|
|
223
|
-
//
|
|
223
|
+
else if (typeof args.cmd === "string") target = args.cmd
|
|
224
|
+
else if (typeof args.command === "string") target = args.command
|
|
225
|
+
// Potong panjang di sini (batas 80/200), potong LEBAR per-paint agar resize
|
|
226
|
+
// langsung berefek. truncateToWidth: tak belah SGR/surrogate — slice mentah
|
|
227
|
+
// bisa mendarat di tengah `\x1b[31m` dan menyisakan escape gantung yang
|
|
228
|
+
// lolos paintWrite.
|
|
224
229
|
// Nama + argumen datang dari model (tak terpercaya): sanitasi sebelum
|
|
225
230
|
// masuk paintWrite — truncateToWidth memotong lebar, bukan sekuens kontrol.
|
|
226
231
|
const cleanName = sanitizeAnsiLine(name)
|
|
227
|
-
const
|
|
228
|
-
|
|
232
|
+
const cleanTarget =
|
|
233
|
+
target.length > 80
|
|
234
|
+
? truncateToWidth(sanitizeAnsiLine(target), 80, "")
|
|
235
|
+
: sanitizeAnsiLine(target)
|
|
236
|
+
const label2 = cleanTarget ? `${cleanName} ${cleanTarget}` : cleanName
|
|
237
|
+
return label2.length > 200 ? truncateToWidth(label2, 200, "") : label2
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
const detach = [
|
package/src/ui/footer.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Status bar TUI: 1 baris status (tanpa garis — keputusan clean).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// tanpa IO, tanpa timer, tanpa tahu mekanisme mana yang memakainya. Frame
|
|
7
|
-
// animasi spark dan angka konteks DIKIRIM pemanggil lewat FooterStatus, jadi
|
|
8
|
-
// render tetap deterministik dan bisa diuji tanpa menunggu waktu.
|
|
3
|
+
// Modul murni render tanpa IO/timer: dipakai App TUI sebagai baris dasar.
|
|
4
|
+
// Frame animasi spark dan angka konteks DIKIRIM pemanggil lewat FooterStatus,
|
|
5
|
+
// jadi render tetap deterministik dan bisa diuji tanpa menunggu waktu.
|
|
9
6
|
//
|
|
10
7
|
// Gaya (keputusan produk): footer hampir tak terlihat — garis + teks status
|
|
11
8
|
// abu-abu gelap; SATU-SATUNYA yang berwarna adalah token mode (mapping sama
|
|
@@ -14,7 +11,7 @@
|
|
|
14
11
|
// Tata letak: `✦ mode • model • cwd ……… 14.2k` — konteks rata kanan. Mode
|
|
15
12
|
// di-pad ke lebar tetap agar teks di kanannya TIDAK bergeser saat mode berganti
|
|
16
13
|
// (Shift+Tab): tanpa padding, `auto`→`allowlist` menggeser seluruh baris.
|
|
17
|
-
import {
|
|
14
|
+
import { sanitizeAnsiLine } from "./render/sanitize.ts"
|
|
18
15
|
import { c, glyphs } from "./render/theme.ts"
|
|
19
16
|
import { displayWidth, padToWidth, truncateToWidth } from "./render/width.ts"
|
|
20
17
|
|
|
@@ -49,7 +46,9 @@ export function shortModel(id: string): string {
|
|
|
49
46
|
export function paintFooterMode(mode: string): string {
|
|
50
47
|
// Padding per KOLOM (bukan padEnd karakter): CJK/emoji = 2 kolom, dan
|
|
51
48
|
// displayWidth sudah dipakai di bawah — konsisten satu penggaris.
|
|
52
|
-
|
|
49
|
+
// Mode satu-baris: newline dari input tak terpercaya wajib dibuang agar tak
|
|
50
|
+
// memecah frame lengket 2-baris chrome.ts.
|
|
51
|
+
const padded = padToWidth(sanitizeAnsiLine(mode), MODE_WIDTH)
|
|
53
52
|
return mode === "plan" ? c.warning(padded) : mode === "ask" ? c.info(padded) : c.success(padded)
|
|
54
53
|
}
|
|
55
54
|
|
|
@@ -72,15 +71,18 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
|
|
|
72
71
|
const mode = paintFooterMode(s.mode)
|
|
73
72
|
const dot = c.gray("•")
|
|
74
73
|
const sep = ` ${dot} `
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
// Satu-baris: cwd/model bisa berisi newline (nama dir) — sanitizeAnsiLine
|
|
75
|
+
// agar \n tak memecah frame lengket ke scrollback (displayWidth menghitung
|
|
76
|
+
// \n = 0 sehingga align mengira muat).
|
|
77
|
+
const model = c.gray(sanitizeAnsiLine(shortModel(s.model)))
|
|
78
|
+
const cwdTxt = c.gray(sanitizeAnsiLine(s.cwd))
|
|
77
79
|
|
|
78
80
|
const full = `${spark} ${mode}${sep}${model}${sep}${cwdTxt}`
|
|
79
81
|
const mid = `${spark} ${mode}${sep}${model}`
|
|
80
82
|
const lean = `${spark} ${mode}`
|
|
81
83
|
|
|
82
84
|
const target = Math.max(4, cols - 1)
|
|
83
|
-
const ctx = s.context ?
|
|
85
|
+
const ctx = s.context ? sanitizeAnsiLine(s.context) : ""
|
|
84
86
|
const ctxW = ctx ? displayWidth(ctx) : 0
|
|
85
87
|
|
|
86
88
|
// Rata kanan: konteks didorong ke kolom `target` dengan gap ideal ≥6
|