Skip to content

Implement interactive wizard for init command #73

@rrrodzilla

Description

@rrrodzilla

Context

The init command currently only prints placeholder messages but doesn't implement the interactive setup wizard described in its documentation.

Location: src/commands/init.rs:64

Current Behavior

When running crately init (without --no-interactive):

Interactive Setup Wizard
========================

This wizard will guide you through:
  1. OpenAI API key setup
  2. Cache configuration
  3. Test run validation
  4. Setup completion

Interactive wizard to be implemented

Initialization complete!

Expected Behavior

The wizard should interactively guide users through initial configuration:

  1. OpenAI API Key Setup

    • Prompt for API key with masked input
    • Validate API key by making test request
    • Store in config file or environment
    • Provide clear error messages if invalid
  2. Cache Configuration

    • Prompt for cache location (default: XDG_CACHE_HOME)
    • Prompt for cache size limits
    • Validate directory is writable
    • Create directory if needed
  3. Test Run Validation

    • Make a test API call to validate setup
    • Verify database connectivity
    • Check all dependencies available
  4. Setup Completion

    • Display summary of configured settings
    • Show config file location
    • Provide next steps

Implementation Requirements

Dependencies

  • dialoguer crate for interactive prompts
  • rpassword for secure API key input
  • Use existing ConfigManager for config persistence

User Experience

  • Clear, step-by-step prompts
  • Validation with helpful error messages
  • Ability to skip optional steps
  • Safe defaults for all settings
  • Progress indication

Files to Modify

  • src/commands/init.rs (main implementation)
  • Cargo.toml (add dialoguer dependency)
  • CLAUDE.md (update documentation)

Example Interactive Flow

Welcome to Crately Setup!
========================

Step 1/4: OpenAI API Key Configuration
--------------------------------------
Enter your OpenAI API key (or press Enter to skip): [hidden input]
✓ API key validated successfully

Step 2/4: Cache Configuration
------------------------------
Cache directory [~/.cache/crately]: [user input]
Cache size limit in GB [10]: [user input]
✓ Cache directory created

Step 3/4: Testing Configuration
--------------------------------
⋯ Running test API call...
✓ Configuration validated

Step 4/4: Setup Complete
------------------------
✓ Configuration saved to: ~/.config/crately/config.toml
✓ Cache directory: ~/.cache/crately
✓ API key configured

Next steps:
  - Run 'crately doctor' to verify your configuration
  - Run 'crately serve' to start the server

Testing Requirements

  • Interactive prompts work correctly
  • API key validation works
  • Invalid inputs show helpful errors
  • Config file is created correctly
  • --no-interactive flag still works
  • All tests pass: cargo nextest run
  • No clippy lints: cargo clippy --all-targets

Success Criteria

  • Users can complete full interactive setup
  • API key validation prevents invalid keys
  • Config file is written correctly
  • Clear error messages for all failure modes
  • Documentation updated
  • Tests cover interactive and non-interactive modes

Related Files

  • src/commands/init.rs - Main implementation needed
  • src/actors/config.rs - ConfigManager for persistence
  • CLAUDE.md - Documentation to update

Priority

Medium - Quality of life improvement for first-time users

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions