MCPcopy Create free account
hub / github.com/Microck/opencode-studio / getSearchRoots

Function getSearchRoots

server/index.js:609–640  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

607const getConfigPath = () => getPaths().current;
608
609const getSearchRoots = () => {
610 const roots = [];
611
612 // 1. Directory of the currently active config
613 const configPath = getConfigPath();
614 if (configPath) roots.push(path.dirname(configPath));
615
616 // 2. Current Working Directory
617 roots.push(process.cwd());
618
619 // 3. XDG Config Home
620 const xdg = process.env.XDG_CONFIG_HOME;
621 if (xdg) roots.push(path.join(xdg, 'opencode'));
622
623 // 4. Home config
624 roots.push(path.join(HOME_DIR, '.config', 'opencode'));
625
626 // 5. Home dotfile
627 roots.push(path.join(HOME_DIR, '.opencode'));
628
629 // 6. Local share
630 roots.push(path.join(HOME_DIR, '.local', 'share', 'opencode'));
631
632 // 7. Windows AppData
633 if (process.platform === 'win32' && process.env.APPDATA) {
634 roots.push(path.join(process.env.APPDATA, 'opencode'));
635 }
636
637 // Filter nulls, duplicates and normalize
638 const unique = [...new Set(roots.filter(Boolean).map(p => path.resolve(p)))];
639 return unique;
640};
641
642const getSkillDirs = () => {
643 const roots = getSearchRoots();

Callers 9

getSkillDirsFunction · 0.85
getCommandDirsFunction · 0.85
getMcpDirsFunction · 0.85
getPluginDirsFunction · 0.85
getAgentDirsFunction · 0.85
aggregateModelsFunction · 0.85
loadAggregatedConfigFunction · 0.85
aggregateAgentsFunction · 0.85
index.jsFile · 0.85

Calls 1

getConfigPathFunction · 0.85

Tested by

no test coverage detected