@mison/ag-kit-cn 2.0.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/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +285 -0
- package/.agent/agents/backend-specialist.md +268 -0
- package/.agent/agents/code-archaeologist.md +106 -0
- package/.agent/agents/database-architect.md +225 -0
- package/.agent/agents/debugger.md +225 -0
- package/.agent/agents/devops-engineer.md +242 -0
- package/.agent/agents/documentation-writer.md +104 -0
- package/.agent/agents/explorer-agent.md +73 -0
- package/.agent/agents/frontend-specialist.md +618 -0
- package/.agent/agents/game-developer.md +162 -0
- package/.agent/agents/mobile-developer.md +382 -0
- package/.agent/agents/orchestrator.md +438 -0
- package/.agent/agents/penetration-tester.md +188 -0
- package/.agent/agents/performance-optimizer.md +187 -0
- package/.agent/agents/product-manager.md +112 -0
- package/.agent/agents/product-owner.md +95 -0
- package/.agent/agents/project-planner.md +405 -0
- package/.agent/agents/qa-automation-engineer.md +103 -0
- package/.agent/agents/security-auditor.md +170 -0
- package/.agent/agents/seo-specialist.md +111 -0
- package/.agent/agents/test-engineer.md +158 -0
- package/.agent/mcp_config.json +12 -0
- package/.agent/rules/GEMINI.md +273 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/api-patterns/SKILL.md +84 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +74 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +57 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/bash-linux/SKILL.md +201 -0
- package/.agent/skills/behavioral-modes/SKILL.md +264 -0
- package/.agent/skills/brainstorming/SKILL.md +164 -0
- package/.agent/skills/brainstorming/dynamic-questioning.md +359 -0
- package/.agent/skills/clean-code/SKILL.md +200 -0
- package/.agent/skills/code-review-checklist/SKILL.md +125 -0
- package/.agent/skills/database-design/SKILL.md +54 -0
- package/.agent/skills/database-design/database-selection.md +43 -0
- package/.agent/skills/database-design/indexing.md +39 -0
- package/.agent/skills/database-design/migrations.md +50 -0
- package/.agent/skills/database-design/optimization.md +36 -0
- package/.agent/skills/database-design/orm-selection.md +30 -0
- package/.agent/skills/database-design/schema-design.md +56 -0
- package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/.agent/skills/frontend-design/SKILL.md +418 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +307 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +727 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1118 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/.agent/skills/game-development/SKILL.md +167 -0
- package/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +155 -0
- package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/.agent/skills/lint-and-validate/SKILL.md +44 -0
- package/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/mobile-design/SKILL.md +394 -0
- package/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/.agent/skills/mobile-design/mobile-design-thinking.md +355 -0
- package/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/.agent/skills/mobile-design/mobile-typography.md +432 -0
- package/.agent/skills/mobile-design/platform-android.md +666 -0
- package/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +311 -0
- package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +241 -0
- package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +489 -0
- package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +263 -0
- package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +431 -0
- package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +683 -0
- package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +149 -0
- package/.agent/skills/nextjs-react-expert/SKILL.md +286 -0
- package/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/.agent/skills/parallel-agents/SKILL.md +194 -0
- package/.agent/skills/performance-profiling/SKILL.md +149 -0
- package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/.agent/skills/plan-writing/SKILL.md +152 -0
- package/.agent/skills/powershell-windows/SKILL.md +166 -0
- package/.agent/skills/python-patterns/SKILL.md +441 -0
- package/.agent/skills/red-team-tactics/SKILL.md +203 -0
- package/.agent/skills/rust-pro/SKILL.md +190 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +135 -0
- package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +215 -0
- package/.agent/skills/server-management/SKILL.md +161 -0
- package/.agent/skills/systematic-debugging/SKILL.md +114 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/.agent/skills/vulnerability-scanner/checklists.md +131 -0
- package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +459 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +242 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +80 -0
- package/.agent/workflows/restore-localize-compat.md +525 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +295 -0
- package/AGENT_FLOW.md +609 -0
- package/CHANGELOG.md +68 -0
- package/LICENSE +21 -0
- package/README.md +260 -0
- package/bin/adapters/base.js +63 -0
- package/bin/adapters/codex.js +391 -0
- package/bin/adapters/gemini.js +137 -0
- package/bin/ag-kit.js +1336 -0
- package/bin/core/builder.js +80 -0
- package/bin/core/generator.js +59 -0
- package/bin/core/resource-loader.js +64 -0
- package/bin/core/transformer.js +208 -0
- package/bin/interactive.js +65 -0
- package/bin/utils/atomic-writer.js +97 -0
- package/bin/utils/git-helper.js +68 -0
- package/bin/utils/managed-block.js +65 -0
- package/bin/utils/manifest.js +241 -0
- package/bin/utils.js +82 -0
- package/docs/codex-rules-template.md +36 -0
- package/docs/mapping-spec.md +68 -0
- package/docs/multi-target-adapter.md +80 -0
- package/docs/official/README.md +53 -0
- package/docs/official/antigravity/agent-modes-settings.md +64 -0
- package/docs/official/antigravity/rules-workflows.md +96 -0
- package/docs/official/antigravity/skills.md +147 -0
- package/docs/official/codex/agents-md.md +119 -0
- package/docs/official/codex/config-advanced.md +358 -0
- package/docs/official/codex/config-basic.md +141 -0
- package/docs/official/codex/config-reference.md +223 -0
- package/docs/official/codex/config-sample.md +216 -0
- package/docs/official/codex/mcp.md +107 -0
- package/docs/official/codex/rules.md +79 -0
- package/docs/official/codex/skills.md +114 -0
- package/docs/official/sources-index.md +32 -0
- package/docs/operations.md +145 -0
- package/docs/terminology-style-guide.md +69 -0
- package/package.json +51 -0
- package/scripts/postinstall-check.js +112 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: webapp-testing
|
|
3
|
+
description: Web 应用测试原则。覆盖端到端(E2E)、Playwright 与深度审计策略。
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Web 应用测试
|
|
8
|
+
|
|
9
|
+
> 发现并测试一切,不放过任何路由。Web 应用测试(Web App Testing)以完整覆盖为目标。
|
|
10
|
+
|
|
11
|
+
## 运行时脚本(Runtime Scripts)
|
|
12
|
+
|
|
13
|
+
**使用以下脚本执行自动化浏览器测试:**
|
|
14
|
+
|
|
15
|
+
| 脚本(Script) | 用途(Purpose) | 用法(Usage) |
|
|
16
|
+
|---------------|----------------|---------------|
|
|
17
|
+
| `scripts/playwright_runner.py` | 基础浏览器测试 | `python scripts/playwright_runner.py <网址>` |
|
|
18
|
+
| | 带截图输出 | `python scripts/playwright_runner.py <网址> --screenshot` |
|
|
19
|
+
| | 可访问性检查 | `python scripts/playwright_runner.py <网址> --a11y` |
|
|
20
|
+
|
|
21
|
+
**依赖要求:** `pip install playwright && playwright install chromium`
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. 深度审计方法(Deep Audit Approach)
|
|
26
|
+
|
|
27
|
+
### 先做发现(Discovery First)
|
|
28
|
+
|
|
29
|
+
| 目标(Target) | 如何发现(How to Find) |
|
|
30
|
+
|---------------|------------------------|
|
|
31
|
+
| 路由(Routes) | 扫描 app/、pages/、router 文件 |
|
|
32
|
+
| API 端点(API Endpoints) | 用 Grep 检索 HTTP 方法 |
|
|
33
|
+
| 组件(Components) | 查找组件目录 |
|
|
34
|
+
| 功能点(Features) | 阅读相关文档 |
|
|
35
|
+
|
|
36
|
+
### 系统化测试(Systematic Testing)
|
|
37
|
+
|
|
38
|
+
1. **Map(建图)** - 列出全部路由/API
|
|
39
|
+
2. **Scan(扫描)** - 验证是否可响应
|
|
40
|
+
3. **Test(测试)** - 覆盖关键路径
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. Web 测试金字塔(Testing Pyramid for Web)
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
/\ 端到端(E2E,少量)
|
|
48
|
+
/ \ 关键用户流程
|
|
49
|
+
/----\
|
|
50
|
+
/ \ 集成测试(Integration,中量)
|
|
51
|
+
/--------\ API、数据流
|
|
52
|
+
/ \
|
|
53
|
+
/------------\ 组件测试(Component,大量)
|
|
54
|
+
单个 UI 单元
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 3. 端到端(E2E)测试原则
|
|
60
|
+
|
|
61
|
+
### 测什么(What to Test)
|
|
62
|
+
|
|
63
|
+
| 优先级(Priority) | 测试内容(Tests) |
|
|
64
|
+
|-------------------|------------------|
|
|
65
|
+
| 1 | Happy Path(主流程) |
|
|
66
|
+
| 2 | 鉴权流程(Authentication flows) |
|
|
67
|
+
| 3 | 关键业务动作 |
|
|
68
|
+
| 4 | 错误处理 |
|
|
69
|
+
|
|
70
|
+
### 端到端(E2E)最佳实践
|
|
71
|
+
|
|
72
|
+
| 实践(Practice) | 原因(Why) |
|
|
73
|
+
|----------------|------------|
|
|
74
|
+
| 使用 `data-testid` | 选择器稳定 |
|
|
75
|
+
| 等待元素就绪 | 避免不稳定测试(flaky tests) |
|
|
76
|
+
| 保持干净状态 | 用例彼此独立 |
|
|
77
|
+
| 避免依赖实现细节 | 面向用户行为测试 |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 4. Playwright 原则(Playwright Principles)
|
|
82
|
+
|
|
83
|
+
### 核心概念(Core Concepts)
|
|
84
|
+
|
|
85
|
+
| 概念(Concept) | 用途(Use) |
|
|
86
|
+
|----------------|-----------|
|
|
87
|
+
| Page Object Model(页面对象模型) | 封装页面逻辑 |
|
|
88
|
+
| Fixtures(测试夹具) | 复用测试准备过程 |
|
|
89
|
+
| Assertions(断言) | 内置自动等待能力 |
|
|
90
|
+
| Trace Viewer(追踪查看器) | 调试失败用例 |
|
|
91
|
+
|
|
92
|
+
### 配置建议(Configuration)
|
|
93
|
+
|
|
94
|
+
| 设置项(Setting) | 建议(Recommendation) |
|
|
95
|
+
|-----------------|------------------------|
|
|
96
|
+
| 重试次数(Retries) | CI 中设为 2 |
|
|
97
|
+
| Trace(追踪) | `on-first-retry` |
|
|
98
|
+
| Screenshots(截图) | `on-failure` |
|
|
99
|
+
| Video(视频) | `retain-on-failure` |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 5. 视觉回归测试(Visual Testing)
|
|
104
|
+
|
|
105
|
+
### 何时使用(When to Use)
|
|
106
|
+
|
|
107
|
+
| 场景(Scenario) | 价值(Value) |
|
|
108
|
+
|-----------------|--------------|
|
|
109
|
+
| 设计系统(Design system) | 高 |
|
|
110
|
+
| 营销页面(Marketing pages) | 高 |
|
|
111
|
+
| 组件库(Component library) | 中 |
|
|
112
|
+
| 动态内容页面 | 相对较低 |
|
|
113
|
+
|
|
114
|
+
### 策略(Strategy)
|
|
115
|
+
|
|
116
|
+
- 先建立基线截图(Baseline screenshots)
|
|
117
|
+
- 变更后做对比
|
|
118
|
+
- 审查视觉差异
|
|
119
|
+
- 对有意变更更新基线
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 6. API 测试原则(API Testing Principles)
|
|
124
|
+
|
|
125
|
+
### 覆盖范围(Coverage Areas)
|
|
126
|
+
|
|
127
|
+
| 范围(Area) | 测试内容(Tests) |
|
|
128
|
+
|-------------|------------------|
|
|
129
|
+
| 状态码(Status codes) | 200, 400, 404, 500 |
|
|
130
|
+
| 响应结构(Response shape) | 与 schema(模式)匹配 |
|
|
131
|
+
| 错误信息(Error messages) | 对用户友好 |
|
|
132
|
+
| 边界场景(Edge cases) | 空值、大输入、特殊字符 |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 7. 测试组织方式(Test Organization)
|
|
137
|
+
|
|
138
|
+
### 文件结构(File Structure)
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
tests/
|
|
142
|
+
├── e2e/ # 全链路用户流程
|
|
143
|
+
├── integration/ # API、数据流
|
|
144
|
+
├── component/ # UI 单元
|
|
145
|
+
└── fixtures/ # 共享数据
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 命名约定(Naming Convention)
|
|
149
|
+
|
|
150
|
+
| 模式(Pattern) | 示例(Example) |
|
|
151
|
+
|---------------|----------------|
|
|
152
|
+
| 按功能命名(Feature-based) | `login.spec.ts` |
|
|
153
|
+
| 描述性命名(Descriptive) | `user-can-checkout.spec.ts` |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 8. CI 集成(CI Integration)
|
|
158
|
+
|
|
159
|
+
### 流水线步骤(Pipeline Steps)
|
|
160
|
+
|
|
161
|
+
1. 安装依赖
|
|
162
|
+
2. 安装浏览器
|
|
163
|
+
3. 执行测试
|
|
164
|
+
4. 上传产物(trace(追踪)、截图)
|
|
165
|
+
|
|
166
|
+
### 并行策略(Parallelization)
|
|
167
|
+
|
|
168
|
+
| 策略(Strategy) | 用途(Use) |
|
|
169
|
+
|-----------------|-----------|
|
|
170
|
+
| 按文件并行(Per file) | Playwright 默认策略 |
|
|
171
|
+
| 分片(Sharding) | 大规模测试集 |
|
|
172
|
+
| Workers(并发工作者)并发 | 多浏览器/多进程执行 |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 9. 反模式(Anti-Patterns)
|
|
177
|
+
|
|
178
|
+
| ❌ 避免(Don't) | ✅ 建议(Do) |
|
|
179
|
+
|----------------|-------------|
|
|
180
|
+
| 测实现细节 | 测用户行为 |
|
|
181
|
+
| 硬编码等待时间 | 使用自动等待 |
|
|
182
|
+
| 跳过清理步骤 | 确保用例隔离 |
|
|
183
|
+
| 忽略不稳定测试(flaky tests) | 修复根因 |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
> **牢记:** 端到端(E2E)成本高,只用于关键路径。
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Skill: webapp-testing
|
|
4
|
+
Script: playwright_runner.py
|
|
5
|
+
Purpose: Run basic Playwright browser tests
|
|
6
|
+
Usage: python playwright_runner.py <url> [--screenshot]
|
|
7
|
+
Output: JSON with page info, health status, and optional screenshot path
|
|
8
|
+
Note: Requires playwright (pip install playwright && playwright install chromium)
|
|
9
|
+
Screenshots: Saved to system temp directory (auto-cleaned by OS)
|
|
10
|
+
"""
|
|
11
|
+
import sys
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import tempfile
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
|
|
17
|
+
# Fix Windows console encoding for Unicode output
|
|
18
|
+
try:
|
|
19
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
20
|
+
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
|
21
|
+
except AttributeError:
|
|
22
|
+
pass # Python < 3.7
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from playwright.sync_api import sync_playwright
|
|
26
|
+
PLAYWRIGHT_AVAILABLE = True
|
|
27
|
+
except ImportError:
|
|
28
|
+
PLAYWRIGHT_AVAILABLE = False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def run_basic_test(url: str, take_screenshot: bool = False) -> dict:
|
|
32
|
+
"""Run basic browser test on URL."""
|
|
33
|
+
if not PLAYWRIGHT_AVAILABLE:
|
|
34
|
+
return {
|
|
35
|
+
"error": "Playwright not installed",
|
|
36
|
+
"fix": "pip install playwright && playwright install chromium"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
result = {
|
|
40
|
+
"url": url,
|
|
41
|
+
"timestamp": datetime.now().isoformat(),
|
|
42
|
+
"status": "pending"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
with sync_playwright() as p:
|
|
47
|
+
browser = p.chromium.launch(headless=True)
|
|
48
|
+
context = browser.new_context(
|
|
49
|
+
viewport={"width": 1280, "height": 720},
|
|
50
|
+
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
|
51
|
+
)
|
|
52
|
+
page = context.new_page()
|
|
53
|
+
|
|
54
|
+
# Navigate
|
|
55
|
+
response = page.goto(url, wait_until="networkidle", timeout=30000)
|
|
56
|
+
|
|
57
|
+
# Basic info
|
|
58
|
+
result["page"] = {
|
|
59
|
+
"title": page.title(),
|
|
60
|
+
"url": page.url,
|
|
61
|
+
"status_code": response.status if response else None
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Health checks
|
|
65
|
+
result["health"] = {
|
|
66
|
+
"loaded": response.ok if response else False,
|
|
67
|
+
"has_title": bool(page.title()),
|
|
68
|
+
"has_h1": page.locator("h1").count() > 0,
|
|
69
|
+
"has_links": page.locator("a").count() > 0,
|
|
70
|
+
"has_images": page.locator("img").count() > 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Console errors
|
|
74
|
+
console_errors = []
|
|
75
|
+
page.on("console", lambda msg: console_errors.append(msg.text) if msg.type == "error" else None)
|
|
76
|
+
|
|
77
|
+
# Performance metrics
|
|
78
|
+
result["performance"] = {
|
|
79
|
+
"dom_content_loaded": page.evaluate("window.performance.timing.domContentLoadedEventEnd - window.performance.timing.navigationStart"),
|
|
80
|
+
"load_complete": page.evaluate("window.performance.timing.loadEventEnd - window.performance.timing.navigationStart")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Screenshot - uses system temp directory (cross-platform, auto-cleaned)
|
|
84
|
+
if take_screenshot:
|
|
85
|
+
# Cross-platform: Windows=%TEMP%, Linux/macOS=/tmp
|
|
86
|
+
screenshot_dir = os.path.join(tempfile.gettempdir(), "maestro_screenshots")
|
|
87
|
+
os.makedirs(screenshot_dir, exist_ok=True)
|
|
88
|
+
screenshot_path = os.path.join(screenshot_dir, f"screenshot_{datetime.now().strftime('%Y%m%d_%H%M%S')}.png")
|
|
89
|
+
page.screenshot(path=screenshot_path, full_page=True)
|
|
90
|
+
result["screenshot"] = screenshot_path
|
|
91
|
+
result["screenshot_note"] = "Saved to temp directory (auto-cleaned by OS)"
|
|
92
|
+
|
|
93
|
+
# Element counts
|
|
94
|
+
result["elements"] = {
|
|
95
|
+
"links": page.locator("a").count(),
|
|
96
|
+
"buttons": page.locator("button").count(),
|
|
97
|
+
"inputs": page.locator("input").count(),
|
|
98
|
+
"images": page.locator("img").count(),
|
|
99
|
+
"forms": page.locator("form").count()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
browser.close()
|
|
103
|
+
|
|
104
|
+
result["status"] = "success" if result["health"]["loaded"] else "failed"
|
|
105
|
+
result["summary"] = "[OK] Page loaded successfully" if result["status"] == "success" else "[X] Page failed to load"
|
|
106
|
+
|
|
107
|
+
except Exception as e:
|
|
108
|
+
result["status"] = "error"
|
|
109
|
+
result["error"] = str(e)
|
|
110
|
+
result["summary"] = f"[X] Error: {str(e)[:100]}"
|
|
111
|
+
|
|
112
|
+
return result
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def run_accessibility_check(url: str) -> dict:
|
|
116
|
+
"""Run basic accessibility check."""
|
|
117
|
+
if not PLAYWRIGHT_AVAILABLE:
|
|
118
|
+
return {"error": "Playwright not installed"}
|
|
119
|
+
|
|
120
|
+
result = {"url": url, "accessibility": {}}
|
|
121
|
+
|
|
122
|
+
try:
|
|
123
|
+
with sync_playwright() as p:
|
|
124
|
+
browser = p.chromium.launch(headless=True)
|
|
125
|
+
page = browser.new_page()
|
|
126
|
+
page.goto(url, wait_until="networkidle", timeout=30000)
|
|
127
|
+
|
|
128
|
+
# Basic a11y checks
|
|
129
|
+
result["accessibility"] = {
|
|
130
|
+
"images_with_alt": page.locator("img[alt]").count(),
|
|
131
|
+
"images_without_alt": page.locator("img:not([alt])").count(),
|
|
132
|
+
"buttons_with_label": page.locator("button[aria-label], button:has-text('')").count(),
|
|
133
|
+
"links_with_text": page.locator("a:has-text('')").count(),
|
|
134
|
+
"form_labels": page.locator("label").count(),
|
|
135
|
+
"headings": {
|
|
136
|
+
"h1": page.locator("h1").count(),
|
|
137
|
+
"h2": page.locator("h2").count(),
|
|
138
|
+
"h3": page.locator("h3").count()
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
browser.close()
|
|
143
|
+
result["status"] = "success"
|
|
144
|
+
|
|
145
|
+
except Exception as e:
|
|
146
|
+
result["status"] = "error"
|
|
147
|
+
result["error"] = str(e)
|
|
148
|
+
|
|
149
|
+
return result
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if __name__ == "__main__":
|
|
153
|
+
if len(sys.argv) < 2:
|
|
154
|
+
print(json.dumps({
|
|
155
|
+
"error": "Usage: python playwright_runner.py <url> [--screenshot] [--a11y]",
|
|
156
|
+
"examples": [
|
|
157
|
+
"python playwright_runner.py https://example.com",
|
|
158
|
+
"python playwright_runner.py https://example.com --screenshot",
|
|
159
|
+
"python playwright_runner.py https://example.com --a11y"
|
|
160
|
+
]
|
|
161
|
+
}, indent=2))
|
|
162
|
+
sys.exit(1)
|
|
163
|
+
|
|
164
|
+
url = sys.argv[1]
|
|
165
|
+
take_screenshot = "--screenshot" in sys.argv
|
|
166
|
+
check_a11y = "--a11y" in sys.argv
|
|
167
|
+
|
|
168
|
+
if check_a11y:
|
|
169
|
+
result = run_accessibility_check(url)
|
|
170
|
+
else:
|
|
171
|
+
result = run_basic_test(url, take_screenshot)
|
|
172
|
+
|
|
173
|
+
print(json.dumps(result, indent=2))
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 面向项目与功能的结构化头脑风暴。在落地实现前探索多个可选方案。
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# /brainstorm - 结构化思路探索
|
|
6
|
+
|
|
7
|
+
$ARGUMENTS
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 目的
|
|
12
|
+
|
|
13
|
+
此命令激活 BRAINSTORM(头脑风暴)模式以进行结构化的思路探索。当你在决定具体的实现方案之前需要探索多个可选选项时,请使用此命令。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 行为
|
|
18
|
+
|
|
19
|
+
当 `/brainstorm` 被触发时:
|
|
20
|
+
|
|
21
|
+
1. **理解目标**
|
|
22
|
+
- 我们要解决什么问题?
|
|
23
|
+
- 目标用户是谁?
|
|
24
|
+
- 存在哪些约束条件?
|
|
25
|
+
|
|
26
|
+
2. **生成方案**
|
|
27
|
+
- 提供至少 3 种不同的处理方法
|
|
28
|
+
- 每种方法都包含 Pros(优点)与 Cons(缺点)
|
|
29
|
+
- 考虑非传统的解决方案
|
|
30
|
+
|
|
31
|
+
3. **比较与推荐**
|
|
32
|
+
- 汇总 tradeoffs(权衡)
|
|
33
|
+
- 给出带有理由的建议方案
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 输出格式
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
## 🧠 Brainstorm(头脑风暴):[主题]
|
|
41
|
+
|
|
42
|
+
### 背景
|
|
43
|
+
[简要的问题描述]
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### 方案 A:[名称]
|
|
48
|
+
[方案描述]
|
|
49
|
+
|
|
50
|
+
✅ **Pros(优点):**
|
|
51
|
+
- [优点 1]
|
|
52
|
+
- [优点 2]
|
|
53
|
+
|
|
54
|
+
❌ **Cons(缺点):**
|
|
55
|
+
- [缺点 1]
|
|
56
|
+
|
|
57
|
+
📊 **Effort(工作量):** 低 | 中 | 高
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### 方案 B:[名称]
|
|
62
|
+
[方案描述]
|
|
63
|
+
|
|
64
|
+
✅ **Pros(优点):**
|
|
65
|
+
- [优点 1]
|
|
66
|
+
|
|
67
|
+
❌ **Cons(缺点):**
|
|
68
|
+
- [缺点 1]
|
|
69
|
+
- [缺点 2]
|
|
70
|
+
|
|
71
|
+
📊 **Effort(工作量):** 低 | 中 | 高
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### 方案 C:[名称]
|
|
76
|
+
[方案描述]
|
|
77
|
+
|
|
78
|
+
✅ **Pros(优点):**
|
|
79
|
+
- [优点 1]
|
|
80
|
+
|
|
81
|
+
❌ **Cons(缺点):**
|
|
82
|
+
- [缺点 1]
|
|
83
|
+
|
|
84
|
+
📊 **Effort(工作量):** 低 | 中 | 高
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 💡 推荐
|
|
89
|
+
|
|
90
|
+
**方案 [X]**,因为 [理由]。
|
|
91
|
+
|
|
92
|
+
你想继续探索哪个方向?
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 示例
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
/brainstorm 身份验证系统
|
|
101
|
+
/brainstorm 复杂表单的状态管理
|
|
102
|
+
/brainstorm 社交类应用的数据库 Schema(架构)设计
|
|
103
|
+
/brainstorm 缓存策略
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 核心原则
|
|
109
|
+
|
|
110
|
+
- **不涉及代码** —— 本阶段侧重于思路,而非具体实现。
|
|
111
|
+
- **必要时可视化** —— 对于架构设计,使用图表进行说明。
|
|
112
|
+
- **诚实的权衡** —— 不要隐瞒方案的复杂度。
|
|
113
|
+
- **选择权交给用户** —— 展示所有选项,由用户进行最终决策。
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 新建应用命令。触发 App Builder(应用构建器)技能并启动与用户的交互式对话。
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# /create - 创建应用
|
|
6
|
+
|
|
7
|
+
$ARGUMENTS
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 任务
|
|
12
|
+
|
|
13
|
+
此命令用于启动一个全新的应用创建流程。
|
|
14
|
+
|
|
15
|
+
### 步骤:
|
|
16
|
+
|
|
17
|
+
1. **需求分析**
|
|
18
|
+
- 理解用户的具体需求
|
|
19
|
+
- 如果信息缺失,使用 `conversation-manager` 技能进行提问
|
|
20
|
+
|
|
21
|
+
2. **项目规划**
|
|
22
|
+
- 使用 `project-planner` Agent(智能体)进行任务拆解
|
|
23
|
+
- 确定技术栈
|
|
24
|
+
- 规划文件结构
|
|
25
|
+
- 创建计划文件并进入构建阶段
|
|
26
|
+
|
|
27
|
+
3. **应用构建(审批后)**
|
|
28
|
+
- 调度 `app-builder` 技能
|
|
29
|
+
- 协调专家 Agent(智能体):
|
|
30
|
+
- `database-architect` → Schema(架构)
|
|
31
|
+
- `backend-specialist` → API(接口)
|
|
32
|
+
- `frontend-specialist` → UI(界面)
|
|
33
|
+
|
|
34
|
+
4. **预览**
|
|
35
|
+
- 完成后使用 `auto_preview.py` 启动预览
|
|
36
|
+
- 将 URL(链接)呈现给用户
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 使用示例
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
/create 博客网站
|
|
44
|
+
/create 包含产品列表和购物车的电商应用
|
|
45
|
+
/create 待办事项(Todo)应用
|
|
46
|
+
/create Instagram 克隆
|
|
47
|
+
/create 具备客户管理功能的 CRM(客户关系管理)系统
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 在开始之前
|
|
53
|
+
|
|
54
|
+
如果需求不清晰,请提出以下问题:
|
|
55
|
+
- 应用属于什么类型?
|
|
56
|
+
- 基础功能有哪些?
|
|
57
|
+
- 谁会使用它?
|
|
58
|
+
|
|
59
|
+
先使用默认值,后续再添加细节。
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 调试命令。激活 DEBUG(调试)模式并进行系统化问题排查。
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# /debug - 系统化问题排查
|
|
6
|
+
|
|
7
|
+
$ARGUMENTS
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 目的
|
|
12
|
+
|
|
13
|
+
该命令用于激活 DEBUG(调试)模式,以系统化调查异常、报错或非预期行为。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 行为
|
|
18
|
+
|
|
19
|
+
当 `/debug` 被触发时:
|
|
20
|
+
|
|
21
|
+
1. **收集信息**
|
|
22
|
+
- 错误信息
|
|
23
|
+
- 复现步骤
|
|
24
|
+
- 预期行为 vs 实际行为
|
|
25
|
+
- 最近代码变更
|
|
26
|
+
|
|
27
|
+
2. **形成假设**
|
|
28
|
+
- 列出可能原因
|
|
29
|
+
- 按概率排序
|
|
30
|
+
|
|
31
|
+
3. **系统化调查**
|
|
32
|
+
- 逐条验证假设
|
|
33
|
+
- 检查日志与数据流
|
|
34
|
+
- 用排除法收敛根因
|
|
35
|
+
|
|
36
|
+
4. **修复并预防**
|
|
37
|
+
- 应用修复
|
|
38
|
+
- 解释根因
|
|
39
|
+
- 增加预防措施
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 输出格式
|
|
44
|
+
|
|
45
|
+
```markdown
|
|
46
|
+
## 🔍 Debug(调试):[问题]
|
|
47
|
+
|
|
48
|
+
### 1. 症状
|
|
49
|
+
[发生了什么]
|
|
50
|
+
|
|
51
|
+
### 2. 已收集信息
|
|
52
|
+
- 错误:`[错误信息]`
|
|
53
|
+
- 文件:`[文件路径]`
|
|
54
|
+
- 行号:[行号]
|
|
55
|
+
|
|
56
|
+
### 3. 假设
|
|
57
|
+
1. ❓ [最可能的原因]
|
|
58
|
+
2. ❓ [第二可能性]
|
|
59
|
+
3. ❓ [较低可能性]
|
|
60
|
+
|
|
61
|
+
### 4. 调查
|
|
62
|
+
|
|
63
|
+
**验证假设 1:**
|
|
64
|
+
[检查内容] → [结果]
|
|
65
|
+
|
|
66
|
+
**验证假设 2:**
|
|
67
|
+
[检查内容] → [结果]
|
|
68
|
+
|
|
69
|
+
### 5. 根因
|
|
70
|
+
🎯 **[为何会发生的解释]**
|
|
71
|
+
|
|
72
|
+
### 6. 修复
|
|
73
|
+
```[language]
|
|
74
|
+
// Before
|
|
75
|
+
[broken code]
|
|
76
|
+
|
|
77
|
+
// After
|
|
78
|
+
[fixed code]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 7. 预防
|
|
82
|
+
🛡️ [如何避免再次发生]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 示例
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
/debug 登录无法使用
|
|
91
|
+
/debug API(接口)返回 500
|
|
92
|
+
/debug 表单无法提交
|
|
93
|
+
/debug 数据未保存
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 核心原则
|
|
99
|
+
|
|
100
|
+
- **先问再判** —— 先拿到完整错误上下文
|
|
101
|
+
- **验证假设** —— 不要凭感觉乱改
|
|
102
|
+
- **解释原因** —— 不只说“怎么修”,还要说“为何坏”
|
|
103
|
+
- **防止复发** —— 补上测试与校验策略
|