@@ -124,6 +124,8 @@ function logHelpMessage(
124124 extraSkills ?: ExtraSkill [ ] ,
125125) {
126126 const toolsList = [ ...BUILTIN_TOOLS ] ;
127+ // Keep help output exhaustive for discoverability. `skill.when` only gates
128+ // the interactive prompt, not the documented list of available skills.
127129 const skillsList = ( extraSkills ?? [ ] )
128130 . map ( ( skill ) => skill . value )
129131 . filter ( Boolean ) ;
@@ -234,10 +236,13 @@ async function getTools(
234236function filterExtraSkills (
235237 extraSkills : ExtraSkill [ ] | undefined ,
236238 templateName ?: string ,
239+ tools : string [ ] = [ ] ,
237240) {
241+ // `skill.when` only affects the interactive prompt. Explicit `--skill`
242+ // values are handled separately in `getSkills`.
238243 return extraSkills ?. filter ( ( extraSkill ) => {
239244 const when = extraSkill . when ?? ( ( ) => true ) ;
240- return templateName ? when ( templateName ) : true ;
245+ return templateName ? when ( { templateName, tools } ) : true ;
241246 } ) ;
242247}
243248
@@ -257,14 +262,17 @@ async function getSkills(
257262 { skill, dir, template } : Argv ,
258263 extraSkills ?: ExtraSkill [ ] ,
259264 templateName ?: string ,
265+ tools : string [ ] = [ ] ,
260266 promptMultiselect : typeof multiselect = multiselect ,
261267) {
262268 const parsedSkills = parseSkillsOption ( skill ) ;
263- const filteredExtraSkills = filterExtraSkills ( extraSkills , templateName ) ;
269+ const filteredExtraSkills = filterExtraSkills ( extraSkills , templateName , tools ) ;
264270
265271 if ( parsedSkills !== null ) {
272+ // Treat explicit `--skill` values as authoritative as long as they refer to
273+ // a declared skill. `skill.when` only hides options from the prompt.
266274 return parsedSkills . filter ( ( value : string ) =>
267- filteredExtraSkills ?. some ( ( extraSkill ) => extraSkill . value === value ) ,
275+ extraSkills ?. some ( ( extraSkill ) => extraSkill . value === value ) ,
268276 ) ;
269277 }
270278
@@ -367,7 +375,12 @@ type ExtraSkill = {
367375 label : string ;
368376 source : string ;
369377 skill ?: string ;
370- when ?: ( templateName : string ) => boolean ;
378+ /**
379+ * Controls whether the skill is shown in the interactive prompt for the
380+ * selected template/tools. Explicit `--skill` values and `--help` remain
381+ * unfiltered so CLI input stays authoritative and help stays discoverable.
382+ */
383+ when ?: ( context : { templateName : string ; tools : string [ ] } ) => boolean ;
371384 order ?: 'pre' | 'post' ;
372385} ;
373386
@@ -566,13 +579,7 @@ export async function create({
566579
567580 const templateName = await getTemplateName ( argv ) ;
568581 const tools = await getTools ( argv , extraTools , templateName ) ;
569- const filteredExtraSkills = filterExtraSkills ( extraSkills , templateName ) ;
570- const skills = await getSkills (
571- argv ,
572- filteredExtraSkills ,
573- templateName ,
574- multiselect ,
575- ) ;
582+ const skills = await getSkills ( argv , extraSkills , templateName , tools , multiselect ) ;
576583
577584 const srcFolder = path . join ( root , `template-${ templateName } ` ) ;
578585 const commonFolder = path . join ( root , 'template-common' ) ;
@@ -598,7 +605,7 @@ export async function create({
598605 } ) ;
599606
600607 const skillsByValue = new Map (
601- ( filteredExtraSkills ?? [ ] ) . map ( ( extraSkill ) => [ extraSkill . value , extraSkill ] ) ,
608+ ( extraSkills ?? [ ] ) . map ( ( extraSkill ) => [ extraSkill . value , extraSkill ] ) ,
602609 ) ;
603610 let currentSkillBatch : ExtraSkill [ ] = [ ] ;
604611
0 commit comments