Copilot CLI hooks fail on Windows: command runs under PowerShell, which can't execute te-hook
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- github, powershell, python
- Lĩnh vực
- cli, developer-experience
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Python
- Star
- 5.6k
- Fork
- 344
- Merge trung bình
- 17 giờ 41 phút
- Pull request đã merge (30 ngày)
- 73
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TokenEconomizer
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2xCó thể đã có người làm @Shizoqua đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/TokenEconomizer#221 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
microsoft/TokenEconomizer#219 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CommandCode supportĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
microsoft/TokenEconomizer#205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
microsoft/TokenEconomizer#193 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
microsoft/TokenEconomizer#186 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/TokenEconomizer
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
splunk/security_content#4418 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug / Enhancement]: Improve teleop_robot CLI with configurable timeout, robust input validation, and clean ROS shutdownCó thể đã có người làm @muskan-creates352 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 3 ngày
-
bug(pipelines): shortcode stripping deletes text between a {{< >}} shortcode and the next {{% %}}Có thể đã có người làm @Ashborne-lab đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
kubeflow/docs-agent#293 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Imbad0202/academic-research-skills#1093 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Input: placeholder drawn in the text colour when the empty Input is focused but not yet editedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pierreaubert/gpui-toolkit#114 ·
Maintainer thường phản hồi trong vòng 1 ngày