@wonderwhy-er/desktop-commander 0.2.18-alpha.11 → 0.2.18-alpha.13
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.
- package/dist/setup-claude-server.js +25 -101
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -207,96 +207,41 @@ function detectShell() {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// Function to get the package spec that was used to run this script
|
|
210
|
-
function getPackageSpec() {
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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...');
|
|
210
|
+
function getPackageSpec(versionArg = null) {
|
|
211
|
+
// If explicit version/tag argument provided, use it
|
|
212
|
+
// Usage: npx @wonderwhy-er/desktop-commander setup alpha
|
|
213
|
+
if (versionArg) {
|
|
214
|
+
return `@wonderwhy-er/desktop-commander@${versionArg}`;
|
|
241
215
|
}
|
|
242
216
|
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
|
|
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';
|
|
217
|
+
// Check if running via npx - look for the package spec in process.argv
|
|
218
|
+
// e.g., npx @wonderwhy-er/desktop-commander@0.2.18-alpha setup
|
|
219
|
+
const argv = process.argv;
|
|
220
|
+
|
|
221
|
+
// Look for the package name in argv
|
|
222
|
+
for (let i = 0; i < argv.length; i++) {
|
|
223
|
+
const arg = argv[i];
|
|
224
|
+
if (arg.includes('@wonderwhy-er/desktop-commander')) {
|
|
225
|
+
// Extract just the package spec (e.g., @wonderwhy-er/desktop-commander@0.2.18-alpha)
|
|
226
|
+
const match = arg.match(/(@wonderwhy-er\/desktop-commander(@[^\/\s]+)?)/);
|
|
227
|
+
if (match) {
|
|
228
|
+
return match[1];
|
|
264
229
|
}
|
|
265
|
-
} else {
|
|
266
|
-
debug('[DEBUG getPackageSpec] ✗ package.json not found');
|
|
267
230
|
}
|
|
268
|
-
} catch (error) {
|
|
269
|
-
debug(`[DEBUG getPackageSpec] ✗ Error reading package.json: ${error.message}`);
|
|
270
231
|
}
|
|
271
232
|
|
|
272
|
-
// Fallback
|
|
273
|
-
debug('[DEBUG getPackageSpec] ⚠ Falling back to @latest');
|
|
233
|
+
// Fallback to @latest if we can't detect
|
|
274
234
|
return '@wonderwhy-er/desktop-commander@latest';
|
|
275
235
|
}
|
|
276
236
|
|
|
277
237
|
// Function to determine execution context
|
|
278
238
|
function getExecutionContext() {
|
|
279
|
-
const debugFile = '/tmp/dc-setup-debug.log';
|
|
280
|
-
try {
|
|
281
|
-
appendFileSync(debugFile, `\n=== getExecutionContext ===\n`);
|
|
282
|
-
appendFileSync(debugFile, `process.env.npm_lifecycle_event: ${process.env.npm_lifecycle_event}\n`);
|
|
283
|
-
appendFileSync(debugFile, `process.env.npm_execpath: ${process.env.npm_execpath}\n`);
|
|
284
|
-
appendFileSync(debugFile, `process.env._: ${process.env._}\n`);
|
|
285
|
-
appendFileSync(debugFile, `import.meta.url: ${import.meta.url}\n`);
|
|
286
|
-
appendFileSync(debugFile, `__dirname: ${__dirname}\n`);
|
|
287
|
-
} catch (e) { /* ignore */ }
|
|
288
|
-
|
|
289
239
|
// Check if running from npx
|
|
290
240
|
const isNpx = process.env.npm_lifecycle_event === 'npx' ||
|
|
291
241
|
process.env.npm_execpath?.includes('npx') ||
|
|
292
242
|
process.env._?.includes('npx') ||
|
|
293
243
|
import.meta.url.includes('node_modules');
|
|
294
244
|
|
|
295
|
-
try {
|
|
296
|
-
appendFileSync(debugFile, `isNpx: ${isNpx}\n`);
|
|
297
|
-
appendFileSync(debugFile, `======================\n\n`);
|
|
298
|
-
} catch (e) { /* ignore */ }
|
|
299
|
-
|
|
300
245
|
// Check if installed globally
|
|
301
246
|
const isGlobal = process.env.npm_config_global === 'true' ||
|
|
302
247
|
process.argv[1]?.includes('node_modules/.bin');
|
|
@@ -305,7 +250,6 @@ function getExecutionContext() {
|
|
|
305
250
|
const isNpmScript = !!process.env.npm_lifecycle_script;
|
|
306
251
|
|
|
307
252
|
return {
|
|
308
|
-
isNpx,
|
|
309
253
|
runMethod: isNpx ? 'npx' : (isGlobal ? 'global' : (isNpmScript ? 'npm_script' : 'direct')),
|
|
310
254
|
isCI: !!process.env.CI || !!process.env.GITHUB_ACTIONS || !!process.env.TRAVIS || !!process.env.CIRCLECI,
|
|
311
255
|
shell: detectShell()
|
|
@@ -696,12 +640,11 @@ async function restartClaude() {
|
|
|
696
640
|
|
|
697
641
|
// Main function to export for ESM compatibility
|
|
698
642
|
export default async function setup() {
|
|
699
|
-
//
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
process.
|
|
704
|
-
process.stderr.write('=============================================\n\n');
|
|
643
|
+
// Parse command line arguments for version/tag
|
|
644
|
+
// Usage: npx @wonderwhy-er/desktop-commander setup alpha
|
|
645
|
+
// npx @wonderwhy-er/desktop-commander setup latest
|
|
646
|
+
// npx @wonderwhy-er/desktop-commander setup 0.2.18
|
|
647
|
+
const versionArg = process.argv[3]; // argv[0]=node, argv[1]=script, argv[2]=setup, argv[3]=version/tag
|
|
705
648
|
|
|
706
649
|
// Add tracking for setup function entry
|
|
707
650
|
await trackEvent('npx_setup_function_started');
|
|
@@ -802,8 +745,6 @@ export default async function setup() {
|
|
|
802
745
|
|
|
803
746
|
// Determine if running through npx or locally
|
|
804
747
|
const isNpx = import.meta.url.includes('node_modules');
|
|
805
|
-
process.stderr.write(`\n[SETUP] import.meta.url: ${import.meta.url}\n`);
|
|
806
|
-
process.stderr.write(`[SETUP] isNpx: ${isNpx}\n`);
|
|
807
748
|
await trackEvent('npx_setup_execution_mode', { isNpx });
|
|
808
749
|
|
|
809
750
|
// Fix Windows path handling for npx execution
|
|
@@ -821,7 +762,7 @@ export default async function setup() {
|
|
|
821
762
|
"DEBUG": "*"
|
|
822
763
|
};
|
|
823
764
|
|
|
824
|
-
const packageSpec = getPackageSpec();
|
|
765
|
+
const packageSpec = getPackageSpec(versionArg);
|
|
825
766
|
serverConfig = {
|
|
826
767
|
"command": isWindows ? "node.exe" : "node",
|
|
827
768
|
"args": [
|
|
@@ -857,22 +798,13 @@ export default async function setup() {
|
|
|
857
798
|
} else {
|
|
858
799
|
// Standard configuration without debug
|
|
859
800
|
if (isNpx) {
|
|
860
|
-
const packageSpec = getPackageSpec();
|
|
861
|
-
const debugFile = '/tmp/dc-setup-debug.log';
|
|
862
|
-
try {
|
|
863
|
-
appendFileSync(debugFile, `\n[SETUP] Creating config with package spec: ${packageSpec}\n`);
|
|
864
|
-
} catch (e) { /* ignore */ }
|
|
865
|
-
process.stderr.write(`\n[SETUP] Creating config with package spec: ${packageSpec}\n`);
|
|
801
|
+
const packageSpec = getPackageSpec(versionArg);
|
|
866
802
|
serverConfig = {
|
|
867
803
|
"command": isWindows ? "npx.cmd" : "npx",
|
|
868
804
|
"args": [
|
|
869
805
|
packageSpec
|
|
870
806
|
]
|
|
871
807
|
};
|
|
872
|
-
try {
|
|
873
|
-
appendFileSync(debugFile, `[SETUP] serverConfig.args: ${JSON.stringify(serverConfig.args)}\n`);
|
|
874
|
-
} catch (e) { /* ignore */ }
|
|
875
|
-
process.stderr.write(`[SETUP] serverConfig.args: ${JSON.stringify(serverConfig.args)}\n`);
|
|
876
808
|
await trackEvent('npx_setup_config_standard_npx', { packageSpec });
|
|
877
809
|
} else {
|
|
878
810
|
// For local installation, use absolute path to handle Windows properly
|
|
@@ -910,16 +842,8 @@ export default async function setup() {
|
|
|
910
842
|
// Add or update the terminal server config with the proper name "desktop-commander"
|
|
911
843
|
config.mcpServers["desktop-commander"] = serverConfig;
|
|
912
844
|
|
|
913
|
-
process.stderr.write('\n[SETUP] Writing config to Claude:\n');
|
|
914
|
-
process.stderr.write(`[SETUP] desktop-commander args: ${JSON.stringify(config.mcpServers["desktop-commander"].args)}\n`);
|
|
915
|
-
|
|
916
845
|
// Write the updated config back
|
|
917
846
|
writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2), 'utf8');
|
|
918
|
-
|
|
919
|
-
// Verify what was written
|
|
920
|
-
const writtenConfig = JSON.parse(readFileSync(claudeConfigPath, 'utf8'));
|
|
921
|
-
process.stderr.write(`[SETUP] Verified written args: ${JSON.stringify(writtenConfig.mcpServers["desktop-commander"].args)}\n\n`);
|
|
922
|
-
|
|
923
847
|
updateSetupStep(updateConfigStep, 'completed');
|
|
924
848
|
await trackEvent('npx_setup_update_config');
|
|
925
849
|
} catch (updateError) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.18-alpha.
|
|
1
|
+
export declare const VERSION = "0.2.18-alpha.13";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.2.18-alpha.
|
|
1
|
+
export const VERSION = '0.2.18-alpha.13';
|
package/package.json
CHANGED