Files
oh-my-opencode/src/shared/opencode-command-dirs.ts
T
YeonGyu-Kim 55b80fb7cd fix(skill-loader): discover skills from parent config dir when using profiles
OPENCODE_CONFIG_DIR pointing to profiles/ subdirectory caused skills at
~/.config/opencode/skills/ to be invisible. Added getOpenCodeSkillDirs()
with the same parent-dir fallback that getOpenCodeCommandDirs() uses.
2026-03-12 19:53:30 +09:00

37 lines
1.1 KiB
TypeScript

import { basename, dirname, join } from "node:path"
import { getOpenCodeConfigDir } from "./opencode-config-dir"
import type { OpenCodeConfigDirOptions } from "./opencode-config-dir-types"
function getParentOpencodeConfigDir(configDir: string): string | null {
const parentDir = dirname(configDir)
if (basename(parentDir) !== "profiles") {
return null
}
return dirname(parentDir)
}
export function getOpenCodeCommandDirs(options: OpenCodeConfigDirOptions): string[] {
const configDir = getOpenCodeConfigDir(options)
const parentConfigDir = getParentOpencodeConfigDir(configDir)
return Array.from(
new Set([
join(configDir, "command"),
...(parentConfigDir ? [join(parentConfigDir, "command")] : []),
])
)
}
export function getOpenCodeSkillDirs(options: OpenCodeConfigDirOptions): string[] {
const configDir = getOpenCodeConfigDir(options)
const parentConfigDir = getParentOpencodeConfigDir(configDir)
return Array.from(
new Set([
join(configDir, "skills"),
...(parentConfigDir ? [join(parentConfigDir, "skills")] : []),
])
)
}