Skip to content

[Feature]: Immediate nova init Validation #148

@stiwicourage

Description

@stiwicourage

Plan: Immediate nova init Validation

Problem Summary

nova init and nova init -e currently collect the full interactive answer set and only then reject an invalid scaffold value, because Read-NovaModuleAnswerSet performs ProjectName validation after all prompts in src/private/scaffold/ReadNovaModuleAnswers.ps1.

This creates a poor UX: one bad early answer can waste the entire questionnaire and end in a terminating error.

Goals

  • Validate scaffold answers immediately at the prompt where the value is entered.
  • Retry inline with a clear validation message instead of failing after the full questionnaire.
  • Keep one shared behavior path for both nova init and nova init -e, since both flow through Initialize-NovaModule and Get-NovaModuleInitializationWorkflowContext.
  • Preserve existing prompt ordering, defaults, and mandatory-empty retry behavior.

Proposed Design

  • Move scaffold-specific validation metadata into the question model returned by Get-NovaModuleQuestionSet in src/private/scaffold/GetNovaModuleQuestions.ps1, starting with ProjectName.
  • Extend the standard prompt loop in Read-AwesomeStandardPrompt and Test-AwesomePromptRequiresRetry in src/private/cli/ReadAwesomeStandardPrompt.ps1 and src/private/cli/TestAwesomePromptRequiresRetry.ps1 so it can evaluate both:
    • empty mandatory input
    • invalid non-empty input against prompt-level validation rules
  • Keep Read-AwesomeHost in src/private/cli/ReadAwesomeHost.ps1 as the shared entrypoint so the behavior automatically applies to standard and example scaffold flows.
  • Convert the current post-questionnaire ProjectName check in Read-NovaModuleAnswerSet into a defensive fallback only, or remove it if prompt-level validation fully covers interactive callers and tests confirm no regression.
  • Update help text in src/resources/cli/help/init.psd1 and docs/NovaModuleTools/en-US/Initialize-NovaModule.md to describe immediate retry behavior.

Implementation Phases

  1. Define prompt-level validation shape in Get-NovaModuleQuestionSet for ProjectName.
  2. Refactor Read-AwesomeStandardPrompt to loop until required and validation checks both pass.
  3. Add user-facing inline validation messaging without changing CLI command routing.
  4. Simplify Read-NovaModuleAnswerSet so it no longer delays interactive validation until the end.
  5. Update init help and docs to reflect the new retry-first UX.

Tests

  • Extend prompt-loop coverage in tests/CoverageCompletion.Tests.ps1 for invalid-then-valid standard prompt retries, alongside existing mandatory retry coverage.
  • Update scaffold tests in tests/CoverageGaps.Tests.ps1 to verify invalid ProjectName is retried inline instead of throwing after all questions.
  • Add regression coverage for both standard and example flows so nova init and nova init -e share the same validation behavior.
  • Keep a fallback test, if retained, to ensure non-interactive or mocked callers still receive a terminating validation error when prompt-level validation is bypassed.

Risks

  • Prompt objects currently mix hashtables and pscustomobject; new validation metadata must work in both shapes.
  • Default-value handling must not create a loop where empty input repeatedly resolves to an invalid default.
  • Removing the late validation entirely could weaken protection for non-interactive consumers unless a defensive guard remains.

Rollout Notes

  • This is a UX-only change for interactive scaffold creation; no CLI syntax or parameter contract changes are required.
  • Release notes should call out that invalid scaffold answers now retry immediately instead of failing at the end.
  • Documentation should clarify that nova init and nova init -e now share the same inline validation experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions