// engine/hooks/custom-commands-generator.ts — .claude/commands/ generator (SPEC-265)
import { mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
// ---------------------------------------------------------------------------
// Command content builders
// ---------------------------------------------------------------------------
function buildSpecCommand(projectPath) {
    return {
        name: 'spec',
        description: 'Create a Planu spec for the described feature',
        content: `---
description: Create a Planu spec for the described feature
---
Use the mcp__planu__create_spec tool with projectPath: ${projectPath}
and the user's description as the description parameter.
Always wait for user approval before implementing.
`,
    };
}
function buildValidateCommand() {
    return {
        name: 'validate',
        description: 'Validate the active Planu spec',
        content: `---
description: Validate the active Planu spec
---
Use the mcp__planu__validate tool with the current project path.
Report any compliance gaps found.
`,
    };
}
function buildStatusCommand() {
    return {
        name: 'status',
        description: 'Show Planu project status snapshot',
        content: `---
description: Show Planu project status snapshot
---
Use the mcp__planu__planu_status tool with the current project path.
Show the active spec, git state, and pending queue in a concise summary.
`,
    };
}
function buildPlanuCommand() {
    return {
        name: 'planu',
        description: 'Quick reference for the Planu SDD workflow',
        content: `---
description: Quick reference for the Planu SDD workflow
---
Explain the Spec Driven Development workflow:
1. /spec <description> — create a spec and get approval
2. Implement only after approval
3. /validate — check implementation against spec
4. /status — see what is active and pending

Always use mcp__planu__* tools. Never write code without an approved spec.
`,
    };
}
// ---------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------
/**
 * Returns the four standard Planu slash commands for .claude/commands/.
 */
export function generateCustomCommands(projectPath) {
    return [
        buildSpecCommand(projectPath),
        buildValidateCommand(),
        buildStatusCommand(),
        buildPlanuCommand(),
    ];
}
/**
 * Writes command markdown files to <projectPath>/.claude/commands/.
 * Creates the directory if it does not exist. Idempotent.
 */
export function writeCustomCommands(projectPath) {
    const commandsDir = join(projectPath, '.claude', 'commands');
    mkdirSync(commandsDir, { recursive: true });
    const commands = generateCustomCommands(projectPath);
    for (const cmd of commands) {
        const filePath = join(commandsDir, `${cmd.name}.md`);
        writeFileSync(filePath, cmd.content, 'utf8');
    }
}
//# sourceMappingURL=custom-commands-generator.js.map