@vibgrate/cli 2026.731.1 → 2026.731.3
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/{agent-33BMKWJC.js → agent-6XOI7RVW.js} +5 -5
- package/dist/{agent-33BMKWJC.js.map → agent-6XOI7RVW.js.map} +1 -1
- package/dist/baseline-PY6TETA5.js +9 -0
- package/dist/{baseline-4FBHW2X2.js.map → baseline-PY6TETA5.js.map} +1 -1
- package/dist/{chunk-KGWEBM2J.js → chunk-3VSU7G75.js} +27 -54
- package/dist/chunk-3VSU7G75.js.map +1 -0
- package/dist/{chunk-SKIMUFCI.js → chunk-5IA2TA57.js} +41 -65
- package/dist/chunk-5IA2TA57.js.map +1 -0
- package/dist/chunk-5XIEVZLW.js +65 -0
- package/dist/chunk-5XIEVZLW.js.map +1 -0
- package/dist/chunk-7G5S5KZN.js +99 -0
- package/dist/chunk-7G5S5KZN.js.map +1 -0
- package/dist/{chunk-DXSEG6SZ.js → chunk-AVCBKQKA.js} +3 -3
- package/dist/{chunk-DXSEG6SZ.js.map → chunk-AVCBKQKA.js.map} +1 -1
- package/dist/{chunk-J3BQ7FIT.js → chunk-B6S2DSBS.js} +7 -7
- package/dist/{chunk-J3BQ7FIT.js.map → chunk-B6S2DSBS.js.map} +1 -1
- package/dist/chunk-BMUTNUB7.js +326 -0
- package/dist/chunk-BMUTNUB7.js.map +1 -0
- package/dist/chunk-DEKGSQHL.js +6 -0
- package/dist/{chunk-2XTPGYR2.js.map → chunk-DEKGSQHL.js.map} +1 -1
- package/dist/{chunk-NJT4CA6K.js → chunk-DT4KIVRI.js} +17 -8
- package/dist/chunk-DT4KIVRI.js.map +1 -0
- package/dist/{chunk-GPDJOCUI.js → chunk-FF5ZQ6KI.js} +4 -4
- package/dist/{chunk-GPDJOCUI.js.map → chunk-FF5ZQ6KI.js.map} +1 -1
- package/dist/{chunk-WBMMRERH.js → chunk-KLO2XBUX.js} +3 -3
- package/dist/{chunk-WBMMRERH.js.map → chunk-KLO2XBUX.js.map} +1 -1
- package/dist/{chunk-T7OFJS3X.js → chunk-LTTVCI5C.js} +13 -328
- package/dist/chunk-LTTVCI5C.js.map +1 -0
- package/dist/{chunk-476KWSFM.js → chunk-MOLBANFB.js} +3 -3
- package/dist/{chunk-476KWSFM.js.map → chunk-MOLBANFB.js.map} +1 -1
- package/dist/{chunk-SE4JMB4W.js → chunk-PHGAUWWF.js} +3 -3
- package/dist/{chunk-SE4JMB4W.js.map → chunk-PHGAUWWF.js.map} +1 -1
- package/dist/{chunk-C22ZY3FV.js → chunk-RIWLXMMT.js} +3 -3
- package/dist/{chunk-C22ZY3FV.js.map → chunk-RIWLXMMT.js.map} +1 -1
- package/dist/chunk-SCTLOFNH.js +42 -0
- package/dist/chunk-SCTLOFNH.js.map +1 -0
- package/dist/{chunk-MYM5VIJ4.js → chunk-TRKRRX2S.js} +10 -6
- package/dist/chunk-TRKRRX2S.js.map +1 -0
- package/dist/{chunk-3NP2DO4G.js → chunk-WK52LWRX.js} +3 -3
- package/dist/{chunk-3NP2DO4G.js.map → chunk-WK52LWRX.js.map} +1 -1
- package/dist/{chunk-UVMP7DFF.js → chunk-XRN7DQGR.js} +11 -11
- package/dist/{chunk-UVMP7DFF.js.map → chunk-XRN7DQGR.js.map} +1 -1
- package/dist/{chunk-CWB6H553.js → chunk-Z7VH4RPO.js} +3 -3
- package/dist/{chunk-CWB6H553.js.map → chunk-Z7VH4RPO.js.map} +1 -1
- package/dist/cli.d.ts +5 -1
- package/dist/cli.js +166 -61
- package/dist/cli.js.map +1 -1
- package/dist/ensure-map-UQL7SM34.js +28 -0
- package/dist/ensure-map-UQL7SM34.js.map +1 -0
- package/dist/fs-NTQUFCXV.js +4 -0
- package/dist/fs-NTQUFCXV.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/{interactive-V6IRYZTA.js → interactive-QWT7ERXJ.js} +22 -19
- package/dist/interactive-QWT7ERXJ.js.map +1 -0
- package/dist/load-WA53B3GW.js +10 -0
- package/dist/{load-KPHH26ND.js.map → load-WA53B3GW.js.map} +1 -1
- package/dist/{run-outcome-TZ53G67B.js → run-outcome-J2IDIVYI.js} +5 -5
- package/dist/{run-outcome-TZ53G67B.js.map → run-outcome-J2IDIVYI.js.map} +1 -1
- package/dist/{runtime-session-PZKXBDJT.js → runtime-session-52P2Y5LX.js} +7 -7
- package/dist/{runtime-session-PZKXBDJT.js.map → runtime-session-52P2Y5LX.js.map} +1 -1
- package/dist/{session-3OBIQLE4.js → session-L7SJNE55.js} +4 -4
- package/dist/{session-3OBIQLE4.js.map → session-L7SJNE55.js.map} +1 -1
- package/dist/session-store-SQECEXUU.js +4 -0
- package/dist/{session-store-O4XPXKOV.js.map → session-store-SQECEXUU.js.map} +1 -1
- package/dist/{stream-json-3YOPU3LF.js → stream-json-TSGYC2MQ.js} +5 -5
- package/dist/{stream-json-3YOPU3LF.js.map → stream-json-TSGYC2MQ.js.map} +1 -1
- package/dist/{vg-mcp-bridge-7NNVIVO7.js → vg-mcp-bridge-IFAXEQMZ.js} +6 -6
- package/dist/{vg-mcp-bridge-7NNVIVO7.js.map → vg-mcp-bridge-IFAXEQMZ.js.map} +1 -1
- package/dist/{vgd-Y2YCN75V.js → vgd-PNR7UKLL.js} +6 -6
- package/dist/vgd-PNR7UKLL.js.map +1 -0
- package/package.json +1 -1
- package/dist/baseline-4FBHW2X2.js +0 -9
- package/dist/chunk-2XTPGYR2.js +0 -6
- package/dist/chunk-K3SLGULW.js +0 -50
- package/dist/chunk-K3SLGULW.js.map +0 -1
- package/dist/chunk-KGWEBM2J.js.map +0 -1
- package/dist/chunk-MYM5VIJ4.js.map +0 -1
- package/dist/chunk-NJT4CA6K.js.map +0 -1
- package/dist/chunk-SKIMUFCI.js.map +0 -1
- package/dist/chunk-T7OFJS3X.js.map +0 -1
- package/dist/fs-HF5DOHYR.js +0 -4
- package/dist/fs-HF5DOHYR.js.map +0 -1
- package/dist/interactive-V6IRYZTA.js.map +0 -1
- package/dist/load-KPHH26ND.js +0 -10
- package/dist/session-store-O4XPXKOV.js +0 -4
- package/dist/vgd-Y2YCN75V.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildMessages, parseEdits, applyEdits, unifiedDiff, redactSecrets } from './chunk-
|
|
1
|
+
import { buildMessages, parseEdits, applyEdits, unifiedDiff, redactSecrets } from './chunk-TRKRRX2S.js';
|
|
2
2
|
import { recordCliCall, CLI_TOOL_ALIASES, buildCodeContext, buildTaskCapsule, capsuleToCodeContext } from './chunk-US2DAKCM.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-KLO2XBUX.js.map
|
|
255
|
+
//# sourceMappingURL=chunk-KLO2XBUX.js.map
|
|
@@ -1 +1 @@
|
|
|
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,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AK,OAAO,CAAA;AAAA,IAC/B,CAAA;AAAA,IACA,OAAO,IAAA,EAAM;AACX,MAAA,IAAI;AACF,QAAG,EAAA,CAAA,MAAA,CAAOA,QAAAA,CAAQ,IAAI,CAAC,CAAA;AAAA,MACzB,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF,CAAA;AAAA,IACA,YAAY,IAAA,EAAM;AAChB,MAAA,MAAM,GAAA,GAAW,IAAA,CAAA,IAAA,CAAK,IAAA,EAAM,WAAW,CAAA;AACvC,MAAG,EAAA,CAAA,SAAA,CAAU,GAAA,EAAK,EAAE,SAAA,EAAW,MAAM,CAAA;AACrC,MAAG,kBAAoB,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-WBMMRERH.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,SAA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AAAA,MAC9C,CAAA,CAAA,MAAQ;AACN,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF,CAAA;AAAA,IACA,KAAA,CAAM,MAAM,OAAA,EAAS;AACnB,MAAA,MAAM,GAAA,GAAMA,SAAQ,IAAI,CAAA;AACxB,MAAG,aAAe,IAAA,CAAA,OAAA,CAAQ,GAAG,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AACnD,MAAG,EAAA,CAAA,aAAA,CAAc,KAAK,OAAO,CAAA;AAAA,IAC/B,CAAA;AAAA,IACA,OAAO,IAAA,EAAM;AACX,MAAA,IAAI;AACF,QAAG,EAAA,CAAA,MAAA,CAAOA,QAAAA,CAAQ,IAAI,CAAC,CAAA;AAAA,MACzB,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF,CAAA;AAAA,IACA,YAAY,IAAA,EAAM;AAChB,MAAA,MAAM,GAAA,GAAW,IAAA,CAAA,IAAA,CAAK,IAAA,EAAM,WAAW,CAAA;AACvC,MAAG,EAAA,CAAA,SAAA,CAAU,GAAA,EAAK,EAAE,SAAA,EAAW,MAAM,CAAA;AACrC,MAAG,kBAAoB,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-KLO2XBUX.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,21 +1,16 @@
|
|
|
1
|
-
import { managerFromProviderId, formatManagerBadgeLine } from './chunk-WHJMS7XC.js';
|
|
2
1
|
import { c, info, json, out } from './chunk-CT5BS56U.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { usageError, buildGraph, UsageError, ResourceLimitError, CliError, ExitCode, writeSnapshot, refreshInstalledInstructions, SMALL_REPO_FILES, epistemicBreakdown, verifyDeterminism } from './chunk-SKIMUFCI.js';
|
|
6
|
-
import { brandProgressBar, resolveHead, workingTreeDirty } from './chunk-UVMP7DFF.js';
|
|
2
|
+
import { usageError, buildGraph, UsageError, ResourceLimitError, CliError, ExitCode, writeSnapshot, refreshInstalledInstructions, SMALL_REPO_FILES, epistemicBreakdown, verifyDeterminism } from './chunk-5IA2TA57.js';
|
|
3
|
+
import { brandProgressBar, resolveHead, workingTreeDirty } from './chunk-XRN7DQGR.js';
|
|
7
4
|
import { resolveEmbedModel, isModelReady, countPending } from './chunk-EETK7S43.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { VERSION } from './chunk-2XTPGYR2.js';
|
|
5
|
+
import { loadGraph } from './chunk-MOLBANFB.js';
|
|
6
|
+
import { writeArtifacts, renderHtml, renderReport } from './chunk-AVCBKQKA.js';
|
|
7
|
+
import { VERSION } from './chunk-DEKGSQHL.js';
|
|
12
8
|
import { serializeGraph } from './chunk-ZKNB4YH4.js';
|
|
13
9
|
import { canonicalize } from './chunk-JFGYT6BI.js';
|
|
14
10
|
import * as path from 'path';
|
|
15
11
|
import * as fs from 'fs';
|
|
16
12
|
import { spawn, execFile } from 'child_process';
|
|
17
13
|
import * as crypto from 'crypto';
|
|
18
|
-
import * as os from 'os';
|
|
19
14
|
|
|
20
15
|
// src/util/logo.ts
|
|
21
16
|
var teal = (s) => c.hex("#3FB0A4")(s);
|
|
@@ -369,7 +364,7 @@ function registerBuild(program) {
|
|
|
369
364
|
});
|
|
370
365
|
applyGlobalOptions(cmd);
|
|
371
366
|
}
|
|
372
|
-
async function runBuild(paths, opts, global) {
|
|
367
|
+
async function runBuild(paths, opts, global, hooks) {
|
|
373
368
|
const root = path.resolve(global.cwd ?? ".");
|
|
374
369
|
if (opts.verify) {
|
|
375
370
|
await verifyGraph(root, opts, global);
|
|
@@ -406,7 +401,10 @@ async function runBuild(paths, opts, global) {
|
|
|
406
401
|
noIndex: opts.index === false,
|
|
407
402
|
analysisTier,
|
|
408
403
|
generatedAt: global.generatedAt,
|
|
409
|
-
onParseProgress:
|
|
404
|
+
onParseProgress: (done, total) => {
|
|
405
|
+
bar?.update(done, total);
|
|
406
|
+
hooks?.onParseProgress?.(done, total);
|
|
407
|
+
},
|
|
410
408
|
grammarsDir: opts.grammars
|
|
411
409
|
});
|
|
412
410
|
} catch (err) {
|
|
@@ -610,320 +608,7 @@ function rel2(root) {
|
|
|
610
608
|
const r = path.relative(process.cwd(), root);
|
|
611
609
|
return r === "" ? "." : r;
|
|
612
610
|
}
|
|
613
|
-
var PROVIDER_LABELS = {
|
|
614
|
-
anthropic: "Anthropic (Claude)",
|
|
615
|
-
openai: "OpenAI (GPT)",
|
|
616
|
-
"x-ai": "xAI (Grok)",
|
|
617
|
-
google: "Google (Gemini)",
|
|
618
|
-
"meta-llama": "Meta (Llama)",
|
|
619
|
-
deepseek: "DeepSeek",
|
|
620
|
-
mistralai: "Mistral",
|
|
621
|
-
qwen: "Qwen"
|
|
622
|
-
};
|
|
623
|
-
var FEATURED_ORDER = Object.keys(PROVIDER_LABELS);
|
|
624
|
-
var OPENROUTER_MODELS_URL = "https://openrouter.ai/api/v1/models";
|
|
625
|
-
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
626
|
-
function catalogCachePath() {
|
|
627
|
-
const base = process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
|
|
628
|
-
return path.join(base, "vibgrate", "catalog", "openrouter-models.json");
|
|
629
|
-
}
|
|
630
|
-
async function fetchCatalog(options = {}) {
|
|
631
|
-
const now = options.now ?? (() => 0);
|
|
632
|
-
const fetchImpl = options.fetchImpl ?? fetch;
|
|
633
|
-
if (!options.noCache) {
|
|
634
|
-
const cached = readCache();
|
|
635
|
-
if (cached && (options.offline || now() - cached.ts < CACHE_TTL_MS)) {
|
|
636
|
-
return { providers: groupModels(cached.models), fresh: false, source: "cache" };
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
if (options.offline) {
|
|
640
|
-
const cached = readCache();
|
|
641
|
-
if (cached) return { providers: groupModels(cached.models), fresh: false, source: "cache" };
|
|
642
|
-
return { providers: curatedFallback(), fresh: false, source: "fallback" };
|
|
643
|
-
}
|
|
644
|
-
try {
|
|
645
|
-
const controller = new AbortController();
|
|
646
|
-
const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? 8e3);
|
|
647
|
-
let raw;
|
|
648
|
-
try {
|
|
649
|
-
const res = await fetchImpl(OPENROUTER_MODELS_URL, { signal: controller.signal });
|
|
650
|
-
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
651
|
-
raw = await res.json();
|
|
652
|
-
} finally {
|
|
653
|
-
clearTimeout(timer);
|
|
654
|
-
}
|
|
655
|
-
const models = parseModels(raw);
|
|
656
|
-
if (models.length === 0) throw new Error("empty catalog");
|
|
657
|
-
writeCache(models, now());
|
|
658
|
-
return { providers: groupModels(models), fresh: true, source: "network" };
|
|
659
|
-
} catch {
|
|
660
|
-
const cached = readCache();
|
|
661
|
-
if (cached) return { providers: groupModels(cached.models), fresh: false, source: "cache" };
|
|
662
|
-
return { providers: curatedFallback(), fresh: false, source: "fallback" };
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
function parseModels(raw) {
|
|
666
|
-
const data = raw?.data;
|
|
667
|
-
if (!Array.isArray(data)) return [];
|
|
668
|
-
const out2 = [];
|
|
669
|
-
for (const entry of data) {
|
|
670
|
-
const e = entry;
|
|
671
|
-
if (typeof e.id !== "string" || !e.id.includes("/")) continue;
|
|
672
|
-
const provider = e.id.split("/")[0];
|
|
673
|
-
out2.push({
|
|
674
|
-
id: e.id,
|
|
675
|
-
name: typeof e.name === "string" ? e.name : e.id,
|
|
676
|
-
provider,
|
|
677
|
-
contextLength: numeric(e.context_length),
|
|
678
|
-
promptPricePerM: perMillion(e.pricing?.prompt),
|
|
679
|
-
completionPricePerM: perMillion(e.pricing?.completion)
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
return out2;
|
|
683
|
-
}
|
|
684
|
-
function groupModels(models) {
|
|
685
|
-
const byProvider = /* @__PURE__ */ new Map();
|
|
686
|
-
for (const m of models) {
|
|
687
|
-
const list = byProvider.get(m.provider) ?? [];
|
|
688
|
-
list.push(m);
|
|
689
|
-
byProvider.set(m.provider, list);
|
|
690
|
-
}
|
|
691
|
-
const groups = [];
|
|
692
|
-
for (const [id, list] of byProvider) {
|
|
693
|
-
groups.push({ id, label: PROVIDER_LABELS[id] ?? titleCase(id), models: list.sort(rankModels) });
|
|
694
|
-
}
|
|
695
|
-
groups.sort((a, b) => {
|
|
696
|
-
const ia = FEATURED_ORDER.indexOf(a.id);
|
|
697
|
-
const ib = FEATURED_ORDER.indexOf(b.id);
|
|
698
|
-
if (ia !== -1 || ib !== -1) return (ia === -1 ? 1e9 : ia) - (ib === -1 ? 1e9 : ib);
|
|
699
|
-
return a.label.localeCompare(b.label);
|
|
700
|
-
});
|
|
701
|
-
return groups;
|
|
702
|
-
}
|
|
703
|
-
function rankModels(a, b) {
|
|
704
|
-
const ca = isCoding(a) ? 0 : 1;
|
|
705
|
-
const cb = isCoding(b) ? 0 : 1;
|
|
706
|
-
if (ca !== cb) return ca - cb;
|
|
707
|
-
const la = a.contextLength ?? 0;
|
|
708
|
-
const lb = b.contextLength ?? 0;
|
|
709
|
-
if (la !== lb) return lb - la;
|
|
710
|
-
return a.id.localeCompare(b.id);
|
|
711
|
-
}
|
|
712
|
-
function isCoding(m) {
|
|
713
|
-
return /cod(e|er|ing)/i.test(m.id) || /cod(e|er|ing)/i.test(m.name);
|
|
714
|
-
}
|
|
715
|
-
function topProviders(catalog, n = 6) {
|
|
716
|
-
return catalog.providers.slice(0, n);
|
|
717
|
-
}
|
|
718
|
-
function readCache() {
|
|
719
|
-
try {
|
|
720
|
-
const parsed = JSON.parse(fs.readFileSync(catalogCachePath(), "utf8"));
|
|
721
|
-
if (Array.isArray(parsed.models) && typeof parsed.ts === "number") return parsed;
|
|
722
|
-
} catch {
|
|
723
|
-
}
|
|
724
|
-
return null;
|
|
725
|
-
}
|
|
726
|
-
function writeCache(models, ts) {
|
|
727
|
-
try {
|
|
728
|
-
const file = catalogCachePath();
|
|
729
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
730
|
-
fs.writeFileSync(file, JSON.stringify({ ts, models }));
|
|
731
|
-
} catch {
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
function curatedFallback() {
|
|
735
|
-
return FEATURED_ORDER.map((id) => ({ id, label: PROVIDER_LABELS[id], models: [] }));
|
|
736
|
-
}
|
|
737
|
-
function numeric(v) {
|
|
738
|
-
const n = typeof v === "string" ? Number(v) : typeof v === "number" ? v : NaN;
|
|
739
|
-
return Number.isFinite(n) ? n : void 0;
|
|
740
|
-
}
|
|
741
|
-
function perMillion(v) {
|
|
742
|
-
const n = numeric(v);
|
|
743
|
-
if (n === void 0) return void 0;
|
|
744
|
-
return Math.round(n * 1e6 * 1e3) / 1e3;
|
|
745
|
-
}
|
|
746
|
-
function titleCase(id) {
|
|
747
|
-
return id.replace(/[-_]/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase());
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// src/code/router.ts
|
|
751
|
-
var HOSTED_IDS = /* @__PURE__ */ new Set(["vibgrate-relay", "openrouter", "litellm", "openai", "together"]);
|
|
752
|
-
function resolveProviders(opts, deps = {}) {
|
|
753
|
-
const env = deps.env ?? process.env;
|
|
754
|
-
const discover = deps.discover ?? discoverModels;
|
|
755
|
-
if (opts.mockReply !== void 0) {
|
|
756
|
-
const providers = [new MockProvider(opts.model ?? "mock-1", opts.mockReply)];
|
|
757
|
-
return finish(providers, "mock provider (scripted, offline)");
|
|
758
|
-
}
|
|
759
|
-
if (opts.codeMode && (!opts.provider || opts.provider === "llama-cpp" || opts.provider === "vibgrate")) {
|
|
760
|
-
const gguf = resolveGgufPath({
|
|
761
|
-
modelPath: opts.modelPath || env.VG_CODE_MODEL_PATH,
|
|
762
|
-
modelRef: opts.model,
|
|
763
|
-
env,
|
|
764
|
-
discover
|
|
765
|
-
});
|
|
766
|
-
if (!gguf) {
|
|
767
|
-
throw new CliError(
|
|
768
|
-
"Code Mode needs the Vibgrate model manager weights on disk. Run `vg models install spark|flow|forge` (or pass --model-path to a GGUF). Custom Ollama/LM Studio backends are only used when you set --provider explicitly.",
|
|
769
|
-
ExitCode.NOT_FOUND
|
|
770
|
-
);
|
|
771
|
-
}
|
|
772
|
-
const providers = [
|
|
773
|
-
new LocalLlamaProvider(opts.model ?? basename2(gguf.path), gguf.path, void 0, !!opts.consent)
|
|
774
|
-
];
|
|
775
|
-
return finish(providers, `Code Mode \u2192 Vibgrate model manager (embedded llama.cpp \xB7 ${gguf.path})`);
|
|
776
|
-
}
|
|
777
|
-
if (opts.provider) {
|
|
778
|
-
const provider = buildExplicit(opts.provider, opts, env, discover);
|
|
779
|
-
if (opts.codeMode) {
|
|
780
|
-
return finish([provider], `Code Mode \u2192 explicit --provider ${opts.provider} (no auto-fallback)`);
|
|
781
|
-
}
|
|
782
|
-
const fallbacks = opts.local || provider.local ? localFallbacks(opts, env, discover, provider.id, { allowLmStudio: opts.provider === "lmstudio" }) : [];
|
|
783
|
-
return finish([provider, ...fallbacks], `explicit --provider ${opts.provider}`);
|
|
784
|
-
}
|
|
785
|
-
if (opts.local) {
|
|
786
|
-
const locals2 = localFallbacks(opts, env, discover, "", { allowLmStudio: false });
|
|
787
|
-
if (locals2.length === 0) {
|
|
788
|
-
throw new CliError(
|
|
789
|
-
"no local model backend available for --local. Install a Code Mode (`vg models install spark`), start Ollama (`ollama serve` + pull), or point --provider llama-cpp at a gguf. See `vg models`.",
|
|
790
|
-
ExitCode.NOT_FOUND
|
|
791
|
-
);
|
|
792
|
-
}
|
|
793
|
-
return finish(locals2, "--local (on-device backends only)");
|
|
794
|
-
}
|
|
795
|
-
if (env.VIBGRATE_RELAY_TOKEN) {
|
|
796
|
-
const model = resolveHostedModel(opts, env, "vibgrate-relay");
|
|
797
|
-
const primary = buildHosted("vibgrate-relay", model);
|
|
798
|
-
return finish(
|
|
799
|
-
[primary, ...localFallbacks(opts, env, discover, "vibgrate-relay", { allowLmStudio: false })],
|
|
800
|
-
"VIBGRATE_RELAY_TOKEN is set \u2192 Vibgrate Relay (with local fallback)"
|
|
801
|
-
);
|
|
802
|
-
}
|
|
803
|
-
if (env.OPENROUTER_API_KEY) {
|
|
804
|
-
const model = resolveHostedModel(opts, env, "openrouter");
|
|
805
|
-
const primary = buildHosted("openrouter", model);
|
|
806
|
-
return finish(
|
|
807
|
-
[primary, ...localFallbacks(opts, env, discover, "openrouter", { allowLmStudio: false })],
|
|
808
|
-
"OPENROUTER_API_KEY is set \u2192 OpenRouter (with local fallback)"
|
|
809
|
-
);
|
|
810
|
-
}
|
|
811
|
-
const locals = localFallbacks(opts, env, discover, "", { allowLmStudio: false });
|
|
812
|
-
if (locals.length) return finish(locals, "a local model is available \u2192 on-device (no key needed)");
|
|
813
|
-
for (const id of ["litellm", "openai", "together"]) {
|
|
814
|
-
const keyEnv = OPENAI_COMPATIBLE[id].apiKeyEnv;
|
|
815
|
-
if (keyEnv && env[keyEnv]) {
|
|
816
|
-
const model = resolveHostedModel(opts, env, id);
|
|
817
|
-
return finish([buildHosted(id, model)], `${keyEnv} is set \u2192 ${OPENAI_COMPATIBLE[id].label}`);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
throw new CliError(
|
|
821
|
-
"no model backend configured. Do one of: sign in to Vibgrate Relay (VIBGRATE_RELAY_TOKEN), set OPENROUTER_API_KEY for the hosted router, run `vg models install spark` for the Vibgrate manager, run Ollama locally, or use --local with a local model. Set the model with --model or VG_CODE_MODEL.",
|
|
822
|
-
ExitCode.NOT_FOUND
|
|
823
|
-
);
|
|
824
|
-
}
|
|
825
|
-
function finish(providers, reason) {
|
|
826
|
-
const primary = providers[0];
|
|
827
|
-
const manager = managerFromProviderId(primary?.id);
|
|
828
|
-
return {
|
|
829
|
-
providers,
|
|
830
|
-
reason,
|
|
831
|
-
manager,
|
|
832
|
-
managerLine: formatManagerBadgeLine(manager, primary?.model)
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
function buildExplicit(id, opts, env, discover) {
|
|
836
|
-
if (id === "ollama") return new OllamaProvider(resolveLocalModel(opts, discover, "ollama"), env.OLLAMA_HOST);
|
|
837
|
-
if (id === "llama-cpp" || id === "vibgrate") {
|
|
838
|
-
const resolved = resolveGgufPath({
|
|
839
|
-
modelPath: opts.modelPath || env.VG_CODE_MODEL_PATH,
|
|
840
|
-
modelRef: opts.model,
|
|
841
|
-
env,
|
|
842
|
-
discover
|
|
843
|
-
});
|
|
844
|
-
if (!resolved) {
|
|
845
|
-
throw new CliError(
|
|
846
|
-
"--provider llama-cpp needs a GGUF: pass --model-path, set VG_CODE_MODEL_PATH, or run `vg models install` so the weight store has a catalogued gguf. See `vg models`.",
|
|
847
|
-
ExitCode.USAGE_ERROR
|
|
848
|
-
);
|
|
849
|
-
}
|
|
850
|
-
return new LocalLlamaProvider(opts.model ?? basename2(resolved.path), resolved.path, void 0, !!opts.consent);
|
|
851
|
-
}
|
|
852
|
-
if (id === "lmstudio") return buildHosted("lmstudio", resolveHostedModel(opts, env, "lmstudio"));
|
|
853
|
-
if (id === "foundry-local" || id === "foundry") {
|
|
854
|
-
return buildHosted("foundry-local", resolveHostedModel(opts, env, "foundry-local"));
|
|
855
|
-
}
|
|
856
|
-
if (HOSTED_IDS.has(id)) return buildHosted(id, resolveHostedModel(opts, env, id));
|
|
857
|
-
throw new CliError(
|
|
858
|
-
`unknown --provider "${id}". Known: vibgrate-relay, ollama, lmstudio, foundry-local, openrouter, litellm, openai, together, llama-cpp.`,
|
|
859
|
-
ExitCode.USAGE_ERROR
|
|
860
|
-
);
|
|
861
|
-
}
|
|
862
|
-
function buildHosted(id, model) {
|
|
863
|
-
const base = OPENAI_COMPATIBLE[id];
|
|
864
|
-
const config = { ...base, id };
|
|
865
|
-
return new OpenAiCompatibleProvider(model, config);
|
|
866
|
-
}
|
|
867
|
-
function localFallbacks(opts, env, discover, exclude, fb) {
|
|
868
|
-
const out2 = [];
|
|
869
|
-
const models = safeDiscover(discover);
|
|
870
|
-
const preferOllama = env.VG_PREFER_OLLAMA === "1" || env.VIBGRATE_PREFER_OLLAMA === "1" || opts.preferEmbedded === false;
|
|
871
|
-
const gguf = exclude === "llama-cpp" || exclude === "vibgrate" ? null : resolveGgufPath({
|
|
872
|
-
modelPath: opts.modelPath || env.VG_CODE_MODEL_PATH,
|
|
873
|
-
modelRef: opts.model,
|
|
874
|
-
env,
|
|
875
|
-
discover: () => models
|
|
876
|
-
});
|
|
877
|
-
if (gguf && !preferOllama) {
|
|
878
|
-
out2.push(new LocalLlamaProvider(opts.model ?? basename2(gguf.path), gguf.path, void 0, !!opts.consent));
|
|
879
|
-
}
|
|
880
|
-
const ollamaModel = opts.model ?? firstOfRuntime(models, "ollama");
|
|
881
|
-
if (exclude !== "ollama" && ollamaModel) out2.push(new OllamaProvider(ollamaModel, env.OLLAMA_HOST));
|
|
882
|
-
if (fb.allowLmStudio && exclude !== "lmstudio") {
|
|
883
|
-
const lmModel = opts.model ?? firstOfRuntime(models, "lm-studio");
|
|
884
|
-
if (lmModel) out2.push(buildHosted("lmstudio", lmModel));
|
|
885
|
-
}
|
|
886
|
-
if (exclude !== "foundry-local" && exclude !== "foundry" && (env.FOUNDRY_LOCAL_BASE_URL || env.VG_CODE_PROVIDER === "foundry-local")) {
|
|
887
|
-
try {
|
|
888
|
-
const m = opts.model || env.VG_CODE_MODEL;
|
|
889
|
-
if (m) out2.push(buildHosted("foundry-local", m));
|
|
890
|
-
} catch {
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
if (gguf && !out2.some((p) => p.id === "llama-cpp")) {
|
|
894
|
-
out2.push(new LocalLlamaProvider(opts.model ?? basename2(gguf.path), gguf.path, void 0, !!opts.consent));
|
|
895
|
-
}
|
|
896
|
-
return out2;
|
|
897
|
-
}
|
|
898
|
-
function resolveLocalModel(opts, discover, runtime) {
|
|
899
|
-
if (opts.model) return opts.model;
|
|
900
|
-
const found = firstOfRuntime(safeDiscover(discover), runtime);
|
|
901
|
-
if (found) return found;
|
|
902
|
-
throw new CliError(`--provider ${runtime} needs a model. Pull one (\`ollama pull <model>\`) then re-run, or pass --model. See \`vg models\`.`, ExitCode.NOT_FOUND);
|
|
903
|
-
}
|
|
904
|
-
function resolveHostedModel(opts, env, id) {
|
|
905
|
-
const model = opts.model || env.VG_CODE_MODEL;
|
|
906
|
-
if (model) return model;
|
|
907
|
-
throw new CliError(
|
|
908
|
-
`${OPENAI_COMPATIBLE[id].label} needs a model id \u2014 pass --model (e.g. a current best-in-breed coding model) or set VG_CODE_MODEL. We don't hard-code a model so you always pick the current best one.`,
|
|
909
|
-
ExitCode.USAGE_ERROR
|
|
910
|
-
);
|
|
911
|
-
}
|
|
912
|
-
function firstOfRuntime(models, runtime) {
|
|
913
|
-
const m = models.find((x) => x.runtime === runtime);
|
|
914
|
-
return m?.name;
|
|
915
|
-
}
|
|
916
|
-
function safeDiscover(discover) {
|
|
917
|
-
try {
|
|
918
|
-
return discover();
|
|
919
|
-
} catch {
|
|
920
|
-
return [];
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
function basename2(p) {
|
|
924
|
-
return p.replace(/\\/g, "/").split("/").pop() ?? p;
|
|
925
|
-
}
|
|
926
611
|
|
|
927
|
-
export { DSSE_PAYLOAD_TYPE, ProgressBar, applyGlobalOptions, dssePae,
|
|
928
|
-
//# sourceMappingURL=chunk-
|
|
929
|
-
//# sourceMappingURL=chunk-
|
|
612
|
+
export { DSSE_PAYLOAD_TYPE, ProgressBar, applyGlobalOptions, dssePae, generateKeypair, keyId, printCodeLogo, printLogo, readGlobal, registerBuild, runBuild, sha256Hex };
|
|
613
|
+
//# sourceMappingURL=chunk-LTTVCI5C.js.map
|
|
614
|
+
//# sourceMappingURL=chunk-LTTVCI5C.js.map
|