gentle-pi 4.5.1 → 4.7.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 (428) hide show
  1. package/README.md +17 -15
  2. package/assets/agents/gentle-ai-explore.md +1 -0
  3. package/assets/agents/gentle-ai-verify.md +8 -1
  4. package/assets/agents/gentle-ai-worker.md +4 -0
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +1 -0
  7. package/assets/agents/jd-judge-b.md +1 -0
  8. package/assets/design-canvas/canvas.css +13 -1
  9. package/assets/design-canvas/canvas.js +11 -2
  10. package/assets/install-wizard/wizard.js +1 -0
  11. package/assets/migrations/agent-body-history.json +162 -0
  12. package/assets/orchestrator-delegation-reference.md +7 -7
  13. package/assets/orchestrator-delegation.md +3 -3
  14. package/assets/orchestrator-full-delegation-card.md +65 -0
  15. package/assets/orchestrator-full-delegation.md +34 -0
  16. package/assets/orchestrator-memory.md +3 -3
  17. package/assets/orchestrator-prompts.md +1 -1
  18. package/assets/orchestrator-skills.md +1 -1
  19. package/assets/orchestrator-verification.md +14 -8
  20. package/assets/orchestrator.md +11 -11
  21. package/bin/gentle-shell.mjs +225 -82
  22. package/docs/agent-status.md +61 -0
  23. package/docs/bundled-install.md +7 -5
  24. package/docs/ci-performance.md +11 -0
  25. package/docs/delegated-verification.md +35 -7
  26. package/docs/fast-mode.md +15 -0
  27. package/docs/gentle-agents-activity.md +22 -0
  28. package/docs/gentle-shell.md +113 -25
  29. package/docs/install-wizard.md +2 -2
  30. package/docs/mcp-status.md +52 -0
  31. package/docs/permission-modes.md +9 -4
  32. package/docs/prompt-budget.md +28 -0
  33. package/docs/readme-reference.md +154 -50
  34. package/docs/render-cache-performance.md +11 -1
  35. package/docs/review-coordinator.md +33 -0
  36. package/docs/review-request-context.md +19 -0
  37. package/docs/review-windows-acl.md +18 -0
  38. package/docs/session-profile-format.md +20 -5
  39. package/docs/sound-notifications.md +1 -1
  40. package/docs/star-prompt.md +32 -0
  41. package/docs/voice.md +6 -3
  42. package/docs/work-continuity.md +46 -0
  43. package/docs/yolo-mode.md +5 -5
  44. package/extensions/ask-user-choice.ts +1 -0
  45. package/extensions/ask-user-question.ts +2 -0
  46. package/extensions/child-safety.ts +3 -0
  47. package/extensions/codegraph-tools.ts +38 -4
  48. package/extensions/gentle-agent-status.ts +99 -0
  49. package/extensions/gentle-agents.ts +803 -84
  50. package/extensions/gentle-ai.ts +2491 -596
  51. package/extensions/gentle-fast.ts +61 -0
  52. package/extensions/gentle-guide.ts +174 -0
  53. package/extensions/gentle-herdr-activity.ts +21 -1
  54. package/extensions/gentle-herdr-agent.ts +144 -0
  55. package/extensions/gentle-program-identity.ts +61 -0
  56. package/extensions/gentle-shell.ts +895 -120
  57. package/extensions/gentle-star-prompt.ts +334 -0
  58. package/extensions/gentle-stats.ts +5 -5
  59. package/extensions/gentle-todo.ts +59 -23
  60. package/extensions/gentle-tps.ts +48 -0
  61. package/extensions/history/store.ts +18 -12
  62. package/extensions/quiet-tools.ts +38 -8
  63. package/extensions/skill-registry.ts +210 -21
  64. package/extensions/startup-banner.ts +69 -10
  65. package/lib/agent-assets.ts +74 -17
  66. package/lib/agent-profile-pin.ts +3 -3
  67. package/lib/agent-profiles.ts +161 -3
  68. package/lib/agent-status.ts +105 -0
  69. package/lib/agents-config.ts +58 -3
  70. package/lib/agents-history.ts +24 -5
  71. package/lib/agents-keys.ts +8 -16
  72. package/lib/agents-messaging.ts +47 -5
  73. package/lib/agents-protocol.ts +80 -4
  74. package/lib/agents-runner.ts +287 -15
  75. package/lib/agents-view.ts +6 -1
  76. package/lib/agents-widget.ts +132 -9
  77. package/lib/auto-permission-runtime.ts +1 -1
  78. package/lib/bounded-writer-admission.ts +13 -1
  79. package/lib/bridge-cost.ts +28 -0
  80. package/lib/card-content-policy.ts +8 -6
  81. package/lib/codemode-renderer.ts +16 -0
  82. package/lib/command-palette-catalog.ts +1 -0
  83. package/lib/command-palette.ts +154 -25
  84. package/lib/context-backstop.ts +14 -5
  85. package/lib/destructive-command-guard.ts +48 -4
  86. package/lib/execution-surface-guard.ts +20 -0
  87. package/lib/exploration-budget.ts +64 -0
  88. package/lib/gentle-ai-binary.ts +1 -1
  89. package/lib/gentle-design.ts +3 -0
  90. package/lib/gentle-guide.ts +201 -0
  91. package/lib/gentle-shell-bundled.ts +6 -19
  92. package/lib/gentle-shell-launcher.ts +47 -8
  93. package/lib/herdr-activity.ts +23 -5
  94. package/lib/herdr-busy.ts +45 -0
  95. package/lib/herdr-task-summary-policy.ts +85 -0
  96. package/lib/image-attachments.ts +33 -0
  97. package/lib/image-disk-cache.ts +137 -0
  98. package/lib/inprocess-reviewer.ts +282 -132
  99. package/lib/jobs-sidebar-state.ts +5 -6
  100. package/lib/jobs-view.ts +198 -11
  101. package/lib/jobs-widget.ts +16 -52
  102. package/lib/keymaps-customize.ts +81 -0
  103. package/lib/keymaps.ts +291 -0
  104. package/lib/model-fallback-notice.ts +61 -0
  105. package/lib/model-fallback-policy.ts +141 -0
  106. package/lib/model-fallback-store.ts +143 -0
  107. package/lib/model-routing-authority.ts +32 -6
  108. package/lib/nan-provider.ts +3 -2
  109. package/lib/native-choice-list.ts +20 -2
  110. package/lib/native-review-cli.ts +103 -21
  111. package/lib/notification-customize.ts +48 -51
  112. package/lib/openai-fast-tier.ts +22 -0
  113. package/lib/orchestrator-discovery.ts +5 -1
  114. package/lib/orchestrator-fallback.ts +75 -0
  115. package/lib/orchestrator-mode-policy.ts +105 -0
  116. package/lib/pasted-image-paths.ts +113 -0
  117. package/lib/questionnaire/questionnaire-view.ts +225 -18
  118. package/lib/rdd-mode-control.ts +32 -0
  119. package/lib/reply-language-anchor.ts +104 -0
  120. package/lib/review-blocker.ts +92 -0
  121. package/lib/review-candidate-symlink-scan.ts +136 -0
  122. package/lib/review-candidate-view-owner.ts +85 -44
  123. package/lib/review-candidate-view.ts +10 -7
  124. package/lib/review-continuation-registry.ts +99 -0
  125. package/lib/review-coordinator.ts +163 -0
  126. package/lib/review-failure-facts.ts +49 -0
  127. package/lib/review-host-relay.ts +51 -11
  128. package/lib/review-integration-v2.ts +29 -8
  129. package/lib/review-relay-phase-timing.ts +45 -0
  130. package/lib/review-repository.ts +5 -0
  131. package/lib/review-start-context.ts +17 -0
  132. package/lib/session-profile-append-controller.ts +21 -6
  133. package/lib/session-profile-authority.ts +119 -0
  134. package/lib/session-profile-binding.ts +54 -5
  135. package/lib/session-profile-freeze.ts +107 -9
  136. package/lib/session-profile-integration.ts +313 -0
  137. package/lib/session-profile-persistence.ts +63 -9
  138. package/lib/shell-bar.ts +269 -72
  139. package/lib/shell-card.ts +26 -6
  140. package/lib/shell-changes.ts +2 -0
  141. package/lib/shell-page.ts +120 -0
  142. package/lib/shell-panel.ts +163 -0
  143. package/lib/shell-prompt.ts +53 -1
  144. package/lib/shell-sidebar-layout.ts +198 -53
  145. package/lib/shell-sidebar.ts +61 -1
  146. package/lib/shell-stats.ts +123 -0
  147. package/lib/shell-todo.ts +79 -1
  148. package/lib/shell-usage.ts +12 -2
  149. package/lib/star-prompt.ts +197 -0
  150. package/lib/verifier-admission.ts +18 -8
  151. package/lib/verifier-settle-reminder.ts +64 -0
  152. package/lib/vim-editor-adapter.ts +6 -1
  153. package/lib/visual-customization-policy.ts +67 -12
  154. package/lib/visual-customize-view.ts +373 -40
  155. package/lib/visual-layout-preview.ts +47 -0
  156. package/lib/visual-profiles.ts +2 -2
  157. package/lib/windows-session-transport.ts +53 -2
  158. package/lib/yolo-session-policy.ts +68 -16
  159. package/package.json +2 -1
  160. package/runtime/gentle-ai-binary.mjs +1 -1
  161. package/runtime/gentle-shell-bundled.mjs +6 -19
  162. package/runtime/gentle-shell-launcher.mjs +46 -7
  163. package/runtime/native-review-cli.mjs +100 -18
  164. package/runtime/review-integration-v2.mjs +29 -8
  165. package/runtime/windows-session-transport.ps1 +60 -3
  166. package/scripts/bootstrap.sh +4 -1
  167. package/scripts/build-full-delegation-card.mjs +175 -0
  168. package/scripts/bundled-install.mjs +38 -8
  169. package/scripts/download-progress.mjs +68 -0
  170. package/scripts/gentle-ai-installer.mjs +41 -18
  171. package/scripts/gentle-ai-proxy.mjs +294 -0
  172. package/scripts/install-gentle-ai.mjs +14 -1
  173. package/scripts/installer-preflight.mjs +6 -6
  174. package/scripts/installer-runner.mjs +27 -12
  175. package/scripts/installer-server.mjs +8 -7
  176. package/scripts/pi-update.mjs +113 -3
  177. package/scripts/render-cache-host.mjs +72 -0
  178. package/scripts/render-cache-performance-worker.mjs +5 -4
  179. package/scripts/render-cache-performance.mjs +6 -1
  180. package/scripts/run-test-suite.mjs +41 -13
  181. package/scripts/shell-snapshot.mjs +340 -0
  182. package/scripts/test-packed-runner.mjs +1 -1
  183. package/scripts/update-agent-body-history.mjs +41 -0
  184. package/scripts/verify-installer-tap.mjs +45 -0
  185. package/scripts/verify-package-files.mjs +14 -2
  186. package/scripts/voice-worker.cjs +32 -6
  187. package/skills/design/SKILL.md +11 -8
  188. package/skills/gentle-ai/SKILL.md +4 -4
  189. package/skills/gentle-ui-design/SKILL.md +46 -0
  190. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  191. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  192. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  193. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  194. package/skills/skill-registry/SKILL.md +4 -2
  195. package/skills/tui-design/NOTICE.md +5 -0
  196. package/skills/tui-design/SKILL.md +56 -0
  197. package/skills/tui-design/references/commands.md +75 -0
  198. package/skills/tui-design/references/critique.md +48 -0
  199. package/skills/tui-design/references/design-doc.md +44 -0
  200. package/skills/tui-design/references/terminal-craft.md +64 -0
  201. package/skills/tui-design/references/visual-loop.md +32 -0
  202. package/skills/work-unit-commits/SKILL.md +6 -7
  203. package/tests/agent-home.test.ts +28 -9
  204. package/tests/agent-profiles-workflow.test.ts +163 -0
  205. package/tests/agent-risk-escalation.test.ts +1 -1
  206. package/tests/agent-status.test.ts +143 -0
  207. package/tests/agents-config.test.ts +96 -0
  208. package/tests/agents-history.test.ts +31 -0
  209. package/tests/agents-jobs-frames.test.ts +93 -0
  210. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  211. package/tests/agents-protocol.test.ts +53 -1
  212. package/tests/agents-runner-drain.test.ts +193 -0
  213. package/tests/agents-runner.test.ts +345 -4
  214. package/tests/agents-view.test.ts +27 -0
  215. package/tests/agents-widget.test.ts +312 -10
  216. package/tests/append-system-prompt-route.test.ts +4 -1
  217. package/tests/ask-user-choice.test.ts +4 -3
  218. package/tests/ask-user-question.test.ts +97 -0
  219. package/tests/auto-permission-runtime.test.ts +1 -1
  220. package/tests/autonomous-guard.test.ts +346 -10
  221. package/tests/bounded-scan-contract.test.ts +39 -0
  222. package/tests/bounded-stop-contract.test.ts +43 -3
  223. package/tests/bridge-cost.test.ts +47 -0
  224. package/tests/bundled-install.test.ts +36 -9
  225. package/tests/card-content-policy.test.ts +3 -3
  226. package/tests/chained-pr-skill.test.ts +8 -6
  227. package/tests/child-safety.test.ts +11 -0
  228. package/tests/ci-concurrency.test.ts +11 -0
  229. package/tests/ci-merge-base-identity.test.ts +114 -0
  230. package/tests/codegraph-tools.test.ts +80 -5
  231. package/tests/codemode-rendering.test.ts +22 -2
  232. package/tests/command-palette.test.ts +300 -3
  233. package/tests/commit-slice-signal.test.ts +11 -9
  234. package/tests/delegate-for-reason-contract.test.ts +8 -7
  235. package/tests/design-canvas-assets.test.ts +185 -2
  236. package/tests/destructive-command-guard.test.ts +52 -0
  237. package/tests/download-progress.test.ts +71 -0
  238. package/tests/execution-surface-guard.test.ts +55 -0
  239. package/tests/exploration-budget.test.ts +128 -0
  240. package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
  241. package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
  242. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -14
  243. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  244. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  245. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  246. package/tests/fixtures/session-profile-v1/replay.ts +172 -0
  247. package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
  248. package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
  249. package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
  250. package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
  251. package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
  252. package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
  253. package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
  254. package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
  255. package/tests/full-delegation-closure.test.ts +131 -0
  256. package/tests/full-delegation-notices.test.ts +76 -0
  257. package/tests/generic-agent-tools.test.ts +3 -3
  258. package/tests/gentle-agent-status.test.ts +74 -0
  259. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  260. package/tests/gentle-agents.test.ts +1491 -38
  261. package/tests/gentle-ai-binary.test.ts +3 -1
  262. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  263. package/tests/gentle-ai-exploration-budget.test.ts +151 -0
  264. package/tests/gentle-ai-installer.test.ts +134 -51
  265. package/tests/gentle-ai-proxy.test.ts +434 -0
  266. package/tests/gentle-ai.test.ts +1101 -52
  267. package/tests/gentle-design.test.ts +21 -0
  268. package/tests/gentle-fast.test.ts +73 -0
  269. package/tests/gentle-guide.test.ts +208 -0
  270. package/tests/gentle-herdr-activity.test.ts +80 -3
  271. package/tests/gentle-herdr-agent.test.ts +111 -0
  272. package/tests/gentle-program-identity.test.ts +197 -0
  273. package/tests/gentle-shell-bin.test.ts +172 -26
  274. package/tests/gentle-shell-bundled.test.ts +207 -31
  275. package/tests/gentle-shell-launcher.test.ts +93 -10
  276. package/tests/gentle-shell.test.ts +1937 -66
  277. package/tests/gentle-stats.test.ts +15 -2
  278. package/tests/gentle-todo.test.ts +67 -4
  279. package/tests/gentle-tps.test.ts +123 -0
  280. package/tests/gentle-ui-design-skill.test.ts +59 -0
  281. package/tests/herdr-busy.test.ts +59 -0
  282. package/tests/herdr-task-summary-policy.test.ts +132 -0
  283. package/tests/history-store-private-mode.test.ts +40 -0
  284. package/tests/image-disk-cache.test.ts +163 -0
  285. package/tests/image-paste-chips.test.ts +42 -0
  286. package/tests/independent-recovery-delivery.test.ts +83 -0
  287. package/tests/inprocess-reviewer.test.ts +298 -4
  288. package/tests/installer-posix-bootstrap.test.ts +68 -6
  289. package/tests/installer-preflight.test.ts +5 -4
  290. package/tests/installer-runner.test.ts +79 -44
  291. package/tests/installer-server.test.ts +14 -11
  292. package/tests/installer-windows-diagnostics.test.ts +4 -5
  293. package/tests/isolated-config-home.ts +28 -0
  294. package/tests/jobs-view.test.ts +260 -6
  295. package/tests/jobs-widget.test.ts +25 -37
  296. package/tests/keymaps-customize.test.ts +114 -0
  297. package/tests/keymaps.test.ts +103 -0
  298. package/tests/maintainer/mcp-status.maintest.ts +88 -0
  299. package/tests/maintainer/pi-update-source.maintest.ts +116 -0
  300. package/tests/modal-mouse-boundaries.test.ts +136 -0
  301. package/tests/model-fallback-notice.test.ts +45 -0
  302. package/tests/model-fallback-policy.test.ts +83 -0
  303. package/tests/model-fallback-store.test.ts +111 -0
  304. package/tests/model-routing-authority.test.ts +178 -2
  305. package/tests/nan-provider.test.ts +4 -4
  306. package/tests/native-choice-list.test.ts +77 -2
  307. package/tests/native-review-capability-contract.test.ts +7 -1
  308. package/tests/native-review-cli.test.ts +269 -1
  309. package/tests/no-self-pause-contract.test.ts +22 -0
  310. package/tests/notification-customize.test.ts +58 -34
  311. package/tests/odd-routing-canonical-ratchet.test.ts +6 -6
  312. package/tests/odd-routing-contract.test.ts +1 -1
  313. package/tests/orchestrator-budget.test.ts +7 -2
  314. package/tests/orchestrator-delegation-mode.test.ts +153 -0
  315. package/tests/orchestrator-fallback.test.ts +82 -0
  316. package/tests/orchestrator-mode-policy.test.ts +175 -0
  317. package/tests/orchestrator-prompt-budget.test.ts +133 -0
  318. package/tests/orchestrator-rdd-ownership.test.ts +2 -2
  319. package/tests/package-manifest.test.ts +169 -14
  320. package/tests/pasted-image-paths.test.ts +118 -0
  321. package/tests/permission-allowlist.test.ts +202 -0
  322. package/tests/persona-reply-language.test.ts +20 -1
  323. package/tests/pi-update-launcher.test.ts +40 -8
  324. package/tests/pi-update-source.test.ts +162 -0
  325. package/tests/pnpm-workspace-config.test.ts +58 -0
  326. package/tests/primary-session-prompt.test.ts +13 -0
  327. package/tests/profile-fast-tier.test.ts +311 -0
  328. package/tests/profile-pin.test.ts +29 -2
  329. package/tests/profile-tier-footer.test.ts +84 -0
  330. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  331. package/tests/questionnaire-view.test.ts +265 -0
  332. package/tests/quiet-bash-runtime.test.ts +1 -1
  333. package/tests/quiet-tool-rendering.test.ts +48 -0
  334. package/tests/rdd-aware-verification-contract.test.ts +16 -11
  335. package/tests/rdd-customize.test.ts +287 -0
  336. package/tests/rdd-mode-cache.test.ts +450 -0
  337. package/tests/rdd-mode-control.test.ts +407 -0
  338. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  339. package/tests/rdd-off-independent-regression.test.ts +69 -0
  340. package/tests/rdd-status-line.test.ts +18 -0
  341. package/tests/render-cache-performance.test.ts +171 -2
  342. package/tests/reply-language-anchor.test.ts +173 -0
  343. package/tests/review-agent-end-preflight.test.ts +1 -1
  344. package/tests/review-blocker.test.ts +193 -0
  345. package/tests/review-candidate-owner-retry.test.ts +1 -1
  346. package/tests/review-candidate-owner-sweep.test.ts +93 -0
  347. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  348. package/tests/review-candidate-view.test.ts +52 -1
  349. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  350. package/tests/review-candidate-windows-probe.test.ts +63 -0
  351. package/tests/review-committed-restart-ack.test.ts +129 -0
  352. package/tests/review-continuation-registry.test.ts +76 -0
  353. package/tests/review-controller-native-routing.test.ts +381 -11
  354. package/tests/review-controller-workspace-root.test.ts +230 -3
  355. package/tests/review-controller.test.ts +96 -11
  356. package/tests/review-coordinator-runtime.test.ts +117 -0
  357. package/tests/review-coordinator.test.ts +195 -0
  358. package/tests/review-failure-facts.test.ts +87 -0
  359. package/tests/review-gate.test.ts +24 -0
  360. package/tests/review-host-relay-routing.test.ts +258 -4
  361. package/tests/review-host-relay.test.ts +39 -0
  362. package/tests/review-inspect-preflight.test.ts +197 -0
  363. package/tests/review-integration-v2-forward.test.ts +59 -0
  364. package/tests/review-integration-v2.test.ts +46 -3
  365. package/tests/review-json-arguments.test.ts +65 -10
  366. package/tests/review-last-event-closure.test.ts +68 -0
  367. package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
  368. package/tests/review-owner-identity.test.ts +60 -24
  369. package/tests/review-relay-phase-timing.test.ts +128 -0
  370. package/tests/review-relay-transport-agent.test.ts +12 -2
  371. package/tests/review-repository.test.ts +52 -1
  372. package/tests/review-reviewer-evidence.test.ts +183 -0
  373. package/tests/review-risk-assessment.test.ts +74 -3
  374. package/tests/review-session-standing-permission-controller.test.ts +21 -1
  375. package/tests/review-sidebar-state.test.ts +5 -5
  376. package/tests/review-start-context.test.ts +19 -0
  377. package/tests/review-tool-prose-budget.test.ts +121 -0
  378. package/tests/run-test-suite.test.ts +183 -6
  379. package/tests/runtime-harness.mjs +4 -1
  380. package/tests/sensitive-path-tools.test.ts +250 -0
  381. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  382. package/tests/session-profile-append-controller.test.ts +63 -0
  383. package/tests/session-profile-authority.test.ts +259 -0
  384. package/tests/session-profile-binding.test.ts +34 -1
  385. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  386. package/tests/session-profile-extension.test.ts +615 -0
  387. package/tests/session-profile-freeze.test.ts +110 -2
  388. package/tests/session-profile-integration.test.ts +857 -0
  389. package/tests/session-profile-persistence.test.ts +57 -0
  390. package/tests/session-profile-v1-compat.test.ts +255 -0
  391. package/tests/shell-bar.test.ts +274 -72
  392. package/tests/shell-card.test.ts +13 -1
  393. package/tests/shell-page.test.ts +108 -0
  394. package/tests/shell-panel.test.ts +360 -0
  395. package/tests/shell-prompt.test.ts +54 -0
  396. package/tests/shell-render-cache.test.ts +5 -0
  397. package/tests/shell-sidebar-fullscreen.test.ts +13 -1
  398. package/tests/shell-sidebar-layout.test.ts +447 -44
  399. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  400. package/tests/shell-stats.test.ts +90 -0
  401. package/tests/shell-surface-transparent.test.ts +89 -0
  402. package/tests/shell-todo.test.ts +12 -0
  403. package/tests/shell-usage.test.ts +14 -0
  404. package/tests/skill-registry.test.ts +902 -2
  405. package/tests/star-prompt.test.ts +470 -0
  406. package/tests/startup-banner.test.ts +209 -2
  407. package/tests/startup-home-repo.test.ts +2 -0
  408. package/tests/support/review-coordinator-runtime.ts +69 -0
  409. package/tests/task-size-routing-contract.test.ts +50 -4
  410. package/tests/verifier-admission.test.ts +49 -0
  411. package/tests/verifier-settle-reminder.test.ts +281 -0
  412. package/tests/verify-first-launch-contract.test.ts +134 -8
  413. package/tests/verify-installer-tap.test.ts +57 -0
  414. package/tests/vim-editor-adapter.test.ts +2 -2
  415. package/tests/visual-customization-policy.test.ts +95 -8
  416. package/tests/visual-customize-view.test.ts +818 -9
  417. package/tests/visual-layout-preview.test.ts +42 -0
  418. package/tests/visual-profiles.test.ts +11 -0
  419. package/tests/voice-worker.test.ts +73 -2
  420. package/tests/windows-session-bootstrap.test.ts +105 -2
  421. package/tests/windows-session-transport.test.ts +126 -0
  422. package/tests/work-continuity-contract.test.ts +114 -0
  423. package/tests/writer-feature-document-admission.test.ts +92 -0
  424. package/tests/writer-surfaces.test.ts +12 -10
  425. package/tests/yolo-customize.test.ts +57 -15
  426. package/tests/yolo-mode-runtime.test.ts +4 -2
  427. package/tests/yolo-mode.test.ts +39 -20
  428. package/tests/yolo-session-policy.test.ts +270 -1
@@ -1,8 +1,9 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
- import { visibleWidth } from "@earendil-works/pi-tui";
3
+ import { TuiAltScreen, visibleWidth, type Terminal, type TuiMouseEvent } from "@earendil-works/pi-tui";
4
+ import { loadThemeFromPath } from "../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js";
4
5
  import type { JobRecord } from "../lib/background-jobs.ts";
5
- import { JobsView } from "../lib/jobs-view.ts";
6
+ import { JobsView, type JobsViewDeps } from "../lib/jobs-view.ts";
6
7
  import { stripAnsi } from "../lib/terminal-theme.ts";
7
8
 
8
9
  const theme = { fg: (_role: string, text: string) => text };
@@ -22,12 +23,12 @@ function job(overrides: Partial<JobRecord> & Pick<JobRecord, "id">): JobRecord {
22
23
  };
23
24
  }
24
25
 
25
- function harness(jobs: JobRecord[], rows = 14) {
26
+ function harness(jobs: JobRecord[], rows = 14, colors: JobsViewDeps["theme"] = theme) {
26
27
  const stopped: string[] = [];
27
28
  let closed = 0;
28
29
  let renders = 0;
29
30
  const view = new JobsView({
30
- theme,
31
+ theme: colors,
31
32
  rows: () => rows,
32
33
  jobs: () => jobs,
33
34
  now: () => 125_000,
@@ -35,10 +36,27 @@ function harness(jobs: JobRecord[], rows = 14) {
35
36
  onClose: () => { closed += 1; },
36
37
  requestRender: () => { renders += 1; },
37
38
  });
38
- const screen = (width = 100) => view.render(width).map(stripAnsi);
39
- return { view, screen, stopped, closed: () => closed, renders: () => renders };
39
+ const interaction = view;
40
+ const frame = (width = 100) => interaction.render(width);
41
+ const screen = (width = 100) => frame(width).map(stripAnsi);
42
+ return { view, interaction, frame, screen, stopped, closed: () => closed, renders: () => renders, setRows: (next: number) => { rows = next; } };
40
43
  }
41
44
 
45
+ function mouse(frame: string[], text: string, type: TuiMouseEvent["type"] = "click", button: TuiMouseEvent["button"] = type === "move" ? "none" : "left"): TuiMouseEvent {
46
+ const lines = frame.map(stripAnsi);
47
+ const y = lines.findIndex((line) => line.includes(text));
48
+ assert.ok(y >= 0, `Missing ${text}:\n${lines.join("\n")}`);
49
+ const x = visibleWidth(lines[y]!.slice(0, lines[y]!.indexOf(text)));
50
+ return { type, button, x, y, screenX: x, screenY: y, width: visibleWidth(lines[0]!), height: lines.length, shift: false, alt: false, ctrl: false };
51
+ }
52
+
53
+ function click(h: ReturnType<typeof harness>, frame: string[], text: string): void {
54
+ h.interaction.handleMouse(mouse(frame, text, "press"));
55
+ h.interaction.handleMouse(mouse(frame, text));
56
+ }
57
+
58
+ const gentleTheme = loadThemeFromPath("themes/Gentle.json", "truecolor");
59
+
42
60
  test("the split view lists this session's jobs beside the selected job's details and output tail", () => {
43
61
  const h = harness([
44
62
  job({ id: "job-1", label: "CI for PR 1834", command: "gh run watch 42 --exit-status", tail: ["check lint: pass", "check test: pending"] }),
@@ -158,3 +176,239 @@ test("a monitor shows its kind and event count in the list and details", () => {
158
176
  assert.match(text, /Status +running · .* · 3 events/);
159
177
  } finally { h.view.dispose(); }
160
178
  });
179
+
180
+ test("pointer hover uses the shared warning role without selecting, stopping or repeatedly redrawing", () => {
181
+ const h = harness([job({ id: "first" }), job({ id: "second" })], 14, gentleTheme);
182
+ try {
183
+ let frame = h.frame();
184
+ const event = mouse(frame, "second", "move");
185
+ const before = h.renders();
186
+ assert.equal(h.interaction.handleMouse(event)?.render, true);
187
+ frame = h.frame();
188
+ const hovered = frame[event.y]!;
189
+ assert.ok(hovered.includes(gentleTheme.getFgAnsi("warning")), "the rendered job row uses the warning token");
190
+ assert.match(frame.map(stripAnsi).join("\n"), /› ◐ first/);
191
+ assert.deepEqual(h.stopped, []);
192
+ assert.equal(h.closed(), 0);
193
+ assert.equal(h.interaction.handleMouse(event)?.render, false, "the same target does not redraw");
194
+ assert.equal(h.renders(), before);
195
+ const blank = { ...event, x: 3, screenX: 3, y: 7, screenY: 7 };
196
+ h.interaction.handleMouse(blank);
197
+ assert.equal(h.renders(), before + 1, "moving to a blank row clears the hover");
198
+ assert.ok(!h.frame()[event.y]!.includes(gentleTheme.getFgAnsi("warning")));
199
+ } finally { h.view.dispose(); }
200
+ });
201
+
202
+ test("clicking a visible row selects its exact job and never implicitly stops it", () => {
203
+ const h = harness([job({ id: "first" }), job({ id: "second", tail: ["second output"] })]);
204
+ try {
205
+ let frame = h.frame();
206
+ h.interaction.handleMouse(mouse(frame, "second", "press"));
207
+ assert.match(h.screen().join("\n"), /› ◐ first/, "press alone does not select");
208
+ frame = h.frame();
209
+ h.interaction.handleMouse(mouse(frame, "second", "click", "right"));
210
+ assert.match(h.screen().join("\n"), /› ◐ first/, "right click does nothing");
211
+ frame = h.frame();
212
+ click(h, frame, "second");
213
+ assert.match(h.screen().join("\n"), /› ◐ second/);
214
+ assert.match(h.screen().join("\n"), /second output/);
215
+ assert.deepEqual(h.stopped, []);
216
+ assert.equal(h.closed(), 0);
217
+ } finally { h.view.dispose(); }
218
+ });
219
+
220
+ test("stale rows, hidden rows and invalid geometry never select or stop a different job", () => {
221
+ const jobs = [job({ id: "first", startedAt: 20 }), job({ id: "second", startedAt: 10 })];
222
+ const h = harness(jobs);
223
+ try {
224
+ const frame = h.frame();
225
+ const stale = mouse(frame, "second");
226
+ jobs.push(job({ id: "newest", startedAt: 30 }));
227
+ h.interaction.handleMouse(stale);
228
+ assert.match(h.screen().join("\n"), /› ◐ first/, "a reordered row is rejected");
229
+ const fresh = h.frame();
230
+ const title = mouse(fresh, "Jobs");
231
+ const blank = { ...title, x: 3, screenX: 3, y: 8, screenY: 8 };
232
+ h.interaction.handleMouse(title);
233
+ h.interaction.handleMouse(blank);
234
+ h.interaction.handleMouse({ ...mouse(fresh, "second"), width: 99 });
235
+ assert.match(h.screen().join("\n"), /› ◐ first/);
236
+ assert.deepEqual(h.stopped, []);
237
+ assert.equal(h.closed(), 0);
238
+ } finally { h.view.dispose(); }
239
+ });
240
+
241
+ test("the explicit stop control rechecks the rendered identity and current running status", () => {
242
+ const first = job({ id: "first" });
243
+ const second = job({ id: "second" });
244
+ const h = harness([first, second], 14, gentleTheme);
245
+ try {
246
+ let frame = h.frame();
247
+ const stop = mouse(frame, "s Stop");
248
+ h.interaction.handleMouse({ ...stop, type: "move", button: "none" });
249
+ assert.ok(h.frame()[stop.y]!.includes(gentleTheme.getFgAnsi("warning")));
250
+ assert.deepEqual(h.stopped, []);
251
+ h.interaction.handleMouse({ ...stop, type: "press" });
252
+ h.view.handleInput("j");
253
+ frame = h.frame();
254
+ h.interaction.handleMouse(mouse(frame, "s Stop"));
255
+ assert.deepEqual(h.stopped, [], "a press on first cannot stop second after selection changes");
256
+ click(h, frame, "s Stop");
257
+ assert.deepEqual(h.stopped, ["second"]);
258
+ frame = h.frame();
259
+ const staleStop = mouse(frame, "s Stop");
260
+ second.status = "exited";
261
+ h.interaction.handleMouse(staleStop);
262
+ assert.deepEqual(h.stopped, ["second"], "a finished job cannot be stopped using an old control");
263
+ assert.doesNotMatch(h.screen().at(-2)!, /s Stop/);
264
+ assert.equal(first.status, "running");
265
+ } finally { h.view.dispose(); }
266
+ });
267
+
268
+ test("narrow details/list and close controls work by click while hidden controls stay inert", () => {
269
+ const h = harness([job({ id: "first" }), job({ id: "second", command: "show second" })], 14, gentleTheme);
270
+ try {
271
+ let frame = h.frame(40);
272
+ click(h, frame, "second");
273
+ frame = h.frame(40);
274
+ assert.match(frame.map(stripAnsi).join("\n"), /show second/);
275
+ assert.doesNotMatch(frame.map(stripAnsi).join("\n"), /› ◐ second/);
276
+ const back = mouse(frame, "tab list", "move");
277
+ h.interaction.handleMouse(back);
278
+ assert.ok(h.frame(40)[back.y]!.includes(gentleTheme.getFgAnsi("warning")));
279
+ frame = h.frame(40);
280
+ click(h, frame, "tab list");
281
+ frame = h.frame(40);
282
+ assert.match(frame.map(stripAnsi).join("\n"), /› ◐ second/);
283
+ click(h, frame, "tab details");
284
+ frame = h.frame(40);
285
+ assert.match(frame.map(stripAnsi).join("\n"), /show second/);
286
+ const close = mouse(frame, "q close", "move");
287
+ h.interaction.handleMouse(close);
288
+ assert.ok(h.frame(40)[close.y]!.includes(gentleTheme.getFgAnsi("warning")));
289
+ assert.equal(h.closed(), 0, "hovering close does not close the overlay");
290
+ click(h, h.frame(40), "q close");
291
+ assert.equal(h.closed(), 1);
292
+ assert.deepEqual(h.stopped, []);
293
+ } finally { h.view.dispose(); }
294
+ });
295
+
296
+ test("very narrow details retain visible mouse back and close controls", () => {
297
+ for (const width of [12, 14, 20, 24, 30, 40]) {
298
+ const h = harness([job({ id: "first" }), job({ id: "second", command: "second detail" })]);
299
+ try {
300
+ h.frame(width);
301
+ h.view.handleInput("\t");
302
+ let frame = h.frame(width);
303
+ const footer = stripAnsi(frame.at(-2)!);
304
+ const back = footer.includes("tab list") ? "tab list" : "←";
305
+ const close = footer.includes("q close") ? "q close" : "×";
306
+ assert.ok(footer.includes(back) && footer.includes(close), `${width} columns: ${footer}`);
307
+ click(h, frame, back);
308
+ frame = h.frame(width);
309
+ const listFooter = stripAnsi(frame.at(-2)!);
310
+ assert.ok(listFooter.includes("tab details") || listFooter.includes("→"), `${width} columns: ${listFooter}`);
311
+ assert.deepEqual(h.stopped, []);
312
+ assert.equal(h.closed(), 0);
313
+ } finally { h.view.dispose(); }
314
+ }
315
+ });
316
+
317
+ test("a changed row under a pending press cannot select the replacement", () => {
318
+ const jobs = [job({ id: "first", startedAt: 20 }), job({ id: "second", startedAt: 10 })];
319
+ const h = harness(jobs);
320
+ try {
321
+ const before = h.frame();
322
+ const row = mouse(before, "second");
323
+ h.interaction.handleMouse({ ...row, type: "press" });
324
+ jobs.push(job({ id: "newest", startedAt: 30 }));
325
+ h.frame();
326
+ h.interaction.handleMouse(row);
327
+ assert.match(h.screen().join("\n"), /› ◐ first/);
328
+ assert.deepEqual(h.stopped, []);
329
+ assert.equal(h.closed(), 0);
330
+ } finally { h.view.dispose(); }
331
+ });
332
+
333
+ test("scrolled lists target only the visible job identities and fallback close remains clickable", () => {
334
+ const h = harness(Array.from({ length: 6 }, (_, index) => job({ id: `job-${index}`, startedAt: 6 - index })), 6);
335
+ try {
336
+ const stale = mouse(h.frame(), "job-1");
337
+ for (let index = 0; index < 4; index += 1) h.view.handleInput("j");
338
+ h.interaction.handleMouse(stale);
339
+ let frame = h.frame();
340
+ assert.match(frame.map(stripAnsi).join("\n"), /› ◐ job-4/);
341
+ assert.ok(!frame.map(stripAnsi).some((line) => line.includes("job-0")));
342
+ click(h, frame, "job-3");
343
+ assert.match(h.screen().join("\n"), /› ◐ job-3/);
344
+ assert.deepEqual(h.stopped, []);
345
+ frame = h.frame(8);
346
+ click(h, frame, "×");
347
+ assert.equal(h.closed(), 1);
348
+ } finally { h.view.dispose(); }
349
+ });
350
+
351
+ test("resize, invalidation and disposal discard pointer geometry and hover", () => {
352
+ const h = harness([job({ id: "first" }), job({ id: "second" })], 14, gentleTheme);
353
+ try {
354
+ let frame = h.frame();
355
+ const row = mouse(frame, "second");
356
+ h.interaction.handleMouse({ ...row, type: "move", button: "none" });
357
+ h.setRows(8);
358
+ h.interaction.handleMouse(row);
359
+ assert.deepEqual(h.stopped, []);
360
+ frame = h.frame(80);
361
+ assert.ok(!frame.join("\n").includes(gentleTheme.getFgAnsi("warning")));
362
+ assert.match(frame.map(stripAnsi).join("\n"), /› ◐ first/);
363
+ const fresh = mouse(frame, "second");
364
+ h.interaction.handleMouse({ ...fresh, type: "move", button: "none" });
365
+ assert.ok(h.frame(80)[fresh.y]!.includes(gentleTheme.getFgAnsi("warning")));
366
+ h.view.invalidate();
367
+ h.interaction.handleMouse(fresh);
368
+ frame = h.frame(80);
369
+ assert.ok(!frame.join("\n").includes(gentleTheme.getFgAnsi("warning")));
370
+ assert.match(frame.map(stripAnsi).join("\n"), /› ◐ first/);
371
+ h.interaction.handleMouse({ ...fresh, type: "move", button: "none" });
372
+ h.view.dispose();
373
+ h.interaction.handleMouse(fresh);
374
+ assert.ok(!h.frame(80).join("\n").includes(gentleTheme.getFgAnsi("warning")));
375
+ assert.deepEqual(h.stopped, []);
376
+ assert.equal(h.closed(), 0);
377
+ } finally { h.view.dispose(); }
378
+ });
379
+
380
+ test("real centered TuiAltScreen SGR events hover, select and stop the visible job", () => {
381
+ let input: ((data: string) => void) | undefined;
382
+ const terminal: Terminal = {
383
+ start(onInput) { input = onInput; }, stop() {}, async drainInput() {}, write() {}, get columns() { return 120; }, get rows() { return 30; }, get kittyProtocolActive() { return false; }, moveBy() {}, hideCursor() {}, showCursor() {}, clearLine() {}, clearFromCursor() {}, clearScreen() {}, setTitle() {}, setProgress() {}, setProgramStatus() {},
384
+ };
385
+ const h = harness([job({ id: "first" }), job({ id: "second" })], 14, gentleTheme);
386
+ const tui = new TuiAltScreen(terminal, false, undefined, { mouse: true });
387
+ const overlay = tui.showOverlay(h.interaction, { anchor: "center", width: 80, maxHeight: 14 });
388
+ tui.start();
389
+ tui.renderNow(true);
390
+ try {
391
+ const bounds = overlay.getBounds();
392
+ assert.ok(bounds && bounds.col > 0 && bounds.row > 0);
393
+ let frame = h.frame(80);
394
+ const row = mouse(frame, "second");
395
+ const x = bounds.col + row.x + 1, y = bounds.row + row.y + 1;
396
+ input?.(`\x1b[<35;${x};${y}M`);
397
+ frame = h.frame(80);
398
+ assert.ok(frame[row.y]!.includes(gentleTheme.getFgAnsi("warning")));
399
+ assert.match(frame.map(stripAnsi).join("\n"), /› ◐ first/);
400
+ input?.("\x1b[<35;1;1M");
401
+ assert.ok(h.frame(80)[row.y]!.includes(gentleTheme.getFgAnsi("warning")), "native overlay dispatch does not deliver outside-card motion");
402
+ input?.(`\x1b[<0;${x};${y}M`);
403
+ input?.(`\x1b[<0;${x};${y}m`);
404
+ tui.renderNow(true);
405
+ frame = h.frame(80);
406
+ assert.match(frame.map(stripAnsi).join("\n"), /› ◐ second/);
407
+ assert.deepEqual(h.stopped, []);
408
+ const stop = mouse(frame, "s Stop");
409
+ const sx = bounds.col + stop.x + 1, sy = bounds.row + stop.y + 1;
410
+ input?.(`\x1b[<0;${sx};${sy}M`);
411
+ input?.(`\x1b[<0;${sx};${sy}m`);
412
+ assert.deepEqual(h.stopped, ["second"]);
413
+ } finally { tui.stop(); h.view.dispose(); }
414
+ });
@@ -1,13 +1,12 @@
1
1
  import assert from "node:assert/strict";
2
- import test, { after, before } from "node:test";
2
+ import test from "node:test";
3
3
  import { visibleWidth } from "@earendil-works/pi-tui";
4
- import { JOBS_GLYPH, renderJobsCard, widgetJobs } from "../lib/jobs-widget.ts";
5
- import { CARD_STYLE, cardStyle, setCardStyle } from "../lib/shell-card.ts";
4
+ import { JOBS_GLYPH, renderJobsSection, widgetJobs } from "../lib/jobs-widget.ts";
6
5
  import { stripAnsi } from "../lib/terminal-theme.ts";
7
6
 
8
- // The Jobs sidebar card replaces the Jobs group the Status card used to print.
9
- // Rendering is pure, so it verifies without a TUI: newest job first, one row
10
- // per running job with its elapsed time, collapsible like Agents and Todos.
7
+ // The Jobs rail section (a panel section, see lib/shell-panel.ts). Rendering is
8
+ // pure, so it verifies without a TUI: newest job first, one row per job with
9
+ // its elapsed time, collapsible like Agents and Todos.
11
10
 
12
11
  // Width math counts every painted character, so these assertions use a plain
13
12
  // theme; colored roles are covered by the widget's paint calls, not here.
@@ -25,46 +24,35 @@ const jobs = [
25
24
  { id: "job-1", label: "Build runtime", startedAt: 10_000 },
26
25
  ];
27
26
 
28
- // The card style defaults to float; these assertions pin the outlined (neon)
29
- // panels unless a test switches the style itself.
30
- const initialCardStyle = cardStyle();
31
- before(() => setCardStyle(CARD_STYLE.NEON));
32
- after(() => setCardStyle(initialCardStyle));
33
-
34
- test("the jobs card lists running jobs newest first with elapsed time", () => {
35
- const lines = renderJobsCard(jobs, plainTheme, 50, 100_000, { collapsed: false, collapseControl: true });
27
+ test("the jobs section lists running jobs newest first with elapsed time", () => {
28
+ const lines = renderJobsSection(jobs, plainTheme, 50, 100_000, { collapsed: false });
36
29
  const text = lines.join("\n");
37
- assert.match(text, new RegExp(`${JOBS_GLYPH} Jobs`));
38
- assert.match(text, /2 running/);
30
+ assert.match(lines[0]!, /^▾ JOBS +2 running$/);
31
+ assert.match(text, new RegExp(`${JOBS_GLYPH} job-2 Watcher CI ronda 2`));
39
32
  const watcher = text.indexOf("Watcher CI ronda 2");
40
33
  const build = text.indexOf("Build runtime");
41
34
  assert.ok(watcher >= 0, "the newest job paints");
42
35
  assert.ok(build > watcher, "newest first, matching the /gentle:jobs running group");
43
36
  assert.match(text, /1m 0s/, "the 60s job shows its elapsed time");
44
37
  assert.match(text, /1m 30s/, "the 90s job shows its elapsed time");
45
- assert.match(text, /▾ Collapse/);
46
- for (const line of lines) assert.ok(visibleWidth(stripAnsi(line)) <= 50, `row fits: ${stripAnsi(line)}`);
38
+ for (const line of lines) assert.equal(visibleWidth(stripAnsi(line)), 50, `row fills the section: ${stripAnsi(line)}`);
47
39
  });
48
40
 
49
41
  test("an empty job list paints nothing", () => {
50
- assert.deepEqual(renderJobsCard([], plainTheme, 50, 100_000, { collapsed: false }), []);
42
+ assert.deepEqual(renderJobsSection([], plainTheme, 50, 100_000, { collapsed: false }), []);
51
43
  });
52
44
 
53
- test("a collapsed jobs card keeps the newest job and folds the rest", () => {
54
- // Wide enough for the header to also fit the "ctrl+shift+j expand" hint.
55
- const lines = renderJobsCard(jobs, plainTheme, 64, 100_000, { collapsed: true, collapseKey: "ctrl+shift+j", collapseControl: true });
45
+ test("a collapsed jobs section keeps the newest job and folds the rest", () => {
46
+ const lines = renderJobsSection(jobs, plainTheme, 64, 100_000, { collapsed: true });
56
47
  const text = lines.join("\n");
48
+ assert.match(lines[0]!, /^▸ JOBS/);
57
49
  assert.match(text, /Watcher CI ronda 2/);
58
50
  assert.doesNotMatch(text, /Build runtime/);
59
51
  assert.match(text, /… 1 more/);
60
- assert.match(text, /ctrl\+shift\+j expand/);
61
- assert.match(text, /▸ Expand/);
62
52
  });
63
53
 
64
- test("the collapse control is opt-in and the sort never mutates the snapshot", () => {
54
+ test("the sort never mutates the snapshot", () => {
65
55
  const snapshot = [{ id: "job-1", label: "Build runtime", startedAt: 10_000 }];
66
- const lines = renderJobsCard(snapshot, plainTheme, 50, 100_000, { collapsed: false });
67
- assert.doesNotMatch(lines.join("\n"), /Collapse|Expand/);
68
56
  const sorted = widgetJobs(snapshot, 100_000);
69
57
  assert.deepEqual(snapshot, [{ id: "job-1", label: "Build runtime", startedAt: 10_000 }]);
70
58
  assert.equal(sorted[0]?.id, "job-1");
@@ -80,36 +68,36 @@ function finishedJobs(): Array<typeof exitedJob> {
80
68
  }
81
69
 
82
70
  test("a finished job lingers with a ✓ row and its elapsed frozen at the end", () => {
83
- const lines = renderJobsCard([exitedJob], plainTheme, 50, 100_000, { collapsed: false });
71
+ const lines = renderJobsSection([exitedJob], plainTheme, 50, 100_000, { collapsed: false });
84
72
  const text = lines.join("\n");
85
- assert.match(text, /✓\s+Build runtime/);
73
+ assert.match(text, /✓ job-1 Build runtime/);
86
74
  assert.match(text, /1m 0s/, "elapsed freezes at endedAt instead of ticking to 1m 30s");
87
75
  assert.match(text, /1 finished/);
88
76
  for (const line of lines) assert.ok(visibleWidth(stripAnsi(line)) <= 50, `row fits: ${stripAnsi(line)}`);
89
77
  });
90
78
 
91
79
  test("a nonzero exit paints ✗ and a stopped job paints –", () => {
92
- const lines = renderJobsCard([
80
+ const lines = renderJobsSection([
93
81
  { ...exitedJob, exitCode: 1 },
94
82
  { id: "job-2", label: "Watcher CI", startedAt: 5_000, status: "stopped", endedAt: 60_000 },
95
83
  ], plainTheme, 50, 100_000, { collapsed: false });
96
84
  const text = lines.join("\n");
97
- assert.match(text, /✗\s+Build runtime/);
98
- assert.match(text, /–\s+Watcher CI/);
85
+ assert.match(text, /✗ job-1 Build runtime/);
86
+ assert.match(text, /– job-2 Watcher CI/);
99
87
  assert.match(text, /2 finished/);
100
88
  });
101
89
 
102
90
  test("a failed job rides the tail with the ✗ glyph", () => {
103
- const lines = renderJobsCard([{ ...exitedJob, status: "failed" as const }], plainTheme, 50, 100_000, { collapsed: false });
91
+ const lines = renderJobsSection([{ ...exitedJob, status: "failed" as const }], plainTheme, 50, 100_000, { collapsed: false });
104
92
  const text = lines.join("\n");
105
- assert.match(text, /✗\s+Build runtime/);
93
+ assert.match(text, /✗ job-1 Build runtime/);
106
94
  assert.match(text, /1m 0s/, "elapsed freezes at endedAt like the other outcomes");
107
95
  assert.match(text, /1 finished/);
108
96
  });
109
97
 
110
98
  test("finished jobs past the TTL paint nothing", () => {
111
99
  // now - endedAt lands exactly on the TTL: not fresh anymore.
112
- assert.deepEqual(renderJobsCard([{ ...exitedJob, endedAt: 40_000 }], plainTheme, 50, 100_000, { collapsed: false }), []);
100
+ assert.deepEqual(renderJobsSection([{ ...exitedJob, endedAt: 40_000 }], plainTheme, 50, 100_000, { collapsed: false }), []);
113
101
  });
114
102
 
115
103
  test("at most the three newest finished jobs survive", () => {
@@ -129,8 +117,8 @@ test("running entries sort before the finished tail and never expire", () => {
129
117
  assert.deepEqual(shown.map((job) => job.id), ["new", "old", "done"]);
130
118
  });
131
119
 
132
- test("the subtitle mixes running and finished counts", () => {
133
- const lines = renderJobsCard([
120
+ test("the header count mixes running and finished jobs", () => {
121
+ const lines = renderJobsSection([
134
122
  { id: "job-1", label: "New run", startedAt: 50_000 },
135
123
  { id: "job-2", label: "Watcher CI", startedAt: 5_000, status: "stopped", endedAt: 60_000 },
136
124
  ], plainTheme, 50, 100_000, { collapsed: false });
@@ -0,0 +1,114 @@
1
+ import assert from "node:assert/strict";
2
+ import test, { after } from "node:test";
3
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { buildKeymapRows, type KeymapRowsOptions } from "../lib/keymaps-customize.ts";
7
+ import type { CustomizeInline, CustomizeRow } from "../lib/visual-customize-view.ts";
8
+ import type { PiKeybindings } from "../lib/keymaps.ts";
9
+
10
+ // The Keymaps category of /gentle:customize: one row per action and palette
11
+ // command; Enter captures the next key, ⌫ disables, r restores the default.
12
+
13
+ const homes: string[] = [];
14
+ after(() => { for (const home of homes) rmSync(home, { recursive: true, force: true }); });
15
+
16
+ const PI_KEYS: PiKeybindings = {
17
+ getKeys: (binding) => binding === "tui.editor.deleteToLineEnd" ? ["ctrl+k"] : [],
18
+ getResolvedBindings: () => ({ "tui.editor.deleteToLineEnd": "ctrl+k" }),
19
+ };
20
+
21
+ function setup(env: NodeJS.ProcessEnv = {}) {
22
+ const configHome = mkdtempSync(join(tmpdir(), "gentle-keymaps-customize-"));
23
+ homes.push(configHome);
24
+ const notices: Array<{ message: string; type: string }> = [];
25
+ let reloads = 0;
26
+ const options: KeymapRowsOptions = {
27
+ env, configHome, keybindings: () => PI_KEYS,
28
+ commands: [{ command: "gentle:changes", label: "Browse changes" }, { command: "gentle:design", label: "Design · HTML artboards" }],
29
+ notify: (message, type) => notices.push({ message, type }),
30
+ reload: () => { reloads += 1; },
31
+ };
32
+ const rows = buildKeymapRows(options);
33
+ const row = (prefix: string) => rows.find((candidate) => label(candidate).startsWith(prefix))!;
34
+ const saved = () => existsSync(join(configHome, "keymaps.json")) ? JSON.parse(readFileSync(join(configHome, "keymaps.json"), "utf8")).bindings : undefined;
35
+ return { rows, row, notices, saved, configHome, reloads: () => reloads };
36
+ }
37
+
38
+ function label(row: CustomizeRow): string {
39
+ return typeof row.label === "function" ? row.label() : row.label;
40
+ }
41
+
42
+ /** An inline bridge whose capture answers with `key` and whose confirm answers `yes`. */
43
+ function inline(key: string | undefined, yes = true, asked: string[] = []): CustomizeInline {
44
+ return { capture: async () => key, confirm: async (message) => { asked.push(message); return yes; }, input: async () => undefined, disposed: false };
45
+ }
46
+
47
+ test("every action and palette command has a Keymaps row with its current key, plus a reload row", () => {
48
+ const { rows } = setup({ GENTLE_PI_AGENTS_VIEW_KEY: "alt+w" });
49
+ assert.ok(rows.every((row) => row.category === "Keymaps"));
50
+ assert.deepEqual(rows.map(label), [
51
+ "Command palette: alt+k", "Browse changes: alt+g", "Subscription usage: alt+u", "Cycle visual preset: alt+l",
52
+ "Subagents overlay: alt+w (GENTLE_PI_AGENTS_VIEW_KEY)", "Stop active subagents: alt+s", "Collapse the agents card: ctrl+shift+a",
53
+ "Collapse the jobs card: ctrl+shift+j", "Collapse the todo list: ctrl+shift+t", "Usage stats: none",
54
+ "/gentle:design · Design · HTML artboards: none", "Reload now to apply keymap changes",
55
+ ]);
56
+ });
57
+
58
+ test("Enter captures a key, saves it, and tells the user to reload", async () => {
59
+ const { row, notices, saved } = setup();
60
+ await row("Command palette").action(inline("\x1bj"));
61
+ assert.deepEqual(saved(), { commands: "alt+j" });
62
+ assert.equal(label(row("Command palette")), "Command palette: alt+j");
63
+ assert.deepEqual(notices.at(-1), { message: "Command palette: alt+j. Run /reload to apply it.", type: "info" });
64
+ await row("/gentle:design").action(inline("\x1bd"));
65
+ assert.deepEqual(saved(), { commands: "alt+j", "command:gentle:design": "alt+d" });
66
+ await row("Usage stats").action(inline(undefined));
67
+ assert.deepEqual(saved(), { commands: "alt+j", "command:gentle:design": "alt+d" }, "a cancelled capture saves nothing");
68
+ });
69
+
70
+ test("a reserved key, a typing key or an environment-controlled action is refused and saves nothing", async () => {
71
+ const { row, notices, saved } = setup({ GENTLE_PI_AGENTS_VIEW_KEY: "alt+w" });
72
+ await row("Command palette").action(inline("\x0b"));
73
+ assert.deepEqual(notices.at(-1), { message: "ctrl+k is reserved by Pi (tui.editor.deleteToLineEnd); choose another key.", type: "warning" });
74
+ await row("Command palette").action(inline("a"));
75
+ assert.match(notices.at(-1)!.message, /a is needed for typing/);
76
+ await row("Subagents overlay").action(inline("\x1bv"));
77
+ assert.deepEqual(notices.at(-1), { message: "Subagents overlay is set by GENTLE_PI_AGENTS_VIEW_KEY; unset it to change the key here.", type: "warning" });
78
+ assert.equal(saved(), undefined);
79
+ });
80
+
81
+ test("a key used by another action moves only after confirmation", async () => {
82
+ const { row, saved } = setup();
83
+ const asked: string[] = [];
84
+ await row("Command palette").action(inline("\x1bg", false, asked));
85
+ assert.deepEqual(asked, ["alt+g is used by Browse changes. Move it to Command palette?"]);
86
+ assert.equal(saved(), undefined);
87
+ await row("Command palette").action(inline("\x1bg", true));
88
+ assert.deepEqual(saved(), { commands: "alt+g", changes: null });
89
+ assert.equal(label(row("Browse changes")), "Browse changes: none");
90
+ });
91
+
92
+ test("⌫ disables a key, r restores the default, and the reload row reloads", async () => {
93
+ const { row, saved, notices, reloads } = setup();
94
+ const bridge = inline(undefined);
95
+ assert.equal(row("Browse changes").key!("\x7f", bridge), true);
96
+ assert.deepEqual(saved(), { changes: null });
97
+ assert.deepEqual(notices.at(-1), { message: "Browse changes: none. Run /reload to apply it.", type: "info" });
98
+ assert.equal(row("Browse changes").key!("r", bridge), true);
99
+ assert.deepEqual(saved(), {});
100
+ assert.equal(label(row("Browse changes")), "Browse changes: alt+g");
101
+ assert.equal(row("Browse changes").key!("x", bridge), false, "other keys stay with the card");
102
+ await row("Reload now").action(bridge);
103
+ assert.equal(reloads(), 1);
104
+ });
105
+
106
+ test("a malformed keymaps.json is never overwritten", async () => {
107
+ const { row, notices, configHome } = setup();
108
+ writeFileSync(join(configHome, "keymaps.json"), "{");
109
+ await row("Command palette").action(inline("\x1bj"));
110
+ assert.equal(readFileSync(join(configHome, "keymaps.json"), "utf8"), "{");
111
+ assert.deepEqual(notices.at(-1), { message: `Keymaps: ${join(configHome, "keymaps.json")} is unreadable or malformed; fix or delete it to change keys.`, type: "error" });
112
+ assert.equal(row("Browse changes").key!("\x7f", inline(undefined)), true);
113
+ assert.equal(readFileSync(join(configHome, "keymaps.json"), "utf8"), "{");
114
+ });
@@ -0,0 +1,103 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import {
7
+ assignKeymap, checkKeymap, commandKeymapId, commandKeymapIds, effectiveKey, keyFromInput, KEYMAP_ACTIONS,
8
+ keymapCommand, keymapSource, normalizeKeyId, readKeymaps, resetKeymap, writeKeymaps, type PiKeybindings,
9
+ } from "../lib/keymaps.ts";
10
+
11
+ // The keymap registry every Gentle shortcut reads: environment variable
12
+ // first (unchanged behavior), then the saved keymaps.json, then the default.
13
+
14
+ const DEFAULTS: Record<string, string | undefined> = {
15
+ commands: "alt+k", changes: "alt+g", usage: "alt+u", preset: "alt+l", "agents.view": "alt+a",
16
+ "agents.stop": "alt+s", "agents.collapse": "ctrl+shift+a", "jobs.collapse": "ctrl+shift+j", "todo.collapse": "ctrl+shift+t", "stats.view": undefined,
17
+ };
18
+
19
+ function scratch(): string {
20
+ return mkdtempSync(join(tmpdir(), "gentle-keymaps-"));
21
+ }
22
+
23
+ /** Pi's default bindings for the few ids the checks look at. */
24
+ const PI_KEYS: PiKeybindings = {
25
+ getKeys: (binding) => ({ "tui.editor.deleteToLineEnd": ["ctrl+k"], "app.clear": ["ctrl+c"], "app.model.cycleBackward": ["shift+ctrl+p"] } as Record<string, string[]>)[binding] ?? [],
26
+ getResolvedBindings: () => ({ "tui.editor.deleteToLineEnd": "ctrl+k", "app.clear": "ctrl+c", "tui.editor.cursorWordLeft": ["alt+left", "ctrl+left"] }),
27
+ };
28
+
29
+ test("with no file and no environment every action keeps its default key", () => {
30
+ for (const action of KEYMAP_ACTIONS) assert.equal(effectiveKey(action.id, {}, {}), DEFAULTS[action.id], action.id);
31
+ assert.deepEqual(KEYMAP_ACTIONS.map((action) => action.id).sort(), Object.keys(DEFAULTS).sort());
32
+ });
33
+
34
+ test("a saved key replaces the default, null disables it, and the environment still wins", () => {
35
+ const bindings = { commands: "alt+j", changes: null };
36
+ assert.equal(effectiveKey("commands", {}, bindings), "alt+j");
37
+ assert.equal(keymapSource("commands", {}, bindings), "saved");
38
+ assert.equal(effectiveKey("changes", {}, bindings), undefined);
39
+ assert.equal(effectiveKey("commands", { GENTLE_PI_COMMANDS_KEY: "alt+x" }, bindings), "alt+x");
40
+ assert.equal(keymapSource("commands", { GENTLE_PI_COMMANDS_KEY: "alt+x" }, bindings), "env");
41
+ assert.equal(effectiveKey("commands", { GENTLE_PI_COMMANDS_KEY: "off" }, bindings), undefined);
42
+ assert.equal(effectiveKey("commands", { GENTLE_PI_COMMANDS_KEY: "" }, bindings), undefined);
43
+ assert.equal(keymapSource("usage", {}, bindings), "default");
44
+ assert.equal(keymapSource("stats.view", {}, bindings), "none");
45
+ });
46
+
47
+ test("any palette command gets a command keymap id, built-in commands reuse their action", () => {
48
+ assert.equal(commandKeymapId("gentle:changes"), "changes");
49
+ assert.equal(commandKeymapId("gentle:design"), "command:gentle:design");
50
+ assert.equal(keymapCommand("command:gentle:design"), "gentle:design");
51
+ assert.equal(keymapCommand("changes"), undefined);
52
+ const bindings = { "command:gentle:design": "alt+d", "command:gentle:vim": null };
53
+ assert.equal(effectiveKey("command:gentle:design", {}, bindings), "alt+d");
54
+ assert.deepEqual(commandKeymapIds(bindings), ["command:gentle:design"]);
55
+ });
56
+
57
+ test("key ids are normalized and only modified keys or function keys can be assigned", () => {
58
+ assert.equal(normalizeKeyId("Shift+Ctrl+A"), "ctrl+shift+a");
59
+ assert.equal(normalizeKeyId("hyper+a"), undefined);
60
+ assert.deepEqual(keyFromInput("\x1bj"), { key: "alt+j" });
61
+ assert.deepEqual(keyFromInput("\x1b[97;6u"), { key: "ctrl+shift+a" });
62
+ assert.deepEqual(keyFromInput("\x1bOP"), { key: "f1" });
63
+ assert.match((keyFromInput("a") as { error: string }).error, /needed for typing/);
64
+ assert.match((keyFromInput("\r") as { error: string }).error, /needed for typing/);
65
+ assert.match((keyFromInput("\x1bK") as { error: string }).error, /not recognized/);
66
+ });
67
+
68
+ test("checks block Pi's reserved keys and environment-controlled actions, and confirm a moved key", () => {
69
+ assert.deepEqual(checkKeymap("commands", "ctrl+k", {}, {}, PI_KEYS), { kind: "blocked", message: "ctrl+k is reserved by Pi (tui.editor.deleteToLineEnd); choose another key." });
70
+ assert.equal(checkKeymap("commands", "ctrl+shift+p", {}, {}, PI_KEYS).kind, "blocked");
71
+ assert.deepEqual(checkKeymap("commands", "alt+j", { GENTLE_PI_COMMANDS_KEY: "alt+k" }, {}, PI_KEYS), { kind: "blocked", message: "Command palette is set by GENTLE_PI_COMMANDS_KEY; unset it to change the key here." });
72
+ assert.deepEqual(checkKeymap("commands", "alt+g", {}, {}, PI_KEYS), { kind: "confirm", message: "alt+g is used by Browse changes. Move it to Command palette?", displaces: "changes" });
73
+ assert.equal(checkKeymap("command:gentle:design", "alt+d", {}, { "command:gentle:vim": "alt+d" }, PI_KEYS).kind, "confirm");
74
+ assert.deepEqual(checkKeymap("commands", "alt+left", {}, {}, PI_KEYS), { kind: "confirm", message: "alt+left is Pi's tui.editor.cursorWordLeft. Use it for Command palette instead?" });
75
+ assert.deepEqual(checkKeymap("commands", "alt+j", {}, {}, PI_KEYS), { kind: "ok" });
76
+ assert.deepEqual(checkKeymap("commands", "alt+k", {}, {}, PI_KEYS), { kind: "ok" }, "its own key is not a conflict");
77
+ });
78
+
79
+ test("assigning moves a key off the displaced action, and reset restores the default", () => {
80
+ const moved = assignKeymap({}, "commands", "alt+g", "changes");
81
+ assert.deepEqual(moved, { commands: "alt+g", changes: null });
82
+ assert.deepEqual(assignKeymap({}, "commands", "Shift+Ctrl+X"), { commands: "ctrl+shift+x" });
83
+ assert.deepEqual(resetKeymap(moved, "changes"), { commands: "alt+g" });
84
+ assert.equal(effectiveKey("changes", {}, resetKeymap(moved, "changes")), "alt+g");
85
+ });
86
+
87
+ test("keymaps.json round-trips atomically and a malformed file is reported, not used", () => {
88
+ const home = scratch();
89
+ try {
90
+ assert.deepEqual(readKeymaps(home), { bindings: {}, path: join(home, "keymaps.json"), malformed: false });
91
+ const path = writeKeymaps(home, { commands: "alt+j", changes: null });
92
+ assert.deepEqual(JSON.parse(readFileSync(path, "utf8")), { schema: 1, bindings: { commands: "alt+j", changes: null } });
93
+ assert.deepEqual(readKeymaps(home).bindings, { commands: "alt+j", changes: null });
94
+ assert.deepEqual(readdirSync(home), ["keymaps.json"], "no temporary file is left behind");
95
+ for (const bad of ["{", "[]", '{"schema":2,"bindings":{}}', '{"schema":1,"bindings":{"commands":3}}', '{"schema":1,"bindings":{"commands":"hyper+a"}}']) {
96
+ writeFileSync(path, bad);
97
+ assert.deepEqual(readKeymaps(home), { bindings: {}, path, malformed: true }, bad);
98
+ assert.equal(readFileSync(path, "utf8"), bad, "reading never rewrites the file");
99
+ }
100
+ } finally {
101
+ rmSync(home, { recursive: true, force: true });
102
+ }
103
+ });