MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / collect_skill_roots

Function collect_skill_roots

crates/opencode-tool/src/skill.rs:59–98  ·  view source on GitHub ↗
(base: &Path)

Source from the content-addressed store, hash-verified

57}
58
59fn collect_skill_roots(base: &Path) -> Vec<PathBuf> {
60 let mut roots = Vec::new();
61 if let Some(home) = home_dir() {
62 roots.push(home.join(".agents/skills"));
63 roots.push(home.join(".claude/skills"));
64 }
65
66 // Global config directory (e.g. ~/.config/opencode/skills)
67 if let Some(config_dir) = dirs::config_dir() {
68 roots.push(config_dir.join("opencode/skill"));
69 roots.push(config_dir.join("opencode/skills"));
70 }
71
72 // Home .opencode directory
73 if let Some(home) = home_dir() {
74 roots.push(home.join(".opencode/skill"));
75 roots.push(home.join(".opencode/skills"));
76 }
77
78 roots.push(base.join(".agents/skills"));
79 roots.push(base.join(".claude/skills"));
80 roots.push(base.join(".opencode/skill"));
81 roots.push(base.join(".opencode/skills"));
82
83 if let Ok(config) = load_config(base) {
84 if let Some(skills) = config.skills {
85 for raw in skills.paths {
86 roots.push(resolve_skill_path(base, &raw));
87 }
88 }
89 }
90
91 let mut deduped = Vec::new();
92 for root in roots {
93 if !deduped.contains(&root) {
94 deduped.push(root);
95 }
96 }
97 deduped
98}
99
100fn parse_frontmatter_value(frontmatter: &str, key: &str) -> Option<String> {
101 for line in frontmatter.lines() {

Callers 1

discover_skillsFunction · 0.85

Calls 5

newFunction · 0.85
home_dirFunction · 0.85
load_configFunction · 0.85
resolve_skill_pathFunction · 0.85
containsMethod · 0.80

Tested by

no test coverage detected