Copilot CLI hooks fail on Windows: command runs under PowerShell, which can't execute te-hook
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- github, powershell, python
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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).
- 主要语言
- Python
- 星标
- 5.6k
- 派生
- 344
- 平均合并
- 17 小时 41 分钟
- 30 天内合并 PR
- 73
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/TokenEconomizer 的其他 Issue
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2x可能已有人在做 @Shizoqua 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/TokenEconomizer#221 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 15/100
microsoft/TokenEconomizer#219 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
microsoft/TokenEconomizer#205 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
microsoft/TokenEconomizer#193 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
microsoft/TokenEconomizer#186 ·
维护者通常 1 天内回复
查看 microsoft/TokenEconomizer 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
gorakhargosh/watchdog#1462 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
openwisp/openwisp-monitoring#889 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
OpenFreeEnergy/Lomap#180 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
roman-corgi/corgisim#327 ·
维护者通常 2 天内回复
-
agent:WSL bug code-review linux pri:medium sev:low tooling
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复