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,7 +1,9 @@
1
- import { decodeKittyPrintable, isKeyRelease, matchesKey, Key, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
1
+ import { sanitizeTerminalText } from "./terminal-theme.ts";
2
+ import { decodeKittyPrintable, isKeyRelease, matchesKey, Key, sliceByColumn, truncateToWidth, visibleWidth, type TuiMouseEvent, type TuiMouseEventResult } from "@earendil-works/pi-tui";
2
3
  import type { VisualProfile } from "./visual-profiles.ts";
3
4
  import { CARD_PADDING, renderPaletteCard, renderPaletteSelection } from "./command-palette.ts";
4
5
  import { stripAnsi } from "./terminal-theme.ts";
6
+ import { paintHoverable } from "./shell-hover.ts";
5
7
 
6
8
  const MAX_INPUT_CODEPOINTS = 512;
7
9
  const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
@@ -30,9 +32,12 @@ function dropLastGrapheme(text: string): string {
30
32
  }
31
33
 
32
34
  /** Category-aware footer; the audio card advertises audio keys, never the visual profiles pane. */
33
- function footerHint(category: string, navOnly: boolean, previewLines: number, keyhint?: string): string {
35
+ function footerHint(category: string, navOnly: boolean, previewLines: number, keyhint?: string, setting = false, applyOnMove = true): string {
34
36
  if (navOnly) return "↑/↓ categories · → open · Esc close";
37
+ if (setting && category === "Notifications") return keyhint ?? "←/→ choose · Enter apply · Tab panes · Esc close";
38
+ if (setting) return applyOnMove ? "↑/↓ settings · ←/→ change · Tab categories · p profiles · Esc close" : "←/→ choose · Enter apply · ↑/↓ settings · Tab panes · Esc close";
35
39
  if (category === "Notifications") return keyhint ?? "Tab panes · Enter change · p test · Esc close";
40
+ if (category === "Keymaps") return keyhint ?? "Enter assign · Tab panes · Esc close";
36
41
  return previewLines ? "←/→ or Tab panes · ↑/↓ move · Enter apply · p profiles · Esc close" : "Preview omitted · ←/→ panes · ↑/↓ move · Enter apply · Esc close";
37
42
  }
38
43
 
@@ -42,13 +47,74 @@ function rowVisible(row: CustomizeRow): boolean {
42
47
  try { return row.visible() !== false; } catch { return false; }
43
48
  }
44
49
 
45
- export type CustomizeCategory = "Animations" | "Banner" | "Themes" | "Editor" | "History" | "Notifications" | "Layout" | "Cards" | "Sections" | "Profiles" | "Reset";
50
+ type LineEntry = { first: number; count: number; setting?: string };
51
+
52
+ interface PointerHit {
53
+ id: string;
54
+ x: number;
55
+ end: number;
56
+ y: number;
57
+ text?: string;
58
+ activate(): void;
59
+ }
60
+ interface HoveredHit {
61
+ id: string;
62
+ x: number;
63
+ end: number;
64
+ y: number;
65
+ text: string;
66
+ }
67
+ interface PointerFrame {
68
+ width: number;
69
+ height: number;
70
+ available: number;
71
+ profile: boolean;
72
+ category: string;
73
+ rows: CustomizeRow[];
74
+ hits: PointerHit[];
75
+ }
76
+ interface ChoiceSpan {
77
+ start: number;
78
+ end: number;
79
+ index: number;
80
+ step?: number;
81
+ }
82
+ interface SettingLine {
83
+ text: string;
84
+ nameEnd: number;
85
+ spans: ChoiceSpan[];
86
+ }
87
+
88
+ /** Only complete, painted consent labels are pointer targets. */
89
+ function confirmationHits(hits: PointerHit[], lines: readonly string[], firstRow: number, answer: (yes: boolean) => void): void {
90
+ const instruction = "y yes · any other key cancel";
91
+ const start = lines.join("").lastIndexOf(instruction);
92
+ if (start < 0) return;
93
+ let offset = 0;
94
+ lines.forEach((line, index) => {
95
+ for (const [label, position, yes] of [["y yes", start, true], ["cancel", start + instruction.length - "cancel".length, false]] as const) {
96
+ const at = position - offset;
97
+ if (at < 0 || at + label.length > line.length) continue;
98
+ const x = 2 + visibleWidth(line.slice(0, at));
99
+ hits.push({ id: yes ? "confirm:yes" : "confirm:cancel", x, end: x + visibleWidth(label), y: firstRow + index, activate: () => answer(yes) });
100
+ }
101
+ offset += line.length;
102
+ });
103
+ }
104
+
105
+ export type CustomizeCategory = "Animations" | "Banner" | "Themes" | "Editor" | "History" | "Notifications" | "Layout" | "Cards" | "Sections" | "Keymaps" | "Profiles" | "Reset";
46
106
 
47
107
  export interface CustomizeRow {
48
108
  category?: CustomizeCategory;
49
109
  label: string | (() => string);
50
- /** Read-only representation of the highlighted choice, never an application. */
110
+ /** Read-only representation of the highlighted choice, never an application; `sample` may span lines. */
51
111
  preview?: () => { title: string; sample: string };
112
+ /**
113
+ * One value of a setting. Consecutive rows of the same `setting` render as one
114
+ * line with their values inline. Layout choices apply on ←/→; set applyOnMove
115
+ * to false for preview-first, permission or privacy settings that need Enter.
116
+ */
117
+ choice?: { setting: string; value: string; current(): boolean; hint?: string; applyOnMove?: boolean };
52
118
  /** When present and it returns false the row is hidden from its category; an exception fails closed. */
53
119
  visible?: () => boolean;
54
120
  /** Audio-footer hint for this row; omitted rows use the category default (never advertising `f WAV`). */
@@ -64,6 +130,8 @@ export interface CustomizeRow {
64
130
  export interface CustomizeInline {
65
131
  /** Opens an inline field on the highlighted row; resolves on submit or undefined when cancelled. */
66
132
  input(request: { prompt: string; value: string }): Promise<string | undefined>;
133
+ /** Waits for the next raw key press on the highlighted row; resolves undefined on Esc or when the prompt is not fully visible. */
134
+ capture(prompt: string): Promise<string | undefined>;
67
135
  /** Opens an inline confirmation; resolves true only after an explicit, fully visible yes. */
68
136
  confirm(message: string): Promise<boolean>;
69
137
  /** Set once the owning card is disposed; a row must never persist after this. */
@@ -97,6 +165,8 @@ export class VisualCustomizeView {
97
165
  private closed = false;
98
166
  private busy = false;
99
167
  private readonly options: CustomizeViewOptions;
168
+ private pointerFrame?: PointerFrame;
169
+ private hovered?: HoveredHit;
100
170
  private error?: string;
101
171
  private profileOpen = false;
102
172
  private profileIndex = 0;
@@ -108,20 +178,39 @@ export class VisualCustomizeView {
108
178
  private profileBusy = false;
109
179
  private inlineInput?: { prompt: string; value: string; resolve: (value: string | undefined) => void; visible: boolean };
110
180
  private inlineConfirm?: { message: string; resolve: (value: boolean) => void; visible: boolean };
181
+ private inlineCapture?: { prompt: string; resolve: (value: string | undefined) => void; visible: boolean };
111
182
  private readonly inline: CustomizeInline = {
112
183
  input: request => this.openInlineInput(request),
184
+ capture: prompt => this.openInlineCapture(prompt),
113
185
  confirm: message => this.openInlineConfirm(message),
114
186
  disposed: false,
115
187
  };
116
188
  /** Header and diagnostic context for the active pane; Notifications is explicitly audio. */
117
189
  title(): string { return (this.categories[this.categoryIndex] ?? "Settings") === "Notifications" ? "Audio notifications" : "Customization"; }
118
190
  /** Ends the interaction and resolves any pending inline field/consent as cancelled. */
119
- dispose(): void { this.closed = true; this.inline.disposed = true; this.cancelInline(); }
191
+ dispose(): void { this.closed = true; this.clearPointer(); this.inline.disposed = true; this.cancelInline(); }
120
192
  private cancelInline(): void {
121
193
  const input = this.inlineInput;
122
194
  if (input) { this.inlineInput = undefined; input.resolve(undefined); }
123
195
  const confirm = this.inlineConfirm;
124
196
  if (confirm) { this.inlineConfirm = undefined; confirm.resolve(false); }
197
+ const capture = this.inlineCapture;
198
+ if (capture) { this.inlineCapture = undefined; capture.resolve(undefined); }
199
+ }
200
+ private openInlineCapture(prompt: string): Promise<string | undefined> {
201
+ if (this.closed) return Promise.resolve(undefined);
202
+ return new Promise(resolve => { this.inlineCapture = { prompt, resolve, visible: false }; });
203
+ }
204
+ /** The next key answers the capture; Esc, or a prompt the card could not show, cancels it. */
205
+ private handleInlineCapture(data: string): void {
206
+ const capture = this.inlineCapture!;
207
+ // Same guard as the inline confirmation: a resize that hides the prompt cancels it.
208
+ const area = this.previewCapacity();
209
+ capture.visible = area !== undefined && !area.navOnly && area.lines > 0
210
+ && this.wrapInline(`${capture.prompt} · Esc cancel`, area.inner, area.lines) !== undefined;
211
+ this.inlineCapture = undefined;
212
+ capture.resolve(matchesKey(data, Key.escape) || !capture.visible ? undefined : data);
213
+ this.options.requestRender();
125
214
  }
126
215
  private openInlineInput(request: { prompt: string; value: string }): Promise<string | undefined> {
127
216
  if (this.closed) return Promise.resolve(undefined);
@@ -138,7 +227,7 @@ export class VisualCustomizeView {
138
227
  try {
139
228
  void Promise.resolve(run()).catch((error: unknown) => {
140
229
  this.options.onError?.(error instanceof Error ? error : new Error(String(error)));
141
- }).finally(() => { this.busy = false; if (!this.closed) this.options.requestRender(); });
230
+ }).finally(() => { this.busy = false; this.clearPointer(); if (!this.closed) this.options.requestRender(); });
142
231
  } catch (error) {
143
232
  this.busy = false;
144
233
  this.options.onError?.(error instanceof Error ? error : new Error(String(error)));
@@ -183,7 +272,8 @@ export class VisualCustomizeView {
183
272
  if (!matchesKey(data, Key.enter)) field.value = appendInput(field.value, data.slice(0, -1));
184
273
  // Guard against a resize that hides the field before this Enter: an unseen value never submits.
185
274
  const area = this.previewCapacity();
186
- field.visible = area !== undefined && !area.navOnly && area.lines > 0 && visibleWidth(`${field.prompt}: ${field.value}▏`) <= area.inner;
275
+ field.visible = area !== undefined && !area.navOnly
276
+ && this.wrapInline(`${field.prompt}: ${field.value}▏`, area.inner, area.lines) !== undefined;
187
277
  if (field.visible) { this.inlineInput = undefined; field.resolve(field.value); }
188
278
  } else if (matchesKey(data, Key.backspace) || data === "\x7f") field.value = dropLastGrapheme(field.value);
189
279
  else { const text = decodeKittyPrintable(data) ?? data; if (safeText(text)) field.value = appendInput(field.value, text); }
@@ -198,7 +288,7 @@ export class VisualCustomizeView {
198
288
  confirm.resolve(matchesKey(data, "y") && confirm.visible);
199
289
  this.options.requestRender();
200
290
  }
201
- openProfiles(): void { this.profileOpen = true; this.error = undefined; this.options.requestRender(); }
291
+ openProfiles(): void { this.clearPointer(); this.profileOpen = true; this.error = undefined; this.options.requestRender(); }
202
292
  private profileAction(action: () => void | Promise<void>): void {
203
293
  if (this.profileBusy) return;
204
294
  this.profileBusy = true;
@@ -206,7 +296,7 @@ export class VisualCustomizeView {
206
296
  void Promise.resolve(action()).catch((error: unknown) => {
207
297
  this.error = error instanceof Error ? error.message : String(error);
208
298
  this.options.onError?.(error instanceof Error ? error : new Error(String(error)));
209
- }).finally(() => { this.profileBusy = false; this.options.requestRender(); });
299
+ }).finally(() => { this.profileBusy = false; this.clearPointer(); this.options.requestRender(); });
210
300
  } catch (error) {
211
301
  this.profileBusy = false;
212
302
  this.error = error instanceof Error ? error.message : String(error);
@@ -302,10 +392,135 @@ export class VisualCustomizeView {
302
392
  return this.options.rows.filter(row => (row.category ?? "Settings") === this.categories[this.categoryIndex] && rowVisible(row));
303
393
  }
304
394
 
395
+ /** The category's lines: a plain row, or every consecutive choice of one setting. */
396
+ private lineEntries(rows: readonly CustomizeRow[]): LineEntry[] {
397
+ const entries: LineEntry[] = [];
398
+ rows.forEach((row, index) => {
399
+ const last = entries.at(-1);
400
+ if (row.choice && last?.setting === row.choice.setting && last.first + last.count === index) last.count++;
401
+ else entries.push({ first: index, count: 1, setting: row.choice?.setting });
402
+ });
403
+ return entries;
404
+ }
405
+ private lineOf(entries: readonly LineEntry[], index: number): number {
406
+ return Math.max(0, entries.findIndex(entry => index >= entry.first && index < entry.first + entry.count));
407
+ }
408
+ /** A setting line is entered on its current value. */
409
+ private landOn(rows: readonly CustomizeRow[], entry: LineEntry | undefined): number {
410
+ if (!entry) return 0;
411
+ if (!entry.setting) return entry.first;
412
+ for (let i = entry.first; i < entry.first + entry.count; i++) {
413
+ try { if (rows[i]!.choice!.current()) return i; } catch { /* An unreadable value lands on the first choice. */ }
414
+ }
415
+ return entry.first;
416
+ }
417
+ private enterControls(): void {
418
+ this.pane = "controls";
419
+ const category = this.categories[this.categoryIndex]!;
420
+ const rows = this.categoryRows();
421
+ const entries = this.lineEntries(rows);
422
+ this.controls.set(category, this.landOn(rows, entries[this.lineOf(entries, Math.min(this.controls.get(category) ?? 0, Math.max(0, rows.length - 1)))]));
423
+ }
424
+ /** The last render showed the controls (not the "Enlarge terminal" fallback), so a key may apply one. */
425
+ private controlsShown(): boolean {
426
+ return this.mainWidth !== undefined && this.mainWidth >= CARD_PADDING + 3 && (this.options.rowsAvailable?.() ?? 24) >= 4;
427
+ }
428
+ /** Moves the selection to the first row whose label contains `label`, without applying it. */
429
+ focus(label: string): boolean {
430
+ const previous = this.categoryIndex;
431
+ for (let index = 0; index < this.categories.length; index++) {
432
+ this.categoryIndex = index;
433
+ const found = this.categoryRows().findIndex(row => (typeof row.label === "function" ? row.label() : row.label).includes(label));
434
+ if (found >= 0) {
435
+ this.clearPointer();
436
+ this.pane = "controls";
437
+ this.controls.set(this.categories[index]!, found);
438
+ this.options.requestRender();
439
+ return true;
440
+ }
441
+ }
442
+ this.categoryIndex = previous;
443
+ return false;
444
+ }
445
+
446
+ private clearPointer(): void {
447
+ this.pointerFrame = undefined;
448
+ this.hovered = undefined;
449
+ }
450
+
451
+ /** Install only painted hits and retain hover solely across an identical target and geometry. */
452
+ private installPointerFrame(lines: string[], next: PointerFrame): string[] {
453
+ const previous = this.pointerFrame;
454
+ for (const hit of next.hits) hit.text = stripAnsi(sliceByColumn(lines[hit.y]!, hit.x, hit.end - hit.x, true));
455
+ const hover = this.hovered;
456
+ const sameFrame = previous && previous.width === next.width && previous.height === next.height
457
+ && previous.available === next.available && previous.profile === next.profile && previous.category === next.category
458
+ && previous.rows.length === next.rows.length && previous.rows.every((row, index) => row === next.rows[index]);
459
+ const hit = hover && sameFrame && next.hits.find(item => item.id === hover.id && item.x === hover.x
460
+ && item.end === hover.end && item.y === hover.y && item.text === hover.text);
461
+ if (!hit) this.hovered = undefined;
462
+ const paintHit = (target: PointerHit, hovered: boolean, idleRole?: string) => {
463
+ const line = lines[target.y]!;
464
+ // Keep existing background and neighboring colors; recolor only the hit's painted cells.
465
+ // Column slices omit codes after the last cell, including the border's reset.
466
+ const trailingSgr = line.match(/(?:\x1b\[[0-9;:]*m)+$/)?.[0] ?? "";
467
+ lines[target.y] = sliceByColumn(line, 0, target.x, true)
468
+ + paintHoverable(this.options.theme, target.text!, hovered, idleRole)
469
+ + sliceByColumn(line, target.end, next.width - target.end, true) + trailingSgr;
470
+ };
471
+ // The surrounding confirmation is already warning-colored. Give its actionable
472
+ // cells an idle text role so the warning hover is a visible change.
473
+ for (const target of next.hits) if (target.id.startsWith("confirm:")) paintHit(target, target === hit, "text");
474
+ if (hit && !hit.id.startsWith("confirm:")) paintHit(hit, true);
475
+ this.pointerFrame = next;
476
+ return lines;
477
+ }
478
+
479
+ /** Mouse coordinates are local to the rendered card, including its border. */
480
+ handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
481
+ if (this.closed) return undefined;
482
+ const moving = event.type === "move" && event.button === "none";
483
+ if (!moving && (event.button !== "left" || (event.type !== "press" && event.type !== "click"))) return undefined;
484
+ const frame = this.pointerFrame;
485
+ const available = this.options.rowsAvailable?.() ?? 24;
486
+ const height = Number.isFinite(available) ? Math.max(0, Math.min(24, Math.floor(available))) : 0;
487
+ let valid = Boolean(frame && event.width === frame.width && event.height === frame.height && height === frame.available
488
+ && this.profileOpen === frame.profile && (this.categories[this.categoryIndex] ?? "Settings") === frame.category);
489
+ if (valid && frame && !frame.profile) {
490
+ const rows = this.categoryRows();
491
+ valid = rows.length === frame.rows.length && rows.every((row, index) => row === frame.rows[index]);
492
+ }
493
+ if (!valid || !frame) {
494
+ if (!moving) return undefined;
495
+ const changed = this.hovered !== undefined;
496
+ this.clearPointer();
497
+ return changed ? { handled: true, render: true } : undefined;
498
+ }
499
+ const hit = frame.hits.find(item => item.y === event.y && event.x >= item.x && event.x < item.end);
500
+ if (moving) {
501
+ const target = (this.busy && !this.inlineConfirm || this.profileBusy) ? undefined : hit;
502
+ const previous = this.hovered;
503
+ const changed = target ? !previous || previous.id !== target.id || previous.x !== target.x || previous.end !== target.end
504
+ || previous.y !== target.y || previous.text !== target.text : previous !== undefined;
505
+ this.hovered = target && target.text !== undefined ? { id: target.id, x: target.x, end: target.end, y: target.y, text: target.text } : undefined;
506
+ return { handled: true, render: changed };
507
+ }
508
+ if (!hit) return undefined;
509
+ if (event.type === "press") return { handled: true, capture: true, render: false };
510
+ this.clearPointer();
511
+ hit.activate();
512
+ if (!this.closed) this.options.requestRender();
513
+ return { handled: true, render: true };
514
+ }
515
+
305
516
  handleInput(data: string): void {
306
517
  if (this.closed || isKeyRelease(data)) return;
518
+ const hovered = this.hovered !== undefined;
519
+ this.clearPointer();
520
+ if (hovered) this.options.requestRender();
307
521
  if (this.inlineInput) { this.handleInlineInput(data); return; }
308
522
  if (this.inlineConfirm) { this.handleInlineConfirm(data); return; }
523
+ if (this.inlineCapture) { this.handleInlineCapture(data); return; }
309
524
  if (this.profileOpen && this.options.profiles) { this.handleProfiles(data); return; }
310
525
  if (matchesKey(data, Key.escape)) { this.dispose(); this.options.onClose(); return; }
311
526
  const rows = this.categoryRows();
@@ -334,36 +549,94 @@ export class VisualCustomizeView {
334
549
  if (matchesKey(data, "p") && this.pane === "controls" && (this.categories[this.categoryIndex] ?? "Settings") === "Notifications") { this.options.requestRender(); return; }
335
550
  if (this.options.profiles && matchesKey(data, "p")) { this.openProfiles(); return; }
336
551
  if (!length) return;
337
- if (matchesKey(data, Key.left) || matchesKey(data, Key.tab) && this.pane === "controls") this.pane = "categories";
338
- else if (matchesKey(data, Key.right) || matchesKey(data, Key.tab) && this.pane === "categories") this.pane = "controls";
552
+ const entries = this.lineEntries(rows);
553
+ const line = this.lineOf(entries, this.selected);
554
+ const entry = entries[line];
555
+ const category = this.categories[this.categoryIndex]!;
556
+ // Walk inline values; live choices apply immediately, deferred choices wait for Enter.
557
+ // Moving left past the first value returns to the categories.
558
+ const step = this.pane === "controls" && entry?.setting ? matchesKey(data, Key.left) ? -1 : matchesKey(data, Key.right) ? 1 : 0 : 0;
559
+ if (step === -1 && this.selected === entry!.first) this.pane = "categories";
560
+ else if (step) {
561
+ const next = this.selected + step;
562
+ // Same guard as Enter: never apply a value the card is too small to show.
563
+ if (next >= entry!.first && next < entry!.first + entry!.count && !this.busy && this.controlsShown()) {
564
+ this.controls.set(category, next);
565
+ if (rows[next]!.choice?.applyOnMove !== false) this.withBusy(() => rows[next]!.action(this.inline));
566
+ }
567
+ } else if (matchesKey(data, Key.left) || matchesKey(data, Key.tab) && this.pane === "controls") this.pane = "categories";
568
+ else if (matchesKey(data, Key.right) || matchesKey(data, Key.tab) && this.pane === "categories") this.enterControls();
339
569
  else if (matchesKey(data, Key.up) || matchesKey(data, "k")) {
340
570
  if (this.pane === "categories") this.categoryIndex = (this.categoryIndex + length - 1) % length;
341
- else this.controls.set(this.categories[this.categoryIndex]!, (this.selected + length - 1) % length);
571
+ else this.controls.set(category, this.landOn(rows, entries[(line + entries.length - 1) % entries.length]));
342
572
  } else if (matchesKey(data, Key.down) || matchesKey(data, "j")) {
343
573
  if (this.pane === "categories") this.categoryIndex = (this.categoryIndex + 1) % length;
344
- else this.controls.set(this.categories[this.categoryIndex]!, (this.selected + 1) % length);
345
- } else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && this.pane === "categories") this.pane = "controls";
346
- else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && !this.busy &&
347
- this.mainWidth !== undefined && this.mainWidth >= CARD_PADDING + 3 &&
348
- (this.options.rowsAvailable?.() ?? 24) >= 4 && rows[this.selected]) {
574
+ else this.controls.set(category, this.landOn(rows, entries[(line + 1) % entries.length]));
575
+ } else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && this.pane === "categories") this.enterControls();
576
+ else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && !this.busy && this.controlsShown() && rows[this.selected]) {
349
577
  this.withBusy(() => rows[this.selected]!.action(this.inline));
350
578
  }
351
579
  this.options.requestRender();
352
580
  }
353
581
 
582
+ /** One setting with its values inline (● current, ○ other); too wide, only the selected value with arrows. */
583
+ private renderSettingLine(rows: readonly CustomizeRow[], entry: LineEntry, width: number, nameWidth: number, focused: boolean, theme: CustomizeViewOptions["theme"]): SettingLine {
584
+ const choices = rows.slice(entry.first, entry.first + entry.count).map(row => row.choice!);
585
+ const isCurrent = (choice: NonNullable<CustomizeRow["choice"]>) => { try { return choice.current(); } catch { return false; } };
586
+ const name = sanitizeTerminalText(entry.setting!);
587
+ const lead = `${name}${" ".repeat(Math.max(0, nameWidth - visibleWidth(name)))} `;
588
+ const shown = focused ? rows[this.selected]?.choice ?? choices[0]! : choices.find(isCurrent) ?? choices[0]!;
589
+ // ● marks the current value; on the focused line › marks the cursor when it is elsewhere.
590
+ const mark = (choice: NonNullable<CustomizeRow["choice"]>) => {
591
+ const cursor = focused && choice === shown && !isCurrent(choice);
592
+ const text = `${isCurrent(choice) ? "●" : cursor ? "›" : "○"} ${sanitizeTerminalText(choice.value)}`;
593
+ return theme.fg(isCurrent(choice) || cursor ? "accent" : "muted", text);
594
+ };
595
+ let body = choices.map(mark).join(" ");
596
+ const bodyStart = 2 + visibleWidth(lead);
597
+ const spans: ChoiceSpan[] = [];
598
+ if (bodyStart + visibleWidth(body) > width) {
599
+ const value = sanitizeTerminalText(shown.value);
600
+ const index = choices.indexOf(shown);
601
+ const compact = `‹ ${value} ›`;
602
+ body = `${theme.fg("accent", compact)} ${theme.fg("muted", `${index + 1}/${choices.length}`)}`;
603
+ // Truncation replaces the last column with an ellipsis: never expose a
604
+ // partial value or arrows that would step from an unseen identity.
605
+ const limit = bodyStart + visibleWidth(body) > width ? width - 1 : width;
606
+ if (bodyStart + visibleWidth(compact) <= limit) {
607
+ if (index > 0) spans.push({ start: bodyStart, end: bodyStart + 1, index, step: -1 });
608
+ spans.push({ start: bodyStart + 2, end: bodyStart + 2 + visibleWidth(value), index });
609
+ if (index + 1 < choices.length) spans.push({ start: bodyStart + 3 + visibleWidth(value), end: bodyStart + 4 + visibleWidth(value), index, step: 1 });
610
+ }
611
+ } else {
612
+ let start = bodyStart;
613
+ choices.forEach((choice, index) => {
614
+ const length = visibleWidth(`○ ${sanitizeTerminalText(choice.value)}`);
615
+ spans.push({ start, end: start + length, index });
616
+ start += length + 2;
617
+ });
618
+ }
619
+ const text = truncateToWidth(`${focused ? theme.fg("accent", "▸ ") : " "}${theme.fg(focused ? "text" : "muted", lead)}${body}`, width, "…");
620
+ const padded = text + " ".repeat(Math.max(0, width - visibleWidth(text)));
621
+ return { text: focused && theme.bg ? theme.bg("selectedBg", padded) : padded, nameEnd: Math.min(width, 2 + visibleWidth(name)), spans };
622
+ }
623
+
354
624
  render(width: number): string[] {
355
625
  if (this.profileOpen && this.options.profiles) {
356
- if (width <= 0) { this.confirmationVisible = false; return []; }
626
+ if (width <= 0) { this.confirmationVisible = false; this.clearPointer(); return []; }
357
627
  return this.renderProfiles(width);
358
628
  }
359
629
  this.mainWidth = width;
360
- if (width <= 0) { this.confirmationVisible = false; return []; }
630
+ if (width <= 0) { this.confirmationVisible = false; this.clearPointer(); return []; }
361
631
  const available = this.options.rowsAvailable?.() ?? 24;
362
632
  const height = Number.isFinite(available) ? Math.max(0, Math.min(24, Math.floor(available))) : 0;
363
- if (!height) return [];
633
+ if (!height) { this.clearPointer(); return []; }
364
634
  // A card needs two border rows. At extreme dimensions keep the old
365
635
  // read-only heading rather than letting invisible controls be activated.
366
- if (width < CARD_PADDING + 1 || height < 4) return Array.from({ length: Math.min(height, 2) }, (_, i) => truncateToWidth(i ? "Enlarge terminal" : this.title(), width, ""));
636
+ if (width < CARD_PADDING + 1 || height < 4) {
637
+ this.clearPointer();
638
+ return Array.from({ length: Math.min(height, 2) }, (_, i) => truncateToWidth(i ? "Enlarge terminal" : this.title(), width, ""));
639
+ }
367
640
  const inner = width - CARD_PADDING;
368
641
  const category = this.categories[this.categoryIndex] ?? "Settings";
369
642
  const rows = this.categoryRows();
@@ -371,15 +644,19 @@ export class VisualCustomizeView {
371
644
  const navOnly = narrow && this.pane === "categories" && this.categories.length > 1;
372
645
  const leftWidth = narrow ? 0 : Math.min(20, Math.max(14, Math.floor(inner * 0.28)));
373
646
  const rightWidth = inner - leftWidth - (leftWidth ? 3 : 0);
374
- const previewLines = height >= 11 ? 3 : height >= 8 ? 1 : 0;
647
+ const previewLines = height >= 18 ? 6 : height >= 11 ? 3 : height >= 8 ? 1 : 0;
375
648
  const showHeading = height >= 6;
376
649
  const showTopGap = height >= 12;
377
650
  const showBottomGap = height >= 9;
378
651
  const chrome = 1 + Number(showHeading) * 2 + Number(showTopGap) + Number(showBottomGap);
379
652
  const contentHeight = Math.max(1, height - 2 - chrome - previewLines);
380
653
  this.selected = Math.min(this.controls.get(category) ?? 0, Math.max(0, rows.length - 1));
381
- const position = navOnly ? this.categoryIndex : this.selected;
382
- const listLength = navOnly ? this.categories.length : rows.length;
654
+ const entries = this.lineEntries(rows);
655
+ const line = this.lineOf(entries, this.selected);
656
+ const focusedSetting = this.pane === "controls" && entries[line]?.setting ? rows[this.selected]?.choice : undefined;
657
+ const position = navOnly ? this.categoryIndex : line;
658
+ const listLength = navOnly ? this.categories.length : entries.length;
659
+ const nameWidth = Math.min(20, Math.max(0, ...entries.map(entry => entry.setting ? visibleWidth(entry.setting) : 0)));
383
660
  const start = Math.min(Math.max(0, position - contentHeight + 1), Math.max(0, listLength - contentHeight));
384
661
  const navStart = Math.min(Math.max(0, this.categoryIndex - contentHeight + 1), Math.max(0, this.categories.length - contentHeight));
385
662
  const paint = (text: string, size: number, role = "text") => {
@@ -387,44 +664,96 @@ export class VisualCustomizeView {
387
664
  return this.options.theme.fg(role, clipped + " ".repeat(Math.max(0, size - visibleWidth(clipped))));
388
665
  };
389
666
  const join = (left: string, right: string) => leftWidth ? `${left}${" ".repeat(Math.max(0, leftWidth - visibleWidth(stripAnsi(left))))} ${paint("│", 1, "border")} ${right}` : right;
390
- const heading = navOnly ? "Categories · choose a category →" : `${category} · ${rows.length ? `${this.selected + 1}/${rows.length}` : "empty"}`;
667
+ const heading = navOnly ? "Categories · choose a category →" : `${category} · ${rows.length ? `${line + 1}/${entries.length}` : "empty"}`;
391
668
  const lines: string[] = [paint(this.title(), inner, "accent")];
669
+ const hits: PointerHit[] = [];
670
+ const modal = Boolean(this.inlineInput || this.inlineConfirm || this.inlineCapture);
671
+ const categoryHit = (name: string, index: number, x: number, y: number, size: number) => {
672
+ const end = x + Math.min(visibleWidth(name), Math.max(0, size));
673
+ if (!modal && end > x) hits.push({ id: `category:${index}`, x, end, y, activate: () => {
674
+ if (this.busy) return;
675
+ this.categoryIndex = index;
676
+ this.pane = "categories";
677
+ if (narrow) this.enterControls();
678
+ } });
679
+ };
680
+ const select = (index: number, apply: boolean) => {
681
+ if (this.busy) return;
682
+ this.pane = "controls";
683
+ this.controls.set(category, index);
684
+ if (apply) this.withBusy(() => rows[index]!.action(this.inline));
685
+ };
392
686
  // Commands uses a header, grouped section labels, whitespace and a footer.
393
687
  if (showHeading) lines.push(join(leftWidth ? paint("CATEGORIES", leftWidth, "accent") : "", paint(heading, rightWidth, "accent")));
394
688
  if (showTopGap) lines.push("");
395
689
  for (let i = 0; i < contentHeight; i++) {
396
690
  const nav = this.categories[navStart + i];
397
691
  const left = nav ? renderPaletteSelection(nav, leftWidth, navStart + i === this.categoryIndex, this.pane === "categories" ? this.options.theme : { fg: this.options.theme.fg.bind(this.options.theme) }) : "";
398
- const row = rows[start + i];
692
+ const entry = navOnly ? undefined : entries[start + i];
693
+ const row = entry ? rows[entry.first] : undefined;
399
694
  const item = navOnly ? this.categories[start + i] : row ? typeof row.label === "function" ? row.label() : row.label : undefined;
400
- const right = item ? renderPaletteSelection(item, rightWidth, start + i === position, navOnly || this.pane === "controls" ? this.options.theme : { fg: this.options.theme.fg.bind(this.options.theme) }) : rows.length ? "" : paint("No settings available", rightWidth, "muted");
695
+ const rowTheme = navOnly || this.pane === "controls" ? this.options.theme : { fg: this.options.theme.fg.bind(this.options.theme) };
696
+ const setting = entry?.setting ? this.renderSettingLine(rows, entry, rightWidth, nameWidth, start + i === position, rowTheme) : undefined;
697
+ const right = setting?.text ?? (item ? renderPaletteSelection(item, rightWidth, start + i === position, rowTheme) : rows.length ? "" : paint("No settings available", rightWidth, "muted"));
698
+ const y = lines.length + 1; // card adds its top border
699
+ const rightX = 2 + (leftWidth ? leftWidth + 3 : 0);
700
+ if (leftWidth && nav) categoryHit(nav, navStart + i, 4, y, leftWidth - 2);
701
+ if (navOnly && item) categoryHit(item, start + i, rightX + 2, y, rightWidth - 2);
702
+ else if (!modal && entry && row) {
703
+ if (setting) {
704
+ if (setting.nameEnd > 2) hits.push({ id: `setting:${entry.first}`, x: rightX + 2, end: rightX + setting.nameEnd, y, activate: () => select(this.landOn(rows, entry), false) });
705
+ for (const span of setting.spans) hits.push({ id: `choice:${entry.first}:${span.index}:${span.step ?? 0}`, x: rightX + span.start, end: rightX + span.end, y, activate: () => {
706
+ if (this.busy) return;
707
+ select(entry.first + span.index, span.step === undefined);
708
+ if (span.step) this.handleInput(span.step < 0 ? "\x1b[D" : "\x1b[C");
709
+ } });
710
+ } else {
711
+ const end = rightX + visibleWidth(stripAnsi(right).trimEnd());
712
+ if (end > rightX + 2) hits.push({ id: `row:${entry.first}`, x: rightX + 2, end, y, activate: () => select(entry.first, true) });
713
+ }
714
+ }
401
715
  lines.push(join(left, right));
402
716
  }
403
717
  if (this.inlineConfirm) {
404
718
  const shows = !navOnly && previewLines > 0 ? this.wrapInline(`${this.inlineConfirm.message} y yes · any other key cancel`, inner, previewLines) : undefined;
405
719
  this.inlineConfirm.visible = shows !== undefined;
406
- if (shows) for (const line of shows) lines.push(paint(line, inner, "warning"));
720
+ if (shows) {
721
+ confirmationHits(hits, shows, lines.length + 1, yes => this.handleInput(yes ? "y" : "n"));
722
+ for (const line of shows) lines.push(paint(line, inner, "warning"));
723
+ }
407
724
  else if (previewLines > 0) lines.push(paint("Confirmation needs more space · enlarge terminal", inner, "warning"));
725
+ } else if (this.inlineCapture) {
726
+ const shows = !navOnly && previewLines > 0 ? this.wrapInline(`${this.inlineCapture.prompt} · Esc cancel`, inner, previewLines) : undefined;
727
+ this.inlineCapture.visible = shows !== undefined;
728
+ if (shows) for (const line of shows) lines.push(paint(line, inner, "accent"));
729
+ else if (previewLines > 0) lines.push(paint("Key capture needs more space · enlarge terminal", inner, "warning"));
408
730
  } else if (this.inlineInput) {
409
731
  const field = `${this.inlineInput.prompt}: ${this.inlineInput.value}▏`;
410
- this.inlineInput.visible = !navOnly && previewLines > 0 && visibleWidth(field) <= inner;
411
- if (previewLines > 0) {
412
- lines.push(paint(field, inner, "accent"));
413
- if (previewLines === 3) lines.push(paint(this.inlineInput.visible ? "Enter confirm · Esc cancel" : "Value too wide · enlarge terminal · Esc cancel", inner, "muted"));
732
+ const shows = !navOnly ? this.wrapInline(field, inner, previewLines) : undefined;
733
+ this.inlineInput.visible = shows !== undefined;
734
+ if (shows) {
735
+ for (const line of shows) lines.push(paint(line, inner, "accent"));
736
+ if (shows.length < previewLines) lines.push(paint("Enter confirm · Esc cancel", inner, "muted"));
737
+ } else if (previewLines > 0) {
738
+ lines.push(paint(`Needs ${visibleWidth(field) + CARD_PADDING} columns for one line · Esc cancel`, inner, "warning"));
414
739
  }
415
- } else if (previewLines === 3) {
740
+ } else if (previewLines >= 3) {
416
741
  let preview: ReturnType<NonNullable<CustomizeRow["preview"]>> | undefined;
417
742
  try { if (!navOnly) preview = rows[this.selected]?.preview?.(); } catch { /* Never substitute the active theme for an unreadable source. */ }
418
743
  lines.push("");
419
- lines.push(paint(navOnly ? "→ controls · Esc close" : preview ? `Preview · ${preview.title}` : "Preview unavailable", inner, "accent"));
420
- lines.push(paint(navOnly ? "" : preview?.sample ?? "No read-only sample for this choice", inner, "muted"));
744
+ // The focused setting says what it does; the preview below shows the highlighted value.
745
+ const headline = focusedSetting?.hint ? `${focusedSetting.setting} — ${focusedSetting.hint}` : preview ? `Preview · ${preview.title}` : "Preview unavailable";
746
+ lines.push(paint(navOnly ? "→ controls · Esc close" : headline, inner, "accent"));
747
+ const sample = navOnly ? [""] : (preview?.sample ?? "No read-only sample for this choice").split("\n");
748
+ for (let i = 0; i < previewLines - 2; i++) lines.push(paint(sample[i] ?? "", inner, "muted"));
421
749
  } else if (previewLines === 1) lines.push(paint(navOnly ? "→ controls · Esc close" : "Preview omitted · enlarge terminal", inner, "muted"));
422
750
  if (showBottomGap) lines.push("");
423
- if (showHeading) lines.push(paint(footerHint(category, navOnly, previewLines, rows[this.selected]?.keyhint), inner, "muted"));
751
+ if (showHeading) lines.push(paint(`Click · ${footerHint(category, navOnly, previewLines, rows[this.selected]?.keyhint, focusedSetting !== undefined, focusedSetting?.applyOnMove !== false)}`, inner, "muted"));
424
752
  // The top-right close hint mirrors Commands without consuming another row.
425
753
  const title = this.title();
426
754
  lines[0] = paint(title + " ".repeat(Math.max(1, inner - visibleWidth(title) - 3)) + "esc", inner, "accent");
427
- return renderPaletteCard(lines.slice(0, height - 2), width, this.options.theme);
755
+ const frame = renderPaletteCard(lines.slice(0, height - 2), width, this.options.theme);
756
+ return this.installPointerFrame(frame, { width, height: frame.length, available: height, profile: false, category, rows, hits: hits.filter(hit => hit.y < frame.length - 1) });
428
757
  }
429
758
  private detailSize(width: number): { height: number; inner: number; capacity: number } {
430
759
  const available = this.options.rowsAvailable?.() ?? 24;
@@ -442,10 +771,11 @@ export class VisualCustomizeView {
442
771
  this.profileWidth = width;
443
772
  this.profileInputVisible = false;
444
773
  const { height, inner, capacity } = this.detailSize(width);
445
- if (height < 3 || inner < 1) { this.confirmationVisible = false; return this.detailFrame(["Visual profiles", "Enlarge terminal"], width, height); }
774
+ if (height < 3 || inner < 1) { this.confirmationVisible = false; this.clearPointer(); return this.detailFrame(["Visual profiles", "Enlarge terminal"], width, height); }
446
775
  let items: VisualProfile[];
447
776
  try { items = this.options.profiles!.list(); } catch (error) {
448
777
  this.confirmationVisible = false;
778
+ this.clearPointer();
449
779
  return this.detailFrame([this.options.theme.fg("accent", "Visual profiles"), `Profiles unavailable: ${error instanceof Error ? error.message : String(error)}`, "Esc back"], width, height);
450
780
  }
451
781
  this.profileIndex = Math.min(this.profileIndex, Math.max(0, items.length - 1));
@@ -453,6 +783,8 @@ export class VisualCustomizeView {
453
783
  const choice = this.confirmation;
454
784
  const promptLines = choice ? this.confirmationLines(choice, inner, capacity) : undefined;
455
785
  this.confirmationVisible = promptLines !== undefined;
786
+ const hits: PointerHit[] = [];
787
+ if (promptLines) confirmationHits(hits, promptLines, 1, yes => this.handleInput(yes ? "y" : "n"));
456
788
  const lines: string[] = promptLines ? promptLines.map(line => this.options.theme.fg("warning", line)) : choice ? [this.options.theme.fg("warning", "Confirmation unavailable · Esc back")] : [];
457
789
  // Input outranks the error, header and preview on tiny terminals.
458
790
  const input = this.profileInput !== undefined ? `New profile name: ${this.profileInput}▏` : undefined;
@@ -474,8 +806,9 @@ export class VisualCustomizeView {
474
806
  lines.push(...details.slice(0, free).map(line => this.options.theme.fg("text", line)));
475
807
  for (const line of tail) if (lines.length < capacity) lines.push(this.options.theme.fg(line.startsWith("Error:") ? "error" : "accent", line));
476
808
  if (lines.length < capacity) lines.push(this.options.theme.fg("muted", footer));
477
- return this.detailFrame(lines, width, height);
809
+ const frame = this.detailFrame(lines, width, height);
810
+ return this.installPointerFrame(frame, { width, height: frame.length, available: height, profile: true, category: this.categories[this.categoryIndex] ?? "Settings", rows: [], hits: hits.filter(hit => hit.y < frame.length - 1) });
478
811
  }
479
812
 
480
- invalidate(): void { this.options.requestRender(); }
813
+ invalidate(): void { this.clearPointer(); this.options.requestRender(); }
481
814
  }