UNPKG

scai

Version:

> AI-powered CLI tool for commit messages **and** pull request reviews — using local models.

53 lines (52 loc) 2.26 kB
import path from 'path'; import fs from 'fs'; import { log } from '../utils/log.js'; import { getDbForRepo } from '../db/client.js'; export async function runInspectCommand(fileArg) { if (!fileArg) { log('❌ Please provide a file path to inspect.'); process.exit(1); } const resolvedPath = path.resolve(fileArg).replace(/\\/g, '/'); if (!fs.existsSync(resolvedPath)) { log(`❌ File does not exist: ${resolvedPath}`); process.exit(1); } const db = getDbForRepo(); const file = db .prepare(`SELECT * FROM files WHERE REPLACE(path, '\\', '/') = ?`) .get(resolvedPath); if (!file) { log(`❌ File not found in database: ${resolvedPath}`); return; } log(`🔍 Inspecting: ${resolvedPath}`); console.log('----------------------------------------'); console.log(`🆔 File ID: ${file.id}`); console.log(`📄 Indexed at: ${file.indexed_at || '❌ Not yet'}`); console.log(`🧠 Summary present: ${file.summary ? '✅' : '❌'}`); console.log(`🧠 Embedding present: ${file.embedding ? '✅' : '❌'}`); const isExtracted = file.processing_status?.includes('extracted'); console.log(`📌 Functions extracted: ${isExtracted ? '✅' : '❌'}`); console.log(`📆 Extracted at: ${file.functions_extracted_at || '❌ Not yet'}`); console.log(`⚙️ Processing status: ${file.processing_status || 'unknown'}`); if (file.summary) { console.log('\n📝 Summary:'); console.log(file.summary.slice(0, 300) + (file.summary.length > 300 ? '...' : '')); } const functions = db .prepare(`SELECT name, start_line, end_line FROM functions WHERE file_id = ? ORDER BY start_line ASC`) .all(file.id); if (functions.length > 0) { console.log(`\n🧑‍💻 Extracted Functions (${functions.length}):`); for (const fn of functions) { const start = fn.start_line ?? '?'; const end = fn.end_line ?? '?'; console.log(`- ${fn.name} (lines ${start}${end})`); } } else { console.log('\n🧑‍💻 Extracted Functions: ❌ None'); } console.log('\n✅ Inspection complete.'); }