Documentation
¶
Index ¶
- Constants
- func CleanVersion(version string) string
- func ClearOSVCacheForTesting()
- func CompareVersions(v1, v2 string) (int, error)
- func ExtractMajorVersion(version string) (int, error)
- func FuzzyMatch(str, query string) bool
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func MakeRequest(client HTTPClient, method, url string, headers map[string]string) ([]byte, error)
- func MakeRequestWithLogger(client HTTPClient, logger *logrus.Logger, method, reqURL string, ...) ([]byte, error)
- func NewToolResultJSON(data any) (*mcp.CallToolResult, error)
- func ParseVersion(version string) (major, minor, patch int, err error)
- func ResetCooldownConfigForTesting()
- func StringPtr(s string) *string
- func StringPtrUnlessLatest(s string) *string
- type BedrockModel
- type BedrockModelSearchResult
- type CargoToml
- type CooldownConfig
- type CooldownInfo
- type DockerImageQuery
- type DockerImageVersion
- type GitHubAction
- type GitHubActionVersion
- type GoModule
- type GoReplace
- type GoRequire
- type GradleDependency
- type HTTPClient
- type MavenDependency
- type NpmDependencies
- type PackageDetails
- type PackageVersion
- type PyProjectDependencies
- type RateLimitedHTTPClient
- type RustCrate
- type RustDetails
- type SwiftDependency
- type VersionConstraint
- type VersionConstraints
- type VersionWithDate
Constants ¶
const ( // DefaultCooldownHours is the default cooldown period (72 hours / 3 days) DefaultCooldownHours = 72 // OSVAPITimeout is the timeout for OSV API requests OSVAPITimeout = 1500 * time.Millisecond // OSVURL is the OSV API endpoint OSVURL = "https://api.osv.dev/v1/query" // OSVCacheDuration is how long to cache OSV results OSVCacheDuration = 5 * time.Minute // MaxOSVResponseSize is the maximum size of OSV API responses (10MB) MaxOSVResponseSize = 10 * 1024 * 1024 )
const ( // DefaultPackagesRateLimit is the default maximum requests per second DefaultPackagesRateLimit = 10 // PackagesRateLimitEnvVar is the environment variable for configuring rate limit PackagesRateLimitEnvVar = "PACKAGES_RATE_LIMIT" )
Variables ¶
This section is empty.
Functions ¶
func CleanVersion ¶
CleanVersion removes any leading version prefix (^, ~, >, =, <, etc.) from a version string
func ClearOSVCacheForTesting ¶ added in v0.53.0
func ClearOSVCacheForTesting()
ClearOSVCacheForTesting clears the OSV cache (for testing only)
func CompareVersions ¶
CompareVersions compares two version strings Returns:
-1 if v1 < v2 0 if v1 == v2 1 if v1 > v2
func ExtractMajorVersion ¶
ExtractMajorVersion extracts the major version from a version string
func FuzzyMatch ¶
FuzzyMatch performs a simple fuzzy match between a string and a query
func MakeRequest ¶
MakeRequest makes an HTTP request and returns the response body
func MakeRequestWithLogger ¶
func MakeRequestWithLogger(client HTTPClient, logger *logrus.Logger, method, reqURL string, headers map[string]string) ([]byte, error)
MakeRequestWithLogger makes an HTTP request with logging and returns the response body
func NewToolResultJSON ¶
func NewToolResultJSON(data any) (*mcp.CallToolResult, error)
NewToolResultJSON creates a new tool result with JSON content
func ParseVersion ¶
ParseVersion parses a version string into major, minor, and patch components
func ResetCooldownConfigForTesting ¶ added in v0.53.0
func ResetCooldownConfigForTesting()
ResetCooldownConfigForTesting resets the cooldown config singleton (for testing only)
func StringPtrUnlessLatest ¶ added in v0.41.5
StringPtrUnlessLatest returns a pointer to the given string unless it equals "latest", in which case it returns nil This is used to avoid including redundant "currentVersion": "latest" fields in package version responses
Types ¶
type BedrockModel ¶
type BedrockModel struct {
Provider string `json:"provider"`
ModelName string `json:"modelName"`
ModelID string `json:"modelId"`
RegionsSupported []string `json:"regionsSupported"`
InputModalities []string `json:"inputModalities"`
OutputModalities []string `json:"outputModalities"`
StreamingSupported bool `json:"streamingSupported"`
}
BedrockModel represents an AWS Bedrock model
type BedrockModelSearchResult ¶
type BedrockModelSearchResult struct {
Models []BedrockModel `json:"models"`
TotalCount int `json:"totalCount"`
}
BedrockModelSearchResult represents search results for AWS Bedrock models
type CargoToml ¶ added in v0.28.0
type CargoToml struct {
Dependencies map[string]any `json:"dependencies,omitempty"`
DevDependencies map[string]any `json:"dev-dependencies,omitempty"`
BuildDependencies map[string]any `json:"build-dependencies,omitempty"`
}
CargoToml represents dependencies in a Cargo.toml file
type CooldownConfig ¶ added in v0.53.0
CooldownConfig holds the cooldown configuration
func GetCooldownConfig ¶ added in v0.53.0
func GetCooldownConfig() *CooldownConfig
GetCooldownConfig returns the cooldown configuration from environment variables
func (*CooldownConfig) GetCooldownDuration ¶ added in v0.53.0
func (c *CooldownConfig) GetCooldownDuration() time.Duration
GetCooldownDuration returns the cooldown duration
func (*CooldownConfig) IsEcosystemCooldownEnabled ¶ added in v0.53.0
func (c *CooldownConfig) IsEcosystemCooldownEnabled(ecosystem string) bool
IsEcosystemCooldownEnabled checks if cooldown is enabled for a specific ecosystem
type CooldownInfo ¶ added in v0.53.0
type CooldownInfo struct {
Applied bool `json:"applied"`
Reason string `json:"reason,omitempty"`
NewerVersion *string `json:"newerVersion,omitempty"`
PublishedAt *string `json:"publishedAt,omitempty"`
CooldownEndsAt *string `json:"cooldownEndsAt,omitempty"`
}
CooldownInfo contains information about cooldown applied to a version
func ApplyCooldown ¶ added in v0.53.0
func ApplyCooldown( logger *logrus.Logger, client HTTPClient, ecosystem string, packageName string, versions []VersionWithDate, latestVersion string, ) (string, *CooldownInfo, error)
ApplyCooldown applies cooldown logic to a list of versions and returns the appropriate version Returns: selected version, cooldown info, error
type DockerImageQuery ¶
type DockerImageQuery struct {
Image string `json:"image"`
Registry string `json:"registry,omitempty"`
CustomRegistry string `json:"customRegistry,omitempty"`
Limit int `json:"limit,omitempty"`
FilterTags []string `json:"filterTags,omitempty"`
IncludeDigest bool `json:"includeDigest,omitempty"`
}
DockerImageQuery represents a query for Docker image tags
type DockerImageVersion ¶
type DockerImageVersion struct {
Name string `json:"name"`
Tag string `json:"tag"`
Registry string `json:"registry"`
Digest *string `json:"digest,omitempty"`
Created *string `json:"created,omitempty"`
Size *string `json:"size,omitempty"`
}
DockerImageVersion represents version information for a Docker image
type GitHubAction ¶
type GitHubAction struct {
Owner string `json:"owner"`
Repo string `json:"repo"`
CurrentVersion *string `json:"currentVersion,omitempty"`
}
GitHubAction represents a GitHub Action
type GitHubActionVersion ¶
type GitHubActionVersion struct {
Owner string `json:"owner"`
Repo string `json:"repo"`
CurrentVersion *string `json:"currentVersion,omitempty"`
LatestVersion string `json:"latestVersion"`
PublishedAt *string `json:"publishedAt,omitempty"`
URL *string `json:"url,omitempty"`
}
GitHubActionVersion represents version information for a GitHub Action
type GoModule ¶
type GoModule struct {
Module string `json:"module"`
Require []GoRequire `json:"require,omitempty"`
Replace []GoReplace `json:"replace,omitempty"`
}
GoModule represents a Go module in a go.mod file
type GoReplace ¶
type GoReplace struct {
Old string `json:"old"`
New string `json:"new"`
Version string `json:"version,omitempty"`
}
GoReplace represents a replacement in a go.mod file
type GradleDependency ¶
type GradleDependency struct {
Configuration string `json:"configuration"`
Group string `json:"group"`
Name string `json:"name"`
Version string `json:"version,omitempty"`
}
GradleDependency represents a dependency in a Gradle build.gradle file
type HTTPClient ¶
HTTPClient is an interface for making HTTP requests
var ( // DefaultHTTPClient is the default HTTP client with rate limiting DefaultHTTPClient HTTPClient = NewRateLimitedHTTPClient() )
type MavenDependency ¶
type MavenDependency struct {
GroupID string `json:"groupId"`
ArtifactID string `json:"artifactId"`
Version string `json:"version,omitempty"`
Scope string `json:"scope,omitempty"`
}
MavenDependency represents a dependency in a Maven pom.xml file
type NpmDependencies ¶
NpmDependencies represents dependencies in a package.json file
type PackageDetails ¶ added in v0.28.0
type PackageDetails struct {
// Common metadata fields
Description *string `json:"description,omitempty"`
Homepage *string `json:"homepage,omitempty"`
Repository *string `json:"repository,omitempty"`
Documentation *string `json:"documentation,omitempty"`
License *string `json:"license,omitempty"`
Downloads *int64 `json:"downloads,omitempty"`
CreatedAt *string `json:"createdAt,omitempty"`
UpdatedAt *string `json:"updatedAt,omitempty"`
PublishedAt *string `json:"publishedAt,omitempty"`
NumVersions *int `json:"numVersions,omitempty"`
Keywords []string `json:"keywords,omitempty"`
Publisher *string `json:"publisher,omitempty"`
// Ecosystem-specific metadata
Rust *RustDetails `json:"rust,omitempty"`
}
PackageDetails contains detailed metadata about a package
type PackageVersion ¶
type PackageVersion struct {
Name string `json:"name"`
CurrentVersion *string `json:"currentVersion,omitempty"`
LatestVersion string `json:"latestVersion"`
Registry string `json:"registry"`
Skipped bool `json:"skipped,omitempty"`
SkipReason string `json:"skipReason,omitempty"`
Details *PackageDetails `json:"details,omitempty"`
Cooldown *CooldownInfo `json:"cooldown,omitempty"`
}
PackageVersion represents version information for a package
type PyProjectDependencies ¶
type PyProjectDependencies struct {
Dependencies map[string]string `json:"dependencies,omitempty"`
OptionalDependencies map[string]map[string]string `json:"optional-dependencies,omitempty"`
DevDependencies map[string]string `json:"dev-dependencies,omitempty"`
}
PyProjectDependencies represents dependencies in a pyproject.toml file
type RateLimitedHTTPClient ¶ added in v0.21.1
type RateLimitedHTTPClient struct {
// contains filtered or unexported fields
}
RateLimitedHTTPClient implements HTTPClient with rate limiting
func NewRateLimitedHTTPClient ¶ added in v0.21.1
func NewRateLimitedHTTPClient() *RateLimitedHTTPClient
NewRateLimitedHTTPClient creates a new rate-limited HTTP client with proxy support
type RustCrate ¶ added in v0.28.0
type RustCrate struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
Source string `json:"source,omitempty"` // e.g., "registry+https://github.com/rust-lang/crates.io-index"
}
RustCrate represents a Rust crate dependency
type RustDetails ¶ added in v0.28.0
type RustDetails struct {
Edition *string `json:"edition,omitempty"`
RustVersion *string `json:"rustVersion,omitempty"`
CrateSize *int64 `json:"crateSize,omitempty"`
Categories []string `json:"categories,omitempty"`
RecentDownloads *int64 `json:"recentDownloads,omitempty"`
}
RustDetails contains Rust-specific package metadata
type SwiftDependency ¶
type SwiftDependency struct {
URL string `json:"url"`
Version string `json:"version,omitempty"`
Requirement string `json:"requirement,omitempty"`
}
SwiftDependency represents a dependency in a Swift Package.swift file
type VersionConstraint ¶
type VersionConstraint struct {
MajorVersion *int `json:"majorVersion,omitempty"`
ExcludePackage bool `json:"excludePackage,omitempty"`
}
VersionConstraint represents constraints for package version updates
type VersionConstraints ¶
type VersionConstraints map[string]VersionConstraint
VersionConstraints maps package names to their constraints
type VersionWithDate ¶ added in v0.53.0
VersionWithDate pairs a version string with its publish date