agentdetect

package
v1.23.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package agentdetect provides functionality to detect when azd is invoked by known AI coding agents (Claude Code, GitHub Copilot, Gemini, OpenCode) and enables automatic adjustment of behavior (e.g., no-prompt mode).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRunningInAgent

func IsRunningInAgent() bool

IsRunningInAgent returns true if azd was invoked by a known AI coding agent.

func ResetDetection

func ResetDetection()

ResetDetection clears the cached detection result. This is primarily useful for testing.

Types

type AgentInfo

type AgentInfo struct {
	// Type is the identified agent type.
	Type AgentType
	// Name is a human-readable name for the agent.
	Name string
	// Source indicates how the agent was detected.
	Source DetectionSource
	// Detected is true if an agent was detected.
	Detected bool
	// Details contains additional detection information (e.g., matched env var or process name).
	Details string
}

AgentInfo contains information about a detected AI coding agent.

func GetCallingAgent

func GetCallingAgent() AgentInfo

GetCallingAgent detects if azd was invoked by a known AI coding agent. The result is cached after the first call.

func NoAgent

func NoAgent() AgentInfo

NoAgent returns an AgentInfo indicating no agent was detected.

type AgentType

type AgentType string

AgentType represents a known AI coding agent.

const (
	// AgentTypeUnknown indicates no agent was detected.
	AgentTypeUnknown AgentType = ""
	// AgentTypeClaudeCode is Anthropic's Claude Code agent.
	AgentTypeClaudeCode AgentType = "claude-code"
	// AgentTypeGitHubCopilotCLI is GitHub's Copilot CLI agent.
	AgentTypeGitHubCopilotCLI AgentType = "github-copilot-cli"
	// AgentTypeVSCodeCopilot is VS Code GitHub Copilot extension.
	AgentTypeVSCodeCopilot AgentType = "vscode-copilot"
	// AgentTypeGemini is Google's Gemini CLI.
	AgentTypeGemini AgentType = "gemini"
	// AgentTypeOpenCode is the OpenCode AI coding CLI.
	AgentTypeOpenCode AgentType = "opencode"
)

func (AgentType) DisplayName

func (a AgentType) DisplayName() string

DisplayName returns a human-readable name for the agent type.

func (AgentType) String

func (a AgentType) String() string

String returns the string representation of the agent type.

type DetectionSource

type DetectionSource string

DetectionSource indicates how an agent was detected.

const (
	// DetectionSourceNone indicates no detection occurred.
	DetectionSourceNone DetectionSource = ""
	// DetectionSourceEnvVar indicates detection via environment variable.
	DetectionSourceEnvVar DetectionSource = "env-var"
	// DetectionSourceParentProcess indicates detection via parent process inspection.
	DetectionSourceParentProcess DetectionSource = "parent-process"
	// DetectionSourceUserAgent indicates detection via AZURE_DEV_USER_AGENT.
	DetectionSourceUserAgent DetectionSource = "user-agent"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL