{"version":3,"file":"completion.mjs","names":[],"sources":["../../src/feature/completion.ts"],"sourcesContent":["import { extractSchemaMetadata, getJsonSchema } from '../core/args.ts';\nimport type { AnyPadroneCommand } from '../types/index.ts';\nimport { detectShell, getRcFile, type ShellType, writeToRcFile } from '../util/shell-utils.ts';\n\nexport { detectShell, escapeRegExp, getRcFile, type ShellType, writeToRcFile } from '../util/shell-utils.ts';\n\n/**\n * Collects all commands from a program recursively.\n */\nfunction collectAllCommands(cmd: AnyPadroneCommand): AnyPadroneCommand[] {\n  const result: AnyPadroneCommand[] = [];\n\n  if (cmd.commands) {\n    for (const subcmd of cmd.commands) {\n      if (!subcmd.hidden) {\n        result.push(subcmd);\n        result.push(...collectAllCommands(subcmd));\n      }\n    }\n  }\n\n  return result;\n}\n\ninterface ExtractedArg {\n  name: string;\n  alias?: string;\n  isBoolean: boolean;\n  enum?: string[];\n  description?: string;\n}\n\n/**\n * Extracts all argument names from a command's schema.\n */\nfunction extractArguments(cmd: AnyPadroneCommand): ExtractedArg[] {\n  const argList: ExtractedArg[] = [];\n\n  if (!cmd.argsSchema) return argList;\n\n  try {\n    const argsMeta = cmd.meta?.fields;\n    const { aliases } = extractSchemaMetadata(cmd.argsSchema, argsMeta, cmd.meta?.autoAlias);\n\n    // Build reverse map: argName → aliasName\n    const argToAlias: Record<string, string> = {};\n    for (const [aliasName, argName] of Object.entries(aliases)) {\n      if (!argToAlias[argName]) argToAlias[argName] = aliasName;\n    }\n\n    const jsonSchema = getJsonSchema(cmd.argsSchema) as Record<string, any>;\n\n    if (jsonSchema.type === 'object' && jsonSchema.properties) {\n      for (const [key, prop] of Object.entries(jsonSchema.properties as Record<string, any>)) {\n        const enumValues = (prop.enum ?? prop.items?.enum) as string[] | undefined;\n        const optMeta = argsMeta?.[key];\n        argList.push({\n          name: key,\n          alias: argToAlias[key],\n          isBoolean: prop?.type === 'boolean',\n          enum: enumValues,\n          description: optMeta?.description ?? prop.description,\n        });\n      }\n    }\n  } catch {\n    // Ignore schema parsing errors\n  }\n\n  return argList;\n}\n\n/**\n * Collects unique args across all commands, preserving first-seen enum values.\n */\nfunction collectUniqueArgs(program: AnyPadroneCommand, commands: AnyPadroneCommand[]): Map<string, ExtractedArg> {\n  const seen = new Map<string, ExtractedArg>();\n\n  for (const cmd of [program, ...commands]) {\n    for (const arg of extractArguments(cmd)) {\n      if (!seen.has(arg.name)) {\n        seen.set(arg.name, arg);\n      }\n    }\n  }\n\n  return seen;\n}\n\n/**\n * Generates a Bash completion script for the program.\n */\nexport function generateBashCompletion(program: AnyPadroneCommand): string {\n  const programName = program.name;\n  const commands = collectAllCommands(program);\n  const commandNames = commands.map((c) => c.name).join(' ');\n  const uniqueArgs = collectUniqueArgs(program, commands);\n\n  // Collect all option names\n  const allArguments = new Set<string>();\n  allArguments.add('--help');\n  allArguments.add('--version');\n\n  for (const arg of uniqueArgs.values()) {\n    allArguments.add(`--${arg.name}`);\n    if (arg.alias) allArguments.add(`--${arg.alias}`);\n  }\n\n  const argsList = Array.from(allArguments).join(' ');\n\n  // Build case branches for options with enum values\n  const enumCases: string[] = [];\n  for (const arg of uniqueArgs.values()) {\n    if (!arg.enum || arg.enum.length === 0) continue;\n    const values = arg.enum.join(' ');\n    const patterns = [`--${arg.name}`];\n    if (arg.alias) patterns.push(`--${arg.alias}`);\n    enumCases.push(`      ${patterns.join('|')}) COMPREPLY=($(compgen -W \"${values}\" -- \"$cur\")); return 0 ;;`);\n  }\n\n  const enumBlock =\n    enumCases.length > 0\n      ? `\n    # Complete option values\n    case \"$prev\" in\n${enumCases.join('\\n')}\n    esac\n\n`\n      : '\\n';\n\n  return `###-begin-${programName}-completion-###\n#\n# ${programName} command completion script\n#\n# Installation: ${programName} completion >> ~/.bashrc  (or ~/.zshrc)\n# Or, maybe: ${programName} completion > /usr/local/etc/bash_completion.d/${programName}\n#\n\nif type complete &>/dev/null; then\n  _${programName}_completion() {\n    local cur prev words cword\n    if type _get_comp_words_by_ref &>/dev/null; then\n      _get_comp_words_by_ref -n = -n @ -n : -w words -i cword\n    else\n      cword=\"$COMP_CWORD\"\n      words=(\"\\${COMP_WORDS[@]}\")\n    fi\n\n    cur=\"\\${words[cword]}\"\n    prev=\"\\${words[cword-1]}\"\n\n    local commands=\"${commandNames}\"\n    local args=\"${argsList}\"\n${enumBlock}    # Complete args when current word starts with -\n    if [[ \"$cur\" == -* ]]; then\n      COMPREPLY=($(compgen -W \"$args\" -- \"$cur\"))\n      return 0\n    fi\n\n    # Complete commands\n    COMPREPLY=($(compgen -W \"$commands\" -- \"$cur\"))\n  }\n  complete -o bashdefault -o default -o nospace -F _${programName}_completion ${programName}\nelif type compdef &>/dev/null; then\n  _${programName}_completion() {\n    local si=$IFS\n    local commands=\"${commandNames}\"\n    local args=\"${argsList}\"\n\n    if [[ \"\\${words[CURRENT]}\" == -* ]]; then\n      compadd -- \\${=args}\n    else\n      compadd -- \\${=commands}\n    fi\n    IFS=$si\n  }\n  compdef _${programName}_completion ${programName}\nelif type compctl &>/dev/null; then\n  _${programName}_completion() {\n    local commands=\"${commandNames}\"\n    local args=\"${argsList}\"\n\n    if [[ \"\\${words[CURRENT]}\" == -* ]]; then\n      reply=(\\${=args})\n    else\n      reply=(\\${=commands})\n    fi\n  }\n  compctl -K _${programName}_completion ${programName}\nfi\n###-end-${programName}-completion-###`;\n}\n\n/**\n * Generates a Zsh completion script for the program.\n */\nexport function generateZshCompletion(program: AnyPadroneCommand): string {\n  const programName = program.name;\n  const commands = collectAllCommands(program);\n\n  // Generate command completions with descriptions\n  const commandCompletions = commands\n    .map((cmd) => {\n      const desc = cmd.description || cmd.title || '';\n      const escapedDesc = desc.replace(/'/g, \"'\\\\''\").replace(/:/g, '\\\\:');\n      return `      '${cmd.name}:${escapedDesc}'`;\n    })\n    .join('\\n');\n\n  // Collect all args with descriptions and enum values\n  const argumentCompletions: string[] = [];\n  argumentCompletions.push(\"      '--help[Show help information]'\");\n  argumentCompletions.push(\"      '--version[Show version number]'\");\n\n  const uniqueArgs = collectUniqueArgs(program, commands);\n\n  for (const arg of uniqueArgs.values()) {\n    const desc = arg.description || '';\n    const escapedDesc = desc.replace(/'/g, \"'\\\\''\").replace(/\\[/g, '\\\\[').replace(/\\]/g, '\\\\]');\n\n    // Zsh action spec for enum values: :label:(val1 val2 val3)\n    const valueAction = arg.enum?.length ? `: :(${arg.enum.join(' ')})` : '';\n\n    if (arg.alias) {\n      argumentCompletions.push(`      {--${arg.alias},--${arg.name}}'[${escapedDesc}]${valueAction}'`);\n    } else {\n      argumentCompletions.push(`      '--${arg.name}[${escapedDesc}]${valueAction}'`);\n    }\n  }\n\n  return `#compdef ${programName}\n###-begin-${programName}-completion-###\n#\n# ${programName} command completion script for Zsh\n#\n# Installation: ${programName} completion >> ~/.zshrc\n# Or: ${programName} completion > ~/.zsh/completions/_${programName}\n#\n\n_${programName}() {\n  local -a commands\n  local -a args\n\n  commands=(\n${commandCompletions}\n  )\n\n  args=(\n${argumentCompletions.join('\\n')}\n  )\n\n  _arguments -s \\\\\n    $args \\\\\n    '1: :->command' \\\\\n    '*::arg:->args'\n\n  case \"$state\" in\n    command)\n      _describe 'command' commands\n      ;;\n  esac\n}\n\n_${programName}\n###-end-${programName}-completion-###`;\n}\n\n/**\n * Generates a Fish completion script for the program.\n */\nexport function generateFishCompletion(program: AnyPadroneCommand): string {\n  const programName = program.name;\n  const commands = collectAllCommands(program);\n\n  const lines: string[] = [\n    `###-begin-${programName}-completion-###`,\n    '#',\n    `# ${programName} command completion script for Fish`,\n    '#',\n    `# Installation: ${programName} completion > ~/.config/fish/completions/${programName}.fish`,\n    '#',\n    '',\n    `# Clear existing completions`,\n    `complete -c ${programName} -e`,\n    '',\n    '# Commands',\n  ];\n\n  for (const cmd of commands) {\n    const desc = cmd.description || cmd.title || '';\n    const escapedDesc = desc.replace(/'/g, \"\\\\'\");\n    lines.push(`complete -c ${programName} -n \"__fish_use_subcommand\" -a \"${cmd.name}\" -d '${escapedDesc}'`);\n  }\n\n  lines.push('');\n  lines.push('# Global arguments');\n  lines.push(`complete -c ${programName} -l help -d 'Show help information'`);\n  lines.push(`complete -c ${programName} -l version -d 'Show version number'`);\n\n  const uniqueArgs = collectUniqueArgs(program, commands);\n\n  for (const arg of uniqueArgs.values()) {\n    const desc = arg.description || '';\n    const escapedDesc = desc.replace(/'/g, \"\\\\'\");\n    // Fish: -xa 'val1 val2' provides exclusive value completions\n    const valueFlag = arg.enum?.length ? ` -xa '${arg.enum.join(' ')}'` : '';\n\n    if (arg.alias) {\n      lines.push(`complete -c ${programName} -l ${arg.name} -s ${arg.alias} -d '${escapedDesc}'${valueFlag}`);\n    } else {\n      lines.push(`complete -c ${programName} -l ${arg.name} -d '${escapedDesc}'${valueFlag}`);\n    }\n  }\n\n  lines.push(`###-end-${programName}-completion-###`);\n\n  return lines.join('\\n');\n}\n\n/**\n * Generates a PowerShell completion script for the program.\n */\nexport function generatePowerShellCompletion(program: AnyPadroneCommand): string {\n  const programName = program.name;\n  const commands = collectAllCommands(program);\n  const uniqueArgs = collectUniqueArgs(program, commands);\n\n  const commandNames = commands.map((c) => `'${c.name}'`).join(', ');\n\n  // Collect all option names\n  const argNames: string[] = [\"'--help'\", \"'--version'\"];\n  for (const arg of uniqueArgs.values()) {\n    argNames.push(`'--${arg.name}'`);\n    if (arg.alias) argNames.push(`'--${arg.alias}'`);\n  }\n\n  // Build switch cases for option value completion\n  const enumCases: string[] = [];\n  for (const arg of uniqueArgs.values()) {\n    if (!arg.enum || arg.enum.length === 0) continue;\n    const values = arg.enum.map((v) => `'${v}'`).join(', ');\n    const patterns = [`'--${arg.name}'`];\n    if (arg.alias) patterns.push(`'--${arg.alias}'`);\n    enumCases.push(`      ${patterns.join(', ')} { @(${values}) | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n        [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n      }; return }`);\n  }\n\n  const enumBlock =\n    enumCases.length > 0\n      ? `\n  # Complete option values\n  $prevWord = $commandAst.CommandElements | Select-Object -Last 2 | Select-Object -First 1\n  switch ($prevWord) {\n${enumCases.join('\\n')}\n  }\n\n`\n      : '\\n';\n\n  return `###-begin-${programName}-completion-###\n#\n# ${programName} command completion script for PowerShell\n#\n# Installation: ${programName} completion >> $PROFILE\n#\n\nRegister-ArgumentCompleter -Native -CommandName ${programName} -ScriptBlock {\n  param($wordToComplete, $commandAst, $cursorPosition)\n\n  $commands = @(${commandNames})\n  $args = @(${argNames.join(', ')})\n${enumBlock}  if ($wordToComplete -like '-*') {\n    $args | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n      [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n    }\n  } else {\n    $commands | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n      [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n    }\n  }\n}\n###-end-${programName}-completion-###`;\n}\n\n/**\n * Generates a completion script for the specified shell.\n */\nexport function generateCompletion(program: AnyPadroneCommand, shell: ShellType): string {\n  switch (shell) {\n    case 'bash':\n      return generateBashCompletion(program);\n    case 'zsh':\n      return generateZshCompletion(program);\n    case 'fish':\n      return generateFishCompletion(program);\n    case 'powershell':\n      return generatePowerShellCompletion(program);\n    default:\n      throw new Error(`Unsupported shell: ${shell}`);\n  }\n}\n\n/**\n * Gets the installation instructions for a shell completion script.\n */\nexport function getCompletionInstallInstructions(programName: string, shell: ShellType): string {\n  switch (shell) {\n    case 'bash':\n      return `# Add to ~/.bashrc:\n${programName} completion bash >> ~/.bashrc\n\n# Or install system-wide:\n${programName} completion bash > /usr/local/etc/bash_completion.d/${programName}`;\n\n    case 'zsh':\n      return `# Add to ~/.zshrc:\n${programName} completion zsh >> ~/.zshrc\n\n# Or add to completions directory:\n${programName} completion zsh > ~/.zsh/completions/_${programName}`;\n\n    case 'fish':\n      return `# Install to Fish completions:\n${programName} completion fish > ~/.config/fish/completions/${programName}.fish`;\n\n    case 'powershell':\n      return `# Add to PowerShell profile:\n${programName} completion powershell >> $PROFILE`;\n\n    default:\n      return `# Run: ${programName} completion <shell>\n# Supported shells: bash, zsh, fish, powershell`;\n  }\n}\n\n/**\n * Generates the completion output with automatic shell detection.\n * If shell is not specified, detects the current shell and provides instructions.\n */\nexport async function generateCompletionOutput(program: AnyPadroneCommand, shell?: ShellType): Promise<string> {\n  const programName = program.name;\n\n  if (shell) {\n    return generateCompletion(program, shell);\n  }\n\n  // Auto-detect shell and provide instructions\n  const detectedShell = await detectShell();\n\n  if (detectedShell) {\n    const instructions = getCompletionInstallInstructions(programName, detectedShell);\n    const script = generateCompletion(program, detectedShell);\n\n    return `# Detected shell: ${detectedShell}\n#\n${instructions}\n#\n# Or evaluate directly (temporary, for current session only):\n# eval \"$(${programName} completion ${detectedShell})\"\n\n${script}`;\n  }\n\n  // Could not detect shell - provide usage info\n  return `# Shell auto-detection failed.\n#\n# Usage: ${programName} completion <shell>\n#\n# Supported shells:\n#   bash       - Bash completion script\n#   zsh        - Zsh completion script\n#   fish       - Fish completion script\n#   powershell - PowerShell completion script\n#\n# Example:\n#   ${programName} completion bash >> ~/.bashrc\n#   ${programName} completion zsh >> ~/.zshrc\n#   ${programName} completion fish > ~/.config/fish/completions/${programName}.fish\n#   ${programName} completion powershell >> $PROFILE`;\n}\n\nexport interface SetupCompletionsResult {\n  /** The file that was written to. */\n  file: string;\n  /** Whether an existing completion block was replaced (true) or a new one was appended (false). */\n  updated: boolean;\n}\n\n/**\n * Sets up shell completions by writing an eval snippet to the appropriate shell config file.\n * Uses marker comments for idempotency — re-running replaces the existing block.\n */\nexport async function setupCompletions(programName: string, shell: ShellType): Promise<SetupCompletionsResult> {\n  const { existsSync, mkdirSync, writeFileSync } = await import('node:fs');\n  const { join } = await import('node:path');\n  const { homedir } = await import('node:os');\n\n  const beginMarker = `###-begin-${programName}-completion-###`;\n  const endMarker = `###-end-${programName}-completion-###`;\n  const snippet = buildSetupSnippet(programName, shell, beginMarker, endMarker);\n\n  if (shell === 'fish') {\n    const completionsDir = join(homedir(), '.config', 'fish', 'completions');\n    const filePath = join(completionsDir, `${programName}.fish`);\n    mkdirSync(completionsDir, { recursive: true });\n    const existed = existsSync(filePath);\n    writeFileSync(filePath, `${snippet}\\n`);\n    return { file: filePath, updated: existed };\n  }\n\n  const rcFile = await getRcFile(shell);\n  if (!rcFile) {\n    throw new Error(`Could not determine config file for ${shell}.`);\n  }\n\n  return writeToRcFile(rcFile, snippet, beginMarker, endMarker);\n}\n\nfunction buildSetupSnippet(programName: string, shell: ShellType, beginMarker: string, endMarker: string): string {\n  const evalCmd = `${programName} completion ${shell}`;\n\n  switch (shell) {\n    case 'bash':\n    case 'zsh':\n      return `${beginMarker}\\neval \"$(${evalCmd})\"\\n${endMarker}`;\n    case 'fish':\n      return `${beginMarker}\\n${evalCmd} | source\\n${endMarker}`;\n    case 'powershell':\n      return `${beginMarker}\\n${evalCmd} | Invoke-Expression\\n${endMarker}`;\n  }\n}\n"],"mappings":";;;;;;AASA,SAAS,mBAAmB,KAA6C;CACvE,MAAM,SAA8B,CAAC;CAErC,IAAI,IAAI;OACD,MAAM,UAAU,IAAI,UACvB,IAAI,CAAC,OAAO,QAAQ;GAClB,OAAO,KAAK,MAAM;GAClB,OAAO,KAAK,GAAG,mBAAmB,MAAM,CAAC;EAC3C;;CAIJ,OAAO;AACT;;;;AAaA,SAAS,iBAAiB,KAAwC;CAChE,MAAM,UAA0B,CAAC;CAEjC,IAAI,CAAC,IAAI,YAAY,OAAO;CAE5B,IAAI;EACF,MAAM,WAAW,IAAI,MAAM;EAC3B,MAAM,EAAE,YAAY,sBAAsB,IAAI,YAAY,UAAU,IAAI,MAAM,SAAS;EAGvF,MAAM,aAAqC,CAAC;EAC5C,KAAK,MAAM,CAAC,WAAW,YAAY,OAAO,QAAQ,OAAO,GACvD,IAAI,CAAC,WAAW,UAAU,WAAW,WAAW;EAGlD,MAAM,aAAa,cAAc,IAAI,UAAU;EAE/C,IAAI,WAAW,SAAS,YAAY,WAAW,YAC7C,KAAK,MAAM,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