Documentation
¶
Overview ¶
Package config loads and merges repolens configuration.
Two trust domains (ADR-005): the in-repo .repolens.yml may only affect rendering (site, ignore, render, rules, theme, view, agent), while source, output and access are honored only from the external --config file and CLI flags. Precedence: CLI > external config > in-repo config > defaults. Render rules cascade in order, later rules overriding earlier ones. View.TOCPanel accepts "floating" or "inline"; invalid values are reported as warnings and rendered with the floating fallback by site assembly. View.Search is a site-level browser UI switch and does not cascade.
Index ¶
- Variables
- func Load(repoRoot, externalPath string, flags Flags) (*Config, []Warning, error)
- type Access
- type Agent
- type AgentFullText
- type CodeOptions
- type Config
- type Encrypt
- type FileOptions
- type Flags
- type HTMLOptions
- type MarkdownOptions
- type Output
- type RepositoryAgentFullTextSettings
- type RepositoryAgentSettings
- type RepositoryByteSize
- type RepositoryCodeOptionsSettings
- type RepositoryDocument
- func (d *RepositoryDocument) AddRule(rule RepositoryRuleSettings) error
- func (d *RepositoryDocument) Apply(settings RepositorySettings) error
- func (d *RepositoryDocument) MoveRule(from, to int) error
- func (d *RepositoryDocument) RemoveRule(index int) error
- func (d *RepositoryDocument) Write() error
- func (d *RepositoryDocument) YAML() ([]byte, error)
- type RepositoryFileOptionsSettings
- type RepositoryHTMLOptionsSettings
- type RepositoryMarkdownOptionsSettings
- type RepositoryRuleSettings
- type RepositorySettings
- type RepositorySiteSettings
- type RepositoryThemeSettings
- type RepositoryValidationError
- type RepositoryValidationIssue
- type RepositoryViewSettings
- type Rule
- type Site
- type Source
- type Theme
- type View
- type Warning
Constants ¶
This section is empty.
Variables ¶
var ErrRevisionConflict = errors.New("repository configuration revision conflict")
ErrRevisionConflict reports that a repository configuration changed after it was loaded and before it could be written.
Functions ¶
Types ¶
type Agent ¶
type Agent struct {
LLMSTxt bool `yaml:"llms_txt"`
LLMSFull AgentFullText `yaml:"llms_full"`
IndexJSON bool `yaml:"index_json"`
}
Agent configures machine-readable outputs.
type AgentFullText ¶
AgentFullText configures llms-full.txt.
type CodeOptions ¶
CodeOptions configures code rendering.
type Config ¶
type Config struct {
Source Source `yaml:"source"`
Output Output `yaml:"output"`
Access Access `yaml:"access"`
Site Site `yaml:"site"`
Ignore []string `yaml:"ignore"`
Render FileOptions `yaml:"render"`
Rules []Rule `yaml:"rules"`
Theme Theme `yaml:"theme"`
View View `yaml:"view"`
Agent Agent `yaml:"agent"`
}
Config is the fully merged repolens configuration.
func (*Config) OptionsFor ¶
func (c *Config) OptionsFor(filePath string) FileOptions
OptionsFor returns the effective rendering options for a repo-relative path.
type Encrypt ¶
type Encrypt struct {
Enabled bool `yaml:"enabled"`
Paths []string `yaml:"paths"`
PasswordEnv string `yaml:"password_env"`
}
Encrypt reserves the v1 client-side encryption schema.
type FileOptions ¶
type FileOptions struct {
Render bool `yaml:"render"`
Markdown MarkdownOptions `yaml:"markdown"`
HTML HTMLOptions `yaml:"html"`
Code CodeOptions `yaml:"code"`
MaxFileSize int64 `yaml:"max_file_size"`
}
FileOptions are the effective rendering options for one file.
type HTMLOptions ¶
type HTMLOptions struct {
View string `yaml:"view"`
}
HTMLOptions configures browser pages for HTML files.
type MarkdownOptions ¶
type MarkdownOptions struct {
TOC bool `yaml:"toc"`
TOCMinHeadings int `yaml:"toc_min_headings"`
Anchors bool `yaml:"anchors"`
Mermaid bool `yaml:"mermaid"`
Math bool `yaml:"math"`
FrontmatterTitle bool `yaml:"frontmatter_title"`
}
MarkdownOptions configures Markdown rendering.
type RepositoryAgentFullTextSettings ¶ added in v1.2.0
type RepositoryAgentFullTextSettings struct {
Enabled *bool `yaml:"enabled" json:"enabled"`
MaxSize *RepositoryByteSize `yaml:"max_size" json:"max_size"`
}
RepositoryAgentFullTextSettings contains editable llms-full options.
type RepositoryAgentSettings ¶ added in v1.2.0
type RepositoryAgentSettings struct {
LLMSTxt *bool `yaml:"llms_txt" json:"llms_txt"`
LLMSFull RepositoryAgentFullTextSettings `yaml:"llms_full" json:"llms_full"`
IndexJSON *bool `yaml:"index_json" json:"index_json"`
}
RepositoryAgentSettings contains the editable agent output fields.
type RepositoryByteSize ¶ added in v1.2.0
type RepositoryByteSize int64
RepositoryByteSize is a byte count accepted in either numeric form or the human-readable form used by .repolens.yml, such as "5MB".
func (*RepositoryByteSize) UnmarshalYAML ¶ added in v1.2.0
func (s *RepositoryByteSize) UnmarshalYAML(raw []byte) error
UnmarshalYAML accepts the same byte-size notation as the merged config.
type RepositoryCodeOptionsSettings ¶ added in v1.2.0
type RepositoryCodeOptionsSettings struct {
LineNumbers *bool `yaml:"line_numbers" json:"line_numbers"`
Theme *string `yaml:"theme" json:"theme"`
}
RepositoryCodeOptionsSettings contains editable code rendering options.
type RepositoryDocument ¶ added in v1.2.0
type RepositoryDocument struct {
Path string
Revision string
Settings RepositorySettings
// contains filtered or unexported fields
}
RepositoryDocument is the unmerged .repolens.yml document in a repository. Its Settings expose only the UI-controlled fields. The remaining YAML AST is retained so unknown fields and unsupported configuration sections survive a settings update.
func LoadRepositoryDocument ¶ added in v1.2.0
func LoadRepositoryDocument(repoRoot string) (*RepositoryDocument, error)
LoadRepositoryDocument reads the repository-local .repolens.yml without merging defaults or trusted external configuration. A missing file is an empty document with the revision of empty content.
func (*RepositoryDocument) AddRule ¶ added in v1.2.0
func (d *RepositoryDocument) AddRule(rule RepositoryRuleSettings) error
AddRule appends a rendering rule while preserving the existing rule order.
func (*RepositoryDocument) Apply ¶ added in v1.2.0
func (d *RepositoryDocument) Apply(settings RepositorySettings) error
Apply updates the editable repository settings. It leaves trusted-only, unknown, and omitted editable YAML nodes unchanged.
func (*RepositoryDocument) MoveRule ¶ added in v1.2.0
func (d *RepositoryDocument) MoveRule(from, to int) error
MoveRule moves the rendering rule at from to its final position at to.
func (*RepositoryDocument) RemoveRule ¶ added in v1.2.0
func (d *RepositoryDocument) RemoveRule(index int) error
RemoveRule removes the rendering rule at index.
func (*RepositoryDocument) Write ¶ added in v1.2.0
func (d *RepositoryDocument) Write() error
Write atomically commits the current document if the file revision has not changed since LoadRepositoryDocument. It updates Revision on success.
func (*RepositoryDocument) YAML ¶ added in v1.2.0
func (d *RepositoryDocument) YAML() ([]byte, error)
YAML returns the current document as YAML. It is intended for displaying a candidate write before Write is called.
type RepositoryFileOptionsSettings ¶ added in v1.2.0
type RepositoryFileOptionsSettings struct {
Render *bool `yaml:"render" json:"render"`
Markdown RepositoryMarkdownOptionsSettings `yaml:"markdown" json:"markdown"`
HTML RepositoryHTMLOptionsSettings `yaml:"html" json:"html"`
Code RepositoryCodeOptionsSettings `yaml:"code" json:"code"`
MaxFileSize *RepositoryByteSize `yaml:"max_file_size" json:"max_file_size"`
}
RepositoryFileOptionsSettings contains editable global rendering options. Its fields are pointers so an omitted field can be distinguished from an explicit false, zero, or empty value.
type RepositoryHTMLOptionsSettings ¶ added in v1.2.0
type RepositoryHTMLOptionsSettings struct {
View *string `yaml:"view" json:"view"`
}
RepositoryHTMLOptionsSettings contains editable HTML rendering options.
type RepositoryMarkdownOptionsSettings ¶ added in v1.2.0
type RepositoryMarkdownOptionsSettings struct {
TOC *bool `yaml:"toc" json:"toc"`
TOCMinHeadings *int `yaml:"toc_min_headings" json:"toc_min_headings"`
Anchors *bool `yaml:"anchors" json:"anchors"`
Mermaid *bool `yaml:"mermaid" json:"mermaid"`
Math *bool `yaml:"math" json:"math"`
FrontmatterTitle *bool `yaml:"frontmatter_title" json:"frontmatter_title"`
}
RepositoryMarkdownOptionsSettings contains editable Markdown options.
type RepositoryRuleSettings ¶ added in v1.2.0
type RepositoryRuleSettings struct {
Match *string `yaml:"match" json:"match"`
Render *bool `yaml:"render" json:"render"`
Markdown RepositoryMarkdownOptionsSettings `yaml:"markdown" json:"markdown"`
HTML RepositoryHTMLOptionsSettings `yaml:"html" json:"html"`
Code RepositoryCodeOptionsSettings `yaml:"code" json:"code"`
MaxFileSize *RepositoryByteSize `yaml:"max_file_size" json:"max_file_size"`
}
RepositoryRuleSettings contains one ordered repository rendering rule. It intentionally contains only the fields accepted by the configuration schema; unknown YAML fields remain in the document AST when rules are updated through RepositoryDocument.
type RepositorySettings ¶ added in v1.2.0
type RepositorySettings struct {
Site RepositorySiteSettings `yaml:"site" json:"site"`
Ignore *[]string `yaml:"ignore" json:"ignore"`
Render RepositoryFileOptionsSettings `yaml:"render" json:"render"`
Rules *[]RepositoryRuleSettings `yaml:"rules" json:"rules"`
Theme RepositoryThemeSettings `yaml:"theme" json:"theme"`
View RepositoryViewSettings `yaml:"view" json:"view"`
Agent RepositoryAgentSettings `yaml:"agent" json:"agent"`
}
RepositorySettings is the subset of repository configuration editable by the UI. A nil leaf is absent from a patch and leaves the existing YAML value unchanged. A non-nil leaf replaces the corresponding YAML value.
type RepositorySiteSettings ¶ added in v1.2.0
type RepositorySiteSettings struct {
Title *string `yaml:"title" json:"title"`
Language *string `yaml:"language" json:"language"`
Home *string `yaml:"home" json:"home"`
}
RepositorySiteSettings contains the editable site metadata fields.
type RepositoryThemeSettings ¶ added in v1.2.0
type RepositoryThemeSettings struct {
Vars *map[string]string `yaml:"vars" json:"vars"`
CSS *string `yaml:"css" json:"css"`
Templates *string `yaml:"templates" json:"templates"`
}
RepositoryThemeSettings contains editable repository theme inputs.
type RepositoryValidationError ¶ added in v1.2.0
type RepositoryValidationError struct {
Issues []RepositoryValidationIssue
}
RepositoryValidationError groups the issues found while validating editable repository settings.
func (*RepositoryValidationError) Error ¶ added in v1.2.0
func (e *RepositoryValidationError) Error() string
type RepositoryValidationIssue ¶ added in v1.2.0
RepositoryValidationIssue describes one invalid editable field. Path uses YAML-style notation, for example rules[1].match.
func ValidateRepositoryDocument ¶ added in v1.2.0
func ValidateRepositoryDocument(document *RepositoryDocument) []RepositoryValidationIssue
ValidateRepositoryDocument validates the editable settings of document.
func ValidateRepositorySettings ¶ added in v1.2.0
func ValidateRepositorySettings(settings RepositorySettings) []RepositoryValidationIssue
ValidateRepositorySettings checks only fields editable in the repository trust domain. Unknown YAML nodes and prohibited trust-domain sections are intentionally outside this validation surface.
type RepositoryViewSettings ¶ added in v1.2.0
type RepositoryViewSettings struct {
TreePosition *string `yaml:"tree_position" json:"tree_position"`
TreeExpandDepth *int `yaml:"tree_expand_depth" json:"tree_expand_depth"`
TOCPanel *string `yaml:"toc_panel" json:"toc_panel"`
Search *bool `yaml:"search" json:"search"`
}
RepositoryViewSettings contains the editable browser view fields.
type Rule ¶
type Rule struct {
Match string `yaml:"match"`
Render *bool `yaml:"render"`
Markdown *MarkdownOptions `yaml:"markdown"`
HTML *HTMLOptions `yaml:"html"`
Code *CodeOptions `yaml:"code"`
MaxFileSize *int64 `yaml:"max_file_size"`
// contains filtered or unexported fields
}
Rule applies file option overrides to paths matching Match.
Option fields hold only what the rule explicitly sets; unset fields are Go zero values, not effective defaults. Always resolve effective options through Config.OptionsFor rather than reading these fields directly.
type Site ¶
type Site struct {
Title string `yaml:"title"`
Language string `yaml:"language"`
Home string `yaml:"home"`
}
Site configures site-level metadata.
type Theme ¶
type Theme struct {
Vars map[string]string `yaml:"vars"`
CSS string `yaml:"css"`
Templates string `yaml:"templates"`
}
Theme configures user-overridable theme inputs.
type View ¶
type View struct {
TreePosition string `yaml:"tree_position"`
TreeExpandDepth int `yaml:"tree_expand_depth"`
// TOCPanel controls Markdown TOC placement: "floating" or "inline".
TOCPanel string `yaml:"toc_panel"`
// Search controls the browser-layer filename and heading search UI.
Search bool `yaml:"search"`
}
View configures browser UI layout.