feat: Auto-detect crew name in gt crew start from cwd

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 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-29 14:51:26 -08:00
parent 3c6019ae73
commit 1b20e1bd2c
2 changed files with 31 additions and 10 deletions

View File

@@ -233,7 +233,7 @@ var crewPrevCmd = &cobra.Command{
}
var crewStartCmd = &cobra.Command{
Use: "start <name>",
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 <rig>/crew/<name>/, 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,
}

View File

@@ -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 <name>", 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