cli

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cli provides CLI-specific types and utilities for the aix command.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownPlatform is returned when an unknown platform name is provided.
	ErrUnknownPlatform = errors.New("unknown platform")

	// ErrNoPlatformsAvailable is returned when no platforms are detected.
	ErrNoPlatformsAvailable = errors.New("no platforms available")
)

Sentinel errors for platform operations.

Functions

func IsRepo added in v0.7.0

func IsRepo(path string) bool

IsRepo returns true if the given path is within a git repository.

Types

type AgentInfo

type AgentInfo struct {
	Name        string
	Description string
	Source      string // "local" or future: git URL
}

AgentInfo provides platform-agnostic agent information for display.

type CommandInfo

type CommandInfo struct {
	// Name is the command's identifier (used as /name in the interface).
	Name string

	// Description explains what the command does.
	Description string

	// Source indicates where the command came from: file path or "installed".
	Source string
}

CommandInfo provides a simplified view of a command for CLI display. This is a platform-agnostic representation used for listing.

type MCPInfo

type MCPInfo struct {
	Name      string
	Transport string // "stdio" or "sse"
	Command   string // Executable path (stdio)
	URL       string // Endpoint (sse)
	Disabled  bool
	Env       map[string]string // Environment variables
}

MCPInfo provides platform-agnostic MCP server information for display.

type Platform

type Platform interface {
	// Name returns the platform identifier (e.g., "claude", "opencode").
	Name() string

	// DisplayName returns a human-readable platform name (e.g., "Claude Code").
	DisplayName() string

	// IsAvailable checks if the platform is installed on this system.
	IsAvailable() bool

	// SkillDir returns the skills directory for the platform.
	SkillDir() string

	// InstallSkill installs a skill to the platform.
	// The skill parameter is platform-specific.
	InstallSkill(skill any, scope Scope) error

	// UninstallSkill removes a skill by name.
	UninstallSkill(name string, scope Scope) error

	// ListSkills returns information about all installed skills.
	ListSkills(scope Scope) ([]SkillInfo, error)

	// GetSkill retrieves a skill by name.
	// Returns the platform-specific skill type.
	GetSkill(name string, scope Scope) (any, error)

	// CommandDir returns the commands directory for the platform.
	CommandDir() string

	// InstallCommand installs a slash command to the platform.
	// The cmd parameter is platform-specific.
	InstallCommand(cmd any, scope Scope) error

	// UninstallCommand removes a command by name.
	UninstallCommand(name string, scope Scope) error

	// ListCommands returns information about all installed commands.
	ListCommands(scope Scope) ([]CommandInfo, error)

	// GetCommand retrieves a command by name.
	// Returns the platform-specific command type.
	GetCommand(name string, scope Scope) (any, error)

	// MCP configuration
	MCPConfigPath() string
	AddMCP(server any, scope Scope) error
	RemoveMCP(name string, scope Scope) error
	ListMCP(scope Scope) ([]MCPInfo, error)
	GetMCP(name string, scope Scope) (any, error)
	EnableMCP(name string) error
	DisableMCP(name string) error

	// Agent configuration
	AgentDir() string
	InstallAgent(agent any, scope Scope) error
	UninstallAgent(name string, scope Scope) error
	ListAgents(scope Scope) ([]AgentInfo, error)
	GetAgent(name string, scope Scope) (any, error)

	// Backup configuration
	// BackupPaths returns all config files/directories that should be backed up.
	// This includes MCP config files and platform-specific directories (skills, commands, agents).
	BackupPaths() []string

	// IsLocalConfigIgnored checks if the local configuration is ignored by VCS.
	IsLocalConfigIgnored() (bool, error)
}

Platform defines the interface that platform adapters must implement for CLI operations. This is the consumer interface used by CLI commands.

func NewPlatform

func NewPlatform(name string) (Platform, error)

func ResolvePlatforms

func ResolvePlatforms(names []string) ([]Platform, error)

ResolvePlatforms returns Platform instances for the given platform names. If names is empty, returns all detected/installed platforms. Returns an error if any platform name is invalid or if no platforms are available.

type Scope added in v0.7.0

type Scope int

Scope defines the configuration layer target (User, Project, Local, Managed).

const (
	// ScopeDefault indicates that the platform should use its default behavior
	// (usually merged view for listing, or precedence-based for getting).
	ScopeDefault Scope = iota
	// ScopeUser targets the user's global home directory configuration.
	ScopeUser
	// ScopeProject targets the project/repository configuration (typically committed).
	ScopeProject
	// ScopeLocal targets local overrides within a project (typically gitignored).
	ScopeLocal
	// ScopeManaged targets system-level managed configuration.
	ScopeManaged
)

func DetermineScope added in v0.7.0

func DetermineScope(requested string) (Scope, error)

DetermineScope resolves the configuration scope based on user request, environment context (Git), and interactivity.

Precedence: 1. Explicit request via flag (--scope) 2. Interactive prompt (if in repo and TTY available) 3. Project scope default (if in repo but no TTY) 4. User scope default (if not in repo)

func ParseScope added in v0.7.0

func ParseScope(s string) Scope

ParseScope converts a string to a Scope. Returns ScopeDefault if empty or invalid.

func (Scope) String added in v0.7.0

func (s Scope) String() string

type SkillInfo

type SkillInfo struct {
	// Name is the skill's unique identifier.
	Name string

	// Description explains what the skill does.
	Description string

	// Source indicates where the skill came from: "local" or a git URL.
	Source string
}

SkillInfo provides a simplified view of a skill for CLI display. This is a platform-agnostic representation used for listing.

Directories

Path Synopsis
Package prompt provides interactive CLI prompts for user input.
Package prompt provides interactive CLI prompts for user input.

Jump to

Keyboard shortcuts

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