@wonderwhy-er/desktop-commander 0.2.18-alpha.0 → 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,23 +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
+ };
219
+
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}`);
224
+
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...');
241
+ }
214
242
 
215
- // Look for the package name in argv
216
- for (let i = 0; i < argv.length; i++) {
217
- const arg = argv[i];
218
- if (arg.includes('@wonderwhy-er/desktop-commander')) {
219
- // Extract just the package spec (e.g., @wonderwhy-er/desktop-commander@0.2.18-alpha)
220
- const match = arg.match(/(@wonderwhy-er\/desktop-commander(@[^\/\s]+)?)/);
221
- if (match) {
222
- return match[1];
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';
223
264
  }
265
+ } else {
266
+ debug('[DEBUG getPackageSpec] ✗ package.json not found');
224
267
  }
268
+ } catch (error) {
269
+ debug(`[DEBUG getPackageSpec] ✗ Error reading package.json: ${error.message}`);
225
270
  }
226
271
 
227
- // Fallback to @latest if we can't detect
272
+ // Fallback
273
+ debug('[DEBUG getPackageSpec] ⚠ Falling back to @latest');
228
274
  return '@wonderwhy-er/desktop-commander@latest';
229
275
  }
230
276
 
@@ -634,6 +680,13 @@ async function restartClaude() {
634
680
 
635
681
  // Main function to export for ESM compatibility
636
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
+
637
690
  // Add tracking for setup function entry
638
691
  await trackEvent('npx_setup_function_started');
639
692
 
@@ -733,6 +786,8 @@ export default async function setup() {
733
786
 
734
787
  // Determine if running through npx or locally
735
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`);
736
791
  await trackEvent('npx_setup_execution_mode', { isNpx });
737
792
 
738
793
  // Fix Windows path handling for npx execution
@@ -787,12 +842,21 @@ export default async function setup() {
787
842
  // Standard configuration without debug
788
843
  if (isNpx) {
789
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`);
790
850
  serverConfig = {
791
851
  "command": isWindows ? "npx.cmd" : "npx",
792
852
  "args": [
793
853
  packageSpec
794
854
  ]
795
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`);
796
860
  await trackEvent('npx_setup_config_standard_npx', { packageSpec });
797
861
  } else {
798
862
  // For local installation, use absolute path to handle Windows properly
@@ -830,8 +894,16 @@ export default async function setup() {
830
894
  // Add or update the terminal server config with the proper name "desktop-commander"
831
895
  config.mcpServers["desktop-commander"] = serverConfig;
832
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
+
833
900
  // Write the updated config back
834
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
+
835
907
  updateSetupStep(updateConfigStep, 'completed');
836
908
  await trackEvent('npx_setup_update_config');
837
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.0";
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.0';
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.0",
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",