parseAgentName validates and returns an AgentName from a raw string. Only alphanumeric characters, hyphens, and underscores are allowed.
(s string)
| 23 | // parseAgentName validates and returns an AgentName from a raw string. |
| 24 | // Only alphanumeric characters, hyphens, and underscores are allowed. |
| 25 | func parseAgentName(s string) (AgentName, error) { |
| 26 | if !validAgentName.MatchString(s) { |
| 27 | return "", fmt.Errorf("invalid agent name %q: must match [a-zA-Z0-9_-]+", s) |
| 28 | } |
| 29 | return AgentName(s), nil |
| 30 | } |
| 31 | |
| 32 | // Detect returns the name of the AI coding agent driving the CLI, |
| 33 | // or an empty AgentName if none is detected. |