// tools/init-project/find-skills-writer.ts — SPEC-655: find-skills Bootstrap
// Single hardcoded entry point for skill discovery in generated config files
import { writeFile, mkdir, access } from 'node:fs/promises';
import { join } from 'node:path';
import { assertEnglishOnlyArtifactText } from '../../engine/spec-language/english-only.js';
const FIND_SKILLS_PATH = '.claude/skills/find-skills.md';
const FIND_SKILLS_CONTENT = `# /find-skills — Discover Available Workflows

Discover the most relevant skills for your current task. Returns top 5 matches based on
active spec tags, session state, and project conventions.

## Search paths (in priority order)

1. \`.claude/skills/\` — project-local skills (this directory)
2. \`.planu/skill-registry.json\` — Planu-installed skills index
3. \`~/.claude/skills/\` — global user skills

## Usage

- "what can I do?" → returns top 5 skills relevant to current active spec
- "how do I test?" → searches for testing-related skills
- "/find-skills backend" → returns skills tagged with "backend"

## Instructions

When invoked, read the active spec from \`planu/session.json\` (if present) to get
the current spec tags. Then scan the search paths above and rank skills by tag overlap
with the active spec tags. Return the top 5 with name, one-line description, and
invocation command.

If no session.json exists, return all available skills sorted alphabetically.
`;
/**
 * SPEC-655: Write .claude/skills/find-skills.md if missing.
 * Idempotent — skips if file already exists.
 */
export async function generateFindSkillsIfMissing(projectPath) {
    const skillPath = join(projectPath, FIND_SKILLS_PATH);
    try {
        await access(skillPath);
        return false;
    }
    catch {
        const skillsDir = join(projectPath, '.claude', 'skills');
        await mkdir(skillsDir, { recursive: true });
        assertEnglishOnlyArtifactText(FIND_SKILLS_CONTENT, 'skill');
        await writeFile(skillPath, FIND_SKILLS_CONTENT, 'utf-8');
        return true;
    }
}
//# sourceMappingURL=find-skills-writer.js.map