feat(polecat): add repo path to worktrees for LLM ergonomics (GH#283)
Changes polecat worktree structure from: polecats/<name>/ to: polecats/<name>/<rigname>/ This gives Claude Code agents a recognizable directory name (e.g., tidepool/) in their cwd instead of just the polecat name, preventing confusion about which repo they are working in. Key changes: - Add clonePath() method to manager.go and session_manager.go for the actual git worktree path, keeping polecatDir() for existence checks - Update Add(), RepairWorktree(), Remove() to use new structure - Update daemon lifecycle and restart code for new paths - Update witness handlers to detect both structures - Update doctor checks (rig_check, branch_check, config_check, claude_settings_check) for backward compatibility - All code includes fallback to old structure for existing polecats Fixes #283 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
c8c97fdf64
commit
9b2f4a7652
@@ -96,11 +96,36 @@ func (m *SessionManager) SessionName(polecat string) string {
|
||||
return fmt.Sprintf("gt-%s-%s", m.rig.Name, polecat)
|
||||
}
|
||||
|
||||
// polecatDir returns the working directory for a polecat.
|
||||
// polecatDir returns the parent directory for a polecat.
|
||||
// This is polecats/<name>/ - the polecat's home directory.
|
||||
func (m *SessionManager) polecatDir(polecat string) string {
|
||||
return filepath.Join(m.rig.Path, "polecats", polecat)
|
||||
}
|
||||
|
||||
// clonePath returns the path where the git worktree lives.
|
||||
// New structure: polecats/<name>/<rigname>/ - gives LLMs recognizable repo context.
|
||||
// Falls back to old structure: polecats/<name>/ for backward compatibility.
|
||||
func (m *SessionManager) clonePath(polecat string) string {
|
||||
// New structure: polecats/<name>/<rigname>/
|
||||
newPath := filepath.Join(m.rig.Path, "polecats", polecat, m.rig.Name)
|
||||
if info, err := os.Stat(newPath); err == nil && info.IsDir() {
|
||||
return newPath
|
||||
}
|
||||
|
||||
// Old structure: polecats/<name>/ (backward compat)
|
||||
oldPath := filepath.Join(m.rig.Path, "polecats", polecat)
|
||||
if info, err := os.Stat(oldPath); err == nil && info.IsDir() {
|
||||
// Check if this is actually a git worktree (has .git file or dir)
|
||||
gitPath := filepath.Join(oldPath, ".git")
|
||||
if _, err := os.Stat(gitPath); err == nil {
|
||||
return oldPath
|
||||
}
|
||||
}
|
||||
|
||||
// Default to new structure for new polecats
|
||||
return newPath
|
||||
}
|
||||
|
||||
// hasPolecat checks if the polecat exists in this rig.
|
||||
func (m *SessionManager) hasPolecat(polecat string) bool {
|
||||
polecatPath := m.polecatDir(polecat)
|
||||
@@ -131,7 +156,7 @@ func (m *SessionManager) Start(polecat string, opts SessionStartOptions) error {
|
||||
// Determine working directory
|
||||
workDir := opts.WorkDir
|
||||
if workDir == "" {
|
||||
workDir = m.polecatDir(polecat)
|
||||
workDir = m.clonePath(polecat)
|
||||
}
|
||||
|
||||
runtimeConfig := config.LoadRuntimeConfig(m.rig.Path)
|
||||
|
||||
Reference in New Issue
Block a user