@uwa4d/openapi-mcp 0.2.0-beta.0 → 0.2.0-beta.10

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 (46) hide show
  1. package/README.md +105 -9
  2. package/dist/annotate-dashboard.d.ts +48 -0
  3. package/dist/annotate-dashboard.js +413 -0
  4. package/dist/cli.js +29 -6
  5. package/dist/client.js +4 -13
  6. package/dist/composite/helpers.d.ts +19 -0
  7. package/dist/composite/helpers.js +90 -0
  8. package/dist/composite/index.d.ts +25 -0
  9. package/dist/composite/index.js +46 -0
  10. package/dist/composite/name-pattern.d.ts +8 -0
  11. package/dist/composite/name-pattern.js +25 -0
  12. package/dist/composite/overview-view.d.ts +33 -0
  13. package/dist/composite/overview-view.js +373 -0
  14. package/dist/composite/report-diagnosis.d.ts +2 -0
  15. package/dist/composite/report-diagnosis.js +347 -0
  16. package/dist/composite/route-overview.d.ts +72 -0
  17. package/dist/composite/route-overview.js +233 -0
  18. package/dist/composite/stack-agg.d.ts +77 -0
  19. package/dist/composite/stack-agg.js +409 -0
  20. package/dist/composite/stack-test-mode.d.ts +33 -0
  21. package/dist/composite/stack-test-mode.js +60 -0
  22. package/dist/composite/top-functions.d.ts +21 -0
  23. package/dist/composite/top-functions.js +178 -0
  24. package/dist/composite/top-resources.d.ts +12 -0
  25. package/dist/composite/top-resources.js +263 -0
  26. package/dist/composite/types.d.ts +25 -0
  27. package/dist/composite/types.js +2 -0
  28. package/dist/error-hints.d.ts +23 -0
  29. package/dist/error-hints.js +80 -0
  30. package/dist/indicator-dashboard-keys.d.ts +12 -0
  31. package/dist/indicator-dashboard-keys.js +50 -0
  32. package/dist/indicator-dashboard-keys.json +338 -0
  33. package/dist/presets.js +9 -0
  34. package/dist/server-instructions.d.ts +5 -0
  35. package/dist/server-instructions.js +17 -0
  36. package/dist/server.d.ts +6 -1
  37. package/dist/server.js +33 -5
  38. package/dist/tools.d.ts +17 -0
  39. package/dist/tools.js +399 -18
  40. package/dist/version-check.d.ts +14 -0
  41. package/dist/version-check.js +94 -0
  42. package/dist/version-guide.d.ts +19 -0
  43. package/dist/version-guide.js +223 -0
  44. package/package.json +2 -2
  45. package/spec/overrides.json +26 -0
  46. package/spec/uwa-openapi.json +495 -111
@@ -0,0 +1,223 @@
1
+ /**
2
+ * 版本成对工具的选用规则。
3
+ *
4
+ * 集中手写、挂到 describe() 首段,避免散落在 notes 里被模型漏读。
5
+ * 不塞进 docs/ 生成链路——刷新官方文档镜像不会冲掉这里。
6
+ */
7
+ /**
8
+ * indicatorDashboards 传参名称说明(面板标识符,非统计维度后缀)。
9
+ * 挂到所有带 indicatorDashboards 的工具 description,避免模型见 _max 只读峰值。
10
+ */
11
+ export const INDICATOR_DASHBOARD_PANEL_GUIDE = [
12
+ '【indicatorDashboards 传参名称——勿按后缀猜统计维度】',
13
+ '- 传参名(如 temperature_max、fps_avg、drawcall_cnt_max)是**面板标识符**,_max / _avg / @max 等为历史命名,**不限制**返回 mean / maximum / min 等统计类型。',
14
+ '- 【返回粒度】每个面板一次返回其下所有子指标的全部统计量(mean / min / maximum / maximum_frame / 专属指标,以及 scene_*),',
15
+ ' 无需也无法按统计量拆成多个面板名(勿传 fps_mean、fps_max、fps_min)。面板→子指标展开见返回体 group;入参→出参映射见 _paramFieldMap。',
16
+ '- 例:temperature_max 面板含子指标 temperature、android_temper_cpu、android_temper_gpu、android_temper_battery;',
17
+ ' · 曲线接口(indicator_curve / custom_dashboard)→ 各子指标逐帧曲线;',
18
+ ' · 统计 2.0(indicator_statistic_dashboard)→ statistic 下 *_mean / *_maximum / *_min 及 scene_* 等全量统计。',
19
+ '- 查温度曲线/均值/峰值:Unity Overview 且 SDK ≥ 2.5.1 时传 indicatorDashboards=temperature_max,再读 y_axis 或 statistic;勿仅看 get_overview_statistic 的汇总段。',
20
+ '- 合法面板名先调 gotonline_overview_indicator_dashboard_keys(全量枚举);勿传 fps_mean、frametime_min、android_pss_max 等统计字段名。',
21
+ '- 误传示例:fps_mean、android_pss_max、frametime_gt_40_pct(缺 @)、frametime_min;合法示例:fps_avg、android_memory_pss@max、frametime@gt_40_pct。',
22
+ '- Android PSS 峰值:只认面板 android_memory_pss@max;优先读返回顶层 pss_peak_kb / pss_peak_mb / pss_peak_frame(单位 KB)。',
23
+ '- UE Overview 当前 Open API 未开放 custom/indicator dashboard 路径(会 24052),UE 温度汇总见 get_ue_overview_statistic_v2 的 temperature 段。',
24
+ ].join('\n');
25
+ /**
26
+ * 堆栈 / 卡顿工具路由。卡顿树已是「多帧合并后的根因视图」,
27
+ * 禁止误导成「对每个 >40ms 帧循环拉指定帧树再聚类」。
28
+ */
29
+ export const STACK_ANALYSIS_GUIDE = [
30
+ '【堆栈/卡顿选用——务必先看】',
31
+ '- 卡顿根因主路径:用**卡顿聚合树**(已合并全部/场景内卡顿帧),不要对每个慢帧循环拉指定帧树。',
32
+ '- 工具分工:',
33
+ ' · gotonline_overview_stack_stutter_full_presign → 卡顿帧列表(哪些帧卡、类型耗时拆分)',
34
+ ' · gotonline_overview_stack_stutter_full_tree_presign → **全部卡顿帧合并后的堆栈树**(全报告卡顿共性根因)',
35
+ ' · gotonline_overview_stack_stutter_scene_tree_presign → **指定场景内卡顿帧合并树**(主玩法段)',
36
+ ' · gotonline_overview_stack_tree_frame_presign → **单帧**完整树(仅尖峰深挖,如已知 frameId=8439)',
37
+ ' · gotonline_overview_stack_overall_tree_presign → 整线程全量堆栈(非卡顿专用;看持续税/全局热点)',
38
+ ' · gotonline_overview_stack_sample_frame_presign → 树结点逐帧曲线',
39
+ '- 慢帧占比/挑代表帧:indicator 面板 frametime@gt_40_pct(统计或 curve+valueGt);根因归因仍走卡顿聚合树。',
40
+ '- 读任何堆栈树前必须配合 gotonline_overview_stack_id_map(树里是 methodId)。',
41
+ '- 错误假设:❌「没有批量帧树就无法做卡顿根因」——总体/场景卡顿树就是合并结果。',
42
+ ].join('\n');
43
+ /** 写入工具 description 的「选用规则」块,key 为 operation id。 */
44
+ export const VERSION_GUIDE = {
45
+ get_overview_statistic_v1: [
46
+ '【选用规则——务必先看】',
47
+ '- Unity:仅适用于解析日 < 2026-07-09 的 Overview 报告。新报告请改用 get_overview_statistic_v2。',
48
+ '- UE:仅适用于提交日 ≤ 2026-03-25 的 Overview 报告。新报告请改用 get_ue_overview_statistic_v2。',
49
+ '- 不确定日期时:先调 get_report_detail 看 createDate / engine / sdkVersion;或直接用复合工具 report_diagnosis / top_functions(内部自动路由)。',
50
+ ].join('\n'),
51
+ get_overview_statistic_v2: [
52
+ '【选用规则——务必先看】',
53
+ '- 仅 Unity。解析日 ≥ 2026-07-09 且 SDK ≥ 2.5.1 的 Overview 报告。',
54
+ '- 更早的 Unity 报告请用 get_overview_statistic_v1。UE 报告请用 get_ue_overview_statistic_v2(或旧报告用 get_overview_statistic_v1)。',
55
+ '- 不确定时用复合工具 report_diagnosis / top_functions,无需自己选版本。',
56
+ ].join('\n'),
57
+ get_ue_overview_statistic_v2: [
58
+ '【选用规则——务必先看】',
59
+ '- 仅 UE。提交日 > 2026-03-25 的 Overview 报告。',
60
+ '- 更早的 UE 报告请用 get_overview_statistic_v1。Unity 报告请用 get_overview_statistic_v1 或 get_overview_statistic_v2。',
61
+ '- 单次批量最多 30 份(文档写 50,实测上限 30)。不确定时用复合工具自动路由。',
62
+ ].join('\n'),
63
+ get_scene_statistic_v1: [
64
+ '【选用规则——务必先看】',
65
+ '- 仅 Unity。解析日 < 2026-07-09 的 Overview 报告场景统计。',
66
+ '- 新报告请改用 get_scene_statistic_v2。',
67
+ ].join('\n'),
68
+ get_scene_statistic_v2: [
69
+ '【选用规则——务必先看】',
70
+ '- 仅 Unity。解析日 ≥ 2026-07-09 且 SDK ≥ 2.5.1 的 Overview 报告场景统计。',
71
+ '- 更早的报告请用 get_scene_statistic_v1。',
72
+ ].join('\n'),
73
+ gotonline_overview_custom_dashboard: [
74
+ '【选用规则——务必先看】',
75
+ '- 自定义面板统计 1.0(抽帧曲线)。不支持 GPU 类面板。',
76
+ '- 需要 GPU 指标或更多统计值类型时,改用 gotonline_overview_indicator_statistic_dashboard(2.0,需 SDK ≥ 2.5.1)。',
77
+ '- 逐帧曲线用 gotonline_overview_indicator_curve_dashboard(2.0,最多 3 个面板)。',
78
+ INDICATOR_DASHBOARD_PANEL_GUIDE,
79
+ ].join('\n'),
80
+ gotonline_overview_indicator_statistic_dashboard: [
81
+ '【选用规则——务必先看】',
82
+ '- 自定义面板统计 2.0。需 SDK ≥ 2.5.1,支持 GPU 指标,最多 15 个面板。',
83
+ '- 旧接口(抽帧、无 GPU)见 gotonline_overview_custom_dashboard。',
84
+ '- 只要逐帧曲线不要统计值时用 gotonline_overview_indicator_curve_dashboard。',
85
+ '- 返回 statistic 为空时优先怀疑 indicatorDashboards 传错;响应可能含 _hint / _unknownDashboards。',
86
+ '- 响应可能含 _paramFieldMap(入参面板→出参字段)、_duplicateFlatAliases、_sceneUnitNote(scene_* 补单位标注)。',
87
+ INDICATOR_DASHBOARD_PANEL_GUIDE,
88
+ ].join('\n'),
89
+ gotonline_overview_indicator_curve_dashboard: [
90
+ '【选用规则——务必先看】',
91
+ '- 自定义面板帧数据 2.0。需 SDK ≥ 2.5.1,最多 3 个面板;不支持内存类面板。',
92
+ '- 要统计值(含场景维度)用 gotonline_overview_indicator_statistic_dashboard。',
93
+ '- 【横轴——勿混用】外层 x_axis 为逐帧共享横轴(1、2、3…);y_axis.{指标名}.x_axis 为该曲线专属横轴(常见步长 30:0、30、60…)。',
94
+ '- 读取某条曲线时:若存在专属 x_axis 必须用专属,否则才用外层共享 x_axis。把共享横轴套到 FPS 等专属曲线会错位。',
95
+ '- 响应另含 _axisBinding / _axisHint,按其中 xAxisSource 取值即可。',
96
+ '- 【过滤——MCP 侧】可选 valueGt / valueLt / topN / returnFramesOnly:只返回超阈值或 TopN 点,适合慢帧列表(例:frametime@gt_40_pct + valueGt=40)。',
97
+ '- 慢帧列表 ≠ 卡顿根因:根因请用 stutter_full_tree / stutter_scene_tree(卡顿帧已合并),不要对 valueGt 结果逐帧拉 stack_tree_frame。',
98
+ INDICATOR_DASHBOARD_PANEL_GUIDE,
99
+ ].join('\n'),
100
+ gotonline_gpu_curve: [
101
+ '【选用规则——务必先看】',
102
+ '- GPU 模式指标面板逐帧曲线,indicatorDashboards 为 GPU 面板映射表中的传参名称。',
103
+ INDICATOR_DASHBOARD_PANEL_GUIDE,
104
+ ].join('\n'),
105
+ gotonline_overview_memory_usage_snapshot: [
106
+ '【选用规则——务必先看】',
107
+ '- 资源快照帧号 1.0。仅适用于解析日 < 2026-07-09 的报告。',
108
+ '- 新报告请用 gotonline_overview_dump_frames(快照帧 2.0)。',
109
+ ].join('\n'),
110
+ gotonline_overview_dump_frames: [
111
+ '【选用规则——务必先看】',
112
+ '- 快照帧 2.0。仅适用于解析日 ≥ 2026-07-09 且 SDK ≥ 2.5.1 的报告。',
113
+ '- 更早的报告请用 gotonline_overview_memory_usage_snapshot。',
114
+ ].join('\n'),
115
+ gotonline_overview_log_export: [
116
+ '【选用规则——务必先看】',
117
+ '- 运行日志 1.0。Unity:解析日 < 2026-07-09;UE:提交日 ≤ 2026-03-25。',
118
+ '- 新报告请用 gotonline_lg_runtime_log_entries_presign(运行日志 2.0)。',
119
+ '- 空列表 ≠「一定没有日志」:新报告误用本接口也可能返回空,应改调 2.0。',
120
+ ].join('\n'),
121
+ gotonline_lg_runtime_log_entries_presign: [
122
+ '【选用规则——务必先看】',
123
+ '- 运行日志 2.0(预签名)。解析日 ≥ 2026-07-09 且 SDK ≥ 2.5.1。',
124
+ '- 更早的报告请用 gotonline_overview_log_export。',
125
+ '- 若返回 80108 FILE_META_NOT_EXIST:Unity = 无 LG meta / 未解析 = 无可用日志数据;UE = 方案切换过,只能说「暂不支持获取当前报告的运行日志」,勿断定报告本身无日志。',
126
+ ].join('\n'),
127
+ gotonline_gpu_bound: [
128
+ '【选用规则——务必先看】',
129
+ '- 说「GPU Bound / GPU 主瓶颈」前必须先调本工具。',
130
+ '- 返回 [] 只能说「未检出 Bound」,禁止断言 GPU 是主要瓶颈。',
131
+ '- Overview 上的 WaitForVsync / RenderTexture 不能替代本接口。',
132
+ ].join('\n'),
133
+ gotonline_overview_group_export: [
134
+ '【选用规则——务必先看】',
135
+ '- UE 自定义函数组统计 1.0。仅适用于提交日 ≤ 2026-03-25 的 UE 报告。',
136
+ '- 新 UE 报告请用 gotonline_overview_method_group_statistic(需 Header api 版本 v1.0.2)。',
137
+ ].join('\n'),
138
+ gotonline_overview_method_group_statistic: [
139
+ '【选用规则——务必先看】',
140
+ '- 自定义函数组统计(Unity SDK ≥ 2.5.1;UE 提交日 > 2026-03-25)。',
141
+ '- **MCP 默认 apiVersion=v1.0.2**(勿用 v1.0.1,会参数错误)。需要旧行为时显式传 apiVersion=v1.0.1。',
142
+ '- UE 旧报告请用 gotonline_overview_group_export。',
143
+ '- 未配置自定义函数组时 data=[];Overview 热点函数曲线优先用 method_idmap_statistic + method_curve_presign,不必依赖函数组。',
144
+ ].join('\n'),
145
+ gotonline_overview_method_idmap_statistic: [
146
+ '【选用规则——务必先看】',
147
+ '- **仅 Overview 报告**;返回 id_map 全部函数的统计(不去重、不过滤)。',
148
+ '- stackTestMode(Overview 堆栈采集模式)决定哪些字段有值:',
149
+ ' · CPU_ONLY:selfTimeMean / totalTimeMean / callCountTotal',
150
+ ' · LUA_MEM_ONLY:callCountTotal / selfMemoryMean / selfMemoryTotal',
151
+ ' · CPU_AND_LUA_MEM:以上全部;UE 固定 CPU_ONLY',
152
+ '- Unity:dataKey/recordId;UE:另传 threadName(如 GameThread)。Header v1.0.2。',
153
+ '- 复合工具 top_functions(Overview)会读 stackTestMode 并校验 metric;Mono 报告不走此规则。',
154
+ ].join('\n'),
155
+ gotonline_overview_method_curve: [
156
+ '【选用规则——务必先看】',
157
+ '- v1.0.1 直出曲线 JSON(按 stackMethodName 或 stackMethodId)。',
158
+ '- **MCP 与 Open API 推荐改用 gotonline_overview_method_curve_presign(v1.0.2)**:OSS 预签名,仅传 stackMethodId。',
159
+ '- stackMethodId 来自 gotonline_overview_method_idmap_statistic 或自定义函数组统计。',
160
+ ].join('\n'),
161
+ gotonline_overview_method_curve_presign: [
162
+ '【选用规则——务必先看】',
163
+ '- v1.0.2 OSS 预签名下载函数逐帧曲线 JSON(Unity · UE)。',
164
+ '- **Open API 入口仅支持 stackMethodId(必填)**;UE 另需 threadName。',
165
+ '- 不要用 v1.0.1 gotonline_overview_method_curve 除非必须服务端直出。',
166
+ '- stackMethodId 优先从 gotonline_overview_method_idmap_statistic 获取。',
167
+ ].join('\n'),
168
+ gotonline_overview_indicator_dashboard_keys: [
169
+ '【选用规则——务必先看】',
170
+ '- 返回 Overview 指标面板传参名称全量列表(indicatorDashboards 合法取值)。',
171
+ '- 无需 dataKey/recordId;与 statistic/curve dashboard 调用前校验同源。',
172
+ '- 勿把 fps_mean、frametime_min 等 statistic 内字段名当作面板名。',
173
+ '- 合法示例:fps_avg、drawcall_cnt_max、frametime@gt_40_pct、temperature_max。',
174
+ INDICATOR_DASHBOARD_PANEL_GUIDE,
175
+ ].join('\n'),
176
+ gotonline_overview_stack_id_map: [
177
+ '【选用规则——务必先看】',
178
+ '- 函数 ID ↔ 名称映射。解析任何 stack_*_tree / stutter_*_tree 前先调本工具。',
179
+ STACK_ANALYSIS_GUIDE,
180
+ ].join('\n'),
181
+ gotonline_overview_stack_overall_tree_presign: [
182
+ '【选用规则——务必先看】',
183
+ '- 指定线程的**全量**调用堆栈树(含非卡顿帧),适合持续税/全局热点。',
184
+ '- 只要卡顿根因:改用 stutter_full_tree / stutter_scene_tree,勿用本接口代替卡顿聚合。',
185
+ STACK_ANALYSIS_GUIDE,
186
+ ].join('\n'),
187
+ gotonline_overview_stack_stutter_full_presign: [
188
+ '【选用规则——务必先看】',
189
+ '- 卡顿**帧列表**(帧号 + 卡顿类型耗时拆分),不是堆栈树。',
190
+ '- 要卡顿根因堆栈:接着调 stutter_full_tree_presign(或场景版 stutter_scene_tree)。',
191
+ STACK_ANALYSIS_GUIDE,
192
+ ].join('\n'),
193
+ gotonline_overview_stack_stutter_full_tree_presign: [
194
+ '【选用规则——务必先看】',
195
+ '- **全部卡顿帧已合并**的调用堆栈树 = 卡顿根因主入口(服务端聚合,无需客户端逐帧拉树再聚类)。',
196
+ '- 禁止把 WaitForVsync / Gfx.WaitForPresent 写成卡顿根因或 GPU Bound 证据。',
197
+ '- 说「GPU 主瓶颈」前必须先查 gotonline_gpu_bound;空数组只能说「未检出 Bound」。',
198
+ '- 只要某一场景:用 stutter_scene_tree;只要某一尖峰帧细节:再用 stack_tree_frame。',
199
+ STACK_ANALYSIS_GUIDE,
200
+ ].join('\n'),
201
+ gotonline_overview_stack_stutter_scene_tree_presign: [
202
+ '【选用规则——务必先看】',
203
+ '- **指定场景内卡顿帧已合并**的堆栈树;sceneIndex 来自 list_scenes 下标。',
204
+ '- 禁止把 WaitForVsync 当根因;GPU 主瓶颈结论须先查 gpu_bound。',
205
+ '- 全报告卡顿用 stutter_full_tree;单帧深挖用 stack_tree_frame。',
206
+ STACK_ANALYSIS_GUIDE,
207
+ ].join('\n'),
208
+ gotonline_overview_stack_tree_frame_presign: [
209
+ '【选用规则——务必先看】',
210
+ '- **单帧**完整堆栈树(frameId 必填)。用于已知尖峰帧深挖,不是卡顿分析的第一步。',
211
+ '- 卡顿共性根因请先用 stutter_full_tree / stutter_scene_tree(已是多帧合并结果)。',
212
+ '- ❌ 不要对 frametime valueGt 筛出的每个慢帧循环调用本工具来「聚类」。',
213
+ STACK_ANALYSIS_GUIDE,
214
+ ].join('\n'),
215
+ gotonline_overview_stack_sample_frame_presign: [
216
+ '【选用规则——务必先看】',
217
+ '- 堆栈树某个结点的逐帧曲线;结点 id 来自树文件。',
218
+ STACK_ANALYSIS_GUIDE,
219
+ ].join('\n'),
220
+ };
221
+ export function versionGuideFor(opId) {
222
+ return VERSION_GUIDE[opId];
223
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwa4d/openapi-mcp",
3
- "version": "0.2.0-beta.0",
3
+ "version": "0.2.0-beta.10",
4
4
  "description": "UWA 开放平台 MCP Server,将 UWA Open API 暴露为 MCP 工具供 AI 助手调用",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "access": "public"
21
21
  },
22
22
  "scripts": {
23
- "gen": "tsx scripts/parse-docs.ts",
23
+ "gen": "tsx scripts/extract-dashboard-keys.ts && tsx scripts/parse-docs.ts",
24
24
  "build": "tsc -p tsconfig.json",
25
25
  "dev": "tsx src/cli.ts",
26
26
  "smoke": "tsx scripts/smoke-test.ts",
@@ -0,0 +1,26 @@
1
+ {
2
+ "$comment": [
3
+ "官方文档与接口实际行为不符时的修正层。",
4
+ "生成 spec 时套用(见 scripts/parse-docs.ts),因此刷新 docs/ 下的文档不会冲掉这里的修正。",
5
+ "每条都必须写明 verifiedAt 与 evidence——没有实测依据不要往这里加,",
6
+ "否则下一个人无法判断该修正是否已经过时。",
7
+ "上游修好文档后应删除对应条目,而不是留着。"
8
+ ],
9
+ "operations": {
10
+ "get_ue_overview_statistic_v2": {
11
+ "reason": "文档称单次最多 50 份,实测上限为 30 份",
12
+ "verifiedAt": "2026-08-04",
13
+ "evidence": "30 个长 dataKey(参数串 1140 字符)成功;31 个短 dataKey(参数串 1094 字符,更短)失败并返回 20001,排除 URL 长度因素。49 个 key 逐个单查均正常,故确为批量条数限制。",
14
+ "replaceInText": [
15
+ {
16
+ "from": "最多 50 个",
17
+ "to": "最多 30 个(文档写 50,实测上限 30)"
18
+ },
19
+ {
20
+ "from": "单次请求最多查询 50 份报告",
21
+ "to": "单次请求最多查询 30 份报告(文档写 50,实测上限 30,超出会返回 20001)"
22
+ }
23
+ ]
24
+ }
25
+ }
26
+ }