openspec-playwright 0.3.52 → 0.3.53

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
@@ -50,7 +50,7 @@ openspec-pw audit # Audit tests for orphaned specs and issues
50
50
  openspec-pw coverage # Analyze spec–test coverage for changes
51
51
  openspec-pw flake # Detect static flake patterns in test files
52
52
  openspec-pw migrate # Migrate old test files to new structure
53
- openspec-pw explore # Explore routes in parallel with Playwright
53
+ openspec-pw explore # Explore app routes with Playwright
54
54
  openspec-pw run <name> # Execute E2E tests for a change
55
55
  openspec-pw uninstall # Remove integration from the project
56
56
  ```
@@ -87,7 +87,7 @@ openspec-pw uninstall # Remove integration from the project
87
87
 
88
88
  ├── 10. Healer (if needed) → auto-heals failures via MCP
89
89
 
90
- └── 11. Report → openspec/reports/playwright-e2e-<name>.md
90
+ └── 11. Report → openspec/reports/playwright-e2e-<name>-<timestamp>.md
91
91
  ```
92
92
 
93
93
  ## Prerequisites
@@ -115,7 +115,7 @@ Browser exploration is provided out of the box by Playwright MCP and `openspec-p
115
115
 
116
116
  1. Detects supported editors in the project (Claude Code and/or OpenCode)
117
117
  2. Installs the E2E command for each detected editor (`/opsx:e2e` for Claude Code, `/opsx-e2e` for OpenCode)
118
- 3. Generates `tests/playwright/seed.spec.ts`, `auth.setup.ts`, `credentials.yaml`, `app-knowledge.md`
118
+ 3. Generates `tests/playwright/seed.spec.ts`, `auth.setup.ts`, `credentials.yaml`, `app-knowledge.md`, `pages/BasePage.ts`
119
119
  4. Generates `playwright.config.ts` with automatic dev script and port detection (Vite/Next/Nuxt/Astro, `.env`, and `--port`)
120
120
 
121
121
  > **Note**: After running `openspec-pw init`, manually install Playwright browsers: `npx playwright install --with-deps`
@@ -144,14 +144,16 @@ Run through these steps in order when using the E2E workflow for the first time:
144
144
 
145
145
  ## App Server Detection
146
146
 
147
- Generated `playwright.config.ts` automatically detects the app URL in this order:
147
+ Generated `playwright.config.ts` automatically detects the app URL in this priority order:
148
148
 
149
149
  1. `BASE_URL` environment variable
150
- 2. port flags in `package.json` scripts, e.g. `vite --port 5125`
151
- 3. `vite.config.*` `server.port`
152
- 4. `.env.local`, `.env.development`, `.env` (`PLAYWRIGHT_PORT`, `E2E_PORT`, `VITE_PORT`, `PORT`)
153
- 5. framework defaults: Vite `5173`, Astro `4321`, Next/Nuxt `3000`
154
- 6. fallback: `http://localhost:3000`
150
+ 2. environment variables: `PLAYWRIGHT_PORT`, `E2E_PORT`, `VITE_PORT`, `PORT`
151
+ 3. port flags in `package.json` scripts, e.g. `vite --port 5125`
152
+ 4. `vite.config.*` `server.port`
153
+ 5. `.env.local`, `.env.development`, `.env` (same env var names)
154
+ 6. framework defaults: Vite `5173`, Astro `4321`, Next/Nuxt `3000`
155
+ 7. `seed.spec.ts` `BASE_URL` constant
156
+ 8. fallback: `http://localhost:3000`
155
157
 
156
158
  Run `openspec-pw doctor` to see the detected dev script and base URL:
157
159
 
@@ -215,27 +217,33 @@ CLI (openspec-pw)
215
217
  ├── run → Executes E2E tests with server lifecycle
216
218
  ├── migrate → Migrates old test files to new structure
217
219
  ├── audit → Audits tests for orphaned specs and issues
220
+ ├── coverage → Analyzes spec–test coverage for changes
218
221
  ├── flake → Detects static flake patterns in test files
219
222
  ├── doctor → Checks prerequisites
220
- ├── explore → Explores routes in parallel with Playwright
223
+ ├── explore → Explores app routes with Playwright
221
224
  └── uninstall → Removes integration from the project
222
225
 
223
226
  Editors (auto-detected by openspec-pw init)
224
227
  ├── Claude Code (/opsx:e2e)
225
228
  │ ├── .claude/commands/opsx/e2e.md → Command file
226
229
  │ ├── @playwright/mcp → Healer Agent tools (via `claude mcp add playwright …`)
227
- │ └── CLAUDE.md → Employee-grade standards
230
+ │ └── CLAUDE.md → Imports AGENTS.md via `@AGENTS.md`
228
231
  └── OpenCode (/opsx-e2e)
229
232
  ├── .opencode/commands/opsx-e2e.md → Command file (body rewritten from /opsx: → /opsx-)
230
233
  ├── opencode.jsonc → Playwright MCP (mcp.playwright) + instructions routing
231
- └── CLAUDE.md or AGENTS.md → Employee-grade standards (routed by detected editors)
234
+ └── AGENTS.md → Employee-grade standards (SSOT)
235
+
236
+ Employee-grade standards live in **AGENTS.md** as the single source of truth. Claude Code
237
+ loads them via a thin CLAUDE.md with `@AGENTS.md` import. OpenCode registers AGENTS.md in
238
+ `opencode.jsonc` under `instructions`.
232
239
 
233
240
  Test Assets (tests/playwright/)
234
241
  ├── seed.spec.ts → Env validation
235
242
  ├── auth.setup.ts → Session recording
236
243
  ├── global.teardown.ts → Post-test cleanup (optional)
237
244
  ├── credentials.yaml → Test users
238
- └── app-knowledge.md → Project-level selector patterns (cross-change)
245
+ ├── app-knowledge.md → Project-level selector patterns (cross-change)
246
+ └── pages/BasePage.ts → Shared page object class
239
247
 
240
248
  Exploration (openspec/changes/<name>/specs/playwright/)
241
249
  ├── app-exploration.md → This change's routes + verified selectors
package/README.zh-CN.md CHANGED
@@ -68,10 +68,12 @@ openspec-pw init # 安装 Playwright E2E 集成
68
68
  ```bash
69
69
  openspec-pw init # 初始化集成(一次性设置;加 --seed 覆盖已有 seed.spec.ts)
70
70
  openspec-pw update # 更新 CLI 和命令到最新版本
71
- openspec-pw doctor # 检查前置条件
71
+ openspec-pw doctor # 检查前置条件 + 应用服务器诊断
72
72
  openspec-pw audit # 检查测试文件是否有孤儿文件和配置问题
73
+ openspec-pw coverage # 分析 spec 与测试之间的覆盖率
74
+ openspec-pw flake # 检测测试文件中的静态不稳定模式
73
75
  openspec-pw migrate # 迁移旧测试文件到新目录结构
74
- openspec-pw explore # 并行探索路由
76
+ openspec-pw explore # 探索应用路由
75
77
  openspec-pw run <name> # 执行指定 change 的 E2E 测试
76
78
  openspec-pw uninstall # 移除项目中的集成
77
79
  ```
@@ -108,14 +110,14 @@ openspec-pw uninstall # 移除项目中的集成
108
110
 
109
111
  ├── 10. Healer(如需要)→ 通过 MCP 自动修复失败
110
112
 
111
- └── 11. 报告 → openspec/reports/playwright-e2e-<name>.md
113
+ └── 11. 报告 → openspec/reports/playwright-e2e-<name>-<timestamp>.md
112
114
  ```
113
115
 
114
116
  ## `openspec-pw init` 做了什么
115
117
 
116
118
  1. 检测项目中的受支持编辑器(Claude Code 和/或 OpenCode)
117
119
  2. 为每个检测到的编辑器安装 E2E 命令(Claude Code 用 `/opsx:e2e`,OpenCode 用 `/opsx-e2e`)
118
- 3. 生成 `tests/playwright/seed.spec.ts`、`auth.setup.ts`、`credentials.yaml`、`app-knowledge.md`
120
+ 3. 生成 `tests/playwright/seed.spec.ts`、`auth.setup.ts`、`credentials.yaml`、`app-knowledge.md`、`pages/BasePage.ts`
119
121
 
120
122
  ## 首次配置清单
121
123
 
@@ -188,23 +190,32 @@ CLI (openspec-pw)
188
190
  ├── run → 执行 E2E 测试并管理服务器生命周期
189
191
  ├── migrate → 迁移旧测试文件到新目录结构
190
192
  ├── audit → 检查测试文件是否有孤儿文件和配置问题
193
+ ├── coverage → 分析 spec 与测试之间的覆盖率
194
+ ├── flake → 检测测试文件中的静态不稳定模式
191
195
  ├── doctor → 检查前置条件
192
- ├── explore → 并行探索路由
196
+ ├── explore → 探索应用路由
193
197
  └── uninstall → 移除项目中的集成
194
198
 
195
199
  编辑器(由 openspec-pw init 自动检测)
196
200
  ├── Claude Code (/opsx:e2e)
197
201
  │ ├── .claude/commands/opsx/e2e.md → 命令文件(从 templates/e2e-command.md 安装)
198
- └── @playwright/mcp → Healer Agent 工具(通过 `claude mcp add playwright …`)
202
+ ├── @playwright/mcp → Healer Agent 工具(通过 `claude mcp add playwright …`)
203
+ │ └── CLAUDE.md → 通过 `@AGENTS.md` 引入 AGENTS.md
199
204
  └── OpenCode (/opsx-e2e)
200
205
  ├── .opencode/commands/opsx-e2e.md → 命令文件(正文由 /opsx: 改写为 /opsx-)
201
- └── opencode.jsonc → Playwright MCP (mcp.playwright) + 指令路由
206
+ ├── opencode.jsonc → Playwright MCP (mcp.playwright) + 指令路由
207
+ └── AGENTS.md → 员工级规范(单一数据源)
208
+
209
+ 员工级规范统一存放在 **AGENTS.md** 中。Claude Code 通过薄层 CLAUDE.md
210
+ (包含 `@AGENTS.md` 导入)加载;OpenCode 在 `opencode.jsonc` 的 `instructions` 中注册 AGENTS.md。
202
211
 
203
212
  测试资产 (tests/playwright/)
204
- ├── seed.spec.ts → 环境验证
205
- ├── auth.setup.ts → 会话录制
206
- ├── credentials.yaml 测试用户
207
- └── app-knowledge.md 项目级选择器模式(跨 change 复用)
213
+ ├── seed.spec.ts → 环境验证
214
+ ├── auth.setup.ts → 会话录制
215
+ ├── global.teardown.ts 测试后清理(可选)
216
+ ├── credentials.yaml 测试用户
217
+ ├── app-knowledge.md → 项目级选择器模式(跨 change 复用)
218
+ └── pages/BasePage.ts → 共享页面对象基类
208
219
 
209
220
  探索结果 (openspec/changes/<name>/specs/playwright/)
210
221
  ├── app-exploration.md → 本次 change 的路由 + 已验证选择器
@@ -20,6 +20,8 @@
20
20
 
21
21
  **精准改动**:只改必要的,改完清理自己造成的垃圾。匹配现有风格,不改进无关代码。
22
22
 
23
+ **代码文件行数上限 1500**:超过 1500 行即视为过长。需要扩展时按职责拆分为多个文件,而不是堆叠。
24
+
23
25
  **lint + typecheck 通过(项目标准工具链)才算成功**。动手前扫描项目根目录源码文件扩展名检测主语言——`.py`→Python(ruff + mypy)、`.ts`/`.tsx`→TypeScript(ESLint + tsc)、`.go`→Go(gofmt + vet),工具不存在时告知用户。
24
26
 
25
27
  **禁止非通用性改动**:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openspec-playwright",
3
- "version": "0.3.52",
3
+ "version": "0.3.53",
4
4
  "description": "OpenSpec + Playwright E2E verification setup tool for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {