UNPKG

spec-coding-mcp

Version:

MCP server for AI-powered IDE to follow spec-driven development

17 lines 767 B
import { readFile } from 'fs/promises'; import { join, dirname } from 'path'; import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); export async function readTemplate(templateName, variables = {}) { // From src/utils go up two levels to the project root, then enter templates const templatePath = join(__dirname, '../../templates', templateName); console.error(`[MCP] Reading template: ${templatePath}`); let content = await readFile(templatePath, 'utf-8'); // Replace variables Object.entries(variables).forEach(([key, value]) => { const regex = new RegExp(`\{${key}\}`, 'g'); content = content.replace(regex, value); }); return content; } //# sourceMappingURL=template.js.map