UNPKG

scai

Version:

> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ā¤ļø.

29 lines (28 loc) • 1.1 kB
import { queryFiles } from '../db/fileIndex.js'; import { sanitizeQueryForFts } from '../utils/sanitizeQuery.js'; import path from 'path'; import os from 'os'; export async function runFindCommand(query) { if (!query) { console.error('āŒ Please provide a search query.\nšŸ‘‰ Usage: scai find "keyword"'); return; } console.log(`\nšŸ” Searching for: "${query}"\n`); const sanitizedQuery = sanitizeQueryForFts(query); const results = queryFiles(sanitizedQuery); if (results.length === 0) { console.log('āš ļø No matching files found.'); return; } console.log(`āœ… Found ${results.length} result(s).\n`); const homeDir = os.homedir(); results.forEach((result, index) => { let absPath = path.resolve(result.path); // ensure absolute path if (absPath.startsWith(homeDir)) { absPath = absPath.replace(homeDir, '~'); } // Normalize to forward slashes (especially for Windows) absPath = absPath.replace(/\\/g, '/'); console.log(`šŸ“„ [${index + 1}] ${absPath}`); }); }