/**
 * 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';
import { transformToHyphenCommands } from '../../../utils/command-references.js';
import { escapeYamlValue } from '../yaml.js';
const PI_INPUT_HEADING = /^\*\*Input\*\*:[^\n]*$/m;
function injectPiArgs(body) {
    if (body.includes('$@') || body.includes('$ARGUMENTS')) {
        return body;
    }
    return body.replace(PI_INPUT_HEADING, (heading) => `${heading}\n**Provided arguments**: $@`);
}
/**
 * Pi adapter for prompt template generation.
 * File path: .pi/prompts/opsx-<id>.md
 * Frontmatter: description
 *
 * Pi uses the filename (minus .md) as the slash command name, so
 * opsx-propose.md → /opsx-propose. Command references in the body
 * are transformed from /opsx: to /opsx- for consistency.
 */
export const piAdapter = {
    toolId: 'pi',
    getFilePath(commandId) {
        return path.join('.pi', 'prompts', `opsx-${commandId}.md`);
    },
    formatFile(content) {
        // Transform /opsx: references to /opsx- and inject $@ for template args
        const transformedBody = transformToHyphenCommands(content.body);
        return `---
description: ${escapeYamlValue(content.description)}
---

${injectPiArgs(transformedBody)}
`;
    },
};
//# sourceMappingURL=pi.js.map