config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 13 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"
)

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(ctx context.Context, serverURL string) (string, error)

Authenticate performs the full OAuth device code flow

func Exists

func Exists() bool

Exists checks if a configuration file exists

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

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"`
}

Config represents the configuration for the skills CLI

func Load

func Load() (*Config, error)

Load loads the configuration from the config file Falls back to the old location (~/.claude/plugins/skills/config.json) for backwards compatibility

func (*Config) GetAuthToken

func (c *Config) GetAuthToken() string

GetAuthToken returns the auth token

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) Validate

func (c *Config) Validate() error

Validate validates the configuration

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 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