minicode-ai 0.26.0 → 0.28.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/cli/args.ts +120 -16
- package/cli/commands/acp.ts +38 -28
- package/cli/commands/auth.ts +17 -17
- package/cli/commands/config.ts +65 -66
- package/cli/commands/daemon.ts +44 -16
- package/cli/commands/doctor.ts +11 -12
- package/cli/commands/exec.ts +35 -73
- package/cli/commands/mcp.ts +25 -8
- package/cli/commands/memory.ts +16 -24
- package/cli/commands/openwork.ts +6 -2
- package/cli/commands/pricing.ts +14 -12
- package/cli/commands/providers.ts +36 -57
- package/cli/commands/sessions.ts +24 -18
- package/cli/commands/skills.ts +33 -18
- package/cli/commands/stats.ts +15 -30
- package/cli/commands.ts +96 -46
- package/cli/context-command-run.ts +171 -0
- package/cli/context-command.ts +87 -0
- package/cli/index.ts +96 -98
- package/cli/model-manager.ts +7 -2
- package/cli/provider-manager.ts +33 -18
- package/cli/router.ts +41 -12
- package/cli/setup.ts +246 -123
- package/cli/tui.ts +311 -109
- package/docs/TERMINAL_CONTRACT.md +254 -69
- package/docs/UI_RENDER_PIPELINE.md +9 -1
- package/docs/agents.md +2 -2
- package/docs/architecture.md +3 -3
- package/docs/choosing-mode.md +7 -9
- package/docs/cli.md +3 -5
- package/docs/config.md +16 -0
- package/docs/environment.md +3 -3
- package/docs/policy-sandbox.md +3 -3
- package/docs/repl.md +3 -2
- package/docs/tools.md +1 -1
- package/package.json +1 -1
- package/src/app/mentions.ts +60 -13
- package/src/app/rag-layer.ts +17 -20
- package/src/app/session.ts +119 -66
- package/src/app/tool-layer.ts +12 -17
- package/src/config.ts +64 -104
- package/src/constants.ts +23 -9
- package/src/daemon/capability.ts +8 -1
- package/src/daemon/control.ts +3 -2
- package/src/daemon/server.ts +57 -0
- package/src/hooks/run.ts +73 -41
- package/src/lib/db-path.ts +47 -0
- package/src/lib/process-tree.ts +62 -0
- package/src/lib/public-http.ts +88 -23
- package/src/lib/trusted-exec.ts +48 -1
- package/src/lsp/client.ts +62 -17
- package/src/mcp/client.ts +85 -38
- package/src/mcp/http-transport.ts +28 -16
- package/src/mcp/transport.ts +42 -6
- package/src/memory/files.ts +164 -134
- package/src/memory/vector.ts +371 -420
- package/src/policy/approval-binding.ts +122 -45
- package/src/policy/bash-guard.ts +18 -7
- package/src/policy/compaction.ts +51 -18
- package/src/policy/context-window.ts +109 -0
- package/src/policy/context.ts +78 -37
- package/src/policy/executor.ts +17 -7
- package/src/policy/microcompact.ts +4 -3
- package/src/policy/no-progress.ts +103 -22
- package/src/policy/permission.ts +36 -12
- package/src/policy/tool-contract.ts +74 -416
- package/src/policy/usage.ts +24 -2
- package/src/policy/verifier.ts +50 -2
- package/src/policy/work-mode.ts +28 -54
- package/src/presentation/adapter.ts +24 -16
- package/src/providers/guards.ts +41 -2
- package/src/providers/provision.ts +6 -60
- package/src/providers/responses.ts +1 -0
- package/src/repo/repomap.ts +180 -23
- package/src/runtime/execution-journal.ts +4 -29
- package/src/sandbox/docker.ts +58 -34
- package/src/sandbox/mask.ts +157 -0
- package/src/sandbox/os.ts +107 -73
- package/src/session/authority.ts +29 -10
- package/src/session/context-projection.ts +6 -5
- package/src/session/open-work.ts +26 -3
- package/src/session/persistence.ts +25 -58
- package/src/session/verification.ts +170 -20
- package/src/skills/loader.ts +31 -16
- package/src/task/production-scheduler.ts +13 -1
- package/src/task/store.ts +20 -37
- package/src/telemetry/trace.ts +27 -0
- package/src/tools/ask_user.ts +1 -13
- package/src/tools/bash.ts +27 -92
- package/src/tools/code_run.ts +1 -1
- package/src/tools/context.ts +133 -0
- package/src/tools/delete_file.ts +3 -2
- package/src/tools/edit.ts +37 -72
- package/src/tools/git.ts +86 -9
- package/src/tools/glob.ts +26 -51
- package/src/tools/grep.ts +67 -57
- package/src/tools/hashline.ts +4 -0
- package/src/tools/lsp.ts +11 -8
- package/src/tools/mcp_call.ts +9 -6
- package/src/tools/memory.ts +56 -33
- package/src/tools/move_file.ts +36 -10
- package/src/tools/patch.ts +13 -21
- package/src/tools/read_file.ts +18 -25
- package/src/tools/read_image.ts +35 -33
- package/src/tools/submit_result.ts +29 -8
- package/src/tools/task.ts +74 -17
- package/src/tools/todo.ts +181 -74
- package/src/tools/web_fetch.ts +42 -2
- package/src/tools/web_search.ts +47 -8
- package/src/ui/approval/prompt.ts +206 -47
- package/src/ui/assistant/turn-status.ts +14 -5
- package/src/ui/footer.ts +4 -4
- package/src/ui/i18n/en.ts +59 -23
- package/src/ui/i18n/id.ts +88 -51
- package/src/ui/input/input.ts +4 -3
- package/src/ui/input/prompt-engine.ts +35 -5
- package/src/ui/render/activity-panel.ts +4 -2
- package/src/ui/render/hint.ts +7 -4
- package/src/ui/render/list.ts +32 -0
- package/src/ui/render/markdown.ts +6 -3
- package/src/ui/render/notice.ts +19 -0
- package/src/ui/render/table-grid.ts +7 -8
- package/src/ui/render/theme.ts +113 -39
- package/src/ui/runtime/screen.ts +74 -10
- package/src/ui/runtime/spinner.ts +19 -6
- package/src/ui/screens/dialog.ts +19 -1
- package/src/ui/screens/form.ts +80 -35
- package/src/ui/screens/model-manager.ts +88 -62
- package/src/ui/screens/output-window.ts +263 -0
- package/src/ui/screens/picker.ts +94 -81
- package/src/ui/screens/provider-manager.ts +100 -69
- package/src/ui/screens/wizard.ts +117 -28
- package/src/ui/tui/app.ts +196 -33
- package/src/ui/tui/transcript.ts +154 -25
- package/vendor/minicore/src/core/executor.ts +2 -0
- package/vendor/minicore/src/core/loop.ts +17 -6
- package/vendor/minicore/src/core/session.ts +3 -0
- package/vendor/minicore/src/core/tool.ts +1 -0
- package/vendor/minicore/src/providers/openai-compat.ts +28 -19
package/cli/commands/exec.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolve as resolvePath } from "node:path"
|
|
2
|
+
import { expandMentions } from "../../src/app/mentions.ts"
|
|
2
3
|
import { NoProviderError } from "../../src/app/provider-layer.ts"
|
|
3
4
|
// F3.2 parity: exec ikut menghormati MINICODE_COMPACT_KEEP_TURNS, sama seperti
|
|
4
5
|
// jalur one-shot (cli/index.ts) — sebelumnya env ini hanya berlaku di REPL.
|
|
@@ -23,8 +24,10 @@ import {
|
|
|
23
24
|
displayWorkMode,
|
|
24
25
|
flagsAfterPromptBoundary,
|
|
25
26
|
hasFlag,
|
|
27
|
+
parseRuntimeNumericFlags,
|
|
26
28
|
promptFromArgs,
|
|
27
29
|
getArg as rawGetArg,
|
|
30
|
+
resolveToolScope,
|
|
28
31
|
resolveWorkModeFlag,
|
|
29
32
|
} from "../args.ts"
|
|
30
33
|
import { createCliSession } from "../setup.ts"
|
|
@@ -34,6 +37,14 @@ function writeMachineLine(line: string): void {
|
|
|
34
37
|
process.stdout.write(`${cleanUntrusted(scrubSecrets(line), false)}\n`)
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
const warnStderr = (msg: string): void => {
|
|
41
|
+
process.stderr.write(msg)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const EXEC_HELP = `minicode exec — headless one-shot execution (JSONL/linear)
|
|
45
|
+
|
|
46
|
+
minicode exec [--json] [--work-mode DISCUSS|BUILD] [--cwd <dir>] [--model <m>] [--sandbox docker|os] "prompt"`
|
|
47
|
+
|
|
37
48
|
/** Prompt lanjutan (Phase D auto-continue): minta model menyelesaikan sisa
|
|
38
49
|
* pekerjaan dari titik berhenti, memanfaatkan progres parsial yang sudah
|
|
39
50
|
* durable (safeTurnBoundary + persist). */
|
|
@@ -60,6 +71,10 @@ export async function handleExec(
|
|
|
60
71
|
subArgs: string[],
|
|
61
72
|
getArg: (name: string) => string | undefined,
|
|
62
73
|
): Promise<never> {
|
|
74
|
+
if (hasFlag(subArgs, "--help") || hasFlag(subArgs, "-h")) {
|
|
75
|
+
console.log(EXEC_HELP)
|
|
76
|
+
process.exit(0)
|
|
77
|
+
}
|
|
63
78
|
// Bersihkan state submit_result dari run sebelumnya — tanpa ini, exec
|
|
64
79
|
// berturut-turut dalam proses sama bisa membaca hasil run lama.
|
|
65
80
|
clearSubmittedResult()
|
|
@@ -79,7 +94,6 @@ export async function handleExec(
|
|
|
79
94
|
const sessionFlag = getArg("--session") ?? ""
|
|
80
95
|
const allowAll = hasFlag(subArgs, "--allow-all")
|
|
81
96
|
const ask = hasFlag(subArgs, "--ask")
|
|
82
|
-
const plan = hasFlag(subArgs, "--plan")
|
|
83
97
|
const allowlistFlag = hasFlag(subArgs, "--allowlist")
|
|
84
98
|
// Sama seperti jalur interaktif: OS sandbox otomatis, dan tanpa isolasi nyata
|
|
85
99
|
// permission default turun ke allowlist. Headless CI justru paling butuh ini —
|
|
@@ -94,7 +108,7 @@ export async function handleExec(
|
|
|
94
108
|
writeMachineLine(JSON.stringify(machineFailure(prompt.trim(), new Error(sandboxRefusal))))
|
|
95
109
|
process.exit(1)
|
|
96
110
|
}
|
|
97
|
-
const sandbox = resolveSandbox(requestedSandbox, allowAll || ask ||
|
|
111
|
+
const sandbox = resolveSandbox(requestedSandbox, allowAll || ask || allowlistFlag)
|
|
98
112
|
if (sandbox.mode === "none") delete process.env.MINICODE_SANDBOX
|
|
99
113
|
else process.env.MINICODE_SANDBOX = sandbox.mode
|
|
100
114
|
const allowlist = allowlistFlag || sandbox.fallbackPermission === "allowlist"
|
|
@@ -103,30 +117,17 @@ export async function handleExec(
|
|
|
103
117
|
console.error(
|
|
104
118
|
`[deprecated] --allow-all is a privileged access profile (hard jail/guard still apply); treat it as an explicit override, not ordinary AUTO`,
|
|
105
119
|
)
|
|
106
|
-
if (
|
|
120
|
+
if (allowlistFlag)
|
|
107
121
|
console.error(
|
|
108
122
|
`[deprecated] --allowlist is a bash/tool access policy; persistent grants remain in ~/.minicode/allowlist.json`,
|
|
109
123
|
)
|
|
110
124
|
// Audit #07 P0: local config repo tak dipercaya kecuali operator opt-in.
|
|
111
125
|
const allowLocal = allowLocalConfig(subArgs)
|
|
112
|
-
const budgetRaw = getArg("--budget")
|
|
113
|
-
let budget = budgetRaw ? Number(budgetRaw) : undefined
|
|
114
|
-
// [Audit #2 A.1/B.4] Selaras dengan cli/index.ts: --budget non-angka/negatif
|
|
115
|
-
// diingatkan eksplisit, bukan dibiarkan berubah jadi undefined secara diam.
|
|
116
|
-
if (budgetRaw && (!Number.isFinite(budget) || (budget as number) < 0)) {
|
|
117
|
-
process.stderr.write(`[warn] --budget requires a USD number, ignoring "${budgetRaw}"\n`)
|
|
118
|
-
budget = undefined
|
|
119
|
-
}
|
|
120
126
|
// Harness-P1: sama seperti one-shot — strict fail-closed bila cost tak dikenal.
|
|
121
127
|
const budgetStrict =
|
|
122
128
|
hasFlag(subArgs, "--budget-strict") || process.env.MINICODE_BUDGET_STRICT === "1"
|
|
123
129
|
// Harness-P2: scope tool sesi.
|
|
124
|
-
const
|
|
125
|
-
getArg("--tool-scope") ??
|
|
126
|
-
process.env.MINICODE_TOOL_SCOPE ??
|
|
127
|
-
""
|
|
128
|
-
).toLowerCase()
|
|
129
|
-
const toolScope = toolScopeRaw === "explore" ? ("explore" as const) : ("full" as const)
|
|
130
|
+
const toolScope = resolveToolScope(getArg)
|
|
130
131
|
// WorkMode (flag > env, default DISCUSS; invalid → DISCUSS + warning).
|
|
131
132
|
const workModeResolved = resolveWorkModeFlag(getArg)
|
|
132
133
|
const workMode = workModeResolved.workMode
|
|
@@ -137,63 +138,21 @@ export async function handleExec(
|
|
|
137
138
|
// (summary.workMode) — bukan teks dekoratif. BUILD = mode yang mengizinkan tulis.
|
|
138
139
|
if (!jsonMode && (workMode !== "EXECUTE" || workModeResolved.explicit)) {
|
|
139
140
|
const modeLabel = displayWorkMode(workMode)
|
|
140
|
-
const modeNote =
|
|
141
|
-
|
|
142
|
-
process.stderr.write(`[work-mode] ${modeLabel}${modeNote}\n`)
|
|
143
|
-
}
|
|
144
|
-
const ratelimitRaw = getArg("--ratelimit")
|
|
145
|
-
let rateLimiter: ReturnType<typeof createRateLimiter> | undefined
|
|
146
|
-
if (ratelimitRaw) {
|
|
147
|
-
const rpm = Number(ratelimitRaw)
|
|
148
|
-
if (!Number.isFinite(rpm) || rpm <= 0) {
|
|
149
|
-
process.stderr.write(
|
|
150
|
-
`[warn] --ratelimit requires a positive number, ignoring "${ratelimitRaw}"\n`,
|
|
151
|
-
)
|
|
152
|
-
} else {
|
|
153
|
-
rateLimiter = createRateLimiter(rpm)
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Live Hardening 0.13.x — parity flag runtime dengan jalur one-shot
|
|
158
|
-
// (cli/index.ts): --max-steps, --context-window, --timeout, dan env
|
|
159
|
-
// MINICODE_COMPACT_KEEP_TURNS kini diteruskan ke sesi. Sebelumnya exec
|
|
160
|
-
// menyaring nilai flag ini dari prompt tetapi tidak pernah menerapkannya —
|
|
161
|
-
// operator mengira batas aktif padahal sesi berjalan dengan default kernel
|
|
162
|
-
// (silently ignored). Parsing + warn tiruan persis jalur one-shot.
|
|
163
|
-
const maxStepsRaw = getArg("--max-steps")
|
|
164
|
-
let maxSteps = maxStepsRaw ? Number(maxStepsRaw) : undefined
|
|
165
|
-
if (maxStepsRaw && (!Number.isFinite(maxSteps) || (maxSteps as number) <= 0)) {
|
|
166
|
-
process.stderr.write(
|
|
167
|
-
`[warn] --max-steps requires a positive number, ignoring "${maxStepsRaw}"\n`,
|
|
168
|
-
)
|
|
169
|
-
maxSteps = undefined
|
|
170
|
-
}
|
|
171
|
-
const ctxWindowRaw = getArg("--context-window")
|
|
172
|
-
let contextWindowTokens = ctxWindowRaw ? Number(ctxWindowRaw) : undefined
|
|
173
|
-
if (
|
|
174
|
-
ctxWindowRaw &&
|
|
175
|
-
(!Number.isFinite(contextWindowTokens) || (contextWindowTokens as number) <= 0)
|
|
176
|
-
) {
|
|
177
|
-
process.stderr.write(
|
|
178
|
-
`[warn] --context-window requires a positive number, ignoring "${ctxWindowRaw}"\n`,
|
|
179
|
-
)
|
|
180
|
-
contextWindowTokens = undefined
|
|
141
|
+
const modeNote = workMode === "DISCUSS" ? " (read-only)" : ""
|
|
142
|
+
warnStderr(`[work-mode] ${modeLabel}${modeNote}\n`)
|
|
181
143
|
}
|
|
144
|
+
const parsedNums = parseRuntimeNumericFlags(getArg, warnStderr)
|
|
145
|
+
const { maxSteps, contextWindowTokens, budget } = parsedNums
|
|
146
|
+
const rateLimiter =
|
|
147
|
+
parsedNums.ratelimitRpm !== undefined ? createRateLimiter(parsedNums.ratelimitRpm) : undefined
|
|
182
148
|
const keepTurnsRaw = (process.env.MINICODE_COMPACT_KEEP_TURNS ?? "").trim()
|
|
183
149
|
const keepRecentTurns = parseCompactKeepTurns(keepTurnsRaw || undefined)
|
|
184
150
|
if (keepTurnsRaw && keepRecentTurns === undefined)
|
|
185
|
-
|
|
151
|
+
warnStderr(
|
|
186
152
|
`[warn] MINICODE_COMPACT_KEEP_TURNS requires an integer >= 1, ignoring "${keepTurnsRaw}"\n`,
|
|
187
153
|
)
|
|
188
|
-
const timeoutRaw = getArg("--timeout")
|
|
189
154
|
// exec (one-shot/CI) default 15 menit — lebih konservatif dari interaktif (1 jam).
|
|
190
|
-
|
|
191
|
-
if (timeoutRaw && (!Number.isFinite(timeoutMs) || (timeoutMs as number) < 0)) {
|
|
192
|
-
process.stderr.write(
|
|
193
|
-
`[warn] --timeout requires a non-negative number, ignoring "${timeoutRaw}"\n`,
|
|
194
|
-
)
|
|
195
|
-
timeoutMs = 900_000
|
|
196
|
-
}
|
|
155
|
+
const timeoutMs = parsedNums.timeoutMs ?? 900_000
|
|
197
156
|
// Phase D — auto-continue (opt-in): pecah tugas panjang menjadi beberapa turn
|
|
198
157
|
// bounded. Saat turn berakhir dengan max_steps_exceeded, kernel SUDAH
|
|
199
158
|
// meng-commit progres parsial (safeTurnBoundary); run lanjutan melanjutkan dari
|
|
@@ -209,7 +168,7 @@ export async function handleExec(
|
|
|
209
168
|
|
|
210
169
|
const ignoredFlags = flagsAfterPromptBoundary(subArgs)
|
|
211
170
|
if (ignoredFlags.length > 0) {
|
|
212
|
-
|
|
171
|
+
warnStderr(
|
|
213
172
|
`[warn] ignored flag(s) after the prompt: ${ignoredFlags.join(", ")} — put flags before the prompt (e.g. minicode exec ${ignoredFlags.join(" ")} "your prompt")\n`,
|
|
214
173
|
)
|
|
215
174
|
}
|
|
@@ -217,7 +176,7 @@ export async function handleExec(
|
|
|
217
176
|
const effectivePrompt = prompt.trim()
|
|
218
177
|
if (!effectivePrompt) {
|
|
219
178
|
console.error(
|
|
220
|
-
'usage: minicode exec [--json] [--work-mode DISCUSS|
|
|
179
|
+
'usage: minicode exec [--json] [--work-mode DISCUSS|BUILD] [--cwd <dir>] [--model <m>] [--sandbox docker|os] "prompt"',
|
|
221
180
|
)
|
|
222
181
|
if (jsonMode)
|
|
223
182
|
writeMachineLine(
|
|
@@ -241,7 +200,6 @@ export async function handleExec(
|
|
|
241
200
|
verbose: false,
|
|
242
201
|
allowAll,
|
|
243
202
|
ask,
|
|
244
|
-
plan,
|
|
245
203
|
allowlist,
|
|
246
204
|
verify: hasFlag(subArgs, "--verify"),
|
|
247
205
|
// [P1 M15] Mode runtime produksi, deterministik per invokasi (sama seperti
|
|
@@ -316,6 +274,9 @@ export async function handleExec(
|
|
|
316
274
|
)
|
|
317
275
|
})
|
|
318
276
|
try {
|
|
277
|
+
const runPrompt = effectivePrompt.includes("@")
|
|
278
|
+
? (await expandMentions(effectivePrompt, cwd ?? process.cwd())).prompt
|
|
279
|
+
: effectivePrompt
|
|
319
280
|
if (autoContinue) {
|
|
320
281
|
// Lanjutkan sampai selesai / cap tercapai. `isStepLimit` memisahkan
|
|
321
282
|
// "habis langkah" (layak dilanjut) dari error lain (auth/network/dll yang
|
|
@@ -327,7 +288,7 @@ export async function handleExec(
|
|
|
327
288
|
for (let i = 0; i <= autoContinueBudget; i++) {
|
|
328
289
|
let err: unknown = null
|
|
329
290
|
try {
|
|
330
|
-
await ctx.runPromptWithVerify(i === 0 ?
|
|
291
|
+
await ctx.runPromptWithVerify(i === 0 ? runPrompt : CONTINUE_PROMPT)
|
|
331
292
|
} catch (e) {
|
|
332
293
|
err = e
|
|
333
294
|
}
|
|
@@ -338,7 +299,7 @@ export async function handleExec(
|
|
|
338
299
|
)
|
|
339
300
|
}
|
|
340
301
|
} else {
|
|
341
|
-
await ctx.runPromptWithVerify(
|
|
302
|
+
await ctx.runPromptWithVerify(runPrompt)
|
|
342
303
|
}
|
|
343
304
|
// Harness-P1: exec sebelumnya mengabaikan --budget total (flag diteruskan
|
|
344
305
|
// tapi tak pernah diperiksa). Samakan dengan one-shot: over → exit 1.
|
|
@@ -377,7 +338,8 @@ export async function handleExec(
|
|
|
377
338
|
if (jsonMode) {
|
|
378
339
|
// submit_result dari model (bila dipanggil) ikut verbatim — pipeline CI
|
|
379
340
|
// tak perlu menebak batas JSON dari prosa turn terakhir.
|
|
380
|
-
const submitted = getSubmittedResult()
|
|
341
|
+
const submitted = getSubmittedResult(ctx.sessionId)
|
|
342
|
+
clearSubmittedResult(ctx.sessionId)
|
|
381
343
|
// P11.1 — hasil verify TERAKHIR (final pasca-self-heal) untuk summary.
|
|
382
344
|
// Aditif & absen bila verify tak jalan: cermin lastVerify sesi, bukan
|
|
383
345
|
// otoritas baru. ok top-level dan exit code SENGAJA tak berubah.
|
package/cli/commands/mcp.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { resolve as resolvePath } from "node:path"
|
|
2
2
|
import { configureMcpSchemaPins, mcpSchemaPinRegistry } from "../../src/mcp/client.ts"
|
|
3
|
+
import { sanitizeAnsiLine } from "../../src/ui/render/sanitize.ts"
|
|
4
|
+
import { guardSubcommand, positionalSubArg } from "../args.ts"
|
|
3
5
|
|
|
4
6
|
const MCP_HELP = `minicode mcp — run minicode as an MCP server / inspect schema pins
|
|
5
7
|
|
|
@@ -27,8 +29,14 @@ export async function handleMcp(
|
|
|
27
29
|
getArg: (name: string) => string | undefined,
|
|
28
30
|
_help: string,
|
|
29
31
|
): Promise<never> {
|
|
30
|
-
|
|
32
|
+
guardSubcommand(args, "mcp", MCP_HELP, out, err, -1)
|
|
33
|
+
const sub = positionalSubArg(args, 1)
|
|
31
34
|
const cwdArg = getArg("--cwd")
|
|
35
|
+
const extra = positionalSubArg(args, 2)
|
|
36
|
+
if (extra && (sub === "serve" || sub === "pins" || sub === "capabilities")) {
|
|
37
|
+
err(`unknown mcp ${sub} argument: ${sanitizeAnsiLine(extra)}\n${MCP_HELP}`)
|
|
38
|
+
process.exit(2)
|
|
39
|
+
}
|
|
32
40
|
if (sub === "serve") {
|
|
33
41
|
const { serveMcp } = await import("../../src/mcp/server.ts")
|
|
34
42
|
await serveMcp({
|
|
@@ -47,7 +55,9 @@ export async function handleMcp(
|
|
|
47
55
|
} else if (pins.length === 0) {
|
|
48
56
|
out("no MCP schema pins recorded for this workspace")
|
|
49
57
|
} else {
|
|
50
|
-
for (const p of pins)
|
|
58
|
+
for (const p of pins) {
|
|
59
|
+
out(`${sanitizeAnsiLine(p.serverId)}.${sanitizeAnsiLine(p.toolName)} ${p.hash}`)
|
|
60
|
+
}
|
|
51
61
|
}
|
|
52
62
|
process.exit(0)
|
|
53
63
|
}
|
|
@@ -73,9 +83,14 @@ export async function handleMcp(
|
|
|
73
83
|
process.exit(0)
|
|
74
84
|
}
|
|
75
85
|
if (sub === "approve") {
|
|
76
|
-
const target =
|
|
77
|
-
const hash = args
|
|
78
|
-
if (
|
|
86
|
+
const target = extra
|
|
87
|
+
const hash = positionalSubArg(args, 3) ?? getArg("--hash")
|
|
88
|
+
if (
|
|
89
|
+
!target?.includes(".") ||
|
|
90
|
+
!hash ||
|
|
91
|
+
!/^[0-9a-f]{64}$/i.test(hash) ||
|
|
92
|
+
positionalSubArg(args, 4)
|
|
93
|
+
) {
|
|
79
94
|
err("usage: minicode mcp approve <server>.<tool> <64-hex-sha256> [--cwd <dir>]")
|
|
80
95
|
process.exit(2)
|
|
81
96
|
}
|
|
@@ -85,13 +100,15 @@ export async function handleMcp(
|
|
|
85
100
|
const cwd = cwdArg ? resolvePath(cwdArg) : undefined
|
|
86
101
|
configureMcpSchemaPins(cwd)
|
|
87
102
|
mcpSchemaPinRegistry.approveMcpSchemaUpdate(serverId, toolName, hash.toLowerCase())
|
|
88
|
-
out(
|
|
103
|
+
out(
|
|
104
|
+
`approved ${sanitizeAnsiLine(serverId)}.${sanitizeAnsiLine(toolName)} -> ${hash.toLowerCase()}`,
|
|
105
|
+
)
|
|
89
106
|
process.exit(0)
|
|
90
107
|
}
|
|
91
108
|
// Help kontekstual, bukan HELP global 45 baris. Subcommand asing = salah
|
|
92
109
|
// pakai (exit 2), bukan gagal runtime (exit 1).
|
|
93
|
-
const asking = sub === undefined
|
|
94
|
-
if (
|
|
110
|
+
const asking = sub === undefined
|
|
111
|
+
if (sub !== undefined) err(`unknown mcp subcommand: ${sanitizeAnsiLine(sub)}\n`)
|
|
95
112
|
out(MCP_HELP)
|
|
96
113
|
process.exit(asking ? 0 : 2)
|
|
97
114
|
}
|
package/cli/commands/memory.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs"
|
|
2
|
-
import { resolve } from "node:path"
|
|
3
1
|
import { getMemoryStats, reconcileMemoryStores } from "../../src/memory/vector.ts"
|
|
2
|
+
import { readTraceRows } from "../../src/telemetry/trace.ts"
|
|
3
|
+
import { sanitizeAnsiLine } from "../../src/ui/render/sanitize.ts"
|
|
4
4
|
import { c } from "../../src/ui/render/theme.ts"
|
|
5
|
+
import { guardSubcommand, positionalSubArg } from "../args.ts"
|
|
5
6
|
|
|
6
7
|
const MEMORY_HELP = `minicode memory — vector RAG store stats
|
|
7
8
|
|
|
@@ -31,20 +32,12 @@ function fmtDate(ts: number | null): string {
|
|
|
31
32
|
function readHitRate(cwd?: string): { runs: number; avgHits: number } {
|
|
32
33
|
let runs = 0
|
|
33
34
|
let total = 0
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
for (const l of lines) {
|
|
39
|
-
try {
|
|
40
|
-
const t = JSON.parse(l) as MemoryTraceRow
|
|
41
|
-
if (typeof t.memoryHits === "number") {
|
|
42
|
-
runs++
|
|
43
|
-
total += t.memoryHits
|
|
44
|
-
}
|
|
45
|
-
} catch {}
|
|
35
|
+
for (const t of readTraceRows<MemoryTraceRow>(cwd, "traces.jsonl")) {
|
|
36
|
+
if (typeof t.memoryHits === "number") {
|
|
37
|
+
runs++
|
|
38
|
+
total += t.memoryHits
|
|
46
39
|
}
|
|
47
|
-
}
|
|
40
|
+
}
|
|
48
41
|
return { runs, avgHits: runs ? total / runs : 0 }
|
|
49
42
|
}
|
|
50
43
|
|
|
@@ -54,11 +47,8 @@ export async function handleMemory(
|
|
|
54
47
|
): Promise<never> {
|
|
55
48
|
// Satu saluran stderr bersama (dihitung inventaris writer sebagai satu site).
|
|
56
49
|
const err = (msg: string): void => console.error(msg)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.log(MEMORY_HELP)
|
|
60
|
-
process.exit(0)
|
|
61
|
-
}
|
|
50
|
+
guardSubcommand(args, "memory", MEMORY_HELP, console.log, err, -1)
|
|
51
|
+
const sub = positionalSubArg(args, 1)
|
|
62
52
|
// [PROMPT 06 · Area E / D4] `reconcileMemoryStores` sebelumnya TIDAK punya
|
|
63
53
|
// call site produksi sama sekali: pesan `write_memory` menyuruh user
|
|
64
54
|
// menjalankan `minicode memory reconcile` padahal subcommand itu tak ada —
|
|
@@ -83,8 +73,8 @@ export async function handleMemory(
|
|
|
83
73
|
process.exit(1)
|
|
84
74
|
}
|
|
85
75
|
}
|
|
86
|
-
if (sub && sub !== "status"
|
|
87
|
-
err(`unknown memory subcommand "${sub}" — see: minicode memory status`)
|
|
76
|
+
if (sub && sub !== "status") {
|
|
77
|
+
err(`unknown memory subcommand "${sanitizeAnsiLine(sub)}" — see: minicode memory status`)
|
|
88
78
|
process.exit(2)
|
|
89
79
|
}
|
|
90
80
|
const cwdArg = getArg("--cwd")
|
|
@@ -120,12 +110,14 @@ export async function handleMemory(
|
|
|
120
110
|
`(db ${fmtBytes(s.dbBytes)} ${dot} wal ${fmtBytes(s.walBytes)} ${dot} shm ${fmtBytes(s.shmBytes)})`,
|
|
121
111
|
]
|
|
122
112
|
if (s.models.length)
|
|
123
|
-
lines.push(
|
|
113
|
+
lines.push(
|
|
114
|
+
` models: ${s.models.map((m) => `${sanitizeAnsiLine(m.model)}×${m.count}`).join(", ")}`,
|
|
115
|
+
)
|
|
124
116
|
if (s.dims.length)
|
|
125
117
|
lines.push(` dims: ${s.dims.map((d) => `${d.dim || "none"}×${d.count}`).join(", ")}`)
|
|
126
118
|
if (s.categories.length)
|
|
127
119
|
lines.push(
|
|
128
|
-
` categories: ${s.categories.map((m) => `${m.category}×${m.count}`).join(", ")} (scope: ${scope})`,
|
|
120
|
+
` categories: ${s.categories.map((m) => `${sanitizeAnsiLine(m.category)}×${m.count}`).join(", ")} (scope: ${sanitizeAnsiLine(scope)})`,
|
|
129
121
|
)
|
|
130
122
|
lines.push(` range: ${fmtDate(s.oldest)} → ${fmtDate(s.newest)}`)
|
|
131
123
|
lines.push(
|
package/cli/commands/openwork.ts
CHANGED
|
@@ -423,7 +423,7 @@ function handleList(getArg: (name: string) => string | undefined): never {
|
|
|
423
423
|
process.exit(0)
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
function handleMerge(getArg: (name: string) => string | undefined): never {
|
|
426
|
+
async function handleMerge(getArg: (name: string) => string | undefined): Promise<never> {
|
|
427
427
|
const cwd = getArg("--cwd") ?? process.cwd()
|
|
428
428
|
const asJson = getArg("--json") !== undefined || process.argv.includes("--json")
|
|
429
429
|
const sessionId = getArg("--session")
|
|
@@ -473,6 +473,10 @@ function handleMerge(getArg: (name: string) => string | undefined): never {
|
|
|
473
473
|
exit1(sanitizeAnsi(`[openwork] merge refused: ${result.outcome} — ${result.detail}`))
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
+
// Sinkronkan view turunan todos/*.json & plans/*.md pasca merge/cancel duplikat.
|
|
477
|
+
const { syncTodoViewsFromTaskStore } = await import("../../src/tools/todo.ts")
|
|
478
|
+
await syncTodoViewsFromTaskStore(sessionId, cwd).catch(() => undefined)
|
|
479
|
+
|
|
476
480
|
if (asJson) {
|
|
477
481
|
emitJson(result)
|
|
478
482
|
process.exit(0)
|
|
@@ -968,7 +972,7 @@ export async function handleOpenwork(
|
|
|
968
972
|
}
|
|
969
973
|
const sub = actionAfter(args)
|
|
970
974
|
if (sub === "merge") {
|
|
971
|
-
handleMerge(getArg)
|
|
975
|
+
return await handleMerge(getArg)
|
|
972
976
|
}
|
|
973
977
|
if (sub === "inventory") {
|
|
974
978
|
handleInventory(getArg)
|
package/cli/commands/pricing.ts
CHANGED
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
pricingOverlayMeta,
|
|
8
8
|
syncPricing,
|
|
9
9
|
} from "../../src/policy/pricing.ts"
|
|
10
|
-
import {
|
|
10
|
+
import { formatError } from "../../src/ui/render/errors.ts"
|
|
11
|
+
import { sanitizeAnsiLine } from "../../src/ui/render/sanitize.ts"
|
|
12
|
+
import { c } from "../../src/ui/render/theme.ts"
|
|
13
|
+
import { hasHelpFlag, positionalSubArg } from "../args.ts"
|
|
11
14
|
|
|
12
15
|
const PRICING_HELP = `minicode pricing — price table for cost estimation
|
|
13
16
|
|
|
@@ -17,23 +20,22 @@ const PRICING_HELP = `minicode pricing — price table for cost estimation
|
|
|
17
20
|
minicode pricing clear clear cache and use built-in data`
|
|
18
21
|
|
|
19
22
|
export async function handlePricing(args: string[]): Promise<never> {
|
|
20
|
-
|
|
21
|
-
if (raw === "--help" || raw === "-h") {
|
|
23
|
+
if (hasHelpFlag(args)) {
|
|
22
24
|
console.log(PRICING_HELP)
|
|
23
25
|
process.exit(0)
|
|
24
26
|
}
|
|
25
|
-
const sub = (
|
|
27
|
+
const sub = (positionalSubArg(args, 1) ?? "status").toLowerCase()
|
|
26
28
|
|
|
27
29
|
if (sub === "sync") {
|
|
28
30
|
process.stderr.write("fetching prices from models.dev…\n")
|
|
29
31
|
try {
|
|
30
32
|
const res = await syncPricing()
|
|
31
33
|
console.log(
|
|
32
|
-
`${c.green(
|
|
34
|
+
`${c.green("ok")} saved ${res.count} models (${Math.round(res.bytes / 1024)} KB)\n ${c.dim(res.path)}`,
|
|
33
35
|
)
|
|
34
36
|
process.exit(0)
|
|
35
37
|
} catch (e) {
|
|
36
|
-
console.error(
|
|
38
|
+
console.error(c.red(`failed: ${formatError(e)}`))
|
|
37
39
|
console.error(c.dim(" built-in price table is still used — nothing is broken"))
|
|
38
40
|
process.exit(1)
|
|
39
41
|
}
|
|
@@ -60,20 +62,20 @@ export async function handlePricing(args: string[]): Promise<never> {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
if (sub === "show") {
|
|
63
|
-
|
|
64
|
-
const model = args[2] && !args[2]!.startsWith("-") ? args[2] : undefined
|
|
65
|
+
const model = positionalSubArg(args, 2)
|
|
65
66
|
if (!model) {
|
|
66
67
|
console.error("usage: minicode pricing show <model>")
|
|
67
68
|
process.exit(2)
|
|
68
69
|
}
|
|
69
70
|
const overlay = await loadPricingOverlay()
|
|
70
71
|
const p = findPrice(model, overlay)
|
|
72
|
+
const safeModel = sanitizeAnsiLine(model)
|
|
71
73
|
if (!p) {
|
|
72
|
-
console.log(`(price for "${
|
|
74
|
+
console.log(`(price for "${safeModel}" is unknown — cost will show N/A)`)
|
|
73
75
|
process.exit(0)
|
|
74
76
|
}
|
|
75
77
|
const src = findPrice(model, {}) === p ? "built-in" : "models.dev"
|
|
76
|
-
console.log(`\n${c.bold(
|
|
78
|
+
console.log(`\n${c.bold(safeModel)} ${c.dim(`(${src})`)}`)
|
|
77
79
|
console.log(` input $${p.input}/M token`)
|
|
78
80
|
console.log(` output $${p.output}/M token`)
|
|
79
81
|
if (p.cacheRead != null) console.log(` cache read $${p.cacheRead}/M`)
|
|
@@ -87,7 +89,7 @@ export async function handlePricing(args: string[]): Promise<never> {
|
|
|
87
89
|
await readFile(pricingCachePath(), "utf8")
|
|
88
90
|
const { rm } = await import("node:fs/promises")
|
|
89
91
|
await rm(pricingCachePath(), { force: true })
|
|
90
|
-
console.log(`${c.green(
|
|
92
|
+
console.log(`${c.green("ok")} pricing cache cleared`)
|
|
91
93
|
} catch {
|
|
92
94
|
console.log("(no pricing cache)")
|
|
93
95
|
}
|
|
@@ -96,7 +98,7 @@ export async function handlePricing(args: string[]): Promise<never> {
|
|
|
96
98
|
|
|
97
99
|
// Subcommand asing = salah pakai: exit 2 supaya skrip bisa mendeteksinya
|
|
98
100
|
// dan membedakannya dari gagal runtime (exit 1).
|
|
99
|
-
console.error(`unknown pricing subcommand: ${sub}\n`)
|
|
101
|
+
console.error(`unknown pricing subcommand: ${sanitizeAnsiLine(sub)}\n`)
|
|
100
102
|
console.log(PRICING_HELP)
|
|
101
103
|
process.exit(2)
|
|
102
104
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs"
|
|
2
|
-
import { resolve } from "node:path"
|
|
3
1
|
import { loadConfig, type MinicodeConfig } from "../../src/config.ts"
|
|
4
2
|
import { refreshProviderModels } from "../../src/providers/provision.ts"
|
|
3
|
+
import { readTraceRows } from "../../src/telemetry/trace.ts"
|
|
5
4
|
import { sanitizeAnsiLine } from "../../src/ui/render/sanitize.ts"
|
|
6
5
|
import { renderTable } from "../../src/ui/render/table.ts"
|
|
7
|
-
import { c
|
|
6
|
+
import { c } from "../../src/ui/render/theme.ts"
|
|
7
|
+
import { allowLocalSubcommand, guardSubcommand, positionalSubArg } from "../args.ts"
|
|
8
|
+
|
|
9
|
+
const PROVIDERS_HELP = `minicode providers | models | sync — inspect & refresh configured LLM providers
|
|
10
|
+
|
|
11
|
+
minicode providers [--allow-local-config] [--cwd <dir>]
|
|
12
|
+
minicode models [provider] [--match <q>] [--allow-local-config] [--cwd <dir>]
|
|
13
|
+
minicode sync [--allow-local-config] [--cwd <dir>]`
|
|
8
14
|
|
|
9
15
|
interface TraceRow {
|
|
10
16
|
model?: string
|
|
@@ -13,23 +19,8 @@ interface TraceRow {
|
|
|
13
19
|
timestamp?: string
|
|
14
20
|
}
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
return readFileSync(resolve(cwd ?? ".", ".minicode", "traces.jsonl"), "utf8")
|
|
20
|
-
.split("\n")
|
|
21
|
-
.filter(Boolean)
|
|
22
|
-
.flatMap((l) => {
|
|
23
|
-
try {
|
|
24
|
-
return [JSON.parse(l) as TraceRow]
|
|
25
|
-
} catch {
|
|
26
|
-
return []
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
} catch {
|
|
30
|
-
return []
|
|
31
|
-
}
|
|
32
|
-
}
|
|
22
|
+
const out = (msg: string): void => console.log(msg)
|
|
23
|
+
const err = (msg: string): void => console.error(msg)
|
|
33
24
|
|
|
34
25
|
export function providerOfTrace(cfg: MinicodeConfig, t: TraceRow): string | undefined {
|
|
35
26
|
const m = t.model ?? ""
|
|
@@ -64,23 +55,20 @@ export async function handleProviders(
|
|
|
64
55
|
if (firstArg !== "providers" && firstArg !== "models" && firstArg !== "sync") {
|
|
65
56
|
process.exit(0)
|
|
66
57
|
}
|
|
58
|
+
guardSubcommand(args, firstArg, PROVIDERS_HELP, out, err, firstArg === "models" ? -1 : 1)
|
|
67
59
|
const cwdArg = getArg("--cwd")
|
|
68
60
|
// Audit #07: local hanya bila operator opt-in (aturan universal — sync
|
|
69
|
-
// tanpa flag tak boleh menghubungi endpoint repo tak dikenal).
|
|
70
|
-
|
|
71
|
-
const allowLocal =
|
|
72
|
-
args.includes("--allow-local-config") || process.env.MINICODE_ALLOW_LOCAL_CONFIG === "1"
|
|
61
|
+
// tanpa flag tak boleh menghubungi endpoint repo tak dikenal).
|
|
62
|
+
const allowLocal = allowLocalSubcommand(args)
|
|
73
63
|
const cfg = await loadConfig(cwdArg, { allowLocal })
|
|
74
64
|
if (firstArg === "providers") {
|
|
75
65
|
if (cfg.providers.length === 0) {
|
|
76
|
-
|
|
66
|
+
out(
|
|
77
67
|
"(no providers yet - run `minicode` for the wizard, `minicode auth login` (free, no API key),\nor `minicode config add --baseUrl <url> --apiKey <key>`)",
|
|
78
68
|
)
|
|
79
69
|
process.exit(0)
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
// padEnd(16) manual sebelumnya rusak begitu id lebih dari 16 karakter.
|
|
83
|
-
const health = healthMap(cfg, readTraces(cwdArg))
|
|
71
|
+
const health = healthMap(cfg, readTraceRows<TraceRow>(cwdArg, "traces.jsonl"))
|
|
84
72
|
const rows = cfg.providers.map((p) => {
|
|
85
73
|
const h = health.get(p.id)
|
|
86
74
|
const status = !h
|
|
@@ -89,13 +77,13 @@ export async function handleProviders(
|
|
|
89
77
|
h.ts ? new Date(h.ts).toISOString().slice(0, 10) : "-",
|
|
90
78
|
)}`
|
|
91
79
|
return {
|
|
92
|
-
id: c.cyan(p.id),
|
|
80
|
+
id: c.cyan(sanitizeAnsiLine(p.id)),
|
|
93
81
|
models: String(p.models.length),
|
|
94
|
-
url: p.baseUrl,
|
|
82
|
+
url: sanitizeAnsiLine(p.baseUrl),
|
|
95
83
|
status,
|
|
96
84
|
}
|
|
97
85
|
})
|
|
98
|
-
|
|
86
|
+
out(
|
|
99
87
|
`\n${c.bold("LLM Providers")}\n` +
|
|
100
88
|
renderTable(
|
|
101
89
|
[
|
|
@@ -108,63 +96,54 @@ export async function handleProviders(
|
|
|
108
96
|
) +
|
|
109
97
|
"\n",
|
|
110
98
|
)
|
|
111
|
-
|
|
99
|
+
out(
|
|
112
100
|
` ${c.dim("next: minicode models | minicode sync | minicode config add --baseUrl <url> --apiKey <key>")}\n`,
|
|
113
101
|
)
|
|
114
102
|
process.exit(0)
|
|
115
103
|
}
|
|
116
104
|
if (firstArg === "models") {
|
|
117
|
-
const pid = args
|
|
118
|
-
const
|
|
119
|
-
const filter = (matchIdx >= 0 && args[matchIdx + 1] ? args[matchIdx + 1]! : "").toLowerCase()
|
|
105
|
+
const pid = positionalSubArg(args, 1)
|
|
106
|
+
const filter = (getArg("--match") ?? "").toLowerCase()
|
|
120
107
|
const match = (s: string) => (filter ? s.toLowerCase().includes(filter) : true)
|
|
121
108
|
if (pid) {
|
|
122
109
|
const p = cfg.providers.find((x) => x.id === pid)
|
|
123
110
|
if (!p) {
|
|
124
|
-
|
|
111
|
+
err(`provider "${sanitizeAnsiLine(pid)}" not found - see: minicode providers`)
|
|
125
112
|
process.exit(1)
|
|
126
113
|
}
|
|
127
114
|
const list = p.models.filter(match)
|
|
128
|
-
if (!list.length)
|
|
129
|
-
for (const [i, m] of list.entries())
|
|
115
|
+
if (!list.length) out(` (no matches for "${sanitizeAnsiLine(filter)}")`)
|
|
116
|
+
for (const [i, m] of list.entries()) out(` [${i}] ${sanitizeAnsiLine(m)}`)
|
|
130
117
|
} else {
|
|
131
|
-
if (cfg.providers.length === 0)
|
|
118
|
+
if (cfg.providers.length === 0) out("(no providers yet)")
|
|
132
119
|
let shown = 0
|
|
133
120
|
for (const p of cfg.providers) {
|
|
134
121
|
const list = p.models.filter(match)
|
|
135
122
|
if (!list.length) continue
|
|
136
|
-
|
|
137
|
-
// hasil probe jaringan — sanitasi sebelum masuk scrollback.
|
|
138
|
-
console.log(
|
|
123
|
+
out(
|
|
139
124
|
`${sanitizeAnsiLine(p.id)} (${sanitizeAnsiLine(p.baseUrl)})${filter ? ` - matches "${sanitizeAnsiLine(filter)}"` : ""}`,
|
|
140
125
|
)
|
|
141
126
|
shown += list.length
|
|
142
|
-
for (const m of list.slice(0, 10))
|
|
143
|
-
if (filter && list.length > 10)
|
|
144
|
-
if (!filter && p.models.length > 10)
|
|
127
|
+
for (const m of list.slice(0, 10)) out(` ${sanitizeAnsiLine(m)}`)
|
|
128
|
+
if (filter && list.length > 10) out(` … +${list.length - 10} more`)
|
|
129
|
+
if (!filter && p.models.length > 10) out(` … +${p.models.length - 10} more`)
|
|
145
130
|
}
|
|
146
|
-
|
|
147
|
-
// mencetak judul lalu "(no matches)", dua baris untuk nol informasi.
|
|
148
|
-
if (filter && shown === 0) console.log(` (no matches for "${sanitizeAnsiLine(filter)}")`)
|
|
131
|
+
if (filter && shown === 0) out(` (no matches for "${sanitizeAnsiLine(filter)}")`)
|
|
149
132
|
}
|
|
150
133
|
process.exit(0)
|
|
151
134
|
}
|
|
152
135
|
if (firstArg === "sync") {
|
|
153
|
-
|
|
136
|
+
out("Syncing model list from providers…")
|
|
154
137
|
const { updated, failed } = await refreshProviderModels({ cwd: cwdArg, allowLocal })
|
|
155
138
|
for (const r of updated)
|
|
156
|
-
|
|
157
|
-
` ${c.green(glyphs.check)} ${sanitizeAnsiLine(r.id)}: ${r.from} -> ${r.to} model`,
|
|
158
|
-
)
|
|
139
|
+
out(` ${c.green("ok")} ${sanitizeAnsiLine(r.id)}: ${r.from} -> ${r.to} model`)
|
|
159
140
|
for (const f of failed)
|
|
160
|
-
|
|
161
|
-
` ${c.red(glyphs.cross)} ${sanitizeAnsiLine(f.id)}: ${sanitizeAnsiLine(f.reason)}`,
|
|
162
|
-
)
|
|
141
|
+
out(` ${c.red("failed")} ${sanitizeAnsiLine(f.id)}: ${sanitizeAnsiLine(f.reason)}`)
|
|
163
142
|
if (!updated.length && !failed.length) {
|
|
164
143
|
const cfgHere = await loadConfig(cwdArg, { allowLocal })
|
|
165
144
|
if (cfgHere.providers.length === 0)
|
|
166
|
-
|
|
167
|
-
else
|
|
145
|
+
out(" (no providers yet - run `minicode config add` first)")
|
|
146
|
+
else out(" (no changes — check API key and network, then retry)")
|
|
168
147
|
}
|
|
169
148
|
process.exit(0)
|
|
170
149
|
}
|