From 1b20e1bd2c18b5443cb46b7102650a09476b8f49 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Mon, 29 Dec 2025 14:51:26 -0800 Subject: [PATCH] feat: Auto-detect crew name in gt crew start from cwd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When run from inside a crew directory like gastown/crew/joe, the command now auto-detects the crew workspace name instead of requiring it as an argument. This matches the existing behavior of 'gt crew at'. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/crew.go | 12 +++++++++--- internal/cmd/crew_lifecycle.go | 29 ++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/internal/cmd/crew.go b/internal/cmd/crew.go index 1f9c62ec..b4817868 100644 --- a/internal/cmd/crew.go +++ b/internal/cmd/crew.go @@ -233,7 +233,7 @@ var crewPrevCmd = &cobra.Command{ } var crewStartCmd = &cobra.Command{ - Use: "start ", + Use: "start [name]", Short: "Start a crew workspace (creates if needed)", Long: `Start a crew workspace, creating it if it doesn't exist. @@ -243,11 +243,17 @@ The crew session starts in the background with Claude running and ready. The name can include the rig in slash format (e.g., gastown/joe). If not specified, the rig is inferred from the current directory. +Role Discovery: + If no name is provided, attempts to detect the crew workspace from the + current directory. If you're in /crew//, it will start that + workspace automatically. + Examples: gt crew start joe # Start joe in current rig gt crew start gastown/joe # Start joe in gastown rig - gt crew start joe --rig beads # Start joe in beads rig`, - Args: cobra.ExactArgs(1), + gt crew start joe --rig beads # Start joe in beads rig + gt crew start # Auto-detect from cwd`, + Args: cobra.MaximumNArgs(1), RunE: runCrewStart, } diff --git a/internal/cmd/crew_lifecycle.go b/internal/cmd/crew_lifecycle.go index 27fd2c3f..96f1b33f 100644 --- a/internal/cmd/crew_lifecycle.go +++ b/internal/cmd/crew_lifecycle.go @@ -158,16 +158,31 @@ func runCrewRefresh(cmd *cobra.Command, args []string) error { } // runCrewStart is an alias for runStartCrew, handling multiple input formats. -// It supports: "name", "rig/name", and "rig/crew/name" formats. +// It supports: "name", "rig/name", "rig/crew/name" formats, or auto-detection from cwd. func runCrewStart(cmd *cobra.Command, args []string) error { - name := args[0] + var name string - // Handle rig/crew/name format (e.g., "gastown/crew/joe" -> "gastown/joe") - if strings.Contains(name, "/crew/") { - parts := strings.SplitN(name, "/crew/", 2) - if len(parts) == 2 && parts[0] != "" && parts[1] != "" { - name = parts[0] + "/" + parts[1] + // Determine crew name: from arg, or auto-detect from cwd + if len(args) > 0 { + name = args[0] + // Handle rig/crew/name format (e.g., "gastown/crew/joe" -> "gastown/joe") + if strings.Contains(name, "/crew/") { + parts := strings.SplitN(name, "/crew/", 2) + if len(parts) == 2 && parts[0] != "" && parts[1] != "" { + name = parts[0] + "/" + parts[1] + } } + } else { + // Try to detect from current directory + detected, err := detectCrewFromCwd() + if err != nil { + return fmt.Errorf("could not detect crew workspace from current directory: %w\n\nUsage: gt crew start ", err) + } + name = detected.crewName + if crewRig == "" { + crewRig = detected.rigName + } + fmt.Printf("Detected crew workspace: %s/%s\n", detected.rigName, name) } // Set the start.go flags from crew.go flags before calling