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>
82 lines
1.9 KiB
Go
82 lines
1.9 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/gastown/internal/style"
|
|
"github.com/steveyegge/gastown/internal/tmux"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(nudgeCmd)
|
|
}
|
|
|
|
var nudgeCmd = &cobra.Command{
|
|
Use: "nudge <rig/polecat> <message>",
|
|
GroupID: GroupComm,
|
|
Short: "Send a message to a polecat session reliably",
|
|
Long: `Sends a message to a polecat's Claude Code session.
|
|
|
|
Uses a reliable delivery pattern:
|
|
1. Sends text in literal mode (-l flag)
|
|
2. Waits 500ms for paste to complete
|
|
3. Sends Enter as a separate command
|
|
|
|
This is the ONLY way to send messages to Claude sessions.
|
|
Do not use raw tmux send-keys elsewhere.
|
|
|
|
Examples:
|
|
gt nudge gastown/furiosa "Check your mail and start working"
|
|
gt nudge gastown/alpha "What's your status?"`,
|
|
Args: cobra.ExactArgs(2),
|
|
RunE: runNudge,
|
|
}
|
|
|
|
func runNudge(cmd *cobra.Command, args []string) error {
|
|
target := args[0]
|
|
message := args[1]
|
|
|
|
t := tmux.NewTmux()
|
|
|
|
// Check if target is rig/polecat format or raw session name
|
|
if strings.Contains(target, "/") {
|
|
// Parse rig/polecat format
|
|
rigName, polecatName, err := parseAddress(target)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
mgr, _, err := getSessionManager(rigName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Get session name and send nudge using the reliable NudgeSession
|
|
sessionName := mgr.SessionName(polecatName)
|
|
if err := t.NudgeSession(sessionName, message); err != nil {
|
|
return fmt.Errorf("nudging session: %w", err)
|
|
}
|
|
|
|
fmt.Printf("%s Nudged %s/%s\n", style.Bold.Render("✓"), rigName, polecatName)
|
|
} else {
|
|
// Raw session name (legacy)
|
|
exists, err := t.HasSession(target)
|
|
if err != nil {
|
|
return fmt.Errorf("checking session: %w", err)
|
|
}
|
|
if !exists {
|
|
return fmt.Errorf("session %q not found", target)
|
|
}
|
|
|
|
if err := t.NudgeSession(target, message); err != nil {
|
|
return fmt.Errorf("nudging session: %w", err)
|
|
}
|
|
|
|
fmt.Printf("✓ Nudged %s\n", target)
|
|
}
|
|
|
|
return nil
|
|
}
|