prizmkit 1.1.72 → 1.1.76

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 (62) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/agents/prizm-dev-team-dev.md +11 -1
  3. package/bundled/dev-pipeline/.env.example +1 -0
  4. package/bundled/dev-pipeline/lib/common.sh +53 -0
  5. package/bundled/dev-pipeline/lib/heartbeat.sh +94 -42
  6. package/bundled/dev-pipeline/run-bugfix.sh +5 -0
  7. package/bundled/dev-pipeline/run-feature.sh +5 -0
  8. package/bundled/dev-pipeline/run-recovery.sh +6 -0
  9. package/bundled/dev-pipeline/run-refactor.sh +5 -0
  10. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +265 -5
  11. package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +21 -0
  12. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +1 -1
  13. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -9
  14. package/bundled/dev-pipeline/templates/sections/feature-context.md +3 -18
  15. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +1 -1
  16. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-base.md +6 -12
  17. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +10 -3
  18. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +1 -0
  19. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +4 -8
  20. package/bundled/dev-pipeline-windows/lib/common.ps1 +23 -0
  21. package/bundled/dev-pipeline-windows/lib/heartbeat.sh +439 -0
  22. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +33 -2
  23. package/bundled/dev-pipeline-windows/run-recovery.ps1 +11 -0
  24. package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +265 -5
  25. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +21 -0
  26. package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +1 -1
  27. package/bundled/dev-pipeline-windows/templates/bootstrap-prompt.md +27 -0
  28. package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +543 -14
  29. package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +664 -14
  30. package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +741 -14
  31. package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +2 -2
  32. package/bundled/dev-pipeline-windows/templates/feature-list-schema.json +1 -1
  33. package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +1 -1
  34. package/bundled/dev-pipeline-windows/templates/refactor-list-schema.json +1 -1
  35. package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +3 -3
  36. package/bundled/dev-pipeline-windows/templates/sections/failure-capture.md +1 -1
  37. package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +3 -18
  38. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +239 -40
  39. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-opencli.md +75 -26
  40. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification.md +142 -36
  41. package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +2 -2
  42. package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +1 -1
  43. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-agent-suffix.md +1 -1
  44. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +7 -17
  45. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-lite-suffix.md +10 -3
  46. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +1 -1
  47. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan.md +1 -1
  48. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +3 -1
  49. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +7 -3
  50. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +1 -3
  51. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-agent.md +1 -1
  52. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +1 -1
  53. package/bundled/dev-pipeline-windows/templates/sections/phase-review-agent.md +1 -1
  54. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +2 -2
  55. package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +13 -17
  56. package/bundled/dev-pipeline-windows/templates/sections/phase0-test-baseline.md +2 -4
  57. package/bundled/dev-pipeline-windows/templates/sections/subagent-timeout-recovery.md +1 -1
  58. package/bundled/skills/_metadata.json +1 -1
  59. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +1 -0
  60. package/bundled/skills/feature-pipeline-launcher/SKILL.md +1 -0
  61. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +1 -0
  62. package/package.json +1 -1
@@ -1,20 +1,74 @@
1
- # PrizmKit Windows Feature Pipeline Prompt (bootstrap-tier1)
1
+ # Dev-Pipeline Session Bootstrap Tier 1 (Single Agent)
2
2
 
3
- You are running in headless non-interactive mode on Windows PowerShell. Use PowerShell-native commands only.
3
+ ## Session Context
4
4
 
5
- ## Feature
6
- {{FEATURE_ID}} {{FEATURE_TITLE}}
5
+ - **Feature ID**: {{FEATURE_ID}} | **Session**: {{SESSION_ID}} | **Run**: {{RUN_ID}}
6
+ - **Complexity**: {{COMPLEXITY}}
7
+ - **Init**: {{INIT_DONE}} | Artifacts: spec={{HAS_SPEC}} plan={{HAS_PLAN}}
8
+
9
+ ## Your Mission
10
+
11
+ You are the **session orchestrator**. Implement Feature {{FEATURE_ID}}: "{{FEATURE_TITLE}}".
12
+
13
+ **CRITICAL**: You MUST NOT exit until ALL work is complete and committed.
14
+
15
+ **Tier 1 — Single Agent**: You handle everything directly. No subagents, no TeamCreate.
16
+
17
+ ### Feature Description
7
18
 
8
19
  {{FEATURE_DESCRIPTION}}
9
20
 
10
- ## Required workflow
11
- 1. Read the relevant project context and existing PrizmKit docs.
12
- 2. Create or update the implementation plan in `.prizmkit/specs/{{FEATURE_SLUG}}/plan.md`.
13
- 3. Implement the feature, run targeted validation, and record results in `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`.
14
- 4. Use browser verification when required by the feature metadata.
15
- 5. Commit the completed feature with the PrizmKit committer workflow.
21
+ {{USER_CONTEXT}}
22
+
23
+ ### Acceptance Criteria
24
+
25
+ {{ACCEPTANCE_CRITERIA}}
26
+
27
+ ### Project Brief
28
+
29
+ > Product ideas checklist from planning. Lines marked [x] are already implemented. When your feature touches any [ ] item, ensure alignment. After implementation, mark relevant items [x] and append the key file/directory paths.
30
+
31
+ {{PROJECT_BRIEF}}
32
+
33
+ ### Dependencies (Already Completed)
34
+
35
+ {{COMPLETED_DEPENDENCIES}}
36
+
37
+ ### App Global Context
38
+
39
+ {{GLOBAL_CONTEXT}}
40
+
41
+ ## ⚠️ Context Budget Rules (CRITICAL — read before any phase)
42
+
43
+ You are running in **headless non-interactive mode** with a FINITE context window. Exceeding it will crash the session and lose all work. Follow these rules strictly:
44
+
45
+ 0. **NON-INTERACTIVE MODE** — There is NO human on the other end. NEVER ask for user confirmation, NEVER wait for user input, NEVER use interactive prompts (e.g. "Would you like me to…"). If a skill has an interactive step (e.g. offer remediation, ask for approval), skip it and proceed autonomously. Make decisions based on the data available and move forward.
46
+
47
+ 1. **context-snapshot.md is your single source of truth** — After Phase 1 builds it, ALWAYS read context-snapshot.md instead of re-reading individual source files
48
+ 2. **Never re-read your own writes** — After you create/modify a file, do NOT read it back to verify. Trust your write was correct.
49
+ 3. **Stay focused** — Do NOT explore code unrelated to this feature. No curiosity-driven reads.
50
+ 4. **One task at a time** — In Phase 3 (implement), complete and test one task before starting the next.
51
+ 5. **Minimize tool output** — Never load full command output into context. First capture to a temp file (`& { <command> } 2>&1 | Tee-Object (Join-Path $env:TEMP "out.txt") | Select-Object -Last 20`), then scan the first/last lines to identify relevant fields, and use targeted filtering (`Select-String`, regex matching, PowerShell object filtering) to extract only the information needed for the current task. Only read the filtered result — never the raw full output.
52
+ 6. **No intermediate commits** — Do NOT run `git add`/`git commit` during Phase 1-3. All changes are committed once at the end in Phase 4 via `/prizmkit-committer`.
53
+ 7. **Capture test output once** — When running test suites, always use `& { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "test-out.txt") | Select-Object -Last 20`. Then Select-String `(Join-Path $env:TEMP "test-out.txt")` for details. Never re-run the suite just to apply a different filter.
54
+
55
+ ---
56
+
57
+ ## PrizmKit Directory Convention
58
+
59
+ ```
60
+ .prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md
61
+ .prizmkit/specs/{{FEATURE_SLUG}}/plan.md ← includes Tasks section
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Execution
67
+
68
+ ### PowerShell Python Helper
69
+
70
+ Define this helper once in the active PowerShell session before running PrizmKit Python scripts:
16
71
 
17
- ## PowerShell checkpoint update
18
72
  ```powershell
19
73
  function Invoke-PrizmPython {
20
74
  param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
@@ -36,8 +90,483 @@ function Invoke-PrizmPython {
36
90
  }
37
91
  throw "Python 3 is required. Install Python and ensure python or py is in PATH."
38
92
  }
39
- Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py --checkpoint-path {{CHECKPOINT_PATH}} --step prizmkit-implement --status completed
40
93
  ```
41
94
 
42
- ## Failure capture
43
- If a phase fails, write the failed phase, reason, files touched, and next recommended action to `.prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md`.
95
+
96
+ {{IF_INIT_NEEDED}}
97
+ ### Phase 0: Project Bootstrap
98
+ - Run `/prizmkit-init` (invoke the prizmkit-init skill)
99
+ - Run `Invoke-PrizmPython {{INIT_SCRIPT_PATH}} --project-root {{PROJECT_ROOT}} --feature-id {{FEATURE_ID}} --feature-slug {{FEATURE_SLUG}}`
100
+ - **CP-0**: Verify `.prizmkit/prizm-docs/root.prizm`, `.prizmkit/config.json` exist
101
+ {{END_IF_INIT_NEEDED}}
102
+ {{IF_INIT_DONE}}
103
+ ### Phase 0: SKIP (already initialized)
104
+ {{END_IF_INIT_DONE}}
105
+
106
+ ### Phase 1: Build Context Snapshot
107
+
108
+ ```powershell
109
+ if (Test-Path -LiteralPath ".prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md") { "EXISTS" } else { "MISSING" }
110
+ ```
111
+
112
+ If MISSING — build it now:
113
+ 1. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1 prizm docs
114
+ 2. Detect source code directories: read KEY_FILES and STRUCTURE sections from `root.prizm` to identify where source code lives (e.g. `src/`, `app/`, `lib/`, `cmd/`, `packages/`, or project root). If `root.prizm` is missing, scan the project tree:
115
+ ```powershell
116
+ Get-ChildItem -Path . -Recurse -File -Depth 2 -Include *.js,*.ts,*.py,*.go,*.java,*.rb,*.rs -ErrorAction SilentlyContinue |
117
+ Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|dist|build|vendor)\\' } |
118
+ Select-Object -First 30 -ExpandProperty FullName
119
+ ```
120
+ Identify the top-level source directories from the results.
121
+ 3. Scan the detected source directories for files related to this feature; read each one
122
+ 4. Write `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`:
123
+ - **Section 1 — Feature Brief**: feature description + acceptance criteria (copy from above)
124
+ - **Section 2 — Project Structure**: run the following to get a visual directory tree, then paste output:
125
+ ```powershell
126
+ Get-ChildItem -Path . -Directory -Recurse -Depth 2 -ErrorAction SilentlyContinue |
127
+ Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|dist|build|__pycache__|vendor)\\' } |
128
+ Select-Object -ExpandProperty FullName
129
+ ```
130
+ - **Section 3 — Prizm Context**: content of root.prizm and relevant L1/L2 docs
131
+ - **Section 4 — Existing Source Files**: **full verbatim content** of each related file in fenced code blocks (with `### path/to/file` heading and line count). Include ALL files needed for implementation and review — downstream phases read this section instead of re-reading individual source files
132
+ - **Section 5 — Existing Tests**: full content of related test files as code block
133
+
134
+ ### Phase 2: Plan & Tasks
135
+
136
+ ```powershell
137
+ Get-ChildItem -LiteralPath ".prizmkit/specs/{{FEATURE_SLUG}}/" -ErrorAction SilentlyContinue
138
+ ```
139
+
140
+ If plan.md missing, run `/prizmkit-plan` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` to generate `plan.md`:
141
+ - The plan.md should include: key components, data flow, files to create/modify, and a Tasks section with `[ ]` checkboxes (each task = one implementable unit). Keep under 80 lines.
142
+ - Resolve any `[NEEDS CLARIFICATION]` markers using the feature description — do NOT pause for interactive input.
143
+
144
+ **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
145
+ Before proceeding past CP-1:
146
+ 1. Scan for existing schema files (`*.prisma`, `*.sql`, `migrations/`, `models/`, `*.entity.*`) and read them
147
+ 2. Ensure new tables/fields follow existing naming conventions and constraint patterns
148
+ 3. Resolve all uncertain DB design decisions before writing Tasks — document choices in plan.md
149
+
150
+ **CP-1**: plan.md exists with Tasks section.
151
+
152
+ ### Phase 3: Implement + Test
153
+
154
+ **Build artifacts**: After any build/compile command (`go build`, `npm run build`, `tsc`, etc.), ensure the output binary or build directory is in `.gitignore`:
155
+ ```powershell
156
+ # Example for Go
157
+ if (-not (Select-String -Path .gitignore -Pattern '^/binary-name$' -Quiet -ErrorAction SilentlyContinue)) {
158
+ Add-Content -Path .gitignore -Value '/binary-name'
159
+ }
160
+ ```
161
+ Never commit compiled binaries, build output, or generated artifacts.
162
+
163
+ **3a.** Detect test commands and record baseline:
164
+
165
+ You know this project's tech stack. Identify ALL test commands that apply (e.g., `go test ./...`, `npm test`, `cargo test`, `pytest`, `make test`, etc.). Record them as `TEST_CMDS` (one or more commands). Then record baseline:
166
+ ```powershell
167
+ # Run each test command, capture output
168
+ & { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "test-baseline.txt") | Select-Object -Last 20
169
+ ```
170
+
171
+ **3b.** Run `/prizmkit-implement` — this handles the full implementation cycle:
172
+ - Reads plan.md Tasks section from `.prizmkit/specs/{{FEATURE_SLUG}}/`
173
+ - Reads context from `context-snapshot.md` (Prizm docs, TRAPS, file manifest)
174
+ - Implements task-by-task with TDD, marking each `[x]` immediately
175
+ - Creates/updates L2 `.prizm` docs when creating new modules or significantly modifying existing ones — AI selectively decides the modules that warrant L2 based on complexity and importance
176
+ - Runs tests using `TEST_CMD` after each task
177
+ - Writes '## Implementation Log' to `context-snapshot.md`
178
+
179
+ **3b-compact.** Context management — if plan.md has more than 5 tasks, run `/compact` after completing every 3 tasks during implementation. This prevents context window exhaustion in long sessions. If `/compact` is not available (non-Claude CLI), skip this step.
180
+
181
+ **3c.** After implement completes, verify:
182
+ 1. All tasks in plan.md are `[x]`
183
+ 2. Run the full test suite to ensure nothing is broken
184
+ 3. Verify each acceptance criterion from Section 1 of context-snapshot.md is met — check mentally, do NOT re-read files you already wrote
185
+ 4. If any criterion is not met, fix it now using the convergence-based recovery loop below
186
+
187
+ **CP-2**: All acceptance criteria met, all tests pass.
188
+
189
+ ### Test Failure Recovery (Convergence-Based)
190
+
191
+ When tests fail, use convergence recovery — keep fixing while progress is being made:
192
+
193
+ 1. **Run tests, record results**: count failures, exclude baseline failures
194
+ 2. **Check termination**: All pass → done | Plateau (same failures 3 rounds) → stop | Failures decreased → continue
195
+ 3. **Fix and iterate**: analyze, fix, re-run `({{TEST_CMD}})`, go back to step 1
196
+
197
+ **Key rule**: If failures decrease (even by 1), plateau counter resets. Do NOT block commit for unresolved failures — document and defer to next session.
198
+
199
+
200
+ {{IF_BROWSER_INTERACTION}}
201
+ ### Phase 3.5: Browser Verification — MANDATORY
202
+
203
+ You MUST execute this phase. Do NOT skip it.
204
+
205
+ **Browser Tool**: {{BROWSER_TOOL}}
206
+
207
+ {{IF_BROWSER_TOOL_PLAYWRIGHT}}
208
+ **Using: playwright-cli**
209
+
210
+ **CRITICAL CONSTRAINT — playwright-cli ONLY, NO Playwright MCP**:
211
+ - You MUST use `playwright-cli` (the CLI tool) for ALL browser interactions in this phase
212
+ - **NEVER** use Playwright MCP server, Playwright MCP tools, or any MCP-based browser automation
213
+ - If you have Playwright MCP configured, IGNORE it entirely — use the CLI command `playwright-cli` exclusively
214
+ - All browser actions go through `playwright-cli <command>` in the PowerShell tool, not through any MCP tool call
215
+
216
+ **Step 0 — Playwright CLI Readiness Check (BLOCKING — must pass before any browser action)**:
217
+
218
+ 0a. Check if `playwright-cli` is installed:
219
+ ```powershell
220
+ $playwright = Get-Command playwright-cli -ErrorAction SilentlyContinue
221
+ if ($playwright) { playwright-cli --version } else { "NOT_INSTALLED" }
222
+ ```
223
+ If output is `NOT_INSTALLED`, install it:
224
+ ```powershell
225
+ npm install -g @playwright/cli@latest
226
+ ```
227
+ Then verify installation succeeded:
228
+ ```powershell
229
+ playwright-cli --version
230
+ ```
231
+ If installation fails, log the error in context-snapshot.md under `## Browser Verification: SKIPPED — playwright-cli installation failed` and proceed to the next phase. Do NOT attempt browser verification without playwright-cli.
232
+
233
+ 0b. Learn playwright-cli usage (run once per session to understand available commands):
234
+ ```powershell
235
+ playwright-cli --help
236
+ ```
237
+ Use this output to determine the correct commands for your verification steps. Do NOT guess command syntax — refer to the help output.
238
+
239
+ 0c. Check if playwright-cli skill is installed for the current AI platform:
240
+ ```powershell
241
+ $currentPlatform = "unknown"
242
+ $skillDir = $null
243
+ if (Get-Command claude -ErrorAction SilentlyContinue) {
244
+ $currentPlatform = "claude"
245
+ $skillDir = Join-Path $HOME ".claude\skills"
246
+ } elseif (Get-Command cbc -ErrorAction SilentlyContinue) {
247
+ $currentPlatform = "codebuddy"
248
+ $skillDir = Join-Path $HOME ".cbc\skills"
249
+ }
250
+
251
+ $skillExists = $false
252
+ if ($skillDir) {
253
+ $directSkill = Join-Path $skillDir "playwright-cli"
254
+ $matchingSkills = Get-ChildItem -Path $skillDir -Filter "playwright*" -ErrorAction SilentlyContinue
255
+ $skillExists = (Test-Path -LiteralPath $directSkill) -or [bool]$matchingSkills
256
+ }
257
+ if ($skillExists) { "SKILL_EXISTS" } else { "SKILL_MISSING" }
258
+ ```
259
+ If `SKILL_MISSING`:
260
+ ```powershell
261
+ playwright-cli install --skills
262
+ ```
263
+ If the current platform is NOT claude, move the installed skill files to the correct location:
264
+ ```powershell
265
+ $claudeSkillDir = Join-Path $HOME ".claude\skills"
266
+ $sourceSkill = Join-Path $claudeSkillDir "playwright-cli"
267
+ if ($currentPlatform -ne "claude" -and $currentPlatform -ne "unknown" -and $skillDir -and (Test-Path -LiteralPath $sourceSkill)) {
268
+ New-Item -ItemType Directory -Force -Path $skillDir | Out-Null
269
+ Copy-Item -Recurse -Force -Path $sourceSkill -Destination $skillDir
270
+ "Moved playwright-cli skill from claude to $currentPlatform"
271
+ }
272
+ ```
273
+
274
+ 0d. Read the installed playwright-cli skill for workflow guidance:
275
+ After skill installation, read the skill's SKILL.md to understand recommended workflows and patterns. Use these patterns to construct your verification flow — do NOT invent your own patterns if the skill provides them.
276
+
277
+ **Step 1 — Start Dev Server**:
278
+
279
+ You know this project's tech stack. Detect and start the dev server yourself:
280
+
281
+ 1. Identify the dev server start command from project config (`package.json` scripts, `Makefile`, `docker-compose.yml`, etc.)
282
+ 2. **Detect the dev server port** — use the pre-detected port from pipeline if available, otherwise extract from project config. Do NOT hardcode or guess the port:
283
+ ```powershell
284
+ $DEV_PORT = "{{DEV_PORT}}"
285
+ if ($DEV_PORT -eq "{{DEV_PORT}}" -or [string]::IsNullOrWhiteSpace($DEV_PORT)) {
286
+ $detectedPort = ""
287
+ if (Test-Path -LiteralPath "package.json") {
288
+ $detectedPort = node -e "const p=require('./package.json'); const s=(p.scripts?.dev) || ''; const m=s.match(/-p\s+(\d+)/); console.log(m?m[1]:'')"
289
+ }
290
+ if (-not $detectedPort -and $env:NEXT_PUBLIC_SITE_URL -match ':([0-9]+)') {
291
+ $detectedPort = $Matches[1]
292
+ }
293
+ if ($detectedPort) { $DEV_PORT = $detectedPort } else { $DEV_PORT = "3000" }
294
+ }
295
+ "Detected DEV_PORT=$DEV_PORT"
296
+ ```
297
+ 3. Verify the port is available and start the dev server in the background, capturing its process id:
298
+ ```powershell
299
+ $portBusy = Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue
300
+ if ($portBusy) { "PORT_IN_USE" } else { "PORT_FREE" }
301
+ $devServerCommand = "<start-command>"
302
+ $server = Start-Process -FilePath "powershell" -ArgumentList @("-NoProfile", "-Command", $devServerCommand) -PassThru
303
+ $DEV_SERVER_PID = $server.Id
304
+ ```
305
+
306
+ Wait for server to be ready: poll `http://localhost:$DEV_PORT` until it returns 200 or 302 (max 30 seconds, 2s interval):
307
+ ```powershell
308
+ $ready = $false
309
+ for ($i = 0; $i -lt 15; $i++) {
310
+ try {
311
+ $response = Invoke-WebRequest -Uri "http://localhost:$DEV_PORT" -UseBasicParsing -TimeoutSec 2
312
+ if ($response.StatusCode -in @(200, 302)) { $ready = $true; break }
313
+ } catch {
314
+ Start-Sleep -Seconds 2
315
+ }
316
+ }
317
+ if (-not $ready) { "DEV_SERVER_NOT_READY" }
318
+ ```
319
+ 4. Open the app in playwright-cli: `playwright-cli open "http://localhost:$DEV_PORT"`
320
+ 5. If the page requires authentication, use playwright-cli to register a test user and log in first
321
+
322
+ **Step 2 — Verification**:
323
+
324
+ Use `playwright-cli snapshot` on the running app to discover actual element refs, then verify these goals:
325
+ {{BROWSER_VERIFY_STEPS}}
326
+
327
+ Construct your verification workflow based on:
328
+ 1. The playwright-cli skill documentation (read in Step 0d)
329
+ 2. The `playwright-cli --help` output (captured in Step 0b)
330
+ 3. The current task's Verification Gates and implemented features
331
+
332
+ Decide the concrete playwright-cli actions (click, fill, snapshot, screenshot, etc.) yourself based on the snapshot output and your knowledge of the implemented code. The goals above describe WHAT to verify — you determine HOW using playwright-cli commands.
333
+
334
+ Take a final screenshot for evidence: `playwright-cli screenshot`
335
+
336
+ **Step 3 — Cleanup (REQUIRED — you started it, you stop it)**:
337
+
338
+ 1. Close the playwright-cli browser: `playwright-cli close`
339
+ 2. Stop the dev server process and any remaining process bound to the dev server port:
340
+ ```powershell
341
+ if ($DEV_SERVER_PID) { Stop-Process -Id $DEV_SERVER_PID -Force -ErrorAction SilentlyContinue }
342
+ Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue |
343
+ Select-Object -ExpandProperty OwningProcess -Unique |
344
+ ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
345
+ ```
346
+
347
+ {{END_IF_BROWSER_TOOL_PLAYWRIGHT}}
348
+ {{IF_BROWSER_TOOL_OPENCLI}}
349
+ **Using: opencli** (reuses Chrome logged-in sessions)
350
+
351
+ **CRITICAL CONSTRAINT — opencli browser ONLY**:
352
+ - You MUST use `opencli browser` for ALL browser interactions in this phase
353
+ - All browser actions go through `opencli browser <command>` in the PowerShell tool
354
+
355
+ **Step 0 — OpenCLI Readiness Check (BLOCKING)**:
356
+
357
+ 0a. Check if `opencli` is installed:
358
+ ```powershell
359
+ $opencli = Get-Command opencli -ErrorAction SilentlyContinue
360
+ if ($opencli) { opencli --version } else { "NOT_INSTALLED" }
361
+ ```
362
+ If `NOT_INSTALLED`: `npm install -g @jackwener/opencli@latest`. If installation fails, log `## Browser Verification: SKIPPED — opencli installation failed` and proceed.
363
+
364
+ 0b. Verify Browser Bridge: `opencli doctor`. If fails, log skip and proceed.
365
+
366
+ 0c. Learn usage:
367
+ ```powershell
368
+ opencli browser --help 2>$null
369
+ if ($LASTEXITCODE -ne 0) { opencli --help }
370
+ ```
371
+
372
+ **Step 1 — Start Dev Server**: use the same port detection and server lifecycle pattern as the playwright-cli path:
373
+ ```powershell
374
+ $DEV_PORT = "{{DEV_PORT}}"
375
+ if ($DEV_PORT -eq "{{DEV_PORT}}" -or [string]::IsNullOrWhiteSpace($DEV_PORT)) {
376
+ $detectedPort = ""
377
+ if (Test-Path -LiteralPath "package.json") {
378
+ $detectedPort = node -e "const p=require('./package.json'); const s=(p.scripts?.dev) || ''; const m=s.match(/-p\s+(\d+)/); console.log(m?m[1]:'')"
379
+ }
380
+ if (-not $detectedPort -and $env:NEXT_PUBLIC_SITE_URL -match ':([0-9]+)') {
381
+ $detectedPort = $Matches[1]
382
+ }
383
+ if ($detectedPort) { $DEV_PORT = $detectedPort } else { $DEV_PORT = "3000" }
384
+ }
385
+ "Detected DEV_PORT=$DEV_PORT"
386
+ ```
387
+ ```powershell
388
+ $portBusy = Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue
389
+ if ($portBusy) { "PORT_IN_USE" } else { "PORT_FREE" }
390
+ $devServerCommand = "<start-command>"
391
+ $server = Start-Process -FilePath "powershell" -ArgumentList @("-NoProfile", "-Command", $devServerCommand) -PassThru
392
+ $DEV_SERVER_PID = $server.Id
393
+ ```
394
+
395
+ Wait for server to be ready: poll `http://localhost:$DEV_PORT` until it returns 200 or 302 (max 30 seconds, 2s interval):
396
+ ```powershell
397
+ $ready = $false
398
+ for ($i = 0; $i -lt 15; $i++) {
399
+ try {
400
+ $response = Invoke-WebRequest -Uri "http://localhost:$DEV_PORT" -UseBasicParsing -TimeoutSec 2
401
+ if ($response.StatusCode -in @(200, 302)) { $ready = $true; break }
402
+ } catch {
403
+ Start-Sleep -Seconds 2
404
+ }
405
+ }
406
+ if (-not $ready) { "DEV_SERVER_NOT_READY" }
407
+ ```
408
+
409
+ Start server, wait for ready, then:
410
+ ```powershell
411
+ opencli browser open "http://localhost:$DEV_PORT"
412
+ if ($LASTEXITCODE -eq 0) { opencli browser state }
413
+ ```
414
+
415
+ **Step 2 — Verification**:
416
+
417
+ Use `opencli browser state` to discover elements with `[N]` indices, then verify:
418
+ {{BROWSER_VERIFY_STEPS}}
419
+
420
+ Chain commands in PowerShell with semicolons and inspect each result, for example: `opencli browser click <N>; opencli browser wait time 1; opencli browser state`
421
+
422
+ **Step 3 — Cleanup**:
423
+ 1. `opencli browser close`
424
+ 2. Stop the dev server process and any remaining process bound to the dev server port:
425
+ ```powershell
426
+ if ($DEV_SERVER_PID) { Stop-Process -Id $DEV_SERVER_PID -Force -ErrorAction SilentlyContinue }
427
+ Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue |
428
+ Select-Object -ExpandProperty OwningProcess -Unique |
429
+ ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
430
+ ```
431
+
432
+ {{END_IF_BROWSER_TOOL_OPENCLI}}
433
+ {{IF_BROWSER_TOOL_AUTO}}
434
+ **Tool Selection**: Choose the best browser tool at runtime.
435
+
436
+ **Step 0 — Detect available tools**:
437
+ ```powershell
438
+ "=== playwright-cli ==="
439
+ $playwright = Get-Command playwright-cli -ErrorAction SilentlyContinue
440
+ if ($playwright) { playwright-cli --version } else { "NOT_INSTALLED" }
441
+ "=== opencli ==="
442
+ $opencli = Get-Command opencli -ErrorAction SilentlyContinue
443
+ if ($opencli) { opencli --version } else { "NOT_INSTALLED" }
444
+ if ($opencli) {
445
+ opencli doctor 2>$null
446
+ if ($LASTEXITCODE -ne 0) { "OPENCLI_BRIDGE_FAILED" }
447
+ }
448
+ ```
449
+
450
+ **Decision table**:
451
+ | Condition | Tool |
452
+ |-----------|------|
453
+ | Only playwright-cli available | playwright-cli |
454
+ | Only opencli available (doctor passes) | opencli |
455
+ | Both — local dev server, forms, components | playwright-cli |
456
+ | Both — needs real login state (OAuth/SSO) | opencli |
457
+ | Both — third-party integration verification | opencli |
458
+ | Neither available | Install playwright-cli as default |
459
+
460
+ Then follow the corresponding tool's workflow above (Steps 1-3).
461
+
462
+ {{END_IF_BROWSER_TOOL_AUTO}}
463
+
464
+ **Step 4 — Reporting**:
465
+
466
+ Append results to `context-snapshot.md`:
467
+ ```
468
+ ## Browser Verification
469
+ Tool: <playwright-cli or opencli>
470
+ URL: http://localhost:$DEV_PORT
471
+ Dev Server Command: <actual command used>
472
+ Tool version: <version>
473
+ Steps executed: [list of commands used]
474
+ Screenshot: [path]
475
+ Result: PASS / FAIL (reason)
476
+ Server cleanup: confirmed
477
+ Browser cleanup: confirmed
478
+ ```
479
+
480
+ If verification fails, log the failure details but continue to commit. Failures do NOT block the commit, but you MUST attempt verification and MUST clean up the dev server.
481
+ {{END_IF_BROWSER_INTERACTION}}
482
+
483
+ ### Phase 4: Architecture Sync & Commit (SINGLE COMMIT)
484
+
485
+ **4a.** Run `/prizmkit-retrospective` — maintains `.prizmkit/prizm-docs/` (architecture index):
486
+ 1. **Structural sync**: Use `git diff --cached --name-status` to locate changed modules, update KEY_FILES/INTERFACES/DEPENDENCIES/file counts in affected `.prizmkit/prizm-docs/` files
487
+ 2. **Architecture knowledge** (feature sessions only): Extract TRAPS/RULES/DECISIONS from completed work into `.prizmkit/prizm-docs/`
488
+ 3. **L2 coverage check**: For any module/sub-module with source files created or significantly modified in this session but no L2 `.prizm` doc — evaluate whether L2 is warranted and create if so. The current session has the best context for accurate KEY_FILES, TRAPS, and DECISIONS.
489
+ 4. Stage doc changes: `git add .prizmkit/prizm-docs/`
490
+ ⚠️ Do NOT commit here. Only stage.
491
+
492
+ **4b.** Stage all feature code explicitly (NEVER use `git add -A` or `git add .`):
493
+ ```powershell
494
+ git add <specific-files-created-or-modified>
495
+ git add .prizmkit/prizm-docs/
496
+ ```
497
+
498
+ **4c.** Run `/prizmkit-committer` → THE ONLY commit for this feature:
499
+ `feat({{FEATURE_ID}}): {{FEATURE_TITLE}}`
500
+ This single commit includes: feature code + tests + .prizmkit/prizm-docs/ updates. Do NOT push.
501
+ - MANDATORY: commit must be done via `/prizmkit-committer` skill. Do NOT run manual `git add`/`git commit` as a substitute.
502
+ - Do NOT run `update-feature-status.py` here — the pipeline runner handles feature-list.json updates automatically after session exit.
503
+
504
+ **4d.** Final verification:
505
+ ```powershell
506
+ git status --short
507
+ ```
508
+ Working tree MUST be clean after this step. If any feature-related files remain, stage them into the SAME commit via `git add <file>; if ($LASTEXITCODE -eq 0) { git commit --amend --no-edit }`, do NOT create a separate commit.
509
+
510
+ **Exception**: `session-summary.md` in the artifact directory is a local cross-session artifact generated by `/prizmkit-committer` — it is NOT committed to git. Ignore it in the clean-tree check.
511
+
512
+ **4e.** Write completion summary for downstream dependency context:
513
+
514
+ Write `.prizmkit/specs/{{FEATURE_SLUG}}/completion-summary.json` with the key changes from this session. This file is NOT committed to git — the pipeline runner reads it to propagate context to dependent features.
515
+
516
+ ```json
517
+ {
518
+ "completion_notes": [
519
+ "<each item: one key change, API, model, or integration point that downstream features may need>",
520
+ "Example: Added User model (id, email, password_hash, display_name) in prisma/schema.prisma",
521
+ "Example: POST /api/auth/register and POST /api/auth/login endpoints in src/api/auth.ts",
522
+ "Example: Auth middleware in src/middleware/auth.ts — validates JWT on protected routes"
523
+ ]
524
+ }
525
+ ```
526
+
527
+ Rules for writing completion notes:
528
+ - Focus on **what downstream features need to know**: new APIs, models, exported functions, key file paths
529
+ - Each note should be self-contained and concise (one line, under 120 characters preferred)
530
+ - Include 3-8 notes covering the most important changes
531
+ - Do NOT include test files, config changes, or internal implementation details unless they affect other features
532
+ - If this feature has no downstream dependents, still write the summary (it serves as documentation)
533
+
534
+ ## Critical Paths
535
+
536
+ | Resource | Path |
537
+ |----------|------|
538
+ | Feature Artifacts Dir | `.prizmkit/specs/{{FEATURE_SLUG}}/` |
539
+ | Context Snapshot | `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` |
540
+ | Project Root | {{PROJECT_ROOT}} |
541
+
542
+ ## Failure Capture Protocol
543
+
544
+ If you encounter an unrecoverable error, context overflow, or are about to exit without completing all phases:
545
+
546
+ 1. Write `.prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md` BEFORE exiting:
547
+ ```
548
+ FAILURE_TYPE: timeout | test_failure | review_rejected | context_overflow | unknown
549
+ PHASE: <Get-Command phase failed>
550
+ ROOT_CAUSE: <1-2 sentence explanation>
551
+ ATTEMPTED: <approaches already tried>
552
+ SUGGESTION: <what the next session should try differently>
553
+ DISCOVERED_TRAPS:
554
+ - [CRITICAL|HIGH|LOW] <gotcha discovered during this failed session> | FIX: <approach>
555
+ ```
556
+
557
+ 2. This file is intentionally lightweight — write it BEFORE context runs out.
558
+
559
+ **Lifecycle**: failure-log.md is a temporary cross-session artifact. Do NOT commit it to git. After a successful session (all phases complete + commit done), delete it:
560
+ ```powershell
561
+ Remove-Item -Force -ErrorAction SilentlyContinue .prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md
562
+ ```
563
+
564
+ ## Reminders
565
+
566
+ - Tier 1: you handle everything directly — no subagents needed
567
+ - MANDATORY skills: `/prizmkit-retrospective`, `/prizmkit-committer` — never skip these
568
+ - Build context-snapshot.md FIRST; use it throughout instead of re-reading files
569
+ - `/prizmkit-committer` is mandatory — do NOT skip the commit phase, and do NOT replace it with manual git commit commands
570
+ - Do NOT run `git add`/`git commit` during Phase 1-3 — all changes are committed once in Phase 4
571
+ - If any files remain after the commit, amend the existing commit — do NOT create a follow-up commit
572
+ - When staging files, always use explicit file names — NEVER use `git add -A` or `git add .`