Ver código fonte

refactor: remove single collection param, use collections array only

BREAKING: collection param removed from structured_search.
Use collections: ['name'] for single collection filter.
Tobi Lütke 3 meses atrás
pai
commit
77e4d8f378
4 arquivos alterados com 8 adições e 14 exclusões
  1. 3 3
      skills/qmd/SKILL.md
  2. 2 5
      src/mcp.ts
  3. 1 1
      src/qmd.ts
  4. 2 5
      src/store.ts

+ 3 - 3
skills/qmd/SKILL.md

@@ -82,11 +82,11 @@ Note: `-term` and `OR` only work in lex queries, not vec/hyde.
 ### Collection Filtering
 
 ```json
-{ "collection": "docs" }           // Single collection
-{ "collections": ["docs", "notes"] }  // Multiple (OR)
+{ "collections": ["docs"] }              // Single
+{ "collections": ["docs", "notes"] }     // Multiple (OR)
 ```
 
-Omit both to search all collections.
+Omit to search all collections.
 
 ## Other MCP Tools
 

+ 2 - 5
src/mcp.ts

@@ -261,11 +261,10 @@ function createMcpServer(store: Store): McpServer {
         ),
         limit: z.number().optional().default(10).describe("Maximum number of results (default: 10)"),
         minScore: z.number().optional().default(0).describe("Minimum relevance score 0-1 (default: 0)"),
-        collection: z.string().optional().describe("Filter to a single collection by name"),
-        collections: z.array(z.string()).optional().describe("Filter to multiple collections (OR match)"),
+        collections: z.array(z.string()).optional().describe("Filter to specific collections (OR match)"),
       },
     },
-    async ({ searches, limit, minScore, collection, collections }) => {
+    async ({ searches, limit, minScore, collections }) => {
       // Map to internal format
       const subSearches: StructuredSubSearch[] = searches.map(s => ({
         type: s.type,
@@ -273,7 +272,6 @@ function createMcpServer(store: Store): McpServer {
       }));
 
       const results = await structuredSearch(store, subSearches, {
-        collection,
         collections,
         limit,
         minScore,
@@ -581,7 +579,6 @@ export async function startMcpHttpServer(port: number, options?: { quiet?: boole
         }));
 
         const results = await structuredSearch(store, subSearches, {
-          collection: params.collection,
           collections: params.collections,
           limit: params.limit ?? 10,
           minScore: params.minScore ?? 0,

+ 1 - 1
src/qmd.ts

@@ -2135,7 +2135,7 @@ async function querySearch(query: string, opts: OutputOptions, _embedModel: stri
       process.stderr.write(`${c.dim}└─ Searching...${c.reset}\n`);
 
       results = await structuredSearch(store, structuredQueries, {
-        collection: singleCollection,
+        collections: singleCollection ? [singleCollection] : undefined,
         limit: opts.all ? 500 : (opts.limit || 10),
         minScore: opts.minScore || 0,
         hooks: {

+ 2 - 5
src/store.ts

@@ -3199,8 +3199,7 @@ export interface StructuredSubSearch {
 }
 
 export interface StructuredSearchOptions {
-  collection?: string;      // Single collection filter
-  collections?: string[];   // Multiple collections filter (OR)
+  collections?: string[];   // Filter to specific collections (OR match)
   limit?: number;           // default 10
   minScore?: number;        // default 0
   candidateLimit?: number;  // default RERANK_CANDIDATE_LIMIT
@@ -3237,9 +3236,7 @@ export async function structuredSearch(
   const candidateLimit = options?.candidateLimit ?? RERANK_CANDIDATE_LIMIT;
   const hooks = options?.hooks;
 
-  // Normalize collection filter to array (undefined = all collections)
-  const collections: string[] | undefined = options?.collections
-    ?? (options?.collection ? [options.collection] : undefined);
+  const collections = options?.collections;
 
   if (searches.length === 0) return [];