minicode-ai 0.28.0 → 0.30.1
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 +93 -70
- package/cli/bootstrap/presentation-bridge.ts +383 -0
- package/cli/commands/acp.ts +7 -1
- package/cli/commands/doctor.ts +7 -3
- package/cli/commands/exec.ts +6 -16
- package/cli/index.ts +3 -2
- package/cli/setup.ts +13 -380
- package/cli/tui.ts +3 -4
- package/docs/TERMINAL_CONTRACT.md +28 -21
- package/docs/UI_RENDER_PIPELINE.md +3 -3
- package/docs/architecture.md +14 -29
- package/docs/environment.md +1 -1
- package/package.json +1 -1
- package/src/app/session.ts +201 -53
- package/src/app/tool-layer.ts +27 -0
- package/src/lib/atomic-write.ts +31 -59
- package/src/policy/jail.ts +6 -8
- package/src/providers/anthropic.ts +16 -5
- package/src/providers/responses.ts +37 -7
- package/src/providers/sse-bounds.ts +6 -4
- package/src/session/db/runs.ts +397 -0
- package/src/session/db/schema.ts +358 -0
- package/src/session/persistence.ts +64 -955
- package/src/task/db/schema.ts +325 -0
- package/src/task/db/types.ts +269 -0
- package/src/task/store.ts +74 -986
- package/src/ui/assistant/simple.ts +25 -19
- package/src/ui/i18n/en.ts +0 -3
- package/src/ui/i18n/id.ts +0 -3
- package/src/ui/render/logo.ts +15 -18
- package/src/ui/render/markdown-layout.ts +293 -0
- package/src/ui/render/markdown.ts +36 -44
- package/src/ui/render/session-summary.ts +1 -1
- package/src/ui/render/table-grid.ts +16 -7
- package/src/ui/render/width.ts +71 -18
- package/src/ui/render/wrap.ts +39 -22
- package/src/ui/session-state.ts +4 -4
- package/src/ui/tui/app.ts +15 -36
- package/src/ui/tui/transcript.ts +111 -50
- package/vendor/minicore/src/providers/openai-compat.ts +7 -0
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ minicode providers # inspect configured providers
|
|
|
34
34
|
minicode exec "task" --json # machine-readable event stream
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
WorkMode controls how the agent works (`DISCUSS
|
|
37
|
+
WorkMode controls how the agent works (`DISCUSS` or `BUILD`); permission settings and tool access policy control which actions require approval or are available. Read [Choosing a mode](docs/choosing-mode.md) before granting write or execution access. `--sandbox docker` requests an isolated container for shell execution; the [security guide](docs/security.md) explains the remaining boundaries.
|
|
38
38
|
|
|
39
39
|
## Documentation
|
|
40
40
|
|
package/cli/args.ts
CHANGED
|
@@ -1,87 +1,110 @@
|
|
|
1
1
|
// Pure arg-parsing helpers - dipisah dari cli/index.ts agar mudah diuji.
|
|
2
2
|
import { sanitizeAnsiLine } from "../src/ui/render/sanitize.ts"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
4
|
+
export type CliFlagKind = "boolean" | "value" | "meta"
|
|
5
|
+
|
|
6
|
+
export interface CliFlagSpec {
|
|
7
|
+
readonly kind: CliFlagKind
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Tabel deklaratif tunggal seluruh flag CLI yang dikenal parser — BOOLEAN_FLAGS,
|
|
11
|
+
// VALUE_FLAGS, dan KNOWN_FLAGS diturunkan darinya agar tidak menyimpang.
|
|
12
|
+
export const CLI_FLAG_SPECS: Readonly<Record<string, CliFlagSpec>> = {
|
|
13
|
+
// ── Flag meta ─────────────────────────────────────────────────────────────
|
|
14
|
+
"-h": { kind: "meta" },
|
|
15
|
+
"--help": { kind: "meta" },
|
|
16
|
+
"-v": { kind: "meta" },
|
|
17
|
+
"--version": { kind: "meta" },
|
|
18
|
+
|
|
19
|
+
// ── Flag boolean ──────────────────────────────────────────────────────────
|
|
20
|
+
"--verbose": { kind: "boolean" },
|
|
21
|
+
"--allow-all": { kind: "boolean" },
|
|
22
|
+
"-y": { kind: "boolean" }, // alias ringkas untuk --allow-all
|
|
23
|
+
"--ask": { kind: "boolean" },
|
|
24
|
+
"--interactive": { kind: "boolean" },
|
|
25
|
+
"--tui": { kind: "boolean" }, // alias usang: TUI fullscreen kini satu-satunya tampilan interaktif
|
|
26
|
+
"--verify": { kind: "boolean" },
|
|
27
|
+
"--allowlist": { kind: "boolean" },
|
|
28
|
+
"--json": { kind: "boolean" }, // dipakai `exec --json` dan `--help --json`
|
|
29
|
+
"--budget-strict": { kind: "boolean" }, // penegasan eksplisit fail-closed (kini juga default --budget)
|
|
30
|
+
"--allow-local-config": { kind: "boolean" }, // opt-in: baca .minicode/config.json + allowlist lokal (default mati)
|
|
15
31
|
// flag boolean subcommand — harus di sini agar router tidak memakan token berikutnya sebagai nilai
|
|
16
|
-
"--allow-private",
|
|
17
|
-
"--jsonl",
|
|
18
|
-
"--all-tools",
|
|
19
|
-
"--global",
|
|
20
|
-
"--local",
|
|
21
|
-
"--auto-continue",
|
|
22
|
-
"--blocked",
|
|
23
|
-
"--closed",
|
|
24
|
-
"--force",
|
|
32
|
+
"--allow-private": { kind: "boolean" },
|
|
33
|
+
"--jsonl": { kind: "boolean" },
|
|
34
|
+
"--all-tools": { kind: "boolean" },
|
|
35
|
+
"--global": { kind: "boolean" },
|
|
36
|
+
"--local": { kind: "boolean" },
|
|
37
|
+
"--auto-continue": { kind: "boolean" },
|
|
38
|
+
"--blocked": { kind: "boolean" },
|
|
39
|
+
"--closed": { kind: "boolean" },
|
|
40
|
+
"--force": { kind: "boolean" },
|
|
25
41
|
// [PHASE 6U] Experimental. Opt-in gate for autonomous Scheduler execution.
|
|
26
42
|
// DEFAULT OFF. A CLI flag and not a config key or env var on purpose: env is
|
|
27
43
|
// inherited by sub-agents and MCP servers, and config is inherited globally or
|
|
28
44
|
// per-repo — both would let autonomous execution switch on without the person
|
|
29
45
|
// running the process asking for it. See src/task/production-scheduler.ts.
|
|
30
|
-
"--enable-scheduler",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"--cwd",
|
|
34
|
-
"--resume",
|
|
35
|
-
"--model",
|
|
36
|
-
"--provider",
|
|
37
|
-
"--session",
|
|
38
|
-
"--max-steps",
|
|
39
|
-
"--context-window",
|
|
40
|
-
"--timeout",
|
|
41
|
-
"--sandbox",
|
|
42
|
-
"--ratelimit",
|
|
43
|
-
"--budget",
|
|
44
|
-
"--tool-scope", // full | explore (read-only) — tanpa ini jadi kata prompt!
|
|
45
|
-
"--work-mode", // DISCUSS | BUILD — HARUS dikenal agar tak bocor ke prompt.
|
|
46
|
+
"--enable-scheduler": { kind: "boolean" },
|
|
47
|
+
|
|
48
|
+
// ── Flag bernilai ─────────────────────────────────────────────────────────
|
|
49
|
+
"--cwd": { kind: "value" },
|
|
50
|
+
"--resume": { kind: "value" },
|
|
51
|
+
"--model": { kind: "value" },
|
|
52
|
+
"--provider": { kind: "value" },
|
|
53
|
+
"--session": { kind: "value" },
|
|
54
|
+
"--max-steps": { kind: "value" },
|
|
55
|
+
"--context-window": { kind: "value" },
|
|
56
|
+
"--timeout": { kind: "value" },
|
|
57
|
+
"--sandbox": { kind: "value" },
|
|
58
|
+
"--ratelimit": { kind: "value" },
|
|
59
|
+
"--budget": { kind: "value" },
|
|
60
|
+
"--tool-scope": { kind: "value" }, // full | explore (read-only) — tanpa ini jadi kata prompt!
|
|
61
|
+
"--work-mode": { kind: "value" }, // DISCUSS | BUILD — HARUS dikenal agar tak bocor ke prompt.
|
|
62
|
+
"--mode": { kind: "value" }, // alias ringkas untuk --work-mode (DISCUSS | BUILD)
|
|
46
63
|
// [P1 M15] Mode runtime produksi (off | constructed | owned). HARUS terdaftar:
|
|
47
64
|
// flag tak dikenal menghentikan scan `hasFlag`/`getArg` (dianggap prompt
|
|
48
65
|
// boundary), sehingga flag yang diletakkan SETELAH `--runtime` akan hilang
|
|
49
66
|
// diam-diam — tepat kebocoran semantik yang ingin dicegah audit flag.
|
|
50
|
-
"--runtime",
|
|
51
|
-
"--output-format", // `exec --output-format=json`
|
|
52
|
-
"--prompt",
|
|
67
|
+
"--runtime": { kind: "value" },
|
|
68
|
+
"--output-format": { kind: "value" }, // `exec --output-format=json`
|
|
69
|
+
"--prompt": { kind: "value" },
|
|
53
70
|
// subcommand flags — harus dikenal agar tidak bocor ke prompt one-shot
|
|
54
|
-
"--baseUrl",
|
|
55
|
-
"--apiKey",
|
|
56
|
-
"--id",
|
|
57
|
-
"--command",
|
|
58
|
-
"--args",
|
|
59
|
-
"--env",
|
|
60
|
-
"--header",
|
|
61
|
-
"--url",
|
|
62
|
-
"--match",
|
|
63
|
-
"--adopt-task",
|
|
64
|
-
"--max-turns",
|
|
65
|
-
"--port",
|
|
66
|
-
"--who",
|
|
67
|
-
"--scopes",
|
|
68
|
-
"--ttl",
|
|
69
|
-
"--hash",
|
|
70
|
-
"--status",
|
|
71
|
-
"--state",
|
|
72
|
-
"--priority",
|
|
73
|
-
"--min-age-days",
|
|
74
|
-
"--depends-on",
|
|
75
|
-
"--stale-days",
|
|
76
|
-
"--keep",
|
|
77
|
-
"--drop",
|
|
78
|
-
"--evidence",
|
|
79
|
-
"--task",
|
|
80
|
-
"--format",
|
|
81
|
-
"--out",
|
|
82
|
-
|
|
71
|
+
"--baseUrl": { kind: "value" },
|
|
72
|
+
"--apiKey": { kind: "value" },
|
|
73
|
+
"--id": { kind: "value" },
|
|
74
|
+
"--command": { kind: "value" },
|
|
75
|
+
"--args": { kind: "value" },
|
|
76
|
+
"--env": { kind: "value" },
|
|
77
|
+
"--header": { kind: "value" },
|
|
78
|
+
"--url": { kind: "value" },
|
|
79
|
+
"--match": { kind: "value" },
|
|
80
|
+
"--adopt-task": { kind: "value" },
|
|
81
|
+
"--max-turns": { kind: "value" },
|
|
82
|
+
"--port": { kind: "value" },
|
|
83
|
+
"--who": { kind: "value" },
|
|
84
|
+
"--scopes": { kind: "value" },
|
|
85
|
+
"--ttl": { kind: "value" },
|
|
86
|
+
"--hash": { kind: "value" },
|
|
87
|
+
"--status": { kind: "value" },
|
|
88
|
+
"--state": { kind: "value" },
|
|
89
|
+
"--priority": { kind: "value" },
|
|
90
|
+
"--min-age-days": { kind: "value" },
|
|
91
|
+
"--depends-on": { kind: "value" },
|
|
92
|
+
"--stale-days": { kind: "value" },
|
|
93
|
+
"--keep": { kind: "value" },
|
|
94
|
+
"--drop": { kind: "value" },
|
|
95
|
+
"--evidence": { kind: "value" },
|
|
96
|
+
"--task": { kind: "value" },
|
|
97
|
+
"--format": { kind: "value" },
|
|
98
|
+
"--out": { kind: "value" },
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const VALUE_FLAGS = new Set(
|
|
102
|
+
Object.entries(CLI_FLAG_SPECS)
|
|
103
|
+
.filter(([, spec]) => spec.kind === "value")
|
|
104
|
+
.map(([name]) => name),
|
|
105
|
+
)
|
|
83
106
|
export const valueFlags = VALUE_FLAGS
|
|
84
|
-
const KNOWN_FLAGS = new Set(
|
|
107
|
+
const KNOWN_FLAGS = new Set(Object.keys(CLI_FLAG_SPECS))
|
|
85
108
|
|
|
86
109
|
/** `--flag` atau `--flag=value` -> normalisasi ke nama flag murni. */
|
|
87
110
|
export function flagNameOf(token: string): string | null {
|
|
@@ -240,7 +263,7 @@ export function resolveWorkModeFlag(getArg: (n: string) => string | undefined):
|
|
|
240
263
|
explicit: boolean
|
|
241
264
|
warning?: string
|
|
242
265
|
} {
|
|
243
|
-
const raw = getArg("--work-mode") ?? process.env.MINICODE_WORK_MODE
|
|
266
|
+
const raw = getArg("--work-mode") ?? getArg("--mode") ?? process.env.MINICODE_WORK_MODE
|
|
244
267
|
if (raw === undefined) return { workMode: "DISCUSS", explicit: false }
|
|
245
268
|
const parsed = parseWorkModeValue(raw)
|
|
246
269
|
if (parsed) return { workMode: parsed, explicit: true }
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { createLlmCompaction } from "../../src/policy/compaction.ts"
|
|
2
|
+
import type { DomainEvent } from "../../src/presentation/events.ts"
|
|
3
|
+
import type { UiPresentationEvent } from "../../src/ui/contract.ts"
|
|
4
|
+
|
|
5
|
+
/** Peta exhaustive dari `DomainEvent` ke kontrak event UI lintas lapisan. */
|
|
6
|
+
function mapPresentationEvent(event: DomainEvent): UiPresentationEvent | null {
|
|
7
|
+
switch (event.type) {
|
|
8
|
+
case "user.message":
|
|
9
|
+
return {
|
|
10
|
+
type: event.type,
|
|
11
|
+
seq: event.eventSeq,
|
|
12
|
+
turnId: event.turnId,
|
|
13
|
+
text: event.text,
|
|
14
|
+
promptRef: event.promptRef,
|
|
15
|
+
}
|
|
16
|
+
case "turn.started":
|
|
17
|
+
return {
|
|
18
|
+
type: event.type,
|
|
19
|
+
seq: event.eventSeq,
|
|
20
|
+
turnId: event.turnId,
|
|
21
|
+
promptRef: event.promptRef,
|
|
22
|
+
}
|
|
23
|
+
case "turn.completed":
|
|
24
|
+
return {
|
|
25
|
+
type: event.type,
|
|
26
|
+
seq: event.eventSeq,
|
|
27
|
+
turnId: event.turnId,
|
|
28
|
+
summary: event.summary,
|
|
29
|
+
}
|
|
30
|
+
case "turn.failed":
|
|
31
|
+
return {
|
|
32
|
+
type: event.type,
|
|
33
|
+
seq: event.eventSeq,
|
|
34
|
+
turnId: event.turnId,
|
|
35
|
+
error: event.error.message,
|
|
36
|
+
cause: event.error.cause,
|
|
37
|
+
}
|
|
38
|
+
case "turn.cancelled":
|
|
39
|
+
return {
|
|
40
|
+
type: event.type,
|
|
41
|
+
seq: event.eventSeq,
|
|
42
|
+
turnId: event.turnId,
|
|
43
|
+
reason: event.reason,
|
|
44
|
+
}
|
|
45
|
+
case "model.delta":
|
|
46
|
+
return {
|
|
47
|
+
type: event.type,
|
|
48
|
+
seq: event.eventSeq,
|
|
49
|
+
turnId: event.turnId,
|
|
50
|
+
delta: event.delta,
|
|
51
|
+
}
|
|
52
|
+
case "model.completed":
|
|
53
|
+
return {
|
|
54
|
+
type: event.type,
|
|
55
|
+
seq: event.eventSeq,
|
|
56
|
+
turnId: event.turnId,
|
|
57
|
+
text: event.text,
|
|
58
|
+
truncated: event.truncated,
|
|
59
|
+
...(event.expandRef ? { expandRef: event.expandRef } : {}),
|
|
60
|
+
}
|
|
61
|
+
case "reasoning.delta":
|
|
62
|
+
return {
|
|
63
|
+
type: event.type,
|
|
64
|
+
seq: event.eventSeq,
|
|
65
|
+
turnId: event.turnId,
|
|
66
|
+
delta: event.delta,
|
|
67
|
+
}
|
|
68
|
+
case "reasoning.completed":
|
|
69
|
+
return {
|
|
70
|
+
type: event.type,
|
|
71
|
+
seq: event.eventSeq,
|
|
72
|
+
turnId: event.turnId,
|
|
73
|
+
truncated: event.truncated,
|
|
74
|
+
expandRef: event.expandRef,
|
|
75
|
+
}
|
|
76
|
+
case "tool.started":
|
|
77
|
+
return {
|
|
78
|
+
type: event.type,
|
|
79
|
+
seq: event.eventSeq,
|
|
80
|
+
turnId: event.turnId,
|
|
81
|
+
stepId: event.stepId,
|
|
82
|
+
toolCallId: event.toolCallId,
|
|
83
|
+
name: event.identity.name,
|
|
84
|
+
qualified: event.identity.qualified,
|
|
85
|
+
target: event.argsSummary.target,
|
|
86
|
+
status: "running",
|
|
87
|
+
tsStart: event.ts,
|
|
88
|
+
...(event.parentLink ? { parentToolCallId: event.parentLink.parentToolCallId } : {}),
|
|
89
|
+
}
|
|
90
|
+
case "tool.progress":
|
|
91
|
+
return {
|
|
92
|
+
type: event.type,
|
|
93
|
+
seq: event.eventSeq,
|
|
94
|
+
turnId: event.turnId,
|
|
95
|
+
toolCallId: event.toolCallId,
|
|
96
|
+
status: "running",
|
|
97
|
+
message: event.message,
|
|
98
|
+
}
|
|
99
|
+
case "tool.completed":
|
|
100
|
+
return {
|
|
101
|
+
type: event.type,
|
|
102
|
+
seq: event.eventSeq,
|
|
103
|
+
turnId: event.turnId,
|
|
104
|
+
toolCallId: event.toolCallId,
|
|
105
|
+
status: "completed",
|
|
106
|
+
durationMs: event.durationMs,
|
|
107
|
+
toolSummary: event.summary,
|
|
108
|
+
expandRef: event.expandRef,
|
|
109
|
+
...(event.receipt
|
|
110
|
+
? {
|
|
111
|
+
receipt: {
|
|
112
|
+
...(event.receipt.paths ? { paths: event.receipt.paths } : {}),
|
|
113
|
+
...(event.receipt.checkpointId ? { checkpointId: event.receipt.checkpointId } : {}),
|
|
114
|
+
...(event.receipt.stats ? { stats: event.receipt.stats } : {}),
|
|
115
|
+
...(event.receipt.test ? { test: event.receipt.test } : {}),
|
|
116
|
+
...(event.receipt.cmd ? { cmd: event.receipt.cmd } : {}),
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
...(event.parentLink ? { parentToolCallId: event.parentLink.parentToolCallId } : {}),
|
|
121
|
+
}
|
|
122
|
+
case "tool.failed":
|
|
123
|
+
return {
|
|
124
|
+
type: event.type,
|
|
125
|
+
seq: event.eventSeq,
|
|
126
|
+
turnId: event.turnId,
|
|
127
|
+
toolCallId: event.toolCallId,
|
|
128
|
+
status: "failed",
|
|
129
|
+
durationMs: event.durationMs,
|
|
130
|
+
message: event.message,
|
|
131
|
+
cause: event.cause,
|
|
132
|
+
...(event.hint ? { hint: event.hint } : {}),
|
|
133
|
+
...(event.schemaDrift ? { schemaDrift: event.schemaDrift } : {}),
|
|
134
|
+
expandRef: event.expandRef,
|
|
135
|
+
...(event.parentLink ? { parentToolCallId: event.parentLink.parentToolCallId } : {}),
|
|
136
|
+
}
|
|
137
|
+
case "tool.denied":
|
|
138
|
+
return {
|
|
139
|
+
type: event.type,
|
|
140
|
+
seq: event.eventSeq,
|
|
141
|
+
turnId: event.turnId,
|
|
142
|
+
toolCallId: event.toolCallId,
|
|
143
|
+
status: "denied",
|
|
144
|
+
message: event.message,
|
|
145
|
+
reason: event.reason,
|
|
146
|
+
...(event.parentLink ? { parentToolCallId: event.parentLink.parentToolCallId } : {}),
|
|
147
|
+
}
|
|
148
|
+
case "tool.cancelled":
|
|
149
|
+
return {
|
|
150
|
+
type: event.type,
|
|
151
|
+
seq: event.eventSeq,
|
|
152
|
+
turnId: event.turnId,
|
|
153
|
+
toolCallId: event.toolCallId,
|
|
154
|
+
status: "cancelled",
|
|
155
|
+
reason: event.reason,
|
|
156
|
+
...(event.parentLink ? { parentToolCallId: event.parentLink.parentToolCallId } : {}),
|
|
157
|
+
}
|
|
158
|
+
case "approval.requested":
|
|
159
|
+
return {
|
|
160
|
+
type: event.type,
|
|
161
|
+
seq: event.eventSeq,
|
|
162
|
+
turnId: event.turnId,
|
|
163
|
+
approvalId: event.approvalId,
|
|
164
|
+
toolCallId: event.toolCallId,
|
|
165
|
+
name: event.identity.name,
|
|
166
|
+
qualified: event.identity.qualified,
|
|
167
|
+
target: event.argsSummary.target,
|
|
168
|
+
via: event.via,
|
|
169
|
+
...(event.riskTier ? { riskTier: event.riskTier } : {}),
|
|
170
|
+
...(event.diffPreview ? { diffPreview: event.diffPreview } : {}),
|
|
171
|
+
}
|
|
172
|
+
case "approval.settled":
|
|
173
|
+
return {
|
|
174
|
+
type: event.type,
|
|
175
|
+
seq: event.eventSeq,
|
|
176
|
+
turnId: event.turnId,
|
|
177
|
+
approvalId: event.approvalId,
|
|
178
|
+
toolCallId: event.toolCallId,
|
|
179
|
+
outcome: event.outcome,
|
|
180
|
+
}
|
|
181
|
+
case "file.changed":
|
|
182
|
+
return {
|
|
183
|
+
type: event.type,
|
|
184
|
+
seq: event.eventSeq,
|
|
185
|
+
turnId: event.turnId,
|
|
186
|
+
toolCallId: event.toolCallId,
|
|
187
|
+
paths: event.paths,
|
|
188
|
+
...(event.journalSeq !== undefined ? { journalSeq: event.journalSeq } : {}),
|
|
189
|
+
...(event.checkpointId ? { checkpointId: event.checkpointId } : {}),
|
|
190
|
+
}
|
|
191
|
+
case "test.completed":
|
|
192
|
+
return {
|
|
193
|
+
type: event.type,
|
|
194
|
+
seq: event.eventSeq,
|
|
195
|
+
turnId: event.turnId,
|
|
196
|
+
toolCallId: event.toolCallId,
|
|
197
|
+
test: { passed: event.passed, failed: event.failed, summary: event.summary },
|
|
198
|
+
}
|
|
199
|
+
case "verification.observed":
|
|
200
|
+
return {
|
|
201
|
+
type: event.type,
|
|
202
|
+
seq: event.eventSeq,
|
|
203
|
+
turnId: event.turnId,
|
|
204
|
+
toolCallId: event.toolCallId,
|
|
205
|
+
invocationId: event.invocationId,
|
|
206
|
+
verification: {
|
|
207
|
+
invocationId: event.invocationId,
|
|
208
|
+
verdict: event.verdict,
|
|
209
|
+
method: event.method,
|
|
210
|
+
observedAt: event.observedAt,
|
|
211
|
+
},
|
|
212
|
+
...(event.parentLink ? { parentToolCallId: event.parentLink.parentToolCallId } : {}),
|
|
213
|
+
}
|
|
214
|
+
case "context.compacted":
|
|
215
|
+
return {
|
|
216
|
+
type: event.type,
|
|
217
|
+
seq: event.eventSeq,
|
|
218
|
+
turnId: event.turnId,
|
|
219
|
+
reason: event.reason,
|
|
220
|
+
compactionReason: event.reason,
|
|
221
|
+
}
|
|
222
|
+
case "plan.updated":
|
|
223
|
+
return {
|
|
224
|
+
type: event.type,
|
|
225
|
+
seq: event.eventSeq,
|
|
226
|
+
turnId: event.turnId,
|
|
227
|
+
planId: event.planId,
|
|
228
|
+
status: event.status === "open" ? "running" : event.status,
|
|
229
|
+
steps: event.steps,
|
|
230
|
+
...(event.expandRef ? { expandRef: event.expandRef } : {}),
|
|
231
|
+
}
|
|
232
|
+
case "finding.detected":
|
|
233
|
+
return {
|
|
234
|
+
type: event.type,
|
|
235
|
+
seq: event.eventSeq,
|
|
236
|
+
turnId: event.turnId,
|
|
237
|
+
findingId: event.findingId,
|
|
238
|
+
category: event.category,
|
|
239
|
+
severity: event.severity,
|
|
240
|
+
text: event.summary,
|
|
241
|
+
evidence: event.evidence,
|
|
242
|
+
...(event.parentLink ? { parentToolCallId: event.parentLink.parentToolCallId } : {}),
|
|
243
|
+
}
|
|
244
|
+
case "result.produced":
|
|
245
|
+
return {
|
|
246
|
+
type: event.type,
|
|
247
|
+
seq: event.eventSeq,
|
|
248
|
+
turnId: event.turnId,
|
|
249
|
+
resultId: event.resultId,
|
|
250
|
+
status: event.status === "completed" ? "completed" : event.status,
|
|
251
|
+
toolSummary: event.summary,
|
|
252
|
+
action: event.action,
|
|
253
|
+
...(event.expandRef ? { expandRef: event.expandRef } : {}),
|
|
254
|
+
}
|
|
255
|
+
case "diagnostic.raised":
|
|
256
|
+
return {
|
|
257
|
+
type: event.type,
|
|
258
|
+
seq: event.eventSeq,
|
|
259
|
+
turnId: event.turnId,
|
|
260
|
+
category: event.category,
|
|
261
|
+
severity: event.severity,
|
|
262
|
+
message: event.message,
|
|
263
|
+
cause: event.cause,
|
|
264
|
+
action: event.action,
|
|
265
|
+
}
|
|
266
|
+
case "checkpoint.created":
|
|
267
|
+
return {
|
|
268
|
+
type: event.type,
|
|
269
|
+
seq: event.eventSeq,
|
|
270
|
+
turnId: event.turnId,
|
|
271
|
+
checkpointId: event.checkpointId,
|
|
272
|
+
paths: event.paths,
|
|
273
|
+
}
|
|
274
|
+
case "consequence.decided":
|
|
275
|
+
return {
|
|
276
|
+
type: event.type,
|
|
277
|
+
seq: event.eventSeq,
|
|
278
|
+
turnId: event.turnId,
|
|
279
|
+
verdict: event.verdict,
|
|
280
|
+
failureClass: event.failureClass,
|
|
281
|
+
nextAction: event.nextAction,
|
|
282
|
+
message: event.rationale,
|
|
283
|
+
severity: event.verdict === "FAIL" || event.verdict === "BLOCKED" ? "error" : "warning",
|
|
284
|
+
...(event.newEvidenceSinceLastAttempt !== undefined
|
|
285
|
+
? { newEvidenceSinceLastAttempt: event.newEvidenceSinceLastAttempt }
|
|
286
|
+
: {}),
|
|
287
|
+
}
|
|
288
|
+
case "context.window":
|
|
289
|
+
return {
|
|
290
|
+
type: event.type,
|
|
291
|
+
seq: event.eventSeq,
|
|
292
|
+
turnId: event.turnId,
|
|
293
|
+
usedTokens: event.usedTokens,
|
|
294
|
+
windowTokens: event.windowTokens,
|
|
295
|
+
...(event.percent !== undefined ? { percent: event.percent } : {}),
|
|
296
|
+
...(event.costUsd !== undefined ? { costUsd: event.costUsd } : {}),
|
|
297
|
+
...(event.providerModel ? { providerModel: event.providerModel } : {}),
|
|
298
|
+
}
|
|
299
|
+
case "context.cutoff":
|
|
300
|
+
return {
|
|
301
|
+
type: event.type,
|
|
302
|
+
seq: event.eventSeq,
|
|
303
|
+
turnId: event.turnId,
|
|
304
|
+
reason: event.reason,
|
|
305
|
+
message: event.reason,
|
|
306
|
+
severity: "warning",
|
|
307
|
+
...(event.usedTokens !== undefined ? { usedTokens: event.usedTokens } : {}),
|
|
308
|
+
...(event.windowTokens !== undefined ? { windowTokens: event.windowTokens } : {}),
|
|
309
|
+
}
|
|
310
|
+
case "task.status":
|
|
311
|
+
return {
|
|
312
|
+
type: event.type,
|
|
313
|
+
seq: event.eventSeq,
|
|
314
|
+
turnId: event.turnId,
|
|
315
|
+
taskId: event.taskId,
|
|
316
|
+
taskStatus: event.status,
|
|
317
|
+
...(event.parentId ? { parentId: event.parentId } : {}),
|
|
318
|
+
...(event.dependsOn ? { dependsOn: [...event.dependsOn] } : {}),
|
|
319
|
+
...(event.revision !== undefined ? { revision: event.revision } : {}),
|
|
320
|
+
...(event.verification ? { taskVerification: event.verification } : {}),
|
|
321
|
+
}
|
|
322
|
+
default: {
|
|
323
|
+
const exhaustive: never = event
|
|
324
|
+
void exhaustive
|
|
325
|
+
return null
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* P1.6: proyeksi UI membawa identitas session/child-run tanpa mengulang setiap
|
|
332
|
+
* case. `sessionId` DomainEvent adalah session pemilik event (anak untuk forward),
|
|
333
|
+
* `parentLink` adalah taut ke pemanggil.
|
|
334
|
+
*/
|
|
335
|
+
export function toPresentationEvent(event: DomainEvent): UiPresentationEvent | null {
|
|
336
|
+
const mapped = mapPresentationEvent(event)
|
|
337
|
+
if (!mapped) return null
|
|
338
|
+
const link = (event as { parentLink?: { childSessionId?: string; runId?: string } }).parentLink
|
|
339
|
+
return {
|
|
340
|
+
...mapped,
|
|
341
|
+
sessionId: event.sessionId,
|
|
342
|
+
...(link?.childSessionId ? { childSessionId: link.childSessionId } : {}),
|
|
343
|
+
...(link?.runId ? { runId: link.runId } : {}),
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export function parseVerifyTestEvidence(
|
|
348
|
+
command: string,
|
|
349
|
+
output: string,
|
|
350
|
+
): { passed: number; failed: number; summary: string } | undefined {
|
|
351
|
+
if (!/(?:test|vitest|jest|pytest|cargo\s+test)/i.test(command)) return undefined
|
|
352
|
+
const passedMatch = /(\d+)\s+(?:pass(?:ed)?|successful?)/i.exec(output)
|
|
353
|
+
const failedMatch = /(\d+)\s+(?:fail(?:ed|ures?)?|failing)/i.exec(output)
|
|
354
|
+
if (!passedMatch && !failedMatch) return undefined
|
|
355
|
+
return {
|
|
356
|
+
passed: passedMatch ? Number(passedMatch[1]) : 0,
|
|
357
|
+
failed: failedMatch ? Number(failedMatch[1]) : 0,
|
|
358
|
+
summary:
|
|
359
|
+
output
|
|
360
|
+
.split(/\r?\n/)
|
|
361
|
+
.find((line) => /(?:pass|fail)/i.test(line))
|
|
362
|
+
?.trim()
|
|
363
|
+
.slice(0, 500) ?? "verify completed",
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** Kompaksi LLM child session bersama (`canPersistMemory: false` mencegah polusi global). */
|
|
368
|
+
export function createChildCompaction(opts: {
|
|
369
|
+
provider: unknown
|
|
370
|
+
model?: string
|
|
371
|
+
cwd?: string
|
|
372
|
+
contextWindowTokensForModel?: (model?: string) => number
|
|
373
|
+
getContextModel?: () => string | undefined
|
|
374
|
+
}) {
|
|
375
|
+
const getWindow = opts.contextWindowTokensForModel
|
|
376
|
+
return createLlmCompaction({
|
|
377
|
+
provider: opts.provider as never,
|
|
378
|
+
getModel: () => opts.getContextModel?.() ?? opts.model,
|
|
379
|
+
cwd: opts.cwd ?? process.cwd(),
|
|
380
|
+
...(getWindow ? { getContextWindowTokens: () => getWindow(opts.model) } : {}),
|
|
381
|
+
canPersistMemory: () => false,
|
|
382
|
+
})
|
|
383
|
+
}
|
package/cli/commands/acp.ts
CHANGED
|
@@ -506,7 +506,13 @@ export async function runAcpSession(
|
|
|
506
506
|
try {
|
|
507
507
|
const persist = (ctx as { persistCurrent?: (usage: unknown) => Promise<void> })
|
|
508
508
|
.persistCurrent
|
|
509
|
-
if (typeof persist === "function")
|
|
509
|
+
if (typeof persist === "function") {
|
|
510
|
+
const turnUsage =
|
|
511
|
+
typeof ctx.usage.get === "function"
|
|
512
|
+
? ctx.usage.get(ctx.modelRef.current)
|
|
513
|
+
: ctx.usage.getSession(ctx.modelRef.current)
|
|
514
|
+
await persist(turnUsage)
|
|
515
|
+
}
|
|
510
516
|
// P2.2: respons sukses sudah terkirim di atas (tepat-sekali per run);
|
|
511
517
|
// histori yang tak durable dilaporkan via stderr diagnostik, bukan
|
|
512
518
|
// pesan protokol kedua.
|
package/cli/commands/doctor.ts
CHANGED
|
@@ -77,12 +77,16 @@ export async function buildDoctorReport(cwd?: string, allowLocal?: boolean): Pro
|
|
|
77
77
|
memoryRows: memRows,
|
|
78
78
|
sandboxOs: osSandbox,
|
|
79
79
|
sandboxDocker: docker,
|
|
80
|
-
// Tanpa isolasi OS (
|
|
80
|
+
// Tanpa isolasi OS (termasuk Windows tanpa Docker) permission default turun ke allowlist —
|
|
81
81
|
// lebih baik membatasi daripada berlabel aman palsu.
|
|
82
82
|
fallbackNote:
|
|
83
83
|
osSandbox === "none" && !docker
|
|
84
|
-
?
|
|
85
|
-
|
|
84
|
+
? process.platform === "win32"
|
|
85
|
+
? "no native Windows sandbox (Docker not detected): default permission falls back to allowlist"
|
|
86
|
+
: "no OS/docker sandbox: default permission falls back to allowlist"
|
|
87
|
+
: osSandbox === "none" && docker
|
|
88
|
+
? "Docker sandbox available (no native OS sandbox)"
|
|
89
|
+
: "sandbox available",
|
|
86
90
|
configGlobal: existsSync(globalConfigPath()),
|
|
87
91
|
configLocal: existsSync(resolve(cwd ?? ".", ".minicode", "config.json")),
|
|
88
92
|
hardening: { bashGuard, jail, scrub, perms },
|