mirror of
https://github.com/imjasonh/cnotes
synced 2026-07-18 23:01:31 +00:00
Scaffold all 7 hook events and eliminate type casting
- Add missing hook handlers: Stop, SubagentStop, PreCompact
- Replace all string type casting with proper JSON unmarshaling
- Change ToolUseRequest.Parameters from map[string]interface{} to json.RawMessage
- Update helper methods to use json.Unmarshal directly to typed structs
- Replace speech notifications with simple logging notifications
- Update documentation to reflect all hook events and remove speech references
- Add comprehensive CLAUDE.md with architecture overview and development guidance
All hooks now use type-safe JSON handling without .(string) assertions.
Complete coverage of Claude Code events: PreToolUse, PostToolUse,
UserPromptSubmit, Notification, Stop, SubagentStop, PreCompact.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c61b579243
commit
45ef980233
10 changed files with 351 additions and 108 deletions
42
internal/handlers/subagentstop.go
Normal file
42
internal/handlers/subagentstop.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/imjasonh/hooks/internal/hooks"
|
||||
)
|
||||
|
||||
func init() {
|
||||
hooks.RegisterHook(hooks.EventSubagentStop, "*", LogSubagentCompletion)
|
||||
}
|
||||
|
||||
// LogSubagentCompletion is triggered when a Claude Code subagent (Task tool call)
|
||||
// finishes responding. Subagents are created when Claude uses the Task tool to
|
||||
// delegate work to another Claude instance.
|
||||
//
|
||||
// Common use cases:
|
||||
// - Track nested workflow completion
|
||||
// - Monitor subagent performance
|
||||
// - Resource cleanup after Task operations
|
||||
// - Debug complex multi-agent workflows
|
||||
// - Collect metrics on task delegation
|
||||
func LogSubagentCompletion(ctx context.Context, input hooks.HookInput) (hooks.HookOutput, error) {
|
||||
slog.Info("Claude subagent completed",
|
||||
"session_id", input.SessionID,
|
||||
"cwd", input.CWD,
|
||||
"transcript_path", input.TranscriptPath,
|
||||
"timestamp", time.Now().Unix())
|
||||
|
||||
// TODO: Future enhancements could include:
|
||||
// - Track subagent hierarchy depth
|
||||
// - Measure subagent execution time
|
||||
// - Collect subagent success/failure rates
|
||||
// - Clean up subagent-specific resources
|
||||
// - Aggregate results from multiple subagents
|
||||
// - Send notifications for long-running subagents
|
||||
// - Export subagent conversation logs
|
||||
|
||||
return hooks.HookOutput{Decision: "approve"}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue