update-completions
Update PowerShell tab completions for the GitHub Copilot CLI based on its current help output. Use when asked to update, sync, or refresh completions, or when the CLI has been updated and completions need to match the latest flags, subcommands, and help topics.
来源信息
- 仓库
- scaryrawr/copilot.pwsh
- 最近来源活动
- 2026年2月18日 02:50
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 0
- 分支
- 0
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
正在显示 SKILL.md
SKILL.md
来源说明 · 只读预览- name
- update-completions
- description
- Update PowerShell tab completions for the GitHub Copilot CLI based on its current help output. Use when asked to update, sync, or refresh completions, or when the CLI has been updated and completions need to match the latest flags, subcommands, and help topics.
- license
- MIT
- compatibility
- Requires copilot CLI and PowerShell 7.0+
# Update Copilot CLI PowerShell Completions
## When to Use
- When the Copilot CLI has been updated and completions may be out of date
- When asked to update, sync, or refresh the PowerShell completions
- When new flags, subcommands, or help topics have been added to the CLI
## Instructions
1. Run the following commands to gather the current CLI help output:
```powershell
copilot --help
copilot help commands
copilot help config
copilot help environment
copilot help logging
copilot help permissions
copilot init --help
copilot update --help
copilot version --help
copilot login --help
copilot plugin --help
copilot plugin install --help
copilot plugin uninstall --help
copilot plugin update --help
copilot plugin list --help
copilot plugin marketplace --help
copilot plugin marketplace add --help
copilot plugin marketplace remove --help
copilot plugin marketplace list --help
copilot plugin marketplace browse --help
```
2. Compare the help output against the existing completions in `copilot.pwsh.psm1`.
3. Update `copilot.pwsh.psm1` to reflect any changes:
- Add entries to the relevant `$script:_*` hashtables/arrays in the **Completion Data** region
- Remove entries for deprecated/removed flags or subcommands
- Update descriptions to match current help text
- Add new subcommands or help topics
- If a new flag accepts a value, add it to `$script:_flagsWithValues`
- If a new flag has enumerated values, add a handler in the `$prevToken` check section of the completer
4. Update the fallback model list in `$script:_models` if the set of available models has changed. Parse the model list from `copilot --help` output under the `--model` section.
5. Validate changes by importing the module and triggering completions:
```powershell
Import-Module .\copilot.pwsh.psm1 -Force
# Verify no parse errors
$null = [System.Management.Automation.Language.Parser]::ParseFile(
(Resolve-Path .\copilot.pwsh.psm1).Path, [ref]$null, [ref]$null)
```
## Key Files
- `copilot.pwsh.psm1` — All completion logic; organized into three regions:
- **Completion Data** — Static `$script:_*` hashtables and arrays
- **Dynamic Completion Helpers** — Functions that shell out to `copilot` at runtime with 30s TTL caching
- **Completer Registration** — `Register-ArgumentCompleter -Native -CommandName copilot` block
- `copilot.pwsh.psd1` — Module manifest (exports nothing; side effect is completer registration)
## Conventions
- All module-level state uses `$script:` scope prefix (e.g., `$script:_topLevelCommands`)
- Completion data variables are prefixed with `_` (e.g., `$script:_globalFlags`, `$script:_models`)
- Flag dictionaries use `[ordered]@{}` to preserve display order in completions
- Dynamic completions parse bullet-point output (`•`) from `copilot` CLI using regex
- `[Console]::OutputEncoding` is temporarily set to UTF-8 and restored in `finally` blocks when invoking external commands
- The manifest exports nothing (`FunctionsToExport = @()`); the module's only side effect is argument completer registration
在 GitHub 查看