@wonderwhy-er/desktop-commander 0.2.18-alpha.0 → 0.2.18-alpha.2

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,22 +208,62 @@ 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
+ // Strategy: We want to preserve the tag/version the user used
212
+ // - If user ran: npx @pkg@latest → keep @latest
213
+ // - If user ran: npx @pkg@alpha → keep @alpha
214
+ // - If user ran: npx @pkg@0.2.18-alpha.1 → keep @0.2.18-alpha.1
214
215
 
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];
216
+ // Check npm_config_user_agent which contains the original command
217
+ // Example: "npm/10.2.4 node/v20.11.0 darwin arm64 workspaces/false"
218
+ const userAgent = process.env.npm_config_user_agent || '';
219
+ const execPath = process.env.npm_execpath || '';
220
+
221
+ // Check if there's a version/tag in the npx cache path
222
+ // npx caches packages like: ~/.npm/_npx/<hash>/node_modules/@wonderwhy-er/desktop-commander
223
+ const scriptPath = import.meta.url;
224
+
225
+ // Look for @version in the path (npx cache includes it sometimes)
226
+ const versionMatch = scriptPath.match(/@wonderwhy-er\/desktop-commander@([^\/]+)/);
227
+ if (versionMatch) {
228
+ const spec = `@wonderwhy-er/desktop-commander@${versionMatch[1]}`;
229
+ console.log('[DEBUG] Detected version from path:', spec);
230
+ return spec;
231
+ }
232
+
233
+ // Read package.json to get the actual installed version
234
+ try {
235
+ const packageJsonPath = join(__dirname, 'package.json');
236
+ if (existsSync(packageJsonPath)) {
237
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
238
+ const version = packageJson.version;
239
+
240
+ if (version) {
241
+ // Check if version looks like a pre-release (alpha, beta, rc)
242
+ if (version.includes('alpha') || version.includes('beta') || version.includes('rc')) {
243
+ // User explicitly installed a pre-release version, keep it
244
+ const spec = `@wonderwhy-er/desktop-commander@${version}`;
245
+ console.log('[DEBUG] Using pre-release version:', spec);
246
+ return spec;
247
+ }
248
+
249
+ // For stable versions, assume user wants @latest
250
+ console.log('[DEBUG] Stable version detected, using @latest');
251
+ return '@wonderwhy-er/desktop-commander@latest';
223
252
  }
224
253
  }
254
+ } catch (error) {
255
+ console.log('[DEBUG] Could not read package.json:', error.message);
256
+ }
257
+
258
+ // Fallback to @latest
259
+ console.log('[DEBUG] Falling back to @latest');
260
+ return '@wonderwhy-er/desktop-commander@latest';
261
+ }
262
+ console.log('[DEBUG] Found package spec from npm env:', spec);
263
+ return spec;
225
264
  }
226
265
 
266
+ console.log('[DEBUG] Falling back to @latest');
227
267
  // Fallback to @latest if we can't detect
228
268
  return '@wonderwhy-er/desktop-commander@latest';
229
269
  }
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.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.18-alpha.0';
1
+ export const VERSION = '0.2.18-alpha.2';
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.2",
4
4
  "description": "MCP server for terminal operations and file editing",
5
5
  "mcpName": "io.github.wonderwhy-er/desktop-commander",
6
6
  "license": "MIT",