archtracker-mcp 0.4.2 → 0.4.3
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/bin.js.map +1 -1
- package/dist/cli/index.js +45 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +45 -13
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +45 -13
- package/dist/mcp/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -600,7 +600,7 @@ var RegexEngine = class {
|
|
|
600
600
|
continue;
|
|
601
601
|
}
|
|
602
602
|
const stripped = stripComments(content, this.config.commentStyle);
|
|
603
|
-
const imports = this.extractImports(stripped);
|
|
603
|
+
const imports = this.extractImports(stripped, filePath, absRootDir, projectFileSet);
|
|
604
604
|
for (const importPath of imports) {
|
|
605
605
|
const resolved = this.config.resolveImport(
|
|
606
606
|
importPath,
|
|
@@ -634,9 +634,9 @@ var RegexEngine = class {
|
|
|
634
634
|
totalEdges: edges.length
|
|
635
635
|
};
|
|
636
636
|
}
|
|
637
|
-
extractImports(content) {
|
|
637
|
+
extractImports(content, filePath, rootDir, projectFiles) {
|
|
638
638
|
if (this.config.extractImports) {
|
|
639
|
-
return this.config.extractImports(content);
|
|
639
|
+
return this.config.extractImports(content, filePath, rootDir, projectFiles);
|
|
640
640
|
}
|
|
641
641
|
const imports = [];
|
|
642
642
|
for (const pattern of this.config.importPatterns) {
|
|
@@ -818,19 +818,20 @@ var python = {
|
|
|
818
818
|
extensions: [".py"],
|
|
819
819
|
commentStyle: "python",
|
|
820
820
|
importPatterns: [
|
|
821
|
-
// from package.module import something
|
|
822
|
-
{ regex:
|
|
821
|
+
// from package.module import something (including indented, e.g. inside try/except)
|
|
822
|
+
{ regex: /^\s*from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm }
|
|
823
823
|
// import package.module (handled by extractImports for multi-module case)
|
|
824
824
|
],
|
|
825
825
|
// Bug #1 fix: custom extractImports to handle `import a, b, c`
|
|
826
|
+
// Bug #12 fix: allow leading whitespace to catch try/except indented imports
|
|
826
827
|
extractImports(content) {
|
|
827
828
|
const imports = [];
|
|
828
|
-
const fromRegex =
|
|
829
|
+
const fromRegex = /^\s*from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm;
|
|
829
830
|
let match;
|
|
830
831
|
while ((match = fromRegex.exec(content)) !== null) {
|
|
831
832
|
imports.push(match[1]);
|
|
832
833
|
}
|
|
833
|
-
const importRegex =
|
|
834
|
+
const importRegex = /^\s*import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/gm;
|
|
834
835
|
while ((match = importRegex.exec(content)) !== null) {
|
|
835
836
|
const modules = match[1].split(",");
|
|
836
837
|
for (const mod of modules) {
|
|
@@ -1189,17 +1190,48 @@ var kotlin = {
|
|
|
1189
1190
|
},
|
|
1190
1191
|
defaultExclude: ["build", "\\.gradle", "\\.idea"]
|
|
1191
1192
|
};
|
|
1193
|
+
var CS_SKIP_CLASSNAMES = /* @__PURE__ */ new Set(["AssemblyInfo", "GlobalUsings"]);
|
|
1192
1194
|
var cSharp = {
|
|
1193
1195
|
id: "c-sharp",
|
|
1194
1196
|
extensions: [".cs"],
|
|
1195
1197
|
commentStyle: "c-style",
|
|
1196
|
-
importPatterns: [
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1198
|
+
importPatterns: [],
|
|
1199
|
+
// handled by extractImports
|
|
1200
|
+
extractImports(content, filePath, _rootDir, projectFiles) {
|
|
1201
|
+
const imports = [];
|
|
1202
|
+
const usingRegex = /^\s*(?:global\s+)?using\s+(?:static\s+)?([\w.]+)\s*;/gm;
|
|
1203
|
+
let match;
|
|
1204
|
+
while ((match = usingRegex.exec(content)) !== null) {
|
|
1205
|
+
imports.push(match[1]);
|
|
1206
|
+
}
|
|
1207
|
+
const classMap = /* @__PURE__ */ new Map();
|
|
1208
|
+
for (const f of projectFiles) {
|
|
1209
|
+
if (f === filePath) continue;
|
|
1210
|
+
if (!f.endsWith(".cs")) continue;
|
|
1211
|
+
const basename = f.split("/").pop();
|
|
1212
|
+
const className = basename.replace(/\.xaml\.cs$/i, "").replace(/\.cs$/i, "");
|
|
1213
|
+
if (!className || CS_SKIP_CLASSNAMES.has(className)) continue;
|
|
1214
|
+
classMap.set(className, f);
|
|
1215
|
+
}
|
|
1216
|
+
if (classMap.size > 0) {
|
|
1217
|
+
const escaped = [...classMap.keys()].map(
|
|
1218
|
+
(n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
1219
|
+
);
|
|
1220
|
+
const combined = new RegExp(`\\b(${escaped.join("|")})\\b`, "g");
|
|
1221
|
+
const matched = /* @__PURE__ */ new Set();
|
|
1222
|
+
while ((match = combined.exec(content)) !== null) {
|
|
1223
|
+
const className = match[1];
|
|
1224
|
+
const targetPath = classMap.get(className);
|
|
1225
|
+
if (targetPath && !matched.has(targetPath)) {
|
|
1226
|
+
matched.add(targetPath);
|
|
1227
|
+
imports.push(targetPath);
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
return imports;
|
|
1232
|
+
},
|
|
1202
1233
|
resolveImport(importPath, _sourceFile, rootDir, projectFiles) {
|
|
1234
|
+
if (projectFiles.has(importPath)) return importPath;
|
|
1203
1235
|
const segments = importPath.split(".");
|
|
1204
1236
|
for (let i = segments.length; i > 0; i--) {
|
|
1205
1237
|
const filePath = segments.slice(0, i).join("/") + ".cs";
|