@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.cjs
CHANGED
|
@@ -1717,7 +1717,7 @@ var ServiceRunner = class {
|
|
|
1717
1717
|
}
|
|
1718
1718
|
};
|
|
1719
1719
|
var HASH_STATES = ["clean", "dirty", "hashing", "missing"];
|
|
1720
|
-
function collectIndexingStatus(runtime, runner) {
|
|
1720
|
+
async function collectIndexingStatus(runtime, runner) {
|
|
1721
1721
|
const byState = {};
|
|
1722
1722
|
for (const state of HASH_STATES) {
|
|
1723
1723
|
byState[state] = runtime.filesRepo.countByState(state);
|
|
@@ -1730,6 +1730,20 @@ function collectIndexingStatus(runtime, runner) {
|
|
|
1730
1730
|
done: queue.countByStatus(qulite.JobStatus.Done),
|
|
1731
1731
|
failed: queue.countByStatus(qulite.JobStatus.Failed)
|
|
1732
1732
|
};
|
|
1733
|
+
const latestSnapshot = runtime.snapshotsRepo.getLatest() ?? null;
|
|
1734
|
+
let serverStatus = null;
|
|
1735
|
+
if (latestSnapshot) {
|
|
1736
|
+
try {
|
|
1737
|
+
serverStatus = await runtime.clients.sync.checkSnapshotStatus(
|
|
1738
|
+
latestSnapshot.snapshot_hash
|
|
1739
|
+
);
|
|
1740
|
+
} catch (error) {
|
|
1741
|
+
runtime.logger.warn(
|
|
1742
|
+
{ err: error, snapshotHash: latestSnapshot.snapshot_hash },
|
|
1743
|
+
"Failed to fetch server snapshot status"
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1733
1747
|
return {
|
|
1734
1748
|
timestamp: Date.now(),
|
|
1735
1749
|
root: {
|
|
@@ -1740,7 +1754,8 @@ function collectIndexingStatus(runtime, runner) {
|
|
|
1740
1754
|
total,
|
|
1741
1755
|
byState
|
|
1742
1756
|
},
|
|
1743
|
-
latestSnapshot
|
|
1757
|
+
latestSnapshot,
|
|
1758
|
+
serverStatus,
|
|
1744
1759
|
queue: queueCounts,
|
|
1745
1760
|
service: runner.getServiceStateSnapshot()
|
|
1746
1761
|
};
|
|
@@ -1777,6 +1792,60 @@ function formatStatus(status) {
|
|
|
1777
1792
|
lines.push(
|
|
1778
1793
|
` Created: ${new Date(status.latestSnapshot.created_at).toISOString()}`
|
|
1779
1794
|
);
|
|
1795
|
+
if (status.serverStatus) {
|
|
1796
|
+
lines.push(` Server Status: ${status.serverStatus.status}`);
|
|
1797
|
+
if (status.serverStatus.status === "READY" && status.serverStatus.timing) {
|
|
1798
|
+
lines.push("");
|
|
1799
|
+
lines.push(" Indexing Performance:");
|
|
1800
|
+
const timing = status.serverStatus.timing;
|
|
1801
|
+
if (timing.pass1 !== void 0) {
|
|
1802
|
+
lines.push(
|
|
1803
|
+
` Pass 1 (File Discovery): ${formatDuration(timing.pass1)}`
|
|
1804
|
+
);
|
|
1805
|
+
}
|
|
1806
|
+
if (timing.gap !== void 0) {
|
|
1807
|
+
lines.push(` Gap (Waiting): ${formatDuration(timing.gap)}`);
|
|
1808
|
+
}
|
|
1809
|
+
if (timing.pass2 !== void 0) {
|
|
1810
|
+
lines.push(
|
|
1811
|
+
` Pass 2 (Cross-Reference): ${formatDuration(timing.pass2)}`
|
|
1812
|
+
);
|
|
1813
|
+
}
|
|
1814
|
+
if (timing.pass2db !== void 0) {
|
|
1815
|
+
lines.push(
|
|
1816
|
+
` Pass 2 DB Operations: ${formatDuration(timing.pass2db)}`
|
|
1817
|
+
);
|
|
1818
|
+
}
|
|
1819
|
+
const totalTime = (timing.pass1 ?? 0) + (timing.gap ?? 0) + (timing.pass2 ?? 0);
|
|
1820
|
+
if (totalTime > 0) {
|
|
1821
|
+
lines.push(` Total Time: ${formatDuration(totalTime)}`);
|
|
1822
|
+
}
|
|
1823
|
+
lines.push("");
|
|
1824
|
+
lines.push(" Indexing Summary:");
|
|
1825
|
+
if (timing.total_files !== void 0) {
|
|
1826
|
+
lines.push(
|
|
1827
|
+
` Files Indexed: ${timing.total_files.toLocaleString()}`
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
if (timing.total_chunks !== void 0) {
|
|
1831
|
+
lines.push(
|
|
1832
|
+
` Chunks Created: ${timing.total_chunks.toLocaleString()}`
|
|
1833
|
+
);
|
|
1834
|
+
}
|
|
1835
|
+
if (timing.total_classes !== void 0) {
|
|
1836
|
+
lines.push(
|
|
1837
|
+
` Classes Found: ${timing.total_classes.toLocaleString()}`
|
|
1838
|
+
);
|
|
1839
|
+
}
|
|
1840
|
+
if (timing.total_methods !== void 0) {
|
|
1841
|
+
lines.push(
|
|
1842
|
+
` Methods Found: ${timing.total_methods.toLocaleString()}`
|
|
1843
|
+
);
|
|
1844
|
+
}
|
|
1845
|
+
} else if (status.serverStatus.message) {
|
|
1846
|
+
lines.push(` Message: ${status.serverStatus.message}`);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1780
1849
|
} else {
|
|
1781
1850
|
lines.push("Latest Snapshot: None");
|
|
1782
1851
|
}
|
|
@@ -1802,6 +1871,19 @@ function formatBytes(bytes) {
|
|
|
1802
1871
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1803
1872
|
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${units[i]}`;
|
|
1804
1873
|
}
|
|
1874
|
+
function formatDuration(seconds) {
|
|
1875
|
+
if (seconds < 1e-3) return "<1ms";
|
|
1876
|
+
if (seconds < 1) return `${(seconds * 1e3).toFixed(0)}ms`;
|
|
1877
|
+
if (seconds < 60) return `${seconds.toFixed(2)}s`;
|
|
1878
|
+
const minutes = Math.floor(seconds / 60);
|
|
1879
|
+
const remainingSeconds = seconds % 60;
|
|
1880
|
+
if (minutes < 60) {
|
|
1881
|
+
return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
|
|
1882
|
+
}
|
|
1883
|
+
const hours = Math.floor(minutes / 60);
|
|
1884
|
+
const remainingMinutes = minutes % 60;
|
|
1885
|
+
return `${hours}h ${remainingMinutes}m ${remainingSeconds.toFixed(0)}s`;
|
|
1886
|
+
}
|
|
1805
1887
|
|
|
1806
1888
|
// src/mcp/server.ts
|
|
1807
1889
|
var SERVER_NAME = "coderule-scanner-mcp";
|
|
@@ -1854,7 +1936,7 @@ function createMcpServer({
|
|
|
1854
1936
|
inputSchema: {}
|
|
1855
1937
|
},
|
|
1856
1938
|
async () => {
|
|
1857
|
-
const status = collectIndexingStatus(runtime, runner);
|
|
1939
|
+
const status = await collectIndexingStatus(runtime, runner);
|
|
1858
1940
|
const text = formatStatus(status);
|
|
1859
1941
|
return {
|
|
1860
1942
|
content: [{ type: "text", text }]
|
|
@@ -1879,7 +1961,9 @@ function createMcpServer({
|
|
|
1879
1961
|
const deadline = Date.now() + runtime.config.maxQueryWaitMs;
|
|
1880
1962
|
const latest = await waitForLocalSnapshot(deadline);
|
|
1881
1963
|
if (!latest) {
|
|
1882
|
-
const statusText = formatStatus(
|
|
1964
|
+
const statusText = formatStatus(
|
|
1965
|
+
await collectIndexingStatus(runtime, runner)
|
|
1966
|
+
);
|
|
1883
1967
|
const text = `We are not ready....
|
|
1884
1968
|
${statusText}`;
|
|
1885
1969
|
return { content: [{ type: "text", text }] };
|
|
@@ -1889,7 +1973,9 @@ ${statusText}`;
|
|
|
1889
1973
|
deadline
|
|
1890
1974
|
);
|
|
1891
1975
|
if (!readyHash) {
|
|
1892
|
-
const statusText = formatStatus(
|
|
1976
|
+
const statusText = formatStatus(
|
|
1977
|
+
await collectIndexingStatus(runtime, runner)
|
|
1978
|
+
);
|
|
1893
1979
|
const text = `We are not ready....
|
|
1894
1980
|
${statusText}`;
|
|
1895
1981
|
return { content: [{ type: "text", text }] };
|