@@ -322,50 +322,90 @@ const AREA_FIELD_TO_LABELS = {
322322 other : [ ] ,
323323} ;
324324
325+ /**
326+ * Heuristic rules. `scope: "title"` avoids false hits from template Environment /
327+ * OS fields in the body; `scope: "full"` is for distinctive technical tokens.
328+ */
325329const AREA_HEURISTICS = [
326330 {
327331 label : "account-pool" ,
328- re : / \b ( o a u t h | r e a u t h | n e e d s r e a u t h | q u o t a | a c c o u n t p o o l | c o d e x .? a u t h | a u t o [ - ] ? s w i t c h | f a i l o v e r | r e f r e s h t o k e n | p l a n _ t y p e | c h a t g p t [ - ] a c c o u n t | r e s e t c r e d i t ) \b / i,
332+ scope : "full" ,
333+ re : / \b ( o a u t h | r e a u t h | n e e d s r e a u t h | a c c o u n t p o o l | c o d e x .? a u t h | a u t o [ - ] ? s w i t c h | a c c o u n t f a i l o v e r | r e f r e s h t o k e n | p l a n _ t y p e | c h a t g p t [ - ] a c c o u n t | r e s e t c r e d i t ) \b / i,
334+ } ,
335+ {
336+ label : "account-pool" ,
337+ scope : "title" ,
338+ re : / \b ( q u o t a | f a i l o v e r | p o o l a c c o u n t | a c c o u n t s w i t c h ) \b / i,
329339 } ,
330340 {
331341 label : "catalog" ,
332- re : / \b ( c a t a l o g | m o d e l l i s t | m o d e l v i s i b i l i t y | v i r t u a l m o d e l | r o u t e d ( c a t a l o g | e n t r i e s | s l u g ) | m o d e l s l u g ) \b / i,
342+ scope : "full" ,
343+ re : / \b ( m o d e l c a t a l o g | o p e n c o d e x - c a t a l o g | m o d e l l i s t | m o d e l v i s i b i l i t y | v i r t u a l m o d e l | r o u t e d ( c a t a l o g | e n t r i e s | s l u g ) | m o d e l s l u g ) \b / i,
344+ } ,
345+ {
346+ label : "catalog" ,
347+ scope : "title" ,
348+ re : / \b c a t a l o g \b / i,
333349 } ,
334350 {
335351 label : "gui" ,
336- re : / \b ( d a s h b o a r d | \b g u i \b | t r a y | s i d e b a r | s e t t i n g s t a b ) \b / i,
352+ scope : "title" ,
353+ re : / \b ( d a s h b o a r d | \b g u i \b | t r a y | s i d e b a r | s e t t i n g s ( p a g e | t a b | u i ) ) \b / i,
337354 } ,
338355 {
339356 label : "cli" ,
357+ scope : "title" ,
340358 re : / \b ( o c x \b | c o n f i g \. t o m l | c o n f i g i n j e c t ) \b / i,
341359 } ,
342360 {
343361 label : "proxy" ,
344- re : / \b ( r e v e r s e [ - ] p r o x y | m a n a g e m e n t a p i | a d m i n [ - ] t o k e n | \/ a p i \/ \* | b i n d ( s ) ? t h e ( o l d ) ? p o r t | p r o x y r u n n i n g ) \b / i,
362+ scope : "full" ,
363+ re : / \b ( r e v e r s e [ - ] p r o x y | m a n a g e m e n t a p i | a d m i n [ - ] t o k e n | \/ a p i \/ \* | b i n d ( s ) ? t h e ( o l d ) ? p o r t ) \b / i,
364+ } ,
365+ {
366+ label : "proxy" ,
367+ scope : "title" ,
368+ re : / \b ( r e v e r s e [ - ] p r o x y | m a n a g e m e n t a p i | a d m i n [ - ] t o k e n ) \b / i,
345369 } ,
346370 {
347371 label : "platform" ,
348- re : / \b ( w i n d o w s | m a c o s | m a c o s | w i n 3 2 | d a r w i n | w s l | w i n s w | l a u n c h d | s y s t e m d | i c a c l s | \b a c l \b ) \b / i,
372+ scope : "full" ,
373+ re : / \b ( w i n s w | l a u n c h d | s c h t a s k s | i c a c l s | w i n d o w s - l a t e s t | t r a y h o s t | s c h e d u l e r b a c k e n d ) \b / i,
374+ } ,
375+ {
376+ label : "platform" ,
377+ scope : "title" ,
378+ re : / \b ( \[ w i n d o w s \] | \[ m a c o s \] | w i n d o w s | m a c o s | d a r w i n | w i n 3 2 | w s l ) \b / i,
349379 } ,
350380 {
351381 label : "streaming" ,
382+ scope : "full" ,
352383 re : / \b ( s s e | w e b s o c k e t | \b w s \b | s t r e a m ( i n g ) ? \b .{ 0 , 40 } \b ( t r u n c a t | t e r m i n a l ) | t e r m i n a l ( s s e ) ? f r a m e | w i t h o u t a t e r m i n a l ) \b / i,
353384 } ,
354385 {
355386 label : "tools" ,
387+ scope : "full" ,
356388 re : / \b ( t o o l _ c a l l s ? | t o o l [ - ] c a l l s ? | \b m c p \b | w e b [ - ] s e a r c h | t o o l [ - ] r e c a l l ) \b / i,
357389 } ,
358390 {
359391 label : "install" ,
392+ scope : "full" ,
360393 re : / \b ( n p m ( g l o b a l ) ? i n s t a l l | p a c k a g i n g | r e l e a s e a s s e t | n p x o c x ) \b / i,
361394 } ,
362395 {
363396 label : "service" ,
397+ scope : "full" ,
364398 re : / \b ( o c x s e r v i c e | w i n s w | s c h e d u l e r b a c k e n d | l a u n c h d s e r v i c e ) \b / i,
365399 } ,
366400 {
367401 label : "provider" ,
368- re : / \b ( p r o v i d e r a d a p t e r | o p e n a i [ - ] c o m p a t i b l e | p r o v i d e r [ - ] c o m p a t | a d a p t e r q u i r k | u p s t r e a m a p i | b u i l t [ - ] i n p r o v i d e r | p r o v i d e r p r e s e t ) \b / i,
402+ scope : "full" ,
403+ re : / \b ( p r o v i d e r a d a p t e r | o p e n a i [ - ] c o m p a t i b l e | p r o v i d e r [ - ] c o m p a t | a d a p t e r q u i r k | b u i l t [ - ] i n p r o v i d e r | p r o v i d e r p r e s e t ) \b / i,
404+ } ,
405+ {
406+ label : "provider" ,
407+ scope : "title" ,
408+ re : / \b ( \[ p r o v i d e r \] | p r o v i d e r c o m p a t | o p e n a i [ - ] c o m p a t i b l e ) \b / i,
369409 } ,
370410] ;
371411
@@ -399,10 +439,15 @@ function mapAreaFieldToLabels(areaText) {
399439 * @returns {string[] }
400440 */
401441function heuristicAreaLabels ( title , body ) {
402- const text = `${ title || "" } \n${ body || "" } ` ;
442+ const titleText = title || "" ;
443+ const fullText = `${ titleText } \n${ body || "" } ` ;
444+ const seen = new Set ( ) ;
403445 const out = [ ] ;
404- for ( const { label, re } of AREA_HEURISTICS ) {
405- if ( re . test ( text ) ) out . push ( label ) ;
446+ for ( const { label, re, scope } of AREA_HEURISTICS ) {
447+ const text = scope === "title" ? titleText : fullText ;
448+ if ( ! re . test ( text ) || seen . has ( label ) ) continue ;
449+ seen . add ( label ) ;
450+ out . push ( label ) ;
406451 }
407452 return out ;
408453}
0 commit comments