import { BaseTool } from './base.tool.js';
export class SearchNotesTool extends BaseTool {
readonly name = 'search_notes';
readonly description = 'Search for notes containing specific text or patterns across the entire vault';
readonly inputSchema = {
type: 'object' as const,
properties: {
query: {
type: 'string',
description: 'Search query (supports regex patterns)',
},
limit: {
type: 'number',
description: 'Maximum number of results to return (default: 50)',
default: 50,
},
},
required: ['query'],
};
async execute(params: { query: string; limit?: number }) {
try {
const results = await this.vault.search(params.query, {
limit: params.limit ?? 50,
});
return {
success: true,
count: results.length,
results: results.map(r => ({
path: r.path,
snippet: r.content,
matches: r.matches,
})),
};
} catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : 'Search failed',
};
}
}
}