Skip to content

fix: multiple fixes to how REPL processes argv and autocomplete #3300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2025

Conversation

justinwilaby
Copy link
Contributor

@justinwilaby justinwilaby commented May 22, 2025

All items except W-18564386, W-18564784 and W-18564887 have been fixed in REPL & Prompt Mode Fixes for Releasable State

Overview

This PR introduces enhancements and refactoring to the CLI's interactive prompt and REPL (Read-Eval-Print Loop) experience. The changes focus on improving user input handling, command completion, and error management, as well as streamlining the main CLI entry point for better maintainability and user experience.

Key Features

  • Improved interactive prompt logic for collecting and validating user input for commands, flags, and arguments.
  • Enhanced REPL with better command completion, session state management, and history handling.
  • Robust error handling and telemetry reporting for both normal and interrupted CLI sessions.
  • The --repl flag was added to enter REPL mode.

Technical Details

  • heroku-prompts.js now provides a more modular and robust set of prompt utilities, including support for required/optional inputs, file path validation, and boolean/choice prompts.
  • The promptUser function is exported and used in the main CLI entry to collect user input interactively before command execution.
  • heroku-repl.js introduces a class-based REPL with improved command completion (including dynamic completions for flags/args), persistent session state, and command history.

Testing Instructions

Prerequisites:

  • Node.js and npm installed. Node v20+ required.
  • All dependencies installed (yarn install).
  • Build the CLI if required by your setup.

Test Scenarios:

  1. REPL Launch: Run the CLI with the --repl flag (./bin/run --repl). Verify the REPL starts, supports command history, and provides completions for commands, flags, and arguments.
  2. Prompted Command Execution: Run a CLI command with the --prompt flag (e.g., heroku apps:create --prompt). Verify that prompts appear for all required/optional inputs, including file paths and choices.
  3. Verify fixes for all GUS items in this epic except the items specified above.

Impact

  • Provides a more user-friendly and robust interactive CLI experience.
  • Reduces user error by validating input and guiding users through required/optional parameters.
  • Improves maintainability and extensibility of the CLI codebase.
  • Enhances business value by making the CLI more approachable for new and existing users, reducing support burden.

@justinwilaby justinwilaby requested a review from a team as a code owner May 22, 2025 15:33
@justinwilaby justinwilaby force-pushed the feature/interactive-prompt branch from 94684cf to 144aa06 Compare May 22, 2025 15:37
Copy link
Contributor

@sbosio sbosio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave a list of further improvements but I'm not sure if they should be blockers or not, I suggest discussing these with Product:

  • For W-18564266, the completion works for both short and long options, but also accepts short options with two dashes (that will eventually fail). Also by typing two consecutive dashes and pressing tab to autocomplete will insert argument placeholders before trying to complete option flag names. Finally, autocomplete will only work with a space between the flag name and value, but not with '=' that should be also accepted.
  • For W-18564575 now the Redis CLI mode works, but it doesn't accepts short option flags.
  • For W-18564625, REPL still shows "undefined" is not a valid command for empty lines.
  • For W-18564625 now the run command executes. It doesn't accept short option flags and exits REPL mode when the command finalizes.
  • For W-18574361, at least when testing with the sudo (legacy) plugin: The REPL mode is maintained if the command succeeds, but it's exited if the command fails. I don't know if this effects only legacy or all plugins.

@justinwilaby justinwilaby merged commit 73f9bb8 into feature/interactive-prompt May 27, 2025
7 of 8 checks passed
@justinwilaby justinwilaby deleted the fix/repl-prompt branch May 27, 2025 14:31
justinwilaby added a commit that referenced this pull request May 28, 2025
* feature: POC for heroku REPL and prompt mode

* fixed a small issue with enternig repl mode and added an exit command

* Route through default command path when no prompt or REPL is used

* Added completions and history to REPL

* feat(REPL): added session and history restoration

* Refinment on prompt delegation and error handling

* Improved docs and arg completions

* Added MCP mode to REPL

* Corrected args handling for quote enclosed values

* Add MCP version to telemetry (#3279)

* Rebase updates

* fix(W-18451520): mcp does not start on windows

* Rebased onto main

* feat: update Add plugin AI as a dependency in MCP feature branch (#3295)

* Adding AI plugin core dependency

* Bumping plugin-ai dependency to v1.0.1

* fix: multiple fixes to how REPL processes argv and autocomplete (#3300)

* fix: multiple fixes to how REPL processes argv and autocomplete

* Added --repl flag

* ignore empty lines

* removed unneeded args

---------

Co-authored-by: Santiago Bosio <[email protected]>
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