Skip to content

Add CLI command typo detection (#34836)#10

Open
MitchLewis930 wants to merge 1 commit intopr_040_beforefrom
pr_040_after
Open

Add CLI command typo detection (#34836)#10
MitchLewis930 wants to merge 1 commit intopr_040_beforefrom
pr_040_after

Conversation

@MitchLewis930
Copy link

PR_040

* Add CLI command typo detection

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 01:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds typo detection for CLI commands to improve user experience by suggesting correct commands when users make typos. When an invalid command is entered, the system now calculates the edit distance to known commands and suggests the closest match if within a reasonable threshold.

Changes:

  • Implemented Levenshtein distance algorithm for string similarity detection
  • Added typo detection when invalid commands are provided to the CLI
  • Added comprehensive test coverage for common command typos

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/integration/cli/test/index.test.js Added test cases covering common typos for build, export, start, and dev commands
packages/next/lib/get-project-dir.ts Integrated typo detection to suggest correct commands when invalid ones are entered
packages/next/lib/detect-typo.ts Implemented edit distance calculation and typo detection logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,44 @@
// the minimum number of operations required to convert string a to string b.
function minDistance(a: string, b: string, threshold: number): number {
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The threshold parameter is passed to minDistance but never used in the calculation. This parameter should either be used for early termination optimization to avoid unnecessary computation, or removed if not needed.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,44 @@
// the minimum number of operations required to convert string a to string b.
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

This comment should be formatted as a proper JSDoc comment and should specify what algorithm is being implemented (Levenshtein distance). Consider: /** Calculates the Levenshtein distance (minimum number of operations required to convert string a to string b). */

Suggested change
// the minimum number of operations required to convert string a to string b.
/**
* Calculates the Levenshtein distance (minimum number of single-character
* operations required to convert string a to string b).
*
* @param a - The first string.
* @param b - The second string.
* @param threshold - A threshold value used by callers to limit acceptable distances.
* @returns The Levenshtein distance between a and b.
*/

Copilot uses AI. Check for mistakes.
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