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/mcp/index.js CHANGED
@@ -604,7 +604,7 @@ var RegexEngine = class {
604
604
  continue;
605
605
  }
606
606
  const stripped = stripComments(content, this.config.commentStyle);
607
- const imports = this.extractImports(stripped);
607
+ const imports = this.extractImports(stripped, filePath, absRootDir, projectFileSet);
608
608
  for (const importPath of imports) {
609
609
  const resolved = this.config.resolveImport(
610
610
  importPath,
@@ -638,9 +638,9 @@ var RegexEngine = class {
638
638
  totalEdges: edges.length
639
639
  };
640
640
  }
641
- extractImports(content) {
641
+ extractImports(content, filePath, rootDir, projectFiles) {
642
642
  if (this.config.extractImports) {
643
- return this.config.extractImports(content);
643
+ return this.config.extractImports(content, filePath, rootDir, projectFiles);
644
644
  }
645
645
  const imports = [];
646
646
  for (const pattern of this.config.importPatterns) {
@@ -841,19 +841,20 @@ var python = {
841
841
  extensions: [".py"],
842
842
  commentStyle: "python",
843
843
  importPatterns: [
844
- // from package.module import something
845
- { regex: /^from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm }
844
+ // from package.module import something (including indented, e.g. inside try/except)
845
+ { regex: /^\s*from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm }
846
846
  // import package.module (handled by extractImports for multi-module case)
847
847
  ],
848
848
  // Bug #1 fix: custom extractImports to handle `import a, b, c`
849
+ // Bug #12 fix: allow leading whitespace to catch try/except indented imports
849
850
  extractImports(content) {
850
851
  const imports = [];
851
- const fromRegex = /^from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm;
852
+ const fromRegex = /^\s*from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm;
852
853
  let match;
853
854
  while ((match = fromRegex.exec(content)) !== null) {
854
855
  imports.push(match[1]);
855
856
  }
856
- const importRegex = /^import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/gm;
857
+ const importRegex = /^\s*import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/gm;
857
858
  while ((match = importRegex.exec(content)) !== null) {
858
859
  const modules = match[1].split(",");
859
860
  for (const mod of modules) {
@@ -1212,17 +1213,48 @@ var kotlin = {
1212
1213
  },
1213
1214
  defaultExclude: ["build", "\\.gradle", "\\.idea"]
1214
1215
  };
1216
+ var CS_SKIP_CLASSNAMES = /* @__PURE__ */ new Set(["AssemblyInfo", "GlobalUsings"]);
1215
1217
  var cSharp = {
1216
1218
  id: "c-sharp",
1217
1219
  extensions: [".cs"],
1218
1220
  commentStyle: "c-style",
1219
- importPatterns: [
1220
- // using Namespace; and using Namespace.SubNamespace;
1221
- // using static Namespace.Class;
1222
- // Skip: using Alias = Namespace.Class; (captured but resolved same way)
1223
- { regex: /^using\s+(?:static\s+)?([\w.]+)\s*;/gm }
1224
- ],
1221
+ importPatterns: [],
1222
+ // handled by extractImports
1223
+ extractImports(content, filePath, _rootDir, projectFiles) {
1224
+ const imports = [];
1225
+ const usingRegex = /^\s*(?:global\s+)?using\s+(?:static\s+)?([\w.]+)\s*;/gm;
1226
+ let match;
1227
+ while ((match = usingRegex.exec(content)) !== null) {
1228
+ imports.push(match[1]);
1229
+ }
1230
+ const classMap = /* @__PURE__ */ new Map();
1231
+ for (const f of projectFiles) {
1232
+ if (f === filePath) continue;
1233
+ if (!f.endsWith(".cs")) continue;
1234
+ const basename = f.split("/").pop();
1235
+ const className = basename.replace(/\.xaml\.cs$/i, "").replace(/\.cs$/i, "");
1236
+ if (!className || CS_SKIP_CLASSNAMES.has(className)) continue;
1237
+ classMap.set(className, f);
1238
+ }
1239
+ if (classMap.size > 0) {
1240
+ const escaped = [...classMap.keys()].map(
1241
+ (n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
1242
+ );
1243
+ const combined = new RegExp(`\\b(${escaped.join("|")})\\b`, "g");
1244
+ const matched = /* @__PURE__ */ new Set();
1245
+ while ((match = combined.exec(content)) !== null) {
1246
+ const className = match[1];
1247
+ const targetPath = classMap.get(className);
1248
+ if (targetPath && !matched.has(targetPath)) {
1249
+ matched.add(targetPath);
1250
+ imports.push(targetPath);
1251
+ }
1252
+ }
1253
+ }
1254
+ return imports;
1255
+ },
1225
1256
  resolveImport(importPath, _sourceFile, rootDir, projectFiles) {
1257
+ if (projectFiles.has(importPath)) return importPath;
1226
1258
  const segments = importPath.split(".");
1227
1259
  for (let i = segments.length; i > 0; i--) {
1228
1260
  const filePath = segments.slice(0, i).join("/") + ".cs";