// engine/ai-integration/codex/agent-roles-generator.ts — Agent role TOML generators (SPEC-266)
import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { join } from 'node:path';
/** Generates TOML for the spec-writer agent role. */
export function generateSpecWriterRole() {
    return [
        '# .codex/agents/spec-writer.toml — Generated by Planu (SPEC-266)',
        'name = "spec-writer"',
        'description = "Creates Planu specs from user requirements. Uses mcp__planu__create_spec, challenge_spec, and check_readiness to produce well-formed specs ready for implementation."',
        'sandbox_mode = "workspace-write"',
        '',
        '[instructions]',
        'focus = "spec creation only"',
        'never = "write production code — that is the implementer role"',
        'always = "run challenge_spec and check_readiness before marking a spec as review-ready"',
    ].join('\n');
}
/** Generates TOML for the implementer agent role. */
export function generateImplementerRole() {
    return [
        '# .codex/agents/implementer.toml — Generated by Planu (SPEC-266)',
        'name = "implementer"',
        'description = "Implements approved Planu specs. Reads spec criteria and writes code that satisfies them. Runs mcp__planu__validate after implementation."',
        'sandbox_mode = "workspace-write"',
        '',
        '[instructions]',
        'focus = "implementation of approved specs only"',
        'never = "implement a spec that is not in approved status"',
        'always = "validate with mcp__planu__validate after implementation"',
        'branch = "feat/SPEC-XXX-description (branch from develop)"',
    ].join('\n');
}
/** Generates TOML for the reviewer agent role. */
export function generateReviewerRole() {
    return [
        '# .codex/agents/reviewer.toml — Generated by Planu (SPEC-266)',
        'name = "reviewer"',
        'description = "Reviews code changes against spec criteria. Read-only access — produces a review report without modifying code."',
        'sandbox_mode = "read-only"',
        '',
        '[instructions]',
        'focus = "code review against spec criteria"',
        'never = "modify production code directly"',
        'always = "reference specific spec criteria in review comments"',
    ].join('\n');
}
/**
 * Creates .codex/agents/ directory and writes all three role TOML files.
 * Idempotent: overwrites existing files.
 */
export function writeAgentRoles(projectPath) {
    const agentsDir = join(projectPath, '.codex', 'agents');
    /* v8 ignore start */
    if (!existsSync(agentsDir)) {
        mkdirSync(agentsDir, { recursive: true });
    }
    /* v8 ignore stop */
    writeFileSync(join(agentsDir, 'spec-writer.toml'), generateSpecWriterRole(), 'utf8');
    writeFileSync(join(agentsDir, 'implementer.toml'), generateImplementerRole(), 'utf8');
    writeFileSync(join(agentsDir, 'reviewer.toml'), generateReviewerRole(), 'utf8');
}
//# sourceMappingURL=agent-roles-generator.js.map