From 12713257d05e0903a0b6a59d9e626e37a82f5704 Mon Sep 17 00:00:00 2001 From: wonder Date: Fri, 26 Jun 2026 00:15:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20UserPromptSubmit=20?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=20prompt=20=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UserPromptSubmit 不是工具事件,prompt 文本作为顶层 JSON 字段传递, 而非 tool_input.prompt。新增 Prompt 字段到结构体并从 event.Prompt 读取。 --- handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index 8522ab2..402167f 100644 --- a/handler.go +++ b/handler.go @@ -17,6 +17,7 @@ type ClaudeCodeHookEvent struct { ToolInput map[string]interface{} `json:"tool_input,omitempty"` Matcher string `json:"matcher,omitempty"` StopHookActive bool `json:"stop_hook_active,omitempty"` + Prompt string `json:"prompt,omitempty"` // UserPromptSubmit 事件的 prompt 文本 } type HookHandler struct { @@ -139,7 +140,7 @@ func (h *HookHandler) handleUserPromptSubmit(event ClaudeCodeHookEvent) { return } - prompt, _ := event.ToolInput["prompt"].(string) + prompt := event.Prompt if prompt == "" { log.Printf("empty prompt in UserPromptSubmit, session=%s", event.SessionID) return