Skip to content

feat(completions): add PowerShell tab completion support#30929

Open
Liohtml wants to merge 3 commits into
oven-sh:mainfrom
Liohtml:claude/powershell-completions
Open

feat(completions): add PowerShell tab completion support#30929
Liohtml wants to merge 3 commits into
oven-sh:mainfrom
Liohtml:claude/powershell-completions

Conversation

@Liohtml
Copy link
Copy Markdown

@Liohtml Liohtml commented May 17, 2026

Summary

  • Add completions/bun.ps1 — PowerShell tab completion for the bun and bunx commands (closes implement completions for powershell #8939)
  • Supports all 21 subcommands with descriptions, 44 global flags, and per-command flags for test, install/add/remove/update, build, init, and audit
  • Dynamic completions: reads package.json scripts, node_modules/.bin binaries, and JS/TS files
  • Install by adding . path/to/bun.ps1 to $PROFILE

Test plan

  • Open PowerShell, source the file: . completions/bun.ps1
  • Type bun <TAB> — should show subcommands (run, test, build, install, etc.)
  • Type bun test --<TAB> — should show test-specific flags (--timeout, --coverage, etc.)
  • Type bun install --<TAB> — should show install flags (--frozen-lockfile, --global, etc.)
  • Type bun run <TAB> in a project with package.json scripts — should show script names
  • Type bun build --<TAB> — should show build flags (--compile, --minify, --target, etc.)
  • Verify syntax: powershell -NoProfile -Command "[System.Management.Automation.Language.Parser]::ParseFile('completions/bun.ps1', [ref]$null, [ref]$null)"

🤖 Generated with Claude Code

Add completions/bun.ps1 with Register-ArgumentCompleter for PowerShell.
Supports all subcommands (run, test, build, install, add, remove, etc.),
global flags, per-command flags, dynamic script/binary completion from
package.json, and JavaScript file completion.

Install by adding `. path/to/bun.ps1` to $PROFILE.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Review Change Stack

Walkthrough

Adds completions/bun.ps1, a PowerShell ArgumentCompleter for bun/bunx that suggests subcommands, global and subcommand flags, package.json scripts, node_modules binaries, JS/TS files, and dependency names based on cursor context.

Changes

PowerShell Completion for bun/bunx

Layer / File(s) Summary
Completion data helpers
completions/bun.ps1
Header plus _bun_get_scripts, _bun_get_bins, _bun_get_js_files, and _bun_get_dependencies to produce completion candidates from package.json, node_modules/.bin, and local JS/TS files.
Main completion dispatcher
completions/bun.ps1
Register-ArgumentCompleter handler tokenizes input, identifies subcommand/position, and dispatches to subcommand suggestions, flag completers, or context-aware candidate gatherers.
Subcommand-specific flag completers
completions/bun.ps1
Flag helper functions (_bun_complete_global_flags, _bun_complete_test_flags, _bun_complete_install_flags, _bun_complete_build_flags, _bun_complete_init_flags, _bun_complete_audit_flags, _bun_complete_publish_flags, _bun_complete_patch_flags) that emit filtered flag suggestions.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(completions): add PowerShell tab completion support' clearly and concisely summarizes the main change—adding PowerShell tab completion functionality.
Description check ✅ Passed The description provides a comprehensive summary of changes, test plan with specific steps, and verification instructions, covering both required template sections.
Linked Issues check ✅ Passed The PR successfully implements PowerShell argument completion support for Bun commands using Register-ArgumentCompleter, directly fulfilling the objectives of issue #8939.
Out of Scope Changes check ✅ Passed All changes are focused on implementing PowerShell completion support; no unrelated modifications were introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@completions/bun.ps1`:
- Around line 141-156: The dependency enumeration block duplicated in the
'remove' case should be extracted into a helper function (suggested name
_bun_get_dependencies) similar to _bun_get_scripts; implement
_bun_get_dependencies accepting a wordToComplete (or currentToken) that reads
package.json, iterates the four dependency keys, filters by the prefix and
returns CompletionResult items, then replace the inline block inside the
'remove' branch with a call to _bun_get_dependencies $currentToken (ensure
Register-ArgumentCompleter still references the new helper and reuse the same
error handling/try/catch semantics).
- Around line 34-42: The path-based completion fails because _bun_get_js_files
uses -Filter "*$wordToComplete*" against the current directory which doesn't
match paths with separators; change _bun_get_js_files to split $wordToComplete
into a directory part and a filename prefix (e.g. use [System.IO.Path] or -split
on '/'/'\'), set the Get-ChildItem -Path to that directory (fall back to $PWD
when empty) and apply the filename filter (or a Where-Object on Name) for the
filename portion, then build the relative path
($_.FullName.Substring($PWD.Path.Length + 1).Replace('\', '/')) and emit
CompletionResult as before so tab-completion works for files in subdirectories.
- Around line 109-129: The switch mapping incorrectly routes 'publish',
'outdated', 'link', 'unlink', 'patch', and 'info' to
_bun_complete_install_flags; update the switch in the
currentToken.StartsWith('-') block so each of those subcommands calls its own
completer (e.g. _bun_complete_publish_flags, _bun_complete_outdated_flags,
_bun_complete_link_flags, _bun_complete_unlink_flags, _bun_complete_patch_flags,
_bun_complete_info_flags) or falls back to _bun_complete_global_flags if
appropriate, and implement those new completer functions (or adjust existing
ones) to provide the correct flags (--access, --tag, etc. for publish; --save
for link; --commit/--patches-dir for patch; --json for info; no major flags for
outdated).
- Around line 157-163: The 'pm' case in completions/bun.ps1 currently generates
completions from an incomplete array; update that array in the 'pm' { ... }
block to include all 17 documented subcommands: bin, cache, default-trusted,
hash, hash-print, hash-string, migrate, pack, pkg, scan, trust, untrusted,
version, view, whoami, why, and ls so the Where-Object { $_ -like
"$currentToken*" } / ForEach-Object { [CompletionResult]::new($_, $_,
'ParameterValue', "pm $_") } pipeline will emit completions for the missing
items (scan, why, whoami, view, version, pkg) as well as the existing ones.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8a4a0852-6577-41ca-bdc5-47581e520997

📥 Commits

Reviewing files that changed from the base of the PR and between 172afa5 and 21e2095.

📒 Files selected for processing (1)
  • completions/bun.ps1

Comment thread completions/bun.ps1
Comment thread completions/bun.ps1
Comment on lines +109 to +129
# Complete flags and args for known subcommands
if ($currentToken.StartsWith('-')) {
switch ($subcommand) {
'test' { _bun_complete_test_flags $currentToken }
'install' { _bun_complete_install_flags $currentToken }
'add' { _bun_complete_install_flags $currentToken }
'remove' { _bun_complete_install_flags $currentToken }
'update' { _bun_complete_install_flags $currentToken }
'build' { _bun_complete_build_flags $currentToken }
'init' { _bun_complete_init_flags $currentToken }
'publish' { _bun_complete_install_flags $currentToken }
'outdated' { _bun_complete_install_flags $currentToken }
'link' { _bun_complete_install_flags $currentToken }
'unlink' { _bun_complete_install_flags $currentToken }
'patch' { _bun_complete_install_flags $currentToken }
'info' { _bun_complete_install_flags $currentToken }
'audit' { _bun_complete_audit_flags $currentToken }
default { _bun_complete_global_flags $currentToken }
}
return
}
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.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if publish, outdated, link, unlink, patch, info support the same flags as install

for cmd in publish outdated link unlink patch info; do
  echo "=== bun $cmd --help ==="
  bun $cmd --help 2>&1 | head -50
  echo ""
done

Repository: oven-sh/bun

Length of output: 467


🏁 Script executed:

# Search for documentation about bun commands
find . -type f \( -name "*.md" -o -name "*.txt" \) | head -20

Repository: oven-sh/bun

Length of output: 739


🏁 Script executed:

# Look for bun CLI documentation or help text in the repo
rg "publish|outdated|link|unlink|patch|info" --type md -A 3 | head -100

Repository: oven-sh/bun

Length of output: 7615


🏁 Script executed:

# Check if there's a bun source directory with CLI definitions
find . -type d -name "*cli*" -o -name "*command*" -o -name "*src*" | head -20

Repository: oven-sh/bun

Length of output: 594


🏁 Script executed:

# Search in docs/pm/cli for command documentation
find ./docs/pm/cli -type f | head -20

Repository: oven-sh/bun

Length of output: 343


🏁 Script executed:

# Look for documentation about these specific commands
rg "publish|outdated|link|unlink|patch|info" ./docs -A 2 -B 2 | head -150

Repository: oven-sh/bun

Length of output: 11590


🏁 Script executed:

# Check the bun.ps1 file more broadly for context about flag handlers
cat -n completions/bun.ps1 | head -150

Repository: oven-sh/bun

Length of output: 7569


🏁 Script executed:

# Check the documentation for install, publish, outdated, link, unlink, patch, info to compare their flags
for file in ./docs/pm/cli/install.mdx ./docs/pm/cli/publish.mdx ./docs/pm/cli/outdated.mdx ./docs/pm/cli/link.mdx ./docs/pm/cli/unlink.mdx ./docs/pm/cli/patch.mdx ./docs/pm/cli/info.mdx; do
  echo "=== $(basename $file) ==="
  head -100 "$file"
  echo ""
done

Repository: oven-sh/bun

Length of output: 15345


🏁 Script executed:

# Let's verify that these commands indeed have different flag sets by searching the source
# Look for flag definitions in the bun source code
find ./src -name "*.ts" -o -name "*.js" | xargs grep -l "publish\|outdated\|link\|patch\|info" 2>/dev/null | head -10

Repository: oven-sh/bun

Length of output: 339


🏁 Script executed:

# Check if there's any pattern showing these commands were intentionally mapped to install flags
rg "publish.*install|outdated.*install|link.*install|patch.*install|info.*install" completions/ -A 2 -B 2

Repository: oven-sh/bun

Length of output: 928


Create separate flag handlers for publish, outdated, link, unlink, patch, and info subcommands.

Lines 119-124 incorrectly map publish, outdated, link, unlink, patch, and info to _bun_complete_install_flags. However, these commands have distinct purposes and flag sets:

  • publish: Uses --access, --tag, --dry-run, --tolerate-republish, --gzip-level
  • outdated: Accepts package name/glob pattern arguments; no major flags
  • link: Uses --save for dependency registration
  • patch: Uses --commit, --patches-dir
  • info: Uses --json for metadata output

Each should have its own flag completer (_bun_complete_publish_flags, etc.) or fall back to _bun_complete_global_flags.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@completions/bun.ps1` around lines 109 - 129, The switch mapping incorrectly
routes 'publish', 'outdated', 'link', 'unlink', 'patch', and 'info' to
_bun_complete_install_flags; update the switch in the
currentToken.StartsWith('-') block so each of those subcommands calls its own
completer (e.g. _bun_complete_publish_flags, _bun_complete_outdated_flags,
_bun_complete_link_flags, _bun_complete_unlink_flags, _bun_complete_patch_flags,
_bun_complete_info_flags) or falls back to _bun_complete_global_flags if
appropriate, and implement those new completer functions (or adjust existing
ones) to provide the correct flags (--access, --tag, etc. for publish; --save
for link; --commit/--patches-dir for patch; --json for info; no major flags for
outdated).

Comment thread completions/bun.ps1
Comment thread completions/bun.ps1
- Fix _bun_get_js_files to handle subdirectory paths (src/index<TAB>)
- Extract _bun_get_dependencies helper for remove command
- Add _bun_complete_publish_flags and _bun_complete_patch_flags
- Complete pm subcommand list (add pkg, scan, version, view, whoami, why)
- Route publish/patch to their own flag completers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@completions/bun.ps1`:
- Around line 360-370: The _bun_complete_publish_flags completer is missing
three options; update the $flags array inside the _bun_complete_publish_flags
function to include entries for '--dry-run' (Desc: 'Simulate publish without
actually publishing'), '--tolerate-republish' (Desc: 'Allow republishing an
already published version'), and '--gzip-level' (Desc: 'Set tarball compression
level (0-9)') so they are returned by the existing Where-Object / ForEach-Object
completion logic; keep the same hash structure (Name/Desc) so the
[CompletionResult] creation remains unchanged.
- Around line 169-171: Remove the invalid 'who' entry from the pm subcommand
suggestions array so only valid commands are listed; specifically edit the
string list that currently contains 'who' and 'whoami' (the array including
'bin', 'cache', ... 'who', 'whoami', 'why') and delete the 'who' element so only
'whoami' remains as the valid npm user command suggestion.
- Around line 143-148: The routing for several subcommands is incorrect: update
the case arms so that 'publish' calls only _bun_complete_publish_flags (remove
the _bun_complete_install_flags call), and change 'outdated', 'link', 'unlink',
and 'info' to fall back to _bun_complete_global_flags instead of
_bun_complete_install_flags; locate the switch/case handling these subcommands
(symbols: 'publish', 'outdated', 'link', 'unlink', 'info') and replace the
referenced helper functions accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8635dcc3-cd71-4a2f-842d-2b7b5c9e0182

📥 Commits

Reviewing files that changed from the base of the PR and between 21e2095 and 9d73ee9.

📒 Files selected for processing (1)
  • completions/bun.ps1

Comment thread completions/bun.ps1 Outdated
Comment on lines +143 to +148
'publish' { _bun_complete_install_flags $currentToken; _bun_complete_publish_flags $currentToken }
'outdated' { _bun_complete_install_flags $currentToken }
'link' { _bun_complete_install_flags $currentToken }
'unlink' { _bun_complete_install_flags $currentToken }
'patch' { _bun_complete_patch_flags $currentToken }
'info' { _bun_complete_install_flags $currentToken }
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify flags for outdated, link, unlink, info, publish commands

for cmd in outdated link unlink info publish; do
  echo "=== bun $cmd --help ==="
  bun $cmd --help 2>&1 | grep -A 30 "^Flags:" || echo "No flags section found"
  echo ""
done

Repository: oven-sh/bun

Length of output: 304


🏁 Script executed:

# Check if bun is available and its version
bun --version 2>&1 || echo "Bun not available"

# Try getting raw help output for one command to see the actual format
bun publish --help 2>&1 | head -50

Repository: oven-sh/bun

Length of output: 157


🏁 Script executed:

# Check the actual state of the bun.ps1 file at the specified lines
cat -n completions/bun.ps1 | sed -n '140,155p'

Repository: oven-sh/bun

Length of output: 1034


🏁 Script executed:

# Search for existing completer functions in bun.ps1 to understand the pattern
rg "function _bun_complete_" completions/bun.ps1 -A 5

Repository: oven-sh/bun

Length of output: 2563


🌐 Web query:

bun outdated link unlink info publish command flags documentation

💡 Result:

The Bun CLI provides several commands for managing dependencies, local package linking, and publishing. Below is a summary of the requested commands and their documentation details. bun outdated The bun outdated command checks for dependencies in your project that have newer versions available [1]. It displays a table comparing the current installed version, the version satisfying your package.json range, and the latest version on the registry [1]. - Key features: Supports dependency filters (package names or glob patterns) and workspace filters using the --filter flag [1]. - Execution: It can be run as bun outdated [1]. bun link and bun unlink These commands are used for local package development by creating symbolic links [2][3]. - bun link: When run in a package directory without arguments, it registers the current package in the global link registry [3][4]. When run with a package name (e.g., bun link ), it creates a symlink in the target project's node_modules pointing to the local directory [2][3]. - bun unlink: When run in a package directory without arguments, it unregisters the package from the global link registry [3][5]. It is also used to remove symlinks from a project [6]. - Note: To remove a linked package from a project's dependencies, use bun remove [5]. bun publish The bun publish command is used to publish packages to the npm registry [7]. While specific flag documentation for publish is often context-dependent, standard package manager publishing workflows in Bun generally follow npm-compatible patterns. For advanced package management utilities, such as creating tarballs, Bun provides the bun pm pack command, which supports flags like --dry-run, --destination, --filename, --ignore-scripts, and --gzip-level [8]. Important Distinctions - File System Unlink: Do not confuse the CLI command bun unlink with the API method Bun.file.delete (used for file system operations) [9] or the RedisClient.unlink method (used for non-blocking key deletion in Redis) [10]. - Documentation: Always refer to the official Bun documentation at bun.sh/docs for the most accurate and up-to-date CLI flag references [2][11].

Citations:


🏁 Script executed:

# Check if there's any documentation in the repo about these commands
find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.ps1" \) -exec grep -l "outdated\|link.*flag\|unlink.*flag\|info.*flag" {} \; | head -20

Repository: oven-sh/bun

Length of output: 220


🏁 Script executed:

# Look for any references to what these commands do in the source or docs
rg "(outdated|link|unlink|info|publish)" completions/bun.ps1 -B 2 -A 2 | head -50

Repository: oven-sh/bun

Length of output: 2745


🏁 Script executed:

# Search for any bun PM documentation or examples in the repo
find . -type f -name "*.md" -exec grep -l "bun outdated\|bun link\|bun unlink\|bun info\|bun publish" {} \;

Repository: oven-sh/bun

Length of output: 67


🏁 Script executed:

# Check the CONTRIBUTING.md or README for any flag documentation
grep -A 10 -B 2 "outdated\|link\|unlink\|info\|publish" ./README.md | head -100

Repository: oven-sh/bun

Length of output: 3574


Fix incorrect flag routing for publish, outdated, link, unlink, and info subcommands.

These commands incorrectly route to _bun_complete_install_flags:

  • Line 143: publish calls both _bun_complete_install_flags and _bun_complete_publish_flags—it should call only _bun_complete_publish_flags (the install flags are redundant and incorrect).
  • Line 144: outdated checks for dependency updates but routes to install flags.
  • Line 145: link creates local package symlinks, not a package installation command.
  • Line 146: unlink removes local package symlinks.
  • Line 148: info displays package metadata.

Since these commands have distinct purposes from package installation, they should fall back to _bun_complete_global_flags:

-        'publish'  { _bun_complete_install_flags $currentToken; _bun_complete_publish_flags $currentToken }
-        'outdated' { _bun_complete_install_flags $currentToken }
-        'link'     { _bun_complete_install_flags $currentToken }
-        'unlink'   { _bun_complete_install_flags $currentToken }
+        'publish'  { _bun_complete_publish_flags $currentToken }
+        'outdated' { _bun_complete_global_flags $currentToken }
+        'link'     { _bun_complete_global_flags $currentToken }
+        'unlink'   { _bun_complete_global_flags $currentToken }
         'patch'    { _bun_complete_patch_flags $currentToken }
-        'info'     { _bun_complete_install_flags $currentToken }
+        'info'     { _bun_complete_global_flags $currentToken }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'publish' { _bun_complete_install_flags $currentToken; _bun_complete_publish_flags $currentToken }
'outdated' { _bun_complete_install_flags $currentToken }
'link' { _bun_complete_install_flags $currentToken }
'unlink' { _bun_complete_install_flags $currentToken }
'patch' { _bun_complete_patch_flags $currentToken }
'info' { _bun_complete_install_flags $currentToken }
'publish' { _bun_complete_publish_flags $currentToken }
'outdated' { _bun_complete_global_flags $currentToken }
'link' { _bun_complete_global_flags $currentToken }
'unlink' { _bun_complete_global_flags $currentToken }
'patch' { _bun_complete_patch_flags $currentToken }
'info' { _bun_complete_global_flags $currentToken }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@completions/bun.ps1` around lines 143 - 148, The routing for several
subcommands is incorrect: update the case arms so that 'publish' calls only
_bun_complete_publish_flags (remove the _bun_complete_install_flags call), and
change 'outdated', 'link', 'unlink', and 'info' to fall back to
_bun_complete_global_flags instead of _bun_complete_install_flags; locate the
switch/case handling these subcommands (symbols: 'publish', 'outdated', 'link',
'unlink', 'info') and replace the referenced helper functions accordingly.

Comment thread completions/bun.ps1 Outdated
- Remove invalid 'who' from pm subcommands (not a real subcommand)
- Add --dry-run and --auth-type to publish flags
- Make patch fall through to install flags for shared options

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
completions/bun.ps1 (1)

143-148: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix incorrect flag routing for publish, outdated, link, unlink, and info subcommands.

These commands incorrectly route to _bun_complete_install_flags:

  • Line 143: publish calls both _bun_complete_install_flags and _bun_complete_publish_flags—the install flags are redundant and incorrect for a publishing operation.
  • Line 144: outdated checks for dependency updates but does not install packages.
  • Lines 145-146: link and unlink manage local package symlinks, not package installation.
  • Line 148: info displays package metadata without installing.

Since these commands have distinct purposes from package installation, update the routing:

🔧 Proposed fix
-        'publish'  { _bun_complete_publish_flags $currentToken; _bun_complete_install_flags $currentToken }
-        'outdated' { _bun_complete_install_flags $currentToken }
-        'link'     { _bun_complete_install_flags $currentToken }
-        'unlink'   { _bun_complete_install_flags $currentToken }
+        'publish'  { _bun_complete_publish_flags $currentToken }
+        'outdated' { _bun_complete_global_flags $currentToken }
+        'link'     { _bun_complete_global_flags $currentToken }
+        'unlink'   { _bun_complete_global_flags $currentToken }
         'patch'    { _bun_complete_patch_flags $currentToken }
-        'info'     { _bun_complete_install_flags $currentToken }
+        'info'     { _bun_complete_global_flags $currentToken }

Run the following script to verify the flag sets for each command:

#!/bin/bash
# Verify that publish, outdated, link, unlink, and info have distinct flag sets from install

echo "=== Checking bun documentation for command-specific flags ==="

# Search for publish command documentation
echo -e "\n--- bun publish ---"
rg -i "bun publish" docs/ -A 10 -B 2 | head -50

# Search for outdated command documentation
echo -e "\n--- bun outdated ---"
rg -i "bun outdated" docs/ -A 10 -B 2 | head -50

# Search for link/unlink command documentation  
echo -e "\n--- bun link/unlink ---"
rg -i "bun (link|unlink)" docs/ -A 10 -B 2 | head -50

# Search for info command documentation
echo -e "\n--- bun info ---"
rg -i "bun info" docs/ -A 10 -B 2 | head -50
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@completions/bun.ps1`:
- Around line 360-373: The publish completer function
_bun_complete_publish_flags is missing the --tolerate-republish and --gzip-level
flags; update the $flags array in _bun_complete_publish_flags to include entries
for @{ Name = '--tolerate-republish'; Desc = 'Exit 0 if version already exists
(useful for CI/CD)' } and @{ Name = '--gzip-level'; Desc = 'Set tarball gzip
compression level' } using the same array/object shape as the other flag entries
so they are returned by the Where-Object/ForEach-Object completion pipeline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 47fdd25f-9181-4da4-8f9d-552d8aa1f75b

📥 Commits

Reviewing files that changed from the base of the PR and between 9d73ee9 and 4a2e1fe.

📒 Files selected for processing (1)
  • completions/bun.ps1

Comment thread completions/bun.ps1
Comment on lines +360 to +373
function _bun_complete_publish_flags {
param([string]$word)
# Publish-specific flags (in addition to shared install flags)
$flags = @(
@{ Name = '--access'; Desc = 'Set package access level (public|restricted)' }
@{ Name = '--tag'; Desc = 'Publish with a specific dist-tag' }
@{ Name = '--otp'; Desc = 'One-time password for 2FA' }
@{ Name = '--dry-run'; Desc = "Don't actually publish" }
@{ Name = '--auth-type'; Desc = 'Authentication type (legacy|web)' }
)
$flags | Where-Object { $_.Name -like "$word*" } | ForEach-Object {
[CompletionResult]::new($_.Name, $_.Name, 'ParameterName', $_.Desc)
}
}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

bun publish command flags official documentation

💡 Result:

The bun publish command is used to publish packages to the npm registry [1][2]. It automatically packs the package into a tarball, resolves workspace and catalog protocols in package.json, and publishes to the registry configured in your bunfig.toml or.npmrc files [1][3]. Commonly used flags for bun publish include: --access <public|restricted>: Sets the access level for the package. Required for scoped packages that should be public [1][2]. --tag : Publishes the package under a specific distribution tag (default is latest) [1][2]. --dry-run: Simulates the publish process without actually uploading the package, allowing you to verify the contents [1][2]. --otp : Provides a one-time password for accounts with 2FA enabled [2][3]. --auth-type <web|legacy>: Specifies the 2FA authentication method. web (default) opens a browser, while legacy prompts in the terminal [1][2]. --tolerate-republish: Exits with code 0 instead of 1 if the package version already exists, which is useful for CI/CD pipelines [2][3]. --gzip-level : Configures the compression level for the tarball [1][3]. For authentication in CI/CD environments, Bun uses the NPM_CONFIG_TOKEN environment variable [2][4]. You can set this variable to your npm auth token to enable automated publishing [2]. For more detailed information, you can refer to the official Bun documentation at https://bun.com/docs/pm/cli/publish [1].

Citations:


Add missing publish flags --tolerate-republish and --gzip-level to the publish completer.

According to the official Bun documentation, the bun publish command supports --tolerate-republish (exits with code 0 instead of 1 if the package version already exists, useful for CI/CD pipelines) and --gzip-level (configures the compression level for the tarball), but these are not included in the function.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@completions/bun.ps1` around lines 360 - 373, The publish completer function
_bun_complete_publish_flags is missing the --tolerate-republish and --gzip-level
flags; update the $flags array in _bun_complete_publish_flags to include entries
for @{ Name = '--tolerate-republish'; Desc = 'Exit 0 if version already exists
(useful for CI/CD)' } and @{ Name = '--gzip-level'; Desc = 'Set tarball gzip
compression level' } using the same array/object shape as the other flag entries
so they are returned by the Where-Object/ForEach-Object completion pipeline.

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.

implement completions for powershell

1 participant