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