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 <noreply@anthropic.com>
This commit is contained in:
@@ -60,10 +60,12 @@ Examples:
|
|||||||
|
|
||||||
// hookShowCmd shows hook status in compact one-line format
|
// hookShowCmd shows hook status in compact one-line format
|
||||||
var hookShowCmd = &cobra.Command{
|
var hookShowCmd = &cobra.Command{
|
||||||
Use: "show <agent>",
|
Use: "show [agent]",
|
||||||
Short: "Show what's on an agent's hook (compact)",
|
Short: "Show what's on an agent's hook (compact)",
|
||||||
Long: `Show what's on any agent's hook in compact one-line format.
|
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:
|
Use cases:
|
||||||
- Mayor checking what polecats are working on
|
- Mayor checking what polecats are working on
|
||||||
- Witness checking polecat status
|
- Witness checking polecat status
|
||||||
@@ -71,13 +73,14 @@ Use cases:
|
|||||||
- Quick status overview
|
- Quick status overview
|
||||||
|
|
||||||
Examples:
|
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/polecats/nux # What's nux working on?
|
||||||
gt hook show gastown/witness # What's the witness hooked to?
|
gt hook show gastown/witness # What's the witness hooked to?
|
||||||
gt hook show mayor # What's the mayor working on?
|
gt hook show mayor # What's the mayor working on?
|
||||||
|
|
||||||
Output format (one line):
|
Output format (one line):
|
||||||
gastown/polecats/nux: gt-abc123 'Fix the widget bug' [in_progress]`,
|
gastown/polecats/nux: gt-abc123 'Fix the widget bug' [in_progress]`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
RunE: runHookShow,
|
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.
|
// runHookShow displays another agent's hook in compact one-line format.
|
||||||
func runHookShow(cmd *cobra.Command, args []string) error {
|
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
|
// Find beads directory
|
||||||
workDir, err := findLocalBeadsDir()
|
workDir, err := findLocalBeadsDir()
|
||||||
|
|||||||
Reference in New Issue
Block a user