-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmoke.js
More file actions
57 lines (48 loc) · 2.38 KB
/
Copy pathsmoke.js
File metadata and controls
57 lines (48 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const { WorkspaceIndex, buildContext, runSwarm } = require("./dist/engine/workspaceIndex.js");
const path = require("path");
async function main() {
const root = path.resolve(__dirname);
const index = new WorkspaceIndex(root, {
excludeGlobs: ["**/node_modules/**", "**/dist/**", "**/bundle/**", "**/media/**", "**/*.test.ts"],
maxFiles: 1000,
godFileLoc: 500,
});
console.log(`Scanning local workspace ${root} ...`);
let progressCalls = 0;
const result = await index.scan((scanned, total) => {
progressCalls += 1;
});
console.log(`(progress callback fired ${progressCalls} times)`);
console.log("\n=== Scan Result ===");
console.log(`Score: ${result.score}/100`);
console.log(`Files: ${result.fileCount} (${result.loc} LOC)`);
console.log(`Symbols: ${result.graph.stats.symbols}`);
console.log(`Edges: ${result.graph.stats.edges} (${result.graph.stats.resolvedCalls} resolved calls)`);
console.log(`Issues: ${result.issues.length}`);
console.log("\n=== Dimensions ===");
for (const d of result.dimensions) console.log(` ${d.dimension}: ${d.score}/100 (${d.issueCount} issues)`);
const qe = index.queryEngine;
const search = qe.search("runSwarm");
console.log(`\n=== QueryEngine: search("runSwarm") ===`);
console.log(search.slice(0, 3).map(s => `${s.name} (${s.file}:${s.line})`));
console.log("\n=== QueryEngine: cycles ===");
const cycles = qe.cycles();
console.log(cycles.length > 0 ? cycles.slice(0, 3).map(c => c.map(s => s.name).join(" -> ")) : "No cycles");
console.log("\n=== Graph-RAG Context ===");
const ctx = buildContext("generate verified fix", qe);
console.log(`Seeds: ${ctx.seeds.length}, Slices: ${ctx.slices.length}, Tokens: ~${ctx.tokenEstimate}`);
console.log("Prompt preview:");
console.log(ctx.prompt.slice(0, 200).replace(/\n/g, "\\n"));
console.log("\n=== Agent Swarm ===");
const plan = runSwarm({ engine: qe, issues: result.issues, hubFanIn: 10 }, result.score);
console.log(`Total Findings: ${plan.totalFindings} (P0: ${plan.buckets.P0.length}, P1: ${plan.buckets.P1.length})`);
console.log(`Projected Score: ${plan.repoScore} -> ${plan.projectedScore}`);
if (plan.topFindings.length > 0) {
const f = plan.topFindings[0];
console.log(`\nTop finding: [${f.agent}] ${f.title}\n ${f.detail}\n Fix: ${f.suggestedFix}`);
}
}
main().catch((e) => {
console.error("SMOKE TEST FAILED:", e);
process.exit(1);
});