@xiaou66/vite-plugin-vue-mcp-next 1.1.1 → 1.3.0

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/README.md CHANGED
@@ -11,10 +11,12 @@
11
11
  | 页面列表 | Vite entry + Runtime | Vite entry + Runtime + CDP target | 用于多页面和多 tab 场景下选择调试目标 |
12
12
  | DOM tree | Runtime Hook | CDP 优先,Hook 兜底 | 可返回裁剪后的运行时 DOM 结构 |
13
13
  | DOM selector 查询 | Runtime Hook | CDP 优先,Hook 兜底 | 可按 selector 返回节点文本、属性和布局信息 |
14
+ | 元素选择上下文 | 编译期 ID + Runtime Hook | 编译期 ID + Runtime Hook | 按住快捷键选择元素,复制 elementId 后通过 MCP 返回组件、DOM 和可编辑源码位置 |
14
15
  | 页面截图 | snapdom DOM 截图 | CDP 真截图优先,snapdom 降级 | 默认保存到项目目录并返回路径,也可配置为 base64 返回 |
15
16
  | Console 日志 | Runtime Hook | CDP 优先,Hook 兜底 | 采集 `log/info/warn/error/debug` 和运行时日志 |
16
17
  | Evaluate 控制台执行 | Runtime Hook | CDP 优先,Hook 兜底 | 默认关闭,必须显式开启 |
17
18
  | Network 请求 | Runtime Hook | CDP 优先,Hook 兜底 | 返回请求 URL、query、body、status、headers、response body |
19
+ | 浏览器存储 | Runtime Hook | CDP 优先,Hook 兜底 | 访问同源 Web Storage、IndexedDB;Cookie 在无 CDP 时回退到 `document.cookie` |
18
20
  | Vue 组件树 | Vue Runtime Bridge | Vue Runtime Bridge | Vue 专属语义不走 CDP |
19
21
  | Vue 组件状态 | Vue Runtime Bridge | Vue Runtime Bridge | 读取和编辑组件状态 |
20
22
  | Router 信息 | Vue Runtime Bridge | Vue Runtime Bridge | 返回当前路由和路由表 |
@@ -59,6 +61,36 @@ Streamable HTTP: http://localhost:<vite-port>/__mcp/mcp
59
61
 
60
62
  实际端口以启动日志中的 `MCP: SSE server is running at ...` 和 `MCP: Streamable HTTP server is running at ...` 为准。
61
63
 
64
+ ### 页面元素选择
65
+
66
+ 开发服务器启动后,页面内默认支持 `Option + Shift` / `Alt + Shift` 进入元素选择模式。按住快捷键移动鼠标会高亮当前元素,单击后插件会自动复制 `elementId`,并提示 `元素位置已复制,请发送给 AI`。
67
+
68
+ AI 收到 `elementId` 后应调用:
69
+
70
+ ```json
71
+ {
72
+ "tool": "get_element_context",
73
+ "arguments": {
74
+ "elementId": "src/pages/Home.vue:12:8"
75
+ }
76
+ }
77
+ ```
78
+
79
+ 项目源码会返回 `editable: true` 和 `codeLocation`;第三方组件会返回 `editable: false`、`packageName` 和 `entryFile`;运行时兜底 ID 只在当前页面生命周期内有效。
80
+
81
+ ```ts
82
+ vueMcpNext({
83
+ elementPicker: {
84
+ enabled: true,
85
+ shortcut: {
86
+ altKey: true,
87
+ shiftKey: true
88
+ },
89
+ toastDurationMs: 2200
90
+ }
91
+ })
92
+ ```
93
+
62
94
  ### 手动配置 MCP 客户端
63
95
 
64
96
  如果你不想使用自动配置,或需要把地址复制到其他支持 HTTP MCP 的客户端,可以手动配置当前 Vite dev server 的 MCP 地址。
@@ -137,6 +169,16 @@ vueMcpNext({
137
169
  skill: {
138
170
  autoConfig: true
139
171
  },
172
+ elementPicker: {
173
+ enabled: true,
174
+ shortcut: {
175
+ altKey: true,
176
+ shiftKey: true,
177
+ metaKey: false,
178
+ ctrlKey: false
179
+ },
180
+ toastDurationMs: 2200
181
+ },
140
182
  appendTo: undefined,
141
183
  runtime: {
142
184
  mode: 'auto',
@@ -548,6 +590,25 @@ interface NetworkRecord {
548
590
 
549
591
  Vue 组件、Router、Pinia 是应用层语义,固定走 Vue Runtime Bridge,不用 CDP 替代。
550
592
 
593
+ ### 浏览器存储
594
+
595
+ 浏览器存储工具组面向调试当前页面的运行时数据。`localStorage`、`sessionStorage` 和 `IndexedDB` 只作用于当前选中页面同源,避免跨站误操作。Cookie 在无 CDP 时通过 `document.cookie` 访问当前页面可见的同源条目;配置 CDP 后可查询浏览器级 Cookie,并能读取 `HttpOnly` 条目,但删除和清空时会跳过 `HttpOnly` 并返回跳过数量。
596
+
597
+ | 资源 | Runtime Hook | CDP |
598
+ | --- | --- | --- |
599
+ | `localStorage` | 读 / 写 / 删 | 读 / 写 / 删 |
600
+ | `sessionStorage` | 读 / 写 / 删 | 读 / 写 / 删 |
601
+ | `IndexedDB` | 同源库和记录操作 | 同源库和记录操作 |
602
+ | `Cookie` | 查询 / 写入 / 删除当前页面可见条目 | 查询 / 写入 / 删除非 `HttpOnly` 条目,`HttpOnly` 仅可查询 |
603
+
604
+ 相关 MCP 工具:
605
+
606
+ - `list_storage`:列出当前页面同源存储和 Cookie;有 CDP 时补充浏览器级 Cookie
607
+ - `get_storage_item`:读取指定 key、IndexedDB 记录或 Cookie
608
+ - `set_storage_item`:写入 Web Storage、IndexedDB 记录或 Cookie
609
+ - `delete_storage_item`:删除 Web Storage、IndexedDB 记录或 Cookie;`HttpOnly` Cookie 仅在 CDP 下可见且删除时会跳过
610
+ - `clear_storage`:清空指定范围,Cookie 清空会跳过 `HttpOnly`
611
+
551
612
  ## 本地验证
552
613
 
553
614
  ### 自动化检查