Skip to content

docs(cli): document managed PowerShell completion setup - #1070

Open
HowardYan888 wants to merge 7 commits into
Fission-AI:mainfrom
HowardYan888:fix-cli-completion-windows-docs
Open

docs(cli): document managed PowerShell completion setup#1070
HowardYan888 wants to merge 7 commits into
Fission-AI:mainfrom
HowardYan888:fix-cli-completion-windows-docs

Conversation

@HowardYan888

@HowardYan888 HowardYan888 commented May 8, 2026

Copy link
Copy Markdown
Contributor

Status

LGTM for final review. Independent review found no blocking documentation issues. All GitHub checks passed on commit 2e10435ce; the PR is conflict-free and awaits human review. It has not been merged.

What was wrong

The CLI reference lacked a PowerShell setup example. The original proposed openspec completion generate powershell >> $PROFILE could append with the wrong encoding, fail when the profile directory did not exist, duplicate the script on repeat runs, and leave a manual installation that completion uninstall cannot remove.

How it was fixed

  • Add separate PowerShell install and uninstall examples using the existing managed installer.
  • Export $env:PROFILE = $PROFILE so OpenSpec targets the active host's profile, including redirected Documents paths.
  • Show . $PROFILE to activate completions immediately and explain restarting after uninstall.
  • Keep the Bash generation example clearly labeled. No runtime code changed.

Replication / proof

  • Build, TypeScript check, lint, and git diff --check passed.
  • All 353 completion-related tests passed across 13 files after clearing inherited ZSH / ZSH_CUSTOM from the test process. The initial run's two completion-tip failures came from the developer's installed Oh My Zsh completions.
  • Executed the documentation's PowerShell blocks with the real built CLI in official PowerShell 7.6.5 on macOS, using isolated temporary profiles: missing profile/directories, UTF-8, UTF-8 BOM, and UTF-16 LE BOM; custom profile filenames and paths containing spaces.
  • Each case verified immediate archive tab completion, repeat installation without changing the profile, uninstall, and preservation of unrelated profile content and BOM. The uninstall check supplied --yes to answer the interactive confirmation.
  • Reproduced the original example's missing-directory failure and mixed UTF-8/UTF-16 profile corruption in PowerShell 7.6.5 before verifying the replacement.
  • Full cross-platform CI passed: Linux and macOS each passed 4,229 tests in 145 files; Windows passed 4,162 tests with 67 platform-specific skips (144 files passed, 1 skipped).
  • Independent source review, lint/type-check CI, security checks, and release tracking passed. The first local full-suite attempt exited 137; a one-worker retry was redundant once all three CI suites passed.

Notes / nits

Documentation-only; no release changeset needed. Windows PowerShell 5.1 was not executed locally. The existing installer shares a completion file between hosts in the same directory; configuring a second host when that file is already up to date is a separate pre-existing runtime limitation, not changed here.

@HowardYan888
HowardYan888 requested a review from TabishB as a code owner May 8, 2026 03:18
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Updates the CLI completion documentation with a manual-installation heading and separate Unix/macOS bash and Windows PowerShell examples. The uninstall section remains after the generate examples.

Changes

CLI Documentation Reorganization

Layer / File(s) Summary
Platform-Specific Completion Examples
docs/cli.md
Adds the manual-installation heading, separates bash and PowerShell examples, and retains the following uninstall section.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: tabishb

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly describes the main change: documenting managed PowerShell completion setup in the CLI documentation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 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 `@docs/cli.md`:
- Around line 1046-1047: The docs currently show a PowerShell snippet that uses
the overwrite redirect operator (`>`). Update the Windows (PowerShell) example
so it appends rather than overwrites: replace the line "openspec completion
generate powershell > $PROFILE" with a safe append variant — either "openspec
completion generate powershell >> $PROFILE" or the explicit PowerShell-safe form
"openspec completion generate powershell | Out-File -Append $PROFILE" and
optionally note how to edit the profile (e.g., notepad $PROFILE) so users can
inspect before modifying.
- Around line 1043-1044: The example uses a non-standard path
(~/.bash_completion.d/openspec) that isn't auto-sourced by bash on most systems;
update the docs for the "openspec completion generate bash" example to either
direct users to append to the common single-file location (~/.bash_completion)
or add a short note and the sourcing snippet that instructs users to source
~/.bash_completion.d/* from their ~/.bashrc/~/.bash_profile so the generated
file is actually loaded.
🪄 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: CHILL

Plan: Pro

Run ID: 20e99fbe-67aa-4d85-8795-1d12e879baf5

📥 Commits

Reviewing files that changed from the base of the PR and between 053d8a5 and 4ca4cd8.

📒 Files selected for processing (1)
  • docs/cli.md

Comment thread docs/cli.md Outdated
Comment on lines 1043 to 1044
# Unix/macOS (bash)
openspec completion generate bash > ~/.bash_completion.d/openspec

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

Verify the bash completion path works without additional setup.

The path ~/.bash_completion.d/openspec may not work automatically on most systems. The ~/.bash_completion.d/ directory is not typically auto-sourced by bash unless explicitly configured in ~/.bashrc or ~/.bash_profile.

Consider using ~/.bash_completion instead, or document that users must source the directory:

# Add to ~/.bashrc if using ~/.bash_completion.d/
for file in ~/.bash_completion.d/*; do
  [ -r "$file" ] && source "$file"
done

Alternatively, update the example to append to the standard single-file location:

# Unix/macOS (bash)
openspec completion generate bash >> ~/.bash_completion
🤖 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 `@docs/cli.md` around lines 1043 - 1044, The example uses a non-standard path
(~/.bash_completion.d/openspec) that isn't auto-sourced by bash on most systems;
update the docs for the "openspec completion generate bash" example to either
direct users to append to the common single-file location (~/.bash_completion)
or add a short note and the sourcing snippet that instructs users to source
~/.bash_completion.d/* from their ~/.bashrc/~/.bash_profile so the generated
file is actually loaded.

Comment thread docs/cli.md Outdated
The shell completion documentation only showed Unix/bash examples,
making it unusable for Windows users. Added platform-specific examples
for both Unix/macOS (bash) and Windows (PowerShell).

Changes:
- Add Unix/macOS (bash) example with ~/.bash_completion.d path
- Add Windows (PowerShell) example with C:\Users\y00031947\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 path
- Improve clarity with platform labels

Fixes: Windows users cannot use shell completion manual installation
Critical fix: Using '>' operator would overwrite the user's PowerShell
profile, deleting existing configurations. Changed to '>>' to append
instead of overwrite, preserving user's existing settings.
@HowardYan888
HowardYan888 force-pushed the fix-cli-completion-windows-docs branch from 933e35b to 88f6ad1 Compare June 4, 2026 06:31
@clay-good
clay-good requested a review from a team as a code owner August 7, 2026 22:00
@clay-good clay-good changed the title docs(cli): add Windows PowerShell completion example docs(cli): document managed PowerShell completion setup Aug 28, 2026
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