@vibgrate/cli 2026.727.4 → 2026.728.2
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/dist/baseline-MRUM2P6H.js +8 -0
- package/dist/{baseline-ENCOSJYQ.js.map → baseline-MRUM2P6H.js.map} +1 -1
- package/dist/{chunk-K7REHDQS.js → chunk-6HX47EBL.js} +25 -19
- package/dist/chunk-6HX47EBL.js.map +1 -0
- package/dist/{chunk-MAUJTPQW.js → chunk-A2IYFNCQ.js} +24 -62
- package/dist/chunk-A2IYFNCQ.js.map +1 -0
- package/dist/{chunk-YKVH2PGF.js → chunk-GQTWDKMJ.js} +93 -141
- package/dist/chunk-GQTWDKMJ.js.map +1 -0
- package/dist/{chunk-FPEOIS7K.js → chunk-IWP7MYIA.js} +10 -7
- package/dist/chunk-IWP7MYIA.js.map +1 -0
- package/dist/{chunk-77LYGXBI.js → chunk-JRAGO6OB.js} +3 -3
- package/dist/{chunk-77LYGXBI.js.map → chunk-JRAGO6OB.js.map} +1 -1
- package/dist/{chunk-HYRAILGM.js → chunk-NTW5UEKT.js} +3 -3
- package/dist/{chunk-HYRAILGM.js.map → chunk-NTW5UEKT.js.map} +1 -1
- package/dist/chunk-OSD546W7.js +167 -0
- package/dist/chunk-OSD546W7.js.map +1 -0
- package/dist/{chunk-XPJZTSY7.js → chunk-R2QNFXE5.js} +3 -3
- package/dist/{chunk-XPJZTSY7.js.map → chunk-R2QNFXE5.js.map} +1 -1
- package/dist/{chunk-PXHNTC6D.js → chunk-SIPGDJT4.js} +3 -3
- package/dist/{chunk-PXHNTC6D.js.map → chunk-SIPGDJT4.js.map} +1 -1
- package/dist/{chunk-YCJIIGLP.js → chunk-UIOBFLE6.js} +3 -3
- package/dist/{chunk-YCJIIGLP.js.map → chunk-UIOBFLE6.js.map} +1 -1
- package/dist/chunk-UZJS7GMK.js +57 -0
- package/dist/chunk-UZJS7GMK.js.map +1 -0
- package/dist/{chunk-R6ZRVVZT.js → chunk-WH2N22S3.js} +3 -3
- package/dist/{chunk-R6ZRVVZT.js.map → chunk-WH2N22S3.js.map} +1 -1
- package/dist/{chunk-LJP2EPKM.js → chunk-WY6DGTBP.js} +4 -4
- package/dist/{chunk-LJP2EPKM.js.map → chunk-WY6DGTBP.js.map} +1 -1
- package/dist/{chunk-KXSKFQMI.js → chunk-YF43FOPP.js} +5 -5
- package/dist/chunk-YF43FOPP.js.map +1 -0
- package/dist/{chunk-T3AYRS7J.js → chunk-ZFTFCM7B.js} +3 -3
- package/dist/{chunk-T3AYRS7J.js.map → chunk-ZFTFCM7B.js.map} +1 -1
- package/dist/cli.js +129 -32
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/{interactive-SMHVURYK.js → interactive-36ZZ64WL.js} +15 -14
- package/dist/interactive-36ZZ64WL.js.map +1 -0
- package/dist/{llm-host-7GWDO6IX.js → llm-host-XYBT4267.js} +4 -4
- package/dist/{llm-host-7GWDO6IX.js.map → llm-host-XYBT4267.js.map} +1 -1
- package/dist/model-manager-OEPY4I7W.js +10 -0
- package/dist/{model-manager-PN7HEDXD.js.map → model-manager-OEPY4I7W.js.map} +1 -1
- package/dist/{runtime-session-4AMZIAAG.js → runtime-session-EJQZXANB.js} +5 -5
- package/dist/{runtime-session-4AMZIAAG.js.map → runtime-session-EJQZXANB.js.map} +1 -1
- package/dist/{session-W3646AOV.js → session-ZJGENHKX.js} +6 -5
- package/dist/{session-W3646AOV.js.map → session-ZJGENHKX.js.map} +1 -1
- package/dist/{stream-json-X7UQFB4T.js → stream-json-Z5KC2DM3.js} +6 -5
- package/dist/stream-json-Z5KC2DM3.js.map +1 -0
- package/dist/{vgd-CVLKBS7K.js → vgd-3MHSB4KA.js} +4 -4
- package/dist/vgd-3MHSB4KA.js.map +1 -0
- package/package.json +1 -1
- package/dist/baseline-ENCOSJYQ.js +0 -8
- package/dist/chunk-FPEOIS7K.js.map +0 -1
- package/dist/chunk-K7REHDQS.js.map +0 -1
- package/dist/chunk-KUIBP3LU.js +0 -101
- package/dist/chunk-KUIBP3LU.js.map +0 -1
- package/dist/chunk-KXSKFQMI.js.map +0 -1
- package/dist/chunk-MAUJTPQW.js.map +0 -1
- package/dist/chunk-YKVH2PGF.js.map +0 -1
- package/dist/interactive-SMHVURYK.js.map +0 -1
- package/dist/model-manager-PN7HEDXD.js +0 -9
- package/dist/stream-json-X7UQFB4T.js.map +0 -1
- package/dist/vgd-CVLKBS7K.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/model-install-plan.ts","../src/runtime/model-manager.ts"],"names":[],"mappings":";;;;;AAaO,IAAM,iCAAA,GAAoC,sBAAA;AAkF1C,SAAS,sBAAsB,OAAA,EAAuC;AAC3E,EAAA,MAAM,CAAA,GAAI,QAAQ,WAAA,EAAY;AAC9B,EAAA,IAAI,CAAA,KAAM,WAAA,IAAe,CAAA,KAAM,WAAA,IAAe,MAAM,UAAA,EAAY;AAC9D,IAAA,OAAO;AAAA,MACL;AAAA,QACE,EAAA,EAAI,gBAAA;AAAA,QACJ,IAAA,EAAM,aAAA;AAAA,QACN,IAAA,EAAM,mBAAA;AAAA,QACN,MAAA,EAAQ;AAAA;AACV,KACF;AAAA,EACF;AACA,EAAA,IAAI,MAAM,QAAA,EAAU;AAClB,IAAA,OAAO;AAAA,MACL;AAAA,QACE,EAAA,EAAI,QAAA;AAAA,QACJ,IAAA,EAAM,eAAA;AAAA,QACN,MAAA,EAAQ,QAAA;AAAA,QACR,MAAA,EAAQ;AAAA;AACV,KACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAC;AACV;AAEO,SAAS,wBAAA,CACd,SACA,IAAA,EACwC;AACxC,EAAA,MAAM,CAAA,GAAI,QAAQ,WAAA,EAAY;AAC9B,EAAA,IAAI,CAAA,KAAM,UAAU,OAAO,QAAA;AAC3B,EAAA,IAAI,CAAA,KAAM,WAAA,IAAe,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A,IACxB;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,SAAS,KAAA,EAAO,SAAA,EAAW,QAAQ,QAAA,EAAS;AACjE","file":"chunk-YCJIIGLP.js","sourcesContent":["/**\n * Model install plan — pure dependency closure for a provider + pack/weights.\n *\n * Used by `vg models install` / `pull` (and hosts that mirror them). Planning is\n * side-effect free; execution lives in `model-install.ts`.\n *\n * schemaVersion: model-install-plan/0\n */\n\nimport { isPackageInstalled } from '../code/ensure.js';\nimport type { PackWeightsRef } from './model-orchestrator.js';\nimport { isWeightCached, lookupCatalog } from './weight-store.js';\n\nexport const MODEL_INSTALL_PLAN_SCHEMA_VERSION = 'model-install-plan/0' as const;\n\nexport type RuntimeDepKind = 'npm-runtime' | 'native-binary' | 'weights';\n\n/** Dep/weight readiness: `manual` = user must supply path/app (we do not auto-fetch). */\nexport type DepStatus = 'satisfied' | 'missing' | 'unmanaged' | 'manual';\n\nexport interface ProviderRuntimeDep {\n id: string;\n kind: RuntimeDepKind;\n /** npm install spec, e.g. `node-llama-cpp@^3`. */\n spec?: string;\n /** PATH binary name for native-binary deps. */\n binary?: string;\n /** One-line human reason. */\n reason: string;\n /** When true, npm install may need scripts (surfaced in plan only). */\n requiresInstallScripts?: boolean;\n}\n\nexport interface PlannedDep extends ProviderRuntimeDep {\n status: DepStatus;\n}\n\nexport interface ModelInstallPlan {\n schemaVersion: typeof MODEL_INSTALL_PLAN_SCHEMA_VERSION;\n provider: string;\n backend: string;\n model: string;\n mode?: string;\n packId?: string;\n license?: string;\n promise?: string;\n fit?: string;\n runtimeDeps: PlannedDep[];\n weights: {\n channel: 'ollama' | 'local-path' | 'manual' | 'vibgrate';\n ref: string;\n status: DepStatus;\n /** First-party or pack download URL when channel is vibgrate. */\n downloadUrl?: string;\n };\n /** Ids already present (runtime + weights). */\n alreadySatisfied: string[];\n /** npm specs / binary ids we will install (never third-party apps). */\n willInstall: string[];\n /** Weight refs we will download via the backend channel. */\n willDownload: string[];\n /** Things the user must fix outside vg (e.g. install Ollama.app). */\n blocked: Array<{ id: string; reason: string }>;\n offlineBlocked: boolean;\n /** True when nothing remains to install/download and nothing is blocked. */\n ready: boolean;\n}\n\nexport interface BuildInstallPlanInput {\n backend: PackWeightsRef['backend'] | string;\n weightsRef: string;\n license?: string;\n mode?: string;\n packId?: string;\n promise?: string;\n fit?: string;\n /** Discovered local model names (Ollama / LM Studio / gguf). */\n installedNames?: string[];\n /** When true, network install/download is forbidden. */\n offline?: boolean;\n /** Injectable binary probe (defaults: which/where style via injected map). */\n hasBinary?: (name: string) => boolean;\n /** Injectable npm package probe. */\n isPackageInstalled?: (spec: string) => boolean;\n /** Optional local GGUF path (llama.cpp) — when set, weights are satisfied. */\n modelPath?: string;\n /** Pack/catalog HTTPS URL for first-party GGUF download. */\n downloadUrl?: string;\n /** Optional sha256 for first-party download. */\n sha256?: string;\n /** Injectable weight-cache probe (tests). */\n isWeightCached?: (ref: string) => boolean;\n}\n\n/** Runtime deps declared per backend (not third-party app installers). */\nexport function runtimeDepsForBackend(backend: string): ProviderRuntimeDep[] {\n const b = backend.toLowerCase();\n if (b === 'llama.cpp' || b === 'llama-cpp' || b === 'vibgrate') {\n return [\n {\n id: 'node-llama-cpp',\n kind: 'npm-runtime',\n spec: 'node-llama-cpp@^3',\n reason: 'in-process llama.cpp binding for the first-party / llama-cpp provider',\n },\n ];\n }\n if (b === 'ollama') {\n return [\n {\n id: 'ollama',\n kind: 'native-binary',\n binary: 'ollama',\n reason: 'Ollama on PATH (install from https://ollama.com — third-party apps are not auto-installed)',\n },\n ];\n }\n // LM Studio / Foundry / other: weights managed externally; no auto deps.\n return [];\n}\n\nexport function weightsChannelForBackend(\n backend: string,\n opts?: { downloadUrl?: string; weightsRef?: string },\n): ModelInstallPlan['weights']['channel'] {\n const b = backend.toLowerCase();\n if (b === 'ollama') return 'ollama';\n if (b === 'llama.cpp' || b === 'llama-cpp' || b === 'vibgrate') {\n // Prefer first-party store when we have a catalog/pack URL for this ref.\n if (opts?.downloadUrl || (opts?.weightsRef && lookupCatalog(opts.weightsRef))) return 'vibgrate';\n return 'local-path';\n }\n if (b === 'lm-studio' || b === 'lmstudio' || b === 'foundry-local') return 'manual';\n return 'manual';\n}\n\nfunction weightsInstalled(ref: string, installedNames: string[]): boolean {\n const want = ref.toLowerCase();\n return installedNames.some((n) => {\n const have = n.toLowerCase();\n return have === want || have.includes(want) || want.includes(have);\n });\n}\n\n/**\n * Build a side-effect-free install plan for a backend + weight ref.\n */\nexport function buildModelInstallPlan(input: BuildInstallPlanInput): ModelInstallPlan {\n const hasBinary = input.hasBinary ?? (() => false);\n const pkgInstalled = input.isPackageInstalled ?? isPackageInstalled;\n const installedNames = input.installedNames ?? [];\n const offline = !!input.offline;\n const backend = input.backend;\n const provider = providerLabel(backend);\n\n const runtimeDeps: PlannedDep[] = runtimeDepsForBackend(backend).map((dep) => {\n if (dep.kind === 'npm-runtime' && dep.spec) {\n return { ...dep, status: pkgInstalled(dep.spec) ? 'satisfied' : 'missing' };\n }\n if (dep.kind === 'native-binary' && dep.binary) {\n // Present → satisfied; absent → unmanaged (we never install third-party apps).\n return { ...dep, status: hasBinary(dep.binary) ? 'satisfied' : 'unmanaged' };\n }\n return { ...dep, status: 'unmanaged' as const };\n });\n\n const channel = weightsChannelForBackend(backend, {\n downloadUrl: input.downloadUrl,\n weightsRef: input.weightsRef,\n });\n const weightCached = (input.isWeightCached ?? isWeightCached)(input.weightsRef);\n const catalog = lookupCatalog(input.weightsRef);\n const downloadUrl = input.downloadUrl ?? catalog?.url;\n\n let weightsStatus: DepStatus = 'missing';\n if (channel === 'ollama') {\n weightsStatus = weightsInstalled(input.weightsRef, installedNames) ? 'satisfied' : 'missing';\n } else if (channel === 'vibgrate') {\n weightsStatus =\n weightCached || weightsInstalled(input.weightsRef, installedNames) || !!input.modelPath ? 'satisfied' : 'missing';\n } else if (channel === 'local-path') {\n // Satisfied only when caller reports the model (path) already discoverable.\n weightsStatus = weightsInstalled(input.weightsRef, installedNames) || !!input.modelPath || weightCached ? 'satisfied' : 'manual';\n } else {\n weightsStatus = weightsInstalled(input.weightsRef, installedNames) ? 'satisfied' : 'manual';\n }\n\n const alreadySatisfied: string[] = [];\n const willInstall: string[] = [];\n const willDownload: string[] = [];\n const blocked: Array<{ id: string; reason: string }> = [];\n\n for (const dep of runtimeDeps) {\n if (dep.status === 'satisfied') {\n alreadySatisfied.push(dep.id);\n continue;\n }\n if (dep.kind === 'npm-runtime' && dep.spec && dep.status === 'missing') {\n if (offline) {\n blocked.push({ id: dep.id, reason: `${dep.spec} needed but --local/offline forbids install` });\n } else {\n willInstall.push(dep.spec);\n }\n continue;\n }\n if (dep.kind === 'native-binary' && dep.status === 'unmanaged') {\n blocked.push({\n id: dep.id,\n reason: dep.reason,\n });\n }\n }\n\n if (weightsStatus === 'satisfied') {\n alreadySatisfied.push(`weights:${input.weightsRef}`);\n } else if (weightsStatus === 'missing' && (channel === 'ollama' || channel === 'vibgrate')) {\n if (offline) {\n blocked.push({ id: `weights:${input.weightsRef}`, reason: 'weights missing and --local/offline forbids download' });\n } else if (channel === 'ollama' && runtimeDeps.some((d) => d.id === 'ollama' && d.status === 'unmanaged')) {\n willDownload.push(input.weightsRef);\n } else if (channel === 'vibgrate' && !downloadUrl) {\n blocked.push({\n id: `weights:${input.weightsRef}`,\n reason: `no first-party download URL for ${input.weightsRef} — place a gguf in the weight store or pass --model-path`,\n });\n } else {\n willDownload.push(input.weightsRef);\n }\n } else if (weightsStatus === 'manual' || weightsStatus === 'missing') {\n blocked.push({\n id: `weights:${input.weightsRef}`,\n reason:\n channel === 'local-path'\n ? `point --model-path at a local gguf for ${input.weightsRef}, or run install when a first-party URL is catalogued`\n : `install or link weights for ${input.weightsRef} via the backend app`,\n });\n }\n\n // Under offline, do not claim we will download/install — those land in blocked.\n const effectiveWillInstall = offline ? [] : willInstall;\n const effectiveWillDownload = offline ? [] : willDownload;\n const offlineBlocked = offline && blocked.some((b) => /offline|forbids/i.test(b.reason));\n\n const allRuntimeOk = runtimeDeps.every((d) => d.status === 'satisfied');\n const fullyReady = allRuntimeOk && weightsStatus === 'satisfied' && blocked.length === 0;\n\n return {\n schemaVersion: MODEL_INSTALL_PLAN_SCHEMA_VERSION,\n provider,\n backend,\n model: input.weightsRef,\n mode: input.mode,\n packId: input.packId,\n license: input.license,\n promise: input.promise,\n fit: input.fit,\n runtimeDeps,\n weights: {\n channel,\n ref: input.weightsRef,\n status: weightsStatus,\n downloadUrl: channel === 'vibgrate' ? downloadUrl : undefined,\n },\n alreadySatisfied,\n willInstall: effectiveWillInstall,\n willDownload: effectiveWillDownload,\n blocked,\n offlineBlocked,\n ready: fullyReady,\n };\n}\n\nfunction providerLabel(backend: string): string {\n const b = backend.toLowerCase();\n if (b === 'llama.cpp' || b === 'llama-cpp') return 'llama-cpp';\n if (b === 'vibgrate') return 'vibgrate';\n if (b === 'lm-studio' || b === 'lmstudio') return 'lmstudio';\n if (b === 'foundry-local') return 'foundry-local';\n return b === 'ollama' ? 'ollama' : backend;\n}\n","/**\n * Model manager identity + runtime ensure.\n *\n * **Code Modes** always use the first-party **Vibgrate** manager (embedded\n * llama.cpp / vgd host-broker + weight store). Custom local/hosted backends\n * (Ollama, LM Studio, OpenRouter, …) are explicit user choices; when chosen we\n * silently install *our* installable runtime packages for that path (npm\n * bindings), never third-party desktop apps. The user sees a short badge for\n * which manager ran.\n */\n\nimport { spawnSync } from 'node:child_process';\nimport { ensurePackage, isPackageInstalled, type EnsureOptions } from '../code/ensure.js';\nimport { runtimeDepsForBackend } from './model-install-plan.js';\n\n/** Durable manager ids surfaced in badges and JSON. */\nexport type ModelManagerId =\n | 'vibgrate'\n | 'ollama'\n | 'lmstudio'\n | 'foundry-local'\n | 'openrouter'\n | 'litellm'\n | 'openai'\n | 'together'\n | 'mock'\n | 'other';\n\nexport interface ManagerBadge {\n id: ModelManagerId;\n /** Short product label, e.g. \"Vibgrate\". */\n label: string;\n /** Compact badge for CLI/UI, e.g. \"[Vibgrate]\". */\n badge: string;\n /** One-line after-run note. */\n note: string;\n}\n\nconst LABELS: Record<ModelManagerId, { label: string; note: string }> = {\n vibgrate: {\n label: 'Vibgrate',\n note: 'Code Mode · first-party model manager (embedded inference)',\n },\n ollama: {\n label: 'Ollama',\n note: 'Custom local · Ollama',\n },\n lmstudio: {\n label: 'LM Studio',\n note: 'Custom local · LM Studio',\n },\n 'foundry-local': {\n label: 'Foundry Local',\n note: 'Custom local · Foundry Local',\n },\n openrouter: {\n label: 'OpenRouter',\n note: 'Custom hosted · OpenRouter',\n },\n litellm: {\n label: 'LiteLLM',\n note: 'Custom hosted · LiteLLM',\n },\n openai: {\n label: 'OpenAI',\n note: 'Custom hosted · OpenAI',\n },\n together: {\n label: 'Together',\n note: 'Custom hosted · Together',\n },\n mock: {\n label: 'Mock',\n note: 'Scripted offline provider',\n },\n other: {\n label: 'Custom',\n note: 'Custom model backend',\n },\n};\n\n/** Map a provider id (`llama-cpp`, `ollama`, …) to a manager badge. */\nexport function managerFromProviderId(providerId: string | undefined | null): ModelManagerId {\n const id = (providerId ?? '').toLowerCase().trim();\n if (id === 'llama-cpp' || id === 'llama.cpp' || id === 'vibgrate' || id === 'vibgrate-store') return 'vibgrate';\n if (id === 'ollama') return 'ollama';\n if (id === 'lmstudio' || id === 'lm-studio') return 'lmstudio';\n if (id === 'foundry-local' || id === 'foundry') return 'foundry-local';\n if (id === 'openrouter') return 'openrouter';\n if (id === 'litellm') return 'litellm';\n if (id === 'openai') return 'openai';\n if (id === 'together') return 'together';\n if (id === 'mock' || id === 'scripted') return 'mock';\n return 'other';\n}\n\nexport function managerBadge(id: ModelManagerId): ManagerBadge {\n const meta = LABELS[id] ?? LABELS.other;\n return {\n id,\n label: meta.label,\n badge: `[${meta.label}]`,\n note: meta.note,\n };\n}\n\nexport function formatManagerBadgeLine(id: ModelManagerId, model?: string): string {\n const b = managerBadge(id);\n const modelPart = model ? ` · ${model}` : '';\n return `${b.badge} ${b.note}${modelPart}`;\n}\n\nexport interface EnsureManagerRuntimeOptions {\n /** Provider id that will run (llama-cpp, ollama, …). */\n providerId: string;\n /** Model id for weight pull when the backend supports it. */\n model?: string;\n /** `--local` / offline — no network install. */\n offline?: boolean;\n /**\n * Consent to install npm runtime packages (and ollama pull when binary is\n * present). True when the user chose a custom provider/model or passed --yes.\n */\n consent?: boolean;\n /** Injectable ensure (tests). */\n ensurePackage?: typeof ensurePackage;\n /** Injectable PATH binary probe. */\n hasBinary?: (name: string) => boolean;\n /** Injectable ollama pull. */\n ollamaPull?: (name: string) => number;\n onProgress?: (line: string) => void;\n}\n\nexport interface EnsureManagerRuntimeResult {\n ok: boolean;\n manager: ModelManagerId;\n badge: ManagerBadge;\n /** npm specs installed this call. */\n installed: string[];\n /** Weight refs pulled (e.g. ollama pull). */\n pulled: string[];\n /** Non-fatal notes (e.g. app already present). */\n messages: string[];\n error?: string;\n}\n\nfunction defaultHasBinary(name: string): boolean {\n const res = spawnSync(name, ['--version'], { stdio: 'ignore', encoding: 'utf8' });\n // Some CLIs use subcommands; try bare which-style.\n if (res.status === 0) return true;\n const which = spawnSync(process.platform === 'win32' ? 'where' : 'which', [name], {\n stdio: 'ignore',\n encoding: 'utf8',\n });\n return which.status === 0;\n}\n\n/**\n * Silently install *installable* runtime deps for the chosen manager.\n * Never installs third-party desktop apps (Ollama.app, LM Studio) — those\n * remain user-managed; we only install npm packages into the Vibgrate runtime\n * cache and pull weights when the backend binary is already on PATH.\n */\nexport async function ensureManagerRuntime(\n opts: EnsureManagerRuntimeOptions,\n): Promise<EnsureManagerRuntimeResult> {\n const manager = managerFromProviderId(opts.providerId);\n const badge = managerBadge(manager);\n const installed: string[] = [];\n const pulled: string[] = [];\n const messages: string[] = [];\n const ensure = opts.ensurePackage ?? ensurePackage;\n const hasBinary = opts.hasBinary ?? defaultHasBinary;\n\n // Hosted OpenAI-compatible backends: no local packages.\n if (\n manager === 'openrouter' ||\n manager === 'litellm' ||\n manager === 'openai' ||\n manager === 'together' ||\n manager === 'mock'\n ) {\n return { ok: true, manager, badge, installed, pulled, messages };\n }\n\n // LM Studio / Foundry: HTTP clients only — no auto app install (ADR-005).\n if (manager === 'lmstudio' || manager === 'foundry-local') {\n messages.push(\n manager === 'lmstudio'\n ? 'LM Studio must already be running with a model loaded (we never install the app)'\n : 'Foundry Local must already be running (we never install the app)',\n );\n return { ok: true, manager, badge, installed, pulled, messages };\n }\n\n const backend =\n manager === 'vibgrate' ? 'llama.cpp' : manager === 'ollama' ? 'ollama' : opts.providerId;\n const deps = runtimeDepsForBackend(backend);\n\n for (const dep of deps) {\n if (dep.kind === 'npm-runtime' && dep.spec) {\n if (isPackageInstalled(dep.spec)) {\n messages.push(`${dep.id} already installed`);\n continue;\n }\n if (opts.offline) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `${dep.spec} needed but offline/--local forbids install`,\n };\n }\n if (!opts.consent) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `${dep.spec} needed — pass --yes or run \\`vg models install\\` once`,\n };\n }\n opts.onProgress?.(`installing ${dep.spec}`);\n const ensureOpts: EnsureOptions = {\n consent: true,\n local: false,\n interactive: false,\n };\n const res = await ensure(dep.spec, ensureOpts);\n if (!res.module) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `couldn't install ${dep.spec}`,\n };\n }\n installed.push(dep.spec);\n continue;\n }\n if (dep.kind === 'native-binary' && dep.binary) {\n if (!hasBinary(dep.binary)) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error:\n dep.reason ||\n `${dep.binary} is not on PATH — install it once, then re-run (vg never auto-installs third-party apps)`,\n };\n }\n messages.push(`${dep.binary} on PATH`);\n }\n }\n\n // Optional: when user chose a custom Ollama model, pull weights if missing.\n if (manager === 'ollama' && opts.model && opts.consent && !opts.offline) {\n const list = spawnSync('ollama', ['list'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });\n const have =\n list.status === 0 &&\n (list.stdout ?? '')\n .split('\\n')\n .slice(1)\n .some((line) => {\n const name = line.trim().split(/\\s+/)[0]?.toLowerCase();\n return name === opts.model!.toLowerCase() || name?.startsWith(`${opts.model!.toLowerCase()}:`);\n });\n if (!have) {\n opts.onProgress?.(`pulling ${opts.model}`);\n const pull = opts.ollamaPull ?? ((name: string) => spawnSync('ollama', ['pull', name], { stdio: 'ignore' }).status ?? 1);\n const status = pull(opts.model);\n if (status !== 0) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `ollama pull ${opts.model} failed (exit ${status})`,\n };\n }\n pulled.push(opts.model);\n }\n }\n\n return { ok: true, manager, badge, installed, pulled, messages };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/runtime/model-install-plan.ts","../src/runtime/model-manager.ts"],"names":[],"mappings":";;;;;AAaO,IAAM,iCAAA,GAAoC,sBAAA;AAkF1C,SAAS,sBAAsB,OAAA,EAAuC;AAC3E,EAAA,MAAM,CAAA,GAAI,QAAQ,WAAA,EAAY;AAC9B,EAAA,IAAI,CAAA,KAAM,WAAA,IAAe,CAAA,KAAM,WAAA,IAAe,MAAM,UAAA,EAAY;AAC9D,IAAA,OAAO;AAAA,MACL;AAAA,QACE,EAAA,EAAI,gBAAA;AAAA,QACJ,IAAA,EAAM,aAAA;AAAA,QACN,IAAA,EAAM,mBAAA;AAAA,QACN,MAAA,EAAQ;AAAA;AACV,KACF;AAAA,EACF;AACA,EAAA,IAAI,MAAM,QAAA,EAAU;AAClB,IAAA,OAAO;AAAA,MACL;AAAA,QACE,EAAA,EAAI,QAAA;AAAA,QACJ,IAAA,EAAM,eAAA;AAAA,QACN,MAAA,EAAQ,QAAA;AAAA,QACR,MAAA,EAAQ;AAAA;AACV,KACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAC;AACV;AAEO,SAAS,wBAAA,CACd,SACA,IAAA,EACwC;AACxC,EAAA,MAAM,CAAA,GAAI,QAAQ,WAAA,EAAY;AAC9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A,CAAA;AAAA,SACzD;AAAA,MACF;AACA,MAAA,MAAA,CAAO,IAAA,CAAK,KAAK,KAAK,CAAA;AAAA,IACxB;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,SAAS,KAAA,EAAO,SAAA,EAAW,QAAQ,QAAA,EAAS;AACjE","file":"chunk-UIOBFLE6.js","sourcesContent":["/**\n * Model install plan — pure dependency closure for a provider + pack/weights.\n *\n * Used by `vg models install` / `pull` (and hosts that mirror them). Planning is\n * side-effect free; execution lives in `model-install.ts`.\n *\n * schemaVersion: model-install-plan/0\n */\n\nimport { isPackageInstalled } from '../code/ensure.js';\nimport type { PackWeightsRef } from './model-orchestrator.js';\nimport { isWeightCached, lookupCatalog } from './weight-store.js';\n\nexport const MODEL_INSTALL_PLAN_SCHEMA_VERSION = 'model-install-plan/0' as const;\n\nexport type RuntimeDepKind = 'npm-runtime' | 'native-binary' | 'weights';\n\n/** Dep/weight readiness: `manual` = user must supply path/app (we do not auto-fetch). */\nexport type DepStatus = 'satisfied' | 'missing' | 'unmanaged' | 'manual';\n\nexport interface ProviderRuntimeDep {\n id: string;\n kind: RuntimeDepKind;\n /** npm install spec, e.g. `node-llama-cpp@^3`. */\n spec?: string;\n /** PATH binary name for native-binary deps. */\n binary?: string;\n /** One-line human reason. */\n reason: string;\n /** When true, npm install may need scripts (surfaced in plan only). */\n requiresInstallScripts?: boolean;\n}\n\nexport interface PlannedDep extends ProviderRuntimeDep {\n status: DepStatus;\n}\n\nexport interface ModelInstallPlan {\n schemaVersion: typeof MODEL_INSTALL_PLAN_SCHEMA_VERSION;\n provider: string;\n backend: string;\n model: string;\n mode?: string;\n packId?: string;\n license?: string;\n promise?: string;\n fit?: string;\n runtimeDeps: PlannedDep[];\n weights: {\n channel: 'ollama' | 'local-path' | 'manual' | 'vibgrate';\n ref: string;\n status: DepStatus;\n /** First-party or pack download URL when channel is vibgrate. */\n downloadUrl?: string;\n };\n /** Ids already present (runtime + weights). */\n alreadySatisfied: string[];\n /** npm specs / binary ids we will install (never third-party apps). */\n willInstall: string[];\n /** Weight refs we will download via the backend channel. */\n willDownload: string[];\n /** Things the user must fix outside vg (e.g. install Ollama.app). */\n blocked: Array<{ id: string; reason: string }>;\n offlineBlocked: boolean;\n /** True when nothing remains to install/download and nothing is blocked. */\n ready: boolean;\n}\n\nexport interface BuildInstallPlanInput {\n backend: PackWeightsRef['backend'] | string;\n weightsRef: string;\n license?: string;\n mode?: string;\n packId?: string;\n promise?: string;\n fit?: string;\n /** Discovered local model names (Ollama / LM Studio / gguf). */\n installedNames?: string[];\n /** When true, network install/download is forbidden. */\n offline?: boolean;\n /** Injectable binary probe (defaults: which/where style via injected map). */\n hasBinary?: (name: string) => boolean;\n /** Injectable npm package probe. */\n isPackageInstalled?: (spec: string) => boolean;\n /** Optional local GGUF path (llama.cpp) — when set, weights are satisfied. */\n modelPath?: string;\n /** Pack/catalog HTTPS URL for first-party GGUF download. */\n downloadUrl?: string;\n /** Optional sha256 for first-party download. */\n sha256?: string;\n /** Injectable weight-cache probe (tests). */\n isWeightCached?: (ref: string) => boolean;\n}\n\n/** Runtime deps declared per backend (not third-party app installers). */\nexport function runtimeDepsForBackend(backend: string): ProviderRuntimeDep[] {\n const b = backend.toLowerCase();\n if (b === 'llama.cpp' || b === 'llama-cpp' || b === 'vibgrate') {\n return [\n {\n id: 'node-llama-cpp',\n kind: 'npm-runtime',\n spec: 'node-llama-cpp@^3',\n reason: 'in-process llama.cpp binding for the first-party / llama-cpp provider',\n },\n ];\n }\n if (b === 'ollama') {\n return [\n {\n id: 'ollama',\n kind: 'native-binary',\n binary: 'ollama',\n reason: 'Ollama on PATH (install from https://ollama.com — third-party apps are not auto-installed)',\n },\n ];\n }\n // LM Studio / Foundry / other: weights managed externally; no auto deps.\n return [];\n}\n\nexport function weightsChannelForBackend(\n backend: string,\n opts?: { downloadUrl?: string; weightsRef?: string },\n): ModelInstallPlan['weights']['channel'] {\n const b = backend.toLowerCase();\n if (b === 'ollama') return 'ollama';\n if (b === 'llama.cpp' || b === 'llama-cpp' || b === 'vibgrate') {\n // Prefer first-party store when we have a catalog/pack URL for this ref.\n if (opts?.downloadUrl || (opts?.weightsRef && lookupCatalog(opts.weightsRef))) return 'vibgrate';\n return 'local-path';\n }\n if (b === 'lm-studio' || b === 'lmstudio' || b === 'foundry-local') return 'manual';\n return 'manual';\n}\n\nfunction weightsInstalled(ref: string, installedNames: string[]): boolean {\n const want = ref.toLowerCase();\n return installedNames.some((n) => {\n const have = n.toLowerCase();\n return have === want || have.includes(want) || want.includes(have);\n });\n}\n\n/**\n * Build a side-effect-free install plan for a backend + weight ref.\n */\nexport function buildModelInstallPlan(input: BuildInstallPlanInput): ModelInstallPlan {\n const hasBinary = input.hasBinary ?? (() => false);\n const pkgInstalled = input.isPackageInstalled ?? isPackageInstalled;\n const installedNames = input.installedNames ?? [];\n const offline = !!input.offline;\n const backend = input.backend;\n const provider = providerLabel(backend);\n\n const runtimeDeps: PlannedDep[] = runtimeDepsForBackend(backend).map((dep) => {\n if (dep.kind === 'npm-runtime' && dep.spec) {\n return { ...dep, status: pkgInstalled(dep.spec) ? 'satisfied' : 'missing' };\n }\n if (dep.kind === 'native-binary' && dep.binary) {\n // Present → satisfied; absent → unmanaged (we never install third-party apps).\n return { ...dep, status: hasBinary(dep.binary) ? 'satisfied' : 'unmanaged' };\n }\n return { ...dep, status: 'unmanaged' as const };\n });\n\n const channel = weightsChannelForBackend(backend, {\n downloadUrl: input.downloadUrl,\n weightsRef: input.weightsRef,\n });\n const weightCached = (input.isWeightCached ?? isWeightCached)(input.weightsRef);\n const catalog = lookupCatalog(input.weightsRef);\n const downloadUrl = input.downloadUrl ?? catalog?.url;\n\n let weightsStatus: DepStatus = 'missing';\n if (channel === 'ollama') {\n weightsStatus = weightsInstalled(input.weightsRef, installedNames) ? 'satisfied' : 'missing';\n } else if (channel === 'vibgrate') {\n weightsStatus =\n weightCached || weightsInstalled(input.weightsRef, installedNames) || !!input.modelPath ? 'satisfied' : 'missing';\n } else if (channel === 'local-path') {\n // Satisfied only when caller reports the model (path) already discoverable.\n weightsStatus = weightsInstalled(input.weightsRef, installedNames) || !!input.modelPath || weightCached ? 'satisfied' : 'manual';\n } else {\n weightsStatus = weightsInstalled(input.weightsRef, installedNames) ? 'satisfied' : 'manual';\n }\n\n const alreadySatisfied: string[] = [];\n const willInstall: string[] = [];\n const willDownload: string[] = [];\n const blocked: Array<{ id: string; reason: string }> = [];\n\n for (const dep of runtimeDeps) {\n if (dep.status === 'satisfied') {\n alreadySatisfied.push(dep.id);\n continue;\n }\n if (dep.kind === 'npm-runtime' && dep.spec && dep.status === 'missing') {\n if (offline) {\n blocked.push({ id: dep.id, reason: `${dep.spec} needed but --local/offline forbids install` });\n } else {\n willInstall.push(dep.spec);\n }\n continue;\n }\n if (dep.kind === 'native-binary' && dep.status === 'unmanaged') {\n blocked.push({\n id: dep.id,\n reason: dep.reason,\n });\n }\n }\n\n if (weightsStatus === 'satisfied') {\n alreadySatisfied.push(`weights:${input.weightsRef}`);\n } else if (weightsStatus === 'missing' && (channel === 'ollama' || channel === 'vibgrate')) {\n if (offline) {\n blocked.push({ id: `weights:${input.weightsRef}`, reason: 'weights missing and --local/offline forbids download' });\n } else if (channel === 'ollama' && runtimeDeps.some((d) => d.id === 'ollama' && d.status === 'unmanaged')) {\n willDownload.push(input.weightsRef);\n } else if (channel === 'vibgrate' && !downloadUrl) {\n blocked.push({\n id: `weights:${input.weightsRef}`,\n reason: `no first-party download URL for ${input.weightsRef} — place a gguf in the weight store or pass --model-path`,\n });\n } else {\n willDownload.push(input.weightsRef);\n }\n } else if (weightsStatus === 'manual' || weightsStatus === 'missing') {\n blocked.push({\n id: `weights:${input.weightsRef}`,\n reason:\n channel === 'local-path'\n ? `point --model-path at a local gguf for ${input.weightsRef}, or run install when a first-party URL is catalogued`\n : `install or link weights for ${input.weightsRef} via the backend app`,\n });\n }\n\n // Under offline, do not claim we will download/install — those land in blocked.\n const effectiveWillInstall = offline ? [] : willInstall;\n const effectiveWillDownload = offline ? [] : willDownload;\n const offlineBlocked = offline && blocked.some((b) => /offline|forbids/i.test(b.reason));\n\n const allRuntimeOk = runtimeDeps.every((d) => d.status === 'satisfied');\n const fullyReady = allRuntimeOk && weightsStatus === 'satisfied' && blocked.length === 0;\n\n return {\n schemaVersion: MODEL_INSTALL_PLAN_SCHEMA_VERSION,\n provider,\n backend,\n model: input.weightsRef,\n mode: input.mode,\n packId: input.packId,\n license: input.license,\n promise: input.promise,\n fit: input.fit,\n runtimeDeps,\n weights: {\n channel,\n ref: input.weightsRef,\n status: weightsStatus,\n downloadUrl: channel === 'vibgrate' ? downloadUrl : undefined,\n },\n alreadySatisfied,\n willInstall: effectiveWillInstall,\n willDownload: effectiveWillDownload,\n blocked,\n offlineBlocked,\n ready: fullyReady,\n };\n}\n\nfunction providerLabel(backend: string): string {\n const b = backend.toLowerCase();\n if (b === 'llama.cpp' || b === 'llama-cpp') return 'llama-cpp';\n if (b === 'vibgrate') return 'vibgrate';\n if (b === 'lm-studio' || b === 'lmstudio') return 'lmstudio';\n if (b === 'foundry-local') return 'foundry-local';\n return b === 'ollama' ? 'ollama' : backend;\n}\n","/**\n * Model manager identity + runtime ensure.\n *\n * **Code Modes** always use the first-party **Vibgrate** manager (embedded\n * llama.cpp / vgd host-broker + weight store). Custom local/hosted backends\n * (Ollama, LM Studio, OpenRouter, …) are explicit user choices; when chosen we\n * silently install *our* installable runtime packages for that path (npm\n * bindings), never third-party desktop apps. The user sees a short badge for\n * which manager ran.\n */\n\nimport { spawnSync } from 'node:child_process';\nimport { ensurePackage, isPackageInstalled, type EnsureOptions } from '../code/ensure.js';\nimport { runtimeDepsForBackend } from './model-install-plan.js';\n\n/** Durable manager ids surfaced in badges and JSON. */\nexport type ModelManagerId =\n | 'vibgrate'\n | 'ollama'\n | 'lmstudio'\n | 'foundry-local'\n | 'openrouter'\n | 'litellm'\n | 'openai'\n | 'together'\n | 'mock'\n | 'other';\n\nexport interface ManagerBadge {\n id: ModelManagerId;\n /** Short product label, e.g. \"Vibgrate\". */\n label: string;\n /** Compact badge for CLI/UI, e.g. \"[Vibgrate]\". */\n badge: string;\n /** One-line after-run note. */\n note: string;\n}\n\nconst LABELS: Record<ModelManagerId, { label: string; note: string }> = {\n vibgrate: {\n label: 'Vibgrate',\n note: 'Code Mode · first-party model manager (embedded inference)',\n },\n ollama: {\n label: 'Ollama',\n note: 'Custom local · Ollama',\n },\n lmstudio: {\n label: 'LM Studio',\n note: 'Custom local · LM Studio',\n },\n 'foundry-local': {\n label: 'Foundry Local',\n note: 'Custom local · Foundry Local',\n },\n openrouter: {\n label: 'OpenRouter',\n note: 'Custom hosted · OpenRouter',\n },\n litellm: {\n label: 'LiteLLM',\n note: 'Custom hosted · LiteLLM',\n },\n openai: {\n label: 'OpenAI',\n note: 'Custom hosted · OpenAI',\n },\n together: {\n label: 'Together',\n note: 'Custom hosted · Together',\n },\n mock: {\n label: 'Mock',\n note: 'Scripted offline provider',\n },\n other: {\n label: 'Custom',\n note: 'Custom model backend',\n },\n};\n\n/** Map a provider id (`llama-cpp`, `ollama`, …) to a manager badge. */\nexport function managerFromProviderId(providerId: string | undefined | null): ModelManagerId {\n const id = (providerId ?? '').toLowerCase().trim();\n if (id === 'llama-cpp' || id === 'llama.cpp' || id === 'vibgrate' || id === 'vibgrate-store') return 'vibgrate';\n if (id === 'ollama') return 'ollama';\n if (id === 'lmstudio' || id === 'lm-studio') return 'lmstudio';\n if (id === 'foundry-local' || id === 'foundry') return 'foundry-local';\n if (id === 'openrouter') return 'openrouter';\n if (id === 'litellm') return 'litellm';\n if (id === 'openai') return 'openai';\n if (id === 'together') return 'together';\n if (id === 'mock' || id === 'scripted') return 'mock';\n return 'other';\n}\n\nexport function managerBadge(id: ModelManagerId): ManagerBadge {\n const meta = LABELS[id] ?? LABELS.other;\n return {\n id,\n label: meta.label,\n badge: `[${meta.label}]`,\n note: meta.note,\n };\n}\n\nexport function formatManagerBadgeLine(id: ModelManagerId, model?: string): string {\n const b = managerBadge(id);\n const modelPart = model ? ` · ${model}` : '';\n return `${b.badge} ${b.note}${modelPart}`;\n}\n\nexport interface EnsureManagerRuntimeOptions {\n /** Provider id that will run (llama-cpp, ollama, …). */\n providerId: string;\n /** Model id for weight pull when the backend supports it. */\n model?: string;\n /** `--local` / offline — no network install. */\n offline?: boolean;\n /**\n * Consent to install npm runtime packages (and ollama pull when binary is\n * present). True when the user chose a custom provider/model or passed --yes.\n */\n consent?: boolean;\n /** Injectable ensure (tests). */\n ensurePackage?: typeof ensurePackage;\n /** Injectable PATH binary probe. */\n hasBinary?: (name: string) => boolean;\n /** Injectable ollama pull. */\n ollamaPull?: (name: string) => number;\n onProgress?: (line: string) => void;\n}\n\nexport interface EnsureManagerRuntimeResult {\n ok: boolean;\n manager: ModelManagerId;\n badge: ManagerBadge;\n /** npm specs installed this call. */\n installed: string[];\n /** Weight refs pulled (e.g. ollama pull). */\n pulled: string[];\n /** Non-fatal notes (e.g. app already present). */\n messages: string[];\n error?: string;\n}\n\nfunction defaultHasBinary(name: string): boolean {\n const res = spawnSync(name, ['--version'], { stdio: 'ignore', encoding: 'utf8' });\n // Some CLIs use subcommands; try bare which-style.\n if (res.status === 0) return true;\n const which = spawnSync(process.platform === 'win32' ? 'where' : 'which', [name], {\n stdio: 'ignore',\n encoding: 'utf8',\n });\n return which.status === 0;\n}\n\n/**\n * Silently install *installable* runtime deps for the chosen manager.\n * Never installs third-party desktop apps (Ollama.app, LM Studio) — those\n * remain user-managed; we only install npm packages into the Vibgrate runtime\n * cache and pull weights when the backend binary is already on PATH.\n */\nexport async function ensureManagerRuntime(\n opts: EnsureManagerRuntimeOptions,\n): Promise<EnsureManagerRuntimeResult> {\n const manager = managerFromProviderId(opts.providerId);\n const badge = managerBadge(manager);\n const installed: string[] = [];\n const pulled: string[] = [];\n const messages: string[] = [];\n const ensure = opts.ensurePackage ?? ensurePackage;\n const hasBinary = opts.hasBinary ?? defaultHasBinary;\n\n // Hosted OpenAI-compatible backends: no local packages.\n if (\n manager === 'openrouter' ||\n manager === 'litellm' ||\n manager === 'openai' ||\n manager === 'together' ||\n manager === 'mock'\n ) {\n return { ok: true, manager, badge, installed, pulled, messages };\n }\n\n // LM Studio / Foundry: HTTP clients only — no auto app install (ADR-005).\n if (manager === 'lmstudio' || manager === 'foundry-local') {\n messages.push(\n manager === 'lmstudio'\n ? 'LM Studio must already be running with a model loaded (we never install the app)'\n : 'Foundry Local must already be running (we never install the app)',\n );\n return { ok: true, manager, badge, installed, pulled, messages };\n }\n\n const backend =\n manager === 'vibgrate' ? 'llama.cpp' : manager === 'ollama' ? 'ollama' : opts.providerId;\n const deps = runtimeDepsForBackend(backend);\n\n for (const dep of deps) {\n if (dep.kind === 'npm-runtime' && dep.spec) {\n if (isPackageInstalled(dep.spec)) {\n messages.push(`${dep.id} already installed`);\n continue;\n }\n if (opts.offline) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `${dep.spec} needed but offline/--local forbids install`,\n };\n }\n if (!opts.consent) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `${dep.spec} needed — pass --yes or run \\`vg models install\\` once`,\n };\n }\n opts.onProgress?.(`installing ${dep.spec}`);\n const ensureOpts: EnsureOptions = {\n consent: true,\n local: false,\n interactive: false,\n };\n const res = await ensure(dep.spec, ensureOpts);\n if (!res.module) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `couldn't install ${dep.spec}`,\n };\n }\n installed.push(dep.spec);\n continue;\n }\n if (dep.kind === 'native-binary' && dep.binary) {\n if (!hasBinary(dep.binary)) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error:\n dep.reason ||\n `${dep.binary} is not on PATH — install it once, then re-run (vg never auto-installs third-party apps)`,\n };\n }\n messages.push(`${dep.binary} on PATH`);\n }\n }\n\n // Optional: when user chose a custom Ollama model, pull weights if missing.\n if (manager === 'ollama' && opts.model && opts.consent && !opts.offline) {\n const list = spawnSync('ollama', ['list'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });\n const have =\n list.status === 0 &&\n (list.stdout ?? '')\n .split('\\n')\n .slice(1)\n .some((line) => {\n const name = line.trim().split(/\\s+/)[0]?.toLowerCase();\n return name === opts.model!.toLowerCase() || name?.startsWith(`${opts.model!.toLowerCase()}:`);\n });\n if (!have) {\n opts.onProgress?.(`pulling ${opts.model}`);\n const pull = opts.ollamaPull ?? ((name: string) => spawnSync('ollama', ['pull', name], { stdio: 'ignore' }).status ?? 1);\n const status = pull(opts.model);\n if (status !== 0) {\n return {\n ok: false,\n manager,\n badge,\n installed,\n pulled,\n messages,\n error: `ollama pull ${opts.model} failed (exit ${status})`,\n };\n }\n pulled.push(opts.model);\n }\n }\n\n return { ok: true, manager, badge, installed, pulled, messages };\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { execFileSync } from 'child_process';
|
|
3
|
+
|
|
4
|
+
// src/util/cli-invocation.ts
|
|
5
|
+
var NPX_INVOCATION = "npx @vibgrate/cli";
|
|
6
|
+
function whichOnPath(cmd) {
|
|
7
|
+
try {
|
|
8
|
+
const out = execFileSync(process.platform === "win32" ? "where" : "which", [cmd], {
|
|
9
|
+
encoding: "utf8",
|
|
10
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
11
|
+
}).trim().split(/\r?\n/)[0];
|
|
12
|
+
return out || null;
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isOwnBinary(binPath) {
|
|
18
|
+
try {
|
|
19
|
+
const real = fs.realpathSync(binPath);
|
|
20
|
+
if (/[\\/]@vibgrate[\\/]cli[\\/]/.test(real)) return true;
|
|
21
|
+
const head = fs.readFileSync(real, { encoding: "utf8" }).slice(0, 2048);
|
|
22
|
+
return head.includes("@vibgrate/cli") || head.includes("vibgrate");
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function isEphemeralNpxBinary(binPath) {
|
|
28
|
+
const NPX_SEGMENT = /[\\/]_npx[\\/]/;
|
|
29
|
+
if (NPX_SEGMENT.test(binPath)) return true;
|
|
30
|
+
try {
|
|
31
|
+
return NPX_SEGMENT.test(fs.realpathSync(binPath));
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function isInstalledOwnBinary(binPath) {
|
|
37
|
+
return isOwnBinary(binPath) && !isEphemeralNpxBinary(binPath);
|
|
38
|
+
}
|
|
39
|
+
var cached;
|
|
40
|
+
function resolveCliInvocation(which) {
|
|
41
|
+
if (!which && cached !== void 0) return cached;
|
|
42
|
+
const lookup = which ?? whichOnPath;
|
|
43
|
+
const vg = lookup("vg");
|
|
44
|
+
let result;
|
|
45
|
+
if (vg && isInstalledOwnBinary(vg)) {
|
|
46
|
+
result = "vg";
|
|
47
|
+
} else {
|
|
48
|
+
const vibgrate = lookup("vibgrate");
|
|
49
|
+
result = vibgrate && isInstalledOwnBinary(vibgrate) ? "vibgrate" : NPX_INVOCATION;
|
|
50
|
+
}
|
|
51
|
+
if (!which) cached = result;
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { NPX_INVOCATION, isInstalledOwnBinary, resolveCliInvocation, whichOnPath };
|
|
56
|
+
//# sourceMappingURL=chunk-UZJS7GMK.js.map
|
|
57
|
+
//# sourceMappingURL=chunk-UZJS7GMK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/cli-invocation.ts"],"names":[],"mappings":";;;;AA4BO,IAAM,cAAA,GAAiB;AAMvB,SAAS,YAAY,GAAA,EAA4B;AACtD,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,aAAa,OAAA,CAAQ,QAAA,KAAa,UAAU,OAAA,GAAU,OAAA,EAAS,CAA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gD;AACnF,EAAA,IAAI,CAAC,KAAA,IAAS,MAAA,KAAW,MAAA,EAAW,OAAO,MAAA;AAC3C,EAAA,MAAM,SAAS,KAAA,IAAS,WAAA;AAExB,EAAA,MAAM,EAAA,GAAK,OAAO,IAAI,CAAA;AACtB,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI,EAAA,IAAM,oBAAA,CAAqB,EAAE,CAAA,EAAG;AAClC,IAAA,MAAA,GAAS,IAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,MAAM,QAAA,GAAW,OAAO,UAAU,CAAA;AAClC,IAAA,MAAA,GAAS,QAAA,IAAY,oBAAA,CAAqB,QAAQ,CAAA,GAAI,UAAA,GAAa,cAAA;AAAA,EACrE;AAEA,EAAA,IAAI,CAAC,OAAO,MAAA,GAAS,MAAA;AACrB,EAAA,OAAO,MAAA;AACT","file":"chunk-UZJS7GMK.js","sourcesContent":["import * as fs from 'node:fs';\nimport { execFileSync } from 'node:child_process';\n\n/**\n * How the user should re-invoke this CLI in a \"next step\" hint.\n *\n * A user who ran `npx @vibgrate/cli scan` has no *persistent* `vg` (or\n * `vibgrate`) on PATH, so a hint like `vg install` or `vg login` would fail for\n * them once the run ends. We answer the practical question \"what will actually\n * run this CLI for this user again?\" by checking whether an *installed* copy of\n * our binary is reachable on PATH:\n *\n * installed `vg` → `vg` (the normal installed case)\n * installed `vibgrate` → `vibgrate` (alias present, `vg` shadowed)\n * neither → `npx @vibgrate/cli` (npx / not installed globally)\n *\n * \"Installed\" is the key qualifier: `npx` prepends its own throwaway\n * `_npx/<hash>/node_modules/.bin` to PATH for the run, so `which vg` finds a `vg`\n * that is genuinely ours yet gone the moment the process exits. That ephemeral\n * binary is excluded (see {@link isEphemeralNpxBinary}) so npx users get the npx\n * form, not a `vg` they can't call again.\n *\n * This is deliberately the same ladder `detectServeLaunch` uses for the MCP\n * launch command — the underlying question (\"is an installed `vg` ours?\") is\n * identical.\n */\n\n/** The npx form that always works without a global install. */\nexport const NPX_INVOCATION = 'npx @vibgrate/cli';\n\n/**\n * Locate `cmd` on PATH, returning its resolved path or null. Best-effort: a\n * missing command or an unavailable `which`/`where` both yield null.\n */\nexport function whichOnPath(cmd: string): string | null {\n try {\n const out = execFileSync(process.platform === 'win32' ? 'where' : 'which', [cmd], {\n encoding: 'utf8',\n stdio: ['ignore', 'pipe', 'ignore'],\n })\n .trim()\n .split(/\\r?\\n/)[0];\n return out || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Does this PATH entry launch *this* package? Symlink installs resolve into a\n * `…/@vibgrate/cli/…` directory; script shims (pnpm/bun/yarn, Windows .cmd)\n * reference the package path in their first bytes. Best-effort: unreadable or\n * unrecognisable entries count as foreign, which only makes callers pick a safer\n * fallback.\n */\nexport function isOwnBinary(binPath: string): boolean {\n try {\n const real = fs.realpathSync(binPath);\n if (/[\\\\/]@vibgrate[\\\\/]cli[\\\\/]/.test(real)) return true;\n const head = fs.readFileSync(real, { encoding: 'utf8' }).slice(0, 2048);\n return head.includes('@vibgrate/cli') || head.includes('vibgrate');\n } catch {\n return false;\n }\n}\n\n/**\n * Is this resolved binary an *ephemeral* npx-cache entry rather than a persistent\n * install? `npx @vibgrate/cli …` unpacks the package into an npm `_npx/<hash>/`\n * cache directory and prepends its `node_modules/.bin` to PATH for the duration\n * of the run — so `which vg` finds a `vg` that is *ours* yet vanishes the instant\n * the process exits. Treating that as an installed `vg` is exactly what made the\n * post-scan hints tell npx users to run `vg login`/`vg push`, commands they have\n * no `vg` on PATH for. npm's cache segment is `_npx` on every platform; we test\n * the raw PATH entry and its realpath (symlink shims resolve into the same tree).\n */\nexport function isEphemeralNpxBinary(binPath: string): boolean {\n const NPX_SEGMENT = /[\\\\/]_npx[\\\\/]/;\n if (NPX_SEGMENT.test(binPath)) return true;\n try {\n return NPX_SEGMENT.test(fs.realpathSync(binPath));\n } catch {\n return false;\n }\n}\n\n/**\n * Does this PATH entry launch *this* CLI in a way that will still work after the\n * current process exits? True only for a persistent install of our package — an\n * ephemeral npx-cache binary does not count, because the user cannot re-invoke it\n * by name. This is the predicate \"next step\" hints and the MCP launch command\n * must use, not {@link isOwnBinary} alone.\n */\nexport function isInstalledOwnBinary(binPath: string): boolean {\n return isOwnBinary(binPath) && !isEphemeralNpxBinary(binPath);\n}\n\nlet cached: string | undefined;\n\n/**\n * The command prefix a user should type to re-run this CLI (see module doc).\n * Memoized per-process: PATH does not change mid-run, and each call would\n * otherwise spawn `which`. Pass `which` to override lookup in tests, which also\n * bypasses the cache.\n */\nexport function resolveCliInvocation(which?: (cmd: string) => string | null): string {\n if (!which && cached !== undefined) return cached;\n const lookup = which ?? whichOnPath;\n\n const vg = lookup('vg');\n let result: string;\n if (vg && isInstalledOwnBinary(vg)) {\n result = 'vg';\n } else {\n const vibgrate = lookup('vibgrate');\n result = vibgrate && isInstalledOwnBinary(vibgrate) ? 'vibgrate' : NPX_INVOCATION;\n }\n\n if (!which) cached = result;\n return result;\n}\n\n/** Reset the memoized invocation. Test-only. */\nexport function resetCliInvocationCache(): void {\n cached = undefined;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildMessages, parseEdits, applyEdits, unifiedDiff, redactSecrets } from './chunk-
|
|
1
|
+
import { buildMessages, parseEdits, applyEdits, unifiedDiff, redactSecrets } from './chunk-YF43FOPP.js';
|
|
2
2
|
import { recordCliCall, CLI_TOOL_ALIASES, buildCodeContext, buildTaskCapsule, capsuleToCodeContext } from './chunk-ZBTY6VV4.js';
|
|
3
3
|
import { repositoryIdFromRoot } from './chunk-BWPBB45M.js';
|
|
4
4
|
import * as fs from 'fs';
|
|
@@ -251,5 +251,5 @@ function shortId() {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
export { commitChanges, nodeCodeFs, runCodeSession, undoChanges };
|
|
254
|
-
//# sourceMappingURL=chunk-
|
|
255
|
-
//# sourceMappingURL=chunk-
|
|
254
|
+
//# sourceMappingURL=chunk-WH2N22S3.js.map
|
|
255
|
+
//# sourceMappingURL=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AAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,GAAI,QAAA,CAAS,MAAM,CAAC,CAAA;AACrF,EAAA,OAAO,CAAA;AACT","file":"chunk-R6ZRVVZT.js","sourcesContent":["/**\n * The `vg code` governance session (VG-CLI-CODE §7).\n *\n * This is the load-bearing rule the whole platform is built on, applied to code\n * edits: a state-altering change goes **through** the lifecycle, never around it\n * (GUARDRAILS §5). One run walks inspect → assess → dry-run → approve → execute\n * → verify → log:\n *\n * inspect build the graph-grounded context for the instruction\n * assess ask the routed model for a terse edit; apply it deterministically\n * (in memory); compute the diff and the blast radius\n * dry-run the DEFAULT terminal state — propose the change, write nothing\n * approve writing requires explicit consent; without it we stop at dry-run\n * execute write the approved changes to disk\n * verify confirm the files on disk match what was approved (+ optional cmd)\n * log append an immutable, secret-free audit record with a correlation id\n *\n * Everything is deterministic except the single model call, which is isolated\n * behind the provider list (tried in order, falling back on transport failure).\n * The filesystem and clock are injectable so the whole session is testable\n * offline with no writes escaping a temp dir.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { buildCodeContext } from './context.js';\nimport { buildTaskCapsule, capsuleToCodeContext } from './capsule.js';\nimport { recordCliCall, CLI_TOOL_ALIASES } from '../engine/savings.js';\nimport { repositoryIdFromRoot } from '../runtime/paths.js';\nimport { parseEdits, applyEdits, type SymbolSpan } from './apply.js';\nimport { unifiedDiff } from './diff.js';\nimport { buildMessages } from './prompt.js';\nimport { redactSecrets } from './providers.js';\nimport type { ChatOptions, CodeContext, CodeSessionResult, FileChange, LifecyclePhase, Provider, ProviderResult } from './types.js';\nimport type { VgGraph } from '../schema.js';\n\n/** Minimal filesystem seam so the session is testable without touching real disk. */\nexport interface CodeFs {\n read(file: string): string | null;\n write(file: string, content: string): void;\n remove(file: string): void;\n appendAudit(line: string): void;\n}\n\nexport interface RunSessionOptions {\n graph: VgGraph;\n root: string;\n instruction: string;\n /** Providers to try in order (from the router); the first that answers wins. */\n providers: Provider[];\n /** Write to disk? Default false — dry-run is the safe default (GUARDRAILS §3.2). */\n apply?: boolean;\n /** Explicit consent for the write (`--yes`); without it, a requested apply stops at dry-run. */\n consent?: boolean;\n /** Restrict the edit surface to these files. */\n files?: string[];\n /** Context token budget. */\n budget?: number;\n chatOptions?: ChatOptions;\n /** Injectable filesystem (defaults to a real, root-scoped fs). */\n fsImpl?: CodeFs;\n /** Injectable clock (ms) for the audit timestamp. */\n now?: () => number;\n /** Injectable correlation id (defaults to a random short id). */\n correlationId?: string;\n /** Progress callback per phase. */\n onPhase?: (phase: LifecyclePhase, detail: string) => void;\n /** Skip appending to the audit log (used by tests/dry programmatic calls). */\n noAudit?: boolean;\n /**\n * Who is making the graph-backed call, for per-model savings auditing. When\n * `client` is set, the context-assembly step (a `query_graph`-equivalent) is\n * recorded to the local savings ledger tagged with the provider + model, so\n * `vg savings` can break usage down per model. VG Code always sets this.\n */\n attribution?: { client: string; provider?: string; model?: string };\n /**\n * Use a source-bearing Task Capsule for the inspect context (Fusion Runtime\n * Phase 0 A/B). Default false keeps the metadata-only path.\n */\n capsule?: boolean;\n}\n\nexport async function runCodeSession(options: RunSessionOptions): Promise<CodeSessionResult> {\n const {\n graph,\n root,\n instruction,\n providers,\n apply = false,\n consent = false,\n files,\n budget,\n chatOptions,\n now = () => 0,\n onPhase = () => {},\n } = options;\n const fsImpl = options.fsImpl ?? nodeCodeFs(root);\n const correlationId = options.correlationId ?? shortId();\n const phasesRun: LifecyclePhase[] = [];\n const phase = (p: LifecyclePhase, detail: string): void => {\n phasesRun.push(p);\n onPhase(p, detail);\n };\n\n // ── inspect ──────────────────────────────────────────────────────────────\n phase('inspect', options.capsule ? 'building source-bearing task capsule' : 'building graph-grounded context');\n const context = buildSessionContext(graph, instruction, {\n budget,\n files,\n capsule: options.capsule,\n root,\n fsImpl,\n });\n\n // Per-model savings: the context build is VG Code's `query_graph`-equivalent.\n // Record it (counts only — never code or the instruction) tagged with the\n // model, so `vg savings` audits usage per model. Local-only, best-effort.\n if (options.attribution?.client) {\n const seedFiles = new Set(context.seeds.map((s) => s.node.file).filter(Boolean));\n recordCliCall(\n root,\n {\n tool: CLI_TOOL_ALIASES.ask,\n client: options.attribution.client,\n provider: options.attribution.provider,\n model: options.attribution.model,\n outcome: context.seeds.length ? 'complete' : 'miss',\n vgTokens: context.tokensEstimate,\n baselineFiles: seedFiles.size,\n },\n now(),\n );\n }\n\n // ── assess ──────────────────────────────────────────────────────────────\n phase('assess', 'asking the routed model for a minimal edit');\n const messages = buildMessages(context);\n const { result, provider, fellBack } = await complete(providers, messages, chatOptions, correlationId);\n\n const edits = parseEdits(result.text);\n const spans = spanIndex(graph);\n const applied = applyEdits(\n edits,\n (file) => fsImpl.read(file),\n (file) => spans.get(normalize(file)) ?? [],\n );\n\n const changes: FileChange[] = [];\n for (const [file, entry] of [...applied.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {\n changes.push({\n file,\n before: entry.before,\n after: entry.after,\n outcomes: entry.outcomes,\n diff: unifiedDiff(entry.before, entry.after, file),\n });\n }\n\n // ── dry-run (always produced) ─────────────────────────────────────────────\n phase('dry-run', `${changes.length} file(s) would change`);\n\n const anyApplicable = changes.some((c) => c.diff !== '' && c.outcomes.some((o) => o.status === 'applied'));\n const base: CodeSessionResult = {\n instruction,\n provider: { id: provider.id, model: provider.model, local: provider.local, fellBack },\n phasesRun,\n changes,\n applied: false,\n verification: { ran: false, ok: false, detail: 'dry-run — no changes written' },\n correlationId,\n };\n\n // ── approve ───────────────────────────────────────────────────────────────\n // Writing is opt-in AND consent-gated. A requested apply without consent is\n // not an error — it degrades to a dry-run so the caller can review, then\n // re-run with --yes. This is the \"never destructive-by-default\" guardrail.\n if (!apply) {\n if (!options.noAudit) writeAudit(fsImpl, base, now());\n return base;\n }\n if (!consent) {\n const stopped = { ...base, verification: { ran: false, ok: false, detail: 'apply requested without consent — re-run with --yes to write these changes' } };\n if (!options.noAudit) writeAudit(fsImpl, stopped, now());\n return stopped;\n }\n if (!anyApplicable) {\n const nothing = { ...base, verification: { ran: false, ok: false, detail: 'nothing to write — no edit applied cleanly' } };\n if (!options.noAudit) writeAudit(fsImpl, nothing, now());\n return nothing;\n }\n phase('approve', 'consent given (--yes)');\n\n // ── execute ───────────────────────────────────────────────────────────────\n phase('execute', 'writing approved changes');\n for (const change of changes) {\n if (change.diff === '') continue; // no-op file\n if (!change.outcomes.some((o) => o.status === 'applied')) continue; // nothing applied cleanly here\n if (change.after === null) fsImpl.remove(change.file);\n else fsImpl.write(change.file, change.after);\n }\n\n // ── verify ────────────────────────────────────────────────────────────────\n phase('verify', 'confirming on-disk content matches the approved change');\n const verification = verifyWrites(fsImpl, changes);\n\n // ── log ───────────────────────────────────────────────────────────────────\n phase('log', 'recording an audit entry');\n const final: CodeSessionResult = { ...base, applied: true, verification };\n if (!options.noAudit) writeAudit(fsImpl, final, now());\n return final;\n}\n\n/**\n * Commit an already-computed dry-run result: write the cleanly-applied changes,\n * verify them on disk, and append the audit record — the \"approve → execute →\n * verify → log\" tail of the lifecycle, run against a proposal the caller has\n * already shown and had approved (the interactive REPL uses this so it never\n * calls the model twice or writes something different from what was reviewed).\n */\nexport function commitChanges(result: CodeSessionResult, fsImpl: CodeFs, now: () => number = () => 0): CodeSessionResult {\n const anyApplicable = result.changes.some((c) => c.diff !== '' && c.outcomes.some((o) => o.status === 'applied'));\n if (!anyApplicable) {\n return { ...result, applied: false, verification: { ran: false, ok: false, detail: 'nothing to write — no edit applied cleanly' } };\n }\n for (const change of result.changes) {\n if (change.diff === '' || !change.outcomes.some((o) => o.status === 'applied')) continue;\n if (change.after === null) fsImpl.remove(change.file);\n else fsImpl.write(change.file, change.after);\n }\n const verification = verifyWrites(fsImpl, result.changes);\n const final: CodeSessionResult = { ...result, applied: true, verification, phasesRun: [...result.phasesRun, 'approve', 'execute', 'verify', 'log'] };\n writeAudit(fsImpl, final, now());\n return final;\n}\n\n/**\n * Undo a set of applied changes by restoring each file's prior content — the\n * `/undo` command. A created file (before === null) is removed; an edited or\n * deleted file is restored to its `before`. Only cleanly-applied changes are\n * reverted. Returns the files it restored.\n */\nexport function undoChanges(changes: FileChange[], fsImpl: CodeFs): string[] {\n const restored: string[] = [];\n for (const ch of changes) {\n if (!ch.outcomes.some((o) => o.status === 'applied')) continue;\n if (ch.before === null) fsImpl.remove(ch.file);\n else fsImpl.write(ch.file, ch.before);\n restored.push(ch.file);\n }\n return restored;\n}\n\nfunction buildSessionContext(\n graph: VgGraph,\n instruction: string,\n opts: { budget?: number; files?: string[]; capsule?: boolean; root: string; fsImpl: CodeFs },\n): CodeContext {\n const budget = opts.budget;\n const files = opts.files;\n if (!opts.capsule) {\n return buildCodeContext(graph, instruction, { budget, files });\n }\n const capsule = buildTaskCapsule(graph, instruction, {\n budget,\n files,\n readFile: (rel) => opts.fsImpl.read(rel),\n repositoryId: repositoryIdFromRoot(opts.root),\n });\n return capsuleToCodeContext(capsule);\n}\n\n/** Try each provider in order; fall back on transport failure. Throws the last actionable error. */\nasync function complete(\n providers: Provider[],\n messages: ReturnType<typeof buildMessages>,\n chatOptions: ChatOptions | undefined,\n correlationId: string,\n): Promise<{ result: ProviderResult; provider: Provider; fellBack: boolean }> {\n if (providers.length === 0) throw new Error(`no model provider available (ref ${correlationId})`);\n let lastErr: unknown;\n for (let i = 0; i < providers.length; i++) {\n const provider = providers[i];\n try {\n const result = await provider.chat(messages, { temperature: 0, ...chatOptions });\n return { result, provider, fellBack: i > 0 };\n } catch (e) {\n lastErr = e;\n }\n }\n const message = lastErr instanceof Error ? redactSecrets(lastErr.message) : String(lastErr);\n throw new Error(`${message} (ref ${correlationId})`);\n}\n\n/** Confirm each written file's on-disk content equals what we approved. */\nfunction verifyWrites(fsImpl: CodeFs, changes: FileChange[]): { ran: boolean; ok: boolean; detail: string } {\n let checked = 0;\n const mismatches: string[] = [];\n for (const change of changes) {\n if (change.diff === '' || !change.outcomes.some((o) => o.status === 'applied')) continue;\n checked++;\n const onDisk = fsImpl.read(change.file);\n if (onDisk !== change.after) mismatches.push(change.file);\n }\n if (mismatches.length) return { ran: true, ok: false, detail: `on-disk content differs for: ${mismatches.join(', ')}` };\n return { ran: true, ok: true, detail: `wrote and verified ${checked} file(s)` };\n}\n\n/** An append-only, secret-free audit record (GUARDRAILS §2.6 / §5). No file contents, no keys. */\nfunction writeAudit(fsImpl: CodeFs, r: CodeSessionResult, ts: number): void {\n const record = {\n ts,\n correlationId: r.correlationId,\n instruction: r.instruction.slice(0, 500),\n provider: r.provider.id,\n model: r.provider.model,\n local: r.provider.local,\n applied: r.applied,\n files: r.changes.map((c) => ({ file: c.file, statuses: c.outcomes.map((o) => o.status) })),\n verification: r.verification,\n phases: r.phasesRun,\n };\n try {\n fsImpl.appendAudit(JSON.stringify(record));\n } catch {\n /* audit is best-effort; never fail the run on a logging problem */\n }\n}\n\n/** Build a per-file map of symbol spans for graph-scoped edit disambiguation. */\nfunction spanIndex(graph: VgGraph): Map<string, SymbolSpan[]> {\n const map = new Map<string, SymbolSpan[]>();\n for (const n of graph.nodes) {\n if (n.kind === 'file' || n.kind === 'external') continue;\n const file = normalize(n.file);\n const list = map.get(file) ?? [];\n list.push({ qualifiedName: n.qualifiedName, file, start: n.span.start, end: n.span.end });\n map.set(file, list);\n }\n return map;\n}\n\nfunction normalize(file: string): string {\n return file.replace(/\\\\/g, '/').replace(/^\\.\\//, '');\n}\n\n/** Default filesystem impl, scoped to `root`. Refuses paths that escape the root. */\nexport function nodeCodeFs(root: string): CodeFs {\n const resolve = (file: string): string => {\n const abs = path.resolve(root, file);\n const rel = path.relative(root, abs);\n if (rel.startsWith('..') || path.isAbsolute(rel)) {\n throw new Error(`edit path escapes the project root: ${file} — refusing to touch files outside ${root}`);\n }\n return abs;\n };\n return {\n read(file) {\n try {\n return fs.readFileSync(resolve(file), 'utf8');\n } catch {\n return null;\n }\n },\n write(file, content) {\n const abs = resolve(file);\n fs.mkdirSync(path.dirname(abs), { recursive: true });\n fs.writeFileSync(abs, content);\n },\n remove(file) {\n try {\n fs.rmSync(resolve(file));\n } catch {\n /* already gone */\n }\n },\n appendAudit(line) {\n const dir = path.join(root, '.vibgrate');\n fs.mkdirSync(dir, { recursive: true });\n fs.appendFileSync(path.join(dir, 'code-audit.jsonl'), line + '\\n');\n },\n };\n}\n\n/** Short, URL-safe correlation id. Not a graph artifact, so runtime randomness is fine here. */\nfunction shortId(): string {\n let s = '';\n const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';\n for (let i = 0; i < 8; i++) s += alphabet[Math.floor(Math.random() * alphabet.length)];\n return s;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/code/session.ts"],"names":["resolve"],"mappings":";;;;;;AAmFA,eAAsB,eAAe,OAAA,EAAwD;AAC3F,EAAA,MAAM;AAAA,IACJ,KAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA,GAAQ,KAAA;AAAA,IACR,OAAA,GAAU,KAAA;AAAA,IACV,KAAA;AAAA,IACA,MAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAM,MAAM,CAAA;AAAA,IACZ,UAAU,MAAM;AAAA,IAAC;AAAA,GACnB,GAAI,OAAA;AACJ,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,MAAA,IAAU,UAAA,CAAW,IAAI,CAAA;AAChD,EAAA,MAAM,aAAA,GAAgB,OAAA,CAAQ,aAAA,IAAiB,OAAA,EAAQ;AACvD,EAAA,MAAM,YAA8B,EAAC;AACrC,EAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,EAAmB,MAAA,KAAyB;AACzD,IAAA,SAAA,CAAU,KAAK,CAAC,CAAA;AAChB,IAAA,OAAA,CAAQ,GAAG,MAAM,CAAA;AAAA,EACnB,CAAA;AAGA,EAAA,KAAA,CAAM,SAAA,EAAW,OAAA,CAAQ,OAAA,GAAU,sCAAA,GAAyC,iCAAiC,CAAA;AAC7G,EAAA,MAAM,OAAA,GAAU,mBAAA,CAAoB,KAAA,EAAO,WAAA,EAAa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oB,IAAA,CAAA,IAAA,CAAK,GAAA,EAAK,kBAAkB,CAAA,EAAG,OAAO,IAAI,CAAA;AAAA,IACnE;AAAA,GACF;AACF;AAGA,SAAS,OAAA,GAAkB;AACzB,EAAA,IAAI,CAAA,GAAI,EAAA;AACR,EAAA,MAAM,QAAA,GAAW,sCAAA;AACjB,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,KAAK,CAAA,IAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,GAAI,QAAA,CAAS,MAAM,CAAC,CAAA;AACrF,EAAA,OAAO,CAAA;AACT","file":"chunk-WH2N22S3.js","sourcesContent":["/**\n * The `vg code` governance session (VG-CLI-CODE §7).\n *\n * This is the load-bearing rule the whole platform is built on, applied to code\n * edits: a state-altering change goes **through** the lifecycle, never around it\n * (GUARDRAILS §5). One run walks inspect → assess → dry-run → approve → execute\n * → verify → log:\n *\n * inspect build the graph-grounded context for the instruction\n * assess ask the routed model for a terse edit; apply it deterministically\n * (in memory); compute the diff and the blast radius\n * dry-run the DEFAULT terminal state — propose the change, write nothing\n * approve writing requires explicit consent; without it we stop at dry-run\n * execute write the approved changes to disk\n * verify confirm the files on disk match what was approved (+ optional cmd)\n * log append an immutable, secret-free audit record with a correlation id\n *\n * Everything is deterministic except the single model call, which is isolated\n * behind the provider list (tried in order, falling back on transport failure).\n * The filesystem and clock are injectable so the whole session is testable\n * offline with no writes escaping a temp dir.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { buildCodeContext } from './context.js';\nimport { buildTaskCapsule, capsuleToCodeContext } from './capsule.js';\nimport { recordCliCall, CLI_TOOL_ALIASES } from '../engine/savings.js';\nimport { repositoryIdFromRoot } from '../runtime/paths.js';\nimport { parseEdits, applyEdits, type SymbolSpan } from './apply.js';\nimport { unifiedDiff } from './diff.js';\nimport { buildMessages } from './prompt.js';\nimport { redactSecrets } from './providers.js';\nimport type { ChatOptions, CodeContext, CodeSessionResult, FileChange, LifecyclePhase, Provider, ProviderResult } from './types.js';\nimport type { VgGraph } from '../schema.js';\n\n/** Minimal filesystem seam so the session is testable without touching real disk. */\nexport interface CodeFs {\n read(file: string): string | null;\n write(file: string, content: string): void;\n remove(file: string): void;\n appendAudit(line: string): void;\n}\n\nexport interface RunSessionOptions {\n graph: VgGraph;\n root: string;\n instruction: string;\n /** Providers to try in order (from the router); the first that answers wins. */\n providers: Provider[];\n /** Write to disk? Default false — dry-run is the safe default (GUARDRAILS §3.2). */\n apply?: boolean;\n /** Explicit consent for the write (`--yes`); without it, a requested apply stops at dry-run. */\n consent?: boolean;\n /** Restrict the edit surface to these files. */\n files?: string[];\n /** Context token budget. */\n budget?: number;\n chatOptions?: ChatOptions;\n /** Injectable filesystem (defaults to a real, root-scoped fs). */\n fsImpl?: CodeFs;\n /** Injectable clock (ms) for the audit timestamp. */\n now?: () => number;\n /** Injectable correlation id (defaults to a random short id). */\n correlationId?: string;\n /** Progress callback per phase. */\n onPhase?: (phase: LifecyclePhase, detail: string) => void;\n /** Skip appending to the audit log (used by tests/dry programmatic calls). */\n noAudit?: boolean;\n /**\n * Who is making the graph-backed call, for per-model savings auditing. When\n * `client` is set, the context-assembly step (a `query_graph`-equivalent) is\n * recorded to the local savings ledger tagged with the provider + model, so\n * `vg savings` can break usage down per model. VG Code always sets this.\n */\n attribution?: { client: string; provider?: string; model?: string };\n /**\n * Use a source-bearing Task Capsule for the inspect context (Fusion Runtime\n * Phase 0 A/B). Default false keeps the metadata-only path.\n */\n capsule?: boolean;\n}\n\nexport async function runCodeSession(options: RunSessionOptions): Promise<CodeSessionResult> {\n const {\n graph,\n root,\n instruction,\n providers,\n apply = false,\n consent = false,\n files,\n budget,\n chatOptions,\n now = () => 0,\n onPhase = () => {},\n } = options;\n const fsImpl = options.fsImpl ?? nodeCodeFs(root);\n const correlationId = options.correlationId ?? shortId();\n const phasesRun: LifecyclePhase[] = [];\n const phase = (p: LifecyclePhase, detail: string): void => {\n phasesRun.push(p);\n onPhase(p, detail);\n };\n\n // ── inspect ──────────────────────────────────────────────────────────────\n phase('inspect', options.capsule ? 'building source-bearing task capsule' : 'building graph-grounded context');\n const context = buildSessionContext(graph, instruction, {\n budget,\n files,\n capsule: options.capsule,\n root,\n fsImpl,\n });\n\n // Per-model savings: the context build is VG Code's `query_graph`-equivalent.\n // Record it (counts only — never code or the instruction) tagged with the\n // model, so `vg savings` audits usage per model. Local-only, best-effort.\n if (options.attribution?.client) {\n const seedFiles = new Set(context.seeds.map((s) => s.node.file).filter(Boolean));\n recordCliCall(\n root,\n {\n tool: CLI_TOOL_ALIASES.ask,\n client: options.attribution.client,\n provider: options.attribution.provider,\n model: options.attribution.model,\n outcome: context.seeds.length ? 'complete' : 'miss',\n vgTokens: context.tokensEstimate,\n baselineFiles: seedFiles.size,\n },\n now(),\n );\n }\n\n // ── assess ──────────────────────────────────────────────────────────────\n phase('assess', 'asking the routed model for a minimal edit');\n const messages = buildMessages(context);\n const { result, provider, fellBack } = await complete(providers, messages, chatOptions, correlationId);\n\n const edits = parseEdits(result.text);\n const spans = spanIndex(graph);\n const applied = applyEdits(\n edits,\n (file) => fsImpl.read(file),\n (file) => spans.get(normalize(file)) ?? [],\n );\n\n const changes: FileChange[] = [];\n for (const [file, entry] of [...applied.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {\n changes.push({\n file,\n before: entry.before,\n after: entry.after,\n outcomes: entry.outcomes,\n diff: unifiedDiff(entry.before, entry.after, file),\n });\n }\n\n // ── dry-run (always produced) ─────────────────────────────────────────────\n phase('dry-run', `${changes.length} file(s) would change`);\n\n const anyApplicable = changes.some((c) => c.diff !== '' && c.outcomes.some((o) => o.status === 'applied'));\n const base: CodeSessionResult = {\n instruction,\n provider: { id: provider.id, model: provider.model, local: provider.local, fellBack },\n phasesRun,\n changes,\n applied: false,\n verification: { ran: false, ok: false, detail: 'dry-run — no changes written' },\n correlationId,\n };\n\n // ── approve ───────────────────────────────────────────────────────────────\n // Writing is opt-in AND consent-gated. A requested apply without consent is\n // not an error — it degrades to a dry-run so the caller can review, then\n // re-run with --yes. This is the \"never destructive-by-default\" guardrail.\n if (!apply) {\n if (!options.noAudit) writeAudit(fsImpl, base, now());\n return base;\n }\n if (!consent) {\n const stopped = { ...base, verification: { ran: false, ok: false, detail: 'apply requested without consent — re-run with --yes to write these changes' } };\n if (!options.noAudit) writeAudit(fsImpl, stopped, now());\n return stopped;\n }\n if (!anyApplicable) {\n const nothing = { ...base, verification: { ran: false, ok: false, detail: 'nothing to write — no edit applied cleanly' } };\n if (!options.noAudit) writeAudit(fsImpl, nothing, now());\n return nothing;\n }\n phase('approve', 'consent given (--yes)');\n\n // ── execute ───────────────────────────────────────────────────────────────\n phase('execute', 'writing approved changes');\n for (const change of changes) {\n if (change.diff === '') continue; // no-op file\n if (!change.outcomes.some((o) => o.status === 'applied')) continue; // nothing applied cleanly here\n if (change.after === null) fsImpl.remove(change.file);\n else fsImpl.write(change.file, change.after);\n }\n\n // ── verify ────────────────────────────────────────────────────────────────\n phase('verify', 'confirming on-disk content matches the approved change');\n const verification = verifyWrites(fsImpl, changes);\n\n // ── log ───────────────────────────────────────────────────────────────────\n phase('log', 'recording an audit entry');\n const final: CodeSessionResult = { ...base, applied: true, verification };\n if (!options.noAudit) writeAudit(fsImpl, final, now());\n return final;\n}\n\n/**\n * Commit an already-computed dry-run result: write the cleanly-applied changes,\n * verify them on disk, and append the audit record — the \"approve → execute →\n * verify → log\" tail of the lifecycle, run against a proposal the caller has\n * already shown and had approved (the interactive REPL uses this so it never\n * calls the model twice or writes something different from what was reviewed).\n */\nexport function commitChanges(result: CodeSessionResult, fsImpl: CodeFs, now: () => number = () => 0): CodeSessionResult {\n const anyApplicable = result.changes.some((c) => c.diff !== '' && c.outcomes.some((o) => o.status === 'applied'));\n if (!anyApplicable) {\n return { ...result, applied: false, verification: { ran: false, ok: false, detail: 'nothing to write — no edit applied cleanly' } };\n }\n for (const change of result.changes) {\n if (change.diff === '' || !change.outcomes.some((o) => o.status === 'applied')) continue;\n if (change.after === null) fsImpl.remove(change.file);\n else fsImpl.write(change.file, change.after);\n }\n const verification = verifyWrites(fsImpl, result.changes);\n const final: CodeSessionResult = { ...result, applied: true, verification, phasesRun: [...result.phasesRun, 'approve', 'execute', 'verify', 'log'] };\n writeAudit(fsImpl, final, now());\n return final;\n}\n\n/**\n * Undo a set of applied changes by restoring each file's prior content — the\n * `/undo` command. A created file (before === null) is removed; an edited or\n * deleted file is restored to its `before`. Only cleanly-applied changes are\n * reverted. Returns the files it restored.\n */\nexport function undoChanges(changes: FileChange[], fsImpl: CodeFs): string[] {\n const restored: string[] = [];\n for (const ch of changes) {\n if (!ch.outcomes.some((o) => o.status === 'applied')) continue;\n if (ch.before === null) fsImpl.remove(ch.file);\n else fsImpl.write(ch.file, ch.before);\n restored.push(ch.file);\n }\n return restored;\n}\n\nfunction buildSessionContext(\n graph: VgGraph,\n instruction: string,\n opts: { budget?: number; files?: string[]; capsule?: boolean; root: string; fsImpl: CodeFs },\n): CodeContext {\n const budget = opts.budget;\n const files = opts.files;\n if (!opts.capsule) {\n return buildCodeContext(graph, instruction, { budget, files });\n }\n const capsule = buildTaskCapsule(graph, instruction, {\n budget,\n files,\n readFile: (rel) => opts.fsImpl.read(rel),\n repositoryId: repositoryIdFromRoot(opts.root),\n });\n return capsuleToCodeContext(capsule);\n}\n\n/** Try each provider in order; fall back on transport failure. Throws the last actionable error. */\nasync function complete(\n providers: Provider[],\n messages: ReturnType<typeof buildMessages>,\n chatOptions: ChatOptions | undefined,\n correlationId: string,\n): Promise<{ result: ProviderResult; provider: Provider; fellBack: boolean }> {\n if (providers.length === 0) throw new Error(`no model provider available (ref ${correlationId})`);\n let lastErr: unknown;\n for (let i = 0; i < providers.length; i++) {\n const provider = providers[i];\n try {\n const result = await provider.chat(messages, { temperature: 0, ...chatOptions });\n return { result, provider, fellBack: i > 0 };\n } catch (e) {\n lastErr = e;\n }\n }\n const message = lastErr instanceof Error ? redactSecrets(lastErr.message) : String(lastErr);\n throw new Error(`${message} (ref ${correlationId})`);\n}\n\n/** Confirm each written file's on-disk content equals what we approved. */\nfunction verifyWrites(fsImpl: CodeFs, changes: FileChange[]): { ran: boolean; ok: boolean; detail: string } {\n let checked = 0;\n const mismatches: string[] = [];\n for (const change of changes) {\n if (change.diff === '' || !change.outcomes.some((o) => o.status === 'applied')) continue;\n checked++;\n const onDisk = fsImpl.read(change.file);\n if (onDisk !== change.after) mismatches.push(change.file);\n }\n if (mismatches.length) return { ran: true, ok: false, detail: `on-disk content differs for: ${mismatches.join(', ')}` };\n return { ran: true, ok: true, detail: `wrote and verified ${checked} file(s)` };\n}\n\n/** An append-only, secret-free audit record (GUARDRAILS §2.6 / §5). No file contents, no keys. */\nfunction writeAudit(fsImpl: CodeFs, r: CodeSessionResult, ts: number): void {\n const record = {\n ts,\n correlationId: r.correlationId,\n instruction: r.instruction.slice(0, 500),\n provider: r.provider.id,\n model: r.provider.model,\n local: r.provider.local,\n applied: r.applied,\n files: r.changes.map((c) => ({ file: c.file, statuses: c.outcomes.map((o) => o.status) })),\n verification: r.verification,\n phases: r.phasesRun,\n };\n try {\n fsImpl.appendAudit(JSON.stringify(record));\n } catch {\n /* audit is best-effort; never fail the run on a logging problem */\n }\n}\n\n/** Build a per-file map of symbol spans for graph-scoped edit disambiguation. */\nfunction spanIndex(graph: VgGraph): Map<string, SymbolSpan[]> {\n const map = new Map<string, SymbolSpan[]>();\n for (const n of graph.nodes) {\n if (n.kind === 'file' || n.kind === 'external') continue;\n const file = normalize(n.file);\n const list = map.get(file) ?? [];\n list.push({ qualifiedName: n.qualifiedName, file, start: n.span.start, end: n.span.end });\n map.set(file, list);\n }\n return map;\n}\n\nfunction normalize(file: string): string {\n return file.replace(/\\\\/g, '/').replace(/^\\.\\//, '');\n}\n\n/** Default filesystem impl, scoped to `root`. Refuses paths that escape the root. */\nexport function nodeCodeFs(root: string): CodeFs {\n const resolve = (file: string): string => {\n const abs = path.resolve(root, file);\n const rel = path.relative(root, abs);\n if (rel.startsWith('..') || path.isAbsolute(rel)) {\n throw new Error(`edit path escapes the project root: ${file} — refusing to touch files outside ${root}`);\n }\n return abs;\n };\n return {\n read(file) {\n try {\n return fs.readFileSync(resolve(file), 'utf8');\n } catch {\n return null;\n }\n },\n write(file, content) {\n const abs = resolve(file);\n fs.mkdirSync(path.dirname(abs), { recursive: true });\n fs.writeFileSync(abs, content);\n },\n remove(file) {\n try {\n fs.rmSync(resolve(file));\n } catch {\n /* already gone */\n }\n },\n appendAudit(line) {\n const dir = path.join(root, '.vibgrate');\n fs.mkdirSync(dir, { recursive: true });\n fs.appendFileSync(path.join(dir, 'code-audit.jsonl'), line + '\\n');\n },\n };\n}\n\n/** Short, URL-safe correlation id. Not a graph artifact, so runtime randomness is fine here. */\nfunction shortId(): string {\n let s = '';\n const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';\n for (let i = 0; i < 8; i++) s += alphabet[Math.floor(Math.random() * alphabet.length)];\n return s;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { refreshIfStale, TOOLS, renderToolResult, warmEmbedderInBackground, countTokens } from './chunk-
|
|
2
|
-
import { VERSION } from './chunk-
|
|
1
|
+
import { refreshIfStale, TOOLS, renderToolResult, warmEmbedderInBackground, countTokens } from './chunk-GQTWDKMJ.js';
|
|
2
|
+
import { VERSION } from './chunk-ZFTFCM7B.js';
|
|
3
3
|
import { sanitizeClient, recordSaving, SAVINGS_TOOLS, PER_FILE_TOKENS } from './chunk-ZBTY6VV4.js';
|
|
4
4
|
import { loadGraphPreferIndex, renderHtml, renderReport } from './chunk-B3YUO3NW.js';
|
|
5
5
|
import { parseGraph, slimGraphForExport, serializeGraph } from './chunk-ZKNB4YH4.js';
|
|
@@ -420,5 +420,5 @@ function spdx(ctx) {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
export { GraphSource, createServer, exportGraph, formatForExt, serveStdio };
|
|
423
|
-
//# sourceMappingURL=chunk-
|
|
424
|
-
//# sourceMappingURL=chunk-
|
|
423
|
+
//# sourceMappingURL=chunk-WY6DGTBP.js.map
|
|
424
|
+
//# sourceMappingURL=chunk-WY6DGTBP.js.map
|