UNPKG

@fission-ai/openspec

Version:

AI-native system for spec-driven development

41 lines (40 loc) 1.23 kB
/** * Pi Command Adapter * * Formats commands for Pi (pi.dev) following its prompt template specification. * Pi prompt templates live in .pi/prompts/*.md with description frontmatter. */ import path from 'path'; /** * Escapes a string value for safe YAML output. * Quotes the string if it contains special YAML characters. */ function escapeYamlValue(value) { // Check if value needs quoting (contains special YAML characters or starts/ends with whitespace) const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value); if (needsQuoting) { // Use double quotes and escape internal double quotes and backslashes const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n'); return `"${escaped}"`; } return value; } /** * Pi adapter for prompt template generation. * File path: .pi/prompts/opsx-<id>.md * Frontmatter: description */ export const piAdapter = { toolId: 'pi', getFilePath(commandId) { return path.join('.pi', 'prompts', `opsx-${commandId}.md`); }, formatFile(content) { return `--- description: ${escapeYamlValue(content.description)} --- ${content.body} `; }, }; //# sourceMappingURL=pi.js.map