@kevlns/u-cli-mod 0.1.1 → 0.1.3
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/AGENTS.md +6 -5
- package/README.md +12 -10
- package/dist/consolePatch.d.ts +2 -0
- package/dist/consolePatch.js +370 -0
- package/dist/transform.js +4 -0
- package/package.json +1 -1
- package/routes/2022.3.59f1c1.json +2 -2
- package/routes/2022.3.62f3c1.json +3 -3
- package/routes/expected-tree/2022.3.59f1c1.json +2 -2
- package/routes/expected-tree/2022.3.62f3c1.json +2 -2
- package/v-cli.plugin.json +4 -3
package/AGENTS.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
- `u-cli-mod pipeline install <project> --dry-run` - 安装预览(不写入工程)
|
|
15
15
|
- `u-cli-mod pipeline install <project>` - 事务式安装适配包(自动备份/回滚/receipt)
|
|
16
16
|
- `u-cli-mod exec <project> -- <pipeline-args>` - 执行 Pipeline 命令(工具统一绑定 `--project-path`)
|
|
17
|
-
- Pipeline 命令全集见文末「Pipeline 工具清单」(适配版 `com.unity.pipeline` 共
|
|
17
|
+
- Pipeline 命令全集见文末「Pipeline 工具清单」(适配版 `com.unity.pipeline` 共 154 个命令,按领域分组)
|
|
18
18
|
- `u-cli-mod routes` / `u-cli-mod cache clean` - 路由表 / 缓存清理
|
|
19
19
|
|
|
20
20
|
## 使用规范(Agent 必须遵守)
|
|
@@ -36,7 +36,7 @@ u-cli-mod exec <project> -- command editor_status # 3. 执行
|
|
|
36
36
|
|
|
37
37
|
## Pipeline 工具清单
|
|
38
38
|
|
|
39
|
-
> 安装的 `com.unity.pipeline`(适配版 0.5.0-exp.1)共 **
|
|
39
|
+
> 安装的 `com.unity.pipeline`(适配版 0.5.0-exp.1)共 **154** 个命令,经 `u-cli-mod exec <project> -- command <名> [参数]` 透传执行;参数全集以 `exec <project> -- command <名> --help` 为准。
|
|
40
40
|
|
|
41
41
|
### GameObject / 组件
|
|
42
42
|
- `add_component` — Add a component (by type name) to a GameObject.
|
|
@@ -186,9 +186,10 @@ u-cli-mod exec <project> -- command editor_status # 3. 执行
|
|
|
186
186
|
### 可观测性 / 审计
|
|
187
187
|
- `audit` — Run a Project Auditor static-analysis scan. Returns immediately; poll audit_status until status is 'completed', then read the CSV.
|
|
188
188
|
- `audit_status` — Get the status of the last audit: idle | scanning | completed | failed | interrupted | unavailable.
|
|
189
|
-
- `clear_console` — Clear the
|
|
189
|
+
- `clear_console` — Clear the Unity Editor Console and all captured pipeline console buffers.
|
|
190
190
|
- `console` — Get captured Unity console output (Editor or Player; supports tail, level filtering, and follow via a cursor)
|
|
191
|
-
- `get_console_logs` — Read
|
|
191
|
+
- `get_console_logs` — Read the current Unity Editor Console (compatibility alias for read_console).
|
|
192
|
+
- `read_console` — Read or clear the current Unity Editor Console, including entries emitted before command initialization; supports type/text filtering, paging, formatting, and stack traces.
|
|
192
193
|
- `get_performance_stats` — Read render, memory, and frame-timing stats (structured, read-only).
|
|
193
194
|
- `log` — Write a message to Unity console
|
|
194
195
|
|
|
@@ -225,4 +226,4 @@ u-cli-mod exec <project> -- command editor_status # 3. 执行
|
|
|
225
226
|
|
|
226
227
|
### Authoring 根路径
|
|
227
228
|
- `get_authoring_root` — Get the base folder (under Assets/) that bare authoring paths resolve against.
|
|
228
|
-
- `set_authoring_root` — Set the base folder (under Assets/) that bare authoring paths resolve against and are confined to. Use 'Assets' for full project access.
|
|
229
|
+
- `set_authoring_root` — Set the base folder (under Assets/) that bare authoring paths resolve against and are confined to. Use 'Assets' for full project access.
|
package/README.md
CHANGED
|
@@ -52,9 +52,11 @@ u-cli-mod routes # 列出支持的 Editor 路由
|
|
|
52
52
|
|
|
53
53
|
## Usage
|
|
54
54
|
|
|
55
|
+
> 示例中的 `<project>` 指代你的 Unity 工程目录,请替换为实际路径。
|
|
56
|
+
|
|
55
57
|
```bash
|
|
56
58
|
# 只读检查工程与路由
|
|
57
|
-
u-cli-mod doctor
|
|
59
|
+
u-cli-mod doctor <project>
|
|
58
60
|
|
|
59
61
|
# 列出支持的 Editor 路由
|
|
60
62
|
u-cli-mod routes
|
|
@@ -63,17 +65,17 @@ u-cli-mod routes
|
|
|
63
65
|
u-cli-mod cli install
|
|
64
66
|
|
|
65
67
|
# 预览 Pipeline 安装(不写入)
|
|
66
|
-
u-cli-mod pipeline install
|
|
68
|
+
u-cli-mod pipeline install <project> --dry-run
|
|
67
69
|
|
|
68
70
|
# 正式安装(先关闭目标工程的 Unity Editor)
|
|
69
|
-
u-cli-mod pipeline install
|
|
71
|
+
u-cli-mod pipeline install <project>
|
|
70
72
|
|
|
71
73
|
# CLI + Pipeline 一键准备
|
|
72
|
-
u-cli-mod setup
|
|
74
|
+
u-cli-mod setup <project>
|
|
73
75
|
|
|
74
76
|
# 执行 Unity Pipeline 命令(自动绑定目标工程)
|
|
75
|
-
u-cli-mod exec
|
|
76
|
-
u-cli-mod exec
|
|
77
|
+
u-cli-mod exec <project> -- command editor_status
|
|
78
|
+
u-cli-mod exec <project> -- command get_scene_hierarchy
|
|
77
79
|
|
|
78
80
|
# 清理缓存
|
|
79
81
|
u-cli-mod cache clean
|
|
@@ -109,7 +111,7 @@ npm run check # build + lint + 110 个 vitest 测试 + pack guard
|
|
|
109
111
|
|
|
110
112
|
`pack:guard` 会执行真实 `npm pack`(含文件清单校验),断言发布包:
|
|
111
113
|
|
|
112
|
-
- 包名为 `@kevlns/u-cli-mod`,tgz 文件名精确为 `kevlns-u-cli-mod-0.1.
|
|
114
|
+
- 包名为 `@kevlns/u-cli-mod`,tgz 文件名精确为 `kevlns-u-cli-mod-0.1.2.tgz`(与 package.json 版本一致);
|
|
113
115
|
- `files` 必须包含 `v-cli.plugin.json`,且清单身份字段(schemaVersion/package/command/bin/platforms)与包一致;
|
|
114
116
|
- 不出现:
|
|
115
117
|
|
|
@@ -129,7 +131,7 @@ npm run check # build + lint + 110 个 vitest 测试 + pack guard
|
|
|
129
131
|
npm run test:package
|
|
130
132
|
```
|
|
131
133
|
|
|
132
|
-
构建真实 tgz,并在本地验证三种消费方式:工程 devDependency(`node_modules/.bin`)、带临时 `--prefix` 的全局安装、`npx --package <本地tgz>`;每种都执行 `u-cli-mod --version` 与 `u-cli-mod routes`。**不会**向任何 registry
|
|
134
|
+
构建真实 tgz,并在本地验证三种消费方式:工程 devDependency(`node_modules/.bin`)、带临时 `--prefix` 的全局安装、`npx --package <本地tgz>`;每种都执行 `u-cli-mod --version` 与 `u-cli-mod routes`。**不会**向任何 registry 发布。报告:`<临时目录>/u-cli-mod-package-test-report.json`(可用 `EPC_PKG_REPORT` 覆盖)。
|
|
133
135
|
|
|
134
136
|
### 自托管 Runner 与 Unity E2E
|
|
135
137
|
|
|
@@ -139,7 +141,7 @@ npm run e2e:windows # 完整 Unity E2E(真实下载/转换/编译/命
|
|
|
139
141
|
```
|
|
140
142
|
|
|
141
143
|
- `preflight:runner` 只读,不下载/注册 Runner;结果 JSON 输出到 stdout。
|
|
142
|
-
- `e2e:windows` 使用**隔离缓存**(干净环境)或显式复用已验证缓存,创建
|
|
144
|
+
- `e2e:windows` 使用**隔离缓存**(干净环境)或显式复用已验证缓存,创建 `<临时目录>/u-cli-mod-e2e/` 下独立临时工程,全部结束后杀掉它启动的所有 Unity 进程并清理临时工程;报告写入 `<临时目录>/u-cli-mod-e2e-report.json`(分别可用 `EPC_E2E_ROOT`、`EPC_E2E_REPORT` 覆盖)。
|
|
143
145
|
- 验收指标:200 次只读调用 100% 成功并记录 P50/P95、20 轮资源修改、5 次 Domain Reload 首次恢复、强杀重启恢复、双工程显式路由 60 次无误选、运行中 Editor 防护与 `--project-path` 覆盖拒绝。
|
|
144
146
|
|
|
145
147
|
详细说明见 `docs/SELF_HOSTED_RUNNER.md`。
|
|
@@ -179,7 +181,7 @@ kevlns 工具家族共享同一套发布约定(tag 驱动、CI 护栏、MIT)
|
|
|
179
181
|
| --- | --- | --- |
|
|
180
182
|
| [`v-cli`](https://github.com/kevlns/v-cli) | 个人工具箱 CLI | v0.2.1 |
|
|
181
183
|
| [`xlmerge`](https://github.com/kevlns/xlmerge) | Git 中 .xlsx/.xlsm 冲突可视化解决工具 | v1.2.2 |
|
|
182
|
-
| [`u-cli-mod`](https://github.com/kevlns/u-cli-mod) | Unity 精确版本路由 + CLI + pipeline 包(Windows-first,本仓库) | v0.1.
|
|
184
|
+
| [`u-cli-mod`](https://github.com/kevlns/u-cli-mod) | Unity 精确版本路由 + CLI + pipeline 包(Windows-first,本仓库) | v0.1.2 |
|
|
183
185
|
|
|
184
186
|
## Compatibility
|
|
185
187
|
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { CliError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Replacement body for the upstream Editor console commands.
|
|
4
|
+
*
|
|
5
|
+
* The upstream implementation only reads buffers populated from
|
|
6
|
+
* Application.logMessageReceivedThreaded. That is useful for follow/player
|
|
7
|
+
* scenarios, but it is not a snapshot of the Unity Editor Console: messages
|
|
8
|
+
* emitted before the subscription (notably compiler/importer diagnostics) can
|
|
9
|
+
* be absent. This editor-only command deliberately reflects Unity's internal
|
|
10
|
+
* LogEntries store, matching the semantics agents expect from UnityMCP's
|
|
11
|
+
* read_console tool. Exact-version routing makes this internal API usage
|
|
12
|
+
* fail-closed and testable per supported Editor revision.
|
|
13
|
+
*/
|
|
14
|
+
const CONSOLE_COMMANDS_BODY_LF = ` [CliCommand("read_console", "Read or clear the current Unity Editor Console (including entries emitted before this command).", Tags = new[] { "observability/console" })]
|
|
15
|
+
public static object ReadConsole(
|
|
16
|
+
[CliArg("action", "Action: get | clear.")] string action = "get",
|
|
17
|
+
[CliArg("types", "Comma-separated entry types: error, warning, log, or all. Defaults to error,warning.")] string types = "error,warning",
|
|
18
|
+
[CliArg("count", "Maximum entries in non-paged mode, capped at 1000.")] int count = 100,
|
|
19
|
+
[CliArg("filterText", "Optional case-insensitive substring filter over the message and stack trace.")] string filterText = null,
|
|
20
|
+
[CliArg("pageSize", "Page size (1-500). Values <= 0 disable paging and use count.")] int pageSize = 0,
|
|
21
|
+
[CliArg("cursor", "Zero-based matching-entry offset used with pageSize.")] int cursor = 0,
|
|
22
|
+
[CliArg("outputFormat", "Entry format: plain | detailed | json (named outputFormat to avoid the Unity CLI global --format option).")] string outputFormat = "detailed",
|
|
23
|
+
[CliArg("includeStacktrace", "Include the stack trace in detailed/json output.")] bool includeStacktrace = true)
|
|
24
|
+
{
|
|
25
|
+
switch ((action ?? "get").Trim().ToLowerInvariant())
|
|
26
|
+
{
|
|
27
|
+
case "clear":
|
|
28
|
+
return ClearConsole();
|
|
29
|
+
case "get":
|
|
30
|
+
var result = ReadUnityConsole(types, count, filterText, pageSize, cursor, outputFormat, includeStacktrace);
|
|
31
|
+
return new
|
|
32
|
+
{
|
|
33
|
+
success = true,
|
|
34
|
+
action = "get",
|
|
35
|
+
total = result.Total,
|
|
36
|
+
returned = result.Messages.Count,
|
|
37
|
+
cursor = result.Cursor,
|
|
38
|
+
nextCursor = result.NextCursor,
|
|
39
|
+
hasMore = result.HasMore,
|
|
40
|
+
messages = result.Messages
|
|
41
|
+
};
|
|
42
|
+
default:
|
|
43
|
+
throw new ArgumentException("Unknown action. Expected 'get' or 'clear'.", nameof(action));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[CliCommand("get_console_logs", "Read the current Unity Editor Console (compatibility alias for read_console).", Tags = new[] { "observability/console" })]
|
|
48
|
+
public static object GetConsoleLogs(
|
|
49
|
+
[CliArg("severity", "Filter: all | log | warning | error.")] string severity = "all",
|
|
50
|
+
[CliArg("limit", "Max entries to return, capped at 1000.")] int limit = 100)
|
|
51
|
+
{
|
|
52
|
+
var requested = string.Equals(severity, "all", StringComparison.OrdinalIgnoreCase)
|
|
53
|
+
? "all"
|
|
54
|
+
: severity;
|
|
55
|
+
var result = ReadUnityConsole(requested, limit, null, 0, 0, "detailed", true);
|
|
56
|
+
return new
|
|
57
|
+
{
|
|
58
|
+
total = result.Total,
|
|
59
|
+
returned = result.Messages.Count,
|
|
60
|
+
logs = result.Messages
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[CliCommand("clear_console", "Clear the Unity Editor Console and all captured pipeline console buffers.", Tags = new[] { "observability/console" })]
|
|
65
|
+
public static object ClearConsole()
|
|
66
|
+
{
|
|
67
|
+
var unityConsoleCleared = false;
|
|
68
|
+
string unityConsoleError = null;
|
|
69
|
+
|
|
70
|
+
try
|
|
71
|
+
{
|
|
72
|
+
var logEntriesType = GetEditorType("UnityEditor.LogEntries");
|
|
73
|
+
GetRequiredMethod(logEntriesType, "Clear").Invoke(null, null);
|
|
74
|
+
unityConsoleCleared = true;
|
|
75
|
+
}
|
|
76
|
+
catch (Exception ex)
|
|
77
|
+
{
|
|
78
|
+
unityConsoleError = UnwrapMessage(ex);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// These are two independent upstream buffers. Clear both so a
|
|
82
|
+
// subsequent console/get_console_logs call cannot return stale data.
|
|
83
|
+
ConsoleLogBuffer.Clear();
|
|
84
|
+
Unity.Pipeline.Console.ConsoleLogCapture.Buffer.Clear();
|
|
85
|
+
Unity.Pipeline.Console.ConsoleLogCapture.Buffer.Save("Temp/pipeline_console_log.json");
|
|
86
|
+
|
|
87
|
+
return new
|
|
88
|
+
{
|
|
89
|
+
success = unityConsoleCleared,
|
|
90
|
+
action = "clear",
|
|
91
|
+
cleared = unityConsoleCleared,
|
|
92
|
+
unityConsoleCleared,
|
|
93
|
+
capturedBuffersCleared = true,
|
|
94
|
+
error = unityConsoleError
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private sealed class ConsoleReadResult
|
|
99
|
+
{
|
|
100
|
+
public int Total { get; set; }
|
|
101
|
+
public List<object> Messages { get; set; }
|
|
102
|
+
public int? Cursor { get; set; }
|
|
103
|
+
public int? NextCursor { get; set; }
|
|
104
|
+
public bool HasMore { get; set; }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private static ConsoleReadResult ReadUnityConsole(
|
|
108
|
+
string types,
|
|
109
|
+
int count,
|
|
110
|
+
string filterText,
|
|
111
|
+
int pageSize,
|
|
112
|
+
int cursor,
|
|
113
|
+
string format,
|
|
114
|
+
bool includeStacktrace)
|
|
115
|
+
{
|
|
116
|
+
var logEntriesType = GetEditorType("UnityEditor.LogEntries");
|
|
117
|
+
var logEntryType = GetEditorType("UnityEditor.LogEntry");
|
|
118
|
+
var staticFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
|
|
119
|
+
var instanceFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
|
|
120
|
+
|
|
121
|
+
var startGettingEntries = GetRequiredMethod(logEntriesType, "StartGettingEntries");
|
|
122
|
+
var endGettingEntries = GetRequiredMethod(logEntriesType, "EndGettingEntries");
|
|
123
|
+
var getEntry = GetRequiredMethod(logEntriesType, "GetEntryInternal");
|
|
124
|
+
var getEntryCount = logEntriesType.GetMethod("GetEntryCount", staticFlags);
|
|
125
|
+
var setConsoleFlag = GetRequiredMethod(logEntriesType, "SetConsoleFlag");
|
|
126
|
+
var setFilteringText = GetRequiredMethod(logEntriesType, "SetFilteringText");
|
|
127
|
+
var getFilteringText = GetRequiredMethod(logEntriesType, "GetFilteringText");
|
|
128
|
+
var consoleFlags = logEntriesType.GetProperty("consoleFlags", staticFlags);
|
|
129
|
+
if (consoleFlags == null)
|
|
130
|
+
throw new MissingMemberException(logEntriesType.FullName, "consoleFlags");
|
|
131
|
+
|
|
132
|
+
var modeField = GetRequiredField(logEntryType, "mode", instanceFlags);
|
|
133
|
+
var messageField = GetRequiredField(logEntryType, "message", instanceFlags);
|
|
134
|
+
var fileField = GetRequiredField(logEntryType, "file", instanceFlags);
|
|
135
|
+
var lineField = GetRequiredField(logEntryType, "line", instanceFlags);
|
|
136
|
+
var callstackStartField = logEntryType.GetField("callstackTextStartUTF16", instanceFlags);
|
|
137
|
+
|
|
138
|
+
var requestedTypes = NormalizeTypes(types);
|
|
139
|
+
var normalizedFormat = (format ?? "detailed").Trim().ToLowerInvariant();
|
|
140
|
+
var usePaging = pageSize > 0;
|
|
141
|
+
var resolvedPageSize = Math.Min(Math.Max(pageSize, 1), 500);
|
|
142
|
+
var resolvedCursor = Math.Max(cursor, 0);
|
|
143
|
+
var resolvedCount = Math.Min(Math.Max(count, 1), 1000);
|
|
144
|
+
var messages = new List<object>();
|
|
145
|
+
var totalMatches = 0;
|
|
146
|
+
var originalFlags = (int)consoleFlags.GetValue(null, null);
|
|
147
|
+
var originalFilter = (string)getFilteringText.Invoke(null, null) ?? string.Empty;
|
|
148
|
+
var started = false;
|
|
149
|
+
|
|
150
|
+
try
|
|
151
|
+
{
|
|
152
|
+
// StartGettingEntries observes the Console window's severity
|
|
153
|
+
// toggles and search filter. Temporarily make the snapshot
|
|
154
|
+
// independent from UI state, then restore both in finally.
|
|
155
|
+
setConsoleFlag.Invoke(null, new object[] { 1 << 7, true });
|
|
156
|
+
setConsoleFlag.Invoke(null, new object[] { 1 << 8, true });
|
|
157
|
+
setConsoleFlag.Invoke(null, new object[] { 1 << 9, true });
|
|
158
|
+
setFilteringText.Invoke(null, new object[] { string.Empty });
|
|
159
|
+
|
|
160
|
+
var totalEntries = (int)startGettingEntries.Invoke(null, null);
|
|
161
|
+
started = true;
|
|
162
|
+
var entry = Activator.CreateInstance(logEntryType);
|
|
163
|
+
|
|
164
|
+
for (var i = 0; i < totalEntries; i++)
|
|
165
|
+
{
|
|
166
|
+
var read = getEntry.Invoke(null, new[] { (object)i, entry });
|
|
167
|
+
if (read is bool && !(bool)read)
|
|
168
|
+
continue;
|
|
169
|
+
|
|
170
|
+
var rawMessage = (string)messageField.GetValue(entry) ?? string.Empty;
|
|
171
|
+
if (rawMessage.Length == 0)
|
|
172
|
+
continue;
|
|
173
|
+
|
|
174
|
+
var mode = (int)modeField.GetValue(entry);
|
|
175
|
+
var type = ClassifyType(mode);
|
|
176
|
+
if (!requestedTypes.Contains(type.ToLowerInvariant()))
|
|
177
|
+
continue;
|
|
178
|
+
|
|
179
|
+
var callstackStart = callstackStartField == null ? -1 : (int)callstackStartField.GetValue(entry);
|
|
180
|
+
string message;
|
|
181
|
+
string stackTrace;
|
|
182
|
+
SplitMessage(rawMessage, callstackStart, out message, out stackTrace);
|
|
183
|
+
|
|
184
|
+
if (!string.IsNullOrEmpty(filterText)
|
|
185
|
+
&& rawMessage.IndexOf(filterText, StringComparison.OrdinalIgnoreCase) < 0)
|
|
186
|
+
continue;
|
|
187
|
+
|
|
188
|
+
var matchingIndex = totalMatches;
|
|
189
|
+
totalMatches++;
|
|
190
|
+
var include = usePaging
|
|
191
|
+
? matchingIndex >= resolvedCursor && matchingIndex < resolvedCursor + resolvedPageSize
|
|
192
|
+
: messages.Count < resolvedCount;
|
|
193
|
+
if (!include)
|
|
194
|
+
continue;
|
|
195
|
+
|
|
196
|
+
if (normalizedFormat == "plain")
|
|
197
|
+
{
|
|
198
|
+
messages.Add(message);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var occurrences = 1;
|
|
203
|
+
if (getEntryCount != null)
|
|
204
|
+
{
|
|
205
|
+
var occurrenceResult = getEntryCount.Invoke(null, new object[] { i });
|
|
206
|
+
if (occurrenceResult is int)
|
|
207
|
+
occurrences = (int)occurrenceResult;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
messages.Add(new
|
|
211
|
+
{
|
|
212
|
+
type,
|
|
213
|
+
message,
|
|
214
|
+
file = (string)fileField.GetValue(entry) ?? string.Empty,
|
|
215
|
+
line = (int)lineField.GetValue(entry),
|
|
216
|
+
stackTrace = includeStacktrace ? stackTrace : null,
|
|
217
|
+
occurrences
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
finally
|
|
222
|
+
{
|
|
223
|
+
try
|
|
224
|
+
{
|
|
225
|
+
if (started)
|
|
226
|
+
endGettingEntries.Invoke(null, null);
|
|
227
|
+
}
|
|
228
|
+
finally
|
|
229
|
+
{
|
|
230
|
+
consoleFlags.SetValue(null, originalFlags, null);
|
|
231
|
+
setFilteringText.Invoke(null, new object[] { originalFilter });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
int? nextCursor = null;
|
|
236
|
+
if (usePaging && resolvedCursor + messages.Count < totalMatches)
|
|
237
|
+
nextCursor = resolvedCursor + messages.Count;
|
|
238
|
+
|
|
239
|
+
return new ConsoleReadResult
|
|
240
|
+
{
|
|
241
|
+
Total = totalMatches,
|
|
242
|
+
Messages = messages,
|
|
243
|
+
Cursor = usePaging ? (int?)resolvedCursor : null,
|
|
244
|
+
NextCursor = nextCursor,
|
|
245
|
+
HasMore = usePaging ? nextCursor.HasValue : totalMatches > messages.Count
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private static HashSet<string> NormalizeTypes(string types)
|
|
250
|
+
{
|
|
251
|
+
var result = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
252
|
+
if (string.IsNullOrWhiteSpace(types))
|
|
253
|
+
{
|
|
254
|
+
result.Add("error");
|
|
255
|
+
result.Add("warning");
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
foreach (var part in types.Split(','))
|
|
260
|
+
{
|
|
261
|
+
var normalized = part.Trim().ToLowerInvariant();
|
|
262
|
+
switch (normalized)
|
|
263
|
+
{
|
|
264
|
+
case "all":
|
|
265
|
+
result.Clear();
|
|
266
|
+
result.Add("error");
|
|
267
|
+
result.Add("warning");
|
|
268
|
+
result.Add("log");
|
|
269
|
+
return result;
|
|
270
|
+
case "warn":
|
|
271
|
+
result.Add("warning");
|
|
272
|
+
break;
|
|
273
|
+
case "exception":
|
|
274
|
+
case "assert":
|
|
275
|
+
result.Add("error");
|
|
276
|
+
break;
|
|
277
|
+
case "error":
|
|
278
|
+
case "warning":
|
|
279
|
+
case "log":
|
|
280
|
+
result.Add(normalized);
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (result.Count == 0)
|
|
286
|
+
{
|
|
287
|
+
result.Add("error");
|
|
288
|
+
result.Add("warning");
|
|
289
|
+
}
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private static string ClassifyType(int mode)
|
|
294
|
+
{
|
|
295
|
+
const int errorMask =
|
|
296
|
+
(1 << 0) | (1 << 1) | (1 << 4) | (1 << 6) | (1 << 8)
|
|
297
|
+
| (1 << 11) | (1 << 17) | (1 << 20) | (1 << 21) | (1 << 22);
|
|
298
|
+
const int warningMask = (1 << 7) | (1 << 9) | (1 << 12);
|
|
299
|
+
if ((mode & errorMask) != 0)
|
|
300
|
+
return "Error";
|
|
301
|
+
if ((mode & warningMask) != 0)
|
|
302
|
+
return "Warning";
|
|
303
|
+
return "Log";
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private static void SplitMessage(string raw, int callstackStart, out string message, out string stackTrace)
|
|
307
|
+
{
|
|
308
|
+
if (callstackStart > 0 && callstackStart < raw.Length)
|
|
309
|
+
{
|
|
310
|
+
message = raw.Substring(0, callstackStart).TrimEnd('\\r', '\\n');
|
|
311
|
+
stackTrace = raw.Substring(callstackStart).TrimStart('\\r', '\\n');
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
message = raw.TrimEnd('\\r', '\\n');
|
|
316
|
+
stackTrace = string.Empty;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private static Type GetEditorType(string name)
|
|
320
|
+
{
|
|
321
|
+
var type = typeof(UnityEditor.EditorApplication).Assembly.GetType(name);
|
|
322
|
+
if (type == null)
|
|
323
|
+
throw new TypeLoadException("Could not find internal Unity Editor type: " + name);
|
|
324
|
+
return type;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private static MethodInfo GetRequiredMethod(Type type, string name)
|
|
328
|
+
{
|
|
329
|
+
var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
|
|
330
|
+
var method = type.GetMethod(name, flags);
|
|
331
|
+
if (method == null)
|
|
332
|
+
throw new MissingMethodException(type.FullName, name);
|
|
333
|
+
return method;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
private static FieldInfo GetRequiredField(Type type, string name, BindingFlags flags)
|
|
337
|
+
{
|
|
338
|
+
var field = type.GetField(name, flags);
|
|
339
|
+
if (field == null)
|
|
340
|
+
throw new MissingFieldException(type.FullName, name);
|
|
341
|
+
return field;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
private static string UnwrapMessage(Exception exception)
|
|
345
|
+
{
|
|
346
|
+
var target = exception as TargetInvocationException;
|
|
347
|
+
return target != null && target.InnerException != null
|
|
348
|
+
? target.InnerException.Message
|
|
349
|
+
: exception.Message;
|
|
350
|
+
}
|
|
351
|
+
`;
|
|
352
|
+
function normalizeCrlf(bytes) {
|
|
353
|
+
return Buffer.from(bytes.toString('utf8').replace(/\r?\n/g, '\r\n'), 'utf8');
|
|
354
|
+
}
|
|
355
|
+
/** Replace the callback-buffer console commands with an Editor LogEntries snapshot reader. */
|
|
356
|
+
export function patchConsoleCommands(bytes) {
|
|
357
|
+
const source = bytes.toString('utf8');
|
|
358
|
+
if (source.includes('[CliCommand("read_console"')) {
|
|
359
|
+
return normalizeCrlf(Buffer.from(source, 'utf8'));
|
|
360
|
+
}
|
|
361
|
+
const startMarker = ' [CliCommand("get_console_logs"';
|
|
362
|
+
const normalized = source.replace(/\r\n/g, '\n');
|
|
363
|
+
const start = normalized.indexOf(startMarker);
|
|
364
|
+
const classClose = normalized.lastIndexOf(' }\n}');
|
|
365
|
+
if (start < 0 || classClose < start) {
|
|
366
|
+
throw new CliError('ConsoleCommands.cs 缺少 get_console_logs/class 闭合锚点');
|
|
367
|
+
}
|
|
368
|
+
const patched = normalized.slice(0, start) + CONSOLE_COMMANDS_BODY_LF + normalized.slice(classClose);
|
|
369
|
+
return normalizeCrlf(Buffer.from(patched, 'utf8'));
|
|
370
|
+
}
|
package/dist/transform.js
CHANGED
|
@@ -2,6 +2,7 @@ import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, existsSync
|
|
|
2
2
|
import { dirname, join, relative, sep } from 'node:path';
|
|
3
3
|
import { CliError } from './errors.js';
|
|
4
4
|
import { sha256Buffer, compareTree } from './integrity.js';
|
|
5
|
+
import { patchConsoleCommands } from './consolePatch.js';
|
|
5
6
|
/** Files/dirs present upstream that must NOT ship in the adapted package. */
|
|
6
7
|
const REMOVE_EXACT = new Set([
|
|
7
8
|
'.attestation.p7m',
|
|
@@ -139,6 +140,9 @@ export async function transformPackage(input) {
|
|
|
139
140
|
else if (rel === 'Editor/Commands/Materials/MaterialCommands.cs') {
|
|
140
141
|
out = patchMaterialCommands(bytes);
|
|
141
142
|
}
|
|
143
|
+
else if (rel === 'Editor/Commands/Observability/ConsoleCommands.cs') {
|
|
144
|
+
out = patchConsoleCommands(bytes);
|
|
145
|
+
}
|
|
142
146
|
else if (DLL_META_NAMES.includes(rel.split('/').pop())) {
|
|
143
147
|
const { guid } = metaBody(bytes);
|
|
144
148
|
out = Buffer.from(`fileFormatVersion: 2\nguid: ${guid}\n${dllImporterBody}`, 'utf8');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevlns/u-cli-mod",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "u-cli-mod: pin exact Unity Editor version routes and install the adapted com.unity.pipeline package for Unity 2022 (Windows-first). Downloads Unity assets at runtime into the user cache; the package itself contains no Unity binaries or package source. Not an official Unity project.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"expectedTree": "expected-tree/2022.3.59f1c1.json",
|
|
22
22
|
"templates": "2022.3.59f1c1",
|
|
23
23
|
"targetUnityVersion": "2022.3",
|
|
24
|
-
"patchVersion":
|
|
24
|
+
"patchVersion": 2
|
|
25
25
|
},
|
|
26
26
|
"status": "unofficial-unity-2022-port",
|
|
27
|
-
"verifiedBy": "local integration run, 2022.3.62f3c1 (1623fc0bbb97);
|
|
27
|
+
"verifiedBy": "local integration run, 2022.3.62f3c1 (1623fc0bbb97); patchVersion 2 read_console + reload/restart/dual-project E2E re-verified on 2022.3.59f1c1 (6f0f5d6fe989)"
|
|
28
28
|
}
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"expectedTree": "expected-tree/2022.3.62f3c1.json",
|
|
22
22
|
"templates": "2022.3.62f3c1",
|
|
23
23
|
"targetUnityVersion": "2022.3",
|
|
24
|
-
"patchVersion":
|
|
24
|
+
"patchVersion": 2
|
|
25
25
|
},
|
|
26
26
|
"status": "unofficial-unity-2022-port",
|
|
27
|
-
"verifiedBy": "
|
|
28
|
-
}
|
|
27
|
+
"verifiedBy": "patchVersion 2 read_console + compile/reload/restart/dual-project E2E, 2022.3.62f3c1 (1623fc0bbb97)"
|
|
28
|
+
}
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"Editor/Commands/Navigation/NavigationCommands.cs": "2d2bfafb2f8563380c8708ecb97300250ee9bdc8a0f6a0512903247cf19a4ae5",
|
|
130
130
|
"Editor/Commands/Navigation/NavigationCommands.cs.meta": "f1002bd852046ce3bd7b3dbd6cc35e707429455ded5ad2c79e1fbac965bf23a9",
|
|
131
131
|
"Editor/Commands/Observability.meta": "0cef75eb0161beeff22e8ba22dac994895bd3d1bef3d86c41fe7f7e192206c73",
|
|
132
|
-
"Editor/Commands/Observability/ConsoleCommands.cs": "
|
|
132
|
+
"Editor/Commands/Observability/ConsoleCommands.cs": "68ccace32673ee6676040350a60003d10150f9978fc082ac747466db0ad65377",
|
|
133
133
|
"Editor/Commands/Observability/ConsoleCommands.cs.meta": "0b36196d922c3f6b34b49c42606a170b298694b06f6df393f3be4c75dda4c04c",
|
|
134
134
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs": "abba3537972218a75536bbf503c9732bc967ae6a18872d6126080111b7a3011e",
|
|
135
135
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs.meta": "2f4e7cbc14f9a3bd5fc2314ebde2ad6ee9b97a292b624f174242659889f24b72",
|
|
@@ -388,4 +388,4 @@
|
|
|
388
388
|
"package.json": "95c7387442ce3f84f5d21a4837e6392ec5b51484a400c1c55d1f64ff96022f3b",
|
|
389
389
|
"package.json.meta": "9552a2c99d7c3fd62e0747077e770fd1f86f1251f4d74d48102620168f67406c"
|
|
390
390
|
}
|
|
391
|
-
}
|
|
391
|
+
}
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"Editor/Commands/Navigation/NavigationCommands.cs": "2d2bfafb2f8563380c8708ecb97300250ee9bdc8a0f6a0512903247cf19a4ae5",
|
|
130
130
|
"Editor/Commands/Navigation/NavigationCommands.cs.meta": "f1002bd852046ce3bd7b3dbd6cc35e707429455ded5ad2c79e1fbac965bf23a9",
|
|
131
131
|
"Editor/Commands/Observability.meta": "0cef75eb0161beeff22e8ba22dac994895bd3d1bef3d86c41fe7f7e192206c73",
|
|
132
|
-
"Editor/Commands/Observability/ConsoleCommands.cs": "
|
|
132
|
+
"Editor/Commands/Observability/ConsoleCommands.cs": "68ccace32673ee6676040350a60003d10150f9978fc082ac747466db0ad65377",
|
|
133
133
|
"Editor/Commands/Observability/ConsoleCommands.cs.meta": "0b36196d922c3f6b34b49c42606a170b298694b06f6df393f3be4c75dda4c04c",
|
|
134
134
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs": "abba3537972218a75536bbf503c9732bc967ae6a18872d6126080111b7a3011e",
|
|
135
135
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs.meta": "2f4e7cbc14f9a3bd5fc2314ebde2ad6ee9b97a292b624f174242659889f24b72",
|
|
@@ -388,4 +388,4 @@
|
|
|
388
388
|
"package.json": "95c7387442ce3f84f5d21a4837e6392ec5b51484a400c1c55d1f64ff96022f3b",
|
|
389
389
|
"package.json.meta": "9552a2c99d7c3fd62e0747077e770fd1f86f1251f4d74d48102620168f67406c"
|
|
390
390
|
}
|
|
391
|
-
}
|
|
391
|
+
}
|
package/v-cli.plugin.json
CHANGED
|
@@ -451,9 +451,10 @@
|
|
|
451
451
|
"tools": {
|
|
452
452
|
"audit": "Run a Project Auditor static-analysis scan. Returns immediately; poll audit_status until status is 'completed', then read the CSV.",
|
|
453
453
|
"audit_status": "Get the status of the last audit: idle | scanning | completed | failed | interrupted | unavailable.",
|
|
454
|
-
"clear_console": "Clear the
|
|
454
|
+
"clear_console": "Clear the Unity Editor Console and all captured pipeline console buffers.",
|
|
455
455
|
"console": "Get captured Unity console output (Editor or Player; supports tail, level filtering, and follow via a cursor)",
|
|
456
|
-
"get_console_logs": "Read
|
|
456
|
+
"get_console_logs": "Read the current Unity Editor Console (compatibility alias for read_console).",
|
|
457
|
+
"read_console": "Read or clear the current Unity Editor Console, including entries emitted before command initialization; supports type/text filtering, paging, formatting, and stack traces.",
|
|
457
458
|
"get_performance_stats": "Read render, memory, and frame-timing stats (structured, read-only).",
|
|
458
459
|
"log": "Write a message to Unity console"
|
|
459
460
|
}
|
|
@@ -507,4 +508,4 @@
|
|
|
507
508
|
}
|
|
508
509
|
]
|
|
509
510
|
}
|
|
510
|
-
}
|
|
511
|
+
}
|