chore(unity): 固定Unity CLI Loop本地包并移除UnitySkills依赖
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
namespace io.github.hatayama.uLoopMCP
|
||||
{
|
||||
/// <summary>
|
||||
/// Compile error or warning information
|
||||
/// </summary>
|
||||
public class CompileIssue
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public string File { get; set; }
|
||||
public int Line { get; set; }
|
||||
|
||||
public CompileIssue(string message, string file, int line)
|
||||
{
|
||||
Message = message;
|
||||
File = file;
|
||||
Line = line;
|
||||
}
|
||||
|
||||
public CompileIssue() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Response schema for Compile command
|
||||
/// Provides type-safe response structure
|
||||
/// </summary>
|
||||
public class CompileResponse : BaseToolResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether compilation was successful.
|
||||
/// Null is used when the tool cannot reliably determine the result yet (e.g., forced recompile/domain reload),
|
||||
/// to avoid misleading clients into treating "0 errors" as a confirmed success.
|
||||
/// </summary>
|
||||
public bool? Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of compilation errors.
|
||||
/// Null is used when the tool intentionally does not provide details (e.g., forced recompile),
|
||||
/// because Unity reports errors/warnings after domain reload and clients should fetch logs later.
|
||||
/// </summary>
|
||||
public int? ErrorCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of compilation warnings.
|
||||
/// Null is used when the tool intentionally does not provide details (e.g., forced recompile),
|
||||
/// because Unity reports errors/warnings after domain reload and clients should fetch logs later.
|
||||
/// </summary>
|
||||
public int? WarningCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compilation errors.
|
||||
/// Null is used when the tool intentionally does not provide details (e.g., forced recompile),
|
||||
/// because Unity reports errors/warnings after domain reload and clients should fetch logs later.
|
||||
/// </summary>
|
||||
public CompileIssue[] Errors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compilation warnings.
|
||||
/// Null is used when the tool intentionally does not provide details (e.g., forced recompile),
|
||||
/// because Unity reports errors/warnings after domain reload and clients should fetch logs later.
|
||||
/// </summary>
|
||||
public CompileIssue[] Warnings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional message for additional information
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unity project root path (from Application.dataPath).
|
||||
/// Set only when WaitForDomainReload=true so that TS/CLI can locate lock files
|
||||
/// in the correct project even when connected to a remote Unity instance.
|
||||
/// </summary>
|
||||
public string ProjectRoot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CompileResponse
|
||||
/// </summary>
|
||||
public CompileResponse(
|
||||
bool? success,
|
||||
int? errorCount,
|
||||
int? warningCount,
|
||||
CompileIssue[] errors,
|
||||
CompileIssue[] warnings,
|
||||
string message = null
|
||||
)
|
||||
{
|
||||
Success = success;
|
||||
ErrorCount = errorCount;
|
||||
WarningCount = warningCount;
|
||||
Errors = errors;
|
||||
Warnings = warnings;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor for JSON deserialization
|
||||
/// </summary>
|
||||
public CompileResponse()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56090f2379ae3428bbe733a4db41e344
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace io.github.hatayama.uLoopMCP
|
||||
{
|
||||
/// <summary>
|
||||
/// Schema for Compile command parameters
|
||||
/// Provides type-safe parameter access with default values
|
||||
/// </summary>
|
||||
public class CompileSchema : BaseToolSchema
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether to perform forced recompilation
|
||||
/// </summary>
|
||||
[Description("Whether to perform forced recompilation. Note: Force compilation results do not include error/warning messages in the response. Use get-logs tool after execution to retrieve compilation messages.")]
|
||||
public bool ForceRecompile { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to wait for domain reload completion before the caller returns.
|
||||
/// </summary>
|
||||
[Description("Whether to wait for domain reload completion before returning.")]
|
||||
public bool WaitForDomainReload { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Internal request identifier used for delayed result recovery across domain reload.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string RequestId { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2581c0d32a90546fd9978a2f938e2f6f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace io.github.hatayama.uLoopMCP
|
||||
{
|
||||
/// <summary>
|
||||
/// Compile tool handler - Type-safe implementation using Schema and Response
|
||||
/// Handles Unity project compilation with optional force recompile
|
||||
/// Related classes: CompileUseCase, CompilationStateValidationService, CompilationExecutionService
|
||||
/// </summary>
|
||||
[McpTool(Description = "Execute Unity project compilation")]
|
||||
public class CompileTool : AbstractUnityTool<CompileSchema, CompileResponse>
|
||||
{
|
||||
public override string ToolName => "compile";
|
||||
|
||||
/// <summary>
|
||||
/// Execute compile tool - delegates to CompileUseCase
|
||||
/// </summary>
|
||||
/// <param name="parameters">Type-safe parameters</param>
|
||||
/// <param name="cancellationToken">Cancellation token for timeout control</param>
|
||||
/// <returns>Compile result</returns>
|
||||
protected override async Task<CompileResponse> ExecuteAsync(CompileSchema parameters, CancellationToken cancellationToken)
|
||||
{
|
||||
// Create and execute CompileUseCase instance
|
||||
CompileUseCase useCase = new();
|
||||
return await useCase.ExecuteAsync(parameters, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60e9cabfcc7d047cbab5dfd6e9b06904
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1186b025586e04dd794dace399e9ce35
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
name: uloop-compile
|
||||
description: "Compile the Unity project and report errors/warnings. Use after C# edits or when a full Domain Reload compile is needed."
|
||||
---
|
||||
|
||||
# uloop compile
|
||||
|
||||
Execute Unity project compilation.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
uloop compile [--force-recompile] [--wait-for-domain-reload]
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-----------|------|---------|-------------|
|
||||
| `--force-recompile` | boolean | `false` | Force full recompilation (triggers Domain Reload) |
|
||||
| `--wait-for-domain-reload` | boolean | `false` | Wait until Domain Reload completes before returning |
|
||||
|
||||
## Global Options
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `--project-path <path>` | Optional. Use only when the target Unity project is not the current directory. |
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
# Check compilation
|
||||
uloop compile
|
||||
|
||||
# Force full recompilation
|
||||
uloop compile --force-recompile
|
||||
|
||||
# Force recompilation and wait for Domain Reload completion
|
||||
uloop compile --force-recompile true --wait-for-domain-reload true
|
||||
|
||||
# Wait for Domain Reload completion even without force recompilation
|
||||
uloop compile --force-recompile false --wait-for-domain-reload true
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Returns JSON:
|
||||
- `Success`: boolean
|
||||
- `ErrorCount`: number
|
||||
- `WarningCount`: number
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Diagnose the failure mode before retrying.
|
||||
|
||||
**Stale lock files** (CLI hangs or shows "Unity is busy" while Unity Editor *is* running):
|
||||
|
||||
```bash
|
||||
uloop fix
|
||||
```
|
||||
|
||||
This removes any leftover lock files (`compiling.lock`, `domainreload.lock`, `serverstarting.lock`) from the Unity project's Temp directory. Then retry `uloop compile`.
|
||||
|
||||
**Unity Editor not running** (CLI returns a connection failure and no Unity process is alive):
|
||||
|
||||
```bash
|
||||
uloop launch
|
||||
```
|
||||
|
||||
`uloop launch` auto-detects the project at the current working directory and opens it in the matching Unity Editor version. After Unity finishes launching, retry `uloop compile`.
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e7fbf71d98ab425486f6bd68b7a6612
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user