trace-mcp 1.13.0 → 1.14.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/dist/cli.js CHANGED
@@ -5006,7 +5006,7 @@ import https from "https";
5006
5006
  import { spawnSync } from "child_process";
5007
5007
  import path3 from "path";
5008
5008
  import fs5 from "fs";
5009
- var CURRENT_VERSION = true ? "1.13.0" : "0.0.0-dev";
5009
+ var CURRENT_VERSION = true ? "1.14.1" : "0.0.0-dev";
5010
5010
  var UPDATE_CACHE_PATH = path3.join(TRACE_MCP_HOME, "update-check.json");
5011
5011
  function readCache() {
5012
5012
  try {
@@ -10695,6 +10695,21 @@ var IndexingPipeline = class _IndexingPipeline {
10695
10695
  absolute: false,
10696
10696
  onlyFiles: true
10697
10697
  });
10698
+ if (entries.length === 0) {
10699
+ const deepPatterns = this.config.include.filter((p5) => !p5.startsWith("**/")).map((p5) => `**/${p5}`);
10700
+ if (deepPatterns.length > 0) {
10701
+ entries = await fg3(deepPatterns, {
10702
+ cwd: this.rootPath,
10703
+ ignore,
10704
+ dot: false,
10705
+ absolute: false,
10706
+ onlyFiles: true
10707
+ });
10708
+ if (entries.length > 0) {
10709
+ logger.info({ count: entries.length, root: this.rootPath }, "Workspace root detected \u2014 using deep glob patterns");
10710
+ }
10711
+ }
10712
+ }
10698
10713
  if (this._traceignore) {
10699
10714
  const ti = this._traceignore;
10700
10715
  entries = entries.filter((e) => !ti.isIgnored(e));
@@ -13324,6 +13339,7 @@ import fs28 from "fs";
13324
13339
  // src/topology/contract-parser.ts
13325
13340
  import fs23 from "fs";
13326
13341
  import path27 from "path";
13342
+ import Database2 from "better-sqlite3";
13327
13343
  var EXCLUDE_DIRS = ["node_modules", "vendor", ".git", "dist", "build", "__pycache__"];
13328
13344
  function parseContracts(repoRoot) {
13329
13345
  const contracts = [];
@@ -13528,6 +13544,36 @@ function findSpecFiles(root) {
13528
13544
  walk2(root, 0);
13529
13545
  return results;
13530
13546
  }
13547
+ function extractRoutesFromDb(dbPath) {
13548
+ if (!fs23.existsSync(dbPath)) return null;
13549
+ try {
13550
+ const db = new Database2(dbPath, { readonly: true });
13551
+ try {
13552
+ const rows = db.prepare(
13553
+ "SELECT method, uri, name FROM routes ORDER BY uri"
13554
+ ).all();
13555
+ if (rows.length === 0) return null;
13556
+ const endpoints = rows.map((r) => ({
13557
+ method: r.method === "ANY" ? null : r.method,
13558
+ path: r.uri.startsWith("/") ? r.uri : `/${r.uri}`,
13559
+ operationId: r.name ?? void 0
13560
+ }));
13561
+ logger.debug({ dbPath, count: endpoints.length }, "Extracted routes from trace-mcp DB");
13562
+ return {
13563
+ type: "framework_routes",
13564
+ specPath: dbPath,
13565
+ version: "auto",
13566
+ endpoints,
13567
+ events: []
13568
+ };
13569
+ } finally {
13570
+ db.close();
13571
+ }
13572
+ } catch (e) {
13573
+ logger.warn({ dbPath, error: e.message }, "Failed to extract routes from DB");
13574
+ return null;
13575
+ }
13576
+ }
13531
13577
 
13532
13578
  // src/topology/service-detector.ts
13533
13579
  import fs25 from "fs";
@@ -14027,7 +14073,7 @@ function scanFileContent(filePath, content, results) {
14027
14073
 
14028
14074
  // src/federation/federated-search.ts
14029
14075
  import fs27 from "fs";
14030
- import Database2 from "better-sqlite3";
14076
+ import Database3 from "better-sqlite3";
14031
14077
  function federatedSearch(topoStore, query, filters, limit = 20) {
14032
14078
  const repos = topoStore.getAllFederatedRepos();
14033
14079
  const allItems = [];
@@ -14036,7 +14082,7 @@ function federatedSearch(topoStore, query, filters, limit = 20) {
14036
14082
  if (!repo.db_path || !fs27.existsSync(repo.db_path)) continue;
14037
14083
  let db = null;
14038
14084
  try {
14039
- db = new Database2(repo.db_path, { readonly: true });
14085
+ db = new Database3(repo.db_path, { readonly: true });
14040
14086
  db.pragma("busy_timeout = 3000");
14041
14087
  const ftsResults = searchFts(db, query, limit, 0, {
14042
14088
  kind: filters?.kind,
@@ -14081,7 +14127,7 @@ function federatedSearch(topoStore, query, filters, limit = 20) {
14081
14127
  }
14082
14128
 
14083
14129
  // src/federation/federation-helpers.ts
14084
- import Database3 from "better-sqlite3";
14130
+ import Database4 from "better-sqlite3";
14085
14131
 
14086
14132
  // src/federation/schema-diff.ts
14087
14133
  function diffSchemas(oldSchema, newSchema, pathPrefix = "") {
@@ -14307,7 +14353,7 @@ function detectBreakingChanges2(topoStore, ep) {
14307
14353
  function resolveSymbolsAtLocation(dbPath, filePath, line) {
14308
14354
  if (!line) return [];
14309
14355
  try {
14310
- const db = new Database3(dbPath, { readonly: true });
14356
+ const db = new Database4(dbPath, { readonly: true });
14311
14357
  try {
14312
14358
  const rows = db.prepare(`
14313
14359
  SELECT s.symbol_id, s.name, s.kind, s.fqn
@@ -14546,6 +14592,11 @@ var FederationManager = class {
14546
14592
  }
14547
14593
  }
14548
14594
  }
14595
+ if (contracts.length === 0) {
14596
+ const dbPath = getDbPath(serviceRoot);
14597
+ const fromDb = extractRoutesFromDb(dbPath);
14598
+ if (fromDb) contracts.push(fromDb);
14599
+ }
14549
14600
  for (const contract of contracts) {
14550
14601
  const contractId = this.topoStore.insertContract(serviceId, {
14551
14602
  contractType: contract.type,
@@ -14665,7 +14716,14 @@ var FederationManager = class {
14665
14716
  for (const call of linkedCalls) {
14666
14717
  const targetEndpoint = this.topoStore.getAllEndpoints().find((e) => e.id === call.matched_endpoint_id);
14667
14718
  if (!targetEndpoint) continue;
14668
- const sourceService = services.find((s) => s.repo_root === repo.repo_root);
14719
+ const repoRoot = repo.repo_root.endsWith("/") ? repo.repo_root : `${repo.repo_root}/`;
14720
+ const callPath = call.file_path.startsWith("/") ? call.file_path : `/${call.file_path}`;
14721
+ const candidates = services.filter((s) => {
14722
+ if (s.repo_root === repo.repo_root) return true;
14723
+ const svcRoot = s.repo_root.endsWith("/") ? s.repo_root : `${s.repo_root}/`;
14724
+ return callPath.startsWith(svcRoot) || call.file_path.startsWith(svcRoot);
14725
+ });
14726
+ const sourceService = candidates.sort((a, b) => b.repo_root.length - a.repo_root.length)[0];
14669
14727
  if (!sourceService || sourceService.id === targetEndpoint.service_id) continue;
14670
14728
  this.topoStore.insertCrossServiceEdge({
14671
14729
  sourceServiceId: sourceService.id,
@@ -29345,7 +29403,7 @@ function registerAITools(server, ctx) {
29345
29403
  }
29346
29404
 
29347
29405
  // src/bundles.ts
29348
- import Database4 from "better-sqlite3";
29406
+ import Database5 from "better-sqlite3";
29349
29407
  import path51 from "path";
29350
29408
  import fs42 from "fs";
29351
29409
  import crypto5 from "crypto";
@@ -29376,9 +29434,9 @@ function saveManifest(manifest) {
29376
29434
  function exportBundle(sourceDbPath, packageName, version) {
29377
29435
  ensureBundlesDir();
29378
29436
  const bundlePath = getBundlePath(packageName, version);
29379
- const src = new Database4(sourceDbPath, { readonly: true });
29437
+ const src = new Database5(sourceDbPath, { readonly: true });
29380
29438
  if (fs42.existsSync(bundlePath)) fs42.unlinkSync(bundlePath);
29381
- const dst = new Database4(bundlePath);
29439
+ const dst = new Database5(bundlePath);
29382
29440
  dst.pragma("journal_mode = WAL");
29383
29441
  dst.pragma("synchronous = OFF");
29384
29442
  dst.exec(`
@@ -29560,7 +29618,7 @@ function loadBundle(packageName, version) {
29560
29618
  const bundlePath = getBundlePath(packageName, version);
29561
29619
  if (!fs42.existsSync(bundlePath)) return null;
29562
29620
  try {
29563
- const db = new Database4(bundlePath, { readonly: true });
29621
+ const db = new Database5(bundlePath, { readonly: true });
29564
29622
  return { package: packageName, version, db };
29565
29623
  } catch (e) {
29566
29624
  logger.warn({ package: packageName, version, error: e }, "Failed to load bundle");
@@ -29611,7 +29669,7 @@ function searchBundles(bundles, query, opts = {}) {
29611
29669
  }
29612
29670
 
29613
29671
  // src/analytics/analytics-store.ts
29614
- import Database5 from "better-sqlite3";
29672
+ import Database6 from "better-sqlite3";
29615
29673
  import path52 from "path";
29616
29674
  var ANALYTICS_DB_PATH = path52.join(TRACE_MCP_HOME, "analytics.db");
29617
29675
  var SCHEMA_SQL = `
@@ -29661,7 +29719,7 @@ var AnalyticsStore = class {
29661
29719
  constructor(dbPath) {
29662
29720
  ensureGlobalDirs();
29663
29721
  const p5 = dbPath ?? ANALYTICS_DB_PATH;
29664
- this.db = new Database5(p5);
29722
+ this.db = new Database6(p5);
29665
29723
  this.db.pragma("journal_mode = WAL");
29666
29724
  this.db.pragma("foreign_keys = OFF");
29667
29725
  this.db.exec(SCHEMA_SQL);
@@ -32648,7 +32706,7 @@ function registerSessionTools(server, ctx) {
32648
32706
  }
32649
32707
 
32650
32708
  // src/topology/topology-db.ts
32651
- import Database6 from "better-sqlite3";
32709
+ import Database7 from "better-sqlite3";
32652
32710
  var TOPOLOGY_DDL = `
32653
32711
  CREATE TABLE IF NOT EXISTS services (
32654
32712
  id INTEGER PRIMARY KEY,
@@ -32798,7 +32856,7 @@ function findBestEndpointMatch(urlPattern, method, endpoints) {
32798
32856
  var TopologyStore = class {
32799
32857
  db;
32800
32858
  constructor(dbPath) {
32801
- this.db = new Database6(dbPath);
32859
+ this.db = new Database7(dbPath);
32802
32860
  this.db.pragma("journal_mode = WAL");
32803
32861
  this.db.pragma("foreign_keys = ON");
32804
32862
  this.db.pragma("busy_timeout = 5000");
@@ -33154,7 +33212,7 @@ var TopologyStore = class {
33154
33212
  };
33155
33213
 
33156
33214
  // src/server/server.ts
33157
- var PKG_VERSION = true ? "1.13.0" : "0.0.0-dev";
33215
+ var PKG_VERSION = true ? "1.14.1" : "0.0.0-dev";
33158
33216
  function j2(value) {
33159
33217
  return JSON.stringify(value, (_key, val) => val === null || val === void 0 ? void 0 : val);
33160
33218
  }
@@ -65910,7 +65968,7 @@ function installTweakccPrompts(opts) {
65910
65968
  import fs93 from "fs";
65911
65969
  import path103 from "path";
65912
65970
  import os10 from "os";
65913
- import Database7 from "better-sqlite3";
65971
+ import Database8 from "better-sqlite3";
65914
65972
  var HOME3 = os10.homedir();
65915
65973
  function detectProject(dir) {
65916
65974
  const projectRoot = path103.resolve(dir);
@@ -66094,7 +66152,7 @@ function detectExistingDb(root, globalDbPath) {
66094
66152
  const dbPath = candidates.find((p5) => fs93.existsSync(p5));
66095
66153
  if (!dbPath) return null;
66096
66154
  try {
66097
- const db = new Database7(dbPath, { readonly: true });
66155
+ const db = new Database8(dbPath, { readonly: true });
66098
66156
  const versionRow = db.prepare("SELECT value FROM schema_meta WHERE key = ?").get("schema_version");
66099
66157
  const schemaVersion = versionRow ? parseInt(versionRow.value, 10) : 0;
66100
66158
  const countRow = db.prepare("SELECT COUNT(*) as cnt FROM files").get();
@@ -69873,7 +69931,7 @@ function shortPath6(p5) {
69873
69931
  // src/cli/status.ts
69874
69932
  import { Command as Command11 } from "commander";
69875
69933
  import fs103 from "fs";
69876
- import Database8 from "better-sqlite3";
69934
+ import Database9 from "better-sqlite3";
69877
69935
  function resolveDbPath5(projectRoot) {
69878
69936
  const entry = getProject(projectRoot);
69879
69937
  if (entry) return entry.dbPath;
@@ -69922,7 +69980,7 @@ var statusCommand = new Command11("status").description("Show indexing progress
69922
69980
  console.log("Run `trace-mcp serve` or `trace-mcp index` first.");
69923
69981
  process.exit(1);
69924
69982
  }
69925
- const db = new Database8(dbPath, { readonly: true });
69983
+ const db = new Database9(dbPath, { readonly: true });
69926
69984
  db.pragma("journal_mode = WAL");
69927
69985
  try {
69928
69986
  const progress = readProgressFromDb(db);
@@ -70004,7 +70062,7 @@ var visualizeCommand = new Command12("visualize").alias("viz").description("Open
70004
70062
  output: outputPath
70005
70063
  });
70006
70064
  db.close();
70007
- if (!result.ok) {
70065
+ if (result.isErr()) {
70008
70066
  console.error("Error:", result.error.message);
70009
70067
  process.exit(1);
70010
70068
  }
@@ -70023,7 +70081,7 @@ visualizeCommand.command("federation").alias("fed").description("Open federation
70023
70081
  output: outputPath
70024
70082
  });
70025
70083
  topoStore.close();
70026
- if (!result.ok) {
70084
+ if (result.isErr()) {
70027
70085
  console.error("Error:", result.error.message);
70028
70086
  process.exit(1);
70029
70087
  }
@@ -70035,7 +70093,7 @@ visualizeCommand.command("federation").alias("fed").description("Open federation
70035
70093
  });
70036
70094
 
70037
70095
  // src/cli.ts
70038
- var PKG_VERSION2 = true ? "1.13.0" : "0.0.0-dev";
70096
+ var PKG_VERSION2 = true ? "1.14.1" : "0.0.0-dev";
70039
70097
  function registerDefaultPlugins(registry) {
70040
70098
  for (const p5 of createAllLanguagePlugins()) registry.registerLanguagePlugin(p5);
70041
70099
  for (const p5 of createAllIntegrationPlugins()) registry.registerFrameworkPlugin(p5);