searchKnowledge
Find information across knowledge topics by searching with keywords. Returns matching entries with topic, title, and content details.
Instructions
Search across all knowledge topics by keyword. Returns matching entries with their topic, title, and content.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search keyword or phrase |
Implementation Reference
- src/core/knowledge.ts:123-158 (handler)The actual implementation of the searchKnowledge logic that parses and searches through topic files in the knowledge base.
async searchKnowledge(query: string): Promise<SearchHit[]> { const log = getLogger(); const topics = await this.listTopics(); if (topics.length === 0) return []; const lower = query.toLowerCase(); const hits: SearchHit[] = []; // Read all topic files in parallel (cached after first read) const files = await Promise.all( topics.map(async (topic) => { try { const file = await this.client.getFile(this.topicPath(topic)); return { topic, content: file.content }; } catch { return null; } }) ); for (const f of files) { if (!f) continue; const entries = parseEntries(f.content); for (const entry of entries) { if ( entry.title.toLowerCase().includes(lower) || entry.content.toLowerCase().includes(lower) ) { hits.push({ topic: f.topic, title: entry.title, content: entry.content }); } } } log.info("searchKnowledge", { query, hits: hits.length, topicsScanned: topics.length }); return hits; }