gentle-pi 4.5.1 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -15
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +8 -1
- package/assets/agents/gentle-ai-worker.md +4 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +162 -0
- package/assets/orchestrator-delegation-reference.md +7 -7
- package/assets/orchestrator-delegation.md +3 -3
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +14 -8
- package/assets/orchestrator.md +11 -11
- package/bin/gentle-shell.mjs +225 -82
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +35 -7
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +22 -0
- package/docs/gentle-shell.md +113 -25
- package/docs/install-wizard.md +2 -2
- package/docs/mcp-status.md +52 -0
- package/docs/permission-modes.md +9 -4
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +154 -50
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +46 -0
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +2 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +803 -84
- package/extensions/gentle-ai.ts +2491 -596
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +895 -120
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +59 -23
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/history/store.ts +18 -12
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +210 -21
- package/extensions/startup-banner.ts +69 -10
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +161 -3
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +58 -3
- package/lib/agents-history.ts +24 -5
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +287 -15
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/bridge-cost.ts +28 -0
- package/lib/card-content-policy.ts +8 -6
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +154 -25
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +64 -0
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +47 -8
- package/lib/herdr-activity.ts +23 -5
- package/lib/herdr-busy.ts +45 -0
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +282 -132
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-view.ts +198 -11
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +32 -6
- package/lib/nan-provider.ts +3 -2
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +103 -21
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +225 -18
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +85 -44
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +29 -8
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-repository.ts +5 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +107 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +269 -72
- package/lib/shell-card.ts +26 -6
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +163 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +198 -53
- package/lib/shell-sidebar.ts +61 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +79 -1
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +67 -12
- package/lib/visual-customize-view.ts +373 -40
- package/lib/visual-layout-preview.ts +47 -0
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +68 -16
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +46 -7
- package/runtime/native-review-cli.mjs +100 -18
- package/runtime/review-integration-v2.mjs +29 -8
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +6 -6
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/pi-update.mjs +113 -3
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +41 -13
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +14 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +4 -4
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +345 -4
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +47 -0
- package/tests/bundled-install.test.ts +36 -9
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +80 -5
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +300 -3
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +8 -7
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -14
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +172 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1491 -38
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +151 -0
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +1101 -52
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +80 -3
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +172 -26
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +93 -10
- package/tests/gentle-shell.test.ts +1937 -66
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +67 -4
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +132 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +298 -4
- package/tests/installer-posix-bootstrap.test.ts +68 -6
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-view.test.ts +260 -6
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider.test.ts +4 -4
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +22 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +6 -6
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +133 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +169 -14
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/persona-reply-language.test.ts +20 -1
- package/tests/pi-update-launcher.test.ts +40 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +84 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +265 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +52 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +381 -11
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +183 -6
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +250 -0
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +34 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +255 -0
- package/tests/shell-bar.test.ts +274 -72
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +360 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +13 -1
- package/tests/shell-sidebar-layout.test.ts +447 -44
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +902 -2
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +209 -2
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +50 -4
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +134 -8
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +95 -8
- package/tests/visual-customize-view.test.ts +818 -9
- package/tests/visual-layout-preview.test.ts +42 -0
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +114 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +57 -15
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +39 -20
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -3,7 +3,171 @@ import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync }
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import test from "node:test";
|
|
6
|
-
import { applySavedModelConfig, readModelConfig, readModelConfigAsync } from "../extensions/gentle-ai.ts";
|
|
6
|
+
import { __testing, applySavedModelConfig, readModelConfig, readModelConfigAsync } from "../extensions/gentle-ai.ts";
|
|
7
|
+
import {
|
|
8
|
+
localProfilePinPath,
|
|
9
|
+
setProfilePinWorktreeResolverForTesting,
|
|
10
|
+
writeProfilePinSync,
|
|
11
|
+
} from "../lib/agent-profile-pin.ts";
|
|
12
|
+
|
|
13
|
+
test("coincident global and legacy paths preserve invalid-global status", async (t) => {
|
|
14
|
+
const cwd = mkdtempSync(join(tmpdir(), "gentle-pi-model-coincidence-"));
|
|
15
|
+
const configHome = join(cwd, ".pi", "gentle-ai");
|
|
16
|
+
mkdirSync(configHome, { recursive: true });
|
|
17
|
+
const previous = process.env.GENTLE_PI_CONFIG_HOME;
|
|
18
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
19
|
+
t.after(() => {
|
|
20
|
+
if (previous === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
21
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previous;
|
|
22
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
23
|
+
});
|
|
24
|
+
const path = join(configHome, "models.json");
|
|
25
|
+
assert.equal(path, join(cwd, ".pi", "gentle-ai", "models.json"));
|
|
26
|
+
writeFileSync(path, "{");
|
|
27
|
+
const results = [__testing.readSavedModelConfig(cwd), await __testing.readSavedModelConfigAsync(cwd)];
|
|
28
|
+
assert.deepEqual(results, [ { status: "invalid", path }, { status: "invalid", path } ]);
|
|
29
|
+
assert.deepEqual(readModelConfig(cwd), {});
|
|
30
|
+
assert.deepEqual(await readModelConfigAsync(cwd), {});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("bootstrapped active profile preserves legacy routing while global models are missing", async (t) => {
|
|
34
|
+
const cwd = mkdtempSync(join(tmpdir(), "gentle-pi-model-bootstrap-"));
|
|
35
|
+
const configHome = join(cwd, "global");
|
|
36
|
+
const projectHome = join(cwd, ".pi", "gentle-ai");
|
|
37
|
+
mkdirSync(configHome, { recursive: true });
|
|
38
|
+
mkdirSync(projectHome, { recursive: true });
|
|
39
|
+
const previous = process.env.GENTLE_PI_CONFIG_HOME;
|
|
40
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
41
|
+
t.after(() => {
|
|
42
|
+
if (previous === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
43
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previous;
|
|
44
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
45
|
+
});
|
|
46
|
+
const config = { "review-risk": { model: "openai/gpt-5" } };
|
|
47
|
+
writeFileSync(join(projectHome, "models.json"), JSON.stringify(config));
|
|
48
|
+
writeFileSync(join(configHome, "profiles.json"), JSON.stringify({
|
|
49
|
+
kind: "gentle-pi.agent_model_profiles", version: 1, active: "current", profiles: { current: config },
|
|
50
|
+
}));
|
|
51
|
+
const expected = { "review-risk": { model: "openai/gpt-5", thinking: undefined } };
|
|
52
|
+
assert.deepEqual({ sync: readModelConfig(cwd), async: await readModelConfigAsync(cwd) }, {
|
|
53
|
+
sync: expected, async: expected,
|
|
54
|
+
});
|
|
55
|
+
assert.throws(() => statSync(join(configHome, "models.json")), { code: "ENOENT" });
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("active profile omission is preserved while global models are still missing", async (t) => {
|
|
59
|
+
const cwd = mkdtempSync(join(tmpdir(), "gentle-pi-model-profile-missing-"));
|
|
60
|
+
const configHome = join(cwd, "global");
|
|
61
|
+
const projectHome = join(cwd, ".pi", "gentle-ai");
|
|
62
|
+
mkdirSync(configHome, { recursive: true });
|
|
63
|
+
mkdirSync(projectHome, { recursive: true });
|
|
64
|
+
const previous = process.env.GENTLE_PI_CONFIG_HOME;
|
|
65
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
66
|
+
t.after(() => {
|
|
67
|
+
if (previous === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
68
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previous;
|
|
69
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
70
|
+
});
|
|
71
|
+
writeFileSync(join(configHome, "profiles.json"), JSON.stringify({
|
|
72
|
+
kind: "gentle-pi.agent_model_profiles", version: 1, active: "team", profiles: { team: {} },
|
|
73
|
+
}));
|
|
74
|
+
writeFileSync(join(projectHome, "models.json"), JSON.stringify({ "review-risk": { model: "openai/gpt-5" } }));
|
|
75
|
+
assert.deepEqual({ sync: readModelConfig(cwd), async: await readModelConfigAsync(cwd) }, { sync: {}, async: {} });
|
|
76
|
+
assert.throws(() => statSync(join(configHome, "models.json")), { code: "ENOENT" });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("active profile omission prevents stale legacy materialization while global models are still missing", async (t) => {
|
|
80
|
+
const cwd = mkdtempSync(join(tmpdir(), "gentle-pi-model-profile-missing-apply-"));
|
|
81
|
+
const configHome = join(cwd, "global");
|
|
82
|
+
const projectHome = join(cwd, ".pi", "gentle-ai");
|
|
83
|
+
mkdirSync(configHome, { recursive: true });
|
|
84
|
+
mkdirSync(projectHome, { recursive: true });
|
|
85
|
+
const previous = process.env.GENTLE_PI_CONFIG_HOME;
|
|
86
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
87
|
+
t.after(() => {
|
|
88
|
+
if (previous === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
89
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previous;
|
|
90
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
91
|
+
});
|
|
92
|
+
writeFileSync(join(configHome, "profiles.json"), JSON.stringify({
|
|
93
|
+
kind: "gentle-pi.agent_model_profiles", version: 1, active: "team", profiles: { team: {} },
|
|
94
|
+
}));
|
|
95
|
+
writeFileSync(join(projectHome, "models.json"), JSON.stringify({ "review-risk": { model: "openai/gpt-5" } }));
|
|
96
|
+
const materialized: unknown[] = [];
|
|
97
|
+
const result = await applySavedModelConfig({ cwd } as Parameters<typeof applySavedModelConfig>[0], async (target, config) => {
|
|
98
|
+
assert.equal(target, cwd);
|
|
99
|
+
materialized.push(config);
|
|
100
|
+
return { updated: 0, skipped: 0 };
|
|
101
|
+
});
|
|
102
|
+
assert.deepEqual({ sync: readModelConfig(cwd), async: await readModelConfigAsync(cwd), materialized, result }, {
|
|
103
|
+
sync: {}, async: {}, materialized: [{}], result: { updated: 0, skipped: 0 },
|
|
104
|
+
});
|
|
105
|
+
assert.throws(() => statSync(join(configHome, "models.json")), { code: "ENOENT" });
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("active profile omission prevents stale legacy routing reads and materialization", async (t) => {
|
|
109
|
+
const cwd = mkdtempSync(join(tmpdir(), "gentle-pi-model-profile-"));
|
|
110
|
+
const configHome = join(cwd, "global");
|
|
111
|
+
const projectHome = join(cwd, ".pi", "gentle-ai");
|
|
112
|
+
mkdirSync(configHome, { recursive: true });
|
|
113
|
+
mkdirSync(projectHome, { recursive: true });
|
|
114
|
+
const previous = process.env.GENTLE_PI_CONFIG_HOME;
|
|
115
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
116
|
+
t.after(() => {
|
|
117
|
+
if (previous === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
118
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previous;
|
|
119
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
120
|
+
});
|
|
121
|
+
writeFileSync(join(configHome, "profiles.json"), JSON.stringify({
|
|
122
|
+
kind: "gentle-pi.agent_model_profiles", version: 1, active: "team", profiles: { team: {} },
|
|
123
|
+
}));
|
|
124
|
+
writeFileSync(join(configHome, "models.json"), "{}");
|
|
125
|
+
writeFileSync(join(projectHome, "models.json"), JSON.stringify({ "review-risk": { model: "openai/gpt-5" } }));
|
|
126
|
+
const materialized: unknown[] = [];
|
|
127
|
+
const result = await applySavedModelConfig({ cwd } as Parameters<typeof applySavedModelConfig>[0], async (target, config) => {
|
|
128
|
+
assert.equal(target, cwd);
|
|
129
|
+
materialized.push(config);
|
|
130
|
+
return { updated: 0, skipped: 0 };
|
|
131
|
+
});
|
|
132
|
+
assert.deepEqual({ sync: readModelConfig(cwd), async: await readModelConfigAsync(cwd), materialized, result }, {
|
|
133
|
+
sync: {}, async: {}, materialized: [{}], result: { updated: 0, skipped: 0 },
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// gentle-shell#2477 regression: a pinned or active profile replaced the legacy
|
|
138
|
+
// project source even when no model config existed at all, so a session that
|
|
139
|
+
// had deliberately cleared its profile read the pin back as saved routing. The
|
|
140
|
+
// profile snapshot only stands in for a legacy file that is actually there.
|
|
141
|
+
test("a pin or active profile invents no saved routing while no model config exists", async (t) => {
|
|
142
|
+
const previous = process.env.GENTLE_PI_CONFIG_HOME;
|
|
143
|
+
t.after(() => {
|
|
144
|
+
setProfilePinWorktreeResolverForTesting();
|
|
145
|
+
if (previous === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
146
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previous;
|
|
147
|
+
});
|
|
148
|
+
const chosen = { "review-risk": { model: "openai/pinned-risk" } };
|
|
149
|
+
for (const target of ["pinned", "active"] as const) {
|
|
150
|
+
const cwd = mkdtempSync(join(tmpdir(), `gentle-pi-model-${target}-no-config-`));
|
|
151
|
+
const configHome = join(cwd, "global");
|
|
152
|
+
const projectHome = join(cwd, ".pi", "gentle-ai");
|
|
153
|
+
mkdirSync(configHome, { recursive: true });
|
|
154
|
+
mkdirSync(projectHome, { recursive: true });
|
|
155
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
156
|
+
t.after(() => rmSync(cwd, { recursive: true, force: true }));
|
|
157
|
+
writeFileSync(join(configHome, "profiles.json"), JSON.stringify({
|
|
158
|
+
kind: "gentle-pi.agent_model_profiles", version: 1, ...(target === "active" ? { active: "chosen" } : {}), profiles: { chosen },
|
|
159
|
+
}));
|
|
160
|
+
const identity = { root: join(cwd, "worktree"), commonDir: join(cwd, "git-common") };
|
|
161
|
+
mkdirSync(identity.root, { recursive: true });
|
|
162
|
+
mkdirSync(identity.commonDir, { recursive: true });
|
|
163
|
+
setProfilePinWorktreeResolverForTesting(() => identity);
|
|
164
|
+
if (target === "pinned") writeProfilePinSync(localProfilePinPath(identity.commonDir), "chosen");
|
|
165
|
+
assert.deepEqual({ sync: readModelConfig(cwd), async: await readModelConfigAsync(cwd) }, { sync: {}, async: {} }, `${target} routing stays empty`);
|
|
166
|
+
assert.deepEqual(__testing.readSavedModelConfig(cwd), { status: "missing" }, `${target} saved routing stays missing`);
|
|
167
|
+
assert.deepEqual(await __testing.readSavedModelConfigAsync(cwd), { status: "missing" }, `${target} async saved routing stays missing`);
|
|
168
|
+
assert.throws(() => statSync(join(configHome, "models.json")), { code: "ENOENT" }, `reading never writes the global file`);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
7
171
|
|
|
8
172
|
test("model routing authority normalizes and preserves sync/async source status", async (t) => {
|
|
9
173
|
const loaded = await import("../lib/model-routing-authority.ts").then(
|
|
@@ -110,12 +274,24 @@ test("model routing authority normalizes and preserves sync/async source status"
|
|
|
110
274
|
path: invalidGlobalPath,
|
|
111
275
|
});
|
|
112
276
|
|
|
277
|
+
// A present global config must merge with, not fully shadow, the legacy project
|
|
278
|
+
// config (gentle-shell#2163): project-only keys survive, same-name keys prefer global.
|
|
279
|
+
const globalWithProjectKeyOverride = join(globalDir, "global-with-project-key.json");
|
|
280
|
+
writeFileSync(globalWithProjectKeyOverride, JSON.stringify({ project: "openai/gpt-5" }));
|
|
281
|
+
const invalidProjectPath = join(projectConfigDir, "invalid.json");
|
|
282
|
+
writeFileSync(invalidProjectPath, "[]");
|
|
283
|
+
|
|
113
284
|
const sourceCases = [
|
|
114
285
|
[missingPath, missingPath, { status: "missing" }],
|
|
115
286
|
[missingPath, projectPath, { status: "valid", config: { project: { model: "google/gemini" } } }],
|
|
116
|
-
[
|
|
287
|
+
[
|
|
288
|
+
validGlobalPath, projectPath,
|
|
289
|
+
{ status: "valid", config: { ...validSync.status === "valid" ? validSync.config : {}, project: { model: "google/gemini" } } },
|
|
290
|
+
],
|
|
291
|
+
[globalWithProjectKeyOverride, projectPath, { status: "valid", config: { project: { model: "openai/gpt-5" } } }],
|
|
117
292
|
[missingPath, invalidGlobalPath, { status: "invalid", path: invalidGlobalPath }],
|
|
118
293
|
[invalidGlobalPath, projectPath, { status: "invalid", path: invalidGlobalPath }],
|
|
294
|
+
[validGlobalPath, invalidProjectPath, { status: "invalid", path: invalidProjectPath }],
|
|
119
295
|
] as const;
|
|
120
296
|
for (const [globalSource, projectSource, expected] of sourceCases) {
|
|
121
297
|
assert.deepEqual(authority.readSavedModelConfig(globalSource, projectSource), expected);
|
|
@@ -192,7 +192,7 @@ test("initial catalog contains all seven documented chat models with configured
|
|
|
192
192
|
assert.deepEqual(model?.input, ["text", "image"]);
|
|
193
193
|
assert.equal(model?.contextWindow, 1_000_000);
|
|
194
194
|
assert.equal(models.length, 7);
|
|
195
|
-
assert.equal(model?.maxTokens,
|
|
195
|
+
assert.equal(model?.maxTokens, 131_072);
|
|
196
196
|
assert.deepEqual(model?.cost, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
197
197
|
});
|
|
198
198
|
|
|
@@ -211,10 +211,10 @@ test("only NaN DeepSeek serializes its unchanged output cap as max_tokens", asyn
|
|
|
211
211
|
},
|
|
212
212
|
});
|
|
213
213
|
assert.equal(result.stopReason, "stop");
|
|
214
|
-
assert.equal(body?.max_tokens,
|
|
214
|
+
assert.equal(body?.max_tokens, 131_072);
|
|
215
215
|
assert.ok(!Object.hasOwn(body!, "max_completion_tokens"));
|
|
216
216
|
assert.equal(body?.reasoning_effort, "minimal");
|
|
217
|
-
assert.equal(model.maxTokens,
|
|
217
|
+
assert.equal(model.maxTokens, 131_072);
|
|
218
218
|
assert.equal(model.compat?.maxTokensField, "max_tokens");
|
|
219
219
|
assert.ok(models.filter((candidate) => candidate.id !== model.id).every((candidate) => candidate.compat === undefined));
|
|
220
220
|
});
|
|
@@ -347,7 +347,7 @@ test("live discovery uses the key-scoped endpoint and replaces the fallback with
|
|
|
347
347
|
test("known chat models retain documented capabilities without advertising audio", async () => {
|
|
348
348
|
const expected = [
|
|
349
349
|
["glm5.3", 1_000_000, ["text", "image"], 32_768],
|
|
350
|
-
["deepseek-v4-flash", 1_000_000, ["text", "image"],
|
|
350
|
+
["deepseek-v4-flash", 1_000_000, ["text", "image"], 131_072],
|
|
351
351
|
["glm5.3-flash", 1_000_000, ["text", "image"], 32_768],
|
|
352
352
|
["qwen3.8-flash", 1_048_576, ["text", "image"], 131_000],
|
|
353
353
|
["mimo-v2.6-flash", 1_000_000, ["text", "image"], 32_768],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test, { mock } from "node:test";
|
|
3
3
|
import {
|
|
4
|
-
KeybindingsManager, stripTerminalSequences, Text, TUI_KEYBINDINGS,
|
|
5
|
-
type Component, type TuiMouseEvent, visibleWidth,
|
|
4
|
+
KeybindingsManager, stripTerminalSequences, Text, TUI_KEYBINDINGS, TuiAltScreen,
|
|
5
|
+
type Component, type Terminal, type TuiMouseEvent, visibleWidth,
|
|
6
6
|
} from "@earendil-works/pi-tui";
|
|
7
7
|
import { NativeChoiceList } from "../lib/native-choice-list.ts";
|
|
8
8
|
import {
|
|
@@ -85,6 +85,81 @@ test("native choice list presents one hovered wrapped option without changing se
|
|
|
85
85
|
assert.doesNotMatch(list.render(56).join("\n"), new RegExp(hoverBackground.replace(/[\[\]]/g, "\\$&")));
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
+
const warningForeground = "\u001b[33m";
|
|
89
|
+
const warningTheme = {
|
|
90
|
+
...theme,
|
|
91
|
+
fg: (role: string, text: string) => role === "warning" ? `${warningForeground}${text}\u001b[39m` : text,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
test("native choice hover uses the shared warning foreground without selecting or activating", () => {
|
|
95
|
+
const items = [
|
|
96
|
+
{ id: "opaque-first", label: "First", description: "First detail." },
|
|
97
|
+
{ id: "opaque-second", label: "Second", description: "Second detail." },
|
|
98
|
+
];
|
|
99
|
+
const list = new NativeChoiceList(items, warningTheme);
|
|
100
|
+
const selected: string[] = [];
|
|
101
|
+
list.onSelect = (item) => selected.push(item.id);
|
|
102
|
+
let { lines, row } = layout(list, 40, "Second");
|
|
103
|
+
assert.equal(list.handleMouse(event("move", "none", row, 40, lines.length))?.render, true);
|
|
104
|
+
lines = list.render(40);
|
|
105
|
+
assert.match(lines[row]!, /\x1b\[33mSecond\x1b\[39m/);
|
|
106
|
+
assert.ok(!lines[row]!.includes(hoverBackground), "hover does not use toolPendingBg");
|
|
107
|
+
assert.equal(list.getSelectedItem(), items[0]);
|
|
108
|
+
assert.deepEqual(selected, []);
|
|
109
|
+
assert.equal(list.handleMouse(event("move", "none", row, 40, lines.length))?.render, false);
|
|
110
|
+
list.handleInput("\r");
|
|
111
|
+
assert.deepEqual(selected, ["opaque-first"], "Enter still selects the keyboard item");
|
|
112
|
+
list.invalidate();
|
|
113
|
+
assert.doesNotMatch(list.render(40).join("\n"), /\x1b\[33m/);
|
|
114
|
+
({ lines, row } = layout(list, 40, "Second"));
|
|
115
|
+
list.handleMouse(event("move", "none", row, 40, lines.length));
|
|
116
|
+
list.dispose();
|
|
117
|
+
assert.equal(list.handleMouse(event("click", "left", row, 40, lines.length)), undefined);
|
|
118
|
+
list.handleInput("\r");
|
|
119
|
+
assert.deepEqual(selected, ["opaque-first"]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("choice overlay uses real SGR coordinates and documents the outside-overlay leave boundary", () => {
|
|
123
|
+
let input: ((data: string) => void) | undefined;
|
|
124
|
+
const terminal: Terminal = {
|
|
125
|
+
start(onInput) { input = onInput; }, stop() {}, async drainInput() {}, write() {},
|
|
126
|
+
get columns() { return 120; }, get rows() { return 30; }, get kittyProtocolActive() { return false; },
|
|
127
|
+
moveBy() {}, hideCursor() {}, showCursor() {}, clearLine() {}, clearFromCursor() {}, clearScreen() {},
|
|
128
|
+
setTitle() {}, setProgress() {}, setProgramStatus() {},
|
|
129
|
+
};
|
|
130
|
+
const list = new NativeChoiceList([{ id: "first", label: "First" }, { id: "second", label: "Second" }], warningTheme);
|
|
131
|
+
const selected: string[] = [];
|
|
132
|
+
list.onSelect = (item) => selected.push(item.id);
|
|
133
|
+
const root = createNativeFullscreenInteraction({
|
|
134
|
+
keyboardTarget: list, requestRender() {}, mouseObserver: list.createMouseObserver(() => {}),
|
|
135
|
+
});
|
|
136
|
+
root.addChild(new Text("Heading", 0, 0));
|
|
137
|
+
root.addChild(list);
|
|
138
|
+
root.addChild(new Text("Footer", 0, 0));
|
|
139
|
+
const tui = new TuiAltScreen(terminal, false, undefined, { mouse: true });
|
|
140
|
+
const overlay = tui.showOverlay(root, { anchor: "center", width: 60, maxHeight: 15 });
|
|
141
|
+
tui.start(); tui.renderNow(true);
|
|
142
|
+
try {
|
|
143
|
+
let lines = root.render(60);
|
|
144
|
+
const bounds = overlay.getBounds();
|
|
145
|
+
assert.ok(bounds && bounds.col > 0 && bounds.row > 0);
|
|
146
|
+
const second = lines.findIndex((line) => stripTerminalSequences(line).includes("Second"));
|
|
147
|
+
assert.ok(second >= 0);
|
|
148
|
+
const x = bounds.col + 3, y = bounds.row + second + 1;
|
|
149
|
+
input?.(`\x1b[<35;${x};${y}M`);
|
|
150
|
+
lines = root.render(60);
|
|
151
|
+
assert.match(lines[second]!, /\x1b\[33mSecond\x1b\[39m/);
|
|
152
|
+
assert.deepEqual(selected, []);
|
|
153
|
+
input?.("\x1b[<35;1;1M");
|
|
154
|
+
assert.match(root.render(60)[second]!, /\x1b\[33mSecond\x1b\[39m/, "outside-overlay motion is not delivered to the root observer");
|
|
155
|
+
input?.(`\x1b[<35;${bounds.col + 1};${bounds.row + 1}M`);
|
|
156
|
+
assert.doesNotMatch(root.render(60).join("\n"), /\x1b\[33m/, "inside-root heading motion clears hover");
|
|
157
|
+
input?.(`\x1b[<0;${x};${y}M`);
|
|
158
|
+
input?.(`\x1b[<0;${x};${y}m`);
|
|
159
|
+
assert.deepEqual(selected, ["second"]);
|
|
160
|
+
} finally { tui.stop(); }
|
|
161
|
+
});
|
|
162
|
+
|
|
88
163
|
test("native choice list refreshes existing item content without changing selection", () => {
|
|
89
164
|
const items = [
|
|
90
165
|
{ id: "first", label: "First", description: "Initial detail." },
|
|
@@ -392,11 +392,17 @@ test("4.3.1 explicitly repeats 4.2.0 because capabilities/v2.6 and provider cont
|
|
|
392
392
|
assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["4.2.0"] as Record<string, boolean>);
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
+
test("4.4.0 explicitly repeats 4.3.1 because capabilities/v2.6 and provider contract 1.4.0 are unchanged", () => {
|
|
396
|
+
const contract = NATIVE_CLI_CONTRACTS["4.4.0"] as Record<string, boolean>;
|
|
397
|
+
assert.ok(contract);
|
|
398
|
+
assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["4.3.1"] as Record<string, boolean>);
|
|
399
|
+
});
|
|
400
|
+
|
|
395
401
|
test("no shipped version key was added beyond the pin bump", () => {
|
|
396
402
|
// Rows are promises to consumers, so a new key only ever appears in a
|
|
397
403
|
// dedicated commit alongside a pin bump, never as a side effect. v2.2.4 and
|
|
398
404
|
// v2.3.0 shipped upstream while Pi stayed on 2.2.3 and were never pinned,
|
|
399
405
|
// so they get no row: a row asserts ground truth measured against a binary
|
|
400
406
|
// Pi actually ran, and the table only has to be ascending, not gapless.
|
|
401
|
-
assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0", "3.2.1", "3.4.0", "3.5.0", "3.6.0", "3.6.1", "3.7.0", "4.0.0", "4.1.1", "4.2.0", "4.3.1"]);
|
|
407
|
+
assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0", "3.2.1", "3.4.0", "3.5.0", "3.6.0", "3.6.1", "3.7.0", "4.0.0", "4.1.1", "4.2.0", "4.3.1", "4.4.0"]);
|
|
402
408
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import {
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
5
6
|
import test from "node:test";
|
|
@@ -13,12 +14,15 @@ import {
|
|
|
13
14
|
NativeReviewCliError,
|
|
14
15
|
NativeReviewCliV216,
|
|
15
16
|
NativeReviewIntegrationError,
|
|
17
|
+
NativeReviewConsentRequiredError,
|
|
18
|
+
createNativeReviewCli,
|
|
16
19
|
createNodeExecFileAdapter,
|
|
17
20
|
createWindowsProcessTreeKiller,
|
|
18
21
|
windowsTaskkillPath,
|
|
19
22
|
gentleAiProcessEnvironment,
|
|
20
23
|
isNativeReviewUnachievableVerbRefused,
|
|
21
24
|
type ExecFileAdapter,
|
|
25
|
+
type NativeReviewModeRequest,
|
|
22
26
|
type NativeTargetStatusRequest,
|
|
23
27
|
} from "../lib/native-review-cli.ts";
|
|
24
28
|
import { setBundledInstallForTesting } from "../lib/gentle-shell-bundled.ts";
|
|
@@ -64,6 +68,114 @@ function client(adapter: ExecFileAdapter): NativeReviewCliV216 {
|
|
|
64
68
|
return new NativeReviewCliV216(adapter, "/package/.gentle-ai/gentle-ai", 30_000, 1024 * 1024);
|
|
65
69
|
}
|
|
66
70
|
|
|
71
|
+
const modeClients = [
|
|
72
|
+
["factory", (adapter: ExecFileAdapter, executable: () => string) => createNativeReviewCli(adapter, executable)],
|
|
73
|
+
["constructor", (adapter: ExecFileAdapter, executable: () => string) => new NativeReviewCliV216(adapter, executable)],
|
|
74
|
+
] as const;
|
|
75
|
+
const modeCwd = "/isolated-review-mode-test";
|
|
76
|
+
const modeExecutable = "/package/.gentle-ai/gentle-ai";
|
|
77
|
+
|
|
78
|
+
function modeOutput(operation: "status" | "enable" | "disable", scope: "clone" | "global" | "both", global: "on" | "off", cloneLocal: "" | "off") {
|
|
79
|
+
const effective = cloneLocal === "off" || global === "off" ? "off" : "on";
|
|
80
|
+
const source = cloneLocal === "off" ? "clone_local" : "global";
|
|
81
|
+
return {
|
|
82
|
+
wire: JSON.stringify({ schema: "gentle-ai.review-mode/v1", operation, scope, status: { schema: "gentle-ai.rdd-mode-status/v1", global, clone_local: cloneLocal, effective, source } }),
|
|
83
|
+
decoded: { operation, scope, status: { global, cloneLocal, effective, source } },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
test("native mode mutations honor each explicit clone or global scope", async (t) => {
|
|
88
|
+
const cases = [
|
|
89
|
+
{ operation: "enable", scope: "clone", global: "off", cloneLocal: "" },
|
|
90
|
+
{ operation: "disable", scope: "clone", global: "on", cloneLocal: "off" },
|
|
91
|
+
{ operation: "enable", scope: "global", global: "on", cloneLocal: "off" },
|
|
92
|
+
{ operation: "disable", scope: "global", global: "off", cloneLocal: "" },
|
|
93
|
+
] as const;
|
|
94
|
+
for (const [name, makeClient] of modeClients) for (const scenario of cases) {
|
|
95
|
+
await t.test(`${name}: ${scenario.operation} ${scenario.scope}`, async () => {
|
|
96
|
+
const expected = modeOutput(scenario.operation, scenario.scope, scenario.global, scenario.cloneLocal);
|
|
97
|
+
const queue = queuedAdapter([{ stdout: expected.wire, stderr: "", exitCode: 0 }]);
|
|
98
|
+
const review = makeClient(queue.adapter, () => modeExecutable);
|
|
99
|
+
const result = await review.reviewMode!({ cwd: modeCwd, operation: scenario.operation, scope: scenario.scope });
|
|
100
|
+
assert.deepEqual(result, expected.decoded);
|
|
101
|
+
assert.deepEqual(queue.calls, [{ file: modeExecutable, arguments: ["review", "mode", scenario.operation, "--cwd", modeCwd, "--scope", scenario.scope, "--json"], cwd: modeCwd, timeoutMs: undefined }]);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("native mode status and mutations without scope preserve their exact argv and decoded status", async (t) => {
|
|
107
|
+
for (const [name, makeClient] of modeClients) for (const operation of ["status", "enable", "disable"] as const) {
|
|
108
|
+
await t.test(`${name}: ${operation}`, async () => {
|
|
109
|
+
const expected = modeOutput(operation, operation === "status" ? "both" : "clone", "on", operation === "disable" ? "off" : "");
|
|
110
|
+
const queue = queuedAdapter([{ stdout: expected.wire, stderr: "", exitCode: 0 }]);
|
|
111
|
+
const review = makeClient(queue.adapter, () => modeExecutable);
|
|
112
|
+
assert.deepEqual(await review.reviewMode!({ cwd: modeCwd, operation }), expected.decoded);
|
|
113
|
+
assert.deepEqual(queue.calls, [{ file: modeExecutable, arguments: ["review", "mode", operation, "--cwd", modeCwd, ...(operation === "status" ? [] : ["--scope", "clone"]), "--json"], cwd: modeCwd, timeoutMs: operation === "status" ? 30_000 : undefined }]);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("native mode rejects unsupported scopes and status scopes before cwd or native access", async (t) => {
|
|
119
|
+
const cases = [
|
|
120
|
+
...(["enable", "disable"] as const).flatMap(operation => ["both", "", "GLOBAL", " global", null, 17].map(scope => ({ operation, scope, message: "Native review mode scope must be clone or global" }))),
|
|
121
|
+
...(["clone", "global"] as const).map(scope => ({ operation: "status", scope, message: "Native review mode scope is only valid for enable or disable" })),
|
|
122
|
+
];
|
|
123
|
+
for (const [name, makeClient] of modeClients) for (const scenario of cases) {
|
|
124
|
+
await t.test(`${name}: ${scenario.operation} ${String(scenario.scope)}`, async () => {
|
|
125
|
+
let cwdReads = 0, binaryResolutions = 0;
|
|
126
|
+
const expected = modeOutput(scenario.operation as "status" | "enable" | "disable", "clone", "on", "");
|
|
127
|
+
const queue = queuedAdapter([{ stdout: expected.wire }]);
|
|
128
|
+
const review = makeClient(queue.adapter, () => { binaryResolutions++; return modeExecutable; });
|
|
129
|
+
const request = { get cwd() { cwdReads++; return modeCwd; }, operation: scenario.operation, scope: scenario.scope } as unknown as NativeReviewModeRequest;
|
|
130
|
+
await assert.rejects(() => review.reviewMode!(request), { name: "TypeError", message: scenario.message });
|
|
131
|
+
assert.deepEqual({ cwdReads, binaryResolutions, calls: queue.calls.length }, { cwdReads: 0, binaryResolutions: 0, calls: 0 });
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("native mode binds operation and scope before asynchronous cwd resolution", async (t) => {
|
|
137
|
+
for (const [name, makeClient] of modeClients) for (const operation of ["status", "enable"] as const) {
|
|
138
|
+
await t.test(`${name}: ${operation}`, async () => {
|
|
139
|
+
const expected = modeOutput(operation, operation === "status" ? "both" : "global", "on", "off");
|
|
140
|
+
const queue = queuedAdapter([{ stdout: expected.wire }]);
|
|
141
|
+
const review = makeClient(queue.adapter, () => modeExecutable);
|
|
142
|
+
const request: NativeReviewModeRequest = { cwd: modeCwd, operation, ...(operation === "enable" ? { scope: "global" } : {}) };
|
|
143
|
+
const pending = review.reviewMode!(request);
|
|
144
|
+
request.operation = "disable";
|
|
145
|
+
request.scope = "clone";
|
|
146
|
+
assert.deepEqual(await pending, expected.decoded);
|
|
147
|
+
assert.deepEqual(queue.calls.map(call => call.arguments), [["review", "mode", operation, "--cwd", modeCwd, ...(operation === "enable" ? ["--scope", "global"] : []), "--json"]]);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("scoped native mode surfaces stderr, exit, and malformed responses without claiming success", async (t) => {
|
|
153
|
+
const expected = modeOutput("enable", "global", "on", "off");
|
|
154
|
+
const cases = [
|
|
155
|
+
{ name: "nonzero", result: { stdout: "{}", stderr: "native refused\n", exitCode: 17 }, code: NATIVE_REVIEW_ERROR_CODE.NON_ZERO, stderr: "native refused", exit: 17 },
|
|
156
|
+
{ name: "stderr", result: { stdout: expected.wire, stderr: "unexpected notice\n", exitCode: 0 }, code: NATIVE_REVIEW_ERROR_CODE.UNEXPECTED_STDERR, stderr: "unexpected notice", exit: 0 },
|
|
157
|
+
{ name: "malformed JSON", result: { stdout: "not-json", stderr: "", exitCode: 0 }, code: NATIVE_REVIEW_ERROR_CODE.MALFORMED_JSON, stderr: undefined, exit: 0 },
|
|
158
|
+
{ name: "foreign operation", result: { stdout: modeOutput("disable", "global", "off", "").wire, stderr: "", exitCode: 0 }, code: NATIVE_REVIEW_ERROR_CODE.SCHEMA_INCOMPATIBLE, stderr: undefined, exit: undefined },
|
|
159
|
+
] as const;
|
|
160
|
+
for (const [name, makeClient] of modeClients) for (const scenario of cases) {
|
|
161
|
+
await t.test(`${name}: ${scenario.name}`, async () => {
|
|
162
|
+
const queue = queuedAdapter([scenario.result]);
|
|
163
|
+
const review = makeClient(queue.adapter, () => modeExecutable);
|
|
164
|
+
const request = { cwd: modeCwd, operation: "enable", scope: "global" } as const;
|
|
165
|
+
await assert.rejects(() => review.reviewMode!(request), (error: unknown) => {
|
|
166
|
+
assert.ok(error instanceof NativeReviewCliError);
|
|
167
|
+
assert.equal(error.code, scenario.code);
|
|
168
|
+
assert.equal(error.operation, NATIVE_REVIEW_OPERATION.MODE);
|
|
169
|
+
assert.equal(error.mutationOutcome, "unknown");
|
|
170
|
+
assert.equal(error.diagnostics.stderr, scenario.stderr);
|
|
171
|
+
assert.equal(error.diagnostics.exit_code, scenario.exit);
|
|
172
|
+
return true;
|
|
173
|
+
});
|
|
174
|
+
assert.deepEqual(queue.calls.map(call => call.arguments), [["review", "mode", "enable", "--cwd", modeCwd, "--scope", "global", "--json"]]);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
67
179
|
test("negotiated STATUS accepts the pinned v5 receipt before routing its transition", async () => {
|
|
68
180
|
const status = fixture("status-v5.captured.json");
|
|
69
181
|
const queue = queuedAdapter([{ stdout: JSON.stringify(status) }]);
|
|
@@ -431,6 +543,120 @@ const LENS_SELECTION_UNSUPPORTED_FAILURE = {
|
|
|
431
543
|
next_action: "correct_request", cause: "flag provided but not defined: -lenses",
|
|
432
544
|
};
|
|
433
545
|
|
|
546
|
+
function contextClient(responses: QueuedResult[], features = ["start_request_context", "start_options_preflight"], executable = join(process.cwd(), "package.json")) {
|
|
547
|
+
const capabilities = JSON.parse(readFileSync(join(process.cwd(), "contracts/review-integration/v2/fixtures/capabilities.fixture.json"), "utf8"));
|
|
548
|
+
capabilities.executable.sha256 = "sha256:" + createHash("sha256").update(readFileSync(executable)).digest("hex");
|
|
549
|
+
capabilities.features.optional.push(...features.map(name => ({ name, supported: true, requires: [] })));
|
|
550
|
+
const queue = queuedAdapter([{ stdout: JSON.stringify(capabilities) }, ...responses]);
|
|
551
|
+
return { ...queue, client: new NativeReviewCliV216(queue.adapter, executable) };
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
test("START discovers capabilities before forwarding the explicit request file unchanged", async () => {
|
|
555
|
+
const path = "/repo/spec with spaces.md";
|
|
556
|
+
const tokens = ["--contract=gentle-ai.review-integration/v2", "--cwd=/repo", "--target=" + TARGET, "--projection=workspace", "--agent=pi", "--consent=relay", "--request-context=" + path];
|
|
557
|
+
const host = contextClient([
|
|
558
|
+
{ stdout: JSON.stringify(negotiatedStartStatus(TARGET, tokens)) },
|
|
559
|
+
{ stdout: JSON.stringify(fixture("start-v3-zero-lens-closed.captured.json")) },
|
|
560
|
+
]);
|
|
561
|
+
await host.client.start({ cwd: "/repo", requestContextPath: path });
|
|
562
|
+
assert.deepEqual(host.calls[0].arguments, ["review", "capabilities", "--contract", "gentle-ai.review-integration/v2"]);
|
|
563
|
+
assert.deepEqual(host.calls[1].arguments.slice(-3), ["--request-context", path, "--next-transition"]);
|
|
564
|
+
assert.deepEqual(host.calls[2].arguments, ["review", "start", ...tokens]);
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
test("request context reuses capabilities while every STATUS remains fresh", async () => {
|
|
568
|
+
const host = contextClient([1, 2].map(() => ({ stdout: JSON.stringify(negotiatedStartStatus(TARGET, [])) })));
|
|
569
|
+
for (let i = 0; i < 2; i++) await host.client.targetStatus({ cwd: "/repo", requestContextPath: "/spec.md" });
|
|
570
|
+
assert.deepEqual(host.calls.map(call => call.arguments[1]), ["capabilities", "status", "status"]);
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
test("request context invalidates capabilities when executable bytes change", async t => {
|
|
574
|
+
const directory = mkdtempSync(join(tmpdir(), "context-capabilities-"));
|
|
575
|
+
t.after(() => rmSync(directory, { recursive: true, force: true }));
|
|
576
|
+
const executable = join(directory, "native");
|
|
577
|
+
writeFileSync(executable, "first executable");
|
|
578
|
+
const replacementCapabilities = JSON.parse(readFileSync(join(process.cwd(), "contracts/review-integration/v2/fixtures/capabilities.fixture.json"), "utf8"));
|
|
579
|
+
replacementCapabilities.executable.sha256 = "sha256:" + createHash("sha256").update("replacement executable").digest("hex");
|
|
580
|
+
const host = contextClient([{ stdout: JSON.stringify(negotiatedStartStatus(TARGET, [])) }, { stdout: JSON.stringify(replacementCapabilities) }], undefined, executable);
|
|
581
|
+
await host.client.targetStatus({ cwd: "/repo", requestContextPath: "/spec.md" });
|
|
582
|
+
writeFileSync(executable, "replacement executable");
|
|
583
|
+
// The old capability result cannot authorize a STATUS with the replacement.
|
|
584
|
+
await assert.rejects(host.client.targetStatus({ cwd: "/repo", requestContextPath: "/spec.md" }), /provider does not support request context/);
|
|
585
|
+
assert.deepEqual(host.calls.map(call => call.arguments[1]), ["capabilities", "status", "capabilities"]);
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
test("request context never caches malformed capability discovery", async () => {
|
|
589
|
+
const host = contextClient([]);
|
|
590
|
+
let discoveries = 0;
|
|
591
|
+
const adapter: ExecFileAdapter = async request => {
|
|
592
|
+
if (++discoveries === 1) return { stdout: "{}", stderr: "", exitCode: 0, signal: null, timedOut: false, outputLimitExceeded: false };
|
|
593
|
+
return host.adapter(request);
|
|
594
|
+
};
|
|
595
|
+
const subject = new NativeReviewCliV216(adapter, join(process.cwd(), "package.json"));
|
|
596
|
+
await assert.rejects(subject.targetStatus({ cwd: "/repo", requestContextPath: "/spec.md" }));
|
|
597
|
+
// The second discovery succeeds; only the subsequent unqueued STATUS fails.
|
|
598
|
+
await assert.rejects(subject.targetStatus({ cwd: "/repo", requestContextPath: "/spec.md" }));
|
|
599
|
+
assert.deepEqual(host.calls.map(call => call.arguments[1]), ["capabilities", "status"]);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
test("Windows request paths preserve exact START and consent spelling and reject normalization drift", async () => {
|
|
603
|
+
for (const path of ["C:\\work\\spec with spaces.md", "C:\\work\\spec.md.", "C:\\work\\spec.md ", "\\\\?\\C:\\work\\spec.md"]) {
|
|
604
|
+
// A trailing space is an invalid process string even before negotiation.
|
|
605
|
+
if (path.endsWith(" ")) {
|
|
606
|
+
const queue = queuedAdapter([]);
|
|
607
|
+
await assert.rejects(client(queue.adapter).start({ cwd: "/repo", requestContextPath: path }));
|
|
608
|
+
assert.equal(queue.calls.length, 0);
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
const tokens = ["--contract=gentle-ai.review-integration/v2", "--cwd=/repo", "--target=" + TARGET, "--projection=workspace", "--agent=pi", "--consent=relay", "--request-context=" + path];
|
|
612
|
+
const host = contextClient([{ stdout: JSON.stringify(negotiatedStartStatus(TARGET, tokens)) }, { stdout: JSON.stringify(fixture("start-v3-zero-lens-closed.captured.json")) }]);
|
|
613
|
+
await host.client.start({ cwd: "/repo", requestContextPath: path });
|
|
614
|
+
assert.ok(host.calls[2].arguments.includes("--request-context=" + path));
|
|
615
|
+
const changed = path.startsWith("\\\\?\\") ? path.slice(4) : path.endsWith(".") ? path.slice(0, -1) : path.replaceAll("\\", "/");
|
|
616
|
+
const drift = contextClient([{ stdout: JSON.stringify(negotiatedStartStatus(TARGET, tokens.slice(0, -1).concat("--request-context=" + changed))) }]);
|
|
617
|
+
await assert.rejects(drift.client.start({ cwd: "/repo", requestContextPath: path }), /context/);
|
|
618
|
+
assert.equal(drift.calls.length, 2);
|
|
619
|
+
const raw = requestContextConsent(path);
|
|
620
|
+
const queue = queuedAdapter([{ stdout: JSON.stringify(reviewingStartV4(raw.target_identity)) }]);
|
|
621
|
+
await client(queue.adapter).answerConsent({ cwd: "/repo", consent: decodeReviewConsentV3(raw, "pi"), answer: "granted", requestContextPath: path });
|
|
622
|
+
assert.ok(queue.calls[0].arguments.includes(path));
|
|
623
|
+
const refused = queuedAdapter([]);
|
|
624
|
+
await assert.rejects(client(refused.adapter).answerConsent({ cwd: "/repo", consent: decodeReviewConsentV3(raw, "pi"), answer: "granted", requestContextPath: changed }), /context/);
|
|
625
|
+
assert.equal(refused.calls.length, 0);
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
test("request context refuses absent or unsupported advertised capabilities before STATUS or START", async () => {
|
|
630
|
+
for (const features of [[], ["start_request_context"], ["start_options_preflight"]]) {
|
|
631
|
+
const host = contextClient([], features);
|
|
632
|
+
await assert.rejects(host.client.start({ cwd: "/repo", requestContextPath: "/spec.md" }), /provider does not support request context/);
|
|
633
|
+
assert.equal(host.calls.length, 1);
|
|
634
|
+
}
|
|
635
|
+
const host = contextClient([]);
|
|
636
|
+
const adapter: ExecFileAdapter = async request => {
|
|
637
|
+
const response = await host.adapter(request);
|
|
638
|
+
const body = JSON.parse(response.stdout);
|
|
639
|
+
body.features.optional.find((f: { name: string }) => f.name === "start_request_context").supported = false;
|
|
640
|
+
return { ...response, stdout: JSON.stringify(body) };
|
|
641
|
+
};
|
|
642
|
+
await assert.rejects(new NativeReviewCliV216(adapter, join(process.cwd(), "package.json")).targetStatus({ cwd: "/repo", requestContextPath: "/spec.md" }), /provider does not support request context/);
|
|
643
|
+
assert.equal(host.calls.length, 1);
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
test("START never drops requested context from a malformed provider transition", async () => {
|
|
647
|
+
const host = contextClient([{ stdout: JSON.stringify(negotiatedStartStatus(TARGET, [])) }]);
|
|
648
|
+
await assert.rejects(host.client.start({ cwd: "/repo", requestContextPath: "/spec.md" }), /did not retain the requested context/);
|
|
649
|
+
assert.equal(host.calls.length, 2);
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
test("invalid request context paths are refused before any native invocation", async () => {
|
|
653
|
+
for (const path of ["", " spaced ", "bad\0path"]) {
|
|
654
|
+
const queue = queuedAdapter([]);
|
|
655
|
+
await assert.rejects(client(queue.adapter).start({ cwd: "/repo", requestContextPath: path }), /requestContextPath/);
|
|
656
|
+
assert.equal(queue.calls.length, 0);
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
|
|
434
660
|
test("native START preflights the agent lens selection through STATUS", async () => {
|
|
435
661
|
const tokens = [
|
|
436
662
|
"--contract=gentle-ai.review-integration/v2", "--cwd=/repo", `--target=${TARGET}`,
|
|
@@ -1144,3 +1370,45 @@ test("the central gentle-ai environment carries Gentle AI's isolation variables
|
|
|
1144
1370
|
const ordinary = gentleAiProcessEnvironment({ PATH: "/usr/bin" });
|
|
1145
1371
|
assert.deepEqual(ordinary, { PATH: "/usr/bin", GENTLE_PI_REVIEW_RELAY_CONTRACT: "gentle-pi.review-relay/v1" });
|
|
1146
1372
|
});
|
|
1373
|
+
|
|
1374
|
+
function requestContextConsent(path: string): Record<string, any> {
|
|
1375
|
+
const raw = fixture("consent-v3.captured.json") as Record<string, any>;
|
|
1376
|
+
raw.agent = "pi";
|
|
1377
|
+
for (const choice of raw.choices) choice.invocation = String(choice.invocation)
|
|
1378
|
+
.replace(/--cwd \S+ --target/, "--cwd /repo --target")
|
|
1379
|
+
.replace(" --consent ", " --agent pi --request-context '" + path + "' --consent ");
|
|
1380
|
+
return raw;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
test("request context is retained and checked before consent replay", async () => {
|
|
1384
|
+
const path = "/repo/spec with spaces.md";
|
|
1385
|
+
const raw = requestContextConsent(path);
|
|
1386
|
+
const tokens = ["--contract=gentle-ai.review-integration/v2", "--cwd=/repo", "--target=" + raw.target_identity, "--projection=workspace", "--agent=pi", "--consent=relay", "--request-context=" + path];
|
|
1387
|
+
const host = contextClient([{ stdout: JSON.stringify(negotiatedStartStatus(raw.target_identity, tokens)) }, { stdout: JSON.stringify(raw) }]);
|
|
1388
|
+
let pending: NativeReviewConsentRequiredError | undefined;
|
|
1389
|
+
try { await host.client.start({ cwd: "/repo", requestContextPath: path }); } catch (error) { assert.ok(error instanceof NativeReviewConsentRequiredError); pending = error; }
|
|
1390
|
+
assert.ok(pending);
|
|
1391
|
+
assert.equal(pending.requestContextPath, path);
|
|
1392
|
+
for (const mutation of ["missing", "changed", "duplicate"]) {
|
|
1393
|
+
const copy = requestContextConsent(path);
|
|
1394
|
+
copy.choices[0].invocation = mutation === "missing" ? copy.choices[0].invocation.replace(" --request-context '" + path + "'", "")
|
|
1395
|
+
: mutation === "changed" ? copy.choices[0].invocation.replace(path, "/other.md")
|
|
1396
|
+
: copy.choices[0].invocation.replace(" --consent ", " --request-context '/other.md' --consent ");
|
|
1397
|
+
const queue = queuedAdapter([]);
|
|
1398
|
+
await assert.rejects(client(queue.adapter).answerConsent({ cwd: "/repo", consent: decodeReviewConsentV3(copy, "pi"), answer: "granted", requestContextPath: path }), /context/);
|
|
1399
|
+
assert.equal(queue.calls.length, 0);
|
|
1400
|
+
}
|
|
1401
|
+
const queue = queuedAdapter([{ stdout: JSON.stringify(reviewingStartV4(raw.target_identity)) }]);
|
|
1402
|
+
assert.equal((await client(queue.adapter).answerConsent({ cwd: "/repo", consent: pending.consent, answer: "granted", requestContextPath: path } as any)).kind, "started");
|
|
1403
|
+
assert.ok(queue.calls[0].arguments.includes(path));
|
|
1404
|
+
});
|
|
1405
|
+
|
|
1406
|
+
test("START refuses consent choices that lose the requested context before presenting consent", async () => {
|
|
1407
|
+
const path = "/repo/spec.md";
|
|
1408
|
+
const raw = requestContextConsent(path);
|
|
1409
|
+
raw.choices[1].invocation = raw.choices[1].invocation.replace(" --request-context '" + path + "'", "");
|
|
1410
|
+
const tokens = ["--contract=gentle-ai.review-integration/v2", "--cwd=/repo", "--target=" + raw.target_identity, "--projection=workspace", "--agent=pi", "--consent=relay", "--request-context=" + path];
|
|
1411
|
+
const host = contextClient([{ stdout: JSON.stringify(negotiatedStartStatus(raw.target_identity, tokens)) }, { stdout: JSON.stringify(raw) }]);
|
|
1412
|
+
await assert.rejects(host.client.start({ cwd: "/repo", requestContextPath: path }), /context/);
|
|
1413
|
+
assert.equal(host.calls.length, 3);
|
|
1414
|
+
});
|