// tools/init-project/skills-multi-teammate-review-writer.ts
// SPEC-593: Write .claude/skills/planu-multi-teammate-review.md during init_project
import { writeFile, mkdir, access, readFile } from 'node:fs/promises';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { assertEnglishOnlyArtifactText } from '../../engine/spec-language/english-only.js';
const SKILL_TARGET_PATH = '.claude/skills/planu-multi-teammate-review.md';
// Resolve the template path relative to this file (works after tsc compilation too)
function resolveTemplatePath() {
    // __dirname equivalent for ESM
    const __filename = fileURLToPath(import.meta.url);
    const __dirname = dirname(__filename);
    // From dist/tools/init-project/ → dist/config/skill-templates/
    return join(__dirname, '../../config/skill-templates/planu-multi-teammate-review.md');
}
async function readTemplate() {
    const templatePath = resolveTemplatePath();
    try {
        return await readFile(templatePath, 'utf-8');
    }
    catch {
        // Fallback inline content if template file is not found (e.g. during tests without build)
        return `---
name: planu-multi-teammate-review
description: Run a 5-specialist panel code review with an Arbitrator.
triggers:
  - panel review
  - thorough review
  - 5-agent review
---

# /planu-multi-teammate-review

Invoke \`multi_teammate_review\` for a 5-specialist panel code review.
`;
    }
}
/**
 * Write .claude/skills/planu-multi-teammate-review.md only if it does not exist yet.
 * @returns true if the file was created, false if it already existed.
 */
export async function generateMultiTeammateReviewSkillIfMissing(projectPath) {
    const skillPath = join(projectPath, SKILL_TARGET_PATH);
    try {
        await access(skillPath);
        return false; // already exists
    }
    catch {
        const skillsDir = join(projectPath, '.claude/skills');
        await mkdir(skillsDir, { recursive: true });
        const content = await readTemplate();
        assertEnglishOnlyArtifactText(content, 'skill');
        await writeFile(skillPath, content, 'utf-8');
        return true;
    }
}
//# sourceMappingURL=skills-multi-teammate-review-writer.js.map