using System; using System.Collections.Generic; using Codely.Newtonsoft.Json.Linq; namespace UnityTcp.Editor.Tools { /// /// Registry for all Unity Tool command handlers (Upgraded Version) /// public static class CommandRegistry { // Maps command names to the corresponding static HandleCommand method in tool classes private static readonly Dictionary> _handlers = new() { // Core tools { "HandleManageScript", ManageScript.HandleCommand }, { "HandleManageScene", ManageScene.HandleCommand }, { "HandleManageEditor", ManageEditor.HandleCommand }, { "HandleManageGameObject", ManageGameObject.HandleCommand }, { "HandleManageAsset", ManageAsset.HandleCommand }, { "HandleReadConsole", ReadConsole.HandleCommand }, { "HandleExecuteMenuItem", ExecuteMenuItem.HandleCommand }, { "HandleManageShader", ManageShader.HandleCommand}, { "HandleManageScreenshot", ManageScreenshot.HandleCommand }, // [EXPERIMENTAL] Phase 3 tools { "HandleManagePackage", ManagePackage.HandleCommand }, { "HandleManageBake", ManageBake.HandleCommand }, { "HandleManageUIToolkit", ManageUIToolkit.HandleCommand }, // Custom tool execution (API Spec aligned) { "HandleExecuteCustomTool", ExecuteCustomTool.HandleCommand }, { "HandleExecuteCSharpScript", ExecuteCSharpScript.HandleCommand }, // [INTERNAL] Not exposed to LLM - for agent execution layer only { "Handle_InternalStateDirty", _InternalStateDirtyNotifier.HandleCommand }, }; /// /// Gets a command handler by name. /// /// Name of the command handler (e.g., "HandleManageAsset"). /// The command handler function if found, null otherwise. public static Func GetHandler(string commandName) { // Use case-insensitive comparison for flexibility, although Python side should be consistent return _handlers.TryGetValue(commandName, out var handler) ? handler : null; // Consider adding logging here if a handler is not found /* if (_handlers.TryGetValue(commandName, out var handler)) { return handler; } else { UnityEngine.Debug.LogError($\"[CommandRegistry] No handler found for command: {commandName}\"); return null; } */ } } }