gentle-pi 4.7.0 → 4.9.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 +115 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +14 -13
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -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 +476 -0
- package/assets/design-canvas/canvas-boot.js +219 -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 +397 -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 +219 -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 +351 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +167 -0
- package/assets/design-canvas/canvas-theme.js +69 -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 +773 -17
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +120 -36
- package/assets/design-canvas/inspector.js +574 -21
- package/assets/design-canvas/theme-early.js +10 -0
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +30 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +5 -9
- package/assets/orchestrator-full-delegation-card.md +11 -16
- package/assets/orchestrator-full-delegation.md +9 -9
- package/assets/orchestrator-memory.md +4 -4
- package/assets/orchestrator-prompts.md +3 -31
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +13 -17
- package/assets/orchestrator-verification.md +12 -10
- package/assets/orchestrator-writer.md +13 -13
- package/assets/orchestrator.md +20 -24
- package/bin/gentle-shell.mjs +205 -10
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/orchestration/pi.md +2 -1
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/routing/pi.md +16 -16
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/assets/features/gentle-tower.png +0 -0
- package/docs/auto-permission-answers.md +1 -1
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +23 -5
- package/docs/desktop-feed.md +303 -0
- package/docs/desktop-rpc.md +1931 -0
- package/docs/fast-mode.md +2 -2
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell-desktop.md +465 -0
- package/docs/gentle-shell.md +102 -17
- package/docs/images/desktop/chat.png +0 -0
- package/docs/images/desktop/palette.png +0 -0
- package/docs/images/desktop/todo.png +0 -0
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +113 -32
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +19 -6
- package/extensions/ask-user-choice.ts +36 -18
- package/extensions/ask-user-question.ts +48 -9
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +436 -66
- package/extensions/gentle-ai.ts +809 -158
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-feed.ts +778 -0
- package/extensions/gentle-desktop-rpc.ts +276 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-herdr-desktop-status.ts +275 -0
- package/extensions/gentle-shell.ts +174 -59
- package/extensions/gentle-stats.ts +30 -1
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/gentle-tower.ts +305 -0
- package/extensions/skill-registry.ts +260 -225
- package/herdr/RECIPE.md +157 -0
- package/herdr/keys.json +14 -0
- package/herdr/layouts/gentle-shell.json +202 -0
- package/herdr/mods/gentle-agents/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-agents/main.js +190 -0
- package/herdr/mods/gentle-agents/mod.json +1 -0
- package/herdr/mods/gentle-agents/snapshot.js +469 -0
- package/herdr/mods/gentle-agents/tokens.js +273 -0
- package/herdr/mods/gentle-chat/MINIMAL.md +69 -0
- package/herdr/mods/gentle-chat/actions.js +180 -0
- package/herdr/mods/gentle-chat/feed.js +321 -0
- package/herdr/mods/gentle-chat/icons/branch.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chat.svg +1 -0
- package/herdr/mods/gentle-chat/icons/check.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chev.svg +1 -0
- package/herdr/mods/gentle-chat/icons/clip.svg +1 -0
- package/herdr/mods/gentle-chat/icons/down.svg +1 -0
- package/herdr/mods/gentle-chat/icons/folder.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-chat/icons/mark.svg +1 -0
- package/herdr/mods/gentle-chat/icons/send.svg +1 -0
- package/herdr/mods/gentle-chat/icons/shield.svg +1 -0
- package/herdr/mods/gentle-chat/icons/stop.svg +1 -0
- package/herdr/mods/gentle-chat/icons/term.svg +1 -0
- package/herdr/mods/gentle-chat/icons/user.svg +1 -0
- package/herdr/mods/gentle-chat/icons/x.svg +1 -0
- package/herdr/mods/gentle-chat/main.js +968 -0
- package/herdr/mods/gentle-chat/mod.json +1 -0
- package/herdr/mods/gentle-chat/session.js +212 -0
- package/herdr/mods/gentle-chat/snapshot.js +469 -0
- package/herdr/mods/gentle-chat/tokens.js +137 -0
- package/herdr/mods/gentle-chat/ui.js +883 -0
- package/herdr/mods/gentle-confirm/main.js +60 -0
- package/herdr/mods/gentle-confirm/mod.json +1 -0
- package/herdr/mods/gentle-inspector/actions.js +180 -0
- package/herdr/mods/gentle-inspector/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/bot.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/check.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/db.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/diff.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/plug.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/review.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stats.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stop.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/todo.svg +1 -0
- package/herdr/mods/gentle-inspector/main.js +500 -0
- package/herdr/mods/gentle-inspector/mod.json +1 -0
- package/herdr/mods/gentle-inspector/snapshot.js +469 -0
- package/herdr/mods/gentle-inspector/tokens.js +273 -0
- package/herdr/mods/gentle-palette/actions.js +180 -0
- package/herdr/mods/gentle-palette/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-palette/icons/bot.svg +1 -0
- package/herdr/mods/gentle-palette/icons/chat.svg +1 -0
- package/herdr/mods/gentle-palette/icons/check.svg +1 -0
- package/herdr/mods/gentle-palette/icons/cmd.svg +1 -0
- package/herdr/mods/gentle-palette/icons/diff.svg +1 -0
- package/herdr/mods/gentle-palette/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-palette/icons/plus.svg +1 -0
- package/herdr/mods/gentle-palette/icons/review.svg +1 -0
- package/herdr/mods/gentle-palette/icons/search.svg +1 -0
- package/herdr/mods/gentle-palette/icons/shield.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stats.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stop.svg +1 -0
- package/herdr/mods/gentle-palette/icons/term.svg +1 -0
- package/herdr/mods/gentle-palette/icons/todo.svg +1 -0
- package/herdr/mods/gentle-palette/main.js +333 -0
- package/herdr/mods/gentle-palette/mod.json +1 -0
- package/herdr/mods/gentle-palette/snapshot.js +469 -0
- package/herdr/mods/gentle-palette/tokens.js +273 -0
- package/herdr/mods/gentle-pane/icons/chat.svg +1 -0
- package/herdr/mods/gentle-pane/icons/close.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-down.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-right.svg +1 -0
- package/herdr/mods/gentle-pane/icons/term.svg +1 -0
- package/herdr/mods/gentle-pane/icons/unzoom.svg +1 -0
- package/herdr/mods/gentle-pane/icons/zoom.svg +1 -0
- package/herdr/mods/gentle-pane/main.js +91 -0
- package/herdr/mods/gentle-pane/mod.json +1 -0
- package/herdr/mods/gentle-pane/snapshot.js +469 -0
- package/herdr/mods/gentle-pane/tokens.js +273 -0
- package/herdr/mods/gentle-sidebar/actions.js +180 -0
- package/herdr/mods/gentle-sidebar/icons/gear.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/mark.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/refresh.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/server-plus.svg +1 -0
- package/herdr/mods/gentle-sidebar/main.js +171 -0
- package/herdr/mods/gentle-sidebar/mod.json +1 -0
- package/herdr/mods/gentle-sidebar/snapshot.js +469 -0
- package/herdr/mods/gentle-sidebar/tokens.js +273 -0
- package/herdr/mods/gentle-spaces/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/monitor.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/plus.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/server.svg +1 -0
- package/herdr/mods/gentle-spaces/machines.js +31 -0
- package/herdr/mods/gentle-spaces/main.js +299 -0
- package/herdr/mods/gentle-spaces/mod.json +1 -0
- package/herdr/mods/gentle-spaces/snapshot.js +469 -0
- package/herdr/mods/gentle-spaces/tokens.js +273 -0
- package/herdr/mods/gentle-status/actions.js +180 -0
- package/herdr/mods/gentle-status/main.js +192 -0
- package/herdr/mods/gentle-status/mod.json +1 -0
- package/herdr/mods/gentle-status/snapshot.js +469 -0
- package/herdr/mods/gentle-status/tokens.js +273 -0
- package/herdr/mods/gentle-tabs/icons/close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/plus.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-max.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-min.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-restore.svg +1 -0
- package/herdr/mods/gentle-tabs/main.js +171 -0
- package/herdr/mods/gentle-tabs/mod.json +1 -0
- package/herdr/mods/gentle-tabs/snapshot.js +469 -0
- package/herdr/mods/gentle-tabs/tokens.js +273 -0
- package/herdr/mods/gentle-tokens/main.js +20 -0
- package/herdr/mods/gentle-tokens/mod.json +1 -0
- package/herdr/mods/gentle-tokens/snapshot.js +469 -0
- package/herdr/mods/gentle-tokens/tokens.js +273 -0
- package/herdr/preview.png +0 -0
- package/herdr/themes/gentle-shell-dark.json +33 -0
- package/herdr/themes/gentle-shell-light.json +34 -0
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +17 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-rpc-publisher.ts +39 -12
- package/lib/agents-runner.ts +92 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/auto-permission-answers.ts +2 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/background-jobs.ts +22 -2
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/change-diff.ts +104 -0
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/commit-slice-signal.ts +1 -1
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +38 -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 +315 -0
- package/lib/desktop-changes-service.ts +171 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-feed-actions.ts +804 -0
- package/lib/desktop-feed-answers.ts +129 -0
- package/lib/desktop-feed-sources.ts +184 -0
- package/lib/desktop-feed-stats.ts +98 -0
- package/lib/desktop-feed-store.ts +124 -0
- package/lib/desktop-feed.ts +788 -0
- package/lib/desktop-jobs-service.ts +290 -0
- package/lib/desktop-review-service.ts +187 -0
- package/lib/desktop-rpc-agents.ts +403 -0
- package/lib/desktop-rpc-changes.ts +223 -0
- package/lib/desktop-rpc-config-watch.ts +285 -0
- package/lib/desktop-rpc-config.ts +885 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +290 -0
- package/lib/desktop-rpc-permissions.ts +328 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-review.ts +180 -0
- package/lib/desktop-rpc-session.ts +203 -0
- package/lib/desktop-rpc-sessions.ts +250 -0
- package/lib/desktop-rpc-stats.ts +187 -0
- package/lib/desktop-rpc-updates.ts +143 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +336 -0
- package/lib/desktop-session-service.ts +223 -0
- package/lib/desktop-sessions-service.ts +249 -0
- package/lib/desktop-stats-service.ts +142 -0
- package/lib/desktop-updates-service.ts +268 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/gentle-shell-desktop.ts +1370 -0
- package/lib/gentle-shell-launcher.ts +45 -3
- package/lib/herdr-desktop-events.ts +40 -0
- package/lib/herdr-desktop-status.ts +229 -0
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/jobs-sidebar-state.ts +5 -0
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +86 -4
- package/lib/openai-fast-tier.ts +1 -0
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/session-profile-freeze.ts +13 -5
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/stats-collector.ts +56 -27
- package/lib/tower-actions.ts +100 -0
- package/lib/tower-hub.ts +73 -0
- package/lib/tower-launch.ts +111 -0
- package/lib/tower-open.ts +99 -0
- package/lib/tower-presence.ts +70 -0
- package/lib/tower-server.ts +234 -0
- package/lib/tower-snapshot.ts +298 -0
- package/lib/update-status.ts +238 -0
- package/lib/verifier-settle-reminder.ts +1 -1
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +14 -5
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +39 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/gentle-shell-desktop.mjs +1371 -0
- package/runtime/gentle-shell-launcher.mjs +44 -2
- package/runtime/native-review-cli.mjs +86 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/runtime/tower-actions.mjs +101 -0
- package/runtime/tower-hub.mjs +74 -0
- package/runtime/tower-launch.mjs +112 -0
- package/runtime/tower-open.mjs +100 -0
- package/runtime/tower-presence.mjs +71 -0
- package/runtime/tower-server.mjs +234 -0
- package/runtime/tower-snapshot.mjs +299 -0
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +5 -21
- package/scripts/build-runtime-modules.mjs +10 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +61 -20
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/provider-defect-report/SKILL.md +61 -0
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -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 +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- 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 +26 -7
- 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 +78 -21
- package/tests/ask-user-question.test.ts +61 -6
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/auto-permission-answers.test.ts +12 -1
- package/tests/background-jobs.test.ts +12 -0
- package/tests/bounded-stop-contract.test.ts +148 -27
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/change-diff.test.ts +75 -0
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/commit-slice-signal.test.ts +3 -2
- package/tests/decision-routing-contract.test.ts +390 -0
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delegated-key-learnings-contract.test.ts +21 -28
- package/tests/delivery-b-rendered-surfaces.test.ts +32 -0
- 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 -878
- 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 +528 -0
- package/tests/design-canvas-inspector.test.ts +1004 -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 +91 -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 +189 -0
- package/tests/design-canvas-theme.test.ts +198 -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-feed-actions-guards.test.ts +595 -0
- package/tests/desktop-feed-actions.test.ts +761 -0
- package/tests/desktop-feed-live-work.test.ts +209 -0
- package/tests/desktop-feed-performance.test.ts +369 -0
- package/tests/desktop-feed-plan-profiles.test.ts +509 -0
- package/tests/desktop-feed-send-prompt.test.ts +303 -0
- package/tests/desktop-feed-tool-summaries.test.ts +69 -0
- package/tests/desktop-feed.test.ts +615 -0
- package/tests/desktop-rpc-agents.test.ts +1319 -0
- package/tests/desktop-rpc-changes.test.ts +608 -0
- package/tests/desktop-rpc-config-watch.test.ts +1159 -0
- package/tests/desktop-rpc-config.test.ts +1462 -0
- package/tests/desktop-rpc-design.test.ts +672 -0
- package/tests/desktop-rpc-jobs.test.ts +1193 -0
- package/tests/desktop-rpc-permissions.test.ts +321 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-review.test.ts +678 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-session.test.ts +642 -0
- package/tests/desktop-rpc-sessions.test.ts +647 -0
- package/tests/desktop-rpc-stats.test.ts +431 -0
- package/tests/desktop-rpc-updates.test.ts +525 -0
- package/tests/desktop-rpc-usage.test.ts +707 -0
- package/tests/desktop-rpc.test.ts +293 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -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 +30 -41
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/fixtures/session-profile-v1/replay.ts +4 -1
- package/tests/full-delegation-closure.test.ts +48 -0
- package/tests/gentle-agents.test.ts +848 -8
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +195 -21
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-fast.test.ts +15 -0
- package/tests/gentle-herdr-desktop-status.test.ts +595 -0
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-desktop-bin.test.ts +125 -0
- package/tests/gentle-shell-desktop.test.ts +927 -0
- package/tests/gentle-shell-launcher-tower.test.ts +104 -0
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +121 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/gentle-tower.test.ts +578 -0
- package/tests/herdr-desktop-status.test.ts +285 -0
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +35 -9
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +181 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +907 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +19 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- 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 +33 -15
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-canonical-ratchet.test.ts +10 -0
- package/tests/odd-routing-contract.test.ts +99 -31
- package/tests/orchestrator-budget.test.ts +32 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +12 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +249 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +15 -14
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- 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-routing-measured-values.test.ts +24 -0
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- 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 +25 -0
- package/tests/profile-fast-tier.test.ts +66 -1
- package/tests/provider-defect-handoff.test.ts +124 -99
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- 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 +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +2 -1
- package/tests/review-controller.test.ts +2 -1
- 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.test.ts +271 -4
- 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 +27 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- 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-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/sensitive-path-tools.test.ts +138 -4
- package/tests/session-profile-extension.test.ts +312 -18
- package/tests/session-profile-freeze.test.ts +26 -0
- package/tests/session-profile-v1-compat.test.ts +20 -0
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-collision-prefixes.test.ts +1 -0
- package/tests/skill-contradictions-contract.test.ts +124 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +983 -306
- package/tests/stats-collector.test.ts +109 -2
- package/tests/support/design-canvas-dom.ts +386 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +49 -14
- 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/tower-actions.test.ts +247 -0
- package/tests/tower-artifacts.test.ts +114 -0
- package/tests/tower-open.test.ts +97 -0
- package/tests/tower-presence.test.ts +175 -0
- package/tests/tower-server.test.ts +122 -0
- package/tests/tower-snapshot.test.ts +236 -0
- package/tests/tower-web-echo.test.ts +125 -0
- package/tests/tower-web-hover.test.ts +251 -0
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-scoped-stop-contract.test.ts +32 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verifier-settle-reminder.test.ts +2 -2
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +88 -12
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +136 -27
- 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 +184 -0
- package/tests/writer-rejection-next-step.test.ts +55 -0
- package/tests/writer-surface-authority-contract.test.ts +158 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/targeted-validator.json +0 -0
package/lib/gentle-design.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { designCommentBatchContent, designCommentContent, hasSystemTokens, listDesignEntries, readDesignManifest, resolveSystemBoard, startDesignCanvasServer, type DesignArtboard, type DesignCanvasServer, type DesignCanvasServerOptions, type DesignSessionContent } from "./design-canvas-server.ts";
|
|
3
|
-
import { createDesignCommentStore, DesignCommentsError, type StoredDesignComment } from "./design-comments.ts";
|
|
3
|
+
import { createDesignCommentStore, DesignCommentsError, describeViewport, noteProblem, type StoredDesignComment } from "./design-comments.ts";
|
|
4
4
|
import { createDesignHandoffStore, DesignHandoffsError, sendDesignHandoff, type DesignHandoff, type DesignHandoffDelivery, type DesignHandoffStatus } from "./design-handoffs.ts";
|
|
5
5
|
import { openInBrowser, type OpenInBrowserResult } from "./design-open-browser.ts";
|
|
6
6
|
import { detectDesignSources, staleDesignSources } from "./design-sources.ts";
|
|
7
|
+
import { createDesignPartStore, DesignPartsError, type DesignPart } from "./design-parts.ts";
|
|
7
8
|
|
|
8
9
|
// Gentle Design helpers: argument parsing, the designs already written under
|
|
9
10
|
// design/<slug>/design.json, the usage text, the per-session canvas that
|
|
@@ -78,7 +79,7 @@ export type DesignImplementInput = {
|
|
|
78
79
|
/** Whether design/system.md exists. */
|
|
79
80
|
systemTokens: boolean;
|
|
80
81
|
/** The open comments on this artboard. */
|
|
81
|
-
comments: ReadonlyArray<Pick<StoredDesignComment, "id" | "selector" | "excerpt" | "comment">>;
|
|
82
|
+
comments: ReadonlyArray<Pick<StoredDesignComment, "id" | "selector" | "excerpt" | "comment" | "viewport">>;
|
|
82
83
|
};
|
|
83
84
|
|
|
84
85
|
/** The handoff message for one artboard (S8); the command and the canvas button both send exactly this. */
|
|
@@ -103,12 +104,13 @@ export function designImplementMessage(input: DesignImplementInput): string {
|
|
|
103
104
|
`${index + 1}. Comment id: ${comment.id}`,
|
|
104
105
|
` Element: ${comment.selector}`,
|
|
105
106
|
` Excerpt: ${comment.excerpt ? JSON.stringify(comment.excerpt) : "(none)"}`,
|
|
107
|
+
...(comment.viewport ? [` Viewport: ${describeViewport(comment.viewport)} (edit for this width)`] : []),
|
|
106
108
|
" Comment:",
|
|
107
109
|
...comment.comment.split("\n").map((line) => ` ${line}`),
|
|
108
110
|
);
|
|
109
111
|
});
|
|
110
112
|
const ids = input.comments.map((comment) => JSON.stringify(comment.id)).join(", ");
|
|
111
|
-
lines.push(`When they are applied, resolve them with the ${DESIGN_COMMENTS_TOOL_NAME} tool (action "resolve", slug "${input.slug}", ids [${ids}]).`);
|
|
113
|
+
lines.push(`When they are applied, resolve them with the ${DESIGN_COMMENTS_TOOL_NAME} tool (action "resolve", slug "${input.slug}", ids [${ids}], note "<one line on what you changed>").`);
|
|
112
114
|
}
|
|
113
115
|
lines.push(
|
|
114
116
|
"",
|
|
@@ -121,6 +123,75 @@ export function designImplementMessage(input: DesignImplementInput): string {
|
|
|
121
123
|
return lines.join("\n");
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
export type DesignVariantInput = {
|
|
127
|
+
slug: string;
|
|
128
|
+
artboard: Pick<DesignArtboard, "file" | "title">;
|
|
129
|
+
/** What should change, already trimmed (1 to 2000 characters). */
|
|
130
|
+
instruction: string;
|
|
131
|
+
/** Whether design/system.md exists. */
|
|
132
|
+
systemTokens: boolean;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** The message for "Try another direction from this…" (S3): the skill adds the next artboard based on the source file. */
|
|
136
|
+
export function designVariantMessage(input: DesignVariantInput): string {
|
|
137
|
+
const folder = `design/${input.slug}`;
|
|
138
|
+
const path = `${folder}/${input.artboard.file}`;
|
|
139
|
+
const lines = [
|
|
140
|
+
`Add another direction to the design ${folder}/, based on the artboard ${path}`,
|
|
141
|
+
"",
|
|
142
|
+
`Source artboard: ${path}`,
|
|
143
|
+
`Title: ${input.artboard.title}`,
|
|
144
|
+
"",
|
|
145
|
+
"What should change:",
|
|
146
|
+
...input.instruction.split("\n").map((line) => ` ${line}`),
|
|
147
|
+
"",
|
|
148
|
+
`Follow the ${DESIGN_SKILL_NAME} skill ("Save and try a different approach"): write the next artboard (the next NN after the existing ones, NN-<name>.html) in ${folder}/, starting from the source file, and append it to ${folder}/design.json with its title, tradeoff, width and height. Keep every existing artboard and its file as they are.`,
|
|
149
|
+
];
|
|
150
|
+
if (input.systemTokens) lines.push("Take colors, typography, spacing, radius and shadows from design/system.md, the project's token source.");
|
|
151
|
+
lines.push(`When it is written, refresh the canvas with the ${DESIGN_TOOL_NAME} tool (action "open", slug "${input.slug}").`);
|
|
152
|
+
return lines.join("\n");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type DesignImplementPartInput = {
|
|
156
|
+
slug: string;
|
|
157
|
+
artboard: Pick<DesignArtboard, "file" | "title">;
|
|
158
|
+
/** The recorded part; `instruction` is the user's note, absent or empty when none. */
|
|
159
|
+
part: Pick<DesignPart, "id" | "selector" | "excerpt" | "instruction">;
|
|
160
|
+
feature?: string;
|
|
161
|
+
/** Whether design/system.md exists. */
|
|
162
|
+
systemTokens: boolean;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The message for "Implement only this" (canvas-implement-part S5): build one element of an artboard in the real
|
|
167
|
+
* app, without choosing the direction, and report on that part with the handoff action's `part`.
|
|
168
|
+
*/
|
|
169
|
+
export function designImplementPartMessage(input: DesignImplementPartInput): string {
|
|
170
|
+
const path = `design/${input.slug}/${input.artboard.file}`;
|
|
171
|
+
const instruction = input.part.instruction ?? "";
|
|
172
|
+
const lines = [
|
|
173
|
+
`Implement only one part of the design artboard ${path}`,
|
|
174
|
+
"",
|
|
175
|
+
`Artboard: ${path}`,
|
|
176
|
+
`Title: ${input.artboard.title}`,
|
|
177
|
+
`Part id: ${input.part.id}`,
|
|
178
|
+
`Element: ${input.part.selector}`,
|
|
179
|
+
`Excerpt: ${input.part.excerpt ? JSON.stringify(input.part.excerpt) : "(none)"}`,
|
|
180
|
+
...(instruction ? ["Note:", ...instruction.split("\n")] : ["Note: (none)"]),
|
|
181
|
+
"",
|
|
182
|
+
"Build only this element in the project's real stack, as the shared piece the app would reuse (a layout or component) when it has one. Use the artboard as the visual spec for it: map it to the project's existing components and styles, and do not copy the artboard HTML verbatim. Leave the rest of the artboard unbuilt: this does not choose a direction, and the other artboards stay open.",
|
|
183
|
+
];
|
|
184
|
+
if (input.systemTokens) lines.push("Take colors, typography, spacing, radius and shadows from design/system.md, the project's token source.");
|
|
185
|
+
lines.push(
|
|
186
|
+
`Report progress with the ${DESIGN_TOOL_NAME} tool: action "handoff", target "${input.slug}/${input.artboard.file}", part "${input.part.id}", status "in_progress" when you start; status "implemented" when it is done, with a one-line note on where it lives in the project.`,
|
|
187
|
+
input.feature
|
|
188
|
+
? `This design belongs to an ODD feature: track this part in ${input.feature} (add or reopen its task there and log this handoff).`
|
|
189
|
+
: "This design is not linked to an ODD feature document: size it under the project's ODD rules as usual.",
|
|
190
|
+
"This handoff itself commits nothing.",
|
|
191
|
+
);
|
|
192
|
+
return lines.join("\n");
|
|
193
|
+
}
|
|
194
|
+
|
|
124
195
|
/** The artboard a handoff records in handoffs.json (S15). */
|
|
125
196
|
export type DesignHandoffTarget = { slug: string; file: string; feature?: string };
|
|
126
197
|
|
|
@@ -188,6 +259,32 @@ export async function planDesignImplement(cwd: string, target: string): Promise<
|
|
|
188
259
|
return { kind: "send", message: designImplementMessage({ slug, artboard, feature, systemTokens: hasSystemTokens(designRoot), comments }), warnings, handoff: { slug, file: artboard.file, feature } };
|
|
189
260
|
}
|
|
190
261
|
|
|
262
|
+
export type DesignVariantPlan = { kind: "send"; message: string } | { kind: "refuse"; notice: DesignNotice };
|
|
263
|
+
|
|
264
|
+
/** Validates `<slug>/<file>` against the design's manifest and builds the variant message; the canvas route sends exactly this. */
|
|
265
|
+
export function planDesignVariant(cwd: string, request: { slug: string; file: string; instruction: string }): DesignVariantPlan {
|
|
266
|
+
const resolved = resolveDesignTarget(cwd, `${request.slug}/${request.file}`, "add a direction to");
|
|
267
|
+
if (resolved.kind === "refuse") return resolved;
|
|
268
|
+
const { slug, artboard } = resolved;
|
|
269
|
+
return { kind: "send", message: designVariantMessage({ slug, artboard, instruction: request.instruction, systemTokens: hasSystemTokens(join(cwd, "design")) }) };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Checks the part's artboard against the design's manifest and builds its message; the canvas route sends exactly this. */
|
|
273
|
+
export function planDesignImplementPart(cwd: string, request: { slug: string; part: DesignPart }): DesignVariantPlan {
|
|
274
|
+
const resolved = resolveDesignTarget(cwd, `${request.slug}/${request.part.file}`, "implement a part of");
|
|
275
|
+
if (resolved.kind === "refuse") return resolved;
|
|
276
|
+
const { slug, artboard, feature } = resolved;
|
|
277
|
+
return { kind: "send", message: designImplementPartMessage({ slug, artboard, part: request.part, feature, systemTokens: hasSystemTokens(join(cwd, "design")) }) };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** A parts.json problem as the reason the model reads; a broken file is never overwritten. */
|
|
281
|
+
function partsProblem(slug: string, error: unknown): Error {
|
|
282
|
+
if (error instanceof DesignPartsError && error.code === "invalid-file") {
|
|
283
|
+
return new Error(`design/${slug}/parts.json cannot be read: ${error.message}. Fix the file by hand; it is never overwritten.`);
|
|
284
|
+
}
|
|
285
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
286
|
+
}
|
|
287
|
+
|
|
191
288
|
/** A handoffs.json problem as the reason the user or the model reads; a broken file is never overwritten. */
|
|
192
289
|
function handoffsProblem(slug: string, error: unknown): Error {
|
|
193
290
|
if (error instanceof DesignHandoffsError && error.code === "invalid-file") {
|
|
@@ -219,6 +316,16 @@ export interface DesignCanvasDeps {
|
|
|
219
316
|
*/
|
|
220
317
|
export type DesignOpenNotice = DesignNotice & { url?: string; opened?: boolean; refreshed?: boolean };
|
|
221
318
|
|
|
319
|
+
/** Sanitized canvas state: whether a server runs, the slug it last showed (null: system board), and connected pages. */
|
|
320
|
+
export type DesignCanvasState = {
|
|
321
|
+
running: boolean;
|
|
322
|
+
slug: string | null;
|
|
323
|
+
connectedClients: number;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
/** An actual open/refresh/stop transition with its sanitized post-transition state; never the URL. */
|
|
327
|
+
export type DesignCanvasTransition = DesignCanvasState & { transition: "open" | "refresh" | "stop" };
|
|
328
|
+
|
|
222
329
|
export interface DesignCanvas {
|
|
223
330
|
/**
|
|
224
331
|
* Shows `slug`, or the most recent design, on the session's canvas server, starting it when needed.
|
|
@@ -229,6 +336,10 @@ export interface DesignCanvas {
|
|
|
229
336
|
stop(): Promise<boolean>;
|
|
230
337
|
/** The URL the running canvas last showed; undefined when none is running. */
|
|
231
338
|
url(): string | undefined;
|
|
339
|
+
/** The running canvas's sanitized state (never the URL); stopped when none is running. */
|
|
340
|
+
state(): Promise<DesignCanvasState>;
|
|
341
|
+
/** Subscribe to actual open/refresh/stop transitions (sanitized, never the URL). */
|
|
342
|
+
observe(onTransition: (transition: DesignCanvasTransition) => void): () => void;
|
|
232
343
|
}
|
|
233
344
|
|
|
234
345
|
/** The canvas of `slug`, or the root canvas (system board only) when slug is null. */
|
|
@@ -244,15 +355,29 @@ function canvasUrl(server: DesignCanvasServer, slug: string | null): string {
|
|
|
244
355
|
export function createDesignCanvas(deliver: (message: DesignSessionContent) => DesignHandoffDelivery | Promise<DesignHandoffDelivery>, deps: DesignCanvasDeps = {}): DesignCanvas {
|
|
245
356
|
const startServer = deps.startServer ?? startDesignCanvasServer;
|
|
246
357
|
const openBrowser = deps.openBrowser ?? ((url: string) => openInBrowser(url));
|
|
247
|
-
let running: { root: string; server: Promise<DesignCanvasServer>; url?: string } | undefined;
|
|
358
|
+
let running: { root: string; server: Promise<DesignCanvasServer>; url?: string; slug: string | null } | undefined;
|
|
359
|
+
const observers = new Set<(transition: DesignCanvasTransition) => void>();
|
|
360
|
+
|
|
361
|
+
function emitTransition(transition: DesignCanvasTransition): void {
|
|
362
|
+
for (const onTransition of [...observers]) {
|
|
363
|
+
try {
|
|
364
|
+
onTransition(transition);
|
|
365
|
+
} catch {
|
|
366
|
+
/* an observer never breaks the canvas */
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
248
370
|
|
|
249
371
|
async function stop(): Promise<boolean> {
|
|
250
372
|
const current = running;
|
|
251
373
|
running = undefined;
|
|
252
374
|
if (!current) return false;
|
|
253
375
|
const server = await current.server.catch(() => undefined);
|
|
254
|
-
|
|
255
|
-
|
|
376
|
+
// A server that never started is a failed action, not a stop transition.
|
|
377
|
+
if (!server) return false;
|
|
378
|
+
await server.close();
|
|
379
|
+
emitTransition({ transition: "stop", running: false, slug: null, connectedClients: 0 });
|
|
380
|
+
return true;
|
|
256
381
|
}
|
|
257
382
|
|
|
258
383
|
async function serverFor(cwd: string): Promise<DesignCanvasServer> {
|
|
@@ -271,8 +396,20 @@ export function createDesignCanvas(deliver: (message: DesignSessionContent) => D
|
|
|
271
396
|
if (plan.kind === "refuse") throw new Error(plan.notice.message);
|
|
272
397
|
return deliver(plan.message);
|
|
273
398
|
},
|
|
399
|
+
// Not a handoff: nothing is recorded, the new artboard arrives through the manifest.
|
|
400
|
+
onVariant: (request) => {
|
|
401
|
+
const plan = planDesignVariant(cwd, request);
|
|
402
|
+
if (plan.kind === "refuse") throw new Error(plan.notice.message);
|
|
403
|
+
return deliver(plan.message);
|
|
404
|
+
},
|
|
405
|
+
// One element on its own: the server has recorded it in parts.json, never handoffs.json.
|
|
406
|
+
onImplementPart: (request) => {
|
|
407
|
+
const plan = planDesignImplementPart(cwd, request);
|
|
408
|
+
if (plan.kind === "refuse") throw new Error(plan.notice.message);
|
|
409
|
+
return deliver(plan.message);
|
|
410
|
+
},
|
|
274
411
|
});
|
|
275
|
-
running = { root, server };
|
|
412
|
+
running = { root, server, slug: null };
|
|
276
413
|
server.catch(() => { if (running?.server === server) running = undefined; });
|
|
277
414
|
}
|
|
278
415
|
return running.server;
|
|
@@ -298,22 +435,41 @@ export function createDesignCanvas(deliver: (message: DesignSessionContent) => D
|
|
|
298
435
|
return { message: `The design canvas could not start: ${error instanceof Error ? error.message : String(error)}`, level: "error" };
|
|
299
436
|
}
|
|
300
437
|
const url = canvasUrl(server, slug);
|
|
301
|
-
if (running)
|
|
438
|
+
if (running) {
|
|
439
|
+
running.url = url;
|
|
440
|
+
running.slug = slug;
|
|
441
|
+
}
|
|
302
442
|
if (reused && server.connectedClients() > 0 && server.show(slug) > 0) {
|
|
443
|
+
emitTransition({ transition: "refresh", running: true, slug, connectedClients: server.connectedClients() });
|
|
303
444
|
return { message: `Design canvas refreshed: ${url}`, level: "info", url, opened: true, refreshed: true };
|
|
304
445
|
}
|
|
305
446
|
const result = await openBrowser(url);
|
|
306
|
-
if (result.opened)
|
|
447
|
+
if (result.opened) {
|
|
448
|
+
emitTransition({ transition: "open", running: true, slug, connectedClients: server.connectedClients() });
|
|
449
|
+
return { message: `Design canvas: ${url}`, level: "info", url, opened: true };
|
|
450
|
+
}
|
|
307
451
|
const reason = result.error ? ` (${result.error})` : "";
|
|
308
452
|
return { message: `Design canvas: ${url}\nThe browser could not be opened${reason}. Open the URL manually.`, level: "warning", url, opened: false };
|
|
309
453
|
}
|
|
310
454
|
|
|
311
|
-
|
|
455
|
+
async function state(): Promise<DesignCanvasState> {
|
|
456
|
+
if (!running) return { running: false, slug: null, connectedClients: 0 };
|
|
457
|
+
const server = await running.server.catch(() => undefined);
|
|
458
|
+
if (!server) return { running: false, slug: null, connectedClients: 0 };
|
|
459
|
+
return { running: true, slug: running.slug, connectedClients: server.connectedClients() };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function observe(onTransition: (transition: DesignCanvasTransition) => void): () => void {
|
|
463
|
+
observers.add(onTransition);
|
|
464
|
+
return () => observers.delete(onTransition);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return { open, stop, url: () => running?.url, state, observe };
|
|
312
468
|
}
|
|
313
469
|
|
|
314
470
|
export const DESIGN_COMMENTS_TOOL_NAME = "gentle_design_comments";
|
|
315
471
|
|
|
316
|
-
export type DesignCommentsToolParams = { action: "list" | "resolve"; slug?: string; file?: string; ids?: string[] };
|
|
472
|
+
export type DesignCommentsToolParams = { action: "list" | "resolve"; slug?: string; file?: string; ids?: string[]; note?: string };
|
|
317
473
|
export type DesignCommentsToolResult = { text: string; details: { comments: Array<StoredDesignComment & { slug: string }> } | { slug: string; resolved: string[]; unknown: string[] } };
|
|
318
474
|
|
|
319
475
|
function describeComment(slug: string, comment: StoredDesignComment): string[] {
|
|
@@ -321,6 +477,7 @@ function describeComment(slug: string, comment: StoredDesignComment): string[] {
|
|
|
321
477
|
`- [${comment.id}] design/${slug}/${comment.file}`,
|
|
322
478
|
` Element: ${comment.selector}`,
|
|
323
479
|
` Excerpt: ${comment.excerpt ? JSON.stringify(comment.excerpt) : "(none)"}`,
|
|
480
|
+
...(comment.viewport ? [` Viewport: ${describeViewport(comment.viewport)} (edit for this width)`] : []),
|
|
324
481
|
` Comment: ${comment.comment.split("\n").join("\n ")}`,
|
|
325
482
|
...(comment.screenshot ? [` Screenshot: design/${slug}/${comment.screenshot} (open it with the read tool)`] : []),
|
|
326
483
|
];
|
|
@@ -336,7 +493,11 @@ export async function runDesignCommentsTool(cwd: string, params: DesignCommentsT
|
|
|
336
493
|
if (typeof params.slug !== "string" || !params.slug) throw new Error("resolve needs the design slug.");
|
|
337
494
|
const ids = params.ids ?? [];
|
|
338
495
|
if (ids.length === 0) throw new Error("resolve needs at least one comment id in ids.");
|
|
339
|
-
|
|
496
|
+
if (params.note !== undefined) {
|
|
497
|
+
const problem = noteProblem(params.note);
|
|
498
|
+
if (problem) throw new Error(problem);
|
|
499
|
+
}
|
|
500
|
+
const { updated, unknown } = await store.setStatus(params.slug, ids, "resolved", params.note === undefined ? undefined : { note: params.note }).catch((error: unknown) => { throw failure(params.slug!, error); });
|
|
340
501
|
const resolved = updated.map((comment) => comment.id);
|
|
341
502
|
const lines = [`Resolved ${resolved.length} comment${resolved.length === 1 ? "" : "s"} in design/${params.slug}${resolved.length ? `: ${resolved.join(", ")}` : ""}.`];
|
|
342
503
|
if (unknown.length) lines.push(`Unknown ids: ${unknown.join(", ")}.`);
|
|
@@ -357,7 +518,7 @@ export async function runDesignCommentsTool(cwd: string, params: DesignCommentsT
|
|
|
357
518
|
const scope = params.slug ? `design/${params.slug}${params.file ? `/${params.file}` : ""}` : "design/";
|
|
358
519
|
const lines = found.length === 0
|
|
359
520
|
? [`No open comments in ${scope}.`]
|
|
360
|
-
: [`Open design comments in ${scope} (${found.length}):`, ...found.flatMap((comment) => describeComment(comment.slug, comment)), "", `After applying a comment, resolve it with ${DESIGN_COMMENTS_TOOL_NAME} (action "resolve", slug, ids).`];
|
|
521
|
+
: [`Open design comments in ${scope} (${found.length}):`, ...found.flatMap((comment) => describeComment(comment.slug, comment)), "", `After applying a comment, resolve it with ${DESIGN_COMMENTS_TOOL_NAME} (action "resolve", slug, ids, note); the note is one line on what you changed, shown next to the comment.`];
|
|
361
522
|
if (problems.length) lines.push("", "Unreadable comment files:", ...problems.map((problem) => `- ${problem}`));
|
|
362
523
|
return { text: lines.join("\n"), details: { comments: found } };
|
|
363
524
|
}
|
|
@@ -381,6 +542,8 @@ export type DesignToolParams = {
|
|
|
381
542
|
status?: string;
|
|
382
543
|
note?: string;
|
|
383
544
|
previewUrl?: string;
|
|
545
|
+
/** handoff only: a part handed off on its own ("Implement only this"); its id in parts.json. */
|
|
546
|
+
part?: string;
|
|
384
547
|
};
|
|
385
548
|
/** How many design source paths list names; `total` still counts them all. */
|
|
386
549
|
const LISTED_DESIGN_SOURCES = 20;
|
|
@@ -397,7 +560,8 @@ export type DesignToolDetails =
|
|
|
397
560
|
| { url: string; opened: boolean; refreshed?: true }
|
|
398
561
|
| { stopped: boolean }
|
|
399
562
|
| { target: string; warnings: string[] }
|
|
400
|
-
| { target: string; chosen: string | null; handoff: DesignHandoff }
|
|
563
|
+
| { target: string; chosen: string | null; handoff: DesignHandoff }
|
|
564
|
+
| { target: string; part: DesignPart };
|
|
401
565
|
/** `texts` become the tool's content parts; a refusal throws, so Pi flags the result as an error. */
|
|
402
566
|
export type DesignToolResult = { texts: string[]; details: DesignToolDetails };
|
|
403
567
|
|
|
@@ -417,11 +581,20 @@ type ListedDesign = {
|
|
|
417
581
|
chosen?: string | null;
|
|
418
582
|
handoffs?: Record<string, DesignHandoff>;
|
|
419
583
|
handoffsError?: string;
|
|
584
|
+
/** Present only when the design has parts handed off on their own (canvas-implement-part). */
|
|
585
|
+
parts?: DesignPart[];
|
|
586
|
+
partsError?: string;
|
|
420
587
|
};
|
|
421
588
|
|
|
589
|
+
function partState(part: DesignPart): string {
|
|
590
|
+
const status = part.status === "in_progress" ? "in progress" : part.status;
|
|
591
|
+
return `${part.id} ${part.file} ${part.selector} (${status}${part.status === "sent" && part.queued ? ", queued" : ""})`;
|
|
592
|
+
}
|
|
593
|
+
|
|
422
594
|
async function listDesignTool(cwd: string, canvas: DesignCanvas): Promise<DesignToolResult> {
|
|
423
595
|
const designRoot = join(cwd, "design");
|
|
424
596
|
const handoffStore = createDesignHandoffStore(designRoot);
|
|
597
|
+
const partStore = createDesignPartStore(designRoot);
|
|
425
598
|
const designs: ListedDesign[] = [];
|
|
426
599
|
for (const { slug, title } of listDesigns(cwd)) {
|
|
427
600
|
let design: ListedDesign;
|
|
@@ -440,6 +613,12 @@ async function listDesignTool(cwd: string, canvas: DesignCanvas): Promise<Design
|
|
|
440
613
|
} catch (error) {
|
|
441
614
|
design.handoffsError = error instanceof Error ? error.message : String(error);
|
|
442
615
|
}
|
|
616
|
+
try {
|
|
617
|
+
const { parts } = await partStore.read(slug);
|
|
618
|
+
if (parts.length > 0) design.parts = parts;
|
|
619
|
+
} catch (error) {
|
|
620
|
+
design.partsError = error instanceof Error ? error.message : String(error);
|
|
621
|
+
}
|
|
443
622
|
designs.push(design);
|
|
444
623
|
}
|
|
445
624
|
const systemBoard = hasSystemBoard(cwd);
|
|
@@ -453,6 +632,8 @@ async function listDesignTool(cwd: string, canvas: DesignCanvas): Promise<Design
|
|
|
453
632
|
const entry = design.handoffs && Object.hasOwn(design.handoffs, artboard.file) ? design.handoffs[artboard.file] : undefined;
|
|
454
633
|
lines.push(` - ${artboard.file}: ${artboard.title}${entry ? ` (${handoffState(entry)})` : ""}`);
|
|
455
634
|
}
|
|
635
|
+
if (design.parts) lines.push(` Parts handed off on their own (${design.parts.length}): ${design.parts.map(partState).join("; ")}`);
|
|
636
|
+
if (design.partsError) lines.push(` parts.json cannot be read: ${design.partsError}`);
|
|
456
637
|
}
|
|
457
638
|
lines.push(systemBoard ? "System board: design/system.html (shown first on the canvas)." : "No system board (design/system.html).");
|
|
458
639
|
const sources = detectDesignSources(cwd);
|
|
@@ -483,6 +664,12 @@ async function handoffTool(cwd: string, params: DesignToolParams): Promise<Desig
|
|
|
483
664
|
const resolved = resolveDesignTarget(cwd, params.target ?? "", "report on");
|
|
484
665
|
if (resolved.kind === "refuse") throw new Error(resolved.notice.message);
|
|
485
666
|
const { slug, artboard } = resolved;
|
|
667
|
+
if (params.part !== undefined) {
|
|
668
|
+
// A part on its own (canvas-implement-part S6): parts.json only, so no direction is chosen.
|
|
669
|
+
const part = await createDesignPartStore(join(cwd, "design")).setStatus(slug, artboard.file, params.part, status, { note: params.note }).catch((error: unknown) => { throw partsProblem(slug, error); });
|
|
670
|
+
const text = `Part ${part.id} of design/${slug}/${artboard.file} (${part.selector}): ${status === "in_progress" ? "in progress" : "implemented"}. No direction is chosen by it.`;
|
|
671
|
+
return { texts: [text], details: { target: `${slug}/${artboard.file}`, part } };
|
|
672
|
+
}
|
|
486
673
|
const store = createDesignHandoffStore(join(cwd, "design"));
|
|
487
674
|
const handoff = await store.setStatus(slug, artboard.file, status, { note: params.note, previewUrl: params.previewUrl }).catch((error: unknown) => { throw handoffsProblem(slug, error); });
|
|
488
675
|
const { chosen } = await store.read(slug).catch((error: unknown) => { throw handoffsProblem(slug, error); });
|
|
@@ -286,16 +286,50 @@ export const ENGRAM_COMPATIBILITY_MIN_VERSION = "3.4.0";
|
|
|
286
286
|
export function engramOutdatedServerNotice(version: string): string {
|
|
287
287
|
return `Engram memory disabled: the running Engram server reports version ${version}, which cannot prove store compatibility. Back up your Engram data, update that server to ${ENGRAM_COMPATIBILITY_MIN_VERSION} or later with the method you installed it with, and restart it; updating Shell alone does not replace a running server. Shell rechecks on every launch and remains usable without memory.`;
|
|
288
288
|
}
|
|
289
|
+
// A canonical numeric x.y.z (optionally v-prefixed, no leading zeros), split
|
|
290
|
+
// into numeric parts; undefined otherwise. The version comes from the server,
|
|
291
|
+
// so anything else is never echoed to the user.
|
|
292
|
+
function canonicalVersion(version: string | undefined): number[] | undefined {
|
|
293
|
+
const match = /^v?(0|[1-9]\d{0,3})\.(0|[1-9]\d{0,3})\.(0|[1-9]\d{0,3})$/.exec(version ?? "");
|
|
294
|
+
return match === null ? undefined : match.slice(1).map(Number);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// "older" or "same-or-newer" over canonical numeric parts, or undefined when
|
|
298
|
+
// the version itself is not canonical.
|
|
299
|
+
function compareVersion(version: string | undefined, minimum: string): "older" | "same-or-newer" | undefined {
|
|
300
|
+
const parts = canonicalVersion(version);
|
|
301
|
+
if (parts === undefined) return undefined;
|
|
302
|
+
const base = canonicalVersion(minimum);
|
|
303
|
+
if (base === undefined) return undefined;
|
|
304
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
305
|
+
if (parts[i] !== base[i]) return parts[i] < base[i] ? "older" : "same-or-newer";
|
|
306
|
+
}
|
|
307
|
+
return "same-or-newer";
|
|
308
|
+
}
|
|
309
|
+
|
|
289
310
|
// A canonical numeric x.y.z (optionally v-prefixed, no leading zeros) older than
|
|
290
311
|
// the minimum. The version comes from the server, so anything else is never
|
|
291
312
|
// echoed to the user.
|
|
292
313
|
function outdatedServerVersion(version: string | undefined): string | undefined {
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
314
|
+
const parts = canonicalVersion(version);
|
|
315
|
+
if (parts === undefined) return undefined;
|
|
316
|
+
return compareVersion(version, ENGRAM_COMPATIBILITY_MIN_VERSION) === "older" ? parts.join(".") : undefined;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// The first release whose CLI runs the shared server's whole lifecycle as a
|
|
320
|
+
// pidfile-tracked daemon (`engram run -d` plus the `ps`, `stop`, `logs`,
|
|
321
|
+
// `restart` verbs; engram issues #2228 and #2346): a core older than this
|
|
322
|
+
// knows only `serve`, which no daemon verb can adopt.
|
|
323
|
+
export const ENGRAM_DAEMON_LIFECYCLE_MIN_VERSION = "3.7.0";
|
|
324
|
+
export function engramSupportsDaemonLifecycle(version: string | undefined): boolean {
|
|
325
|
+
return compareVersion(version, ENGRAM_DAEMON_LIFECYCLE_MIN_VERSION) === "same-or-newer";
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// The command line Shell starts the shared server with: daemon-lifecycle cores
|
|
329
|
+
// register with `run -d` so the standard verbs manage the server; older cores
|
|
330
|
+
// spawn only the legacy detached `serve`.
|
|
331
|
+
export function engramSpawnArgs(version: string | undefined): string[] {
|
|
332
|
+
return engramSupportsDaemonLifecycle(version) ? ["run", "-d"] : ["serve"];
|
|
299
333
|
}
|
|
300
334
|
// The default endpoint gentle-engram uses without ENGRAM_URL or ENGRAM_PORT.
|
|
301
335
|
export const ENGRAM_DEFAULT_PORT = 7437;
|
|
@@ -410,14 +444,71 @@ export function parseEngramProvenance(text: string | undefined): EngramProvenanc
|
|
|
410
444
|
}
|
|
411
445
|
|
|
412
446
|
// The bundled core's own schema (SQLite user_version), verified from the
|
|
413
|
-
// tagged sources v3.3.2, v3.4.0
|
|
414
|
-
//
|
|
415
|
-
|
|
447
|
+
// tagged sources v3.3.2, v3.4.0, v3.5.2 and the v3.7.0 and v3.7.2 trees:
|
|
448
|
+
// internal/store/store.go `const schemaVersion = 1`, and the released 3.7.2
|
|
449
|
+
// linux/darwin binaries stamp user_version 1 in an isolated store. A pin
|
|
450
|
+
// without a verified entry leaves the header check unavailable.
|
|
451
|
+
const BUNDLED_ENGRAM_SCHEMA: Record<string, number> = { "3.3.2": 1, "3.4.0": 1, "3.5.2": 1, "3.7.0": 1, "3.7.2": 1 };
|
|
416
452
|
|
|
417
453
|
export function bundledEngramSchema(coreVersion: string): number | undefined {
|
|
418
454
|
return Object.hasOwn(BUNDLED_ENGRAM_SCHEMA, coreVersion) ? BUNDLED_ENGRAM_SCHEMA[coreVersion] : undefined;
|
|
419
455
|
}
|
|
420
456
|
|
|
457
|
+
// Companion-vs-core contract gate (gentle-shell#3015): the runtime-contract
|
|
458
|
+
// digest each pinned core answers on GET /runtime-contract, read from the real
|
|
459
|
+
// release binaries during development; the 3.5.2 windows archive sha256 matched
|
|
460
|
+
// the retired 3.5.2 pin exactly. gentle-engram 0.8.0 requires the 3.7.2 digest:
|
|
461
|
+
// the released 3.7.2 binary and the published 0.8.0 companion both report
|
|
462
|
+
// contract_id engram.pi-http-runtime/v1, revision 1, with the same digest, and
|
|
463
|
+
// only that digest differs from 3.5.2. A pin without a verified entry leaves
|
|
464
|
+
// the gate unavailable, and the gate only ever warns (S3: "Instalar y avisar
|
|
465
|
+
// fuerte"), never blocks.
|
|
466
|
+
const BUNDLED_ENGRAM_CONTRACT: Record<string, string> = {
|
|
467
|
+
"3.5.2": "4bf32703e111162b24073d090bec1c15c9120708587000bf595a07264e768672",
|
|
468
|
+
"3.7.0": "0af9af176928e98562ab1396d3196efe582dd5d1c5d2c5f8f546ab4ed609810f",
|
|
469
|
+
"3.7.2": "0af9af176928e98562ab1396d3196efe582dd5d1c5d2c5f8f546ab4ed609810f",
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
export function bundledEngramContract(coreVersion: string): string | undefined {
|
|
473
|
+
return Object.hasOwn(BUNDLED_ENGRAM_CONTRACT, coreVersion) ? BUNDLED_ENGRAM_CONTRACT[coreVersion] : undefined;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// The runtime contract a gentle-engram companion ships (runtime-contract.json)
|
|
477
|
+
// and the running core answers on GET /runtime-contract. Only the exact
|
|
478
|
+
// contract id, an integer revision and a lowercase 64-hex digest count as
|
|
479
|
+
// evidence; anything else is no signal, never an error.
|
|
480
|
+
export type ParsedEngramRuntimeContract = { contract_id: "engram.pi-http-runtime/v1"; revision: number; digest: string };
|
|
481
|
+
|
|
482
|
+
export function parseEngramRuntimeContract(payload: unknown): ParsedEngramRuntimeContract | undefined {
|
|
483
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return undefined;
|
|
484
|
+
const record = payload as Record<string, unknown>;
|
|
485
|
+
const revision = record.revision;
|
|
486
|
+
if (record.contract_id !== "engram.pi-http-runtime/v1" || typeof revision !== "number" || !Number.isInteger(revision)) return undefined;
|
|
487
|
+
if (typeof record.digest !== "string" || !/^[0-9a-f]{64}$/.test(record.digest)) return undefined;
|
|
488
|
+
return { contract_id: "engram.pi-http-runtime/v1", revision, digest: record.digest };
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// The loud, warn-only mismatch notice (S3): Shell still installs and runs the
|
|
492
|
+
// pair, and the human decides whether to update the core or the companion.
|
|
493
|
+
// Silent when the digests are equal or either side is unknown — never a false
|
|
494
|
+
// alarm. `coreDigest` lets the launch path pass the digest the running server
|
|
495
|
+
// actually answered; the default is the pinned core's verified table entry.
|
|
496
|
+
// `coreLabel` names whoever answered, so a reused older server is never
|
|
497
|
+
// misattributed to the pinned version.
|
|
498
|
+
export function engramContractMismatchNotice(companionDigest: string | undefined, coreVersion: string, coreDigest: string | undefined = bundledEngramContract(coreVersion), coreLabel: string = `the Engram core ${coreVersion}`): string | undefined {
|
|
499
|
+
if (companionDigest === undefined || coreDigest === undefined || !/^[0-9a-f]{64}$/.test(companionDigest) || companionDigest === coreDigest) return undefined;
|
|
500
|
+
return `Engram contract mismatch: the gentle-engram companion declares runtime-contract digest ${companionDigest}, while ${coreLabel} answers ${coreDigest}; memory may be unavailable until the pair matches. Update the core with a new Gentle Shell release, or update the companion.`;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// One bounded read-only GET /runtime-contract on the shared server (the same
|
|
504
|
+
// loopback rules as probeEngramEndpoint): the parsed digest, or undefined when
|
|
505
|
+
// the server does not answer with a well-formed contract.
|
|
506
|
+
export async function probeEngramRuntimeContract(input: { port?: number; timeoutMs?: number } = {}): Promise<string | undefined> {
|
|
507
|
+
const answer = await localGet(input.port ?? ENGRAM_DEFAULT_PORT, "/runtime-contract", input.timeoutMs ?? 1000);
|
|
508
|
+
if (answer.kind !== "response" || answer.status !== 200) return undefined;
|
|
509
|
+
return parseEngramRuntimeContract(parseJson(answer.body))?.digest;
|
|
510
|
+
}
|
|
511
|
+
|
|
421
512
|
// SQLite's user_version from the raw database header (bytes 60-63), or
|
|
422
513
|
// undefined for anything that is not a well-formed rollback or WAL database.
|
|
423
514
|
export function sqliteHeaderUserVersion(header: Uint8Array, size: number): number | undefined {
|