Class: Aidp::Setup::Wizard
- Inherits:
-
Object
- Object
- Aidp::Setup::Wizard
- Defined in:
- lib/aidp/setup/wizard.rb
Overview
Interactive setup wizard for configuring AIDP. Guides the user through provider, work loop, NFR, logging, and mode settings while remaining idempotent and safe to re-run.
Constant Summary collapse
- SCHEMA_VERSION =
1- DEVCONTAINER_COMPONENT =
"setup_wizard.devcontainer"- DEFAULT_AUTOCONFIG_TIERS =
%w[mini standard pro].freeze
- LEGACY_TIER_ALIASES =
{ advanced: :pro }.freeze
- PRD_STYLE_OPTIONS =
{ "Detailed - deep questioning, longer sessions" => "detailed", "Balanced - moderate questioning (recommended)" => "balanced", "Quick Sketch - minimal questions, Aidp fills gaps automatically" => "quick_sketch" }.freeze
- DEFAULT_PRD_QUESTION_ROUNDS =
{ detailed: 30, balanced: 10, quick_sketch: 3 }.freeze
- PHASE_TWO_SUGGESTION_SCHEMA =
{ "commands" => [ { "name" => "identifier", "command" => "shell command", "category" => "test|lint|formatter|build|documentation|custom", "run_after" => "each_unit|full_loop|on_completion", "required" => true } ], "watch_patterns" => ["spec/**/*_spec.rb"], "guard_include_patterns" => ["lib/**/*"], "guard_exclude_patterns" => ["node_modules/**"] }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Expose state for testability.
-
#discovery_threads ⇒ Object
readonly
Expose state for testability.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#existing_config ⇒ Object
readonly
Expose state for testability.
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
-
#warnings ⇒ Object
readonly
Expose state for testability.
Instance Method Summary collapse
-
#initialize(project_dir = Dir.pwd, prompt: nil, dry_run: false) ⇒ Wizard
constructor
A new instance of Wizard.
- #run ⇒ Object
- #saved? ⇒ Boolean
Constructor Details
#initialize(project_dir = Dir.pwd, prompt: nil, dry_run: false) ⇒ Wizard
Returns a new instance of Wizard.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/aidp/setup/wizard.rb', line 57 def initialize(project_dir = Dir.pwd, prompt: nil, dry_run: false) @project_dir = project_dir @prompt = prompt || TTY::Prompt.new @dry_run = dry_run @warnings = [] @existing_config = load_existing_config @config = deep_symbolize(@existing_config) @original_config_content = File.exist?(config_path) ? File.read(config_path) : nil @saved = false @phase_one_persisted = false end |
Instance Attribute Details
#config ⇒ Object (readonly)
Expose state for testability
55 56 57 |
# File 'lib/aidp/setup/wizard.rb', line 55 def config @config end |
#discovery_threads ⇒ Object (readonly)
Expose state for testability
55 56 57 |
# File 'lib/aidp/setup/wizard.rb', line 55 def discovery_threads @discovery_threads end |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
53 54 55 |
# File 'lib/aidp/setup/wizard.rb', line 53 def dry_run @dry_run end |
#existing_config ⇒ Object (readonly)
Expose state for testability
55 56 57 |
# File 'lib/aidp/setup/wizard.rb', line 55 def existing_config @existing_config end |
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
53 54 55 |
# File 'lib/aidp/setup/wizard.rb', line 53 def project_dir @project_dir end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
53 54 55 |
# File 'lib/aidp/setup/wizard.rb', line 53 def prompt @prompt end |
#warnings ⇒ Object (readonly)
Expose state for testability
55 56 57 |
# File 'lib/aidp/setup/wizard.rb', line 55 def warnings @warnings end |
Instance Method Details
#run ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/aidp/setup/wizard.rb', line 69 def run final_save_succeeded = false display_welcome # Normalize any legacy tier/model_family entries before prompting normalize_existing_model_families! normalize_existing_thinking_tiers! return @saved if skip_wizard? run_phase_one persist_phase_one_config unless dry_run run_phase_two yaml_content = generate_yaml display_preview(yaml_content) display_diff(yaml_content) if @original_config_content return true if dry_run_mode?(yaml_content) if prompt.yes?("Save this configuration?", default: true) save_config(yaml_content) final_save_succeeded = true prompt.ok("✅ Configuration saved to #{relative_config_path}") show_next_steps display_warnings @saved = true else rollback_phase_one_config prompt.warn("Configuration not saved") display_warnings end @saved ensure # Only roll back when the phase-one snapshot has not been replaced # by a successful final write. save_config clears @phase_one_persisted # once the YAML is on disk, so a post-write artifact failure leaves # the user's chosen config intact instead of being overwritten by # the original. rollback_phase_one_config if @phase_one_persisted && !final_save_succeeded end |
#saved? ⇒ Boolean
110 111 112 |
# File 'lib/aidp/setup/wizard.rb', line 110 def saved? @saved end |