Skip to content

feat(inquirerer): add boolean alias and json question types#69

Merged
pyramation merged 1 commit intomainfrom
devin/1772751964-inquirerer-boolean-json-types
Mar 5, 2026
Merged

feat(inquirerer): add boolean alias and json question types#69
pyramation merged 1 commit intomainfrom
devin/1772751964-inquirerer-boolean-json-types

Conversation

@pyramation
Copy link
Contributor

feat(inquirerer): add boolean alias and json question types

Summary

Adds two new question types to inquirerer:

  • boolean — Semantic alias for confirm. Routes to the same y/n handler but provides a more natural type name when generating CLI prompts from schema types where the field is Boolean.
  • json — New handler that accepts raw JSON string input, validates with JSON.parse(), and returns the parsed object. Shows a (JSON) hint in the prompt. Returns null for invalid JSON.

Also fixes a pre-existing test isolation bug where inputQueue/currentInputIndex weren't reset between tests in beforeEach.

Review & Testing Checklist for Human

  • json() return type is Record<string, unknown> but JSON.parse() can return arrays, primitives, etc. Verify this is intentionally restrictive or should be widened to unknown
  • Invalid JSON silently returns null instead of re-prompting or showing a parse error message. Confirm this is acceptable UX for interactive use — users get no feedback about why their input was rejected
  • as unknown as ConfirmQuestion cast in handleQuestionType for the boolean case — works because confirm() only reads question.default (which is boolean on both types), but is fragile if confirm() ever reads a ConfirmQuestion-specific property
  • json() noTty path returns implicit undefined (via bare return;) when no default exists, which doesn't match the declared return type Promise<Record<string, unknown> | null>. Check if this causes downstream issues

Recommended test: Run the test suite locally with npx jest --config jest.config.js from packages/inquirerer/ and verify all 150 tests pass.

Notes

- Add BooleanQuestion type as semantic alias for confirm (y/n prompt)
- Add JsonQuestion type with JSON.parse validation
- Add json handler method to Inquirerer class
- Route 'boolean' type to confirm handler in handleQuestionType
- Add (JSON) hint in prompt message for json type
- Add tests for both new types (interactive, noTty, CLI flag override)
- Fix inputQueue/currentInputIndex not being reset in beforeEach
- Update README with Boolean Question and JSON Question docs
- Update TypeScript imports section and Table of Contents
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 922947d into main Mar 5, 2026
36 checks passed
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