Documentation
¶
Overview ¶
Package config loads and validates Ghost's TOML configuration.
Index ¶
- Constants
- Variables
- func RenderPrompt(text string, d PromptData) (string, error)
- func SaveViews(path string, views []View) error
- func ViewsPath(configPath string) string
- func WriteDefaults(configPath string) ([]string, error)
- type Agent
- type AutoApprove
- type Config
- type Duration
- type PromptData
- type View
Constants ¶
const ViewsFileName = "views.toml"
ViewsFileName holds the views Ghost manages from the TUI. It sits next to config.toml, which Ghost never writes (so its comments survive).
Variables ¶
var DefaultConfigTOML string
var DefaultPrompt string
DefaultPrompt is used by agents that set neither prompt nor prompt_file.
var KnownAgentKinds = map[string]bool{"claude": true}
KnownAgentKinds lists the agent implementations Ghost can run.
Functions ¶
func RenderPrompt ¶
func RenderPrompt(text string, d PromptData) (string, error)
RenderPrompt executes a review prompt template against d.
func SaveViews ¶
SaveViews replaces views.toml with views, atomically and durably: it writes a synced temp file next to the real file and renames it over it. A symlinked views.toml (dotfile managers) stays a symlink, and an existing file keeps its permissions.
func WriteDefaults ¶
WriteDefaults writes a starter config and prompt beside configPath, skipping any file that already exists. It returns the files it created.
Types ¶
type AutoApprove ¶
type AutoApprove struct {
Enabled bool `toml:"enabled"`
RequireConfirm bool `toml:"require_confirm"`
RequireCIGreen bool `toml:"require_ci_green"`
NoChecksIsGreen bool `toml:"no_checks_is_green"`
NoBlockingComments bool `toml:"no_blocking_comments"`
NoChangesRequested bool `toml:"no_changes_requested"`
MaxChangedLines int `toml:"max_changed_lines"`
}
type Config ¶
type Config struct {
PollInterval Duration `toml:"poll_interval"`
MaxConcurrentReviews int `toml:"max_concurrent_reviews"`
MaxDailyCostUSD float64 `toml:"max_daily_cost_usd"`
MaxCostPerReviewUSD float64 `toml:"max_cost_per_review_usd"`
PostMode string `toml:"post_mode"`
Theme string `toml:"theme"`
DefaultAgent string `toml:"default_agent"`
Agents map[string]Agent `toml:"agents"`
AutoApprove AutoApprove `toml:"auto_approve"`
Views []View `toml:"view"`
// contains filtered or unexported fields
}
func Default ¶
func Default() Config
Default returns the configuration used for any key the file leaves unset.
func (*Config) AgentPrompt ¶
AgentPrompt returns the raw prompt template text for the named agent: inline prompt, else the contents of prompt_file, else DefaultPrompt.
func (*Config) ThemesDir ¶
ThemesDir is where user theme files live: <config dir>/themes. It is empty for a config that wasn't loaded from a file.
func (*Config) Validate ¶
Validate checks the config and reports every problem at once. When exactly one agent is defined and default_agent is unset, it becomes the default.
func (*Config) ValidateThemes ¶
ValidateThemes loads the theme files and checks that the configured theme exists. It is separate from Validate because only the TUI and --check use themes; a broken theme file shouldn't stop ghost review.
func (*Config) ValidateViews ¶
ValidateViews checks only the views (names, queries, agent references), so saving a view isn't blocked by an unrelated file that broke after startup.
type Duration ¶
Duration is a time.Duration that reads from TOML strings like "5m".
func (Duration) MarshalText ¶
func (*Duration) UnmarshalText ¶
type PromptData ¶
type PromptData struct {
Repo string
Number int
Title string
Author string
Body string
BaseRef string
HeadRef string
HeadSHA string
URL string
ChangedFiles []string
}
PromptData holds the variables available to review prompt templates.
type View ¶
type View struct {
Name string `toml:"name"`
Query string `toml:"query"`
AutoReview bool `toml:"auto_review"`
Agent string `toml:"agent,omitempty"`
// Source is the file that defined the view: "config.toml" or
// "views.toml". Only views.toml views are edited from the TUI.
Source string `toml:"-"`
}