parseAgentName validates and returns an AgentName from a raw string. Only alphanumeric characters, hyphens, and underscores are allowed.
(s string)
| 33 | // parseAgentName validates and returns an AgentName from a raw string. |
| 34 | // Only alphanumeric characters, hyphens, and underscores are allowed. |
| 35 | func parseAgentName(s string) (AgentName, error) { |
| 36 | if !validAgentName.MatchString(s) { |
| 37 | return "", fmt.Errorf("invalid agent name %q: must match [a-zA-Z0-9_-]+", s) |
| 38 | } |
| 39 | return AgentName(s), nil |
| 40 | } |
| 41 | |
| 42 | // Detect returns the name of the AI coding agent driving the CLI, |
| 43 | // or an empty AgentName if none is detected. |