@wonderwhy-er/desktop-commander 0.2.18-alpha.1 → 0.2.18-alpha.10

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,37 +208,69 @@ function detectShell() {
208
208
 
209
209
  // Function to get the package spec that was used to run this script
210
210
  function getPackageSpec() {
211
- // Check if running via npx - look for the package spec in process.argv
212
- // e.g., npx @wonderwhy-er/desktop-commander@0.2.18-alpha setup
213
- const argv = process.argv;
211
+ // Write to a debug file that we can check
212
+ const debugFile = '/tmp/dc-setup-debug.log';
213
+ const debug = (msg) => {
214
+ process.stderr.write(`${msg}\n`);
215
+ try {
216
+ appendFileSync(debugFile, `${msg}\n`);
217
+ } catch (e) { /* ignore */ }
218
+ };
214
219
 
215
- // Debug: log what we're seeing
216
- console.log('[DEBUG] process.argv:', JSON.stringify(argv, null, 2));
220
+ debug('\n[DEBUG getPackageSpec] Starting detection...');
221
+ debug(`[DEBUG getPackageSpec] process.argv: ${JSON.stringify(process.argv)}`);
222
+ debug(`[DEBUG getPackageSpec] __dirname: ${__dirname}`);
223
+ debug(`[DEBUG getPackageSpec] __filename: ${__filename}`);
217
224
 
218
- // Look for the package name in argv
219
- for (let i = 0; i < argv.length; i++) {
220
- const arg = argv[i];
221
- if (arg.includes('@wonderwhy-er/desktop-commander')) {
222
- // Extract just the package spec (e.g., @wonderwhy-er/desktop-commander@0.2.18-alpha)
223
- const match = arg.match(/(@wonderwhy-er\/desktop-commander(@[^\/\s]+)?)/);
224
- if (match) {
225
- console.log('[DEBUG] Found package spec in argv:', match[1]);
226
- return match[1];
227
- }
228
- }
225
+ // Strategy: Check multiple sources to detect the version
226
+ // 1. Check process.argv[1] which contains the actual script path
227
+ // 2. Check package.json in the script's directory
228
+ // 3. Fall back to @latest for stable, keep version for pre-release
229
+
230
+ // Method 1: Check the script path (process.argv[1] or __dirname)
231
+ // npx extracts packages to: ~/.npm/_npx/<hash>/node_modules/@scope/package-name/
232
+ // The actual script path will contain this structure
233
+ const scriptPath = __dirname;
234
+ debug('[DEBUG getPackageSpec] Checking script path for version...');
235
+
236
+ // Look for node_modules/@wonderwhy-er/desktop-commander in the path
237
+ // This works because npx extracts to a predictable location
238
+ const nodeModulesMatch = scriptPath.match(/node_modules\/@wonderwhy-er\/desktop-commander/);
239
+ if (nodeModulesMatch) {
240
+ debug('[DEBUG getPackageSpec] Script is in node_modules, reading package.json...');
229
241
  }
230
242
 
231
- // Also check npm environment variables
232
- const npmPackage = process.env.npm_package_name;
233
- const npmVersion = process.env.npm_package_version;
234
- if (npmPackage === '@wonderwhy-er/desktop-commander' && npmVersion) {
235
- const spec = `${npmPackage}@${npmVersion}`;
236
- console.log('[DEBUG] Found package spec from npm env:', spec);
237
- return spec;
243
+ // Method 2: Read package.json to get the actual installed version
244
+ try {
245
+ const packageJsonPath = join(__dirname, 'package.json');
246
+ debug(`[DEBUG getPackageSpec] Trying to read: ${packageJsonPath}`);
247
+
248
+ if (existsSync(packageJsonPath)) {
249
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
250
+ const version = packageJson.version;
251
+ debug(`[DEBUG getPackageSpec] Found version in package.json: ${version}`);
252
+
253
+ if (version) {
254
+ // Always use the exact version if it's a pre-release
255
+ if (version.includes('alpha') || version.includes('beta') || version.includes('rc')) {
256
+ const spec = `@wonderwhy-er/desktop-commander@${version}`;
257
+ debug(`[DEBUG getPackageSpec] ✓ Using pre-release version: ${spec}`);
258
+ return spec;
259
+ }
260
+
261
+ // For stable versions, use @latest tag
262
+ debug('[DEBUG getPackageSpec] ✓ Stable version, using @latest');
263
+ return '@wonderwhy-er/desktop-commander@latest';
264
+ }
265
+ } else {
266
+ debug('[DEBUG getPackageSpec] ✗ package.json not found');
267
+ }
268
+ } catch (error) {
269
+ debug(`[DEBUG getPackageSpec] ✗ Error reading package.json: ${error.message}`);
238
270
  }
239
271
 
240
- console.log('[DEBUG] Falling back to @latest');
241
- // Fallback to @latest if we can't detect
272
+ // Fallback
273
+ debug('[DEBUG getPackageSpec] ⚠ Falling back to @latest');
242
274
  return '@wonderwhy-er/desktop-commander@latest';
243
275
  }
244
276
 
@@ -648,6 +680,13 @@ async function restartClaude() {
648
680
 
649
681
  // Main function to export for ESM compatibility
650
682
  export default async function setup() {
683
+ // VERY FIRST THING - test if stderr works AT ALL
684
+ process.stderr.write('\n\n========== SETUP FUNCTION STARTED ==========\n');
685
+ process.stderr.write(`__dirname: ${__dirname}\n`);
686
+ process.stderr.write(`__filename: ${__filename}\n`);
687
+ process.stderr.write(`process.argv: ${JSON.stringify(process.argv)}\n`);
688
+ process.stderr.write('=============================================\n\n');
689
+
651
690
  // Add tracking for setup function entry
652
691
  await trackEvent('npx_setup_function_started');
653
692
 
@@ -747,6 +786,8 @@ export default async function setup() {
747
786
 
748
787
  // Determine if running through npx or locally
749
788
  const isNpx = import.meta.url.includes('node_modules');
789
+ process.stderr.write(`\n[SETUP] import.meta.url: ${import.meta.url}\n`);
790
+ process.stderr.write(`[SETUP] isNpx: ${isNpx}\n`);
750
791
  await trackEvent('npx_setup_execution_mode', { isNpx });
751
792
 
752
793
  // Fix Windows path handling for npx execution
@@ -801,12 +842,21 @@ export default async function setup() {
801
842
  // Standard configuration without debug
802
843
  if (isNpx) {
803
844
  const packageSpec = getPackageSpec();
845
+ const debugFile = '/tmp/dc-setup-debug.log';
846
+ try {
847
+ appendFileSync(debugFile, `\n[SETUP] Creating config with package spec: ${packageSpec}\n`);
848
+ } catch (e) { /* ignore */ }
849
+ process.stderr.write(`\n[SETUP] Creating config with package spec: ${packageSpec}\n`);
804
850
  serverConfig = {
805
851
  "command": isWindows ? "npx.cmd" : "npx",
806
852
  "args": [
807
853
  packageSpec
808
854
  ]
809
855
  };
856
+ try {
857
+ appendFileSync(debugFile, `[SETUP] serverConfig.args: ${JSON.stringify(serverConfig.args)}\n`);
858
+ } catch (e) { /* ignore */ }
859
+ process.stderr.write(`[SETUP] serverConfig.args: ${JSON.stringify(serverConfig.args)}\n`);
810
860
  await trackEvent('npx_setup_config_standard_npx', { packageSpec });
811
861
  } else {
812
862
  // For local installation, use absolute path to handle Windows properly
@@ -844,8 +894,16 @@ export default async function setup() {
844
894
  // Add or update the terminal server config with the proper name "desktop-commander"
845
895
  config.mcpServers["desktop-commander"] = serverConfig;
846
896
 
897
+ process.stderr.write('\n[SETUP] Writing config to Claude:\n');
898
+ process.stderr.write(`[SETUP] desktop-commander args: ${JSON.stringify(config.mcpServers["desktop-commander"].args)}\n`);
899
+
847
900
  // Write the updated config back
848
901
  writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2), 'utf8');
902
+
903
+ // Verify what was written
904
+ const writtenConfig = JSON.parse(readFileSync(claudeConfigPath, 'utf8'));
905
+ process.stderr.write(`[SETUP] Verified written args: ${JSON.stringify(writtenConfig.mcpServers["desktop-commander"].args)}\n\n`);
906
+
849
907
  updateSetupStep(updateConfigStep, 'completed');
850
908
  await trackEvent('npx_setup_update_config');
851
909
  } catch (updateError) {
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.1";
1
+ export declare const VERSION = "0.2.18-alpha.10";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.18-alpha.1';
1
+ export const VERSION = '0.2.18-alpha.10';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderwhy-er/desktop-commander",
3
- "version": "0.2.18-alpha.1",
3
+ "version": "0.2.18-alpha.10",
4
4
  "description": "MCP server for terminal operations and file editing",
5
5
  "mcpName": "io.github.wonderwhy-er/desktop-commander",
6
6
  "license": "MIT",