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 CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bin.ts"],"sourcesContent":["/**\n * Smart entry point for `archtracker-mcp` binary.\n *\n * - If CLI subcommands are detected (serve, analyze, init, etc.) → run CLI\n * - Otherwise → start MCP server on stdio\n *\n * This allows both:\n * npx archtracker-mcp → MCP server\n * npx archtracker-mcp serve --target src → Web viewer (CLI mode)\n * npx archtracker-mcp analyze --target src → Analysis report (CLI mode)\n */\n\nconst CLI_COMMANDS = [\"init\", \"analyze\", \"check\", \"context\", \"serve\", \"ci-setup\", \"help\"];\nconst CLI_FLAGS = [\"--help\", \"-h\", \"--version\", \"-V\"];\n\nconst args = process.argv.slice(2);\nconst hasCommand = args.some((arg) => CLI_COMMANDS.includes(arg));\nconst hasFlag = args.some((arg) => CLI_FLAGS.includes(arg));\n\nif (hasCommand || hasFlag) {\n await import(\"./cli/index.js\");\n} else {\n await import(\"./mcp/index.js\");\n}\n"],"mappings":";;;AAYA,IAAM,eAAe,CAAC,QAAQ,WAAW,SAAS,WAAW,SAAS,YAAY,MAAM;AACxF,IAAM,YAAY,CAAC,UAAU,MAAM,aAAa,IAAI;AAEpD,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,aAAa,KAAK,KAAK,CAAC,QAAQ,aAAa,SAAS,GAAG,CAAC;AAChE,IAAM,UAAU,KAAK,KAAK,CAAC,QAAQ,UAAU,SAAS,GAAG,CAAC;AAE1D,IAAI,cAAc,SAAS;AACzB,QAAM,OAAO,gBAAgB;AAC/B,OAAO;AACL,QAAM,OAAO,gBAAgB;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../src/bin.ts"],"sourcesContent":["/**\n * Smart entry point for `archtracker-mcp` binary.\n *\n * - If CLI subcommands are detected (serve, analyze, init, etc.) → run CLI\n * - Otherwise → start MCP server on stdio\n *\n * This allows both:\n * npx archtracker-mcp → MCP server\n * npx archtracker-mcp serve --target src → Web viewer (CLI mode)\n * npx archtracker-mcp analyze --target src → Analysis report (CLI mode)\n */\n\nconst CLI_COMMANDS = [\"init\", \"analyze\", \"check\", \"context\", \"serve\", \"ci-setup\", \"help\"];\nconst CLI_FLAGS = [\"--help\", \"-h\", \"--version\", \"-V\"];\n\nconst args = process.argv.slice(2);\nconst hasCommand = args.some((arg) => CLI_COMMANDS.includes(arg));\nconst hasFlag = args.some((arg) => CLI_FLAGS.includes(arg));\n\nif (hasCommand || hasFlag) {\n await import(\"./cli/index.js\");\n} else {\n await import(\"./mcp/index.js\");\n}\n\nexport {};\n"],"mappings":";;;AAYA,IAAM,eAAe,CAAC,QAAQ,WAAW,SAAS,WAAW,SAAS,YAAY,MAAM;AACxF,IAAM,YAAY,CAAC,UAAU,MAAM,aAAa,IAAI;AAEpD,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,aAAa,KAAK,KAAK,CAAC,QAAQ,aAAa,SAAS,GAAG,CAAC;AAChE,IAAM,UAAU,KAAK,KAAK,CAAC,QAAQ,UAAU,SAAS,GAAG,CAAC;AAE1D,IAAI,cAAc,SAAS;AACzB,QAAM,OAAO,gBAAgB;AAC/B,OAAO;AACL,QAAM,OAAO,gBAAgB;AAC/B;","names":[]}
package/dist/cli/index.js CHANGED
@@ -605,7 +605,7 @@ var RegexEngine = class {
605
605
  continue;
606
606
  }
607
607
  const stripped = stripComments(content, this.config.commentStyle);
608
- const imports = this.extractImports(stripped);
608
+ const imports = this.extractImports(stripped, filePath, absRootDir, projectFileSet);
609
609
  for (const importPath of imports) {
610
610
  const resolved = this.config.resolveImport(
611
611
  importPath,
@@ -639,9 +639,9 @@ var RegexEngine = class {
639
639
  totalEdges: edges.length
640
640
  };
641
641
  }
642
- extractImports(content) {
642
+ extractImports(content, filePath, rootDir, projectFiles) {
643
643
  if (this.config.extractImports) {
644
- return this.config.extractImports(content);
644
+ return this.config.extractImports(content, filePath, rootDir, projectFiles);
645
645
  }
646
646
  const imports = [];
647
647
  for (const pattern of this.config.importPatterns) {
@@ -842,19 +842,20 @@ var python = {
842
842
  extensions: [".py"],
843
843
  commentStyle: "python",
844
844
  importPatterns: [
845
- // from package.module import something
846
- { regex: /^from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm }
845
+ // from package.module import something (including indented, e.g. inside try/except)
846
+ { regex: /^\s*from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm }
847
847
  // import package.module (handled by extractImports for multi-module case)
848
848
  ],
849
849
  // Bug #1 fix: custom extractImports to handle `import a, b, c`
850
+ // Bug #12 fix: allow leading whitespace to catch try/except indented imports
850
851
  extractImports(content) {
851
852
  const imports = [];
852
- const fromRegex = /^from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm;
853
+ const fromRegex = /^\s*from\s+(\.[\w.]*|\w[\w.]*)\s+import\b/gm;
853
854
  let match;
854
855
  while ((match = fromRegex.exec(content)) !== null) {
855
856
  imports.push(match[1]);
856
857
  }
857
- const importRegex = /^import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/gm;
858
+ const importRegex = /^\s*import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/gm;
858
859
  while ((match = importRegex.exec(content)) !== null) {
859
860
  const modules = match[1].split(",");
860
861
  for (const mod of modules) {
@@ -1213,17 +1214,48 @@ var kotlin = {
1213
1214
  },
1214
1215
  defaultExclude: ["build", "\\.gradle", "\\.idea"]
1215
1216
  };
1217
+ var CS_SKIP_CLASSNAMES = /* @__PURE__ */ new Set(["AssemblyInfo", "GlobalUsings"]);
1216
1218
  var cSharp = {
1217
1219
  id: "c-sharp",
1218
1220
  extensions: [".cs"],
1219
1221
  commentStyle: "c-style",
1220
- importPatterns: [
1221
- // using Namespace; and using Namespace.SubNamespace;
1222
- // using static Namespace.Class;
1223
- // Skip: using Alias = Namespace.Class; (captured but resolved same way)
1224
- { regex: /^using\s+(?:static\s+)?([\w.]+)\s*;/gm }
1225
- ],
1222
+ importPatterns: [],
1223
+ // handled by extractImports
1224
+ extractImports(content, filePath, _rootDir, projectFiles) {
1225
+ const imports = [];
1226
+ const usingRegex = /^\s*(?:global\s+)?using\s+(?:static\s+)?([\w.]+)\s*;/gm;
1227
+ let match;
1228
+ while ((match = usingRegex.exec(content)) !== null) {
1229
+ imports.push(match[1]);
1230
+ }
1231
+ const classMap = /* @__PURE__ */ new Map();
1232
+ for (const f of projectFiles) {
1233
+ if (f === filePath) continue;
1234
+ if (!f.endsWith(".cs")) continue;
1235
+ const basename = f.split("/").pop();
1236
+ const className = basename.replace(/\.xaml\.cs$/i, "").replace(/\.cs$/i, "");
1237
+ if (!className || CS_SKIP_CLASSNAMES.has(className)) continue;
1238
+ classMap.set(className, f);
1239
+ }
1240
+ if (classMap.size > 0) {
1241
+ const escaped = [...classMap.keys()].map(
1242
+ (n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
1243
+ );
1244
+ const combined = new RegExp(`\\b(${escaped.join("|")})\\b`, "g");
1245
+ const matched = /* @__PURE__ */ new Set();
1246
+ while ((match = combined.exec(content)) !== null) {
1247
+ const className = match[1];
1248
+ const targetPath = classMap.get(className);
1249
+ if (targetPath && !matched.has(targetPath)) {
1250
+ matched.add(targetPath);
1251
+ imports.push(targetPath);
1252
+ }
1253
+ }
1254
+ }
1255
+ return imports;
1256
+ },
1226
1257
  resolveImport(importPath, _sourceFile, rootDir, projectFiles) {
1258
+ if (projectFiles.has(importPath)) return importPath;
1227
1259
  const segments = importPath.split(".");
1228
1260
  for (let i = segments.length; i > 0; i--) {
1229
1261
  const filePath = segments.slice(0, i).join("/") + ".cs";