minicode-ai 0.22.0 → 0.25.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/README.md +2 -2
- package/cli/commands.ts +10 -0
- package/cli/index.ts +11 -0
- package/cli/setup.ts +64 -33
- package/cli/tui.ts +29 -3
- package/docs/README.md +2 -2
- package/docs/SUMMARY.md +10 -19
- package/docs/TERMINAL_CONTRACT.md +119 -32
- package/docs/architecture.md +1 -1
- package/docs/autonomous-scheduler.md +283 -2
- package/docs/choosing-mode.md +4 -4
- package/docs/concepts.md +39 -3
- package/docs/config.md +90 -4
- package/docs/environment.md +6 -0
- package/docs/getting-started.md +58 -2
- package/docs/repl.md +1 -1
- package/docs/security.md +49 -2
- package/docs/tools.md +2 -1
- package/package.json +2 -36
- package/src/app/provider-layer.ts +1 -1
- package/src/app/session.ts +129 -20
- package/src/config.ts +102 -2
- package/src/constants.ts +32 -4
- package/src/lib/safe-open.ts +21 -12
- package/src/memory/vector.ts +0 -31
- package/src/policy/compaction.ts +27 -0
- package/src/policy/context-budget.ts +132 -0
- package/src/policy/context-escalation.ts +140 -0
- package/src/policy/context-window.ts +14 -9
- package/src/policy/context.ts +10 -1
- package/src/policy/microcompact.ts +162 -0
- package/src/policy/no-progress.ts +1 -1
- package/src/policy/permission.ts +5 -0
- package/src/policy/scrub.ts +15 -2
- package/src/policy/tool-contract.ts +11 -9
- package/src/presentation/reducer.ts +1 -0
- package/src/providers/anthropic.ts +17 -3
- package/src/providers/detect.ts +155 -13
- package/src/providers/provision.ts +92 -1
- package/src/providers/responses.ts +13 -1
- package/src/session/persistence.ts +56 -0
- package/src/task/autonomous-policy.ts +7 -0
- package/src/task/graph-validate.ts +1 -1
- package/src/task/session-authority.ts +0 -5
- package/src/task/store.ts +0 -4
- package/src/tools/ask_user.ts +14 -1
- package/src/tools/bash.ts +57 -9
- package/src/tools/context.ts +10 -0
- package/src/tools/delete_file.ts +3 -2
- package/src/tools/edit.ts +5 -4
- package/src/tools/git.ts +70 -12
- package/src/tools/glob.ts +13 -5
- package/src/tools/grep.ts +26 -10
- package/src/tools/index.ts +3 -2
- package/src/tools/lsp.ts +15 -9
- package/src/tools/move_file.ts +4 -3
- package/src/tools/patch.ts +5 -4
- package/src/tools/read_file.ts +3 -2
- package/src/tools/read_image.ts +3 -2
- package/src/tools/task.ts +1 -0
- package/src/tools/todo.ts +4 -8
- package/src/tools/write_file.ts +4 -3
- package/src/ui/approval/prompt.ts +226 -77
- package/src/ui/assistant/simple.ts +1 -1
- package/src/ui/footer.ts +41 -29
- package/src/ui/i18n/en.ts +23 -4
- package/src/ui/i18n/id.ts +25 -4
- package/src/ui/input/input.ts +2 -2
- package/src/ui/render/activity-group.ts +1 -0
- package/src/ui/render/activity-panel.ts +21 -3
- package/src/ui/render/hint.ts +28 -0
- package/src/ui/render/ledger.ts +1 -9
- package/src/ui/render/logo.ts +86 -0
- package/src/ui/render/markdown-table.ts +0 -3
- package/src/ui/render/session-summary.ts +22 -1
- package/src/ui/render/table-grid.ts +0 -3
- package/src/ui/render/theme.ts +36 -5
- package/src/ui/runtime/screen.ts +11 -3
- package/src/ui/screens/dialog.ts +45 -81
- package/src/ui/screens/form.ts +29 -33
- package/src/ui/screens/lifecycle.ts +80 -0
- package/src/ui/screens/model-manager.ts +84 -91
- package/src/ui/screens/picker.ts +36 -33
- package/src/ui/screens/provider-manager.ts +50 -59
- package/src/ui/screens/watchdog.ts +27 -0
- package/src/ui/screens/wizard.ts +3 -20
- package/src/ui/tui/app.ts +97 -11
- package/src/ui/tui/transcript.ts +55 -16
- package/vendor/minicore/src/core/compact.ts +10 -0
- package/vendor/minicore/src/core/errors.ts +11 -1
- package/vendor/minicore/src/core/executor.ts +6 -1
- package/vendor/minicore/src/core/loop.ts +92 -2
- package/vendor/minicore/src/core/session.ts +8 -0
- package/vendor/minicore/src/providers/openai-compat.ts +15 -2
- package/docs/P14_OPEN_WORK.md +0 -290
- package/docs/config-providers.md +0 -87
- package/docs/glossary.md +0 -39
- package/docs/quickstart.md +0 -60
- package/docs/security-model.md +0 -96
- package/docs/terminal.md +0 -91
package/src/ui/i18n/id.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const id: Record<MsgKey, string> = {
|
|
|
26
26
|
"appr.decAllow": "izinkan",
|
|
27
27
|
"appr.decAlways": "selalu",
|
|
28
28
|
"appr.decDeny": "tolak",
|
|
29
|
+
"appr.keyHint": "↑↓ pindah · Enter pilih · Esc batal",
|
|
29
30
|
"appr.askTitle": "Agen bertanya",
|
|
30
31
|
"appr.a11y": "[butuh persetujuan: {name}]",
|
|
31
32
|
"appr.answerPrompt": "Jawaban (kosong = batal): ",
|
|
@@ -38,9 +39,17 @@ export const id: Record<MsgKey, string> = {
|
|
|
38
39
|
"appr.tier.unknown": "efek tidak diketahui",
|
|
39
40
|
"dlg.more": "… {n} lagi",
|
|
40
41
|
"ts.compacted": "… dipadatkan: {reason}",
|
|
42
|
+
"ts.compactedNoOp":
|
|
43
|
+
"… dipadatkan: tidak ada yang bisa dibuang ({reason}) — konteks tidak menyusut",
|
|
44
|
+
"ts.compactedFixpoint":
|
|
45
|
+
"… kompaksi berhenti: target tak tercapai meski hanya {kept} pesan tersisa",
|
|
46
|
+
"ts.compactedImpossible":
|
|
47
|
+
"… kompaksi mustahil: instruksi tetap + skema tool ({fixed}) sudah melebihi ambang {trigger}",
|
|
48
|
+
"ts.compactedLlmFailed": "… ringkasan LLM gagal ({reason}), memakai ringkasan mekanikal",
|
|
49
|
+
"ts.contextWindowSource": "konteks {tokens} token ({source})",
|
|
41
50
|
"ts.providerAttemptDiscarded": "percobaan provider {attempt} gagal; output parsial dibuang",
|
|
42
51
|
"ts.thinking": "… berpikir",
|
|
43
|
-
"ts.evictMarker": "… {n} baris awal di luar viewport
|
|
52
|
+
"ts.evictMarker": "… {n} baris awal di luar viewport",
|
|
44
53
|
"ts.statusRunning": "berjalan",
|
|
45
54
|
"ts.statusCompleted": "selesai",
|
|
46
55
|
"ts.statusFailed": "gagal",
|
|
@@ -73,7 +82,7 @@ export const id: Record<MsgKey, string> = {
|
|
|
73
82
|
"model.del": 'Hapus model "{id}"?',
|
|
74
83
|
"model.failOpen": "model manager gagal dibuka: {msg}",
|
|
75
84
|
"effort.title": "Upaya berpikir",
|
|
76
|
-
"effort.saved": "
|
|
85
|
+
"effort.saved": "Upaya berpikir: {effort} (sesi berikut)",
|
|
77
86
|
"prov.empty": "Belum ada penyedia",
|
|
78
87
|
"prov.addTitle": "Tambah penyedia",
|
|
79
88
|
"prov.customUrl": "URL kustom",
|
|
@@ -129,11 +138,20 @@ export const id: Record<MsgKey, string> = {
|
|
|
129
138
|
"st.input": " Masukan: {v} (pemakaian provider)",
|
|
130
139
|
"st.output": " Keluaran: {v} (pemakaian provider)",
|
|
131
140
|
"st.total": " Total: {v} (kumulatif sesi)",
|
|
141
|
+
"st.cache": " Cache: {read} hit · {write} tulis (prompt cache)",
|
|
132
142
|
"st.cost": " Biaya: {v} (estimasi tabel harga)",
|
|
133
143
|
"st.budget": " Budget: {v}{extra}",
|
|
134
144
|
"st.costUnknown": " (biaya tak diketahui — model tanpa harga)",
|
|
135
145
|
"help.head": "Perintah:",
|
|
136
146
|
"help.keysLine": "Mouse wheel/PgUp/PgDn gulir (Shift = ½) · /help tombol = semua pintasan",
|
|
147
|
+
"hint.move": "gerak",
|
|
148
|
+
"hint.select": "pilih",
|
|
149
|
+
"hint.close": "tutup",
|
|
150
|
+
"hint.filter": "saring",
|
|
151
|
+
"hint.delete": "hapus",
|
|
152
|
+
"hint.edit": "ubah",
|
|
153
|
+
"hint.add": "tambah",
|
|
154
|
+
"hint.effort": "upaya",
|
|
137
155
|
"help.cHead": "Perintah:",
|
|
138
156
|
"help.cKeys":
|
|
139
157
|
"Tombol: Tab work-mode · Shift+Tab izin · ↑↓ riwayat · Mouse wheel/PgUp/PgDn gulir · Ctrl+R cari · Ctrl+D keluar",
|
|
@@ -240,8 +258,11 @@ export const id: Record<MsgKey, string> = {
|
|
|
240
258
|
"tui.workModeLine": "mode kerja: {m}",
|
|
241
259
|
"tui.workModeUsage": "pemakaian: /work-mode <DISCUSS|PLAN|BUILD> — aktif: {m}",
|
|
242
260
|
"tui.workModeUnavailable": "work mode tidak tersedia di sesi ini",
|
|
243
|
-
"tui.unrestrictedOn": "
|
|
244
|
-
"tui.unrestrictedOff": "
|
|
261
|
+
"tui.unrestrictedOn": "mode unrestricted aktif - akses penuh",
|
|
262
|
+
"tui.unrestrictedOff": "unrestricted nonaktif — mode izin kembali ke {m}",
|
|
263
|
+
"tui.bgFinished": "job background {id} selesai (exit {code})",
|
|
264
|
+
"tui.bgFinishedAuto":
|
|
265
|
+
"job background {id} selesai dengan exit code {code}. Lanjutkan pekerjaan yang tadi tanpa menunggu saya: ambil output job lewat bash_output bila relevan, verifikasi hasilnya, lalu selesaikan tugas yang tersisa.",
|
|
245
266
|
"tui.langLine": "lang: {v}",
|
|
246
267
|
"tui.toolCall": "pemanggilan tool: {v}",
|
|
247
268
|
"tui.modelSet": "model: {v}",
|
package/src/ui/input/input.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { homedir } from "node:os"
|
|
|
3
3
|
import { join } from "node:path"
|
|
4
4
|
import { createInterface } from "node:readline"
|
|
5
5
|
import { t } from "../i18n/locale.ts"
|
|
6
|
-
import { stripAnsi } from "../render/theme.ts"
|
|
6
|
+
import { glyphs, stripAnsi } from "../render/theme.ts"
|
|
7
7
|
import { displayWidth, escapeLength, truncateToWidth } from "../render/width.ts"
|
|
8
8
|
import { beginInteractiveScreen } from "../runtime/statusline.ts"
|
|
9
9
|
import {
|
|
@@ -877,7 +877,7 @@ export async function askSecret(
|
|
|
877
877
|
.replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, "")
|
|
878
878
|
if (clean) {
|
|
879
879
|
secret += clean
|
|
880
|
-
process.stdout.write(
|
|
880
|
+
process.stdout.write(glyphs.mask.repeat(toGraphemes(clean).length))
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
883
|
}
|
|
@@ -10,6 +10,7 @@ import type { UiPresentationActivity } from "../contract.ts"
|
|
|
10
10
|
import { t } from "../i18n/locale.ts"
|
|
11
11
|
import { activityGroup } from "./activity-group.ts"
|
|
12
12
|
import { sanitizeAnsiLine, stripSgr } from "./sanitize.ts"
|
|
13
|
+
import { c } from "./theme.ts"
|
|
13
14
|
import { truncateToWidth } from "./width.ts"
|
|
14
15
|
/** Satu grup teragregasi (dipakai renderer + /expand buffer). */
|
|
15
16
|
export interface ActivityGroupView {
|
|
@@ -22,6 +23,8 @@ export interface ActivityGroupView {
|
|
|
22
23
|
denied: number
|
|
23
24
|
/** Nama tool pertama (indikator; sudah tersanitasi & terpotong). */
|
|
24
25
|
names: string[]
|
|
26
|
+
/** Total nama tool unik (sebelum dibatasi 3) untuk penanda `+N`. */
|
|
27
|
+
nameTotal: number
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
const MAX_PANEL_LABEL = 40
|
|
@@ -32,12 +35,15 @@ export function groupActivities(
|
|
|
32
35
|
activities: readonly UiPresentationActivity[],
|
|
33
36
|
): Map<string, ActivityGroupView> {
|
|
34
37
|
const groups = new Map<string, ActivityGroupView>()
|
|
38
|
+
// Nama unik per grup (untuk penanda `+N` saat > 3 nama berbeda).
|
|
39
|
+
const uniqueNames = new Map<string, Set<string>>()
|
|
35
40
|
for (const a of activities) {
|
|
36
41
|
const kind = activityGroup(a.name)
|
|
37
42
|
let g = groups.get(kind)
|
|
38
43
|
if (!g) {
|
|
39
|
-
g = { kind, count: 0, ok: 0, failed: 0, running: 0, denied: 0, names: [] }
|
|
44
|
+
g = { kind, count: 0, ok: 0, failed: 0, running: 0, denied: 0, names: [], nameTotal: 0 }
|
|
40
45
|
groups.set(kind, g)
|
|
46
|
+
uniqueNames.set(kind, new Set())
|
|
41
47
|
}
|
|
42
48
|
g.count++
|
|
43
49
|
const status = a.status
|
|
@@ -48,11 +54,21 @@ export function groupActivities(
|
|
|
48
54
|
// Nama tool dari model/provider = input tak-terpercaya: buang SEMUA ANSI
|
|
49
55
|
// (termasuk SGR) saat masuk — styling ditambahkan renderer sendiri.
|
|
50
56
|
const cleanName = stripSgr(sanitizeAnsiLine(a.name))
|
|
57
|
+
const seen = uniqueNames.get(kind)!
|
|
58
|
+
seen.add(cleanName)
|
|
59
|
+
g.nameTotal = seen.size
|
|
51
60
|
if (g.names.length < 3 && !g.names.includes(cleanName)) g.names.push(cleanName)
|
|
52
61
|
}
|
|
53
62
|
return groups
|
|
54
63
|
}
|
|
55
64
|
|
|
65
|
+
/** Warna grup: gagal → merah, ditolak → kuning, sisanya → redup (tenang). */
|
|
66
|
+
function groupPaint(g: ActivityGroupView): (s: string) => string {
|
|
67
|
+
if (g.failed > 0) return c.error
|
|
68
|
+
if (g.denied > 0) return c.warning
|
|
69
|
+
return c.muted
|
|
70
|
+
}
|
|
71
|
+
|
|
56
72
|
/** Satu baris grup (`+ explore · 3 tools · 2 ok · 1 failed`). */
|
|
57
73
|
export function groupLine(g: ActivityGroupView): string {
|
|
58
74
|
// Kunci i18n literal (bukan template) — MsgKey adalah union, bukan string.
|
|
@@ -69,8 +85,10 @@ export function groupLine(g: ActivityGroupView): string {
|
|
|
69
85
|
if (g.failed > 0) parts.push(t("panel.failed", { n: g.failed }))
|
|
70
86
|
if (g.running > 0) parts.push(t("panel.running", { n: g.running }))
|
|
71
87
|
const names = g.names.map((n) => sanitizeAnsiLine(n)).join(", ")
|
|
72
|
-
|
|
73
|
-
|
|
88
|
+
const more = Math.max(0, g.nameTotal - g.names.length)
|
|
89
|
+
if (names)
|
|
90
|
+
parts.push(`· ${truncateToWidth(names, MAX_PANEL_LABEL, "…")}${more > 0 ? ` +${more}` : ""}`)
|
|
91
|
+
return groupPaint(g)(parts.join(" "))
|
|
74
92
|
}
|
|
75
93
|
|
|
76
94
|
/** Baris panel lengkap (header + satu baris per grup). Kosong bila tak ada
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Petunjuk aksi minimalis untuk jendela pilihan / manager / form.
|
|
2
|
+
//
|
|
3
|
+
// Bentuk sengaja "a add" (bukan "a: add"): kunci pendek, pemisah satu SPASI,
|
|
4
|
+
// label redup — kunci yang bisa ditekan lebih terang. Ini menyeragamkan seluruh
|
|
5
|
+
// jendela MiniCode yang sebelumnya menulis hint dengan gaya berbeda-beda
|
|
6
|
+
// ("a add · d delete" vs footer form vs tanpa hint sama sekali), dan tetap
|
|
7
|
+
// mematuhi kontrak v7.8 (tanpa judul, tanpa footer dekoratif di dalam kotak):
|
|
8
|
+
// hint ditaruh sebagai baris body paling bawah, bukan chrome kotak.
|
|
9
|
+
import { c } from "../render/theme.ts"
|
|
10
|
+
|
|
11
|
+
export interface HintItem {
|
|
12
|
+
/** Tombol yang benar-benar berlaku di permukaan ini. */
|
|
13
|
+
key: string
|
|
14
|
+
/** Label pendek, title case/lowercase mengikuti bahasa. */
|
|
15
|
+
label: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Warna kunci (lebih terang) vs label (redup) — aksesibel tanpa warna. */
|
|
19
|
+
export function paintHint(item: HintItem): string {
|
|
20
|
+
return `${c.accent(item.key)} ${c.dim(item.label)}`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Satu baris hint: `a add · d hapus · Esc tutup` (tanpa awalan/akhiran).
|
|
24
|
+
* Tanpa pembungkus faint di seluruh baris: itu akan meredupkan KUNCI juga
|
|
25
|
+
* (SGR 2 tak dibatalkan warna). Kunci = accent (lebih terang), label = dim. */
|
|
26
|
+
export function hintLine(items: readonly HintItem[]): string {
|
|
27
|
+
return items.map(paintHint).join(` ${c.faint("·")} `)
|
|
28
|
+
}
|
package/src/ui/render/ledger.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// pemotongan lebar tetap di sisi pemanggil.
|
|
8
8
|
import type { UiToolStatus } from "../contract.ts"
|
|
9
9
|
import { t } from "../i18n/locale.ts"
|
|
10
|
-
import { c
|
|
10
|
+
import { c } from "./theme.ts"
|
|
11
11
|
|
|
12
12
|
/** Kata status lokal ("completed"/"failed"/dst.) — fallback non-warna. */
|
|
13
13
|
export function statusWord(status: UiToolStatus): string {
|
|
@@ -19,14 +19,6 @@ export function statusWord(status: UiToolStatus): string {
|
|
|
19
19
|
return t("ts.statusRunning")
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
/** Glyph status (ASCII-aman via `glyphs`). */
|
|
23
|
-
export function statusGlyph(status: UiToolStatus): string {
|
|
24
|
-
if (status === "completed") return glyphs.check
|
|
25
|
-
if (status === "failed") return glyphs.cross
|
|
26
|
-
if (status === "denied") return glyphs.denied
|
|
27
|
-
return glyphs.circle
|
|
28
|
-
}
|
|
29
|
-
|
|
30
22
|
/** Warna baris ledger berdasar status terminal (sukses/error/denied/lain). */
|
|
31
23
|
export function paintLedger(status: UiToolStatus, line: string): string {
|
|
32
24
|
if (status === "failed") return c.error(line)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Block logo minicode: mark wordmark pemilik, dikonversi dari SVG vektor
|
|
2
|
+
// (CorelDRAW) menjadi grid 17 kolom × 9 baris sel.
|
|
3
|
+
//
|
|
4
|
+
// ASPEK PER-SEL — inti modul ini. Satu karakter terminal TIDAK persegi:
|
|
5
|
+
// tingginya ±2× lebarnya. Menggambar satu sel = satu karakter penuh membuat
|
|
6
|
+
// setiap "kotak" logo tampak persegi panjang (tinggi > lebar). Solusi: setiap
|
|
7
|
+
// sel logis dipetakan ke SETENGAH sel karakter (upper/lower half block), yang
|
|
8
|
+
// kotak tintanya persegi di terminal tipikal (lebar 1 kolom, tinggi ½ baris).
|
|
9
|
+
//
|
|
10
|
+
// Komposisi 2 sel logis bertumpuk → 1 baris karakter, memakai glyph set yang
|
|
11
|
+
// sudah ada (U+2580–U+2584):
|
|
12
|
+
// atas∅ bawah∅ → ' '
|
|
13
|
+
// atas█ bawah█ → '█' (kedua sel terisi)
|
|
14
|
+
// atas█ bawah∅ → '▀' (hanya sel atas)
|
|
15
|
+
// atas∅ bawah█ → '▄' (hanya sel bawah)
|
|
16
|
+
// Hasil: 17 kolom × 5 baris karakter (baris terakhir hanya berisi sel ke-9,
|
|
17
|
+
// karena tinggi logis 9 sel — ganjil). Rasio kotak fisik ≈ 17:9, sama dengan
|
|
18
|
+
// SVG asli; tidak lagi "dipipihkan" seperti blok karakter penuh.
|
|
19
|
+
//
|
|
20
|
+
// Fallback: terminal tanpa UTF-8 (MINICODE_ASCII/mini console legacy) memakai
|
|
21
|
+
// '#' 9 baris — aspek setengah-sel tidak tersedia di sana, jadi bentuk penuh
|
|
22
|
+
// dipertahankan agar pola tidak terpotong.
|
|
23
|
+
//
|
|
24
|
+
// Dimensi DIVERIFIKASI terhadap SVG (viewBox 8418.09 × 4456.66): 8418.09 =
|
|
25
|
+
// 495.18 × 17 kolom, 4456.66 = 495.18 × 9 baris (sel seragam 495.18²).
|
|
26
|
+
// Setiap '#' = satu sel terisi (75 polygon → 75 sel).
|
|
27
|
+
|
|
28
|
+
import { supportsUtf8 } from "./theme.ts"
|
|
29
|
+
|
|
30
|
+
const ROWS = [
|
|
31
|
+
" ##### ",
|
|
32
|
+
" ### #######",
|
|
33
|
+
"##### ## ##",
|
|
34
|
+
"## ### ## ##",
|
|
35
|
+
"## ## ##",
|
|
36
|
+
"## ## ##",
|
|
37
|
+
"## ## ### ##",
|
|
38
|
+
"###### ### ###",
|
|
39
|
+
" #### ##### ",
|
|
40
|
+
] as const
|
|
41
|
+
|
|
42
|
+
/** Dimensi logis logo (sel), untuk pemanggil yang butuh geometri/centering. */
|
|
43
|
+
export const LOGO_WIDTH = 17
|
|
44
|
+
export const LOGO_HEIGHT = 9
|
|
45
|
+
|
|
46
|
+
/** Glyph sel terisi (fallback ASCII). */
|
|
47
|
+
export function logoBlock(): string {
|
|
48
|
+
return supportsUtf8() ? "█" : "#"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Apakah terminal mampu glyph half-block (U+2580/U+2584/U+2588)? */
|
|
52
|
+
export function supportsHalfBlocks(): boolean {
|
|
53
|
+
return supportsUtf8()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function halfLine(top: string, bottom: string): string {
|
|
57
|
+
let out = ""
|
|
58
|
+
for (let x = 0; x < LOGO_WIDTH; x++) {
|
|
59
|
+
const up = top[x] === "#"
|
|
60
|
+
const down = bottom[x] === "#"
|
|
61
|
+
if (up && down) out += "█"
|
|
62
|
+
else if (up) out += "▀"
|
|
63
|
+
else if (down) out += "▄"
|
|
64
|
+
else out += " "
|
|
65
|
+
}
|
|
66
|
+
return out
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Baris logo, kotak-per-sel:
|
|
71
|
+
* - UTF-8: gabungkan 2 sel logis per baris dengan glyph half-block (5 baris).
|
|
72
|
+
* - ASCII/legacy: tetap 1 sel per karakter (9 baris) supaya pola tidak hilang.
|
|
73
|
+
*/
|
|
74
|
+
export function renderLogoRows(): string[] {
|
|
75
|
+
if (!supportsUtf8()) {
|
|
76
|
+
const block = logoBlock()
|
|
77
|
+
return ROWS.map((row) => row.replace(/#/g, block))
|
|
78
|
+
}
|
|
79
|
+
const out: string[] = []
|
|
80
|
+
for (let y = 0; y < ROWS.length; y += 2) {
|
|
81
|
+
const top = ROWS[y] ?? " ".repeat(LOGO_WIDTH)
|
|
82
|
+
const bottom = ROWS[y + 1] ?? " ".repeat(LOGO_WIDTH)
|
|
83
|
+
out.push(halfLine(top, bottom))
|
|
84
|
+
}
|
|
85
|
+
return out
|
|
86
|
+
}
|
|
@@ -294,9 +294,6 @@ export function parseMarkdownTable(
|
|
|
294
294
|
return parseMarkdownBlocks(source).find((block) => block.type === "table")?.table ?? null
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
export const parsePipeTable = parseMarkdownTable
|
|
298
|
-
export const parseMarkdownPipeTable = parseMarkdownTable
|
|
299
|
-
|
|
300
297
|
export function parseMarkdownTables(input: string): MarkdownTable[] {
|
|
301
298
|
return parseMarkdownBlocks(input)
|
|
302
299
|
.filter((block): block is Extract<MarkdownBlock, { type: "table" }> => block.type === "table")
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// via `c` menjamin selalu terlihat + hormati NO_COLOR.
|
|
10
10
|
|
|
11
11
|
import { t } from "../i18n/locale.ts"
|
|
12
|
+
import { renderLogoRows } from "./logo.ts"
|
|
12
13
|
import { formatUsd } from "./money.ts"
|
|
13
14
|
import { sanitizeAnsiLine, stripSgr } from "./sanitize.ts"
|
|
14
15
|
import { c } from "./theme.ts"
|
|
@@ -20,12 +21,22 @@ function paintWordmark(): string {
|
|
|
20
21
|
return c.bold(WORDMARK)
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
/** Block logo pemilik (9×19) dicat dengan aksen brand — jatuh ke plain saat
|
|
25
|
+
* NO_COLOR, dan ke '#' saat terminal tanpa UTF-8 (fallback di logo.ts). */
|
|
26
|
+
function paintLogo(): string[] {
|
|
27
|
+
return renderLogoRows().map((row) => c.accent(row))
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
export interface SessionSummary {
|
|
24
31
|
sessionId: string
|
|
25
32
|
model: string
|
|
26
33
|
totalTokens: number
|
|
27
34
|
cost?: number
|
|
28
35
|
durationMs: number
|
|
36
|
+
/** Input token (Fase 7 ukur): penyebut hit-rate cache. */
|
|
37
|
+
inputTokens?: number
|
|
38
|
+
/** Token yang dibaca dari prompt cache (Fase 7 ukur). 0/undefined = nol. */
|
|
39
|
+
cacheReadTokens?: number
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
/** "3m 12s" / "1m 5s" / "45s" untuk durasi manusia. */
|
|
@@ -40,17 +51,27 @@ export function renderSessionSummary(s: SessionSummary): string {
|
|
|
40
51
|
// Parameter dinamai `text`, bukan `t`: `t` sudah dipakai untuk i18n.
|
|
41
52
|
const label = (text: string): string => c.muted(text.padEnd(7))
|
|
42
53
|
const cost = s.cost != null ? formatUsd(s.cost) : null
|
|
54
|
+
// Fase 7 ukur: fraksi input dari cache; tampil hanya bila cache read > 0.
|
|
55
|
+
const cacheRead = s.cacheReadTokens ?? 0
|
|
56
|
+
const input = s.inputTokens ?? 0
|
|
57
|
+
const cachePart =
|
|
58
|
+
cacheRead > 0 && input > 0
|
|
59
|
+
? ` · cache ${cacheRead.toLocaleString()} (${Math.round((cacheRead / input) * 100)}%)`
|
|
60
|
+
: ""
|
|
43
61
|
// sessionId/model = input tak-terpercaya (config/network): buang SEMUA ANSI
|
|
44
62
|
// (termasuk SGR) sebelum dibungkus style — nilai mentah hanya boleh muncul
|
|
45
63
|
// sebagai teks polos, styling ditambahkan pemanggil (aturan repo).
|
|
46
64
|
const clean = (v: string): string => stripSgr(sanitizeAnsiLine(v))
|
|
47
65
|
return `${[
|
|
66
|
+
"",
|
|
67
|
+
...paintLogo(),
|
|
68
|
+
"",
|
|
48
69
|
paintWordmark(),
|
|
49
70
|
`${label(t("summary.session"))} ${c.gray(clean(s.sessionId))}`,
|
|
50
71
|
`${label(t("summary.model"))} ${c.gray(clean(s.model))}`,
|
|
51
72
|
`${label(t("summary.usage"))} ${s.totalTokens.toLocaleString()} ${t("summary.tokens")}${
|
|
52
73
|
cost != null ? ` · ${cost}` : ""
|
|
53
|
-
} · ${formatDuration(s.durationMs)}`,
|
|
74
|
+
}${cachePart} · ${formatDuration(s.durationMs)}`,
|
|
54
75
|
]
|
|
55
76
|
.join("\r\n")
|
|
56
77
|
.concat("\r\n")}`
|
|
@@ -394,9 +394,6 @@ export function renderGridTable(table: GridTable, options: GridRenderOptions = {
|
|
|
394
394
|
return [separator, header.join(" "), ...rows.map((row) => row.join(" "))].join("\n")
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
export const renderTableGrid = renderGridTable
|
|
398
|
-
export const renderGrid = renderGridTable
|
|
399
|
-
|
|
400
397
|
export function renderMarkdownTable(
|
|
401
398
|
table: MarkdownTable,
|
|
402
399
|
width = getTerminalWidth(),
|
package/src/ui/render/theme.ts
CHANGED
|
@@ -47,12 +47,37 @@ function colorLevel(): number {
|
|
|
47
47
|
// Determinisme Unix: output ke pipe/redirect/file tidak boleh memuat ANSI,
|
|
48
48
|
// apa pun TERM/COLORTERM di env (env sesi interaktif sering bocor ke proses
|
|
49
49
|
// yang di-pipe). Warna hanya untuk stdout yang benar-benar terminal.
|
|
50
|
-
if (!process.stdout.isTTY) return 0
|
|
50
|
+
if (!process.stdout.isTTY || process.env.TERM?.toLowerCase() === "dumb") return 0
|
|
51
51
|
if (hasTruecolorEnv()) return 3
|
|
52
52
|
if (process.env.TERM?.includes("256color")) return 2
|
|
53
|
+
// Terminal/ConPTY sering tak mengisi TERM; env eksplisit di atas tetap menang.
|
|
54
|
+
try {
|
|
55
|
+
const depth = (
|
|
56
|
+
process.stdout as NodeJS.WriteStream & { getColorDepth?: () => number }
|
|
57
|
+
).getColorDepth?.()
|
|
58
|
+
if (depth != null && depth >= 24) return 3
|
|
59
|
+
if (depth != null && depth >= 8) return 2
|
|
60
|
+
} catch {}
|
|
53
61
|
return 1
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
export type ScrimMode = "bg" | "faint" | "none"
|
|
65
|
+
|
|
66
|
+
/** Mode scrim (lazy); tak menambah byte di pipe. */
|
|
67
|
+
export function scrimMode(): ScrimMode {
|
|
68
|
+
if (noColorEnv() || !process.stdout.isTTY || process.env.TERM?.toLowerCase() === "dumb")
|
|
69
|
+
return "none"
|
|
70
|
+
if (process.env.MINICODE_SCRIM === "none") return "faint"
|
|
71
|
+
return colorLevel() >= 2 ? "bg" : colorLevel() === 1 ? "faint" : "none"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** SGR pembuka scrim; pemanggil menjaga efek tetap hidup melewati reset konten. */
|
|
75
|
+
export function scrimSgr(mode: ScrimMode): string {
|
|
76
|
+
if (mode === "bg") return "\x1b[2;48;5;236m"
|
|
77
|
+
if (mode === "faint") return "\x1b[2m"
|
|
78
|
+
return ""
|
|
79
|
+
}
|
|
80
|
+
|
|
56
81
|
/**
|
|
57
82
|
* Kunci kapabilitas tampilan (level warna + glyph UTF-8) untuk cache render.
|
|
58
83
|
*
|
|
@@ -345,6 +370,11 @@ export const glyphs = {
|
|
|
345
370
|
get spinnerFrames() {
|
|
346
371
|
return supportsUtf8() ? ["·", "··", "···"] : [".", "..", "..."]
|
|
347
372
|
},
|
|
373
|
+
/** Karakter mask field secret (form & prompt inline) — satu sumber.
|
|
374
|
+
* Sengaja getter (bukan const): MINICODE_ASCII bisa berubah saat runtime. */
|
|
375
|
+
get mask() {
|
|
376
|
+
return supportsUtf8() ? "•" : "*"
|
|
377
|
+
},
|
|
348
378
|
// Blok progress bar loading (baris tunggal). Fallback ASCII untuk terminal
|
|
349
379
|
// tanpa UTF-8 (MINICODE_ASCII / konsol Windows legacy).
|
|
350
380
|
get blockFilled() {
|
|
@@ -359,13 +389,14 @@ export const glyphs = {
|
|
|
359
389
|
// Fallback * untuk terminal tanpa UTF-8.
|
|
360
390
|
return supportsUtf8() ? "✦" : "*"
|
|
361
391
|
},
|
|
362
|
-
//
|
|
363
|
-
//
|
|
392
|
+
// Badge bash allow-list (footer): titik monokrom, bukan emoji gembok —
|
|
393
|
+
// emoji berwarna dan lebarnya beda antar-font (kolom footer bergeser).
|
|
394
|
+
// ●/○ satu kolom dan tetap terbaca saat diwarnai; fallback teks ASCII.
|
|
364
395
|
get lock() {
|
|
365
|
-
return supportsUtf8() ? "
|
|
396
|
+
return supportsUtf8() ? "●" : "[LOCK]"
|
|
366
397
|
},
|
|
367
398
|
get unlock() {
|
|
368
|
-
return supportsUtf8() ? "
|
|
399
|
+
return supportsUtf8() ? "○" : "[OPEN]"
|
|
369
400
|
},
|
|
370
401
|
}
|
|
371
402
|
|
package/src/ui/runtime/screen.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// Refcount menutup modal nested (effort-picker di dalam manager): tulis
|
|
11
11
|
// enter/exit fisik hanya di lapis terluar; handle dalam = no-op paint-through.
|
|
12
12
|
import { type Cell, diffCellLine, parseCells } from "../render/cells.ts"
|
|
13
|
+
import { truncateToWidth } from "../render/width.ts"
|
|
13
14
|
import {
|
|
14
15
|
__resetTransientForTest,
|
|
15
16
|
beginInteractiveScreen,
|
|
@@ -214,7 +215,9 @@ export function openAltScreen(): AltScreen {
|
|
|
214
215
|
if (cursor) {
|
|
215
216
|
const row = Math.max(1, Math.floor(cursor.row))
|
|
216
217
|
const col = Math.max(1, Math.floor(cursor.col))
|
|
217
|
-
|
|
218
|
+
// DECSCUSR `6 q` = bar tegak stabil (tak berkedip): caret tak menutupi
|
|
219
|
+
// karakter di bawahnya (blok penuh), dan lebih tenang = clean & minimal.
|
|
220
|
+
out += `\x1b[?25l\x1b[${row};${col}H\x1b[6 q\x1b[?25h`
|
|
218
221
|
}
|
|
219
222
|
out += SYNC_END
|
|
220
223
|
process.stdout.write(out)
|
|
@@ -226,7 +229,7 @@ export function openAltScreen(): AltScreen {
|
|
|
226
229
|
// Sync block + reset atribut: kursor tak boleh mewarisi warna run
|
|
227
230
|
// sebelumnya, dan perpindahan kursor tak perlu menyentuh satu sel pun.
|
|
228
231
|
process.stdout.write(
|
|
229
|
-
`${SYNC_START}${RESET_ATTRS}\x1b[?25l\x1b[${r};${c}H\x1b[?25h${SYNC_END}`,
|
|
232
|
+
`${SYNC_START}${RESET_ATTRS}\x1b[?25l\x1b[${r};${c}H\x1b[6 q\x1b[?25h${SYNC_END}`,
|
|
230
233
|
)
|
|
231
234
|
},
|
|
232
235
|
paintRegion(lines: string[], topRow: number): void {
|
|
@@ -250,7 +253,12 @@ export function openAltScreen(): AltScreen {
|
|
|
250
253
|
const i = r - top
|
|
251
254
|
// Baris diasumsi satu-baris-tersanitasi dari dialogBox (tanpa \n —
|
|
252
255
|
// \n akan menggeser kursor dan merusak baris berikut; split defensif).
|
|
253
|
-
|
|
256
|
+
// Clamp ke lebar layar: baris lebih lebar memicu auto-wrap dan
|
|
257
|
+
// menggeser seluruh region (AUD-009).
|
|
258
|
+
const row = truncateToWidth(
|
|
259
|
+
i >= 0 && i < h ? ((lines[i] ?? "").split("\n")[0] ?? "") : "",
|
|
260
|
+
this.cols,
|
|
261
|
+
)
|
|
254
262
|
out += `\x1b[${r};1H\x1b[2K${row}`
|
|
255
263
|
}
|
|
256
264
|
out += SYNC_END
|