mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-14 03:30:26 +00:00
23c16bb197
Phase 2+3 extension API additions:
- Tool management: GetAllTools, SetActiveTools (plan-mode support)
- Model management: SetModel, GetAvailableModels, ModelChangedEvent
- Extension options: RegisterOption, GetOption, SetOption (env/config/default)
- Inter-extension event bus: OnCustomEvent, EmitCustomEvent
- Direct LLM completion: ctx.Complete with streaming/blocking modes
- Steer delivery mode: CancelAndSend for interrupt-and-redirect
New example extensions (10):
- plan-mode.go: read-only exploration with /plan toggle
- summarize.go: conversation summarization via ctx.Complete
- bookmark.go: persistent bookmarks via AppendEntry/GetEntries
- auto-commit.go: auto-commit on exit using last assistant message
- permission-gate.go: confirm dangerous bash commands
- protected-paths.go: block writes to .env, .git/, secrets/
- notify.go: desktop notifications on agent completion
- inline-bash.go: !{cmd} expansion in prompts
- pirate.go: system prompt persona injection
- project-rules.go: load .kit/rules/*.md into system prompt
Always-wrap tools through runner for SetActiveTools disabled-tool checking.
Removed phase1/phase2 test extensions from examples.
36 lines
953 B
Go
36 lines
953 B
Go
//go:build ignore
|
|
|
|
package main
|
|
|
|
import (
|
|
"os/exec"
|
|
"runtime"
|
|
|
|
"kit/ext"
|
|
)
|
|
|
|
// Init sends a desktop notification when the agent finishes responding.
|
|
// Useful for long-running tasks — get notified without watching the terminal.
|
|
// Inspired by Pi's notify.ts.
|
|
//
|
|
// Supports: Linux (notify-send), macOS (osascript).
|
|
//
|
|
// Usage: kit -e examples/extensions/notify.go
|
|
func Init(api ext.API) {
|
|
api.OnAgentEnd(func(_ ext.AgentEndEvent, ctx ext.Context) {
|
|
sendNotification("Kit", "Agent finished responding")
|
|
})
|
|
}
|
|
|
|
func sendNotification(title, body string) {
|
|
switch runtime.GOOS {
|
|
case "linux":
|
|
// Uses notify-send (libnotify) — available on most Linux desktops.
|
|
_ = exec.Command("notify-send", "-a", "Kit", title, body).Start()
|
|
case "darwin":
|
|
// Uses macOS built-in osascript for native notifications.
|
|
script := `display notification "` + body + `" with title "` + title + `"`
|
|
_ = exec.Command("osascript", "-e", script).Start()
|
|
}
|
|
}
|