@@ -199,10 +199,10 @@ describe('learnPrompts', () => {
199199 } ) ;
200200
201201 describe ( 'buildLearnUserPrompt registry handling' , ( ) => {
202- it ( 'does not dump full registry when skills exceed threshold ' , ( ) => {
202+ it ( 'caps skills at 30 and mentions overflow ' , ( ) => {
203203 const analysis = makeAnalysis ( { languages : [ 'typescript' ] , frameworks : [ 'react' ] } ) ;
204204
205- // Generate a large registry with no language/framework match
205+ // Generate a large registry
206206 const manySkills = Array . from ( { length : 50 } , ( _ , i ) =>
207207 makeRegistrySkill ( {
208208 id : `skill-${ i } ` ,
@@ -215,22 +215,29 @@ describe('learnPrompts', () => {
215215
216216 const prompt = buildLearnUserPrompt ( analysis , [ ] , manySkills ) ;
217217
218- // Should mention find_agent_skills, not list all 50
218+ // Should cap at 30 and mention overflow
219219 expect ( prompt ) . toContain ( 'find_agent_skills' ) ;
220- expect ( prompt ) . not . toContain ( 'skill-49' ) ;
220+ expect ( prompt ) . toContain ( 'skill-0' ) ;
221+ expect ( prompt ) . toContain ( 'skill-29' ) ;
222+ expect ( prompt ) . not . toContain ( 'skill-30' ) ;
221223 } ) ;
222224
223- it ( 'shows matching skills filtered by project stack ' , ( ) => {
225+ it ( 'lists matching skills first, then others ' , ( ) => {
224226 const analysis = makeAnalysis ( { languages : [ 'typescript' ] , frameworks : [ 'react' ] } ) ;
225227
226228 const skills = [
227- makeRegistrySkill ( { id : 'ts-skill' , languages : [ 'typescript' ] , frameworks : [ ] } ) ,
228229 makeRegistrySkill ( { id : 'ruby-skill' , languages : [ 'ruby' ] , frameworks : [ 'rails' ] } ) ,
230+ makeRegistrySkill ( { id : 'ts-skill' , languages : [ 'typescript' ] , frameworks : [ ] } ) ,
229231 ] ;
230232
231233 const prompt = buildLearnUserPrompt ( analysis , [ ] , skills ) ;
234+ // Both should be visible to the LLM
232235 expect ( prompt ) . toContain ( 'ts-skill' ) ;
233- expect ( prompt ) . not . toContain ( 'ruby-skill' ) ;
236+ expect ( prompt ) . toContain ( 'ruby-skill' ) ;
237+ // Matching skill should appear before non-matching (in "Matching Skills" section)
238+ const tsIdx = prompt . indexOf ( 'ts-skill' ) ;
239+ const rubyIdx = prompt . indexOf ( 'ruby-skill' ) ;
240+ expect ( tsIdx ) . toBeLessThan ( rubyIdx ) ;
234241 } ) ;
235242
236243 it ( 'includes registry count summary' , ( ) => {
@@ -248,6 +255,36 @@ describe('learnPrompts', () => {
248255 const prompt = buildLearnUserPrompt ( analysis , [ ] , skills ) ;
249256 expect ( prompt ) . toContain ( 'find_agent_skills' ) ;
250257 } ) ;
258+
259+ it ( 'includes skills with empty languages/frameworks (no metadata)' , ( ) => {
260+ const analysis = makeAnalysis ( { languages : [ 'typescript' ] , frameworks : [ 'react' ] } ) ;
261+
262+ const skills = [
263+ makeRegistrySkill ( { id : 'error-handling' , description : 'Error patterns' , languages : [ ] , frameworks : [ ] , tags : [ 'patterns' ] } ) ,
264+ makeRegistrySkill ( { id : 'ts-skill' , languages : [ 'typescript' ] , frameworks : [ ] } ) ,
265+ ] ;
266+
267+ const prompt = buildLearnUserPrompt ( analysis , [ ] , skills ) ;
268+ // Skills with no metadata should still appear — the LLM should decide relevance
269+ expect ( prompt ) . toContain ( 'error-handling' ) ;
270+ expect ( prompt ) . toContain ( 'ts-skill' ) ;
271+ } ) ;
272+
273+ it ( 'includes all skills when total count is within the limit' , ( ) => {
274+ const analysis = makeAnalysis ( { languages : [ 'typescript' ] , frameworks : [ 'react' ] } ) ;
275+
276+ const skills = [
277+ makeRegistrySkill ( { id : 'ts-skill' , languages : [ 'typescript' ] , frameworks : [ ] } ) ,
278+ makeRegistrySkill ( { id : 'go-skill' , languages : [ 'go' ] , frameworks : [ ] } ) ,
279+ makeRegistrySkill ( { id : 'generic-skill' , languages : [ ] , frameworks : [ ] } ) ,
280+ ] ;
281+
282+ const prompt = buildLearnUserPrompt ( analysis , [ ] , skills ) ;
283+ // All 3 skills should be visible to the LLM for ranking
284+ expect ( prompt ) . toContain ( 'ts-skill' ) ;
285+ expect ( prompt ) . toContain ( 'go-skill' ) ;
286+ expect ( prompt ) . toContain ( 'generic-skill' ) ;
287+ } ) ;
251288 } ) ;
252289
253290 describe ( 'buildLearnGenerationSystemPrompt' , ( ) => {
0 commit comments