import { exec } from 'child_process';
import { readFile } from 'fs/promises';
import { promisify } from 'util';
const execAsync = promisify(exec);
async function getProjectGuidelines(category: string) {
try {
// Read guidelines from your docs directory
const guidePath = `./docs/guidelines/${category}.md`;
const content = await readFile(guidePath, 'utf-8');
return {
content: [
{
type: 'text',
text: content,
},
],
};
} catch (error) {
return {
content: [
{
type: 'text',
text: `Guidelines not found for category: ${category}`,
},
],
isError: true,
};
}
}
async function runProjectTests(testPath?: string, args: string[] = []) {
try {
const command = `npm test ${testPath || ''} ${args.join(' ')}`.trim();
const { stdout, stderr } = await execAsync(command);
return {
content: [
{
type: 'text',
text: stdout || stderr,
},
],
};
} catch (error) {
return {
content: [
{
type: 'text',
text: `Test execution failed: ${error.message}`,
},
],
isError: true,
};
}
}