fix(rig): Reject rig names with hyphens, dots, or spaces (GHI #23)

Add validation in Manager.AddRig() to reject rig names containing
characters that break agent ID parsing. Agent IDs use format
<prefix>-<rig>-<role>[-<name>] with hyphens as delimiters, so
hyphenated rig names like op-baby cause parsing failures.

The validation rejects hyphens, dots, and spaces, and suggests a
sanitized alternative in the error message.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
capable
2026-01-02 12:15:10 -08:00
committed by Steve Yegge
parent c5ee18c6ab
commit 1f72285a76
2 changed files with 39 additions and 0 deletions

View File

@@ -174,6 +174,13 @@ func (m *Manager) AddRig(opts AddRigOptions) (*Rig, error) {
return nil, ErrRigExists
}
// Validate rig name: reject characters that break agent ID parsing
// Agent IDs use format <prefix>-<rig>-<role>[-<name>] with hyphens as delimiters
if strings.ContainsAny(opts.Name, "-. ") {
sanitized := strings.NewReplacer("-", "", ".", "", " ", "").Replace(opts.Name)
return nil, fmt.Errorf("rig name %q contains invalid characters (hyphens, dots, or spaces break agent ID parsing); use %q instead", opts.Name, sanitized)
}
rigPath := filepath.Join(m.townRoot, opts.Name)
// Check if directory already exists