Skip to content

feat: Replace prompts library with @clack/prompts - #604

Merged
razor-x merged 2 commits into
mainfrom
claude/prompts-replacement-explore-m8h9vq
Aug 4, 2026
Merged

feat: Replace prompts library with @clack/prompts#604
razor-x merged 2 commits into
mainfrom
claude/prompts-replacement-explore-m8h9vq

Conversation

@razor-x

@razor-x razor-x commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

Migrated the CLI's interactive prompting system from the prompts library to @clack/prompts, providing a more modern and composable API for user interactions.

Key Changes

  • Replaced prompt library: Removed dependency on prompts and added @clack/prompts as the new prompting solution
  • Refactored prompt API: Replaced the generic prompt() function with specialized, type-safe functions:
    • promptText() - for text input
    • promptNumber() - for numeric input with validation
    • promptConfirm() - for yes/no confirmations
    • promptSelect() - for single-choice selection
    • promptAutocomplete() - for searchable selection
    • promptAutocompleteMultiselect() - for multi-select with search
  • Added error handling: Introduced PromptCancelledError to handle user cancellations (Ctrl+C/Escape)
  • Standardized choice format: Created PromptChoice<Value> interface with label, value, and optional hint fields, replacing the previous title/description format
  • Updated all call sites: Modified all interactive modules to use the new prompt functions:
    • interact-for-blueprint-object.ts
    • interact-for-custom-metadata.ts
    • interact-for-use-remote-api-defs.ts
    • interact-for-array.ts
    • interact-for-server-selection.ts
    • interact-for-timestamp.ts
    • interact-for-command-selection.ts
    • interact-for-workspace-id.ts
    • interact-for-resource.ts
    • interact-for-action-attempt-poll.ts
    • interact-for-login.ts
    • cli.ts
  • Improved timestamp handling: Replaced the date prompt type with promptText() and added custom validation for ISO timestamp format
  • Updated tests: Modified test mocks to reflect the new prompt function signatures

Notable Implementation Details

  • All prompts output to stderr to prevent interference with stdout when piped
  • The ensureInteractive() helper validates that a TTY is available before prompting
  • The unwrap() helper converts @clack/prompts cancel symbols to PromptCancelledError exceptions
  • Validation functions now return undefined for valid input (instead of true) to match @clack/prompts conventions
  • Removed unnecessary null checks in several places since the new API throws on cancellation rather than returning undefined

https://claude.ai/code/session_01N2Ch14ybwrTTFwM7sHFWr6

claude added 2 commits August 4, 2026 21:38
The prompts package is unmaintained (last published October 2021).
Replace it with @clack/prompts, which covers every prompt type the CLI
uses, including autocomplete, autocomplete multiselect, and toggle-style
confirm, and ships its own TypeScript types.

The prompt wrapper now exposes one typed helper per prompt kind instead
of passing through prompts question objects. Each helper keeps the TTY
guard and renders to stderr, and normalizes clack's cancel symbol into
a PromptCancelledError that the CLI entrypoint reports as a quiet
'Cancelled' instead of cascading undefined answers.

Timestamps are now collected with a validated text prompt defaulting to
the current time, since the clack date picker has no time-of-day
segments and API timestamps need them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N2Ch14ybwrTTFwM7sHFWr6
…ement-explore-m8h9vq

# Conflicts:
#	src/lib/interact-for-server-selection.ts
#	src/lib/interact-for-workspace-id.ts
#	src/lib/util/prompt.ts
@razor-x
razor-x marked this pull request as ready for review August 4, 2026 21:51
@razor-x razor-x changed the title Replace prompts library with @clack/prompts feat: Replace prompts library with @clack/prompts Aug 4, 2026
@razor-x
razor-x merged commit da63f78 into main Aug 4, 2026
12 checks passed
@razor-x
razor-x deleted the claude/prompts-replacement-explore-m8h9vq branch August 5, 2026 05:48
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.

2 participants