minicode-ai 0.11.1 → 0.13.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 +89 -0
- package/LICENSE +21 -21
- package/README.md +4 -4
- package/cli/args.ts +46 -0
- package/cli/commands/acp.ts +163 -10
- package/cli/commands/config.ts +33 -18
- package/cli/commands/daemon.ts +515 -0
- package/cli/commands/exec.ts +145 -53
- package/cli/commands/openwork.ts +986 -0
- package/cli/commands/sessions.ts +4 -1
- package/cli/commands/stats.ts +34 -4
- package/cli/commands.ts +217 -2
- package/cli/index.ts +146 -14
- package/cli/recovery-warning.ts +115 -0
- package/cli/router.ts +32 -1
- package/cli/setup.ts +2332 -171
- package/cli/tui.ts +113 -7
- package/docs/OUTPUT_ARCHITECTURE_AUDIT.md +489 -0
- package/docs/OUTPUT_EVENT_MODEL.md +289 -0
- package/docs/OUTPUT_IMPLEMENTATION_PLAN.md +391 -0
- package/docs/OUTPUT_PROTOCOL_SPEC.md +285 -0
- package/docs/OUTPUT_RENDERING_SPEC.md +248 -0
- package/docs/OUTPUT_UX_RULES.md +449 -0
- package/docs/PLAN_UIUX_V6.md +2 -2
- package/docs/README.md +4 -3
- package/docs/TERMINAL_CONTRACT.md +278 -71
- package/docs/architecture.md +89 -7
- package/docs/changelog.md +1 -1
- package/docs/choosing-mode.md +2 -2
- package/docs/cli.md +9 -5
- package/docs/concepts.md +1 -1
- package/docs/contributing.md +9 -2
- package/docs/environment.md +6 -2
- package/docs/exec.md +46 -5
- package/docs/memory-sessions.md +2 -0
- package/docs/policy-sandbox.md +1 -1
- package/docs/pricing-budget.md +1 -1
- package/docs/quickstart.md +2 -2
- package/docs/repl.md +6 -2
- package/docs/security-model.md +1 -1
- package/docs/security.md +1 -1
- package/docs/skills.md +2 -2
- package/docs/terminal.md +9 -5
- package/docs/tools.md +1 -1
- package/package.json +35 -5
- package/src/app/session.ts +261 -15
- package/src/app/tool-layer.ts +94 -7
- package/src/daemon/approvals.ts +361 -0
- package/src/daemon/capability.ts +145 -0
- package/src/daemon/children.ts +142 -0
- package/src/daemon/client.ts +267 -0
- package/src/daemon/control.ts +350 -0
- package/src/daemon/discovery.ts +234 -0
- package/src/daemon/feed.ts +155 -0
- package/src/daemon/framing.ts +94 -0
- package/src/daemon/host.ts +316 -0
- package/src/daemon/protocol.ts +217 -0
- package/src/daemon/resource.ts +170 -0
- package/src/daemon/sanitize.ts +57 -0
- package/src/daemon/server.ts +627 -0
- package/src/daemon/store.ts +317 -0
- package/src/daemon/subscription.ts +270 -0
- package/src/daemon/telemetry.ts +81 -0
- package/src/hooks/run.ts +12 -1
- package/src/lib/atomic-write.ts +29 -3
- package/src/lib/db-path.ts +26 -0
- package/src/lib/keystore.ts +544 -42
- package/src/lib/net.ts +43 -1
- package/src/lib/safe-open.ts +116 -1
- package/src/lib/session-id.ts +15 -0
- package/src/lsp/client.ts +123 -5
- package/src/mcp/client.ts +139 -17
- package/src/mcp/server.ts +177 -50
- package/src/mcp/transport.ts +16 -19
- package/src/memory/vector.ts +770 -55
- package/src/policy/allowlist.ts +14 -2
- package/src/policy/bash-guard.ts +105 -10
- package/src/policy/compaction.ts +82 -5
- package/src/policy/consequence-engine.ts +220 -0
- package/src/policy/context.ts +132 -0
- package/src/policy/executor.ts +187 -121
- package/src/policy/no-progress.ts +559 -0
- package/src/policy/permission.ts +4 -8
- package/src/policy/pricing.ts +17 -3
- package/src/policy/scrub.ts +69 -2
- package/src/policy/tool-contract.ts +515 -0
- package/src/policy/usage.ts +310 -24
- package/src/policy/verifier.ts +6 -3
- package/src/policy/work-mode.ts +182 -0
- package/src/presentation/adapter.ts +533 -26
- package/src/presentation/events.ts +151 -0
- package/src/presentation/model.ts +180 -27
- package/src/presentation/projection.ts +858 -0
- package/src/presentation/reducer.ts +645 -310
- package/src/presentation/store.ts +12 -7
- package/src/providers/anthropic.ts +18 -10
- package/src/providers/responses.ts +2 -2
- package/src/runtime/capability.ts +409 -0
- package/src/runtime/child-execution.ts +274 -0
- package/src/runtime/composition.ts +958 -0
- package/src/runtime/dispatch.ts +591 -0
- package/src/runtime/execution-backend.ts +632 -0
- package/src/runtime/execution-events.ts +272 -0
- package/src/runtime/execution-id.ts +230 -0
- package/src/runtime/execution-journal.ts +926 -0
- package/src/runtime/execution-kernel.ts +456 -0
- package/src/runtime/execution-registry.ts +379 -0
- package/src/runtime/process-supervision.ts +276 -0
- package/src/runtime/production-execution.ts +551 -0
- package/src/runtime/production-runtime.ts +217 -0
- package/src/runtime/recovery-safety.ts +70 -0
- package/src/runtime/recovery.ts +477 -0
- package/src/runtime/runtime-capabilities.ts +179 -0
- package/src/runtime/runtime-diagnostics.ts +141 -0
- package/src/runtime/runtime-host.ts +365 -0
- package/src/runtime/runtime-status-facts.ts +222 -0
- package/src/runtime/runtime-status-provider.ts +74 -0
- package/src/runtime/runtime-status.ts +459 -0
- package/src/runtime/runtime-task-admission.ts +101 -0
- package/src/runtime/supervisor.ts +444 -0
- package/src/session/authority.ts +168 -0
- package/src/session/checkpoint.ts +88 -1
- package/src/session/context-adapter.ts +251 -0
- package/src/session/context-assembly.ts +242 -0
- package/src/session/context-identity.ts +389 -0
- package/src/session/context-projection.ts +248 -0
- package/src/session/context-selector.ts +500 -0
- package/src/session/cross-session-adoption.ts +249 -0
- package/src/session/full-history-fold.ts +171 -0
- package/src/session/identity.ts +192 -0
- package/src/session/journal.ts +805 -102
- package/src/session/open-work-intent.ts +732 -0
- package/src/session/open-work.ts +767 -0
- package/src/session/pending-tools.ts +94 -0
- package/src/session/persistence.ts +3569 -127
- package/src/session/runtime-header.ts +208 -0
- package/src/session/shadow-git.ts +13 -5
- package/src/session/verification.ts +1623 -0
- package/src/task/assignment.ts +136 -0
- package/src/task/autonomous-adapter.ts +168 -0
- package/src/task/autonomous-context.ts +630 -0
- package/src/task/autonomous-policy.ts +490 -0
- package/src/task/continuity.ts +179 -0
- package/src/task/execution-cancellation.ts +165 -0
- package/src/task/graph-validate.ts +379 -0
- package/src/task/graph.ts +305 -0
- package/src/task/identity.ts +230 -0
- package/src/task/model.ts +417 -0
- package/src/task/production-scheduler.ts +293 -0
- package/src/task/readiness.ts +229 -0
- package/src/task/scheduler-observability.ts +387 -0
- package/src/task/scheduler.ts +1197 -0
- package/src/task/scheduling-policy.ts +165 -0
- package/src/task/session-authority.ts +148 -0
- package/src/task/session-ownership.ts +211 -0
- package/src/task/store.ts +2887 -0
- package/src/task/sync.ts +343 -0
- package/src/task/trigger.ts +260 -0
- package/src/tools/bash.ts +377 -211
- package/src/tools/code_run.ts +1 -1
- package/src/tools/delete_file.ts +1 -1
- package/src/tools/edit.ts +33 -6
- package/src/tools/evidence.ts +30 -0
- package/src/tools/git.ts +4 -4
- package/src/tools/glob.ts +12 -3
- package/src/tools/grep.ts +1 -1
- package/src/tools/lsp.ts +4 -4
- package/src/tools/mcp_call.ts +11 -4
- package/src/tools/memory.ts +153 -18
- package/src/tools/move_file.ts +1 -1
- package/src/tools/patch.ts +1 -1
- package/src/tools/read_file.ts +1 -1
- package/src/tools/read_image.ts +1 -1
- package/src/tools/submit_result.ts +1 -1
- package/src/tools/task.ts +437 -41
- package/src/tools/todo.ts +662 -35
- package/src/tools/web_fetch.ts +4 -2
- package/src/tools/web_search.ts +9 -3
- package/src/tools/write_file.ts +1 -1
- package/src/ui/assistant/simple.ts +123 -50
- package/src/ui/assistant/turn-status.ts +17 -3
- package/src/ui/contract.ts +184 -0
- package/src/ui/footer.ts +52 -19
- package/src/ui/i18n/en.ts +58 -6
- package/src/ui/i18n/id.ts +58 -6
- package/src/ui/input/prompt-engine.ts +120 -25
- package/src/ui/render/errors.ts +39 -1
- package/src/ui/render/markdown-table.ts +455 -0
- package/src/ui/render/markdown.ts +22 -1
- package/src/ui/render/table-grid.ts +184 -0
- package/src/ui/render/table.ts +15 -76
- package/src/ui/runtime/screen.ts +7 -2
- package/src/ui/runtime/statusline.ts +25 -6
- package/src/ui/tui/app.ts +507 -169
- package/src/ui/tui/transcript.ts +531 -89
- package/vendor/minicore/VENDOR.md +1 -1
- package/vendor/minicore/src/core/budget.ts +25 -25
- package/vendor/minicore/src/core/compact.ts +75 -75
- package/vendor/minicore/src/core/errors.ts +59 -59
- package/vendor/minicore/src/core/events.ts +73 -73
- package/vendor/minicore/src/core/executor.ts +139 -139
- package/vendor/minicore/src/core/history.ts +31 -31
- package/vendor/minicore/src/core/index.ts +41 -41
- package/vendor/minicore/src/core/loop.ts +355 -355
- package/vendor/minicore/src/core/permission.ts +22 -22
- package/vendor/minicore/src/core/provider.ts +39 -39
- package/vendor/minicore/src/core/recovery.ts +35 -35
- package/vendor/minicore/src/core/session.ts +327 -327
- package/vendor/minicore/src/core/snapshot.ts +146 -146
- package/vendor/minicore/src/core/tokens.ts +107 -107
- package/vendor/minicore/src/core/tool.ts +115 -115
- package/vendor/minicore/src/core/types.ts +50 -50
- package/vendor/minicore/src/providers/openai-compat.ts +417 -417
- package/AGENTS.md +0 -45
- package/PLAN.md +0 -491
- package/docs/ARCHITECTURE.html +0 -1248
- package/docs/CONTROL-PLANE-MAP.md +0 -139
- package/docs/HARNESS.md +0 -150
- package/docs/SUMMARY.md +0 -52
- package/docs/UI_RENDER_PIPELINE.md +0 -169
- package/docs/USAGE.md +0 -11
package/src/ui/render/table.ts
CHANGED
|
@@ -1,94 +1,33 @@
|
|
|
1
1
|
import { sanitizeAnsiLine } from "./sanitize.ts"
|
|
2
|
+
import { renderGridTable } from "./table-grid.ts"
|
|
2
3
|
import { c, getTerminalWidth } from "./theme.ts"
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
export { renderGridTable, renderMarkdownTable, renderMarkdownTableLines } from "./table-grid.ts"
|
|
4
6
|
|
|
5
7
|
export interface ColumnDef {
|
|
6
8
|
header: string
|
|
7
|
-
/** Lebar kolom dalam KOLOM terminal sebagai BATAS KERAS; isi lebih panjang dipotong "…". */
|
|
8
9
|
width?: number
|
|
9
10
|
key: string
|
|
10
|
-
align?: "left" | "right"
|
|
11
|
+
align?: "left" | "right" | "center"
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const AUTO_MAX = 50
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Nilai sel siap tampil: newline/tab/karakter kontrol dibuang.
|
|
19
|
-
*
|
|
20
|
-
* Satu newline dalam nilai memecah baris tabel menjadi dua dan seluruh
|
|
21
|
-
* kolom setelahnya bergeser — pemanggil (`config list`, `providers`, `skills`)
|
|
22
|
-
* mengambil nilai dari config/frontmatter yang bisa berisi apa pun.
|
|
23
|
-
*/
|
|
24
|
-
function sanitizeCell(v: unknown): string {
|
|
25
|
-
const s = v == null ? "" : String(v)
|
|
26
|
-
// Sekuens non-SGR dibuang, SGR dipertahankan — sel tabel bisa berisi data tidak terpercaya.
|
|
27
|
-
return sanitizeAnsiLine(s)
|
|
14
|
+
function cleanCell(value: unknown): string {
|
|
15
|
+
return sanitizeAnsiLine(value == null ? "" : String(value))
|
|
28
16
|
.replace(/[\t\v\f\u0085\u2028\u2029]/g, " ")
|
|
29
17
|
.replace(/\r/g, " ")
|
|
30
18
|
}
|
|
31
19
|
|
|
32
|
-
// Table minimal - kolom aligned + separator header, tanpa border.
|
|
33
20
|
export function renderTable(columns: ColumnDef[], data: Record<string, unknown>[]): string {
|
|
34
21
|
if (columns.length === 0) return c.muted("(no columns)")
|
|
35
22
|
if (data.length === 0) return c.muted("(no entries)")
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (termW < 40 && columns.length > 3) {
|
|
46
|
-
return data
|
|
47
|
-
.map((row) =>
|
|
48
|
-
columns
|
|
49
|
-
.map((col, ci) => {
|
|
50
|
-
// Nilai dipotong dari sisa budget SETELAH header: tanpa ini
|
|
51
|
-
// header+": "+value pasti > termW di terminal sempit (jalur
|
|
52
|
-
// penyelamat yang malah wrap sendiri).
|
|
53
|
-
const budget = Math.max(4, termW - displayWidth(heads[ci] ?? "") - 2)
|
|
54
|
-
return `${c.bold(heads[ci] ?? "")}: ${truncateToWidth(sanitizeCell(row[col.key]), budget, ELLIPSIS)}`
|
|
55
|
-
})
|
|
56
|
-
.join("\n"),
|
|
57
|
-
)
|
|
58
|
-
.join("\n\n")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// `width` yang dideklarasikan adalah batas keras dalam KOLOM terminal
|
|
62
|
-
// (CJK/emoji dihitung dua). Sebelumnya ia hanya MINIMUM dan diukur per
|
|
63
|
-
// karakter, sehingga satu nilai panjang mendorong kolom melebar dan header
|
|
64
|
-
// berhenti berbaris dengan body.
|
|
65
|
-
const widths = columns.map((col, i) => {
|
|
66
|
-
// Nilai negatif/NaN dari pemanggil tidak boleh membuat "".repeat() melempar.
|
|
67
|
-
if (col.width != null && Number.isFinite(col.width)) return Math.max(0, Math.trunc(col.width))
|
|
68
|
-
let max = displayWidth(heads[i] ?? "")
|
|
69
|
-
for (const row of cells) {
|
|
70
|
-
const w = displayWidth(row[i] ?? "")
|
|
71
|
-
if (w > max) max = w
|
|
72
|
-
}
|
|
73
|
-
// AUTO_MAX dihormati, tapi di terminal sempit kurangi agar tidak overflow.
|
|
74
|
-
const budget = Math.max(10, Math.floor((termW - columns.length * 3) / columns.length))
|
|
75
|
-
return Math.min(max, Math.min(AUTO_MAX, budget))
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
const cell = (text: string, width: number, align: "left" | "right" = "left"): string =>
|
|
79
|
-
padToWidth(truncateToWidth(text, width, ELLIPSIS), width, align)
|
|
80
|
-
|
|
81
|
-
const header = columns
|
|
82
|
-
.map((col, i) => ` ${c.bold(c.accent(cell(heads[i] ?? "", widths[i]!, col.align)))} `)
|
|
83
|
-
.join(" ")
|
|
84
|
-
|
|
85
|
-
// Separator (─ antara header dan body). Lebarnya harus SAMA dengan baris
|
|
86
|
-
// data: tiap sel adalah " isi " (width+2) dan antar sel disatukan satu spasi.
|
|
87
|
-
const sep = c.dim(widths.map((w) => "─".repeat(w + 2)).join(" "))
|
|
88
|
-
|
|
89
|
-
const rows = cells.map((row) =>
|
|
90
|
-
columns.map((col, i) => ` ${cell(row[i] ?? "", widths[i]!, col.align)} `).join(" "),
|
|
23
|
+
const rows = data.map((row) => columns.map((column) => cleanCell(row[column.key])))
|
|
24
|
+
return renderGridTable(
|
|
25
|
+
{
|
|
26
|
+
headers: columns.map((column) => cleanCell(column.header)),
|
|
27
|
+
rows,
|
|
28
|
+
aligns: columns.map((column) => column.align ?? "left"),
|
|
29
|
+
widths: columns.map((column) => column.width),
|
|
30
|
+
},
|
|
31
|
+
{ width: getTerminalWidth(), maxCellWidth: 50, styleHeader: true },
|
|
91
32
|
)
|
|
92
|
-
|
|
93
|
-
return [sep, header, ...rows].join("\n")
|
|
94
33
|
}
|
package/src/ui/runtime/screen.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface AltScreen {
|
|
|
55
55
|
readonly cols: number
|
|
56
56
|
readonly rows: number
|
|
57
57
|
/** Lukis satu frame penuh (tepat `rows` baris dari dialog.ts). */
|
|
58
|
-
paint(lines: string[]): void
|
|
58
|
+
paint(lines: string[], cursor?: { row: number; col: number }): void
|
|
59
59
|
/**
|
|
60
60
|
* Lukis REGION TANPA clear: popup di atas konten pemilik layar (App TUI).
|
|
61
61
|
* Tiap baris ditulis di `topRow+i` (1-based) setelah hapus-baris; baris di
|
|
@@ -128,13 +128,18 @@ export function openAltScreen(): AltScreen {
|
|
|
128
128
|
get rows() {
|
|
129
129
|
return process.stdout.rows || NULL_ROWS
|
|
130
130
|
},
|
|
131
|
-
paint(lines: string[]): void {
|
|
131
|
+
paint(lines: string[], cursor?: { row: number; col: number }): void {
|
|
132
132
|
if (closed) return
|
|
133
133
|
try {
|
|
134
134
|
process.stdout.write(SYNC_START)
|
|
135
135
|
process.stdout.write(HOME)
|
|
136
136
|
process.stdout.write(CLEAR_ALL)
|
|
137
137
|
process.stdout.write(lines.join("\r\n"))
|
|
138
|
+
if (cursor) {
|
|
139
|
+
const row = Math.max(1, Math.floor(cursor.row))
|
|
140
|
+
const col = Math.max(1, Math.floor(cursor.col))
|
|
141
|
+
process.stdout.write(`\x1b[?25l\x1b[${row};${col}H\x1b[?25h`)
|
|
142
|
+
}
|
|
138
143
|
process.stdout.write(SYNC_END)
|
|
139
144
|
} catch {}
|
|
140
145
|
},
|
|
@@ -85,18 +85,37 @@ function ensureWrap(): void {
|
|
|
85
85
|
const cur = process.stderr.write
|
|
86
86
|
if (ourWrite && (cur as unknown) === ourWrite) return
|
|
87
87
|
origWrite = process.stderr.write
|
|
88
|
-
|
|
88
|
+
// Target tulis yang dibungkus INI, disimpan di CLOSURE wrapper (bukan
|
|
89
|
+
// variabel modul `bound`).
|
|
90
|
+
//
|
|
91
|
+
// Kenapa closure: wrapper bisa tetap hidup di rantai writer stderr setelah
|
|
92
|
+
// state modul di-reset — test lain boleh membungkus writer yang sedang
|
|
93
|
+
// terpasang lalu mengembalikannya (pola `write.bind(write)`), sehingga wrapper
|
|
94
|
+
// lama ini masih dirujuk saat `bound` sudah dinolkan. Kalau wrapper membaca
|
|
95
|
+
// `bound` dari modul, tulis asing setelah reset melempar "bound is not a
|
|
96
|
+
// function" — pesan diagnostik hilang bersama turn. Dengan target per-install,
|
|
97
|
+
// wrapper lama tetap menulis ke TUJUANNYA (tanpa kehilangan maupun duplikasi
|
|
98
|
+
// byte), kapan pun dipanggil.
|
|
99
|
+
//
|
|
100
|
+
// `target` di-bind ke `process.stderr` (bukan detached): Bun Windows memanggil
|
|
101
|
+
// `this[kWriteMonkeyPatchDefense]` di writeFast → detached melempar TypeError.
|
|
102
|
+
const target = process.stderr.write.bind(process.stderr) as RawWrite
|
|
103
|
+
bound = target
|
|
89
104
|
ourWrite = ((chunk: string | Uint8Array, ...rest: never[]) => {
|
|
90
105
|
if (ownerWriting || !owner) {
|
|
91
106
|
try {
|
|
92
|
-
return
|
|
107
|
+
return target(chunk, ...rest)
|
|
93
108
|
} catch (e) {
|
|
94
109
|
// Runtime stderr rusak (bug Bun di atas): jangan gagalkan tulis
|
|
95
|
-
// diagnostik — matikan transient lalu coba sekali via
|
|
110
|
+
// diagnostik — matikan transient lalu coba sekali lagi via leaf yang
|
|
111
|
+
// sama (method-call, `this` = process.stderr).
|
|
96
112
|
if (isBunWriteBug(e)) {
|
|
97
113
|
disableTransient()
|
|
98
114
|
try {
|
|
99
|
-
|
|
115
|
+
// Leaf install-time (`target`) — BUKAN writer yang terpasang:
|
|
116
|
+
// bila writer terpasang masih wrapper ini, memanggilnya akan
|
|
117
|
+
// memanggil wrapper yang sama lagi (rekursi).
|
|
118
|
+
return target(chunk, ...rest)
|
|
100
119
|
} catch {
|
|
101
120
|
return false
|
|
102
121
|
}
|
|
@@ -107,13 +126,13 @@ function ensureWrap(): void {
|
|
|
107
126
|
// Tulis ASING saat garis transient aktif: komit sebagai baris permanen.
|
|
108
127
|
ownerWriting = true
|
|
109
128
|
try {
|
|
110
|
-
|
|
129
|
+
target("\r\x1b[2K")
|
|
111
130
|
} finally {
|
|
112
131
|
ownerWriting = false
|
|
113
132
|
}
|
|
114
133
|
let r: boolean
|
|
115
134
|
try {
|
|
116
|
-
r =
|
|
135
|
+
r = target(chunk, ...rest)
|
|
117
136
|
} catch (e) {
|
|
118
137
|
if (isBunWriteBug(e)) {
|
|
119
138
|
disableTransient()
|