Skip to content

Plugin hooks can't invoke relative bundled scripts #307478

Description

  • Copilot Chat Extension Version: 0.42.3
  • VS Code Version: 1.114.0
  • OS Version: Windows 11 23H2 22631.6199
  • Feature (e.g. agent/edit/ask mode): Agent via Copilot Plugin
  • Selected model (e.g. GPT 4.1, Claude 3.7 Sonnet): Any

Steps to Reproduce:

  1. Create a basic plugin following the official documentation.
    This plugin must include:
    1.1. Any custom agent, just to trigger the hooks.
    1.2. /hooks/*.ts scripts. Can also be any language, even powershell.
    1.3. /hooks.json
{
  "version": 1,
  "hooks": {
    "HOOK NAME HERE, USE ALL FOR MORE DEBUG INFO": [
      {
        "type": "command",
        "bash": "bun ./.github/hooks/scripts/session-start.ts",
        "powershell": "bun ./.github/hooks/scripts/session-start.ts",
        // OR
        "windows": "powershell.exe -NoLogo -NoProfile -Command \"bun ./.github/hooks/scripts/session-start.ts\"",
        "cwd": ".",
        "timeoutSec": 10
      }
    ],
  }
}
  1. Publish plugin via marketplace.
  2. Install plugin in VSCode (works differently if installed using Copilot CLI.
  3. Any hook invocation (sessionStart, preToolUse, userPromptSubmitted...) will now generate an warning | execution error.

Warning output:

. : O arquivo %USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 não pode ser 
carregado porque a execução de scripts foi desabilitada neste sistema. Para obter mais informações, consulte 
about_Execution_Policies em https://go.microsoft.com/fwlink/?LinkID=135170.
No linha:1 caractere:3
+ . '%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.Powe ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ErrodeSegurança: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
error: Module not found "./.github/hooks/scripts/pre-tool-guard.ts"

this include another unrelated issue with powershell execution policies in my company, can be circumvented by using "windows": "powershell.exe -NoLogo -NoProfile

I have also tried:

  • Utilizing the cwd property but that is also relative to current VSCode directory
  • An absolute path but it gets inconsistent with the plugin installation path

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions