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
|
@@ -179,6 +179,95 @@ test("guarded words inside data-command arguments are not guarded operations (#2
|
|
|
179
179
|
] as const) assert.equal(classifyGuardedCommand(command, config), expected, command);
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
+
// gentle-shell#1202: a read-only git or gh segment elsewhere on the line does not
|
|
183
|
+
// make the data commands' arguments executable. Anything that can run or re-route
|
|
184
|
+
// text keeps the lexical guard.
|
|
185
|
+
test("guarded words inside data-command arguments stay prose next to read-only git and gh segments (#1202)", () => {
|
|
186
|
+
const config = { autonomousMode: false, guardedCommands: {} };
|
|
187
|
+
for (const command of [
|
|
188
|
+
"git -C /repo log -1 --oneline; tail -c 300000 f.jsonl | grep -oE 'git push origin [A-Za-z0-9]+' | tail -1",
|
|
189
|
+
"grep -oE 'git push origin' f.jsonl; git -C /repo status --short",
|
|
190
|
+
"gh pr view 1251 --json headRefOid; grep -n 'git push' f",
|
|
191
|
+
"cat > file <<'X'\nremember to git push later\nX\ngit -C /repo status --short",
|
|
192
|
+
"git status && grep -rn 'git reset --hard' docs",
|
|
193
|
+
"git diff --stat | wc -l; grep -l 'npm publish' a.md",
|
|
194
|
+
"git log --oneline | head -3; echo 'git rebase main'",
|
|
195
|
+
"grep 'pi remove' notes.md && gh pr list --state open",
|
|
196
|
+
]) assert.equal(classifyGuardedCommand(command, config), "not-guarded", command);
|
|
197
|
+
for (const [command, expected] of [
|
|
198
|
+
["git push", "confirm"],
|
|
199
|
+
["cd x && git push", "confirm"],
|
|
200
|
+
["grep a f; git push origin b", "confirm"],
|
|
201
|
+
["git -C r push", "confirm"],
|
|
202
|
+
["git -C r log; git push", "confirm"],
|
|
203
|
+
["git -C r log; grep 'git push' f; git push origin b", "confirm"],
|
|
204
|
+
["bash -c 'git push'", "confirm"],
|
|
205
|
+
["git status; bash -c 'git push'", "confirm"],
|
|
206
|
+
["eval \"git push\"", "confirm"],
|
|
207
|
+
["git status; eval \"git push\"", "confirm"],
|
|
208
|
+
["echo b | xargs git push origin", "confirm"],
|
|
209
|
+
["git status; echo b | xargs git push origin", "confirm"],
|
|
210
|
+
["git status; $(echo git push)", "confirm"],
|
|
211
|
+
["env git push", "confirm"],
|
|
212
|
+
["sudo git push", "confirm"],
|
|
213
|
+
["git status; grep x f; env git push", "confirm"],
|
|
214
|
+
["git status; cat <<'EOF' | bash\ngit push origin main\nEOF", "confirm"],
|
|
215
|
+
["git status; bash <<'EOF'\ngit push origin main\nEOF", "confirm"],
|
|
216
|
+
["git status; sh <<EOF\ngit push origin main\nEOF", "confirm"],
|
|
217
|
+
["git status; git rebase main", "confirm"],
|
|
218
|
+
["git status; git branch -D old", "confirm"],
|
|
219
|
+
["git status; npm publish", "confirm"],
|
|
220
|
+
["git status; pi remove foo", "confirm"],
|
|
221
|
+
["git status; git reset --hard", "block"],
|
|
222
|
+
// A git or gh segment that can run text stays opaque.
|
|
223
|
+
["git -C r log; grep 'git push' f | git -c alias.x='!sh' x", "confirm"],
|
|
224
|
+
["grep 'git push origin main' f | git log", "confirm"],
|
|
225
|
+
["git status; grep 'git push origin main' f | gh pr view", "confirm"],
|
|
226
|
+
["git -c alias.x='!sh' status; grep 'git push origin main' f", "confirm"],
|
|
227
|
+
["GIT_PAGER=sh git log; grep 'git push origin main' f", "confirm"],
|
|
228
|
+
["git status; grep 'git push origin main' f | git foo", "confirm"],
|
|
229
|
+
["git $(grep 'git push origin main' f); grep 'git push origin main' f", "confirm"],
|
|
230
|
+
["git alias-x; grep 'git push origin main' f", "confirm"],
|
|
231
|
+
["gh api repos/x; grep 'git push origin main' f", "confirm"],
|
|
232
|
+
["git status; grep 'git push origin main' f |& git log", "confirm"],
|
|
233
|
+
["git log $(echo git push); git status", "confirm"],
|
|
234
|
+
["git status; git rebase -x \"$(grep 'git push origin' f)\" main", "confirm"],
|
|
235
|
+
] as const) assert.equal(classifyGuardedCommand(command, config), expected, command);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// gentle-shell#1202 S6/S7: through the same evaluation path the extension uses.
|
|
239
|
+
test("YOLO still waives a reversible push on a line whose grep pattern mentions the phrase (#1202)", () => {
|
|
240
|
+
const config = { autonomousMode: false, guardedCommands: {} };
|
|
241
|
+
const waived = (command: string) => isReversibleYoloCommand(command, evaluateGuardedCommand(command, config));
|
|
242
|
+
for (const command of [
|
|
243
|
+
"git -C /repo log -1 --oneline; git push origin main; grep -n 'git push origin' f.jsonl",
|
|
244
|
+
"git -C /repo log -1 --oneline; grep -n 'git push origin' f.jsonl; git push origin main",
|
|
245
|
+
"git -C /repo status --short && git push -u origin feature/x && tail -c 300000 f.jsonl | grep -oE 'git push origin [A-Za-z0-9]+' | tail -1",
|
|
246
|
+
]) assert.equal(waived(command), true, command);
|
|
247
|
+
for (const command of [
|
|
248
|
+
"git -C /repo log -1 --oneline; git push -o ci.skip origin main; grep -n 'git push origin' f.jsonl",
|
|
249
|
+
"git -C /repo log -1 --oneline; grep -n 'git push origin' f.jsonl; git push --delete origin main",
|
|
250
|
+
"git -C /repo log -1 --oneline; grep -n 'git push origin' f.jsonl; git push origin :main",
|
|
251
|
+
"git -C /repo log -1 --oneline; grep -n 'git push origin' f.jsonl; git push --force origin main",
|
|
252
|
+
"git -C /repo log -1 --oneline; grep -n 'git push origin' f.jsonl; git push origin main | sh",
|
|
253
|
+
]) assert.equal(waived(command), false, command);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// By design: a quoted variable in a refspec is not in the push grammar, so the
|
|
257
|
+
// confirmation stays. Do not loosen YOLO_PUSH_SEGMENT_RE to "fix" this.
|
|
258
|
+
test("YOLO keeps the confirmation for a push whose refspec holds a quoted variable (#1202)", () => {
|
|
259
|
+
const config = { autonomousMode: false, guardedCommands: {} };
|
|
260
|
+
for (const command of [
|
|
261
|
+
`git push origin HEAD:refs/heads/"$REF"`,
|
|
262
|
+
`git -C /repo log -1; git push origin HEAD:refs/heads/"$REF"`,
|
|
263
|
+
`git -C /repo log -1; grep -n 'git push origin' f.jsonl; git push origin HEAD:refs/heads/"$REF"`,
|
|
264
|
+
]) {
|
|
265
|
+
const evaluation = evaluateGuardedCommand(command, config);
|
|
266
|
+
assert.equal(evaluation.action, "confirm", command);
|
|
267
|
+
assert.equal(isReversibleYoloCommand(command, evaluation), false, command);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
182
271
|
test("YOLO preserves explicit push restrictions in either config layer independently of persistent autonomy", () => {
|
|
183
272
|
const root = makeTmpDir();
|
|
184
273
|
const cwd = join(root, "repo");
|
|
@@ -504,12 +593,30 @@ test("evaluateGuardedCommand: repeated forced branch deletions remain separate m
|
|
|
504
593
|
);
|
|
505
594
|
});
|
|
506
595
|
|
|
507
|
-
|
|
596
|
+
// Explicit allow in the user config is honored in normal mode too: the
|
|
597
|
+
// permission-allowlist feature writes exactly this entry when the user picks
|
|
598
|
+
// "Always allow" in the confirmation dialog.
|
|
599
|
+
test("classifyGuardedCommand: git push honors explicit allow when autonomousMode=false", () => {
|
|
508
600
|
const result = classifyGuardedCommand("git push origin feature/test", {
|
|
509
601
|
autonomousMode: false,
|
|
510
602
|
guardedCommands: { gitPush: "allow" },
|
|
511
603
|
});
|
|
512
|
-
assert.equal(result, "
|
|
604
|
+
assert.equal(result, "allow");
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
// Explicit allow in the user config is honored in normal mode too (see the
|
|
608
|
+
// permission-allowlist feature); explicit confirm keeps asking.
|
|
609
|
+
test("classifyGuardedCommand: pi remove honors explicit allow when autonomousMode=false", () => {
|
|
610
|
+
const result = classifyGuardedCommand("pi remove my-package", {
|
|
611
|
+
autonomousMode: false,
|
|
612
|
+
guardedCommands: { piRemove: "allow" },
|
|
613
|
+
});
|
|
614
|
+
assert.equal(result, "allow");
|
|
615
|
+
const confirmResult = classifyGuardedCommand("pi remove my-package", {
|
|
616
|
+
autonomousMode: false,
|
|
617
|
+
guardedCommands: { piRemove: "confirm" },
|
|
618
|
+
});
|
|
619
|
+
assert.equal(confirmResult, "confirm");
|
|
513
620
|
});
|
|
514
621
|
|
|
515
622
|
// ---------------------------------------------------------------------------
|
|
@@ -700,14 +807,6 @@ test("loadRuntimeGuardrailsConfig: invalid project config fails safe (autonomous
|
|
|
700
807
|
// When autonomous mode is OFF nothing changes vs current behavior
|
|
701
808
|
// ---------------------------------------------------------------------------
|
|
702
809
|
|
|
703
|
-
test("classifyGuardedCommand: pi remove confirm when autonomousMode=false", () => {
|
|
704
|
-
const result = classifyGuardedCommand("pi remove my-package", {
|
|
705
|
-
autonomousMode: false,
|
|
706
|
-
guardedCommands: { piRemove: "allow" },
|
|
707
|
-
});
|
|
708
|
-
assert.equal(result, "confirm");
|
|
709
|
-
});
|
|
710
|
-
|
|
711
810
|
test("classifyGuardedCommand: pi remove allowed when autonomousMode=true and piRemove=allow", () => {
|
|
712
811
|
const result = classifyGuardedCommand("pi remove my-package", {
|
|
713
812
|
autonomousMode: true,
|
|
@@ -910,6 +1009,243 @@ test("loadRuntimeGuardrailsConfig: autonomousMode:{} (object) in JSON does NOT a
|
|
|
910
1009
|
rmSync(dir, { recursive: true, force: true });
|
|
911
1010
|
}
|
|
912
1011
|
});
|
|
1012
|
+
// evaluateBashPolicies — ordered bash command policy seam (gentle-pi#405 S1)
|
|
1013
|
+
// ---------------------------------------------------------------------------
|
|
1014
|
+
|
|
1015
|
+
type BashPolicySeamArgs = Parameters<typeof __testing.evaluateBashPolicies>;
|
|
1016
|
+
|
|
1017
|
+
function makeBashPolicySeamHarness(cwd: string) {
|
|
1018
|
+
return {
|
|
1019
|
+
ctx: { cwd, hasUI: false, ui: {} } as BashPolicySeamArgs[1],
|
|
1020
|
+
events: {
|
|
1021
|
+
emit: (_channel: string, _data: unknown) => {},
|
|
1022
|
+
on: (_channel: string, _handler: (data: unknown) => void) => () => {},
|
|
1023
|
+
},
|
|
1024
|
+
herdrLifecycle: {
|
|
1025
|
+
begin: () => {},
|
|
1026
|
+
settle: () => {},
|
|
1027
|
+
} as BashPolicySeamArgs[3],
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function makeStubBashPolicy(
|
|
1032
|
+
name: string,
|
|
1033
|
+
verdict: { block: true; reason: string } | undefined,
|
|
1034
|
+
calls: string[],
|
|
1035
|
+
): NonNullable<BashPolicySeamArgs[5]>[number] {
|
|
1036
|
+
return {
|
|
1037
|
+
name,
|
|
1038
|
+
async evaluate(_command: string) {
|
|
1039
|
+
calls.push(name);
|
|
1040
|
+
return verdict;
|
|
1041
|
+
},
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
test("evaluateBashPolicies: forwards yoloActive to every policy", async () => {
|
|
1046
|
+
const seen: boolean[] = [];
|
|
1047
|
+
const seam = makeBashPolicySeamHarness("/stub-cwd");
|
|
1048
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1049
|
+
"git push",
|
|
1050
|
+
seam.ctx,
|
|
1051
|
+
seam.events,
|
|
1052
|
+
seam.herdrLifecycle,
|
|
1053
|
+
true,
|
|
1054
|
+
[
|
|
1055
|
+
{
|
|
1056
|
+
name: "yolo-recorder",
|
|
1057
|
+
async evaluate(_command, _ctx, _events, _herdrLifecycle, yoloActive) {
|
|
1058
|
+
seen.push(yoloActive);
|
|
1059
|
+
return undefined;
|
|
1060
|
+
},
|
|
1061
|
+
},
|
|
1062
|
+
],
|
|
1063
|
+
);
|
|
1064
|
+
assert.equal(result, undefined);
|
|
1065
|
+
assert.deepEqual(seen, [true], "the seam must thread yoloActive into policies");
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
test("evaluateBashPolicies: forwards the Auto permission gate to every policy", async () => {
|
|
1069
|
+
const autoGate = async () => undefined;
|
|
1070
|
+
const seen: unknown[] = [];
|
|
1071
|
+
const seam = makeBashPolicySeamHarness("/stub-cwd");
|
|
1072
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1073
|
+
"echo hello",
|
|
1074
|
+
seam.ctx,
|
|
1075
|
+
seam.events,
|
|
1076
|
+
seam.herdrLifecycle,
|
|
1077
|
+
false,
|
|
1078
|
+
[
|
|
1079
|
+
{
|
|
1080
|
+
name: "auto-gate-recorder",
|
|
1081
|
+
async evaluate(_command, _ctx, _events, _herdrLifecycle, _yoloActive, gate) {
|
|
1082
|
+
seen.push(gate);
|
|
1083
|
+
return undefined;
|
|
1084
|
+
},
|
|
1085
|
+
},
|
|
1086
|
+
],
|
|
1087
|
+
autoGate,
|
|
1088
|
+
);
|
|
1089
|
+
assert.equal(result, undefined);
|
|
1090
|
+
assert.deepEqual(seen, [autoGate], "the seam must thread the Auto gate into policies");
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
test("evaluateBashPolicies: forwards superYoloActive to every policy", async () => {
|
|
1094
|
+
const seen: boolean[] = [];
|
|
1095
|
+
const seam = makeBashPolicySeamHarness("/stub-cwd");
|
|
1096
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1097
|
+
"git push --force origin main",
|
|
1098
|
+
seam.ctx,
|
|
1099
|
+
seam.events,
|
|
1100
|
+
seam.herdrLifecycle,
|
|
1101
|
+
false,
|
|
1102
|
+
[
|
|
1103
|
+
{
|
|
1104
|
+
name: "super-yolo-recorder",
|
|
1105
|
+
async evaluate(_command, _ctx, _events, _herdrLifecycle, _yoloActive, _autoGate, superYoloActive) {
|
|
1106
|
+
seen.push(superYoloActive);
|
|
1107
|
+
return undefined;
|
|
1108
|
+
},
|
|
1109
|
+
},
|
|
1110
|
+
],
|
|
1111
|
+
undefined,
|
|
1112
|
+
true,
|
|
1113
|
+
);
|
|
1114
|
+
assert.equal(result, undefined);
|
|
1115
|
+
assert.deepEqual(seen, [true], "the seam must thread superYoloActive into policies");
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
test("evaluateBashPolicies: real runtime-guardrails policy defers a non-guarded command to the Auto gate", async () => {
|
|
1119
|
+
const cwd = mkdtempSync(join(tmpdir(), "gentle-ai-bash-policy-auto-"));
|
|
1120
|
+
try {
|
|
1121
|
+
const seam = makeBashPolicySeamHarness(cwd);
|
|
1122
|
+
let gateCalls = 0;
|
|
1123
|
+
const denied = { block: true as const, reason: "auto-mode classifier denied" };
|
|
1124
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1125
|
+
"echo hello",
|
|
1126
|
+
seam.ctx,
|
|
1127
|
+
seam.events,
|
|
1128
|
+
seam.herdrLifecycle,
|
|
1129
|
+
false,
|
|
1130
|
+
undefined,
|
|
1131
|
+
async () => {
|
|
1132
|
+
gateCalls += 1;
|
|
1133
|
+
return denied;
|
|
1134
|
+
},
|
|
1135
|
+
);
|
|
1136
|
+
assert.deepEqual(result, denied, "the Auto gate verdict must reach the caller through the seam");
|
|
1137
|
+
assert.equal(gateCalls, 1);
|
|
1138
|
+
} finally {
|
|
1139
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1143
|
+
test('evaluateBashPolicies: ordered policy list is exactly ["runtime-guardrails"]', () => {
|
|
1144
|
+
assert.deepEqual(
|
|
1145
|
+
__testing.BASH_COMMAND_POLICIES.map((policy) => policy.name),
|
|
1146
|
+
["runtime-guardrails"],
|
|
1147
|
+
);
|
|
1148
|
+
assert.ok(
|
|
1149
|
+
__testing.BASH_COMMAND_POLICIES.every(
|
|
1150
|
+
(policy) => typeof policy.evaluate === "function",
|
|
1151
|
+
),
|
|
1152
|
+
"every policy must expose an evaluate function",
|
|
1153
|
+
);
|
|
1154
|
+
});
|
|
1155
|
+
|
|
1156
|
+
test("evaluateBashPolicies: short-circuits on the first verdict (later policies are not evaluated)", async () => {
|
|
1157
|
+
const calls: string[] = [];
|
|
1158
|
+
const firstVerdict = { block: true, reason: "first policy verdict" } as const;
|
|
1159
|
+
const seam = makeBashPolicySeamHarness("/stub-cwd");
|
|
1160
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1161
|
+
"ignored by stubs",
|
|
1162
|
+
seam.ctx,
|
|
1163
|
+
seam.events,
|
|
1164
|
+
seam.herdrLifecycle,
|
|
1165
|
+
false,
|
|
1166
|
+
[
|
|
1167
|
+
makeStubBashPolicy("first", firstVerdict, calls),
|
|
1168
|
+
makeStubBashPolicy(
|
|
1169
|
+
"second",
|
|
1170
|
+
{ block: true, reason: "second policy verdict" },
|
|
1171
|
+
calls,
|
|
1172
|
+
),
|
|
1173
|
+
],
|
|
1174
|
+
);
|
|
1175
|
+
assert.deepEqual(result, firstVerdict);
|
|
1176
|
+
assert.deepEqual(
|
|
1177
|
+
calls,
|
|
1178
|
+
["first"],
|
|
1179
|
+
"the second policy must not run after a verdict",
|
|
1180
|
+
);
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
test("evaluateBashPolicies: allow verdict from the last policy returns undefined overall", async () => {
|
|
1184
|
+
const calls: string[] = [];
|
|
1185
|
+
const seam = makeBashPolicySeamHarness("/stub-cwd");
|
|
1186
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1187
|
+
"ignored by stubs",
|
|
1188
|
+
seam.ctx,
|
|
1189
|
+
seam.events,
|
|
1190
|
+
seam.herdrLifecycle,
|
|
1191
|
+
false,
|
|
1192
|
+
[
|
|
1193
|
+
makeStubBashPolicy("first-allow", undefined, calls),
|
|
1194
|
+
makeStubBashPolicy("last-allow", undefined, calls),
|
|
1195
|
+
],
|
|
1196
|
+
);
|
|
1197
|
+
assert.equal(result, undefined);
|
|
1198
|
+
assert.deepEqual(
|
|
1199
|
+
calls,
|
|
1200
|
+
["first-allow", "last-allow"],
|
|
1201
|
+
"an allow must not short-circuit remaining policies",
|
|
1202
|
+
);
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
test("evaluateBashPolicies: real runtime-guardrails policy blocks hard-deny commands through the seam", async () => {
|
|
1206
|
+
const dir = makeTmpDir();
|
|
1207
|
+
const originalConfigHome = process.env.GENTLE_PI_CONFIG_HOME;
|
|
1208
|
+
process.env.GENTLE_PI_CONFIG_HOME = join(dir, "config-home");
|
|
1209
|
+
try {
|
|
1210
|
+
const seam = makeBashPolicySeamHarness(dir);
|
|
1211
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1212
|
+
"rm -rf /",
|
|
1213
|
+
seam.ctx,
|
|
1214
|
+
seam.events,
|
|
1215
|
+
seam.herdrLifecycle,
|
|
1216
|
+
false,
|
|
1217
|
+
);
|
|
1218
|
+
assert.equal(result?.block, true);
|
|
1219
|
+
assert.match(result?.reason ?? "", /destructive/);
|
|
1220
|
+
} finally {
|
|
1221
|
+
if (originalConfigHome === undefined)
|
|
1222
|
+
delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
1223
|
+
else process.env.GENTLE_PI_CONFIG_HOME = originalConfigHome;
|
|
1224
|
+
rmSync(dir, { recursive: true, force: true });
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
test("evaluateBashPolicies: real runtime-guardrails policy allows a non-guarded command through the seam", async () => {
|
|
1229
|
+
const dir = makeTmpDir();
|
|
1230
|
+
const originalConfigHome = process.env.GENTLE_PI_CONFIG_HOME;
|
|
1231
|
+
process.env.GENTLE_PI_CONFIG_HOME = join(dir, "config-home");
|
|
1232
|
+
try {
|
|
1233
|
+
const seam = makeBashPolicySeamHarness(dir);
|
|
1234
|
+
const result = await __testing.evaluateBashPolicies(
|
|
1235
|
+
"echo hello",
|
|
1236
|
+
seam.ctx,
|
|
1237
|
+
seam.events,
|
|
1238
|
+
seam.herdrLifecycle,
|
|
1239
|
+
false,
|
|
1240
|
+
);
|
|
1241
|
+
assert.equal(result, undefined);
|
|
1242
|
+
} finally {
|
|
1243
|
+
if (originalConfigHome === undefined)
|
|
1244
|
+
delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
1245
|
+
else process.env.GENTLE_PI_CONFIG_HOME = originalConfigHome;
|
|
1246
|
+
rmSync(dir, { recursive: true, force: true });
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
913
1249
|
|
|
914
1250
|
test("evaluateSuperYoloCommand: waives data-loss and configured confirmations, keeps only catastrophic denies", () => {
|
|
915
1251
|
const { evaluateSuperYoloCommand } = __testing;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
|
|
6
|
+
// gentle-shell#2686: on network-mounted workspaces a single unbounded recursive
|
|
7
|
+
// scan (`grep -r … .`) over raw `bash` cost up to 24.8 minutes (21–75× SMB I/O),
|
|
8
|
+
// and six such calls turned a trivial verification into a 49.6-minute wait. The
|
|
9
|
+
// dedicated `grep`/`find` tools honour `.gitignore`, and a
|
|
10
|
+
// bounded scan is faster even on local disks (0.06 s vs 1.8 s on an 8.7 MB repo),
|
|
11
|
+
// so the bound is unconditional: it never depends on the model detecting a
|
|
12
|
+
// network mount. Like the other prompt contracts here, this pins instruction
|
|
13
|
+
// delivery, not model adherence.
|
|
14
|
+
// These are instruction-delivery contracts, not proof of model adherence.
|
|
15
|
+
|
|
16
|
+
const read = (relative: string): string => readFileSync(join(import.meta.dirname, "..", relative), "utf8");
|
|
17
|
+
const verify = read("assets/agents/gentle-ai-verify.md");
|
|
18
|
+
const worker = read("assets/agents/gentle-ai-worker.md");
|
|
19
|
+
|
|
20
|
+
function containsAll(text: string, clauses: readonly string[], label: string): void {
|
|
21
|
+
const folded = text.toLowerCase();
|
|
22
|
+
for (const clause of clauses) assert.ok(folded.includes(clause.toLowerCase()), `${label} is missing: ${clause}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const [label, prompt] of [["verify", verify], ["worker", worker]] as const) {
|
|
26
|
+
test(`${label}: prefers the dedicated tools over raw bash grep`, () => {
|
|
27
|
+
containsAll(prompt, [
|
|
28
|
+
"prefer the dedicated `grep`/`find` tools over raw `bash` grep",
|
|
29
|
+
"they honour `.gitignore`",
|
|
30
|
+
], `${label} search bounds`);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test(`${label}: forbids unbounded recursive scans`, () => {
|
|
34
|
+
containsAll(prompt, [
|
|
35
|
+
"Never run an unbounded recursive scan (`grep -r … .`, `find .` from the workspace root)",
|
|
36
|
+
"bound to source directories and pass `--exclude-dir={.git,vendor,node_modules}`",
|
|
37
|
+
], `${label} search bounds`);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
3
4
|
import { join } from "node:path";
|
|
4
|
-
import test from "node:test";
|
|
5
|
+
import test, { after, before } from "node:test";
|
|
5
6
|
import { __testing } from "../extensions/gentle-ai.ts";
|
|
6
7
|
|
|
7
8
|
// gentle-shell#1731 T23 (G1 audit L48): port the gentle-ai Native Checking
|
|
@@ -18,6 +19,22 @@ const tracking = read("assets/orchestrator-tracking.md");
|
|
|
18
19
|
const worker = read("assets/agents/gentle-ai-worker.md");
|
|
19
20
|
const verify = read("assets/agents/gentle-ai-verify.md");
|
|
20
21
|
const personas = ["gentleman", "neutral"] as const;
|
|
22
|
+
let scratch: string;
|
|
23
|
+
let previousConfigHome: string | undefined;
|
|
24
|
+
before(() => {
|
|
25
|
+
scratch = mkdtempSync(join(tmpdir(), "gentle-bounded-stop-"));
|
|
26
|
+
previousConfigHome = process.env.GENTLE_PI_CONFIG_HOME;
|
|
27
|
+
process.env.GENTLE_PI_CONFIG_HOME = join(scratch, "config");
|
|
28
|
+
});
|
|
29
|
+
after(() => {
|
|
30
|
+
if (previousConfigHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
31
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previousConfigHome;
|
|
32
|
+
if (scratch) rmSync(scratch, { recursive: true, force: true });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function prompt(persona: (typeof personas)[number]): string {
|
|
36
|
+
return __testing.buildGentlePrompt(persona, scratch, ["read"]);
|
|
37
|
+
}
|
|
21
38
|
|
|
22
39
|
function lineStarting(text: string, prefix: string): string {
|
|
23
40
|
const line = text.split("\n").find((entry) => entry.startsWith(prefix));
|
|
@@ -30,7 +47,7 @@ function containsAll(text: string, clauses: readonly string[], label: string): v
|
|
|
30
47
|
}
|
|
31
48
|
|
|
32
49
|
function closeStep(persona: (typeof personas)[number]): string {
|
|
33
|
-
return lineStarting(
|
|
50
|
+
return lineStarting(prompt(persona), "7. **Close.**");
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
test("T23(a): a partial or blocked writer gets the one correction, then Needs your decision, never more verify", () => {
|
|
@@ -77,6 +94,29 @@ test("T23(d)(e): a quick check runs once and an unavailable verifier is reported
|
|
|
77
94
|
}
|
|
78
95
|
});
|
|
79
96
|
|
|
97
|
+
test("S4-S5: the unchanged Close stop is scoped to the ended automatic cycle", () => {
|
|
98
|
+
for (const persona of personas) {
|
|
99
|
+
containsAll(prompt(persona), [
|
|
100
|
+
"The Close step's bounded stop ends the current automatic cycle; a later explicit human request is separate and remains subject to native authority.",
|
|
101
|
+
"Partial worker execution is not by itself exhausted proof or a terminal native review outcome.",
|
|
102
|
+
], `${persona} delivered continuation`);
|
|
103
|
+
assert.ok(closeStep(persona).includes("never more verification"), "the mirrored Close rule remains intact");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("S4-S5: the worker returns remaining work and a human-controlled continuation after its bound", () => {
|
|
108
|
+
containsAll(worker, [
|
|
109
|
+
"After the correction bound is exhausted, stop and return `status: partial`",
|
|
110
|
+
"report the concrete remaining implementation work, failing commands and outputs, and missing proof",
|
|
111
|
+
"identify a scoped continuation the parent can offer for explicit human authorization",
|
|
112
|
+
"Do not start a fresh correction cycle or treat a new session as a reset",
|
|
113
|
+
"native authority and all other applicable limits remain binding",
|
|
114
|
+
], "worker continuation handoff");
|
|
115
|
+
containsAll(verification, [
|
|
116
|
+
"Follow **Authorized work continuity** for setup and worker recovery; scratch: `gentle-ai-verify`.",
|
|
117
|
+
], "parent continuation reference");
|
|
118
|
+
});
|
|
119
|
+
|
|
80
120
|
test("T23(f): the verify agent allows a second correction only for the same blocker still failing", () => {
|
|
81
121
|
containsAll(lineStarting(verify, "5. **Every item.**"), [
|
|
82
122
|
"one correction batch and one recheck limited to the reported blockers",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { priceBridgeMessage } from "../lib/bridge-cost.ts";
|
|
7
|
+
|
|
8
|
+
const metadata = join(dirname(fileURLToPath(import.meta.resolve("@earendil-works/pi-ai"))), "..", "package.json");
|
|
9
|
+
const version: string = JSON.parse(readFileSync(metadata, "utf8")).version;
|
|
10
|
+
assert.match(version, /^\d+\.\d+\.\d+$/);
|
|
11
|
+
const [major, minor] = version.split(".").map(Number);
|
|
12
|
+
assert.ok(major >= 1, `Pi AI >=1.0.0 required, installed ${version}`);
|
|
13
|
+
const hasProviderTotal = major > 1 || (major === 1 && minor >= 5);
|
|
14
|
+
|
|
15
|
+
const OPUS = { input: 4, output: 20, cacheRead: 0.2, cacheWrite: 5 };
|
|
16
|
+
const zeroCost = () => ({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 });
|
|
17
|
+
const bridgeMessage = (overrides: Record<string, unknown> = {}) => ({
|
|
18
|
+
role: "assistant", provider: "claude-bridge", model: "claude-opus-5-5",
|
|
19
|
+
usage: { input: 1_000_000, output: 100_000, cacheRead: 2_000_000, cacheWrite: 200_000, totalTokens: 3_300_000, cost: zeroCost() },
|
|
20
|
+
...overrides,
|
|
21
|
+
});
|
|
22
|
+
const catalog = (provider: string, id: string) => (provider === "anthropic" && id === "claude-opus-5-5" ? OPUS : undefined);
|
|
23
|
+
|
|
24
|
+
test("priceBridgeMessage prices a zero-cost claude-bridge message at the Anthropic list price", () => {
|
|
25
|
+
const message = bridgeMessage();
|
|
26
|
+
const original = structuredClone(message);
|
|
27
|
+
const priced = priceBridgeMessage(message, catalog);
|
|
28
|
+
assert.ok(priced);
|
|
29
|
+
// 1M input * $4 + 100k output * $20 + 2M cache read * $0.2 + 200k cache write * $5
|
|
30
|
+
const cost = { input: 4, output: 2, cacheRead: 0.4, cacheWrite: 1, total: 7.4, ...(hasProviderTotal ? { totalFromProvider: false } : {}) };
|
|
31
|
+
assert.deepEqual(priced.usage.cost, cost);
|
|
32
|
+
assert.deepEqual(priced.usage, { ...original.usage, cost }, "all token counts stay as the bridge reported them");
|
|
33
|
+
assert.deepEqual(message, original, "the original message is not mutated");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("priceBridgeMessage leaves messages it must not price untouched", () => {
|
|
37
|
+
const nonBridge = bridgeMessage({ provider: "anthropic" });
|
|
38
|
+
const original = structuredClone(nonBridge);
|
|
39
|
+
assert.equal(priceBridgeMessage(nonBridge, catalog), undefined, "other providers price themselves");
|
|
40
|
+
assert.deepEqual(nonBridge, original, "other providers are not mutated");
|
|
41
|
+
assert.equal(priceBridgeMessage(bridgeMessage({ role: "user" }), catalog), undefined);
|
|
42
|
+
assert.equal(priceBridgeMessage(bridgeMessage({ model: "claude-unknown" }), catalog), undefined, "no catalog price, no guess");
|
|
43
|
+
const alreadyPriced = bridgeMessage();
|
|
44
|
+
alreadyPriced.usage.cost = { input: 1, output: 0, cacheRead: 0, cacheWrite: 0, total: 1 };
|
|
45
|
+
assert.equal(priceBridgeMessage(alreadyPriced, catalog), undefined, "a bridge that reports cost wins");
|
|
46
|
+
assert.equal(priceBridgeMessage(bridgeMessage({ usage: undefined }), catalog), undefined);
|
|
47
|
+
});
|
|
@@ -1179,9 +1179,8 @@ posixTest("writeNpmrcAuth writes the filtered npmrc 0600 inside the prefix; user
|
|
|
1179
1179
|
});
|
|
1180
1180
|
|
|
1181
1181
|
test("pnpmEnvironment keeps the variables the prefix npmrc references and still drops npm settings", () => {
|
|
1182
|
-
const
|
|
1183
|
-
const layout = prefixLayout({ platform: "linux", env: {}, home:
|
|
1184
|
-
mkdirSync(join(layout.root, "pnpm", "config"), { recursive: true });
|
|
1182
|
+
const config = join(home(), "npmrc");
|
|
1183
|
+
const layout = { ...prefixLayout({ platform: "linux", env: {}, home: "/home/me" }), npmrc: config };
|
|
1185
1184
|
writeFileSync(layout.npmrc, "//npm.acme.dev/:_authToken=${NPM_TOKEN}\n//h/:_auth=${npm_config_x}\n");
|
|
1186
1185
|
const env = pnpmEnvironment(layout, { platform: "linux", env: { PATH: "/usr/bin", NPM_TOKEN: "secret", NPM_OTHER: "o", npm_config_x: "x",
|
|
1187
1186
|
npm_config_cache: "/home/me/.npm" } });
|
|
@@ -1343,13 +1342,38 @@ posixTest("upgradeBundled never downgrades a newer Pi installed with update --la
|
|
|
1343
1342
|
const lines: string[] = [];
|
|
1344
1343
|
const result = await upgradeBundled({ layout, home: user, platform: "darwin", arch: "arm64", env: {}, adapters: same.adapters, out: (line: string) => lines.push(line) });
|
|
1345
1344
|
assert.deepEqual(result, { id: "4.1.0-1.0.5", changed: false });
|
|
1346
|
-
assert.deepEqual(lines, ["Gentle Shell 4.1.0 is current; Pi 1.0.5
|
|
1345
|
+
assert.deepEqual(lines, ["Gentle Shell 4.1.0 is current; Pi 1.0.5 is newer than this release's verified Pi 1.0.1."]);
|
|
1347
1346
|
assert.deepEqual([same.calls.ensureRuntime.length, same.calls.verify.length, same.calls.loaded.length], [0, 0, 0]);
|
|
1348
1347
|
assert.equal(activeVersion(layout), "4.1.0-1.0.5");
|
|
1349
|
-
const newer = upgradeAdapters(layout);
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1352
|
-
|
|
1348
|
+
const newer = upgradeAdapters(layout, { reported: { shell: "4.2.0", pi: "1.0.5" } });
|
|
1349
|
+
const pnpm = fakePnpm({ shell: "4.2.0", pi: "1.0.5" });
|
|
1350
|
+
newer.adapters.install.run = pnpm.run;
|
|
1351
|
+
const output: string[] = [];
|
|
1352
|
+
const upgraded = await upgradeBundled({ layout, home: user, platform: "darwin", arch: "arm64", env: {}, adapters: newer.adapters, out: (line: string) => output.push(line) });
|
|
1353
|
+
assert.deepEqual(upgraded, { id: "4.2.0-1.0.5", changed: true, previous: "4.1.0-1.0.5", removed: ["4.0.0-1.0.0", "4.1.0-1.0.1"] });
|
|
1354
|
+
assert.equal(activeVersion(layout), "4.2.0-1.0.5");
|
|
1355
|
+
assert.deepEqual(pnpm.runs[0].args.slice(1), ["install", "--no-frozen-lockfile"]);
|
|
1356
|
+
assert.equal(existsSync(join(layout.versions, upgraded.id, "pnpm-lock.yaml")), false);
|
|
1357
|
+
assert.match(output[0], /warning:.*Pi 1\.0\.5.*verified Pi 1\.0\.2.*without.*lockfile/);
|
|
1358
|
+
assert.match(output[1], /Upgraded to Gentle Shell 4\.2\.0 with Pi 1\.0\.5/);
|
|
1359
|
+
});
|
|
1360
|
+
|
|
1361
|
+
posixTest("a failed new Shell installation with preserved newer Pi leaves current unchanged", async () => {
|
|
1362
|
+
const { user, layout } = await activeInstall();
|
|
1363
|
+
await installed(layout, [["4.1.0", "1.0.5"]]);
|
|
1364
|
+
activateVersion(layout, "4.1.0-1.0.5");
|
|
1365
|
+
const { adapters, calls } = upgradeAdapters(layout);
|
|
1366
|
+
const attempts: string[][] = [];
|
|
1367
|
+
adapters.install.run = (_command: string, args: string[]) => { attempts.push(args); return { status: 1, stdout: "fixture failed", stderr: "" }; };
|
|
1368
|
+
const output: string[] = [];
|
|
1369
|
+
await assert.rejects(upgradeBundled({ layout, home: user, platform: "darwin", arch: "arm64", env: {}, adapters, out: (line: string) => output.push(line) }),
|
|
1370
|
+
{ message: "pnpm install failed (exit 1)" });
|
|
1371
|
+
assert.deepEqual(attempts.map((args) => args.slice(1)), [["install", "--no-frozen-lockfile"]]);
|
|
1372
|
+
assert.equal(activeVersion(layout), "4.1.0-1.0.5");
|
|
1373
|
+
assert.equal(existsSync(join(layout.versions, "4.2.0-1.0.5")), false);
|
|
1374
|
+
assert.deepEqual(calls.verify, []);
|
|
1375
|
+
assert.equal(output.length, 1);
|
|
1376
|
+
assert.match(output[0], /warning:/);
|
|
1353
1377
|
});
|
|
1354
1378
|
|
|
1355
1379
|
function latestAdapters(layout: ReturnType<typeof prefixLayout>, { latestPi = "1.0.5", reported = { shell: "4.1.0", pi: latestPi } } = {}) {
|
|
@@ -1526,7 +1550,10 @@ test("Pi reads the bundled npmCommand as npm and installs git extensions with np
|
|
|
1526
1550
|
: prefixLayout({ platform: process.platform, env: {}, home: "/home/npm" });
|
|
1527
1551
|
const pi = await piPackageManager(bundledNpmCommand(host));
|
|
1528
1552
|
assert.equal(pi.getPackageManagerName(), "npm");
|
|
1529
|
-
|
|
1553
|
+
const args = pi.getGitDependencyInstallArgs();
|
|
1554
|
+
const npmFlags = ["install", "--omit=dev", "--legacy-peer-deps"];
|
|
1555
|
+
// Pi 1.5 adds two npm-only flags; reject any vector other than the audited 1.4/1.5 forms.
|
|
1556
|
+
assert.deepEqual(args, args.length === npmFlags.length ? npmFlags : [...npmFlags, "--no-audit", "--no-fund"]);
|
|
1530
1557
|
// The command before N1 read as `node`: plain `npm install` for git extensions.
|
|
1531
1558
|
const before = await piPackageManager([host.node, host.npmCli, ...bundledNpmCommand(host).slice(2)]);
|
|
1532
1559
|
assert.equal(before.getPackageManagerName(), "node");
|
|
@@ -9,7 +9,7 @@ const home = () => mkdtempSync(join(tmpdir(), "gentle-card-content-"));
|
|
|
9
9
|
|
|
10
10
|
test("a missing preference means the default content level", () => {
|
|
11
11
|
const dir = home();
|
|
12
|
-
assert.deepEqual(resolveCardContent({ gentlePiConfigHome: dir }), { content: "
|
|
12
|
+
assert.deepEqual(resolveCardContent({ gentlePiConfigHome: dir }), { content: "minimal", source: "default", malformed: false, globalFile: join(dir, "card-content.json") }, "minimal is the default");
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
test("the preference round-trips through the atomic writer", () => {
|
|
@@ -35,7 +35,7 @@ test("invalid or unreadable preference files read as default and are never overw
|
|
|
35
35
|
const dir = home();
|
|
36
36
|
const path = join(dir, "card-content.json");
|
|
37
37
|
writeFileSync(path, raw);
|
|
38
|
-
assert.deepEqual(resolveCardContent({ gentlePiConfigHome: dir }), { content: "
|
|
38
|
+
assert.deepEqual(resolveCardContent({ gentlePiConfigHome: dir }), { content: "minimal", source: "global_file", malformed: true, globalFile: path }, raw);
|
|
39
39
|
assert.throws(() => writeCardContent(CARD_CONTENT.MINIMAL, { gentlePiConfigHome: dir }), /Cannot update malformed or unreadable card content preference/, raw);
|
|
40
40
|
assert.equal(readFileSync(path, "utf8"), raw, "the malformed file is preserved");
|
|
41
41
|
}
|
|
@@ -55,7 +55,7 @@ test("POSIX unreadable preference files read as default and are never overwritte
|
|
|
55
55
|
writeCardContent(CARD_CONTENT.MINIMAL, { gentlePiConfigHome: locked });
|
|
56
56
|
chmodSync(join(locked, "card-content.json"), 0o000);
|
|
57
57
|
try {
|
|
58
|
-
assert.deepEqual({ ...resolveCardContent({ gentlePiConfigHome: locked }), globalFile: "" }, { content: "
|
|
58
|
+
assert.deepEqual({ ...resolveCardContent({ gentlePiConfigHome: locked }), globalFile: "" }, { content: "minimal", source: "global_file", malformed: true, globalFile: "" });
|
|
59
59
|
assert.throws(() => writeCardContent(CARD_CONTENT.DEFAULT, { gentlePiConfigHome: locked }), /Cannot update malformed or unreadable card content preference/);
|
|
60
60
|
} finally {
|
|
61
61
|
chmodSync(join(locked, "card-content.json"), 0o600);
|