chore(unity): 固定Unity CLI Loop本地包并移除UnitySkills依赖

This commit is contained in:
Liubing\LB
2026-09-28 18:14:59 +08:00
parent 0eb43b2b40
commit c4ae02def9
952 changed files with 70137 additions and 11 deletions

View File

@@ -0,0 +1,63 @@
using System;
namespace io.github.hatayama.uLoopMCP
{
internal static class JsonRpcRequestIdentityValidator
{
internal const string ServerSessionChangedMessage = "Unity CLI Loop server session changed. Retry the command.";
public static void Validate(
JsonRpcRequestUloopMetadata metadata,
string actualProjectRoot,
string actualServerSessionId)
{
if (metadata == null)
{
return;
}
if (string.IsNullOrWhiteSpace(metadata.ExpectedProjectRoot))
{
throw new ParameterValidationException("Invalid x-uloop metadata: expectedProjectRoot is required.");
}
if (string.IsNullOrWhiteSpace(metadata.ExpectedServerSessionId))
{
throw new ParameterValidationException("Invalid x-uloop metadata: expectedServerSessionId is required.");
}
if (string.IsNullOrWhiteSpace(actualProjectRoot))
{
throw new ParameterValidationException("Fast project validation is unavailable. Restart Unity CLI Loop and retry.");
}
if (string.IsNullOrWhiteSpace(actualServerSessionId))
{
throw new ParameterValidationException(ServerSessionChangedMessage);
}
if (!string.Equals(metadata.ExpectedProjectRoot, actualProjectRoot, StringComparison.Ordinal))
{
throw new ParameterValidationException("Connected Unity instance belongs to a different project.");
}
if (!string.Equals(metadata.ExpectedServerSessionId, actualServerSessionId, StringComparison.Ordinal))
{
throw new ParameterValidationException(ServerSessionChangedMessage);
}
}
internal static bool IsExpectedRetryableFailure(ParameterValidationException exception)
{
if (exception == null)
{
return false;
}
return string.Equals(
exception.Message,
ServerSessionChangedMessage,
StringComparison.Ordinal);
}
}
}