diff options
| author | sigoden <sigoden@gmail.com> | 2025-01-17 20:06:28 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-17 20:06:28 +0800 |
| commit | 30dae5c12b81a6f92be138966d8930fa15612cb0 (patch) | |
| tree | ecb641bedbe8798d6b477f1036d714b99f1a8081 /scripts | |
| parent | 50c60e8097f5148c30295a296063d0fc8391a5f4 (diff) | |
| download | aichat-30dae5c12b81a6f92be138966d8930fa15612cb0.tar.gz | |
feat: support macro (#1087)
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/completions/aichat.bash | 7 | ||||
| -rw-r--r-- | scripts/completions/aichat.fish | 2 | ||||
| -rw-r--r-- | scripts/completions/aichat.nu | 8 | ||||
| -rw-r--r-- | scripts/completions/aichat.ps1 | 6 | ||||
| -rw-r--r-- | scripts/completions/aichat.zsh | 4 |
5 files changed, 24 insertions, 3 deletions
diff --git a/scripts/completions/aichat.bash b/scripts/completions/aichat.bash index c335a6e..4708077 100644 --- a/scripts/completions/aichat.bash +++ b/scripts/completions/aichat.bash @@ -17,7 +17,7 @@ _aichat() { case "${cmd}" in aichat) - opts="-m -r -s -a -e -c -f -S -h -V --model --prompt --role --session --empty-session --save-session --agent --agent-variable --rag --rebuild-rag --serve --execute --code --file --no-stream --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version" + opts="-m -r -s -a -e -c -f -S -h -V --model --prompt --role --session --empty-session --save-session --agent --agent-variable --rag --rebuild-rag --macro --serve --execute --code --file --no-stream --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --list-macros --help --version" if [[ ${cur} == -* || ${cword} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -53,6 +53,11 @@ _aichat() { __ltrim_colon_completions "$cur" return 0 ;; + --macro) + COMPREPLY=($(compgen -W "$("$1" --list-macros)" -- "${cur}")) + __ltrim_colon_completions "$cur" + return 0 + ;; -f|--file) local oldifs if [[ -v IFS ]]; then diff --git a/scripts/completions/aichat.fish b/scripts/completions/aichat.fish index 19446f8..3618a5d 100644 --- a/scripts/completions/aichat.fish +++ b/scripts/completions/aichat.fish @@ -8,6 +8,7 @@ complete -c aichat -s a -l agent -x -a "(aichat --list-agents)" -d 'Start a age complete -c aichat -l agent-variable -d 'Set agent variables' complete -c aichat -l rag -x -a"(aichat --list-rags)" -d 'Start a RAG' -r complete -c aichat -l rebuild-rag -d 'Rebuild the RAG to sync document changes' +complete -c aichat -l macro -x -a"(aichat --list-macros)" -d 'Execute a macro' -r complete -c aichat -l serve -d 'Serve the LLM API and WebAPP' complete -c aichat -s e -l execute -d 'Execute commands in natural language' complete -c aichat -s c -l code -d 'Output code only' @@ -20,5 +21,6 @@ complete -c aichat -l list-roles -d 'List all roles' complete -c aichat -l list-sessions -d 'List all sessions' complete -c aichat -l list-agents -d 'List all agents' complete -c aichat -l list-rags -d 'List all RAGs' +complete -c aichat -l list-macros -d 'List all macros' complete -c aichat -s h -l help -d 'Print help' complete -c aichat -s V -l version -d 'Print version' diff --git a/scripts/completions/aichat.nu b/scripts/completions/aichat.nu index ca41518..bbea5e2 100644 --- a/scripts/completions/aichat.nu +++ b/scripts/completions/aichat.nu @@ -34,6 +34,12 @@ module completions { | parse "{value}" } + def "nu-complete aichat macro" [] { + ^aichat --list-macros | + | lines + | parse "{value}" + } + # All-in-one chat and copilot CLI that integrates 10+ AI platforms export extern aichat [ --model(-m): string@"nu-complete aichat model" # Select a LLM model @@ -46,6 +52,7 @@ module completions { --agent-variable # Set agent variables --rag: string@"nu-complete aichat rag" # Start a RAG --rebuild-rag # Rebuild the RAG to sync document changes + --macro: string@"nu-complete aichat macro" # Execute a macro --serve # Serve the LLM API and WebAPP --execute(-e) # Execute commands in natural language --code(-c) # Output code only @@ -58,6 +65,7 @@ module completions { --list-sessions # List all sessions --list-agents # List all agents --list-rags # List all RAGs + --list-macros # List all macros ...text: string # Input text --help(-h) # Print help --version(-V) # Print version diff --git a/scripts/completions/aichat.ps1 b/scripts/completions/aichat.ps1 index 8827351..dc4ef64 100644 --- a/scripts/completions/aichat.ps1 +++ b/scripts/completions/aichat.ps1 @@ -34,6 +34,7 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock { [CompletionResult]::new('--agent-variable', '--agent-variable', [CompletionResultType]::ParameterName, 'Set agent variables') [CompletionResult]::new('--rag', '--rag', [CompletionResultType]::ParameterName, 'Start a RAG') [CompletionResult]::new('--rebuild-rag', '--rebuild-rag', [CompletionResultType]::ParameterName, 'Rebuild the RAG to sync document changes') + [CompletionResult]::new('--macro', '--macro', [CompletionResultType]::ParameterName, 'Execute a macro') [CompletionResult]::new('--serve', '--serve', [CompletionResultType]::ParameterName, 'Serve the LLM API and WebAPP') [CompletionResult]::new('-e', '-e', [CompletionResultType]::ParameterName, 'Execute commands in natural language') [CompletionResult]::new('--execute', '--execute', [CompletionResultType]::ParameterName, 'Execute commands in natural language') @@ -50,6 +51,7 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock { [CompletionResult]::new('--list-sessions', '--list-sessions', [CompletionResultType]::ParameterName, 'List all sessions') [CompletionResult]::new('--list-agents', '--list-agents', [CompletionResultType]::ParameterName, 'List all agents') [CompletionResult]::new('--list-rags', '--list-rags', [CompletionResultType]::ParameterName, 'List all RAGs') + [CompletionResult]::new('--list-macros', '--list-macros', [CompletionResultType]::ParameterName, 'List all macros') [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('-V', '-V', [CompletionResultType]::ParameterName, 'Print version') @@ -77,8 +79,10 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock { $completions = Get-AichatValues "--list-sessions" } elseif ($flag -ceq "-a" -or $flag -eq "--agent") { $completions = Get-AichatValues "--list-agents" - } elseif ($flag -ceq "-R" -or $flag -eq "--rag") { + } elseif ($flag -eq "--rag") { $completions = Get-AichatValues "--list-rags" + } elseif ($flag -eq "--macro") { + $completions = Get-AichatValues "--list-macros" } elseif ($flag -ceq "-f" -or $flag -eq "--file") { $completions = @() } diff --git a/scripts/completions/aichat.zsh b/scripts/completions/aichat.zsh index bb6fcda..15cbdce 100644 --- a/scripts/completions/aichat.zsh +++ b/scripts/completions/aichat.zsh @@ -29,6 +29,7 @@ _aichat() { '--agent-variable[Set agent variables]' \ '--rag[Start a RAG]:RAG:->rags' \ '--rebuild-rag[Rebuild the RAG to sync document changes]' \ +'--macro[Execute a macro]:MACRO:->macros' \ '--serve[Serve the LLM API and WebAPP]' \ '-e[Execute commands in natural language]' \ '--execute[Execute commands in natural language]' \ @@ -45,6 +46,7 @@ _aichat() { '--list-sessions[List all sessions]' \ '--list-agents[List all agents]' \ '--list-rags[List all RAGs]' \ +'--list-macros[List all macros]' \ '-h[Print help]' \ '--help[Print help]' \ '-V[Print version]' \ @@ -56,7 +58,7 @@ _aichat() { _arguments "${_arguments_options[@]}" $common \ && ret=0 case $state in - models|roles|sessions|agents|rags) + models|roles|sessions|agents|rags|macros) local -a values expl values=( ${(f)"$(_call_program values aichat --list-$state)"} ) _wanted values expl $state compadd -a values && ret=0 |
