unity-mcp-cli 0.69.1 → 0.71.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/README.md +14 -1
- package/dist/commands/open.d.ts +20 -10
- package/dist/commands/open.js +224 -117
- package/dist/commands/open.js.map +1 -1
- package/dist/lib/open.d.ts +97 -0
- package/dist/lib/open.js +461 -0
- package/dist/lib/open.js.map +1 -0
- package/dist/lib/types.d.ts +191 -0
- package/dist/lib.d.ts +2 -1
- package/dist/lib.js +1 -0
- package/dist/lib.js.map +1 -1
- package/dist/utils/launch-error-dismiss.d.ts +159 -0
- package/dist/utils/launch-error-dismiss.js +440 -0
- package/dist/utils/launch-error-dismiss.js.map +1 -0
- package/dist/utils/unity-editor.d.ts +17 -3
- package/dist/utils/unity-editor.js +47 -11
- package/dist/utils/unity-editor.js.map +1 -1
- package/dist/utils/unity-hub.js +20 -4
- package/dist/utils/unity-hub.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -255,8 +255,21 @@ cd ./MyGame && unity-mcp-cli open
|
|
|
255
255
|
| `--tools <names>` | `UNITY_MCP_TOOLS` | No | Comma-separated list of tools to enable |
|
|
256
256
|
| `--transport <method>` | `UNITY_MCP_TRANSPORT` | No | Transport method: `streamableHttp` or `stdio` |
|
|
257
257
|
| `--start-server <value>` | `UNITY_MCP_START_SERVER` | No | Set to `true` or `false` to control MCP server auto-start |
|
|
258
|
+
| `--no-auto-dismiss-launch-errors` | — | No | Disable auto-dismissal of the Unity Editor "compile errors at launch" dialog (default: enabled) |
|
|
259
|
+
| `--launch-dismiss-timeout-ms <ms>` | — | No | Overall timeout (milliseconds) for the launch-errors auto-dismiss polling loop (default: `30000`) |
|
|
260
|
+
| `--launch-dismiss-poll-interval-ms <ms>` | — | No | Polling tick interval (milliseconds) for the launch-errors auto-dismiss loop (default: `1500`) |
|
|
258
261
|
|
|
259
|
-
The editor process is spawned in detached mode — the
|
|
262
|
+
The editor process is spawned in detached mode. By default, after spawning the editor, `open` polls for Unity's "compile errors at launch" dialog (`"Enter Safe Mode?"` on Unity 2020.2+, `"Hold On" / "Compiler Errors"` on older releases) and clicks `Ignore` so the editor finishes initialising — without this, any in-Editor automation that needs to run after a state where Unity itself can't compile (e.g. the NuGet dependency resolver) cannot self-heal. The dialog is surfaced after Unity has booted, connected to Package Manager, and started compiling — empirically ~6s on a fast machine and longer on a slow one — so the polling loop has a grace window after which it exits early if no dialog has been seen. The grace window has to cover Unity's full startup phase or the loop bails out before the dialog ever appears (issue #737); it never runs the full `--launch-dismiss-timeout-ms` in the no-dialog case. If the dialog is observed (and successfully dismissed), polling continues until the overall timeout so a re-appearing dialog (resolver fixes one error → dialog re-surfaces with the next) is dismissed again. Library-mode callers can supply an `AbortSignal` (`launchDismissAbortSignal` on `OpenProjectOptions`) to abort the loop the instant their own readiness signal fires.
|
|
263
|
+
|
|
264
|
+
### Auto-dismiss platform requirements
|
|
265
|
+
|
|
266
|
+
| Platform | Requirement | Notes |
|
|
267
|
+
|---|---|---|
|
|
268
|
+
| **Windows** | Built-in (Win32 API) | Uses `EnumWindows` / `EnumChildWindows` / `SendMessageW(BM_CLICK)` driven from PowerShell. No extra setup required. |
|
|
269
|
+
| **macOS** | **Accessibility permission** must be granted to the terminal (or `unity-mcp-cli` binary). System Settings → Privacy & Security → Accessibility. | Implemented via AppleScript / `osascript`. Without this permission, `osascript` reports an error every poll tick and the dialog cannot be dismissed. |
|
|
270
|
+
| **Linux/X11** | `xdotool` on `PATH` (e.g. `sudo apt-get install xdotool`). | Wayland is **not** supported in the first cut — track upstream issues for Wayland support. |
|
|
271
|
+
|
|
272
|
+
To opt out entirely, pass `--no-auto-dismiss-launch-errors`.
|
|
260
273
|
|
|
261
274
|
**Example — open with MCP connection:**
|
|
262
275
|
|
package/dist/commands/open.d.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { isUnityProjectDir as libIsUnityProjectDir } from '../lib/open.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the project path from the positional argument, `--path` option, or
|
|
5
|
+
* the current working directory when neither is provided.
|
|
6
|
+
*
|
|
7
|
+
* Re-exported from the library helper so existing tests continue to import
|
|
8
|
+
* `resolveOpenProjectPath` from this module.
|
|
9
|
+
*/
|
|
2
10
|
export interface ResolveProjectPathResult {
|
|
3
11
|
/** Absolute, resolved path to the project directory. */
|
|
4
12
|
projectPath: string;
|
|
5
13
|
/** True if no path was supplied and we fell back to `process.cwd()`. */
|
|
6
14
|
usedCwdFallback: boolean;
|
|
7
15
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the project path from the positional argument, `--path` option, or
|
|
10
|
-
* the current working directory when neither is provided.
|
|
11
|
-
*
|
|
12
|
-
* Exported for unit testing.
|
|
13
|
-
*/
|
|
14
16
|
export declare function resolveOpenProjectPath(positionalPath: string | undefined, optionPath: string | undefined, cwd: string): ResolveProjectPathResult;
|
|
17
|
+
/** Re-export for backward compatibility with existing tests. */
|
|
18
|
+
export declare const isUnityProjectDir: typeof libIsUnityProjectDir;
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* Parse a `--xxx <ms>` style commander option as a positive integer.
|
|
21
|
+
* Commander stores the raw string (including the literal default
|
|
22
|
+
* supplied to `.option()`), so a parse-and-validate step is required
|
|
23
|
+
* before the value can flow into the library. Exits with code 1 on
|
|
24
|
+
* a non-numeric / non-positive value — matches the CLI's existing
|
|
25
|
+
* error-handling pattern for malformed flag values (`--auth`,
|
|
26
|
+
* `--transport`, `--start-server`).
|
|
18
27
|
*
|
|
19
|
-
* Exported for unit
|
|
28
|
+
* Exported for unit tests; the CLI wrapper is the only production
|
|
29
|
+
* caller.
|
|
20
30
|
*/
|
|
21
|
-
export declare function
|
|
31
|
+
export declare function parsePositiveIntFlag(raw: string | undefined, flagName: string, fallback: number): number;
|
|
22
32
|
export declare const openCommand: Command;
|
package/dist/commands/open.js
CHANGED
|
@@ -1,35 +1,86 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import
|
|
4
|
-
import { findEditorPath, getProjectEditorVersion, launchEditor, printEditorNotFoundHelp } from '../utils/unity-editor.js';
|
|
3
|
+
import { findUnityHub, listInstalledEditors } from '../utils/unity-hub.js';
|
|
5
4
|
import { findUnityProcess } from '../utils/unity-process.js';
|
|
6
5
|
import * as ui from '../utils/ui.js';
|
|
7
6
|
import { verbose } from '../utils/ui.js';
|
|
8
|
-
import {
|
|
9
|
-
/**
|
|
10
|
-
* Resolve the project path from the positional argument, `--path` option, or
|
|
11
|
-
* the current working directory when neither is provided.
|
|
12
|
-
*
|
|
13
|
-
* Exported for unit testing.
|
|
14
|
-
*/
|
|
7
|
+
import { openProject, resolveProjectPath as libResolveProjectPath, isUnityProjectDir as libIsUnityProjectDir, } from '../lib/open.js';
|
|
15
8
|
export function resolveOpenProjectPath(positionalPath, optionPath, cwd) {
|
|
9
|
+
// The CLI takes both a positional `[path]` AND an `--path` flag; the
|
|
10
|
+
// library helper only takes a single `optionPath`. Collapse the two
|
|
11
|
+
// CLI inputs (positional wins) before delegating.
|
|
16
12
|
const explicit = positionalPath ?? optionPath;
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
projectPath: path.resolve(resolvedPath),
|
|
20
|
-
usedCwdFallback: explicit === undefined,
|
|
21
|
-
};
|
|
13
|
+
return libResolveProjectPath(explicit, cwd);
|
|
22
14
|
}
|
|
15
|
+
/** Re-export for backward compatibility with existing tests. */
|
|
16
|
+
export const isUnityProjectDir = libIsUnityProjectDir;
|
|
23
17
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
18
|
+
* Parse a `--xxx <ms>` style commander option as a positive integer.
|
|
19
|
+
* Commander stores the raw string (including the literal default
|
|
20
|
+
* supplied to `.option()`), so a parse-and-validate step is required
|
|
21
|
+
* before the value can flow into the library. Exits with code 1 on
|
|
22
|
+
* a non-numeric / non-positive value — matches the CLI's existing
|
|
23
|
+
* error-handling pattern for malformed flag values (`--auth`,
|
|
24
|
+
* `--transport`, `--start-server`).
|
|
26
25
|
*
|
|
27
|
-
* Exported for unit
|
|
26
|
+
* Exported for unit tests; the CLI wrapper is the only production
|
|
27
|
+
* caller.
|
|
28
28
|
*/
|
|
29
|
-
export function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
export function parsePositiveIntFlag(raw, flagName, fallback) {
|
|
30
|
+
if (raw === undefined)
|
|
31
|
+
return fallback;
|
|
32
|
+
const trimmed = String(raw).trim();
|
|
33
|
+
if (trimmed === '')
|
|
34
|
+
return fallback;
|
|
35
|
+
// Reject scientific notation, fractions, and explicit signs — the
|
|
36
|
+
// ms value MUST be a positive whole number for the polling loop's
|
|
37
|
+
// bookkeeping to be sane.
|
|
38
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
39
|
+
ui.error(`${flagName} must be a positive integer (got: "${raw}")`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
const parsed = parseInt(trimmed, 10);
|
|
43
|
+
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
44
|
+
ui.error(`${flagName} must be a positive integer (got: "${raw}")`);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
return parsed;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Print actionable help when a required Unity Editor version is not found.
|
|
51
|
+
* Lists installed editors and suggests install or override commands. Lives
|
|
52
|
+
* here (next to the CLI command) instead of `unity-editor.ts` because it
|
|
53
|
+
* writes to the chalk-styled `ui` and we want to keep the `unity-editor.ts`
|
|
54
|
+
* helpers library-safe.
|
|
55
|
+
*/
|
|
56
|
+
function printEditorNotFoundHelp(requestedVersion, commandName) {
|
|
57
|
+
if (requestedVersion) {
|
|
58
|
+
ui.error(`Unity Editor ${requestedVersion} is not installed.`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
ui.error('No Unity Editor found.');
|
|
62
|
+
}
|
|
63
|
+
ui.heading('Options:');
|
|
64
|
+
if (requestedVersion) {
|
|
65
|
+
ui.info(`Install it: npx unity-mcp-cli install-unity ${requestedVersion}`);
|
|
66
|
+
}
|
|
67
|
+
ui.info('Install latest stable: npx unity-mcp-cli install-unity');
|
|
68
|
+
const hubPath = findUnityHub();
|
|
69
|
+
if (hubPath) {
|
|
70
|
+
const editors = listInstalledEditors(hubPath);
|
|
71
|
+
if (editors.length > 0) {
|
|
72
|
+
ui.heading('Installed editors:');
|
|
73
|
+
for (const editor of editors) {
|
|
74
|
+
ui.label(editor.version, editor.path);
|
|
75
|
+
}
|
|
76
|
+
if (requestedVersion) {
|
|
77
|
+
const hint = commandName === 'connect'
|
|
78
|
+
? `npx unity-mcp-cli ${commandName} --unity ${editors[0].version} --path <path> --url <url>`
|
|
79
|
+
: `npx unity-mcp-cli ${commandName} <path> --unity ${editors[0].version}`;
|
|
80
|
+
ui.info(`Use a different version: ${hint}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
33
84
|
}
|
|
34
85
|
export const openCommand = new Command('open')
|
|
35
86
|
.description('Open a Unity project in Unity Editor, optionally passing MCP connection env vars when connection options (--url, --token, etc.) are provided. Use --no-connect to suppress all MCP env vars.')
|
|
@@ -44,17 +95,23 @@ export const openCommand = new Command('open')
|
|
|
44
95
|
.option('--keep-connected', 'Force keep connected (sets UNITY_MCP_KEEP_CONNECTED=true)')
|
|
45
96
|
.option('--transport <method>', 'Transport method: streamableHttp or stdio (sets UNITY_MCP_TRANSPORT)')
|
|
46
97
|
.option('--start-server <value>', 'Set to true/false to control server auto-start (sets UNITY_MCP_START_SERVER)', undefined)
|
|
98
|
+
.option('--no-auto-dismiss-launch-errors', 'Disable auto-dismissal of the Unity Editor "compile errors at launch" dialog (default: enabled). On macOS, requires Accessibility permission for the terminal / unity-mcp-cli binary. On Linux/X11, requires `xdotool` on PATH (Wayland not supported).')
|
|
99
|
+
.option('--launch-dismiss-timeout-ms <ms>', 'Overall timeout (milliseconds) for the launch-errors auto-dismiss polling loop (default: 30000)', '30000')
|
|
100
|
+
.option('--launch-dismiss-poll-interval-ms <ms>', 'Polling tick interval (milliseconds) for the launch-errors auto-dismiss loop (default: 1500)', '1500')
|
|
47
101
|
.action(async (positionalPath, options) => {
|
|
102
|
+
// Resolve the path the same way the library does, but also
|
|
103
|
+
// validate the existence + Unity-project shape up front so we
|
|
104
|
+
// can emit the historical, friendlier "Current directory is
|
|
105
|
+
// not a Unity project" message when the cwd-fallback was used.
|
|
106
|
+
// The library always reports the underlying error string, but
|
|
107
|
+
// the CLI is allowed to render two different variants.
|
|
48
108
|
const { projectPath, usedCwdFallback } = resolveOpenProjectPath(positionalPath, options.path, process.cwd());
|
|
109
|
+
const fs = await import('fs');
|
|
49
110
|
if (!fs.existsSync(projectPath)) {
|
|
50
111
|
ui.error(`Project path does not exist: ${projectPath}`);
|
|
51
112
|
process.exit(1);
|
|
52
113
|
}
|
|
53
|
-
|
|
54
|
-
// presence of both `Assets/` and `ProjectSettings/ProjectVersion.txt`
|
|
55
|
-
// to avoid launching the Editor against an unrelated folder — this
|
|
56
|
-
// matters most when the user omits the path and we fall back to cwd.
|
|
57
|
-
if (!isUnityProjectDir(projectPath)) {
|
|
114
|
+
if (!libIsUnityProjectDir(projectPath)) {
|
|
58
115
|
if (usedCwdFallback) {
|
|
59
116
|
ui.error(`Current directory is not a Unity project: ${projectPath}`);
|
|
60
117
|
ui.info('Run this command from a Unity project folder, or pass a path: unity-mcp-cli open <path>');
|
|
@@ -69,107 +126,157 @@ export const openCommand = new Command('open')
|
|
|
69
126
|
}
|
|
70
127
|
verbose(`open invoked for project: ${projectPath}`);
|
|
71
128
|
verbose(`--no-connect: ${options.connect === false}`);
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
ui.
|
|
77
|
-
process.exit(
|
|
78
|
-
}
|
|
79
|
-
// Determine editor version
|
|
80
|
-
let version = options.unity;
|
|
81
|
-
if (!version) {
|
|
82
|
-
version = getProjectEditorVersion(projectPath) ?? undefined;
|
|
83
|
-
if (version) {
|
|
84
|
-
ui.info(`Detected editor version from project: ${version}`);
|
|
85
|
-
verbose(`Resolved editor version from ProjectVersion.txt: ${version}`);
|
|
86
|
-
}
|
|
129
|
+
// Validate auth/transport/startServer here — keeps the historical
|
|
130
|
+
// CLI error messages and exit codes (the library reports these
|
|
131
|
+
// as `kind: 'failure'` instead).
|
|
132
|
+
if (options.auth !== undefined && options.auth !== 'none' && options.auth !== 'required') {
|
|
133
|
+
ui.error('--auth must be "none" or "required"');
|
|
134
|
+
process.exit(1);
|
|
87
135
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!editorPath) {
|
|
91
|
-
spinner.stop();
|
|
92
|
-
printEditorNotFoundHelp(version, 'open');
|
|
136
|
+
if (options.transport !== undefined && options.transport !== 'streamableHttp' && options.transport !== 'stdio') {
|
|
137
|
+
ui.error('--transport must be "streamableHttp" or "stdio"');
|
|
93
138
|
process.exit(1);
|
|
94
139
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const config = readConfig(projectPath);
|
|
102
|
-
if (config && isCloudMode(config) && config.cloudToken) {
|
|
103
|
-
if (!options.keepConnected) {
|
|
104
|
-
options.keepConnected = true;
|
|
105
|
-
verbose('Cloud mode with token detected — auto-enabling keep-connected');
|
|
106
|
-
}
|
|
107
|
-
const skillAutoGenerate = { ...(config.skillAutoGenerate ?? {}) };
|
|
108
|
-
if (!skillAutoGenerate['claude-code']) {
|
|
109
|
-
skillAutoGenerate['claude-code'] = true;
|
|
110
|
-
writeConfig(projectPath, { ...config, skillAutoGenerate });
|
|
111
|
-
verbose('Auto-enabled skill generation for claude-code');
|
|
112
|
-
}
|
|
140
|
+
let startServerBool;
|
|
141
|
+
if (options.startServer !== undefined) {
|
|
142
|
+
const val = options.startServer.toLowerCase();
|
|
143
|
+
if (val !== 'true' && val !== 'false') {
|
|
144
|
+
ui.error('--start-server must be "true" or "false"');
|
|
145
|
+
process.exit(1);
|
|
113
146
|
}
|
|
147
|
+
startServerBool = val === 'true';
|
|
114
148
|
}
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
// --launch-dismiss-timeout-ms / --launch-dismiss-poll-interval-ms
|
|
150
|
+
// are commander string options with numeric defaults. Parse and
|
|
151
|
+
// validate here so the failure mode is a clear CLI error rather
|
|
152
|
+
// than a silent NaN that disables the polling loop.
|
|
153
|
+
const launchDismissTimeoutMs = parsePositiveIntFlag(options.launchDismissTimeoutMs, '--launch-dismiss-timeout-ms', 30000);
|
|
154
|
+
const launchDismissPollIntervalMs = parsePositiveIntFlag(options.launchDismissPollIntervalMs, '--launch-dismiss-poll-interval-ms', 1500);
|
|
155
|
+
// Commander's `--no-auto-dismiss-launch-errors` produces
|
|
156
|
+
// `autoDismissLaunchErrors: false`; the absence of the flag
|
|
157
|
+
// produces `undefined` (which `openProject` treats as the default
|
|
158
|
+
// `true`). No additional parsing needed.
|
|
159
|
+
// Pre-flight already-running check so we don't flash the
|
|
160
|
+
// "Locating Unity Editor..." spinner when Unity is already open
|
|
161
|
+
// for this project. The lib does its own check too (single
|
|
162
|
+
// source of truth for the result shape); this one only suppresses
|
|
163
|
+
// spinner spam in the common already-open case.
|
|
164
|
+
const alreadyRunningPid = findUnityProcess(projectPath)?.pid;
|
|
165
|
+
// Spinner around editor location for parity with the legacy UX.
|
|
166
|
+
let spinner = alreadyRunningPid === undefined
|
|
167
|
+
? ui.startSpinner('Locating Unity Editor...')
|
|
168
|
+
: undefined;
|
|
169
|
+
const result = await openProject({
|
|
170
|
+
projectPath,
|
|
171
|
+
unityVersion: options.unity,
|
|
172
|
+
noConnect: options.connect === false,
|
|
173
|
+
url: options.url,
|
|
174
|
+
token: options.token,
|
|
175
|
+
auth: options.auth,
|
|
176
|
+
tools: options.tools,
|
|
177
|
+
keepConnected: options.keepConnected,
|
|
178
|
+
transport: options.transport,
|
|
179
|
+
startServer: startServerBool,
|
|
180
|
+
autoDismissLaunchErrors: options.autoDismissLaunchErrors !== false,
|
|
181
|
+
launchDismissTimeoutMs,
|
|
182
|
+
launchDismissPollIntervalMs,
|
|
183
|
+
onProgress: (event) => {
|
|
184
|
+
switch (event.phase) {
|
|
185
|
+
case 'detecting-editor-version': {
|
|
186
|
+
// unity-version detection is fast — no UI noise needed.
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
case 'editors-located': {
|
|
190
|
+
// Cover the case where editor discovery succeeded — the
|
|
191
|
+
// spinner success message lands on `editor-resolved`,
|
|
192
|
+
// not here, so we don't overwrite the "Locating…" line.
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case 'editor-resolved': {
|
|
196
|
+
if (spinner) {
|
|
197
|
+
spinner.success('Unity Editor located');
|
|
198
|
+
spinner = undefined;
|
|
199
|
+
}
|
|
200
|
+
verbose(`Editor path: ${event.editorPath}`);
|
|
201
|
+
if (event.version) {
|
|
202
|
+
ui.info(`Detected editor version from project: ${event.version}`);
|
|
203
|
+
verbose(`Resolved editor version from ProjectVersion.txt: ${event.version}`);
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 'connection-details': {
|
|
208
|
+
const envVars = event.envVars;
|
|
209
|
+
if (Object.keys(envVars).length > 0) {
|
|
210
|
+
ui.heading('Connection Details');
|
|
211
|
+
ui.label('Project', event.projectPath);
|
|
212
|
+
ui.label('Editor', event.editorPath);
|
|
213
|
+
ui.heading('Environment Variables');
|
|
214
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
215
|
+
const display = key === 'UNITY_MCP_TOKEN' ? '***' : value;
|
|
216
|
+
ui.label(key, display);
|
|
217
|
+
verbose(`Setting ${key}=${display}`);
|
|
218
|
+
}
|
|
219
|
+
ui.divider();
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
verbose('MCP connection disabled via --no-connect or no options');
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
case 'launching-editor': {
|
|
227
|
+
ui.label('Project', event.projectPath);
|
|
228
|
+
ui.label('Editor', event.editorPath);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case 'editor-launched': {
|
|
232
|
+
ui.success(`Launched Unity Editor (PID: ${event.pid ?? 'unknown'})`);
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
case 'launch-errors-dismissed': {
|
|
236
|
+
// Single info-level log line on dismissal — exact format
|
|
237
|
+
// is part of the issue's acceptance contract. Keep in
|
|
238
|
+
// sync with `launch-error-dismiss.ts` if changed.
|
|
239
|
+
ui.info(`[open] dismissed Unity launch-errors dialog (button=${event.button}, platform=${event.platform})`);
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
default:
|
|
243
|
+
break;
|
|
143
244
|
}
|
|
144
|
-
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
if (spinner) {
|
|
248
|
+
// Library returned before emitting `editor-resolved` — most
|
|
249
|
+
// likely failed to locate an editor. Stop the spinner so the
|
|
250
|
+
// error path renders cleanly.
|
|
251
|
+
spinner.stop();
|
|
252
|
+
spinner = undefined;
|
|
253
|
+
}
|
|
254
|
+
if (result.kind === 'failure') {
|
|
255
|
+
// Render the failure with the original CLI surface. Two cases
|
|
256
|
+
// get the rich "no editor found" help; everything else is a
|
|
257
|
+
// plain ui.error.
|
|
258
|
+
if (result.errorMessage.startsWith('Unity Editor') &&
|
|
259
|
+
result.errorMessage.endsWith('is not installed.')) {
|
|
260
|
+
printEditorNotFoundHelp(options.unity, 'open');
|
|
145
261
|
}
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
if (val !== 'true' && val !== 'false') {
|
|
149
|
-
ui.error('--start-server must be "true" or "false"');
|
|
150
|
-
process.exit(1);
|
|
151
|
-
}
|
|
152
|
-
envVars['UNITY_MCP_START_SERVER'] = val;
|
|
262
|
+
else if (result.errorMessage === 'No Unity Editor found.') {
|
|
263
|
+
printEditorNotFoundHelp(undefined, 'open');
|
|
153
264
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
ui.heading('Connection Details');
|
|
157
|
-
ui.label('Project', projectPath);
|
|
158
|
-
ui.label('Editor', editorPath);
|
|
159
|
-
ui.heading('Environment Variables');
|
|
160
|
-
for (const [key, value] of Object.entries(envVars)) {
|
|
161
|
-
const display = key === 'UNITY_MCP_TOKEN' ? '***' : value;
|
|
162
|
-
ui.label(key, display);
|
|
163
|
-
verbose(`Setting ${key}=${display}`);
|
|
164
|
-
}
|
|
165
|
-
ui.divider();
|
|
265
|
+
else {
|
|
266
|
+
ui.error(result.errorMessage);
|
|
166
267
|
}
|
|
268
|
+
process.exit(1);
|
|
167
269
|
}
|
|
168
|
-
|
|
169
|
-
|
|
270
|
+
// Already-running short-circuit: the library returns success
|
|
271
|
+
// with `alreadyRunning: true`. Preserve the original exit-0 +
|
|
272
|
+
// friendly message.
|
|
273
|
+
if (result.alreadyRunning) {
|
|
274
|
+
ui.success(`Unity is already running with this project (PID: ${result.editorPid ?? 'unknown'})`);
|
|
275
|
+
ui.info('Skipping launch. Use the running instance or close it first.');
|
|
276
|
+
process.exit(0);
|
|
170
277
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
278
|
+
// Path is normally absolute already; resolve defensively for
|
|
279
|
+
// verbose log parity with the legacy CLI.
|
|
280
|
+
verbose(`Resolved project path: ${path.resolve(result.projectPath)}`);
|
|
174
281
|
});
|
|
175
282
|
//# sourceMappingURL=open.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/commands/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/commands/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,WAAW,EACX,kBAAkB,IAAI,qBAAqB,EAC3C,iBAAiB,IAAI,oBAAoB,GAC1C,MAAM,gBAAgB,CAAC;AAiBxB,MAAM,UAAU,sBAAsB,CACpC,cAAkC,EAClC,UAA8B,EAC9B,GAAW;IAEX,qEAAqE;IACrE,oEAAoE;IACpE,kDAAkD;IAClD,MAAM,QAAQ,GAAG,cAAc,IAAI,UAAU,CAAC;IAC9C,OAAO,qBAAqB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAuB,EACvB,QAAgB,EAChB,QAAgB;IAEhB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACvC,MAAM,OAAO,GAAG,M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,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,6DAA6D;IAC7D,8DAA8D;IAC9D,oBAAoB;IACpB,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,EAAE,CAAC,OAAO,CAAC,oDAAoD,MAAM,CAAC,SAAS,IAAI,SAAS,GAAG,CAAC,CAAC;QACjG,EAAE,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,6DAA6D;IAC7D,0CAA0C;IAC1C,OAAO,CAAC,0BAA0B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { tryDismissLaunchErrorsDialog, type DismissPlatform } from '../utils/launch-error-dismiss.js';
|
|
2
|
+
import type { OpenEnvInputs, OpenProjectOptions, OpenProjectResult, ProgressCallback } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the project path from an explicit option or fall back to
|
|
5
|
+
* the supplied cwd. Always returns an absolute, resolved path plus a
|
|
6
|
+
* flag indicating whether the cwd fallback was used (so the CLI
|
|
7
|
+
* surface can emit a friendlier "no path provided" message).
|
|
8
|
+
*
|
|
9
|
+
* Pure / no I/O — exported for tests and for the CLI command's own
|
|
10
|
+
* use so the two paths can share resolution semantics.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveProjectPath(optionPath: string | undefined, cwd: string): {
|
|
13
|
+
projectPath: string;
|
|
14
|
+
usedCwdFallback: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Returns true if `projectPath` looks like a Unity project — i.e. it
|
|
18
|
+
* contains an `Assets/` directory and a
|
|
19
|
+
* `ProjectSettings/ProjectVersion.txt` file. Pure / no I/O beyond
|
|
20
|
+
* `fs.existsSync`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isUnityProjectDir(projectPath: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Build the env-var map propagated to the editor process when
|
|
25
|
+
* `noConnect !== true`. Pure (returns a fresh object); validates the
|
|
26
|
+
* `auth` and `transport` enums and throws on bad input — the
|
|
27
|
+
* `openProject` boundary catches the throw and returns it as a
|
|
28
|
+
* `{ kind: 'failure' }` result so nothing escapes past the public
|
|
29
|
+
* boundary.
|
|
30
|
+
*
|
|
31
|
+
* Exported for tests so the env-var assembly can be exercised
|
|
32
|
+
* without a real editor launch.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildOpenEnv(options: OpenEnvInputs): Record<string, string> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Open a Unity project in the Unity Editor — the library-callable
|
|
37
|
+
* equivalent of the `open` CLI command. Library-safe: never calls
|
|
38
|
+
* `process.exit`, never prints to stdout / stderr, never throws past
|
|
39
|
+
* the public boundary.
|
|
40
|
+
*
|
|
41
|
+
* The launch logic (Unity-version detection, editor location,
|
|
42
|
+
* project-path validation, environment-variable wiring, editor
|
|
43
|
+
* spawn) is shared with the CLI command — `commands/open.ts`
|
|
44
|
+
* delegates to this function so the two paths cannot drift.
|
|
45
|
+
*
|
|
46
|
+
* Returns a discriminated union — narrow with
|
|
47
|
+
* `result.kind === 'success'` to access `editorPath` / `editorPid`
|
|
48
|
+
* / `unityVersion` / `projectPath`, or `result.kind === 'failure'`
|
|
49
|
+
* to access `errorMessage` / `error`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function openProject(options: OpenProjectOptions): Promise<OpenProjectResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Options for `pollAndDismissLaunchErrors`. The `_` prefix marks the
|
|
54
|
+
* test-only export; production code never imports this directly —
|
|
55
|
+
* `openProject` is the only caller.
|
|
56
|
+
*/
|
|
57
|
+
export interface _PollAndDismissOptionsForTests {
|
|
58
|
+
timeoutMs: number;
|
|
59
|
+
intervalMs: number;
|
|
60
|
+
onProgress: ProgressCallback | undefined;
|
|
61
|
+
warnings: string[];
|
|
62
|
+
platform?: DismissPlatform;
|
|
63
|
+
probe?: typeof tryDismissLaunchErrorsDialog;
|
|
64
|
+
abortSignal?: AbortSignal;
|
|
65
|
+
/**
|
|
66
|
+
* Grace window (ms) after polling starts: if no dialog has been
|
|
67
|
+
* observed within this window, exit early. Test override only —
|
|
68
|
+
* production callers do not configure this.
|
|
69
|
+
*
|
|
70
|
+
* @see PollAndDismissOptions.noDialogGraceMs for the production
|
|
71
|
+
* default and rationale.
|
|
72
|
+
*/
|
|
73
|
+
noDialogGraceMs?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Poll the OS desktop for the Unity "compile errors at launch"
|
|
77
|
+
* dialog and click `Ignore` (or the platform-equivalent) every time
|
|
78
|
+
* the probe reports it as found. Returns once the abort signal has
|
|
79
|
+
* fired, the no-dialog grace window has elapsed, the overall timeout
|
|
80
|
+
* has elapsed, or a permanent platform error has been observed.
|
|
81
|
+
*
|
|
82
|
+
* Re-entrant dismissals are supported: when the dialog re-appears
|
|
83
|
+
* after a successful click (the resolver-fix → dialog-reappears
|
|
84
|
+
* cycle described in the issue), each subsequent dismissal emits its
|
|
85
|
+
* own `launch-errors-dismissed` progress event so the user sees the
|
|
86
|
+
* recurrence in the log.
|
|
87
|
+
*
|
|
88
|
+
* Library-safe: never throws. Transient platform errors (e.g. a
|
|
89
|
+
* missing `xdotool` on Linux, or a momentary syscall failure on
|
|
90
|
+
* Windows) are recorded once as a warning on the supplied
|
|
91
|
+
* `warnings` array; subsequent identical errors are silently
|
|
92
|
+
* suppressed so the warnings array does not balloon over the polling
|
|
93
|
+
* window. Permanent errors (e.g. xdotool truly absent) bail out of
|
|
94
|
+
* the loop after the first occurrence so the helper does not spawn
|
|
95
|
+
* 60 doomed tool invocations on a 30s budget.
|
|
96
|
+
*/
|
|
97
|
+
export declare function _pollAndDismissLaunchErrorsForTests(opts: _PollAndDismissOptionsForTests): Promise<void>;
|