Skip to content

feat: --auto flag to unlock auto/bypassPermissions modes#22

Open
BenSheridanEdwards wants to merge 2 commits into
aattaran:mainfrom
BenSheridanEdwards:feat/auto-mode
Open

feat: --auto flag to unlock auto/bypassPermissions modes#22
BenSheridanEdwards wants to merge 2 commits into
aattaran:mainfrom
BenSheridanEdwards:feat/auto-mode

Conversation

@BenSheridanEdwards
Copy link
Copy Markdown

Claude Code disables auto and bypassPermissions permission modes when ANTHROPIC_DEFAULT_*_MODEL is not a claude-* value. Default deepclaude exports the resolved backend name (deepseek-v4-pro etc.) so the gate stays locked and Shift+Tab reports "auto mode isn't available for this model".

This PR adds an opt-in --auto flag. When passed, set_model_env exports canonical claude-opus-4-7 / claude-sonnet-4-6 / claude-haiku-4-5-20251001 in place of the backend names. The proxy translates them back to the configured backend on the wire via MODEL_REMAP. The TUI's welcome chip will display the canonical name — that's the explicit, opt-in tradeoff for unlocking the gate.

Default behaviour is unchanged: backend names in env vars and TUI, no auto/bypassPermissions, no model remap fires.

Why opt-in

Surfacing the right tradeoff at launch matters because deepclaude's premise is cost savings — silently lying about the model in the TUI would mislead users about where their tokens are landing. With --auto, the user is asking for the gate to be unlocked; they accept the TUI showing a Claude name in exchange. With --auto off, everything stays honest by default.

The launch banner makes the tradeoff explicit either way:

# deepclaude
Auto mode: OFF (TUI shows 'deepseek-v4-pro')
  Pass --auto to unlock auto/bypassPermissions modes — TUI will then show 'claude-opus-4-7'.

# deepclaude --auto
Auto mode: ON
  TUI will display 'claude-opus-4-7' (auto/bypassPermissions unlocked).
  Actual routing: deepseek-v4-pro via https://api.deepseek.com/anthropic.
  Verify with: curl -s http://127.0.0.1:$PROXY_PORT/_proxy/cost | jq

A future PR will add a Claude Code statusLine integration so the actual backend (and live cost) is also visible at the bottom of the terminal — the natural counterpart to a TUI chip that lies under --auto.

What's in the diff

--auto core:

  • AUTO_MODE global + --auto) arg parsing.
  • set_model_env branched on $AUTO_MODE: canonical claude-* names under --auto, $RESOLVED_* otherwise.
  • print_auto_mode_tip helper surfacing the tradeoff and the actual routing destination at launch (called from both launch_claude and launch_remote).
  • --auto documented in show_help.

Proxy / launch foundation (active in both modes — not auto-mode-specific, but required for --auto to function):

  • launch_claude now starts the local proxy and points ANTHROPIC_BASE_URL at it. Previously only --remote did this.
  • start_proxy shared helper sets PROXY_PID/PROXY_PORT/PROXY_LOG as script globals; must be called without $() or the EXIT trap leaks the node child.
  • SCRIPT_DIR is symlink-resolved so deepclaude works when installed via a ~/.local/bin symlink.
  • start-proxy.js legacy mode accepts an optional [defaultMode] third argv so state.mode resolves to e.g. deepseek rather than _single and MODEL_REMAP[state.mode] actually fires.
  • launch_claude deliberately does not touch ANTHROPIC_AUTH_TOKEN — whatever Claude Code is already carrying flows through; the proxy injects backend auth itself for non-image, non-Anthropic calls.

Adjacent proxy additions:

  • MODEL_REMAP['fireworks'] block, mirroring the deepseek/openrouter entries, so --auto works on the fireworks backend.
  • console.warn line in the existing remap branch when an inbound claude-* name has no MODEL_REMAP entry — drift detector for when Anthropic ships a new model and the table falls behind.

Test plan

  • deepclaude (no --auto): TUI shows deepseek-v4-pro, Shift+Tab doesn't include auto/bypassPermissions, requests route through the proxy to DeepSeek.
  • deepclaude --auto: TUI shows claude-opus-4-7, Shift+Tab cycles default → auto → plan → bypassPermissions, requests still route to DeepSeek (proxy log: model remap: claude-opus-4-7 → deepseek-v4-pro).
  • Launch banner prints the appropriate auto-mode tip on both paths.
  • curl http://127.0.0.1:$PROXY_PORT/_proxy/status reports "mode": "deepseek" (i.e. the defaultMode argv plumbing works); /_proxy/cost accumulates a deepseek bucket on each turn.

Notes

This PR overlaps with #21 on the proxy-in-path foundation (start_proxy, symlink-resolved SCRIPT_DIR, launch_claude routing through proxy, start-proxy.js [defaultMode] argv). When either PR merges first, the other can rebase onto main; git will recognise the duplicate patches and drop them. The auto-mode-only delta (~50 lines across deepclaude.sh and proxy/model-proxy.js) is what survives in this PR after such a rebase.

BenSheridanEdwards and others added 2 commits May 7, 2026 14:22
launch_claude now starts proxy/start-proxy.js and points
ANTHROPIC_BASE_URL at the local proxy. Previously only --remote did
this. Without it, plain deepclaude pointed Claude Code straight at the
backend URL, bypassing the proxy entirely.

start_proxy is a shared helper that sets PROXY_PID/PROXY_PORT/PROXY_LOG
as script globals; must be called WITHOUT command substitution because
the EXIT trap depends on PROXY_PID reaching the parent shell. SCRIPT_DIR
is symlink-resolved so deepclaude works when installed via a
~/.local/bin symlink. The exec on `claude` is dropped so the EXIT trap
fires and the node child is cleaned up. ANTHROPIC_AUTH_TOKEN is left
untouched — whatever the user has in their environment flows through.

start-proxy.js legacy mode accepts an optional [defaultMode] third arg
so state.mode resolves to e.g. \`deepseek\` rather than \`_single\` and
MODEL_REMAP[state.mode] fires.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Claude Code disables `auto` and `bypassPermissions` for any
ANTHROPIC_DEFAULT_*_MODEL value that isn't a `claude-*` name. Default
deepclaude exports the resolved backend name (`deepseek-v4-pro` etc.)
so the gate stays locked and `Shift+Tab` reports "auto mode isn't
available for this model".

This PR adds `--auto`. When passed, set_model_env exports canonical
`claude-opus-4-7` / `claude-sonnet-4-6` / `claude-haiku-4-5-20251001`
in place of the resolved backend names. The proxy translates them back
to the backend on the wire via MODEL_REMAP. The TUI welcome chip will
show the canonical name — `print_auto_mode_tip` surfaces this as an
explicit tradeoff at launch alongside the actual backend routing and
points at /_proxy/cost as the truth source for spend.

Default behaviour is unchanged: backend names in env vars and TUI, no
auto/bypassPermissions, no model remap fires (the body's model is
already a backend name, not a key in MODEL_REMAP).

Two adjacent additions this PR also lands:

- `MODEL_REMAP['fireworks']` block, mirroring the deepseek/openrouter
  entries, so `--auto` works on the fireworks backend.
- A `console.warn` line in the existing remap branch when an inbound
  `claude-*` name has no MODEL_REMAP entry — drift detector for when
  Anthropic ships a new model and the table falls behind.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant