MoonshotAI / MoonshotAI/kimi-cli

Notification hook with matcher=permission_prompt never triggers

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

Nobody has claimed this yet.

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

Description

Bug Description

The Notification hook with matcher = "permission_prompt" never triggers, even though the documentation explicitly lists this as an example use case.

Configuration Example

[[hooks]]
event = "Notification"
matcher = "permission_prompt"
command = 'powershell.exe -ExecutionPolicy Bypass -File "C:\Users\zhuzh\.kimi\hooks\windows-toast.ps1" -EventType Permission'
timeout = 10

Root Cause Analysis

  1. Where Notification hooks are triggered: src/kimi_cli/soul/kimisoul.py:877-896, inside the deliver_pending("llm") callback. The matcher_value is view.event.type (the notification's type field).

  2. Where NotificationEvents are currently created: Only in src/kimi_cli/background/manager.py:525, with type = f"task.{terminal_reason}" (e.g. task.completed, task.failed).

  3. Where approval/permission requests live: The ApprovalRuntime in src/kimi_cli/approval_runtime/runtime.py handles permission prompts completely independently from the NotificationManager. It never publishes a NotificationEvent.

  4. Documentation inconsistency: Both docs/zh/customization/hooks.md:59-63 and docs/en/customization/hooks.md:59-63 document matcher = "permission_prompt" as a working example, but the code has no implementation for it.

Suggested Fix

Bind NotificationManager to ApprovalRuntime (e.g. in Runtime.__post_init__), and publish a NotificationEvent inside ApprovalRuntime.create_request() with:

  • category="system"
  • type="permission_prompt"
  • source_kind="approval"
  • targets=["llm", "wire", "shell"]

This would allow the existing Notification hook pipeline to catch permission prompts and run user-configured commands (e.g. desktop toast notifications).

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

Read the Notification hook path in src/kimi_cli/soul/kimisoul.py:877-896, event creation in src/kimi_cli/background/manager.py:525, and approval handling in src/kimi_cli/approval_runtime/runtime.py. Trace Runtime.post_init and ApprovalRuntime.create_request(), then compare the documented examples in docs/en/customization/hooks.md and docs/zh/customization/hooks.md. Done means permission prompts publish a permission_prompt NotificationEvent that the existing matcher and hook pipeline can receive.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, python
Domain
authorization, cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.