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
package/lib/shell-bar.ts
CHANGED
|
@@ -2,7 +2,10 @@ import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works
|
|
|
2
2
|
import { GAUGE_CELLS, gaugeTone, paintGauge, renderGauge, type GaugePaint, type GaugeTone } from "./shell-gauge.ts";
|
|
3
3
|
import { renderUsageBar, selectUsageLimit, type ProviderUsage, type UsageWindow } from "./shell-usage.ts";
|
|
4
4
|
import { sanitizeTerminalText } from "./terminal-theme.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { HOVER_ROLE } from "./shell-hover.ts";
|
|
6
|
+
import { renderStatsRows, type SessionStats } from "./shell-stats.ts";
|
|
7
|
+
import { CARD_TONE, floatRows, paintSurfaceRow, panelInnerWidth, renderCard } from "./shell-card.ts";
|
|
8
|
+
import { chromeSurface, clipPanelText, fitPanelLine, PANEL_ROW_INDENT, panelSurfaceOpener, renderPanelHeader, renderPanelRow, sectionGap } from "./shell-panel.ts";
|
|
6
9
|
import { REVIEW_SCOPE_UNAVAILABLE, REVIEW_SIDEBAR_LABELS, type ReviewSidebarSnapshot } from "./review-sidebar-state.ts";
|
|
7
10
|
import type { VisualSettings } from "./visual-customization-policy.ts";
|
|
8
11
|
import { renderChangesWidget, type ChangesModel } from "./shell-changes.ts";
|
|
@@ -19,6 +22,8 @@ export { gaugeTone, renderGauge, type GaugeTone };
|
|
|
19
22
|
// verified without a live TUI.
|
|
20
23
|
|
|
21
24
|
export interface ShellBarModel {
|
|
25
|
+
/** Session statistics for the Power user rail; absent elsewhere. */
|
|
26
|
+
stats?: SessionStats;
|
|
22
27
|
review?: ReviewSidebarSnapshot;
|
|
23
28
|
jobs?: RunningJobDisplay[];
|
|
24
29
|
profile?: string;
|
|
@@ -29,12 +34,18 @@ export interface ShellBarModel {
|
|
|
29
34
|
sessionName: string | undefined;
|
|
30
35
|
modelId: string;
|
|
31
36
|
effort: string | undefined;
|
|
37
|
+
/** Orchestrator tier configured in the named profile; not a server observation. */
|
|
38
|
+
profileTier?: "standard" | "fast";
|
|
32
39
|
contextPercent: number | null;
|
|
33
40
|
contextWindow: number;
|
|
34
41
|
costTotal: number;
|
|
35
42
|
subscription: boolean;
|
|
36
43
|
usage: ProviderUsage | undefined;
|
|
37
44
|
statuses: string[];
|
|
45
|
+
/** The permission mode published under its own status key, shown once in the status bar. */
|
|
46
|
+
permission?: { mode: string; detail?: string };
|
|
47
|
+
/** Statuses for the rail's Integrations: `statuses` without the permission keys. */
|
|
48
|
+
integrations?: string[];
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
// The live header row above the fullscreen rail: session identity plus the
|
|
@@ -159,9 +170,10 @@ function executionSegment(modelId: string, effort: string | undefined, theme: Sh
|
|
|
159
170
|
: theme.fg(ROLE.MODEL, modelId);
|
|
160
171
|
}
|
|
161
172
|
|
|
162
|
-
function contextSegment(contextPercent: number | null, theme: ShellBarTheme, paint?: GaugePaint): string {
|
|
173
|
+
function contextSegment(contextPercent: number | null, theme: ShellBarTheme, paint?: GaugePaint, withGauge = true): string {
|
|
163
174
|
const percentText = contextPercent === null ? "?%" : `${Math.round(contextPercent)}%`;
|
|
164
|
-
|
|
175
|
+
const gauge = withGauge ? `${paintGauge(contextPercent, theme, GAUGE_CELLS, paint)} ` : "";
|
|
176
|
+
return `${theme.fg(ROLE.LABEL, "ctx")} ${gauge}${theme.fg(ROLE.VALUE, percentText)}`;
|
|
165
177
|
}
|
|
166
178
|
|
|
167
179
|
function costSegment(costTotal: number, subscription: boolean, theme: ShellBarTheme): string {
|
|
@@ -211,68 +223,220 @@ function joinSegments(segments: string[], theme: ShellBarTheme): string {
|
|
|
211
223
|
|
|
212
224
|
// Sidebar groups use structured fields, never positional compact-bar segments
|
|
213
225
|
// or inferred meanings from opaque extension status strings.
|
|
214
|
-
|
|
215
|
-
|
|
226
|
+
// The fullscreen rail's Status, drawn as panel sections (design/shell-rework/02-proposal.html):
|
|
227
|
+
// Changes, Review (only with current-session RDD evidence) and Integrations.
|
|
228
|
+
// Location and model live in the header row; the effective agent profile opens
|
|
229
|
+
// Stats when that section is enabled. Opaque integration statuses wrap so none
|
|
230
|
+
// of their meaning is clipped; callers can still supply optional legacy hints.
|
|
231
|
+
export function renderShellSidebarBar(model: ShellBarModel, theme: ShellBarTheme, width: number, presentation?: Presentation, hints?: string, options: StatusSectionsOptions = {}): string[] {
|
|
232
|
+
return renderShellStatusSections(model, theme, width, presentation, hints, options).lines;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type StatusSection = "session" | "changes" | "review" | "stats" | "integrations";
|
|
236
|
+
export type StatusTarget = { row: number; kind: "toggle"; section: StatusSection } | { row: number; kind: "open-changes" };
|
|
237
|
+
export interface StatusSectionsOptions {
|
|
238
|
+
/** Keep the session name (no title row shows it). */
|
|
239
|
+
session?: boolean;
|
|
240
|
+
/** Sections folded to their header. */
|
|
241
|
+
collapsed?: ReadonlySet<StatusSection>;
|
|
242
|
+
/** The pointer is over this section's header, or over the Changes row. */
|
|
243
|
+
hovered?: StatusSection | "open-changes";
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** The rail Status with its click targets: section headers collapse them and the Changes row opens /gentle:changes. */
|
|
247
|
+
export function renderShellStatusSections(model: ShellBarModel, theme: ShellBarTheme, width: number, presentation?: Presentation, hints?: string, options: StatusSectionsOptions = {}): { lines: string[]; targets: StatusTarget[]; groups: Array<{ start: number; end: number }>; loose: number[] } {
|
|
216
248
|
const label = (text: string) => theme.fg(ROLE.LABEL, text);
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
label("/gentle:changes"),
|
|
244
|
-
],
|
|
245
|
-
}]),
|
|
246
|
-
...(model.review && presentation?.visibility.rdd !== false ? [{
|
|
247
|
-
title: "🌹 RDD",
|
|
248
|
-
lines: [
|
|
249
|
-
value(REVIEW_SIDEBAR_LABELS[model.review.state]),
|
|
249
|
+
const wrapped = (text: string, role: string) => wrapTextWithAnsi(text, Math.max(1, width - PANEL_ROW_INDENT)).map((line) => renderPanelRow(width, theme.fg(role, line)));
|
|
250
|
+
type Section = { key?: StatusSection; header?: string; rows: string[]; openChangesRow?: number };
|
|
251
|
+
const sections: Section[] = [];
|
|
252
|
+
const header = (key: StatusSection, title: string, count?: string, countRole?: string) => renderPanelHeader(theme, width, { title, count, countRole, open: !options.collapsed?.has(key), hovered: options.hovered === key });
|
|
253
|
+
// Without the top title row (header below the input) the session name has no
|
|
254
|
+
// other home, so the rail keeps it.
|
|
255
|
+
if (options.session && model.sessionName) {
|
|
256
|
+
sections.push({ key: "session", header: header("session", "Session"), rows: wrapped(sanitizeStatus(model.sessionName), ROLE.VALUE) });
|
|
257
|
+
}
|
|
258
|
+
if (presentation?.visibility.changes !== false) {
|
|
259
|
+
const changes = model.changes;
|
|
260
|
+
const command = options.hovered === "open-changes" ? theme.fg(HOVER_ROLE, "/gentle:changes") : label("/gentle:changes");
|
|
261
|
+
sections.push({
|
|
262
|
+
key: "changes",
|
|
263
|
+
header: header("changes", "Changes", changes?.files ? `${changes.files} ${changes.files === 1 ? "file" : "files"}` : "clean"),
|
|
264
|
+
rows: [renderPanelRow(width, changes?.files ? `${theme.fg("success", `+${changes.added}`)} ${theme.fg("error", `−${changes.deleted}`)}` : label("no captured changes"), command)],
|
|
265
|
+
openChangesRow: 0,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (model.review && presentation?.visibility.rdd !== false) {
|
|
269
|
+
const needsYou = model.review.state === "consent";
|
|
270
|
+
sections.push({
|
|
271
|
+
key: "review",
|
|
272
|
+
header: header("review", "Review", needsYou ? "needs you" : undefined, "warning"),
|
|
273
|
+
rows: [
|
|
274
|
+
...wrapped(REVIEW_SIDEBAR_LABELS[model.review.state], needsYou ? "warning" : ROLE.VALUE),
|
|
250
275
|
// Unknown scope is an internal sentinel, not something the user acts on.
|
|
251
|
-
...(model.review.scope !== REVIEW_SCOPE_UNAVAILABLE ?
|
|
276
|
+
...(model.review.scope !== REVIEW_SCOPE_UNAVAILABLE ? wrapped(sanitizeStatus(model.review.scope), ROLE.LABEL) : []),
|
|
252
277
|
],
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
// Power user (compact density) adds what the session spent, per model.
|
|
281
|
+
if (model.stats) {
|
|
282
|
+
// The agent profile opens Stats: it decides which models the session's spend went to.
|
|
283
|
+
const profile = model.profile ? sanitizeStatus(model.profile) : "";
|
|
284
|
+
const profileRow = profile ? [renderPanelRow(width, clipPanelText(`${label("profile")} ${theme.fg(ROLE.VALUE, profile)}`, Math.max(1, width - PANEL_ROW_INDENT)))] : [];
|
|
285
|
+
sections.push({ key: "stats", header: header("stats", "Stats", formatCost(model.stats.cost, model.subscription)), rows: [...profileRow, ...renderStatsRows(model.stats, theme, width, model.subscription)] });
|
|
286
|
+
}
|
|
287
|
+
// The status bar shows the permission mode once; Integrations only says
|
|
288
|
+
// what it means, so neither the mode nor its banner repeats here.
|
|
289
|
+
const integrations = model.integrations ?? model.statuses;
|
|
290
|
+
const integrationRows = (text: string) => wrapTextWithAnsi(text, Math.max(1, width - PANEL_ROW_INDENT - 2))
|
|
291
|
+
.map((line, index) => renderPanelRow(width, `${label(index === 0 ? "- " : " ")}${line}`));
|
|
292
|
+
const permission = model.permission?.detail ? integrationRows(`${label("permissions")} ${theme.fg(ROLE.STATUS, sanitizeStatus(model.permission.detail))}`) : [];
|
|
293
|
+
const count = integrations.length + (permission.length ? 1 : 0);
|
|
294
|
+
sections.push({
|
|
295
|
+
key: "integrations",
|
|
296
|
+
header: header("integrations", "Integrations", count ? String(count) : "none"),
|
|
297
|
+
rows: [...permission, ...(integrations.length ? integrations.flatMap((status) => integrationRows(theme.fg(ROLE.STATUS, sanitizeStatus(status)))) : permission.length ? [] : [renderPanelRow(width, label("no status reported"))])],
|
|
298
|
+
});
|
|
299
|
+
// Minimal density keeps only the sections: the key hints row goes.
|
|
300
|
+
if (hints && presentation?.density !== "minimal") sections.push({ rows: [renderPanelRow(width, label(hints))] });
|
|
301
|
+
const gap = sectionGap(presentation?.density) ? [" ".repeat(Math.max(0, width))] : [];
|
|
302
|
+
const lines: string[] = [];
|
|
303
|
+
const targets: StatusTarget[] = [];
|
|
304
|
+
// Each headed section's row range, and the unheaded rows (key hints), so a
|
|
305
|
+
// transparent rail can draw every section as its own card.
|
|
306
|
+
const groups: Array<{ start: number; end: number }> = [];
|
|
307
|
+
const loose: number[] = [];
|
|
308
|
+
sections.forEach((section, index) => {
|
|
309
|
+
if (index) lines.push(...gap);
|
|
310
|
+
const start = lines.length;
|
|
311
|
+
if (section.key && section.header) {
|
|
312
|
+
targets.push({ row: lines.length, kind: "toggle", section: section.key });
|
|
313
|
+
lines.push(section.header);
|
|
314
|
+
if (options.collapsed?.has(section.key)) { groups.push({ start, end: lines.length }); return; }
|
|
315
|
+
}
|
|
316
|
+
if (section.openChangesRow !== undefined) targets.push({ row: lines.length + section.openChangesRow, kind: "open-changes" });
|
|
317
|
+
lines.push(...section.rows);
|
|
318
|
+
if (section.key && section.header) groups.push({ start, end: lines.length });
|
|
319
|
+
else for (let row = start; row < lines.length; row++) loose.push(row);
|
|
320
|
+
});
|
|
321
|
+
return { lines, targets, groups, loose };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// The wide fullscreen chrome (design/shell-rework/02-proposal.html): a title row
|
|
325
|
+
// with the project identity above the transcript and the rail, and one status
|
|
326
|
+
// bar row below them. Both sit on the rail's panel surface.
|
|
327
|
+
const STATUS_BAR_DIVIDER = "│";
|
|
328
|
+
const paintChromeRow = (theme: ShellBarTheme, row: string) => paintSurfaceRow(row, panelSurfaceOpener(theme));
|
|
329
|
+
|
|
330
|
+
// `cwd` is already abbreviated by the footer model; never consult the filesystem
|
|
331
|
+
// while rendering. Strip terminal controls before displaying either copy.
|
|
332
|
+
function projectIdentity(cwd: string, theme: ShellBarTheme): { name: string; full: string } {
|
|
333
|
+
const path = sanitizeStatus(cwd);
|
|
334
|
+
const name = path.split("/").filter((part) => part.length > 0).pop() ?? path;
|
|
335
|
+
const label = `${theme.fg(ROLE.BRAND, "✿")} ${theme.fg(ROLE.VALUE, theme.bold(name))}`;
|
|
336
|
+
return { name: label, full: `${label} ${theme.fg(ROLE.PATH, path)}` };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** `✿ name path` left; the session name, or the model and profile on mobile, right. */
|
|
340
|
+
export function renderShellTitleRow(model: ShellBarModel, theme: ShellBarTheme, width: number, options: { model?: boolean } = {}): string {
|
|
341
|
+
const target = Math.max(0, Math.floor(width));
|
|
342
|
+
const left = projectIdentity(model.cwd, theme).full;
|
|
343
|
+
// Mobile: the narrow status bar leaves the model out, so the title row carries
|
|
344
|
+
// it with the agent profile; wide, the status bar carries both and this row keeps the session.
|
|
345
|
+
const profileName = model.profile ? sanitizeStatus(model.profile) : "";
|
|
346
|
+
const profile = profileName ? ` ${theme.fg(ROLE.SEPARATOR, "·")} ${theme.fg(ROLE.LABEL, profileName)}` : "";
|
|
347
|
+
const right = options.model
|
|
348
|
+
? `${executionSegment(model.modelId, model.effort, theme)}${profile}`
|
|
349
|
+
: model.sessionName ? theme.fg(ROLE.VALUE, sanitizeStatus(model.sessionName)) : "";
|
|
350
|
+
return paintChromeRow(theme, ` ${fitPanelLine(left, right, Math.max(0, target - 2))} `);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// The status bar replaces the YOLO banners, so it keeps their icons.
|
|
354
|
+
const MODE_GLYPHS: Record<string, string> = { YOLO: "🔥", "SUPER-YOLO": "💥" };
|
|
355
|
+
function modeBadge(mode: string): string {
|
|
356
|
+
const glyph = MODE_GLYPHS[mode];
|
|
357
|
+
return glyph ? `${glyph} ${mode}` : mode;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* The status bar: branch, dirty count and a non-default permission mode on
|
|
361
|
+
* the left; model · effort, context, cost and usage on the right. A long
|
|
362
|
+
* branch shortens before the model and counters give way; usage and its
|
|
363
|
+
* click target degrade with the available space.
|
|
364
|
+
*/
|
|
365
|
+
export function renderShellStatusBar(model: ShellBarModel, theme: ShellBarTheme, width: number, usageHint?: string, presentation?: Presentation, paint?: GaugePaint, extras: { jobs?: boolean; project?: boolean } = {}): ShellHeaderChrome {
|
|
366
|
+
const target = Math.max(0, Math.floor(width));
|
|
367
|
+
if (target < 2) return { rows: [paintChromeRow(theme, " ".repeat(target))], headerRow: 0 };
|
|
368
|
+
const room = target - 2;
|
|
369
|
+
const divider = ` ${theme.fg(ROLE.SEPARATOR, STATUS_BAR_DIVIDER)} `;
|
|
370
|
+
const join = (segments: string[]) => segments.filter(Boolean).join(divider);
|
|
371
|
+
const dirty = model.dirty ? theme.fg(ROLE.DIRTY, `±${model.dirty}`) : "";
|
|
372
|
+
const branch = [model.branch ? theme.fg(ROLE.BRANCH, model.branch) : "", dirty].filter(Boolean).join(" ");
|
|
373
|
+
const mode = model.permission && model.permission.mode !== "NORMAL" ? theme.fg("warning", theme.bold(modeBadge(sanitizeStatus(model.permission.mode)))) : "";
|
|
374
|
+
// Without a rail (mobile) the running jobs keep their compact count here.
|
|
375
|
+
const runningJobs = extras.jobs ? (model.jobs?.filter((job) => job.status === undefined).length ?? 0) : 0;
|
|
376
|
+
const tail = join([mode, runningJobs ? theme.fg(ROLE.STATUS, shellJobsCount(runningJobs)) : ""]);
|
|
377
|
+
const left = join([branch, tail]);
|
|
378
|
+
const minimal = presentation?.density === "minimal";
|
|
379
|
+
const showCounters = presentation?.visibility.usageCost !== false;
|
|
380
|
+
// The configured tier stays beside the effort and yields only at the end; the
|
|
381
|
+
// agent profile follows it and gives way before the usage does.
|
|
382
|
+
const tier = model.profileTier ? ` ${theme.fg(ROLE.LABEL, "·")} ${theme.fg(model.profileTier === "fast" ? "warning" : ROLE.LABEL, model.profileTier === "fast" ? "Fast" : "Standard")}` : "";
|
|
383
|
+
const profileName = model.profile ? sanitizeStatus(model.profile) : "";
|
|
384
|
+
const profile = profileName ? ` ${theme.fg(ROLE.LABEL, "·")} ${theme.fg(ROLE.LABEL, profileName)}` : "";
|
|
385
|
+
const exec = presentation?.visibility.modelDetails === false ? "" : executionSegment(model.modelId, model.effort, theme);
|
|
386
|
+
const counters = showCounters ? [contextSegment(model.contextPercent, theme, paint, !minimal), costSegment(model.costTotal, model.subscription, theme)] : [];
|
|
387
|
+
const windows = model.usage ? (selectUsageLimit(model.usage, model.modelId)?.windows ?? []) : [];
|
|
388
|
+
const stages: Array<UsageStage | undefined> = !showCounters ? [undefined] : minimal ? ["text", "primary", undefined] : ["full", "text", "primary", undefined];
|
|
389
|
+
const attempts = [...stages.flatMap((stage) => [{ stage, withExec: true, withTier: true, withProfile: true }, ...(profile ? [{ stage, withExec: true, withTier: true, withProfile: false }] : [])]),
|
|
390
|
+
...(tier ? [{ stage: undefined, withExec: true, withTier: false, withProfile: false }] : []), { stage: undefined, withExec: false, withTier: false, withProfile: false }];
|
|
391
|
+
for (const { stage, withExec, withTier, withProfile } of attempts) {
|
|
392
|
+
const usage = stage ? usageSegmentText(windows, theme, stage, minimal ? undefined : usageHint, paint) : "";
|
|
393
|
+
const right = join([withExec ? exec + (exec && withTier ? tier : "") + (exec && withProfile ? profile : "") : "", ...counters, usage]);
|
|
394
|
+
let shownLeft = left;
|
|
395
|
+
if (visibleWidth(shownLeft) + (right ? RIGHT_PADDING : 0) + visibleWidth(right) > room) {
|
|
396
|
+
if (!model.branch || visibleWidth(model.branch) <= COMPACT_BRANCH_WIDTH) continue;
|
|
397
|
+
// Reserve the dirty count and the permission/job badges before clipping
|
|
398
|
+
// the branch itself. Keep a recognizable prefix while usage is present;
|
|
399
|
+
// after usage gives way, a shorter prefix can still save model and effort.
|
|
400
|
+
const protectedWidth = visibleWidth(join([dirty, tail])) + (dirty ? 1 : tail ? visibleWidth(divider) : 0);
|
|
401
|
+
const branchRoom = room - visibleWidth(right) - (right ? RIGHT_PADDING : 0) - protectedWidth;
|
|
402
|
+
if (branchRoom < (stage ? COMPACT_BRANCH_WIDTH : 4)) continue;
|
|
403
|
+
const shortened = theme.fg(ROLE.BRANCH, clipPanelText(model.branch, branchRoom));
|
|
404
|
+
shownLeft = join([[shortened, dirty].filter(Boolean).join(" "), tail]);
|
|
405
|
+
if (visibleWidth(shownLeft) + (right ? RIGHT_PADDING : 0) + visibleWidth(right) > room) continue;
|
|
406
|
+
}
|
|
407
|
+
if (extras.project) {
|
|
408
|
+
// Add identity only in spare cells, so path and name never displace
|
|
409
|
+
// model, effort, tier, badges or counters selected by the existing fit.
|
|
410
|
+
const identity = projectIdentity(model.cwd, theme);
|
|
411
|
+
const available = room - visibleWidth(shownLeft) - visibleWidth(right) - (right ? RIGHT_PADDING : 0) - (shownLeft ? visibleWidth(divider) : 0);
|
|
412
|
+
const project = [identity.full, identity.name].find((candidate) => visibleWidth(candidate) <= available);
|
|
413
|
+
if (project) shownLeft = join([project, shownLeft]);
|
|
414
|
+
}
|
|
415
|
+
const row = ` ${shownLeft}${" ".repeat(room - visibleWidth(shownLeft) - visibleWidth(right))}${right} `;
|
|
416
|
+
const usageSpan = usage ? { start: target - 1 - visibleWidth(usage), end: target - 1 } : undefined;
|
|
417
|
+
return { rows: [paintChromeRow(theme, row)], headerRow: 0, ...(usageSpan ? { usageSpan } : {}) };
|
|
418
|
+
}
|
|
419
|
+
// Still too wide: the branch gives way before context and cost, which give
|
|
420
|
+
// way last, context after cost. Keep the badges when only they fit.
|
|
421
|
+
const tailWidth = tail ? visibleWidth(tail) + (branch ? visibleWidth(divider) : 0) : 0;
|
|
422
|
+
for (const right of [join(counters), counters[0] ?? "", ""]) {
|
|
423
|
+
const leftRoom = room - visibleWidth(right) - (right ? RIGHT_PADDING : 0);
|
|
424
|
+
const branchRoom = leftRoom - tailWidth;
|
|
425
|
+
if (branch && branchRoom < 4 && right) continue;
|
|
426
|
+
if (branch && branchRoom < 1 && !right && tail) return { rows: [paintChromeRow(theme, ` ${fitPanelLine(tail, "", room)} `)], headerRow: 0 };
|
|
427
|
+
const fitted = join([branch ? clipPanelText(branch, Math.max(1, branchRoom)) : "", tail]);
|
|
428
|
+
if (visibleWidth(fitted) > leftRoom && right) continue;
|
|
429
|
+
return { rows: [paintChromeRow(theme, ` ${fitPanelLine(fitted, right, room)} `)], headerRow: 0 };
|
|
430
|
+
}
|
|
431
|
+
return { rows: [paintChromeRow(theme, ` ${fitPanelLine(left, "", room)} `)], headerRow: 0 };
|
|
268
432
|
}
|
|
269
433
|
|
|
270
434
|
const HEADER_BRAND = "✿ Gentle Shell";
|
|
271
435
|
|
|
272
436
|
// Narrower than the width, widest first: dropping the profile, then the
|
|
273
|
-
// effort, then the whole location keeps the brand and the
|
|
274
|
-
//
|
|
275
|
-
// counters.
|
|
437
|
+
// effort, then the whole location keeps the brand and the model alive.
|
|
438
|
+
// Once location goes, restore effort if it fits before trying model-only
|
|
439
|
+
// alongside the right-aligned counters.
|
|
276
440
|
function headerLeftStages(model: ShellHeaderModel, theme: ShellBarTheme, showModelDetails: boolean): string[][] {
|
|
277
441
|
const brand = theme.fg(ROLE.BRAND, theme.bold(HEADER_BRAND));
|
|
278
442
|
const location = locationSegment(model, theme);
|
|
@@ -284,6 +448,7 @@ function headerLeftStages(model: ShellHeaderModel, theme: ShellBarTheme, showMod
|
|
|
284
448
|
[brand, location, withProfile],
|
|
285
449
|
[brand, location, withEffort],
|
|
286
450
|
[brand, location, modelOnly],
|
|
451
|
+
...(model.effort ? [[brand, withEffort]] : []),
|
|
287
452
|
[brand, modelOnly],
|
|
288
453
|
[brand],
|
|
289
454
|
];
|
|
@@ -305,7 +470,7 @@ function usageWindowText(window: UsageWindow, theme: ShellBarTheme, withGauge: b
|
|
|
305
470
|
// Three degrading shapes for the same windows, narrowest last: every window
|
|
306
471
|
// with its gauge, every window as text only, or just the first window as
|
|
307
472
|
// text only. A provider with no usage data at all has no windows to shape,
|
|
308
|
-
// so all three collapse to the
|
|
473
|
+
// so all three collapse to the "usage" label and an optional shortcut hint.
|
|
309
474
|
type UsageStage = "full" | "text" | "primary";
|
|
310
475
|
function usageSegmentText(windows: UsageWindow[], theme: ShellBarTheme, stage: UsageStage, hint: string | undefined, paint?: GaugePaint): string {
|
|
311
476
|
const label = theme.fg(USAGE_LABEL_ROLE, "usage");
|
|
@@ -335,7 +500,7 @@ function fitHeaderContent(text: string, width: number): string {
|
|
|
335
500
|
return clipped + " ".repeat(Math.max(0, width - visibleWidth(clipped)));
|
|
336
501
|
}
|
|
337
502
|
|
|
338
|
-
export function renderShellHeaderBar(model: ShellHeaderModel, theme: ShellBarTheme, width: number, usageHint?: string, presentation?:
|
|
503
|
+
export function renderShellHeaderBar(model: ShellHeaderModel, theme: ShellBarTheme, width: number, usageHint?: string, presentation?: HeaderPresentation, paint?: GaugePaint): ShellHeaderResult {
|
|
339
504
|
const targetWidth = Math.max(0, Math.floor(width));
|
|
340
505
|
let content: ShellHeaderResult | undefined;
|
|
341
506
|
let contentWidth = targetWidth;
|
|
@@ -368,39 +533,67 @@ export function renderShellHeaderChrome(model: ShellHeaderModel, theme: ShellBar
|
|
|
368
533
|
return { rows: [padding, text, padding, rule], headerRow: 1, usageSpan };
|
|
369
534
|
}
|
|
370
535
|
|
|
536
|
+
/** One blank row on the chrome surface: the margin a chrome bar keeps toward the content in comfortable density. */
|
|
537
|
+
export function renderShellChromePad(theme: ShellBarTheme, width: number): string {
|
|
538
|
+
return paintChromeRow(theme, " ".repeat(Math.max(0, Math.floor(width))));
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* A chrome bar: the split status bar row (branch, permission mode, model,
|
|
543
|
+
* context, cost, usage). In comfortable density it is centered between two
|
|
544
|
+
* margin rows on the chrome surface; compact and minimal draw the bar row
|
|
545
|
+
* alone, with minimal omitting gauges and shortcut hints. The top, below-input
|
|
546
|
+
* and split bars share this design; a transparent surface leaves it unpainted.
|
|
547
|
+
*/
|
|
548
|
+
export function renderShellChromeBar(model: ShellBarModel, theme: ShellBarTheme, width: number, usageHint: string | undefined, presentation: HeaderPresentation | undefined, paint: GaugePaint | undefined, extras: { jobs?: boolean } = {}): ShellHeaderChrome {
|
|
549
|
+
const project = presentation?.headerPlacement === "top" || presentation?.headerPlacement === "below-input";
|
|
550
|
+
const bar = renderShellStatusBar(model, theme, width, usageHint, presentation, paint, { ...extras, project });
|
|
551
|
+
if (presentation !== undefined && presentation.density !== "comfortable") return bar;
|
|
552
|
+
// Comfortable centers the text: one margin row on each side of the bar row.
|
|
553
|
+
const pad = renderShellChromePad(theme, width);
|
|
554
|
+
return { ...bar, rows: [pad, ...bar.rows, pad], headerRow: bar.headerRow + 1 };
|
|
555
|
+
}
|
|
556
|
+
|
|
371
557
|
/** The usage segment is interactive only on the content row, never padding or the edge. */
|
|
372
558
|
export function shellHeaderUsageHit(chrome: ShellHeaderChrome, x: number, y: number): boolean {
|
|
373
559
|
const { usageSpan } = chrome;
|
|
374
560
|
return y === chrome.headerRow && usageSpan !== undefined && x >= usageSpan.start && x < usageSpan.end;
|
|
375
561
|
}
|
|
376
562
|
|
|
377
|
-
function headerContent(model: ShellHeaderModel, theme: ShellBarTheme, width: number, usageHint?: string, presentation?:
|
|
563
|
+
function headerContent(model: ShellHeaderModel, theme: ShellBarTheme, width: number, usageHint?: string, presentation?: HeaderPresentation, paint?: GaugePaint): ShellHeaderResult {
|
|
378
564
|
const targetWidth = Math.max(0, Math.floor(width));
|
|
379
565
|
const jobs = model.jobs ? theme.fg(ROLE.STATUS, shellJobsCount(model.jobs)) : undefined;
|
|
566
|
+
const minimal = presentation?.density === "minimal";
|
|
380
567
|
const ctxCost = joinSegments([
|
|
381
568
|
...(jobs ? [jobs] : []),
|
|
382
|
-
...(presentation?.visibility.usageCost === false ? [] : [contextSegment(model.contextPercent, theme, paint), costSegment(model.costTotal, model.subscription, theme)]),
|
|
569
|
+
...(presentation?.visibility.usageCost === false ? [] : [contextSegment(model.contextPercent, theme, paint, !minimal), costSegment(model.costTotal, model.subscription, theme)]),
|
|
383
570
|
], theme);
|
|
384
571
|
const windows = model.usage ? (selectUsageLimit(model.usage, model.modelId)?.windows ?? []) : [];
|
|
385
|
-
const
|
|
572
|
+
const belowInput = presentation?.headerPlacement === "below-input";
|
|
573
|
+
const safeModel = belowInput ? { ...model, cwd: sanitizeStatus(model.cwd), branch: model.branch === null ? null : sanitizeStatus(model.branch) } : model;
|
|
574
|
+
const location = locationSegment(safeModel, theme);
|
|
575
|
+
const leftStages = headerLeftStages(safeModel, theme, presentation?.visibility.modelDetails !== false)
|
|
576
|
+
.flatMap((stage) => belowInput && stage[1] === location
|
|
577
|
+
? [[stage[0]!, `${projectIdentity(safeModel.cwd, theme).name} ${location}`, ...stage.slice(2)], stage]
|
|
578
|
+
: [stage])
|
|
386
579
|
.map((stage) => presentation?.density === "minimal" ? stage.slice(1) : stage);
|
|
387
580
|
const minimalLeft = Math.max(0, leftStages.length - 2); // brand + bare model id, before dropping the model too
|
|
388
581
|
// One flat, ordered cascade — never a per-stage nested search — so the
|
|
389
|
-
// left group fully degrades (profile → effort → location) before usage
|
|
582
|
+
// left group fully degrades (profile → effort → location → restored effort) before usage
|
|
390
583
|
// ever gives anything up, and usage fully degrades (gauges → secondary
|
|
391
584
|
// windows → the whole segment) before ctx/cost is touched: every window
|
|
392
585
|
// with its gauge, then text-only, then the first window only, then gone.
|
|
393
586
|
// Unlike the compact bar's usage meter (hidden with no data), this is a
|
|
394
|
-
// standing, clickable affordance
|
|
395
|
-
//
|
|
396
|
-
const usageStages: Array<UsageStage | undefined> = presentation?.visibility.usageCost === false ? [undefined] : ["full", "text", "primary", undefined];
|
|
587
|
+
// standing, clickable affordance: it reads "usage" even with no data, plus
|
|
588
|
+
// the shortcut hint outside minimal density, unless disabled or too narrow.
|
|
589
|
+
const usageStages: Array<UsageStage | undefined> = presentation?.visibility.usageCost === false ? [undefined] : minimal ? ["text", "primary", undefined] : ["full", "text", "primary", undefined];
|
|
397
590
|
const attempts: Array<{ leftIndex: number; usageStage: UsageStage | undefined }> = [
|
|
398
591
|
...leftStages.slice(0, minimalLeft).map((_, leftIndex) => ({ leftIndex, usageStage: usageStages[0] })),
|
|
399
592
|
...usageStages.map((usageStage) => ({ leftIndex: minimalLeft, usageStage })),
|
|
400
593
|
{ leftIndex: leftStages.length - 1, usageStage: undefined },
|
|
401
594
|
];
|
|
402
595
|
for (const { leftIndex, usageStage } of attempts) {
|
|
403
|
-
const usageText = usageStage ? usageSegmentText(windows, theme, usageStage, usageHint, paint) : undefined;
|
|
596
|
+
const usageText = usageStage ? usageSegmentText(windows, theme, usageStage, minimal ? undefined : usageHint, paint) : undefined;
|
|
404
597
|
const right = usageText ? joinSegments([ctxCost, usageText], theme) : ctxCost;
|
|
405
598
|
const left = joinSegments(leftStages[leftIndex]!, theme);
|
|
406
599
|
if (visibleWidth(left) + (right ? RIGHT_PADDING : 0) + visibleWidth(right) > targetWidth) continue;
|
|
@@ -429,9 +622,9 @@ export function renderShellBelowInputFloat(model: ShellBarModel, theme: ShellBar
|
|
|
429
622
|
const changesRow = Boolean(changes && changes.files.length > 0) && presentation.visibility.changes !== false
|
|
430
623
|
? floatHeaderRow(theme, targetWidth, (inner) => renderChangesWidget(changes, theme, inner)[0] ?? "")
|
|
431
624
|
: undefined;
|
|
625
|
+
// Integrations live only in the rail; this row keeps the running jobs count.
|
|
432
626
|
const statuses = presentation.statusPlacement === "hidden" ? [] : [
|
|
433
627
|
...(model.jobs?.length ? [shellJobsCount(model.jobs.length)] : []),
|
|
434
|
-
...model.statuses.map(sanitizeStatus).filter(Boolean),
|
|
435
628
|
];
|
|
436
629
|
const statusRow = statuses.length
|
|
437
630
|
? floatHeaderRow(theme, targetWidth, () => joinSegments(statuses.map((status) => theme.fg(ROLE.STATUS, status)), theme))
|
|
@@ -460,9 +653,8 @@ export function renderShellBottomOnlyBar(model: ShellBarModel, theme: ShellBarTh
|
|
|
460
653
|
if (grouped) return grouped.rows;
|
|
461
654
|
const headerModel = buildShellHeaderModel(model, true);
|
|
462
655
|
// Neon, missing backgrounds and sub-minimum widths keep the old row count.
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return statuses.length ? [...rows, truncateToWidth(joinSegments(statuses, theme), Math.max(0, Math.floor(width)), "…")] : rows;
|
|
656
|
+
// Integrations live only in the rail (and the [ Panel ] sheet), never in this bar.
|
|
657
|
+
return [headerContent(headerModel, theme, width, usageHint, presentation, paint).text];
|
|
466
658
|
}
|
|
467
659
|
|
|
468
660
|
// The rule row painted directly under the header bar: one full-width horizontal
|
|
@@ -479,7 +671,8 @@ const BG_RESET = "\x1b[49m";
|
|
|
479
671
|
// Paints the header content with floatRows and returns the row without its
|
|
480
672
|
// transparent margins plus the background opener. The painted row is
|
|
481
673
|
// `<open> <content> <reset>`; the opener has no spaces, so the first space ends
|
|
482
|
-
// it. Undefined when the float style does not apply.
|
|
674
|
+
// it. Undefined when the float style does not apply. A transparent chrome
|
|
675
|
+
// surface keeps the same geometry with an empty opener and no background.
|
|
483
676
|
function floatHeaderPaint(theme: ShellBarTheme, width: number, content: (width: number) => string): { inner: string; open: string } | undefined {
|
|
484
677
|
let floated = false;
|
|
485
678
|
const [row] = floatRows(CARD_TONE.INFO, theme, width, (inner) => {
|
|
@@ -488,8 +681,12 @@ function floatHeaderPaint(theme: ShellBarTheme, width: number, content: (width:
|
|
|
488
681
|
});
|
|
489
682
|
if (!floated || row === undefined) return undefined;
|
|
490
683
|
const inner = row.slice(1, -1);
|
|
684
|
+
// Callers slice the trailing reset off `inner`, so the unpainted row keeps one.
|
|
685
|
+
if (chromeSurface() === "transparent") return { inner: `${inner.replace(BG_SGR, "")}${BG_RESET}`, open: "" };
|
|
491
686
|
return { inner, open: inner.slice(0, inner.indexOf(" ")) };
|
|
492
687
|
}
|
|
688
|
+
// Background openers (`48;…`) and resets (`49`), which a transparent surface drops.
|
|
689
|
+
const BG_SGR = /\x1b\[(?:48(?:;[0-9]+)*|49)m/g;
|
|
493
690
|
|
|
494
691
|
// In the float style the rule closes the hanging header tab with an upper
|
|
495
692
|
// one-eighth block line. Box-drawing lines sit mid-cell: a transparent `└──┘`
|
package/lib/shell-card.ts
CHANGED
|
@@ -138,8 +138,7 @@ function frame(theme: CardTheme, tone: CardTone, text: string): string {
|
|
|
138
138
|
return theme.fg(FRAME_ROLE[tone], text);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
export function cardTop(card: Card, theme: CardTheme, width: number, hint?: string): string {
|
|
142
|
-
const targetWidth = Math.max(0, Math.floor(width));
|
|
141
|
+
export function cardTop(card: Card, theme: CardTheme, width: number, hint?: string): string { const targetWidth = Math.max(0, Math.floor(width));
|
|
143
142
|
if (targetWidth === 0) return "";
|
|
144
143
|
if (targetWidth < 5) {
|
|
145
144
|
const left = theme.fg(FRAME_ROLE[card.tone], "╭");
|
|
@@ -159,6 +158,17 @@ export function cardTop(card: Card, theme: CardTheme, width: number, hint?: stri
|
|
|
159
158
|
return theme.fg(FRAME_ROLE[card.tone], chrome.topLeft) + frame(theme, card.tone, chrome.topLead) + styledTitle + frame(theme, card.tone, ` ${fill}`) + tail + frame(theme, card.tone, chrome.topRight);
|
|
160
159
|
}
|
|
161
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Whether a heading row keeps its key hint at this width. Callers that compose
|
|
163
|
+
* a subtitle from optional facts (a model, an effort) use it to shed the least
|
|
164
|
+
* important chip instead of silently losing the affordance.
|
|
165
|
+
*/
|
|
166
|
+
export function headingFits(card: Card, hint: string | undefined, width: number): boolean {
|
|
167
|
+
const targetWidth = Math.max(0, Math.floor(width));
|
|
168
|
+
const head = visibleWidth(`${card.glyph ?? CARD_GLYPH} ${card.title}`) + (card.subtitle ? visibleWidth(card.subtitle) + 3 : 0);
|
|
169
|
+
return head + 5 + (hint ? visibleWidth(hint) + 2 : 0) <= targetWidth;
|
|
170
|
+
}
|
|
171
|
+
|
|
162
172
|
export function cardLine(text: string, tone: CardTone, theme: CardTheme, width: number): string {
|
|
163
173
|
const targetWidth = Math.max(0, Math.floor(width));
|
|
164
174
|
if (targetWidth === 0) return "";
|
|
@@ -274,17 +284,27 @@ const BG_RESET = "\x1b[49m";
|
|
|
274
284
|
// Full resets (pi-tui truncation inserts one) and background resets.
|
|
275
285
|
const BG_CLEARING = /\x1b\[(?:0|49)?m/g;
|
|
276
286
|
|
|
277
|
-
|
|
287
|
+
/** The SGR that opens `role` as a background, or "" when the theme cannot paint it. */
|
|
288
|
+
export function surfaceOpener(theme: CardTheme, role: string): string {
|
|
278
289
|
if (typeof theme.bg !== "function") return "";
|
|
279
290
|
try {
|
|
280
|
-
const painted = theme.bg(
|
|
291
|
+
const painted = theme.bg(role, "");
|
|
281
292
|
return painted.endsWith(BG_RESET) ? painted.slice(0, -BG_RESET.length) : "";
|
|
282
293
|
} catch {
|
|
283
|
-
// A theme without the
|
|
294
|
+
// A theme without the role keeps the row unpainted (the outlined card).
|
|
284
295
|
return "";
|
|
285
296
|
}
|
|
286
297
|
}
|
|
287
298
|
|
|
299
|
+
/** Paints `row` behind the background `open` starts, re-armed after every reset the row carries. */
|
|
300
|
+
export function paintSurfaceRow(row: string, open: string): string {
|
|
301
|
+
return open ? `${open}${row.replace(BG_CLEARING, (reset) => reset + open)}${BG_RESET}` : row;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function panelOpener(theme: CardTheme, tone: CardTone): string {
|
|
305
|
+
return surfaceOpener(theme, FLOAT_BG_ROLE[tone]);
|
|
306
|
+
}
|
|
307
|
+
|
|
288
308
|
/**
|
|
289
309
|
* Draws one conversation card component in the active style. The outlined
|
|
290
310
|
* style returns the parts unchanged; the float style renders them one margin
|
|
@@ -322,7 +342,7 @@ function floatOpener(theme: CardTheme, tone: CardTone, width: number): string {
|
|
|
322
342
|
// Padding rows keep their tone-coloured accent just like content rows.
|
|
323
343
|
function paintFloat(rows: readonly string[], open: string): string[] {
|
|
324
344
|
const margin = " ".repeat(FLOAT_MARGIN);
|
|
325
|
-
return rows.map((row) => `${margin}${
|
|
345
|
+
return rows.map((row) => `${margin}${paintSurfaceRow(row, open)}${margin}`);
|
|
326
346
|
}
|
|
327
347
|
|
|
328
348
|
/**
|
package/lib/shell-changes.ts
CHANGED
|
@@ -209,6 +209,8 @@ export interface GitResult {
|
|
|
209
209
|
code: number;
|
|
210
210
|
/** The runner stopped reading at its output bound; stdout is partial. */
|
|
211
211
|
truncated?: boolean;
|
|
212
|
+
/** The Git deadline elapsed; stdout is diagnostic output, not a complete result. */
|
|
213
|
+
timedOut?: boolean;
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
export type GitRunner = (args: string[]) => Promise<GitResult>;
|