simple-skills 1.8.3 → 1.8.4

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
@@ -87,7 +87,6 @@ rm -rf ~/.claude/skills # 若当初装了这份
87
87
  | [officedocs](./skills/engineering/officedocs/SKILL.md) | 处理 Microsoft Office 三件套:Word(.docx)、PowerPoint(.pptx)、Excel(.xlsx)——创建、读取、编辑、提取、转换与清理 |
88
88
  | [pdf](./skills/engineering/pdf/SKILL.md) | 处理 PDF 的一切操作:读取/提取、合并、拆分、旋转、水印、表单、加密解密、OCR |
89
89
  | [performance](./skills/engineering/performance/SKILL.md) | 性能分析与优化:成本估算 → 剖析定位 → 优化技术目录 → 微基准验证 |
90
- | [playwright-cli](./skills/engineering/playwright-cli/SKILL.md) | 用 playwright-cli 自动化浏览器交互、测试网页并生成测试代码 |
91
90
  | [skill-creator](./skills/engineering/skill-creator/SKILL.md) | 创建、迭代改进 skill,并用 eval 与方差分析基准衡量性能 |
92
91
  | [skill-translator](./skills/engineering/skill-translator/SKILL.md) | 批量翻译 skills 目录或文档树到目标语言,生成结构一致的副本并执行技能精简 |
93
92
  | [verification-before-completion](./skills/engineering/verification-before-completion/SKILL.md) | 宣称完成或修复前必须运行验证命令,始终用证据支撑断言 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-skills",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "简洁有效的 agent skills",
5
5
  "bin": {
6
6
  "simple-skills": "scripts/install.mjs"
@@ -1,357 +0,0 @@
1
- ---
2
- name: playwright-cli
3
- description: 自动化浏览器交互、测试网页以及处理Playwright测试用例
4
- allowed-tools: Bash(playwright-cli:*) Bash(npx:*) Bash(npm:*)
5
- ---
6
-
7
- # playwright-cli 浏览器自动化工具
8
-
9
- > 🔴 ⚠️ 【强制规则,必须遵守】⚠️ 🔴
10
- > 🔴 所有调用`playwright-cli open`的命令,必须默认加上`--headed`参数!
11
- > 🔴 仅用户明确要求使用无头模式时,才可去掉该参数!
12
- > 🔴 禁止后台静默运行浏览器,必须显示窗口!
13
-
14
- ## 快速入门
15
-
16
- ```bash
17
- # 打开新浏览器
18
- playwright-cli open
19
- # 跳转到指定页面
20
- playwright-cli goto https://playwright.dev
21
- # 使用快照中的元素引用与页面交互
22
- playwright-cli click e15
23
- playwright-cli type "page.click"
24
- playwright-cli press Enter
25
- # 截图(较少使用,快照功能更常用)
26
- playwright-cli screenshot
27
- # 关闭浏览器
28
- playwright-cli close
29
- ```
30
-
31
- ## 命令说明
32
-
33
- ### 核心命令
34
-
35
- ```bash
36
- playwright-cli open
37
- # 打开浏览器并直接跳转到指定url
38
- playwright-cli open https://example.com/
39
- playwright-cli goto https://playwright.dev
40
- playwright-cli type "搜索关键词"
41
- playwright-cli click e3
42
- playwright-cli dblclick e7
43
- # --submit参数会在填充元素后自动按回车提交
44
- playwright-cli fill e5 "user@example.com" --submit
45
- playwright-cli drag e2 e8
46
- playwright-cli hover e4
47
- playwright-cli select e9 "选项值"
48
- playwright-cli upload ./document.pdf
49
- playwright-cli check e12
50
- playwright-cli uncheck e12
51
- playwright-cli snapshot
52
- playwright-cli eval "document.title"
53
- playwright-cli eval "el => el.textContent" e5
54
- # 获取快照中不显示的元素id、class或其他属性
55
- playwright-cli eval "el => el.id" e5
56
- playwright-cli eval "el => el.getAttribute('data-testid')" e5
57
- playwright-cli dialog-accept
58
- playwright-cli dialog-accept "确认文本"
59
- playwright-cli dialog-dismiss
60
- playwright-cli resize 1920 1080
61
- playwright-cli close
62
- ```
63
-
64
- ### 导航命令
65
-
66
- ```bash
67
- playwright-cli go-back
68
- playwright-cli go-forward
69
- playwright-cli reload
70
- ```
71
-
72
- ### 键盘命令
73
-
74
- ```bash
75
- playwright-cli press Enter
76
- playwright-cli press ArrowDown
77
- playwright-cli keydown Shift
78
- playwright-cli keyup Shift
79
- ```
80
-
81
- ### 鼠标命令
82
-
83
- ```bash
84
- playwright-cli mousemove 150 300
85
- playwright-cli mousedown
86
- playwright-cli mousedown right
87
- playwright-cli mouseup
88
- playwright-cli mouseup right
89
- playwright-cli mousewheel 0 100
90
- ```
91
-
92
- ### 导出命令
93
-
94
- ```bash
95
- playwright-cli screenshot
96
- playwright-cli screenshot e5
97
- playwright-cli screenshot --filename=page.png
98
- playwright-cli pdf --filename=page.pdf
99
- ```
100
-
101
- ### 标签页命令
102
-
103
- ```bash
104
- playwright-cli tab-list
105
- playwright-cli tab-new
106
- playwright-cli tab-new https://example.com/page
107
- playwright-cli tab-close
108
- playwright-cli tab-close 2
109
- playwright-cli tab-select 0
110
- ```
111
-
112
- ### 存储命令
113
-
114
- ```bash
115
- playwright-cli state-save
116
- playwright-cli state-save auth.json
117
- playwright-cli state-load auth.json
118
-
119
- # Cookie操作
120
- playwright-cli cookie-list
121
- playwright-cli cookie-list --domain=example.com
122
- playwright-cli cookie-get session_id
123
- playwright-cli cookie-set session_id abc123
124
- playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
125
- playwright-cli cookie-delete session_id
126
- playwright-cli cookie-clear
127
-
128
- # LocalStorage操作
129
- playwright-cli localstorage-list
130
- playwright-cli localstorage-get theme
131
- playwright-cli localstorage-set theme dark
132
- playwright-cli localstorage-delete theme
133
- playwright-cli localstorage-clear
134
-
135
- # SessionStorage操作
136
- playwright-cli sessionstorage-list
137
- playwright-cli sessionstorage-get step
138
- playwright-cli sessionstorage-set step 3
139
- playwright-cli sessionstorage-delete step
140
- playwright-cli sessionstorage-clear
141
- ```
142
-
143
- ### 网络命令
144
-
145
- ```bash
146
- playwright-cli route "**/*.jpg" --status=404
147
- playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
148
- playwright-cli route-list
149
- playwright-cli unroute "**/*.jpg"
150
- playwright-cli unroute
151
- ```
152
-
153
- ### 开发者工具命令
154
-
155
- ```bash
156
- playwright-cli console
157
- playwright-cli console warning
158
- playwright-cli network
159
- playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
160
- playwright-cli run-code --filename=script.js
161
- playwright-cli tracing-start
162
- playwright-cli tracing-stop
163
- playwright-cli video-start video.webm
164
- playwright-cli video-chapter "章节标题" --description="详细说明" --duration=2000
165
- playwright-cli video-stop
166
- ```
167
-
168
- ## 原始输出模式
169
-
170
- 全局参数`--raw`会去掉页面状态、生成代码和快照部分的输出,仅返回结果值,适合将命令输出管道到其他工具使用。没有输出的命令执行后不会返回任何内容。
171
-
172
- ```bash
173
- playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
174
- playwright-cli --raw eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))" > links.json
175
- playwright-cli --raw snapshot > before.yml
176
- playwright-cli click e5
177
- playwright-cli --raw snapshot > after.yml
178
- diff before.yml after.yml
179
- TOKEN=$(playwright-cli --raw cookie-get session_id)
180
- playwright-cli --raw localstorage-get theme
181
- ```
182
-
183
- ## 启动参数
184
-
185
- ```bash
186
- # 启动时指定使用的浏览器,可选值:chrome, firefox, webkit, msedge
187
- playwright-cli open --browser=chrome
188
- playwright-cli open --browser=firefox
189
- playwright-cli open --browser=webkit
190
- playwright-cli open --browser=msedge
191
-
192
- # 使用持久化浏览器配置文件(默认使用内存中的临时配置,关闭后清空所有数据)
193
- playwright-cli open --persistent
194
- # 自定义持久化配置文件的存储目录
195
- playwright-cli open --profile=/path/to/profile
196
-
197
- # 通过扩展连接到浏览器
198
- playwright-cli attach --extension
199
-
200
- # 通过通道名连接到正在运行的Chrome或Edge
201
- playwright-cli attach --cdp=chrome
202
- playwright-cli attach --cdp=msedge
203
-
204
- # 通过CDP端点连接到正在运行的浏览器
205
- playwright-cli attach --cdp=http://localhost:9222
206
-
207
- # 从指定配置文件启动
208
- playwright-cli open --config=my-config.json
209
-
210
- # 关闭浏览器
211
- playwright-cli close
212
- # 删除默认会话的用户数据
213
- playwright-cli delete-data
214
- ```
215
-
216
- ## 快照功能
217
-
218
- 每次命令执行后,playwright-cli都会返回当前浏览器状态的快照。
219
-
220
- ```bash
221
- > playwright-cli goto https://example.com
222
- ### 页面信息
223
- - 页面URL: https://example.com/
224
- - 页面标题: Example Domain
225
- ### 快照
226
- [Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
227
- ```
228
-
229
- 你也可以按需手动执行`snapshot`命令获取快照,所有参数可以组合使用:
230
-
231
- ```bash
232
- # 默认保存到按时间戳命名的文件
233
- playwright-cli snapshot
234
-
235
- # 保存到指定文件,适合工作流结果中使用快照
236
- playwright-cli snapshot --filename=after-click.yaml
237
-
238
- # 仅快照指定元素而非整个页面
239
- playwright-cli snapshot "#main"
240
-
241
- # 限制快照的深度提升效率,之后可以对指定元素单独快照
242
- playwright-cli snapshot --depth=4
243
- playwright-cli snapshot e34
244
- ```
245
-
246
- ## 元素定位
247
-
248
- 默认使用快照中的元素引用(比如e15这种形式)来和页面元素交互。
249
-
250
- ```bash
251
- # 获取带元素引用的快照
252
- playwright-cli snapshot
253
-
254
- # 使用元素引用进行交互
255
- playwright-cli click e15
256
- ```
257
-
258
- 你也可以使用css选择器或者Playwright内置选择器:
259
-
260
- ```bash
261
- # css选择器
262
- playwright-cli click "#main > button.submit"
263
-
264
- # 角色选择器
265
- playwright-cli click "getByRole('button', { name: 'Submit' })"
266
-
267
- # 测试ID选择器
268
- playwright-cli click "getByTestId('submit-button')"
269
- ```
270
-
271
- ## 浏览器会话
272
-
273
- ```bash
274
- # 创建名为mysession的新浏览器会话,使用持久化配置
275
- playwright-cli -s=mysession open example.com --persistent
276
- # 手动指定配置文件目录(需要时使用)
277
- playwright-cli -s=mysession open example.com --profile=/path/to/profile
278
- playwright-cli -s=mysession click e6
279
- playwright-cli -s=mysession close # 停止指定名称的浏览器会话
280
- playwright-cli -s=mysession delete-data # 删除持久化会话的用户数据
281
-
282
- playwright-cli list
283
- # 关闭所有浏览器
284
- playwright-cli close-all
285
- # 强制终止所有浏览器进程
286
- playwright-cli kill-all
287
- ```
288
-
289
- ## 安装说明
290
-
291
- 如果全局`playwright-cli`命令不可用,可以尝试通过npx使用本地版本:
292
-
293
- ```bash
294
- npx --no-install playwright-cli --version
295
- ```
296
-
297
- 如果本地版本可用,所有命令都可以用`npx playwright-cli`代替。否则可以全局安装playwright-cli:
298
-
299
- ```bash
300
- npm install -g @playwright/cli@latest
301
- ```
302
-
303
- ## 示例:表单提交
304
-
305
- ```bash
306
- playwright-cli open https://example.com/form
307
- playwright-cli snapshot
308
-
309
- playwright-cli fill e1 "user@example.com"
310
- playwright-cli fill e2 "password123"
311
- playwright-cli click e3
312
- playwright-cli snapshot
313
- playwright-cli close
314
- ```
315
-
316
- ## 示例:多标签页工作流
317
-
318
- ```bash
319
- playwright-cli open https://example.com
320
- playwright-cli tab-new https://example.com/other
321
- playwright-cli tab-list
322
- playwright-cli tab-select 0
323
- playwright-cli snapshot
324
- playwright-cli close
325
- ```
326
-
327
- ## 示例:使用开发者工具调试
328
-
329
- ```bash
330
- playwright-cli open https://example.com
331
- playwright-cli click e4
332
- playwright-cli fill e7 "test"
333
- playwright-cli console
334
- playwright-cli network
335
- playwright-cli close
336
- ```
337
-
338
- ```bash
339
- playwright-cli open https://example.com
340
- playwright-cli tracing-start
341
- playwright-cli click e4
342
- playwright-cli fill e7 "test"
343
- playwright-cli tracing-stop
344
- playwright-cli close
345
- ```
346
-
347
- ## 特定场景用法
348
-
349
- * **运行和调试Playwright测试用例** [references/playwright-tests.md](references/playwright-tests.md)
350
- * **请求Mock** [references/request-mocking.md](references/request-mocking.md)
351
- * **运行Playwright代码** [references/running-code.md](references/running-code.md)
352
- * **浏览器会话管理** [references/session-management.md](references/session-management.md)
353
- * **存储状态(Cookie、localStorage)** [references/storage-state.md](references/storage-state.md)
354
- * **测试用例生成** [references/test-generation.md](references/test-generation.md)
355
- * **链路追踪** [references/tracing.md](references/tracing.md)
356
- * **视频录制** [references/video-recording.md](references/video-recording.md)
357
- * **元素属性检查** [references/element-attributes.md](references/element-attributes.md)
@@ -1,23 +0,0 @@
1
- # Inspecting Element Attributes
2
-
3
- When the snapshot doesn't show an element's `id`, `class`, `data-*` attributes, or other DOM properties, use `eval` to inspect them.
4
-
5
- ## Examples
6
-
7
- ```bash
8
- playwright-cli snapshot
9
- # snapshot shows a button as e7 but doesn't reveal its id or data attributes
10
-
11
- # get the element's id
12
- playwright-cli eval "el => el.id" e7
13
-
14
- # get all CSS classes
15
- playwright-cli eval "el => el.className" e7
16
-
17
- # get a specific attribute
18
- playwright-cli eval "el => el.getAttribute('data-testid')" e7
19
- playwright-cli eval "el => el.getAttribute('aria-label')" e7
20
-
21
- # get a computed style property
22
- playwright-cli eval "el => getComputedStyle(el).display" e7
23
- ```
@@ -1,39 +0,0 @@
1
- # Running Playwright Tests
2
-
3
- To run Playwright tests, use the `npx playwright test` command, or a package manager script. To avoid opening the interactive html report, use `PLAYWRIGHT_HTML_OPEN=never` environment variable.
4
-
5
- ```bash
6
- # Run all tests
7
- PLAYWRIGHT_HTML_OPEN=never npx playwright test
8
-
9
- # Run all tests through a custom npm script
10
- PLAYWRIGHT_HTML_OPEN=never npm run special-test-command
11
- ```
12
-
13
- # Debugging Playwright Tests
14
-
15
- To debug a failing Playwright test, run it with `--debug=cli` option. This command will pause the test at the start and print the debugging instructions.
16
-
17
- **IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed.
18
-
19
- Once instructions containing a session name are printed, use `playwright-cli` to attach the session and explore the page.
20
-
21
- ```bash
22
- # Run the test
23
- PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli
24
- # ...
25
- # ... debugging instructions for "tw-abcdef" session ...
26
- # ...
27
-
28
- # Attach to the test
29
- playwright-cli attach tw-abcdef
30
- ```
31
-
32
- Keep the test running in the background while you explore and look for a fix.
33
- The test is paused at the start, so you should step over or pause at a particular location
34
- where the problem is most likely to be.
35
-
36
- Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.
37
- This code appears in the output and can be copied directly into the test. Most of the time, a specific locator or an expectation should be updated, but it could also be a bug in the app. Use your judgement.
38
-
39
- After fixing the test, stop the background test run. Rerun to check that test passes.
@@ -1,87 +0,0 @@
1
- # Request Mocking
2
-
3
- Intercept, mock, modify, and block network requests.
4
-
5
- ## CLI Route Commands
6
-
7
- ```bash
8
- # Mock with custom status
9
- playwright-cli route "**/*.jpg" --status=404
10
-
11
- # Mock with JSON body
12
- playwright-cli route "**/api/users" --body='[{"id":1,"name":"Alice"}]' --content-type=application/json
13
-
14
- # Mock with custom headers
15
- playwright-cli route "**/api/data" --body='{"ok":true}' --header="X-Custom: value"
16
-
17
- # Remove headers from requests
18
- playwright-cli route "**/*" --remove-header=cookie,authorization
19
-
20
- # List active routes
21
- playwright-cli route-list
22
-
23
- # Remove a route or all routes
24
- playwright-cli unroute "**/*.jpg"
25
- playwright-cli unroute
26
- ```
27
-
28
- ## URL Patterns
29
-
30
- ```
31
- **/api/users - Exact path match
32
- **/api/*/details - Wildcard in path
33
- **/*.{png,jpg,jpeg} - Match file extensions
34
- **/search?q=* - Match query parameters
35
- ```
36
-
37
- ## Advanced Mocking with run-code
38
-
39
- For conditional responses, request body inspection, response modification, or delays:
40
-
41
- ### Conditional Response Based on Request
42
-
43
- ```bash
44
- playwright-cli run-code "async page => {
45
- await page.route('**/api/login', route => {
46
- const body = route.request().postDataJSON();
47
- if (body.username === 'admin') {
48
- route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) });
49
- } else {
50
- route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) });
51
- }
52
- });
53
- }"
54
- ```
55
-
56
- ### Modify Real Response
57
-
58
- ```bash
59
- playwright-cli run-code "async page => {
60
- await page.route('**/api/user', async route => {
61
- const response = await route.fetch();
62
- const json = await response.json();
63
- json.isPremium = true;
64
- await route.fulfill({ response, json });
65
- });
66
- }"
67
- ```
68
-
69
- ### Simulate Network Failures
70
-
71
- ```bash
72
- playwright-cli run-code "async page => {
73
- await page.route('**/api/offline', route => route.abort('internetdisconnected'));
74
- }"
75
- # Options: connectionrefused, timedout, connectionreset, internetdisconnected
76
- ```
77
-
78
- ### Delayed Response
79
-
80
- ```bash
81
- playwright-cli run-code "async page => {
82
- await page.route('**/api/slow', async route => {
83
- await new Promise(r => setTimeout(r, 3000));
84
- route.fulfill({ body: JSON.stringify({ data: 'loaded' }) });
85
- });
86
- }"
87
- ```