feat: implement agent-notify CLI with hooks and tmux passthrough

Add OSC 777 notification sender, Cursor/Claude hook adapters,
config/install commands, and README for Ghostty + tmux setup.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-26 11:19:34 +08:00
parent f13dcd6cae
commit 5fecb6d215
22 changed files with 2729 additions and 11 deletions
+41
View File
@@ -0,0 +1,41 @@
package hook
import (
"encoding/json"
"io"
"github.com/longbin/agent-notify/internal/config"
"github.com/longbin/agent-notify/internal/context"
"github.com/longbin/agent-notify/internal/notify"
)
type claudePayload struct {
StopHookActive bool `json:"stop_hook_active"`
Message string `json:"message"`
}
type claudeResponse struct {
TerminalSequence string `json:"terminalSequence,omitempty"`
}
func RunClaude(r io.Reader, cfg config.Config, event string, w io.Writer) error {
if !cfg.EventEnabled(event) {
_, err := io.WriteString(w, "{}\n")
return err
}
var payload claudePayload
_ = json.NewDecoder(r).Decode(&payload)
if event == "stop" && payload.StopHookActive {
_, err := io.WriteString(w, "{}\n")
return err
}
meta := context.MetaFromEnv("Claude", event)
title := context.Render(cfg.Notify.TitleTemplate, meta)
body := cfg.BodyForEvent(event)
seq := notify.BuildSequence(cfg.Notify.Protocol, title, body)
resp := claudeResponse{TerminalSequence: seq}
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
return enc.Encode(resp)
}