gentle-pi 4.7.0 → 4.9.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 +115 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +14 -13
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +476 -0
- package/assets/design-canvas/canvas-boot.js +219 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +397 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +219 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +351 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +167 -0
- package/assets/design-canvas/canvas-theme.js +69 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +773 -17
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +120 -36
- package/assets/design-canvas/inspector.js +574 -21
- package/assets/design-canvas/theme-early.js +10 -0
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +30 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +5 -9
- package/assets/orchestrator-full-delegation-card.md +11 -16
- package/assets/orchestrator-full-delegation.md +9 -9
- package/assets/orchestrator-memory.md +4 -4
- package/assets/orchestrator-prompts.md +3 -31
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +13 -17
- package/assets/orchestrator-verification.md +12 -10
- package/assets/orchestrator-writer.md +13 -13
- package/assets/orchestrator.md +20 -24
- package/bin/gentle-shell.mjs +205 -10
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/orchestration/pi.md +2 -1
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/routing/pi.md +16 -16
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/assets/features/gentle-tower.png +0 -0
- package/docs/auto-permission-answers.md +1 -1
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +23 -5
- package/docs/desktop-feed.md +303 -0
- package/docs/desktop-rpc.md +1931 -0
- package/docs/fast-mode.md +2 -2
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell-desktop.md +465 -0
- package/docs/gentle-shell.md +102 -17
- package/docs/images/desktop/chat.png +0 -0
- package/docs/images/desktop/palette.png +0 -0
- package/docs/images/desktop/todo.png +0 -0
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +113 -32
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +19 -6
- package/extensions/ask-user-choice.ts +36 -18
- package/extensions/ask-user-question.ts +48 -9
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +436 -66
- package/extensions/gentle-ai.ts +809 -158
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-feed.ts +778 -0
- package/extensions/gentle-desktop-rpc.ts +276 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-herdr-desktop-status.ts +275 -0
- package/extensions/gentle-shell.ts +174 -59
- package/extensions/gentle-stats.ts +30 -1
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/gentle-tower.ts +305 -0
- package/extensions/skill-registry.ts +260 -225
- package/herdr/RECIPE.md +157 -0
- package/herdr/keys.json +14 -0
- package/herdr/layouts/gentle-shell.json +202 -0
- package/herdr/mods/gentle-agents/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-agents/main.js +190 -0
- package/herdr/mods/gentle-agents/mod.json +1 -0
- package/herdr/mods/gentle-agents/snapshot.js +469 -0
- package/herdr/mods/gentle-agents/tokens.js +273 -0
- package/herdr/mods/gentle-chat/MINIMAL.md +69 -0
- package/herdr/mods/gentle-chat/actions.js +180 -0
- package/herdr/mods/gentle-chat/feed.js +321 -0
- package/herdr/mods/gentle-chat/icons/branch.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chat.svg +1 -0
- package/herdr/mods/gentle-chat/icons/check.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chev.svg +1 -0
- package/herdr/mods/gentle-chat/icons/clip.svg +1 -0
- package/herdr/mods/gentle-chat/icons/down.svg +1 -0
- package/herdr/mods/gentle-chat/icons/folder.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-chat/icons/mark.svg +1 -0
- package/herdr/mods/gentle-chat/icons/send.svg +1 -0
- package/herdr/mods/gentle-chat/icons/shield.svg +1 -0
- package/herdr/mods/gentle-chat/icons/stop.svg +1 -0
- package/herdr/mods/gentle-chat/icons/term.svg +1 -0
- package/herdr/mods/gentle-chat/icons/user.svg +1 -0
- package/herdr/mods/gentle-chat/icons/x.svg +1 -0
- package/herdr/mods/gentle-chat/main.js +968 -0
- package/herdr/mods/gentle-chat/mod.json +1 -0
- package/herdr/mods/gentle-chat/session.js +212 -0
- package/herdr/mods/gentle-chat/snapshot.js +469 -0
- package/herdr/mods/gentle-chat/tokens.js +137 -0
- package/herdr/mods/gentle-chat/ui.js +883 -0
- package/herdr/mods/gentle-confirm/main.js +60 -0
- package/herdr/mods/gentle-confirm/mod.json +1 -0
- package/herdr/mods/gentle-inspector/actions.js +180 -0
- package/herdr/mods/gentle-inspector/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/bot.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/check.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/db.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/diff.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/plug.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/review.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stats.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stop.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/todo.svg +1 -0
- package/herdr/mods/gentle-inspector/main.js +500 -0
- package/herdr/mods/gentle-inspector/mod.json +1 -0
- package/herdr/mods/gentle-inspector/snapshot.js +469 -0
- package/herdr/mods/gentle-inspector/tokens.js +273 -0
- package/herdr/mods/gentle-palette/actions.js +180 -0
- package/herdr/mods/gentle-palette/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-palette/icons/bot.svg +1 -0
- package/herdr/mods/gentle-palette/icons/chat.svg +1 -0
- package/herdr/mods/gentle-palette/icons/check.svg +1 -0
- package/herdr/mods/gentle-palette/icons/cmd.svg +1 -0
- package/herdr/mods/gentle-palette/icons/diff.svg +1 -0
- package/herdr/mods/gentle-palette/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-palette/icons/plus.svg +1 -0
- package/herdr/mods/gentle-palette/icons/review.svg +1 -0
- package/herdr/mods/gentle-palette/icons/search.svg +1 -0
- package/herdr/mods/gentle-palette/icons/shield.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stats.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stop.svg +1 -0
- package/herdr/mods/gentle-palette/icons/term.svg +1 -0
- package/herdr/mods/gentle-palette/icons/todo.svg +1 -0
- package/herdr/mods/gentle-palette/main.js +333 -0
- package/herdr/mods/gentle-palette/mod.json +1 -0
- package/herdr/mods/gentle-palette/snapshot.js +469 -0
- package/herdr/mods/gentle-palette/tokens.js +273 -0
- package/herdr/mods/gentle-pane/icons/chat.svg +1 -0
- package/herdr/mods/gentle-pane/icons/close.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-down.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-right.svg +1 -0
- package/herdr/mods/gentle-pane/icons/term.svg +1 -0
- package/herdr/mods/gentle-pane/icons/unzoom.svg +1 -0
- package/herdr/mods/gentle-pane/icons/zoom.svg +1 -0
- package/herdr/mods/gentle-pane/main.js +91 -0
- package/herdr/mods/gentle-pane/mod.json +1 -0
- package/herdr/mods/gentle-pane/snapshot.js +469 -0
- package/herdr/mods/gentle-pane/tokens.js +273 -0
- package/herdr/mods/gentle-sidebar/actions.js +180 -0
- package/herdr/mods/gentle-sidebar/icons/gear.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/mark.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/refresh.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/server-plus.svg +1 -0
- package/herdr/mods/gentle-sidebar/main.js +171 -0
- package/herdr/mods/gentle-sidebar/mod.json +1 -0
- package/herdr/mods/gentle-sidebar/snapshot.js +469 -0
- package/herdr/mods/gentle-sidebar/tokens.js +273 -0
- package/herdr/mods/gentle-spaces/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/monitor.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/plus.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/server.svg +1 -0
- package/herdr/mods/gentle-spaces/machines.js +31 -0
- package/herdr/mods/gentle-spaces/main.js +299 -0
- package/herdr/mods/gentle-spaces/mod.json +1 -0
- package/herdr/mods/gentle-spaces/snapshot.js +469 -0
- package/herdr/mods/gentle-spaces/tokens.js +273 -0
- package/herdr/mods/gentle-status/actions.js +180 -0
- package/herdr/mods/gentle-status/main.js +192 -0
- package/herdr/mods/gentle-status/mod.json +1 -0
- package/herdr/mods/gentle-status/snapshot.js +469 -0
- package/herdr/mods/gentle-status/tokens.js +273 -0
- package/herdr/mods/gentle-tabs/icons/close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/plus.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-max.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-min.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-restore.svg +1 -0
- package/herdr/mods/gentle-tabs/main.js +171 -0
- package/herdr/mods/gentle-tabs/mod.json +1 -0
- package/herdr/mods/gentle-tabs/snapshot.js +469 -0
- package/herdr/mods/gentle-tabs/tokens.js +273 -0
- package/herdr/mods/gentle-tokens/main.js +20 -0
- package/herdr/mods/gentle-tokens/mod.json +1 -0
- package/herdr/mods/gentle-tokens/snapshot.js +469 -0
- package/herdr/mods/gentle-tokens/tokens.js +273 -0
- package/herdr/preview.png +0 -0
- package/herdr/themes/gentle-shell-dark.json +33 -0
- package/herdr/themes/gentle-shell-light.json +34 -0
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +17 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-rpc-publisher.ts +39 -12
- package/lib/agents-runner.ts +92 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/auto-permission-answers.ts +2 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/background-jobs.ts +22 -2
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/change-diff.ts +104 -0
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/commit-slice-signal.ts +1 -1
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +38 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +315 -0
- package/lib/desktop-changes-service.ts +171 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-feed-actions.ts +804 -0
- package/lib/desktop-feed-answers.ts +129 -0
- package/lib/desktop-feed-sources.ts +184 -0
- package/lib/desktop-feed-stats.ts +98 -0
- package/lib/desktop-feed-store.ts +124 -0
- package/lib/desktop-feed.ts +788 -0
- package/lib/desktop-jobs-service.ts +290 -0
- package/lib/desktop-review-service.ts +187 -0
- package/lib/desktop-rpc-agents.ts +403 -0
- package/lib/desktop-rpc-changes.ts +223 -0
- package/lib/desktop-rpc-config-watch.ts +285 -0
- package/lib/desktop-rpc-config.ts +885 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +290 -0
- package/lib/desktop-rpc-permissions.ts +328 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-review.ts +180 -0
- package/lib/desktop-rpc-session.ts +203 -0
- package/lib/desktop-rpc-sessions.ts +250 -0
- package/lib/desktop-rpc-stats.ts +187 -0
- package/lib/desktop-rpc-updates.ts +143 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +336 -0
- package/lib/desktop-session-service.ts +223 -0
- package/lib/desktop-sessions-service.ts +249 -0
- package/lib/desktop-stats-service.ts +142 -0
- package/lib/desktop-updates-service.ts +268 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/gentle-shell-desktop.ts +1370 -0
- package/lib/gentle-shell-launcher.ts +45 -3
- package/lib/herdr-desktop-events.ts +40 -0
- package/lib/herdr-desktop-status.ts +229 -0
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/jobs-sidebar-state.ts +5 -0
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +86 -4
- package/lib/openai-fast-tier.ts +1 -0
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/session-profile-freeze.ts +13 -5
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/stats-collector.ts +56 -27
- package/lib/tower-actions.ts +100 -0
- package/lib/tower-hub.ts +73 -0
- package/lib/tower-launch.ts +111 -0
- package/lib/tower-open.ts +99 -0
- package/lib/tower-presence.ts +70 -0
- package/lib/tower-server.ts +234 -0
- package/lib/tower-snapshot.ts +298 -0
- package/lib/update-status.ts +238 -0
- package/lib/verifier-settle-reminder.ts +1 -1
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +14 -5
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +39 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/gentle-shell-desktop.mjs +1371 -0
- package/runtime/gentle-shell-launcher.mjs +44 -2
- package/runtime/native-review-cli.mjs +86 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/runtime/tower-actions.mjs +101 -0
- package/runtime/tower-hub.mjs +74 -0
- package/runtime/tower-launch.mjs +112 -0
- package/runtime/tower-open.mjs +100 -0
- package/runtime/tower-presence.mjs +71 -0
- package/runtime/tower-server.mjs +234 -0
- package/runtime/tower-snapshot.mjs +299 -0
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +5 -21
- package/scripts/build-runtime-modules.mjs +10 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +61 -20
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/provider-defect-report/SKILL.md +61 -0
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +26 -7
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-choice.test.ts +78 -21
- package/tests/ask-user-question.test.ts +61 -6
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/auto-permission-answers.test.ts +12 -1
- package/tests/background-jobs.test.ts +12 -0
- package/tests/bounded-stop-contract.test.ts +148 -27
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/change-diff.test.ts +75 -0
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/commit-slice-signal.test.ts +3 -2
- package/tests/decision-routing-contract.test.ts +390 -0
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delegated-key-learnings-contract.test.ts +21 -28
- package/tests/delivery-b-rendered-surfaces.test.ts +32 -0
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -878
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +528 -0
- package/tests/design-canvas-inspector.test.ts +1004 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +91 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +189 -0
- package/tests/design-canvas-theme.test.ts +198 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-feed-actions-guards.test.ts +595 -0
- package/tests/desktop-feed-actions.test.ts +761 -0
- package/tests/desktop-feed-live-work.test.ts +209 -0
- package/tests/desktop-feed-performance.test.ts +369 -0
- package/tests/desktop-feed-plan-profiles.test.ts +509 -0
- package/tests/desktop-feed-send-prompt.test.ts +303 -0
- package/tests/desktop-feed-tool-summaries.test.ts +69 -0
- package/tests/desktop-feed.test.ts +615 -0
- package/tests/desktop-rpc-agents.test.ts +1319 -0
- package/tests/desktop-rpc-changes.test.ts +608 -0
- package/tests/desktop-rpc-config-watch.test.ts +1159 -0
- package/tests/desktop-rpc-config.test.ts +1462 -0
- package/tests/desktop-rpc-design.test.ts +672 -0
- package/tests/desktop-rpc-jobs.test.ts +1193 -0
- package/tests/desktop-rpc-permissions.test.ts +321 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-review.test.ts +678 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-session.test.ts +642 -0
- package/tests/desktop-rpc-sessions.test.ts +647 -0
- package/tests/desktop-rpc-stats.test.ts +431 -0
- package/tests/desktop-rpc-updates.test.ts +525 -0
- package/tests/desktop-rpc-usage.test.ts +707 -0
- package/tests/desktop-rpc.test.ts +293 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +30 -41
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/fixtures/session-profile-v1/replay.ts +4 -1
- package/tests/full-delegation-closure.test.ts +48 -0
- package/tests/gentle-agents.test.ts +848 -8
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +195 -21
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-fast.test.ts +15 -0
- package/tests/gentle-herdr-desktop-status.test.ts +595 -0
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-desktop-bin.test.ts +125 -0
- package/tests/gentle-shell-desktop.test.ts +927 -0
- package/tests/gentle-shell-launcher-tower.test.ts +104 -0
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +121 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/gentle-tower.test.ts +578 -0
- package/tests/herdr-desktop-status.test.ts +285 -0
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +35 -9
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +181 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +907 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +19 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +33 -15
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-canonical-ratchet.test.ts +10 -0
- package/tests/odd-routing-contract.test.ts +99 -31
- package/tests/orchestrator-budget.test.ts +32 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +12 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +249 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +15 -14
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-routing-measured-values.test.ts +24 -0
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/primary-session-prompt.test.ts +25 -0
- package/tests/profile-fast-tier.test.ts +66 -1
- package/tests/provider-defect-handoff.test.ts +124 -99
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +2 -1
- package/tests/review-controller.test.ts +2 -1
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator.test.ts +271 -4
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +27 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/sensitive-path-tools.test.ts +138 -4
- package/tests/session-profile-extension.test.ts +312 -18
- package/tests/session-profile-freeze.test.ts +26 -0
- package/tests/session-profile-v1-compat.test.ts +20 -0
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-collision-prefixes.test.ts +1 -0
- package/tests/skill-contradictions-contract.test.ts +124 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +983 -306
- package/tests/stats-collector.test.ts +109 -2
- package/tests/support/design-canvas-dom.ts +386 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +49 -14
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/tower-actions.test.ts +247 -0
- package/tests/tower-artifacts.test.ts +114 -0
- package/tests/tower-open.test.ts +97 -0
- package/tests/tower-presence.test.ts +175 -0
- package/tests/tower-server.test.ts +122 -0
- package/tests/tower-snapshot.test.ts +236 -0
- package/tests/tower-web-echo.test.ts +125 -0
- package/tests/tower-web-hover.test.ts +251 -0
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-scoped-stop-contract.test.ts +32 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verifier-settle-reminder.test.ts +2 -2
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +88 -12
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +136 -27
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +184 -0
- package/tests/writer-rejection-next-step.test.ts +55 -0
- package/tests/writer-surface-authority-contract.test.ts +158 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -0,0 +1,883 @@
|
|
|
1
|
+
// The centre column of design/herdr-desktop/01-inspector.html (region 4: header 4a, log 4b,
|
|
2
|
+
// composer 4c), drawn from the view's state. Every number is the artboard's; FIDELITY.md maps
|
|
3
|
+
// each one to its CSS line. `v` is the GentleChat view, `p` the palette (tokens.js).
|
|
4
|
+
|
|
5
|
+
import { div, svg } from "gpui-kit";
|
|
6
|
+
import { home } from "herdr";
|
|
7
|
+
import { v_flex, h_flex, TextView, Textarea, Popover } from "gpui-base";
|
|
8
|
+
import { alpha, mono, R } from "./tokens.js";
|
|
9
|
+
import { money, prettyModel, seconds, parsePatch } from "./feed.js";
|
|
10
|
+
import { SESSION_KINDS, machineOf, liveState } from "./snapshot.js";
|
|
11
|
+
|
|
12
|
+
const MOD = "gentle-chat";
|
|
13
|
+
// A session that runs outside Herdr app (T11): what the Terminal switch and ⌘J say instead.
|
|
14
|
+
export const ELSEWHERE = "This session runs in another terminal";
|
|
15
|
+
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
16
|
+
const CLEAR = "#00000000";
|
|
17
|
+
const CLIP = 6000; // characters of a tool's output shown when expanded
|
|
18
|
+
const HUNK_ROWS = 80; // diff rows drawn per hunk
|
|
19
|
+
|
|
20
|
+
export const icon = (name, size = 15) => svg(`mods/${MOD}/icons/${name}.svg`).size(size).flex_none();
|
|
21
|
+
const clip = (s) => (s.length > CLIP ? s.slice(0, CLIP) + "\n… (truncated)" : s);
|
|
22
|
+
const firstLine = (s) => String(s ?? "").split("\n").find((l) => l.trim())?.trim() ?? "";
|
|
23
|
+
|
|
24
|
+
// One centred lane of the log: .log-in max-width 780, padding 0 28 (l.116).
|
|
25
|
+
export const lane = (el) => div().flex_none().w_full().max_w(780).px(28).self_center().child(el);
|
|
26
|
+
|
|
27
|
+
// .num (l.50): mono; tabular figures are the font's own.
|
|
28
|
+
const num = (text, color) => div().font_family(mono()).when(Boolean(color), (el) => el.text_color(color)).child(text);
|
|
29
|
+
|
|
30
|
+
// kbd (l.47): 0 5px, 1px line-strong, radius 5, muted 11px mono. An inline box is as tall as
|
|
31
|
+
// the font's content area, not the line: 13.5 + 2 × 1 = 15.5 (measured in the render).
|
|
32
|
+
const kbd = (p, text) => div().flex_none().px(5).border(1).border_color(p.lineStrong).rounded(R.kbd).text_color(p.muted)
|
|
33
|
+
.text_size(11).line_height("13.5px").font_family(mono()).child(text);
|
|
34
|
+
|
|
35
|
+
// pi titles its terminal "π - <folder>": the name without the prefix.
|
|
36
|
+
export const sessionTitle = (title) => String(title ?? "").replace(/^\s*π\s*[-–—·:]?\s*/u, "").trim();
|
|
37
|
+
|
|
38
|
+
// Rough text widths for the header's fit (12px: sans ≈ 0.56 em per character, mono 0.5).
|
|
39
|
+
const textW = (s, size = 12, monoFont = false) => String(s ?? "").length * size * (monoFont ? 0.5 : 0.56);
|
|
40
|
+
|
|
41
|
+
// .state (l.79-88): a 7px dot (a ring for idle, dashed for queue) and a label, never colour alone.
|
|
42
|
+
// The ring is ::before, which `* { box-sizing: border-box }` does not reach: 5px + 2 × 1.5px = 8px.
|
|
43
|
+
export function stateLabel(p, kind, label) {
|
|
44
|
+
const color = { work: p.info, need: p.warn, done: p.ok, idle: p.muted, fail: p.err, queue: p.muted }[kind] ?? p.muted;
|
|
45
|
+
let dot = div().flex_none().rounded_full();
|
|
46
|
+
if (kind === "idle" || kind === "queue") {
|
|
47
|
+
dot = dot.w(8).h(8).border(1.5).border_color(color);
|
|
48
|
+
if (kind === "queue") dot = dot.border_dashed();
|
|
49
|
+
} else dot = dot.w(7).h(7).bg(color);
|
|
50
|
+
// No pulse on a working dot (S13, herdr/PERF.md): a native loop redraws the whole window every
|
|
51
|
+
// frame for as long as it is drawn (≈40 % CPU while a session works). The word says it.
|
|
52
|
+
return h_flex().gap(6).items_center().text_size(12).whitespace_nowrap().text_color(color).child(dot).child(label);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// .btn (l.92-95): 5px 10px, radius 8, 1px #ffffff17, muted 12px; hover accent border.
|
|
56
|
+
function btn(p, id, label, { danger = false, tip = null, onClick = null, iconName = null } = {}) {
|
|
57
|
+
return h_flex().id(id).flex_none().items_center().gap(6).px(10).py(5).rounded(R.sm).border(1).border_color(p.btnLine)
|
|
58
|
+
.text_size(12).text_color(p.muted).whitespace_nowrap().cursor_pointer()
|
|
59
|
+
.hover((s) => (danger ? s.border_color(p.err).text_color(p.err) : s.border_color(p.accent).text_color(p.accentSoft)))
|
|
60
|
+
.when(Boolean(tip), (el) => el.tooltip(tip))
|
|
61
|
+
.when(Boolean(onClick), (el) => el.on_click(onClick))
|
|
62
|
+
.when(Boolean(iconName), (el) => el.child(icon(iconName, 13)))
|
|
63
|
+
.child(label);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const chev = (open) => icon(open ? "down" : "chev", 13);
|
|
67
|
+
|
|
68
|
+
// A tool's path as the artboard writes it: relative to the session's project or one of its
|
|
69
|
+
// worktrees ("herdr/mods/gentle-chat/main.js"), else from the home folder ("~/…").
|
|
70
|
+
function shortPath(v, path) {
|
|
71
|
+
const s = v.snap;
|
|
72
|
+
const roots = [s?.project?.cwd, ...(s?.changes?.worktrees ?? []).map((w) => w?.root), v.feed.cwd, v.cwd]
|
|
73
|
+
.filter((r) => typeof r === "string" && r.length > 1).map((r) => r.replace(/\/+$/, "")).sort((a, b) => b.length - a.length);
|
|
74
|
+
const root = roots.find((r) => path.startsWith(r + "/"));
|
|
75
|
+
if (root) return path.slice(root.length + 1);
|
|
76
|
+
let h = "";
|
|
77
|
+
try { h = home(); } catch { h = ""; }
|
|
78
|
+
return h && path.startsWith(h + "/") ? "~" + path.slice(h.length) : path;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The summary beside a tool's name, with its path shortened.
|
|
82
|
+
function toolSay(v, call) {
|
|
83
|
+
const path = [call.args?.path, call.args?.file_path].find((x) => typeof x === "string" && x);
|
|
84
|
+
return path && call.summary.startsWith(path) ? shortPath(v, path) + call.summary.slice(path.length) : call.summary;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ---------------------------------------------------------------- 4a header (l.259-270, 369-399)
|
|
88
|
+
|
|
89
|
+
export function header(v, p) {
|
|
90
|
+
const s = v.snap;
|
|
91
|
+
const f = v.feed;
|
|
92
|
+
const { stack } = v.stackProps();
|
|
93
|
+
const title = s?.identity?.sessionName || f.name || sessionTitle(v.agentInfo?.title) || "Gentle Shell";
|
|
94
|
+
// The session's kind badge follows its name (S10): Herdr or TUI, as in the sidebar and tabs.
|
|
95
|
+
// S15: then its live state while it is not idle, the sidebar's words ("Working · 2 agents",
|
|
96
|
+
// "Waiting on 2 agents", "Needs you"); an idle session keeps the artboard's quiet header. A
|
|
97
|
+
// narrow card (< 640px) leaves it to the sidebar and the status bar: the name keeps the room.
|
|
98
|
+
const live = s ? liveState(s) : null;
|
|
99
|
+
const herdrWorking = v.agentInfo?.status === "working";
|
|
100
|
+
const roomy = (v.headW ?? Infinity) >= 640;
|
|
101
|
+
const shownLive = !roomy ? null : live && live.status !== "idle" ? live : herdrWorking ? { status: "working", label: "Working" } : null;
|
|
102
|
+
const row1 = h_flex().min_h(30).items_center().justify_between().gap(16).min_w(0).overflow_hidden()
|
|
103
|
+
.child(h_flex().flex_1().min_w(v.elsewhere() ? 150 : 0).gap(8).items_center()
|
|
104
|
+
.child(div().id("title").min_w(0).truncate().text_size(14).font_semibold()
|
|
105
|
+
.tooltip(v.address ? `${v.address}${v.file ? ` · ${v.file}` : ""}` : v.file ? `${ELSEWHERE} · ${v.file}` : "No Gentle Shell session")
|
|
106
|
+
.child(title))
|
|
107
|
+
.when(Boolean(v.key), (el) => el.child(machineOf(v.address)
|
|
108
|
+
? kindBadge(p, SESSION_KINDS.remote, machineOf(v.address))
|
|
109
|
+
: kindBadge(p, v.elsewhere() ? SESSION_KINDS.tui : SESSION_KINDS.herdr)))
|
|
110
|
+
.when(Boolean(shownLive), (el) => el.child(div().id("chat-state").flex_none()
|
|
111
|
+
.child(stateLabel(p, shownLive.status === "blocked" ? "need" : "work", shownLive.label)))))
|
|
112
|
+
.when(Boolean(stack), (el) => el.child(v.elsewhere() ? elsewhere(v, p) : viewSwitch(v, p)));
|
|
113
|
+
// No clip here: the Model and permission menus open from this row.
|
|
114
|
+
const row2 = h_flex().items_center().justify_between().gap(16).min_w(0)
|
|
115
|
+
.child(crumbs(v, p))
|
|
116
|
+
.child(facts(v, p));
|
|
117
|
+
return v_flex().id("chat-head").flex_none().gap(4).px(14).pt(8).pb(7).border_b(1).border_color(p.line).bg(p.chrome)
|
|
118
|
+
.rounded_t(R.window - 1)
|
|
119
|
+
.on_size_change((size, cx) => { if (Math.abs((v.headW ?? 0) - size.width) >= 1) { v.headW = size.width; cx.notify(); } })
|
|
120
|
+
.on_mouse_down("left", () => v.focus.focus())
|
|
121
|
+
.child(row1).child(row2);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// .seg (l.96-99): Chat | Terminal, run("layout.select") on the layout stack.
|
|
125
|
+
function viewSwitch(v, p) {
|
|
126
|
+
const showing = v.showing();
|
|
127
|
+
const seg = (id, iconName, label, active, onClick) => h_flex().id(id).items_center().gap(6).px(9).py(2).rounded(R.inner)
|
|
128
|
+
.border(1).border_color(active ? p.lineStrong : CLEAR).when(active, (el) => el.bg(p.selected))
|
|
129
|
+
.text_size(12).text_color(active ? p.text : p.muted).cursor_pointer().hover((st) => st.text_color(p.text))
|
|
130
|
+
.on_click(onClick).child(icon(iconName, 13)).child(label);
|
|
131
|
+
return h_flex().flex_none().p(2).gap(2).border(1).border_color(p.lineStrong).rounded(R.sm)
|
|
132
|
+
.child(seg("sw-chat", "chat", "Chat", showing, (_e, cx) => v.go("chat", cx)))
|
|
133
|
+
.child(seg("sw-term", "term", "Terminal", !showing, (_e, cx) => v.go("terminal", cx)));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// A session's own spend as its TUI footer writes it (lib/shell-bar.ts formatCost): $33.46 from a
|
|
137
|
+
// dollar up, $0.247 below (S10). The per-message costs in the log keep feed.js money().
|
|
138
|
+
const sessionCost = (n) => { const v = Number(n); return Number.isFinite(v) ? `$${v >= 1 ? v.toFixed(2) : v.toFixed(3)}` : "$0.000"; };
|
|
139
|
+
|
|
140
|
+
// A session's kind (snapshot.js SESSION_KINDS) as the shared badge (tokens.js kindBadge of the other
|
|
141
|
+
// mods): its icon and word in the kbd's mono look; Herdr in the info tone, TUI in accent-soft, a
|
|
142
|
+
// remote session (S14) in the warn tone with its machine's name.
|
|
143
|
+
export function kindBadge(p, kind, machine) {
|
|
144
|
+
const remote = kind.kind === "remote";
|
|
145
|
+
return h_flex().id("kind").flex_none().h(17).px(5).gap(4).items_center().rounded(R.kbd).border(1).border_color(p.lineStrong)
|
|
146
|
+
.font_family(mono()).font_semibold().text_size(10.5).line_height(1.25).text_color(kind.kind === "herdr" ? p.info : remote ? p.warn : p.accentSoft)
|
|
147
|
+
.when(remote, (el) => el.max_w(120).overflow_hidden())
|
|
148
|
+
.tooltip(remote && machine ? `${kind.about} (${machine})` : kind.about)
|
|
149
|
+
.child(icon(kind.icon, 11).flex_none())
|
|
150
|
+
.child(remote && machine ? div().min_w(0).truncate().child(machine) : kind.label);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// T11 (S10): a session that runs outside Herdr app has no Terminal here. The switch's place says
|
|
154
|
+
// where it runs (its Herdr TUI pane, else its pid), in the switch's muted look.
|
|
155
|
+
function elsewhere(v, p) {
|
|
156
|
+
const id = v.snap?.identity;
|
|
157
|
+
const where = id?.herdr?.paneId ? `Herdr ${id.herdr.paneId}` : id?.pid ? `pid ${id.pid}` : null;
|
|
158
|
+
// It gives way to the session's name: the words truncate, the icon stays.
|
|
159
|
+
return h_flex().id("sw-elsewhere").min_w(0).flex_shrink_1().items_center().gap(6).px(9).py(4).border(1).border_color(p.line).rounded(R.sm)
|
|
160
|
+
.text_size(12).text_color(p.muted)
|
|
161
|
+
.tooltip(`${ELSEWHERE}${where ? ` (${where})` : ""}: answer its prompts and run /commands there. Messages, answers, Stop and modes work from here.`)
|
|
162
|
+
// A narrow header says it in two words (the tooltip keeps the whole sentence).
|
|
163
|
+
.child(icon("term", 13).flex_none()).child(div().min_w(0).truncate().child((v.headW ?? Infinity) < 760 ? "Other terminal" : ELSEWHERE));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// .crumbs (l.263-264): project / branch · N changed. The project is the Herdr space the session
|
|
167
|
+
// runs in ("gentle-pi"), else its folder's name.
|
|
168
|
+
function crumbs(v, p) {
|
|
169
|
+
const pr = v.snap?.project;
|
|
170
|
+
const cwd = pr?.cwd ?? v.feed.cwd ?? v.cwd;
|
|
171
|
+
const project = v.agentInfo?.space_name || (cwd ? cwd.replace(/[/\\]+$/, "").split(/[/\\]/).pop() || cwd : null);
|
|
172
|
+
const sep = (t) => div().flex_none().text_color(p.faint).child(t);
|
|
173
|
+
// The names give way (truncate with an ellipsis); icons, separators and the count keep their
|
|
174
|
+
// width. The branch gives way first (shrink 3 to the project's 1); a narrow header (< 560px)
|
|
175
|
+
// keeps only the project, so a name never shrinks to nothing between its icons.
|
|
176
|
+
const give = (el, n = 1) => el.flex_shrink(n).min_w(0).truncate();
|
|
177
|
+
const wide = (v.headW ?? Infinity) >= 560;
|
|
178
|
+
const projectEl = div().child(project ?? "No project");
|
|
179
|
+
const parts = [icon("folder", 13), give(projectEl)];
|
|
180
|
+
if (pr?.branch && wide) parts.push(sep("/"), icon("branch", 13), give(div().child(pr.branch), 3));
|
|
181
|
+
if (Number.isInteger(pr?.dirty) && wide) parts.push(sep("·"), div().flex_none().child(pr.dirty === 0 ? "clean" : `${pr.dirty} changed`));
|
|
182
|
+
return h_flex().mt(1).min_w(0).overflow_hidden().items_center().gap(6).text_size(12).text_color(p.muted).whitespace_nowrap()
|
|
183
|
+
.children(parts);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const PERM = [
|
|
187
|
+
{ mode: "normal", label: "Normal", about: "Standard permission prompts", tone: null },
|
|
188
|
+
{ mode: "auto", label: "Auto", about: "Independent checks; extra model calls", tone: null },
|
|
189
|
+
{ mode: "yolo", label: "YOLO", about: "Scoped work; destructive actions ask", tone: "warn" },
|
|
190
|
+
{ mode: "super-yolo", label: "Super-YOLO", about: "No permission prompts; private paths blocked; consent remains", tone: "err" },
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
// .facts-row (l.265-270): Model, Persona, Ctx, Cost, permission menu. Empty fields say so.
|
|
194
|
+
function facts(v, p) {
|
|
195
|
+
const s = v.snap;
|
|
196
|
+
const f = v.feed;
|
|
197
|
+
const fact = (id, kids, tip) => h_flex().id(id).items_center().gap(6).px(4).py(3).rounded(R.inner).whitespace_nowrap()
|
|
198
|
+
.text_color(p.text).when(Boolean(tip), (el) => el.tooltip(tip)).children(kids);
|
|
199
|
+
const k = (t) => div().text_color(p.muted).child(t);
|
|
200
|
+
const none = (t = "—") => div().text_color(p.muted).child(t);
|
|
201
|
+
|
|
202
|
+
const model = [prettyModel(s?.model?.id ?? f.model), s?.model?.effort ?? (s ? null : f.thinking), s?.model?.profile?.name]
|
|
203
|
+
.filter(Boolean).join(" · ");
|
|
204
|
+
// Model opens the profiles menu (S12: list, active, per-agent models, Apply); Persona opens the
|
|
205
|
+
// TUI's own screen (/gentle:persona) in the Terminal.
|
|
206
|
+
// A narrow card keeps a compact "Model ▾" so the profiles menu stays one click away.
|
|
207
|
+
const modelFact = (compact) => profileMenu(v, p, fact("f-model", [k("Model"), ...(compact ? [] : [model ? div().child(model) : none()]), icon("down", 13).text_color(p.muted)],
|
|
208
|
+
compact ? `Model · ${model || "—"} (switch profile)` : "Model · effort · profile (switch profile)").cursor_pointer().hover((st) => st.bg(p.selected))
|
|
209
|
+
.when(v.busy === "profile", (el) => el.opacity(0.6)));
|
|
210
|
+
const persona = typeof s?.persona === "string" ? s.persona : s?.persona?.name ?? null;
|
|
211
|
+
const personaFact = fact("f-persona", [icon("user", 13).text_color(p.muted), persona ? div().child(persona) : none("No persona")],
|
|
212
|
+
"Persona (opens /gentle:persona in the Terminal)").cursor_pointer().hover((st) => st.bg(p.selected))
|
|
213
|
+
.on_click((_e, cx) => v.command("persona", "/gentle:persona", cx));
|
|
214
|
+
|
|
215
|
+
const ctx = s?.context;
|
|
216
|
+
const pct = Number.isFinite(ctx?.percent) ? Math.max(0, Math.min(100, Math.round(ctx.percent))) : null;
|
|
217
|
+
const kTok = (n) => (n >= 1000 ? `${Math.round(n / 1000)}k` : String(n));
|
|
218
|
+
const ctxTip = Number.isFinite(ctx?.tokens) && Number.isFinite(ctx?.window) ? `Context window · ${kTok(ctx.tokens)} / ${kTok(ctx.window)}` : "Context window";
|
|
219
|
+
const ctxFact = fact("f-ctx", [k("Ctx"), bar(p, pct, p.info, 46), pct === null ? none() : num(`${pct}%`)], ctxTip);
|
|
220
|
+
|
|
221
|
+
const total = Number.isFinite(s?.cost?.total) ? s.cost.total : f.total;
|
|
222
|
+
// The TUI footer's own words: "$32.57 sub" on a subscription (S10).
|
|
223
|
+
const sub = Boolean(s?.cost?.subscription);
|
|
224
|
+
const costFact = fact("f-cost", [k("Cost"), num(sessionCost(total)), ...(sub ? [k("sub")] : [])], sub ? "Session spend (subscription)" : "Session spend");
|
|
225
|
+
|
|
226
|
+
// Narrow cards drop facts instead of clipping (the artboard has room for all): Persona first,
|
|
227
|
+
// then Ctx, then Model, then Cost; the permission menu always stays. Widths are estimates
|
|
228
|
+
// (padding 4 + 4, gap 6, gap 14 between facts); the crumbs keep 180px.
|
|
229
|
+
const permLabel = PERM.find((m) => m.mode === s?.permission?.mode)?.label ?? (s?.permission?.mode || "—");
|
|
230
|
+
const est = {
|
|
231
|
+
persona: 14 + 13 + 6 + textW(persona ?? "No persona"),
|
|
232
|
+
ctx: 14 + 8 + textW("Ctx") + 6 + 46 + 6 + textW(pct === null ? "—" : `${pct}%`, 12, true),
|
|
233
|
+
model: 14 + 8 + textW("Model") + 6 + textW(model || "—") + 6 + 13,
|
|
234
|
+
cost: 14 + 8 + textW("Cost") + 6 + textW(sessionCost(total), 12, true) + (sub ? 6 + textW("sub") : 0),
|
|
235
|
+
};
|
|
236
|
+
const room = Number.isFinite(v.headW) ? v.headW - 28 - 16 - 180 : Infinity;
|
|
237
|
+
let need = 20 + 13 + 6 + textW(permLabel) + 6 + 13 + Object.values(est).reduce((a, b) => a + b, 0);
|
|
238
|
+
const drop = new Set();
|
|
239
|
+
const compactModel = 14 + 8 + textW("Model") + 6 + 13;
|
|
240
|
+
for (const k of ["persona", "ctx", "model", "cost"]) if (need > room) { drop.add(k); need -= est[k] - (k === "model" ? compactModel : 0); }
|
|
241
|
+
return h_flex().flex_none().items_center().gap(14).text_size(12)
|
|
242
|
+
.child(modelFact(drop.has("model")))
|
|
243
|
+
.when(!drop.has("persona"), (el) => el.child(personaFact))
|
|
244
|
+
.when(!drop.has("ctx"), (el) => el.child(ctxFact))
|
|
245
|
+
.when(!drop.has("cost"), (el) => el.child(costFact))
|
|
246
|
+
.child(permission(v, p));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// .bar (l.89-91): 4px, pill, raised groove.
|
|
250
|
+
export function bar(p, pct, color, width) {
|
|
251
|
+
return div().flex_none().w(width).h(4).rounded_full().bg(p.raised).overflow_hidden()
|
|
252
|
+
.when(pct !== null && pct > 0, (el) => el.child(div().h_full().w(`${pct}%`).rounded_full().bg(color)));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// .perm + .perm-menu (l.102-112): the four live modes. Choosing one asks the session's permission
|
|
256
|
+
// owner (the one /gentle:mode uses); Super-YOLO asks first.
|
|
257
|
+
function permission(v, p) {
|
|
258
|
+
const perm = v.snap?.permission;
|
|
259
|
+
const cur = PERM.find((m) => m.mode === perm?.mode);
|
|
260
|
+
const yolo = Boolean(perm?.yolo);
|
|
261
|
+
const pill = h_flex().id("perm").items_center().gap(6).px(9).py(3).rounded_full().border(1).text_size(12).whitespace_nowrap()
|
|
262
|
+
.cursor_pointer()
|
|
263
|
+
.when(v.busy === "perm", (el) => el.opacity(0.6))
|
|
264
|
+
.border_color(yolo ? alpha(p.warn, 0x99 / 255) : p.lineStrong)
|
|
265
|
+
.when(yolo, (el) => el.bg(alpha(p.warn, 0x14 / 255)))
|
|
266
|
+
.text_color(yolo ? p.warn : cur ? p.text : p.muted)
|
|
267
|
+
.tooltip(perm?.detail ? `Permission mode: ${cur?.label ?? perm.mode} · ${perm.detail}` : `Permission mode: ${cur?.label ?? "unknown"}`)
|
|
268
|
+
.child(icon("shield", 13)).child(cur?.label ?? (perm?.mode || "—")).child(icon("down", 13));
|
|
269
|
+
const item = (m) => {
|
|
270
|
+
const on = m === cur;
|
|
271
|
+
const color = m.tone === "warn" ? p.warn : m.tone === "err" ? p.err : p.text;
|
|
272
|
+
return h_flex().id(`perm-${m.mode}`).w_full().items_start().gap(8).px(8).py(7).rounded(R.inner).cursor_pointer()
|
|
273
|
+
.hover((st) => st.bg(p.selected)).tooltip(on ? `${m.label} is this session's mode` : `Switch this session to ${m.label}`)
|
|
274
|
+
.on_click((_e, cx) => v.setMode(m.mode, cx))
|
|
275
|
+
.child(div().w(18).h(18).flex_none().items_center().justify_center().flex()
|
|
276
|
+
.when(on, (el) => el.child(icon("check", 13).text_color(p.accent))))
|
|
277
|
+
.child(v_flex().flex_1().min_w(0).gap(2)
|
|
278
|
+
.child(div().font_semibold().text_size(13).text_color(color).child(m.label))
|
|
279
|
+
.child(div().text_size(12).text_color(p.muted).child(m.about)));
|
|
280
|
+
};
|
|
281
|
+
const menu = v_flex().mt(6).w(330).p(6).bg(p.raised).border(1).border_color(p.lineStrong).rounded(R.md).shadow_lg()
|
|
282
|
+
.text_color(p.text).children(PERM.map(item));
|
|
283
|
+
// The menu's top-right corner on the pill: below it, right-aligned, 6px down (l.107).
|
|
284
|
+
return Popover.new("perm-menu").anchor("top_right").open(Boolean(v.permOpen))
|
|
285
|
+
.on_open_change((open, cx) => { v.permOpen = open; cx.notify(); })
|
|
286
|
+
.trigger(pill).content(menu);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// The profiles menu (S12), in the permission menu's look (.perm-menu l.102-112): the saved
|
|
290
|
+
// profiles (/gentle:profiles' store) with the session's one checked, the per-agent models of the
|
|
291
|
+
// hovered (or selected) profile, Apply ("Use in this session", through the session's own
|
|
292
|
+
// /gentle:profiles apply), and "Manage in Terminal" (the TUI screen, Herdr sessions only).
|
|
293
|
+
const PROFILE_ROWS = 12; // agent rows shown before "+N more"
|
|
294
|
+
function profileMenu(v, p, trigger) {
|
|
295
|
+
const list = v.snap?.profiles ?? null;
|
|
296
|
+
const active = list?.active ?? null;
|
|
297
|
+
// The session's profile first, then the store's order.
|
|
298
|
+
const items = (Array.isArray(list?.items) ? list.items : []).slice().sort((a, b) => (b.name === active) - (a.name === active));
|
|
299
|
+
const shown = items.find((i) => i.name === v.profAt) ?? items.find((i) => i.name === active) ?? items[0] ?? null;
|
|
300
|
+
const tag = (text, color) => div().flex_none().px(5).rounded(R.kbd).border(1).border_color(p.lineStrong)
|
|
301
|
+
.font_family(mono()).text_size(10.5).line_height("14px").text_color(color ?? p.muted).child(text);
|
|
302
|
+
const about = (i) => [`${i.roles.length}${i.truncated ? "+" : ""} ${i.roles.length === 1 ? "role" : "roles"}`, i.tier, i.mode && i.mode !== "organic" ? i.mode : null]
|
|
303
|
+
.filter(Boolean).join(" · ");
|
|
304
|
+
const item = (i) => {
|
|
305
|
+
const on = i.name === active;
|
|
306
|
+
const picked = i.name === shown?.name;
|
|
307
|
+
return h_flex().id(`prof-${i.name}`).w_full().items_start().gap(8).px(8).py(7).rounded(R.inner).cursor_pointer()
|
|
308
|
+
.when(picked, (el) => el.bg(p.selected)).hover((st) => st.bg(p.selected))
|
|
309
|
+
.tooltip(on ? `${i.name} is this session's profile` : `Show ${i.name}; Apply uses it in this session`)
|
|
310
|
+
.on_mouse_move((_e, cx) => { if (v.profAt !== i.name) { v.profAt = i.name; cx.notify(); } })
|
|
311
|
+
.on_click((_e, cx) => { v.profAt = i.name; cx.notify(); })
|
|
312
|
+
.child(div().w(18).h(18).flex_none().items_center().justify_center().flex()
|
|
313
|
+
.when(on, (el) => el.child(icon("check", 13).text_color(p.accent))))
|
|
314
|
+
.child(v_flex().flex_1().min_w(0).gap(2)
|
|
315
|
+
.child(h_flex().gap(6).items_center()
|
|
316
|
+
.child(div().font_semibold().text_size(13).text_color(p.text).truncate().child(i.name))
|
|
317
|
+
.when(list?.default === i.name, (el) => el.child(tag("default"))))
|
|
318
|
+
.child(div().text_size(12).text_color(p.muted).child(about(i))));
|
|
319
|
+
};
|
|
320
|
+
const route = (agent, r, key) => h_flex().id(key).w_full().gap(8).items_baseline().px(8).py(2).text_size(12)
|
|
321
|
+
.tooltip(`${agent}: ${r.model}${r.thinking && r.thinking !== "inherit" ? ` · ${r.thinking}` : ""}`)
|
|
322
|
+
.child(div().w(132).flex_none().truncate().font_family(mono()).text_size(11.5).text_color(p.muted).child(agent))
|
|
323
|
+
.child(div().flex_1().min_w(0).truncate().text_color(p.text).child(prettyModel(r.model) || r.model))
|
|
324
|
+
.when(Boolean(r.thinking) && r.thinking !== "inherit", (el) => el.child(div().flex_none().text_color(p.muted).child(r.thinking)));
|
|
325
|
+
const detail = shown ? v_flex().w_full().gap(1).pt(6).mt(2).border_t(1).border_color(p.line)
|
|
326
|
+
.when(Boolean(shown.orchestrator), (el) => el.child(route("orchestrator", shown.orchestrator, "prof-orch")))
|
|
327
|
+
.children(shown.roles.slice(0, PROFILE_ROWS).map((r) => route(r.agent, r, `prof-role-${r.agent}`)))
|
|
328
|
+
.when(shown.roles.length > PROFILE_ROWS || shown.truncated, (el) => el.child(div().px(8).py(2).text_size(11.5).text_color(p.faint)
|
|
329
|
+
.child(`+${Math.max(0, shown.roles.length - PROFILE_ROWS)} more in /gentle:profiles`)))
|
|
330
|
+
.when(!shown.roles.length && !shown.orchestrator, (el) => el.child(div().px(8).py(2).text_size(12).text_color(p.muted)
|
|
331
|
+
.child("No routing entries: every agent inherits its default model."))) : null;
|
|
332
|
+
const canApply = Boolean(shown) && shown.name !== active && !v.busy;
|
|
333
|
+
const apply = h_flex().id("prof-apply").flex_none().items_center().px(10).py(5).rounded(R.sm).text_size(12).font_semibold()
|
|
334
|
+
.when(canApply, (el) => el.bg(p.accent).text_color(p.onAccent).cursor_pointer().hover((st) => st.opacity(0.88))
|
|
335
|
+
.on_click((_e, cx) => v.applyProfile(shown.name, cx)))
|
|
336
|
+
.when(!canApply, (el) => el.border(1).border_color(p.btnLine).text_color(p.faint))
|
|
337
|
+
.tooltip(shown && shown.name === active ? `${shown.name} is already this session's profile` : "Use this profile in this session (as /gentle:profiles does)")
|
|
338
|
+
.child(shown && shown.name === active ? "In use" : "Apply");
|
|
339
|
+
const manage = !v.elsewhere()
|
|
340
|
+
? div().id("prof-manage").text_size(12).text_color(p.muted).cursor_pointer().hover((st) => st.text_color(p.accentSoft))
|
|
341
|
+
.tooltip("Opens /gentle:profiles in the Terminal").on_click((_e, cx) => { v.profOpen = false; v.command("model", "/gentle:profiles", cx); })
|
|
342
|
+
.child("Manage in Terminal")
|
|
343
|
+
: div().text_size(12).text_color(p.faint).child("Manage in that session's terminal");
|
|
344
|
+
const empty = !list
|
|
345
|
+
? "This session publishes no profiles. Update Gentle Shell and restart it."
|
|
346
|
+
: "No saved profiles. Create them with /gentle:profiles.";
|
|
347
|
+
const menu = v_flex().mt(6).w(420).p(6).bg(p.raised).border(1).border_color(p.lineStrong).rounded(R.md).shadow_lg()
|
|
348
|
+
.text_color(p.text)
|
|
349
|
+
.child(h_flex().px(8).pt(2).pb(6).items_center().justify_between()
|
|
350
|
+
.child(div().font_family(mono()).font_weight(600).text_size(11).text_color(p.muted).child("PROFILES"))
|
|
351
|
+
.when(Boolean(active), (el) => el.child(div().text_size(12).text_color(p.muted).child(`Session: ${active}`))))
|
|
352
|
+
.when(!items.length, (el) => el.child(div().px(8).py(7).text_size(12.5).text_color(p.muted).child(empty)))
|
|
353
|
+
.child(v_flex().id("prof-list").w_full().max_h(260).overflow_y_scrollbar().children(items.map(item)))
|
|
354
|
+
.when(Boolean(detail), (el) => el.child(detail))
|
|
355
|
+
.child(h_flex().px(8).pt(8).pb(2).items_center().justify_between().child(manage).when(Boolean(shown), (el) => el.child(apply)));
|
|
356
|
+
// The menu's top-left corner under the Model fact, 6px down (the permission menu's offset).
|
|
357
|
+
return Popover.new("prof-menu").anchor("top_left").open(Boolean(v.profOpen))
|
|
358
|
+
.on_open_change((open, cx) => { v.profOpen = open; if (open) v.profAt = null; cx.notify(); })
|
|
359
|
+
.trigger(trigger).content(menu);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// ---------------------------------------------------------------- 4b log (l.115-172)
|
|
363
|
+
|
|
364
|
+
// Consecutive assistant messages are one reply (.msg-ai, gap 10); everything else stands alone.
|
|
365
|
+
export function entries(items) {
|
|
366
|
+
const out = [];
|
|
367
|
+
for (const it of items) {
|
|
368
|
+
const last = out[out.length - 1];
|
|
369
|
+
if (it.kind === "assistant" && last?.kind === "turn") last.items.push(it);
|
|
370
|
+
else if (it.kind === "assistant") out.push({ kind: "turn", id: it.id, items: [it] });
|
|
371
|
+
else out.push(it);
|
|
372
|
+
}
|
|
373
|
+
return out;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export function entry(v, p, e, live) {
|
|
377
|
+
if (e.kind === "user") return userMessage(p, e);
|
|
378
|
+
if (e.kind === "note") return noteCard(v, p, e);
|
|
379
|
+
if (e.kind === "skill") {
|
|
380
|
+
return card(v, p, `skill-${e.id}`, false, [glyph(p, "✦", p.accent), name("skill"), arg(p, e.name)],
|
|
381
|
+
() => markdownBody(p, `sk-${e.id}`, e.text));
|
|
382
|
+
}
|
|
383
|
+
if (e.kind === "compaction") {
|
|
384
|
+
const said = Number.isFinite(e.tokens) ? `Compacted from ${grouped(e.tokens)} tokens` : "Compacted";
|
|
385
|
+
return card(v, p, `cmp-${e.id}`, false, [glyph(p, "⊟", p.muted), name("compaction"), arg(p, said)],
|
|
386
|
+
() => markdownBody(p, `cm-${e.id}`, e.summary));
|
|
387
|
+
}
|
|
388
|
+
if (e.kind === "branch") {
|
|
389
|
+
return card(v, p, `br-${e.id}`, false, [glyph(p, "⑂", p.muted), name("branch"), arg(p, firstLine(e.summary))],
|
|
390
|
+
() => markdownBody(p, `bs-${e.id}`, e.summary));
|
|
391
|
+
}
|
|
392
|
+
return turn(v, p, e, live);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// ---- The minimal view (T12, S11; MINIMAL.md): every non-text item is one row in the .tool look
|
|
396
|
+
// (l.135-140: 1px line, surface, radius 8; summary 7px 10px, gap 8, 12.5px; status, semibold
|
|
397
|
+
// name, mono 12px muted argument, a muted note, the chevron). A click on the row opens it and
|
|
398
|
+
// closes it again; ⌘O (gentle-chat.expand) opens or closes every row. The body is built only
|
|
399
|
+
// while it is open.
|
|
400
|
+
|
|
401
|
+
function card(v, p, id, def, kids, body, note = null) {
|
|
402
|
+
const open = v.isOpen(id, def);
|
|
403
|
+
return v_flex().w_full().min_w(0).overflow_hidden().border(1).border_color(p.line).bg(p.surface).rounded(R.sm)
|
|
404
|
+
.child(summaryRow(v, p, id, [...kids, note, chev(open)], def))
|
|
405
|
+
.when(open, (el) => el.child(body()));
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const glyph = (p, text, color) => div().flex_none().w(13).text_center().text_color(color).child(text);
|
|
409
|
+
const name = (text) => div().flex_none().font_semibold().child(text);
|
|
410
|
+
// One line for a row: tabs, line breaks and runs of spaces become one space, so a summary never
|
|
411
|
+
// carries a break or a tab stop past the truncation (a bash argument with "\t" did).
|
|
412
|
+
const oneLine = (s) => String(s ?? "").replace(/\s+/g, " ").trim();
|
|
413
|
+
const arg = (p, text) => div().flex_1().min_w(0).truncate().font_family(mono()).text_size(12).text_color(p.muted).child(oneLine(text));
|
|
414
|
+
const grouped = (n) => String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
415
|
+
|
|
416
|
+
// .tool-body (l.141) holding markdown: 1px rule, 8px 10px 10px, 13px.
|
|
417
|
+
const markdownBody = (p, key, text) => div().w_full().border_t(1).border_color(p.line).px(10).pt(8).pb(10).text_size(13)
|
|
418
|
+
.child(TextView.markdown(key, text).selectable(true));
|
|
419
|
+
|
|
420
|
+
// A custom message the session displays (subagent output, review notes, …). One short line
|
|
421
|
+
// stays as it is; anything longer is a row that opens to the whole message, as the TUI's
|
|
422
|
+
// message renderers fold theirs.
|
|
423
|
+
function noteCard(v, p, e) {
|
|
424
|
+
const first = firstLine(e.text);
|
|
425
|
+
// A user-role message the runtime wrote (a Gentle Agents wake, a harness note; feed.js
|
|
426
|
+
// systemMessage) is never a "You" bubble: one closed notice row that opens to its text.
|
|
427
|
+
if (e.system) {
|
|
428
|
+
return card(v, p, `note-${e.id}`, false, [icon("mark", 13).text_color(p.muted), name(e.label || "System"), arg(p, first),
|
|
429
|
+
e.time ? div().flex_none().text_size(11.5).text_color(p.faint).child(e.time) : null],
|
|
430
|
+
() => markdownBody(p, `n-${e.id}`, e.text));
|
|
431
|
+
}
|
|
432
|
+
if (e.text.trim() === first && first.length <= 160) {
|
|
433
|
+
return div().px(10).py(6).rounded(R.sm).border_l(2).border_color(p.accent).bg(p.surface).text_size(12)
|
|
434
|
+
.min_w(0).overflow_hidden().child(TextView.markdown(`n-${e.id}`, e.text).selectable(true));
|
|
435
|
+
}
|
|
436
|
+
return card(v, p, `note-${e.id}`, false, [icon("chat", 13).text_color(p.accent), name(e.type || "note"), arg(p, first)],
|
|
437
|
+
() => markdownBody(p, `n-${e.id}`, e.text));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// .msg-user (l.120-122): right, max 82%, bubble 9px 13px, radius 12, 14px/1.55; meta 11.5px.
|
|
441
|
+
function userMessage(p, e) {
|
|
442
|
+
return h_flex().w_full().justify_end()
|
|
443
|
+
.child(v_flex().max_w("82%").items_end().gap(4)
|
|
444
|
+
.child(div().bg(p.user).border(1).border_color(p.lineStrong).rounded(R.md).px(13).py(9).text_size(14).line_height(1.55)
|
|
445
|
+
.child(TextView.markdown(`u-${e.id}`, e.text).selectable(true)))
|
|
446
|
+
.child(div().text_size(11.5).text_color(p.muted).child(e.time ? `You · ${e.time}` : "You")));
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const EXPLORE = { read: "read", grep: "search", find: "search", glob: "search", ls: "list" };
|
|
450
|
+
|
|
451
|
+
function turn(v, p, e, live) {
|
|
452
|
+
const parts = [];
|
|
453
|
+
e.items.forEach((it, i) => {
|
|
454
|
+
const lastItem = live && i === e.items.length - 1;
|
|
455
|
+
const blocks = it.blocks;
|
|
456
|
+
for (let k = 0; k < blocks.length; k++) {
|
|
457
|
+
const b = blocks[k];
|
|
458
|
+
const key = `${it.id}-${k}`;
|
|
459
|
+
if (b.type === "text") {
|
|
460
|
+
parts.push(div().w_full().text_size(14).line_height(1.6).child(TextView.markdown(`a-${key}`, b.text).selectable(true)));
|
|
461
|
+
} else if (b.type === "thinking") {
|
|
462
|
+
// Consecutive thinking blocks are one run, one row (pi's AssistantMessageComponent).
|
|
463
|
+
let j = k + 1;
|
|
464
|
+
while (j < blocks.length && blocks[j].type === "thinking") j++;
|
|
465
|
+
const run = j - k > 1 ? { type: "thinking", text: blocks.slice(k, j).map((x) => x.text.trim()).join("\n\n") } : b;
|
|
466
|
+
parts.push(thinking(v, p, run, key, it.seconds, lastItem && j === blocks.length));
|
|
467
|
+
k = j - 1;
|
|
468
|
+
} else {
|
|
469
|
+
// A run of read-only tools is one "Explored" group (.tool-group, l.143-145).
|
|
470
|
+
let j = k;
|
|
471
|
+
while (j < blocks.length && blocks[j].type === "tool" && EXPLORE[blocks[j].call.name]) j++;
|
|
472
|
+
if (j - k >= 2) {
|
|
473
|
+
parts.push(toolGroup(v, p, blocks.slice(k, j).map((x) => x.call), key, live));
|
|
474
|
+
k = j - 1;
|
|
475
|
+
} else parts.push(toolCard(v, p, b.call, key, live));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (it.error) parts.push(div().w_full().min_w(0).text_size(12).text_color(p.err).child(`⚠ ${it.error}`));
|
|
479
|
+
});
|
|
480
|
+
return v_flex().w_full().gap(10).children(parts);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// .think (l.132-134): italic muted 12.5px summary; body 2px line-strong rule, muted 13px.
|
|
484
|
+
// Closed by default when the session hides thinking blocks (pi's hideThinkingBlock), open
|
|
485
|
+
// otherwise, as the TUI draws them.
|
|
486
|
+
function thinking(v, p, b, key, secs, now) {
|
|
487
|
+
const id = `th-${key}`;
|
|
488
|
+
const def = !v.hideThinking;
|
|
489
|
+
const open = v.isOpen(id, def);
|
|
490
|
+
const label = now ? "Thinking…" : Number.isFinite(secs) && secs > 0 ? `Thought for ${secs}s` : "Thought";
|
|
491
|
+
return v_flex()
|
|
492
|
+
.child(h_flex().id(id).gap(6).items_center().text_size(12.5).italic().text_color(p.muted).cursor_pointer()
|
|
493
|
+
.hover((st) => st.text_color(p.text)).on_click((_e, cx) => v.toggle(id, def, cx))
|
|
494
|
+
.child(chev(open)).child(label))
|
|
495
|
+
.when(open, (el) => el.child(div().mt(6).ml(6).pl(12).border_l(2).border_color(p.lineStrong).text_size(13).text_color(p.muted)
|
|
496
|
+
.child(TextView.markdown(`tht-${key}`, b.text).selectable(true))));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function mark(p, call, live) {
|
|
500
|
+
const r = call.result;
|
|
501
|
+
if (r) return div().flex_none().text_color(r.error ? p.err : p.ok).child(r.error ? "✕" : "✓");
|
|
502
|
+
// A running tool: a still mark in the working colour (S13: no spinner while a tool runs, which
|
|
503
|
+
// can be minutes; the Send button keeps its spinner for the second a send takes).
|
|
504
|
+
return div().flex_none().text_color(live ? p.info : p.faint).child("•");
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// What a finished tool says beside its arguments: "· 299 lines", "· 6 matches".
|
|
508
|
+
function countNote(call) {
|
|
509
|
+
const r = call.result;
|
|
510
|
+
if (!r || r.error) return "";
|
|
511
|
+
const n = r.text.split("\n").filter((l) => l.trim()).length;
|
|
512
|
+
if (call.name === "read") return ` · ${n} lines`;
|
|
513
|
+
if (EXPLORE[call.name] === "search") return ` · ${n} ${n === 1 ? "match" : "matches"}`;
|
|
514
|
+
return "";
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// The dim note at the right of a tool summary: a bash outcome, or why it failed (the TUI keeps a
|
|
518
|
+
// failed card's error tail while collapsed), and the time it took. The tail and the time are
|
|
519
|
+
// separate pieces: the tail may truncate, the time never does.
|
|
520
|
+
function sideNote(call) {
|
|
521
|
+
const r = call.result;
|
|
522
|
+
if (!r) return { tail: "", took: "" };
|
|
523
|
+
const took = seconds(r.ms) || "";
|
|
524
|
+
const last = firstLine(r.text.split("\n").filter((l) => l.trim()).pop() ?? "");
|
|
525
|
+
const said = r.error || call.name === "bash" ? last : "";
|
|
526
|
+
// A failure's tail keeps its whole line (the row truncates it to fit); an outcome its 40.
|
|
527
|
+
const tail = !r.error && said.length > 40 ? said.slice(0, 39) + "…" : said;
|
|
528
|
+
return { tail, took };
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// .tool (l.135-142): 1px line, surface, radius 8; summary 7px 10px, 12.5px.
|
|
532
|
+
function toolCard(v, p, call, key, live) {
|
|
533
|
+
if (call.name === "subagent_run") return subagentCard(v, p, call, key);
|
|
534
|
+
const patch = call.name === "edit" && call.result?.patch ? parsePatch(call.result.patch) : null;
|
|
535
|
+
if (patch?.hunks.length) return diffCard(v, p, call, key, patch, live);
|
|
536
|
+
const id = `tool-${key}`;
|
|
537
|
+
const open = v.isOpen(id, false);
|
|
538
|
+
const r = call.result;
|
|
539
|
+
const { tail, took } = sideNote(call);
|
|
540
|
+
const args = JSON.stringify(call.args, null, 2) ?? "";
|
|
541
|
+
const argsSay = args.includes("\n") && args.length > call.summary.length + 20;
|
|
542
|
+
const failed = Boolean(r?.error) && Boolean(tail);
|
|
543
|
+
const said = oneLine(toolSay(v, call) + countNote(call));
|
|
544
|
+
// One piece of the row takes the room that is left and truncates: the error's tail on a
|
|
545
|
+
// failure (the argument then keeps at most a third of the row, and is dropped when empty),
|
|
546
|
+
// else the argument (the outcome keeps at most a third). The bounded piece gives way too once
|
|
547
|
+
// the other is gone, so mark, name, time and chevron always stay inside the card.
|
|
548
|
+
const bounded = (el) => el.flex_grow_0().flex_shrink_1().min_w(0).max_w("33%");
|
|
549
|
+
const argEl = div().min_w(0).truncate().font_family(mono()).text_size(12).text_color(p.muted).child(said);
|
|
550
|
+
return v_flex().w_full().min_w(0).overflow_hidden().border(1).border_color(p.line).bg(p.surface).rounded(R.sm)
|
|
551
|
+
.child(summaryRow(v, p, id, [
|
|
552
|
+
mark(p, call, live),
|
|
553
|
+
div().flex_none().font_semibold().child(call.name),
|
|
554
|
+
failed ? (said ? bounded(argEl) : null) : argEl.flex_1(),
|
|
555
|
+
tail ? div().id(`${id}-tail`).min_w(0).truncate().text_color(failed ? p.err : p.muted)
|
|
556
|
+
.map((el) => (failed ? el.flex_1() : bounded(el))).child(took ? `${oneLine(tail)} ·` : oneLine(tail)) : null,
|
|
557
|
+
took ? div().flex_none().text_color(failed ? p.err : p.muted).child(took) : null,
|
|
558
|
+
chev(open),
|
|
559
|
+
]))
|
|
560
|
+
.when(open, (el) => el.child(v_flex().gap(8).border_t(1).border_color(p.line).px(10).pt(8).pb(10).text_size(12)
|
|
561
|
+
.when(argsSay, (e2) => e2.child(pre(p, clip(args), p.muted)))
|
|
562
|
+
.child(pre(p, r ? clip(r.text || "(no output)") : live ? "Running…" : "No result yet", r?.error ? p.err : p.text))));
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// Every summary row is one line that never paints past its card: the row clips, and each
|
|
566
|
+
// caller gives exactly one middle piece flex_1 + min_w(0) + truncate.
|
|
567
|
+
function summaryRow(v, p, id, kids, def = false) {
|
|
568
|
+
return h_flex().id(id).w_full().min_w(0).overflow_hidden().whitespace_nowrap().items_center().gap(8).px(10).py(7).text_size(12.5).rounded(R.sm).cursor_pointer()
|
|
569
|
+
.hover((st) => st.bg(p.selected)).on_click((_e, cx) => v.toggle(id, def, cx))
|
|
570
|
+
.children(kids.filter(Boolean));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// .tool-body pre (l.142): mono 12px/1.55, pre-wrap.
|
|
574
|
+
const pre = (p, text, color) => div().w_full().font_family(mono()).text_size(12).line_height(1.55).text_color(color).child(text);
|
|
575
|
+
|
|
576
|
+
// .tool-group (l.143-145): "✓ Explored · 3 reads, 1 search 0.8s", expands to the cards.
|
|
577
|
+
function toolGroup(v, p, calls, key, live) {
|
|
578
|
+
const id = `grp-${key}`;
|
|
579
|
+
const open = v.isOpen(id, false);
|
|
580
|
+
const counts = {};
|
|
581
|
+
for (const c of calls) counts[EXPLORE[c.name]] = (counts[EXPLORE[c.name]] ?? 0) + 1;
|
|
582
|
+
const plural = { read: "reads", search: "searches", list: "lists" };
|
|
583
|
+
const said = Object.entries(counts).map(([k, n]) => `${n} ${n === 1 ? k : plural[k]}`).join(", ");
|
|
584
|
+
const failed = calls.some((c) => c.result?.error);
|
|
585
|
+
const pending = calls.some((c) => !c.result);
|
|
586
|
+
const ms = calls.reduce((n, c) => n + (c.result?.ms ?? 0), 0);
|
|
587
|
+
const m = pending ? div().flex_none().text_color(live ? p.info : p.faint).child("•")
|
|
588
|
+
: div().flex_none().text_color(failed ? p.err : p.ok).child(failed ? "✕" : "✓");
|
|
589
|
+
// The words give way (no grow: the time sits right after them, as in .tool-group).
|
|
590
|
+
return v_flex().w_full().min_w(0)
|
|
591
|
+
.child(h_flex().id(id).w_full().min_w(0).overflow_hidden().whitespace_nowrap().gap(8).py(2).items_center().text_size(12.5)
|
|
592
|
+
.text_color(p.muted).cursor_pointer()
|
|
593
|
+
.hover((st) => st.text_color(p.text)).on_click((_e, cx) => v.toggle(id, false, cx))
|
|
594
|
+
.child(chev(open)).child(m).child(div().flex_shrink_1().min_w(0).truncate().child(`Explored · ${said}`))
|
|
595
|
+
.when(ms > 0, (el) => el.child(div().flex_none().text_color(p.muted).child(seconds(ms)))))
|
|
596
|
+
.when(open, (el) => el.child(v_flex().mt(8).gap(6).children(calls.map((c, i) => toolCard(v, p, c, `${key}-${i}`, live)))));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// .tool.diff + .hunk + .diff-foot (l.146-154). The artboard draws it open; the minimal view
|
|
600
|
+
// (S11) starts it as its summary row (file, +N −M) like the TUI's command-only edit card.
|
|
601
|
+
function diffCard(v, p, call, key, patch, live) {
|
|
602
|
+
const id = `diff-${key}`;
|
|
603
|
+
const open = v.isOpen(id, false);
|
|
604
|
+
const at = Math.min(v.hunkAt.get(id) ?? 0, patch.hunks.length - 1);
|
|
605
|
+
const h = patch.hunks[at];
|
|
606
|
+
const row = (bg, ln, sign, signColor, text, textColor) => h_flex().w_full().pr(10).when(Boolean(bg), (el) => el.bg(bg))
|
|
607
|
+
.child(div().w(40).flex_none().pr(8).text_right().text_color(p.muted).child(ln))
|
|
608
|
+
.child(div().w(16).flex_none().when(Boolean(signColor), (el) => el.text_color(signColor)).child(sign))
|
|
609
|
+
.child(div().flex_1().min_w(0).truncate().text_color(textColor ?? p.text).child(text || " "));
|
|
610
|
+
const rows = [row(p.raised, "", "", null, h.header, p.muted)];
|
|
611
|
+
for (const r of h.rows.slice(0, HUNK_ROWS)) {
|
|
612
|
+
if (r.kind === "a") rows.push(row(alpha(p.ok, 0x14 / 255), String(r.ln), "+", p.ok, r.text));
|
|
613
|
+
else if (r.kind === "d") rows.push(row(alpha(p.err, 0x14 / 255), String(r.ln), "−", p.err, r.text));
|
|
614
|
+
else rows.push(row(null, String(r.ln), "", null, r.text));
|
|
615
|
+
}
|
|
616
|
+
if (h.rows.length > HUNK_ROWS) rows.push(row(null, "", "", null, `… ${h.rows.length - HUNK_ROWS} more lines`, p.muted));
|
|
617
|
+
const path = typeof call.args?.path === "string" ? shortPath(v, call.args.path) : toolSay(v, call);
|
|
618
|
+
return v_flex().w_full().min_w(0).overflow_hidden().border(1).border_color(p.line).bg(p.surface).rounded(R.sm)
|
|
619
|
+
.child(summaryRow(v, p, id, [
|
|
620
|
+
mark(p, call, live),
|
|
621
|
+
div().flex_none().font_semibold().child(call.name),
|
|
622
|
+
div().flex_1().min_w(0).truncate().font_family(mono()).text_size(12).text_color(p.muted).child(oneLine(path)),
|
|
623
|
+
num(`+${patch.added}`, p.ok).flex_none(),
|
|
624
|
+
num(`−${patch.deleted}`, p.err).flex_none(),
|
|
625
|
+
chev(open),
|
|
626
|
+
]))
|
|
627
|
+
.when(open, (el) => el.child(v_flex().border_t(1).border_color(p.line)
|
|
628
|
+
.child(v_flex().py(4).font_family(mono()).text_size(12).line_height(1.6).children(rows))
|
|
629
|
+
.child(h_flex().justify_between().items_center().gap(8).px(10).py(6).border_t(1).border_color(p.line).text_size(12).text_color(p.muted)
|
|
630
|
+
.child(`Hunk ${at + 1} of ${patch.hunks.length}`)
|
|
631
|
+
.child(h_flex().gap(6)
|
|
632
|
+
.child(btn(p, `${id}-next`, "Next hunk", {
|
|
633
|
+
tip: patch.hunks.length > 1 ? null : "This edit has one hunk",
|
|
634
|
+
onClick: (_e, cx) => { v.hunkAt.set(id, (at + 1) % patch.hunks.length); cx.notify(); },
|
|
635
|
+
}))
|
|
636
|
+
.child(btn(p, `${id}-changes`, "Open in Changes", {
|
|
637
|
+
tip: "Show this file in the inspector's Changes tab",
|
|
638
|
+
onClick: (_e, cx) => v.openInChanges(typeof call.args?.path === "string" ? shortPath(v, call.args.path) : "", cx),
|
|
639
|
+
}))))));
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const AGENT_STATE = {
|
|
643
|
+
queued: ["queue", "Queued"], running: ["work", "Running"], starting: ["work", "Running"], waiting: ["need", "Waiting"],
|
|
644
|
+
completed: ["done", "Done"], failed: ["fail", "Failed"], timed_out: ["fail", "Timed out"], cancelled: ["idle", "Cancelled"],
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// .sub (l.155-160): a subagent run, live from the snapshot's agents when it lists the task. The
|
|
648
|
+
// minimal view (S11) draws it as one row in the .tool look (role, task, state, model, spend);
|
|
649
|
+
// open, it is the artboard's card, whose title row closes it again.
|
|
650
|
+
function subagentCard(v, p, call, key) {
|
|
651
|
+
const a = call.args ?? {};
|
|
652
|
+
const started = call.result?.agent ?? null;
|
|
653
|
+
const live = started?.taskId ? v.snap?.agents?.items?.find((x) => x.id === started.taskId) : null;
|
|
654
|
+
const name = String(live?.name ?? started?.agent ?? a.agent ?? "agent");
|
|
655
|
+
const role = name.replace(/^gentle-ai-/, "").replace(/^gentle-/, "");
|
|
656
|
+
const title = oneLine(a.label || firstLine(a.task) || name);
|
|
657
|
+
const status = live?.state ?? started?.status ?? (call.result ? (call.result.error ? "failed" : "completed") : "queued");
|
|
658
|
+
const [kind, label] = AGENT_STATE[status] ?? ["idle", status];
|
|
659
|
+
const model = prettyModel(live?.model ?? started?.model);
|
|
660
|
+
const cost = live?.spend?.cost;
|
|
661
|
+
const step = live?.step ?? started?.lastStep;
|
|
662
|
+
const running = kind === "work" || kind === "need" || kind === "queue";
|
|
663
|
+
const taskId = live?.id ?? started?.taskId ?? null;
|
|
664
|
+
const stopping = Boolean(taskId) && v.busy === `stop-${taskId}`;
|
|
665
|
+
const id = `sub-${key}`;
|
|
666
|
+
const roleTag = div().flex_none().font_family(mono()).text_size(11).text_color(p.accent).child(role.toUpperCase());
|
|
667
|
+
if (!v.isOpen(id, false)) {
|
|
668
|
+
return v_flex().w_full().min_w(0).overflow_hidden().border(1).border_color(p.line).bg(p.surface).rounded(R.sm)
|
|
669
|
+
.child(summaryRow(v, p, id, [
|
|
670
|
+
roleTag,
|
|
671
|
+
// The task takes what is left; the state's word and the model give way after it (at
|
|
672
|
+
// most a third each); role, spend and chevron keep their width.
|
|
673
|
+
div().flex_1().min_w(0).truncate().child(title),
|
|
674
|
+
stateLabel(p, kind, div().min_w(0).truncate().child(label)).flex_grow_0().flex_shrink_1().min_w(0).max_w("33%"),
|
|
675
|
+
model ? div().flex_grow_0().flex_shrink_1().min_w(0).max_w("33%").truncate().text_size(12).text_color(p.muted).child(model) : null,
|
|
676
|
+
Number.isFinite(cost) ? num(money(cost), p.muted).flex_none().text_size(12) : null,
|
|
677
|
+
chev(false),
|
|
678
|
+
]));
|
|
679
|
+
}
|
|
680
|
+
return v_flex().w_full().min_w(0).overflow_hidden().gap(4).px(12).py(10).border(1).border_color(p.lineStrong).rounded(R.md).bg(p.surface)
|
|
681
|
+
.child(h_flex().items_start().gap(12).min_w(0)
|
|
682
|
+
.child(v_flex().flex_1().min_w(0).gap(4)
|
|
683
|
+
.child(h_flex().id(id).gap(8).items_center().min_w(0).overflow_hidden().whitespace_nowrap().text_size(13).font_semibold().cursor_pointer()
|
|
684
|
+
.hover((st) => st.text_color(p.accentSoft)).on_click((_e, cx) => v.toggle(id, false, cx))
|
|
685
|
+
.child(roleTag)
|
|
686
|
+
.child(div().flex_1().min_w(0).truncate().child(title))
|
|
687
|
+
.child(chev(true).text_color(p.muted)))
|
|
688
|
+
.child(h_flex().flex_wrap().gap(12).items_center().text_size(12).text_color(p.muted)
|
|
689
|
+
.child(stateLabel(p, kind, label))
|
|
690
|
+
.when(Boolean(model), (el) => el.child(div().child(model)))
|
|
691
|
+
.when(Number.isFinite(cost), (el) => el.child(num(money(cost))))))
|
|
692
|
+
// View opens the TUI's /gentle:agents; Stop asks the subagent owner (as desktop RPC
|
|
693
|
+
// cancel_subagent). Only a subagent that still runs has them (the inspector's .acts, l.213).
|
|
694
|
+
.when(running, (el) => el.child(h_flex().flex_none().gap(6).items_start()
|
|
695
|
+
.child(btn(p, `sub-view-${key}`, "View", { tip: "Open /gentle:agents in the Terminal", onClick: (_e, cx) => v.command(`view-${key}`, "/gentle:agents", cx) }))
|
|
696
|
+
.when(Boolean(taskId), (el) => el.child(btn(p, `sub-stop-${key}`, stopping ? "Stopping…" : "Stop", {
|
|
697
|
+
danger: true, iconName: "stop", tip: "Stop this subagent", onClick: (_e, cx) => v.stopAgent(taskId, cx),
|
|
698
|
+
}))))))
|
|
699
|
+
.when(Boolean(step) && step !== status, (el) => el.child(div().mt(2).pt(6).border_t(1).border_color(p.line)
|
|
700
|
+
.font_family(mono()).text_size(12).text_color(p.muted).truncate().child(`› ${step}`)))
|
|
701
|
+
// The run's own answer (its result text), as the TUI's expanded card shows it.
|
|
702
|
+
.when(Boolean(call.result?.text?.trim()), (el) => el.child(div().mt(2).pt(6).border_t(1).border_color(p.line)
|
|
703
|
+
.text_size(13).child(TextView.markdown(`sr-${key}`, clip(call.result.text)).selectable(true))));
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// The options a pending question offers: its own, then "Something else…" when it takes a
|
|
707
|
+
// typed answer. "(Recommended)" in a label becomes the badge. A question the session marks
|
|
708
|
+
// `terminalOnly` (consent, a relayed provider decision, several questions) offers none here.
|
|
709
|
+
export function askOptions(pq) {
|
|
710
|
+
if (pq?.terminalOnly) return [];
|
|
711
|
+
return choiceRows(pq);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
function choiceRows(pq) {
|
|
715
|
+
const opts = (pq?.options ?? []).map((o) => {
|
|
716
|
+
const raw = String(o.label ?? "");
|
|
717
|
+
const rec = /\s*\(recommended\)\s*$/i.test(raw);
|
|
718
|
+
return { label: raw.replace(/\s*\(recommended\)\s*$/i, ""), about: o.description ?? null, rec, custom: false };
|
|
719
|
+
});
|
|
720
|
+
if (opts.length && pq.custom) opts.push({ label: "Something else…", about: "Type your own answer in the composer.", rec: false, custom: true });
|
|
721
|
+
return opts;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// .ask (l.161-171): the open question, clickable options, keys 1–N.
|
|
725
|
+
export function askCard(v, p, pq) {
|
|
726
|
+
const opts = askOptions(pq);
|
|
727
|
+
const done = v.answered;
|
|
728
|
+
const n = opts.length;
|
|
729
|
+
const foot = done
|
|
730
|
+
? (opts[done.index]?.custom ? "Type your answer in the composer; it goes to this question." : `Answer sent: ${done.index + 1}. The agent continues.`)
|
|
731
|
+
: n ? `Press ${n === 1 ? "1" : `1–${n}`} or click · Esc answers later` : "Answer it in the Terminal view.";
|
|
732
|
+
// Terminal-only: the options are shown for reading, never numbered or clickable.
|
|
733
|
+
const shown = n ? [] : (pq.terminalOnly ? choiceRows(pq).filter((o) => !o.custom) : []);
|
|
734
|
+
const readOnly = (o, i) => v_flex().id(`ask-ro-${i}`).w_full().min_w(0).overflow_hidden().gap(1).px(10).py(6).rounded(R.sm).border(1).border_color(p.line).bg(p.background)
|
|
735
|
+
.child(div().min_w(0).font_semibold().text_size(13.5).child(o.label))
|
|
736
|
+
.when(Boolean(o.about), (el) => el.child(div().text_size(12.5).text_color(p.muted).child(o.about)));
|
|
737
|
+
const many = (pq.questions?.length ?? 0) > 1 ? ` · 1 of ${pq.questions.length}` : "";
|
|
738
|
+
const opt = (o, i) => {
|
|
739
|
+
const pressed = done?.index === i;
|
|
740
|
+
return h_flex().id(`ask-${i}`).w_full().min_w(0).overflow_hidden().min_h(44).items_start().gap(10).px(10).py(8).rounded(R.sm).border(1)
|
|
741
|
+
.border_color(pressed ? p.accent : p.line).bg(pressed ? p.selected : p.background)
|
|
742
|
+
.when(Boolean(done) && !pressed, (el) => el.opacity(0.55))
|
|
743
|
+
.when(!done, (el) => el.cursor_pointer().hover((st) => st.border_color(p.accent)).on_click((_e, cx) => v.answer(i, cx)))
|
|
744
|
+
.child(div().w(26).flex_none()
|
|
745
|
+
.child(div().w(22).h(22).flex().items_center().justify_center().border(1).border_color(p.lineStrong).rounded(R.inner)
|
|
746
|
+
.font_family(mono()).font_semibold().text_size(12).line_height(1).text_color(p.accentSoft).child(String(i + 1))))
|
|
747
|
+
.child(v_flex().flex_1().min_w(0).gap(1)
|
|
748
|
+
.child(h_flex().min_w(0).items_center().flex_wrap()
|
|
749
|
+
.child(div().min_w(0).font_semibold().text_size(13.5).child(o.label))
|
|
750
|
+
.when(o.rec, (el) => el.child(div().flex_none().ml(8).font_family(mono()).font_semibold().text_size(10.5).line_height(1)
|
|
751
|
+
.text_color(p.accent).child("RECOMMENDED"))))
|
|
752
|
+
.when(Boolean(o.about), (el) => el.child(div().text_size(12.5).text_color(p.muted).child(o.about))));
|
|
753
|
+
};
|
|
754
|
+
// A 3px accent left edge on a 1px line-strong card: Herdr draws one border colour per
|
|
755
|
+
// element, so the accent is the outer fill showing through a 3px left inset, and the card
|
|
756
|
+
// keeps its top, right and bottom borders.
|
|
757
|
+
return h_flex().w_full().rounded(R.md).bg(p.accent).pl(3)
|
|
758
|
+
.child(v_flex().flex_1().min_w(0).gap(8).py(12).pl(14).pr(14).bg(p.surface)
|
|
759
|
+
.rounded_tl(R.md - 3).rounded_bl(R.md - 3).rounded_tr(R.md).rounded_br(R.md)
|
|
760
|
+
.border_t(1).border_r(1).border_b(1).border_color(p.lineStrong)
|
|
761
|
+
.child(div().font_family(mono()).font_semibold().text_size(11).line_height(1.4).text_color(p.accent)
|
|
762
|
+
.child(`QUESTION · THE AGENT WAITS FOR YOU${many.toUpperCase()}`))
|
|
763
|
+
.child(div().min_w(0).text_size(14.5).font_semibold().child(pq.header && pq.header !== pq.question ? `${pq.header}: ${pq.question}` : pq.question))
|
|
764
|
+
.when(n > 0, (el) => el.child(v_flex().mt(2).gap(6).children(opts.map(opt))))
|
|
765
|
+
.when(shown.length > 0, (el) => el.child(v_flex().mt(2).gap(6).children(shown.map(readOnly))))
|
|
766
|
+
.child(h_flex().min_w(0).items_center().justify_between().gap(8)
|
|
767
|
+
.child(div().flex_1().min_w(0).text_size(12).text_color(p.muted).child(foot))
|
|
768
|
+
// A prompt or consent has no options here: it is answered in the real terminal, by you.
|
|
769
|
+
.when(n === 0, (el) => el.child(btn(p, "ask-terminal", "Answer in Terminal", { iconName: "term", tip: "Answer it in the Terminal", onClick: () => v.toTerminal() })))));
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// ---------------------------------------------------------------- 4c composer (l.175-184)
|
|
773
|
+
|
|
774
|
+
// The "/" menu (T10): the session's commands above the field, in the .perm-menu look (l.107-111:
|
|
775
|
+
// raised, 1px line-strong, radius 12, 6px padding, shadow; rows 7px 8px radius 6, hover fill).
|
|
776
|
+
// The artboard has no open state of it; rows show "/name", the argument it takes, the
|
|
777
|
+
// description, and the terminal mark when the command answers in the TUI. At most 8 rows show,
|
|
778
|
+
// around the selected one.
|
|
779
|
+
const SLASH_ROWS = 8;
|
|
780
|
+
// Where the Textarea starts its text inside its box (its own left padding), for the placeholder.
|
|
781
|
+
const PLACEHOLDER_INSET = 0;
|
|
782
|
+
function slashMenu(v, p) {
|
|
783
|
+
const m = v.slashMenu();
|
|
784
|
+
if (!m) return null;
|
|
785
|
+
const from = Math.max(0, Math.min(m.at - Math.floor(SLASH_ROWS / 2), m.items.length - SLASH_ROWS));
|
|
786
|
+
const rows = m.items.slice(from, from + SLASH_ROWS).map((c, k) => {
|
|
787
|
+
const i = from + k;
|
|
788
|
+
const on = i === m.at;
|
|
789
|
+
return h_flex().id(`slash-${i}`).w_full().items_center().gap(10).px(8).py(7).rounded(R.inner).cursor_pointer()
|
|
790
|
+
.when(on, (el) => el.bg(p.selected)).hover((st) => st.bg(p.selected))
|
|
791
|
+
.on_mouse_down("left", (_e, cx) => cx.stop_propagation())
|
|
792
|
+
.on_click((_e, cx) => v.slashPick(i, false, cx))
|
|
793
|
+
.child(div().flex_none().font_family(mono()).text_size(12.5).font_semibold().text_color(on ? p.accentSoft : p.text).child(`/${c.name}`))
|
|
794
|
+
.when(Boolean(c.args), (el) => el.child(div().flex_none().font_family(mono()).text_size(12).text_color(p.faint).child(c.args)))
|
|
795
|
+
.child(div().flex_1().min_w(0).truncate().text_size(12).text_color(p.muted).child(c.description ?? ""))
|
|
796
|
+
.when(c.terminal !== false, (el) => el.child(icon("term", 13).text_color(p.faint)));
|
|
797
|
+
});
|
|
798
|
+
const more = m.items.length > SLASH_ROWS ? `${m.at + 1} of ${m.items.length}` : null;
|
|
799
|
+
return v_flex().id("slash-menu").absolute().left(0).right(0).bottom(66).p(6).bg(p.raised).border(1).border_color(p.lineStrong)
|
|
800
|
+
.rounded(R.md).shadow_lg().text_color(p.text)
|
|
801
|
+
.children(rows)
|
|
802
|
+
.child(h_flex().px(8).pt(4).gap(14).items_center().text_size(11.5).text_color(p.muted)
|
|
803
|
+
.child(h_flex().gap(3).items_center().child(kbd(p, "↑↓")).child("move"))
|
|
804
|
+
.child(h_flex().gap(3).items_center().child(kbd(p, "Enter")).child("run"))
|
|
805
|
+
.child(h_flex().gap(3).items_center().child(kbd(p, "Tab")).child("complete"))
|
|
806
|
+
.child(div().flex_1())
|
|
807
|
+
.when(Boolean(more), (el) => el.child(div().font_family(mono()).child(more))));
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// The Send button, or Stop while the agent works and the draft is empty (the artboard draws
|
|
811
|
+
// only Send; Stop keeps its 32px size and radius in the .btn.danger look, l.92-95, with the
|
|
812
|
+
// i-stop symbol, l.308). Typing while it works brings Send back: the message is queued, as in
|
|
813
|
+
// the terminal.
|
|
814
|
+
function sendOrStop(v, p) {
|
|
815
|
+
if (v.working() && !v.draft.trim() && v.key) {
|
|
816
|
+
const stopping = v.busy === "stop";
|
|
817
|
+
return h_flex().id("stop").h(32).flex_none().items_center().gap(6).px(12).rounded(R.sm).border(1).border_color(p.lineStrong)
|
|
818
|
+
.text_color(p.text).font_semibold().text_size(13).cursor_pointer()
|
|
819
|
+
.when(stopping, (el) => el.opacity(0.6))
|
|
820
|
+
.hover((st) => st.border_color(p.err).text_color(p.err))
|
|
821
|
+
.tooltip("Stop the agent's turn (Esc Esc)")
|
|
822
|
+
.on_click((_e, cx) => v.stop(cx))
|
|
823
|
+
.child(icon("stop", 13).text_color(p.err)).child(stopping ? "Stopping…" : "Stop");
|
|
824
|
+
}
|
|
825
|
+
return h_flex().id("send").h(32).flex_none().items_center().gap(6).px(12).rounded(R.sm)
|
|
826
|
+
.bg(v.key ? p.accent : p.raised).text_color(v.key ? p.onAccent : p.faint).font_semibold().text_size(13)
|
|
827
|
+
.cursor_pointer().on_click((_e, cx) => v.send(cx))
|
|
828
|
+
.child(v.sending ? div().frames(SPINNER, 90) : icon("send", 13)).child("Send");
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
export function composer(v, p, pq) {
|
|
832
|
+
const menu = slashMenu(v, p);
|
|
833
|
+
// Clip, text and Send share one centre line (S8 report "no esta centrado"): the row centres
|
|
834
|
+
// its three, and the text sits in a 42px box (the artboard's textarea height, l.179) whose one
|
|
835
|
+
// line is centred; a longer draft grows the box, the clip and Send stay on its centre.
|
|
836
|
+
const field = h_flex().w_full().items_center().gap(8).pl(12).pr(8).py(8).border(1)
|
|
837
|
+
.border_color(v.typing ? p.accent : p.lineStrong).rounded(R.md).bg(p.background)
|
|
838
|
+
// Attach: the clipboard's image (or files) into the session's draft, as Ctrl+V in the terminal.
|
|
839
|
+
.child(h_flex().id("attach").w(32).h(32).flex_none().items_center().justify_center().rounded(R.sm).text_color(p.muted)
|
|
840
|
+
.cursor_pointer().when(v.busy === "attach", (el) => el.opacity(0.6))
|
|
841
|
+
.hover((st) => st.bg(p.selected).text_color(p.text)).tooltip("Attach: paste the clipboard image into the draft (Ctrl+V)")
|
|
842
|
+
.on_click((_e, cx) => v.attach(cx)).child(icon("clip", 15)))
|
|
843
|
+
.child(div().flex_1().min_w(0).key_context("GentleChatComposer").on_action("gentle_chat_send", (_e, cx) => v.send(cx))
|
|
844
|
+
// While the "/" menu is open, ↑/↓/Tab are its keys (main.js binds them in GentleSlashMenu).
|
|
845
|
+
.child(div().w_full().key_context(menu ? "GentleSlashMenu" : "GentleSlashIdle")
|
|
846
|
+
.on_action("gentle_chat_slash_up", (_e, cx) => v.slashMove(-1, cx))
|
|
847
|
+
.on_action("gentle_chat_slash_down", (_e, cx) => v.slashMove(1, cx))
|
|
848
|
+
.on_action("gentle_chat_slash_complete", (_e, cx) => v.slashPick(v.slashAt, true, cx))
|
|
849
|
+
.child(div().relative().w_full().min_h(42).flex().items_center()
|
|
850
|
+
.child(Textarea.new(v.input).w_full().text_size(14).line_height(1.5).text_color(p.text).bg(CLEAR))
|
|
851
|
+
// The placeholder: one line, muted, an ellipsis when the card is narrow. It paints
|
|
852
|
+
// under nothing that listens, so a click still reaches the field.
|
|
853
|
+
.when(!v.draft, (el) => el.child(div().absolute().top(0).bottom(0).left(PLACEHOLDER_INSET).right(0).flex().items_center()
|
|
854
|
+
.child(div().w_full().min_w(0).truncate().text_size(14).line_height(1.5).text_color(p.muted).child(v.placeholder ?? "")))))))
|
|
855
|
+
.child(sendOrStop(v, p));
|
|
856
|
+
const hint = (key, text) => h_flex().flex_none().items_center().gap(3).child(kbd(p, key)).child(text);
|
|
857
|
+
// The hints row is one line: a narrow card drops hints from the right (Esc Esc, then ⌘J,
|
|
858
|
+
// then /, then ⇧ Enter) instead of wrapping or clipping; Enter send and the minimal view's
|
|
859
|
+
// toggle stay.
|
|
860
|
+
const w = Number.isFinite(v.composerW) ? Math.min(780, v.composerW - 32) : 780;
|
|
861
|
+
const show = { esc: w >= 700, term: w >= 540 && !v.elsewhere(), cmd: w >= 450, nl: w >= 360 };
|
|
862
|
+
// S11: "⌘O Expand all" / "⌘O Collapse all", the TUI's ctrl+o for every row of the log.
|
|
863
|
+
const expand = h_flex().id("expand-all").flex_none().items_center().gap(3).rounded(R.kbd).cursor_pointer()
|
|
864
|
+
.hover((st) => st.text_color(p.text))
|
|
865
|
+
.tooltip(v.expandAll ? "Back to the minimal view: every tool call, thought, diff and subagent as one line" : "Open every tool call, thought, diff and subagent in the chat")
|
|
866
|
+
.on_click((_e, cx) => v.expandToggle(cx))
|
|
867
|
+
.child(kbd(p, "⌘O")).child(v.expandAll ? "collapse all" : "expand all");
|
|
868
|
+
return v_flex().id("composer").flex_none().px(16).pt(10).pb(12).border_t(1).border_color(p.line).bg(p.chrome)
|
|
869
|
+
.rounded_b(R.window - 1)
|
|
870
|
+
.on_size_change((size, cx) => { if (Math.abs((v.composerW ?? 0) - size.width) >= 1) { v.composerW = size.width; cx.notify(); } })
|
|
871
|
+
.child(v_flex().w_full().max_w(780).self_center()
|
|
872
|
+
.child(div().w_full().relative().child(field).when(Boolean(menu), (el) => el.child(menu)))
|
|
873
|
+
.when(Boolean(v.error), (el) => el.child(div().mt(6).text_size(12).text_color(p.err).child(v.error)))
|
|
874
|
+
.when(!v.error && Boolean(v.notice), (el) => el.child(div().mt(6).text_size(12).text_color(p.muted).child(v.notice)))
|
|
875
|
+
.child(h_flex().mt(6).gap(14).items_center().overflow_hidden().whitespace_nowrap().text_size(11.5).text_color(p.muted)
|
|
876
|
+
.child(hint("Enter", "send"))
|
|
877
|
+
.when(show.nl, (el) => el.child(hint("⇧ Enter", "new line")))
|
|
878
|
+
.when(show.cmd, (el) => el.child(hint("/", "commands")))
|
|
879
|
+
.when(show.term, (el) => el.child(hint("⌘J", "Terminal")))
|
|
880
|
+
.child(div().flex_1())
|
|
881
|
+
.child(expand)
|
|
882
|
+
.when(show.esc, (el) => el.child(div().flex_none().child("Esc Esc stops the agent")))));
|
|
883
|
+
}
|