agent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AgentNameHeader = "X-Agent-Name"

AgentNameHeader carries the agent slug (e.g. "claude-code") to the MCP server, which uses it to attribute requests to a specific agent.

Variables

This section is empty.

Functions

func InjectAll

func InjectAll(agents []Agent, cfg MCPConfig, workspaceDir string) error

InjectAll injects the SafeDep MCP config into every detected agent. workspaceDir="" skips workspace injection. Best-effort: all agents are attempted; errors are accumulated.

func RemoveAll

func RemoveAll(agents []Agent, workspaceDir string) error

RemoveAll removes the SafeDep MCP config from every detected agent. Same error semantics as InjectAll.

Types

type Agent

type Agent interface {
	// Name returns a stable identifier (e.g. "claude-code").
	Name() string

	// Detected reports whether the agent is installed on this machine.
	Detected() bool

	// AsGlobalInjector returns the user-level injector if this agent supports global config.
	AsGlobalInjector() (GlobalInjector, bool)

	// AsWorkspaceInjector returns the workspace injector if this agent supports project config.
	AsWorkspaceInjector() (WorkspaceInjector, bool)
}

Agent is an AI coding agent that may be installed on the current machine.

func FilterDetected

func FilterDetected(agents []Agent) []Agent

FilterDetected returns the subset of agents whose Detected() method returns true.

func NewRegistry

func NewRegistry() []Agent

NewRegistry returns all known agent adapters initialised with the current user's home directory.

type GlobalInjector

type GlobalInjector interface {
	// GlobalConfigPath returns the absolute path to the global config file.
	GlobalConfigPath() string

	// InjectGlobal writes the SafeDep entry. Idempotent; preserves all other keys.
	InjectGlobal(cfg MCPConfig) error

	// RemoveGlobal deletes the SafeDep entry. No-op if absent.
	RemoveGlobal() error

	// GlobalConfigured reports whether the SafeDep entry is present in the
	// global config file. Returns false (no error) when the file is absent.
	GlobalConfigured() (bool, error)
}

GlobalInjector writes or removes the SafeDep MCP config from a user-level config file.

type MCPConfig

type MCPConfig struct {
	URL     string
	Headers map[string]string
}

MCPConfig is the SafeDep MCP server entry to inject.

type WorkspaceInjector

type WorkspaceInjector interface {
	// WorkspaceConfigPath returns the absolute path to the workspace config file.
	// The path may or may not be inside workspaceDir depending on the agent.
	WorkspaceConfigPath(workspaceDir string) string

	// InjectWorkspace writes the SafeDep entry. Idempotent; preserves all other keys.
	InjectWorkspace(workspaceDir string, cfg MCPConfig) error

	// RemoveWorkspace deletes the SafeDep entry. No-op if absent.
	RemoveWorkspace(workspaceDir string) error

	// WorkspaceConfigured reports whether the SafeDep entry is present in the
	// workspace config file. Returns false (no error) when the file is absent.
	WorkspaceConfigured(workspaceDir string) (bool, error)
}

WorkspaceInjector writes or removes the SafeDep MCP config from a workspace config file.

Jump to

Keyboard shortcuts

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