mixgram 1.0.8 → 1.1.2

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
@@ -70,7 +70,8 @@ Add to Cursor’s MCP config (or run `mixgram setup cursor`):
70
70
  "mcpServers": {
71
71
  "mixgram": {
72
72
  "command": "mixgram",
73
- "args": ["mcp"]
73
+ "args": ["mcp"],
74
+ "cwd": "${workspaceFolder}"
74
75
  }
75
76
  }
76
77
  }
@@ -81,11 +82,12 @@ With embeddings and custom paths via args:
81
82
  ```json
82
83
  "mixgram": {
83
84
  "command": "mixgram",
84
- "args": ["mcp", "--embeddings", "--home", "/data/memory", "--project-memory", "./specs"]
85
+ "args": ["mcp", "--embeddings", "--home", "/data/memory", "--project-memory", "./specs"],
86
+ "cwd": "${workspaceFolder}"
85
87
  }
86
88
  ```
87
89
 
88
- Or use `./mixgram` (default), `./docs`, or any path. Or use a config file (see below) and just `"args": ["mcp"]`. Restart Cursor after changing config.
90
+ Set `cwd` to `${workspaceFolder}` so relative project paths like `./mixgram` resolve inside the active repo instead of the parent process directory. Or use a config file (see below) and just `"args": ["mcp"]`. Restart Cursor after changing config.
89
91
 
90
92
  ---
91
93
 
package/bin/mixgram.js CHANGED
@@ -100,6 +100,13 @@ const MIXGRAM_ENTRY = {
100
100
  args: ['mcp']
101
101
  };
102
102
 
103
+ const CURSOR_MIXGRAM_ENTRY = {
104
+ ...MIXGRAM_ENTRY,
105
+ // Cursor interpolates this to the active workspace root, so project memory
106
+ // stays under <workspace>/mixgram instead of the parent process cwd.
107
+ cwd: '${workspaceFolder}'
108
+ };
109
+
103
110
  function cursorMcpPath() {
104
111
  const home = os.homedir();
105
112
  if (process.platform === 'win32') {
@@ -139,7 +146,7 @@ function setupCursor() {
139
146
  process.exit(1);
140
147
  }
141
148
  }
142
- data.mcpServers.mixgram = MIXGRAM_ENTRY;
149
+ data.mcpServers.mixgram = CURSOR_MIXGRAM_ENTRY;
143
150
  fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
144
151
  console.log('Cursor: added mixgram to', filePath);
145
152
  console.log('Restart Cursor to load the MCP server.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixgram",
3
- "version": "1.0.8",
3
+ "version": "1.1.2",
4
4
  "description": "MCP memory server with Markdown source of truth and SQLite FTS5.",
5
5
  "keywords": [
6
6
  "mcp",
package/spec/run-tests.js CHANGED
@@ -7,6 +7,8 @@
7
7
  import fs from 'fs';
8
8
  import path from 'path';
9
9
  import os from 'os';
10
+ import { spawnSync } from 'child_process';
11
+ import { fileURLToPath } from 'url';
10
12
  import { loadConfig } from '../src/config.js';
11
13
  import { createToolHandlers } from '../src/mcp/tools.js';
12
14
  import { getToolDefinitions } from '../src/mcp/tool-registry.js';
@@ -14,6 +16,9 @@ import { closeDb, getDb } from '../src/db/sqlite.js';
14
16
  import { scenarios } from './scenarios/scenarios.js';
15
17
  import * as reporter from './reporter.js';
16
18
 
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = path.dirname(__filename);
21
+
17
22
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mixgram-test-'));
18
23
  const config = loadConfig({
19
24
  homeMemoryRoot: path.join(tmpDir, 'home', 'memory'),
@@ -47,6 +52,51 @@ const ctx = {
47
52
  shared: {}
48
53
  };
49
54
 
55
+ function runCliSetupChecks() {
56
+ const cliTmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mixgram-cli-test-'));
57
+ const repoRoot = path.dirname(__dirname);
58
+
59
+ if (reporter.VISUAL) {
60
+ reporter.startScenario('CLI setup cursor config', 'Verify Cursor setup writes workspace cwd for project-scoped memory.');
61
+ }
62
+
63
+ let p = 0;
64
+ let f = 0;
65
+ const ok = (cond, msg) => {
66
+ if (cond) p++;
67
+ else f++;
68
+ if (reporter.VISUAL) reporter.check(msg, cond);
69
+ };
70
+
71
+ try {
72
+ const result = spawnSync(process.execPath, [path.join(repoRoot, 'bin', 'mixgram.js'), 'setup', 'cursor'], {
73
+ cwd: repoRoot,
74
+ env: { ...process.env, HOME: cliTmpDir },
75
+ encoding: 'utf8'
76
+ });
77
+
78
+ ok(result.status === 0, 'setup cursor exits successfully');
79
+
80
+ const cursorConfigPath = path.join(cliTmpDir, '.cursor', 'mcp.json');
81
+ ok(fs.existsSync(cursorConfigPath), 'cursor mcp.json created');
82
+
83
+ const cursorConfig = JSON.parse(fs.readFileSync(cursorConfigPath, 'utf8'));
84
+ const entry = cursorConfig?.mcpServers?.mixgram;
85
+ ok(entry?.command === 'mixgram', 'cursor entry command preserved');
86
+ ok(Array.isArray(entry?.args) && entry.args[0] === 'mcp', 'cursor entry args preserved');
87
+ ok(entry?.cwd === '${workspaceFolder}', 'cursor entry uses workspace cwd');
88
+ } catch (err) {
89
+ if (reporter.VISUAL) reporter.check('CLI setup cursor config threw', false, err.message);
90
+ f += 1;
91
+ } finally {
92
+ try { fs.rmSync(cliTmpDir, { recursive: true, force: true }); } catch (_) {}
93
+ }
94
+
95
+ if (reporter.VISUAL) reporter.endScenario(p, f);
96
+ totalPassed += p;
97
+ totalFailed += f;
98
+ }
99
+
50
100
  async function runScenarios() {
51
101
  for (const scenario of scenarios) {
52
102
  if (scenario.name === 'Semantic / embeddings (save and search)' && !ctx.hSemantic) {
@@ -141,6 +191,7 @@ async function runLegacySemanticKnn() {
141
191
  }
142
192
 
143
193
  async function run() {
194
+ runCliSetupChecks();
144
195
  await runScenarios();
145
196
  await runLegacySemanticKnn();
146
197
 
@@ -4,6 +4,8 @@
4
4
  * ctx: { h, parse, config, fs, reporter, ok } where ok(cond, msg) counts and optionally prints check.
5
5
  */
6
6
 
7
+ import path from 'path';
8
+
7
9
  import {
8
10
  decisionSqliteIndex,
9
11
  decisionSqliteIndexRevision2,
@@ -44,6 +46,7 @@ export const scenarios = [
44
46
  ok(s1.success && s1.id && s1.created === true, 'save success');
45
47
  ok(fs.existsSync(s1.path), 'file created');
46
48
  ok(s1.path.includes('mixgram') || s1.path.replace(/\\/g, '/').includes('mixgram'), 'project doc under mixgram');
49
+ ok(path.basename(s1.path) === 'architecture-sqlite-derived-index.md', 'project doc filename omits redundant prefixes');
47
50
 
48
51
  const search1 = await h.mem_search({ query: 'derived SQLite index', project: PROJECT_NAME });
49
52
  const search1Parsed = parseRes(search1);
@@ -74,6 +77,7 @@ export const scenarios = [
74
77
  const s2 = parseRes(save2);
75
78
  reporter.step('mem_save (home)', { scope: 'home', topic_key: patternIncrementalReindex.topic_key }, { path: s2.path, created: s2.created });
76
79
  ok(s2.success && s2.path && s2.path.includes('home'), 'home save');
80
+ ok(path.basename(s2.path) === 'incremental-reindexing.md', 'home doc filename omits folder category');
77
81
 
78
82
  const searchMerged = await h.mem_search({ query: 'reindex', scope_mode: 'merged', project: PROJECT_NAME });
79
83
  const mergedParsed = parseRes(searchMerged);
package/src/config.js CHANGED
@@ -10,8 +10,8 @@ function expandHome(p) {
10
10
  }
11
11
 
12
12
  const DEFAULT_CONFIG = {
13
- homeMemoryRoot: '~/.mixgram/shared',
14
- projectMemoryRoot: './mixgram',
13
+ homeMemoryRoot: '~/.mixgram/docs',
14
+ projectMemoryRoot: './docs',
15
15
  sqlitePath: '~/.mixgram/index.db',
16
16
  watch: true,
17
17
  indexing: {
package/src/fs/paths.js CHANGED
@@ -32,10 +32,38 @@ function slugFromTopicKey(topicKey) {
32
32
  .replace(/^-|-$/g, '') || 'note';
33
33
  }
34
34
 
35
+ function filenameSlugFromTopicKey(topicKey, { project = null, type = null } = {}) {
36
+ if (!topicKey || typeof topicKey !== 'string') return 'note';
37
+
38
+ const segments = topicKey
39
+ .split('/')
40
+ .map((segment) => segment.trim())
41
+ .filter(Boolean);
42
+
43
+ if (segments.length === 0) return 'note';
44
+
45
+ const normalizedProject = slugFromTopicKey(project);
46
+ if (normalizedProject !== 'note' && slugFromTopicKey(segments[0]) === normalizedProject) {
47
+ segments.shift();
48
+ }
49
+
50
+ const typeDir = TYPE_TO_DIR[type] || 'generated';
51
+ const redundantPrefixes = new Set([
52
+ slugFromTopicKey(type),
53
+ slugFromTopicKey(typeDir)
54
+ ].filter((value) => value !== 'note'));
55
+
56
+ if (segments.length > 1 && redundantPrefixes.has(slugFromTopicKey(segments[0]))) {
57
+ segments.shift();
58
+ }
59
+
60
+ return slugFromTopicKey(segments.join('-'));
61
+ }
62
+
35
63
  function documentPath(config, { scope, project, type, topic_key, id }) {
36
64
  const typeDir = TYPE_TO_DIR[type] || 'generated';
37
- const slug = slugFromTopicKey(topic_key);
38
- const baseName = `${type}--${slug}.md`;
65
+ const slug = filenameSlugFromTopicKey(topic_key, { project, type });
66
+ const baseName = `${slug}.md`;
39
67
 
40
68
  if (scope === 'home') {
41
69
  const root = config.homeMemoryRoot;
@@ -75,5 +103,6 @@ export {
75
103
  mixgramDir,
76
104
  ensureMixgramDir,
77
105
  TYPE_TO_DIR,
78
- slugFromTopicKey
106
+ slugFromTopicKey,
107
+ filenameSlugFromTopicKey
79
108
  };