@vibgrate/cli 2026.722.2 → 2026.727.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 +418 -196
- package/README.md +34 -7
- package/dist/baseline-K7YBFKZI.js +7 -0
- package/dist/{baseline-BD3A7EXD.js.map → baseline-K7YBFKZI.js.map} +1 -1
- package/dist/chunk-3BVSDMHV.js +2496 -0
- package/dist/chunk-3BVSDMHV.js.map +1 -0
- package/dist/{chunk-PY3DNX5H.js → chunk-3Q7QBWFW.js} +13 -2
- package/dist/chunk-3Q7QBWFW.js.map +1 -0
- package/dist/chunk-4CQ3MGNN.js +136 -0
- package/dist/chunk-4CQ3MGNN.js.map +1 -0
- package/dist/chunk-5I4VSBWQ.js +764 -0
- package/dist/chunk-5I4VSBWQ.js.map +1 -0
- package/dist/chunk-5Q54GEHM.js +29 -0
- package/dist/chunk-5Q54GEHM.js.map +1 -0
- package/dist/{chunk-2O5YZVZV.js → chunk-65MEOA4E.js} +21 -18
- package/dist/chunk-65MEOA4E.js.map +1 -0
- package/dist/{chunk-WNIIKCNF.js → chunk-6IOQJGFT.js} +29 -238
- package/dist/chunk-6IOQJGFT.js.map +1 -0
- package/dist/{chunk-CS37OBE3.js → chunk-7JHPQ6WF.js} +791 -783
- package/dist/chunk-7JHPQ6WF.js.map +1 -0
- package/dist/chunk-BPF3YX2U.js +64 -0
- package/dist/chunk-BPF3YX2U.js.map +1 -0
- package/dist/chunk-BWPBB45M.js +88 -0
- package/dist/chunk-BWPBB45M.js.map +1 -0
- package/dist/chunk-C4CKTAZP.js +1695 -0
- package/dist/chunk-C4CKTAZP.js.map +1 -0
- package/dist/chunk-EDAAG7BL.js +612 -0
- package/dist/chunk-EDAAG7BL.js.map +1 -0
- package/dist/chunk-EDBV33B7.js +57 -0
- package/dist/chunk-EDBV33B7.js.map +1 -0
- package/dist/chunk-HABUT7HW.js +233 -0
- package/dist/chunk-HABUT7HW.js.map +1 -0
- package/dist/{chunk-NONYJLOJ.js → chunk-HYZVHJ3Q.js} +3 -3
- package/dist/{chunk-NONYJLOJ.js.map → chunk-HYZVHJ3Q.js.map} +1 -1
- package/dist/chunk-IS7VTH2Q.js +627 -0
- package/dist/chunk-IS7VTH2Q.js.map +1 -0
- package/dist/chunk-IZDH67DX.js +289 -0
- package/dist/chunk-IZDH67DX.js.map +1 -0
- package/dist/chunk-J7LKEB2R.js +51 -0
- package/dist/chunk-J7LKEB2R.js.map +1 -0
- package/dist/chunk-JIBOJTGS.js +313 -0
- package/dist/chunk-JIBOJTGS.js.map +1 -0
- package/dist/chunk-JZYGEZTU.js +82 -0
- package/dist/chunk-JZYGEZTU.js.map +1 -0
- package/dist/chunk-K7REHDQS.js +776 -0
- package/dist/chunk-K7REHDQS.js.map +1 -0
- package/dist/chunk-KHJO4D5N.js +108 -0
- package/dist/chunk-KHJO4D5N.js.map +1 -0
- package/dist/chunk-NDMDSPFX.js +69 -0
- package/dist/chunk-NDMDSPFX.js.map +1 -0
- package/dist/chunk-OOIG3RUM.js +276 -0
- package/dist/chunk-OOIG3RUM.js.map +1 -0
- package/dist/{chunk-6CXTPC74.js → chunk-OXQNQW5J.js} +27 -6
- package/dist/chunk-OXQNQW5J.js.map +1 -0
- package/dist/chunk-PMYWZRRS.js +62 -0
- package/dist/chunk-PMYWZRRS.js.map +1 -0
- package/dist/chunk-PXHNTC6D.js +382 -0
- package/dist/chunk-PXHNTC6D.js.map +1 -0
- package/dist/{chunk-3MXNNBLI.js → chunk-S6CYDZEW.js} +1395 -1975
- package/dist/chunk-S6CYDZEW.js.map +1 -0
- package/dist/chunk-SZLF66FJ.js +843 -0
- package/dist/chunk-SZLF66FJ.js.map +1 -0
- package/dist/chunk-VXGV6NTD.js +476 -0
- package/dist/chunk-VXGV6NTD.js.map +1 -0
- package/dist/{chunk-5BDHQ7DD.js → chunk-WLETRGAC.js} +16 -9
- package/dist/chunk-WLETRGAC.js.map +1 -0
- package/dist/{chunk-I7GY7MVN.js → chunk-YDAT7LD2.js} +51 -11
- package/dist/chunk-YDAT7LD2.js.map +1 -0
- package/dist/cli.js +3412 -513
- package/dist/cli.js.map +1 -1
- package/dist/execution-env-3BN7Z737.js +3 -0
- package/dist/execution-env-3BN7Z737.js.map +1 -0
- package/dist/federation-EPZDUWCK.js +6 -0
- package/dist/federation-EPZDUWCK.js.map +1 -0
- package/dist/git-ref-HPRLUFFW.js +3 -0
- package/dist/git-ref-HPRLUFFW.js.map +1 -0
- package/dist/graph-backend-ZMSYOZMW.js +10 -0
- package/dist/graph-backend-ZMSYOZMW.js.map +1 -0
- package/dist/index.d.ts +432 -126
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/{interactive-A4DISSIW.js → interactive-ICL7D7LO.js} +185 -226
- package/dist/interactive-ICL7D7LO.js.map +1 -0
- package/dist/llm-host-2RAYQSDQ.js +8 -0
- package/dist/llm-host-2RAYQSDQ.js.map +1 -0
- package/dist/load-OHVKDX4R.js +7 -0
- package/dist/load-OHVKDX4R.js.map +1 -0
- package/dist/local-runtime-OJFLX2HI.js +4 -0
- package/dist/local-runtime-OJFLX2HI.js.map +1 -0
- package/dist/model-execution-profile-MQ2QCP24.js +3 -0
- package/dist/model-execution-profile-MQ2QCP24.js.map +1 -0
- package/dist/model-orchestrator-FFTZI3U2.js +8 -0
- package/dist/model-orchestrator-FFTZI3U2.js.map +1 -0
- package/dist/parse-worker.d.ts +1 -1
- package/dist/parse-worker.js +1 -1
- package/dist/paths-MCH75O3G.js +5 -0
- package/dist/paths-MCH75O3G.js.map +1 -0
- package/dist/resolve-gguf-4UPIGPEE.js +7 -0
- package/dist/resolve-gguf-4UPIGPEE.js.map +1 -0
- package/dist/runtime-session-IDU5BDUJ.js +17 -0
- package/dist/runtime-session-IDU5BDUJ.js.map +1 -0
- package/dist/session-L2OSDRPI.js +10 -0
- package/dist/{session-POJUDFPH.js.map → session-L2OSDRPI.js.map} +1 -1
- package/dist/{stream-json-Q2JGWPHB.js → stream-json-F74W5FCK.js} +16 -6
- package/dist/stream-json-F74W5FCK.js.map +1 -0
- package/dist/{types-Jl6RJ175.d.ts → types-ZMg1mSuu.d.ts} +3 -1
- package/dist/vgd-EGBQD7BW.js +16 -0
- package/dist/vgd-EGBQD7BW.js.map +1 -0
- package/package.json +9 -6
- package/dist/baseline-BD3A7EXD.js +0 -7
- package/dist/chunk-2O5YZVZV.js.map +0 -1
- package/dist/chunk-3MXNNBLI.js.map +0 -1
- package/dist/chunk-5BDHQ7DD.js.map +0 -1
- package/dist/chunk-6CXTPC74.js.map +0 -1
- package/dist/chunk-CS37OBE3.js.map +0 -1
- package/dist/chunk-GGJZA3Q6.js +0 -961
- package/dist/chunk-GGJZA3Q6.js.map +0 -1
- package/dist/chunk-I7GY7MVN.js.map +0 -1
- package/dist/chunk-JBXNQCGE.js +0 -484
- package/dist/chunk-JBXNQCGE.js.map +0 -1
- package/dist/chunk-PY3DNX5H.js.map +0 -1
- package/dist/chunk-WNIIKCNF.js.map +0 -1
- package/dist/interactive-A4DISSIW.js.map +0 -1
- package/dist/session-POJUDFPH.js +0 -6
- package/dist/stream-json-Q2JGWPHB.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/push.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/engine/push.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAsBO,SAAS,aAAA,CAAc,IAAA,EAAc,KAAA,EAAgB,YAAA,EAA4C;AACtG,EAAA,MAAM,MAAM,GAAA,CAAI,IAAA,EAAM,CAAC,WAAA,EAAa,MAAM,CAAC,CAAA,IAAK,0CAAA;AAChD,EAAA,MAAM,MAAA,GAAS,IAAI,IAAA,EAAM,CAAC,aAAa,cAAA,EAAgB,MAAM,CAAC,CAAA,IAAK,MAAA;AACnE,EAAA,MAAM,SAAA,GAAY,IAAI,IAAA,EAAM,CAAC,UAAU,OAAA,EAAS,mBAAmB,CAAC,CAAA,IAAK,MAAA;AACzE,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,cAAA;AAAA,IACf,YAAA,EAAc,OAAA;AAAA,IACd,YAAA;AAAA,IACA,GAAA,EAAK,EAAE,GAAA,EAAK,QAAA,EAAU,IAAI,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,EAAG,MAAA,EAAO;AAAA,IAC/C,YAAY,SAAA,GAAY,EAAE,WAAW,oBAAA,CAAqB,SAAS,GAAE,GAAI,MAAA;AAAA,IACzE,aAAa,KAAA,CAAM,WAAA;AAAA,IACnB,KAAA,EAAO,YAAY,KAAK;AAAA,GAC1B;AACF;AAOO,SAAS,YAAY,KAAA,EAAyB;AACnD,EAAA,OAAO;AAAA,IACL,GAAG,KAAA;AAAA,IACH,KAAA,EAAO,KAAA,CAAM,KAAA,CAAM,GAAA,CAAI,CAAC,CAAA,KAAM;AAC5B,MAAA,MAAM,YAAY,CAAA,CAAE,SAAA,GAAY,cAAc,CAAA,CAAE,SAAS,IAAI,CAAA,CAAE,SAAA;AAC/D,MAAA,MAAM,MAAM,CAAA,CAAE,GAAA,GAAM,cAAc,CAAA,CAAE,GAAG,IAAI,CAAA,CAAE,GAAA;AAC7C,MAAA,OAAO,SAAA,KAAc,CAAA,CAAE,SAAA,IAAa,GAAA,KAAQ,CAAA,CAAE,GAAA,GAAM,EAAE,GAAG,CAAA,EAAG,SAAA,EAAW,GAAA,EAAI,GAAI,CAAA;AAAA,IACjF,CAAC;AAAA,GACH;AACF;AAEA,SAAS,GAAA,CAAI,MAAc,IAAA,EAA+B;AACxD,EAAA,IAAI;AACF,IAAA,OAAO,YAAA,CAAa,KAAA,EAAO,IAAA,EAAM,EAAE,GAAA,EAAK,IAAA,EAAM,QAAA,EAAU,MAAA,EAAQ,CAAA,CAAE,IAAA,EAAK,IAAK,IAAA;AAAA,EAC9E,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"index.js","sourcesContent":["import { execFileSync } from 'node:child_process';\nimport { redactSecrets, redactUrlCredentials } from '../core-open/utils/redact.js';\nimport type { VgGraph } from '../schema.js';\n\n/**\n * The deferred, decoupled push envelope (VG-PACKAGE-AND-SCHEMA §7). In the open\n * CLI `vg push` is **specified but not built**: it assembles and redacts the\n * envelope and prints a notice, but performs **no network upload**. Nothing in\n * the free path depends on it. Drift-over-time/governance is the separate\n * commercial product.\n */\n\nexport interface GraphUploadEnvelope {\n schemaVersion: 'vg-graph/1.0';\n artifactType: 'graph';\n scanIngestId?: string;\n vcs: { sha: string; shortSha: string; branch: string };\n repository?: { name?: string; remoteUrl?: string };\n generatedAt: string;\n graph: VgGraph;\n}\n\nexport function buildEnvelope(root: string, graph: VgGraph, scanIngestId?: string): GraphUploadEnvelope {\n const sha = git(root, ['rev-parse', 'HEAD']) ?? '0000000000000000000000000000000000000000';\n const branch = git(root, ['rev-parse', '--abbrev-ref', 'HEAD']) ?? 'HEAD';\n const remoteUrl = git(root, ['config', '--get', 'remote.origin.url']) ?? undefined;\n return {\n schemaVersion: 'vg-graph/1.0',\n artifactType: 'graph',\n scanIngestId,\n vcs: { sha, shortSha: sha.slice(0, 12), branch },\n repository: remoteUrl ? { remoteUrl: redactUrlCredentials(remoteUrl) } : undefined,\n generatedAt: graph.generatedAt,\n graph: redactGraph(graph),\n };\n}\n\n/**\n * Redaction pass (GUARDRAILS §1: redact before storage). The graph is structure,\n * not content, but we defensively scrub any signature/name that matches a\n * credential-shaped pattern, and strip credentials from the remote URL.\n */\nexport function redactGraph(graph: VgGraph): VgGraph {\n return {\n ...graph,\n nodes: graph.nodes.map((n) => {\n const signature = n.signature ? redactSecrets(n.signature) : n.signature;\n const doc = n.doc ? redactSecrets(n.doc) : n.doc;\n return signature !== n.signature || doc !== n.doc ? { ...n, signature, doc } : n;\n }),\n };\n}\n\nfunction git(root: string, args: string[]): string | null {\n try {\n return execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim() || null;\n } catch {\n return null;\n }\n}\n"]}
|
|
@@ -1,22 +1,40 @@
|
|
|
1
|
+
import { McpToolset, defaultMcpConnect } from './chunk-LEPTUB4H.js';
|
|
1
2
|
import { newSession, loadLatestSession, summarizeSession, saveSession, recordTask } from './chunk-K3SLGULW.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import './chunk-
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
3
|
+
import { startCodeRuntimeSession } from './chunk-JZYGEZTU.js';
|
|
4
|
+
import { TtyPrompter, PromptCancelled } from './chunk-JYS4OBN2.js';
|
|
5
|
+
import { printCodeLogo, runBuild, fetchCatalog, resolveProviders, topProviders } from './chunk-YDAT7LD2.js';
|
|
6
|
+
import { BranchGraphSession } from './chunk-SZLF66FJ.js';
|
|
7
|
+
import { loadOrDiscoverFederation } from './chunk-5I4VSBWQ.js';
|
|
8
|
+
import { resolveExecutionEnv } from './chunk-IS7VTH2Q.js';
|
|
9
|
+
import { runAgent } from './chunk-3BVSDMHV.js';
|
|
10
|
+
import { hasOllama, gatherSystemMemory, stopModel, pullModelClean } from './chunk-EDBV33B7.js';
|
|
11
|
+
import { estimateModelBytes, assessCapability, fmt } from './chunk-KHJO4D5N.js';
|
|
12
|
+
import { mergeModelExecutionProfile, resolveModelExecutionProfile } from './chunk-IZDH67DX.js';
|
|
13
|
+
import { resolveGraphBackend } from './chunk-4CQ3MGNN.js';
|
|
14
|
+
import { vgdIsRunning, vgdRequest } from './chunk-PMYWZRRS.js';
|
|
15
|
+
import './chunk-K7REHDQS.js';
|
|
16
|
+
import './chunk-JIBOJTGS.js';
|
|
17
|
+
import './chunk-NDMDSPFX.js';
|
|
18
|
+
import { nodeCodeFs, undoChanges } from './chunk-OXQNQW5J.js';
|
|
19
|
+
import { summarizeDiffs } from './chunk-7JHPQ6WF.js';
|
|
20
|
+
import { info, c, out } from './chunk-CT5BS56U.js';
|
|
21
|
+
import { refreshIfStale } from './chunk-S6CYDZEW.js';
|
|
22
|
+
import './chunk-WLETRGAC.js';
|
|
23
|
+
import './chunk-C4CKTAZP.js';
|
|
24
|
+
import './chunk-J7LKEB2R.js';
|
|
25
|
+
import { discoverModels } from './chunk-OOIG3RUM.js';
|
|
26
|
+
import { readModelSavings } from './chunk-EDAAG7BL.js';
|
|
27
|
+
import './chunk-6IOQJGFT.js';
|
|
28
|
+
import './chunk-3Q7QBWFW.js';
|
|
8
29
|
import './chunk-RXP66R2E.js';
|
|
30
|
+
import { loadGraph, resolveGraphPath } from './chunk-HABUT7HW.js';
|
|
31
|
+
import './chunk-5Q54GEHM.js';
|
|
32
|
+
import './chunk-BWPBB45M.js';
|
|
33
|
+
import './chunk-JFGYT6BI.js';
|
|
34
|
+
import './chunk-BPF3YX2U.js';
|
|
9
35
|
import './chunk-GI6W53LM.js';
|
|
10
36
|
import './chunk-CRAMOEBE.js';
|
|
11
|
-
import {
|
|
12
|
-
import { summarizeDiffs } from './chunk-CS37OBE3.js';
|
|
13
|
-
import { readModelSavings } from './chunk-WNIIKCNF.js';
|
|
14
|
-
import './chunk-JFGYT6BI.js';
|
|
15
|
-
import { TtyPrompter, PromptCancelled } from './chunk-JYS4OBN2.js';
|
|
16
|
-
import { info, c, out } from './chunk-CT5BS56U.js';
|
|
17
|
-
import { McpToolset, defaultMcpConnect } from './chunk-LEPTUB4H.js';
|
|
18
|
-
import * as os from 'os';
|
|
19
|
-
import { spawnSync, spawn } from 'child_process';
|
|
37
|
+
import { spawnSync } from 'child_process';
|
|
20
38
|
|
|
21
39
|
// src/code/wizard.ts
|
|
22
40
|
var ENTER_SLUG = "__enter_slug__";
|
|
@@ -99,160 +117,6 @@ function modelHint(contextLength, pricePerM) {
|
|
|
99
117
|
return parts.join(" \xB7 ");
|
|
100
118
|
}
|
|
101
119
|
|
|
102
|
-
// src/code/capability.ts
|
|
103
|
-
var GiB = 1024 ** 3;
|
|
104
|
-
var QUANT_BYTES_PER_PARAM = {
|
|
105
|
-
f16: 2,
|
|
106
|
-
fp16: 2,
|
|
107
|
-
f32: 4,
|
|
108
|
-
q8: 1.06,
|
|
109
|
-
q8_0: 1.06,
|
|
110
|
-
q6: 0.82,
|
|
111
|
-
q6_k: 0.82,
|
|
112
|
-
q5: 0.7,
|
|
113
|
-
q5_k_m: 0.72,
|
|
114
|
-
q5_k_s: 0.68,
|
|
115
|
-
q5_0: 0.71,
|
|
116
|
-
q5_1: 0.77,
|
|
117
|
-
q4: 0.58,
|
|
118
|
-
q4_k_m: 0.6,
|
|
119
|
-
q4_k_s: 0.56,
|
|
120
|
-
q4_0: 0.56,
|
|
121
|
-
q4_1: 0.63,
|
|
122
|
-
q3: 0.46,
|
|
123
|
-
q3_k_m: 0.48,
|
|
124
|
-
q3_k_s: 0.44,
|
|
125
|
-
q2: 0.36,
|
|
126
|
-
q2_k: 0.4
|
|
127
|
-
};
|
|
128
|
-
var DEFAULT_QUANT = "q4_k_m";
|
|
129
|
-
var RUNTIME_OVERHEAD = 1.2;
|
|
130
|
-
function estimateModelBytes(slug, defaultParamsB = 7) {
|
|
131
|
-
const lower = slug.toLowerCase();
|
|
132
|
-
const paramMatch = lower.match(/(\d+(?:\.\d+)?)\s*b\b/);
|
|
133
|
-
const paramsB = paramMatch ? Number(paramMatch[1]) : void 0;
|
|
134
|
-
const quant = detectQuant(lower);
|
|
135
|
-
const bytesPerParam = QUANT_BYTES_PER_PARAM[quant] ?? QUANT_BYTES_PER_PARAM[DEFAULT_QUANT];
|
|
136
|
-
const effectiveParams = (paramsB ?? defaultParamsB) * 1e9;
|
|
137
|
-
const bytes = Math.round(effectiveParams * bytesPerParam * RUNTIME_OVERHEAD);
|
|
138
|
-
return { paramsB, quant, bytes, guessed: paramsB === void 0 };
|
|
139
|
-
}
|
|
140
|
-
function detectQuant(lower) {
|
|
141
|
-
const keys = Object.keys(QUANT_BYTES_PER_PARAM).sort((a, b) => b.length - a.length);
|
|
142
|
-
for (const k of keys) if (lower.includes(k)) return k;
|
|
143
|
-
return DEFAULT_QUANT;
|
|
144
|
-
}
|
|
145
|
-
function parseOllamaPs(stdout) {
|
|
146
|
-
const lines = stdout.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
147
|
-
const out2 = [];
|
|
148
|
-
for (const line of lines) {
|
|
149
|
-
if (/^NAME\b/i.test(line)) continue;
|
|
150
|
-
const sizeMatch = line.match(/(\d+(?:\.\d+)?)\s*(GB|GiB|MB|MiB|TB)/i);
|
|
151
|
-
const name = line.split(/\s+/)[0];
|
|
152
|
-
if (!name || !sizeMatch) continue;
|
|
153
|
-
out2.push({ name, bytes: toBytes(Number(sizeMatch[1]), sizeMatch[2]) });
|
|
154
|
-
}
|
|
155
|
-
return out2;
|
|
156
|
-
}
|
|
157
|
-
function parseNvidiaSmi(stdout) {
|
|
158
|
-
const line = stdout.split("\n").map((l) => l.trim()).find(Boolean);
|
|
159
|
-
if (!line) return null;
|
|
160
|
-
const parts = line.split(",").map((p) => Number(p.trim()));
|
|
161
|
-
if (parts.length < 2 || !Number.isFinite(parts[0]) || !Number.isFinite(parts[1])) return null;
|
|
162
|
-
return { totalBytes: parts[0] * 1024 * 1024, usedBytes: parts[1] * 1024 * 1024 };
|
|
163
|
-
}
|
|
164
|
-
function assessCapability(model, sys) {
|
|
165
|
-
const useVram = typeof sys.vramTotalBytes === "number" && sys.vramTotalBytes > 0;
|
|
166
|
-
const free = useVram ? sys.vramFreeBytes ?? 0 : sys.freeRamBytes;
|
|
167
|
-
const loadedBytes = sys.loaded.reduce((n, m) => n + m.bytes, 0);
|
|
168
|
-
const margin = Math.min(2 * GiB, (useVram ? sys.vramTotalBytes : sys.totalRamBytes) * 0.1);
|
|
169
|
-
const available = Math.max(0, free - margin);
|
|
170
|
-
const availableIfUnloaded = Math.max(0, free + loadedBytes - margin);
|
|
171
|
-
const need = model.bytes;
|
|
172
|
-
const canRunNow = available >= need;
|
|
173
|
-
const canRunUnloaded = availableIfUnloaded >= need;
|
|
174
|
-
const suggestions = [];
|
|
175
|
-
if (!canRunNow && canRunUnloaded && sys.loaded.length) {
|
|
176
|
-
const biggest = [...sys.loaded].sort((a, b) => b.bytes - a.bytes);
|
|
177
|
-
suggestions.push(`unload a loaded model to free memory (e.g. \`ollama stop ${biggest[0].name}\` frees ~${fmt(biggest[0].bytes)})`);
|
|
178
|
-
}
|
|
179
|
-
if (!canRunUnloaded) {
|
|
180
|
-
suggestions.push(`this model needs ~${fmt(need)} but only ~${fmt(availableIfUnloaded)} is available \u2014 choose a smaller model or a lower quant (e.g. q4_K_M)`);
|
|
181
|
-
}
|
|
182
|
-
if (model.guessed) {
|
|
183
|
-
suggestions.push(`couldn't read the parameter count from the name \u2014 this estimate assumes a ~${(model.bytes / GiB).toFixed(1)} GiB model; verify before pulling`);
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
model,
|
|
187
|
-
availableBytes: available,
|
|
188
|
-
availableIfUnloadedBytes: availableIfUnloaded,
|
|
189
|
-
canRun: canRunNow || canRunUnloaded,
|
|
190
|
-
needsUnload: !canRunNow && canRunUnloaded,
|
|
191
|
-
suggestions,
|
|
192
|
-
loaded: sys.loaded
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function fmt(bytes) {
|
|
196
|
-
if (bytes >= GiB) return `${(bytes / GiB).toFixed(1)} GiB`;
|
|
197
|
-
return `${(bytes / (1024 * 1024)).toFixed(0)} MiB`;
|
|
198
|
-
}
|
|
199
|
-
function toBytes(n, unit) {
|
|
200
|
-
const u = unit.toLowerCase();
|
|
201
|
-
if (u.startsWith("t")) return n * 1e3 ** 4;
|
|
202
|
-
if (u.startsWith("g")) return n * (u.includes("i") ? GiB : 1e9);
|
|
203
|
-
if (u.startsWith("m")) return n * (u.includes("i") ? 1024 * 1024 : 1e6);
|
|
204
|
-
return n;
|
|
205
|
-
}
|
|
206
|
-
function gatherSystemMemory() {
|
|
207
|
-
const loaded = safeRun("ollama", ["ps"]).map(parseOllamaPs).flat();
|
|
208
|
-
const smi = safeRun("nvidia-smi", ["--query-gpu=memory.total,memory.used", "--format=csv,noheader,nounits"]).map(parseNvidiaSmi).find(Boolean);
|
|
209
|
-
const sys = {
|
|
210
|
-
totalRamBytes: os.totalmem(),
|
|
211
|
-
freeRamBytes: os.freemem(),
|
|
212
|
-
loaded
|
|
213
|
-
};
|
|
214
|
-
if (smi) {
|
|
215
|
-
sys.vramTotalBytes = smi.totalBytes;
|
|
216
|
-
sys.vramFreeBytes = Math.max(0, smi.totalBytes - smi.usedBytes);
|
|
217
|
-
}
|
|
218
|
-
return sys;
|
|
219
|
-
}
|
|
220
|
-
function hasOllama() {
|
|
221
|
-
return spawnSync(process.platform === "win32" ? "where" : "which", ["ollama"], { stdio: "ignore" }).status === 0;
|
|
222
|
-
}
|
|
223
|
-
function stopModel(name) {
|
|
224
|
-
return spawnSync("ollama", ["stop", name], { stdio: "ignore" }).status === 0;
|
|
225
|
-
}
|
|
226
|
-
function pullModelClean(name, spinner) {
|
|
227
|
-
return new Promise((resolve) => {
|
|
228
|
-
const child = spawn("ollama", ["pull", name]);
|
|
229
|
-
const onData = (buf) => {
|
|
230
|
-
const line = lastMeaningfulLine(buf.toString());
|
|
231
|
-
if (line) spinner.update(`pulling ${name} \u2014 ${line}`);
|
|
232
|
-
};
|
|
233
|
-
child.stdout?.on("data", onData);
|
|
234
|
-
child.stderr?.on("data", onData);
|
|
235
|
-
child.on("error", () => resolve(false));
|
|
236
|
-
child.on("close", (code) => resolve(code === 0));
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
function lastMeaningfulLine(chunk) {
|
|
240
|
-
const lines = chunk.split(/[\r\n]+/).map((l) => l.trim()).map((l) => l.replace(/\x1b\[[0-9;]*[A-Za-z]/g, "").replace(/[▏▎▍▌▋▊▉█░▒▓⣀-⣿]/g, "").trim()).filter(Boolean);
|
|
241
|
-
const last = lines[lines.length - 1] ?? "";
|
|
242
|
-
const pct = last.match(/(\d+)\s*%/);
|
|
243
|
-
const status = last.replace(/\s{2,}.*$/, "").slice(0, 48);
|
|
244
|
-
return pct ? `${status} ${pct[1]}%`.trim() : status;
|
|
245
|
-
}
|
|
246
|
-
function safeRun(bin, args) {
|
|
247
|
-
try {
|
|
248
|
-
const res = spawnSync(bin, args, { encoding: "utf8", timeout: 5e3 });
|
|
249
|
-
if (res.status !== 0 || typeof res.stdout !== "string") return [];
|
|
250
|
-
return [res.stdout];
|
|
251
|
-
} catch {
|
|
252
|
-
return [];
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
120
|
// src/code/cost.ts
|
|
257
121
|
function costOf(usage, pricing) {
|
|
258
122
|
const inCost = (usage.promptTokens ?? 0) / 1e6 * (pricing.promptPerM ?? 0);
|
|
@@ -300,54 +164,23 @@ function fmtTokens(n) {
|
|
|
300
164
|
function round4(x) {
|
|
301
165
|
return Math.round(x * 1e4) / 1e4;
|
|
302
166
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const spawnImpl = options.spawnImpl ?? spawn;
|
|
321
|
-
try {
|
|
322
|
-
const child = spawnImpl(launch.command, args, { cwd: options.root, stdio: "ignore", detached: false });
|
|
323
|
-
if (!child || typeof child.pid !== "number") return null;
|
|
324
|
-
child.on("error", () => {
|
|
325
|
-
});
|
|
326
|
-
return new _GraphProcess(child, launch.command, args);
|
|
327
|
-
} catch {
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
get pid() {
|
|
332
|
-
return this.child?.pid;
|
|
333
|
-
}
|
|
334
|
-
/** True while the child is believed to be running. */
|
|
335
|
-
get running() {
|
|
336
|
-
return this.child !== null && !this.disposed;
|
|
337
|
-
}
|
|
338
|
-
/** Kill the child. Idempotent and safe to call after the child already exited. */
|
|
339
|
-
dispose() {
|
|
340
|
-
if (this.disposed) return;
|
|
341
|
-
this.disposed = true;
|
|
342
|
-
const child = this.child;
|
|
343
|
-
this.child = null;
|
|
344
|
-
if (!child || child.killed) return;
|
|
345
|
-
try {
|
|
346
|
-
child.kill("SIGTERM");
|
|
347
|
-
} catch {
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
};
|
|
167
|
+
|
|
168
|
+
// src/runtime/bridge-facts.ts
|
|
169
|
+
function bridgePinnedFacts(bridges, options = {}) {
|
|
170
|
+
if (!bridges?.length) return [];
|
|
171
|
+
const min = options.minConfidence ?? 0.8;
|
|
172
|
+
const max = options.maxFacts ?? 12;
|
|
173
|
+
return bridges.filter((b) => b.confidence >= min).map((b) => {
|
|
174
|
+
const from = shortLabel(b.fromRoot);
|
|
175
|
+
const to = shortLabel(b.toRoot);
|
|
176
|
+
const via = b.packageName ? ` package ${b.packageName}` : "";
|
|
177
|
+
return `bridge ${b.kind}: ${from} \u2192 ${to}${via} (${b.confidence.toFixed(2)})`;
|
|
178
|
+
}).sort((a, b) => a.localeCompare(b)).slice(0, max);
|
|
179
|
+
}
|
|
180
|
+
function shortLabel(root) {
|
|
181
|
+
const parts = root.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
182
|
+
return parts[parts.length - 1] || root;
|
|
183
|
+
}
|
|
351
184
|
|
|
352
185
|
// src/code/interactive.ts
|
|
353
186
|
async function runInteractive(root, global, opts, prompter = new TtyPrompter()) {
|
|
@@ -379,7 +212,8 @@ async function ensureMap(root, global, prompter) {
|
|
|
379
212
|
return;
|
|
380
213
|
}
|
|
381
214
|
const sp = prompter.spinner("Checking the code map is up to date\u2026");
|
|
382
|
-
const
|
|
215
|
+
const graphPath = resolveGraphPath(root);
|
|
216
|
+
const refreshed = await refreshIfStale(root, { graphPath }).catch(() => null);
|
|
383
217
|
if (refreshed?.status === "refreshed") sp.stop("Code map refreshed");
|
|
384
218
|
else sp.stop("Code map ready");
|
|
385
219
|
}
|
|
@@ -454,14 +288,58 @@ async function codingRepl(root, global, opts, selection, prompter) {
|
|
|
454
288
|
sp.stop(`MCP tools: ${toolset.specs().length} from ${Object.keys(opts.mcpServers).length} server(s)${from}`);
|
|
455
289
|
for (const w of warnings) prompter.note(c.yellow(` ${w}`));
|
|
456
290
|
}
|
|
457
|
-
const
|
|
291
|
+
const runtime = await startCodeRuntimeSession({ root });
|
|
292
|
+
const branchGraphs = new BranchGraphSession({ root, graphPath: global.graph });
|
|
293
|
+
const federation = loadOrDiscoverFederation(root);
|
|
294
|
+
const extraPinnedFacts = bridgePinnedFacts(federation.bridges);
|
|
295
|
+
if (federation.members.length > 1 && await vgdIsRunning({ socketPath: runtime.socketPath })) {
|
|
296
|
+
try {
|
|
297
|
+
await vgdRequest(
|
|
298
|
+
{
|
|
299
|
+
op: "register-federation",
|
|
300
|
+
primaryRoot: federation.primaryRoot,
|
|
301
|
+
members: federation.members.map((m) => ({ root: m.root, label: m.label, role: m.role }))
|
|
302
|
+
},
|
|
303
|
+
{ socketPath: runtime.socketPath }
|
|
304
|
+
);
|
|
305
|
+
const bridgeN = federation.bridges?.length ?? 0;
|
|
306
|
+
prompter.note(
|
|
307
|
+
c.dim(
|
|
308
|
+
`federation \xB7 ${federation.members.length} workspace(s) registered with vgd` + (bridgeN ? ` \xB7 ${bridgeN} bridge edge(s)` : "")
|
|
309
|
+
)
|
|
310
|
+
);
|
|
311
|
+
} catch {
|
|
312
|
+
}
|
|
313
|
+
} else if ((federation.bridges?.length ?? 0) > 0) {
|
|
314
|
+
prompter.note(
|
|
315
|
+
c.dim(
|
|
316
|
+
`federation \xB7 ${federation.members.length} member(s) \xB7 ${federation.bridges.length} bridge edge(s) (discovery)`
|
|
317
|
+
)
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
let modelProfile = mergeModelExecutionProfile(
|
|
321
|
+
resolveModelExecutionProfile({
|
|
322
|
+
providerId: sel.providerSlug,
|
|
323
|
+
model: sel.model,
|
|
324
|
+
budget: opts.budget ? Number(opts.budget) : void 0,
|
|
325
|
+
maxRepairRounds: opts.verify?.maxRounds,
|
|
326
|
+
securityTier: opts.securityTier
|
|
327
|
+
}),
|
|
328
|
+
opts.modelProfile
|
|
329
|
+
);
|
|
330
|
+
const securityTier = opts.securityTier ?? modelProfile.securityTier ?? (opts.auto ? "L1" : "L0");
|
|
331
|
+
const writableRoots = federation?.members.map((m) => m.root) ?? [root];
|
|
332
|
+
const executionEnv = resolveExecutionEnv(securityTier, { writableRoots });
|
|
458
333
|
const cleanup = () => {
|
|
459
|
-
|
|
334
|
+
void runtime.dispose();
|
|
460
335
|
void mcp?.dispose();
|
|
461
336
|
};
|
|
462
337
|
process.once("SIGINT", cleanup);
|
|
463
338
|
const autoNote = opts.auto ? c.yellow(" \xB7 auto-approve ON") : "";
|
|
464
|
-
|
|
339
|
+
const runtimeNote = runtime.kind !== "none" ? c.dim(` \xB7 ${runtime.label}`) : "";
|
|
340
|
+
const securityNote = c.dim(` \xB7 ${executionEnv.tier}/${executionEnv.label}`);
|
|
341
|
+
const mepNote = c.dim(` \xB7 mep ${modelProfile.mode}`);
|
|
342
|
+
prompter.intro(`Ready \u2014 ${sel.providerSlug}/${sel.model}${runtimeNote}${securityNote}${mepNote}${autoNote}. Describe a task, or /help. Empty line to exit.`);
|
|
465
343
|
try {
|
|
466
344
|
for (; ; ) {
|
|
467
345
|
const line = (await prompter.input("code \u203A")).trim();
|
|
@@ -499,11 +377,47 @@ async function codingRepl(root, global, opts, selection, prompter) {
|
|
|
499
377
|
}
|
|
500
378
|
continue;
|
|
501
379
|
}
|
|
502
|
-
const
|
|
380
|
+
const branchLoad = branchGraphs.ensureCurrent();
|
|
381
|
+
const graph = branchLoad.graph;
|
|
503
382
|
if (!graph) {
|
|
504
383
|
prompter.note(c.red("the code map disappeared \u2014 run `vg` to rebuild"));
|
|
505
384
|
break;
|
|
506
385
|
}
|
|
386
|
+
if (branchLoad.switched) {
|
|
387
|
+
prompter.note(
|
|
388
|
+
c.dim(
|
|
389
|
+
`branch \xB7 ${branchLoad.gitRef}${branchLoad.fromCache ? " (warm cache)" : " (loaded map)"}`
|
|
390
|
+
)
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
if (runtime.socketPath && graph && branchLoad.gitRef && branchLoad.gitRef !== "unknown") {
|
|
394
|
+
void vgdRequest(
|
|
395
|
+
{
|
|
396
|
+
op: "put-graph",
|
|
397
|
+
repositoryId: branchLoad.repositoryId,
|
|
398
|
+
gitRef: branchLoad.gitRef,
|
|
399
|
+
graph
|
|
400
|
+
},
|
|
401
|
+
{ socketPath: runtime.socketPath }
|
|
402
|
+
).catch(() => {
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
const graphBackend = resolveGraphBackend({
|
|
406
|
+
graph,
|
|
407
|
+
repositoryId: branchLoad.repositoryId,
|
|
408
|
+
gitRef: branchLoad.gitRef !== "unknown" ? branchLoad.gitRef : null,
|
|
409
|
+
socketPath: runtime.socketPath
|
|
410
|
+
});
|
|
411
|
+
modelProfile = mergeModelExecutionProfile(
|
|
412
|
+
resolveModelExecutionProfile({
|
|
413
|
+
providerId: sel.providerSlug,
|
|
414
|
+
model: sel.model,
|
|
415
|
+
budget: opts.budget ? Number(opts.budget) : void 0,
|
|
416
|
+
maxRepairRounds: opts.verify?.maxRounds,
|
|
417
|
+
securityTier
|
|
418
|
+
}),
|
|
419
|
+
opts.modelProfile
|
|
420
|
+
);
|
|
507
421
|
const result = await agentTask({
|
|
508
422
|
root,
|
|
509
423
|
graph,
|
|
@@ -513,15 +427,21 @@ async function codingRepl(root, global, opts, selection, prompter) {
|
|
|
513
427
|
attribution: { client: "vg-code", provider: sel.providerSlug, model: sel.model },
|
|
514
428
|
auto: !!opts.auto,
|
|
515
429
|
maxSteps: opts.maxSteps,
|
|
430
|
+
budget: modelProfile.capsuleBudgetTokens,
|
|
516
431
|
denyCommands: opts.denyCommands,
|
|
517
432
|
testCommand: opts.testCommand,
|
|
518
433
|
contextBudget: opts.contextBudget,
|
|
519
434
|
stream: opts.stream,
|
|
520
|
-
verify: opts.verify,
|
|
435
|
+
verify: opts.verify ? { ...opts.verify, maxRounds: opts.verify.maxRounds ?? modelProfile.maxRepairRounds } : void 0,
|
|
521
436
|
priorSummary,
|
|
522
437
|
externalTools: mcp ? mcpExternalTools(mcp, agentApprove(opts, prompter)) : void 0,
|
|
523
438
|
meter,
|
|
524
|
-
prompter
|
|
439
|
+
prompter,
|
|
440
|
+
capsule: opts.capsule,
|
|
441
|
+
executionEnv,
|
|
442
|
+
graphBackend,
|
|
443
|
+
modelProfile,
|
|
444
|
+
extraPinnedFacts
|
|
525
445
|
});
|
|
526
446
|
priorSummary = void 0;
|
|
527
447
|
if (result.changes.length) {
|
|
@@ -541,6 +461,12 @@ function agentApprove(opts, prompter) {
|
|
|
541
461
|
return async (action) => {
|
|
542
462
|
if (opts.auto) return true;
|
|
543
463
|
if (action.kind === "tool") return prompter.confirm(`Call ${action.name}?`, false);
|
|
464
|
+
if (action.kind === "patch") {
|
|
465
|
+
const n = action.files.length;
|
|
466
|
+
const names = action.files.slice(0, 6).map((f) => f.file).join(", ");
|
|
467
|
+
const more = n > 6 ? ` (+${n - 6} more)` : "";
|
|
468
|
+
return prompter.confirm(`Apply patch to ${n} file(s): ${names}${more}?`, false);
|
|
469
|
+
}
|
|
544
470
|
return true;
|
|
545
471
|
};
|
|
546
472
|
}
|
|
@@ -597,6 +523,16 @@ async function agentTask(params) {
|
|
|
597
523
|
return prompter.confirm(`Run \`${action.command}\`?`, false);
|
|
598
524
|
case "tool":
|
|
599
525
|
return prompter.confirm(`Call ${action.name}(${briefArgs(action.args)})?`, false);
|
|
526
|
+
case "patch": {
|
|
527
|
+
const n = action.files.length;
|
|
528
|
+
for (const f of action.files) {
|
|
529
|
+
if (f.diff) out(f.diff);
|
|
530
|
+
else out(`${f.op} ${f.file}`);
|
|
531
|
+
}
|
|
532
|
+
const names = action.files.slice(0, 6).map((f) => f.file).join(", ");
|
|
533
|
+
const more = n > 6 ? ` (+${n - 6} more)` : "";
|
|
534
|
+
return prompter.confirm(`Apply patch to ${n} file(s): ${names}${more}?`, false);
|
|
535
|
+
}
|
|
600
536
|
}
|
|
601
537
|
};
|
|
602
538
|
let streaming = false;
|
|
@@ -623,6 +559,20 @@ async function agentTask(params) {
|
|
|
623
559
|
info(c.dim(` \xB7 compacted context (${e.droppedRounds} earlier round(s) summarized)`));
|
|
624
560
|
} else if (e.type === "verify") {
|
|
625
561
|
info(e.passed ? c.green(` \u2714 ${e.command} passed`) : c.yellow(` \u2717 ${e.command} failed \u2014 asking the model to fix it`));
|
|
562
|
+
} else if (e.type === "ladder") {
|
|
563
|
+
info(e.ok ? c.green(" \u2714 verification ladder passed") : c.yellow(" \u2717 verification ladder failed \u2014 asking the model to fix it"));
|
|
564
|
+
if (!e.ok && e.summary.trim()) {
|
|
565
|
+
for (const line of e.summary.split("\n").slice(0, 6)) info(c.dim(` ${line}`));
|
|
566
|
+
}
|
|
567
|
+
} else if (e.type === "session-graph") {
|
|
568
|
+
info(c.dim(` \xB7 session graph updated (${e.reparsed} reparsed, ${e.dirty} dirty)`));
|
|
569
|
+
} else if (e.type === "capsule") {
|
|
570
|
+
info(c.dim(` \xB7 Task Capsule \xB7 ${e.summary.primary.length} primary \xB7 ${e.summary.sourceSliceCount} source slice(s) \xB7 ~${e.summary.tokensEstimate} tokens`));
|
|
571
|
+
} else if (e.type === "failure-capsule") {
|
|
572
|
+
info(c.yellow(` \xB7 Failure Capsule \xB7 ${e.capsule.failedStep.type}${e.capsule.failedStep.command ? ` \xB7 ${e.capsule.failedStep.command}` : ""}`));
|
|
573
|
+
} else if (e.type === "metrics") {
|
|
574
|
+
const m = e.metrics;
|
|
575
|
+
info(c.dim(` \xB7 metrics \xB7 discovery ${m.discoveryToolCalls} \xB7 mutations ${m.mutationToolCalls}${m.znsAt1 ? " \xB7 ZNS@1" : ""}`));
|
|
626
576
|
}
|
|
627
577
|
};
|
|
628
578
|
const result = await runAgent({
|
|
@@ -632,6 +582,13 @@ async function agentTask(params) {
|
|
|
632
582
|
providers: params.providers,
|
|
633
583
|
fsImpl: params.fsImpl,
|
|
634
584
|
run: shellRunner(params.root),
|
|
585
|
+
executionEnv: params.executionEnv,
|
|
586
|
+
graphBackend: params.graphBackend,
|
|
587
|
+
modelProfile: params.modelProfile,
|
|
588
|
+
advancedMode: params.advancedMode,
|
|
589
|
+
// Interactive sessions always prefer a worktree-correct map unless disabled.
|
|
590
|
+
worktreeOverlay: params.worktreeOverlay ?? true,
|
|
591
|
+
extraPinnedFacts: params.extraPinnedFacts,
|
|
635
592
|
approve,
|
|
636
593
|
onEvent,
|
|
637
594
|
attribution: params.attribution,
|
|
@@ -645,6 +602,8 @@ async function agentTask(params) {
|
|
|
645
602
|
verify: params.verify,
|
|
646
603
|
priorSummary: params.priorSummary,
|
|
647
604
|
externalTools: params.externalTools,
|
|
605
|
+
capsule: params.capsule,
|
|
606
|
+
files: params.files,
|
|
648
607
|
now: () => Date.now()
|
|
649
608
|
});
|
|
650
609
|
closeStream();
|
|
@@ -677,5 +636,5 @@ ${res.stderr}` : "");
|
|
|
677
636
|
}
|
|
678
637
|
|
|
679
638
|
export { agentTask, runInteractive };
|
|
680
|
-
//# sourceMappingURL=interactive-
|
|
681
|
-
//# sourceMappingURL=interactive-
|
|
639
|
+
//# sourceMappingURL=interactive-ICL7D7LO.js.map
|
|
640
|
+
//# sourceMappingURL=interactive-ICL7D7LO.js.map
|