@srobroek/pi-design 0.12.2 → 0.13.0

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 (81) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +51 -14
  3. package/_kit/prereqs.json +2 -2
  4. package/agents/ui-implementer.md +2 -2
  5. package/agents/ui-ux-specialist.md +3 -2
  6. package/extensions/design.js +10 -3
  7. package/formulas/design-surface.formula.toml +2 -2
  8. package/formulas/design-system.formula.toml +2 -2
  9. package/formulas/mol-design-iterate.formula.toml +2 -2
  10. package/package.json +1 -1
  11. package/skills/design-guide/SKILL.md +4 -2
  12. package/skills/design-prototype/SKILL.md +9 -0
  13. package/skills/design-prototype/references/upstream.md +3 -0
  14. package/skills/design-upstream-preflight/SKILL.md +31 -5
  15. package/skills/impeccable/LICENSE +191 -0
  16. package/skills/impeccable/LICENSE-platform-design-skills +21 -0
  17. package/skills/impeccable/NOTICE +87 -0
  18. package/skills/impeccable/REUSE.toml +26 -0
  19. package/skills/impeccable/SKILL.md +95 -0
  20. package/skills/impeccable/reference/adapt.md +318 -0
  21. package/skills/impeccable/reference/adapt.native.md +58 -0
  22. package/skills/impeccable/reference/android.md +46 -0
  23. package/skills/impeccable/reference/animate.md +108 -0
  24. package/skills/impeccable/reference/audit.md +159 -0
  25. package/skills/impeccable/reference/audit.native.md +152 -0
  26. package/skills/impeccable/reference/bolder.md +33 -0
  27. package/skills/impeccable/reference/clarify.md +94 -0
  28. package/skills/impeccable/reference/colorize.md +86 -0
  29. package/skills/impeccable/reference/component-review.md +65 -0
  30. package/skills/impeccable/reference/craft-floor.md +46 -0
  31. package/skills/impeccable/reference/craft.md +5 -0
  32. package/skills/impeccable/reference/critique-rubric.md +496 -0
  33. package/skills/impeccable/reference/critique.md +331 -0
  34. package/skills/impeccable/reference/degraded/asset-producer.md +44 -0
  35. package/skills/impeccable/reference/degraded/documenter.md +24 -0
  36. package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  37. package/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
  38. package/skills/impeccable/reference/degraded/motion-reviewer.md +29 -0
  39. package/skills/impeccable/reference/delight.md +70 -0
  40. package/skills/impeccable/reference/distill.md +111 -0
  41. package/skills/impeccable/reference/doctor.md +60 -0
  42. package/skills/impeccable/reference/document.md +418 -0
  43. package/skills/impeccable/reference/extract.md +69 -0
  44. package/skills/impeccable/reference/foundations.md +46 -0
  45. package/skills/impeccable/reference/generate.md +103 -0
  46. package/skills/impeccable/reference/harden.md +362 -0
  47. package/skills/impeccable/reference/hooks.md +33 -0
  48. package/skills/impeccable/reference/init.md +133 -0
  49. package/skills/impeccable/reference/ios.md +51 -0
  50. package/skills/impeccable/reference/layout.md +86 -0
  51. package/skills/impeccable/reference/live-setup.md +106 -0
  52. package/skills/impeccable/reference/live.md +345 -0
  53. package/skills/impeccable/reference/mode-operate.md +21 -0
  54. package/skills/impeccable/reference/mode-persuade.md +19 -0
  55. package/skills/impeccable/reference/mode-read.md +21 -0
  56. package/skills/impeccable/reference/new-work-comp.md +26 -0
  57. package/skills/impeccable/reference/new-work-world.md +22 -0
  58. package/skills/impeccable/reference/new-work.md +125 -0
  59. package/skills/impeccable/reference/onboard.md +235 -0
  60. package/skills/impeccable/reference/operate.md +61 -0
  61. package/skills/impeccable/reference/optimize.md +257 -0
  62. package/skills/impeccable/reference/overdrive.md +127 -0
  63. package/skills/impeccable/reference/polish.md +107 -0
  64. package/skills/impeccable/reference/quieter.md +99 -0
  65. package/skills/impeccable/reference/region-map.md +28 -0
  66. package/skills/impeccable/reference/routing.md +26 -0
  67. package/skills/impeccable/reference/shape.md +59 -0
  68. package/skills/impeccable/reference/typeset.md +98 -0
  69. package/skills/impeccable/reference/visualize.md +49 -0
  70. package/skills/impeccable/scripts/VERSION +1 -0
  71. package/skills/impeccable/scripts/command-metadata.json +98 -0
  72. package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  73. package/skills/impeccable/scripts/data/font-index.json +1 -0
  74. package/skills/impeccable/scripts/engine-checksums.txt +9 -0
  75. package/skills/impeccable/scripts/impeccable +349 -0
  76. package/skills/impeccable/scripts/impeccable.cmd +371 -0
  77. package/skills/impeccable/scripts/live-browser-dom.js +320 -0
  78. package/skills/impeccable/scripts/live-browser-ignores.js +246 -0
  79. package/skills/impeccable/scripts/live-browser-session.js +183 -0
  80. package/skills/impeccable/scripts/live-browser.js +13925 -0
  81. package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
@@ -0,0 +1,371 @@
1
+ @echo off
2
+ setlocal
3
+ rem Impeccable launcher (Windows). Runs bin\windows-<arch>\impeccable.exe next
4
+ rem to this file, else a cached or freshly downloaded engine binary.
5
+ rem
6
+ rem Structure notes (this file is exercised by dry parsing and string-level
7
+ rem tests, not yet on a real Windows machine):
8
+ rem - No multi-line parenthesized blocks: cmd expands %var% at block parse
9
+ rem time, which made the old download path read back empty %url%/%cached%.
10
+ rem Linear goto flow keeps every expansion on its own line, and avoids
11
+ rem delayed expansion eating ! characters in user arguments.
12
+ rem - The unversioned user binary and the PATH candidate are validated with
13
+ rem the engine-probe handshake (see :probe) so the retired 3.x npm CLI,
14
+ rem whose bin is also named impeccable, is never exec'd. The sibling binary
15
+ rem must also report the version in VERSION: it is not tracked, so a skill
16
+ rem upgrade can leave an old engine in place. IMPECCABLE_BIN stays trusted.
17
+ rem - Downloads and the version-pinned cache are verified via certutil
18
+ rem against engine-checksums.txt next to this file, and fail closed; a
19
+ rem .verified stamp lets later runs skip hashing the cache while it holds
20
+ rem the manifest digest and the binary's size and is not older than the
21
+ rem binary. On ARM64 the arm64 asset is tried first and the x64 asset is the
22
+ rem fallback (Windows on ARM runs x64 binaries), each only when the manifest
23
+ rem has a line for it.
24
+ if not defined IMPECCABLE_SKILL_DIR set "IMPECCABLE_SKILL_DIR=%~dp0.."
25
+ if not defined IMPECCABLE_SELF set "IMPECCABLE_SELF=%~f0"
26
+ set "arch=x64"
27
+ if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "arch=arm64"
28
+
29
+ if not defined IMPECCABLE_BIN goto no_env_bin
30
+ if not exist "%IMPECCABLE_BIN%" goto no_env_bin
31
+ set "run=%IMPECCABLE_BIN%"
32
+ goto run
33
+ :no_env_bin
34
+
35
+ set "version="
36
+ if exist "%~dp0VERSION" set /p version=<"%~dp0VERSION"
37
+ set "bin=%~dp0bin\windows-%arch%\impeccable.exe"
38
+ if not exist "%bin%" goto no_sibling
39
+ if defined IMPECCABLE_LAUNCHER_PROBE goto sibling_ok
40
+ if not defined version goto sibling_ok
41
+ call :probe "%bin%"
42
+ if "%probe_version%"=="%version%" goto sibling_ok
43
+ if not defined probe_version set "probe_version=unknown"
44
+ echo impeccable: skipping "%bin%": it reports engine %probe_version% but this skill pins %version%; delete it to stop this warning 1>&2
45
+ goto no_sibling
46
+ :sibling_ok
47
+ set "run=%bin%"
48
+ goto run
49
+ :no_sibling
50
+
51
+ set "home_bin=%USERPROFILE%\.impeccable\bin\impeccable.exe"
52
+ if not exist "%home_bin%" goto no_home_bin
53
+ if defined IMPECCABLE_LAUNCHER_PROBE goto no_home_bin
54
+ call :probe "%home_bin%"
55
+ if not "%probe_ok%"=="1" goto no_home_bin
56
+ set "run=%home_bin%"
57
+ goto run
58
+ :no_home_bin
59
+
60
+ if not defined IMPECCABLE_HOME set "IMPECCABLE_HOME=%USERPROFILE%\.impeccable"
61
+ set "cached=%IMPECCABLE_HOME%\bin\%version%\impeccable.exe"
62
+ set "asset=impeccable-windows-%arch%.exe"
63
+ set "manifest=%~dp0engine-checksums.txt"
64
+ if not defined version goto no_cache
65
+ if not exist "%cached%" goto no_cache
66
+ call :read_expected
67
+ for %%f in ("%cached%") do set "size=%%~zf"
68
+ set "stamp="
69
+ if exist "%cached%.verified" for /f "usebackq tokens=1,2" %%s in ("%cached%.verified") do set "stamp=%%s"& set "stamp_size=%%t"
70
+ if not defined stamp goto cache_hash
71
+ if not "%stamp_size%"=="%size%" goto cache_hash
72
+ if /I "%stamp%"=="%expected%" goto cache_stamp_matches
73
+ if /I "%stamp%"=="%expected_x64%" goto cache_stamp_matches
74
+ goto cache_hash
75
+ :cache_stamp_matches
76
+ rem Newest first: the stamp must be listed before the binary it vouches for.
77
+ set "newest="
78
+ for /f "delims=" %%f in ('dir /b /a:-d /o:-d "%cached%*" 2^>nul') do if not defined newest set "newest=%%f"
79
+ if /I "%newest%"=="impeccable.exe.verified" goto cache_trusted
80
+ :cache_hash
81
+ call :sha256 "%cached%" "%TEMP%\impeccable-hash-%RANDOM%%RANDOM%.txt"
82
+ if not defined actual goto cache_unverified
83
+ if /I "%actual%"=="%expected%" goto cache_verified
84
+ if /I "%actual%"=="%expected_x64%" goto cache_verified
85
+ :cache_unverified
86
+ echo impeccable: cannot verify the cached engine "%cached%" against "%manifest%"; not using it 1>&2
87
+ goto no_cache
88
+ :cache_verified
89
+ (>"%cached%.verified" echo %actual% %size%) 2>nul
90
+ :cache_trusted
91
+ set "run=%cached%"
92
+ goto run
93
+ :no_cache
94
+
95
+ if defined IMPECCABLE_LAUNCHER_PROBE goto download
96
+ rem The first impeccable on PATH, resolved once so the probe and the run see
97
+ rem the same file. A batch shim (npm writes impeccable.cmd) must run under
98
+ rem call to return here (#1240), and call expands % in the arguments a second
99
+ rem time; a real binary runs directly so a target such as a%20b reaches it intact.
100
+ set "path_bin="
101
+ rem where also lists npm's extensionless POSIX shim, which cmd cannot run:
102
+ rem take the first match with a runnable extension.
103
+ rem Loop letters c and k are not path modifiers, so %%~xc reads as the
104
+ rem extension of c and never as a loop variable followed by text.
105
+ for /f "delims=" %%c in ('where impeccable 2^>nul') do if not defined path_bin for %%k in (.exe .com .cmd .bat) do if /I "%%~xc"=="%%k" set "path_bin=%%c"
106
+ if not defined path_bin goto download
107
+ call :probe "%path_bin%"
108
+ if not "%probe_ok%"=="1" goto download
109
+ for %%k in ("%path_bin%") do set "path_ext=%%~xk"
110
+ if /I "%path_ext%"==".cmd" goto path_shim
111
+ if /I "%path_ext%"==".bat" goto path_shim
112
+ "%path_bin%" %*
113
+ exit /b %errorlevel%
114
+ :path_shim
115
+ call "%path_bin%" %*
116
+ exit /b %errorlevel%
117
+
118
+ :download_refused
119
+ rem Modified by the harness-plugins design plugin (see ..\NOTICE): the engine is
120
+ rem downloaded only after the user agreed to it, signalled by IMPECCABLE_ALLOW_DOWNLOAD=1.
121
+ echo impeccable: no engine found: no impeccable on PATH and none in the version cache. 1>&2
122
+ echo Install the CLI with "mise use -g npm:impeccable", or ask the user before downloading engine %version% from the github.com/pbakaus/impeccable releases; once they agree, rerun with IMPECCABLE_ALLOW_DOWNLOAD=1. 1>&2
123
+ exit /b 127
124
+
125
+ :download
126
+ rem Last resort: fetch this version's binary from the release channel into
127
+ rem the version-pinned user cache, verify it, then run it. Never inside
128
+ rem another launcher's probe: fail fast and quiet instead.
129
+ if defined IMPECCABLE_LAUNCHER_PROBE exit /b 127
130
+ if not "%IMPECCABLE_ALLOW_DOWNLOAD%"=="1" goto download_refused
131
+ if not defined version goto fail
132
+ call :read_expected
133
+ if not defined expected if not defined expected_x64 goto no_checksum
134
+ where curl.exe >nul 2>nul
135
+ if errorlevel 1 goto curl_missing
136
+ if not defined IMPECCABLE_DOWNLOAD_BASE set "IMPECCABLE_DOWNLOAD_BASE=https://github.com/pbakaus/impeccable/releases/download"
137
+ if exist "%IMPECCABLE_HOME%\bin\%version%\" goto cache_ready
138
+ mkdir "%IMPECCABLE_HOME%\bin\%version%" >nul 2>nul
139
+ if errorlevel 1 goto cache_directory_failed
140
+ :cache_ready
141
+ rem Remove staging directories killed runs left in any version's cache, once
142
+ rem two days idle (forfiles /d counts days; a live curl's open file stays).
143
+ forfiles /p "%IMPECCABLE_HOME%\bin" /s /m .impeccable.part.* /d -2 /c "cmd /c if @isdir==TRUE rd /s /q @path" >nul 2>nul
144
+ rem Stage the download in a directory only this run owns, as the sh launcher
145
+ rem does with .impeccable.part.$$: concurrent first runs (parallel hooks, two
146
+ rem agents) must never write, hash or move each other's files. mkdir fails
147
+ rem when the name exists, so it claims the name atomically. RANDOM alone is
148
+ rem not enough because cmd seeds it from the clock in whole seconds; the
149
+ rem timestamp and the retry on collision keep same-second runs apart. A cache
150
+ rem directory that refuses every mkdir is reported as unwritable.
151
+ set "attempt=0"
152
+ :claim_staging
153
+ set /a attempt+=1
154
+ if %attempt% GTR 20 goto cache_write_failed
155
+ set "stamp=%TIME: =0%"
156
+ set "stamp=%stamp::=%"
157
+ set "stamp=%stamp:.=%"
158
+ set "stamp=%stamp:,=%"
159
+ set "staging=%IMPECCABLE_HOME%\bin\%version%\.impeccable.part.%stamp%-%RANDOM%%RANDOM%"
160
+ mkdir "%staging%" >nul 2>nul
161
+ if errorlevel 1 goto claim_staging
162
+ set "part=%staging%\impeccable.exe"
163
+ rem Redirection failures do not reliably update ERRORLEVEL in cmd.exe;
164
+ rem branch on the command's failure directly.
165
+ (type nul >"%part%") 2>nul || goto staging_write_failed
166
+ set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%"
167
+ if not defined expected goto fetch_x64
168
+ call :fetch_url
169
+ if not errorlevel 1 goto verify
170
+ :fetch_x64
171
+ if not defined expected_x64 goto download_failed
172
+ set "asset=impeccable-windows-x64.exe"
173
+ set "expected=%expected_x64%"
174
+ set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%"
175
+ call :fetch_url
176
+ if errorlevel 1 goto download_failed
177
+
178
+ :verify
179
+ call :check_download
180
+ if errorlevel 1 exit /b 127
181
+ rem Mirrors the sh launcher and fails closed: a freshly downloaded binary
182
+ rem runs only after its hash matches the digest read from engine-checksums.txt.
183
+ rem An empty certutil result refuses the download instead of running an
184
+ rem unverified binary.
185
+ call :sha256 "%part%" "%staging%\hash.txt"
186
+ call :check_download
187
+ if errorlevel 1 exit /b 127
188
+ if not defined actual goto verify_refuse
189
+ if /I "%actual%"=="%expected%" goto place
190
+ call :discard_staging
191
+ echo impeccable: checksum mismatch downloading %url% 1>&2
192
+ exit /b 127
193
+
194
+ :verify_refuse
195
+ call :check_download
196
+ if errorlevel 1 exit /b 127
197
+ call :discard_staging
198
+ echo impeccable: cannot verify %url% (certutil could not hash it); refusing the unverified download 1>&2
199
+ exit /b 127
200
+
201
+ :fetch_url
202
+ set "http_status="
203
+ set "effective_url="
204
+ set "download_host="
205
+ set "curl_error="
206
+ curl.exe -fsSL --retry 2 -w "%%{http_code} %%{url_effective} %%{errormsg}" -o "%part%" "%url%" >"%staging%\http.txt" 2>nul
207
+ set "fetch_result=%errorlevel%"
208
+ for /f "usebackq tokens=1" %%a in ("%staging%\http.txt") do set "http_status=%%a"
209
+ for /f "usebackq tokens=2" %%a in ("%staging%\http.txt") do set "effective_url=%%a"
210
+ for /f "usebackq tokens=2,*" %%a in ("%staging%\http.txt") do set "curl_error=%%b"
211
+ rem Token 2 is the authority after scheme://. Drop userinfo and the port.
212
+ for /f "tokens=2 delims=/" %%h in ("%effective_url%") do set "download_host=%%h"
213
+ for /f "tokens=1,* delims=@" %%h in ("%download_host%") do if not "%%i"=="" set "download_host=%%i"
214
+ rem Bracketed IPv6 hosts contain colons that are not port separators.
215
+ if "%download_host:~0,1%"=="[" goto fetch_ipv6
216
+ for /f "tokens=1 delims=:" %%h in ("%download_host%") do set "download_host=%%h"
217
+ exit /b %fetch_result%
218
+ :fetch_ipv6
219
+ for /f "tokens=1 delims=]" %%h in ("%download_host%") do set "download_host=%%h]"
220
+ exit /b %fetch_result%
221
+
222
+ :read_expected
223
+ rem Sets expected (and, on ARM64, expected_x64: Windows on ARM runs x64
224
+ rem binaries) from engine-checksums.txt.
225
+ call :manifest_digest "%asset%" expected
226
+ set "expected_x64="
227
+ if "%arch%"=="arm64" call :manifest_digest impeccable-windows-x64.exe expected_x64
228
+ exit /b 0
229
+
230
+ :manifest_digest
231
+ rem Sets the variable named %2 to the digest the first engine-checksums.txt
232
+ rem line for this version and asset %1 records, empty when there is none.
233
+ set "%~2="
234
+ if not exist "%manifest%" exit /b 0
235
+ for /f "usebackq tokens=1-3" %%a in ("%manifest%") do if "%%a"=="%version%" if /I "%%b"=="%~1" if not defined %~2 set "%~2=%%c"
236
+ exit /b 0
237
+
238
+ :sha256
239
+ rem Sets actual to the sha256 of %~1, empty when certutil fails. %~2 is the
240
+ rem scratch file for its output. Check certutil's status before parsing: its
241
+ rem error text on stdout is not a digest.
242
+ set "actual="
243
+ certutil -hashfile "%~1" SHA256 >"%~2" 2>nul
244
+ if errorlevel 1 goto sha256_done
245
+ for /f "usebackq skip=1 delims=" %%h in ("%~2") do if not defined actual set "actual=%%h"
246
+ if not defined actual goto sha256_done
247
+ set "actual=%actual: =%"
248
+ :sha256_done
249
+ del "%~2" >nul 2>nul
250
+ exit /b 0
251
+
252
+ :check_download
253
+ set "download_file=%~1"
254
+ if not defined download_file set "download_file=%part%"
255
+ if not exist "%download_file%" goto download_missing
256
+ for %%f in ("%download_file%") do if %%~zf==0 goto download_empty
257
+ exit /b 0
258
+
259
+ :download_missing
260
+ call :discard_staging
261
+ echo impeccable: download completed but the file was removed before execution: %url%; check your antivirus quarantine or logs. Refusing to continue; do not disable protection. 1>&2
262
+ exit /b 127
263
+
264
+ :download_empty
265
+ del "%download_file%" >nul 2>nul
266
+ call :discard_staging
267
+ echo impeccable: downloaded file is empty: %url%; refusing the unverified download 1>&2
268
+ exit /b 127
269
+
270
+ :discard_staging
271
+ rem Removes this run's staging directory and whatever is left in it. Never
272
+ rem touches another run's staging directory or the cached binary.
273
+ if defined staging rd /s /q "%staging%" >nul 2>nul
274
+ exit /b 0
275
+
276
+ :place
277
+ call :check_download
278
+ if errorlevel 1 exit /b 127
279
+ move /y "%part%" "%cached%" >nul 2>nul
280
+ if errorlevel 1 goto place_failed
281
+ call :discard_staging
282
+ call :check_download "%cached%"
283
+ if errorlevel 1 exit /b 127
284
+ for %%f in ("%cached%") do set "size=%%~zf"
285
+ (>"%cached%.verified" echo %actual% %size%) 2>nul
286
+ set "run=%cached%"
287
+ goto run
288
+
289
+ :place_failed
290
+ call :check_download
291
+ if errorlevel 1 exit /b 127
292
+ call :discard_staging
293
+ echo impeccable: could not cache the verified download: %url% 1>&2
294
+ exit /b 127
295
+
296
+ :run
297
+ "%run%" %*
298
+ exit /b %errorlevel%
299
+
300
+ :probe
301
+ rem Sets probe_ok=1 when %1 answers the engine handshake: prints
302
+ rem "impeccable-engine <version>" and exits 0, and probe_version to that
303
+ rem version. The 3.x npm CLI answers any unknown verb with "Unknown command",
304
+ rem exit 1, so it never passes.
305
+ rem The candidate runs under call: an npm .cmd shim run without it takes
306
+ rem over this script and never returns (#1240).
307
+ set "probe_ok="
308
+ set "probe_version="
309
+ set "probe_tmp=%TEMP%\impeccable-probe-%RANDOM%%RANDOM%.txt"
310
+ set "IMPECCABLE_LAUNCHER_PROBE=1"
311
+ call "%~1" engine-probe >"%probe_tmp%" 2>nul
312
+ set "probe_err=%ERRORLEVEL%"
313
+ set "IMPECCABLE_LAUNCHER_PROBE="
314
+ if not "%probe_err%"=="0" goto probe_done
315
+ findstr /b /c:"impeccable-engine" "%probe_tmp%" >nul 2>nul
316
+ if errorlevel 1 goto probe_done
317
+ set "probe_ok=1"
318
+ for /f "usebackq tokens=2" %%v in ("%probe_tmp%") do if not defined probe_version set "probe_version=%%v"
319
+ :probe_done
320
+ del "%probe_tmp%" >nul 2>nul
321
+ exit /b 0
322
+
323
+ :no_checksum
324
+ echo impeccable: no checksum for engine %version% (%asset%) in "%manifest%"; refusing the unverified download 1>&2
325
+ exit /b 127
326
+
327
+ :cache_directory_failed
328
+ echo impeccable: engine %version% is not installed; cannot create cache directory: "%IMPECCABLE_HOME%\bin\%version%" 1>&2
329
+ goto setup_failed
330
+
331
+ :staging_write_failed
332
+ call :discard_staging
333
+
334
+ :cache_write_failed
335
+ echo impeccable: engine %version% is not installed; cannot write to cache directory: "%IMPECCABLE_HOME%\bin\%version%" 1>&2
336
+ goto setup_failed
337
+
338
+ :curl_missing
339
+ echo impeccable: cannot download engine %version%; curl.exe is unavailable. 1>&2
340
+ goto setup_failed
341
+
342
+ :download_failed
343
+ call :discard_staging
344
+ if not "%http_status:~0,1%"=="5" goto download_generic
345
+ if "%http_status:~2,1%"=="" goto download_generic
346
+ if /I "%download_host%"=="github.com" goto download_github
347
+ if /I "%download_host:~-11%"==".github.com" goto download_github
348
+ if /I "%download_host%"=="githubusercontent.com" goto download_github
349
+ if /I "%download_host:~-22%"==".githubusercontent.com" goto download_github
350
+ echo impeccable: could not download engine %version%: %download_host% is failing right now (HTTP %http_status%), a server error on %download_host%'s side. Try again later. 1>&2
351
+ exit /b 127
352
+ :download_github
353
+ echo impeccable: could not download engine %version%: GitHub's downloads are failing right now (HTTP %http_status% from %download_host%). This is an outage on GitHub's side, not a problem with your setup or the CLI, so updating won't help. Check https://www.githubstatus.com and run the same command again once GitHub has recovered. 1>&2
354
+ exit /b 127
355
+ :download_generic
356
+ rem Delayed expansion keeps cmd metacharacters in curl's message literal.
357
+ setlocal EnableDelayedExpansion
358
+ if defined curl_error set "curl_error=: !curl_error!"
359
+ echo impeccable: could not download engine %version% from !url! (curl exit %fetch_result%!curl_error!); check network access and the release URL. 1>&2
360
+ endlocal
361
+
362
+ :setup_failed
363
+ echo Engine %version% setup needs network access and write permission to "%IMPECCABLE_HOME%\bin\%version%". 1>&2
364
+ echo Run this launcher ("%~f0") with engine-probe in a terminal that has those permissions, then retry the original command. 1>&2
365
+ echo Alternatively, set IMPECCABLE_HOME to a writable cache location, or IMPECCABLE_BIN to a preinstalled engine binary. 1>&2
366
+ exit /b 127
367
+
368
+ :fail
369
+ echo impeccable: no engine binary found (looked in %bin%, %cached%, PATH). 1>&2
370
+ echo Download impeccable-windows-%arch%.exe from https://github.com/pbakaus/impeccable/releases (tag engine-v%version%) and save it as %cached%, or set IMPECCABLE_BIN to a preinstalled engine binary. Docs: https://impeccable.style 1>&2
371
+ exit /b 127
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Browser-side DOM helpers for Impeccable live mode.
3
+ *
4
+ * Kept separate from live-browser.js so future browser script parts can share
5
+ * chrome mounting, lookup, focus, and picker helpers without depending on the
6
+ * full overlay UI bundle.
7
+ */
8
+ (function (root) {
9
+ 'use strict';
10
+ if (!root) return;
11
+
12
+ function createLiveBrowserDomHelpers({
13
+ prefix,
14
+ skipTags,
15
+ document: doc = root.document,
16
+ css = root.CSS,
17
+ crypto = root.crypto,
18
+ } = {}) {
19
+ if (!prefix) throw new Error('prefix required');
20
+ if (!doc) throw new Error('document required');
21
+ const tagsToSkip = skipTags || new Set();
22
+
23
+ function own(el) {
24
+ return el && (el.id?.startsWith(prefix) || el.closest?.('[id^="' + prefix + '"]'));
25
+ }
26
+
27
+ function pickable(el) {
28
+ if (!el || el.nodeType !== 1) return false;
29
+ if (tagsToSkip.has(String(el.tagName || '').toLowerCase())) return false;
30
+ if (own(el)) return false;
31
+ const r = el.getBoundingClientRect();
32
+ return r.width >= 20 && r.height >= 20;
33
+ }
34
+
35
+ function desc(el) {
36
+ if (!el) return '';
37
+ let s = el.tagName.toLowerCase();
38
+ if (el.id) s += '#' + el.id;
39
+ else if (el.classList.length) s += '.' + [...el.classList].slice(0, 2).join('.');
40
+ return s;
41
+ }
42
+
43
+ function rectIsUsableAnchor(rect) {
44
+ return !!rect && rect.width > 0.5 && rect.height > 0.5;
45
+ }
46
+
47
+ function makeFrozenAnchor(el) {
48
+ if (!el || !el.getBoundingClientRect) return null;
49
+ const r = el.getBoundingClientRect();
50
+ if (!rectIsUsableAnchor(r)) return null;
51
+ const rect = {
52
+ x: r.x, y: r.y,
53
+ top: r.top, left: r.left,
54
+ right: r.right, bottom: r.bottom,
55
+ width: r.width, height: r.height,
56
+ };
57
+ return {
58
+ __impeccableFrozenAnchor: true,
59
+ tagName: el.tagName || 'DIV',
60
+ id: el.id || '',
61
+ classList: el.classList ? [...el.classList] : [],
62
+ hasAttribute: () => false,
63
+ getBoundingClientRect: () => rect,
64
+ };
65
+ }
66
+
67
+ function hasFrameworkHmrOwnership(el) {
68
+ for (let node = el; node; node = node.parentElement) {
69
+ let keys = [];
70
+ try { keys = Object.getOwnPropertyNames(node); } catch {}
71
+ if (keys.some((key) => (
72
+ key.startsWith('__reactFiber$')
73
+ || key.startsWith('__reactProps$')
74
+ || key.startsWith('__reactContainer$')
75
+ || key === '_reactRootContainer'
76
+ || key === '__vueParentComponent'
77
+ || key === '__vue_app__'
78
+ || key === '__vnode'
79
+ || key === '__svelte_meta'
80
+ ))) {
81
+ return true;
82
+ }
83
+ }
84
+ return false;
85
+ }
86
+
87
+ function id8() {
88
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
89
+ try {
90
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
91
+ } catch { /* fall through */ }
92
+ try {
93
+ if (typeof crypto?.getRandomValues === 'function') {
94
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
95
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
96
+ }
97
+ } catch { /* fall through */ }
98
+ return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
99
+ }
100
+
101
+ function cssId(id) {
102
+ if (css?.escape) return css.escape(id);
103
+ return String(id).replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, '\\$1');
104
+ }
105
+
106
+ function liveUiRoot() {
107
+ const uiRoot = root.__IMPECCABLE_LIVE_UI_ROOT__;
108
+ if (uiRoot && typeof uiRoot.appendChild === 'function') return uiRoot;
109
+ return doc.body;
110
+ }
111
+
112
+ // A modal <dialog> (showModal) paints in the top layer and makes every
113
+ // node outside its subtree inert, so chrome on <body> can be neither seen
114
+ // nor clicked while one is open, and no z-index reaches it (issue #879).
115
+ // While a modal is open the chrome parks inside the topmost one, in one
116
+ // popover: inside the dialog it is not inert, and a popover shown after
117
+ // the dialog paints above it. One popover for all of it, because
118
+ // top-layer entries stack by show order, which would drop the z-index
119
+ // order between the roots. The detect overlay (browser-bundle/
120
+ // 40-overlay.js) mounts its outlines here too: it finds the host by this
121
+ // id and places its outlines again on the event of the same name, fired
122
+ // on every move.
123
+ const topLayerHost = doc.createElement('div');
124
+ topLayerHost.id = prefix + '-top-layer';
125
+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.
126
+ // `all: initial` also clears the popover UA box.
127
+ for (const [name, value] of Object.entries({
128
+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',
129
+ })) topLayerHost.style.setProperty(name, value, 'important');
130
+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself
131
+ const openModals = []; // in the order they opened; last is topmost
132
+
133
+ // Modals that were open before watching began have no readable top-layer
134
+ // order, but the topmost one's backdrop covers the viewport, so a hit
135
+ // test lands in it. Raise that one to the top of the stack.
136
+ function raiseHitModal() {
137
+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));
138
+ if (i !== -1) openModals.push(...openModals.splice(i, 1));
139
+ }
140
+
141
+ function syncTopLayerHost(records = []) {
142
+ for (const { type, target, oldValue } of records) {
143
+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;
144
+ // Opened, or closed and reopened in one task (the observer sees only
145
+ // the end state): either way it is back on top of the top layer, so
146
+ // a host shown inside it earlier has to be shown again. A write to an
147
+ // `open` that was already set (oldValue not null) moved nothing.
148
+ const i = openModals.indexOf(target);
149
+ if (i !== -1) openModals.splice(i, 1);
150
+ openModals.push(target);
151
+ if (topLayerHost.parentNode === target) topLayerHost.remove();
152
+ }
153
+ // A closed dialog, or one removed from the document while open, stops
154
+ // matching :modal. Whichever is now on top may predate the watch.
155
+ const before = openModals.length;
156
+ for (let i = openModals.length - 1; i >= 0; i--) {
157
+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);
158
+ }
159
+ if (openModals.length < before && openModals.length > 1) raiseHitModal();
160
+ const modal = openModals[openModals.length - 1] || null;
161
+ if (topLayerHost.parentNode === modal) return;
162
+ if (modal) {
163
+ modal.appendChild(topLayerHost);
164
+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);
165
+ topLayerHost.showPopover();
166
+ } else {
167
+ doc.body.append(...topLayerHost.childNodes);
168
+ topLayerHost.remove();
169
+ }
170
+ doc.dispatchEvent(new Event(topLayerHost.id));
171
+ }
172
+
173
+ // Returns the function that stops watching and puts the chrome back.
174
+ function watchModalDialogs() {
175
+ if (typeof topLayerHost.showPopover !== 'function') return () => {};
176
+ topLayerHost.popover = 'manual';
177
+ // Parked in the page's dialog, chrome clicks would bubble into its own
178
+ // handlers, such as a click-outside-the-box close. Live listens in capture.
179
+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());
180
+ openModals.push(...doc.querySelectorAll('dialog:modal'));
181
+ raiseHitModal();
182
+ const observer = new MutationObserver(syncTopLayerHost);
183
+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });
184
+ syncTopLayerHost();
185
+ return () => {
186
+ observer.disconnect();
187
+ openModals.length = 0;
188
+ syncTopLayerHost();
189
+ };
190
+ }
191
+
192
+ // A copy of a page element without the chrome parked inside it, which a
193
+ // picked modal dialog contains.
194
+ function cloneWithoutChrome(el) {
195
+ const clone = el.cloneNode(true);
196
+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();
197
+ return clone;
198
+ }
199
+
200
+ // Mount a chrome node on the page itself: <body>, or the top-layer host
201
+ // while the chrome is parked in a modal.
202
+ function uiAppendToPage(el) {
203
+ pageRoots.add(el);
204
+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);
205
+ return el;
206
+ }
207
+
208
+ // Copy text through a selected textarea and execCommand, for origins where
209
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
210
+ // The textarea mounts like any page-level chrome, so while a modal
211
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
212
+ // would be inert, and inert text cannot be selected or copied.
213
+ function copyTextViaSelection(text) {
214
+ let ta = null;
215
+ const previous = activeElementDeep();
216
+ try {
217
+ ta = doc.createElement('textarea');
218
+ ta.id = prefix + '-clipboard';
219
+ ta.value = text;
220
+ ta.setAttribute('readonly', '');
221
+ ta.setAttribute('aria-hidden', 'true');
222
+ ta.tabIndex = -1;
223
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
224
+ uiAppendToPage(ta);
225
+ ta.select();
226
+ return doc.execCommand('copy');
227
+ } catch {
228
+ return false;
229
+ } finally {
230
+ ta?.remove();
231
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
232
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
233
+ }
234
+ }
235
+ }
236
+
237
+ function uiAppend(el) {
238
+ const uiRoot = liveUiRoot();
239
+ if (uiRoot === doc.body) return uiAppendToPage(el);
240
+ // An adapter shadow root: its host is the node that sits on the page.
241
+ if (uiRoot.host) pageRoots.add(uiRoot.host);
242
+ uiRoot.appendChild(el);
243
+ return el;
244
+ }
245
+
246
+ function uiAppendStyle(styleEl) {
247
+ const uiRoot = liveUiRoot();
248
+ if (uiRoot && uiRoot !== doc.body) uiRoot.appendChild(styleEl);
249
+ else doc.head.appendChild(styleEl);
250
+ return styleEl;
251
+ }
252
+
253
+ function uiGetById(id) {
254
+ const uiRoot = liveUiRoot();
255
+ if (uiRoot?.getElementById) {
256
+ const found = uiRoot.getElementById(id);
257
+ if (found) return found;
258
+ }
259
+ if (uiRoot?.querySelector) {
260
+ const found = uiRoot.querySelector('#' + cssId(id));
261
+ if (found) return found;
262
+ }
263
+ return doc.getElementById(id);
264
+ }
265
+
266
+ function activeElementDeep() {
267
+ let active = doc.activeElement;
268
+ while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
269
+ return active;
270
+ }
271
+
272
+ function defangOutsideHandlers(rootEl, { setPointerEvents = true } = {}) {
273
+ if (!rootEl) return;
274
+ if (setPointerEvents) {
275
+ rootEl.style.setProperty('pointer-events', 'auto', 'important');
276
+ }
277
+ const stop = (e) => e.stopPropagation();
278
+ rootEl.addEventListener('pointerdown', stop);
279
+ rootEl.addEventListener('mousedown', stop);
280
+ rootEl.addEventListener('focusin', stop);
281
+ }
282
+
283
+ // The half of the defang that cannot sit on the chrome: a focus trap (Radix /
284
+ // Reka FocusScope) also hears the page's own focusout as focus leaves its
285
+ // modal for our chrome, and pulls it back. Register on the document in
286
+ // capture, ahead of the trap. The page's own focusout handlers miss that
287
+ // one transition too; blur still fires.
288
+ function stopFocusOutIntoChrome(e) {
289
+ if (own(e.relatedTarget)) e.stopPropagation();
290
+ }
291
+
292
+ return {
293
+ own,
294
+ pickable,
295
+ desc,
296
+ rectIsUsableAnchor,
297
+ makeFrozenAnchor,
298
+ hasFrameworkHmrOwnership,
299
+ id8,
300
+ cssId,
301
+ liveUiRoot,
302
+ uiAppend,
303
+ uiAppendToPage,
304
+ copyTextViaSelection,
305
+ topLayerHost,
306
+ watchModalDialogs,
307
+ cloneWithoutChrome,
308
+ uiAppendStyle,
309
+ uiGetById,
310
+ activeElementDeep,
311
+ defangOutsideHandlers,
312
+ stopFocusOutIntoChrome,
313
+ };
314
+ }
315
+
316
+ root.__IMPECCABLE_LIVE_DOM__ = {
317
+ version: 1,
318
+ createLiveBrowserDomHelpers,
319
+ };
320
+ })(typeof window !== 'undefined' ? window : globalThis);