@veloxts/mcp 0.6.51 → 0.6.52

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @veloxts/mcp
2
2
 
3
+ ## 0.6.52
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(mcp): smart CLI resolution with fallbacks
8
+ - Updated dependencies
9
+ - @veloxts/cli@0.6.52
10
+ - @veloxts/router@0.6.52
11
+ - @veloxts/validation@0.6.52
12
+
3
13
  ## 0.6.51
4
14
 
5
15
  ### Patch Changes
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { spawn } from 'node:child_process';
7
7
  import { z } from 'zod';
8
+ import { resolveVeloxCLI } from '../utils/cli.js';
8
9
  import { findProjectRoot } from '../utils/project.js';
9
10
  // ============================================================================
10
11
  // Output Validation Schemas
@@ -55,10 +56,11 @@ export async function generate(options) {
55
56
  };
56
57
  }
57
58
  const args = buildArgs(options);
59
+ const resolved = resolveVeloxCLI(projectRoot, args);
58
60
  return new Promise((resolve) => {
59
- const child = spawn('npx', ['velox', ...args], {
61
+ const child = spawn(resolved.command, resolved.args, {
60
62
  cwd: projectRoot,
61
- shell: true,
63
+ shell: resolved.isNpx, // Only use shell for npx fallback
62
64
  stdio: ['pipe', 'pipe', 'pipe'],
63
65
  });
64
66
  let stdout = '';
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { spawn } from 'node:child_process';
7
7
  import { z } from 'zod';
8
+ import { resolveVeloxCLI } from '../utils/cli.js';
8
9
  import { findProjectRoot } from '../utils/project.js';
9
10
  // ============================================================================
10
11
  // Output Validation Schemas
@@ -54,10 +55,11 @@ export async function migrate(options) {
54
55
  };
55
56
  }
56
57
  const args = buildArgs(options);
58
+ const resolved = resolveVeloxCLI(projectRoot, args);
57
59
  return new Promise((resolve) => {
58
- const child = spawn('npx', ['velox', ...args], {
60
+ const child = spawn(resolved.command, resolved.args, {
59
61
  cwd: projectRoot,
60
- shell: true,
62
+ shell: resolved.isNpx, // Only use shell for npx fallback
61
63
  stdio: ['pipe', 'pipe', 'pipe'],
62
64
  });
63
65
  let stdout = '';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * CLI Resolution Utilities
3
+ *
4
+ * Utilities for finding and executing the VeloxTS CLI binary.
5
+ */
6
+ /**
7
+ * Resolved CLI command information
8
+ */
9
+ export interface ResolvedCLI {
10
+ /** Command to execute (binary path, 'node', or 'npx') */
11
+ command: string;
12
+ /** Arguments to pass (includes binary path if using node, or '@veloxts/cli' if using npx) */
13
+ args: string[];
14
+ /** Whether we're using npx fallback */
15
+ isNpx: boolean;
16
+ }
17
+ /**
18
+ * Resolve the VeloxTS CLI binary path with smart fallbacks
19
+ *
20
+ * Resolution order:
21
+ * 1. Local node_modules/.bin/velox (fastest, respects local version)
22
+ * 2. Windows .cmd wrapper (node_modules/.bin/velox.cmd)
23
+ * 3. Resolve @veloxts/cli package and find bin entry
24
+ * 4. Fallback to npx @veloxts/cli (slowest, downloads if needed)
25
+ */
26
+ export declare function resolveVeloxCLI(projectRoot: string, args: string[]): ResolvedCLI;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * CLI Resolution Utilities
3
+ *
4
+ * Utilities for finding and executing the VeloxTS CLI binary.
5
+ */
6
+ import { existsSync, readFileSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ /**
9
+ * Resolve the VeloxTS CLI binary path with smart fallbacks
10
+ *
11
+ * Resolution order:
12
+ * 1. Local node_modules/.bin/velox (fastest, respects local version)
13
+ * 2. Windows .cmd wrapper (node_modules/.bin/velox.cmd)
14
+ * 3. Resolve @veloxts/cli package and find bin entry
15
+ * 4. Fallback to npx @veloxts/cli (slowest, downloads if needed)
16
+ */
17
+ export function resolveVeloxCLI(projectRoot, args) {
18
+ const isWindows = process.platform === 'win32';
19
+ // 1. Try local .bin/velox (Unix)
20
+ if (!isWindows) {
21
+ const localBin = join(projectRoot, 'node_modules', '.bin', 'velox');
22
+ if (existsSync(localBin)) {
23
+ return {
24
+ command: localBin,
25
+ args,
26
+ isNpx: false,
27
+ };
28
+ }
29
+ }
30
+ // 2. Try Windows .cmd wrapper
31
+ if (isWindows) {
32
+ const localBinCmd = join(projectRoot, 'node_modules', '.bin', 'velox.cmd');
33
+ if (existsSync(localBinCmd)) {
34
+ return {
35
+ command: localBinCmd,
36
+ args,
37
+ isNpx: false,
38
+ };
39
+ }
40
+ }
41
+ // 3. Try resolving @veloxts/cli package directly
42
+ try {
43
+ const cliPackageJson = join(projectRoot, 'node_modules', '@veloxts', 'cli', 'package.json');
44
+ if (existsSync(cliPackageJson)) {
45
+ const pkg = JSON.parse(readFileSync(cliPackageJson, 'utf-8'));
46
+ const binRelative = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.velox;
47
+ if (binRelative) {
48
+ const binPath = join(projectRoot, 'node_modules', '@veloxts', 'cli', binRelative);
49
+ if (existsSync(binPath)) {
50
+ return {
51
+ command: 'node',
52
+ args: [binPath, ...args],
53
+ isNpx: false,
54
+ };
55
+ }
56
+ }
57
+ }
58
+ }
59
+ catch {
60
+ // Ignore resolution errors, fall through to npx
61
+ }
62
+ // 4. Fallback to npx (works even if not installed locally)
63
+ return {
64
+ command: 'npx',
65
+ args: ['@veloxts/cli', ...args],
66
+ isNpx: true,
67
+ };
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/mcp",
3
- "version": "0.6.51",
3
+ "version": "0.6.52",
4
4
  "description": "Model Context Protocol server for VeloxTS - expose project context to AI tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@modelcontextprotocol/sdk": "1.25.1",
26
- "@veloxts/router": "0.6.51",
27
- "@veloxts/validation": "0.6.51",
28
- "@veloxts/cli": "0.6.51"
26
+ "@veloxts/cli": "0.6.52",
27
+ "@veloxts/validation": "0.6.52",
28
+ "@veloxts/router": "0.6.52"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "zod": ">=3.25.0"