@dreamtree-org/graphify 1.1.1 → 1.1.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/README.md +6 -2
- package/dist/{chunk-EW23BLJC.js → chunk-PXVI2L45.js} +89 -44
- package/dist/chunk-PXVI2L45.js.map +1 -0
- package/dist/cli/index.cjs +248 -195
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +15 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +108 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-EW23BLJC.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1603,10 +1603,10 @@ async function extractRust(filePath, displayPath) {
|
|
|
1603
1603
|
}
|
|
1604
1604
|
}
|
|
1605
1605
|
} else if (fn.type === "scoped_identifier") {
|
|
1606
|
-
const
|
|
1606
|
+
const path12 = fn.childForFieldName("path")?.text;
|
|
1607
1607
|
const name = fn.childForFieldName("name")?.text;
|
|
1608
|
-
if (
|
|
1609
|
-
const viaImport = importIndex.get(
|
|
1608
|
+
if (path12 && name) {
|
|
1609
|
+
const viaImport = importIndex.get(path12);
|
|
1610
1610
|
if (viaImport) {
|
|
1611
1611
|
targetId = viaImport.id;
|
|
1612
1612
|
confidence = "INFERRED";
|
|
@@ -2087,6 +2087,8 @@ function buildGraph(extractions) {
|
|
|
2087
2087
|
}
|
|
2088
2088
|
|
|
2089
2089
|
// src/resolve.ts
|
|
2090
|
+
var fs9 = __toESM(require("fs/promises"), 1);
|
|
2091
|
+
var path5 = __toESM(require("path"), 1);
|
|
2090
2092
|
var CODE_EXTENSIONS2 = [
|
|
2091
2093
|
".ts",
|
|
2092
2094
|
".tsx",
|
|
@@ -2106,6 +2108,29 @@ var CODE_EXTENSIONS2 = [
|
|
|
2106
2108
|
function isOpaque(id) {
|
|
2107
2109
|
return id.startsWith("module:") || id.startsWith("external:") || id.startsWith("db:");
|
|
2108
2110
|
}
|
|
2111
|
+
var SELF_IMPORT_STEMS = (subpath) => subpath === "" ? ["index", "src/index", "lib/index", "source/index", "src/main"] : [
|
|
2112
|
+
subpath,
|
|
2113
|
+
`src/${subpath}`,
|
|
2114
|
+
`lib/${subpath}`,
|
|
2115
|
+
`source/${subpath}`,
|
|
2116
|
+
`${subpath}/index`,
|
|
2117
|
+
`src/${subpath}/index`,
|
|
2118
|
+
`lib/${subpath}/index`
|
|
2119
|
+
];
|
|
2120
|
+
function selfImportCandidates(spec, selfNames) {
|
|
2121
|
+
const selfName = selfNames.find((n) => spec === n || spec.startsWith(`${n}/`));
|
|
2122
|
+
if (selfName === void 0) return null;
|
|
2123
|
+
const subpath = spec === selfName ? "" : spec.slice(selfName.length + 1);
|
|
2124
|
+
return SELF_IMPORT_STEMS(subpath).flatMap((stem) => CODE_EXTENSIONS2.map((ext) => `${stem}${ext}`));
|
|
2125
|
+
}
|
|
2126
|
+
async function readSelfNames(root) {
|
|
2127
|
+
try {
|
|
2128
|
+
const pkg = JSON.parse(await fs9.readFile(path5.join(root, "package.json"), "utf-8"));
|
|
2129
|
+
return typeof pkg.name === "string" && pkg.name.length > 0 ? [pkg.name] : [];
|
|
2130
|
+
} catch {
|
|
2131
|
+
return [];
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2109
2134
|
function stripKnownExtension(p) {
|
|
2110
2135
|
for (const ext of CODE_EXTENSIONS2) {
|
|
2111
2136
|
if (p.endsWith(ext)) return p.slice(0, -ext.length);
|
|
@@ -2130,11 +2155,16 @@ function uniqueMatch(guessed, candidates, realIds) {
|
|
|
2130
2155
|
if (matches.size !== 1) return null;
|
|
2131
2156
|
return [...matches][0];
|
|
2132
2157
|
}
|
|
2133
|
-
function resolveCrossFileReferences(extractions) {
|
|
2158
|
+
function resolveCrossFileReferences(extractions, options = {}) {
|
|
2159
|
+
const selfNames = options.selfNames ?? [];
|
|
2134
2160
|
const realIds = /* @__PURE__ */ new Set();
|
|
2135
2161
|
const realFiles = /* @__PURE__ */ new Set();
|
|
2136
2162
|
for (const extraction of extractions) {
|
|
2137
2163
|
for (const node of extraction.nodes) realIds.add(node.id);
|
|
2164
|
+
const first = extraction.nodes[0];
|
|
2165
|
+
if (first && first.id === first.sourceFile && !isOpaque(first.id)) {
|
|
2166
|
+
realFiles.add(first.id);
|
|
2167
|
+
}
|
|
2138
2168
|
for (const node of extraction.nodes) {
|
|
2139
2169
|
const sep3 = node.id.indexOf("::");
|
|
2140
2170
|
if (sep3 > 0) realFiles.add(node.id.slice(0, sep3));
|
|
@@ -2145,6 +2175,19 @@ function resolveCrossFileReferences(extractions) {
|
|
|
2145
2175
|
}
|
|
2146
2176
|
const remap = /* @__PURE__ */ new Map();
|
|
2147
2177
|
const resolveId = (id) => {
|
|
2178
|
+
if (id.startsWith("module:") && selfNames.length > 0) {
|
|
2179
|
+
const cachedSelf = remap.get(id);
|
|
2180
|
+
if (cachedSelf !== void 0) return cachedSelf;
|
|
2181
|
+
const candidates = selfImportCandidates(id.slice("module:".length), selfNames);
|
|
2182
|
+
if (candidates !== null) {
|
|
2183
|
+
const resolved2 = uniqueMatch(id, candidates, realFiles);
|
|
2184
|
+
if (resolved2 !== null) {
|
|
2185
|
+
remap.set(id, resolved2);
|
|
2186
|
+
return resolved2;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
return null;
|
|
2190
|
+
}
|
|
2148
2191
|
if (isOpaque(id)) return null;
|
|
2149
2192
|
const cached = remap.get(id);
|
|
2150
2193
|
if (cached !== void 0) return cached;
|
|
@@ -2453,15 +2496,15 @@ function renderReport(graph, analysis, now = /* @__PURE__ */ new Date()) {
|
|
|
2453
2496
|
|
|
2454
2497
|
// src/export.ts
|
|
2455
2498
|
var import_node_module2 = require("module");
|
|
2456
|
-
var
|
|
2457
|
-
var
|
|
2499
|
+
var fs11 = __toESM(require("fs/promises"), 1);
|
|
2500
|
+
var path6 = __toESM(require("path"), 1);
|
|
2458
2501
|
|
|
2459
2502
|
// src/security.ts
|
|
2460
2503
|
var import_node_crypto2 = require("crypto");
|
|
2461
2504
|
var dns = __toESM(require("dns"), 1);
|
|
2462
2505
|
var http = __toESM(require("http"), 1);
|
|
2463
2506
|
var https = __toESM(require("https"), 1);
|
|
2464
|
-
var
|
|
2507
|
+
var fs10 = __toESM(require("fs"), 1);
|
|
2465
2508
|
var net = __toESM(require("net"), 1);
|
|
2466
2509
|
var nodePath = __toESM(require("path"), 1);
|
|
2467
2510
|
var MAX_FETCH_BYTES = 50 * 1024 * 1024;
|
|
@@ -2497,25 +2540,25 @@ function validateDsn(dsn) {
|
|
|
2497
2540
|
}
|
|
2498
2541
|
};
|
|
2499
2542
|
}
|
|
2500
|
-
function validateGraphPath(
|
|
2543
|
+
function validateGraphPath(path12, base) {
|
|
2501
2544
|
const baseDir = base ?? nodePath.join(process.cwd(), "graphify-out");
|
|
2502
2545
|
let resolvedBase;
|
|
2503
2546
|
try {
|
|
2504
|
-
resolvedBase =
|
|
2547
|
+
resolvedBase = fs10.realpathSync(baseDir);
|
|
2505
2548
|
} catch {
|
|
2506
2549
|
throw new Error(`Base directory does not exist: ${baseDir}`);
|
|
2507
2550
|
}
|
|
2508
|
-
const candidate = nodePath.isAbsolute(
|
|
2551
|
+
const candidate = nodePath.isAbsolute(path12) ? path12 : nodePath.join(resolvedBase, path12);
|
|
2509
2552
|
const resolvedCandidate = nodePath.resolve(candidate);
|
|
2510
2553
|
let realCandidate = resolvedCandidate;
|
|
2511
2554
|
try {
|
|
2512
|
-
realCandidate =
|
|
2555
|
+
realCandidate = fs10.realpathSync(resolvedCandidate);
|
|
2513
2556
|
} catch {
|
|
2514
2557
|
}
|
|
2515
2558
|
const relative4 = nodePath.relative(resolvedBase, realCandidate);
|
|
2516
2559
|
const escapes = relative4 === ".." || relative4.startsWith(`..${nodePath.sep}`) || nodePath.isAbsolute(relative4);
|
|
2517
2560
|
if (escapes) {
|
|
2518
|
-
throw new Error(`Path escapes graphify-out/: ${
|
|
2561
|
+
throw new Error(`Path escapes graphify-out/: ${path12}`);
|
|
2519
2562
|
}
|
|
2520
2563
|
return realCandidate;
|
|
2521
2564
|
}
|
|
@@ -2532,10 +2575,10 @@ function escapeHtml(text) {
|
|
|
2532
2575
|
var require3 = (0, import_node_module2.createRequire)(importMetaUrl);
|
|
2533
2576
|
function resolveVisNetworkAssets() {
|
|
2534
2577
|
const packageJsonPath = require3.resolve("vis-network/package.json");
|
|
2535
|
-
const root =
|
|
2578
|
+
const root = path6.dirname(packageJsonPath);
|
|
2536
2579
|
return {
|
|
2537
|
-
jsPath:
|
|
2538
|
-
cssPath:
|
|
2580
|
+
jsPath: path6.join(root, "standalone", "umd", "vis-network.min.js"),
|
|
2581
|
+
cssPath: path6.join(root, "styles", "vis-network.min.css")
|
|
2539
2582
|
};
|
|
2540
2583
|
}
|
|
2541
2584
|
var COMMUNITY_PALETTE = [
|
|
@@ -2594,8 +2637,8 @@ community: ${communityLabel}` : ""}`,
|
|
|
2594
2637
|
async function renderHtml(graph) {
|
|
2595
2638
|
const { jsPath, cssPath } = resolveVisNetworkAssets();
|
|
2596
2639
|
const [visJs, visCss] = await Promise.all([
|
|
2597
|
-
|
|
2598
|
-
|
|
2640
|
+
fs11.readFile(jsPath, "utf-8"),
|
|
2641
|
+
fs11.readFile(cssPath, "utf-8")
|
|
2599
2642
|
]);
|
|
2600
2643
|
const { nodes, edges } = buildVisNodesAndEdges(graph);
|
|
2601
2644
|
const dataJson = safeInlineJson({ nodes, edges });
|
|
@@ -2635,17 +2678,17 @@ ${visJs}
|
|
|
2635
2678
|
`;
|
|
2636
2679
|
}
|
|
2637
2680
|
async function exportGraph(graph, options, report) {
|
|
2638
|
-
const outDir =
|
|
2639
|
-
await
|
|
2681
|
+
const outDir = path6.resolve(options.outDir);
|
|
2682
|
+
await fs11.mkdir(outDir, { recursive: true });
|
|
2640
2683
|
const jsonPath = validateGraphPath("graph.json", outDir);
|
|
2641
|
-
await
|
|
2684
|
+
await fs11.writeFile(jsonPath, JSON.stringify(graph.toJSON(), null, 2), "utf-8");
|
|
2642
2685
|
if (options.html !== false) {
|
|
2643
2686
|
const htmlPath = validateGraphPath("graph.html", outDir);
|
|
2644
|
-
await
|
|
2687
|
+
await fs11.writeFile(htmlPath, await renderHtml(graph), "utf-8");
|
|
2645
2688
|
}
|
|
2646
2689
|
if (report !== void 0) {
|
|
2647
2690
|
const reportPath = validateGraphPath("GRAPH_REPORT.md", outDir);
|
|
2648
|
-
await
|
|
2691
|
+
await fs11.writeFile(reportPath, report, "utf-8");
|
|
2649
2692
|
}
|
|
2650
2693
|
const notImplemented = [];
|
|
2651
2694
|
if (options.svg) notImplemented.push("--svg");
|
|
@@ -2658,24 +2701,24 @@ async function exportGraph(graph, options, report) {
|
|
|
2658
2701
|
}
|
|
2659
2702
|
|
|
2660
2703
|
// src/pipeline.ts
|
|
2661
|
-
var
|
|
2662
|
-
var
|
|
2704
|
+
var fs13 = __toESM(require("fs/promises"), 1);
|
|
2705
|
+
var path8 = __toESM(require("path"), 1);
|
|
2663
2706
|
|
|
2664
2707
|
// src/extractionCache.ts
|
|
2665
2708
|
var import_node_crypto3 = require("crypto");
|
|
2666
|
-
var
|
|
2667
|
-
var
|
|
2709
|
+
var fs12 = __toESM(require("fs/promises"), 1);
|
|
2710
|
+
var path7 = __toESM(require("path"), 1);
|
|
2668
2711
|
var ExtractionCache = class {
|
|
2669
2712
|
dir;
|
|
2670
2713
|
constructor(outDir) {
|
|
2671
|
-
this.dir =
|
|
2714
|
+
this.dir = path7.join(outDir, "cache");
|
|
2672
2715
|
}
|
|
2673
2716
|
key(relFile, content) {
|
|
2674
2717
|
return (0, import_node_crypto3.createHash)("sha256").update(relFile).update("\0").update(content).digest("hex");
|
|
2675
2718
|
}
|
|
2676
2719
|
async get(key) {
|
|
2677
2720
|
try {
|
|
2678
|
-
const raw = await
|
|
2721
|
+
const raw = await fs12.readFile(path7.join(this.dir, `${key}.json`), "utf-8");
|
|
2679
2722
|
const parsed = JSON.parse(raw);
|
|
2680
2723
|
if (!Array.isArray(parsed.nodes) || !Array.isArray(parsed.edges)) return null;
|
|
2681
2724
|
return parsed;
|
|
@@ -2684,8 +2727,8 @@ var ExtractionCache = class {
|
|
|
2684
2727
|
}
|
|
2685
2728
|
}
|
|
2686
2729
|
async put(key, extraction) {
|
|
2687
|
-
await
|
|
2688
|
-
await
|
|
2730
|
+
await fs12.mkdir(this.dir, { recursive: true });
|
|
2731
|
+
await fs12.writeFile(path7.join(this.dir, `${key}.json`), JSON.stringify(extraction), "utf-8");
|
|
2689
2732
|
}
|
|
2690
2733
|
};
|
|
2691
2734
|
|
|
@@ -2693,21 +2736,21 @@ var ExtractionCache = class {
|
|
|
2693
2736
|
async function runPipeline(root, options = {}) {
|
|
2694
2737
|
const progress = options.onProgress ?? (() => {
|
|
2695
2738
|
});
|
|
2696
|
-
const resolvedRoot =
|
|
2739
|
+
const resolvedRoot = path8.resolve(root);
|
|
2697
2740
|
progress(`Scanning ${resolvedRoot} ...`);
|
|
2698
2741
|
const manifest = collectFiles(resolvedRoot);
|
|
2699
2742
|
progress(
|
|
2700
2743
|
`Found ${manifest.totalFiles} file(s) (${manifest.files.code.length} code, ${manifest.skippedSensitive.length} skipped as sensitive).`
|
|
2701
2744
|
);
|
|
2702
|
-
const outDir = options.outDir ??
|
|
2745
|
+
const outDir = options.outDir ?? path8.join(resolvedRoot, "graphify-out");
|
|
2703
2746
|
const cache = new ExtractionCache(outDir);
|
|
2704
2747
|
progress("Extracting...");
|
|
2705
2748
|
const extractions = [];
|
|
2706
2749
|
let cacheHits = 0;
|
|
2707
2750
|
for (const relFile of manifest.files.code.sort((a, b) => a.localeCompare(b))) {
|
|
2708
|
-
const filePath =
|
|
2751
|
+
const filePath = path8.relative(process.cwd(), path8.join(resolvedRoot, relFile)) || relFile;
|
|
2709
2752
|
try {
|
|
2710
|
-
const key = cache.key(relFile, await
|
|
2753
|
+
const key = cache.key(relFile, await fs13.readFile(path8.join(resolvedRoot, relFile)));
|
|
2711
2754
|
let extraction = options.update ? await cache.get(key) : null;
|
|
2712
2755
|
if (extraction) {
|
|
2713
2756
|
cacheHits++;
|
|
@@ -2728,7 +2771,9 @@ async function runPipeline(root, options = {}) {
|
|
|
2728
2771
|
extractions.push(...options.extraExtractions);
|
|
2729
2772
|
}
|
|
2730
2773
|
progress("Resolving cross-file references...");
|
|
2731
|
-
const resolveStats = resolveCrossFileReferences(extractions
|
|
2774
|
+
const resolveStats = resolveCrossFileReferences(extractions, {
|
|
2775
|
+
selfNames: await readSelfNames(resolvedRoot)
|
|
2776
|
+
});
|
|
2732
2777
|
if (resolveStats.resolvedEndpoints > 0) {
|
|
2733
2778
|
progress(
|
|
2734
2779
|
` re-pointed ${resolveStats.resolvedEndpoints} guessed reference(s) at real nodes (${resolveStats.droppedPlaceholders} placeholder node(s) dropped).`
|
|
@@ -2760,12 +2805,12 @@ async function runPipeline(root, options = {}) {
|
|
|
2760
2805
|
}
|
|
2761
2806
|
|
|
2762
2807
|
// src/graphStore.ts
|
|
2763
|
-
var
|
|
2764
|
-
var
|
|
2808
|
+
var fs14 = __toESM(require("fs/promises"), 1);
|
|
2809
|
+
var path9 = __toESM(require("path"), 1);
|
|
2765
2810
|
var import_graphology3 = __toESM(require("graphology"), 1);
|
|
2766
|
-
async function loadGraph(outDir =
|
|
2811
|
+
async function loadGraph(outDir = path9.join(process.cwd(), "graphify-out")) {
|
|
2767
2812
|
const jsonPath = validateGraphPath("graph.json", outDir);
|
|
2768
|
-
const raw = await
|
|
2813
|
+
const raw = await fs14.readFile(jsonPath, "utf-8");
|
|
2769
2814
|
const data = JSON.parse(raw);
|
|
2770
2815
|
return import_graphology3.default.from(data);
|
|
2771
2816
|
}
|
|
@@ -2989,25 +3034,25 @@ function shortestPath(graph, fromQuery, toQuery) {
|
|
|
2989
3034
|
if (!visited.has(to.id)) {
|
|
2990
3035
|
return { from, to, found: false, path: [], edges: [] };
|
|
2991
3036
|
}
|
|
2992
|
-
const
|
|
3037
|
+
const path12 = [to.id];
|
|
2993
3038
|
let cursor = to.id;
|
|
2994
3039
|
while (cursor !== from.id) {
|
|
2995
3040
|
const prev = predecessor.get(cursor);
|
|
2996
3041
|
if (!prev) break;
|
|
2997
|
-
|
|
3042
|
+
path12.unshift(prev);
|
|
2998
3043
|
cursor = prev;
|
|
2999
3044
|
}
|
|
3000
3045
|
const edges = [];
|
|
3001
|
-
for (let i = 0; i <
|
|
3002
|
-
const a =
|
|
3003
|
-
const b =
|
|
3046
|
+
for (let i = 0; i < path12.length - 1; i++) {
|
|
3047
|
+
const a = path12[i];
|
|
3048
|
+
const b = path12[i + 1];
|
|
3004
3049
|
const key = graph.edges(a, b)[0] ?? graph.edges(b, a)[0];
|
|
3005
3050
|
if (key) {
|
|
3006
3051
|
const attrs = graph.getEdgeAttributes(key);
|
|
3007
3052
|
edges.push({ source: a, target: b, relation: String(attrs.relation), confidence: String(attrs.confidence) });
|
|
3008
3053
|
}
|
|
3009
3054
|
}
|
|
3010
|
-
return { from, to, found: true, path:
|
|
3055
|
+
return { from, to, found: true, path: path12, edges };
|
|
3011
3056
|
}
|
|
3012
3057
|
function explainNode(graph, query) {
|
|
3013
3058
|
const match = resolveNode(graph, query);
|
|
@@ -3302,8 +3347,8 @@ async function addViewEdges(query, schema, viewNames, tableNames, edges) {
|
|
|
3302
3347
|
|
|
3303
3348
|
// src/memory.ts
|
|
3304
3349
|
var import_node_crypto4 = require("crypto");
|
|
3305
|
-
var
|
|
3306
|
-
var
|
|
3350
|
+
var fs15 = __toESM(require("fs/promises"), 1);
|
|
3351
|
+
var path10 = __toESM(require("path"), 1);
|
|
3307
3352
|
var OUTCOMES = /* @__PURE__ */ new Set(["useful", "dead_end", "corrected"]);
|
|
3308
3353
|
var TYPES = /* @__PURE__ */ new Set(["query", "path", "explain", "affected"]);
|
|
3309
3354
|
function validateResult(value) {
|
|
@@ -3321,25 +3366,25 @@ function validateResult(value) {
|
|
|
3321
3366
|
}
|
|
3322
3367
|
async function saveResult(entry, memoryDir, now = /* @__PURE__ */ new Date()) {
|
|
3323
3368
|
validateResult(entry);
|
|
3324
|
-
await
|
|
3369
|
+
await fs15.mkdir(memoryDir, { recursive: true });
|
|
3325
3370
|
const saved = { ...entry, savedAt: now.toISOString() };
|
|
3326
3371
|
const hash = (0, import_node_crypto4.createHash)("sha256").update(JSON.stringify(saved)).digest("hex").slice(0, 8);
|
|
3327
3372
|
const stamp = saved.savedAt.replace(/[:.]/g, "-");
|
|
3328
|
-
const filePath =
|
|
3329
|
-
await
|
|
3373
|
+
const filePath = path10.join(memoryDir, `result-${stamp}-${hash}.json`);
|
|
3374
|
+
await fs15.writeFile(filePath, JSON.stringify(saved, null, 2), "utf-8");
|
|
3330
3375
|
return filePath;
|
|
3331
3376
|
}
|
|
3332
3377
|
async function loadResults(memoryDir) {
|
|
3333
3378
|
let files;
|
|
3334
3379
|
try {
|
|
3335
|
-
files = (await
|
|
3380
|
+
files = (await fs15.readdir(memoryDir)).filter((f) => f.startsWith("result-") && f.endsWith(".json"));
|
|
3336
3381
|
} catch {
|
|
3337
3382
|
return [];
|
|
3338
3383
|
}
|
|
3339
3384
|
const results = [];
|
|
3340
3385
|
for (const file of files.sort((a, b) => a.localeCompare(b))) {
|
|
3341
3386
|
try {
|
|
3342
|
-
const parsed = JSON.parse(await
|
|
3387
|
+
const parsed = JSON.parse(await fs15.readFile(path10.join(memoryDir, file), "utf-8"));
|
|
3343
3388
|
if (parsed.question && parsed.savedAt) results.push(parsed);
|
|
3344
3389
|
} catch {
|
|
3345
3390
|
}
|
|
@@ -3452,7 +3497,7 @@ function snippetRange(startLine, fileLineCount, entityStartsInFile, maxLines) {
|
|
|
3452
3497
|
const hardEnd = nextStart !== void 0 ? nextStart - 1 : fileLineCount;
|
|
3453
3498
|
return { start: startLine, end: Math.min(hardEnd, startLine + maxLines - 1) };
|
|
3454
3499
|
}
|
|
3455
|
-
async function buildContextPack(graph, task,
|
|
3500
|
+
async function buildContextPack(graph, task, readFile14, options = {}) {
|
|
3456
3501
|
const tokenBudget = options.tokenBudget ?? DEFAULT_CONTEXT_BUDGET;
|
|
3457
3502
|
const maxSnippetLines = options.maxSnippetLines ?? DEFAULT_MAX_SNIPPET_LINES;
|
|
3458
3503
|
const ranked = rankForTask(graph, task, options.maxSeeds);
|
|
@@ -3473,7 +3518,7 @@ async function buildContextPack(graph, task, readFile13, options = {}) {
|
|
|
3473
3518
|
if (cached !== void 0) return cached;
|
|
3474
3519
|
let lines;
|
|
3475
3520
|
try {
|
|
3476
|
-
lines = (await
|
|
3521
|
+
lines = (await readFile14(file)).split("\n");
|
|
3477
3522
|
} catch {
|
|
3478
3523
|
lines = null;
|
|
3479
3524
|
}
|
|
@@ -3561,8 +3606,8 @@ var TEST_FILE_PATTERNS = [
|
|
|
3561
3606
|
/_spec\.rb$/,
|
|
3562
3607
|
/_test\.rb$/
|
|
3563
3608
|
];
|
|
3564
|
-
function isTestFile(
|
|
3565
|
-
return TEST_FILE_PATTERNS.some((p) => p.test(
|
|
3609
|
+
function isTestFile(path12) {
|
|
3610
|
+
return TEST_FILE_PATTERNS.some((p) => p.test(path12));
|
|
3566
3611
|
}
|
|
3567
3612
|
var TEST_REACH_DEPTH = 4;
|
|
3568
3613
|
var TEST_REACH_LIMIT = 2e3;
|
|
@@ -3611,22 +3656,22 @@ function testsForChangedFiles(graph, changedFiles) {
|
|
|
3611
3656
|
|
|
3612
3657
|
// src/diff.ts
|
|
3613
3658
|
var import_node_child_process = require("child_process");
|
|
3614
|
-
var
|
|
3659
|
+
var fs16 = __toESM(require("fs/promises"), 1);
|
|
3615
3660
|
var os = __toESM(require("os"), 1);
|
|
3616
|
-
var
|
|
3661
|
+
var path11 = __toESM(require("path"), 1);
|
|
3617
3662
|
var import_node_util = require("util");
|
|
3618
3663
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
3619
3664
|
async function graphForDirectory(root) {
|
|
3620
3665
|
const manifest = collectFiles(root);
|
|
3621
3666
|
const extractions = [];
|
|
3622
3667
|
for (const relFile of manifest.files.code.sort((a, b) => a.localeCompare(b))) {
|
|
3623
|
-
extractions.push(await extract(
|
|
3668
|
+
extractions.push(await extract(path11.join(root, relFile), relFile));
|
|
3624
3669
|
}
|
|
3625
|
-
resolveCrossFileReferences(extractions);
|
|
3670
|
+
resolveCrossFileReferences(extractions, { selfNames: await readSelfNames(root) });
|
|
3626
3671
|
return buildGraph(extractions);
|
|
3627
3672
|
}
|
|
3628
3673
|
async function checkoutRev(repoRoot, rev) {
|
|
3629
|
-
const dest = await
|
|
3674
|
+
const dest = await fs16.mkdtemp(path11.join(os.tmpdir(), `graphify-review-${rev.replace(/[^a-zA-Z0-9]/g, "_")}-`));
|
|
3630
3675
|
const { stdout } = await execFileAsync(
|
|
3631
3676
|
"git",
|
|
3632
3677
|
["-C", repoRoot, "archive", "--format=tar", rev],
|
|
@@ -3694,8 +3739,8 @@ async function reviewRevisions(repoRoot, base, head = "HEAD") {
|
|
|
3694
3739
|
return diffGraphs(baseGraph, headGraph, base, head);
|
|
3695
3740
|
} finally {
|
|
3696
3741
|
await Promise.all([
|
|
3697
|
-
|
|
3698
|
-
|
|
3742
|
+
fs16.rm(baseDir, { recursive: true, force: true }),
|
|
3743
|
+
fs16.rm(headDir, { recursive: true, force: true })
|
|
3699
3744
|
]);
|
|
3700
3745
|
}
|
|
3701
3746
|
}
|