@swarmvaultai/engine 0.7.26 → 0.7.27
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/index.js +111 -10
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -493,7 +493,9 @@ async function autoCommitWikiChanges(rootDir, operation, detail, options) {
|
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
// src/graph-export.ts
|
|
496
|
+
import { readFileSync } from "fs";
|
|
496
497
|
import fs2 from "fs/promises";
|
|
498
|
+
import { createRequire } from "module";
|
|
497
499
|
import path2 from "path";
|
|
498
500
|
import matter from "gray-matter";
|
|
499
501
|
|
|
@@ -941,6 +943,15 @@ document.getElementById("page-filter").addEventListener("input", function(e) {
|
|
|
941
943
|
}
|
|
942
944
|
|
|
943
945
|
// src/graph-export.ts
|
|
946
|
+
var _visNetworkJs;
|
|
947
|
+
function loadVisNetworkJs() {
|
|
948
|
+
if (!_visNetworkJs) {
|
|
949
|
+
const require3 = createRequire(import.meta.url);
|
|
950
|
+
const pkgDir = path2.dirname(require3.resolve("vis-network/package.json"));
|
|
951
|
+
_visNetworkJs = readFileSync(path2.join(pkgDir, "standalone/umd/vis-network.min.js"), "utf8");
|
|
952
|
+
}
|
|
953
|
+
return _visNetworkJs;
|
|
954
|
+
}
|
|
944
955
|
var NODE_COLORS = {
|
|
945
956
|
source: "#f59e0b",
|
|
946
957
|
module: "#fb7185",
|
|
@@ -1341,7 +1352,7 @@ function renderHtmlStandalone(graph) {
|
|
|
1341
1352
|
<head>
|
|
1342
1353
|
<meta charset="utf-8">
|
|
1343
1354
|
<title>SwarmVault Graph</title>
|
|
1344
|
-
<script
|
|
1355
|
+
<script>${loadVisNetworkJs()}</script>
|
|
1345
1356
|
<style>
|
|
1346
1357
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
1347
1358
|
body { font-family: system-ui, sans-serif; display: flex; height: 100vh; background: #0f172a; color: #e2e8f0; }
|
|
@@ -2998,9 +3009,9 @@ import YAML2 from "yaml";
|
|
|
2998
3009
|
|
|
2999
3010
|
// src/code-tree-sitter.ts
|
|
3000
3011
|
import fs5 from "fs/promises";
|
|
3001
|
-
import { createRequire } from "module";
|
|
3012
|
+
import { createRequire as createRequire2 } from "module";
|
|
3002
3013
|
import path5 from "path";
|
|
3003
|
-
var require2 =
|
|
3014
|
+
var require2 = createRequire2(import.meta.url);
|
|
3004
3015
|
var TREE_SITTER_RUNTIME_PACKAGE = "@vscode/tree-sitter-wasm";
|
|
3005
3016
|
var TREE_SITTER_EXTRA_GRAMMARS_PACKAGE = "tree-sitter-wasms";
|
|
3006
3017
|
var SWIFT_TREE_SITTER_OPT_IN_ENV = "SWARMVAULT_ENABLE_SWIFT_TREE_SITTER";
|
|
@@ -3127,8 +3138,8 @@ function singleLineSignature(value) {
|
|
|
3127
3138
|
180
|
|
3128
3139
|
);
|
|
3129
3140
|
}
|
|
3130
|
-
function makeSymbolId(sourceId, name, seen) {
|
|
3131
|
-
const base = slugify(name)
|
|
3141
|
+
function makeSymbolId(sourceId, name, kind, seen) {
|
|
3142
|
+
const base = `${slugify(name)}.${kind}`;
|
|
3132
3143
|
const count = (seen.get(base) ?? 0) + 1;
|
|
3133
3144
|
seen.set(base, count);
|
|
3134
3145
|
return `symbol:${sourceId}:${count === 1 ? base : `${base}-${count}`}`;
|
|
@@ -3210,7 +3221,7 @@ function finalizeCodeAnalysis(manifest, language, imports, draftSymbols, exportL
|
|
|
3210
3221
|
}
|
|
3211
3222
|
const seenSymbolIds = /* @__PURE__ */ new Map();
|
|
3212
3223
|
const symbols = draftSymbols.map((symbol) => ({
|
|
3213
|
-
id: makeSymbolId(manifest.sourceId, symbol.name, seenSymbolIds),
|
|
3224
|
+
id: makeSymbolId(manifest.sourceId, symbol.name, symbol.kind, seenSymbolIds),
|
|
3214
3225
|
name: symbol.name,
|
|
3215
3226
|
kind: symbol.kind,
|
|
3216
3227
|
signature: symbol.signature,
|
|
@@ -7019,8 +7030,8 @@ function isNodeExported(node) {
|
|
|
7019
7030
|
)
|
|
7020
7031
|
);
|
|
7021
7032
|
}
|
|
7022
|
-
function makeSymbolId2(scope, name, seen) {
|
|
7023
|
-
const base = slugify(name)
|
|
7033
|
+
function makeSymbolId2(scope, name, kind, seen) {
|
|
7034
|
+
const base = `${slugify(name)}.${kind}`;
|
|
7024
7035
|
const count = (seen.get(base) ?? 0) + 1;
|
|
7025
7036
|
seen.set(base, count);
|
|
7026
7037
|
return `symbol:${scope}:${count === 1 ? base : `${base}-${count}`}`;
|
|
@@ -7187,7 +7198,7 @@ function finalizeCodeAnalysis2(manifest, language, imports, draftSymbols, export
|
|
|
7187
7198
|
const seenSymbolIds = /* @__PURE__ */ new Map();
|
|
7188
7199
|
const symbolScope = metadata?.namespace ? `ns:${slugify(metadata.namespace)}` : manifest.sourceId;
|
|
7189
7200
|
const symbols = draftSymbols.map((symbol) => ({
|
|
7190
|
-
id: makeSymbolId2(symbolScope, symbol.name, seenSymbolIds),
|
|
7201
|
+
id: makeSymbolId2(symbolScope, symbol.name, symbol.kind, seenSymbolIds),
|
|
7191
7202
|
name: symbol.name,
|
|
7192
7203
|
kind: symbol.kind,
|
|
7193
7204
|
signature: symbol.signature,
|
|
@@ -7601,6 +7612,81 @@ function manifestBasenameWithoutExtension(manifest) {
|
|
|
7601
7612
|
const target = manifest.repoRelativePath ?? manifest.originalPath ?? manifest.storedPath;
|
|
7602
7613
|
return path6.posix.basename(stripCodeExtension2(normalizeAlias(target)));
|
|
7603
7614
|
}
|
|
7615
|
+
async function readNearestTsconfigPaths(startPath, cache) {
|
|
7616
|
+
let current = path6.resolve(startPath);
|
|
7617
|
+
try {
|
|
7618
|
+
const stat = await fs6.stat(current);
|
|
7619
|
+
if (!stat.isDirectory()) {
|
|
7620
|
+
current = path6.dirname(current);
|
|
7621
|
+
}
|
|
7622
|
+
} catch {
|
|
7623
|
+
current = path6.dirname(current);
|
|
7624
|
+
}
|
|
7625
|
+
while (true) {
|
|
7626
|
+
if (cache.has(current)) {
|
|
7627
|
+
const cached = cache.get(current);
|
|
7628
|
+
return cached === null ? void 0 : cached;
|
|
7629
|
+
}
|
|
7630
|
+
const tsconfigPath = path6.join(current, "tsconfig.json");
|
|
7631
|
+
const exists = await fs6.access(tsconfigPath).then(() => true).catch(() => false);
|
|
7632
|
+
if (exists) {
|
|
7633
|
+
const configFile = ts.readConfigFile(tsconfigPath, (p) => ts.sys.readFile(p));
|
|
7634
|
+
if (!configFile.error && configFile.config) {
|
|
7635
|
+
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, current);
|
|
7636
|
+
const rawPaths = parsed.options.paths;
|
|
7637
|
+
if (rawPaths && Object.keys(rawPaths).length > 0) {
|
|
7638
|
+
const baseUrl = parsed.options.baseUrl ? toPosix(path6.relative(current, parsed.options.baseUrl)) : ".";
|
|
7639
|
+
const config = { baseUrl, paths: rawPaths };
|
|
7640
|
+
cache.set(current, config);
|
|
7641
|
+
return config;
|
|
7642
|
+
}
|
|
7643
|
+
}
|
|
7644
|
+
cache.set(current, null);
|
|
7645
|
+
return void 0;
|
|
7646
|
+
}
|
|
7647
|
+
const parent = path6.dirname(current);
|
|
7648
|
+
if (parent === current) {
|
|
7649
|
+
cache.set(current, null);
|
|
7650
|
+
return void 0;
|
|
7651
|
+
}
|
|
7652
|
+
current = parent;
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
function tsconfigPathAliasesForFile(repoRelativePath, config) {
|
|
7656
|
+
const aliases = [];
|
|
7657
|
+
const stripped = stripCodeExtension2(normalizeAlias(repoRelativePath));
|
|
7658
|
+
const indexStripped = stripped.endsWith("/index") ? stripped.slice(0, -"/index".length) : void 0;
|
|
7659
|
+
for (const [pattern, targets] of Object.entries(config.paths)) {
|
|
7660
|
+
for (const target of targets) {
|
|
7661
|
+
if (pattern.includes("*") && target.includes("*")) {
|
|
7662
|
+
const targetPrefix = normalizeAlias(
|
|
7663
|
+
config.baseUrl === "." ? target.replace("*", "") : path6.posix.join(config.baseUrl, target.replace("*", ""))
|
|
7664
|
+
);
|
|
7665
|
+
const patternBase = pattern.replace("*", "");
|
|
7666
|
+
for (const candidate of [stripped, indexStripped]) {
|
|
7667
|
+
if (candidate && candidate.startsWith(targetPrefix)) {
|
|
7668
|
+
aliases.push(patternBase + candidate.slice(targetPrefix.length));
|
|
7669
|
+
}
|
|
7670
|
+
}
|
|
7671
|
+
} else if (!pattern.includes("*") && !target.includes("*")) {
|
|
7672
|
+
const targetNorm = normalizeAlias(config.baseUrl === "." ? target : path6.posix.join(config.baseUrl, target));
|
|
7673
|
+
if (stripped === stripCodeExtension2(targetNorm) || indexStripped === stripCodeExtension2(targetNorm)) {
|
|
7674
|
+
aliases.push(pattern);
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
}
|
|
7679
|
+
if (config.baseUrl !== ".") {
|
|
7680
|
+
const basePrefix = normalizeAlias(config.baseUrl) + "/";
|
|
7681
|
+
if (stripped.startsWith(basePrefix)) {
|
|
7682
|
+
aliases.push(stripped.slice(basePrefix.length));
|
|
7683
|
+
}
|
|
7684
|
+
if (indexStripped && indexStripped.startsWith(basePrefix)) {
|
|
7685
|
+
aliases.push(indexStripped.slice(basePrefix.length));
|
|
7686
|
+
}
|
|
7687
|
+
}
|
|
7688
|
+
return aliases;
|
|
7689
|
+
}
|
|
7604
7690
|
async function readNearestDartPackageInfo(startPath, cache) {
|
|
7605
7691
|
let current = path6.resolve(startPath);
|
|
7606
7692
|
try {
|
|
@@ -7763,6 +7849,7 @@ async function buildCodeIndex(rootDir, manifests, analyses) {
|
|
|
7763
7849
|
const analysesBySourceId = new Map(analyses.map((analysis) => [analysis.sourceId, analysis]));
|
|
7764
7850
|
const goModuleCache = /* @__PURE__ */ new Map();
|
|
7765
7851
|
const dartPackageCache = /* @__PURE__ */ new Map();
|
|
7852
|
+
const tsconfigCache = /* @__PURE__ */ new Map();
|
|
7766
7853
|
const entries = [];
|
|
7767
7854
|
for (const manifest of manifests) {
|
|
7768
7855
|
const analysis = analysesBySourceId.get(manifest.sourceId);
|
|
@@ -7784,6 +7871,20 @@ async function buildCodeIndex(rootDir, manifests, analyses) {
|
|
|
7784
7871
|
recordAlias(aliases, normalizedModuleName);
|
|
7785
7872
|
recordAlias(aliases, normalizedNamespace);
|
|
7786
7873
|
switch (analysis.code.language) {
|
|
7874
|
+
case "javascript":
|
|
7875
|
+
case "jsx":
|
|
7876
|
+
case "typescript":
|
|
7877
|
+
case "tsx": {
|
|
7878
|
+
if (repoRelativePath && manifest.originalPath) {
|
|
7879
|
+
const tsconfigPaths = await readNearestTsconfigPaths(manifest.originalPath, tsconfigCache);
|
|
7880
|
+
if (tsconfigPaths) {
|
|
7881
|
+
for (const alias of tsconfigPathAliasesForFile(repoRelativePath, tsconfigPaths)) {
|
|
7882
|
+
recordAlias(aliases, alias);
|
|
7883
|
+
}
|
|
7884
|
+
}
|
|
7885
|
+
}
|
|
7886
|
+
break;
|
|
7887
|
+
}
|
|
7787
7888
|
case "python":
|
|
7788
7889
|
recordAlias(aliases, normalizedModuleName?.replace(/\//g, "."));
|
|
7789
7890
|
break;
|
|
@@ -22194,7 +22295,7 @@ async function bootstrapDemo(rootDir, input) {
|
|
|
22194
22295
|
}
|
|
22195
22296
|
|
|
22196
22297
|
// src/mcp.ts
|
|
22197
|
-
var SERVER_VERSION = "0.7.
|
|
22298
|
+
var SERVER_VERSION = "0.7.27";
|
|
22198
22299
|
async function createMcpServer(rootDir) {
|
|
22199
22300
|
const server = new McpServer({
|
|
22200
22301
|
name: "swarmvault",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swarmvaultai/engine",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.27",
|
|
4
4
|
"description": "Core engine for SwarmVault: ingest, compile, query, lint, and provider abstractions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"tree-sitter-wasms": "^0.1.13",
|
|
73
73
|
"turndown": "^7.2.1",
|
|
74
74
|
"typescript": "^5.9.3",
|
|
75
|
+
"vis-network": "^10.0.2",
|
|
75
76
|
"xlsx": "^0.18.5",
|
|
76
77
|
"yaml": "^2.8.1",
|
|
77
78
|
"youtube-transcript-plus": "^2.0.0",
|