gentle-pi 4.6.0 → 4.8.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 +65 -55
- package/assets/agents/gentle-ai-explore.md +4 -3
- package/assets/agents/gentle-ai-verify.md +23 -6
- package/assets/agents/gentle-ai-worker.md +9 -6
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +2 -3
- package/assets/agents/jd-judge-b.md +2 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +759 -16
- package/assets/design-canvas/canvas.js +2 -1497
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +6 -1
- package/assets/migrations/agent-body-history.json +40 -1
- package/assets/orchestrator-delegation-reference.md +10 -16
- package/assets/orchestrator-delegation.md +5 -5
- package/assets/orchestrator-full-delegation-card.md +64 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +5 -5
- package/assets/orchestrator-prompts.md +2 -2
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +14 -13
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +12 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +21 -25
- package/bin/gentle-shell.mjs +292 -65
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/agent-status.md +61 -0
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +20 -10
- package/docs/delegated-verification.md +46 -8
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +40 -0
- package/docs/gentle-shell.md +91 -30
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +17 -4
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +142 -45
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +53 -0
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +11 -1
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +3 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +559 -66
- package/extensions/gentle-ai.ts +2001 -518
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +398 -115
- package/extensions/gentle-todo.ts +66 -27
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +349 -167
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +93 -6
- package/lib/agents-history.ts +24 -5
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +55 -7
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +272 -16
- package/lib/agents-session-transport.ts +17 -1
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +197 -32
- package/lib/card-content-policy.ts +8 -6
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +236 -17
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +204 -14
- package/lib/gentle-shell-bundled.ts +106 -28
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/hidden-tools.ts +35 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +358 -144
- package/lib/jobs-view.ts +198 -11
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +31 -4
- package/lib/nan-provider.ts +42 -28
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +172 -20
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +129 -0
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +116 -0
- package/lib/review-coordinator.ts +407 -0
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +63 -4
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/reviewer-stream.ts +87 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/verifier-admission.ts +1 -1
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +46 -16
- package/package.json +3 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +106 -28
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +169 -17
- package/runtime/review-integration-v2.mjs +63 -4
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +179 -0
- package/scripts/build-runtime-modules.mjs +1 -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-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +33 -22
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +46 -16
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- 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 +40 -28
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +50 -19
- package/scripts/voice-worker.cjs +32 -6
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +16 -13
- package/skills/gentle-ai/SKILL.md +7 -7
- 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/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -11
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +10 -11
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +106 -1
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +215 -3
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +12 -1
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +99 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +51 -3
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +31 -6
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-safety.test.ts +11 -0
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +32 -10
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -695
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +160 -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 +1403 -20
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +135 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +233 -43
- package/tests/gentle-design.test.ts +386 -1
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +293 -31
- package/tests/gentle-shell-launcher.test.ts +78 -11
- package/tests/gentle-shell.test.ts +1017 -146
- package/tests/gentle-todo.test.ts +51 -11
- 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 +8 -4
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +97 -0
- package/tests/inprocess-reviewer.test.ts +249 -4
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +115 -14
- package/tests/installer-preflight.test.ts +54 -5
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +215 -13
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/jobs-view.test.ts +260 -6
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +17 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +13 -2
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +35 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +154 -0
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +13 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +4 -3
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +16 -13
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +372 -0
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +25 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/questionnaire-view.test.ts +115 -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 +17 -12
- 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 +112 -1
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +189 -0
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +80 -2
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +66 -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 +107 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +98 -12
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +462 -0
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +105 -11
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +39 -2
- package/tests/review-reviewer-evidence.test.ts +223 -0
- package/tests/review-risk-assessment.test.ts +126 -8
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +53 -3
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +122 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +1461 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +264 -0
- package/tests/task-size-routing-contract.test.ts +45 -12
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +162 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +77 -6
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +276 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +62 -18
- package/tests/yolo-session-policy.test.ts +270 -1
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -4,7 +4,7 @@ import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
6
6
|
import { join } from "node:path";
|
|
7
|
-
import { resolveAnimationPolicy } from "../lib/animation-policy.ts";
|
|
7
|
+
import { resolveAnimationPolicy, type AnimationPolicy } from "../lib/animation-policy.ts";
|
|
8
8
|
import { PI_SUBCOMMANDS } from "../lib/gentle-shell-launcher.ts";
|
|
9
9
|
import { gentlePiConfigHome } from "../lib/agent-home.ts";
|
|
10
10
|
|
|
@@ -362,6 +362,23 @@ type LetterStroke = { orderMap: Map<string, number>; maxOrder: number };
|
|
|
362
362
|
|
|
363
363
|
const WRITING_START_TICK = 6;
|
|
364
364
|
const FALLBACK_LETTER_TICKS = 8;
|
|
365
|
+
// Every rose pulse step repaints every rose cell, which drives the TUI diff to
|
|
366
|
+
// redraw the whole header region and teleport the hardware cursor; on fast
|
|
367
|
+
// terminals (ghostty) that churn reads as flicker/ghosting (ghostty#12685).
|
|
368
|
+
// The resolved animation policy owns the step, so the cadence table in
|
|
369
|
+
// docs/readme-reference.md stays authoritative: quality paints every 25ms and
|
|
370
|
+
// takes the coarser ~100ms wave, while performance already paints every 250ms
|
|
371
|
+
// and keeps the merge-base 2-tick step instead of freezing the wave.
|
|
372
|
+
const ROSE_PULSE_TICKS: Record<AnimationPolicy, number> = {
|
|
373
|
+
quality: 4,
|
|
374
|
+
performance: 2,
|
|
375
|
+
potato: 2,
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/** Ticks per rose pulse step under the resolved animation policy. */
|
|
379
|
+
export function rosePulseTicks(policy: AnimationPolicy): number {
|
|
380
|
+
return ROSE_PULSE_TICKS[policy];
|
|
381
|
+
}
|
|
365
382
|
|
|
366
383
|
const LETTER_STROKES: Array<LetterStroke | null> = LETTER_SPANS.map(() => null);
|
|
367
384
|
const LETTER_TICKS: number[] = LETTER_SPANS.map(() => FALLBACK_LETTER_TICKS);
|
|
@@ -662,6 +679,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
662
679
|
// CLI subcommands such as `pi update` or `pi install` skip the animated intro.
|
|
663
680
|
if (isPiCliSubcommandInvocation(process.argv)) return;
|
|
664
681
|
|
|
682
|
+
// /reload re-fires session_start with reason "reload". The splash is a
|
|
683
|
+
// first-start experience, so the intro must not run again; but the
|
|
684
|
+
// disposeHeader() above already dropped the previous header, and banner
|
|
685
|
+
// changes are documented to apply on the next session or /reload. Returning
|
|
686
|
+
// early here would leave the editor without a header, so a reload repaints
|
|
687
|
+
// the complete static artwork instead (see the header factory below).
|
|
688
|
+
const reload = (_event as { reason?: string })?.reason === "reload";
|
|
665
689
|
if (currentIntroMode() === "skip") return;
|
|
666
690
|
|
|
667
691
|
// Pi has already started its renderer. Let setHeader schedule the paint;
|
|
@@ -767,8 +791,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
767
791
|
refreshStats = () => tui.requestRender();
|
|
768
792
|
// Capture once: a command changes the live prompt, not this intro.
|
|
769
793
|
const animationPolicy = resolveAnimationPolicy().policy;
|
|
794
|
+
const rosePulse = rosePulseTicks(animationPolicy);
|
|
770
795
|
const animStart = Date.now();
|
|
771
|
-
if (animationPolicy === "potato") {
|
|
796
|
+
if (reload || animationPolicy === "potato") {
|
|
797
|
+
// Completed static artwork, no animation interval: potato asks for no
|
|
798
|
+
// periodic animation, and a /reload repaint has no intro to replay.
|
|
772
799
|
tick = Number.MAX_SAFE_INTEGER;
|
|
773
800
|
state.timer = null;
|
|
774
801
|
} else {
|
|
@@ -821,7 +848,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
821
848
|
tick >= flashStartTick
|
|
822
849
|
? Math.max(0, 1 - (tick - flashStartTick) / 12)
|
|
823
850
|
: 0;
|
|
824
|
-
const frame = Math.floor(tick /
|
|
851
|
+
const frame = Math.floor(tick / rosePulse);
|
|
825
852
|
|
|
826
853
|
const sideBySideMinWidth = roseBase.width + 3 + logoBase.width + 4;
|
|
827
854
|
const horizontal =
|
package/lib/agent-assets.ts
CHANGED
|
@@ -56,7 +56,12 @@ function gentlePiAgentHome(): string {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* What `readManagedAssetsManifestResult` reports, and the shape the installer
|
|
61
|
+
* writes. Exported so the Desktop config projection can name the type it filters
|
|
62
|
+
* without redefining it.
|
|
63
|
+
*/
|
|
64
|
+
export interface ManagedAssetsManifest {
|
|
60
65
|
schemaVersion: number;
|
|
61
66
|
assets: Record<string, string>;
|
|
62
67
|
}
|
|
@@ -64,7 +69,6 @@ interface ManagedAssetsManifest {
|
|
|
64
69
|
interface LegacyManagedAssetsManifest extends ManagedAssetsManifest {
|
|
65
70
|
packageVersion: string;
|
|
66
71
|
}
|
|
67
|
-
|
|
68
72
|
interface ManagedAssetsLockOwner {
|
|
69
73
|
schemaVersion: 1;
|
|
70
74
|
token: string;
|
|
@@ -88,7 +92,27 @@ function emptyManagedAssetsManifest(): ManagedAssetsManifest {
|
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
function readManagedAssetsManifest(path: string): ManagedAssetsManifest {
|
|
91
|
-
|
|
95
|
+
const read = readManagedAssetsManifestResult(path);
|
|
96
|
+
return read.status === "valid" ? read.manifest : emptyManagedAssetsManifest();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Where the installer keeps its ownership manifest for one agent home. */
|
|
100
|
+
export function managedAssetsManifestPath(agentHome: string): string {
|
|
101
|
+
return join(agentHome, "gentle-ai", MANAGED_ASSETS_MANIFEST);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Read-side status of the manifest, kept apart from the installer's forgiving
|
|
106
|
+
* reader so a caller can report an absent file separately from one this version
|
|
107
|
+
* cannot understand. It never writes and never repairs the file.
|
|
108
|
+
*/
|
|
109
|
+
export type ManagedAssetsManifestReadResult =
|
|
110
|
+
| { status: "missing" }
|
|
111
|
+
| { status: "invalid" }
|
|
112
|
+
| { status: "valid"; manifest: ManagedAssetsManifest };
|
|
113
|
+
|
|
114
|
+
export function readManagedAssetsManifestResult(path: string): ManagedAssetsManifestReadResult {
|
|
115
|
+
if (!existsSync(path)) return { status: "missing" };
|
|
92
116
|
try {
|
|
93
117
|
const parsed: unknown = JSON.parse(readFileSync(path, "utf8"));
|
|
94
118
|
if (
|
|
@@ -96,16 +120,16 @@ function readManagedAssetsManifest(path: string): ManagedAssetsManifest {
|
|
|
96
120
|
parsed.schemaVersion !== MANAGED_ASSETS_SCHEMA_VERSION ||
|
|
97
121
|
!isRecord(parsed.assets)
|
|
98
122
|
) {
|
|
99
|
-
return
|
|
123
|
+
return { status: "invalid" };
|
|
100
124
|
}
|
|
101
125
|
const assets = Object.fromEntries(
|
|
102
126
|
Object.entries(parsed.assets).filter(
|
|
103
127
|
(entry): entry is [string, string] => typeof entry[1] === "string",
|
|
104
128
|
),
|
|
105
129
|
);
|
|
106
|
-
return { schemaVersion: MANAGED_ASSETS_SCHEMA_VERSION, assets };
|
|
130
|
+
return { status: "valid", manifest: { schemaVersion: MANAGED_ASSETS_SCHEMA_VERSION, assets } };
|
|
107
131
|
} catch {
|
|
108
|
-
return
|
|
132
|
+
return { status: "invalid" };
|
|
109
133
|
}
|
|
110
134
|
}
|
|
111
135
|
|
package/lib/agent-profile-pin.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
|
26
26
|
import { join } from "node:path";
|
|
27
27
|
import { isValidProfileName, profileRoleEntries, profilesFilePath, readProfilesFileResult, writeJsonFileAtomicallySync } from "./agent-profiles.ts";
|
|
28
28
|
import type { AgentModelConfig } from "./model-routing-authority.ts";
|
|
29
|
-
import {
|
|
29
|
+
import { resolveSessionWorktree, type WorktreeIdentity, type WorktreeResolver } from "./session-worktree-registry.ts";
|
|
30
30
|
|
|
31
31
|
export const PROFILE_PIN_KIND = "gentle-pi.agent_model_profile_pin";
|
|
32
32
|
export const PROFILE_PIN_VERSION = 1;
|
|
@@ -178,7 +178,7 @@ export function readProfilePin(path: string): string | undefined {
|
|
|
178
178
|
return result.status === "valid" ? result.profile : undefined;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
let profilePinWorktreeResolver: WorktreeResolver =
|
|
181
|
+
let profilePinWorktreeResolver: WorktreeResolver = resolveSessionWorktree;
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* Test seam, mirroring the other injectable seams in `lib/`: the `/gentle:profiles`
|
|
@@ -187,7 +187,7 @@ let profilePinWorktreeResolver: WorktreeResolver = resolveSessionWorktreeWithGit
|
|
|
187
187
|
* passes its own resolver instead, so it needs no seam.
|
|
188
188
|
*/
|
|
189
189
|
export function setProfilePinWorktreeResolverForTesting(resolver?: WorktreeResolver): void {
|
|
190
|
-
profilePinWorktreeResolver = resolver ??
|
|
190
|
+
profilePinWorktreeResolver = resolver ?? resolveSessionWorktree;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
function gentlePiWorktreeIdentity(
|
package/lib/agent-profiles.ts
CHANGED
|
@@ -22,11 +22,35 @@ export const PROFILES_VERSION = 1;
|
|
|
22
22
|
export const PROFILE_EXPORT_KIND = "gentle-pi.agent_model_profile";
|
|
23
23
|
export const PROFILE_EXPORT_VERSION = 1;
|
|
24
24
|
|
|
25
|
+
// The orchestrator workflow a profile opts into (full-delegation-mode S1).
|
|
26
|
+
//
|
|
27
|
+
// This deliberately does NOT live inside a profile's routing map. A profile's
|
|
28
|
+
// value is an `AgentModelConfig` — `Record<string, AgentRoutingEntry>` — and
|
|
29
|
+
// `normalizeModelConfig` drops every key that is not a routing entry, reporting
|
|
30
|
+
// it as a broken role. A nested `workflow` key would therefore be destroyed on
|
|
31
|
+
// the first read of `<configHome>/profiles.json`, so the flag travels in a
|
|
32
|
+
// sibling map keyed by profile name instead: same profile, same file, same
|
|
33
|
+
// live-switch semantics, unchanged routing contract.
|
|
34
|
+
export const ORCHESTRATOR_MODES = ["organic", "full-delegation"] as const;
|
|
35
|
+
export type OrchestratorMode = (typeof ORCHESTRATOR_MODES)[number];
|
|
36
|
+
/** Today's behaviour: the orchestrator may implement inline under the usual rules. */
|
|
37
|
+
export const DEFAULT_ORCHESTRATOR_MODE: OrchestratorMode = "organic";
|
|
38
|
+
|
|
39
|
+
export interface ProfileWorkflow {
|
|
40
|
+
orchestratorMode: OrchestratorMode;
|
|
41
|
+
}
|
|
42
|
+
|
|
25
43
|
export interface AgentProfilesFile {
|
|
26
44
|
kind: typeof PROFILES_KIND;
|
|
27
45
|
version: typeof PROFILES_VERSION;
|
|
28
46
|
active?: string;
|
|
29
47
|
profiles: Record<string, AgentModelConfig>;
|
|
48
|
+
/** Per-profile workflow opt-ins; absent means every profile is organic. */
|
|
49
|
+
workflow?: Record<string, ProfileWorkflow>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function isOrchestratorMode(value: unknown): value is OrchestratorMode {
|
|
53
|
+
return typeof value === "string" && (ORCHESTRATOR_MODES as readonly string[]).includes(value);
|
|
30
54
|
}
|
|
31
55
|
|
|
32
56
|
export type AgentProfileErrorCode =
|
|
@@ -103,6 +127,12 @@ export interface ProfilesParseDrops {
|
|
|
103
127
|
droppedAgents: Array<{ profile: string; agent: string }>;
|
|
104
128
|
/** An `active` marker that did not name a normalized profile, when present. */
|
|
105
129
|
droppedActive?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Workflow modes that named an unknown profile or an unknown mode, when any.
|
|
132
|
+
* Optional so the existing drops shape stays compatible for callers and tests
|
|
133
|
+
* that assert it without a workflow map.
|
|
134
|
+
*/
|
|
135
|
+
droppedWorkflow?: Array<{ profile: string; mode: string }>;
|
|
106
136
|
}
|
|
107
137
|
|
|
108
138
|
export interface NormalizedProfilesFile {
|
|
@@ -165,7 +195,49 @@ export function normalizeProfilesFile(value: unknown): NormalizedProfilesFile |
|
|
|
165
195
|
typeof value.active === "string" ? value.active : JSON.stringify(value.active);
|
|
166
196
|
}
|
|
167
197
|
}
|
|
168
|
-
|
|
198
|
+
const workflow = normalizeWorkflowMap(value.workflow, profiles, drops);
|
|
199
|
+
return {
|
|
200
|
+
file: {
|
|
201
|
+
kind: PROFILES_KIND,
|
|
202
|
+
version: PROFILES_VERSION,
|
|
203
|
+
active,
|
|
204
|
+
profiles,
|
|
205
|
+
...(workflow === undefined ? {} : { workflow }),
|
|
206
|
+
},
|
|
207
|
+
drops,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Keeps only workflow opt-ins that name a surviving profile and a declared
|
|
213
|
+
* mode. Anything else is reported through `drops.droppedWorkflow` instead of
|
|
214
|
+
* being honoured or silently erased (full-delegation-mode S6).
|
|
215
|
+
*/
|
|
216
|
+
function normalizeWorkflowMap(
|
|
217
|
+
value: unknown,
|
|
218
|
+
profiles: Record<string, AgentModelConfig>,
|
|
219
|
+
drops: ProfilesParseDrops,
|
|
220
|
+
): Record<string, ProfileWorkflow> | undefined {
|
|
221
|
+
if (value === undefined) return undefined;
|
|
222
|
+
if (!isRecord(value)) return undefined;
|
|
223
|
+
const workflow: Record<string, ProfileWorkflow> = {};
|
|
224
|
+
const dropped: Array<{ profile: string; mode: string }> = [];
|
|
225
|
+
for (const [name, rawEntry] of Object.entries(value)) {
|
|
226
|
+
const rawMode = isRecord(rawEntry) ? rawEntry.orchestratorMode : undefined;
|
|
227
|
+
const described = rawMode === undefined ? JSON.stringify(rawEntry ?? null) : String(rawMode);
|
|
228
|
+
if (!hasOwn(profiles, name) || !isOrchestratorMode(rawMode)) {
|
|
229
|
+
dropped.push({ profile: name, mode: described });
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
workflow[name] = { orchestratorMode: rawMode };
|
|
233
|
+
}
|
|
234
|
+
if (dropped.length > 0) drops.droppedWorkflow = dropped;
|
|
235
|
+
// An all-organic map carries no information: keep the file identical to the
|
|
236
|
+
// pre-change shape so an opted-out file never grows a `workflow` key.
|
|
237
|
+
const meaningful = Object.fromEntries(
|
|
238
|
+
Object.entries(workflow).filter(([, entry]) => entry.orchestratorMode !== DEFAULT_ORCHESTRATOR_MODE),
|
|
239
|
+
);
|
|
240
|
+
return Object.keys(meaningful).length === 0 ? undefined : meaningful;
|
|
169
241
|
}
|
|
170
242
|
|
|
171
243
|
export type ProfilesFileParseResult =
|
|
@@ -204,9 +276,25 @@ export function serializeProfilesFile(file: AgentProfilesFile): string {
|
|
|
204
276
|
profiles: cloneProfiles(file.profiles),
|
|
205
277
|
};
|
|
206
278
|
if (file.active !== undefined) payload.active = file.active;
|
|
279
|
+
const workflow = meaningfulWorkflowMap(file.workflow, file.profiles);
|
|
280
|
+
if (workflow !== undefined) payload.workflow = workflow;
|
|
207
281
|
return `${JSON.stringify(payload, null, 2)}\n`;
|
|
208
282
|
}
|
|
209
283
|
|
|
284
|
+
/** The subset of a workflow map worth persisting: declared profiles, non-default modes. */
|
|
285
|
+
function meaningfulWorkflowMap(
|
|
286
|
+
workflow: Record<string, ProfileWorkflow> | undefined,
|
|
287
|
+
profiles: Record<string, AgentModelConfig>,
|
|
288
|
+
): Record<string, ProfileWorkflow> | undefined {
|
|
289
|
+
if (workflow === undefined) return undefined;
|
|
290
|
+
const kept = Object.fromEntries(
|
|
291
|
+
Object.entries(workflow)
|
|
292
|
+
.filter(([name, entry]) => hasOwn(profiles, name) && entry.orchestratorMode !== DEFAULT_ORCHESTRATOR_MODE)
|
|
293
|
+
.map(([name, entry]) => [name, { orchestratorMode: entry.orchestratorMode }]),
|
|
294
|
+
);
|
|
295
|
+
return Object.keys(kept).length === 0 ? undefined : kept;
|
|
296
|
+
}
|
|
297
|
+
|
|
210
298
|
// ---- Store mutations (each returns a new file and never mutates the input) ----
|
|
211
299
|
|
|
212
300
|
export function createProfile(
|
|
@@ -246,7 +334,8 @@ export function duplicateProfile(
|
|
|
246
334
|
if (hasOwn(file.profiles, to)) {
|
|
247
335
|
throw new AgentProfileError("duplicate_name", `Profile already exists: ${to}.`);
|
|
248
336
|
}
|
|
249
|
-
|
|
337
|
+
const created = createProfile(file, to, file.profiles[from]);
|
|
338
|
+
return setProfileOrchestratorMode(created, to, readProfileWorkflow(file, from).orchestratorMode);
|
|
250
339
|
}
|
|
251
340
|
|
|
252
341
|
export function renameProfile(
|
|
@@ -272,6 +361,9 @@ export function renameProfile(
|
|
|
272
361
|
...file,
|
|
273
362
|
active: file.active === from ? to : file.active,
|
|
274
363
|
profiles,
|
|
364
|
+
...(renamedWorkflow(file.workflow, from, to) === undefined
|
|
365
|
+
? {}
|
|
366
|
+
: { workflow: renamedWorkflow(file.workflow, from, to) }),
|
|
275
367
|
};
|
|
276
368
|
}
|
|
277
369
|
|
|
@@ -291,6 +383,9 @@ export function deleteProfile(file: AgentProfilesFile, name: string): AgentProfi
|
|
|
291
383
|
profiles: Object.fromEntries(
|
|
292
384
|
Object.entries(file.profiles).filter(([profileName]) => profileName !== name),
|
|
293
385
|
),
|
|
386
|
+
...(workflowWithout(file.workflow, name) === undefined
|
|
387
|
+
? {}
|
|
388
|
+
: { workflow: workflowWithout(file.workflow, name) }),
|
|
294
389
|
};
|
|
295
390
|
}
|
|
296
391
|
|
|
@@ -302,6 +397,69 @@ export function setActiveProfile(file: AgentProfilesFile, name: string): AgentPr
|
|
|
302
397
|
return { ...file, active: name };
|
|
303
398
|
}
|
|
304
399
|
|
|
400
|
+
// ---- Per-profile orchestrator workflow (full-delegation-mode) ----
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The orchestrator mode a profile carries, defaulting to today's behaviour.
|
|
404
|
+
*
|
|
405
|
+
* Unknown names resolve to the default instead of throwing: this is read on
|
|
406
|
+
* every prompt build, and a profile deleted or renamed between reads must not
|
|
407
|
+
* be able to break the orchestrator prompt.
|
|
408
|
+
*/
|
|
409
|
+
export function readProfileWorkflow(file: AgentProfilesFile, name: string): ProfileWorkflow {
|
|
410
|
+
const entry = file.workflow !== undefined && hasOwn(file.workflow, name) ? file.workflow[name] : undefined;
|
|
411
|
+
return { orchestratorMode: entry?.orchestratorMode ?? DEFAULT_ORCHESTRATOR_MODE };
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Opts one profile into a mode (S1). Selecting the default removes the entry
|
|
416
|
+
* instead of persisting it, so an all-organic store keeps its pre-change shape.
|
|
417
|
+
*/
|
|
418
|
+
export function setProfileOrchestratorMode(
|
|
419
|
+
file: AgentProfilesFile,
|
|
420
|
+
name: string,
|
|
421
|
+
mode: OrchestratorMode,
|
|
422
|
+
): AgentProfilesFile {
|
|
423
|
+
requireValidName(name);
|
|
424
|
+
if (!hasOwn(file.profiles, name)) {
|
|
425
|
+
throw new AgentProfileError("missing_profile", `Profile does not exist: ${name}.`);
|
|
426
|
+
}
|
|
427
|
+
if (mode === DEFAULT_ORCHESTRATOR_MODE) return { ...file, workflow: workflowWithout(file.workflow, name) };
|
|
428
|
+
return { ...file, workflow: { ...file.workflow, [name]: { orchestratorMode: mode } } };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** The mode the focused profile would get from one key press (panel `d`). */
|
|
432
|
+
export function toggleProfileOrchestratorMode(
|
|
433
|
+
file: AgentProfilesFile,
|
|
434
|
+
name: string,
|
|
435
|
+
): AgentProfilesFile {
|
|
436
|
+
const current = readProfileWorkflow(file, name).orchestratorMode;
|
|
437
|
+
const next = ORCHESTRATOR_MODES[(ORCHESTRATOR_MODES.indexOf(current) + 1) % ORCHESTRATOR_MODES.length];
|
|
438
|
+
return setProfileOrchestratorMode(file, name, next);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** Drops one profile's workflow entry, and the map itself once it is empty. */
|
|
442
|
+
function workflowWithout(
|
|
443
|
+
workflow: Record<string, ProfileWorkflow> | undefined,
|
|
444
|
+
name: string,
|
|
445
|
+
): Record<string, ProfileWorkflow> | undefined {
|
|
446
|
+
if (workflow === undefined) return undefined;
|
|
447
|
+
const kept = Object.fromEntries(Object.entries(workflow).filter(([key]) => key !== name));
|
|
448
|
+
return Object.keys(kept).length === 0 ? undefined : kept;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function renamedWorkflow(
|
|
452
|
+
workflow: Record<string, ProfileWorkflow> | undefined,
|
|
453
|
+
from: string,
|
|
454
|
+
to: string,
|
|
455
|
+
): Record<string, ProfileWorkflow> | undefined {
|
|
456
|
+
if (workflow === undefined) return undefined;
|
|
457
|
+
const remapped = Object.fromEntries(
|
|
458
|
+
Object.entries(workflow).map(([key, entry]) => [key === from ? to : key, entry]),
|
|
459
|
+
);
|
|
460
|
+
return Object.keys(remapped).length === 0 ? undefined : remapped;
|
|
461
|
+
}
|
|
462
|
+
|
|
305
463
|
// ---- Summaries and panel decision helpers ----
|
|
306
464
|
|
|
307
465
|
export interface ProfileModelSummary {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
export interface AgentStatus {
|
|
6
|
+
schema: "gentle-shell.agent-status/v1";
|
|
7
|
+
agent: "gentle-shell" | "pi";
|
|
8
|
+
session: string;
|
|
9
|
+
pid: number;
|
|
10
|
+
cwd: string;
|
|
11
|
+
state: "working" | "blocked" | "idle";
|
|
12
|
+
task: { title: string } | null;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
const ORPHAN_AGE_MS = 24 * 60 * 60 * 1000;
|
|
16
|
+
const ORPHAN_MAX_BYTES = 64 * 1024;
|
|
17
|
+
export function agentStatus(input: Omit<AgentStatus, "schema" | "updatedAt">, now: number): AgentStatus {
|
|
18
|
+
return { schema: "gentle-shell.agent-status/v1", ...input, updatedAt: new Date(now).toISOString() };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Private, best-effort store. No destination file is ever opened for writing. */
|
|
22
|
+
export function createAgentStatusStore(home: string, session: string) {
|
|
23
|
+
const configHome = resolve(home);
|
|
24
|
+
const root = join(configHome, "agent-status");
|
|
25
|
+
const path = join(root, `${createHash("sha256").update(session).digest("hex")}.json`);
|
|
26
|
+
const owned = (stat: fs.Stats) => process.platform === "win32" || stat.uid === process.getuid?.();
|
|
27
|
+
const directory = (create: boolean) => {
|
|
28
|
+
// Validate through the config home only; its ancestors are trusted.
|
|
29
|
+
const ensure = (dir: string): void => {
|
|
30
|
+
try {
|
|
31
|
+
const stat = fs.lstatSync(dir);
|
|
32
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) throw Error("unsafe-directory");
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (!create || (error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
35
|
+
if (dir === configHome) fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
36
|
+
else { ensure(dirname(dir)); fs.mkdirSync(dir, { mode: 0o700 }); }
|
|
37
|
+
}
|
|
38
|
+
if (dir !== configHome) ensureExisting(dirname(dir));
|
|
39
|
+
};
|
|
40
|
+
const ensureExisting = (dir: string): void => {
|
|
41
|
+
const stat = fs.lstatSync(dir);
|
|
42
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) throw Error("unsafe-directory");
|
|
43
|
+
if (dir !== configHome) ensureExisting(dirname(dir));
|
|
44
|
+
};
|
|
45
|
+
// Same trust boundary as orchestrator presence: refuse a foreign-owned or
|
|
46
|
+
// group/other-writable config home, where another account could swap the root.
|
|
47
|
+
const home = () => {
|
|
48
|
+
const parent = fs.lstatSync(dirname(root));
|
|
49
|
+
if (!parent.isDirectory() || parent.isSymbolicLink() || !owned(parent) || (process.platform !== "win32" && (parent.mode & 0o022) !== 0)) throw Error("unsafe-home");
|
|
50
|
+
};
|
|
51
|
+
try { home(); } catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
52
|
+
ensure(root); home();
|
|
53
|
+
const stat = fs.lstatSync(root);
|
|
54
|
+
if (!owned(stat) || (process.platform !== "win32" && (stat.mode & 0o077) !== 0)) throw Error("not-private");
|
|
55
|
+
};
|
|
56
|
+
const regular = () => {
|
|
57
|
+
try {
|
|
58
|
+
const stat = fs.lstatSync(path);
|
|
59
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || !owned(stat)) throw Error("unsafe-file");
|
|
60
|
+
} catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
61
|
+
};
|
|
62
|
+
// Probe a recorded owner PID: only ESRCH proves it dead; EPERM means alive.
|
|
63
|
+
const gone = (pid: unknown) => {
|
|
64
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) return false;
|
|
65
|
+
try { process.kill(pid, 0); } catch (error) { return (error as NodeJS.ErrnoException).code === "ESRCH"; }
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
const orphaned = (value: { pid?: unknown; updatedAt?: unknown }) => {
|
|
69
|
+
const updated = typeof value.updatedAt === "string" ? Date.parse(value.updatedAt) : Number.NaN;
|
|
70
|
+
return (Number.isFinite(updated) && Date.now() - updated > ORPHAN_AGE_MS) || gone(value.pid);
|
|
71
|
+
};
|
|
72
|
+
// A crashed session leaves its file behind; a bounded startup sweep drops proven
|
|
73
|
+
// orphans only. Unreadable, oversized, foreign, linked or unparsable files stay.
|
|
74
|
+
const sweep = () => {
|
|
75
|
+
let entries: string[];
|
|
76
|
+
try { directory(false); entries = fs.readdirSync(root); } catch { return; }
|
|
77
|
+
for (const entry of entries) {
|
|
78
|
+
const candidate = join(root, entry);
|
|
79
|
+
if (!entry.endsWith(".json") || candidate === path) continue;
|
|
80
|
+
try {
|
|
81
|
+
const stat = fs.lstatSync(candidate);
|
|
82
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || !owned(stat) || stat.size > ORPHAN_MAX_BYTES) continue;
|
|
83
|
+
const value = JSON.parse(fs.readFileSync(candidate, "utf8")) as { pid?: unknown; updatedAt?: unknown } | null;
|
|
84
|
+
if (typeof value !== "object" || value === null || !orphaned(value)) continue;
|
|
85
|
+
fs.unlinkSync(candidate);
|
|
86
|
+
} catch { /* Never touch what cannot be proven an orphan. */ }
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
try { sweep(); } catch { /* The sweep never interrupts a session start. */ }
|
|
90
|
+
return { path, write(value: AgentStatus): boolean {
|
|
91
|
+
let temporary: string | undefined;
|
|
92
|
+
try {
|
|
93
|
+
directory(true); regular();
|
|
94
|
+
const candidate = join(root, `.${randomUUID()}.tmp`);
|
|
95
|
+
const fd = fs.openSync(candidate, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL, 0o600);
|
|
96
|
+
temporary = candidate;
|
|
97
|
+
try { fs.writeFileSync(fd, `${JSON.stringify(value)}\n`); } finally { fs.closeSync(fd); }
|
|
98
|
+
directory(false); regular(); fs.renameSync(temporary, path);
|
|
99
|
+
temporary = undefined; return true;
|
|
100
|
+
} catch { return false; }
|
|
101
|
+
finally { if (temporary) { try { fs.unlinkSync(temporary); } catch { /* Best effort. */ } } }
|
|
102
|
+
}, remove(): void {
|
|
103
|
+
try { directory(false); regular(); fs.unlinkSync(path); } catch { /* Missing, unsafe or unavailable. */ }
|
|
104
|
+
} };
|
|
105
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
// Gentle AI agent tool overlay: a load-time layer that adds/removes subagent
|
|
5
|
+
// tools without editing the package-owned agent files. Mirrors the routing
|
|
6
|
+
// layer (`models.json`): applied at load, never written back, so package
|
|
7
|
+
// ownership and upgrade behavior stay untouched (gentle-shell#3133).
|
|
8
|
+
//
|
|
9
|
+
// Sources merge low -> high (higher wins on a per-tool conflict):
|
|
10
|
+
// 1. extension drop-ins under `<configHome>/agent-overlays.d/*.json`
|
|
11
|
+
// 2. global `<configHome>/tools.json`
|
|
12
|
+
// 3. project `<cwd>/.pi/gentle-ai/tools.json`
|
|
13
|
+
|
|
14
|
+
export interface ToolOverlayEntry {
|
|
15
|
+
add: string[];
|
|
16
|
+
remove: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ToolOverlayResult {
|
|
20
|
+
entries: Record<string, ToolOverlayEntry>;
|
|
21
|
+
notices: string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
25
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isStringArray(value: unknown): value is string[] {
|
|
29
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function readOverlayFile(path: string, notices: string[]): Record<string, ToolOverlayEntry> | undefined {
|
|
33
|
+
let parsed: unknown;
|
|
34
|
+
try {
|
|
35
|
+
parsed = JSON.parse(readFileSync(path, "utf8")) as unknown;
|
|
36
|
+
} catch {
|
|
37
|
+
notices.push(`ignored invalid tool overlay ${path}`);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (!isPlainObject(parsed)) {
|
|
41
|
+
notices.push(`ignored invalid tool overlay ${path}`);
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const entries: Record<string, ToolOverlayEntry> = {};
|
|
45
|
+
for (const [name, value] of Object.entries(parsed)) {
|
|
46
|
+
if (!isPlainObject(value)) {
|
|
47
|
+
notices.push(`ignored invalid entry for "${name}" in ${path}`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const add = value.add;
|
|
51
|
+
const remove = value.remove;
|
|
52
|
+
if ((add !== undefined && !isStringArray(add)) || (remove !== undefined && !isStringArray(remove))) {
|
|
53
|
+
notices.push(`ignored invalid entry for "${name}" in ${path}`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
entries[name] = {
|
|
57
|
+
add: isStringArray(add) ? add : [],
|
|
58
|
+
remove: isStringArray(remove) ? remove : [],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return entries;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function loadToolOverlays(configHome: string, cwd: string): ToolOverlayResult {
|
|
65
|
+
const notices: string[] = [];
|
|
66
|
+
const addByAgent = new Map<string, Set<string>>();
|
|
67
|
+
const removeByAgent = new Map<string, Set<string>>();
|
|
68
|
+
|
|
69
|
+
const sources: Array<Record<string, ToolOverlayEntry> | undefined> = [];
|
|
70
|
+
|
|
71
|
+
const dropInDir = join(configHome, "agent-overlays.d");
|
|
72
|
+
if (existsSync(dropInDir)) {
|
|
73
|
+
for (const file of readdirSync(dropInDir).filter((entry) => entry.endsWith(".json")).sort()) {
|
|
74
|
+
sources.push(readOverlayFile(join(dropInDir, file), notices));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const globalPath = join(configHome, "tools.json");
|
|
79
|
+
if (existsSync(globalPath)) sources.push(readOverlayFile(globalPath, notices));
|
|
80
|
+
|
|
81
|
+
const projectPath = join(cwd, ".pi", "gentle-ai", "tools.json");
|
|
82
|
+
if (existsSync(projectPath)) sources.push(readOverlayFile(projectPath, notices));
|
|
83
|
+
|
|
84
|
+
for (const entries of sources) {
|
|
85
|
+
if (entries === undefined) continue;
|
|
86
|
+
for (const [name, entry] of Object.entries(entries)) {
|
|
87
|
+
const addSet = addByAgent.get(name) ?? new Set<string>();
|
|
88
|
+
const removeSet = removeByAgent.get(name) ?? new Set<string>();
|
|
89
|
+
for (const tool of entry.add) {
|
|
90
|
+
addSet.add(tool);
|
|
91
|
+
removeSet.delete(tool);
|
|
92
|
+
}
|
|
93
|
+
for (const tool of entry.remove) {
|
|
94
|
+
removeSet.add(tool);
|
|
95
|
+
addSet.delete(tool);
|
|
96
|
+
}
|
|
97
|
+
addByAgent.set(name, addSet);
|
|
98
|
+
removeByAgent.set(name, removeSet);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const entries: Record<string, ToolOverlayEntry> = {};
|
|
103
|
+
for (const name of new Set([...addByAgent.keys(), ...removeByAgent.keys()])) {
|
|
104
|
+
entries[name] = {
|
|
105
|
+
add: [...(addByAgent.get(name) ?? new Set<string>())],
|
|
106
|
+
remove: [...(removeByAgent.get(name) ?? new Set<string>())],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { entries, notices };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function applyToolOverlay(tools: string[], overlay: ToolOverlayEntry | undefined): string[] {
|
|
114
|
+
if (overlay === undefined) return tools;
|
|
115
|
+
const removeSet = new Set(overlay.remove);
|
|
116
|
+
return [...new Set([...tools, ...overlay.add])].filter((tool) => !removeSet.has(tool));
|
|
117
|
+
}
|