persona

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 6 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 Identity added in v0.16.5

type Identity struct {
	Name  string `yaml:"name"`
	Emoji string `yaml:"emoji"`
	Theme string `yaml:"theme"`
	Body  string `yaml:"-"` // markdown body after frontmatter
}

Identity holds the parsed YAML frontmatter and body from IDENTITY.md.

type Persona

type Persona struct {

	// 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. All exported fields are guarded by mu; callers must use the accessor methods or hold the lock.

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 NewEmpty added in v0.13.0

func NewEmpty(dir string) *Persona

NewEmpty creates a writable Persona with no content. The directory is created on first Save if it does not exist. Use this when the persona directory is known but no files exist yet, so the user can create sections from the dashboard.

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) GetIdentity added in v0.16.9

func (p *Persona) GetIdentity() *Identity

GetIdentity returns the parsed Identity (may be nil).

func (*Persona) GetIdentityRaw added in v0.16.9

func (p *Persona) GetIdentityRaw() string

GetIdentityRaw returns the raw IDENTITY.md content for API round-tripping.

func (*Persona) GetMemory added in v0.16.9

func (p *Persona) GetMemory() string

GetMemory returns the MEMORY.md content.

func (*Persona) GetSection added in v0.16.9

func (p *Persona) GetSection(section string) (content string, editable, agentMutable, ok bool)

GetSection returns the content for the given section, whether the section is user-editable, whether the agent can mutate it, and whether it exists.

func (*Persona) GetSoul added in v0.16.9

func (p *Persona) GetSoul() string

GetSoul returns the SOUL.md content.

func (*Persona) GetUser added in v0.16.9

func (p *Persona) GetUser() string

GetUser returns the USER.md content.

func (*Persona) IdentityUpdateInstruction added in v0.16.5

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

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

func (*Persona) IsAgentMutable added in v0.13.0

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

IsAgentMutable reports whether the agent itself can modify the given section. "memory" is always agent-mutable; "identity", "user" and "soul" require supervised/autonomous tier (via approval or directive).

func (*Persona) IsEditable

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

IsEditable reports whether the section can be edited via the dashboard/API by the user. Unknown sections are treated as not editable (returns false).

func (*Persona) IsEditableUnlocked added in v0.16.9

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

IsEditableUnlocked is like IsEditable but does not acquire the lock. Caller must hold at least mu.RLock.

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 "identity", "memory", "user", or "soul". Returns an error if the persona was not loaded from a directory.

func (*Persona) Sections added in v0.16.9

func (p *Persona) Sections() map[string]bool

Sections returns which sections have content, keyed by section name.

func (*Persona) SoulUpdateInstruction added in v0.14.0

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

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

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