feat: 新增技能编排引擎和工作流构建器组件
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
refactor: 统一Hands系统常量到单个源文件 refactor: 更新Hands中文名称和描述 fix: 修复技能市场在连接状态变化时重新加载 fix: 修复身份变更提案的错误处理逻辑 docs: 更新多个功能文档的验证状态和实现位置 docs: 更新Hands系统文档 test: 添加测试文件验证工作区路径
This commit is contained in:
@@ -132,38 +132,103 @@ impl Kernel {
|
||||
.map(|p| p.clone())
|
||||
.unwrap_or_else(|| "You are a helpful AI assistant.".to_string());
|
||||
|
||||
// Inject skill information
|
||||
// Inject skill information with categories
|
||||
if !skills.is_empty() {
|
||||
prompt.push_str("\n\n## Available Skills\n\n");
|
||||
prompt.push_str("You have access to the following skills that can help with specific tasks. ");
|
||||
prompt.push_str("Use the `execute_skill` tool with the skill_id to invoke them:\n\n");
|
||||
prompt.push_str("You have access to specialized skills. Analyze user intent and autonomously call `execute_skill` with the appropriate skill_id.\n\n");
|
||||
|
||||
for skill in skills {
|
||||
prompt.push_str(&format!(
|
||||
"- **{}**: {}",
|
||||
skill.id.as_str(),
|
||||
skill.description
|
||||
));
|
||||
// Group skills by category based on their ID patterns
|
||||
let categories = self.categorize_skills(&skills);
|
||||
|
||||
// Add trigger words if available
|
||||
if !skill.triggers.is_empty() {
|
||||
for (category, category_skills) in categories {
|
||||
prompt.push_str(&format!("### {}\n", category));
|
||||
for skill in category_skills {
|
||||
prompt.push_str(&format!(
|
||||
" (Triggers: {})",
|
||||
skill.triggers.join(", ")
|
||||
"- **{}**: {}",
|
||||
skill.id.as_str(),
|
||||
skill.description
|
||||
));
|
||||
prompt.push('\n');
|
||||
}
|
||||
prompt.push('\n');
|
||||
}
|
||||
|
||||
prompt.push_str("\n### When to use skills:\n");
|
||||
prompt.push_str("- When the user's request matches a skill's trigger words\n");
|
||||
prompt.push_str("- When you need specialized expertise for a task\n");
|
||||
prompt.push_str("- When the task would benefit from a structured workflow\n");
|
||||
prompt.push_str("### When to use skills:\n");
|
||||
prompt.push_str("- **IMPORTANT**: You should autonomously decide when to use skills based on your understanding of the user's intent.\n");
|
||||
prompt.push_str("- Do not wait for explicit skill names - recognize the need and act.\n");
|
||||
prompt.push_str("- Match user's request to the most appropriate skill's domain.\n");
|
||||
prompt.push_str("- If multiple skills could apply, choose the most specialized one.\n\n");
|
||||
prompt.push_str("### Example:\n");
|
||||
prompt.push_str("User: \"分析腾讯财报\" → Intent: Financial analysis → Call: execute_skill(\"finance-tracker\", {...})\n");
|
||||
}
|
||||
|
||||
prompt
|
||||
}
|
||||
|
||||
/// Categorize skills into logical groups
|
||||
///
|
||||
/// Priority:
|
||||
/// 1. Use skill's `category` field if defined in SKILL.md
|
||||
/// 2. Fall back to pattern matching for backward compatibility
|
||||
fn categorize_skills<'a>(&self, skills: &'a [zclaw_skills::SkillManifest]) -> Vec<(String, Vec<&'a zclaw_skills::SkillManifest>)> {
|
||||
let mut categories: std::collections::HashMap<String, Vec<&zclaw_skills::SkillManifest>> = std::collections::HashMap::new();
|
||||
|
||||
// Fallback category patterns for skills without explicit category
|
||||
let fallback_patterns = [
|
||||
("开发工程", vec!["senior-developer", "frontend-developer", "backend-architect", "ai-engineer", "devops-automator", "rapid-prototyper", "lsp-index-engineer"]),
|
||||
("测试质量", vec!["api-tester", "evidence-collector", "reality-checker", "performance-benchmarker", "test-results-analyzer", "accessibility-auditor", "code-review"]),
|
||||
("安全合规", vec!["security-engineer", "legal-compliance-checker", "agentic-identity-trust"]),
|
||||
("数据分析", vec!["analytics-reporter", "finance-tracker", "data-analysis", "sales-data-extraction-agent", "data-consolidation-agent", "report-distribution-agent"]),
|
||||
("项目管理", vec!["senior-pm", "project-shepherd", "sprint-prioritizer", "experiment-tracker", "feedback-synthesizer", "trend-researcher", "agents-orchestrator"]),
|
||||
("设计UX", vec!["ui-designer", "ux-architect", "ux-researcher", "visual-storyteller", "image-prompt-engineer", "whimsy-injector", "brand-guardian"]),
|
||||
("内容营销", vec!["content-creator", "chinese-writing", "executive-summary-generator", "social-media-strategist"]),
|
||||
("社交平台", vec!["twitter-engager", "instagram-curator", "tiktok-strategist", "reddit-community-builder", "zhihu-strategist", "xiaohongshu-specialist", "wechat-official-account", "growth-hacker", "app-store-optimizer"]),
|
||||
("运营支持", vec!["studio-operations", "studio-producer", "support-responder", "workflow-optimizer", "infrastructure-maintainer", "tool-evaluator"]),
|
||||
("XR/空间计算", vec!["visionos-spatial-engineer", "macos-spatial-metal-engineer", "xr-immersive-developer", "xr-interface-architect", "xr-cockpit-interaction-specialist", "terminal-integration-specialist"]),
|
||||
("基础工具", vec!["web-search", "file-operations", "shell-command", "git", "translation", "feishu-docs"]),
|
||||
];
|
||||
|
||||
// Categorize each skill
|
||||
for skill in skills {
|
||||
// Priority 1: Use skill's explicit category
|
||||
if let Some(ref category) = skill.category {
|
||||
if !category.is_empty() {
|
||||
categories.entry(category.clone()).or_default().push(skill);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Priority 2: Fallback to pattern matching
|
||||
let skill_id = skill.id.as_str();
|
||||
let mut categorized = false;
|
||||
|
||||
for (category, patterns) in &fallback_patterns {
|
||||
if patterns.iter().any(|p| skill_id.contains(p) || *p == skill_id) {
|
||||
categories.entry(category.to_string()).or_default().push(skill);
|
||||
categorized = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Put uncategorized skills in "其他"
|
||||
if !categorized {
|
||||
categories.entry("其他".to_string()).or_default().push(skill);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to ordered vector
|
||||
let mut result: Vec<(String, Vec<_>)> = categories.into_iter().collect();
|
||||
result.sort_by(|a, b| {
|
||||
// Sort by predefined order
|
||||
let order = ["开发工程", "测试质量", "安全合规", "数据分析", "项目管理", "设计UX", "内容营销", "社交平台", "运营支持", "XR/空间计算", "基础工具", "其他"];
|
||||
let a_idx = order.iter().position(|&x| x == a.0).unwrap_or(99);
|
||||
let b_idx = order.iter().position(|&x| x == b.0).unwrap_or(99);
|
||||
a_idx.cmp(&b_idx)
|
||||
});
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
/// Spawn a new agent
|
||||
pub async fn spawn_agent(&self, config: AgentConfig) -> Result<AgentId> {
|
||||
let id = config.id;
|
||||
|
||||
Reference in New Issue
Block a user