Copilot CLI hooks fail on Windows: command runs under PowerShell, which can't execute te-hook
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- github, powershell, python
- Domain
- cli, developer-experience
Research direction
Read plugin/hooks/copilot-hooks.json and the existing Windows handling in the Codex manifest. Check how Copilot hook commands are configured for bash and powershell, then verify the proposed shell lookup against the Windows environments in the report. Done means all six hooks run without errors on Windows and te status shows the repository.
Written by the indexing model from the issue text.
Description
Summary
On Windows, every Copilot CLI hook from the plugin fails with exit code 1, so TokenEconomizer never runs (no state under ~/.tokeneconomizer/repos/...).
plugin/hooks/copilot-hooks.json uses only command:
"command": "\"${PLUGIN_ROOT}/scripts/te-hook\" --host copilot"
Per the Copilot hooks reference, command is copied to both bash and powershell. On Windows, Copilot CLI runs the powershell variant, and PowerShell can't execute the extensionless POSIX script te-hook (Cannot run a document in the middle of a pipeline: ...\plugin\scripts\te-hook).
docs/PLUGIN.md already notes that Copilot CLI on Windows is untested, so this may be expected. I'm filing it with a verified workaround.
Environment
- Windows 11, Copilot CLI 1.0.107 (standalone
copilot.exe) - Git for Windows (
C:\Program Files\Git); itsbin\is not on the machine PATH by default (onlyGit\cmd) - Python 3.15 via the Python install manager
- Plugin installed from a local clone at
main(marketplace add +copilot plugin install tokeneconomizer@tokeneconomizer)
Repro
- Install the plugin on Windows as above.
- In any git repo:
copilot -p "Reply with just: ok" ~/.copilot/logs/process-*.logshows, once per hook:
[ERROR] [rust:hooks] Hook from "tokeneconomizer@tokeneconomizer" execution failed: Error: Hook command failed with code 1
What I tested
| Variant | Normal user PATH | PATH with Git bin on it |
|---|---|---|
Original command |
❌ 4 hook failures | ❌ 4 hook failures |
"command": "sh \"${PLUGIN_ROOT}/scripts/te-hook\" ..." |
❌ (sh not on PATH) |
✅ |
Split bash + powershell with sh lookup (below) |
✅ | ✅ |
A plain sh prefix isn't enough, because Git for Windows doesn't put sh.exe on PATH by default. Deriving it from git.exe alone isn't enough either: some hosts bundle a Git whose sh.exe is under usr\bin instead of bin.
Suggested fix
Keep the POSIX command as bash, and add a powershell entry that locates sh.exe (PATH first, then next to git.exe):
{
"type": "command",
"bash": "\"${PLUGIN_ROOT}/scripts/te-hook\" --host copilot",
"powershell": "$s=(Get-Command sh.exe -ErrorAction SilentlyContinue).Source; if(-not $s){$g=Split-Path (Split-Path (Get-Command git.exe -ErrorAction SilentlyContinue).Source); $s=@(\"$g\\bin\\sh.exe\",\"$g\\usr\\bin\\sh.exe\") | Where-Object {Test-Path $_} | Select-Object -First 1}; & $s \"${PLUGIN_ROOT}/scripts/te-hook\" --host copilot",
"timeoutSec": 30
}
With this applied to all 6 events, I get no hook errors, te status shows the repo, and toolprune records the catalog. A small te-hook.ps1 wrapper would be cleaner than the inline one-liner. The Codex manifest's commandWindows handling looks like the equivalent of this for Codex.
Possibly related: #167 (te launcher on Windows/Git Bash).
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 344
- Avg merge
- 17h 41m
- Merged PRs (30d)
- 73
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/TokenEconomizer
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2xPossibly taken @Shizoqua claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/TokenEconomizer#221 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
microsoft/TokenEconomizer#219 ·
Maintainers usually reply within 1 day
-
CommandCode supportOpen
Difficulty 5/5 Over a week Newbie friendliness 25/100
microsoft/TokenEconomizer#205 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
microsoft/TokenEconomizer#193 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
microsoft/TokenEconomizer#186 ·
Maintainers usually reply within 1 day
All issues in microsoft/TokenEconomizer
Similar issues
-
documentation type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
add entry to blockOpen
Difficulty 1/5 Under an hour Newbie friendliness 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Possibly taken @0z5a claimed this today. Openneeds-triage
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
plot_graph crashes when a mesh node has no m2m edgePossibly taken @tygvi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mllam/neural-lam#883 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/graphrag#2626 · 1 comment ·
Maintainers usually reply within 5 days