Skip to content

fix(hitl/cli): suggest the closest valid name for unknown HITL keys and CLI flags - #2208

Merged
murdore merged 1 commit into
juspay:releasefrom
punyamsingh:fix/hitl-unknown-key-suggestion
Nov 25, 2026
Merged

murdore merged 1 commit into
juspay:releasefrom
punyamsingh:fix/hitl-unknown-key-suggestion

Conversation

@punyamsingh

@punyamsingh punyamsingh commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Two "did you mean?" hints for names that are silently wrong today, both built on the existing suggestClosest helper.

HITL config keys. The unknown-key warning added in 09a24bd now names the closest supported key.

[HITL] Unknown config key "timout" is ignored and has no effect. Did you mean "timeout"? Supported keys: ...

CLI flags. The parser runs with strictOptions(), so a mistyped flag fails the command with only "Unknown argument" and a pointer to --help (over 100 flags for generate). The error now names the closest flag of the command that failed.

Error: Unknown argument: temprature
Did you mean --temperature instead of --temprature?
Use --help to see available options.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Motivation and Context

A typo'd HITL key silently disables the approval gate it was meant to configure, and the warning left the reader to spot the near miss among 11 keys. A typo'd CLI flag left the user to search a long help page.

Changes Made

  • HITLManager.validateConfig appends Did you mean "<key>"? when an unknown key is within 3 edits of a supported one (case-insensitive); planned keys like requireApproval get no hint
  • src/cli/parser.ts: the unknown-argument branch of .fail() suggests flags from the yargs usage object's getDescriptions(), i.e. the failing command's visible options. The method is not in @types/yargs, so it is checked at runtime; if it is missing the message is unchanged
  • CLI matching ignores hyphens and case (--max-tokenz suggests --maxTokens), scales the edit budget with the name's length so short junk gets no hint, and reports yargs' camelCase twin of a kebab-case typo once
  • Tests: a new case in continuous-test-suite-hitl-documented-config; a new offline suite continuous-test-suite-cli-unknown-option (pnpm run test:cli-unknown-option)

Breaking Changes

  • No breaking changes (both are extra lines on messages that were already printed)

New Provider Onboarding

  • N/A — no provider/model change

Testing

  • continuous-test-suite-hitl-documented-config: 46/46 against a fresh build
  • continuous-test-suite-cli-unknown-option: 4/4; against a CLI built from the unchanged parser.ts, the three suggestion cases fail and the run exits 1
  • ESLint, Prettier, svelte-check + tsc --noEmit --strict, build pass

Dependencies

  • No dependency changes

Security Considerations

  • No security implications

Summary by CodeRabbit

  • Improvements
    • Warnings for unsupported HITL configuration keys now suggest the closest supported key when one is available. Unknown keys continue to be ignored.
    • CLI errors for mistyped or invalid options now suggest a matching available option when appropriate. Suggestions are limited to the relevant command, and distant or unrelated option names are not suggested.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

HITL configuration warnings and CLI errors now suggest a closest supported key or flag when one is available. Tests cover matching and non-matching names in both contexts.

Changes: HITL Key Suggestions

Layer / File(s) Summary
Unknown-key warning suggestions
src/lib/hitl/hitlManager.ts, test/continuous-test-suite-hitl-documented-config.ts
HITLManager adds a “Did you mean?” hint when suggestClosest returns a match. Tests check suggestions for timout and autoApproveOnTimeOut, and verify that requireApproval receives no suggestion.

CLI Flag Suggestions

Layer / File(s) Summary
CLI flag error suggestions
src/cli/parser.ts, test/continuous-test-suite-cli-unknown-option.ts, package.json
The CLI parser compares unknown arguments with visible option names and suggests a close match within a length-based distance limit capped at 3. It adds suggestions to unknown-argument and invalid-value errors before the help hint. Tests cover command-specific suggestions, duplicate suppression, distant flags, and the help hint. The package script runs the new test suite.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Possibly related PRs

  • juspay/neurolink#2200: Adds the unknown HITL configuration key warning and known-key list that this change uses to provide suggestions.

Suggested reviewers: murdore

Merge Risk: Minimal · up to ca52b

This change adds "Did you mean" hints to unknown HITL config key warnings and unknown CLI flag errors. Behavior is otherwise unchanged and the new tests cover matching and non-matching names. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two areas the changeset touches: closest-name suggestions for unknown HITL config keys and for unknown CLI flags. The raw summary covers the HITL warning change, the CLI parser sug…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the two areas the changeset touches: closest-name suggestions for unknown HITL config keys and for unknown CLI flags. The raw summary covers the HITL warning change, the CLI parser suggestion logic, and the new tests, so the title matches the main change. The 81-character length is slightly long but still readable, and the title uses a standard conventional-commit form.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/cli/parser.ts

Parsing error: Unable to parse the specified 'tsconfig' file. Ensure it's correct and has valid syntax.

tsconfig.json(2,14): error TS6053: File '$app/tsconfig' not found.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bf04e93 and ca52bdc.

Files selected for processing: 3

  • package.json
  • src/cli/parser.ts
  • test/continuous-test-suite-cli-unknown-option.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

…nd CLI flags

- HITL validateConfig appends 'Did you mean "<key>"?' when an unknown key is within 3 edits of one
- planned HITL keys like requireApproval are near no supported key and get no hint
- the CLI's unknown-argument error names the closest flag of the command that failed
- CLI matching ignores hyphens and case, and reports a kebab-case typo once
- both reuse suggestClosest from utils/stringDistance
- hitl-documented-config covers typo, casing and planned keys; new offline cli-unknown-option suite
@punyamsingh
punyamsingh force-pushed the fix/hitl-unknown-key-suggestion branch from bf04e93 to ca52bdc Compare November 24, 2026 10:16
@punyamsingh punyamsingh changed the title fix(hitl): suggest the closest supported key in the unknown-config-key warning fix(hitl/cli): suggest the closest valid name for unknown HITL keys and CLI flags Nov 24, 2026

@murdore murdore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed and verified locally against head ca52bdc (based on the current release tip).

  • Built cleanly. test:cli-unknown-option passes 4/4; continuous-test-suite-hitl-documented-config passes 46/46.
  • ESLint, Prettier, check:test-parse, check:ci-scripts and check:docs-api pass.
  • Both changes only add a line to messages that were already printed, so nothing existing breaks. The runtime check for getDescriptions() falls back to the old message if yargs ever drops it, and the length-scaled edit budget keeps junk flags quiet.

Approving. CI still has to run: the fork workflows are waiting for maintainer approval.

@murdore
murdore merged commit 7339011 into juspay:release Nov 25, 2026
24 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 13.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants