@wonderwhy-er/desktop-commander 0.2.18-alpha.4 → 0.2.18-alpha.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.
@@ -209,36 +209,32 @@ function detectShell() {
209
209
  // Function to get the package spec that was used to run this script
210
210
  function getPackageSpec() {
211
211
  console.log('\n[DEBUG getPackageSpec] Starting detection...');
212
+ console.log('[DEBUG getPackageSpec] process.argv:', process.argv);
213
+ console.log('[DEBUG getPackageSpec] __dirname:', __dirname);
214
+ console.log('[DEBUG getPackageSpec] __filename:', __filename);
212
215
 
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
216
+ // Strategy: Check multiple sources to detect the version
217
+ // 1. Check process.argv[1] which contains the actual script path
218
+ // 2. Check package.json in the script's directory
219
+ // 3. Fall back to @latest for stable, keep version for pre-release
217
220
 
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);
221
+ // Method 1: Check the script path (process.argv[1] or __dirname)
222
+ // npx extracts packages to: ~/.npm/_npx/<hash>/node_modules/@scope/package-name/
223
+ // The actual script path will contain this structure
224
+ const scriptPath = __dirname;
225
+ console.log('[DEBUG getPackageSpec] Checking script path for version...');
224
226
 
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);
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;
227
+ // Look for node_modules/@wonderwhy-er/desktop-commander in the path
228
+ // This works because npx extracts to a predictable location
229
+ const nodeModulesMatch = scriptPath.match(/node_modules\/@wonderwhy-er\/desktop-commander/);
230
+ if (nodeModulesMatch) {
231
+ console.log('[DEBUG getPackageSpec] Script is in node_modules, reading package.json...');
236
232
  }
237
233
 
238
- // Read package.json to get the actual installed version
234
+ // Method 2: Read package.json to get the actual installed version
239
235
  try {
240
236
  const packageJsonPath = join(__dirname, 'package.json');
241
- console.log('[DEBUG getPackageSpec] Reading package.json from:', packageJsonPath);
237
+ console.log('[DEBUG getPackageSpec] Trying to read:', packageJsonPath);
242
238
 
243
239
  if (existsSync(packageJsonPath)) {
244
240
  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
@@ -246,31 +242,28 @@ function getPackageSpec() {
246
242
  console.log('[DEBUG getPackageSpec] Found version in package.json:', version);
247
243
 
248
244
  if (version) {
249
- // Check if version looks like a pre-release (alpha, beta, rc)
245
+ // Always use the exact version if it's a pre-release
250
246
  if (version.includes('alpha') || version.includes('beta') || version.includes('rc')) {
251
- // User explicitly installed a pre-release version, keep it
252
247
  const spec = `@wonderwhy-er/desktop-commander@${version}`;
253
- console.log('[DEBUG getPackageSpec] Using pre-release version:', spec);
248
+ console.log('[DEBUG getPackageSpec] Using pre-release version:', spec);
254
249
  return spec;
255
250
  }
256
251
 
257
- // For stable versions, assume user wants @latest
258
- console.log('[DEBUG getPackageSpec] Stable version detected, using @latest');
252
+ // For stable versions, use @latest tag
253
+ console.log('[DEBUG getPackageSpec] Stable version, using @latest');
259
254
  return '@wonderwhy-er/desktop-commander@latest';
260
255
  }
261
256
  } else {
262
- console.log('[DEBUG getPackageSpec] package.json not found at path');
257
+ console.log('[DEBUG getPackageSpec] package.json not found');
263
258
  }
264
259
  } catch (error) {
265
- console.log('[DEBUG getPackageSpec] Error reading package.json:', error.message);
260
+ console.log('[DEBUG getPackageSpec] Error reading package.json:', error.message);
266
261
  }
267
262
 
268
- // Fallback to @latest
269
- console.log('[DEBUG getPackageSpec] Falling back to @latest');
263
+ // Fallback
264
+ console.log('[DEBUG getPackageSpec] Falling back to @latest');
270
265
  return '@wonderwhy-er/desktop-commander@latest';
271
266
  }
272
- console.log('[DEBUG] Found package spec from npm env:', spec);
273
- return spec;
274
267
  }
275
268
 
276
269
  console.log('[DEBUG] Falling back to @latest');
@@ -837,12 +830,14 @@ export default async function setup() {
837
830
  // Standard configuration without debug
838
831
  if (isNpx) {
839
832
  const packageSpec = getPackageSpec();
833
+ console.log('\n[SETUP] Creating config with package spec:', packageSpec);
840
834
  serverConfig = {
841
835
  "command": isWindows ? "npx.cmd" : "npx",
842
836
  "args": [
843
837
  packageSpec
844
838
  ]
845
839
  };
840
+ console.log('[SETUP] serverConfig.args:', JSON.stringify(serverConfig.args));
846
841
  await trackEvent('npx_setup_config_standard_npx', { packageSpec });
847
842
  } else {
848
843
  // For local installation, use absolute path to handle Windows properly
@@ -880,8 +875,16 @@ export default async function setup() {
880
875
  // Add or update the terminal server config with the proper name "desktop-commander"
881
876
  config.mcpServers["desktop-commander"] = serverConfig;
882
877
 
878
+ console.log('\n[SETUP] Writing config to Claude:');
879
+ console.log('[SETUP] desktop-commander args:', JSON.stringify(config.mcpServers["desktop-commander"].args));
880
+
883
881
  // Write the updated config back
884
882
  writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2), 'utf8');
883
+
884
+ // Verify what was written
885
+ const writtenConfig = JSON.parse(readFileSync(claudeConfigPath, 'utf8'));
886
+ console.log('[SETUP] Verified written args:', JSON.stringify(writtenConfig.mcpServers["desktop-commander"].args));
887
+
885
888
  updateSetupStep(updateConfigStep, 'completed');
886
889
  await trackEvent('npx_setup_update_config');
887
890
  } catch (updateError) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.2.18-alpha.4";
1
+ export declare const VERSION = "0.2.18-alpha.6";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.18-alpha.4';
1
+ export const VERSION = '0.2.18-alpha.6';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderwhy-er/desktop-commander",
3
- "version": "0.2.18-alpha.4",
3
+ "version": "0.2.18-alpha.6",
4
4
  "description": "MCP server for terminal operations and file editing",
5
5
  "mcpName": "io.github.wonderwhy-er/desktop-commander",
6
6
  "license": "MIT",