Documentation
¶
Index ¶
- Variables
- type AssetDetails
- type AssetSummary
- type AssetVersion
- type Config
- type ErrVersionExists
- type GitSourceHandler
- type GitVault
- func (g *GitVault) AddAsset(ctx context.Context, asset *lockfile.Asset, zipData []byte) error
- func (g *GitVault) Authenticate(ctx context.Context) (string, error)
- func (g *GitVault) CommitAndPush(ctx context.Context, asset *lockfile.Asset) error
- func (g *GitVault) GetAsset(ctx context.Context, asset *lockfile.Asset) ([]byte, error)
- func (g *GitVault) GetAssetByVersion(ctx context.Context, name, version string) ([]byte, error)
- func (g *GitVault) GetAssetDetails(ctx context.Context, name string) (*AssetDetails, error)
- func (g *GitVault) GetBootstrapOptions(ctx context.Context) []bootstrap.Option
- func (g *GitVault) GetLockFile(ctx context.Context, cachedETag string) (content []byte, etag string, notModified bool, err error)
- func (g *GitVault) GetLockFilePath() string
- func (g *GitVault) GetMCPTools() any
- func (g *GitVault) GetMetadata(ctx context.Context, name, version string) (*metadata.Metadata, error)
- func (g *GitVault) GetVersionList(ctx context.Context, name string) ([]string, error)
- func (g *GitVault) ListAssets(ctx context.Context, opts ListAssetsOptions) (*ListAssetsResult, error)
- func (r *GitVault) PostUsageStats(ctx context.Context, jsonlData string) error
- func (g *GitVault) RemoveAsset(ctx context.Context, assetName, version string) error
- func (g *GitVault) SetInstallations(ctx context.Context, asset *lockfile.Asset) error
- func (g *GitVault) UpdateTemplates(ctx context.Context, commit bool) ([]string, error)
- func (g *GitVault) VerifyIntegrity(data []byte, hashes map[string]string, size int64) error
- type HTTPSourceHandler
- type ListAssetsOptions
- type ListAssetsResult
- type PathSourceHandler
- type PathVault
- func (p *PathVault) AddAsset(ctx context.Context, asset *lockfile.Asset, zipData []byte) error
- func (p *PathVault) Authenticate(ctx context.Context) (string, error)
- func (p *PathVault) GetAsset(ctx context.Context, asset *lockfile.Asset) ([]byte, error)
- func (p *PathVault) GetAssetByVersion(ctx context.Context, name, version string) ([]byte, error)
- func (p *PathVault) GetAssetDetails(ctx context.Context, name string) (*AssetDetails, error)
- func (p *PathVault) GetBootstrapOptions(ctx context.Context) []bootstrap.Option
- func (p *PathVault) GetLockFile(ctx context.Context, cachedETag string) (content []byte, etag string, notModified bool, err error)
- func (p *PathVault) GetLockFilePath() string
- func (p *PathVault) GetMCPTools() any
- func (p *PathVault) GetMetadata(ctx context.Context, name, version string) (*metadata.Metadata, error)
- func (p *PathVault) GetVersionList(ctx context.Context, name string) ([]string, error)
- func (p *PathVault) ListAssets(ctx context.Context, opts ListAssetsOptions) (*ListAssetsResult, error)
- func (p *PathVault) PostUsageStats(ctx context.Context, jsonlData string) error
- func (p *PathVault) RemoveAsset(ctx context.Context, assetName, version string) error
- func (p *PathVault) SetInstallations(ctx context.Context, asset *lockfile.Asset) error
- func (p *PathVault) VerifyIntegrity(data []byte, hashes map[string]string, size int64) error
- type QueryInput
- type Role
- type RoleListResponse
- type SleuthVault
- func (s *SleuthVault) AddAsset(ctx context.Context, asset *lockfile.Asset, zipData []byte) error
- func (s *SleuthVault) Authenticate(ctx context.Context) (string, error)
- func (s *SleuthVault) GetAsset(ctx context.Context, asset *lockfile.Asset) ([]byte, error)
- func (s *SleuthVault) GetAssetByVersion(ctx context.Context, name, ver string) ([]byte, error)
- func (s *SleuthVault) GetAssetDetails(ctx context.Context, name string) (*AssetDetails, error)
- func (s *SleuthVault) GetBootstrapOptions(ctx context.Context) []bootstrap.Option
- func (s *SleuthVault) GetLockFile(ctx context.Context, cachedETag string) (content []byte, etag string, notModified bool, err error)
- func (s *SleuthVault) GetMCPTools() any
- func (s *SleuthVault) GetMetadata(ctx context.Context, name, version string) (*metadata.Metadata, error)
- func (s *SleuthVault) GetVersionList(ctx context.Context, name string) ([]string, error)
- func (s *SleuthVault) ListAssets(ctx context.Context, opts ListAssetsOptions) (*ListAssetsResult, error)
- func (s *SleuthVault) ListRoles(ctx context.Context) (*RoleListResponse, error)
- func (s *SleuthVault) PostUsageStats(ctx context.Context, jsonlData string) error
- func (s *SleuthVault) QueryIntegration(ctx context.Context, query, integration string, gitContext any) (string, error)
- func (s *SleuthVault) QueryIntegrationStream(ctx context.Context, query, integration string, gitContext any, ...) (string, error)
- func (s *SleuthVault) RemoveAsset(ctx context.Context, assetName, version string) error
- func (s *SleuthVault) SetActiveRole(ctx context.Context, slug *string) (*Role, error)
- func (s *SleuthVault) SetInstallations(ctx context.Context, asset *lockfile.Asset) error
- func (s *SleuthVault) VerifyIntegrity(data []byte, hashes map[string]string, size int64) error
- type SourceHandler
- type ToolDef
- type Vault
Constants ¶
This section is empty.
Variables ¶
var ErrLockFileNotFound = errors.New("lock file not found")
ErrLockFileNotFound is returned when the lock file does not exist in the vault
Functions ¶
This section is empty.
Types ¶
type AssetDetails ¶ added in v0.6.0
type AssetDetails struct {
Name string
Type asset.Type
Description string
CreatedAt time.Time
UpdatedAt time.Time
Versions []AssetVersion
Metadata *metadata.Metadata // Metadata for latest version (or nil if not available)
}
AssetDetails contains detailed information about a specific asset
type AssetSummary ¶ added in v0.6.0
type AssetSummary struct {
Name string
Type asset.Type
LatestVersion string
VersionsCount int
Description string
CreatedAt time.Time
UpdatedAt time.Time
}
AssetSummary contains summary information about a vault asset
type AssetVersion ¶ added in v0.6.0
AssetVersion contains version information for an asset
type Config ¶
type Config interface {
GetType() string
GetServerURL() string
GetAuthToken() string
GetRepositoryURL() string
}
Config represents the minimal configuration needed to create a vault This avoids circular dependency with the config package
type ErrVersionExists ¶ added in v0.9.1
ErrVersionExists is returned when attempting to add an asset version that already exists
func (*ErrVersionExists) Error ¶ added in v0.9.1
func (e *ErrVersionExists) Error() string
type GitSourceHandler ¶
type GitSourceHandler struct {
// contains filtered or unexported fields
}
GitSourceHandler handles assets with source-git
func NewGitSourceHandler ¶
func NewGitSourceHandler(gitClient *git.Client) *GitSourceHandler
NewGitSourceHandler creates a new Git source handler
func (*GitSourceHandler) ResolveRef ¶
ResolveRef resolves a branch or tag name to a commit SHA This is used during lock file generation to convert friendly names to commit SHAs
type GitVault ¶
type GitVault struct {
// contains filtered or unexported fields
}
GitVault implements Vault for Git vaults
func NewGitVault ¶
NewGitVault creates a new Git repository
func (*GitVault) Authenticate ¶
Authenticate performs authentication with the Git repository For Git repos, this is a no-op as authentication is handled by git itself
func (*GitVault) CommitAndPush ¶
CommitAndPush commits all changes and pushes to remote
func (*GitVault) GetAssetByVersion ¶
GetAssetByVersion retrieves an asset by name and version from the git repository This creates a zip from the exploded directory
func (*GitVault) GetAssetDetails ¶ added in v0.6.0
GetAssetDetails returns detailed information about a specific asset
func (*GitVault) GetBootstrapOptions ¶ added in v0.9.2
GetBootstrapOptions returns no bootstrap options for GitVault
func (*GitVault) GetLockFile ¶
func (g *GitVault) GetLockFile(ctx context.Context, cachedETag string) (content []byte, etag string, notModified bool, err error)
GetLockFile retrieves the lock file from the Git repository
func (*GitVault) GetLockFilePath ¶
GetLockFilePath returns the path to the lock file in the git repository
func (*GitVault) GetMCPTools ¶ added in v0.6.0
GetMCPTools returns no additional MCP tools for GitVault
func (*GitVault) GetMetadata ¶
func (g *GitVault) GetMetadata(ctx context.Context, name, version string) (*metadata.Metadata, error)
GetMetadata retrieves metadata for a specific asset version Not applicable for Git repositories (metadata is inside the zip)
func (*GitVault) GetVersionList ¶
GetVersionList retrieves available versions for an asset from list.txt
func (*GitVault) ListAssets ¶ added in v0.6.0
func (g *GitVault) ListAssets(ctx context.Context, opts ListAssetsOptions) (*ListAssetsResult, error)
ListAssets returns a list of all assets in the vault by reading the assets/ directory
func (*GitVault) PostUsageStats ¶
PostUsageStats is a no-op for Git repositories Git repositories don't support stats collection
func (*GitVault) RemoveAsset ¶
RemoveAsset removes an asset from the lock file and pushes to remote
func (*GitVault) SetInstallations ¶ added in v0.6.0
SetInstallations updates the lock file with installation scopes and commits/pushes
func (*GitVault) UpdateTemplates ¶
UpdateTemplates updates templates in the repository if needed and returns the list of updated files The commit parameter controls whether to commit and push changes (git-specific behavior)
type HTTPSourceHandler ¶
type HTTPSourceHandler struct {
// contains filtered or unexported fields
}
HTTPSourceHandler handles assets with source-http
func NewHTTPSourceHandler ¶
func NewHTTPSourceHandler(authToken string) *HTTPSourceHandler
NewHTTPSourceHandler creates a new HTTP source handler
func (*HTTPSourceHandler) DownloadWithProgress ¶
func (h *HTTPSourceHandler) DownloadWithProgress(ctx context.Context, url string, progressCallback func(current, total int64)) ([]byte, error)
DownloadWithProgress downloads a file with progress reporting This is used for user-facing downloads with progress bars
type ListAssetsOptions ¶ added in v0.6.0
type ListAssetsOptions struct {
Type string // Filter by asset type (skill, mcp, etc.)
Search string // Search query for filtering assets
Limit int // Maximum number of assets to return (default 100)
}
ListAssetsOptions contains options for listing vault assets
type ListAssetsResult ¶ added in v0.6.0
type ListAssetsResult struct {
Assets []AssetSummary
}
ListAssetsResult contains the results of a ListAssets call
type PathSourceHandler ¶
type PathSourceHandler struct {
// contains filtered or unexported fields
}
PathSourceHandler handles assets with source-path
func NewPathSourceHandler ¶
func NewPathSourceHandler(lockFileDir string) *PathSourceHandler
NewPathSourceHandler creates a new path source handler
func (*PathSourceHandler) ResolvePath ¶
func (p *PathSourceHandler) ResolvePath(path string) (string, error)
ResolvePath resolves a path (absolute, relative, or tilde) to an absolute path
type PathVault ¶
type PathVault struct {
// contains filtered or unexported fields
}
PathVault implements Vault for local filesystem directories It follows the same pattern as GitRepository and SleuthRepository
func NewPathVault ¶
NewPathVault creates a new path repository from a file:// URL
func (*PathVault) AddAsset ¶
AddAsset adds an asset to the local repository Follows the same pattern as GitRepository: exploded storage + list.txt
func (*PathVault) Authenticate ¶
Authenticate performs authentication - no-op for path repositories
func (*PathVault) GetAsset ¶
GetAsset downloads an asset using its source configuration Reuses the same dispatch pattern as GitRepository and SleuthRepository
func (*PathVault) GetAssetByVersion ¶ added in v0.9.1
GetAssetByVersion retrieves an asset by name and version Creates a zip from the exploded directory
func (*PathVault) GetAssetDetails ¶ added in v0.6.0
GetAssetDetails returns detailed information about a specific asset
func (*PathVault) GetBootstrapOptions ¶ added in v0.9.2
GetBootstrapOptions returns no bootstrap options for PathVault
func (*PathVault) GetLockFile ¶
func (p *PathVault) GetLockFile(ctx context.Context, cachedETag string) (content []byte, etag string, notModified bool, err error)
GetLockFile retrieves the lock file from the local directory
func (*PathVault) GetLockFilePath ¶
GetLockFilePath returns the path to the lock file in the path repository
func (*PathVault) GetMCPTools ¶ added in v0.6.0
GetMCPTools returns no additional MCP tools for PathVault
func (*PathVault) GetMetadata ¶
func (p *PathVault) GetMetadata(ctx context.Context, name, version string) (*metadata.Metadata, error)
GetMetadata retrieves metadata for a specific asset version
func (*PathVault) GetVersionList ¶
GetVersionList retrieves available versions for an asset from list.txt Reuses the same pattern as GitRepository
func (*PathVault) ListAssets ¶ added in v0.6.0
func (p *PathVault) ListAssets(ctx context.Context, opts ListAssetsOptions) (*ListAssetsResult, error)
ListAssets returns a list of all assets in the vault by reading the assets/ directory
func (*PathVault) PostUsageStats ¶
PostUsageStats is a no-op for path repositories Same as GitRepository
func (*PathVault) RemoveAsset ¶
RemoveAsset removes an asset from the lock file
func (*PathVault) SetInstallations ¶ added in v0.6.0
SetInstallations updates the lock file with installation scopes
type QueryInput ¶ added in v0.6.0
type QueryInput struct {
Query string `` /* 235-byte string literal not displayed */
Integration string `json:"integration" jsonschema:"which integration to query (github, circleci, linear, or datadog)"`
}
QueryInput is the input type for query tool
type Role ¶ added in v0.11.1
type Role struct {
Title string `json:"title"`
Slug string `json:"slug"`
Description string `json:"description"`
}
Role represents a skill profile (role) from the server
type RoleListResponse ¶ added in v0.11.1
RoleListResponse represents the response from the roles list endpoint
type SleuthVault ¶
type SleuthVault struct {
// contains filtered or unexported fields
}
SleuthVault implements Vault for Sleuth HTTP servers
func NewSleuthVault ¶
func NewSleuthVault(serverURL, authToken string) *SleuthVault
NewSleuthVault creates a new Sleuth repository
func (*SleuthVault) Authenticate ¶
func (s *SleuthVault) Authenticate(ctx context.Context) (string, error)
Authenticate performs authentication with the Sleuth server
func (*SleuthVault) GetAssetByVersion ¶ added in v0.9.1
GetAssetByVersion downloads an asset by name and version
func (*SleuthVault) GetAssetDetails ¶ added in v0.6.0
func (s *SleuthVault) GetAssetDetails(ctx context.Context, name string) (*AssetDetails, error)
GetAssetDetails retrieves detailed information about a specific asset using GraphQL
func (*SleuthVault) GetBootstrapOptions ¶ added in v0.9.2
func (s *SleuthVault) GetBootstrapOptions(ctx context.Context) []bootstrap.Option
GetBootstrapOptions returns bootstrap options for the Sleuth vault. This includes the Sleuth AI Query MCP server.
func (*SleuthVault) GetLockFile ¶
func (s *SleuthVault) GetLockFile(ctx context.Context, cachedETag string) (content []byte, etag string, notModified bool, err error)
GetLockFile retrieves the lock file from the Sleuth server
func (*SleuthVault) GetMCPTools ¶ added in v0.6.0
func (s *SleuthVault) GetMCPTools() any
GetMCPTools returns the query tool for Sleuth vault
func (*SleuthVault) GetMetadata ¶
func (s *SleuthVault) GetMetadata(ctx context.Context, name, version string) (*metadata.Metadata, error)
GetMetadata retrieves metadata for a specific asset version
func (*SleuthVault) GetVersionList ¶
GetVersionList retrieves available versions for an asset
func (*SleuthVault) ListAssets ¶ added in v0.6.0
func (s *SleuthVault) ListAssets(ctx context.Context, opts ListAssetsOptions) (*ListAssetsResult, error)
ListAssets retrieves a list of all assets in the vault using GraphQL
func (*SleuthVault) ListRoles ¶ added in v0.11.1
func (s *SleuthVault) ListRoles(ctx context.Context) (*RoleListResponse, error)
ListRoles retrieves the list of available roles from the server
func (*SleuthVault) PostUsageStats ¶
func (s *SleuthVault) PostUsageStats(ctx context.Context, jsonlData string) error
PostUsageStats sends asset usage statistics to the Sleuth server
func (*SleuthVault) QueryIntegration ¶ added in v0.6.0
func (s *SleuthVault) QueryIntegration(ctx context.Context, query, integration string, gitContext any) (string, error)
QueryIntegration queries integrated services (GitHub, CircleCI, Linear) using natural language
func (*SleuthVault) QueryIntegrationStream ¶ added in v0.6.1
func (s *SleuthVault) QueryIntegrationStream( ctx context.Context, query, integration string, gitContext any, onEvent func(eventType, content string), ) (string, error)
QueryIntegrationStream queries integrated services using SSE streaming. The onEvent callback is called for each event received, which can be used to send MCP log notifications to keep the connection alive.
func (*SleuthVault) RemoveAsset ¶
func (s *SleuthVault) RemoveAsset(ctx context.Context, assetName, version string) error
RemoveAsset removes an asset from the Sleuth server's lock file
func (*SleuthVault) SetActiveRole ¶ added in v0.11.1
SetActiveRole sets or clears the active role on the server. Pass nil to clear the active role.
func (*SleuthVault) SetInstallations ¶ added in v0.6.0
SetInstallations sets the installation scopes for an asset using GraphQL mutation
func (*SleuthVault) VerifyIntegrity ¶
VerifyIntegrity checks hashes and sizes for downloaded assets
type SourceHandler ¶
type SourceHandler interface {
// Fetch retrieves asset data from the source
Fetch(ctx context.Context, asset *lockfile.Asset) ([]byte, error)
}
SourceHandler handles fetching assets from specific source types This is used internally by Vault implementations to handle different source types
type ToolDef ¶ added in v0.6.0
type ToolDef struct {
Tool *mcp.Tool
Handler func(context.Context, *mcp.CallToolRequest, QueryInput) (*mcp.CallToolResult, any, error)
}
ToolDef represents an MCP tool with its handler
type Vault ¶
type Vault interface {
// Authenticate performs authentication with the repository
// Returns an auth token or empty string if no auth needed
Authenticate(ctx context.Context) (string, error)
// GetLockFile retrieves the lock file from the repository
// Returns lock file content and ETag for caching
// If cachedETag matches, returns notModified=true with empty content
GetLockFile(ctx context.Context, cachedETag string) (content []byte, etag string, notModified bool, err error)
// GetAsset downloads an asset using its source configuration from the lock file
// The asset parameter contains the source configuration (source-http, source-git, source-path)
GetAsset(ctx context.Context, asset *lockfile.Asset) ([]byte, error)
// AddAsset uploads an asset to the repository
AddAsset(ctx context.Context, asset *lockfile.Asset, zipData []byte) error
// SetInstallations configures where an asset should be installed
// Updates the lock file with the installation scopes
SetInstallations(ctx context.Context, asset *lockfile.Asset) error
// GetVersionList retrieves available versions for an asset (for resolution)
// Only applicable to repositories with version management (Sleuth, not Git)
GetVersionList(ctx context.Context, name string) ([]string, error)
// GetMetadata retrieves metadata for a specific asset version
GetMetadata(ctx context.Context, name, version string) (*metadata.Metadata, error)
// GetAssetByVersion downloads an asset by name and version
// Used for comparing content when adding assets
GetAssetByVersion(ctx context.Context, name, version string) ([]byte, error)
// VerifyIntegrity checks hashes and sizes for downloaded assets
VerifyIntegrity(data []byte, hashes map[string]string, size int64) error
// PostUsageStats sends asset usage statistics to the repository
// jsonlData is newline-separated JSON (JSONL format)
PostUsageStats(ctx context.Context, jsonlData string) error
// RemoveAsset removes an asset from the lock file
// The asset remains in the vault and can be re-added later
// If version is empty, removes any version of the asset
RemoveAsset(ctx context.Context, assetName, version string) error
// ListAssets returns a list of all assets in the vault
// This enables asset discovery via `sx vault list`
ListAssets(ctx context.Context, opts ListAssetsOptions) (*ListAssetsResult, error)
// GetAssetDetails returns detailed information about a specific asset
// This enables asset inspection via `sx vault show <name>`
GetAssetDetails(ctx context.Context, name string) (*AssetDetails, error)
// GetMCPTools returns additional MCP tools provided by this vault
// Returns nil if the vault doesn't provide any MCP tools
GetMCPTools() any
// GetBootstrapOptions returns bootstrap options provided by this vault
// These are options for MCP servers or other infrastructure the vault provides
GetBootstrapOptions(ctx context.Context) []bootstrap.Option
}
Vault represents a source of assets with read and write capabilities This interface unifies the concepts of "vault" and "source fetcher"
func NewFromConfig ¶
NewFromConfig creates a vault instance from configuration This factory function eliminates repetitive switch statements across commands