// {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

import type { Command } from 'commander';

import { loadConfig } from '../core/config-manager.js';
import { getCachedStore } from '../data/store-repository.js';
import { searchOperations } from '../tools/search-tool.js';

export function registerSearchCommand(program: Command): void {
  program
    .command('search <query>')
    .description('Semantic search for operations matching a natural-language query')
    .option('-l, --limit <n>', 'maximum number of results', '5')
    .action(async (query: string, options: { limit: string }) => {
      const config = loadConfig();
      const store = getCachedStore(config.api_version);
      const results = await searchOperations(store, query, Number(options.limit));
      console.log(JSON.stringify(results, null, 2));
    });
}
