persona

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName        = "ccpersona.json"
	LegacyPersonaFileName = "persona.json"
	LegacyVoiceConfigName = "config.json"
	ClaudeDir             = ".claude"
	AgentsDir             = ".agents"
	CodexDir              = ".codex"
	CursorDir             = ".cursor"
	DirPermission         = 0755
	FilePermission        = 0600
)
View Source
const (
	PlatformClaudeCode = "claude-code"
	PlatformCodex      = "codex"
	PlatformCursor     = "cursor"
)

Platform identifiers for platform-specific configuration.

Variables

This section is empty.

Functions

func ConfigPath added in v0.1.21

func ConfigPath(baseDir string) string

ConfigPath returns the canonical ccpersona config path under baseDir.

func GetGlobalConfigDir added in v0.1.11

func GetGlobalConfigDir(platform string) string

GetGlobalConfigDir returns the canonical global config directory.

func HandleSessionStart

func HandleSessionStart() error

HandleSessionStart is the main entry point for hook functionality This is a convenience wrapper for HandleSessionStartForPlatform with empty platform.

func HandleSessionStartForPlatform added in v0.1.10

func HandleSessionStartForPlatform(platform string) error

HandleSessionStartForPlatform is the main entry point for hook functionality with platform support

func MigrateConfig added in v0.1.21

func MigrateConfig(baseDir string, force bool) (string, error)

MigrateConfig merges legacy persona and voice config files into .agents/ccpersona.json under baseDir.

func SaveConfig

func SaveConfig(projectPath string, config *Config) error

SaveConfig saves unified configuration to .agents/ccpersona.json.

func ValidateConfig

func ValidateConfig(config *Config) error

ValidateConfig checks if the unified configuration is valid.

Types

type Config

type Config struct {
	Name               string                            `json:"name"`
	Voice              *VoiceConfig                      `json:"voice,omitempty"`
	CustomInstructions string                            `json:"custom_instructions,omitempty"`
	Engines            map[string]voice.EngineUserConfig `json:"engines,omitempty"`
}

Config represents the persona configuration for a project

func GetDefaultConfig

func GetDefaultConfig() *Config

GetDefaultConfig returns a default persona configuration.

func LoadConfig

func LoadConfig(projectPath string) (*Config, error)

LoadConfig loads unified ccpersona configuration from the specified project.

func LoadConfigForPlatform added in v0.1.10

func LoadConfigForPlatform(projectPath, platform string) (*Config, error)

LoadConfigForPlatform loads unified configuration from .agents/ccpersona.json. Platform is accepted for call-site compatibility, but no longer changes the path: the unified config is shared across Claude Code, Codex, Cursor, and MCP.

func LoadConfigFromPath added in v0.1.21

func LoadConfigFromPath(path string) (*Config, error)

LoadConfigFromPath loads a specific unified config file strictly.

func LoadConfigWithFallback added in v0.1.8

func LoadConfigWithFallback() (*Config, error)

LoadConfigWithFallback loads configuration from the current directory, falling back to ~/.agents/ccpersona.json.

func LoadConfigWithFallbackForPlatform added in v0.1.10

func LoadConfigWithFallbackForPlatform(platform string) (*Config, error)

LoadConfigWithFallbackForPlatform loads unified project config first, then unified global config. Broken files are reported to stderr and ignored so runtime paths such as voice synthesis can continue with built-in defaults.

func (*Config) ToVoiceConfigFile added in v0.1.21

func (c *Config) ToVoiceConfigFile() *voice.ConfigFile

ToVoiceConfigFile projects the unified config onto the voice resolver's file representation. The new schema has one active voice block, so it becomes the provider-specific config for voice.provider.

func (*Config) ToVoiceInput added in v0.1.21

func (c *Config) ToVoiceInput() voice.PersonaVoiceInput

ToVoiceInput converts the unified config into the small resolver input used for persona-level precedence.

type Definition

type Definition struct {
	Name          string            `json:"name"`
	Description   string            `json:"description"`
	FilePath      string            `json:"file_path"`
	Tone          string            `json:"tone"`
	Approach      string            `json:"approach"`
	Specialties   []string          `json:"specialties"`
	DialogueStyle string            `json:"dialogue_style"`
	Values        map[string]string `json:"values"`
}

Definition represents a persona definition

type Manager

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

Manager handles persona operations

func NewManager

func NewManager() (*Manager, error)

NewManager creates a new persona manager

func (*Manager) CreatePersona

func (m *Manager) CreatePersona(name string) error

CreatePersona creates a new persona from a template

func (*Manager) GetCurrentPersona

func (m *Manager) GetCurrentPersona() (string, error)

GetCurrentPersona returns the currently configured persona name from persona.json

func (*Manager) GetPersonaPath

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

GetPersonaPath returns the full path to a persona file

func (*Manager) ListPersonas

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

ListPersonas returns all available personas

func (*Manager) PersonaExists

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

PersonaExists checks if a persona exists

func (*Manager) ReadPersona

func (m *Manager) ReadPersona(name string) (string, error)

ReadPersona reads and returns the raw content of a persona file (including front matter).

func (*Manager) ReadPersonaForContext added in v0.1.15

func (m *Manager) ReadPersonaForContext(name string) (string, error)

ReadPersonaForContext reads a persona file and strips YAML front matter, returning only the body intended as AI context.

type PersonaFile

type PersonaFile struct {
	Title          string
	Tone           string
	Approach       string
	Values         string
	CustomSections map[string]string
}

PersonaFile represents the structure of a persona markdown file

type VoiceConfig

type VoiceConfig struct {
	Provider string  `json:"provider,omitempty"`
	Speaker  int     `json:"speaker,omitempty"`
	Volume   float64 `json:"volume,omitempty"`
	Speed    float64 `json:"speed,omitempty"`

	APIKey string `json:"api_key,omitempty"`
	Voice  string `json:"voice,omitempty"`
	Model  string `json:"model,omitempty"`
	Format string `json:"format,omitempty"`

	Host           string `json:"host,omitempty"`
	Port           int    `json:"port,omitempty"`
	BaseURL        string `json:"base_url,omitempty"`
	TimeoutSeconds int    `json:"timeout_seconds,omitempty"`

	Stability       float64 `json:"stability,omitempty"`
	SimilarityBoost float64 `json:"similarity_boost,omitempty"`
	Style           float64 `json:"style,omitempty"`
	UseSpeakerBoost *bool   `json:"use_speaker_boost,omitempty"`

	Region     string `json:"region,omitempty"`
	Engine     string `json:"engine,omitempty"`
	SampleRate string `json:"sample_rate,omitempty"`
}

VoiceConfig represents the active voice synthesis settings for a persona.

func (*VoiceConfig) ToProviderConfig added in v0.1.21

func (v *VoiceConfig) ToProviderConfig() voice.ProviderConfig

ToProviderConfig converts the active voice block into provider-specific TTS settings.

Jump to

Keyboard shortcuts

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