xstudio-linux 0.0.0-stage → 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.
Files changed (222) hide show
  1. package/CHANGELOG.md +469 -0
  2. package/LICENSE +31 -0
  3. package/README.md +542 -2
  4. package/dist/adapter-cli/cli.d.ts +28 -0
  5. package/dist/adapter-cli/cli.js +233 -0
  6. package/dist/adapter-cli/cli.js.map +1 -0
  7. package/dist/adapter-mcp/server.d.ts +81 -0
  8. package/dist/adapter-mcp/server.js +473 -0
  9. package/dist/adapter-mcp/server.js.map +1 -0
  10. package/dist/config.d.ts +45 -0
  11. package/dist/config.js +78 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/core/catalog/pronunciation.d.ts +47 -0
  14. package/dist/core/catalog/pronunciation.js +402 -0
  15. package/dist/core/catalog/pronunciation.js.map +1 -0
  16. package/dist/core/catalog/singers.d.ts +46 -0
  17. package/dist/core/catalog/singers.js +122 -0
  18. package/dist/core/catalog/singers.js.map +1 -0
  19. package/dist/core/contracts.d.ts +348 -0
  20. package/dist/core/contracts.js +17 -0
  21. package/dist/core/contracts.js.map +1 -0
  22. package/dist/core/degrade/chain.d.ts +80 -0
  23. package/dist/core/degrade/chain.js +137 -0
  24. package/dist/core/degrade/chain.js.map +1 -0
  25. package/dist/core/diagnose/error-resolver.d.ts +51 -0
  26. package/dist/core/diagnose/error-resolver.js +202 -0
  27. package/dist/core/diagnose/error-resolver.js.map +1 -0
  28. package/dist/core/guard/skill-gate.d.ts +89 -0
  29. package/dist/core/guard/skill-gate.js +121 -0
  30. package/dist/core/guard/skill-gate.js.map +1 -0
  31. package/dist/core/midi/convert.d.ts +31 -0
  32. package/dist/core/midi/convert.js +125 -0
  33. package/dist/core/midi/convert.js.map +1 -0
  34. package/dist/core/midi/smf.d.ts +37 -0
  35. package/dist/core/midi/smf.js +422 -0
  36. package/dist/core/midi/smf.js.map +1 -0
  37. package/dist/core/render/artifacts.d.ts +37 -0
  38. package/dist/core/render/artifacts.js +417 -0
  39. package/dist/core/render/artifacts.js.map +1 -0
  40. package/dist/core/render/orchestrator.d.ts +110 -0
  41. package/dist/core/render/orchestrator.js +974 -0
  42. package/dist/core/render/orchestrator.js.map +1 -0
  43. package/dist/core/svip/codec.d.ts +30 -0
  44. package/dist/core/svip/codec.js +664 -0
  45. package/dist/core/svip/codec.js.map +1 -0
  46. package/dist/core/svip/document.d.ts +31 -0
  47. package/dist/core/svip/document.js +158 -0
  48. package/dist/core/svip/document.js.map +1 -0
  49. package/dist/core/svip/editor.d.ts +71 -0
  50. package/dist/core/svip/editor.js +245 -0
  51. package/dist/core/svip/editor.js.map +1 -0
  52. package/dist/core/svip/model.d.ts +74 -0
  53. package/dist/core/svip/model.js +158 -0
  54. package/dist/core/svip/model.js.map +1 -0
  55. package/dist/core/svip/tick.d.ts +21 -0
  56. package/dist/core/svip/tick.js +59 -0
  57. package/dist/core/svip/tick.js.map +1 -0
  58. package/dist/core/svip/validator.d.ts +39 -0
  59. package/dist/core/svip/validator.js +267 -0
  60. package/dist/core/svip/validator.js.map +1 -0
  61. package/dist/host/linux.d.ts +15 -0
  62. package/dist/host/linux.js +42 -0
  63. package/dist/host/linux.js.map +1 -0
  64. package/dist/host/sidecar.d.ts +61 -0
  65. package/dist/host/sidecar.js +365 -0
  66. package/dist/host/sidecar.js.map +1 -0
  67. package/dist/host/wine-launch.d.ts +60 -0
  68. package/dist/host/wine-launch.js +77 -0
  69. package/dist/host/wine-launch.js.map +1 -0
  70. package/dist/host/wine-paths.d.ts +30 -0
  71. package/dist/host/wine-paths.js +103 -0
  72. package/dist/host/wine-paths.js.map +1 -0
  73. package/dist/index.d.ts +20 -0
  74. package/dist/index.js +17 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/services.d.ts +55 -0
  77. package/dist/services.js +78 -0
  78. package/dist/services.js.map +1 -0
  79. package/dist/shared/errors.d.ts +61 -0
  80. package/dist/shared/errors.js +125 -0
  81. package/dist/shared/errors.js.map +1 -0
  82. package/dist/shared/paths.d.ts +8 -0
  83. package/dist/shared/paths.js +30 -0
  84. package/dist/shared/paths.js.map +1 -0
  85. package/dist/shared/schema.d.ts +26 -0
  86. package/dist/shared/schema.js +68 -0
  87. package/dist/shared/schema.js.map +1 -0
  88. package/dist/shared/types.d.ts +43 -0
  89. package/dist/shared/types.js +19 -0
  90. package/dist/shared/types.js.map +1 -0
  91. package/dist/tests/unit/artifacts.test.d.ts +1 -0
  92. package/dist/tests/unit/artifacts.test.js +243 -0
  93. package/dist/tests/unit/artifacts.test.js.map +1 -0
  94. package/dist/tests/unit/data-plane.test.d.ts +1 -0
  95. package/dist/tests/unit/data-plane.test.js +153 -0
  96. package/dist/tests/unit/data-plane.test.js.map +1 -0
  97. package/dist/tests/unit/degrade.test.d.ts +1 -0
  98. package/dist/tests/unit/degrade.test.js +133 -0
  99. package/dist/tests/unit/degrade.test.js.map +1 -0
  100. package/dist/tests/unit/diagnosis.test.d.ts +1 -0
  101. package/dist/tests/unit/diagnosis.test.js +66 -0
  102. package/dist/tests/unit/diagnosis.test.js.map +1 -0
  103. package/dist/tests/unit/errors.test.d.ts +1 -0
  104. package/dist/tests/unit/errors.test.js +83 -0
  105. package/dist/tests/unit/errors.test.js.map +1 -0
  106. package/dist/tests/unit/mcp-server.test.d.ts +1 -0
  107. package/dist/tests/unit/mcp-server.test.js +267 -0
  108. package/dist/tests/unit/mcp-server.test.js.map +1 -0
  109. package/dist/tests/unit/mcp-smoke.d.ts +6 -0
  110. package/dist/tests/unit/mcp-smoke.js +7 -0
  111. package/dist/tests/unit/mcp-smoke.js.map +1 -0
  112. package/dist/tests/unit/mcp-smoke.test.d.ts +1 -0
  113. package/dist/tests/unit/mcp-smoke.test.js +196 -0
  114. package/dist/tests/unit/mcp-smoke.test.js.map +1 -0
  115. package/dist/tests/unit/midi.test.d.ts +1 -0
  116. package/dist/tests/unit/midi.test.js +255 -0
  117. package/dist/tests/unit/midi.test.js.map +1 -0
  118. package/dist/tests/unit/pronunciation.test.d.ts +1 -0
  119. package/dist/tests/unit/pronunciation.test.js +83 -0
  120. package/dist/tests/unit/pronunciation.test.js.map +1 -0
  121. package/dist/tests/unit/registry-contract.test.d.ts +1 -0
  122. package/dist/tests/unit/registry-contract.test.js +114 -0
  123. package/dist/tests/unit/registry-contract.test.js.map +1 -0
  124. package/dist/tests/unit/render-orchestrator.test.d.ts +1 -0
  125. package/dist/tests/unit/render-orchestrator.test.js +548 -0
  126. package/dist/tests/unit/render-orchestrator.test.js.map +1 -0
  127. package/dist/tests/unit/sidecar.test.d.ts +1 -0
  128. package/dist/tests/unit/sidecar.test.js +299 -0
  129. package/dist/tests/unit/sidecar.test.js.map +1 -0
  130. package/dist/tests/unit/singers.test.d.ts +1 -0
  131. package/dist/tests/unit/singers.test.js +73 -0
  132. package/dist/tests/unit/singers.test.js.map +1 -0
  133. package/dist/tests/unit/skill-gate.test.d.ts +1 -0
  134. package/dist/tests/unit/skill-gate.test.js +207 -0
  135. package/dist/tests/unit/skill-gate.test.js.map +1 -0
  136. package/dist/tests/unit/svip-codec.test.d.ts +1 -0
  137. package/dist/tests/unit/svip-codec.test.js +182 -0
  138. package/dist/tests/unit/svip-codec.test.js.map +1 -0
  139. package/dist/tests/unit/svip-document.test.d.ts +1 -0
  140. package/dist/tests/unit/svip-document.test.js +137 -0
  141. package/dist/tests/unit/svip-document.test.js.map +1 -0
  142. package/dist/tests/unit/svip-editor.test.d.ts +1 -0
  143. package/dist/tests/unit/svip-editor.test.js +275 -0
  144. package/dist/tests/unit/svip-editor.test.js.map +1 -0
  145. package/dist/tests/unit/svip-tick.test.d.ts +1 -0
  146. package/dist/tests/unit/svip-tick.test.js +66 -0
  147. package/dist/tests/unit/svip-tick.test.js.map +1 -0
  148. package/dist/tools/common.d.ts +87 -0
  149. package/dist/tools/common.js +174 -0
  150. package/dist/tools/common.js.map +1 -0
  151. package/dist/tools/control.d.ts +21 -0
  152. package/dist/tools/control.js +376 -0
  153. package/dist/tools/control.js.map +1 -0
  154. package/dist/tools/data.d.ts +37 -0
  155. package/dist/tools/data.js +680 -0
  156. package/dist/tools/data.js.map +1 -0
  157. package/dist/tools/definition.d.ts +60 -0
  158. package/dist/tools/definition.js +44 -0
  159. package/dist/tools/definition.js.map +1 -0
  160. package/dist/tools/degrade.d.ts +3 -0
  161. package/dist/tools/degrade.js +30 -0
  162. package/dist/tools/degrade.js.map +1 -0
  163. package/dist/tools/guide.d.ts +10 -0
  164. package/dist/tools/guide.js +66 -0
  165. package/dist/tools/guide.js.map +1 -0
  166. package/dist/tools/open.d.ts +3 -0
  167. package/dist/tools/open.js +74 -0
  168. package/dist/tools/open.js.map +1 -0
  169. package/dist/tools/probe.d.ts +8 -0
  170. package/dist/tools/probe.js +132 -0
  171. package/dist/tools/probe.js.map +1 -0
  172. package/dist/tools/registry.d.ts +10 -0
  173. package/dist/tools/registry.js +16 -0
  174. package/dist/tools/registry.js.map +1 -0
  175. package/dist/version.d.ts +4 -0
  176. package/dist/version.js +19 -0
  177. package/dist/version.js.map +1 -0
  178. package/docs/DESIGN.md +561 -0
  179. package/docs/RECON-GUI.md +271 -0
  180. package/docs/RECON.md +339 -0
  181. package/docs/SPEC.md +786 -0
  182. package/docs/WINE.md +193 -0
  183. package/examples/.scratch/01-midi-to-wudi/wudi-demo.svip3 +0 -0
  184. package/examples/.scratch/01-midi-to-wudi/wudi-melody.mid +0 -0
  185. package/examples/.scratch/01-midi-to-wudi/wudi-roundtrip.mid +0 -0
  186. package/examples/.scratch/02-three-singers/melody.chenziyu.svip3 +0 -0
  187. package/examples/.scratch/02-three-singers/melody.hechang.svip3 +0 -0
  188. package/examples/.scratch/02-three-singers/melody.svip3 +0 -0
  189. package/examples/.scratch/02-three-singers/melody.wudi.svip3 +0 -0
  190. package/examples/.scratch/03-velocity-diction/phrase.svip3 +0 -0
  191. package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-200 +0 -0
  192. package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-203 +0 -0
  193. package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-204 +0 -0
  194. package/examples/.scratch/04-unknown-dialog-abort/dialog-demo.svip3 +0 -0
  195. package/examples/01-midi-to-wudi.mjs +144 -0
  196. package/examples/02-three-singers-compare.mjs +140 -0
  197. package/examples/03-velocity-diction-rerender.mjs +160 -0
  198. package/examples/04-unknown-dialog-abort.mjs +126 -0
  199. package/examples/README.md +101 -0
  200. package/examples/lib/harness.mjs +274 -0
  201. package/fixtures/midi/melody-480.mid +0 -0
  202. package/fixtures/midi/melody-96.mid +0 -0
  203. package/fixtures/svip/1.svip3 +0 -0
  204. package/fixtures/svip/3.svip3 +0 -0
  205. package/fixtures/uia/README.md +37 -0
  206. package/fixtures/uia/export-dialog.snapshot.json +446 -0
  207. package/fixtures/uia/main-window.snapshot.json +2997 -0
  208. package/fixtures/uia/open-dialog.snapshot.json +103 -0
  209. package/icon.svg +10 -0
  210. package/package.json +84 -4
  211. package/proto/xstudio.proto +128 -0
  212. package/scripts/check-contract.mjs +184 -0
  213. package/scripts/entry-smoke.mjs +26 -0
  214. package/scripts/inspect-svip.mjs +161 -0
  215. package/scripts/setup-venv.sh +93 -0
  216. package/scripts/wine-gui-probe.py +302 -0
  217. package/sidecar/xstudio_uia.py +1478 -0
  218. package/skills/xstudio-gui/SKILL.md +196 -0
  219. package/skills/xstudio-gui/assertions.md +103 -0
  220. package/skills/xstudio-gui/dialogs.md +90 -0
  221. package/skills/xstudio-gui/gestures.md +158 -0
  222. package/skills/xstudio-gui/ui-map.json +242 -0
@@ -0,0 +1,103 @@
1
+ {
2
+ "$comment": "Reconstructed UIA snapshot of the native Win32 open-project dialog (#32770) captured read-only during the earlier recon session (team-5a10f17a tool result #62, then closed with WM_CLOSE). Native common-dialog controls surface as Pane elements; their AutomationId is the Win32 control id. Not a fresh capture; see docs/RECON-GUI.md.",
3
+ "capturedFrom": "X Studio 1.2.7 native 打开工程 dialog, Windows 11",
4
+ "snapshot": {
5
+ "window": {
6
+ "title": "打开工程",
7
+ "pid": 0,
8
+ "className": "#32770"
9
+ },
10
+ "elements": [
11
+ {
12
+ "ref": "recon02:e1",
13
+ "name": "打开工程",
14
+ "automationId": "",
15
+ "className": "#32770",
16
+ "controlType": "Window",
17
+ "patterns": [],
18
+ "enabled": true,
19
+ "offscreen": false,
20
+ "depth": 0,
21
+ "windowRef": "recon02:e1"
22
+ },
23
+ {
24
+ "ref": "recon02:e2",
25
+ "name": "文件名(N):",
26
+ "automationId": "1090",
27
+ "className": "Static",
28
+ "controlType": "Pane",
29
+ "patterns": [],
30
+ "enabled": true,
31
+ "offscreen": false,
32
+ "depth": 1,
33
+ "parentRef": "recon02:e1",
34
+ "windowRef": "recon02:e1"
35
+ },
36
+ {
37
+ "ref": "recon02:e3",
38
+ "name": "",
39
+ "automationId": "1148",
40
+ "className": "Edit",
41
+ "controlType": "Pane",
42
+ "patterns": [],
43
+ "enabled": true,
44
+ "offscreen": false,
45
+ "depth": 2,
46
+ "parentRef": "recon02:e2",
47
+ "windowRef": "recon02:e1"
48
+ },
49
+ {
50
+ "ref": "recon02:e4",
51
+ "name": "网易云音乐·X Studio Project (*.svip3 *.svip)",
52
+ "automationId": "1136",
53
+ "className": "ComboBox",
54
+ "controlType": "Pane",
55
+ "patterns": [],
56
+ "enabled": true,
57
+ "offscreen": false,
58
+ "depth": 1,
59
+ "parentRef": "recon02:e1",
60
+ "windowRef": "recon02:e1"
61
+ },
62
+ {
63
+ "ref": "recon02:e5",
64
+ "name": "打开(O)",
65
+ "automationId": "1",
66
+ "className": "Button",
67
+ "controlType": "Pane",
68
+ "patterns": [],
69
+ "enabled": true,
70
+ "offscreen": false,
71
+ "depth": 1,
72
+ "parentRef": "recon02:e1",
73
+ "windowRef": "recon02:e1"
74
+ },
75
+ {
76
+ "ref": "recon02:e6",
77
+ "name": "取消",
78
+ "automationId": "2",
79
+ "className": "Button",
80
+ "controlType": "Pane",
81
+ "patterns": [],
82
+ "enabled": true,
83
+ "offscreen": false,
84
+ "depth": 1,
85
+ "parentRef": "recon02:e1",
86
+ "windowRef": "recon02:e1"
87
+ }
88
+ ],
89
+ "truncated": false,
90
+ "capturedAt": 0,
91
+ "snapshotId": "recon02",
92
+ "warnings": [
93
+ "reconstructed from recon evidence, not a live capture"
94
+ ],
95
+ "additionalWindows": [
96
+ {
97
+ "ref": "recon02:e1",
98
+ "title": "打开工程",
99
+ "className": "#32770"
100
+ }
101
+ ]
102
+ }
103
+ }
package/icon.svg ADDED
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="dsh-xstudio">
2
+ <defs>
3
+ <linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#ff4d6d"/>
5
+ <stop offset="1" stop-color="#7b61ff"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <rect x="4" y="4" width="56" height="56" rx="14" fill="url(#g)"/>
9
+ <path d="M25 42a6 6 0 1 0 4-5.66V19l16-3v7l-12 2.25V42z" fill="#fff"/>
10
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,86 @@
1
1
  {
2
2
  "name": "xstudio-linux",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.4",
4
+ "description": "X Studio (NetEase Cloud Music) .svip3 editing, cloud-render orchestration and GUI automation on Linux/Wine. Standalone CLI + stdio MCP server.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./mcp": {
14
+ "types": "./dist/adapter-mcp/server.d.ts",
15
+ "default": "./dist/adapter-mcp/server.js"
16
+ },
17
+ "./cli": {
18
+ "types": "./dist/adapter-cli/cli.d.ts",
19
+ "default": "./dist/adapter-cli/cli.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "bin": {
24
+ "xstudio": "./dist/adapter-cli/cli.js",
25
+ "xstudio-mcp": "./dist/adapter-mcp/server.js"
26
+ },
27
+ "icon": "./icon.svg",
28
+ "files": [
29
+ "dist",
30
+ "proto",
31
+ "skills",
32
+ "sidecar",
33
+ "scripts",
34
+ "icon.svg",
35
+ "README.md",
36
+ "CHANGELOG.md",
37
+ "docs",
38
+ "examples",
39
+ "fixtures",
40
+ "LICENSE"
41
+ ],
42
+ "keywords": [
43
+ "xstudio",
44
+ "netease",
45
+ "wine",
46
+ "linux",
47
+ "mcp-server",
48
+ "protobuf",
49
+ "atspi2"
50
+ ],
51
+ "license": "MIT",
52
+ "scripts": {
53
+ "build": "tsc -p tsconfig.json",
54
+ "typecheck": "tsc -p tsconfig.json --noEmit",
55
+ "test": "node --test \"dist/tests/unit/*.test.js\"",
56
+ "test:unit": "node --test \"dist/tests/unit/*.test.js\"",
57
+ "dev": "tsc -p tsconfig.json --watch",
58
+ "prepublishOnly": "npm run build",
59
+ "check:contract": "node scripts/check-contract.mjs",
60
+ "mcp:smoke": "node dist/tests/unit/mcp-smoke.js",
61
+ "test:core": "node --test \"dist/tests/unit/{svip-*,midi,singers,pronunciation,diagnosis,degrade,wine-paths,sidecar,skill-gate,errors}.test.js\"",
62
+ "smoke:entry": "node scripts/entry-smoke.mjs",
63
+ "wine:probe": "python3 scripts/wine-gui-probe.py",
64
+ "setup:venv": "scripts/setup-venv.sh",
65
+ "check:venv": "scripts/setup-venv.sh --check"
66
+ },
67
+ "dependencies": {
68
+ "protobufjs": "^7.5.4"
69
+ },
70
+ "devDependencies": {
71
+ "@types/node": "^24.0.0",
72
+ "typescript": "^5.9.3"
73
+ },
74
+ "engines": {
75
+ "node": ">=20"
76
+ },
77
+ "repository": {
78
+ "type": "git",
79
+ "url": "https://github.com/example/xstudio-linux.git"
80
+ },
81
+ "author": "xstudio-linux contributors",
82
+ "homepage": "https://github.com/example/xstudio-linux#readme",
83
+ "bugs": {
84
+ "url": "https://github.com/example/xstudio-linux/issues"
85
+ }
86
+ }
@@ -0,0 +1,128 @@
1
+ // X Studio (.svip3) project schema.
2
+ //
3
+ // This file is the documentation copy of the wire schema. The codec
4
+ // (src/core/svip/codec.ts) keeps an equivalent schema inlined so that it can be
5
+ // parsed at module load without resolving imports: `google.protobuf.Any` is
6
+ // inlined there as `message Any { string type_url = 1; bytes value = 2; }`.
7
+ //
8
+ // Verified against real X Studio 3.0.3 project files (fixtures/svip/*.svip3,
9
+ // 363 bytes each): protobufjs decode -> encode reproduces both files
10
+ // byte-for-byte. Every field number, wire type and default below was checked
11
+ // against the raw wire bytes.
12
+ //
13
+ // Traps:
14
+ // - `internal_clock_base` is 115200 in every observed file. It is NOT the PPQ.
15
+ // The timeline is 480 ticks per quarter note (PPQ = 480).
16
+ // - `visibility_mask` is a 64-bit varint (uint64), not fixed64: the fixtures
17
+ // encode field 18 with wire type 0 (tag 0x90 0x01) and value 2^64-1.
18
+ // - `position_tick` is proto3 `optional`; X Studio omits the field when the
19
+ // value is 0 (the first note of every observed file does this).
20
+ // - The fields documented as read-only pass-through (internal_clock_base,
21
+ // unknown_field_9, total_ticks, flags, visibility_mask, start_tick/end_tick)
22
+ // are preserved verbatim and never given semantics.
23
+
24
+ syntax = "proto3";
25
+
26
+ package xstudio.proto;
27
+
28
+ import "google/protobuf/any.proto";
29
+
30
+ // The root .svip3 message.
31
+ message Project {
32
+ // Path the project was last saved from, as stored by X Studio.
33
+ string source_path = 1;
34
+ // X Studio version that wrote the file, e.g. "3.0.3".
35
+ string app_version = 2;
36
+ // Read-only pass-through. 115200 in observed files; NOT the PPQ.
37
+ uint32 internal_clock_base = 3;
38
+ TempoInfo tempo = 4;
39
+ TimeSignature time_sig = 5;
40
+ // google.protobuf.Any whose type_url is
41
+ // "type.googleapis.com/xstudio.proto.SingingTrack".
42
+ google.protobuf.Any track_data = 6;
43
+ GainInfo gain = 7;
44
+ // Read-only pass-through. Constant 8 in observed files.
45
+ uint32 unknown_field_9 = 9;
46
+ // Read-only pass-through. 7680 in observed files.
47
+ uint32 total_ticks = 11;
48
+ // Read-only pass-through. Constant 1 in observed files.
49
+ uint32 flags = 12;
50
+ DisplayMeta display = 14;
51
+ }
52
+
53
+ // Tempo stored as hundredths of a BPM (12000 = 120.00 BPM).
54
+ message TempoInfo {
55
+ uint32 bpm_x100 = 2;
56
+ }
57
+
58
+ // Time signature wrapper. The actual signature lives in the nested `ns`.
59
+ message TimeSignature {
60
+ NumeratorDenominator ns = 2;
61
+ }
62
+
63
+ message NumeratorDenominator {
64
+ uint32 numerator = 1;
65
+ uint32 denominator = 2;
66
+ }
67
+
68
+ // Master gain. Observed values are linear floats (1.0, 6.0).
69
+ message GainInfo {
70
+ float linear_gain = 1;
71
+ }
72
+
73
+ // Placeholder text shown by the editor when the project is empty.
74
+ message DisplayMeta {
75
+ string placeholder = 2;
76
+ }
77
+
78
+ // The decoded payload of the google.protobuf.Any `track_data` field.
79
+ message SingingTrack {
80
+ // Global velocity offset as a linear float (0.7 in observed files).
81
+ float velocity_offset = 1;
82
+ // Singer display name stored by X Studio, e.g. "何畅" (UTF-8).
83
+ string singer_name = 4;
84
+ // UI colour, e.g. "#7F97AE".
85
+ string ui_color_hex = 6;
86
+ // 2 = singing track.
87
+ uint32 track_type = 7;
88
+ TrackPayload payload = 8;
89
+ // Stable track UUID.
90
+ string uuid = 9;
91
+ // Pan in dB (observed -18.0).
92
+ float pan_db = 12;
93
+ }
94
+
95
+ message TrackPayload {
96
+ string label = 1;
97
+ uint32 sub_type = 2;
98
+ // Read-only pass-through (21120 in observed files).
99
+ uint32 start_tick = 4;
100
+ // Read-only pass-through (21120 in observed files).
101
+ uint32 end_tick = 6;
102
+ repeated Note notes = 8;
103
+ // Read-only pass-through: all bits set (2^64-1).
104
+ uint64 visibility_mask = 18;
105
+ // Read-only pass-through ("F969" in observed files).
106
+ string short_id = 19;
107
+ }
108
+
109
+ // One sung note.
110
+ message Note {
111
+ // Absolute tick on the project timeline (PPQ = 480). Proto3 optional:
112
+ // omitted when 0 (X Studio does this for the first note).
113
+ optional uint32 position_tick = 1;
114
+ // Duration in ticks: 240 = eighth, 480 = quarter, 720 = dotted quarter.
115
+ uint32 length_tick = 2;
116
+ // MIDI pitch: 60 = C4.
117
+ uint32 midi_pitch = 3;
118
+ // Lyric text, UTF-8.
119
+ string lyric_text = 4;
120
+ // Romanized phoneme, e.g. "la".
121
+ string phoneme_roman = 5;
122
+ // Constant 1 in observed files; read-only pass-through.
123
+ uint32 note_flag = 14;
124
+ // -1.0 means "unset" (sentinel); never reinterpret it.
125
+ float expr_param_1 = 15;
126
+ // -1.0 means "unset" (sentinel); never reinterpret it.
127
+ float expr_param_2 = 16;
128
+ }
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Contract checker: the shared tool registry and the MCP stdio server must expose
4
+ * the same tools with byte-identical name/description/parameters, and both must
5
+ * match the tool tables in README.md.
6
+ *
7
+ * Run after `pnpm run build`:
8
+ * node scripts/check-contract.mjs
9
+ *
10
+ * Exit codes: 0 = consistent, 1 = drift, 2 = compiled plugin missing/broken.
11
+ */
12
+ import { readFileSync } from 'node:fs'
13
+ import { dirname, resolve } from 'node:path'
14
+ import { fileURLToPath, pathToFileURL } from 'node:url'
15
+
16
+ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
17
+
18
+ /** Import one compiled module, reporting a build hint on failure. */
19
+ async function load(relativePath) {
20
+ const absolute = resolve(ROOT, 'dist', relativePath)
21
+ try {
22
+ return await import(pathToFileURL(absolute).href)
23
+ } catch (error) {
24
+ console.error('check-contract: cannot import the compiled plugin.')
25
+ console.error(` expected: ${absolute}`)
26
+ console.error(` reason: ${error instanceof Error ? error.message : String(error)}`)
27
+ console.error(' fix: run "pnpm run build" first.')
28
+ process.exit(2)
29
+ }
30
+ }
31
+
32
+ /** Stable JSON rendering (sorted object keys) for deep comparison. */
33
+ function stable(value) {
34
+ if (Array.isArray(value)) return `[${value.map((item) => stable(item)).join(',')}]`
35
+ if (value !== null && typeof value === 'object') {
36
+ const keys = Object.keys(value).sort()
37
+ return `{${keys.map((key) => `${JSON.stringify(key)}:${stable(value[key])}`).join(',')}}`
38
+ }
39
+ return JSON.stringify(value)
40
+ }
41
+
42
+ /** Read a markdown file, returning null when it does not exist. */
43
+ function readOptional(relativePath) {
44
+ try {
45
+ return readFileSync(resolve(ROOT, relativePath), 'utf8')
46
+ } catch {
47
+ return null
48
+ }
49
+ }
50
+
51
+ /** Extract `| \`xstudio_name\` |` table rows from a markdown document. */
52
+ function documentedToolNames(markdown) {
53
+ const names = []
54
+ for (const match of markdown.matchAll(/^\|\s*`(xstudio_[a-z0-9_]+)`/gm)) names.push(match[1])
55
+ return names
56
+ }
57
+
58
+ /**
59
+ * Compare two name lists and return a human-readable drift summary.
60
+ *
61
+ * `expected` is compared as a set: a document may mention a tool in more than
62
+ * one table (docs/SPEC.md is normative and repeats the five UI primitives in
63
+ * §6.4), so only README.md — the canonical tool table — is checked for repeats.
64
+ */
65
+ function compareNameSets(label, expected, actual, options = {}) {
66
+ const expectedSet = new Set(expected)
67
+ const actualSet = new Set(actual)
68
+ const missing = [...expectedSet].filter((name) => !actualSet.has(name))
69
+ const extra = [...actualSet].filter((name) => !expectedSet.has(name))
70
+ const problems = []
71
+ if (missing.length > 0) problems.push(`${label} is missing: ${missing.join(', ')}`)
72
+ if (extra.length > 0) problems.push(`${label} documents unknown tools: ${extra.join(', ')}`)
73
+ if (options.detectDuplicates === true) {
74
+ const duplicates = actual.filter((name, index) => actual.indexOf(name) !== index)
75
+ if (duplicates.length > 0) problems.push(`${label} repeats: ${[...new Set(duplicates)].join(', ')}`)
76
+ }
77
+ return problems
78
+ }
79
+
80
+ const configModule = await load('config.js')
81
+ const servicesModule = await load('services.js')
82
+ const registryModule = await load('tools/registry.js')
83
+ const mcpModule = await load('adapter-mcp/server.js')
84
+
85
+ const config = configModule.resolveConfig({})
86
+ const services = servicesModule.createServices(config)
87
+ const definitions = registryModule.buildToolDefinitions(services)
88
+ const mcpTools = mcpModule.toMcpTools(definitions)
89
+
90
+ const problems = []
91
+
92
+ // 1. Name sanity.
93
+ const names = definitions.map((definition) => definition.name)
94
+ for (const name of names) {
95
+ if (!/^xstudio_[a-z0-9_]+$/.test(name)) problems.push(`tool name "${name}" does not match /^xstudio_[a-z0-9_]+$/`)
96
+ }
97
+ const seen = new Set()
98
+ for (const name of names) {
99
+ if (seen.has(name)) problems.push(`duplicate tool name "${name}"`)
100
+ seen.add(name)
101
+ }
102
+ for (const definition of definitions) {
103
+ if (typeof definition.description !== 'string' || definition.description.trim() === '') {
104
+ problems.push(`tool "${definition.name}" has no description`)
105
+ }
106
+ if (definition.parameters === null || typeof definition.parameters !== 'object' || definition.parameters.type !== 'object') {
107
+ problems.push(`tool "${definition.name}" parameters are not an object schema`)
108
+ }
109
+ }
110
+
111
+ // 2a. The skill gate must be visible in the gated tools' descriptions and
112
+ // absent from every other tool.
113
+ const GATED_GUI_TOOLS = [
114
+ 'xstudio_open', 'xstudio_ui_snapshot', 'xstudio_ui_act', 'xstudio_ui_assert', 'xstudio_ui_dialog_respond',
115
+ 'xstudio_ui_abort', 'xstudio_preview_trigger', 'xstudio_preview_wait', 'xstudio_export_run',
116
+ ]
117
+ for (const name of GATED_GUI_TOOLS) {
118
+ const definition = definitions.find((candidate) => candidate.name === name)
119
+ if (definition === undefined) problems.push(`gated GUI tool "${name}" is missing`)
120
+ else if (!String(definition.description).includes('xstudio-gui skill')) {
121
+ problems.push(`gated tool "${name}" description does not name the xstudio-gui skill`)
122
+ }
123
+ }
124
+ for (const definition of definitions) {
125
+ if (GATED_GUI_TOOLS.includes(definition.name)) continue
126
+ if (String(definition.description).includes('xstudio-gui skill')) {
127
+ problems.push(`non-GUI tool "${definition.name}" claims the skill gate`)
128
+ }
129
+ }
130
+
131
+ // 2. DSH registry vs MCP exposure.
132
+ if (mcpTools.length !== definitions.length) {
133
+ problems.push(`MCP exposes ${mcpTools.length} tools but the registry builds ${definitions.length}`)
134
+ }
135
+ for (let index = 0; index < definitions.length; index += 1) {
136
+ const definition = definitions[index]
137
+ const mcpTool = mcpTools[index]
138
+ if (mcpTool === undefined) {
139
+ problems.push(`MCP is missing tool "${definition.name}" (position ${index})`)
140
+ continue
141
+ }
142
+ if (mcpTool.name !== definition.name) {
143
+ problems.push(`position ${index}: registry "${definition.name}" vs MCP "${mcpTool.name}"`)
144
+ continue
145
+ }
146
+ if (mcpTool.description !== definition.description) {
147
+ problems.push(`tool "${definition.name}": MCP description differs from the registry`)
148
+ }
149
+ if (stable(mcpTool.inputSchema) !== stable(definition.parameters)) {
150
+ problems.push(`tool "${definition.name}": MCP inputSchema differs from the registry parameters`)
151
+ }
152
+ }
153
+
154
+ // 3. Documented tables must match the registry.
155
+ const readme = readOptional('README.md')
156
+ if (readme === null) {
157
+ problems.push('README.md is missing')
158
+ } else {
159
+ problems.push(...compareNameSets('README.md', names, documentedToolNames(readme), { detectDuplicates: true }))
160
+ if (!readme.includes('NEED_SKILL')) problems.push('README.md does not document the NEED_SKILL code (kept in the error table for protocol compatibility)')
161
+ }
162
+ const spec = readOptional('docs/SPEC.md')
163
+ if (spec === null) {
164
+ problems.push('docs/SPEC.md is missing')
165
+ } else {
166
+ problems.push(...compareNameSets('docs/SPEC.md', names, documentedToolNames(spec)))
167
+ }
168
+
169
+ await services.dispose()
170
+
171
+ const summary = [
172
+ `${definitions.length} registry tools`,
173
+ `${mcpTools.length} MCP tools`,
174
+ `${readme === null ? '?' : documentedToolNames(readme).length} documented in README.md`,
175
+ `${spec === null ? '?' : documentedToolNames(spec).length} documented in docs/SPEC.md`,
176
+ ].join(', ')
177
+
178
+ if (problems.length > 0) {
179
+ console.error(`check-contract: DRIFT (${summary})`)
180
+ for (const problem of problems) console.error(` - ${problem}`)
181
+ process.exit(1)
182
+ }
183
+
184
+ console.log(`check-contract: OK (${summary})`)
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Entry smoke: the standalone package exports its programmatic API and builds
4
+ * the full 25-tool surface from a default config.
5
+ * Run after "npm run build": node scripts/entry-smoke.mjs
6
+ */
7
+ import assert from 'node:assert/strict'
8
+ import { resolveConfig, createServices, buildToolDefinitions, version } from '../dist/index.js'
9
+
10
+ assert.equal(typeof resolveConfig, 'function')
11
+ assert.equal(typeof createServices, 'function')
12
+ assert.equal(typeof buildToolDefinitions, 'function')
13
+ assert.ok(/^[0-9]+\.[0-9]+\.[0-9]+$/.test(version()), 'version() returns a semver string')
14
+
15
+ const config = resolveConfig({})
16
+ assert.equal(config.defaultSinger, 'beta-netease:wudi')
17
+ assert.equal(config.backupOnWrite, true)
18
+ assert.equal(config.wine.prefix, '~/.wine')
19
+
20
+ const services = createServices(config)
21
+ const tools = buildToolDefinitions(services)
22
+ assert.equal(tools.length, 25, 'expected 25 tools')
23
+ assert.ok(tools.every((tool) => typeof tool.name === 'string' && tool.name.startsWith('xstudio_')))
24
+ assert.ok(tools.every((tool) => typeof tool.execute === 'function'))
25
+ await services.dispose()
26
+ console.log('ENTRY SMOKE: PASS — tools=', tools.length, 'version=', version())