gentle-pi 4.6.0 → 4.8.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 (536) hide show
  1. package/README.md +65 -55
  2. package/assets/agents/gentle-ai-explore.md +4 -3
  3. package/assets/agents/gentle-ai-verify.md +23 -6
  4. package/assets/agents/gentle-ai-worker.md +9 -6
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +2 -3
  7. package/assets/agents/jd-judge-b.md +2 -3
  8. package/assets/agents/review-readability.md +1 -5
  9. package/assets/agents/review-reliability.md +1 -5
  10. package/assets/agents/review-resilience.md +1 -5
  11. package/assets/agents/review-risk.md +1 -5
  12. package/assets/design-canvas/canvas-api.js +45 -0
  13. package/assets/design-canvas/canvas-boards.js +456 -0
  14. package/assets/design-canvas/canvas-boot.js +217 -0
  15. package/assets/design-canvas/canvas-checks.js +491 -0
  16. package/assets/design-canvas/canvas-comments.js +315 -0
  17. package/assets/design-canvas/canvas-compare.js +159 -0
  18. package/assets/design-canvas/canvas-events.js +75 -0
  19. package/assets/design-canvas/canvas-export.js +393 -0
  20. package/assets/design-canvas/canvas-focus.js +203 -0
  21. package/assets/design-canvas/canvas-handoffs.js +150 -0
  22. package/assets/design-canvas/canvas-i18n-es.js +392 -0
  23. package/assets/design-canvas/canvas-i18n.js +108 -0
  24. package/assets/design-canvas/canvas-layout.js +526 -0
  25. package/assets/design-canvas/canvas-menu.js +213 -0
  26. package/assets/design-canvas/canvas-messages.js +86 -0
  27. package/assets/design-canvas/canvas-minimap.js +163 -0
  28. package/assets/design-canvas/canvas-parts.js +401 -0
  29. package/assets/design-canvas/canvas-popover.js +234 -0
  30. package/assets/design-canvas/canvas-rail.js +348 -0
  31. package/assets/design-canvas/canvas-sizes.js +524 -0
  32. package/assets/design-canvas/canvas-store.js +164 -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 +759 -16
  37. package/assets/design-canvas/canvas.js +2 -1497
  38. package/assets/design-canvas/index.html +117 -36
  39. package/assets/design-canvas/inspector.js +546 -16
  40. package/assets/install-wizard/wizard.js +6 -1
  41. package/assets/migrations/agent-body-history.json +40 -1
  42. package/assets/orchestrator-delegation-reference.md +10 -16
  43. package/assets/orchestrator-delegation.md +5 -5
  44. package/assets/orchestrator-full-delegation-card.md +64 -0
  45. package/assets/orchestrator-full-delegation.md +34 -0
  46. package/assets/orchestrator-memory.md +5 -5
  47. package/assets/orchestrator-prompts.md +2 -2
  48. package/assets/orchestrator-quota-recovery.md +5 -0
  49. package/assets/orchestrator-skills.md +14 -13
  50. package/assets/orchestrator-tracking.md +10 -14
  51. package/assets/orchestrator-verification.md +12 -8
  52. package/assets/orchestrator-writer.md +4 -4
  53. package/assets/orchestrator.md +21 -25
  54. package/bin/gentle-shell.mjs +292 -65
  55. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
  56. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
  57. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
  58. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
  59. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
  60. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
  61. package/docs/agent-status.md +61 -0
  62. package/docs/assets/brand/sponsor-banner.svg +60 -0
  63. package/docs/bundled-install.md +20 -10
  64. package/docs/delegated-verification.md +46 -8
  65. package/docs/desktop-rpc.md +1253 -0
  66. package/docs/gentle-agents-activity.md +40 -0
  67. package/docs/gentle-shell.md +91 -30
  68. package/docs/install-wizard.md +30 -21
  69. package/docs/odd-preparation-continuity.md +24 -0
  70. package/docs/permission-modes.md +17 -4
  71. package/docs/prompt-budget.md +12 -0
  72. package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
  73. package/docs/readme-reference.md +142 -45
  74. package/docs/render-cache-performance.md +11 -1
  75. package/docs/review-coordinator.md +53 -0
  76. package/docs/review-delivery-preflight.md +22 -0
  77. package/docs/review-request-context.md +19 -0
  78. package/docs/review-windows-acl.md +18 -0
  79. package/docs/voice.md +6 -3
  80. package/docs/work-continuity.md +11 -1
  81. package/docs/yolo-mode.md +5 -5
  82. package/extensions/ask-user-choice.ts +1 -0
  83. package/extensions/ask-user-question.ts +3 -2
  84. package/extensions/child-context.ts +21 -7
  85. package/extensions/child-safety.ts +3 -0
  86. package/extensions/gentle-agent-status.ts +99 -0
  87. package/extensions/gentle-agents.ts +559 -66
  88. package/extensions/gentle-ai.ts +2001 -518
  89. package/extensions/gentle-design.ts +69 -3
  90. package/extensions/gentle-desktop-rpc.ts +143 -0
  91. package/extensions/gentle-guide.ts +3 -0
  92. package/extensions/gentle-shell.ts +398 -115
  93. package/extensions/gentle-todo.ts +66 -27
  94. package/extensions/gentle-tps.ts +48 -0
  95. package/extensions/quiet-tools.ts +38 -8
  96. package/extensions/skill-registry.ts +349 -167
  97. package/extensions/startup-banner.ts +30 -3
  98. package/lib/agent-assets.ts +30 -6
  99. package/lib/agent-profile-pin.ts +3 -3
  100. package/lib/agent-profiles.ts +160 -2
  101. package/lib/agent-status.ts +105 -0
  102. package/lib/agent-tool-overlay.ts +117 -0
  103. package/lib/agents-config.ts +93 -6
  104. package/lib/agents-history.ts +24 -5
  105. package/lib/agents-message-delivery.ts +17 -0
  106. package/lib/agents-messaging.ts +55 -7
  107. package/lib/agents-protocol.ts +15 -0
  108. package/lib/agents-report-cap.ts +115 -0
  109. package/lib/agents-runner.ts +272 -16
  110. package/lib/agents-session-transport.ts +17 -1
  111. package/lib/auto-permission-runtime.ts +1 -1
  112. package/lib/background-jobs-tools.ts +9 -4
  113. package/lib/bounded-writer-admission.ts +197 -32
  114. package/lib/card-content-policy.ts +8 -6
  115. package/lib/child-context-files.ts +21 -6
  116. package/lib/codemode-renderer.ts +1 -0
  117. package/lib/command-palette.ts +133 -17
  118. package/lib/context-backstop.ts +14 -5
  119. package/lib/delivery-conflict-markers.ts +349 -0
  120. package/lib/design-canvas-assets.ts +36 -0
  121. package/lib/design-canvas-server.ts +241 -23
  122. package/lib/design-comments.ts +94 -4
  123. package/lib/design-handoffs.ts +2 -1
  124. package/lib/design-layout.ts +125 -0
  125. package/lib/design-parts.ts +281 -0
  126. package/lib/design-system-tokens.ts +111 -0
  127. package/lib/desktop-agents-service.ts +294 -0
  128. package/lib/desktop-design-service.ts +233 -0
  129. package/lib/desktop-jobs-service.ts +263 -0
  130. package/lib/desktop-rpc-agents.ts +294 -0
  131. package/lib/desktop-rpc-config.ts +731 -0
  132. package/lib/desktop-rpc-design.ts +138 -0
  133. package/lib/desktop-rpc-jobs.ts +181 -0
  134. package/lib/desktop-rpc-permissions.ts +177 -0
  135. package/lib/desktop-rpc-profiles.ts +196 -0
  136. package/lib/desktop-rpc-usage.ts +229 -0
  137. package/lib/desktop-rpc.ts +225 -0
  138. package/lib/desktop-usage-service.ts +310 -0
  139. package/lib/destructive-command-guard.ts +236 -17
  140. package/lib/execution-surface-guard.ts +20 -0
  141. package/lib/exploration-budget.ts +4 -2
  142. package/lib/gentle-ai-binary.ts +1 -1
  143. package/lib/gentle-ai-renderer.ts +13 -1
  144. package/lib/gentle-design.ts +204 -14
  145. package/lib/gentle-shell-bundled.ts +106 -28
  146. package/lib/gentle-shell-launcher.ts +43 -8
  147. package/lib/herdr-activity.ts +14 -2
  148. package/lib/herdr-busy.ts +45 -0
  149. package/lib/hidden-tools.ts +35 -0
  150. package/lib/image-attachments.ts +33 -0
  151. package/lib/image-disk-cache.ts +137 -0
  152. package/lib/inprocess-reviewer.ts +358 -144
  153. package/lib/jobs-view.ts +198 -11
  154. package/lib/model-fallback-policy.ts +9 -0
  155. package/lib/model-routing-authority.ts +31 -4
  156. package/lib/nan-provider.ts +42 -28
  157. package/lib/native-choice-list.ts +20 -2
  158. package/lib/native-review-cli.ts +172 -20
  159. package/lib/orchestrator-discovery.ts +39 -2
  160. package/lib/orchestrator-mode-policy.ts +105 -0
  161. package/lib/questionnaire/questionnaire-view.ts +105 -12
  162. package/lib/rdd-mode-control.ts +32 -0
  163. package/lib/reply-language-anchor.ts +129 -0
  164. package/lib/request-context-placement.ts +53 -0
  165. package/lib/review-blocker.ts +92 -0
  166. package/lib/review-candidate-symlink-scan.ts +136 -0
  167. package/lib/review-candidate-view-owner.ts +81 -44
  168. package/lib/review-candidate-view.ts +11 -1
  169. package/lib/review-continuation-registry.ts +116 -0
  170. package/lib/review-coordinator.ts +407 -0
  171. package/lib/review-delivery-preflight.ts +85 -0
  172. package/lib/review-failure-facts.ts +49 -0
  173. package/lib/review-host-relay.ts +51 -11
  174. package/lib/review-integration-v2.ts +63 -4
  175. package/lib/review-relay-phase-timing.ts +45 -0
  176. package/lib/review-start-context.ts +17 -0
  177. package/lib/reviewer-stream.ts +87 -0
  178. package/lib/session-profile-freeze.ts +4 -2
  179. package/lib/shell-bar.ts +140 -58
  180. package/lib/shell-changes.ts +2 -0
  181. package/lib/shell-panel.ts +17 -3
  182. package/lib/shell-prompt.ts +16 -3
  183. package/lib/shell-sidebar-layout.ts +112 -40
  184. package/lib/shell-sidebar.ts +7 -0
  185. package/lib/shell-todo.ts +10 -3
  186. package/lib/shell-usage.ts +10 -0
  187. package/lib/verifier-admission.ts +1 -1
  188. package/lib/vim-editor-adapter.ts +9 -2
  189. package/lib/visual-customization-policy.ts +36 -16
  190. package/lib/visual-customize-view.ts +216 -21
  191. package/lib/visual-layout-preview.ts +9 -5
  192. package/lib/visual-profiles.ts +2 -2
  193. package/lib/windows-session-transport.ts +53 -2
  194. package/lib/writer-batch-admission.ts +55 -0
  195. package/lib/yolo-session-policy.ts +46 -16
  196. package/package.json +3 -2
  197. package/prompts/skill-creation.md +1 -10
  198. package/runtime/design-canvas-assets.mjs +37 -0
  199. package/runtime/gentle-ai-binary.mjs +1 -1
  200. package/runtime/gentle-shell-bundled.mjs +106 -28
  201. package/runtime/gentle-shell-launcher.mjs +42 -7
  202. package/runtime/native-review-cli.mjs +169 -17
  203. package/runtime/review-integration-v2.mjs +63 -4
  204. package/scripts/bootstrap.cmd +2 -2
  205. package/scripts/bootstrap.sh +41 -4
  206. package/scripts/build-full-delegation-card.mjs +179 -0
  207. package/scripts/build-runtime-modules.mjs +1 -0
  208. package/scripts/bundled-install.mjs +38 -8
  209. package/scripts/download-progress.mjs +68 -0
  210. package/scripts/gentle-ai-installer.mjs +41 -18
  211. package/scripts/gentle-ai-proxy.mjs +294 -0
  212. package/scripts/install-gentle-ai.mjs +14 -1
  213. package/scripts/installer-downloads.mjs +34 -8
  214. package/scripts/installer-preflight.mjs +33 -22
  215. package/scripts/installer-probes.mjs +25 -5
  216. package/scripts/installer-runner.mjs +27 -12
  217. package/scripts/installer-server.mjs +46 -16
  218. package/scripts/installer-windows.mjs +2 -2
  219. package/scripts/pi-update.mjs +166 -27
  220. package/scripts/prepare-verifier.mjs +107 -0
  221. package/scripts/render-cache-host.mjs +72 -0
  222. package/scripts/render-cache-performance-worker.mjs +5 -4
  223. package/scripts/render-cache-performance.mjs +6 -1
  224. package/scripts/run-test-suite.mjs +40 -28
  225. package/scripts/update-agent-body-history.mjs +55 -8
  226. package/scripts/verify-package-files.mjs +50 -19
  227. package/scripts/voice-worker.cjs +32 -6
  228. package/skills/branch-pr/SKILL.md +16 -16
  229. package/skills/comment-writer/SKILL.md +1 -1
  230. package/skills/design/SKILL.md +16 -13
  231. package/skills/gentle-ai/SKILL.md +7 -7
  232. package/skills/gentle-ui-design/SKILL.md +46 -0
  233. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  234. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  235. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  236. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  237. package/skills/judgment-day/SKILL.md +2 -2
  238. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  239. package/skills/rdd-defect-workflow/SKILL.md +6 -6
  240. package/skills/skill-improver/SKILL.md +2 -2
  241. package/skills/skill-registry/SKILL.md +11 -11
  242. package/skills/tui-design/SKILL.md +1 -1
  243. package/skills/work-unit-commits/SKILL.md +10 -11
  244. package/tests/agent-home.test.ts +28 -9
  245. package/tests/agent-profiles-workflow.test.ts +163 -0
  246. package/tests/agent-prompt-diet-contract.test.ts +101 -0
  247. package/tests/agent-risk-escalation.test.ts +1 -1
  248. package/tests/agent-status.test.ts +143 -0
  249. package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
  250. package/tests/agent-tool-overlay.test.ts +89 -0
  251. package/tests/agents-config.test.ts +106 -1
  252. package/tests/agents-history.test.ts +31 -0
  253. package/tests/agents-jobs-frames.test.ts +93 -0
  254. package/tests/agents-message-delivery.test.ts +36 -0
  255. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  256. package/tests/agents-queries.test.ts +144 -4
  257. package/tests/agents-report-cap.test.ts +126 -0
  258. package/tests/agents-runner-drain.test.ts +193 -0
  259. package/tests/agents-runner.test.ts +215 -3
  260. package/tests/agents-session-transport.test.ts +34 -0
  261. package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
  262. package/tests/append-system-prompt-route.test.ts +12 -1
  263. package/tests/approved-text-leftovers-contract.test.ts +136 -0
  264. package/tests/artifact-language.test.ts +1 -1
  265. package/tests/ask-user-choice.test.ts +4 -3
  266. package/tests/ask-user-question.test.ts +99 -1
  267. package/tests/audit-leftovers-contract.test.ts +51 -0
  268. package/tests/auto-permission-runtime.test.ts +1 -1
  269. package/tests/autonomous-guard.test.ts +346 -10
  270. package/tests/bounded-stop-contract.test.ts +51 -3
  271. package/tests/branch-pr-skill.test.ts +10 -1
  272. package/tests/bridge-cost.test.ts +19 -4
  273. package/tests/bundled-install.test.ts +31 -6
  274. package/tests/card-content-policy.test.ts +3 -3
  275. package/tests/chained-pr-skill.test.ts +8 -6
  276. package/tests/child-context-files.test.ts +64 -8
  277. package/tests/child-safety.test.ts +11 -0
  278. package/tests/child-skills-catalog.test.ts +56 -0
  279. package/tests/codegraph-tools.test.ts +11 -5
  280. package/tests/codemode-rendering.test.ts +4 -1
  281. package/tests/command-palette.test.ts +284 -1
  282. package/tests/delegate-for-reason-contract.test.ts +32 -10
  283. package/tests/delivery-conflict-markers.test.ts +348 -0
  284. package/tests/design-canvas-all-sizes.test.ts +631 -0
  285. package/tests/design-canvas-allowlist.test.ts +32 -0
  286. package/tests/design-canvas-assets.test.ts +11 -695
  287. package/tests/design-canvas-boards.test.ts +77 -0
  288. package/tests/design-canvas-checks.test.ts +655 -0
  289. package/tests/design-canvas-compare.test.ts +79 -0
  290. package/tests/design-canvas-events.test.ts +59 -0
  291. package/tests/design-canvas-export.test.ts +1168 -0
  292. package/tests/design-canvas-focus.test.ts +113 -0
  293. package/tests/design-canvas-handoffs.test.ts +59 -0
  294. package/tests/design-canvas-i18n-review.test.ts +513 -0
  295. package/tests/design-canvas-i18n-views.test.ts +259 -0
  296. package/tests/design-canvas-i18n.test.ts +526 -0
  297. package/tests/design-canvas-inspector.test.ts +937 -0
  298. package/tests/design-canvas-layout.test.ts +1222 -0
  299. package/tests/design-canvas-minimap.test.ts +413 -0
  300. package/tests/design-canvas-modules.test.ts +90 -0
  301. package/tests/design-canvas-parts.test.ts +721 -0
  302. package/tests/design-canvas-rail.test.ts +799 -0
  303. package/tests/design-canvas-server.test.ts +855 -17
  304. package/tests/design-canvas-sizes.test.ts +548 -0
  305. package/tests/design-canvas-store.test.ts +180 -0
  306. package/tests/design-canvas-tokens.test.ts +965 -0
  307. package/tests/design-canvas-view.test.ts +299 -0
  308. package/tests/design-comments.test.ts +201 -1
  309. package/tests/design-handoffs.test.ts +20 -0
  310. package/tests/design-layout.test.ts +100 -0
  311. package/tests/design-parts.test.ts +260 -0
  312. package/tests/design-system-tokens.test.ts +215 -0
  313. package/tests/desktop-rpc-agents.test.ts +893 -0
  314. package/tests/desktop-rpc-config.test.ts +1452 -0
  315. package/tests/desktop-rpc-design.test.ts +662 -0
  316. package/tests/desktop-rpc-jobs.test.ts +796 -0
  317. package/tests/desktop-rpc-permissions.test.ts +311 -0
  318. package/tests/desktop-rpc-profiles.test.ts +140 -0
  319. package/tests/desktop-rpc-safety.test.ts +119 -0
  320. package/tests/desktop-rpc-usage.test.ts +697 -0
  321. package/tests/desktop-rpc.test.ts +252 -0
  322. package/tests/destructive-command-guard.test.ts +52 -0
  323. package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
  324. package/tests/devbinary/review-session-consent.devtest.ts +84 -0
  325. package/tests/download-progress.test.ts +71 -0
  326. package/tests/engram-safety.test.ts +111 -0
  327. package/tests/execution-surface-guard.test.ts +55 -0
  328. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
  329. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
  330. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
  331. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  332. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  333. package/tests/fixtures/refusal-identity.probe.mjs +139 -0
  334. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  335. package/tests/fixtures/session-profile-v1/replay.ts +53 -6
  336. package/tests/full-delegation-closure.test.ts +160 -0
  337. package/tests/full-delegation-notices.test.ts +76 -0
  338. package/tests/generic-agent-tools.test.ts +3 -3
  339. package/tests/gentle-agent-status.test.ts +74 -0
  340. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  341. package/tests/gentle-agents.test.ts +1403 -20
  342. package/tests/gentle-ai-binary.test.ts +3 -1
  343. package/tests/gentle-ai-child-guards.test.ts +1 -0
  344. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  345. package/tests/gentle-ai-exploration-budget.test.ts +18 -2
  346. package/tests/gentle-ai-installer.test.ts +135 -51
  347. package/tests/gentle-ai-proxy.test.ts +434 -0
  348. package/tests/gentle-ai-renderer.test.ts +36 -2
  349. package/tests/gentle-ai.test.ts +233 -43
  350. package/tests/gentle-design.test.ts +386 -1
  351. package/tests/gentle-herdr-activity.test.ts +9 -6
  352. package/tests/gentle-shell-bin.test.ts +123 -0
  353. package/tests/gentle-shell-bundled.test.ts +293 -31
  354. package/tests/gentle-shell-launcher.test.ts +78 -11
  355. package/tests/gentle-shell.test.ts +1017 -146
  356. package/tests/gentle-todo.test.ts +51 -11
  357. package/tests/gentle-tps.test.ts +123 -0
  358. package/tests/gentle-ui-design-skill.test.ts +59 -0
  359. package/tests/herdr-busy.test.ts +59 -0
  360. package/tests/herdr-task-summary-policy.test.ts +8 -4
  361. package/tests/hidden-tools.test.ts +188 -0
  362. package/tests/image-disk-cache.test.ts +163 -0
  363. package/tests/independent-recovery-delivery.test.ts +97 -0
  364. package/tests/inprocess-reviewer.test.ts +249 -4
  365. package/tests/install-wizard.test.ts +27 -1
  366. package/tests/installer-downloads.test.ts +30 -1
  367. package/tests/installer-posix-bootstrap.test.ts +115 -14
  368. package/tests/installer-preflight.test.ts +54 -5
  369. package/tests/installer-probes.test.ts +146 -0
  370. package/tests/installer-runner.test.ts +79 -44
  371. package/tests/installer-server.test.ts +215 -13
  372. package/tests/installer-windows-bootstrap.test.ts +19 -1
  373. package/tests/jobs-view.test.ts +260 -6
  374. package/tests/judgment-day-severity-admission.test.ts +46 -0
  375. package/tests/lazy-module-contradictions-contract.test.ts +158 -0
  376. package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
  377. package/tests/maintainer/pi-update-source.maintest.ts +48 -18
  378. package/tests/modal-mouse-boundaries.test.ts +136 -0
  379. package/tests/model-fallback-policy.test.ts +26 -7
  380. package/tests/model-routing-authority.test.ts +178 -2
  381. package/tests/nan-provider-runtime.test.ts +17 -3
  382. package/tests/nan-provider.test.ts +111 -56
  383. package/tests/native-choice-list.test.ts +77 -2
  384. package/tests/native-review-capability-contract.test.ts +17 -1
  385. package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
  386. package/tests/native-review-cli.test.ts +269 -1
  387. package/tests/native-review-parity.test.ts +24 -5
  388. package/tests/native-review-refusal-identity.test.ts +25 -0
  389. package/tests/no-self-pause-contract.test.ts +13 -2
  390. package/tests/odd-integration.test.ts +11 -3
  391. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  392. package/tests/odd-routing-contract.test.ts +80 -28
  393. package/tests/orchestrator-budget.test.ts +35 -5
  394. package/tests/orchestrator-consultation-sdk.test.ts +32 -6
  395. package/tests/orchestrator-delegation-mode.test.ts +154 -0
  396. package/tests/orchestrator-discovery.test.ts +28 -0
  397. package/tests/orchestrator-mode-policy.test.ts +175 -0
  398. package/tests/orchestrator-prompt-budget.test.ts +13 -2
  399. package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
  400. package/tests/orchestrator-rdd-ownership.test.ts +4 -3
  401. package/tests/orchestrator-work-search.test.ts +4 -2
  402. package/tests/package-files.test.ts +25 -1
  403. package/tests/package-manifest.test.ts +16 -13
  404. package/tests/parallel-reason-contract.test.ts +6 -3
  405. package/tests/permission-allowlist.test.ts +372 -0
  406. package/tests/persona-neutral-voseo.test.ts +4 -4
  407. package/tests/persona-reply-language.test.ts +1 -1
  408. package/tests/persona-single-channel.test.ts +13 -5
  409. package/tests/pi-update-launcher.test.ts +25 -7
  410. package/tests/pi-update-source.test.ts +113 -6
  411. package/tests/pi-update.test.ts +294 -19
  412. package/tests/pnpm-workspace-config.test.ts +58 -0
  413. package/tests/pnpm-workspace-policy.test.ts +47 -0
  414. package/tests/primary-context-files.test.ts +233 -0
  415. package/tests/primary-context-three-files.test.ts +174 -0
  416. package/tests/primary-session-prompt.test.ts +13 -0
  417. package/tests/profile-pin.test.ts +29 -2
  418. package/tests/profile-tier-footer.test.ts +5 -0
  419. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  420. package/tests/provider-defect-handoff.test.ts +9 -2
  421. package/tests/questionnaire-view.test.ts +115 -0
  422. package/tests/quiet-bash-runtime.test.ts +1 -1
  423. package/tests/quiet-tool-rendering.test.ts +48 -0
  424. package/tests/rdd-aware-verification-contract.test.ts +17 -12
  425. package/tests/rdd-customize.test.ts +287 -0
  426. package/tests/rdd-mode-cache.test.ts +450 -0
  427. package/tests/rdd-mode-control.test.ts +407 -0
  428. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  429. package/tests/rdd-off-independent-regression.test.ts +69 -0
  430. package/tests/rdd-status-line.test.ts +112 -1
  431. package/tests/render-cache-performance.test.ts +171 -2
  432. package/tests/reply-language-anchor-placement.test.ts +184 -0
  433. package/tests/reply-language-anchor.test.ts +189 -0
  434. package/tests/request-context-append-only.test.ts +218 -0
  435. package/tests/request-context-placement.test.ts +148 -0
  436. package/tests/review-agent-end-preflight.test.ts +80 -2
  437. package/tests/review-blocker.test.ts +193 -0
  438. package/tests/review-candidate-owner-retry.test.ts +1 -1
  439. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  440. package/tests/review-candidate-view.test.ts +66 -1
  441. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  442. package/tests/review-candidate-windows-probe.test.ts +63 -0
  443. package/tests/review-committed-restart-ack.test.ts +129 -0
  444. package/tests/review-continuation-registry.test.ts +107 -0
  445. package/tests/review-contract-prompt.test.ts +1 -1
  446. package/tests/review-controller-native-routing.test.ts +261 -5
  447. package/tests/review-controller-workspace-root.test.ts +230 -3
  448. package/tests/review-controller.test.ts +98 -12
  449. package/tests/review-coordinator-correction-gate.test.ts +105 -0
  450. package/tests/review-coordinator-findings.test.ts +206 -0
  451. package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
  452. package/tests/review-coordinator-runtime.test.ts +117 -0
  453. package/tests/review-coordinator.test.ts +462 -0
  454. package/tests/review-delivery-preflight.test.ts +462 -0
  455. package/tests/review-due-compaction.test.ts +31 -0
  456. package/tests/review-due-public-boundary.test.ts +26 -0
  457. package/tests/review-failure-facts.test.ts +87 -0
  458. package/tests/review-host-relay-routing.test.ts +258 -4
  459. package/tests/review-host-relay.test.ts +39 -0
  460. package/tests/review-integration-nonblocking-findings.test.ts +108 -0
  461. package/tests/review-integration-v2.test.ts +46 -3
  462. package/tests/review-json-arguments.test.ts +105 -11
  463. package/tests/review-last-event-closure.test.ts +68 -0
  464. package/tests/review-ledger-contract.test.ts +19 -40
  465. package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
  466. package/tests/review-one-call-findings.test.ts +131 -0
  467. package/tests/review-one-call-followups.test.ts +308 -0
  468. package/tests/review-one-call-reviewer-requests.test.ts +207 -0
  469. package/tests/review-one-call.test.ts +452 -0
  470. package/tests/review-owner-identity.test.ts +60 -24
  471. package/tests/review-relay-phase-timing.test.ts +128 -0
  472. package/tests/review-relay-transport-agent.test.ts +39 -2
  473. package/tests/review-reviewer-evidence.test.ts +223 -0
  474. package/tests/review-risk-assessment.test.ts +126 -8
  475. package/tests/review-run-statement-guidance-independent.test.ts +54 -0
  476. package/tests/review-session-standing-permission-controller.test.ts +53 -3
  477. package/tests/review-start-context.test.ts +19 -0
  478. package/tests/review-tool-prose-budget.test.ts +122 -0
  479. package/tests/reviewer-stream.test.ts +149 -0
  480. package/tests/run-test-suite.test.ts +122 -1
  481. package/tests/runtime-harness.mjs +4 -1
  482. package/tests/sensitive-path-tools.test.ts +181 -5
  483. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  484. package/tests/session-profile-binding.test.ts +19 -1
  485. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  486. package/tests/session-profile-extension.test.ts +2 -2
  487. package/tests/session-profile-v1-compat.test.ts +35 -1
  488. package/tests/shell-bar.test.ts +186 -42
  489. package/tests/shell-panel.test.ts +50 -22
  490. package/tests/shell-prompt.test.ts +17 -0
  491. package/tests/shell-sidebar-fullscreen.test.ts +5 -5
  492. package/tests/shell-sidebar-layout.test.ts +294 -23
  493. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  494. package/tests/shell-surface-transparent.test.ts +89 -0
  495. package/tests/shell-todo.test.ts +12 -0
  496. package/tests/shell-usage.test.ts +59 -10
  497. package/tests/skill-contradictions-contract.test.ts +122 -0
  498. package/tests/skill-registry-watcher.test.ts +216 -2
  499. package/tests/skill-registry.test.ts +1461 -5
  500. package/tests/startup-banner.test.ts +152 -1
  501. package/tests/startup-home-repo.test.ts +2 -0
  502. package/tests/support/design-canvas-dom.ts +369 -0
  503. package/tests/support/review-coordinator-runtime.ts +264 -0
  504. package/tests/task-size-routing-contract.test.ts +45 -12
  505. package/tests/test-strength-contract.test.ts +2 -1
  506. package/tests/todo-request-append-only.test.ts +214 -0
  507. package/tests/tool-batching-contract.test.ts +3 -1
  508. package/tests/update-agent-body-history.test.ts +138 -0
  509. package/tests/verification-tiers-contract.test.ts +229 -0
  510. package/tests/verifier-admission.test.ts +49 -0
  511. package/tests/verifier-preparation.test.ts +229 -0
  512. package/tests/verify-agent-contract.test.ts +20 -2
  513. package/tests/verify-first-launch-contract.test.ts +162 -11
  514. package/tests/vim-editor-adapter.test.ts +2 -2
  515. package/tests/visual-customization-policy.test.ts +39 -6
  516. package/tests/visual-customize-view.test.ts +573 -9
  517. package/tests/visual-layout-preview.test.ts +15 -1
  518. package/tests/visual-profiles.test.ts +11 -0
  519. package/tests/voice-worker.test.ts +73 -2
  520. package/tests/windows-session-transport.test.ts +126 -0
  521. package/tests/work-continuity-contract.test.ts +77 -6
  522. package/tests/writer-admission-messages.test.ts +232 -0
  523. package/tests/writer-batch-admission.test.ts +66 -0
  524. package/tests/writer-edit-surface-scope.test.ts +52 -20
  525. package/tests/writer-feature-document-admission.test.ts +276 -0
  526. package/tests/yolo-customize.test.ts +27 -4
  527. package/tests/yolo-mode.test.ts +62 -18
  528. package/tests/yolo-session-policy.test.ts +270 -1
  529. package/skills/_shared/review-ledger-contract.md +0 -106
  530. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
  531. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
  532. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
  533. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  534. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
  535. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
  536. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -0,0 +1,413 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { click, findAll, handoffDoc, loadCanvas, memoryStorage, read, setHandoffs, texts, withClass, type FakeElement } from "./support/design-canvas-dom.ts";
4
+
5
+ // The minimap (canvas-minimap.js): every board drawn small where the layout puts it,
6
+ // the visible area as an outlined rectangle, a click or drag in it to move the view,
7
+ // and M (a single key of the rail) to show or hide it.
8
+
9
+ const SYSTEM_REPLY = { "/t/api/system": { exists: true, file: "system.html", width: 800, height: 600 } };
10
+ // With the system board (800 x 600) the row is [0, 0, 800, 600], [880, 0, 400, 300], [1360, 0, 560, 840]: 1920 x 840
11
+ // world bounds into the 204 x 96 map with a 6 px pad, a scale of exactly 0.1 and a 6 px offset.
12
+ const WIDE_SECOND = {
13
+ "/t/api/designs/alpha": {
14
+ slug: "alpha",
15
+ title: "Alpha",
16
+ brief: "",
17
+ artboards: [
18
+ { file: "01-a.html", title: "First", tradeoff: "", width: 400, height: 300 },
19
+ { file: "02-b.html", title: "Second", tradeoff: "", width: 560, height: 840 },
20
+ ],
21
+ },
22
+ };
23
+
24
+ async function loadMinimap(replies: Record<string, unknown> = {}, extraWindow: Record<string, unknown> = {}, config: Record<string, unknown> = {}) {
25
+ const canvas = await loadCanvas(300, replies, config, extraWindow);
26
+ // The fake DOM starts every element visible; index.html starts these hidden.
27
+ canvas.document.getElementById("gd-popover").hidden = true;
28
+ canvas.document.getElementById("gd-menu").hidden = true;
29
+ // index.html nests the minimap inside the viewport, at its bottom right.
30
+ const panel = miniPanelOf(canvas.document);
31
+ panel.className = "gd-minimap";
32
+ canvas.viewport.append(panel);
33
+ panel.append(canvas.document.getElementById("gd-minimap-map"));
34
+ // The map sits at (1000, 600) on the page.
35
+ canvas.document.getElementById("gd-minimap-map").rect = { left: 1000, top: 600, width: 204, height: 96 };
36
+ return canvas;
37
+ }
38
+ type Canvas = Awaited<ReturnType<typeof loadMinimap>>;
39
+
40
+ const miniPanelOf = (document: Canvas["document"]) => document.getElementById("gd-minimap");
41
+ const miniPanel = (canvas: Canvas) => miniPanelOf(canvas.document);
42
+ const miniMap = (canvas: Canvas) => canvas.document.getElementById("gd-minimap-map");
43
+ const miniView = (canvas: Canvas) => canvas.document.getElementById("gd-minimap-view");
44
+ const miniBlocks = (canvas: Canvas) => withClass(miniMap(canvas), "gd-minimap-block");
45
+ const miniBox = (element: FakeElement) => ["left", "top", "width", "height"].map((key) => Number.parseFloat(element.style[key]));
46
+ const near = (actual: number[], expected: number[]) => {
47
+ assert.equal(actual.length, expected.length);
48
+ actual.forEach((value, index) => assert.ok(Math.abs(value - expected[index]) < 0.05, `${JSON.stringify(actual)} is not ${JSON.stringify(expected)}`));
49
+ };
50
+ const minimapCanvas = (replies: Record<string, unknown> = {}, extraWindow: Record<string, unknown> = {}) => loadMinimap({ ...SYSTEM_REPLY, ...WIDE_SECOND, ...replies }, extraWindow);
51
+ const mapPointer = (canvas: Canvas, type: string, worldX: number, worldY: number, init: Record<string, unknown> = {}) =>
52
+ miniMap(canvas).dispatch(type, { button: 0, pointerId: 7, clientX: 1000 + 6 + worldX * 0.1, clientY: 600 + 6 + worldY * 0.1, ...init });
53
+
54
+ /** A key press delivered to the document's keydown listeners, as the browser would from `target`. */
55
+ function press(canvas: Canvas, key: string, init: Record<string, unknown> = {}, target?: FakeElement) {
56
+ const event: any = { key, shiftKey: false, ctrlKey: false, metaKey: false, altKey: false, target: target ?? canvas.document.body, defaultPrevented: false, preventDefault() { event.defaultPrevented = true; }, ...init };
57
+ for (const listener of canvas.document.listeners.get("keydown") ?? []) listener(event);
58
+ return event;
59
+ }
60
+
61
+ // ---- the map
62
+
63
+ test("the minimap draws every board as a block at its place in the layout, the system board first", async () => {
64
+ const canvas = await minimapCanvas();
65
+ const blocks = miniBlocks(canvas);
66
+ assert.equal(blocks.length, 3, "the system board and both artboards");
67
+ near(miniBox(blocks[0]), [6, 6, 80, 60]);
68
+ near(miniBox(blocks[1]), [94, 6, 40, 30]);
69
+ near(miniBox(blocks[2]), [142, 6, 56, 84]);
70
+ assert.ok(blocks[0].classes.has("gd-minimap-system"), "the first block is the system board");
71
+ assert.ok(!blocks[1].classes.has("gd-minimap-system") && !blocks[2].classes.has("gd-minimap-system"));
72
+ assert.equal(miniPanel(canvas).hidden, false);
73
+ assert.equal(miniMap(canvas).children.at(-1), miniView(canvas), "the visible area is drawn over the blocks");
74
+ });
75
+
76
+ test("minimap blocks carry no text; each names its artboard on hover", async () => {
77
+ const canvas = await minimapCanvas();
78
+ const blocks = miniBlocks(canvas);
79
+ assert.deepEqual(blocks.map((block) => block.children.length), [0, 0, 0], "no label inside the blocks");
80
+ assert.deepEqual(blocks.map((block) => block.title), ["Design system", "First", "Second"]);
81
+ });
82
+
83
+ test("blocks keep the world's aspect and are centered in the map", async () => {
84
+ // Wide and short bounds (3840 x 400): the width limits the scale to 0.05 and the height is centered.
85
+ const canvas = await loadMinimap({
86
+ "/t/api/system": { exists: true, file: "system.html", width: 2000, height: 400 },
87
+ "/t/api/designs/alpha": { slug: "alpha", title: "Alpha", brief: "", artboards: [
88
+ { file: "01-a.html", title: "First", tradeoff: "", width: 800, height: 400 },
89
+ { file: "02-b.html", title: "Second", tradeoff: "", width: 880, height: 400 },
90
+ ] },
91
+ });
92
+ const blocks = miniBlocks(canvas);
93
+ near(miniBox(blocks[0]), [6, 38, 100, 20]);
94
+ near(miniBox(blocks[2]), [154, 38, 44, 20]);
95
+ });
96
+
97
+ test("the chosen artboard's block is the accent one, live, and no other block is marked", async () => {
98
+ const canvas = await minimapCanvas();
99
+ assert.deepEqual(miniBlocks(canvas).map((block) => block.classes.has("gd-minimap-chosen")), [false, false, false]);
100
+ await setHandoffs(canvas, handoffDoc("02-b.html", { "02-b.html": {} }));
101
+ assert.deepEqual(miniBlocks(canvas).map((block) => block.classes.has("gd-minimap-chosen")), [false, false, true]);
102
+ assert.ok(miniBlocks(canvas).every((block) => [...block.classes].every((name) => ["gd-minimap-block", "gd-minimap-system", "gd-minimap-chosen"].includes(name))), "the alternatives carry no discarded styling");
103
+ await setHandoffs(canvas, handoffDoc(null, {}));
104
+ assert.deepEqual(miniBlocks(canvas).map((block) => block.classes.has("gd-minimap-chosen")), [false, false, false]);
105
+ });
106
+
107
+ test("a moved artboard moves its block while it is dragged", async () => {
108
+ const canvas = await minimapCanvas({ "/t/api/designs/alpha/layout": { layout: null } });
109
+ const title = withClass(canvas.world.children[1], "gd-artboard-title")[0];
110
+ title.dispatch("pointerdown", { button: 0, pointerId: 3, clientX: 900, clientY: 100 });
111
+ title.dispatch("pointermove", { pointerId: 3, clientX: 900, clientY: 200 });
112
+ near(miniBox(miniBlocks(canvas)[1]), [94, 16, 40, 30]);
113
+ title.dispatch("pointerup", { button: 0, pointerId: 3, clientX: 900, clientY: 200 });
114
+ near(miniBox(miniBlocks(canvas)[1]), [94, 16, 40, 30]);
115
+ });
116
+
117
+ // ---- the visible area
118
+
119
+ test("the visible area is an outlined rectangle that follows pan and zoom", async () => {
120
+ const canvas = await minimapCanvas();
121
+ // Initial view: world offset (48, 48) at 100% in a 1000 x 700 viewport shows world x -48..952, y -48..652.
122
+ near(miniBox(miniView(canvas)), [1.2, 1.2, 100, 70]);
123
+ // A key pan of 50 px to the left moves the view 50 world px right.
124
+ canvas.viewport.dispatch("keydown", { key: "ArrowRight" });
125
+ near(miniBox(miniView(canvas)), [6.2, 1.2, 100, 70]);
126
+ canvas.viewport.dispatch("keydown", { key: "ArrowLeft" });
127
+ // Zoom in 25% around the center: x = -65, y = -27.5 shows world x 52..852, y 22..582.
128
+ canvas.viewport.dispatch("keydown", { key: "+" });
129
+ near(miniBox(miniView(canvas)), [11.2, 8.2, 80, 56]);
130
+ assert.equal(miniView(canvas).getAttribute("aria-hidden"), null, "the rectangle lives inside the map, which carries the name");
131
+ });
132
+
133
+ test("the visible-area rectangle is clipped to the map when the view is away from the boards, and never shrinks to nothing", async () => {
134
+ const canvas = await minimapCanvas();
135
+ for (let i = 0; i < 40; i++) canvas.viewport.dispatch("keydown", { key: "ArrowRight", shiftKey: true });
136
+ const [left, top, width, height] = miniBox(miniView(canvas));
137
+ assert.ok(left >= 0 && top >= 0 && left + width <= 204.01 && top + height <= 96.01, "never outside the map");
138
+ assert.ok(left + width > 203.9 && Math.abs(width - 4) < 0.05, "pinned to the right edge at 4 px, pointing to where the view went");
139
+ assert.ok(height > 60);
140
+ // Far up and to the left: pinned to the top left corner, 4 px each way.
141
+ for (let i = 0; i < 80; i++) canvas.viewport.dispatch("keydown", { key: "ArrowLeft", shiftKey: true });
142
+ for (let i = 0; i < 40; i++) canvas.viewport.dispatch("keydown", { key: "ArrowUp", shiftKey: true });
143
+ near(miniBox(miniView(canvas)), [0, 0, 4, 4]);
144
+ });
145
+
146
+ test("a pan or a wheel only moves the outline: it reads no board's layout and does not measure the viewport", async () => {
147
+ const canvas = await minimapCanvas();
148
+ let reads = 0;
149
+ for (const element of findAll(canvas.world, () => true)) {
150
+ for (const key of ["offsetLeft", "offsetTop", "offsetWidth", "offsetHeight"]) {
151
+ const value = (element as any)[key];
152
+ Object.defineProperty(element, key, { configurable: true, get: () => { reads += 1; return value; } });
153
+ }
154
+ }
155
+ let measured = 0;
156
+ const rect = canvas.viewport.rect;
157
+ canvas.viewport.getBoundingClientRect = () => { measured += 1; return rect; };
158
+ for (let i = 0; i < 5; i++) canvas.viewport.dispatch("wheel", { deltaX: 20, deltaY: 10, deltaMode: 0, ctrlKey: false, metaKey: false, shiftKey: false, clientX: 300, clientY: 300 });
159
+ canvas.viewport.dispatch("keydown", { key: "ArrowDown" });
160
+ canvas.viewport.dispatch("pointerdown", { button: 0, pointerId: 9, clientX: 10, clientY: 10 });
161
+ canvas.viewport.dispatch("pointermove", { pointerId: 9, clientX: 30, clientY: 10 });
162
+ canvas.viewport.dispatch("pointerup", { button: 0, pointerId: 9, clientX: 30, clientY: 10 });
163
+ near(miniBox(miniView(canvas)), [1.2 + 10 - 2, 1.2 + 5 + 5, 100, 70]);
164
+ assert.equal(reads, 0, "no board offsets per pan");
165
+ assert.equal(measured, 0, "no viewport measure per pan");
166
+ });
167
+
168
+ // ---- moving the view from the map
169
+
170
+ test("a click in the minimap centers the view on that world point; zoom stays", async () => {
171
+ const canvas = await minimapCanvas();
172
+ canvas.viewport.dispatch("keydown", { key: "+" });
173
+ const zoom = canvas.zoomLevel.textContent;
174
+ // Click world point (400, 300): at 125% the viewport's center (500, 350) goes there.
175
+ mapPointer(canvas, "pointerdown", 400, 300);
176
+ assert.equal(canvas.world.style.transform, "translate(0px, -25px) scale(1.25)");
177
+ mapPointer(canvas, "pointerup", 400, 300);
178
+ assert.equal(canvas.zoomLevel.textContent, zoom);
179
+ near(miniBox(miniView(canvas)), [6, 8, 80, 56]);
180
+ assert.equal(canvas.navMode.textContent, "Navigating", "a click in the map never focuses an artboard");
181
+ assert.deepEqual(canvas.viewport.capturedPointers, [], "nor starts a pan of the canvas underneath");
182
+ });
183
+
184
+ test("dragging in the minimap pans with the pointer until it is released", async () => {
185
+ const canvas = await minimapCanvas();
186
+ mapPointer(canvas, "pointerdown", 400, 300);
187
+ assert.equal(canvas.world.style.transform, "translate(100px, 50px) scale(1)");
188
+ assert.deepEqual(miniMap(canvas).capturedPointers, [7]);
189
+ mapPointer(canvas, "pointermove", 600, 400);
190
+ assert.equal(canvas.world.style.transform, "translate(-100px, -50px) scale(1)");
191
+ near(miniBox(miniView(canvas)), [16, 11, 100, 70]);
192
+ mapPointer(canvas, "pointerup", 600, 400);
193
+ mapPointer(canvas, "pointermove", 1000, 700);
194
+ assert.equal(canvas.world.style.transform, "translate(-100px, -50px) scale(1)", "moves after the release do nothing");
195
+ });
196
+
197
+ test("only the primary button pans the minimap, and another pointer's moves are ignored", async () => {
198
+ const canvas = await minimapCanvas();
199
+ const before = canvas.world.style.transform;
200
+ mapPointer(canvas, "pointerdown", 400, 300, { button: 2 });
201
+ assert.equal(canvas.world.style.transform, before);
202
+ mapPointer(canvas, "pointerdown", 400, 300);
203
+ const after = canvas.world.style.transform;
204
+ mapPointer(canvas, "pointermove", 900, 500, { pointerId: 8 });
205
+ assert.equal(canvas.world.style.transform, after);
206
+ mapPointer(canvas, "pointercancel", 400, 300);
207
+ mapPointer(canvas, "pointermove", 900, 500);
208
+ assert.equal(canvas.world.style.transform, after, "a cancelled drag ends too");
209
+ });
210
+
211
+ test("a second pointer pressed during a minimap drag is ignored, and losing the capture ends the drag", async () => {
212
+ const canvas = await minimapCanvas();
213
+ mapPointer(canvas, "pointerdown", 400, 300);
214
+ assert.equal(canvas.world.style.transform, "translate(100px, 50px) scale(1)");
215
+ mapPointer(canvas, "pointerdown", 900, 500, { pointerId: 8 });
216
+ assert.equal(canvas.world.style.transform, "translate(100px, 50px) scale(1)", "the second press does not move the view");
217
+ assert.deepEqual(miniMap(canvas).capturedPointers, [7], "nor takes the capture");
218
+ mapPointer(canvas, "pointermove", 900, 500, { pointerId: 8 });
219
+ assert.equal(canvas.world.style.transform, "translate(100px, 50px) scale(1)");
220
+ mapPointer(canvas, "pointermove", 600, 400);
221
+ assert.equal(canvas.world.style.transform, "translate(-100px, -50px) scale(1)", "the first pointer still drags");
222
+ mapPointer(canvas, "pointerup", 900, 500, { pointerId: 8 });
223
+ mapPointer(canvas, "pointermove", 500, 300);
224
+ assert.equal(canvas.world.style.transform, "translate(0px, 50px) scale(1)", "the second pointer's release does not end the first one's drag");
225
+ mapPointer(canvas, "lostpointercapture", 500, 300);
226
+ mapPointer(canvas, "pointermove", 600, 400);
227
+ assert.equal(canvas.world.style.transform, "translate(0px, 50px) scale(1)", "a lost capture ends the drag");
228
+ });
229
+
230
+ test("a minimap drag past the map's edges stops at them", async () => {
231
+ const canvas = await minimapCanvas();
232
+ mapPointer(canvas, "pointerdown", 400, 300);
233
+ // Far past the bottom right: the map's corner (204, 96) is world (1980, 900).
234
+ mapPointer(canvas, "pointermove", 9000, 4000);
235
+ assert.equal(canvas.world.style.transform, "translate(-1480px, -550px) scale(1)");
236
+ // Far past the top left: the map's corner (0, 0) is world (-60, -60).
237
+ mapPointer(canvas, "pointermove", -9000, -4000);
238
+ assert.equal(canvas.world.style.transform, "translate(560px, 410px) scale(1)");
239
+ mapPointer(canvas, "pointerup", -9000, -4000);
240
+ });
241
+
242
+ test("the minimap follows the view for every kind of pan, a resize and a change of boards", async () => {
243
+ const canvas = await minimapCanvas();
244
+ const view = () => miniBox(miniView(canvas));
245
+ canvas.viewport.dispatch("wheel", { deltaX: 100, deltaY: 0, deltaMode: 0, ctrlKey: false, metaKey: false, shiftKey: false, clientX: 300, clientY: 300 });
246
+ near(view(), [1.2 + 10, 1.2, 100, 70]);
247
+ canvas.viewport.rect = { left: 0, top: 50, width: 500, height: 700 };
248
+ canvas.windowEvent("resize");
249
+ near(view(), [11.2, 1.2, 50, 70]);
250
+ // A third artboard widens the world to 2400: everything is redrawn at 0.08.
251
+ // A new manifest object: WIDE_SECOND is shared by every test in this file.
252
+ const manifest = canvas.replies["/t/api/designs/alpha"] as { artboards: unknown[] };
253
+ canvas.replies["/t/api/designs/alpha"] = { ...manifest, artboards: [...manifest.artboards, { file: "03-c.html", title: "Third", tradeoff: "", width: 400, height: 300 }] };
254
+ await canvas.serverEvent("show", { slug: "alpha" });
255
+ assert.equal(miniBlocks(canvas).length, 4);
256
+ near(miniBox(miniBlocks(canvas)[3]), [166, 14.4, 32, 24]);
257
+ assert.match(miniMap(canvas).getAttribute("aria-label")!, /among 3 artboards\./);
258
+ });
259
+
260
+ test("a ResizeObserver on the viewport measures it again for the minimap", async () => {
261
+ const observers: Array<() => void> = [];
262
+ class FakeResizeObserver {
263
+ constructor(callback: () => void) { observers.push(callback); }
264
+ observe() {}
265
+ }
266
+ const canvas = await minimapCanvas({}, { ResizeObserver: FakeResizeObserver });
267
+ near(miniBox(miniView(canvas)), [1.2, 1.2, 100, 70]);
268
+ canvas.viewport.rect = { left: 0, top: 50, width: 500, height: 700 };
269
+ for (const callback of observers) callback();
270
+ near(miniBox(miniView(canvas)), [1.2, 1.2, 50, 70]);
271
+ });
272
+
273
+ // ---- showing and hiding it
274
+
275
+ test("M shows and hides the minimap with the other single keys' rules", async () => {
276
+ const canvas = await minimapCanvas();
277
+ assert.equal(press(canvas, "m").defaultPrevented, true);
278
+ assert.equal(miniPanel(canvas).hidden, true);
279
+ press(canvas, "M");
280
+ assert.equal(miniPanel(canvas).hidden, false, "case does not matter");
281
+ press(canvas, "m");
282
+ assert.equal(miniPanel(canvas).hidden, true);
283
+ press(canvas, "m");
284
+ assert.equal(miniPanel(canvas).hidden, false);
285
+ // A view change while it was hidden shows when it comes back.
286
+ press(canvas, "m");
287
+ canvas.viewport.dispatch("keydown", { key: "+" });
288
+ press(canvas, "m");
289
+ near(miniBox(miniView(canvas)), [11.2, 8.2, 80, 56]);
290
+ });
291
+
292
+ test("M is ignored while typing, with a chord, with the comment box, a menu or the shortcuts open, and in focus mode", async () => {
293
+ const canvas = await minimapCanvas();
294
+ for (const tag of ["input", "textarea", "select"]) press(canvas, "m", {}, canvas.document.createElement(tag));
295
+ for (const chord of [{ ctrlKey: true }, { metaKey: true }, { altKey: true }]) press(canvas, "m", chord);
296
+ assert.equal(miniPanel(canvas).hidden, false, "typing and browser chords never toggle it");
297
+ canvas.document.getElementById("gd-popover").hidden = false;
298
+ press(canvas, "m");
299
+ canvas.document.getElementById("gd-popover").hidden = true;
300
+ canvas.document.getElementById("gd-rail-settings").dispatch("click");
301
+ press(canvas, "m");
302
+ canvas.document.getElementById("gd-rail-settings").dispatch("click");
303
+ canvas.document.getElementById("gd-shortcuts").setAttribute("open", "");
304
+ press(canvas, "m");
305
+ canvas.document.getElementById("gd-shortcuts").removeAttribute("open");
306
+ assert.equal(miniPanel(canvas).hidden, false, "the open comment box, menu and shortcuts list leave it alone");
307
+
308
+ click(canvas.boards[1].shield!, 200, 200);
309
+ const event = press(canvas, "m");
310
+ assert.equal(event.defaultPrevented, false, "the focused artboard owns the keyboard");
311
+ canvas.document.getElementById("gd-back").dispatch("click");
312
+ assert.equal(miniPanel(canvas).hidden, false, "M in focus mode did not switch it off behind the scenes");
313
+ });
314
+
315
+ test("the minimap is hidden in focus mode and comes back, as it was, on Back to canvas", async () => {
316
+ const canvas = await minimapCanvas();
317
+ click(canvas.boards[1].shield!, 200, 200);
318
+ assert.equal(miniPanel(canvas).hidden, true);
319
+ canvas.document.getElementById("gd-back").dispatch("click");
320
+ assert.equal(miniPanel(canvas).hidden, false);
321
+ near(miniBox(miniView(canvas)), [1.2, 1.2, 100, 70]);
322
+ press(canvas, "m");
323
+ click(canvas.boards[1].shield!, 200, 200);
324
+ canvas.document.getElementById("gd-back").dispatch("click");
325
+ assert.equal(miniPanel(canvas).hidden, true, "a minimap switched off with M stays off after focus");
326
+ });
327
+
328
+ test("the minimap is hidden while Compare is open and returns when it closes", async () => {
329
+ const canvas = await minimapCanvas({ "/t/api/designs/alpha/handoffs": handoffDoc("01-a.html", { "01-a.html": { status: "implemented", previewUrl: "http://localhost:5173/login" } }) });
330
+ assert.equal(miniPanel(canvas).hidden, false);
331
+ withClass(canvas.world.children[1], "gd-compare-start")[0].dispatch("click");
332
+ assert.equal(canvas.document.getElementById("gd-compare").hidden, false);
333
+ assert.equal(miniPanel(canvas).hidden, true);
334
+ canvas.document.getElementById("gd-compare-back").dispatch("click");
335
+ assert.equal(miniPanel(canvas).hidden, false);
336
+ });
337
+
338
+ test("the minimap is hidden when there is nothing to show", async () => {
339
+ const canvas = await loadMinimap({ "/t/api/designs": { designs: [] } }, {}, { slug: null });
340
+ assert.equal(miniPanel(canvas).hidden, true);
341
+ });
342
+
343
+ // ---- accessibility, markup, shortcut and styles
344
+
345
+ test("the map carries an accessible name with the artboard count, and nothing in it takes the keyboard", async () => {
346
+ const canvas = await minimapCanvas();
347
+ assert.equal(miniMap(canvas).getAttribute("aria-label"), "Position of the visible area among 2 artboards. Click or drag to move the view.");
348
+ for (const block of miniBlocks(canvas)) {
349
+ assert.equal(block.getAttribute("tabindex"), null);
350
+ assert.notEqual(block.localName, "button");
351
+ assert.equal(block.getAttribute("role"), null);
352
+ assert.equal(block.getAttribute("aria-hidden"), "true");
353
+ }
354
+ assert.equal(miniView(canvas).getAttribute("tabindex"), null);
355
+ assert.equal(withClass(canvas.world, "gd-minimap-block").length, 0, "blocks live in the minimap, not in the world");
356
+ });
357
+
358
+ test("the map's name says 1 artboard in the singular", async () => {
359
+ const canvas = await loadMinimap({ "/t/api/designs/alpha": { slug: "alpha", title: "Alpha", brief: "", artboards: [{ file: "01-a.html", title: "First", tradeoff: "", width: 400, height: 300 }] } });
360
+ assert.equal(miniMap(canvas).getAttribute("aria-label"), "Position of the visible area among 1 artboard. Click or drag to move the view.");
361
+ });
362
+
363
+ test("the shortcuts list has a row for M, and a changed key shows in the minimap's title and toggles it", async () => {
364
+ const canvas = await minimapCanvas();
365
+ const row = withClass(canvas.document.getElementById("gd-keys-custom"), "gd-key-row").find((entry) => entry.dataset.shortcut === "minimap")!;
366
+ assert.deepEqual([texts(row, "gd-key-current")[0], texts(row, "gd-key-action")[0]], ["M", "Show or hide the minimap"]);
367
+ assert.equal(canvas.document.getElementById("gd-minimap-key").textContent, "M");
368
+
369
+ const storage = memoryStorage({ "gentle-design:shortcuts": JSON.stringify({ minimap: "n" }) });
370
+ const custom = await minimapCanvas({}, { localStorage: storage.localStorage });
371
+ assert.equal(custom.document.getElementById("gd-minimap-key").textContent, "N");
372
+ assert.equal(press(custom, "m").defaultPrevented, false, "the old key is free");
373
+ assert.equal(miniPanel(custom).hidden, false);
374
+ press(custom, "n");
375
+ assert.equal(miniPanel(custom).hidden, true);
376
+ });
377
+
378
+ test("index.html carries the minimap inside the viewport, hidden until there are boards", () => {
379
+ const html = read("index.html");
380
+ const section = html.match(/<section id="gd-minimap"[^>]*>[^]*?<\/section>/)![0];
381
+ assert.match(section, /^<section id="gd-minimap" class="gd-minimap" aria-labelledby="gd-minimap-title" hidden>/);
382
+ assert.match(section, /<h2 id="gd-minimap-title" class="gd-minimap-title"><span data-i18n="minimap">Minimap<\/span><kbd id="gd-minimap-key" aria-hidden="true">M<\/kbd><\/h2>/);
383
+ assert.match(section, /<div id="gd-minimap-map" class="gd-minimap-map" role="img" aria-label="[^"]+" data-i18n-aria-label="minimapMap">/);
384
+ assert.match(section, /<b id="gd-minimap-view" class="gd-minimap-view"><\/b>/);
385
+ // Its words are keyed for the language (ES.html, tests/design-canvas-i18n.test.ts); the English stays in the markup.
386
+ assert.ok(!/tabindex|<button/.test(section), "nothing in the minimap takes the keyboard");
387
+ const viewport = html.slice(html.indexOf('<main id="gd-viewport"'), html.indexOf("</main>"));
388
+ assert.ok(viewport.includes('id="gd-minimap"'), "the minimap is inside the viewport");
389
+ });
390
+
391
+ test("canvas.css styles the minimap with tokens only, at the viewport's bottom right, with no motion and no dots", () => {
392
+ const css = read("canvas.css");
393
+ const block = (selector: string) => {
394
+ const start = css.indexOf(`\n${selector} {`);
395
+ assert.ok(start >= 0, `${selector} is styled`);
396
+ return css.slice(start, css.indexOf("}", start) + 1);
397
+ };
398
+ for (const selector of [".gd-minimap", ".gd-minimap-title", ".gd-minimap-map", ".gd-minimap-block", ".gd-minimap-system", ".gd-minimap-chosen", ".gd-minimap-view"]) {
399
+ const text = block(selector);
400
+ assert.ok(!/#[0-9a-fA-F]{3,8}\b|rgba?\(/.test(text), `${selector}: tokens only`);
401
+ assert.ok(!/transition|animation/.test(text), `${selector}: no motion`);
402
+ assert.ok(!/border-radius:\s*50%/.test(text), `${selector}: no dots`);
403
+ }
404
+ assert.match(block(".gd-minimap"), /position:\s*absolute[^}]*right:\s*16px[^}]*bottom:\s*16px/);
405
+ assert.match(block(".gd-minimap"), /background:\s*var\(--gd-panel\)/);
406
+ assert.match(block(".gd-minimap-map"), /width:\s*204px[^}]*height:\s*96px/);
407
+ assert.match(block(".gd-minimap-map"), /overflow:\s*hidden/);
408
+ assert.match(block(".gd-minimap-map"), /touch-action:\s*none/);
409
+ assert.match(block(".gd-minimap-chosen"), /var\(--gd-accent\)/);
410
+ assert.match(block(".gd-minimap-view"), /var\(--gd-focus\)/);
411
+ assert.match(block(".gd-minimap-view"), /pointer-events:\s*none/);
412
+ assert.doesNotMatch(css, /gd-minimap-discarded|gd-minimap-placeholder/, "no discarded or placeholder styling");
413
+ });
@@ -0,0 +1,90 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import { readFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import test from "node:test";
6
+ import { fileURLToPath, pathToFileURL } from "node:url";
7
+ import { DESIGN_CANVAS_ASSETS } from "../lib/design-canvas-assets.ts";
8
+ import { FakeDocument } from "./support/design-canvas-dom.ts";
9
+
10
+ // The canvas modules (S1, S3, S4): flat files under assets/design-canvas/, loaded
11
+ // as ES modules from canvas.js, wired only by canvas-boot.js.
12
+
13
+ const ASSET_DIR = fileURLToPath(new URL("../assets/design-canvas/", import.meta.url));
14
+ const read = (name: string) => readFileSync(join(ASSET_DIR, name), "utf8");
15
+ const MODULES = Object.keys(DESIGN_CANVAS_ASSETS).filter((name) => name.startsWith("canvas-") && name.endsWith(".js"));
16
+ // Every browser global the canvas uses, and the usual ways to reach the page.
17
+ const BROWSER_GLOBALS = ["window", "document", "self", "globalThis.window", "fetch", "EventSource", "localStorage", "location", "history", "URL", "CSS", "innerWidth", "innerHeight", "setTimeout", "clearTimeout", "requestAnimationFrame", "ResizeObserver", "FileReader", "addEventListener", "navigator"];
18
+
19
+ /** Imports `names` in a fresh Node process where touching any browser global throws. */
20
+ function importWithoutGlobals(names: string[]) {
21
+ const urls = names.map((name) => pathToFileURL(join(ASSET_DIR, name)).href);
22
+ const script = [
23
+ `for (const name of ${JSON.stringify(BROWSER_GLOBALS.filter((name) => !name.includes(".")))}) {`,
24
+ "\tObject.defineProperty(globalThis, name, { configurable: true, get() { throw new Error(`touched ${name}`); }, set() { throw new Error(`touched ${name}`); } });",
25
+ "}",
26
+ `for (const url of ${JSON.stringify(urls)}) {`,
27
+ "\ttry { await import(url); console.log(`imported ${url.split(\"/\").pop()}`); } catch (error) { console.log(`failed ${url.split(\"/\").pop()}: ${error.message}`); process.exitCode = 1; }",
28
+ "}",
29
+ ].join("\n");
30
+ return spawnSync(process.execPath, ["--input-type=module", "-e", script], { encoding: "utf8" });
31
+ }
32
+
33
+ test("no canvas module touches the DOM or window when it is imported", () => {
34
+ assert.equal(MODULES.length, 24);
35
+ const result = importWithoutGlobals(MODULES);
36
+ assert.equal(result.stderr, "");
37
+ assert.deepEqual(result.stdout.trim().split("\n"), MODULES.map((name) => `imported ${name}`));
38
+ assert.equal(result.status, 0);
39
+ // The guard is real: the entry boots at import and so touches window.
40
+ const entry = importWithoutGlobals(["canvas.js"]);
41
+ assert.equal(entry.stdout.trim(), "failed canvas.js: touched window");
42
+ assert.equal(entry.status, 1);
43
+ });
44
+
45
+ test("canvas.js is the two-line entry and index.html loads it as a module", () => {
46
+ assert.equal(read("canvas.js"), 'import { boot } from "./canvas-boot.js";\nboot(window, document);\n');
47
+ const html = read("index.html");
48
+ assert.match(html, /<script type="module" src="\{\{BASE\}\}assets\/canvas\.js"><\/script>/);
49
+ assert.equal(html.match(/<script\b[^>]*\bsrc=/g)?.length, 1, "canvas.js is the only script the page loads");
50
+ assert.ok(!/\bdefer\b/.test(html), "module scripts are deferred already");
51
+ });
52
+
53
+ test("each module exports init(ctx), and only canvas-boot.js imports its siblings", async () => {
54
+ for (const name of MODULES) {
55
+ const source = read(name);
56
+ const imports = source.match(/^\s*import\b.*$/gm) ?? [];
57
+ if (name === "canvas-boot.js") {
58
+ assert.deepEqual(imports.map((line) => /from "(\.\/[^"]+)"/.exec(line)?.[1]).sort(), MODULES.filter((module) => module !== "canvas-boot.js").map((module) => `./${module}`).sort(), "boot imports every other module");
59
+ } else {
60
+ assert.deepEqual(imports, [], `${name} imports nothing`);
61
+ }
62
+ assert.ok(!/\bimport\s*\(/.test(source), `${name} has no dynamic import`);
63
+ const module = await import(pathToFileURL(join(ASSET_DIR, name)).href);
64
+ // canvas-i18n-es.js is the Spanish catalog (canvas-i18n.js reads it): data, not a module with an init.
65
+ const expected = name === "canvas-boot.js" ? "boot" : name === "canvas-store.js" ? "createStore" : name === "canvas-i18n-es.js" ? "ES" : "init";
66
+ assert.deepEqual(Object.keys(module), [expected], `${name} exports ${expected}`);
67
+ assert.equal(typeof module[expected], expected === "ES" ? "object" : "function");
68
+ }
69
+ });
70
+
71
+ test("canvas-boot.js documents the ctx.actions rule", () => {
72
+ const boot = read("canvas-boot.js").replace(/\n\/\/ ?/g, " ");
73
+ assert.ok(boot.includes("Actions are only complete once every `init` has returned, so no `init` may call another module's action synchronously"));
74
+ });
75
+
76
+ test("boot registers window listeners in main's order, with and without ResizeObserver", async () => {
77
+ const { boot } = await import(pathToFileURL(join(ASSET_DIR, "canvas-boot.js")).href);
78
+ for (const ro of [false, true]) {
79
+ const doc = new FakeDocument();
80
+ doc.getElementById("gd-config").textContent = JSON.stringify({ base: "/t/", slug: null });
81
+ const order: string[] = [];
82
+ const observed: unknown[] = [];
83
+ const win: Record<string, any> = { addEventListener: (type: string) => order.push(type), localStorage: { getItem: () => null, setItem() {} }, setTimeout, clearTimeout, requestAnimationFrame: () => 0, fetch: () => new Promise(() => {}), EventSource: class { addEventListener() {} }, location: { port: "1" }, URL, history: { replaceState() {} } };
84
+ if (ro) win.ResizeObserver = class { observe(el: unknown) { observed.push(el); } };
85
+ boot(win, doc);
86
+ // blur: Space held to pan lets go when the window loses focus (canvas-layout.js); languagechange: Match the browser follows it (canvas-i18n.js).
87
+ assert.deepEqual(order, ro ? ["blur", "message", "resize", "resize", "languagechange"] : ["blur", "message", "resize", "resize", "resize", "languagechange"]);
88
+ assert.deepEqual(observed, ro ? [doc.getElementById("gd-viewport")] : []);
89
+ }
90
+ });