@@ -18,8 +18,28 @@ interface SupermemoryConfig {
1818 injectProfile ?: boolean ;
1919 containerTagPrefix ?: string ;
2020 filterPrompt ?: string ;
21+ keywordPatterns ?: string [ ] ;
2122}
2223
24+ const DEFAULT_KEYWORD_PATTERNS = [
25+ "remember" ,
26+ "memorize" ,
27+ "save\\s+this" ,
28+ "note\\s+this" ,
29+ "keep\\s+in\\s+mind" ,
30+ "don'?t\\s+forget" ,
31+ "learn\\s+this" ,
32+ "store\\s+this" ,
33+ "record\\s+this" ,
34+ "make\\s+a\\s+note" ,
35+ "take\\s+note" ,
36+ "jot\\s+down" ,
37+ "commit\\s+to\\s+memory" ,
38+ "remember\\s+that" ,
39+ "never\\s+forget" ,
40+ "always\\s+remember" ,
41+ ] ;
42+
2343const DEFAULTS : Required < Omit < SupermemoryConfig , "apiKey" > > = {
2444 similarityThreshold : 0.6 ,
2545 maxMemories : 5 ,
@@ -28,8 +48,18 @@ const DEFAULTS: Required<Omit<SupermemoryConfig, "apiKey">> = {
2848 injectProfile : true ,
2949 containerTagPrefix : "opencode" ,
3050 filterPrompt : "You are a stateful coding agent. Remember all the information, including but not limited to user's coding preferences, tech stack, behaviours, workflows, and any other relevant details." ,
51+ keywordPatterns : [ ] ,
3152} ;
3253
54+ function isValidRegex ( pattern : string ) : boolean {
55+ try {
56+ new RegExp ( pattern ) ;
57+ return true ;
58+ } catch {
59+ return false ;
60+ }
61+ }
62+
3363function loadConfig ( ) : SupermemoryConfig {
3464 for ( const path of CONFIG_FILES ) {
3565 if ( existsSync ( path ) ) {
@@ -57,6 +87,10 @@ export const CONFIG = {
5787 injectProfile : fileConfig . injectProfile ?? DEFAULTS . injectProfile ,
5888 containerTagPrefix : fileConfig . containerTagPrefix ?? DEFAULTS . containerTagPrefix ,
5989 filterPrompt : fileConfig . filterPrompt ?? DEFAULTS . filterPrompt ,
90+ keywordPatterns : [
91+ ...DEFAULT_KEYWORD_PATTERNS ,
92+ ...( fileConfig . keywordPatterns ?? [ ] ) . filter ( isValidRegex ) ,
93+ ] ,
6094} ;
6195
6296export function isConfigured ( ) : boolean {
0 commit comments