csspilot 0.1.0 → 0.1.1

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 ADDED
@@ -0,0 +1,122 @@
1
+ # csspilot
2
+
3
+ > [TestPilot](https://github.com/3lin9/css-test-pilot) CLI —— AI Native 跨端业务测试基础设施:让 AI 能理解、生成、校验并执行业务测试。
4
+
5
+ `csspilot` 把一套**可校验、可执行、可取证**的端到端测试工作流带进你的业务项目:用 YAML DSL 描述用例,同时驱动 **Web(Playwright)** 与**微信小程序(WeChat DevTools)** 两端,产出截图 / video / trace 证据与 JSON + HTML 报告;并随包附带 AI Skill,安装后让 AI 助手按同一套规范生成和维护用例。
6
+
7
+ [![npm version](https://img.shields.io/npm/v/csspilot.svg)](https://www.npmjs.com/package/csspilot)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/3lin9/css-test-pilot/blob/main/LICENSE)
9
+ [![node](https://img.shields.io/node/v/csspilot.svg)](https://www.npmjs.com/package/csspilot)
10
+
11
+ ## 特性
12
+
13
+ - **一套 DSL,跨端执行**:`target: miniapp | web` 自由切换,变量跨端传递(小程序下单 → extract 订单号 → Web 后台 assert)
14
+ - **先校验后执行**:用例在运行前经过 DSL schema / action / locator / 变量引用 / adapter 支持的完整校验
15
+ - **全程取证**:每一步可留 screenshot,运行留 video / trace / 日志,证据按 run 归档在 `.testpilot/artifacts/runs/<id>/`
16
+ - **JSON + HTML 报告**:`csspilot report` 一步生成,支持按 run id 回看
17
+ - **AI Native**:内置 TestPilot Skill(规则 + 工作流),`init` 后 AI 助手即可按规范帮你写用例、跑测试、分析结果
18
+
19
+ ## 安装
20
+
21
+ 要求 Node.js ≥ 22。
22
+
23
+ ```bash
24
+ npm install -g csspilot
25
+ # 或免安装直接用
26
+ npx csspilot --help
27
+ ```
28
+
29
+ Web 端执行依赖 Playwright 浏览器:
30
+
31
+ ```bash
32
+ npx playwright install chromium
33
+ ```
34
+
35
+ ## 快速开始
36
+
37
+ ```bash
38
+ # 1. 在业务项目根目录接入 TestPilot(装 AI Skill、初始化 .testpilot/、生成 testpilot.yaml)
39
+ csspilot init
40
+
41
+ # 2. 在 tests/e2e/cases/ 下写用例(可让 AI 按 Skill 规范生成)
42
+
43
+ # 3. 校验用例
44
+ csspilot validate
45
+
46
+ # 4. 执行
47
+ csspilot run
48
+
49
+ # 5. 生成报告
50
+ csspilot report
51
+ ```
52
+
53
+ 不确定环境是否就绪?`csspilot doctor` 一键体检(Node / Playwright / WeChat DevTools / 项目配置)。
54
+
55
+ ## 命令
56
+
57
+ | 命令 | 作用 |
58
+ | --- | --- |
59
+ | `csspilot init` | 把 TestPilot 接入当前业务项目(装 Skill 到 `.ai/skills/testpilot/`、初始化 `.testpilot/`、创建/复用 `tests/e2e`、生成 `testpilot.yaml`) |
60
+ | `csspilot validate [paths...]` | 校验用例(DSL schema / action / locator / 变量引用 / adapter 支持) |
61
+ | `csspilot list [--tag <tag>]` | 列出用例 |
62
+ | `csspilot run [paths...] [--tag <tag>]` | 执行用例(Case Loader → Validator → Engine → Adapter → Evidence → Reporter) |
63
+ | `csspilot report [--run <id>]` | 生成 JSON + HTML 报告(`.testpilot/artifacts/runs/<id>/`) |
64
+ | `csspilot doctor` | 环境体检(Node / Playwright / WeChat DevTools / 项目配置) |
65
+
66
+ ## DSL 速览
67
+
68
+ 九个基础 Action:`launch` `navigate` `click` `input` `select` `wait` `assert` `extract` `screenshot`。Action 是通用测试原语;业务动作(登录 / 下单 / 支付)永远是业务项目里的 Case。
69
+
70
+ ```yaml
71
+ # tests/e2e/cases/order-create.yaml
72
+ id: order-create
73
+ name: 用户创建订单
74
+ tags:
75
+ - smoke
76
+
77
+ steps:
78
+ # 小程序端:下单
79
+ - target: miniapp
80
+ action: launch
81
+
82
+ - target: miniapp
83
+ action: navigate
84
+ url: /pages/index/index
85
+
86
+ - target: miniapp
87
+ action: click
88
+ locator:
89
+ css: ".submit-btn"
90
+
91
+ # 提取订单号,存入上下文变量
92
+ - target: miniapp
93
+ action: extract
94
+ locator:
95
+ css: ".order-id"
96
+ variable: orderId
97
+
98
+ # Web 端:后台验证该订单(locator 支持 ${var} 引用)
99
+ - target: web
100
+ action: assert
101
+ locator:
102
+ css: "tr[data-order='${orderId}']"
103
+ ```
104
+
105
+ ## AI Skill
106
+
107
+ `csspilot init` 会把随包分发的 TestPilot Skill 安装到业务项目 `.ai/skills/testpilot/`,包含:
108
+
109
+ - `SKILL.md` —— 能力总览与使用约定
110
+ - `rules/` —— 用例设计 / DSL 书写 / 断言 / locator 规范
111
+ - `workflows/` —— 创建用例、校验、执行、结果分析的完整工作流
112
+
113
+ 安装后,你的 AI 助手(Claude Code、Cursor 等)即可按这套规范生成、修改和运行用例。
114
+
115
+ ## 相关链接
116
+
117
+ - [GitHub 仓库](https://github.com/3lin9/css-test-pilot) —— 完整架构、DSL 示例与开发文档
118
+ - [问题反馈](https://github.com/3lin9/css-test-pilot/issues)
119
+
120
+ ## License
121
+
122
+ [MIT](https://github.com/3lin9/css-test-pilot/blob/main/LICENSE)
package/dist/bin.js CHANGED
@@ -31754,7 +31754,7 @@ function makeValidateCommand() {
31754
31754
  // src/cli.ts
31755
31755
  async function createCli() {
31756
31756
  const program2 = new Command();
31757
- program2.name("csspilot").description("TestPilot \u2014 AI Native \u8DE8\u7AEF\u4E1A\u52A1\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD").version("0.1.0").addCommand(makeInitCommand()).addCommand(makeValidateCommand()).addCommand(makeListCommand()).addCommand(makeRunCommand()).addCommand(makeReportCommand()).addCommand(makeDoctorCommand());
31757
+ program2.name("csspilot").description("TestPilot \u2014 AI Native \u8DE8\u7AEF\u4E1A\u52A1\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD").version("0.1.1").addCommand(makeInitCommand()).addCommand(makeValidateCommand()).addCommand(makeListCommand()).addCommand(makeRunCommand()).addCommand(makeReportCommand()).addCommand(makeDoctorCommand());
31758
31758
  return program2;
31759
31759
  }
31760
31760
 
package/dist/index.js CHANGED
@@ -31753,7 +31753,7 @@ function makeValidateCommand() {
31753
31753
  // src/cli.ts
31754
31754
  async function createCli() {
31755
31755
  const program2 = new Command();
31756
- program2.name("csspilot").description("TestPilot \u2014 AI Native \u8DE8\u7AEF\u4E1A\u52A1\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD").version("0.1.0").addCommand(makeInitCommand()).addCommand(makeValidateCommand()).addCommand(makeListCommand()).addCommand(makeRunCommand()).addCommand(makeReportCommand()).addCommand(makeDoctorCommand());
31756
+ program2.name("csspilot").description("TestPilot \u2014 AI Native \u8DE8\u7AEF\u4E1A\u52A1\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD").version("0.1.1").addCommand(makeInitCommand()).addCommand(makeValidateCommand()).addCommand(makeListCommand()).addCommand(makeRunCommand()).addCommand(makeReportCommand()).addCommand(makeDoctorCommand());
31757
31757
  return program2;
31758
31758
  }
31759
31759
  export {
@@ -23,9 +23,9 @@ Use TestPilot when the user wants to:
23
23
  2. Inspect project
24
24
  3. Identify test target
25
25
  4. Create TestPilot Case (`tests/e2e/cases/*.yaml`)
26
- 5. Validate Case (`npx testpilot validate`)
27
- 6. Run Case (`npx testpilot run`)
28
- 7. Analyze result (`npx testpilot report`)
26
+ 5. Validate Case (`npx csspilot validate`)
27
+ 6. Run Case (`npx csspilot run`)
28
+ 7. Analyze result (`npx csspilot report`)
29
29
 
30
30
  ## Important rules
31
31
 
@@ -40,12 +40,12 @@ Use TestPilot when the user wants to:
40
40
  ## CLI
41
41
 
42
42
  ```bash
43
- npx testpilot init # install TestPilot into the current project
44
- npx testpilot validate # validate cases against the DSL
45
- npx testpilot list # list cases (--tag smoke)
46
- npx testpilot run # run cases (file paths / --tag)
47
- npx testpilot report # generate JSON + HTML report
48
- npx testpilot doctor # check environment
43
+ npx csspilot init # install TestPilot into the current project
44
+ npx csspilot validate # validate cases against the DSL
45
+ npx csspilot list # list cases (--tag smoke)
46
+ npx csspilot run # run cases (file paths / --tag)
47
+ npx csspilot report # generate JSON + HTML report
48
+ npx csspilot doctor # check environment
49
49
  ```
50
50
 
51
51
  ## Directory map (business project)
@@ -1,8 +1,8 @@
1
1
  # TestPilot Skill 清单(源文件)
2
- # `npx testpilot init` 会把整个 skills/testpilot/ 安装到业务项目 .ai/skills/testpilot/
2
+ # `npx csspilot init` 会把整个 skills/testpilot/ 安装到业务项目 .ai/skills/testpilot/
3
3
  id: testpilot
4
4
  name: TestPilot
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
 
7
7
  description: >
8
8
  AI Native cross-platform testing skill.
@@ -15,7 +15,7 @@ capabilities:
15
15
  - report
16
16
 
17
17
  runtime:
18
- cli: testpilot
18
+ cli: csspilot
19
19
 
20
20
  permissions:
21
21
  filesystem:
@@ -1,6 +1,6 @@
1
1
  # Workflow:分析测试结果
2
2
 
3
- 1. 执行 `npx testpilot report` 生成报告。
3
+ 1. 执行 `npx csspilot report` 生成报告。
4
4
  2. 产物位于 `.testpilot/artifacts/runs/<run-id>/`:
5
5
  - `report.json` —— 结构化结果,AI 优先读这个:`{ generatedAt, summary: { runId, status, totals, cases: [{ caseId, status, steps: [{ index, target, action, status, durationMs, error?, screenshot?, extracted? }] }] } }`
6
6
  - `report.html` —— 人类可读报告
@@ -7,7 +7,7 @@
7
7
  3. 找到业务路径上的真实页面与组件,收集证据(读代码 / DOM / 现有测试)。
8
8
  4. 确定测试路径:从入口到业务结果页的完整步骤。
9
9
  5. 按 DSL 规范生成 Case,写入 `tests/e2e/cases/<case-id>.yaml`。
10
- 6. 执行 `npx testpilot validate tests/e2e/cases/<case-id>.yaml`。
10
+ 6. 执行 `npx csspilot validate tests/e2e/cases/<case-id>.yaml`。
11
11
  7. 校验失败则修复 Case 后重新 validate,直到通过。
12
12
 
13
13
  禁止:跳过第 2-3 步直接生成 Case(AI 不能凭空生成测试)。
@@ -1,9 +1,9 @@
1
1
  # Workflow:执行测试
2
2
 
3
3
  ```bash
4
- npx testpilot run # 运行项目配置(testpilot.yaml)中的 Case
5
- npx testpilot run <file> # 运行指定 Case
6
- npx testpilot run --tag smoke # 按标签运行
4
+ npx csspilot run # 运行项目配置(testpilot.yaml)中的 Case
5
+ npx csspilot run <file> # 运行指定 Case
6
+ npx csspilot run --tag smoke # 按标签运行
7
7
  ```
8
8
 
9
9
  执行链路:
@@ -3,8 +3,8 @@
3
3
  任何 Case 在 run 之前必须先 validate。
4
4
 
5
5
  ```bash
6
- npx testpilot validate # 全量
7
- npx testpilot validate <file> # 指定文件
6
+ npx csspilot validate # 全量
7
+ npx csspilot validate <file> # 指定文件
8
8
  ```
9
9
 
10
10
  检查内容:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "csspilot",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "TestPilot — AI Native 跨端业务测试基础设施 CLI",
5
5
  "license": "MIT",
6
6
  "repository": {