/** v0.50.18：Worker 完成信号的默认词——Stop hook 监听此词触发 COMPLETED 标签 */
export const DEFAULT_COMPLETION_SIGNAL = 'done';
export function buildPhasePrompt(ctx) {
    const sections = [];
    if (ctx.skillContent?.trim()) {
        sections.push(ctx.skillContent.trim());
        sections.push('---');
    }
    if (ctx.projectRules?.trim()) {
        sections.push(ctx.projectRules.trim());
        sections.push('---');
    }
    if (ctx.knowledge?.trim()) {
        sections.push(ctx.knowledge.trim());
        sections.push('---');
    }
    if (ctx.wikiContext?.trim()) {
        sections.push(ctx.wikiContext.trim());
        sections.push('---');
    }
    sections.push(buildTaskSection(ctx));
    sections.push(buildPhaseInstructions(ctx));
    if (ctx.wikiUpdateReminder?.trim()) {
        sections.push(ctx.wikiUpdateReminder.trim());
    }
    return sections.join('\n\n').trim() + '\n';
}
function buildTaskSection(ctx) {
    // v0.50.9：只显式列 MR 相关字段，当 merge mode = create 时才输出。其余情况
    // Card Full ID / GitLab Project ID / MR Mode 对 Worker 基本无用，去掉降噪。
    const mrLine = ctx.mergeMode === 'create'
        ? `\nTarget branch: ${ctx.targetBranch} (MR mode, GitLab project ${ctx.gitlabProjectId})`
        : '';
    return `# Task

${ctx.taskTitle} (seq ${ctx.taskSeq})

Working directory: ${ctx.worktreePath}${mrLine}

Description:
${ctx.taskDescription || '(no description)'}`;
}
function buildPhaseInstructions(ctx) {
    // v0.50.9：大幅瘦身。只保留 SPS 框架不可回避的不变式：worktree 隔离、push、
    // 报告 blocker、说 <signal> 作为完成信号。其他项目级约定（CHANGELOG / DECISIONS /
    // conventional commits）归 CLAUDE.md 管，projectRules 段会注入。
    // v0.50.18：completion signal 参数化，默认 "done"。
    const signal = ctx.completionSignal ?? DEFAULT_COMPLETION_SIGNAL;
    return `# How to Run

Work inside \`${ctx.worktreePath}\`. Inspect the code, implement the task, commit, then \`git push\` to the current branch. Say "${signal}" only after the push succeeds.

If blocked by missing permissions / unclear requirements / environment issues, report the exact blocker instead of guessing.`;
}
/**
 * Build prompt for non-git task (git: false pipeline).
 * No branch, worktree, push, or merge instructions.
 */
export function buildTaskPrompt(ctx) {
    const sections = [];
    if (ctx.skillContent?.trim()) {
        sections.push(ctx.skillContent.trim());
        sections.push('---');
    }
    if (ctx.projectRules?.trim()) {
        sections.push(ctx.projectRules.trim());
        sections.push('---');
    }
    if (ctx.knowledge?.trim()) {
        sections.push(ctx.knowledge.trim());
        sections.push('---');
    }
    if (ctx.wikiContext?.trim()) {
        sections.push(ctx.wikiContext.trim());
        sections.push('---');
    }
    sections.push(`# Task

${ctx.taskTitle} (seq ${ctx.taskSeq})

Working directory: ${ctx.worktreePath}

Description:
${ctx.taskDescription || '(no description)'}`);
    const signal = ctx.completionSignal ?? DEFAULT_COMPLETION_SIGNAL;
    sections.push(`# How to Run

Work inside \`${ctx.worktreePath}\`. Complete the task, validate the output, then say "${signal}". Don't touch files outside this directory. If blocked, report the exact blocker.`);
    if (ctx.wikiUpdateReminder?.trim()) {
        sections.push(ctx.wikiUpdateReminder.trim());
    }
    return sections.join('\n\n').trim() + '\n';
}
//# sourceMappingURL=taskPrompts.js.map