MCPcopy Index your code
hub / github.com/cli/cli / parseAgentName

Function parseAgentName

internal/agents/detect.go:35–40  ·  view source on GitHub ↗

parseAgentName validates and returns an AgentName from a raw string. Only alphanumeric characters, hyphens, and underscores are allowed.

(s string)

Source from the content-addressed store, hash-verified

33// parseAgentName validates and returns an AgentName from a raw string.
34// Only alphanumeric characters, hyphens, and underscores are allowed.
35func 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.

Callers 2

detectWithFunction · 0.85
TestParseAgentNameFunction · 0.85

Calls 2

AgentNameTypeAlias · 0.85
ErrorfMethod · 0.65

Tested by 1

TestParseAgentNameFunction · 0.68