ms-vite-plugin 1.4.15 → 1.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/SKILL.md CHANGED
@@ -33,22 +33,32 @@ MCP 工具和项目命令都可以使用。
33
33
 
34
34
  可以使用命令的情况:
35
35
 
36
- - MCP transport 断开或不可用。
37
36
  - 用户明确要求使用命令。
38
37
  - 需要快速验证项目本地 `ms` CLI 能力。
39
- - 使用项目自带 KuaiJS CLI 进行同步、运行、停止、截图。
38
+ - 使用项目自带 KuaiJS CLI 查询文档、调用已确认的 HTTP API、同步、运行、停止、截图、抓节点、查日志和 OCR。
40
39
 
41
40
  允许的常用命令示例:
42
41
 
43
42
  ```bash
44
43
  npx ms --help
44
+ npx ms docs paths
45
+ npx ms docs search <query> --language js_zh
46
+ npx ms http-docs search <query>
47
+ npx ms http-call -i <device-ip> --port <port> --method GET --path <path> --doc-slug <slug>
45
48
  npx ms run -i <device-ip> --port <port>
46
49
  npx ms run-ui -i <device-ip> --port <port>
47
50
  npx ms screenshot -i <device-ip> --port <port> --format file --output <path>
51
+ npx ms source -i <device-ip> --port <port> --mode 1 --output <path>
52
+ npx ms logs -i <device-ip> --port <port> --limit 200
53
+ npx ms ocr -i <device-ip> --port <port> --engine appleocr --mode recognize
54
+ npx ms screen-crop -i <device-ip> --port <port> --x <x> --y <y> --width <w> --height <h> --output <path>
55
+ npx ms screen-pick-color -i <device-ip> --port <port> --x <x> --y <y>
56
+ npx ms image-crop --image <path> --x <x> --y <y> --width <w> --height <h> --output <path>
57
+ npx ms image-transparent --image <path> --output <path>
48
58
  npx ms stop -i <device-ip> --port <port>
49
59
  ```
50
60
 
51
- 使用 `curl` 调用设备 HTTP API 前,必须先通过 MCP HTTP API 文档或本地 HTTP API 文档确认接口存在、方法、路径、参数位置和返回结构。
61
+ 使用 `ms http-call` 调用设备 HTTP API 前,必须先通过 MCP HTTP API 文档或 `ms http-docs` 确认接口存在、方法、路径、参数位置和返回结构。
52
62
 
53
63
  ## 目录职责
54
64
 
@@ -74,57 +84,66 @@ npx ms stop -i <device-ip> --port <port>
74
84
 
75
85
  回答快点JS API 或编写脚本前,先确认语言并查询对应语言文档。
76
86
 
77
- MCP 可用时:
87
+ MCP 入口:
78
88
 
79
- 1. 使用 `set_docs_language` 设置语言:`js`、`js_zh` 或 `python`。
80
- 2. 使用 `search_api_docs` 搜索相关模块或 API
81
- 3. 使用 `read_api_doc` 读取完整文档。
89
+ 1. 使用 `get_docs_paths` 获取本地文档路径。
90
+ 2. 使用 `search_api_docs` 搜索相关模块或 API,按需传 `language`。
91
+ 3. 使用 `read_api_doc` 读取完整文档,按需传 `language`。
82
92
  4. 只依据已确认的文档内容回答或编写代码。
83
93
 
84
- MCP 不可用时:
94
+ CLI 入口:
85
95
 
86
- 1. 查阅项目本地文档,例如 `node_modules/ms-vite-plugin/docs/apipython/`、`node_modules/ms-vite-plugin/docs/httpapi/`。
87
- 2. 只使用文档中已经确认的 API
88
- 3. 在回复中说明使用了本地文档作为 MCP fallback。
96
+ 1. 使用 `npx ms docs paths` 获取本地文档路径。
97
+ 2. 使用 `npx ms docs search <query> --language js_zh|js|python` 搜索语言 API 文档。
98
+ 3. 使用 `npx ms docs read <slug> --language js_zh|js|python` 读取完整文档。
99
+ 4. 只使用文档中已经确认的 API。
89
100
 
90
101
  ## HTTP API 工作流
91
102
 
92
103
  调用设备 HTTP API 前,必须查询 HTTP API 文档。
93
104
 
94
- MCP 可用时:
105
+ MCP 入口:
95
106
 
96
107
  1. 使用 `search_http_api_docs` 搜索目标能力、中文标题或接口路径。
97
108
  2. 使用 `read_http_api_doc` 读取目标接口片段。
98
109
  3. 确认 `method`、`path`、参数位置、参数类型和返回结构。
99
110
  4. 使用 `http_api_call` 调用接口,并传入文档返回的 `docSlug`。
100
111
 
101
- 命令 fallback 时:
112
+ CLI 入口:
102
113
 
103
- 1. 先在本地 HTTP API 文档中确认接口。
104
- 2. 再用 `curl` 调用明确存在的接口。
105
- 3. 不要把未确认的路径当成可用接口。
114
+ 1. 使用 `npx ms docs paths` 获取 HTTP API 文档路径。
115
+ 2. 使用 `npx ms http-docs search <query>` 搜索目标接口。
116
+ 3. 使用 `npx ms http-docs read <identifier> --method GET|POST` 读取目标接口片段。
117
+ 4. 使用 `npx ms http-call -i <device-ip> --port <port> --method <method> --path <path> --doc-slug <slug>` 调用明确存在的接口。
118
+ 5. 不要把未确认的路径当成可用接口。
106
119
 
107
120
  ## 设备工作流
108
121
 
109
122
  设备相关操作以用户指定的设备为准。不要假设设备已经设置;用户给出新设备时必须使用新设备。
110
123
 
111
- MCP 可用时:
124
+ MCP 入口:
112
125
 
113
126
  1. 使用 `get_device` 查看当前默认设备。
114
127
  2. 如果未设置设备,使用 `set_device` 设置设备 IP 和端口。
115
128
  3. 使用 `get_logs` 获取当前日志最新行。
116
129
 
117
- 命令 fallback 时:
130
+ CLI 入口:
118
131
 
119
132
  - 用 `npx ms run -i <device-ip> --port <port>` 运行脚本。
120
133
  - 用 `npx ms screenshot -i <device-ip> --port <port> --format file --output <path>` 截图验证。
134
+ - 用 `npx ms source -i <device-ip> --port <port> --mode 1 --output <path>` 获取节点 XML。
135
+ - 用 `npx ms logs -i <device-ip> --port <port> --limit 200` 查看当前日志。
136
+ - 用 `npx ms ocr -i <device-ip> --port <port> --engine appleocr --mode recognize` 执行 OCR。
137
+ - 用 `npx ms screen-crop` 或 `npx ms image-crop` 裁切找图模板。
138
+ - 用 `npx ms screen-pick-color` 或 `npx ms image-pick-color` 获取颜色。
139
+ - 用 `npx ms image-transparent` 制作透明找图模板。
121
140
  - 用 `npx ms stop -i <device-ip> --port <port>` 停止项目。
122
141
 
123
142
  UI 预览发起后不需要长时间等待结果,可以用截图查看当前界面效果。
124
143
 
125
144
  ## 项目运行工作流
126
145
 
127
- MCP 可用时:
146
+ MCP 入口:
128
147
 
129
148
  1. 使用 `set_workspace` 设置快点JS项目根目录。
130
149
  2. 使用 `get_workspace` 确认当前工作区。
@@ -133,20 +152,19 @@ MCP 可用时:
133
152
  5. 使用 `stop_project` 停止当前设备上的项目。
134
153
  6. 使用 `package_project` 执行生产打包。
135
154
 
136
- 命令可用时:
155
+ CLI 入口:
137
156
 
138
- 1. 使用项目根目录执行 `npx ms --help` 确认 CLI。
157
+ 1. 使用 `npx ms --help` 确认 CLI。
139
158
  2. 使用 `npx ms run -i <device-ip> --port <port>` 同步并运行。
140
159
  3. 使用 `npx ms screenshot ...` 验证界面。
141
160
 
142
- 工作区必须包含 `package.json` 和 `scripts/`。
161
+ `build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录必须包含 `package.json` 和 `scripts/`。文档、HTTP API 查询/调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。
143
162
 
144
163
  ## 工具分组
145
164
 
146
165
  ### 文档
147
166
 
148
- - `set_docs_language`
149
- - `get_docs_language`
167
+ - `get_docs_paths`
150
168
  - `list_api_docs`
151
169
  - `search_api_docs`
152
170
  - `read_api_doc`
@@ -180,9 +198,9 @@ MCP 可用时:
180
198
 
181
199
  - `http_api_call`
182
200
 
183
- 控制、HID、IME、镜像、配置、当前应用、运行脚本等普通设备 HTTP API 通过 `search_http_api_docs`、`read_http_api_doc` 和 `http_api_call` 使用;命令 fallback 时可用已确认文档的 `curl` 调用。
201
+ 控制、HID、IME、镜像、配置、当前应用、运行脚本等普通设备 HTTP API 通过 `search_http_api_docs`、`read_http_api_doc` 和 `http_api_call` 使用;CLI 入口使用 `ms http-docs``ms http-call`。
184
202
 
185
- OCR 没有独立 HTTP 接口,使用 `ocr_recognize` 通过 `POST /api/runScript` 执行快点JS OCR 脚本。`ocr_recognize` 支持 `appleocr` 和 `paddleocr`,默认 `appleocr`。`runScript` 的规则是最后一行表达式或变量会作为结果返回,不需要写 `return`。
203
+ 使用 `ocr_recognize` 执行 OCR 识别。`ocr_recognize` 支持 `appleocr` 和 `paddleocr`,默认 `appleocr`,识别结果坐标可直接用于点击。
186
204
 
187
205
  图片与识别工作流:
188
206
 
@@ -203,4 +221,4 @@ OCR 没有独立 HTTP 接口,使用 `ocr_recognize` 通过 `POST /api/runScrip
203
221
 
204
222
  ## 文档入口
205
223
 
206
- 优先通过 MCP 文档工具查询 API 文档。MCP 不可用时,可以查阅项目本地 `node_modules/ms-vite-plugin/docs/` 文档作为 fallback,并在说明中明确这一点。
224
+ 优先直接读取项目本地 `node_modules/ms-vite-plugin/docs/` 文档;也可以使用 MCP 文档工具或 `ms docs` / `ms http-docs` 定位具体文档。
@@ -4,11 +4,11 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
4
4
 
5
5
  ## 功能概览
6
6
 
7
- - **模型管理**: PP-OCRv5 模型加载和资源管理
7
+ - **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
8
8
  - **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
9
9
  - **区域识别**: 支持指定区域的精确文字识别
10
10
  - **结构化结果**: 提供详细的文本位置、置信度和方向信息
11
- - **资源控制**: 完整的模型生命周期管理
11
+ - **资源释放**: 可在需要时释放 OCR 资源
12
12
 
13
13
  ## 数据类型
14
14
 
@@ -61,7 +61,9 @@ interface OCRResult {
61
61
 
62
62
  ### 模型管理
63
63
 
64
- #### loadV5 - 初始化 PP-OCRv5 模型,这是使用 OCR 功能的前提。
64
+ #### loadV5 - 可选预加载 PP-OCRv5 模型。
65
+
66
+ 识别和查找方法会自动加载所需模型,通常不需要先调用 `loadV5`。只有需要提前加载或指定模型参数时才调用。
65
67
 
66
68
  ```typescript
67
69
  function loadV5(maxSideLen?: number, useGpu?: boolean): boolean;
@@ -69,29 +71,17 @@ function loadV5(maxSideLen?: number, useGpu?: boolean): boolean;
69
71
 
70
72
  **参数:**
71
73
 
72
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
73
- | ------------ | ------- | -------- | ------ | ----------------------------------- |
74
- | `maxSideLen` | number | 否 | 640 | 输入图像的最大边长,默认值为 640 |
75
- | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
74
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
75
+ | ------------ | ------- | -------- | ------ | -------------------------------- |
76
+ | `maxSideLen` | number | 否 | 640 | 输入图像的最大边长,默认值为 640 |
77
+ | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
76
78
 
77
79
  **返回值:**
78
80
 
79
- | 类型 | 描述 |
80
- | ------- | ------------------------------------------ |
81
+ | 类型 | 描述 |
82
+ | ------- | --------------------------------------------------- |
81
83
  | boolean | 加载成功或模型已加载返回 `true`,否则返回 `false` |
82
84
 
83
- 重复调用 `loadV5` 时,如果模型已经加载,会直接返回 `true`,不会重新加载或应用新的参数。需要更换加载参数时,先调用 `free()` 释放模型。
84
-
85
- **示例:**
86
-
87
- ```javascript
88
- // 使用默认参数加载模型
89
- const loaded = paddleOcr.loadV5();
90
- if (loaded) {
91
- logi("PP-OCRv5 模型加载成功");
92
- }
93
- ```
94
-
95
85
  ### 文字识别
96
86
 
97
87
  #### recognize - 执行 OCR 文字识别,支持多种输入源和指定识别区域。
@@ -127,12 +117,6 @@ function recognize(
127
117
  **示例:**
128
118
 
129
119
  ```javascript
130
- // 首先加载模型
131
- if (!paddleOcr.loadV5()) {
132
- logi("模型加载失败");
133
- return;
134
- }
135
-
136
120
  // 识别整个屏幕
137
121
  const fullScreenResults = paddleOcr.recognize("screen", 0, 0, 0, 0);
138
122
  logi(`识别到 ${fullScreenResults.length} 个文本区域`);
@@ -227,12 +211,6 @@ function findText(
227
211
  **示例:**
228
212
 
229
213
  ```javascript
230
- // 首先加载模型
231
- if (!paddleOcr.loadV5()) {
232
- logi("模型加载失败");
233
- return;
234
- }
235
-
236
214
  // 在整个屏幕中查找目标文本
237
215
  const hitResults = paddleOcr.findText(
238
216
  "screen",
@@ -4,11 +4,11 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
4
4
 
5
5
  ## 功能概览
6
6
 
7
- - **模型管理**: PP-OCRv5 模型加载和资源管理
7
+ - **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
8
8
  - **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
9
9
  - **区域识别**: 支持指定区域的精确文字识别
10
10
  - **结构化结果**: 提供详细的文本位置、置信度和方向信息
11
- - **资源控制**: 完整的模型生命周期管理
11
+ - **资源释放**: 可在需要时释放 OCR 资源
12
12
 
13
13
  ## 数据类型
14
14
 
@@ -61,7 +61,9 @@ interface OCR识别结果 {
61
61
 
62
62
  ### 模型管理
63
63
 
64
- #### 加载 V5 模型 - 初始化 PP-OCRv5 模型,这是使用 OCR 功能的前提。
64
+ #### 加载 V5 模型 - 可选预加载 PP-OCRv5 模型。
65
+
66
+ 识别和查找方法会自动加载所需模型,通常不需要先调用 `加载V5模型`。只有需要提前加载或指定模型参数时才调用。
65
67
 
66
68
  ```typescript
67
69
  function 加载V5模型(最大边长?: 数字, useGpu?: 布尔值): 布尔值;
@@ -80,18 +82,6 @@ function 加载V5模型(最大边长?: 数字, useGpu?: 布尔值): 布尔值;
80
82
  | ------ | --------------------------------------------------- |
81
83
  | 布尔值 | 加载成功或模型已加载返回 `true`,否则返回 `false` |
82
84
 
83
- 重复调用 `加载V5模型` 时,如果模型已经加载,会直接返回 `true`,不会重新加载或应用新的参数。需要更换加载参数时,先调用 `释放资源()` 释放模型。
84
-
85
- **示例:**
86
-
87
- ```javascript
88
- // 使用默认参数加载模型
89
- const 是否加载成功 = $PaddleOCR.加载V5模型();
90
- if (是否加载成功) {
91
- $打印信息日志("PP-OCRv5 模型加载成功");
92
- }
93
- ```
94
-
95
85
  ### 文字识别
96
86
 
97
87
  #### 识别 - 执行 OCR 文字识别,支持多种输入源和指定识别区域。
@@ -127,13 +117,6 @@ function 识别(
127
117
  **示例:**
128
118
 
129
119
  ```javascript
130
- // 首先加载模型
131
- const 是否加载成功 = $PaddleOCR.加载V5模型();
132
- if (!是否加载成功) {
133
- $打印错误日志("模型加载失败");
134
- return;
135
- }
136
-
137
120
  // 识别整个屏幕
138
121
  const fullScreenResults = $PaddleOCR.识别("screen", 0, 0, 0, 0);
139
122
  $打印信息日志(`识别到 ${fullScreenResults.length} 个文本区域`);
@@ -228,13 +211,6 @@ function 查找文本(
228
211
  **示例:**
229
212
 
230
213
  ```javascript
231
- // 首先加载模型
232
- const 是否加载成功 = $PaddleOCR.加载V5模型();
233
- if (!是否加载成功) {
234
- $打印错误日志("模型加载失败");
235
- return;
236
- }
237
-
238
214
  // 在整个屏幕中查找目标文本
239
215
  const 命中结果 = $PaddleOCR.查找文本(
240
216
  "screen",
@@ -4,11 +4,11 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
4
4
 
5
5
  ## 功能概览
6
6
 
7
- - **模型管理**: PP-OCRv5 模型加载和资源管理
7
+ - **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
8
8
  - **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
9
9
  - **区域识别**: 支持指定区域的精确文字识别
10
10
  - **结构化结果**: 提供详细的文本位置、置信度和方向信息
11
- - **资源控制**: 完整的模型生命周期管理
11
+ - **资源释放**: 可在需要时释放 OCR 资源
12
12
 
13
13
  ## 类型定义
14
14
 
@@ -38,9 +38,9 @@ class OCRResult(TypedDict):
38
38
 
39
39
  ### 模型管理
40
40
 
41
- #### `loadV5` - 初始化 PP-OCRv5 模型
41
+ #### `loadV5` - 可选预加载 PP-OCRv5 模型
42
42
 
43
- 初始化 PP-OCRv5 模型,这是使用 OCR 功能的前提。
43
+ 识别和查找方法会自动加载所需模型,通常不需要先调用 `loadV5`。只有需要提前加载或指定模型参数时才调用。
44
44
 
45
45
  ```python
46
46
  def loadV5(maxSideLen: int = 640, useGpu: bool = False) -> bool
@@ -59,19 +59,6 @@ def loadV5(maxSideLen: int = 640, useGpu: bool = False) -> bool
59
59
  | ------ | --------------------------------------------------- |
60
60
  | `bool` | 加载成功或模型已加载返回 `True`,否则返回 `False` |
61
61
 
62
- 重复调用 `loadV5` 时,如果模型已经加载,会直接返回 `True`,不会重新加载或应用新的参数。需要更换加载参数时,先调用 `free()` 释放模型。
63
-
64
- **示例:**
65
-
66
- ```python
67
- from kuaijs import paddleocr
68
-
69
- # 使用默认参数加载模型
70
- loaded = paddleocr.loadV5()
71
- if loaded:
72
- print("PP-OCRv5 模型加载成功")
73
- ```
74
-
75
62
  ### 文字识别
76
63
 
77
64
  #### `recognize` - 执行 OCR 文字识别
@@ -111,30 +98,26 @@ def recognize(
111
98
  ```python
112
99
  from kuaijs import paddleocr
113
100
 
114
- # 首先加载模型
115
- if not paddleocr.loadV5():
116
- print("模型加载失败")
117
- else:
118
- # 识别整个屏幕
119
- full_screen_results = paddleocr.recognize("screen", 0, 0, 0, 0)
120
- print(f"识别到 {len(full_screen_results)} 个文本区域")
121
- for r in full_screen_results:
122
- print(f"文本: {r.text}, 置信度: {r.confidence}")
123
-
124
- # 识别屏幕指定区域
125
- region_results = paddleocr.recognize("screen", 100, 100, 500, 300)
126
- if region_results:
127
- top = region_results[0]
128
- print(f"指定区域文本: {top.text}, 中心: ({top.centerX}, {top.centerY})")
129
-
130
- # 识别图片文件
131
- image_results = paddleocr.recognize("/path/to/image.png", 0, 0, 800, 600)
132
- for r in image_results:
133
- print(f"图片文字: {r.text}")
134
-
135
- # 识别网络图片
136
- url_results = paddleocr.recognize("https://example.com/image.jpg", 0, 0, 1000, 800)
137
- print(f"网络图片识别结果数量: {len(url_results)}")
101
+ # 识别整个屏幕
102
+ full_screen_results = paddleocr.recognize("screen", 0, 0, 0, 0)
103
+ print(f"识别到 {len(full_screen_results)} 个文本区域")
104
+ for r in full_screen_results:
105
+ print(f"文本: {r.text}, 置信度: {r.confidence}")
106
+
107
+ # 识别屏幕指定区域
108
+ region_results = paddleocr.recognize("screen", 100, 100, 500, 300)
109
+ if region_results:
110
+ top = region_results[0]
111
+ print(f"指定区域文本: {top.text}, 中心: ({top.centerX}, {top.centerY})")
112
+
113
+ # 识别图片文件
114
+ image_results = paddleocr.recognize("/path/to/image.png", 0, 0, 800, 600)
115
+ for r in image_results:
116
+ print(f"图片文字: {r.text}")
117
+
118
+ # 识别网络图片
119
+ url_results = paddleocr.recognize("https://example.com/image.jpg", 0, 0, 1000, 800)
120
+ print(f"网络图片识别结果数量: {len(url_results)}")
138
121
  ```
139
122
 
140
123
  #### `recognizeAbs` - 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标
@@ -201,21 +184,17 @@ def findText(
201
184
  ```python
202
185
  from kuaijs import paddleocr
203
186
 
204
- # 首先加载模型
205
- if not paddleocr.loadV5():
206
- print("模型加载失败")
187
+ # 在整个屏幕中查找目标文本
188
+ hit_results = paddleocr.findText("screen", ["登录", "确定"], 0, 0, 0, 0, 0.6, False)
189
+ if hit_results:
190
+ for i, r in enumerate(hit_results, 1):
191
+ print(f"命中{i}: {r.text}, 中心点=({r.centerX}, {r.centerY}), 置信度={r.confidence}")
207
192
  else:
208
- # 在整个屏幕中查找目标文本
209
- hit_results = paddleocr.findText("screen", ["登录", "确定"], 0, 0, 0, 0, 0.6, False)
210
- if hit_results:
211
- for i, r in enumerate(hit_results, 1):
212
- print(f"命中{i}: {r.text}, 中心点=({r.centerX}, {r.centerY}), 置信度={r.confidence}")
213
- else:
214
- print("未命中目标文本")
215
-
216
- # 在指定区域查找目标文本
217
- region_hits = paddleocr.findText("screen", ["下一步"], 100, 100, 500, 400)
218
- print(f"区域命中数量: {len(region_hits)}")
193
+ print("未命中目标文本")
194
+
195
+ # 在指定区域查找目标文本
196
+ region_hits = paddleocr.findText("screen", ["下一步"], 100, 100, 500, 400)
197
+ print(f"区域命中数量: {len(region_hits)}")
219
198
  ```
220
199
 
221
200
  #### `findTextAbs` - 查找目标文本,并将结果坐标映射为原图/全屏绝对坐标
@@ -28,32 +28,41 @@ MCP 工具和项目自带命令都可以使用。
28
28
 
29
29
  可以使用命令的情况:
30
30
 
31
- - MCP transport 断开或不可用。
32
31
  - 用户明确要求使用命令。
33
32
  - 需要快速确认项目本地 `ms` CLI 能力。
34
- - 需要使用项目自带 KuaiJS CLI 进行同步、运行、停止或截图。
33
+ - 需要使用项目自带 KuaiJS CLI 查询文档、调用已确认的 HTTP API、同步、运行、停止、截图、抓节点、查日志或 OCR。
35
34
 
36
35
  允许的常用项目命令:
37
36
 
38
37
  ```bash
39
38
  npx ms --help
39
+ npx ms docs paths
40
+ npx ms docs search <query> --language js_zh
41
+ npx ms http-docs search <query>
42
+ npx ms http-call -i <device-ip> --port <port> --method GET --path <path> --doc-slug <slug>
40
43
  npx ms run -i <device-ip> --port <port>
41
44
  npx ms run-ui -i <device-ip> --port <port>
42
45
  npx ms screenshot -i <device-ip> --port <port> --format file --output <path>
46
+ npx ms source -i <device-ip> --port <port> --mode 1 --output <path>
47
+ npx ms logs -i <device-ip> --port <port> --limit 200
48
+ npx ms ocr -i <device-ip> --port <port> --engine appleocr --mode recognize
49
+ npx ms screen-crop -i <device-ip> --port <port> --x <x> --y <y> --width <w> --height <h> --output <path>
50
+ npx ms screen-pick-color -i <device-ip> --port <port> --x <x> --y <y>
51
+ npx ms image-crop --image <path> --x <x> --y <y> --width <w> --height <h> --output <path>
52
+ npx ms image-transparent --image <path> --output <path>
43
53
  npx ms stop -i <device-ip> --port <port>
44
54
  npx ms package
45
55
  ```
46
56
 
47
- 命令必须在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。不要用未确认的通用 Node.js、浏览器或 Python 命令替代 MCP 或项目自带 `ms` CLI。
57
+ `build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档、HTTP API 查询/调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js、浏览器或 Python 命令替代 MCP 或项目自带 `ms` CLI。
48
58
 
49
59
  ## 文档优先
50
60
 
51
- 回答或写代码前,优先查询当前语言对应的快点JS文档。
61
+ 回答或写代码前,优先查询目标语言对应的快点JS文档。
52
62
 
53
63
  语言 API 文档工具:
54
64
 
55
- - `set_docs_language`
56
- - `get_docs_language`
65
+ - `get_docs_paths`
57
66
  - `list_api_docs`
58
67
  - `search_api_docs`
59
68
  - `read_api_doc`
@@ -63,27 +72,28 @@ HTTP API 文档工具:
63
72
  - `search_http_api_docs`
64
73
  - `read_http_api_doc`
65
74
 
66
- MCP 可用时,按以下流程使用语言 API:
75
+ MCP 入口:
67
76
 
68
- 1. 使用 `set_docs_language` 设置语言:`js`、`js_zh` 或 `python`。
69
- 2. 使用 `search_api_docs` 搜索相关模块或 API
70
- 3. 使用 `read_api_doc` 读取完整文档。
77
+ 1. 使用 `get_docs_paths` 获取本地文档路径。
78
+ 2. 使用 `search_api_docs` 搜索相关模块或 API,按需传 `language`。
79
+ 3. 使用 `read_api_doc` 读取完整文档,按需传 `language`。
71
80
  4. 只依据已确认的文档内容回答或编写代码。
72
81
 
73
- MCP 不可用时,可以查阅项目本地文档作为 fallback,例如:
82
+ CLI 入口:
74
83
 
75
- - `node_modules/ms-vite-plugin/docs/api/`
76
- - `node_modules/ms-vite-plugin/docs/apicn/`
77
- - `node_modules/ms-vite-plugin/docs/apipython/`
78
- - `node_modules/ms-vite-plugin/docs/httpapi/`
84
+ - `npx ms docs paths`
85
+ - `npx ms docs search <query> --language js_zh|js|python`
86
+ - `npx ms docs read <slug> --language js_zh|js|python`
87
+ - `npx ms http-docs search <query>`
88
+ - `npx ms http-docs read <identifier> --method GET|POST`
79
89
 
80
- 使用本地文档 fallback 时,要在回复中说明依据来自本地文档。
90
+ 使用本地文档路径或 CLI 查询时,要在回复中说明依据来自本地文档。
81
91
 
82
92
  ## HTTP API 工作流
83
93
 
84
94
  调用设备 HTTP API 前,必须先查询 HTTP API 文档中的对应接口说明。不要猜测接口路径、请求方法或参数名称。
85
95
 
86
- MCP 可用时:
96
+ MCP 入口:
87
97
 
88
98
  1. 使用 `search_http_api_docs` 搜索目标能力、中文标题或接口路径。
89
99
  2. 使用 `read_http_api_doc` 读取目标接口片段。
@@ -107,11 +117,13 @@ MCP 可用时:
107
117
 
108
118
  `http_api_call` 会拒绝 HTTP API 文档中未声明的接口,也会拒绝 `docSlug`、`method`、`path` 不匹配的调用。
109
119
 
110
- 命令 fallback 时:
120
+ CLI 入口:
111
121
 
112
- 1. 先在本地 HTTP API 文档中确认接口存在。
113
- 2. 再用 `curl` 调用明确存在的接口。
114
- 3. 不要把未确认的路径当成可用接口。
122
+ 1. 使用 `npx ms docs paths` 获取 HTTP API 文档路径。
123
+ 2. 使用 `npx ms http-docs search <query>` 搜索目标接口。
124
+ 3. 使用 `npx ms http-docs read <identifier> --method GET|POST` 读取目标接口片段。
125
+ 4. 使用 `npx ms http-call -i <device-ip> --port <port> --method <method> --path <path> --doc-slug <slug>` 调用明确存在的接口。
126
+ 5. 不要把未确认的路径当成可用接口。
115
127
 
116
128
  ## 项目目录职责
117
129
 
@@ -145,8 +157,7 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
145
157
 
146
158
  ### 文档
147
159
 
148
- - `set_docs_language`
149
- - `get_docs_language`
160
+ - `get_docs_paths`
150
161
  - `list_api_docs`
151
162
  - `search_api_docs`
152
163
  - `read_api_doc`
@@ -180,27 +191,27 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
180
191
 
181
192
  - `http_api_call`
182
193
 
183
- 控制、HID、IME、镜像、配置、当前应用、运行脚本等普通设备 HTTP API 不再作为大量独立 MCP 工具暴露。MCP 可用时必须通过 `search_http_api_docs`、`read_http_api_doc` 和 `http_api_call` 使用;命令 fallback 时可以用已确认文档的 `curl` 调用。
194
+ 控制、HID、IME、镜像、配置、当前应用、运行脚本等普通设备 HTTP API 不再作为大量独立 MCP 工具暴露。MCP 入口使用 `search_http_api_docs`、`read_http_api_doc` 和 `http_api_call`;CLI 入口使用 `ms http-docs` `ms http-call`。
184
195
 
185
196
  ## 工具选择规则
186
197
 
187
198
  - 写快点JS脚本代码:先设置或确认文档语言,再查语言 API 文档。
188
- - 调设备 HTTP API:先查 HTTP API 文档,再调用 `http_api_call` 或已确认接口的 `curl` fallback。
189
- - 获取截图:优先使用 `take_screenshot`;命令 fallback 可用 `npx ms screenshot`。
190
- - 从本地图片裁切找图模板:使用 `image_crop`,输出到 `res`。
191
- - 从当前设备截图裁切找图模板:使用 `screen_crop`,输出到 `res`。
192
- - 从本地图片指定坐标取色:使用 `image_pick_color`。
193
- - 从当前设备截图指定坐标取色:使用 `screen_pick_color`。
194
- - 执行 OCR 识别、数字识别或查找文字:使用 `ocr_recognize`;支持用户指定 `appleocr` 或 `paddleocr`,默认 `appleocr`。
195
- - OCR 没有独立 HTTP 接口,通过 `POST /api/runScript` 执行快点JS OCR 脚本;`runScript` 的规则是最后一行表达式或变量会作为结果返回,不需要写 `return`。
196
- - 制作透明找图模板:使用 `image_make_transparent`,输出到 `res`。
197
- - 获取节点 XML:优先使用 `get_node_source`。
198
- - 查看日志:优先使用 `get_logs`。
199
- - 运行项目:优先使用 `run_project` 或 `run_ui_project`;命令 fallback 可用 `npx ms run` 或 `npx ms run-ui`。
200
- - 停止项目:优先使用 `stop_project`;命令 fallback 可用 `npx ms stop`。
201
- - 打包项目:优先使用 `package_project`;命令 fallback 可用 `npx ms package`。
202
-
203
- 对设备操作优先使用 MCP 工具。MCP 不可用或用户明确要求时,可以使用项目自带 `ms` CLI;不要改写成未确认的通用构建命令,也不要假设存在浏览器、Node.js 或通用 Python 运行时能力。
199
+ - 调设备 HTTP API:先查 HTTP API 文档,再调用 `http_api_call` `npx ms http-call`。
200
+ - 获取截图:使用 `take_screenshot` `npx ms screenshot`。
201
+ - 从本地图片裁切找图模板:使用 `image_crop` 或 `npx ms image-crop`,输出到 `res`。
202
+ - 从当前设备截图裁切找图模板:使用 `screen_crop` 或 `npx ms screen-crop`,输出到 `res`。
203
+ - 从本地图片指定坐标取色:使用 `image_pick_color` 或 `npx ms image-pick-color`。
204
+ - 从当前设备截图指定坐标取色:使用 `screen_pick_color` 或 `npx ms screen-pick-color`。
205
+ - 执行 OCR 识别、数字识别或查找文字:使用 `ocr_recognize` 或 `npx ms ocr`。
206
+ - OCR 识别支持 `appleocr` `paddleocr`,默认 `appleocr`,识别结果坐标可直接用于点击。
207
+ - 制作透明找图模板:使用 `image_make_transparent` 或 `npx ms image-transparent`,输出到 `res`。
208
+ - 获取节点 XML:使用 `get_node_source` 或 `npx ms source --mode 1`。
209
+ - 查看日志:使用 `get_logs` 或 `npx ms logs`。
210
+ - 运行项目:使用 `run_project`、`run_ui_project`、`npx ms run` 或 `npx ms run-ui`。
211
+ - 停止项目:使用 `stop_project` `npx ms stop`。
212
+ - 打包项目:使用 `package_project` `npx ms package`。
213
+
214
+ 对设备操作使用 MCP 工具或项目自带 `ms` CLI;不要改写成未确认的通用构建命令,也不要假设存在浏览器、Node.js 或通用 Python 运行时能力。
204
215
 
205
216
  ## 验证要求
206
217
 
@@ -220,7 +231,7 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
220
231
  - 不要混用 JavaScript 与 Python API。
221
232
  - 不要把快点JS当成普通 Node.js、浏览器或通用 Python 环境。
222
233
  - 不要对快点JS Python 脚本运行 `py_compile` 或其他 CPython 编译校验。
223
- - 不要在没有查询 HTTP API 文档的情况下调用 `http_api_call` 或 `curl`。
234
+ - 不要在没有查询 HTTP API 文档的情况下调用 `http_api_call` 或 `ms http-call`。
224
235
  - 不要把完整 URL 传给 `http_api_call.path`,只能传 `/api/...`、`/logger/...`、`/mirror/...` 这类相对路径。
225
236
  - 不要调用 HTTP API 文档中未声明的接口。
226
237
  - 不要用 `http_api_call` 替代截图落文件、节点 XML 落文件、日志缓存、项目打包和项目运行等专用工具。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {