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
|
@@ -38,12 +38,12 @@ function isPiSubcommand(token ) {
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
// Home-, upgrade- and
|
|
41
|
+
// Home-, upgrade-, self-uninstall-, memory- and desktop-subcommand parsing is deliberately shallow:
|
|
42
42
|
// each only counts as the subcommand when it is argv[0], and everything after it is handed over
|
|
43
43
|
// untouched as commandArgs — T2 owns interpreting `home link|isolated|<path>`.
|
|
44
44
|
// `self-uninstall` is not `uninstall`, which stays pi's own alias for `remove`.
|
|
45
45
|
export function parseLauncherArgs(argv ) {
|
|
46
|
-
if (argv[0] === "home" || argv[0] === "upgrade" || argv[0] === "self-uninstall" || argv[0] === "memory") {
|
|
46
|
+
if (argv[0] === "home" || argv[0] === "upgrade" || argv[0] === "self-uninstall" || argv[0] === "memory" || argv[0] === "desktop" || argv[0] === "tower") {
|
|
47
47
|
return {
|
|
48
48
|
link: false,
|
|
49
49
|
isolated: false,
|
|
@@ -179,6 +179,38 @@ export function parseLauncherArgs(argv ) {
|
|
|
179
179
|
return { link, isolated, home, packageRoot, help, version, command, commandArgs, passthrough, piSubcommand, error };
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
// --- tower ------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
// `gentle-shell tower [--no-open] [--port <n>]`: the server always binds
|
|
191
|
+
// 127.0.0.1; --port only fixes which local port.
|
|
192
|
+
export function parseTowerArgs(args ) {
|
|
193
|
+
let open = true;
|
|
194
|
+
let port ;
|
|
195
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
196
|
+
const arg = args[i];
|
|
197
|
+
if (arg === "--no-open") {
|
|
198
|
+
open = false;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (arg === "--port" || arg.startsWith("--port=")) {
|
|
202
|
+
const value = arg === "--port" ? args[(i += 1)] : arg.slice("--port=".length);
|
|
203
|
+
if (value === undefined) return { open, error: "--port needs a whole number from 1 to 65535" };
|
|
204
|
+
const n = /^\d+$/.test(value) ? Number(value) : NaN;
|
|
205
|
+
if (!(n >= 1 && n <= 65535)) return { open, error: `--port needs a whole number from 1 to 65535 (got "${value}")` };
|
|
206
|
+
port = n;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
return { open, error: `unknown tower argument "${arg}"` };
|
|
210
|
+
}
|
|
211
|
+
return port === undefined ? { open } : { open, port };
|
|
212
|
+
}
|
|
213
|
+
|
|
182
214
|
// --- home resolution -------------------------------------------------------
|
|
183
215
|
|
|
184
216
|
|
|
@@ -1340,6 +1372,8 @@ export function helpText() {
|
|
|
1340
1372
|
" gentle-shell upgrade --rollback",
|
|
1341
1373
|
" gentle-shell memory migrate --confirm-quiescent",
|
|
1342
1374
|
" gentle-shell self-uninstall [--dry-run] [--yes] [--include-shared]",
|
|
1375
|
+
" gentle-shell desktop [--yes] [--no-open] | --status | --uninstall",
|
|
1376
|
+
" gentle-shell tower [--no-open] [--port <n>]",
|
|
1343
1377
|
"",
|
|
1344
1378
|
"Opens pi with the Gentle Shell package loaded, without touching your",
|
|
1345
1379
|
"vanilla pi installation.",
|
|
@@ -1383,6 +1417,14 @@ export function helpText() {
|
|
|
1383
1417
|
" ~/.pi/gentle-ai configuration is kept unless",
|
|
1384
1418
|
" you accept or pass --include-shared; --dry-run only shows the plan.",
|
|
1385
1419
|
" Never touches your pi home or custom --home homes.",
|
|
1420
|
+
" desktop Install and open Gentle Shell Desktop: Herdr app (pinned minimum",
|
|
1421
|
+
" version, downloaded from releases.herdr.dev and checked against its pinned",
|
|
1422
|
+
" SHA-256 when missing or older) with Gentle Shell's gentle-* mods and",
|
|
1423
|
+
" gentle-shell layout. Shows the plan and asks first (--yes skips the",
|
|
1424
|
+
" question); --status and --uninstall; 'gentle-shell desktop --help'.",
|
|
1425
|
+
" tower Open the Gentle Tower outside any session: every open Gentle Shell session",
|
|
1426
|
+
" as a floor, in your browser. Prints the local URL and serves until Ctrl+C.",
|
|
1427
|
+
" --no-open only prints the URL; --port <n> fixes the port (127.0.0.1 only).",
|
|
1386
1428
|
"",
|
|
1387
1429
|
"Managing packages:",
|
|
1388
1430
|
" gentle-shell install npm:<pkg> Run pi's own 'install' against the resolved home.",
|
|
@@ -493,6 +493,45 @@ const NATIVE_REVIEW_UNKNOWN_UNACHIEVABLE_VERB_REFUSAL = /unknown review command
|
|
|
493
493
|
// flags with this exact typed preflight cause, before reading the repository.
|
|
494
494
|
const NATIVE_REVIEW_UNKNOWN_LENS_FLAG_CAUSE = /^flag provided but not defined: -lenses(?:-reason)?$/;
|
|
495
495
|
|
|
496
|
+
// A provider older than gentle-ai#6088 refuses the STATUS opt-in with this
|
|
497
|
+
// exact typed preflight cause, before reading the repository.
|
|
498
|
+
const NATIVE_REVIEW_UNKNOWN_NON_BLOCKING_FLAG_CAUSE = /^flag provided but not defined: -non-blocking-findings$/;
|
|
499
|
+
|
|
500
|
+
/** Reports a not-started STATUS refusal caused only by an unknown --non-blocking-findings flag. */
|
|
501
|
+
function isNativeReviewNonBlockingFindingsUnsupported(error ) {
|
|
502
|
+
if (!(error instanceof NativeReviewIntegrationError)) return false;
|
|
503
|
+
const failure = error.failureEnvelope;
|
|
504
|
+
return failure.code === "invalid_request" && failure.mutationOutcome === "not_started" &&
|
|
505
|
+
typeof failure.cause === "string" && NATIVE_REVIEW_UNKNOWN_NON_BLOCKING_FLAG_CAUSE.test(failure.cause);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Provider binaries (executable path to its sha256) that refused
|
|
509
|
+
// --non-blocking-findings in this process. A replaced binary at the same path
|
|
510
|
+
// has another digest and is asked again. Never a capability claim.
|
|
511
|
+
const nonBlockingFindingsRefusals = new Map ();
|
|
512
|
+
|
|
513
|
+
function nonBlockingFindingsRefused(executable ) {
|
|
514
|
+
const digest = nonBlockingFindingsRefusals.get(executable);
|
|
515
|
+
if (digest === undefined) return false;
|
|
516
|
+
try {
|
|
517
|
+
return binaryDigest(executable) === digest;
|
|
518
|
+
} catch {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function nonBlockingExecutableDigest(executable ) {
|
|
524
|
+
try { return binaryDigest(executable); } catch { return undefined; }
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function rememberNonBlockingFindingsRefusal(executable , digest ) {
|
|
528
|
+
// An old in-flight refusal must neither label a replacement unsupported
|
|
529
|
+
// nor erase a newer request's cache entry when identity cannot be read.
|
|
530
|
+
if (digest !== undefined && nonBlockingExecutableDigest(executable) === digest) {
|
|
531
|
+
nonBlockingFindingsRefusals.set(executable, digest);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
496
535
|
/** Reports a not-started STATUS refusal caused only by an unknown --lenses flag. */
|
|
497
536
|
export function isNativeReviewLensSelectionUnsupported(error ) {
|
|
498
537
|
if (!(error instanceof NativeReviewIntegrationError)) return false;
|
|
@@ -592,6 +631,14 @@ export const NATIVE_REVIEW_CONSENT_ANSWER = { GRANTED: "granted", DECLINED: "dec
|
|
|
592
631
|
|
|
593
632
|
|
|
594
633
|
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
595
642
|
|
|
596
643
|
|
|
597
644
|
|
|
@@ -1123,6 +1170,23 @@ export const NATIVE_CLI_CONTRACTS = Object.freeze({
|
|
|
1123
1170
|
// 58450471280aeb357443d6a28c819132d8c8eb78dd25b12bac64296b2f8c27c2.
|
|
1124
1171
|
// No new negotiated capability identity is asserted.
|
|
1125
1172
|
"4.4.0": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1173
|
+
// v4.5.0 repeats 4.4.0: the published binary still advertises
|
|
1174
|
+
// capabilities/v2.6 (protocol minor 6) under review-integration/v2, and the
|
|
1175
|
+
// provider contract moved from 1.4.0 to 1.5.0 additively (one stop reason,
|
|
1176
|
+
// no negotiated START/STATUS field), with published provider-contract tarball
|
|
1177
|
+
// SHA-256 08fdb65329b47a2cd2563edfa62b5781fd5ec7b0d1e8812e8e29a01a486da838.
|
|
1178
|
+
// Ground truth: `review capabilities --contract gentle-ai.review-integration/v2`
|
|
1179
|
+
// on the released darwin/arm64 v4.5.0 binary reports schema
|
|
1180
|
+
// gentle-ai.review-integration.capabilities/v2.6 with protocol minor 6.
|
|
1181
|
+
// No new negotiated capability identity is asserted.
|
|
1182
|
+
"4.5.0": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1183
|
+
// The published darwin/arm64 v4.6.0 binary still advertises capabilities/v2.6
|
|
1184
|
+
// (protocol minor 6) under review-integration/v2. The CLI contract artifacts
|
|
1185
|
+
// are unchanged from v4.5.0. Separately, the provider bundle moved from
|
|
1186
|
+
// 1.5.0 to 1.6.0; the published archive (SHA-256
|
|
1187
|
+
// af87572ac591c005941c898957f4084bd3c38e1afe2fe794e2f308be714096a6)
|
|
1188
|
+
// matches Shell's existing 1.6.0 mirror byte-for-byte.
|
|
1189
|
+
"4.6.0": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1126
1190
|
});
|
|
1127
1191
|
|
|
1128
1192
|
|
|
@@ -2495,7 +2559,12 @@ export class NativeReviewCliV216 {
|
|
|
2495
2559
|
NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE, undefined, false);
|
|
2496
2560
|
}
|
|
2497
2561
|
}
|
|
2498
|
-
|
|
2562
|
+
// The opt-in rides only this client's own contracted STATUS, never a
|
|
2563
|
+
// provider-issued selection submission.
|
|
2564
|
+
const nonBlockingExecutable = request.nonBlockingFindings === true && submittedTokens === undefined
|
|
2565
|
+
? contextExecutable ?? measureStatusSync("resolution", () => this.executablePath(NATIVE_REVIEW_OPERATION.STATUS, false))
|
|
2566
|
+
: undefined;
|
|
2567
|
+
const statusArguments = (nonBlockingFindings ) => submittedTokens === undefined ? [
|
|
2499
2568
|
"review", "status", "--contract", REVIEW_INTEGRATION_CONTRACT, "--cwd", request.cwd,
|
|
2500
2569
|
"--projection", request.projection ?? "workspace",
|
|
2501
2570
|
...nativeUntrackedSelectionArguments(selection),
|
|
@@ -2504,11 +2573,24 @@ export class NativeReviewCliV216 {
|
|
|
2504
2573
|
...(request.agent === undefined ? [] : ["--agent", request.agent]),
|
|
2505
2574
|
...nativeLensSelectionArguments(request),
|
|
2506
2575
|
...requestContextArguments,
|
|
2576
|
+
...(nonBlockingFindings ? ["--non-blocking-findings"] : []),
|
|
2507
2577
|
"--next-transition",
|
|
2508
2578
|
] : ["review", "status", "--cwd", request.cwd, ...submittedTokens, ...forwardedBaseRef, ...forwardedLineage, ...nativeLensSelectionArguments(request), ...requestContextArguments];
|
|
2509
|
-
const
|
|
2510
|
-
|
|
2511
|
-
|
|
2579
|
+
const executable = nonBlockingExecutable ?? contextExecutable;
|
|
2580
|
+
const run = (nonBlockingFindings ) => executable === undefined
|
|
2581
|
+
? this.negotiated(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments(nonBlockingFindings), false, request.signal)
|
|
2582
|
+
: this.invoke(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments(nonBlockingFindings), false, request.signal, executable);
|
|
2583
|
+
const sendNonBlocking = nonBlockingExecutable !== undefined && !nonBlockingFindingsRefused(nonBlockingExecutable);
|
|
2584
|
+
const nonBlockingDigest = sendNonBlocking ? nonBlockingExecutableDigest(nonBlockingExecutable ) : undefined;
|
|
2585
|
+
let execution ;
|
|
2586
|
+
try {
|
|
2587
|
+
execution = await run(sendNonBlocking);
|
|
2588
|
+
} catch (error) {
|
|
2589
|
+
// Only the unknown-flag refusal falls back, once; every other failure is the caller's.
|
|
2590
|
+
if (!sendNonBlocking || !isNativeReviewNonBlockingFindingsUnsupported(error)) throw error;
|
|
2591
|
+
rememberNonBlockingFindingsRefusal(nonBlockingExecutable , nonBlockingDigest);
|
|
2592
|
+
execution = await run(false);
|
|
2593
|
+
}
|
|
2512
2594
|
measureStatusSync("decode", () => assertSupportedNextTransitionOperation(execution.body));
|
|
2513
2595
|
return decode(NATIVE_REVIEW_OPERATION.STATUS, false, () => decodeReviewStatusV3(execution.body));
|
|
2514
2596
|
}
|
|
@@ -703,6 +703,29 @@ function decodeReviewEscalationV1(value , label )
|
|
|
703
703
|
|
|
704
704
|
|
|
705
705
|
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
706
729
|
|
|
707
730
|
|
|
708
731
|
|
|
@@ -2049,8 +2072,9 @@ export function decodeReviewStatusV3(value ) {
|
|
|
2049
2072
|
// branch's contract, ahead of the released v8) adds nothing at this top
|
|
2050
2073
|
// level either: its one addition is the host-mediated role `submission`
|
|
2051
2074
|
// on a next_transition.collect input (gentle-pi#311 P3), gated on v9 in
|
|
2052
|
-
// decodeCollectInput, not here.
|
|
2053
|
-
//
|
|
2075
|
+
// decodeCollectInput, not here. Its one top-level key is the opt-in
|
|
2076
|
+
// `non_blocking_findings` (gentle-ai#6088), decoded below. v3 keeps
|
|
2077
|
+
// rejecting every v5/v6/v7/v8/v9-only field.
|
|
2054
2078
|
const schema = typeof value === "object" && value !== null ? (value ).schema : undefined;
|
|
2055
2079
|
const v9 = schema === "gentle-ai.review-integration.status/v9";
|
|
2056
2080
|
const v8 = v9 || schema === "gentle-ai.review-integration.status/v8";
|
|
@@ -2059,7 +2083,7 @@ export function decodeReviewStatusV3(value ) {
|
|
|
2059
2083
|
const v5 = v6 || schema === "gentle-ai.review-integration.status/v5";
|
|
2060
2084
|
const body = exactRecord(value, "status", [
|
|
2061
2085
|
"schema", "contract", "operation", "applicability", "action", "replayability", "target_identity", "projection", "repair", "candidates",
|
|
2062
|
-
], ["authority", "frozen", "action_disposition", "eligibility", "next_transition", "authority_target_identity", ...(v5 ? ["receipt", "forecast", "repository_context", "validation_request"] : []), ...(v7 ? ["eligible_untracked_inventory", "escalation"] : [])]);
|
|
2086
|
+
], ["authority", "frozen", "action_disposition", "eligibility", "next_transition", "authority_target_identity", ...(v5 ? ["receipt", "forecast", "repository_context", "validation_request"] : []), ...(v7 ? ["eligible_untracked_inventory", "escalation"] : []), ...(v9 ? ["non_blocking_findings"] : [])]);
|
|
2063
2087
|
requireIdentity(body, v9 ? "gentle-ai.review-integration.status/v9" : v8 ? "gentle-ai.review-integration.status/v8" : v7 ? "gentle-ai.review-integration.status/v7" : v6 ? "gentle-ai.review-integration.status/v6" : v5 ? "gentle-ai.review-integration.status/v5" : "gentle-ai.review-integration.status/v3", REVIEW_INTEGRATION_OPERATION.STATUS);
|
|
2064
2088
|
|
|
2065
2089
|
const applicability = enumeration(body.applicability, ["current_target", "unrelated", "ambiguous", "corrupted"] , "status.applicability");
|
|
@@ -2156,6 +2180,16 @@ export function decodeReviewStatusV3(value ) {
|
|
|
2156
2180
|
? sha256(body.eligible_untracked_inventory, "status.eligible_untracked_inventory")
|
|
2157
2181
|
: undefined;
|
|
2158
2182
|
|
|
2183
|
+
// status/v9 opt-in (gentle-ai#6088): the same rule as the provider's schema,
|
|
2184
|
+
// a current compact-v2 authority in correction_required or escalated.
|
|
2185
|
+
let nonBlockingFindings ;
|
|
2186
|
+
if (Object.hasOwn(body, "non_blocking_findings")) {
|
|
2187
|
+
if (authority?.version !== REVIEW_AUTHORITY_VERSION.COMPACT_V2 || (authority.state !== "correction_required" && authority.state !== "escalated")) {
|
|
2188
|
+
throw new TypeError("status.non_blocking_findings requires a current compact-v2 authority in correction_required or escalated");
|
|
2189
|
+
}
|
|
2190
|
+
nonBlockingFindings = decodeReviewNonBlockingFindingsV1(body.non_blocking_findings, "status.non_blocking_findings");
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2159
2193
|
return {
|
|
2160
2194
|
contract: REVIEW_INTEGRATION_CONTRACT,
|
|
2161
2195
|
applicability,
|
|
@@ -2176,10 +2210,29 @@ export function decodeReviewStatusV3(value ) {
|
|
|
2176
2210
|
...(validationRequest === undefined ? {} : { validationRequest }),
|
|
2177
2211
|
...(escalation === undefined ? {} : { escalation }),
|
|
2178
2212
|
...(eligibleUntrackedInventory === undefined ? {} : { eligibleUntrackedInventory }),
|
|
2213
|
+
...(nonBlockingFindings === undefined ? {} : { nonBlockingFindings }),
|
|
2179
2214
|
raw: body,
|
|
2180
2215
|
};
|
|
2181
2216
|
}
|
|
2182
2217
|
|
|
2218
|
+
function decodeReviewNonBlockingFindingsV1(value , label ) {
|
|
2219
|
+
const body = exactRecord(value, label, ["statement", "findings"]);
|
|
2220
|
+
return {
|
|
2221
|
+
statement: nonempty(body.statement, `${label}.statement`),
|
|
2222
|
+
findings: array(body.findings, `${label}.findings`, (entry, itemLabel) => {
|
|
2223
|
+
const finding = exactRecord(entry, itemLabel, ["id", "severity", "disposition", "claim"], ["lens", "location"]);
|
|
2224
|
+
return {
|
|
2225
|
+
id: nonempty(finding.id, `${itemLabel}.id`),
|
|
2226
|
+
...(finding.lens === undefined ? {} : { lens: nonempty(finding.lens, `${itemLabel}.lens`) }),
|
|
2227
|
+
...(finding.location === undefined ? {} : { location: nonempty(finding.location, `${itemLabel}.location`) }),
|
|
2228
|
+
severity: nonempty(finding.severity, `${itemLabel}.severity`),
|
|
2229
|
+
disposition: enumeration(finding.disposition, Object.values(REVIEW_ADVISORY_FINDING_DISPOSITION), `${itemLabel}.disposition`),
|
|
2230
|
+
claim: text(finding.claim, `${itemLabel}.claim`),
|
|
2231
|
+
};
|
|
2232
|
+
}),
|
|
2233
|
+
};
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2183
2236
|
// ---------------------------------------------------------------------------
|
|
2184
2237
|
// consent/v2 — net-new. The typed per-candidate blocking consent question
|
|
2185
2238
|
// emitted by negotiated v2 START when the caller declared --consent relay.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Generated by scripts/build-runtime-modules.mjs. Do not edit.
|
|
2
|
+
// Gentle Tower actions: the closed set of things the web view may ask a floor
|
|
3
|
+
// to do. The server only validates and queues; the session re-validates and
|
|
4
|
+
// executes with its own authority. Inbox: <hub>/../inbox/<sessionId>/, 0700/0600.
|
|
5
|
+
|
|
6
|
+
import { chmodSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
8
|
+
import { TOWER_PATH_MAX } from "./tower-snapshot.mjs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
|
|
11
|
+
export const TOWER_ACTION_MAX_BYTES = 8 * 1024;
|
|
12
|
+
export const TOWER_MESSAGE_MAX_CHARS = 4000;
|
|
13
|
+
/** Modes the web may request. The session lowers at once; a raise needs approval in its own terminal. */
|
|
14
|
+
export const TOWER_PERMISSION_MODES = ["normal", "auto", "yolo", "super-yolo"] ;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/** Actions the session executes; new-floor is handled by the tower server itself. */
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const ID = /^[A-Za-z0-9._-]{1,128}$/;
|
|
28
|
+
const okId = (v ) => typeof v === "string" && ID.test(v) && !v.startsWith(".");
|
|
29
|
+
const text = (v , max ) => (typeof v === "string" && v.trim().length > 0 && v.length <= max ? v.trim() : undefined);
|
|
30
|
+
const exactKeys = (o , keys ) => Object.keys(o).length === keys.length && keys.every((k) => k in o);
|
|
31
|
+
/** Absolute only: POSIX `/...`, a Windows drive `C:\...` / `C:/...`, or a UNC share `\\server\share...`. */
|
|
32
|
+
const ABSOLUTE = /^(?:\/|[A-Za-z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+)/;
|
|
33
|
+
|
|
34
|
+
export function parseTowerAction(value ) {
|
|
35
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return undefined;
|
|
36
|
+
const o = value ;
|
|
37
|
+
if (o.type === "new-floor") {
|
|
38
|
+
const project = o.project;
|
|
39
|
+
if (typeof project !== "string" || !ABSOLUTE.test(project) || project.length > TOWER_PATH_MAX || /[\0\n\r]/.test(project)) return undefined;
|
|
40
|
+
if (o.prompt === undefined) return exactKeys(o, ["type", "project"]) ? { type: "new-floor", project } : undefined;
|
|
41
|
+
const prompt = text(o.prompt, TOWER_MESSAGE_MAX_CHARS);
|
|
42
|
+
return prompt && exactKeys(o, ["type", "project", "prompt"]) ? { type: "new-floor", project, prompt } : undefined;
|
|
43
|
+
}
|
|
44
|
+
if (!okId(o.sessionId)) return undefined;
|
|
45
|
+
const sessionId = o.sessionId;
|
|
46
|
+
switch (o.type) {
|
|
47
|
+
case "message": { const t = text(o.text, TOWER_MESSAGE_MAX_CHARS); return t && exactKeys(o, ["type", "sessionId", "text"]) ? { type: "message", sessionId, text: t } : undefined; }
|
|
48
|
+
case "cancel-helper": return okId(o.helperId) && exactKeys(o, ["type", "sessionId", "helperId"]) ? { type: "cancel-helper", sessionId, helperId: o.helperId } : undefined;
|
|
49
|
+
case "permission": return (TOWER_PERMISSION_MODES ).includes(o.mode) && exactKeys(o, ["type", "sessionId", "mode"]) ? { type: "permission", sessionId, mode: o.mode } : undefined;
|
|
50
|
+
case "review": return typeof o.enabled === "boolean" && exactKeys(o, ["type", "sessionId", "enabled"]) ? { type: "review", sessionId, enabled: o.enabled } : undefined;
|
|
51
|
+
default: return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function towerInboxDir(hubDir , sessionId ) {
|
|
56
|
+
if (!okId(sessionId)) throw new Error(`Gentle Tower: unsafe session id ${JSON.stringify(sessionId)}`);
|
|
57
|
+
return join(dirname(hubDir), "inbox", sessionId);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function privateDir(dir ) {
|
|
61
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
62
|
+
const st = lstatSync(dir);
|
|
63
|
+
if (!st.isDirectory() || st.isSymbolicLink()) throw new Error(`Gentle Tower: inbox is not a directory: ${dir}`);
|
|
64
|
+
if ((st.mode & 0o077) !== 0) chmodSync(dir, 0o700);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let sequence = 0;
|
|
68
|
+
export function writeTowerAction(hubDir , action ) {
|
|
69
|
+
const checked = parseTowerAction(action);
|
|
70
|
+
if (!checked || checked.type === "new-floor") throw new Error("Gentle Tower: invalid action");
|
|
71
|
+
const body = JSON.stringify(checked);
|
|
72
|
+
// The session drops a larger file unread, so it is refused here, before it is queued.
|
|
73
|
+
if (Buffer.byteLength(body) > TOWER_ACTION_MAX_BYTES) throw new Error(`Gentle Tower: action too large (${Buffer.byteLength(body)} bytes)`);
|
|
74
|
+
const dir = towerInboxDir(hubDir, checked.sessionId);
|
|
75
|
+
privateDir(dir);
|
|
76
|
+
const id = `${Date.now().toString().padStart(15, "0")}-${String(sequence++ % 1e6).padStart(6, "0")}-${randomBytes(6).toString("hex")}`;
|
|
77
|
+
const temp = join(dir, `.${id}.tmp`);
|
|
78
|
+
writeFileSync(temp, body, { mode: 0o600, flag: "wx" });
|
|
79
|
+
renameSync(temp, join(dir, `${id}.json`));
|
|
80
|
+
return id;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Valid actions addressed to this session, oldest first; every file read is removed. */
|
|
84
|
+
export function consumeTowerActions(hubDir , sessionId ) {
|
|
85
|
+
const dir = towerInboxDir(hubDir, sessionId);
|
|
86
|
+
let names ;
|
|
87
|
+
try { names = readdirSync(dir).filter((n) => n.endsWith(".json") && !n.startsWith(".")).sort(); } catch { return []; }
|
|
88
|
+
const out = [];
|
|
89
|
+
for (const name of names) {
|
|
90
|
+
const path = join(dir, name);
|
|
91
|
+
try {
|
|
92
|
+
const st = lstatSync(path);
|
|
93
|
+
if (st.isFile() && st.size <= TOWER_ACTION_MAX_BYTES) {
|
|
94
|
+
const action = parseTowerAction(JSON.parse(readFileSync(path, "utf8")));
|
|
95
|
+
if (action && action.type !== "new-floor" && action.sessionId === sessionId) out.push(action);
|
|
96
|
+
}
|
|
97
|
+
} catch { /* dropped */ }
|
|
98
|
+
rmSync(path, { force: true });
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Generated by scripts/build-runtime-modules.mjs. Do not edit.
|
|
2
|
+
// Gentle Tower hub: one private JSON file per live session, written atomically.
|
|
3
|
+
// Directory 0700, files 0600, write to a temp file then rename (repo convention).
|
|
4
|
+
|
|
5
|
+
import { chmodSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { isTowerSnapshot, TOWER_SNAPSHOT_MAX_BYTES, } from "./tower-snapshot.mjs";
|
|
9
|
+
|
|
10
|
+
export { TOWER_SNAPSHOT_MAX_BYTES };
|
|
11
|
+
|
|
12
|
+
/** `GENTLE_TOWER_HOME` overrides the hub for tests and isolated runs. */
|
|
13
|
+
export function towerHubDir(env = process.env, home = homedir()) {
|
|
14
|
+
return env.GENTLE_TOWER_HOME || join(home, ".gentle-shell", "tower", "sessions");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function safeId(sessionId ) {
|
|
18
|
+
if (!/^[A-Za-z0-9._-]{1,128}$/.test(sessionId) || sessionId.startsWith(".")) throw new Error(`Gentle Tower: unsafe session id ${JSON.stringify(sessionId)}`);
|
|
19
|
+
return sessionId;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function privateDir(dir ) {
|
|
23
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
24
|
+
const st = lstatSync(dir);
|
|
25
|
+
if (!st.isDirectory() || st.isSymbolicLink()) throw new Error(`Gentle Tower: hub is not a directory: ${dir}`);
|
|
26
|
+
if ((st.mode & 0o077) !== 0) chmodSync(dir, 0o700);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function writeTowerSnapshot(dir , snapshot ) {
|
|
30
|
+
const id = safeId(snapshot.sessionId);
|
|
31
|
+
const body = JSON.stringify(snapshot);
|
|
32
|
+
if (Buffer.byteLength(body) > TOWER_SNAPSHOT_MAX_BYTES) throw new Error(`Gentle Tower: snapshot too large (${Buffer.byteLength(body)} bytes)`);
|
|
33
|
+
privateDir(dir);
|
|
34
|
+
const target = join(dir, `${id}.json`);
|
|
35
|
+
const temp = join(dir, `.${id}.${process.pid}.${Date.now()}.tmp`);
|
|
36
|
+
try {
|
|
37
|
+
writeFileSync(temp, body, { mode: 0o600, flag: "wx" });
|
|
38
|
+
renameSync(temp, target);
|
|
39
|
+
} finally {
|
|
40
|
+
rmSync(temp, { force: true });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function removeTowerSnapshot(dir , sessionId ) {
|
|
45
|
+
rmSync(join(dir, `${safeId(sessionId)}.json`), { force: true });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function alive(pid ) {
|
|
49
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) return true;
|
|
50
|
+
try { process.kill(pid, 0); return true; } catch (e) { return (e ).code === "EPERM"; }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Snapshots whose publishing process is still running (one killed without shutdown left a frozen file). */
|
|
54
|
+
export function readLiveTowerSnapshots(dir ) {
|
|
55
|
+
return readTowerSnapshots(dir).filter((s) => alive(s.pid));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Every valid snapshot in the hub; unreadable, oversized or foreign files are skipped. */
|
|
59
|
+
export function readTowerSnapshots(dir ) {
|
|
60
|
+
let names ;
|
|
61
|
+
try { names = readdirSync(dir); } catch { return []; }
|
|
62
|
+
const out = [];
|
|
63
|
+
for (const name of names.sort()) {
|
|
64
|
+
if (!name.endsWith(".json") || name.startsWith(".")) continue;
|
|
65
|
+
try {
|
|
66
|
+
const path = join(dir, name);
|
|
67
|
+
const st = lstatSync(path);
|
|
68
|
+
if (!st.isFile() || st.size > TOWER_SNAPSHOT_MAX_BYTES) continue;
|
|
69
|
+
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
70
|
+
if (isTowerSnapshot(value) && `${value.sessionId}.json` === name) out.push(value);
|
|
71
|
+
} catch { /* skip */ }
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Generated by scripts/build-runtime-modules.mjs. Do not edit.
|
|
2
|
+
// Gentle Tower: open a new floor = start a new Gentle Shell session in a new
|
|
3
|
+
// terminal window, in a project already in the tower. Fixed command, every
|
|
4
|
+
// value quoted for the shell that reads it (sh on macOS/Linux, cmd on
|
|
5
|
+
// Windows); the first message is one argument and never reaches a command line.
|
|
6
|
+
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { chmodSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
|
|
12
|
+
/** POSIX single-quote: safe for any byte except NUL. */
|
|
13
|
+
export function shellQuote(value ) {
|
|
14
|
+
if (value.includes("\0")) throw new Error("Gentle Tower: NUL in a shell argument");
|
|
15
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export function buildLaunchScript(spec ) {
|
|
21
|
+
// `--` for gentle-shell, then `--` for pi: a message starting with "-" is never an option.
|
|
22
|
+
const args = [spec.node, spec.launcher, ...(spec.prompt ? ["--", "--", spec.prompt] : [])].map(shellQuote).join(" ");
|
|
23
|
+
// The script removes itself first: it runs once and leaves no copy of the message behind.
|
|
24
|
+
return `#!/bin/sh\nrm -f "$0"\ncd ${shellQuote(spec.cwd)} && exec ${args}\n`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** cmd reads at most 8191 characters per line. */
|
|
28
|
+
const CMD_LINE_MAX = 8191;
|
|
29
|
+
|
|
30
|
+
function cmdSafe(value , what , quotes ) {
|
|
31
|
+
// A line break ends the command; other control characters have no safe spelling in a batch file.
|
|
32
|
+
if (/[\0-\x08\n-\x1f\x7f]/.test(value)) throw new Error(`Gentle Tower: the ${what} has a line break or control character, which cmd cannot pass safely`);
|
|
33
|
+
if (!quotes && value.includes('"')) throw new Error(`Gentle Tower: the ${what} has a double quote, which cmd cannot pass safely`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* One argument for a batch-file line, read first by cmd and then by the C runtime of the program.
|
|
39
|
+
* Inside double quotes cmd keeps `& | < > ^ ( )` literal; `%` is the one character a batch file
|
|
40
|
+
* still expands there, so it is written `%%`. A quote is written `""`: cmd stays inside the quotes and
|
|
41
|
+
* the C runtime reads one literal `"`; backslashes before a quote or at the end are doubled for it.
|
|
42
|
+
*/
|
|
43
|
+
function cmdArg(value ) {
|
|
44
|
+
const escaped = value.replace(/(\\*)"/g, '$1$1""').replace(/(\\+)$/, "$1$1");
|
|
45
|
+
return `"${escaped.replace(/%/g, "%%")}"`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The Windows launcher (a `.cmd` file, CRLF). Delayed expansion is turned off so `!` stays literal,
|
|
50
|
+
* the code page is UTF-8 so the message keeps its accents, and the script deletes itself at the end:
|
|
51
|
+
* a running batch file cannot remove itself before its last line.
|
|
52
|
+
*/
|
|
53
|
+
export function buildWindowsLaunchScript(spec ) {
|
|
54
|
+
const cwd = cmdSafe(spec.cwd, "project folder", false);
|
|
55
|
+
const node = cmdSafe(spec.node, "Node path", false);
|
|
56
|
+
const launcher = cmdSafe(spec.launcher, "launcher path", false);
|
|
57
|
+
const prompt = spec.prompt === undefined ? undefined : cmdSafe(spec.prompt, "first message", true);
|
|
58
|
+
// `--` for gentle-shell, then `--` for pi: a message starting with "-" is never an option.
|
|
59
|
+
const args = [node, launcher, ...(prompt ? ["--", "--", prompt] : [])].map(cmdArg).join(" ");
|
|
60
|
+
const run = `cd /d "${cwd.replace(/%/g, "%%")}" && ${args}`;
|
|
61
|
+
if (run.length > CMD_LINE_MAX) throw new Error(`Gentle Tower: the command is longer than cmd's ${CMD_LINE_MAX}-character line limit`);
|
|
62
|
+
return ["@echo off", "setlocal DisableDelayedExpansion", "chcp 65001 >nul", run, `(goto) 2>nul & del "%~f0"`, ""].join("\r\n");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Opens the script in a new terminal window: macOS Terminal, the Linux default terminal
|
|
69
|
+
* (x-terminal-emulator), or on Windows Windows Terminal, else a cmd window. Never throws: every failure is a rejection.
|
|
70
|
+
*/
|
|
71
|
+
export async function launchInTerminal(spec , deps = {}) {
|
|
72
|
+
const platform = deps.platform ?? process.platform;
|
|
73
|
+
const run = deps.spawn ?? spawn;
|
|
74
|
+
if (platform === "win32") {
|
|
75
|
+
const body = buildWindowsLaunchScript(spec);
|
|
76
|
+
const dir = mkdtempSync(join(deps.tmpRoot ?? tmpdir(), "gentle-tower-floor-"));
|
|
77
|
+
writeFileSync(join(dir, "new-floor.cmd"), body, { mode: 0o700, flag: "wx" });
|
|
78
|
+
// Every starter runs in the script's folder and names it by a fixed relative name, so no
|
|
79
|
+
// user text and no path ever reaches a command line that cmd parses.
|
|
80
|
+
const starter = (cmd , args , verbatim ) => new Promise ((resolve, reject) => {
|
|
81
|
+
const child = run(cmd, args, { stdio: "ignore", cwd: dir, windowsVerbatimArguments: verbatim });
|
|
82
|
+
child.once("error", reject);
|
|
83
|
+
// wt.exe and `cmd /c start` hand the window off and exit: their exit code is the answer.
|
|
84
|
+
child.once("exit", (code) => (code === 0 ? resolve() : reject(new Error(`Gentle Tower: ${cmd} exited with ${code}`))));
|
|
85
|
+
});
|
|
86
|
+
// Windows Terminal splits its own arguments on `;`, so a folder with one goes straight to cmd.
|
|
87
|
+
if (!dir.includes(";")) {
|
|
88
|
+
try {
|
|
89
|
+
return await starter("wt.exe", ["-d", dir, "cmd", "/d", "/c", ".\\new-floor.cmd"], false);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
// Only a missing Windows Terminal falls back; one that started and failed is not retried in a second window.
|
|
92
|
+
if ((error ).code !== "ENOENT") throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Verbatim: the empty window title `""` must reach `start` as written.
|
|
96
|
+
return starter("cmd.exe", ["/d", "/c", "start", '""', "cmd", "/d", "/k", ".\\new-floor.cmd"], true);
|
|
97
|
+
}
|
|
98
|
+
const dir = mkdtempSync(join(deps.tmpRoot ?? tmpdir(), "gentle-tower-floor-"));
|
|
99
|
+
chmodSync(dir, 0o700);
|
|
100
|
+
const script = join(dir, "new-floor.command");
|
|
101
|
+
writeFileSync(script, buildLaunchScript(spec), { mode: 0o700, flag: "wx" });
|
|
102
|
+
const mac = platform === "darwin";
|
|
103
|
+
const [cmd, args] = mac ? ["open", ["-a", "Terminal", script]] : ["x-terminal-emulator", ["-e", script]];
|
|
104
|
+
await new Promise ((resolve, reject) => {
|
|
105
|
+
const child = run(cmd, args , { stdio: "ignore", detached: !mac });
|
|
106
|
+
child.once("error", reject);
|
|
107
|
+
// `open` hands the script to Terminal and exits: its exit code is the answer.
|
|
108
|
+
// The Linux terminal is the window itself and keeps running, so starting it is enough.
|
|
109
|
+
if (mac) child.once("exit", (code) => (code === 0 ? resolve() : reject(new Error(`Gentle Tower: open exited with ${code}`))));
|
|
110
|
+
else child.once("spawn", () => { child.unref(); resolve(); });
|
|
111
|
+
});
|
|
112
|
+
}
|