persona

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPrompt = "You are Denkeeper, a helpful personal AI assistant."

DefaultPrompt is the fallback system prompt when no persona files are available.

Variables

This section is empty.

Functions

This section is empty.

Types

type Persona

type Persona struct {
	Soul   string // SOUL.md content (required)
	User   string // USER.md content (optional)
	Memory string // MEMORY.md content (optional)

	// Editable tracks which sections the agent can modify without elevated permissions.
	// true = freely writable; false = requires approval or elevated permissions.
	Editable map[string]bool
	// contains filtered or unexported fields
}

Persona holds the content of persona definition files.

func Load

func Load(dir string) (*Persona, error)

Load reads persona files from the given directory. SOUL.md is required and must be non-empty. USER.md and MEMORY.md are optional.

func (*Persona) Dir

func (p *Persona) Dir() string

Dir returns the directory the persona was loaded from. Empty string means no write path is available.

func (*Persona) IsEditable

func (p *Persona) IsEditable(section string) bool

IsEditable reports whether the agent can modify the given section without elevated permissions. Unknown sections are treated as not editable (returns false).

func (*Persona) MemoryUpdateInstruction

func (p *Persona) MemoryUpdateInstruction() string

MemoryUpdateInstruction returns the system prompt fragment that instructs the agent how to signal a memory update. Returns an empty string if no write path is available (dir not set or memory is not editable).

func (*Persona) Save

func (p *Persona) Save(section, content string) error

Save writes content to the named section file atomically and updates the in-memory state. section must be one of "memory", "user", or "soul". Returns an error if the persona was not loaded from a directory.

func (*Persona) SystemPrompt

func (p *Persona) SystemPrompt() string

SystemPrompt assembles the persona into a single system prompt string.

func (*Persona) UpdateMemory

func (p *Persona) UpdateMemory(content string) error

UpdateMemory replaces MEMORY.md with the given content. It is shorthand for Save("memory", content).

func (*Persona) UserUpdateInstruction

func (p *Persona) UserUpdateInstruction(tier string) string

UserUpdateInstruction returns the system prompt fragment that instructs the agent how to request a USER.md update via a [USER_UPDATE] directive. Returns an empty string if the persona has no write path or the tier is "restricted" (which cannot write user files).

Jump to

Keyboard shortcuts

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