Skip to content

Commit 5e1cef3

Browse files
authored
fix(spec): align cli-completion spec with implementation (#360)
Update the cli-completion spec to match the actual implementation: - Change `completion zsh` to `completion generate [shell]` command structure - Update uninstall behavior to reflect confirmation prompt cancels entire operation - Change "not installed" uninstall exit code from 0 to 1 - Update shell detection error message to match implementation - Replace Purpose placeholder with actual description
1 parent 1adf3ce commit 5e1cef3

File tree

1 file changed

+12
-9
lines changed
  • openspec/specs/cli-completion

1 file changed

+12
-9
lines changed

openspec/specs/cli-completion/spec.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cli-completion Specification
22

33
## Purpose
4-
TBD - created by archiving change add-shell-completions. Update Purpose after archive.
4+
Provide shell completion scripts for the OpenSpec CLI, enabling tab-completion for commands, flags, and dynamic values (change IDs, spec IDs) in supported shells. Currently supports Zsh with architecture designed for future shell expansion.
55
## Requirements
66
### Requirement: Native Shell Behavior Integration
77

@@ -30,7 +30,7 @@ The completion command SHALL follow a subcommand pattern for generating and mana
3030

3131
- **WHEN** user executes `openspec completion --help`
3232
- **THEN** display available subcommands:
33-
- `zsh` - Generate Zsh completion script
33+
- `generate [shell]` - Generate completion script for a shell (outputs to stdout)
3434
- `install [shell]` - Install completion for Zsh (auto-detects or requires explicit shell)
3535
- `uninstall [shell]` - Remove completion for Zsh (auto-detects or requires explicit shell)
3636

@@ -57,7 +57,7 @@ The completion command SHALL generate Zsh completion scripts on demand.
5757

5858
#### Scenario: Generating Zsh completion
5959

60-
- **WHEN** user executes `openspec completion zsh`
60+
- **WHEN** user executes `openspec completion generate zsh`
6161
- **THEN** output a complete Zsh completion script to stdout
6262
- **AND** include completions for all commands: init, list, show, validate, archive, view, update, change, spec, completion
6363
- **AND** include all command-specific flags and options
@@ -140,9 +140,11 @@ The completion command SHALL remove installed completion scripts and configurati
140140
#### Scenario: Uninstalling Oh My Zsh completion
141141

142142
- **WHEN** user executes `openspec completion uninstall zsh`
143-
- **THEN** remove `~/.oh-my-zsh/custom/completions/_openspec` if Oh My Zsh is detected
143+
- **THEN** prompt for confirmation before proceeding (unless `--yes` flag provided)
144+
- **AND** if user declines, cancel uninstall and display "Uninstall cancelled."
145+
- **AND** if user confirms, remove `~/.oh-my-zsh/custom/completions/_openspec` if Oh My Zsh is detected
144146
- **AND** remove `~/.zsh/completions/_openspec` if standard Zsh setup is detected
145-
- **AND** optionally remove fpath modifications from `~/.zshrc` (with confirmation)
147+
- **AND** remove fpath modifications from `~/.zshrc`
146148
- **AND** display success message
147149

148150
#### Scenario: Auto-detecting Zsh for uninstallation
@@ -154,8 +156,8 @@ The completion command SHALL remove installed completion scripts and configurati
154156
#### Scenario: Not installed
155157

156158
- **WHEN** attempting to uninstall completion that isn't installed
157-
- **THEN** display message indicating completion is not installed
158-
- **AND** exit with code 0
159+
- **THEN** display error message indicating completion is not installed
160+
- **AND** exit with code 1
159161

160162
### Requirement: Architecture Patterns
161163

@@ -227,7 +229,8 @@ The completion command SHALL provide clear error messages for common failure sce
227229
#### Scenario: Shell not detected
228230

229231
- **WHEN** `openspec completion install` cannot detect current shell or detects non-Zsh shell
230-
- **THEN** display error: "Could not detect Zsh. Please specify explicitly: openspec completion install zsh"
232+
- **THEN** display error: "Could not auto-detect shell. Please specify shell explicitly."
233+
- **AND** display usage hint: "Usage: openspec completion <operation> [shell]"
231234
- **AND** exit with code 1
232235

233236
### Requirement: Output Format
@@ -238,7 +241,7 @@ The completion command SHALL provide machine-parseable and human-readable output
238241

239242
- **WHEN** generating completion script to stdout
240243
- **THEN** output only the completion script content (no extra messages)
241-
- **AND** allow redirection to files: `openspec completion zsh > /path/to/_openspec`
244+
- **AND** allow redirection to files: `openspec completion generate zsh > /path/to/_openspec`
242245

243246
#### Scenario: Installation success output
244247

0 commit comments

Comments
 (0)