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.
- package/CHANGELOG.md +469 -0
- package/LICENSE +31 -0
- package/README.md +542 -2
- package/dist/adapter-cli/cli.d.ts +28 -0
- package/dist/adapter-cli/cli.js +233 -0
- package/dist/adapter-cli/cli.js.map +1 -0
- package/dist/adapter-mcp/server.d.ts +81 -0
- package/dist/adapter-mcp/server.js +473 -0
- package/dist/adapter-mcp/server.js.map +1 -0
- package/dist/config.d.ts +45 -0
- package/dist/config.js +78 -0
- package/dist/config.js.map +1 -0
- package/dist/core/catalog/pronunciation.d.ts +47 -0
- package/dist/core/catalog/pronunciation.js +402 -0
- package/dist/core/catalog/pronunciation.js.map +1 -0
- package/dist/core/catalog/singers.d.ts +46 -0
- package/dist/core/catalog/singers.js +122 -0
- package/dist/core/catalog/singers.js.map +1 -0
- package/dist/core/contracts.d.ts +348 -0
- package/dist/core/contracts.js +17 -0
- package/dist/core/contracts.js.map +1 -0
- package/dist/core/degrade/chain.d.ts +80 -0
- package/dist/core/degrade/chain.js +137 -0
- package/dist/core/degrade/chain.js.map +1 -0
- package/dist/core/diagnose/error-resolver.d.ts +51 -0
- package/dist/core/diagnose/error-resolver.js +202 -0
- package/dist/core/diagnose/error-resolver.js.map +1 -0
- package/dist/core/guard/skill-gate.d.ts +89 -0
- package/dist/core/guard/skill-gate.js +121 -0
- package/dist/core/guard/skill-gate.js.map +1 -0
- package/dist/core/midi/convert.d.ts +31 -0
- package/dist/core/midi/convert.js +125 -0
- package/dist/core/midi/convert.js.map +1 -0
- package/dist/core/midi/smf.d.ts +37 -0
- package/dist/core/midi/smf.js +422 -0
- package/dist/core/midi/smf.js.map +1 -0
- package/dist/core/render/artifacts.d.ts +37 -0
- package/dist/core/render/artifacts.js +417 -0
- package/dist/core/render/artifacts.js.map +1 -0
- package/dist/core/render/orchestrator.d.ts +110 -0
- package/dist/core/render/orchestrator.js +974 -0
- package/dist/core/render/orchestrator.js.map +1 -0
- package/dist/core/svip/codec.d.ts +30 -0
- package/dist/core/svip/codec.js +664 -0
- package/dist/core/svip/codec.js.map +1 -0
- package/dist/core/svip/document.d.ts +31 -0
- package/dist/core/svip/document.js +158 -0
- package/dist/core/svip/document.js.map +1 -0
- package/dist/core/svip/editor.d.ts +71 -0
- package/dist/core/svip/editor.js +245 -0
- package/dist/core/svip/editor.js.map +1 -0
- package/dist/core/svip/model.d.ts +74 -0
- package/dist/core/svip/model.js +158 -0
- package/dist/core/svip/model.js.map +1 -0
- package/dist/core/svip/tick.d.ts +21 -0
- package/dist/core/svip/tick.js +59 -0
- package/dist/core/svip/tick.js.map +1 -0
- package/dist/core/svip/validator.d.ts +39 -0
- package/dist/core/svip/validator.js +267 -0
- package/dist/core/svip/validator.js.map +1 -0
- package/dist/host/linux.d.ts +15 -0
- package/dist/host/linux.js +42 -0
- package/dist/host/linux.js.map +1 -0
- package/dist/host/sidecar.d.ts +61 -0
- package/dist/host/sidecar.js +365 -0
- package/dist/host/sidecar.js.map +1 -0
- package/dist/host/wine-launch.d.ts +60 -0
- package/dist/host/wine-launch.js +77 -0
- package/dist/host/wine-launch.js.map +1 -0
- package/dist/host/wine-paths.d.ts +30 -0
- package/dist/host/wine-paths.js +103 -0
- package/dist/host/wine-paths.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/services.d.ts +55 -0
- package/dist/services.js +78 -0
- package/dist/services.js.map +1 -0
- package/dist/shared/errors.d.ts +61 -0
- package/dist/shared/errors.js +125 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/paths.d.ts +8 -0
- package/dist/shared/paths.js +30 -0
- package/dist/shared/paths.js.map +1 -0
- package/dist/shared/schema.d.ts +26 -0
- package/dist/shared/schema.js +68 -0
- package/dist/shared/schema.js.map +1 -0
- package/dist/shared/types.d.ts +43 -0
- package/dist/shared/types.js +19 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tests/unit/artifacts.test.d.ts +1 -0
- package/dist/tests/unit/artifacts.test.js +243 -0
- package/dist/tests/unit/artifacts.test.js.map +1 -0
- package/dist/tests/unit/data-plane.test.d.ts +1 -0
- package/dist/tests/unit/data-plane.test.js +153 -0
- package/dist/tests/unit/data-plane.test.js.map +1 -0
- package/dist/tests/unit/degrade.test.d.ts +1 -0
- package/dist/tests/unit/degrade.test.js +133 -0
- package/dist/tests/unit/degrade.test.js.map +1 -0
- package/dist/tests/unit/diagnosis.test.d.ts +1 -0
- package/dist/tests/unit/diagnosis.test.js +66 -0
- package/dist/tests/unit/diagnosis.test.js.map +1 -0
- package/dist/tests/unit/errors.test.d.ts +1 -0
- package/dist/tests/unit/errors.test.js +83 -0
- package/dist/tests/unit/errors.test.js.map +1 -0
- package/dist/tests/unit/mcp-server.test.d.ts +1 -0
- package/dist/tests/unit/mcp-server.test.js +267 -0
- package/dist/tests/unit/mcp-server.test.js.map +1 -0
- package/dist/tests/unit/mcp-smoke.d.ts +6 -0
- package/dist/tests/unit/mcp-smoke.js +7 -0
- package/dist/tests/unit/mcp-smoke.js.map +1 -0
- package/dist/tests/unit/mcp-smoke.test.d.ts +1 -0
- package/dist/tests/unit/mcp-smoke.test.js +196 -0
- package/dist/tests/unit/mcp-smoke.test.js.map +1 -0
- package/dist/tests/unit/midi.test.d.ts +1 -0
- package/dist/tests/unit/midi.test.js +255 -0
- package/dist/tests/unit/midi.test.js.map +1 -0
- package/dist/tests/unit/pronunciation.test.d.ts +1 -0
- package/dist/tests/unit/pronunciation.test.js +83 -0
- package/dist/tests/unit/pronunciation.test.js.map +1 -0
- package/dist/tests/unit/registry-contract.test.d.ts +1 -0
- package/dist/tests/unit/registry-contract.test.js +114 -0
- package/dist/tests/unit/registry-contract.test.js.map +1 -0
- package/dist/tests/unit/render-orchestrator.test.d.ts +1 -0
- package/dist/tests/unit/render-orchestrator.test.js +548 -0
- package/dist/tests/unit/render-orchestrator.test.js.map +1 -0
- package/dist/tests/unit/sidecar.test.d.ts +1 -0
- package/dist/tests/unit/sidecar.test.js +299 -0
- package/dist/tests/unit/sidecar.test.js.map +1 -0
- package/dist/tests/unit/singers.test.d.ts +1 -0
- package/dist/tests/unit/singers.test.js +73 -0
- package/dist/tests/unit/singers.test.js.map +1 -0
- package/dist/tests/unit/skill-gate.test.d.ts +1 -0
- package/dist/tests/unit/skill-gate.test.js +207 -0
- package/dist/tests/unit/skill-gate.test.js.map +1 -0
- package/dist/tests/unit/svip-codec.test.d.ts +1 -0
- package/dist/tests/unit/svip-codec.test.js +182 -0
- package/dist/tests/unit/svip-codec.test.js.map +1 -0
- package/dist/tests/unit/svip-document.test.d.ts +1 -0
- package/dist/tests/unit/svip-document.test.js +137 -0
- package/dist/tests/unit/svip-document.test.js.map +1 -0
- package/dist/tests/unit/svip-editor.test.d.ts +1 -0
- package/dist/tests/unit/svip-editor.test.js +275 -0
- package/dist/tests/unit/svip-editor.test.js.map +1 -0
- package/dist/tests/unit/svip-tick.test.d.ts +1 -0
- package/dist/tests/unit/svip-tick.test.js +66 -0
- package/dist/tests/unit/svip-tick.test.js.map +1 -0
- package/dist/tools/common.d.ts +87 -0
- package/dist/tools/common.js +174 -0
- package/dist/tools/common.js.map +1 -0
- package/dist/tools/control.d.ts +21 -0
- package/dist/tools/control.js +376 -0
- package/dist/tools/control.js.map +1 -0
- package/dist/tools/data.d.ts +37 -0
- package/dist/tools/data.js +680 -0
- package/dist/tools/data.js.map +1 -0
- package/dist/tools/definition.d.ts +60 -0
- package/dist/tools/definition.js +44 -0
- package/dist/tools/definition.js.map +1 -0
- package/dist/tools/degrade.d.ts +3 -0
- package/dist/tools/degrade.js +30 -0
- package/dist/tools/degrade.js.map +1 -0
- package/dist/tools/guide.d.ts +10 -0
- package/dist/tools/guide.js +66 -0
- package/dist/tools/guide.js.map +1 -0
- package/dist/tools/open.d.ts +3 -0
- package/dist/tools/open.js +74 -0
- package/dist/tools/open.js.map +1 -0
- package/dist/tools/probe.d.ts +8 -0
- package/dist/tools/probe.js +132 -0
- package/dist/tools/probe.js.map +1 -0
- package/dist/tools/registry.d.ts +10 -0
- package/dist/tools/registry.js +16 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +19 -0
- package/dist/version.js.map +1 -0
- package/docs/DESIGN.md +561 -0
- package/docs/RECON-GUI.md +271 -0
- package/docs/RECON.md +339 -0
- package/docs/SPEC.md +786 -0
- package/docs/WINE.md +193 -0
- package/examples/.scratch/01-midi-to-wudi/wudi-demo.svip3 +0 -0
- package/examples/.scratch/01-midi-to-wudi/wudi-melody.mid +0 -0
- package/examples/.scratch/01-midi-to-wudi/wudi-roundtrip.mid +0 -0
- package/examples/.scratch/02-three-singers/melody.chenziyu.svip3 +0 -0
- package/examples/.scratch/02-three-singers/melody.hechang.svip3 +0 -0
- package/examples/.scratch/02-three-singers/melody.svip3 +0 -0
- package/examples/.scratch/02-three-singers/melody.wudi.svip3 +0 -0
- package/examples/.scratch/03-velocity-diction/phrase.svip3 +0 -0
- package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-200 +0 -0
- package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-203 +0 -0
- package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-204 +0 -0
- package/examples/.scratch/04-unknown-dialog-abort/dialog-demo.svip3 +0 -0
- package/examples/01-midi-to-wudi.mjs +144 -0
- package/examples/02-three-singers-compare.mjs +140 -0
- package/examples/03-velocity-diction-rerender.mjs +160 -0
- package/examples/04-unknown-dialog-abort.mjs +126 -0
- package/examples/README.md +101 -0
- package/examples/lib/harness.mjs +274 -0
- package/fixtures/midi/melody-480.mid +0 -0
- package/fixtures/midi/melody-96.mid +0 -0
- package/fixtures/svip/1.svip3 +0 -0
- package/fixtures/svip/3.svip3 +0 -0
- package/fixtures/uia/README.md +37 -0
- package/fixtures/uia/export-dialog.snapshot.json +446 -0
- package/fixtures/uia/main-window.snapshot.json +2997 -0
- package/fixtures/uia/open-dialog.snapshot.json +103 -0
- package/icon.svg +10 -0
- package/package.json +84 -4
- package/proto/xstudio.proto +128 -0
- package/scripts/check-contract.mjs +184 -0
- package/scripts/entry-smoke.mjs +26 -0
- package/scripts/inspect-svip.mjs +161 -0
- package/scripts/setup-venv.sh +93 -0
- package/scripts/wine-gui-probe.py +302 -0
- package/sidecar/xstudio_uia.py +1478 -0
- package/skills/xstudio-gui/SKILL.md +196 -0
- package/skills/xstudio-gui/assertions.md +103 -0
- package/skills/xstudio-gui/dialogs.md +90 -0
- package/skills/xstudio-gui/gestures.md +158 -0
- package/skills/xstudio-gui/ui-map.json +242 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Example 4 — an unknown error dialog falls back to the always-safe manual
|
|
4
|
+
* suggestion, destructive dialogs are refused, and a failed render run is
|
|
5
|
+
* aborted cleanly.
|
|
6
|
+
*
|
|
7
|
+
* Safety properties demonstrated (all with an in-memory fake GUI, no real
|
|
8
|
+
* window is touched and no network request is made):
|
|
9
|
+
* 1. `diagnoseDialog` matches nothing locally → the result is the safe
|
|
10
|
+
* `manual` action with confidence 0 (Tavily synthesis was removed in
|
|
11
|
+
* xstudio-linux, so no search text can ever enter the diagnosis);
|
|
12
|
+
* 2. the same path through the real `xstudio_ui_dialog_respond` tool;
|
|
13
|
+
* 3. a destructive dialog ("是否保存更改?") can never be auto-confirmed —
|
|
14
|
+
* an explicit `confirm` is coerced to `cancel`;
|
|
15
|
+
* 4. a simulated cloud outage yields a structured CLOUD_UNREACHABLE envelope
|
|
16
|
+
* and `xstudio_ui_abort` releases control.
|
|
17
|
+
*
|
|
18
|
+
* Run: node examples/04-unknown-dialog-abort.mjs
|
|
19
|
+
*/
|
|
20
|
+
import { join } from 'node:path'
|
|
21
|
+
import {
|
|
22
|
+
check,
|
|
23
|
+
createDataToolbox,
|
|
24
|
+
createFakeControlToolbox,
|
|
25
|
+
distModule,
|
|
26
|
+
fakeRender,
|
|
27
|
+
fakeSidecar,
|
|
28
|
+
freshDir,
|
|
29
|
+
info,
|
|
30
|
+
reportEnvelope,
|
|
31
|
+
requireDist,
|
|
32
|
+
runExample,
|
|
33
|
+
section,
|
|
34
|
+
} from './lib/harness.mjs'
|
|
35
|
+
|
|
36
|
+
/** Unknown dialog text: contains none of the local fingerprint needles. */
|
|
37
|
+
const UNKNOWN_DIALOG = '合成引擎返回代码 QX-4096:无法继续当前任务,请选择处理方式。'
|
|
38
|
+
|
|
39
|
+
await runExample('04 — unknown dialog diagnosis, destructive-dialog guard, abort', async () => {
|
|
40
|
+
requireDist()
|
|
41
|
+
const { diagnoseDialog } = await distModule('core/diagnose/error-resolver.js')
|
|
42
|
+
const workdir = await freshDir('04-unknown-dialog-abort')
|
|
43
|
+
|
|
44
|
+
const dataToolbox = await createDataToolbox({ workdir })
|
|
45
|
+
try {
|
|
46
|
+
section('0. Prepare a project (data plane, no GUI)')
|
|
47
|
+
const projectPath = join(workdir, 'dialog-demo.svip3')
|
|
48
|
+
const created = await dataToolbox.call('xstudio_project_create', {
|
|
49
|
+
out_path: projectPath,
|
|
50
|
+
singer_id: 'beta-netease:wudi',
|
|
51
|
+
notes: [{ pos: 0, len: 480, pitch: 60, lyric: '啦' }],
|
|
52
|
+
})
|
|
53
|
+
check(created.ok, 'project creation failed')
|
|
54
|
+
info(`project: ${projectPath}`)
|
|
55
|
+
|
|
56
|
+
section('1. diagnoseDialog — unknown text → the always-safe manual action')
|
|
57
|
+
const diagnosis = await diagnoseDialog(UNKNOWN_DIALOG, {})
|
|
58
|
+
info(`via=${diagnosis.via} suggestedAction=${diagnosis.suggestedAction} confidence=${diagnosis.confidence}`)
|
|
59
|
+
info(`cause: ${diagnosis.cause}`)
|
|
60
|
+
info(`manualInstruction: ${diagnosis.manualInstruction ?? '(none)'}`)
|
|
61
|
+
check(diagnosis.via === 'local-fallback', 'an unknown dialog must fall back to local-fallback')
|
|
62
|
+
check(diagnosis.suggestedAction === 'manual', `expected manual, got ${diagnosis.suggestedAction}`)
|
|
63
|
+
check(diagnosis.confidence === 0, 'the fallback must carry confidence 0')
|
|
64
|
+
check(diagnosis.manualInstruction.includes('QX-4096'), 'the instruction quotes the dialog snippet for the human')
|
|
65
|
+
|
|
66
|
+
section('2. xstudio_ui_dialog_respond — the real tool, fake sidecar + mocked search')
|
|
67
|
+
const sidecarLog = []
|
|
68
|
+
const sidecar = fakeSidecar(sidecarLog)
|
|
69
|
+
sidecar.openDialog({
|
|
70
|
+
title: 'X Studio',
|
|
71
|
+
text: UNKNOWN_DIALOG,
|
|
72
|
+
buttons: ['重试', '取消'],
|
|
73
|
+
windowClass: '#32770',
|
|
74
|
+
})
|
|
75
|
+
const control = await createFakeControlToolbox({
|
|
76
|
+
workdir,
|
|
77
|
+
sidecar,
|
|
78
|
+
diagnose: (text) => diagnoseDialog(text, {}),
|
|
79
|
+
})
|
|
80
|
+
const responded = reportEnvelope('xstudio_ui_dialog_respond (unknown dialog)', await control.call('xstudio_ui_dialog_respond', {}))
|
|
81
|
+
check(responded.ok, 'dialog_respond must succeed')
|
|
82
|
+
check(responded.data.suggested_action === 'manual', 'an unknown dialog must suggest manual handling')
|
|
83
|
+
check(responded.data.responded === false, 'nothing is auto-clicked for an unknown dialog')
|
|
84
|
+
info(`dialog buttons: ${responded.data.dialog.buttons.join(' / ')} → responded: ${responded.data.responded}`)
|
|
85
|
+
info(`manual instruction: ${responded.data.manual_instruction}`)
|
|
86
|
+
|
|
87
|
+
section('3. Destructive dialog — an explicit confirm is coerced to cancel')
|
|
88
|
+
sidecar.openDialog({
|
|
89
|
+
title: 'X Studio',
|
|
90
|
+
text: '是否保存更改?',
|
|
91
|
+
buttons: ['保存', '不保存', '取消'],
|
|
92
|
+
windowClass: '#32770',
|
|
93
|
+
})
|
|
94
|
+
const refused = reportEnvelope(
|
|
95
|
+
'xstudio_ui_dialog_respond (save-changes, action:confirm)',
|
|
96
|
+
await control.call('xstudio_ui_dialog_respond', { action: 'confirm' }),
|
|
97
|
+
)
|
|
98
|
+
check(refused.ok, 'dialog_respond must still answer safely')
|
|
99
|
+
check(refused.data.suggested_action === 'cancel', `destructive dialog must be cancelled, got ${refused.data.suggested_action}`)
|
|
100
|
+
check(sidecarLog.some((entry) => entry === 'sidecar.respondDialog cancel'), 'sidecar must receive cancel, never confirm')
|
|
101
|
+
info('the "save changes?" dialog is answered with cancel: the plugin keeps its own *.bak backups')
|
|
102
|
+
|
|
103
|
+
section('4. Simulated render outage → CLOUD_UNREACHABLE → xstudio_ui_abort')
|
|
104
|
+
const offlineLog = []
|
|
105
|
+
const offlineSidecar = fakeSidecar(offlineLog)
|
|
106
|
+
const outage = new TypeError('fetch failed')
|
|
107
|
+
outage.cause = new Error('getaddrinfo ENOTFOUND cloud.xstudio')
|
|
108
|
+
const offline = await createFakeControlToolbox({
|
|
109
|
+
workdir,
|
|
110
|
+
sidecar: offlineSidecar,
|
|
111
|
+
render: fakeRender(offlineLog, { triggerError: outage }),
|
|
112
|
+
})
|
|
113
|
+
const failed = await offline.call('xstudio_preview_trigger', { project_path: projectPath })
|
|
114
|
+
reportEnvelope('xstudio_preview_trigger (cloud down)', failed)
|
|
115
|
+
check(failed.ok === false && failed.error.code === 'CLOUD_UNREACHABLE', 'outage must map to CLOUD_UNREACHABLE')
|
|
116
|
+
const aborted = reportEnvelope('xstudio_ui_abort', await offline.call('xstudio_ui_abort'))
|
|
117
|
+
check(aborted.ok && aborted.data.ok === true, 'abort must succeed')
|
|
118
|
+
info(`offline fake-GUI log: ${offlineLog.join(' → ')}`)
|
|
119
|
+
check(offlineLog.includes('sidecar.abort'), 'abort must reach the sidecar')
|
|
120
|
+
|
|
121
|
+
console.log('\nDone. A real run would now report CLOUD_UNREACHABLE to the user and')
|
|
122
|
+
console.log('leave the project intact; the data plane remains fully usable offline.')
|
|
123
|
+
} finally {
|
|
124
|
+
await dataToolbox.dispose()
|
|
125
|
+
}
|
|
126
|
+
})
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# dsh-xstudio examples
|
|
2
|
+
|
|
3
|
+
Status: all five examples were executed against the built `dist/` on
|
|
4
|
+
2026-10-18 (Windows 11, bundled Node 24.21, plugin bundle installed) and exit 0;
|
|
5
|
+
the full test suite is 210/210 passing and `scripts/check-contract.mjs` reports
|
|
6
|
+
OK (24 registry / 24 MCP / 24 README tools).
|
|
7
|
+
|
|
8
|
+
Five runnable end-to-end examples for the compiled plugin. They exercise the
|
|
9
|
+
**real tool definitions** from `dist/` — the same objects the DSH Host plugin
|
|
10
|
+
and the MCP server register — with two deliberate substitutions so they are safe
|
|
11
|
+
and deterministic:
|
|
12
|
+
|
|
13
|
+
| Substitution | Why |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| GUI control plane is an in-memory fake sidecar/renderer | the examples never touch the user's X Studio window, never modify app state, and run on a machine without the app |
|
|
16
|
+
|
|
17
|
+
Every control-plane output in these examples says **simulated**; with X Studio
|
|
18
|
+
running, the same tool calls drive the real UIA automation.
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm install
|
|
24
|
+
pnpm build # examples import ../dist/*.js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
All examples exit 0 on success and non-zero on a failed assertion. Generated
|
|
28
|
+
files go to `examples/.scratch/<example>/` (gitignored); delete that directory
|
|
29
|
+
whenever you like.
|
|
30
|
+
|
|
31
|
+
## Run all five
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
node examples/01-midi-to-wudi.mjs
|
|
35
|
+
node examples/02-three-singers-compare.mjs
|
|
36
|
+
node examples/03-velocity-diction-rerender.mjs
|
|
37
|
+
node examples/04-unknown-dialog-abort.mjs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or one after another:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
for f in examples/0*.mjs; do node "$f" || exit 1; done
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## What each example demonstrates
|
|
47
|
+
|
|
48
|
+
### 01 — MIDI + lyrics → 伍笛 singing project (`01-midi-to-wudi.mjs`)
|
|
49
|
+
|
|
50
|
+
- writes a small Standard MIDI File with the plugin's own SMF writer;
|
|
51
|
+
- `xstudio_project_create` from MIDI + one lyric per note + `beta-netease:wudi`;
|
|
52
|
+
- `xstudio_project_read` (summary + notes + unknown-field count);
|
|
53
|
+
- `xstudio_midi_export` round trip (note count and tempo preserved);
|
|
54
|
+
- two-phase `xstudio_preview_trigger` → `xstudio_preview_wait` (simulated GUI);
|
|
55
|
+
- `xstudio_guide_print` for the human fallback.
|
|
56
|
+
|
|
57
|
+
Output: `examples/.scratch/01-midi-to-wudi/wudi-demo.svip3`.
|
|
58
|
+
|
|
59
|
+
### 02 — same melody, three singers (`02-three-singers-compare.mjs`)
|
|
60
|
+
|
|
61
|
+
- creates one base melody;
|
|
62
|
+
- `xstudio_singers_list()` returns the built-in catalog → `via: "pb"`;
|
|
63
|
+
- `refresh:true` stays local and adds the "Tavily removed" compatibility
|
|
64
|
+
warning;
|
|
65
|
+
- `xstudio_batch(dry_run:true)` validates the jobs and reports
|
|
66
|
+
`estimated_cloud_requests` **before** any cloud render is attempted;
|
|
67
|
+
- `xstudio_batch` writes one `.svip3` per singer; each is read back to verify
|
|
68
|
+
the singer name;
|
|
69
|
+
- three guarded two-phase render hand-offs (simulated), one per variant.
|
|
70
|
+
|
|
71
|
+
Output: `examples/.scratch/02-three-singers/melody*.svip3`.
|
|
72
|
+
|
|
73
|
+
### 03 — velocity + diction → re-render → export (`03-velocity-diction-rerender.mjs`)
|
|
74
|
+
|
|
75
|
+
- creates a phrase, lowers/raises the global velocity offset
|
|
76
|
+
(`xstudio_velocity_set`);
|
|
77
|
+
- `xstudio_lyrics_align(auto)` fills lyrics + phonemes from the local rule
|
|
78
|
+
table (no network exists in 0.2.0);
|
|
79
|
+
- `xstudio_note_edit` fixes one note's pitch and phoneme (diction);
|
|
80
|
+
- `xstudio_project_read` verifies absolute positions and counts the automatic
|
|
81
|
+
`*.bak.<timestamp>` backups;
|
|
82
|
+
- simulated render + export (`wav`, 48 kHz);
|
|
83
|
+
- a simulated cloud outage returns a `CLOUD_UNREACHABLE` envelope (not a throw)
|
|
84
|
+
and `xstudio_guide_print` provides manual export steps.
|
|
85
|
+
|
|
86
|
+
Output: `examples/.scratch/03-velocity-diction/phrase.svip3`.
|
|
87
|
+
|
|
88
|
+
### 04 — unknown dialog + abort path (`04-unknown-dialog-abort.mjs`)
|
|
89
|
+
|
|
90
|
+
- `diagnoseDialog` matches no local fingerprint → the always-safe `manual`
|
|
91
|
+
suggestion with confidence 0 (no network diagnosis exists in 0.2.0, so no
|
|
92
|
+
external text can enter the result by construction);
|
|
93
|
+
- the same path through the real `xstudio_ui_dialog_respond` tool with an
|
|
94
|
+
in-memory sidecar — unknown dialogs are never auto-clicked;
|
|
95
|
+
- a destructive `是否保存更改?` dialog cannot be confirmed: an explicit
|
|
96
|
+
`confirm` is coerced to `cancel`;
|
|
97
|
+
- a simulated cloud outage → `CLOUD_UNREACHABLE`, then `xstudio_ui_abort`
|
|
98
|
+
releases control (project files stay intact; writes are atomic + backed up).
|
|
99
|
+
|
|
100
|
+
Output: `examples/.scratch/04-unknown-dialog-abort/dialog-demo.svip3`.
|
|
101
|
+
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared plumbing for the xstudio-linux runnable examples.
|
|
3
|
+
*
|
|
4
|
+
* The examples execute the REAL compiled tool definitions from `dist/`. They
|
|
5
|
+
* never touch the network and never drive the real GUI:
|
|
6
|
+
* - data-plane tools run against real services (local catalog, no Tavily);
|
|
7
|
+
* - control-plane tools are wired to an in-memory fake GUI sidecar/renderer,
|
|
8
|
+
* which is clearly reported as simulated in the output.
|
|
9
|
+
*
|
|
10
|
+
* Run `pnpm build` first. Every example prints what it did and exits non-zero
|
|
11
|
+
* when an assertion about the tool surface fails.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync } from 'node:fs'
|
|
14
|
+
import { mkdir, rm } from 'node:fs/promises'
|
|
15
|
+
import { dirname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
17
|
+
|
|
18
|
+
/** Repository root (the directory containing package.json and dist/). */
|
|
19
|
+
export const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..')
|
|
20
|
+
/** Where examples write generated projects/MIDI files (gitignored: .scratch/). */
|
|
21
|
+
export const SCRATCH_ROOT = join(REPO_ROOT, 'examples', '.scratch')
|
|
22
|
+
/** Fixed clock so TTL/breaker behavior is deterministic across runs. */
|
|
23
|
+
export const FIXED_NOW = Date.parse('2026-10-18T00:00:00Z')
|
|
24
|
+
|
|
25
|
+
/** Print a section heading. */
|
|
26
|
+
export function section(title) {
|
|
27
|
+
console.log(`\n=== ${title} ===`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Print one informative line. */
|
|
31
|
+
export function info(message) {
|
|
32
|
+
console.log(` ${message}`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Assert a condition; on failure records a failed exit code and throws. */
|
|
36
|
+
export function check(condition, message) {
|
|
37
|
+
if (!condition) {
|
|
38
|
+
console.error(`\n✗ ${message}`)
|
|
39
|
+
process.exitCode = 1
|
|
40
|
+
throw new Error(message)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Path relative to the repository root, for readable output. */
|
|
45
|
+
export function rel(absolutePath) {
|
|
46
|
+
return relative(REPO_ROOT, absolutePath).replaceAll('\\', '/')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Exit with concrete build instructions when dist/ is missing. */
|
|
50
|
+
export function requireDist() {
|
|
51
|
+
if (existsSync(join(REPO_ROOT, 'dist', 'adapter-mcp', 'server.js'))) return
|
|
52
|
+
console.error(
|
|
53
|
+
[
|
|
54
|
+
'',
|
|
55
|
+
'✗ dist/ is missing: build the plugin first.',
|
|
56
|
+
'',
|
|
57
|
+
' pnpm install',
|
|
58
|
+
' pnpm build',
|
|
59
|
+
'',
|
|
60
|
+
` (looked for ${join(REPO_ROOT, 'dist', 'adapter-mcp', 'server.js')})`,
|
|
61
|
+
'',
|
|
62
|
+
].join('\n'),
|
|
63
|
+
)
|
|
64
|
+
process.exit(1)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Dynamically import one compiled module from dist/ (fails helpfully). */
|
|
68
|
+
export async function distModule(relativePath) {
|
|
69
|
+
const absolute = join(REPO_ROOT, 'dist', relativePath)
|
|
70
|
+
if (!existsSync(absolute)) {
|
|
71
|
+
console.error(`\n✗ compiled module missing: ${rel(absolute)} — run "pnpm build".`)
|
|
72
|
+
process.exit(1)
|
|
73
|
+
}
|
|
74
|
+
return import(pathToFileURL(absolute).href)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A clean scratch directory for one example. */
|
|
78
|
+
export async function freshDir(name) {
|
|
79
|
+
const dir = join(SCRATCH_ROOT, name)
|
|
80
|
+
await rm(dir, { recursive: true, force: true })
|
|
81
|
+
await mkdir(dir, { recursive: true })
|
|
82
|
+
return dir
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Build a config object without losing caller defaults. */
|
|
86
|
+
function buildConfig(workdir, overrides) {
|
|
87
|
+
const { wine, ...rest } = overrides
|
|
88
|
+
return {
|
|
89
|
+
xstudioInstallDir: join(workdir, 'xstudio-install'),
|
|
90
|
+
workspaceDir: join(workdir, 'workspace'),
|
|
91
|
+
defaultSinger: 'beta-netease:wudi',
|
|
92
|
+
backupOnWrite: true,
|
|
93
|
+
...rest,
|
|
94
|
+
wine: {
|
|
95
|
+
prefix: '~/.wine',
|
|
96
|
+
driveMappings: {},
|
|
97
|
+
...(wine ?? {}),
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Build the real 24-tool surface from compiled dist/ modules.
|
|
104
|
+
*
|
|
105
|
+
* @param {{ workdir: string, config?: object, fetchImpl?: typeof fetch, now?: () => number }} options
|
|
106
|
+
*/
|
|
107
|
+
export async function createDataToolbox(options) {
|
|
108
|
+
const workdir = options.workdir ?? (await freshDir('shared'))
|
|
109
|
+
const { resolveConfig } = await distModule('config.js')
|
|
110
|
+
const { createServices } = await distModule('services.js')
|
|
111
|
+
const { buildToolDefinitions } = await distModule('tools/registry.js')
|
|
112
|
+
|
|
113
|
+
const config = resolveConfig(buildConfig(workdir, options.config ?? {}))
|
|
114
|
+
const services = createServices(config, {
|
|
115
|
+
cwd: async () => workdir,
|
|
116
|
+
now: options.now ?? (() => FIXED_NOW),
|
|
117
|
+
fetchImpl: options.fetchImpl,
|
|
118
|
+
})
|
|
119
|
+
const tools = new Map(buildToolDefinitions(services).map((definition) => [definition.name, definition]))
|
|
120
|
+
const callTool = async (name, args = {}) => {
|
|
121
|
+
const definition = tools.get(name)
|
|
122
|
+
if (definition === undefined) throw new Error(`unknown tool "${name}"`)
|
|
123
|
+
return definition.execute(args, { signal: new AbortController().signal })
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
workdir,
|
|
127
|
+
config,
|
|
128
|
+
services,
|
|
129
|
+
tools,
|
|
130
|
+
names: [...tools.keys()],
|
|
131
|
+
call: callTool,
|
|
132
|
+
dispose: () => services.dispose(),
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Build the real control-plane tool definitions wired to a fake GUI.
|
|
138
|
+
* No process is spawned and no window is touched; every effect is recorded in
|
|
139
|
+
* `log` and reported as simulated.
|
|
140
|
+
*/
|
|
141
|
+
export async function createFakeControlToolbox(options) {
|
|
142
|
+
const workdir = options.workdir
|
|
143
|
+
const { controlTools } = await distModule('tools/control.js')
|
|
144
|
+
const { SkillGate } = await distModule('core/guard/skill-gate.js')
|
|
145
|
+
const log = []
|
|
146
|
+
const sidecar = options.sidecar ?? fakeSidecar(log)
|
|
147
|
+
const render = options.render ?? fakeRender(log)
|
|
148
|
+
const resolvePath = async (input) => (isAbsolute(input) ? resolve(input) : resolve(workdir, input))
|
|
149
|
+
const fakeServices = {
|
|
150
|
+
config: {},
|
|
151
|
+
resolvePath,
|
|
152
|
+
getSidecar: async () => sidecar,
|
|
153
|
+
getRender: async () => ({ sidecar, render }),
|
|
154
|
+
diagnose: options.diagnose,
|
|
155
|
+
// The examples simulate an agent that already loaded the xstudio-gui skill;
|
|
156
|
+
// the runtime gate itself is exercised by the dedicated gate tests and the
|
|
157
|
+
// live fresh-session check, not by these offline examples.
|
|
158
|
+
skillGate: new SkillGate({ probe: { isSkillLoaded: () => true } }),
|
|
159
|
+
}
|
|
160
|
+
const tools = new Map(controlTools(fakeServices).map((definition) => [definition.name, definition]))
|
|
161
|
+
const callTool = async (name, args = {}) => {
|
|
162
|
+
const definition = tools.get(name)
|
|
163
|
+
if (definition === undefined) throw new Error(`unknown tool "${name}"`)
|
|
164
|
+
return definition.execute(args, { signal: new AbortController().signal })
|
|
165
|
+
}
|
|
166
|
+
return { workdir, sidecar, render, log, tools, names: [...tools.keys()], call: callTool }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** An in-memory GuiSidecar; `dialog` may be replaced between calls. */
|
|
170
|
+
export function fakeSidecar(log) {
|
|
171
|
+
const state = { dialog: null }
|
|
172
|
+
return {
|
|
173
|
+
state,
|
|
174
|
+
/** Pretend an unknown dialog is open. */
|
|
175
|
+
openDialog(dialog) {
|
|
176
|
+
state.dialog = dialog
|
|
177
|
+
},
|
|
178
|
+
async probe() {
|
|
179
|
+
log.push('sidecar.probe')
|
|
180
|
+
return { running: true, foreground: true, windowTitle: '网易云音乐·X Studio - 2.svip3', pid: 22324 }
|
|
181
|
+
},
|
|
182
|
+
async snapshot() {
|
|
183
|
+
log.push('sidecar.snapshot')
|
|
184
|
+
return {
|
|
185
|
+
window: { title: '网易云音乐·X Studio - 2.svip3', pid: 22324, className: 'Qt622QWindowIcon' },
|
|
186
|
+
elements: [
|
|
187
|
+
{ ref: 'e1', name: '播放', automationId: 'playButton', className: 'QToolButton', controlType: 'Button', patterns: ['Invoke'], enabled: true, offscreen: false, depth: 3 },
|
|
188
|
+
{ ref: 'e2', name: '导出', automationId: 'exportButton', className: 'QToolButton', controlType: 'Button', patterns: ['Invoke'], enabled: true, offscreen: false, depth: 3 },
|
|
189
|
+
],
|
|
190
|
+
truncated: false,
|
|
191
|
+
capturedAt: FIXED_NOW,
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
async act(action) {
|
|
195
|
+
log.push(`sidecar.act ${action.ref} ${action.op}`)
|
|
196
|
+
return { ok: true, detail: 'simulated (no real window was touched)' }
|
|
197
|
+
},
|
|
198
|
+
async assert(assertion) {
|
|
199
|
+
log.push(`sidecar.assert ${assertion.ref ?? assertion.text ?? assertion.state}`)
|
|
200
|
+
return { ok: true, actual: 'simulated' }
|
|
201
|
+
},
|
|
202
|
+
async readDialog() {
|
|
203
|
+
log.push('sidecar.readDialog')
|
|
204
|
+
return state.dialog === null ? null : { ...state.dialog }
|
|
205
|
+
},
|
|
206
|
+
async respondDialog(choice) {
|
|
207
|
+
log.push(`sidecar.respondDialog ${choice}`)
|
|
208
|
+
state.dialog = null
|
|
209
|
+
return { ok: true, detail: `simulated response: ${choice}` }
|
|
210
|
+
},
|
|
211
|
+
async abort() {
|
|
212
|
+
log.push('sidecar.abort')
|
|
213
|
+
return { ok: true }
|
|
214
|
+
},
|
|
215
|
+
async dispose() {
|
|
216
|
+
log.push('sidecar.dispose')
|
|
217
|
+
},
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** An in-memory RenderOrchestrator; `triggerError` simulates a cloud outage. */
|
|
222
|
+
export function fakeRender(log, overrides = {}) {
|
|
223
|
+
return {
|
|
224
|
+
async trigger(projectPath) {
|
|
225
|
+
log.push(`render.trigger ${projectPath}`)
|
|
226
|
+
if (overrides.triggerError !== undefined) throw overrides.triggerError
|
|
227
|
+
return overrides.trigger ?? {
|
|
228
|
+
opened: true,
|
|
229
|
+
started: true,
|
|
230
|
+
steps: ['find main window', 'open file dialog', 'select project', 'confirm open', 'press play/render'],
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
async wait(timeoutMs) {
|
|
234
|
+
log.push(`render.wait ${timeoutMs}`)
|
|
235
|
+
return overrides.wait ?? {
|
|
236
|
+
completed: true,
|
|
237
|
+
elapsedMs: 4200,
|
|
238
|
+
evidence: ['progress dialog closed', 'waveform drawn', 'no error dialog'],
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
async runExport(request) {
|
|
242
|
+
log.push(`render.runExport ${request.format}`)
|
|
243
|
+
return overrides.export ?? { path: join(request.outDir, `simulated.${request.format}`), bytes: 0, format: request.format }
|
|
244
|
+
},
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Pretty-print a tool envelope's key facts without dumping huge payloads. */
|
|
249
|
+
export function reportEnvelope(label, envelope) {
|
|
250
|
+
const facts = [`via=${envelope.via}`, `ok=${envelope.ok}`]
|
|
251
|
+
if (envelope.ok !== true && envelope.error !== undefined) {
|
|
252
|
+
facts.push(`code=${envelope.error.code}`, `message=${envelope.error.message}`)
|
|
253
|
+
}
|
|
254
|
+
if (Array.isArray(envelope.warnings) && envelope.warnings.length > 0) {
|
|
255
|
+
facts.push(`warnings=${envelope.warnings.length}`)
|
|
256
|
+
}
|
|
257
|
+
console.log(` · ${label}: ${facts.join(' ')}`)
|
|
258
|
+
if (envelope.ok !== true && envelope.error !== undefined && Array.isArray(envelope.error.next) && envelope.error.next.length > 0) {
|
|
259
|
+
for (const step of envelope.error.next) console.log(` next: ${step}`)
|
|
260
|
+
}
|
|
261
|
+
return envelope
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Run one example, converting an unexpected throw into a failed exit code. */
|
|
265
|
+
export async function runExample(title, body) {
|
|
266
|
+
console.log(`\n# ${title}`)
|
|
267
|
+
try {
|
|
268
|
+
await body()
|
|
269
|
+
if (process.exitCode === undefined) console.log('\n✓ example finished')
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console.error('\n✗ example failed:', error instanceof Error ? (error.stack ?? error.message) : String(error))
|
|
272
|
+
process.exitCode = 1
|
|
273
|
+
}
|
|
274
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# `fixtures/uia` — UIA evidence fixtures
|
|
2
|
+
|
|
3
|
+
Real-structure UIA snapshots used as evidence and as shape references for
|
|
4
|
+
`xstudio_ui_snapshot` consumers. They are **fixtures, not automation maps**: no
|
|
5
|
+
cached coordinates and no hard-coded screen positions are used to drive the app
|
|
6
|
+
(actions only ever use refs from a live snapshot).
|
|
7
|
+
|
|
8
|
+
| File | Provenance | Status |
|
|
9
|
+
| --- | --- | --- |
|
|
10
|
+
| `main-window.snapshot.json` | Live read-only `xstudio_ui_snapshot` of the running X Studio 1.2.7 main window (131 elements, no dialog open) | verified-live |
|
|
11
|
+
| `open-dialog.snapshot.json` | Reconstruction of the earlier read-only recon capture of the native `打开工程` dialog (`#32770`), which was closed with `WM_CLOSE` afterwards | verified-recon (reconstructed) |
|
|
12
|
+
| `export-dialog.snapshot.json` | Reconstruction of the earlier read-only recon capture of `ExportAudioSettingDialog` (menu path `文件 → 导出 → 导出音频`, cancelled with `取消` afterwards) | verified-recon (reconstructed) |
|
|
13
|
+
|
|
14
|
+
## Redaction
|
|
15
|
+
|
|
16
|
+
- random snapshot token normalised (`fixture01:` / `recon01:` / `recon02:`);
|
|
17
|
+
- `pid` and `capturedAt` zeroed, wall-clock tokens removed;
|
|
18
|
+
- project file name in the window title replaced with `<project>`;
|
|
19
|
+
- absolute user directories in dialog labels replaced with `<user>`;
|
|
20
|
+
- nothing else is edited: element identity (`automationId`, `name`,
|
|
21
|
+
`className`, `controlType`, `patterns`, `toggleState`) is preserved exactly as
|
|
22
|
+
captured.
|
|
23
|
+
|
|
24
|
+
## Shape notes
|
|
25
|
+
|
|
26
|
+
- Snapshots may contain additive runtime fields beyond the `UiSnapshot`
|
|
27
|
+
contract: `snapshotId`, `warnings`, `additionalWindows`, and per-element
|
|
28
|
+
`parentRef` / `windowRef` / `toggleState`. The DSH/MCP adapters project only
|
|
29
|
+
the contract fields, so these extras stay internal.
|
|
30
|
+
- `windowRef` groups elements by top-level window; the element with `depth: 0`
|
|
31
|
+
is that window's root and its `windowRef` equals its own `ref`.
|
|
32
|
+
- `ref` values are snapshot-scoped: `"<token>:eN"` for the main window,
|
|
33
|
+
`"<token>:wN"` for other visible top-level windows (dialogs, popups, toasts).
|
|
34
|
+
|
|
35
|
+
The element identities are summarised for agents in
|
|
36
|
+
[ui-map.json](../../skills/xstudio-gui/ui-map.json) and the verification status
|
|
37
|
+
is discussed in [docs/RECON-GUI.md](../../docs/RECON-GUI.md).
|