gentle-pi 4.7.0 → 4.9.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 (617) hide show
  1. package/README.md +115 -44
  2. package/assets/agents/gentle-ai-explore.md +3 -3
  3. package/assets/agents/gentle-ai-verify.md +20 -6
  4. package/assets/agents/gentle-ai-worker.md +14 -13
  5. package/assets/agents/jd-judge-a.md +1 -3
  6. package/assets/agents/jd-judge-b.md +1 -3
  7. package/assets/agents/review-readability.md +1 -5
  8. package/assets/agents/review-reliability.md +1 -5
  9. package/assets/agents/review-resilience.md +1 -5
  10. package/assets/agents/review-risk.md +1 -5
  11. package/assets/design-canvas/canvas-api.js +45 -0
  12. package/assets/design-canvas/canvas-boards.js +476 -0
  13. package/assets/design-canvas/canvas-boot.js +219 -0
  14. package/assets/design-canvas/canvas-checks.js +491 -0
  15. package/assets/design-canvas/canvas-comments.js +315 -0
  16. package/assets/design-canvas/canvas-compare.js +159 -0
  17. package/assets/design-canvas/canvas-events.js +75 -0
  18. package/assets/design-canvas/canvas-export.js +393 -0
  19. package/assets/design-canvas/canvas-focus.js +203 -0
  20. package/assets/design-canvas/canvas-handoffs.js +150 -0
  21. package/assets/design-canvas/canvas-i18n-es.js +397 -0
  22. package/assets/design-canvas/canvas-i18n.js +108 -0
  23. package/assets/design-canvas/canvas-layout.js +526 -0
  24. package/assets/design-canvas/canvas-menu.js +219 -0
  25. package/assets/design-canvas/canvas-messages.js +86 -0
  26. package/assets/design-canvas/canvas-minimap.js +163 -0
  27. package/assets/design-canvas/canvas-parts.js +401 -0
  28. package/assets/design-canvas/canvas-popover.js +234 -0
  29. package/assets/design-canvas/canvas-rail.js +351 -0
  30. package/assets/design-canvas/canvas-sizes.js +524 -0
  31. package/assets/design-canvas/canvas-store.js +167 -0
  32. package/assets/design-canvas/canvas-theme.js +69 -0
  33. package/assets/design-canvas/canvas-tokens.js +674 -0
  34. package/assets/design-canvas/canvas-ui.js +24 -0
  35. package/assets/design-canvas/canvas-view.js +184 -0
  36. package/assets/design-canvas/canvas.css +773 -17
  37. package/assets/design-canvas/canvas.js +2 -1506
  38. package/assets/design-canvas/index.html +120 -36
  39. package/assets/design-canvas/inspector.js +574 -21
  40. package/assets/design-canvas/theme-early.js +10 -0
  41. package/assets/install-wizard/wizard.js +5 -1
  42. package/assets/migrations/agent-body-history.json +30 -0
  43. package/assets/orchestrator-delegation-reference.md +8 -14
  44. package/assets/orchestrator-delegation.md +5 -9
  45. package/assets/orchestrator-full-delegation-card.md +11 -16
  46. package/assets/orchestrator-full-delegation.md +9 -9
  47. package/assets/orchestrator-memory.md +4 -4
  48. package/assets/orchestrator-prompts.md +3 -31
  49. package/assets/orchestrator-quota-recovery.md +5 -0
  50. package/assets/orchestrator-skills.md +13 -12
  51. package/assets/orchestrator-tracking.md +13 -17
  52. package/assets/orchestrator-verification.md +12 -10
  53. package/assets/orchestrator-writer.md +13 -13
  54. package/assets/orchestrator.md +20 -24
  55. package/bin/gentle-shell.mjs +205 -10
  56. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
  57. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/manifest.json +3 -3
  58. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/orchestration/pi.md +2 -1
  59. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/routing/pi.md +16 -16
  60. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-capabilities.baseline.json +3 -3
  61. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-roles.baseline.json +1 -1
  62. package/docs/assets/brand/sponsor-banner.svg +60 -0
  63. package/docs/assets/features/gentle-tower.png +0 -0
  64. package/docs/auto-permission-answers.md +1 -1
  65. package/docs/bundled-install.md +14 -6
  66. package/docs/delegated-verification.md +23 -5
  67. package/docs/desktop-feed.md +303 -0
  68. package/docs/desktop-rpc.md +1931 -0
  69. package/docs/fast-mode.md +2 -2
  70. package/docs/gentle-agents-activity.md +26 -0
  71. package/docs/gentle-shell-desktop.md +465 -0
  72. package/docs/gentle-shell.md +102 -17
  73. package/docs/images/desktop/chat.png +0 -0
  74. package/docs/images/desktop/palette.png +0 -0
  75. package/docs/images/desktop/todo.png +0 -0
  76. package/docs/install-wizard.md +30 -21
  77. package/docs/odd-preparation-continuity.md +24 -0
  78. package/docs/permission-modes.md +9 -1
  79. package/docs/prompt-budget.md +12 -0
  80. package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
  81. package/docs/readme-reference.md +113 -32
  82. package/docs/review-coordinator.md +29 -9
  83. package/docs/review-delivery-preflight.md +22 -0
  84. package/docs/work-continuity.md +19 -6
  85. package/extensions/ask-user-choice.ts +36 -18
  86. package/extensions/ask-user-question.ts +48 -9
  87. package/extensions/child-context.ts +21 -7
  88. package/extensions/gentle-agents.ts +436 -66
  89. package/extensions/gentle-ai.ts +809 -158
  90. package/extensions/gentle-design.ts +69 -3
  91. package/extensions/gentle-desktop-feed.ts +778 -0
  92. package/extensions/gentle-desktop-rpc.ts +276 -0
  93. package/extensions/gentle-guide.ts +3 -0
  94. package/extensions/gentle-herdr-desktop-status.ts +275 -0
  95. package/extensions/gentle-shell.ts +174 -59
  96. package/extensions/gentle-stats.ts +30 -1
  97. package/extensions/gentle-todo.ts +48 -25
  98. package/extensions/gentle-tower.ts +305 -0
  99. package/extensions/skill-registry.ts +260 -225
  100. package/herdr/RECIPE.md +157 -0
  101. package/herdr/keys.json +14 -0
  102. package/herdr/layouts/gentle-shell.json +202 -0
  103. package/herdr/mods/gentle-agents/icons/kind-herdr.svg +1 -0
  104. package/herdr/mods/gentle-agents/icons/kind-remote.svg +1 -0
  105. package/herdr/mods/gentle-agents/icons/kind-tui.svg +1 -0
  106. package/herdr/mods/gentle-agents/main.js +190 -0
  107. package/herdr/mods/gentle-agents/mod.json +1 -0
  108. package/herdr/mods/gentle-agents/snapshot.js +469 -0
  109. package/herdr/mods/gentle-agents/tokens.js +273 -0
  110. package/herdr/mods/gentle-chat/MINIMAL.md +69 -0
  111. package/herdr/mods/gentle-chat/actions.js +180 -0
  112. package/herdr/mods/gentle-chat/feed.js +321 -0
  113. package/herdr/mods/gentle-chat/icons/branch.svg +1 -0
  114. package/herdr/mods/gentle-chat/icons/chat.svg +1 -0
  115. package/herdr/mods/gentle-chat/icons/check.svg +1 -0
  116. package/herdr/mods/gentle-chat/icons/chev.svg +1 -0
  117. package/herdr/mods/gentle-chat/icons/clip.svg +1 -0
  118. package/herdr/mods/gentle-chat/icons/down.svg +1 -0
  119. package/herdr/mods/gentle-chat/icons/folder.svg +1 -0
  120. package/herdr/mods/gentle-chat/icons/kind-herdr.svg +1 -0
  121. package/herdr/mods/gentle-chat/icons/kind-remote.svg +1 -0
  122. package/herdr/mods/gentle-chat/icons/kind-tui.svg +1 -0
  123. package/herdr/mods/gentle-chat/icons/mark.svg +1 -0
  124. package/herdr/mods/gentle-chat/icons/send.svg +1 -0
  125. package/herdr/mods/gentle-chat/icons/shield.svg +1 -0
  126. package/herdr/mods/gentle-chat/icons/stop.svg +1 -0
  127. package/herdr/mods/gentle-chat/icons/term.svg +1 -0
  128. package/herdr/mods/gentle-chat/icons/user.svg +1 -0
  129. package/herdr/mods/gentle-chat/icons/x.svg +1 -0
  130. package/herdr/mods/gentle-chat/main.js +968 -0
  131. package/herdr/mods/gentle-chat/mod.json +1 -0
  132. package/herdr/mods/gentle-chat/session.js +212 -0
  133. package/herdr/mods/gentle-chat/snapshot.js +469 -0
  134. package/herdr/mods/gentle-chat/tokens.js +137 -0
  135. package/herdr/mods/gentle-chat/ui.js +883 -0
  136. package/herdr/mods/gentle-confirm/main.js +60 -0
  137. package/herdr/mods/gentle-confirm/mod.json +1 -0
  138. package/herdr/mods/gentle-inspector/actions.js +180 -0
  139. package/herdr/mods/gentle-inspector/icons/bolt.svg +1 -0
  140. package/herdr/mods/gentle-inspector/icons/bot.svg +1 -0
  141. package/herdr/mods/gentle-inspector/icons/check.svg +1 -0
  142. package/herdr/mods/gentle-inspector/icons/db.svg +1 -0
  143. package/herdr/mods/gentle-inspector/icons/diff.svg +1 -0
  144. package/herdr/mods/gentle-inspector/icons/jobs.svg +1 -0
  145. package/herdr/mods/gentle-inspector/icons/plug.svg +1 -0
  146. package/herdr/mods/gentle-inspector/icons/review.svg +1 -0
  147. package/herdr/mods/gentle-inspector/icons/stats.svg +1 -0
  148. package/herdr/mods/gentle-inspector/icons/stop.svg +1 -0
  149. package/herdr/mods/gentle-inspector/icons/todo.svg +1 -0
  150. package/herdr/mods/gentle-inspector/main.js +500 -0
  151. package/herdr/mods/gentle-inspector/mod.json +1 -0
  152. package/herdr/mods/gentle-inspector/snapshot.js +469 -0
  153. package/herdr/mods/gentle-inspector/tokens.js +273 -0
  154. package/herdr/mods/gentle-palette/actions.js +180 -0
  155. package/herdr/mods/gentle-palette/icons/bolt.svg +1 -0
  156. package/herdr/mods/gentle-palette/icons/bot.svg +1 -0
  157. package/herdr/mods/gentle-palette/icons/chat.svg +1 -0
  158. package/herdr/mods/gentle-palette/icons/check.svg +1 -0
  159. package/herdr/mods/gentle-palette/icons/cmd.svg +1 -0
  160. package/herdr/mods/gentle-palette/icons/diff.svg +1 -0
  161. package/herdr/mods/gentle-palette/icons/jobs.svg +1 -0
  162. package/herdr/mods/gentle-palette/icons/plus.svg +1 -0
  163. package/herdr/mods/gentle-palette/icons/review.svg +1 -0
  164. package/herdr/mods/gentle-palette/icons/search.svg +1 -0
  165. package/herdr/mods/gentle-palette/icons/shield.svg +1 -0
  166. package/herdr/mods/gentle-palette/icons/stats.svg +1 -0
  167. package/herdr/mods/gentle-palette/icons/stop.svg +1 -0
  168. package/herdr/mods/gentle-palette/icons/term.svg +1 -0
  169. package/herdr/mods/gentle-palette/icons/todo.svg +1 -0
  170. package/herdr/mods/gentle-palette/main.js +333 -0
  171. package/herdr/mods/gentle-palette/mod.json +1 -0
  172. package/herdr/mods/gentle-palette/snapshot.js +469 -0
  173. package/herdr/mods/gentle-palette/tokens.js +273 -0
  174. package/herdr/mods/gentle-pane/icons/chat.svg +1 -0
  175. package/herdr/mods/gentle-pane/icons/close.svg +1 -0
  176. package/herdr/mods/gentle-pane/icons/kind-herdr.svg +1 -0
  177. package/herdr/mods/gentle-pane/icons/kind-remote.svg +1 -0
  178. package/herdr/mods/gentle-pane/icons/kind-tui.svg +1 -0
  179. package/herdr/mods/gentle-pane/icons/split-down.svg +1 -0
  180. package/herdr/mods/gentle-pane/icons/split-right.svg +1 -0
  181. package/herdr/mods/gentle-pane/icons/term.svg +1 -0
  182. package/herdr/mods/gentle-pane/icons/unzoom.svg +1 -0
  183. package/herdr/mods/gentle-pane/icons/zoom.svg +1 -0
  184. package/herdr/mods/gentle-pane/main.js +91 -0
  185. package/herdr/mods/gentle-pane/mod.json +1 -0
  186. package/herdr/mods/gentle-pane/snapshot.js +469 -0
  187. package/herdr/mods/gentle-pane/tokens.js +273 -0
  188. package/herdr/mods/gentle-sidebar/actions.js +180 -0
  189. package/herdr/mods/gentle-sidebar/icons/gear.svg +1 -0
  190. package/herdr/mods/gentle-sidebar/icons/mark.svg +1 -0
  191. package/herdr/mods/gentle-sidebar/icons/refresh.svg +1 -0
  192. package/herdr/mods/gentle-sidebar/icons/server-plus.svg +1 -0
  193. package/herdr/mods/gentle-sidebar/main.js +171 -0
  194. package/herdr/mods/gentle-sidebar/mod.json +1 -0
  195. package/herdr/mods/gentle-sidebar/snapshot.js +469 -0
  196. package/herdr/mods/gentle-sidebar/tokens.js +273 -0
  197. package/herdr/mods/gentle-spaces/icons/kind-herdr.svg +1 -0
  198. package/herdr/mods/gentle-spaces/icons/kind-remote.svg +1 -0
  199. package/herdr/mods/gentle-spaces/icons/kind-tui.svg +1 -0
  200. package/herdr/mods/gentle-spaces/icons/monitor.svg +1 -0
  201. package/herdr/mods/gentle-spaces/icons/plus.svg +1 -0
  202. package/herdr/mods/gentle-spaces/icons/server.svg +1 -0
  203. package/herdr/mods/gentle-spaces/machines.js +31 -0
  204. package/herdr/mods/gentle-spaces/main.js +299 -0
  205. package/herdr/mods/gentle-spaces/mod.json +1 -0
  206. package/herdr/mods/gentle-spaces/snapshot.js +469 -0
  207. package/herdr/mods/gentle-spaces/tokens.js +273 -0
  208. package/herdr/mods/gentle-status/actions.js +180 -0
  209. package/herdr/mods/gentle-status/main.js +192 -0
  210. package/herdr/mods/gentle-status/mod.json +1 -0
  211. package/herdr/mods/gentle-status/snapshot.js +469 -0
  212. package/herdr/mods/gentle-status/tokens.js +273 -0
  213. package/herdr/mods/gentle-tabs/icons/close.svg +1 -0
  214. package/herdr/mods/gentle-tabs/icons/kind-herdr.svg +1 -0
  215. package/herdr/mods/gentle-tabs/icons/kind-remote.svg +1 -0
  216. package/herdr/mods/gentle-tabs/icons/kind-tui.svg +1 -0
  217. package/herdr/mods/gentle-tabs/icons/plus.svg +1 -0
  218. package/herdr/mods/gentle-tabs/icons/win-close.svg +1 -0
  219. package/herdr/mods/gentle-tabs/icons/win-max.svg +1 -0
  220. package/herdr/mods/gentle-tabs/icons/win-min.svg +1 -0
  221. package/herdr/mods/gentle-tabs/icons/win-restore.svg +1 -0
  222. package/herdr/mods/gentle-tabs/main.js +171 -0
  223. package/herdr/mods/gentle-tabs/mod.json +1 -0
  224. package/herdr/mods/gentle-tabs/snapshot.js +469 -0
  225. package/herdr/mods/gentle-tabs/tokens.js +273 -0
  226. package/herdr/mods/gentle-tokens/main.js +20 -0
  227. package/herdr/mods/gentle-tokens/mod.json +1 -0
  228. package/herdr/mods/gentle-tokens/snapshot.js +469 -0
  229. package/herdr/mods/gentle-tokens/tokens.js +273 -0
  230. package/herdr/preview.png +0 -0
  231. package/herdr/themes/gentle-shell-dark.json +33 -0
  232. package/herdr/themes/gentle-shell-light.json +34 -0
  233. package/lib/agent-assets.ts +30 -6
  234. package/lib/agent-tool-overlay.ts +117 -0
  235. package/lib/agents-config.ts +47 -6
  236. package/lib/agents-message-delivery.ts +17 -0
  237. package/lib/agents-messaging.ts +8 -2
  238. package/lib/agents-protocol.ts +17 -0
  239. package/lib/agents-report-cap.ts +115 -0
  240. package/lib/agents-rpc-publisher.ts +39 -12
  241. package/lib/agents-runner.ts +92 -6
  242. package/lib/agents-session-transport.ts +17 -1
  243. package/lib/auto-permission-answers.ts +2 -1
  244. package/lib/background-jobs-tools.ts +9 -4
  245. package/lib/background-jobs.ts +22 -2
  246. package/lib/bounded-writer-admission.ts +184 -31
  247. package/lib/change-diff.ts +104 -0
  248. package/lib/child-context-files.ts +21 -6
  249. package/lib/codemode-renderer.ts +1 -0
  250. package/lib/commit-slice-signal.ts +1 -1
  251. package/lib/delivery-conflict-markers.ts +349 -0
  252. package/lib/design-canvas-assets.ts +38 -0
  253. package/lib/design-canvas-server.ts +241 -23
  254. package/lib/design-comments.ts +94 -4
  255. package/lib/design-handoffs.ts +2 -1
  256. package/lib/design-layout.ts +125 -0
  257. package/lib/design-parts.ts +281 -0
  258. package/lib/design-system-tokens.ts +111 -0
  259. package/lib/desktop-agents-service.ts +315 -0
  260. package/lib/desktop-changes-service.ts +171 -0
  261. package/lib/desktop-design-service.ts +233 -0
  262. package/lib/desktop-feed-actions.ts +804 -0
  263. package/lib/desktop-feed-answers.ts +129 -0
  264. package/lib/desktop-feed-sources.ts +184 -0
  265. package/lib/desktop-feed-stats.ts +98 -0
  266. package/lib/desktop-feed-store.ts +124 -0
  267. package/lib/desktop-feed.ts +788 -0
  268. package/lib/desktop-jobs-service.ts +290 -0
  269. package/lib/desktop-review-service.ts +187 -0
  270. package/lib/desktop-rpc-agents.ts +403 -0
  271. package/lib/desktop-rpc-changes.ts +223 -0
  272. package/lib/desktop-rpc-config-watch.ts +285 -0
  273. package/lib/desktop-rpc-config.ts +885 -0
  274. package/lib/desktop-rpc-design.ts +138 -0
  275. package/lib/desktop-rpc-jobs.ts +290 -0
  276. package/lib/desktop-rpc-permissions.ts +328 -0
  277. package/lib/desktop-rpc-profiles.ts +196 -0
  278. package/lib/desktop-rpc-review.ts +180 -0
  279. package/lib/desktop-rpc-session.ts +203 -0
  280. package/lib/desktop-rpc-sessions.ts +250 -0
  281. package/lib/desktop-rpc-stats.ts +187 -0
  282. package/lib/desktop-rpc-updates.ts +143 -0
  283. package/lib/desktop-rpc-usage.ts +229 -0
  284. package/lib/desktop-rpc.ts +336 -0
  285. package/lib/desktop-session-service.ts +223 -0
  286. package/lib/desktop-sessions-service.ts +249 -0
  287. package/lib/desktop-stats-service.ts +142 -0
  288. package/lib/desktop-updates-service.ts +268 -0
  289. package/lib/desktop-usage-service.ts +310 -0
  290. package/lib/destructive-command-guard.ts +188 -13
  291. package/lib/gentle-ai-renderer.ts +13 -1
  292. package/lib/gentle-design.ts +201 -14
  293. package/lib/gentle-shell-bundled.ts +100 -9
  294. package/lib/gentle-shell-desktop.ts +1370 -0
  295. package/lib/gentle-shell-launcher.ts +45 -3
  296. package/lib/herdr-desktop-events.ts +40 -0
  297. package/lib/herdr-desktop-status.ts +229 -0
  298. package/lib/hidden-tools.ts +35 -0
  299. package/lib/inprocess-reviewer.ts +96 -12
  300. package/lib/jobs-sidebar-state.ts +5 -0
  301. package/lib/model-fallback-policy.ts +9 -0
  302. package/lib/model-routing-authority.ts +9 -0
  303. package/lib/nan-provider.ts +42 -28
  304. package/lib/native-review-cli.ts +86 -4
  305. package/lib/openai-fast-tier.ts +1 -0
  306. package/lib/orchestrator-discovery.ts +39 -2
  307. package/lib/reply-language-anchor.ts +27 -2
  308. package/lib/request-context-placement.ts +53 -0
  309. package/lib/review-candidate-view.ts +11 -1
  310. package/lib/review-continuation-registry.ts +17 -0
  311. package/lib/review-coordinator.ts +252 -8
  312. package/lib/review-delivery-preflight.ts +85 -0
  313. package/lib/review-host-relay.ts +5 -1
  314. package/lib/review-integration-v2.ts +56 -3
  315. package/lib/reviewer-stream.ts +87 -0
  316. package/lib/session-profile-freeze.ts +13 -5
  317. package/lib/shell-prompt.ts +16 -3
  318. package/lib/shell-usage.ts +10 -0
  319. package/lib/stats-collector.ts +56 -27
  320. package/lib/tower-actions.ts +100 -0
  321. package/lib/tower-hub.ts +73 -0
  322. package/lib/tower-launch.ts +111 -0
  323. package/lib/tower-open.ts +99 -0
  324. package/lib/tower-presence.ts +70 -0
  325. package/lib/tower-server.ts +234 -0
  326. package/lib/tower-snapshot.ts +298 -0
  327. package/lib/update-status.ts +238 -0
  328. package/lib/verifier-settle-reminder.ts +1 -1
  329. package/lib/vim-editor-adapter.ts +9 -2
  330. package/lib/writer-batch-admission.ts +55 -0
  331. package/lib/yolo-session-policy.ts +6 -1
  332. package/package.json +14 -5
  333. package/prompts/skill-creation.md +1 -10
  334. package/runtime/design-canvas-assets.mjs +39 -0
  335. package/runtime/gentle-shell-bundled.mjs +100 -9
  336. package/runtime/gentle-shell-desktop.mjs +1371 -0
  337. package/runtime/gentle-shell-launcher.mjs +44 -2
  338. package/runtime/native-review-cli.mjs +86 -4
  339. package/runtime/review-integration-v2.mjs +56 -3
  340. package/runtime/tower-actions.mjs +101 -0
  341. package/runtime/tower-hub.mjs +74 -0
  342. package/runtime/tower-launch.mjs +112 -0
  343. package/runtime/tower-open.mjs +100 -0
  344. package/runtime/tower-presence.mjs +71 -0
  345. package/runtime/tower-server.mjs +234 -0
  346. package/runtime/tower-snapshot.mjs +299 -0
  347. package/scripts/bootstrap.cmd +2 -2
  348. package/scripts/bootstrap.sh +41 -4
  349. package/scripts/build-full-delegation-card.mjs +5 -21
  350. package/scripts/build-runtime-modules.mjs +10 -0
  351. package/scripts/gentle-ai-installer.mjs +10 -10
  352. package/scripts/gentle-ai-proxy.mjs +1 -1
  353. package/scripts/installer-downloads.mjs +34 -8
  354. package/scripts/installer-preflight.mjs +28 -17
  355. package/scripts/installer-probes.mjs +25 -5
  356. package/scripts/installer-server.mjs +38 -9
  357. package/scripts/installer-windows.mjs +2 -2
  358. package/scripts/pi-update.mjs +166 -27
  359. package/scripts/prepare-verifier.mjs +107 -0
  360. package/scripts/update-agent-body-history.mjs +55 -8
  361. package/scripts/verify-package-files.mjs +61 -20
  362. package/skills/branch-pr/SKILL.md +16 -16
  363. package/skills/comment-writer/SKILL.md +1 -1
  364. package/skills/design/SKILL.md +6 -6
  365. package/skills/gentle-ai/SKILL.md +5 -5
  366. package/skills/judgment-day/SKILL.md +2 -2
  367. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  368. package/skills/provider-defect-report/SKILL.md +61 -0
  369. package/skills/rdd-defect-workflow/SKILL.md +6 -6
  370. package/skills/skill-improver/SKILL.md +2 -2
  371. package/skills/skill-registry/SKILL.md +11 -13
  372. package/skills/tui-design/SKILL.md +1 -1
  373. package/skills/work-unit-commits/SKILL.md +5 -5
  374. package/tests/agent-prompt-diet-contract.test.ts +101 -0
  375. package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
  376. package/tests/agent-tool-overlay.test.ts +89 -0
  377. package/tests/agents-config.test.ts +10 -1
  378. package/tests/agents-message-delivery.test.ts +36 -0
  379. package/tests/agents-queries.test.ts +144 -4
  380. package/tests/agents-report-cap.test.ts +126 -0
  381. package/tests/agents-runner.test.ts +37 -1
  382. package/tests/agents-session-transport.test.ts +34 -0
  383. package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
  384. package/tests/append-system-prompt-route.test.ts +26 -7
  385. package/tests/approved-text-leftovers-contract.test.ts +136 -0
  386. package/tests/artifact-language.test.ts +1 -1
  387. package/tests/ask-user-choice.test.ts +78 -21
  388. package/tests/ask-user-question.test.ts +61 -6
  389. package/tests/audit-leftovers-contract.test.ts +51 -0
  390. package/tests/auto-permission-answers.test.ts +12 -1
  391. package/tests/background-jobs.test.ts +12 -0
  392. package/tests/bounded-stop-contract.test.ts +148 -27
  393. package/tests/branch-pr-skill.test.ts +10 -1
  394. package/tests/bundled-install.test.ts +1 -1
  395. package/tests/change-diff.test.ts +75 -0
  396. package/tests/child-context-files.test.ts +64 -8
  397. package/tests/child-skills-catalog.test.ts +56 -0
  398. package/tests/codemode-rendering.test.ts +4 -1
  399. package/tests/commit-slice-signal.test.ts +3 -2
  400. package/tests/decision-routing-contract.test.ts +390 -0
  401. package/tests/delegate-for-reason-contract.test.ts +30 -8
  402. package/tests/delegated-key-learnings-contract.test.ts +21 -28
  403. package/tests/delivery-b-rendered-surfaces.test.ts +32 -0
  404. package/tests/delivery-conflict-markers.test.ts +348 -0
  405. package/tests/design-canvas-all-sizes.test.ts +631 -0
  406. package/tests/design-canvas-allowlist.test.ts +32 -0
  407. package/tests/design-canvas-assets.test.ts +11 -878
  408. package/tests/design-canvas-boards.test.ts +77 -0
  409. package/tests/design-canvas-checks.test.ts +655 -0
  410. package/tests/design-canvas-compare.test.ts +79 -0
  411. package/tests/design-canvas-events.test.ts +59 -0
  412. package/tests/design-canvas-export.test.ts +1168 -0
  413. package/tests/design-canvas-focus.test.ts +113 -0
  414. package/tests/design-canvas-handoffs.test.ts +59 -0
  415. package/tests/design-canvas-i18n-review.test.ts +513 -0
  416. package/tests/design-canvas-i18n-views.test.ts +259 -0
  417. package/tests/design-canvas-i18n.test.ts +528 -0
  418. package/tests/design-canvas-inspector.test.ts +1004 -0
  419. package/tests/design-canvas-layout.test.ts +1222 -0
  420. package/tests/design-canvas-minimap.test.ts +413 -0
  421. package/tests/design-canvas-modules.test.ts +91 -0
  422. package/tests/design-canvas-parts.test.ts +721 -0
  423. package/tests/design-canvas-rail.test.ts +799 -0
  424. package/tests/design-canvas-server.test.ts +855 -17
  425. package/tests/design-canvas-sizes.test.ts +548 -0
  426. package/tests/design-canvas-store.test.ts +189 -0
  427. package/tests/design-canvas-theme.test.ts +198 -0
  428. package/tests/design-canvas-tokens.test.ts +965 -0
  429. package/tests/design-canvas-view.test.ts +299 -0
  430. package/tests/design-comments.test.ts +201 -1
  431. package/tests/design-handoffs.test.ts +20 -0
  432. package/tests/design-layout.test.ts +100 -0
  433. package/tests/design-parts.test.ts +260 -0
  434. package/tests/design-system-tokens.test.ts +215 -0
  435. package/tests/desktop-feed-actions-guards.test.ts +595 -0
  436. package/tests/desktop-feed-actions.test.ts +761 -0
  437. package/tests/desktop-feed-live-work.test.ts +209 -0
  438. package/tests/desktop-feed-performance.test.ts +369 -0
  439. package/tests/desktop-feed-plan-profiles.test.ts +509 -0
  440. package/tests/desktop-feed-send-prompt.test.ts +303 -0
  441. package/tests/desktop-feed-tool-summaries.test.ts +69 -0
  442. package/tests/desktop-feed.test.ts +615 -0
  443. package/tests/desktop-rpc-agents.test.ts +1319 -0
  444. package/tests/desktop-rpc-changes.test.ts +608 -0
  445. package/tests/desktop-rpc-config-watch.test.ts +1159 -0
  446. package/tests/desktop-rpc-config.test.ts +1462 -0
  447. package/tests/desktop-rpc-design.test.ts +672 -0
  448. package/tests/desktop-rpc-jobs.test.ts +1193 -0
  449. package/tests/desktop-rpc-permissions.test.ts +321 -0
  450. package/tests/desktop-rpc-profiles.test.ts +140 -0
  451. package/tests/desktop-rpc-review.test.ts +678 -0
  452. package/tests/desktop-rpc-safety.test.ts +119 -0
  453. package/tests/desktop-rpc-session.test.ts +642 -0
  454. package/tests/desktop-rpc-sessions.test.ts +647 -0
  455. package/tests/desktop-rpc-stats.test.ts +431 -0
  456. package/tests/desktop-rpc-updates.test.ts +525 -0
  457. package/tests/desktop-rpc-usage.test.ts +707 -0
  458. package/tests/desktop-rpc.test.ts +293 -0
  459. package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
  460. package/tests/devbinary/review-session-consent.devtest.ts +84 -0
  461. package/tests/engram-safety.test.ts +111 -0
  462. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
  463. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
  464. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +30 -41
  465. package/tests/fixtures/refusal-identity.probe.mjs +139 -0
  466. package/tests/fixtures/session-profile-v1/replay.ts +4 -1
  467. package/tests/full-delegation-closure.test.ts +48 -0
  468. package/tests/gentle-agents.test.ts +848 -8
  469. package/tests/gentle-ai-binary.test.ts +1 -1
  470. package/tests/gentle-ai-child-guards.test.ts +1 -0
  471. package/tests/gentle-ai-installer.test.ts +52 -51
  472. package/tests/gentle-ai-renderer.test.ts +36 -2
  473. package/tests/gentle-ai.test.ts +195 -21
  474. package/tests/gentle-design.test.ts +365 -1
  475. package/tests/gentle-fast.test.ts +15 -0
  476. package/tests/gentle-herdr-desktop-status.test.ts +595 -0
  477. package/tests/gentle-shell-bundled.test.ts +91 -5
  478. package/tests/gentle-shell-desktop-bin.test.ts +125 -0
  479. package/tests/gentle-shell-desktop.test.ts +927 -0
  480. package/tests/gentle-shell-launcher-tower.test.ts +104 -0
  481. package/tests/gentle-shell-launcher.test.ts +1 -1
  482. package/tests/gentle-shell.test.ts +121 -87
  483. package/tests/gentle-todo.test.ts +32 -9
  484. package/tests/gentle-tower.test.ts +578 -0
  485. package/tests/herdr-desktop-status.test.ts +285 -0
  486. package/tests/hidden-tools.test.ts +188 -0
  487. package/tests/independent-recovery-delivery.test.ts +35 -9
  488. package/tests/inprocess-reviewer.test.ts +73 -0
  489. package/tests/install-wizard.test.ts +27 -1
  490. package/tests/installer-downloads.test.ts +30 -1
  491. package/tests/installer-posix-bootstrap.test.ts +114 -13
  492. package/tests/installer-preflight.test.ts +49 -1
  493. package/tests/installer-probes.test.ts +146 -0
  494. package/tests/installer-server.test.ts +203 -4
  495. package/tests/installer-windows-bootstrap.test.ts +19 -1
  496. package/tests/judgment-day-severity-admission.test.ts +46 -0
  497. package/tests/lazy-module-contradictions-contract.test.ts +181 -0
  498. package/tests/maintainer/desktop-rpc.maintest.ts +907 -0
  499. package/tests/maintainer/pi-update-source.maintest.ts +48 -18
  500. package/tests/model-fallback-policy.test.ts +26 -7
  501. package/tests/nan-provider-runtime.test.ts +17 -3
  502. package/tests/nan-provider.test.ts +111 -56
  503. package/tests/native-review-capability-contract.test.ts +19 -1
  504. package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
  505. package/tests/native-review-parity.test.ts +24 -5
  506. package/tests/native-review-refusal-identity.test.ts +25 -0
  507. package/tests/no-self-pause-contract.test.ts +33 -15
  508. package/tests/odd-integration.test.ts +11 -3
  509. package/tests/odd-routing-canonical-ratchet.test.ts +10 -0
  510. package/tests/odd-routing-contract.test.ts +99 -31
  511. package/tests/orchestrator-budget.test.ts +32 -5
  512. package/tests/orchestrator-consultation-sdk.test.ts +32 -6
  513. package/tests/orchestrator-delegation-mode.test.ts +2 -1
  514. package/tests/orchestrator-discovery.test.ts +28 -0
  515. package/tests/orchestrator-prompt-budget.test.ts +12 -2
  516. package/tests/orchestrator-prompt-diet-contract.test.ts +249 -0
  517. package/tests/orchestrator-rdd-ownership.test.ts +2 -1
  518. package/tests/orchestrator-work-search.test.ts +4 -2
  519. package/tests/package-files.test.ts +25 -1
  520. package/tests/package-manifest.test.ts +15 -14
  521. package/tests/parallel-reason-contract.test.ts +6 -3
  522. package/tests/permission-allowlist.test.ts +200 -30
  523. package/tests/persona-neutral-voseo.test.ts +4 -4
  524. package/tests/persona-reply-language.test.ts +1 -1
  525. package/tests/persona-single-channel.test.ts +13 -5
  526. package/tests/pi-routing-measured-values.test.ts +24 -0
  527. package/tests/pi-update-launcher.test.ts +17 -7
  528. package/tests/pi-update-source.test.ts +113 -6
  529. package/tests/pi-update.test.ts +294 -19
  530. package/tests/pnpm-workspace-policy.test.ts +47 -0
  531. package/tests/primary-context-files.test.ts +233 -0
  532. package/tests/primary-context-three-files.test.ts +174 -0
  533. package/tests/primary-session-prompt.test.ts +25 -0
  534. package/tests/profile-fast-tier.test.ts +66 -1
  535. package/tests/provider-defect-handoff.test.ts +124 -99
  536. package/tests/rdd-aware-verification-contract.test.ts +1 -1
  537. package/tests/rdd-status-line.test.ts +94 -1
  538. package/tests/reply-language-anchor-placement.test.ts +184 -0
  539. package/tests/reply-language-anchor.test.ts +17 -1
  540. package/tests/request-context-append-only.test.ts +218 -0
  541. package/tests/request-context-placement.test.ts +148 -0
  542. package/tests/review-agent-end-preflight.test.ts +79 -1
  543. package/tests/review-candidate-view.test.ts +65 -0
  544. package/tests/review-continuation-registry.test.ts +31 -0
  545. package/tests/review-contract-prompt.test.ts +2 -1
  546. package/tests/review-controller.test.ts +2 -1
  547. package/tests/review-coordinator-correction-gate.test.ts +105 -0
  548. package/tests/review-coordinator-findings.test.ts +206 -0
  549. package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
  550. package/tests/review-coordinator.test.ts +271 -4
  551. package/tests/review-delivery-preflight.test.ts +462 -0
  552. package/tests/review-due-compaction.test.ts +31 -0
  553. package/tests/review-due-public-boundary.test.ts +27 -0
  554. package/tests/review-integration-nonblocking-findings.test.ts +108 -0
  555. package/tests/review-json-arguments.test.ts +41 -2
  556. package/tests/review-ledger-contract.test.ts +19 -40
  557. package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
  558. package/tests/review-one-call-findings.test.ts +131 -0
  559. package/tests/review-one-call-followups.test.ts +308 -0
  560. package/tests/review-one-call-reviewer-requests.test.ts +207 -0
  561. package/tests/review-one-call.test.ts +452 -0
  562. package/tests/review-relay-transport-agent.test.ts +28 -1
  563. package/tests/review-reviewer-evidence.test.ts +41 -1
  564. package/tests/review-risk-assessment.test.ts +52 -5
  565. package/tests/review-run-statement-guidance-independent.test.ts +54 -0
  566. package/tests/review-session-standing-permission-controller.test.ts +32 -2
  567. package/tests/review-tool-prose-budget.test.ts +1 -0
  568. package/tests/reviewer-stream.test.ts +149 -0
  569. package/tests/sensitive-path-tools.test.ts +138 -4
  570. package/tests/session-profile-extension.test.ts +312 -18
  571. package/tests/session-profile-freeze.test.ts +26 -0
  572. package/tests/session-profile-v1-compat.test.ts +20 -0
  573. package/tests/shell-prompt.test.ts +17 -0
  574. package/tests/shell-usage.test.ts +59 -10
  575. package/tests/skill-collision-prefixes.test.ts +1 -0
  576. package/tests/skill-contradictions-contract.test.ts +124 -0
  577. package/tests/skill-registry-watcher.test.ts +216 -2
  578. package/tests/skill-registry.test.ts +983 -306
  579. package/tests/stats-collector.test.ts +109 -2
  580. package/tests/support/design-canvas-dom.ts +386 -0
  581. package/tests/support/review-coordinator-runtime.ts +212 -17
  582. package/tests/task-size-routing-contract.test.ts +49 -14
  583. package/tests/test-strength-contract.test.ts +2 -1
  584. package/tests/todo-request-append-only.test.ts +214 -0
  585. package/tests/tool-batching-contract.test.ts +3 -1
  586. package/tests/tower-actions.test.ts +247 -0
  587. package/tests/tower-artifacts.test.ts +114 -0
  588. package/tests/tower-open.test.ts +97 -0
  589. package/tests/tower-presence.test.ts +175 -0
  590. package/tests/tower-server.test.ts +122 -0
  591. package/tests/tower-snapshot.test.ts +236 -0
  592. package/tests/tower-web-echo.test.ts +125 -0
  593. package/tests/tower-web-hover.test.ts +251 -0
  594. package/tests/update-agent-body-history.test.ts +138 -0
  595. package/tests/verification-scoped-stop-contract.test.ts +32 -0
  596. package/tests/verification-tiers-contract.test.ts +229 -0
  597. package/tests/verifier-preparation.test.ts +229 -0
  598. package/tests/verifier-settle-reminder.test.ts +2 -2
  599. package/tests/verify-agent-contract.test.ts +20 -2
  600. package/tests/verify-first-launch-contract.test.ts +88 -12
  601. package/tests/vim-editor-adapter.test.ts +2 -2
  602. package/tests/work-continuity-contract.test.ts +136 -27
  603. package/tests/writer-admission-messages.test.ts +232 -0
  604. package/tests/writer-batch-admission.test.ts +66 -0
  605. package/tests/writer-edit-surface-scope.test.ts +52 -20
  606. package/tests/writer-feature-document-admission.test.ts +184 -0
  607. package/tests/writer-rejection-next-step.test.ts +55 -0
  608. package/tests/writer-surface-authority-contract.test.ts +158 -0
  609. package/tests/yolo-mode.test.ts +39 -0
  610. package/skills/_shared/review-ledger-contract.md +0 -106
  611. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/README.md +0 -0
  612. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/lens.schema.json +0 -0
  613. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/refuter.schema.json +0 -0
  614. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  615. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/lens.json +0 -0
  616. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/refuter.json +0 -0
  617. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -0,0 +1,655 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+ import test from "node:test";
4
+ import { fileURLToPath } from "node:url";
5
+ import { findAll, flush, heardGeneration, loadCanvas, read, texts, withClass, type FakeElement } from "./support/design-canvas-dom.ts";
6
+
7
+ // Accessibility checks (canvas-checks.js): each design artboard's own frame checks its page after it loads and
8
+ // after a resize (inspector.js gd:checks); the panel's Quality tab lists the findings per artboard, with Show
9
+ // (zoom in, center, a ring on the canvas) and Ask the agent to fix (the comment box, prefilled). The panel has two
10
+ // tabs, Comments and Quality, with counts. Covers the reload, design-switch, stale-identity and every-exit-path
11
+ // cases the maintainer probes (S7). Assertions compare strings, numbers and booleans, never fake elements.
12
+
13
+ const SYSTEM_REPLY = { "/t/api/system": { exists: true, file: "system.html", width: 800, height: 600 } };
14
+ const CHECKS: Array<[string, string]> = [["contrast", "Text contrast"], ["target", "Target size"], ["alt", "Images have alt text"], ["label", "Form fields have labels"], ["heading", "Headings in order"]];
15
+ const DETAIL = '"or pay with card" is 3.1 : 1 (#999999 on #ffffff); WCAG AA needs 4.5 : 1.';
16
+ const finding = (extra: Record<string, unknown> = {}) => ({ check: "contrast", severity: "fail", title: "Low contrast", detail: DETAIL, selector: "main > p.or", label: "p.or", excerpt: "or pay with card", rect: { x: 30, y: 40, width: 200, height: 20 }, ...extra });
17
+ const advice = (extra: Record<string, unknown> = {}) => finding({ check: "target", severity: "advice", title: "Touch target under 44 px", detail: '"Pay" is 100 × 28 px; 44 × 44 px is recommended for touch.', selector: "#pay", label: "button#pay", rect: { x: 10, y: 250, width: 4, height: 2 }, ...extra });
18
+
19
+ function checksReport(issues: Array<Record<string, any>> = []) {
20
+ const checks = CHECKS.map(([id, label]) => ({
21
+ id, label,
22
+ count: issues.filter((entry) => entry.check === id && entry.severity === "fail").length,
23
+ advice: issues.filter((entry) => entry.check === id && entry.severity === "advice").length,
24
+ }));
25
+ return { type: "gd:checks", checks, issues };
26
+ }
27
+
28
+ async function loadChecks(replies: Record<string, unknown> = {}) {
29
+ const canvas = await loadCanvas(300, replies);
30
+ // The fake DOM starts every element visible; index.html starts these hidden.
31
+ for (const id of ["gd-popover", "gd-menu", "gd-device-menu", "gd-inspector", "gd-quality"]) canvas.document.getElementById(id).hidden = true;
32
+ canvas.boards.forEach((board, index) => { board.frame.rect = { left: 100 + index * 500, top: 120, width: 400, height: 300 }; });
33
+ return canvas;
34
+ }
35
+ type Canvas = Awaited<ReturnType<typeof loadChecks>>;
36
+
37
+ const $ = (canvas: Canvas, id: string) => canvas.document.getElementById(id);
38
+ const settle = async () => { for (let i = 0; i < 10; i++) await flush(); };
39
+ /** A gd:checks as inspector.js posts it from `frame`'s page: tagged with the size generation that page heard last (or `generation`). */
40
+ const report = (canvas: Canvas, frame: FakeElement, issues: Array<Record<string, any>> = [], generation = heardGeneration(frame)) => canvas.message(frame.contentWindow, { ...checksReport(issues), generation });
41
+ const openQuality = (canvas: Canvas) => $(canvas, "gd-tab-quality").dispatch("click");
42
+ const quality = (canvas: Canvas) => $(canvas, "gd-quality");
43
+ const count = (canvas: Canvas) => $(canvas, "gd-count-quality").textContent;
44
+ const cards = (canvas: Canvas) => withClass(quality(canvas), "gd-check");
45
+ const groups = (canvas: Canvas) => withClass(quality(canvas), "gd-check-group").map((group) => `${texts(group, "gd-check-heading")[0]}: ${texts(group, "gd-check-summary")[0]}`);
46
+ const showButton = (canvas: Canvas, index: number) => withClass(cards(canvas)[index], "gd-check-show")[0];
47
+ const fixButton = (canvas: Canvas, index: number) => withClass(cards(canvas)[index], "gd-check-fix")[0];
48
+ const showCard = (canvas: Canvas, index: number) => showButton(canvas, index).dispatch("click");
49
+ /** The rings on the page (the world and the All sizes frames both live in the viewport). */
50
+ const marks = (canvas: Canvas) => withClass(canvas.viewport, "gd-check-mark");
51
+ const markBox = (canvas: Canvas) => marks(canvas).map((ring) => [ring.style.left, ring.style.top, ring.style["--gd-mark-w"], ring.style["--gd-mark-h"]].join(" "));
52
+ /** The cards marked as the ring's (aria-current), by index. */
53
+ const activeCards = (canvas: Canvas) => cards(canvas).flatMap((card, index) => (card.getAttribute("aria-current") === "true" ? [index] : []));
54
+ const ringIn = (root: FakeElement) => withClass(root, "gd-check-mark").length;
55
+ const frameBox = (canvas: Canvas, index: number) => canvas.boards[index].frame.parentElement!;
56
+ const pressed = (canvas: Canvas, id: string) => $(canvas, id).getAttribute("aria-pressed");
57
+ const focusOn = (canvas: Canvas, index = 0) => canvas.boards[index].shield!.dispatch("keydown", { key: "Enter" });
58
+ const chooseSize = (canvas: Canvas, size: string) => {
59
+ if ($(canvas, "gd-device-menu").hidden) $(canvas, "gd-device").dispatch("click");
60
+ findAll($(canvas, "gd-device-menu"), (element) => element.dataset.size === size)[0].dispatch("click");
61
+ };
62
+ const sizeSections = (canvas: Canvas) => withClass(canvas.viewport, "gd-size-frame");
63
+ const iframeOf = (root: FakeElement) => findAll(root, (element) => element.localName === "iframe")[0];
64
+ const view = (canvas: Canvas) => {
65
+ const match = /^translate\((-?[\d.e+-]+)px, (-?[\d.e+-]+)px\) scale\(([\d.e+-]+)\)$/.exec(canvas.world.style.transform);
66
+ assert.ok(match, `a world transform: ${canvas.world.style.transform}`);
67
+ return { x: Number(match[1]), y: Number(match[2]), zoom: Number(match[3]) };
68
+ };
69
+ /** A key press delivered to the document's keydown listeners, as the browser would from `target`. */
70
+ function press(canvas: Canvas, key: string, init: Record<string, unknown> = {}, target?: FakeElement) {
71
+ const event: any = { key, shiftKey: false, ctrlKey: false, metaKey: false, altKey: false, target: target ?? canvas.document.body, defaultPrevented: false, preventDefault() { event.defaultPrevented = true; }, ...init };
72
+ for (const listener of canvas.document.listeners.get("keydown") ?? []) listener(event);
73
+ return event;
74
+ }
75
+ const lastOf = (frame: FakeElement, type: string) => frame.contentWindow!.posted.filter((message) => message.type === type).at(-1) ?? null;
76
+ const activeId = (canvas: Canvas) => canvas.document.activeElement?.id ?? "";
77
+
78
+ // ---- the tabs (S8)
79
+
80
+ test("the panel has two tabs, Comments and Quality, with counts; the arrows, Home and End move between them", async () => {
81
+ const comments = { comments: [
82
+ { id: "c1", file: "01-a.html", selector: "#x", excerpt: "", comment: "one", status: "open", createdAt: "2026-10-26T10:00:00.000Z", sentAt: null },
83
+ { id: "c2", file: "01-a.html", selector: "#y", excerpt: "", comment: "two", status: "open", createdAt: "2026-10-26T10:00:00.000Z", sentAt: null },
84
+ { id: "c3", file: "02-b.html", selector: "#z", excerpt: "", comment: "three", status: "resolved", createdAt: "2026-10-26T10:00:00.000Z", sentAt: null },
85
+ ] };
86
+ const canvas = await loadChecks({ "/t/api/designs/alpha/comments": comments });
87
+ const tabs = () => ["gd-tab-comments", "gd-tab-quality"].map((id) => `${$(canvas, id).getAttribute("aria-selected")}/${$(canvas, id).getAttribute("tabindex") ?? "0"}`);
88
+ const panels = () => [$(canvas, "gd-tabpanel-comments").hidden, quality(canvas).hidden];
89
+ assert.equal($(canvas, "gd-count-comments").textContent, "2", "Comments counts the open comments");
90
+ assert.equal(count(canvas), "", "no count before an artboard reports");
91
+ openQuality(canvas);
92
+ assert.deepEqual([tabs(), panels()], [["false/-1", "true/0"], [true, false]]);
93
+ assert.deepEqual(texts(quality(canvas), "gd-check-summary"), ["Not checked yet", "Not checked yet"], "a group per design artboard, before it reports");
94
+ report(canvas, canvas.boards[1].frame, []);
95
+ assert.equal(count(canvas), "0", "one artboard reported, with no problems");
96
+
97
+ const tablist = $(canvas, "gd-tabs");
98
+ const right = tablist.dispatch("keydown", { key: "ArrowRight" });
99
+ assert.deepEqual([right.defaultPrevented, tabs(), panels(), activeId(canvas)], [true, ["true/0", "false/-1"], [false, true], "gd-tab-comments"], "the arrows wrap around and move focus to the tab");
100
+ tablist.dispatch("keydown", { key: "ArrowLeft" });
101
+ assert.deepEqual([tabs(), activeId(canvas)], [["false/-1", "true/0"], "gd-tab-quality"]);
102
+ tablist.dispatch("keydown", { key: "Home" });
103
+ assert.deepEqual([tabs(), activeId(canvas)], [["true/0", "false/-1"], "gd-tab-comments"]);
104
+ tablist.dispatch("keydown", { key: "End" });
105
+ assert.deepEqual([tabs(), activeId(canvas)], [["false/-1", "true/0"], "gd-tab-quality"]);
106
+ const other = tablist.dispatch("keydown", { key: "Enter" });
107
+ assert.deepEqual([other.defaultPrevented, tabs()], [false, ["false/-1", "true/0"]], "other keys stay with the tab");
108
+ $(canvas, "gd-tab-comments").dispatch("click");
109
+ assert.deepEqual(panels(), [false, true]);
110
+ });
111
+
112
+ test("Partial implementations stays at the panel's bottom in both tabs", async () => {
113
+ const part = { id: "p1", file: "01-a.html", selector: "#x", excerpt: "Pay", status: "sent", queued: false, sentAt: "2026-10-26T10:00:00.000Z", startedAt: null, implementedAt: null };
114
+ const canvas = await loadChecks({ "/t/api/designs/alpha/parts": { version: 1, parts: [part] } });
115
+ assert.equal($(canvas, "gd-parts").hidden, false);
116
+ openQuality(canvas);
117
+ assert.equal($(canvas, "gd-parts").hidden, false, "Quality keeps it");
118
+ const html = read("index.html");
119
+ const panel = html.slice(html.indexOf('<aside id="gd-panel"'), html.indexOf("</aside>"));
120
+ const at = (id: string) => panel.indexOf(`id="${id}"`);
121
+ assert.ok(at("gd-tabpanel-comments") > 0 && at("gd-tabpanel-comments") < at("gd-quality") && at("gd-quality") < at("gd-parts"), "outside both tab panels, after them");
122
+ });
123
+
124
+ test("clicking a comment's pin while Quality shows brings the Comments tab back", async () => {
125
+ const comments = { comments: [{ id: "c1", file: "01-a.html", selector: "#x", excerpt: "", comment: "one", status: "open", createdAt: "2026-10-26T10:00:00.000Z", sentAt: null }] };
126
+ const canvas = await loadChecks({ "/t/api/designs/alpha/comments": comments });
127
+ canvas.message(canvas.boards[0].frame.contentWindow, { type: "gd:pin-rects", rects: [{ id: "c1", rect: { x: 10, y: 10, width: 20, height: 20 } }] });
128
+ openQuality(canvas);
129
+ withClass(canvas.world, "gd-pin")[0].dispatch("click");
130
+ assert.deepEqual([$(canvas, "gd-tab-comments").getAttribute("aria-selected"), $(canvas, "gd-tabpanel-comments").hidden, quality(canvas).hidden], ["true", false, true]);
131
+ });
132
+
133
+ // ---- what the artboards report
134
+
135
+ test("only each design artboard's own frame is asked to check itself: never a size frame or the system board", async () => {
136
+ const canvas = await loadChecks(SYSTEM_REPLY);
137
+ const [system, first] = canvas.frames();
138
+ for (const frame of canvas.frames()) frame.dispatch("load");
139
+ assert.deepEqual([lastOf(system, "gd:run-checks"), lastOf(first, "gd:run-checks")], [null, { type: "gd:run-checks" }]);
140
+ assert.deepEqual(lastOf(canvas.frames()[2], "gd:run-checks"), { type: "gd:run-checks" });
141
+ canvas.world.children[1].children.find((child) => child.classes.has("gd-frame-box"))!.children.find((child) => child.classes.has("gd-shield"))!.dispatch("keydown", { key: "Enter" });
142
+ chooseSize(canvas, "all");
143
+ for (const section of sizeSections(canvas)) iframeOf(section).dispatch("load");
144
+ assert.deepEqual(sizeSections(canvas).map((section) => lastOf(iframeOf(section), "gd:run-checks")), [null, null, null], "the size frames would only repeat the work, and the canvas ignores them");
145
+ });
146
+
147
+ test("a report fills Quality: a group per design artboard with its summary, a card per finding, the passed checks once, and a count of problems", async () => {
148
+ const canvas = await loadChecks();
149
+ const [first, second] = canvas.boards;
150
+ report(canvas, first.frame, [
151
+ finding(),
152
+ finding({ check: "label", title: "Form field without a label", detail: "The select has no label.", selector: "#size", label: "select#size" }),
153
+ advice(),
154
+ ]);
155
+ report(canvas, second.frame, [advice({ selector: "#other" })]);
156
+ assert.equal(count(canvas), "2", "advice does not count");
157
+ openQuality(canvas);
158
+ assert.deepEqual(groups(canvas), ["01 First: 2 checks", "02 Second: Accessible ✓"]);
159
+ assert.deepEqual(cards(canvas).map((card) => `${texts(card, "gd-check-title")[0]} | ${texts(card, "gd-check-kind")[0]} | ${card.classes.has("gd-check-fail") ? "fail" : "advice"}`), [
160
+ "Low contrast | Problem | fail", "Form field without a label | Problem | fail", "Touch target under 44 px | Advice | advice", "Touch target under 44 px | Advice | advice",
161
+ ]);
162
+ assert.equal(texts(cards(canvas)[0], "gd-check-detail")[0], DETAIL, "the finding as the artboard reported it");
163
+ assert.deepEqual(texts(quality(canvas), "gd-check-passed"), ["Passed: Target size · Images have alt text · Headings in order", "Passed: Text contrast · Target size · Images have alt text · Form fields have labels · Headings in order"]);
164
+ assert.equal(showButton(canvas, 0).getAttribute("aria-label"), "Show Low contrast on p.or in 01 First");
165
+ assert.equal(fixButton(canvas, 0).getAttribute("aria-label"), "Ask the agent to fix Low contrast on p.or");
166
+ assert.equal(withClass(quality(canvas), "gd-check-group")[0].getAttribute("aria-label"), "Accessibility checks of 01 First");
167
+ // The same report again (a resize with nothing new) leaves the count alone; a cleaner one lowers it.
168
+ report(canvas, first.frame, [finding()]);
169
+ assert.deepEqual([count(canvas), groups(canvas)[0]], ["1", "01 First: 1 check"]);
170
+ });
171
+
172
+ test("keyboard focus on a card's button survives a new report; a finding that went sends it to the Quality tab, never the page", async () => {
173
+ const canvas = await loadChecks();
174
+ const [first, second] = canvas.boards;
175
+ report(canvas, first.frame, [finding(), advice()]);
176
+ openQuality(canvas);
177
+ fixButton(canvas, 1).focus();
178
+ const focused = () => { const element = canvas.document.activeElement!; return element.id || `${element.dataset.control}:${element.dataset.key?.split("\n").at(-1)}`; };
179
+ assert.equal(focused(), "fix:#pay");
180
+ report(canvas, second.frame, [finding()]);
181
+ assert.equal(focused(), "fix:#pay", "another artboard's report re-renders Quality");
182
+ report(canvas, first.frame, [advice()]);
183
+ assert.equal(focused(), "fix:#pay", "the same finding, now first");
184
+ report(canvas, first.frame, []);
185
+ assert.equal(focused(), "gd-tab-quality");
186
+ });
187
+
188
+ test("reports from an unknown frame, a size frame or the system board are ignored, and a malformed one never throws or touches the status line", async () => {
189
+ const canvas = await loadChecks(SYSTEM_REPLY);
190
+ const [system, first, second] = canvas.frames();
191
+ $(canvas, "gd-status").textContent = "before";
192
+ canvas.message({}, checksReport([finding()]));
193
+ report(canvas, system, [finding()]);
194
+ const bad: unknown[] = [
195
+ { type: "gd:checks" },
196
+ { ...checksReport(), checks: "no" },
197
+ { ...checksReport(), issues: "no" },
198
+ { ...checksReport(), checks: [5] },
199
+ { ...checksReport(), checks: [null] },
200
+ { ...checksReport(), checks: [{ id: "contrast", count: -1, advice: 0 }] },
201
+ { ...checksReport(), checks: [{ id: "contrast", count: 1.5, advice: 0 }] },
202
+ { ...checksReport(), checks: [{ id: "contrast", count: 1, advice: 0 }, { id: "contrast", count: 1, advice: 0 }] },
203
+ { ...checksReport(), checks: Array.from({ length: 11 }, () => ({ id: "alt", count: 0, advice: 0 })) },
204
+ checksReport([finding({ rect: null })]),
205
+ checksReport([finding({ rect: { x: "1", y: 0, width: 1, height: 1 } })]),
206
+ checksReport([finding({ selector: "" })]),
207
+ checksReport([finding({ selector: "x".repeat(501) })]),
208
+ checksReport([finding({ title: 5 })]),
209
+ checksReport([finding({ severity: "boom" })]),
210
+ checksReport([finding({ check: "unknown" })]),
211
+ checksReport([finding({ excerpt: 5 })]),
212
+ checksReport([finding({ excerpt: undefined })]),
213
+ { ...checksReport(), issues: [null] },
214
+ { ...checksReport(), issues: [5] },
215
+ checksReport(Array.from({ length: 201 }, () => finding())),
216
+ ];
217
+ for (const data of bad) assert.doesNotThrow(() => canvas.message(second.contentWindow, data));
218
+ assert.deepEqual([count(canvas), $(canvas, "gd-status").textContent, $(canvas, "gd-status").classes.has("gd-error")], ["", "before", false]);
219
+ openQuality(canvas);
220
+ assert.deepEqual(groups(canvas), ["01 First: Not checked yet", "02 Second: Not checked yet"], "the system board has no group");
221
+
222
+ // In All sizes only the artboard's own frame speaks for it.
223
+ focusOn(canvas, 1);
224
+ chooseSize(canvas, "all");
225
+ for (const section of sizeSections(canvas)) report(canvas, iframeOf(section), [finding()]);
226
+ assert.equal(count(canvas), "", "size frames are not the artboard");
227
+ report(canvas, first, [finding()]);
228
+ assert.equal(count(canvas), "1");
229
+ });
230
+
231
+ test("a reload of an artboard drops its result until it reports again", async () => {
232
+ const canvas = await loadChecks();
233
+ const [first] = canvas.boards;
234
+ report(canvas, first.frame, [finding()]);
235
+ openQuality(canvas);
236
+ assert.deepEqual(groups(canvas)[0], "01 First: 1 check");
237
+ await canvas.serverEvent("change", { slug: "alpha", file: "01-a.html" });
238
+ first.frame.dispatch("load");
239
+ assert.deepEqual([groups(canvas)[0], count(canvas), cards(canvas).length], ["01 First: Not checked yet", "", 0]);
240
+ report(canvas, first.frame, []);
241
+ assert.deepEqual(groups(canvas)[0], "01 First: Accessible ✓");
242
+ });
243
+
244
+ test("a manifest reload builds new boards: Quality re-renders, the ring goes, and a card of an old board does nothing", async () => {
245
+ const canvas = await loadChecks();
246
+ report(canvas, canvas.boards[0].frame, [finding()]);
247
+ openQuality(canvas);
248
+ showCard(canvas, 0);
249
+ const staleShow = showButton(canvas, 0);
250
+ const staleFix = fixButton(canvas, 0);
251
+ assert.equal(marks(canvas).length, 1);
252
+ await canvas.serverEvent("change", { slug: "alpha", file: "design.json" });
253
+ assert.deepEqual([groups(canvas), count(canvas), marks(canvas).length], [["01 First: Not checked yet", "02 Second: Not checked yet"], "", 0]);
254
+ const fresh = canvas.frames();
255
+ const posted = fresh.map((frame) => frame.contentWindow!.posted.length);
256
+ staleShow.dispatch("click");
257
+ staleFix.dispatch("click");
258
+ assert.deepEqual([marks(canvas).length, $(canvas, "gd-popover").hidden, fresh.map((frame) => frame.contentWindow!.posted.length)], [0, true, posted], "nothing drawn, opened or highlighted");
259
+ // The old frame is no longer trusted; the new one is.
260
+ report(canvas, canvas.boards[0].frame, [finding()]);
261
+ assert.equal(count(canvas), "");
262
+ report(canvas, fresh[0], [finding()]);
263
+ assert.equal(count(canvas), "1");
264
+ });
265
+
266
+ test("a design switch clears Quality and the ring at once, by the design menu and by the server's show event", async () => {
267
+ for (const how of ["menu", "show"]) {
268
+ const canvas = await loadChecks();
269
+ report(canvas, canvas.boards[0].frame, [finding()]);
270
+ openQuality(canvas);
271
+ showCard(canvas, 0);
272
+ if (how === "menu") {
273
+ $(canvas, "gd-design").value = "beta";
274
+ $(canvas, "gd-design").dispatch("change");
275
+ } else canvas.serverEvent("show", { slug: "beta" });
276
+ assert.deepEqual([count(canvas), groups(canvas), marks(canvas).length], ["", [], 0], `${how}: nothing of alpha shows while beta loads`);
277
+ report(canvas, canvas.boards[0].frame, [finding()]);
278
+ assert.equal(count(canvas), "", `${how}: a late report of alpha's frame is ignored`);
279
+ await settle();
280
+ assert.deepEqual(groups(canvas), ["01 Only: Not checked yet"], `${how}: beta's artboard`);
281
+ }
282
+ });
283
+
284
+ // ---- Show and the ring
285
+
286
+ test("Show draws one ring on the canvas over the element, in its severity, and highlights it in the artboard", async () => {
287
+ const canvas = await loadChecks();
288
+ const [first, second] = canvas.boards;
289
+ report(canvas, first.frame, [finding(), advice()]);
290
+ report(canvas, second.frame, [finding({ selector: "#second" })]);
291
+ openQuality(canvas);
292
+ assert.equal(marks(canvas).length, 0);
293
+ showCard(canvas, 0);
294
+ assert.deepEqual([marks(canvas).length, ringIn(frameBox(canvas, 0)), markBox(canvas)], [1, 1, ["130px 50px 200px 20px"]], "centered on the rect, in artboard px, beside the frame in the world");
295
+ const ring = marks(canvas)[0];
296
+ assert.deepEqual([ring.getAttribute("aria-hidden"), ring.classes.has("gd-check-mark-fail"), texts(ring, "gd-check-mark-label")], ["true", true, ["Low contrast"]]);
297
+ assert.deepEqual([lastOf(first.frame, "gd:highlight"), activeCards(canvas)], [{ type: "gd:highlight", selector: "main > p.or", locate: true }, [0]], "the frame is asked where the element is once in view");
298
+ showCard(canvas, 1);
299
+ assert.deepEqual([marks(canvas).length, marks(canvas)[0].classes.has("gd-check-mark-advice"), markBox(canvas), activeCards(canvas)], [1, true, ["12px 251px 4px 2px"], [1]], "one ring at a time");
300
+ $(canvas, "gd-zoom-in").dispatch("click");
301
+ assert.deepEqual(markBox(canvas), ["12px 251px 4px 2px"], "a zoom keeps it");
302
+ showCard(canvas, 2);
303
+ assert.deepEqual([ringIn(frameBox(canvas, 0)), ringIn(frameBox(canvas, 1))], [0, 1], "another artboard's finding moves it there");
304
+ // A new report keeps the ring on the same finding at its new rect, or drops it.
305
+ report(canvas, second.frame, [advice(), finding({ selector: "#second", rect: { x: 0, y: 0, width: 50, height: 10 } })]);
306
+ assert.deepEqual([markBox(canvas), activeCards(canvas)], [["25px 5px 50px 10px"], [3]]);
307
+ report(canvas, second.frame, [advice()]);
308
+ assert.deepEqual([marks(canvas).length, activeCards(canvas)], [0, []]);
309
+ });
310
+
311
+ test("Show follows the element where its page scrolled it: the ring and the pan use the frame's located rect, not the checks' rect", async () => {
312
+ const canvas = await loadChecks();
313
+ const [first, second] = canvas.boards;
314
+ // The checks saw the element below the fold of its 300 px tall frame; Show scrolls the page to it.
315
+ report(canvas, first.frame, [finding({ rect: { x: 30, y: 900, width: 200, height: 20 } })]);
316
+ report(canvas, second.frame, [finding()]);
317
+ openQuality(canvas);
318
+ showCard(canvas, 0);
319
+ assert.deepEqual(lastOf(first.frame, "gd:highlight"), { type: "gd:highlight", selector: "main > p.or", locate: true });
320
+ assert.deepEqual([marks(canvas).length, marks(canvas)[0].hidden], [1, true], "never drawn below its frame, over the canvas or the next artboard");
321
+ const located = (frame: FakeElement, selector: string, y: number) => canvas.message(frame.contentWindow, { type: "gd:located", selector, rect: { x: 30, y, width: 200, height: 20 } });
322
+ // The frame where the view puts it now: where the element's center at y 250 is in the world.
323
+ const before = view(canvas);
324
+ first.frame.rect = { left: 100, top: 120, width: 400 * before.zoom, height: 300 * before.zoom };
325
+ const world = { x: (100 + 130 * before.zoom - before.x) / before.zoom, y: (120 + 260 * before.zoom - 50 - before.y) / before.zoom };
326
+ const lands = () => { const now = view(canvas); return [Math.round(now.x + world.x * now.zoom), Math.round(50 + now.y + world.y * now.zoom)]; };
327
+ located(first.frame, "main > p.or", 250);
328
+ assert.deepEqual([markBox(canvas), marks(canvas)[0].hidden, lands()], [["130px 260px 200px 20px"], false, [500, 400]], "the ring inside the frame, the element at the viewport's center");
329
+ const centered = view(canvas);
330
+ located(first.frame, "main > p.or", 100);
331
+ assert.deepEqual([markBox(canvas), marks(canvas)[0].hidden, view(canvas)], [["130px 110px 200px 20px"], false, centered], "a scroll moves the ring; only the first report re-centers");
332
+ located(first.frame, "main > p.or", 400);
333
+ assert.deepEqual([markBox(canvas), marks(canvas)[0].hidden], [["130px 410px 200px 20px"], true], "scrolled out of its frame: no ring outside it");
334
+ located(first.frame, "main > p.or", 100);
335
+ // Another board's frame, another selector or a malformed rect change nothing.
336
+ located(second.frame, "main > p.or", 20);
337
+ located(first.frame, "#other", 20);
338
+ canvas.message(first.frame.contentWindow, { type: "gd:located", selector: "main > p.or", rect: { x: "1", y: 20, width: 200, height: 20 } });
339
+ canvas.message(first.frame.contentWindow, { type: "gd:located", selector: "main > p.or" });
340
+ canvas.message({}, { type: "gd:located", selector: "main > p.or", rect: { x: 30, y: 20, width: 200, height: 20 } });
341
+ assert.deepEqual([markBox(canvas), view(canvas)], [["130px 110px 200px 20px"], centered]);
342
+ // A new report keeps the ring on its finding, at the rect the page reported then.
343
+ report(canvas, first.frame, [finding({ rect: { x: 30, y: 60, width: 200, height: 20 } })]);
344
+ assert.deepEqual(markBox(canvas), ["130px 70px 200px 20px"]);
345
+ // With no ring, a late report draws nothing.
346
+ press(canvas, "Escape");
347
+ located(first.frame, "main > p.or", 100);
348
+ assert.deepEqual([marks(canvas).length, view(canvas)], [0, centered]);
349
+ });
350
+
351
+ test("in All sizes the ring follows only the frame it is drawn on, the frame as designed", async () => {
352
+ const canvas = await loadChecks();
353
+ const [first] = canvas.boards;
354
+ report(canvas, first.frame, [finding({ rect: { x: 30, y: 900, width: 200, height: 20 } })]);
355
+ openQuality(canvas);
356
+ focusOn(canvas, 0);
357
+ chooseSize(canvas, "all");
358
+ showCard(canvas, 0);
359
+ const [phone, , designed] = sizeSections(canvas).map(iframeOf);
360
+ const located = (frame: FakeElement, y: number) => canvas.message(frame.contentWindow, { type: "gd:located", selector: "main > p.or", rect: { x: 30, y, width: 200, height: 20 } });
361
+ located(first.frame, 250);
362
+ located(phone, 250);
363
+ assert.deepEqual([markBox(canvas), marks(canvas)[0].hidden], [["130px 910px 200px 20px"], true], "the artboard's own frame, hidden behind, and the other sizes are not where the ring is");
364
+ located(designed, 250);
365
+ assert.deepEqual([markBox(canvas), marks(canvas)[0].hidden], [["130px 260px 200px 20px"], false]);
366
+ });
367
+
368
+ test("S5: in All sizes a new report from the artboard's own frame keeps the ring where the frame as designed located it", async () => {
369
+ const canvas = await loadChecks();
370
+ const [first] = canvas.boards;
371
+ report(canvas, first.frame, [finding()]);
372
+ openQuality(canvas);
373
+ focusOn(canvas, 0);
374
+ chooseSize(canvas, "all");
375
+ showCard(canvas, 0);
376
+ const designed = sizeSections(canvas).map(iframeOf).at(-1)!;
377
+ canvas.message(designed.contentWindow, { type: "gd:located", selector: "main > p.or", rect: { x: 30, y: 92, width: 200, height: 20 } });
378
+ assert.deepEqual([markBox(canvas), marks(canvas)[0].hidden], [["130px 102px 200px 20px"], false], "the ring where the frame as designed shows the element");
379
+ // The hidden own frame reports the same finding at its own coordinates: the displayed element has not moved.
380
+ report(canvas, first.frame, [finding({ title: "Lower contrast", rect: { x: 30, y: 252, width: 200, height: 20 } })]);
381
+ assert.deepEqual([markBox(canvas), marks(canvas)[0].hidden, texts(marks(canvas)[0], "gd-check-mark-label"), activeCards(canvas)], [["130px 102px 200px 20px"], false, ["Lower contrast"], [0]], "the same ring, on the same finding, still where it was located");
382
+ // The finding gone from a report still clears it.
383
+ report(canvas, first.frame, []);
384
+ assert.equal(marks(canvas).length, 0);
385
+ });
386
+
387
+ test("Show zooms in under 100% about the element and centers it, and never zooms out", async () => {
388
+ const canvas = await loadChecks();
389
+ const [first] = canvas.boards;
390
+ report(canvas, first.frame, [finding(), finding({ selector: "#page", rect: { x: 0, y: 0, width: 2000, height: 100 } })]);
391
+ openQuality(canvas);
392
+ /** Shows card `index` with the frame where the current view puts it; where the element's center lands, and the zoom. */
393
+ const showAt = (index: number, rect: { x: number; y: number; width: number; height: number }) => {
394
+ const before = view(canvas);
395
+ first.frame.rect = { left: 100, top: 120, width: 400 * before.zoom, height: 300 * before.zoom };
396
+ const x = 100 + (rect.x + rect.width / 2) * before.zoom;
397
+ const y = 120 + (rect.y + rect.height / 2) * before.zoom;
398
+ const world = { x: (x - before.x) / before.zoom, y: (y - 50 - before.y) / before.zoom };
399
+ showCard(canvas, index);
400
+ const after = view(canvas);
401
+ return { zoom: Number(after.zoom.toFixed(4)), lands: [Math.round(after.x + world.x * after.zoom), Math.round(50 + after.y + world.y * after.zoom)] };
402
+ };
403
+ $(canvas, "gd-zoom-out").dispatch("click");
404
+ $(canvas, "gd-zoom-out").dispatch("click");
405
+ assert.equal(view(canvas).zoom.toFixed(2), "0.64");
406
+ assert.deepEqual(showAt(0, finding().rect), { zoom: 1, lands: [500, 400] }, "to 100%, the element at the viewport's center");
407
+ $(canvas, "gd-zoom-out").dispatch("click");
408
+ assert.deepEqual(showAt(1, { x: 0, y: 0, width: 2000, height: 100 }), { zoom: 0.8, lands: [500, 400] }, "a wide element would fit only under 0.8: the zoom stays");
409
+ for (let i = 0; i < 4; i++) $(canvas, "gd-zoom-in").dispatch("click");
410
+ const zoomed = view(canvas).zoom;
411
+ assert.deepEqual(showAt(0, finding().rect), { zoom: Number(zoomed.toFixed(4)), lands: [500, 400] }, "over 100% it only centers");
412
+ });
413
+
414
+ test("a drag pans and keeps the ring; a still click on the canvas or an artboard clears it, and its card's mark", async () => {
415
+ const canvas = await loadChecks();
416
+ report(canvas, canvas.boards[0].frame, [finding()]);
417
+ openQuality(canvas);
418
+ showCard(canvas, 0);
419
+ const before = view(canvas);
420
+ canvas.viewport.dispatch("pointerdown", { button: 0, pointerId: 1, clientX: 500, clientY: 400 });
421
+ canvas.viewport.dispatch("pointermove", { pointerId: 1, clientX: 560, clientY: 430 });
422
+ canvas.viewport.dispatch("pointerup", { button: 0, pointerId: 1, clientX: 560, clientY: 430 });
423
+ assert.deepEqual([view(canvas).x - before.x, marks(canvas).length], [60, 1], "a pan moves the ring with the world");
424
+ canvas.viewport.dispatch("pointerdown", { button: 0, pointerId: 1, clientX: 500, clientY: 400 });
425
+ canvas.viewport.dispatch("pointerup", { button: 0, pointerId: 1, clientX: 501, clientY: 401 });
426
+ assert.deepEqual([marks(canvas).length, activeCards(canvas)], [0, []]);
427
+ showCard(canvas, 0);
428
+ const label = canvas.world.children[1].children[0];
429
+ label.dispatch("pointerdown", { button: 0, pointerId: 2, clientX: 700, clientY: 100 });
430
+ label.dispatch("pointerup", { button: 0, pointerId: 2, clientX: 700, clientY: 100 });
431
+ assert.equal(marks(canvas).length, 0, "a click on an artboard's header is on the canvas too");
432
+ });
433
+
434
+ test("a finding out of sight gets no ring: its card says why and Show centers the artboard", async () => {
435
+ const canvas = await loadChecks();
436
+ report(canvas, canvas.boards[0].frame, [finding({ check: "target", severity: "advice", title: "Small touch target", detail: '"Skip" is 120 × 20 px; WCAG 2.2 asks for 24 × 24 px, or enough space around it that a 24 px circle on it touches no other target.', selector: "#skip", hidden: true })]);
437
+ openQuality(canvas);
438
+ const note = withClass(cards(canvas)[0], "gd-check-hidden")[0];
439
+ assert.equal(note.textContent, "Out of sight (hidden or off-screen), so Show centers its artboard without a ring.");
440
+ assert.equal(showButton(canvas, 0).getAttribute("aria-describedby"), note.id);
441
+ showCard(canvas, 0);
442
+ assert.deepEqual([marks(canvas).length, lastOf(canvas.boards[0].frame, "gd:highlight")], [0, { type: "gd:highlight", selector: "#skip" }]);
443
+ });
444
+
445
+ test("the ring goes when its frame goes: another size, leaving All sizes, focus on another artboard, a reload", async () => {
446
+ const canvas = await loadChecks();
447
+ const [first] = canvas.boards;
448
+ report(canvas, first.frame, [finding()]);
449
+ openQuality(canvas);
450
+ focusOn(canvas, 0);
451
+ showCard(canvas, 0);
452
+ assert.deepEqual([ringIn(frameBox(canvas, 0)), lastOf(first.frame, "gd:highlight")], [1, { type: "gd:highlight", selector: "main > p.or", locate: true }], "in focus mode on the open artboard");
453
+ chooseSize(canvas, "phone");
454
+ assert.equal(marks(canvas).length, 0, "another size");
455
+ chooseSize(canvas, "all");
456
+ showCard(canvas, 0);
457
+ const sections = sizeSections(canvas);
458
+ assert.deepEqual(sections.map(ringIn), [0, 0, 1], "in All sizes, on the frame as designed, where the checks ran");
459
+ assert.deepEqual(sections.map((section) => lastOf(iframeOf(section), "gd:highlight")), [{ type: "gd:highlight", selector: "main > p.or" }, { type: "gd:highlight", selector: "main > p.or" }, { type: "gd:highlight", selector: "main > p.or", locate: true }], "the element is highlighted in every frame, and the ring's frame says where it is");
460
+ $(canvas, "gd-back").dispatch("click");
461
+ assert.deepEqual([marks(canvas).length, activeCards(canvas)], [0, []], "leaving focus mode drops the size frames and the ring");
462
+ focusOn(canvas, 0);
463
+ chooseSize(canvas, "all");
464
+ showCard(canvas, 0);
465
+ assert.equal(marks(canvas).length, 1);
466
+ iframeOf(sizeSections(canvas)[2]).dispatch("load");
467
+ assert.equal(marks(canvas).length, 0, "its frame reloads");
468
+ chooseSize(canvas, "desktop");
469
+ showCard(canvas, 0);
470
+ first.frame.dispatch("load");
471
+ assert.equal(marks(canvas).length, 0, "the artboard reloads");
472
+ });
473
+
474
+ test("Esc goes to the comment box, Compare and the dialogs first, then clears the ring, then the selected artboard, then Comment mode", async () => {
475
+ const canvas = await loadChecks();
476
+ const [first] = canvas.boards;
477
+ report(canvas, first.frame, [finding()]);
478
+ openQuality(canvas);
479
+ const label = canvas.world.children[1].children[0];
480
+ label.dispatch("pointerdown", { button: 0, pointerId: 1, clientX: 700, clientY: 100 });
481
+ label.dispatch("pointerup", { button: 0, pointerId: 1, clientX: 700, clientY: 100 });
482
+ const selected = () => canvas.world.children.flatMap((wrapper, index) => (wrapper.classes.has("gd-selected") ? [index] : []));
483
+ assert.deepEqual(selected(), [1]);
484
+ showCard(canvas, 0);
485
+ assert.equal(press(canvas, "Escape", { defaultPrevented: true }).defaultPrevented, true);
486
+ assert.equal(marks(canvas).length, 1, "an Esc something else took keeps the ring");
487
+ $(canvas, "gd-shortcuts").setAttribute("open", "");
488
+ press(canvas, "Escape");
489
+ assert.equal(marks(canvas).length, 1, "a dialog keeps its Esc");
490
+ $(canvas, "gd-shortcuts").removeAttribute("open");
491
+ $(canvas, "gd-popover").hidden = false;
492
+ press(canvas, "Escape");
493
+ assert.equal(marks(canvas).length, 1, "the comment box keeps its Esc");
494
+ $(canvas, "gd-popover").hidden = true;
495
+ assert.equal(press(canvas, "Escape", { shiftKey: true }).defaultPrevented, false, "Shift+Esc is not the ring's");
496
+ const first_ = press(canvas, "Escape");
497
+ assert.deepEqual([first_.defaultPrevented, marks(canvas).length, activeCards(canvas), selected()], [true, 0, [], [1]], "the ring first");
498
+ press(canvas, "Escape");
499
+ assert.deepEqual(selected(), [], "then the selected artboard");
500
+
501
+ // Comment mode: Esc in the canvas and Esc forwarded by an artboard clear the ring before leaving Comment mode.
502
+ $(canvas, "gd-comment").dispatch("click");
503
+ showCard(canvas, 0);
504
+ press(canvas, "Escape");
505
+ assert.deepEqual([marks(canvas).length, pressed(canvas, "gd-comment")], [0, "true"]);
506
+ press(canvas, "Escape");
507
+ assert.equal(pressed(canvas, "gd-comment"), "false");
508
+ $(canvas, "gd-comment").dispatch("click");
509
+ showCard(canvas, 0);
510
+ canvas.message(first.frame.contentWindow, { type: "gd:escape" });
511
+ assert.deepEqual([marks(canvas).length, pressed(canvas, "gd-comment")], [0, "true"]);
512
+ canvas.message(first.frame.contentWindow, { type: "gd:escape" });
513
+ assert.equal(pressed(canvas, "gd-comment"), "false");
514
+ });
515
+
516
+ test("clearing the ring clears the element's highlight in its page too: Esc, a still click, and in every All sizes frame", async () => {
517
+ const canvas = await loadChecks();
518
+ const [first, second] = canvas.boards;
519
+ report(canvas, first.frame, [finding()]);
520
+ openQuality(canvas);
521
+ const last = (frame: FakeElement) => frame.contentWindow!.posted.at(-1);
522
+ showCard(canvas, 0);
523
+ press(canvas, "Escape");
524
+ assert.deepEqual([marks(canvas).length, last(first.frame), lastOf(second.frame, "gd:clear")], [0, { type: "gd:clear" }, null], "Esc: only the ring's artboard");
525
+ showCard(canvas, 0);
526
+ canvas.viewport.dispatch("pointerdown", { button: 0, pointerId: 1, clientX: 500, clientY: 400 });
527
+ canvas.viewport.dispatch("pointerup", { button: 0, pointerId: 1, clientX: 500, clientY: 400 });
528
+ assert.deepEqual([marks(canvas).length, last(first.frame)], [0, { type: "gd:clear" }], "a still click");
529
+ showCard(canvas, 0);
530
+ canvas.viewport.dispatch("pointerdown", { button: 0, pointerId: 1, clientX: 500, clientY: 400 });
531
+ canvas.viewport.dispatch("pointermove", { pointerId: 1, clientX: 560, clientY: 430 });
532
+ canvas.viewport.dispatch("pointerup", { button: 0, pointerId: 1, clientX: 560, clientY: 430 });
533
+ assert.deepEqual([marks(canvas).length, last(first.frame)], [1, { type: "gd:highlight", selector: "main > p.or", locate: true }], "a drag pans and keeps both");
534
+ press(canvas, "Escape");
535
+ focusOn(canvas, 0);
536
+ chooseSize(canvas, "all");
537
+ showCard(canvas, 0);
538
+ press(canvas, "Escape");
539
+ assert.deepEqual([first.frame, ...sizeSections(canvas).map(iframeOf)].map(last), [{ type: "gd:clear" }, { type: "gd:clear" }, { type: "gd:clear" }, { type: "gd:clear" }]);
540
+ });
541
+
542
+ // ---- Ask the agent to fix
543
+
544
+ test("Ask the agent to fix opens the comment box on that artboard's element, prefilled and editable", async () => {
545
+ const canvas = await loadChecks();
546
+ const [first, second] = canvas.boards;
547
+ report(canvas, first.frame, [finding()]);
548
+ report(canvas, second.frame, [advice()]);
549
+ openQuality(canvas);
550
+ focusOn(canvas, 1);
551
+ fixButton(canvas, 0).dispatch("click");
552
+ assert.deepEqual([canvas.navMode.textContent, $(canvas, "gd-popover").hidden, $(canvas, "gd-popover-target").textContent], ["Navigating", false, "01-a.html · main > p.or"], "another artboard's focus ends first");
553
+ assert.equal($(canvas, "gd-popover-text").value, `Accessibility check on main > p.or: Low contrast.\n${DETAIL}\nFix it so it meets WCAG 2.2 AA, keeping the design's tokens.`);
554
+ assert.deepEqual(lastOf(first.frame, "gd:highlight"), { type: "gd:highlight", selector: "main > p.or" });
555
+ $(canvas, "gd-popover-text").value += "\nAlso on hover.";
556
+ $(canvas, "gd-popover-form").dispatch("submit");
557
+ await settle();
558
+ const body = canvas.posts.at(-1)!.body as Record<string, unknown>;
559
+ assert.deepEqual([body.file, body.selector, body.excerpt, String(body.comment).endsWith("Also on hover.")], ["01-a.html", "main > p.or", "or pay with card", true], "the element's text, as a pick sends it, not its CSS label");
560
+ report(canvas, first.frame, [finding({ excerpt: "x".repeat(400) })]);
561
+ fixButton(canvas, 0).dispatch("click");
562
+ $(canvas, "gd-popover-form").dispatch("submit");
563
+ await settle();
564
+ assert.equal((canvas.posts.at(-1)!.body as Record<string, unknown>).excerpt, "x".repeat(300), "bounded like a pick's excerpt");
565
+ fixButton(canvas, 1).dispatch("click");
566
+ assert.match($(canvas, "gd-popover-text").value, /^Accessibility advice on #pay: Touch target under 44 px\.\n"Pay" is 100 × 28 px; 44 × 44 px is recommended for touch\.\nConsider fixing it, keeping the design's tokens\.$/);
567
+ });
568
+
569
+ test("S4: a finding made at Phone keeps Phone's size when Ask the agent to fix files it after the switch to Tablet; a Phone report arriving late is dropped", async () => {
570
+ const canvas = await loadChecks();
571
+ const [first] = canvas.boards;
572
+ const phoneDetail = '"or pay with card" is 2.32 : 1 (#999999 on #ffffff); WCAG AA needs 4.5 : 1.';
573
+ const tabletDetail = '"or pay with card" is 4.47 : 1 (#767676 on #ffffff); WCAG AA needs 4.5 : 1.';
574
+ openQuality(canvas);
575
+ focusOn(canvas, 0);
576
+ chooseSize(canvas, "phone");
577
+ const phoneGeneration = heardGeneration(first.frame);
578
+ report(canvas, first.frame, [finding({ detail: phoneDetail })]);
579
+ chooseSize(canvas, "tablet");
580
+ // The page's scan from before it heard of Tablet arrives now: it describes Phone and changes nothing.
581
+ report(canvas, first.frame, [finding({ detail: "late" })], phoneGeneration);
582
+ assert.deepEqual(texts(quality(canvas), "gd-check-detail"), [phoneDetail], "the late Phone report is dropped");
583
+ // Before Tablet's own scan, the retained Phone finding is filed with the size it was found at.
584
+ fixButton(canvas, 0).dispatch("click");
585
+ assert.match($(canvas, "gd-popover-text").value, /2\.32 : 1/);
586
+ $(canvas, "gd-popover-form").dispatch("submit");
587
+ await settle();
588
+ let body = canvas.posts.at(-1)!.body as Record<string, unknown>;
589
+ assert.deepEqual([body.selector, body.viewport], ["main > p.or", { width: 390, height: 844 }], "Phone's finding, Phone's size");
590
+ // Tablet's scan arrives: its finding is filed with Tablet's size.
591
+ report(canvas, first.frame, [finding({ detail: tabletDetail })]);
592
+ fixButton(canvas, 0).dispatch("click");
593
+ assert.match($(canvas, "gd-popover-text").value, /4\.47 : 1/);
594
+ $(canvas, "gd-popover-form").dispatch("submit");
595
+ await settle();
596
+ body = canvas.posts.at(-1)!.body as Record<string, unknown>;
597
+ assert.deepEqual(body.viewport, { width: 820, height: 1180 });
598
+ });
599
+
600
+ test("in All sizes Ask the agent to fix asks on the frame as designed, with no size recorded", async () => {
601
+ const canvas = await loadChecks();
602
+ report(canvas, canvas.boards[0].frame, [finding()]);
603
+ openQuality(canvas);
604
+ focusOn(canvas, 0);
605
+ chooseSize(canvas, "all");
606
+ fixButton(canvas, 0).dispatch("click");
607
+ $(canvas, "gd-popover-form").dispatch("submit");
608
+ await settle();
609
+ const body = canvas.posts.at(-1)!.body as Record<string, unknown>;
610
+ assert.deepEqual([body.selector, Object.hasOwn(body, "viewport")], ["main > p.or", false]);
611
+ });
612
+
613
+ // ---- module rules, markup, styles and docs
614
+
615
+ test("canvas-checks.js keeps its words in one TEXT block, changes state only through the store, and runs before the layout's Esc", () => {
616
+ const source = read("canvas-checks.js");
617
+ assert.match(source, /^const TEXT = Object\.freeze\(\{$/m);
618
+ assert.ok(!/(?:textContent|title) = ["'`]/.test(source), "every visible string comes from TEXT");
619
+ assert.ok(!/\bstate\.\w+\s*=[^=]/.test(source), "state changes only through the store");
620
+ assert.ok(source.includes("they are heuristics, not a full audit"), "the module header says what the checks are");
621
+ const boot = read("canvas-boot.js");
622
+ const modules = /const MODULES = \[([^\]]*)\]/.exec(boot)![1].split(",").map((name) => name.trim());
623
+ assert.ok(modules.indexOf("checks") >= 0 && modules.indexOf("checks") < modules.indexOf("layout"), "its Esc listener comes before the layout's");
624
+ const store = read("canvas-store.js").replace(/\n\/\/ ?/g, " ");
625
+ assert.ok(store.includes("board.checks") && store.includes("setChecks"), "the store header names board.checks and its one mutator");
626
+ });
627
+
628
+ test("index.html has the tabs, the Quality panel and the Show icon; canvas.css styles them on --gd-* tokens and hides the ring in exports", () => {
629
+ const html = read("index.html");
630
+ // Each tab's word in its own keyed span (ES.html), so the language never wipes its count.
631
+ assert.match(html, /<div id="gd-tabs" class="gd-tabs" role="tablist" aria-label="Review" data-i18n-aria-label="review">/);
632
+ assert.match(html, /<button type="button" role="tab" id="gd-tab-comments" class="gd-tab" aria-selected="true" aria-controls="gd-tabpanel-comments"><span data-i18n="tabComments">Comments<\/span> <span id="gd-count-comments" class="gd-count">0<\/span><\/button>/);
633
+ assert.match(html, /<button type="button" role="tab" id="gd-tab-quality" class="gd-tab" aria-selected="false" aria-controls="gd-quality" tabindex="-1"><span data-i18n="quality">Quality<\/span> <span id="gd-count-quality" class="gd-count"><\/span><\/button>/);
634
+ assert.match(html, /<div id="gd-quality" class="gd-quality" role="tabpanel" aria-labelledby="gd-tab-quality" hidden><\/div>/);
635
+ assert.match(html, /<div id="gd-tabpanel-comments" class="gd-tabpanel" role="tabpanel" aria-labelledby="gd-tab-comments">/);
636
+ assert.match(html, /<symbol id="i-target" viewBox="0 0 24 24">/);
637
+ const css = read("canvas.css");
638
+ const rules = css.split("}").filter((rule) => /(^|\n)\.gd-(check|tab|quality|count)/.test(rule.trim().split("{")[0]));
639
+ assert.ok(rules.length >= 10, "the tabs, the cards and the ring are styled");
640
+ for (const rule of rules) {
641
+ assert.ok(!/#[0-9a-fA-F]{3,8}\b|rgba?\(|hsla?\(/.test(rule), `${rule.trim()}: tokens only`);
642
+ for (const name of rule.match(/var\((--[\w-]+)/g) ?? []) assert.ok(name.startsWith("var(--gd-"), `${name}: a --gd-* token`);
643
+ assert.ok(!/::before|::after|50%\s*;/.test(rule) || /translate\(-50%, -50%\)/.test(rule), `${rule.trim()}: no dots (S4)`);
644
+ }
645
+ assert.match(css, /\.gd-check-mark \{[^}]*border: calc\(2px \* var\(--gd-inv-zoom, 1\)\) solid/, "the ring keeps its screen width at any zoom");
646
+ assert.match(css, /\.gd-exporting \.gd-check-mark \{ visibility: hidden; \}/);
647
+ });
648
+
649
+ test("the docs describe the Quality tab, Show and the checks' limits in the heuristics note", () => {
650
+ const docs = readFileSync(fileURLToPath(new URL("../docs/gentle-shell.md", import.meta.url)), "utf8");
651
+ const section = docs.slice(docs.indexOf("### Gentle Design"), docs.indexOf("### Gentle Music"));
652
+ assert.ok(section.includes("The checks run inside the artboard's own frame, so they describe the artboard at the size it is shown, and they are heuristics, not a full audit: they miss keyboard, focus-order, motion and screen-reader problems, each list is capped (20 problems and 10 advice items per check, with the full count reported), and a page with more than 3000 elements is checked only up to its 3000th, so its counts cover that part only."));
653
+ assert.ok(section.includes("The ring follows the element as its page scrolls"), "the docs say the ring follows the element");
654
+ for (const words of ["**Quality**", "**Comments**", "**Show**", "**Ask the agent to fix**", "`Accessible ✓`"]) assert.ok(section.includes(words), `the Gentle Design docs mention ${words}`);
655
+ });