@wonderwhy-er/desktop-commander 0.2.18-alpha.5 → 0.2.18-alpha.7

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.
@@ -208,73 +208,63 @@ function detectShell() {
208
208
 
209
209
  // Function to get the package spec that was used to run this script
210
210
  function getPackageSpec() {
211
- console.log('\n[DEBUG getPackageSpec] Starting detection...');
211
+ // Use stderr for debug output so it's always visible
212
+ const debug = (msg) => process.stderr.write(`${msg}\n`);
212
213
 
213
- // Strategy: We want to preserve the tag/version the user used
214
- // - If user ran: npx @pkg@latest → keep @latest
215
- // - If user ran: npx @pkg@alpha → keep @alpha
216
- // - If user ran: npx @pkg@0.2.18-alpha.1 → keep @0.2.18-alpha.1
214
+ debug('\n[DEBUG getPackageSpec] Starting detection...');
215
+ debug(`[DEBUG getPackageSpec] process.argv: ${JSON.stringify(process.argv)}`);
216
+ debug(`[DEBUG getPackageSpec] __dirname: ${__dirname}`);
217
+ debug(`[DEBUG getPackageSpec] __filename: ${__filename}`);
217
218
 
218
- // Check npm_config_user_agent which contains the original command
219
- // Example: "npm/10.2.4 node/v20.11.0 darwin arm64 workspaces/false"
220
- const userAgent = process.env.npm_config_user_agent || '';
221
- const execPath = process.env.npm_execpath || '';
222
- console.log('[DEBUG getPackageSpec] userAgent:', userAgent);
223
- console.log('[DEBUG getPackageSpec] execPath:', execPath);
219
+ // Strategy: Check multiple sources to detect the version
220
+ // 1. Check process.argv[1] which contains the actual script path
221
+ // 2. Check package.json in the script's directory
222
+ // 3. Fall back to @latest for stable, keep version for pre-release
224
223
 
225
- // Check if there's a version/tag in the npx cache path
226
- // npx caches packages like: ~/.npm/_npx/<hash>/node_modules/@wonderwhy-er/desktop-commander
227
- const scriptPath = import.meta.url;
228
- console.log('[DEBUG getPackageSpec] scriptPath:', scriptPath);
224
+ // Method 1: Check the script path (process.argv[1] or __dirname)
225
+ // npx extracts packages to: ~/.npm/_npx/<hash>/node_modules/@scope/package-name/
226
+ // The actual script path will contain this structure
227
+ const scriptPath = __dirname;
228
+ debug('[DEBUG getPackageSpec] Checking script path for version...');
229
229
 
230
- // Look for @version in the path (npx cache includes it sometimes)
231
- const versionMatch = scriptPath.match(/@wonderwhy-er\/desktop-commander@([^\/]+)/);
232
- if (versionMatch) {
233
- const spec = `@wonderwhy-er/desktop-commander@${versionMatch[1]}`;
234
- console.log('[DEBUG getPackageSpec] Detected version from path:', spec);
235
- return spec;
230
+ // Look for node_modules/@wonderwhy-er/desktop-commander in the path
231
+ // This works because npx extracts to a predictable location
232
+ const nodeModulesMatch = scriptPath.match(/node_modules\/@wonderwhy-er\/desktop-commander/);
233
+ if (nodeModulesMatch) {
234
+ debug('[DEBUG getPackageSpec] Script is in node_modules, reading package.json...');
236
235
  }
237
236
 
238
- // Read package.json to get the actual installed version
237
+ // Method 2: Read package.json to get the actual installed version
239
238
  try {
240
239
  const packageJsonPath = join(__dirname, 'package.json');
241
- console.log('[DEBUG getPackageSpec] Reading package.json from:', packageJsonPath);
240
+ debug(`[DEBUG getPackageSpec] Trying to read: ${packageJsonPath}`);
242
241
 
243
242
  if (existsSync(packageJsonPath)) {
244
243
  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
245
244
  const version = packageJson.version;
246
- console.log('[DEBUG getPackageSpec] Found version in package.json:', version);
245
+ debug(`[DEBUG getPackageSpec] Found version in package.json: ${version}`);
247
246
 
248
247
  if (version) {
249
- // Check if version looks like a pre-release (alpha, beta, rc)
248
+ // Always use the exact version if it's a pre-release
250
249
  if (version.includes('alpha') || version.includes('beta') || version.includes('rc')) {
251
- // User explicitly installed a pre-release version, keep it
252
250
  const spec = `@wonderwhy-er/desktop-commander@${version}`;
253
- console.log('[DEBUG getPackageSpec] Using pre-release version:', spec);
251
+ debug(`[DEBUG getPackageSpec] Using pre-release version: ${spec}`);
254
252
  return spec;
255
253
  }
256
254
 
257
- // For stable versions, assume user wants @latest
258
- console.log('[DEBUG getPackageSpec] Stable version detected, using @latest');
255
+ // For stable versions, use @latest tag
256
+ debug('[DEBUG getPackageSpec] Stable version, using @latest');
259
257
  return '@wonderwhy-er/desktop-commander@latest';
260
258
  }
261
259
  } else {
262
- console.log('[DEBUG getPackageSpec] package.json not found at path');
260
+ debug('[DEBUG getPackageSpec] package.json not found');
263
261
  }
264
262
  } catch (error) {
265
- console.log('[DEBUG getPackageSpec] Error reading package.json:', error.message);
263
+ debug(`[DEBUG getPackageSpec] Error reading package.json: ${error.message}`);
266
264
  }
267
265
 
268
- // Fallback to @latest
269
- console.log('[DEBUG getPackageSpec] Falling back to @latest');
270
- return '@wonderwhy-er/desktop-commander@latest';
271
- }
272
- console.log('[DEBUG] Found package spec from npm env:', spec);
273
- return spec;
274
- }
275
-
276
- console.log('[DEBUG] Falling back to @latest');
277
- // Fallback to @latest if we can't detect
266
+ // Fallback
267
+ debug('[DEBUG getPackageSpec] Falling back to @latest');
278
268
  return '@wonderwhy-er/desktop-commander@latest';
279
269
  }
280
270
 
@@ -837,14 +827,14 @@ export default async function setup() {
837
827
  // Standard configuration without debug
838
828
  if (isNpx) {
839
829
  const packageSpec = getPackageSpec();
840
- console.log('\n[SETUP] Creating config with package spec:', packageSpec);
830
+ process.stderr.write(`\n[SETUP] Creating config with package spec: ${packageSpec}\n`);
841
831
  serverConfig = {
842
832
  "command": isWindows ? "npx.cmd" : "npx",
843
833
  "args": [
844
834
  packageSpec
845
835
  ]
846
836
  };
847
- console.log('[SETUP] serverConfig.args:', JSON.stringify(serverConfig.args));
837
+ process.stderr.write(`[SETUP] serverConfig.args: ${JSON.stringify(serverConfig.args)}\n`);
848
838
  await trackEvent('npx_setup_config_standard_npx', { packageSpec });
849
839
  } else {
850
840
  // For local installation, use absolute path to handle Windows properly
@@ -882,15 +872,15 @@ export default async function setup() {
882
872
  // Add or update the terminal server config with the proper name "desktop-commander"
883
873
  config.mcpServers["desktop-commander"] = serverConfig;
884
874
 
885
- console.log('\n[SETUP] Writing config to Claude:');
886
- console.log('[SETUP] desktop-commander args:', JSON.stringify(config.mcpServers["desktop-commander"].args));
875
+ process.stderr.write('\n[SETUP] Writing config to Claude:\n');
876
+ process.stderr.write(`[SETUP] desktop-commander args: ${JSON.stringify(config.mcpServers["desktop-commander"].args)}\n`);
887
877
 
888
878
  // Write the updated config back
889
879
  writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2), 'utf8');
890
880
 
891
881
  // Verify what was written
892
882
  const writtenConfig = JSON.parse(readFileSync(claudeConfigPath, 'utf8'));
893
- console.log('[SETUP] Verified written args:', JSON.stringify(writtenConfig.mcpServers["desktop-commander"].args));
883
+ process.stderr.write(`[SETUP] Verified written args: ${JSON.stringify(writtenConfig.mcpServers["desktop-commander"].args)}\n\n`);
894
884
 
895
885
  updateSetupStep(updateConfigStep, 'completed');
896
886
  await trackEvent('npx_setup_update_config');
package/dist/setup.log CHANGED
@@ -61,3 +61,24 @@ The server is available as "desktop-commander" in Claude's MCP server list
61
61
  2025-08-21T15:01:43.932Z - or join our community: https://discord.com/invite/kQ27sNnZr7
62
62
 
63
63
 
64
+ 2025-10-22T15:22:43.506Z - ✅ Desktop Commander MCP v0.2.18-alpha.6 successfully added to Claude’s configuration.
65
+ 2025-10-22T15:22:43.507Z - Configuration location: /Users/fiberta/Library/Application Support/Claude/claude_desktop_config.json
66
+ 2025-10-22T15:22:46.639Z -
67
+ ✅ Claude has been restarted automatically!
68
+ 2025-10-22T15:22:46.664Z -
69
+ ✅ Installation successfully completed! Thank you for using Desktop Commander!
70
+
71
+ 2025-10-22T15:22:46.664Z -
72
+ The server is available as "desktop-commander" in Claude's MCP server list
73
+ 2025-10-22T15:22:46.665Z - Future updates will install automatically — no need to run this setup again.
74
+
75
+
76
+ 2025-10-22T15:22:46.665Z - 🤔 Need help or have feedback? Happy to jump on a quick call:
77
+
78
+
79
+ 2025-10-22T15:22:46.665Z - https://calendar.app.google/SHMNZN5MJznJWC5A7
80
+
81
+
82
+ 2025-10-22T15:22:46.665Z - or join our community: https://discord.com/invite/kQ27sNnZr7
83
+
84
+
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.2.18-alpha.5";
1
+ export declare const VERSION = "0.2.18-alpha.7";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.18-alpha.5';
1
+ export const VERSION = '0.2.18-alpha.7';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderwhy-er/desktop-commander",
3
- "version": "0.2.18-alpha.5",
3
+ "version": "0.2.18-alpha.7",
4
4
  "description": "MCP server for terminal operations and file editing",
5
5
  "mcpName": "io.github.wonderwhy-er/desktop-commander",
6
6
  "license": "MIT",