Documentation
¶
Overview ¶
Package themefile is the pi theme JSON resource format: parsing, validation, variable resolution, and path discovery. It is headless: the agent resource loader and HTML export read it, and agent/modes/theme renders it.
Index ¶
- Variables
- func ANSI256ToHex(index int) string
- func CleanPath(path string) string
- func Discover(cwd string, paths []string) ([]*Theme, []Diagnostic)
- func HexColors(colors map[string]Color, defaultColor string) map[string]string
- func ParseHex(value string) (int, int, int, error)
- func ResolvePaths(paths []string, base string) []string
- type Collision
- type Color
- type ColorValue
- type Diagnostic
- type Loader
- type Theme
Constants ¶
This section is empty.
Variables ¶
var RequiredColors = []string{
"accent", "border", "borderAccent", "borderMuted", "success", "error", "warning", "muted", "dim", "text", "thinkingText",
"selectedBg", "userMessageBg", "userMessageText", "customMessageBg", "customMessageText", "customMessageLabel", "toolPendingBg", "toolSuccessBg", "toolErrorBg", "toolTitle", "toolOutput",
"mdHeading", "mdLink", "mdLinkUrl", "mdCode", "mdCodeBlock", "mdCodeBlockBorder", "mdQuote", "mdQuoteBorder", "mdHr", "mdListBullet",
"toolDiffAdded", "toolDiffRemoved", "toolDiffContext", "syntaxComment", "syntaxKeyword", "syntaxFunction", "syntaxVariable", "syntaxString", "syntaxNumber", "syntaxType", "syntaxOperator", "syntaxPunctuation",
"thinkingOff", "thinkingMinimal", "thinkingLow", "thinkingMedium", "thinkingHigh", "thinkingXhigh", "bashMode",
}
RequiredColors are the tokens every theme file must define.
Functions ¶
func ANSI256ToHex ¶
ANSI256ToHex maps a 256-color palette index to its xterm hex value.
func Discover ¶
func Discover(cwd string, paths []string) ([]*Theme, []Diagnostic)
Discover loads the themes under paths (relative ones resolved against cwd): first name wins, and diagnostics list load warnings before collisions.
func ResolvePaths ¶
ResolvePaths cleans paths, joining relative ones onto base.
Types ¶
type Color ¶
Color is a resolved theme color: a 256-color palette index, or hex text where "" means the terminal default.
type ColorValue ¶
ColorValue is a theme JSON color: #rgb/#rrggbb, oklch(), okhsl(), a variable name, "" for the terminal default, or a 256-color index.
func (*ColorValue) UnmarshalJSON ¶
func (value *ColorValue) UnmarshalJSON(data []byte) error
type Diagnostic ¶
func CollisionDiagnostic ¶
func CollisionDiagnostic(name, winnerPath, loserPath string) Diagnostic
CollisionDiagnostic reports loser losing its name to an earlier winner.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader walks theme paths in pi's discovery order. Each root is walked once; unreadable, missing, or invalid entries become warnings, and every parsed theme goes to the caller, which owns name collisions.
func (*Loader) LoadDefaultDirectory ¶
LoadDefaultDirectory walks path only when it is an existing directory.
func (*Loader) Warnings ¶
func (loader *Loader) Warnings() []Diagnostic
Warnings returns the load warnings in discovery order.
type Theme ¶
type Theme struct {
Name string
// Appearance is the theme's declared "dark" or "light" look, if any.
Appearance string
SourcePath string
// Keys are the color tokens the file defines, in file order.
Keys []string
Colors map[string]Color
Export map[string]Color
}
Theme is a parsed theme resource with every color reference resolved.