Skip to content

Commit ecf921a

Browse files
committed
feat!: make skill.when accept a context object
1 parent 28aafd7 commit ecf921a

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function filterExtraSkills(
242242
// values are handled separately in `getSkills`.
243243
return extraSkills?.filter((extraSkill) => {
244244
const when = extraSkill.when ?? (() => true);
245-
return templateName ? when(templateName, tools) : true;
245+
return templateName ? when({ templateName, tools }) : true;
246246
});
247247
}
248248

@@ -380,7 +380,7 @@ type ExtraSkill = {
380380
* selected template/tools. Explicit `--skill` values and `--help` remain
381381
* unfiltered so CLI input stays authoritative and help stays discoverable.
382382
*/
383-
when?: (templateName: string, tools: string[]) => boolean;
383+
when?: (context: { templateName: string; tools: string[] }) => boolean;
384384
order?: 'pre' | 'post';
385385
};
386386

test/help.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ test('help message lists all optional skills even when template and tools are pr
118118
value: 'shared-docs',
119119
label: 'Shared Docs',
120120
source: 'acme/skills',
121-
when: (templateName) => templateName === 'vanilla',
121+
when: ({ templateName }) => templateName === 'vanilla',
122122
},
123123
{
124124
value: 'react-docs',
125125
label: 'React Docs',
126126
source: 'acme/skills',
127-
when: (templateName) => templateName === 'react',
127+
when: ({ templateName }) => templateName === 'react',
128128
},
129129
{
130130
value: 'rstest-best-practices',
131131
label: 'Rstest Best Practices',
132132
source: 'rstackjs/agent-skills',
133-
when: (_templateName, selectedTools) => selectedTools.includes('rstest'),
133+
when: ({ tools }) => tools.includes('rstest'),
134134
},
135135
],
136136
argv: ['node', 'test', '--help', '--template', 'vanilla', '--tools', 'biome'],

test/skills.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,14 +746,14 @@ test('should honor explicit --skill values even when they are hidden by template
746746
label: 'React Docs',
747747
source: 'acme/skills',
748748
skill: 'docs/react',
749-
when: (templateName) => templateName === 'react',
749+
when: ({ templateName }) => templateName === 'react',
750750
},
751751
{
752752
value: 'shared-docs',
753753
label: 'Shared Docs',
754754
source: 'acme/skills',
755755
skill: 'docs/shared',
756-
when: (templateName) => templateName === 'vanilla',
756+
when: ({ templateName }) => templateName === 'vanilla',
757757
},
758758
],
759759
argv: [
@@ -818,7 +818,7 @@ test('should show tool-gated skills in the prompt when the required tool is sele
818818
value: 'rstest-best-practices',
819819
label: 'Rstest Best Practices',
820820
source: 'rstackjs/agent-skills',
821-
when: (_templateName, selectedTools) => selectedTools.includes('rstest'),
821+
when: ({ tools }) => tools.includes('rstest'),
822822
},
823823
],
824824
argv: ['node', 'test', projectDir, '--tools', 'rstest'],
@@ -864,7 +864,7 @@ test('should honor explicit --skill values even when the required tool is not se
864864
value: 'rstest-best-practices',
865865
label: 'Rstest Best Practices',
866866
source: 'rstackjs/agent-skills',
867-
when: (_templateName, selectedTools) => selectedTools.includes('rstest'),
867+
when: ({ tools }) => tools.includes('rstest'),
868868
},
869869
],
870870
argv: [

0 commit comments

Comments
 (0)