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.
- package/README.md +17 -15
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +8 -1
- package/assets/agents/gentle-ai-worker.md +4 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +162 -0
- package/assets/orchestrator-delegation-reference.md +7 -7
- package/assets/orchestrator-delegation.md +3 -3
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +14 -8
- package/assets/orchestrator.md +11 -11
- package/bin/gentle-shell.mjs +225 -82
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +35 -7
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +22 -0
- package/docs/gentle-shell.md +113 -25
- package/docs/install-wizard.md +2 -2
- package/docs/mcp-status.md +52 -0
- package/docs/permission-modes.md +9 -4
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +154 -50
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +46 -0
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +2 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +803 -84
- package/extensions/gentle-ai.ts +2491 -596
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +895 -120
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +59 -23
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/history/store.ts +18 -12
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +210 -21
- package/extensions/startup-banner.ts +69 -10
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +161 -3
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +58 -3
- package/lib/agents-history.ts +24 -5
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +287 -15
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/bridge-cost.ts +28 -0
- package/lib/card-content-policy.ts +8 -6
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +154 -25
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +64 -0
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +47 -8
- package/lib/herdr-activity.ts +23 -5
- package/lib/herdr-busy.ts +45 -0
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +282 -132
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-view.ts +198 -11
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +32 -6
- package/lib/nan-provider.ts +3 -2
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +103 -21
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +225 -18
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +85 -44
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +29 -8
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-repository.ts +5 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +107 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +269 -72
- package/lib/shell-card.ts +26 -6
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +163 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +198 -53
- package/lib/shell-sidebar.ts +61 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +79 -1
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +67 -12
- package/lib/visual-customize-view.ts +373 -40
- package/lib/visual-layout-preview.ts +47 -0
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +68 -16
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +46 -7
- package/runtime/native-review-cli.mjs +100 -18
- package/runtime/review-integration-v2.mjs +29 -8
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +6 -6
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/pi-update.mjs +113 -3
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +41 -13
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +14 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +4 -4
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +345 -4
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +47 -0
- package/tests/bundled-install.test.ts +36 -9
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +80 -5
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +300 -3
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +8 -7
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -14
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +172 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1491 -38
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +151 -0
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +1101 -52
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +80 -3
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +172 -26
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +93 -10
- package/tests/gentle-shell.test.ts +1937 -66
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +67 -4
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +132 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +298 -4
- package/tests/installer-posix-bootstrap.test.ts +68 -6
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-view.test.ts +260 -6
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider.test.ts +4 -4
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +22 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +6 -6
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +133 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +169 -14
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/persona-reply-language.test.ts +20 -1
- package/tests/pi-update-launcher.test.ts +40 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +84 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +265 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +52 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +381 -11
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +183 -6
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +250 -0
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +34 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +255 -0
- package/tests/shell-bar.test.ts +274 -72
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +360 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +13 -1
- package/tests/shell-sidebar-layout.test.ts +447 -44
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +902 -2
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +209 -2
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +50 -4
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +134 -8
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +95 -8
- package/tests/visual-customize-view.test.ts +818 -9
- package/tests/visual-layout-preview.test.ts +42 -0
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +114 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +57 -15
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +39 -20
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { ScrollView, VStack, visibleWidth, type Component, type TUI, type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
2
|
-
import { sidebarState, type SidebarRail } from "./shell-sidebar.ts";
|
|
1
|
+
import { Container, ScrollView, VStack, truncateToWidth, visibleWidth, type Component, type TUI, type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
2
|
+
import { setSidebarHover, sidebarState, type SidebarRail } from "./shell-sidebar.ts";
|
|
3
3
|
import type { ShellBarTheme } from "./shell-bar.ts";
|
|
4
|
-
import { CARD_STYLE, cardStyle, type CardStyle } from "./shell-card.ts";
|
|
4
|
+
import { CARD_STYLE, CARD_TONE, cardBottom, cardLine, cardStyle, cardTop, floatRows, paintSurfaceRow, panelInnerWidth, type CardStyle } from "./shell-card.ts";
|
|
5
|
+
import { chromeSurface, PANEL_ROW_INDENT, panelSurfaceOpener, sectionGap } from "./shell-panel.ts";
|
|
5
6
|
import { renderSidebarBanner } from "./shell-sidebar-banner.ts";
|
|
6
7
|
import type { Density, HeaderPlacement, StatusPlacement } from "./visual-customization-policy.ts";
|
|
7
8
|
|
|
8
9
|
export const SIDEBAR_BREAKPOINT = 140;
|
|
9
10
|
const RAIL_WIDTH = 50;
|
|
10
11
|
const RAIL_PADDING = 1;
|
|
11
|
-
// The
|
|
12
|
-
// padding that puts the card's right border two columns in from the edge.
|
|
13
|
-
// The header row stops at the same column so its right group lines up with
|
|
14
|
-
// the card instead of touching the terminal edge.
|
|
15
|
-
const HEADER_RIGHT_INSET = RAIL_PADDING + 1;
|
|
12
|
+
// The conversation and rail keep a gap below the full-width header.
|
|
16
13
|
const GAP = 3;
|
|
17
14
|
/** Right-edge columns the painting rail takes from the editor column; published as `railColumns`. */
|
|
18
15
|
export const SIDEBAR_RAIL_COLUMNS = RAIL_WIDTH + GAP;
|
|
@@ -24,14 +21,59 @@ type StackLayoutEntry = ConstructorParameters<typeof VStack>[0] extends Array<in
|
|
|
24
21
|
type LayoutRoot = Component & { [NODE]?: () => LayoutNode };
|
|
25
22
|
type Host = TUI & { mode?: string; layoutRoot?: LayoutRoot };
|
|
26
23
|
type SidebarCache = { revision: number };
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
// `x`/`row` map a rail cell to the part's own cells; `frameWidth`/`frameHeight` are
|
|
25
|
+
// the frame the part rendered, which its mouse handler checks events against.
|
|
26
|
+
// A card title row (`wholeRow`) answers across the whole rail row, its x clamped into the frame.
|
|
27
|
+
type RailHit = { key: string; component: Component; startY: number; height: number; width: number; x: number; row: number; frameWidth: number; frameHeight: number; wholeRow?: boolean };
|
|
28
|
+
type SectionCacheEntry = { component: Component; digest: string | undefined; revision: number; contentWidth: number; renderWidth: number; cardStyle: CardStyle; theme: ShellBarTheme; themeSignature: string; lines: string[] };
|
|
29
|
+
// A transparent rail draws every section as its own card in the transcript's
|
|
30
|
+
// card style (neon outline with the title in the top rule, float tint with its
|
|
31
|
+
// accent bar), through the same renderCard the conversation cards use.
|
|
32
|
+
type CardGeometry = { headerRow: number; headerX: number; bodyRow: number; bodyX: number };
|
|
33
|
+
// One section card: the title (with its count as the top rule's hint) and the
|
|
34
|
+
// body rows together, so a float card spends no separator row between them.
|
|
35
|
+
function sectionCardRows(header: { glyph?: string; title: string; count?: string }, body: readonly string[], theme: ShellBarTheme, width: number): string[] {
|
|
36
|
+
const tone = CARD_TONE.INFO;
|
|
37
|
+
return floatRows(tone, theme, width, (inner) => ({
|
|
38
|
+
head: [cardTop({ title: header.title, ...(header.glyph ? { glyph: header.glyph } : {}), body: [], tone }, theme, inner, header.count), ...body.map((row) => cardLine(row, tone, theme, inner))],
|
|
39
|
+
bottom: cardBottom(tone, theme, inner),
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
const CARD_PROBE = "\u2063probe";
|
|
43
|
+
const geometryCache = new Map<string, CardGeometry>();
|
|
44
|
+
function cardGeometry(theme: ShellBarTheme, width: number, style: CardStyle): CardGeometry {
|
|
45
|
+
const key = `${style}:${width}:${themeSignature(theme)}`;
|
|
46
|
+
const cached = geometryCache.get(key);
|
|
47
|
+
if (cached) return cached;
|
|
48
|
+
const rows = sectionCardRows({ glyph: "▾", title: "HEADER" }, [CARD_PROBE], theme, width).map((row) => row.replace(/\x1b\[[0-9;]*m/g, ""));
|
|
49
|
+
const bodyRow = Math.max(0, rows.findIndex((row) => row.includes(CARD_PROBE)));
|
|
50
|
+
const headerRow = Math.max(0, rows.findIndex((row) => row.includes("HEADER")));
|
|
51
|
+
const geometry = { headerRow, headerX: Math.max(0, visibleWidth(rows[headerRow]!.slice(0, rows[headerRow]!.indexOf("▾")))), bodyRow, bodyX: Math.max(0, visibleWidth(rows[bodyRow]!.slice(0, rows[bodyRow]!.indexOf(CARD_PROBE)))) };
|
|
52
|
+
if (geometryCache.size > 64) geometryCache.clear();
|
|
53
|
+
geometryCache.set(key, geometry);
|
|
54
|
+
return geometry;
|
|
55
|
+
}
|
|
56
|
+
// The header row a part renders (`▾ NAME … count`, styled, hover included),
|
|
57
|
+
// split at the gap before its right-aligned count into the card's glyph,
|
|
58
|
+
// title and count, keeping their styling.
|
|
59
|
+
function headerParts(line: string): { glyph?: string; title: string; count?: string } {
|
|
60
|
+
const trimmed = line.replace(/ +((?:\x1b\[[0-9;]*m)*)$/, "$1");
|
|
61
|
+
const split = /^(.*?\S)( {2,})(?=\S|\x1b)(.*)$/s.exec(trimmed);
|
|
62
|
+
const left = split ? split[1]! : trimmed;
|
|
63
|
+
const count = split?.[3]?.trim() ? split[3] : undefined;
|
|
64
|
+
// The glyph keeps its own escape codes on both sides (the hover role paints it),
|
|
65
|
+
// so no opening code leaks onto the title.
|
|
66
|
+
const glyph = /^((?:\x1b\[[0-9;]*m)*[▾▸](?:\x1b\[[0-9;]*m)*)\s/.exec(left);
|
|
67
|
+
return { ...(glyph ? { glyph: glyph[1] } : {}), title: glyph ? left.slice(glyph[0].length) : left, ...(count ? { count } : {}) };
|
|
68
|
+
}
|
|
29
69
|
type SidebarPresentation = { scrollTop: number; output: LayoutNode };
|
|
30
70
|
type PreparedRail = {
|
|
31
71
|
revision: number;
|
|
32
72
|
width: number;
|
|
33
73
|
mode: string | undefined;
|
|
34
74
|
headerPlacement: HeaderPlacement;
|
|
75
|
+
density: Density;
|
|
76
|
+
surface: string;
|
|
35
77
|
cardStyle: CardStyle;
|
|
36
78
|
root: LayoutRoot;
|
|
37
79
|
theme: ShellBarTheme;
|
|
@@ -46,6 +88,9 @@ type PreparedRail = {
|
|
|
46
88
|
// section: it never enters `lines`/`hits`, and an empty/blank result
|
|
47
89
|
// falls back to the old hstack-direct shape with the banner restored.
|
|
48
90
|
headerLines: string[];
|
|
91
|
+
statusLines: string[];
|
|
92
|
+
/** The tinted blank row that fills the rail below a trailing panel section, or "" when the rail ends on a card. */
|
|
93
|
+
fillRow: string;
|
|
49
94
|
headerActive: boolean;
|
|
50
95
|
presentation?: SidebarPresentation;
|
|
51
96
|
};
|
|
@@ -106,11 +151,11 @@ export interface StatusOwnerInput {
|
|
|
106
151
|
*/
|
|
107
152
|
export function narrowStatusOwner(input: StatusOwnerInput): StatusOwner | undefined {
|
|
108
153
|
if (input.mode !== "fullscreen" || input.columns >= SIDEBAR_BREAKPOINT) return undefined;
|
|
109
|
-
return input.headerPlacement
|
|
154
|
+
return input.headerPlacement !== "below-input" || input.statusPlacement === "hidden" ? STATUS_OWNER.HEADER : STATUS_OWNER.BOTTOM;
|
|
110
155
|
}
|
|
111
156
|
|
|
112
157
|
/** Installs the fullscreen rail: wraps the host layout root with the [rail, transcript] hstack and returns a disposer restoring the original layout. */
|
|
113
|
-
export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () => StatusPlacement = () => "auto", headerPlacement: () => HeaderPlacement = () => "
|
|
158
|
+
export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () => StatusPlacement = () => "auto", headerPlacement: () => HeaderPlacement = () => "split", density: () => Density = () => "comfortable"): () => void {
|
|
114
159
|
if (!tui.terminal) return () => {};
|
|
115
160
|
const host = tui as Host;
|
|
116
161
|
const state = sidebarState(tui);
|
|
@@ -120,7 +165,9 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
120
165
|
let stopped = false;
|
|
121
166
|
let failed = false;
|
|
122
167
|
let railLines: string[] = [];
|
|
168
|
+
let fillRow = "";
|
|
123
169
|
let headerLines: string[] = [];
|
|
170
|
+
let statusLines: string[] = [];
|
|
124
171
|
let prepared: PreparedRail | undefined;
|
|
125
172
|
// One rendered-lines cache per rail section key, independent of the
|
|
126
173
|
// whole-rail `prepared` memo below: a section with its own digest is
|
|
@@ -136,13 +183,20 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
136
183
|
// A narrow top header is the only status row there. Whether it paints comes
|
|
137
184
|
// from the last layout pass (a blank or failed header never swallows the
|
|
138
185
|
// bottom bar); the geometry is read live so a resize applies before the next pass.
|
|
139
|
-
const headerOwnsStatus = () => !stopped && !failed && headerLines.length > 0 && headerPlacement()
|
|
186
|
+
const headerOwnsStatus = () => !stopped && !failed && headerLines.length > 0 && headerPlacement() !== "below-input" &&
|
|
140
187
|
narrowStatusOwner({ mode: host.mode, columns: tui.terminal.columns, statusPlacement: placement(), headerPlacement: headerPlacement() }) === STATUS_OWNER.HEADER;
|
|
141
188
|
state.headerOwnsStatus = headerOwnsStatus;
|
|
142
189
|
state.railColumns = SIDEBAR_RAIL_COLUMNS;
|
|
190
|
+
state.layoutAttached = () => !stopped && !failed && host.mode === "fullscreen" && !!host.layoutRoot && roots.has(host.layoutRoot);
|
|
143
191
|
state.ownsHost = () => !stopped && host.mode === "fullscreen" && tui.terminal.columns >= SIDEBAR_BREAKPOINT && (placement() === "auto" || placement() === "right") && !!host.layoutRoot && roots.has(host.layoutRoot);
|
|
192
|
+
// The panel surface runs to the bottom of the rail: below the last panel
|
|
193
|
+
// section, blank tinted rows fill what is left of the viewport. They are
|
|
194
|
+
// not content, so they never add scroll range or hit targets.
|
|
144
195
|
const rail: Component = {
|
|
145
|
-
render: () =>
|
|
196
|
+
render: () => {
|
|
197
|
+
const room = scroll.viewportHeight - railLines.length;
|
|
198
|
+
return fillRow && room > 0 ? [...railLines, ...Array.from({ length: room }, () => fillRow)] : railLines;
|
|
199
|
+
},
|
|
146
200
|
invalidate() {
|
|
147
201
|
invalidateSidebar(tui);
|
|
148
202
|
for (const part of state.parts.values()) part.invalidate();
|
|
@@ -161,7 +215,20 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
161
215
|
const header: Component = {
|
|
162
216
|
render: () => headerLines,
|
|
163
217
|
invalidate() {},
|
|
164
|
-
handleMouse: (event) =>
|
|
218
|
+
handleMouse: (event) => {
|
|
219
|
+
if (event.type === "move" && event.button === "none") setSidebarHover(tui);
|
|
220
|
+
return state.parts.get("header")?.handleMouse?.(event);
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
// The status bar row: a leaf like the header, painted full-width below the
|
|
224
|
+
// hstack while the rail is shown, delegating its mouse to the registered part.
|
|
225
|
+
const statusBar: Component = {
|
|
226
|
+
render: () => statusLines,
|
|
227
|
+
invalidate() {},
|
|
228
|
+
handleMouse: (event) => {
|
|
229
|
+
if (event.type === "move" && event.button === "none") setSidebarHover(tui);
|
|
230
|
+
return state.parts.get("statusbar")?.handleMouse?.(event);
|
|
231
|
+
},
|
|
165
232
|
};
|
|
166
233
|
const scroll = new ScrollView(rail, {
|
|
167
234
|
follow: "none",
|
|
@@ -179,17 +246,19 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
179
246
|
const current = prepared;
|
|
180
247
|
if (!current || stopped || failed || !current.active || current.revision !== cache.revision ||
|
|
181
248
|
host.mode !== "fullscreen" || tui.terminal.columns !== current.width || host.layoutRoot !== current.root ||
|
|
182
|
-
scroll.getContentWidth(event.width) !== current.contentWidth || event.x <
|
|
249
|
+
scroll.getContentWidth(event.width) !== current.contentWidth || event.x < 0 ||
|
|
183
250
|
event.x >= current.contentWidth || event.y < 0 || event.y >= event.height) return undefined;
|
|
184
251
|
const contentY = scroll.scrollTop + event.y;
|
|
185
252
|
const hit = current.hits.find((candidate) => contentY >= candidate.startY && contentY < candidate.startY + candidate.height);
|
|
186
|
-
if (!hit || state.parts.get(hit.key) !== hit.component
|
|
253
|
+
if (!hit || state.parts.get(hit.key) !== hit.component) return undefined;
|
|
254
|
+
if (!hit.wholeRow && (event.x < hit.x || event.x >= hit.x + hit.width)) return undefined;
|
|
255
|
+
// The part sees the event in the frame it rendered: its own width and all its rows.
|
|
187
256
|
return hit.component.handleMouse?.({
|
|
188
257
|
...event,
|
|
189
|
-
x: event.x -
|
|
190
|
-
y: contentY - hit.startY,
|
|
191
|
-
width: hit.
|
|
192
|
-
height: hit.
|
|
258
|
+
x: Math.max(0, Math.min(hit.frameWidth - 1, event.x - hit.x)),
|
|
259
|
+
y: hit.row + contentY - hit.startY,
|
|
260
|
+
width: hit.frameWidth,
|
|
261
|
+
height: hit.frameHeight,
|
|
193
262
|
});
|
|
194
263
|
};
|
|
195
264
|
scroll.handleMouse = (event) => {
|
|
@@ -207,23 +276,31 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
207
276
|
target: { component: scroll, originX: event.screenX - event.x, originY: event.screenY - event.y, width: event.width, height: event.height },
|
|
208
277
|
};
|
|
209
278
|
}
|
|
210
|
-
|
|
279
|
+
const result = dispatchPartMouse(event);
|
|
280
|
+
if (!result && event.type === "move" && event.button === "none") setSidebarHover(tui);
|
|
281
|
+
return result ?? nativeMouse(event);
|
|
211
282
|
};
|
|
212
283
|
const prepare = (width: number, root: LayoutRoot): boolean => {
|
|
213
284
|
state.active = false;
|
|
214
285
|
if (stopped || failed || host.mode !== "fullscreen") {
|
|
215
286
|
prepared = undefined;
|
|
216
287
|
headerLines = [];
|
|
288
|
+
statusLines = [];
|
|
217
289
|
return false;
|
|
218
290
|
}
|
|
219
291
|
const railEligible = width >= SIDEBAR_BREAKPOINT && placement() !== "bottom" && placement() !== "hidden";
|
|
220
292
|
if (!railEligible) {
|
|
221
293
|
prepared = undefined;
|
|
294
|
+
statusLines = [];
|
|
222
295
|
try {
|
|
223
296
|
const headerPart = state.parts.get("header");
|
|
224
|
-
headerLines = headerPlacement()
|
|
297
|
+
headerLines = headerPlacement() !== "below-input" && headerPart
|
|
225
298
|
? [...(headerPart.render(Math.max(0, width)) ?? [])] : [];
|
|
226
299
|
if (!headerLines.some((line) => line.trim() !== "")) headerLines = [];
|
|
300
|
+
// A narrow terminal keeps the status bar row (mobile chrome) when its part paints one.
|
|
301
|
+
const statusPart = state.parts.get("statusbar");
|
|
302
|
+
const narrowStatus = statusPart ? [...(statusPart.render(Math.max(0, width)) ?? [])] : [];
|
|
303
|
+
statusLines = narrowStatus.some((line) => line.trim() !== "") ? narrowStatus : [];
|
|
227
304
|
} catch {
|
|
228
305
|
failed = true;
|
|
229
306
|
headerLines = [];
|
|
@@ -238,24 +315,33 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
238
315
|
const digests = parts.map(([, rail]) => railDigest(rail));
|
|
239
316
|
const signature = themeSignature(theme);
|
|
240
317
|
const unchanged = prepared?.revision === cache.revision &&
|
|
241
|
-
prepared.width === width && prepared.mode === host.mode && prepared.headerPlacement === headerPlacement() && prepared.cardStyle === style && prepared.root === root && prepared.theme === theme && prepared.themeSignature === signature &&
|
|
318
|
+
prepared.width === width && prepared.mode === host.mode && prepared.headerPlacement === headerPlacement() && prepared.density === density() && prepared.surface === chromeSurface() && prepared.cardStyle === style && prepared.root === root && prepared.theme === theme && prepared.themeSignature === signature &&
|
|
242
319
|
prepared.parts.length === parts.length && prepared.parts.every(([key, part], index) => parts[index]?.[0] === key && parts[index]?.[1] === part) &&
|
|
243
320
|
prepared.digests.length === digests.length && prepared.digests.every((digest, index) => digest === digests[index]);
|
|
244
321
|
if (unchanged) {
|
|
245
322
|
railLines = prepared.lines;
|
|
323
|
+
statusLines = prepared.statusLines;
|
|
324
|
+
fillRow = prepared.fillRow;
|
|
246
325
|
state.active = prepared.active;
|
|
247
326
|
return prepared.active;
|
|
248
327
|
}
|
|
249
328
|
try {
|
|
250
329
|
const digestByPart = new Map(parts.map(([key], index) => [key, digests[index]]));
|
|
251
|
-
//
|
|
252
|
-
// the
|
|
253
|
-
// 50-column rail's content width.
|
|
330
|
+
// Top and split headers are full-width siblings above the conversation
|
|
331
|
+
// and rail; the registered part still chooses which content to render.
|
|
254
332
|
const headerPart = state.parts.get("header");
|
|
255
|
-
const preparedHeaderLines = [...(headerPart?.render(Math.max(0, width
|
|
333
|
+
const preparedHeaderLines = [...(headerPart?.render(Math.max(0, width)) ?? [])];
|
|
256
334
|
const headerActive = headerPart !== undefined && preparedHeaderLines.some((line) => line.trim() !== "");
|
|
257
335
|
const contentWidth = scroll.getContentWidth(RAIL_WIDTH);
|
|
258
|
-
const
|
|
336
|
+
const carded = chromeSurface() === "transparent";
|
|
337
|
+
// Float cards are tinted from edge to edge, so two of them would fuse into one
|
|
338
|
+
// slab: like the conversation cards, they always keep a blank row between them.
|
|
339
|
+
// Neon cards close with their own rule, so the density decides their gap.
|
|
340
|
+
const cardGap = () => (carded && style === CARD_STYLE.FLOAT) || sectionGap(density());
|
|
341
|
+
// A carded section renders one indent wider; its body rows drop that indent inside the card.
|
|
342
|
+
const renderWidth = carded ? panelInnerWidth(theme, contentWidth) + PANEL_ROW_INDENT : contentWidth - RAIL_PADDING * 2;
|
|
343
|
+
// Live work first, then the session Status sections (design/shell-rework/02-proposal.html).
|
|
344
|
+
const sections = ["todo", "jobs", "agents", "footer"].filter((key) => key !== "todo" || state.visibility?.todo !== false).map((key) => {
|
|
259
345
|
const component = state.parts.get(key);
|
|
260
346
|
if (!component) {
|
|
261
347
|
sectionCache.delete(key);
|
|
@@ -263,14 +349,16 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
263
349
|
}
|
|
264
350
|
const digest = digestByPart.get(key);
|
|
265
351
|
const existing = sectionCache.get(key);
|
|
266
|
-
|
|
352
|
+
// Sections paint their card chrome in the active style, which their
|
|
353
|
+
// own digests do not track, so a style switch must re-render them.
|
|
354
|
+
const reusable = existing?.component === component && existing.contentWidth === contentWidth && existing.renderWidth === renderWidth && existing.cardStyle === style && existing.theme === theme && existing.themeSignature === signature &&
|
|
267
355
|
(digest !== undefined ? existing.digest === digest : existing.digest === undefined && existing.revision === cache.revision);
|
|
268
356
|
const lines = reusable ? existing.lines : (() => {
|
|
269
|
-
const rendered = [...(component.render(
|
|
357
|
+
const rendered = [...(component.render(renderWidth) ?? [])];
|
|
270
358
|
while (rendered.length && rendered[rendered.length - 1]?.trim() === "") rendered.pop();
|
|
271
359
|
return rendered;
|
|
272
360
|
})();
|
|
273
|
-
sectionCache.set(key, { component, digest, revision: cache.revision, contentWidth, theme, themeSignature: signature, lines });
|
|
361
|
+
sectionCache.set(key, { component, digest, revision: cache.revision, contentWidth, renderWidth, cardStyle: style, theme, themeSignature: signature, lines });
|
|
274
362
|
return { key, component, lines };
|
|
275
363
|
}).filter((section) => section.component !== undefined && section.lines.length > 0) as Array<{ key: string; component: Component; lines: string[] }>;
|
|
276
364
|
// The header carries the brand once it is active; the banner is the
|
|
@@ -278,25 +366,61 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
278
366
|
const branding = headerActive ? [] : renderSidebarBanner(theme, contentWidth - RAIL_PADDING * 2);
|
|
279
367
|
const hits: RailHit[] = [];
|
|
280
368
|
railLines = [];
|
|
369
|
+
fillRow = "";
|
|
370
|
+
const surface = panelSurfaceOpener(theme);
|
|
371
|
+
if (sections.length && headerActive && headerPlacement() !== "below-input") {
|
|
372
|
+
// Tinted spacing continues the rail background; transparent spacing
|
|
373
|
+
// leaves a clear row above the first card. Count it before recording hits.
|
|
374
|
+
railLines.push(paintSurfaceRow(" ".repeat(contentWidth), surface));
|
|
375
|
+
}
|
|
281
376
|
if (sections.length && branding.length) {
|
|
282
377
|
railLines.push(...branding.map((line) => " ".repeat(RAIL_PADDING) + line + " ".repeat(RAIL_PADDING)));
|
|
283
|
-
} else if (sections.length && headerActive && density() === "comfortable" && style === CARD_STYLE.NEON) {
|
|
284
|
-
//
|
|
285
|
-
|
|
286
|
-
railLines.push("");
|
|
378
|
+
} else if (!carded && sections.length && headerActive && headerPlacement() === "below-input" && density() === "comfortable" && style === CARD_STYLE.NEON) {
|
|
379
|
+
// Keep neon's existing comfortable gap for below-input headers too.
|
|
380
|
+
railLines.push((sections[0].component as SidebarRail).surface === "panel" ? paintSurfaceRow(" ".repeat(contentWidth), surface) : "");
|
|
287
381
|
}
|
|
382
|
+
// Panel sections share one tinted surface: their rows, padding
|
|
383
|
+
// included, and the gap between two of them are painted alike.
|
|
384
|
+
let previousPanel = false;
|
|
288
385
|
for (const section of sections) {
|
|
386
|
+
const panel = (section.component as SidebarRail).surface === "panel";
|
|
387
|
+
const paint = (row: string) => (panel ? paintSurfaceRow(row, surface) : row);
|
|
289
388
|
// One blank row separates a section from the banner or the
|
|
290
389
|
// previous section; neon's header gap above is not a section.
|
|
291
|
-
if ((hits.length > 0 || branding.length > 0) &&
|
|
390
|
+
if ((hits.length > 0 || branding.length > 0) && (carded ? cardGap() : sectionGap(density()))) railLines.push(!carded && panel && previousPanel ? paint(" ".repeat(contentWidth)) : "");
|
|
391
|
+
if (carded) {
|
|
392
|
+
const layout = (section.component as SidebarRail).cardGroups?.(renderWidth) ?? { groups: [{ start: 0, end: section.lines.length }] };
|
|
393
|
+
const geometry = cardGeometry(theme, contentWidth, style);
|
|
394
|
+
const indent = " ".repeat(PANEL_ROW_INDENT);
|
|
395
|
+
layout.groups.forEach((group, index) => {
|
|
396
|
+
if (index > 0 && cardGap()) railLines.push("");
|
|
397
|
+
const body = section.lines.slice(group.start + 1, group.end).map((row) => row.startsWith(indent) ? row.slice(PANEL_ROW_INDENT) : row);
|
|
398
|
+
while (body.length && body[body.length - 1]?.trim() === "") body.pop();
|
|
399
|
+
const top = railLines.length;
|
|
400
|
+
railLines.push(...sectionCardRows(headerParts(section.lines[group.start] ?? ""), body, theme, contentWidth));
|
|
401
|
+
// The title row folds the section like its header; body rows keep their own rows.
|
|
402
|
+
const frame = { frameWidth: renderWidth, frameHeight: section.lines.length };
|
|
403
|
+
hits.push({ key: section.key, component: section.component, startY: top + geometry.headerRow, height: 1, width: renderWidth, x: geometry.headerX, row: group.start, wholeRow: true, ...frame });
|
|
404
|
+
if (body.length) hits.push({ key: section.key, component: section.component, startY: top + geometry.bodyRow, height: body.length, width: renderWidth - PANEL_ROW_INDENT, x: geometry.bodyX - PANEL_ROW_INDENT, row: group.start + 1, ...frame });
|
|
405
|
+
});
|
|
406
|
+
const loose = (layout.loose ?? []).map((row) => section.lines[row] ?? "").filter((row) => row.trim() !== "");
|
|
407
|
+
if (loose.length && sectionGap(density())) railLines.push("");
|
|
408
|
+
railLines.push(...loose.map((row) => truncateToWidth(row.trimEnd(), contentWidth, "…")));
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
292
411
|
const startY = railLines.length;
|
|
293
|
-
railLines.push(...section.lines.map((line) => " ".repeat(RAIL_PADDING) + line + " ".repeat(RAIL_PADDING)));
|
|
294
|
-
|
|
412
|
+
railLines.push(...section.lines.map((line) => paint(" ".repeat(RAIL_PADDING) + line + " ".repeat(RAIL_PADDING))));
|
|
413
|
+
previousPanel = panel;
|
|
414
|
+
fillRow = panel ? paint(" ".repeat(contentWidth)) : "";
|
|
415
|
+
hits.push({ key: section.key, component: section.component, startY, height: section.lines.length, width: renderWidth, x: RAIL_PADDING, row: 0, frameWidth: renderWidth, frameHeight: section.lines.length });
|
|
295
416
|
}
|
|
296
417
|
// Height is owned by the native ScrollView, never by the transcript.
|
|
297
418
|
const active = railLines.length > 0 && railLines.every((line) => visibleWidth(line) <= contentWidth);
|
|
298
|
-
headerLines = headerActive && headerPlacement()
|
|
299
|
-
|
|
419
|
+
headerLines = headerActive && headerPlacement() !== "below-input" ? preparedHeaderLines : [];
|
|
420
|
+
const statusPart = state.parts.get("statusbar");
|
|
421
|
+
const preparedStatusLines = active && statusPart ? [...(statusPart.render(Math.max(0, width)) ?? [])] : [];
|
|
422
|
+
statusLines = preparedStatusLines.some((line) => line.trim() !== "") ? preparedStatusLines : [];
|
|
423
|
+
prepared = { revision: cache.revision, width, mode: host.mode, headerPlacement: headerPlacement(), density: density(), surface: chromeSurface(), cardStyle: style, root, theme, themeSignature: signature, parts, digests, contentWidth, active, lines: railLines, hits, headerLines, statusLines, fillRow, headerActive: headerLines.length > 0 };
|
|
300
424
|
state.active = active;
|
|
301
425
|
return active;
|
|
302
426
|
} catch {
|
|
@@ -313,6 +437,16 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
313
437
|
if (roots.has(root)) return;
|
|
314
438
|
const original = root[NODE]!;
|
|
315
439
|
const descriptor = Object.getOwnPropertyDescriptor(root, NODE);
|
|
440
|
+
const mouseDescriptor = Object.getOwnPropertyDescriptor(root, "handleMouse");
|
|
441
|
+
// pi-tui skips layout roots that keep Container.prototype.handleMouse:
|
|
442
|
+
// without a mouse layout cache it renders every child to measure it,
|
|
443
|
+
// which re-renders the whole transcript on each wheel or move event.
|
|
444
|
+
// Replacing it must not re-enable that path, so only own handlers run.
|
|
445
|
+
const originalMouse = root.handleMouse === Container.prototype.handleMouse ? undefined : root.handleMouse;
|
|
446
|
+
const fallbackMouse: NonNullable<Component["handleMouse"]> = (event) => {
|
|
447
|
+
if (event.type === "move" && event.button === "none") setSidebarHover(tui);
|
|
448
|
+
return originalMouse?.call(root, event);
|
|
449
|
+
};
|
|
316
450
|
// Fullscreen gives this stretched stack an explicit viewport height.
|
|
317
451
|
// Its intrinsic-height probe is unused; real painting traverses NODE.
|
|
318
452
|
// Delegating that probe to root.render would render the transcript twice.
|
|
@@ -343,13 +477,13 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
343
477
|
// Without a rail the native layout stays in place; a hidden Status, or a
|
|
344
478
|
// narrow top header owning it, only frees the footer's reserved dock row,
|
|
345
479
|
// exactly as the rail does.
|
|
346
|
-
|
|
480
|
+
// The minimal edition (compact work) hands the footer row to its status bar too.
|
|
481
|
+
const nativeLayout = () => placement() === "hidden" || headerOwnsStatus() || state.compactWork?.() ? reclaimFooterRow(original.call(root)) : original.call(root);
|
|
347
482
|
const nativeHost = { render: () => [], invalidate() {}, [NODE]: nativeLayout };
|
|
348
483
|
const left = { render: () => [], invalidate() {}, [NODE]: () => reclaimFooterRow(original.call(root)) };
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
// recurses into a nested layout via [NODE].
|
|
484
|
+
// The full-width header is a sibling above this stable conversation/rail
|
|
485
|
+
// hstack. Pi keeps native transcript scrolling and dispatches header and
|
|
486
|
+
// rail mouse events in their respective boxes.
|
|
353
487
|
const hstackHost: Component & { [NODE](): LayoutNode } = {
|
|
354
488
|
render: () => [],
|
|
355
489
|
invalidate() {},
|
|
@@ -361,29 +495,39 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
361
495
|
const replacement = () => {
|
|
362
496
|
if (!prepare(tui.terminal.columns, root)) {
|
|
363
497
|
if (failed || stopped || host.mode !== "fullscreen") return original.call(root);
|
|
364
|
-
if (!headerLines.length) return nativeLayout();
|
|
498
|
+
if (!headerLines.length && !statusLines.length) return nativeLayout();
|
|
365
499
|
return { type: "vstack", gap: 0, align: "stretch", entries: [
|
|
366
|
-
{ component: header, basis: "auto", grow: 0, shrink: 0, minSize: 1 },
|
|
500
|
+
...(headerLines.length ? [{ component: header, basis: "auto" as const, grow: 0, shrink: 0, minSize: 1 }] : []),
|
|
367
501
|
{ component: nativeHost, basis: 0, grow: 1, shrink: 1, minSize: 1 },
|
|
502
|
+
...(statusLines.length ? [{ component: statusBar, basis: "auto" as const, grow: 0, shrink: 0, minSize: 1 }] : []),
|
|
368
503
|
] };
|
|
369
504
|
}
|
|
370
505
|
const current = prepared!;
|
|
371
506
|
if (current.presentation?.scrollTop === scroll.scrollTop) return current.presentation.output;
|
|
372
|
-
const
|
|
507
|
+
const withHeader = current.headerActive && headerPlacement() !== "below-input";
|
|
508
|
+
const withStatus = current.statusLines.length > 0;
|
|
509
|
+
const output: LayoutNode = withHeader || withStatus
|
|
373
510
|
? { type: "vstack", gap: 0, align: "stretch", entries: [
|
|
374
|
-
{ component: header, basis: "auto", grow: 0, shrink: 0, minSize: 1 },
|
|
511
|
+
...(withHeader ? [{ component: header, basis: "auto" as const, grow: 0, shrink: 0, minSize: 1 }] : []),
|
|
375
512
|
{ component: hstackHost, basis: 0, grow: 1, shrink: 1, minSize: 1 },
|
|
513
|
+
...(withStatus ? [{ component: statusBar, basis: "auto" as const, grow: 0, shrink: 0, minSize: 1 }] : []),
|
|
376
514
|
] }
|
|
377
515
|
: hstackHost[NODE]();
|
|
378
516
|
return (current.presentation = { scrollTop: scroll.scrollTop, output }).output;
|
|
379
517
|
};
|
|
380
518
|
root[NODE] = replacement;
|
|
519
|
+
root.handleMouse = fallbackMouse;
|
|
381
520
|
roots.add(root);
|
|
382
521
|
tui.requestRender();
|
|
383
522
|
cleanups.push(() => {
|
|
384
|
-
if (root[NODE]
|
|
385
|
-
|
|
386
|
-
|
|
523
|
+
if (root[NODE] === replacement) {
|
|
524
|
+
if (descriptor) Object.defineProperty(root, NODE, descriptor);
|
|
525
|
+
else Reflect.deleteProperty(root, NODE);
|
|
526
|
+
}
|
|
527
|
+
if (root.handleMouse === fallbackMouse) {
|
|
528
|
+
if (mouseDescriptor) Object.defineProperty(root, "handleMouse", mouseDescriptor);
|
|
529
|
+
else Reflect.deleteProperty(root, "handleMouse");
|
|
530
|
+
}
|
|
387
531
|
});
|
|
388
532
|
} catch {
|
|
389
533
|
failed = true;
|
|
@@ -397,6 +541,7 @@ export function installSidebar(tui: TUI, theme: ShellBarTheme, placement: () =>
|
|
|
397
541
|
timer.unref();
|
|
398
542
|
return () => {
|
|
399
543
|
stopped = true;
|
|
544
|
+
setSidebarHover(tui);
|
|
400
545
|
state.active = false;
|
|
401
546
|
clearInterval(timer);
|
|
402
547
|
scroll.setScrollbar("hidden");
|
package/lib/shell-sidebar.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Component, TUI } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { PanelSummary } from "./shell-panel.ts";
|
|
2
3
|
|
|
3
4
|
// Store on the terminal, not a module singleton: extension loaders may isolate
|
|
4
5
|
// modules, while Pi keeps this terminal across regular/fullscreen transitions.
|
|
@@ -20,11 +21,26 @@ export interface SidebarState {
|
|
|
20
21
|
statusHidden?: () => boolean;
|
|
21
22
|
/** True while a painting top header is the only status row of a narrow fullscreen terminal: the bottom Status bar steps aside. */
|
|
22
23
|
headerOwnsStatus?: () => boolean;
|
|
24
|
+
/** True while a narrow fullscreen terminal folds live work into the mobile work row: the Todos and Agents cards step aside. */
|
|
25
|
+
compactWork?: () => boolean;
|
|
26
|
+
/** True while the IDE chrome's status bar shows the permission mode: the above-editor YOLO banner steps aside. */
|
|
27
|
+
statusBarShowsMode?: () => boolean;
|
|
28
|
+
/** True while the fullscreen layout is installed on the host's root, so its title row and status bar can actually draw. */
|
|
29
|
+
layoutAttached?: () => boolean;
|
|
30
|
+
/** Current shell-owned pointer hover; shared across separately loaded extensions. */
|
|
31
|
+
hover?: { owner: object; clear: () => void };
|
|
23
32
|
parts: Map<string, SidebarRail>;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
/** A rail slot in the fullscreen sidebar. */
|
|
27
36
|
export interface SidebarRail extends Component {
|
|
37
|
+
/**
|
|
38
|
+
* Row ranges of the sections this part renders, for a transparent rail that
|
|
39
|
+
* draws every section as its own card: each group starts at its header row
|
|
40
|
+
* and ends before `end`; `loose` rows (key hints) sit outside the cards.
|
|
41
|
+
* Without it the whole part is one section headed by its first row.
|
|
42
|
+
*/
|
|
43
|
+
cardGroups?(width: number): { groups: Array<{ start: number; end: number }>; loose?: number[] } | undefined;
|
|
28
44
|
/**
|
|
29
45
|
* Cheap digest of the live state this rail paints. The fullscreen layout memo
|
|
30
46
|
* re-renders a part only when its digest changes, so a rail that reads session
|
|
@@ -32,12 +48,41 @@ export interface SidebarRail extends Component {
|
|
|
32
48
|
* one; explicit invalidateSidebar() stays for discrete state changes.
|
|
33
49
|
*/
|
|
34
50
|
digest?(): string;
|
|
51
|
+
/**
|
|
52
|
+
* "panel" sections render IDE-like panel rows (lib/shell-panel.ts) and the
|
|
53
|
+
* rail paints them, padding included, on one shared surface; others are
|
|
54
|
+
* cards that carry their own chrome.
|
|
55
|
+
*/
|
|
56
|
+
surface?: "panel";
|
|
57
|
+
/** A one-row digest for the mobile work row; undefined when the section has nothing live. */
|
|
58
|
+
summary?(): PanelSummary | undefined;
|
|
59
|
+
/** Opens the section's own view (Agents: /gentle:agents); a tap on the mobile work row runs it when this section leads the row. */
|
|
60
|
+
open?(): void;
|
|
61
|
+
/** "Needs you" rows the panel editor draws right above its rule (an agent asking the user); [] when none. */
|
|
62
|
+
alert?(width: number): string[];
|
|
63
|
+
/** What this section's work spent (the Agents section: started subagents), for the Stats section. */
|
|
64
|
+
spend?(): { runs: number; tokens: number; cost: number } | undefined;
|
|
35
65
|
}
|
|
36
66
|
export function sidebarState(tui: TUI): SidebarState {
|
|
37
67
|
const terminal = tui.terminal as unknown as Record<symbol, SidebarState>;
|
|
38
68
|
return terminal[STATE] ??= { active: false, parts: new Map() };
|
|
39
69
|
}
|
|
40
70
|
|
|
71
|
+
/** Transfer shell hover ownership without clearing an unchanged owner. */
|
|
72
|
+
export function setSidebarHover(tui: TUI, owner?: object, clear?: () => void): void {
|
|
73
|
+
if (!tui.terminal) return;
|
|
74
|
+
const state = sidebarState(tui);
|
|
75
|
+
if (state.hover?.owner === owner) return;
|
|
76
|
+
const previous = state.hover;
|
|
77
|
+
state.hover = owner && clear ? { owner, clear } : undefined;
|
|
78
|
+
previous?.clear();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Forget a disposed or invalidated owner without disturbing another surface. */
|
|
82
|
+
export function releaseSidebarHover(tui: TUI, owner: object): void {
|
|
83
|
+
if (tui.terminal && sidebarState(tui).hover?.owner === owner) sidebarState(tui).hover = undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
41
86
|
/** Keep the original bottom component mounted, suppressing only its paint. */
|
|
42
87
|
export function sidebarPart<T extends Component & { dispose?(): void }>(tui: TUI, key: string, bottom: T, rail: SidebarRail = bottom): T {
|
|
43
88
|
// Minimal extension hosts cannot share terminal-owned layout state.
|
|
@@ -46,7 +91,7 @@ export function sidebarPart<T extends Component & { dispose?(): void }>(tui: TUI
|
|
|
46
91
|
state.parts.set(key, rail);
|
|
47
92
|
return {
|
|
48
93
|
...bottom,
|
|
49
|
-
render: (width: number) => (key === "todo" && state.visibility?.todo === false) || (key === "footer" && (state.statusHidden?.() || state.headerOwnsStatus?.())) || (state.active && state.ownsHost?.()) ? [] : bottom.render(width),
|
|
94
|
+
render: (width: number) => (key === "todo" && state.visibility?.todo === false) || (key === "footer" && (state.statusHidden?.() || state.headerOwnsStatus?.() || state.compactWork?.())) || ((key === "todo" || key === "agents") && state.compactWork?.()) || (state.active && state.ownsHost?.()) ? [] : bottom.render(width),
|
|
50
95
|
dispose() {
|
|
51
96
|
if (state.parts.get(key) === rail) state.parts.delete(key);
|
|
52
97
|
bottom.dispose?.();
|
|
@@ -69,3 +114,18 @@ export function sidebarHeader(tui: TUI, rail: SidebarRail): () => void {
|
|
|
69
114
|
if (state.parts.get("header") === rail) state.parts.delete("header");
|
|
70
115
|
};
|
|
71
116
|
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Register the fullscreen status bar: one full-width row below the transcript
|
|
120
|
+
* and the rail while the rail is shown. Below the breakpoint it paints nothing;
|
|
121
|
+
* the compact bar carries the same data there. Writes the "statusbar" slot and
|
|
122
|
+
* returns its own disposer.
|
|
123
|
+
*/
|
|
124
|
+
export function sidebarStatusBar(tui: TUI, rail: SidebarRail): () => void {
|
|
125
|
+
if (!tui.terminal) return () => {};
|
|
126
|
+
const state = sidebarState(tui);
|
|
127
|
+
state.parts.set("statusbar", rail);
|
|
128
|
+
return () => {
|
|
129
|
+
if (state.parts.get("statusbar") === rail) state.parts.delete("statusbar");
|
|
130
|
+
};
|
|
131
|
+
}
|