@vibgrate/cli 2026.721.3 → 2026.722.1
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/DOCS.md +185 -0
- package/README.md +2 -1
- package/dist/baseline-J44M7MWP.js +7 -0
- package/dist/{baseline-37G4TINM.js.map → baseline-J44M7MWP.js.map} +1 -1
- package/dist/chunk-2EVQKZTO.js +696 -0
- package/dist/chunk-2EVQKZTO.js.map +1 -0
- package/dist/chunk-6CXTPC74.js +234 -0
- package/dist/chunk-6CXTPC74.js.map +1 -0
- package/dist/chunk-CRAMOEBE.js +675 -0
- package/dist/chunk-CRAMOEBE.js.map +1 -0
- package/dist/chunk-CS37OBE3.js +861 -0
- package/dist/chunk-CS37OBE3.js.map +1 -0
- package/dist/chunk-CT5BS56U.js +23 -0
- package/dist/chunk-CT5BS56U.js.map +1 -0
- package/dist/{chunk-5PLKADD6.js → chunk-EXQV26MF.js} +4 -3
- package/dist/chunk-EXQV26MF.js.map +1 -0
- package/dist/chunk-GGJZA3Q6.js +961 -0
- package/dist/chunk-GGJZA3Q6.js.map +1 -0
- package/dist/chunk-JBXNQCGE.js +484 -0
- package/dist/chunk-JBXNQCGE.js.map +1 -0
- package/dist/chunk-JFGYT6BI.js +32 -0
- package/dist/chunk-JFGYT6BI.js.map +1 -0
- package/dist/{chunk-JLRF5TFA.js → chunk-JSNHZCIV.js} +42 -71
- package/dist/chunk-JSNHZCIV.js.map +1 -0
- package/dist/chunk-JYS4OBN2.js +148 -0
- package/dist/chunk-JYS4OBN2.js.map +1 -0
- package/dist/chunk-K3SLGULW.js +50 -0
- package/dist/chunk-K3SLGULW.js.map +1 -0
- package/dist/chunk-LEPTUB4H.js +108 -0
- package/dist/chunk-LEPTUB4H.js.map +1 -0
- package/dist/{chunk-IKJBELUV.js → chunk-PY3DNX5H.js} +4 -29
- package/dist/chunk-PY3DNX5H.js.map +1 -0
- package/dist/{chunk-ELUFCQDR.js → chunk-VXT6LUGP.js} +240 -2519
- package/dist/chunk-VXT6LUGP.js.map +1 -0
- package/dist/chunk-WNIIKCNF.js +972 -0
- package/dist/chunk-WNIIKCNF.js.map +1 -0
- package/dist/chunk-XKXKWYJF.js +417 -0
- package/dist/chunk-XKXKWYJF.js.map +1 -0
- package/dist/cli.js +2479 -1234
- package/dist/cli.js.map +1 -1
- package/dist/fs-KCABDURV.js +3 -0
- package/dist/fs-KCABDURV.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/interactive-736PBC7J.js +820 -0
- package/dist/interactive-736PBC7J.js.map +1 -0
- package/dist/mcp-tools-I6PME3AV.js +3 -0
- package/dist/mcp-tools-I6PME3AV.js.map +1 -0
- package/dist/parse-worker.js +2 -1
- package/dist/parse-worker.js.map +1 -1
- package/dist/session-POJUDFPH.js +6 -0
- package/dist/session-POJUDFPH.js.map +1 -0
- package/dist/session-store-W5RZZHA3.js +3 -0
- package/dist/session-store-W5RZZHA3.js.map +1 -0
- package/dist/stream-json-Q2JGWPHB.js +65 -0
- package/dist/stream-json-Q2JGWPHB.js.map +1 -0
- package/dist/ui-HOVOPWMX.js +4 -0
- package/dist/ui-HOVOPWMX.js.map +1 -0
- package/package.json +1 -1
- package/dist/baseline-37G4TINM.js +0 -6
- package/dist/chunk-5PLKADD6.js.map +0 -1
- package/dist/chunk-ELUFCQDR.js.map +0 -1
- package/dist/chunk-IKJBELUV.js.map +0 -1
- package/dist/chunk-JLRF5TFA.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/code/ensure.ts","../src/code/providers.ts","../src/code/context.ts","../src/code/apply.ts","../src/code/diff.ts","../src/code/prompt.ts"],"names":["mod","at","i","j"],"mappings":";;;;;;;;AAwDO,SAAS,eAAA,GAA0B;AACxC,EAAA,MAAM,OAAO,OAAA,CAAQ,GAAA,CAAI,kBAAuB,IAAA,CAAA,IAAA,CAAQ,EAAA,CAAA,OAAA,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tE,EAAA,OAAO;AAAA,IACL,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,mBAAA,EAAoB;AAAA,IAC/C,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAS,QAAQ,QAAA,EAAS;AAAA,IAC1C,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,CAAA,MAAA,EAAS,OAAA,CAAQ,WAAW,CAAA,CAAA;AAAG,GAC1D;AACF","file":"chunk-CS37OBE3.js","sourcesContent":["/**\n * Lazy, consent-gated runtime dependency install (VG-CLI-CODE §6).\n *\n * The code capability must stay lean by default: we ship **no** model weights\n * and **no** heavyweight inference runtime in the published package, and we do\n * not pull anything until the `code`/`models` commands are actually used for the\n * first time — and even then only with explicit consent. This mirrors the\n * existing optional-embedder pattern (a host-side install into its own storage\n * on consent), generalized so any provider backend that needs an out-of-tree\n * package can request it.\n *\n * Guarantees:\n * - `--local`/offline never installs (air-gapped stays air-gapped).\n * - Non-interactive runs never install silently — they require `--yes`.\n * - Nothing is written into the published package tree; installs live under a\n * per-user runtime cache and load via `createRequire` from there.\n * - The installer is injectable, so tests exercise every branch without ever\n * shelling out to npm.\n */\n\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport { pathToFileURL } from 'node:url';\n\n/** Why a package could not be made available — for calm, actionable messaging. */\nexport type EnsureFailure = 'offline' | 'no-consent' | 'install-failed' | 'load-failed';\n\nexport interface EnsureOptions {\n /** `--local`: never touch the network, never install. */\n local?: boolean;\n /** `--yes`/`--install`: consent to install without an interactive prompt. */\n consent?: boolean;\n /** Whether the caller is attached to an interactive TTY (defaults to a real check). */\n interactive?: boolean;\n /** Injectable installer — defaults to `npm install --prefix <dir> <spec>`. Returns true on success. */\n install?: (spec: string, dir: string) => boolean;\n /** Called (not thrown) with the reason when the package can't be provided. */\n onUnavailable?: (reason: EnsureFailure, spec: string) => void;\n}\n\nexport interface EnsureResult {\n /** The loaded module, or null when unavailable. */\n module: unknown | null;\n /** The runtime dir the package was resolved from (for diagnostics). */\n dir: string;\n reason?: EnsureFailure;\n}\n\n/**\n * The per-user runtime cache for on-demand packages. XDG-standard, shared across\n * repos (like the model cache), never inside the published package.\n * `$XDG_CACHE_HOME/vibgrate/runtime` (or `~/.cache/vibgrate/runtime`).\n */\nexport function runtimeCacheDir(): string {\n const base = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache');\n return path.join(base, 'vibgrate', 'runtime');\n}\n\n/** Whether `spec`'s package is already resolvable from the runtime cache. */\nexport function isPackageInstalled(spec: string): boolean {\n const name = packageName(spec);\n try {\n const req = createRequire(path.join(runtimeCacheDir(), 'package.json'));\n req.resolve(name);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * A one-line, actionable explanation of why a runtime dependency isn't available\n * — always names the off switch and the fix, never alarms (GUARDRAILS §1.3).\n */\nexport function ensureUnavailableMessage(reason: EnsureFailure, spec: string): string {\n const name = packageName(spec);\n switch (reason) {\n case 'offline':\n return `${name} is needed for this backend but --local/offline is set — using a backend that needs no install, or drop --local to allow a one-time install.`;\n case 'no-consent':\n return `${name} is needed for this backend and isn't installed yet. Re-run with --yes to install it once into ${runtimeCacheDir()} (nothing is written into the CLI itself), or pick a backend that needs no install (e.g. --provider ollama).`;\n case 'install-failed':\n return `couldn't install ${name} (offline, or npm unavailable) — using a backend that needs no install. It will try again next time.`;\n case 'load-failed':\n default:\n return `${name} installed but couldn't be loaded here — using a backend that needs no install.`;\n }\n}\n\n/**\n * Ensure `spec` (e.g. `node-llama-cpp@^3`) is available, installing it once into\n * the runtime cache with consent if needed, then load and return it. Returns\n * `{ module: null, reason }` on any refusal/failure — the caller degrades to a\n * backend that needs no install; it never throws for an unavailable optional\n * package.\n */\nexport async function ensurePackage(spec: string, options: EnsureOptions = {}): Promise<EnsureResult> {\n const dir = runtimeCacheDir();\n const fail = (reason: EnsureFailure): EnsureResult => {\n options.onUnavailable?.(reason, spec);\n return { module: null, dir, reason };\n };\n\n // Already present → just load it (no network, no consent needed).\n if (isPackageInstalled(spec)) {\n const mod = await load(spec, dir);\n return mod ? { module: mod, dir } : fail('load-failed');\n }\n\n // Not present. `--local`/offline forbids install outright.\n if (options.local) return fail('offline');\n\n // Non-interactive without consent must not install silently.\n const interactive = options.interactive ?? Boolean(process.stdout.isTTY && process.stdin.isTTY);\n if (!options.consent && !interactive) return fail('no-consent');\n if (!options.consent && interactive) return fail('no-consent'); // caller prompts, then re-invokes with consent\n\n // Install into the runtime cache.\n try {\n fs.mkdirSync(dir, { recursive: true });\n ensureRuntimeManifest(dir);\n } catch {\n return fail('install-failed');\n }\n const installer = options.install ?? defaultInstaller;\n const ok = installer(spec, dir);\n if (!ok || !isPackageInstalled(spec)) return fail('install-failed');\n\n const mod = await load(spec, dir);\n return mod ? { module: mod, dir } : fail('load-failed');\n}\n\n/** A minimal manifest so npm has a project to install into. */\nfunction ensureRuntimeManifest(dir: string): void {\n const manifest = path.join(dir, 'package.json');\n if (!fs.existsSync(manifest)) {\n fs.writeFileSync(\n manifest,\n JSON.stringify({ name: 'vibgrate-runtime-deps', private: true, description: 'On-demand vg runtime packages' }, null, 2),\n );\n }\n}\n\nasync function load(spec: string, dir: string): Promise<unknown | null> {\n const name = packageName(spec);\n try {\n const req = createRequire(path.join(dir, 'package.json'));\n const resolved = req.resolve(name);\n const mod: any = await import(pathToFileURL(resolved).href);\n return mod?.default ?? mod;\n } catch {\n return null;\n }\n}\n\n/** `npm install --prefix <dir> <spec>` with no scripts, quiet. */\nfunction defaultInstaller(spec: string, dir: string): boolean {\n const res = spawnSync('npm', ['install', '--prefix', dir, '--no-audit', '--no-fund', '--ignore-scripts', spec], {\n stdio: 'ignore',\n timeout: 180_000,\n });\n return res.status === 0;\n}\n\n/** Strip a version range from a spec → the bare package name (scoped-safe). */\nexport function packageName(spec: string): string {\n if (spec.startsWith('@')) {\n const at = spec.indexOf('@', 1);\n return at === -1 ? spec : spec.slice(0, at);\n }\n const at = spec.indexOf('@');\n return at === -1 ? spec : spec.slice(0, at);\n}\n","/**\n * Model backends for `vg code` (VG-CLI-CODE §5).\n *\n * Every backend implements the same {@link Provider} contract, so the router and\n * session are provider-agnostic. Three families:\n * - **local HTTP** — Ollama and LM Studio, reached over `fetch` on localhost;\n * no package, no key, no egress. Selected under `--local`.\n * - **hosted HTTP** — any OpenAI-compatible endpoint (OpenRouter, LiteLLM,\n * Together, a self-hosted gateway, …). One shape covers the \"best in breed\n * router\" story: an ordered model list with automatic fallback lives in the\n * router, not here. Keys come from the environment only and are never logged.\n * - **local inference** — a llama.cpp binding loaded on demand via\n * {@link ensurePackage}; this is the one path that may install a package on\n * first use, and only with consent. Model weights are never auto-downloaded.\n *\n * A deterministic {@link MockProvider} backs the tests, the offline benchmark,\n * and the `--mock` flag, so the whole loop runs end-to-end with no network.\n */\n\nimport { ensurePackage, ensureUnavailableMessage } from './ensure.js';\nimport type { ChatMessage, ChatOptions, Provider, ProviderResult, ToolCall, ToolSpec } from './types.js';\n\n/* ------------------------------------------------------------------ *\\\n * Tool-calling wire helpers (shared by the HTTP providers)\n\\* ------------------------------------------------------------------ */\n\n/** Map our ChatMessage union to OpenAI-compatible wire messages (tool calls included). */\nfunction openAiMessages(messages: ChatMessage[]): unknown[] {\n return messages.map((m) => {\n if (m.role === 'tool') return { role: 'tool', tool_call_id: m.toolCallId, name: m.name, content: m.content };\n if (m.role === 'assistant' && m.toolCalls?.length) {\n return {\n role: 'assistant',\n content: m.content || null,\n tool_calls: m.toolCalls.map((t) => ({ id: t.id, type: 'function', function: { name: t.name, arguments: JSON.stringify(t.arguments) } })),\n };\n }\n return { role: m.role, content: m.content };\n });\n}\n\n/** OpenAI-compatible `tools` array from our specs. */\nfunction openAiTools(tools: ToolSpec[] | undefined): unknown[] | undefined {\n if (!tools?.length) return undefined;\n return tools.map((t) => ({ type: 'function', function: { name: t.name, description: t.description, parameters: t.parameters } }));\n}\n\n/** Parse OpenAI-shaped tool_calls, tolerating a malformed arguments string. */\nfunction parseToolCalls(raw: unknown, synthesizePrefix = 'call'): ToolCall[] {\n const calls = raw as { id?: string; function?: { name?: string; arguments?: unknown } }[] | undefined;\n if (!Array.isArray(calls)) return [];\n return calls.map((c, i) => ({\n id: typeof c.id === 'string' && c.id ? c.id : `${synthesizePrefix}_${i}`,\n name: c.function?.name ?? 'unknown',\n arguments: coerceArgs(c.function?.arguments),\n }));\n}\n\nfunction coerceArgs(raw: unknown): Record<string, unknown> {\n if (raw && typeof raw === 'object') return raw as Record<string, unknown>;\n if (typeof raw === 'string') {\n try {\n const parsed = JSON.parse(raw);\n return parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n }\n return {};\n}\n\n/** Redact anything that looks like a credential before it can reach a log/error. */\nexport function redactSecrets(s: string): string {\n return s\n .replace(/\\b(sk|xoxb|ghp|gho|glpat|AKIA)[-_][A-Za-z0-9-_]{6,}/g, '$1-***redacted***')\n .replace(/Bearer\\s+[A-Za-z0-9._-]{8,}/gi, 'Bearer ***redacted***');\n}\n\n/** Common HTTP-completion error shaping: actionable, internals-free (GUARDRAILS §1.3). */\nfunction httpError(label: string, status: number, hint: string): Error {\n return new Error(`${label} returned HTTP ${status} — ${hint}`);\n}\n\n/** Yield newline-delimited lines from a streamed response body. */\nasync function* streamLines(res: Response): AsyncGenerator<string> {\n const reader = res.body?.getReader();\n if (!reader) return;\n const decoder = new TextDecoder();\n let buf = '';\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n buf += decoder.decode(value, { stream: true });\n let idx: number;\n while ((idx = buf.indexOf('\\n')) >= 0) {\n const line = buf.slice(0, idx).trim();\n buf = buf.slice(idx + 1);\n if (line) yield line;\n }\n }\n if (buf.trim()) yield buf.trim();\n}\n\n/** Accumulate an OpenAI-compatible SSE stream into text + tool calls + usage. */\nexport function accumulateOpenAiDelta(\n acc: { text: string; tools: Map<number, { id?: string; name?: string; args: string }>; usage: { promptTokens?: number; completionTokens?: number } },\n chunk: unknown,\n onToken?: (t: string) => void,\n): void {\n const c = chunk as { choices?: { delta?: { content?: string; tool_calls?: { index?: number; id?: string; function?: { name?: string; arguments?: string } }[] } }[]; usage?: { prompt_tokens?: number; completion_tokens?: number } };\n const delta = c.choices?.[0]?.delta;\n if (delta?.content) {\n acc.text += delta.content;\n onToken?.(delta.content);\n }\n for (const tc of delta?.tool_calls ?? []) {\n const idx = tc.index ?? 0;\n const e = acc.tools.get(idx) ?? { args: '' };\n if (tc.id) e.id = tc.id;\n if (tc.function?.name) e.name = tc.function.name;\n if (tc.function?.arguments) e.args += tc.function.arguments;\n acc.tools.set(idx, e);\n }\n if (c.usage) {\n acc.usage.promptTokens = c.usage.prompt_tokens;\n acc.usage.completionTokens = c.usage.completion_tokens;\n }\n}\n\n/** Turn accumulated OpenAI tool-call fragments into ToolCalls. */\nfunction finalizeTools(tools: Map<number, { id?: string; name?: string; args: string }>): ToolCall[] {\n return [...tools.entries()]\n .sort((a, b) => a[0] - b[0])\n .map(([i, e]) => ({ id: e.id ?? `call_${i}`, name: e.name ?? 'unknown', arguments: coerceArgs(e.args) }));\n}\n\nasync function postJson(url: string, body: unknown, headers: Record<string, string>, timeoutMs: number): Promise<Response> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json', ...headers }, body: JSON.stringify(body), signal: controller.signal });\n } finally {\n clearTimeout(timer);\n }\n}\n\n/* ------------------------------------------------------------------ *\\\n * Deterministic mock (tests / offline / --mock)\n\\* ------------------------------------------------------------------ */\n\n/**\n * A provider that returns a fixed, scripted reply — the deterministic floor that\n * lets the entire `vg code` loop run offline. Used by tests, the benchmark, and\n * the `--mock` flag (which reads the scripted edit blocks from a file).\n */\nexport class MockProvider implements Provider {\n readonly id = 'mock';\n readonly label = 'Mock (deterministic)';\n readonly local = true;\n constructor(\n readonly model: string,\n private readonly reply: string,\n ) {}\n async chat(_messages?: ChatMessage[], _opts?: ChatOptions): Promise<ProviderResult> {\n return { text: this.reply, model: this.model, provider: this.id };\n }\n}\n\n/* ------------------------------------------------------------------ *\\\n * Ollama (local, no key)\n\\* ------------------------------------------------------------------ */\n\nexport class OllamaProvider implements Provider {\n readonly id = 'ollama';\n readonly label = 'Ollama (local)';\n readonly local = true;\n constructor(\n readonly model: string,\n private readonly host = process.env.OLLAMA_HOST || 'http://127.0.0.1:11434',\n ) {}\n async chat(messages: ChatMessage[], opts: ChatOptions = {}): Promise<ProviderResult> {\n const streaming = !!(opts.stream && opts.onToken);\n let res: Response;\n try {\n res = await postJson(\n `${this.host.replace(/\\/$/, '')}/api/chat`,\n { model: this.model, messages: openAiMessages(messages), stream: streaming, tools: openAiTools(opts.tools), options: { temperature: opts.temperature ?? 0 } },\n {},\n opts.timeoutMs ?? 120_000,\n );\n } catch {\n throw new Error(`couldn't reach Ollama at ${this.host} — is \\`ollama serve\\` running? (start it, or pass --provider to use a different backend)`);\n }\n if (!res.ok) throw httpError('Ollama', res.status, res.status === 404 ? `model \"${this.model}\" isn't pulled — run \\`ollama pull ${this.model}\\` or pick another with --model` : 'check `ollama serve` and the model name');\n\n if (streaming) {\n let text = '';\n let toolCallsRaw: unknown;\n const usage: { promptTokens?: number; completionTokens?: number } = {};\n for await (const line of streamLines(res)) {\n try {\n const obj = JSON.parse(line) as { message?: { content?: string; tool_calls?: unknown }; prompt_eval_count?: number; eval_count?: number };\n const delta = obj.message?.content;\n if (delta) {\n text += delta;\n opts.onToken?.(delta);\n }\n if (obj.message?.tool_calls) toolCallsRaw = obj.message.tool_calls;\n if (typeof obj.prompt_eval_count === 'number') usage.promptTokens = obj.prompt_eval_count;\n if (typeof obj.eval_count === 'number') usage.completionTokens = obj.eval_count;\n } catch {\n /* skip a malformed line */\n }\n }\n return { text, model: this.model, provider: this.id, toolCalls: parseToolCalls(toolCallsRaw), usage };\n }\n\n const data = (await res.json()) as { message?: { content?: string; tool_calls?: unknown }; prompt_eval_count?: number; eval_count?: number };\n return {\n text: data.message?.content ?? '',\n model: this.model,\n provider: this.id,\n toolCalls: parseToolCalls(data.message?.tool_calls),\n usage: { promptTokens: data.prompt_eval_count, completionTokens: data.eval_count },\n };\n }\n}\n\n/* ------------------------------------------------------------------ *\\\n * OpenAI-compatible (LM Studio, OpenRouter, LiteLLM, …)\n\\* ------------------------------------------------------------------ */\n\nexport interface OpenAiCompatibleConfig {\n /** Base URL, e.g. `https://openrouter.ai/api/v1` or `http://127.0.0.1:1234/v1`. */\n baseUrl: string;\n /** Env var name holding the API key (never the key itself). Absent for local. */\n apiKeyEnv?: string;\n /** Whether this endpoint is on-device (LM Studio) vs hosted. */\n local: boolean;\n /** Display label. */\n label: string;\n id: string;\n}\n\nexport class OpenAiCompatibleProvider implements Provider {\n readonly id: string;\n readonly label: string;\n readonly local: boolean;\n constructor(\n readonly model: string,\n private readonly config: OpenAiCompatibleConfig,\n ) {\n this.id = config.id;\n this.label = config.label;\n this.local = config.local;\n }\n async chat(messages: ChatMessage[], opts: ChatOptions = {}): Promise<ProviderResult> {\n const headers: Record<string, string> = {};\n if (this.config.apiKeyEnv) {\n const key = process.env[this.config.apiKeyEnv];\n if (!key) {\n throw new Error(`${this.label} needs an API key in ${this.config.apiKeyEnv} — set it in your environment (never pass keys as flags), or use --local for an on-device backend.`);\n }\n headers.authorization = `Bearer ${key}`;\n }\n const streaming = !!(opts.stream && opts.onToken);\n const url = `${this.config.baseUrl.replace(/\\/$/, '')}/chat/completions`;\n const body = {\n model: this.model,\n messages: openAiMessages(messages),\n tools: openAiTools(opts.tools),\n temperature: opts.temperature ?? 0,\n max_tokens: opts.maxTokens,\n stream: streaming,\n ...(streaming ? { stream_options: { include_usage: true } } : {}),\n };\n let res: Response;\n try {\n res = await postJson(url, body, headers, opts.timeoutMs ?? 120_000);\n } catch {\n throw new Error(`couldn't reach ${this.label} at ${this.config.baseUrl} — check the endpoint is up (or use --local).`);\n }\n if (!res.ok) {\n const hint = res.status === 401 || res.status === 403 ? `the key in ${this.config.apiKeyEnv ?? '(none)'} was rejected — check it has access to \"${this.model}\"` : `check the model id \"${this.model}\" and the endpoint`;\n throw httpError(this.label, res.status, hint);\n }\n\n if (streaming) {\n const acc = { text: '', tools: new Map<number, { id?: string; name?: string; args: string }>(), usage: {} as { promptTokens?: number; completionTokens?: number } };\n for await (const line of streamLines(res)) {\n if (!line.startsWith('data:')) continue;\n const payload = line.slice(5).trim();\n if (payload === '[DONE]') break;\n try {\n accumulateOpenAiDelta(acc, JSON.parse(payload), opts.onToken);\n } catch {\n /* skip a malformed chunk */\n }\n }\n const tools = finalizeTools(acc.tools);\n return { text: acc.text, model: this.model, provider: this.id, toolCalls: tools.length ? tools : undefined, usage: acc.usage };\n }\n const data = (await res.json()) as { choices?: { message?: { content?: string; tool_calls?: unknown } }[]; usage?: { prompt_tokens?: number; completion_tokens?: number } };\n const message = data.choices?.[0]?.message;\n return {\n text: message?.content ?? '',\n model: this.model,\n provider: this.id,\n toolCalls: parseToolCalls(message?.tool_calls),\n usage: { promptTokens: data.usage?.prompt_tokens, completionTokens: data.usage?.completion_tokens },\n };\n }\n}\n\n/* ------------------------------------------------------------------ *\\\n * Scripted provider (agent-loop tests / offline demos)\n\\* ------------------------------------------------------------------ */\n\n/**\n * Returns a queued sequence of {@link ProviderResult}s — one per turn — so the\n * agentic loop can be driven deterministically offline: script the tool calls\n * the \"model\" makes (read → search → edit → run → finish) and assert what the\n * agent did. Ignores the incoming messages by design.\n */\nexport class ScriptedProvider implements Provider {\n readonly id = 'scripted';\n readonly label = 'Scripted (deterministic)';\n readonly local = true;\n private turn = 0;\n constructor(\n readonly model: string,\n private readonly steps: Array<{ text?: string; toolCalls?: ToolCall[] }>,\n ) {}\n async chat(): Promise<ProviderResult> {\n const step = this.steps[Math.min(this.turn, this.steps.length - 1)];\n this.turn++;\n return { text: step.text ?? '', model: this.model, provider: this.id, toolCalls: step.toolCalls };\n }\n}\n\n/** The catalogue of known OpenAI-compatible endpoints, keyed by short id. */\nexport const OPENAI_COMPATIBLE: Record<string, Omit<OpenAiCompatibleConfig, 'label' | 'id'> & { label: string }> = {\n openrouter: { baseUrl: 'https://openrouter.ai/api/v1', apiKeyEnv: 'OPENROUTER_API_KEY', local: false, label: 'OpenRouter' },\n litellm: { baseUrl: process.env.LITELLM_BASE_URL || 'http://127.0.0.1:4000', apiKeyEnv: 'LITELLM_API_KEY', local: false, label: 'LiteLLM' },\n openai: { baseUrl: 'https://api.openai.com/v1', apiKeyEnv: 'OPENAI_API_KEY', local: false, label: 'OpenAI' },\n together: { baseUrl: 'https://api.together.xyz/v1', apiKeyEnv: 'TOGETHER_API_KEY', local: false, label: 'Together' },\n lmstudio: { baseUrl: process.env.LMSTUDIO_BASE_URL || 'http://127.0.0.1:1234/v1', local: true, label: 'LM Studio (local)' },\n};\n\n/* ------------------------------------------------------------------ *\\\n * Local llama.cpp (installs a package on first use, with consent)\n\\* ------------------------------------------------------------------ */\n\n/**\n * A fully-local inference backend backed by `node-llama-cpp`. This is the one\n * provider that may install a package on first use — and only through\n * {@link ensurePackage} (consent-gated, never under `--local`/offline, never\n * bundled). Model *weights* are never fetched automatically: `modelPath` must\n * point at a gguf the user already has (see `vg models`). When the runtime\n * isn't available it degrades with an actionable note rather than throwing.\n */\nexport class LocalLlamaProvider implements Provider {\n readonly id = 'llama-cpp';\n readonly label = 'llama.cpp (local)';\n readonly local = true;\n private session: unknown | null = null;\n constructor(\n readonly model: string,\n private readonly modelPath: string,\n private readonly ensure: typeof ensurePackage = ensurePackage,\n private readonly consent = false,\n ) {}\n async chat(messages: ChatMessage[], opts: ChatOptions = {}): Promise<ProviderResult> {\n const res = await this.ensure('node-llama-cpp@^3', { consent: this.consent, onUnavailable: () => {} });\n if (!res.module) {\n throw new Error(ensureUnavailableMessage(res.reason ?? 'no-consent', 'node-llama-cpp'));\n }\n // The concrete llama binding call is intentionally isolated here; the rest of\n // the subsystem never depends on it. Kept minimal and defensive.\n const lib: any = res.module;\n try {\n const llama = await lib.getLlama();\n const model = await llama.loadModel({ modelPath: this.modelPath });\n const ctx = await model.createContext();\n const { LlamaChatSession } = lib;\n const chat = new LlamaChatSession({ contextSequence: ctx.getSequence() });\n const prompt = messages.map((m) => `${m.role}: ${m.content}`).join('\\n\\n');\n const text: string = await chat.prompt(prompt, { temperature: opts.temperature ?? 0, maxTokens: opts.maxTokens });\n return { text, model: this.model, provider: this.id };\n } catch (e) {\n throw new Error(`local llama.cpp inference failed for ${this.modelPath} — ${redactSecrets((e as Error).message)}`);\n }\n }\n}\n","/**\n * Graph-grounded context assembly for `vg code` (VG-CLI-CODE §3).\n *\n * A generic coding agent starts blind and reconstructs structure by grepping and\n * reading whole files — which is exactly what blows the context window and\n * degrades the model. This module instead uses the deterministic code graph to\n * hand the planner a *small, high-signal, budget-bounded* context: the symbols\n * most relevant to the instruction, their immediate relations, the blast radius\n * of changing them, and any declared facts (hard constraints) that must not be\n * dropped by later compaction. Deterministic given a graph + instruction, so it\n * is fully offline-testable and benchmarkable.\n */\n\nimport { queryGraph } from '../engine/query.js';\nimport { indexFor } from '../engine/relations.js';\nimport { impactOf } from '../engine/impact.js';\nimport type { CodeContext } from './types.js';\nimport type { GraphNode, VgGraph } from '../schema.js';\n\nexport interface BuildContextOptions {\n /** Approx token budget for the rendered block (default 3000). */\n budget?: number;\n /** How many retrieval seeds to expand (default 8). */\n seeds?: number;\n /** Impact BFS depth for the blast radius (default 2). */\n impactDepth?: number;\n /** Restrict the edit surface to these files (from `--file`), if given. */\n files?: string[];\n}\n\n/**\n * Build the context block for a coding instruction. The ordering is\n * cache-stable by design (see router.ts): the invariant, repo-derived material\n * (facts, symbols, relations) comes first and the volatile instruction is\n * echoed last, so a provider's prompt cache can reuse the stable prefix across\n * turns.\n */\nexport function buildCodeContext(graph: VgGraph, instruction: string, options: BuildContextOptions = {}): CodeContext {\n const budget = options.budget ?? 3000;\n const seedLimit = options.seeds ?? 8;\n const impactDepth = options.impactDepth ?? 2;\n const index = indexFor(graph);\n\n // Retrieval seeds: reuse the deterministic lexical/structural retrieval that\n // backs `vg ask`. When `--file` narrows the surface, keep only seeds in those\n // files (but still let impact reach outside them, so the review is honest).\n const q = queryGraph(graph, instruction, { budget: Math.floor(budget * 0.6), limit: seedLimit * 2 });\n let seeds = q.matches.map((m) => ({ node: m.node, why: m.why }));\n if (options.files && options.files.length) {\n const set = new Set(options.files.map(normalize));\n const inScope = seeds.filter((s) => set.has(normalize(s.node.file)));\n // If nothing matched inside the named files, keep the best global seeds but\n // still steer target files to what the caller asked for.\n if (inScope.length) seeds = inScope;\n }\n seeds = seeds.slice(0, seedLimit);\n\n // Blast radius: who depends on the seeds. This is the impact-aware review\n // signal — an edit to a hub is riskier and the context says so.\n const impacted = new Map<string, { node: GraphNode; via: string }>();\n for (const s of seeds) {\n const impact = impactOf(graph, s.node.id, { depth: impactDepth });\n for (const item of impact.affected.slice(0, 6)) {\n const node = index.node(item.id);\n if (node && !impacted.has(node.id)) impacted.set(node.id, { node, via: s.node.qualifiedName });\n }\n }\n\n // Target files: the seed files (or the explicit --file set), stable order.\n const targetFiles = options.files?.length\n ? [...new Set(options.files.map(normalize))].sort()\n : [...new Set(seeds.map((s) => s.node.file))].sort();\n\n // Pinned facts: declared invariants/contracts that touch the seeds. These are\n // hard constraints; they are surfaced explicitly and never summarized away.\n const seedIds = new Set(seeds.map((s) => s.node.id));\n const pinnedFacts = pinnedFactsFor(graph, seedIds);\n\n const rendered = render(instruction, seeds, [...impacted.values()], targetFiles, pinnedFacts, index, budget);\n return {\n instruction,\n seeds,\n targetFiles,\n impacted: [...impacted.values()],\n pinnedFacts,\n rendered,\n tokensEstimate: estimateTokens(rendered),\n };\n}\n\nfunction pinnedFactsFor(graph: VgGraph, seedIds: Set<string>): string[] {\n if (!graph.facts?.length) return [];\n const out: string[] = [];\n for (const f of graph.facts) {\n if (f.kind === 'characterization') continue; // keep hard constraints only\n if (!f.subjectIds.some((id) => seedIds.has(id))) continue;\n const subjects = f.subjectIds\n .map((id) => graph.nodes.find((n) => n.id === id)?.qualifiedName ?? id)\n .join(', ');\n out.push(`${f.kind}: ${subjects} — ${JSON.stringify(f.predicate)}`);\n }\n return out.sort().slice(0, 12);\n}\n\nfunction render(\n instruction: string,\n seeds: { node: GraphNode; why: string }[],\n impacted: { node: GraphNode; via: string }[],\n targetFiles: string[],\n pinnedFacts: string[],\n index: ReturnType<typeof indexFor>,\n budget: number,\n): string {\n const lines: string[] = [];\n lines.push('# Repository context (from the deterministic code graph)');\n lines.push('');\n\n if (pinnedFacts.length) {\n lines.push('## Hard constraints (do not violate)');\n for (const f of pinnedFacts) lines.push(`- ${f}`);\n lines.push('');\n }\n\n lines.push('## Relevant symbols');\n for (const { node, why } of seeds) {\n const block: string[] = [];\n block.push(`### ${node.qualifiedName} (${node.kind}, ${node.file}:${node.span.start}-${node.span.end})`);\n if (node.signature) block.push('`' + node.signature + '`');\n const callees = uniqueNames(index.callees(node.id).map((x) => x.node.qualifiedName)).slice(0, 6);\n const callers = uniqueNames(index.callers(node.id).map((x) => x.node.qualifiedName)).slice(0, 6);\n if (callees.length) block.push(`calls: ${callees.join(', ')}`);\n if (callers.length) block.push(`called by: ${callers.join(', ')}`);\n block.push(`importance ${node.importance.toFixed(3)}${node.isHub ? ' · hub (high blast radius)' : ''} · ${why}`);\n block.push('');\n const candidate = lines.concat(block).join('\\n');\n if (estimateTokens(candidate) > budget && lines.length > 3) break;\n lines.push(...block);\n }\n\n if (impacted.length) {\n lines.push('## Blast radius (would be affected by a change here)');\n for (const { node, via } of impacted.slice(0, 10)) {\n lines.push(`- ${node.qualifiedName} (${node.file}:${node.span.start}) — depends on ${via}`);\n }\n lines.push('');\n }\n\n lines.push('## Files in scope for this edit');\n for (const f of targetFiles) lines.push(`- ${f}`);\n lines.push('');\n\n lines.push('## Task');\n lines.push(instruction);\n return lines.join('\\n');\n}\n\nfunction uniqueNames(xs: string[]): string[] {\n return [...new Set(xs)];\n}\n\nfunction normalize(file: string): string {\n return file.replace(/\\\\/g, '/').replace(/^\\.\\//, '');\n}\n\nfunction estimateTokens(text: string): number {\n return Math.ceil(text.length / 4);\n}\n","/**\n * The deterministic fast-apply merge engine (VG-CLI-CODE §4).\n *\n * Speed in the fast coding tools comes from letting the planner emit a *terse*\n * edit instead of rewriting a whole file; correctness comes from applying that\n * edit **deterministically and scoped**, never by letting the model free-hand\n * the merge. This module is that deterministic floor: it parses the\n * search/replace edit form and applies it with three escalating match\n * strategies — exact, whitespace-flexible, then graph-span-scoped — so an\n * ambiguous SEARCH is resolved to the symbol the planner actually named rather\n * than the first textual hit. No model is required to apply an edit; a hosted\n * fast-apply model is only ever an *acceleration* over this same contract.\n *\n * Everything here is pure and deterministic: identical (content, edit) always\n * yields the identical outcome, which is what makes it unit- and\n * benchmark-testable offline.\n */\n\nimport type { CodeEdit, EditOutcome } from './types.js';\n\n/** A symbol span the graph knows about, used to disambiguate a SEARCH match. */\nexport interface SymbolSpan {\n /** Qualified name, matched against `anchorSymbol`. */\n qualifiedName: string;\n file: string;\n /** 1-based inclusive line range. */\n start: number;\n end: number;\n}\n\n/**\n * Parse a model's reply into structured edits. The accepted form is the\n * widely-supported search/replace block (robust to surrounding prose and code\n * fences), plus explicit whole-file create/delete markers:\n *\n * ```\n * path/to/file.ts\n * <<<<<<< SEARCH\n * old code\n * =======\n * new code\n * >>>>>>> REPLACE\n * ```\n *\n * `CREATE path/to/new.ts` … `END CREATE` wraps a new file's whole body;\n * `DELETE path/to/gone.ts` removes a file. Parsing is forgiving of blank lines\n * and fences but strict about the block markers, so a malformed block surfaces\n * as an `invalid` outcome at apply time rather than silently corrupting a file.\n */\nexport function parseEdits(text: string): CodeEdit[] {\n const edits: CodeEdit[] = [];\n const lines = text.split('\\n');\n let i = 0;\n let pendingFile = '';\n\n const isFence = (s: string): boolean => /^\\s*```/.test(s);\n\n while (i < lines.length) {\n const line = lines[i];\n\n // Whole-file create: `CREATE <path>` … `END CREATE`.\n const create = /^\\s*CREATE\\s+(\\S.*?)\\s*$/.exec(line);\n if (create) {\n const file = create[1];\n const body: string[] = [];\n i++;\n while (i < lines.length && !/^\\s*END CREATE\\s*$/.test(lines[i])) {\n if (!isFence(lines[i])) body.push(lines[i]);\n i++;\n }\n i++; // consume END CREATE\n edits.push({ op: 'create', file, content: body.join('\\n') });\n pendingFile = '';\n continue;\n }\n\n // Whole-file delete: `DELETE <path>`.\n const del = /^\\s*DELETE\\s+(\\S.*?)\\s*$/.exec(line);\n if (del) {\n edits.push({ op: 'delete', file: del[1] });\n i++;\n pendingFile = '';\n continue;\n }\n\n // Search/replace block. The file path is the most recent non-fence,\n // non-blank line before the SEARCH marker (or an inline `path` on it).\n if (/^\\s*<{5,}\\s*SEARCH/.test(line)) {\n const file = pendingFile;\n const search: string[] = [];\n const replace: string[] = [];\n i++;\n while (i < lines.length && !/^\\s*={5,}\\s*$/.test(lines[i])) {\n search.push(lines[i]);\n i++;\n }\n i++; // consume =======\n while (i < lines.length && !/^\\s*>{5,}\\s*REPLACE/.test(lines[i])) {\n replace.push(lines[i]);\n i++;\n }\n i++; // consume >>>>>>> REPLACE\n edits.push({\n op: 'replace',\n file,\n search: search.join('\\n'),\n replace: replace.join('\\n'),\n anchorSymbol: undefined,\n });\n continue;\n }\n\n // Track the most recent file-path candidate: a lone token that looks like a\n // path (has a slash or a file extension) and isn't a fence/marker.\n const trimmed = line.trim();\n if (trimmed && !isFence(line) && looksLikePath(trimmed)) pendingFile = trimmed.replace(/[:`]+$/, '');\n i++;\n }\n\n return edits;\n}\n\nfunction looksLikePath(s: string): boolean {\n if (/\\s/.test(s.replace(/:$/, ''))) return false; // paths don't contain spaces\n return /\\//.test(s) || /\\.[A-Za-z0-9]{1,8}:?$/.test(s);\n}\n\n/**\n * Apply a single edit to a file's current content (or `null` when the file does\n * not exist). Pure: returns the new content and an outcome; never touches disk.\n * The `spans` are the graph's symbol spans for this file — when a SEARCH is\n * textually ambiguous, a match inside the `anchorSymbol` span wins, which is how\n * the graph makes a terse edit land where the planner meant it to.\n */\nexport function applyEdit(\n content: string | null,\n edit: CodeEdit,\n spans: SymbolSpan[] = [],\n): { content: string | null; outcome: EditOutcome } {\n if (edit.op === 'create') {\n if (content !== null && content !== edit.content) {\n return { content, outcome: { edit, status: 'conflict', reason: `${edit.file} already exists — refusing to overwrite it with a create; use a replace edit instead` } };\n }\n return { content: edit.content, outcome: { edit, status: content === edit.content ? 'no-op' : 'applied', matchedBy: 'exact' } };\n }\n\n if (edit.op === 'delete') {\n if (content === null) return { content: null, outcome: { edit, status: 'no-op', reason: `${edit.file} does not exist — nothing to delete` } };\n return { content: null, outcome: { edit, status: 'applied', matchedBy: 'exact' } };\n }\n\n // op === 'replace'\n if (content === null) {\n return { content: null, outcome: { edit, status: 'not-found', reason: `${edit.file} does not exist — a replace needs an existing file (did you mean CREATE ${edit.file}?)` } };\n }\n if (edit.search === '') {\n // Empty SEARCH means \"prepend\" only when the file is empty; otherwise it is\n // ambiguous and we refuse rather than guess a location.\n if (content === '') return { content: edit.replace, outcome: { edit, status: 'applied', matchedBy: 'exact' } };\n return { content, outcome: { edit, status: 'invalid', reason: 'empty SEARCH on a non-empty file is ambiguous — quote the exact lines to replace' } };\n }\n if (edit.search === edit.replace) {\n return { content, outcome: { edit, status: 'no-op', reason: 'SEARCH and REPLACE are identical — no change' } };\n }\n\n const located = locate(content, edit.search, edit.anchorSymbol, spans, edit.file);\n if (located.kind === 'none') {\n return { content, outcome: { edit, status: 'not-found', reason: `the SEARCH text was not found in ${edit.file} — it must match the current file exactly (whitespace-flexible)` } };\n }\n if (located.kind === 'ambiguous') {\n return {\n content,\n outcome: {\n edit,\n status: 'ambiguous',\n reason: `the SEARCH text matches ${located.count} places in ${edit.file} — add more surrounding lines, or name the symbol so the graph can disambiguate`,\n },\n };\n }\n const next = content.slice(0, located.from) + edit.replace + content.slice(located.to);\n return { content: next, outcome: { edit, status: 'applied', matchedBy: located.matchedBy } };\n}\n\n/**\n * Apply a set of edits across a set of files. `read(file)` returns current\n * content or `null`. Edits are applied in the order given, threading each\n * file's evolving content so two edits to the same file compose. Returns, per\n * file, its before/after content and the per-edit outcomes — the dry-run\n * product the session turns into diffs. Deterministic given a deterministic\n * `read`.\n */\nexport function applyEdits(\n edits: CodeEdit[],\n read: (file: string) => string | null,\n spansByFile: (file: string) => SymbolSpan[] = () => [],\n): Map<string, { before: string | null; after: string | null; outcomes: EditOutcome[] }> {\n const state = new Map<string, { before: string | null; after: string | null; outcomes: EditOutcome[] }>();\n for (const edit of edits) {\n let entry = state.get(edit.file);\n if (!entry) {\n const before = read(edit.file);\n entry = { before, after: before, outcomes: [] };\n state.set(edit.file, entry);\n }\n const { content, outcome } = applyEdit(entry.after, edit, spansByFile(edit.file));\n entry.after = content;\n entry.outcomes.push(outcome);\n }\n return state;\n}\n\ntype Located =\n | { kind: 'unique'; from: number; to: number; matchedBy: 'exact' | 'whitespace' | 'graph-span' }\n | { kind: 'ambiguous'; count: number }\n | { kind: 'none' };\n\n/**\n * Find the SEARCH text in the content. Escalates: (1) exact substring; (2)\n * whitespace-flexible (indentation/trailing-space differences tolerated); and\n * when either is ambiguous, (3) narrow to the `anchorSymbol`'s graph span so the\n * intended occurrence wins. Line-oriented so offsets map back to real edits.\n */\nfunction locate(content: string, search: string, anchor: string | undefined, spans: SymbolSpan[], file: string): Located {\n const exact = allIndexes(content, search);\n if (exact.length === 1) return { kind: 'unique', from: exact[0], to: exact[0] + search.length, matchedBy: 'exact' };\n if (exact.length > 1) {\n const scoped = scopeToAnchor(content, exact.map((from) => ({ from, to: from + search.length })), anchor, spans, file);\n if (scoped) return { ...scoped, matchedBy: 'graph-span' };\n return { kind: 'ambiguous', count: exact.length };\n }\n\n // Whitespace-flexible: compare with runs of whitespace collapsed and each\n // line trimmed, then map the match back to real character offsets.\n const flex = flexIndexes(content, search);\n if (flex.length === 1) return { kind: 'unique', from: flex[0].from, to: flex[0].to, matchedBy: 'whitespace' };\n if (flex.length > 1) {\n const scoped = scopeToAnchor(content, flex, anchor, spans, file);\n if (scoped) return { ...scoped, matchedBy: 'graph-span' };\n return { kind: 'ambiguous', count: flex.length };\n }\n return { kind: 'none' };\n}\n\n/** Every start index of `needle` in `hay` (non-overlapping left-to-right). */\nfunction allIndexes(hay: string, needle: string): number[] {\n const out: number[] = [];\n if (needle === '') return out;\n let from = 0;\n for (;;) {\n const idx = hay.indexOf(needle, from);\n if (idx === -1) break;\n out.push(idx);\n from = idx + needle.length;\n }\n return out;\n}\n\n/**\n * Whitespace-flexible match: align the search's trimmed non-empty lines against\n * the content's lines, tolerating indentation and trailing-whitespace drift\n * (the single most common reason an otherwise-correct terse edit fails to\n * apply). Returns real character offset ranges for each full-block match.\n */\nfunction flexIndexes(content: string, search: string): { from: number; to: number }[] {\n const cLines = content.split('\\n');\n const sLines = search.split('\\n');\n // Trim a possible leading/trailing blank line from the search block.\n while (sLines.length && sLines[0].trim() === '') sLines.shift();\n while (sLines.length && sLines[sLines.length - 1].trim() === '') sLines.pop();\n if (sLines.length === 0) return [];\n const sNorm = sLines.map((l) => l.trim());\n\n // Precompute char offset of the start of each content line.\n const lineStart: number[] = [];\n let acc = 0;\n for (const l of cLines) {\n lineStart.push(acc);\n acc += l.length + 1; // +1 for the '\\n'\n }\n\n const out: { from: number; to: number }[] = [];\n for (let i = 0; i + sNorm.length <= cLines.length; i++) {\n let ok = true;\n for (let j = 0; j < sNorm.length; j++) {\n if (cLines[i + j].trim() !== sNorm[j]) {\n ok = false;\n break;\n }\n }\n if (!ok) continue;\n const from = lineStart[i];\n const lastLine = i + sNorm.length - 1;\n const to = lineStart[lastLine] + cLines[lastLine].length; // end of the last matched line (exclusive of '\\n')\n out.push({ from, to });\n }\n return out;\n}\n\n/** If exactly one candidate falls inside the anchor symbol's span, pick it. */\nfunction scopeToAnchor(\n content: string,\n candidates: { from: number; to: number }[],\n anchor: string | undefined,\n spans: SymbolSpan[],\n file: string,\n): { kind: 'unique'; from: number; to: number } | null {\n if (!anchor) return null;\n const span = spans.find((s) => s.file === file && s.qualifiedName === anchor);\n if (!span) return null;\n const lineOf = lineIndexer(content);\n const inside = candidates.filter((c) => {\n const line = lineOf(c.from); // 1-based\n return line >= span.start && line <= span.end;\n });\n if (inside.length === 1) return { kind: 'unique', from: inside[0].from, to: inside[0].to };\n return null;\n}\n\n/** Returns a function mapping a char offset → 1-based line number. */\nfunction lineIndexer(content: string): (offset: number) => number {\n const starts: number[] = [0];\n for (let i = 0; i < content.length; i++) if (content[i] === '\\n') starts.push(i + 1);\n return (offset: number) => {\n // binary search for the greatest line start <= offset\n let lo = 0;\n let hi = starts.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (starts[mid] <= offset) lo = mid;\n else hi = mid - 1;\n }\n return lo + 1;\n };\n}\n","/**\n * Deterministic unified diff (VG-CLI-CODE §4.3).\n *\n * A `vg code` dry-run shows the human/agent exactly what would change *before*\n * anything is written — the \"inspect the proposal\" half of the governance\n * lifecycle. This is a small, dependency-free Myers-style line diff producing\n * standard unified-diff hunks. Identical (before, after) always renders the\n * identical text, so the dry-run output is stable and diff-able in tests and\n * benchmarks.\n */\n\n/** Render a unified diff for one file. Returns '' when there is no change. */\nexport function unifiedDiff(before: string | null, after: string | null, file: string, context = 3): string {\n if (before === after) return '';\n if (before === null) return newFileDiff(after ?? '', file);\n if (after === null) return deletedFileDiff(before, file);\n\n const a = splitLines(before);\n const b = splitLines(after);\n const ops = diffLines(a, b);\n const hunks = groupHunks(ops, context);\n if (hunks.length === 0) return '';\n\n const out: string[] = [`--- a/${file}`, `+++ b/${file}`];\n for (const h of hunks) {\n out.push(`@@ -${h.aStart},${h.aLen} +${h.bStart},${h.bLen} @@`);\n for (const line of h.lines) out.push(line);\n }\n return out.join('\\n');\n}\n\nfunction newFileDiff(after: string, file: string): string {\n const lines = splitLines(after);\n const out = [`--- /dev/null`, `+++ b/${file}`, `@@ -0,0 +1,${lines.length} @@`];\n for (const l of lines) out.push(`+${l}`);\n return out.join('\\n');\n}\n\nfunction deletedFileDiff(before: string, file: string): string {\n const lines = splitLines(before);\n const out = [`--- a/${file}`, `+++ /dev/null`, `@@ -1,${lines.length} +0,0 @@`];\n for (const l of lines) out.push(`-${l}`);\n return out.join('\\n');\n}\n\nfunction splitLines(s: string): string[] {\n if (s === '') return [];\n const lines = s.split('\\n');\n // A trailing newline yields a final '' element — drop it so line counts match.\n if (lines.length && lines[lines.length - 1] === '') lines.pop();\n return lines;\n}\n\ntype Op = { tag: 'eq' | 'del' | 'add'; line: string };\n\n/**\n * Line diff via LCS (dynamic programming). O(n·m) space is fine for source\n * files; the deterministic backtrace (favouring deletions before additions on\n * ties) keeps output stable.\n */\nfunction diffLines(a: string[], b: string[]): Op[] {\n const n = a.length;\n const m = b.length;\n const dp: number[][] = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));\n for (let i = n - 1; i >= 0; i--) {\n for (let j = m - 1; j >= 0; j--) {\n dp[i][j] = a[i] === b[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);\n }\n }\n const ops: Op[] = [];\n let i = 0;\n let j = 0;\n while (i < n && j < m) {\n if (a[i] === b[j]) {\n ops.push({ tag: 'eq', line: a[i] });\n i++;\n j++;\n } else if (dp[i + 1][j] >= dp[i][j + 1]) {\n ops.push({ tag: 'del', line: a[i] });\n i++;\n } else {\n ops.push({ tag: 'add', line: b[j] });\n j++;\n }\n }\n while (i < n) ops.push({ tag: 'del', line: a[i++] });\n while (j < m) ops.push({ tag: 'add', line: b[j++] });\n return ops;\n}\n\ninterface Hunk {\n aStart: number;\n aLen: number;\n bStart: number;\n bLen: number;\n lines: string[];\n}\n\n/** Group the op stream into unified-diff hunks with `context` equal lines around changes. */\nfunction groupHunks(ops: Op[], context: number): Hunk[] {\n // Index of each op that is a change (del/add).\n const changeIdx = ops.map((o, i) => (o.tag === 'eq' ? -1 : i)).filter((i) => i >= 0);\n if (changeIdx.length === 0) return [];\n\n // Merge change indices into windows that share context.\n const windows: [number, number][] = [];\n let start = Math.max(0, changeIdx[0] - context);\n let end = Math.min(ops.length - 1, changeIdx[0] + context);\n for (let k = 1; k < changeIdx.length; k++) {\n const cs = Math.max(0, changeIdx[k] - context);\n const ce = Math.min(ops.length - 1, changeIdx[k] + context);\n if (cs <= end + 1) {\n end = ce;\n } else {\n windows.push([start, end]);\n start = cs;\n end = ce;\n }\n }\n windows.push([start, end]);\n\n const hunks: Hunk[] = [];\n // Running 1-based line numbers into a and b.\n let aLine = 1;\n let bLine = 1;\n let idx = 0;\n for (const [ws, we] of windows) {\n // advance line counters up to window start\n while (idx < ws) {\n const o = ops[idx];\n if (o.tag !== 'add') aLine++;\n if (o.tag !== 'del') bLine++;\n idx++;\n }\n const hunk: Hunk = { aStart: aLine, aLen: 0, bStart: bLine, bLen: 0, lines: [] };\n for (let k = ws; k <= we; k++) {\n const o = ops[k];\n if (o.tag === 'eq') {\n hunk.lines.push(` ${o.line}`);\n hunk.aLen++;\n hunk.bLen++;\n aLine++;\n bLine++;\n } else if (o.tag === 'del') {\n hunk.lines.push(`-${o.line}`);\n hunk.aLen++;\n aLine++;\n } else {\n hunk.lines.push(`+${o.line}`);\n hunk.bLen++;\n bLine++;\n }\n idx = k + 1;\n }\n // A hunk that starts at line 1 with zero length should report start 0.\n if (hunk.aLen === 0) hunk.aStart = Math.max(0, hunk.aStart - 1);\n if (hunk.bLen === 0) hunk.bStart = Math.max(0, hunk.bStart - 1);\n hunks.push(hunk);\n }\n return hunks;\n}\n\n/** A compact one-line changeset summary: `+adds -dels across N file(s)`. */\nexport function summarizeDiffs(diffs: { file: string; diff: string }[]): string {\n let adds = 0;\n let dels = 0;\n let touched = 0;\n for (const { diff } of diffs) {\n if (!diff) continue;\n touched++;\n for (const line of diff.split('\\n')) {\n if (line.startsWith('+') && !line.startsWith('+++')) adds++;\n else if (line.startsWith('-') && !line.startsWith('---')) dels++;\n }\n }\n return `+${adds} -${dels} across ${touched} file(s)`;\n}\n","/**\n * Prompt assembly with cache-stable ordering (VG-CLI-CODE §5.1).\n *\n * The fast coding tools lean hard on prompt caching — cached tokens are roughly\n * an order of magnitude cheaper and skip re-encoding, so hit-rate is a\n * first-class speed lever. A cache only helps if the *prefix* is byte-stable\n * across turns, which makes prompt ordering a scheduling constraint, not a\n * cosmetic choice: put the invariant material (the instruction contract + the\n * repo-derived context) first and the volatile turn-specific ask last. This\n * module is the single place that ordering is enforced, so every provider\n * inherits it.\n */\n\nimport type { ChatMessage, CodeContext } from './types.js';\n\n/**\n * The system contract for the planner. Intentionally fixed (no interpolation)\n * so it is a perfectly stable cache prefix. It pins the edit *format* the\n * deterministic applier expects — the model's only job is to emit these blocks.\n */\nexport const CODE_SYSTEM_PROMPT = [\n 'You are a precise code-editing assistant operating inside the Vibgrate CLI.',\n 'You are given repository context derived from a deterministic code graph, then a task.',\n 'Propose the smallest correct change. Do not restate unchanged code.',\n '',\n 'Reply ONLY with edit blocks in this exact format, one per change:',\n '',\n '<path/to/file>',\n '<<<<<<< SEARCH',\n '<exact current lines to find>',\n '=======',\n '<replacement lines>',\n '>>>>>>> REPLACE',\n '',\n 'The SEARCH text must match the current file (whitespace differences are tolerated).',\n 'To add a new file use:',\n 'CREATE <path/to/file>',\n '<full file body>',\n 'END CREATE',\n 'To remove a file use: DELETE <path/to/file>',\n '',\n 'Respect every hard constraint in the context. Keep edits minimal and self-consistent.',\n].join('\\n');\n\n/**\n * Build the chat messages for a planning turn, in cache-stable order:\n * 1. system contract (fixed)\n * 2. repository context (stable for the repo/turn — the big, reusable prefix)\n * 3. the task instruction (volatile — always last)\n *\n * Keeping the volatile instruction in its own trailing user turn maximizes the\n * reusable prefix when the same repo is edited across multiple asks.\n */\nexport function buildMessages(context: CodeContext): ChatMessage[] {\n return [\n { role: 'system', content: CODE_SYSTEM_PROMPT },\n { role: 'user', content: context.rendered },\n { role: 'user', content: `Now produce the edit blocks for: ${context.instruction}` },\n ];\n}\n\n/**\n * The system contract for the agentic loop (tool-calling). It steers the model\n * to use the code graph to navigate instead of reading blindly, to make small\n * verified changes, and to finish explicitly. Fixed text → stable cache prefix.\n */\nexport const AGENT_SYSTEM_PROMPT = [\n 'You are VG Code, a precise coding agent working inside a real repository.',\n 'You have tools: search_code (searches a deterministic code graph — prefer it over guessing),',\n 'read_file, list_files, graph_impact (blast radius of a change), edit_file, create_file,',\n 'delete_file, run_command, and finish.',\n '',\n 'Work in small steps: search or read to understand before you edit; check graph_impact before',\n 'changing shared code; make the smallest correct edit; run the tests or build to verify when useful.',\n 'edit_file replaces an exact snippet — the search text must match the current file (whitespace is',\n 'tolerated). Do not restate unchanged code. When the task is complete, call finish with a short summary.',\n '',\n 'Editing, creating, deleting, and running commands require user approval — expect some to be declined,',\n 'and adapt if so. Never invent file contents; read first.',\n].join('\\n');\n\n/** Build the opening messages for an agent run: system contract + graph-grounded context + task. */\nexport function buildAgentMessages(context: CodeContext): ChatMessage[] {\n return [\n { role: 'system', content: AGENT_SYSTEM_PROMPT },\n { role: 'user', content: context.rendered },\n { role: 'user', content: `Task: ${context.instruction}` },\n ];\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
// src/util/output.ts
|
|
4
|
+
function info(message = "") {
|
|
5
|
+
process.stderr.write(`${message}
|
|
6
|
+
`);
|
|
7
|
+
}
|
|
8
|
+
function out(message) {
|
|
9
|
+
process.stdout.write(`${message}
|
|
10
|
+
`);
|
|
11
|
+
}
|
|
12
|
+
function json(value) {
|
|
13
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
14
|
+
`);
|
|
15
|
+
}
|
|
16
|
+
var c = chalk;
|
|
17
|
+
function disableColor() {
|
|
18
|
+
chalk.level = 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { c, disableColor, info, json, out };
|
|
22
|
+
//# sourceMappingURL=chunk-CT5BS56U.js.map
|
|
23
|
+
//# sourceMappingURL=chunk-CT5BS56U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/output.ts"],"names":[],"mappings":";;;AAQO,SAAS,IAAA,CAAK,UAAU,EAAA,EAAU;AACvC,EAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,OAAO;AAAA,CAAI,CAAA;AACrC;AAEO,SAAS,IAAI,OAAA,EAAuB;AACzC,EAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,OAAO;AAAA,CAAI,CAAA;AACrC;AAEO,SAAS,KAAK,KAAA,EAAsB;AACzC,EAAA,OAAA,CAAQ,MAAA,CAAO,MAAM,CAAA,EAAG,IAAA,CAAK,UAAU,KAAA,EAAO,IAAA,EAAM,CAAC,CAAC;AAAA,CAAI,CAAA;AAC5D;AAEO,IAAM,CAAA,GAAI;AAGV,SAAS,YAAA,GAAqB;AACnC,EAAA,KAAA,CAAM,KAAA,GAAQ,CAAA;AAChB","file":"chunk-CT5BS56U.js","sourcesContent":["import chalk from 'chalk';\n\n/**\n * Output conventions (VG-CLI-SPEC §1.1): human output + progress → stderr;\n * machine output (JSON/exports) → stdout. So `vg \"…\" --json | jq` and\n * `vg export - …` pipe cleanly.\n */\n\nexport function info(message = ''): void {\n process.stderr.write(`${message}\\n`);\n}\n\nexport function out(message: string): void {\n process.stdout.write(`${message}\\n`);\n}\n\nexport function json(value: unknown): void {\n process.stdout.write(`${JSON.stringify(value, null, 2)}\\n`);\n}\n\nexport const c = chalk;\n\n/** Honor NO_COLOR / --no-color via chalk's level (set by the CLI bootstrap). */\nexport function disableColor(): void {\n chalk.level = 0;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { runCoreScan,
|
|
1
|
+
import { runCoreScan, compactUiPurpose } from './chunk-JSNHZCIV.js';
|
|
2
2
|
import { findPackageJsonFiles, readJsonFile, findFiles, readTextFile, pathExists } from './chunk-GI6W53LM.js';
|
|
3
|
+
import { writeJsonFile } from './chunk-CRAMOEBE.js';
|
|
3
4
|
import * as path3 from 'path';
|
|
4
5
|
import { Command } from 'commander';
|
|
5
6
|
import chalk from 'chalk';
|
|
@@ -4355,5 +4356,5 @@ var baselineCommand = new Command("baseline").description("Create a drift baseli
|
|
|
4355
4356
|
});
|
|
4356
4357
|
|
|
4357
4358
|
export { baselineCommand, loadAdvancedScanHook, runBaseline };
|
|
4358
|
-
//# sourceMappingURL=chunk-
|
|
4359
|
-
//# sourceMappingURL=chunk-
|
|
4359
|
+
//# sourceMappingURL=chunk-EXQV26MF.js.map
|
|
4360
|
+
//# sourceMappingURL=chunk-EXQV26MF.js.map
|