@kevlns/u-cli-mod 0.2.2 → 0.2.4

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 CHANGED
@@ -13,11 +13,11 @@
13
13
  - `u-cli-mod setup <project>` - CLI + 适配包一键就绪(推荐首次入口)
14
14
  - `u-cli-mod pipeline install <project> --dry-run` - 安装预览(不写入工程)
15
15
  - `u-cli-mod pipeline install <project>` - 事务式安装适配包(自动备份/回滚/receipt)
16
- - `u-cli-mod exec <project> -- <pipeline-args>` - 执行 Pipeline 命令(工具统一绑定 `--project-path`)
17
- - Pipeline 命令全集见文末「Pipeline 工具清单」(适配版 `com.unity.pipeline` 共 154 个命令,按领域分组)
18
- - `u-cli-mod exec <project> [--wait <秒>] -- <pipeline-args>` - 长任务默认 5s 后让出控制权,结果用对应的 `command <name>_status` 轮询
16
+ - `u-cli-mod exec <project> [--wait <秒>] -- <pipeline-args>` - 执行 Pipeline 命令(工具统一绑定 `--project-path`);长任务(`run_tests`)默认 5s 后让出控制权,结果用对应的 `command <name>_status` 轮询
19
17
  - `u-cli-mod routes` / `u-cli-mod cache clean` - 路由表 / 缓存清理
20
18
 
19
+ Pipeline 命令全集见文末「Pipeline 工具清单」(适配版 `com.unity.pipeline`,按领域分组)。
20
+
21
21
  ## 使用规范(Agent 必须遵守)
22
22
 
23
23
  1. **首次对某工程执行 `exec` 前**,必须检查 `doctor` 的 `cli.state="valid"`、`pipeline.state="current"` 且 `pipeline.installed=true`。`doctor` 退出成功仅表示诊断完成,不代表工程已就绪;`pipeline.present=true` 也只表示包存在。`missing` 时先跑 `setup`;`outdated`/`invalid` 时先关闭目标 Editor,再通过 `pipeline install <project> --force` 备份并更新。升级 npm 包不会自动更新工程内适配包,不要直接 `exec`。
@@ -27,8 +27,8 @@
27
27
  5. **版本路由是精确匹配**(`m_EditorVersion` + revision 同时一致),没有"就近版本"回退;工程版本不在路由表内时如实报告支持列表,不得猜测、不得改写 `ProjectVersion.txt`。
28
28
  6. `exec` 每次调用前都会重新校验 CLI 哈希(防篡改),属正常行为;校验失败按提示跑 `u-cli-mod cli install --force` 修复即可。
29
29
  7. **读取 Editor 当前 Console 首选 `command read_console`**,`get_console_logs` 是兼容别名;`command console` 读取回调捕获流,适合 `since`/cursor 跟随,但不能代替原生 Console 快照。工具必须经 `command <名>` 调用。若实际 schema 中缺少 `read_console`,先检查 `doctor` 的 `patchVersion`/`installedPatchVersion` 和 `state`,不要将其误认成 `console` 的别名。
30
+ 8. **全量测试必须走 `--async_tests`**:Unity CLI 对同步命令有 30 秒硬性等待上限(`--timeout` 无法延长),同步 `run_tests` 全量必然超时且不入 `test_status` 跟踪。用法:`run_tests --mode EditMode --async_tests`(立即返回)→ 轮询 `test_status` 至 `completed` 拿完整 Summary;小范围用 `--filter` 缩到单命名空间/类,可直接同步等待拿 Summary。
30
31
 
31
- 8. **全量测试必须走 `--async_tests`**:Unity CLI 对同步命令有 30 秒硬性等待上限(`--timeout` 无法延长),同步 `run_tests` 全量必然超时且不入 `test_status` 跟踪。全量:`run_tests --mode EditMode --async_tests`(立即返回)→ 轮询 `test_status` 至 `completed` 拿完整 Summary;小范围用 `--filter` 缩到单命名空间/类,可直接同步等待拿 Summary。
32
32
  ## 典型流程
33
33
 
34
34
  ```bash
@@ -40,7 +40,9 @@ u-cli-mod exec <project> -- command run_tests --mode EditMode --async_tests
40
40
  u-cli-mod exec <project> -- command read_console --types error,warning --count 100
41
41
  ```
42
42
 
43
- `doctor.pipeline` 的 `patchVersion` 为当前路由要求的补丁版本,`installedPatchVersion` 为 receipt 记录的版本(旧 receipt 也兼容,未知为 null);`state` 为 `missing | outdated | invalid | current`。只有完整 expected-tree 校验通过且没有旧 patch receipt 时才返回 `installed=true`;`sourceReady` 同样经过文件树校验。
43
+ ### doctor 输出要点
44
+
45
+ `doctor.pipeline` 的 `patchVersion` 为当前路由要求的补丁版本,`installedPatchVersion` 为 receipt 记录的版本(缺失或未知为 null);`state` 为 `missing | outdated | invalid | current`。完整 expected-tree 校验通过即返回 `installed=true` / `current`,receipt 缺失或陈旧不触发重装。`verification` 列出内容不匹配、校验错误及仅行尾差异的文件。已安装 UTF-8 文本允许 LF/CRLF 等价,其他内容及二进制仍严格校验;生成源与 staging 保持字节级校验,新生成文本统一 LF。`sourceReady=false` 仅表示生成缓存需重建,不代表已安装包失效。
44
46
 
45
47
  ## Pipeline 工具清单
46
48
 
@@ -234,4 +236,4 @@ u-cli-mod exec <project> -- command read_console --types error,warning --count 1
234
236
 
235
237
  ### Authoring 根路径
236
238
  - `get_authoring_root` — Get the base folder (under Assets/) that bare authoring paths resolve against.
237
- - `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.
239
+ - `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,6 +52,8 @@ u-cli-mod routes # 列出支持的 Editor 路由
52
52
 
53
53
  升级 npm 包不会自动替换已有工程的 `Packages/com.unity.pipeline`。检查 `doctor` 的 `pipeline.state`:只有 `current` 且 `installed=true` 才表示当前补丁完整;`outdated`/`invalid` 时关闭目标 Unity Editor 后执行 `u-cli-mod pipeline install <project> --force`(自动备份)。`patchVersion` 是路由要求,`installedPatchVersion` 来自安装 receipt;仅看到上游版本 `0.5.0-exp.1` 或诊断退出码 0 不代表适配包已更新。
54
54
 
55
+ 就绪状态以当前路由的完整文件树为准,旧 receipt、缺失 receipt 或生成缓存未就绪均不会推翻已通过校验的安装。`pipeline.verification` 提供 `mismatches`、`lineEndingDifferences` 和 `error`,可直接定位失效原因。新生成的文本统一 LF;已安装 UTF-8 文本只接受 LF/CRLF 的等价差异,不忽略 BOM、空白、实际内容、缺失或额外文件,二进制保持 SHA-256 严格校验。生成缓存与安装 staging 仍要求精确字节。
56
+
55
57
  ## Usage
56
58
 
57
59
  > 示例中的 `<project>` 指代你的 Unity 工程目录,请替换为实际路径。
@@ -104,9 +106,9 @@ u-cli-mod cache clean
104
106
  5. 事务式安装到 `Packages/com.unity.pipeline`:staging → 校验 → 备份 → 替换 → 再校验 → receipt;任一步失败自动回滚。运行中的 Unity Editor 会 fail-closed 阻止安装。
105
107
  6. `exec` 每次调用前重新校验 CLI 哈希,并**禁止任何 `--project-path` 变体覆盖目标工程**。
106
108
 
107
- > **缓存目录说明**:用户缓存默认为 `%LOCALAPPDATA%\editor-pipeline-cli`;该目录名沿用历史名称,以避免破坏已通过验证的缓存/收据契约。工程内的安装事务目录 `Library/editor-pipeline-cli` 同理保留。这两个目录名与 npm 包名 `@kevlns/u-cli-mod` 无关,属于兼容性保留项。
109
+ > **缓存目录说明**:用户缓存固定为 `%LOCALAPPDATA%\editor-pipeline-cli`,工程内的安装事务目录固定为 `Library/editor-pipeline-cli`。两个目录名是缓存与 receipt 契约的一部分,不随 npm 包名(`@kevlns/u-cli-mod`)变化;改名会使既有缓存与 receipt 失效。
108
110
 
109
- ## 本仓库/包 与 不包含
111
+ ## 包内容与分发边界
110
112
 
111
113
  - ✅ 只包含本工具自己的 TypeScript 代码、版本路由元数据与哈希清单。
112
114
  - ✅ Unity CLI 与 `com.unity.pipeline` 在**运行时**从 Unity 官方地址下载到**用户缓存**。
@@ -121,9 +123,11 @@ u-cli-mod cache clean
121
123
  npm run check # build + lint + vitest 测试 + pack guard
122
124
  ```
123
125
 
126
+ > 发版除 `npm version` 外,还需同步 tests/scripts 中的版本断言(`cli.test.ts`、`vcli-manifest.test.ts`、`pack-guard.mjs`、`test-package-install.mjs`):grep 旧版本号应为零,再打 tag。
127
+
124
128
  `pack:guard` 会执行真实 `npm pack`(含文件清单校验),断言发布包:
125
129
 
126
- - 包名为 `@kevlns/u-cli-mod`,tgz 文件名精确为 `kevlns-u-cli-mod-0.2.1.tgz`(与 package.json 版本一致);
130
+ - 包名为 `@kevlns/u-cli-mod`,tgz 文件名精确为 `kevlns-u-cli-mod-0.2.3.tgz`(与 package.json 版本一致);
127
131
  - `files` 必须包含 `v-cli.plugin.json`,且清单身份字段(schemaVersion/package/command/bin/platforms)与包一致;
128
132
  - 不出现:
129
133
 
@@ -135,7 +139,7 @@ npm run check # build + lint + vitest 测试 + pack guard
135
139
 
136
140
  ### v-cli 插件清单
137
141
 
138
- `v-cli.plugin.json` 随包发布(`package.json` 中 `vCli.manifest` 指向),声明 v-cli 命令 `unity`(平台 win32)与全部公共命令路径、参数、选项、输出与副作用元数据。`tests/vcli-manifest.test.ts` 以 `buildProgram()` 为行为源校验清单:命令树、参数、选项(flags 与描述)、usage 逐项一致,任何 CLI 定义变更未同步清单都会失败。
142
+ `v-cli.plugin.json` 随包发布(`package.json` 中 `vCli.manifest` 指向),声明 v-cli 命令 `unity`(平台 win32)与全部公共命令路径、参数、选项、输出与副作用元数据。`tests/vcli-manifest.test.ts` 以 `buildProgram()` 为行为源校验清单:命令树、参数、选项(flags 与描述)、usage 逐项一致;同一测试还把 AGENTS.md 的 154 条 Pipeline 命令目录与清单逐条互锁——两处任一未同步都会失败。
139
143
 
140
144
  ### 本地 tarball 安装矩阵(三模式验证)
141
145
 
@@ -143,7 +147,7 @@ npm run check # build + lint + vitest 测试 + pack guard
143
147
  npm run test:package
144
148
  ```
145
149
 
146
- 构建真实 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` 覆盖)。
150
+ 构建真实 tgz,并在本地验证三种消费方式:工程 devDependency(`node_modules/.bin`)、带临时 `--prefix` 的全局安装、`npx --package <本地tgz>`;每种都执行 `u-cli-mod --version` 与 `u-cli-mod routes`。**不会**向任何 registry 发布。报告:`C:/tmp/u-cli-mod-package-test-report.json`(可用 `EPC_PKG_REPORT` 覆盖)。
147
151
 
148
152
  ### 自托管 Runner 与 Unity E2E
149
153
 
@@ -153,30 +157,30 @@ npm run e2e:windows # 完整 Unity E2E(真实下载/转换/编译/命
153
157
  ```
154
158
 
155
159
  - `preflight:runner` 只读,不下载/注册 Runner;结果 JSON 输出到 stdout。
156
- - `e2e:windows` 使用**隔离缓存**(干净环境)或显式复用已验证缓存,创建 `<临时目录>/u-cli-mod-e2e/` 下独立临时工程,全部结束后杀掉它启动的所有 Unity 进程并清理临时工程;报告写入 `<临时目录>/u-cli-mod-e2e-report.json`(分别可用 `EPC_E2E_ROOT`、`EPC_E2E_REPORT` 覆盖)。
160
+ - `e2e:windows` 默认使用隔离缓存(设 `EPC_E2E_FRESH_CACHE=0` 可复用真实用户缓存),在 `C:/tmp/u-cli-mod-e2e/` 下创建独立临时工程,全部结束后杀掉它启动的所有 Unity 进程并清理临时工程;报告写入 `C:/tmp/u-cli-mod-e2e-report.json`(分别可用 `EPC_E2E_ROOT`、`EPC_E2E_REPORT` 覆盖)。
157
161
  - 验收指标:200 次只读调用 100% 成功并记录 P50/P95、`read_console` 原生 Console 历史读取与统一清理、20 轮资源修改、5 次 Domain Reload 首次恢复、强杀重启恢复、双工程显式路由 60 次无误选、运行中 Editor 防护与 `--project-path` 覆盖拒绝。
158
162
 
159
163
  详细说明见 `docs/SELF_HOSTED_RUNNER.md`。
160
164
 
161
165
  ### GitHub Actions
162
166
 
163
- - `.github/workflows/ci.yml`:hosted windows runner 上跑 `npm ci` + `npm run check` + `npm audit --omit=dev` + 禁用扩展名扫描;push/PR 触发。
167
+ - `.github/workflows/ci.yml`:hosted windows runner 上跑 `npm ci` + `npm run check` + `npm audit --omit=dev` + 违禁产物扩展名扫描;push/PR 触发。
164
168
  - `.github/workflows/e2e-windows.yml`:**self-hosted** runner(标签 `self-hosted/windows/unity-2022.3.62f3c1`)上跑 Unity E2E;仅 `workflow_dispatch` 与受保护 `v*` tag 触发,不跑 pull_request,不发布;权限最小化(contents: read);产物 `u-cli-mod-e2e-report`。
169
+ - `.github/workflows/publish.yml`:`v*` tag 触发,GitHub 托管 runner 上以 OIDC Trusted Publisher 短期凭证发布到 npm,不保存长期 NPM_TOKEN。
165
170
 
166
171
  ## Routes
167
172
 
168
173
  | Editor | Revision | CLI | Pipeline | 状态 |
169
174
  |---|---|---|---|---|
170
175
  | `2022.3.62f3c1` | `1623fc0bbb97` | `1.0.0-beta.2` | `0.5.0-exp.1`(适配版) | 已验证(非官方移植) |
171
- | `2022.3.59f1c1` | `6f0f5d6fe989` | `1.0.0-beta.2` | `0.5.0-exp.1`(适配版) | 已验证(非官方移植;同一上游 tgz 与补丁规则,适配载荷与 62f3 逐字节一致,已在 2022.3.59f1c1 编辑器完成真机回归) |
176
+ | `2022.3.59f1c1` | `6f0f5d6fe989` | `1.0.0-beta.2` | `0.5.0-exp.1`(适配版) | 已验证(非官方移植;与 62f3 共用同一上游 tgz 与补丁规则,适配载荷逐字节一致;2022.3.59f1c1 真机回归通过) |
172
177
 
173
- 新增 Editor 版本时必须:新增 `routes/<版本>.json` 与 `routes/expected-tree/<版本>.json`、对应转换模板与补丁规则,并在该版本 Unity 上重新完成编译与回归测试。不得让相近版本复用既有路由。
178
+ 新增 Editor 版本要求:添加 `routes/<版本>.json` 与 `routes/expected-tree/<版本>.json`、对应转换模板与补丁规则,并在该版本 Unity 上完成编译与回归测试;相近版本不得复用既有路由。
174
179
 
175
180
  ## 目录
176
181
 
177
182
  ```text
178
- routes/ 精确版本路由 + expected-tree 哈希清单
179
- routes/expected-tree/ 385 文件 SHA-256 清单(含 Tests.meta)
183
+ routes/ 精确版本路由;expected-tree/ 子目录为 385 文件 SHA-256 清单(含 Tests.meta)
180
184
  templates/ Unity 生成的 .meta 模板(数据,非 Unity 源码)
181
185
  AGENTS.md AI Agent 使用规范(场景/规范/速览)
182
186
  src/ TypeScript 实现
@@ -189,11 +193,12 @@ scripts/ pack-guard / preflight-runner / e2e-windows / test-package-inst
189
193
 
190
194
  kevlns 工具家族共享同一套发布约定(tag 驱动、CI 护栏、MIT)。
191
195
 
192
- | Package | Purpose | Status |
196
+ | Package | Purpose | Version |
193
197
  | --- | --- | --- |
194
- | [`v-cli`](https://github.com/kevlns/v-cli) | 个人工具箱 CLI | v0.2.3 |
195
- | [`xlmerge`](https://github.com/kevlns/xlmerge) | Git 中 .xlsx/.xlsm 冲突可视化解决工具 | v1.2.2 |
196
- | [`u-cli-mod`](https://github.com/kevlns/u-cli-mod) | Unity 精确版本路由 + CLI + pipeline 包(Windows-first,本仓库) | v0.2.1 |
198
+ | [`v-cli`](https://github.com/kevlns/v-cli) | 个人工具箱 CLI | v0.2.14 |
199
+ | [`xlmerge`](https://github.com/kevlns/xlmerge) | Git 中 .xlsx/.xlsm 冲突可视化解决工具 | v2.0.0 |
200
+ | [`u-cli-mod`](https://github.com/kevlns/u-cli-mod) | Unity 精确版本路由 + CLI + pipeline 包(Windows-first,本仓库) | v0.2.3 |
201
+ | [`figma-to-uprefab`](https://github.com/kevlns/figma-to-uprefab) | Figma 导出、契约校验与 Unity UGUI staging Prefab 构建 | v0.1.1 |
197
202
 
198
203
  ## Compatibility
199
204
 
@@ -206,17 +211,17 @@ kevlns 工具家族共享同一套发布约定(tag 驱动、CI 护栏、MIT)
206
211
 
207
212
  ```bash
208
213
  npm ci
209
- npm run check # build + lint + test + pack:guard 一键
214
+ npm run check # build + lint + vitest 测试 + pack guard
210
215
  ```
211
216
 
212
217
  For bugs and feature requests, use [GitHub Issues](https://github.com/kevlns/u-cli-mod/issues).
213
218
 
214
219
  ## License
215
220
 
216
- 本工具代码为 MIT(见 LICENSE)。运行时下载的 Unity CLI 与 `com.unity.pipeline` 归其各自的 Unity 许可(如 Unity Package Distribution License)约束,不在本仓库/包内分发。本工具与 Unity 无关,非官方项目。
221
+ 本工具代码为 MIT(见 LICENSE)。运行时下载的 Unity CLI 与 `com.unity.pipeline` 归其各自的 Unity 许可(如 Unity Package Distribution License)约束,不在本仓库/包内分发。
217
222
 
218
223
  <div align="center">
219
224
 
220
225
  Part of the **kevlns** tool family.
221
226
 
222
- </div>
227
+ </div>
@@ -20,6 +20,18 @@ export declare function runDoctor(projectPath: string, options?: DoctorOptions):
20
20
  installed: boolean;
21
21
  state: string;
22
22
  installedPatchVersion: number | null;
23
+ verification: {
24
+ ok: boolean;
25
+ mismatches: never[];
26
+ lineEndingDifferences: never[];
27
+ error: string;
28
+ } | {
29
+ error: null;
30
+ ok: boolean;
31
+ mismatches: import("../integrity.js").TreeMismatch[];
32
+ fileCount: number;
33
+ lineEndingDifferences: string[];
34
+ };
23
35
  };
24
36
  unityProcesses: string[];
25
37
  supportedVersions: string[];
@@ -25,14 +25,14 @@ async function readInstalledPatchVersion(receiptPath) {
25
25
  }
26
26
  return null;
27
27
  }
28
- async function packageTreeMatches(root, expected) {
28
+ async function inspectPackageTree(root, expected, options = {}) {
29
29
  if (!existsSync(root))
30
- return false;
30
+ return { ok: false, mismatches: [], lineEndingDifferences: [], error: 'Package directory is missing' };
31
31
  try {
32
- return (await compareTree(root, expected)).ok;
32
+ return { ...await compareTree(root, expected, options), error: null };
33
33
  }
34
- catch {
35
- return false;
34
+ catch (err) {
35
+ return { ok: false, mismatches: [], lineEndingDifferences: [], error: err instanceof Error ? err.message : String(err) };
36
36
  }
37
37
  }
38
38
  export async function runDoctor(projectPath, options = {}) {
@@ -53,18 +53,17 @@ export async function runDoctor(projectPath, options = {}) {
53
53
  const pipelineOutdated = pipelinePresent &&
54
54
  installedPatchVersion !== null &&
55
55
  installedPatchVersion < route.pipeline.patchVersion;
56
- const pipelineTreeMatches = pipelinePresent
57
- ? await packageTreeMatches(pipelineRoot, expectedTree.files)
58
- : false;
59
- const pipelineInstalled = pipelinePresent && pipelineTreeMatches && !pipelineOutdated;
56
+ const verification = await inspectPackageTree(pipelineRoot, expectedTree.files, { allowTextLineEndings: true });
57
+ // Receipts live in Library and may be stale after a checkout. The pinned tree is authoritative.
58
+ const pipelineInstalled = pipelinePresent && verification.ok;
60
59
  const pipelineState = !pipelinePresent
61
60
  ? 'missing'
62
- : pipelineOutdated
63
- ? 'outdated'
64
- : pipelineTreeMatches
65
- ? 'current'
61
+ : verification.ok
62
+ ? 'current'
63
+ : pipelineOutdated
64
+ ? 'outdated'
66
65
  : 'invalid';
67
- const pipelineSourceReady = await packageTreeMatches(generated, expectedTree.files);
66
+ const pipelineSourceReady = (await inspectPackageTree(generated, expectedTree.files)).ok;
68
67
  let editors = [];
69
68
  if (!options.allowRunningEditor) {
70
69
  try {
@@ -90,6 +89,7 @@ export async function runDoctor(projectPath, options = {}) {
90
89
  installed: pipelineInstalled,
91
90
  state: pipelineState,
92
91
  installedPatchVersion,
92
+ verification,
93
93
  },
94
94
  unityProcesses: editors,
95
95
  supportedVersions: listEditorVersions(),
@@ -349,14 +349,14 @@ const CONSOLE_COMMANDS_BODY_LF = ` [CliCommand("read_console", "Read or c
349
349
  : exception.Message;
350
350
  }
351
351
  `;
352
- function normalizeCrlf(bytes) {
353
- return Buffer.from(bytes.toString('utf8').replace(/\r?\n/g, '\r\n'), 'utf8');
352
+ function normalizeLf(bytes) {
353
+ return Buffer.from(bytes.toString('utf8').replace(/\r\n/g, '\n'), 'utf8');
354
354
  }
355
355
  /** Replace the callback-buffer console commands with an Editor LogEntries snapshot reader. */
356
356
  export function patchConsoleCommands(bytes) {
357
357
  const source = bytes.toString('utf8');
358
358
  if (source.includes('[CliCommand("read_console"')) {
359
- return normalizeCrlf(Buffer.from(source, 'utf8'));
359
+ return normalizeLf(Buffer.from(source, 'utf8'));
360
360
  }
361
361
  const startMarker = ' [CliCommand("get_console_logs"';
362
362
  const normalized = source.replace(/\r\n/g, '\n');
@@ -366,5 +366,5 @@ export function patchConsoleCommands(bytes) {
366
366
  throw new CliError('ConsoleCommands.cs 缺少 get_console_logs/class 闭合锚点');
367
367
  }
368
368
  const patched = normalized.slice(0, start) + CONSOLE_COMMANDS_BODY_LF + normalized.slice(classClose);
369
- return normalizeCrlf(Buffer.from(patched, 'utf8'));
369
+ return normalizeLf(Buffer.from(patched, 'utf8'));
370
370
  }
package/dist/installer.js CHANGED
@@ -48,8 +48,7 @@ export async function installPipeline(project, route, sourceDir, expectedTree, o
48
48
  let existingIsValid = false;
49
49
  if (existsSync(destination)) {
50
50
  try {
51
- await verifyPackageRoot(destination, expectedTree);
52
- existingIsValid = true;
51
+ existingIsValid = (await compareTree(destination, expectedTree, { allowTextLineEndings: true })).ok;
53
52
  }
54
53
  catch {
55
54
  existingIsValid = false;
@@ -26,11 +26,16 @@ export interface TreeMismatch {
26
26
  expected?: string;
27
27
  actual?: string;
28
28
  }
29
- /** Two-way comparison: expected entries must exist with exact bytes; extra files are rejected. */
30
- export declare function compareTree(root: string, expected: Record<string, string>): Promise<{
29
+ export interface TreeComparisonOptions {
30
+ /** Installed text may have passed through Git; generated sources remain byte-exact. */
31
+ allowTextLineEndings?: boolean;
32
+ }
33
+ /** Two-way comparison; optional installed-text EOL equivalence never relaxes binary hashes. */
34
+ export declare function compareTree(root: string, expected: Record<string, string>, options?: TreeComparisonOptions): Promise<{
31
35
  ok: boolean;
32
36
  mismatches: TreeMismatch[];
33
37
  fileCount: number;
38
+ lineEndingDifferences: string[];
34
39
  }>;
35
40
  export declare function assertTreeMatches(root: string, expected: Record<string, string>, what: string): Promise<number>;
36
41
  export declare function fileSize(file: string): number;
package/dist/integrity.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { createReadStream } from 'node:fs';
3
3
  import { readdirSync, statSync } from 'node:fs';
4
- import { join, relative } from 'node:path';
4
+ import { readFile } from 'node:fs/promises';
5
+ import { basename, extname, join, relative } from 'node:path';
5
6
  import { CliError } from './errors.js';
6
7
  export function sha256Buffer(data) {
7
8
  return createHash('sha256').update(data).digest('hex');
@@ -48,17 +49,43 @@ export async function sha256Tree(root, readdirImpl = readdirSync) {
48
49
  }
49
50
  return result;
50
51
  }
51
- /** Two-way comparison: expected entries must exist with exact bytes; extra files are rejected. */
52
- export async function compareTree(root, expected) {
52
+ const TEXT_EXTENSIONS = new Set(['.cs', '.json', '.asmdef', '.meta', '.md', '.txt', '.unity']);
53
+ const TEXT_FILENAMES = new Set(['CHECKSUMS', 'LICENSE']);
54
+ async function matchesTextLineEndings(file, expected) {
55
+ if (!TEXT_EXTENSIONS.has(extname(file).toLowerCase()) && !TEXT_FILENAMES.has(basename(file)))
56
+ return false;
57
+ const bytes = await readFile(file);
58
+ if (bytes.includes(0))
59
+ return false;
60
+ let text;
61
+ try {
62
+ // Preserve BOM bytes and reject invalid UTF-8 instead of silently replacing them.
63
+ text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
64
+ }
65
+ catch {
66
+ return false;
67
+ }
68
+ const lf = text.replace(/\r\n/g, '\n');
69
+ return sha256Buffer(Buffer.from(lf)) === expected ||
70
+ sha256Buffer(Buffer.from(lf.replace(/\n/g, '\r\n'))) === expected;
71
+ }
72
+ /** Two-way comparison; optional installed-text EOL equivalence never relaxes binary hashes. */
73
+ export async function compareTree(root, expected, options = {}) {
53
74
  const actual = await sha256Tree(root);
54
75
  const mismatches = [];
76
+ const lineEndingDifferences = [];
55
77
  for (const [path, hash] of Object.entries(expected)) {
56
78
  const real = actual.get(path);
57
79
  if (real === undefined) {
58
80
  mismatches.push({ kind: 'missing', path });
59
81
  }
60
82
  else if (real !== hash) {
61
- mismatches.push({ kind: 'hash', path, expected: hash, actual: real });
83
+ if (options.allowTextLineEndings && await matchesTextLineEndings(join(root, path), hash)) {
84
+ lineEndingDifferences.push(path);
85
+ }
86
+ else {
87
+ mismatches.push({ kind: 'hash', path, expected: hash, actual: real });
88
+ }
62
89
  }
63
90
  }
64
91
  for (const path of actual.keys()) {
@@ -66,7 +93,7 @@ export async function compareTree(root, expected) {
66
93
  mismatches.push({ kind: 'extra', path });
67
94
  }
68
95
  }
69
- return { ok: mismatches.length === 0, mismatches, fileCount: Object.keys(expected).length };
96
+ return { ok: mismatches.length === 0, mismatches, fileCount: Object.keys(expected).length, lineEndingDifferences };
70
97
  }
71
98
  export async function assertTreeMatches(root, expected, what) {
72
99
  const { ok, mismatches, fileCount } = await compareTree(root, expected);
package/dist/transform.js CHANGED
@@ -43,8 +43,8 @@ export function shouldRemove(relPath) {
43
43
  return true;
44
44
  return REMOVE_PREFIX.some((p) => relPath.startsWith(p));
45
45
  }
46
- function normalizeCrlf(buf) {
47
- return Buffer.from(buf.toString('utf8').replace(/\r?\n/g, '\r\n'), 'utf8');
46
+ function normalizeLf(buf) {
47
+ return Buffer.from(buf.toString('utf8').replace(/\r\n/g, '\n'), 'utf8');
48
48
  }
49
49
  /** JSON rewrite matching the verified reference: compact separators, non-ASCII escaped, key order kept. */
50
50
  export function rewritePackageJson(bytes, targetUnity) {
@@ -81,7 +81,7 @@ function patchAssetCommands(bytes) {
81
81
  const extra = ALIAS_EXTRA_LF.split('\n').join(eol);
82
82
  s = s.replace(marker, marker + extra);
83
83
  }
84
- return normalizeCrlf(Buffer.from(s, 'utf8'));
84
+ return normalizeLf(Buffer.from(s, 'utf8'));
85
85
  }
86
86
  function patchMaterialCommands(bytes) {
87
87
  let s = bytes.toString('utf8');
@@ -97,7 +97,7 @@ function patchMaterialCommands(bytes) {
97
97
  if (s.includes('RenderQueue = mat.rawRenderQueue,')) {
98
98
  s = s.replace('RenderQueue = mat.rawRenderQueue,', 'RenderQueue = GetRawRenderQueue(mat),');
99
99
  }
100
- return normalizeCrlf(Buffer.from(s, 'utf8'));
100
+ return normalizeLf(Buffer.from(s, 'utf8'));
101
101
  }
102
102
  function metaBody(bytes) {
103
103
  const text = bytes.toString('utf8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevlns/u-cli-mod",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
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": {
@@ -57,7 +57,7 @@
57
57
  "Editor/Commands/Animation/TimelineGuard.cs": "56996b9a540a57aa0ca6a44dbc1534d2b4094716983dc808683b2000f7667e8a",
58
58
  "Editor/Commands/Animation/TimelineGuard.cs.meta": "379f2eda0f2e46f7e80b4ba41d489e12cbca16b01e693b2d24103989860b392e",
59
59
  "Editor/Commands/Assets.meta": "50d4c1b23e0f31417d8c6810b20f50ae59e12d815a93c177f78fb2714d6713dc",
60
- "Editor/Commands/Assets/AssetCommands.cs": "b46560bf111b873a49f8922c24699aab5920101b67b16e8742fb734afa6616b4",
60
+ "Editor/Commands/Assets/AssetCommands.cs": "ee9ef1c0f5d684c52f0b673e97362ebc54ec14b5936050bf9c8b14da4ae5dece",
61
61
  "Editor/Commands/Assets/AssetCommands.cs.meta": "55316a0aaa1ef4b6546dfe6c6836b9c3693f3e82d85339eb336ac920541ad722",
62
62
  "Editor/Commands/Assets/AssetImportCommands.cs": "4ab1172a1fe4570b83fc186feffe43e55622d922cbe4897b7cefa3f76d3ceb0a",
63
63
  "Editor/Commands/Assets/AssetImportCommands.cs.meta": "89d86143ec620e33ba315683b2e44a27528fa676a8f0b81bbcd1728fcc36e919",
@@ -115,7 +115,7 @@
115
115
  "Editor/Commands/GameObjects/TypeResolver.cs": "510e80c81e30ef6684398481fc94cb6cec5f4d416fcd3c6d31f986dd14825882",
116
116
  "Editor/Commands/GameObjects/TypeResolver.cs.meta": "c044ba48eb76deeed438928fae73234ef401a5bbacd9c35f41041082c5963f90",
117
117
  "Editor/Commands/Materials.meta": "ecbe40a5a0ccab03e659df0a46e57bfb693f5495482653b2b9e969841c99c9f6",
118
- "Editor/Commands/Materials/MaterialCommands.cs": "ba8388cc9ef9101184344f01a35bbc67591fd180634156c448d8cad12d60e8f8",
118
+ "Editor/Commands/Materials/MaterialCommands.cs": "46aace61bf4d50b84052285ef182a36aeaced574443899e6b3104c353029baf1",
119
119
  "Editor/Commands/Materials/MaterialCommands.cs.meta": "2cecb3f36a2dbea3f648340a4c85c1560b28d659be520d946db6aa03bd54162b",
120
120
  "Editor/Commands/Materials/MaterialResults.cs": "ee362f70720544d29fbc726f25f18170957a9b8b889331ccb01fe877aa6265db",
121
121
  "Editor/Commands/Materials/MaterialResults.cs.meta": "71101ecf14c75c41224836720e1fa0a8a8517be79e9f7f346ab66c8f81fb23f1",
@@ -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": "68ccace32673ee6676040350a60003d10150f9978fc082ac747466db0ad65377",
132
+ "Editor/Commands/Observability/ConsoleCommands.cs": "1d2cb5aa44ca70e77395c6e52e63123eb81fa7082aa13f89ba7bfe01dcffc7dd",
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",
@@ -57,7 +57,7 @@
57
57
  "Editor/Commands/Animation/TimelineGuard.cs": "56996b9a540a57aa0ca6a44dbc1534d2b4094716983dc808683b2000f7667e8a",
58
58
  "Editor/Commands/Animation/TimelineGuard.cs.meta": "379f2eda0f2e46f7e80b4ba41d489e12cbca16b01e693b2d24103989860b392e",
59
59
  "Editor/Commands/Assets.meta": "50d4c1b23e0f31417d8c6810b20f50ae59e12d815a93c177f78fb2714d6713dc",
60
- "Editor/Commands/Assets/AssetCommands.cs": "b46560bf111b873a49f8922c24699aab5920101b67b16e8742fb734afa6616b4",
60
+ "Editor/Commands/Assets/AssetCommands.cs": "ee9ef1c0f5d684c52f0b673e97362ebc54ec14b5936050bf9c8b14da4ae5dece",
61
61
  "Editor/Commands/Assets/AssetCommands.cs.meta": "55316a0aaa1ef4b6546dfe6c6836b9c3693f3e82d85339eb336ac920541ad722",
62
62
  "Editor/Commands/Assets/AssetImportCommands.cs": "4ab1172a1fe4570b83fc186feffe43e55622d922cbe4897b7cefa3f76d3ceb0a",
63
63
  "Editor/Commands/Assets/AssetImportCommands.cs.meta": "89d86143ec620e33ba315683b2e44a27528fa676a8f0b81bbcd1728fcc36e919",
@@ -115,7 +115,7 @@
115
115
  "Editor/Commands/GameObjects/TypeResolver.cs": "510e80c81e30ef6684398481fc94cb6cec5f4d416fcd3c6d31f986dd14825882",
116
116
  "Editor/Commands/GameObjects/TypeResolver.cs.meta": "c044ba48eb76deeed438928fae73234ef401a5bbacd9c35f41041082c5963f90",
117
117
  "Editor/Commands/Materials.meta": "ecbe40a5a0ccab03e659df0a46e57bfb693f5495482653b2b9e969841c99c9f6",
118
- "Editor/Commands/Materials/MaterialCommands.cs": "ba8388cc9ef9101184344f01a35bbc67591fd180634156c448d8cad12d60e8f8",
118
+ "Editor/Commands/Materials/MaterialCommands.cs": "46aace61bf4d50b84052285ef182a36aeaced574443899e6b3104c353029baf1",
119
119
  "Editor/Commands/Materials/MaterialCommands.cs.meta": "2cecb3f36a2dbea3f648340a4c85c1560b28d659be520d946db6aa03bd54162b",
120
120
  "Editor/Commands/Materials/MaterialResults.cs": "ee362f70720544d29fbc726f25f18170957a9b8b889331ccb01fe877aa6265db",
121
121
  "Editor/Commands/Materials/MaterialResults.cs.meta": "71101ecf14c75c41224836720e1fa0a8a8517be79e9f7f346ab66c8f81fb23f1",
@@ -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": "68ccace32673ee6676040350a60003d10150f9978fc082ac747466db0ad65377",
132
+ "Editor/Commands/Observability/ConsoleCommands.cs": "1d2cb5aa44ca70e77395c6e52e63123eb81fa7082aa13f89ba7bfe01dcffc7dd",
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",
package/v-cli.plugin.json CHANGED
@@ -51,7 +51,7 @@
51
51
  ],
52
52
  "output": {
53
53
  "format": "json",
54
- "description": "Diagnostics object: projectPath, editorVersion, editorRevision, routeSupported, routeRevision, cli {version, path, state}, pipeline {version, patchVersion, installedPatchVersion, sourceReady, present, installed, state: missing|outdated|invalid|current}, unityProcesses, supportedVersions. installed/sourceReady require expected-tree integrity. Exit 0 means diagnostics completed, not readiness. Close the target Editor and use pipeline install --force for outdated/invalid. npm upgrades do not update project packages."
54
+ "description": "Diagnostics object: projectPath, editorVersion, editorRevision, routeSupported, routeRevision, cli {version, path, state}, pipeline {version, patchVersion, installedPatchVersion, sourceReady, present, installed, state: missing|outdated|invalid|current}, unityProcesses, supportedVersions. installed/sourceReady require expected-tree integrity. Exit 0 means diagnostics completed, not readiness. Close the target Editor and use pipeline install --force for outdated/invalid. npm upgrades do not update project packages. pipeline.verification reports mismatches, lineEndingDifferences and error. Verified installed content is authoritative over stale/missing receipts; installed UTF-8 text tolerates LF/CRLF only, generated sources and binaries remain byte-exact. New generated text uses LF."
55
55
  },
56
56
  "exitCodes": {
57
57
  "0": "success",