Skip to content

feat: generic wizard framework, websites wizard with validation retry#45

Merged
pcfreak30 merged 2 commits into
developfrom
feat/wizard-framework-websites-wizard
May 17, 2026
Merged

feat: generic wizard framework, websites wizard with validation retry#45
pcfreak30 merged 2 commits into
developfrom
feat/wizard-framework-websites-wizard

Conversation

@pcfreak30

@pcfreak30 pcfreak30 commented May 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract reusable generic wizard framework into pkg/cli/wizard/ using Go generics (Step[S any], StepFunc[S], Run[S any])
  • Add ShouldRetry as a first-class concept in the Step interface — the framework owns the retry loop, steps signal retry via state
  • Add pinner websites wizard with 7-step guided flow: Auth Check → Content Source → Domain → DNS Mode → Create Website → DNS Setup → Validation
  • Validation step shows required DNS records, prompts user, retries automatically on failure until valid or user skips
  • Add website as alias for websites command
  • Fix pinner websites validate: show DNS record instructions on failure instead of raw error; proper single-object JSON output with required_records
  • Migrate SetupWizard to use the new framework
  • All tests pass, golangci-lint clean (0 issues)

Introduce a reusable generic wizard framework and add an interactive website creation wizard built on top of it.

Wizard Framework (pkg/cli/wizard/):

  • Extract the step-based wizard orchestration (welcome, progress, skip, execute, retry, completion) into a generic Run[S any] function with a Step[S] interface, StepFunc adapter, UI interface, and Result struct.
  • Provide PTerm and Mock implementations of the UI interface.
  • Support step retry logic via ShouldRetry, enabling steps like validation to be re-executed until they succeed or the user opts out.

Setup Wizard Refactor:

  • Replace the ad-hoc SetupStep interface and concrete step types with wizard.StepFunc[*SetupWizard] closures, delegating orchestration to wizard.Run.
  • SetupUI now embeds wizard.UI, and PTermSetupUI/MockSetupUI embed the shared PTerm/Mock implementations, eliminating duplicated display and call-tracking code.
  • SetupWizard.Run now returns (wizard.Result, error) with completion metrics.

Websites Wizard (pinner websites wizard):

  • Add a new interactive wizard guiding users through website creation: authentication check, content source (CID), domain name, DNS mode (Pinner-managed or self-managed), website creation, DNS setup, and validation with retry.
  • Include PTerm UI with interactive prompts, a mock UI for testing, and comprehensive test coverage.

Websites Command Improvements:

  • Add website as an alias for the websites command.
  • Extract showDNSRecordInstructions and buildRequiredRecords helpers for consistent DNS record display across create, validate, and the wizard.
  • Improve websites validate to show required DNS records on validation failure and include required_records in JSON output.

@kody-ai

This comment has been minimized.

…etry

- Extract reusable wizard framework into pkg/cli/wizard/ using Go
  generics (Step[S any], StepFunc[S], Run[S any])
- Step interface: Name, ShouldSkip, Execute, ShouldRetry — retry is
  a first-class concept, the framework owns the loop
- Add wizard.UI with ShowStepProgress/ShowStepSkipped/ShowStepRetrying/
  ShowCompletion; PTermUI and MockUI as embeddable building blocks
- Migrate SetupWizard to wizard.Step[*SetupWizard] and wizard.Run
- Add 'pinner websites wizard' with 7-step guided flow: Auth Check,
  Content Source, Domain, DNS Mode, Create Website, DNS Setup (skipped
  if self-managed), Validation (retries via ShouldRetry until valid or
  user skips)
- Add 'website' as alias for 'websites' command
- Validation step: shows required DNS records, prompts user, signals
  retry via wizard state — framework re-executes automatically.
  Service errors and invalid results are retryable, not fatal
- Fix pinner websites validate: show DNS record instructions when
  validation fails instead of raw error; proper single-object JSON
  output with required_records field
- Extract doWebsitesValidate() to DRY test helper (no duplicate logic)
- Guard nil ExecuteFunc in StepFunc.Execute() with descriptive error
- Fix MockUI ReturnError consistency with errorIfSet() helper
- All tests pass, golangci-lint clean
@pcfreak30 pcfreak30 force-pushed the feat/wizard-framework-websites-wizard branch from d064707 to f3bebac Compare May 17, 2026 08:49
@pcfreak30 pcfreak30 changed the title feat/wizard framework websites wizard feat: generic wizard framework, websites wizard with validation retry May 17, 2026
@github-actions

github-actions Bot commented May 17, 2026

Copy link
Copy Markdown

Code Coverage Report

Total Coverage: 34.3%

Generated from commit: 8ed0fb6
Repository: LumeWeb/pinner-cli

Comment thread pkg/cli/websites_wizard.go Outdated
Comment thread pkg/cli/websites_wizard_pterm.go Outdated
…ntext

- executeDNSSetup and setupDNSHosting were generating a local validation
  token instead of using the server-assigned website.ValidationToken,
  causing validation to always fail after DNS setup — the DNS TXT
  record contained a token the server didn't recognize
- Change setupDNSHosting signature to accept *WebsiteItem instead of
  domain/targetHash strings, using website.ValidationToken directly
- Remove now-unused generateValidationToken() function
- Fix ExecuteValidateStep to propagate the incoming context to
  executeValidate() instead of using context.Background(), preserving
  cancellation and deadline propagation
@kody-ai

kody-ai Bot commented May 17, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@pcfreak30 pcfreak30 merged commit d1820f7 into develop May 17, 2026
2 checks passed
@pcfreak30 pcfreak30 deleted the feat/wizard-framework-websites-wizard branch May 17, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant