minicode-ai 0.11.0 → 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 +98 -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 -66
- 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 +17 -7
- 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 +54 -18
- package/src/ui/i18n/en.ts +62 -6
- package/src/ui/i18n/id.ts +62 -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 +598 -133
- 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 -165
- package/docs/USAGE.md +0 -11
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// P9.2.2.1 — Format baris peringatan recovery delegasi satu-shot.
|
|
2
|
+
//
|
|
3
|
+
// Modul murni tanpa efek samping: boleh diimpor test tanpa menjalankan CLI
|
|
4
|
+
// (cli/index.ts adalah skrip executable — formatter TAK BOLEH tinggal di
|
|
5
|
+
// sana). Warna tetap di boundary pemanggil (c.yellow), di sini teks polos.
|
|
6
|
+
// Nol penulis langsung (console/process.stdout) — jaga begitu agar
|
|
7
|
+
// inventaris writer tak berubah.
|
|
8
|
+
//
|
|
9
|
+
// Aturan tampilan: ringkasan anak adalah observasi model yang tak tepercaya.
|
|
10
|
+
// Secret sudah disanitasi saat persist (P9.2.1); di sini netralkan perilaku
|
|
11
|
+
// terminal (ANSI/escape/kontrol/baris) dengan helper mapan, BUKAN framework
|
|
12
|
+
// baru. Tak ada string di sini yang menjadi instruksi untuk model — ini
|
|
13
|
+
// stderr operator, bukan prompt.
|
|
14
|
+
import type { ChildStatus } from "../src/session/journal.ts"
|
|
15
|
+
import { isDisplayableChildStatus } from "../src/session/journal.ts"
|
|
16
|
+
import { sanitizeAnsiLine, stripSgr } from "../src/ui/render/sanitize.ts"
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Batas preview per anak (satuan code-unit UTF-16, konsisten dengan batas
|
|
20
|
+
* 2000 durable di verification.ts): ringkasan durable tak pernah dicetak
|
|
21
|
+
* utuh di baris peringatan. Nilai 240 menjaga satu baris tetap terbaca di
|
|
22
|
+
* terminal sempit bersama imbuhan status — display-only, bukan retensi.
|
|
23
|
+
*/
|
|
24
|
+
export const RECOVERY_PREVIEW_MAX = 240
|
|
25
|
+
|
|
26
|
+
/** Input minimal formatter: identitas + observasi tervalidasi (boleh absen). */
|
|
27
|
+
export interface DelegateRecoveryEntry {
|
|
28
|
+
readonly childSessionId: string
|
|
29
|
+
readonly childStatus?: ChildStatus
|
|
30
|
+
readonly resultSummary?: string
|
|
31
|
+
readonly truncated?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Hasil preview: teks final + dari mana pemotongan berasal (jujur dua sumbu). */
|
|
35
|
+
export interface RecoveryPreview {
|
|
36
|
+
readonly text: string
|
|
37
|
+
readonly displayTruncated: boolean
|
|
38
|
+
readonly persistedTruncated: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Potong ringkasan untuk satu baris terminal. Urutan mengikat (§7 misi):
|
|
43
|
+
* sanitasi display dulu, lalu batasi, lalu tandai, lalu pembungkus warna
|
|
44
|
+
* (di pemanggil). SGR dibuang juga (di luar warna pembungkus c.yellow —
|
|
45
|
+
* SGR anak tak boleh mengubah presentasi baris). Lone surrogate di ujung
|
|
46
|
+
* potongan dibuang (satu unit lebih pendek, bukan karakter rusak).
|
|
47
|
+
*/
|
|
48
|
+
export function boundRecoveryPreview(
|
|
49
|
+
summary: string,
|
|
50
|
+
persistedTruncated: boolean,
|
|
51
|
+
): RecoveryPreview {
|
|
52
|
+
// U+2028/U+2029 dinetralkan jadi spasi di sini (jalur display, BUKAN
|
|
53
|
+
// sanitizer global — preseden cleanCell di src/ui/render/table.ts:16):
|
|
54
|
+
// keduanya batas baris logis yang dipertahankan sanitizeAnsiLine, dan
|
|
55
|
+
// baris peringatan ini berkontrak satu baris fisik maupun logis.
|
|
56
|
+
const safe = stripSgr(sanitizeAnsiLine(summary)).replace(/[\u2028\u2029]/g, " ")
|
|
57
|
+
let text = safe
|
|
58
|
+
let cut = 0
|
|
59
|
+
if (text.length > RECOVERY_PREVIEW_MAX) {
|
|
60
|
+
cut = text.length - RECOVERY_PREVIEW_MAX
|
|
61
|
+
text = text.slice(0, RECOVERY_PREVIEW_MAX)
|
|
62
|
+
if (/[\uD800-\uDBFF]$/.test(text)) {
|
|
63
|
+
text = text.slice(0, -1)
|
|
64
|
+
cut += 1
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (cut > 0 && persistedTruncated) {
|
|
68
|
+
return {
|
|
69
|
+
text: `${text}…[+${cut} more, persisted truncated]`,
|
|
70
|
+
displayTruncated: true,
|
|
71
|
+
persistedTruncated: true,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (cut > 0) {
|
|
75
|
+
return { text: `${text}…[+${cut} more]`, displayTruncated: true, persistedTruncated: false }
|
|
76
|
+
}
|
|
77
|
+
if (persistedTruncated) {
|
|
78
|
+
return {
|
|
79
|
+
text: `${text}…[persisted truncated]`,
|
|
80
|
+
displayTruncated: false,
|
|
81
|
+
persistedTruncated: true,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { text, displayTruncated: false, persistedTruncated: false }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Satu baris peringatan per anak. Deterministik murni: tanpa IO, tanpa tulis
|
|
89
|
+
* jurnal/sesi, tanpa eksekusi/retry. Tanpa amplop usable (record legacy atau
|
|
90
|
+
* rusak) = baris legacy byte-identik — JANGAN ubah string legacy di bawah
|
|
91
|
+
* tanpa ADR (test warisan menguncinya).
|
|
92
|
+
*/
|
|
93
|
+
export function formatDelegateRecoveryLine(entry: DelegateRecoveryEntry): string {
|
|
94
|
+
const legacy =
|
|
95
|
+
`[recovery] turn failed after sub-agent ${entry.childSessionId} ` +
|
|
96
|
+
`completed — its effects stand; verify before re-delegating`
|
|
97
|
+
// Keduanya wajib ada DAN status harus dikenal (predikat bersama dengan
|
|
98
|
+
// pembaca — status asing tak boleh jadi teks status menyesatkan di lapisan
|
|
99
|
+
// mana pun). Ringkasan WAJIB string: null/angka/objek dari jurnal
|
|
100
|
+
// tulisan-tangan = rusak → fallback legacy. String kosong tetap valid
|
|
101
|
+
// (observasi kosong yang jujur, bukan data hilang). Data yang diragukan →
|
|
102
|
+
// fallback legacy, bukan tebakan setengah.
|
|
103
|
+
if (!isDisplayableChildStatus(entry.childStatus) || typeof entry.resultSummary !== "string")
|
|
104
|
+
return legacy
|
|
105
|
+
const preview = boundRecoveryPreview(entry.resultSummary, entry.truncated === true)
|
|
106
|
+
// `receipt: committed` akurat di sini karena pembaca (committedDelegatesSince)
|
|
107
|
+
// hanya menghasilkan baris committed; ditulis eksplisit agar status observasi
|
|
108
|
+
// anak TAK PERNAH dibaca sebagai vonis sukses eksekusi. Sufiks verifikasi
|
|
109
|
+
// dipertahankan: efek yang selamat tetap harus diverifikasi.
|
|
110
|
+
return (
|
|
111
|
+
`[recovery] turn failed after sub-agent ${entry.childSessionId} ` +
|
|
112
|
+
`(observed child status: ${entry.childStatus}; receipt: committed) — ` +
|
|
113
|
+
`prior child output: ${preview.text} — effects stand; verify before re-delegating`
|
|
114
|
+
)
|
|
115
|
+
}
|
package/cli/router.ts
CHANGED
|
@@ -44,6 +44,11 @@ export async function dispatch(
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
// P11.2 — posisi token subcommand di subArgv. Semua flag global sudah
|
|
48
|
+
// ter-push di titik ini; catat sebelum cmd+rest bergabung agar handler
|
|
49
|
+
// exec bisa menerima argv scoped TANPA token routing (cmd tetap ikut di
|
|
50
|
+
// subArgv demi subGetArg dan kompatibilitas handler lain).
|
|
51
|
+
const cmdTokenPos = subArgv.length
|
|
47
52
|
subArgv.push(...args.slice(cmdIndex))
|
|
48
53
|
// subGetArg untuk handler: cari flag di subArgv TANPA boundary prompt,
|
|
49
54
|
// karena token subcommand ("sessions") sendiri akan memicu early-return di
|
|
@@ -75,6 +80,13 @@ export async function dispatch(
|
|
|
75
80
|
await handleSessions(args, subGetArg)
|
|
76
81
|
return true
|
|
77
82
|
}
|
|
83
|
+
if (cmd === "openwork") {
|
|
84
|
+
// [P14.4] Portofolio open-work lintas sesi (read-only) + merge dedup
|
|
85
|
+
// eksplisit (P14.3). Handler process.exit sendiri (kontrak I28).
|
|
86
|
+
const { handleOpenwork } = await import("./commands/openwork.ts")
|
|
87
|
+
await handleOpenwork(args, subGetArg)
|
|
88
|
+
return true
|
|
89
|
+
}
|
|
78
90
|
if (cmd === "mcp") {
|
|
79
91
|
const { handleMcp } = await import("./commands/mcp.ts")
|
|
80
92
|
await handleMcp(args, subGetArg, HELP)
|
|
@@ -107,7 +119,13 @@ export async function dispatch(
|
|
|
107
119
|
}
|
|
108
120
|
if (cmd === "exec") {
|
|
109
121
|
const { handleExec } = await import("./commands/exec.ts")
|
|
110
|
-
|
|
122
|
+
// P11.2 — argv scoped TANPA token "exec": guard lokal `args[0] === "exec"`
|
|
123
|
+
// di handler hanya benar bila exec token pertama; dengan flag global
|
|
124
|
+
// mendahului ("--json exec ...") token routing bocor ke prompt + summary
|
|
125
|
+
// mesin. cmdArgv = flag global yang dikenal + semua token setelah
|
|
126
|
+
// subcommand. subGetArg tak berubah (tetap di atas subArgv penuh).
|
|
127
|
+
const cmdArgv = [...subArgv.slice(0, cmdTokenPos), ...args.slice(cmdIndex + 1)]
|
|
128
|
+
await handleExec(cmdArgv, subGetArg)
|
|
111
129
|
return true
|
|
112
130
|
}
|
|
113
131
|
if (cmd === "acp") {
|
|
@@ -117,6 +135,19 @@ export async function dispatch(
|
|
|
117
135
|
await handleAcp()
|
|
118
136
|
return true
|
|
119
137
|
}
|
|
138
|
+
if (cmd === "daemon") {
|
|
139
|
+
// P2.12 — host daemon lintas-platform (loopback + capability bercakupan).
|
|
140
|
+
// Terpisah dari exec/acp: daemon adalah proses panjang yang melayani
|
|
141
|
+
// konsumen, bukan pelaksana satu prompt.
|
|
142
|
+
// P11.3 — argv scoped TANPA token "daemon" (cermin pola exec P11.2):
|
|
143
|
+
// guard lokal `args[0] === "daemon"` di handler salah saat flag global
|
|
144
|
+
// mendahului ("--json daemon status" dibaca sebagai aksi "daemon" →
|
|
145
|
+
// exit 2 palsu). subGetArg tak berubah (tetap di atas subArgv penuh).
|
|
146
|
+
const { handleDaemon } = await import("./commands/daemon.ts")
|
|
147
|
+
const cmdArgv = [...subArgv.slice(0, cmdTokenPos), ...args.slice(cmdIndex + 1)]
|
|
148
|
+
await handleDaemon(cmdArgv, subGetArg, HELP)
|
|
149
|
+
return true
|
|
150
|
+
}
|
|
120
151
|
if (cmd === "memory") {
|
|
121
152
|
const { handleMemory } = await import("./commands/memory.ts")
|
|
122
153
|
await handleMemory(args, subGetArg)
|