mixgram 1.2.2 → 1.2.6

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/README.md CHANGED
@@ -220,9 +220,9 @@ Omit `query` or use `*` to get **recent** context only.
220
220
  ### Example: one round-trip
221
221
 
222
222
  ```text
223
- 1. mem_save → { success: true, id: "obs_...", path: "...", created: true }
223
+ 1. mem_save → { success: true, id: "<10-char id>", path: "...", created: true }
224
224
  2. mem_search({ query: "SQLite", project: "my-app" }) → { results: [ { title, snippet, ... } ] }
225
- 3. mem_get_observation({ id: "obs_..." }) → { title, content, type, scope, project, ... }
225
+ 3. mem_get_observation({ id: "<10-char id>" }) → { title, content, type, scope, project, ... }
226
226
  ```
227
227
 
228
228
  ---
package/bin/mixgram.js CHANGED
@@ -240,8 +240,8 @@ Setup targets:
240
240
  gemini-cli Gemini CLI
241
241
  codex Codex
242
242
 
243
- Example (Cursor): "mixgram": { "command": "mixgram", "args": ["mcp", "--project-memory", "${workspaceFolder}/docs"] }
244
- With embeddings: "args": ["mcp", "--project-memory", "${workspaceFolder}/docs", "--embeddings"]
243
+ Example (Cursor): "mixgram": { "command": "mixgram", "args": ["mcp", "--project-memory", "\${workspaceFolder}/docs"] }
244
+ With embeddings: "args": ["mcp", "--project-memory", "\${workspaceFolder}/docs", "--embeddings"]
245
245
  Config file: .mixgram/config.json or ~/.mixgram/config.json
246
246
 
247
247
  npm install -g mixgram
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixgram",
3
- "version": "1.2.2",
3
+ "version": "1.2.6",
4
4
  "description": "MCP memory server with Markdown source of truth and SQLite FTS5.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -74,9 +74,9 @@ console.log('Mode: %s\n', RUN_EMBED_PROCESSING ? 'indexing + embedding queue pro
74
74
 
75
75
  // --- Create corpus ---
76
76
  for (let i = 0; i < NUM_SMALL; i++) {
77
- writeDoc(baseConfig.projectMemoryRoot, `obs_small_${i}`, `Small ${i}`, `Content for small doc ${i}.\n`);
77
+ writeDoc(baseConfig.projectMemoryRoot, `bench${String(i).padStart(5, '0')}`, `Small ${i}`, `Content for small doc ${i}.\n`);
78
78
  }
79
- const largePath = writeDoc(baseConfig.projectMemoryRoot, 'obs_large', 'Large doc', buildLargeBody(LARGE_SIZE));
79
+ const largePath = writeDoc(baseConfig.projectMemoryRoot, 'bench99999', 'Large doc', buildLargeBody(LARGE_SIZE));
80
80
 
81
81
  /**
82
82
  * Full reindex with breakdown: clearIndex, listMarkdownPaths, index loop.
@@ -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).',
@@ -502,14 +532,14 @@ export const scenarios = [
502
532
 
503
533
  reporter.startScenario(this.name, this.goal);
504
534
 
505
- const updBad = await h.mem_update({ id: 'obs_nonexistent123', title: 'No', content: 'No' });
535
+ const updBad = await h.mem_update({ id: 'nonexist01', title: 'No', content: 'No' });
506
536
  const updBadParsed = parseRes(updBad);
507
- reporter.step('mem_update (bad id)', { id: 'obs_nonexistent123' }, updBadParsed);
537
+ reporter.step('mem_update (bad id)', { id: 'nonexist01' }, updBadParsed);
508
538
  ok(updBadParsed.success === false && updBadParsed.error, 'update fails cleanly');
509
539
 
510
- const getBad = await h.mem_get_observation({ id: 'obs_nonexistent456' });
540
+ const getBad = await h.mem_get_observation({ id: 'nonexist02' });
511
541
  const getBadParsed = parseRes(getBad);
512
- reporter.step('mem_get_observation (bad id)', { id: 'obs_nonexistent456' }, getBadParsed);
542
+ reporter.step('mem_get_observation (bad id)', { id: 'nonexist02' }, getBadParsed);
513
543
  ok(getBadParsed.error === 'Observation not found' || !!getBadParsed.error, 'get_observation error');
514
544
 
515
545
  reporter.endScenario(p, f);
package/spec/sdd.md CHANGED
@@ -338,13 +338,13 @@ Each memory document should include structured frontmatter.
338
338
 
339
339
  ```md
340
340
  ---
341
- id: obs_01HXYZ123ABC
341
+ id: a1b2c3d4e5
342
342
  title: Use SQLite as derived index
343
343
  type: decision
344
344
  scope: project
345
345
  project: castlebravo
346
346
  topic_key: architecture/sqlite-derived-index
347
- session_id: sess_01HXYZ456DEF
347
+ session_id: f6g7h8i9j0
348
348
  tool_name: mem_save
349
349
  created_at: 2026-03-08T18:00:00Z
350
350
  updated_at: 2026-03-08T18:00:00Z
@@ -39,7 +39,7 @@ export function runLargeDocumentTest(config) {
39
39
  fs.mkdirSync(docsDir, { recursive: true });
40
40
 
41
41
  const body = buildLargeBody(TARGET_SIZE);
42
- const id = 'obs_large_100k';
42
+ const id = 'large100k00';
43
43
  const now = new Date().toISOString();
44
44
  const frontmatter = {
45
45
  id,
@@ -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
- return normalizeForFts(q.trim());
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
  /**
@@ -31,7 +40,7 @@ function normalizeQuery(q) {
31
40
  * @param {string} [options.scopeMode] - 'project-only' | 'home-only' | 'merged'
32
41
  * @param {string} [options.project] - project name (required for project-only and merged)
33
42
  * @param {number} [options.limit] - max results
34
- * @returns {Array<{ documentId: string, title: string, topicKey: string, type: string, scope: string, project: string | null, snippet: string, score: number }>}
43
+ * @returns {Array<{ documentId: string, title: string, topicKey: string, type: string, scope: string, project: string | null, created: string | null, snippet: string, score: number }>}
35
44
  */
36
45
  function search(config, options = {}) {
37
46
  const {
@@ -76,9 +85,10 @@ function search(config, options = {}) {
76
85
  d.type AS type,
77
86
  d.scope AS scope,
78
87
  d.project AS project,
88
+ d.created_at AS created,
79
89
  d.body AS body,
80
- snippet(document_fts, 1, '<b>', '</b>', '...', 24) AS snippetTitle,
81
- snippet(document_fts, 8, '<b>', '</b>', '...', 64) AS snippetBody,
90
+ snippet(document_fts, 1, '**', '**', '...', 24) AS snippetTitle,
91
+ snippet(document_fts, 8, '**', '**', '...', 64) AS snippetBody,
82
92
  bm25(document_fts, ${bm25Args}) AS rank
83
93
  FROM document_fts f
84
94
  JOIN documents d ON d.id = f.document_id
@@ -101,6 +111,7 @@ function search(config, options = {}) {
101
111
  type: r.type,
102
112
  scope: r.scope,
103
113
  project: r.project,
114
+ created: r.created || null,
104
115
  snippet: String(snippet).trim(),
105
116
  score: -Number(r.rank)
106
117
  };
@@ -114,7 +125,7 @@ function getRecentContext(config, options = {}) {
114
125
  const { project = null, limit = config.search?.defaultLimit ?? 10 } = options;
115
126
  const db = getDb(config);
116
127
  let sql = `
117
- SELECT d.id AS documentId, d.title, d.topic_key AS topicKey, d.type, d.scope, d.project, d.body
128
+ SELECT d.id AS documentId, d.title, d.topic_key AS topicKey, d.type, d.scope, d.project, d.created_at AS created, d.body
118
129
  FROM documents d
119
130
  WHERE d.deleted_at IS NULL
120
131
  `;
@@ -136,6 +147,7 @@ function getRecentContext(config, options = {}) {
136
147
  type: r.type,
137
148
  scope: r.scope,
138
149
  project: r.project,
150
+ created: r.created || null,
139
151
  snippet: (r.body || '').slice(0, 300).trim()
140
152
  }));
141
153
  }
package/src/utils/ids.js CHANGED
@@ -1,22 +1,27 @@
1
1
  import crypto from 'crypto';
2
2
 
3
- export function generateId(prefix = 'obs') {
4
- const hex = crypto.randomBytes(12).toString('hex');
5
- return `${prefix}_${hex}`;
3
+ const ALPHANUM = '0123456789abcdefghijklmnopqrstuvwxyz';
4
+
5
+ export function generateId() {
6
+ const bytes = crypto.randomBytes(10);
7
+ let s = '';
8
+ for (let i = 0; i < 10; i++) s += ALPHANUM[bytes[i] % 36];
9
+ return s;
6
10
  }
7
11
 
8
12
  export function observationId() {
9
- return generateId('obs');
13
+ return generateId();
10
14
  }
11
15
 
12
16
  export function sessionId() {
13
- return generateId('sess');
17
+ return generateId();
14
18
  }
15
19
 
16
20
  export function chunkId(documentId, index) {
17
- return `${documentId}_chunk_${index}`;
21
+ return `${documentId}_${index}`;
18
22
  }
19
23
 
20
24
  export function promptId() {
21
- return generateId('prompt');
25
+ return generateId();
22
26
  }
27
+