@akiojin/unity-mcp-server 2.14.16 → 2.16.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/LICENSE +0 -0
- package/README.md +0 -0
- package/package.json +1 -1
- package/src/core/codeIndex.js +0 -0
- package/src/core/codeIndexDb.js +0 -0
- package/src/core/config.js +45 -1
- package/src/core/indexWatcher.js +0 -0
- package/src/core/projectInfo.js +0 -0
- package/src/core/unityConnection.js +3 -2
- package/src/handlers/analysis/AnalyzeSceneContentsToolHandler.js +0 -0
- package/src/handlers/analysis/FindByComponentToolHandler.js +0 -0
- package/src/handlers/analysis/GetAnimatorStateToolHandler.js +0 -0
- package/src/handlers/analysis/GetComponentValuesToolHandler.js +0 -0
- package/src/handlers/analysis/GetGameObjectDetailsToolHandler.js +0 -0
- package/src/handlers/analysis/GetInputActionsStateToolHandler.js +0 -0
- package/src/handlers/analysis/GetObjectReferencesToolHandler.js +0 -0
- package/src/handlers/asset/AssetDatabaseToolHandler.js +0 -0
- package/src/handlers/asset/AssetDependencyToolHandler.js +0 -0
- package/src/handlers/asset/AssetImportSettingsToolHandler.js +0 -0
- package/src/handlers/asset/CreateMaterialToolHandler.js +0 -0
- package/src/handlers/asset/CreatePrefabToolHandler.js +0 -0
- package/src/handlers/asset/ExitPrefabModeToolHandler.js +0 -0
- package/src/handlers/asset/InstantiatePrefabToolHandler.js +0 -0
- package/src/handlers/asset/ModifyMaterialToolHandler.js +0 -0
- package/src/handlers/asset/ModifyPrefabToolHandler.js +0 -0
- package/src/handlers/asset/OpenPrefabToolHandler.js +0 -0
- package/src/handlers/asset/SavePrefabToolHandler.js +0 -0
- package/src/handlers/base/BaseToolHandler.js +71 -1
- package/src/handlers/compilation/GetCompilationStateToolHandler.js +0 -0
- package/src/handlers/component/AddComponentToolHandler.js +0 -0
- package/src/handlers/component/GetComponentTypesToolHandler.js +0 -0
- package/src/handlers/component/ListComponentsToolHandler.js +0 -0
- package/src/handlers/component/ModifyComponentToolHandler.js +0 -0
- package/src/handlers/component/RemoveComponentToolHandler.js +0 -0
- package/src/handlers/console/ClearConsoleToolHandler.js +0 -0
- package/src/handlers/console/ReadConsoleToolHandler.js +0 -0
- package/src/handlers/editor/LayerManagementToolHandler.js +0 -0
- package/src/handlers/editor/SelectionToolHandler.js +0 -0
- package/src/handlers/editor/TagManagementToolHandler.js +0 -0
- package/src/handlers/editor/ToolManagementToolHandler.js +0 -0
- package/src/handlers/editor/WindowManagementToolHandler.js +0 -0
- package/src/handlers/gameobject/CreateGameObjectToolHandler.js +0 -0
- package/src/handlers/gameobject/DeleteGameObjectToolHandler.js +0 -0
- package/src/handlers/gameobject/FindGameObjectToolHandler.js +0 -0
- package/src/handlers/gameobject/GetHierarchyToolHandler.js +0 -0
- package/src/handlers/gameobject/ModifyGameObjectToolHandler.js +0 -0
- package/src/handlers/index.js +11 -1
- package/src/handlers/input/AddInputActionToolHandler.js +0 -0
- package/src/handlers/input/AddInputBindingToolHandler.js +0 -0
- package/src/handlers/input/CreateActionMapToolHandler.js +0 -0
- package/src/handlers/input/CreateCompositeBindingToolHandler.js +0 -0
- package/src/handlers/input/GamepadSimulationHandler.js +0 -0
- package/src/handlers/input/InputSystemHandler.js +0 -0
- package/src/handlers/input/KeyboardSimulationHandler.js +0 -0
- package/src/handlers/input/ManageControlSchemesToolHandler.js +0 -0
- package/src/handlers/input/MouseSimulationHandler.js +0 -0
- package/src/handlers/input/RemoveActionMapToolHandler.js +0 -0
- package/src/handlers/input/RemoveAllBindingsToolHandler.js +0 -0
- package/src/handlers/input/RemoveInputActionToolHandler.js +0 -0
- package/src/handlers/input/RemoveInputBindingToolHandler.js +0 -0
- package/src/handlers/input/TouchSimulationHandler.js +0 -0
- package/src/handlers/menu/ExecuteMenuItemToolHandler.js +0 -0
- package/src/handlers/package/PackageManagerToolHandler.js +0 -0
- package/src/handlers/package/RegistryConfigToolHandler.js +0 -0
- package/src/handlers/playmode/GetEditorStateToolHandler.js +0 -0
- package/src/handlers/playmode/PauseToolHandler.js +0 -0
- package/src/handlers/playmode/PlayToolHandler.js +0 -0
- package/src/handlers/playmode/StopToolHandler.js +0 -0
- package/src/handlers/playmode/WaitForEditorStateToolHandler.js +0 -0
- package/src/handlers/scene/CreateSceneToolHandler.js +0 -0
- package/src/handlers/scene/GetSceneInfoToolHandler.js +0 -0
- package/src/handlers/scene/ListScenesToolHandler.js +0 -0
- package/src/handlers/scene/LoadSceneToolHandler.js +0 -0
- package/src/handlers/scene/SaveSceneToolHandler.js +0 -0
- package/src/handlers/screenshot/AnalyzeScreenshotToolHandler.js +0 -0
- package/src/handlers/screenshot/CaptureScreenshotToolHandler.js +0 -0
- package/src/handlers/script/BuildCodeIndexToolHandler.js +0 -0
- package/src/handlers/script/ScriptCreateClassFileToolHandler.js +0 -0
- package/src/handlers/script/ScriptEditStructuredToolHandler.js +0 -0
- package/src/handlers/script/ScriptIndexStatusToolHandler.js +0 -0
- package/src/handlers/script/ScriptPackagesListToolHandler.js +0 -0
- package/src/handlers/script/ScriptReadToolHandler.js +0 -0
- package/src/handlers/script/ScriptRefactorRenameToolHandler.js +0 -0
- package/src/handlers/script/ScriptRefsFindToolHandler.js +0 -0
- package/src/handlers/script/ScriptRemoveSymbolToolHandler.js +0 -0
- package/src/handlers/script/ScriptSearchToolHandler.js +0 -0
- package/src/handlers/script/ScriptSymbolFindToolHandler.js +0 -0
- package/src/handlers/script/ScriptSymbolsGetToolHandler.js +0 -0
- package/src/handlers/settings/GetProjectSettingsToolHandler.js +0 -0
- package/src/handlers/settings/UpdateProjectSettingsToolHandler.js +0 -0
- package/src/handlers/system/GetCommandStatsToolHandler.js +0 -0
- package/src/handlers/system/PingToolHandler.js +0 -0
- package/src/handlers/system/RefreshAssetsToolHandler.js +0 -0
- package/src/handlers/test/GetTestStatusToolHandler.js +79 -0
- package/src/handlers/test/RunTestsToolHandler.js +153 -0
- package/src/handlers/ui/ClickUIElementToolHandler.js +0 -0
- package/src/handlers/ui/FindUIElementsToolHandler.js +0 -0
- package/src/handlers/ui/GetUIElementStateToolHandler.js +0 -0
- package/src/handlers/ui/SetUIElementValueToolHandler.js +10 -2
- package/src/handlers/ui/SimulateUIInputToolHandler.js +0 -0
- package/src/handlers/video/CaptureVideoForToolHandler.js +0 -0
- package/src/handlers/video/CaptureVideoStartToolHandler.js +0 -0
- package/src/handlers/video/CaptureVideoStatusToolHandler.js +0 -0
- package/src/handlers/video/CaptureVideoStopToolHandler.js +0 -0
- package/src/lsp/CSharpLspUtils.js +0 -0
- package/src/lsp/LspProcessManager.js +0 -0
- package/src/lsp/LspRpcClient.js +0 -0
- package/src/tools/analysis/analyzeSceneContents.js +0 -0
- package/src/tools/analysis/findByComponent.js +0 -0
- package/src/tools/analysis/getAnimatorState.js +0 -0
- package/src/tools/analysis/getComponentValues.js +0 -0
- package/src/tools/analysis/getGameObjectDetails.js +0 -0
- package/src/tools/analysis/getInputActionsState.js +0 -0
- package/src/tools/analysis/getObjectReferences.js +0 -0
- package/src/tools/input/inputActionsEditor.js +0 -0
- package/src/tools/scene/createScene.js +0 -0
- package/src/tools/scene/getSceneInfo.js +0 -0
- package/src/tools/scene/listScenes.js +0 -0
- package/src/tools/scene/loadScene.js +0 -0
- package/src/tools/scene/saveScene.js +0 -0
- package/src/tools/system/ping.js +0 -0
- package/src/tools/video/recordFor.js +0 -0
- package/src/tools/video/recordPlayMode.js +0 -0
- package/src/utils/csharpParse.js +0 -0
- package/src/utils/validators.js +0 -0
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/core/codeIndex.js
CHANGED
|
File without changes
|
package/src/core/codeIndexDb.js
CHANGED
|
File without changes
|
package/src/core/config.js
CHANGED
|
@@ -19,10 +19,26 @@ function merge(a, b) {
|
|
|
19
19
|
/**
|
|
20
20
|
* Base configuration for Unity Editor MCP Server
|
|
21
21
|
*/
|
|
22
|
+
const envUnityHost =
|
|
23
|
+
process.env.UNITY_UNITY_HOST ||
|
|
24
|
+
process.env.UNITY_BIND_HOST ||
|
|
25
|
+
process.env.UNITY_HOST ||
|
|
26
|
+
null;
|
|
27
|
+
|
|
28
|
+
const envMcpHost =
|
|
29
|
+
process.env.UNITY_MCP_HOST ||
|
|
30
|
+
process.env.UNITY_CLIENT_HOST ||
|
|
31
|
+
process.env.UNITY_HOST ||
|
|
32
|
+
null;
|
|
33
|
+
|
|
34
|
+
const envBindHost = process.env.UNITY_BIND_HOST || null;
|
|
35
|
+
|
|
22
36
|
const baseConfig = {
|
|
23
37
|
// Unity connection settings
|
|
24
38
|
unity: {
|
|
25
|
-
|
|
39
|
+
unityHost: envUnityHost,
|
|
40
|
+
mcpHost: envMcpHost,
|
|
41
|
+
bindHost: envBindHost,
|
|
26
42
|
port: parseInt(process.env.UNITY_PORT || '', 10) || 6400,
|
|
27
43
|
reconnectDelay: 1000,
|
|
28
44
|
maxReconnectDelay: 30000,
|
|
@@ -118,6 +134,34 @@ function loadExternalConfig() {
|
|
|
118
134
|
const external = loadExternalConfig();
|
|
119
135
|
export const config = merge(baseConfig, external);
|
|
120
136
|
|
|
137
|
+
const normalizeUnityConfig = () => {
|
|
138
|
+
const unityConfig = config.unity || (config.unity = {});
|
|
139
|
+
|
|
140
|
+
// Legacy aliases coming from config files or env vars
|
|
141
|
+
const legacyHost = unityConfig.host;
|
|
142
|
+
const legacyClientHost = unityConfig.clientHost;
|
|
143
|
+
const legacyBindHost = unityConfig.bindHost;
|
|
144
|
+
|
|
145
|
+
if (!unityConfig.unityHost) {
|
|
146
|
+
unityConfig.unityHost = legacyBindHost || legacyHost || envUnityHost || 'localhost';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!unityConfig.mcpHost) {
|
|
150
|
+
unityConfig.mcpHost = legacyClientHost || envMcpHost || legacyHost || unityConfig.unityHost;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Keep bindHost for backwards compatibility with legacy code paths
|
|
154
|
+
if (!unityConfig.bindHost) {
|
|
155
|
+
unityConfig.bindHost = legacyBindHost || envBindHost || unityConfig.unityHost;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Maintain legacy properties so older handlers keep working
|
|
159
|
+
unityConfig.host = unityConfig.unityHost;
|
|
160
|
+
unityConfig.clientHost = unityConfig.mcpHost;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
normalizeUnityConfig();
|
|
164
|
+
|
|
121
165
|
// Workspace root detection: directory that contains .unity/config.json used
|
|
122
166
|
const initialCwd = process.cwd();
|
|
123
167
|
let workspaceRoot = initialCwd;
|
package/src/core/indexWatcher.js
CHANGED
|
File without changes
|
package/src/core/projectInfo.js
CHANGED
|
File without changes
|
|
@@ -40,7 +40,8 @@ export class UnityConnection extends EventEmitter {
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const targetHost = config.unity.mcpHost || config.unity.unityHost;
|
|
44
|
+
logger.info(`Connecting to Unity at ${targetHost}:${config.unity.port}...`);
|
|
44
45
|
|
|
45
46
|
this.socket = new net.Socket();
|
|
46
47
|
let connectionTimeout = null;
|
|
@@ -118,7 +119,7 @@ export class UnityConnection extends EventEmitter {
|
|
|
118
119
|
});
|
|
119
120
|
|
|
120
121
|
// Attempt connection
|
|
121
|
-
this.socket.connect(config.unity.port,
|
|
122
|
+
this.socket.connect(config.unity.port, targetHost);
|
|
122
123
|
|
|
123
124
|
// Set timeout for initial connection
|
|
124
125
|
connectionTimeout = setTimeout(() => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,11 +4,81 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { logger } from '../../core/config.js';
|
|
6
6
|
|
|
7
|
+
function cloneSchema(schema) {
|
|
8
|
+
if (!schema || typeof schema !== 'object') {
|
|
9
|
+
return schema;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (typeof structuredClone === 'function') {
|
|
13
|
+
return structuredClone(schema);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(JSON.stringify(schema));
|
|
18
|
+
} catch {
|
|
19
|
+
return schema;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function sanitizeSchema(schema) {
|
|
24
|
+
if (!schema) {
|
|
25
|
+
return schema;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (Array.isArray(schema)) {
|
|
29
|
+
schema.forEach(item => sanitizeSchema(item));
|
|
30
|
+
return schema;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (typeof schema !== 'object') {
|
|
34
|
+
return schema;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (Array.isArray(schema.required) && schema.required.length === 0) {
|
|
38
|
+
delete schema.required;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (schema.properties && typeof schema.properties === 'object') {
|
|
42
|
+
Object.values(schema.properties).forEach(value => sanitizeSchema(value));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (schema.items) {
|
|
46
|
+
sanitizeSchema(schema.items);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (Array.isArray(schema.anyOf)) {
|
|
50
|
+
schema.anyOf.forEach(branch => sanitizeSchema(branch));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (Array.isArray(schema.oneOf)) {
|
|
54
|
+
schema.oneOf.forEach(branch => sanitizeSchema(branch));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (Array.isArray(schema.allOf)) {
|
|
58
|
+
schema.allOf.forEach(branch => sanitizeSchema(branch));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (schema.then) {
|
|
62
|
+
sanitizeSchema(schema.then);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (schema.else) {
|
|
66
|
+
sanitizeSchema(schema.else);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
70
|
+
sanitizeSchema(schema.additionalProperties);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return schema;
|
|
74
|
+
}
|
|
75
|
+
|
|
7
76
|
export class BaseToolHandler {
|
|
8
77
|
constructor(name, description, inputSchema = {}) {
|
|
9
78
|
this.name = name;
|
|
10
79
|
this.description = description;
|
|
11
|
-
|
|
80
|
+
const clonedSchema = cloneSchema(inputSchema) || {};
|
|
81
|
+
this.inputSchema = sanitizeSchema(clonedSchema);
|
|
12
82
|
}
|
|
13
83
|
|
|
14
84
|
/**
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/handlers/index.js
CHANGED
|
@@ -103,6 +103,10 @@ export { GetComponentTypesToolHandler } from './component/GetComponentTypesToolH
|
|
|
103
103
|
// Compilation handlers
|
|
104
104
|
export { GetCompilationStateToolHandler } from './compilation/GetCompilationStateToolHandler.js';
|
|
105
105
|
|
|
106
|
+
// Test handlers
|
|
107
|
+
export { RunTestsToolHandler } from './test/RunTestsToolHandler.js';
|
|
108
|
+
export { GetTestStatusToolHandler } from './test/GetTestStatusToolHandler.js';
|
|
109
|
+
|
|
106
110
|
// Editor control handlers
|
|
107
111
|
export { TagManagementToolHandler } from './editor/TagManagementToolHandler.js';
|
|
108
112
|
export { LayerManagementToolHandler } from './editor/LayerManagementToolHandler.js';
|
|
@@ -204,6 +208,8 @@ import { ModifyComponentToolHandler } from './component/ModifyComponentToolHandl
|
|
|
204
208
|
import { ListComponentsToolHandler } from './component/ListComponentsToolHandler.js';
|
|
205
209
|
import { GetComponentTypesToolHandler } from './component/GetComponentTypesToolHandler.js';
|
|
206
210
|
import { GetCompilationStateToolHandler } from './compilation/GetCompilationStateToolHandler.js';
|
|
211
|
+
import { RunTestsToolHandler } from './test/RunTestsToolHandler.js';
|
|
212
|
+
import { GetTestStatusToolHandler } from './test/GetTestStatusToolHandler.js';
|
|
207
213
|
import { TagManagementToolHandler } from './editor/TagManagementToolHandler.js';
|
|
208
214
|
import { LayerManagementToolHandler } from './editor/LayerManagementToolHandler.js';
|
|
209
215
|
import { SelectionToolHandler } from './editor/SelectionToolHandler.js';
|
|
@@ -341,7 +347,11 @@ const HANDLER_CLASSES = [
|
|
|
341
347
|
|
|
342
348
|
// Compilation handlers
|
|
343
349
|
GetCompilationStateToolHandler,
|
|
344
|
-
|
|
350
|
+
|
|
351
|
+
// Test handlers
|
|
352
|
+
RunTestsToolHandler,
|
|
353
|
+
GetTestStatusToolHandler,
|
|
354
|
+
|
|
345
355
|
// Editor control handlers
|
|
346
356
|
TagManagementToolHandler,
|
|
347
357
|
LayerManagementToolHandler,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handler for getting Unity test execution status
|
|
5
|
+
* Works with non-blocking test execution from RunUnityTestsToolHandler
|
|
6
|
+
*/
|
|
7
|
+
export class GetTestStatusToolHandler extends BaseToolHandler {
|
|
8
|
+
constructor(unityConnection) {
|
|
9
|
+
super(
|
|
10
|
+
'get_test_status',
|
|
11
|
+
'Get current Unity test execution status and results',
|
|
12
|
+
{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {}
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
this.unityConnection = unityConnection;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Gets current test execution status
|
|
23
|
+
* @param {Object} params - The validated input parameters
|
|
24
|
+
* @returns {Promise<Object>} Test execution status and results
|
|
25
|
+
*/
|
|
26
|
+
async execute(params) {
|
|
27
|
+
// Ensure connection to Unity
|
|
28
|
+
if (!this.unityConnection.isConnected()) {
|
|
29
|
+
await this.unityConnection.connect();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Send command to Unity
|
|
33
|
+
const response = await this.unityConnection.sendCommand('get_test_status', params);
|
|
34
|
+
|
|
35
|
+
// Handle Unity response
|
|
36
|
+
if (response.error) {
|
|
37
|
+
throw new Error(response.error);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Return status directly if still running or idle
|
|
41
|
+
if (response.status === 'running' || response.status === 'idle') {
|
|
42
|
+
return response;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Format completed results
|
|
46
|
+
if (response.status === 'completed') {
|
|
47
|
+
const result = {
|
|
48
|
+
status: 'completed',
|
|
49
|
+
success: response.success,
|
|
50
|
+
totalTests: response.totalTests,
|
|
51
|
+
passedTests: response.passedTests,
|
|
52
|
+
failedTests: response.failedTests,
|
|
53
|
+
skippedTests: response.skippedTests,
|
|
54
|
+
inconclusiveTests: response.inconclusiveTests,
|
|
55
|
+
summary: `${response.passedTests}/${response.totalTests} tests passed`,
|
|
56
|
+
failures: response.failures || [],
|
|
57
|
+
tests: response.tests || []
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Error status
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets example usage for this tool
|
|
69
|
+
* @returns {Object} Example usage scenarios
|
|
70
|
+
*/
|
|
71
|
+
getExamples() {
|
|
72
|
+
return {
|
|
73
|
+
checkStatus: {
|
|
74
|
+
description: 'Check current test execution status',
|
|
75
|
+
params: {}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handler for running Unity NUnit tests via Test Runner API
|
|
5
|
+
* Implements SPEC-e7c9b50c: Unity Test Execution Feature
|
|
6
|
+
*/
|
|
7
|
+
export class RunTestsToolHandler extends BaseToolHandler {
|
|
8
|
+
constructor(unityConnection) {
|
|
9
|
+
super(
|
|
10
|
+
'run_tests',
|
|
11
|
+
'Run Unity NUnit tests in the current project',
|
|
12
|
+
{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
testMode: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
enum: ['EditMode', 'PlayMode', 'All'],
|
|
18
|
+
default: 'EditMode',
|
|
19
|
+
description: 'Test mode to run (EditMode: editor tests, PlayMode: runtime tests, All: both)'
|
|
20
|
+
},
|
|
21
|
+
filter: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'Filter tests by class name (e.g., "PlayerControllerTests")'
|
|
24
|
+
},
|
|
25
|
+
category: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Filter tests by category attribute (e.g., "Integration")'
|
|
28
|
+
},
|
|
29
|
+
namespace: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'Filter tests by namespace (e.g., "MyGame.Tests.Player")'
|
|
32
|
+
},
|
|
33
|
+
includeDetails: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
default: false,
|
|
36
|
+
description: 'Include detailed test results for each individual test'
|
|
37
|
+
},
|
|
38
|
+
exportPath: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Export test results to NUnit XML file at specified path'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
this.unityConnection = unityConnection;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Executes Unity tests based on specified parameters
|
|
51
|
+
* @param {Object} params - The validated input parameters
|
|
52
|
+
* @returns {Promise<Object>} Test execution results
|
|
53
|
+
*/
|
|
54
|
+
async execute(params) {
|
|
55
|
+
// Ensure connection to Unity
|
|
56
|
+
if (!this.unityConnection.isConnected()) {
|
|
57
|
+
await this.unityConnection.connect();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Send command to Unity
|
|
61
|
+
const response = await this.unityConnection.sendCommand('run_tests', params);
|
|
62
|
+
|
|
63
|
+
// Handle Unity response
|
|
64
|
+
if (response.error) {
|
|
65
|
+
throw new Error(response.error);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Handle new non-blocking response format (status: "running")
|
|
69
|
+
if (response.status === 'running') {
|
|
70
|
+
return {
|
|
71
|
+
status: 'running',
|
|
72
|
+
message: response.message || 'Test execution started. Use get_test_status to check progress.'
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Legacy format support (for backwards compatibility)
|
|
77
|
+
// Format and return result
|
|
78
|
+
const result = {
|
|
79
|
+
success: response.success,
|
|
80
|
+
totalTests: response.totalTests,
|
|
81
|
+
passedTests: response.passedTests,
|
|
82
|
+
failedTests: response.failedTests,
|
|
83
|
+
skippedTests: response.skippedTests,
|
|
84
|
+
inconclusiveTests: response.inconclusiveTests,
|
|
85
|
+
duration: response.duration,
|
|
86
|
+
summary: `${response.passedTests}/${response.totalTests} tests passed in ${response.duration}s`,
|
|
87
|
+
failures: response.failures || []
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Include detailed test results if requested
|
|
91
|
+
if (params.includeDetails && response.tests) {
|
|
92
|
+
result.tests = response.tests;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Gets example usage for this tool
|
|
100
|
+
* @returns {Object} Example usage scenarios
|
|
101
|
+
*/
|
|
102
|
+
getExamples() {
|
|
103
|
+
return {
|
|
104
|
+
runAllEditModeTests: {
|
|
105
|
+
description: 'Run all Edit Mode tests',
|
|
106
|
+
params: {
|
|
107
|
+
testMode: 'EditMode'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
runSpecificClass: {
|
|
111
|
+
description: 'Run tests in a specific class',
|
|
112
|
+
params: {
|
|
113
|
+
testMode: 'EditMode',
|
|
114
|
+
filter: 'PlayerControllerTests'
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
runCategoryTests: {
|
|
118
|
+
description: 'Run tests in a specific category',
|
|
119
|
+
params: {
|
|
120
|
+
testMode: 'EditMode',
|
|
121
|
+
category: 'Integration'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
runWithDetails: {
|
|
125
|
+
description: 'Run tests with detailed results for each test',
|
|
126
|
+
params: {
|
|
127
|
+
testMode: 'EditMode',
|
|
128
|
+
includeDetails: true
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
runAndExport: {
|
|
132
|
+
description: 'Run tests and export results to XML',
|
|
133
|
+
params: {
|
|
134
|
+
testMode: 'EditMode',
|
|
135
|
+
exportPath: 'TestResults/results.xml'
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
runPlayModeTests: {
|
|
139
|
+
description: 'Run Play Mode tests (requires Play Mode)',
|
|
140
|
+
params: {
|
|
141
|
+
testMode: 'PlayMode'
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
runAllTests: {
|
|
145
|
+
description: 'Run both Edit Mode and Play Mode tests',
|
|
146
|
+
params: {
|
|
147
|
+
testMode: 'All',
|
|
148
|
+
includeDetails: true
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,7 +13,15 @@ export class SetUIElementValueToolHandler extends BaseToolHandler {
|
|
|
13
13
|
description: 'Full hierarchy path to the UI element'
|
|
14
14
|
},
|
|
15
15
|
value: {
|
|
16
|
-
|
|
16
|
+
anyOf: [
|
|
17
|
+
{ type: 'string' },
|
|
18
|
+
{ type: 'number' },
|
|
19
|
+
{ type: 'boolean' },
|
|
20
|
+
{ type: 'object' },
|
|
21
|
+
{ type: 'array' },
|
|
22
|
+
{ type: 'null' }
|
|
23
|
+
],
|
|
24
|
+
description: 'New value to set. Supports string, number, boolean, object, array, or null depending on the UI element type.'
|
|
17
25
|
},
|
|
18
26
|
triggerEvents: {
|
|
19
27
|
type: 'boolean',
|
|
@@ -46,4 +54,4 @@ export class SetUIElementValueToolHandler extends BaseToolHandler {
|
|
|
46
54
|
|
|
47
55
|
return result;
|
|
48
56
|
}
|
|
49
|
-
}
|
|
57
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/lsp/LspRpcClient.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/tools/system/ping.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/utils/csharpParse.js
CHANGED
|
File without changes
|
package/src/utils/validators.js
CHANGED
|
File without changes
|