mcp-code-context 3.9.2 → 7.0.1
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/CHANGELOG.md +72 -0
- package/INSTRUCTIONS.md +15 -4
- package/README.md +109 -5
- package/dist/src/core/engine.d.ts +1 -1
- package/dist/src/core/engine.js +1 -1
- package/dist/src/core/indexManager.d.ts +1 -1
- package/dist/src/core/indexManager.js +1 -1
- package/dist/src/core/sessionManager.d.ts +1 -1
- package/dist/src/core/sessionManager.js +1 -1
- package/dist/src/core/validator.d.ts +1 -1
- package/dist/src/core/validator.js +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.js +119 -14
- package/dist/src/index.js.map +1 -1
- package/dist/src/operations/apiRoutes.d.ts +31 -0
- package/dist/src/operations/apiRoutes.js +170 -0
- package/dist/src/operations/apiRoutes.js.map +1 -0
- package/dist/src/operations/architectureLinter.d.ts +45 -0
- package/dist/src/operations/architectureLinter.js +223 -0
- package/dist/src/operations/architectureLinter.js.map +1 -0
- package/dist/src/operations/astComplexity.d.ts +38 -0
- package/dist/src/operations/astComplexity.js +243 -0
- package/dist/src/operations/astComplexity.js.map +1 -0
- package/dist/src/operations/astMockGenerator.d.ts +34 -0
- package/dist/src/operations/astMockGenerator.js +203 -0
- package/dist/src/operations/astMockGenerator.js.map +1 -0
- package/dist/src/operations/astQuery.d.ts +47 -0
- package/dist/src/operations/astQuery.js +169 -0
- package/dist/src/operations/astQuery.js.map +1 -0
- package/dist/src/operations/astTransform.d.ts +1 -1
- package/dist/src/operations/astTransform.js +11 -2
- package/dist/src/operations/astTransform.js.map +1 -1
- package/dist/src/operations/asyncBlockers.d.ts +33 -0
- package/dist/src/operations/asyncBlockers.js +162 -0
- package/dist/src/operations/asyncBlockers.js.map +1 -0
- package/dist/src/operations/blastRadiusReport.d.ts +43 -0
- package/dist/src/operations/blastRadiusReport.js +236 -0
- package/dist/src/operations/blastRadiusReport.js.map +1 -0
- package/dist/src/operations/callHierarchy.d.ts +28 -0
- package/dist/src/operations/callHierarchy.js +166 -0
- package/dist/src/operations/callHierarchy.js.map +1 -0
- package/dist/src/operations/circularDependencies.d.ts +28 -0
- package/dist/src/operations/circularDependencies.js +201 -0
- package/dist/src/operations/circularDependencies.js.map +1 -0
- package/dist/src/operations/classHierarchyFlattener.d.ts +35 -0
- package/dist/src/operations/classHierarchyFlattener.js +185 -0
- package/dist/src/operations/classHierarchyFlattener.js.map +1 -0
- package/dist/src/operations/compress.d.ts +2 -2
- package/dist/src/operations/compress.js +154 -20
- package/dist/src/operations/compress.js.map +1 -1
- package/dist/src/operations/conceptSearch.d.ts +19 -0
- package/dist/src/operations/conceptSearch.js +176 -0
- package/dist/src/operations/conceptSearch.js.map +1 -0
- package/dist/src/operations/confirmationStore.d.ts +1 -1
- package/dist/src/operations/confirmationStore.js +1 -1
- package/dist/src/operations/conflictPredictor.d.ts +21 -0
- package/dist/src/operations/conflictPredictor.js +139 -0
- package/dist/src/operations/conflictPredictor.js.map +1 -0
- package/dist/src/operations/contextCompactor.d.ts +38 -0
- package/dist/src/operations/contextCompactor.js +348 -0
- package/dist/src/operations/contextCompactor.js.map +1 -0
- package/dist/src/operations/cstCodemod.d.ts +34 -0
- package/dist/src/operations/cstCodemod.js +205 -0
- package/dist/src/operations/cstCodemod.js.map +1 -0
- package/dist/src/operations/deadSymbols.d.ts +32 -0
- package/dist/src/operations/deadSymbols.js +178 -0
- package/dist/src/operations/deadSymbols.js.map +1 -0
- package/dist/src/operations/envContract.d.ts +35 -0
- package/dist/src/operations/envContract.js +194 -0
- package/dist/src/operations/envContract.js.map +1 -0
- package/dist/src/operations/errorAudit.d.ts +36 -0
- package/dist/src/operations/errorAudit.js +201 -0
- package/dist/src/operations/errorAudit.js.map +1 -0
- package/dist/src/operations/importIntegrity.d.ts +48 -0
- package/dist/src/operations/importIntegrity.js +395 -0
- package/dist/src/operations/importIntegrity.js.map +1 -0
- package/dist/src/operations/incrementalDiff.d.ts +47 -0
- package/dist/src/operations/incrementalDiff.js +216 -0
- package/dist/src/operations/incrementalDiff.js.map +1 -0
- package/dist/src/operations/lexicalScope.d.ts +51 -0
- package/dist/src/operations/lexicalScope.js +212 -0
- package/dist/src/operations/lexicalScope.js.map +1 -0
- package/dist/src/operations/read.d.ts +21 -0
- package/dist/src/operations/read.js +21 -0
- package/dist/src/operations/read.js.map +1 -1
- package/dist/src/operations/readCore.js +37 -17
- package/dist/src/operations/readCore.js.map +1 -1
- package/dist/src/operations/rename.js +35 -24
- package/dist/src/operations/rename.js.map +1 -1
- package/dist/src/operations/sqlValidator.d.ts +36 -0
- package/dist/src/operations/sqlValidator.js +202 -0
- package/dist/src/operations/sqlValidator.js.map +1 -0
- package/dist/src/operations/symbolQuery.js +112 -23
- package/dist/src/operations/symbolQuery.js.map +1 -1
- package/dist/src/operations/taintAnalysis.d.ts +46 -0
- package/dist/src/operations/taintAnalysis.js +220 -0
- package/dist/src/operations/taintAnalysis.js.map +1 -0
- package/dist/src/operations/testImpact.d.ts +31 -0
- package/dist/src/operations/testImpact.js +179 -0
- package/dist/src/operations/testImpact.js.map +1 -0
- package/dist/src/operations/typeInference.d.ts +54 -0
- package/dist/src/operations/typeInference.js +565 -0
- package/dist/src/operations/typeInference.js.map +1 -0
- package/dist/src/operations/wireContract.d.ts +34 -0
- package/dist/src/operations/wireContract.js +185 -0
- package/dist/src/operations/wireContract.js.map +1 -0
- package/dist/src/operations/write.d.ts +2 -2
- package/dist/src/operations/write.js +151 -82
- package/dist/src/operations/write.js.map +1 -1
- package/dist/src/parsers/base.d.ts +9 -1
- package/dist/src/parsers/base.js +61 -1
- package/dist/src/parsers/base.js.map +1 -1
- package/dist/src/parsers/csharp.d.ts +1 -1
- package/dist/src/parsers/csharp.js +1 -1
- package/dist/src/parsers/dartTreeSitter.d.ts +1 -1
- package/dist/src/parsers/dartTreeSitter.js +1 -1
- package/dist/src/parsers/go.d.ts +1 -1
- package/dist/src/parsers/go.js +1 -1
- package/dist/src/parsers/java.d.ts +1 -1
- package/dist/src/parsers/java.js +1 -1
- package/dist/src/parsers/kotlin.d.ts +1 -1
- package/dist/src/parsers/kotlin.js +1 -1
- package/dist/src/parsers/php.d.ts +1 -1
- package/dist/src/parsers/php.js +1 -1
- package/dist/src/parsers/python.d.ts +1 -1
- package/dist/src/parsers/python.js +1 -1
- package/dist/src/parsers/registry.d.ts +1 -1
- package/dist/src/parsers/registry.js +1 -1
- package/dist/src/parsers/ruby.d.ts +1 -1
- package/dist/src/parsers/ruby.js +1 -1
- package/dist/src/parsers/rust.d.ts +1 -1
- package/dist/src/parsers/rust.js +1 -1
- package/dist/src/parsers/typescript.d.ts +1 -1
- package/dist/src/parsers/typescript.js +1 -1
- package/dist/src/tools/context.d.ts +4 -0
- package/dist/src/tools/context.js +14 -0
- package/dist/src/tools/context.js.map +1 -1
- package/dist/src/tools/pipeline.js +26 -0
- package/dist/src/tools/pipeline.js.map +1 -1
- package/dist/src/tools/readHandlers.d.ts +150 -0
- package/dist/src/tools/readHandlers.js +622 -17
- package/dist/src/tools/readHandlers.js.map +1 -1
- package/dist/src/tools/toolDefinitions.d.ts +2184 -0
- package/dist/src/tools/toolDefinitionsCore.d.ts +2184 -0
- package/dist/src/tools/toolDefinitionsCore.js +381 -1
- package/dist/src/tools/toolDefinitionsCore.js.map +1 -1
- package/dist/src/tools/writeHandlers.js +3 -1
- package/dist/src/tools/writeHandlers.js.map +1 -1
- package/dist/src/utils/appDir.d.ts +1 -1
- package/dist/src/utils/appDir.js +1 -1
- package/dist/src/utils/auditLogger.d.ts +1 -1
- package/dist/src/utils/auditLogger.js +1 -1
- package/dist/src/utils/backupManager.d.ts +1 -1
- package/dist/src/utils/backupManager.js +1 -1
- package/dist/src/utils/conceptEngine.d.ts +56 -0
- package/dist/src/utils/conceptEngine.js +234 -0
- package/dist/src/utils/conceptEngine.js.map +1 -0
- package/dist/src/utils/constants.d.ts +1 -1
- package/dist/src/utils/constants.js +2 -1
- package/dist/src/utils/constants.js.map +1 -1
- package/dist/src/utils/diff.d.ts +1 -1
- package/dist/src/utils/diff.js +1 -1
- package/dist/src/utils/fileLock.d.ts +1 -1
- package/dist/src/utils/fileLock.js +1 -1
- package/dist/src/utils/fileWalker.d.ts +1 -1
- package/dist/src/utils/fileWalker.js +1 -1
- package/dist/src/utils/fileWatcher.d.ts +1 -1
- package/dist/src/utils/fileWatcher.js +1 -1
- package/dist/src/utils/fuzzySearch.d.ts +1 -1
- package/dist/src/utils/fuzzySearch.js +1 -1
- package/dist/src/utils/gemfileParser.d.ts +1 -1
- package/dist/src/utils/gemfileParser.js +1 -1
- package/dist/src/utils/logger.d.ts +1 -1
- package/dist/src/utils/logger.js +1 -1
- package/dist/src/utils/metaprogramming.d.ts +1 -1
- package/dist/src/utils/metaprogramming.js +1 -1
- package/dist/src/utils/railsRoutes.d.ts +1 -1
- package/dist/src/utils/railsRoutes.js +1 -1
- package/dist/src/utils/rateLimiter.d.ts +26 -1
- package/dist/src/utils/rateLimiter.js +26 -1
- package/dist/src/utils/rateLimiter.js.map +1 -1
- package/dist/src/utils/streaming.d.ts +1 -1
- package/dist/src/utils/streaming.js +1 -1
- package/dist/src/utils/telemetry.d.ts +1 -1
- package/dist/src/utils/telemetry.js +1 -1
- package/dist/src/utils/virtualSchema.d.ts +31 -0
- package/dist/src/utils/virtualSchema.js +367 -0
- package/dist/src/utils/virtualSchema.js.map +1 -0
- package/llms.txt +13 -3
- package/package.json +97 -95
- package/skills/code-context-logo.png +0 -0
- package/skills/code-context-pro/SKILL.md +149 -0
- package/skills/code-context-pro/references/benchmarks.md +25 -0
- package/skills/code-context-pro/references/decision-tree.md +32 -0
- package/skills/code-context-pro/references/multi-ide-setup.md +104 -0
- package/skills/code-context-pro.zip +0 -0
- package/HIRE_ME.md +0 -234
- package/SPONSORS.md +0 -104
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Complexity Matrix (McCabe Cyclomatic & Sonar Cognitive Complexity)
|
|
3
|
+
* v5.6.0 Enterprise AST Intelligence
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import { ParserRegistry } from "../parsers/registry.js";
|
|
9
|
+
import { CodeContextEngine } from "../core/engine.js";
|
|
10
|
+
/** Node types that introduce branching in Cyclomatic Complexity */
|
|
11
|
+
const CYCLOMATIC_BRANCH_TYPES = new Set([
|
|
12
|
+
"if_statement",
|
|
13
|
+
"ternary_expression",
|
|
14
|
+
"conditional_expression",
|
|
15
|
+
"for_statement",
|
|
16
|
+
"for_in_statement",
|
|
17
|
+
"for_of_statement",
|
|
18
|
+
"while_statement",
|
|
19
|
+
"do_statement",
|
|
20
|
+
"switch_case",
|
|
21
|
+
"case_clause",
|
|
22
|
+
"catch_clause",
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Calculates Cyclomatic Complexity of an AST subtree
|
|
26
|
+
*/
|
|
27
|
+
function calculateCyclomatic(node) {
|
|
28
|
+
let complexity = 1;
|
|
29
|
+
function traverse(n) {
|
|
30
|
+
if (CYCLOMATIC_BRANCH_TYPES.has(n.type)) {
|
|
31
|
+
complexity++;
|
|
32
|
+
}
|
|
33
|
+
else if (n.type === "binary_expression") {
|
|
34
|
+
const op = n.childForFieldName("operator")?.text;
|
|
35
|
+
if (op === "&&" || op === "||" || op === "??") {
|
|
36
|
+
complexity++;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (let i = 0; i < n.namedChildCount; i++) {
|
|
40
|
+
const child = n.namedChild(i);
|
|
41
|
+
if (child &&
|
|
42
|
+
child.type !== "function_declaration" &&
|
|
43
|
+
child.type !== "function_definition" &&
|
|
44
|
+
child.type !== "method_definition" &&
|
|
45
|
+
child.type !== "arrow_function") {
|
|
46
|
+
traverse(child);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
traverse(node);
|
|
51
|
+
return complexity;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Calculates Cognitive Complexity with nesting penalties
|
|
55
|
+
*/
|
|
56
|
+
function calculateCognitive(node) {
|
|
57
|
+
let score = 0;
|
|
58
|
+
let maxNesting = 0;
|
|
59
|
+
function traverse(n, nesting) {
|
|
60
|
+
if (nesting > maxNesting)
|
|
61
|
+
maxNesting = nesting;
|
|
62
|
+
let isNestingConstruct = false;
|
|
63
|
+
let increments = 0;
|
|
64
|
+
switch (n.type) {
|
|
65
|
+
case "if_statement":
|
|
66
|
+
case "switch_statement":
|
|
67
|
+
case "switch_case":
|
|
68
|
+
case "for_statement":
|
|
69
|
+
case "for_in_statement":
|
|
70
|
+
case "for_of_statement":
|
|
71
|
+
case "while_statement":
|
|
72
|
+
case "do_statement":
|
|
73
|
+
case "catch_clause":
|
|
74
|
+
increments = 1 + nesting;
|
|
75
|
+
isNestingConstruct = true;
|
|
76
|
+
break;
|
|
77
|
+
case "ternary_expression":
|
|
78
|
+
case "conditional_expression":
|
|
79
|
+
increments = 1 + nesting;
|
|
80
|
+
break;
|
|
81
|
+
case "binary_expression": {
|
|
82
|
+
const op = n.childForFieldName("operator")?.text;
|
|
83
|
+
if (op === "&&" || op === "||" || op === "??") {
|
|
84
|
+
increments = 1;
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
score += increments;
|
|
90
|
+
const nextNesting = isNestingConstruct ? nesting + 1 : nesting;
|
|
91
|
+
for (let i = 0; i < n.namedChildCount; i++) {
|
|
92
|
+
const child = n.namedChild(i);
|
|
93
|
+
if (child &&
|
|
94
|
+
child.type !== "function_declaration" &&
|
|
95
|
+
child.type !== "function_definition" &&
|
|
96
|
+
child.type !== "method_definition" &&
|
|
97
|
+
child.type !== "arrow_function") {
|
|
98
|
+
traverse(child, nextNesting);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
traverse(node, 0);
|
|
103
|
+
return { score, maxNesting };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Finds all functions and methods within AST
|
|
107
|
+
*/
|
|
108
|
+
function extractFunctions(root) {
|
|
109
|
+
const list = [];
|
|
110
|
+
function walk(n) {
|
|
111
|
+
if (n.type === "function_declaration" ||
|
|
112
|
+
n.type === "function_definition" ||
|
|
113
|
+
n.type === "method_definition") {
|
|
114
|
+
const name = n.childForFieldName("name")?.text || "anonymous";
|
|
115
|
+
const kind = n.type === "method_definition" ? "method" : "function";
|
|
116
|
+
list.push({ node: n, name, kind });
|
|
117
|
+
}
|
|
118
|
+
else if (n.type === "arrow_function") {
|
|
119
|
+
let name = "anonymous_arrow";
|
|
120
|
+
if (n.parent?.type === "variable_declarator") {
|
|
121
|
+
name = n.parent.childForFieldName("name")?.text || name;
|
|
122
|
+
}
|
|
123
|
+
list.push({ node: n, name, kind: "arrow_function" });
|
|
124
|
+
}
|
|
125
|
+
for (let i = 0; i < n.namedChildCount; i++) {
|
|
126
|
+
const child = n.namedChild(i);
|
|
127
|
+
if (child)
|
|
128
|
+
walk(child);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
walk(root);
|
|
132
|
+
return list;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Computes the AST complexity matrix for a file
|
|
136
|
+
*/
|
|
137
|
+
export async function getAstComplexityMatrix(params) {
|
|
138
|
+
let tree = null;
|
|
139
|
+
try {
|
|
140
|
+
const targetPath = params.filePath || "in_memory.ts";
|
|
141
|
+
let content = params.code ?? params.content;
|
|
142
|
+
if (content === undefined) {
|
|
143
|
+
if (params.filePath && existsSync(params.filePath)) {
|
|
144
|
+
content = await fs.readFile(params.filePath, "utf-8");
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
return {
|
|
148
|
+
success: false,
|
|
149
|
+
error: `File does not exist: ${params.filePath || "none"}`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const ext = path.extname(targetPath).toLowerCase();
|
|
154
|
+
let registry = params.registry;
|
|
155
|
+
if (!registry) {
|
|
156
|
+
const engine = new CodeContextEngine();
|
|
157
|
+
await engine.init();
|
|
158
|
+
registry = new ParserRegistry(engine);
|
|
159
|
+
await registry.init();
|
|
160
|
+
}
|
|
161
|
+
const parser = registry.getParser(ext === ".py" ? ".py" : ".ts");
|
|
162
|
+
if (!parser) {
|
|
163
|
+
return {
|
|
164
|
+
success: false,
|
|
165
|
+
error: `No Tree-sitter parser available for extension: ${ext}`,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
tree = parser.parse(content);
|
|
169
|
+
const functions = extractFunctions(tree.rootNode);
|
|
170
|
+
const threshold = params.threshold || 0;
|
|
171
|
+
const metrics = [];
|
|
172
|
+
let totalCyclomatic = 0;
|
|
173
|
+
let totalCognitive = 0;
|
|
174
|
+
for (const fn of functions) {
|
|
175
|
+
const cyclomatic = calculateCyclomatic(fn.node);
|
|
176
|
+
const { score: cognitive, maxNesting } = calculateCognitive(fn.node);
|
|
177
|
+
totalCyclomatic += cyclomatic;
|
|
178
|
+
totalCognitive += cognitive;
|
|
179
|
+
let riskLevel = "LOW";
|
|
180
|
+
let recommendation = "Function is concise and straightforward.";
|
|
181
|
+
if (cognitive >= 25 || cyclomatic >= 20) {
|
|
182
|
+
riskLevel = "CRITICAL";
|
|
183
|
+
recommendation = "Decompose immediately. High probability of hidden bugs and testing resistance.";
|
|
184
|
+
}
|
|
185
|
+
else if (cognitive >= 15 || cyclomatic >= 10) {
|
|
186
|
+
riskLevel = "HIGH";
|
|
187
|
+
recommendation = "Extract nested control structures and early return guard clauses.";
|
|
188
|
+
}
|
|
189
|
+
else if (cognitive >= 8 || cyclomatic >= 6) {
|
|
190
|
+
riskLevel = "MODERATE";
|
|
191
|
+
recommendation = "Consider simplifying nested conditions or ternary operators.";
|
|
192
|
+
}
|
|
193
|
+
if (cognitive >= threshold) {
|
|
194
|
+
metrics.push({
|
|
195
|
+
name: fn.name,
|
|
196
|
+
kind: fn.kind,
|
|
197
|
+
startLine: fn.node.startPosition.row + 1,
|
|
198
|
+
endLine: fn.node.endPosition.row + 1,
|
|
199
|
+
cyclomaticComplexity: cyclomatic,
|
|
200
|
+
cognitiveComplexity: cognitive,
|
|
201
|
+
maxNestingDepth: maxNesting,
|
|
202
|
+
riskLevel,
|
|
203
|
+
recommendation,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// Sort by cognitive complexity descending
|
|
208
|
+
metrics.sort((a, b) => b.cognitiveComplexity - a.cognitiveComplexity);
|
|
209
|
+
const count = functions.length;
|
|
210
|
+
const avgCyclomatic = count > 0 ? Number((totalCyclomatic / count).toFixed(2)) : 0;
|
|
211
|
+
const avgCognitive = count > 0 ? Number((totalCognitive / count).toFixed(2)) : 0;
|
|
212
|
+
const report = {
|
|
213
|
+
filePath: params.filePath,
|
|
214
|
+
totalFunctionsAnalyzed: count,
|
|
215
|
+
averageCyclomatic: avgCyclomatic,
|
|
216
|
+
averageCognitive: avgCognitive,
|
|
217
|
+
highestCognitiveFunction: metrics.length > 0 ? `${metrics[0].name} (Score: ${metrics[0].cognitiveComplexity})` : undefined,
|
|
218
|
+
metrics,
|
|
219
|
+
summary: `Analyzed ${count} functions. Avg Cyclomatic: ${avgCyclomatic}, Avg Cognitive: ${avgCognitive}. Identified ${metrics.filter(m => m.riskLevel === "HIGH" || m.riskLevel === "CRITICAL").length} high-risk functions.`,
|
|
220
|
+
};
|
|
221
|
+
return {
|
|
222
|
+
success: true,
|
|
223
|
+
content: JSON.stringify(report, null, 2),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
return {
|
|
228
|
+
success: false,
|
|
229
|
+
error: `get_ast_complexity_matrix failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
if (tree) {
|
|
234
|
+
try {
|
|
235
|
+
tree.delete();
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
// ignore disposal errors
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=astComplexity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astComplexity.js","sourceRoot":"","sources":["../../../src/operations/astComplexity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAkCtD,mEAAmE;AACnE,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,cAAc;IACd,oBAAoB;IACpB,wBAAwB;IACxB,eAAe;IACf,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,aAAa;IACb,cAAc;CACf,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,mBAAmB,CAAC,IAAU;IACrC,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,SAAS,QAAQ,CAAC,CAAO;QACvB,IAAI,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,UAAU,EAAE,CAAC;QACf,CAAC;aAAM,IAAI,CAAC,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YAC1C,MAAM,EAAE,GAAG,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC;YACjD,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;gBAC9C,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC;Q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,uBAAuB;SAC9N,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;SACzC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,qCAAqC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SACrG,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,CAAC;YAAC,MAAM,CAAC;gBACP,yBAAyB;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-Hallucination AST Mock Generator
|
|
3
|
+
* v5.6.0 Enterprise AST Intelligence
|
|
4
|
+
*/
|
|
5
|
+
import { ParserRegistry } from "../parsers/registry.js";
|
|
6
|
+
import type { ReadResult } from "./readCore.js";
|
|
7
|
+
export interface MockProperty {
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
optional: boolean;
|
|
11
|
+
defaultValue: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AstMockReport {
|
|
14
|
+
symbolName: string;
|
|
15
|
+
kind: "interface" | "type" | "class";
|
|
16
|
+
propertiesCount: number;
|
|
17
|
+
properties: MockProperty[];
|
|
18
|
+
mockCode: string;
|
|
19
|
+
format: "factory" | "fixture" | "inline_json";
|
|
20
|
+
summary: string;
|
|
21
|
+
}
|
|
22
|
+
export interface AstMockOptions {
|
|
23
|
+
filePath?: string;
|
|
24
|
+
symbolName: string;
|
|
25
|
+
code?: string;
|
|
26
|
+
content?: string;
|
|
27
|
+
format?: "factory" | "fixture" | "inline_json";
|
|
28
|
+
projectRoot?: string;
|
|
29
|
+
registry?: ParserRegistry;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generates typed mocks from AST definitions
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateAstMocks(params: AstMockOptions): Promise<ReadResult>;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-Hallucination AST Mock Generator
|
|
3
|
+
* v5.6.0 Enterprise AST Intelligence
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import { ParserRegistry } from "../parsers/registry.js";
|
|
9
|
+
import { CodeContextEngine } from "../core/engine.js";
|
|
10
|
+
/**
|
|
11
|
+
* Derives a deterministic mock value for a given TypeScript/JavaScript type
|
|
12
|
+
*/
|
|
13
|
+
function deriveDefaultValue(propName, rawType) {
|
|
14
|
+
const t = rawType.trim().toLowerCase();
|
|
15
|
+
if (t === "string")
|
|
16
|
+
return `"mock_${propName}"`;
|
|
17
|
+
if (t === "number")
|
|
18
|
+
return "100";
|
|
19
|
+
if (t === "boolean")
|
|
20
|
+
return "true";
|
|
21
|
+
if (t === "date")
|
|
22
|
+
return 'new Date("2026-01-01T00:00:00.000Z")';
|
|
23
|
+
if (t.endsWith("[]") || t.startsWith("array<"))
|
|
24
|
+
return "[]";
|
|
25
|
+
if (t.startsWith("record<") || t.startsWith("{"))
|
|
26
|
+
return "{}";
|
|
27
|
+
if (t.includes("null") && !t.includes("string") && !t.includes("number"))
|
|
28
|
+
return "null";
|
|
29
|
+
if (t.includes("|")) {
|
|
30
|
+
const firstOption = rawType.split("|")[0].trim();
|
|
31
|
+
if (firstOption.startsWith('"') || firstOption.startsWith("'")) {
|
|
32
|
+
return firstOption;
|
|
33
|
+
}
|
|
34
|
+
return deriveDefaultValue(propName, firstOption);
|
|
35
|
+
}
|
|
36
|
+
return `{} as ${rawType}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extracts properties from an interface, type alias, or class node
|
|
40
|
+
*/
|
|
41
|
+
function extractProperties(targetNode) {
|
|
42
|
+
const props = [];
|
|
43
|
+
function findMembers(n) {
|
|
44
|
+
if (n.type === "property_signature" || n.type === "field_definition") {
|
|
45
|
+
const nameNode = n.childForFieldName("name");
|
|
46
|
+
const typeNode = n.childForFieldName("type");
|
|
47
|
+
if (nameNode) {
|
|
48
|
+
const name = nameNode.text;
|
|
49
|
+
const optional = n.text.includes("?") || Boolean(n.children.some(c => Boolean(c && c.type === "?")));
|
|
50
|
+
const rawType = typeNode?.text?.replace(/^:\s*/, "") || "any";
|
|
51
|
+
props.push({
|
|
52
|
+
name,
|
|
53
|
+
type: rawType,
|
|
54
|
+
optional,
|
|
55
|
+
defaultValue: deriveDefaultValue(name, rawType),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (let i = 0; i < n.namedChildCount; i++) {
|
|
60
|
+
const child = n.namedChild(i);
|
|
61
|
+
if (child)
|
|
62
|
+
findMembers(child);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
findMembers(targetNode);
|
|
66
|
+
return props;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generates formatted mock code from extracted properties
|
|
70
|
+
*/
|
|
71
|
+
function formatMockCode(symbolName, props, format) {
|
|
72
|
+
const indent = " ";
|
|
73
|
+
if (format === "inline_json") {
|
|
74
|
+
const obj = {};
|
|
75
|
+
for (const p of props) {
|
|
76
|
+
if (p.defaultValue.startsWith('"')) {
|
|
77
|
+
obj[p.name] = p.defaultValue.replace(/^"|"$/g, "");
|
|
78
|
+
}
|
|
79
|
+
else if (p.defaultValue === "true" || p.defaultValue === "false") {
|
|
80
|
+
obj[p.name] = p.defaultValue === "true";
|
|
81
|
+
}
|
|
82
|
+
else if (!isNaN(Number(p.defaultValue))) {
|
|
83
|
+
obj[p.name] = Number(p.defaultValue);
|
|
84
|
+
}
|
|
85
|
+
else if (p.defaultValue === "[]") {
|
|
86
|
+
obj[p.name] = [];
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
obj[p.name] = p.defaultValue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return JSON.stringify(obj, null, 2);
|
|
93
|
+
}
|
|
94
|
+
if (format === "fixture") {
|
|
95
|
+
const lines = props.map(p => `${indent}${p.name}: ${p.defaultValue},`);
|
|
96
|
+
return `export const mock${symbolName}: ${symbolName} = {\n${lines.join("\n")}\n};`;
|
|
97
|
+
}
|
|
98
|
+
// Factory format (default)
|
|
99
|
+
const lines = props.map(p => `${indent}${p.name}: ${p.defaultValue},`);
|
|
100
|
+
return `export const createMock${symbolName} = (overrides?: Partial<${symbolName}>): ${symbolName} => ({\n${lines.join("\n")}\n ...overrides,\n});`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Generates typed mocks from AST definitions
|
|
104
|
+
*/
|
|
105
|
+
export async function generateAstMocks(params) {
|
|
106
|
+
let tree = null;
|
|
107
|
+
try {
|
|
108
|
+
const targetPath = params.filePath || "in_memory.ts";
|
|
109
|
+
let content = params.code ?? params.content;
|
|
110
|
+
if (content === undefined) {
|
|
111
|
+
if (params.filePath && existsSync(params.filePath)) {
|
|
112
|
+
content = await fs.readFile(params.filePath, "utf-8");
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return {
|
|
116
|
+
success: false,
|
|
117
|
+
error: `File does not exist: ${params.filePath || "none"}`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const ext = path.extname(targetPath).toLowerCase();
|
|
122
|
+
let registry = params.registry;
|
|
123
|
+
if (!registry) {
|
|
124
|
+
const engine = new CodeContextEngine();
|
|
125
|
+
await engine.init();
|
|
126
|
+
registry = new ParserRegistry(engine);
|
|
127
|
+
await registry.init();
|
|
128
|
+
}
|
|
129
|
+
const parser = registry.getParser(ext === ".py" ? ".py" : ".ts");
|
|
130
|
+
if (!parser) {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
error: `No parser available for extension: ${ext}`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
tree = parser.parse(content);
|
|
137
|
+
// Locate symbol
|
|
138
|
+
let targetNode = null;
|
|
139
|
+
let targetKind = "interface";
|
|
140
|
+
function findSymbol(n) {
|
|
141
|
+
if (n.type === "interface_declaration" ||
|
|
142
|
+
n.type === "type_alias_declaration" ||
|
|
143
|
+
n.type === "class_declaration") {
|
|
144
|
+
const nameNode = n.childForFieldName("name");
|
|
145
|
+
if (nameNode?.text === params.symbolName) {
|
|
146
|
+
targetNode = n;
|
|
147
|
+
if (n.type === "class_declaration")
|
|
148
|
+
targetKind = "class";
|
|
149
|
+
else if (n.type === "type_alias_declaration")
|
|
150
|
+
targetKind = "type";
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
for (let i = 0; i < n.namedChildCount; i++) {
|
|
155
|
+
if (!targetNode) {
|
|
156
|
+
const child = n.namedChild(i);
|
|
157
|
+
if (child)
|
|
158
|
+
findSymbol(child);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
findSymbol(tree.rootNode);
|
|
163
|
+
if (!targetNode) {
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
error: `Symbol '${params.symbolName}' not found in AST. Checked interface, type, and class declarations.`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const props = extractProperties(targetNode);
|
|
170
|
+
const format = params.format || "factory";
|
|
171
|
+
const mockCode = formatMockCode(params.symbolName, props, format);
|
|
172
|
+
const report = {
|
|
173
|
+
symbolName: params.symbolName,
|
|
174
|
+
kind: targetKind,
|
|
175
|
+
propertiesCount: props.length,
|
|
176
|
+
properties: props,
|
|
177
|
+
mockCode,
|
|
178
|
+
format,
|
|
179
|
+
summary: `Generated ${format} mock for ${targetKind} '${params.symbolName}' with ${props.length} typed fields.`,
|
|
180
|
+
};
|
|
181
|
+
return {
|
|
182
|
+
success: true,
|
|
183
|
+
content: JSON.stringify(report, null, 2),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
return {
|
|
188
|
+
success: false,
|
|
189
|
+
error: `generate_ast_mocks failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
if (tree) {
|
|
194
|
+
try {
|
|
195
|
+
tree.delete();
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
// ignore
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=astMockGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astMockGenerator.js","sourceRoot":"","sources":["../../../src/operations/astMockGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA8BtD;;GAEG;AACH,SAAS,kBAAkB,CAAC,QAAgB,EAAE,OAAe;IAC3D,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEvC,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,SAAS,QAAQ,GAAG,CAAC;IAChD,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,CAAC,KAAK,MAAM;QAA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-Expression Query DSL Engine (v5.5.0)
|
|
3
|
+
*
|
|
4
|
+
* Executes native Scheme / S-Expression AST queries against source code using
|
|
5
|
+
* web-tree-sitter compiled to WebAssembly. Enables complex syntactic pattern matching
|
|
6
|
+
* (e.g. empty catch blocks, excessive parameters, nested ternaries, unhandled promises)
|
|
7
|
+
* with zero regex fragility and sub-millisecond execution.
|
|
8
|
+
*/
|
|
9
|
+
import { ParserRegistry } from "../parsers/registry.js";
|
|
10
|
+
import type { ReadResult } from "./readCore.js";
|
|
11
|
+
export interface AstQueryCapture {
|
|
12
|
+
captureName: string;
|
|
13
|
+
nodeType: string;
|
|
14
|
+
text: string;
|
|
15
|
+
startLine: number;
|
|
16
|
+
endLine: number;
|
|
17
|
+
startColumn: number;
|
|
18
|
+
endColumn: number;
|
|
19
|
+
snippet: string;
|
|
20
|
+
}
|
|
21
|
+
export type AstQueryTemplate = "empty-catch" | "excessive-params" | "nested-ternary" | "eval-call" | "todo-comment" | "console-log" | "print-call" | string;
|
|
22
|
+
export interface AstQueryReport {
|
|
23
|
+
filePath?: string;
|
|
24
|
+
language: string;
|
|
25
|
+
queryPattern: string;
|
|
26
|
+
matchesCount: number;
|
|
27
|
+
captures: AstQueryCapture[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Built-in query templates for common AST anti-patterns
|
|
31
|
+
*/
|
|
32
|
+
export declare const PREDEFINED_QUERY_TEMPLATES: Record<string, Record<string, string>>;
|
|
33
|
+
export interface AstQueryOptions {
|
|
34
|
+
filePath?: string;
|
|
35
|
+
query?: string;
|
|
36
|
+
template?: AstQueryTemplate;
|
|
37
|
+
code?: string;
|
|
38
|
+
content?: string;
|
|
39
|
+
limit?: number;
|
|
40
|
+
maxMatches?: number;
|
|
41
|
+
projectRoot?: string;
|
|
42
|
+
registry?: ParserRegistry;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Executes a Tree-sitter S-Expression query against a file
|
|
46
|
+
*/
|
|
47
|
+
export declare function queryCodeAst(params: AstQueryOptions): Promise<ReadResult>;
|