smart-coding-mcp 2.1.0 → 2.1.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/package.json +2 -2
- package/test/better-sqlite3.test.js +153 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-coding-mcp",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "An extensible MCP server that enhances coding productivity with AI-powered features including semantic code search, intelligent indexing, and more, using local LLMs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@huggingface/transformers": "^3.8.1",
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
50
|
-
"better-sqlite3": "^
|
|
50
|
+
"better-sqlite3": "^12.5.0",
|
|
51
51
|
"chokidar": "^3.5.3",
|
|
52
52
|
"fastembed": "^2.1.0",
|
|
53
53
|
"fdir": "^6.5.0",
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for better-sqlite3 compatibility
|
|
3
|
+
*
|
|
4
|
+
* Tests that better-sqlite3 v12.5.0 works correctly with Node.js v25:
|
|
5
|
+
* - Database creation
|
|
6
|
+
* - Table creation
|
|
7
|
+
* - Data insertion
|
|
8
|
+
* - Data querying
|
|
9
|
+
* - Database cleanup
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
13
|
+
import Database from 'better-sqlite3';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
import { dirname, join } from 'path';
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
|
|
18
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
+
const __dirname = dirname(__filename);
|
|
20
|
+
|
|
21
|
+
describe('better-sqlite3 Integration', () => {
|
|
22
|
+
let testDbPath;
|
|
23
|
+
let db;
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
testDbPath = join(__dirname, `test-${Date.now()}.db`);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
// Close database if open
|
|
31
|
+
if (db) {
|
|
32
|
+
try {
|
|
33
|
+
db.close();
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// Already closed
|
|
36
|
+
}
|
|
37
|
+
db = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Cleanup test database
|
|
41
|
+
if (fs.existsSync(testDbPath)) {
|
|
42
|
+
fs.unlinkSync(testDbPath);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('Database Operations', () => {
|
|
47
|
+
it('should create a database successfully', () => {
|
|
48
|
+
db = new Database(testDbPath);
|
|
49
|
+
expect(db).toBeDefined();
|
|
50
|
+
expect(fs.existsSync(testDbPath)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should create tables', () => {
|
|
54
|
+
db = new Database(testDbPath);
|
|
55
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
56
|
+
|
|
57
|
+
// Verify table exists
|
|
58
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='users'").all();
|
|
59
|
+
expect(tables.length).toBe(1);
|
|
60
|
+
expect(tables[0].name).toBe('users');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should insert data', () => {
|
|
64
|
+
db = new Database(testDbPath);
|
|
65
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
66
|
+
|
|
67
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
68
|
+
const result1 = insert.run('Alice');
|
|
69
|
+
const result2 = insert.run('Bob');
|
|
70
|
+
|
|
71
|
+
expect(result1.changes).toBe(1);
|
|
72
|
+
expect(result2.changes).toBe(1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should query data', () => {
|
|
76
|
+
db = new Database(testDbPath);
|
|
77
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
78
|
+
|
|
79
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
80
|
+
insert.run('Alice');
|
|
81
|
+
insert.run('Bob');
|
|
82
|
+
|
|
83
|
+
const users = db.prepare('SELECT * FROM users').all();
|
|
84
|
+
expect(users.length).toBe(2);
|
|
85
|
+
expect(users[0].name).toBe('Alice');
|
|
86
|
+
expect(users[1].name).toBe('Bob');
|
|
87
|
+
expect(users[0].id).toBe(1);
|
|
88
|
+
expect(users[1].id).toBe(2);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should handle prepared statements', () => {
|
|
92
|
+
db = new Database(testDbPath);
|
|
93
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
94
|
+
|
|
95
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
96
|
+
insert.run('Alice');
|
|
97
|
+
|
|
98
|
+
const getUser = db.prepare('SELECT * FROM users WHERE name = ?');
|
|
99
|
+
const user = getUser.get('Alice');
|
|
100
|
+
|
|
101
|
+
expect(user).toBeDefined();
|
|
102
|
+
expect(user.name).toBe('Alice');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should handle transactions', () => {
|
|
106
|
+
db = new Database(testDbPath);
|
|
107
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
108
|
+
|
|
109
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
110
|
+
const insertMany = db.transaction((users) => {
|
|
111
|
+
for (const name of users) {
|
|
112
|
+
insert.run(name);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
insertMany(['Alice', 'Bob', 'Charlie']);
|
|
117
|
+
|
|
118
|
+
const count = db.prepare('SELECT COUNT(*) as count FROM users').get();
|
|
119
|
+
expect(count.count).toBe(3);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should close database properly', () => {
|
|
123
|
+
db = new Database(testDbPath);
|
|
124
|
+
expect(() => db.close()).not.toThrow();
|
|
125
|
+
db = null; // Mark as closed for cleanup
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should work with in-memory database', () => {
|
|
129
|
+
const memDb = new Database(':memory:');
|
|
130
|
+
memDb.exec('CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)');
|
|
131
|
+
memDb.prepare('INSERT INTO test (value) VALUES (?)').run('test');
|
|
132
|
+
|
|
133
|
+
const result = memDb.prepare('SELECT * FROM test').get();
|
|
134
|
+
expect(result.value).toBe('test');
|
|
135
|
+
|
|
136
|
+
memDb.close();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('Node.js v25 Compatibility', () => {
|
|
141
|
+
it('should work with current Node.js version', () => {
|
|
142
|
+
// This test verifies we can use better-sqlite3 with Node.js v25
|
|
143
|
+
expect(process.version).toMatch(/^v25\./);
|
|
144
|
+
|
|
145
|
+
db = new Database(testDbPath);
|
|
146
|
+
db.exec('CREATE TABLE compatibility_test (id INTEGER PRIMARY KEY, version TEXT)');
|
|
147
|
+
db.prepare('INSERT INTO compatibility_test (version) VALUES (?)').run(process.version);
|
|
148
|
+
|
|
149
|
+
const result = db.prepare('SELECT * FROM compatibility_test').get();
|
|
150
|
+
expect(result.version).toBe(process.version);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|