minicode-ai 0.14.6 → 0.20.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.
Files changed (142) hide show
  1. package/README.md +6 -4
  2. package/cli/args.ts +20 -8
  3. package/cli/commands/exec.ts +17 -14
  4. package/cli/commands/openwork.ts +1 -1
  5. package/cli/commands.ts +39 -23
  6. package/cli/index.ts +29 -7
  7. package/cli/model-manager.ts +1 -1
  8. package/cli/router.ts +22 -9
  9. package/cli/setup.ts +77 -35
  10. package/cli/tui.ts +179 -25
  11. package/docs/CONTROL-PLANE-MAP.md +7 -5
  12. package/docs/OUTPUT_EVENT_MODEL.md +4 -3
  13. package/docs/OUTPUT_PROTOCOL_SPEC.md +1 -1
  14. package/docs/OUTPUT_RENDERING_SPEC.md +16 -4
  15. package/docs/OUTPUT_UX_RULES.md +38 -32
  16. package/docs/P14_OPEN_WORK.md +290 -0
  17. package/docs/README.md +1 -1
  18. package/docs/SUMMARY.md +36 -22
  19. package/docs/TERMINAL_CONTRACT.md +89 -17
  20. package/docs/UI_RENDER_PIPELINE.md +47 -8
  21. package/docs/agents.md +1 -1
  22. package/docs/architecture.md +10 -8
  23. package/docs/autonomous-scheduler.md +142 -0
  24. package/docs/choosing-mode.md +4 -2
  25. package/docs/cli.md +11 -9
  26. package/docs/concepts.md +5 -5
  27. package/docs/config-providers.md +3 -3
  28. package/docs/config.md +1 -1
  29. package/docs/contributing.md +7 -9
  30. package/docs/environment.md +8 -5
  31. package/docs/getting-started.md +5 -5
  32. package/docs/mcp-lsp.md +2 -2
  33. package/docs/memory-sessions.md +3 -3
  34. package/docs/policy-sandbox.md +7 -4
  35. package/docs/pricing-budget.md +3 -3
  36. package/docs/quickstart.md +1 -1
  37. package/docs/repl.md +11 -8
  38. package/docs/security-model.md +4 -2
  39. package/docs/security.md +9 -8
  40. package/docs/skills.md +2 -2
  41. package/docs/terminal.md +10 -2
  42. package/docs/tools.md +4 -4
  43. package/docs/troubleshooting.md +3 -3
  44. package/docs/verify-benchmark.md +0 -3
  45. package/package.json +9 -18
  46. package/scripts/vendor-overlays/minicode-context.patch +1 -1
  47. package/src/app/mentions.ts +1 -1
  48. package/src/app/rag-layer.ts +11 -2
  49. package/src/app/session.ts +128 -10
  50. package/src/constants.ts +32 -1
  51. package/src/daemon/client.ts +11 -6
  52. package/src/daemon/control.ts +2 -9
  53. package/src/daemon/resource.ts +5 -4
  54. package/src/hooks/run.ts +5 -6
  55. package/src/lib/keystore.ts +11 -9
  56. package/src/lib/net.ts +8 -3
  57. package/src/lib/safe-open.ts +29 -5
  58. package/src/lib/trusted-exec.ts +4 -1
  59. package/src/lsp/client.ts +9 -10
  60. package/src/mcp/http-transport.ts +1 -1
  61. package/src/mcp/server.ts +17 -7
  62. package/src/memory/files.ts +2 -1
  63. package/src/memory/vector.ts +25 -16
  64. package/src/policy/bash-guard.ts +58 -16
  65. package/src/policy/bpe.ts +110 -0
  66. package/src/policy/compaction.ts +139 -22
  67. package/src/policy/consequence-engine.ts +3 -3
  68. package/src/policy/context-window.ts +43 -1
  69. package/src/policy/context.ts +50 -12
  70. package/src/policy/jail.ts +48 -3
  71. package/src/policy/no-progress.ts +15 -8
  72. package/src/policy/permission.ts +243 -5
  73. package/src/policy/tokenizer-registry.ts +104 -0
  74. package/src/policy/usage.ts +20 -13
  75. package/src/policy/verifier.ts +7 -4
  76. package/src/policy/work-mode.ts +9 -5
  77. package/src/presentation/adapter.ts +8 -4
  78. package/src/presentation/events.ts +2 -2
  79. package/src/presentation/label.ts +3 -3
  80. package/src/presentation/model.ts +4 -0
  81. package/src/presentation/projection.ts +10 -2
  82. package/src/presentation/store.ts +2 -2
  83. package/src/providers/anthropic.ts +13 -3
  84. package/src/providers/responses.ts +16 -6
  85. package/src/runtime/capability.ts +22 -4
  86. package/src/runtime/child-execution.ts +1 -1
  87. package/src/runtime/composition.ts +5 -5
  88. package/src/runtime/execution-journal.ts +13 -7
  89. package/src/runtime/execution-registry.ts +1 -1
  90. package/src/runtime/production-execution.ts +7 -6
  91. package/src/runtime/production-runtime.ts +2 -2
  92. package/src/runtime/runtime-capabilities.ts +1 -1
  93. package/src/runtime/runtime-status-facts.ts +1 -1
  94. package/src/runtime/runtime-task-admission.ts +2 -2
  95. package/src/sandbox/os.ts +4 -3
  96. package/src/session/checkpoint.ts +29 -4
  97. package/src/session/context-assembly.ts +8 -1
  98. package/src/session/context-identity.ts +2 -2
  99. package/src/session/context-projection.ts +36 -11
  100. package/src/session/persistence.ts +22 -11
  101. package/src/task/autonomous-context.ts +2 -3
  102. package/src/task/autonomous-policy.ts +3 -3
  103. package/src/task/model.ts +2 -2
  104. package/src/task/production-scheduler.ts +2 -2
  105. package/src/task/scheduler-observability.ts +1 -0
  106. package/src/task/scheduler.ts +3 -2
  107. package/src/task/scheduling-policy.ts +2 -1
  108. package/src/task/trigger.ts +5 -5
  109. package/src/tools/git.ts +22 -4
  110. package/src/tools/lsp.ts +10 -8
  111. package/src/tools/read_image.ts +2 -1
  112. package/src/tools/task.ts +1 -1
  113. package/src/tools/web_fetch.ts +6 -2
  114. package/src/tools/web_search.ts +2 -1
  115. package/src/ui/assistant/simple.ts +42 -33
  116. package/src/ui/contract.ts +4 -0
  117. package/src/ui/footer.ts +63 -12
  118. package/src/ui/i18n/en.ts +14 -2
  119. package/src/ui/i18n/id.ts +14 -2
  120. package/src/ui/input/prompt-engine.ts +36 -10
  121. package/src/ui/render/cells.ts +320 -0
  122. package/src/ui/render/composer-wrap.ts +73 -0
  123. package/src/ui/render/detail.ts +2 -2
  124. package/src/ui/render/diff.ts +14 -5
  125. package/src/ui/render/highlight.ts +4 -4
  126. package/src/ui/render/ledger.ts +47 -0
  127. package/src/ui/render/markdown.ts +12 -5
  128. package/src/ui/render/session-summary.ts +50 -0
  129. package/src/ui/render/table-grid.ts +134 -6
  130. package/src/ui/render/theme.ts +49 -4
  131. package/src/ui/render/width.ts +91 -4
  132. package/src/ui/render/wrap.ts +5 -3
  133. package/src/ui/runtime/screen.ts +100 -22
  134. package/src/ui/runtime/statusline.ts +26 -0
  135. package/src/ui/screens/model-manager.ts +1 -1
  136. package/src/ui/session-state.ts +27 -1
  137. package/src/ui/tui/app.ts +336 -65
  138. package/src/ui/tui/transcript.ts +335 -104
  139. package/vendor/minicore/VENDOR.md +16 -12
  140. package/vendor/minicore/src/core/events.ts +1 -0
  141. package/vendor/minicore/src/core/loop.ts +11 -1
  142. package/vendor/minicore/src/core/session.ts +39 -0
@@ -1,18 +1,22 @@
1
- # vendor/minicore — JANGAN EDIT MANUAL
1
+ # vendor/minicore — HOST-EDITABLE (unfrozen)
2
2
 
3
- Salinan MiniCore dari source commit yang dipin, ditambah overlay host yang
4
- diperiksa dari patch di `scripts/vendor-overlays/minicode-context.patch`.
5
- Overlay memberi admission context per model dan system prompt dinamis;
6
- simpan seam ini saat menyinkronkan source upstream.
3
+ Salinan MiniCore yang kini **dapat diedit langsung di host** sejak v0.16.0
4
+ (keputusan pemilik 2026-11-10: "vendor beku" DIHAPUS agar pengembangan seam
5
+ host tidak terhambat di tengah banyak perubahan/upgrade).
6
+
7
+ Nilai pin di bawah adalah **referensi historis** (provenance sumber asal),
8
+ **bukan invarian keras**. `bun run vendor:check` tidak lagi dipakai sebagai
9
+ gate; test verifikasi fingerprint dinyatakan nonaktif bersamaan keputusan
10
+ unfreeze ini (lihat `test/import-convention.test.ts`,
11
+ `test/pack-integrity.test.ts`, `test/phase6ae-vendor-eol.test.ts` yang di-skip).
12
+ Bila suatu saat vendor dibekukan kembali, jalankan `bun run vendor:minicore`
13
+ lalu pulihkan test tersebut.
7
14
 
8
15
  - source commit: `0d33571047c0ed3778986108fd42e4bde6828bb0`
9
16
  - source hash: `c8d214bb8d5eea86`
10
- - overlay sha256: `7545ff914e4f83745634ee106c9a2e774dfea3bf4541e58ea98eba216902d432`
17
+ - overlay sha256: `fa3e3a789782523c3de99c2d31c173789a7fee2bf0f8087267c222ce9b4eebcf`
11
18
  - files: 20
12
- - hash: `b5e27f72d08afb98`
13
- - shipped hash: `4998979304b3c6e2` (18 file) — fingerprint file vendor yang ikut paket npm
14
- (hash di atas mencakup test/fakes.ts yang sengaja tidak ikut paket;
15
- verifikasi dari paket terbit: hitung hash vendor/minicore di dalam tarball)
19
+ - hash: `4cee16b60d65d18f`
20
+ - shipped hash: `b714c2adc59ea720` (18 file)
16
21
 
17
- Perbarui dengan `bun run vendor:minicore` (butuh `../minicore`).
18
- `bun run vendor:check` memverifikasi source, overlay, dan fingerprint final.
22
+ Perbarui referensi dengan `bun run vendor:minicore` (butuh `../minicore`).
@@ -5,6 +5,7 @@ import type { Execution, Step, TurnResult } from "./session.ts";
5
5
  export type AgentEvent =
6
6
  | { type: "turn:started"; turn: number }
7
7
  | { type: "turn:completed"; result: TurnResult }
8
+ | { type: "turn:interrupted" }
8
9
  | { type: "step:started"; step: Step }
9
10
  | { type: "step:completed"; step: Step }
10
11
  | { type: "execution:started"; execution: Execution }
@@ -50,7 +50,7 @@ export async function executeTurn(
50
50
  // Permit one follow-up policy compaction after tool results grow the current
51
51
  // turn. The hard cap prevents a no-progress compactor from looping forever.
52
52
  let budgetCompactions = 0;
53
- const maxBudgetCompactions = 2;
53
+ const maxBudgetCompactions = 3;
54
54
  let compactedForRecovery = false;
55
55
 
56
56
  // Resolve once for the turn: model switching is a between-turn operation,
@@ -274,6 +274,16 @@ export async function executeTurn(
274
274
  steps.push(step);
275
275
  s.state.stepCount = stepIndex + 1;
276
276
  s.events.emit({ type: "step:completed", step: snapshotStep(step) });
277
+ // Live context occupancy (host seam): laporkan ukuran konteks turn-store
278
+ // SESUDAH hasil tool step ini masuk, sehingga host (footer TUI) dapat
279
+ // memperbarui meter konteks per step alih-alih menunggu turn selesai.
280
+ // Nilai ini memakai estimator "satu sumber" yang sama dengan pressure eval
281
+ // di atas — tanpa duplikasi estimator.
282
+ s.events.emit({
283
+ type: "provider:extension",
284
+ kind: "context-window",
285
+ data: { usedTokens: contextTokens(s), windowTokens: contextWindowTokens },
286
+ });
277
287
  stepIndex++;
278
288
  }
279
289
 
@@ -260,6 +260,17 @@ export function createSession(config: SessionConfig): Session {
260
260
  state.stepCount = turnState.stepCount;
261
261
  events.emit({ type: "turn:completed", result: snapshotTurnResult(result) });
262
262
  return result;
263
+ } catch (error) {
264
+ // B3 (host seam): on abort/timeout/error, the turn is transactional —
265
+ // but a long turn that only reads (no mutations) would otherwise lose
266
+ // all accumulated context on resume. Commit the partUp to a complete
267
+ // step boundary so a later run/resume can continue instead of amnesia.
268
+ const safe = safeTurnBoundary(store.messages.length, turnStore.messages);
269
+ if (safe.length > store.messages.length) {
270
+ store.replace(0, store.messages.length, safe);
271
+ events.emit({ type: "turn:interrupted" });
272
+ }
273
+ throw error;
263
274
  } finally {
264
275
  timeout.cancel();
265
276
  joined.cleanup();
@@ -338,3 +349,31 @@ function withAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {
338
349
  }
339
350
  });
340
351
  }
352
+
353
+ /**
354
+ * B3 — batas commit aman untuk turn yang terputus (abort/timeout/error).
355
+ *
356
+ * `executeTurn` selalu memulai turnStore dengan prefix committed + SATU pesan
357
+ * `user` (input), lalu per step menambah assistant(toolCalls) → tool results.
358
+ * Abort bisa meninggalkan (a) hanya si `user` input, atau (b) `assistant(toolCalls)`
359
+ * yang hasilnya belum sempat di-append (orphan). Keduanya HARUS dibuang:
360
+ * (a) karena menyimpannya membuat dua `user` berurutan pada run berikutnya
361
+ * (invariant role bergantian → HTTP 400), (b) karena pasangan tool-call/result
362
+ * yang menggantung akan ditolak dilihat resume. Selain itu, commit sejauh
363
+ * langkah lengkap terakhir.
364
+ */
365
+ function safeTurnBoundary(committedLen: number, messages: readonly Message[]): readonly Message[] {
366
+ let end = messages.length
367
+ while (end > committedLen) {
368
+ const last = messages[end - 1]
369
+ if (last && last.role === "assistant" && Array.isArray(last.toolCalls) && last.toolCalls.length > 0) {
370
+ end-- // orphaned toolCalls tanpa hasil
371
+ } else {
372
+ break
373
+ }
374
+ }
375
+ if (end === committedLen + 1 && messages[committedLen]?.role === "user") {
376
+ end = committedLen // hanya input baru — tidak ada progres untuk dipertahankan
377
+ }
378
+ return messages.slice(0, end)
379
+ }