@scitrera/memorylayer-mcp-server 0.1.22 → 0.2.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.
@@ -1,152 +0,0 @@
1
- /**
2
- * Tests for SessionManager
3
- */
4
-
5
- import { describe, it, expect, beforeEach } from "vitest";
6
- import { SessionManager } from "../src/session.js";
7
-
8
- describe("SessionManager", () => {
9
- let manager: SessionManager;
10
-
11
- beforeEach(() => {
12
- manager = new SessionManager();
13
- });
14
-
15
- describe("constructor", () => {
16
- it("should be enabled by default", () => {
17
- expect(manager.isEnabled).toBe(true);
18
- });
19
-
20
- it("should respect enabled config", () => {
21
- const disabled = new SessionManager({ enabled: false });
22
- expect(disabled.isEnabled).toBe(false);
23
- });
24
-
25
- it("should have no active session initially", () => {
26
- expect(manager.hasActiveSession).toBe(false);
27
- expect(manager.currentSession).toBeNull();
28
- });
29
- });
30
-
31
- describe("startSession", () => {
32
- it("should create a new session", () => {
33
- const session = manager.startSession("test-workspace");
34
-
35
- expect(session).toBeDefined();
36
- expect(session.id).toMatch(/^local_\d+_[a-z0-9]+$/);
37
- expect(session.workspaceId).toBe("test-workspace");
38
- expect(session.committed).toBe(false);
39
- expect(session.workingMemory.size).toBe(0);
40
- });
41
-
42
- it("should set hasActiveSession to true", () => {
43
- manager.startSession("test-workspace");
44
- expect(manager.hasActiveSession).toBe(true);
45
- });
46
-
47
- it("should store server session ID if provided", () => {
48
- const session = manager.startSession("test-workspace", "server-123");
49
- expect(session.serverSessionId).toBe("server-123");
50
- });
51
-
52
- it("should replace existing session", () => {
53
- const first = manager.startSession("workspace-1");
54
- const second = manager.startSession("workspace-2");
55
-
56
- expect(manager.currentSession?.id).toBe(second.id);
57
- expect(manager.currentSession?.workspaceId).toBe("workspace-2");
58
- });
59
- });
60
-
61
- describe("endSession", () => {
62
- it("should return null if no active session", () => {
63
- const result = manager.endSession();
64
- expect(result).toBeNull();
65
- });
66
-
67
- it("should return the ended session", () => {
68
- const started = manager.startSession("test-workspace");
69
- const ended = manager.endSession();
70
-
71
- expect(ended?.id).toBe(started.id);
72
- });
73
-
74
- it("should clear the active session", () => {
75
- manager.startSession("test-workspace");
76
- manager.endSession();
77
-
78
- expect(manager.hasActiveSession).toBe(false);
79
- expect(manager.currentSession).toBeNull();
80
- });
81
- });
82
-
83
- describe("markCommitted", () => {
84
- it("should mark session as committed", () => {
85
- manager.startSession("test-workspace");
86
- manager.markCommitted();
87
-
88
- expect(manager.currentSession?.committed).toBe(true);
89
- });
90
-
91
- it("should do nothing if no active session", () => {
92
- // Should not throw
93
- manager.markCommitted();
94
- });
95
- });
96
-
97
- describe("working memory", () => {
98
- beforeEach(() => {
99
- manager.startSession("test-workspace");
100
- });
101
-
102
- describe("getAllWorkingMemory", () => {
103
- it("should return empty array for new session", () => {
104
- const entries = manager.getAllWorkingMemory();
105
- expect(entries).toEqual([]);
106
- });
107
-
108
- it("should return empty array if no session", () => {
109
- manager.endSession();
110
- const entries = manager.getAllWorkingMemory();
111
- expect(entries).toEqual([]);
112
- });
113
- });
114
-
115
- describe("clearWorkingMemory", () => {
116
- it("should not throw on empty working memory", () => {
117
- expect(() => manager.clearWorkingMemory()).not.toThrow();
118
- expect(manager.getAllWorkingMemory()).toHaveLength(0);
119
- });
120
- });
121
- });
122
-
123
- describe("getSessionSummary", () => {
124
- it("should return inactive status when no session", () => {
125
- const summary = manager.getSessionSummary();
126
- expect(summary.active).toBe(false);
127
- });
128
-
129
- it("should return session info when active", () => {
130
- manager.startSession("test-workspace", "server-123");
131
-
132
- const summary = manager.getSessionSummary();
133
-
134
- expect(summary.active).toBe(true);
135
- expect(summary.workspaceId).toBe("test-workspace");
136
- expect(summary.serverSessionId).toBe("server-123");
137
- expect(summary.workingMemoryCount).toBe(0);
138
- expect(summary.committed).toBe(false);
139
- });
140
- });
141
-
142
- describe("getTtlSeconds", () => {
143
- it("should return default TTL", () => {
144
- expect(manager.getTtlSeconds()).toBe(3600);
145
- });
146
-
147
- it("should return custom TTL", () => {
148
- const custom = new SessionManager({ ttlSeconds: 7200 });
149
- expect(custom.getTtlSeconds()).toBe(7200);
150
- });
151
- });
152
- });
@@ -1,191 +0,0 @@
1
- /**
2
- * Tests for MCP tool definitions
3
- */
4
-
5
- import { describe, it, expect } from "vitest";
6
- import { TOOLS, SESSION_TOOLS, CONTEXT_ENVIRONMENT_TOOLS, CORE_TOOLS, EXTENDED_TOOLS } from "../src/tools.js";
7
-
8
- describe("Tool Definitions", () => {
9
- describe("TOOLS", () => {
10
- it("should export core memory tools", () => {
11
- const toolNames = TOOLS.map(t => t.name);
12
-
13
- expect(toolNames).toContain("memory_remember");
14
- expect(toolNames).toContain("memory_recall");
15
- expect(toolNames).toContain("memory_reflect");
16
- expect(toolNames).toContain("memory_forget");
17
- expect(toolNames).toContain("memory_associate");
18
- expect(toolNames).toContain("memory_briefing");
19
- expect(toolNames).toContain("memory_statistics");
20
- expect(toolNames).toContain("memory_graph_query");
21
- expect(toolNames).toContain("memory_audit");
22
- });
23
-
24
- it("should have valid input schemas", () => {
25
- for (const tool of TOOLS) {
26
- expect(tool.inputSchema).toBeDefined();
27
- expect(tool.inputSchema.type).toBe("object");
28
- expect(tool.inputSchema.properties).toBeDefined();
29
- }
30
- });
31
-
32
- it("should have descriptions for all tools", () => {
33
- for (const tool of TOOLS) {
34
- expect(tool.description).toBeDefined();
35
- expect(tool.description.length).toBeGreaterThan(10);
36
- }
37
- });
38
- });
39
-
40
- describe("SESSION_TOOLS", () => {
41
- it("should export session management tools", () => {
42
- const toolNames = SESSION_TOOLS.map(t => t.name);
43
-
44
- expect(toolNames).toContain("memory_session_start");
45
- expect(toolNames).toContain("memory_session_end");
46
- expect(toolNames).toContain("memory_session_commit");
47
- expect(toolNames).toContain("memory_session_status");
48
- });
49
-
50
- it("should have valid input schemas", () => {
51
- for (const tool of SESSION_TOOLS) {
52
- expect(tool.inputSchema).toBeDefined();
53
- expect(tool.inputSchema.type).toBe("object");
54
- }
55
- });
56
-
57
- it("should have descriptions for all tools", () => {
58
- for (const tool of SESSION_TOOLS) {
59
- expect(tool.description).toBeDefined();
60
- expect(tool.description.length).toBeGreaterThan(10);
61
- }
62
- });
63
- });
64
-
65
- describe("CONTEXT_ENVIRONMENT_TOOLS", () => {
66
- it("should export context environment tools", () => {
67
- const toolNames = CONTEXT_ENVIRONMENT_TOOLS.map(t => t.name);
68
-
69
- expect(toolNames).toContain("memory_context_exec");
70
- expect(toolNames).toContain("memory_context_inspect");
71
- expect(toolNames).toContain("memory_context_load");
72
- expect(toolNames).toContain("memory_context_inject");
73
- expect(toolNames).toContain("memory_context_query");
74
- expect(toolNames).toContain("memory_context_rlm");
75
- expect(toolNames).toContain("memory_context_status");
76
- expect(toolNames).toContain("memory_context_checkpoint");
77
- });
78
-
79
- it("should have valid input schemas", () => {
80
- for (const tool of CONTEXT_ENVIRONMENT_TOOLS) {
81
- expect(tool.inputSchema).toBeDefined();
82
- expect(tool.inputSchema.type).toBe("object");
83
- }
84
- });
85
-
86
- it("should have descriptions for all tools", () => {
87
- for (const tool of CONTEXT_ENVIRONMENT_TOOLS) {
88
- expect(tool.description).toBeDefined();
89
- expect(tool.description.length).toBeGreaterThan(10);
90
- }
91
- });
92
- });
93
-
94
- describe("memory_remember tool", () => {
95
- const tool = TOOLS.find(t => t.name === "memory_remember");
96
-
97
- it("should require content", () => {
98
- expect(tool?.inputSchema.required).toContain("content");
99
- });
100
-
101
- it("should have memory type enum", () => {
102
- const typeProperty = tool?.inputSchema.properties?.type;
103
- expect(typeProperty?.enum).toContain("episodic");
104
- expect(typeProperty?.enum).toContain("semantic");
105
- expect(typeProperty?.enum).toContain("procedural");
106
- expect(typeProperty?.enum).toContain("working");
107
- });
108
-
109
- it("should have importance range", () => {
110
- const importance = tool?.inputSchema.properties?.importance;
111
- expect(importance?.minimum).toBe(0);
112
- expect(importance?.maximum).toBe(1);
113
- });
114
- });
115
-
116
- describe("memory_recall tool", () => {
117
- const tool = TOOLS.find(t => t.name === "memory_recall");
118
-
119
- it("should require query", () => {
120
- expect(tool?.inputSchema.required).toContain("query");
121
- });
122
-
123
- it("should have limit constraints", () => {
124
- const limit = tool?.inputSchema.properties?.limit;
125
- expect(limit?.minimum).toBe(1);
126
- expect(limit?.maximum).toBe(100);
127
- });
128
- });
129
-
130
- describe("memory_associate tool", () => {
131
- const tool = TOOLS.find(t => t.name === "memory_associate");
132
-
133
- it("should require source_id, target_id, and relationship", () => {
134
- expect(tool?.inputSchema.required).toContain("source_id");
135
- expect(tool?.inputSchema.required).toContain("target_id");
136
- expect(tool?.inputSchema.required).toContain("relationship");
137
- });
138
-
139
- it("should have relationship description", () => {
140
- const relationship = tool?.inputSchema.properties?.relationship;
141
- expect(relationship?.type).toBe("string");
142
- expect(relationship?.description).toBeDefined();
143
- });
144
- });
145
-
146
- describe("memory_context_exec tool", () => {
147
- const tool = CONTEXT_ENVIRONMENT_TOOLS.find(t => t.name === "memory_context_exec");
148
-
149
- it("should require code", () => {
150
- expect(tool?.inputSchema.required).toContain("code");
151
- });
152
-
153
- it("should have return_result option", () => {
154
- const returnResult = tool?.inputSchema.properties?.return_result;
155
- expect(returnResult?.type).toBe("boolean");
156
- });
157
- });
158
-
159
- describe("memory_session_end tool", () => {
160
- const tool = SESSION_TOOLS.find(t => t.name === "memory_session_end");
161
-
162
- it("should have commit option", () => {
163
- expect(tool?.inputSchema.properties?.commit).toBeDefined();
164
- expect(tool?.inputSchema.properties?.commit?.type).toBe("boolean");
165
- });
166
-
167
- it("should have importance_threshold option", () => {
168
- const threshold = tool?.inputSchema.properties?.importance_threshold;
169
- expect(threshold?.minimum).toBe(0);
170
- expect(threshold?.maximum).toBe(1);
171
- });
172
- });
173
-
174
- describe("Legacy exports", () => {
175
- it("should export CORE_TOOLS as filtered subset of TOOLS", () => {
176
- const coreNames = CORE_TOOLS.map(t => t.name);
177
- expect(coreNames).toEqual([
178
- "memory_remember", "memory_recall", "memory_reflect",
179
- "memory_forget", "memory_associate"
180
- ]);
181
- });
182
-
183
- it("should export EXTENDED_TOOLS as filtered subset of TOOLS", () => {
184
- const extNames = EXTENDED_TOOLS.map(t => t.name);
185
- expect(extNames).toEqual([
186
- "memory_briefing", "memory_statistics",
187
- "memory_graph_query", "memory_audit"
188
- ]);
189
- });
190
- });
191
- });
package/vitest.config.ts DELETED
@@ -1,15 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: "node",
7
- include: ["tests/**/*.test.ts"],
8
- coverage: {
9
- provider: "v8",
10
- reporter: ["text", "json", "html"],
11
- include: ["src/**/*.ts"],
12
- exclude: ["src/index.ts", "src/types.ts"],
13
- },
14
- },
15
- });