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.
- package/AGENTS.md +45 -0
- package/CHANGELOG.md +59 -4
- package/PLAN.md +491 -0
- package/README.md +2 -2
- package/cli/commands/acp.ts +485 -0
- package/cli/commands/auth.ts +7 -4
- package/cli/commands/config.ts +41 -27
- package/cli/commands/exec.ts +33 -12
- package/cli/commands/mcp.ts +3 -2
- package/cli/commands/memory.ts +1 -1
- package/cli/commands/pricing.ts +6 -4
- package/cli/commands/providers.ts +18 -8
- package/cli/commands/sessions.ts +11 -4
- package/cli/commands/skills.ts +3 -3
- package/cli/commands/stats.ts +3 -1
- package/cli/commands.ts +6 -0
- package/cli/index.ts +82 -57
- package/cli/model-manager.ts +6 -1
- package/cli/router.ts +7 -0
- package/cli/setup.ts +341 -5
- package/cli/tui.ts +54 -18
- package/docs/ARCHITECTURE.html +29 -22
- package/docs/CONTROL-PLANE-MAP.md +139 -0
- package/docs/HARNESS.md +150 -0
- package/docs/PLAN_UIUX_V6.md +209 -0
- package/docs/README.md +1 -1
- package/docs/SUMMARY.md +52 -0
- package/docs/TERMINAL_CONTRACT.md +367 -0
- package/docs/UI_RENDER_PIPELINE.md +165 -0
- package/docs/USAGE.md +11 -0
- package/docs/agents.md +31 -0
- package/docs/architecture.md +3 -3
- package/docs/choosing-mode.md +34 -0
- package/docs/cli.md +130 -0
- package/docs/concepts.md +53 -0
- package/docs/config-providers.md +87 -0
- package/docs/config.md +63 -0
- package/docs/contributing.md +79 -0
- package/docs/environment.md +95 -0
- package/docs/exec.md +73 -0
- package/docs/getting-started.md +102 -0
- package/docs/glossary.md +37 -0
- package/docs/mcp-lsp.md +54 -0
- package/docs/memory-sessions.md +63 -0
- package/docs/policy-sandbox.md +72 -0
- package/docs/pricing-budget.md +49 -0
- package/docs/quickstart.md +60 -0
- package/docs/repl.md +67 -0
- package/docs/security-model.md +95 -0
- package/docs/security.md +91 -0
- package/docs/skills.md +48 -0
- package/docs/terminal.md +79 -0
- package/docs/tools.md +123 -0
- package/docs/troubleshooting.md +40 -0
- package/docs/verify-benchmark.md +58 -0
- package/package.json +8 -5
- package/src/app/provider-layer.ts +12 -4
- package/src/app/session.ts +6 -0
- package/src/app/tool-layer.ts +2 -1
- package/src/constants.ts +35 -0
- package/src/lib/net.ts +6 -1
- package/src/lsp/client.ts +41 -8
- package/src/mcp/http-transport.ts +52 -15
- package/src/mcp/transport.ts +32 -1
- package/src/memory/files.ts +6 -5
- package/src/policy/allowlist.ts +1 -1
- package/src/policy/bash-guard.ts +154 -14
- package/src/policy/compaction.ts +57 -3
- package/src/policy/context.ts +4 -0
- package/src/policy/jail.ts +49 -4
- package/src/policy/permission.ts +152 -12
- package/src/policy/pricing.ts +12 -9
- package/src/presentation/adapter.ts +721 -0
- package/src/presentation/events.ts +324 -0
- package/src/presentation/label.ts +140 -0
- package/src/presentation/model.ts +172 -0
- package/src/presentation/reducer.ts +486 -0
- package/src/presentation/store.ts +256 -0
- package/src/providers/anthropic.ts +22 -4
- package/src/providers/detect.ts +2 -1
- package/src/providers/router.ts +13 -0
- package/src/repo/repomap.ts +2 -29
- package/src/session/checkpoint.ts +27 -9
- package/src/session/journal.ts +27 -5
- package/src/skills/loader.ts +88 -5
- package/src/telemetry/trace.ts +36 -15
- package/src/tools/ask_user.ts +73 -4
- package/src/tools/bash.ts +15 -17
- package/src/tools/glob.ts +10 -11
- package/src/tools/lsp.ts +3 -56
- package/src/tools/memory.ts +13 -12
- package/src/tools/task.ts +1 -0
- package/src/ui/approval/prompt.ts +14 -6
- package/src/ui/assistant/simple.ts +137 -26
- package/src/ui/assistant/turn-status.ts +16 -3
- package/src/ui/contract.ts +119 -0
- package/src/ui/footer.ts +21 -2
- package/src/ui/i18n/en.ts +34 -6
- package/src/ui/i18n/id.ts +34 -6
- package/src/ui/i18n/locale.ts +3 -1
- package/src/ui/input/input.ts +51 -4
- package/src/ui/input/prompt-engine.ts +46 -4
- package/src/ui/render/collapse.ts +13 -13
- package/src/ui/render/diff.ts +7 -2
- package/src/ui/render/format.ts +16 -8
- package/src/ui/render/highlight.ts +7 -3
- package/src/ui/render/markdown.ts +5 -1
- package/src/ui/render/sanitize.ts +29 -2
- package/src/ui/render/table.ts +8 -5
- package/src/ui/render/theme.ts +18 -4
- package/src/ui/render/width.ts +89 -10
- package/src/ui/runtime/motion.ts +16 -0
- package/src/ui/runtime/screen.ts +45 -0
- package/src/ui/runtime/spinner.ts +50 -4
- package/src/ui/runtime/statusline.ts +50 -1
- package/src/ui/screens/form.ts +42 -15
- package/src/ui/screens/model-manager.ts +26 -18
- package/src/ui/screens/picker.ts +47 -23
- package/src/ui/screens/provider-manager.ts +18 -12
- package/src/ui/screens/wizard.ts +24 -8
- package/src/ui/tui/app.ts +233 -27
- package/src/ui/tui/transcript.ts +269 -65
- package/vendor/minicore/LICENSE +21 -0
- package/vendor/minicore/VENDOR.md +6 -3
- package/vendor/minicore/package.json +6 -3
- package/vendor/minicore/src/core/loop.ts +12 -2
- package/vendor/minicore/src/core/snapshot.ts +4 -0
- package/vendor/minicore/src/providers/openai-compat.ts +76 -25
|
@@ -10,14 +10,13 @@ import {
|
|
|
10
10
|
} from "../input/prompt-engine.ts"
|
|
11
11
|
import { sanitizeAnsiLine } from "../render/sanitize.ts"
|
|
12
12
|
import { c, glyphs, stripAnsi } from "../render/theme.ts"
|
|
13
|
-
import { displayWidth,
|
|
13
|
+
import { displayWidth, truncateToWidth } from "../render/width.ts"
|
|
14
14
|
import { type AltScreen, openAltScreen } from "../runtime/screen.ts"
|
|
15
15
|
import { boxLeftPad, dialogBox } from "./dialog.ts"
|
|
16
16
|
import { runForm } from "./form.ts"
|
|
17
17
|
import { runPicker } from "./picker.ts"
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
RESTORE = "\x1b[22m"
|
|
19
|
+
const dim = (s: string): string => c.dim(s)
|
|
21
20
|
|
|
22
21
|
export interface ModelRow {
|
|
23
22
|
/** Format "providerId::model". */
|
|
@@ -92,8 +91,9 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
92
91
|
}
|
|
93
92
|
// Lantai lebar tak boleh melebihi terminal. Lebar konten = lebar kotak
|
|
94
93
|
// tetap dikurangi chrome dialog (border+padding = 4) agar sepakat dengan
|
|
95
|
-
// dialogBox (tanpa potong ulang).
|
|
96
|
-
|
|
94
|
+
// dialogBox (tanpa potong ulang). innerMax dialog = cols−6, jadi konten
|
|
95
|
+
// = cols−6 juga (dulu cols−4 → potong-ganda 2 kolom di terminal sempit).
|
|
96
|
+
const width = () => Math.max(8, Math.min((process.stdout.columns || 80) - 6, MODAL_BOX_W - 4))
|
|
97
97
|
|
|
98
98
|
// Isi MINIMAL dialog /model (tanpa judul/footer/hitungan/penanda —
|
|
99
99
|
// seleksi murni warna). Search selalu tampil, daftar tanpa `›`.
|
|
@@ -106,25 +106,26 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
106
106
|
const cut = (s: string) => truncateToWidth(s, w)
|
|
107
107
|
const view = list.slice(scroll, scroll + v)
|
|
108
108
|
const lines: string[] = []
|
|
109
|
-
lines.push(cut(`${
|
|
109
|
+
lines.push(cut(`${dim(">")} ${c.brightCyan(sanitizeAnsiLine(filter ?? ""))}█`))
|
|
110
110
|
if (!list.length) {
|
|
111
|
-
lines.push(
|
|
112
|
-
cut(`${DIM} ${filter == null ? t("model.empty") : t("model.noMatch")}${RESTORE}`),
|
|
113
|
-
)
|
|
111
|
+
lines.push(cut(dim(` ${filter == null ? t("model.empty") : t("model.noMatch")}`)))
|
|
114
112
|
} else {
|
|
115
113
|
for (let i = 0; i < view.length; i++) {
|
|
116
114
|
const row = view[i]!
|
|
117
115
|
const picked = i === sel - scroll
|
|
118
116
|
const badge = row.effort && row.effort !== "default" ? ` [${row.effort}]` : ""
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
// Penanda aktif di luar budget truncasi (paritas provider-manager):
|
|
118
|
+
// nama yang dipotong, status yang selamat.
|
|
119
|
+
const active = row.active ? ` (${t("common.active")})` : ""
|
|
120
|
+
const nameBudget = Math.max(8, w - 4 - displayWidth(active))
|
|
121
|
+
const label = `${truncateToWidth(`${sanitizeAnsiLine(row.id)}${badge}`, nameBudget, "…")}${active}`
|
|
122
|
+
// Penanda › paritas picker/provider-manager — aksesibilitas visual
|
|
123
|
+
// (warna saja tak cukup untuk sebagian pengguna).
|
|
124
|
+
if (picked) lines.push(` ${c.accent("›")} ${c.accent(c.bold(label))}`)
|
|
125
|
+
else lines.push(` ${dim(label)}`)
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
|
-
if (notice) lines.push(cut(
|
|
128
|
+
if (notice) lines.push(cut(dim(sanitizeAnsiLine(notice))))
|
|
128
129
|
return lines
|
|
129
130
|
}
|
|
130
131
|
|
|
@@ -175,6 +176,11 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
175
176
|
try {
|
|
176
177
|
console.log(`⚠ ${t("gate.tuiModel")}`)
|
|
177
178
|
} catch {}
|
|
179
|
+
// Tutup layar sebelum batal: openAltScreen sudah menulis ENTER fisik —
|
|
180
|
+
// bail tanpa close membocorkan alt-screen + hold painter (I27).
|
|
181
|
+
try {
|
|
182
|
+
screen.close()
|
|
183
|
+
} catch {}
|
|
178
184
|
resolve()
|
|
179
185
|
return
|
|
180
186
|
}
|
|
@@ -428,8 +434,10 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
428
434
|
continue
|
|
429
435
|
}
|
|
430
436
|
if (item.key.type === "ctrl-u") {
|
|
431
|
-
// Ctrl+U =
|
|
432
|
-
|
|
437
|
+
// Ctrl+U = kosongkan query tapi TETAP di mode saring (paritas
|
|
438
|
+
// readline kill-line + picker). Dulu null (keluar mode) — beda
|
|
439
|
+
// dari picker yang tetap di mode filter setelah Ctrl+U.
|
|
440
|
+
filter = ""
|
|
433
441
|
sel = 0
|
|
434
442
|
scroll = 0
|
|
435
443
|
continue
|
package/src/ui/screens/picker.ts
CHANGED
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
} from "../input/prompt-engine.ts"
|
|
11
11
|
import { sanitizeAnsiLine } from "../render/sanitize.ts"
|
|
12
12
|
import { c, stripAnsi } from "../render/theme.ts"
|
|
13
|
-
import { truncateToWidth } from "../render/width.ts"
|
|
13
|
+
import { displayWidth, truncateToWidth } from "../render/width.ts"
|
|
14
14
|
import { type AltScreen, openAltScreen } from "../runtime/screen.ts"
|
|
15
|
+
import { beginInteractiveScreen } from "../runtime/statusline.ts"
|
|
15
16
|
import { boxLeftPad, dialogBox } from "./dialog.ts"
|
|
16
17
|
|
|
17
18
|
export interface PickerItem {
|
|
@@ -29,8 +30,7 @@ export interface PickerOptions {
|
|
|
29
30
|
filterable?: boolean
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
const
|
|
33
|
-
RESTORE = "\x1b[22m",
|
|
33
|
+
const dim = (s: string): string => c.dim(s),
|
|
34
34
|
ACC_DIM = (s: string) => c.accent(s)
|
|
35
35
|
|
|
36
36
|
/** Lebar kotak popup picker TETAP (keputusan rasa: geometri stabil). */
|
|
@@ -51,8 +51,11 @@ function highlightMatch(label: string, query: string): string {
|
|
|
51
51
|
|
|
52
52
|
export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
53
53
|
if (!process.stdin.isTTY) {
|
|
54
|
+
// Pipe/redirect: item dari config (tak-terpercaya) disanitasi agar ANSI
|
|
55
|
+
// mentah tak mencemari output program (kontrak stdout non-TTY).
|
|
54
56
|
console.log(`\n${opts.title}`)
|
|
55
|
-
for (const [i, it] of opts.items.entries())
|
|
57
|
+
for (const [i, it] of opts.items.entries())
|
|
58
|
+
console.log(` [${i}] ${sanitizeAnsiLine(it.provider)}::${sanitizeAnsiLine(it.name)}`)
|
|
56
59
|
console.log("")
|
|
57
60
|
// Fail-closed: pemanggil nested (mis. pickEffort di /model) menunggu
|
|
58
61
|
// onPick/onCancel — tanpa ini await-nya gantung selamanya (busy=true)
|
|
@@ -114,14 +117,12 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
114
117
|
if (isFilterable) {
|
|
115
118
|
const placeholderText = opts.placeholder ?? t("pick.placeholder")
|
|
116
119
|
// Filter = input user tak terpercaya — sanitasi sebelum tampil.
|
|
117
|
-
const display = filter
|
|
118
|
-
|
|
119
|
-
: DIM + placeholderText + RESTORE
|
|
120
|
-
const label = filter ? ACC_DIM(t("pick.filter")) : `${DIM}${t("pick.filter")}${RESTORE}`
|
|
120
|
+
const display = filter ? c.brightCyan(sanitizeAnsiLine(filter)) : dim(placeholderText)
|
|
121
|
+
const label = filter ? ACC_DIM(t("pick.filter")) : dim(t("pick.filter"))
|
|
121
122
|
lines.push(cut(`${label} ${display}`))
|
|
122
123
|
}
|
|
123
124
|
if (items.length === 0) {
|
|
124
|
-
lines.push(cut(
|
|
125
|
+
lines.push(cut(dim(` ${t("pick.noMatch", { q: sanitizeAnsiLine(filter) })}`)))
|
|
125
126
|
return lines
|
|
126
127
|
}
|
|
127
128
|
for (let i = 0; i < rows.length; i++) {
|
|
@@ -135,16 +136,14 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
135
136
|
// menyalin semua escape (juga 2J).
|
|
136
137
|
const rawLabel = `${sanitizeAnsiLine(it.name)}${it.provider ? ` — ${sanitizeAnsiLine(it.provider)}` : ""}`
|
|
137
138
|
const label = highlightMatch(truncateToWidth(rawLabel, w - 4), filter)
|
|
138
|
-
if (picked) lines.push(` ${c.accent("›")} ${c.accent(c.bold(label))}
|
|
139
|
-
else lines.push(` ${
|
|
139
|
+
if (picked) lines.push(` ${c.accent("›")} ${c.accent(c.bold(label))}`)
|
|
140
|
+
else lines.push(` ${dim(label)}`)
|
|
140
141
|
}
|
|
141
142
|
if (items.length > scroll + v) {
|
|
142
|
-
lines.push(cut(
|
|
143
|
+
lines.push(cut(dim(t("dlg.more", { n: items.length - scroll - v }))))
|
|
143
144
|
} else if (isFilterable && filter) {
|
|
144
145
|
lines.push(
|
|
145
|
-
cut(
|
|
146
|
-
`${DIM} ${t("pick.matches", { n: items.length, total: opts.items.length })}${RESTORE}`,
|
|
147
|
-
),
|
|
146
|
+
cut(dim(` ${t("pick.matches", { n: items.length, total: opts.items.length })}`)),
|
|
148
147
|
)
|
|
149
148
|
}
|
|
150
149
|
return lines
|
|
@@ -168,15 +167,25 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
168
167
|
screen.rows,
|
|
169
168
|
)
|
|
170
169
|
screen.paintRegion(box.lines, box.topRow)
|
|
171
|
-
// Parkir kursor
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const li = Math.min(box.lines.length - 1, box.bodyTop + bodyOffset + itemRow)
|
|
176
|
-
const row = box.topRow + li
|
|
170
|
+
// Parkir kursor: saat filter terisi, user sedang mengetik → kursor di
|
|
171
|
+
// ujung teks filter (dulu selalu di baris item = ketik buta). Saat
|
|
172
|
+
// filter kosong, parkir di baris item aktif (navigasi ↑↓).
|
|
173
|
+
// Kolom = padding kiri + border + spasi + lebar label+filter + 1.
|
|
177
174
|
try {
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
if (isFilterable && filter !== "") {
|
|
176
|
+
const li = Math.min(box.lines.length - 1, box.bodyTop)
|
|
177
|
+
const row = box.topRow + li
|
|
178
|
+
const leftPad = boxLeftPad(stripAnsi(box.lines[li] ?? ""))
|
|
179
|
+
const col = leftPad + 2 + displayWidth(stripAnsi(`${t("pick.filter")} ${filter}`)) + 1
|
|
180
|
+
process.stdout.write(`\x1b[${row};${Math.max(1, col)}H\x1b[?25h`)
|
|
181
|
+
} else {
|
|
182
|
+
const itemRow = Math.min(Math.max(0, sel - scroll), Math.max(0, visibleRows() - 1))
|
|
183
|
+
const bodyOffset = isFilterable ? 1 : 0
|
|
184
|
+
const li = Math.min(box.lines.length - 1, box.bodyTop + bodyOffset + itemRow)
|
|
185
|
+
const row = box.topRow + li
|
|
186
|
+
const leftPad = boxLeftPad(stripAnsi(box.lines[li] ?? ""))
|
|
187
|
+
process.stdout.write(`\x1b[${row};${Math.max(1, leftPad + 1)}H\x1b[?25h`)
|
|
188
|
+
}
|
|
180
189
|
} catch {}
|
|
181
190
|
}
|
|
182
191
|
|
|
@@ -224,9 +233,21 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
224
233
|
try {
|
|
225
234
|
opts.onCancel()
|
|
226
235
|
} catch {}
|
|
236
|
+
// Tutup layar sebelum batal: openAltScreen sudah menulis ENTER fisik
|
|
237
|
+
// (?1049h) — bail tanpa close membocorkan alt-screen (terminal tertinggal
|
|
238
|
+
// di buffer alternatif) dan hold painter-nya (I27) tidak pernah lepas.
|
|
239
|
+
try {
|
|
240
|
+
screen.close()
|
|
241
|
+
} catch {}
|
|
227
242
|
resolve()
|
|
228
243
|
return
|
|
229
244
|
}
|
|
245
|
+
// Raw mode (sama seperti askLine/askSecret): picker juga menghalangi
|
|
246
|
+
// painter transient stderr melukis di baris yang sama. Jalur ini aktif
|
|
247
|
+
// bahkan saat runPicker dipanggil langsung (bukan lewat wizard), misalnya
|
|
248
|
+
// di bawah alt-screen App yang painter-nya sudah ditahan — hold nested dan
|
|
249
|
+
// release-nya idempoten.
|
|
250
|
+
const endScreen = beginInteractiveScreen()
|
|
230
251
|
const cleanup = () => {
|
|
231
252
|
if (done) return
|
|
232
253
|
done = true
|
|
@@ -237,6 +258,9 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
237
258
|
process.stdin.setMaxListeners(prevMaxListeners)
|
|
238
259
|
} catch {}
|
|
239
260
|
if (idleTimer) clearTimeout(idleTimer)
|
|
261
|
+
// Lepas kepemilikan layar: painter boleh melukis lagi setelah ini
|
|
262
|
+
// (kursor sudah kembali ke anchor, overlay sudah dibersihkan).
|
|
263
|
+
endScreen()
|
|
240
264
|
// Hapus region popup sendiri; pemilik layar (App.resume) repaint penuh,
|
|
241
265
|
// standalone (wizard) membuang alt-buffer utuh via close.
|
|
242
266
|
try {
|
|
@@ -11,14 +11,13 @@ import {
|
|
|
11
11
|
} from "../input/prompt-engine.ts"
|
|
12
12
|
import { sanitizeAnsiLine } from "../render/sanitize.ts"
|
|
13
13
|
import { c, glyphs, stripAnsi } from "../render/theme.ts"
|
|
14
|
-
import { padToWidth, truncateToWidth } from "../render/width.ts"
|
|
14
|
+
import { displayWidth, padToWidth, truncateToWidth } from "../render/width.ts"
|
|
15
15
|
import { type AltScreen, openAltScreen } from "../runtime/screen.ts"
|
|
16
16
|
import { boxLeftPad, dialogBox } from "./dialog.ts"
|
|
17
17
|
import { runForm, validateRequired, validateUrl } from "./form.ts"
|
|
18
18
|
import { runPicker } from "./picker.ts"
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
RESTORE = "\x1b[22m"
|
|
20
|
+
const dim = (s: string): string => c.dim(s)
|
|
22
21
|
|
|
23
22
|
/** Lebar kotak popup provider TETAP (lebih lebar: kolom URL panjang). */
|
|
24
23
|
const PROVIDER_BOX_W = 76
|
|
@@ -109,7 +108,7 @@ export async function runProviderManagerView(opts: ProviderManagerViewOptions):
|
|
|
109
108
|
const rows = providers.slice(scroll, scroll + v)
|
|
110
109
|
const lines: string[] = []
|
|
111
110
|
if (providers.length === 0) {
|
|
112
|
-
lines.push(cut(
|
|
111
|
+
lines.push(cut(dim(` ${t("prov.empty")}`)))
|
|
113
112
|
} else {
|
|
114
113
|
for (let i = 0; i < rows.length; i++) {
|
|
115
114
|
const it = rows[i]!
|
|
@@ -120,19 +119,21 @@ export async function runProviderManagerView(opts: ProviderManagerViewOptions):
|
|
|
120
119
|
const aktif = opts.currentModel?.startsWith(`${it.id}::`)
|
|
121
120
|
? ` (${t("common.active")})`
|
|
122
121
|
: ""
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
// Status aktif TAK BOLEH ikut terpotong: URL dipotong dari budget
|
|
123
|
+
// sisa SETELAH head+aktif (dulu truncate menelan "(aktif)" dulu
|
|
124
|
+
// saat URL panjang — user tak tahu mana yang aktif).
|
|
125
|
+
const head = `${padToWidth(sanitizeAnsiLine(it.id), 18)} ${t("prov.models", { n: it.models })} `
|
|
126
|
+
const urlBudget = Math.max(8, w - 4 - displayWidth(head) - displayWidth(aktif))
|
|
127
|
+
const label = `${head}${truncateToWidth(sanitizeAnsiLine(it.baseUrl), urlBudget, "…")}${aktif}`
|
|
128
|
+
if (picked) lines.push(` ${c.accent("›")} ${c.accent(c.bold(label))}`)
|
|
129
|
+
else lines.push(` ${dim(label)}`)
|
|
129
130
|
}
|
|
130
131
|
if (providers.length > scroll + v) {
|
|
131
|
-
lines.push(cut(
|
|
132
|
+
lines.push(cut(dim(t("dlg.more", { n: providers.length - scroll - v }))))
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
// Struk transient (jalur legacy maupun modal).
|
|
135
|
-
if (notice) lines.push(cut(
|
|
136
|
+
if (notice) lines.push(cut(dim(sanitizeAnsiLine(notice))))
|
|
136
137
|
return lines
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -178,6 +179,11 @@ export async function runProviderManagerView(opts: ProviderManagerViewOptions):
|
|
|
178
179
|
try {
|
|
179
180
|
console.log(`⚠ ${t("gate.tuiProvider")}`)
|
|
180
181
|
} catch {}
|
|
182
|
+
// Tutup layar sebelum batal: openAltScreen sudah menulis ENTER fisik —
|
|
183
|
+
// bail tanpa close membocorkan alt-screen + hold painter (I27).
|
|
184
|
+
try {
|
|
185
|
+
screen.close()
|
|
186
|
+
} catch {}
|
|
181
187
|
resolve()
|
|
182
188
|
return
|
|
183
189
|
}
|
package/src/ui/screens/wizard.ts
CHANGED
|
@@ -22,6 +22,9 @@ export interface SetupWizardViewOptions {
|
|
|
22
22
|
onSubmit(baseUrl: string, apiKey: string): Promise<string>
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** Lebar kotak wizard TETAP (paritas picker/form/manager — tak bernapas antar langkah). */
|
|
26
|
+
const WIZARD_BOX_W = 64
|
|
27
|
+
|
|
25
28
|
/**
|
|
26
29
|
* Tunggu tanpa menahan process hidup (unref): jeda sukses/gagal wizard tak
|
|
27
30
|
* boleh menahan exit bila stdin sudah ditutup. Gagal-di-kode-lama: timer
|
|
@@ -46,6 +49,7 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
46
49
|
if (!process.stdin.isTTY) return false
|
|
47
50
|
const screen = openAltScreen()
|
|
48
51
|
if (!screen.ok) return false
|
|
52
|
+
let exitMsg: string | null = null
|
|
49
53
|
try {
|
|
50
54
|
const CUSTOM = "\u0000custom"
|
|
51
55
|
const items = [
|
|
@@ -67,14 +71,14 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
67
71
|
},
|
|
68
72
|
})
|
|
69
73
|
if (picked === null) {
|
|
70
|
-
|
|
74
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
71
75
|
return false
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
// URL via form dalam popup (validasi inline, bukan gagal saat detect).
|
|
75
79
|
const urlForm = await runForm(
|
|
76
80
|
{
|
|
77
|
-
title: t("wiz.
|
|
81
|
+
title: t("wiz.stepUrl"),
|
|
78
82
|
fields: [
|
|
79
83
|
{
|
|
80
84
|
id: "url",
|
|
@@ -92,13 +96,13 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
92
96
|
screen,
|
|
93
97
|
)
|
|
94
98
|
if (urlForm.cancelled || !urlForm.values) {
|
|
95
|
-
|
|
99
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
96
100
|
return false
|
|
97
101
|
}
|
|
98
102
|
const rawUrl = (urlForm.values.url ?? "").trim()
|
|
99
103
|
const targetUrl = rawUrl || (picked === CUSTOM ? "" : (picked as string))
|
|
100
104
|
if (!targetUrl) {
|
|
101
|
-
|
|
105
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
102
106
|
return false
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -109,7 +113,7 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
109
113
|
if (!lokal) {
|
|
110
114
|
const keyForm = await runForm(
|
|
111
115
|
{
|
|
112
|
-
title: t("wiz.
|
|
116
|
+
title: t("wiz.stepKey"),
|
|
113
117
|
fields: [
|
|
114
118
|
{
|
|
115
119
|
id: "key",
|
|
@@ -122,19 +126,24 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
122
126
|
screen,
|
|
123
127
|
)
|
|
124
128
|
if (keyForm.cancelled || !keyForm.values) {
|
|
125
|
-
|
|
129
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
126
130
|
return false
|
|
127
131
|
}
|
|
128
132
|
apiKey = (keyForm.values.key ?? "").trim()
|
|
129
133
|
if (!apiKey) {
|
|
130
|
-
|
|
134
|
+
exitMsg = `${t("wiz.keyLater")}\n`
|
|
131
135
|
return false
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
// Progres sebagai baris dalam kotak (bukan spinner liar di bawah popup).
|
|
136
140
|
const box = dialogBox(
|
|
137
|
-
{
|
|
141
|
+
{
|
|
142
|
+
title: t("wiz.title"),
|
|
143
|
+
body: [c.muted(t("wiz.detecting"))],
|
|
144
|
+
minWidth: WIZARD_BOX_W,
|
|
145
|
+
maxWidth: WIZARD_BOX_W,
|
|
146
|
+
},
|
|
138
147
|
screen.cols,
|
|
139
148
|
screen.rows,
|
|
140
149
|
)
|
|
@@ -147,6 +156,8 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
147
156
|
{
|
|
148
157
|
title: t("wiz.title"),
|
|
149
158
|
body: [`${glyphs.check} ${sanitizeAnsiLine(message)}`, "", t("wiz.done")],
|
|
159
|
+
minWidth: WIZARD_BOX_W,
|
|
160
|
+
maxWidth: WIZARD_BOX_W,
|
|
150
161
|
},
|
|
151
162
|
screen.cols,
|
|
152
163
|
screen.rows,
|
|
@@ -160,6 +171,8 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
160
171
|
{
|
|
161
172
|
title: t("wiz.title"),
|
|
162
173
|
body: [c.error(`${glyphs.cross} ${t("wiz.detectFail", { msg: formatError(e) })}`)],
|
|
174
|
+
minWidth: WIZARD_BOX_W,
|
|
175
|
+
maxWidth: WIZARD_BOX_W,
|
|
163
176
|
},
|
|
164
177
|
screen.cols,
|
|
165
178
|
screen.rows,
|
|
@@ -175,5 +188,8 @@ export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<
|
|
|
175
188
|
try {
|
|
176
189
|
screen.close()
|
|
177
190
|
} catch {}
|
|
191
|
+
if (exitMsg) {
|
|
192
|
+
process.stdout.write(exitMsg)
|
|
193
|
+
}
|
|
178
194
|
}
|
|
179
195
|
}
|