Work with wizards
Use wizards when you need to create guided, multi-step interactive workflows that collect user input and generate structured output.
Prerequisites
- Access to the project source code
- Understanding of the wizard system architecture in
src/attune/wizards/ - Python development environment configured
Steps
-
Choose your wizard approach
Determine whether to use a built-in wizard, extend an existing one, or create a custom wizard:
- For debugging workflows, use
DebugWizard - For code refactoring, use
RefactorWizard - For security audits, use
SecurityWizard - For test generation, use
TestGenWizard - For release preparation, use
ReleasePrepWizard
- For debugging workflows, use
-
Register or retrieve your wizard
For built-in wizards, retrieve them with:
from attune.wizards import get_wizard wizard_class = get_wizard("debug") # or "refactor", "security", etc.For custom wizards, register them first:
from attune.wizards import register_wizard register_wizard("my-custom-wizard", MyCustomWizardClass) -
Configure wizard steps
Create
WizardStepinstances with the required fields:from attune.wizards import WizardStep, StepType step = WizardStep( id="analyze-code", name="Code Analysis", description="Analyze the codebase for issues", step_type=StepType.QUESTION, prompt_template="What specific issues should I look for?", tier="capable" ) -
Initialize and run the wizard
Create a wizard instance and execute it:
wizard = wizard_class(ask_user_callback=your_callback_function) result = wizard.run(initial_context={"project_path": "/path/to/project"}) -
Process the wizard result
Handle the
WizardResultobject returned:if result.success: print(f"Wizard completed {len(result.steps_completed)} steps") print(f"Generated output: {result.generated_output}") print(f"Total cost: ${result.total_cost:.2f}") else: print(f"Wizard failed: {result.error}") -
Save custom wizard definitions (optional)
For reusable custom wizards, save the configuration:
from attune.wizards import save_custom_wizard wizard_data = { "wizard_id": "my-workflow", "name": "My Custom Workflow", "description": "Custom workflow description", "steps": [/* step definitions */] } save_custom_wizard(wizard_data)
Verification
Run your wizard and verify:
- All wizard steps execute in the correct order
- User input is collected and processed correctly
- The wizard generates the expected output format
- The
WizardResultcontains complete execution data - Custom wizards appear in
list_wizards()output
Key files
src/attune/wizards/base.py-BaseWizardabstract classsrc/attune/wizards/types.py- Data type definitionssrc/attune/wizards/builtin.py- Pre-built wizard implementationssrc/attune/wizards/registry.py- Wizard registration and management