UNPKG

scai

Version:

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

43 lines (42 loc) 1.5 kB
function isNaturalLanguageNoise(line) { const trimmed = line.trim().toLowerCase(); return (trimmed.startsWith('i ') || trimmed.startsWith('here') || trimmed.startsWith('this') || trimmed.startsWith('the following') || trimmed.startsWith('below') || trimmed.startsWith('in this') || trimmed.startsWith('we have') || trimmed.includes('the code above') || trimmed.includes('ensures that') || trimmed.includes('it handles') || trimmed.includes('used to')); } export const cleanupModule = { name: 'cleanup', description: 'Remove markdown fences and natural language noise from top/bottom of code', async run({ content }) { let lines = content.trim().split('\n'); // ───── Clean top ───── while (lines.length) { const line = lines[0].trim(); if (line === '' || line.startsWith('```') || isNaturalLanguageNoise(line)) { lines.shift(); } else { break; } } // ───── Clean bottom ───── while (lines.length) { const line = lines[lines.length - 1].trim(); if (line === '' || line.startsWith('```') || isNaturalLanguageNoise(line)) { lines.pop(); } else { break; } } return { content: lines.join('\n').trim() }; } };