fix: ensure gitignore patterns on role creation

Add EnsureGitignorePatterns to rig package that ensures .gitignore
has required Gas Town patterns (.runtime/, .claude/, .beads/, .logs/).

Called from crew and polecat managers when creating new workers.
This prevents runtime-gitignore warnings from gt doctor.

The function:
- Creates .gitignore if it doesn't exist
- Appends missing patterns to existing files
- Recognizes pattern variants (.runtime vs .runtime/)
- Adds "# Gas Town" header when appending

Includes comprehensive tests for all scenarios.
This commit is contained in:
Dustin Smith
2026-01-18 17:08:19 +07:00
committed by Steve Yegge
parent 05ea767149
commit 2aadb0165b
4 changed files with 277 additions and 0 deletions

View File

@@ -188,6 +188,12 @@ func (m *Manager) Add(name string, createBranch bool) (*CrewWorker, error) {
fmt.Printf("Warning: could not copy overlay files: %v\n", err)
}
// Ensure .gitignore has required Gas Town patterns
if err := rig.EnsureGitignorePatterns(crewPath); err != nil {
// Non-fatal - log warning but continue
fmt.Printf("Warning: could not update .gitignore: %v\n", err)
}
// NOTE: Slash commands (.claude/commands/) are provisioned at town level by gt install.
// All agents inherit them via Claude's directory traversal - no per-workspace copies needed.
@@ -581,3 +587,4 @@ func (m *Manager) IsRunning(name string) (bool, error) {
sessionID := m.SessionName(name)
return t.HasSession(sessionID)
}