feat(cli): shell completion support for CLI v2 and fix v1 side effects#15113
Draft
iamnamananand996 wants to merge 1 commit intomainfrom
Draft
feat(cli): shell completion support for CLI v2 and fix v1 side effects#15113iamnamananand996 wants to merge 1 commit intomainfrom
iamnamananand996 wants to merge 1 commit intomainfrom
Conversation
…ects - Detect --get-yargs-completions in CLI v1 to suppress upgrade notices and skip version redirection during shell completion - Add .completion() to CLI v2 with content-aware completions for --group, --api, and --instance flags (reads fern.yml) - Skip telemetry initialization during completion mode for speed
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Linear ticket: Closes FER-8704
Shell completion currently triggers upgrade notices and slow network calls every time the user presses TAB. This PR fixes those side effects in CLI v1 and adds full shell completion support to CLI v2, including content-aware completions for workspace-derived flags.
Changes Made
CLI v1 — Fix side effects during completion (
packages/cli/cli/src/cli.ts)--get-yargs-completionsinprocess.argvearly inrunCli()cliContext.suppressUpgradeMessage()to prevent upgrade notices from appearing during TAB completiongetIntendedVersionOfCli()(network call for version redirection) during completion mode so TAB stays fastCLI v2 — Add shell completion (
packages/cli/cli-v2/src/cli.ts).completion()on the yargs instance to enablefern completion(outputs the shell completion script) and--get-yargs-completions(provides completions on TAB)getOrCreateFernRunId()telemetry setup during completion modecompletionHandlerthat provides content-aware completions for--group,--api, and--instanceflags by reading values fromfern.ymlContent-aware completion module (
packages/cli/cli-v2/src/completion.ts)fern.ymlparser that walks up fromcwdand parses as plain YAML (no Zod validation, no$refresolution) for speedisCompletionMode()— detects when CLI is invoked for shell completiongetCompletionValues()— extracts group names (fromsdks.targets[*].group[]), API names (fromapiskeys), and docs instance URLs (fromdocs.instances[*].url)Testing
pnpm run check(biome lint) passespnpm turbo run compile --filter @fern-api/cli-v2compiles successfullyLink to Devin session: https://app.devin.ai/sessions/acbef1fddc974c579f764955a105160e
Requested by: @iamnamananand996