| #!/usr/bin/env zsh |
|
|
| |
|
|
| |
| function _forge_action_agent() { |
| local input_text="$1" |
| |
| echo |
| |
| |
| if [[ -n "$input_text" ]]; then |
| local agent_id="$input_text" |
| |
| |
| local agent_exists=$($_FORGE_BIN list agents --porcelain 2>/dev/null | tail -n +2 | grep -q "^${agent_id}\b" && echo "true" || echo "false") |
| if [[ "$agent_exists" == "false" ]]; then |
| _forge_log error "Agent '\033[1m${agent_id}\033[0m' not found" |
| return 0 |
| fi |
| |
| |
| _FORGE_ACTIVE_AGENT="$agent_id" |
| |
| |
| _forge_log success "Switched to agent \033[1m${agent_id}\033[0m" |
| |
| return 0 |
| fi |
| |
| |
| local agent_id |
| agent_id=$(_forge_select_with_query "$input_text" agent) |
| |
| if [[ -n "$agent_id" ]]; then |
| _FORGE_ACTIVE_AGENT="$agent_id" |
| _forge_log success "Switched to agent \033[1m${agent_id}\033[0m" |
| fi |
| } |
|
|
| |
| |
| function _forge_action_model() { |
| local input_text="$1" |
| echo |
|
|
| local model_id provider_id |
| if _forge_select_model_pair_global "$input_text"; then |
| model_id="${reply[1]}" |
| provider_id="${reply[2]}" |
| _forge_exec config set model "$provider_id" "$model_id" |
| fi |
| } |
|
|
| |
| |
| function _forge_action_commit_model() { |
| local input_text="$1" |
| echo |
|
|
| local model_id provider_id |
| if _forge_select_model_pair "$input_text"; then |
| model_id="${reply[1]}" |
| provider_id="${reply[2]}" |
| _forge_exec config set commit "$provider_id" "$model_id" |
| fi |
| } |
|
|
| |
| |
| function _forge_action_suggest_model() { |
| local input_text="$1" |
| echo |
|
|
| local model_id provider_id |
| if _forge_select_model_pair "$input_text"; then |
| model_id="${reply[1]}" |
| provider_id="${reply[2]}" |
| _forge_exec config set suggest "$provider_id" "$model_id" |
| fi |
| } |
|
|
| |
| function _forge_action_sync() { |
| echo |
| |
| |
| |
| |
| _forge_exec_interactive workspace sync --init |
| } |
|
|
| |
| function _forge_action_sync_init() { |
| echo |
| |
| _forge_exec_interactive workspace init |
| } |
|
|
| |
| function _forge_action_sync_status() { |
| echo |
| _forge_exec workspace status "." |
| } |
|
|
| |
| function _forge_action_sync_info() { |
| echo |
| _forge_exec workspace info "." |
| } |
|
|
| |
| |
| |
| |
| function _forge_action_session_model() { |
| local input_text="$1" |
| echo |
|
|
| if _forge_select_model_pair "$input_text"; then |
| _FORGE_SESSION_MODEL="${reply[1]}" |
| _FORGE_SESSION_PROVIDER="${reply[2]}" |
| _forge_log success "Session model set to \033[1m${_FORGE_SESSION_MODEL}\033[0m (provider: \033[1m${_FORGE_SESSION_PROVIDER}\033[0m)" |
| fi |
| } |
|
|
| |
| |
| |
| |
| function _forge_action_config_reload() { |
| echo |
|
|
| if [[ -z "$_FORGE_SESSION_MODEL" && -z "$_FORGE_SESSION_PROVIDER" && -z "$_FORGE_SESSION_REASONING_EFFORT" ]]; then |
| _forge_log info "No session overrides active (already using global config)" |
| return 0 |
| fi |
|
|
| _FORGE_SESSION_MODEL="" |
| _FORGE_SESSION_PROVIDER="" |
| _FORGE_SESSION_REASONING_EFFORT="" |
|
|
| _forge_log success "Session overrides cleared — using global config" |
| } |
|
|
| |
| |
| |
| |
| function _forge_action_reasoning_effort() { |
| local input_text="$1" |
| echo |
|
|
| local selected |
| selected=$(_forge_select_with_query "$input_text" reasoning-effort) |
|
|
| if [[ -n "$selected" ]]; then |
| _FORGE_SESSION_REASONING_EFFORT="$selected" |
| _forge_log success "Session reasoning effort set to \033[1m${selected}\033[0m" |
| fi |
| } |
|
|
| |
| |
| |
| function _forge_action_config_reasoning_effort() { |
| local input_text="$1" |
| echo |
|
|
| local selected |
| selected=$(_forge_select_with_query "$input_text" reasoning-effort) |
|
|
| if [[ -n "$selected" ]]; then |
| _forge_exec config set reasoning-effort "$selected" |
| fi |
| } |
|
|
| |
| function _forge_action_config() { |
| echo |
| _forge_exec config list |
| } |
|
|
| |
| function _forge_action_config_edit() { |
| echo |
|
|
| |
| local editor_cmd="${FORGE_EDITOR:-${EDITOR:-nano}}" |
|
|
| |
| if ! command -v "${editor_cmd%% *}" &>/dev/null; then |
| _forge_log error "Editor not found: $editor_cmd (set FORGE_EDITOR or EDITOR)" |
| return 1 |
| fi |
|
|
| |
| |
| local config_file |
| config_file=$($_FORGE_BIN config path 2>/dev/null) |
| if [[ -z "$config_file" ]]; then |
| _forge_log error "Failed to resolve config path from '$_FORGE_BIN config path'" |
| return 1 |
| fi |
|
|
| local config_dir |
| config_dir=$(dirname "$config_file") |
|
|
| |
| if [[ ! -d "$config_dir" ]]; then |
| mkdir -p "$config_dir" || { |
| _forge_log error "Failed to create $config_dir directory" |
| return 1 |
| } |
| fi |
|
|
| |
| if [[ ! -f "$config_file" ]]; then |
| touch "$config_file" || { |
| _forge_log error "Failed to create $config_file" |
| return 1 |
| } |
| fi |
|
|
| |
| (eval "$editor_cmd '$config_file'" </dev/tty >/dev/tty 2>&1) |
| local exit_code=$? |
|
|
| if [[ $exit_code -ne 0 ]]; then |
| _forge_log error "Editor exited with error code $exit_code" |
| fi |
|
|
| _forge_reset |
| } |
|
|
| |
| function _forge_action_tools() { |
| echo |
| |
| local agent_id="${_FORGE_ACTIVE_AGENT:-forge}" |
| _forge_exec list tools "$agent_id" |
| } |
|
|
| |
| function _forge_action_skill() { |
| echo |
| _forge_exec list skill |
| } |
|
|