Skip to content

Feature Request: Add Hooks System for Notifications and Lifecycle Events #1313

@AungMyoKyaw

Description

@AungMyoKyaw

Feature Request: Add Hooks System for Notifications and Lifecycle Events

Problem

Kimi CLI currently lacks a hooks system to notify users when the agent needs attention. When running long tasks (e.g., analyzing large codebases, running builds), users often switch to other windows and miss when Kimi finishes or needs input.

Comparison with Other Tools

Other CLI agents provide hook systems for this use case:

Tool Hooks Support Config Location
Claude Code ✅ Yes ~/.claude/settings.json
Gemini CLI ✅ Yes (Jan 2026) config
Codex CLI ✅ Yes ~/.codex/config.toml
Kimi CLI ❌ No N/A

Claude Code Example

{
  "hooks": {
    "Notification": [
      {
        "matcher": "idle_prompt",
        "hooks": [{
          "type": "command",
          "command": "terminal-notifier -title 'Kimi CLI' -message 'Ready for input'"
        }]
      },
      {
        "matcher": "permission_prompt",
        "hooks": [{
          "type": "command",
          "command": "terminal-notifier -title 'Kimi CLI' -message 'Approval required' -sound default"
        }]
      }
    ]
  }
}

Proposed Solution

Add a hooks system to Kimi CLI supporting:

1. Hook Types

  • NotificationHook: Triggered when agent state changes
  • LifecycleHook: Triggered at specific execution points
  • ToolHook: Triggered before/after tool execution

2. Matchers

  • idle_prompt - Agent finished working, waiting for user input
  • permission_prompt - Agent needs approval to run command/tool
  • turn_complete - Agent finished a turn
  • error - Agent encountered an error
  • start - Agent started processing

3. Configuration

Support in ~/.kimi/config.toml:

[hooks.notification]
enabled = true

[[hooks.notification.matchers]]
event = "idle_prompt"
command = "terminal-notifier -title 'Kimi CLI' -message 'Ready for input'"
sound = "default"

[[hooks.notification.matchers]]
event = "permission_prompt"
command = "terminal-notifier -title 'Kimi CLI' -message 'Approval required' -sound default"

# Or use webhook
[[hooks.notification.matchers]]
event = "turn_complete"
webhook = "https://hooks.slack.com/services/..."

4. Script Hooks

Allow executable scripts in ~/.kimi/hooks/:

~/.kimi/hooks/
├── on-idle.sh
├── on-permission.sh
└── on-complete.sh

Use Cases

  1. macOS Notifications: Desktop alerts when Kimi needs input
  2. Slack/Discord Integration: Team notifications for long-running tasks
  3. Sound Alerts: Audio cues when terminal is not focused
  4. Logging: Audit trail of agent activities
  5. Automation: Trigger CI/CD pipelines when tasks complete

Benefits

  • Reduced Context Switching: Users don't need to constantly check terminal
  • Better Async Workflows: Start long tasks and get notified when done
  • Accessibility: Audio notifications help users with visual impairments
  • Enterprise Integration: Connect Kimi to company notification systems

Workaround (Current)

Currently using shell wrapper and Hammerspoon monitoring as workaround:

# Wrap kimi command to track duration and notify
kimi() {
  local start=$(date +%s)
  command kimi "$@"
  local duration=$(($(date +%s) - start))
  if [[ $duration -gt 10 ]]; then
    terminal-notifier -title "Kimi CLI" -message "Task completed in ${duration}s"
  fi
}

References

Environment

  • Kimi CLI Version: 1.16.0
  • OS: macOS (Apple Silicon)
  • Terminal: Ghostty + tmux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions