claudewheel v0.24.2 /claudewheel.launch
Edit
On this page

Launch logic for resolving selections into a Claude Code invocation.

#claudewheel.launch

#claudewheel.launch

Map TUI selections to binary path, env vars, flags, and exec.

#fetch_gh_token

python
def fetch_gh_token(account: str) -> str | None

Fetch GH token live via gh CLI. Returns None on failure.

#resolve_launch_config

python
def resolve_launch_config(selections: dict[str, str | None], options_def: dict[str, Any], default_flags: list[str], locator: BinaryLocator, profiles: ProfileStore, extra_flags: list[str] | None=None, metadata: dict[str, dict[str, dict[str, Any]]] | None=None, client: str='claude', clients_config: dict[str, Any] | None=None, passthrough: list[str] | None=None) -> tuple[str, list[str], dict[str, str]]

Build (cwd, argv, env) for os.execvpe from TUI selections.

Maps segment values to their concrete effects. The env and cwd (the target-agnostic pieces) are assembled here; the argv is delegated to the selected client adapter in :mod:claudewheel.clients:

  • profile -> CLAUDE_CONFIG_DIR + OAuth token env vars via profiles (shared)
  • github -> GH_TOKEN env var, fetched live via gh CLI (shared)
  • directory -> os.chdir target (shared)
  • model -> resolved model id (shared), then formatted per client
  • version / mcp / permissions / session flags -> client-specific argv

The client names an entry in :data:claudewheel.clients.CLIENT_ADAPTERS ("claude" preserves the historical behavior exactly; "miniclaude" targets the miniclaude REPL). clients_config is the clients section of config.json (used by the miniclaude adapter to locate its binary). passthrough is the tail of extra_flags that came from args after --; the claude adapter appends it verbatim, the miniclaude adapter rejects it.

The selected profile is resolved through the injected profiles ProfileStore -- the single source of profile identity. A named profile that no longer exists raises :class:ValueError (the hard-error contract that replaced the old silent ~/.claude fallback); a corrupt tokens.json raises :class:TokenStoreError.

The "default" profile -- selected explicitly OR reached via the no-profile fallback -- is the VANILLA path: ~/.claude is Claude Code's own config dir, managed by Claude Code and strictly read-only to cw. The built env therefore carries NEITHER CLAUDE_CONFIG_DIR (any ambient one inherited from os.environ is explicitly removed) NOR CLAUDE_CODE_OAUTH_TOKEN (no token injection, even if a "default" tokens key exists).

When metadata is provided (TUI path), use it for model lookups. When None (skip-TUI path), fall back to reading from options_def.

#do_launch

python
def do_launch(cwd: str, argv: list[str], env: dict[str, str]) -> Any

Change to directory and exec Claude Code. Does not return.

Under --dry-run there is nothing to replace this process with: the exec is recorded and the carrier standing in for it is returned, so the dispatch can finish and the would-do log can render.

Search