@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
@@ -0,0 +1,116 @@
1
+ const { test } = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const http = require('http');
4
+ const fs = require('fs');
5
+ const os = require('os');
6
+ const path = require('path');
7
+ const { spawn, spawnSync } = require('child_process');
8
+ const { createRedactionExpression, validateOrigin, validateRequirements } = require('./privacy-guard');
9
+
10
+ const requirements = Object.fromEntries(['avatar', 'email', 'token', 'qr'].map(name => [name, {
11
+ selector: `[data-doc-private="${name}"]`, expected: 'present',
12
+ }]));
13
+ const recipe = {
14
+ id: 'synthetic', route: '/?docMode=1&docScenario=synthetic',
15
+ viewport: { width: 600, height: 450 },
16
+ waitFor: { selector: '[data-doc-private="avatar"]', timeoutMs: 5000 },
17
+ privacy: { policy: 'fixture-markers-v1', requirements },
18
+ };
19
+
20
+ function run(file, args, cwd) {
21
+ return new Promise((resolve, reject) => {
22
+ const child = spawn(process.execPath, [file, ...args], { cwd, env: process.env });
23
+ let output = '';
24
+ child.stdout.on('data', data => { output += data; });
25
+ child.stderr.on('data', data => { output += data; });
26
+ child.on('error', reject);
27
+ child.on('close', code => resolve({ code, output }));
28
+ });
29
+ }
30
+
31
+ test('requires a local fixture and every explicit privacy marker', () => {
32
+ assert.throws(() => validateOrigin('https://example.com'));
33
+ assert.throws(() => validateOrigin('http://127.0.0.1:5000/path'));
34
+ assert.throws(() => validateRequirements({ ...recipe, privacy: { masks: ['avatar'] } }));
35
+ assert.throws(() => validateRequirements({ ...recipe, route: '/?docMode=0&docScenario=synthetic' }));
36
+ assert.throws(() => createRedactionExpression('http://127.0.0.1:5000', {
37
+ ...recipe, privacy: { ...recipe.privacy, requirements: { ...requirements, token: undefined } },
38
+ }));
39
+ });
40
+
41
+ test('capture masks a synthetic page, and freshness check rejects tampered and legacy images', async () => {
42
+ const html = `<!doctype html><style>body{margin:0;font:16px sans-serif}.secret{position:absolute;width:120px;height:50px;background:white;color:black}.token:before{content:'synthetic token'}</style>
43
+ <div class="secret" data-doc-private="avatar" style="top:30px;left:30px">FAKE AVATAR</div>
44
+ <div class="secret" data-doc-private="email" style="top:100px;left:30px">fixture@example.test</div>
45
+ <div class="secret token" data-doc-private="token" style="top:170px;left:30px"></div>
46
+ <svg data-doc-private="qr" style="position:absolute;top:240px;left:30px;width:120px;height:50px;background:white"><text y="25">FAKE QR</text></svg>
47
+ <p style="position:absolute;top:330px">Synthetic fixture used only for screenshot privacy tests.</p>`;
48
+ let currentHtml = html;
49
+ let redirectFixture = false;
50
+ const server = http.createServer((req, res) => {
51
+ if (redirectFixture && req.url.includes('docScenario=synthetic')) {
52
+ res.writeHead(302, { location: '/?docMode=1&docScenario=wrong' });
53
+ res.end();
54
+ return;
55
+ }
56
+ res.setHeader('content-type', 'text/html'); res.end(currentHtml);
57
+ });
58
+ await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
59
+ const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'ttmg-docs-privacy-'));
60
+ try {
61
+ const origin = `http://127.0.0.1:${server.address().port}`;
62
+ const recipes = path.join(temp, 'recipes.mjs');
63
+ const output = path.join(temp, 'out');
64
+ const setRecipe = current => fs.writeFileSync(recipes, `export const schemaVersion=1; export const locales=['en-US']; export const guideTitle='Synthetic'; export const recipes=${JSON.stringify([current])};`);
65
+ setRecipe({ ...recipe, privacy: { masks: ['avatar'] } });
66
+ fs.mkdirSync(output);
67
+ fs.writeFileSync(path.join(output, 'capture-report.json'), '{}');
68
+ const args = [`--base-url=${origin}`, `--recipes=${recipes}`, `--output-dir=${output}`];
69
+ let result = await run(path.join(__dirname, 'capture.js'), args, temp);
70
+ assert.notEqual(result.code, 0);
71
+ assert.match(result.output, /Missing fixture-markers-v1/);
72
+ assert.equal(fs.existsSync(path.join(output, 'capture-report.json')), false);
73
+ assert.deepEqual(fs.readdirSync(path.join(output, 'assets')), []);
74
+
75
+ setRecipe(recipe);
76
+ currentHtml = html.replace('data-doc-private="qr"', 'data-not-marked="qr"');
77
+ result = await run(path.join(__dirname, 'capture.js'), args, temp);
78
+ assert.notEqual(result.code, 0);
79
+ assert.match(result.output, /Privacy redaction failed/);
80
+ assert.equal(fs.existsSync(path.join(output, 'capture-report.json')), false);
81
+ assert.deepEqual(fs.readdirSync(path.join(output, 'assets')), []);
82
+
83
+ currentHtml = html;
84
+ redirectFixture = true;
85
+ result = await run(path.join(__dirname, 'capture.js'), args, temp);
86
+ assert.notEqual(result.code, 0);
87
+ assert.match(result.output, /Privacy redaction failed/);
88
+ assert.equal(fs.existsSync(path.join(output, 'capture-report.json')), false);
89
+ assert.deepEqual(fs.readdirSync(path.join(output, 'assets')), []);
90
+
91
+ redirectFixture = false;
92
+ result = await run(path.join(__dirname, 'capture.js'), args, temp);
93
+ assert.equal(result.code, 0, result.output);
94
+ const reportPath = path.join(output, 'capture-report.json');
95
+ const report = JSON.parse(fs.readFileSync(reportPath));
96
+ const image = path.join(output, report.screenshots[0].path);
97
+ assert.deepEqual(report.screenshots[0].privacy.counts, { avatar: 1, email: 1, token: 1, qr: 1 });
98
+ const pixels = spawnSync('python3', ['-c', `from PIL import Image\nimport sys\nim=Image.open(sys.argv[1]).convert('RGB')\nfor y in (31,55,79,101,125,149,171,195,219,241,265,289):\n for x in (31,90,149): assert im.getpixel((x,y)) == (63,69,73)\nassert im.getpixel((5,5)) != (63,69,73)`, image], { encoding: 'utf8' });
99
+ assert.equal(pixels.status, 0, pixels.stderr);
100
+ const checkArgs = [`--recipes=${recipes}`, `--output-dir=${output}`];
101
+ result = await run(path.join(__dirname, 'check.js'), checkArgs, temp);
102
+ assert.equal(result.code, 0, result.output);
103
+ fs.appendFileSync(image, 'tampered');
104
+ result = await run(path.join(__dirname, 'check.js'), checkArgs, temp);
105
+ assert.notEqual(result.code, 0);
106
+ assert.match(result.output, /changed after capture/);
107
+ delete report.screenshots[0].privacy;
108
+ fs.writeFileSync(reportPath, JSON.stringify(report));
109
+ result = await run(path.join(__dirname, 'check.js'), checkArgs, temp);
110
+ assert.notEqual(result.code, 0);
111
+ assert.match(result.output, /Missing privacy redaction evidence/);
112
+ } finally {
113
+ await new Promise(resolve => server.close(resolve));
114
+ fs.rmSync(temp, { recursive: true, force: true });
115
+ }
116
+ });
@@ -314,7 +314,7 @@ function renderGettingStarted(locale, sectionIndex) {
314
314
  renderCommand({
315
315
  title: '安装调试工具',
316
316
  description: '在小游戏项目目录中安装并使用 `ttmg` CLI。安装完成后,后续调试、登录、配置和上传发布都通过这个工具进入。',
317
- command: 'npm install -g @ttmg/cli@0.4.4-beta.1 --registry=https://registry.npmjs.org/',
317
+ command: 'npm install -g @ttmg/cli --registry=https://registry.npmjs.org/',
318
318
  }),
319
319
  renderCommand({
320
320
  title: '登录开发账号',
@@ -343,7 +343,7 @@ function renderGettingStarted(locale, sectionIndex) {
343
343
  renderCommand({
344
344
  title: 'Install the Debugging Tool',
345
345
  description: 'Install and use the `ttmg` CLI in your mini-game project. Debugging, sign-in, configuration, and upload flows all start from this tool.',
346
- command: 'npm install -g @ttmg/cli@0.4.4-beta.1 --registry=https://registry.npmjs.org/',
346
+ command: 'npm install -g @ttmg/cli --registry=https://registry.npmjs.org/',
347
347
  }),
348
348
  renderCommand({
349
349
  title: 'Sign in with a Developer Account',
@@ -112,7 +112,7 @@ export const screenshotInventory = [
112
112
  recipeId: 'subpackage-collect',
113
113
  guideSection: 'Performance optimization',
114
114
  publishInGuide: true,
115
- purpose: 'pending-open subpackage collection entry and requirements',
115
+ purpose: 'subpackage collection entry and requirements',
116
116
  },
117
117
  {
118
118
  id: 'subpackage.collecting',
@@ -185,8 +185,8 @@ const zhFaqs = [
185
185
  {
186
186
  question: 'Unity 和非 Unity 的分包能力有什么区别?',
187
187
  answer: [
188
- '子包收集目前是待开放功能,正式开放前不要把它作为通用 DevTool 链路使用;Unity 小游戏仍使用 Wasm 分包链路。',
189
- '后续子包收集开放后,会面向非 Unity 小游戏采集启动阶段预下载的子包,并转换为预加载配置。',
188
+ '子包收集面向符合使用条件的非 Unity 小游戏;Unity 小游戏使用 Wasm 分包链路。',
189
+ '子包收集采集真实启动路径中的子包,并转换为预加载配置。',
190
190
  'Unity 由于 wasmcode 形态暂不能完整预先检查,当前仍需要继续调研并关注页面里的 Wasm Code Split 提示。',
191
191
  ],
192
192
  },
@@ -226,8 +226,8 @@ const enFaqs = [
226
226
  {
227
227
  question: 'How are Unity and non-Unity subpackage flows different?',
228
228
  answer: [
229
- 'Subpackage Collection is currently a coming-soon feature and should not be treated as a general DevTool workflow before it is officially opened. Unity mini games should still use the Wasm Split flow.',
230
- 'After Subpackage Collection is opened, it will target non-Unity mini games and collect subpackages downloaded during startup for preload configuration.',
229
+ 'Subpackage Collection supports non-Unity mini games that meet the prerequisites. Unity mini games use the Wasm Split flow.',
230
+ 'Subpackage Collection records subpackages from a real startup path and generates preload configuration.',
231
231
  'Because Unity uses wasmcode, full precheck is not available yet and still needs investigation. Watch the Wasm Code Split prompts on the page.',
232
232
  ],
233
233
  },
@@ -732,38 +732,34 @@ export const recipes = [
732
732
  ],
733
733
  notes: notes(
734
734
  {
735
- title: '子包收集(待开放)',
736
- purpose: '正式开放后,DevTool 会记录真实启动过程中被预下载的子包,并把结果转换为预加载配置,帮助非 Unity 小游戏减少首屏等待。',
737
- whenToUse: '当前用于提前了解功能入口、适用范围和未来操作流程;正式开放后,非 Unity 小游戏可在需要优化冷启动时使用。',
735
+ title: '子包收集',
736
+ purpose: 'DevTool 记录真实启动过程中被预下载的子包,并把结果转换为预加载配置,帮助非 Unity 小游戏减少首屏等待。',
737
+ whenToUse: '符合使用条件的非 Unity 小游戏需要优化冷启动时使用。',
738
738
  steps: [
739
- '等待功能正式开放;当前页面仅用于预览能力和接入要求。',
740
- '开放后,在「性能优化」中进入「收集子包」。',
739
+ '在「性能优化」中进入「收集子包」。',
741
740
  '开始收集前,在游戏代码中接入 `TTMinis.game.reportScene`,并在可交互时传入 `sceneId: 9999`。',
742
741
  '确认手机 TikTok 登录的是非 US 地区账号。',
743
742
  '扫码后按真实启动路径操作游戏。',
744
743
  '调试页面收到 `reportScene({sceneId:9999})` 后,检查结果并完成收集。',
745
744
  ],
746
745
  keyChecks: [
747
- '当前是待开放功能,不能作为正式生产流程使用。',
748
746
  '`reportScene({sceneId:9999})` 是代码必接项;未收到上报时不能完成收集。',
749
747
  'US 账号无法收集函数,需要直接提示。',
750
748
  'Unity 小游戏不支持该收集链路。',
751
749
  ],
752
750
  },
753
751
  {
754
- title: 'Subpackage Collection (Coming Soon)',
755
- purpose: 'After release, DevTool will record subpackages downloaded during a real startup run and convert the result into preload configuration to reduce first-screen waiting for non-Unity mini games.',
756
- whenToUse: 'Use the current page to preview the entry, scope, and future workflow. After official release, non-Unity mini games can use it for cold-start optimization.',
752
+ title: 'Subpackage Collection',
753
+ purpose: 'DevTool records subpackages downloaded during a real startup run and converts the result into preload configuration for non-Unity mini games.',
754
+ whenToUse: 'Use it for cold-start optimization in non-Unity mini games that meet the prerequisites.',
757
755
  steps: [
758
- 'Wait for the feature to be officially released. The current page is a preview of the capability and requirements.',
759
- 'After release, open Subpackage Collection from Performance optimization.',
756
+ 'Open Subpackage Collection from Performance optimization.',
760
757
  'Before collection, integrate `TTMinis.game.reportScene` in the game code and pass `sceneId: 9999` when the game becomes interactive.',
761
758
  'Confirm that TikTok on the phone is signed in with a non-US account.',
762
759
  'Scan and operate the game through the real startup path.',
763
760
  'After the debug page receives `reportScene({sceneId:9999})`, review the result and finish collection.',
764
761
  ],
765
762
  keyChecks: [
766
- 'This feature is coming soon and is not yet a production workflow.',
767
763
  '`reportScene({sceneId:9999})` is required in game code; collection cannot finish until the report is received.',
768
764
  'US accounts cannot collect functions and must be called out directly.',
769
765
  'Unity mini-games are not supported by this collection flow.',
@@ -0,0 +1,14 @@
1
+ const fs = require('node:fs');
2
+ const os = require('node:os');
3
+ const path = require('node:path');
4
+ const { spawnSync } = require('node:child_process');
5
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'ttmg-language-route-'));
6
+ try {
7
+ const result = spawnSync(process.execPath, [path.join(__dirname, 'run-ts-test.js'),
8
+ 'src/commands/native/dev/server/routes/game-language.test.ts'], {
9
+ cwd: path.resolve(__dirname, '..'),
10
+ env: { ...process.env, TTMGRC_PATH: path.join(directory, 'config.json') },
11
+ stdio: 'inherit', timeout: 30000,
12
+ });
13
+ process.exitCode = result.status ?? 1;
14
+ } finally { fs.rmSync(directory, { recursive: true, force: true }); }
@@ -0,0 +1,69 @@
1
+ const assert = require('node:assert/strict');
2
+ const fs = require('node:fs');
3
+ const os = require('node:os');
4
+ const path = require('node:path');
5
+ const { spawnSync } = require('node:child_process');
6
+ const cli = process.env.TTMG_TEST_CLI || path.resolve(__dirname, '../dist/index.js');
7
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'ttmg-localization-'));
8
+ const rc = path.join(directory, 'config.json');
9
+ const run = args => {
10
+ const result = spawnSync(process.execPath, [cli, ...args], {
11
+ cwd: directory,
12
+ env: { ...process.env, TTMGRC_PATH: rc, NO_COLOR: '1' },
13
+ encoding: 'utf8', timeout: 30000,
14
+ });
15
+ assert.equal(result.status, 0, `${args.join(' ')}: ${result.stderr}`);
16
+ return result;
17
+ };
18
+ try {
19
+ fs.writeFileSync(rc, JSON.stringify({ clientKey: 'preserved-test-key' }));
20
+ const project = path.join(directory, 'game');
21
+ fs.mkdirSync(project);
22
+ fs.writeFileSync(path.join(project, 'game.json'), '{}');
23
+ fs.writeFileSync(path.join(project, 'game.js'), 'console.log("localization fixture");');
24
+ for (const language of ['ja-JP', 'ko-KR']) {
25
+ const glyphs = language === 'ja-JP' ? /[\u3040-\u30ff]/ : /[\uac00-\ud7af]/;
26
+ assert.match(run(['setup', '--lang', language]).stdout, glyphs);
27
+ const config = JSON.parse(fs.readFileSync(rc, 'utf8'));
28
+ assert.equal(config.lang, language);
29
+ assert.equal(config.clientKey, 'preserved-test-key');
30
+ assert.match(run(['--help']).stdout, glyphs);
31
+ const configured = run(['config', 'set', 'lang', language]);
32
+ assert.match(configured.stdout + configured.stderr, glyphs);
33
+ const capabilities = JSON.parse(run(['capabilities', '--format', 'json']).stdout);
34
+ assert.equal(capabilities.command, 'capabilities');
35
+ assert.ok(capabilities.commands.integration.languages.includes(language));
36
+ const checklist = JSON.parse(run(['integration', '--mode', 'iaa', '--format', 'json']).stdout);
37
+ assert.equal(checklist.language, language);
38
+ assert.equal(checklist.platformWrite, false);
39
+ assert.equal(checklist.status, 'succeeded');
40
+ assert.match(checklist.capabilities[0].title, glyphs);
41
+ const checked = JSON.parse(run(['check', '--dir', project, '--format', 'json', '--include-passed']).stdout);
42
+ assert.equal(checked.summary.errors, 0);
43
+ assert.ok(checked.diagnostics.some(item => glyphs.test(item.message)), 'pack diagnostics localized');
44
+ assert.ok(checked.diagnostics.every(item => item.code.startsWith('TTMG_CHECK_')), 'diagnostic codes preserved');
45
+ }
46
+ const en = run(['setup', '--lang', 'en-US']);
47
+ assert.match(en.stdout, /en-US/);
48
+ console.log('Built CLI Japanese/Korean setup, persisted config, help and structured output passed.');
49
+ } finally { fs.rmSync(directory, { recursive: true, force: true }); }
50
+
51
+ async function verifyWorkerLanguage() {
52
+ const { Worker } = require('node:worker_threads');
53
+ for (const language of ['ja-JP', 'ko-KR']) {
54
+ const worker = new Worker(path.join(path.dirname(cli), 'scripts/worker.js'), { stdout: true, stderr: true });
55
+ try {
56
+ const message = await new Promise((resolve, reject) => {
57
+ const timer = setTimeout(() => reject(new Error('Worker language timeout')), 10000);
58
+ worker.once('error', error => { clearTimeout(timer); reject(error); });
59
+ worker.once('message', value => { clearTimeout(timer); resolve(value); });
60
+ // Missing clientKey returns before building or writing files.
61
+ worker.postMessage({ type: 'compile', context: { lang: language } });
62
+ });
63
+ assert.equal(message.type, 'error');
64
+ assert.match(message.error, language === 'ja-JP' ? /[\u3040-\u30ff]/ : /[\uac00-\ud7af]/);
65
+ } finally { await worker.terminate(); }
66
+ }
67
+ console.log('Built compile worker Japanese/Korean error messages passed.');
68
+ }
69
+ verifyWorkerLanguage().catch(error => { console.error(error); process.exitCode = 1; });
@@ -0,0 +1,42 @@
1
+ const assert = require('node:assert/strict');
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+ const os = require('node:os');
5
+ const { spawnSync } = require('node:child_process');
6
+ const entry = path.resolve(__dirname, '../dist/index.js');
7
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ttmg-removed-features-'));
8
+ const run = args => spawnSync(process.execPath, [entry, ...args], {
9
+ cwd: root, encoding: 'utf8', timeout: 10000,
10
+ env: { ...process.env, TTMGRC_PATH: path.join(root, 'rc.json'), NO_COLOR: '1' },
11
+ });
12
+ try {
13
+ fs.writeFileSync(path.join(root, 'index.html'), '<html>unchanged</html>');
14
+ fs.writeFileSync(path.join(root, 'game.js'), 'console.log("unchanged");');
15
+ fs.writeFileSync(path.join(root, 'game.json'), '{}');
16
+ const before = fs.readdirSync(root).map(name => [name, fs.readFileSync(path.join(root, name), 'utf8')]);
17
+ for (const args of [['--h5', 'init'], ['init', '--h5'], ['dev', '--h5'], ['build', '--h5'],
18
+ ['--h5', 'dev', '--format', 'json'], ['dev', 'logs', '--h5'], ['dev', 'sync', '--h5']]) {
19
+ const result = run(args);
20
+ assert.equal(result.status, 1, JSON.stringify({ args, error: result.stderr }));
21
+ assert.match(result.stderr, /unknown option '--h5'/);
22
+ assert.deepEqual(fs.readdirSync(root).map(name => [name, fs.readFileSync(path.join(root, name), 'utf8')]), before);
23
+ }
24
+ for (const args of [[], ['init'], ['dev'], ['build']]) {
25
+ const result = run([...args, '--help']);
26
+ assert.equal(result.status, 0);
27
+ assert.doesNotMatch(result.stdout, /--h5/);
28
+ }
29
+ const result = run(['capabilities', '--format', 'json']);
30
+ assert.equal(result.status, 0);
31
+ assert.equal(result.stdout.trim().split('\n').length, 1);
32
+ const caps = JSON.parse(result.stdout);
33
+ assert.equal(caps.commands.wasm.execution, 'local');
34
+ assert.deepEqual(caps.removedFeatures, { h5Cli: true, wasmRemoteSplit: true });
35
+ const assets = path.join(__dirname, '../dist/public/assets');
36
+ for (const file of fs.readdirSync(assets).filter(file => file.endsWith('.js'))) {
37
+ assert.doesNotMatch(fs.readFileSync(path.join(assets, file), 'utf8'),
38
+ /wasmSplit\.mode\.remote|remotePreparing\.|\/game\/pipeline-mode|stark_wasm\/v4/);
39
+ }
40
+ assert.equal(fs.existsSync(path.join(__dirname, '../dist/openDataContext')), false);
41
+ console.log('Removed feature process checks passed: H5 rejection without project writes; local-only Wasm capability and UI assets.');
42
+ } finally { fs.rmSync(root, { recursive: true, force: true }); }
@@ -20,7 +20,7 @@ try {
20
20
  format: 'cjs',
21
21
  target: 'node20',
22
22
  outfile: outputFile,
23
- external: ['esbuild'],
23
+ external: ['esbuild', '@anrans001/ttmg-wasmtool'],
24
24
  sourcemap: 'inline',
25
25
  logLevel: 'warning',
26
26
  });
@@ -28,6 +28,8 @@ try {
28
28
  stdio: 'inherit',
29
29
  env: {
30
30
  ...process.env,
31
+ // Unit tests must not read or mutate the developer's active CLI profile.
32
+ TTMGRC_PATH: process.env.TTMGRC_PATH || path.join(tempDir, 'config.json'),
31
33
  NODE_PATH: [
32
34
  path.resolve(process.cwd(), 'node_modules'),
33
35
  process.env.NODE_PATH,
@@ -0,0 +1,48 @@
1
+ const assert = require('node:assert/strict');
2
+ const { spawnSync } = require('node:child_process');
3
+ const fs = require('node:fs');
4
+ const os = require('node:os');
5
+ const path = require('node:path');
6
+
7
+ const cliRoot = path.resolve(__dirname, '..');
8
+ const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'ttmg-skills-package-'));
9
+
10
+ function run(command, args, options = {}) {
11
+ const result = spawnSync(command, args, { encoding: 'utf8', ...options });
12
+ assert.equal(result.status, 0, result.stderr || result.stdout);
13
+ return result.stdout;
14
+ }
15
+
16
+ try {
17
+ const packed = JSON.parse(run('npm', ['pack', '--ignore-scripts', '--json', '--pack-destination', temp], { cwd: cliRoot }))[0];
18
+ assert.ok(packed.files.some(file => file.path === 'skills/README.md'), 'npm tarball omits the skills directory');
19
+ run('tar', ['-xzf', path.join(temp, packed.filename), '-C', temp]);
20
+ const installed = path.join(temp, 'package');
21
+ // Use the checkout's already-installed dependencies; this does not simulate npm install.
22
+ fs.symlinkSync(path.join(cliRoot, 'node_modules'), path.join(installed, 'node_modules'), 'dir');
23
+ const entry = path.join(installed, 'dist', 'index.js');
24
+ const invoke = (args, expected = 0) => {
25
+ const r = spawnSync(process.execPath, [entry, ...args, '--format', 'json'], { encoding: 'utf8', cwd: temp });
26
+ assert.equal(r.status, expected, r.stderr || r.stdout);
27
+ assert.equal(r.stdout.trim().split(/\r?\n/).length, 1, 'expected exactly one JSON line');
28
+ return JSON.parse(r.stdout);
29
+ };
30
+ const existing = invoke(['skills', 'list']);
31
+ assert.ok(['empty', 'ready'].includes(existing.status));
32
+ assert.ok(!existing.skills.includes('fixture-skill-for-test'), 'fixture name is reserved for this test');
33
+ const fixture = path.join(installed, 'skills', 'fixture-skill-for-test');
34
+ fs.mkdirSync(path.join(fixture, 'references'), { recursive: true });
35
+ fs.writeFileSync(path.join(fixture, 'SKILL.md'), '---\nname: fixture-skill-for-test\ndescription: Test fixture only\n---\n');
36
+ fs.writeFileSync(path.join(fixture, 'references', 'example.md'), 'sample');
37
+ assert.ok(invoke(['skills', 'list']).skills.includes('fixture-skill-for-test'));
38
+ const target = path.join(temp, 'developer', 'skills');
39
+ assert.ok(invoke(['skills', 'install', '--target', target]).installed.includes('fixture-skill-for-test'));
40
+ assert.ok(invoke(['skills', 'install', '--target', target]).unchanged.includes('fixture-skill-for-test'));
41
+ const destination = path.join(target, 'fixture-skill-for-test', 'SKILL.md');
42
+ fs.writeFileSync(destination, 'developer change');
43
+ assert.equal(invoke(['skills', 'install', '--target', target], 1).errorCode, 'SKILLS_DESTINATION_CONFLICT');
44
+ assert.equal(fs.readFileSync(destination, 'utf8'), 'developer change');
45
+ console.log('skills tarball and CLI process tests passed');
46
+ } finally {
47
+ fs.rmSync(temp, { recursive: true, force: true });
48
+ }
@@ -0,0 +1,103 @@
1
+ const assert = require('node:assert/strict');
2
+ const fs = require('node:fs');
3
+ const os = require('node:os');
4
+ const path = require('node:path');
5
+ const { spawnSync } = require('node:child_process');
6
+ const { brotliCompressSync } = require('node:zlib');
7
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ttmg-unity-process-'));
8
+ const game = path.join(root, 'game');
9
+ fs.mkdirSync(game);
10
+ const entry = path.resolve(__dirname, '../dist/index.js');
11
+ const run = args =>
12
+ spawnSync(process.execPath, [entry, 'check', ...args], {
13
+ encoding: 'utf8',
14
+ timeout: 30000,
15
+ env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' },
16
+ });
17
+ try {
18
+ fs.writeFileSync(path.join(game, 'game.json'), '{"gameEngine":"unity"}');
19
+ fs.writeFileSync(
20
+ path.join(game, 'game.js'),
21
+ 'throw new Error("Do not execute");',
22
+ );
23
+ fs.writeFileSync(
24
+ path.join(game, 'webgl-wasm-split.js'),
25
+ 'module.exports={enableWasmSplit:false};',
26
+ );
27
+ fs.writeFileSync(
28
+ path.join(game, 'main.wasm.br'),
29
+ brotliCompressSync(Buffer.from([0, 97, 115, 109, 1, 0, 0, 0])),
30
+ );
31
+ fs.writeFileSync(
32
+ path.join(game, 'main.data.br'),
33
+ brotliCompressSync(Buffer.from('data')),
34
+ );
35
+ const args = ['--unity', '--dir', game, '--format', 'json'];
36
+ const first = run([
37
+ ...args,
38
+ '--report',
39
+ '--no-open',
40
+ '--output',
41
+ path.join(root, 'first'),
42
+ ]);
43
+ assert.equal(first.status, 0, first.stderr || first.stdout);
44
+ const report = JSON.parse(first.stdout);
45
+ assert.equal(first.stdout.trim().split('\n').length, 1);
46
+ assert.equal(report.status, 'partial');
47
+ assert.equal(report.browser, 'not_requested');
48
+ assert.equal(report.sourceModified, false);
49
+ assert.deepEqual(
50
+ JSON.parse(fs.readFileSync(report.artifacts.json, 'utf8')),
51
+ report,
52
+ );
53
+ const html = fs.readFileSync(report.artifacts.html, 'utf8');
54
+ assert.deepEqual(
55
+ JSON.parse(
56
+ html.match(
57
+ /<script id="report-data" type="application\/json">(.*?)<\/script>/s,
58
+ )[1],
59
+ ),
60
+ report,
61
+ );
62
+ const second = run([...args, '--baseline', report.artifacts.json]);
63
+ assert.equal(second.status, 0, second.stderr);
64
+ assert.deepEqual(JSON.parse(second.stdout).comparison.changes, []);
65
+ const strict = run([...args, '--fail-on', 'warning']);
66
+ assert.equal(strict.status, 1);
67
+ assert.equal(JSON.parse(strict.stdout).status, 'partial');
68
+ for (const extras of [
69
+ ['--ai'],
70
+ ['--output', path.join(root, 'unused')],
71
+ ['--report', '--no-open', '--output', path.join(game, 'report')],
72
+ ]) {
73
+ const failure = run([...args, ...extras]);
74
+ assert.equal(failure.status, 1);
75
+ assert.equal(JSON.parse(failure.stdout).status, 'failed');
76
+ }
77
+ const missing = run([
78
+ '--unity',
79
+ '--dir',
80
+ path.join(root, 'missing'),
81
+ '--format',
82
+ 'json',
83
+ ]);
84
+ assert.equal(missing.status, 1);
85
+ assert.equal(
86
+ JSON.parse(missing.stdout).errorCode,
87
+ 'UNITY_DIRECTORY_NOT_FOUND',
88
+ );
89
+ const modeMissing = run(['--report', '--format', 'json']);
90
+ assert.equal(modeMissing.status, 1);
91
+ assert.equal(
92
+ JSON.parse(modeMissing.stdout).errorCode,
93
+ 'INVALID_UNITY_OPTIONS',
94
+ );
95
+ const unknown = run([...args, '--unrecognized-unity-flag']);
96
+ assert.notEqual(unknown.status, 0);
97
+ assert.equal(fs.existsSync(path.join(game, 'report')), false);
98
+ console.log(
99
+ 'Unity CLI process: one JSON object, exports, baseline, exit codes and invalid options passed.',
100
+ );
101
+ } finally {
102
+ fs.rmSync(root, { recursive: true, force: true });
103
+ }