csspilot 0.1.0 → 0.2.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 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 到 `.agents/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 安装到业务项目 `.agents/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)