MCPcopy Create free account
hub / github.com/chokcoco/iCSS / searchCssTechniques

Method searchCssTechniques

MCP/debug-local.js:241–320  ·  view source on GitHub ↗
({ query, categories = [], tags = [], min_weight, limit = 10 })

Source from the content-addressed store, hash-verified

239 }
240
241 async searchCssTechniques({ query, categories = [], tags = [], min_weight, limit = 10 }) {
242 debugLog(`🔍 Searching CSS techniques: "${query}"`);
243
244 if (!this.searchEngine) {
245 throw new McpError(
246 ErrorCode.InternalError,
247 'Search engine not initialized'
248 );
249 }
250
251 let results = this.searchEngine.search(query);
252 debugLog(`📊 Found ${results.length} initial results`);
253
254 // 过滤结果
255 if (categories.length > 0) {
256 results = results.filter(result =>
257 result.item.categories.some(cat =>
258 categories.some(c => cat.toLowerCase().includes(c.toLowerCase()))
259 )
260 );
261 debugLog(`📊 After category filter: ${results.length} results`);
262 }
263
264 if (tags.length > 0) {
265 results = results.filter(result =>
266 tags.every(tag =>
267 result.item.tags.some(t => t.toLowerCase().includes(tag.toLowerCase()))
268 )
269 );
270 debugLog(`📊 After tag filter: ${results.length} results`);
271 }
272
273 if (min_weight) {
274 results = results.filter(result =>
275 result.item.weights.some(w => w >= min_weight)
276 );
277 debugLog(`📊 After weight filter: ${results.length} results`);
278 }
279
280 // 格式化结果
281 const formattedResults = results.slice(0, limit).map(result => {
282 const item = result.item;
283 return {
284 title: item.title,
285 number: item.number,
286 url: item.html_url,
287 relevance: Math.round((1 - result.score) * 100),
288 tags: item.tags.map((tag, i) => ({
289 name: tag,
290 category: item.categories[i] || 'other',
291 weight: item.weights[i] || 1.0,
292 description: item.descriptions[i] || ''
293 })),
294 preview: this.extractPreview(item.body),
295 updated_at: item.updated_at
296 };
297 });
298

Callers 1

setupHandlersMethod · 0.95

Calls 2

extractPreviewMethod · 0.95
debugLogFunction · 0.70

Tested by

no test coverage detected