Skip to content

Commit 90d87eb

Browse files
committed
v10.1 重设计: 插件去掉AI爬取蓝本,改为复制提示词按钮让编程AI读源码生成
- 删除 _handleGenerateBlueprint / _handleGetPreviewApps TS方法 - 删除 JS 中 onPreviewApps/selectGenPreview/resetGenBtn/onGenerateBlueprintDone/Error 函数 - 删除 HTML 生成区(label/select/3个input/旧按钮) - 新增 _handleCopyBlueprintPrompt:写入完整提示词到剪贴板,弹出提示 - 新增 HTML「 复制蓝本生成提示词」按钮 - 更新备忘录和项目规划:记录设计决策和核心哲学
1 parent 69c658a commit 90d87eb

26 files changed

Lines changed: 2900 additions & 60 deletions

.cursorrules

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# TestPilot AI - 项目编码规范
2+
3+
## 蓝本文件(testpilot.json)管理规则
4+
5+
当你需要为某个被测应用生成或修改测试蓝本时,**必须遵守以下规则**:
6+
7+
1. **只允许存在一个蓝本文件**:每个被测应用目录下只保留一个 `testpilot.json`。
8+
2. **更新而非新建**:若该目录已存在 `testpilot.json`,直接覆盖更新,**不得**创建 `testpilot_v2.json`、`testpilot_new.json`、`testpilot_backup.json` 等任何变体文件。
9+
3. **文件放置位置**:蓝本文件必须放在被测应用的**根目录**,固定命名为 `testpilot.json`。
10+
- ✅ 正确:`shop-demo/testpilot.json`
11+
- ❌ 错误:`shop-demo/testpilot_v2.json`、`shop-demo/blueprints/test.json`
12+
13+
这样 TestPilot AI 插件才能自动扫描并选中正确的蓝本。

.github/copilot-instructions.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# TestPilot AI - 项目编码规范
2+
3+
## 蓝本文件(testpilot.json)管理规则
4+
5+
当你需要为某个被测应用生成或修改测试蓝本时,**必须遵守以下规则**
6+
7+
1. **只允许存在一个蓝本文件**:每个被测应用目录下只保留一个 `testpilot.json`
8+
2. **更新而非新建**:若该目录已存在 `testpilot.json`,直接覆盖更新,**不得**创建 `testpilot_v2.json``testpilot_new.json``testpilot_backup.json` 等任何变体文件。
9+
3. **文件放置位置**:蓝本文件必须放在被测应用的**根目录**,固定命名为 `testpilot.json`
10+
- ✅ 正确:`shop-demo/testpilot.json`
11+
- ❌ 错误:`shop-demo/testpilot_v2.json``shop-demo/blueprints/test.json`
12+
13+
这样 TestPilot AI 插件才能自动扫描并选中正确的蓝本。
14+
15+
## 编程完成后必须生成/更新蓝本
16+
17+
**每次完成编程任务后,你必须同时生成或更新被测应用的 `testpilot.json`**
18+
19+
这是因为你是最了解自己代码的人——你知道每个元素的 ID、class、功能逻辑,你生成的蓝本最精准、覆盖最全面。
20+
21+
### 蓝本生成时机
22+
23+
-**新建应用**:代码写完后,立即生成完整 `testpilot.json`
24+
-**修改功能**:新增/修改/删除任何 UI 元素或业务逻辑后,同步更新蓝本对应场景和选择器
25+
-**修复 Bug 后**:确认代码修复正确,更新蓝本中对应的 expected 断言
26+
-**不允许跳过**:不得以"稍后再写"为由跳过蓝本生成
27+
28+
### 蓝本质量要求
29+
30+
生成蓝本时,遵守以下规则:
31+
32+
1. **功能全覆盖**:每个可操作的功能(按钮/表单/导航/弹窗)必须有对应场景
33+
2. **使用精确选择器**:直接使用代码中的 `id``#login-btn`)或稳定 `class`,不要用 `div:nth-child(3)` 这类脆弱选择器
34+
3. **逐字段断言**`fill` 之后要有 `assert_text``screenshot` 验证,不能只操作不验证
35+
4. **边界场景**:包含空表单提交、错误输入、权限不足等异常场景
36+
5. **页面跳转显式化**:每次 `navigate` 必须有对应的 `assert_text``screenshot` 验证页面已正确加载
37+
38+
### 快速生成模板
39+
40+
```json
41+
{
42+
"app_name": "你的应用名",
43+
"base_url": "http://localhost:你的端口",
44+
"version": "1.0",
45+
"pages": [
46+
{
47+
"url": "/",
48+
"title": "页面标题",
49+
"elements": {
50+
"元素描述": "#实际CSS选择器"
51+
},
52+
"scenarios": [
53+
{
54+
"name": "功能场景名",
55+
"steps": [
56+
{"action": "navigate", "value": "http://localhost:端口"},
57+
{"action": "fill", "target": "#input-id", "value": "测试值"},
58+
{"action": "click", "target": "#submit-btn"},
59+
{"action": "assert_text", "target": "#result", "expected": "预期文本"}
60+
]
61+
}
62+
]
63+
}
64+
]
65+
}
66+
```
67+
68+
支持的 action:`navigate` / `click` / `fill` / `select` / `wait` / `screenshot` / `assert_text` / `assert_visible` / `hover` / `scroll`
69+

demo-app/testpilot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"app_name": "Todo + 购物清单(v1.3全面测试)",
3-
"base_url": "http://localhost:3001",
3+
"base_url": "http://localhost:8900/preview/demo-app/",
44
"version": "1.3",
55
"pages": [
66
{

extension/.vscodeignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.vscode/**
2+
node_modules/**
3+
src/**
4+
out/**/*.map
5+
out/engineClient.js
6+
out/sidebarProvider.js
7+
esbuild.js
8+
tsconfig.json
9+
**/*.ts
10+
package-lock.json

extension/esbuild.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const esbuild = require("esbuild");
2+
3+
esbuild.build({
4+
entryPoints: ["src/extension.ts"],
5+
bundle: true,
6+
outfile: "out/extension.js",
7+
external: ["vscode"], // vscode API 由宿主提供,不打包
8+
format: "cjs",
9+
platform: "node",
10+
target: "node16",
11+
sourcemap: true,
12+
minify: false,
13+
}).catch(() => process.exit(1));

0 commit comments

Comments
 (0)