Introduces a comprehensive agent management system and a new research interface within the cockpit. This includes backend API endpoints for CRUD operations on agents, a new agent lifecycle manager, and frontend components for managing agents, skills, and research workflows. - feat(backend): add REST API for agent lifecycle management (list, create, update, delete, import) - feat(backend): implement `pkg/agent/manager` for agent lifecycle control - feat(gateway): register agent API routes in the gateway - feat(frontend): add cockpit tabs for Agents, Skills, and Research - feat(frontend): implement AgentsPage and ResearchPage components - feat(frontend): add `use-agents` and `use-cockpit-skills` hooks - docs: add Agent Management API documentation and update project map - refactor(tools): update ToolSkill metadata handling and regex parsing
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// pkg/tools/toolskill.go
|
|
package tools
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"regexp"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type ToolSkill struct {
|
|
Name string `yaml:"name"`
|
|
Description string `yaml:"description"`
|
|
Type string `yaml:"type"`
|
|
Tags []string `yaml:"tags"`
|
|
Version string `yaml:"version"`
|
|
UsageCount int `yaml:"usage_count"`
|
|
LastUsed string `yaml:"last_used"`
|
|
Metadata map[string]interface{} `yaml:",inline"`
|
|
}
|
|
|
|
// LoadToolSkill reads a tool skill file and parses it
|
|
func LoadToolSkill(filePath string) (*ToolSkill, error) {
|
|
data, err := ioutil.ReadFile(filePath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var skill ToolSkill
|
|
if err := yaml.Unmarshal(data, &skill); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// Extract tags from content if not in frontmatter
|
|
if len(skill.Tags) == 0 {
|
|
skill.Tags = extractTagsFromContent(string(data))
|
|
}
|
|
|
|
return &skill, nil
|
|
}
|
|
|
|
// extractTagsFromContent extracts tags from markdown content
|
|
func extractTagsFromContent(content string) []string {
|
|
// Look for #tag patterns
|
|
re := regexp.MustCompile(`#([a-zA-Z0-9_-]+)`)
|
|
matches := re.FindAllStringSubmatch(content, -1)
|
|
tags := make([]string, 0, len(matches))
|
|
for _, m := range matches {
|
|
tags = append(tags, m[1])
|
|
}
|
|
return tags
|
|
}
|