Files
gastown/internal/cmd/peek.go
Steve Yegge 91fa5e63dc Replace 'gastown' with 'greenplace' in user-facing docs/examples
Using "greenplace" (The Green Place from Mad Max: Fury Road) as the
canonical example project/rig name in documentation and help text.
This provides a clearer distinction from the actual gastown repo name.

Changes:
- docs/*.md: Updated all example paths and commands
- internal/cmd/*.go: Updated help text examples
- internal/templates/: Updated example references
- Tests: Updated to use greenplace in example session names

Note: Import paths (github.com/steveyegge/gastown) and actual code
paths referencing the gastown repo structure are unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 18:03:06 -08:00

70 lines
1.6 KiB
Go

package cmd
import (
"fmt"
"strconv"
"github.com/spf13/cobra"
)
// Peek command flags
var peekLines int
func init() {
rootCmd.AddCommand(peekCmd)
peekCmd.Flags().IntVarP(&peekLines, "lines", "n", 100, "Number of lines to capture")
}
var peekCmd = &cobra.Command{
Use: "peek <rig/polecat> [count]",
GroupID: GroupComm,
Short: "View recent output from a polecat session",
Long: `Capture and display recent terminal output from a polecat session.
This is the ergonomic alias for 'gt session capture'. Use it to check
what an agent is currently doing or has recently output.
The nudge/peek pair provides the canonical interface for agent sessions:
gt nudge - send messages TO a session (reliable delivery)
gt peek - read output FROM a session (capture-pane wrapper)
Examples:
gt peek greenplace/furiosa # Last 100 lines (default)
gt peek greenplace/furiosa 50 # Last 50 lines
gt peek greenplace/furiosa -n 200 # Last 200 lines`,
Args: cobra.RangeArgs(1, 2),
RunE: runPeek,
}
func runPeek(cmd *cobra.Command, args []string) error {
address := args[0]
// Handle optional positional count argument
lines := peekLines
if len(args) > 1 {
n, err := strconv.Atoi(args[1])
if err != nil {
return fmt.Errorf("invalid line count: %s", args[1])
}
lines = n
}
rigName, polecatName, err := parseAddress(address)
if err != nil {
return err
}
mgr, _, err := getSessionManager(rigName)
if err != nil {
return err
}
output, err := mgr.Capture(polecatName, lines)
if err != nil {
return fmt.Errorf("capturing output: %w", err)
}
fmt.Print(output)
return nil
}