( value: unknown, sourceLabel: string, index: number, )
| 35 | } |
| 36 | |
| 37 | function validateSkillEntry( |
| 38 | value: unknown, |
| 39 | sourceLabel: string, |
| 40 | index: number, |
| 41 | ): asserts value is SkillEntry { |
| 42 | if (!value || typeof value !== "object") { |
| 43 | throw new Error( |
| 44 | `Invalid config from ${sourceLabel}: "skills[${index}]" must be an object`, |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | const skill = value as Record<string, unknown>; |
| 49 | if ("installSource" in skill || "specificSkills" in skill) { |
| 50 | throw new Error( |
| 51 | `Invalid config from ${sourceLabel}: legacy skill fields are no longer supported; keep only "source", "name", and "description"`, |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | if (typeof skill.source !== "string" || !skill.source.trim()) { |
| 56 | throw new Error( |
| 57 | `Invalid config from ${sourceLabel}: "skills[${index}].source" is required`, |
| 58 | ); |
| 59 | } |
| 60 | |
| 61 | if (typeof skill.name !== "string" || !skill.name.trim()) { |
| 62 | throw new Error( |
| 63 | `Invalid config from ${sourceLabel}: "skills[${index}].name" is required`, |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | if (typeof skill.description !== "string") { |
| 68 | throw new Error( |
| 69 | `Invalid config from ${sourceLabel}: "skills[${index}].description" must be a string`, |
| 70 | ); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | export function validateConfigShape( |
| 75 | value: unknown, |
no outgoing calls
no test coverage detected