fix(create): use agent-aware prefix extraction for agent beads
The generic ValidateIDFormat() used isLikelyHash() which treated 3-character suffixes like "nux" as valid hashes, causing agent IDs like "nx-nexus-polecat-nux" to extract prefix as "nx-nexus-polecat" instead of the correct "nx". Fix: For --type=agent, validate agent ID format first and use ExtractAgentPrefix() which correctly extracts prefix from the first hyphen for agent IDs. Fixes #591 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
gastown/crew/dennis
parent
2c00d6d203
commit
87f84c5fa6
@@ -170,6 +170,22 @@ func isNamedRole(s string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ExtractAgentPrefix extracts the prefix from an agent ID.
|
||||
// Agent IDs have the format: prefix-rig-role-name or prefix-role
|
||||
// The prefix is always the part before the first hyphen.
|
||||
// Examples:
|
||||
// - "gt-gastown-polecat-nux" -> "gt"
|
||||
// - "nx-nexus-polecat-nux" -> "nx"
|
||||
// - "gt-mayor" -> "gt"
|
||||
// - "bd-beads-witness" -> "bd"
|
||||
func ExtractAgentPrefix(id string) string {
|
||||
hyphenIdx := strings.Index(id, "-")
|
||||
if hyphenIdx <= 0 {
|
||||
return ""
|
||||
}
|
||||
return id[:hyphenIdx]
|
||||
}
|
||||
|
||||
// ValidateAgentID validates that an agent ID follows the expected pattern.
|
||||
// Canonical format: prefix-rig-role-name
|
||||
// Patterns:
|
||||
|
||||
Reference in New Issue
Block a user