71 lines
1.8 KiB
Markdown
71 lines
1.8 KiB
Markdown
|
|
# pkg/persona
|
||
|
|
|
||
|
|
> Sistema de personalidades configurables para agentes LLM.
|
||
|
|
|
||
|
|
## Responsabilidad
|
||
|
|
|
||
|
|
Ensamblar el system prompt final del agente combinando:
|
||
|
|
|
||
|
|
1. **Base prompt** (hardcoded en la librería)
|
||
|
|
2. **Persona YAML** (configurable por proyecto)
|
||
|
|
3. **AGENTS.md** (instrucciones del proyecto, descubierto por búsqueda en árbol de directorios)
|
||
|
|
4. **Working memory context** (resúmenes si hay compaction)
|
||
|
|
|
||
|
|
## API pública
|
||
|
|
|
||
|
|
```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) // incluye AGENTS.md
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
## Formato YAML
|
||
|
|
|
||
|
|
```yaml
|
||
|
|
id: pragmatista
|
||
|
|
name: Pragmatista
|
||
|
|
tone: "Directo y profesional"
|
||
|
|
style: "Enfoque Go idiomatic"
|
||
|
|
language: "Español, con términos técnicos en inglés"
|
||
|
|
constraints:
|
||
|
|
- "No usar interface{} en código nuevo"
|
||
|
|
- "Siempre wrapped errors con %w"
|
||
|
|
few_shot:
|
||
|
|
- role: user
|
||
|
|
content: "Refactoriza este código"
|
||
|
|
- role: assistant
|
||
|
|
content: "Listo. Optimizado. ¿Aplico?"
|
||
|
|
```
|
||
|
|
|
||
|
|
## AGENTS.md discovery
|
||
|
|
|
||
|
|
El loader busca `./AGENTS.md`, sube al directorio padre, etc., concatenando todos los encontrados hasta llegar a `~` o `/`. También incluye `~/.config/rony/AGENTS.md` como default global.
|
||
|
|
|
||
|
|
```
|
||
|
|
/home/user/proyecto/AGENTS.md ← incluye
|
||
|
|
/home/user/AGENTS.md ← incluye
|
||
|
|
/home/AGENTS.md ← incluye
|
||
|
|
~/.config/rony/AGENTS.md ← incluye
|
||
|
|
```
|
||
|
|
|
||
|
|
## Uso
|
||
|
|
|
||
|
|
```go
|
||
|
|
p, err := persona.Discover(ctx, "/home/user/mi-proyecto")
|
||
|
|
// p.Content incluye todo lo anterior concatenado
|
||
|
|
```
|
||
|
|
|
||
|
|
## Ver también
|
||
|
|
|
||
|
|
- [pkg/agent](../agent/README.md) — Usa la persona en el system prompt
|