用途:当用户要求为项目添加、配置或集成 Component Explorer 时使用此技能,按步骤把 CLI、MCP 服务器、VS Code 任务和启动配置安装到项目中。
主要能力:通过 npm 安装 @vscode/component-explorer 相关三个包;在 vite.config.ts 中加入 componentExplorer() 插件;创建 component-explorer.json 配置 CLI/daemon/MCP;配置 .vscode/mcp.json 中的 MCP 服务器,使 AI 智能体可截图、比较 fixture 和交互组件;配置 .vscode/tasks.json 后台任务启动 explorer 服务器;可选配置 Chrome 启动配置打开 explorer UI。
前置条件:项目使用 Vite 作为打包器,Node.js >= 22。安装命令:npm install @vscode/component-explorer @vscode/component-explorer-cli @vscode/component-explorer-vite-plugin。Monorepo 中需装到拥有 Vite 配置的包。
插件选项默认值:include 为 './src/**/*.fixture.{ts,tsx}',route 为 '/___explorer',build 为 'app-only',outFile 为 '___explorer.html',logLevel 为 'info'。fixture 不在 ./ 下时需显式设置 include。
使用方式:按资料中的七个步骤依次操作,配置 MCP、任务和启动项;启动 npx vite 后通过 Simple Browser 打开 http://localhost:5173/___explorer,并运行任务或启动配置。写 fixture 前需先阅读 use-component-explorer 技能。
限制:仅适用于 Vite 项目与 Node.js >= 22;资料未提供其他平台或非 Vite 项目的支持信息。