@vibgrate/cli 2026.727.3 → 2026.727.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseline-ENCOSJYQ.js +8 -0
- package/dist/{baseline-ATM5MXBZ.js.map → baseline-ENCOSJYQ.js.map} +1 -1
- package/dist/chunk-3SDV6ADQ.js +78 -0
- package/dist/chunk-3SDV6ADQ.js.map +1 -0
- package/dist/{chunk-6JIKUDWM.js → chunk-6AXHLQBV.js} +219 -22
- package/dist/chunk-6AXHLQBV.js.map +1 -0
- package/dist/{chunk-C66GOHYB.js → chunk-FPEOIS7K.js} +58 -23
- package/dist/chunk-FPEOIS7K.js.map +1 -0
- package/dist/{chunk-OOIG3RUM.js → chunk-GYSOQH5C.js} +18 -79
- package/dist/chunk-GYSOQH5C.js.map +1 -0
- package/dist/{chunk-FFWGT55D.js → chunk-HYRAILGM.js} +3 -3
- package/dist/{chunk-FFWGT55D.js.map → chunk-HYRAILGM.js.map} +1 -1
- package/dist/{chunk-NDMDSPFX.js → chunk-KKRSQQ3A.js} +4 -3
- package/dist/chunk-KKRSQQ3A.js.map +1 -0
- package/dist/chunk-KUIBP3LU.js +101 -0
- package/dist/chunk-KUIBP3LU.js.map +1 -0
- package/dist/{chunk-OFUC6RYN.js → chunk-KXSKFQMI.js} +6 -99
- package/dist/chunk-KXSKFQMI.js.map +1 -0
- package/dist/{chunk-AVQSHIJ5.js → chunk-LJP2EPKM.js} +4 -4
- package/dist/{chunk-AVQSHIJ5.js.map → chunk-LJP2EPKM.js.map} +1 -1
- package/dist/{chunk-Z7GP7XTJ.js → chunk-MAUJTPQW.js} +5 -5
- package/dist/{chunk-Z7GP7XTJ.js.map → chunk-MAUJTPQW.js.map} +1 -1
- package/dist/{chunk-3V24O47U.js → chunk-PVZBYZZR.js} +19 -9
- package/dist/chunk-PVZBYZZR.js.map +1 -0
- package/dist/{chunk-2VFWXNS5.js → chunk-R6ZRVVZT.js} +3 -3
- package/dist/{chunk-2VFWXNS5.js.map → chunk-R6ZRVVZT.js.map} +1 -1
- package/dist/{chunk-Y23HMSWU.js → chunk-T3AYRS7J.js} +14 -7
- package/dist/chunk-T3AYRS7J.js.map +1 -0
- package/dist/chunk-YCJIIGLP.js +356 -0
- package/dist/chunk-YCJIIGLP.js.map +1 -0
- package/dist/{chunk-MAY5HLDH.js → chunk-YKVH2PGF.js} +68 -23
- package/dist/chunk-YKVH2PGF.js.map +1 -0
- package/dist/cli.js +68 -199
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/{interactive-INGJNSON.js → interactive-SMHVURYK.js} +44 -14
- package/dist/interactive-SMHVURYK.js.map +1 -0
- package/dist/model-manager-PN7HEDXD.js +9 -0
- package/dist/{model-orchestrator-TVONAUPS.js.map → model-manager-PN7HEDXD.js.map} +1 -1
- package/dist/{model-orchestrator-TVONAUPS.js → model-orchestrator-4VSYP4J4.js} +3 -3
- package/dist/model-orchestrator-4VSYP4J4.js.map +1 -0
- package/dist/resolve-gguf-Y6FH3CNB.js +9 -0
- package/dist/{resolve-gguf-VPL4YQ6J.js.map → resolve-gguf-Y6FH3CNB.js.map} +1 -1
- package/dist/{session-M72522AP.js → session-W3646AOV.js} +5 -4
- package/dist/{session-M72522AP.js.map → session-W3646AOV.js.map} +1 -1
- package/dist/{stream-json-6ZBUA2L3.js → stream-json-X7UQFB4T.js} +7 -6
- package/dist/stream-json-X7UQFB4T.js.map +1 -0
- package/package.json +1 -1
- package/dist/baseline-ATM5MXBZ.js +0 -8
- package/dist/chunk-3V24O47U.js.map +0 -1
- package/dist/chunk-6JIKUDWM.js.map +0 -1
- package/dist/chunk-C66GOHYB.js.map +0 -1
- package/dist/chunk-MAY5HLDH.js.map +0 -1
- package/dist/chunk-NDMDSPFX.js.map +0 -1
- package/dist/chunk-OFUC6RYN.js.map +0 -1
- package/dist/chunk-OOIG3RUM.js.map +0 -1
- package/dist/chunk-Y23HMSWU.js.map +0 -1
- package/dist/interactive-INGJNSON.js.map +0 -1
- package/dist/resolve-gguf-VPL4YQ6J.js +0 -8
- package/dist/stream-json-6ZBUA2L3.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { baselineCommand, runBaseline } from './chunk-HYRAILGM.js';
|
|
2
|
+
import './chunk-T3AYRS7J.js';
|
|
3
|
+
import './chunk-CRAMOEBE.js';
|
|
4
|
+
import './chunk-RXP66R2E.js';
|
|
5
|
+
import './chunk-GI6W53LM.js';
|
|
6
|
+
import './chunk-DGUM43GV.js';
|
|
7
|
+
//# sourceMappingURL=baseline-ENCOSJYQ.js.map
|
|
8
|
+
//# sourceMappingURL=baseline-ENCOSJYQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"baseline-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"baseline-ENCOSJYQ.js"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { listCachedWeights } from './chunk-GYSOQH5C.js';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
|
|
6
|
+
function discoverModels(home = os.homedir()) {
|
|
7
|
+
return [...ollama(home), ...lmStudio(home), ...looseGguf(home), ...vibgrateWeightStore()].sort(
|
|
8
|
+
(a, b) => a.runtime.localeCompare(b.runtime) || a.name.localeCompare(b.name)
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function vibgrateWeightStore() {
|
|
12
|
+
return listCachedWeights().map((w) => ({ runtime: "gguf", name: w.name, path: w.path }));
|
|
13
|
+
}
|
|
14
|
+
function ollama(home) {
|
|
15
|
+
const base = path.join(home, ".ollama", "models", "manifests");
|
|
16
|
+
const out = [];
|
|
17
|
+
walk(base, 4, (file) => {
|
|
18
|
+
const rel = path.relative(base, file).split(path.sep);
|
|
19
|
+
if (rel.length >= 2) {
|
|
20
|
+
const tag = rel[rel.length - 1];
|
|
21
|
+
const model = rel[rel.length - 2];
|
|
22
|
+
out.push({ runtime: "ollama", name: `${model}:${tag}`, path: file });
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return dedupe(out);
|
|
26
|
+
}
|
|
27
|
+
function lmStudio(home) {
|
|
28
|
+
const bases = [path.join(home, ".lmstudio", "models"), path.join(home, ".cache", "lm-studio", "models")];
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const base of bases) {
|
|
31
|
+
walk(base, 5, (file) => {
|
|
32
|
+
if (!file.endsWith(".gguf")) return;
|
|
33
|
+
const rel = path.relative(base, file).replace(/\\/g, "/");
|
|
34
|
+
out.push({ runtime: "lm-studio", name: rel, path: file });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return dedupe(out);
|
|
38
|
+
}
|
|
39
|
+
function looseGguf(home) {
|
|
40
|
+
const bases = [path.join(home, "models"), path.join(home, ".cache", "huggingface")];
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const base of bases) {
|
|
43
|
+
walk(base, 4, (file) => {
|
|
44
|
+
if (!file.endsWith(".gguf")) return;
|
|
45
|
+
out.push({ runtime: "gguf", name: path.basename(file), path: file });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return dedupe(out);
|
|
49
|
+
}
|
|
50
|
+
function walk(dir, depth, onFile) {
|
|
51
|
+
if (depth < 0) return;
|
|
52
|
+
let entries;
|
|
53
|
+
try {
|
|
54
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
55
|
+
} catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (const e of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
59
|
+
const abs = path.join(dir, e.name);
|
|
60
|
+
if (e.isDirectory()) walk(abs, depth - 1, onFile);
|
|
61
|
+
else if (e.isFile()) onFile(abs);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function dedupe(models) {
|
|
65
|
+
const seen = /* @__PURE__ */ new Set();
|
|
66
|
+
const out = [];
|
|
67
|
+
for (const m of models) {
|
|
68
|
+
const key = `${m.runtime}:${m.name}`;
|
|
69
|
+
if (seen.has(key)) continue;
|
|
70
|
+
seen.add(key);
|
|
71
|
+
out.push(m);
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { discoverModels };
|
|
77
|
+
//# sourceMappingURL=chunk-3SDV6ADQ.js.map
|
|
78
|
+
//# sourceMappingURL=chunk-3SDV6ADQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/models.ts"],"names":[],"mappings":";;;;;AAkBO,SAAS,cAAA,CAAe,IAAA,GAAU,EAAA,CAAA,OAAA,EAAQ,EAAiB;AAChE,EAAA,OAAO,CAAC,GAAG,MAAA,CAAO,IAAI,CAAA,EAAG,GAAG,QAAA,CAAS,IAAI,CAAA,EAAG,GAAG,UAAU,IAAI,CAAA,EAAG,GAAG,mBAAA,EAAqB,CAAA,CAAE,IAAA;AAAA,IACxF,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,OAAA,CAAQ,aAAA,CAAc,CAAA,CAAE,OAAO,CAAA,IAAK,CAAA,CAAE,IAAA,CAAK,aAAA,CAAc,EAAE,IAAI;AAAA,GAC7E;AACF;AAGA,SAAS,mBAAA,GAAoC;AAC3C,EAAA,OAAO,iBAAA,EAAkB,CAAE,GAAA,CAAI,CAAC,OAAO,EAAE,OAAA,EAAS,MAAA,EAAiB,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,IAAA,EAAM,CAAA,CAAE,MAAK,CAAE,CAAA;AAClG;AAEA,SAAS,OAAO,IAAA,EAA4B;AAC1C,EAAA,MAAM,IAAA,GAAY,IAAA,CAAA,IAAA,CAAK,IAAA,EAAM,SAAA,EAAW,UAAU,WAAW,CAAA;AAC7D,EAAA,MAAM,MAAoB,EAAC;AAC3B,EAAA,IAA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AI,CAAA;AACjC,IAAA,IAAI,EAAE,WAAA,EAAY,OAAQ,GAAA,EAAK,KAAA,GAAQ,GAAG,MAAM,CAAA;AAAA,SAAA,IACvC,CAAA,CAAE,MAAA,EAAO,EAAG,MAAA,CAAO,GAAG,CAAA;AAAA,EACjC;AACF;AAEA,SAAS,OAAO,MAAA,EAAoC;AAClD,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,MAAM,MAAoB,EAAC;AAC3B,EAAA,KAAA,MAAW,KAAK,MAAA,EAAQ;AACtB,IAAA,MAAM,MAAM,CAAA,EAAG,CAAA,CAAE,OAAO,CAAA,CAAA,EAAI,EAAE,IAAI,CAAA,CAAA;AAClC,IAAA,IAAI,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA,EAAG;AACnB,IAAA,IAAA,CAAK,IAAI,GAAG,CAAA;AACZ,IAAA,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,EACZ;AACA,EAAA,OAAO,GAAA;AACT","file":"chunk-3SDV6ADQ.js","sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { listCachedWeights } from '../runtime/weight-store.js';\n\n/**\n * Local-model discovery (VG-LOCAL-MODELS §9.2) — be a no-key *consumer* of the\n * developer's local model fleet. Fully offline and deterministic: inspect the\n * on-disk layouts of Ollama / LM Studio / llama.cpp / the Vibgrate weight store,\n * never the network. No runtime is built or launched.\n */\n\nexport interface LocalModel {\n runtime: 'ollama' | 'lm-studio' | 'gguf';\n name: string;\n path: string;\n}\n\nexport function discoverModels(home = os.homedir()): LocalModel[] {\n return [...ollama(home), ...lmStudio(home), ...looseGguf(home), ...vibgrateWeightStore()].sort(\n (a, b) => a.runtime.localeCompare(b.runtime) || a.name.localeCompare(b.name),\n );\n}\n\n/** First-party GGUF cache (runtime/weight-store.ts). */\nfunction vibgrateWeightStore(): LocalModel[] {\n return listCachedWeights().map((w) => ({ runtime: 'gguf' as const, name: w.name, path: w.path }));\n}\n\nfunction ollama(home: string): LocalModel[] {\n const base = path.join(home, '.ollama', 'models', 'manifests');\n const out: LocalModel[] = [];\n walk(base, 4, (file) => {\n // .../library/<model>/<tag>\n const rel = path.relative(base, file).split(path.sep);\n if (rel.length >= 2) {\n const tag = rel[rel.length - 1];\n const model = rel[rel.length - 2];\n out.push({ runtime: 'ollama', name: `${model}:${tag}`, path: file });\n }\n });\n return dedupe(out);\n}\n\nfunction lmStudio(home: string): LocalModel[] {\n const bases = [path.join(home, '.lmstudio', 'models'), path.join(home, '.cache', 'lm-studio', 'models')];\n const out: LocalModel[] = [];\n for (const base of bases) {\n walk(base, 5, (file) => {\n if (!file.endsWith('.gguf')) return;\n const rel = path.relative(base, file).replace(/\\\\/g, '/');\n out.push({ runtime: 'lm-studio', name: rel, path: file });\n });\n }\n return dedupe(out);\n}\n\nfunction looseGguf(home: string): LocalModel[] {\n const bases = [path.join(home, 'models'), path.join(home, '.cache', 'huggingface')];\n const out: LocalModel[] = [];\n for (const base of bases) {\n walk(base, 4, (file) => {\n if (!file.endsWith('.gguf')) return;\n out.push({ runtime: 'gguf', name: path.basename(file), path: file });\n });\n }\n return dedupe(out);\n}\n\nfunction walk(dir: string, depth: number, onFile: (file: string) => void): void {\n if (depth < 0) return;\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const e of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n const abs = path.join(dir, e.name);\n if (e.isDirectory()) walk(abs, depth - 1, onFile);\n else if (e.isFile()) onFile(abs);\n }\n}\n\nfunction dedupe(models: LocalModel[]): LocalModel[] {\n const seen = new Set<string>();\n const out: LocalModel[] = [];\n for (const m of models) {\n const key = `${m.runtime}:${m.name}`;\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(m);\n }\n return out;\n}\n"]}
|
|
@@ -1241,20 +1241,95 @@ function npmPackageDir(root, name) {
|
|
|
1241
1241
|
}
|
|
1242
1242
|
return void 0;
|
|
1243
1243
|
}
|
|
1244
|
-
|
|
1244
|
+
var README_CANDIDATES = ["llms.txt", "README.md", "README.mdx", "README", "readme.md"];
|
|
1245
|
+
function packageDocsMarkdown(dir, query) {
|
|
1246
|
+
const docsDir = path4.join(dir, "docs");
|
|
1247
|
+
if (!fs4.existsSync(docsDir) || !fs4.statSync(docsDir).isDirectory()) return void 0;
|
|
1248
|
+
const files = [];
|
|
1249
|
+
const walk = (d, depth) => {
|
|
1250
|
+
if (depth > 3 || files.length >= 40) return;
|
|
1251
|
+
let entries;
|
|
1252
|
+
try {
|
|
1253
|
+
entries = fs4.readdirSync(d, { withFileTypes: true });
|
|
1254
|
+
} catch {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
1258
|
+
for (const e of entries) {
|
|
1259
|
+
if (files.length >= 40) return;
|
|
1260
|
+
const full = path4.join(d, e.name);
|
|
1261
|
+
if (e.isDirectory()) {
|
|
1262
|
+
if (e.name.startsWith(".") || e.name === "node_modules") continue;
|
|
1263
|
+
walk(full, depth + 1);
|
|
1264
|
+
} else if (e.isFile() && /\.(md|mdx)$/i.test(e.name)) {
|
|
1265
|
+
files.push(full);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
walk(docsDir, 0);
|
|
1270
|
+
if (!files.length) return void 0;
|
|
1271
|
+
const terms = (query ?? "").toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length > 2);
|
|
1272
|
+
const scored = files.map((f) => {
|
|
1273
|
+
let body = "";
|
|
1274
|
+
try {
|
|
1275
|
+
body = fs4.readFileSync(f, "utf8");
|
|
1276
|
+
} catch {
|
|
1277
|
+
return { f, body: "", score: -1 };
|
|
1278
|
+
}
|
|
1279
|
+
const lc = `${path4.basename(f)}
|
|
1280
|
+
${body}`.toLowerCase();
|
|
1281
|
+
const score = terms.length ? terms.filter((t) => lc.includes(t)).length : 1;
|
|
1282
|
+
return { f, body, score };
|
|
1283
|
+
});
|
|
1284
|
+
const picked = (terms.length ? scored.filter((s) => s.score > 0).sort((a, b) => b.score - a.score || a.f.localeCompare(b.f)) : scored).filter((s) => s.body.trim()).slice(0, terms.length ? 8 : 5);
|
|
1285
|
+
if (!picked.length) return void 0;
|
|
1286
|
+
const text = picked.map((s) => `<!-- ${path4.relative(dir, s.f).split(path4.sep).join("/")} -->
|
|
1287
|
+
${s.body.trim()}`).join("\n\n");
|
|
1288
|
+
return {
|
|
1289
|
+
text,
|
|
1290
|
+
files: picked.map((s) => path4.relative(dir, s.f).split(path4.sep).join("/"))
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
function localPackageDocs(root, name, opts) {
|
|
1245
1294
|
const dir = npmPackageDir(root, name);
|
|
1246
1295
|
if (!dir) return void 0;
|
|
1247
1296
|
const version = resolveVersion(root, name).served;
|
|
1248
|
-
|
|
1297
|
+
let primary;
|
|
1298
|
+
for (const f of README_CANDIDATES) {
|
|
1249
1299
|
const p = path4.join(dir, f);
|
|
1250
1300
|
try {
|
|
1251
1301
|
const docs = fs4.readFileSync(p, "utf8");
|
|
1252
1302
|
if (docs.trim()) {
|
|
1253
|
-
|
|
1303
|
+
primary = { docs, source: path4.relative(root, p).split(path4.sep).join("/") };
|
|
1304
|
+
break;
|
|
1254
1305
|
}
|
|
1255
1306
|
} catch {
|
|
1256
1307
|
}
|
|
1257
1308
|
}
|
|
1309
|
+
const extra = packageDocsMarkdown(dir, opts?.query);
|
|
1310
|
+
if (primary && extra) {
|
|
1311
|
+
return {
|
|
1312
|
+
docs: `${primary.docs.trim()}
|
|
1313
|
+
|
|
1314
|
+
## Package docs
|
|
1315
|
+
|
|
1316
|
+
${extra.text}`,
|
|
1317
|
+
version,
|
|
1318
|
+
source: `${primary.source}+docs/`,
|
|
1319
|
+
readmeOnly: false
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
if (primary) {
|
|
1323
|
+
return { ...primary, version, readmeOnly: true };
|
|
1324
|
+
}
|
|
1325
|
+
if (extra) {
|
|
1326
|
+
return {
|
|
1327
|
+
docs: extra.text,
|
|
1328
|
+
version,
|
|
1329
|
+
source: path4.relative(root, path4.join(dir, "docs")).split(path4.sep).join("/") + "/",
|
|
1330
|
+
readmeOnly: false
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1258
1333
|
try {
|
|
1259
1334
|
const pkg = JSON.parse(fs4.readFileSync(path4.join(dir, "package.json"), "utf8"));
|
|
1260
1335
|
if (pkg.description?.trim()) {
|
|
@@ -1263,35 +1338,104 @@ function localPackageDocs(root, name) {
|
|
|
1263
1338
|
|
|
1264
1339
|
${pkg.description}`,
|
|
1265
1340
|
version: version ?? pkg.version,
|
|
1266
|
-
source: path4.relative(root, path4.join(dir, "package.json")).split(path4.sep).join("/")
|
|
1341
|
+
source: path4.relative(root, path4.join(dir, "package.json")).split(path4.sep).join("/"),
|
|
1342
|
+
readmeOnly: true
|
|
1267
1343
|
};
|
|
1268
1344
|
}
|
|
1269
1345
|
} catch {
|
|
1270
1346
|
}
|
|
1271
1347
|
return void 0;
|
|
1272
1348
|
}
|
|
1349
|
+
function typesFromPkg(dir, pkg) {
|
|
1350
|
+
const tryRel = (rel) => {
|
|
1351
|
+
if (typeof rel !== "string") return void 0;
|
|
1352
|
+
const p = path4.join(dir, rel);
|
|
1353
|
+
return fs4.existsSync(p) ? p : void 0;
|
|
1354
|
+
};
|
|
1355
|
+
const top = tryRel(pkg.types) ?? tryRel(pkg.typings);
|
|
1356
|
+
if (top) return top;
|
|
1357
|
+
const exp = pkg.exports;
|
|
1358
|
+
if (!exp || typeof exp !== "object") return void 0;
|
|
1359
|
+
const roots = [];
|
|
1360
|
+
if ("." in exp) roots.push(exp["."]);
|
|
1361
|
+
else roots.push(...Object.values(exp));
|
|
1362
|
+
for (const entry of roots) {
|
|
1363
|
+
if (typeof entry === "string") {
|
|
1364
|
+
const hit = tryRel(entry.endsWith(".d.ts") ? entry : void 0);
|
|
1365
|
+
if (hit) return hit;
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
if (entry && typeof entry === "object") {
|
|
1369
|
+
const o = entry;
|
|
1370
|
+
for (const key of ["types", "typings", "import", "require", "default"]) {
|
|
1371
|
+
const v = o[key];
|
|
1372
|
+
if (typeof v === "string") {
|
|
1373
|
+
const hit = tryRel(v.endsWith(".ts") || v.endsWith(".d.ts") || v.endsWith(".mts") || v.endsWith(".cts") ? v : void 0);
|
|
1374
|
+
if (hit) return hit;
|
|
1375
|
+
} else if (v && typeof v === "object" && typeof v.types === "string") {
|
|
1376
|
+
const hit = tryRel(v.types);
|
|
1377
|
+
if (hit) return hit;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return void 0;
|
|
1383
|
+
}
|
|
1273
1384
|
function dtsEntry(dir) {
|
|
1274
1385
|
try {
|
|
1275
1386
|
const pkg = JSON.parse(fs4.readFileSync(path4.join(dir, "package.json"), "utf8"));
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1278
|
-
const p = path4.join(dir, rel);
|
|
1279
|
-
if (fs4.existsSync(p)) return p;
|
|
1280
|
-
}
|
|
1387
|
+
const fromPkg = typesFromPkg(dir, pkg);
|
|
1388
|
+
if (fromPkg) return fromPkg;
|
|
1281
1389
|
} catch {
|
|
1282
1390
|
}
|
|
1283
|
-
for (const c of [
|
|
1391
|
+
for (const c of [
|
|
1392
|
+
"index.d.ts",
|
|
1393
|
+
"dist/index.d.ts",
|
|
1394
|
+
"dist/types/index.d.ts",
|
|
1395
|
+
"lib/index.d.ts",
|
|
1396
|
+
"types/index.d.ts",
|
|
1397
|
+
"build/index.d.ts"
|
|
1398
|
+
]) {
|
|
1284
1399
|
const p = path4.join(dir, c);
|
|
1285
1400
|
if (fs4.existsSync(p)) return p;
|
|
1286
1401
|
}
|
|
1287
1402
|
return void 0;
|
|
1288
1403
|
}
|
|
1404
|
+
var MAX_DTS_FILES = 30;
|
|
1405
|
+
var MAX_DTS_BYTES = 512e3;
|
|
1406
|
+
function collectDtsFiles(dir) {
|
|
1407
|
+
const out = [];
|
|
1408
|
+
const walk = (d, depth) => {
|
|
1409
|
+
if (depth > 4 || out.length >= MAX_DTS_FILES) return;
|
|
1410
|
+
let entries;
|
|
1411
|
+
try {
|
|
1412
|
+
entries = fs4.readdirSync(d, { withFileTypes: true });
|
|
1413
|
+
} catch {
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
1417
|
+
for (const e of entries) {
|
|
1418
|
+
if (out.length >= MAX_DTS_FILES) return;
|
|
1419
|
+
if (e.name === "node_modules" || e.name.startsWith(".")) continue;
|
|
1420
|
+
const full = path4.join(d, e.name);
|
|
1421
|
+
if (e.isDirectory()) walk(full, depth + 1);
|
|
1422
|
+
else if (e.isFile() && /\.d\.(ts|mts|cts)$/.test(e.name)) out.push(full);
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
walk(dir, 0);
|
|
1426
|
+
return out;
|
|
1427
|
+
}
|
|
1289
1428
|
function extractDtsApi(src, maxDecls = 200) {
|
|
1290
1429
|
const out = [];
|
|
1291
1430
|
let depth = 0;
|
|
1292
1431
|
let capture = null;
|
|
1293
1432
|
for (const raw of src.split("\n")) {
|
|
1294
1433
|
const line = raw.trim();
|
|
1434
|
+
if (capture === null && depth === 0 && /^export\s+\{[^}]+\}/.test(line)) {
|
|
1435
|
+
out.push(raw.trim());
|
|
1436
|
+
if (out.length >= maxDecls) break;
|
|
1437
|
+
continue;
|
|
1438
|
+
}
|
|
1295
1439
|
if (capture === null && depth === 0 && /^export\b/.test(line) && !/^export\s+(\{|\*|default\b|type\s+\{)/.test(line)) {
|
|
1296
1440
|
capture = [];
|
|
1297
1441
|
}
|
|
@@ -1308,19 +1452,72 @@ function extractDtsApi(src, maxDecls = 200) {
|
|
|
1308
1452
|
}
|
|
1309
1453
|
return out;
|
|
1310
1454
|
}
|
|
1311
|
-
function
|
|
1455
|
+
function reExportNames(decl) {
|
|
1456
|
+
const m = /^export\s*\{([^}]+)\}/.exec(decl.trim());
|
|
1457
|
+
if (!m) return [];
|
|
1458
|
+
const names = [];
|
|
1459
|
+
for (const part of m[1].split(",")) {
|
|
1460
|
+
const n = part.trim().split(/\s+as\s+/i).pop()?.trim();
|
|
1461
|
+
if (n && /^[A-Za-z_$][\w$]*$/.test(n)) names.push(n);
|
|
1462
|
+
}
|
|
1463
|
+
return names;
|
|
1464
|
+
}
|
|
1465
|
+
function localApiSurface(root, name, query) {
|
|
1312
1466
|
const dir = npmPackageDir(root, name);
|
|
1313
1467
|
if (!dir) return void 0;
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1468
|
+
const entry = dtsEntry(dir);
|
|
1469
|
+
const files = entry ? [entry, ...collectDtsFiles(dir).filter((f) => f !== entry)] : collectDtsFiles(dir);
|
|
1470
|
+
if (!files.length) return void 0;
|
|
1471
|
+
const allDecls = [];
|
|
1472
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1473
|
+
for (const f of files) {
|
|
1474
|
+
let src;
|
|
1475
|
+
try {
|
|
1476
|
+
const st = fs4.statSync(f);
|
|
1477
|
+
if (st.size > MAX_DTS_BYTES) continue;
|
|
1478
|
+
src = fs4.readFileSync(f, "utf8");
|
|
1479
|
+
} catch {
|
|
1480
|
+
continue;
|
|
1481
|
+
}
|
|
1482
|
+
for (const d of extractDtsApi(src)) {
|
|
1483
|
+
if (seen.has(d)) continue;
|
|
1484
|
+
seen.add(d);
|
|
1485
|
+
allDecls.push(d);
|
|
1486
|
+
if (allDecls.length >= 400) break;
|
|
1487
|
+
}
|
|
1488
|
+
if (allDecls.length >= 400) break;
|
|
1489
|
+
}
|
|
1490
|
+
if (!allDecls.length) return void 0;
|
|
1491
|
+
const terms = (query ?? "").split(/[^A-Za-z0-9_$]+/).filter((w) => w.length > 2);
|
|
1492
|
+
if (terms.length) {
|
|
1493
|
+
const lcTerms = terms.map((t) => t.toLowerCase());
|
|
1494
|
+
const matched = allDecls.filter((d) => {
|
|
1495
|
+
const lc = d.toLowerCase();
|
|
1496
|
+
return lcTerms.some((t) => lc.includes(t));
|
|
1497
|
+
});
|
|
1498
|
+
const expanded = [];
|
|
1499
|
+
const expandedSeen = /* @__PURE__ */ new Set();
|
|
1500
|
+
for (const d of matched) {
|
|
1501
|
+
const names = reExportNames(d);
|
|
1502
|
+
if (names.length) {
|
|
1503
|
+
for (const n of names) {
|
|
1504
|
+
const fuller = allDecls.find(
|
|
1505
|
+
(x) => !/^export\s*\{/.test(x) && new RegExp(`\\b${n}\\b`).test(x)
|
|
1506
|
+
);
|
|
1507
|
+
const pick = fuller ?? d;
|
|
1508
|
+
if (!expandedSeen.has(pick)) {
|
|
1509
|
+
expandedSeen.add(pick);
|
|
1510
|
+
expanded.push(pick);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
} else if (!expandedSeen.has(d)) {
|
|
1514
|
+
expandedSeen.add(d);
|
|
1515
|
+
expanded.push(d);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
if (expanded.length) return expanded.slice(0, 40).join("\n\n");
|
|
1321
1519
|
}
|
|
1322
|
-
|
|
1323
|
-
return decls.length ? decls.join("\n\n") : void 0;
|
|
1520
|
+
return allDecls.slice(0, 80).join("\n\n");
|
|
1324
1521
|
}
|
|
1325
1522
|
function cloneAndReadGit(url) {
|
|
1326
1523
|
const dir = fs4.mkdtempSync(path4.join(os.tmpdir(), "vg-lib-git-"));
|
|
@@ -1691,5 +1888,5 @@ var EdgeSet = class {
|
|
|
1691
1888
|
};
|
|
1692
1889
|
|
|
1693
1890
|
export { ECOSYSTEMS, addLibrary, applyStaticTestLinkage, buildModuleResolver, catalogPath, driftFor, edgeId, enrichOnline, inventory, isTestFile, libDir, libId, loadCatalog, localApiSurface, localPackageDocs, nodeId, parseJsonc, readDoc, relativeResolver, resolve3 as resolve, resolveLib, resolveVersion, saveCatalog };
|
|
1694
|
-
//# sourceMappingURL=chunk-
|
|
1695
|
-
//# sourceMappingURL=chunk-
|
|
1891
|
+
//# sourceMappingURL=chunk-6AXHLQBV.js.map
|
|
1892
|
+
//# sourceMappingURL=chunk-6AXHLQBV.js.map
|