{"version":3,"file":"completions-command.d.ts","sourceRoot":"","sources":["../../src/cli/completions-command.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2FH,kFAAkF;AAClF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAYhE","sourcesContent":["/**\n * `phi completions <bash|zsh|fish>` — print shell completions.\n *\n * Generated from the live command/flag metadata (top-level commands and\n * builtin slash commands), so completions stay in sync with the CLI.\n */\n\nimport { BUILTIN_SLASH_COMMANDS } from \"../core/slash-commands.ts\";\n\nconst TOP_LEVEL_COMMANDS = [\n\t\"install\",\n\t\"remove\",\n\t\"uninstall\",\n\t\"update\",\n\t\"list\",\n\t\"config\",\n\t\"auth\",\n\t\"login\",\n\t\"logout\",\n\t\"completions\",\n] as const;\n\nconst GLOBAL_FLAGS = [\n\t\"--help\",\n\t\"--version\",\n\t\"--model\",\n\t\"--provider\",\n\t\"--print\",\n\t\"--continue\",\n\t\"--resume\",\n\t\"--mode\",\n\t\"--offline\",\n\t\"--verbose\",\n] as const;\n\nfunction bashCompletions(): string {\n\tconst commands = TOP_LEVEL_COMMANDS.join(\" \");\n\tconst flags = GLOBAL_FLAGS.join(\" \");\n\tconst slash = BUILTIN_SLASH_COMMANDS.map((c) => `/${c.name}`).join(\" \");\n\treturn `# bash completion for phi\n_phi_complete() {\n  local cur prev\n  cur=\"\\${COMP_WORDS[COMP_CWORD]}\"\n  prev=\"\\${COMP_WORDS[COMP_CWORD-1]}\"\n  if [[ $COMP_CWORD -eq 1 ]]; then\n    COMPREPLY=($(compgen -W \"${commands} ${flags}\" -- \"$cur\"))\n    return 0\n  fi\n  if [[ \"$cur\" == /* ]]; then\n    COMPREPLY=($(compgen -W \"${slash}\" -- \"$cur\"))\n    return 0\n  fi\n  COMPREPLY=($(compgen -W \"${flags}\" -- \"$cur\"))\n}\ncomplete -F _phi_complete phi\n`;\n}\n\nfunction zshCompletions(): string {\n\tconst commands = TOP_LEVEL_COMMANDS.map((c) => `'${c}'`).join(\" \");\n\tconst flags = GLOBAL_FLAGS.map((f) => `'${f}'`).join(\" \");\n\tconst slash = BUILTIN_SLASH_COMMANDS.map((c) => `'/${c.name}:${c.description.replace(/'/g, \"\")}'`).join(\" \");\n\treturn `#compdef phi\n# zsh completion for phi\n_phi() {\n  local -a commands flags slash\n  commands=(${commands})\n  flags=(${flags})\n  slash=(${slash})\n  if (( CURRENT == 2 )); then\n    _describe 'command' commands\n    _describe 'flag' flags\n  elif [[ \\${words[CURRENT]} == /* ]]; then\n    _describe 'slash command' slash\n  else\n    _describe 'flag' flags\n  fi\n}\n_phi \"$@\"\n`;\n}\n\nfunction fishCompletions(): string {\n\tconst lines: string[] = [\"# fish completion for phi\"];\n\tfor (const c of TOP_LEVEL_COMMANDS) {\n\t\tlines.push(`complete -c phi -n \"__fish_use_subcommand\" -a \"${c}\"`);\n\t}\n\tfor (const f of GLOBAL_FLAGS) {\n\t\tlines.push(`complete -c phi -l ${f.slice(2)}`);\n\t}\n\tfor (const c of BUILTIN_SLASH_COMMANDS) {\n\t\tlines.push(`complete -c phi -a \"/${c.name}\" -d \"${c.description.replace(/\"/g, \"'\")}\"`);\n\t}\n\treturn `${lines.join(\"\\n\")}\\n`;\n}\n\n/** Handle `phi completions <shell>`. Returns true when the args were consumed. */\nexport function handleCompletionsCommand(args: string[]): boolean {\n\tif (args[0] !== \"completions\") return false;\n\tconst shell = args[1];\n\tif (shell === \"bash\") process.stdout.write(bashCompletions());\n\telse if (shell === \"zsh\") process.stdout.write(zshCompletions());\n\telse if (shell === \"fish\") process.stdout.write(fishCompletions());\n\telse {\n\t\tconsole.error(\"Usage: phi completions <bash|zsh|fish>\");\n\t\tconsole.error(\"Install: phi completions bash > ~/.local/share/bash-completion/completions/phi\");\n\t\tprocess.exitCode = 1;\n\t}\n\treturn true;\n}\n"]}