@dreamtree-org/graphify 1.1.3 → 1.3.0
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/README.md +18 -2
- package/dist/{chunk-ZK3TA6FW.js → chunk-K322XB4U.js} +45 -7
- package/dist/{chunk-ZK3TA6FW.js.map → chunk-K322XB4U.js.map} +1 -1
- package/dist/{chunk-NS5HB65S.js → chunk-UBXYMMXJ.js} +9 -4
- package/dist/{chunk-NS5HB65S.js.map → chunk-UBXYMMXJ.js.map} +1 -1
- package/dist/cli/index.cjs +135 -23
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +65 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +67 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -4
- package/dist/index.d.ts +58 -4
- package/dist/index.js +8 -2
- package/dist/mcp/server.cjs +43 -6
- package/dist/mcp/server.cjs.map +1 -1
- package/dist/mcp/server.js +1 -1
- package/package.json +1 -1
- package/src/skill/SKILL.md +9 -4
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
ExtractionCache: () => ExtractionCache,
|
|
35
35
|
ExtractionResultSchema: () => ExtractionResultSchema,
|
|
36
36
|
ExtractionValidationError: () => ExtractionValidationError,
|
|
37
|
+
LocalFileGraphStore: () => LocalFileGraphStore,
|
|
37
38
|
affectedBy: () => affectedBy,
|
|
38
39
|
analyze: () => analyze,
|
|
39
40
|
buildContextPack: () => buildContextPack,
|
|
@@ -41,6 +42,7 @@ __export(index_exports, {
|
|
|
41
42
|
checkRules: () => checkRules,
|
|
42
43
|
cluster: () => cluster,
|
|
43
44
|
collectFiles: () => collectFiles,
|
|
45
|
+
deserializeGraph: () => deserializeGraph,
|
|
44
46
|
diffGraphs: () => diffGraphs,
|
|
45
47
|
explainNode: () => explainNode,
|
|
46
48
|
exportGraph: () => exportGraph,
|
|
@@ -64,6 +66,7 @@ __export(index_exports, {
|
|
|
64
66
|
runPipeline: () => runPipeline,
|
|
65
67
|
saveResult: () => saveResult,
|
|
66
68
|
scoreNodes: () => scoreNodes,
|
|
69
|
+
serializeGraph: () => serializeGraph,
|
|
67
70
|
shortestPath: () => shortestPath,
|
|
68
71
|
testsForChangedFiles: () => testsForChangedFiles,
|
|
69
72
|
testsForNode: () => testsForNode,
|
|
@@ -2570,7 +2573,7 @@ function renderReport(graph, analysis, now = /* @__PURE__ */ new Date()) {
|
|
|
2570
2573
|
|
|
2571
2574
|
// src/export.ts
|
|
2572
2575
|
var import_node_module2 = require("module");
|
|
2573
|
-
var
|
|
2576
|
+
var fs12 = __toESM(require("fs/promises"), 1);
|
|
2574
2577
|
var path6 = __toESM(require("path"), 1);
|
|
2575
2578
|
|
|
2576
2579
|
// src/security.ts
|
|
@@ -2645,6 +2648,44 @@ function escapeHtml(text) {
|
|
|
2645
2648
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2646
2649
|
}
|
|
2647
2650
|
|
|
2651
|
+
// src/store/localFile.ts
|
|
2652
|
+
var fs11 = __toESM(require("fs/promises"), 1);
|
|
2653
|
+
|
|
2654
|
+
// src/store/serialize.ts
|
|
2655
|
+
var import_graphology3 = __toESM(require("graphology"), 1);
|
|
2656
|
+
function serializeGraph(graph) {
|
|
2657
|
+
return graph.export();
|
|
2658
|
+
}
|
|
2659
|
+
function deserializeGraph(data) {
|
|
2660
|
+
return import_graphology3.default.from(data);
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
// src/store/localFile.ts
|
|
2664
|
+
var LocalFileGraphStore = class {
|
|
2665
|
+
async load(ref) {
|
|
2666
|
+
let jsonPath;
|
|
2667
|
+
try {
|
|
2668
|
+
jsonPath = validateGraphPath("graph.json", ref);
|
|
2669
|
+
} catch (error) {
|
|
2670
|
+
if (error.message.startsWith("Base directory does not exist")) return null;
|
|
2671
|
+
throw error;
|
|
2672
|
+
}
|
|
2673
|
+
let raw;
|
|
2674
|
+
try {
|
|
2675
|
+
raw = await fs11.readFile(jsonPath, "utf-8");
|
|
2676
|
+
} catch (error) {
|
|
2677
|
+
if (error.code === "ENOENT") return null;
|
|
2678
|
+
throw error;
|
|
2679
|
+
}
|
|
2680
|
+
return deserializeGraph(JSON.parse(raw));
|
|
2681
|
+
}
|
|
2682
|
+
async save(ref, graph) {
|
|
2683
|
+
await fs11.mkdir(ref, { recursive: true });
|
|
2684
|
+
const jsonPath = validateGraphPath("graph.json", ref);
|
|
2685
|
+
await fs11.writeFile(jsonPath, JSON.stringify(serializeGraph(graph), null, 2), "utf-8");
|
|
2686
|
+
}
|
|
2687
|
+
};
|
|
2688
|
+
|
|
2648
2689
|
// src/export.ts
|
|
2649
2690
|
var require3 = (0, import_node_module2.createRequire)(importMetaUrl);
|
|
2650
2691
|
function resolveVisNetworkAssets() {
|
|
@@ -2711,8 +2752,8 @@ community: ${communityLabel}` : ""}`,
|
|
|
2711
2752
|
async function renderHtml(graph) {
|
|
2712
2753
|
const { jsPath, cssPath } = resolveVisNetworkAssets();
|
|
2713
2754
|
const [visJs, visCss] = await Promise.all([
|
|
2714
|
-
|
|
2715
|
-
|
|
2755
|
+
fs12.readFile(jsPath, "utf-8"),
|
|
2756
|
+
fs12.readFile(cssPath, "utf-8")
|
|
2716
2757
|
]);
|
|
2717
2758
|
const { nodes, edges } = buildVisNodesAndEdges(graph);
|
|
2718
2759
|
const dataJson = safeInlineJson({ nodes, edges });
|
|
@@ -2753,16 +2794,15 @@ ${visJs}
|
|
|
2753
2794
|
}
|
|
2754
2795
|
async function exportGraph(graph, options, report) {
|
|
2755
2796
|
const outDir = path6.resolve(options.outDir);
|
|
2756
|
-
await
|
|
2757
|
-
|
|
2758
|
-
await fs11.writeFile(jsonPath, JSON.stringify(graph.toJSON(), null, 2), "utf-8");
|
|
2797
|
+
await fs12.mkdir(outDir, { recursive: true });
|
|
2798
|
+
await new LocalFileGraphStore().save(outDir, graph);
|
|
2759
2799
|
if (options.html !== false) {
|
|
2760
2800
|
const htmlPath = validateGraphPath("graph.html", outDir);
|
|
2761
|
-
await
|
|
2801
|
+
await fs12.writeFile(htmlPath, await renderHtml(graph), "utf-8");
|
|
2762
2802
|
}
|
|
2763
2803
|
if (report !== void 0) {
|
|
2764
2804
|
const reportPath = validateGraphPath("GRAPH_REPORT.md", outDir);
|
|
2765
|
-
await
|
|
2805
|
+
await fs12.writeFile(reportPath, report, "utf-8");
|
|
2766
2806
|
}
|
|
2767
2807
|
const notImplemented = [];
|
|
2768
2808
|
if (options.svg) notImplemented.push("--svg");
|
|
@@ -2775,12 +2815,12 @@ async function exportGraph(graph, options, report) {
|
|
|
2775
2815
|
}
|
|
2776
2816
|
|
|
2777
2817
|
// src/pipeline.ts
|
|
2778
|
-
var
|
|
2818
|
+
var fs14 = __toESM(require("fs/promises"), 1);
|
|
2779
2819
|
var path8 = __toESM(require("path"), 1);
|
|
2780
2820
|
|
|
2781
2821
|
// src/extractionCache.ts
|
|
2782
2822
|
var import_node_crypto3 = require("crypto");
|
|
2783
|
-
var
|
|
2823
|
+
var fs13 = __toESM(require("fs/promises"), 1);
|
|
2784
2824
|
var path7 = __toESM(require("path"), 1);
|
|
2785
2825
|
var ExtractionCache = class {
|
|
2786
2826
|
dir;
|
|
@@ -2792,7 +2832,7 @@ var ExtractionCache = class {
|
|
|
2792
2832
|
}
|
|
2793
2833
|
async get(key) {
|
|
2794
2834
|
try {
|
|
2795
|
-
const raw = await
|
|
2835
|
+
const raw = await fs13.readFile(path7.join(this.dir, `${key}.json`), "utf-8");
|
|
2796
2836
|
const parsed = JSON.parse(raw);
|
|
2797
2837
|
if (!Array.isArray(parsed.nodes) || !Array.isArray(parsed.edges)) return null;
|
|
2798
2838
|
return parsed;
|
|
@@ -2801,8 +2841,8 @@ var ExtractionCache = class {
|
|
|
2801
2841
|
}
|
|
2802
2842
|
}
|
|
2803
2843
|
async put(key, extraction) {
|
|
2804
|
-
await
|
|
2805
|
-
await
|
|
2844
|
+
await fs13.mkdir(this.dir, { recursive: true });
|
|
2845
|
+
await fs13.writeFile(path7.join(this.dir, `${key}.json`), JSON.stringify(extraction), "utf-8");
|
|
2806
2846
|
}
|
|
2807
2847
|
};
|
|
2808
2848
|
|
|
@@ -2824,7 +2864,7 @@ async function runPipeline(root, options = {}) {
|
|
|
2824
2864
|
for (const relFile of manifest.files.code.sort((a, b) => a.localeCompare(b))) {
|
|
2825
2865
|
const filePath = path8.relative(process.cwd(), path8.join(resolvedRoot, relFile)) || relFile;
|
|
2826
2866
|
try {
|
|
2827
|
-
const key = cache.key(relFile, await
|
|
2867
|
+
const key = cache.key(relFile, await fs14.readFile(path8.join(resolvedRoot, relFile)));
|
|
2828
2868
|
let extraction = options.update ? await cache.get(key) : null;
|
|
2829
2869
|
if (extraction) {
|
|
2830
2870
|
cacheHits++;
|
|
@@ -2874,19 +2914,23 @@ async function runPipeline(root, options = {}) {
|
|
|
2874
2914
|
},
|
|
2875
2915
|
report
|
|
2876
2916
|
);
|
|
2917
|
+
if (options.store) {
|
|
2918
|
+
const storeRef = options.storeRef ?? outDir;
|
|
2919
|
+
progress(`Saving graph to store (${storeRef}) ...`);
|
|
2920
|
+
await options.store.save(storeRef, graph);
|
|
2921
|
+
}
|
|
2877
2922
|
progress("Done.");
|
|
2878
2923
|
return { manifest, graph, analysis, report };
|
|
2879
2924
|
}
|
|
2880
2925
|
|
|
2881
2926
|
// src/graphStore.ts
|
|
2882
|
-
var fs14 = __toESM(require("fs/promises"), 1);
|
|
2883
2927
|
var path9 = __toESM(require("path"), 1);
|
|
2884
|
-
var import_graphology3 = __toESM(require("graphology"), 1);
|
|
2885
2928
|
async function loadGraph(outDir = path9.join(process.cwd(), "graphify-out")) {
|
|
2886
|
-
const
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2929
|
+
const graph = await new LocalFileGraphStore().load(outDir);
|
|
2930
|
+
if (graph === null) {
|
|
2931
|
+
throw new Error(`No graph found in ${outDir} \u2014 run \`graphify <path>\` to build one first.`);
|
|
2932
|
+
}
|
|
2933
|
+
return graph;
|
|
2890
2934
|
}
|
|
2891
2935
|
|
|
2892
2936
|
// src/query.ts
|
|
@@ -3951,6 +3995,7 @@ function checkRules(graph, config) {
|
|
|
3951
3995
|
ExtractionCache,
|
|
3952
3996
|
ExtractionResultSchema,
|
|
3953
3997
|
ExtractionValidationError,
|
|
3998
|
+
LocalFileGraphStore,
|
|
3954
3999
|
affectedBy,
|
|
3955
4000
|
analyze,
|
|
3956
4001
|
buildContextPack,
|
|
@@ -3958,6 +4003,7 @@ function checkRules(graph, config) {
|
|
|
3958
4003
|
checkRules,
|
|
3959
4004
|
cluster,
|
|
3960
4005
|
collectFiles,
|
|
4006
|
+
deserializeGraph,
|
|
3961
4007
|
diffGraphs,
|
|
3962
4008
|
explainNode,
|
|
3963
4009
|
exportGraph,
|
|
@@ -3981,6 +4027,7 @@ function checkRules(graph, config) {
|
|
|
3981
4027
|
runPipeline,
|
|
3982
4028
|
saveResult,
|
|
3983
4029
|
scoreNodes,
|
|
4030
|
+
serializeGraph,
|
|
3984
4031
|
shortestPath,
|
|
3985
4032
|
testsForChangedFiles,
|
|
3986
4033
|
testsForNode,
|