@@ -36,6 +36,8 @@ const RULE_SHORTHAND =
3636const UNMARKED_FIX = / ^ (? ! i \b | i t \b | t h \w + \b | w e \b | y o u \b ) [ a - z ] [ \w - ] * \s + \S + / i;
3737const COMMAND_SHAPED =
3838 / ^ (?: g i t | g h | n o d e | n p m | o p e n c l a w | p n p m ) \s + | ^ [ a - z ] [ \w - ] * \s + (?: - | \. ? \/ | h t t p s ? : \/ \/ | [ A - Z _ ] [ A - Z 0 - 9 _ ] * = ) / ;
39+ const EXPLICIT_ACTION_MARKER =
40+ / \b (?: r e m e m b e r t o | m a k e s u r e t o ) \b | ^ (?: (?: c a n | c o u l d | w o u l d | w i l l ) y o u \s + | p l e a s e \s + ) ? a l w a y s \b | [ , ; : — – - ] \s + a l w a y s \b / i;
3941
4042const MATCH_STOPWORDS = new Set (
4143 "and are as before but for from have into not should that the them then they this was were what when with you your" . split (
@@ -195,9 +197,7 @@ function normalizeRule(value: string, explicit = false): string | undefined {
195197 . replace ( / ^ (?: (?: a l s o | a l w a y s | m a k e s u r e t o | p l e a s e | j u s t | r e m e m b e r t o ) \s + ) + / i, "" )
196198 . trim ( ) ;
197199 const literalDotArgument = / ^ r u n \s + \S + .* \s \. $ / i. test ( rule ) ;
198- if ( ! literalDotArgument ) {
199- rule = rule . replace ( / [ . ! ? ] + $ / , "" ) ;
200- }
200+ rule = literalDotArgument ? rule : rule . replace ( / [ . ! ? ] + $ / , "" ) ;
201201 if (
202202 ! rule ||
203203 ( compact . endsWith ( "?" ) && ! request && ! IMPERATIVE_RULE . test ( rule ) ) ||
@@ -240,8 +240,7 @@ function normalizeRule(value: string, explicit = false): string | undefined {
240240 } else if ( / \b i n p a r e n t h e s e s $ / i. test ( rule ) && ! IMPERATIVE_RULE . test ( rule ) ) {
241241 rule = `Include ${ rule } ` ;
242242 }
243- const normalized = commandShaped ? rule : rule . charAt ( 0 ) . toUpperCase ( ) + rule . slice ( 1 ) ;
244- return literalDotArgument ? normalized : `${ normalized } .` ;
243+ return `${ commandShaped ? rule : rule . charAt ( 0 ) . toUpperCase ( ) + rule . slice ( 1 ) } ${ literalDotArgument ? "" : "." } ` ;
245244}
246245
247246function normalizeRuleList ( value : string , splitList : boolean , explicit = false ) : string [ ] {
@@ -269,10 +268,6 @@ function normalizeRuleList(value: string, splitList: boolean, explicit = false):
269268
270269function parseInstruction ( instruction : string ) {
271270 const compactInstruction = compactWhitespace ( instruction . split ( "\uE000" , 1 ) [ 0 ] ?? instruction ) ;
272- const explicitActionMarker =
273- / \b (?: r e m e m b e r t o | m a k e s u r e t o ) \b | ^ (?: (?: c a n | c o u l d | w o u l d | w i l l ) y o u \s + | p l e a s e \s + ) ? a l w a y s \b | [ , ; : — – - ] \s + a l w a y s \b / i. test (
274- compactInstruction ,
275- ) ;
276271 const isolatedInstruction = stripSignalMarkers ( compactInstruction ) ;
277272 const actorEvent = isolatedInstruction . match (
278273 new RegExp (
@@ -508,7 +503,7 @@ function parseInstruction(instruction: string) {
508503 ? { rules : normalizeRuleList ( explicitFix , false ) }
509504 : undefined ;
510505 }
511- const rules = normalizeRuleList ( text , false , explicitActionMarker ) ;
506+ const rules = normalizeRuleList ( text , false , EXPLICIT_ACTION_MARKER . test ( compactInstruction ) ) ;
512507 return rules . length > 0 ? { rules } : undefined ;
513508}
514509
0 commit comments