config

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPollInterval is the default interval for polling the token endpoint
	DefaultPollInterval = 5 * time.Second

	// OAuthClientID is the well-known client ID for the Skills CLI
	OAuthClientID = "sleuth-skills-claude-code"
)
View Source
const DefaultProfileName = "default"

DefaultProfileName is the name used for the default profile

Variables

This section is empty.

Functions

func Exists

func Exists() bool

Exists checks if a configuration file exists

func GetActiveProfileName added in v0.7.0

func GetActiveProfileName(mpc *MultiProfileConfig) string

GetActiveProfileName returns the name of the profile that should be used

func GetActiveProfileOverride added in v0.7.0

func GetActiveProfileOverride() string

GetActiveProfileOverride returns the current profile override, if any

func IsSilent

func IsSilent() bool

IsSilent checks if silent mode is enabled via environment variable

func OpenBrowser

func OpenBrowser(verificationURI string) error

OpenBrowser opens the verification URI in the user's default browser

func Save

func Save(cfg *Config) error

Save saves the configuration to the config file This updates the active profile while preserving other profiles

func SaveMultiProfile added in v0.7.0

func SaveMultiProfile(mpc *MultiProfileConfig) error

SaveMultiProfile saves the full multi-profile configuration

func SaveToProfile added in v0.7.0

func SaveToProfile(cfg *Config, profileName string) error

SaveToProfile saves the configuration to a specific profile If profileName is empty, uses the active profile

func SetActiveProfile added in v0.7.0

func SetActiveProfile(name string)

SetActiveProfile sets the active profile for the current session This is typically set from a --profile flag or SX_PROFILE env var

Types

type Config

type Config struct {
	// Type of repository: "sleuth", "git", or "path"
	Type RepositoryType `json:"type"`

	// ServerURL is the Sleuth server URL (only for type=sleuth)
	ServerURL string `json:"serverUrl,omitempty"`

	// AuthToken is the OAuth token for Sleuth server (only for type=sleuth)
	AuthToken string `json:"authToken,omitempty"`

	// RepositoryURL is the repository URL
	// - For git: git repository URL (https://github.com/org/repo.git)
	// - For path: file:// URL pointing to local directory (file:///path/to/repo)
	RepositoryURL string `json:"repositoryUrl,omitempty"`

	// EnabledClients is the list of client IDs that assets should be installed to.
	// An empty/nil slice means "all detected clients" (backwards compatible default).
	EnabledClients []string `json:"enabledClients,omitempty"`
}

Config represents the configuration for the skills CLI

func Load

func Load() (*Config, error)

Load loads the configuration from the config file Uses the multi-profile system and returns the active profile as a Config

func (*Config) GetAuthToken

func (c *Config) GetAuthToken() string

GetAuthToken returns the auth token

func (*Config) GetEnabledClients added in v0.5.4

func (c *Config) GetEnabledClients() []string

GetEnabledClients returns the list of enabled client IDs. Returns nil if not explicitly configured (meaning use all detected).

func (*Config) GetRepositoryURL

func (c *Config) GetRepositoryURL() string

GetRepositoryURL returns the repository URL

func (*Config) GetServerURL

func (c *Config) GetServerURL() string

GetServerURL returns the Sleuth server URL, with environment override For backwards compatibility, falls back to ServerURL if RepositoryURL is empty

func (*Config) GetType

func (c *Config) GetType() string

GetType returns the repository type

func (*Config) IsClientEnabled added in v0.5.4

func (c *Config) IsClientEnabled(clientID string) bool

IsClientEnabled checks if a specific client ID is enabled. If EnabledClients is empty/nil, all clients are considered enabled (backwards compatible).

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type MultiProfileConfig added in v0.7.0

type MultiProfileConfig struct {
	// DefaultProfile is the name of the currently active profile
	DefaultProfile string `json:"defaultProfile"`

	// Profiles is a map of profile name to profile configuration
	Profiles map[string]*Profile `json:"profiles"`

	// EnabledClients is the list of client IDs that assets should be installed to.
	// An empty/nil slice means "all detected clients" (backwards compatible default).
	// This is global across all profiles.
	EnabledClients []string `json:"enabledClients,omitempty"`
}

MultiProfileConfig represents the full configuration file with multiple profiles

func LoadMultiProfile added in v0.7.0

func LoadMultiProfile() (*MultiProfileConfig, error)

LoadMultiProfile loads the full multi-profile configuration

func (*MultiProfileConfig) DeleteProfile added in v0.7.0

func (mpc *MultiProfileConfig) DeleteProfile(name string) error

DeleteProfile removes a profile by name

func (*MultiProfileConfig) GetProfile added in v0.7.0

func (mpc *MultiProfileConfig) GetProfile(name string) (*Profile, bool)

GetProfile returns a profile by name

func (*MultiProfileConfig) ListProfiles added in v0.7.0

func (mpc *MultiProfileConfig) ListProfiles() []string

ListProfiles returns a sorted list of profile names

func (*MultiProfileConfig) SetDefaultProfile added in v0.7.0

func (mpc *MultiProfileConfig) SetDefaultProfile(name string) error

SetDefaultProfile sets the default profile

func (*MultiProfileConfig) SetProfile added in v0.7.0

func (mpc *MultiProfileConfig) SetProfile(name string, profile *Profile)

SetProfile adds or updates a profile

type OAuthClient

type OAuthClient struct {
	// contains filtered or unexported fields
}

OAuthClient handles OAuth device code flow

func NewOAuthClient

func NewOAuthClient(serverURL string) *OAuthClient

NewOAuthClient creates a new OAuth client

func (*OAuthClient) PollForToken

func (o *OAuthClient) PollForToken(ctx context.Context, deviceCode string) (*OAuthTokenResponse, error)

PollForToken polls the token endpoint until the user completes authorization

func (*OAuthClient) StartDeviceFlow

func (o *OAuthClient) StartDeviceFlow(ctx context.Context) (*OAuthDeviceCodeResponse, error)

StartDeviceFlow initiates the OAuth device code flow

type OAuthDeviceCodeResponse

type OAuthDeviceCodeResponse struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationURIComplete string `json:"verification_uri_complete,omitempty"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval,omitempty"`
}

OAuthDeviceCodeResponse represents the response from the device authorization endpoint

type OAuthTokenResponse

type OAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Error        string `json:"error,omitempty"`
	ErrorDesc    string `json:"error_description,omitempty"`
}

OAuthTokenResponse represents the response from the token endpoint

type Profile added in v0.7.0

type Profile struct {
	// Type of repository: "sleuth", "git", or "path"
	Type RepositoryType `json:"type"`

	// ServerURL is the Sleuth server URL (only for type=sleuth)
	ServerURL string `json:"serverUrl,omitempty"`

	// AuthToken is the OAuth token for Sleuth server (only for type=sleuth)
	AuthToken string `json:"authToken,omitempty"`

	// RepositoryURL is the repository URL
	// - For git: git repository URL (https://github.com/org/repo.git)
	// - For path: file:// URL pointing to local directory (file:///path/to/repo)
	RepositoryURL string `json:"repositoryUrl,omitempty"`
}

Profile represents a single configuration profile

func ProfileFromConfig added in v0.7.0

func ProfileFromConfig(cfg *Config) *Profile

ProfileFromConfig creates a Profile from a Config

func (*Profile) ToConfig added in v0.7.0

func (p *Profile) ToConfig(enabledClients []string) *Config

ToConfig converts a Profile to a Config with the given enabled clients

type RepositoryType

type RepositoryType string

RepositoryType represents the type of repository (sleuth, git, or path)

const (
	RepositoryTypeSleuth RepositoryType = "sleuth"
	RepositoryTypeGit    RepositoryType = "git"
	RepositoryTypePath   RepositoryType = "path"
)

Jump to

Keyboard shortcuts

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