scai
Version:
> AI-powered CLI tool for commit messages **and** pull request reviews ā using local models.
43 lines (38 loc) ⢠1.49 kB
JavaScript
import { Config } from '../../config.js';
import { generate } from '../../lib/generate.js';
import path from 'path';
export const summaryModule = {
name: 'summary',
description: 'Generates a general summary of any file content.',
run: async ({ content, filepath }) => {
const model = Config.getModel();
const ext = filepath ? path.extname(filepath).toLowerCase() : '';
const filename = filepath ? path.basename(filepath) : '';
// More neutral prompt for general-purpose content
const prompt = `
You are an assistant specialized in summarizing files.
Your task is to summarize the contents of the following file as clearly and concisely as possible.
File: ${filename}
Extension: ${ext}
š Instructions:
- Identify the main topic and purpose of the file
- Summarize key content and sections
- Mention any technical, legal, or structural info if relevant
- Do NOT include the raw content or repeat lines from it
- Return a human-readable bullet-point summary
--- FILE CONTENT START ---
${content}
--- FILE CONTENT END ---
`.trim();
const response = await generate({ content: prompt, filepath }, model);
if (response.content) {
response.summary = response.content;
console.log('\nš Summary:\n');
console.log(response.summary);
}
else {
console.warn('ā ļø No summary generated.');
}
return response;
}
};