Documentation
¶
Overview ¶
Package image provides auto-detection of Docker base images based on workspace language/framework signals.
Package image provides version parsing and normalization for language version detection.
Index ¶
Constants ¶
const DefaultImage = "ghcr.io/holon-run/holon-base:0.3.0"
DefaultImage is the fallback Docker image used when no language signal is detected.
Variables ¶
This section is empty.
Functions ¶
func FormatResult ¶
func FormatResult(result *DetectResult) string
FormatResult formats a DetectResult as a human-readable string.
func NormalizeVersionRange ¶
NormalizeVersionRange attempts to normalize a version range to a specific version. For broad ranges (e.g., "^1.0.0", ">=2"), it returns a suggested LTS version. Returns empty string if the range is too broad and a default should be used.
Types ¶
type DebugDetectResult ¶ added in v0.6.0
type DebugDetectResult struct {
*DetectResult
// ScannedSignals lists all signals found during scanning
ScannedSignals []SignalMatch `json:"scanned_signals"`
// VersionInfo contains version detection details
VersionInfo *VersionDebugInfo `json:"version_info,omitempty"`
// FileCount is the total number of files scanned
FileCount int `json:"file_count"`
// DurationMs is how long the detection took
DurationMs int64 `json:"duration_ms"`
// ScanMode indicates which scanning strategy was used (root-only or full-recursive)
ScanMode string `json:"scan_mode"`
}
DebugDetectResult contains detailed detection information for debugging.
type DetectResult ¶
type DetectResult struct {
Image string // Detected Docker image (e.g., image.DefaultImage)
Signals []string // List of signals that contributed to this detection
Rationale string // Human-readable explanation of the detection
Disabled bool // True if auto-detection is disabled
}
DetectResult contains the detected image and detection rationale.
func Detect ¶
func Detect(workspace string) *DetectResult
Detect is a convenience function that detects the image for a workspace.
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector detects the appropriate Docker base image for a workspace.
func NewDetector ¶
NewDetector creates a new Detector for the given workspace path.
func (*Detector) Detect ¶
func (d *Detector) Detect() *DetectResult
Detect analyzes the workspace to determine an appropriate base image. If no strong signal is detected, returns a safe default. Attempts to detect language versions from project files.
func (*Detector) DetectDebug ¶ added in v0.6.0
func (d *Detector) DetectDebug() *DebugDetectResult
DetectDebug performs detection with detailed debug information.
type SignalMatch ¶ added in v0.6.0
type SignalMatch struct {
Name string `json:"name"`
Priority int `json:"priority"`
Path string `json:"path"`
Found bool `json:"found"`
}
SignalMatch represents a found signal with location info.
type Version ¶
Version represents a parsed language version with major, minor, and patch components.
func ParseVersion ¶
ParseVersion parses a version string and returns a Version struct. Supports various version formats: - "1.22" -> {Major: 1, Minor: 22, Patch: 0} - "1.22.0" -> {Major: 1, Minor: 22, Patch: 0} - "22" -> {Major: 22, Minor: 0, Patch: 0}
func (*Version) Compare ¶
Compare compares two versions. Returns: -1 if v < other, 0 if v == other, 1 if v > other
func (*Version) ImageString ¶
ImageString returns the version formatted for Docker image tags. For most languages, this is "major.minor", but some languages use just major (Node.js).
type VersionDebugInfo ¶ added in v0.6.0
type VersionDebugInfo struct {
Language string `json:"language"`
Version string `json:"version"`
SourceFile string `json:"source_file"`
SourceField string `json:"source_field"`
LineNumber int `json:"line_number"`
RawValue string `json:"raw_value"`
}
VersionDebugInfo contains version detection details for debugging.