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

Function load_modes_from_dir

crates/opencode-config/src/loader.rs:636–656  ·  view source on GitHub ↗

Load mode definitions from markdown files in {mode,modes}/*.md

(dir: &Path)

Source from the content-addressed store, hash-verified

634
635/// Load mode definitions from markdown files in {mode,modes}/*.md
636fn load_modes_from_dir(dir: &Path) -> HashMap<String, AgentConfig> {
637 let mut result = HashMap::new();
638
639 for subdir_name in &["mode", "modes"] {
640 let subdir = dir.join(subdir_name);
641 if !subdir.is_dir() {
642 continue;
643 }
644 if let Ok(entries) = glob_md_files(&subdir) {
645 for entry in entries {
646 if let Some((name, mut config)) = parse_markdown_agent(&entry, dir) {
647 // Modes are always primary agents
648 config.mode = Some(AgentMode::Primary);
649 result.insert(name, config);
650 }
651 }
652 }
653 }
654
655 result
656}
657
658/// Load plugin paths from .ts/.js files in {plugin,plugins}/*.{ts,js}
659fn load_plugins_from_dir(dir: &Path) -> Vec<String> {

Callers 1

load_allMethod · 0.85

Calls 4

newFunction · 0.85
glob_md_filesFunction · 0.85
parse_markdown_agentFunction · 0.85
is_dirMethod · 0.80

Tested by

no test coverage detected