From 67c952290a544838dbb4184a968312a00f815362 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 19 Dec 2025 00:28:21 -0800 Subject: [PATCH] feat(session): add positional line count to capture command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'gt session capture rig/polecat 50' now works in addition to 'gt session capture rig/polecat -n 50'. Agent UX: commands should work the way agents guess they work. Closes: gt-d7i 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/session.go | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/internal/cmd/session.go b/internal/cmd/session.go index 5b272bfd..e9a15ac3 100644 --- a/internal/cmd/session.go +++ b/internal/cmd/session.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "strings" "github.com/spf13/cobra" @@ -85,12 +86,17 @@ Shows session status, rig, and polecat name. Use --rig to filter by rig.`, } var sessionCaptureCmd = &cobra.Command{ - Use: "capture /", + Use: "capture / [count]", Short: "Capture recent session output", Long: `Capture recent output from a polecat session. -Returns the last N lines of terminal output. Useful for checking progress.`, - Args: cobra.ExactArgs(1), +Returns the last N lines of terminal output. Useful for checking progress. + +Examples: + gt session capture wyvern/Toast # Last 100 lines (default) + gt session capture wyvern/Toast 50 # Last 50 lines + gt session capture wyvern/Toast -n 50 # Same as above`, + Args: cobra.RangeArgs(1, 2), RunE: runSessionCapture, } @@ -352,7 +358,20 @@ func runSessionCapture(cmd *cobra.Command, args []string) error { return err } - output, err := mgr.Capture(polecatName, sessionLines) + // Use positional count if provided, otherwise use flag value + lines := sessionLines + if len(args) > 1 { + n, err := strconv.Atoi(args[1]) + if err != nil { + return fmt.Errorf("invalid line count '%s': must be a number", args[1]) + } + if n <= 0 { + return fmt.Errorf("line count must be positive, got %d", n) + } + lines = n + } + + output, err := mgr.Capture(polecatName, lines) if err != nil { return fmt.Errorf("capturing output: %w", err) }