@kopikocappu/mycelium 0.2.1 → 0.2.2
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/cli.js +24 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -15727,9 +15727,10 @@ var CbmAdapter = class {
|
|
|
15727
15727
|
}
|
|
15728
15728
|
/** Run cbm index on a project */
|
|
15729
15729
|
async index(repoPath) {
|
|
15730
|
+
const fwdPath = import_path2.default.resolve(repoPath).replace(/\\/g, "/");
|
|
15730
15731
|
const result = (0, import_child_process.spawnSync)(
|
|
15731
15732
|
this.cbmBin,
|
|
15732
|
-
["cli", "index_repository", JSON.stringify({ repo_path:
|
|
15733
|
+
["cli", "index_repository", JSON.stringify({ repo_path: fwdPath })],
|
|
15733
15734
|
{ timeout: 3e5, stdio: "pipe", encoding: "utf-8" }
|
|
15734
15735
|
);
|
|
15735
15736
|
if (result.status !== 0) {
|
|
@@ -15739,18 +15740,19 @@ var CbmAdapter = class {
|
|
|
15739
15740
|
/** Pull the full graph from cbm and convert to Mycelium format */
|
|
15740
15741
|
async getGraph(repoPath) {
|
|
15741
15742
|
const absPath = import_path2.default.resolve(repoPath);
|
|
15743
|
+
const slug = this.slugifyPath(absPath);
|
|
15742
15744
|
const fnResult = this.runCbmCli("search_graph", {
|
|
15743
15745
|
label: "Function",
|
|
15744
|
-
project:
|
|
15746
|
+
project: slug,
|
|
15745
15747
|
limit: 1e4
|
|
15746
15748
|
});
|
|
15747
15749
|
const fileResult = this.runCbmCli("search_graph", {
|
|
15748
15750
|
label: "File",
|
|
15749
|
-
project:
|
|
15751
|
+
project: slug,
|
|
15750
15752
|
limit: 1e4
|
|
15751
15753
|
});
|
|
15752
15754
|
const archResult = this.runCbmCli("get_architecture", {
|
|
15753
|
-
repo_path: absPath
|
|
15755
|
+
repo_path: absPath.replace(/\\/g, "/")
|
|
15754
15756
|
});
|
|
15755
15757
|
const fnNodes = fnResult?.results ?? [];
|
|
15756
15758
|
const fileNodes = fileResult?.results ?? [];
|
|
@@ -15815,15 +15817,29 @@ var CbmAdapter = class {
|
|
|
15815
15817
|
}));
|
|
15816
15818
|
}
|
|
15817
15819
|
// ─── Private helpers ────────────────────────────────────────────────────────
|
|
15820
|
+
/**
|
|
15821
|
+
* cbm stores projects as slugified absolute paths.
|
|
15822
|
+
* e.g. C:\Users\Minh Tran\Desktop\pakky → C-Users-Minh-Tran-Desktop-pakky
|
|
15823
|
+
* This is what the 'project' field expects in search_graph, trace_path, etc.
|
|
15824
|
+
*/
|
|
15825
|
+
slugifyPath(absPath) {
|
|
15826
|
+
return absPath.replace(/\\/g, "-").replace(/\//g, "-").replace(/:/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
15827
|
+
}
|
|
15818
15828
|
runCbmCli(tool, args) {
|
|
15819
15829
|
try {
|
|
15830
|
+
const normalizedArgs = {};
|
|
15831
|
+
for (const [k, v] of Object.entries(args)) {
|
|
15832
|
+
normalizedArgs[k] = typeof v === "string" ? v.replace(/\\/g, "/") : v;
|
|
15833
|
+
}
|
|
15820
15834
|
const result = (0, import_child_process.spawnSync)(
|
|
15821
15835
|
this.cbmBin,
|
|
15822
|
-
["cli", tool, JSON.stringify(
|
|
15836
|
+
["cli", tool, JSON.stringify(normalizedArgs)],
|
|
15823
15837
|
{ timeout: 3e4, stdio: "pipe", encoding: "utf-8" }
|
|
15824
15838
|
);
|
|
15825
|
-
if (
|
|
15826
|
-
|
|
15839
|
+
if (!result.stdout?.trim()) return null;
|
|
15840
|
+
const parsed = JSON.parse(result.stdout.trim());
|
|
15841
|
+
if (parsed?.error) return null;
|
|
15842
|
+
return parsed;
|
|
15827
15843
|
} catch {
|
|
15828
15844
|
return null;
|
|
15829
15845
|
}
|
|
@@ -15869,7 +15885,7 @@ var CbmAdapter = class {
|
|
|
15869
15885
|
for (const fn of sample) {
|
|
15870
15886
|
const result = this.runCbmCli("trace_path", {
|
|
15871
15887
|
function_name: fn.qualified_name ?? fn.name,
|
|
15872
|
-
project: import_path2.default.resolve(repoPath),
|
|
15888
|
+
project: this.slugifyPath(import_path2.default.resolve(repoPath)),
|
|
15873
15889
|
direction: "outbound",
|
|
15874
15890
|
depth: 1
|
|
15875
15891
|
});
|
package/package.json
CHANGED