claude-cortex 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +291 -0
  2. package/dist/api/events.d.ts +134 -0
  3. package/dist/api/events.d.ts.map +1 -0
  4. package/dist/api/events.js +73 -0
  5. package/dist/api/events.js.map +1 -0
  6. package/dist/api/visualization-server.d.ts +11 -0
  7. package/dist/api/visualization-server.d.ts.map +1 -0
  8. package/dist/api/visualization-server.js +653 -0
  9. package/dist/api/visualization-server.js.map +1 -0
  10. package/dist/context/project-context.d.ts +57 -0
  11. package/dist/context/project-context.d.ts.map +1 -0
  12. package/dist/context/project-context.js +135 -0
  13. package/dist/context/project-context.js.map +1 -0
  14. package/dist/database/init.d.ts +49 -0
  15. package/dist/database/init.d.ts.map +1 -0
  16. package/dist/database/init.js +336 -0
  17. package/dist/database/init.js.map +1 -0
  18. package/dist/embeddings/generator.d.ts +20 -0
  19. package/dist/embeddings/generator.d.ts.map +1 -0
  20. package/dist/embeddings/generator.js +77 -0
  21. package/dist/embeddings/generator.js.map +1 -0
  22. package/dist/embeddings/index.d.ts +2 -0
  23. package/dist/embeddings/index.d.ts.map +1 -0
  24. package/dist/embeddings/index.js +2 -0
  25. package/dist/embeddings/index.js.map +1 -0
  26. package/dist/errors.d.ts +74 -0
  27. package/dist/errors.d.ts.map +1 -0
  28. package/dist/errors.js +131 -0
  29. package/dist/errors.js.map +1 -0
  30. package/dist/index.d.ts +16 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +83 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/memory/activation.d.ts +69 -0
  35. package/dist/memory/activation.d.ts.map +1 -0
  36. package/dist/memory/activation.js +168 -0
  37. package/dist/memory/activation.js.map +1 -0
  38. package/dist/memory/consolidate.d.ts +96 -0
  39. package/dist/memory/consolidate.d.ts.map +1 -0
  40. package/dist/memory/consolidate.js +400 -0
  41. package/dist/memory/consolidate.js.map +1 -0
  42. package/dist/memory/contradiction.d.ts +69 -0
  43. package/dist/memory/contradiction.d.ts.map +1 -0
  44. package/dist/memory/contradiction.js +286 -0
  45. package/dist/memory/contradiction.js.map +1 -0
  46. package/dist/memory/decay.d.ts +62 -0
  47. package/dist/memory/decay.d.ts.map +1 -0
  48. package/dist/memory/decay.js +184 -0
  49. package/dist/memory/decay.js.map +1 -0
  50. package/dist/memory/salience.d.ts +36 -0
  51. package/dist/memory/salience.d.ts.map +1 -0
  52. package/dist/memory/salience.js +200 -0
  53. package/dist/memory/salience.js.map +1 -0
  54. package/dist/memory/similarity.d.ts +57 -0
  55. package/dist/memory/similarity.d.ts.map +1 -0
  56. package/dist/memory/similarity.js +114 -0
  57. package/dist/memory/similarity.js.map +1 -0
  58. package/dist/memory/store.d.ts +170 -0
  59. package/dist/memory/store.d.ts.map +1 -0
  60. package/dist/memory/store.js +973 -0
  61. package/dist/memory/store.js.map +1 -0
  62. package/dist/memory/types.d.ts +91 -0
  63. package/dist/memory/types.d.ts.map +1 -0
  64. package/dist/memory/types.js +30 -0
  65. package/dist/memory/types.js.map +1 -0
  66. package/dist/server.d.ts +12 -0
  67. package/dist/server.d.ts.map +1 -0
  68. package/dist/server.js +466 -0
  69. package/dist/server.js.map +1 -0
  70. package/dist/tools/context.d.ts +135 -0
  71. package/dist/tools/context.d.ts.map +1 -0
  72. package/dist/tools/context.js +273 -0
  73. package/dist/tools/context.js.map +1 -0
  74. package/dist/tools/forget.d.ts +53 -0
  75. package/dist/tools/forget.d.ts.map +1 -0
  76. package/dist/tools/forget.js +179 -0
  77. package/dist/tools/forget.js.map +1 -0
  78. package/dist/tools/recall.d.ts +74 -0
  79. package/dist/tools/recall.d.ts.map +1 -0
  80. package/dist/tools/recall.js +140 -0
  81. package/dist/tools/recall.js.map +1 -0
  82. package/dist/tools/remember.d.ts +65 -0
  83. package/dist/tools/remember.d.ts.map +1 -0
  84. package/dist/tools/remember.js +147 -0
  85. package/dist/tools/remember.js.map +1 -0
  86. package/dist/worker/brain-worker.d.ts +100 -0
  87. package/dist/worker/brain-worker.d.ts.map +1 -0
  88. package/dist/worker/brain-worker.js +261 -0
  89. package/dist/worker/brain-worker.js.map +1 -0
  90. package/dist/worker/link-discovery.d.ts +47 -0
  91. package/dist/worker/link-discovery.d.ts.map +1 -0
  92. package/dist/worker/link-discovery.js +103 -0
  93. package/dist/worker/link-discovery.js.map +1 -0
  94. package/dist/worker/predictive-consolidation.d.ts +46 -0
  95. package/dist/worker/predictive-consolidation.d.ts.map +1 -0
  96. package/dist/worker/predictive-consolidation.js +110 -0
  97. package/dist/worker/predictive-consolidation.js.map +1 -0
  98. package/dist/worker/types.d.ts +91 -0
  99. package/dist/worker/types.d.ts.map +1 -0
  100. package/dist/worker/types.js +22 -0
  101. package/dist/worker/types.js.map +1 -0
  102. package/package.json +59 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Salience Detection System
3
+ *
4
+ * Determines what information is worth remembering, like how the human brain
5
+ * filters important from unimportant information.
6
+ */
7
+ import { MemoryCategory, SalienceFactors, MemoryInput } from './types.js';
8
+ /**
9
+ * Calculate salience score based on content analysis
10
+ */
11
+ export declare function calculateSalience(input: MemoryInput): number;
12
+ /**
13
+ * Analyze content to extract salience factors
14
+ */
15
+ export declare function analyzeSalienceFactors(input: MemoryInput): SalienceFactors;
16
+ /**
17
+ * Compute final salience score from factors
18
+ */
19
+ export declare function computeSalienceScore(factors: SalienceFactors): number;
20
+ /**
21
+ * Suggest a category based on content analysis
22
+ */
23
+ export declare function suggestCategory(input: MemoryInput): MemoryCategory;
24
+ /**
25
+ * Extract tags from content
26
+ */
27
+ export declare function extractTags(input: MemoryInput): string[];
28
+ /**
29
+ * Analyze if content is worth remembering at all
30
+ */
31
+ export declare function isWorthRemembering(input: MemoryInput, minSalience?: number): boolean;
32
+ /**
33
+ * Get a human-readable explanation of why something was considered important
34
+ */
35
+ export declare function explainSalience(factors: SalienceFactors): string;
36
+ //# sourceMappingURL=salience.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salience.d.ts","sourceRoot":"","sources":["../../src/memory/salience.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAwC1E;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAG5D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,CAa1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAmBrE;AAkCD;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAmBlE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,EAAE,CA0BxD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,GAAE,MAAY,GAAG,OAAO,CAGzF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAchE"}
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Salience Detection System
3
+ *
4
+ * Determines what information is worth remembering, like how the human brain
5
+ * filters important from unimportant information.
6
+ */
7
+ // Keywords that indicate high-importance content
8
+ const ARCHITECTURE_KEYWORDS = [
9
+ 'architecture', 'design', 'pattern', 'structure', 'system',
10
+ 'database', 'api', 'schema', 'model', 'framework', 'stack',
11
+ 'microservice', 'monolith', 'serverless', 'infrastructure'
12
+ ];
13
+ const ERROR_KEYWORDS = [
14
+ 'error', 'bug', 'fix', 'issue', 'problem', 'crash', 'fail',
15
+ 'exception', 'debug', 'resolve', 'solution', 'workaround'
16
+ ];
17
+ const PREFERENCE_KEYWORDS = [
18
+ 'prefer', 'always', 'never', 'style', 'convention', 'standard',
19
+ 'like', 'want', 'should', 'must', 'require'
20
+ ];
21
+ const PATTERN_KEYWORDS = [
22
+ 'pattern', 'practice', 'approach', 'method', 'technique',
23
+ 'implementation', 'strategy', 'algorithm', 'workflow'
24
+ ];
25
+ const EMOTIONAL_MARKERS = [
26
+ 'important', 'critical', 'crucial', 'essential', 'key',
27
+ 'finally', 'breakthrough', 'eureka', 'aha', 'got it',
28
+ 'frustrating', 'annoying', 'tricky', 'remember'
29
+ ];
30
+ // Code reference patterns
31
+ const CODE_REFERENCE_PATTERNS = [
32
+ /\b[A-Z][a-zA-Z]*\.[a-zA-Z]+\b/, // Class.method
33
+ /\b[a-z_][a-zA-Z0-9_]*\.(ts|js|py|go|rs)\b/, // filename.ext
34
+ /`[^`]+`/, // backtick code
35
+ /\b(function|class|interface|type|const|let|var)\s+\w+/i, // declarations
36
+ /\bline\s*\d+\b/i, // line references
37
+ /\b(src|lib|app|components?)\/\S+/, // path references
38
+ ];
39
+ /**
40
+ * Calculate salience score based on content analysis
41
+ */
42
+ export function calculateSalience(input) {
43
+ const factors = analyzeSalienceFactors(input);
44
+ return computeSalienceScore(factors);
45
+ }
46
+ /**
47
+ * Analyze content to extract salience factors
48
+ */
49
+ export function analyzeSalienceFactors(input) {
50
+ const text = `${input.title} ${input.content}`.toLowerCase();
51
+ return {
52
+ explicitRequest: detectExplicitRequest(text),
53
+ isArchitectureDecision: detectKeywords(text, ARCHITECTURE_KEYWORDS),
54
+ isErrorResolution: detectKeywords(text, ERROR_KEYWORDS),
55
+ isCodePattern: detectKeywords(text, PATTERN_KEYWORDS),
56
+ isUserPreference: detectKeywords(text, PREFERENCE_KEYWORDS),
57
+ mentionCount: 1, // Will be updated by external context
58
+ hasCodeReference: detectCodeReferences(input.content),
59
+ emotionalMarkers: detectKeywords(text, EMOTIONAL_MARKERS),
60
+ };
61
+ }
62
+ /**
63
+ * Compute final salience score from factors
64
+ */
65
+ export function computeSalienceScore(factors) {
66
+ let score = 0.25; // Base score (lowered from 0.4 so trivial notes don't appear important)
67
+ // Weight each factor
68
+ if (factors.explicitRequest)
69
+ score += 0.5; // Highest weight
70
+ if (factors.isArchitectureDecision)
71
+ score += 0.4;
72
+ if (factors.isErrorResolution)
73
+ score += 0.35;
74
+ if (factors.isCodePattern)
75
+ score += 0.25;
76
+ if (factors.isUserPreference)
77
+ score += 0.25;
78
+ if (factors.hasCodeReference)
79
+ score += 0.15;
80
+ if (factors.emotionalMarkers)
81
+ score += 0.2;
82
+ // Mention count bonus (diminishing returns)
83
+ if (factors.mentionCount > 1) {
84
+ score += Math.min(0.3, Math.log2(factors.mentionCount) * 0.1);
85
+ }
86
+ // Cap at 1.0
87
+ return Math.min(1.0, score);
88
+ }
89
+ /**
90
+ * Detect if user explicitly requested to remember
91
+ */
92
+ function detectExplicitRequest(text) {
93
+ const patterns = [
94
+ /\bremember\s+(this|that)\b/i,
95
+ /\bdon'?t\s+forget\b/i,
96
+ /\bkeep\s+(in\s+)?mind\b/i,
97
+ /\bnote\s+(this|that)\b/i,
98
+ /\bsave\s+(this|that)\b/i,
99
+ /\bstore\s+(this|that)\b/i,
100
+ /\bimportant[:\s]/i,
101
+ /\bfor\s+future\s+reference\b/i,
102
+ ];
103
+ return patterns.some(pattern => pattern.test(text));
104
+ }
105
+ /**
106
+ * Detect presence of keywords in text
107
+ */
108
+ function detectKeywords(text, keywords) {
109
+ return keywords.some(keyword => text.includes(keyword.toLowerCase()));
110
+ }
111
+ /**
112
+ * Detect code references in content
113
+ */
114
+ function detectCodeReferences(content) {
115
+ return CODE_REFERENCE_PATTERNS.some(pattern => pattern.test(content));
116
+ }
117
+ /**
118
+ * Suggest a category based on content analysis
119
+ */
120
+ export function suggestCategory(input) {
121
+ const text = `${input.title} ${input.content}`.toLowerCase();
122
+ if (detectKeywords(text, ARCHITECTURE_KEYWORDS))
123
+ return 'architecture';
124
+ if (detectKeywords(text, ERROR_KEYWORDS))
125
+ return 'error';
126
+ if (detectKeywords(text, PREFERENCE_KEYWORDS))
127
+ return 'preference';
128
+ if (detectKeywords(text, PATTERN_KEYWORDS))
129
+ return 'pattern';
130
+ // Check for TODO patterns
131
+ if (/\b(todo|fixme|hack|xxx)\b/i.test(text))
132
+ return 'todo';
133
+ // Check for learning patterns
134
+ if (/\b(learned?|discovered?|realized?|found\s+out)\b/i.test(text))
135
+ return 'learning';
136
+ // Check for relationship patterns
137
+ if (/\b(depends?\s+on|requires?|uses?|imports?|extends?)\b/i.test(text))
138
+ return 'relationship';
139
+ // Default to note
140
+ return 'note';
141
+ }
142
+ /**
143
+ * Extract tags from content
144
+ */
145
+ export function extractTags(input) {
146
+ const tags = new Set(input.tags || []);
147
+ const text = `${input.title} ${input.content}`;
148
+ // Extract hashtags
149
+ const hashtagMatches = text.match(/#[a-zA-Z][a-zA-Z0-9_-]*/g);
150
+ if (hashtagMatches) {
151
+ hashtagMatches.forEach(tag => tags.add(tag.slice(1).toLowerCase()));
152
+ }
153
+ // Extract common tech terms
154
+ const techTerms = [
155
+ 'react', 'vue', 'angular', 'node', 'python', 'typescript', 'javascript',
156
+ 'api', 'database', 'sql', 'nosql', 'mongodb', 'postgresql', 'mysql',
157
+ 'docker', 'kubernetes', 'aws', 'gcp', 'azure', 'git', 'ci/cd',
158
+ 'testing', 'auth', 'security', 'performance', 'caching'
159
+ ];
160
+ const lowerText = text.toLowerCase();
161
+ techTerms.forEach(term => {
162
+ if (lowerText.includes(term)) {
163
+ tags.add(term);
164
+ }
165
+ });
166
+ return Array.from(tags).slice(0, 10); // Limit to 10 tags
167
+ }
168
+ /**
169
+ * Analyze if content is worth remembering at all
170
+ */
171
+ export function isWorthRemembering(input, minSalience = 0.3) {
172
+ const salience = calculateSalience(input);
173
+ return salience >= minSalience;
174
+ }
175
+ /**
176
+ * Get a human-readable explanation of why something was considered important
177
+ */
178
+ export function explainSalience(factors) {
179
+ const reasons = [];
180
+ if (factors.explicitRequest)
181
+ reasons.push('explicitly requested to remember');
182
+ if (factors.isArchitectureDecision)
183
+ reasons.push('architecture decision');
184
+ if (factors.isErrorResolution)
185
+ reasons.push('error resolution');
186
+ if (factors.isCodePattern)
187
+ reasons.push('code pattern');
188
+ if (factors.isUserPreference)
189
+ reasons.push('user preference');
190
+ if (factors.hasCodeReference)
191
+ reasons.push('references specific code');
192
+ if (factors.emotionalMarkers)
193
+ reasons.push('marked as important');
194
+ if (factors.mentionCount > 1)
195
+ reasons.push(`mentioned ${factors.mentionCount} times`);
196
+ if (reasons.length === 0)
197
+ return 'general note';
198
+ return reasons.join(', ');
199
+ }
200
+ //# sourceMappingURL=salience.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salience.js","sourceRoot":"","sources":["../../src/memory/salience.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,iDAAiD;AACjD,MAAM,qBAAqB,GAAG;IAC5B,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ;IAC1D,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO;IAC1D,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB;CAC3D,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM;IAC1D,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY;CAC1D,CAAC;AAEF,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU;IAC9D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS;CAC5C,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW;IACxD,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU;CACtD,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,WAAW,EAAE,UA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EG;AACH,MAAM,UAAU,eAAe,CAAC,OAAwB;IACtD,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,IAAI,OAAO,CAAC,eAAe;QAAE,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAC9E,IAAI,OAAO,CAAC,sBAAsB;QAAE,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC1E,IAAI,OAAO,CAAC,iBAAiB;QAAE,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAChE,IAAI,OAAO,CAAC,aAAa;QAAE,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxD,IAAI,OAAO,CAAC,gBAAgB;QAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC9D,IAAI,OAAO,CAAC,gBAAgB;QAAE,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACvE,IAAI,OAAO,CAAC,gBAAgB;QAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClE,IAAI,OAAO,CAAC,YAAY,GAAG,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,aAAa,OAAO,CAAC,YAAY,QAAQ,CAAC,CAAC;IAEtF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,cAAc,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Text Similarity Utilities
3
+ *
4
+ * Provides Jaccard similarity and related text comparison functions
5
+ * for memory enrichment and contradiction detection.
6
+ *
7
+ * Phase 3 Organic Brain Feature
8
+ */
9
+ /**
10
+ * Tokenize text into a set of normalized words
11
+ * Removes punctuation, lowercases, and filters short words
12
+ */
13
+ export declare function tokenize(text: string): Set<string>;
14
+ /**
15
+ * Calculate Jaccard similarity between two texts
16
+ * Returns a value between 0 (completely different) and 1 (identical)
17
+ *
18
+ * Jaccard Index = |A ∩ B| / |A ∪ B|
19
+ *
20
+ * @param textA - First text to compare
21
+ * @param textB - Second text to compare
22
+ * @returns Similarity score between 0 and 1
23
+ */
24
+ export declare function jaccardSimilarity(textA: string, textB: string): number;
25
+ /**
26
+ * Extract key phrases/concepts from text
27
+ * Used for topic comparison in contradiction detection
28
+ *
29
+ * Extracts:
30
+ * - Quoted phrases ("like this")
31
+ * - Backticked code/terms (`like_this`)
32
+ * - Capitalized terms (LikeThis)
33
+ *
34
+ * @param text - Text to extract key phrases from
35
+ * @returns Array of unique key phrases (lowercased)
36
+ */
37
+ export declare function extractKeyPhrases(text: string): string[];
38
+ /**
39
+ * Calculate word overlap between two texts
40
+ * Returns the count of shared words
41
+ *
42
+ * @param textA - First text
43
+ * @param textB - Second text
44
+ * @returns Number of shared words
45
+ */
46
+ export declare function wordOverlap(textA: string, textB: string): number;
47
+ /**
48
+ * Check if two texts share significant content
49
+ * Quick check before running full similarity calculation
50
+ *
51
+ * @param textA - First text
52
+ * @param textB - Second text
53
+ * @param minOverlap - Minimum word overlap required
54
+ * @returns True if texts share at least minOverlap words
55
+ */
56
+ export declare function hasSignificantOverlap(textA: string, textB: string, minOverlap?: number): boolean;
57
+ //# sourceMappingURL=similarity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"similarity.d.ts","sourceRoot":"","sources":["../../src/memory/similarity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAQlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAiBtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA4BxD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAU,GACrB,OAAO,CAET"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Text Similarity Utilities
3
+ *
4
+ * Provides Jaccard similarity and related text comparison functions
5
+ * for memory enrichment and contradiction detection.
6
+ *
7
+ * Phase 3 Organic Brain Feature
8
+ */
9
+ /**
10
+ * Tokenize text into a set of normalized words
11
+ * Removes punctuation, lowercases, and filters short words
12
+ */
13
+ export function tokenize(text) {
14
+ return new Set(text
15
+ .toLowerCase()
16
+ .replace(/[^\w\s]/g, ' ') // Remove punctuation
17
+ .split(/\s+/)
18
+ .filter(word => word.length > 2) // Filter very short words
19
+ );
20
+ }
21
+ /**
22
+ * Calculate Jaccard similarity between two texts
23
+ * Returns a value between 0 (completely different) and 1 (identical)
24
+ *
25
+ * Jaccard Index = |A ∩ B| / |A ∪ B|
26
+ *
27
+ * @param textA - First text to compare
28
+ * @param textB - Second text to compare
29
+ * @returns Similarity score between 0 and 1
30
+ */
31
+ export function jaccardSimilarity(textA, textB) {
32
+ const setA = tokenize(textA);
33
+ const setB = tokenize(textB);
34
+ if (setA.size === 0 && setB.size === 0)
35
+ return 1.0;
36
+ if (setA.size === 0 || setB.size === 0)
37
+ return 0.0;
38
+ // Calculate intersection
39
+ let intersection = 0;
40
+ for (const word of setA) {
41
+ if (setB.has(word))
42
+ intersection++;
43
+ }
44
+ // Calculate union: |A| + |B| - |A ∩ B|
45
+ const union = setA.size + setB.size - intersection;
46
+ return intersection / union;
47
+ }
48
+ /**
49
+ * Extract key phrases/concepts from text
50
+ * Used for topic comparison in contradiction detection
51
+ *
52
+ * Extracts:
53
+ * - Quoted phrases ("like this")
54
+ * - Backticked code/terms (`like_this`)
55
+ * - Capitalized terms (LikeThis)
56
+ *
57
+ * @param text - Text to extract key phrases from
58
+ * @returns Array of unique key phrases (lowercased)
59
+ */
60
+ export function extractKeyPhrases(text) {
61
+ const phrases = [];
62
+ // Extract quoted phrases
63
+ const quotedMatches = text.match(/"[^"]+"/g);
64
+ if (quotedMatches) {
65
+ phrases.push(...quotedMatches.map(m => m.replace(/"/g, '').toLowerCase()));
66
+ }
67
+ // Extract backticked code/terms
68
+ const backtickMatches = text.match(/`[^`]+`/g);
69
+ if (backtickMatches) {
70
+ phrases.push(...backtickMatches.map(m => m.replace(/`/g, '').toLowerCase()));
71
+ }
72
+ // Extract capitalized terms (likely proper nouns/tech terms)
73
+ const capitalMatches = text.match(/\b[A-Z][a-zA-Z0-9]+\b/g);
74
+ if (capitalMatches) {
75
+ phrases.push(...capitalMatches.map(m => m.toLowerCase()));
76
+ }
77
+ // Extract common tech terms that might not be capitalized
78
+ const techTerms = text.match(/\b(?:api|sql|css|html|json|xml|http|rest|graphql|docker|kubernetes|redis|postgres|sqlite|mongodb|react|vue|angular|node|npm|yarn|git|github|aws|gcp|azure)\b/gi);
79
+ if (techTerms) {
80
+ phrases.push(...techTerms.map(m => m.toLowerCase()));
81
+ }
82
+ return [...new Set(phrases)];
83
+ }
84
+ /**
85
+ * Calculate word overlap between two texts
86
+ * Returns the count of shared words
87
+ *
88
+ * @param textA - First text
89
+ * @param textB - Second text
90
+ * @returns Number of shared words
91
+ */
92
+ export function wordOverlap(textA, textB) {
93
+ const setA = tokenize(textA);
94
+ const setB = tokenize(textB);
95
+ let overlap = 0;
96
+ for (const word of setA) {
97
+ if (setB.has(word))
98
+ overlap++;
99
+ }
100
+ return overlap;
101
+ }
102
+ /**
103
+ * Check if two texts share significant content
104
+ * Quick check before running full similarity calculation
105
+ *
106
+ * @param textA - First text
107
+ * @param textB - Second text
108
+ * @param minOverlap - Minimum word overlap required
109
+ * @returns True if texts share at least minOverlap words
110
+ */
111
+ export function hasSignificantOverlap(textA, textB, minOverlap = 3) {
112
+ return wordOverlap(textA, textB) >= minOverlap;
113
+ }
114
+ //# sourceMappingURL=similarity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"similarity.js","sourceRoot":"","sources":["../../src/memory/similarity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,IAAI,GAAG,CACZ,IAAI;SACD,WAAW,EAAE;SACb,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,qBAAqB;SAC9C,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,0BAA0B;KAC9D,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,KAAa;IAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE7B,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACnD,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAEnD,yBAAyB;IACzB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,YAAY,EAAE,CAAC;IACrC,CAAC;IAED,uCAAuC;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAEnD,OAAO,YAAY,GAAG,KAAK,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,C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AOG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,KAAa;IACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE7B,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAa,EACb,KAAa,EACb,aAAqB,CAAC;IAEtB,OAAO,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC;AACjD,CAAC"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Memory Store
3
+ *
4
+ * Core CRUD operations for the memory database.
5
+ * Handles storage, retrieval, and management of memories.
6
+ */
7
+ import { Memory, MemoryInput, MemoryType, SearchOptions, SearchResult, MemoryConfig } from './types.js';
8
+ /**
9
+ * Get truncation info from the last addMemory call
10
+ */
11
+ export declare function getLastTruncationInfo(): {
12
+ wasTruncated: boolean;
13
+ originalLength: number;
14
+ truncatedLength: number;
15
+ } | null;
16
+ /**
17
+ * Convert database row to Memory object
18
+ */
19
+ export declare function rowToMemory(row: Record<string, unknown>): Memory;
20
+ /**
21
+ * Add a new memory
22
+ */
23
+ export declare function addMemory(input: MemoryInput, config?: MemoryConfig): Memory;
24
+ /**
25
+ * Get a memory by ID
26
+ */
27
+ export declare function getMemoryById(id: number): Memory | null;
28
+ /**
29
+ * Update a memory
30
+ */
31
+ export declare function updateMemory(id: number, updates: Partial<MemoryInput>): Memory | null;
32
+ /**
33
+ * Delete a memory
34
+ */
35
+ export declare function deleteMemory(id: number): boolean;
36
+ /**
37
+ * Access a memory (updates access count and timestamp, returns reinforced memory)
38
+ */
39
+ export declare function accessMemory(id: number, config?: MemoryConfig): Memory | null;
40
+ /**
41
+ * Soft access - updates last_accessed without boosting salience
42
+ * Used for search results to close the reinforcement loop
43
+ * ORGANIC FEATURE: This allows searched memories to stay fresh without
44
+ * artificially inflating their salience scores
45
+ */
46
+ export declare function softAccessMemory(id: number): void;
47
+ /**
48
+ * Enrichment result indicating what happened
49
+ */
50
+ export interface EnrichmentResult {
51
+ enriched: boolean;
52
+ reason: string;
53
+ }
54
+ /**
55
+ * Enrich a memory with additional context
56
+ *
57
+ * This adds timestamped context to a memory when:
58
+ * 1. The new context is sufficiently related but different (new information)
59
+ * 2. The memory hasn't been enriched recently (cooldown)
60
+ * 3. The content won't exceed the size limit
61
+ *
62
+ * ORGANIC FEATURE: Memories grow with new context over time,
63
+ * mimicking how human memories are reconsolidated with new information
64
+ *
65
+ * @param memoryId - ID of the memory to enrich
66
+ * @param newContext - New context to add
67
+ * @param contextType - Type of context ('search' | 'access' | 'related')
68
+ * @returns EnrichmentResult indicating success or failure with reason
69
+ */
70
+ export declare function enrichMemory(memoryId: number, newContext: string, contextType?: 'search' | 'access' | 'related'): EnrichmentResult;
71
+ /**
72
+ * Clear enrichment cooldown for a memory (for testing)
73
+ */
74
+ export declare function clearEnrichmentCooldown(memoryId: number): void;
75
+ /**
76
+ * Get enrichment cooldown status for a memory
77
+ */
78
+ export declare function getEnrichmentCooldownStatus(memoryId: number): {
79
+ onCooldown: boolean;
80
+ remainingMs: number;
81
+ };
82
+ /**
83
+ * Update persisted decay scores for all memories
84
+ * Called during consolidation and periodically by the API server
85
+ * Returns the number of memories updated
86
+ */
87
+ export declare function updateDecayScores(): number;
88
+ /**
89
+ * Search memories using full-text search, vector similarity, and filters
90
+ * Now uses hybrid search combining FTS5 keywords with semantic vector matching
91
+ */
92
+ export declare function searchMemories(options: SearchOptions, config?: MemoryConfig): Promise<SearchResult[]>;
93
+ /**
94
+ * Get all memories for a project
95
+ */
96
+ export declare function getProjectMemories(project: string, config?: MemoryConfig): Memory[];
97
+ /**
98
+ * Get recent memories
99
+ */
100
+ export declare function getRecentMemories(limit?: number, project?: string): Memory[];
101
+ /**
102
+ * Get memories by type
103
+ */
104
+ export declare function getMemoriesByType(type: MemoryType, limit?: number): Memory[];
105
+ /**
106
+ * Get high-priority memories (for context injection)
107
+ */
108
+ export declare function getHighPriorityMemories(limit?: number, project?: string): Memory[];
109
+ /**
110
+ * Promote a memory from short-term to long-term
111
+ */
112
+ export declare function promoteMemory(id: number): Memory | null;
113
+ /**
114
+ * Bulk delete decayed memories
115
+ */
116
+ export declare function cleanupDecayedMemories(config?: MemoryConfig): number;
117
+ /**
118
+ * Get memory statistics
119
+ */
120
+ export declare function getMemoryStats(project?: string): {
121
+ total: number;
122
+ shortTerm: number;
123
+ longTerm: number;
124
+ episodic: number;
125
+ byCategory: Record<string, number>;
126
+ averageSalience: number;
127
+ };
128
+ export type RelationshipType = 'references' | 'extends' | 'contradicts' | 'related';
129
+ export interface MemoryLink {
130
+ id: number;
131
+ sourceId: number;
132
+ targetId: number;
133
+ relationship: RelationshipType;
134
+ strength: number;
135
+ createdAt: Date;
136
+ }
137
+ /**
138
+ * Create a link between two memories
139
+ */
140
+ export declare function createMemoryLink(sourceId: number, targetId: number, relationship: RelationshipType, strength?: number): MemoryLink | null;
141
+ /**
142
+ * Get all memories related to a given memory
143
+ */
144
+ export declare function getRelatedMemories(memoryId: number): {
145
+ memory: Memory;
146
+ relationship: RelationshipType;
147
+ strength: number;
148
+ direction: 'outgoing' | 'incoming';
149
+ }[];
150
+ /**
151
+ * Delete a memory link
152
+ */
153
+ export declare function deleteMemoryLink(sourceId: number, targetId: number): boolean;
154
+ /**
155
+ * Get all memory links
156
+ */
157
+ export declare function getAllMemoryLinks(): MemoryLink[];
158
+ /**
159
+ * Detect potential relationships for a new memory
160
+ * Returns memories that might be related based on:
161
+ * - Shared tags
162
+ * - Similar project
163
+ * - Content similarity (keywords)
164
+ */
165
+ export declare function detectRelationships(memory: Memory, maxResults?: number): {
166
+ targetId: number;
167
+ relationship: RelationshipType;
168
+ strength: number;
169
+ }[];
170
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/memory/store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,MAAM,EACN,WAAW,EACX,UAAU,EAEV,aAAa,EACb,YAAY,EACZ,YAAY,EAEb,MAAM,YAAY,CAAC;AA+CpB;;GAEG;AACH,wBAAgB,qBAAqB;kBArBG,OAAO;oBAAkB,MAAM;qBAAmB,MAAM;SAuB/F;AAgCD;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAmBhE;AAkBD;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,MAAM,GAAE,YAA6B,GACpC,MAAM,CAsGR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAC5B,MAAM,GAAG,IAAI,CAoDf;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAchD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,YAA6B,GACpC,MAAM,GAAG,IAAI,CA4Df;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAIjD;AAcD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC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