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
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
existsSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
mkdtempSync,
|
|
7
|
+
readFileSync,
|
|
8
|
+
renameSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
writeFileSync,
|
|
11
|
+
} from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import {
|
|
15
|
+
AgentSessionRuntime,
|
|
16
|
+
createAgentSession,
|
|
17
|
+
createEventBus,
|
|
18
|
+
createExtensionRuntime,
|
|
19
|
+
ModelRuntime,
|
|
20
|
+
SessionManager,
|
|
21
|
+
SettingsManager,
|
|
22
|
+
type AgentSession,
|
|
23
|
+
type ExtensionAPI,
|
|
24
|
+
type ExtensionUIContext,
|
|
25
|
+
type ResourceLoader,
|
|
26
|
+
} from "@earendil-works/pi-coding-agent";
|
|
27
|
+
import { loadExtensionFromFactory } from "../node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js";
|
|
28
|
+
import { getThemeByName } from "../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js";
|
|
29
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
30
|
+
import { readSessionProfileBinding } from "../lib/session-profile-binding.ts";
|
|
31
|
+
import { SESSION_PROFILE_CUSTOM_TYPE } from "../lib/session-profile-persistence.ts";
|
|
32
|
+
import { replay, type Transcript } from "./fixtures/session-profile-v1/replay.ts";
|
|
33
|
+
|
|
34
|
+
// Actual SDK factory loader, AgentSession and replacement runtime. Only resource,
|
|
35
|
+
// auth and UI boundaries are fixture-owned. No prompts, provider streams or Git.
|
|
36
|
+
async function fixture(t: test.TestContext, memory = false, flushed = true, active?: string) {
|
|
37
|
+
const root = mkdtempSync(join(tmpdir(), "u3-public-"));
|
|
38
|
+
const config = join(root, "config"),
|
|
39
|
+
agentDir = join(root, "agent");
|
|
40
|
+
mkdirSync(config);
|
|
41
|
+
mkdirSync(agentDir);
|
|
42
|
+
const originalConfig = process.env.GENTLE_PI_CONFIG_HOME;
|
|
43
|
+
process.env.GENTLE_PI_CONFIG_HOME = config;
|
|
44
|
+
const profilesPath = join(config, "profiles.json");
|
|
45
|
+
const profiles = {
|
|
46
|
+
team: { worker: { model: "openai/gpt-4o" } },
|
|
47
|
+
empty: {},
|
|
48
|
+
live: { orchestrator: { model: "openai/gpt-5.2", thinking: "high" } },
|
|
49
|
+
};
|
|
50
|
+
const saveProfiles = () =>
|
|
51
|
+
writeFileSync(
|
|
52
|
+
profilesPath,
|
|
53
|
+
JSON.stringify({
|
|
54
|
+
kind: "gentle-pi.agent_model_profiles",
|
|
55
|
+
version: 1,
|
|
56
|
+
profiles,
|
|
57
|
+
...(active === undefined ? {} : { active }),
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
saveProfiles();
|
|
61
|
+
const modelRuntime = await ModelRuntime.create({
|
|
62
|
+
authPath: join(agentDir, "auth.json"),
|
|
63
|
+
modelsPath: null,
|
|
64
|
+
refreshOnCreate: false,
|
|
65
|
+
allowModelNetwork: false,
|
|
66
|
+
});
|
|
67
|
+
const baseModel = modelRuntime.getModel("openai", "gpt-4o");
|
|
68
|
+
assert.ok(baseModel, "fixture model catalog prerequisite");
|
|
69
|
+
assert.ok(
|
|
70
|
+
modelRuntime.getModel("openai", "gpt-5.2"),
|
|
71
|
+
"fixture live model catalog prerequisite",
|
|
72
|
+
);
|
|
73
|
+
let authCalls = 0,
|
|
74
|
+
providerCalls = 0;
|
|
75
|
+
let auth: () => Promise<unknown> = async () => ({ type: "api-key" });
|
|
76
|
+
modelRuntime.hasConfiguredAuth = () => true;
|
|
77
|
+
modelRuntime.checkAuth = (async () => {
|
|
78
|
+
authCalls++;
|
|
79
|
+
return auth();
|
|
80
|
+
}) as typeof modelRuntime.checkAuth;
|
|
81
|
+
modelRuntime.streamSimple = () => {
|
|
82
|
+
providerCalls++;
|
|
83
|
+
assert.fail("no provider requests");
|
|
84
|
+
};
|
|
85
|
+
const notices: Array<{ text: string; severity?: string }> = [],
|
|
86
|
+
errors: string[] = [],
|
|
87
|
+
events: string[] = [];
|
|
88
|
+
let selection: keyof typeof profiles | undefined;
|
|
89
|
+
let currentApi: ExtensionAPI | undefined;
|
|
90
|
+
let cancel = false;
|
|
91
|
+
const ui = {
|
|
92
|
+
theme: getThemeByName("dark")!,
|
|
93
|
+
getAllThemes: () => [{ name: "dark" }],
|
|
94
|
+
notify: (text: string, severity?: string) => notices.push({ text, severity }),
|
|
95
|
+
setStatus() {},
|
|
96
|
+
setWidget() {},
|
|
97
|
+
custom(factory: Parameters<ExtensionUIContext["custom"]>[0]) {
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
void Promise.resolve(
|
|
100
|
+
factory(
|
|
101
|
+
{
|
|
102
|
+
terminal: { rows: 24 },
|
|
103
|
+
requestRender() {},
|
|
104
|
+
stop() {},
|
|
105
|
+
start() {},
|
|
106
|
+
} as never,
|
|
107
|
+
getThemeByName("dark")!,
|
|
108
|
+
{} as never,
|
|
109
|
+
resolve as never,
|
|
110
|
+
),
|
|
111
|
+
).then((panel) => {
|
|
112
|
+
if (selection === undefined) panel.handleInput?.("\x1b");
|
|
113
|
+
else {
|
|
114
|
+
// Profiles are tabs in store order: left/right move one tab (a move may
|
|
115
|
+
// reopen the screen), and u uses the shown profile in this session.
|
|
116
|
+
const names = Object.keys(profiles);
|
|
117
|
+
const shown = () => {
|
|
118
|
+
const line = (panel.render?.(120) ?? [])[3] ?? "";
|
|
119
|
+
// eslint-disable-next-line no-control-regex
|
|
120
|
+
return line.replace(/\x1b\[[0-9;]*m/g, "").replace(/^│\s*/, "").split(/\s{3}|\s*│/)[0]?.trim() ?? "";
|
|
121
|
+
};
|
|
122
|
+
for (let step = 0; step < names.length && shown() !== selection; step++)
|
|
123
|
+
panel.handleInput?.(names.indexOf(selection) < names.indexOf(shown()) ? "\x1b[D" : "\x1b[C");
|
|
124
|
+
if (shown() === selection) {
|
|
125
|
+
selection = undefined;
|
|
126
|
+
panel.handleInput?.("u");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
} as unknown as ExtensionUIContext;
|
|
133
|
+
const make = async (
|
|
134
|
+
manager: SessionManager,
|
|
135
|
+
startEvent: {
|
|
136
|
+
type: "session_start";
|
|
137
|
+
reason: "startup" | "new" | "resume" | "fork";
|
|
138
|
+
previousSessionFile?: string;
|
|
139
|
+
},
|
|
140
|
+
) => {
|
|
141
|
+
let extensionRuntime = createExtensionRuntime();
|
|
142
|
+
let loaded: Awaited<ReturnType<typeof loadExtensionFromFactory>>[] = [];
|
|
143
|
+
const reload = async () => {
|
|
144
|
+
extensionRuntime = createExtensionRuntime();
|
|
145
|
+
const bus = createEventBus();
|
|
146
|
+
loaded = [
|
|
147
|
+
await loadExtensionFromFactory(
|
|
148
|
+
(pi) => {
|
|
149
|
+
currentApi = pi;
|
|
150
|
+
createGentleAiExtension({
|
|
151
|
+
nativeReviewCli: null,
|
|
152
|
+
candidateViews: null,
|
|
153
|
+
processEnv: { GENTLE_PI_AGENTS_CHILD: "1" },
|
|
154
|
+
resolveTelemetryTriggerBinary: () => {
|
|
155
|
+
throw Error("disabled fixture telemetry");
|
|
156
|
+
},
|
|
157
|
+
})(pi);
|
|
158
|
+
},
|
|
159
|
+
root,
|
|
160
|
+
bus,
|
|
161
|
+
extensionRuntime,
|
|
162
|
+
),
|
|
163
|
+
await loadExtensionFromFactory(
|
|
164
|
+
(pi) => {
|
|
165
|
+
pi.on("session_before_fork", () =>
|
|
166
|
+
cancel ? { cancel: true } : undefined,
|
|
167
|
+
);
|
|
168
|
+
pi.on("session_before_tree", () =>
|
|
169
|
+
cancel ? { cancel: true } : undefined,
|
|
170
|
+
);
|
|
171
|
+
pi.on("session_before_switch", () =>
|
|
172
|
+
cancel ? { cancel: true } : undefined,
|
|
173
|
+
);
|
|
174
|
+
pi.on("session_start", (e) => {
|
|
175
|
+
events.push(`start:${e.reason}`);
|
|
176
|
+
});
|
|
177
|
+
pi.on("session_shutdown", (e) => {
|
|
178
|
+
events.push(`shutdown:${e.reason}`);
|
|
179
|
+
});
|
|
180
|
+
pi.on("session_tree", () => {
|
|
181
|
+
events.push("tree");
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
root,
|
|
185
|
+
bus,
|
|
186
|
+
extensionRuntime,
|
|
187
|
+
),
|
|
188
|
+
];
|
|
189
|
+
};
|
|
190
|
+
const loader: ResourceLoader = {
|
|
191
|
+
getExtensions: () => ({
|
|
192
|
+
extensions: loaded,
|
|
193
|
+
errors: [],
|
|
194
|
+
runtime: extensionRuntime,
|
|
195
|
+
}),
|
|
196
|
+
getSkills: () => ({ skills: [], diagnostics: [] }),
|
|
197
|
+
getPrompts: () => ({ prompts: [], diagnostics: [] }),
|
|
198
|
+
getThemes: () => ({ themes: [], diagnostics: [] }),
|
|
199
|
+
getAgentsFiles: () => ({ agentsFiles: [] }),
|
|
200
|
+
getSystemPrompt: () => "Offline U3 fixture",
|
|
201
|
+
getSystemPromptSource: () => undefined,
|
|
202
|
+
getAppendSystemPrompt: () => [],
|
|
203
|
+
getAppendSystemPromptSources: () => [],
|
|
204
|
+
extendResources() {},
|
|
205
|
+
reload,
|
|
206
|
+
};
|
|
207
|
+
await reload();
|
|
208
|
+
const created = await createAgentSession({
|
|
209
|
+
cwd: root,
|
|
210
|
+
agentDir,
|
|
211
|
+
modelRuntime,
|
|
212
|
+
model: baseModel,
|
|
213
|
+
thinkingLevel: "off",
|
|
214
|
+
tools: [],
|
|
215
|
+
resourceLoader: loader,
|
|
216
|
+
settingsManager: SettingsManager.inMemory({
|
|
217
|
+
compaction: { enabled: false },
|
|
218
|
+
retry: { enabled: false },
|
|
219
|
+
cacheWarming: "off",
|
|
220
|
+
}),
|
|
221
|
+
sessionManager: manager,
|
|
222
|
+
sessionStartEvent: startEvent,
|
|
223
|
+
});
|
|
224
|
+
return { ...created, loader };
|
|
225
|
+
};
|
|
226
|
+
const manager = memory
|
|
227
|
+
? SessionManager.inMemory(root)
|
|
228
|
+
: SessionManager.create(root, join(root, "sessions"));
|
|
229
|
+
if (flushed)
|
|
230
|
+
manager.appendMessage({ role: "user", content: "fixture", timestamp: 1 });
|
|
231
|
+
const first = await make(manager, {
|
|
232
|
+
type: "session_start",
|
|
233
|
+
reason: "startup",
|
|
234
|
+
});
|
|
235
|
+
const bind = (session: AgentSession) =>
|
|
236
|
+
session.bindExtensions({
|
|
237
|
+
uiContext: ui,
|
|
238
|
+
mode: "tui",
|
|
239
|
+
onError: (e) => errors.push(JSON.stringify(e)),
|
|
240
|
+
});
|
|
241
|
+
await bind(first.session);
|
|
242
|
+
const runtime = new AgentSessionRuntime(
|
|
243
|
+
first.session,
|
|
244
|
+
{ cwd: root, agentDir } as never,
|
|
245
|
+
async (options) => {
|
|
246
|
+
const next = await make(
|
|
247
|
+
options.sessionManager,
|
|
248
|
+
options.sessionStartEvent! as never,
|
|
249
|
+
);
|
|
250
|
+
return {
|
|
251
|
+
...next,
|
|
252
|
+
services: { cwd: root, agentDir } as never,
|
|
253
|
+
diagnostics: [],
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
);
|
|
257
|
+
runtime.setRebindSession(bind);
|
|
258
|
+
t.after(async () => {
|
|
259
|
+
await runtime.dispose();
|
|
260
|
+
if (originalConfig === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
261
|
+
else process.env.GENTLE_PI_CONFIG_HOME = originalConfig;
|
|
262
|
+
rmSync(root, { recursive: true, force: true });
|
|
263
|
+
assert.equal(providerCalls, 0);
|
|
264
|
+
assert.deepEqual(errors, []);
|
|
265
|
+
});
|
|
266
|
+
const enter = async (
|
|
267
|
+
name: keyof typeof profiles = "team",
|
|
268
|
+
session: AgentSession = runtime.session,
|
|
269
|
+
) => {
|
|
270
|
+
selection = name;
|
|
271
|
+
const command = session.extensionRunner.getCommand("gentle:profiles");
|
|
272
|
+
assert.ok(command);
|
|
273
|
+
await command.handler("", session.extensionRunner.createCommandContext());
|
|
274
|
+
};
|
|
275
|
+
const clear = () =>
|
|
276
|
+
runtime.session.extensionRunner
|
|
277
|
+
.getCommand("gentle:profiles")!
|
|
278
|
+
.handler("clear", runtime.session.extensionRunner.createCommandContext());
|
|
279
|
+
const binding = () =>
|
|
280
|
+
readSessionProfileBinding(runtime.session.sessionManager.getSessionId());
|
|
281
|
+
const family = () =>
|
|
282
|
+
runtime.session.sessionManager
|
|
283
|
+
.getBranch()
|
|
284
|
+
.filter(
|
|
285
|
+
(e) => e.type === "custom" && e.customType === SESSION_PROFILE_CUSTOM_TYPE,
|
|
286
|
+
);
|
|
287
|
+
const protectedBytes = () => [
|
|
288
|
+
readFileSync(profilesPath, "utf8"),
|
|
289
|
+
existsSync(join(config, "models.json")),
|
|
290
|
+
existsSync(join(agentDir, "settings.json")),
|
|
291
|
+
existsSync(join(root, ".pi", "subagents.json")),
|
|
292
|
+
];
|
|
293
|
+
return {
|
|
294
|
+
root,
|
|
295
|
+
runtime,
|
|
296
|
+
manager,
|
|
297
|
+
notices,
|
|
298
|
+
events,
|
|
299
|
+
errors,
|
|
300
|
+
profiles,
|
|
301
|
+
saveProfiles,
|
|
302
|
+
enter,
|
|
303
|
+
clear,
|
|
304
|
+
binding,
|
|
305
|
+
family,
|
|
306
|
+
protectedBytes,
|
|
307
|
+
api: () => currentApi!,
|
|
308
|
+
authCalls: () => authCalls,
|
|
309
|
+
setAuth: (fn: typeof auth) => {
|
|
310
|
+
auth = fn;
|
|
311
|
+
},
|
|
312
|
+
cancel: (value: boolean) => {
|
|
313
|
+
cancel = value;
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
for (const memory of [false, true])
|
|
319
|
+
for (const flushed of [false, true])
|
|
320
|
+
test(`U3 Enter public component persists or explicitly reports preflush (${memory}, ${flushed})`, async (t) => {
|
|
321
|
+
const f = await fixture(t, memory, flushed),
|
|
322
|
+
before = f.protectedBytes();
|
|
323
|
+
await f.enter();
|
|
324
|
+
assert.equal(
|
|
325
|
+
f.family().length,
|
|
326
|
+
1,
|
|
327
|
+
"Enter appends one public profile record before publication",
|
|
328
|
+
);
|
|
329
|
+
assert.equal(f.authCalls(), 0);
|
|
330
|
+
assert.deepEqual(f.protectedBytes(), before);
|
|
331
|
+
// A flushed in-memory session never corroborates its append (published
|
|
332
|
+
// append controller: append-not-corroborated), so Enter adopts nothing.
|
|
333
|
+
if (memory && flushed) {
|
|
334
|
+
assert.equal(f.binding(), undefined);
|
|
335
|
+
assert.match(f.notices.at(-1)?.text ?? "", /Session profile authority is unavailable/);
|
|
336
|
+
} else {
|
|
337
|
+
assert.equal(f.binding()?.name, "team");
|
|
338
|
+
assert.deepEqual(f.binding()?.modelProfiles, f.profiles.team);
|
|
339
|
+
assert.match(
|
|
340
|
+
f.notices.at(-1)?.text ?? "",
|
|
341
|
+
memory || !flushed ? /not yet persisted/ : /persisted/,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
await f.runtime.session.reload();
|
|
345
|
+
assert.equal(
|
|
346
|
+
f.binding()?.name,
|
|
347
|
+
memory || !flushed ? undefined : "team",
|
|
348
|
+
"reload restores only disk-corroborated state",
|
|
349
|
+
);
|
|
350
|
+
assert.equal(
|
|
351
|
+
f.authCalls(),
|
|
352
|
+
0,
|
|
353
|
+
"no restoration-time orchestrator application",
|
|
354
|
+
);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
test("U3 Enter composes append, exact publication and existing live controls without shared writes", async (t) => {
|
|
358
|
+
const f = await fixture(t),
|
|
359
|
+
before = f.protectedBytes();
|
|
360
|
+
f.setAuth(async () => {
|
|
361
|
+
assert.equal(f.binding()?.name, "live", "publication precedes live effects");
|
|
362
|
+
assert.equal(f.family().length, 1);
|
|
363
|
+
assert.ok(
|
|
364
|
+
readFileSync(f.runtime.session.sessionFile!, "utf8").includes(
|
|
365
|
+
SESSION_PROFILE_CUSTOM_TYPE,
|
|
366
|
+
),
|
|
367
|
+
);
|
|
368
|
+
return { type: "api-key" };
|
|
369
|
+
});
|
|
370
|
+
await f.enter("live");
|
|
371
|
+
assert.equal(f.runtime.session.model?.id, "gpt-5.2");
|
|
372
|
+
assert.equal(f.runtime.session.thinkingLevel, "high");
|
|
373
|
+
assert.equal(f.authCalls(), 1);
|
|
374
|
+
assert.deepEqual(f.protectedBytes(), before);
|
|
375
|
+
await f.enter("empty");
|
|
376
|
+
assert.deepEqual(f.binding()?.modelProfiles, {});
|
|
377
|
+
assert.equal(f.authCalls(), 1, "empty profile does not switch model");
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
for (const failure of ["before-append", "EISDIR"] as const)
|
|
381
|
+
test(`U3 failed Enter ${failure} adopts nothing and applies no live effects`, async (t) => {
|
|
382
|
+
const f = await fixture(t);
|
|
383
|
+
await f.enter();
|
|
384
|
+
const file = f.manager.getSessionFile()!,
|
|
385
|
+
disk = readFileSync(file, "utf8"),
|
|
386
|
+
before = f.protectedBytes();
|
|
387
|
+
const append = f.manager.appendCustomEntry.bind(f.manager);
|
|
388
|
+
if (failure === "EISDIR") {
|
|
389
|
+
renameSync(file, `${file}.saved`);
|
|
390
|
+
mkdirSync(file);
|
|
391
|
+
} else
|
|
392
|
+
f.manager.appendCustomEntry = () => {
|
|
393
|
+
throw Error("fixture rejected append");
|
|
394
|
+
};
|
|
395
|
+
await f.enter("live");
|
|
396
|
+
assert.equal(f.authCalls(), 0);
|
|
397
|
+
assert.equal(f.runtime.session.model?.id, "gpt-4o");
|
|
398
|
+
assert.equal(f.binding()?.name, failure === "EISDIR" ? undefined : "team");
|
|
399
|
+
assert.equal(f.notices.at(-1)?.severity, "warning");
|
|
400
|
+
assert.doesNotMatch(f.notices.at(-1)?.text ?? "", /bound profile "live"/);
|
|
401
|
+
assert.deepEqual(f.protectedBytes(), before);
|
|
402
|
+
f.manager.appendCustomEntry = append;
|
|
403
|
+
if (failure === "EISDIR") {
|
|
404
|
+
rmSync(file, { recursive: true });
|
|
405
|
+
renameSync(`${file}.saved`, file);
|
|
406
|
+
}
|
|
407
|
+
assert.equal(
|
|
408
|
+
readFileSync(file, "utf8"),
|
|
409
|
+
disk,
|
|
410
|
+
"rejected entry did not reach disk",
|
|
411
|
+
);
|
|
412
|
+
await f.runtime.session.reload();
|
|
413
|
+
assert.equal(
|
|
414
|
+
f.binding()?.name,
|
|
415
|
+
"team",
|
|
416
|
+
"quarantine survives module replacement",
|
|
417
|
+
);
|
|
418
|
+
assert.equal(f.authCalls(), 0);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
for (const customType of [
|
|
422
|
+
SESSION_PROFILE_CUSTOM_TYPE,
|
|
423
|
+
"gentle-pi.session-profile/v99",
|
|
424
|
+
])
|
|
425
|
+
test(`U3 terminal invalid/future selection ${customType} blocks until explicit recovery`, async (t) => {
|
|
426
|
+
const f = await fixture(t);
|
|
427
|
+
await f.enter();
|
|
428
|
+
f.manager.appendCustomEntry(customType, { invalid: true });
|
|
429
|
+
await f.runtime.session.reload();
|
|
430
|
+
assert.equal(f.binding(), undefined);
|
|
431
|
+
await f.enter();
|
|
432
|
+
assert.equal(f.binding()?.name, "team");
|
|
433
|
+
assert.equal(f.authCalls(), 0);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
for (const memory of [false, true])
|
|
437
|
+
for (const cut of ["before", "at", "root", "label"] as const)
|
|
438
|
+
test(`U3 actual runtime fork retained cut ${cut} (${memory})`, async (t) => {
|
|
439
|
+
const f = await fixture(t, memory);
|
|
440
|
+
const root = f.manager.getBranch()[0].id;
|
|
441
|
+
await f.enter();
|
|
442
|
+
const profile = f.manager.getLeafId()!;
|
|
443
|
+
const user = f.manager.appendMessage({
|
|
444
|
+
role: "user",
|
|
445
|
+
content: "cut",
|
|
446
|
+
timestamp: 2,
|
|
447
|
+
});
|
|
448
|
+
f.manager.appendLabelChange(profile, "profile-label");
|
|
449
|
+
const before = readSessionProfileBinding(f.manager.getSessionId());
|
|
450
|
+
const target =
|
|
451
|
+
cut === "root" ? root : cut === "at" || cut === "label" ? profile : user;
|
|
452
|
+
const result = await f.runtime.fork(target, {
|
|
453
|
+
position: cut === "root" || cut === "before" ? "before" : "at",
|
|
454
|
+
});
|
|
455
|
+
assert.equal(result.cancelled, false);
|
|
456
|
+
assert.equal(
|
|
457
|
+
f.binding()?.name,
|
|
458
|
+
cut === "root" || memory ? undefined : "team",
|
|
459
|
+
"only retained corroborated records restore",
|
|
460
|
+
);
|
|
461
|
+
assert.equal(f.authCalls(), 0);
|
|
462
|
+
// In memory the flushed append is never corroborated, so nothing was bound.
|
|
463
|
+
assert.deepEqual(before?.modelProfiles, memory ? undefined : f.profiles.team);
|
|
464
|
+
assert.ok(f.events.includes("shutdown:fork"));
|
|
465
|
+
assert.ok(f.events.includes("start:fork"));
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
test("U3 public runtime cancellation and unsaved rejection preserve explicit authority", async (t) => {
|
|
469
|
+
const f = await fixture(t, false, false);
|
|
470
|
+
await f.enter();
|
|
471
|
+
const leaf = f.manager.getLeafId()!;
|
|
472
|
+
const branch = f.manager.getBranch(),
|
|
473
|
+
before = f.binding();
|
|
474
|
+
f.cancel(true);
|
|
475
|
+
assert.equal((await f.runtime.fork(leaf, { position: "at" })).cancelled, true);
|
|
476
|
+
assert.equal((await f.runtime.newSession()).cancelled, true);
|
|
477
|
+
assert.deepEqual(f.manager.getBranch(), branch);
|
|
478
|
+
assert.deepEqual(f.binding(), before);
|
|
479
|
+
f.cancel(false);
|
|
480
|
+
await assert.rejects(
|
|
481
|
+
f.runtime.fork(leaf, { position: "at" }),
|
|
482
|
+
/has not been saved/,
|
|
483
|
+
);
|
|
484
|
+
assert.deepEqual(f.binding(), before);
|
|
485
|
+
assert.equal(
|
|
486
|
+
f.events.some((e) => e.startsWith("shutdown")),
|
|
487
|
+
false,
|
|
488
|
+
);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
test("U3 actual new/resume/tree/reload revoke stale public contexts without restoration effects", async (t) => {
|
|
492
|
+
const f = await fixture(t);
|
|
493
|
+
await f.enter();
|
|
494
|
+
const file = f.manager.getSessionFile()!,
|
|
495
|
+
old = f.runtime.session;
|
|
496
|
+
const profile = f.manager.getLeafId()!;
|
|
497
|
+
const later = f.manager.appendCustomEntry("ordinary", {});
|
|
498
|
+
await old.navigateTree(profile);
|
|
499
|
+
assert.equal(f.binding()?.name, "team");
|
|
500
|
+
await old.navigateTree(later);
|
|
501
|
+
assert.equal(f.binding()?.name, "team");
|
|
502
|
+
await f.runtime.newSession();
|
|
503
|
+
assert.equal(f.binding(), undefined);
|
|
504
|
+
await assert.rejects(f.enter("live", old));
|
|
505
|
+
assert.equal(f.authCalls(), 0);
|
|
506
|
+
await f.runtime.switchSession(file);
|
|
507
|
+
assert.equal(f.binding()?.name, "team");
|
|
508
|
+
await f.runtime.session.reload();
|
|
509
|
+
assert.equal(f.binding()?.name, "team");
|
|
510
|
+
assert.equal(f.authCalls(), 0);
|
|
511
|
+
assert.ok(f.events.includes("start:new"));
|
|
512
|
+
assert.ok(f.events.includes("start:resume"));
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
for (const transition of ["fork", "tree", "reload", "new"] as const)
|
|
516
|
+
test(`U3 pending Enter serializes before ${transition} on actual public SDK`, async (t) => {
|
|
517
|
+
const f = await fixture(t);
|
|
518
|
+
const leaf = f.manager.getLeafId()!;
|
|
519
|
+
// Tree navigation to the current leaf is a no-op, so move the leaf away first.
|
|
520
|
+
if (transition === "tree") f.manager.appendCustomEntry("ordinary", {});
|
|
521
|
+
let release!: () => void, started!: () => void;
|
|
522
|
+
const ready = new Promise<void>((resolve) => {
|
|
523
|
+
started = resolve;
|
|
524
|
+
});
|
|
525
|
+
f.setAuth(() => {
|
|
526
|
+
started();
|
|
527
|
+
return new Promise((resolve) => {
|
|
528
|
+
release = () => resolve({ type: "api-key" });
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
const enter = f.enter("live");
|
|
532
|
+
// RED must fail an assertion, not hang waiting for a nonexistent live call.
|
|
533
|
+
await Promise.race([ready, enter]);
|
|
534
|
+
assert.equal(f.authCalls(), 1, "Enter reaches the existing live control");
|
|
535
|
+
const branch = JSON.stringify(f.manager.getBranch()),
|
|
536
|
+
before = f.binding();
|
|
537
|
+
let transitioned = false;
|
|
538
|
+
const move = (
|
|
539
|
+
transition === "fork"
|
|
540
|
+
? f.runtime.fork(leaf, { position: "at" })
|
|
541
|
+
: transition === "tree"
|
|
542
|
+
? f.runtime.session.navigateTree(leaf)
|
|
543
|
+
: transition === "reload"
|
|
544
|
+
? f.runtime.session.reload()
|
|
545
|
+
: f.runtime.newSession()
|
|
546
|
+
).then(() => {
|
|
547
|
+
transitioned = true;
|
|
548
|
+
});
|
|
549
|
+
// Fork/tree/reload/new take several ticks unserialized; sample well after that.
|
|
550
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
551
|
+
assert.equal(
|
|
552
|
+
f.events.some((e) => e.startsWith("shutdown")),
|
|
553
|
+
false,
|
|
554
|
+
"no owner shutdown while Enter awaits authentication",
|
|
555
|
+
);
|
|
556
|
+
assert.equal(f.events.includes("tree"), false, "no tree navigation yet");
|
|
557
|
+
assert.equal(transitioned, false, "transition waits for Enter to settle");
|
|
558
|
+
if (transition !== "reload") {
|
|
559
|
+
assert.equal(
|
|
560
|
+
JSON.stringify(f.manager.getBranch()),
|
|
561
|
+
branch,
|
|
562
|
+
"branch is not copied or moved while Enter is pending",
|
|
563
|
+
);
|
|
564
|
+
assert.deepEqual(f.binding(), before);
|
|
565
|
+
}
|
|
566
|
+
release();
|
|
567
|
+
await Promise.all([enter, move]);
|
|
568
|
+
assert.equal(transitioned, true);
|
|
569
|
+
assert.equal(
|
|
570
|
+
transition === "tree"
|
|
571
|
+
? f.events.includes("tree")
|
|
572
|
+
: f.events.includes(`shutdown:${transition}`),
|
|
573
|
+
true,
|
|
574
|
+
"transition completes once Enter settles",
|
|
575
|
+
);
|
|
576
|
+
assert.equal(f.authCalls(), 1);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// gentle-shell#2742, section 3: a new session knows the startup state it froze.
|
|
580
|
+
const data = (entry: unknown) => (entry as { data?: unknown } | undefined)?.data;
|
|
581
|
+
for (const active of ["live", undefined] as const)
|
|
582
|
+
test(`A2 clear in a new session goes back to the startup ${active ?? "no profile"} and v1 replays it the same`, async (t) => {
|
|
583
|
+
const f = await fixture(t, false, false, active);
|
|
584
|
+
f.manager.appendMessage({ role: "user", content: "first", timestamp: 2 });
|
|
585
|
+
await f.enter("team");
|
|
586
|
+
const startup = active === undefined ? "none" : { origin: "global", name: active, modelProfiles: f.profiles[active] };
|
|
587
|
+
assert.deepEqual(data(f.family().at(-1)), { kind: "bind", origin: "user", name: "team", modelProfiles: f.profiles.team, startup });
|
|
588
|
+
await f.clear();
|
|
589
|
+
assert.deepEqual(data(f.family().at(-1)), startup === "none" ? { kind: "clear", startup } : { kind: "bind", ...startup }, "the orchestrator key travels with the startup bind");
|
|
590
|
+
assert.match(f.notices.at(-1)?.text ?? "", active === undefined ? /go back to no profile, as this session started/ : /go back to the profile this session started with, "live", and use it/);
|
|
591
|
+
assert.equal(f.runtime.session.model?.id, "gpt-4o", "the live orchestrator is unchanged");
|
|
592
|
+
const transcript: Transcript = { records: f.family().map(data), defaults: { profiles: f.profiles as Transcript["defaults"]["profiles"], ...(active ? { active } : {}) } };
|
|
593
|
+
const [current, v1] = [replay("current", transcript), replay("v1", transcript)];
|
|
594
|
+
assert.equal(v1.notice, undefined, "v1 finds no definition drift");
|
|
595
|
+
assert.deepEqual([current.routing, current.foreignRouting], [v1.routing, v1.foreignRouting].map((r) => r && Object.fromEntries(Object.entries(r).filter(([k]) => k !== "orchestrator"))));
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
test("A2 clear in a resumed session without a recorded startup state writes a legacy clear", async (t) => {
|
|
599
|
+
const f = await fixture(t, false, true, "live");
|
|
600
|
+
await f.enter("team");
|
|
601
|
+
assert.equal(Object.hasOwn(data(f.family().at(-1)) as object, "startup"), false);
|
|
602
|
+
await f.clear();
|
|
603
|
+
assert.deepEqual(data(f.family().at(-1)), { kind: "clear" });
|
|
604
|
+
assert.match(f.notices.at(-1)?.text ?? "", /New launches use the routing without a session profile/);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
test("A2 clear of an invalid newest entry in a new session writes the startup profile", async (t) => {
|
|
608
|
+
const f = await fixture(t, false, false, "live");
|
|
609
|
+
f.manager.appendMessage({ role: "user", content: "first", timestamp: 2 });
|
|
610
|
+
f.manager.appendCustomEntry(SESSION_PROFILE_CUSTOM_TYPE, { invalid: true });
|
|
611
|
+
await f.clear();
|
|
612
|
+
assert.deepEqual(data(f.family().at(-1)), { kind: "bind", origin: "global", name: "live", modelProfiles: f.profiles.live });
|
|
613
|
+
assert.match(f.notices.at(-1)?.text ?? "", /cleared the unreadable session profile record \(persisted in this session\)\. New launches go back to the profile this session started with, "live"/);
|
|
614
|
+
assert.equal(f.binding()?.origin, "global");
|
|
615
|
+
});
|