Hook `ask` decisions show raw JSON instead of diff view
まだ誰も着手していません。
- 主要言語
- Shell
- スター
- 11.2k
- フォーク
- 1.9k
- 平均マージ
- 14時間 16分
- マージ済み PR(30日)
- 6
説明
Describe the bug
Copilot CLI normally shows a rich diff/content view when asking permission to create or edit a file. However, when the ask decision comes from a PreToolUse hook (i.e. the hook returns {"permissionDecision": "ask", "permissionDecisionReason": "..."}) rather than from the default built-in ask-before-write behavior, that rich diff view does not get triggered.
Instead, the "Hook permission request" dialog renders the permissionDecisionReason correctly as readable yellow text, but shows the proposed change as a single JSON line containing the raw tool input (file path plus the entire file content field), hard-wrapped at the current terminal width. For a file write/edit with non-trivial content this becomes a wall of wrapped JSON (quotes, escaped \n, braces, etc.) that is effectively unreadable, instead of the normal diff view Copilot CLI already has and uses elsewhere.
Affected version
$ copilot --version
GitHub Copilot CLI 1.0.70.
Steps to reproduce the behavior
- Configure a
PreToolUsehook script for Copilot CLI (a hook that reads the tool-call JSON from stdin and can return a permission decision). - Have the hook return an
askdecision for a file create/edit tool call, e.g.:{ "permissionDecision": "ask", "permissionDecisionReason": "Human review requested for this file write." } - Trigger a tool call that creates or edits a file with non-trivial (multi-line) content.
- Observe the "Hook permission request" dialog that Copilot CLI shows: compare it to the normal ask-before-write dialog (without a hook forcing
ask), which renders a proper diff/content view for the same kind of file change.
Expected behavior
- The
permissionDecisionReasonshould display as it currently does (readable yellow text) — this part works correctly. - When the
askdecision is produced by a hook for a file create/edit tool, the dialog should render the proposed change using the same rich diff/content view Copilot CLI already uses for its default ask-before-write flow, instead of falling back to a single wrapped line of raw JSON tool input.
Additional context
- OS: Windows 11
- CPU architecture: x86_64
- Terminal: Windows Terminal
- Shell: PowerShell 7 — note that Copilot CLI runs its own tool calls (including file create/edit) via its internal PowerShell invocation regardless of the interactive shell, so this shouldn't affect reproduction
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
複数行ファイルの作成または編集に対して ask 判定を返す PreToolUse フックを通じて問題を再現し、その後 Hook permission request ダイアログをデフォルトの ask-before-write フローと比較します。hook permission request のエントリーポイントと既存の diff/content view を追跡します。完了条件は、フック経路が読みやすい理由を保持し、折り返された raw JSON ではなく同じリッチビューを使用することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- powershell, shell
- 領域
- cli
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 55/100