@coderule/mcp 1.6.2 → 1.6.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-cli.cjs +91 -5
- package/dist/mcp-cli.cjs.map +1 -1
- package/dist/mcp-cli.js +91 -5
- package/dist/mcp-cli.js.map +1 -1
- package/package.json +2 -2
package/dist/mcp-cli.js
CHANGED
|
@@ -1702,7 +1702,7 @@ var ServiceRunner = class {
|
|
|
1702
1702
|
}
|
|
1703
1703
|
};
|
|
1704
1704
|
var HASH_STATES = ["clean", "dirty", "hashing", "missing"];
|
|
1705
|
-
function collectIndexingStatus(runtime, runner) {
|
|
1705
|
+
async function collectIndexingStatus(runtime, runner) {
|
|
1706
1706
|
const byState = {};
|
|
1707
1707
|
for (const state of HASH_STATES) {
|
|
1708
1708
|
byState[state] = runtime.filesRepo.countByState(state);
|
|
@@ -1715,6 +1715,20 @@ function collectIndexingStatus(runtime, runner) {
|
|
|
1715
1715
|
done: queue.countByStatus(JobStatus.Done),
|
|
1716
1716
|
failed: queue.countByStatus(JobStatus.Failed)
|
|
1717
1717
|
};
|
|
1718
|
+
const latestSnapshot = runtime.snapshotsRepo.getLatest() ?? null;
|
|
1719
|
+
let serverStatus = null;
|
|
1720
|
+
if (latestSnapshot) {
|
|
1721
|
+
try {
|
|
1722
|
+
serverStatus = await runtime.clients.sync.checkSnapshotStatus(
|
|
1723
|
+
latestSnapshot.snapshot_hash
|
|
1724
|
+
);
|
|
1725
|
+
} catch (error) {
|
|
1726
|
+
runtime.logger.warn(
|
|
1727
|
+
{ err: error, snapshotHash: latestSnapshot.snapshot_hash },
|
|
1728
|
+
"Failed to fetch server snapshot status"
|
|
1729
|
+
);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1718
1732
|
return {
|
|
1719
1733
|
timestamp: Date.now(),
|
|
1720
1734
|
root: {
|
|
@@ -1725,7 +1739,8 @@ function collectIndexingStatus(runtime, runner) {
|
|
|
1725
1739
|
total,
|
|
1726
1740
|
byState
|
|
1727
1741
|
},
|
|
1728
|
-
latestSnapshot
|
|
1742
|
+
latestSnapshot,
|
|
1743
|
+
serverStatus,
|
|
1729
1744
|
queue: queueCounts,
|
|
1730
1745
|
service: runner.getServiceStateSnapshot()
|
|
1731
1746
|
};
|
|
@@ -1762,6 +1777,60 @@ function formatStatus(status) {
|
|
|
1762
1777
|
lines.push(
|
|
1763
1778
|
` Created: ${new Date(status.latestSnapshot.created_at).toISOString()}`
|
|
1764
1779
|
);
|
|
1780
|
+
if (status.serverStatus) {
|
|
1781
|
+
lines.push(` Server Status: ${status.serverStatus.status}`);
|
|
1782
|
+
if (status.serverStatus.status === "READY" && status.serverStatus.timing) {
|
|
1783
|
+
lines.push("");
|
|
1784
|
+
lines.push(" Indexing Performance:");
|
|
1785
|
+
const timing = status.serverStatus.timing;
|
|
1786
|
+
if (timing.pass1 !== void 0) {
|
|
1787
|
+
lines.push(
|
|
1788
|
+
` Pass 1 (File Discovery): ${formatDuration(timing.pass1)}`
|
|
1789
|
+
);
|
|
1790
|
+
}
|
|
1791
|
+
if (timing.gap !== void 0) {
|
|
1792
|
+
lines.push(` Gap (Waiting): ${formatDuration(timing.gap)}`);
|
|
1793
|
+
}
|
|
1794
|
+
if (timing.pass2 !== void 0) {
|
|
1795
|
+
lines.push(
|
|
1796
|
+
` Pass 2 (Cross-Reference): ${formatDuration(timing.pass2)}`
|
|
1797
|
+
);
|
|
1798
|
+
}
|
|
1799
|
+
if (timing.pass2db !== void 0) {
|
|
1800
|
+
lines.push(
|
|
1801
|
+
` Pass 2 DB Operations: ${formatDuration(timing.pass2db)}`
|
|
1802
|
+
);
|
|
1803
|
+
}
|
|
1804
|
+
const totalTime = (timing.pass1 ?? 0) + (timing.gap ?? 0) + (timing.pass2 ?? 0);
|
|
1805
|
+
if (totalTime > 0) {
|
|
1806
|
+
lines.push(` Total Time: ${formatDuration(totalTime)}`);
|
|
1807
|
+
}
|
|
1808
|
+
lines.push("");
|
|
1809
|
+
lines.push(" Indexing Summary:");
|
|
1810
|
+
if (timing.total_files !== void 0) {
|
|
1811
|
+
lines.push(
|
|
1812
|
+
` Files Indexed: ${timing.total_files.toLocaleString()}`
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1815
|
+
if (timing.total_chunks !== void 0) {
|
|
1816
|
+
lines.push(
|
|
1817
|
+
` Chunks Created: ${timing.total_chunks.toLocaleString()}`
|
|
1818
|
+
);
|
|
1819
|
+
}
|
|
1820
|
+
if (timing.total_classes !== void 0) {
|
|
1821
|
+
lines.push(
|
|
1822
|
+
` Classes Found: ${timing.total_classes.toLocaleString()}`
|
|
1823
|
+
);
|
|
1824
|
+
}
|
|
1825
|
+
if (timing.total_methods !== void 0) {
|
|
1826
|
+
lines.push(
|
|
1827
|
+
` Methods Found: ${timing.total_methods.toLocaleString()}`
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
} else if (status.serverStatus.message) {
|
|
1831
|
+
lines.push(` Message: ${status.serverStatus.message}`);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1765
1834
|
} else {
|
|
1766
1835
|
lines.push("Latest Snapshot: None");
|
|
1767
1836
|
}
|
|
@@ -1787,6 +1856,19 @@ function formatBytes(bytes) {
|
|
|
1787
1856
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1788
1857
|
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${units[i]}`;
|
|
1789
1858
|
}
|
|
1859
|
+
function formatDuration(seconds) {
|
|
1860
|
+
if (seconds < 1e-3) return "<1ms";
|
|
1861
|
+
if (seconds < 1) return `${(seconds * 1e3).toFixed(0)}ms`;
|
|
1862
|
+
if (seconds < 60) return `${seconds.toFixed(2)}s`;
|
|
1863
|
+
const minutes = Math.floor(seconds / 60);
|
|
1864
|
+
const remainingSeconds = seconds % 60;
|
|
1865
|
+
if (minutes < 60) {
|
|
1866
|
+
return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
|
|
1867
|
+
}
|
|
1868
|
+
const hours = Math.floor(minutes / 60);
|
|
1869
|
+
const remainingMinutes = minutes % 60;
|
|
1870
|
+
return `${hours}h ${remainingMinutes}m ${remainingSeconds.toFixed(0)}s`;
|
|
1871
|
+
}
|
|
1790
1872
|
|
|
1791
1873
|
// src/mcp/server.ts
|
|
1792
1874
|
var SERVER_NAME = "coderule-scanner-mcp";
|
|
@@ -1839,7 +1921,7 @@ function createMcpServer({
|
|
|
1839
1921
|
inputSchema: {}
|
|
1840
1922
|
},
|
|
1841
1923
|
async () => {
|
|
1842
|
-
const status = collectIndexingStatus(runtime, runner);
|
|
1924
|
+
const status = await collectIndexingStatus(runtime, runner);
|
|
1843
1925
|
const text = formatStatus(status);
|
|
1844
1926
|
return {
|
|
1845
1927
|
content: [{ type: "text", text }]
|
|
@@ -1864,7 +1946,9 @@ function createMcpServer({
|
|
|
1864
1946
|
const deadline = Date.now() + runtime.config.maxQueryWaitMs;
|
|
1865
1947
|
const latest = await waitForLocalSnapshot(deadline);
|
|
1866
1948
|
if (!latest) {
|
|
1867
|
-
const statusText = formatStatus(
|
|
1949
|
+
const statusText = formatStatus(
|
|
1950
|
+
await collectIndexingStatus(runtime, runner)
|
|
1951
|
+
);
|
|
1868
1952
|
const text = `We are not ready....
|
|
1869
1953
|
${statusText}`;
|
|
1870
1954
|
return { content: [{ type: "text", text }] };
|
|
@@ -1874,7 +1958,9 @@ ${statusText}`;
|
|
|
1874
1958
|
deadline
|
|
1875
1959
|
);
|
|
1876
1960
|
if (!readyHash) {
|
|
1877
|
-
const statusText = formatStatus(
|
|
1961
|
+
const statusText = formatStatus(
|
|
1962
|
+
await collectIndexingStatus(runtime, runner)
|
|
1963
|
+
);
|
|
1878
1964
|
const text = `We are not ready....
|
|
1879
1965
|
${statusText}`;
|
|
1880
1966
|
return { content: [{ type: "text", text }] };
|