@@ -17,8 +17,9 @@ export type Kind = "rule" | "memory" | "ambiguous"
1717const ASKED_RULE = / \b a s \s + a \s + (?: t e a m \s + ) ? r u l e \b / i
1818// Only the named forms: a bare "for me" opens ordinary requests ("fix this model for me"), and "in memory" describes
1919// data ("never load the fact table in memory"). "Just for me" always names a personal scope; "remember … for me" only
20- // within one clause, so a later "for me" does not turn a team instruction into a memory.
21- const ASKED_MEMORY = / \b a s \s + a \s + m e m o r y \b | \b i n \s + m y \s + m e m o r y \b | \b j u s t \s + f o r \s + m e \b | \b r e m e m b e r \b [ ^ . ! ? \n , ; : ] * \b f o r \s + m e \b / i
20+ // within one clause, so a later "for me" does not turn a team instruction into a memory. The clause scan is bounded:
21+ // unbounded, every "remember" rescans to the clause end, and a long text takes seconds.
22+ const ASKED_MEMORY = / \b a s \s + a \s + m e m o r y \b | \b i n \s + m y \s + m e m o r y \b | \b j u s t \s + f o r \s + m e \b | \b r e m e m b e r \b [ ^ . ! ? \n , ; : ] { 0 , 300 } \b f o r \s + m e \b / i
2223
2324// "I want …" / "I like …" open many ordinary requests ("I want staging models in models/staging"): on its own
2425// that is not enough to file a team convention as a personal memory, so it only makes the text ambiguous.
@@ -27,7 +28,7 @@ const WEAK_MEMORY = /\bi\s+(?:like|want)\b/i
2728const MEMORY_CUES : readonly [ RegExp , string ] [ ] = [
2829 [ / \b i \s + (?: p r e f e r | u s u a l l y | t e n d t o ) \b / i, "a personal preference" ] ,
2930 [ / \b m y \s + (?: p r e f e r e n c e | s t y l e | d e f a u l t | s e t u p | m a c h i n e | l a p t o p ) \b / i, "a personal preference" ] ,
30- [ / \b r e m e m b e r \s + (?: t h a t | o u r | t h e ) \b (? ! .* \b (?: a l w a y s | n e v e r | m u s t ) \b ) / i, "a fact to remember" ] ,
31+ [ / \b r e m e m b e r \s + (?: t h a t | o u r | t h e ) \b (? ! .{ 0 , 2000 } \b (?: a l w a y s | n e v e r | m u s t ) \b ) / i, "a fact to remember" ] ,
3132 [ / \b (?: o u r | t h e ) \s + (?: w a r e h o u s e | d a t a b a s e | a c c o u n t | c l u s t e r | s t a c k | r e g i o n | t e a m | c o m p a n y | o r g ) \s + (?: i s | u s e s | r u n s | l i v e s ) \b / i, "a fact about the environment" ] ,
3233 [ / \b [ A - Z ] { 2 , } \s + (?: m e a n s | s t a n d s f o r | i s s h o r t f o r ) \b | \b m e a n s \b .* \b (?: r e v e n u e | u s e r s ? | c u s t o m e r s ? | m e t r i c ) \b / , "a glossary term" ] ,
3334]
@@ -41,11 +42,7 @@ const RULE_CUES: readonly [RegExp, string][] = [
4142 [ / \b (?: n a m e | p r e f i x | s u f f i x | a l i a s ) \s + \S + (?: \s + \S + ) ? \s + (?: a s | w i t h | l i k e ) \b / i, "a naming convention" ] ,
4243]
4344
44- // A request to remember is short, and some of the patterns backtrack: a longer text is left to the person to choose.
45- const MAX_CLASSIFIED_CHARS = 2000
46-
4745export function classify ( text : string ) : { kind : Kind ; cue ?: string } {
48- if ( text . length > MAX_CLASSIFIED_CHARS ) return { kind : "ambiguous" }
4946 if ( ASKED_RULE . test ( text ) ) return { kind : "rule" , cue : "asked for a rule" }
5047 if ( ASKED_MEMORY . test ( text ) ) return { kind : "memory" , cue : "asked to remember it for themselves" }
5148 const memory = MEMORY_CUES . find ( ( [ pattern ] ) => pattern . test ( text ) )
0 commit comments