minicode-ai 0.15.0 → 0.20.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 +6 -4
- package/cli/commands/exec.ts +3 -2
- package/cli/commands/openwork.ts +1 -1
- package/cli/commands.ts +6 -6
- package/cli/index.ts +4 -4
- package/cli/model-manager.ts +1 -1
- package/cli/setup.ts +57 -30
- package/cli/tui.ts +106 -11
- package/docs/CONTROL-PLANE-MAP.md +6 -4
- package/docs/OUTPUT_EVENT_MODEL.md +4 -3
- package/docs/OUTPUT_PROTOCOL_SPEC.md +1 -1
- package/docs/OUTPUT_RENDERING_SPEC.md +16 -4
- package/docs/OUTPUT_UX_RULES.md +38 -32
- package/docs/P14_OPEN_WORK.md +290 -0
- package/docs/README.md +1 -1
- package/docs/SUMMARY.md +36 -22
- package/docs/TERMINAL_CONTRACT.md +54 -7
- package/docs/UI_RENDER_PIPELINE.md +47 -8
- package/docs/agents.md +1 -1
- package/docs/architecture.md +9 -8
- package/docs/autonomous-scheduler.md +142 -0
- package/docs/choosing-mode.md +2 -2
- package/docs/cli.md +4 -4
- package/docs/concepts.md +5 -5
- package/docs/config-providers.md +3 -3
- package/docs/contributing.md +7 -9
- package/docs/environment.md +5 -4
- package/docs/getting-started.md +4 -4
- package/docs/mcp-lsp.md +2 -2
- package/docs/memory-sessions.md +1 -1
- package/docs/policy-sandbox.md +7 -4
- package/docs/pricing-budget.md +3 -3
- package/docs/quickstart.md +1 -1
- package/docs/repl.md +5 -5
- package/docs/security-model.md +1 -1
- package/docs/security.md +9 -8
- package/docs/skills.md +2 -2
- package/docs/terminal.md +10 -2
- package/docs/tools.md +4 -4
- package/docs/troubleshooting.md +3 -3
- package/docs/verify-benchmark.md +0 -3
- package/package.json +9 -18
- package/src/app/session.ts +40 -7
- package/src/constants.ts +31 -0
- package/src/hooks/run.ts +5 -6
- package/src/mcp/http-transport.ts +1 -1
- package/src/policy/bash-guard.ts +26 -6
- package/src/policy/compaction.ts +107 -17
- package/src/policy/consequence-engine.ts +3 -3
- package/src/policy/context-window.ts +24 -1
- package/src/policy/context.ts +16 -4
- package/src/policy/permission.ts +219 -4
- package/src/presentation/adapter.ts +1 -1
- package/src/presentation/events.ts +2 -2
- package/src/presentation/label.ts +3 -3
- package/src/presentation/model.ts +4 -0
- package/src/presentation/store.ts +2 -2
- package/src/runtime/child-execution.ts +1 -1
- package/src/runtime/composition.ts +5 -5
- package/src/runtime/execution-registry.ts +1 -1
- package/src/runtime/production-execution.ts +3 -3
- package/src/runtime/production-runtime.ts +2 -2
- package/src/runtime/runtime-capabilities.ts +1 -1
- package/src/runtime/runtime-status-facts.ts +1 -1
- package/src/runtime/runtime-task-admission.ts +2 -2
- package/src/session/context-assembly.ts +8 -1
- package/src/session/context-identity.ts +2 -2
- package/src/session/context-projection.ts +36 -11
- package/src/session/persistence.ts +1 -1
- package/src/task/autonomous-context.ts +2 -2
- package/src/task/autonomous-policy.ts +3 -3
- package/src/task/model.ts +2 -2
- package/src/task/production-scheduler.ts +2 -2
- package/src/task/scheduler.ts +3 -2
- package/src/task/scheduling-policy.ts +2 -1
- package/src/task/trigger.ts +5 -5
- package/src/tools/read_image.ts +2 -1
- package/src/tools/task.ts +1 -1
- package/src/ui/assistant/simple.ts +33 -30
- package/src/ui/footer.ts +48 -9
- package/src/ui/i18n/en.ts +1 -0
- package/src/ui/i18n/id.ts +1 -0
- package/src/ui/input/prompt-engine.ts +36 -10
- package/src/ui/render/cells.ts +320 -0
- package/src/ui/render/composer-wrap.ts +73 -0
- package/src/ui/render/detail.ts +2 -2
- package/src/ui/render/ledger.ts +47 -0
- package/src/ui/render/theme.ts +32 -4
- package/src/ui/render/width.ts +2 -2
- package/src/ui/render/wrap.ts +5 -3
- package/src/ui/runtime/screen.ts +84 -7
- package/src/ui/runtime/statusline.ts +26 -0
- package/src/ui/screens/model-manager.ts +1 -1
- package/src/ui/tui/app.ts +336 -65
- package/src/ui/tui/transcript.ts +247 -88
- package/vendor/minicore/VENDOR.md +15 -11
- package/vendor/minicore/src/core/events.ts +1 -0
- package/vendor/minicore/src/core/loop.ts +10 -0
- package/vendor/minicore/src/core/session.ts +39 -0
package/src/ui/runtime/screen.ts
CHANGED
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
// try { ... screen.paint(frame) ... } finally { screen.close() }
|
|
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
|
-
import {
|
|
12
|
+
import { type Cell, diffCellLine, parseCells } from "../render/cells.ts"
|
|
13
|
+
import {
|
|
14
|
+
__resetTransientForTest,
|
|
15
|
+
beginInteractiveScreen,
|
|
16
|
+
consumeScreenDrift,
|
|
17
|
+
} from "./statusline.ts"
|
|
13
18
|
|
|
14
19
|
const ENTER = "\x1b[?1049h"
|
|
15
20
|
const EXIT = "\x1b[?1049l"
|
|
@@ -69,6 +74,12 @@ export interface AltScreen {
|
|
|
69
74
|
readonly rows: number
|
|
70
75
|
/** Lukis frame penuh; exception writer dipropagasikan agar owner menutup sesi. */
|
|
71
76
|
paint(lines: string[], cursor?: { row: number; col: number }): void
|
|
77
|
+
/**
|
|
78
|
+
* Pindahkan kursor SAJA, tanpa menyentuh isi frame. Dipakai fast path
|
|
79
|
+
* panah/Home/End: pergerakan kursor tak mengubah satu sel pun, jadi
|
|
80
|
+
* merakit ulang frame penuh hanya membuang kerja.
|
|
81
|
+
*/
|
|
82
|
+
moveCursor(row: number, col: number): void
|
|
72
83
|
/**
|
|
73
84
|
* Lukis REGION TANPA clear: popup di atas konten pemilik layar (App TUI).
|
|
74
85
|
* Tiap baris ditulis di `topRow+i` (1-based) setelah hapus-baris; baris di
|
|
@@ -97,6 +108,7 @@ function nullScreen(): AltScreen {
|
|
|
97
108
|
cols: process.stdout.columns || NULL_COLS,
|
|
98
109
|
rows: process.stdout.rows || NULL_ROWS,
|
|
99
110
|
paint: () => {},
|
|
111
|
+
moveCursor: () => {},
|
|
100
112
|
paintRegion: () => {},
|
|
101
113
|
clearRegion: () => {},
|
|
102
114
|
close: () => {},
|
|
@@ -138,6 +150,17 @@ export function openAltScreen(): AltScreen {
|
|
|
138
150
|
// (closure), bukan global: popup nested (effort di dalam manager) melacak
|
|
139
151
|
// areanya masing-masing.
|
|
140
152
|
let lastRegion: { top: number; height: number } | null = null
|
|
153
|
+
// [perf] Frame LOGIS tetap penuh (`rows` baris — kontrak I1); yang di-diff
|
|
154
|
+
// hanyalah PENULISAN FISIK. Diff dilakukan per SEL (bukan per baris): prefix
|
|
155
|
+
// yang identik dilewati, lalu ekor dari kolom berbeda pertama ditulis ulang
|
|
156
|
+
// setelah EL (lihat diffCellLine). Satu huruf berubah di prompt panjang hanya
|
|
157
|
+
// menulis ekornya, bukan seluruh baris. Inisialisasi/resize (jumlah
|
|
158
|
+
// baris/kolom berubah) tetap clear penuh.
|
|
159
|
+
// Per-handle (closure): screen baru = diff state baru, konsisten dengan
|
|
160
|
+
// `lastRegion`.
|
|
161
|
+
let lastFrame: string[] | null = null
|
|
162
|
+
let lastCells: Cell[][] | null = null
|
|
163
|
+
let lastCols = 0
|
|
141
164
|
return {
|
|
142
165
|
ok: true,
|
|
143
166
|
// Getter LIVE (bukan snapshot saat open) — resize di tengah modal wajib
|
|
@@ -151,16 +174,60 @@ export function openAltScreen(): AltScreen {
|
|
|
151
174
|
},
|
|
152
175
|
paint(lines: string[], cursor?: { row: number; col: number }): void {
|
|
153
176
|
if (closed) return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
// SATU string per frame = SATU `write` ke pipe ConPTY. Sebelumnya frame
|
|
178
|
+
// dipecah 4–5 write (sync-start, tiap baris, kursor, sync-end); di
|
|
179
|
+
// Windows tiap write menyeberangi ConPTY dan biayanya jauh lebih mahal
|
|
180
|
+
// daripada merakit string di JS.
|
|
181
|
+
let out = SYNC_START
|
|
182
|
+
const cols = process.stdout.columns || NULL_COLS
|
|
183
|
+
// Tulis asing ke stderr (diagnostik/hooks) mengotori buffer di balik
|
|
184
|
+
// pelacakan diff; paksa repaint penuh sekali agar tak ada fragmen asing
|
|
185
|
+
// yang menempel di baris yang kebetulan tak berubah.
|
|
186
|
+
const drifted = consumeScreenDrift()
|
|
187
|
+
if (
|
|
188
|
+
!drifted &&
|
|
189
|
+
lastFrame &&
|
|
190
|
+
lastCells &&
|
|
191
|
+
lastFrame.length === lines.length &&
|
|
192
|
+
lastCols === cols
|
|
193
|
+
) {
|
|
194
|
+
// Diff per sel. Bandingkan string baris dulu (murah); hanya baris yang
|
|
195
|
+
// berubah yang di-parse menjadi sel dan di-diff. Baris tak berubah =
|
|
196
|
+
// nol byte, bukan CUP+EL+seluruh baris.
|
|
197
|
+
for (let r = 0; r < lines.length; r++) {
|
|
198
|
+
const line = lines[r]!
|
|
199
|
+
if (line === lastFrame[r]) continue
|
|
200
|
+
const nextCells = parseCells(line)
|
|
201
|
+
out += diffCellLine(lastCells[r] ?? [], nextCells, r + 1)
|
|
202
|
+
lastCells[r] = nextCells
|
|
203
|
+
lastFrame[r] = line
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
out += HOME + CLEAR_ALL + lines.join("\r\n")
|
|
207
|
+
lastFrame = lines.slice()
|
|
208
|
+
lastCells = lines.map((line) => parseCells(line))
|
|
209
|
+
lastCols = cols
|
|
210
|
+
}
|
|
211
|
+
// Reset atribut sebelum kursor: run diff bisa berakhir dengan warna
|
|
212
|
+
// aktif, dan kursor yang ditampilkan mewarisi atribut itu.
|
|
213
|
+
out += RESET_ATTRS
|
|
158
214
|
if (cursor) {
|
|
159
215
|
const row = Math.max(1, Math.floor(cursor.row))
|
|
160
216
|
const col = Math.max(1, Math.floor(cursor.col))
|
|
161
|
-
|
|
217
|
+
out += `\x1b[?25l\x1b[${row};${col}H\x1b[?25h`
|
|
162
218
|
}
|
|
163
|
-
|
|
219
|
+
out += SYNC_END
|
|
220
|
+
process.stdout.write(out)
|
|
221
|
+
},
|
|
222
|
+
moveCursor(row: number, col: number): void {
|
|
223
|
+
if (closed) return
|
|
224
|
+
const r = Math.max(1, Math.floor(row))
|
|
225
|
+
const c = Math.max(1, Math.floor(col))
|
|
226
|
+
// Sync block + reset atribut: kursor tak boleh mewarisi warna run
|
|
227
|
+
// sebelumnya, dan perpindahan kursor tak perlu menyentuh satu sel pun.
|
|
228
|
+
process.stdout.write(
|
|
229
|
+
`${SYNC_START}${RESET_ATTRS}\x1b[?25l\x1b[${r};${c}H\x1b[?25h${SYNC_END}`,
|
|
230
|
+
)
|
|
164
231
|
},
|
|
165
232
|
paintRegion(lines: string[], topRow: number): void {
|
|
166
233
|
if (closed) return
|
|
@@ -189,6 +256,11 @@ export function openAltScreen(): AltScreen {
|
|
|
189
256
|
out += SYNC_END
|
|
190
257
|
process.stdout.write(out)
|
|
191
258
|
lastRegion = h > 0 ? { top, height: h } : null
|
|
259
|
+
// Region menimpa isi frame di luar pelacakan diff; paksa paint berikutnya
|
|
260
|
+
// clear penuh agar sisa popup tidak tertinggal sebagai baris hantu.
|
|
261
|
+
lastFrame = null
|
|
262
|
+
lastCells = null
|
|
263
|
+
lastCols = 0
|
|
192
264
|
},
|
|
193
265
|
clearRegion(): void {
|
|
194
266
|
if (closed) return
|
|
@@ -202,6 +274,11 @@ export function openAltScreen(): AltScreen {
|
|
|
202
274
|
process.stdout.write(out)
|
|
203
275
|
} catch {}
|
|
204
276
|
lastRegion = null
|
|
277
|
+
// Area popup sudah dihapus, tetapi isi frame di bawahnya tidak lagi
|
|
278
|
+
// tercermin di `lastCells`; paint berikutnya harus penuh.
|
|
279
|
+
lastFrame = null
|
|
280
|
+
lastCells = null
|
|
281
|
+
lastCols = 0
|
|
205
282
|
},
|
|
206
283
|
close(): void {
|
|
207
284
|
if (closed) return
|
|
@@ -23,6 +23,12 @@ let ourWrite: ((chunk: string | Uint8Array, ...rest: never[]) => boolean) | null
|
|
|
23
23
|
/** Write asli sebelum wrapper dipasang — untuk restore saat self-disable. */
|
|
24
24
|
let origWrite: typeof process.stderr.write | null = null
|
|
25
25
|
const warnedOverlap = new Set<string>()
|
|
26
|
+
// Penulis ASING ke stderr selama alt-screen hidup mengotori buffer terminal di
|
|
27
|
+
// luar kendali layar (mis. `[hooks] skipped …`, warning provider). Karena layar
|
|
28
|
+
// kini menulis inkremental (diff), baris yang tak berubah TIDAK ditulis ulang —
|
|
29
|
+
// tanpa sinyal ini, sampah asing menempel permanen. Layar mengonsumsi sinyal
|
|
30
|
+
// ini dan memaksa repaint penuh pada paint berikutnya.
|
|
31
|
+
let screenDrift = false
|
|
26
32
|
|
|
27
33
|
// Bun Windows (1.4.x): `stderr.write` yang dilepas dari method (bound/detached)
|
|
28
34
|
// melempar `TypeError: undefined is not an object (evaluating
|
|
@@ -73,6 +79,17 @@ export function __resetTransientForTest(): void {
|
|
|
73
79
|
transientBroken = false
|
|
74
80
|
warnedOverlap.clear()
|
|
75
81
|
screenDepth = 0
|
|
82
|
+
screenDrift = false
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Konsumsi sinyal "terminal dikotori tulis asing". Mengembalikan true sekali
|
|
87
|
+
* lalu membersihkan; layar memakainya untuk memaksa repaint penuh.
|
|
88
|
+
*/
|
|
89
|
+
export function consumeScreenDrift(): boolean {
|
|
90
|
+
const drift = screenDrift
|
|
91
|
+
screenDrift = false
|
|
92
|
+
return drift
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
// Pasang wrapper stderr HANYA bila owner transient pertama muncul. Wrapper
|
|
@@ -102,6 +119,10 @@ function ensureWrap(): void {
|
|
|
102
119
|
const target = process.stderr.write.bind(process.stderr) as RawWrite
|
|
103
120
|
bound = target
|
|
104
121
|
ourWrite = ((chunk: string | Uint8Array, ...rest: never[]) => {
|
|
122
|
+
// Tulis asing (bukan dari painter internal) saat layar alt memegang
|
|
123
|
+
// terminal: tandai kotor. `paintWrite` menyetel `ownerWriting` sehingga
|
|
124
|
+
// jalur internal tak pernah menandai dirinya sendiri.
|
|
125
|
+
if (!ownerWriting && screenDepth > 0) screenDrift = true
|
|
105
126
|
if (ownerWriting || !owner) {
|
|
106
127
|
try {
|
|
107
128
|
return target(chunk, ...rest)
|
|
@@ -177,6 +198,11 @@ let screenDepth = 0
|
|
|
177
198
|
* subcommand TTY, dan suspend yang sudah dihapus bersama driver linier.
|
|
178
199
|
*/
|
|
179
200
|
export function beginInteractiveScreen(): () => void {
|
|
201
|
+
// Pasang wrapper stderr saat alt-screen pertama mengambil alih: tanpa owner
|
|
202
|
+
// transient (mode TUI tak selalu punya), wrapper inert tidak terpasang, dan
|
|
203
|
+
// tulis asing ke stderr tak terdeteksi — padahal justru itu yang mengotori
|
|
204
|
+
// buffer di balik diff layar.
|
|
205
|
+
if (screenDepth === 0) ensureWrap()
|
|
180
206
|
// Baris painter terakhir dibersihkan SEKARANG (kursor masih persis di sana),
|
|
181
207
|
// sebelum layar menulis byte pertamanya — dan SEBELUM depth naik, karena
|
|
182
208
|
// paintWrite menolak menulis saat layar sudah aktif. Tanpa ini teks spinner
|
|
@@ -365,7 +365,7 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
// Picker effort dipakai alur Enter — HANYA bila modelnya mendukung
|
|
368
|
-
// (lihat
|
|
368
|
+
// (lihat callback `opts.getEfforts`): model tanpa thinking langsung select tanpa
|
|
369
369
|
// picker dan tanpa menyentuh effort tersimpan. Dipanggil saat manager
|
|
370
370
|
// di-suspend, sehingga raw mode/lisener milik picker, bukan manager.
|
|
371
371
|
const pickEffort = (
|