function truncate(value, maxLength) {
    if (value.length <= maxLength)
        return value;
    return `${value.slice(0, maxLength)}\n\n[truncated]`;
}
function describeFile(file) {
    if (file.status === 'renamed' && file.originalPath) {
        return `${file.status}: ${file.originalPath} -> ${file.path}`;
    }
    return `${file.status}: ${file.path}`;
}
export function buildCommitMessagePrompt(stagedFiles, stagedDiff) {
    const fileList = stagedFiles.length
        ? stagedFiles.map((file) => `- ${describeFile(file)}`).join('\n')
        : '- (no staged files)';
    const diff = truncate(stagedDiff.trim(), 24_000) || '(no diff available)';
    return [
        'You are an expert software engineer writing a git commit message.',
        '',
        'Rules:',
        '- Output ONLY the commit message — no explanation, no markdown, no quotes.',
        '- First line: 50 chars or less, imperative mood, no period.',
        '  Good: "Add rate limiting to auth endpoints"',
        '  Bad: "Added some rate limiting stuff" / "This commit adds..."',
        '- Use a conventional commit prefix when it fits naturally:',
        '  feat, fix, refactor, test, docs, chore, perf, style, ci, build',
        '  Example: "feat: add dark mode toggle"',
        '- Skip the prefix for mixed or unclear changes.',
        '- Body (optional, blank line after subject): explain WHY, not what.',
        '  Wrap at 72 chars. Only include if the change needs context.',
        '- Never mention file names in the subject unless truly essential.',
        '- Focus on the intent and impact, not the mechanics.',
        '',
        'Staged files:',
        fileList,
        '',
        'Staged diff:',
        diff
    ].join('\n');
}
//# sourceMappingURL=commit-message-prompt.js.map