scai
Version:
> AI-powered CLI tools for smart commit messages, auto generated comments, and readme files — all powered by local models.
32 lines (29 loc) • 1.06 kB
JavaScript
import { ModelConfig } from '../../config/ModelConfig.js';
export const addCommentsModule = {
name: 'addComments',
description: 'Adds meaningful // comments to each block of code',
async run(input) {
const model = ModelConfig.getModel();
const lang = ModelConfig.getLanguage();
const prompt = `
You are a senior ${lang.toUpperCase()} engineer.
Add clear and helpful single-line // comments to complex parts of the code.
- Do NOT remove or change in ANY way any parts of the code!
- Output ALL of the original code with your comments included
--- CODE START ---
${input.code}
--- CODE END ---
`.trim();
const res = await fetch('http://localhost:11434/api/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model,
prompt,
stream: false,
}),
});
const data = await res.json();
return { code: data.response?.trim() ?? '' };
},
};