Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds shell autocompletion: a completion engine that normalizes the command registry, computes completions for commands and options, emits a server-format response, and generates Bash/Zsh/Fish/PowerShell scripts. Adds an early CLI fast-path for yargs completion requests and a ChangesShell Completion Engine
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryShell autocompletion is added for the WorkOS CLI.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported Bash portability, Zsh escaping, registry mutation, and PowerShell tab-splitting issues are corrected in the current code. Important Files Changed
|
There was a problem hiding this comment.
🟡 completion command not excluded from unclaimed-env middleware
The completion command is missing from the middleware exclusion list at src/bin.ts:200. The middleware comment explicitly states that utility commands like skills, doctor, env, and debug are excluded because the warning is unnecessary — completion is also a utility command but was not added. When completion runs through the middleware, maybeWarnUnclaimed() may make an API call (adding latency) and emit a stderr warning. While it won't corrupt the stdout script output, running eval "$(workos completion bash)" could flash a confusing "Unclaimed environment" warning.
(Refers to lines 200-202)
Was this helpful? React with 👍 or 👎 to provide feedback.
| if ($line -match '^:(\\d+)$') { | ||
| $directive = [int]$matches[1] | ||
| } elseif ($line.Trim()) { | ||
| $parts = $line.Split("\\t", 2) |
There was a problem hiding this comment.
🔴 PowerShell completion script splits on literal \t instead of tab character
The generated PowerShell completion script uses $line.Split("\t", 2) to parse tab-separated completions. However, in PowerShell, "\t" is the literal two-character string backslash-t — PowerShell uses backtick escapes ("`t") for tab characters, not backslash escapes. The .Split() method is not regex-based, so it won't interpret \t as a tab.
Impact on different PowerShell versions
On PowerShell 7+ (.NET 6+): .Split("\t", 2) matches String.Split(String, Int32) and looks for the literal two-character string \t, which never appears in the output (the actual output uses real tab characters from src/utils/completion.ts:29). The entire line becomes $comp, including the tab and description text.
On PowerShell 5 (.NET Framework): .Split("\t", 2) resolves to Split(Char[], Int32), splitting on either \ or t as individual characters. This incorrectly splits any completion containing the letter t (e.g., --git-check splits into --gi and -check...).
Prompt for agents
In src/utils/completion.ts, the generatePowershell function at line 364 outputs `$parts = $line.Split("\\t", 2)` which generates PowerShell code `$parts = $line.Split("\t", 2)`. In PowerShell, `"\t"` is a literal backslash-t, not a tab character. PowerShell uses backtick escapes for special characters.
The fix needs to produce PowerShell code that splits on an actual tab character. Two options:
1. Use PowerShell's [char]9 for a tab: change the line to produce `$parts = $line.Split([char]9, 2)` — this works on both PowerShell 5 and 7.
2. Use PowerShell's backtick escape: change to produce `$parts = $line.Split("`t", 2)` — but this requires careful escaping in the JavaScript template literal since backtick is the template delimiter.
Option 1 is simpler and avoids JS escaping complexity. In the JS template literal, the line should be: `$parts = $line.Split([char]9, 2)`
Was this helpful? React with 👍 or 👎 to provide feedback.
|
❌ Cannot revive Devin session - the session is too old. Please start a new session instead. |
…owershell Add `workos completion <shell>` command that generates shell-specific completion scripts. A hidden `--get-yargs-completions` fast path is intercepted before yargs parses to avoid validation errors on partial tab input. The completion engine walks the existing help-json.ts command registry, normalizing its mixed flat/nested naming into a uniform tree so both `auth login` style entries and `skills > install` style entries resolve correctly for subcommand drilling. Supports descriptions alongside candidates in shells that render them (zsh with fzf-tab, fish, powershell). Riker-Verification: check
Riker-Verification: check
Riker-Verification: check
- Hoist completion intercept above heavy imports (yargs, clack, semver) so Tab presses skip ~150ms of module loading - Export raw command/option arrays from help-json.ts, eliminating double buildCommandTree() call and 'in' type narrowing in completion.ts - Remove dead DIRECTIVE.DEFAULT constant - Remove unused _resetCache export - Remove duplicate shell validation in bin.ts (yargs choices + generateShellScript throw already cover it) - Add 7 new tests (option value skipping, empty args, partial prefix filtering, hidden commands, descriptions) Riker-Verification: check
Add parameterized test that asserts every public bin.ts command has a matching entry in the help-json registry. Catches forgotten registry updates at CI time (which would cause missing tab completions and missing --help --json entries). Also add 7 completion edge case tests: option value skipping, empty args, partial prefix filtering, hidden commands, descriptions. Riker-Verification: check
Co-Authored-By: nick.nisi@workos.com <nick.nisi@workos.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Riker-Verification: check
Co-Authored-By: nick.nisi@workos.com <nick.nisi@workos.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Riker-Verification: check
Co-Authored-By: nick.nisi@workos.com <nick.nisi@workos.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Riker-Verification: check
Riker-Verification: check
Riker-Verification: check
a6a3c57 to
99692e2
Compare
|
❌ Cannot revive Devin session - the session is too old. Please start a new session instead. |
There was a problem hiding this comment.
Devin Review found 4 potential issues.
7 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| const sub = currentCommands.find((c) => c.name === word); | ||
| if (sub) { | ||
| current = sub; | ||
| currentCommands = sub.commands ?? []; |
There was a problem hiding this comment.
🟡 Missing completions after command aliases
After workos org l, walkCommandTree misses the org alias and never enters the organization command. Tab omits list and other organization-specific suggestions.
Learn more
The CLI registers org as an alias of organization in the organization command. The alias map records the same mapping, along with other aliases including one that expands to a command and subcommand. Completion only looks for canonical names in the normalized tree, so it remains at the root when an alias is already on the command line.
Example: Press Tab at workos org l. list is available after workos organization l, but the alias returns only global flags from the engine.
Recommended fix: Resolve supported aliases for the first command word before walking the tree. Add tests for org list and env list, and handle multi-part targets without matching aliases against option values.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
|
||
| local IFS=$'\\n' | ||
| local output | ||
| output=$("${bin}" --get-yargs-completions "\${COMP_WORDS[@]:1}" 2>/dev/null) |
There was a problem hiding this comment.
🟡 Bash and Zsh complete the wrong word
When editing an earlier word, _workos_completions passes the words after the cursor too. Zsh’s _workos does the same. The completion engine completes the last word, so --ver before --fix loses its matches.
Learn more
The shell scripts pass an argument list to generateCompletions, which treats the last element as the word being completed. Bash already has the index and current word in cword and cur, but sends all of COMP_WORDS. generateZsh also sends every word instead of stopping at Zsh's CURRENT index.
Example: Type workos doctor --ver --fix, move the cursor back to the end of --ver, and press Tab. The engine matches --fix rather than returning --verbose or --version for --ver.
Recommended fix: Forward only the arguments before the cursor and the current prefix. In Bash, use the normalized words from _init_completion when available. In Zsh, bound the slice by CURRENT. Preserve an explicit empty string for an empty current word.
Was this helpful? React with 👍 or 👎 to provide feedback.
| $words = $commandAst.ToString().Split(' ', [StringSplitOptions]::RemoveEmptyEntries) | ||
| $args = @() | ||
| if ($words.Count -gt 1) { | ||
| $args = $words[1..($words.Count - 1)] | ||
| } | ||
| $args += $wordToComplete |
There was a problem hiding this comment.
🟡 PowerShell counts the current word twice
At workos auth without a trailing space, $args includes auth from the command AST and again as the prefix. The completion engine enters auth too early, so Tab no longer offers authkit.
Learn more
PowerShell provides the current word, a parsed command, and the cursor position. The callback splits the entire command text on spaces and then appends the current word, so the command portion includes the token being completed. generateCompletions treats everything except the final element as already entered. The split also preserves quote characters in a quoted command name rather than using its parsed value.
Example: Press Tab at workos auth without a space. The engine receives auth twice and searches for subcommands of auth, instead of offering auth and authkit at the root.
Recommended fix: Take completed arguments from the AST's command elements and their source extents, exclude the element at the cursor and all later elements, and append the current prefix once. Test exact matches, empty prefixes, and quoted command names.
Was this helpful? React with 👍 or 👎 to provide feedback.
| partial: string, | ||
| usedOptions: Set<string>, | ||
| ): Completion[] { | ||
| const opts = [...(command?.options ?? []), ...globalOptions]; |
There was a problem hiding this comment.
🟡 Missing inherited flags after subcommands
After workos vault list --api, completeOptions omits --api-key. The Vault list command accepts that flag from its parent.
Learn more
The Vault parent declares the API-key option once rather than repeating it on each subcommand. The Vault list handler uses the inherited value. Completion keeps only the leaf and global options for both suggestions and option lookup, so it neither suggests inherited flags nor recognizes their values when walking the input.
Example: workos vault --api<Tab> offers --api-key, but workos vault list --api<Tab> does not, even though both positions are accepted by the parser.
Recommended fix: Keep the ancestor path while walking, and use one effective option list for suggestions and lookup. Prefer the nearest declaration when names overlap, while preserving hidden-option and used-option handling.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
workos completion <shell>command supporting bash, zsh, fish, and powershell--get-yargs-completionsfast path intercepted before yargs parses, avoiding validation errors on partial tab inputhelp-json.tscommand registry with normalization to handle the mixed flat/nested naming (e.g.auth loginvsskills > install)head -n-1:in zsh descriptions before passing candidates to_describe`tcompletionfrom unclaimed-environment warning middlewarehelp-jsoncommand registry during normalizationReview & Testing Checklist for Human
eval "$(workos completion bash)",eval "$(workos completion zsh)", fish, and PowerShell setup each produce usable completions in a real shell sessionhead: illegal line counterror appears:render correctly and do not break candidate parsingworkos completion <shell>does not show an unclaimed-environment warningNotes
Usage examples:
Local validation run:
pnpm test -- src/utils/completion.spec.ts— full Vitest suite passed, 125 files / 1675 testspnpm lintpnpm typecheckpnpm format:checkpnpm buildworkos --get-yargs-completions auth ""Summary by CodeRabbit
New Features
Documentation
Tests
Link to Devin session: https://app.devin.ai/sessions/d1f3c75f768e47d49b8fa040482284bd
Requested by: @nicknisi
Riker job 361: Rebase shell-completion PR
(test -x node_modules/.bin/vitest || timeout 300 bun install --frozen-lockfile …passed on 99692e2 (run 3)riker job 361·riker watch 361Review still flags
Riker's review of this code didn't approve it; it went out as it is with these findings:
Verification: Riker's check passed on exactly this code. Head 99692e2, 2026-11-23 16:59 UTC.