UNPKG

scai

Version:

> **A local-first AI CLI for understanding, querying, and iterating on large codebases.** > **100% local • No token costs • No cloud • No prompt injection • Private by design**

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}`); }); }