Hooks in config.json are not preserved across session starts
- 主要语言
- Shell
- 星标
- 11.2k
- 派生
- 1.9k
- 平均合并
- 14 小时 16 分钟
- 30 天内合并 PR
- 6
描述
## Bug
The `hooks` field in `~/.copilot/config.json` is documented as the location for user-level hooks (`copilot help config` states: "In global config.json these act as user-level hooks").
However, Copilot CLI **overwrites `config.json` on every session start**, dropping any `hooks` key that was previously written there. This makes it impossible for external tools (like [cmux](https://github.com/manaflow-ai/cmux)) to install persistent user-level hooks.
## Steps to Reproduce
1. Install cmux session restore hooks: `cmux hooks copilot install`
2. Verify `~/.copilot/config.json` now contains a `"hooks"` key with SessionStart, SessionEnd, etc.
3. Start a new `copilot` session
4. Check `~/.copilot/config.json` — the `"hooks"` key is gone
## Expected Behavior
The `hooks` field should be preserved when Copilot CLI rewrites `config.json` (e.g., when updating `expAssignmentsCache` or other managed state).
## Additional Context
- Copilot CLI version: 1.0.49
- Hooks in `settings.json` do **not** fire as user-level hooks (despite being a recognized config location)
- The file header says `// User settings belong in settings.json` but `copilot help config` says hooks go in `config.json`
- macOS, cmux latest
## Workaround
Currently none for global user-level hooks. Repo-level hooks (`.github/hooks/*.json`) work but require per-repo setup.
贡献指南
调研方向
首先找到重写 ~/.copilot/config.json 的代码,并使用由 cmux 安装的 hooks 条目重现会话启动行为。当托管状态更新不再移除 hooks 字段时,修复即完成;请按照已记录的复现步骤进行验证。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cli, shell
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 62/100