persona

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package persona handles loading and managing persona definitions.

Index

Constants

View Source
const MaxDescriptionLen = 500

MaxDescriptionLen is the maximum length, in runes, of a persona description.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles persona loading and retrieval.

func NewManager

func NewManager(personaPath string) (*Manager, error)

NewManager creates a new persona manager. If personaPath is empty, creates an empty manager.

func NewManagerWithBuiltins added in v0.200.0

func NewManagerWithBuiltins(builtinFS fs.ReadDirFS, personaPath string) (*Manager, error)

NewManagerWithBuiltins creates a persona manager that first loads built-in personas from the provided embed.FS, then overlays any user-defined personas from personaPath. personaPath may be empty (only built-ins will be loaded).

func (*Manager) ApplyPersona

func (m *Manager) ApplyPersona(personaName, prompt string) string

ApplyPersona prepends persona content to the given prompt. If persona is empty or not found, returns the original prompt.

func (*Manager) Description added in v1.2.7

func (m *Manager) Description(name string) string

Description returns a short natural-language description of when the persona applies. It uses the front matter "description" when present, otherwise the persona's first heading or non-empty line. The result has collapsed whitespace and is at most MaxDescriptionLen runes. Returns empty string for unknown personas.

func (*Manager) Descriptions added in v1.2.7

func (m *Manager) Descriptions() map[string]string

Descriptions returns a copy of the name -> description map for all loaded personas.

func (*Manager) GetActivePersona added in v0.200.0

func (m *Manager) GetActivePersona() string

GetActivePersona returns the currently active persona name. Empty string means no persona is manually set (auto-select or none).

func (*Manager) GetPersona

func (m *Manager) GetPersona(name string) string

GetPersona returns the content of a persona by name, without any front matter. Returns empty string if persona not found.

func (*Manager) GetPersonaMCPConfig

func (m *Manager) GetPersonaMCPConfig(name string) string

GetPersonaMCPConfig returns the path to the persona's associated MCP config file. Returns empty string if the persona has no associated MCP config.

func (*Manager) HasPersona

func (m *Manager) HasPersona(name string) bool

HasPersona checks if a persona exists.

func (*Manager) ListPersonas

func (m *Manager) ListPersonas() []string

ListPersonas returns a sorted list of available persona names.

func (*Manager) SetActivePersona added in v0.200.0

func (m *Manager) SetActivePersona(name string)

SetActivePersona sets the manually selected persona. Pass empty string to clear the active persona (revert to auto-select or none).

Directories

Path Synopsis
Package builtin provides embedded built-in persona definitions.
Package builtin provides embedded built-in persona definitions.

Jump to

Keyboard shortcuts

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