@coderule/mcp 1.6.3 → 1.7.0

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 CHANGED
@@ -1061,6 +1061,11 @@ async function walkDirectory(current, opts, stats) {
1061
1061
  stats.skipped += 1;
1062
1062
  continue;
1063
1063
  }
1064
+ if (stat.size === 0) {
1065
+ stats.skipped += 1;
1066
+ dirLogger.debug({ relPath }, "Skipping zero-length file");
1067
+ continue;
1068
+ }
1064
1069
  const target = dirent.isSymbolicLink() ? await readSymlinkTarget(absPath, dirLogger) : null;
1065
1070
  const state = opts.filesRepo.upsertFromStat({
1066
1071
  relPath,
@@ -1579,6 +1584,13 @@ var ServiceRunner = class {
1579
1584
  this.runtime.logger.debug({ relPath }, "Watcher event ignored by rules");
1580
1585
  return;
1581
1586
  }
1587
+ if (fileStats.size === 0) {
1588
+ this.runtime.logger.debug(
1589
+ { relPath },
1590
+ "Watcher skipping zero-length file"
1591
+ );
1592
+ return;
1593
+ }
1582
1594
  const isSymlink = fileStats.isSymbolicLink();
1583
1595
  const target = isSymlink ? await readSymlinkTarget2(absPath) : null;
1584
1596
  const state = this.runtime.filesRepo.upsertFromStat({
@@ -1931,9 +1943,21 @@ function createMcpServer({
1931
1943
  server.registerTool(
1932
1944
  "check",
1933
1945
  {
1934
- title: "Indexer status",
1935
- description: "Inspect the current indexing state, snapshot, and queue metrics",
1936
- inputSchema: {}
1946
+ title: "Coderule Indexing Status",
1947
+ description: `Check the current state of the code indexer. Returns repository info, file states (clean/dirty/hashing/missing), queue metrics, latest snapshot details, and service health.
1948
+
1949
+ Use this tool to:
1950
+ - Debug why queries are failing or returning no results
1951
+ - Verify the indexer is ready before querying
1952
+ - Check which repository is currently indexed
1953
+ - Monitor indexing progress`,
1954
+ inputSchema: {},
1955
+ annotations: {
1956
+ readOnlyHint: true,
1957
+ destructiveHint: false,
1958
+ idempotentHint: true,
1959
+ openWorldHint: false
1960
+ }
1937
1961
  },
1938
1962
  async () => {
1939
1963
  const status = await collectIndexingStatus(runtime, runner);
@@ -1943,16 +1967,51 @@ function createMcpServer({
1943
1967
  };
1944
1968
  }
1945
1969
  );
1946
- const queryInputSchema = {
1947
- query: zod.z.string().min(1, "Query text is required"),
1948
- budgetTokens: zod.z.number().int().positive().optional().describe("Token budget for retrieval (default 3000)")
1949
- };
1950
1970
  server.registerTool(
1951
1971
  "query",
1952
1972
  {
1953
- title: "Snapshot retrieval query",
1954
- description: "Execute a retrieval query against the most recent indexed snapshot",
1955
- inputSchema: queryInputSchema
1973
+ title: "Semantic Code Retrieval",
1974
+ description: `Graph-based RAG for semantic code search across the indexed codebase.
1975
+
1976
+ \u{1F6A8} CRITICAL: Use this tool FIRST before any code modification, bug fix, feature addition, or architecture exploration.
1977
+
1978
+ QUERY STRATEGY:
1979
+ Use keyword-rich technical terms, NOT natural language questions.
1980
+
1981
+ \u2705 GOOD: "JWT authentication middleware token validation security handler FastAPI"
1982
+ \u2705 GOOD: "file indexing worker celery queue job AST parser embedding chunker"
1983
+ \u2705 GOOD: "database schema SQLAlchemy model migration table column relationship"
1984
+
1985
+ \u274C BAD: "How does authentication work?"
1986
+ \u274C BAD: "Show me the login code"
1987
+
1988
+ RETRIEVAL MECHANISM:
1989
+ - Seeds: Semantic similarity via embeddings (~6 initial matches)
1990
+ - Flood: Graph propagation through AST relationships (imports, calls, inheritance)
1991
+ - Neighbors: Adjacent code chunks for context
1992
+ - Calls: Function call relationships
1993
+
1994
+ Returns 30-50 code segments with file paths, line numbers, and relevance scores.
1995
+
1996
+ DEFAULT BUDGET: 10,000 tokens (sufficient for most tasks)
1997
+
1998
+ WHEN TO USE:
1999
+ - Before modifying ANY existing code
2000
+ - Understanding system architecture
2001
+ - Finding related implementations
2002
+ - Locating tests or examples
2003
+ - Bug investigation
2004
+ - Feature implementation planning`,
2005
+ inputSchema: {
2006
+ query: zod.z.string().min(1, "Query text is required"),
2007
+ budgetTokens: zod.z.number().int().positive().optional().describe("Token budget for retrieval (default 10000)")
2008
+ },
2009
+ annotations: {
2010
+ readOnlyHint: true,
2011
+ destructiveHint: false,
2012
+ idempotentHint: true,
2013
+ openWorldHint: false
2014
+ }
1956
2015
  },
1957
2016
  async ({
1958
2017
  query,
@@ -1964,7 +2023,8 @@ function createMcpServer({
1964
2023
  const statusText = formatStatus(
1965
2024
  await collectIndexingStatus(runtime, runner)
1966
2025
  );
1967
- const text = `We are not ready....
2026
+ const text = `Indexer not ready. Current status:
2027
+
1968
2028
  ${statusText}`;
1969
2029
  return { content: [{ type: "text", text }] };
1970
2030
  }
@@ -1976,11 +2036,12 @@ ${statusText}`;
1976
2036
  const statusText = formatStatus(
1977
2037
  await collectIndexingStatus(runtime, runner)
1978
2038
  );
1979
- const text = `We are not ready....
2039
+ const text = `Snapshot not ready on server. Current status:
2040
+
1980
2041
  ${statusText}`;
1981
2042
  return { content: [{ type: "text", text }] };
1982
2043
  }
1983
- const effectiveBudget = Math.max(100, budgetTokens ?? 3e3);
2044
+ const effectiveBudget = Math.max(100, budgetTokens ?? 1e4);
1984
2045
  try {
1985
2046
  const result = await runtime.clients.retrieval.query(
1986
2047
  readyHash,