Class: Aidp::Skills::Wizard::Controller
- Inherits:
-
Object
- Object
- Aidp::Skills::Wizard::Controller
- Defined in:
- lib/aidp/skills/wizard/controller.rb
Overview
Controller orchestrating the skill creation wizard
Coordinates the wizard flow: template selection, prompting, building, preview, and writing the skill.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
-
#prompter ⇒ Object
readonly
Returns the value of attribute prompter.
-
#template_library ⇒ Object
readonly
Returns the value of attribute template_library.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
-
#initialize(project_dir:, options: {}) ⇒ Controller
constructor
Initialize controller.
-
#run ⇒ String?
Run the wizard.
Constructor Details
#initialize(project_dir:, options: {}) ⇒ Controller
Initialize controller
38 39 40 41 42 43 44 |
# File 'lib/aidp/skills/wizard/controller.rb', line 38 def initialize(project_dir:, options: {}) @project_dir = project_dir = @template_library = TemplateLibrary.new(project_dir: project_dir) @prompter = Prompter.new @writer = Writer.new(project_dir: project_dir) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
27 28 29 |
# File 'lib/aidp/skills/wizard/controller.rb', line 27 def end |
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
27 28 29 |
# File 'lib/aidp/skills/wizard/controller.rb', line 27 def project_dir @project_dir end |
#prompter ⇒ Object (readonly)
Returns the value of attribute prompter.
27 28 29 |
# File 'lib/aidp/skills/wizard/controller.rb', line 27 def prompter @prompter end |
#template_library ⇒ Object (readonly)
Returns the value of attribute template_library.
27 28 29 |
# File 'lib/aidp/skills/wizard/controller.rb', line 27 def template_library @template_library end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
27 28 29 |
# File 'lib/aidp/skills/wizard/controller.rb', line 27 def writer @writer end |
Instance Method Details
#run ⇒ String?
Run the wizard
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/aidp/skills/wizard/controller.rb', line 49 def run Aidp.log_info("wizard", "Starting skill creation wizard", options: ) # Gather user responses responses = prompter.gather_responses(template_library, options: ) # Build skill from responses base_skill = responses.delete(:base_skill) builder = Builder.new(base_skill: base_skill) skill = builder.build(responses) # Generate SKILL.md content skill_md_content = builder.to_skill_md(skill) # Preview show_preview(skill, skill_md_content) unless [:minimal] # Confirm unless [:dry_run] || [:yes] || confirm_save(skill) prompter.prompt.warn("Cancelled") return nil end # Write to disk path = writer.write( skill, content: skill_md_content, dry_run: [:dry_run], backup: true ) # Show success message show_success(skill, path) unless [:dry_run] path rescue Interrupt prompter.prompt.warn("\nWizard cancelled") nil rescue => e Aidp.log_error("wizard", "Wizard failed", error: e., backtrace: e.backtrace.first(5)) prompter.prompt.error("Error: #{e.message}") nil end |