@muggleai/mcp 1.0.15 → 1.0.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muggleai/mcp",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Unified MCP server for Muggle AI - Cloud QA and Local Testing tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "test:watch": "vitest"
27
27
  },
28
28
  "muggleConfig": {
29
- "electronAppVersion": "1.0.5",
29
+ "electronAppVersion": "1.0.6",
30
30
  "downloadBaseUrl": "https://github.com/multiplex-ai/muggle-ai-mcp/releases/download",
31
31
  "checksums": {
32
32
  "darwin-arm64": "",
@@ -6,13 +6,21 @@
6
6
 
7
7
  import { createHash } from "crypto";
8
8
  import { exec } from "child_process";
9
- import { createReadStream, createWriteStream, existsSync, mkdirSync, rmSync } from "fs";
9
+ import {
10
+ createReadStream,
11
+ createWriteStream,
12
+ existsSync,
13
+ mkdirSync,
14
+ readdirSync,
15
+ rmSync,
16
+ } from "fs";
10
17
  import { homedir, platform } from "os";
11
18
  import { join } from "path";
12
19
  import { pipeline } from "stream/promises";
13
20
  import { createRequire } from "module";
14
21
 
15
22
  const require = createRequire(import.meta.url);
23
+ const VERSION_DIRECTORY_NAME_PATTERN = /^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/;
16
24
 
17
25
  /**
18
26
  * Get the Muggle AI data directory.
@@ -50,6 +58,15 @@ function getPlatformKey() {
50
58
  }
51
59
  }
52
60
 
61
+ /**
62
+ * Check whether a directory name looks like a version folder.
63
+ * @param {string} directoryName - Directory name to validate
64
+ * @returns {boolean} True when the directory name is a version
65
+ */
66
+ function isVersionDirectoryName(directoryName) {
67
+ return VERSION_DIRECTORY_NAME_PATTERN.test(directoryName);
68
+ }
69
+
53
70
  /**
54
71
  * Calculate SHA256 checksum of a file.
55
72
  * @param {string} filePath - Path to the file
@@ -97,6 +114,38 @@ async function verifyFileChecksum(filePath, expectedChecksum) {
97
114
  };
98
115
  }
99
116
 
117
+ /**
118
+ * Remove Electron app version directories that do not match the current version.
119
+ * @param {object} params - Cleanup parameters
120
+ * @param {string} params.appDir - Base Electron app directory
121
+ * @param {string} params.currentVersion - Version that should be kept
122
+ */
123
+ function cleanupNonCurrentVersions({ appDir, currentVersion }) {
124
+ if (!existsSync(appDir)) {
125
+ return;
126
+ }
127
+
128
+ const appEntries = readdirSync(appDir, { withFileTypes: true });
129
+
130
+ for (const appEntry of appEntries) {
131
+ if (!appEntry.isDirectory()) {
132
+ continue;
133
+ }
134
+
135
+ if (!isVersionDirectoryName(appEntry.name)) {
136
+ continue;
137
+ }
138
+
139
+ if (appEntry.name === currentVersion) {
140
+ continue;
141
+ }
142
+
143
+ const staleVersionDir = join(appDir, appEntry.name);
144
+ console.log(`Removing stale Electron app version: ${appEntry.name}`);
145
+ rmSync(staleVersionDir, { recursive: true, force: true });
146
+ }
147
+ }
148
+
100
149
  /**
101
150
  * Get platform-specific binary name.
102
151
  * @returns {string} Binary filename
@@ -139,6 +188,7 @@ async function downloadElectronApp() {
139
188
 
140
189
  // Check if already downloaded
141
190
  if (existsSync(versionDir)) {
191
+ cleanupNonCurrentVersions({ appDir: appDir, currentVersion: version });
142
192
  console.log(`Electron app v${version} already installed at ${versionDir}`);
143
193
  return;
144
194
  }
@@ -204,6 +254,8 @@ async function downloadElectronApp() {
204
254
  // Clean up temp file
205
255
  rmSync(tempFile, { force: true });
206
256
 
257
+ cleanupNonCurrentVersions({ appDir: appDir, currentVersion: version });
258
+
207
259
  console.log(`Electron app installed to ${versionDir}`);
208
260
  } catch (error) {
209
261
  console.error("\n========================================");