71 lines
No EOL
1.8 KiB
Markdown
71 lines
No EOL
1.8 KiB
Markdown
# pkg/persona
|
|
|
|
> Configurable personality system for LLM agents.
|
|
|
|
## Responsibility
|
|
|
|
Assemble the agent's final system prompt by combining:
|
|
|
|
1. **Base prompt** (hardcoded in the library)
|
|
2. **Persona YAML** (configurable per project)
|
|
3. **AGENTS.md** (project instructions, discovered by searching up the directory tree)
|
|
4. **Working memory context** (summaries if there's compaction)
|
|
|
|
## Public API
|
|
|
|
```go
|
|
type Persona struct {
|
|
ID string
|
|
Name string
|
|
Tone string
|
|
Style string
|
|
Language string
|
|
Constraints []string
|
|
FewShot []llm.Message
|
|
}
|
|
|
|
type Loader interface {
|
|
Load(ctx context.Context, configPath string) (Persona, error)
|
|
Discover(ctx context.Context, workdir string) (Persona, error) // includes AGENTS.md
|
|
}
|
|
```
|
|
|
|
## YAML format
|
|
|
|
```yaml
|
|
id: pragmatist
|
|
name: Pragmatist
|
|
tone: "Direct and professional"
|
|
style: "Idiomatic Go approach"
|
|
language: "English, with Spanish when needed"
|
|
constraints:
|
|
- "Don't use interface{} in new code (use any)"
|
|
- "Always wrap errors with %w"
|
|
few_shot:
|
|
- role: user
|
|
content: "Refactor this code"
|
|
- role: assistant
|
|
content: "Done. Optimized. Apply?"
|
|
```
|
|
|
|
## AGENTS.md discovery
|
|
|
|
The loader searches for `./AGENTS.md`, walks up to the parent directory, etc., concatenating all found until reaching `~` or `/`. Also includes `~/.config/rony/AGENTS.md` as a global default.
|
|
|
|
```
|
|
/home/user/project/AGENTS.md ← includes
|
|
/home/user/AGENTS.md ← includes
|
|
/home/AGENTS.md ← includes
|
|
~/.config/rony/AGENTS.md ← includes
|
|
```
|
|
|
|
## Usage
|
|
|
|
```go
|
|
p, err := persona.Discover(ctx, "/home/user/my-project")
|
|
// p.Content includes all of the above concatenated
|
|
```
|
|
|
|
## See also
|
|
|
|
- [pkg/agent](../agent/README.md) — Uses the persona in the system prompt |