openkrak-mcp 1.0.16 → 1.0.17

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.
Files changed (2) hide show
  1. package/dist/index.js +115 -41
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -242241,6 +242241,66 @@ function computeStats(nodes, edges) {
242241
242241
  edge_kind_breakdown: edgeBreakdown
242242
242242
  };
242243
242243
  }
242244
+ var EXTERNAL_PREFIXES = [
242245
+ "node:",
242246
+ "fs/",
242247
+ "path",
242248
+ "crypto",
242249
+ "os",
242250
+ "http",
242251
+ "https",
242252
+ "stream",
242253
+ "util",
242254
+ "events",
242255
+ "buffer",
242256
+ "url",
242257
+ "querystring",
242258
+ "child_process",
242259
+ "cluster",
242260
+ "next/",
242261
+ "react",
242262
+ "react-dom",
242263
+ "react/",
242264
+ "@next/",
242265
+ "@vercel/",
242266
+ "@modelcontextprotocol/",
242267
+ "@typescript-eslint/",
242268
+ "@base-ui/",
242269
+ "hono",
242270
+ "hono/",
242271
+ "zod",
242272
+ "openai",
242273
+ "pino",
242274
+ "pino/",
242275
+ "kysely",
242276
+ "p-retry",
242277
+ "simple-git",
242278
+ "dorchester",
242279
+ "framer-motion",
242280
+ "lucide-react",
242281
+ "mathjs",
242282
+ "katex",
242283
+ "tailwindcss",
242284
+ "typescript",
242285
+ "tsup",
242286
+ "tsx",
242287
+ "vitest",
242288
+ "jest",
242289
+ "payhip",
242290
+ "stripe",
242291
+ "@stripe/"
242292
+ ];
242293
+ function isExternalImport(target) {
242294
+ if (!target.includes("/") && !target.startsWith(".")) return true;
242295
+ for (const prefix of EXTERNAL_PREFIXES) {
242296
+ if (target.startsWith(prefix)) return true;
242297
+ }
242298
+ if (target.endsWith(".css") || target.endsWith(".scss") || target.endsWith(".svg")) return true;
242299
+ return false;
242300
+ }
242301
+ function isBarrelFile(filePath) {
242302
+ return filePath.endsWith("/index.ts") || filePath.endsWith("/index.js") || filePath === "index.ts" || filePath === "index.js";
242303
+ }
242244
242304
  function detectCycles(graph) {
242245
242305
  const adjMap = /* @__PURE__ */ new Map();
242246
242306
  for (const edge of graph.edges) {
@@ -242261,11 +242321,14 @@ function detectCycles(graph) {
242261
242321
  const visited = /* @__PURE__ */ new Set();
242262
242322
  const inStack = /* @__PURE__ */ new Set();
242263
242323
  const cyclePaths = [];
242324
+ const MAX_CYCLES = 20;
242264
242325
  function dfs(nodeId, path7) {
242326
+ if (cyclePaths.length >= MAX_CYCLES) return;
242265
242327
  visited.add(nodeId);
242266
242328
  inStack.add(nodeId);
242267
242329
  path7.push(nodeId);
242268
242330
  for (const neighbor of adjMap.get(nodeId) ?? []) {
242331
+ if (cyclePaths.length >= MAX_CYCLES) break;
242269
242332
  if (!visited.has(neighbor)) {
242270
242333
  dfs(neighbor, [...path7]);
242271
242334
  } else if (inStack.has(neighbor)) {
@@ -242278,6 +242341,7 @@ function detectCycles(graph) {
242278
242341
  inStack.delete(nodeId);
242279
242342
  }
242280
242343
  for (const node of graph.nodes) {
242344
+ if (cyclePaths.length >= MAX_CYCLES) break;
242281
242345
  if (!visited.has(node.id)) {
242282
242346
  dfs(node.id, []);
242283
242347
  }
@@ -242291,57 +242355,67 @@ function detectDeadCode(graph, fileIndex) {
242291
242355
  incomingCount.set(edge.to, (incomingCount.get(edge.to) ?? 0) + 1);
242292
242356
  }
242293
242357
  const testFiles = new Set(fileIndex.filter((f) => f.role === "test").map((f) => f.path));
242294
- const entryPoints = new Set(
242295
- graph.nodes.filter((n) => n.is_entry_point).map((n) => n.id)
242296
- );
242358
+ const entryPoints = new Set(graph.nodes.filter((n) => n.is_entry_point).map((n) => n.id));
242359
+ const barrelFiles = new Set(fileIndex.filter((f) => isBarrelFile(f.path)).map((f) => f.path));
242297
242360
  const findings = [];
242361
+ const MAX_DEAD_CODE_PER_FILE = 3;
242362
+ const deadCountPerFile = /* @__PURE__ */ new Map();
242298
242363
  for (const node of graph.nodes) {
242299
242364
  if (node.kind === "file") continue;
242365
+ if (testFiles.has(node.file)) continue;
242366
+ if (entryPoints.has(node.id)) continue;
242367
+ if (node.is_exported && barrelFiles.has(node.file)) continue;
242368
+ if (node.is_exported) continue;
242300
242369
  const incoming = incomingCount.get(node.id) ?? 0;
242301
- if (incoming === 0 && !entryPoints.has(node.id) && !testFiles.has(node.file)) {
242302
- const isExported = node.is_exported;
242303
- findings.push({
242304
- id: (0, import_crypto2.randomUUID)(),
242305
- type: "dead_code",
242306
- severity: isExported ? "low" : "medium",
242307
- file: node.file,
242308
- line_start: node.line_start,
242309
- line_end: node.line_end,
242310
- symbol: node.id,
242311
- title: `Dead code: ${node.name}`,
242312
- description: `Symbol '${node.name}' has no incoming references and is not an entry point.`,
242313
- raw_data: { incoming_edge_count: 0, last_referenced_at: null },
242314
- source_component: "deepstrike",
242315
- is_structural: true
242316
- });
242317
- }
242370
+ if (incoming > 0) continue;
242371
+ const fileCount = deadCountPerFile.get(node.file) ?? 0;
242372
+ if (fileCount >= MAX_DEAD_CODE_PER_FILE) continue;
242373
+ deadCountPerFile.set(node.file, fileCount + 1);
242374
+ findings.push({
242375
+ id: (0, import_crypto2.randomUUID)(),
242376
+ type: "dead_code",
242377
+ severity: "low",
242378
+ file: node.file,
242379
+ line_start: node.line_start,
242380
+ line_end: node.line_end,
242381
+ symbol: node.id,
242382
+ title: `Dead code: ${node.name}`,
242383
+ description: `Symbol '${node.name}' has no incoming references and is not exported or an entry point.`,
242384
+ raw_data: { incoming_edge_count: 0, last_referenced_at: null },
242385
+ source_component: "deepstrike",
242386
+ is_structural: true
242387
+ });
242318
242388
  }
242319
242389
  return findings;
242320
242390
  }
242321
242391
  function detectMissingSymbols(graph, knownNodeIds) {
242322
242392
  const findings = [];
242393
+ const seen = /* @__PURE__ */ new Set();
242394
+ const MAX_MISSING = 30;
242323
242395
  for (const edge of graph.edges) {
242324
242396
  if (edge.kind !== "import") continue;
242325
- if (!edge.to.includes("/") && !edge.to.startsWith(".")) continue;
242326
- if (!knownNodeIds.has(edge.to)) {
242327
- findings.push({
242328
- id: (0, import_crypto2.randomUUID)(),
242329
- type: "missing_symbol",
242330
- severity: "high",
242331
- file: edge.file,
242332
- line_start: edge.line,
242333
- line_end: edge.line,
242334
- symbol: null,
242335
- title: `Unresolved import: ${edge.to}`,
242336
- description: `Import target '${edge.to}' could not be resolved in the dependency graph.`,
242337
- raw_data: {
242338
- import_statement: edge.to,
242339
- attempted_resolution: edge.to
242340
- },
242341
- source_component: "deepstrike",
242342
- is_structural: true
242343
- });
242344
- }
242397
+ if (isExternalImport(edge.to)) continue;
242398
+ if (knownNodeIds.has(edge.to)) continue;
242399
+ if (seen.has(edge.to)) continue;
242400
+ if (findings.length >= MAX_MISSING) break;
242401
+ seen.add(edge.to);
242402
+ findings.push({
242403
+ id: (0, import_crypto2.randomUUID)(),
242404
+ type: "missing_symbol",
242405
+ severity: "medium",
242406
+ file: edge.file,
242407
+ line_start: edge.line,
242408
+ line_end: edge.line,
242409
+ symbol: null,
242410
+ title: `Unresolved import: ${edge.to}`,
242411
+ description: `Import target '${edge.to}' could not be resolved. May indicate a missing file, broken alias, or uninstalled dependency.`,
242412
+ raw_data: {
242413
+ import_statement: edge.to,
242414
+ attempted_resolution: edge.to
242415
+ },
242416
+ source_component: "deepstrike",
242417
+ is_structural: true
242418
+ });
242345
242419
  }
242346
242420
  return findings;
242347
242421
  }
@@ -242360,7 +242434,7 @@ function buildCycleFindings(cyclePaths, nodes) {
242360
242434
  line_end: null,
242361
242435
  symbol: cycle[0],
242362
242436
  title: `Circular dependency (${cycle.length} nodes)`,
242363
- description: `Cycle: ${cycle.slice(0, 3).join(" \u2192 ")}${cycle.length > 3 ? " ..." : ""}`,
242437
+ description: `Cycle: ${cycle.slice(0, 4).join(" \u2192 ")}${cycle.length > 4 ? " ..." : ""}`,
242364
242438
  raw_data: { cycle_path: cycle, cycle_length: cycle.length },
242365
242439
  source_component: "deepstrike",
242366
242440
  is_structural: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openkrak-mcp",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "OpenKrak MCP Server - AI coding intelligence via Dorchester engine",
5
5
  "mcpName": "io.github.FrnzJulianBergmann/openkrak",
6
6
  "type": "commonjs",