Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 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, "commands"),
|
|
join(configDir, "command"),
|
|
...(parentConfigDir ? [join(parentConfigDir, "commands"), 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"),
|
|
join(configDir, "skill"),
|
|
...(parentConfigDir ? [join(parentConfigDir, "skills"), join(parentConfigDir, "skill")] : []),
|
|
])
|
|
)
|
|
}
|