Lines 1-28javascript
1// Ollama + phi4-mini auto-setup (ADR-0047) for the vkm-spec local drafting layer.
2// Under `--full` the whole stack installs WITHOUT questions (user decision, 4.0.0 plan):
3// on Windows that means `winget install Ollama.Ollama --silent` when the binary is
4// missing, then `ollama pull phi4-mini:3.8b-q4_K_M` (~2.3GB download, logged loudly).
5// Everything here is BEST-EFFORT by contract: vkm-spec's deterministic fallback is a
6// CI-pinned invariant, so a failed/skipped Ollama setup degrades the experience, never
7// breaks it. Non-Windows platforms get the exact command to run instead of a pipe-to-shell
8// install (never curl|sh on the user's behalf).
9import { execa } from "execa";
10import pc from "picocolors";
12export const OLLAMA_MODEL = "phi4-mini:3.8b-q4_K_M";
13/** Structured outputs via `format` need ≥0.5.13 for phi4-mini (model requirement). */
14export const OLLAMA_MIN_VERSION = "0.5.13";
16/** `ollama --version` → semver string or null (missing/unrunnable binary). */
17export async function ollamaVersion() {
18 const res = await execa("ollama", ["--version"], { reject: false });
19 if (res.failed || res.exitCode !== 0) return null;
20 return res.stdout?.match(/(\d+\.\d+\.\d+)/)?.[1] ?? null;
HighSandbox Evasion Gated Capability
Source gates dangerous network, credential, or execution behavior behind CI, host, platform, time, or geo fingerprint checks.
src/ollama-setup.mjsView on unpkg · L8 23/** Best-effort numeric compare: is `version` ≥ `min`? */
24export function versionAtLeast(version, min) {
25 const a = String(version).split(".").map(Number);
26 const b = String(min).split(".").map(Number);
27 for (let i = 0; i < 3; i++) {
28 if ((a[i] || 0) > (b[i] || 0)) return true;