fix: ignore hidden directories when enumerating polecats (#258)
* fix(sling): route bd mol commands to target rig directory * Fix daemon polecat enumeration to ignore hidden dirs * Ignore hidden dirs when discovering rig polecats * Fix CI: enable beads custom types during install --------- Co-authored-by: joshuavial <git@codewithjv.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -439,7 +440,7 @@ func (d *Daemon) ensureRefineriesRunning() {
|
||||
// ensureRefineryRunning ensures the refinery for a specific rig is running.
|
||||
// Discover, don't track: uses Manager.Start() which checks tmux directly (gt-zecmc).
|
||||
func (d *Daemon) ensureRefineryRunning(rigName string) {
|
||||
// Check rig operational state before auto-starting
|
||||
// Check rig operational state before auto-starting
|
||||
if operational, reason := d.isRigOperational(rigName); !operational {
|
||||
d.logger.Printf("Skipping refinery auto-start for %s: %s", rigName, reason)
|
||||
return
|
||||
@@ -697,18 +698,35 @@ func (d *Daemon) checkPolecatSessionHealth() {
|
||||
func (d *Daemon) checkRigPolecatHealth(rigName string) {
|
||||
// Get polecat directories for this rig
|
||||
polecatsDir := filepath.Join(d.config.TownRoot, rigName, "polecats")
|
||||
entries, err := os.ReadDir(polecatsDir)
|
||||
polecats, err := listPolecatWorktrees(polecatsDir)
|
||||
if err != nil {
|
||||
return // No polecats directory - rig might not have polecats
|
||||
}
|
||||
|
||||
for _, polecatName := range polecats {
|
||||
d.checkPolecatHealth(rigName, polecatName)
|
||||
}
|
||||
}
|
||||
|
||||
func listPolecatWorktrees(polecatsDir string) ([]string, error) {
|
||||
entries, err := os.ReadDir(polecatsDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
polecats := make([]string, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
polecatName := entry.Name()
|
||||
d.checkPolecatHealth(rigName, polecatName)
|
||||
name := entry.Name()
|
||||
if strings.HasPrefix(name, ".") {
|
||||
continue
|
||||
}
|
||||
polecats = append(polecats, name)
|
||||
}
|
||||
|
||||
return polecats, nil
|
||||
}
|
||||
|
||||
// checkPolecatHealth checks a single polecat's session health.
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -206,6 +207,33 @@ func TestSaveLoadState_Roundtrip(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestListPolecatWorktrees_SkipsHiddenDirs(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
polecatsDir := filepath.Join(tmpDir, "some-rig", "polecats")
|
||||
|
||||
if err := os.MkdirAll(filepath.Join(polecatsDir, ".claude"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Join(polecatsDir, "furiosa"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(polecatsDir, "not-a-dir.txt"), []byte("x"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
polecats, err := listPolecatWorktrees(polecatsDir)
|
||||
if err != nil {
|
||||
t.Fatalf("listPolecatWorktrees returned error: %v", err)
|
||||
}
|
||||
|
||||
if slices.Contains(polecats, ".claude") {
|
||||
t.Fatalf("expected hidden dir .claude to be ignored, got %v", polecats)
|
||||
}
|
||||
if !slices.Contains(polecats, "furiosa") {
|
||||
t.Fatalf("expected furiosa to be included, got %v", polecats)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: TestIsWitnessSession removed - isWitnessSession function was deleted
|
||||
// as part of ZFC cleanup. Witness poking is now Deacon's responsibility.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user