Documentation
¶
Index ¶
- Constants
- type Identity
- type Persona
- func (p *Persona) AppendMemoryEntry(entry string) error
- func (p *Persona) Dir() string
- func (p *Persona) GetIdentity() *Identity
- func (p *Persona) GetIdentityRaw() string
- func (p *Persona) GetMemory() string
- func (p *Persona) GetSection(section string) (content string, editable, agentMutable, ok bool)
- func (p *Persona) GetSoul() string
- func (p *Persona) GetUser() string
- func (p *Persona) IsAgentMutable(section string) bool
- func (p *Persona) IsEditable(section string) bool
- func (p *Persona) IsEditableUnlocked(section string) bool
- func (p *Persona) RemoveMemoryEntry(heading string) error
- func (p *Persona) Save(section, content string) error
- func (p *Persona) Sections() map[string]bool
- func (p *Persona) SystemPrompt() string
- func (p *Persona) UpdateMemory(content string) error
Constants ¶
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 ¶
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
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) AppendMemoryEntry ¶ added in v0.18.0
AppendMemoryEntry reads the current MEMORY.md, appends a new entry separated by "---", and writes the result back. If memory is currently empty the entry is written without a separator. The entire read-modify-write is atomic.
func (*Persona) Dir ¶
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
GetIdentity returns the parsed Identity (may be nil).
func (*Persona) GetIdentityRaw ¶ added in v0.16.9
GetIdentityRaw returns the raw IDENTITY.md content for API round-tripping.
func (*Persona) GetSection ¶ added in v0.16.9
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) IsAgentMutable ¶ added in v0.13.0
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 ¶
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
IsEditableUnlocked is like IsEditable but does not acquire the lock. Caller must hold at least mu.RLock.
func (*Persona) RemoveMemoryEntry ¶ added in v0.18.0
RemoveMemoryEntry finds and removes a memory entry whose first line starts with "## <heading>" (case-insensitive match). Entries are separated by blank- line-surrounded "---" lines. Returns an error if no matching entry is found. The entire read-modify-write is atomic.
func (*Persona) Save ¶
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.
The write lock is held for the entire operation (file I/O + in-memory update) so that read-modify-write callers like AppendMemoryEntry can use saveLocked without a race window. This means concurrent readers (GetMemory, etc.) block during file I/O — acceptable at current concurrency levels but worth revisiting if persona access ever becomes a hot path.
func (*Persona) Sections ¶ added in v0.16.9
Sections returns which sections have content, keyed by section name.
func (*Persona) SystemPrompt ¶
SystemPrompt assembles the persona into a single system prompt string.
func (*Persona) UpdateMemory ¶
UpdateMemory replaces MEMORY.md with the given content. It is shorthand for Save("memory", content).