@@ -56,37 +56,94 @@ data class DocQLParams(
5656
5757object DocQLSchema : DeclarativeToolSchema(
5858 description = """
59- **Use this tool FIRST** when the user asks about:
60- - Project architecture, design, or structure ("How does X work?")
61- - Where specific functionality is implemented ("Where is authentication handled?")
62- - Code or documentation search ("Find classes related to Y")
59+ Executes a DocQL query against available documents (both in-memory and indexed).
6360
64- ## Usage
65- Just provide a keyword: `{"query": "authentication"}` → Auto-searches classes, functions, and docs
61+ ## SMART SEARCH (Recommended)
62+ Simply provide a keyword or phrase, and the tool will automatically:
63+ 1. Search for Classes and Functions matching the keyword (High Priority)
64+ 2. Search for Headings and Content matching the keyword (Medium Priority)
65+ 3. Rerank results to show the most relevant code and documentation first.
66+ 4. 如果用户使用的语言搜索不到结果,可以从用户的语言编码方式来搜索,比如拼音搜索、拼音编写、英语等。
6667
67- **Advanced**: Use DocQL queries for precise results:
68- - Code: `$.code.class("UserService")` or `$.code.function("login")`
69- - Docs: `$.content.heading("Architecture")` or `$.toc[*]`
68+ **Example:** `{"query": "Auth"}` -> Finds `AuthService` class, `authenticate` function, and "Authentication" sections.
69+
70+ ## ADVANCED: DIRECT DOCQL QUERIES
71+ For precise control, use standard DocQL syntax (starts with `$.`):
72+
73+ ### 1. Document Queries ($.content.*, $.toc[*])
74+ **For:** Markdown, text files, documentation (.md, .txt, README)
75+ **Examples:**
76+ - $.content.heading("keyword") - Find sections by heading
77+ - $.content.chunks() - Get all content chunks
78+ - $.toc[*] - Get table of contents
79+
80+ ### 2. Code Queries ($.code.*)
81+ **For:** Source code files (.kt, .java, .py, .js, .ts, .go, .rs, .cs)
82+ **Parser:** TreeSitter-based with full code structure
83+ **Examples:**
84+ - $.code.class("ClassName") - Find class with full source code
85+ - $.code.function("functionName") - Find function/method with implementation
86+ - $.code.classes[*] - List all classes
87+ - $.code.functions[*] - List all functions/methods
88+
89+ ## Parameters
90+ - **query** (required): The keyword (Smart Search) or DocQL query string (Advanced)
91+ - **documentPath** (optional): Target specific document by path
92+ - **maxResults** (optional): Limit results (default: 20)
93+ - **secondaryKeyword** (optional): Additional keyword for filtering when results are too many
94+
95+ ## Multi-Level Keyword Strategy
96+ The tool automatically expands keywords when needed:
97+ - **Level 1**: Original query + phrase variations (e.g., "base64 encoding" → "base64 encoder")
98+ - **Level 2**: Component words (e.g., "base64", "encoding")
99+ - **Level 3**: Stem variants (e.g., "encode", "encoded", "encoder")
100+
101+ If you provide a **secondaryKeyword**, it will be used to filter Level 1 results when too many.
70102 """ .trimIndent(),
71103 properties = mapOf(
72104 "query" to string(
73- description = "Keyword for smart search, or DocQL query ($.code.*, $.content.*). Examples : \" MCP \", \"$.code.class(\\\" AuthService \\\")\" ",
105+ description = "The keyword to search for ( Smart Search ) or a specific DocQL query (e.g., ' $.content.heading(\" Introduction \")'). ",
74106 required = true
75107 ),
76108 "documentPath" to string(
77- description = "Target specific document (e.g., 'README .md'). Omit to search all.",
109+ description = """
110+ The path of the document to query (e.g., 'design-system-color.md').
111+ Use this to target specific documents when their names match your keywords.
112+ Check the available documents list and match keywords before querying.
113+ If omitted, searches all registered documents.
114+ """.trimIndent(),
78115 required = false
79116 ),
80117 "maxResults" to integer(
81- description = "Max results (default: 20)",
118+ description = """
119+ Maximum number of results to return. Default is 20.
120+ Use lower values for quick overview, higher values for comprehensive search.
121+ Note : Very high values may exceed context limits for large result sets.
122+ """.trimIndent(),
82123 required = false
83124 ),
84125 "secondaryKeyword" to string(
85- description = "Additional filter keyword when too many results",
126+ description = """
127+ Optional secondary keyword for multi-level filtering.
128+ When the primary query returns too many results (>50), the secondary keyword
129+ is used to filter and prioritize the most relevant results.
130+
131+ Example : query="Auth ", secondaryKeyword="Service "
132+ → Finds AuthService , AuthenticationService with higher priority
133+ """.trimIndent(),
86134 required = false
87135 ),
88136 "rerankerType" to string(
89- description = "Reranker : 'heuristic' (default, fast), 'llm_metadata' (uses AI model, smarter but costs tokens), 'hybrid' (balanced)",
137+ description = """
138+ Reranker algorithm to use for ordering results.
139+
140+ Options :
141+ - "heuristic" (default): Fast BM25 + type + name matching. Best for quick searches.
142+ - "rrf_composite": RRF fusion with composite scoring. Better for multi-source results.
143+ - "llm_metadata": LLM -based intelligent reranking using document metadata.
144+ Considers file paths, headings, modification time, references. Slower but smarter.
145+ - "hybrid": Heuristic pre-filter + LLM rerank. Balance of speed and quality.
146+ """.trimIndent(),
90147 required = false
91148 )
92149 )
0 commit comments