uloop-cli 0.45.2 → 0.46.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uloop-cli",
3
- "version": "0.45.2",
3
+ "version": "0.46.0",
4
4
  "//version": "x-release-please-version",
5
5
  "description": "CLI tool for Unity Editor communication via uLoopMCP",
6
6
  "main": "dist/cli.bundle.cjs",
@@ -41,12 +41,14 @@
41
41
  "provenance": true
42
42
  },
43
43
  "dependencies": {
44
- "commander": "^14.0.2"
44
+ "commander": "^14.0.2",
45
+ "semver": "^7.7.3"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@eslint/js": "9.39.2",
48
49
  "@types/jest": "30.0.0",
49
50
  "@types/node": "25.0.2",
51
+ "@types/semver": "^7.7.1",
50
52
  "esbuild": "0.27.1",
51
53
  "eslint": "9.39.2",
52
54
  "eslint-config-prettier": "^10.1.8",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.45.2",
2
+ "version": "0.46.0",
3
3
  "tools": [
4
4
  {
5
5
  "name": "compile",
@@ -10,6 +10,7 @@
10
10
  import * as readline from 'readline';
11
11
  import { existsSync } from 'fs';
12
12
  import { join } from 'path';
13
+ import * as semver from 'semver';
13
14
  import { DirectUnityClient } from './direct-unity-client.js';
14
15
  import { resolveUnityPort } from './port-resolver.js';
15
16
  import { saveToolsCache, getCacheFilePath, ToolsCache, ToolDefinition } from './tool-cache.js';
@@ -70,6 +71,52 @@ function isRetryableError(error: unknown): boolean {
70
71
  return message.includes('ECONNREFUSED') || message === 'UNITY_NO_RESPONSE';
71
72
  }
72
73
 
74
+ /**
75
+ * Compare two semantic versions safely.
76
+ * Returns true if v1 < v2, false otherwise.
77
+ * Falls back to string comparison if versions are invalid.
78
+ */
79
+ function isVersionOlder(v1: string, v2: string): boolean {
80
+ const parsed1 = semver.valid(v1);
81
+ const parsed2 = semver.valid(v2);
82
+
83
+ if (parsed1 && parsed2) {
84
+ return semver.lt(parsed1, parsed2);
85
+ }
86
+
87
+ return v1 < v2;
88
+ }
89
+
90
+ /**
91
+ * Print version mismatch warning to stderr.
92
+ * Does not block execution - just warns the user.
93
+ */
94
+ function printVersionWarning(cliVersion: string, serverVersion: string): void {
95
+ const isCliOlder = isVersionOlder(cliVersion, serverVersion);
96
+ const updateCommand = isCliOlder
97
+ ? `npm install -g uloop-cli@${serverVersion}`
98
+ : `Update uLoopMCP package to ${cliVersion} via Unity Package Manager`;
99
+
100
+ console.error('\x1b[33m⚠️ Version mismatch detected!\x1b[0m');
101
+ console.error(` uloop-cli version: ${cliVersion}`);
102
+ console.error(` uloop server version: ${serverVersion}`);
103
+ console.error('');
104
+ console.error(' This may cause unexpected behavior or errors.');
105
+ console.error('');
106
+ console.error(` ${isCliOlder ? 'To update CLI:' : 'To update server:'} ${updateCommand}`);
107
+ console.error('');
108
+ }
109
+
110
+ /**
111
+ * Check server version from response and print warning if mismatched.
112
+ */
113
+ function checkServerVersion(result: Record<string, unknown>): void {
114
+ const serverVersion = result['ULoopServerVersion'] as string | undefined;
115
+ if (serverVersion && serverVersion !== VERSION) {
116
+ printVersionWarning(VERSION, serverVersion);
117
+ }
118
+ }
119
+
73
120
  /**
74
121
  * Check if Unity is in a busy state (compiling, reloading, or server starting).
75
122
  * Throws an error with appropriate message if busy.
@@ -123,7 +170,7 @@ export async function executeToolCommand(
123
170
  await client.connect();
124
171
 
125
172
  spinner.update(`Executing ${toolName}...`);
126
- const result = await client.sendRequest(toolName, params);
173
+ const result = await client.sendRequest<Record<string, unknown>>(toolName, params);
127
174
 
128
175
  if (result === undefined || result === null) {
129
176
  throw new Error('UNITY_NO_RESPONSE');
@@ -132,6 +179,10 @@ export async function executeToolCommand(
132
179
  // Success - stop spinner and output result
133
180
  spinner.stop();
134
181
  restoreStdin();
182
+
183
+ // Check server version and warn if mismatched
184
+ checkServerVersion(result);
185
+
135
186
  console.log(JSON.stringify(result, null, 2));
136
187
  return;
137
188
  } catch (error) {
package/src/version.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  * This file exists to avoid bundling the entire package.json into the CLI bundle.
5
5
  * This version is automatically updated by release-please.
6
6
  */
7
- export const VERSION = '0.45.2'; // x-release-please-version
7
+ export const VERSION = '0.46.0'; // x-release-please-version