From 8051c8bdd73838d921cbdd9e710e3a698811c42f Mon Sep 17 00:00:00 2001 From: beads/crew/emma Date: Tue, 13 Jan 2026 13:15:57 -0800 Subject: [PATCH] feat(hook): auto-detect agent in gt hook show When no argument is provided, `gt hook show` now auto-detects the current agent from context using resolveSelfTarget(), matching the behavior of other commands like `gt hook` and `gt mail inbox`. Fixes steveyegge/beads#1078 Co-Authored-By: Claude Opus 4.5 --- internal/cmd/hook.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/internal/cmd/hook.go b/internal/cmd/hook.go index e6d00a2e..20e3d0ab 100644 --- a/internal/cmd/hook.go +++ b/internal/cmd/hook.go @@ -60,10 +60,12 @@ Examples: // hookShowCmd shows hook status in compact one-line format var hookShowCmd = &cobra.Command{ - Use: "show ", + Use: "show [agent]", Short: "Show what's on an agent's hook (compact)", Long: `Show what's on any agent's hook in compact one-line format. +With no argument, shows your own hook status (auto-detected from context). + Use cases: - Mayor checking what polecats are working on - Witness checking polecat status @@ -71,13 +73,14 @@ Use cases: - Quick status overview Examples: + gt hook show # What's on MY hook? (auto-detect) gt hook show gastown/polecats/nux # What's nux working on? gt hook show gastown/witness # What's the witness hooked to? gt hook show mayor # What's the mayor working on? Output format (one line): gastown/polecats/nux: gt-abc123 'Fix the widget bug' [in_progress]`, - Args: cobra.ExactArgs(1), + Args: cobra.MaximumNArgs(1), RunE: runHookShow, } @@ -265,7 +268,17 @@ func checkPinnedBeadComplete(b *beads.Beads, issue *beads.Issue) (isComplete boo // runHookShow displays another agent's hook in compact one-line format. func runHookShow(cmd *cobra.Command, args []string) error { - target := args[0] + var target string + if len(args) > 0 { + target = args[0] + } else { + // Auto-detect current agent from context + agentID, _, _, err := resolveSelfTarget() + if err != nil { + return fmt.Errorf("auto-detecting agent (use explicit argument): %w", err) + } + target = agentID + } // Find beads directory workDir, err := findLocalBeadsDir()