UNPKG

scai

Version:

> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** > **100% local • No token cost • Private by design • 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}`); }); }