import { formatSubagentsForPrompt, getSubagentBasePrompt } from "../subagents/registry.js";
import { buildBaseSystemPrompt, buildEnvironmentTag } from "../utils/context.js";
import { resolvePromptGitRoot } from "../utils/git.js";
export function composeSessionPrompts(args) {
    const repoRoot = resolvePromptGitRoot({ cwd: args.cwd });
    const environmentTag = buildEnvironmentTag({
        riskLevel: args.riskLevel,
        cwd: args.cwd,
        repoRoot,
        datetime: args.datetime,
        platform: args.platform,
        nodeVersion: args.nodeVersion,
    });
    const baseSystemPrompt = buildBaseSystemPrompt({
        personaSystemPrompt: args.persona.systemPrompt,
        skillsBlock: args.skillsBlock,
        projectContextBlock: args.projectContextBlock,
        environmentTag,
        subagentsBlock: formatSubagentsForPrompt(args.persona),
    });
    const subagentPrompts = {};
    const subagents = args.persona.subagents;
    if (subagents) {
        for (const [name, config] of Object.entries(subagents)) {
            const personaSystemPrompt = getSubagentBasePrompt({
                name,
                config,
                mainPersonaSystemPrompt: args.persona.systemPrompt,
            });
            const subagentEnvironmentTag = buildEnvironmentTag({
                riskLevel: config.riskLevel ?? args.riskLevel,
                cwd: args.cwd,
                repoRoot,
                datetime: args.datetime,
                platform: args.platform,
                nodeVersion: args.nodeVersion,
            });
            subagentPrompts[name] = buildBaseSystemPrompt({
                personaSystemPrompt,
                skillsBlock: args.skillsBlock,
                projectContextBlock: args.projectContextBlock,
                environmentTag: subagentEnvironmentTag,
            });
        }
    }
    return {
        environmentTag,
        baseSystemPrompt,
        subagentPrompts,
    };
}
//# sourceMappingURL=session_prompt_composer.js.map