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
|
@@ -10,11 +10,14 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
createSessionProfileBind,
|
|
12
12
|
createSessionProfileClear,
|
|
13
|
+
createSessionProfileStartupBind,
|
|
13
14
|
isSessionProfileFamilyEntry,
|
|
14
15
|
readSessionProfileEntry,
|
|
15
16
|
SESSION_PROFILE_CUSTOM_TYPE,
|
|
16
17
|
type SessionProfileBindPayload,
|
|
17
18
|
type SessionProfileClearPayload,
|
|
19
|
+
type SessionProfileStartupOrigin,
|
|
20
|
+
type SessionProfileStartupState,
|
|
18
21
|
} from "./session-profile-persistence.ts";
|
|
19
22
|
|
|
20
23
|
type Entry = {
|
|
@@ -49,7 +52,8 @@ export type SessionProfileControllerReason =
|
|
|
49
52
|
| "detached-source"
|
|
50
53
|
| "source-changed"
|
|
51
54
|
| "unobservable-append"
|
|
52
|
-
| "unobservable-source"
|
|
55
|
+
| "unobservable-source"
|
|
56
|
+
| "unavailable-lifecycle";
|
|
53
57
|
export type SessionProfileAppendOutcome = {
|
|
54
58
|
status:
|
|
55
59
|
| "persisted"
|
|
@@ -84,8 +88,15 @@ export interface SessionProfileAttachment {
|
|
|
84
88
|
bind(
|
|
85
89
|
name: string,
|
|
86
90
|
models: SessionProfileBindPayload["modelProfiles"],
|
|
91
|
+
startup?: SessionProfileStartupState,
|
|
87
92
|
): SessionProfileAppendOutcome;
|
|
88
|
-
|
|
93
|
+
/** Record the profile the session took at startup (gentle-shell#2742). */
|
|
94
|
+
bindStartup(
|
|
95
|
+
origin: SessionProfileStartupOrigin,
|
|
96
|
+
name: string,
|
|
97
|
+
models: SessionProfileBindPayload["modelProfiles"],
|
|
98
|
+
): SessionProfileAppendOutcome;
|
|
99
|
+
clear(startup?: "none"): SessionProfileAppendOutcome;
|
|
89
100
|
refresh(): SessionProfileAppendOutcome;
|
|
90
101
|
}
|
|
91
102
|
export type SessionProfileAttachContext = {
|
|
@@ -465,13 +476,17 @@ export function createSessionProfileAppendController(
|
|
|
465
476
|
const epoch = generation;
|
|
466
477
|
const live = () => source !== undefined && epoch === generation;
|
|
467
478
|
return {
|
|
468
|
-
bind: (name, models) =>
|
|
479
|
+
bind: (name, models, startup) =>
|
|
480
|
+
live()
|
|
481
|
+
? append(createSessionProfileBind(name, models, startup))
|
|
482
|
+
: unavailable("detached-source"),
|
|
483
|
+
bindStartup: (origin, name, models) =>
|
|
469
484
|
live()
|
|
470
|
-
? append(
|
|
485
|
+
? append(createSessionProfileStartupBind(origin, name, models))
|
|
471
486
|
: unavailable("detached-source"),
|
|
472
|
-
clear: () =>
|
|
487
|
+
clear: (startup) =>
|
|
473
488
|
live()
|
|
474
|
-
? append(createSessionProfileClear())
|
|
489
|
+
? append(createSessionProfileClear(startup))
|
|
475
490
|
: unavailable("detached-source"),
|
|
476
491
|
refresh: () => (live() ? refresh() : unavailable("detached-source")),
|
|
477
492
|
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Current admission/publication bridge. Controller evidence stays in the
|
|
2
|
+
// integration owner; this module owns no quarantine, capability or cache.
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readSessionProfileDisk } from "./session-profile-disk-reader.ts";
|
|
5
|
+
import {
|
|
6
|
+
readCurrentSessionProfileOutcome,
|
|
7
|
+
type SessionProfileLifecycleManager,
|
|
8
|
+
} from "./session-profile-integration.ts";
|
|
9
|
+
import type { SessionProfileAppendOutcome } from "./session-profile-append-controller.ts";
|
|
10
|
+
import {
|
|
11
|
+
bindSessionProfile,
|
|
12
|
+
clearSessionProfileBinding,
|
|
13
|
+
readSessionProfileBinding,
|
|
14
|
+
recordSessionProfileStartupNone,
|
|
15
|
+
type SessionProfileBinding,
|
|
16
|
+
} from "./session-profile-binding.ts";
|
|
17
|
+
|
|
18
|
+
export type SessionProfileAuthority =
|
|
19
|
+
| { available: true; binding?: SessionProfileBinding }
|
|
20
|
+
| { available: false };
|
|
21
|
+
|
|
22
|
+
/** Publish only the returned detached snapshot, including preserved disk state
|
|
23
|
+
* on append failure. Terminal invalid/future records never expose a fallback.
|
|
24
|
+
* The record's origin and startup state travel with it (gentle-shell#2742), so
|
|
25
|
+
* a startup record is never read as an explicit choice and a startup-none
|
|
26
|
+
* clear stays distinct from a legacy clear.
|
|
27
|
+
*/
|
|
28
|
+
export function publishSessionProfileOutcome(
|
|
29
|
+
manager: SessionProfileLifecycleManager,
|
|
30
|
+
outcome: SessionProfileAppendOutcome,
|
|
31
|
+
): SessionProfileAuthority {
|
|
32
|
+
const id = manager.getSessionId();
|
|
33
|
+
const state = outcome.state;
|
|
34
|
+
if (state.status === "bound") {
|
|
35
|
+
const { name, origin, modelProfiles, startup } = state.binding;
|
|
36
|
+
bindSessionProfile(id, name, modelProfiles, { origin, ...(startup === undefined ? {} : { startup }) });
|
|
37
|
+
return { available: true, binding: readSessionProfileBinding(id) };
|
|
38
|
+
}
|
|
39
|
+
if (state.status === "cleared" && state.startup === "none") recordSessionProfileStartupNone(id);
|
|
40
|
+
else clearSessionProfileBinding(id);
|
|
41
|
+
return state.status === "absent" || state.status === "cleared"
|
|
42
|
+
? { available: true }
|
|
43
|
+
: { available: false };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function noProfile(manager: SessionProfileLifecycleManager): boolean {
|
|
47
|
+
const entries = manager.getBranch();
|
|
48
|
+
return (
|
|
49
|
+
Array.isArray(entries) &&
|
|
50
|
+
!entries.some((entry) => {
|
|
51
|
+
if (!entry || typeof entry !== "object") return true;
|
|
52
|
+
const value = entry as { type?: unknown; customType?: unknown };
|
|
53
|
+
return (
|
|
54
|
+
value.type === "custom" &&
|
|
55
|
+
typeof value.customType === "string" &&
|
|
56
|
+
value.customType.startsWith("gentle-pi.session-profile/")
|
|
57
|
+
);
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Load-order independent read. Without an owner, disk is read-only authority;
|
|
63
|
+
* with an owner, every request revalidates its existing negative evidence.
|
|
64
|
+
* An ordinary empty/preflush branch with no profile meaning retains its legacy
|
|
65
|
+
* routing. Missing disk never restores a profile found only in memory. A saved
|
|
66
|
+
* profile-less branch is decided before any disk read, so unrelated session-file
|
|
67
|
+
* damage never blocks it, and a binding left from another branch is dropped.
|
|
68
|
+
*/
|
|
69
|
+
export function readSessionProfileAuthority(
|
|
70
|
+
manager: SessionProfileLifecycleManager,
|
|
71
|
+
): SessionProfileAuthority {
|
|
72
|
+
try {
|
|
73
|
+
const id = manager.getSessionId(),
|
|
74
|
+
file = manager.getSessionFile?.();
|
|
75
|
+
if (!id) return { available: false };
|
|
76
|
+
if (noProfile(manager) && file !== undefined && existsSync(file)) {
|
|
77
|
+
clearSessionProfileBinding(id);
|
|
78
|
+
return { available: true };
|
|
79
|
+
}
|
|
80
|
+
const owned = readCurrentSessionProfileOutcome(manager);
|
|
81
|
+
const outcome = owned ?? {
|
|
82
|
+
status: "persisted" as const,
|
|
83
|
+
state: readSessionProfileDisk(manager),
|
|
84
|
+
};
|
|
85
|
+
const empty =
|
|
86
|
+
outcome.state.status === "indeterminate" &&
|
|
87
|
+
["missing-source", "unreadable-file"].includes(outcome.state.reason) &&
|
|
88
|
+
noProfile(manager) &&
|
|
89
|
+
(file === undefined || !existsSync(file));
|
|
90
|
+
if (manager.getSessionId() !== id || manager.getSessionFile?.() !== file)
|
|
91
|
+
return { available: false };
|
|
92
|
+
if (empty) {
|
|
93
|
+
if (owned) clearSessionProfileBinding(id);
|
|
94
|
+
return {
|
|
95
|
+
available: true,
|
|
96
|
+
binding: owned ? undefined : readSessionProfileBinding(id),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return publishSessionProfileOutcome(manager, outcome);
|
|
100
|
+
} catch {
|
|
101
|
+
try {
|
|
102
|
+
clearSessionProfileBinding(manager.getSessionId());
|
|
103
|
+
} catch {
|
|
104
|
+
/* Unobservable manager. */
|
|
105
|
+
}
|
|
106
|
+
return { available: false };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function requireSessionProfileAuthority(
|
|
111
|
+
manager: SessionProfileLifecycleManager,
|
|
112
|
+
): SessionProfileAuthority & { available: true } {
|
|
113
|
+
const authority = readSessionProfileAuthority(manager);
|
|
114
|
+
if (!authority.available)
|
|
115
|
+
throw new Error(
|
|
116
|
+
"Session profile authority unavailable; affected launches are blocked until corroborated state or an explicit selection is available.",
|
|
117
|
+
);
|
|
118
|
+
return authority;
|
|
119
|
+
}
|
|
@@ -17,11 +17,24 @@
|
|
|
17
17
|
// `Symbol.for` key, which every evaluation of this module in one process
|
|
18
18
|
// resolves to the same symbol and therefore the same shared Map.
|
|
19
19
|
import type { AgentModelConfig } from "./model-routing-authority.ts";
|
|
20
|
+
import type { SessionProfileOrigin, SessionProfileStartupState } from "./session-profile-persistence.ts";
|
|
20
21
|
|
|
21
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* A session's bound profile: its saved name plus the routing snapshot taken at
|
|
24
|
+
* bind time, the origin of the record it came from (`user` for an explicit
|
|
25
|
+
* choice) and, when known, the startup state the record carried (gentle-shell#2742).
|
|
26
|
+
*/
|
|
22
27
|
export interface SessionProfileBinding {
|
|
23
28
|
readonly name: string;
|
|
29
|
+
readonly origin: SessionProfileOrigin;
|
|
24
30
|
readonly modelProfiles: AgentModelConfig;
|
|
31
|
+
readonly startup?: SessionProfileStartupState;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Record provenance for one binding; omitted fields keep today's explicit choice. */
|
|
35
|
+
export interface SessionProfileBindingProvenance {
|
|
36
|
+
origin?: SessionProfileOrigin;
|
|
37
|
+
startup?: SessionProfileStartupState;
|
|
25
38
|
}
|
|
26
39
|
|
|
27
40
|
const bindingsRegistryKey = Symbol.for("gentle-pi:session-profile-bindings");
|
|
@@ -33,19 +46,42 @@ function bindingsBySession(): Map<string, SessionProfileBinding> {
|
|
|
33
46
|
return holder[bindingsRegistryKey]!;
|
|
34
47
|
}
|
|
35
48
|
|
|
49
|
+
// Sessions whose newest record says they started without a profile
|
|
50
|
+
// (gentle-shell#2742), kept apart from the bindings because no profile is bound.
|
|
51
|
+
const startupNoneRegistryKey = Symbol.for("gentle-pi:session-profile-startup-none");
|
|
52
|
+
|
|
53
|
+
function startupNoneSessions(): Set<string> {
|
|
54
|
+
const holder = globalThis as { [startupNoneRegistryKey]?: Set<string> };
|
|
55
|
+
return (holder[startupNoneRegistryKey] ??= new Set());
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
/** Copy one routing snapshot level deep — the layer a defensive copy needs, so a binding never aliases its source or its readers. */
|
|
37
59
|
function cloneProfiles(profiles: AgentModelConfig): AgentModelConfig {
|
|
38
60
|
return Object.fromEntries(Object.entries(profiles).map(([agent, entry]) => [agent, { ...entry }]));
|
|
39
61
|
}
|
|
40
62
|
|
|
63
|
+
function cloneBinding(binding: SessionProfileBinding): SessionProfileBinding {
|
|
64
|
+
const { startup } = binding;
|
|
65
|
+
const copy = { name: binding.name, origin: binding.origin, modelProfiles: cloneProfiles(binding.modelProfiles) };
|
|
66
|
+
if (startup === undefined) return copy;
|
|
67
|
+
return { ...copy, startup: startup === "none" ? startup : { ...startup, modelProfiles: cloneProfiles(startup.modelProfiles) } };
|
|
68
|
+
}
|
|
69
|
+
|
|
41
70
|
/**
|
|
42
71
|
* Bind (or rebind) one parent session to a profile. The routing snapshot is
|
|
43
72
|
* copied, so later edits to the caller's object or to the saved profile
|
|
44
73
|
* definition never mutate a session that already bound it; refreshing a bound
|
|
45
74
|
* session requires an explicit re-selection.
|
|
46
75
|
*/
|
|
47
|
-
export function bindSessionProfile(
|
|
48
|
-
|
|
76
|
+
export function bindSessionProfile(
|
|
77
|
+
sessionId: string,
|
|
78
|
+
name: string,
|
|
79
|
+
modelProfiles: AgentModelConfig,
|
|
80
|
+
provenance: SessionProfileBindingProvenance = {},
|
|
81
|
+
): void {
|
|
82
|
+
const { origin = "user", startup } = provenance;
|
|
83
|
+
startupNoneSessions().delete(sessionId);
|
|
84
|
+
bindingsBySession().set(sessionId, cloneBinding({ name, origin, modelProfiles, ...(startup === undefined ? {} : { startup }) }));
|
|
49
85
|
}
|
|
50
86
|
|
|
51
87
|
/**
|
|
@@ -56,17 +92,30 @@ export function bindSessionProfile(sessionId: string, name: string, modelProfile
|
|
|
56
92
|
export function readSessionProfileBinding(sessionId: string | undefined): SessionProfileBinding | undefined {
|
|
57
93
|
if (sessionId === undefined) return undefined;
|
|
58
94
|
const binding = bindingsBySession().get(sessionId);
|
|
59
|
-
return binding === undefined ? undefined :
|
|
95
|
+
return binding === undefined ? undefined : cloneBinding(binding);
|
|
60
96
|
}
|
|
61
97
|
|
|
62
|
-
/** Remove one session's binding without touching any other session's. */
|
|
98
|
+
/** Remove one session's binding, and any recorded startup without a profile, without touching any other session's. */
|
|
63
99
|
export function clearSessionProfileBinding(sessionId: string): void {
|
|
64
100
|
bindingsBySession().delete(sessionId);
|
|
101
|
+
startupNoneSessions().delete(sessionId);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Record that the session's newest record says it started with no profile in any layer; replaces its binding. */
|
|
105
|
+
export function recordSessionProfileStartupNone(sessionId: string): void {
|
|
106
|
+
bindingsBySession().delete(sessionId);
|
|
107
|
+
startupNoneSessions().add(sessionId);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Whether the session's newest record says it started with no profile in any layer. */
|
|
111
|
+
export function readSessionProfileStartupNone(sessionId: string | undefined): boolean {
|
|
112
|
+
return sessionId !== undefined && startupNoneSessions().has(sessionId);
|
|
65
113
|
}
|
|
66
114
|
|
|
67
115
|
/** Testing-only reset of every binding. */
|
|
68
116
|
export function resetSessionProfileBindingsForTesting(): void {
|
|
69
117
|
bindingsBySession().clear();
|
|
118
|
+
startupNoneSessions().clear();
|
|
70
119
|
}
|
|
71
120
|
|
|
72
121
|
/**
|
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
// `gentle-pi.session-profile/v1` entry with origin `local | repo | global` is
|
|
28
28
|
// the integration point with slice 3b-i.
|
|
29
29
|
import { createHash } from "node:crypto";
|
|
30
|
-
import {
|
|
30
|
+
import { join } from "node:path";
|
|
31
|
+
import { normalizeModelConfig, normalizeRoutingEntry, readModelConfigFile, type AgentModelConfig, type AgentRoutingEntry } from "./model-routing-authority.ts";
|
|
31
32
|
import { profileRoleEntries, profilesFilePath, readProfilesFileResult } from "./agent-profiles.ts";
|
|
32
33
|
import { readProfilePinStatus, resolveProfilePin, resolveUnversionedProjectProfile } from "./agent-profile-pin.ts";
|
|
33
|
-
import { readSessionProfileBinding } from "./session-profile-binding.ts";
|
|
34
|
+
import { readSessionProfileBinding, readSessionProfileStartupNone } from "./session-profile-binding.ts";
|
|
35
|
+
import type { SessionProfileStartupState } from "./session-profile-persistence.ts";
|
|
34
36
|
import type { WorktreeIdentity, WorktreeResolver } from "./session-worktree-registry.ts";
|
|
35
37
|
|
|
36
38
|
/** Opt-in that keeps the live `p → P → G` resolution instead of freezing it at startup. */
|
|
@@ -49,6 +51,8 @@ export interface InheritedProfile {
|
|
|
49
51
|
/** A frozen session: `profile` is `undefined` when no layer had a profile at startup. */
|
|
50
52
|
export interface FrozenInheritedProfile {
|
|
51
53
|
readonly profile: InheritedProfile | undefined;
|
|
54
|
+
/** Pi's global default orchestrator, separate from the role-only routing. */
|
|
55
|
+
readonly defaultOrchestrator?: AgentRoutingEntry;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
/**
|
|
@@ -70,10 +74,18 @@ export interface InheritedProfileOptions {
|
|
|
70
74
|
export interface SessionProfileOptions extends InheritedProfileOptions {
|
|
71
75
|
sessionId: string | undefined;
|
|
72
76
|
env?: NodeJS.ProcessEnv;
|
|
77
|
+
/** Injected only by callers that already own an authoritative startup snapshot. */
|
|
78
|
+
readDefaultOrchestrator?: () => AgentRoutingEntry | undefined;
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
interface FreezeRegistry {
|
|
76
82
|
frozen: Map<string, FrozenInheritedProfile>;
|
|
83
|
+
// The frozen profile's full definition, orchestrator included, read in the
|
|
84
|
+
// same freeze step; launch routing keeps the role-only `frozen` copy.
|
|
85
|
+
definitions: Map<string, AgentModelConfig>;
|
|
86
|
+
// Sessions this process froze at their own start, not at a resume.
|
|
87
|
+
ownStart: Set<string>;
|
|
88
|
+
orchestrators: Map<string, AgentRoutingEntry | null>;
|
|
77
89
|
// Drift fingerprints already reported, per session.
|
|
78
90
|
notified: Map<string, Set<string>>;
|
|
79
91
|
}
|
|
@@ -82,8 +94,13 @@ const freezeRegistryKey = Symbol.for("gentle-pi:session-profile-freeze");
|
|
|
82
94
|
|
|
83
95
|
function registry(): FreezeRegistry {
|
|
84
96
|
const holder = globalThis as { [freezeRegistryKey]?: FreezeRegistry };
|
|
85
|
-
(holder[freezeRegistryKey] ??= { frozen: new Map(), notified: new Map() });
|
|
86
|
-
|
|
97
|
+
(holder[freezeRegistryKey] ??= { frozen: new Map(), definitions: new Map(), ownStart: new Set(), orchestrators: new Map(), notified: new Map() });
|
|
98
|
+
const store = holder[freezeRegistryKey]!;
|
|
99
|
+
store.orchestrators ??= new Map();
|
|
100
|
+
// An older evaluation of this module may have created the shared registry.
|
|
101
|
+
store.definitions ??= new Map();
|
|
102
|
+
store.ownStart ??= new Set();
|
|
103
|
+
return store;
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
function cloneProfiles(profiles: AgentModelConfig): AgentModelConfig {
|
|
@@ -136,7 +153,38 @@ export function resolveInheritedProfile(options: InheritedProfileOptions): Inher
|
|
|
136
153
|
export function readFrozenInheritedProfile(sessionId: string | undefined): FrozenInheritedProfile | undefined {
|
|
137
154
|
if (sessionId === undefined) return undefined;
|
|
138
155
|
const frozen = registry().frozen.get(sessionId);
|
|
139
|
-
|
|
156
|
+
if (frozen === undefined) return undefined;
|
|
157
|
+
const defaultOrchestrator = readFrozenDefaultOrchestrator(sessionId);
|
|
158
|
+
return { profile: cloneProfile(frozen.profile), ...(defaultOrchestrator ? { defaultOrchestrator } : {}) };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Capture the materialized global orchestrator once; pins only affect roles. */
|
|
162
|
+
function freezeDefaultOrchestrator(options: SessionProfileOptions): void {
|
|
163
|
+
const id = options.sessionId;
|
|
164
|
+
if (!id || isChildSession(options.env ?? process.env)) return;
|
|
165
|
+
const store = registry().orchestrators;
|
|
166
|
+
if (store.has(id)) return;
|
|
167
|
+
const raw = options.readDefaultOrchestrator
|
|
168
|
+
? options.readDefaultOrchestrator()
|
|
169
|
+
: (() => {
|
|
170
|
+
const result = readModelConfigFile(join(options.configHome, "models.json"));
|
|
171
|
+
return result.status === "valid" ? result.config.orchestrator : undefined;
|
|
172
|
+
})();
|
|
173
|
+
const entry = normalizeRoutingEntry(raw);
|
|
174
|
+
store.set(id, entry?.model && entry.tier ? { model: entry.model, tier: entry.tier } : null);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function readFrozenDefaultOrchestrator(sessionId: string | undefined): AgentRoutingEntry | undefined {
|
|
178
|
+
if (!sessionId) return undefined;
|
|
179
|
+
const entry = registry().orchestrators.get(sessionId);
|
|
180
|
+
return entry ? { ...entry } : undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** An explicit Make default may update only the applying session's snapshot. */
|
|
184
|
+
export function setFrozenDefaultOrchestrator(sessionId: string | undefined, value: AgentRoutingEntry | undefined): void {
|
|
185
|
+
if (!sessionId) return;
|
|
186
|
+
const entry = normalizeRoutingEntry(value);
|
|
187
|
+
registry().orchestrators.set(sessionId, entry?.model && entry.tier ? { model: entry.model, tier: entry.tier } : null);
|
|
140
188
|
}
|
|
141
189
|
|
|
142
190
|
function freezes(options: SessionProfileOptions): boolean {
|
|
@@ -146,22 +194,57 @@ function freezes(options: SessionProfileOptions): boolean {
|
|
|
146
194
|
|
|
147
195
|
// Only called after `freezes(options)`, which guarantees a session id.
|
|
148
196
|
function frozenOrFreeze(options: SessionProfileOptions): FrozenInheritedProfile {
|
|
197
|
+
freezeDefaultOrchestrator(options);
|
|
149
198
|
const store = registry().frozen;
|
|
150
199
|
const sessionId = options.sessionId!;
|
|
151
200
|
let frozen = store.get(sessionId);
|
|
152
201
|
if (frozen === undefined) {
|
|
153
202
|
frozen = { profile: cloneProfile(resolveInheritedProfile(options)) };
|
|
154
203
|
store.set(sessionId, frozen);
|
|
204
|
+
const definition = frozen.profile && startupDefinition(options, frozen.profile);
|
|
205
|
+
if (definition !== undefined) registry().definitions.set(sessionId, definition);
|
|
155
206
|
}
|
|
156
207
|
return { profile: cloneProfile(frozen.profile) };
|
|
157
208
|
}
|
|
158
209
|
|
|
210
|
+
// The full definition behind a profile just frozen; `undefined` when the store
|
|
211
|
+
// no longer holds the role routing the freeze resolved.
|
|
212
|
+
function startupDefinition(options: SessionProfileOptions, profile: InheritedProfile): AgentModelConfig | undefined {
|
|
213
|
+
const store = readProfilesFileResult(profilesFilePath(options.configHome));
|
|
214
|
+
if (store.status !== "valid" || !Object.hasOwn(store.file.profiles, profile.name)) return undefined;
|
|
215
|
+
const definition = store.file.profiles[profile.name]!;
|
|
216
|
+
return stableJson(roleRouting(definition)) === stableJson(profile.modelProfiles) ? cloneProfiles(definition) : undefined;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Freeze at the session's own start, a new session rather than a resume, so
|
|
221
|
+
* this process knows its startup state (gentle-shell#2742, section 3).
|
|
222
|
+
*/
|
|
223
|
+
export function freezeSessionProfileAtOwnStart(options: SessionProfileOptions): void {
|
|
224
|
+
freezeSessionProfileAtStartup(options);
|
|
225
|
+
if (freezes(options)) registry().ownStart.add(options.sessionId!);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The startup state this process froze at the session's own start, with the
|
|
230
|
+
* profile's full definition; `undefined` when unknown, including a profile
|
|
231
|
+
* whose definition the freeze could not capture.
|
|
232
|
+
*/
|
|
233
|
+
export function readSessionProfileOwnStartup(sessionId: string | undefined): SessionProfileStartupState | undefined {
|
|
234
|
+
const frozen = sessionId === undefined ? undefined : registry().frozen.get(sessionId);
|
|
235
|
+
if (frozen === undefined || !registry().ownStart.has(sessionId!)) return undefined;
|
|
236
|
+
if (frozen.profile === undefined) return "none";
|
|
237
|
+
const definition = registry().definitions.get(sessionId!);
|
|
238
|
+
return definition && { origin: frozen.profile.origin, name: frozen.profile.name, modelProfiles: cloneProfiles(definition) };
|
|
239
|
+
}
|
|
240
|
+
|
|
159
241
|
/**
|
|
160
242
|
* Freeze a parent session's inherited profile at startup. Idempotent: the
|
|
161
243
|
* first snapshot wins, so a session keeps it across `/reload` in the same
|
|
162
244
|
* process. Children and `follow` sessions never freeze.
|
|
163
245
|
*/
|
|
164
246
|
export function freezeSessionProfileAtStartup(options: SessionProfileOptions): void {
|
|
247
|
+
freezeDefaultOrchestrator(options);
|
|
165
248
|
if (freezes(options)) frozenOrFreeze(options);
|
|
166
249
|
}
|
|
167
250
|
|
|
@@ -171,8 +254,14 @@ export function freezeSessionProfileAtStartup(options: SessionProfileOptions): v
|
|
|
171
254
|
* extension's `session_start` ran first.
|
|
172
255
|
*/
|
|
173
256
|
export function resolveSessionProfile(options: SessionProfileOptions): SessionProfileResolution {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
257
|
+
const recorded = readSessionProfileBinding(options.sessionId);
|
|
258
|
+
if (recorded?.origin === "user") return { kind: "explicit", name: recorded.name, modelProfiles: recorded.modelProfiles };
|
|
259
|
+
// gentle-shell#2742: a startup record is the session's inherited profile,
|
|
260
|
+
// taken as recorded instead of freezing again, and routed in `follow` mode
|
|
261
|
+
// too, as v1 routes any bind. Like the freeze, it keeps role routing only.
|
|
262
|
+
if (recorded !== undefined)
|
|
263
|
+
return { kind: "inherited", profile: { name: recorded.name, origin: recorded.origin, modelProfiles: roleRouting(recorded.modelProfiles) } };
|
|
264
|
+
if (freezes(options) && readSessionProfileStartupNone(options.sessionId)) return { kind: "inherited", profile: undefined };
|
|
176
265
|
if (freezes(options)) return { kind: "inherited", profile: frozenOrFreeze(options).profile };
|
|
177
266
|
const env = options.env ?? process.env;
|
|
178
267
|
const profile = resolveInheritedProfile(options);
|
|
@@ -198,7 +287,11 @@ export function sessionProfileRoutingAt(
|
|
|
198
287
|
resolution: SessionProfileResolution,
|
|
199
288
|
target: InheritedProfileOptions & { foreignRepository?: boolean },
|
|
200
289
|
): AgentModelConfig | undefined {
|
|
201
|
-
|
|
290
|
+
// A binding keeps the whole profile, the reserved orchestrator key included,
|
|
291
|
+
// but launch routing returns role keys only, like the pin and global layers.
|
|
292
|
+
// The provider review roles read the orchestrator from the resolution's full
|
|
293
|
+
// modelProfiles (readReviewerModelConfig), not from this routing.
|
|
294
|
+
if (resolution.kind === "explicit") return roleRouting(resolution.modelProfiles);
|
|
202
295
|
if (resolution.kind === "inherited") {
|
|
203
296
|
if (resolution.profile !== undefined || target.foreignRepository !== true) return resolution.profile?.modelProfiles;
|
|
204
297
|
return resolveProfilePin(target)?.modelProfiles;
|
|
@@ -217,7 +310,9 @@ export function sessionProfileLabel(resolution: SessionProfileResolution): strin
|
|
|
217
310
|
function stableJson(value: unknown): string {
|
|
218
311
|
if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
|
|
219
312
|
if (value !== null && typeof value === "object") {
|
|
220
|
-
|
|
313
|
+
// Absent and `undefined` fields are the same route: a recorded snapshot
|
|
314
|
+
// (gentle-shell#2742) omits what a live resolution may hold as `undefined`.
|
|
315
|
+
return `{${Object.keys(value).filter((key) => (value as Record<string, unknown>)[key] !== undefined).sort().map((key) => `${JSON.stringify(key)}:${stableJson((value as Record<string, unknown>)[key])}`).join(",")}}`;
|
|
221
316
|
}
|
|
222
317
|
return JSON.stringify(value) ?? "null";
|
|
223
318
|
}
|
|
@@ -286,5 +381,8 @@ function bindingDefinitionDriftNotice(
|
|
|
286
381
|
/** Testing-only reset of every frozen snapshot and drift memory. */
|
|
287
382
|
export function resetFrozenInheritedProfilesForTesting(): void {
|
|
288
383
|
registry().frozen.clear();
|
|
384
|
+
registry().definitions.clear();
|
|
385
|
+
registry().ownStart.clear();
|
|
386
|
+
registry().orchestrators.clear();
|
|
289
387
|
registry().notified.clear();
|
|
290
388
|
}
|