mixgram 1.2.0 → 1.2.4
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/bin/mixgram.js +22 -0
- package/package.json +1 -1
- package/spec/scenarios/scenarios.js +30 -0
- package/src/core/search/search.js +10 -1
package/bin/mixgram.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { run } from '../src/mcp/server.js';
|
|
9
9
|
import { loadConfig } from '../src/config.js';
|
|
10
|
+
import { closeDb } from '../src/db/sqlite.js';
|
|
10
11
|
import { createToolHandlers } from '../src/mcp/tools.js';
|
|
11
12
|
import { getToolByName, listToolNames, parseToolArgs, formatToolHelp } from '../src/mcp/cli-adapter.js';
|
|
12
13
|
import fs from 'fs';
|
|
@@ -217,6 +218,7 @@ Usage: mixgram <command> [options]
|
|
|
217
218
|
Commands:
|
|
218
219
|
mcp [options] Run the MCP server (stdio). Use this in your client config.
|
|
219
220
|
setup <client> Register Mixgram with an MCP client.
|
|
221
|
+
flushdb Delete the SQLite database file (and WAL/shm).
|
|
220
222
|
help [tool] Show help; with optional tool name, show options for that tool.
|
|
221
223
|
-v, --version Print version from package and exit.
|
|
222
224
|
<tool> [options] Run an MCP tool by name. Tools:
|
|
@@ -263,6 +265,26 @@ async function main() {
|
|
|
263
265
|
return;
|
|
264
266
|
}
|
|
265
267
|
|
|
268
|
+
if (SUBCOMMAND === 'flushdb') {
|
|
269
|
+
const { overrides, baseDir, projectBaseDir } = loadCliConfig();
|
|
270
|
+
const config = loadConfig(overrides, baseDir, projectBaseDir);
|
|
271
|
+
const dbPath = config.sqlitePath;
|
|
272
|
+
closeDb();
|
|
273
|
+
const removed = [];
|
|
274
|
+
for (const p of [dbPath, dbPath + '-wal', dbPath + '-shm']) {
|
|
275
|
+
if (fs.existsSync(p)) {
|
|
276
|
+
fs.unlinkSync(p);
|
|
277
|
+
removed.push(p);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (removed.length) {
|
|
281
|
+
console.log('Removed:', removed.join(', '));
|
|
282
|
+
} else {
|
|
283
|
+
console.log('No database file at', dbPath);
|
|
284
|
+
}
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
266
288
|
if (SUBCOMMAND === 'setup') {
|
|
267
289
|
if (!ARG) {
|
|
268
290
|
console.error('Usage: mixgram setup <cursor|gemini-cli|codex>');
|
package/package.json
CHANGED
|
@@ -168,6 +168,36 @@ export const scenarios = [
|
|
|
168
168
|
return { passed: p, failed: f };
|
|
169
169
|
}
|
|
170
170
|
},
|
|
171
|
+
{
|
|
172
|
+
name: 'Search with hyphen and slash in query (FTS5 sanitization)',
|
|
173
|
+
goal: 'mem_search does not throw on queries containing "-" or "/" (no "syntax error near /" or "no such column").',
|
|
174
|
+
run: async function (ctx) {
|
|
175
|
+
const { h, reporter } = ctx;
|
|
176
|
+
const parseRes = ctx.parse || parse;
|
|
177
|
+
let p = 0, f = 0;
|
|
178
|
+
const ok = (cond, msg) => { if (cond) p++; else f++; reporter.check(msg, cond); };
|
|
179
|
+
|
|
180
|
+
reporter.startScenario(this.name, this.goal);
|
|
181
|
+
|
|
182
|
+
const queries = ['sdd-init', 'sdd-init/alchemy-tycoon', 'alchemy-tycoon sdd-init'];
|
|
183
|
+
for (const query of queries) {
|
|
184
|
+
let res;
|
|
185
|
+
try {
|
|
186
|
+
res = await h.mem_search({ query, project: PROJECT_NAME, limit: 5 });
|
|
187
|
+
} catch (e) {
|
|
188
|
+
reporter.check(`mem_search("${query}") does not throw`, false);
|
|
189
|
+
f++;
|
|
190
|
+
reporter.endScenario(p, f);
|
|
191
|
+
return { passed: p, failed: f };
|
|
192
|
+
}
|
|
193
|
+
const data = parseRes(res).results;
|
|
194
|
+
ok(Array.isArray(data), `mem_search("${query}") returns array`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
reporter.endScenario(p, f);
|
|
198
|
+
return { passed: p, failed: f };
|
|
199
|
+
}
|
|
200
|
+
},
|
|
171
201
|
{
|
|
172
202
|
name: 'Context for project',
|
|
173
203
|
goal: 'mem_context returns usable context (recent or query-based).',
|
|
@@ -15,13 +15,22 @@ function getBm25Weights(config) {
|
|
|
15
15
|
];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
// FTS5 uses "/" for NEAR (e.g. term/5) and "-" for NOT; dash-like chars between words break parsing.
|
|
19
|
+
const FTS5_NEAR_SLASH = /\//g;
|
|
20
|
+
const FTS5_NOT_HYPHEN = /(?<=\w)[-\u2010-\u2015\u2212](?=\w)/g; // hyphen, en/em-dash, minus
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* Normalize query for FTS5: same as indexed text (NFD, remove diacritics, lowercase).
|
|
24
|
+
* Replaces "/" with space so it is not interpreted as FTS5 NEAR syntax (e.g. term/5).
|
|
25
|
+
* Replaces "-" (and Unicode dashes) between word chars with space so "alchemy-tycoon" is not parsed as "alchemy" NOT "tycoon".
|
|
20
26
|
* Leaves FTS5 operators (AND, OR, NOT, "phrase") intact.
|
|
21
27
|
*/
|
|
22
28
|
function normalizeQuery(q) {
|
|
23
29
|
if (q == null || typeof q !== 'string') return '';
|
|
24
|
-
|
|
30
|
+
const trimmed = q.trim();
|
|
31
|
+
const slashSafe = trimmed.replace(FTS5_NEAR_SLASH, ' ');
|
|
32
|
+
const hyphenSafe = slashSafe.replace(FTS5_NOT_HYPHEN, ' ');
|
|
33
|
+
return normalizeForFts(hyphenSafe);
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
/**
|