@quicktvui/ai 1.1.16 → 1.1.19

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