From c7e1451ce6581337272a5dada83fd73994c7785e Mon Sep 17 00:00:00 2001 From: gastown/crew/dennis Date: Fri, 16 Jan 2026 15:26:22 -0800 Subject: [PATCH] fix(polecat): ignore .beads/ files when detecting uncommitted work Add CleanExcludingBeads() method that returns true if the only uncommitted changes are .beads/ database files. These files are synced across worktrees and shouldn't block polecat cleanup. Fixes #516 Co-Authored-By: Claude Opus 4.5 --- internal/git/git.go | 31 +++++++++++++++++++++++++++++++ internal/polecat/manager.go | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/internal/git/git.go b/internal/git/git.go index 4fb0eac5..da59ce94 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -973,6 +973,37 @@ func (s *UncommittedWorkStatus) Clean() bool { return !s.HasUncommittedChanges && s.StashCount == 0 && s.UnpushedCommits == 0 } +// CleanExcludingBeads returns true if the only uncommitted changes are .beads/ files. +// This is useful for polecat stale detection where beads database files are synced +// across worktrees and shouldn't block cleanup. +func (s *UncommittedWorkStatus) CleanExcludingBeads() bool { + // Stashes and unpushed commits always count as uncommitted work + if s.StashCount > 0 || s.UnpushedCommits > 0 { + return false + } + + // Check if all modified files are beads files + for _, f := range s.ModifiedFiles { + if !isBeadsPath(f) { + return false + } + } + + // Check if all untracked files are beads files + for _, f := range s.UntrackedFiles { + if !isBeadsPath(f) { + return false + } + } + + return true +} + +// isBeadsPath returns true if the path is a .beads/ file. +func isBeadsPath(path string) bool { + return strings.Contains(path, ".beads/") || strings.Contains(path, ".beads\\") +} + // String returns a human-readable summary of uncommitted work. func (s *UncommittedWorkStatus) String() string { var issues []string diff --git a/internal/polecat/manager.go b/internal/polecat/manager.go index ed54557a..a761845e 100644 --- a/internal/polecat/manager.go +++ b/internal/polecat/manager.go @@ -1021,9 +1021,9 @@ func (m *Manager) DetectStalePolecats(threshold int) ([]*StalenessInfo, error) { polecatGit := git.NewGit(p.ClonePath) info.CommitsBehind = countCommitsBehind(polecatGit, defaultBranch) - // Check for uncommitted work + // Check for uncommitted work (excluding .beads/ files which are synced across worktrees) status, err := polecatGit.CheckUncommittedWork() - if err == nil && !status.Clean() { + if err == nil && !status.CleanExcludingBeads() { info.HasUncommittedWork = true }