claude-cortex 1.2.1 → 1.3.1
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.
- package/LICENSE +21 -0
- package/README.md +3 -3
- package/dashboard/src/app/error.tsx +49 -0
- package/dashboard/src/components/brain/BrainMesh.tsx +30 -15
- package/dashboard/src/components/brain/SynapseNodes.tsx +12 -6
- package/dashboard/src/lib/websocket.ts +10 -3
- package/dist/__tests__/store.test.d.ts +7 -0
- package/dist/__tests__/store.test.d.ts.map +1 -0
- package/dist/__tests__/store.test.js +321 -0
- package/dist/__tests__/store.test.js.map +1 -0
- package/dist/embeddings/generator.d.ts.map +1 -1
- package/dist/embeddings/generator.js +1 -0
- package/dist/embeddings/generator.js.map +1 -1
- package/dist/tools/recall.d.ts +2 -2
- package/dist/tools/remember.d.ts +2 -2
- package/package.json +9 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael Kyriacou
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Claude Code has fundamental limitations:
|
|
|
12
12
|
|
|
13
13
|
## The Solution
|
|
14
14
|
|
|
15
|
-
Claude
|
|
15
|
+
Claude Cortex works like a human brain:
|
|
16
16
|
|
|
17
17
|
- **Short-term memory** - Session-level, high detail, decays fast
|
|
18
18
|
- **Long-term memory** - Cross-session, consolidated, persists
|
|
@@ -277,8 +277,8 @@ npm run watch
|
|
|
277
277
|
|
|
278
278
|
## How This Differs from Other Solutions
|
|
279
279
|
|
|
280
|
-
| Feature | Claude
|
|
281
|
-
|
|
280
|
+
| Feature | Claude Cortex | Other MCP Memory Tools |
|
|
281
|
+
|---------|---------------|------------------------|
|
|
282
282
|
| Salience detection | ✅ Auto-detects importance | ❌ Manual only |
|
|
283
283
|
| Temporal decay | ✅ Memories fade naturally | ❌ Static storage |
|
|
284
284
|
| Consolidation | ✅ STM → LTM promotion | ❌ Flat storage |
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
export default function Error({
|
|
6
|
+
error,
|
|
7
|
+
reset,
|
|
8
|
+
}: {
|
|
9
|
+
error: Error & { digest?: string };
|
|
10
|
+
reset: () => void;
|
|
11
|
+
}) {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
console.error('[claude-cortex] Dashboard error:', error);
|
|
14
|
+
}, [error]);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="min-h-screen bg-[#0a0a0f] flex items-center justify-center p-4">
|
|
18
|
+
<div className="max-w-md w-full bg-gray-900 rounded-lg border border-gray-800 p-6 text-center">
|
|
19
|
+
<div className="text-4xl mb-4">🧠</div>
|
|
20
|
+
<h2 className="text-xl font-semibold text-white mb-2">
|
|
21
|
+
Visualization Error
|
|
22
|
+
</h2>
|
|
23
|
+
<p className="text-gray-400 mb-4">
|
|
24
|
+
The brain visualization encountered an error. This might be due to WebGL
|
|
25
|
+
compatibility or memory constraints.
|
|
26
|
+
</p>
|
|
27
|
+
{error.message && (
|
|
28
|
+
<pre className="text-xs text-red-400 bg-gray-950 p-3 rounded mb-4 overflow-auto max-h-32 text-left">
|
|
29
|
+
{error.message}
|
|
30
|
+
</pre>
|
|
31
|
+
)}
|
|
32
|
+
<div className="flex gap-3 justify-center">
|
|
33
|
+
<button
|
|
34
|
+
onClick={reset}
|
|
35
|
+
className="px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-md transition-colors"
|
|
36
|
+
>
|
|
37
|
+
Try Again
|
|
38
|
+
</button>
|
|
39
|
+
<button
|
|
40
|
+
onClick={() => window.location.reload()}
|
|
41
|
+
className="px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-md transition-colors"
|
|
42
|
+
>
|
|
43
|
+
Reload Page
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Uses simplex noise to create organic cortex-like surface folds
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { useMemo, useEffect } from 'react';
|
|
9
|
+
import { useMemo, useEffect, useRef } from 'react';
|
|
10
10
|
import * as THREE from 'three';
|
|
11
11
|
import { fbm3D, ridged3D } from '@/lib/simplex-noise';
|
|
12
12
|
|
|
@@ -85,28 +85,43 @@ export function BrainMesh({
|
|
|
85
85
|
opacity = 0.05,
|
|
86
86
|
showWireframe = true,
|
|
87
87
|
}: BrainMeshProps) {
|
|
88
|
+
// Use refs to track resources for proper cleanup
|
|
89
|
+
const geometryRef = useRef<THREE.BufferGeometry | null>(null);
|
|
90
|
+
const materialRef = useRef<THREE.MeshBasicMaterial | null>(null);
|
|
91
|
+
|
|
88
92
|
// Create geometry once
|
|
89
|
-
const brainGeometry = useMemo(() =>
|
|
93
|
+
const brainGeometry = useMemo(() => {
|
|
94
|
+
const geo = createBrainGeometry();
|
|
95
|
+
geometryRef.current = geo;
|
|
96
|
+
return geo;
|
|
97
|
+
}, []);
|
|
90
98
|
|
|
91
99
|
// Ghost wireframe material - very faint gray
|
|
92
|
-
const wireframeMaterial = useMemo(
|
|
93
|
-
(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
100
|
+
const wireframeMaterial = useMemo(() => {
|
|
101
|
+
const mat = new THREE.MeshBasicMaterial({
|
|
102
|
+
color: '#333333',
|
|
103
|
+
wireframe: true,
|
|
104
|
+
transparent: true,
|
|
105
|
+
opacity: opacity,
|
|
106
|
+
});
|
|
107
|
+
materialRef.current = mat;
|
|
108
|
+
return mat;
|
|
109
|
+
}, [opacity]);
|
|
102
110
|
|
|
103
111
|
// Cleanup on unmount to prevent GPU memory leaks
|
|
112
|
+
// Use refs to ensure we always dispose the actual resources
|
|
104
113
|
useEffect(() => {
|
|
105
114
|
return () => {
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
if (geometryRef.current) {
|
|
116
|
+
geometryRef.current.dispose();
|
|
117
|
+
geometryRef.current = null;
|
|
118
|
+
}
|
|
119
|
+
if (materialRef.current) {
|
|
120
|
+
materialRef.current.dispose();
|
|
121
|
+
materialRef.current = null;
|
|
122
|
+
}
|
|
108
123
|
};
|
|
109
|
-
}, [
|
|
124
|
+
}, []);
|
|
110
125
|
|
|
111
126
|
// Only render wireframe - no solid surface, no core, no animation
|
|
112
127
|
if (!showWireframe) return null;
|
|
@@ -63,23 +63,29 @@ export function SynapseNode({
|
|
|
63
63
|
const scale = size * (1 + pulse * 0.3 * activity);
|
|
64
64
|
meshRef.current.scale.setScalar(scale);
|
|
65
65
|
|
|
66
|
+
// Helper to safely update material opacity
|
|
67
|
+
const updateOpacity = (mesh: THREE.Mesh | null, opacity: number) => {
|
|
68
|
+
if (!mesh) return;
|
|
69
|
+
const mat = mesh.material;
|
|
70
|
+
if (mat && 'opacity' in mat && typeof mat.opacity === 'number') {
|
|
71
|
+
mat.opacity = opacity;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
66
75
|
// Core opacity
|
|
67
|
-
(meshRef.current.
|
|
68
|
-
0.7 + pulse * 0.3;
|
|
76
|
+
updateOpacity(meshRef.current, 0.7 + pulse * 0.3);
|
|
69
77
|
|
|
70
78
|
// Inner glow
|
|
71
79
|
if (glowRef.current) {
|
|
72
80
|
glowRef.current.scale.setScalar(scale * 2);
|
|
73
|
-
(glowRef.current.
|
|
74
|
-
(0.3 + pulse * 0.2) * activity;
|
|
81
|
+
updateOpacity(glowRef.current, (0.3 + pulse * 0.2) * activity);
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
// Outer glow (slower pulse)
|
|
78
85
|
if (outerGlowRef.current) {
|
|
79
86
|
const outerPulse = Math.sin(time * pulseSpeed * 0.5) * 0.5 + 0.5;
|
|
80
87
|
outerGlowRef.current.scale.setScalar(scale * 3.5 * (1 + outerPulse * 0.2));
|
|
81
|
-
(outerGlowRef.current.
|
|
82
|
-
(0.1 + outerPulse * 0.1) * activity;
|
|
88
|
+
updateOpacity(outerGlowRef.current, (0.1 + outerPulse * 0.1) * activity);
|
|
83
89
|
}
|
|
84
90
|
});
|
|
85
91
|
|
|
@@ -59,6 +59,13 @@ export function useMemoryWebSocket(options: UseMemoryWebSocketOptions = {}) {
|
|
|
59
59
|
timestamp: string;
|
|
60
60
|
} | null>(null);
|
|
61
61
|
|
|
62
|
+
// Use ref for onMessage to avoid recreating connect callback when callback changes
|
|
63
|
+
// This prevents WebSocket reconnections on every render
|
|
64
|
+
const onMessageRef = useRef(onMessage);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
onMessageRef.current = onMessage;
|
|
67
|
+
}, [onMessage]);
|
|
68
|
+
|
|
62
69
|
const connect = useCallback(() => {
|
|
63
70
|
if (!enabled || wsRef.current?.readyState === WebSocket.OPEN) return;
|
|
64
71
|
|
|
@@ -89,8 +96,8 @@ export function useMemoryWebSocket(options: UseMemoryWebSocketOptions = {}) {
|
|
|
89
96
|
timestamp: message.timestamp || new Date().toISOString(),
|
|
90
97
|
});
|
|
91
98
|
|
|
92
|
-
// Notify external handler
|
|
93
|
-
|
|
99
|
+
// Notify external handler (use ref to avoid stale closure)
|
|
100
|
+
onMessageRef.current?.(message);
|
|
94
101
|
|
|
95
102
|
// Invalidate relevant queries based on event type
|
|
96
103
|
switch (message.type) {
|
|
@@ -181,7 +188,7 @@ export function useMemoryWebSocket(options: UseMemoryWebSocketOptions = {}) {
|
|
|
181
188
|
} catch (err) {
|
|
182
189
|
console.error('[WebSocket] Failed to connect:', err);
|
|
183
190
|
}
|
|
184
|
-
}, [enabled, queryClient
|
|
191
|
+
}, [enabled, queryClient]); // onMessage accessed via ref to prevent reconnection loops
|
|
185
192
|
|
|
186
193
|
// Connect on mount
|
|
187
194
|
useEffect(() => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/store.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Store Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for core memory operations, salience detection, and decay calculations.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect } from '@jest/globals';
|
|
7
|
+
describe('Memory Types', () => {
|
|
8
|
+
describe('DEFAULT_CONFIG', () => {
|
|
9
|
+
it('should have sensible default values', async () => {
|
|
10
|
+
const { DEFAULT_CONFIG } = await import('../memory/types.js');
|
|
11
|
+
expect(DEFAULT_CONFIG.decayRate).toBeGreaterThan(0);
|
|
12
|
+
expect(DEFAULT_CONFIG.decayRate).toBeLessThan(1);
|
|
13
|
+
expect(DEFAULT_CONFIG.reinforcementFactor).toBeGreaterThan(1);
|
|
14
|
+
expect(DEFAULT_CONFIG.salienceThreshold).toBeGreaterThan(0);
|
|
15
|
+
expect(DEFAULT_CONFIG.salienceThreshold).toBeLessThan(1);
|
|
16
|
+
expect(DEFAULT_CONFIG.maxShortTermMemories).toBeGreaterThan(0);
|
|
17
|
+
expect(DEFAULT_CONFIG.maxLongTermMemories).toBeGreaterThan(0);
|
|
18
|
+
});
|
|
19
|
+
it('should have valid thresholds', async () => {
|
|
20
|
+
const { DEFAULT_CONFIG } = await import('../memory/types.js');
|
|
21
|
+
// Consolidation threshold should be higher than deletion threshold
|
|
22
|
+
expect(DEFAULT_CONFIG.consolidationThreshold).toBeGreaterThan(DEFAULT_CONFIG.salienceThreshold);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('DELETION_THRESHOLDS', () => {
|
|
26
|
+
it('should have thresholds for all categories', async () => {
|
|
27
|
+
const { DELETION_THRESHOLDS } = await import('../memory/types.js');
|
|
28
|
+
const expectedCategories = [
|
|
29
|
+
'architecture',
|
|
30
|
+
'pattern',
|
|
31
|
+
'preference',
|
|
32
|
+
'error',
|
|
33
|
+
'context',
|
|
34
|
+
'learning',
|
|
35
|
+
'todo',
|
|
36
|
+
'note',
|
|
37
|
+
'relationship',
|
|
38
|
+
'custom',
|
|
39
|
+
];
|
|
40
|
+
for (const category of expectedCategories) {
|
|
41
|
+
expect(DELETION_THRESHOLDS[category]).toBeDefined();
|
|
42
|
+
expect(DELETION_THRESHOLDS[category]).toBeGreaterThan(0);
|
|
43
|
+
expect(DELETION_THRESHOLDS[category]).toBeLessThan(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
it('should prioritize architecture and error over notes', async () => {
|
|
47
|
+
const { DELETION_THRESHOLDS } = await import('../memory/types.js');
|
|
48
|
+
// Lower threshold = harder to delete
|
|
49
|
+
expect(DELETION_THRESHOLDS.architecture).toBeLessThan(DELETION_THRESHOLDS.note);
|
|
50
|
+
expect(DELETION_THRESHOLDS.error).toBeLessThan(DELETION_THRESHOLDS.note);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('Salience Detection', () => {
|
|
55
|
+
describe('calculateSalience', () => {
|
|
56
|
+
it('should return higher salience for explicit remember requests', async () => {
|
|
57
|
+
const { calculateSalience } = await import('../memory/salience.js');
|
|
58
|
+
const explicitResult = calculateSalience({
|
|
59
|
+
title: 'Test Memory',
|
|
60
|
+
content: 'Remember this important information',
|
|
61
|
+
});
|
|
62
|
+
const implicitResult = calculateSalience({
|
|
63
|
+
title: 'Test Memory',
|
|
64
|
+
content: 'Some random text without markers',
|
|
65
|
+
});
|
|
66
|
+
expect(explicitResult).toBeGreaterThanOrEqual(implicitResult);
|
|
67
|
+
});
|
|
68
|
+
it('should detect architecture decisions', async () => {
|
|
69
|
+
const { calculateSalience } = await import('../memory/salience.js');
|
|
70
|
+
const result = calculateSalience({
|
|
71
|
+
title: 'Database Choice',
|
|
72
|
+
content: 'We decided to use PostgreSQL for better JSON support',
|
|
73
|
+
});
|
|
74
|
+
expect(result).toBeGreaterThan(0.3);
|
|
75
|
+
});
|
|
76
|
+
it('should detect error resolutions', async () => {
|
|
77
|
+
const { calculateSalience } = await import('../memory/salience.js');
|
|
78
|
+
const result = calculateSalience({
|
|
79
|
+
title: 'Bug Fix',
|
|
80
|
+
content: 'Fixed by updating the dependency to version 2.0',
|
|
81
|
+
});
|
|
82
|
+
expect(result).toBeGreaterThan(0.3);
|
|
83
|
+
});
|
|
84
|
+
it('should return values between 0 and 1', async () => {
|
|
85
|
+
const { calculateSalience } = await import('../memory/salience.js');
|
|
86
|
+
const result = calculateSalience({
|
|
87
|
+
title: 'Test',
|
|
88
|
+
content: 'Any content',
|
|
89
|
+
});
|
|
90
|
+
expect(result).toBeGreaterThanOrEqual(0);
|
|
91
|
+
expect(result).toBeLessThanOrEqual(1);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('suggestCategory', () => {
|
|
95
|
+
it('should suggest architecture for design decisions', async () => {
|
|
96
|
+
const { suggestCategory } = await import('../memory/salience.js');
|
|
97
|
+
const result = suggestCategory({
|
|
98
|
+
title: 'System Design',
|
|
99
|
+
content: 'Using microservices architecture with API gateway',
|
|
100
|
+
});
|
|
101
|
+
expect(result).toBe('architecture');
|
|
102
|
+
});
|
|
103
|
+
it('should suggest error for bug fixes', async () => {
|
|
104
|
+
const { suggestCategory } = await import('../memory/salience.js');
|
|
105
|
+
const result = suggestCategory({
|
|
106
|
+
title: 'Bug Resolution',
|
|
107
|
+
content: 'The error was caused by null pointer exception',
|
|
108
|
+
});
|
|
109
|
+
expect(result).toBe('error');
|
|
110
|
+
});
|
|
111
|
+
it('should suggest preference for user preferences', async () => {
|
|
112
|
+
const { suggestCategory } = await import('../memory/salience.js');
|
|
113
|
+
const result = suggestCategory({
|
|
114
|
+
title: 'User Setting',
|
|
115
|
+
content: 'User prefers TypeScript strict mode always',
|
|
116
|
+
});
|
|
117
|
+
expect(result).toBe('preference');
|
|
118
|
+
});
|
|
119
|
+
it('should return a valid category', async () => {
|
|
120
|
+
const { suggestCategory } = await import('../memory/salience.js');
|
|
121
|
+
const validCategories = [
|
|
122
|
+
'architecture',
|
|
123
|
+
'pattern',
|
|
124
|
+
'preference',
|
|
125
|
+
'error',
|
|
126
|
+
'context',
|
|
127
|
+
'learning',
|
|
128
|
+
'todo',
|
|
129
|
+
'note',
|
|
130
|
+
'relationship',
|
|
131
|
+
'custom',
|
|
132
|
+
];
|
|
133
|
+
const result = suggestCategory({
|
|
134
|
+
title: 'Test',
|
|
135
|
+
content: 'Generic content',
|
|
136
|
+
});
|
|
137
|
+
expect(validCategories).toContain(result);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe('extractTags', () => {
|
|
141
|
+
it('should extract hashtags from content', async () => {
|
|
142
|
+
const { extractTags } = await import('../memory/salience.js');
|
|
143
|
+
const result = extractTags({
|
|
144
|
+
title: 'Test',
|
|
145
|
+
content: 'This is about #typescript and #react',
|
|
146
|
+
});
|
|
147
|
+
expect(result).toContain('typescript');
|
|
148
|
+
expect(result).toContain('react');
|
|
149
|
+
});
|
|
150
|
+
it('should include provided tags', async () => {
|
|
151
|
+
const { extractTags } = await import('../memory/salience.js');
|
|
152
|
+
const result = extractTags({
|
|
153
|
+
title: 'Test',
|
|
154
|
+
content: 'Some content',
|
|
155
|
+
tags: ['existing-tag'],
|
|
156
|
+
});
|
|
157
|
+
expect(result).toContain('existing-tag');
|
|
158
|
+
});
|
|
159
|
+
it('should return an array', async () => {
|
|
160
|
+
const { extractTags } = await import('../memory/salience.js');
|
|
161
|
+
const result = extractTags({
|
|
162
|
+
title: 'Test',
|
|
163
|
+
content: 'Content without hashtags',
|
|
164
|
+
});
|
|
165
|
+
expect(Array.isArray(result)).toBe(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe('Temporal Decay', () => {
|
|
170
|
+
// Helper to create a valid Memory object for testing
|
|
171
|
+
function createTestMemory(overrides = {}) {
|
|
172
|
+
return {
|
|
173
|
+
id: 1,
|
|
174
|
+
type: 'short_term',
|
|
175
|
+
category: 'note',
|
|
176
|
+
title: 'Test Memory',
|
|
177
|
+
content: 'Test content for decay testing',
|
|
178
|
+
salience: 0.8,
|
|
179
|
+
lastAccessed: new Date(),
|
|
180
|
+
createdAt: new Date(),
|
|
181
|
+
accessCount: 1,
|
|
182
|
+
project: 'test-project',
|
|
183
|
+
tags: [],
|
|
184
|
+
metadata: {},
|
|
185
|
+
decayedScore: 0.8,
|
|
186
|
+
scope: 'project',
|
|
187
|
+
transferable: false,
|
|
188
|
+
...overrides,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
describe('calculateDecayedScore', () => {
|
|
192
|
+
it('should decay score over time', async () => {
|
|
193
|
+
const { calculateDecayedScore } = await import('../memory/decay.js');
|
|
194
|
+
const memory = createTestMemory({
|
|
195
|
+
lastAccessed: new Date(Date.now() - 24 * 60 * 60 * 1000), // 24 hours ago
|
|
196
|
+
});
|
|
197
|
+
const decayedScore = calculateDecayedScore(memory);
|
|
198
|
+
// Score should be less than original salience after 24 hours
|
|
199
|
+
expect(decayedScore).toBeLessThan(memory.salience);
|
|
200
|
+
expect(decayedScore).toBeGreaterThan(0);
|
|
201
|
+
});
|
|
202
|
+
it('should not decay recently accessed memories significantly', async () => {
|
|
203
|
+
const { calculateDecayedScore } = await import('../memory/decay.js');
|
|
204
|
+
const memory = createTestMemory({
|
|
205
|
+
lastAccessed: new Date(), // Just now
|
|
206
|
+
});
|
|
207
|
+
const decayedScore = calculateDecayedScore(memory);
|
|
208
|
+
// Score should be very close to original for recently accessed
|
|
209
|
+
expect(decayedScore).toBeCloseTo(memory.salience, 1);
|
|
210
|
+
});
|
|
211
|
+
it('should decay long-term memories slower than short-term', async () => {
|
|
212
|
+
const { calculateDecayedScore } = await import('../memory/decay.js');
|
|
213
|
+
const hoursSinceAccess = 24;
|
|
214
|
+
const lastAccessed = new Date(Date.now() - hoursSinceAccess * 60 * 60 * 1000);
|
|
215
|
+
const shortTermMemory = createTestMemory({
|
|
216
|
+
type: 'short_term',
|
|
217
|
+
lastAccessed,
|
|
218
|
+
});
|
|
219
|
+
const longTermMemory = createTestMemory({
|
|
220
|
+
type: 'long_term',
|
|
221
|
+
lastAccessed,
|
|
222
|
+
});
|
|
223
|
+
const shortTermScore = calculateDecayedScore(shortTermMemory);
|
|
224
|
+
const longTermScore = calculateDecayedScore(longTermMemory);
|
|
225
|
+
// Long-term should retain more score than short-term
|
|
226
|
+
expect(longTermScore).toBeGreaterThan(shortTermScore);
|
|
227
|
+
});
|
|
228
|
+
it('should return value between 0 and 1', async () => {
|
|
229
|
+
const { calculateDecayedScore } = await import('../memory/decay.js');
|
|
230
|
+
const memory = createTestMemory({
|
|
231
|
+
lastAccessed: new Date(Date.now() - 1000 * 60 * 60 * 24 * 365), // 1 year ago
|
|
232
|
+
});
|
|
233
|
+
const decayedScore = calculateDecayedScore(memory);
|
|
234
|
+
expect(decayedScore).toBeGreaterThanOrEqual(0);
|
|
235
|
+
expect(decayedScore).toBeLessThanOrEqual(1);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
describe('calculateReinforcementBoost', () => {
|
|
239
|
+
it('should boost score on access', async () => {
|
|
240
|
+
const { calculateReinforcementBoost } = await import('../memory/decay.js');
|
|
241
|
+
const memory = createTestMemory({ salience: 0.5 });
|
|
242
|
+
const boost = calculateReinforcementBoost(memory);
|
|
243
|
+
expect(boost).toBeGreaterThan(memory.salience);
|
|
244
|
+
expect(boost).toBeLessThanOrEqual(1.0);
|
|
245
|
+
});
|
|
246
|
+
it('should cap boost at 1.0', async () => {
|
|
247
|
+
const { calculateReinforcementBoost } = await import('../memory/decay.js');
|
|
248
|
+
const memory = createTestMemory({ salience: 0.95 });
|
|
249
|
+
const boost = calculateReinforcementBoost(memory);
|
|
250
|
+
expect(boost).toBeLessThanOrEqual(1.0);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
describe('Text Similarity', () => {
|
|
255
|
+
describe('jaccardSimilarity', () => {
|
|
256
|
+
it('should return 1.0 for identical texts', async () => {
|
|
257
|
+
const { jaccardSimilarity } = await import('../memory/similarity.js');
|
|
258
|
+
const result = jaccardSimilarity('the quick brown fox', 'the quick brown fox');
|
|
259
|
+
expect(result).toBe(1.0);
|
|
260
|
+
});
|
|
261
|
+
it('should return 0.0 for completely different texts', async () => {
|
|
262
|
+
const { jaccardSimilarity } = await import('../memory/similarity.js');
|
|
263
|
+
const result = jaccardSimilarity('apple banana cherry', 'dog elephant frog');
|
|
264
|
+
expect(result).toBe(0.0);
|
|
265
|
+
});
|
|
266
|
+
it('should return value between 0 and 1 for partial overlap', async () => {
|
|
267
|
+
const { jaccardSimilarity } = await import('../memory/similarity.js');
|
|
268
|
+
const result = jaccardSimilarity('the quick brown fox', 'the lazy brown dog');
|
|
269
|
+
expect(result).toBeGreaterThan(0);
|
|
270
|
+
expect(result).toBeLessThan(1);
|
|
271
|
+
});
|
|
272
|
+
it('should be symmetric', async () => {
|
|
273
|
+
const { jaccardSimilarity } = await import('../memory/similarity.js');
|
|
274
|
+
const result1 = jaccardSimilarity('hello world', 'world hello');
|
|
275
|
+
const result2 = jaccardSimilarity('world hello', 'hello world');
|
|
276
|
+
expect(result1).toBeCloseTo(result2, 10);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
describe('tokenize', () => {
|
|
280
|
+
it('should lowercase text', async () => {
|
|
281
|
+
const { tokenize } = await import('../memory/similarity.js');
|
|
282
|
+
const result = tokenize('HELLO World');
|
|
283
|
+
expect(result.has('hello')).toBe(true);
|
|
284
|
+
expect(result.has('world')).toBe(true);
|
|
285
|
+
expect(result.has('HELLO')).toBe(false);
|
|
286
|
+
});
|
|
287
|
+
it('should remove punctuation', async () => {
|
|
288
|
+
const { tokenize } = await import('../memory/similarity.js');
|
|
289
|
+
const result = tokenize('hello, world! how are you?');
|
|
290
|
+
expect(result.has('hello')).toBe(true);
|
|
291
|
+
expect(result.has('world')).toBe(true);
|
|
292
|
+
expect(result.has('hello,')).toBe(false);
|
|
293
|
+
});
|
|
294
|
+
it('should filter short words', async () => {
|
|
295
|
+
const { tokenize } = await import('../memory/similarity.js');
|
|
296
|
+
const result = tokenize('a an the and or but');
|
|
297
|
+
// Words with 2 or fewer characters should be filtered
|
|
298
|
+
expect(result.has('a')).toBe(false);
|
|
299
|
+
expect(result.has('an')).toBe(false);
|
|
300
|
+
expect(result.has('the')).toBe(true); // 3 chars
|
|
301
|
+
expect(result.has('and')).toBe(true); // 3 chars
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
describe('Content Truncation', () => {
|
|
306
|
+
it('should define MAX_CONTENT_SIZE constant', () => {
|
|
307
|
+
const MAX_CONTENT_SIZE = 10 * 1024; // 10KB
|
|
308
|
+
expect(MAX_CONTENT_SIZE).toBe(10240);
|
|
309
|
+
});
|
|
310
|
+
it('should handle content under the limit', () => {
|
|
311
|
+
const content = 'Short content';
|
|
312
|
+
const MAX_CONTENT_SIZE = 10 * 1024;
|
|
313
|
+
expect(content.length).toBeLessThan(MAX_CONTENT_SIZE);
|
|
314
|
+
});
|
|
315
|
+
it('should identify content over the limit', () => {
|
|
316
|
+
const MAX_CONTENT_SIZE = 10 * 1024;
|
|
317
|
+
const longContent = 'x'.repeat(MAX_CONTENT_SIZE + 100);
|
|
318
|
+
expect(longContent.length).toBeGreaterThan(MAX_CONTENT_SIZE);
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
//# sourceMappingURL=store.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.test.js","sourceRoot":"","sources":["../../src/__tests__/store.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AAGhE,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;YACnD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;YAE9D,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YAC9D,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,eAAe,CAA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CAAC;QAEvD,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/embeddings/generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/embeddings/generator.ts"],"names":[],"mappings":"AA+CA;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAY3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,MAAM,CAmBzE;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD"}
|
|
@@ -16,6 +16,7 @@ async function getEmbeddingPipeline() {
|
|
|
16
16
|
return loadPromise;
|
|
17
17
|
}
|
|
18
18
|
isLoading = true;
|
|
19
|
+
// Cast the pipeline to our typed interface
|
|
19
20
|
loadPromise = pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
|
|
20
21
|
try {
|
|
21
22
|
embeddingPipeline = await loadPromise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/embeddings/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAErD,qCAAqC;AACrC,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC;AAC7B,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/embeddings/generator.ts"],"names":[],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IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE9B,OAAO,UAAU,GAAG,SAAS,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,iBAAiB,KAAK,IAAI,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,oBAAoB,EAAE,CAAC;AAC/B,CAAC"}
|
package/dist/tools/recall.d.ts
CHANGED
|
@@ -21,15 +21,15 @@ export declare const recallSchema: z.ZodObject<{
|
|
|
21
21
|
includeGlobal: boolean;
|
|
22
22
|
mode: "search" | "important" | "recent";
|
|
23
23
|
project?: string | undefined;
|
|
24
|
-
category?: "architecture" | "pattern" | "preference" | "error" | "context" | "learning" | "todo" | "note" | "relationship" | "custom" | undefined;
|
|
25
24
|
type?: "short_term" | "long_term" | "episodic" | undefined;
|
|
25
|
+
category?: "architecture" | "pattern" | "preference" | "error" | "context" | "learning" | "todo" | "note" | "relationship" | "custom" | undefined;
|
|
26
26
|
tags?: string[] | undefined;
|
|
27
27
|
query?: string | undefined;
|
|
28
28
|
}, {
|
|
29
29
|
project?: string | undefined;
|
|
30
|
+
type?: "short_term" | "long_term" | "episodic" | undefined;
|
|
30
31
|
category?: "architecture" | "pattern" | "preference" | "error" | "context" | "learning" | "todo" | "note" | "relationship" | "custom" | undefined;
|
|
31
32
|
limit?: number | undefined;
|
|
32
|
-
type?: "short_term" | "long_term" | "episodic" | undefined;
|
|
33
33
|
tags?: string[] | undefined;
|
|
34
34
|
query?: string | undefined;
|
|
35
35
|
includeDecayed?: boolean | undefined;
|
package/dist/tools/remember.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ export declare const rememberSchema: z.ZodObject<{
|
|
|
21
21
|
scope?: "project" | "global" | undefined;
|
|
22
22
|
transferable?: boolean | undefined;
|
|
23
23
|
project?: string | undefined;
|
|
24
|
-
category?: "architecture" | "pattern" | "preference" | "error" | "context" | "learning" | "todo" | "note" | "relationship" | "custom" | undefined;
|
|
25
24
|
type?: "short_term" | "long_term" | "episodic" | undefined;
|
|
25
|
+
category?: "architecture" | "pattern" | "preference" | "error" | "context" | "learning" | "todo" | "note" | "relationship" | "custom" | undefined;
|
|
26
26
|
tags?: string[] | undefined;
|
|
27
27
|
importance?: "critical" | "low" | "normal" | "high" | undefined;
|
|
28
28
|
}, {
|
|
@@ -31,8 +31,8 @@ export declare const rememberSchema: z.ZodObject<{
|
|
|
31
31
|
scope?: "project" | "global" | undefined;
|
|
32
32
|
transferable?: boolean | undefined;
|
|
33
33
|
project?: string | undefined;
|
|
34
|
-
category?: "architecture" | "pattern" | "preference" | "error" | "context" | "learning" | "todo" | "note" | "relationship" | "custom" | undefined;
|
|
35
34
|
type?: "short_term" | "long_term" | "episodic" | undefined;
|
|
35
|
+
category?: "architecture" | "pattern" | "preference" | "error" | "context" | "learning" | "todo" | "note" | "relationship" | "custom" | undefined;
|
|
36
36
|
tags?: string[] | undefined;
|
|
37
37
|
importance?: "critical" | "low" | "normal" | "high" | undefined;
|
|
38
38
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-cortex",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Brain-like memory system for Claude Code - solves context compaction and memory persistence",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
"dev": "tsx src/index.ts",
|
|
14
14
|
"dev:api": "tsx src/index.ts --mode api",
|
|
15
15
|
"dev:dashboard": "tsx src/index.ts --dashboard",
|
|
16
|
-
"watch": "tsc --watch"
|
|
16
|
+
"watch": "tsc --watch",
|
|
17
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
18
|
+
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
|
|
19
|
+
"test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
|
|
20
|
+
"audit:security": "npm audit --audit-level=moderate"
|
|
17
21
|
},
|
|
18
22
|
"keywords": [
|
|
19
23
|
"claude",
|
|
@@ -48,8 +52,11 @@
|
|
|
48
52
|
"@types/better-sqlite3": "^7.6.11",
|
|
49
53
|
"@types/cors": "^2.8.17",
|
|
50
54
|
"@types/express": "^5.0.0",
|
|
55
|
+
"@types/jest": "^30.0.0",
|
|
51
56
|
"@types/node": "^22.0.0",
|
|
52
57
|
"@types/ws": "^8.5.13",
|
|
58
|
+
"jest": "^30.2.0",
|
|
59
|
+
"ts-jest": "^29.4.6",
|
|
53
60
|
"tsx": "^4.19.0",
|
|
54
61
|
"typescript": "^5.6.0"
|
|
55
62
|
},
|