import type { QuickAction } from './types';

function qa(
  id: string,
  name: string,
  icon: string,
  category: QuickAction['category'],
  modelHint: string,
  description: string,
  systemPrompt: string,
  userTemplate: string
): QuickAction {
  return {
    id,
    name,
    icon,
    category,
    modelHint,
    description,
    systemPrompt,
    userTemplate,
    builtin: true,
    usageCount: 0,
  };
}

export const BUILTIN_QUICK_ACTIONS: QuickAction[] = [
  // Code (8)
  qa(
    'builtin-code-review',
    'Code Review',
    '🔍',
    'code',
    'reasoning',
    'Review code for bugs, perf, and security',
    'You are a senior code reviewer. Find bugs, security issues, performance issues, and maintainability improvements. Reference concrete code lines and provide fixes.',
    'Review this code:\n\n{paste code}'
  ),
  qa(
    'builtin-explain-code',
    'Explain Code',
    '📖',
    'code',
    'fast',
    'Explain what code does',
    'Explain the provided code in clear simple language. Break down each section and call out important patterns.',
    'Explain this code:\n\n{paste code}'
  ),
  qa(
    'builtin-write-tests',
    'Write Tests',
    '🧪',
    'code',
    'coding',
    'Generate unit tests',
    'You are a test engineer. Generate comprehensive unit tests with edge cases and clear test names.',
    'Write tests for:\n\n{paste code}'
  ),
  qa(
    'builtin-debug-error',
    'Debug Error',
    '🐛',
    'code',
    'reasoning',
    'Root-cause debugging assistant',
    'You are a debugging specialist. Identify root cause, explain why, and provide corrected code.',
    'Error:\n{paste error}\n\nCode:\n{paste code}'
  ),
  qa(
    'builtin-refactor',
    'Refactor',
    '♻️',
    'code',
    'coding',
    'Refactor for readability and performance',
    'Refactor the code for readability, maintainability, and performance without changing behavior.',
    'Refactor this:\n\n{paste code}'
  ),
  qa(
    'builtin-generate-code',
    'Generate Code',
    '⚡',
    'code',
    'coding',
    'Generate production-ready code',
    'Generate robust production-ready code with clear comments only where needed.',
    'Build this:\n\n{describe requirement}'
  ),
  qa(
    'builtin-regex-builder',
    'Regex Builder',
    '🔤',
    'code',
    'fast',
    'Build and explain regex patterns',
    'You are a regex expert. Build the requested regex and explain each part with test examples.',
    'Create regex for:\n\n{describe pattern}'
  ),
  qa(
    'builtin-sql-query',
    'SQL Query',
    '🗄️',
    'code',
    'coding',
    'Generate optimized SQL queries',
    'You are a SQL expert. Generate efficient SQL and explain indexing/performance implications.',
    'Write SQL for:\n\n{describe}\n\nSchema:\n{paste schema}'
  ),

  // Writing (6)
  qa(
    'builtin-summarize',
    'Summarize',
    '📝',
    'writing',
    'fast',
    'Summarize content into key points',
    'Summarize the content clearly with concise bullet points and key takeaways.',
    'Summarize:\n\n{paste text}'
  ),
  qa(
    'builtin-rewrite',
    'Rewrite',
    '✏️',
    'writing',
    'chat',
    'Rewrite text for clarity/tone',
    'Rewrite while preserving meaning and improving clarity, flow, and tone.',
    'Rewrite this:\n\n{paste text}'
  ),
  qa(
    'builtin-translate',
    'Translate',
    '🌐',
    'writing',
    'chat',
    'Translate while preserving nuance',
    'Translate accurately preserving tone and intent. Provide alternate phrasing if ambiguous.',
    'Translate to {language}:\n\n{paste text}'
  ),
  qa(
    'builtin-proofread',
    'Proofread',
    '✅',
    'writing',
    'fast',
    'Proofread grammar and style',
    'Proofread grammar, spelling, punctuation, and style. Return corrected version and notable issues.',
    'Proofread:\n\n{paste text}'
  ),
  qa(
    'builtin-draft-email',
    'Draft Email',
    '📧',
    'writing',
    'chat',
    'Draft professional email',
    'Draft concise professional emails with clear subject, action items, and tone.',
    'Draft email to {recipient} about {topic}.'
  ),
  qa(
    'builtin-tech-doc',
    'Technical Docs',
    '📄',
    'writing',
    'coding',
    'Write technical documentation',
    'Write clear technical documentation with examples, edge cases, and concise structure.',
    'Document this:\n\n{paste code or feature}'
  ),

  // Analysis (6)
  qa(
    'builtin-deep-think',
    'Deep Think',
    '🧠',
    'analysis',
    'reasoning',
    'Step-by-step deep analysis',
    'Think carefully and step-by-step. Compare alternatives and provide recommendation.',
    'Think through:\n\n{problem}'
  ),
  qa(
    'builtin-compare-options',
    'Compare Options',
    '⚖️',
    'analysis',
    'reasoning',
    'Compare alternatives with trade-offs',
    'Compare options objectively with pros/cons matrix and recommendation.',
    'Compare:\n\n{option A}\nvs\n{option B}'
  ),
  qa(
    'builtin-eli5',
    'Explain Like I’m 5',
    '👶',
    'analysis',
    'chat',
    'Explain complex ideas simply',
    'Explain complex concepts to a beginner using analogies and plain language.',
    'Explain simply:\n\n{topic}'
  ),
  qa(
    'builtin-fact-check',
    'Fact Check',
    '🔎',
    'analysis',
    'reasoning',
    'Check claims and caveats',
    'Evaluate factual claims. Separate confirmed facts, likely true, and uncertain points.',
    'Fact-check:\n\n{claim}'
  ),
  qa(
    'builtin-risk-review',
    'Risk Review',
    '⚠️',
    'analysis',
    'reasoning',
    'Analyze implementation risks',
    'Identify technical, security, and operational risks. Provide mitigations and severity.',
    'Review risks for:\n\n{proposal}'
  ),
  qa(
    'builtin-root-cause',
    'Root Cause Analysis',
    '🧩',
    'analysis',
    'reasoning',
    'Find root causes systematically',
    'Perform root cause analysis and provide 5 whys plus actionable fixes.',
    'Analyze root cause:\n\n{incident description}'
  ),

  // Creative (5)
  qa(
    'builtin-brainstorm',
    'Brainstorm',
    '💡',
    'creative',
    'chat',
    'Generate diverse ideas',
    'Generate diverse ideas including practical and unconventional options.',
    'Brainstorm ideas for:\n\n{topic}'
  ),
  qa(
    'builtin-role-play',
    'Role Play',
    '🎭',
    'creative',
    'chat',
    'Role-play scenario',
    'Stay in character and respond consistently with persona and context.',
    'Role-play:\n\n{scenario}'
  ),
  qa(
    'builtin-story-writer',
    'Story Writer',
    '📚',
    'creative',
    'chat',
    'Write story content',
    'Write engaging story content with strong pacing and vivid details.',
    'Write a story about:\n\n{premise}'
  ),
  qa(
    'builtin-name-generator',
    'Name Generator',
    '🏷️',
    'creative',
    'fast',
    'Generate names with rationale',
    'Generate creative names and explain why each name works.',
    'Generate names for:\n\n{product or concept}'
  ),
  qa(
    'builtin-pitch-maker',
    'Pitch Maker',
    '🎤',
    'creative',
    'chat',
    'Create a concise pitch',
    'Craft a concise compelling pitch with hook, value, and call to action.',
    'Pitch this idea:\n\n{idea}'
  ),

  // DevOps (5)
  qa(
    'builtin-shell-command',
    'Shell Command',
    '💻',
    'devops',
    'coding',
    'Generate safe shell commands',
    'Generate safe macOS zsh commands. Warn explicitly for destructive commands.',
    'Write command to:\n\n{task}'
  ),
  qa(
    'builtin-docker-k8s',
    'Docker/K8s',
    '🐳',
    'devops',
    'coding',
    'Generate Docker/K8s configs',
    'Generate secure Docker/K8s config with sensible defaults and brief rationale.',
    'Generate config for:\n\n{service requirement}'
  ),
  qa(
    'builtin-git-help',
    'Git Help',
    '🌿',
    'devops',
    'fast',
    'Provide git commands for scenarios',
    'Provide exact git commands and explain each command briefly.',
    'Help with git scenario:\n\n{scenario}'
  ),
  qa(
    'builtin-json-yaml',
    'JSON/YAML Tool',
    '📋',
    'devops',
    'fast',
    'Convert/validate data formats',
    'Convert and validate JSON/YAML with clear errors and fixed output.',
    'Convert/validate:\n\n{data}'
  ),
  qa(
    'builtin-release-notes',
    'Release Notes',
    '🚀',
    'devops',
    'chat',
    'Generate release notes from changes',
    'Generate concise release notes grouped by feature/fix/chore.',
    'Create release notes from:\n\n{change log}'
  ),
];
