minicode-ai 0.9.29 → 0.11.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/AGENTS.md +45 -0
- package/CHANGELOG.md +79 -1
- package/PLAN.md +491 -0
- package/README.md +2 -2
- package/cli/args.ts +1 -0
- package/cli/commands/acp.ts +485 -0
- package/cli/commands/auth.ts +7 -4
- package/cli/commands/config.ts +41 -27
- package/cli/commands/exec.ts +33 -12
- package/cli/commands/mcp.ts +3 -2
- package/cli/commands/memory.ts +1 -1
- package/cli/commands/pricing.ts +6 -4
- package/cli/commands/providers.ts +18 -8
- package/cli/commands/sessions.ts +11 -4
- package/cli/commands/skills.ts +3 -3
- package/cli/commands/stats.ts +3 -1
- package/cli/commands.ts +225 -103
- package/cli/index.ts +89 -62
- package/cli/model-manager.ts +8 -8
- package/cli/provider-manager.ts +13 -13
- package/cli/router.ts +7 -0
- package/cli/setup.ts +349 -4
- package/cli/tui.ts +542 -0
- package/cli/wizard.ts +2 -1
- package/docs/ARCHITECTURE.html +62 -36
- package/docs/CONTROL-PLANE-MAP.md +139 -0
- package/docs/HARNESS.md +150 -0
- package/docs/PLAN_UIUX_V6.md +209 -0
- package/docs/README.md +1 -1
- package/docs/SUMMARY.md +52 -0
- package/docs/TERMINAL_CONTRACT.md +367 -0
- package/docs/UI_RENDER_PIPELINE.md +165 -0
- package/docs/USAGE.md +11 -0
- package/docs/agents.md +31 -0
- package/docs/architecture.md +3 -3
- package/docs/choosing-mode.md +34 -0
- package/docs/cli.md +130 -0
- package/docs/concepts.md +53 -0
- package/docs/config-providers.md +87 -0
- package/docs/config.md +63 -0
- package/docs/contributing.md +79 -0
- package/docs/environment.md +95 -0
- package/docs/exec.md +73 -0
- package/docs/getting-started.md +102 -0
- package/docs/glossary.md +37 -0
- package/docs/mcp-lsp.md +54 -0
- package/docs/memory-sessions.md +63 -0
- package/docs/policy-sandbox.md +72 -0
- package/docs/pricing-budget.md +49 -0
- package/docs/quickstart.md +60 -0
- package/docs/repl.md +67 -0
- package/docs/security-model.md +95 -0
- package/docs/security.md +91 -0
- package/docs/skills.md +48 -0
- package/docs/terminal.md +79 -0
- package/docs/tools.md +123 -0
- package/docs/troubleshooting.md +40 -0
- package/docs/verify-benchmark.md +58 -0
- package/package.json +8 -5
- package/src/app/provider-layer.ts +12 -4
- package/src/app/rag-layer.ts +7 -2
- package/src/app/session.ts +6 -0
- package/src/app/tool-layer.ts +2 -1
- package/src/config.ts +30 -1
- package/src/constants.ts +35 -0
- package/src/lib/net.ts +6 -1
- package/src/lsp/client.ts +41 -8
- package/src/mcp/http-transport.ts +52 -15
- package/src/mcp/transport.ts +32 -1
- package/src/memory/files.ts +6 -5
- package/src/policy/allowlist.ts +1 -1
- package/src/policy/bash-guard.ts +213 -17
- package/src/policy/compaction.ts +57 -3
- package/src/policy/context.ts +4 -0
- package/src/policy/jail.ts +49 -4
- package/src/policy/permission.ts +152 -12
- package/src/policy/pricing.ts +12 -9
- package/src/policy/update-check.ts +4 -1
- package/src/presentation/adapter.ts +721 -0
- package/src/presentation/events.ts +324 -0
- package/src/presentation/label.ts +140 -0
- package/src/presentation/model.ts +172 -0
- package/src/presentation/reducer.ts +486 -0
- package/src/presentation/store.ts +256 -0
- package/src/providers/anthropic.ts +22 -4
- package/src/providers/detect.ts +2 -1
- package/src/providers/router.ts +13 -0
- package/src/repo/repomap.ts +2 -29
- package/src/session/checkpoint.ts +27 -9
- package/src/session/journal.ts +27 -5
- package/src/skills/loader.ts +88 -5
- package/src/telemetry/trace.ts +36 -15
- package/src/tools/ask_user.ts +73 -4
- package/src/tools/bash.ts +23 -17
- package/src/tools/glob.ts +10 -11
- package/src/tools/lsp.ts +3 -56
- package/src/tools/memory.ts +13 -12
- package/src/tools/task.ts +7 -1
- package/src/tools/web_fetch.ts +11 -2
- package/src/tools/web_search.ts +4 -1
- package/src/ui/approval/prompt.ts +96 -22
- package/src/ui/assistant/simple.ts +188 -44
- package/src/ui/assistant/turn-status.ts +32 -10
- package/src/ui/contract.ts +119 -0
- package/src/ui/footer.ts +35 -14
- package/src/ui/i18n/en.ts +253 -0
- package/src/ui/i18n/id.ts +255 -0
- package/src/ui/i18n/locale.ts +68 -0
- package/src/ui/input/input.ts +189 -81
- package/src/ui/input/prompt-engine.ts +139 -4
- package/src/ui/render/collapse.ts +20 -13
- package/src/ui/render/diff.ts +7 -2
- package/src/ui/render/errors.ts +75 -50
- package/src/ui/render/format.ts +26 -8
- package/src/ui/render/highlight.ts +12 -5
- package/src/ui/render/markdown.ts +5 -1
- package/src/ui/render/sanitize.ts +29 -2
- package/src/ui/render/table.ts +12 -6
- package/src/ui/render/theme.ts +23 -4
- package/src/ui/render/width.ts +104 -17
- package/src/ui/runtime/motion.ts +16 -0
- package/src/ui/runtime/screen.ts +242 -0
- package/src/ui/runtime/spinner.ts +50 -4
- package/src/ui/runtime/statusline.ts +50 -1
- package/src/ui/screens/dialog.ts +174 -0
- package/src/ui/screens/form.ts +486 -0
- package/src/ui/screens/model-manager.ts +289 -134
- package/src/ui/screens/picker.ts +264 -109
- package/src/ui/screens/provider-manager.ts +385 -172
- package/src/ui/screens/wizard.ts +165 -102
- package/src/ui/tui/app.ts +951 -0
- package/src/ui/tui/transcript.ts +475 -0
- package/vendor/minicore/LICENSE +21 -0
- package/vendor/minicore/VENDOR.md +6 -3
- package/vendor/minicore/package.json +6 -3
- package/vendor/minicore/src/core/loop.ts +12 -2
- package/vendor/minicore/src/core/snapshot.ts +4 -0
- package/vendor/minicore/src/providers/openai-compat.ts +76 -25
- package/cli/repl.ts +0 -740
- package/src/ui/runtime/chrome.ts +0 -369
- package/src/ui/screens/overlay.ts +0 -61
|
@@ -12,20 +12,19 @@ import type { Content, Message } from "../core/types.ts";
|
|
|
12
12
|
// `args` — the executor rejects unknown properties (all schemas are
|
|
13
13
|
// additionalProperties:false), so smuggling it there fails validation.
|
|
14
14
|
// Side-map keeps args clean; consume-once + cap so long sessions can't leak.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return v
|
|
15
|
+
// The map lives per provider INSTANCE (inside createOpenAICompatProvider):
|
|
16
|
+
// a module-level map would be shared across concurrent sessions, and
|
|
17
|
+
// index-based fallback ids (`call_0`) could then echo one session's metadata
|
|
18
|
+
// into another session's history replay.
|
|
19
|
+
|
|
20
|
+
/** Sniff a well-known image format from magic bytes; undefined when unknown. */
|
|
21
|
+
function sniffImageMime(bytes: Uint8Array): string | undefined {
|
|
22
|
+
if (bytes.length >= 4 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) return "image/png";
|
|
23
|
+
if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) return "image/jpeg";
|
|
24
|
+
if (bytes.length >= 4 && bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46 && bytes[3] === 0x38) return "image/gif";
|
|
25
|
+
if (bytes.length >= 12 && bytes[0] === 0x52 && bytes[1] === 0x49 && bytes[2] === 0x46 && bytes[3] === 0x46 && bytes[8] === 0x57 && bytes[9] === 0x45 && bytes[10] === 0x42 && bytes[11] === 0x50) return "image/webp";
|
|
26
|
+
if (bytes.length >= 2 && bytes[0] === 0x42 && bytes[1] === 0x4d) return "image/bmp";
|
|
27
|
+
return undefined;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
/** Configuration for an OpenAI-compatible chat completions endpoint. */
|
|
@@ -68,6 +67,23 @@ export function createOpenAICompatProvider(config: OpenAICompatConfig): ModelPro
|
|
|
68
67
|
...config.headers,
|
|
69
68
|
};
|
|
70
69
|
|
|
70
|
+
// Per-instance provider-metadata side-map (see comment at top of file).
|
|
71
|
+
const providerMetaByCallId = new Map<string, unknown>();
|
|
72
|
+
function stashProviderMeta(id: string, meta: unknown): void {
|
|
73
|
+
if (!id || meta == null) return;
|
|
74
|
+
providerMetaByCallId.set(id, meta);
|
|
75
|
+
// Cap: drop the oldest entry when a very long session piles up.
|
|
76
|
+
if (providerMetaByCallId.size > 500) {
|
|
77
|
+
const first = providerMetaByCallId.keys().next();
|
|
78
|
+
if (!first.done) providerMetaByCallId.delete(first.value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function takeProviderMeta(id: string): unknown {
|
|
82
|
+
const v = providerMetaByCallId.get(id);
|
|
83
|
+
if (v != null) providerMetaByCallId.delete(id);
|
|
84
|
+
return v;
|
|
85
|
+
}
|
|
86
|
+
|
|
71
87
|
return {
|
|
72
88
|
id: config.id ?? "openai-compat",
|
|
73
89
|
models: config.models,
|
|
@@ -76,14 +92,16 @@ export function createOpenAICompatProvider(config: OpenAICompatConfig): ModelPro
|
|
|
76
92
|
const buildBody = (withUsage: boolean): string =>
|
|
77
93
|
JSON.stringify({
|
|
78
94
|
model: request.model ?? config.defaultModel,
|
|
79
|
-
messages: toMessages(request.messages),
|
|
95
|
+
messages: toMessages(request.messages, takeProviderMeta),
|
|
80
96
|
tools: request.tools?.length ? toTools(request.tools) : undefined,
|
|
81
97
|
stream: true,
|
|
82
98
|
// JSON.stringify drops undefined keys, so the field is omitted entirely.
|
|
83
99
|
stream_options: withUsage ? { include_usage: true } : undefined,
|
|
84
100
|
// DeepSeek-style thinking: provider seperti b.ai butuh reasoning_content
|
|
85
101
|
// di history saat thinking aktif. OFF via env agar multi-turn aman.
|
|
86
|
-
|
|
102
|
+
// MINICORE_THINKING adalah nama resmi; MINICODE_THINKING (brand lama)
|
|
103
|
+
// dipertahankan sebagai fallback kompatibilitas.
|
|
104
|
+
...((process.env.MINICORE_THINKING ?? process.env.MINICODE_THINKING) === "off" ? { enable_thinking: false } : {}),
|
|
87
105
|
...(config.reasoningEffort ? { reasoning_effort: config.reasoningEffort } : {}),
|
|
88
106
|
});
|
|
89
107
|
let body = buildBody(includeUsage);
|
|
@@ -223,7 +241,7 @@ export function createOpenAICompatProvider(config: OpenAICompatConfig): ModelPro
|
|
|
223
241
|
};
|
|
224
242
|
}
|
|
225
243
|
|
|
226
|
-
function toMessages(messages: readonly Message[]): unknown[] {
|
|
244
|
+
function toMessages(messages: readonly Message[], takeMeta: (id: string) => unknown): unknown[] {
|
|
227
245
|
return messages.map((message) => {
|
|
228
246
|
switch (message.role) {
|
|
229
247
|
case "user":
|
|
@@ -239,7 +257,7 @@ function toMessages(messages: readonly Message[]): unknown[] {
|
|
|
239
257
|
? message.toolCalls.map((call) => {
|
|
240
258
|
// Echo provider metadata from the side-map (consume-once);
|
|
241
259
|
// args are sent exactly as received, with no hidden keys.
|
|
242
|
-
const extra =
|
|
260
|
+
const extra = takeMeta(call.id)
|
|
243
261
|
return {
|
|
244
262
|
id: call.id,
|
|
245
263
|
type: "function",
|
|
@@ -249,12 +267,24 @@ function toMessages(messages: readonly Message[]): unknown[] {
|
|
|
249
267
|
})
|
|
250
268
|
: undefined,
|
|
251
269
|
};
|
|
252
|
-
case "tool":
|
|
270
|
+
case "tool": {
|
|
271
|
+
const content = message.content;
|
|
272
|
+
// Binary tool results must never reach the wire as a JSON index map
|
|
273
|
+
// ({"0":1,...}): sniffed images travel as an image_url data-URL part;
|
|
274
|
+
// any other binary becomes an explicit placeholder string.
|
|
275
|
+
if (content instanceof Uint8Array) {
|
|
276
|
+
const mime = sniffImageMime(content);
|
|
277
|
+
const wire = mime
|
|
278
|
+
? [{ type: "image_url", image_url: { url: `data:${mime};base64,${bytesToBase64(content)}` } }]
|
|
279
|
+
: `[binary: ${content.byteLength} bytes]`;
|
|
280
|
+
return { role: "tool", tool_call_id: message.toolCallId, content: wire };
|
|
281
|
+
}
|
|
253
282
|
return {
|
|
254
283
|
role: "tool",
|
|
255
284
|
tool_call_id: message.toolCallId,
|
|
256
|
-
content: typeof
|
|
285
|
+
content: typeof content === "string" ? content : JSON.stringify(content),
|
|
257
286
|
};
|
|
287
|
+
}
|
|
258
288
|
}
|
|
259
289
|
});
|
|
260
290
|
}
|
|
@@ -351,16 +381,37 @@ async function* sse(body: ReadableStream<Uint8Array>, signal: AbortSignal): Asyn
|
|
|
351
381
|
|
|
352
382
|
function toProviderError(status: number, body: string, headers: Headers): ProviderError {
|
|
353
383
|
const detail = body.slice(0, 500);
|
|
354
|
-
const
|
|
384
|
+
const retryAfterMs = parseRetryAfter(headers.get("retry-after"));
|
|
355
385
|
if (status === 429) {
|
|
356
|
-
|
|
357
|
-
return new ProviderError("rate_limit", `rate limited (${status}): ${detail}`, Number.isFinite(ms) ? ms : undefined);
|
|
386
|
+
return new ProviderError("rate_limit", `rate limited (${status}): ${detail}`, retryAfterMs);
|
|
358
387
|
}
|
|
359
388
|
if (status === 401 || status === 403) return new ProviderError("auth", `auth failed (${status}): ${detail}`);
|
|
360
389
|
if (status === 400 || status === 404 || status === 422) {
|
|
361
|
-
|
|
390
|
+
// Providers phrase context overflow differently: OpenAI "maximum context
|
|
391
|
+
// length", OpenRouter-style "context_length_exceeded", Anthropic "prompt
|
|
392
|
+
// is too long", Gemini-style "input is too long". Missing a phrase turns
|
|
393
|
+
// a compact-and-retry case into a terminal invalid_request throw.
|
|
394
|
+
const lower = body.toLowerCase();
|
|
395
|
+
const isContext = ["context_length", "context length", "maximum context", "prompt is too long", "input is too long"].some((phrase) =>
|
|
396
|
+
lower.includes(phrase),
|
|
397
|
+
);
|
|
362
398
|
return new ProviderError(isContext ? "context_length_exceeded" : "invalid_request", `${status}: ${detail}`);
|
|
363
399
|
}
|
|
364
400
|
if (status >= 500) return new ProviderError("server", `server error (${status}): ${detail}`);
|
|
365
401
|
return new ProviderError("unknown", `${status}: ${detail}`);
|
|
366
|
-
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Parse a `Retry-After` header in either RFC form — delta-seconds ("120")
|
|
406
|
+
* or HTTP-date ("Wed, 21 Oct 2026 07:28:00 GMT") — into milliseconds from
|
|
407
|
+
* now. Returns undefined when absent or unparsable; a past date yields 0.
|
|
408
|
+
*/
|
|
409
|
+
function parseRetryAfter(value: string | null): number | undefined {
|
|
410
|
+
if (!value) return undefined;
|
|
411
|
+
const trimmed = value.trim();
|
|
412
|
+
if (trimmed === "") return undefined;
|
|
413
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) return Math.round(Number(trimmed) * 1_000);
|
|
414
|
+
const date = Date.parse(trimmed);
|
|
415
|
+
if (Number.isNaN(date)) return undefined;
|
|
416
|
+
return Math.max(0, date - Date.now());
|
|
417
|
+
}
|