| 1 | /** The explicit reviewed-root subset of the raw DSH filesystem row. */ |
| 2 | import type { Context } from '@deepseek-ai/cordis' |
| 3 | import { normalizeSkillRoot } from '../shims/skills.ts' |
| 4 | export interface ReviewedSkillContext extends Context { skills:{registerRoot(definition:{path:string}):()=>void} } |
| 5 | export function reviewedSkillModule() { |
| 6 | return {name:'codewhale-reviewed-skills',inject:['skills'],apply(ctx:ReviewedSkillContext,config:Record<string,unknown>) { |
| 7 | if(!config||Array.isArray(config)||Object.keys(config).some(k=>!['providerName','includeDefaultRoots','customSkillDirs','watch'].includes(k)))throw new Error('filesystem row requires reviewed roots; ambient roots and watcher controls are unsupported') |
| 8 | if(config.includeDefaultRoots!==false||config.watch!==false)throw new Error('filesystem row must explicitly disable default roots and watchers') |
| 9 | if(config.providerName!==undefined&&(typeof config.providerName!=='string'||!config.providerName||config.providerName.length>64))throw new Error('skill providerName must be bounded') |
| 10 | if(!Array.isArray(config.customSkillDirs)||!config.customSkillDirs.length||config.customSkillDirs.length>8)throw new Error('filesystem row needs 1–8 reviewed roots') |
| 11 | const roots=config.customSkillDirs.map(path=>normalizeSkillRoot({path})) |
| 12 | const seen=new Set<string>();for(const {path} of roots){if(seen.has(path))throw new Error('duplicate filesystem root');seen.add(path)} |
| 13 | for(const {path} of roots)ctx.skills.registerRoot({path:`source/${path}`}) |
| 14 | }} |
| 15 | } |
| 16 |