minicode-ai 0.14.2 → 0.14.4

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.
Files changed (76) hide show
  1. package/README.md +34 -178
  2. package/cli/args.ts +10 -18
  3. package/cli/commands/acp.ts +20 -27
  4. package/cli/commands/daemon.ts +6 -7
  5. package/cli/commands/exec.ts +12 -10
  6. package/cli/commands.ts +6 -9
  7. package/cli/index.ts +30 -15
  8. package/cli/provider-manager.ts +1 -3
  9. package/cli/setup.ts +167 -143
  10. package/cli/tui.ts +15 -23
  11. package/docs/CONTROL-PLANE-MAP.md +145 -0
  12. package/docs/OUTPUT_EVENT_MODEL.md +1 -1
  13. package/docs/OUTPUT_PROTOCOL_SPEC.md +2 -2
  14. package/docs/OUTPUT_RENDERING_SPEC.md +7 -2
  15. package/docs/OUTPUT_UX_RULES.md +1 -1
  16. package/docs/README.md +14 -102
  17. package/docs/SUMMARY.md +53 -0
  18. package/docs/TERMINAL_CONTRACT.md +84 -51
  19. package/docs/UI_RENDER_PIPELINE.md +204 -0
  20. package/docs/agents.md +5 -5
  21. package/docs/architecture.md +23 -12
  22. package/docs/choosing-mode.md +7 -7
  23. package/docs/cli.md +22 -29
  24. package/docs/concepts.md +1 -1
  25. package/docs/config.md +10 -5
  26. package/docs/contributing.md +6 -6
  27. package/docs/environment.md +3 -1
  28. package/docs/exec.md +5 -5
  29. package/docs/glossary.md +8 -6
  30. package/docs/memory-sessions.md +7 -5
  31. package/docs/policy-sandbox.md +16 -14
  32. package/docs/quickstart.md +2 -2
  33. package/docs/repl.md +4 -3
  34. package/docs/security-model.md +14 -15
  35. package/docs/security.md +8 -29
  36. package/docs/skills.md +1 -1
  37. package/docs/tools.md +2 -2
  38. package/package.json +5 -3
  39. package/scripts/vendor-overlays/minicode-context.patch +109 -0
  40. package/src/app/provider-layer.ts +13 -1
  41. package/src/app/session.ts +216 -13
  42. package/src/config.ts +30 -3
  43. package/src/constants.ts +2 -0
  44. package/src/daemon/control.ts +1 -1
  45. package/src/mcp/server.ts +2 -3
  46. package/src/policy/compaction.ts +272 -16
  47. package/src/policy/context-window.ts +73 -0
  48. package/src/policy/context.ts +55 -3
  49. package/src/policy/ratelimit.ts +47 -18
  50. package/src/policy/usage.ts +15 -8
  51. package/src/policy/work-mode.ts +1 -1
  52. package/src/providers/guards.ts +61 -4
  53. package/src/providers/provision.ts +12 -3
  54. package/src/providers/router.ts +56 -23
  55. package/src/session/context-projection.ts +14 -0
  56. package/src/session/context-selector.ts +58 -20
  57. package/src/session/persistence.ts +1 -1
  58. package/src/task/model.ts +21 -70
  59. package/src/tools/task.ts +7 -0
  60. package/src/ui/footer.ts +131 -66
  61. package/src/ui/i18n/en.ts +0 -11
  62. package/src/ui/i18n/id.ts +0 -11
  63. package/src/ui/input/input.ts +2 -3
  64. package/src/ui/input/prompt-engine.ts +2 -5
  65. package/src/ui/screens/model-manager.ts +3 -10
  66. package/src/ui/screens/picker.ts +23 -40
  67. package/src/ui/screens/provider-manager.ts +12 -33
  68. package/src/ui/screens/wizard.ts +0 -1
  69. package/src/ui/tui/app.ts +10 -6
  70. package/src/ui/tui/transcript.ts +48 -8
  71. package/vendor/minicore/VENDOR.md +9 -5
  72. package/vendor/minicore/src/core/loop.ts +47 -12
  73. package/vendor/minicore/src/core/provider.ts +4 -0
  74. package/vendor/minicore/src/core/session.ts +14 -1
  75. package/docs/OUTPUT_ARCHITECTURE_AUDIT.md +0 -489
  76. package/docs/OUTPUT_IMPLEMENTATION_PLAN.md +0 -391
@@ -1,489 +0,0 @@
1
- # Output Architecture Audit
2
-
3
- **Status:** audit selesai; Phase 1–8 remediation landed, with one ACP compatibility window. Tables and evidence marked historical describe the pre-remediation baseline.
4
- **Tanggal:** 2026-09-25
5
- **Produk:** MiniCode coding agent CLI
6
- **Rujukan kontrak:** `docs/TERMINAL_CONTRACT.md`, `docs/UI_RENDER_PIPELINE.md`
7
-
8
- ## Scope
9
-
10
- Audit ini mencakup output yang dihasilkan atau diturunkan oleh runtime MiniCode:
11
-
12
- - TUI fullscreen: transkrip, composer, status bar, popup, selection, clipboard.
13
- - Output linear/one-shot: model text, reasoning, tool ledger, error, receipt.
14
- - `exec --json`: JSON Lines dan summary envelope.
15
- - `acp`: JSON-RPC stdio minimal untuk IDE.
16
- - Diagnostic, approval, spinner/status transient, setup/recovery/verify.
17
- - Batas vendor: `vendor/minicore/**` dibaca sebagai evidence, tidak diubah.
18
-
19
- Rancangan `AGENT_PRESENTATION_ARCHITECTURE_V2_1.md` diperlakukan sebagai target
20
- arsitektur, bukan bukti bahwa semua fase sudah selesai. Audit ini menilai wiring
21
- aktual terhadap rancangan tersebut.
22
-
23
- ## Phase 1–8 implementation update
24
-
25
- Audit ini capturing baseline sebelum remediation. Current implementation status
26
- setelah Phase 1–8:
27
-
28
- - Phase 1: `user.message`, mapper exhaustive, `PROPOSED_EVENT_TYPES`, dan
29
- `unsupportedProjection` diagnostics landed.
30
- - Phase 2: semantic collections, derived summaries, bounded retention, durable
31
- SQLite event log, resume rebuild, checkpoint evidence, child-session
32
- persistence, producer `finding.detected`, contract restart/branch/child/delete/
33
- TTL/resume, dan `eventSeq` unik landed.
34
- - Phase 3–7: policy proyeksi murni, envelope machine, migrasi TUI/linear/machine,
35
- persist headless, dan writer inventory landed.
36
- - Phase 8: rollback flag dan raw ledger TUI dihapus. Runtime EventBus tetap
37
- dipakai untuk streaming konten dan debug/trace, bukan sebagai sumber status
38
- user-facing kedua.
39
- - OAP-001–OAP-010 dan OAP-012–OAP-013 closed atau documenting the compatibility
40
- boundary; OAP-011 tetap proposed/compatibility-only. Residual window: ACP
41
- legacy `type:"tool"` when canonical lifecycle is unavailable.
42
-
43
- ## Executive verdict
44
-
45
- Audit baseline menunjukkan MiniCode memiliki fondasi terminal yang kuat:
46
- sanitasi trust boundary, perhitungan lebar kolom, ownership alternate-screen,
47
- coalesce repaint, source-mapped selection, OSC52, dan test proteksi yang luas.
48
- Setelah remediation Phase 1–8, status, activity, visibility, correlation, dan
49
- machine lifecycle mengambil keputusan dari canonical presentation policy yang
50
- di-inject pada composition root.
51
-
52
- ```text
53
- Agent Runtime
54
- ↓ MiniCore EventBus
55
- ↓ streaming content transport
56
- ├─ TUI transcript content + canonical policy ledger
57
- ├─ Linear content + canonical policy writer
58
- ├─ exec canonical lifecycle + text delta
59
- └─ ACP canonical lifecycle + text delta
60
-
61
- PresentationAdapter
62
- ↓
63
- DomainEvent → PresentationState (durable/replayable)
64
- ↓ UiPresentationEvent + PresentationPolicy
65
- TUI / linear / exec / ACP
66
- ```
67
-
68
- Tidak ditemukan P0. Residual risk terbatas pada live streaming dan kompatibilitas
69
- ACP legacy `type:"tool"`; keduanya tidak menentukan status user-facing canonical.
70
- The historical findings below remain as evidence for the pre-remediation state;
71
- the current implementation is recorded in the Phase 1–8 update above.
72
-
73
- ## Arsitektur aktual
74
-
75
- ```text
76
- Provider/router
77
- │ provider:text / provider:extension / usage
78
- ▼
79
- MiniCore loop (vendor/minicore, frozen)
80
- │ turn:started, step:*, execution:*, provider:*, context:*
81
- ▼
82
- session.events (raw EventBus; raw content streaming tetap, semantic legacy
83
- user-facing dihapus di Phase 8)
84
- ├── attachSimpleLogger() ── stdout/stderr linear (keputusan status dari policy)
85
- │ └── turn-status.ts ── transient stderr (label via activityFor DI)
86
- ├── Transcript() ── append-only visual state TUI (ledger/summary dari policy)
87
- │ └── TuiApp + screen.ts ── alternate screen
88
- ├── exec.ts ── envelope minicode.output.v1 → JSONL (+ text delta terpisah)
89
- ├── acp.ts ── lifecycle presentasi penuh + text delta tersanitasi
90
- ├── journal/checkpoint/trace
91
- ├── presentation_events (SQLite durable log)
92
- └── PresentationAdapter (cli/setup.ts)
93
- ├── turn/tool/model/reasoning/context/checkpoint events
94
- ├── approval hooks + noteRunSettled + file.changed
95
- └── replayable bounded PresentationState
96
- ├── toPresentationEvent() compatibility bridge
97
- └── projection.ts policy (di-inject ke renderer sebagai PresentationPolicy)
98
- ```
99
-
100
- ### Batas aktual yang sudah baik
101
-
102
- - `src/ui/` tidak mengimpor `cli/`, `src/` non-UI, atau kernel; dijaga
103
- `test/ui-boundary.test.ts`.
104
- - `TuiApp` adalah pemilik tunggal frame TUI; `screen.ts` memiliki pairing
105
- alternate-screen dan `paintRegion()`.
106
- - `statusline.ts` meng arbitrasi transient painter dan menahan painter ketika
107
- interactive screen aktif.
108
- - Sanitasi dan geometri memakai modul bersama; teks yang tidak dipercaya tidak
109
- boleh keluar sebagai control sequence mentah.
110
- - Event bus mengisolasi handler yang melempar sehingga observer/UI tidak
111
- menggagalkan turn (`vendor/minicore/src/core/events.ts:35-71`).
112
- - TUI, linear, ACP, dan exec sudah memiliki test output serta boundary fail-closed
113
- untuk machine mode.
114
-
115
- ## Historical Pipeline (pre-remediation evidence)
116
-
117
- | Stage | Current implementation | Problem | Risk |
118
- |---|---|---|---|
119
- | Provider stream | `src/providers/router.ts`, `vendor/minicore/src/core/loop.ts:108-135` | Raw provider event tidak memiliki schema output bersama | Tiap consumer menafsirkan event sendiri |
120
- | Kernel lifecycle | `vendor/minicore/src/core/events.ts:5-14`, `session.ts:234-249` | `turn:completed` hanya sukses; abort/timeout/failure tidak menjadi terminal event | Consumer harus merekonstruksi makna dari driver |
121
- | Tool execution | `vendor/minicore/src/core/executor.ts:40-104` | Permission deny, unknown tool, dan invalid args dapat kembali tanpa `execution:*` | Denial/validation perlu dibaca dari `step.completed` |
122
- | Semantic adapter | `src/presentation/adapter.ts:158-721` | Semua lifecycle harus direkonstruksi; beberapa event dideklarasikan tanpa producer | Risiko event hilang/duplikat/anomali |
123
- | State/reducer | `src/presentation/{model,reducer}.ts`, wiring `cli/setup.ts:642-655` | Reducer hanya shadow; `PresentationState` belum lengkap untuk semua event | TUI/linear/ACP dapat berbeda |
124
- | UI bridge | `cli/setup.ts:449-532`, `src/ui/contract.ts:144-174` | Hanya turn/tool/approval yang diproyeksikan; model/reasoning/file/test/context di-drop | Consumer tidak dapat memakai satu event stream |
125
- | TUI | `src/ui/tui/{transcript,app}.ts`, `runtime/screen.ts` | Truth visual berasal dari raw bus + buffer sendiri, bukan snapshot tunggal | Status/ledger dapat berbeda dari linear |
126
- | Linear/one-shot | `src/ui/assistant/simple.ts`, `turn-status.ts` | Menggabungkan state, sanitasi, collapse, policy, dan writes | Perubahan semantics berisiko duplication |
127
- | Exec machine | `cli/commands/exec.ts:126-199` | Streaming raw `session.events("*")`; summary memiliki schema sendiri | Client harus memahami dua protocol |
128
- | ACP machine | `cli/commands/acp.ts:278-349` | Menggabungkan raw text/tool stream dengan partial presentation lifecycle | IDE bisa melihat event lifecycle tidak lengkap |
129
- | Diagnostic/policy | `cli/setup.ts`, `cli/index.ts`, `statusline.ts`, approval/popup | Banyak direct write; arbitration melindungi transient, bukan semantik | Jalur baru mudah melanggar stream contract |
130
- | Durable state | `session/journal`, `persistence`, checkpoint, `turn-marker` | Data durable tidak ditulis sebagai `DomainEvent` yang dapat direplay ke model | `rebuildFromDurable()` belum wired di production |
131
-
132
- ## Event Inventory
133
-
134
- | Event | Source | Current presentation | Desired semantic type |
135
- |---|---|---|---|
136
- | `turn:started` | MiniCore loop | TUI/linear/ACP turn marker; `turn.started` shadow | `task.started` dengan `sessionId`, `turnId`, visibility normal |
137
- | `turn:completed` | MiniCore success | Flush transcript/answer, status, `turn.completed` shadow | `task.completed` + derived summary |
138
- | `turn.failed` | `noteRunSettled()` | Error friendly dari driver; tidak selalu event live | `task.failed` dengan cause/severity/action |
139
- | `turn.cancelled` | `noteRunSettled()` | Stopped/budget/timeout messages; TUI/linear/ACP bergantung driver | `task.cancelled` dengan reason user/timeout/budget |
140
- | `model.delta` | `provider:text` | Stream text sanitized ke TUI/linear/ACP | `assistant.message.delta`, live-only |
141
- | `model.completed` | `TurnResult.finalText` saat turn selesai | Commit transcript/answer; bridge tidak mengirim ke UI | `assistant.message.completed`, durable final |
142
- | `reasoning.delta` | `provider:extension(kind=reasoning)` | Dots/stream/buffer sesuai surface | `assistant.reasoning.delta`, live-only |
143
- | `reasoning.completed` | Tidak ada producer runtime saat ini | Hanya tipe dan durability; tidak tampil konsisten | `assistant.reasoning.completed`, hasil final/ref |
144
- | `tool.started` | `execution:started` | Ledger/progress/status running | `tool.started` dengan identity/correlation |
145
- | `tool.progress` | Tidak ada producer runtime saat ini | Hanya field `progress` bila event eksternal | `tool.progress`, live-only, optional |
146
- | `tool.completed` | `execution:completed` success | Receipt/ledger/collapse | `tool.completed` dengan duration/evidence |
147
- | `tool.failed` | execution result atau `step.results` | Error ringkas; klasifikasi dapat berbeda | `tool.failed` dengan cause/hint/partial state |
148
- | `tool.denied` | Reconstructed dari permission result | Warning/deny; adapter diklasifikasi khusus | `tool.denied` dengan deny reason/outcome |
149
- | `tool.cancelled` | Cascade saat abort/parent settle | Dibatasi/ditampilkan sebagai cancelled | `tool.cancelled` dengan cancellation reason |
150
- | `approval.requested` | Permission/ask hook | Blok TUI/linear/headless deny | `approval.requested` |
151
- | `approval.settled` | Permission/ask hook | Keputusan tercatat; bridge partial | `approval.settled` dengan allow/deny/cancelled |
152
- | `file.changed` | `attachMutationJournal` → adapter | Receipt pada activity; bridge meng-drop event | `file.changed` sebagai evidence/receipt |
153
- | `test.completed` | Tidak ada producer saat ini | Hanya tipe dan receipt join | `test.completed` sebagai evidence |
154
- | `context.compacted` | MiniCore loop | Warning/entry system; bridge meng-drop | `context.compacted` sebagai system event |
155
- | Diagnostic | CLI/provider/policy direct write | `[warn]`, `[recovery]`, `[verify]`, spinner | `diagnostic.raised` atau `recovery.*` dengan policy stream |
156
-
157
- ## Output Inventory
158
-
159
- | Output | Category | Current mode | Recommended mode |
160
- |---|---|---|---|
161
- | TUI transcript | Human, interactive | Fullscreen frame; raw-bus-fed view | Same layout, sourced from canonical projection |
162
- | TUI status/footer | Human, interactive | Clock/ANSI state in `TuiApp` | Semantic snapshot; renderer owns only layout |
163
- | Linear model text | Human, append-only | Sanitized stream, collapse, markdown table | Normal/verbose projection from same state |
164
- | Linear tool receipt | Human + operational evidence | Direct writer with status suffix | Derived activity node; evidence remains ref-backed |
165
- | Reasoning | Human, optional | TUI/linear independently buffer/minimize | Same state, visibility policy per projection |
166
- | Transient status/spinner | Human, ephemeral | `turn-status`/`statusline` direct writes | Derived projection of active task; output sink route |
167
- | `exec --json` | Machine | Raw EventBus JSONL + summary | Versioned canonical JSONL + terminal summary |
168
- | ACP | Machine/IDE | Text deltas + raw tool fallback + partial lifecycle | Canonical lifecycle notifications + text delta |
169
- | Approval | Human or machine policy | TUI sink, inline askLine, headless deny | Approval event + surface-specific prompt/decision |
170
- | Diagnostics | Human diagnostic | Direct stderr with varied prefixes | Typed diagnostic policy, never mixed with machine stdout |
171
- | Clipboard | Human interaction | `/copy` + app selection OSC52 | Same; source-mapped and sanitized |
172
- | Debug bus | Debug | Opt-in `bus-debug` raw event summaries | Debug projection from canonical events, redacted payload |
173
-
174
- ## Historical Findings (before remediation)
175
-
176
- The original finding list below is preserved as audit evidence. Current disposition:
177
-
178
- | Finding | Current disposition |
179
- |---|---|
180
- | OAP-001 | Closed for user-facing decisions; raw EventBus remains only for streaming content/debug. |
181
- | OAP-002 | Closed at adapter/reducer seam; vendor runtime remains unchanged. |
182
- | OAP-003 | Closed by exhaustive `toPresentationEvent()` bridge. |
183
- | OAP-004/OAP-005 | Closed by semantic collections and evidence-derived summaries. |
184
- | OAP-006 | Closed by versioned machine envelopes. |
185
- | OAP-007 | Closed by production durable rebuild. |
186
- | OAP-008/OAP-013 | Closed by writer inventory, boundary checks, and documentation updates. |
187
- | OAP-009/OAP-010/OAP-012 | Closed by canonical policy and semantic nodes. |
188
- | OAP-011 | Proposed events remain explicit; no fabricated producer. |
189
-
190
-
191
- ### Original finding register (historical)
192
-
193
- | ID | Severity | Location | Problem | Recommendation |
194
- |---|---|---|---|---|
195
- | OAP-001 | P1 | `cli/setup.ts:642-655`, `transcript.ts:161-185`, `simple.ts:417-...`, `exec.ts:126-139` | Raw bus dan shadow presentation state adalah dua sumber kebenaran | Jadikan canonical projection satu-satunya feed renderer setelah parity gate |
196
- | OAP-002 | P1 | `vendor/minicore/src/core/events.ts:5-14`, `executor.ts:40-74`, `session.ts:234-249` | Failure/abort/deny tidak selalu memiliki terminal event runtime | Pertahankan adapter rekonstruksi sebagai seam, tambahkan canonical settle event |
197
- | OAP-003 | P1 | `cli/setup.ts:449-532`, `src/ui/contract.ts:144-174` | Bridge membuang model/reasoning/file/test/context events | Definisikan bridge total dengan default fail-safe dan diagnostic counter |
198
- | OAP-004 | P1 | `src/presentation/model.ts:74-130`, `reducer.ts:391-400` | State tidak menyimpan reasoning/system/user/plan/finding secara lengkap | Tambahkan entry collections dan user/task semantic events |
199
- | OAP-005 | P1 | `src/presentation/adapter.ts:294-302` | `turnSummary.filesChanged` selalu `0`; receipt tidak masuk summary | Hitung summary dari reducer/journal-derived state, bukan konstanta adapter |
200
- | OAP-006 | P1 | `cli/commands/exec.ts:126-199`, `acp.ts:278-349` | Machine output bukan canonical protocol yang sama | Tambahkan schema/version/envelope dan mapper eksplisit |
201
- | OAP-007 | P1 | `reducer.ts:441-483`, `cli/setup.ts:1029-1038` | Rebuild durable adalah helper test, belum menjadi jalur production | Simpan semantic durable log atau replay adapter dari session/journal saat resume |
202
- | OAP-008 | P2 | `cli/index.ts`, `cli/setup.ts`, `cli/commands.ts`, `src/ui/approval/prompt.ts`, `src/ui/runtime/*` | Direct writes tersebar; policy stream tidak terpusat | Inventory writer dan routekan diagnostic/permanent output lewat sink |
203
- | OAP-009 | P2 | `simple.ts:434-546`, `transcript.ts:183-186`, `acp.ts:260-268` | Visibility/verbose/normal state dihitung terpisah per surface | Buat policy projection bersama; renderer hanya berbeda pada layout |
204
- | OAP-010 | P2 | `adapter.ts:125-135`, `simple.ts:597-615`, `transcript.ts:601-633` | Klasifikasi deny/fail tetap string/`isError` di beberapa jalur | Reduced satu canonical outcome, diagnostics fallback hanya di adapter |
205
- | OAP-011 | P2 | `events.ts:164-263`, `adapter.ts:549-567` | Vocabulary punya event tanpa producer/consumer konsisten | Tandai proposed/unsupported eksplisit atau tambahkan producer/adapter |
206
- | OAP-012 | P2 | `cli/tui.ts:675-689`, `src/ui/tui/transcript.ts:131-186` | User message, plan, dan finding tidak punya semantic event terpisah | Tambahkan `user.message`, plan nodes, evidence/finding nodes |
207
- | OAP-013 | P2 | `docs/UI_RENDER_PIPELINE.md:112-116`, `PLAN.md:158-300` | Dokumentasi masih menyatakan tidak ada event yang diabaikan dan plan lama belum direkonsiliasi | Sinkronkan docs, plan, dan test coverage map sebelum remediation |
208
-
209
- ### Detail temuan
210
-
211
- #### OAP-001 — P1 — Dua sumber kebenaran
212
-
213
- **Evidence:** `cli/setup.ts:369-380` menyebut adapter dan shadow reducer;
214
- `cli/setup.ts:642-655` menjalankan reducer dalam mode shadow. `Transcript` masih
215
- subscribe langsung ke raw bus pada `src/ui/tui/transcript.ts:161-185`;
216
- `attachSimpleLogger` masih memproses raw `provider:text`, `execution:*`, dan extension
217
- pada `src/ui/assistant/simple.ts:417-763`; `exec` dan `ACP` juga menerima raw `*` pada
218
- `cli/commands/exec.ts:131-139` dan `cli/commands/acp.ts:290-303`.
219
-
220
- **Problem:** Presentation state direduksi sebagai pengamat, bukan authoritative
221
- model. TUI/linear dapat memiliki buffer, status, dan urutan yang berbeda dari state.
222
-
223
- **Impact:** Perubahan semantic event belum dapat di-push ke semua consumer
224
- sekaligus; parity test hanya dapat membandingkan output, tidak menjamin state yang
225
- sama.
226
-
227
- **Recommendation:** Tetapkan fase migrasi berflag: pertahankan raw bus hanya untuk
228
- runtime/debug, kirim semua user-facing surface melalui projection dari
229
- `PresentationState`, lalu hapus shadow setelah golden parity.
230
-
231
- **Update Phase 3–7:** keputusan ledger/summary/elapsed/label kini dari
232
- `src/presentation/projection.ts` via injeksi `PresentationPolicy`
233
- (`cli/tui.ts`, `cli/setup.ts`); parity test policy-vs-legacy hijau di
234
- `test/presentation-projections.test.ts` dan `test/presentation-linear-acp.test.ts`.
235
- Jalur raw ledger TUI dan rollback flag dihapus di Phase 8;
236
- penghapusan menunggu satu rilis hijau (Phase 8).
237
-
238
- #### OAP-002 — P1 — Lifecycle runtime tidak lengkap
239
-
240
- **Evidence:** vendor event union hanya sembilan tipe
241
- (`vendor/minicore/src/core/events.ts:5-14`); executor mengembalikan deny/unknown/validation
242
- sebelum `execution:started` (`vendor/minicore/src/core/executor.ts:40-74`); session hanya
243
- menerbitkan `turn:completed` setelah `executeTurn` sukses
244
- (`vendor/minicore/src/core/session.ts:234-249`).
245
-
246
- **Problem:** Deny, invalid, abort, timeout, dan failure tidak selalu memiliki
247
- terminal event yang sama. Adapter harus membaca `step.completed`, permission hook,
248
- dan `noteRunSettled()` untuk menutup gap.
249
-
250
- **Impact:** Failure bisa hilang pada surface yang tidak memasang driver settle;
251
- urutan terminal bisa berbeda antara TUI, linear, dan ACP.
252
-
253
- **Recommendation:** Jadikan canonical event vocabulary tetap memuat task/tool
254
- terminal states. Tambahkan seam adapter-only terlebih dahulu; kernel tidak perlu
255
- diubah. Pastikan setiap user-visible execution memiliki tepat satu status final.
256
-
257
- #### OAP-003 — P1 — Bridge partial
258
-
259
- **Evidence:** `toPresentationEvent()` hanya menangani turn/tool/approval pada
260
- `cli/setup.ts:449-532` dan mengembalikan `null` untuk model, reasoning, file,
261
- test, context, dan diagnostic. `UiPresentationEvent` di
262
- `src/ui/contract.ts:144-174` juga tidak mendeklarasikan event delta.
263
-
264
- **Problem:** State shadow dapat memproses event yang tidak pernah sampai ke
265
- consumer presentasi. TUI dan linear masih mengambil event tersebut dari raw bus.
266
-
267
- **Impact:** `verbose`, `debug`, ACP lifecycle, resume, dan golden fixture tidak
268
- menguji event yang sama.
269
-
270
- **Recommendation:** Buat mapper exhaustive dengan exhaustive check dan counter
271
- `unsupportedProjection`; mapper tidak boleh diam-diam membuang event yang
272
- dinilai user-relevant.
273
-
274
- #### OAP-004 — P1 — Model presentation belum lengkap
275
-
276
- **Evidence:** `ReasoningEntry` dan `SystemEntry` dideklarasikan pada
277
- `src/presentation/model.ts:74-97`, tetapi `PresentationState` hanya menyimpan
278
- `conversation`, `turns`, `activities`, `approvals`, dan `order`
279
- (`src/presentation/model.ts:119-130`). Reducer hanya menambahkan order ref untuk
280
- reasoning/context (`src/presentation/reducer.ts:391-400`). Tidak ada user event;
281
- user prompt masuk melalui `Transcript.pushUser()` di `cli/tui.ts:675-689`.
282
-
283
- **Problem:** Model tidak dapat menjadi transcript semantic lengkap maupun
284
- merepresentasikan plans/findings secara terpisah dari activity.
285
-
286
- **Impact:** TUI, `/copy`, resume, dan machine projection harus tetap memiliki
287
- buffer/parser tambahan.
288
-
289
- **Recommendation:** Tambahkan `user.message`, `reasoning`, `system`, `plan`,
290
- `finding`, dan `result` entries dengan lifecycle serta visibility. Reducer tetap
291
- murni dan tidak menyimpan payload besar.
292
-
293
- #### OAP-005 — P1 — Summary/receipt tidak truthful
294
-
295
- **Evidence:** `turnSummary()` di `src/presentation/adapter.ts:294-302` selalu
296
- mengisi `filesChanged: 0`; `file.changed` dipanggil dari
297
- `cli/setup.ts:662-673`, tetapi `turn.completed` tidak membawa hasil agregasi
298
- checkpoint. TUI memakai summary yang diterima melalui bridge pada
299
- `src/ui/tui/transcript.ts:635-667`.
300
-
301
- **Problem:** Evidence file yang sudah dijournal/checkpoint tidak masuk turn summary
302
- yang dipakai TUI/ACP.
303
-
304
- **Impact:** User dan IDE dapat melihat jumlah file berubah yang salah, sedangkan
305
- receipt per activity mungkin benar.
306
-
307
- **Recommendation:** Reducer menghitung summary setelah event file/test masuk;
308
- adapter hanya memberikan metadata clock, bukan angka domain.
309
-
310
- #### OAP-006 — P1 — Machine output tidak memakai satu protocol
311
-
312
- **Evidence:** `exec --json` streaming raw `session.events("*")` pada
313
- `cli/commands/exec.ts:126-139`; ACP juga subscribe raw pada
314
- `cli/commands/acp.ts:290-303`, lalu menggabungkan text delta dan partial lifecycle.
315
-
316
- **Problem:** `exec` tidak mempunyai canonical schema/version yang sama;
317
- ACP bergantung pada keberadaan `onPresentationEvent` dan fallback legacy tool event.
318
-
319
- **Impact:** Client harus menangani event raw, semantic event, dan summary dengan
320
- bentuk berbeda. Perubahan internal dapat mengubah machine contract tanpa gate.
321
-
322
- **Recommendation:** Buat mapper `machineProjection()` dari `DomainEvent`/snapshot;
323
- exec dan ACP memakai envelope yang sama, dengan ACP JSON-RPC sebagai transport
324
- wrapper. Tetap lakukan scrub dan test wire contract.
325
-
326
- **Update Phase 6:** `toMachineEnvelope()` di `src/presentation/projection.ts`
327
- menghasilkan `minicode.output.v1`; `exec --json` streaming envelope + summary
328
- berversi + setup-failure selalu ber-envelope; ACP memetakan lifecycle penuh
329
- (file/test/diagnostic/checkpoint/plan/finding/result/context) dengan framing
330
- JSON-RPC yang sama. Legacy `type:"tool"` hanya bila lifecycle absen.
331
-
332
- #### OAP-007 — P1 — Durable rebuild belum dipakai
333
-
334
- **Evidence:** `rebuildFromDurable()` diimplementasikan pada
335
- `src/presentation/reducer.ts:441-483` dan diuji pada
336
- `test/presentation-reducer.test.ts:289-323`, tetapi tidak ditemukan call production;
337
- `cli/setup.ts:1029-1038` hanya persist session messages/usage.
338
-
339
- **Problem:** Setelah restart, presentation model tidak direkonstruksi dari semantic
340
- lifecycle; yang ada adalah message/session persistence dan recovery text.
341
-
342
- **Impact:** Status interrupted, approval close, summary, dan correlation historical
343
- tidak dapat diverifikasi oleh renderer yang baru.
344
-
345
- **Recommendation:** Pilih durable event log minimal (journal/session store),
346
- serialize canonical events, dan rebuild saat `createCliSession`/resume. Delta tidak
347
- perlu disimpan; final state harus.
348
-
349
- #### OAP-008 — P2 — Direct-print policy tersebar
350
-
351
- **Evidence:** Writes permanent/transient ada di `cli/index.ts:90-505`,
352
- `cli/setup.ts:208-1036`, `cli/commands.ts:196-433`, approval
353
- `src/ui/approval/prompt.ts:24-149`, `turn-status.ts`, `statusline.ts`, serta
354
- popup/form/input modules.
355
-
356
- **Problem:** `statusline.ts` melindungi transient owner dan interactive screen,
357
- tetapi tidak menjadi semantic router untuk semua output.
358
-
359
- **Impact:** Jalur setup/verify/manager baru dapat menulis ke stream yang salah atau
360
- mencemari alt-screen/machine stream.
361
-
362
- **Recommendation:** Buat writer registry/sink (`humanPermanent`, `humanDiagnostic`,
363
- `machine`, `tui`) di composition root. Legacy direct writes boleh selama
364
- diinventory dan diberi guard, tetapi tidak boleh menjadi jalur default baru.
365
-
366
- #### OAP-009 — P2 — Visibility policy tidak seragam
367
-
368
- **Evidence:** `simple.ts` menentukan `verbose`/answer visibility secara lokal;
369
- `Transcript` hanya memiliki mode reasoning/minimize; `ACP` selalu meminta
370
- `verbose: false` pada `cli/commands/acp.ts:260-268`; TUI dan linear tidak memakai
371
- satu policy snapshot.
372
-
373
- **Problem:** “normal”, “verbose”, “debug”, dan “machine” bukan satu konsep yang
374
- dihasilkan dari model yang sama.
375
-
376
- **Impact:** Tool status/receipt dapat muncul berbeda, dan debug dapat memilih
377
- field yang tidak tersedia pada machine stream.
378
-
379
- **Recommendation:** Definisikan `PresentationPolicy`/`ProjectionMode` bersama;
380
- mode hanya memilih node/verbosity, bukan mengubah status runtime.
381
-
382
- #### OAP-010 — P2 — Klasifikasi outcome masih stringly typed di beberapa jalur
383
-
384
- **Evidence:** `adapter.ts:125-135` memakai `classifyToolResult`, `denyReasonOf`, dan
385
- regex `mapToolFailCause`; `simple.ts:597-615` dan `transcript.ts:601-633` memakai
386
- `result.isError`/text untuk status terminal.
387
-
388
- **Problem:** Satu result dapat menjadi denied di adapter tetapi failed di raw sink
389
- jika bentuk/urutan event berbeda.
390
-
391
- **Impact:** Mode yang berbeda dapat menampilkan kategori error berbeda.
392
-
393
- **Recommendation:** Canonical outcome hanya boleh lahir di adapter/kernel seam;
394
- fallback string hanya diagnostics dan harus menghasilkan anomaly counter.
395
-
396
- #### OAP-011 — P2 — Vocabulary memiliki event tanpa producer
397
-
398
- **Evidence:** Phase 2 kini memiliki producer untuk `reasoning.completed`,
399
- `plan.updated`, `finding.detected` dari `submit_result` terstruktur,
400
- `result.produced`, `diagnostic.raised`, `test.completed` dari verify terstruktur,
401
- dan `checkpoint.created`; hanya `tool.progress` yang masih ditandai proposed
402
- karena live-only.
403
-
404
- **Problem:** Tipe dan durability map menjanjikan event yang belum menjadi kontrak
405
- produksi.
406
-
407
- **Impact:** Test dapat lulus untuk event buatan sementara jalur nyata tidak pernah
408
- menghasilkan event tersebut.
409
-
410
- **Recommendation:** Tandai event sebagai `proposed`, `derived`, atau `runtime`; jangan
411
- jadi aggregate bersama dengan lifecycle inti.
412
-
413
- #### OAP-012 — P2 — User, plan, dan finding belum semantic
414
-
415
- **Evidence:** Phase 2 kini memiliki `user.message`, plan object dari
416
- `todo_write`, tipe `Finding` di model, dan producer `finding.detected` dari
417
- `result.findings` eksplisit pada `submit_result`.
418
-
419
- **Problem:** Activity, future work, dan evidence finding tidak dapat dipisahkan
420
- sesuai prinsip output architecture.
421
-
422
- **Impact:** Plan dapat disalahartikan sebagai replay aktivitas; normal mode tidak
423
- tahu node mana yang actionable.
424
-
425
- **Recommendation:** Tambahkan semantic nodes terpisah: `user.message`,
426
- `plan.created/updated`, `finding.detected`, `result.produced`; tool tetap activity.
427
-
428
- #### OAP-013 — P2 — Dokumentasi dan proteksi belum sinkron dengan aktual
429
-
430
- **Evidence:** `docs/UI_RENDER_PIPELINE.md:112-116` menyatakan tidak ada event runtime
431
- yang diabaikan UI, tetapi `cli/setup.ts:530-532` meng-drop event yang tidak
432
- memiliki projection; `PLAN.md:158-300` masih menandai mouse selection belum
433
- implementasikan.
434
-
435
- **Problem:** Plan/document tidak lagi menjadi sumber status yang dapat dipercaya.
436
-
437
- **Impact:** Agent berikutnya dapat mengulangi pekerjaan atau tidak menjalankan
438
- remediation yang sebenarnya sudah ada.
439
-
440
- **Recommendation:** Update plan/artifact links dan tambahkan test contract yang
441
- memeriksa event coverage, bukan hanya output string.
442
-
443
- ## Rekomendasi arsitektur
444
-
445
- Target yang direkomendasikan:
446
-
447
- ```text
448
- Agent Runtime
449
- ↓
450
- Semantic Event Boundary
451
- ├─ durable semantic events
452
- └─ live deltas/progress
453
- ↓
454
- Pure Reducer → PresentationState + ContentRef
455
- ↓
456
- Policy Projection (normal | verbose | debug | machine)
457
- ├─ TUI renderer
458
- ├─ Linear renderer
459
- ├─ exec JSONL projection
460
- ├─ ACP projection
461
- └─ future web/API
462
- ```
463
-
464
- Prinsip yang dipertahankan:
465
-
466
- - `vendor/minicore/**` tetap frozen; seam adapter cukup untuk fase awal.
467
- - `PresentationState` menyimpan status/correlation/receipt refs, bukan terminal state
468
- atau payload besar.
469
- - Renderer hanya memilih layout dan interaksi; tidak menginfer status dari teks.
470
- - Sanitasi/depth/wrapping/ownership terminal tetap menjadi gerbang terakhir.
471
- - Migrasi staged dan dapat dibalik dengan flag; tidak melakukan flag-day rewrite.
472
-
473
- ## Validation gate untuk audit ini
474
-
475
- - [x] Pipeline runtime → raw bus → adapter → reducer → consumer ditelusuri.
476
- - [x] TUI, linear, exec, ACP, approval, diagnostics, clipboard diinventaris.
477
- - [x] Event vocabulary dan output mode dibandingkan dengan producer aktual.
478
- - [x] Temuan memiliki severity, evidence, problem, impact, recommendation.
479
- - [ ] Canonical projection dan remediation belum diimplementasikan pada artefak ini.
480
- - [ ] Resume/replay production, parity test, dan golden machine fixtures masih
481
- menjadi pekerjaan fase berikutnya.
482
-
483
- ## Deliverable berikutnya
484
-
485
- - Model event: `docs/OUTPUT_EVENT_MODEL.md`
486
- - Protocol/mode/stream: `docs/OUTPUT_PROTOCOL_SPEC.md`
487
- - Renderer boundary: `docs/OUTPUT_RENDERING_SPEC.md`
488
- - UX grammar: `docs/OUTPUT_UX_RULES.md`
489
- - Migration plan: `docs/OUTPUT_IMPLEMENTATION_PLAN.md`