Some agents (like OpenCode) accept model configuration via CLI flags
instead of environment variables. Added _synu_agent_{agent}_args hook
that returns additional arguments to pass during execution.
Fixed flag extraction loop in main wrapper to handle arbitrary flag
names (including new -m/model for OpenCode). Adds OpenCode agent
definition that uses both cache system and CLI args feature.
Assisted-by: Claude Sonnet 4.5 via Crush
@@ -83,6 +83,7 @@ function synu --description "Universal agent wrapper with Synthetic API quota tr
set -l parsed_args
if test -n "$flag_spec"
# Parse with --ignore-unknown so agent-native flags pass through
+ # @fish-lsp-disable-next-line 4004
argparse --ignore-unknown $flag_spec -- $agent_args
or return 1
@@ -91,8 +92,7 @@ function synu --description "Universal agent wrapper with Synthetic API quota tr
# Rebuild the flag arguments to pass to configure
# Check each possible flag and add if set
- for flag in L/large l/light o/opus s/sonnet H/haiku a/agent- set -l short_flag (string split '/' $flag)[1]
+ for flag in L/large l/light o/opus s/sonnet H/haiku a/agent m/model
set -l long_flag (string split '/' $flag)[2]
set -l var_name _flag_$long_flag
if set -q $var_name
@@ -106,6 +106,12 @@ function synu --description "Universal agent wrapper with Synthetic API quota tr
or return 1
end
+ # Check if agent provides extra CLI arguments (for agents that don't use env vars)
+ set -l extra_args
+ if functions -q _synu_agent_{$agent}_args
+ set extra_args (_synu_agent_{$agent}_args)
+ end
+
# Fetch quota before agent execution
set -l quota_before (_synu_get_quota)
if test $status -ne 0
@@ -121,7 +127,8 @@ function synu --description "Universal agent wrapper with Synthetic API quota tr
# Execute the agent with all arguments passed through unchanged
# Use 'command' to bypass function recursion and call the actual binary
- command $agent $agent_args
+ # extra_args contains agent-specific CLI flags (e.g., -m for opencode)
+ command $agent $extra_args $agent_args
set -l exit_status $status
# Fetch quota after agent execution