@playcraft/cli 0.0.40 → 0.0.42

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.
Files changed (130) hide show
  1. package/README.md +66 -3
  2. package/dist/atom-plan/validate-atom-plan.js +298 -0
  3. package/dist/cli-root-help.js +1 -1
  4. package/dist/commands/3d.js +363 -0
  5. package/dist/commands/create.js +337 -0
  6. package/dist/commands/image.js +1337 -43
  7. package/dist/commands/recommend.js +1 -1
  8. package/dist/commands/remix.js +213 -0
  9. package/dist/commands/skills.js +1379 -0
  10. package/dist/commands/tools-3d.js +473 -0
  11. package/dist/commands/tools-generation.js +452 -0
  12. package/dist/commands/tools-project.js +400 -0
  13. package/dist/commands/tools-research.js +37 -0
  14. package/dist/commands/tools-research.test.js +216 -0
  15. package/dist/commands/tools-utils.js +183 -0
  16. package/dist/commands/tools.js +7 -616
  17. package/dist/config.js +2 -0
  18. package/dist/index.js +19 -1
  19. package/dist/utils/version-checker.js +8 -11
  20. package/package.json +9 -3
  21. package/project-template/.claude/agents/designer.md +120 -0
  22. package/project-template/.claude/agents/developer.md +124 -0
  23. package/project-template/.claude/agents/pm.md +164 -0
  24. package/project-template/.claude/agents/refs/README.md +73 -0
  25. package/project-template/.claude/agents/refs/designer-art-style-catalog.md +533 -0
  26. package/project-template/.claude/agents/refs/designer-color-audio-recipes.md +153 -0
  27. package/project-template/.claude/agents/refs/designer-deliverable-spec.md +191 -0
  28. package/project-template/.claude/agents/refs/designer-dimension-axis.md +27 -0
  29. package/project-template/.claude/agents/refs/designer-handoff-v2-checklist.md +68 -0
  30. package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +208 -0
  31. package/project-template/.claude/agents/refs/designer-style-exploration-flow.md +37 -0
  32. package/project-template/.claude/agents/refs/developer-dev-handoff.md +109 -0
  33. package/project-template/.claude/agents/refs/developer-impl-cookbook.md +134 -0
  34. package/project-template/.claude/agents/refs/developer-phase1-flow.md +136 -0
  35. package/project-template/.claude/agents/refs/pm-workflow-detail.md +551 -0
  36. package/project-template/.claude/agents/refs/reviewer-convergence-eval.md +130 -0
  37. package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +6 -0
  38. package/project-template/.claude/agents/refs/ta-3d-flip-recipe.md +85 -0
  39. package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
  40. package/project-template/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  41. package/project-template/.claude/agents/refs/ta-image-generation-detail.md +356 -0
  42. package/project-template/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  43. package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +1108 -0
  44. package/project-template/.claude/agents/refs/ta-tools-reference.md +111 -0
  45. package/project-template/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  46. package/project-template/.claude/agents/reviewer.md +127 -0
  47. package/project-template/.claude/agents/technical-artist.md +122 -0
  48. package/project-template/.claude/hooks/README.md +44 -0
  49. package/project-template/.claude/hooks/validate-atom-plan.mjs +224 -0
  50. package/project-template/.claude/hooks/validate-workflow-stop.mjs +343 -0
  51. package/project-template/.claude/settings.json +36 -0
  52. package/project-template/.claude/settings.local.json +4 -0
  53. package/project-template/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  54. package/project-template/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  55. package/project-template/.claude/skills/playcraft-asset-state-sheet/SKILL.md +141 -0
  56. package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  57. package/project-template/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  58. package/project-template/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  59. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +279 -0
  60. package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  61. package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  62. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +235 -0
  63. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
  64. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  65. package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
  66. package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  67. package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  68. package/project-template/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  69. package/project-template/.claude/skills/playcraft-masking/SKILL.md +373 -0
  70. package/project-template/.claude/skills/playcraft-research/SKILL.md +212 -0
  71. package/project-template/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  72. package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
  73. package/project-template/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  74. package/project-template/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  75. package/project-template/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  76. package/project-template/.claude/skills/playcraft-workflow/SKILL.md +485 -0
  77. package/project-template/.claude/skills/playwright-cli/SKILL.md +390 -0
  78. package/project-template/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  79. package/project-template/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  80. package/project-template/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  81. package/project-template/.claude/skills/playwright-cli/references/running-code.md +240 -0
  82. package/project-template/.claude/skills/playwright-cli/references/session-management.md +226 -0
  83. package/project-template/.claude/skills/playwright-cli/references/spec-driven-testing.md +312 -0
  84. package/project-template/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  85. package/project-template/.claude/skills/playwright-cli/references/test-generation.md +138 -0
  86. package/project-template/.claude/skills/playwright-cli/references/tracing.md +142 -0
  87. package/project-template/.claude/skills/playwright-cli/references/video-recording.md +157 -0
  88. package/project-template/.cursor/hooks.json +17 -0
  89. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +137 -0
  90. package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +18 -0
  91. package/project-template/CLAUDE.md +280 -0
  92. package/project-template/assets/audio/bgm/.gitkeep +0 -0
  93. package/project-template/assets/audio/sfx/.gitkeep +0 -0
  94. package/project-template/assets/bundles/.gitkeep +0 -0
  95. package/project-template/assets/images/bg/.gitkeep +0 -0
  96. package/project-template/assets/images/reference/.gitkeep +0 -0
  97. package/project-template/assets/images/storyboard/.gitkeep +0 -0
  98. package/project-template/assets/images/tiles/.gitkeep +0 -0
  99. package/project-template/assets/images/ui/.gitkeep +0 -0
  100. package/project-template/assets/images/vfx/.gitkeep +0 -0
  101. package/project-template/assets/models/.gitkeep +0 -0
  102. package/project-template/docs/team/agent-conduct.md +121 -0
  103. package/project-template/docs/team/agent-runtime-matrix.md +62 -0
  104. package/project-template/docs/team/atom-plan-format.md +105 -0
  105. package/project-template/docs/team/collaboration.md +297 -0
  106. package/project-template/docs/team/core-model.md +50 -0
  107. package/project-template/docs/team/platform-capabilities.md +15 -0
  108. package/project-template/docs/team/workflow-changelog.md +65 -0
  109. package/project-template/docs/team/workflow-consistency-checklist.md +140 -0
  110. package/project-template/game/config/.gitkeep +0 -0
  111. package/project-template/game/gameplay/.gitkeep +0 -0
  112. package/project-template/game/scenes/.gitkeep +0 -0
  113. package/project-template/logs/.gitkeep +0 -0
  114. package/project-template/ta-workspace/logs/.gitkeep +0 -0
  115. package/project-template/ta-workspace/scripts/.gitkeep +0 -0
  116. package/project-template/ta-workspace/tmp/.gitkeep +0 -0
  117. package/project-template/templates/atom-plan.template.json +26 -0
  118. package/project-template/templates/atom-plan.template.md +108 -0
  119. package/project-template/templates/design-brief.template.md +195 -0
  120. package/project-template/templates/design-lens-checklist.reference.md +117 -0
  121. package/project-template/templates/design-methodology.md +99 -0
  122. package/project-template/templates/designer-log.template.md +114 -0
  123. package/project-template/templates/developer-log.template.md +134 -0
  124. package/project-template/templates/five-axis-framework.md +186 -0
  125. package/project-template/templates/intent-clarifications.template.md +58 -0
  126. package/project-template/templates/layout-spec.template.md +146 -0
  127. package/project-template/templates/project-state.template.md +237 -0
  128. package/project-template/templates/review-report.template.md +91 -0
  129. package/project-template/templates/style-exploration.template.md +93 -0
  130. package/project-template/templates/ta-log.template.md +343 -0
@@ -0,0 +1,138 @@
1
+ # Test Generation
2
+
3
+ Generate Playwright test code automatically as you interact with the browser.
4
+
5
+ ## How It Works
6
+
7
+ Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.
8
+ This code appears in the output and can be copied directly into your test files.
9
+
10
+ ## Example Workflow
11
+
12
+ ```bash
13
+ # Start a session
14
+ playwright-cli open https://example.com/login
15
+
16
+ # Take a snapshot to see elements
17
+ playwright-cli snapshot
18
+ # Output shows: e1 [textbox "Email"], e2 [textbox "Password"], e3 [button "Sign In"]
19
+
20
+ # Fill form fields - generates code automatically
21
+ playwright-cli fill e1 "user@example.com"
22
+ # Ran Playwright code:
23
+ # await page.getByRole('textbox', { name: 'Email' }).fill('user@example.com');
24
+
25
+ playwright-cli fill e2 "password123"
26
+ # Ran Playwright code:
27
+ # await page.getByRole('textbox', { name: 'Password' }).fill('password123');
28
+
29
+ playwright-cli click e3
30
+ # Ran Playwright code:
31
+ # await page.getByRole('button', { name: 'Sign In' }).click();
32
+ ```
33
+
34
+ ## Building a Test File
35
+
36
+ Collect the generated code into a Playwright test:
37
+
38
+ ```typescript
39
+ import { test, expect } from "@playwright/test";
40
+
41
+ test("login flow", async ({ page }) => {
42
+ // Generated code from playwright-cli session:
43
+ await page.goto("https://example.com/login");
44
+ await page.getByRole("textbox", { name: "Email" }).fill("user@example.com");
45
+ await page.getByRole("textbox", { name: "Password" }).fill("password123");
46
+ await page.getByRole("button", { name: "Sign In" }).click();
47
+
48
+ // Add assertions
49
+ await expect(page).toHaveURL(/.*dashboard/);
50
+ });
51
+ ```
52
+
53
+ ## Best Practices
54
+
55
+ ### 1. Use Semantic Locators
56
+
57
+ The generated code uses role-based locators when possible, which are more resilient:
58
+
59
+ ```typescript
60
+ // Generated (good - semantic)
61
+ await page.getByRole("button", { name: "Submit" }).click();
62
+
63
+ // Avoid (fragile - CSS selectors)
64
+ await page.locator("#submit-btn").click();
65
+ ```
66
+
67
+ ### 2. Explore Before Recording
68
+
69
+ Take snapshots to understand the page structure before recording actions:
70
+
71
+ ```bash
72
+ playwright-cli open https://example.com
73
+ playwright-cli snapshot
74
+ # Review the element structure
75
+ playwright-cli click e5
76
+ ```
77
+
78
+ ### 3. Add Assertions Manually
79
+
80
+ Generated code captures actions but not assertions. Add expectations in your test using one of the recommended matchers:
81
+
82
+ - `toBeVisible()` — element is rendered and visible
83
+ - `toHaveText(text)` — element text content matches
84
+ - `toHaveValue(value) / toBeEmpty()` — input/select value matches
85
+ - `toBeChecked() / toBeUnchecked()` — checkbox state matches
86
+ - `toMatchAriaSnapshot(snapshot)` — page (or locator) matches a partial accessibility snapshot
87
+
88
+ Use `playwright-cli generate-locator <target>` to produce the locator expression for the assertion, and the snapshot/eval commands to capture the expected value.
89
+
90
+ When asserting text content, make sure that generated locator does not contain text from the element itself. `getByTestId()` or `getByLabel()` usually work well with asserting text. When locator is text-based, prefer `toBeVisible()` instead.
91
+
92
+ Snapshot to be matched does not have to contain all the information - only capture what's necessary for the assertion. You can use regular expressions for unstable values.
93
+
94
+ ```bash
95
+ # Get a stable locator for an element ref to use in the assertion
96
+ playwright-cli --raw generate-locator e5
97
+ # getByRole('button', { name: 'Submit' })
98
+
99
+ # Capture expected text content for toHaveText
100
+ playwright-cli --raw eval "el => el.textContent" e5
101
+
102
+ # Capture expected input value for toHaveValue/toBeEmpty
103
+ playwright-cli --raw eval "el => el.value" e5
104
+
105
+ # Capture expected aria snapshot for toMatchAriaSnapshot/toBeChecked
106
+ # (whole page, or use a ref to scope to a region)
107
+ playwright-cli --raw snapshot
108
+ playwright-cli --raw snapshot e5
109
+ ```
110
+
111
+ ```typescript
112
+ // Generated action
113
+ await page.getByRole("button", { name: "Submit" }).click();
114
+
115
+ // Manual assertions using the outputs above:
116
+ await expect(page.getByRole("alert", { name: "Success" })).toBeVisible();
117
+ await expect(page.getByTestId("main-header")).toHaveText("Welcome, user");
118
+ await expect(page.getByRole("textbox", { name: "Email" })).toHaveValue(
119
+ "user@example.com",
120
+ );
121
+ await expect(
122
+ page.getByRole("checkbox", { name: "Enable notifications" }),
123
+ ).toBeChecked();
124
+
125
+ // toMatchAriaSnapshot on the whole page, finds a matching region
126
+ await expect(page).toMatchAriaSnapshot(`
127
+ - heading "Welcome, user"
128
+ - link /\\d+ new messages?/
129
+ - button "Sign out"
130
+ `);
131
+
132
+ // toMatchAriaSnapshot scoped to a region
133
+ await expect(page.getByRole("navigation")).toMatchAriaSnapshot(`
134
+ - link "Home"
135
+ - link /\\d+ new messages?/
136
+ - link "Profile"
137
+ `);
138
+ ```
@@ -0,0 +1,142 @@
1
+ # Tracing
2
+
3
+ Capture detailed execution traces for debugging and analysis. Traces include DOM snapshots, screenshots, network activity, and console logs.
4
+
5
+ ## Basic Usage
6
+
7
+ ```bash
8
+ # Start trace recording
9
+ playwright-cli tracing-start
10
+
11
+ # Perform actions
12
+ playwright-cli open https://example.com
13
+ playwright-cli click e1
14
+ playwright-cli fill e2 "test"
15
+
16
+ # Stop trace recording
17
+ playwright-cli tracing-stop
18
+ ```
19
+
20
+ ## Trace Output Files
21
+
22
+ When you start tracing, Playwright creates a `traces/` directory with several files:
23
+
24
+ ### `trace-{timestamp}.trace`
25
+
26
+ **Action log** - The main trace file containing:
27
+
28
+ - Every action performed (clicks, fills, navigations)
29
+ - DOM snapshots before and after each action
30
+ - Screenshots at each step
31
+ - Timing information
32
+ - Console messages
33
+ - Source locations
34
+
35
+ ### `trace-{timestamp}.network`
36
+
37
+ **Network log** - Complete network activity:
38
+
39
+ - All HTTP requests and responses
40
+ - Request headers and bodies
41
+ - Response headers and bodies
42
+ - Timing (DNS, connect, TLS, TTFB, download)
43
+ - Resource sizes
44
+ - Failed requests and errors
45
+
46
+ ### `resources/`
47
+
48
+ **Resources directory** - Cached resources:
49
+
50
+ - Images, fonts, stylesheets, scripts
51
+ - Response bodies for replay
52
+ - Assets needed to reconstruct page state
53
+
54
+ ## What Traces Capture
55
+
56
+ | Category | Details |
57
+ | --------------- | -------------------------------------------------- |
58
+ | **Actions** | Clicks, fills, hovers, keyboard input, navigations |
59
+ | **DOM** | Full DOM snapshot before/after each action |
60
+ | **Screenshots** | Visual state at each step |
61
+ | **Network** | All requests, responses, headers, bodies, timing |
62
+ | **Console** | All console.log, warn, error messages |
63
+ | **Timing** | Precise timing for each operation |
64
+
65
+ ## Use Cases
66
+
67
+ ### Debugging Failed Actions
68
+
69
+ ```bash
70
+ playwright-cli tracing-start
71
+ playwright-cli open https://app.example.com
72
+
73
+ # This click fails - why?
74
+ playwright-cli click e5
75
+
76
+ playwright-cli tracing-stop
77
+ # Open trace to see DOM state when click was attempted
78
+ ```
79
+
80
+ ### Analyzing Performance
81
+
82
+ ```bash
83
+ playwright-cli tracing-start
84
+ playwright-cli open https://slow-site.com
85
+ playwright-cli tracing-stop
86
+
87
+ # View network waterfall to identify slow resources
88
+ ```
89
+
90
+ ### Capturing Evidence
91
+
92
+ ```bash
93
+ # Record a complete user flow for documentation
94
+ playwright-cli tracing-start
95
+
96
+ playwright-cli open https://app.example.com/checkout
97
+ playwright-cli fill e1 "4111111111111111"
98
+ playwright-cli fill e2 "12/25"
99
+ playwright-cli fill e3 "123"
100
+ playwright-cli click e4
101
+
102
+ playwright-cli tracing-stop
103
+ # Trace shows exact sequence of events
104
+ ```
105
+
106
+ ## Trace vs Video vs Screenshot
107
+
108
+ | Feature | Trace | Video | Screenshot |
109
+ | ----------------------- | ----------- | ----------- | ---------------- |
110
+ | **Format** | .trace file | .webm video | .png/.jpeg image |
111
+ | **DOM inspection** | Yes | No | No |
112
+ | **Network details** | Yes | No | No |
113
+ | **Step-by-step replay** | Yes | Continuous | Single frame |
114
+ | **File size** | Medium | Large | Small |
115
+ | **Best for** | Debugging | Demos | Quick capture |
116
+
117
+ ## Best Practices
118
+
119
+ ### 1. Start Tracing Before the Problem
120
+
121
+ ```bash
122
+ # Trace the entire flow, not just the failing step
123
+ playwright-cli tracing-start
124
+ playwright-cli open https://example.com
125
+ # ... all steps leading to the issue ...
126
+ playwright-cli tracing-stop
127
+ ```
128
+
129
+ ### 2. Clean Up Old Traces
130
+
131
+ Traces can consume significant disk space:
132
+
133
+ ```bash
134
+ # Remove traces older than 7 days
135
+ find .playwright-cli/traces -mtime +7 -delete
136
+ ```
137
+
138
+ ## Limitations
139
+
140
+ - Traces add overhead to automation
141
+ - Large traces can consume significant disk space
142
+ - Some dynamic content may not replay perfectly
@@ -0,0 +1,157 @@
1
+ # Video Recording
2
+
3
+ Capture browser automation sessions as video for debugging, documentation, or verification. Produces WebM (VP8/VP9 codec).
4
+
5
+ ## Basic Recording
6
+
7
+ ```bash
8
+ # Open browser first
9
+ playwright-cli open
10
+
11
+ # Start recording
12
+ playwright-cli video-start demo.webm
13
+
14
+ # Add a chapter marker for section transitions
15
+ playwright-cli video-chapter "Getting Started" --description="Opening the homepage" --duration=2000
16
+
17
+ # Navigate and perform actions
18
+ playwright-cli goto https://example.com
19
+ playwright-cli snapshot
20
+ playwright-cli click e1
21
+
22
+ # Add another chapter
23
+ playwright-cli video-chapter "Filling Form" --description="Entering test data" --duration=2000
24
+ playwright-cli fill e2 "test input"
25
+
26
+ # Stop and save
27
+ playwright-cli video-stop
28
+ ```
29
+
30
+ ## Best Practices
31
+
32
+ ### 1. Use Descriptive Filenames
33
+
34
+ ```bash
35
+ # Include context in filename
36
+ playwright-cli video-start recordings/login-flow-2024-01-15.webm
37
+ playwright-cli video-start recordings/checkout-test-run-42.webm
38
+ ```
39
+
40
+ ### 2. Record entire hero scripts.
41
+
42
+ When recording a video for the user or as a proof of work, it is best to create a code snippet and execute it with run-code.
43
+ It allows pulling appropriate pauses between the actions and annotating the video. There are new Playwright APIs for that.
44
+
45
+ 1. Perform scenario using CLI and take note of all locators and actions. You'll need those locators to request their bounding boxes for highlight.
46
+ 2. Create a file with the intended script for video (below). Use pressSequentially w/ delay for nice typing, make reasonable pauses.
47
+ 3. Use playwright-cli run-code --filename your-script.js
48
+
49
+ **Important**: Overlays are `pointer-events: none` — they do not interfere with page interactions. You can safely keep sticky overlays visible while clicking, filling, or performing any actions on the page.
50
+
51
+ ```js
52
+ async (page) => {
53
+ await page.screencast.start({
54
+ path: "video.webm",
55
+ size: { width: 1280, height: 800 },
56
+ });
57
+ await page.goto("https://demo.playwright.dev/todomvc");
58
+
59
+ // Show a chapter card — blurs the page and shows a dialog.
60
+ // Blocks until duration expires, then auto-removes.
61
+ // Use this for simple use cases, but always feel free to hand-craft your own beautiful
62
+ // overlay via await page.screencast.showOverlay().
63
+ await page.screencast.showChapter("Adding Todo Items", {
64
+ description: "We will add several items to the todo list.",
65
+ duration: 2000,
66
+ });
67
+
68
+ // Perform action
69
+ await page
70
+ .getByRole("textbox", { name: "What needs to be done?" })
71
+ .pressSequentially("Walk the dog", { delay: 60 });
72
+ await page
73
+ .getByRole("textbox", { name: "What needs to be done?" })
74
+ .press("Enter");
75
+ await page.waitForTimeout(1000);
76
+
77
+ // Show next chapter
78
+ await page.screencast.showChapter("Verifying Results", {
79
+ description: "Checking the item appeared in the list.",
80
+ duration: 2000,
81
+ });
82
+
83
+ // Add a sticky annotation that stays while you perform actions.
84
+ // Overlays are pointer-events: none, so they won't block clicks.
85
+ const annotation = await page.screencast.showOverlay(`
86
+ <div style="position: absolute; top: 8px; right: 8px;
87
+ padding: 6px 12px; background: rgba(0,0,0,0.7);
88
+ border-radius: 8px; font-size: 13px; color: white;">
89
+ ✓ Item added successfully
90
+ </div>
91
+ `);
92
+
93
+ // Perform more actions while the annotation is visible
94
+ await page
95
+ .getByRole("textbox", { name: "What needs to be done?" })
96
+ .pressSequentially("Buy groceries", { delay: 60 });
97
+ await page
98
+ .getByRole("textbox", { name: "What needs to be done?" })
99
+ .press("Enter");
100
+ await page.waitForTimeout(1500);
101
+
102
+ // Remove the annotation when done
103
+ await annotation.dispose();
104
+
105
+ // You can also highlight relevant locators and provide contextual annotations.
106
+ const bounds = await page.getByText("Walk the dog").boundingBox();
107
+ await page.screencast.showOverlay(
108
+ `
109
+ <div style="position: absolute;
110
+ top: ${bounds.y}px;
111
+ left: ${bounds.x}px;
112
+ width: ${bounds.width}px;
113
+ height: ${bounds.height}px;
114
+ border: 1px solid red;">
115
+ </div>
116
+ <div style="position: absolute;
117
+ top: ${bounds.y + bounds.height + 5}px;
118
+ left: ${bounds.x + bounds.width / 2}px;
119
+ transform: translateX(-50%);
120
+ padding: 6px;
121
+ background: #808080;
122
+ border-radius: 10px;
123
+ font-size: 14px;
124
+ color: white;">Check it out, it is right above this text
125
+ </div>
126
+ `,
127
+ { duration: 2000 },
128
+ );
129
+
130
+ await page.screencast.stop();
131
+ };
132
+ ```
133
+
134
+ Embrace creativity, overlays are powerful.
135
+
136
+ ### Overlay API Summary
137
+
138
+ | Method | Use Case |
139
+ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
140
+ | `page.screencast.showChapter(title, { description?, duration?, styleSheet? })` | Full-screen chapter card with blurred backdrop — ideal for section transitions |
141
+ | `page.screencast.showOverlay(html, { duration? })` | Custom HTML overlay — use for callouts, labels, highlights |
142
+ | `disposable.dispose()` | Remove a sticky overlay added without duration |
143
+ | `page.screencast.hideOverlays()` / `page.screencast.showOverlays()` | Temporarily hide/show all overlays |
144
+
145
+ ## Tracing vs Video
146
+
147
+ | Feature | Video | Tracing |
148
+ | -------- | -------------------- | ---------------------------------------- |
149
+ | Output | WebM file | Trace file (viewable in Trace Viewer) |
150
+ | Shows | Visual recording | DOM snapshots, network, console, actions |
151
+ | Use case | Demos, documentation | Debugging, analysis |
152
+ | Size | Larger | Smaller |
153
+
154
+ ## Limitations
155
+
156
+ - Recording adds slight overhead to automation
157
+ - Large recordings can consume significant disk space
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "subagentStop": [
5
+ {
6
+ "command": "node .claude/hooks/validate-atom-plan.mjs",
7
+ "timeout": 30,
8
+ "failClosed": false
9
+ },
10
+ {
11
+ "command": "node .claude/hooks/validate-workflow-stop.mjs",
12
+ "timeout": 30,
13
+ "failClosed": false
14
+ }
15
+ ]
16
+ }
17
+ }
@@ -0,0 +1,137 @@
1
+ ---
2
+ description: PlayCraft playable ad orchestrator — gates, stages, sub-agent spawn only
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # PlayCraft Orchestrator
7
+
8
+ You are the **orchestrator** for a PlayCraft playable ad project. Do not role-play PM, Designer, TA, Developer, and Reviewer in one session when `@agent` invoke is available.
9
+
10
+ ## Invoke `@developer` (`ui_pass` / `gameplay_pass` only)
11
+
12
+ Sub-agents start a **fresh session** — they do not see your `playcraft skills match` output.
13
+
14
+ **Before `ui_pass`** (after TA Wave 2 `done`):
15
+
16
+ 1. Confirm PM ran `playcraft skills link --from-atom-plan --prune` (or run it before spawn).
17
+ 2. Read `docs/atom-plan.json` → `atoms[]` where `assignTo: Developer` and `skillRef` is non-null.
18
+ 3. Optional 30s spot-check: `ta-log` Compliance green + contract paths exist under `assets/`.
19
+ 4. In the **first message** to `@developer`, paste skillRef list; require Skill Preflight + **UI Pass Plan** (not full gameplay yet).
20
+ 5. Ban hand-written PGS that ignores linked Skill `ref/`.
21
+
22
+ **Before `gameplay_pass`** (after `ui_review` pass):
23
+
24
+ 1. Confirm `devStatus: ui_ready` and UI Diff Report passed (or max rounds reached).
25
+ 2. Invoke `@developer` for gameplay only — UI shell must not be rewritten unless UI Diff items remain open.
26
+
27
+ UI Pass STOP invalid without **§ Skill Preflight** + **§ UI Pass Plan**. Gameplay Pass STOP invalid without **§ Gameplay Pass Plan**.
28
+
29
+ ## Gate pre-check: Reviewer `design_check`
30
+
31
+ Before **Gate #1** and **Gate #2b** (not #2a), invoke `@reviewer` with mode `design_check`:
32
+
33
+ 1. PM or Designer STOP with gate materials ready.
34
+ 2. Invoke `@reviewer design_check` — soft checklist only (completeness, no subjective quality).
35
+ 3. If fail → route to PM/Designer per report → re-invoke Reviewer → then run Gate.
36
+
37
+ ## Dispatching Principle: WHAT + Skill Refs, not HOW
38
+
39
+ **Orchestrator 不是全知全能的指挥官。** Sub-agents 有完整的 `.claude/agents/<role>.md` + `refs/` + Skills 体系。
40
+
41
+ **调度时只传递:**
42
+ 1. **目标**:需要完成哪些 atoms / review mode
43
+ 2. **关键约束/提醒**:如 `mediaGroups` 中有可复用资产
44
+ 3. **上游依赖状态**:哪些 Wave 已完成
45
+
46
+ **禁止调度时:**
47
+ - 写出详细生产步骤(agent 自己读 refs/ 和 Skills)
48
+ - 越俎代庖选择 prompt/model/工具(agent 按 Skill Preflight 决定)
49
+ - 跳过 agent 自身的 Step 0 流程
50
+
51
+ ## Post-STOP 验证(必须,在阶段转换前)
52
+
53
+ Sub-agent STOP 返回后,orchestrator **必须验证** 再转阶段:
54
+
55
+ | 验证项 | 方法 | 失败处理 |
56
+ | ----------------------------------------- | ------------------------------------------------------------------------------------ | ------------------ |
57
+ | Atom status 已全部更新 | `atom-plan.json` → 该 agent 所有 atoms 的 `status ≠ pending` | 要求补全 |
58
+ | actualOutput 非空且文件存在 | `atoms[].actualOutput` 对应文件在磁盘上存在 | 要求补全 |
59
+ | Skill Context 已填写 | `atom-plan.md` 对应区域不含 `"(Pending"` | 要求回填 |
60
+ | Skill Preflight 已完成 | TA: `ta-log.md` § Skill Preflight; Developer: `developer-log.md` § Skill Preflight | 拒绝 STOP,重新入 |
61
+ | Plan section 已完成 | `ui_pass`: § UI Pass Plan; `gameplay_pass`: § Gameplay Pass Plan | 拒绝 STOP,重新入 |
62
+ | mediaGroups 处置已记录(Designer/TA) | `ta-log.md` § mediaGroups Reuse 或 `designer-log` 有处置记录 | 要求补充 |
63
+
64
+ ## Before every decision
65
+
66
+ 1. Read `docs/project-state.md` → parse **`## Agent handoff`** YAML + Gates table + **Production Pipeline** waves.
67
+ 2. If `gate_pending` non-null and `waiting_for: user_gate` → **Gate only** — do **not** invoke sub-agents.
68
+ 3. If `subagent_stop: true` and `waiting_for: orchestrator` → execute **only** `next_orchestrator_action`.
69
+ 4. Follow `CLAUDE.md` Orchestration Protocol and `docs/team/collaboration.md` § Gate Protocol, § Agent Handoff.
70
+ 5. Before invoke: reset handoff (`subagent_stop: false`, `waiting_for: none`, `subagent: <target>`).
71
+
72
+ ## Gates (only you ask the user)
73
+
74
+ | Gate | When | Action |
75
+ | ---- | ---- | ------ |
76
+ | #1 | handoff `gate_pending: "1"` after Reviewer `design_check` pass | `AskUserQuestion` → pass → `stage: style_exploration` → `@designer` |
77
+ | #2a | `gate_pending: "2a"` | `AskUserQuestion` → `selectedMcOption` → resume `@designer` (no Reviewer pre-check) |
78
+ | #2b | `gate_pending: "2b"` after Reviewer `design_check` pass | Confirm MC+ASR → `stage: production` → invoke `@designer` Ph.2 **only** |
79
+ | #3 | Reviewer `load_check` pass, `devStatus: ready` | Show **devUrl** via `AskUserQuestion` — user never runs `npm run dev` |
80
+
81
+ Sub-agents **must not** use `AskUserQuestion` or set mainline `stage`. See `docs/team/agent-conduct.md`.
82
+
83
+ ## Workflow STOP hooks (Claude Code + Cursor)
84
+
85
+ After **Technical Artist** or **Developer** subagent STOP, `.claude/hooks/validate-workflow-stop.mjs` runs automatically:
86
+
87
+ - **Claude Code**: `.claude/settings.json` → `SubagentStop`
88
+ - **Cursor**: `.cursor/hooks.json` → `subagentStop`
89
+
90
+ If intake validation fails, the subagent **cannot stop** until `logs/ta-log.md` or `logs/developer-log.md` § **Upstream Intake** + correct Plan section is complete. Do **not** invoke the next role until handoff shows a successful STOP (or re-invoke the same agent to fix intake).
91
+
92
+ **Serial spawn after Gate #2b:** `@designer` → (Wave 1 done) `@technical-artist` → (Wave 2 done) `stage: ui_pass` + `@developer`. **Never** spawn `@developer` during `production`.
93
+
94
+ ## Stage sync on handoff
95
+
96
+ When executing `next_orchestrator_action`, **also** update `stage` / gates (sub-agents never do this):
97
+
98
+ | Action substring | Must write |
99
+ | ---------------- | ---------- |
100
+ | `Invoke @reviewer design_check Gate #1` | Stay `pm`; Reviewer audit only |
101
+ | `Run Gate #1` | After pass: `stage: style_exploration`, `gates.#1 = passed` |
102
+ | `Run Gate #2a` | `gates.#2a = passed`, set `selectedMcOption`, resume `@designer` |
103
+ | `Invoke @reviewer design_check Gate #2b` | Stay `style_exploration`; Reviewer audit only |
104
+ | `Run Gate #2b` | `stage: production`, `gates.#2b = passed`, invoke `@designer` Ph.2 only |
105
+ | `Invoke @technical-artist` | Wave 1 `done` → invoke TA (stay `production`) |
106
+ | `Set stage=ui_pass` / invoke `@developer` | Wave 2 `done` → `stage: ui_pass` |
107
+ | `Invoke @reviewer ui_diff` | `stage: ui_review` |
108
+ | `Set stage=ui_rework` | `stage: ui_rework` + invoke routed agents |
109
+ | `Set stage=gameplay_pass` | UI convergence done → `stage: gameplay_pass` |
110
+ | `Invoke @reviewer load_check` | Before Gate #3 |
111
+ | `Run Gate #3` | `gates.#3 = pending` → accept → `stage: done` |
112
+
113
+ ## Handoff × stage matrix
114
+
115
+ | stage | gate_pending | Typical `next_orchestrator_action` |
116
+ | ----- | ------------ | ------------------------------------ |
117
+ | `pm` | `"1"` | Invoke `@reviewer design_check Gate #1` → Run Gate #1 |
118
+ | `style_exploration` | `"2a"` | Run Gate #2a |
119
+ | `style_exploration` | `"2b"` | Invoke `@reviewer design_check Gate #2b` → Run Gate #2b → `stage: production` → `@designer` Ph.2 |
120
+ | `production` | null, Wave 1 pending | `@designer` Ph.2 |
121
+ | `production` | null, Wave 1 done | `Invoke @technical-artist` |
122
+ | `production` | null, Wave 2 done | `Set stage=ui_pass, invoke @developer` |
123
+ | `ui_pass` | null, `devStatus: ui_ready` | Invoke `@reviewer ui_diff` |
124
+ | `ui_pass` | null, `blocked_upstream` | Re-invoke per `devBlockers.routeTo` → `@developer` |
125
+ | `ui_review` | — (fail) | Set `stage: ui_rework`, invoke routed agents |
126
+ | `ui_rework` | null | Fixes → `@developer` → `@reviewer ui_diff` |
127
+ | `ui_review` | — (pass or 5 rounds) | Set `stage: gameplay_pass, invoke @developer` |
128
+ | `gameplay_pass` | null, `devStatus: ready` | Invoke `@reviewer load_check` |
129
+ | `gameplay_pass` | load_check fail | Re-invoke `@developer` → `@reviewer load_check` |
130
+ | `gameplay_pass` | load_check pass | Gate #3 devUrl |
131
+
132
+ ## Stage shortcuts
133
+
134
+ - Gate #2b → `@designer` only; Wave 1 done → `@technical-artist`; Wave 2 done → `ui_pass` + `@developer`
135
+ - UI fail → **you** set `stage: ui_rework` (Reviewer does not)
136
+ - `uiReworkRound` max 5 — then proceed to `gameplay_pass` or escalate to user
137
+ - `done` = user accepts devUrl; **not** `playcraft build`
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: PlayCraft sub-agent file boundaries — no user gates, STOP protocol
3
+ globs: .claude/agents/**,docs/**,logs/**,assets/**,game/**
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Sub-Agent Boundary
8
+
9
+ When editing project outputs as a **sub-agent** (PM / Designer / TA / Developer / Reviewer):
10
+
11
+ - **Do not** `AskUserQuestion` or ask the user to choose Gate options.
12
+ - On gate-ready work: update `## Agent handoff` YAML + `gates.#*` = `pending` + Progress Checkpoint → **STOP** (see `## Runtime` in your agent file).
13
+ - If `subagent_stop: true` for your role → do not duplicate work; wait for orchestrator.
14
+ - Read `docs/team/agent-conduct.md` and your `.claude/agents/<role>.md` § Runtime + § Agent Conduct.
15
+ - **Do not** change mainline `stage` — use `next_orchestrator_action` in handoff.
16
+ - R/W matrix: `docs/team/collaboration.md`.
17
+
18
+ Designer: read `selectedMcOption` before ASR (UI + element state sheets). TA: only after Production Pipeline Wave 1 `done`. Developer: only in `ui_pass` / `gameplay_pass` / `ui_rework`; complete `developer-log.md` § Skill Preflight + stage-appropriate Plan before `game/` edits; `ui_pass` → `devStatus: ui_ready`; `gameplay_pass` → `devStatus: ready`; never either with open `devBlockers`.