feat(crew): add --debug flag to crew at command
Add --debug flag for troubleshooting crew attach issues. Shows: - Current working directory - Detected rig and crew name - Computed session ID - Whether inside tmux - Which session we are attaching to Also adds Attaching to session message before attach. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@ var (
|
|||||||
crewAll bool
|
crewAll bool
|
||||||
crewListAll bool
|
crewListAll bool
|
||||||
crewDryRun bool
|
crewDryRun bool
|
||||||
|
crewDebug bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var crewCmd = &cobra.Command{
|
var crewCmd = &cobra.Command{
|
||||||
@@ -333,6 +334,7 @@ func init() {
|
|||||||
crewAtCmd.Flags().BoolVarP(&crewDetached, "detached", "d", false, "Start session without attaching")
|
crewAtCmd.Flags().BoolVarP(&crewDetached, "detached", "d", false, "Start session without attaching")
|
||||||
crewAtCmd.Flags().StringVar(&crewAccount, "account", "", "Claude Code account handle to use (overrides default)")
|
crewAtCmd.Flags().StringVar(&crewAccount, "account", "", "Claude Code account handle to use (overrides default)")
|
||||||
crewAtCmd.Flags().StringVar(&crewAgentOverride, "agent", "", "Agent alias to run crew worker with (overrides rig/town default)")
|
crewAtCmd.Flags().StringVar(&crewAgentOverride, "agent", "", "Agent alias to run crew worker with (overrides rig/town default)")
|
||||||
|
crewAtCmd.Flags().BoolVar(&crewDebug, "debug", false, "Show debug output for troubleshooting")
|
||||||
|
|
||||||
crewRemoveCmd.Flags().StringVar(&crewRig, "rig", "", "Rig to use")
|
crewRemoveCmd.Flags().StringVar(&crewRig, "rig", "", "Rig to use")
|
||||||
crewRemoveCmd.Flags().BoolVar(&crewForce, "force", false, "Force remove (skip safety checks)")
|
crewRemoveCmd.Flags().BoolVar(&crewForce, "force", false, "Force remove (skip safety checks)")
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/steveyegge/gastown/internal/beads"
|
"github.com/steveyegge/gastown/internal/beads"
|
||||||
@@ -18,6 +19,13 @@ import (
|
|||||||
func runCrewAt(cmd *cobra.Command, args []string) error {
|
func runCrewAt(cmd *cobra.Command, args []string) error {
|
||||||
var name string
|
var name string
|
||||||
|
|
||||||
|
// Debug mode: --debug flag or GT_DEBUG env var
|
||||||
|
debug := crewDebug || os.Getenv("GT_DEBUG") != ""
|
||||||
|
if debug {
|
||||||
|
cwd, _ := os.Getwd()
|
||||||
|
fmt.Printf("[DEBUG] runCrewAt: args=%v, crewRig=%q, cwd=%q\n", args, crewRig, cwd)
|
||||||
|
}
|
||||||
|
|
||||||
// Determine crew name: from arg, or auto-detect from cwd
|
// Determine crew name: from arg, or auto-detect from cwd
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
name = args[0]
|
name = args[0]
|
||||||
@@ -53,6 +61,10 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Printf("Detected crew workspace: %s/%s\n", detected.rigName, name)
|
fmt.Printf("Detected crew workspace: %s/%s\n", detected.rigName, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if debug {
|
||||||
|
fmt.Printf("[DEBUG] after detection: name=%q, crewRig=%q\n", name, crewRig)
|
||||||
|
}
|
||||||
|
|
||||||
crewMgr, r, err := getCrewManager(crewRig)
|
crewMgr, r, err := getCrewManager(crewRig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -96,10 +108,16 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
|
|||||||
// Check if session exists
|
// Check if session exists
|
||||||
t := tmux.NewTmux()
|
t := tmux.NewTmux()
|
||||||
sessionID := crewSessionName(r.Name, name)
|
sessionID := crewSessionName(r.Name, name)
|
||||||
|
if debug {
|
||||||
|
fmt.Printf("[DEBUG] sessionID=%q (r.Name=%q, name=%q)\n", sessionID, r.Name, name)
|
||||||
|
}
|
||||||
hasSession, err := t.HasSession(sessionID)
|
hasSession, err := t.HasSession(sessionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("checking session: %w", err)
|
return fmt.Errorf("checking session: %w", err)
|
||||||
}
|
}
|
||||||
|
if debug {
|
||||||
|
fmt.Printf("[DEBUG] hasSession=%v\n", hasSession)
|
||||||
|
}
|
||||||
|
|
||||||
// Before creating a new session, check if there's already a runtime session
|
// Before creating a new session, check if there's already a runtime session
|
||||||
// running in this crew's directory (might have been started manually or via
|
// running in this crew's directory (might have been started manually or via
|
||||||
@@ -258,8 +276,12 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If inside tmux (but different session), don't switch - just inform user
|
// If inside tmux (but different session), don't switch - just inform user
|
||||||
if tmux.IsInsideTmux() {
|
insideTmux := tmux.IsInsideTmux()
|
||||||
fmt.Printf("Started %s/%s. Use C-b s to switch.\n", r.Name, name)
|
if debug {
|
||||||
|
fmt.Printf("[DEBUG] tmux.IsInsideTmux()=%v\n", insideTmux)
|
||||||
|
}
|
||||||
|
if insideTmux {
|
||||||
|
fmt.Printf("Session %s ready. Use C-b s to switch.\n", sessionID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,6 +291,10 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach to session
|
// Attach to session - show which session we're attaching to
|
||||||
|
fmt.Printf("Attaching to %s...\n", sessionID)
|
||||||
|
if debug {
|
||||||
|
fmt.Printf("[DEBUG] calling attachToTmuxSession(%q)\n", sessionID)
|
||||||
|
}
|
||||||
return attachToTmuxSession(sessionID)
|
return attachToTmuxSession(sessionID)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user