Documentation
¶
Overview ¶
Package gemini provides Gemini CLI specific configuration and path handling.
Index ¶
- Constants
- Variables
- func ListVariables(content string) []string
- func TranslateToCanonical(content string) string
- func TranslateVariables(content string) string
- func ValidateVariables(content string) error
- type Agent
- type AgentManager
- type Command
- type CommandManager
- type GeminiPaths
- func (p *GeminiPaths) AgentDir() string
- func (p *GeminiPaths) AgentPath(name string) string
- func (p *GeminiPaths) BaseDir() string
- func (p *GeminiPaths) CommandDir() string
- func (p *GeminiPaths) CommandPath(name string) string
- func (p *GeminiPaths) InstructionsPath() string
- func (p *GeminiPaths) MCPConfigPath() string
- func (p *GeminiPaths) SkillDir() string
- func (p *GeminiPaths) SkillPath(name string) string
- type GeminiPlatform
- func (p *GeminiPlatform) AddMCP(s *MCPServer) error
- func (p *GeminiPlatform) AgentDir() string
- func (p *GeminiPlatform) BackupPaths() []string
- func (p *GeminiPlatform) CommandDir() string
- func (p *GeminiPlatform) DisableMCP(name string) error
- func (p *GeminiPlatform) DisplayName() string
- func (p *GeminiPlatform) EnableMCP(name string) error
- func (p *GeminiPlatform) GetAgent(name string) (*Agent, error)
- func (p *GeminiPlatform) GetCommand(name string) (*Command, error)
- func (p *GeminiPlatform) GetMCP(name string) (*MCPServer, error)
- func (p *GeminiPlatform) GetSkill(name string) (*Skill, error)
- func (p *GeminiPlatform) GlobalConfigDir() string
- func (p *GeminiPlatform) InstallAgent(a *Agent) error
- func (p *GeminiPlatform) InstallCommand(c *Command) error
- func (p *GeminiPlatform) InstallSkill(s *Skill) error
- func (p *GeminiPlatform) InstructionsPath(projectRoot string) string
- func (p *GeminiPlatform) IsAvailable() bool
- func (p *GeminiPlatform) ListAgents() ([]*Agent, error)
- func (p *GeminiPlatform) ListCommands() ([]*Command, error)
- func (p *GeminiPlatform) ListMCP() ([]*MCPServer, error)
- func (p *GeminiPlatform) ListSkills() ([]*Skill, error)
- func (p *GeminiPlatform) MCPConfigPath() string
- func (p *GeminiPlatform) Name() string
- func (p *GeminiPlatform) ProjectConfigDir(projectRoot string) string
- func (p *GeminiPlatform) RemoveMCP(name string) error
- func (p *GeminiPlatform) SkillDir() string
- func (p *GeminiPlatform) TranslateToCanonical(content string) string
- func (p *GeminiPlatform) TranslateVariables(content string) string
- func (p *GeminiPlatform) UninstallAgent(name string) error
- func (p *GeminiPlatform) UninstallCommand(name string) error
- func (p *GeminiPlatform) UninstallSkill(name string) error
- func (p *GeminiPlatform) ValidateVariables(content string) error
- func (p *GeminiPlatform) Version() (string, error)
- type MCPConfig
- type MCPManager
- type MCPServer
- type MCPTranslator
- type Option
- type Scope
- type Settings
- type Skill
- type SkillManager
- type ToolList
Constants ¶
const (
VarArguments = "$ARGUMENTS"
)
Variables supported by Gemini CLI.
Variables ¶
var ( ErrAgentNotFound = errors.New("agent not found") ErrInvalidAgent = errors.New("invalid agent: name required") )
Sentinel errors for agent operations.
var ( ErrCommandNotFound = errors.New("command not found") ErrInvalidCommand = errors.New("invalid command: name required") )
Sentinel errors for command operations.
var ( ErrMCPServerNotFound = errors.New("MCP server not found") ErrInvalidMCPServer = errors.New("invalid MCP server: name required") )
Sentinel errors for MCP operations.
var ( ErrSkillNotFound = errors.New("skill not found") ErrInvalidSkill = errors.New("invalid skill: name required") )
Sentinel errors for skill operations.
var ErrUnsupportedVariable = errors.New("unsupported variable")
ErrUnsupportedVariable indicates content contains variables not supported by Gemini CLI.
Functions ¶
func ListVariables ¶
ListVariables returns all canonical variables found in the content.
func TranslateToCanonical ¶
TranslateToCanonical converts Gemini CLI variable syntax to canonical format. {{args}} -> $ARGUMENTS {{argument}} -> $ARGUMENTS
func TranslateVariables ¶
TranslateVariables converts canonical variable syntax to Gemini CLI format. $ARGUMENTS -> {{argument}}
func ValidateVariables ¶
ValidateVariables checks if content contains only supported variables.
Types ¶
type Agent ¶
type Agent struct {
// Name is the agent's identifier.
Name string `yaml:"name" json:"name" toml:"name"`
// Description explains the agent's purpose.
Description string `yaml:"description,omitempty" json:"description,omitempty" toml:"description,omitempty"`
// Instructions contains the agent's markdown body content.
Instructions string `yaml:"-" json:"-" toml:"instructions,multiline"`
}
Agent represents a Gemini CLI agent definition.
func (*Agent) GetDescription ¶
GetDescription returns the agent's description.
func (*Agent) GetInstructions ¶
GetInstructions returns the agent's instructions.
type AgentManager ¶
type AgentManager struct {
// contains filtered or unexported fields
}
AgentManager provides CRUD operations for Gemini CLI agents.
func NewAgentManager ¶
func NewAgentManager(paths *GeminiPaths) *AgentManager
NewAgentManager creates a new AgentManager with the given paths configuration.
func (*AgentManager) Get ¶
func (m *AgentManager) Get(name string) (*Agent, error)
Get retrieves an agent by name.
func (*AgentManager) Install ¶
func (m *AgentManager) Install(a *Agent) error
Install writes an agent to disk in TOML format.
func (*AgentManager) List ¶
func (m *AgentManager) List() ([]*Agent, error)
List returns all agents in the agents directory.
func (*AgentManager) Uninstall ¶
func (m *AgentManager) Uninstall(name string) error
Uninstall removes an agent from disk.
type Command ¶
type Command struct {
// Name is the command's identifier.
Name string `yaml:"name" json:"name" toml:"-"`
// Description explains what the command does.
Description string `yaml:"description,omitempty" json:"description,omitempty" toml:"description,omitempty"`
// Instructions contains the command's markdown body content.
Instructions string `yaml:"-" json:"-" toml:"prompt"`
}
Command represents a Gemini CLI slash command definition.
func (*Command) SetInstructions ¶
SetInstructions sets the command's instructions.
type CommandManager ¶
type CommandManager struct {
// contains filtered or unexported fields
}
CommandManager provides CRUD operations for Gemini CLI slash commands.
func NewCommandManager ¶
func NewCommandManager(paths *GeminiPaths) *CommandManager
NewCommandManager creates a new CommandManager with the given paths configuration.
func (*CommandManager) Get ¶
func (m *CommandManager) Get(name string) (*Command, error)
Get retrieves a command by name.
func (*CommandManager) Install ¶
func (m *CommandManager) Install(c *Command) error
Install writes a command to disk in TOML format.
func (*CommandManager) List ¶
func (m *CommandManager) List() ([]*Command, error)
List returns all commands in the commands directory.
func (*CommandManager) Uninstall ¶
func (m *CommandManager) Uninstall(name string) error
Uninstall removes a command from disk.
type GeminiPaths ¶
type GeminiPaths struct {
// contains filtered or unexported fields
}
GeminiPaths provides Gemini-specific path resolution. It wraps the generic paths package with Gemini-specific defaults.
func NewGeminiPaths ¶
func NewGeminiPaths(scope Scope, projectRoot string) *GeminiPaths
NewGeminiPaths creates a new GeminiPaths instance. For ScopeProject, projectRoot must be non-empty. For ScopeUser, projectRoot is ignored.
func (*GeminiPaths) AgentDir ¶
func (p *GeminiPaths) AgentDir() string
AgentDir returns the agents directory. Returns <base>/agents/
func (*GeminiPaths) AgentPath ¶
func (p *GeminiPaths) AgentPath(name string) string
AgentPath returns the path to a specific agent file. Returns <agents>/<name>.toml Returns empty string if name is empty.
func (*GeminiPaths) BaseDir ¶
func (p *GeminiPaths) BaseDir() string
BaseDir returns the base configuration directory. For ScopeUser: ~/.gemini/ For ScopeProject: <projectRoot>/.gemini/ Returns empty string if projectRoot is empty for ScopeProject.
func (*GeminiPaths) CommandDir ¶
func (p *GeminiPaths) CommandDir() string
CommandDir returns the commands directory. Returns <base>/commands/
func (*GeminiPaths) CommandPath ¶
func (p *GeminiPaths) CommandPath(name string) string
CommandPath returns the path to a specific command file. Returns <commands>/<name>.toml Returns empty string if name is empty.
func (*GeminiPaths) InstructionsPath ¶
func (p *GeminiPaths) InstructionsPath() string
InstructionsPath returns the path to the GEMINI.md instructions file. For ScopeUser: ~/.gemini/GEMINI.md For ScopeProject: <projectRoot>/GEMINI.md (note: at project root, not .gemini/)
func (*GeminiPaths) MCPConfigPath ¶
func (p *GeminiPaths) MCPConfigPath() string
MCPConfigPath returns the path to the MCP servers configuration file. Returns <base>/settings.json
func (*GeminiPaths) SkillDir ¶
func (p *GeminiPaths) SkillDir() string
SkillDir returns the skills directory. Returns <base>/skills/
func (*GeminiPaths) SkillPath ¶
func (p *GeminiPaths) SkillPath(name string) string
SkillPath returns the path to a specific skill's SKILL.md file. Returns <skills>/<name>/SKILL.md Returns empty string if name is empty.
type GeminiPlatform ¶
type GeminiPlatform struct {
// contains filtered or unexported fields
}
GeminiPlatform provides the unified platform adapter for Gemini CLI.
func NewGeminiPlatform ¶
func NewGeminiPlatform(opts ...Option) *GeminiPlatform
NewGeminiPlatform creates a new GeminiPlatform with the given options.
func (*GeminiPlatform) AddMCP ¶
func (p *GeminiPlatform) AddMCP(s *MCPServer) error
func (*GeminiPlatform) AgentDir ¶
func (p *GeminiPlatform) AgentDir() string
func (*GeminiPlatform) BackupPaths ¶
func (p *GeminiPlatform) BackupPaths() []string
func (*GeminiPlatform) CommandDir ¶
func (p *GeminiPlatform) CommandDir() string
func (*GeminiPlatform) DisableMCP ¶
func (p *GeminiPlatform) DisableMCP(name string) error
func (*GeminiPlatform) DisplayName ¶
func (p *GeminiPlatform) DisplayName() string
func (*GeminiPlatform) EnableMCP ¶
func (p *GeminiPlatform) EnableMCP(name string) error
func (*GeminiPlatform) GetCommand ¶
func (p *GeminiPlatform) GetCommand(name string) (*Command, error)
func (*GeminiPlatform) GlobalConfigDir ¶
func (p *GeminiPlatform) GlobalConfigDir() string
func (*GeminiPlatform) InstallAgent ¶
func (p *GeminiPlatform) InstallAgent(a *Agent) error
func (*GeminiPlatform) InstallCommand ¶
func (p *GeminiPlatform) InstallCommand(c *Command) error
func (*GeminiPlatform) InstallSkill ¶
func (p *GeminiPlatform) InstallSkill(s *Skill) error
func (*GeminiPlatform) InstructionsPath ¶
func (p *GeminiPlatform) InstructionsPath(projectRoot string) string
func (*GeminiPlatform) IsAvailable ¶
func (p *GeminiPlatform) IsAvailable() bool
func (*GeminiPlatform) ListAgents ¶
func (p *GeminiPlatform) ListAgents() ([]*Agent, error)
func (*GeminiPlatform) ListCommands ¶
func (p *GeminiPlatform) ListCommands() ([]*Command, error)
func (*GeminiPlatform) ListMCP ¶
func (p *GeminiPlatform) ListMCP() ([]*MCPServer, error)
func (*GeminiPlatform) ListSkills ¶
func (p *GeminiPlatform) ListSkills() ([]*Skill, error)
func (*GeminiPlatform) MCPConfigPath ¶
func (p *GeminiPlatform) MCPConfigPath() string
func (*GeminiPlatform) Name ¶
func (p *GeminiPlatform) Name() string
func (*GeminiPlatform) ProjectConfigDir ¶
func (p *GeminiPlatform) ProjectConfigDir(projectRoot string) string
func (*GeminiPlatform) RemoveMCP ¶
func (p *GeminiPlatform) RemoveMCP(name string) error
func (*GeminiPlatform) SkillDir ¶
func (p *GeminiPlatform) SkillDir() string
func (*GeminiPlatform) TranslateToCanonical ¶
func (p *GeminiPlatform) TranslateToCanonical(content string) string
func (*GeminiPlatform) TranslateVariables ¶
func (p *GeminiPlatform) TranslateVariables(content string) string
func (*GeminiPlatform) UninstallAgent ¶
func (p *GeminiPlatform) UninstallAgent(name string) error
func (*GeminiPlatform) UninstallCommand ¶
func (p *GeminiPlatform) UninstallCommand(name string) error
func (*GeminiPlatform) UninstallSkill ¶
func (p *GeminiPlatform) UninstallSkill(name string) error
func (*GeminiPlatform) ValidateVariables ¶
func (p *GeminiPlatform) ValidateVariables(content string) error
func (*GeminiPlatform) Version ¶
func (p *GeminiPlatform) Version() (string, error)
type MCPConfig ¶
type MCPConfig struct {
// Servers maps server names to their configurations.
Servers map[string]*MCPServer `json:"servers"`
}
MCPConfig represents the MCP section in Gemini CLI's settings.json.
type MCPManager ¶
type MCPManager struct {
// contains filtered or unexported fields
}
MCPManager provides CRUD operations for Gemini CLI MCP server configurations.
func NewMCPManager ¶
func NewMCPManager(paths *GeminiPaths) *MCPManager
NewMCPManager creates a new MCPManager instance.
func (*MCPManager) Add ¶
func (m *MCPManager) Add(server *MCPServer) error
Add adds or updates an MCP server configuration.
func (*MCPManager) Disable ¶
func (m *MCPManager) Disable(name string) error
Disable deactivates an MCP server.
func (*MCPManager) Enable ¶
func (m *MCPManager) Enable(name string) error
Enable activates an MCP server.
func (*MCPManager) Get ¶
func (m *MCPManager) Get(name string) (*MCPServer, error)
Get returns a single MCP server by name.
func (*MCPManager) List ¶
func (m *MCPManager) List() ([]*MCPServer, error)
List returns all configured MCP servers.
func (*MCPManager) Remove ¶
func (m *MCPManager) Remove(name string) error
Remove removes an MCP server configuration.
type MCPServer ¶
type MCPServer struct {
// Name is the server's identifier, derived from the map key.
Name string `json:"-"`
// Command is the executable path for local servers.
Command string `json:"command,omitempty"`
// Args are command-line arguments for the server process.
Args []string `json:"args,omitempty"`
// URL is the server endpoint for remote servers.
URL string `json:"url,omitempty"`
// Env contains environment variables for the server process.
Env map[string]string `json:"env,omitempty"`
// Headers contains HTTP headers for remote connections.
Headers map[string]string `json:"headers,omitempty"`
// Enabled indicates whether the server is active.
Enabled bool `json:"enabled"`
}
MCPServer represents an MCP server configuration for Gemini CLI. Gemini uses an "inferred" transport type based on presence of command or url.
type MCPTranslator ¶
type MCPTranslator struct{}
MCPTranslator converts between canonical and Gemini CLI MCP formats.
func NewMCPTranslator ¶
func NewMCPTranslator() *MCPTranslator
NewMCPTranslator creates a new Gemini CLI MCP translator.
func (*MCPTranslator) FromCanonical ¶
func (t *MCPTranslator) FromCanonical(cfg *mcp.Config) ([]byte, error)
FromCanonical converts canonical MCP configuration to Gemini CLI format.
func (*MCPTranslator) Platform ¶
func (t *MCPTranslator) Platform() string
Platform returns the platform identifier for this translator.
func (*MCPTranslator) ToCanonical ¶
func (t *MCPTranslator) ToCanonical(platformData []byte) (*mcp.Config, error)
ToCanonical converts Gemini CLI MCP configuration to canonical format.
type Option ¶
type Option func(*GeminiPlatform)
Option configures a GeminiPlatform instance.
func WithProjectRoot ¶
WithProjectRoot sets the project root directory.
type Scope ¶
type Scope int
Scope defines whether paths resolve to user-level or project-level configuration.
type Settings ¶
type Settings struct {
// MCP contains the MCP server configurations.
MCP *MCPConfig `json:"mcp,omitempty"`
// contains filtered or unexported fields
}
Settings represents the root structure of Gemini CLI's settings.json. It preserves unknown fields to avoid data loss when modifying MCP section.
func (*Settings) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Settings) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Skill ¶
type Skill struct {
// Name is the skill's unique identifier (required).
Name string `yaml:"name" json:"name"`
// Description explains what the skill does (required).
Description string `yaml:"description" json:"description"`
// License is the SPDX license identifier (optional).
License string `yaml:"license,omitempty" json:"license,omitempty"`
// Compatibility lists compatible AI assistants (optional).
Compatibility []string `yaml:"compatibility,omitempty" json:"compatibility,omitempty"`
// Metadata contains optional key-value pairs like author, version, repository.
Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
// AllowedTools lists the tool permissions required by this skill.
AllowedTools ToolList `yaml:"allowed-tools,omitempty" json:"allowed-tools,omitempty"`
// Instructions contains the skill's markdown body content.
// This field is not part of the YAML frontmatter.
Instructions string `yaml:"-" json:"-"`
}
Skill represents a skill definition per the Agent Skills Specification. Skills are markdown files with YAML frontmatter that define reusable capabilities.
type SkillManager ¶
type SkillManager struct {
// contains filtered or unexported fields
}
SkillManager handles CRUD operations for Gemini CLI skills.
func NewSkillManager ¶
func NewSkillManager(paths *GeminiPaths) *SkillManager
NewSkillManager creates a new SkillManager with the given paths configuration.
func (*SkillManager) Get ¶
func (m *SkillManager) Get(name string) (*Skill, error)
Get retrieves a skill by name.
func (*SkillManager) Install ¶
func (m *SkillManager) Install(s *Skill) error
Install creates or overwrites a skill.
func (*SkillManager) List ¶
func (m *SkillManager) List() ([]*Skill, error)
List returns all skills in the skill directory.
func (*SkillManager) Uninstall ¶
func (m *SkillManager) Uninstall(name string) error
Uninstall removes a skill by name.