Documentation
¶
Overview ¶
Package custom implements user-defined mod sources configured declaratively via YAML files in <configDir>/sources/. See the design doc: docs/plans/2026-07-13-custom-sources-design.md
Index ¶
- Constants
- func New(def SourceDefinition) (source.ModSource, error)
- type APIConfig
- type Directory
- func (d *Directory) AuthURL() string
- func (d *Directory) Capabilities() source.Capabilities
- func (d *Directory) CheckUpdates(ctx context.Context, installed []domain.InstalledMod) ([]domain.Update, error)
- func (d *Directory) ExchangeToken(ctx context.Context, code string) (*source.Token, error)
- func (d *Directory) GetDependencies(ctx context.Context, mod *domain.Mod) ([]domain.ModReference, error)
- func (d *Directory) GetDownloadURL(ctx context.Context, mod *domain.Mod, fileID string) (string, error)
- func (d *Directory) GetMod(ctx context.Context, gameID, modID string) (*domain.Mod, error)
- func (d *Directory) GetModFiles(ctx context.Context, mod *domain.Mod) ([]domain.DownloadableFile, error)
- func (d *Directory) ID() string
- func (d *Directory) Name() string
- func (d *Directory) Search(ctx context.Context, query source.SearchQuery) (source.SearchResult, error)
- type DirectoryConfig
- type ManifestConfig
- type SourceDefinition
Constants ¶
const ( TypeDirectory = "directory" TypeManifest = "manifest" TypeAPI = "api" )
Source type identifiers for SourceDefinition.Type.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIConfig ¶
type APIConfig struct {
BaseURL string `yaml:"base_url"`
}
APIConfig configures a declarative REST source (expanded in Phase 4).
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
Directory is a ModSource backed by a local directory: each subdirectory (or .zip/.jar archive) is one mod. The directory is rescanned on each operation so edits show up without restarting lmm; scans are local and cheap.
func NewDirectory ¶
func NewDirectory(def SourceDefinition) (*Directory, error)
NewDirectory constructs a directory source from a validated definition. The configured path must exist and be a directory.
func (*Directory) Capabilities ¶
func (d *Directory) Capabilities() source.Capabilities
Capabilities implements source.CapabilityReporter.
func (*Directory) CheckUpdates ¶
func (d *Directory) CheckUpdates(ctx context.Context, installed []domain.InstalledMod) ([]domain.Update, error)
CheckUpdates implements source.ModSource by comparing installed versions to the current scan.
func (*Directory) ExchangeToken ¶
ExchangeToken implements source.ModSource.
func (*Directory) GetDependencies ¶
func (d *Directory) GetDependencies(ctx context.Context, mod *domain.Mod) ([]domain.ModReference, error)
GetDependencies implements source.ModSource; directory mods declare none.
func (*Directory) GetDownloadURL ¶
func (d *Directory) GetDownloadURL(ctx context.Context, mod *domain.Mod, fileID string) (string, error)
GetDownloadURL implements source.ModSource, returning a file:// URL that Service.DownloadModToCache ingests by local copy instead of HTTP download.
func (*Directory) GetMod ¶
GetMod implements source.ModSource. gameID is accepted from any game and not used to look up the mod (see Search); it is echoed onto the returned mod so downstream installs are attributed to the correct game.
func (*Directory) GetModFiles ¶
func (d *Directory) GetModFiles(ctx context.Context, mod *domain.Mod) ([]domain.DownloadableFile, error)
GetModFiles implements source.ModSource: every mod has exactly one synthetic file ("main") representing its directory or archive.
func (*Directory) Search ¶
func (d *Directory) Search(ctx context.Context, query source.SearchQuery) (source.SearchResult, error)
Search implements source.ModSource with client-side matching: case-insensitive substring on name and summary; name matches rank first, then alphabetical. GameID is accepted from any game (a directory source applies to any game that maps it — it does not filter by GameID) but is echoed onto every returned mod so downstream installs are attributed to the correct game.
type DirectoryConfig ¶
type DirectoryConfig struct {
Path string `yaml:"path"`
}
DirectoryConfig configures a local-directory source.
type ManifestConfig ¶
type ManifestConfig struct {
URL string `yaml:"url"`
Refresh string `yaml:"refresh"` // Go duration string, e.g. "15m"; empty = default
}
ManifestConfig configures a manifest source (Phase 3).
type SourceDefinition ¶
type SourceDefinition struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Type string `yaml:"type"`
AllowHTTP bool `yaml:"allow_http"`
Directory *DirectoryConfig `yaml:"directory"`
Manifest *ManifestConfig `yaml:"manifest"`
API *APIConfig `yaml:"api"`
}
SourceDefinition is one user-defined source, parsed from a YAML file in <configDir>/sources/. Exactly one of Directory/Manifest/API must be set, matching Type.
func (*SourceDefinition) Validate ¶
func (d *SourceDefinition) Validate() error
Validate checks the definition for structural errors. It does not touch the filesystem or network; existence checks happen when the source is constructed.