Skip to content

feat: wizard entry points — /setup command, claw setup subcommand, and Ctrl+P provider swap#3218

Open
TheArchitectit wants to merge 1 commit into
ultraworkers:mainfrom
TheArchitectit:worktree-wizard-entry-points
Open

feat: wizard entry points — /setup command, claw setup subcommand, and Ctrl+P provider swap#3218
TheArchitectit wants to merge 1 commit into
ultraworkers:mainfrom
TheArchitectit:worktree-wizard-entry-points

Conversation

@TheArchitectit
Copy link
Copy Markdown
Contributor

Problem

The setup wizard was merged in PR #3017 but is completely orphaned — it's not declared as a module in main.rs, so users cannot reach it via any entry point. Additionally, setup_wizard.rs imports RuntimeProviderConfig which did not exist on upstream/main, so the module cannot even compile without the type definition.

Solution

This PR activates the setup wizard by adding the three key pieces:

  1. RuntimeProviderConfig type — Adds the provider section parser to runtime/src/config.rs so ConfigLoader::load().provider() returns structured provider settings (kind, apiKey, baseUrl, model). This is the same type that PR feat: 3-tier provider credential resolution (env var → .env → stored config) #3211 introduces for 3-tier credential resolution.

  2. claw setup subcommand — Wires the wizard as a standalone CLI subcommand so users can run it from the terminal without entering the REPL.

  3. /setup slash command — Adds /setup as a recognized slash command that runs the wizard inside the REPL session.

Also includes a minor fix: adds subagentModel to the settings validator's TOP_LEVEL_FIELDS allowlist so that the wizard's fast-model persistence doesn't trigger an "unknown key" validation error.

Note: Ctrl+P provider swap in the TUI input loop is deferred to a follow-up PR — it requires deeper integration with the TUI state machine.

Changes

  • rust/crates/runtime/src/config.rs — Add RuntimeProviderConfig struct with kind(), api_key(), base_url(), model() accessors. Add parse_optional_provider_config() parser. Wire provider field into RuntimeFeatureConfig and add provider() methods to RuntimeConfig and RuntimeFeatureConfig.

  • rust/crates/runtime/src/lib.rs — Export RuntimeProviderConfig, save_user_provider_settings, clear_user_provider_settings, and default_config_home from the runtime crate public API.

  • rust/crates/runtime/src/config_validate.rs — Add subagentModel to TOP_LEVEL_FIELDS so the wizard's fast-model setting passes validation.

  • rust/crates/commands/src/lib.rs — Add Setup variant to SlashCommand enum. Add /setup spec entry in SLASH_COMMAND_SPECS. Add "setup" parsing in validate_slash_command_input(). Add "setup" to Config category and exhaustive matches.

  • rust/crates/rusty-claude-cli/src/main.rs — Add mod setup_wizard;. Add CliAction::Setup variant. Add LocalHelpTopic::Setup with help text. Add "setup" subcommand parsing with argument validation. Add SlashCommand::Setup REPL dispatch calling setup_wizard::run_setup_wizard(). Add run_setup() function. Wire "setup" into all dispatch tables (local-help, single-word-alias, similar-subcommand suggestions).

  • rust/crates/rusty-claude-cli/src/setup_wizard.rs — Formatting-only changes from cargo fmt (the module was already present on upstream/main but orphaned).

Diff verification

$ git diff upstream/main --stat
rust/crates/commands/src/lib.rs                  | 16 +++++-
rust/crates/runtime/src/config.rs                | 67 ++++++++++++++++++++++++
rust/crates/runtime/src/config_validate.rs       |  4 ++
rust/crates/runtime/src/lib.rs                   |  3 +-
rust/crates/rusty-claude-cli/src/main.rs         | 45 +++++++++++++++-
rust/crates/rusty-claude-cli/src/setup_wizard.rs | 58 ++++++++++++--------
6 files changed, 166 insertions(+), 27 deletions(-)

All changes are feature-only additions. The 27 deletions in setup_wizard.rs are formatting fixes from cargo fmt, not functionality removals. No upstream commits were reverted.

Testing

  1. cargo check --workspace — passes
  2. cargo test -p api -p runtime -p tools — all 102 tools tests pass, all api/runtime tests pass
  3. cargo fmt -p api -p runtime -p tools -p commands -p rusty-claude-cli — no changes needed
  4. Manual verification:
    • claw setup runs the interactive wizard
    • /setup is recognized as a valid slash command
    • claw setup --help shows the setup help topic
    • claw help setup shows the setup help topic

Related upstream PR: #3211 (3-tier credential resolution, which introduces the same RuntimeProviderConfig type)

…nd RuntimeProviderConfig

The setup wizard was merged in PR ultraworkers#3017 but was orphaned -- it was not
declared as a module in main.rs, making it unreachable. Additionally,
the setup_wizard.rs imports RuntimeProviderConfig which did not exist
on upstream/main. This commit makes the wizard accessible and adds the
necessary RuntimeProviderConfig type.

Changes:
- Add RuntimeProviderConfig struct to runtime/src/config.rs with
  kind(), api_key(), base_url(), model() accessors. This represents
  the "provider" section in ~/.claw/settings.json and supports the
  3-tier credential resolution: env var > .env file > stored config.
- Add parse_optional_provider_config() to parse the provider object
  from merged settings JSON.
- Add provider() method to RuntimeConfig and RuntimeFeatureConfig.
- Export RuntimeProviderConfig, save_user_provider_settings,
  clear_user_provider_settings, and default_config_home from runtime
  crate public API (runtime/src/lib.rs).
- Add "mod setup_wizard;" to rusty-claude-cli/src/main.rs to activate
  the previously orphaned setup wizard module.
- Add "claw setup" CLI subcommand: runs the interactive provider
  setup wizard from the terminal.
- Add "/setup" slash command: runs the wizard inside the REPL.
- Add Setup variant to SlashCommand enum with /setup spec entry.
- Add Setup to LocalHelpTopic enum with help text.
- Add "setup" to diagnostic subcommand matching, local-help topic
  routes, suggest_similar_subcommand list, and all parse dispatches.
- Add "subagentModel" to TOP_LEVEL_FIELDS in config_validate.rs so
  that the setup wizard's fast-model setting is recognized as a
  valid settings key instead of causing an "unknown key" error.

Note: Ctrl+P provider swap in the TUI input loop is deferred to a
follow-up as it requires deeper integration with the TUI state
machine (see reference commit 99351d4 from feat-tui).

[depends on ultraworkers#3211 for 3-tier credential resolution]

Co-Authored-By: Claude Opus 4.8 <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