@coderule/mcp 1.6.2 → 1.6.4

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-cli.js CHANGED
@@ -1046,6 +1046,11 @@ async function walkDirectory(current, opts, stats) {
1046
1046
  stats.skipped += 1;
1047
1047
  continue;
1048
1048
  }
1049
+ if (stat.size === 0) {
1050
+ stats.skipped += 1;
1051
+ dirLogger.debug({ relPath }, "Skipping zero-length file");
1052
+ continue;
1053
+ }
1049
1054
  const target = dirent.isSymbolicLink() ? await readSymlinkTarget(absPath, dirLogger) : null;
1050
1055
  const state = opts.filesRepo.upsertFromStat({
1051
1056
  relPath,
@@ -1564,6 +1569,13 @@ var ServiceRunner = class {
1564
1569
  this.runtime.logger.debug({ relPath }, "Watcher event ignored by rules");
1565
1570
  return;
1566
1571
  }
1572
+ if (fileStats.size === 0) {
1573
+ this.runtime.logger.debug(
1574
+ { relPath },
1575
+ "Watcher skipping zero-length file"
1576
+ );
1577
+ return;
1578
+ }
1567
1579
  const isSymlink = fileStats.isSymbolicLink();
1568
1580
  const target = isSymlink ? await readSymlinkTarget2(absPath) : null;
1569
1581
  const state = this.runtime.filesRepo.upsertFromStat({
@@ -1702,7 +1714,7 @@ var ServiceRunner = class {
1702
1714
  }
1703
1715
  };
1704
1716
  var HASH_STATES = ["clean", "dirty", "hashing", "missing"];
1705
- function collectIndexingStatus(runtime, runner) {
1717
+ async function collectIndexingStatus(runtime, runner) {
1706
1718
  const byState = {};
1707
1719
  for (const state of HASH_STATES) {
1708
1720
  byState[state] = runtime.filesRepo.countByState(state);
@@ -1715,6 +1727,20 @@ function collectIndexingStatus(runtime, runner) {
1715
1727
  done: queue.countByStatus(JobStatus.Done),
1716
1728
  failed: queue.countByStatus(JobStatus.Failed)
1717
1729
  };
1730
+ const latestSnapshot = runtime.snapshotsRepo.getLatest() ?? null;
1731
+ let serverStatus = null;
1732
+ if (latestSnapshot) {
1733
+ try {
1734
+ serverStatus = await runtime.clients.sync.checkSnapshotStatus(
1735
+ latestSnapshot.snapshot_hash
1736
+ );
1737
+ } catch (error) {
1738
+ runtime.logger.warn(
1739
+ { err: error, snapshotHash: latestSnapshot.snapshot_hash },
1740
+ "Failed to fetch server snapshot status"
1741
+ );
1742
+ }
1743
+ }
1718
1744
  return {
1719
1745
  timestamp: Date.now(),
1720
1746
  root: {
@@ -1725,7 +1751,8 @@ function collectIndexingStatus(runtime, runner) {
1725
1751
  total,
1726
1752
  byState
1727
1753
  },
1728
- latestSnapshot: runtime.snapshotsRepo.getLatest() ?? null,
1754
+ latestSnapshot,
1755
+ serverStatus,
1729
1756
  queue: queueCounts,
1730
1757
  service: runner.getServiceStateSnapshot()
1731
1758
  };
@@ -1762,6 +1789,60 @@ function formatStatus(status) {
1762
1789
  lines.push(
1763
1790
  ` Created: ${new Date(status.latestSnapshot.created_at).toISOString()}`
1764
1791
  );
1792
+ if (status.serverStatus) {
1793
+ lines.push(` Server Status: ${status.serverStatus.status}`);
1794
+ if (status.serverStatus.status === "READY" && status.serverStatus.timing) {
1795
+ lines.push("");
1796
+ lines.push(" Indexing Performance:");
1797
+ const timing = status.serverStatus.timing;
1798
+ if (timing.pass1 !== void 0) {
1799
+ lines.push(
1800
+ ` Pass 1 (File Discovery): ${formatDuration(timing.pass1)}`
1801
+ );
1802
+ }
1803
+ if (timing.gap !== void 0) {
1804
+ lines.push(` Gap (Waiting): ${formatDuration(timing.gap)}`);
1805
+ }
1806
+ if (timing.pass2 !== void 0) {
1807
+ lines.push(
1808
+ ` Pass 2 (Cross-Reference): ${formatDuration(timing.pass2)}`
1809
+ );
1810
+ }
1811
+ if (timing.pass2db !== void 0) {
1812
+ lines.push(
1813
+ ` Pass 2 DB Operations: ${formatDuration(timing.pass2db)}`
1814
+ );
1815
+ }
1816
+ const totalTime = (timing.pass1 ?? 0) + (timing.gap ?? 0) + (timing.pass2 ?? 0);
1817
+ if (totalTime > 0) {
1818
+ lines.push(` Total Time: ${formatDuration(totalTime)}`);
1819
+ }
1820
+ lines.push("");
1821
+ lines.push(" Indexing Summary:");
1822
+ if (timing.total_files !== void 0) {
1823
+ lines.push(
1824
+ ` Files Indexed: ${timing.total_files.toLocaleString()}`
1825
+ );
1826
+ }
1827
+ if (timing.total_chunks !== void 0) {
1828
+ lines.push(
1829
+ ` Chunks Created: ${timing.total_chunks.toLocaleString()}`
1830
+ );
1831
+ }
1832
+ if (timing.total_classes !== void 0) {
1833
+ lines.push(
1834
+ ` Classes Found: ${timing.total_classes.toLocaleString()}`
1835
+ );
1836
+ }
1837
+ if (timing.total_methods !== void 0) {
1838
+ lines.push(
1839
+ ` Methods Found: ${timing.total_methods.toLocaleString()}`
1840
+ );
1841
+ }
1842
+ } else if (status.serverStatus.message) {
1843
+ lines.push(` Message: ${status.serverStatus.message}`);
1844
+ }
1845
+ }
1765
1846
  } else {
1766
1847
  lines.push("Latest Snapshot: None");
1767
1848
  }
@@ -1787,6 +1868,19 @@ function formatBytes(bytes) {
1787
1868
  const i = Math.floor(Math.log(bytes) / Math.log(k));
1788
1869
  return `${(bytes / Math.pow(k, i)).toFixed(2)} ${units[i]}`;
1789
1870
  }
1871
+ function formatDuration(seconds) {
1872
+ if (seconds < 1e-3) return "<1ms";
1873
+ if (seconds < 1) return `${(seconds * 1e3).toFixed(0)}ms`;
1874
+ if (seconds < 60) return `${seconds.toFixed(2)}s`;
1875
+ const minutes = Math.floor(seconds / 60);
1876
+ const remainingSeconds = seconds % 60;
1877
+ if (minutes < 60) {
1878
+ return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
1879
+ }
1880
+ const hours = Math.floor(minutes / 60);
1881
+ const remainingMinutes = minutes % 60;
1882
+ return `${hours}h ${remainingMinutes}m ${remainingSeconds.toFixed(0)}s`;
1883
+ }
1790
1884
 
1791
1885
  // src/mcp/server.ts
1792
1886
  var SERVER_NAME = "coderule-scanner-mcp";
@@ -1839,7 +1933,7 @@ function createMcpServer({
1839
1933
  inputSchema: {}
1840
1934
  },
1841
1935
  async () => {
1842
- const status = collectIndexingStatus(runtime, runner);
1936
+ const status = await collectIndexingStatus(runtime, runner);
1843
1937
  const text = formatStatus(status);
1844
1938
  return {
1845
1939
  content: [{ type: "text", text }]
@@ -1864,7 +1958,9 @@ function createMcpServer({
1864
1958
  const deadline = Date.now() + runtime.config.maxQueryWaitMs;
1865
1959
  const latest = await waitForLocalSnapshot(deadline);
1866
1960
  if (!latest) {
1867
- const statusText = formatStatus(collectIndexingStatus(runtime, runner));
1961
+ const statusText = formatStatus(
1962
+ await collectIndexingStatus(runtime, runner)
1963
+ );
1868
1964
  const text = `We are not ready....
1869
1965
  ${statusText}`;
1870
1966
  return { content: [{ type: "text", text }] };
@@ -1874,7 +1970,9 @@ ${statusText}`;
1874
1970
  deadline
1875
1971
  );
1876
1972
  if (!readyHash) {
1877
- const statusText = formatStatus(collectIndexingStatus(runtime, runner));
1973
+ const statusText = formatStatus(
1974
+ await collectIndexingStatus(runtime, runner)
1975
+ );
1878
1976
  const text = `We are not ready....
1879
1977
  ${statusText}`;
1880
1978
  return { content: [{ type: "text", text }] };