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.
- package/README.md +6 -4
- package/cli/args.ts +20 -8
- package/cli/commands/exec.ts +17 -14
- package/cli/commands/openwork.ts +1 -1
- package/cli/commands.ts +39 -23
- package/cli/index.ts +29 -7
- package/cli/model-manager.ts +1 -1
- package/cli/router.ts +22 -9
- package/cli/setup.ts +77 -35
- package/cli/tui.ts +179 -25
- package/docs/CONTROL-PLANE-MAP.md +7 -5
- package/docs/OUTPUT_EVENT_MODEL.md +4 -3
- package/docs/OUTPUT_PROTOCOL_SPEC.md +1 -1
- package/docs/OUTPUT_RENDERING_SPEC.md +16 -4
- package/docs/OUTPUT_UX_RULES.md +38 -32
- package/docs/P14_OPEN_WORK.md +290 -0
- package/docs/README.md +1 -1
- package/docs/SUMMARY.md +36 -22
- package/docs/TERMINAL_CONTRACT.md +89 -17
- package/docs/UI_RENDER_PIPELINE.md +47 -8
- package/docs/agents.md +1 -1
- package/docs/architecture.md +10 -8
- package/docs/autonomous-scheduler.md +142 -0
- package/docs/choosing-mode.md +4 -2
- package/docs/cli.md +11 -9
- package/docs/concepts.md +5 -5
- package/docs/config-providers.md +3 -3
- package/docs/config.md +1 -1
- package/docs/contributing.md +7 -9
- package/docs/environment.md +8 -5
- package/docs/getting-started.md +5 -5
- package/docs/mcp-lsp.md +2 -2
- package/docs/memory-sessions.md +3 -3
- package/docs/policy-sandbox.md +7 -4
- package/docs/pricing-budget.md +3 -3
- package/docs/quickstart.md +1 -1
- package/docs/repl.md +11 -8
- package/docs/security-model.md +4 -2
- package/docs/security.md +9 -8
- package/docs/skills.md +2 -2
- package/docs/terminal.md +10 -2
- package/docs/tools.md +4 -4
- package/docs/troubleshooting.md +3 -3
- package/docs/verify-benchmark.md +0 -3
- package/package.json +9 -18
- package/scripts/vendor-overlays/minicode-context.patch +1 -1
- package/src/app/mentions.ts +1 -1
- package/src/app/rag-layer.ts +11 -2
- package/src/app/session.ts +128 -10
- package/src/constants.ts +32 -1
- package/src/daemon/client.ts +11 -6
- package/src/daemon/control.ts +2 -9
- package/src/daemon/resource.ts +5 -4
- package/src/hooks/run.ts +5 -6
- package/src/lib/keystore.ts +11 -9
- package/src/lib/net.ts +8 -3
- package/src/lib/safe-open.ts +29 -5
- package/src/lib/trusted-exec.ts +4 -1
- package/src/lsp/client.ts +9 -10
- package/src/mcp/http-transport.ts +1 -1
- package/src/mcp/server.ts +17 -7
- package/src/memory/files.ts +2 -1
- package/src/memory/vector.ts +25 -16
- package/src/policy/bash-guard.ts +58 -16
- package/src/policy/bpe.ts +110 -0
- package/src/policy/compaction.ts +139 -22
- package/src/policy/consequence-engine.ts +3 -3
- package/src/policy/context-window.ts +43 -1
- package/src/policy/context.ts +50 -12
- package/src/policy/jail.ts +48 -3
- package/src/policy/no-progress.ts +15 -8
- package/src/policy/permission.ts +243 -5
- package/src/policy/tokenizer-registry.ts +104 -0
- package/src/policy/usage.ts +20 -13
- package/src/policy/verifier.ts +7 -4
- package/src/policy/work-mode.ts +9 -5
- package/src/presentation/adapter.ts +8 -4
- package/src/presentation/events.ts +2 -2
- package/src/presentation/label.ts +3 -3
- package/src/presentation/model.ts +4 -0
- package/src/presentation/projection.ts +10 -2
- package/src/presentation/store.ts +2 -2
- package/src/providers/anthropic.ts +13 -3
- package/src/providers/responses.ts +16 -6
- package/src/runtime/capability.ts +22 -4
- package/src/runtime/child-execution.ts +1 -1
- package/src/runtime/composition.ts +5 -5
- package/src/runtime/execution-journal.ts +13 -7
- package/src/runtime/execution-registry.ts +1 -1
- package/src/runtime/production-execution.ts +7 -6
- package/src/runtime/production-runtime.ts +2 -2
- package/src/runtime/runtime-capabilities.ts +1 -1
- package/src/runtime/runtime-status-facts.ts +1 -1
- package/src/runtime/runtime-task-admission.ts +2 -2
- package/src/sandbox/os.ts +4 -3
- package/src/session/checkpoint.ts +29 -4
- package/src/session/context-assembly.ts +8 -1
- package/src/session/context-identity.ts +2 -2
- package/src/session/context-projection.ts +36 -11
- package/src/session/persistence.ts +22 -11
- package/src/task/autonomous-context.ts +2 -3
- package/src/task/autonomous-policy.ts +3 -3
- package/src/task/model.ts +2 -2
- package/src/task/production-scheduler.ts +2 -2
- package/src/task/scheduler-observability.ts +1 -0
- package/src/task/scheduler.ts +3 -2
- package/src/task/scheduling-policy.ts +2 -1
- package/src/task/trigger.ts +5 -5
- package/src/tools/git.ts +22 -4
- package/src/tools/lsp.ts +10 -8
- package/src/tools/read_image.ts +2 -1
- package/src/tools/task.ts +1 -1
- package/src/tools/web_fetch.ts +6 -2
- package/src/tools/web_search.ts +2 -1
- package/src/ui/assistant/simple.ts +42 -33
- package/src/ui/contract.ts +4 -0
- package/src/ui/footer.ts +63 -12
- package/src/ui/i18n/en.ts +14 -2
- package/src/ui/i18n/id.ts +14 -2
- package/src/ui/input/prompt-engine.ts +36 -10
- package/src/ui/render/cells.ts +320 -0
- package/src/ui/render/composer-wrap.ts +73 -0
- package/src/ui/render/detail.ts +2 -2
- package/src/ui/render/diff.ts +14 -5
- package/src/ui/render/highlight.ts +4 -4
- package/src/ui/render/ledger.ts +47 -0
- package/src/ui/render/markdown.ts +12 -5
- package/src/ui/render/session-summary.ts +50 -0
- package/src/ui/render/table-grid.ts +134 -6
- package/src/ui/render/theme.ts +49 -4
- package/src/ui/render/width.ts +91 -4
- package/src/ui/render/wrap.ts +5 -3
- package/src/ui/runtime/screen.ts +100 -22
- package/src/ui/runtime/statusline.ts +26 -0
- package/src/ui/screens/model-manager.ts +1 -1
- package/src/ui/session-state.ts +27 -1
- package/src/ui/tui/app.ts +336 -65
- package/src/ui/tui/transcript.ts +335 -104
- package/vendor/minicore/VENDOR.md +16 -12
- package/vendor/minicore/src/core/events.ts +1 -0
- package/vendor/minicore/src/core/loop.ts +11 -1
- package/vendor/minicore/src/core/session.ts +39 -0
package/cli/setup.ts
CHANGED
|
@@ -59,6 +59,8 @@ import {
|
|
|
59
59
|
matchTurnBySummary,
|
|
60
60
|
pendingVerificationObservation,
|
|
61
61
|
projectProvenance,
|
|
62
|
+
provenanceMark,
|
|
63
|
+
verificationMark,
|
|
62
64
|
} from "../src/presentation/projection.ts"
|
|
63
65
|
import {
|
|
64
66
|
createReducerDiagnostics,
|
|
@@ -112,11 +114,7 @@ import {
|
|
|
112
114
|
type RuntimeContextMetadata,
|
|
113
115
|
runtimeMetadataFromSelection,
|
|
114
116
|
} from "../src/session/context-adapter.ts"
|
|
115
|
-
import {
|
|
116
|
-
assembleContext,
|
|
117
|
-
type ContextOnlyArtifact,
|
|
118
|
-
stripContextOnly,
|
|
119
|
-
} from "../src/session/context-assembly.ts"
|
|
117
|
+
import { type ContextOnlyArtifact, stripContextOnly } from "../src/session/context-assembly.ts"
|
|
120
118
|
import {
|
|
121
119
|
countDurableCompactions,
|
|
122
120
|
deriveFrontierFromDurable,
|
|
@@ -1120,13 +1118,15 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1120
1118
|
}
|
|
1121
1119
|
}
|
|
1122
1120
|
|
|
1123
|
-
// Timeout default: --timeout > MINICODE_TIMEOUT_MS env >
|
|
1121
|
+
// Timeout default: --timeout > MINICODE_TIMEOUT_MS env > 1 jam. 0 = Infinity.
|
|
1122
|
+
// Default interaktif 1 jam (audit panjang tak macet di tengah); jalur exec
|
|
1123
|
+
// meneruskan default 15 menit sendiri (lebih konservatif untuk CI).
|
|
1124
1124
|
const envTimeout = process.env.MINICODE_TIMEOUT_MS
|
|
1125
1125
|
let effectiveTimeoutMs =
|
|
1126
|
-
timeoutMs ?? (envTimeout != null && envTimeout !== "" ? Number(envTimeout) :
|
|
1126
|
+
timeoutMs ?? (envTimeout != null && envTimeout !== "" ? Number(envTimeout) : 3_600_000)
|
|
1127
1127
|
if (!Number.isFinite(effectiveTimeoutMs) || effectiveTimeoutMs < 0) {
|
|
1128
|
-
process.stderr.write(`[warn] invalid timeout ${effectiveTimeoutMs}, fallback to
|
|
1129
|
-
effectiveTimeoutMs =
|
|
1128
|
+
process.stderr.write(`[warn] invalid timeout ${effectiveTimeoutMs}, fallback to 3600000\n`)
|
|
1129
|
+
effectiveTimeoutMs = 3_600_000
|
|
1130
1130
|
} else if (effectiveTimeoutMs > LIMITS.MAX_TIMER_DELAY_MS) {
|
|
1131
1131
|
process.stderr.write(
|
|
1132
1132
|
`[warn] timeout exceeds runtime limit; capped at ${LIMITS.MAX_TIMER_DELAY_MS}ms\n`,
|
|
@@ -1215,6 +1215,7 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1215
1215
|
}
|
|
1216
1216
|
const effectiveDefaultModel = () => modelRef.current ?? cfg.providers[0]?.models[0]
|
|
1217
1217
|
const warnedContextModels = new Set<string>()
|
|
1218
|
+
const warnedCatalogDrift = new Set<string>()
|
|
1218
1219
|
const routedContextModel = (model?: string) =>
|
|
1219
1220
|
router.contextModelIdentity(model ?? effectiveDefaultModel()) ?? model ?? "default"
|
|
1220
1221
|
const contextModelId = (requested?: string): string => {
|
|
@@ -1233,6 +1234,19 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1233
1234
|
)
|
|
1234
1235
|
}
|
|
1235
1236
|
}
|
|
1237
|
+
// R9/T8 — katalog vs models.dev beda >2×: katalog mungkin basi. Peringatkan
|
|
1238
|
+
// sekali per model agar user tahu harus `pricing sync`/set contextWindows.
|
|
1239
|
+
if (resolved.drift) {
|
|
1240
|
+
const key = resolved.providerId
|
|
1241
|
+
? `${resolved.providerId}::${resolved.model ?? "default"}`
|
|
1242
|
+
: (resolved.model ?? "default")
|
|
1243
|
+
if (!warnedCatalogDrift.has(key)) {
|
|
1244
|
+
warnedCatalogDrift.add(key)
|
|
1245
|
+
process.stderr.write(
|
|
1246
|
+
`${c.yellow(`[context] catalog window ${resolved.drift.catalogTokens} for ${sanitizeAnsi(key)} differs >2x from models.dev (${resolved.drift.overlayTokens}); catalog may be stale — run \`minicode pricing sync\` or set provider.contextWindows.\n`)}`,
|
|
1247
|
+
)
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1236
1250
|
return resolved.tokens
|
|
1237
1251
|
}
|
|
1238
1252
|
const getReportedContextWindowTokens = (model?: string) => {
|
|
@@ -1322,12 +1336,6 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1322
1336
|
resumeUsageSnapshot = loadSessionUsageSummary(sessionId, cwd)
|
|
1323
1337
|
}
|
|
1324
1338
|
if (prev?.messages.length) {
|
|
1325
|
-
// P2.8 — perakitan konteks (baca-saja, turunan, RAM): pakai ringkasan
|
|
1326
|
-
// proyeksi HANYA bila CURRENT; state lain/absen → fallback histori
|
|
1327
|
-
// kanonik utuh (identik replay sebelum P2.8). Tak pernah menulis apa pun.
|
|
1328
|
-
// `view` tetap dipakai untuk diagnostik + kompatibilitas P2.8.
|
|
1329
|
-
const view = assembleContext(sessionId, defaultThread.thread_id, cwd)
|
|
1330
|
-
|
|
1331
1339
|
// [Fase 4 / LOOP-13, LOOP-INV-16] Kumpulkan snapshot state operasional
|
|
1332
1340
|
// deterministik dari sumber durable (TaskStore + usage historis) agar
|
|
1333
1341
|
// header [RUNTIME_STATE_HEADER] ikut ke konteks resume — tak hilang
|
|
@@ -1368,18 +1376,13 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1368
1376
|
const rowsForSelector = loadThreadHistoryWithSeq(sessionId, defaultThread.thread_id, cwd)
|
|
1369
1377
|
// P3.4: proyeksi kanonik durable adalah sumber UTAMA untuk selector
|
|
1370
1378
|
// (cakupan-valid: CURRENT atau STALE berjangkar utuh, P3.0 §8 D6),
|
|
1371
|
-
// sehingga `summary-plus-tail` menjadi perilaku produksi nyata.
|
|
1372
|
-
// `assembleContext` (CURRENT-only) tetap jadi fallback kompatibel.
|
|
1379
|
+
// sehingga `summary-plus-tail` menjadi perilaku produksi nyata.
|
|
1373
1380
|
const durableProjection = readConsumableSummaryProjection(
|
|
1374
1381
|
sessionId,
|
|
1375
1382
|
cwd,
|
|
1376
1383
|
defaultThread.thread_id,
|
|
1377
1384
|
)
|
|
1378
|
-
const projectionSummary =
|
|
1379
|
-
durableProjection ??
|
|
1380
|
-
(view.source === "projection" && view.summary
|
|
1381
|
-
? { baseSeq: view.coveredSeq, summaryText: view.summary }
|
|
1382
|
-
: undefined)
|
|
1385
|
+
const projectionSummary = durableProjection
|
|
1383
1386
|
const selectedWindow = getContextWindowTokens()
|
|
1384
1387
|
const messageBudget = selectedWindow
|
|
1385
1388
|
// N1: turunkan frontier kanonis dari baris yang BARU DIBACA (sumber
|
|
@@ -1426,16 +1429,10 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1426
1429
|
console.error(
|
|
1427
1430
|
c.dim(
|
|
1428
1431
|
// "(N messages)" dipertahankan VERBATIM (kontrak diagnostik yang
|
|
1429
|
-
// sudah dipakai test/CLI)
|
|
1430
|
-
// segmen terpisah agar tak mengubah string yang sudah diam.
|
|
1432
|
+
// sudah dipakai test/CLI).
|
|
1431
1433
|
`[resumed session ${sessionId} (${prev.messages.length} messages)]\n`,
|
|
1432
1434
|
),
|
|
1433
1435
|
)
|
|
1434
|
-
console.error(
|
|
1435
|
-
c.dim(
|
|
1436
|
-
`[context sid=${sessionId} source=${view.source} status=${view.status} covered=${view.coveredSeq}]\n`,
|
|
1437
|
-
),
|
|
1438
|
-
)
|
|
1439
1436
|
// P3.3 — jejak provenance seleksi (baca-saja; tak mengubah perilaku).
|
|
1440
1437
|
console.error(
|
|
1441
1438
|
c.dim(
|
|
@@ -1625,8 +1622,30 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1625
1622
|
orphanEvidence: shadowDiag?.orphanEvidence ?? 0,
|
|
1626
1623
|
unsupportedProjection,
|
|
1627
1624
|
})
|
|
1625
|
+
// Fase 1 perf (butir 1): cache snapshot presentasi. Snapshot dibangun ulang
|
|
1626
|
+
// penuh pada tiap panggil — padahal panggil terjadi tiap paint (ketikan/scroll),
|
|
1627
|
+
// dan nilai yang dibangun tidak berubah di antara event. Reducer immutable:
|
|
1628
|
+
// shadowState hanya bermutasi via reduce(event); reduce menaikkan `state.seq`
|
|
1629
|
+
// HANYA pada event durable, dan semata field yang dipetakan ke snapshot pun
|
|
1630
|
+
// hanya diubah oleh event durable (model.delta/tool.progress/context.window
|
|
1631
|
+
// kembali awal / hanya menulis `progress` yang tak masuk snapshot). Karena itu
|
|
1632
|
+
// cache ber-key (objek state, seq) aman: seq berubah ⟺ snapshot berubah.
|
|
1633
|
+
let snapshotCache: {
|
|
1634
|
+
state: PresentationState
|
|
1635
|
+
seq: number
|
|
1636
|
+
value: UiPresentationSnapshot
|
|
1637
|
+
} | null = null
|
|
1628
1638
|
const getPresentationSnapshot = (): UiPresentationSnapshot => {
|
|
1629
1639
|
if (!shadowState) return { activities: [], turns: [] }
|
|
1640
|
+
// Objek `shadowState` identik + seq identik = konten tak berubah (lihat
|
|
1641
|
+
// alasan di atas); reuse tanpa membangun ulang ratusan objek per paint.
|
|
1642
|
+
if (
|
|
1643
|
+
snapshotCache &&
|
|
1644
|
+
snapshotCache.state === shadowState &&
|
|
1645
|
+
snapshotCache.seq === shadowState.seq
|
|
1646
|
+
) {
|
|
1647
|
+
return snapshotCache.value
|
|
1648
|
+
}
|
|
1630
1649
|
const activities: UiPresentationActivity[] = [...shadowState.activities.values()].map((a) => ({
|
|
1631
1650
|
seq: a.seq,
|
|
1632
1651
|
turnId: a.turnId,
|
|
@@ -1750,7 +1769,7 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1750
1769
|
...(entry.cause ? { cause: entry.cause } : {}),
|
|
1751
1770
|
...(entry.action ? { action: entry.action } : {}),
|
|
1752
1771
|
}))
|
|
1753
|
-
|
|
1772
|
+
const snapshot: UiPresentationSnapshot = {
|
|
1754
1773
|
activities,
|
|
1755
1774
|
turns,
|
|
1756
1775
|
conversation,
|
|
@@ -1761,6 +1780,8 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1761
1780
|
results,
|
|
1762
1781
|
diagnostics,
|
|
1763
1782
|
}
|
|
1783
|
+
snapshotCache = { state: shadowState, seq: shadowState.seq, value: snapshot }
|
|
1784
|
+
return snapshot
|
|
1764
1785
|
}
|
|
1765
1786
|
const onPresentationEvent = (handler: (event: UiPresentationEvent) => void): (() => void) => {
|
|
1766
1787
|
presentationSubscribers.add(handler)
|
|
@@ -1793,9 +1814,20 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1793
1814
|
}
|
|
1794
1815
|
}
|
|
1795
1816
|
const compaction = createLlmCompaction({
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1817
|
+
// LLM compaction DIUTAMAKAN supaya fakta tak hilang lewat fallback mekanikal
|
|
1818
|
+
// yang lossy. Provider: summarizer murah khusus (DEEPSEEK_API_KEY) ATAU
|
|
1819
|
+
// pakai ulang provider sesi (router) — jangan diam-diam jatuh ke mekanikal
|
|
1820
|
+
// bila sesi punya provider.
|
|
1821
|
+
...(process.env.DEEPSEEK_API_KEY
|
|
1822
|
+
? {
|
|
1823
|
+
apiKey: process.env.DEEPSEEK_API_KEY,
|
|
1824
|
+
baseUrl: process.env.DEEPSEEK_BASE_URL ?? "https://api.deepseek.com/v1",
|
|
1825
|
+
model: "deepseek-chat",
|
|
1826
|
+
}
|
|
1827
|
+
: {
|
|
1828
|
+
provider: router,
|
|
1829
|
+
model: modelRef.current ?? cfg.providers[0]?.models[0] ?? "deepseek-chat",
|
|
1830
|
+
}),
|
|
1799
1831
|
cwd: cwd ?? process.cwd(),
|
|
1800
1832
|
getContextWindowTokens,
|
|
1801
1833
|
onUsage: (u) => {
|
|
@@ -1810,8 +1842,8 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
1810
1842
|
totalTokens: u.totalTokens,
|
|
1811
1843
|
source: "compaction",
|
|
1812
1844
|
// P1.4: atribusi biaya compaction memakai model yang benar-benar
|
|
1813
|
-
// dipakai (
|
|
1814
|
-
model:
|
|
1845
|
+
// dipakai (u.model dari compactWithLlm), bukan hardcode.
|
|
1846
|
+
model: u.model,
|
|
1815
1847
|
},
|
|
1816
1848
|
})
|
|
1817
1849
|
} catch {}
|
|
@@ -2982,6 +3014,14 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
2982
3014
|
const { attachBusDebug } = await import("../src/ui/runtime/bus-debug.ts")
|
|
2983
3015
|
const detachBusDebug = attachBusDebug(session.events)
|
|
2984
3016
|
const usage = createUsageCollector(session.events, effectiveInitialModel, resumeUsageSnapshot)
|
|
3017
|
+
// B3 — persist parsial saat turn terputus (timeout/abort/error): kernel sudah
|
|
3018
|
+
// commit turnStore sampai batas aman ke committed store (RAM); di sini kita
|
|
3019
|
+
// flush ke SQLite (durable) supaya `--resume` tak amnesia. Fire-and-forget:
|
|
3020
|
+
// listener bus tak boleh melempar/blocking, dan persist gagal (mis. stale
|
|
3021
|
+
// writer) = best-effort. Penting untuk REPL+resume lintas proses.
|
|
3022
|
+
session.events.on("turn:interrupted", () => {
|
|
3023
|
+
void persistCurrent(usage.getSession()).catch(() => {})
|
|
3024
|
+
})
|
|
2985
3025
|
// Statusline kaya = opt-in (default mati, shell tetap bersih). Data biaya
|
|
2986
3026
|
// disuntik sebagai callback agar UI tak perlu impor lapisan policy.
|
|
2987
3027
|
const richStatus = process.env.MINICODE_STATUSLINE === "rich"
|
|
@@ -3004,6 +3044,8 @@ export async function createCliSession(opts: CliSessionOptions): Promise<CliSess
|
|
|
3004
3044
|
describeActivity,
|
|
3005
3045
|
matchTurn: matchTurnBySummary,
|
|
3006
3046
|
elapsedVisible,
|
|
3047
|
+
verificationMark,
|
|
3048
|
+
provenanceMark,
|
|
3007
3049
|
},
|
|
3008
3050
|
})
|
|
3009
3051
|
if (enterRepl === true) {
|
package/cli/tui.ts
CHANGED
|
@@ -21,10 +21,17 @@ import {
|
|
|
21
21
|
describeActivity,
|
|
22
22
|
elapsedVisible,
|
|
23
23
|
matchTurnBySummary,
|
|
24
|
+
provenanceMark,
|
|
25
|
+
verificationMark,
|
|
24
26
|
} from "../src/presentation/projection.ts"
|
|
25
27
|
import { redoLastCheckpoint, undoLastCheckpoint } from "../src/session/checkpoint.ts"
|
|
26
28
|
import { renderSkill } from "../src/skills/loader.ts"
|
|
27
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
clipboardByteLength,
|
|
31
|
+
MAX_CLIPBOARD_BYTES,
|
|
32
|
+
MAX_COPY_TURNS,
|
|
33
|
+
writeClipboardOsc52,
|
|
34
|
+
} from "../src/ui/assistant/simple.ts"
|
|
28
35
|
import type { UiBus } from "../src/ui/contract.ts"
|
|
29
36
|
import { t } from "../src/ui/i18n/locale.ts"
|
|
30
37
|
import { loadHistory } from "../src/ui/input/input.ts"
|
|
@@ -58,6 +65,7 @@ const DRIVER_COMMANDS = [
|
|
|
58
65
|
"/thinking",
|
|
59
66
|
"/expand [id]",
|
|
60
67
|
"/minimize",
|
|
68
|
+
"/fold",
|
|
61
69
|
"/mode",
|
|
62
70
|
"/work-mode",
|
|
63
71
|
]
|
|
@@ -74,14 +82,16 @@ function fmtCtx(n: number): string | undefined {
|
|
|
74
82
|
* F-CTX-1: metrik usage footer (biaya + window %) dari angka NYATA, tanpa
|
|
75
83
|
* perkiraan. Kosong = tak ada data relevan (belum belanja / flag window tak
|
|
76
84
|
* disetel) — footer tak pernah menampilkan persentase/biaya palsu.
|
|
85
|
+
*
|
|
86
|
+
* P1.4: persentase footer = OCCUPANCY konteks saat ini (param `used`), bukan
|
|
87
|
+
* total token yang sudah dibelanjakan sepanjang sesi. Memakai spend membuat
|
|
88
|
+
* footer mentok 100% setelah beberapa step meski konteks masih jauh di bawah
|
|
89
|
+
* window. `used` di-inject oleh pemanggil (cache per turn) agar angka
|
|
90
|
+
* O(history) `session.contextTokens` tak dihitung ulang tiap paint.
|
|
77
91
|
*/
|
|
78
|
-
function fmtUsageMetrics(ctx: CliSession): string | undefined {
|
|
92
|
+
function fmtUsageMetrics(ctx: CliSession, used: number): string | undefined {
|
|
79
93
|
const cost: number | undefined = ctx.usage.getSession().cost
|
|
80
94
|
const windowTokens: number | undefined = ctx.getContextWindowTokens?.() ?? ctx.contextWindowTokens
|
|
81
|
-
// P1.4: persentase footer = OCCUPANCY konteks saat ini, bukan total token
|
|
82
|
-
// yang sudah dibelanjakan sepanjang sesi. Memakai spend membuat footer
|
|
83
|
-
// mentok 100% setelah beberapa step meski konteks masih jauh di bawah window.
|
|
84
|
-
const used: number = ctx.session.contextTokens
|
|
85
95
|
const parts: string[] = []
|
|
86
96
|
if (cost !== undefined && Number.isFinite(cost) && cost > 0) parts.push(formatUsd(cost))
|
|
87
97
|
if (
|
|
@@ -99,7 +109,7 @@ function fmtUsageMetrics(ctx: CliSession): string | undefined {
|
|
|
99
109
|
/**
|
|
100
110
|
* Tangkap console.log/error selama `fn` → baris teks (tanpa warna liar:
|
|
101
111
|
* caller yang mewarnai). Dipakai membungkus handleBuiltinCommand supaya
|
|
102
|
-
* readout warisan (/help,
|
|
112
|
+
* readout warisan (/help, pesan status/undo) mendarat di transkrip,
|
|
103
113
|
* bukan menimpa frame alt-screen. View modal menulis via stdout.write
|
|
104
114
|
* langsung (bukan console) sehingga tak ikut tertangkap — layarnya tetap
|
|
105
115
|
* tampil normal (nested refcount screen.ts). Baris yang sudah tercetak
|
|
@@ -153,7 +163,8 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
153
163
|
} = ctx
|
|
154
164
|
const { session } = ctx
|
|
155
165
|
// [Area A · PROMPT 06] State UI sesi. `runTui` juga dijalankan fixture tes
|
|
156
|
-
// dengan CliSession parsial — absen berarti pakai instance default
|
|
166
|
+
// dengan CliSession parsial — absen berarti pakai instance default (dipakai
|
|
167
|
+
// tes yang memasangkan logger linier + TUI pada state yang sama).
|
|
157
168
|
const ui: UiSessionState = ctx.uiState ?? defaultUiState
|
|
158
169
|
const getPresentationSnapshot = () =>
|
|
159
170
|
typeof ctx.getPresentationSnapshot === "function"
|
|
@@ -161,11 +172,70 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
161
172
|
: { activities: [], turns: [] }
|
|
162
173
|
|
|
163
174
|
let mode: string = permissions?.getMode() ?? permissionMode ?? "auto"
|
|
175
|
+
// Mode permission sebelum /unrestric diaktifkan — dipakai untuk memulihkan
|
|
176
|
+
// saat operator menonaktifkannya kembali (toggle, per-sesi).
|
|
177
|
+
let modeBeforeUnrestricted: string | null = null
|
|
178
|
+
let workModeBeforeUnrestricted: "DISCUSS" | "PLAN" | "EXECUTE" | null = null
|
|
164
179
|
if (process.env.MINICODE_COMPACT === undefined) ui.setCompactMode(true)
|
|
165
180
|
if (process.env.MINICODE_MINIMIZE_TOOL === undefined) ui.setSectionMinimized("tool", true)
|
|
181
|
+
// Grouping aktivitas tool jadi satu baris (opencode-like): default ON di TUI;
|
|
182
|
+
// `MINICODE_MINIMIZE_ACTIVITY=0` eksplisit mematikan (transparan). Hanya
|
|
183
|
+
// disetel pada instance MILIK SESI (ctx.uiState ada) — bukan singleton default
|
|
184
|
+
// (dipakai path tes) agar nilai tidak bocor antar tes.
|
|
185
|
+
if (ctx.uiState !== undefined && process.env.MINICODE_MINIMIZE_ACTIVITY === undefined)
|
|
186
|
+
ui.setMinimizeActivity(true)
|
|
166
187
|
let warned80 = false
|
|
167
188
|
let abort: AbortController | null = null
|
|
168
189
|
|
|
190
|
+
// Fase 1 perf (butir 2b): `session.contextTokens` adalah getter O(history)
|
|
191
|
+
// (estimateMessages mengiterasi SELURUH store + estimator per pesan). Footer
|
|
192
|
+
// membacanya tiap paint/ketikan — untuk chat panjang ini pengulangan token
|
|
193
|
+
// estimation penuh per ketikan. Committed store hanya berubah saat turn
|
|
194
|
+
// selesai (turnCount naik), jadi cache keyed turnCount aman + output-identik.
|
|
195
|
+
let cachedContext: { turn: number; tokens: number } | null = null
|
|
196
|
+
// Item 16 (live context): nilai per-step yang di-emit kernel (loop.ts, event
|
|
197
|
+
// `provider:extension` kind `context-window`). Saat turn berjalan nilainya
|
|
198
|
+
// O(1) dan terus diperbarui tiap step; direset di batas turn agar idle
|
|
199
|
+
// kembali ke nilai committed.
|
|
200
|
+
let liveContextTokens: number | undefined
|
|
201
|
+
const liveContextUnsubs: (() => void)[] = []
|
|
202
|
+
const uiBus = session.events as unknown as UiBus
|
|
203
|
+
try {
|
|
204
|
+
liveContextUnsubs.push(
|
|
205
|
+
uiBus.on("provider:extension", (e: { kind?: unknown; data?: unknown }) => {
|
|
206
|
+
if (e?.kind !== "context-window") return
|
|
207
|
+
const d = e.data as { usedTokens?: unknown } | undefined
|
|
208
|
+
if (typeof d?.usedTokens === "number") liveContextTokens = d.usedTokens
|
|
209
|
+
}),
|
|
210
|
+
)
|
|
211
|
+
} catch {}
|
|
212
|
+
try {
|
|
213
|
+
liveContextUnsubs.push(
|
|
214
|
+
uiBus.on("turn:started", () => {
|
|
215
|
+
liveContextTokens = undefined
|
|
216
|
+
}),
|
|
217
|
+
)
|
|
218
|
+
} catch {}
|
|
219
|
+
try {
|
|
220
|
+
liveContextUnsubs.push(
|
|
221
|
+
uiBus.on("turn:completed", () => {
|
|
222
|
+
liveContextTokens = undefined
|
|
223
|
+
}),
|
|
224
|
+
)
|
|
225
|
+
} catch {}
|
|
226
|
+
const getContextTokens = (): number => {
|
|
227
|
+
// Live (per-step) menang saat turn berjalan; idle → committed (cache).
|
|
228
|
+
if (liveContextTokens !== undefined) return liveContextTokens
|
|
229
|
+
// Beberapa fixture test menyediakan `session` parsial (tanpa `state`): tanpa
|
|
230
|
+
// sinyal turn yang andal, baca langsung seperti perilaku lama.
|
|
231
|
+
const turn = (session.state as { turnCount?: number } | undefined)?.turnCount
|
|
232
|
+
if (turn === undefined) return session.contextTokens
|
|
233
|
+
if (!cachedContext || cachedContext.turn !== turn) {
|
|
234
|
+
cachedContext = { turn, tokens: session.contextTokens }
|
|
235
|
+
}
|
|
236
|
+
return cachedContext.tokens
|
|
237
|
+
}
|
|
238
|
+
|
|
169
239
|
// Bahasa UI: state.json (sesi bisa menimpa via /lang). Gagal baca = default.
|
|
170
240
|
const { setConfigLocale } = await import("../src/ui/i18n/locale.ts")
|
|
171
241
|
try {
|
|
@@ -184,9 +254,33 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
184
254
|
describeActivity,
|
|
185
255
|
matchTurn: matchTurnBySummary,
|
|
186
256
|
elapsedVisible,
|
|
257
|
+
verificationMark,
|
|
258
|
+
provenanceMark,
|
|
187
259
|
},
|
|
188
260
|
})
|
|
189
261
|
|
|
262
|
+
// [resume] Rebuild riwayat transkrip dari event presentasi durable. Hanya sesi
|
|
263
|
+
// yang BENAR-BENAR di-resume (turnCount > 0) yang punya histori — `--session
|
|
264
|
+
// <id>` reuse tanpa `--resume` tak boleh menampilkan riwayat lama. Sesi baru
|
|
265
|
+
// (tanpa event) = no-op. Tak double-render: replay memproses event LAMA,
|
|
266
|
+
// turn live baru menyusul dengan event baru.
|
|
267
|
+
try {
|
|
268
|
+
const turnCount = (session.state as { turnCount?: number } | undefined)?.turnCount ?? 0
|
|
269
|
+
if (turnCount > 0) {
|
|
270
|
+
const { loadPresentationEvents } = await import("../src/session/persistence.ts")
|
|
271
|
+
const { toPresentationEvent } = await import("./setup.ts")
|
|
272
|
+
const durable = await loadPresentationEvents(sessionId, cwd)
|
|
273
|
+
if (durable.length > 0) {
|
|
274
|
+
const events = durable
|
|
275
|
+
.map((e) => toPresentationEvent(e))
|
|
276
|
+
.filter((e): e is import("../src/ui/contract.ts").UiPresentationEvent => e !== null)
|
|
277
|
+
transcript.replayHistory(events)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
} catch {
|
|
281
|
+
// Replay best-effort: gagal membaca histori bukan alasan membatalkan TUI.
|
|
282
|
+
}
|
|
283
|
+
|
|
190
284
|
const commandCtx: CommandContext = {
|
|
191
285
|
cwd,
|
|
192
286
|
sessionId,
|
|
@@ -391,18 +485,18 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
391
485
|
* membanjiri transkrip. Detail penuh = `/help tombol` (delegasi).
|
|
392
486
|
*/
|
|
393
487
|
function helpConcise(): void {
|
|
394
|
-
//
|
|
395
|
-
//
|
|
396
|
-
//
|
|
397
|
-
//
|
|
398
|
-
const
|
|
399
|
-
const driver = [
|
|
400
|
-
...new Set([...DRIVER_COMMANDS, ...DRIVER_HELP_COMMANDS.map((b) => `/${b.name}`)]),
|
|
401
|
-
].join(" ")
|
|
488
|
+
// Grup kurasi (sengaja bukan dump flat dari registry): label + baris pendek
|
|
489
|
+
// per kategori supaya /help mudah dipindai. Daftar tetap 1:1 dengan command
|
|
490
|
+
// yang ditangani di `submit` (bila ada command baru, tambahkan ke grup yang
|
|
491
|
+
// tepat di sini). Tab completion tetap diturunkan dari registry (suggestions).
|
|
492
|
+
const group = (label: string, cmds: string): string => ` ${label.padEnd(9)}${cmds}`
|
|
402
493
|
transcript.pushInfo([
|
|
403
494
|
t("help.cHead"),
|
|
404
|
-
|
|
405
|
-
|
|
495
|
+
group(t("help.gSession"), "/status /sessions /history /clear /copy /init /exit"),
|
|
496
|
+
group(t("help.gModel"), "/model /provider /sync"),
|
|
497
|
+
group(t("help.gMode"), "/mode /work-mode /undo /redo /lang"),
|
|
498
|
+
group(t("help.gView"), "/compact /thinking /expand /minimize /fold"),
|
|
499
|
+
group(t("help.gTask"), "/scheduler"),
|
|
406
500
|
t("help.cKeys"),
|
|
407
501
|
t("help.cMore"),
|
|
408
502
|
])
|
|
@@ -427,6 +521,15 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
427
521
|
transcript.pushInfo([c.muted(t("tui.copyNone"))])
|
|
428
522
|
return
|
|
429
523
|
}
|
|
524
|
+
// Guard byte SEBELUM base64: 10 turn panjang bisa melewati batas OSC 52;
|
|
525
|
+
// memberi pesan spesifik lebih baik daripada gagal "butuh TTY" yang keliru.
|
|
526
|
+
const bytes = clipboardByteLength(txt)
|
|
527
|
+
if (bytes > MAX_CLIPBOARD_BYTES) {
|
|
528
|
+
transcript.pushInfo([
|
|
529
|
+
c.warning(t("tui.copyTooLarge", { n: bytes, max: MAX_CLIPBOARD_BYTES })),
|
|
530
|
+
])
|
|
531
|
+
return
|
|
532
|
+
}
|
|
430
533
|
if (writeClipboardOsc52(txt)) {
|
|
431
534
|
const key = turns.length > 1 ? "tui.copyOkMany" : "tui.copyOk"
|
|
432
535
|
transcript.pushInfo([c.muted(t(key, { n: txt.length, turns: turns.length }))])
|
|
@@ -497,6 +600,39 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
497
600
|
workModeControl.setWorkMode(next)
|
|
498
601
|
return
|
|
499
602
|
}
|
|
603
|
+
// /unrestric — full akses tanpa gerbang (jail + bash-guard + sandbox/allowlist).
|
|
604
|
+
// HIDDEN dari daftar "/" dan /help: operator yang tahu perintahnya yang bisa
|
|
605
|
+
// memanggil. Berlaku per-sesi, toggle. Gerbang keamanan = kepercayaan operator.
|
|
606
|
+
if (name === "unrestric" || name === "unrestrict") {
|
|
607
|
+
const norm = args.trim().toLowerCase()
|
|
608
|
+
const next = norm === "" ? mode !== "unrestricted" : norm === "on" || norm === "1"
|
|
609
|
+
if (next) {
|
|
610
|
+
if (mode !== "unrestricted") {
|
|
611
|
+
modeBeforeUnrestricted = mode
|
|
612
|
+
workModeBeforeUnrestricted = workModeControl?.getWorkMode() ?? "DISCUSS"
|
|
613
|
+
}
|
|
614
|
+
mode = "unrestricted"
|
|
615
|
+
permissions?.setMode("unrestricted")
|
|
616
|
+
// WorkMode EXECUTE (BUILD) agar ceiling DISCUSS/PLAN tak menahan tulis.
|
|
617
|
+
workModeControl?.setWorkMode("EXECUTE")
|
|
618
|
+
app.repaint()
|
|
619
|
+
transcript.pushInfo([c.warning(t("tui.unrestrictedOn"))])
|
|
620
|
+
return
|
|
621
|
+
}
|
|
622
|
+
mode = modeBeforeUnrestricted ?? "auto"
|
|
623
|
+
// modeBeforeUnrestricted adalah nilai sebelum /unrestric: auto/ask (via /mode)
|
|
624
|
+
// atau allow-all/allowlist (via flag start). Tidak pernah readonly/plan/
|
|
625
|
+
// unrestricted — cast jujur ke himpunan yang memang bisa dipegang `mode`.
|
|
626
|
+
permissions?.setMode(mode as "auto" | "ask" | "allow-all" | "allowlist")
|
|
627
|
+
// Pulihkan juga WorkMode semula (DISCUSS/PLAN) agar ceiling read-only
|
|
628
|
+
// kembali berlaku — tanpa ini toggle-off meninggalkan BUILD (tulis bebas).
|
|
629
|
+
workModeControl?.setWorkMode(workModeBeforeUnrestricted ?? "DISCUSS")
|
|
630
|
+
modeBeforeUnrestricted = null
|
|
631
|
+
workModeBeforeUnrestricted = null
|
|
632
|
+
app.repaint()
|
|
633
|
+
transcript.pushInfo([c.muted(t("tui.unrestrictedOff", { m: mode }))])
|
|
634
|
+
return
|
|
635
|
+
}
|
|
500
636
|
if (name === "lang") {
|
|
501
637
|
const { currentLocale, setSessionLocale } = await import("../src/ui/i18n/locale.ts")
|
|
502
638
|
if (!args) {
|
|
@@ -526,6 +662,12 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
526
662
|
ui.setReasoningVisible(next)
|
|
527
663
|
return
|
|
528
664
|
}
|
|
665
|
+
if (name === "fold") {
|
|
666
|
+
const next = args === "" ? undefined : args === "on" || args === "1"
|
|
667
|
+
const on = ui.setMinimizeActivity(next)
|
|
668
|
+
transcript.pushInfo([c.muted(t("tui.activityFold", { v: on ? "folded" : "expanded" }))])
|
|
669
|
+
return
|
|
670
|
+
}
|
|
529
671
|
if (name === "expand") {
|
|
530
672
|
const sections = args ? ctx.expandContent(args) : ctx.expandAllContent()
|
|
531
673
|
const views = args ? [] : ui.collapsedSectionsSnapshot()
|
|
@@ -636,24 +778,31 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
636
778
|
const host: TuiHost = {
|
|
637
779
|
bus: session.events as unknown as TuiHost["bus"],
|
|
638
780
|
getStatus: () => {
|
|
781
|
+
const busy = abort != null
|
|
639
782
|
const status = {
|
|
640
783
|
footer: {
|
|
641
784
|
// Normalisasi: sumbu persetujuan hanya AUTO/ASK. Profil warisan
|
|
642
|
-
// (allow-all/allowlist) tak lagi bocor sebagai label mode.
|
|
643
|
-
|
|
644
|
-
|
|
785
|
+
// (allow-all/allowlist) tak lagi bocor sebagai label mode. "unrestricted"
|
|
786
|
+
// adalah mode full-akses eksplisit (/unrestric) — tampil apa adanya.
|
|
787
|
+
mode: mode === "ask" ? "ask" : mode === "unrestricted" ? "unrestricted" : "auto",
|
|
788
|
+
// Gembok (allow-list) terang HANYA saat allow-list benar-benar menahan
|
|
789
|
+
// bash: restrictBash + mode AUTO. Di ASK bash diawasi prompt (bukan
|
|
790
|
+
// allow-list), dan di allow-all bash bebas — keduanya gembok redup.
|
|
791
|
+
strictBash: (permissions?.getRestrictBash?.() ?? false) && mode === "auto",
|
|
645
792
|
// P12 S2.2 Slice 5 - WorkMode LIVE (bukan snapshot boot): footer
|
|
646
793
|
// mencerminkan mode aktif saat frame digambar.
|
|
647
794
|
workMode: workModeControl?.getWorkMode() ?? "DISCUSS",
|
|
648
795
|
model: modelRef.current ?? cfg.providers[0]?.models[0] ?? t("tui.noModel"),
|
|
649
796
|
cwd: cwd ?? process.cwd(),
|
|
650
|
-
context: fmtCtx(
|
|
651
|
-
metrics: fmtUsageMetrics(ctx),
|
|
797
|
+
context: fmtCtx(getContextTokens()),
|
|
798
|
+
metrics: fmtUsageMetrics(ctx, getContextTokens()),
|
|
652
799
|
},
|
|
653
|
-
busy
|
|
800
|
+
busy,
|
|
654
801
|
}
|
|
802
|
+
// Fase 1 perf (butir 2): pinnedActivity hanya ditampilkan saat busy —
|
|
803
|
+
// jangan memindai seluruh activities pada tiap ketikan idle.
|
|
804
|
+
if (!busy) return { ...status, pinnedActivity: undefined }
|
|
655
805
|
const activities = getPresentationSnapshot().activities
|
|
656
|
-
|
|
657
806
|
return {
|
|
658
807
|
...status,
|
|
659
808
|
pinnedActivity:
|
|
@@ -705,6 +854,11 @@ export async function runTui(ctx: CliSession): Promise<void> {
|
|
|
705
854
|
}
|
|
706
855
|
} finally {
|
|
707
856
|
setApprovalSink(null)
|
|
857
|
+
for (const unsub of liveContextUnsubs.splice(0)) {
|
|
858
|
+
try {
|
|
859
|
+
unsub()
|
|
860
|
+
} catch {}
|
|
861
|
+
}
|
|
708
862
|
transcript.dispose()
|
|
709
863
|
await close()
|
|
710
864
|
}
|
|
@@ -12,7 +12,7 @@ punya owner sendiri; yang disatukan di sini hanya *hubungannya*.
|
|
|
12
12
|
|
|
13
13
|
| Konsep | Ukuran | Owner | Sumber kebenaran | Dipakai |
|
|
14
14
|
|---|---|---|---|---|
|
|
15
|
-
| Logical context | token ESTIMASI (
|
|
15
|
+
| Logical context | token ESTIMASI (densitas: kode/JSON ~2.4 cpt, CJK ~1, fallback usage anchor + tokenizer exact on-demand) | Kernel loop + `Session.contextTokens` | `estimateSessionContext` (`vendor tokens.ts`) — messages+system+tools | pressure evaluation, footer, `/status` |
|
|
16
16
|
| Serialized context | chars wire (JSON/base64 +overhead) | Adapter provider | `buildRequest` per adapter | dikirim, tidak diukur tersendiri |
|
|
17
17
|
| Provider usage | token yang dilaporkan provider | `createUsageCollector` | event `provider:extension{kind:"usage"}` — **boleh hilang** | akumulasi turn/session, cost |
|
|
18
18
|
| Economic usage | USD estimated dari harga tabel | `costFor`/`findPrice` | harga × usage; `undefined` = unknown | `--budget`, `/status` |
|
|
@@ -59,9 +59,12 @@ diselaraskan 0.9.27 saat seam dihilirkan; sebelumnya `budget:<…>`):
|
|
|
59
59
|
- *What is eligible?* — hanya messages; system prompt di-cap di hulu
|
|
60
60
|
(`SYSTEM_PROMPT_MAX_CHARS` 8000), tool schema TIDAK pernah terkompaksi.
|
|
61
61
|
- *What must be preserved?* — pasangan assistant(toolCalls)→tool results tidak
|
|
62
|
-
pernah dipecah (`compact.ts`);
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
pernah dipecah (folder mekanis kernel `vendor/minicore/src/core/compact.ts`);
|
|
63
|
+
summary LLM terpin verbatim (anti-drift).
|
|
64
|
+
- *What may be removed?* — teks di luar head per peran: jalur host
|
|
65
|
+
(`src/policy/compaction.ts`) mempertahankan hasil tool pembawa fakta ~800 char
|
|
66
|
+
dan prosa ~250/180 char (TIDAK lagi `<result omitted>` seperti folder mekanis
|
|
67
|
+
kernel), plus reasoning dan tail lama.
|
|
65
68
|
- *What if compaction fails?* — LLM gagal/timeout (10s) → fallback sync
|
|
66
69
|
mekanis; async compactor tak pernah bisa crash loop.
|
|
67
70
|
- *Can it retry?* — budget: tidak (flag); recovery: sekali per turn (flag).
|
|
@@ -140,6 +143,5 @@ Operator harus bisa membedakan (tanpa ambigu):
|
|
|
140
143
|
- `test/control-plane.test.ts` — compaction budget≠recovery (F-10), anti-loop,
|
|
141
144
|
contextTokens getter + konsistensi estimator, termination reason.
|
|
142
145
|
- `test/cli-help-language.test.ts` — /status membedakan Context/Usage/Budget.
|
|
143
|
-
- `test/repl-linear.test.ts` — footer membaca kernel contextTokens.
|
|
144
146
|
- `test/usage-session.test.ts` / `budget-unknown.test.ts` — budget contract.
|
|
145
147
|
- `test/pack-integrity.test.ts` — vendor hash + VENDOR.md sinkron.
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
**Status:** Phase 2 core state/replay contract landed; renderer/wire protocol masih target
|
|
4
4
|
**Tanggal:** 2026-09-25
|
|
5
|
-
**Kontrak aktif:**
|
|
5
|
+
**Kontrak aktif:** definisi tipe + registry durability di `src/presentation/events.ts`;
|
|
6
|
+
producer event di `src/presentation/adapter.ts` (events.ts tidak mem-`publish`).
|
|
6
7
|
|
|
7
8
|
## Status implementasi
|
|
8
9
|
|
|
@@ -133,8 +134,8 @@ mengarang final message.
|
|
|
133
134
|
| `diagnostic.raised` | adapter/policy | diagnostic actionable | ya |
|
|
134
135
|
|
|
135
136
|
Tool `completed` harus membawa `summary`, `durationMs`, `expandRef`, dan bila ada
|
|
136
|
-
`receipt`. Tool `failed` harus membawa `cause
|
|
137
|
-
Tool `denied` harus membawa `reason`; `denied` tidak boleh berubah menjadi generic
|
|
137
|
+
`receipt`. Tool `failed` harus membawa `cause` dan `message` (`hint` dan `expandRef`
|
|
138
|
+
opsional). Tool `denied` harus membawa `reason`; `denied` tidak boleh berubah menjadi generic
|
|
138
139
|
`failed` hanya karena satu renderer tidak tahu policy.
|
|
139
140
|
|
|
140
141
|
### Error, recovery, dan lifecycle
|
|
@@ -59,6 +59,14 @@ interface RendererInput {
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
> **Catatan sinkronisasi:** blok tipe di atas adalah **sketsa target**. Implementasi
|
|
63
|
+
> aktif memakai `UiPresentationSnapshot`/`PresentationPolicy` (`src/ui/contract.ts`)
|
|
64
|
+
> dan `ProjectionNode` berbentuk `{ kind, id, seq, data }` dengan kind
|
|
65
|
+
> `message|turn|tool|approval|reasoning|system|plan|finding|result|diagnostic`
|
|
66
|
+
> (`src/presentation/projection.ts`). Tipe `PresentationSnapshot`, `ContentResolver`,
|
|
67
|
+
> `RendererClock`, `SourceRef`, `EvidenceRef`, dan `SemanticError` belum ada sebagai
|
|
68
|
+
> tipe runtime.
|
|
69
|
+
|
|
62
70
|
`PresentationSnapshot` harus read-only. `ContentResolver` mengembalikan `ContentEntry`
|
|
63
71
|
dengan marker retention; tidak mengembalikan seluruh raw database tanpa batas.
|
|
64
72
|
`RendererClock` adalah satu-satunya sumber waktu visual; `Date.now()` tidak boleh
|
|
@@ -132,7 +140,8 @@ popup tidak boleh membuat listener stdin kedua.
|
|
|
132
140
|
- Assistant stream: live buffer yang di-cap; final node dipisah dari stream.
|
|
133
141
|
- Whitespace jawaban dirapikan hanya pada layer tampilan: baris kosong tepi dibuang,
|
|
134
142
|
jeda berulang di luar code fence dirapatkan, isi fenced code tetap literal.
|
|
135
|
-
- Activity: started → running → terminal, dengan glyph
|
|
143
|
+
- Activity: started → running → terminal, dengan status word (glyph status dihapus;
|
|
144
|
+
bukan lagi penanda `✓`/`✗` — lihat `OUTPUT_UX_RULES.md` §3).
|
|
136
145
|
- Tool child: default dikelompokkan ke parent `delegate_task`; child detail tersedia
|
|
137
146
|
pada verbose/debug.
|
|
138
147
|
- Context compaction: system entry, tidak menghapus history.
|
|
@@ -263,9 +272,12 @@ untuk regressions visual dan protocol.
|
|
|
263
272
|
3. TUI/linear dapat membandingkan canonical projection dengan legacy output pada test.
|
|
264
273
|
4. Exec/ACP memakai canonical projection lebih dulu karena machine parity paling mudah
|
|
265
274
|
diukur.
|
|
266
|
-
5.
|
|
267
|
-
|
|
268
|
-
|
|
275
|
+
5. Raw EventBus tetap dipakai untuk streaming content, trace, dan sebagian
|
|
276
|
+
lifecycle turn/execution yang dibaca TUI (`src/ui/tui/transcript.ts`,
|
|
277
|
+
`src/ui/tui/app.ts`); keputusan user-facing tetap lewat semantic
|
|
278
|
+
projection/policy. Klaim lama "raw semantic subscriptions dihapus dari TUI"
|
|
279
|
+
tidak akurat: TUI masih melanggan `turn:*`/`execution:*`/`provider:extension`
|
|
280
|
+
untuk transcript dan status.
|
|
269
281
|
|
|
270
282
|
## 13. Definition of done renderer
|
|
271
283
|
|