###-begin-opencode-completions-###
#
# Static completion script for Bash
#
# Installation:
#   opencode --completions bash >> ~/.bashrc
#

if ! type _init_completion &>/dev/null; then
  _init_completion()
  {
    COMPREPLY=()
    local _i _j=0 _piece _line="$COMP_LINE"
    words=("${COMP_WORDS[0]}")
    cword=0
    _line="${_line#*"${COMP_WORDS[0]}"}"
    for ((_i = 1; _i < ${#COMP_WORDS[@]}; _i++)); do
      _piece="${COMP_WORDS[_i]}"
      if [[ "$_line" == [[:blank:]]* ]]; then
        ((_j++))
        words[_j]="$_piece"
      else
        words[_j]="${words[_j]}$_piece"
      fi
      ((_i == COMP_CWORD)) && cword=$_j
      _line="${_line#*"$_piece"}"
    done
    cur="${words[cword]}"
    prev=""
    ((cword > 0)) && prev="${words[cword-1]}"
    return 0
  }
fi

_opencode--choices()
{
  local _cur="$1" _word="$2"; shift 2

  local _head="${_cur%"$_word"}"
  local _open=""
  case "$_head" in
    *\') _open="'" ;;
    *\") _open='"' ;;
  esac

  local _prefix="$_cur" _committed="$_head"
  _prefix=${_prefix//\\/}; _prefix=${_prefix//\"/}; _prefix=${_prefix//\'/}
  _committed=${_committed//\\/}; _committed=${_committed//\"/}; _committed=${_committed//\'/}

  COMPREPLY=()
  local _choice _rest _match
  for _choice in "$@"; do
    [[ "$_choice" == "$_prefix"* ]] || continue
    _rest="${_choice#"$_committed"}"
    case "$_open" in
      "'")
        if [[ "$_head" == "'" ]]; then
          _match=${_rest//\'/\'\\\'\'}
        else
          [[ "$_rest" == *\'* ]] && continue
          _match="$_rest"
        fi
        ;;
      '"')
        _match="${_rest//\\/\\\\}"
        _match="${_match//\$/\\$}"
        _match="${_match//\`/\\\`}"
        _match="${_match//\"/\\\"}"
        ;;
      *)
        printf -v _match '%q' "$_rest"
        [[ -z "$_head" && "$_match" == '~'* ]] && _match="\\$_match"
        ;;
    esac
    [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"
    COMPREPLY+=("$_match")
  done
}

_opencode()
{
  local cur prev words cword i
  local _command_index=0
  _init_completion -n "$COMP_WORDBREAKS" || return
  local _comp_word="$2"

  # Flag value completions
  case "$prev" in
  esac

  # Subcommand dispatch
  local cmd _skip_next=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    case "${words[i]}" in
      --server) _skip_next=1 ;;
      --server=*) ;;
      --session|-s) _skip_next=1 ;;
      --session=*|-s=*) ;;
      --prompt) _skip_next=1 ;;
      --prompt=*) ;;
      upgrade)
        _opencode_upgrade "$i"
        return
        ;;
      uninstall)
        _opencode_uninstall "$i"
        return
        ;;
      acp)
        _opencode_acp "$i"
        return
        ;;
      api)
        _opencode_api "$i"
        return
        ;;
      debug)
        _opencode_debug "$i"
        return
        ;;
      auth)
        _opencode_auth "$i"
        return
        ;;
      mcp)
        _opencode_mcp "$i"
        return
        ;;
      plugin)
        _opencode_plugin "$i"
        return
        ;;
      models)
        _opencode_models "$i"
        return
        ;;
      stats)
        _opencode_stats "$i"
        return
        ;;
      mini)
        _opencode_mini "$i"
        return
        ;;
      run)
        _opencode_run "$i"
        return
        ;;
      session)
        _opencode_session "$i"
        return
        ;;
      service)
        _opencode_service "$i"
        return
        ;;
      pair)
        _opencode_pair "$i"
        return
        ;;
      serve)
        _opencode_serve "$i"
        return
        ;;
    esac
  done

  local _used_0="" _used_1="" _used_2="" _used_3="" _used_4="" _used_5=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --auto|--no-auto) _used_2=1 ;;
      --continue|-c|--no-continue) _used_3=1 ;;
      --session|-s) _used_4=1 ;;
      --prompt) _used_5=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --auto --no-auto"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --continue -c --no-continue"
  [[ -n "$_used_4" ]] || _filtered_flags+=" --session -s"
  [[ -n "$_used_5" ]] || _filtered_flags+=" --prompt"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

  COMPREPLY=( $(compgen -W 'upgrade uninstall acp api debug auth mcp plugin models stats mini run session service pair serve' -- "$cur") )
}

_opencode_upgrade()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
    --method|-m)
      _opencode--choices "$cur" "$_comp_word" 'curl' 'npm' 'pnpm' 'bun' 'yarn'
      return
      ;;
  esac

  local _used_0=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --method|-m) _used_0=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --method -m"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_uninstall()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  local _used_0="" _used_1="" _used_2="" _used_3=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --keep-config|-c|--no-keep-config) _used_0=1 ;;
      --keep-data|-d|--no-keep-data) _used_1=1 ;;
      --dry-run|--no-dry-run) _used_2=1 ;;
      --force|-f|--no-force) _used_3=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --keep-config -c --no-keep-config"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --keep-data -d --no-keep-data"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --dry-run --no-dry-run"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --force -f --no-force"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_acp()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_api()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2="" _used_3="" _used_4=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --data|-d) _used_2=1 ;;
      --header|-H) _used_3=1 ;;
      --param) _used_4=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --data -d"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --header -H"
  [[ -n "$_used_4" ]] || _filtered_flags+=" --param"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_debug()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Subcommand dispatch
  local cmd _skip_next=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    case "${words[i]}" in
      agents)
        _opencode_debug_agents "$i"
        return
        ;;
      config)
        _opencode_debug_config "$i"
        return
        ;;
      paths)
        _opencode_debug_paths "$i"
        return
        ;;
    esac
  done

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    return
  fi

  COMPREPLY=( $(compgen -W 'agents config paths' -- "$cur") )
}

_opencode_debug_agents()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_debug_config()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_debug_paths()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Positional argument completions
  local _position=0 _skip_next=0 _end_of_options=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    if (( _end_of_options )); then
      ((_position += 1))
      continue
    fi
    case "${words[i]}" in
      --) _end_of_options=1 ;;
      -*) ;;
      *) ((_position += 1)) ;;
    esac
  done
  case "$_position" in
    0)
      _opencode--choices "$cur" "$_comp_word" 'db' 'home' 'data' 'config' 'cache' 'state' 'tmp' 'bin' 'log' 'repos'
      return
      ;;
  esac
}

_opencode_auth()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Subcommand dispatch
  local cmd _skip_next=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    case "${words[i]}" in
      list)
        _opencode_auth_list "$i"
        return
        ;;
      login)
        _opencode_auth_login "$i"
        return
        ;;
      logout)
        _opencode_auth_logout "$i"
        return
        ;;
      switch)
        _opencode_auth_switch "$i"
        return
        ;;
    esac
  done

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    return
  fi

  COMPREPLY=( $(compgen -W 'list login logout switch' -- "$cur") )
}

_opencode_auth_list()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
    --format)
      _opencode--choices "$cur" "$_comp_word" 'default' 'json'
      return
      ;;
  esac

  local _used_0="" _used_1="" _used_2=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --format) _used_2=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --format"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_auth_login()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --method) _used_2=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --method"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_auth_logout()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_auth_switch()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_mcp()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Subcommand dispatch
  local cmd _skip_next=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    case "${words[i]}" in
      list)
        _opencode_mcp_list "$i"
        return
        ;;
      add)
        _opencode_mcp_add "$i"
        return
        ;;
      auth)
        _opencode_mcp_auth "$i"
        return
        ;;
      logout)
        _opencode_mcp_logout "$i"
        return
        ;;
    esac
  done

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    return
  fi

  COMPREPLY=( $(compgen -W 'list add auth logout' -- "$cur") )
}

_opencode_mcp_list()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_mcp_add()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2="" _used_3=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --url) _used_0=1 ;;
      --header) _used_1=1 ;;
      --env) _used_2=1 ;;
      --global|--no-global) _used_3=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --url"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --header"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --env"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --global --no-global"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_mcp_auth()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_mcp_logout()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_plugin()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Subcommand dispatch
  local cmd _skip_next=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    case "${words[i]}" in
      list)
        _opencode_plugin_list "$i"
        return
        ;;
      add)
        _opencode_plugin_add "$i"
        return
        ;;
      check)
        _opencode_plugin_check "$i"
        return
        ;;
      update)
        _opencode_plugin_update "$i"
        return
        ;;
      remove)
        _opencode_plugin_remove "$i"
        return
        ;;
    esac
  done

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    return
  fi

  COMPREPLY=( $(compgen -W 'list add check update remove' -- "$cur") )
}

_opencode_plugin_list()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  local _used_0=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --builtin|--no-builtin) _used_0=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --builtin --no-builtin"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_plugin_add()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_plugin_check()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_plugin_update()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_plugin_remove()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_models()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_stats()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2="" _used_3="" _used_4="" _used_5="" _used_6="" _used_7="" _used_8="" _used_9="" _used_10="" _used_11=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --days) _used_2=1 ;;
      --year) _used_3=1 ;;
      --all|--no-all) _used_4=1 ;;
      --project) _used_5=1 ;;
      --models|--no-models) _used_6=1 ;;
      --tools|--no-tools) _used_7=1 ;;
      --cost|--no-cost) _used_8=1 ;;
      --full|--no-full) _used_9=1 ;;
      --limit) _used_10=1 ;;
      --json|--no-json) _used_11=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --days"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --year"
  [[ -n "$_used_4" ]] || _filtered_flags+=" --all --no-all"
  [[ -n "$_used_5" ]] || _filtered_flags+=" --project"
  [[ -n "$_used_6" ]] || _filtered_flags+=" --models --no-models"
  [[ -n "$_used_7" ]] || _filtered_flags+=" --tools --no-tools"
  [[ -n "$_used_8" ]] || _filtered_flags+=" --cost --no-cost"
  [[ -n "$_used_9" ]] || _filtered_flags+=" --full --no-full"
  [[ -n "$_used_10" ]] || _filtered_flags+=" --limit"
  [[ -n "$_used_11" ]] || _filtered_flags+=" --json --no-json"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_mini()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2="" _used_3="" _used_4="" _used_5="" _used_6="" _used_7="" _used_8="" _used_9=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --continue|-c|--no-continue) _used_2=1 ;;
      --session|-s) _used_3=1 ;;
      --fork|--no-fork) _used_4=1 ;;
      --replay|--no-replay) _used_5=1 ;;
      --replay-limit) _used_6=1 ;;
      --model|-m) _used_7=1 ;;
      --agent) _used_8=1 ;;
      --prompt) _used_9=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --continue -c --no-continue"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --session -s"
  [[ -n "$_used_4" ]] || _filtered_flags+=" --fork --no-fork"
  [[ -n "$_used_5" ]] || _filtered_flags+=" --replay --no-replay"
  [[ -n "$_used_6" ]] || _filtered_flags+=" --replay-limit"
  [[ -n "$_used_7" ]] || _filtered_flags+=" --model -m"
  [[ -n "$_used_8" ]] || _filtered_flags+=" --agent"
  [[ -n "$_used_9" ]] || _filtered_flags+=" --prompt"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_run()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
    --format)
      _opencode--choices "$cur" "$_comp_word" 'default' 'json'
      return
      ;;
  esac

  local _used_0="" _used_1="" _used_2="" _used_3="" _used_4="" _used_5="" _used_6="" _used_7="" _used_8="" _used_9="" _used_10="" _used_11=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --continue|-c|--no-continue) _used_2=1 ;;
      --session|-s) _used_3=1 ;;
      --fork|--no-fork) _used_4=1 ;;
      --model|-m) _used_5=1 ;;
      --agent) _used_6=1 ;;
      --format) _used_7=1 ;;
      --file|-f) _used_8=1 ;;
      --title) _used_9=1 ;;
      --thinking|--no-thinking) _used_10=1 ;;
      --auto|--no-auto) _used_11=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --continue -c --no-continue"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --session -s"
  [[ -n "$_used_4" ]] || _filtered_flags+=" --fork --no-fork"
  [[ -n "$_used_5" ]] || _filtered_flags+=" --model -m"
  [[ -n "$_used_6" ]] || _filtered_flags+=" --agent"
  [[ -n "$_used_7" ]] || _filtered_flags+=" --format"
  [[ -n "$_used_8" ]] || _filtered_flags+=" --file -f"
  [[ -n "$_used_9" ]] || _filtered_flags+=" --title"
  [[ -n "$_used_10" ]] || _filtered_flags+=" --thinking --no-thinking"
  [[ -n "$_used_11" ]] || _filtered_flags+=" --auto --no-auto"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_session()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Subcommand dispatch
  local cmd _skip_next=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    case "${words[i]}" in
      list)
        _opencode_session_list "$i"
        return
        ;;
      delete)
        _opencode_session_delete "$i"
        return
        ;;
      export)
        _opencode_session_export "$i"
        return
        ;;
      import)
        _opencode_session_import "$i"
        return
        ;;
    esac
  done

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    return
  fi

  COMPREPLY=( $(compgen -W 'list delete export import' -- "$cur") )
}

_opencode_session_list()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
    --format)
      _opencode--choices "$cur" "$_comp_word" 'table' 'json'
      return
      ;;
  esac

  local _used_0="" _used_1="" _used_2="" _used_3=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --max-count|-n) _used_2=1 ;;
      --format) _used_3=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --max-count -n"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --format"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_session_delete()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_session_export()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --sanitize|--no-sanitize) _used_2=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --sanitize --no-sanitize"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_session_import()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --standalone|--no-standalone) _used_0=1 ;;
      --server) _used_1=1 ;;
      --directory) _used_2=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --standalone --no-standalone"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --server"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --directory"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_service()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Subcommand dispatch
  local cmd _skip_next=0
  for ((i = _command_index + 1; i < cword; i++)); do
    if (( _skip_next )); then
      _skip_next=0
      continue
    fi
    case "${words[i]}" in
      start)
        _opencode_service_start "$i"
        return
        ;;
      restart)
        _opencode_service_restart "$i"
        return
        ;;
      status)
        _opencode_service_status "$i"
        return
        ;;
      stop)
        _opencode_service_stop "$i"
        return
        ;;
      get)
        _opencode_service_get "$i"
        return
        ;;
      set)
        _opencode_service_set "$i"
        return
        ;;
      unset)
        _opencode_service_unset "$i"
        return
        ;;
    esac
  done

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    return
  fi

  COMPREPLY=( $(compgen -W 'start restart status stop get set unset' -- "$cur") )
}

_opencode_service_start()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_service_restart()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_service_status()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_service_stop()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_service_get()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_service_set()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_service_unset()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

}

_opencode_pair()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --url) _used_0=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --url"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

_opencode_serve()
{
  local cur prev words cword i
  local _command_index="$1"
  _init_completion -n "$COMP_WORDBREAKS" || return

  # Flag value completions
  case "$prev" in
  esac

  local _used_0="" _used_1="" _used_2="" _used_3="" _used_4=""
  for ((i = 1; i < cword; i++)); do
    case "${words[i]%%=*}" in
      --hostname) _used_0=1 ;;
      --port) _used_1=1 ;;
      --cors) _used_2=1 ;;
      --service|--no-service) _used_3=1 ;;
      --stdio|--no-stdio) _used_4=1 ;;
    esac
  done
  local _filtered_flags=""
  [[ -n "$_used_0" ]] || _filtered_flags+=" --hostname"
  [[ -n "$_used_1" ]] || _filtered_flags+=" --port"
  [[ -n "$_used_2" ]] || _filtered_flags+=" --cors"
  [[ -n "$_used_3" ]] || _filtered_flags+=" --service --no-service"
  [[ -n "$_used_4" ]] || _filtered_flags+=" --stdio --no-stdio"

  # Complete flags (filtered) and subcommands
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )
    return
  fi

}

complete -F _opencode opencode
###-end-opencode-completions-###
