Files
gastown/internal/cmd/peek.go
Steve Yegge f86a73c2f0 feat: Add gcloud-style command grouping to gt help output
Organize 43 commands into 7 logical groups using cobra's built-in
AddGroup/GroupID feature:

- Work Management: spawn, sling, hook, handoff, done, mol, mq, etc.
- Agent Management: mayor, witness, refinery, deacon, polecat, etc.
- Communication: mail, nudge, broadcast, peek
- Services: daemon, start, stop, up, down, shutdown
- Workspace: rig, crew, init, install, git-init, namepool
- Configuration: account, theme, hooks, issue, completion
- Diagnostics: status, doctor, prime, version, help

Also renamed molecule to mol as the primary command name
(molecule is now an alias).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 02:32:01 -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 gastown/furiosa # Last 100 lines (default)
gt peek gastown/furiosa 50 # Last 50 lines
gt peek gastown/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
}