@@ -69,13 +69,23 @@ export async function runWizardAgent(userPrompt) {
6969 console . log ( '🔧 Triggering MCP tool:' , toolName ) ;
7070
7171 // --- Extract context dynamically from userPrompt or decision ---
72- const repoMatch = userPrompt . match ( / \b ( [ \w - ] + \/ [ \w - ] + ) \b / ) || decision . match ( / \b ( [ \w - ] + \/ [ \w - ] + ) \b / ) ;
73- const providerMatch = userPrompt . match ( / \b ( a w s | j e n k i n s | g i t h u b a c t i o n s | g c p | a z u r e ) \b / i) || decision . match ( / \b ( a w s | j e n k i n s | g i t h u b a c t i o n s | g c p | a z u r e ) \b / i) ;
74- const templateMatch = userPrompt . match ( / \b ( n o d e | p y t h o n | r e a c t | e x p r e s s | d j a n g o | f l a s k | j a v a | g o ) \b / i) || decision . match ( / \b ( n o d e | p y t h o n | r e a c t | e x p r e s s | d j a n g o | f l a s k | j a v a | g o ) \b / i) ;
75-
76- const repo = repoMatch ? repoMatch [ 0 ] : null ;
77- const provider = providerMatch ? providerMatch [ 0 ] . toLowerCase ( ) : null ;
78- const template = templateMatch ? templateMatch [ 0 ] . toLowerCase ( ) : null ;
72+ // Prefer explicit labels like: "repo owner/name", "template node_app", "provider aws"
73+ const labeledRepo = userPrompt . match ( / \b r e p o \s + ( [ A - Z a - z 0 - 9 _ . - ] + \/ [ A - Z a - z 0 - 9 _ . - ] + ) \b / i)
74+ || decision . match ( / \b r e p o \s + ( [ A - Z a - z 0 - 9 _ . - ] + \/ [ A - Z a - z 0 - 9 _ . - ] + ) \b / i) ;
75+ const genericRepo = ( userPrompt + " " + decision ) . match ( / \b (? ! c i \/ c d \b ) ( [ A - Z a - z 0 - 9 _ . - ] + \/ [ A - Z a - z 0 - 9 _ . - ] + ) \b / ) ;
76+ const repo = ( labeledRepo ?. [ 1 ] || genericRepo ?. [ 1 ] || null ) ;
77+
78+ const labeledProvider = userPrompt . match ( / \b p r o v i d e r \s + ( a w s | j e n k i n s | g c p | a z u r e ) \b / i)
79+ || decision . match ( / \b p r o v i d e r \s + ( a w s | j e n k i n s | g c p | a z u r e ) \b / i) ;
80+ const genericProvider = userPrompt . match ( / \b ( a w s | j e n k i n s | g i t h u b a c t i o n s | g c p | a z u r e ) \b / i)
81+ || decision . match ( / \b ( a w s | j e n k i n s | g i t h u b a c t i o n s | g c p | a z u r e ) \b / i) ;
82+ const provider = ( labeledProvider ?. [ 1 ] || genericProvider ?. [ 1 ] || null ) ?. toLowerCase ( ) . replace ( / \s + / g, ' ' ) ;
83+
84+ const labeledTemplate = userPrompt . match ( / \b t e m p l a t e \s + ( [ a - z _ ] [ a - z 0 - 9 _ ] + ) \b / i)
85+ || decision . match ( / \b t e m p l a t e \s + ( [ a - z _ ] [ a - z 0 - 9 _ ] + ) \b / i) ;
86+ const genericTemplate = userPrompt . match ( / \b ( n o d e _ a p p | p y t h o n _ a p p | c o n t a i n e r _ s e r v i c e | n o d e | p y t h o n | r e a c t | e x p r e s s | d j a n g o | f l a s k | j a v a | g o ) \b / i)
87+ || decision . match ( / \b ( n o d e _ a p p | p y t h o n _ a p p | c o n t a i n e r _ s e r v i c e | n o d e | p y t h o n | r e a c t | e x p r e s s | d j a n g o | f l a s k | j a v a | g o ) \b / i) ;
88+ const template = ( labeledTemplate ?. [ 1 ] || genericTemplate ?. [ 1 ] || null ) ?. toLowerCase ( ) ;
7989
8090 if ( toolName === "repo_reader" ) {
8191 // Extract optional username, user_id, and repo info
0 commit comments