@quicktvui/ai 1.1.14 → 1.1.18

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: copilot-instructions.md
3
- version: 1.1.14
3
+ version: 1.1.18
4
4
  ---
5
5
 
6
6
  # copilot-instructions.md - QuickTVUI AI Development Guide
@@ -49,6 +49,146 @@ When asked to create a new QuickTVUI project, you MUST NOT generate a generic Vu
49
49
  4. **Install Deps**: `yarn install`
50
50
  5. **Setup Reminder**: Remind the user to run `npm install -g @quicktvui/cli@latest` and `qui setup` if they haven't configured the environment (see https://quicktvui.com/zh-CN/guide/basic/quick-start.html).
51
51
 
52
+ ## Runtime Debug Data Workflow (CRITICAL)
53
+
54
+ When the task is to inspect a running QuickTVUI app, AI MUST use this priority:
55
+
56
+ 1. MCP first, if `@quicktvui/ai-debug-mcp` is connected.
57
+ 2. Otherwise use `quicktvui-ai debug-*` commands against `ESDebugServer`.
58
+ 3. Only ask the user to paste logs manually if neither tool path is available.
59
+
60
+ Required CLI sequence:
61
+
62
+ - `quicktvui-ai debug-targets --base-url http://127.0.0.1:38989`
63
+ - select `clientId`
64
+ - `quicktvui-ai debug-context --client-id <clientId>`
65
+ - `quicktvui-ai debug-events --client-id <clientId> --limit 100`
66
+ - `quicktvui-ai debug-native-logs --client-id <clientId> --limit 100`
67
+ - `quicktvui-ai debug-screenshot --client-id <clientId> --project <project-path>`
68
+
69
+ AI MUST NOT say it has checked logs/screenshots unless one of those MCP/CLI reads actually succeeded.
70
+
71
+ ## Plugin Server Workflow (CRITICAL)
72
+
73
+ When the task is to inspect, upload, or debug TV plugin server endpoints (`/hello`, `/status`, `/uploadSo`, `/uploadPlugin`), AI MUST use this priority:
74
+
75
+ 1. Prefer connected `quicktvui-ai-mcp` plugin tools:
76
+ - `plugin_server_check`
77
+ - `plugin_server_hello`
78
+ - `plugin_server_status`
79
+ - `plugin_upload_so`
80
+ - `plugin_upload_plugin`
81
+ 2. Otherwise use `quicktvui-ai plugin-*`
82
+ 3. Only fall back to manual `adb` + `curl` when neither tool path is available
83
+
84
+ Required order:
85
+
86
+ - Enable Toolkit RESTful API first:
87
+ - `quicktvui-ai plugin-enable-api --device <serial>`
88
+ - manual fallback: `adb -s <serial> shell am broadcast -a "eskit.sdk.core.ACTION_TOOLKIT_SETTING" --es "RESTFUL_API" "true"`
89
+ - Probe readiness:
90
+ - `plugin_server_check`
91
+ - or `quicktvui-ai plugin-check --device <serial>`
92
+ - Read current state:
93
+ - `plugin_server_status`
94
+ - or `quicktvui-ai plugin-status --device <serial>`
95
+ - Resolve plugin server address:
96
+ - explicit `baseUrl` / `--plugin-base-url`
97
+ - adb-connected device service address
98
+ - adb forward + `http://127.0.0.1:36366` when target host cannot be inferred
99
+ - if multiple adb devices are connected, ask for `serial` or `baseUrl`
100
+ - if no adb-connected device exists, ask the user for service IP / `baseUrl` and never invent a developer-specific TV IP
101
+ - Upload So zip:
102
+ - choose the archive matching `ro.product.cpu.abi`
103
+ - `quicktvui-ai plugin-upload-so --device <serial> --tag eskit.so.ffmpeg.command --pkg eskit.so.ffmpeg.command --file <zip-path>`
104
+ - Upload plugin APK:
105
+ - `quicktvui-ai plugin-upload-plugin --device <serial> --pkg eskit.plugin.imagequality --file <apk-path>`
106
+
107
+ Hard requirements:
108
+
109
+ - Runtime endpoint behavior overrides markdown docs.
110
+ - Probe `/hello`, `/status`, `/uploadSo`, `/uploadPlugin` with `POST`, not `GET`.
111
+ - If AI is working inside the `quicktvui-ai` repo and finds doc/runtime drift, AI MUST update the docs.
112
+ - `uploadSo` currently has `pkg` / `tag` drift. AI SHOULD send both fields and trust successful `data.tag`.
113
+ - Default demo identifiers:
114
+ - So package/tag: `eskit.so.ffmpeg.command`
115
+ - Plugin package: `eskit.plugin.imagequality`
116
+ - ABI MUST match `ro.product.cpu.abi` on the service-corresponding device, but AI SHOULD only resolve ABI when uploading So and SHOULD let CLI / MCP fill it on demand if `abi` is not explicitly provided.
117
+ - AI MUST NOT claim upload success unless MCP or CLI returned a success payload.
118
+ - `status.pluginList` may still be empty after `uploadPlugin` returns `registered: true`; report that exact state.
119
+ - `uploadPlugin` success or `registered: true` only means the package reached plugin service storage. If the task is to use the plugin from a Vue page, AI MUST still add Vue-side installation logic.
120
+ - After uploading a newly rebuilt or replaced plugin package, restart the host/runtime process before validating page-side usage or startup; the running host does not hot-swap new plugin bytes automatically.
121
+ - Consult:
122
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-server-api.md`
123
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-server.md`
124
+
125
+
126
+ ## Plugin Scaffold Workflow (CRITICAL)
127
+
128
+ When the user asks AI to create/update/build Android plugin projects, native modules, or native UI components, AI MUST use this priority:
129
+
130
+ 1. Prefer connected `quicktvui-ai-mcp` tools:
131
+ - `plugin_project_create`
132
+ - `plugin_project_build`
133
+ - `plugin_module_create`
134
+ - `plugin_component_create`
135
+ 2. Otherwise use `quicktvui-ai`:
136
+ - `plugin-create-project`
137
+ - `plugin-build`
138
+ - `plugin-create-module`
139
+ - `plugin-create-component`
140
+ 3. Only if neither MCP nor CLI execution is available may AI scaffold manually
141
+
142
+ Decision rules:
143
+
144
+ - project init / update / packaging -> `plugin_project_create` / `plugin_project_build`
145
+ - non-UI native capability -> `plugin_module_create`
146
+ - native View + props/events/functions -> `plugin_component_create`
147
+
148
+ Hard requirements:
149
+
150
+ - Read these packaged docs first:
151
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-project.md`
152
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-module.md`
153
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-component.md`
154
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-scaffold-mcp.md`
155
+ - Source-of-truth interfaces come from `.source/sdk/base/...`:
156
+ - `com.quicktvui.sdk.base.module.IEsModule`
157
+ - `com.quicktvui.sdk.base.component.IEsComponent`
158
+ - `com.quicktvui.sdk.base.component.IEsComponentView`
159
+ - `com.quicktvui.sdk.base.component.EsComponentAttribute`
160
+ - Project creation MUST write `.kyy-plugin-project.json`
161
+ - By default, long-lived or releasable plugin projects SHOULD live under `<project-root>/plugin/<plugin-name>`
162
+ - Plugin projects MUST NOT default to hidden directories such as `.ai-test/*` or other dot-prefixed paths
163
+ - If plugin project is under a workspace subdirectory and root has `package.json`, AI MUST inject `build:android-plugin`
164
+ - Build order MUST be:
165
+ 1. `npm run build:android-plugin`
166
+ 2. `npm run build:plugin`
167
+ 3. `npm run build`
168
+ 4. `./gradlew assembleGeneralDebug`
169
+ - Module/component generation MUST require a concrete feature description first
170
+ - Java package segments MUST be valid identifiers; do NOT place kebab-case directly into Java package names
171
+ - Component generation MUST create/update `docs/component/<kebab-name>.md`
172
+ - Component tags MUST be kebab-case
173
+ - In Vue `h()`, do NOT use the fully-qualified Java class name
174
+ - If plugin build reports missing Android SDK, resolve SDK generically in this order: `ANDROID_SDK_ROOT` -> `ANDROID_HOME` -> platform default SDK directories.
175
+ - If SDK is found and the target plugin project lacks `local.properties` / `sdk.dir`, allow CLI / MCP to create or update that local file for the current machine only.
176
+ - Never turn one developer's local Android SDK path into a shared rule, hardcoded project setting, or committed repository file.
177
+ - Read plugin runtime installation references when the page must really use the plugin:
178
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/module/plugin.md`
179
+ - `node_modules/@quicktvui/ai/rules/.docs/examples/module/plugin/es-basic.vue`
180
+ - `node_modules/@quicktvui/ai/rules/.source/quicktvui/src/long-image/index.vue`
181
+ - Build/upload success does NOT mean the Vue page can already use the plugin.
182
+ - If a Vue page depends on the plugin, use `useESPlugin()` from `@extscreen/es3-core`, add listeners in `onESCreate`, and remove them in `onESDestroy`.
183
+ - For component plugins, call `useES().isComponentRegistered("<fully-qualified-component-class>")` before using the component, and install the plugin first when registration is still missing.
184
+ - Gate plugin-dependent rendering and calls on installation / registration readiness instead of assuming upload or install finishes synchronously.
185
+ - Scaffold structure should follow `.source/sdk/base/...`, but live device logs override the default runtime namespace when startup fails.
186
+ - If logs show `ClassNotFoundException: com.quicktvui.sdk.base.core.EsProxy` or missing `com.quicktvui.sdk.base.*`, treat that as runtime compatibility drift and adapt runtime-facing imports/registration to the namespace actually present on the device before rebuilding/reuploading.
187
+ - If logs show `java.lang.NoSuchMethodError: No static method get()Leskit/sdk/support/core/EsProxy;`, treat that as a bytecode-signature mismatch in the plugin registration entry, realign `EsProxy.get()` usage / registration to the actual device runtime signature, then rebuild/reupload.
188
+ - Do not confuse local stub compilation with device runtime availability.
189
+ - After install success, allow a short retry/recheck window if registration is still briefly missing.
190
+ - After reuploading a compatibility-fixed plugin build, restart the host/runtime process before retesting.
191
+ - If docs drift from source or implementation, AI MUST update docs
52
192
 
53
193
  ## Game Loop & Timer Constraints (CRITICAL)
54
194
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: .windsurfrules
3
- version: 0.6.1
3
+ version: 1.1.14
4
4
  ---
5
5
 
6
6
  # .windsurfrules - QuickTVUI AI Development Guide
@@ -83,6 +83,146 @@ Hard requirements:
83
83
  - If user asks to launch a specific ES app/version/source, run:
84
84
  `quicktvui-ai run-esapp --project <project-path> --pkg <es-package> [options]`
85
85
 
86
+ ## Runtime Debug Data Workflow (CRITICAL)
87
+
88
+ When the user asks AI to inspect runtime logs, native logs, screenshots, or target state:
89
+
90
+ 1. Prefer connected `@quicktvui/ai-debug-mcp`
91
+ 2. Otherwise use `quicktvui-ai debug-*`
92
+ 3. Only ask the user to paste logs manually when neither path is available
93
+
94
+ Required CLI order:
95
+
96
+ 1. `quicktvui-ai debug-targets --base-url http://127.0.0.1:38989`
97
+ 2. resolve `clientId`
98
+ 3. `quicktvui-ai debug-context --client-id <clientId>`
99
+ 4. `quicktvui-ai debug-events --client-id <clientId> --limit 100`
100
+ 5. `quicktvui-ai debug-native-logs --client-id <clientId> --limit 100`
101
+ 6. `quicktvui-ai debug-screenshot --client-id <clientId> --project <project-path>`
102
+
103
+ AI MUST NOT claim it inspected runtime data unless MCP or `quicktvui-ai debug-*` actually returned it.
104
+
105
+ ## Plugin Server Workflow (CRITICAL)
106
+
107
+ When the user asks AI to inspect, upload, or debug TV plugin server endpoints (`/hello`, `/status`, `/uploadSo`, `/uploadPlugin`):
108
+
109
+ 1. Prefer connected `quicktvui-ai-mcp` plugin tools:
110
+ - `plugin_server_check`
111
+ - `plugin_server_hello`
112
+ - `plugin_server_status`
113
+ - `plugin_upload_so`
114
+ - `plugin_upload_plugin`
115
+ 2. Otherwise use `quicktvui-ai plugin-*`
116
+ 3. Only fall back to manual `adb` + `curl` when neither path is available
117
+
118
+ Required order:
119
+
120
+ 1. Enable Toolkit RESTful API first:
121
+ - `quicktvui-ai plugin-enable-api --device <serial>`
122
+ - manual fallback: `adb -s <serial> shell am broadcast -a "eskit.sdk.core.ACTION_TOOLKIT_SETTING" --es "RESTFUL_API" "true"`
123
+ 2. Probe readiness:
124
+ - `plugin_server_check`
125
+ - or `quicktvui-ai plugin-check --device <serial>`
126
+ 3. Read current state:
127
+ - `plugin_server_status`
128
+ - or `quicktvui-ai plugin-status --device <serial>`
129
+ 4. Upload So zip:
130
+ - choose the archive matching `ro.product.cpu.abi` on the service-corresponding device
131
+ - `quicktvui-ai plugin-upload-so --device <serial> --tag eskit.so.ffmpeg.command --pkg eskit.so.ffmpeg.command --file <zip-path>`
132
+ 5. Upload plugin APK:
133
+ - `quicktvui-ai plugin-upload-plugin --device <serial> --pkg eskit.plugin.imagequality --file <apk-path>`
134
+
135
+ Hard requirements:
136
+
137
+ - Runtime endpoint behavior overrides markdown docs.
138
+ - Probe `/hello`, `/status`, `/uploadSo`, `/uploadPlugin` with `POST`, not `GET`.
139
+ - Resolve plugin server address in this order:
140
+ - explicit `baseUrl` / `--plugin-base-url`
141
+ - adb-connected device service address
142
+ - adb forward + `http://127.0.0.1:36366` when target host cannot be inferred
143
+ - If multiple adb devices are connected, ask the user to choose `serial` or provide service IP / `baseUrl`.
144
+ - If no adb-connected device exists, ask the user for service IP / `baseUrl` and never invent a developer-specific TV IP.
145
+ - If AI is working inside the `quicktvui-ai` repo and finds doc/runtime drift, AI MUST update the docs.
146
+ - `uploadSo` currently has `pkg` / `tag` drift. AI SHOULD send both fields and trust successful `data.tag`.
147
+ - Default demo identifiers:
148
+ - So package/tag: `eskit.so.ffmpeg.command`
149
+ - Plugin package: `eskit.plugin.imagequality`
150
+ - ABI MUST match `ro.product.cpu.abi` on the service-corresponding device, but AI SHOULD only resolve ABI when uploading So and SHOULD let CLI / MCP fill it on demand if `abi` is not explicitly provided.
151
+ - AI MUST NOT claim upload success unless MCP or CLI returned a success payload.
152
+ - `status.pluginList` may still be empty after `uploadPlugin` returns `registered: true`; report that exact state.
153
+ - `uploadPlugin` success or `registered: true` only means the package reached plugin service storage. If the task is to use the plugin from a Vue page, AI MUST still add Vue-side installation logic.
154
+ - After uploading a newly rebuilt or replaced plugin package, restart the host/runtime process before validating page-side usage or startup; the running host does not hot-swap new plugin bytes automatically.
155
+ - Consult:
156
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-server-api.md`
157
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-server.md`
158
+
159
+
160
+ ## Plugin Scaffold Workflow (CRITICAL)
161
+
162
+ When the user asks AI to create/update/build Android plugin projects, native modules, or native UI components, AI MUST use this priority:
163
+
164
+ 1. Prefer connected `quicktvui-ai-mcp` tools:
165
+ - `plugin_project_create`
166
+ - `plugin_project_build`
167
+ - `plugin_module_create`
168
+ - `plugin_component_create`
169
+ 2. Otherwise use `quicktvui-ai`:
170
+ - `plugin-create-project`
171
+ - `plugin-build`
172
+ - `plugin-create-module`
173
+ - `plugin-create-component`
174
+ 3. Only if neither MCP nor CLI execution is available may AI scaffold manually
175
+
176
+ Decision rules:
177
+
178
+ - Project init / update / packaging -> `plugin_project_create` / `plugin_project_build`
179
+ - Non-UI native capability -> `plugin_module_create`
180
+ - Native View + props/events/functions -> `plugin_component_create`
181
+
182
+ Hard requirements:
183
+
184
+ - Read these packaged docs first:
185
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-project.md`
186
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-module.md`
187
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-component.md`
188
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-scaffold-mcp.md`
189
+ - Source-of-truth interfaces come from `.source/sdk/base/...`:
190
+ - `com.quicktvui.sdk.base.module.IEsModule`
191
+ - `com.quicktvui.sdk.base.component.IEsComponent`
192
+ - `com.quicktvui.sdk.base.component.IEsComponentView`
193
+ - `com.quicktvui.sdk.base.component.EsComponentAttribute`
194
+ - Project creation MUST write `.kyy-plugin-project.json`
195
+ - By default, long-lived or releasable plugin projects SHOULD live under `<project-root>/plugin/<plugin-name>`
196
+ - Plugin projects MUST NOT default to hidden directories such as `.ai-test/*` or other dot-prefixed paths
197
+ - If plugin project is under a workspace subdirectory and root has `package.json`, AI MUST inject `build:android-plugin`
198
+ - Build order MUST be:
199
+ 1. `npm run build:android-plugin`
200
+ 2. `npm run build:plugin`
201
+ 3. `npm run build`
202
+ 4. `./gradlew assembleGeneralDebug`
203
+ - If plugin build reports missing Android SDK, resolve SDK generically in this order: `ANDROID_SDK_ROOT` -> `ANDROID_HOME` -> platform default SDK directories.
204
+ - If SDK is found and the target plugin project lacks `local.properties` / `sdk.dir`, allow CLI / MCP to create or update that local file for the current machine only.
205
+ - Never turn one developer's local Android SDK path into a shared rule, hardcoded project setting, or committed repository file.
206
+ - Module/component generation MUST require a concrete feature description first
207
+ - Java package segments MUST be valid identifiers; do NOT place kebab-case directly into Java package names
208
+ - Component generation MUST create/update `docs/component/<kebab-name>.md`
209
+ - Component tags MUST be kebab-case
210
+ - In Vue `h()`, do NOT use the fully-qualified Java class name
211
+ - Read plugin runtime installation references when the page must really use the plugin:
212
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/module/plugin.md`
213
+ - `node_modules/@quicktvui/ai/rules/.docs/examples/module/plugin/es-basic.vue`
214
+ - `node_modules/@quicktvui/ai/rules/.source/quicktvui/src/long-image/index.vue`
215
+ - Build/upload success does NOT mean the Vue page can already use the plugin.
216
+ - If a Vue page depends on the plugin, use `useESPlugin()` from `@extscreen/es3-core`, add listeners in `onESCreate`, and remove them in `onESDestroy`.
217
+ - For component plugins, call `useES().isComponentRegistered("<fully-qualified-component-class>")` before using the component, and install the plugin first when registration is still missing.
218
+ - Gate plugin-dependent rendering and calls on installation / registration readiness instead of assuming upload or install finishes synchronously.
219
+ - Scaffold structure should follow `.source/sdk/base/...`, but live device logs override the default runtime namespace when startup fails.
220
+ - If logs show `ClassNotFoundException: com.quicktvui.sdk.base.core.EsProxy` or missing `com.quicktvui.sdk.base.*`, treat that as runtime compatibility drift and adapt runtime-facing imports/registration to the namespace actually present on the device before rebuilding/reuploading.
221
+ - If logs show `java.lang.NoSuchMethodError: No static method get()Leskit/sdk/support/core/EsProxy;`, treat that as a bytecode-signature mismatch in the plugin registration entry, realign `EsProxy.get()` usage / registration to the actual device runtime signature, then rebuild/reupload.
222
+ - Do not confuse local stub compilation with device runtime availability.
223
+ - After install success, allow a short retry/recheck window if registration is still briefly missing.
224
+ - After reuploading a compatibility-fixed plugin build, restart the host/runtime process before retesting.
225
+ - If docs drift from source or implementation, AI MUST update docs
86
226
 
87
227
  ## Game Loop & Timer Constraints (CRITICAL)
88
228
 
package/rules/AGENTS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: AGENTS.md
3
- version: 1.1.14
3
+ version: 1.1.18
4
4
  ---
5
5
 
6
6
  # AGENTS.md - QuickTVUI AI Development Guide
@@ -115,6 +115,153 @@ Hard requirements:
115
115
  - If user asks to launch a specific ES app/version/source, run:
116
116
  `quicktvui-ai run-esapp --project <project-path> --pkg <es-package> [options]`
117
117
 
118
+ ## Runtime Debug Data Workflow (CRITICAL)
119
+
120
+ When the user asks AI to inspect runtime logs, native logs, screenshots, recent errors, or current target state for a running QuickTVUI app, AI MUST use this priority:
121
+
122
+ 1. Prefer MCP resources/tools when `@quicktvui/ai-debug-mcp` is connected.
123
+ 2. If MCP is unavailable but shell/CLI execution is available, AI MUST use `quicktvui-ai debug-*` commands against the running `ESDebugServer`.
124
+ 3. Only if neither MCP nor CLI execution is available may AI ask the user to paste logs manually.
125
+
126
+ Required non-MCP command order:
127
+
128
+ 1. `quicktvui-ai debug-targets --base-url http://127.0.0.1:38989`
129
+ 2. Choose `clientId`
130
+ - If only one target exists, AI MAY use it directly.
131
+ - If multiple targets exist, AI MUST ask user to confirm the right `clientId`.
132
+ 3. `quicktvui-ai debug-context --client-id <clientId>`
133
+ 4. `quicktvui-ai debug-events --client-id <clientId> --limit 100`
134
+ 5. `quicktvui-ai debug-native-logs --client-id <clientId> --limit 100`
135
+ 6. `quicktvui-ai debug-screenshot --client-id <clientId> --project <project-path>`
136
+
137
+ Hard requirements:
138
+
139
+ - AI MUST NOT claim it has inspected Chrome logs, Android native logs, target context, or screenshots unless MCP or `quicktvui-ai debug-*` actually returned data.
140
+ - If `debug-targets` returns an empty list, AI MUST clearly state that no active `ESDebugServer /ai/targets` are available yet.
141
+ - If `debug-native-logs` or `debug-screenshot` fails, AI MUST report the concrete command/error instead of fabricating fallback observations.
142
+ - When user asks for a screenshot and CLI mode is used, AI SHOULD prefer the file path returned by `quicktvui-ai debug-screenshot` rather than asking the user to locate the image manually.
143
+
144
+ ## Plugin Server Workflow (CRITICAL)
145
+
146
+ When the user asks AI to inspect, upload, or debug TV plugin server endpoints (`/hello`, `/status`, `/uploadSo`, `/uploadPlugin`), AI MUST use this priority:
147
+
148
+ 1. Prefer connected `quicktvui-ai-mcp` plugin tools:
149
+ - `plugin_server_check`
150
+ - `plugin_server_hello`
151
+ - `plugin_server_status`
152
+ - `plugin_upload_so`
153
+ - `plugin_upload_plugin`
154
+ 2. If MCP is unavailable but shell/CLI execution is available, AI MUST use `quicktvui-ai plugin-*`.
155
+ 3. Only if neither MCP nor CLI execution is available may AI fall back to manual `adb` + `curl`.
156
+
157
+ Required workflow:
158
+
159
+ 1. Enable Toolkit RESTful API first:
160
+ - CLI: `quicktvui-ai plugin-enable-api --device <serial>`
161
+ - Manual fallback: `adb -s <serial> shell am broadcast -a "eskit.sdk.core.ACTION_TOOLKIT_SETTING" --es "RESTFUL_API" "true"`
162
+ 2. Probe readiness:
163
+ - MCP: `plugin_server_check`
164
+ - CLI: `quicktvui-ai plugin-check --device <serial>`
165
+ 3. Read current state:
166
+ - MCP: `plugin_server_status`
167
+ - CLI: `quicktvui-ai plugin-status --device <serial>`
168
+ 4. Resolve plugin server address:
169
+ - If `baseUrl` / `--plugin-base-url` is explicitly provided, use it
170
+ - Otherwise, if adb already has a connected target, use that target's plugin service address first
171
+ - If the target host cannot be inferred, use adb port forward and `http://127.0.0.1:36366`
172
+ - If multiple adb devices are connected, AI MUST ask the user to choose `serial` or provide service IP / `baseUrl`
173
+ - If no adb-connected device exists, AI MUST ask the user for service IP / `baseUrl`, and MUST NOT invent or hardcode a developer-specific TV IP
174
+ 5. Upload So zip:
175
+ - choose the zip whose ABI matches `ro.product.cpu.abi` on the device that serves the current plugin endpoint
176
+ - CLI: `quicktvui-ai plugin-upload-so --device <serial> --tag eskit.so.ffmpeg.command --pkg eskit.so.ffmpeg.command --file <zip-path>`
177
+ 6. Upload plugin APK:
178
+ - CLI: `quicktvui-ai plugin-upload-plugin --device <serial> --pkg eskit.plugin.imagequality --file <apk-path>`
179
+
180
+ Hard requirements:
181
+
182
+ - AI MUST treat live endpoint behavior as the source of truth over markdown docs.
183
+ - AI MUST probe `/hello`, `/status`, `/uploadSo`, `/uploadPlugin` with `POST`, not `GET`.
184
+ - If AI is working inside the `quicktvui-ai` repository and docs disagree with the live interface, AI MUST update the docs to match the runtime behavior.
185
+ - `uploadSo` currently has observed `pkg` / `tag` drift. AI SHOULD send both `pkg` and `tag`, and treat successful response field `data.tag` as authoritative.
186
+ - The default demo identifiers are:
187
+ - So package/tag: `eskit.so.ffmpeg.command`
188
+ - Plugin package: `eskit.plugin.imagequality`
189
+ - ABI selection MUST match `ro.product.cpu.abi` on the service-corresponding device, but AI SHOULD only resolve ABI when uploading So and SHOULD let CLI / MCP fill it on demand if `abi` is not explicitly provided.
190
+ - AI MUST NOT claim upload success unless MCP or CLI returned a success payload.
191
+ - `status.pluginList` may remain empty even after `uploadPlugin` returns `registered: true`; AI MUST report that as-is instead of fabricating a derived install state.
192
+ - `uploadPlugin` success or `registered: true` only means the package reached the plugin service. If the user needs to use that plugin from a Vue page, AI MUST still add Vue-side plugin installation logic and MUST NOT treat upload as "already installed in page runtime".
193
+ - Uploading a newly rebuilt or replaced plugin package to the plugin service does NOT hot-swap the already running host/runtime process. Before validating startup, registration, or page-side usage after a new plugin upload, AI MUST restart the host/runtime process so the new plugin bytes can take effect.
194
+ - AI SHOULD consult these packaged docs before generating commands or guidance:
195
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-server-api.md`
196
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-server.md`
197
+
198
+ ## Plugin Scaffold Workflow (CRITICAL)
199
+
200
+ When the user asks AI to create/update/build Android plugin projects, native modules, or native UI components, AI MUST use this priority:
201
+
202
+ 1. Prefer connected `quicktvui-ai-mcp` tools:
203
+ - `plugin_project_create`
204
+ - `plugin_project_build`
205
+ - `plugin_module_create`
206
+ - `plugin_component_create`
207
+ 2. If MCP is unavailable but shell/CLI execution is available, AI MUST use `quicktvui-ai`:
208
+ - `plugin-create-project`
209
+ - `plugin-build`
210
+ - `plugin-create-module`
211
+ - `plugin-create-component`
212
+ 3. Only if neither MCP nor CLI execution is available may AI scaffold manually.
213
+
214
+ Decision rules:
215
+
216
+ - Project template init / update / packaging -> `plugin_project_create` / `plugin_project_build`
217
+ - Non-UI native capability -> `plugin_module_create`
218
+ - Native View + props/events/functions -> `plugin_component_create`
219
+
220
+ Hard requirements:
221
+
222
+ - AI SHOULD consult these packaged docs first:
223
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-project.md`
224
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-module.md`
225
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-component.md`
226
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-scaffold-mcp.md`
227
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/module/plugin.md`
228
+ - `node_modules/@quicktvui/ai/rules/.docs/examples/module/plugin/es-basic.vue`
229
+ - `node_modules/@quicktvui/ai/rules/.source/quicktvui/src/long-image/index.vue`
230
+ - Source-of-truth interfaces come from `.source/sdk/base/...` and override markdown docs:
231
+ - `com.quicktvui.sdk.base.module.IEsModule`
232
+ - `com.quicktvui.sdk.base.component.IEsComponent`
233
+ - `com.quicktvui.sdk.base.component.IEsComponentView`
234
+ - `com.quicktvui.sdk.base.component.EsComponentAttribute`
235
+ - The scaffold shape should follow `.source/sdk/base/...`, but target-device runtime logs are authoritative for runtime namespace compatibility.
236
+ - If device logs show `ClassNotFoundException: com.quicktvui.sdk.base.core.EsProxy` or other missing `com.quicktvui.sdk.base.*` classes during plugin startup, AI MUST treat that as a runtime-compatibility failure, switch runtime-facing registration/imports to the namespace actually present on the device, and rebuild/reupload instead of repeatedly forcing the scaffold default.
237
+ - If device logs show `java.lang.NoSuchMethodError: No static method get()Leskit/sdk/support/core/EsProxy;`, AI MUST treat that as a bytecode-signature mismatch between the plugin's compiled registration entry and the actual device runtime, not as a page-logic bug. AI MUST realign runtime-facing `EsProxy.get()` usage / imports / registration path to the signature actually present on the device, then rebuild and reupload.
238
+ - AI MUST distinguish compile-time stubs from real device runtime classes. A plugin that compiles against local stubs but crashes on device because `EsProxy` or related runtime classes are missing is NOT considered valid.
239
+ - Plugin build/upload does NOT mean Vue can already use the plugin. If a Vue page needs the plugin at runtime, AI MUST add Vue-side installation with `useESPlugin()` from `@extscreen/es3-core`.
240
+ - AI MUST register plugin listeners in `onESCreate` and remove them in `onESDestroy`.
241
+ - For component plugins, AI SHOULD call `useES().isComponentRegistered("<fully-qualified-component-class>")` before rendering or dispatching to the plugin component, and install the plugin first when registration is still missing.
242
+ - AI MUST gate plugin-dependent Vue rendering or calls on installation / registration readiness, instead of assuming upload or install starts synchronously and finishes instantly.
243
+ - After page-side install success, if module/component registration is still missing, AI SHOULD perform a short retry/recheck window before declaring failure, because registration may lag slightly behind the install callback.
244
+ - After reuploading a new plugin build for a runtime-compatibility fix, AI MUST restart the host/runtime process before retesting, because the already running host may still hold the old plugin bytes.
245
+ - Project creation MUST write `.kyy-plugin-project.json`.
246
+ - For long-lived or releasable plugin projects, AI SHOULD place the project under `<project-root>/plugin/<plugin-name>` by default.
247
+ - AI MUST NOT default plugin projects to hidden directories such as `.ai-test/*` or other dot-prefixed paths.
248
+ - If the plugin project is created under a workspace subdirectory and the workspace root has `package.json`, AI MUST inject `build:android-plugin`.
249
+ - Build order MUST be:
250
+ 1. `npm run build:android-plugin`
251
+ 2. `npm run build:plugin`
252
+ 3. `npm run build`
253
+ 4. `./gradlew assembleGeneralDebug`
254
+ - If plugin build reports missing Android SDK, AI MUST first resolve SDK generically via `ANDROID_SDK_ROOT`, then `ANDROID_HOME`, then platform-default SDK directories, before declaring the environment broken.
255
+ - If SDK is found and the target plugin project lacks `local.properties` / `sdk.dir`, AI MAY let CLI / MCP create or update that local file for the current machine only.
256
+ - AI MUST NOT turn one developer's local Android SDK path into a shared rule, hardcoded project setting, or committed repository file.
257
+ - Module/component generation MUST require a concrete feature description before generating files.
258
+ - Java package segments MUST be valid identifiers. Do NOT put kebab-case directly into Java package names.
259
+ - Component generation MUST create or update `docs/component/<kebab-name>.md`.
260
+ - Component tags MUST be kebab-case.
261
+ - In Vue `h()`, AI MUST NOT use the fully-qualified Java class name; use the component class name or agreed tag name instead.
262
+ - When an `Application` class can be located, AI SHOULD register generated classes with `EsProxy.get().registerModule(...)` or `EsProxy.get().registerComponent(...)`.
263
+ - If docs drift from source or actual implementation, AI MUST update the docs.
264
+
118
265
  ## 🔥 ARCHITECTURAL GOTCHAS (CRITICAL)
119
266
 
120
267
  AI assistants frequently fail by applying traditional Web paradigms to QuickTVUI. **You MUST memorize these constraints**:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: AI_HANDOFF.md
3
- version: 1.1.14
3
+ version: 1.1.18
4
4
  ---
5
5
 
6
6
  # QuickTVUI AI 集成 - 工作交接文档
@@ -61,6 +61,136 @@ AI 在编写业务逻辑时,极易带入传统 Web 开发习惯导致严重报
61
61
  - 不得在未检查 CLI 能力前直接进入 `yarn dev` / 手写 `adb` 流程。
62
62
  - 若某一步骤在 `quicktvui-ai-cli` 中不存在对应命令,AI 必须先明确说明“CLI 暂不支持该步骤”,再走手工兜底流程。
63
63
 
64
+ ## Runtime Debug Data Workflow (CRITICAL)
65
+
66
+ 对于“读取运行中应用调试数据”的任务,后续 AI 必须统一遵循以下优先级:
67
+
68
+ 1. 优先使用 `@quicktvui/ai-debug-mcp`
69
+ 2. 没有 MCP 时,使用 `quicktvui-ai debug-*`
70
+ 3. 两者都不可用时,才要求用户手工提供日志或截图
71
+
72
+ 当前约定的非 MCP 命令链路:
73
+
74
+ 1. `quicktvui-ai debug-targets --base-url http://127.0.0.1:38989`
75
+ 2. 选择或确认 `clientId`
76
+ 3. `quicktvui-ai debug-context --client-id <clientId>`
77
+ 4. `quicktvui-ai debug-events --client-id <clientId> --limit 100`
78
+ 5. `quicktvui-ai debug-native-logs --client-id <clientId> --limit 100`
79
+ 6. `quicktvui-ai debug-screenshot --client-id <clientId> --project <project-path>`
80
+
81
+ 接手注意事项:
82
+
83
+ - 未通过 MCP 或 `quicktvui-ai debug-*` 真正读取到数据前,不得宣称“已检查运行时日志/截图”
84
+ - `debug-targets` 返回空数组时,应先回到 run/dev 链路,确认 `ESDebugServer /ai/targets` 已建立
85
+ - `debug-screenshot` 默认会把图片写到 `<project>/.quicktvui-ai/debug-screenshots/`,后续 AI 应优先使用命令返回的 `savedTo` 路径
86
+ - `debug-native-logs` 与 `debug-screenshot` 的失败信息应直接向用户透明披露,不要二次包装成模糊描述
87
+
88
+ ## 插件服务工作流 (CRITICAL)
89
+
90
+ 当任务涉及电视插件服务接口(`/hello`、`/status`、`/uploadSo`、`/uploadPlugin`)时,后续 AI 必须统一遵循以下优先级:
91
+
92
+ 1. 优先使用 `quicktvui-ai-mcp` 中的插件工具
93
+ 2. 没有 MCP 时,使用 `quicktvui-ai plugin-*`
94
+ 3. 两者都不可用时,才退回手工 `adb` + `curl`
95
+
96
+ 当前约定的执行顺序:
97
+
98
+ 1. 先打开 Toolkit RESTful API
99
+ - `quicktvui-ai plugin-enable-api --device <serial>`
100
+ - 或手工:`adb -s <serial> shell am broadcast -a "eskit.sdk.core.ACTION_TOOLKIT_SETTING" --es "RESTFUL_API" "true"`
101
+ 2. 健康检查
102
+ - MCP:`plugin_server_check`
103
+ - CLI:`quicktvui-ai plugin-check --device <serial>`
104
+ 3. 读取状态
105
+ - MCP:`plugin_server_status`
106
+ - CLI:`quicktvui-ai plugin-status --device <serial>`
107
+ 4. 解析插件服务地址
108
+ - 如果显式传了 `baseUrl` / `--plugin-base-url`,优先使用该地址
109
+ - 否则,如果 adb 已连接设备,先尝试使用该设备的插件服务地址
110
+ - 如果无法从目标设备推断 host,则改用 adb 端口转发和 `http://127.0.0.1:36366`
111
+ - 如果同时连接了多台 adb 设备,后续 AI 必须要求用户选择 `serial` 或提供服务 IP / `baseUrl`
112
+ - 如果没有任何 adb 已连接设备,后续 AI 必须向用户索要服务 IP / `baseUrl`,不得脑补或写死某个开发者自己的电视 IP
113
+ 5. 上传 So
114
+ - 必须先根据当前插件服务对应设备的 `ro.product.cpu.abi` 选择 zip
115
+ - CLI:`quicktvui-ai plugin-upload-so --device <serial> --tag eskit.so.ffmpeg.command --pkg eskit.so.ffmpeg.command --file <zip-path>`
116
+ 6. 上传插件 APK
117
+ - CLI:`quicktvui-ai plugin-upload-plugin --device <serial> --pkg eskit.plugin.imagequality --file <apk-path>`
118
+
119
+ 接手注意事项:
120
+
121
+ - 文档与接口返回不一致时,统一以接口真实返回为准
122
+ - `/hello`、`/status`、`/uploadSo`、`/uploadPlugin` 必须使用 `POST` 探测,不能用 `GET` 判断服务是否可用
123
+ - 如果此时正在 `quicktvui-ai` 仓库中改规则或文档,必须同步把差异写回文档
124
+ - `uploadSo` 目前存在 `pkg` / `tag` 漂移,调用时应尽量同时传这两个字段
125
+ - 测试 Demo 固定标识:
126
+ - So:`eskit.so.ffmpeg.command`
127
+ - 插件:`eskit.plugin.imagequality`
128
+ - `uploadPlugin` 返回 `registered: true` 后,`status.pluginList` 仍可能为空;后续 AI 必须按真实状态说明
129
+ - 重新上传新的插件包后,接手方在复测前必须先重启宿主 / runtime 进程;当前进程不会自动热更新到新插件字节码
130
+ - 优先参考包内文档:
131
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-server-api.md`
132
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-server.md`
133
+
134
+ ## 插件脚手架工作流 (CRITICAL)
135
+
136
+ 当任务涉及 Android 插件工程创建 / 更新 / 打包,或原生模块 / 原生组件生成时,后续 AI 必须统一遵循以下优先级:
137
+
138
+ 1. 优先使用 `quicktvui-ai-mcp`
139
+ 2. 没有 MCP 时,使用 `quicktvui-ai plugin-*`
140
+ 3. 两者都不可用时,才退回手工脚手架
141
+
142
+ 当前约定工具:
143
+
144
+ 1. 工程创建 / 更新:`plugin_project_create` 或 `quicktvui-ai plugin-create-project`
145
+ 2. 工程打包:`plugin_project_build` 或 `quicktvui-ai plugin-build`
146
+ 3. 无界面原生能力:`plugin_module_create` 或 `quicktvui-ai plugin-create-module`
147
+ 4. 有界面原生能力:`plugin_component_create` 或 `quicktvui-ai plugin-create-component`
148
+
149
+ 接手注意事项:
150
+
151
+ - 先查阅包内文档:
152
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-project.md`
153
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-module.md`
154
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/cli/plugin-create-component.md`
155
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/tool/api/plugin-scaffold-mcp.md`
156
+ - `node_modules/@quicktvui/ai/rules/.docs/zh-CN/module/plugin.md`
157
+ - `node_modules/@quicktvui/ai/rules/.docs/examples/module/plugin/es-basic.vue`
158
+ - `node_modules/@quicktvui/ai/rules/.source/quicktvui/src/long-image/index.vue`
159
+ - 真实接口必须以 `.source/sdk/base/...` 为准:
160
+ - `com.quicktvui.sdk.base.module.IEsModule`
161
+ - `com.quicktvui.sdk.base.component.IEsComponent`
162
+ - `com.quicktvui.sdk.base.component.IEsComponentView`
163
+ - `com.quicktvui.sdk.base.component.EsComponentAttribute`
164
+ - 脚手架结构默认仍以 `.source/sdk/base/...` 为准,但目标设备运行时日志对运行时命名空间兼容性拥有更高优先级。
165
+ - 如果设备日志出现 `ClassNotFoundException: com.quicktvui.sdk.base.core.EsProxy`,或启动阶段提示缺失 `com.quicktvui.sdk.base.*`,接手方必须把它视为运行时兼容性问题,并改为适配设备实际存在的命名空间后重新构建、重传。
166
+ - 如果设备日志出现 `java.lang.NoSuchMethodError: No static method get()Leskit/sdk/support/core/EsProxy;`,接手方必须把它视为插件注册入口的字节码签名不兼容,而不是页面逻辑问题;应按设备真实 runtime 的 `EsProxy.get()` 签名 / 调用路径调整后重新构建、重传。
167
+ - 不要把“本地 stub 编译通过”误判成“设备运行时也没问题”;只要设备侧因为 `EsProxy` 或相关类缺失而崩溃,就必须回到兼容性修复。
168
+ - 如果是为修复运行时兼容性而重新上传的新插件版本,接手方在复测前必须先重启宿主 / runtime 进程,否则当前进程仍可能持有旧插件字节码。
169
+ - 插件工程打包完成或插件包上传完成,并不代表 Vue 页面已经可直接使用插件;如果需求里包含页面接入,接手方必须补齐 Vue 侧安装逻辑。
170
+ - Vue 侧必须使用 `@extscreen/es3-core` 的 `useESPlugin()`,并在 `onESCreate` 中添加监听、在 `onESDestroy` 中移除监听。
171
+ - 对于组件型插件,接手方应优先使用 `useES().isComponentRegistered("<组件完整类名>")` 判断是否已注册;若未注册,应先安装插件,再渲染或调用对应组件。
172
+ - 不允许把“已上传插件”误判成“页面里已自动安装完成”,也不允许跳过安装完成监听。
173
+ - 如果页面收到安装成功回调后,注册状态仍短暂不可见,接手方应允许一次简短轮询复查,而不是立刻判定失败。
174
+ - 创建工程后必须写入 `.kyy-plugin-project.json`
175
+ - 对于长期保留或准备发布的插件工程,默认应放在 `<project-root>/plugin/<plugin-name>` 这种项目根目录下的可见目录
176
+ - 不允许把插件工程默认放到 `.ai-test/*` 等隐藏目录或其他点前缀目录
177
+ - 若插件工程位于子目录且根目录有 `package.json`,必须注入 `build:android-plugin`
178
+ - 如果插件构建报 Android SDK 缺失,接手方应先按通用顺序探测 SDK:`ANDROID_SDK_ROOT` -> `ANDROID_HOME` -> 当前平台默认 SDK 目录。
179
+ - 如果已探测到 SDK 且目标插件工程缺少 `local.properties` / `sdk.dir`,可以让 CLI / MCP 只为当前开发机补齐该本地文件。
180
+ - 不要把某个开发者本机的 Android SDK 路径写进共享规则、硬编码项目配置或提交到仓库。
181
+ - 打包顺序固定为:
182
+ 1. `npm run build:android-plugin`
183
+ 2. `npm run build:plugin`
184
+ 3. `npm run build`
185
+ 4. `./gradlew assembleGeneralDebug`
186
+ - 生成 module / component 前必须先拿到明确功能描述
187
+ - Java 包名不能使用带 `-` 的包段,不能把 `kebab-case` 直接写进 Java 包路径
188
+ - component 必须同步生成或更新 `docs/component/<kebab-name>.md`
189
+ - 组件标签必须使用 `kebab-case`
190
+ - 在 Vue `h()` 中禁止使用完整 Java 包名,必须使用组件类名或约定标签名
191
+ - 若能定位到 `Application`,应优先补 `EsProxy.get().registerModule(...)` / `EsProxy.get().registerComponent(...)`
192
+ - 文档与源码或实际实现不一致时,必须回写文档
193
+
64
194
  ---
65
195
 
66
196
  ## 一、项目背景