minicode-ai 0.13.0 → 0.14.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 +23 -0
- package/LICENSE +21 -21
- package/README.md +4 -0
- package/cli/args.ts +50 -2
- package/cli/commands/acp.ts +18 -3
- package/cli/commands/daemon.ts +114 -19
- package/cli/commands/exec.ts +95 -7
- package/cli/commands/mcp.ts +66 -5
- package/cli/commands/memory.ts +46 -14
- package/cli/commands.ts +5 -0
- package/cli/index.ts +30 -5
- package/cli/minicode.js +6 -0
- package/cli/setup.ts +365 -24
- package/cli/tui.ts +72 -27
- package/docs/TERMINAL_CONTRACT.md +91 -24
- package/docs/agents.md +2 -2
- package/docs/cli.md +1 -0
- package/docs/environment.md +1 -0
- package/docs/memory-sessions.md +5 -0
- package/package.json +3 -2
- package/src/app/session.ts +153 -35
- package/src/app/tool-layer.ts +67 -61
- package/src/daemon/approvals.ts +25 -1
- package/src/daemon/client.ts +51 -1
- package/src/daemon/control.ts +8 -0
- package/src/daemon/protocol.ts +47 -1
- package/src/daemon/server.ts +45 -9
- package/src/daemon/subscription.ts +25 -1
- package/src/daemon/telemetry.ts +4 -0
- package/src/hooks/run.ts +5 -1
- package/src/mcp/client.ts +349 -90
- package/src/mcp/http-transport.ts +7 -0
- package/src/mcp/transport.ts +5 -0
- package/src/memory/files.ts +69 -3
- package/src/memory/vector.ts +556 -160
- package/src/policy/approval-binding.ts +199 -0
- package/src/policy/context.ts +20 -1
- package/src/policy/executor.ts +44 -5
- package/src/policy/permission.ts +243 -26
- package/src/policy/tool-contract.ts +77 -0
- package/src/policy/usage.ts +3 -1
- package/src/policy/work-mode.ts +49 -1
- package/src/presentation/adapter.ts +157 -7
- package/src/presentation/events.ts +173 -1
- package/src/presentation/model.ts +37 -0
- package/src/presentation/projection.ts +107 -18
- package/src/presentation/reducer.ts +134 -10
- package/src/sandbox/os.ts +18 -1
- package/src/session/persistence.ts +153 -11
- package/src/task/store.ts +43 -3
- package/src/tools/memory.ts +70 -10
- package/src/tools/task.ts +7 -1
- package/src/tools/todo.ts +14 -4
- package/src/ui/approval/prompt.ts +52 -7
- package/src/ui/assistant/simple.ts +160 -57
- package/src/ui/contract.ts +46 -0
- package/src/ui/footer.ts +14 -5
- package/src/ui/i18n/en.ts +9 -0
- package/src/ui/i18n/id.ts +9 -0
- package/src/ui/render/collapse.ts +24 -52
- package/src/ui/render/detail.ts +14 -9
- package/src/ui/render/errors.ts +8 -0
- package/src/ui/render/reasoning.ts +13 -8
- package/src/ui/session-state.ts +243 -0
- package/src/ui/tui/app.ts +7 -3
- package/src/ui/tui/transcript.ts +271 -30
- 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/cli/commands/mcp.ts
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { resolve as resolvePath } from "node:path"
|
|
2
|
+
import { configureMcpSchemaPins, mcpSchemaPinRegistry } from "../../src/mcp/client.ts"
|
|
2
3
|
|
|
3
|
-
const MCP_HELP = `minicode mcp — run minicode as an MCP server
|
|
4
|
+
const MCP_HELP = `minicode mcp — run minicode as an MCP server / inspect schema pins
|
|
4
5
|
|
|
5
6
|
minicode mcp serve [--allow-all] [--all-tools] [--cwd <dir>]
|
|
7
|
+
minicode mcp pins [--json] [--cwd <dir>]
|
|
8
|
+
minicode mcp approve <server>.<tool> <new-hash> [--cwd <dir>]
|
|
9
|
+
minicode mcp capabilities [--json]
|
|
6
10
|
|
|
7
11
|
--allow-all allow all tools without permission gating
|
|
8
12
|
--all-tools expose all tools, not only safe ones
|
|
9
|
-
--cwd <dir> workspace root
|
|
13
|
+
--cwd <dir> workspace root (pins are stored per workspace)
|
|
14
|
+
|
|
15
|
+
Schema pins live in <cwd>/.minicode/mcp-schema-pins.json. A drift is
|
|
16
|
+
fail-closed; approve explicitly with the current hash from the drift message.
|
|
10
17
|
|
|
11
18
|
MCP servers USED by minicode are configured via:
|
|
12
19
|
minicode config mcp <add|list|remove>`
|
|
13
20
|
|
|
21
|
+
// Satu situs writer per stream (writer-inventory max: 2).
|
|
22
|
+
const out = (line = ""): void => console.log(line)
|
|
23
|
+
const err = (line: string): void => console.error(line)
|
|
24
|
+
|
|
14
25
|
export async function handleMcp(
|
|
15
26
|
args: string[],
|
|
16
27
|
getArg: (name: string) => string | undefined,
|
|
17
28
|
_help: string,
|
|
18
29
|
): Promise<never> {
|
|
19
30
|
const sub = args[1]
|
|
31
|
+
const cwdArg = getArg("--cwd")
|
|
20
32
|
if (sub === "serve") {
|
|
21
33
|
const { serveMcp } = await import("../../src/mcp/server.ts")
|
|
22
|
-
const cwdArg = getArg("--cwd")
|
|
23
34
|
await serveMcp({
|
|
24
35
|
allowAll: args.includes("--allow-all"),
|
|
25
36
|
allTools: args.includes("--all-tools"),
|
|
@@ -27,10 +38,60 @@ export async function handleMcp(
|
|
|
27
38
|
})
|
|
28
39
|
process.exit(0)
|
|
29
40
|
}
|
|
41
|
+
if (sub === "pins") {
|
|
42
|
+
const cwd = cwdArg ? resolvePath(cwdArg) : undefined
|
|
43
|
+
configureMcpSchemaPins(cwd)
|
|
44
|
+
const pins = mcpSchemaPinRegistry.list()
|
|
45
|
+
if (getArg("--json") !== undefined || args.includes("--json")) {
|
|
46
|
+
out(JSON.stringify({ pins }))
|
|
47
|
+
} else if (pins.length === 0) {
|
|
48
|
+
out("no MCP schema pins recorded for this workspace")
|
|
49
|
+
} else {
|
|
50
|
+
for (const p of pins) out(`${p.serverId}.${p.toolName} ${p.hash}`)
|
|
51
|
+
}
|
|
52
|
+
process.exit(0)
|
|
53
|
+
}
|
|
54
|
+
if (sub === "capabilities") {
|
|
55
|
+
// Jujur: kami menyatakan apa yang BENAR-BENAR didukung client. Server-
|
|
56
|
+
// initiated notifications belum disurfacekan transport, jadi subscriptions
|
|
57
|
+
// TIDAK diklaim aktif.
|
|
58
|
+
const caps = {
|
|
59
|
+
tools: true,
|
|
60
|
+
resources: true,
|
|
61
|
+
prompts: true,
|
|
62
|
+
pagination: true,
|
|
63
|
+
reconnect: { supported: true, maxAttempts: 3, backoff: "exponential+jitter" },
|
|
64
|
+
subscriptions: false,
|
|
65
|
+
notifications: false,
|
|
66
|
+
note: "server-initiated notifications/resources-updated are not surfaced by this transport",
|
|
67
|
+
}
|
|
68
|
+
out(
|
|
69
|
+
getArg("--json") !== undefined || args.includes("--json")
|
|
70
|
+
? JSON.stringify(caps)
|
|
71
|
+
: JSON.stringify(caps, null, 2),
|
|
72
|
+
)
|
|
73
|
+
process.exit(0)
|
|
74
|
+
}
|
|
75
|
+
if (sub === "approve") {
|
|
76
|
+
const target = args[2]
|
|
77
|
+
const hash = args[3] ?? getArg("--hash")
|
|
78
|
+
if (!target?.includes(".") || !hash || !/^[0-9a-f]{64}$/i.test(hash)) {
|
|
79
|
+
err("usage: minicode mcp approve <server>.<tool> <64-hex-sha256> [--cwd <dir>]")
|
|
80
|
+
process.exit(2)
|
|
81
|
+
}
|
|
82
|
+
const i = target.indexOf(".")
|
|
83
|
+
const serverId = target.slice(0, i)
|
|
84
|
+
const toolName = target.slice(i + 1)
|
|
85
|
+
const cwd = cwdArg ? resolvePath(cwdArg) : undefined
|
|
86
|
+
configureMcpSchemaPins(cwd)
|
|
87
|
+
mcpSchemaPinRegistry.approveMcpSchemaUpdate(serverId, toolName, hash.toLowerCase())
|
|
88
|
+
out(`approved ${serverId}.${toolName} -> ${hash.toLowerCase()}`)
|
|
89
|
+
process.exit(0)
|
|
90
|
+
}
|
|
30
91
|
// Help kontekstual, bukan HELP global 45 baris. Subcommand asing = salah
|
|
31
92
|
// pakai (exit 2), bukan gagal runtime (exit 1).
|
|
32
93
|
const asking = sub === undefined || sub === "--help" || sub === "-h"
|
|
33
|
-
if (!asking)
|
|
34
|
-
|
|
94
|
+
if (!asking) err(`unknown mcp subcommand: ${sub}\n`)
|
|
95
|
+
out(MCP_HELP)
|
|
35
96
|
process.exit(asking ? 0 : 2)
|
|
36
97
|
}
|
package/cli/commands/memory.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs"
|
|
2
2
|
import { resolve } from "node:path"
|
|
3
|
-
import { getMemoryStats } from "../../src/memory/vector.ts"
|
|
3
|
+
import { getMemoryStats, reconcileMemoryStores } from "../../src/memory/vector.ts"
|
|
4
4
|
import { c } from "../../src/ui/render/theme.ts"
|
|
5
5
|
|
|
6
6
|
const MEMORY_HELP = `minicode memory — vector RAG store stats
|
|
7
7
|
|
|
8
|
-
minicode memory status [--json]
|
|
8
|
+
minicode memory status [--json] rows, size, models, hit-rate (default)
|
|
9
|
+
minicode memory reconcile [--json] samakan vector.db ↔ .minicode/MEMORY.md`
|
|
9
10
|
|
|
10
11
|
interface MemoryTraceRow {
|
|
11
12
|
memoryHits?: number
|
|
@@ -51,13 +52,39 @@ export async function handleMemory(
|
|
|
51
52
|
args: string[],
|
|
52
53
|
getArg: (name: string) => string | undefined,
|
|
53
54
|
): Promise<never> {
|
|
55
|
+
// Satu saluran stderr bersama (dihitung inventaris writer sebagai satu site).
|
|
56
|
+
const err = (msg: string): void => console.error(msg)
|
|
54
57
|
const sub = args[1]
|
|
55
58
|
if (sub === "--help" || sub === "-h") {
|
|
56
59
|
console.log(MEMORY_HELP)
|
|
57
60
|
process.exit(0)
|
|
58
61
|
}
|
|
62
|
+
// [PROMPT 06 · Area E / D4] `reconcileMemoryStores` sebelumnya TIDAK punya
|
|
63
|
+
// call site produksi sama sekali: pesan `write_memory` menyuruh user
|
|
64
|
+
// menjalankan `minicode memory reconcile` padahal subcommand itu tak ada —
|
|
65
|
+
// split-brain (file-only / vector-only) hanya bisa dipulihkan lewat test.
|
|
66
|
+
// Perintah ini memberi jalur pemulihan yang benar-benar dapat dijalankan.
|
|
67
|
+
if (sub === "reconcile") {
|
|
68
|
+
const cwdArg = getArg("--cwd")
|
|
69
|
+
const asJson = getArg("--json") !== undefined || args.includes("--json")
|
|
70
|
+
try {
|
|
71
|
+
const res = await reconcileMemoryStores(cwdArg)
|
|
72
|
+
const dot = "\u00b7"
|
|
73
|
+
console.log(
|
|
74
|
+
asJson
|
|
75
|
+
? JSON.stringify(res)
|
|
76
|
+
: `reconciled ${res.reconciled} entri ${dot} diadopsi dari vector ${res.vectorOnlyAdopted} ${dot} ditambah dari file ${res.fileOnlyAdded} ${dot} superseded dilewati ${res.supersededSkipped} ${dot} baris superseded dibersihkan ${res.supersededFileRemoved} ${dot} legacy perlu review ${res.legacySuspectLines}`,
|
|
77
|
+
)
|
|
78
|
+
process.exit(0)
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// Fail-closed dengan pesan actionable: DB tak terbuka (mis. path rusak)
|
|
81
|
+
// bukan alasan mencetak stack trace mentah ke user.
|
|
82
|
+
err(`memory reconcile gagal: ${(e as Error).message}`)
|
|
83
|
+
process.exit(1)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
59
86
|
if (sub && sub !== "status" && !sub.startsWith("-")) {
|
|
60
|
-
|
|
87
|
+
err(`unknown memory subcommand "${sub}" — see: minicode memory status`)
|
|
61
88
|
process.exit(2)
|
|
62
89
|
}
|
|
63
90
|
const cwdArg = getArg("--cwd")
|
|
@@ -70,6 +97,8 @@ export async function handleMemory(
|
|
|
70
97
|
console.log(
|
|
71
98
|
JSON.stringify({
|
|
72
99
|
rows: s.rows,
|
|
100
|
+
liveRows: s.liveRows,
|
|
101
|
+
supersededRows: s.supersededRows,
|
|
73
102
|
dbBytes: s.dbBytes,
|
|
74
103
|
walBytes: s.walBytes,
|
|
75
104
|
shmBytes: s.shmBytes,
|
|
@@ -86,22 +115,25 @@ export async function handleMemory(
|
|
|
86
115
|
process.exit(0)
|
|
87
116
|
}
|
|
88
117
|
const dot = "\u00b7"
|
|
89
|
-
|
|
90
|
-
`\n${c.bold("Memory")} ${s.rows} rows ${dot} ${fmtBytes(s.dbBytes + s.walBytes + s.shmBytes)} ` +
|
|
118
|
+
const lines: string[] = [
|
|
119
|
+
`\n${c.bold("Memory")} ${s.rows} rows (${s.liveRows} live ${dot} ${s.supersededRows} superseded) ${dot} ${fmtBytes(s.dbBytes + s.walBytes + s.shmBytes)} ` +
|
|
91
120
|
`(db ${fmtBytes(s.dbBytes)} ${dot} wal ${fmtBytes(s.walBytes)} ${dot} shm ${fmtBytes(s.shmBytes)})`,
|
|
92
|
-
|
|
121
|
+
]
|
|
93
122
|
if (s.models.length)
|
|
94
|
-
|
|
123
|
+
lines.push(` models: ${s.models.map((m) => `${m.model}×${m.count}`).join(", ")}`)
|
|
95
124
|
if (s.dims.length)
|
|
96
|
-
|
|
125
|
+
lines.push(` dims: ${s.dims.map((d) => `${d.dim || "none"}×${d.count}`).join(", ")}`)
|
|
97
126
|
if (s.categories.length)
|
|
98
|
-
|
|
127
|
+
lines.push(
|
|
99
128
|
` categories: ${s.categories.map((m) => `${m.category}×${m.count}`).join(", ")} (scope: ${scope})`,
|
|
100
129
|
)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
130
|
+
lines.push(` range: ${fmtDate(s.oldest)} → ${fmtDate(s.newest)}`)
|
|
131
|
+
lines.push(
|
|
132
|
+
runs > 0
|
|
133
|
+
? ` RAG hit-rate: ${avgHits.toFixed(2)} hits/run over ${runs} traced runs`
|
|
134
|
+
: c.dim(` (no memoryHits in traces yet — run once to measure hit-rate)`),
|
|
135
|
+
)
|
|
136
|
+
lines.push("")
|
|
137
|
+
console.log(lines.join("\n"))
|
|
106
138
|
process.exit(0)
|
|
107
139
|
}
|
package/cli/commands.ts
CHANGED
|
@@ -36,6 +36,9 @@ export interface CommandContext {
|
|
|
36
36
|
skills: Skill[]
|
|
37
37
|
toolsCount: number
|
|
38
38
|
providerHint?: string
|
|
39
|
+
/** P1.2: WorkMode adalah lapis intent, TERPISAH dari permission mode. */
|
|
40
|
+
workMode?: string
|
|
41
|
+
permissionMode?: string
|
|
39
42
|
setModelOverride: (model: string) => void
|
|
40
43
|
/** Dipanggil sebelum spawn anak stdio-inherit — composition root (tui.ts)
|
|
41
44
|
* mengisinya (saat ini no-op; DECSTBM tak pernah dipakai lagi). Tanpa
|
|
@@ -212,6 +215,8 @@ function statusLines(ctx: CommandContext): string[] {
|
|
|
212
215
|
t("st.model", { v: ctx.currentModel ?? "default" }),
|
|
213
216
|
t("st.provider", { v: provider }),
|
|
214
217
|
t("st.tools", { v: ctx.toolsCount }),
|
|
218
|
+
t("st.workMode", { v: ctx.workMode ?? "EXECUTE" }),
|
|
219
|
+
t("st.permissionMode", { v: ctx.permissionMode ?? "auto" }),
|
|
215
220
|
t("st.context", { v: ctx.getContextTokens().toLocaleString() }),
|
|
216
221
|
t("st.turn", { v: last.totalTokens.toLocaleString() }),
|
|
217
222
|
t("st.input", { v: u.inputTokens.toLocaleString() }),
|
package/cli/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { parseCompactKeepTurns } from "../src/policy/compaction.ts"
|
|
|
7
7
|
import { createRateLimiter } from "../src/policy/ratelimit.ts"
|
|
8
8
|
import { resolveSandbox, sandboxRefusalReason } from "../src/policy/sandbox-policy.ts"
|
|
9
9
|
import { budgetStatus } from "../src/policy/usage.ts"
|
|
10
|
+
import { VerifyWorkModeConflictError } from "../src/policy/work-mode.ts"
|
|
10
11
|
import { resolveRuntimeMode } from "../src/runtime/production-execution.ts"
|
|
11
12
|
import { AdoptionRefusedError, parseAdoptTaskArg } from "../src/session/cross-session-adoption.ts"
|
|
12
13
|
import { mintSessionId } from "../src/session/identity.ts"
|
|
@@ -17,11 +18,12 @@ import { findSkill, renderSkill } from "../src/skills/loader.ts"
|
|
|
17
18
|
import { GATE_ENABLED, resolveSchedulerGate } from "../src/task/production-scheduler.ts"
|
|
18
19
|
import { writeTrace } from "../src/telemetry/trace.ts"
|
|
19
20
|
import { setSubAgentSessionFactory } from "../src/tools/task.ts"
|
|
20
|
-
import { formatError
|
|
21
|
+
import { formatError } from "../src/ui/assistant/simple.ts"
|
|
21
22
|
import { formatUsd } from "../src/ui/render/money.ts"
|
|
22
23
|
import { c, glyphs } from "../src/ui/render/theme.ts"
|
|
23
24
|
import {
|
|
24
25
|
allowLocalConfig,
|
|
26
|
+
flagsAfterPromptBoundary,
|
|
25
27
|
hasFlag,
|
|
26
28
|
promptFromArgs,
|
|
27
29
|
getArg as rawGetArg,
|
|
@@ -90,7 +92,7 @@ Options:
|
|
|
90
92
|
admitted through the runtime (kernel + durable journal); a rejected
|
|
91
93
|
admission runs nothing. Unknown value = off.
|
|
92
94
|
|
|
93
|
-
TUI: /help /provider /model /sync /status /sessions /init /exit /mode /undo /redo /clear /copy /history /compact /thinking /minimize
|
|
95
|
+
TUI: /help /provider /model /sync /status /sessions /init /exit /mode /work-mode /undo /redo /clear /copy /history /compact /thinking /minimize
|
|
94
96
|
Keys: Enter submit · Tab/Shift+Tab mode · Up/Down history · Mouse wheel/PgUp/PgDn scroll (Shift = half page)
|
|
95
97
|
Home/End jump to transcript top/tail · Ctrl+R search · Esc abort turn (twice = quit) · Ctrl+D exit
|
|
96
98
|
Subcommand flags (config/mcp/sessions/skills/exec/...): see 'minicode <cmd> --help'.
|
|
@@ -288,6 +290,10 @@ const allowLocal = allowLocalConfig(args)
|
|
|
288
290
|
// disamakan dengan WorkMode PLAN — keduanya lapisan terpisah.
|
|
289
291
|
const workModeResolved = resolveWorkModeFlag(getArg)
|
|
290
292
|
const workMode = workModeResolved.workMode
|
|
293
|
+
// P12 S2.2 (D-2) — Sinyal WorkMode eksplisit (flag/env) ikut diteruskan supaya
|
|
294
|
+
// jalur resume bisa memberi tahu transparan bahwa WorkMode TIDAK dipersist dan
|
|
295
|
+
// default EXECUTE saat tak diberi ulang.
|
|
296
|
+
const workModeExplicit = workModeResolved.explicit
|
|
291
297
|
if (workModeResolved.warning) process.stderr.write(`[warn] ${workModeResolved.warning}\n`)
|
|
292
298
|
// [PHASE 6U] Autonomous Scheduler opt-in. DEFAULT OFF.
|
|
293
299
|
//
|
|
@@ -426,6 +432,16 @@ if (ratelimitRaw) {
|
|
|
426
432
|
}
|
|
427
433
|
|
|
428
434
|
const prompt = promptFromArgs(args) || (await readPrompt())
|
|
435
|
+
// [Live Hardening 0.13.x §8.3] Flag dikenal yang muncul SETELAH prompt boundary
|
|
436
|
+
// menjadi teks prompt (pertahanan anti-injeksi), bukan flag terparse — operator
|
|
437
|
+
// yang salah letak flag diam-diam tidak mendapat perilaku yang diminta (stage5:
|
|
438
|
+
// --resume dibuang). Peringatan actionable, hanya bila nyata ada flag tersisip.
|
|
439
|
+
const ignoredFlags = flagsAfterPromptBoundary(args)
|
|
440
|
+
if (ignoredFlags.length > 0) {
|
|
441
|
+
process.stderr.write(
|
|
442
|
+
`[warn] ignored flag(s) after the prompt: ${ignoredFlags.join(", ")} — put flags before the prompt (e.g. minicode ${ignoredFlags.join(" ")} "your prompt")\n`,
|
|
443
|
+
)
|
|
444
|
+
}
|
|
429
445
|
const enterRepl = interactive || (!prompt && process.stdin.isTTY)
|
|
430
446
|
// REPL interaktif: cek update FRESH tiap dibuka → install + restart bila ada
|
|
431
447
|
// versi baru (tak pernah kembali bila restart). Tampilkan spinner 1.8 dtk
|
|
@@ -517,6 +533,8 @@ try {
|
|
|
517
533
|
toolScope,
|
|
518
534
|
// P12 S2.2 — WorkMode efektif (sudah di-resolve, default EXECUTE).
|
|
519
535
|
workMode,
|
|
536
|
+
// P12 S2.2 (D-2) — transparansi resume: tahu apakah WorkMode diberi eksplisit.
|
|
537
|
+
workModeExplicit,
|
|
520
538
|
maxSteps,
|
|
521
539
|
contextWindowTokens,
|
|
522
540
|
...(keepRecentTurns !== undefined ? { keepRecentTurns } : {}),
|
|
@@ -538,9 +556,9 @@ try {
|
|
|
538
556
|
// DIGABUNG ke cabang NoProvider di atas (satu writer untuk kelas
|
|
539
557
|
// "setup menolak, bukan gagal"): menambah penulis kedua hanya untuk satu
|
|
540
558
|
// format pesan menaikkan inventaris writer tanpa menambah informasi.
|
|
541
|
-
if (e instanceof AdoptionRefusedError) {
|
|
559
|
+
if (e instanceof AdoptionRefusedError || e instanceof VerifyWorkModeConflictError) {
|
|
542
560
|
console.error(e.message)
|
|
543
|
-
process.exit(1)
|
|
561
|
+
process.exit(e instanceof VerifyWorkModeConflictError ? 2 : 1)
|
|
544
562
|
}
|
|
545
563
|
throw e
|
|
546
564
|
} finally {
|
|
@@ -553,6 +571,13 @@ if (enterRepl) {
|
|
|
553
571
|
const { runTui } = await import("./tui.ts")
|
|
554
572
|
await runTui(ctx)
|
|
555
573
|
} else {
|
|
574
|
+
// P12 S2.2 (F-DISCUSS-4) + P0.2: one-shot linear memakai `ctx.workMode`
|
|
575
|
+
// efektif (termasuk hasil pulihan `--resume`).
|
|
576
|
+
if (ctx.workMode !== "EXECUTE") {
|
|
577
|
+
process.stderr.write(
|
|
578
|
+
`[work-mode] ${ctx.workMode}${ctx.workMode === "PLAN" ? " (read-only planning)" : " (read-only)"}\n`,
|
|
579
|
+
)
|
|
580
|
+
}
|
|
556
581
|
const {
|
|
557
582
|
session,
|
|
558
583
|
usage,
|
|
@@ -632,7 +657,7 @@ if (enterRepl) {
|
|
|
632
657
|
} catch (e) {
|
|
633
658
|
// Error provider biasanya sudah dirender ramah oleh event handler
|
|
634
659
|
// (takePendingError) — cetak sekali saja, jangan dua blok ✗.
|
|
635
|
-
const shown = takePendingError()
|
|
660
|
+
const shown = ctx.uiState.takePendingError()
|
|
636
661
|
process.stderr.write(`\n${c.red(glyphs.cross)} ${shown ?? formatError(e)}\n`)
|
|
637
662
|
// Audit #04 P1: sama seperti REPL — turn gagal setelah delegasi
|
|
638
663
|
// committed = efek anak tetap ada. One-shot tak punya retry loop, tapi
|
package/cli/minicode.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// Gerbang bin untuk npm. Bin berupa berkas `.ts` kurang disukai tooling npm,
|
|
3
|
+
// dan path bin dengan prefix `./` memicu warning `"bin[...] ... invalid and removed"`
|
|
4
|
+
// saat publish. Wrapper `.js` ini memuat entry CLI TypeScript asli (cli/index.ts)
|
|
5
|
+
// via Bun; seluruh logika tetap di index.ts.
|
|
6
|
+
import "./index.ts"
|