spec

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManifestVersion = "1.0.0"
)

Format version constants

Variables

This section is empty.

Functions

func CalculateSHA256FromBytes

func CalculateSHA256FromBytes(data []byte) string

CalculateSHA256FromBytes calculates SHA-256 hash of byte data

func GetGlobalCacheDir

func GetGlobalCacheDir() string

GetGlobalCacheDir returns the global cache directory

func ValidateManifest

func ValidateManifest(manifest *Manifest) []error

ValidateManifest validates a manifest

func WriteManifest

func WriteManifest(path string, manifest *Manifest) error

WriteManifest writes a manifest to a file

Types

type Lockfile

type Lockfile struct {
	Version   string
	Entries   []LockfileEntry
	Timestamp time.Time
	TotalSize int64
}

Lockfile represents the lockfile (spec.sum) that contains resolved dependencies

func NewLockfile

func NewLockfile(version string) *Lockfile

NewLockfile creates a new lockfile

func ReadLockfile

func ReadLockfile(path string) (*Lockfile, error)

Read reads a lockfile from disk

func (*Lockfile) AddEntry

func (l *Lockfile) AddEntry(entry LockfileEntry)

AddEntry adds an entry to the lockfile

func (*Lockfile) CalculateSHA256

func (l *Lockfile) CalculateSHA256() (string, error)

CalculateSHA256 calculates the SHA-256 hash of the lockfile content

func (*Lockfile) GetContentHash

func (l *Lockfile) GetContentHash(repoURL, specPath string) (string, bool)

GetContentHash retrieves the content hash for a dependency

func (*Lockfile) GetEntry

func (l *Lockfile) GetEntry(repoURL, specPath string) (*LockfileEntry, bool)

GetEntry retrieves an entry from the lockfile

func (*Lockfile) GetRepositoryEntries

func (l *Lockfile) GetRepositoryEntries(repoURL string) []LockfileEntry

GetRepositoryEntries retrieves all entries for a given repository

func (*Lockfile) RemoveEntry

func (l *Lockfile) RemoveEntry(repoURL, specPath string) bool

RemoveEntry removes an entry from the lockfile

func (*Lockfile) Verify

func (l *Lockfile) Verify(manifest *Manifest) ([]string, error)

Verify verifies that the lockfile content matches the current content

func (*Lockfile) Write

func (l *Lockfile) Write(path string) error

Write writes the lockfile to disk

type LockfileEntry

type LockfileEntry struct {
	RepositoryURL string `json:"repository_url"`
	CommitHash    string `json:"commit_hash"`
	ContentHash   string `json:"content_hash"`
	SpecPath      string `json:"spec_path"`
	Branch        string `json:"branch,omitempty"`
	Size          int64  `json:"size"`
	FetchedAt     string `json:"fetched_at"`
}

LockfileEntry represents a single entry in the lockfile

type Manifest

type Manifest struct {
	Version     string
	Dependecies []models.Dependency
	ID          string
	Path        string
	UpdatedAt   time.Time
}

Manifest represents the parsed spec.mod file

func ParseManifest

func ParseManifest(path string) (*Manifest, error)

ParseManifest parses a spec.mod file

type ResolveResult

type ResolveResult struct {
	Dependency  *models.Dependency
	CommitHash  string
	Content     []byte
	ContentHash string
	Size        int64
	Source      string
}

ResolveResult represents the result of a dependency resolution

type Resolver

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

Resolver resolves dependencies by fetching specs from Git repositories

func NewResolver

func NewResolver(projectCacheDir string) *Resolver

NewResolver creates a new resolver with global cache directory

func (*Resolver) GetCachePath

func (r *Resolver) GetCachePath(dep models.Dependency, commitHash string) string

GetCachePath returns the cache path for a dependency This can be used by LLMs to read cached specs

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, manifest *Manifest, noCache bool) ([]ResolveResult, error)

Resolve resolves all dependencies in the manifest

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error returns the error message

Jump to

Keyboard shortcuts

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