mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-15 12:15:16 +00:00
feat: complete HomeAgent architecture v2
- IO abstraction layer with OutputChannel routing and capability validation - Three-layer memory (Context-Document-Graph) with TF-IDF relevance pruning - OneBot V11 QQ protocol plugin with Reverse WebSocket client - Plugin system with hot-reload (SKILL.md + native factories) - Knowledge system with TF-IDF vector indexing - Personality system (personal.md) - Text memory (JSONL with rotation) - Change tracker (overlayfs) with rollback - Lua adapter VM - Design document (DESIGN.md) Module: gitcode.com/JianFeeeee/HomeAgent
This commit is contained in:
41
internal/agent/personal.go
Normal file
41
internal/agent/personal.go
Normal file
@ -0,0 +1,41 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type Personality struct {
|
||||
Content string
|
||||
Path string
|
||||
}
|
||||
|
||||
func LoadPersonality(path string) (*Personality, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return &Personality{}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("read personal.md: %w", err)
|
||||
}
|
||||
return &Personality{
|
||||
Content: string(data),
|
||||
Path: path,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func SavePersonality(path, content string) error {
|
||||
dir := filepath.Dir(path)
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return fmt.Errorf("create personality dir: %w", err)
|
||||
}
|
||||
return os.WriteFile(path, []byte(content), 0644)
|
||||
}
|
||||
|
||||
func (p *Personality) InjectPrompt() string {
|
||||
if p.Content == "" {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("【人格设定】\n%s\n", p.Content)
|
||||
}
|
||||
Reference in New Issue
Block a user