# Fish completion for pieces
# This file is automatically generated by the Pieces CLI.
# Do not edit this file manually.
# Version: 1.16.1

# Disable file completions by default
complete -c pieces -f

# Helper function to check if we're completing the first argument (command)
function __pieces_needs_command
    set -l cmd (commandline -opc)
    set -e cmd[1]  # Remove the program name
    for arg in $cmd
        # If we find a non-option argument, we have a command
        if not string match -q -- '-*' $arg
            return 1
        end
    end
    return 0
end

# Helper function to get the current command
function __pieces_get_command
    set -l cmd (commandline -opc)
    set -e cmd[1]  # Remove the program name
    for arg in $cmd
        if not string match -q -- '-*' $arg
            echo $arg
            return 0
        end
    end
    return 1
end

# Helper function to check if we're in a specific command
function __pieces_using_command
    set -l cmd (__pieces_get_command)
    test "$cmd" = "$argv[1]"
end

# Helper function to check if we need a subcommand for a command group
function __pieces_needs_subcommand
    set -l cmd (commandline -opc)
    set -e cmd[1]  # Remove the program name
    set -l command_found 0
    set -l subcommand_found 0

    for arg in $cmd
        if not string match -q -- '-*' $arg
            if test $command_found -eq 0
                # This is the main command
                if test "$arg" = "$argv[1]"
                    set command_found 1
                else
                    return 1  # Different command
                end
            else
                # This is a subcommand
                set subcommand_found 1
                return 1
            end
        end
    end

    # We found the command but no subcommand yet
    test $command_found -eq 1 -a $subcommand_found -eq 0
end

# Helper function to get the subcommand
function __pieces_get_subcommand
    set -l cmd (commandline -opc)
    set -e cmd[1]  # Remove the program name
    set -l command_found 0

    for arg in $cmd
        if not string match -q -- '-*' $arg
            if test $command_found -eq 0
                set command_found 1
            else
                # This is the subcommand
                echo $arg
                return 0
            end
        end
    end
    return 1
end

# Helper function to check if we're using a specific subcommand
function __pieces_using_subcommand
    set -l main_cmd (__pieces_get_command)
    set -l sub_cmd (__pieces_get_subcommand)
    test "$main_cmd" = "$argv[1]" -a "$sub_cmd" = "$argv[2]"
end

# Helper function to check if the last argument is a specific flag
function __pieces_last_arg_is
    set -l cmd (commandline -opc)
    set -l last_arg $cmd[-1]
    test "$last_arg" = "$argv[1]"
end

# Helper function to check if we should complete option values
function __pieces_should_complete_option_value
    set -l flag $argv[1]
    set -l cmd_condition $argv[2]
    
    # Check if the command condition is met
    if not eval $cmd_condition
        return 1
    end
    
    # Check if the last token is exactly the flag (with space after it)
    # This prevents showing values when typing -i without space
    set -l line (commandline -c)
    set -l last_char (string sub -s -1 "$line")
    
    # Only show completions if there's a space after the flag
    if test "$last_char" = " "
        # Check if the previous token is our flag
        if __pieces_last_arg_is "$flag"
            return 0
        end
    end
    
    return 1
end

# Global options - only available before any command is specified
complete -c pieces -n "__pieces_needs_command" -s h -l help -d "Show help message"
complete -c pieces -n "__pieces_needs_command" -s v -l version -d "Show version"
complete -c pieces -n "__pieces_needs_command" -l ignore-onboarding -d "Ignore onboarding for this command"

# Commands - only show when no command is specified yet
complete -c pieces -n "__pieces_needs_command" -a "ask" -d "Ask a question to the Copilot"
complete -c pieces -n "__pieces_needs_command" -a "chat" -d "Select a chat"
complete -c pieces -n "__pieces_needs_command" -a "chats" -d "Print all chats"
complete -c pieces -n "__pieces_needs_command" -a "commit" -d "Auto-generate a GitHub commit message and commit changes"
complete -c pieces -n "__pieces_needs_command" -a "completion" -d "Display shell completion scripts"
complete -c pieces -n "__pieces_needs_command" -a "config" -d "Configure settings"
complete -c pieces -n "__pieces_needs_command" -a "contribute" -d "How to contribute"
complete -c pieces -n "__pieces_needs_command" -a "create" -d "Create a new material"
complete -c pieces -n "__pieces_needs_command" -a "delete" -d "Delete the current material"
complete -c pieces -n "__pieces_needs_command" -a "edit" -d "Edit an existing material\'s metadata"
complete -c pieces -n "__pieces_needs_command" -a "execute" -d "Execute shell or bash materials"
complete -c pieces -n "__pieces_needs_command" -a "feedback" -d "Submit feedback"
complete -c pieces -n "__pieces_needs_command" -a "install" -d "Install PiecesOS"
complete -c pieces -n "__pieces_needs_command" -a "list" -d "List materials or apps or models"
complete -c pieces -n "__pieces_needs_command" -a "login" -d "Sign into PiecesOS"
complete -c pieces -n "__pieces_needs_command" -a "logout" -d "Sign out from PiecesOS"
complete -c pieces -n "__pieces_needs_command" -a "mcp" -d "setup the MCP server for an integration"
complete -c pieces -n "__pieces_needs_command" -a "modify" -d "Updates the current material content"
complete -c pieces -n "__pieces_needs_command" -a "onboarding" -d "Start the onboarding process"
complete -c pieces -n "__pieces_needs_command" -a "open" -d "Opens PiecesOS or Applet"
complete -c pieces -n "__pieces_needs_command" -a "run" -d "Runs CLI in a loop"
complete -c pieces -n "__pieces_needs_command" -a "search" -d "Perform a search for materials using the specified query string"
complete -c pieces -n "__pieces_needs_command" -a "share" -d "Share the current material"
complete -c pieces -n "__pieces_needs_command" -a "version" -d "Gets version of PiecesOS"
complete -c pieces -n "__pieces_needs_command" -a "conversation" -d "Alias for chat"
complete -c pieces -n "__pieces_needs_command" -a "conversations" -d "Alias for chats"
complete -c pieces -n "__pieces_needs_command" -a "drive" -d "Alias for list"
complete -c pieces -n "__pieces_needs_command" -a "save" -d "Alias for modify"

# Command-specific completions
complete -c pieces -n "__pieces_using_command config" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command config" -s e -l editor -d "Set the default code editor"
complete -c pieces -n "__pieces_using_command list" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command list" -s e -l editor -d "Open the chosen material in the editor"
# Positional argument: type
complete -c pieces -n "__pieces_using_command list" -x -a "materials apps models" -d "Type of the list"
complete -c pieces -n "__pieces_using_command drive" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command drive" -s e -l editor -d "Open the chosen material in the editor"
# Positional argument: type
complete -c pieces -n "__pieces_using_command drive" -x -a "materials apps models" -d "Type of the list"
complete -c pieces -n "__pieces_using_command login" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command logout" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command search" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command search" -l mode -x -a "fuzzy ncs fts" -d "Type of search"
complete -c pieces -n "__pieces_using_command modify" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command save" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command delete" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command create" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command create" -s c -l content -d "Enter snippet content manually in the terminal or via stdin"
complete -c pieces -n "__pieces_using_command share" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command edit" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command edit" -s n -l name -d "Set a new name for the material"
complete -c pieces -n "__pieces_using_command edit" -s c -l classification -d "Reclassify a material (eg. py, js)"
complete -c pieces -n "__pieces_using_command run" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command execute" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command feedback" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command contribute" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command install" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command onboarding" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command version" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command ask" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command ask" -s f -l files -r -F -d "Provide one or more files or folders as context (absolute or relative path)"
complete -c pieces -n "__pieces_using_command ask" -s m -l materials -x -a "1 2 3 4 5 6 7 8 9 10" -d "Use one or more saved materials as context (provide material's index)."
complete -c pieces -n "__pieces_using_command ask" -l ltm -d "Enable Long-Term Memory (LTM) to include prior context"
complete -c pieces -n "__pieces_using_command chats" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command conversations" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command chat" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command chat" -s n -l new -d "Create a new chat"
complete -c pieces -n "__pieces_using_command chat" -s r -l rename -d "Rename the conversation that you are currently. If nothing is specified it will rename the current chat using the llm model"
complete -c pieces -n "__pieces_using_command chat" -s d -l delete -d "Delete the chat that you are currently using in the ask command"
complete -c pieces -n "__pieces_using_command conversation" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command conversation" -s n -l new -d "Create a new chat"
complete -c pieces -n "__pieces_using_command conversation" -s r -l rename -d "Rename the conversation that you are currently. If nothing is specified it will rename the current chat using the llm model"
complete -c pieces -n "__pieces_using_command conversation" -s d -l delete -d "Delete the chat that you are currently using in the ask command"
complete -c pieces -n "__pieces_using_command commit" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command commit" -s p -l push -d "Push the code to GitHub"
complete -c pieces -n "__pieces_using_command commit" -s a -l all -d "Stage all the files before committing"
complete -c pieces -n "__pieces_using_command commit" -s i -l issues -d "Add issue number in the commit message"
complete -c pieces -n "__pieces_using_command open" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_command open" -s p -l pieces_os -d "Opens PiecesOS"
complete -c pieces -n "__pieces_using_command open" -s c -l copilot -d "Opens Pieces Copilot"
complete -c pieces -n "__pieces_using_command open" -s d -l drive -d "Opens Pieces Drive"
complete -c pieces -n "__pieces_using_command open" -s s -l settings -d "Opens Pieces Settings"
complete -c pieces -n "__pieces_using_command completion" -s h -l help -d "show this help message and exit"
# Positional argument: shell
complete -c pieces -n "__pieces_using_command completion" -x -a "bash zsh fish powershell" -d "Shell to show the completion script for"

# Command groups

# mcp subcommands
complete -c pieces -n "__pieces_using_command mcp" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_needs_subcommand mcp" -a "docs" -d "Print the documentations for an integration"
complete -c pieces -n "__pieces_needs_subcommand mcp" -a "list" -d "List all MCP integrations"
complete -c pieces -n "__pieces_needs_subcommand mcp" -a "repair" -d "Repair an MCP config settings"
complete -c pieces -n "__pieces_needs_subcommand mcp" -a "setup" -d "Set up an integration"
complete -c pieces -n "__pieces_needs_subcommand mcp" -a "start" -d "Start the stdio MCP server"
complete -c pieces -n "__pieces_needs_subcommand mcp" -a "status" -d "Show the Status of the LTM and the MCPs"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l vscode -d "Set up the MCP for VS Code"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l goose -d "Set up the MCP for Goose"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l cursor -d "Set up the MCP for Cursor"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l claude -d "Set up the MCP for Claude Desktop"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l windsurf -d "Set up the MCP for Windsurf"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l zed -d "Set up the MCP for Zed"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l shortwave -d "Set up the MCP for Shortwave"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l claude_code -d "Set up the MCP for Claude Code"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l raycast -d "Set up the MCP for Raycast"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l wrap -d "Set up the MCP for Wrap"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l globally -d "For VS Code or Cursor to set the Global MCP"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l specific-workspace -d "For VS Code or Cursor to set the Local MCP"
complete -c pieces -n "__pieces_using_subcommand mcp setup" -l stdio -d "Use the stdio MCP instead of sse"
complete -c pieces -n "__pieces_using_subcommand mcp list" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_subcommand mcp list" -l already-registered -d "Display the list of the registered MCPs"
complete -c pieces -n "__pieces_using_subcommand mcp list" -l available-for-setup -d "Display the list of the ready to be registered MCPs"
complete -c pieces -n "__pieces_using_subcommand mcp docs" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_subcommand mcp docs" -s i -l integration -x -a "vscode goose cursor claude windsurf zed shortwave claude_code all current raycast wrap" -d "The integration to print its documentation"
complete -c pieces -n "__pieces_using_subcommand mcp docs" -s o -l open -d "Open the queried docs in the browser"
complete -c pieces -n "__pieces_using_subcommand mcp start" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_subcommand mcp repair" -s h -l help -d "show this help message and exit"
complete -c pieces -n "__pieces_using_subcommand mcp repair" -s i -l integration -x -a "vscode goose cursor claude windsurf zed shortwave claude_code all" -d "The integration to repair"
complete -c pieces -n "__pieces_using_subcommand mcp status" -s h -l help -d "show this help message and exit"
