Add built-in skills with trigger-based activation system: Git Operations: - git-log: commit history analysis via git_log/git_graph/git_reflog - git-diff: code changes analysis via git_diff/git_diff_stats/git_blame - git-branch: branch management via git_branch_list/git_branch_info - file-reader: file reading/search via git_file_content/git_grep Code Quality: - code-review: security/performance/quality checks - code-explainer: explain complex code in accessible terms Project Management: - repo-manager: list/create/update repos - issue-manager: manage issues with triage/labels/priorities - board-manager: kanban boards and card management - member-manager: team members and permissions Development Productivity: - pr-summary: generate PR summaries - issue-triage: classify and prioritize issues - doc-generator: generate README/API docs - test-generator: write unit tests (AAA pattern) - commit-message: generate conventional commits Utilities: - http-requester: HTTP requests and API testing Skills integrated via PerceptionService with active/passive/auto triggers Built-in skills automatically available to all projects Database skills override built-in skills with same slug
297 lines
11 KiB
Rust
297 lines
11 KiB
Rust
//! Built-in skill templates.
|
|
//!
|
|
//! Each skill is a Markdown file containing instructions and guidelines
|
|
//! for the AI to follow when performing that task.
|
|
|
|
use once_cell::sync::Lazy;
|
|
use std::collections::HashMap;
|
|
|
|
/// A built-in skill template.
|
|
#[derive(Debug, Clone)]
|
|
pub struct BuiltInSkill {
|
|
/// URL-safe identifier (e.g., "code-review")
|
|
pub slug: &'static str,
|
|
/// Human-readable name (e.g., "Code Review")
|
|
pub name: &'static str,
|
|
/// Short description (e.g., "Review code changes...")
|
|
pub description: &'static str,
|
|
/// Primary keywords that trigger this skill
|
|
pub trigger_keywords: Vec<&'static str>,
|
|
/// Tool names that trigger this skill
|
|
pub trigger_tools: Vec<&'static str>,
|
|
/// The skill content/instructions
|
|
pub content: String,
|
|
}
|
|
|
|
impl BuiltInSkill {
|
|
/// Create a new built-in skill.
|
|
pub fn new(
|
|
slug: &'static str,
|
|
name: &'static str,
|
|
description: &'static str,
|
|
trigger_keywords: Vec<&'static str>,
|
|
trigger_tools: Vec<&'static str>,
|
|
content: &'static str,
|
|
) -> Self {
|
|
Self {
|
|
slug,
|
|
name,
|
|
description,
|
|
trigger_keywords,
|
|
trigger_tools,
|
|
content: content.to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
/// All built-in skill templates.
|
|
pub static SKILL_TEMPLATES: Lazy<HashMap<&'static str, BuiltInSkill>> =
|
|
Lazy::new(|| {
|
|
let mut map = HashMap::new();
|
|
|
|
let skills = [
|
|
BuiltInSkill::new(
|
|
"code-review",
|
|
"Code Review",
|
|
"Expert code review with security, performance, and quality checks",
|
|
vec![
|
|
"review", "code review", "review code", "代码审查", "review pr",
|
|
"security", "performance", "bug", "vulnerability"
|
|
],
|
|
vec!["git_diff", "git_diff_stats", "git_blame"],
|
|
include_str!("./templates/code-review.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"git-log",
|
|
"Git Log Analysis",
|
|
"Analyze commit history and understand code evolution",
|
|
vec![
|
|
"commit", "history", "log", "提交", "历史", "author", "git log",
|
|
"查看提交", "commits"
|
|
],
|
|
vec!["git_log", "git_graph", "git_reflog", "git_search_commits"],
|
|
include_str!("./templates/git-log.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"git-diff",
|
|
"Git Diff Analysis",
|
|
"Understand code changes between commits or branches",
|
|
vec![
|
|
"diff", "change", "修改", "变更", "compare", "对比",
|
|
"改动", "patch", "delta", "changes"
|
|
],
|
|
vec!["git_diff", "git_diff_stats", "git_blame"],
|
|
include_str!("./templates/git-diff.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"git-branch",
|
|
"Git Branch Management",
|
|
"Manage branches and understand branch relationships",
|
|
vec![
|
|
"branch", "branches", "分支", "HEAD", "main", "develop",
|
|
"feature", "hotfix", "merged", "compare branches"
|
|
],
|
|
vec![
|
|
"git_branch_list", "git_branch_info", "git_branches_merged",
|
|
"git_branch_diff"
|
|
],
|
|
include_str!("./templates/git-branch.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"file-reader",
|
|
"File Reading & Search",
|
|
"Read file contents and search for patterns in code",
|
|
vec![
|
|
"read", "view", "show", "显示", "读取", "file", "content",
|
|
"search", "grep", "find", "search", "配置", "csv", "json"
|
|
],
|
|
vec![
|
|
"git_file_content", "git_tree_ls", "read_csv", "read_json",
|
|
"read_markdown", "git_grep"
|
|
],
|
|
include_str!("./templates/file-reader.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"repo-manager",
|
|
"Repository Management",
|
|
"List, create, and manage project repositories",
|
|
vec![
|
|
"repo", "repository", "仓库", "project", "项目",
|
|
"create repo", "update repo", "仓库管理"
|
|
],
|
|
vec![
|
|
"project_list_repos", "project_create_repo",
|
|
"project_update_repo"
|
|
],
|
|
include_str!("./templates/repo-manager.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"issue-manager",
|
|
"Issue Management",
|
|
"Manage issues with triage, labels, and priorities",
|
|
vec![
|
|
"issue", "bug", "task", "任务", "问题", "triage",
|
|
"priority", "label", "assign", "状态"
|
|
],
|
|
vec![
|
|
"list_issues_exec", "create_issue_exec",
|
|
"update_issue_exec"
|
|
],
|
|
include_str!("./templates/issue-manager.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"board-manager",
|
|
"Board & Kanban Management",
|
|
"Manage project boards, cards, and kanban workflows",
|
|
vec![
|
|
"board", "kanban", "看板", "card", "task", "sprint",
|
|
"column", "lane", "泳道", "进度"
|
|
],
|
|
vec![
|
|
"list_boards_exec", "create_board_exec",
|
|
"create_board_card_exec", "update_board_card_exec"
|
|
],
|
|
include_str!("./templates/board-manager.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"member-manager",
|
|
"Team Member Management",
|
|
"Manage team members, roles, and permissions",
|
|
vec![
|
|
"member", "team", "user", "成员", "团队", "role",
|
|
"permission", "权限", "admin", "maintainer", "contributor"
|
|
],
|
|
vec!["list_members_exec"],
|
|
include_str!("./templates/member-manager.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"http-requester",
|
|
"HTTP Request & API Testing",
|
|
"Make HTTP requests and test APIs",
|
|
vec![
|
|
"http", "api", "endpoint", "request", "response",
|
|
"curl", "webhook", "POST", "GET", "REST"
|
|
],
|
|
vec!["curl_exec", "project_curl"],
|
|
include_str!("./templates/http-requester.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"pr-summary",
|
|
"PR Summary",
|
|
"Generate clear pull request summaries following conventional format",
|
|
vec![
|
|
"pr", "pull request", "merge", "summary", "describe"
|
|
],
|
|
vec!["git_diff", "git_log"],
|
|
include_str!("./templates/pr-summary.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"issue-triage",
|
|
"Issue Triage",
|
|
"Classify and prioritize GitHub issues with labels and components",
|
|
vec![
|
|
"triage", "classify", "priority", "severity", "component"
|
|
],
|
|
vec!["list_issues_exec"],
|
|
include_str!("./templates/issue-triage.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"doc-generator",
|
|
"Documentation Generator",
|
|
"Generate README, API docs, and code documentation",
|
|
vec![
|
|
"doc", "document", "readme", "api doc", "文档", "生成文档"
|
|
],
|
|
vec!["read_markdown", "read_json"],
|
|
include_str!("./templates/doc-generator.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"test-generator",
|
|
"Test Generator",
|
|
"Write comprehensive unit tests following AAA pattern",
|
|
vec![
|
|
"test", "testing", "unit test", "测试", "spec"
|
|
],
|
|
vec!["git_file_content"],
|
|
include_str!("./templates/test-generator.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"commit-message",
|
|
"Commit Message Generator",
|
|
"Generate conventional commit messages following best practices",
|
|
vec![
|
|
"commit", "message", "conventional", "提交信息"
|
|
],
|
|
vec!["git_diff", "git_log"],
|
|
include_str!("./templates/commit-message.md"),
|
|
),
|
|
BuiltInSkill::new(
|
|
"code-explainer",
|
|
"Code Explainer",
|
|
"Explain complex code in simple, accessible terms",
|
|
vec![
|
|
"explain", "understand", "what does", "解释", "说明"
|
|
],
|
|
vec!["git_file_content", "git_blame"],
|
|
include_str!("./templates/code-explainer.md"),
|
|
),
|
|
];
|
|
|
|
for skill in skills {
|
|
map.insert(skill.slug, skill);
|
|
}
|
|
|
|
map
|
|
});
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_all_skills_loaded() {
|
|
let expected = [
|
|
"code-review", "git-log", "git-diff", "git-branch", "file-reader",
|
|
"repo-manager", "issue-manager", "board-manager", "member-manager",
|
|
"http-requester", "pr-summary", "issue-triage", "doc-generator",
|
|
"test-generator", "commit-message", "code-explainer",
|
|
];
|
|
for slug in expected {
|
|
assert!(
|
|
SKILL_TEMPLATES.contains_key(slug),
|
|
"Missing skill: {}",
|
|
slug
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_skill_has_triggers() {
|
|
for skill in SKILL_TEMPLATES.values() {
|
|
assert!(
|
|
!skill.trigger_keywords.is_empty() || !skill.trigger_tools.is_empty(),
|
|
"Skill {} has no triggers",
|
|
skill.slug
|
|
);
|
|
assert!(
|
|
skill.content.len() > 100,
|
|
"Skill {} content too short",
|
|
skill.slug
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_skill_uniqueness() {
|
|
let mut slugs = Vec::new();
|
|
for skill in SKILL_TEMPLATES.values() {
|
|
assert!(
|
|
!slugs.contains(&skill.slug),
|
|
"Duplicate skill slug: {}",
|
|
skill.slug
|
|
);
|
|
slugs.push(skill.slug);
|
|
}
|
|
}
|
|
}
|