github / github/copilot-cli

preToolUse: silent command rewrite via updatedInput — confirmation dialog appears even with permissionDecision: allow

未關閉
#2,643 12 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
area:plugins
主要語言
Shell
星號
11.2k
分支
1.9k
平均合併
14 小時 16 分鐘
30 天內合併 PR
6

描述

## Summary

When a `preToolUse` hook rewrites a command using `updatedInput` with `permissionDecision: allow`, Copilot CLI v1.0.24 still shows an interactive confirmation dialog to the user on **every** rewritten command. There is currently no way for a hook to silently rewrite a command.

## Environment

- Copilot CLI version: `1.0.24`
- OS: Linux

## Context

Consider a tool that automatically prepends a proxy prefix to dev commands (e.g. `git status` → `proxy git status`) to reduce LLM token consumption. Users install a `preToolUse` hook so the agent's commands are transparently rewritten without friction.

Before v1.0.24, `updatedInput` was not supported in Copilot CLI ([#2013](https://github.com/github/copilot-cli/issues/2013)), so the hook used deny-with-suggestion as a workaround. When v1.0.24 shipped `updatedInput` support, the hook was upgraded to use `updatedInput` + `permissionDecision: allow`.

## What I expected

A hook returning:

```json
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"permissionDecisionReason": "proxy auto-rewrite",
"updatedInput": {
"command": "proxy git status",
"description": "check repo status"
}
}
}
```

should silently rewrite the command and run it — no confirmation needed, since:
1. The user explicitly installed the hook (opt-in)
2. `permissionDecision` is `allow`
3. The rewrite is mechanical (just prepending a proxy prefix)

## What happened instead

Copilot CLI shows a confirmation dialog on **every** rewritten command:

```
╭─────────────────────────────────────────────────────╮
│ Hook permission request │
│ ⚠ proxy auto-rewrite │
│ │
│ Tool: bash │
│ Args: {"command": "proxy git status", ...} │
│ │
│ Do you want to allow this tool call? │
╰─────────────────────────────────────────────────────╯
```

This dialog appears for **every single command** the agent runs that gets rewritten — making the hook more disruptive than the old deny-with-suggestion workaround.

## Proposed solution

Add a way for hooks to indicate a rewrite should be applied silently. Options:

**Option A** — `permissionDecision: allow` should suppress the dialog (most intuitive):
> If the hook already decided `allow`, no confirmation should be needed.

**Option B** — New field `showConfirmation: false`:
```json
{
"hookSpecificOutput": {
"permissionDecision": "allow",
"updatedInput": { ... },
"showConfirmation": false
}
}
```

**Option C** — New `permissionDecision` value `"silent-allow"` or `"allow-silent"`

Option A seems most consistent with the existing semantics — `allow` already means the hook approved it.

## Impact

Without silent rewrite, `updatedInput` is not practical for high-frequency mechanical rewrites (like token optimization proxies). The old deny-with-suggestion workaround was less disruptive because denials are handled gracefully by the agent without surfacing a modal to the user.

cc @MRayermannMSFT (from #2013)

貢獻指南

開啟貢獻指南

研究方向

首先,在 Copilot CLI v1.0.24 上使用 updatedInput 和 permissionDecision: allow 重現 preToolUse hook 的行為。比較權限對話框流程與 hook 要求的決策;當重寫後的命令無需確認對話框即可執行,同時保留 hook 更新後的輸入時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
shell
領域
cli
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。