minicode-ai 0.14.0 → 0.14.2
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 +1 -1
- package/cli/args.ts +16 -3
- package/cli/auto-update.ts +32 -2
- package/cli/commands/exec.ts +9 -0
- package/cli/index.ts +31 -13
- package/cli/setup.ts +31 -19
- package/cli/tui.ts +63 -40
- package/docs/OUTPUT_PROTOCOL_SPEC.md +6 -0
- package/docs/OUTPUT_RENDERING_SPEC.md +28 -4
- package/docs/README.md +2 -2
- package/docs/TERMINAL_CONTRACT.md +52 -26
- package/docs/agents.md +2 -2
- package/docs/choosing-mode.md +20 -13
- package/docs/cli.md +11 -11
- package/docs/environment.md +3 -3
- package/docs/getting-started.md +14 -12
- package/docs/glossary.md +1 -1
- package/docs/mcp-lsp.md +1 -1
- package/docs/policy-sandbox.md +7 -1
- package/docs/security-model.md +2 -2
- package/docs/security.md +7 -1
- package/docs/tools.md +4 -4
- package/docs/verify-benchmark.md +16 -0
- package/package.json +1 -3
- package/src/app/mentions.ts +4 -3
- package/src/app/session.ts +19 -9
- package/src/app/tool-layer.ts +10 -3
- package/src/constants.ts +17 -0
- package/src/lib/git-hardening.ts +27 -22
- package/src/lib/safe-open.ts +73 -19
- package/src/lib/trusted-exec.ts +7 -4
- package/src/mcp/client.ts +34 -9
- package/src/mcp/transport.ts +96 -42
- package/src/memory/files.ts +15 -4
- package/src/memory/vector.ts +5 -1
- package/src/policy/context.ts +21 -13
- package/src/policy/permission.ts +75 -16
- package/src/policy/tool-contract.ts +21 -10
- package/src/policy/update-check.ts +83 -6
- package/src/policy/usage.ts +17 -7
- package/src/policy/work-mode.ts +51 -17
- package/src/presentation/adapter.ts +64 -2
- package/src/presentation/events.ts +6 -0
- package/src/presentation/model.ts +1 -0
- package/src/presentation/projection.ts +2 -0
- package/src/presentation/reducer.ts +1 -0
- package/src/providers/anthropic.ts +52 -19
- package/src/providers/guards.ts +98 -13
- package/src/providers/responses.ts +61 -23
- package/src/providers/sse-bounds.ts +170 -0
- package/src/repo/repomap.ts +10 -11
- package/src/runtime/execution-backend.ts +7 -8
- package/src/sandbox/docker.ts +113 -9
- package/src/session/checkpoint.ts +9 -2
- package/src/session/persistence.ts +5 -2
- package/src/session/verification.ts +55 -16
- package/src/skills/loader.ts +16 -3
- package/src/tools/bash.ts +6 -3
- package/src/tools/code_run.ts +6 -5
- package/src/tools/context.ts +8 -0
- package/src/tools/delete_file.ts +2 -1
- package/src/tools/edit.ts +2 -1
- package/src/tools/git.ts +128 -54
- package/src/tools/glob.ts +2 -1
- package/src/tools/grep.ts +31 -6
- package/src/tools/lsp.ts +5 -4
- package/src/tools/mcp_call.ts +3 -1
- package/src/tools/memory.ts +175 -180
- package/src/tools/move_file.ts +2 -1
- package/src/tools/patch.ts +2 -1
- package/src/tools/read_file.ts +94 -1
- package/src/tools/read_image.ts +2 -1
- package/src/tools/task.ts +2 -1
- package/src/tools/todo.ts +4 -5
- package/src/tools/web_fetch.ts +28 -12
- package/src/tools/web_search.ts +28 -9
- package/src/tools/write_file.ts +2 -1
- package/src/ui/assistant/simple.ts +72 -3
- package/src/ui/footer.ts +17 -12
- package/src/ui/i18n/en.ts +6 -3
- package/src/ui/i18n/id.ts +6 -3
- package/src/ui/render/width.ts +107 -79
- package/src/ui/runtime/screen.ts +49 -37
- package/src/ui/tui/app.ts +261 -209
- package/src/ui/tui/transcript.ts +39 -0
- package/CHANGELOG.md +0 -1167
- package/docs/PLAN_UIUX_V6.md +0 -209
- package/docs/changelog.md +0 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Coding agent built on **MiniCore** (kernel di-vendor ke `vendor/minicore`, seam
|
|
|
4
4
|
|
|
5
5
|
MiniCore = kernel runtime `STATE/MODEL/ACTION/LOOP` (inti di-freeze; satu-satunya patch = seam additif backward-compatible). Minicode = layer agencode: tools FS/bash/git/memory/todo/MCP/LSP, sub-agents, skills, hooks ask, CLI shell-first pure ANSI (output linier di scrollback, tanpa Ink/React), memory hybrid RAG, sessions sqlite, repo-map, verifier.
|
|
6
6
|
|
|
7
|
-
> Angka yang bisa dihitung mesin (jumlah test, tool, coverage) **tidak ditulis di sini** — jalankan `bun test`, `bun run gate:coverage`, atau lihat CI. Riwayat perubahan per versi ada di [
|
|
7
|
+
> Angka yang bisa dihitung mesin (jumlah test, tool, coverage) **tidak ditulis di sini** — jalankan `bun test`, `bun run gate:coverage`, atau lihat CI. Riwayat perubahan per versi ada di [GitHub Releases](https://github.com/startupmini/minicode/releases).
|
|
8
8
|
|
|
9
9
|
📖 **Mulai dari [docs/](docs/)** — [Instalasi](docs/getting-started.md), [Quickstart](docs/quickstart.md), [Memilih Mode](docs/choosing-mode.md) · [docs/ARCHITECTURE.html](docs/ARCHITECTURE.html) untuk peta struktur repo.
|
|
10
10
|
|
package/cli/args.ts
CHANGED
|
@@ -106,15 +106,28 @@ export type CliWorkMode = "DISCUSS" | "PLAN" | "EXECUTE"
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* P12 S2.2 — Parse nilai WorkMode dari argumen operator (command `/work-mode`).
|
|
109
|
-
* Murni + diekspor untuk test.
|
|
110
|
-
* dikenal (undefined) agar pemanggil bisa menolak
|
|
109
|
+
* Murni + diekspor untuk test. Tiga nilai sah + alias produk `BUILD` (→ EXECUTE
|
|
110
|
+
* internal); nilai lain = tak dikenal (undefined) agar pemanggil bisa menolak
|
|
111
|
+
* tanpa mengubah state.
|
|
111
112
|
*/
|
|
112
113
|
export function parseWorkModeValue(raw: string): CliWorkMode | undefined {
|
|
113
114
|
const norm = raw.trim().toUpperCase()
|
|
115
|
+
// Alias produk: BUILD == identitas runtime/persistence EXECUTE (satu identitas,
|
|
116
|
+
// dua ejaan — bukan enum kedua).
|
|
117
|
+
if (norm === "BUILD") return "EXECUTE"
|
|
114
118
|
if (norm === "DISCUSS" || norm === "PLAN" || norm === "EXECUTE") return norm
|
|
115
119
|
return undefined
|
|
116
120
|
}
|
|
117
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Nama produk WorkMode untuk antarmuka pengguna: identitas internal `EXECUTE`
|
|
124
|
+
* ditampilkan sebagai `BUILD`. Dipakai footer, /status, help, dan i18n agar
|
|
125
|
+
* semua permukaan konsisten, tanpa mengubah identitas runtime/persistence.
|
|
126
|
+
*/
|
|
127
|
+
export function displayWorkMode(workMode: CliWorkMode): "DISCUSS" | "PLAN" | "BUILD" {
|
|
128
|
+
return workMode === "EXECUTE" ? "BUILD" : workMode
|
|
129
|
+
}
|
|
130
|
+
|
|
118
131
|
/**
|
|
119
132
|
* P12 S2.2 — Resolusi WorkMode dari flag CLI + env, murni & diekspor untuk
|
|
120
133
|
* test (pola repo). Flag `--work-mode` mengalahkan env `MINICODE_WORK_MODE`;
|
|
@@ -138,7 +151,7 @@ export function resolveWorkModeFlag(getArg: (n: string) => string | undefined):
|
|
|
138
151
|
return {
|
|
139
152
|
workMode: "EXECUTE",
|
|
140
153
|
explicit: true,
|
|
141
|
-
warning: `--work-mode requires DISCUSS|PLAN|
|
|
154
|
+
warning: `--work-mode requires DISCUSS|PLAN|BUILD, ignoring "${raw}" (using BUILD/EXECUTE)`,
|
|
142
155
|
}
|
|
143
156
|
}
|
|
144
157
|
|
package/cli/auto-update.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
isInstalledCopy,
|
|
12
12
|
shouldAutoUpdate,
|
|
13
13
|
UPDATE_GUARD_ENV,
|
|
14
|
+
verifyInstalledVersion,
|
|
14
15
|
} from "../src/policy/update-check.ts"
|
|
15
16
|
import { c } from "../src/ui/render/theme.ts"
|
|
16
17
|
|
|
@@ -44,7 +45,7 @@ export function waitChildExit(child: ChildProcess): Promise<number | null> {
|
|
|
44
45
|
export async function maybeAutoUpdate(
|
|
45
46
|
version: string,
|
|
46
47
|
signal?: AbortSignal,
|
|
47
|
-
opts?: { onLongOp?: () => void },
|
|
48
|
+
opts?: { onLongOp?: () => void; getInstalledVersion?: () => string },
|
|
48
49
|
): Promise<void> {
|
|
49
50
|
let decision: ReturnType<typeof shouldAutoUpdate>
|
|
50
51
|
try {
|
|
@@ -77,7 +78,7 @@ export async function maybeAutoUpdate(
|
|
|
77
78
|
process.stderr.write(c.dim("Menginstall pembaruan otomatis…\n"))
|
|
78
79
|
let ok = false
|
|
79
80
|
try {
|
|
80
|
-
ok = installUpdate()
|
|
81
|
+
ok = installUpdate(latest)
|
|
81
82
|
} catch {
|
|
82
83
|
ok = false
|
|
83
84
|
}
|
|
@@ -89,6 +90,35 @@ export async function maybeAutoUpdate(
|
|
|
89
90
|
)
|
|
90
91
|
return
|
|
91
92
|
}
|
|
93
|
+
const installedMatches = (expected: string): boolean => {
|
|
94
|
+
if (!opts?.getInstalledVersion) return true
|
|
95
|
+
return verifyInstalledVersion(expected, opts.getInstalledVersion)
|
|
96
|
+
}
|
|
97
|
+
if (!installedMatches(latest)) {
|
|
98
|
+
process.stderr.write(
|
|
99
|
+
c.yellow(
|
|
100
|
+
`Versi terpasang tidak cocok dengan target ${latest}; mencoba memulihkan ${version}…\n`,
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
let restored = false
|
|
104
|
+
try {
|
|
105
|
+
restored = installUpdate(version) && installedMatches(version)
|
|
106
|
+
} catch {
|
|
107
|
+
restored = false
|
|
108
|
+
}
|
|
109
|
+
if (restored) {
|
|
110
|
+
process.stderr.write(
|
|
111
|
+
c.yellow(`Auto-update dibatalkan; versi ${version} berhasil dipulihkan.\n`),
|
|
112
|
+
)
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
process.stderr.write(
|
|
116
|
+
c.error(
|
|
117
|
+
`Auto-update tidak dapat memverifikasi atau memulihkan instalasi. Keluar; pulihkan dengan: npm install -g minicode-ai@${version}\n`,
|
|
118
|
+
),
|
|
119
|
+
)
|
|
120
|
+
process.exit(1)
|
|
121
|
+
}
|
|
92
122
|
// Restart ke kode baru dengan argv identik; guard env cegah loop bila
|
|
93
123
|
// versi ter-install ternyata masih dilaporkan lebih tua.
|
|
94
124
|
process.stderr.write(c.dim(`Restart ke versi ${latest}…\n`))
|
package/cli/commands/exec.ts
CHANGED
|
@@ -89,6 +89,15 @@ export async function handleExec(
|
|
|
89
89
|
if (sandbox.mode === "none") delete process.env.MINICODE_SANDBOX
|
|
90
90
|
else process.env.MINICODE_SANDBOX = sandbox.mode
|
|
91
91
|
const allowlist = allowlistFlag || sandbox.fallbackPermission === "allowlist"
|
|
92
|
+
// [mode-architecture] Deprecation notice utk profil warisan (paritas jalur utama).
|
|
93
|
+
if (allowAll)
|
|
94
|
+
console.error(
|
|
95
|
+
`[deprecated] --allow-all is a privileged access profile (hard jail/guard still apply); treat it as an explicit override, not ordinary AUTO`,
|
|
96
|
+
)
|
|
97
|
+
if (allowlist)
|
|
98
|
+
console.error(
|
|
99
|
+
`[deprecated] --allowlist is a bash/tool access policy; persistent grants remain in ~/.minicode/allowlist.json`,
|
|
100
|
+
)
|
|
92
101
|
// Audit #07 P0: local config repo tak dipercaya kecuali operator opt-in.
|
|
93
102
|
const allowLocal = allowLocalConfig(subArgs)
|
|
94
103
|
const budgetRaw = getArg("--budget")
|
package/cli/index.ts
CHANGED
|
@@ -66,9 +66,9 @@ Options:
|
|
|
66
66
|
--model <name> override model (provider::model)
|
|
67
67
|
--provider <id> force provider id
|
|
68
68
|
--session <id> session id (default random)
|
|
69
|
-
--allow-all allow all tools
|
|
70
|
-
--ask ask per tool (y/n/a)
|
|
71
|
-
--plan
|
|
69
|
+
--allow-all allow all tools (privileged access profile; hard jail/guard still apply)
|
|
70
|
+
--ask ask per tool (y/n/a) — human-supervised execution
|
|
71
|
+
--plan deprecated: alias for --work-mode PLAN (read-only planning)
|
|
72
72
|
--allowlist bash allowlist only (see MINICODE_BASH_ALLOWLIST)
|
|
73
73
|
--max-steps <n> max tool steps (default 50)
|
|
74
74
|
--context-window <n> context window tokens
|
|
@@ -80,8 +80,8 @@ Options:
|
|
|
80
80
|
--budget <usd> session cost limit
|
|
81
81
|
--budget-strict unknown cost + spend counts as over budget (fail-closed default)
|
|
82
82
|
--tool-scope <s> full (default) | explore (read-only subset)
|
|
83
|
-
--work-mode <m> DISCUSS | PLAN |
|
|
84
|
-
|
|
83
|
+
--work-mode <m> DISCUSS | PLAN | BUILD (default). Operating mode: DISCUSS =
|
|
84
|
+
read-only investigation, PLAN = planning, BUILD = implementation.
|
|
85
85
|
--tui deprecated no-op (interactive mode is always the fullscreen TUI)
|
|
86
86
|
--enable-scheduler EXPERIMENTAL: opt in to the autonomous scheduler (default: off).
|
|
87
87
|
Manual only - run /scheduler run. No timer; autonomous turns are
|
|
@@ -93,7 +93,7 @@ Options:
|
|
|
93
93
|
admission runs nothing. Unknown value = off.
|
|
94
94
|
|
|
95
95
|
TUI: /help /provider /model /sync /status /sessions /init /exit /mode /work-mode /undo /redo /clear /copy /history /compact /thinking /minimize
|
|
96
|
-
Keys: Enter submit · Tab
|
|
96
|
+
Keys: Enter submit · Tab work-mode · Shift+Tab permission · Up/Down history · Mouse wheel/PgUp/PgDn scroll (Shift = half page)
|
|
97
97
|
Home/End jump to transcript top/tail · Ctrl+R search · Esc abort turn (twice = quit) · Ctrl+D exit
|
|
98
98
|
Subcommand flags (config/mcp/sessions/skills/exec/...): see 'minicode <cmd> --help'.
|
|
99
99
|
`
|
|
@@ -244,9 +244,9 @@ if (args.includes("-h") || args.includes("--help")) {
|
|
|
244
244
|
flag: "--timeout <ms>",
|
|
245
245
|
desc: "hard deadline per run (default 900000 = 15min; 0 = Infinity)",
|
|
246
246
|
},
|
|
247
|
-
{ flag: "--allow-all", desc: "allow all tools (
|
|
248
|
-
{ flag: "--ask", desc: "ask per tool" },
|
|
249
|
-
{ flag: "--plan", desc: "
|
|
247
|
+
{ flag: "--allow-all", desc: "allow all tools (privileged access profile)" },
|
|
248
|
+
{ flag: "--ask", desc: "ask per tool (human-supervised)" },
|
|
249
|
+
{ flag: "--plan", desc: "deprecated: alias for --work-mode PLAN" },
|
|
250
250
|
{ flag: "--allowlist", desc: "bash allowlist only" },
|
|
251
251
|
{ flag: "--interactive", desc: "interactive TUI" },
|
|
252
252
|
{ flag: "--verify", desc: "auto-verify + self-heal" },
|
|
@@ -256,8 +256,8 @@ if (args.includes("-h") || args.includes("--help")) {
|
|
|
256
256
|
{ flag: "--budget-strict", desc: "unknown cost + spend counts as over budget (default)" },
|
|
257
257
|
{ flag: "--tool-scope <full|explore>", desc: "tool subset (explore = read-only)" },
|
|
258
258
|
{
|
|
259
|
-
flag: "--work-mode <DISCUSS|PLAN|
|
|
260
|
-
desc: "
|
|
259
|
+
flag: "--work-mode <DISCUSS|PLAN|BUILD>",
|
|
260
|
+
desc: "operating mode: DISCUSS (read-only), PLAN (planning), BUILD (default)",
|
|
261
261
|
},
|
|
262
262
|
{ flag: "--json", desc: "JSON output (help/exec)" },
|
|
263
263
|
{ flag: "--tui", desc: "deprecated no-op (interactive is always the fullscreen TUI)" },
|
|
@@ -277,6 +277,16 @@ const ask = hasFlag(args, "--ask")
|
|
|
277
277
|
const interactive = hasFlag(args, "--interactive")
|
|
278
278
|
const plan = hasFlag(args, "--plan") || process.env.MINICODE_PLAN === "1"
|
|
279
279
|
const allowlist = hasFlag(args, "--allowlist") || process.env.MINICODE_PERMISSION === "allowlist"
|
|
280
|
+
// [mode-architecture] Deprecation notice utk profil warisan — jangan dihapus
|
|
281
|
+
// diam-diam; peta kompatibilitas di MODE_ARCHITECTURE_MIGRATION_REPORT.
|
|
282
|
+
if (allowAll)
|
|
283
|
+
process.stderr.write(
|
|
284
|
+
`[deprecated] --allow-all is a privileged access profile (hard jail/guard still apply); treat it as an explicit override, not ordinary AUTO\n`,
|
|
285
|
+
)
|
|
286
|
+
if (allowlist)
|
|
287
|
+
process.stderr.write(
|
|
288
|
+
`[deprecated] --allowlist is a bash/tool access policy; the persistent approval grants remain in ~/.minicode/allowlist.json (unrenamed)\n`,
|
|
289
|
+
)
|
|
280
290
|
const verify = hasFlag(args, "--verify")
|
|
281
291
|
const cwdRaw = getArg("--cwd")
|
|
282
292
|
const cwd = cwdRaw ? resolvePath(cwdRaw) : undefined
|
|
@@ -463,7 +473,10 @@ if (enterRepl) {
|
|
|
463
473
|
// matikan spinner agar tak menulis ke stderr yang sama dengan anak selama
|
|
464
474
|
// berjam-jam (stdio inherit) — itu yang terlihat sebagai hang/flicker.
|
|
465
475
|
// Idempoten: aman dipanggil dua kali (sebelum install, sebelum restart).
|
|
466
|
-
await maybeAutoUpdate(readVersion(), ctrl.signal, {
|
|
476
|
+
await maybeAutoUpdate(readVersion(), ctrl.signal, {
|
|
477
|
+
onLongOp: () => spin.stop(),
|
|
478
|
+
getInstalledVersion: readVersion,
|
|
479
|
+
})
|
|
467
480
|
} catch {}
|
|
468
481
|
clearTimeout(to)
|
|
469
482
|
spin.stop()
|
|
@@ -569,7 +582,12 @@ if (enterRepl) {
|
|
|
569
582
|
// Satu-satunya tampilan interaktif = TUI fullscreen (REPL linier dihapus).
|
|
570
583
|
// One-shot/exec tak tersentuh (cabang else di bawah).
|
|
571
584
|
const { runTui } = await import("./tui.ts")
|
|
572
|
-
|
|
585
|
+
try {
|
|
586
|
+
await runTui(ctx)
|
|
587
|
+
} catch (error) {
|
|
588
|
+
process.stderr.write(`[error] ${formatError(error)}\n`)
|
|
589
|
+
process.exitCode = 1
|
|
590
|
+
}
|
|
573
591
|
} else {
|
|
574
592
|
// P12 S2.2 (F-DISCUSS-4) + P0.2: one-shot linear memakai `ctx.workMode`
|
|
575
593
|
// efektif (termasuk hasil pulihan `--resume`).
|
package/cli/setup.ts
CHANGED
|
@@ -978,9 +978,21 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
978
978
|
}
|
|
979
979
|
// P0.2 (Q5): saat `--resume` tanpa sinyal WorkMode eksplisit, pulihkan
|
|
980
980
|
// WorkMode tersimpan dari metadata sesi (NULL legacy → default EXECUTE).
|
|
981
|
+
//
|
|
982
|
+
// [mode-architecture] --plan = alias warisan WorkMode PLAN (bukan permission
|
|
983
|
+
// mode). Dilipat di sini (satu titik untuk semua pemanggil: index/exec/acp).
|
|
981
984
|
const persistedWorkMode = identity.resumed ? loadSessionWorkMode(sessionId, cwd) : undefined
|
|
985
|
+
const planAsWorkMode =
|
|
986
|
+
plan && !workModeExplicit && workMode === "EXECUTE" ? ("PLAN" as const) : workMode
|
|
987
|
+
if (plan && !workModeExplicit && workMode === "EXECUTE") {
|
|
988
|
+
process.stderr.write(
|
|
989
|
+
`${c.dim("[deprecated] --plan is now WorkMode PLAN; use --work-mode PLAN\n")}`,
|
|
990
|
+
)
|
|
991
|
+
}
|
|
982
992
|
const effectiveWorkMode: "DISCUSS" | "PLAN" | "EXECUTE" =
|
|
983
|
-
identity.resumed && !workModeExplicit
|
|
993
|
+
identity.resumed && !workModeExplicit && !plan
|
|
994
|
+
? (persistedWorkMode ?? "EXECUTE")
|
|
995
|
+
: planAsWorkMode
|
|
984
996
|
// P0.2 (Q4): tolak startup (fail-closed) bila `--verify` digabung dengan
|
|
985
997
|
// WorkMode DISCUSS atau PLAN (baik dari flag/env maupun pulihan `--resume`).
|
|
986
998
|
if (verify && effectiveWorkMode !== "EXECUTE") {
|
|
@@ -1145,15 +1157,10 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1145
1157
|
return rc.signal
|
|
1146
1158
|
})()
|
|
1147
1159
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
: plan
|
|
1153
|
-
? "plan"
|
|
1154
|
-
: allowlist
|
|
1155
|
-
? "allowlist"
|
|
1156
|
-
: "auto"
|
|
1160
|
+
// [mode-architecture] `--plan` legacy bukan lagi permission mode — pemetaannya
|
|
1161
|
+
// ke WorkMode PLAN terjadi di effectiveWorkMode (di atas). Sisa profil warisan
|
|
1162
|
+
// (allow-all/allowlist) tetap tersedia sebagai tool-access profile.
|
|
1163
|
+
const permissionMode = allowAll ? "allow-all" : ask ? "ask" : allowlist ? "allowlist" : "auto"
|
|
1157
1164
|
|
|
1158
1165
|
// Home guard: sesi dibuka di home berisiko (glob rame, write berbahaya).
|
|
1159
1166
|
// Standar industri: percaya-tapi-ingatkan, jangan tolak diam-diam maupun
|
|
@@ -1220,12 +1227,12 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1220
1227
|
cfg,
|
|
1221
1228
|
prompt,
|
|
1222
1229
|
cwd,
|
|
1223
|
-
// RAG retrieval tak boleh menulis access_count di mode tanpa-mutasi
|
|
1224
|
-
//
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1230
|
+
// RAG retrieval tak boleh menulis access_count di mode tanpa-mutasi.
|
|
1231
|
+
// [mode-architecture] PermissionMode readonly/plan tak lagi ada sebagai sumbu
|
|
1232
|
+
// persetujuan; ceiling tanpa-mutasi kini diekspresikan via WorkMode
|
|
1233
|
+
// DISCUSS/PLAN (effectiveWorkMode). Profil warisan allowlist/allow-all
|
|
1234
|
+
// tetap menulis (bukan read-only).
|
|
1235
|
+
trackAccess: effectiveWorkMode === "EXECUTE",
|
|
1229
1236
|
}),
|
|
1230
1237
|
)
|
|
1231
1238
|
|
|
@@ -2188,6 +2195,10 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
2188
2195
|
? e.result.usage.turns
|
|
2189
2196
|
: session.state.turnCount
|
|
2190
2197
|
const desc = `turn ${turn}`
|
|
2198
|
+
if (pre.mode === "unavailable") {
|
|
2199
|
+
warnLine(`checkpoint unavailable: ${pre.reason}; undo/redo will not cover turn ${turn}`)
|
|
2200
|
+
return
|
|
2201
|
+
}
|
|
2191
2202
|
if (pre.mode === "git") {
|
|
2192
2203
|
const after = await snapshotTree(cwd ?? ".", sessionId, `post-${turn}`)
|
|
2193
2204
|
const checkpoint = await recordCheckpointFromTrees(
|
|
@@ -2747,8 +2758,7 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
2747
2758
|
const stopCtxWindow = watchContextWindowLimit({
|
|
2748
2759
|
bus: session.events,
|
|
2749
2760
|
windowTokens: contextWindowTokens ?? 0,
|
|
2750
|
-
|
|
2751
|
-
getOutputTokens: () => usage.get().outputTokens,
|
|
2761
|
+
getRequestTokens: () => usage.currentRequestTokens(),
|
|
2752
2762
|
onOver: (allowed, actual) => {
|
|
2753
2763
|
const windowTokens = contextWindowTokens ?? 0
|
|
2754
2764
|
// F-CTX-1 + P1.4: meter occupancy konteks (bukan output cutoff).
|
|
@@ -3092,7 +3102,9 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
3092
3102
|
)
|
|
3093
3103
|
return
|
|
3094
3104
|
}
|
|
3095
|
-
//
|
|
3105
|
+
// Histori adalah bukti durable untuk turn ini. Error selain epoch harus
|
|
3106
|
+
// naik ke pemanggil agar one-shot tidak mengaku berhasil saat pesan hilang.
|
|
3107
|
+
throw e
|
|
3096
3108
|
}
|
|
3097
3109
|
}
|
|
3098
3110
|
|
package/cli/tui.ts
CHANGED
|
@@ -36,7 +36,7 @@ import { c } from "../src/ui/render/theme.ts"
|
|
|
36
36
|
import { defaultUiState, type UiSessionState } from "../src/ui/session-state.ts"
|
|
37
37
|
import { TuiApp, type TuiHost } from "../src/ui/tui/app.ts"
|
|
38
38
|
import { Transcript } from "../src/ui/tui/transcript.ts"
|
|
39
|
-
import { parseWorkModeValue } from "./args.ts"
|
|
39
|
+
import { displayWorkMode, parseWorkModeValue } from "./args.ts"
|
|
40
40
|
import {
|
|
41
41
|
BUILTIN_COMMANDS,
|
|
42
42
|
type CommandContext,
|
|
@@ -47,7 +47,11 @@ import {
|
|
|
47
47
|
} from "./commands.ts"
|
|
48
48
|
import type { CliSession } from "./setup.ts"
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
// [mode-architecture] Approval axis (PermissionMode) = AUTO/ASK; operating axis
|
|
51
|
+
// (WorkMode) = DISCUSS/PLAN/BUILD, dikelola terpisah via /work-mode. Nilai
|
|
52
|
+
// internal tetap lowercase (auto/ask) dan EXECUTE (identitas BUILD).
|
|
53
|
+
const PERMISSION_MODES = ["auto", "ask"] as const
|
|
54
|
+
const WORK_MODE_CYCLE = ["DISCUSS", "PLAN", "EXECUTE"] as const
|
|
51
55
|
// /expand [id]: tanpa arg = semua entry store; dengan id = satu tool.
|
|
52
56
|
const DRIVER_COMMANDS = [
|
|
53
57
|
"/compact",
|
|
@@ -215,11 +219,12 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
215
219
|
skills: allLoadedSkills,
|
|
216
220
|
toolsCount: sessionTools.length,
|
|
217
221
|
// P1.2: dua dimensi selalu terbaca live di /status — bukan snapshot boot.
|
|
222
|
+
// [mode-architecture] /status memakai nilai PRODUK (BUILD/AUTO/ASK).
|
|
218
223
|
get workMode() {
|
|
219
|
-
return workModeControl?.getWorkMode() ?? "EXECUTE"
|
|
224
|
+
return displayWorkMode(workModeControl?.getWorkMode() ?? "EXECUTE")
|
|
220
225
|
},
|
|
221
226
|
get permissionMode() {
|
|
222
|
-
return permissions?.getMode() ?? mode
|
|
227
|
+
return (permissions?.getMode() ?? mode).toUpperCase()
|
|
223
228
|
},
|
|
224
229
|
providerHint: cfg.providers[0]?.providerHint,
|
|
225
230
|
setModelOverride: (m) => persistModelChoice(m, modelRef),
|
|
@@ -263,14 +268,24 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
263
268
|
return all.filter((t) => t.startsWith(line))
|
|
264
269
|
}
|
|
265
270
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
+
// Tab: cycle WorkMode (DISCUSS → PLAN → BUILD → DISCUSS). Hanya command ini
|
|
272
|
+
// (beserta /work-mode) yang menggeser operating mode — TIDAK permission mode.
|
|
273
|
+
const cycleWorkMode = (dir: 1 | -1): void => {
|
|
274
|
+
if (!workModeControl) return // policy terinjeksi = tanpa kontrol (fail-closed)
|
|
275
|
+
const current = workModeControl.getWorkMode() ?? "EXECUTE"
|
|
276
|
+
const idx = (WORK_MODE_CYCLE as readonly string[]).indexOf(current)
|
|
277
|
+
if (idx === -1) return
|
|
278
|
+
const next = WORK_MODE_CYCLE[(idx + dir + WORK_MODE_CYCLE.length) % WORK_MODE_CYCLE.length]!
|
|
279
|
+
workModeControl.setWorkMode(next)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Shift+Tab: toggle PermissionMode (AUTO ↔ ASK). Tidak ada privilege change
|
|
283
|
+
// diam — hanya sumbu persetujuan.
|
|
284
|
+
const togglePermissionMode = (): void => {
|
|
285
|
+
if (!permissions) return
|
|
286
|
+
const next = permissions.getMode() === "ask" ? "auto" : "ask"
|
|
287
|
+
permissions.setMode(next)
|
|
271
288
|
mode = next
|
|
272
|
-
if (permissions) permissions.setMode(mode as (typeof MODES)[number])
|
|
273
|
-
else mode = permissionMode ?? mode
|
|
274
289
|
}
|
|
275
290
|
|
|
276
291
|
async function runBuiltin(
|
|
@@ -444,33 +459,35 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
444
459
|
app.clearView()
|
|
445
460
|
return
|
|
446
461
|
}
|
|
462
|
+
// [mode-architecture] /mode = PermissionMode (persetujuan AUTO/ASK) SAJA.
|
|
447
463
|
if (name === "mode") {
|
|
448
464
|
if (args) {
|
|
449
|
-
|
|
450
|
-
|
|
465
|
+
const norm = args.toLowerCase()
|
|
466
|
+
if (!(PERMISSION_MODES as readonly string[]).includes(norm)) {
|
|
467
|
+
transcript.pushInfo([c.muted(t("tui.unknownMode", { a: args, modes: "AUTO, ASK" }))])
|
|
451
468
|
return
|
|
452
469
|
}
|
|
453
|
-
mode =
|
|
454
|
-
permissions?.setMode(
|
|
470
|
+
mode = norm
|
|
471
|
+
permissions?.setMode(norm as (typeof PERMISSION_MODES)[number])
|
|
455
472
|
} else {
|
|
456
|
-
|
|
473
|
+
togglePermissionMode()
|
|
457
474
|
}
|
|
458
|
-
transcript.pushInfo([c.muted(t("tui.modeLine", { m: mode }))])
|
|
475
|
+
transcript.pushInfo([c.muted(t("tui.modeLine", { m: mode.toUpperCase() }))])
|
|
459
476
|
return
|
|
460
477
|
}
|
|
461
|
-
//
|
|
462
|
-
// Aksi operator EKSPLISIT
|
|
463
|
-
// Tab/Shift+Tab dan `/mode` tetap khusus permission mode.
|
|
478
|
+
// [mode-architecture] /work-mode = WorkMode (operating mode) SAJA.
|
|
479
|
+
// Aksi operator EKSPLISIT untuk operating mode; Tab/Shift+Tab = pintasan.
|
|
464
480
|
if (name === "work-mode") {
|
|
465
481
|
const current = workModeControl?.getWorkMode() ?? "EXECUTE"
|
|
482
|
+
const currentDisplay = displayWorkMode(current)
|
|
466
483
|
if (!args) {
|
|
467
|
-
transcript.pushInfo([c.muted(t("tui.workModeUsage", { m:
|
|
484
|
+
transcript.pushInfo([c.muted(t("tui.workModeUsage", { m: currentDisplay }))])
|
|
468
485
|
return
|
|
469
486
|
}
|
|
470
487
|
const next = parseWorkModeValue(args)
|
|
471
488
|
if (!next) {
|
|
472
489
|
transcript.pushInfo([
|
|
473
|
-
c.muted(t("tui.workModeUnknown", { a: args, modes: "DISCUSS, PLAN,
|
|
490
|
+
c.muted(t("tui.workModeUnknown", { a: args, modes: "DISCUSS, PLAN, BUILD" })),
|
|
474
491
|
])
|
|
475
492
|
return
|
|
476
493
|
}
|
|
@@ -481,7 +498,7 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
481
498
|
return
|
|
482
499
|
}
|
|
483
500
|
workModeControl.setWorkMode(next)
|
|
484
|
-
transcript.pushInfo([c.muted(t("tui.workModeLine", { m: next }))])
|
|
501
|
+
transcript.pushInfo([c.muted(t("tui.workModeLine", { m: displayWorkMode(next) }))])
|
|
485
502
|
return
|
|
486
503
|
}
|
|
487
504
|
if (name === "lang") {
|
|
@@ -656,8 +673,11 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
656
673
|
abort: () => {
|
|
657
674
|
abort?.abort()
|
|
658
675
|
},
|
|
659
|
-
|
|
660
|
-
|
|
676
|
+
cycleWorkMode: (dir) => {
|
|
677
|
+
cycleWorkMode(dir)
|
|
678
|
+
},
|
|
679
|
+
togglePermissionMode: () => {
|
|
680
|
+
togglePermissionMode()
|
|
661
681
|
},
|
|
662
682
|
toggleCompact: () => {
|
|
663
683
|
const compact = ui.setCompactMode()
|
|
@@ -673,21 +693,24 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
673
693
|
// Approval sebagai warga TUI: blok pertanyaan + keputusan tercatat di
|
|
674
694
|
// transkrip dan terlihat sebelum menjawab (tanpa sink = tulis langsung).
|
|
675
695
|
const { setApprovalSink } = await import("../src/ui/tui/transcript.ts")
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
696
|
+
try {
|
|
697
|
+
setApprovalSink({
|
|
698
|
+
pushBlock: (lines) => transcript.pushInfo(lines),
|
|
699
|
+
repaint: () => app.repaint(),
|
|
700
|
+
suspend: () => app.suspend(),
|
|
701
|
+
resume: () => app.resume(),
|
|
702
|
+
})
|
|
703
|
+
const res = await app.run()
|
|
704
|
+
if (!res.started) {
|
|
705
|
+
// Kegagalan startup adalah diagnostik, bukan keluaran program. App
|
|
706
|
+
// sudah menolak membuka layar dan tidak ada fallback linear yang sah.
|
|
707
|
+
process.stderr.write(`${t("tui.noTty")}\n`)
|
|
708
|
+
process.exitCode = 1
|
|
709
|
+
return
|
|
710
|
+
}
|
|
711
|
+
} finally {
|
|
712
|
+
setApprovalSink(null)
|
|
713
|
+
transcript.dispose()
|
|
688
714
|
await close()
|
|
689
|
-
return
|
|
690
715
|
}
|
|
691
|
-
transcript.dispose()
|
|
692
|
-
await close()
|
|
693
716
|
}
|
|
@@ -56,6 +56,12 @@ secara default dan tidak boleh dianggap machine contract.
|
|
|
56
56
|
| SGR | boleh bila color gate | tidak perlu; `NO_COLOR` menang |
|
|
57
57
|
| raw OSC/CSI dari untrusted text | Forbidden | Forbidden |
|
|
58
58
|
|
|
59
|
+
Saat `--interactive` gagal membuka fullscreen (pipe/non-TTY atau terminal tidak
|
|
60
|
+
mampu), CLI menulis diagnostik ke stderr dan keluar nonzero tanpa fallback linear
|
|
61
|
+
dan tanpa byte UI pada stdout. Saat TUI aktif, stdout dimiliki `App` untuk frame;
|
|
62
|
+
diagnostik yang tidak transient masuk transcript/system node atau jalur diagnostic
|
|
63
|
+
yang memang diizinkan kontrak. Output machine tetap terpisah dari kedua jalur UI.
|
|
64
|
+
|
|
59
65
|
`App` adalah pemilik tunggal frame TUI. Foreign writer ke stdout tidak boleh aktif
|
|
60
66
|
saat `TuiApp` memegang layar; diagnostic stderr yang tidak transient harus masuk ke
|
|
61
67
|
transcript atau competing-ownership guard.
|
|
@@ -204,7 +204,16 @@ arbitrator untuk transient, tetapi bukan pengganti semantic routing.
|
|
|
204
204
|
|
|
205
205
|
## 9. Geometry, text, dan fallback
|
|
206
206
|
|
|
207
|
-
- `displayWidth()` menghitung terminal
|
|
207
|
+
- `displayWidth()` menghitung kolom terminal per grapheme dengan
|
|
208
|
+
`Intl.Segmenter("und", { granularity: "grapheme" })`. Karakter CJK/fullwidth
|
|
209
|
+
dihitung dua kolom; combining marks tidak menambah kolom. Cluster emoji yang
|
|
210
|
+
ditampilkan sebagai emoji (Emoji_Presentation/VS16), skin-tone, ZWJ, regional
|
|
211
|
+
indicator, dan keycap dihitung dua kolom sebagai satu unit. Kebijakan ini
|
|
212
|
+
mengikuti perilaku terminal umum; MiniCode tidak mengukur lebar glyph per
|
|
213
|
+
terminal, sehingga font/terminal yang menyimpang dapat tetap berbeda.
|
|
214
|
+
- Wrapping, truncation/chunking, transcript selection, kursor prompt, dan
|
|
215
|
+
geometri frame memakai helper lebar bersama. `truncateToWidth()` dan
|
|
216
|
+
`chunkByWidth()` tidak memecah grapheme.
|
|
208
217
|
- Sanitasi control bytes dilakukan sebelum output; SGR boleh hanya bila color gate.
|
|
209
218
|
- Resize dibaca saat paint, bukan saat event.
|
|
210
219
|
- `NO_COLOR`/legacy Windows memakai glyph ASCII atau status word.
|
|
@@ -212,7 +221,22 @@ arbitrator untuk transient, tetapi bukan pengganti semantic routing.
|
|
|
212
221
|
- TTY table boleh aligned; machine/non-TTY tidak boleh berubah makna.
|
|
213
222
|
- Copy/paste tidak bergantung pada warna.
|
|
214
223
|
|
|
215
|
-
## 10.
|
|
224
|
+
## 10. Visual system dan accessibility
|
|
225
|
+
|
|
226
|
+
`src/ui/render/theme.ts` menyediakan token semantik (`success`, `error`,
|
|
227
|
+
`warning`, `info`, `accent`, `muted`, `faint`) dengan getter runtime. Token
|
|
228
|
+
warna hanya menegaskan status dan hierarki; status penting juga memakai kata
|
|
229
|
+
atau glyph sehingga tetap dapat dibaca pada `NO_COLOR`/mono. Fallback ASCII
|
|
230
|
+
dikendalikan oleh `MINICODE_ASCII` dan capability UTF-8 Windows.
|
|
231
|
+
|
|
232
|
+
Interaksi tetap keyboard-first: PgUp/PgDn dan Home/End untuk transkrip, Esc
|
|
233
|
+
untuk membatalkan/menutup selection, Ctrl+D untuk keluar, dan popup menahan
|
|
234
|
+
fokus sampai ditutup. Tidak ada mode screen-reader terpisah karena kontrak
|
|
235
|
+
fullscreen terminal dibekukan. Navigasi keyboard dan jalur mono memiliki test;
|
|
236
|
+
screen-reader announcement, kontras fisik, dan manual assistive-technology UAT
|
|
237
|
+
belum diverifikasi. Tampilan antar terminal tetap dapat berbeda.
|
|
238
|
+
|
|
239
|
+
## 11. Parity matrix
|
|
216
240
|
|
|
217
241
|
| Semantic | TUI | Linear | Exec | ACP |
|
|
218
242
|
|---|---|---|---|---|
|
|
@@ -227,7 +251,7 @@ arbitrator untuk transient, tetapi bukan pengganti semantic routing.
|
|
|
227
251
|
Parity diuji pada semantic object sebelum snapshot string. Test output tetap diperlukan
|
|
228
252
|
untuk regressions visual dan protocol.
|
|
229
253
|
|
|
230
|
-
##
|
|
254
|
+
## 12. Migration seams
|
|
231
255
|
|
|
232
256
|
1. `PresentationAdapter` dapat tetap emit raw-compatible events.
|
|
233
257
|
2. `ProjectionBridge` aktif untuk semua surface; flag `MINICODE_PRESENTATION_V2` dihapus di Phase 8.
|
|
@@ -238,7 +262,7 @@ untuk regressions visual dan protocol.
|
|
|
238
262
|
removed from user-facing TUI. Raw EventBus remains for streaming content and
|
|
239
263
|
diagnostics/trace only.
|
|
240
264
|
|
|
241
|
-
##
|
|
265
|
+
## 13. Definition of done renderer
|
|
242
266
|
|
|
243
267
|
- Tidak ada renderer yang meng-status-kan teks.
|
|
244
268
|
- TUI/linear/exec/ACP menghasilkan semantic fields yang sama.
|
package/docs/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Beberapa hal penting yang perlu Anda tahu:
|
|
|
34
34
|
- **Tidak ada data yang dikirim tanpa sepengetahuan Anda.** Konfigurasi Anda tersimpan di komputer Anda sendiri. Token akses disimpan dengan aman dan tidak disebarkan.
|
|
35
35
|
- **Kegagalan dilaporkan apa adanya.** Jika ada masalah, Minicode akan memberitahu secara langsung, tanpa disamarkan.
|
|
36
36
|
- **Informasi kuantitatif tidak ditulis secara permanen di sini.** Jika Anda ingin tahu jumlah test, cakupan, atau jumlah alat yang tersedia, jalankan perintah `bun test`, `bun run gate:coverage`, atau lihat hasil di layanan continuous integration (CI). Informasi seperti ini bisa berubah sewaktu-waktu.
|
|
37
|
-
- **Riwayat perubahan** tercatat di
|
|
37
|
+
- **Riwayat perubahan** tercatat di [GitHub Releases](https://github.com/startupmini/minicode/releases); changelog lengkap tersedia pada repository.
|
|
38
38
|
|
|
39
39
|
## Mulai dalam 5 menit
|
|
40
40
|
|
|
@@ -100,7 +100,7 @@ Habis itu, baca sesuai kebutuhan lewat tabel Navigasi di bawah — tak perlu ber
|
|
|
100
100
|
| Kontrak internal kontributor: terminal FROZEN, control-plane, pipeline render | [Internal & Arsitektur](TERMINAL_CONTRACT.md) (grup di sidebar) |
|
|
101
101
|
| Audit dan target arsitektur output/presentation | [Output Architecture Audit](OUTPUT_ARCHITECTURE_AUDIT.md) |
|
|
102
102
|
| Ikut kontribusi, gate, batas lapisan | [Contributing](contributing.md) |
|
|
103
|
-
| Perubahan per versi | [Changelog](
|
|
103
|
+
| Perubahan per versi | [Changelog](https://github.com/startupmini/minicode/releases) |
|
|
104
104
|
| Arsip panduan monolit lama (baca hanya bila perlu) | `USAGE.md` (file pendamping, status legacy) |
|
|
105
105
|
|
|
106
106
|
## Konvensi dokumen ini
|