extensions

package
v0.9.39 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package extensions discovers trusted local CSS/JavaScript web extensions. Reload captures assets in memory so a document never mixes partially edited files.

Index

Constants

View Source
const MaxBytes = 32 << 20
View Source
const MaxFiles = 512
View Source
const SettingsFile = "extensions.yaml"

SettingsFile is deliberately inside the extension directory, not the main term-llm configuration directory. Builders need no credential/config access.

Variables

This section is empty.

Functions

func ReadSettings

func ReadSettings(dir string) (data []byte, exists bool, err error)

func SettingsBytes

func SettingsBytes(previous []byte, ids []string) ([]byte, error)

SettingsBytes updates only the enabled list, preserving comments/other YAML presentation without ever loading or rewriting the main config file.

func ValidID

func ValidID(id string) bool

func ValidateEnabled

func ValidateEnabled(ids []string) error

func WriteSettings

func WriteSettings(dir string, data []byte) error

WriteSettings atomically replaces the directory entry via os.Root. In particular, even a racing symlink cannot redirect this write into main config.

Types

type Entry

type Entry struct {
	Manifest
	ID    string `json:"id"`
	Error string `json:"error,omitempty"`
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Asset

func (m *Manager) Asset(generation, name string) ([]byte, bool)

func (*Manager) Reload

func (m *Manager) Reload(dir string, ids []string, source string, disabled bool, revision, configPath string) error

func (*Manager) Status

func (m *Manager) Status() Snapshot

Status returns a detached copy; callers must not mutate the active snapshot.

type Manifest

type Manifest struct {
	Title         string `yaml:"title" json:"title"`
	Description   string `yaml:"description" json:"description"`
	FormatVersion int    `yaml:"format_version" json:"format_version"`
	CSS           string `yaml:"css" json:"css,omitempty"`
	JS            string `yaml:"js" json:"js,omitempty"`
}

type Settings

type Settings struct {
	Enabled []string `yaml:"enabled"`
}

func ParseSettings

func ParseSettings(data []byte) (Settings, error)

type Snapshot

type Snapshot struct {
	Directory      string   `json:"directory"`
	Enabled        []string `json:"enabled"`
	Entries        []Entry  `json:"entries"`
	Errors         []string `json:"errors"`
	Generation     string   `json:"generation"`
	Source         string   `json:"source"`
	Disabled       bool     `json:"disabled"`
	ConfigRevision string   `json:"config_revision"`
	ConfigPath     string   `json:"config_path"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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