@@ -901,20 +901,6 @@ The candidate skills are as follows:\n\n`;
901901 const signal = controller ?. signal ;
902902 this . throwIfAborted ( signal ) ;
903903
904- if ( userPrompt . text ) {
905- const skills = await this . listSkills ( ) ;
906- const skillNames = await this . identifyMatchingSkillNames ( skills , userPrompt . text , { signal } ) ;
907- this . throwIfAborted ( signal ) ;
908- const skillSet = new Set ( skillNames ) ;
909- const matchedSkill = skills . filter ( ( skill ) => skillSet . has ( skill . name ) ) ;
910- if ( Array . isArray ( userPrompt . skills ) ) {
911- userPrompt . skills . push ( ...matchedSkill ) ;
912- } else if ( matchedSkill . length > 0 ) {
913- userPrompt . skills = matchedSkill ;
914- }
915- }
916- userPrompt . skills = await this . normalizeSkills ( userPrompt . skills ) ;
917- this . throwIfAborted ( signal ) ;
918904 const sessionId = crypto . randomUUID ( ) ;
919905 this . ensureFileHistorySession ( sessionId ) ;
920906 const now = new Date ( ) . toISOString ( ) ;
@@ -977,6 +963,21 @@ The candidate skills are as follows:\n\n`;
977963 const userMessage = this . buildUserMessage ( sessionId , userPrompt ) ;
978964 this . appendSessionMessage ( sessionId , userMessage ) ;
979965
966+ if ( userPrompt . text ) {
967+ const skills = await this . listSkills ( ) ;
968+ const skillNames = await this . identifyMatchingSkillNames ( skills , userPrompt . text , { signal } ) ;
969+ this . throwIfAborted ( signal ) ;
970+ const skillSet = new Set ( skillNames ) ;
971+ const matchedSkill = skills . filter ( ( skill ) => skillSet . has ( skill . name ) ) ;
972+ if ( Array . isArray ( userPrompt . skills ) ) {
973+ userPrompt . skills . push ( ...matchedSkill ) ;
974+ } else if ( matchedSkill . length > 0 ) {
975+ userPrompt . skills = matchedSkill ;
976+ }
977+ }
978+ userPrompt . skills = await this . normalizeSkills ( userPrompt . skills ) ;
979+ this . throwIfAborted ( signal ) ;
980+
980981 if ( userPrompt . skills && userPrompt . skills . length > 0 ) {
981982 for ( const skill of userPrompt . skills ) {
982983 if ( skill . isLoaded ) {
@@ -1022,6 +1023,10 @@ ${skillMd}
10221023
10231024 this . reportNewPrompt ( ) ;
10241025
1026+ this . ensureFileHistorySession ( sessionId ) ;
1027+ const userMessage = this . buildUserMessage ( sessionId , userPrompt ) ;
1028+ this . appendSessionMessage ( sessionId , userMessage ) ;
1029+
10251030 if ( userPrompt . text ) {
10261031 const skills = await this . listSkills ( sessionId ) ;
10271032 const skillNames = await this . identifyMatchingSkillNames ( skills , userPrompt . text , { signal, sessionId } ) ;
@@ -1037,10 +1042,6 @@ ${skillMd}
10371042 userPrompt . skills = await this . normalizeSkills ( userPrompt . skills , sessionId ) ;
10381043 this . throwIfAborted ( signal ) ;
10391044
1040- this . ensureFileHistorySession ( sessionId ) ;
1041- const userMessage = this . buildUserMessage ( sessionId , userPrompt ) ;
1042- this . appendSessionMessage ( sessionId , userMessage ) ;
1043-
10441045 if ( userPrompt . skills && userPrompt . skills . length > 0 ) {
10451046 for ( const skill of userPrompt . skills ) {
10461047 if ( skill . isLoaded ) {
0 commit comments