Skip to content

Add copilot PowerShell wrapper that pre-approves safe file writes - #638

Draft
DevSecNinja with Copilot wants to merge 2 commits into
mainfrom
copilot/add-copilot-powershell-wrapper
Draft

Add copilot PowerShell wrapper that pre-approves safe file writes#638
DevSecNinja with Copilot wants to merge 2 commits into
mainfrom
copilot/add-copilot-powershell-wrapper

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Every file create/edit in Copilot CLI triggers a manual accept prompt, even in trusted, git-tracked repos where git diff/git restore already provide a safety net. This adds a copilot PowerShell wrapper that pre-approves file writes only, leaving shell and MCP tools gated.

Changes

  • Invoke-Copilot function (Public/Copilot.ps1): resolves the real copilot executable via Get-Command -CommandType Application (never itself, avoiding alias recursion) and invokes it with --allow-tool=<list> prepended.
    • Defaults to write (file create/edit only).
    • Allow-list is configurable via $env:COPILOT_ALLOW_TOOLS, so it can be widened (e.g. read-only git status/git diff) or narrowed without editing the function.
    • -Raw switch bypasses pre-approval entirely as an escape hatch.
    • Throws a clear error if copilot isn't found on PATH.
  • Alias wiring: copilot alias added in aliases.ps1 pointing to Invoke-Copilot; function registered in DotfilesHelpers.psd1 FunctionsToExport, matching the existing Connect-CopilotSsh pattern.
  • Docs: new "Pre-approving safe file writes (PowerShell)" section in docs/copilot-cli.md, clarifying this is independent from the existing bash/zsh/fish 1Password shell-plugin wrapper.
  • Tests: new Pester suite validates default/overridden allow-tool values, argument forwarding, -Raw bypass, and missing-CLI error handling using a PATH-stubbed copilot executable.
copilot                 # runs with --allow-tool=write pre-approved
copilot -Raw             # unwrapped CLI, every tool call prompts
$env:COPILOT_ALLOW_TOOLS = 'write,shell(git status),shell(git diff)'
copilot                  # widened allow-list

Copilot AI changed the title [WIP] Add copilot PowerShell wrapper for safe file writes Add copilot PowerShell wrapper that pre-approves safe file writes Jul 29, 2026
Copilot AI requested a review from DevSecNinja July 29, 2026 13:20
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.

Add a copilot PowerShell wrapper that pre-approves safe file writes (--allow-tool='write')

2 participants