MoonshotAI / MoonshotAI/kimi-cli

Approval prompts should trigger a hook event

Open
#2,337 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
11.4k
Forks
1.3k
Avg merge
9h 47m
Merged PRs (30d)
2

Description

What feature would you like to see?

Feature Request: Approval prompts should trigger a hook event

What version of Kimi Code CLI is running?

kimi, version 1.12.0

Which open platform/subscription were you using?

Kimi For Coding

What platform is your computer?

macOS 15.4 (Darwin 24.4.0 arm64)

What issue are you seeing?

When the CLI shows an approval prompt (e.g., "Approve / Reject / Approve for session" before executing a Shell command), no hook event is fired. This makes it impossible to configure audio reminders or other automations for approval prompts via ~/.kimi/config.toml hooks.

Current behavior

The approval prompt modal is rendered internally by the UI layer (_activate_prompt_approval_modal) and does not trigger any of the existing hook events (PreToolUse, Notification, etc.).

I have verified this by checking all 13 supported hook events:

  • PreToolUse is fired before the approval prompt appears, with matcher_value set to the tool name (e.g., Shell), not the approval itself.
  • Notification is not fired for approval prompts (the permission_prompt matcher never matches).
  • No other event covers this interaction.
Expected behavior

Approval prompts should expose a hook event so users can configure reactions (e.g., play a sound, send a system notification) when human confirmation is required.

Suggested implementation

Option A: Re-use PreToolUse with a special matcher_value (e.g., approval:Shell) when an approval is pending.

Option B: Fire a new dedicated event, e.g.:

[[hooks]]
event = "ApprovalPrompt"
command = "osascript -e 'beep'"
matcher = "Shell|WriteFile|StrReplaceFile"
timeout = 5

Option C: Re-use Notification with type = "permission_prompt" so the existing Notification + matcher = "permission_prompt" configuration actually works.

Use case

I rely on audio hooks (play-sound.sh) to alert me when the CLI needs attention. Currently:

  • AskUserQuestion triggers PreToolUse → I hear "选项" ✅
  • Approval prompts are silent → I miss them if I look away from the terminal ❌

This is especially problematic during long-running tasks where I step away from the keyboard.

Additional information

My current hooks config:

[[hooks]]
event = "PreToolUse"
command = "bash /Users/sen/.kimi/hooks/play-sound.sh"
matcher = "AskUserQuestion"
timeout = 10

[[hooks]]
event = "Notification"
command = "bash /Users/sen/.kimi/hooks/play-sound.sh"
matcher = "permission_prompt"
timeout = 10

The Notification + permission_prompt hook was my attempt to cover approval prompts, but it never triggers because approval prompts do not emit Notification events with type = "permission_prompt".

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the UI layer's _activate_prompt_approval_modal and trace how the existing hook events are dispatched and matched from ~/.kimi/config.toml. Resolve whether approval prompts should reuse PreToolUse or Notification, or introduce a new event, then verify that a configured hook runs when an approval prompt appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.