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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user