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

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,31 +208,57 @@ 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
- // Debug: log what we're seeing
216
- console.log('[DEBUG] process.argv:', JSON.stringify(argv, null, 2));
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 || '';
217
220
 
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];
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';
227
252
  }
228
253
  }
254
+ } catch (error) {
255
+ console.log('[DEBUG] Could not read package.json:', error.message);
229
256
  }
230
257
 
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}`;
258
+ // Fallback to @latest
259
+ console.log('[DEBUG] Falling back to @latest');
260
+ return '@wonderwhy-er/desktop-commander@latest';
261
+ }
236
262
  console.log('[DEBUG] Found package spec from npm env:', spec);
237
263
  return spec;
238
264
  }
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.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.18-alpha.1';
1
+ export const VERSION = '0.2.18-alpha.3';
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.3",
4
4
  "description": "MCP server for terminal operations and file editing",
5
5
  "mcpName": "io.github.wonderwhy-er/desktop-commander",
6
6
  "license": "MIT",