Documentation
¶
Overview ¶
* ChatCLI - Persona System * pkg/persona/builder.go * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Persona System * pkg/persona/loader.go * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Persona System * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Persona System * pkg/persona/types.go * Copyright (c) 2024 Edilson Freitas * License: MIT
Index ¶
- func InferExecutionCommand(scriptName, absPath string) string
- type Agent
- type Builder
- type ComposedPrompt
- type LoadResult
- type Loader
- func (l *Loader) EnsureDirectories() error
- func (l *Loader) GetAgent(name string) (*Agent, error)
- func (l *Loader) GetAgentsDir() string
- func (l *Loader) GetSkill(name string) (*Skill, error)
- func (l *Loader) GetSkillsDir() string
- func (l *Loader) ListAgents() ([]*Agent, error)
- func (l *Loader) ListSkills() ([]*Skill, error)
- func (l *Loader) SetProjectDir(dir string)
- type Manager
- func (m *Manager) AttachAgent(name string) (*LoadResult, error)
- func (m *Manager) DetachAgent(name string) error
- func (m *Manager) GetActiveAgent() *Agent
- func (m *Manager) GetActiveAgents() []*Agent
- func (m *Manager) GetActivePrompt() *ComposedPrompt
- func (m *Manager) GetAgentsDir() string
- func (m *Manager) GetLoader() *Loader
- func (m *Manager) GetSkill(name string) (*Skill, error)
- func (m *Manager) GetSkillsDir() string
- func (m *Manager) GetSystemPrompt() string
- func (m *Manager) HasActiveAgent() bool
- func (m *Manager) Initialize() error
- func (m *Manager) ListAgents() ([]*Agent, error)
- func (m *Manager) ListSkills() ([]*Skill, error)
- func (m *Manager) LoadAgent(name string) (*LoadResult, error)
- func (m *Manager) RefreshSkills() ([]*Skill, error)
- func (m *Manager) SetProjectDir(dir string)
- func (m *Manager) UnloadAgent()
- func (m *Manager) UnloadAllAgents()
- func (m *Manager) ValidateAgent(name string) ([]string, []string, error)
- type Skill
- type StringList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InferExecutionCommand ¶ added in v1.62.0
inferExecutionCommand guesses the best command to run a script based on extension
Types ¶
type Agent ¶
type Agent struct {
// Metadata from frontmatter
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Skills StringList `json:"skills" yaml:"skills"` // Usando StringList para robustez
Plugins StringList `json:"plugins" yaml:"plugins"` // Usando StringList para robustez
Tools StringList `json:"tools" yaml:"tools"` // Allowed tools for worker mode (Read, Grep, Glob, Bash, Write, Edit)
Model string `json:"model" yaml:"model"`
// Content is the markdown body (without frontmatter)
Content string `json:"-" yaml:"-"`
// Path to the source file
Path string `json:"-" yaml:"-"`
}
Agent represents a loadable persona with skills
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder assembles system prompts from agents and skills
func NewBuilder ¶
NewBuilder creates a new prompt builder
func (*Builder) BuildMultiAgentPrompt ¶ added in v1.49.0
func (b *Builder) BuildMultiAgentPrompt(agents []*Agent) (*ComposedPrompt, error)
BuildMultiAgentPrompt assembles a prompt for multiple agents simultaneously
func (*Builder) BuildSystemPrompt ¶
func (b *Builder) BuildSystemPrompt(agentName string) (*ComposedPrompt, error)
BuildSystemPrompt legacy wrapper for single agent
type ComposedPrompt ¶
type ComposedPrompt struct {
ActiveAgents []string // List of active agent names
SkillsLoaded []string
SkillsMissing []string
FullPrompt string
}
ComposedPrompt represents the final assembled system prompt
type LoadResult ¶
type LoadResult struct {
Agent *Agent
LoadedSkills []string // Skills that were successfully loaded
MissingSkills []string // Skills that were not found
Warnings []string // Non-fatal issues
}
LoadResult represents the result of loading an agent with its skills
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading agents and skills from disk
func (*Loader) EnsureDirectories ¶
EnsureDirectories creates the agents and skills directories if they don't exist
func (*Loader) GetAgent ¶
GetAgent returns an agent by name. It prioritizes: 1. Project-local agent file (.agent/agents/{name}.md) 2. Project-local agent by metadata search 3. Global agent file (~/.chatcli/agents/{name}.md) 4. Global agent by metadata search
func (*Loader) GetAgentsDir ¶
GetAgentsDir returns the path to the agents directory
func (*Loader) GetSkill ¶
GetSkill locates and loads a skill by name. It prioritizes: 1. Project-local Package (Folder with SKILL.md) 2. Project-local File (.md) 3. Global Package 4. Global File
func (*Loader) GetSkillsDir ¶
GetSkillsDir returns the path to the skills directory
func (*Loader) ListAgents ¶
ListAgents returns all available agents scanning both project-local and global directories. Priority: Project Local (.agent/agents/) > Global (~/.chatcli/agents/)
func (*Loader) ListSkills ¶
ListSkills returns all available skills (names only for listing purposes) It performs a shallow scan of both project-local and global directories.
func (*Loader) SetProjectDir ¶
SetProjectDir sets an optional project-local directory for skills lookup Priority: Project Local > Global
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the active persona state
func NewManager ¶
NewManager creates a new persona manager
func (*Manager) AttachAgent ¶ added in v1.49.0
func (m *Manager) AttachAgent(name string) (*LoadResult, error)
AttachAgent adds an agent to the active pool without removing others
func (*Manager) DetachAgent ¶ added in v1.49.0
DetachAgent removes a specific agent
func (*Manager) GetActiveAgent ¶
GetActiveAgent returns the first active agent (legacy compatibility)
func (*Manager) GetActiveAgents ¶ added in v1.49.0
GetActiveAgents returns list of active agents
func (*Manager) GetActivePrompt ¶
func (m *Manager) GetActivePrompt() *ComposedPrompt
GetActivePrompt returns the composed prompt for the active agent
func (*Manager) GetAgentsDir ¶
GetAgentsDir returns the path to the agents directory
func (*Manager) GetLoader ¶ added in v1.62.0
GetLoader returns the underlying loader for advanced callers (e.g., the worker system).
func (*Manager) GetSkill ¶ added in v1.62.0
GetSkill loads a skill by name, delegating to the loader.
func (*Manager) GetSkillsDir ¶
GetSkillsDir returns the path to the skills directory
func (*Manager) GetSystemPrompt ¶
GetSystemPrompt returns the full system prompt string for the active agent
func (*Manager) HasActiveAgent ¶
HasActiveAgent returns true if an agent is currently loaded
func (*Manager) Initialize ¶
Initialize sets up the persona system (creates directories if needed)
func (*Manager) ListAgents ¶
ListAgents returns all available agents
func (*Manager) ListSkills ¶
ListSkills returns all available skills
func (*Manager) LoadAgent ¶
func (m *Manager) LoadAgent(name string) (*LoadResult, error)
LoadAgent (Legacy/Reset Mode): Clears all agents and loads specific one
func (*Manager) RefreshSkills ¶ added in v1.66.0
RefreshSkills re-scans skill directories to pick up newly installed or removed skills.
func (*Manager) SetProjectDir ¶
SetProjectDir sets the project directory for local skills
func (*Manager) UnloadAgent ¶
func (m *Manager) UnloadAgent()
UnloadAgent (legacy) - alias for backward compatibility
func (*Manager) UnloadAllAgents ¶ added in v1.49.0
func (m *Manager) UnloadAllAgents()
UnloadAllAgents (antigo UnloadAgent) clears everything
type Skill ¶
type Skill struct {
// Metadata from frontmatter
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Tools StringList `json:"allowed-tools" yaml:"allowed-tools"` // Usando StringList
// Content is the markdown body (without frontmatter)
Content string `json:"-" yaml:"-"`
// Path to the root directory of this skill
Dir string `json:"-" yaml:"-"`
// Path to the source file (legacy or main file)
Path string `json:"-" yaml:"-"`
// Subskills mapeia "nomearquivo.md" -> caminho absoluto
Subskills map[string]string `json:"subskills" yaml:"-"`
// Scripts mapeia "scripts/nomescript.py" -> caminho absoluto
Scripts map[string]string `json:"scripts" yaml:"-"`
}
Skill represents a reusable knowledge/compliance module
type StringList ¶
type StringList []string
StringList é um tipo auxiliar que permite que o usuário escreva no YAML tanto uma lista de strings quanto uma string única separada por vírgulas. Ex: skills: [a, b] OU skills: a, b, c
func (*StringList) UnmarshalYAML ¶
func (sl *StringList) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implementa a interface yaml.Unmarshaler para flexibilidade