043e84be56
Converts the host OpenCode config.skills object (with paths/urls arrays set by other plugins like superpowers) into the SkillsConfig format used by discoverConfigSourceSkills. Filters blank/whitespace entries and non-string values. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
29 lines
759 B
TypeScript
29 lines
759 B
TypeScript
import type { SkillsConfig } from "../config/schema/skills"
|
|
|
|
type HostSkillConfig = {
|
|
paths?: unknown
|
|
urls?: unknown
|
|
}
|
|
|
|
function toStringArray(value: unknown): string[] {
|
|
if (!Array.isArray(value)) return []
|
|
return value
|
|
.filter((item): item is string => typeof item === "string")
|
|
.map((item) => item.trim())
|
|
.filter((item) => item.length > 0)
|
|
}
|
|
|
|
export function adaptHostSkillConfig(value: unknown): SkillsConfig | undefined {
|
|
if (!value || typeof value !== "object") return undefined
|
|
|
|
const hostSkillConfig = value as HostSkillConfig
|
|
const sources = [
|
|
...toStringArray(hostSkillConfig.paths),
|
|
...toStringArray(hostSkillConfig.urls),
|
|
]
|
|
|
|
if (sources.length === 0) return undefined
|
|
|
|
return { sources } as SkillsConfig
|
|
}
|