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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The files the design canvas serves from assets/design-canvas/ under
|
|
2
|
+
// `assets/<name>`, and the package check requires in the tarball. The list is
|
|
3
|
+
// explicit on purpose: it is a security boundary, and inspector.js is also
|
|
4
|
+
// loaded inside the artboard sandbox. index.html is the page template, read by
|
|
5
|
+
// the server and never served as an asset.
|
|
6
|
+
|
|
7
|
+
/** Canvas asset file name to the Content-Type it is served with. */
|
|
8
|
+
export const DESIGN_CANVAS_ASSETS: Readonly<Record<string, string>> = Object.freeze({
|
|
9
|
+
"canvas.js": "text/javascript; charset=utf-8",
|
|
10
|
+
"canvas-boot.js": "text/javascript; charset=utf-8",
|
|
11
|
+
"canvas-store.js": "text/javascript; charset=utf-8",
|
|
12
|
+
"canvas-api.js": "text/javascript; charset=utf-8",
|
|
13
|
+
"canvas-ui.js": "text/javascript; charset=utf-8",
|
|
14
|
+
"canvas-view.js": "text/javascript; charset=utf-8",
|
|
15
|
+
"canvas-focus.js": "text/javascript; charset=utf-8",
|
|
16
|
+
"canvas-boards.js": "text/javascript; charset=utf-8",
|
|
17
|
+
"canvas-handoffs.js": "text/javascript; charset=utf-8",
|
|
18
|
+
"canvas-compare.js": "text/javascript; charset=utf-8",
|
|
19
|
+
"canvas-events.js": "text/javascript; charset=utf-8",
|
|
20
|
+
"canvas-comments.js": "text/javascript; charset=utf-8",
|
|
21
|
+
"canvas-popover.js": "text/javascript; charset=utf-8",
|
|
22
|
+
"canvas-messages.js": "text/javascript; charset=utf-8",
|
|
23
|
+
"canvas-menu.js": "text/javascript; charset=utf-8",
|
|
24
|
+
"canvas-rail.js": "text/javascript; charset=utf-8",
|
|
25
|
+
"canvas-sizes.js": "text/javascript; charset=utf-8",
|
|
26
|
+
"canvas-layout.js": "text/javascript; charset=utf-8",
|
|
27
|
+
"canvas-minimap.js": "text/javascript; charset=utf-8",
|
|
28
|
+
"canvas-export.js": "text/javascript; charset=utf-8",
|
|
29
|
+
"canvas-parts.js": "text/javascript; charset=utf-8",
|
|
30
|
+
"canvas-tokens.js": "text/javascript; charset=utf-8",
|
|
31
|
+
"canvas-checks.js": "text/javascript; charset=utf-8",
|
|
32
|
+
"canvas-i18n.js": "text/javascript; charset=utf-8",
|
|
33
|
+
"canvas-i18n-es.js": "text/javascript; charset=utf-8",
|
|
34
|
+
"canvas.css": "text/css; charset=utf-8",
|
|
35
|
+
"inspector.js": "text/javascript; charset=utf-8",
|
|
36
|
+
});
|
|
@@ -5,8 +5,12 @@ import { open, readFile, realpath, stat } from "node:fs/promises";
|
|
|
5
5
|
import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
|
|
6
6
|
import { extname, isAbsolute, join, sep } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
import {
|
|
8
|
+
import { DESIGN_CANVAS_ASSETS } from "./design-canvas-assets.ts";
|
|
9
|
+
import { DESIGN_COMMENTS_FILE, DESIGN_COMMENT_LIMITS, DESIGN_SCREENSHOT_TYPES, DesignCommentsError, MAX_DESIGN_SCREENSHOT_BYTES, createDesignCommentStore, describeViewport, isDesignCommentId, truncateUtf16, viewportProblem, type DesignViewport, type StoredDesignComment } from "./design-comments.ts";
|
|
9
10
|
import { DESIGN_FEATURE_PATH, DesignHandoffsError, createDesignHandoffStore, sendDesignHandoff, type DesignHandoffDelivery } from "./design-handoffs.ts";
|
|
11
|
+
import { readSystemTokens } from "./design-system-tokens.ts";
|
|
12
|
+
import { DesignLayoutError, createDesignLayoutStore } from "./design-layout.ts";
|
|
13
|
+
import { DesignPartsError, createDesignPartStore, sendDesignPart, type DesignPart } from "./design-parts.ts";
|
|
10
14
|
|
|
11
15
|
// Loopback canvas host for gentle-design (S4-S6). Every route lives under a
|
|
12
16
|
// per-server random token, the Host header must name this server, POSTs need
|
|
@@ -15,14 +19,16 @@ import { DESIGN_FEATURE_PATH, DesignHandoffsError, createDesignHandoffStore, sen
|
|
|
15
19
|
const HOST = "127.0.0.1";
|
|
16
20
|
/** Design directory names the canvas serves: kebab-case, never a dot or path segment. */
|
|
17
21
|
export const DESIGN_SLUG = /^[a-z0-9][a-z0-9-]*$/;
|
|
22
|
+
|
|
23
|
+
/** One-line diagnostic naming why canvas change events cannot fire; surfaced per SSE stream (gentle-shell#3156). */
|
|
24
|
+
export function describeWatchFailure(error: unknown): string {
|
|
25
|
+
const code = (error as NodeJS.ErrnoException | undefined)?.code;
|
|
26
|
+
if (code === "ENOSPC") return "fs.watch failed: ENOSPC (inotify watch limit exhausted; check fs.inotify.max_user_watches)";
|
|
27
|
+
return `fs.watch failed: ${code ?? String(error)}`;
|
|
28
|
+
}
|
|
18
29
|
const SLUG = DESIGN_SLUG;
|
|
19
30
|
const TOKEN_SHAPE = /^[A-Za-z0-9_-]{16,128}$/;
|
|
20
31
|
const ASSET_DIR = fileURLToPath(new URL("../assets/design-canvas/", import.meta.url));
|
|
21
|
-
const ASSETS: Readonly<Record<string, string>> = Object.freeze({
|
|
22
|
-
"canvas.js": "text/javascript; charset=utf-8",
|
|
23
|
-
"canvas.css": "text/css; charset=utf-8",
|
|
24
|
-
"inspector.js": "text/javascript; charset=utf-8",
|
|
25
|
-
});
|
|
26
32
|
const FILE_TYPES: Readonly<Record<string, string>> = Object.freeze({
|
|
27
33
|
".html": "text/html; charset=utf-8",
|
|
28
34
|
".css": "text/css; charset=utf-8",
|
|
@@ -41,6 +47,8 @@ const LIMITS = Object.freeze({
|
|
|
41
47
|
bodyBytes: 16 * 1024,
|
|
42
48
|
/** POST api/comments may carry one base64 screenshot; its other fields keep `bodyBytes`. */
|
|
43
49
|
commentBodyBytes: 8 * 1024 * 1024,
|
|
50
|
+
/** POST api/designs/<slug>/layout: up to 100 positions keyed by artboard paths of up to 512 characters. */
|
|
51
|
+
layoutBodyBytes: 64 * 1024,
|
|
44
52
|
...DESIGN_COMMENT_LIMITS,
|
|
45
53
|
manifestBytes: 256 * 1024,
|
|
46
54
|
fileBytes: 32 * 1024 * 1024,
|
|
@@ -69,8 +77,9 @@ const CANVAS_CSP = [
|
|
|
69
77
|
"style-src 'self'",
|
|
70
78
|
"img-src 'self' data:",
|
|
71
79
|
"connect-src 'self'",
|
|
72
|
-
// Compare (S15) frames the running app next to its artboard: loopback origins only.
|
|
73
|
-
|
|
80
|
+
// Compare (S15) frames the running app next to its artboard: loopback origins only. No [::1]: CSP host sources
|
|
81
|
+
// have no IPv6 form, so browsers reject it (and log an error); Compare offers a new tab for such a preview.
|
|
82
|
+
`frame-src 'self' ${["http", "https"].flatMap((scheme) => ["localhost", "127.0.0.1"].map((host) => `${scheme}://${host}:*`)).join(" ")}`,
|
|
74
83
|
"base-uri 'none'",
|
|
75
84
|
"form-action 'none'",
|
|
76
85
|
"frame-ancestors 'none'",
|
|
@@ -83,7 +92,7 @@ const CANVAS_CSP = [
|
|
|
83
92
|
export type DesignCommentScreenshot = { path: string; mimeType: string; data?: string };
|
|
84
93
|
|
|
85
94
|
/** A comment as delivered to the session; `id` names it in design/<slug>/comments.json. */
|
|
86
|
-
export type DesignComment = { id: string; slug: string; file: string; selector: string; excerpt: string; comment: string; screenshot?: DesignCommentScreenshot };
|
|
95
|
+
export type DesignComment = { id: string; slug: string; file: string; selector: string; excerpt: string; comment: string; screenshot?: DesignCommentScreenshot; viewport?: DesignViewport; /** Set when the canvas edits a comment already sent (canvas-layout S17). */ edited?: { previous: string } };
|
|
87
96
|
|
|
88
97
|
/** Session message content: plain text, or text followed by the attached screenshots. */
|
|
89
98
|
export type DesignSessionContent = string | Array<{ type: "text"; text: string } | { type: "image"; data: string; mimeType: string }>;
|
|
@@ -104,6 +113,18 @@ export type DesignCanvasServerOptions = {
|
|
|
104
113
|
* takes the record back and answers 500.
|
|
105
114
|
*/
|
|
106
115
|
onImplement?: (request: DesignImplementRequest) => DesignHandoffDelivery | Promise<DesignHandoffDelivery>;
|
|
116
|
+
/**
|
|
117
|
+
* "Try another direction from this…": an artboard of the manifest and what should change, already
|
|
118
|
+
* validated. It answers whether the message was queued behind a busy agent; a throw answers 500.
|
|
119
|
+
* Nothing is recorded: the new artboard arrives through the manifest.
|
|
120
|
+
*/
|
|
121
|
+
onVariant?: (request: DesignVariantRequest) => DesignHandoffDelivery | Promise<DesignHandoffDelivery>;
|
|
122
|
+
/**
|
|
123
|
+
* "Implement only this": one element of an artboard of the manifest, already validated and recorded in
|
|
124
|
+
* parts.json (never handoffs.json, so no direction is chosen). It answers whether the message was queued
|
|
125
|
+
* behind a busy agent; a throw takes the part back and answers 500.
|
|
126
|
+
*/
|
|
127
|
+
onImplementPart?: (request: DesignImplementPartRequest) => DesignHandoffDelivery | Promise<DesignHandoffDelivery>;
|
|
107
128
|
initialSlug?: string;
|
|
108
129
|
randomToken?: () => string;
|
|
109
130
|
};
|
|
@@ -123,6 +144,14 @@ export type DesignArtboard = { file: string; title: string; tradeoff: string; wi
|
|
|
123
144
|
/** `feature` is present only when valid; `warnings` only when something in design.json was dropped. */
|
|
124
145
|
export type DesignManifest = { slug: string; title: string; brief: string; artboards: DesignArtboard[]; feature?: string; warnings?: string[] };
|
|
125
146
|
export type DesignImplementRequest = { slug: string; file: string };
|
|
147
|
+
/** `instruction` is trimmed, with LF line ends, 1 to `DESIGN_VARIANT_INSTRUCTION_MAX` characters. */
|
|
148
|
+
export type DesignVariantRequest = { slug: string; file: string; instruction: string };
|
|
149
|
+
|
|
150
|
+
/** The most characters one "another direction" instruction may have. */
|
|
151
|
+
export const DESIGN_VARIANT_INSTRUCTION_MAX = 2000;
|
|
152
|
+
|
|
153
|
+
/** One element of an artboard handed to the session on its own, as recorded in design/<slug>/parts.json. */
|
|
154
|
+
export type DesignImplementPartRequest = { slug: string; part: DesignPart };
|
|
126
155
|
|
|
127
156
|
export { DESIGN_FEATURE_PATH };
|
|
128
157
|
|
|
@@ -145,9 +174,32 @@ function storeFailure(error: unknown): never {
|
|
|
145
174
|
if (error.code === "invalid-file") throw new HttpError(422, "invalid-comments", { error: "invalid-comments", reason: error.message });
|
|
146
175
|
if (error.code === "limit") throw new HttpError(409, "too-many-comments", { error: "too-many-comments", reason: error.message });
|
|
147
176
|
if (error.code === "invalid-input") throw new HttpError(400, "invalid-comment", { error: "invalid-comment", reason: error.message });
|
|
177
|
+
if (error.code === "locked") throw new HttpError(409, "comment-resolved", { error: "comment-resolved", reason: error.message });
|
|
148
178
|
throw new HttpError(500, "internal");
|
|
149
179
|
}
|
|
150
180
|
|
|
181
|
+
/** parts.json failures as HTTP: a broken file is 422 and is never overwritten. */
|
|
182
|
+
function partFailure(error: unknown): never {
|
|
183
|
+
if (!(error instanceof DesignPartsError)) throw error;
|
|
184
|
+
if (error.code === "not-found") throw new HttpError(404, "not-found");
|
|
185
|
+
if (error.code === "invalid-file") throw new HttpError(422, "invalid-parts", { error: "invalid-parts", reason: error.message });
|
|
186
|
+
if (error.code === "limit") throw new HttpError(409, "too-many-parts", { error: "too-many-parts", reason: error.message });
|
|
187
|
+
if (error.code === "not-sent") throw new HttpError(409, "part-not-sent", { error: "part-not-sent", reason: error.message });
|
|
188
|
+
if (error.code === "too-large") throw new HttpError(409, "parts-too-large", { error: "parts-too-large", reason: error.message });
|
|
189
|
+
throw new HttpError(400, "invalid-part", { error: "invalid-part", reason: error.message });
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* layout.json failures as HTTP: an unknown design is 404, a layout.json that cannot be read or used 422 with its reason
|
|
194
|
+
* (never overwritten here; the canvas keeps the layout it shows), a refused layout 400 with its reason.
|
|
195
|
+
*/
|
|
196
|
+
function layoutFailure(error: unknown): never {
|
|
197
|
+
if (!(error instanceof DesignLayoutError)) throw error;
|
|
198
|
+
if (error.code === "not-found") throw new HttpError(404, "not-found");
|
|
199
|
+
if (error.code === "invalid-file") throw new HttpError(422, "unreadable-layout", { error: "unreadable-layout", reason: error.message });
|
|
200
|
+
throw new HttpError(400, "invalid-layout", { error: "invalid-layout", reason: error.message });
|
|
201
|
+
}
|
|
202
|
+
|
|
151
203
|
/** handoffs.json failures as HTTP: a broken file is 422 and is never overwritten. */
|
|
152
204
|
function handoffFailure(error: unknown): never {
|
|
153
205
|
if (!(error instanceof DesignHandoffsError)) throw error;
|
|
@@ -159,13 +211,18 @@ function handoffFailure(error: unknown): never {
|
|
|
159
211
|
|
|
160
212
|
function resolveInstruction(slug: string, ids: readonly string[]): string {
|
|
161
213
|
const list = ids.map((id) => JSON.stringify(id)).join(", ");
|
|
162
|
-
return `mark it resolved with the gentle_design_comments tool (action "resolve", slug "${slug}", ids [${list}]), or set its status to "resolved" in design/${slug}/${DESIGN_COMMENTS_FILE}.`;
|
|
214
|
+
return `mark it resolved with the gentle_design_comments tool (action "resolve", slug "${slug}", ids [${list}], note "<one line on what you changed>"), or set its status to "resolved" in design/${slug}/${DESIGN_COMMENTS_FILE}.`;
|
|
163
215
|
}
|
|
164
216
|
|
|
165
217
|
function excerptLine(excerpt: string): string {
|
|
166
218
|
return `Excerpt: ${excerpt ? JSON.stringify(excerpt) : "(none)"}`;
|
|
167
219
|
}
|
|
168
220
|
|
|
221
|
+
/** The size the comment was made at, so the agent edits for that width (S7). */
|
|
222
|
+
function viewportLine(viewport: DesignViewport): string {
|
|
223
|
+
return `Viewport: ${describeViewport(viewport)} (the comment was made at this size; make the change hold at this width)`;
|
|
224
|
+
}
|
|
225
|
+
|
|
169
226
|
function screenshotLine(screenshot: DesignCommentScreenshot, attached: boolean): string {
|
|
170
227
|
return `Screenshot: ${screenshot.path} (${attached ? "attached; open it with the read tool if you cannot see it" : "open it with the read tool"})`;
|
|
171
228
|
}
|
|
@@ -194,17 +251,19 @@ export function designCommentBatchContent(batch: readonly DesignComment[]): Desi
|
|
|
194
251
|
export function formatDesignComment(comment: DesignComment): string {
|
|
195
252
|
const artboard = `design/${comment.slug}/${comment.file}`;
|
|
196
253
|
return [
|
|
197
|
-
`Design comment for ${artboard}`,
|
|
254
|
+
`Design comment${comment.edited ? " edited" : ""} for ${artboard}`,
|
|
198
255
|
"",
|
|
199
256
|
`Design: ${comment.slug}`,
|
|
200
257
|
`Artboard: ${artboard}`,
|
|
201
258
|
`Comment id: ${comment.id}`,
|
|
202
259
|
`Element: ${comment.selector}`,
|
|
203
260
|
excerptLine(comment.excerpt),
|
|
261
|
+
...(comment.viewport ? [viewportLine(comment.viewport)] : []),
|
|
204
262
|
...(comment.screenshot ? [screenshotLine(comment.screenshot, comment.screenshot.data !== undefined)] : []),
|
|
205
263
|
"",
|
|
206
|
-
"Comment:",
|
|
264
|
+
comment.edited ? "Comment (edited; it replaces the text you received earlier for this id):" : "Comment:",
|
|
207
265
|
comment.comment,
|
|
266
|
+
...(comment.edited ? ["", "Previous text:", comment.edited.previous] : []),
|
|
208
267
|
"",
|
|
209
268
|
`Edit only the artboard ${artboard}, following the gentle-design skill.`,
|
|
210
269
|
`When it is applied, ${resolveInstruction(comment.slug, [comment.id])}`,
|
|
@@ -222,6 +281,7 @@ export function formatDesignCommentBatch(batch: readonly DesignComment[]): strin
|
|
|
222
281
|
` Artboard: design/${comment.slug}/${comment.file}`,
|
|
223
282
|
` Element: ${comment.selector}`,
|
|
224
283
|
` ${excerptLine(comment.excerpt)}`,
|
|
284
|
+
...(comment.viewport ? [` ${viewportLine(comment.viewport)}`] : []),
|
|
225
285
|
...(comment.screenshot ? [` ${screenshotLine(comment.screenshot, attached.has(comment))}`] : []),
|
|
226
286
|
" Comment:",
|
|
227
287
|
...comment.comment.split("\n").map((line) => ` ${line}`),
|
|
@@ -329,7 +389,18 @@ function scriptJson(value: unknown): string {
|
|
|
329
389
|
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
330
390
|
}
|
|
331
391
|
|
|
332
|
-
|
|
392
|
+
/**
|
|
393
|
+
* The inspector tag the server injects into every artboard served under `base`. canvas-export.js builds the
|
|
394
|
+
* same tag (same escaping) to remove it again for Download HTML; its tests serve artboards through injectInspector,
|
|
395
|
+
* so a change here fails them.
|
|
396
|
+
*/
|
|
397
|
+
function inspectorTag(base: string): string {
|
|
398
|
+
return `<script src="${escapeHtml(base)}assets/inspector.js"></script>`;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** The artboard HTML as served: the inspector tag before the last `</body>`, or at the end without one. */
|
|
402
|
+
export function injectInspector(html: string, base: string): string {
|
|
403
|
+
const tag = inspectorTag(base);
|
|
333
404
|
const index = html.toLowerCase().lastIndexOf("</body>");
|
|
334
405
|
return index === -1 ? html + tag : html.slice(0, index) + tag + html.slice(index);
|
|
335
406
|
}
|
|
@@ -462,8 +533,12 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
462
533
|
const designRoot = options.designRoot;
|
|
463
534
|
const store = createDesignCommentStore(designRoot);
|
|
464
535
|
const handoffs = createDesignHandoffStore(designRoot);
|
|
536
|
+
const partStore = createDesignPartStore(designRoot);
|
|
537
|
+
const layouts = createDesignLayoutStore(designRoot);
|
|
465
538
|
// Deliveries of one design run one at a time (send-now and send-all), so a
|
|
466
539
|
// comment is never delivered twice: a send-all waits for an in-flight send-now.
|
|
540
|
+
// An implement-part delivery and a parts/remove share it, so a Remove never
|
|
541
|
+
// takes out a part whose message is still on its way to the session.
|
|
467
542
|
const sending = new Map<string, Promise<unknown>>();
|
|
468
543
|
|
|
469
544
|
function exclusive<T>(slug: string, task: () => Promise<T>): Promise<T> {
|
|
@@ -483,6 +558,7 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
483
558
|
let ownOrigins = new Set<string>();
|
|
484
559
|
let closing: Promise<void> | undefined;
|
|
485
560
|
let watcher: FSWatcher | undefined;
|
|
561
|
+
let watchFailure: string | undefined;
|
|
486
562
|
const clients = new Set<ServerResponse>();
|
|
487
563
|
const pending = new Map<string, NodeJS.Timeout>();
|
|
488
564
|
let heartbeat: NodeJS.Timeout | undefined;
|
|
@@ -557,13 +633,13 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
557
633
|
function canvasPage(res: ServerResponse, slug: string | null): void {
|
|
558
634
|
const html = template
|
|
559
635
|
.replaceAll("{{BASE}}", escapeHtml(base))
|
|
560
|
-
.replace("{{CONFIG}}", () => scriptJson({ base, slug }));
|
|
636
|
+
.replace("{{CONFIG}}", () => scriptJson({ base, slug, delivery: { comment: true, batch: Boolean(options.onComments), implement: Boolean(options.onImplement), variant: Boolean(options.onVariant), part: Boolean(options.onImplementPart) } }));
|
|
561
637
|
reply(res, 200, html, { "Content-Type": "text/html; charset=utf-8", "Content-Security-Policy": CANVAS_CSP });
|
|
562
638
|
}
|
|
563
639
|
|
|
564
640
|
async function serveAsset(res: ServerResponse, name: string | null): Promise<void> {
|
|
565
|
-
if (!name || !Object.hasOwn(
|
|
566
|
-
raw(res, await readFile(join(ASSET_DIR, name)), { "Content-Type":
|
|
641
|
+
if (!name || !Object.hasOwn(DESIGN_CANVAS_ASSETS, name)) throw new HttpError(404, "not-found");
|
|
642
|
+
raw(res, await readFile(join(ASSET_DIR, name)), { "Content-Type": DESIGN_CANVAS_ASSETS[name] });
|
|
567
643
|
}
|
|
568
644
|
|
|
569
645
|
/** Artboard responses are CSP-sandboxed so even a top-level visit gets an opaque origin. */
|
|
@@ -607,7 +683,7 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
607
683
|
await handle.close();
|
|
608
684
|
}
|
|
609
685
|
const body = type.startsWith("text/html")
|
|
610
|
-
? injectInspector(content.toString("utf8"),
|
|
686
|
+
? injectInspector(content.toString("utf8"), base)
|
|
611
687
|
: content;
|
|
612
688
|
raw(res, body, { "Content-Type": type, "Content-Security-Policy": artboardCsp(String(req.headers.host)) });
|
|
613
689
|
}
|
|
@@ -628,6 +704,7 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
628
704
|
/** The stored comment as a session comment of design `slug`, with its screenshot loaded when it has one. */
|
|
629
705
|
async function toDesignComment(slug: string, stored: StoredDesignComment): Promise<DesignComment> {
|
|
630
706
|
const comment: DesignComment = { id: stored.id, slug, file: stored.file, selector: stored.selector, excerpt: stored.excerpt, comment: stored.comment };
|
|
707
|
+
if (stored.viewport) comment.viewport = stored.viewport;
|
|
631
708
|
if (stored.screenshot) {
|
|
632
709
|
const image = await store.readScreenshot(slug, stored.id).catch(() => undefined);
|
|
633
710
|
const ext = extname(stored.screenshot).toLowerCase();
|
|
@@ -650,6 +727,15 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
650
727
|
return { mimeType, data: bytes };
|
|
651
728
|
}
|
|
652
729
|
|
|
730
|
+
/** The optional `viewport: { width, height }` of a comment body: whole px within the stored limits. */
|
|
731
|
+
function parseViewport(value: unknown): DesignViewport | undefined {
|
|
732
|
+
if (value === undefined) return undefined;
|
|
733
|
+
const problem = viewportProblem(value);
|
|
734
|
+
if (problem) throw new HttpError(400, "invalid-viewport", { error: "invalid-viewport", reason: problem });
|
|
735
|
+
const { width, height } = value as DesignViewport;
|
|
736
|
+
return { width, height };
|
|
737
|
+
}
|
|
738
|
+
|
|
653
739
|
async function receiveComment(req: IncomingMessage, res: ServerResponse): Promise<void> {
|
|
654
740
|
const body = await readJsonObject(req, false, LIMITS.commentBodyBytes);
|
|
655
741
|
// Only the screenshot gets the larger allowance; the rest of the body keeps the usual limit.
|
|
@@ -673,7 +759,8 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
673
759
|
if (!target || !info?.isFile() || extname(target).toLowerCase() !== ".html") throw new HttpError(400, "invalid-file");
|
|
674
760
|
const slug = body.slug;
|
|
675
761
|
const screenshot = parseScreenshot(body.screenshot);
|
|
676
|
-
const
|
|
762
|
+
const viewport = parseViewport(body.viewport);
|
|
763
|
+
const input = { file: segments.join("/"), selector, excerpt, comment, ...(screenshot ? { screenshot } : {}), ...(viewport ? { viewport } : {}) };
|
|
677
764
|
const add = () => store.add(slug, input).catch((error: unknown) => {
|
|
678
765
|
if (screenshot && error instanceof DesignCommentsError && error.code === "invalid-input") throw new HttpError(400, "invalid-screenshot", { error: "invalid-screenshot", reason: error.message });
|
|
679
766
|
return storeFailure(error);
|
|
@@ -738,6 +825,81 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
738
825
|
reply(res, 202, { ok: true, slug, file, queued });
|
|
739
826
|
}
|
|
740
827
|
|
|
828
|
+
async function variant(req: IncomingMessage, res: ServerResponse, slug: string): Promise<void> {
|
|
829
|
+
const body = await readJsonObject(req);
|
|
830
|
+
const onVariant = options.onVariant;
|
|
831
|
+
if (!onVariant) throw new HttpError(501, "variant-unavailable");
|
|
832
|
+
const segments = relativeSegments(body.file);
|
|
833
|
+
if (!segments) throw new HttpError(400, "invalid-file");
|
|
834
|
+
const file = segments.join("/");
|
|
835
|
+
const manifest = await readManifest(slug);
|
|
836
|
+
if (!manifest.artboards.some((artboard) => artboard.file === file)) throw new HttpError(400, "invalid-file", { error: "invalid-file", reason: `${file} is not an artboard of design/${slug}` });
|
|
837
|
+
const instruction = typeof body.instruction === "string" ? body.instruction.replace(/\r\n?/g, "\n").trim() : "";
|
|
838
|
+
if (instruction.length < 1 || instruction.length > DESIGN_VARIANT_INSTRUCTION_MAX) {
|
|
839
|
+
throw new HttpError(400, "invalid-instruction", { error: "invalid-instruction", reason: `instruction must have 1 to ${DESIGN_VARIANT_INSTRUCTION_MAX} characters` });
|
|
840
|
+
}
|
|
841
|
+
let delivery: DesignHandoffDelivery;
|
|
842
|
+
try {
|
|
843
|
+
delivery = await onVariant({ slug, file, instruction });
|
|
844
|
+
} catch (error) {
|
|
845
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
846
|
+
throw new HttpError(500, "delivery-failed", { error: "delivery-failed", slug, file, reason });
|
|
847
|
+
}
|
|
848
|
+
reply(res, 202, { ok: true, slug, file, queued: typeof delivery === "object" && delivery !== null && delivery.queued === true });
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* "Implement only this" (canvas-implement-part S4): one element of an artboard of the manifest (a selector of
|
|
853
|
+
* 1 to 500 characters, the excerpt cut to 300, a note of at most 2000), recorded in parts.json before delivery and taken back when the delivery fails.
|
|
854
|
+
*/
|
|
855
|
+
async function implementPart(req: IncomingMessage, res: ServerResponse, slug: string): Promise<void> {
|
|
856
|
+
const body = await readJsonObject(req);
|
|
857
|
+
const onImplementPart = options.onImplementPart;
|
|
858
|
+
if (!onImplementPart) throw new HttpError(501, "implement-part-unavailable");
|
|
859
|
+
const manifest = await readManifest(slug);
|
|
860
|
+
const segments = relativeSegments(body.file);
|
|
861
|
+
const file = segments ? segments.join("/") : "";
|
|
862
|
+
if (!manifest.artboards.some((artboard) => artboard.file === file)) throw new HttpError(400, "invalid-file", { error: "invalid-file", reason: `${file || String(body.file)} is not an artboard of design/${slug}` });
|
|
863
|
+
const selector = typeof body.selector === "string" ? collapse(body.selector) : "";
|
|
864
|
+
if (selector.length < 1 || selector.length > LIMITS.selector) throw new HttpError(400, "invalid-selector", { error: "invalid-selector", reason: `selector must have 1 to ${LIMITS.selector} characters` });
|
|
865
|
+
if (body.excerpt !== undefined && typeof body.excerpt !== "string") throw new HttpError(400, "invalid-excerpt", { error: "invalid-excerpt", reason: "excerpt must be text" });
|
|
866
|
+
if (body.note !== undefined && typeof body.note !== "string") throw new HttpError(400, "invalid-note", { error: "invalid-note", reason: "note must be text" });
|
|
867
|
+
const note = typeof body.note === "string" ? body.note.replace(/\r\n?/g, "\n").trim() : "";
|
|
868
|
+
if (note.length > LIMITS.comment) throw new HttpError(400, "invalid-note", { error: "invalid-note", reason: `note must have at most ${LIMITS.comment} characters` });
|
|
869
|
+
const excerpt = typeof body.excerpt === "string" ? body.excerpt : "";
|
|
870
|
+
let deliveryFailed: HttpError | undefined;
|
|
871
|
+
// Record, deliver and settle under the design's delivery lock, so a parts/remove waits for the delivery in flight.
|
|
872
|
+
const { part, queued } = await exclusive(slug, () => sendDesignPart(partStore, slug, { file, selector, excerpt, instruction: note }, async (recorded) => {
|
|
873
|
+
try {
|
|
874
|
+
return await onImplementPart({ slug, part: recorded });
|
|
875
|
+
} catch (error) {
|
|
876
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
877
|
+
deliveryFailed = new HttpError(500, "delivery-failed", { error: "delivery-failed", slug, file, reason });
|
|
878
|
+
throw deliveryFailed;
|
|
879
|
+
}
|
|
880
|
+
})).catch((error: unknown) => (deliveryFailed !== undefined && error === deliveryFailed ? Promise.reject(error) : partFailure(error)));
|
|
881
|
+
reply(res, 202, { ok: true, id: part.id, queued });
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* "Remove" (canvas-server-data S2): takes a part still `sent` out of parts.json through the store's serialized writer,
|
|
886
|
+
* so a part the agent never reports can be cleared. Anything else is refused without writing; handoffs.json is never touched.
|
|
887
|
+
* It runs under the design's delivery lock (S10): a Remove that lands while a part is being delivered waits for that
|
|
888
|
+
* delivery to settle, then removes the delivered part or finds the failed one already taken back.
|
|
889
|
+
*/
|
|
890
|
+
async function removePart(req: IncomingMessage, res: ServerResponse, slug: string): Promise<void> {
|
|
891
|
+
const body = await readJsonObject(req);
|
|
892
|
+
const removed = await exclusive(slug, () => partStore.removeSent(slug, typeof body.id === "string" ? body.id : "")).catch(partFailure);
|
|
893
|
+
reply(res, 200, { ok: true, id: removed.id });
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** canvas-layout S3: the canvas saves where its artboards sit, validated whole before layout.json is replaced. */
|
|
897
|
+
async function saveLayout(req: IncomingMessage, res: ServerResponse, slug: string): Promise<void> {
|
|
898
|
+
const body = await readJsonObject(req, false, LIMITS.layoutBodyBytes);
|
|
899
|
+
const layout = await layouts.write(slug, body).catch(layoutFailure);
|
|
900
|
+
reply(res, 200, { ok: true, layout });
|
|
901
|
+
}
|
|
902
|
+
|
|
741
903
|
async function serveScreenshot(res: ServerResponse, slug: string, id: string): Promise<void> {
|
|
742
904
|
const image = await store.readScreenshot(slug, id).catch(storeFailure);
|
|
743
905
|
if (!image) throw new HttpError(404, "not-found");
|
|
@@ -752,6 +914,25 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
752
914
|
reply(res, 200, { ok: true, comment: updated[0] });
|
|
753
915
|
}
|
|
754
916
|
|
|
917
|
+
async function changeText(req: IncomingMessage, res: ServerResponse, slug: string, id: string): Promise<void> {
|
|
918
|
+
const body = await readJsonObject(req);
|
|
919
|
+
if (typeof body.comment !== "string") throw new HttpError(400, "invalid-comment");
|
|
920
|
+
const comment = body.comment.replace(/\r\n?/g, "\n").trim();
|
|
921
|
+
if (comment.length < 1 || comment.length > LIMITS.comment) throw new HttpError(400, "invalid-comment");
|
|
922
|
+
// Inside the delivery lock, so an edit never lands between a send-all's read and its markSent.
|
|
923
|
+
return exclusive(slug, async () => {
|
|
924
|
+
const { comment: updated, previous } = await store.setText(slug, id, comment).catch(storeFailure);
|
|
925
|
+
// The session already has a sent comment's old text: a changed one goes to it as an edit.
|
|
926
|
+
if (updated.sentAt === null || previous === updated.comment) return reply(res, 200, { ok: true, comment: updated, sent: false });
|
|
927
|
+
try {
|
|
928
|
+
await options.onComment({ ...(await toDesignComment(slug, updated)), edited: { previous } });
|
|
929
|
+
} catch {
|
|
930
|
+
throw new HttpError(500, "edit-not-delivered", { error: "edit-not-delivered", id, saved: true, sent: false });
|
|
931
|
+
}
|
|
932
|
+
reply(res, 200, { ok: true, comment: updated, sent: true });
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
|
|
755
936
|
function broadcast(chunk: string): void {
|
|
756
937
|
for (const client of clients) client.write(chunk);
|
|
757
938
|
}
|
|
@@ -784,12 +965,14 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
784
965
|
const next = watch(root, { recursive: true, persistent: false }, (_event, filename) => {
|
|
785
966
|
if (typeof filename === "string" && filename) queueChange(filename);
|
|
786
967
|
});
|
|
787
|
-
next.on("error", () => {
|
|
968
|
+
next.on("error", (error) => {
|
|
969
|
+
watchFailure = describeWatchFailure(error);
|
|
788
970
|
next.close();
|
|
789
971
|
if (watcher === next) watcher = undefined;
|
|
790
972
|
});
|
|
791
973
|
watcher = next;
|
|
792
|
-
} catch {
|
|
974
|
+
} catch (error) {
|
|
975
|
+
watchFailure = describeWatchFailure(error);
|
|
793
976
|
watcher = undefined;
|
|
794
977
|
}
|
|
795
978
|
}
|
|
@@ -799,6 +982,7 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
799
982
|
await ensureWatcher();
|
|
800
983
|
res.writeHead(200, { ...BASE_HEADERS, "Content-Type": "text/event-stream; charset=utf-8", Connection: "keep-alive" });
|
|
801
984
|
res.write("retry: 2000\n\n: connected\n\n");
|
|
985
|
+
if (watchFailure) res.write(`: watch-failed: ${watchFailure}\n\n`);
|
|
802
986
|
clients.add(res);
|
|
803
987
|
req.socket.setTimeout(0);
|
|
804
988
|
const drop = () => clients.delete(res);
|
|
@@ -820,11 +1004,11 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
820
1004
|
const rest = parts.slice(2);
|
|
821
1005
|
const method = req.method ?? "GET";
|
|
822
1006
|
const post = postRoute(rest);
|
|
823
|
-
const get =
|
|
1007
|
+
const get = route(rest);
|
|
824
1008
|
// Unknown paths stay 404 whatever the method; only known routes answer 405.
|
|
825
1009
|
if (!post && !get) return reply(res, 404, { error: "not-found" });
|
|
826
|
-
if (method
|
|
827
|
-
if (post) {
|
|
1010
|
+
if (!(method === "POST" && post) && !(method === "GET" && get)) return reply(res, 405, { error: "method-not-allowed" }, { Allow: [get ? "GET" : "", post ? "POST" : ""].filter(Boolean).join(", ") });
|
|
1011
|
+
if (method === "POST" && post) {
|
|
828
1012
|
// Every write needs this server's exact Origin and a JSON body, so no other page can forge one.
|
|
829
1013
|
if (!ownOrigins.has(String(req.headers.origin))) return reply(res, 403, { error: "forbidden" });
|
|
830
1014
|
if (mediaType(req) !== "application/json") return reply(res, 415, { error: "unsupported-media-type" });
|
|
@@ -848,6 +1032,22 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
848
1032
|
const slug = safeSegment(rest[2]);
|
|
849
1033
|
return slug && SLUG.test(slug) ? (req, res) => implement(req, res, slug) : undefined;
|
|
850
1034
|
}
|
|
1035
|
+
if (rest.length === 4 && rest[0] === "api" && rest[1] === "designs" && rest[3] === "variant") {
|
|
1036
|
+
const slug = safeSegment(rest[2]);
|
|
1037
|
+
return slug && SLUG.test(slug) ? (req, res) => variant(req, res, slug) : undefined;
|
|
1038
|
+
}
|
|
1039
|
+
if (rest.length === 4 && rest[0] === "api" && rest[1] === "designs" && rest[3] === "implement-part") {
|
|
1040
|
+
const slug = safeSegment(rest[2]);
|
|
1041
|
+
return slug && SLUG.test(slug) ? (req, res) => implementPart(req, res, slug) : undefined;
|
|
1042
|
+
}
|
|
1043
|
+
if (rest.length === 5 && rest[0] === "api" && rest[1] === "designs" && rest[3] === "parts" && rest[4] === "remove") {
|
|
1044
|
+
const slug = safeSegment(rest[2]);
|
|
1045
|
+
return slug && SLUG.test(slug) ? (req, res) => removePart(req, res, slug) : undefined;
|
|
1046
|
+
}
|
|
1047
|
+
if (rest.length === 4 && rest[0] === "api" && rest[1] === "designs" && rest[3] === "layout") {
|
|
1048
|
+
const slug = safeSegment(rest[2]);
|
|
1049
|
+
return slug && SLUG.test(slug) ? (req, res) => saveLayout(req, res, slug) : undefined;
|
|
1050
|
+
}
|
|
851
1051
|
if (rest.length < 5 || rest[0] !== "api" || rest[1] !== "designs" || rest[3] !== "comments") return undefined;
|
|
852
1052
|
const slug = safeSegment(rest[2]);
|
|
853
1053
|
if (!slug || !SLUG.test(slug)) return undefined;
|
|
@@ -856,6 +1056,10 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
856
1056
|
const id = safeSegment(rest[4]);
|
|
857
1057
|
return id && isDesignCommentId(id) ? (req, res) => changeStatus(req, res, slug, id) : undefined;
|
|
858
1058
|
}
|
|
1059
|
+
if (rest.length === 6 && rest[5] === "text") {
|
|
1060
|
+
const id = safeSegment(rest[4]);
|
|
1061
|
+
return id && isDesignCommentId(id) ? (req, res) => changeText(req, res, slug, id) : undefined;
|
|
1062
|
+
}
|
|
859
1063
|
return undefined;
|
|
860
1064
|
}
|
|
861
1065
|
|
|
@@ -873,6 +1077,10 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
873
1077
|
if (head === "api" && tail.length === 1 && tail[0] === "system") {
|
|
874
1078
|
return async (_req, res) => reply(res, 200, { exists: (await resolveSystem()) !== undefined, file: SYSTEM_FILE, ...SYSTEM_BOARD });
|
|
875
1079
|
}
|
|
1080
|
+
if (head === "api" && tail.length === 2 && tail[0] === "system" && tail[1] === "tokens") {
|
|
1081
|
+
// The inspector's tokens: design/system.md read-only, per request; it never fails the canvas.
|
|
1082
|
+
return async (_req, res) => reply(res, 200, await readSystemTokens(designRoot));
|
|
1083
|
+
}
|
|
876
1084
|
if (head === "api" && tail[0] === "designs") {
|
|
877
1085
|
if (tail.length === 1) return async (_req, res) => reply(res, 200, { designs: listDesignEntries(designRoot) });
|
|
878
1086
|
if (tail.length === 2) {
|
|
@@ -892,6 +1100,16 @@ export async function startDesignCanvasServer(options: DesignCanvasServerOptions
|
|
|
892
1100
|
const slug = safeSegment(tail[1]);
|
|
893
1101
|
return slug && SLUG.test(slug) ? async (_req, res) => reply(res, 200, await handoffs.read(slug).catch(handoffFailure)) : undefined;
|
|
894
1102
|
}
|
|
1103
|
+
if (tail.length === 3 && tail[2] === "parts") {
|
|
1104
|
+
const slug = safeSegment(tail[1]);
|
|
1105
|
+
return slug && SLUG.test(slug) ? async (_req, res) => reply(res, 200, await partStore.read(slug).catch(partFailure)) : undefined;
|
|
1106
|
+
}
|
|
1107
|
+
if (tail.length === 3 && tail[2] === "layout") {
|
|
1108
|
+
// A missing layout.json is `layout: null` (the canvas lays the artboards out in a row); one that cannot be read
|
|
1109
|
+
// or holds no valid layout is a 422 with the reason (canvas-layout S17), so a disk error never resets a layout.
|
|
1110
|
+
const slug = safeSegment(tail[1]);
|
|
1111
|
+
return slug && SLUG.test(slug) ? async (_req, res) => reply(res, 200, { layout: await layouts.load(slug).catch(layoutFailure) }) : undefined;
|
|
1112
|
+
}
|
|
895
1113
|
}
|
|
896
1114
|
if (head === "files" && tail.length >= 2) {
|
|
897
1115
|
const slug = safeSegment(tail[0]);
|