minicode-ai 0.27.0 → 0.30.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 (145) hide show
  1. package/README.md +1 -1
  2. package/cli/args.ts +184 -57
  3. package/cli/bootstrap/presentation-bridge.ts +383 -0
  4. package/cli/commands/acp.ts +45 -29
  5. package/cli/commands/auth.ts +17 -17
  6. package/cli/commands/config.ts +65 -66
  7. package/cli/commands/daemon.ts +44 -16
  8. package/cli/commands/doctor.ts +18 -15
  9. package/cli/commands/exec.ts +41 -89
  10. package/cli/commands/mcp.ts +25 -8
  11. package/cli/commands/memory.ts +16 -24
  12. package/cli/commands/openwork.ts +6 -2
  13. package/cli/commands/pricing.ts +14 -12
  14. package/cli/commands/providers.ts +36 -57
  15. package/cli/commands/sessions.ts +24 -18
  16. package/cli/commands/skills.ts +33 -18
  17. package/cli/commands/stats.ts +15 -30
  18. package/cli/commands.ts +73 -44
  19. package/cli/context-command-run.ts +30 -18
  20. package/cli/index.ts +51 -100
  21. package/cli/model-manager.ts +7 -2
  22. package/cli/provider-manager.ts +33 -18
  23. package/cli/router.ts +41 -12
  24. package/cli/setup.ts +241 -485
  25. package/cli/tui.ts +303 -100
  26. package/docs/TERMINAL_CONTRACT.md +258 -73
  27. package/docs/UI_RENDER_PIPELINE.md +9 -1
  28. package/docs/agents.md +2 -2
  29. package/docs/architecture.md +17 -32
  30. package/docs/choosing-mode.md +7 -9
  31. package/docs/cli.md +3 -5
  32. package/docs/environment.md +1 -2
  33. package/docs/policy-sandbox.md +3 -3
  34. package/docs/repl.md +2 -2
  35. package/docs/tools.md +1 -1
  36. package/package.json +1 -1
  37. package/src/app/mentions.ts +60 -13
  38. package/src/app/rag-layer.ts +17 -20
  39. package/src/app/session.ts +144 -68
  40. package/src/app/tool-layer.ts +38 -16
  41. package/src/config.ts +64 -104
  42. package/src/constants.ts +4 -6
  43. package/src/daemon/capability.ts +8 -1
  44. package/src/daemon/control.ts +3 -2
  45. package/src/daemon/server.ts +57 -0
  46. package/src/hooks/run.ts +73 -41
  47. package/src/lib/atomic-write.ts +31 -59
  48. package/src/lib/db-path.ts +47 -0
  49. package/src/lib/process-tree.ts +62 -0
  50. package/src/lib/public-http.ts +88 -23
  51. package/src/lib/trusted-exec.ts +48 -1
  52. package/src/lsp/client.ts +62 -17
  53. package/src/mcp/client.ts +85 -38
  54. package/src/mcp/http-transport.ts +28 -16
  55. package/src/mcp/transport.ts +42 -6
  56. package/src/memory/files.ts +164 -134
  57. package/src/memory/vector.ts +371 -420
  58. package/src/policy/approval-binding.ts +122 -45
  59. package/src/policy/bash-guard.ts +18 -7
  60. package/src/policy/compaction.ts +51 -18
  61. package/src/policy/context-window.ts +31 -8
  62. package/src/policy/context.ts +62 -36
  63. package/src/policy/executor.ts +17 -7
  64. package/src/policy/jail.ts +6 -8
  65. package/src/policy/microcompact.ts +4 -3
  66. package/src/policy/no-progress.ts +103 -22
  67. package/src/policy/permission.ts +36 -12
  68. package/src/policy/tool-contract.ts +74 -416
  69. package/src/policy/usage.ts +24 -2
  70. package/src/policy/verifier.ts +50 -2
  71. package/src/policy/work-mode.ts +28 -54
  72. package/src/presentation/adapter.ts +24 -16
  73. package/src/providers/anthropic.ts +16 -5
  74. package/src/providers/provision.ts +6 -56
  75. package/src/providers/responses.ts +38 -7
  76. package/src/providers/sse-bounds.ts +6 -4
  77. package/src/runtime/execution-journal.ts +4 -29
  78. package/src/sandbox/docker.ts +58 -34
  79. package/src/sandbox/mask.ts +157 -0
  80. package/src/sandbox/os.ts +107 -73
  81. package/src/session/authority.ts +29 -10
  82. package/src/session/context-projection.ts +6 -5
  83. package/src/session/db/runs.ts +397 -0
  84. package/src/session/db/schema.ts +358 -0
  85. package/src/session/open-work.ts +26 -3
  86. package/src/session/persistence.ts +74 -998
  87. package/src/session/verification.ts +170 -20
  88. package/src/skills/loader.ts +31 -16
  89. package/src/task/db/schema.ts +325 -0
  90. package/src/task/db/types.ts +269 -0
  91. package/src/task/production-scheduler.ts +13 -1
  92. package/src/task/store.ts +92 -1021
  93. package/src/telemetry/trace.ts +27 -0
  94. package/src/tools/ask_user.ts +1 -13
  95. package/src/tools/bash.ts +27 -92
  96. package/src/tools/code_run.ts +1 -1
  97. package/src/tools/context.ts +133 -0
  98. package/src/tools/delete_file.ts +3 -2
  99. package/src/tools/edit.ts +37 -72
  100. package/src/tools/git.ts +86 -9
  101. package/src/tools/glob.ts +26 -51
  102. package/src/tools/grep.ts +67 -57
  103. package/src/tools/hashline.ts +4 -0
  104. package/src/tools/lsp.ts +11 -8
  105. package/src/tools/mcp_call.ts +9 -6
  106. package/src/tools/memory.ts +56 -33
  107. package/src/tools/move_file.ts +36 -10
  108. package/src/tools/patch.ts +13 -21
  109. package/src/tools/read_file.ts +18 -25
  110. package/src/tools/read_image.ts +35 -33
  111. package/src/tools/submit_result.ts +29 -8
  112. package/src/tools/task.ts +74 -17
  113. package/src/tools/todo.ts +181 -74
  114. package/src/tools/web_fetch.ts +42 -2
  115. package/src/tools/web_search.ts +47 -8
  116. package/src/ui/approval/prompt.ts +206 -47
  117. package/src/ui/assistant/turn-status.ts +14 -5
  118. package/src/ui/footer.ts +4 -4
  119. package/src/ui/i18n/en.ts +47 -23
  120. package/src/ui/i18n/id.ts +76 -51
  121. package/src/ui/input/input.ts +4 -3
  122. package/src/ui/input/prompt-engine.ts +35 -5
  123. package/src/ui/render/activity-panel.ts +4 -2
  124. package/src/ui/render/hint.ts +7 -4
  125. package/src/ui/render/list.ts +32 -0
  126. package/src/ui/render/markdown.ts +6 -3
  127. package/src/ui/render/notice.ts +19 -0
  128. package/src/ui/render/table-grid.ts +7 -8
  129. package/src/ui/render/theme.ts +113 -39
  130. package/src/ui/runtime/screen.ts +74 -10
  131. package/src/ui/runtime/spinner.ts +19 -6
  132. package/src/ui/screens/dialog.ts +19 -1
  133. package/src/ui/screens/form.ts +80 -35
  134. package/src/ui/screens/model-manager.ts +82 -61
  135. package/src/ui/screens/output-window.ts +263 -0
  136. package/src/ui/screens/picker.ts +94 -81
  137. package/src/ui/screens/provider-manager.ts +100 -69
  138. package/src/ui/screens/wizard.ts +117 -28
  139. package/src/ui/tui/app.ts +196 -33
  140. package/src/ui/tui/transcript.ts +158 -25
  141. package/vendor/minicore/src/core/executor.ts +2 -0
  142. package/vendor/minicore/src/core/loop.ts +17 -6
  143. package/vendor/minicore/src/core/session.ts +3 -0
  144. package/vendor/minicore/src/core/tool.ts +1 -0
  145. package/vendor/minicore/src/providers/openai-compat.ts +35 -19
@@ -0,0 +1,269 @@
1
+ import { scrubSecrets } from "../../policy/scrub.ts"
2
+ import type { CompletionEvidence } from "../../tools/todo.ts"
3
+ import type {
4
+ Task,
5
+ TaskAcceptance,
6
+ TaskEvidence,
7
+ TaskProvenance,
8
+ TaskStatus,
9
+ TaskVerification,
10
+ } from "../model.ts"
11
+
12
+ export const TASK_DB_FILENAME = "tasks.db"
13
+ export const MAX_DEPENDS_ON = 32
14
+ export const MAX_EVIDENCE = 32
15
+ export const TASK_DATA_VERSION = 1
16
+
17
+ export type TaskTransitionKind = "created" | "updated" | "claimed"
18
+
19
+ export interface TaskTransition {
20
+ kind: TaskTransitionKind
21
+ task: Task
22
+ previousStatus: TaskStatus | null
23
+ }
24
+
25
+ let taskTransitionSink: ((transition: TaskTransition) => void) | null = null
26
+
27
+ export function setTaskTransitionSink(sink: ((transition: TaskTransition) => void) | null): void {
28
+ taskTransitionSink = sink
29
+ }
30
+
31
+ /** Emit SETELAH commit; kegagalan observer tak boleh menggagalkan transisi. */
32
+ export function emitTaskTransition(
33
+ kind: TaskTransitionKind,
34
+ task: Task,
35
+ previousStatus: TaskStatus | null,
36
+ ): void {
37
+ try {
38
+ taskTransitionSink?.({ kind, task, previousStatus })
39
+ } catch {}
40
+ }
41
+
42
+ export interface TaskRow {
43
+ session_id: string
44
+ task_id: string
45
+ title: string
46
+ status: string
47
+ task_order: number
48
+ parent_id: string | null
49
+ depends_on_json: string | null
50
+ blocked_reason: string | null
51
+ verification_json: string | null
52
+ evidence_json: string | null
53
+ acceptance_json: string | null
54
+ provenance_json: string | null
55
+ created_at: string
56
+ updated_at: string
57
+ revision: number
58
+ exec_generation: number
59
+ attempt_generation: number | null
60
+ execution_owner: string | null
61
+ }
62
+
63
+ export interface ExecutionLineage {
64
+ readonly execGeneration: number
65
+ readonly attemptGeneration: number | null
66
+ }
67
+
68
+ export type ExecutionOwner = "scheduler"
69
+
70
+ export interface ExecutionOwnership {
71
+ readonly executionOwner: ExecutionOwner | null
72
+ }
73
+
74
+ export type AttemptRecordOutcome = "RECORDED" | "TASK_GONE" | "SUPERSEDED" | "SESSION_SUPERSEDED"
75
+
76
+ export type LineageReconcileOutcome =
77
+ | "RECONCILED"
78
+ | "NOT_STRANDED"
79
+ | "REJECTED_STALE"
80
+ | "NOT_FOUND"
81
+ | "REFUSED_NO_OWNERSHIP"
82
+
83
+ export const ADOPTABLE_STATUSES: readonly TaskStatus[] = [
84
+ "PENDING",
85
+ "IN_PROGRESS",
86
+ "VERIFYING",
87
+ "BLOCKED",
88
+ "FAILED",
89
+ "RETRYING",
90
+ ]
91
+
92
+ export const ADOPTABLE_STATUS_SET: ReadonlySet<TaskStatus> = new Set(ADOPTABLE_STATUSES)
93
+ export const CLAIMABLE_STATUSES: readonly TaskStatus[] = ["PENDING"]
94
+
95
+ export function sqlList(statuses: readonly TaskStatus[]): string {
96
+ return statuses.map((s) => `'${s}'`).join(", ")
97
+ }
98
+
99
+ export interface TaskTransfer {
100
+ readonly transferId: string
101
+ readonly taskId: string
102
+ readonly fromSessionId: string
103
+ readonly fromIncarnation: number
104
+ readonly toSessionId: string
105
+ readonly toIncarnation: number
106
+ readonly expectedRevision: number
107
+ readonly newRevision: number
108
+ readonly status: string
109
+ readonly execGeneration: number
110
+ readonly attemptGeneration: number | null
111
+ readonly executionOwner: ExecutionOwner | null
112
+ readonly transferredAt: string
113
+ }
114
+
115
+ export interface TaskTransferRequest {
116
+ readonly taskId: string
117
+ readonly fromSessionId: string
118
+ readonly fromIncarnation: number
119
+ readonly toSessionId: string
120
+ readonly toIncarnation: number
121
+ readonly expectedRevision: number
122
+ readonly sourceOwnerToken: string
123
+ readonly targetOwnerToken: string
124
+ readonly now?: number
125
+ }
126
+
127
+ export type TaskTransferOutcome =
128
+ | "TRANSFERRED"
129
+ | "NOT_FOUND"
130
+ | "REFUSED_SELF_TRANSFER"
131
+ | "REJECTED_STALE_SOURCE_INCARNATION"
132
+ | "REJECTED_STALE_TARGET_INCARNATION"
133
+ | "REJECTED_STALE_REVISION"
134
+ | "REFUSED_NO_SOURCE_AUTHORITY"
135
+ | "REFUSED_NO_TARGET_AUTHORITY"
136
+ | "REFUSED_STATUS"
137
+ | "REFUSED_TARGET_ID_CONFLICT"
138
+ | "REFUSED_UNRESOLVED_RELATION"
139
+ | "REFUSED_CORRUPT_STATE"
140
+
141
+ export interface TaskTransferResult {
142
+ readonly outcome: TaskTransferOutcome
143
+ readonly task: Task | null
144
+ readonly transfer: TaskTransfer | null
145
+ readonly detail: string
146
+ readonly unresolvedRelations: readonly string[]
147
+ }
148
+
149
+ export interface UnfinishedWorkItem {
150
+ readonly sessionId: string
151
+ readonly sessionIncarnation: number
152
+ readonly task: Task
153
+ readonly execGeneration: number
154
+ readonly attemptGeneration: number | null
155
+ readonly executionOwner: ExecutionOwner | null
156
+ readonly transferredFromSessionId: string | null
157
+ readonly transferredAt: string | null
158
+ }
159
+
160
+ export interface TaskMerge {
161
+ readonly mergeId: string
162
+ readonly sessionId: string
163
+ readonly survivorId: string
164
+ readonly duplicateId: string
165
+ readonly evidence: string
166
+ readonly survivorStatus: string
167
+ readonly duplicateStatus: string
168
+ readonly duplicateRevision: number
169
+ readonly mergedAt: string
170
+ }
171
+
172
+ export interface TaskDuplicateRequest {
173
+ readonly sessionId: string
174
+ readonly survivorId: string
175
+ readonly duplicateId: string
176
+ readonly evidence: string
177
+ readonly expectedRevision?: number
178
+ }
179
+
180
+ export type TaskDuplicateOutcome =
181
+ | "DECLARED"
182
+ | "NOT_FOUND"
183
+ | "REFUSED_SELF_MERGE"
184
+ | "REFUSED_NO_EVIDENCE"
185
+ | "REFUSED_TERMINAL_DUPLICATE"
186
+ | "REJECTED_STALE_REVISION"
187
+
188
+ export interface TaskDuplicateResult {
189
+ readonly outcome: TaskDuplicateOutcome
190
+ readonly duplicate: Task | null
191
+ readonly survivor: Task | null
192
+ readonly merge: TaskMerge | null
193
+ readonly detail: string
194
+ }
195
+
196
+ export interface NewTaskInput {
197
+ title: string
198
+ status: TaskStatus
199
+ order: number
200
+ parentId?: string | null
201
+ dependsOn?: string[]
202
+ blockedReason?: string | null
203
+ verification?: TaskVerification | null
204
+ evidence?: TaskEvidence[]
205
+ acceptance?: TaskAcceptance | null
206
+ provenance: TaskProvenance
207
+ }
208
+
209
+ export interface TaskPatch {
210
+ title?: string
211
+ status?: TaskStatus
212
+ order?: number
213
+ parentId?: string | null
214
+ dependsOn?: string[]
215
+ blockedReason?: string | null
216
+ verification?: TaskVerification | null
217
+ evidence?: TaskEvidence[]
218
+ acceptance?: TaskAcceptance | null
219
+ }
220
+
221
+ export interface UpsertOptions {
222
+ evidence?: CompletionEvidence
223
+ expectedRevision?: number
224
+ }
225
+
226
+ export interface PatchOptions extends UpsertOptions {
227
+ allowReopen?: boolean
228
+ authorityToken?: string
229
+ }
230
+
231
+ export interface VerificationGateOutcome {
232
+ readonly ok: boolean
233
+ readonly verdict: "passed" | "failed" | "stale"
234
+ readonly exitCode?: number | null
235
+ readonly command?: string
236
+ readonly summary?: string
237
+ readonly integrityOk?: boolean
238
+ readonly timestamp?: string
239
+ }
240
+
241
+ export type TaskAuthorityMode = "LEGACY" | "SCHEDULER"
242
+
243
+ export interface TaskStoreOptions {
244
+ authority?: TaskAuthorityMode
245
+ }
246
+
247
+ export function nowIso(): string {
248
+ return new Date().toISOString()
249
+ }
250
+
251
+ export function buildVerificationTaskEvidence(outcome: VerificationGateOutcome): TaskEvidence {
252
+ const at = outcome.timestamp ?? nowIso()
253
+ const payload = {
254
+ verdict: outcome.verdict,
255
+ ok: outcome.ok,
256
+ exitCode: outcome.exitCode ?? (outcome.ok ? 0 : 1),
257
+ ...(outcome.command ? { command: scrubSecrets(outcome.command).slice(0, 200) } : {}),
258
+ summary: scrubSecrets(
259
+ outcome.summary ?? (outcome.ok ? "verification passed" : "verification failed"),
260
+ ).slice(0, 500),
261
+ ...(typeof outcome.integrityOk === "boolean" ? { integrityOk: outcome.integrityOk } : {}),
262
+ timestamp: at,
263
+ }
264
+ return {
265
+ kind: "verify",
266
+ detail: JSON.stringify(payload),
267
+ at,
268
+ }
269
+ }
@@ -217,6 +217,18 @@ export async function createProductionScheduler(
217
217
  // here would create a THIRD copy of one policy, furthest from the tests that
218
218
  // justify it and therefore most likely to drift.
219
219
 
220
+ const onEvent = (e: SchedulerEvent): void => {
221
+ try {
222
+ d.onSchedulerEvent?.(e)
223
+ } finally {
224
+ if (e.kind === "task:claimed" || e.kind === "task:recovered") {
225
+ void import("../tools/todo.ts")
226
+ .then(({ syncTodoViewsFromTaskStore }) => syncTodoViewsFromTaskStore(d.sessionId, d.cwd))
227
+ .catch(() => {})
228
+ }
229
+ }
230
+ }
231
+
220
232
  const scheduler = new Scheduler(d.sessionId, {
221
233
  store: d.store,
222
234
  runTurn: buildAutonomousRunTurn(d.bindingFor, d.adapter),
@@ -225,7 +237,7 @@ export async function createProductionScheduler(
225
237
  // P2.2: teruskan token komposisi (bila ada) — satu penulis per boot.
226
238
  ...(d.authorityToken ? { authorityToken: d.authorityToken } : {}),
227
239
  ...(d.continuity ? { continuity: d.continuity } : {}),
228
- ...(d.onSchedulerEvent ? { onEvent: d.onSchedulerEvent } : {}),
240
+ onEvent,
229
241
  })
230
242
 
231
243
  const trigger = new TriggerCoordinator({