/*
 * Copyright 2026, Jaime Terrats.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { join } from 'node:path';
import { ensureDir } from './file-writer.js';
export function setupAdvisoryMode(cwd, profiles, writer) {
    const advisoryDir = join(cwd, '.setup-agents', 'advisory');
    const rolesDir = join(advisoryDir, 'roles');
    ensureDir(rolesDir);
    const files = ['README.md', ...profiles.map((profile) => `roles/${profile.id}.md`)];
    writer.write(join(advisoryDir, 'README.md'), readme(profiles));
    for (const profile of profiles) {
        writer.write(join(rolesDir, `${profile.id}.md`), roleGuide(profile));
    }
    return { enabled: true, path: advisoryDir, files };
}
function readme(profiles) {
    return [
        '# Setup Agents Advisory Mode',
        '',
        'This directory contains consultative role guidance for sessions that are not attached to a project workspace.',
        '',
        'Advisory mode must not assume source files, test commands, deployments, metadata paths, or project conventions exist.',
        '',
        '## Active Advisory Roles',
        '',
        ...profiles.map((profile) => `- [${profile.label}](roles/${profile.id}.md)`),
        '',
        '## Rules',
        '',
        '- Discuss options, tradeoffs, risks, and next steps.',
        '- Ask for a project folder before writing project-scoped files.',
        '- Do not run deploy, test, or metadata commands unless the user later selects a real workspace.',
        '- Do not create root `AGENTS.md`, `CLAUDE.md`, `.cursor/rules/`, `.codex/`, or `.a4drules/` files from advisory mode.',
    ].join('\n');
}
function roleGuide(profile) {
    const metadata = profile.orchestration;
    return [
        `# ${profile.label} Advisory Role`,
        '',
        'Use this role for planning, ideation, review, and clarification before a project workspace exists.',
        '',
        '## Activation Signals',
        '',
        ...(metadata?.activationCriteria ?? []).map((item) => `- ${item}`),
        '',
        '## Expected Outputs',
        '',
        ...(metadata?.expectedEvidence ?? []).map((item) => `- ${item}`),
        '',
        '## Guardrails',
        '',
        '- Provide advisory guidance only until the user selects a project workspace.',
        '- Keep generated recommendations portable and avoid project-specific file paths unless the user provides them.',
        '- Capture assumptions explicitly.',
    ].join('\n');
}
//# sourceMappingURL=advisory-mode.js.map