orca.ai/pkg/skill/skill.go
大森 e18dde7c15 feat: implement TUI with bubbletea and multi-agent collaboration
- Add bubbletea/lipgloss/glamour dependencies for TUI
- Create internal/tui package with EventWriter, styles, and bubbletea Model
- Support streaming output display in conversation window
- Add right panel with statistics and active agent status
- Implement multi-agent collaboration with sub-agents
- Add AgentCallTool for delegating tasks to sub-agents
- Support parallel tool execution with goroutines
- Auto-discover sub-agents from ~/.orca/prompts/ directory
- Fix orchestrator routing based on msg.To field
- Add non-blocking event writer with timeout to prevent blocking
2026-05-10 14:28:17 +08:00

56 lines
1.9 KiB
Go

// Package skill 提供 Skill 定义和管理系统。
//
// 技能是从 ~/.agents/skills/ 加载的可组合能力。
// 每个技能都有一个带 YAML 前置元数据的 SKILL.md 清单文件,
// 以及可选的 scripts/ 子目录中的脚本。
// 技能可以通过触发关键词被发现和调用。
package skill
import (
"fmt"
"strings"
)
// Skill 表示从技能目录加载的可组合能力。
//
// 每个技能由 SKILL.md 文件定义,其中包含 YAML 前置元数据(名称、描述、触发器)
// 以及可选的 scripts/ 子目录中的可执行脚本。
type Skill struct {
// Name 是此技能的唯一标识符(例如 "dev-browser")。
Name string `yaml:"name"`
// Description 是对此技能功能的可读说明。
Description string `yaml:"description"`
// Triggers 是从自然语言中激活此技能的关键词。
Triggers []string `yaml:"triggers"`
// Scripts 是 scripts/ 目录中的脚本文件名称列表。
Scripts []string `yaml:"-"`
// ScriptsDir 是 scripts/ 目录的绝对路径。
ScriptsDir string `yaml:"-"`
// Body 是 YAML 前置元数据之后的 Markdown 内容。
Body string `yaml:"-"`
// Path 是 SKILL.md 文件的绝对路径。
Path string `yaml:"-"`
}
// MatchTrigger 检查给定查询是否与技能的任何触发器匹配。
// 匹配不区分大小写,支持部分匹配。
func (s *Skill) MatchTrigger(query string) bool {
query = strings.ToLower(query)
for _, trigger := range s.Triggers {
if strings.Contains(strings.ToLower(query), strings.ToLower(trigger)) {
return true
}
}
return false
}
// String 返回技能的可读表示形式。
func (s *Skill) String() string {
return fmt.Sprintf("Skill{Name: %q, Triggers: %v, Scripts: %d}", s.Name, s.Triggers, len(s.Scripts))
}
// HasScripts 如果技能至少有一个脚本,则返回 true。
func (s *Skill) HasScripts() bool {
return len(s.Scripts) > 0
}