|
| 1 | +# Fish completions for forge CLI |
| 2 | +# Auto-loaded from ~/.config/fish/completions/ |
| 3 | + |
| 4 | +# ── Helpers ─────────────────────────────────────────────────────────────────── |
| 5 | +# __forge_needs_subcommand <parent> |
| 6 | +# True when <parent> has been seen but the next positional arg is still needed. |
| 7 | +# Works by counting positional (non-option) tokens on the command line. |
| 8 | +function __forge_needs_subcommand |
| 9 | + set -l parent $argv[1] |
| 10 | + set -l cmd (commandline -opc) |
| 11 | + set -l found_parent 0 |
| 12 | + for tok in $cmd[2..] # skip "forge" itself |
| 13 | + switch $tok |
| 14 | + case '-*' |
| 15 | + continue |
| 16 | + case '*' |
| 17 | + if test $found_parent -eq 0 |
| 18 | + if test "$tok" = "$parent" |
| 19 | + set found_parent 1 |
| 20 | + end |
| 21 | + else |
| 22 | + # A positional token after parent => subcommand already present |
| 23 | + return 1 |
| 24 | + end |
| 25 | + end |
| 26 | + end |
| 27 | + # Return true only if we found the parent and there's no sub yet |
| 28 | + test $found_parent -eq 1 |
| 29 | +end |
| 30 | + |
| 31 | +# __forge_at_depth3 <parent> <child> |
| 32 | +# True when "forge <parent> <child>" have been seen and a 3rd positional |
| 33 | +# argument is still needed (e.g. "forge config set <TAB>"). |
| 34 | +function __forge_at_depth3 |
| 35 | + set -l parent $argv[1] |
| 36 | + set -l child $argv[2] |
| 37 | + set -l cmd (commandline -opc) |
| 38 | + set -l depth 0 |
| 39 | + set -l match_parent 0 |
| 40 | + set -l match_child 0 |
| 41 | + for tok in $cmd[2..] |
| 42 | + switch $tok |
| 43 | + case '-*' |
| 44 | + continue |
| 45 | + case '*' |
| 46 | + set depth (math $depth + 1) |
| 47 | + if test $depth -eq 1; and test "$tok" = "$parent" |
| 48 | + set match_parent 1 |
| 49 | + else if test $depth -eq 2; and test $match_parent -eq 1; and test "$tok" = "$child" |
| 50 | + set match_child 1 |
| 51 | + else if test $depth -ge 3 |
| 52 | + return 1 # already have a 3rd token |
| 53 | + end |
| 54 | + end |
| 55 | + end |
| 56 | + test $match_parent -eq 1; and test $match_child -eq 1 |
| 57 | +end |
| 58 | + |
| 59 | +# Disable file completions by default for forge |
| 60 | +complete -c forge -f |
| 61 | + |
| 62 | +# ── Top-level subcommands ───────────────────────────────────────────────────── |
| 63 | +complete -c forge -n __fish_use_subcommand -a agent -d "Manage agents" |
| 64 | +complete -c forge -n __fish_use_subcommand -a zsh -d "Generate shell extension scripts" |
| 65 | +complete -c forge -n __fish_use_subcommand -a list -d "List agents, models, providers, tools, or MCP servers" |
| 66 | +complete -c forge -n __fish_use_subcommand -a banner -d "Display the banner with version information" |
| 67 | +complete -c forge -n __fish_use_subcommand -a info -d "Show configuration, active model, and environment status" |
| 68 | +complete -c forge -n __fish_use_subcommand -a env -d "Display environment information" |
| 69 | +complete -c forge -n __fish_use_subcommand -a config -d "Get, set, or list configuration values" |
| 70 | +complete -c forge -n __fish_use_subcommand -a conversation -d "Manage conversation history and state" |
| 71 | +complete -c forge -n __fish_use_subcommand -a commit -d "Generate and optionally commit changes with AI-generated message" |
| 72 | +complete -c forge -n __fish_use_subcommand -a mcp -d "Manage Model Context Protocol servers" |
| 73 | +complete -c forge -n __fish_use_subcommand -a suggest -d "Generate shell commands without executing them" |
| 74 | +complete -c forge -n __fish_use_subcommand -a provider -d "Manage API provider authentication" |
| 75 | +complete -c forge -n __fish_use_subcommand -a cmd -d "Run or list custom commands" |
| 76 | +complete -c forge -n __fish_use_subcommand -a workspace -d "Manage workspaces for semantic search" |
| 77 | +complete -c forge -n __fish_use_subcommand -a data -d "Process JSONL data through LLM" |
| 78 | +complete -c forge -n __fish_use_subcommand -a vscode -d "VS Code integration commands" |
| 79 | +complete -c forge -n __fish_use_subcommand -a update -d "Update forge to the latest version" |
| 80 | +complete -c forge -n __fish_use_subcommand -a setup -d "Setup zsh integration" |
| 81 | +complete -c forge -n __fish_use_subcommand -a doctor -d "Run diagnostics on shell environment" |
| 82 | + |
| 83 | +# Top-level options |
| 84 | +complete -c forge -n __fish_use_subcommand -s p -l prompt -d "Direct prompt to process" |
| 85 | +complete -c forge -n __fish_use_subcommand -l conversation -d "Path to conversation JSON" -r -F |
| 86 | +complete -c forge -n __fish_use_subcommand -l conversation-id -d "Conversation ID to use" |
| 87 | +complete -c forge -n __fish_use_subcommand -s C -l directory -d "Working directory" -r -a "(__fish_complete_directories)" |
| 88 | +complete -c forge -n __fish_use_subcommand -l sandbox -d "Isolated git worktree name" |
| 89 | +complete -c forge -n __fish_use_subcommand -l verbose -d "Enable verbose logging" |
| 90 | +complete -c forge -n __fish_use_subcommand -l agent -d "Agent ID to use" |
| 91 | +complete -c forge -n __fish_use_subcommand -s e -l event -d "Event to dispatch (JSON)" |
| 92 | +complete -c forge -n __fish_use_subcommand -s h -l help -d "Print help" |
| 93 | +complete -c forge -n __fish_use_subcommand -s V -l version -d "Print version" |
| 94 | + |
| 95 | +# ── config subcommands ──────────────────────────────────────────────────────── |
| 96 | +complete -c forge -n "__forge_needs_subcommand config" -a set -d "Set a configuration value" |
| 97 | +complete -c forge -n "__forge_needs_subcommand config" -a get -d "Get a configuration value" |
| 98 | +complete -c forge -n "__forge_needs_subcommand config" -a list -d "List configuration" |
| 99 | + |
| 100 | +# config set targets |
| 101 | +complete -c forge -n "__forge_at_depth3 config set" -a model -d "Set default model" |
| 102 | +complete -c forge -n "__forge_at_depth3 config set" -a provider -d "Set default provider" |
| 103 | +complete -c forge -n "__forge_at_depth3 config set" -a commit -d "Set commit model" |
| 104 | +complete -c forge -n "__forge_at_depth3 config set" -a suggest -d "Set suggest model" |
| 105 | +complete -c forge -n "__forge_at_depth3 config set" -a reasoning-effort -d "Set reasoning effort" |
| 106 | + |
| 107 | +# config get targets |
| 108 | +complete -c forge -n "__forge_at_depth3 config get" -a model -d "Get default model" |
| 109 | +complete -c forge -n "__forge_at_depth3 config get" -a provider -d "Get default provider" |
| 110 | +complete -c forge -n "__forge_at_depth3 config get" -a commit -d "Get commit model" |
| 111 | +complete -c forge -n "__forge_at_depth3 config get" -a suggest -d "Get suggest model" |
| 112 | +complete -c forge -n "__forge_at_depth3 config get" -a reasoning-effort -d "Get reasoning effort" |
| 113 | + |
| 114 | +# ── conversation subcommands ────────────────────────────────────────────────── |
| 115 | +complete -c forge -n "__forge_needs_subcommand conversation" -a list -d "List conversations" |
| 116 | +complete -c forge -n "__forge_needs_subcommand conversation" -a new -d "Create new conversation" |
| 117 | +complete -c forge -n "__forge_needs_subcommand conversation" -a dump -d "Export conversation" |
| 118 | +complete -c forge -n "__forge_needs_subcommand conversation" -a compact -d "Compact conversation" |
| 119 | +complete -c forge -n "__forge_needs_subcommand conversation" -a retry -d "Retry last turn" |
| 120 | +complete -c forge -n "__forge_needs_subcommand conversation" -a resume -d "Resume conversation" |
| 121 | +complete -c forge -n "__forge_needs_subcommand conversation" -a show -d "Show conversation" |
| 122 | +complete -c forge -n "__forge_needs_subcommand conversation" -a info -d "Show conversation info" |
| 123 | +complete -c forge -n "__forge_needs_subcommand conversation" -a stats -d "Show conversation stats" |
| 124 | +complete -c forge -n "__forge_needs_subcommand conversation" -a clone -d "Clone conversation" |
| 125 | +complete -c forge -n "__forge_needs_subcommand conversation" -a delete -d "Delete conversation" |
| 126 | +complete -c forge -n "__forge_needs_subcommand conversation" -a rename -d "Rename conversation" |
| 127 | + |
| 128 | +# ── list subcommands ────────────────────────────────────────────────────────── |
| 129 | +complete -c forge -n "__forge_needs_subcommand list" -a agent -d "List agents" |
| 130 | +complete -c forge -n "__forge_needs_subcommand list" -a provider -d "List providers" |
| 131 | +complete -c forge -n "__forge_needs_subcommand list" -a model -d "List models" |
| 132 | +complete -c forge -n "__forge_needs_subcommand list" -a command -d "List commands" |
| 133 | +complete -c forge -n "__forge_needs_subcommand list" -a config -d "List config" |
| 134 | +complete -c forge -n "__forge_needs_subcommand list" -a tool -d "List tools" |
| 135 | +complete -c forge -n "__forge_needs_subcommand list" -a mcp -d "List MCP servers" |
| 136 | +complete -c forge -n "__forge_needs_subcommand list" -a conversation -d "List conversations" |
| 137 | +complete -c forge -n "__forge_needs_subcommand list" -a cmd -d "List custom commands" |
| 138 | +complete -c forge -n "__forge_needs_subcommand list" -a skill -d "List skills" |
| 139 | + |
| 140 | +# ── provider subcommands ────────────────────────────────────────────────────── |
| 141 | +complete -c forge -n "__forge_needs_subcommand provider" -a login -d "Log in to provider" |
| 142 | +complete -c forge -n "__forge_needs_subcommand provider" -a logout -d "Log out from provider" |
| 143 | +complete -c forge -n "__forge_needs_subcommand provider" -a list -d "List providers" |
| 144 | + |
| 145 | +# ── mcp subcommands ─────────────────────────────────────────────────────────── |
| 146 | +complete -c forge -n "__forge_needs_subcommand mcp" -a import -d "Import MCP server config" |
| 147 | +complete -c forge -n "__forge_needs_subcommand mcp" -a list -d "List MCP servers" |
| 148 | +complete -c forge -n "__forge_needs_subcommand mcp" -a remove -d "Remove MCP server" |
| 149 | +complete -c forge -n "__forge_needs_subcommand mcp" -a show -d "Show MCP server details" |
| 150 | +complete -c forge -n "__forge_needs_subcommand mcp" -a reload -d "Reload MCP servers" |
| 151 | + |
| 152 | +# ── workspace subcommands ───────────────────────────────────────────────────── |
| 153 | +complete -c forge -n "__forge_needs_subcommand workspace" -a sync -d "Sync workspace" |
| 154 | +complete -c forge -n "__forge_needs_subcommand workspace" -a init -d "Initialize workspace" |
| 155 | +complete -c forge -n "__forge_needs_subcommand workspace" -a status -d "Show workspace status" |
| 156 | +complete -c forge -n "__forge_needs_subcommand workspace" -a info -d "Show workspace info" |
| 157 | + |
| 158 | +# ── commit options ──────────────────────────────────────────────────────────── |
| 159 | +complete -c forge -n "__fish_seen_subcommand_from commit" -l max-diff -d "Maximum git diff size in bytes" |
| 160 | +complete -c forge -n "__fish_seen_subcommand_from commit" -l preview -d "Preview commit message without committing" |
| 161 | + |
| 162 | +# ── zsh subcommands ─────────────────────────────────────────────────────────── |
| 163 | +complete -c forge -n "__forge_needs_subcommand zsh" -a plugin -d "Generate shell plugin script" |
| 164 | +complete -c forge -n "__forge_needs_subcommand zsh" -a theme -d "Generate shell theme" |
| 165 | +complete -c forge -n "__forge_needs_subcommand zsh" -a doctor -d "Run diagnostics" |
| 166 | +complete -c forge -n "__forge_needs_subcommand zsh" -a rprompt -d "Get rprompt information" |
| 167 | +complete -c forge -n "__forge_needs_subcommand zsh" -a setup -d "Setup zsh integration" |
| 168 | +complete -c forge -n "__forge_needs_subcommand zsh" -a keyboard -d "Show keyboard shortcuts" |
| 169 | + |
| 170 | +# Common flags across subcommands |
| 171 | +complete -c forge -n "__fish_seen_subcommand_from list agent provider mcp config conversation" -l porcelain -d "Machine-readable output" |
| 172 | +complete -c forge -n "__fish_seen_subcommand_from list agent provider mcp config conversation" -s h -l help -d "Print help" |
0 commit comments