@ttmg/cli 0.4.6 → 0.4.8-alpha.0

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/README.md +192 -15
  3. package/dist/index.js +6626 -2395
  4. package/dist/index.js.map +1 -1
  5. package/dist/package.json +21 -15
  6. package/dist/public/assets/{Card-D4FjfZC9.js → Card-BC5ydRHh.js} +1 -1
  7. package/dist/public/assets/Detail-DPCqXgFa.js +1 -0
  8. package/dist/public/assets/Detail-DPCqXgFa.js.br +0 -0
  9. package/dist/public/assets/MonetizationMode-BGXVb7wG.js +1 -0
  10. package/dist/public/assets/MonetizationModeSummary-LeYQ02Tv.js +1 -0
  11. package/dist/public/assets/{SectionHeader-CAuUcT9Q.js → SectionHeader-BQDU_6TX.js} +1 -1
  12. package/dist/public/assets/baseForm-3VpF68Sz.css +1 -0
  13. package/dist/public/assets/baseForm-3VpF68Sz.css.br +0 -0
  14. package/dist/public/assets/baseForm-dqhahTXM.js +10 -0
  15. package/dist/public/assets/baseForm-dqhahTXM.js.br +0 -0
  16. package/dist/public/assets/{compass-H7uPUHxP.js → compass-DfWJoWl3.js} +1 -1
  17. package/dist/public/assets/{index-CRqInRg3.js → index-3IxvKwO3.js} +1 -1
  18. package/dist/public/assets/index-BAmVtXgk.js +1 -0
  19. package/dist/public/assets/index-BAmVtXgk.js.br +0 -0
  20. package/dist/public/assets/index-BBHaV7vS.js +1 -0
  21. package/dist/public/assets/index-BIkx7MZA.js +1 -0
  22. package/dist/public/assets/index-BIkx7MZA.js.br +0 -0
  23. package/dist/public/assets/index-BT67axp7.css +1 -0
  24. package/dist/public/assets/index-Ba7wrRXG.js +1 -0
  25. package/dist/public/assets/index-Ba7wrRXG.js.br +0 -0
  26. package/dist/public/assets/index-BhTApVX6.js +1 -0
  27. package/dist/public/assets/{index-Bbsc4UYr.js → index-BkbwTqmH.js} +1 -1
  28. package/dist/public/assets/{index-BIZgIFOe.js → index-BmS73Skw.js} +1 -1
  29. package/dist/public/assets/{index-Ckp_mJJy.css → index-BoFbvk-8.css} +1 -1
  30. package/dist/public/assets/index-BoFbvk-8.css.br +0 -0
  31. package/dist/public/assets/{index-CyDpw03-.js → index-BqslPc39.js} +1 -1
  32. package/dist/public/assets/index-C0-lsmcf.js +1 -0
  33. package/dist/public/assets/index-C947zURI.js +1 -0
  34. package/dist/public/assets/index-C947zURI.js.br +0 -0
  35. package/dist/public/assets/index-CC4YJwDI.js +1 -0
  36. package/dist/public/assets/{index-CCX74BCm.js → index-CDxeVVlI.js} +1 -1
  37. package/dist/public/assets/{index-sIdIkg5O.js → index-CF4RJ3VA.js} +1 -1
  38. package/dist/public/assets/{index-CqDAcAbN.js → index-CSOt669g.js} +1 -1
  39. package/dist/public/assets/index-CbUw1wBM.js +3 -0
  40. package/dist/public/assets/index-CbUw1wBM.js.br +0 -0
  41. package/dist/public/assets/index-DLHXV9xo.css +1 -0
  42. package/dist/public/assets/index-DLHXV9xo.css.br +0 -0
  43. package/dist/public/assets/{index-ivwHgxUB.js → index-DRKEUX85.js} +1 -1
  44. package/dist/public/assets/index-DRKEUX85.js.br +0 -0
  45. package/dist/public/assets/index-DS-Ah-pZ.js +1 -0
  46. package/dist/public/assets/index-DcpswdR4.js +21 -0
  47. package/dist/public/assets/index-DcpswdR4.js.br +0 -0
  48. package/dist/public/assets/{index-BhswTE7o.js → index-DpCdlpoj.js} +1 -1
  49. package/dist/public/assets/index-FKgvaTum.js +1 -0
  50. package/dist/public/assets/index-FKgvaTum.js.br +0 -0
  51. package/dist/public/assets/index-_IVh5FZw.js +1 -0
  52. package/dist/public/assets/index-docEsXsM.css +1 -0
  53. package/dist/public/assets/index-docEsXsM.css.br +0 -0
  54. package/dist/public/assets/{index-CrRxN4us.js → index-ejkbZVVo.js} +1 -1
  55. package/dist/public/assets/{index-wTaBRIal.js → index-wGfWSqnF.js} +1 -1
  56. package/dist/public/assets/index-xPCWyPvk.js +2 -0
  57. package/dist/public/assets/{layers-Bw-W5e-K.js → layers-kzl3dc3j.js} +1 -1
  58. package/dist/public/assets/{list-checks-ClFMgLBy.js → list-checks-Ce0l0Ylc.js} +1 -1
  59. package/dist/public/assets/{sparkles-JXa7CZhS.js → sparkles-Dnyv9lnL.js} +1 -1
  60. package/dist/public/assets/{triangle-alert--wDqk97a.js → triangle-alert-BaPLcm_f.js} +1 -1
  61. package/dist/public/assets/{zap-D27jUGUv.js → zap-DyzOTCOX.js} +1 -1
  62. package/dist/public/index.html +2 -2
  63. package/dist/scripts/dev-client-preview-control-smoke.js +4 -0
  64. package/dist/scripts/dev-remote-resources-smoke.js +8 -0
  65. package/dist/scripts/dev-workflow-smoke.js +15 -1
  66. package/dist/scripts/docs/README.md +19 -0
  67. package/dist/scripts/docs/capture.js +46 -3
  68. package/dist/scripts/docs/check.js +9 -0
  69. package/dist/scripts/docs/privacy-guard.js +74 -0
  70. package/dist/scripts/docs/privacy-guard.test.js +116 -0
  71. package/dist/scripts/docs/render.js +2 -2
  72. package/dist/scripts/docs/scenarios/devtool-guide.mjs +13 -17
  73. package/dist/scripts/language-route.test.js +14 -0
  74. package/dist/scripts/localization-process.test.js +69 -0
  75. package/dist/scripts/removed-features-smoke.js +42 -0
  76. package/dist/scripts/run-ts-test.js +3 -1
  77. package/dist/scripts/skills-process.test.js +48 -0
  78. package/dist/scripts/unity-check-process.test.js +103 -0
  79. package/dist/scripts/unity-report-template.html +148 -0
  80. package/dist/scripts/verify-agent-contract.js +28 -0
  81. package/dist/scripts/verify-locales.js +50 -0
  82. package/dist/scripts/wasm-worker.js +4 -0
  83. package/dist/scripts/worker.js +23 -2
  84. package/dist/scripts/workflow-review-smoke.js +36 -0
  85. package/package.json +21 -15
  86. package/skills/README.md +16 -0
  87. package/vibe-upload.md +4 -4
  88. package/dist/openDataContext/template/open_context.html.hbs +0 -29
  89. package/dist/openDataContext/template/open_context_sdk.js.hbs +0 -16
  90. package/dist/public/assets/Detail-m3nH8XXe.js +0 -1
  91. package/dist/public/assets/Detail-m3nH8XXe.js.br +0 -0
  92. package/dist/public/assets/MonetizationMode-1rShmN0o.js +0 -1
  93. package/dist/public/assets/MonetizationModeSummary-CVfWOth1.js +0 -1
  94. package/dist/public/assets/baseForm-BAvk37jF.css +0 -1
  95. package/dist/public/assets/baseForm-BAvk37jF.css.br +0 -0
  96. package/dist/public/assets/baseForm-C3PqJ30b.js +0 -10
  97. package/dist/public/assets/baseForm-C3PqJ30b.js.br +0 -0
  98. package/dist/public/assets/col-BXewy14r.css +0 -1
  99. package/dist/public/assets/col-BXewy14r.css.br +0 -0
  100. package/dist/public/assets/col-CcZ10DdH.js +0 -1
  101. package/dist/public/assets/index-B0xVTiB7.js +0 -1
  102. package/dist/public/assets/index-B0xVTiB7.js.br +0 -0
  103. package/dist/public/assets/index-BAbIp3cP.js +0 -1
  104. package/dist/public/assets/index-BAbIp3cP.js.br +0 -0
  105. package/dist/public/assets/index-BESASZaa.js +0 -1
  106. package/dist/public/assets/index-BFPQPvSA.css +0 -1
  107. package/dist/public/assets/index-BX17swkm.js +0 -1
  108. package/dist/public/assets/index-BX17swkm.js.br +0 -0
  109. package/dist/public/assets/index-BntW17GH.js +0 -1
  110. package/dist/public/assets/index-BswJGTPK.js +0 -1
  111. package/dist/public/assets/index-BswJGTPK.js.br +0 -0
  112. package/dist/public/assets/index-CQ3yj6IA.js +0 -1
  113. package/dist/public/assets/index-CQ3yj6IA.js.br +0 -0
  114. package/dist/public/assets/index-CYnulX57.css +0 -1
  115. package/dist/public/assets/index-CYnulX57.css.br +0 -0
  116. package/dist/public/assets/index-C_G_C9eS.js +0 -21
  117. package/dist/public/assets/index-C_G_C9eS.js.br +0 -0
  118. package/dist/public/assets/index-Ckp_mJJy.css.br +0 -0
  119. package/dist/public/assets/index-D8BnlF58.js +0 -1
  120. package/dist/public/assets/index-DAY6FKtH.js +0 -1
  121. package/dist/public/assets/index-DKcAZ6VY.js +0 -1
  122. package/dist/public/assets/index-DS5Uafh7.js +0 -1
  123. package/dist/public/assets/index-DdxoW9oQ.js +0 -1
  124. package/dist/public/assets/index-O0yoYI51.js +0 -1
  125. package/dist/public/assets/index-aQ98LrVv.js +0 -1
  126. package/dist/public/assets/index-aQ98LrVv.js.br +0 -0
  127. package/dist/public/assets/index-ivwHgxUB.js.br +0 -0
  128. package/dist/public/assets/index-vlN_-PRJ.css +0 -1
  129. package/src/commands/common/game/categories.test.ts +0 -38
  130. package/src/commands/common/game/categories.ts +0 -48
  131. package/src/commands/common/game/categoryCatalog.json +0 -522
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
- ## Unreleased
1
+ ## 0.4.7 · 2026-11-03
2
2
 
3
- - 本地调试:声明的远程资源通过现有 HTTP 服务的独立路径提供,调试 Meta 下发本地目标及对应域名许可;资源缓存不进入手机上传 ZIP。需要 SDK 配合调试 URL 转换,双端真机结果待验证。
3
+ - Add Japanese and Korean to DevTool, the CLI, and QR-code preview pages. Switching languages preserves the current page and debugging state.
4
+ - Import or export launch configurations and reuse scenes, entry packages, parameters, and developer options in CLI device preview.
5
+ - Use `ttmg upload --check` to run static checks before a standard upload; check errors prevent code-version creation. The option does not support `--vibe`.
6
+ - Use `ttmg preview` to list existing Code Versions and wait for a selected version's preview.
7
+ - Improve capability integration guidance and documentation links. The checklist is guidance and does not replace platform upload or review checks.
8
+ - Improve CLI device-preview connection and update failure guidance. Fix premature preview-wait failures, incorrect upload-history details, and saved subpackage configuration being cleared when collection is canceled.
9
+ - Remove the legacy `--h5` CLI and remote Wasm splitting. Local Wasm splitting and function collection remain available. Native project initialization with `ttmg init` is currently unsupported and returns an error.
10
+
11
+ The opt-in `ttmg check --unity` reports local static evidence; it does not measure runtime performance. `ttmg wasm apply` and `ttmg wasm restore` operate on supported Unity template projects; device validation remains pending. The `ttmg skills list/install` foundation is included, but this package does not bundle a game-development Skill.
4
12
 
5
13
  ## 0.4.6
6
14
 
package/README.md CHANGED
@@ -1,16 +1,22 @@
1
1
  ### @ttmg/cli
2
2
 
3
- 本地调试声明了 `project.config.json.remote_cdn_resources` 的项目时,CLI 将资源保存到本次构建的调试缓存,通过同一 HTTP 端口的 `/game/remote-resources/` 提供文件。IDE 和 CLI 预览的调试 Meta 保留 `base_url` / `resources`,将 `platform_cdn_base_url` 设为设备可访问的本地地址,并在 `allowed_domains` 追加该源站。手机上传 ZIP 不包含这份缓存。需要搭配支持调试 URL 转换的 ttmg-core;SDK 在调试环境中按 `base_url + resources[].root` 匹配并转换到本地地址,调试映射不依赖线上 CDN 实验。
3
+ #### Bundled Skills / 内置 Skills
4
4
 
5
- For projects declaring `project.config.json.remote_cdn_resources`, local debugging serves a build-specific resource cache at `/game/remote-resources/` on the existing HTTP port. Debug Meta preserves `base_url` / `resources`, supplies the reachable local URL as `platform_cdn_base_url`, and adds its origin to `allowed_domains`. The device upload ZIP excludes this cache. This requires ttmg-core support for debug URL rewriting using `base_url + resources[].root`, independently of production CDN experiments.
5
+ `ttmg skills list --format json` lists the Skills shipped with the installed CLI. `ttmg skills install --target <skills-directory>` copies them to an explicitly selected Agent Skills directory. The initial bundle contains no game-development Skills; the command reports an empty bundle until Skills are added. Install is opt-in, preserves identical copies, and reports conflicts instead of overwriting changed files. Selecting a directory and reloading the Agent do not by themselves prove automatic discovery. See [Skills](skills/README.md).
6
+
7
+ `ttmg skills list --format json` 查看当前 CLI 包内的 Skills;`ttmg skills install --target <skills-directory>` 将它们复制到指定的 Agent Skills 目录。首版尚未包含小游戏开发 Skill,加入前命令会明确返回空列表。安装需显式执行;同内容保持不变,不同内容报告冲突,不覆盖已有文件。选择目录或重新加载 Agent 不代表已验证自动发现。详见 [Skills](skills/README.md)。
8
+
9
+ 本地调试声明了 `project.config.json.remote_cdn_resources` 的项目时,CLI 将资源保存到本次构建的调试缓存,通过同一 HTTP 端口的 `/game/remote-resources/` 提供文件。IDE 和 CLI 预览的调试 Meta 保留 `base_url` / `resources`,将 `platform_cdn_base_url` 设为设备可访问的本地地址,并在 `allowed_domains` 追加该源站。手机上传 ZIP 不包含这份缓存。设备端 URL 转换仍取决于 ttmg-core 设置和 CDN 实验开关;Android、iOS 真机尚未验证这条调试链路。
10
+
11
+ For projects declaring `project.config.json.remote_cdn_resources`, local debugging serves a build-specific resource cache at `/game/remote-resources/` on the existing HTTP port. Debug Meta preserves `base_url` / `resources`, supplies the reachable local URL as `platform_cdn_base_url`, and adds its origin to `allowed_domains`. The device upload ZIP excludes this cache. Device URL rewriting still depends on ttmg-core settings and the CDN experiment gate; this debug path has not been verified on Android or iOS devices.
6
12
 
7
13
  普通项目不增加资源缓存或域名;原扫码、WebSocket、端口选择及浏览器 `nodeStaticBaseUrl` 保持。设备资源地址优先使用手机实际连接到的电脑网卡地址。新增缓存只产生本地复制和临时磁盘开销,随构建清理。
8
14
 
9
15
  Projects without a resource declaration retain their existing behavior. QR connection, WebSocket, port selection and the browser's `nodeStaticBaseUrl` are unchanged. Device resource URLs prefer the computer interface used by the phone's connection. The resource cache adds local copying and temporary disk use and is cleaned up with the build.
10
16
 
11
- `0.4.6` 整理了 CDN 远程资源计数、调试文件隔离、结构化命令、真机预览和 Wasm 工具。详细变化见 [CHANGELOG](CHANGELOG.md)。普通平台请求默认使用线上环境;`upload --vibe` 仍是显式启用的 PPE 扫码试用入口。
17
+ `0.4.7` 整理了 CDN 远程资源计数、调试文件隔离、结构化命令、真机预览和 Wasm 工具。详细变化见 [CHANGELOG](CHANGELOG.md)。普通平台请求默认使用线上环境;`upload --vibe` 仍是显式启用的 PPE 扫码试用入口。
12
18
 
13
- Version `0.4.6` includes CDN resource sizing, debug-file isolation, structured commands, device preview and Wasm tools. See the [CHANGELOG](CHANGELOG.md). Ordinary platform requests use production by default; `upload --vibe` remains an opt-in PPE trial.
19
+ Version `0.4.7` includes CDN resource sizing, debug-file isolation, structured commands, device preview and Wasm tools. See the [CHANGELOG](CHANGELOG.md). Ordinary platform requests use production by default; `upload --vibe` remains an opt-in PPE trial.
14
20
 
15
21
  默认总等待时间为 30 分钟,`--timeout <seconds>` 最长可设 60 分钟。页面在任务进行中保持可用,CLI 结束后再保留 30 分钟;失败仍保留上传回执,勿直接重传。页面随浏览器语言显示中英文。
16
22
 
@@ -24,19 +30,19 @@ Tool 试用使用 `--minis-type MINI_TOOL`,仅支持 Native 包、效率办公
24
30
 
25
31
  For the Tool trial, use `--minis-type MINI_TOOL` in a separate project directory. It supports Native packages, Efficiency & Office, US and SDK 1.0.0. Games remain the default (`MINI_GAME`).
26
32
 
27
- `ttmg` is a command-line tool designed for managing and developing mini-game projects. It supports initialization, development, debugging, and packaging for both H5 and native mini-games.
28
- `ttmg` 是一款专为小游戏项目管理与开发设计的命令行工具,支持 H5 小游戏和原生小游戏的初始化、开发调试及打包构建。
33
+ `ttmg` is a command-line tool for developing, debugging, checking, packaging and uploading TikTok mini-game packages. The legacy H5 commands have been removed.
34
+ `ttmg` 用于 TikTok 小游戏运行包的开发调试、检查、构建和上传,旧 H5 命令已移除。
29
35
 
30
36
  #### Installation 安装
31
37
 
32
38
  Vibe 版本支持手机扫码授权上传、可选 `--description`、分类查询及 `--category / --subcategory`。默认描述为 `Discover the fun of TikTok Mini Games.`,默认分类为 Other/Other。完整流程见 [Quick Start](vibe-upload.md)。
33
39
 
34
- 0.4.6 发布准备期间使用本地候选包;正式发布后可按固定版本安装:
40
+ 0.4.7 发布准备期间使用本地候选包;正式发布后可按固定版本安装:
35
41
 
36
42
  During release preparation, install the local candidate tarball. After publication, use the exact version:
37
43
 
38
44
  ```bash
39
- npm install -g @ttmg/cli@0.4.6
45
+ npm install -g @ttmg/cli@0.4.7
40
46
  ttmg --version
41
47
  ttmg capabilities --format json
42
48
  ttmg upload --help
@@ -181,7 +187,7 @@ returned QR once, then submit and observe each update.
181
187
 
182
188
  在已转换的 Native 游戏工程目录调用,使用已有 Client Key。命令在同一执行机
183
189
  运行,执行机与手机须双向可达。启动命令返回后,预览进程继续在后台运行;同一
184
- 工程有配置匹配的预览时会复用。首次扫描返回的二维码,然后逐轮提交更新与读取结果。
190
+ 工程有配置匹配的预览时会复用。复用结果的 `nextAction` 根据实际连接和部署状态提示扫码、等待、更新或处理失败。首次扫描返回的二维码,然后逐轮提交更新与读取结果。
185
191
 
186
192
  ```bash
187
193
  ttmg dev --mode client-preview --update-mode manual --background --client-key <CLIENT_KEY> --record-logs --format json
@@ -205,6 +211,17 @@ ttmg dev session stop <SESSION_ID> --format json
205
211
  - A deployment has a 120-second deadline; shutdown or a new Runtime cancels its
206
212
  network requests. Connecting a new Runtime can redeploy the same captured build
207
213
  without a new request ID or compilation. Query that iteration again afterward.
214
+ - Application metadata/access is checked before resetting the device or uploading.
215
+ Failures include `recovery` (`retryable`, `requiresHuman`, `nextAction`,
216
+ `upstreamStatus`); 403 is `DEV_APP_ACCESS_DENIED`, not a generic Runtime failure.
217
+ Initial setup and updates follow the same device sequence: reset the Runtime,
218
+ send debug settings, upload the package, then deliver Meta.
219
+ - Manual previews add a per-deployment console marker inside the main entry of
220
+ supported private compiled snapshots. `buildExecution.status` is `pending`,
221
+ `confirmed` or `unsupported`; `confirmed` means that entry executed, not that
222
+ the visible game instance, first frame or gameplay passed. The source project,
223
+ watch mode and platform packages are unchanged. Only exact Runtime console calls
224
+ for that deployment/session and after its log cursor count as confirmation.
208
225
  - Log/screenshot results identify the deployment and Runtime and reject changes
209
226
  during collection. The client has no active-build acknowledgment:
210
227
  `runtimeBuildVerified: false`, `attribution: deployment_window`, and
@@ -232,6 +249,13 @@ ttmg dev session stop <SESSION_ID> --format json
232
249
  日志截断时,可将 `nextLogQuery` 交给已有 `dev logs` 命令续读。
233
250
  - 部署设有 120 秒超时;停止会话或切换 Runtime 会取消部署中的网络请求。
234
251
  连接新的 Runtime 可继续部署同一份构建,无须换请求标识或重新编译;之后查询原轮次。
252
+ - 重建设备 Runtime 和传包前先检查应用元信息与访问权限。失败时返回 `recovery`,
253
+ 包含能否重试、是否需要人工、下一动作及上游状态;403 返回 `DEV_APP_ACCESS_DENIED`。
254
+ 初次启动和更新沿用相同顺序:重建 Runtime、发送调试设置、上传代码包,最后下发 Meta。
255
+ - 手动预览在支持的私有编译副本主入口中加入本次部署独有的日志标记。
256
+ `buildExecution.status` 为 `pending / confirmed / unsupported`;确认仅表示入口已执行,
257
+ 不表示当前显示实例、首帧或玩法通过。源码、watch 模式和平台代码包不变;只接受
258
+ 当前部署与 Runtime、且位于部署游标之后的精确 console 调用,不接受旧标记或代码片段。
235
259
  - 结果关联部署与 Runtime,采集中发生变化会拒绝返回。客户端尚无已激活构建确认,
236
260
  因此明确返回 `runtimeBuildVerified: false`、`attribution: deployment_window`
237
261
  和 `gameplayValidation: not_evaluated`。日志可能含部署期间的旧游戏记录,仍需
@@ -246,11 +270,48 @@ ttmg dev session stop <SESSION_ID> --format json
246
270
 
247
271
  ### Wasm prepare and split / Wasm 准备与分包
248
272
 
249
- Prepare compressed Wasm, collect function IDs and split code with the following commands.
250
- 使用以下命令解压 Wasm、采集函数 ID 并完成代码分包。
273
+ Wasm preparation and splitting run locally. Function collection still uses the platform collection service. Remote splitting and its strategy selector have been removed.
274
+ Wasm 准备和分包在本机执行,函数采集仍使用平台采集服务。远程分包及策略选择已移除。
251
275
 
252
276
  #### Platform collection commands / 平台采集命令
253
277
 
278
+ `wasm apply` and `wasm restore` connect isolated outputs to a Unity template project.
279
+ They support `wasmcode/` originals and the template `webgl-wasm-split.js`; split application
280
+ uses the existing archive layout (`wasmcode`, `wasmcode1`, `wasmcode-archive`).
281
+ Stop all DevTool/CLI preview owners before applying or restoring. A detected running preview is rejected.
282
+ Keep the backup outside game assets. Inspect `changes` with `--dry-run` before writing:
283
+
284
+ ```bash
285
+ ttmg wasm apply --manifest .ttmg/wasm/prepared/manifest.json --dir . \
286
+ --wasm-path wasmcode/original.wasm.br --backup ../wasm-prepare-backup --dry-run
287
+ ttmg wasm apply --manifest .ttmg/wasm/prepared/manifest.json --dir . \
288
+ --wasm-path wasmcode/original.wasm.br --backup ../wasm-prepare-backup
289
+ # Use the returned originalWasmPath for collect export and split; the project copy is now instrumented.
290
+ # After collection, stop preview, restore the original, then apply the split manifest using a NEW backup.
291
+ ttmg wasm restore --dir . --backup ../wasm-prepare-backup --dry-run
292
+ ttmg wasm restore --dir . --backup ../wasm-prepare-backup
293
+ ttmg wasm apply --manifest .ttmg/wasm/split/manifest.json --dir . \
294
+ --wasm-path wasmcode/original.wasm.br --backup ../wasm-split-backup --dry-run
295
+ ```
296
+
297
+ Both source identity and artifact hashes must match the manifest. Applying split output also updates
298
+ `game.json`, fills the split configuration and replaces the original Wasm with generated packages.
299
+ The backup stores exact original bytes, generated bytes, a recovery record and `originalWasmPath`.
300
+ Restore checks every target and backup before writing; a developer edit to a target returns `WASM_RESTORE_CONFLICT`.
301
+ Unrelated files are preserved. Writes across multiple files are recoverable, not atomic as a group;
302
+ after an interrupted process, stop every preview/apply owner, remove the empty `wasmcode/.ttmg-apply.lock`
303
+ directory if it remains, and run restore. Keep the backup until phone validation finishes.
304
+ Do not mix this standalone workflow with DevTool's legacy Wasm cache/reset controls.
305
+ Existing manifests without split artifact roles must be regenerated. Custom layouts require manual integration.
306
+ These commands change local files only (`platformWrite: false`); they do not upload, launch a phone,
307
+ measure performance or establish gameplay correctness. `gameValidation` stays `not_evaluated`.
308
+
309
+ 中文:新增 `apply/restore` 将 prepare/split 产物应用到现有 Unity 模板工程,并保留可恢复备份。
310
+ 先停止预览,使用 `--dry-run` 查看变更;备份必须放在游戏目录之外。应用 prepare 后,使用返回的
311
+ `originalWasmPath` 导出采集结果并执行 split;应用 split 前先停止预览、恢复原始工程,再指定新备份目录。
312
+ 源文件不匹配、产物被修改、模板已被替换或恢复目标有后续修改时会失败。此流程与 DevTool 旧缓存重置分开使用,
313
+ 当前只完成本地和组件样本验证,尚待目标游戏真机验证。
314
+
254
315
  Check `commands.wasmCollect` in `ttmg capabilities` for the installed version.
255
316
  The CLI uses its own `ttmg login` session; do not pass or read Cookie values in
256
317
  Agent prompts, arguments or local HTTP requests. No running DevTool server is required.
@@ -288,7 +349,7 @@ these failures. A nonempty collection does not prove gameplay coverage.
288
349
  The commands reuse the existing platform request environment; local fixture
289
350
  tests do not establish real platform or device acceptance.
290
351
 
291
- 安装 `0.4.6-agent-beta.3`,通过 `ttmg capabilities` 中的 `commands.wasmCollect` 确认支持。
352
+ 安装 `0.4.7`,通过 `ttmg capabilities` 中的 `commands.wasmCollect` 确认支持。
292
353
  CLI 内部复用 `ttmg login` 登录态,无需运行 DevTool 本地服务,Agent 不读取或传递 Cookie。
293
354
  按上方命令执行:prepare → 开采集窗口 → 接入插桩副本并扫码、清存储、玩游戏 → export → split。
294
355
  `<MD5>` 使用 prepare 返回的 `input.wasmMd5`,插桩游戏须上报相同的原始 MD5 和 Client Key。
@@ -350,6 +411,54 @@ Native `ttmg build` 的 text 与 JSON 模式现执行相同本地调试构建,
350
411
  text 占位提示;JSON schema 保持版本 1,不创建平台版本。原有自动监听 `dev`
351
412
  和单独日志、截图命令保持可用。
352
413
 
414
+ Existing Code Versions / 已有版本预览:
415
+
416
+ ```bash
417
+ ttmg preview --client-key <CLIENT_KEY> --format json
418
+ ttmg preview --client-key <CLIENT_KEY> --version-id <ASSET_ID> --wait --timeout 120 --serve-preview-page --format json
419
+ ```
420
+
421
+ The first command lists existing version IDs and normalized processing status. The second retrieves
422
+ that version's preview and optionally starts the existing local QR page. Both require Developer Portal login,
423
+ use only platform GET requests and report `platformWrite: false`. Neither uploads a package nor creates a version.
424
+ `--wait` polls within the total timeout (1–600 seconds); `--format ndjson` emits only changed states.
425
+ A `processing` result means the version is not ready yet. Retry with the same ID after interruption or timeout.
426
+ The version must belong to the specified application. Platform and phone verification of this new command is pending.
427
+
428
+ 中文:上传后查询中断时,使用回执中的 `versionId` 继续预览查询,无需再次上传。省略 `--version-id` 可列出已有版本。
429
+ `--wait` 有总超时限制;JSON/NDJSON 结果始终保留应用、版本 ID 和 `platformWrite: false`。
430
+
431
+ Reusable launch configuration / 复用启动配置:
432
+
433
+ Save the following JSON outside the game assets (for example `.ttmg/launch.json`).
434
+ Both developers and Agents can run `ttmg dev --mode client-preview --client-key <CLIENT_KEY> --launch-config .ttmg/launch.json`.
435
+ Add `--update-mode manual --background --format json` for a detached Agent session.
436
+
437
+ ```json
438
+ {
439
+ "schemaVersion": "1",
440
+ "scene": "search",
441
+ "pkgName": "__GAME__",
442
+ "queries": "level=2&source=debug",
443
+ "debugSettings": { "enableAdMock": true, "enableDomainCheck": false }
444
+ }
445
+ ```
446
+
447
+ `scene`, `pkgName` and `queries` use the same meanings as DevTool launch settings.
448
+ Use `__GAME__` for the main package or the name of a declared independent subpackage.
449
+ Omitted fields retain the usual scan/main-package defaults and the five default developer options.
450
+ Supported scenes: `scan_qrcode`, `search`, `fyf_promotion_direct_feed_play`, `anchor`, `center`, `ads`,
451
+ `desktop_shortcut`, `dm_sharing`, `minis_link`, `inbox`. Developer option names:
452
+ `enableAdMock`, `enableIAPMock`, `enableDomainCheck`, `enableVConsole`, `enableDevInfoPanel`.
453
+ Duplicate/reserved query keys, credentials, unknown fields and invalid packages fail before startup.
454
+ `launch.configuration` records the resolved startup configuration; live developer options are read through `dev session status`.
455
+ Background startup freezes the configuration and rejects reuse if it differs. Stop the owner before changing it.
456
+ This option configures the initial scan; it does not restart an already running game. Device validation is pending.
457
+
458
+ 中文:配置文件放在游戏资源之外,例如 `.ttmg/launch.json`;场景、query、主包/独立分包及开发选项沿用 DevTool 含义。
459
+ 结果中的 `launch.configuration` 可读回启动配置,实时开发选项通过 `dev session status` 查询。
460
+ 后台会话只复用配置一致的 owner;切换配置需先停止旧会话。该选项用于首次扫码启动,尚未完成真机验证。
461
+
353
462
  For an Agent-owned iOS client-preview session, opt in explicitly. TikTok must
354
463
  still be opened by a human scanning the generated QR code. The resident `ttmg
355
464
  dev` process then owns the Runtime Debug WebSocket and performs client setup,
@@ -741,6 +850,51 @@ ttmg doctor --dir <game-dir> --format json
741
850
  ttmg doctor --dir <game-dir> --format json --fail-on warning
742
851
  ```
743
852
 
853
+ #### Unity Package Check / Unity 包内检查
854
+
855
+ `--unity` runs a separate, offline package inspection. It does not log in, execute
856
+ game scripts, start a debug session, or modify the source directory. Existing
857
+ `ttmg check` and `ttmg check --ai` keep their behavior; do not combine the modes.
858
+ `--unity` 独立进行离线包内检查,无需登录、不执行游戏脚本、不启动调试、不修改游戏目录;原有检查模式保持不变。
859
+
860
+ ```sh
861
+ ttmg check --unity --dir <game-dir> --format json
862
+ ttmg check --unity --dir <game-dir> --report --no-open --format json
863
+ ttmg check --unity --dir <game-dir> --baseline <previous-report.json> --format json
864
+ ```
865
+
866
+ `--report` writes `report.json`, `report.csv`, `report.html`, and `schema.json` to
867
+ `~/__TTMG__/reports/unity/<operation-id>/` and requests a browser window. Agents
868
+ should add `--no-open`. `--output <new-directory>` selects a new directory outside
869
+ the game root; existing destinations are rejected. JSON stdout is exactly one
870
+ object, also embedded in HTML and used to derive CSV. No HTML scraping is needed.
871
+ `--report` 生成网页、表格、原始 JSON 和结构定义,默认打开网页;Agent 加 `--no-open` 即可无交互执行。指定输出目录必须是游戏目录之外的新目录。三种报告读取同一份结果。
872
+
873
+ The v1 contract includes `schemaVersion`, `rulesetVersion`, a source tree SHA-256,
874
+ stable `ruleId` / `ruleVersion`, status, reason code, hashed file evidence, metrics,
875
+ missing inputs, next actions and documentation. Statuses are `applied`,
876
+ `not_applied`, `partial`, `unknown`, and `not_applicable`. `unknown` means evidence
877
+ is missing or unreadable, never that an optimization is absent. Report status
878
+ `partial` means inspection coverage is incomplete; exit 0 means the scan ran,
879
+ not that the game passed every check. Execution failures exit 1. With
880
+ `--fail-on warning`, observed `not_applied` or `partial` rules also exit 1.
881
+ 状态、原因码、证据位置和下一步均可直接读取;`unknown` 不能解释为“未优化”。退出码 0 表示扫描已执行,是否完整看 `status` 和 `coverage`。
882
+
883
+ This first version parses Brotli Wasm/Data artifacts, embedded Wasm debug sections,
884
+ literal split configuration and matching Android artifact hashes. It inventories
885
+ resource directories but does not infer load timing from their sizes. Asset
886
+ metadata, Unity Editor settings, dependency reports and runtime measurements are
887
+ not yet ingested; affected checks return explicit missing-input requirements.
888
+ 当前可判定压缩、Wasm 内嵌调试段与本地拆分配置;资源布局仅作证据。纹理/音频对象、工程设置、依赖报告和真机数据尚未接入,不沿用历史手工分析结果。
889
+
890
+ Baselines require schema v1 and the same canonical root with complete source
891
+ identity. Changes distinguish resolution, regression, changed evidence and rule
892
+ versions. A changed static result does not establish a performance improvement.
893
+ The scan excludes `.git`, `.ttmg`, `node_modules`, and `__TTMG__`; symlinks are
894
+ skipped and make inventory incomplete. Limits are 5,000 files, 512 MiB total,
895
+ 128 MiB per stored file, 256 MiB per decoded artifact, and a 60-second scan budget.
896
+ 基线对比限定同一 root;跳过链接或解析失败会记录诊断和覆盖缺口,前后扫描发现源文件变化则失败。
897
+
744
898
  #### Structured Build 结构化构建
745
899
 
746
900
  The existing native `ttmg build` default behavior is unchanged. Agents can
@@ -798,7 +952,30 @@ fails, the platform upload remains `ready` and `previewPage.status` is `failed`,
798
952
  so callers must not retry the upload just to recreate the page.
799
953
  NDJSON 状态依次为 `precheck`、`packaging`、`uploading`、`processing`,最终进入 `ready` 或 `failed`。平台处理阶段的 `platformStatus` 使用 `waiting_for_asset`、`pending`、`processing`、`success`、`failed` 等可读值;可选的 `platformStatusRaw` 仅保留平台原始枚举用于排障。成功结果包含 `previewUrl`、与其一致的 `qrPayload`、平台版本地址和 `platformWrite: true`。
800
954
  增加 `--serve-preview-page` 后,每次成功上传都会返回新的 `previewPage.url`。响应式本地页面通过两个二维码和直接链接依次承接测试账号授权与预览启动;HTML 和二维码只驻留内存。同一个 Client Key 反复上传时复用同一个 localhost 服务,新地址会立即替换旧页面并重新计算 1 小时有效期;到期后清除内存中的二维码,原地址继续显示 1 小时的重新执行提示,随后服务退出。不同 Client Key 使用独立服务。默认文本模式会打印浏览器展示信息并自动打开页面,`--no-open` 可关闭自动打开;JSON 和 NDJSON 模式不会调用系统浏览器,而是返回 `preferredAction: "open_url"` 和链接降级方式供 Agent 执行。系统临时目录只保存最小进程协同信息,不写入页面资源或项目内容。如果本地页面失败,平台上传仍保持 `ready`,并通过 `previewPage.status=failed` 返回局部失败;调用方不能为重新生成页面而重复上传。
955
+ # Workflow updates (unreleased)
956
+
957
+ DevTool's launch settings page can import/export `ttmg.launch.json`. It uses the same schema and validation as `ttmg dev --mode client-preview --launch-config ttmg.launch.json`. Scene, independent package, query and developer settings are included; credentials are excluded. Import previews the settings; save applies them. Validate independent packages against the current project. This shares launch settings, not the global account or Client Key defaults.
958
+
959
+ `ttmg init` does not create Native projects. It now reports this explicitly and exits 1. Start from an existing Native package.
960
+
961
+ ```bash
962
+ # Read a checklist, without inspecting or modifying a game.
963
+ ttmg integration --mode iaa --language en-US --format json
964
+
965
+ # Optional code checks on the exact snapshot to be uploaded.
966
+ ttmg upload --dir ./game --client-key YOUR_CLIENT_KEY --check --preview --format ndjson
967
+
968
+ ```
969
+
970
+ The integration checklist shares metadata and translations with the page. Requirement labels describe business integration guidance (`requirementScope: business_guidance`), not verified platform upload or review rules (`platformRequirementsChecked: false`). `conditional` means the capability depends on the game's needs; this includes IAA business login and revisit features. Platform Login API upload checks are separate and are not waived by the checklist. Static detection does not prove login, ads or payments work. `verification: not_evaluated` remains until tested separately.
971
+
972
+ Default upload's precheck covers local login, application access and the source directory; it does not run code checks. `--check` opts into the existing static code checks on an isolated package snapshot; errors block version creation, warnings remain visible. The check report and `packageArtifact.sha256` identify the bytes associated with `versionId`. The ZIP hash is not proof that a device ran the game. `--check` is not supported by `--vibe`. Checked upload rejects symlinks and special files; original source files are not modified. Existing version lookup still uses `ttmg preview`.
973
+ ### Language
974
+
975
+ DevTool, CLI messages, integration checklists and scan/preview pages support English (`en-US`), Simplified Chinese (`zh-CN`), Japanese (`ja-JP`) and Korean (`ko-KR`).
976
+
977
+ Use the language menu in DevTool, or run `ttmg setup --lang ja-JP` / `ttmg setup --lang ko-KR`. You can also use `ttmg config set lang ja-JP` or `ttmg config set lang ko-KR`. The choice is saved for subsequent runs. Scan pages for local client preview use the CLI preference; upload authorization and platform preview pages follow the browser language.
978
+
979
+ The IDE updates the current page immediately without reloading it. Navigation, options and known status messages follow the selected language; unsaved form values and the current route remain in place. Rapid language choices are saved to the CLI in order. If saving fails, the page keeps the selected language and shows a retry message. Use Enter to open the language menu and Escape to close it; selecting a language closes the menu.
801
980
 
802
- - 调试 H5 小游戏:
803
- - To debug H5 mini-games:
804
- ttmg dev --h5
981
+ Command names, option names, JSON fields, statuses, error codes, user-entered game metadata and Runtime log contents are preserved. For example, `ttmg integration --mode iaa --language ko-KR --format json` localizes checklist text while keeping the JSON schema unchanged.