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
@@ -400,9 +400,23 @@ var createCmd = &cobra.Command{
|
||||
|
||||
// Validate explicit ID format if provided
|
||||
if explicitID != "" {
|
||||
requestedPrefix, err := validation.ValidateIDFormat(explicitID)
|
||||
if err != nil {
|
||||
FatalError("%v", err)
|
||||
var requestedPrefix string
|
||||
var err error
|
||||
|
||||
// For agent types, use agent-aware prefix extraction.
|
||||
// This fixes the bug where 3-char polecat names like "nux" in
|
||||
// "nx-nexus-polecat-nux" were incorrectly treated as hash suffixes,
|
||||
// causing prefix to be extracted as "nx-nexus-polecat" instead of "nx".
|
||||
if issueType == "agent" {
|
||||
if err := validation.ValidateAgentID(explicitID); err != nil {
|
||||
FatalError("invalid agent ID: %v", err)
|
||||
}
|
||||
requestedPrefix = validation.ExtractAgentPrefix(explicitID)
|
||||
} else {
|
||||
requestedPrefix, err = validation.ValidateIDFormat(explicitID)
|
||||
if err != nil {
|
||||
FatalError("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Validate prefix matches database prefix
|
||||
@@ -431,13 +445,6 @@ var createCmd = &cobra.Command{
|
||||
if err := validation.ValidatePrefixWithAllowed(requestedPrefix, dbPrefix, allowedPrefixes, forceCreate); err != nil {
|
||||
FatalError("%v", err)
|
||||
}
|
||||
|
||||
// Validate agent ID pattern if type is agent
|
||||
if issueType == "agent" {
|
||||
if err := validation.ValidateAgentID(explicitID); err != nil {
|
||||
FatalError("invalid agent ID: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var externalRefPtr *string
|
||||
|
||||
Reference in New Issue
Block a user