import type { Context } from 'telegraf';
import { escapeMarkdown } from '../utils/format.js';

const COMMANDS = [
  { cmd: '/help', desc: 'Show this command list' },
  { cmd: '/list', desc: 'All Trello board lists and cards' },
  { cmd: '/todo', desc: 'Cards in the To Do list' },
  { cmd: '/doing', desc: 'Cards currently in progress' },
  { cmd: '/done', desc: 'Recently completed cards' },
  { cmd: '/btw <text>', desc: 'Quick-add a card to Trello' },
  { cmd: '/status', desc: 'AI-generated board summary' },
  { cmd: '/sub <task>', desc: 'Run Claude on the Hetzi codebase' },
  {
    cmd: '/summarize <query>',
    desc: 'Summarize group conversation - e.g. "last 2 hours", "today"',
  },
  {
    cmd: '/search <query>',
    desc: 'Search messages - literal or natural language, e.g. "/search Astro" or "/search payment provider AP mentioned"',
  },
];

export async function helpHandler(ctx: Context): Promise<void> {
  const lines = COMMANDS.map(({ cmd, desc }) => `${escapeMarkdown(cmd)} - ${escapeMarkdown(desc)}`);
  await ctx.replyWithMarkdownV2(`*Hetzi Bot Commands*\n\n${lines.join('\n')}`);
}
