@dexhq/canvas 0.16.0 → 0.17.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/CHANGELOG.md +58 -0
- package/README.md +4 -4
- package/app/app.tsx +21 -3
- package/app/base.ts +8 -3
- package/app/canvas/activity-bar.tsx +34 -14
- package/app/canvas/activity-model.ts +112 -53
- package/app/canvas/activity-parts.tsx +30 -8
- package/app/canvas/activity.tsx +153 -35
- package/app/canvas/add-to-spec.ts +14 -5
- package/app/canvas/agent-changes.ts +59 -4
- package/app/canvas/anchoring.ts +165 -49
- package/app/canvas/canvas-chrome.tsx +44 -13
- package/app/canvas/canvas-clipboard.ts +38 -8
- package/app/canvas/canvas-commands.ts +191 -20
- package/app/canvas/canvas-context-menu.tsx +3 -0
- package/app/canvas/canvas-context.tsx +17 -2
- package/app/canvas/canvas-corners.tsx +2 -0
- package/app/canvas/canvas-document.ts +140 -23
- package/app/canvas/canvas-input.ts +277 -36
- package/app/canvas/canvas-keys.ts +165 -68
- package/app/canvas/canvas-menus.tsx +29 -5
- package/app/canvas/canvas-merge.ts +141 -29
- package/app/canvas/canvas-model.ts +253 -213
- package/app/canvas/canvas-panels.ts +10 -0
- package/app/canvas/canvas-scene.ts +526 -96
- package/app/canvas/canvas-ui.ts +68 -6
- package/app/canvas/canvas.css +398 -31
- package/app/canvas/change-notice.tsx +16 -7
- package/app/canvas/command-menu.tsx +12 -0
- package/app/canvas/comment-layer.tsx +79 -120
- package/app/canvas/comments.tsx +331 -127
- package/app/canvas/device-edits.ts +19 -2
- package/app/canvas/device-icons.ts +1 -0
- package/app/canvas/device-picker.tsx +5 -2
- package/app/canvas/devices-panel.tsx +14 -8
- package/app/canvas/draw-layer.tsx +49 -10
- package/app/canvas/draw-model.ts +15 -12
- package/app/canvas/editable-text.tsx +36 -15
- package/app/canvas/element-link.ts +25 -6
- package/app/canvas/element-picker.ts +103 -481
- package/app/canvas/engine/camera.ts +24 -3
- package/app/canvas/engine/canvas-gestures.ts +223 -53
- package/app/canvas/engine/canvas-store.ts +36 -0
- package/app/canvas/engine/canvas-view.tsx +39 -3
- package/app/canvas/export-dialog.tsx +17 -3
- package/app/canvas/find-bar.tsx +114 -16
- package/app/canvas/find-model.ts +20 -4
- package/app/canvas/floating-panel.tsx +16 -0
- package/app/canvas/flow-canvas.tsx +341 -99
- package/app/canvas/flow-renames.ts +9 -0
- package/app/canvas/follow-pin.ts +11 -0
- package/app/canvas/forced-states.ts +25 -4
- package/app/canvas/frame-choices.tsx +4 -0
- package/app/canvas/frame-code.ts +139 -0
- package/app/canvas/frame-context-menu.tsx +267 -31
- package/app/canvas/frame-copies.ts +100 -29
- package/app/canvas/frame-drops.ts +56 -7
- package/app/canvas/frame-inspector.ts +154 -0
- package/app/canvas/frame-node.tsx +297 -69
- package/app/canvas/frame-pictures.ts +96 -13
- package/app/canvas/frame-resize.tsx +17 -0
- package/app/canvas/frame-shown.ts +5 -0
- package/app/canvas/frame-source.ts +19 -2
- package/app/canvas/frame-thumb.tsx +5 -4
- package/app/canvas/grid-overlay.tsx +4 -3
- package/app/canvas/grid-panel.tsx +24 -10
- package/app/canvas/imported-reviews.tsx +105 -41
- package/app/canvas/insert-hint.tsx +26 -0
- package/app/canvas/inspect-layer.tsx +85 -26
- package/app/canvas/inspect-tools.ts +15 -4
- package/app/canvas/jpeg-pdf.ts +30 -3
- package/app/canvas/label-action.tsx +2 -1
- package/app/canvas/large-canvas-notice.tsx +7 -1
- package/app/canvas/layout.ts +699 -306
- package/app/canvas/linked-element.tsx +24 -1
- package/app/canvas/live-page.ts +226 -29
- package/app/canvas/measure-box.tsx +1 -0
- package/app/canvas/mentions.tsx +12 -0
- package/app/canvas/new-frame.ts +73 -11
- package/app/canvas/note-placing.ts +187 -31
- package/app/canvas/number-field.tsx +3 -0
- package/app/canvas/open-page.ts +8 -1
- package/app/canvas/others-hidden.ts +140 -0
- package/app/canvas/page-find.ts +47 -5
- package/app/canvas/page-heights.tsx +21 -0
- package/app/canvas/page-scroll.ts +22 -4
- package/app/canvas/page-style.ts +3 -1
- package/app/canvas/pass-to-canvas.ts +81 -0
- package/app/canvas/pasted-cuts.ts +2 -0
- package/app/canvas/person-busy.ts +3 -0
- package/app/canvas/picked-box.tsx +1 -0
- package/app/canvas/picks-menu.tsx +26 -8
- package/app/canvas/picks.ts +36 -29
- package/app/canvas/point-menu.tsx +4 -0
- package/app/canvas/props-model.ts +27 -5
- package/app/canvas/props-panel.tsx +31 -6
- package/app/canvas/quick-bar.tsx +59 -15
- package/app/canvas/removed-views-panel.tsx +39 -8
- package/app/canvas/request-node.tsx +22 -8
- package/app/canvas/review-marker.tsx +9 -2
- package/app/canvas/review-panel.tsx +145 -42
- package/app/canvas/row-node.tsx +15 -3
- package/app/canvas/scene-context.tsx +16 -1
- package/app/canvas/section-node.tsx +73 -14
- package/app/canvas/selection.ts +3 -1
- package/app/canvas/server-notice.tsx +10 -4
- package/app/canvas/size-label.tsx +2 -1
- package/app/canvas/sketch-boxes.tsx +194 -139
- package/app/canvas/sketch-layer.tsx +88 -30
- package/app/canvas/sketch-model.ts +78 -9
- package/app/canvas/slide-frame.tsx +13 -1
- package/app/canvas/slide-full-screen.tsx +19 -3
- package/app/canvas/slide-page.tsx +9 -1
- package/app/canvas/slide-pdf.tsx +44 -5
- package/app/canvas/snapping.ts +26 -1
- package/app/canvas/spec-copies.ts +13 -2
- package/app/canvas/spec-frame.tsx +198 -60
- package/app/canvas/spec-full-screen.tsx +39 -17
- package/app/canvas/spec-margin.tsx +32 -7
- package/app/canvas/spec-mode.tsx +28 -20
- package/app/canvas/spec-placing.tsx +32 -7
- package/app/canvas/spec-threads.ts +14 -0
- package/app/canvas/spec-title.tsx +12 -5
- package/app/canvas/spot-pins.tsx +8 -0
- package/app/canvas/stack-frame.tsx +357 -0
- package/app/canvas/stack-model.ts +267 -0
- package/app/canvas/stack-node.tsx +19 -11
- package/app/canvas/state-store.ts +7 -0
- package/app/canvas/sticker-model.ts +16 -2
- package/app/canvas/sticker-sheet.tsx +63 -11
- package/app/canvas/stored-viewport.ts +14 -13
- package/app/canvas/styles-layer.tsx +70 -52
- package/app/canvas/teammates-layer.tsx +21 -3
- package/app/canvas/tell-open-page.tsx +12 -0
- package/app/canvas/testing/must.ts +11 -0
- package/app/canvas/testing/stand-in.ts +9 -0
- package/app/canvas/testing/waits.ts +17 -0
- package/app/canvas/text-layer.tsx +55 -14
- package/app/canvas/thread-focus.tsx +47 -17
- package/app/canvas/thread-place.ts +27 -3
- package/app/canvas/tip.tsx +4 -0
- package/app/canvas/tool-cursors.ts +15 -1
- package/app/canvas/tool-icons.tsx +17 -4
- package/app/canvas/toolbar-parts.tsx +11 -5
- package/app/canvas/toolbar.tsx +132 -83
- package/app/canvas/tools.ts +32 -9
- package/app/canvas/typing.ts +6 -1
- package/app/canvas/unknown-frame.tsx +39 -12
- package/app/canvas/use-activity.ts +57 -2
- package/app/canvas/use-agent-changes.tsx +60 -15
- package/app/canvas/use-canvas-clipboard.tsx +190 -64
- package/app/canvas/use-canvas-commands.ts +14 -0
- package/app/canvas/use-canvas-editor.ts +39 -14
- package/app/canvas/use-component-drops.ts +21 -5
- package/app/canvas/use-spec-copies.ts +29 -14
- package/app/canvas/viewports.ts +4 -1
- package/app/canvas/wireframe-panel.tsx +18 -2
- package/app/canvas/xray.ts +3 -10
- package/app/client.d.ts +6 -0
- package/app/content.d.ts +1 -0
- package/app/design-system/components-canvas.ts +58 -21
- package/app/design-system/components-prototype.tsx +56 -20
- package/app/design-system/pseudo-states.ts +45 -16
- package/app/editor/annotations.ts +60 -20
- package/app/editor/blocks.ts +99 -34
- package/app/editor/embed-arrange.tsx +59 -22
- package/app/editor/embed-box.ts +54 -28
- package/app/editor/extensions.ts +16 -5
- package/app/editor/markdown-source.ts +42 -8
- package/app/editor/node-views.tsx +39 -12
- package/app/editor/quote-bubble.tsx +10 -1
- package/app/editor/two-versions.ts +24 -9
- package/app/export/player-model.ts +37 -9
- package/app/export/player.tsx +21 -4
- package/app/frame/file-errors.ts +4 -0
- package/app/frame/frame-app.tsx +15 -1
- package/app/frame/frame-history.ts +9 -0
- package/app/frame/frame-links.ts +7 -0
- package/app/frame/hold-window-focus.ts +4 -0
- package/app/frame/left-view.tsx +6 -0
- package/app/frame/start-frame.tsx +8 -2
- package/app/frame/studio-view.tsx +2 -0
- package/app/frame/view-exports.ts +240 -0
- package/app/frame/view-loads.ts +37 -11
- package/app/frame/views.ts +79 -8
- package/app/git/branch-panel.tsx +71 -25
- package/app/git/change-list.tsx +15 -6
- package/app/git/clash.tsx +10 -5
- package/app/git/git-controls.tsx +78 -22
- package/app/git/git-state.ts +20 -0
- package/app/git/git-toasts.tsx +41 -2
- package/app/git/paused.tsx +28 -12
- package/app/git/saved-list.tsx +10 -3
- package/app/git/sync-panel.tsx +39 -18
- package/app/i18n/locales/en/messages.po +119 -6
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +116 -3
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/i18n/locales.ts +4 -0
- package/app/i18n/provider.tsx +9 -5
- package/app/icons/dex-glyphs.tsx +38 -0
- package/app/icons/glyphs.tsx +5 -0
- package/app/icons/index.tsx +3 -1
- package/app/icons/types.ts +1 -0
- package/app/kit/inspect-runtime.ts +50 -5
- package/app/kit/sample-people.ts +6 -0
- package/app/kit/use-simulated-load.ts +6 -2
- package/app/kit/use-simulated-stream.ts +8 -2
- package/app/kit/use-view-control.ts +1 -0
- package/app/live/canvas-teammates.ts +14 -1
- package/app/live/deployed-preview.ts +1 -0
- package/app/live/focus-reporter.ts +8 -0
- package/app/live/guest-review.ts +115 -23
- package/app/live/restart-wait.ts +14 -2
- package/app/live/server-connection.ts +21 -4
- package/app/live/studio-action.ts +6 -1
- package/app/live/studio-api.ts +191 -54
- package/app/live/studio-data.ts +26 -1
- package/app/live/studio-live.ts +44 -8
- package/app/live/studio-request.ts +15 -1
- package/app/live/thread-state.ts +8 -0
- package/app/live/use-devices.ts +11 -2
- package/app/live/use-focus.ts +5 -2
- package/app/live/use-last-edited.ts +2 -0
- package/app/live/use-show-requests.ts +3 -0
- package/app/live/use-workspace.ts +10 -2
- package/app/main.tsx +9 -3
- package/app/next/fonts.ts +1 -0
- package/app/next/image.tsx +17 -10
- package/app/next/navigation.ts +9 -6
- package/app/next/router.ts +4 -4
- package/app/pages/agent-settings.tsx +11 -3
- package/app/pages/ask-the-agent.tsx +2 -0
- package/app/pages/canvas-settings.tsx +3 -0
- package/app/pages/canvas.tsx +230 -71
- package/app/pages/chrome-extension.tsx +4 -2
- package/app/pages/commands-settings.tsx +74 -25
- package/app/pages/deployment-settings.tsx +9 -0
- package/app/pages/doc.tsx +4 -1
- package/app/pages/file-sort.ts +11 -4
- package/app/pages/git-checks.tsx +30 -10
- package/app/pages/guidelines.tsx +8 -4
- package/app/pages/home.tsx +41 -17
- package/app/pages/host.tsx +4 -0
- package/app/pages/markup-settings.tsx +11 -5
- package/app/pages/people.tsx +18 -10
- package/app/pages/play-bar.tsx +27 -9
- package/app/pages/play-size.ts +31 -11
- package/app/pages/play.tsx +115 -33
- package/app/pages/profile.tsx +6 -2
- package/app/pages/prototype.tsx +10 -4
- package/app/pages/render.tsx +33 -8
- package/app/pages/settings.tsx +5 -1
- package/app/pages/workspace-general.tsx +29 -5
- package/app/pages/workspace-git.tsx +38 -10
- package/app/pages/your-guidelines.tsx +7 -0
- package/app/pages/your-picture.tsx +33 -10
- package/app/registry-files.ts +6 -1
- package/app/registry.ts +73 -13
- package/app/renamed-storage.ts +8 -1
- package/app/shell/about.tsx +10 -4
- package/app/shell/agent-logos.tsx +4 -0
- package/app/shell/agent-manual.tsx +13 -5
- package/app/shell/avatar-pictures.ts +18 -6
- package/app/shell/avatar.tsx +11 -1
- package/app/shell/bell.tsx +27 -13
- package/app/shell/broke.tsx +1 -1
- package/app/shell/chrome-theme.tsx +4 -0
- package/app/shell/connect-agent.tsx +76 -38
- package/app/shell/copy-text.tsx +3 -1
- package/app/shell/deployed-preview-bar.tsx +4 -6
- package/app/shell/desktop-app.tsx +30 -15
- package/app/shell/empty-state.tsx +2 -2
- package/app/shell/feedback-details.ts +8 -1
- package/app/shell/feedback-form.tsx +38 -30
- package/app/shell/feedback-link.tsx +3 -0
- package/app/shell/file-bytes.ts +3 -1
- package/app/shell/host.ts +37 -8
- package/app/shell/info-tip.tsx +2 -1
- package/app/shell/install-prompt.ts +10 -1
- package/app/shell/instructions-editor.tsx +184 -78
- package/app/shell/instructions.tsx +7 -1
- package/app/shell/main-sidebar.tsx +27 -6
- package/app/shell/open-agent.tsx +8 -2
- package/app/shell/page-header.tsx +6 -3
- package/app/shell/page-title.ts +36 -14
- package/app/shell/presence-style.ts +8 -0
- package/app/shell/presence.tsx +74 -10
- package/app/shell/prototype-menu.tsx +84 -27
- package/app/shell/quick-start.tsx +21 -3
- package/app/shell/recents.ts +21 -2
- package/app/shell/report-issue.ts +29 -23
- package/app/shell/restart-toast.tsx +37 -4
- package/app/shell/save-state.tsx +4 -0
- package/app/shell/scaled-frame.tsx +22 -1
- package/app/shell/settings-sections.ts +12 -11
- package/app/shell/settings-sidebar.tsx +7 -1
- package/app/shell/settings-ui.tsx +11 -7
- package/app/shell/shell-bar.ts +2 -5
- package/app/shell/sidebar.tsx +2 -2
- package/app/shell/skeleton.ts +80 -22
- package/app/shell/status-badge.tsx +2 -0
- package/app/shell/studio-shell.tsx +11 -4
- package/app/shell/thread-list.tsx +18 -7
- package/app/shell/time-ago.ts +7 -0
- package/app/shell/toasts.tsx +20 -13
- package/app/shell/update-notice.tsx +241 -41
- package/app/shell/use-copied.ts +4 -0
- package/app/shell/use-space.ts +5 -0
- package/app/shell/watch-switch.tsx +4 -1
- package/app/shell/welcome.tsx +18 -3
- package/app/shell/window-buttons.tsx +17 -3
- package/app/shell/working-on.tsx +10 -2
- package/app/shell/workspace-mark.tsx +59 -25
- package/app/studio-ui.d.ts +2 -1
- package/app/styles.css +4 -12
- package/app/types.ts +8 -6
- package/app/ui/boundary.tsx +6 -1
- package/app/ui/file-drop.ts +32 -18
- package/app/ui/prompt-editor.tsx +81 -25
- package/app/ui/reference.tsx +6 -1
- package/app/ui/segmented.tsx +3 -1
- package/app/ui/theme-switch.tsx +1 -0
- package/app/ui/theme.css +17 -0
- package/app/ui/use-latest.ts +13 -0
- package/app/ui/use-once.ts +9 -0
- package/bin/dex.mjs +6 -1
- package/bin/sudio.mjs +1 -0
- package/dist/cli/banner.mjs +0 -1
- package/dist/cli/command.d.mts +237 -5
- package/dist/cli/command.mjs +8 -3
- package/dist/cli/commands/agents/add.mjs +1 -1
- package/dist/cli/commands/app.mjs +13 -16
- package/dist/cli/commands/claude.d.mts +3 -3
- package/dist/cli/commands/claude.mjs +10 -9
- package/dist/cli/commands/cloud/publish.mjs +1 -1
- package/dist/cli/commands/dev.mjs +64 -19
- package/dist/cli/commands/doctor.mjs +3 -1
- package/dist/cli/commands/hook.mjs +1 -1
- package/dist/cli/commands/mcp.mjs +10 -4
- package/dist/cli/commands/merge-canvas.d.mts +29 -0
- package/dist/cli/commands/merge-canvas.mjs +101 -0
- package/dist/cli/commands/merge-contributors.d.mts +0 -7
- package/dist/cli/commands/merge-contributors.mjs +2 -1
- package/dist/cli/commands/merge-spec.d.mts +0 -7
- package/dist/cli/commands/merge-spec.mjs +2 -1
- package/dist/cli/help.mjs +7 -13
- package/dist/cli/main.d.mts +26 -0
- package/dist/cli/main.mjs +4 -2
- package/dist/cli/mcp-relay.d.mts +5 -5
- package/dist/cli/mcp-relay.mjs +36 -24
- package/dist/cli/recovery-server.mjs +2 -2
- package/dist/cli/strict-flags.mjs +6 -6
- package/dist/cli/supervise.mjs +37 -26
- package/dist/cli/ui.d.mts +21 -21
- package/dist/cli/ui.mjs +2 -1
- package/dist/config/design-system.mjs +19 -14
- package/dist/config/load.mjs +10 -7
- package/dist/config/project-files.d.mts +3 -2
- package/dist/config/project-files.mjs +35 -41
- package/dist/config/renamed.d.mts +4 -8
- package/dist/config/renamed.mjs +4 -17
- package/dist/content/biome.mjs +15 -10
- package/dist/content/capture.mjs +43 -42
- package/dist/content/commands.d.mts +10 -4
- package/dist/content/commands.mjs +49 -21
- package/dist/content/comments-log.mjs +102 -19
- package/dist/content/component-props.mjs +6 -10
- package/dist/content/content.d.mts +269 -33
- package/dist/content/content.mjs +205 -146
- package/dist/content/devices.mjs +2 -2
- package/dist/content/element-words.mjs +7 -7
- package/dist/content/file-turns.mjs +1 -1
- package/dist/content/first-run.mjs +3 -5
- package/dist/content/flow-specs.mjs +18 -16
- package/dist/content/format-check.d.mts +46 -0
- package/dist/content/format-check.mjs +338 -0
- package/dist/content/hosted-person.mjs +4 -3
- package/dist/content/insert-edit.mjs +7 -6
- package/dist/content/jsx-source.d.mts +5 -1
- package/dist/content/jsx-source.mjs +8 -7
- package/dist/content/last-edited.mjs +1 -1
- package/dist/content/layout.d.mts +44 -2
- package/dist/content/layout.mjs +65 -6
- package/dist/content/merge-rules.d.mts +11 -4
- package/dist/content/merge-rules.mjs +31 -18
- package/dist/content/prop-edit.mjs +4 -4
- package/dist/content/prototype-checks.mjs +13 -12
- package/dist/content/prototype-summary.d.mts +1 -1
- package/dist/content/prototype-summary.mjs +8 -8
- package/dist/content/prototypes.d.mts +8 -1
- package/dist/content/prototypes.mjs +41 -27
- package/dist/content/review-import.mjs +1 -1
- package/dist/content/review-pages.mjs +19 -16
- package/dist/content/screenshot.d.mts +4 -1
- package/dist/content/screenshot.mjs +18 -14
- package/dist/content/snapshot-client.mjs +2 -3
- package/dist/content/store.d.mts +16 -8
- package/dist/content/store.mjs +99 -26
- package/dist/content/sub-agents.d.mts +12 -0
- package/dist/content/sub-agents.mjs +52 -0
- package/dist/content/text-edit.mjs +6 -6
- package/dist/content/text-replace.mjs +13 -15
- package/dist/content/thread-module.d.mts +9 -1
- package/dist/content/thread-module.mjs +19 -1
- package/dist/content/threads.d.mts +13 -0
- package/dist/content/threads.mjs +59 -14
- package/dist/content/trash.d.mts +4 -2
- package/dist/content/trash.mjs +31 -31
- package/dist/desktop/src/app.d.mts +40 -0
- package/dist/desktop/src/app.mjs +80 -0
- package/dist/desktop/src/contract.d.mts +7 -0
- package/dist/desktop/src/contract.mjs +22 -0
- package/dist/desktop/src/host.d.mts +48 -0
- package/dist/desktop/src/index.d.mts +32 -0
- package/dist/desktop/src/index.mjs +69 -0
- package/dist/desktop/src/mac/bundle.mjs +116 -0
- package/dist/desktop/src/mac/icon.mjs +53 -0
- package/dist/desktop/src/mac/launcher.mjs +69 -0
- package/dist/desktop/src/mac/plist.mjs +73 -0
- package/dist/desktop/src/mac/program/constants.mjs +62 -0
- package/dist/desktop/src/mac/program/delegate.mjs +214 -0
- package/dist/desktop/src/mac/program/downloads.mjs +19 -0
- package/dist/desktop/src/mac/program/index.mjs +26 -0
- package/dist/desktop/src/mac/program/menu.mjs +125 -0
- package/dist/desktop/src/mac/program/server-pages.mjs +140 -0
- package/dist/desktop/src/mac/program/web-view.mjs +59 -0
- package/dist/desktop/src/mac/program/window.mjs +197 -0
- package/dist/desktop/src/mac/services.mjs +28 -0
- package/dist/desktop/src/plug-in/http.d.mts +11 -0
- package/dist/desktop/src/plug-in/http.mjs +51 -0
- package/dist/desktop/src/plug-in/page-head.d.mts +8 -0
- package/dist/desktop/src/plug-in/page-head.mjs +31 -0
- package/dist/desktop/src/service.d.mts +15 -0
- package/dist/desktop/src/service.mjs +151 -0
- package/dist/desktop/src/start.d.mts +42 -0
- package/dist/{setup/desktop-app-start.mjs → desktop/src/start.mjs} +14 -39
- package/dist/harness/src/agents/adapter.d.mts +11 -0
- package/dist/harness/src/agents/adapter.mjs +6 -0
- package/dist/harness/src/agents/claude-code.mjs +179 -0
- package/dist/harness/src/agents/codex.mjs +189 -0
- package/dist/harness/src/agents/copilot.mjs +20 -0
- package/dist/harness/src/agents/cursor.mjs +21 -0
- package/dist/harness/src/agents/opencode.mjs +27 -0
- package/dist/harness/src/agents/other.mjs +21 -0
- package/dist/harness/src/agents/registry.mjs +21 -0
- package/dist/harness/src/agents/sub-agent.d.mts +14 -0
- package/dist/harness/src/agents.mjs +7 -0
- package/dist/harness/src/checks.mjs +9 -0
- package/dist/harness/src/connect/agent-config.mjs +252 -0
- package/dist/{server → harness/src/connect}/agent-env.mjs +3 -4
- package/dist/harness/src/connect/agent-root.mjs +30 -0
- package/dist/harness/src/connect/json-layout.mjs +52 -0
- package/dist/harness/src/connect/launch.mjs +67 -0
- package/dist/harness/src/connect/launched.d.mts +23 -0
- package/dist/harness/src/connect/package-manager.d.mts +1 -0
- package/dist/{config → harness/src/connect}/package-manager.mjs +17 -6
- package/dist/harness/src/connect/setups.d.mts +24 -0
- package/dist/harness/src/connect/setups.mjs +98 -0
- package/dist/harness/src/connect/workspace-root.d.mts +20 -0
- package/dist/harness/src/connect/workspace-root.mjs +110 -0
- package/dist/harness/src/events/channel-server.mjs +10 -0
- package/dist/harness/src/events/channel.d.mts +104 -0
- package/dist/harness/src/events/channel.mjs +457 -0
- package/dist/harness/src/events/connected-agent.d.mts +35 -0
- package/dist/harness/src/events/place.d.mts +21 -0
- package/dist/harness/src/mcp/define-tool.d.mts +26 -0
- package/dist/harness/src/mcp/define-tool.mjs +11 -0
- package/dist/harness/src/mcp/mcp-handover.d.mts +11 -0
- package/dist/{server → harness/src/mcp}/mcp-handover.mjs +6 -4
- package/dist/harness/src/mcp/mcp.d.mts +15 -0
- package/dist/harness/src/mcp/mcp.mjs +97 -0
- package/dist/harness/src/paths.d.mts +4 -0
- package/dist/harness/src/paths.mjs +15 -0
- package/dist/harness/src/project.d.mts +6 -0
- package/dist/harness/src/renamed.d.mts +9 -0
- package/dist/harness/src/renamed.mjs +22 -0
- package/dist/harness/src/session/session.d.mts +31 -0
- package/dist/harness/src/version.d.mts +13 -0
- package/dist/harness/src/version.mjs +47 -0
- package/dist/inspector.js +598 -0
- package/dist/paste/figma/captures.mjs +3 -3
- package/dist/paste/figma/decode.d.mts +14 -8
- package/dist/paste/figma/decode.mjs +11 -9
- package/dist/paste/figma/layout.d.mts +4 -3
- package/dist/paste/figma/layout.mjs +1 -1
- package/dist/paste/figma/paint.mjs +7 -5
- package/dist/paste/figma/render.mjs +1 -1
- package/dist/paste/figma/styles.d.mts +3 -1
- package/dist/paste/figma/styles.mjs +5 -9
- package/dist/paste/figma/text.mjs +21 -17
- package/dist/paste/figma/vector.mjs +9 -9
- package/dist/paste/fonts.mjs +7 -8
- package/dist/paste/paste.d.mts +2 -2
- package/dist/paste/paste.mjs +16 -15
- package/dist/paths.d.mts +22 -16
- package/dist/paths.mjs +28 -57
- package/dist/server/agent-session.d.mts +49 -3
- package/dist/server/agent-session.mjs +264 -20
- package/dist/server/agent-tools.d.mts +17 -0
- package/dist/server/agent-tools.mjs +31 -0
- package/dist/server/agents-place.d.mts +6 -0
- package/dist/server/agents-place.mjs +18 -0
- package/dist/server/allowed-request.mjs +1 -1
- package/dist/server/avatars.d.mts +3 -1
- package/dist/server/avatars.mjs +9 -7
- package/dist/server/brief.mjs +10 -10
- package/dist/server/briefing.d.mts +5 -5
- package/dist/server/briefing.mjs +5 -5
- package/dist/server/build-pictures.mjs +8 -8
- package/dist/server/build-settings.d.mts +1 -1
- package/dist/server/build-settings.mjs +4 -4
- package/dist/server/changelog.mjs +5 -4
- package/dist/server/claimed-presence.mjs +10 -7
- package/dist/server/close-check.mjs +17 -15
- package/dist/server/cloud.d.mts +1 -1
- package/dist/server/cloud.mjs +5 -4
- package/dist/server/command-settings.d.mts +4 -2
- package/dist/server/command-settings.mjs +11 -7
- package/dist/server/comments/actions.d.mts +17 -56
- package/dist/server/comments/actions.mjs +65 -59
- package/dist/server/comments/agent-actions.d.mts +73 -0
- package/dist/server/comments/agent-actions.mjs +76 -0
- package/dist/server/comments/close-tools.d.mts +31 -0
- package/dist/server/comments/close-tools.mjs +124 -0
- package/dist/server/comments/files.d.mts +53 -0
- package/dist/server/comments/files.mjs +1 -0
- package/dist/server/comments/hand-out.d.mts +42 -0
- package/dist/server/comments/hand-out.mjs +46 -0
- package/dist/server/comments/push.d.mts +26 -0
- package/dist/server/comments/push.mjs +238 -0
- package/dist/server/comments/routes.d.mts +12 -0
- package/dist/server/comments/routes.mjs +21 -11
- package/dist/server/comments/studio-files.d.mts +14 -0
- package/dist/server/comments/studio-files.mjs +80 -0
- package/dist/server/comments/tools.d.mts +35 -3
- package/dist/server/comments/tools.mjs +54 -147
- package/dist/server/comments/workflow.d.mts +13 -0
- package/dist/server/comments/workflow.mjs +15 -0
- package/dist/server/comments/workspace.d.mts +36 -0
- package/dist/server/comments/workspace.mjs +84 -0
- package/dist/server/component-catalogue.mjs +19 -21
- package/dist/server/config-settings.d.mts +1 -1
- package/dist/server/config-settings.mjs +3 -3
- package/dist/server/content-type.mjs +1 -1
- package/dist/server/dependency-clash.d.mts +6 -2
- package/dist/server/dependency-clash.mjs +23 -17
- package/dist/server/desktop.d.mts +20 -0
- package/dist/server/desktop.mjs +56 -0
- package/dist/server/dev-server.mjs +19 -37
- package/dist/server/export/build.mjs +3 -3
- package/dist/server/export/page.mjs +4 -4
- package/dist/server/export/plugin.d.mts +4 -2
- package/dist/server/export/plugin.mjs +4 -1
- package/dist/server/features.d.mts +0 -5
- package/dist/server/features.mjs +1 -6
- package/dist/server/file-errors.mjs +4 -4
- package/dist/server/file-lock.mjs +14 -9
- package/dist/server/git-host.mjs +6 -9
- package/dist/server/git-paused.mjs +4 -1
- package/dist/server/git-settings.d.mts +1 -1
- package/dist/server/git-settings.mjs +5 -5
- package/dist/server/git-sync.d.mts +8 -0
- package/dist/server/git-sync.mjs +77 -19
- package/dist/server/git.d.mts +0 -5
- package/dist/server/git.mjs +53 -48
- package/dist/server/instructions.mjs +9 -8
- package/dist/server/live-mirror.mjs +20 -13
- package/dist/server/live.mjs +8 -6
- package/dist/server/machine-update.mjs +32 -32
- package/dist/server/me.mjs +4 -2
- package/dist/server/merge-check.d.mts +14 -0
- package/dist/server/merge-check.mjs +80 -0
- package/dist/server/next.mjs +9 -6
- package/dist/server/notices.d.mts +6 -6
- package/dist/server/notices.mjs +11 -9
- package/dist/server/open-page.mjs +11 -10
- package/dist/server/outcome.d.mts +7 -8
- package/dist/server/own-copies.mjs +21 -11
- package/dist/server/people.mjs +4 -4
- package/dist/server/pictures.mjs +14 -8
- package/dist/server/port.mjs +5 -9
- package/dist/server/prebundle.mjs +16 -13
- package/dist/server/preferences.mjs +1 -1
- package/dist/server/presence.d.mts +3 -3
- package/dist/server/presence.mjs +2 -4
- package/dist/server/project-public.mjs +1 -1
- package/dist/server/prototype-brief.d.mts +36 -3
- package/dist/server/prototype-brief.mjs +6 -6
- package/dist/server/push-notice.d.mts +1 -1
- package/dist/server/quiet-run.mjs +1 -1
- package/dist/server/registry.mjs +9 -8
- package/dist/server/requests.d.mts +9 -20
- package/dist/server/requests.mjs +136 -130
- package/dist/server/response-budget.d.mts +16 -7
- package/dist/server/response-budget.mjs +6 -5
- package/dist/server/restart.mjs +3 -1
- package/dist/server/roster.d.mts +2 -2
- package/dist/server/roster.mjs +7 -8
- package/dist/server/source-stamp.d.mts +5 -4
- package/dist/server/source-stamp.mjs +43 -15
- package/dist/server/spec-decisions.mjs +2 -2
- package/dist/server/state.d.mts +6 -6
- package/dist/server/state.mjs +3 -5
- package/dist/server/studio-server.d.mts +92 -0
- package/dist/server/studio-server.mjs +77 -0
- package/dist/server/sync-install.mjs +2 -2
- package/dist/server/thread-forms.d.mts +7 -8
- package/dist/server/thread-forms.mjs +13 -14
- package/dist/server/thread-place.d.mts +2 -2
- package/dist/server/thread-place.mjs +28 -18
- package/dist/server/thread-source.d.mts +35 -5
- package/dist/server/thread-source.mjs +43 -40
- package/dist/server/tools/context.d.mts +53 -35
- package/dist/server/tools/context.mjs +17 -32
- package/dist/server/tools/describe.d.mts +3 -5
- package/dist/server/tools/describe.mjs +4 -24
- package/dist/server/tools/export.d.mts +14 -2
- package/dist/server/tools/export.mjs +30 -25
- package/dist/server/tools/feedback.d.mts +20 -4
- package/dist/server/tools/feedback.mjs +70 -62
- package/dist/server/tools/place-frame.d.mts +15 -3
- package/dist/server/tools/place-frame.mjs +70 -63
- package/dist/server/tools/prototype-name.mjs +3 -4
- package/dist/server/tools/reading.d.mts +4 -4
- package/dist/server/tools/reading.mjs +137 -114
- package/dist/server/tools/show.d.mts +9 -4
- package/dist/server/tools/show.mjs +39 -34
- package/dist/server/tools/snapshot.d.mts +19 -5
- package/dist/server/tools/snapshot.mjs +64 -59
- package/dist/server/tools/studio-context.d.mts +8 -0
- package/dist/server/tools/studio-context.mjs +44 -0
- package/dist/server/tools/thread-list.d.mts +19 -4
- package/dist/server/tools/thread-list.mjs +59 -61
- package/dist/server/tools/watch.d.mts +11 -4
- package/dist/server/tools/watch.mjs +165 -115
- package/dist/server/unresolved-imports.mjs +4 -1
- package/dist/server/update-branch.mjs +2 -2
- package/dist/server/update-studio.d.mts +3 -1
- package/dist/server/update-studio.mjs +30 -19
- package/dist/server/updates.mjs +10 -10
- package/dist/server/vite.mjs +29 -24
- package/dist/server/web-app.mjs +17 -30
- package/dist/server/welcome.mjs +4 -2
- package/dist/server/work-groups.d.mts +13 -2
- package/dist/server/work-groups.mjs +58 -23
- package/dist/server/workspace-settings.d.mts +9 -5
- package/dist/server/workspace-settings.mjs +40 -39
- package/dist/server/zip.mjs +1 -1
- package/dist/setup/apply.d.mts +6 -1
- package/dist/setup/apply.mjs +26 -23
- package/dist/setup/cancelled.d.mts +6 -0
- package/dist/setup/cancelled.mjs +10 -0
- package/dist/setup/commit-lint.d.mts +6 -4
- package/dist/setup/commit-lint.mjs +23 -27
- package/dist/setup/components.mjs +3 -3
- package/dist/setup/config-source.d.mts +16 -5
- package/dist/setup/config-source.mjs +36 -27
- package/dist/setup/create.mjs +64 -52
- package/dist/setup/design-md-setup.d.mts +6 -4
- package/dist/setup/design-md-setup.mjs +14 -12
- package/dist/setup/design-md.mjs +50 -52
- package/dist/setup/design-system-checks.mjs +8 -8
- package/dist/setup/detect/workspace.d.mts +3 -17
- package/dist/setup/detect/workspace.mjs +23 -126
- package/dist/setup/detect.mjs +24 -18
- package/dist/setup/doctor.d.mts +1 -1
- package/dist/setup/doctor.mjs +15 -14
- package/dist/setup/existing-setup.mjs +20 -15
- package/dist/setup/git-checks.mjs +5 -5
- package/dist/setup/hash.d.mts +4 -0
- package/dist/setup/hash.mjs +6 -0
- package/dist/setup/hints.mjs +5 -4
- package/dist/setup/host-format.mjs +2 -6
- package/dist/setup/json.d.mts +12 -0
- package/dist/setup/json.mjs +9 -0
- package/dist/setup/migrate/agent-files.mjs +8 -7
- package/dist/setup/migrate/config-name.mjs +1 -1
- package/dist/setup/migrate/design-system.mjs +37 -34
- package/dist/setup/migrate/dex-folder.d.mts +1 -1
- package/dist/setup/migrate/dex-folder.mjs +27 -23
- package/dist/setup/migrate/explorations.mjs +7 -5
- package/dist/setup/migrate/files-folder.mjs +35 -20
- package/dist/setup/migrate/frame-notes.d.mts +20 -0
- package/dist/setup/migrate/frame-notes.mjs +126 -0
- package/dist/setup/migrate/frame-uids.d.mts +24 -0
- package/dist/setup/migrate/frame-uids.mjs +144 -0
- package/dist/setup/migrate/guides.mjs +1 -1
- package/dist/setup/migrate/manifest-name.d.mts +23 -0
- package/dist/setup/migrate/manifest-name.mjs +93 -0
- package/dist/setup/migrate/migrations.mjs +12 -2
- package/dist/setup/migrate/people-folders.d.mts +3 -3
- package/dist/setup/migrate/people-folders.mjs +25 -36
- package/dist/setup/migrate/picks-file.d.mts +33 -0
- package/dist/setup/migrate/picks-file.mjs +172 -0
- package/dist/setup/migrate/project-files.mjs +10 -8
- package/dist/setup/migrate/row-titles.mjs +5 -2
- package/dist/setup/migrate/setup-files.mjs +18 -12
- package/dist/setup/migrate/studio-state.mjs +8 -6
- package/dist/setup/own-app.d.mts +2 -1
- package/dist/setup/own-app.mjs +17 -15
- package/dist/setup/placement.mjs +20 -18
- package/dist/setup/plan.d.mts +5 -3
- package/dist/setup/plan.mjs +7 -6
- package/dist/setup/project.mjs +11 -8
- package/dist/setup/prompts.d.mts +1 -5
- package/dist/setup/prompts.mjs +54 -53
- package/dist/setup/provider.mjs +3 -2
- package/dist/setup/questions.d.mts +13 -7
- package/dist/setup/questions.mjs +2 -4
- package/dist/setup/starters.mjs +6 -3
- package/dist/setup/templates.d.mts +3 -3
- package/dist/setup/templates.mjs +18 -14
- package/dist/setup/workspace-setup.mjs +4 -5
- package/dist/setup/write.d.mts +10 -2
- package/dist/setup/write.mjs +17 -16
- package/dist/shared/block-merge.d.mts +5 -4
- package/dist/shared/block-merge.mjs +5 -5
- package/dist/shared/built-pictures.d.mts +13 -4
- package/dist/shared/built-pictures.mjs +16 -8
- package/dist/shared/canvas-core.d.mts +117 -57
- package/dist/shared/canvas-core.mjs +192 -79
- package/dist/shared/canvas-file.d.mts +15 -6
- package/dist/shared/canvas-merge.d.mts +28 -0
- package/dist/shared/canvas-merge.mjs +384 -0
- package/dist/shared/checks.d.mts +8 -0
- package/dist/shared/checks.mjs +9 -1
- package/dist/shared/code-anchor.d.mts +16 -0
- package/dist/shared/code-anchor.mjs +33 -0
- package/dist/shared/commands-core.d.mts +25 -0
- package/dist/shared/commands-core.mjs +31 -7
- package/dist/shared/comments/routes.d.mts +4 -2
- package/dist/shared/comments/routes.mjs +6 -4
- package/dist/shared/comments/state.d.mts +71 -0
- package/dist/shared/comments/state.mjs +66 -0
- package/dist/shared/contributors-merge.mjs +4 -4
- package/dist/shared/devices.d.mts +5 -4
- package/dist/shared/devices.mjs +1 -1
- package/dist/shared/export-core.d.mts +0 -1
- package/dist/shared/export-core.mjs +20 -21
- package/dist/shared/feedback.mjs +5 -7
- package/dist/shared/file-errors.mjs +3 -3
- package/dist/shared/file-names.d.mts +6 -0
- package/dist/shared/file-names.mjs +521 -0
- package/dist/shared/fix-prompt.mjs +1 -1
- package/dist/shared/front-matter.mjs +8 -9
- package/dist/shared/generated-sections.mjs +7 -7
- package/dist/shared/git-core.mjs +11 -11
- package/dist/shared/json-style.mjs +5 -4
- package/dist/shared/live-core.d.mts +10 -5
- package/dist/shared/live-core.mjs +5 -4
- package/dist/shared/live-presence.mjs +12 -9
- package/dist/shared/markup-prompt.d.mts +7 -3
- package/dist/shared/markup-prompt.mjs +9 -5
- package/dist/shared/open-page-core.mjs +6 -5
- package/dist/shared/page-messages.d.mts +16 -4
- package/dist/shared/page-messages.mjs +26 -14
- package/dist/shared/page-review.mjs +8 -10
- package/dist/shared/people-core.d.mts +37 -29
- package/dist/shared/people-core.mjs +49 -24
- package/dist/shared/{annotations-core.d.mts → picks-core.d.mts} +24 -29
- package/dist/shared/{annotations-core.mjs → picks-core.mjs} +48 -62
- package/dist/shared/prototypes-core.d.mts +70 -15
- package/dist/shared/prototypes-core.mjs +184 -100
- package/dist/shared/references-core.mjs +5 -6
- package/dist/shared/removed-views-core.mjs +6 -6
- package/dist/shared/review-file.mjs +3 -3
- package/dist/shared/server-page.mjs +4 -4
- package/dist/shared/signup.mjs +3 -2
- package/dist/shared/sketch-core.mjs +7 -7
- package/dist/shared/snapshot-clipboard.d.mts +5 -4
- package/dist/shared/snapshot-clipboard.mjs +2 -2
- package/dist/shared/snapshot-images.d.mts +10 -1
- package/dist/shared/snapshot-images.mjs +62 -14
- package/dist/shared/spec-quote.mjs +4 -4
- package/dist/shared/studio-events.d.mts +5 -36
- package/dist/shared/studio-events.mjs +5 -5
- package/dist/shared/studio-files.d.mts +3 -3
- package/dist/shared/studio-files.mjs +7 -7
- package/dist/shared/studio-routes.d.mts +28 -30
- package/dist/shared/studio-routes.mjs +6 -1
- package/dist/shared/threads-core.d.mts +346 -32
- package/dist/shared/threads-core.mjs +223 -76
- package/dist/shared/unknown-fields.d.mts +10 -0
- package/dist/shared/unknown-fields.mjs +74 -0
- package/dist/shared/unzip.d.mts +4 -2
- package/dist/shared/unzip.mjs +9 -7
- package/dist/shared/word-diff.mjs +6 -6
- package/dist/shared/xray.d.mts +4 -0
- package/dist/shared/xray.mjs +11 -0
- package/extension/dist/background.js +1 -1
- package/extension/dist/manifest.json +2 -3
- package/extension/dist/picker.js +114 -104
- package/package.json +82 -60
- package/schema/canvas.json +390 -0
- package/schema/comment-event.json +441 -0
- package/schema/contributors.json +30 -0
- package/schema/defs.json +66 -0
- package/schema/file.json +59 -0
- package/schema/picks.json +45 -0
- package/src/cli/banner.ts +46 -5
- package/src/cli/command.ts +25 -12
- package/src/cli/commands/agents/add.ts +4 -1
- package/src/cli/commands/agents.ts +1 -0
- package/src/cli/commands/app.ts +33 -24
- package/src/cli/commands/build.ts +4 -0
- package/src/cli/commands/claude.ts +20 -10
- package/src/cli/commands/cloud/link.ts +2 -0
- package/src/cli/commands/cloud/live.ts +2 -0
- package/src/cli/commands/cloud/login.ts +1 -0
- package/src/cli/commands/cloud/publish.ts +23 -9
- package/src/cli/commands/cloud/push.ts +2 -0
- package/src/cli/commands/cloud/status.ts +2 -0
- package/src/cli/commands/cloud/unlink.ts +2 -0
- package/src/cli/commands/cloud.ts +1 -0
- package/src/cli/commands/components.ts +1 -0
- package/src/cli/commands/create.ts +3 -0
- package/src/cli/commands/dev.ts +148 -32
- package/src/cli/commands/doctor.ts +9 -1
- package/src/cli/commands/export.ts +10 -1
- package/src/cli/commands/extension.ts +1 -0
- package/src/cli/commands/hook.ts +17 -1
- package/src/cli/commands/init.ts +3 -0
- package/src/cli/commands/mcp.ts +23 -4
- package/src/cli/commands/merge-canvas.ts +134 -0
- package/src/cli/commands/merge-contributors.ts +10 -4
- package/src/cli/commands/merge-spec.ts +7 -1
- package/src/cli/commands/preview.ts +2 -0
- package/src/cli/commands/stop.ts +6 -0
- package/src/cli/commands/upgrade.ts +11 -0
- package/src/cli/commands/work/check.ts +2 -0
- package/src/cli/commands/work/contributor.ts +3 -1
- package/src/cli/commands/work/new.ts +3 -1
- package/src/cli/commands/work/presence.ts +3 -1
- package/src/cli/commands/work/scope.ts +3 -1
- package/src/cli/commands/work/snapshot.ts +3 -1
- package/src/cli/commands/work/thread.ts +3 -1
- package/src/cli/commands/work/threads.ts +3 -1
- package/src/cli/commands/work/whoami.ts +3 -1
- package/src/cli/help.ts +32 -10
- package/src/cli/main.ts +31 -3
- package/src/cli/mcp-relay.ts +150 -49
- package/src/cli/recovery-server.ts +23 -9
- package/src/cli/strict-flags.ts +41 -6
- package/src/cli/supervise.ts +119 -37
- package/src/cli/ui.ts +55 -26
- package/src/config/design-system.ts +65 -18
- package/src/config/index.ts +1 -0
- package/src/config/load.ts +37 -6
- package/src/config/project-files.ts +180 -43
- package/src/config/renamed.ts +15 -20
- package/src/config/schema.ts +8 -0
- package/src/content/biome.ts +31 -17
- package/src/content/capture.ts +200 -56
- package/src/content/commands.ts +85 -27
- package/src/content/comments-log.ts +183 -34
- package/src/content/component-props.ts +134 -23
- package/src/content/content.ts +707 -217
- package/src/content/devices.ts +12 -3
- package/src/content/element-words.ts +33 -8
- package/src/content/file-turns.ts +12 -4
- package/src/content/first-run.ts +10 -10
- package/src/content/flow-specs.ts +88 -40
- package/src/content/format-check.ts +599 -0
- package/src/content/hosted-person.ts +31 -7
- package/src/content/insert-edit.ts +52 -17
- package/src/content/jsx-source.ts +17 -6
- package/src/content/last-edited.ts +15 -4
- package/src/content/layout.ts +131 -9
- package/src/content/merge-rules.ts +71 -37
- package/src/content/prop-edit.ts +60 -4
- package/src/content/prototype-checks.ts +52 -18
- package/src/content/prototype-summary.ts +37 -20
- package/src/content/prototypes.ts +138 -52
- package/src/content/review-import.ts +8 -1
- package/src/content/review-pages.ts +63 -8
- package/src/content/screenshot.ts +82 -24
- package/src/content/snapshot-client.ts +25 -3
- package/src/content/store.ts +177 -55
- package/src/content/sub-agents.ts +107 -0
- package/src/content/text-edit.ts +41 -5
- package/src/content/text-replace.ts +130 -32
- package/src/content/thread-module.ts +84 -12
- package/src/content/threads.ts +146 -16
- package/src/content/trash.ts +100 -40
- package/src/paste/figma/appearance.ts +39 -6
- package/src/paste/figma/captures.ts +21 -6
- package/src/paste/figma/decode.ts +82 -15
- package/src/paste/figma/document.ts +73 -5
- package/src/paste/figma/layout.ts +44 -5
- package/src/paste/figma/paint.ts +52 -8
- package/src/paste/figma/render.ts +18 -3
- package/src/paste/figma/styles.ts +20 -5
- package/src/paste/figma/text.ts +97 -29
- package/src/paste/figma/vector.ts +74 -12
- package/src/paste/fonts.ts +30 -9
- package/src/paste/paste.ts +45 -15
- package/src/paths.ts +66 -87
- package/src/server/agent-session.ts +451 -20
- package/src/server/agent-tools.ts +52 -0
- package/src/server/agents-place.ts +22 -0
- package/src/server/allowed-request.ts +7 -1
- package/src/server/avatars.ts +18 -6
- package/src/server/brief.ts +75 -16
- package/src/server/briefing.ts +19 -9
- package/src/server/build-pictures.ts +57 -9
- package/src/server/build-settings.ts +10 -4
- package/src/server/canvas-presence.ts +31 -2
- package/src/server/changelog.ts +15 -3
- package/src/server/claimed-presence.ts +32 -8
- package/src/server/close-check.ts +56 -19
- package/src/server/cloud.ts +61 -12
- package/src/server/command-settings.ts +30 -12
- package/src/server/comments/actions.ts +137 -133
- package/src/server/comments/agent-actions.ts +178 -0
- package/src/server/comments/close-tools.ts +240 -0
- package/src/server/comments/files.ts +66 -0
- package/src/server/comments/hand-out.ts +105 -0
- package/src/server/comments/push.ts +503 -0
- package/src/server/comments/routes.ts +39 -9
- package/src/server/comments/studio-files.ts +128 -0
- package/src/server/comments/tools.ts +103 -301
- package/src/server/comments/workflow.ts +18 -0
- package/src/server/comments/workspace.ts +123 -0
- package/src/server/component-catalogue.ts +58 -20
- package/src/server/config-settings.ts +11 -3
- package/src/server/content-type.ts +3 -1
- package/src/server/dependency-clash.ts +86 -26
- package/src/server/desktop.ts +92 -0
- package/src/server/dev-server.ts +65 -61
- package/src/server/export/build.ts +37 -3
- package/src/server/export/page.ts +16 -7
- package/src/server/export/plugin.ts +28 -9
- package/src/server/export/run.ts +12 -0
- package/src/server/export/save.ts +5 -0
- package/src/server/features.ts +4 -6
- package/src/server/file-errors.ts +35 -5
- package/src/server/file-lock.ts +53 -19
- package/src/server/git-asks.ts +13 -4
- package/src/server/git-host.ts +51 -12
- package/src/server/git-paused.ts +39 -3
- package/src/server/git-settings.ts +15 -5
- package/src/server/git-sync.ts +229 -36
- package/src/server/git.ts +236 -116
- package/src/server/hosted.ts +11 -0
- package/src/server/instructions.ts +32 -7
- package/src/server/live-mirror.ts +109 -10
- package/src/server/live.ts +85 -16
- package/src/server/machine-update.ts +167 -35
- package/src/server/me.ts +8 -3
- package/src/server/merge-check.ts +125 -0
- package/src/server/next.ts +30 -8
- package/src/server/notices.ts +77 -15
- package/src/server/open-page.ts +44 -19
- package/src/server/outcome.ts +8 -7
- package/src/server/own-copies.ts +104 -13
- package/src/server/people.ts +22 -7
- package/src/server/personal-folder.ts +3 -0
- package/src/server/pictures.ts +76 -8
- package/src/server/port.ts +38 -6
- package/src/server/prebundle.ts +53 -18
- package/src/server/preferences.ts +6 -1
- package/src/server/presence.ts +17 -6
- package/src/server/problems.ts +2 -0
- package/src/server/project-id.ts +2 -0
- package/src/server/project-public.ts +12 -1
- package/src/server/prototype-brief.ts +36 -17
- package/src/server/push-notice.ts +11 -1
- package/src/server/quiet-run.ts +10 -3
- package/src/server/registry.ts +34 -7
- package/src/server/requests.ts +543 -252
- package/src/server/response-budget.ts +29 -6
- package/src/server/restart.ts +36 -3
- package/src/server/roster.ts +50 -8
- package/src/server/saved.ts +15 -5
- package/src/server/source-stamp.ts +116 -12
- package/src/server/spec-decisions.ts +11 -2
- package/src/server/state.ts +21 -9
- package/src/server/stop-studio.ts +9 -1
- package/src/server/studio-for.ts +38 -9
- package/src/server/studio-server.ts +233 -0
- package/src/server/sync-install.ts +8 -3
- package/src/server/thread-forms.ts +84 -27
- package/src/server/thread-place.ts +61 -19
- package/src/server/thread-source.ts +114 -50
- package/src/server/tools/context.ts +95 -112
- package/src/server/tools/describe.ts +10 -35
- package/src/server/tools/export.ts +13 -11
- package/src/server/tools/feedback.ts +47 -22
- package/src/server/tools/place-frame.ts +44 -15
- package/src/server/tools/prototype-name.ts +11 -7
- package/src/server/tools/reading.ts +215 -177
- package/src/server/tools/result.ts +3 -0
- package/src/server/tools/show.ts +35 -12
- package/src/server/tools/snapshot.ts +24 -12
- package/src/server/tools/studio-context.ts +72 -0
- package/src/server/tools/thread-list.ts +58 -43
- package/src/server/tools/watch.ts +230 -81
- package/src/server/unresolved-imports.ts +18 -3
- package/src/server/update-branch.ts +29 -4
- package/src/server/update-studio.ts +54 -20
- package/src/server/updates.ts +55 -9
- package/src/server/vite.ts +154 -29
- package/src/server/web-app.ts +27 -46
- package/src/server/welcome.ts +8 -3
- package/src/server/work-groups.ts +150 -34
- package/src/server/workspace-settings.ts +133 -45
- package/src/server/zip.ts +21 -3
- package/src/setup/apply.ts +132 -40
- package/src/setup/cancelled.ts +7 -0
- package/src/setup/commit-lint.ts +104 -28
- package/src/setup/components.ts +18 -3
- package/src/setup/config-choices.ts +7 -0
- package/src/setup/config-source.ts +226 -61
- package/src/setup/create.ts +281 -64
- package/src/setup/design-md-setup.ts +48 -11
- package/src/setup/design-md.ts +276 -80
- package/src/setup/design-system-checks.ts +70 -12
- package/src/setup/design-system-guide.ts +7 -0
- package/src/setup/detect/workspace.ts +219 -192
- package/src/setup/detect.ts +95 -26
- package/src/setup/doctor.ts +86 -22
- package/src/setup/existing-setup.ts +114 -22
- package/src/setup/git-checks.ts +60 -7
- package/src/setup/hash.ts +5 -0
- package/src/setup/hints.ts +42 -4
- package/src/setup/host-format.ts +31 -7
- package/src/setup/json.ts +23 -0
- package/src/setup/migrate/agent-files.ts +45 -9
- package/src/setup/migrate/config-name.ts +13 -1
- package/src/setup/migrate/design-system.ts +198 -50
- package/src/setup/migrate/dex-folder.ts +145 -30
- package/src/setup/migrate/explorations.ts +7 -3
- package/src/setup/migrate/files-folder.ts +145 -43
- package/src/setup/migrate/frame-notes.ts +253 -0
- package/src/setup/migrate/frame-uids.ts +274 -0
- package/src/setup/migrate/guides.ts +18 -15
- package/src/setup/migrate/manifest-name.ts +183 -0
- package/src/setup/migrate/migrations.ts +28 -6
- package/src/setup/migrate/people-folders.ts +76 -48
- package/src/setup/migrate/picks-file.ts +297 -0
- package/src/setup/migrate/project-files.ts +8 -3
- package/src/setup/migrate/row-titles.ts +8 -4
- package/src/setup/migrate/setup-files.ts +41 -16
- package/src/setup/migrate/studio-state.ts +26 -5
- package/src/setup/own-app.ts +74 -20
- package/src/setup/placement.ts +80 -21
- package/src/setup/plan.ts +96 -17
- package/src/setup/project.ts +75 -11
- package/src/setup/prompts.ts +201 -54
- package/src/setup/provider.ts +20 -2
- package/src/setup/questions.ts +71 -23
- package/src/setup/starters.ts +55 -14
- package/src/setup/templates.ts +66 -20
- package/src/setup/workspace-setup.ts +50 -5
- package/src/setup/write.ts +63 -25
- package/src/shared/agent-prompts.ts +1 -1
- package/src/shared/block-merge.ts +65 -8
- package/src/shared/built-pictures.ts +38 -9
- package/src/shared/canvas-core.ts +596 -153
- package/src/shared/canvas-file.ts +15 -6
- package/src/shared/canvas-merge.ts +784 -0
- package/src/shared/checks.ts +18 -0
- package/src/shared/code-anchor.ts +73 -0
- package/src/shared/commands-core.ts +62 -8
- package/src/shared/comments/routes.ts +7 -5
- package/src/shared/comments/state.ts +146 -0
- package/src/shared/contributors-merge.ts +26 -12
- package/src/shared/devices.ts +63 -16
- package/src/shared/export-core.ts +51 -29
- package/src/shared/feedback.ts +56 -8
- package/src/shared/file-errors.ts +4 -4
- package/src/shared/file-names.ts +528 -0
- package/src/shared/fix-prompt.ts +3 -1
- package/src/shared/frame-grids.ts +33 -8
- package/src/shared/front-matter.ts +24 -7
- package/src/shared/generated-sections.ts +30 -7
- package/src/shared/git-core.ts +40 -14
- package/src/shared/json-style.ts +24 -6
- package/src/shared/listing.ts +1 -0
- package/src/shared/live-core.ts +55 -12
- package/src/shared/live-presence.ts +66 -15
- package/src/shared/markup-prompt.ts +9 -4
- package/src/shared/open-page-core.ts +15 -8
- package/src/shared/page-messages.ts +57 -17
- package/src/shared/page-review.ts +60 -35
- package/src/shared/paste-arrangement.ts +4 -0
- package/src/shared/people-core.ts +251 -59
- package/src/shared/{annotations-core.ts → picks-core.ts} +125 -96
- package/src/shared/prototypes-core.ts +323 -128
- package/src/shared/references-core.ts +20 -8
- package/src/shared/removed-views-core.ts +30 -7
- package/src/shared/review-file.ts +38 -19
- package/src/shared/server-page.ts +13 -5
- package/src/shared/signup.ts +12 -2
- package/src/shared/sketch-core.ts +55 -7
- package/src/shared/snapshot-clipboard.ts +20 -3
- package/src/shared/snapshot-images.ts +114 -14
- package/src/shared/spec-quote.ts +36 -5
- package/src/shared/studio-events.ts +24 -37
- package/src/shared/studio-files.ts +28 -10
- package/src/shared/studio-routes.ts +27 -31
- package/src/shared/threads-core.ts +597 -164
- package/src/shared/unknown-fields.ts +118 -0
- package/src/shared/unzip.ts +22 -8
- package/src/shared/update-core.ts +3 -0
- package/src/shared/word-diff.ts +31 -6
- package/src/shared/xray.ts +14 -0
- package/templates/agents/dex-checker.md +25 -0
- package/templates/agents/dex-riffer.md +16 -0
- package/templates/agents/dex-worker.md +23 -0
- package/templates/feedback-workflow.md +1 -1
- package/templates/methods/handoff.md +1 -1
- package/templates/methods/review.md +7 -3
- package/templates/rules/always.md +1 -1
- package/templates/rules/canvas-frames.md +9 -2
- package/templates/rules/canvas.md +19 -11
- package/templates/rules/prototypes.md +6 -5
- package/templates/rules/scope.md +2 -2
- package/templates/skills/boil/SKILL.md +40 -0
- package/templates/skills/comprehend/SKILL.md +1 -0
- package/templates/skills/distill/SKILL.md +1 -0
- package/templates/skills/export-prototype/SKILL.md +1 -0
- package/templates/skills/restrain/SKILL.md +76 -0
- package/templates/skills/riff/SKILL.md +2 -0
- package/templates/skills/riff-deep/SKILL.md +2 -0
- package/templates/skills/riff-max/SKILL.md +2 -0
- package/templates/skills/riff-state/SKILL.md +2 -0
- package/templates/skills/riff-up/SKILL.md +2 -0
- package/templates/skills/riff-wide/SKILL.md +2 -0
- package/templates/starter-prototype/welcome.tsx +8 -4
- package/templates/starters/standalone/package.json +1 -1
- package/templates/starters/turborepo/apps/web/package.json +1 -1
- package/templates/starters/turborepo/apps/web/src/app.tsx +3 -3
- package/templates/starters/turborepo/apps/web/src/main.tsx +4 -1
- package/templates/starters/turborepo/apps/web/vite.config.ts +2 -1
- package/templates/starters/turborepo/package.json +2 -2
- package/templates/starters/turborepo/packages/ui/package.json +3 -3
- package/templates/starters/vite/package.json +1 -1
- package/templates/starters/vite/src/app.tsx +3 -2
- package/templates/starters/vite/src/components/ui/button.tsx +1 -1
- package/templates/starters/vite/src/index.css +1 -1
- package/templates/starters/vite/src/main.tsx +4 -1
- package/templates/starters/vite/vite.config.ts +2 -1
- package/app/canvas/pass-wheel.ts +0 -48
- package/dist/config/package-manager.d.mts +0 -15
- package/dist/server/agent-env.d.mts +0 -16
- package/dist/server/agents.d.mts +0 -143
- package/dist/server/agents.mjs +0 -786
- package/dist/server/channel.d.mts +0 -239
- package/dist/server/channel.mjs +0 -687
- package/dist/server/mcp-handover.d.mts +0 -37
- package/dist/server/mcp.d.mts +0 -61
- package/dist/server/mcp.mjs +0 -157
- package/dist/server/spec-suggestions.d.mts +0 -21
- package/dist/server/spec-suggestions.mjs +0 -59
- package/dist/setup/desktop-app-script.d.mts +0 -28
- package/dist/setup/desktop-app-script.mjs +0 -775
- package/dist/setup/desktop-app-start.d.mts +0 -65
- package/dist/setup/desktop-app.d.mts +0 -174
- package/dist/setup/desktop-app.mjs +0 -551
- package/dist/shared/element-steps.d.mts +0 -38
- package/dist/shared/element-steps.mjs +0 -40
- package/extension/dist/feedback.html +0 -19
- package/extension/dist/feedback.js +0 -519
- package/src/config/package-manager.ts +0 -93
- package/src/server/agent-env.ts +0 -70
- package/src/server/agents.ts +0 -1251
- package/src/server/channel.ts +0 -1161
- package/src/server/mcp-handover.ts +0 -147
- package/src/server/mcp.ts +0 -295
- package/src/server/spec-suggestions.ts +0 -87
- package/src/setup/desktop-app-script.ts +0 -815
- package/src/setup/desktop-app-start.ts +0 -220
- package/src/setup/desktop-app.ts +0 -849
- package/src/shared/element-steps.ts +0 -99
package/src/server/requests.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* oxlint-disable anti-slop/no-runtime-typeof, anti-slop/no-unknown-parameters -- the studio's routes check request bodies, which come from outside */
|
|
1
2
|
// What the development server answers under /__studio/. It is given the
|
|
2
3
|
// project, its threads, an event hub and an agent launcher, so the Vite
|
|
3
4
|
// plugin only mounts it and tests serve it from a plain Node server, without
|
|
@@ -5,8 +6,27 @@
|
|
|
5
6
|
|
|
6
7
|
import { execFile } from "node:child_process";
|
|
7
8
|
import { existsSync } from "node:fs";
|
|
9
|
+
import { readFile } from "node:fs/promises";
|
|
8
10
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
9
11
|
import { dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
12
|
+
|
|
13
|
+
import { noDesktop, type ProjectDesktop } from "@dexhq/desktop";
|
|
14
|
+
import {
|
|
15
|
+
agentRootOf,
|
|
16
|
+
isLaunchAgent,
|
|
17
|
+
launchAgent,
|
|
18
|
+
addAgent,
|
|
19
|
+
agentSetups,
|
|
20
|
+
} from "@dexhq/harness/agents";
|
|
21
|
+
import {
|
|
22
|
+
connectedAgents,
|
|
23
|
+
isWatching,
|
|
24
|
+
NotAnOldSessionError,
|
|
25
|
+
setWatching,
|
|
26
|
+
stopAgentServer,
|
|
27
|
+
trackAgents,
|
|
28
|
+
} from "@dexhq/harness/channel";
|
|
29
|
+
|
|
10
30
|
import type { ResolvedDesignSystem } from "../config/design-system.ts";
|
|
11
31
|
import { findBiome } from "../content/biome.ts";
|
|
12
32
|
import { saveCaptures } from "../content/capture.ts";
|
|
@@ -23,10 +43,10 @@ import {
|
|
|
23
43
|
duplicatePrototype,
|
|
24
44
|
joinCurrentPerson,
|
|
25
45
|
readCanvasRevision,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type
|
|
29
|
-
|
|
46
|
+
readPrototypePicks,
|
|
47
|
+
removePick,
|
|
48
|
+
type SavedPicks,
|
|
49
|
+
savePick,
|
|
30
50
|
setPrototypeCover,
|
|
31
51
|
setPrototypeStatus,
|
|
32
52
|
setPrototypeTitle,
|
|
@@ -60,28 +80,18 @@ import { editText } from "../content/text-edit.ts";
|
|
|
60
80
|
import { replaceText, undoReplace } from "../content/text-replace.ts";
|
|
61
81
|
import type { ThreadModule } from "../content/thread-module.ts";
|
|
62
82
|
import {
|
|
63
|
-
dismissThreadsOn,
|
|
64
83
|
emptyTrash,
|
|
65
84
|
removedViewsWithComments,
|
|
66
85
|
trashHolds,
|
|
67
86
|
trashViews,
|
|
68
87
|
} from "../content/trash.ts";
|
|
69
|
-
import { type Pasted,
|
|
88
|
+
import { type Pasted, PasteProblemError, readPaste } from "../paste/paste.ts";
|
|
70
89
|
import {
|
|
71
90
|
EXTENSION_DIR,
|
|
72
91
|
isOlder,
|
|
73
92
|
PACKAGE_ROOT,
|
|
74
93
|
runningVersion,
|
|
75
94
|
} from "../paths.ts";
|
|
76
|
-
import {
|
|
77
|
-
bundlePath,
|
|
78
|
-
type DesktopApp,
|
|
79
|
-
type DesktopAppUnavailable,
|
|
80
|
-
desktopAppState,
|
|
81
|
-
installDesktopApp,
|
|
82
|
-
type LaunchServices,
|
|
83
|
-
removeDesktopApp,
|
|
84
|
-
} from "../setup/desktop-app.ts";
|
|
85
95
|
import { checkGitSetup, checkLog, realGitProbes } from "../setup/git-checks.ts";
|
|
86
96
|
import {
|
|
87
97
|
BUILD_DEFAULTS,
|
|
@@ -144,39 +154,43 @@ import {
|
|
|
144
154
|
type StudioMethodOf,
|
|
145
155
|
type StudioRouteName,
|
|
146
156
|
} from "../shared/studio-routes.ts";
|
|
147
|
-
import {
|
|
148
|
-
addAgent,
|
|
149
|
-
agentRootOf,
|
|
150
|
-
agentSetups,
|
|
151
|
-
isLaunchAgent,
|
|
152
|
-
launchAgent,
|
|
153
|
-
} from "./agents.ts";
|
|
157
|
+
import { agentsPlace } from "./agents-place.ts";
|
|
154
158
|
import {
|
|
155
159
|
isAllowedRequest,
|
|
156
160
|
isFromThisMachine,
|
|
157
161
|
isLoopbackHost,
|
|
158
162
|
type ServedHosts,
|
|
159
163
|
} from "./allowed-request.ts";
|
|
160
|
-
import {
|
|
164
|
+
import { AvatarRefusedError, removeAvatar, writeAvatar } from "./avatars.ts";
|
|
161
165
|
import { readBuildSettings, writeBuildSettings } from "./build-settings.ts";
|
|
162
166
|
import { notesSince } from "./changelog.ts";
|
|
163
|
-
import {
|
|
164
|
-
connectedAgents,
|
|
165
|
-
isWatching,
|
|
166
|
-
NotAnOldSession,
|
|
167
|
-
setWatching,
|
|
168
|
-
stopAgentServer,
|
|
169
|
-
trackAgents,
|
|
170
|
-
} from "./channel.ts";
|
|
171
167
|
import {
|
|
172
168
|
codebaseSkills,
|
|
173
169
|
readCommandMenu,
|
|
174
170
|
skillFolders,
|
|
175
171
|
writeCommandMenu,
|
|
176
172
|
} from "./command-settings.ts";
|
|
177
|
-
import {
|
|
173
|
+
import {
|
|
174
|
+
acceptSuggestion,
|
|
175
|
+
dismissCommentsOnViews,
|
|
176
|
+
startComment,
|
|
177
|
+
} from "./comments/actions.ts";
|
|
178
|
+
import {
|
|
179
|
+
answer as commentAnswer,
|
|
180
|
+
COMMENT_HANDLERS,
|
|
181
|
+
personComments,
|
|
182
|
+
} from "./comments/routes.ts";
|
|
178
183
|
import { exportInChild } from "./export/run.ts";
|
|
179
184
|
import { type Feature, features } from "./features.ts";
|
|
185
|
+
import { gitAskBody } from "./git-asks.ts";
|
|
186
|
+
import { forgetPullRequests, mergePullRequest } from "./git-host.ts";
|
|
187
|
+
import { settlePaused, undoPaused } from "./git-paused.ts";
|
|
188
|
+
import { readGitSettings, writeGitSettings } from "./git-settings.ts";
|
|
189
|
+
import {
|
|
190
|
+
moveToPullRequest,
|
|
191
|
+
queueSync,
|
|
192
|
+
switchToSyncBranch,
|
|
193
|
+
} from "./git-sync.ts";
|
|
180
194
|
import {
|
|
181
195
|
branchPrototypes,
|
|
182
196
|
clashesIn,
|
|
@@ -194,15 +208,6 @@ import {
|
|
|
194
208
|
switchBranch,
|
|
195
209
|
syncBranch,
|
|
196
210
|
} from "./git.ts";
|
|
197
|
-
import { gitAskBody } from "./git-asks.ts";
|
|
198
|
-
import { forgetPullRequests, mergePullRequest } from "./git-host.ts";
|
|
199
|
-
import { settlePaused, undoPaused } from "./git-paused.ts";
|
|
200
|
-
import { readGitSettings, writeGitSettings } from "./git-settings.ts";
|
|
201
|
-
import {
|
|
202
|
-
moveToPullRequest,
|
|
203
|
-
queueSync,
|
|
204
|
-
switchToSyncBranch,
|
|
205
|
-
} from "./git-sync.ts";
|
|
206
211
|
import { writeInstructions } from "./instructions.ts";
|
|
207
212
|
import {
|
|
208
213
|
currentActivity,
|
|
@@ -211,7 +216,7 @@ import {
|
|
|
211
216
|
ranBeforeThis,
|
|
212
217
|
updateMachine,
|
|
213
218
|
} from "./machine-update.ts";
|
|
214
|
-
import {
|
|
219
|
+
import { readMe } from "./me.ts";
|
|
215
220
|
import { loadPeople } from "./people.ts";
|
|
216
221
|
import { framePictures, latestAround, latestChange } from "./pictures.ts";
|
|
217
222
|
import { readPreferences, savePreferences } from "./preferences.ts";
|
|
@@ -227,14 +232,21 @@ import {
|
|
|
227
232
|
} from "./restart.ts";
|
|
228
233
|
import { otherServers, readRoster, stopOthers } from "./roster.ts";
|
|
229
234
|
import { readSaved, restoreSaved } from "./saved.ts";
|
|
230
|
-
import { acceptSuggestion } from "./spec-suggestions.ts";
|
|
231
235
|
import { writeFocus } from "./state.ts";
|
|
232
236
|
import { pullBaseAndUpdate, syncAndUpdate } from "./sync-install.ts";
|
|
233
|
-
import {
|
|
234
|
-
|
|
237
|
+
import {
|
|
238
|
+
type Updated,
|
|
239
|
+
UpdateStoppedError,
|
|
240
|
+
updateStudio,
|
|
241
|
+
} from "./update-studio.ts";
|
|
242
|
+
import {
|
|
243
|
+
checkForUpdate,
|
|
244
|
+
checkForUpdateWithin,
|
|
245
|
+
updateCheckProblem,
|
|
246
|
+
} from "./updates.ts";
|
|
235
247
|
import { markWelcomed, readWelcome } from "./welcome.ts";
|
|
236
248
|
import {
|
|
237
|
-
|
|
249
|
+
IconRefusedError,
|
|
238
250
|
readWorkspace,
|
|
239
251
|
readWorkspaceIcon,
|
|
240
252
|
removeWorkspaceIcon,
|
|
@@ -245,13 +257,16 @@ import { zipFolder } from "./zip.ts";
|
|
|
245
257
|
|
|
246
258
|
const PREFIX = "/__studio/";
|
|
247
259
|
const UPDATE_WAIT_MS = 3000;
|
|
248
|
-
const TRAILING_SLASH_RE =
|
|
260
|
+
const TRAILING_SLASH_RE = /\/$/u;
|
|
249
261
|
const METHODS = ["GET", "POST", "PUT", "DELETE"] as const;
|
|
250
262
|
const WITH_BODY = new Set<string>(["POST", "PUT"]);
|
|
251
263
|
export const MAX_BODY_BYTES = 1_000_000;
|
|
252
|
-
|
|
253
|
-
//
|
|
254
|
-
|
|
264
|
+
|
|
265
|
+
// A snapshot copied with the extension brings its images, up to 18 MB of them
|
|
266
|
+
// (packages/extension/messages.ts), and the clipboard carries it all as
|
|
267
|
+
// base64, a third larger again; images pasted or dropped come in whole.
|
|
268
|
+
export const MAX_CAPTURE_BYTES = 40_000_000;
|
|
269
|
+
|
|
255
270
|
// A Markup review brings a snapshot of each page commented on.
|
|
256
271
|
export const MAX_REVIEW_BYTES = 120_000_000;
|
|
257
272
|
const KEEP_ALIVE_MS = 25_000;
|
|
@@ -291,12 +306,14 @@ export type AgentLauncher = (
|
|
|
291
306
|
export type Formatter = (file: string) => Promise<void>;
|
|
292
307
|
|
|
293
308
|
/** Unchecked: each handler checks the fields it relies on. */
|
|
309
|
+
// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- a request body, which each route checks
|
|
294
310
|
type RequestBody = Record<string, unknown>;
|
|
295
311
|
|
|
296
312
|
/**
|
|
297
313
|
* For a body passed on as it came: each prototype change refuses a slug that
|
|
298
314
|
* names none (prototypeExists).
|
|
299
315
|
*/
|
|
316
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- matches any function, to name its first argument's type
|
|
300
317
|
type ArgumentOf<F extends (...args: never[]) => unknown> = Parameters<F>[0];
|
|
301
318
|
|
|
302
319
|
type Method = (typeof METHODS)[number];
|
|
@@ -322,6 +339,7 @@ interface Failure {
|
|
|
322
339
|
}
|
|
323
340
|
|
|
324
341
|
/** The modules routes call throw only Errors. */
|
|
342
|
+
// SAFETY: a thrown value that is no Error reads undefined here, which the message still shows.
|
|
325
343
|
const messageOf = (error: unknown): string => (error as Error).message;
|
|
326
344
|
|
|
327
345
|
const sendJson = (
|
|
@@ -347,6 +365,7 @@ const send = (response: ServerResponse, answered: unknown): void => {
|
|
|
347
365
|
|
|
348
366
|
export function eventHub(): EventHub {
|
|
349
367
|
const listeners = new Set<(event: StudioEvent) => void>();
|
|
368
|
+
|
|
350
369
|
return {
|
|
351
370
|
send: (event) => {
|
|
352
371
|
for (const listener of listeners) {
|
|
@@ -355,6 +374,7 @@ export function eventHub(): EventHub {
|
|
|
355
374
|
},
|
|
356
375
|
listen: (listener) => {
|
|
357
376
|
listeners.add(listener);
|
|
377
|
+
|
|
358
378
|
return () => {
|
|
359
379
|
listeners.delete(listener);
|
|
360
380
|
};
|
|
@@ -373,11 +393,13 @@ const readBody = (
|
|
|
373
393
|
request: IncomingMessage,
|
|
374
394
|
limit = MAX_BODY_BYTES
|
|
375
395
|
): Promise<string> =>
|
|
396
|
+
// oxlint-disable-next-line promise/avoid-new -- reads the stream to its end, keeping its size within the limit as it goes
|
|
376
397
|
new Promise((resolve, reject) => {
|
|
377
398
|
const chunks: Buffer[] = [];
|
|
378
399
|
let size = 0;
|
|
379
400
|
request.on("data", (chunk: Buffer) => {
|
|
380
401
|
size += chunk.length;
|
|
402
|
+
|
|
381
403
|
if (size <= limit) {
|
|
382
404
|
chunks.push(chunk);
|
|
383
405
|
}
|
|
@@ -397,9 +419,11 @@ const readJson = async (
|
|
|
397
419
|
limit?: number
|
|
398
420
|
): Promise<RequestBody | undefined> => {
|
|
399
421
|
const text = await readBody(request, limit);
|
|
422
|
+
|
|
400
423
|
if (!text) {
|
|
401
424
|
return;
|
|
402
425
|
}
|
|
426
|
+
|
|
403
427
|
try {
|
|
404
428
|
return JSON.parse(text);
|
|
405
429
|
} catch {
|
|
@@ -409,12 +433,16 @@ const readJson = async (
|
|
|
409
433
|
|
|
410
434
|
const formatter = (content: string): Formatter => {
|
|
411
435
|
const biome = findBiome(content);
|
|
436
|
+
|
|
412
437
|
return (file) =>
|
|
438
|
+
// oxlint-disable-next-line promise/avoid-new -- resolves whether or not Biome formatted the file
|
|
413
439
|
new Promise((done) => {
|
|
414
440
|
if (!biome) {
|
|
415
441
|
done();
|
|
442
|
+
|
|
416
443
|
return;
|
|
417
444
|
}
|
|
445
|
+
|
|
418
446
|
execFile(biome, ["format", "--write", file], () => done());
|
|
419
447
|
});
|
|
420
448
|
};
|
|
@@ -435,9 +463,11 @@ const UNKNOWN_PROTOTYPE = "Unknown file.";
|
|
|
435
463
|
*/
|
|
436
464
|
const whoChanges = async (content: string): Promise<string> => {
|
|
437
465
|
const person = await joinCurrentPerson(content);
|
|
466
|
+
|
|
438
467
|
if (!person) {
|
|
439
468
|
throw new Problems(403, [NOT_RECOGNISED]);
|
|
440
469
|
}
|
|
470
|
+
|
|
441
471
|
return person.slug;
|
|
442
472
|
};
|
|
443
473
|
|
|
@@ -447,9 +477,11 @@ const prototypeNamed = (
|
|
|
447
477
|
{ mustExist = true }: { mustExist?: boolean } = {}
|
|
448
478
|
): ResolvedPrototype => {
|
|
449
479
|
const prototype = resolvePrototype(content, reference, { mustExist });
|
|
480
|
+
|
|
450
481
|
if (!prototype) {
|
|
451
482
|
throw new Problems(400, [UNKNOWN_PROTOTYPE]);
|
|
452
483
|
}
|
|
484
|
+
|
|
453
485
|
return prototype;
|
|
454
486
|
};
|
|
455
487
|
|
|
@@ -460,8 +492,8 @@ type StudioPages = ReturnType<typeof studioPages>;
|
|
|
460
492
|
|
|
461
493
|
interface RouteContext {
|
|
462
494
|
body: RequestBody | undefined;
|
|
463
|
-
/**
|
|
464
|
-
desktop: () =>
|
|
495
|
+
/** This studio's app, asked as a desktop route answers. */
|
|
496
|
+
desktop: () => ProjectDesktop;
|
|
465
497
|
events: EventHub;
|
|
466
498
|
format: Formatter;
|
|
467
499
|
launcher: AgentLauncher;
|
|
@@ -484,11 +516,13 @@ async function loadCanvas({ project, prototype }: PrototypeContext) {
|
|
|
484
516
|
const { slug } = prototype;
|
|
485
517
|
// Nobody's revision when Dex can't tell who this is: a save asks.
|
|
486
518
|
const person = (await currentPerson(project.content)) ?? "";
|
|
519
|
+
|
|
487
520
|
const { canvas, revision } = await readCanvasRevision(
|
|
488
521
|
slug,
|
|
489
522
|
person,
|
|
490
523
|
project.content
|
|
491
524
|
);
|
|
525
|
+
|
|
492
526
|
return { ...canvas, person, revision };
|
|
493
527
|
}
|
|
494
528
|
|
|
@@ -501,23 +535,28 @@ async function saveCanvas({ project, prototype, body, url }: PrototypeContext) {
|
|
|
501
535
|
const { slug } = prototype;
|
|
502
536
|
const person = await whoChanges(project.content);
|
|
503
537
|
const revision = url.searchParams.get("revision") ?? undefined;
|
|
538
|
+
|
|
504
539
|
const saved = await writeCanvas(
|
|
505
540
|
{ slug, person, canvas: body, revision },
|
|
506
541
|
project.content
|
|
507
542
|
);
|
|
543
|
+
|
|
508
544
|
if (saved.stale) {
|
|
509
545
|
throw new Problems(409, ["The canvas changed since it was read."]);
|
|
510
546
|
}
|
|
547
|
+
|
|
511
548
|
if (saved.problems) {
|
|
512
549
|
throw new Problems(422, saved.problems);
|
|
513
550
|
}
|
|
551
|
+
|
|
514
552
|
const { renamed } = saved;
|
|
553
|
+
|
|
515
554
|
return {
|
|
516
555
|
...saved.canvas,
|
|
517
556
|
person: saved.person,
|
|
518
557
|
revision: saved.revision,
|
|
519
|
-
...(Object.keys(renamed).length > 0
|
|
520
|
-
...(saved.large
|
|
558
|
+
...(Object.keys(renamed).length > 0 && { renamed }),
|
|
559
|
+
...(saved.large && { large: true as const }),
|
|
521
560
|
};
|
|
522
561
|
}
|
|
523
562
|
|
|
@@ -539,60 +578,89 @@ const listRemovedViews = async (context: PrototypeContext) => ({
|
|
|
539
578
|
trash: await trashHolds(context.project.content),
|
|
540
579
|
});
|
|
541
580
|
|
|
581
|
+
/**
|
|
582
|
+
* A view's file as it is on disk, from whoever's folder it is in (viewFiles):
|
|
583
|
+
* what a frame's Copy as React copies.
|
|
584
|
+
*/
|
|
585
|
+
async function loadViewSource({ project, prototype, url }: PrototypeContext) {
|
|
586
|
+
const view = url.searchParams.get("view") ?? "";
|
|
587
|
+
const views = await viewFiles(project.content, prototype.slug);
|
|
588
|
+
const found = views.get(view);
|
|
589
|
+
|
|
590
|
+
// Gone since it was listed: not there either.
|
|
591
|
+
const source =
|
|
592
|
+
found && (await readFile(found.file, "utf8").catch(() => undefined));
|
|
593
|
+
|
|
594
|
+
if (!(found && source !== undefined)) {
|
|
595
|
+
throw new Problems(404, ["That view is not there."]);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
return { source };
|
|
599
|
+
}
|
|
600
|
+
|
|
542
601
|
async function trashRemovedViews(context: PrototypeContext) {
|
|
543
602
|
const { project, prototype, body, threads } = context;
|
|
544
603
|
const { slug } = prototype;
|
|
604
|
+
|
|
605
|
+
// Who moves them, read once: the views go to their folder's owner only,
|
|
606
|
+
// and the comments on them are dismissed in their name.
|
|
607
|
+
const comments = await personComments({ project, threads }, { slug });
|
|
608
|
+
const person = comments.author.id;
|
|
609
|
+
|
|
610
|
+
if (!person) {
|
|
611
|
+
throw new Problems(403, [NOT_RECOGNISED]);
|
|
612
|
+
}
|
|
613
|
+
|
|
545
614
|
const trashed = await trashViews(
|
|
546
|
-
{
|
|
547
|
-
slug,
|
|
548
|
-
person: await whoChanges(project.content),
|
|
549
|
-
views: body?.views,
|
|
550
|
-
},
|
|
615
|
+
{ slug, person, views: body?.views },
|
|
551
616
|
project.content
|
|
552
617
|
);
|
|
618
|
+
|
|
553
619
|
if (trashed.problems) {
|
|
554
620
|
throw new Problems(422, trashed.problems);
|
|
555
621
|
}
|
|
622
|
+
|
|
556
623
|
// The views moved whatever the comments do: a workspace out of reach
|
|
557
624
|
// leaves its threads open, as they were.
|
|
558
|
-
const dismissed = await
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}).catch(() => []);
|
|
625
|
+
const dismissed = await dismissCommentsOnViews(comments, trashed.views).catch(
|
|
626
|
+
() => []
|
|
627
|
+
);
|
|
628
|
+
|
|
563
629
|
return { ...trashed, dismissed };
|
|
564
630
|
}
|
|
565
631
|
|
|
566
632
|
const emptyTheTrash = async ({ project }: RouteContext) => {
|
|
567
633
|
await emptyTrash(project.content);
|
|
634
|
+
|
|
568
635
|
return {};
|
|
569
636
|
};
|
|
570
637
|
|
|
571
|
-
const listConnectedAgents = async ({ project
|
|
572
|
-
agents: await connectedAgents(project.content
|
|
638
|
+
const listConnectedAgents = async ({ project }: RouteContext) => ({
|
|
639
|
+
agents: await connectedAgents(agentsPlace(project.content)),
|
|
573
640
|
});
|
|
574
641
|
|
|
575
642
|
/** Only on this machine, where that process runs. */
|
|
576
|
-
const stopOldAgent = async ({
|
|
577
|
-
project,
|
|
578
|
-
body,
|
|
579
|
-
request,
|
|
580
|
-
threads,
|
|
581
|
-
}: RouteContext) => {
|
|
643
|
+
const stopOldAgent = async ({ project, body, request }: RouteContext) => {
|
|
582
644
|
onlyFromThisMachine(request, "Stop agents from the machine Dex runs on.");
|
|
583
645
|
const pid = body?.pid;
|
|
646
|
+
|
|
584
647
|
if (!(typeof pid === "number" && Number.isInteger(pid))) {
|
|
585
648
|
throw new Problems(422, ["Say which agent to stop, by its process."]);
|
|
586
649
|
}
|
|
650
|
+
|
|
587
651
|
try {
|
|
588
|
-
await stopAgentServer(project.content, pid
|
|
652
|
+
await stopAgentServer(agentsPlace(project.content), pid);
|
|
589
653
|
} catch (error) {
|
|
590
|
-
if (error instanceof
|
|
654
|
+
if (error instanceof NotAnOldSessionError) {
|
|
591
655
|
throw new Problems(409, [error.message]);
|
|
592
656
|
}
|
|
657
|
+
|
|
593
658
|
throw error;
|
|
594
659
|
}
|
|
595
|
-
|
|
660
|
+
|
|
661
|
+
return {
|
|
662
|
+
agents: await connectedAgents(agentsPlace(project.content)),
|
|
663
|
+
};
|
|
596
664
|
};
|
|
597
665
|
|
|
598
666
|
const listAgentSetups = async ({ project }: RouteContext) => ({
|
|
@@ -613,6 +681,7 @@ async function addAgentSetup(context: RouteContext) {
|
|
|
613
681
|
agentRootOf(project.root)
|
|
614
682
|
)
|
|
615
683
|
);
|
|
684
|
+
|
|
616
685
|
return listAgentSetups(context);
|
|
617
686
|
}
|
|
618
687
|
|
|
@@ -620,10 +689,13 @@ async function addAgentSetup(context: RouteContext) {
|
|
|
620
689
|
const openInTerminal = ({ project, launcher, body, request }: RouteContext) => {
|
|
621
690
|
onlyFromThisMachine(request, "Open agents from the machine Dex runs on.");
|
|
622
691
|
const agent = body?.agent;
|
|
692
|
+
|
|
623
693
|
if (!isLaunchAgent(agent)) {
|
|
624
694
|
throw cantOpen(agent);
|
|
625
695
|
}
|
|
696
|
+
|
|
626
697
|
const agentRoot = agentRootOf(project.root);
|
|
698
|
+
|
|
627
699
|
return agentRoot === project.root
|
|
628
700
|
? launcher(agent, project.root)
|
|
629
701
|
: launcher(agent, project.root, agentRoot);
|
|
@@ -637,16 +709,20 @@ const PREFERENCES_ELSEWHERE = "Choose your agent on the machine Dex runs on.";
|
|
|
637
709
|
|
|
638
710
|
const loadPreferences = ({ request }: RouteContext) => {
|
|
639
711
|
onlyFromThisMachine(request, PREFERENCES_ELSEWHERE);
|
|
712
|
+
|
|
640
713
|
return readPreferences();
|
|
641
714
|
};
|
|
642
715
|
|
|
643
716
|
async function savePersonalPreferences({ body, request }: RouteContext) {
|
|
644
717
|
onlyFromThisMachine(request, PREFERENCES_ELSEWHERE);
|
|
645
718
|
const agent = body?.defaultAgent ?? null;
|
|
719
|
+
|
|
646
720
|
if (!(agent === null || isLaunchAgent(agent))) {
|
|
647
721
|
throw cantOpen(agent);
|
|
648
722
|
}
|
|
723
|
+
|
|
649
724
|
await savePreferences({ defaultAgent: agent });
|
|
725
|
+
|
|
650
726
|
return readPreferences();
|
|
651
727
|
}
|
|
652
728
|
|
|
@@ -655,12 +731,14 @@ const WELCOME_ELSEWHERE = "Dex welcomes you on the machine it runs on.";
|
|
|
655
731
|
|
|
656
732
|
function loadWelcome({ project, request }: RouteContext) {
|
|
657
733
|
onlyFromThisMachine(request, WELCOME_ELSEWHERE);
|
|
734
|
+
|
|
658
735
|
return readWelcome(project.content);
|
|
659
736
|
}
|
|
660
737
|
|
|
661
738
|
async function answerWelcome({ body, request }: RouteContext) {
|
|
662
739
|
onlyFromThisMachine(request, WELCOME_ELSEWHERE);
|
|
663
740
|
await markWelcomed(body?.answer === "sent" ? "sent" : "skipped");
|
|
741
|
+
|
|
664
742
|
return {};
|
|
665
743
|
}
|
|
666
744
|
|
|
@@ -684,9 +762,13 @@ function onlyFromThisMachine(request: IncomingMessage, problem: string): void {
|
|
|
684
762
|
}
|
|
685
763
|
}
|
|
686
764
|
|
|
687
|
-
async function loadUpdate({ project }: RouteContext) {
|
|
765
|
+
async function loadUpdate({ project, url }: RouteContext) {
|
|
688
766
|
const machine = await machineState(project);
|
|
767
|
+
const current = machine.installed ?? machine.running;
|
|
768
|
+
// ?fresh=1, from Check for Updates: npm is asked now, and waited on.
|
|
769
|
+
const fresh = url.searchParams.get("fresh") === "1";
|
|
689
770
|
const from = await ranBeforeThis(project.content);
|
|
771
|
+
|
|
690
772
|
const updated =
|
|
691
773
|
from && isOlder(from, runningVersion)
|
|
692
774
|
? {
|
|
@@ -694,35 +776,52 @@ async function loadUpdate({ project }: RouteContext) {
|
|
|
694
776
|
notes: await notesSince(from, runningVersion),
|
|
695
777
|
}
|
|
696
778
|
: undefined;
|
|
779
|
+
|
|
697
780
|
const remote = Boolean(await remoteOf(project.content));
|
|
698
781
|
const share = shareOf(await readGitSettings(project.root));
|
|
782
|
+
|
|
699
783
|
return {
|
|
700
784
|
machine,
|
|
701
|
-
...(updated
|
|
785
|
+
...(updated && { updated }),
|
|
702
786
|
pullRequest: remote && share === "pull-requests",
|
|
703
787
|
restarts: canRestart(),
|
|
704
788
|
run: RUN_ID,
|
|
705
789
|
running: runningVersion,
|
|
706
790
|
syncs: remote && share === "sync",
|
|
707
|
-
update:
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
791
|
+
update: fresh
|
|
792
|
+
? await checkForUpdate(project.content, project.root, {
|
|
793
|
+
current,
|
|
794
|
+
fresh,
|
|
795
|
+
})
|
|
796
|
+
: await checkForUpdateWithin(
|
|
797
|
+
UPDATE_WAIT_MS,
|
|
798
|
+
project.content,
|
|
799
|
+
project.root,
|
|
800
|
+
{ current }
|
|
801
|
+
),
|
|
802
|
+
...(fresh ? await freshProblem(project) : undefined),
|
|
713
803
|
};
|
|
714
804
|
}
|
|
715
805
|
|
|
806
|
+
/** Why npm could not say just now, for a fresh check that it could not. */
|
|
807
|
+
async function freshProblem({ content, root }: ProjectFolders) {
|
|
808
|
+
const problem = await updateCheckProblem(content, root);
|
|
809
|
+
|
|
810
|
+
return problem ? { checkProblem: problem } : {};
|
|
811
|
+
}
|
|
812
|
+
|
|
716
813
|
async function updateThisMachine({ project, request }: RouteContext) {
|
|
717
814
|
onlyFromThisMachine(
|
|
718
815
|
request,
|
|
719
816
|
"Open Dex at localhost on the machine it runs on to update it."
|
|
720
817
|
);
|
|
818
|
+
|
|
721
819
|
return await queueSync(project.content, "step", () => updateMachine(project));
|
|
722
820
|
}
|
|
723
821
|
|
|
724
822
|
const updateActivity = ({ project }: RouteContext) => {
|
|
725
823
|
const doing = currentActivity(project.content);
|
|
824
|
+
|
|
726
825
|
return doing ? { doing } : {};
|
|
727
826
|
};
|
|
728
827
|
|
|
@@ -731,9 +830,10 @@ const updateActivity = ({ project }: RouteContext) => {
|
|
|
731
830
|
* answers the same route while no Dex does.
|
|
732
831
|
*/
|
|
733
832
|
async function restartStatus({ project }: RouteContext) {
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
);
|
|
833
|
+
const listed = await openPresence(project.content).list();
|
|
834
|
+
|
|
835
|
+
const working = listed.some((entry) => !isTeammate(entry));
|
|
836
|
+
|
|
737
837
|
return { state: "ready" as const, run: RUN_ID, agentWorking: working };
|
|
738
838
|
}
|
|
739
839
|
|
|
@@ -742,15 +842,19 @@ async function restartStudio({ project, request }: RouteContext) {
|
|
|
742
842
|
request,
|
|
743
843
|
"Open Dex at localhost on the machine it runs on to restart it."
|
|
744
844
|
);
|
|
845
|
+
|
|
745
846
|
if (orphaned()) {
|
|
746
847
|
throw new Problems(409, [ORPHANED_LINE]);
|
|
747
848
|
}
|
|
849
|
+
|
|
748
850
|
if (!canRestart()) {
|
|
749
851
|
throw new Problems(409, [
|
|
750
852
|
"This Dex can’t restart itself. Stop it and start it again.",
|
|
751
853
|
]);
|
|
752
854
|
}
|
|
855
|
+
|
|
753
856
|
await restartWhenIdle(project.content);
|
|
857
|
+
|
|
754
858
|
return { restartingFrom: RUN_ID };
|
|
755
859
|
}
|
|
756
860
|
|
|
@@ -765,6 +869,7 @@ async function stopOtherDexes({ project, request }: RouteContext) {
|
|
|
765
869
|
request,
|
|
766
870
|
"Open Dex at localhost on the machine it runs on to stop other Dexes."
|
|
767
871
|
);
|
|
872
|
+
|
|
768
873
|
return {
|
|
769
874
|
stopped: await stopOthers(project.content, projectId(project.root)),
|
|
770
875
|
};
|
|
@@ -777,12 +882,13 @@ async function updateFromNotice({ project, events, request }: RouteContext) {
|
|
|
777
882
|
);
|
|
778
883
|
const settings = await readGitSettings(project.root);
|
|
779
884
|
let updated: Updated | null;
|
|
885
|
+
|
|
780
886
|
try {
|
|
781
887
|
updated = await queueSync(project.content, "step", () =>
|
|
782
888
|
updateStudio({ content: project.content, root: project.root, settings })
|
|
783
889
|
);
|
|
784
890
|
} catch (error) {
|
|
785
|
-
throw new Problems(error instanceof
|
|
891
|
+
throw new Problems(error instanceof UpdateStoppedError ? 409 : 500, [
|
|
786
892
|
messageOf(error),
|
|
787
893
|
]);
|
|
788
894
|
} finally {
|
|
@@ -790,29 +896,18 @@ async function updateFromNotice({ project, events, request }: RouteContext) {
|
|
|
790
896
|
// It synced: every page's branch and changes move.
|
|
791
897
|
events.send(studioEvent.git());
|
|
792
898
|
}
|
|
899
|
+
|
|
793
900
|
if (!updated) {
|
|
794
901
|
throw new Problems(409, ["Dex is already up to date."]);
|
|
795
902
|
}
|
|
903
|
+
|
|
796
904
|
if (updated.restartingFrom) {
|
|
797
905
|
restartWhenIdle(project.content);
|
|
798
906
|
}
|
|
907
|
+
|
|
799
908
|
return updated;
|
|
800
909
|
}
|
|
801
910
|
|
|
802
|
-
/**
|
|
803
|
-
* `home` is the folder whose Applications the app goes in; `launchServices`
|
|
804
|
-
* registers its URL scheme, and forgets it on remove.
|
|
805
|
-
*/
|
|
806
|
-
export type DesktopAppHost =
|
|
807
|
-
| {
|
|
808
|
-
app: DesktopApp;
|
|
809
|
-
home: string;
|
|
810
|
-
launchServices: LaunchServices;
|
|
811
|
-
open: (path: string) => Promise<void>;
|
|
812
|
-
reveal: (path: string) => Promise<void>;
|
|
813
|
-
}
|
|
814
|
-
| { unavailable: DesktopAppUnavailable };
|
|
815
|
-
|
|
816
911
|
/**
|
|
817
912
|
* The app writes outside the project and makes something that runs code, so
|
|
818
913
|
* only this machine, addressed by a loopback name, may ask; and a change
|
|
@@ -821,73 +916,44 @@ export type DesktopAppHost =
|
|
|
821
916
|
*/
|
|
822
917
|
function fromThisMac(request: IncomingMessage, change: boolean): void {
|
|
823
918
|
onlyFromThisMachine(request, "Install the app from the Mac Dex runs on.");
|
|
919
|
+
|
|
824
920
|
if (change && !request.headers.origin) {
|
|
825
921
|
throw new Problems(403, ["Install the app from Dex's Settings."]);
|
|
826
922
|
}
|
|
827
923
|
}
|
|
828
924
|
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
? { available: false, why: desktop.unavailable }
|
|
834
|
-
: {
|
|
835
|
-
available: true,
|
|
836
|
-
...(await desktopAppState(desktop.app, desktop.home)),
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
const loadDesktopApp = ({ request, desktop }: RouteContext) => {
|
|
925
|
+
const loadDesktopApp = ({
|
|
926
|
+
request,
|
|
927
|
+
desktop,
|
|
928
|
+
}: RouteContext): Promise<DesktopAppAnswer> => {
|
|
840
929
|
fromThisMac(request, false);
|
|
841
|
-
|
|
930
|
+
|
|
931
|
+
return desktop().answer();
|
|
842
932
|
};
|
|
843
933
|
|
|
844
|
-
|
|
934
|
+
const changeDesktopApp = ({
|
|
935
|
+
request,
|
|
936
|
+
desktop,
|
|
937
|
+
body,
|
|
938
|
+
}: RouteContext): Promise<DesktopAppAnswer> => {
|
|
845
939
|
fromThisMac(request, true);
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
: "Installing outside the browser is macOS-only for now.",
|
|
852
|
-
]);
|
|
853
|
-
}
|
|
854
|
-
const { app, home, reveal, open, launchServices } = host;
|
|
855
|
-
switch (body?.action) {
|
|
856
|
-
case "install": {
|
|
857
|
-
const path = await refusable(() =>
|
|
858
|
-
installDesktopApp(app, home, launchServices)
|
|
859
|
-
);
|
|
860
|
-
await reveal(path).catch(() => undefined);
|
|
861
|
-
break;
|
|
862
|
-
}
|
|
863
|
-
case "open": {
|
|
864
|
-
if (!(await desktopAppState(app, home)).installed) {
|
|
865
|
-
throw new Problems(409, ["Install the app first."]);
|
|
866
|
-
}
|
|
867
|
-
await refusable(() => open(bundlePath(home)));
|
|
868
|
-
break;
|
|
869
|
-
}
|
|
870
|
-
case "remove":
|
|
871
|
-
await refusable(() => removeDesktopApp(app, home, launchServices));
|
|
872
|
-
break;
|
|
873
|
-
default:
|
|
874
|
-
throw new Problems(400, [
|
|
875
|
-
'Send an action: "install", "open" or "remove".',
|
|
876
|
-
]);
|
|
877
|
-
}
|
|
878
|
-
return desktopAnswer(host);
|
|
879
|
-
}
|
|
940
|
+
const action = body?.action;
|
|
941
|
+
|
|
942
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- a JSON body's action is whatever was sent
|
|
943
|
+
return desktop().change(typeof action === "string" ? action : undefined);
|
|
944
|
+
};
|
|
880
945
|
|
|
881
946
|
const readWatch = async ({ project }: RouteContext) => ({
|
|
882
|
-
on: await isWatching(project.content),
|
|
947
|
+
on: await isWatching(agentsPlace(project.content)),
|
|
883
948
|
});
|
|
884
949
|
|
|
885
950
|
/** Every open page hears it, so each switch shows the same. */
|
|
886
951
|
const setWatch = ({ project, body, events, pages }: RouteContext) =>
|
|
887
952
|
pages.inWatchOrder(async () => {
|
|
888
|
-
await setWatching(project.content, Boolean(body?.on));
|
|
889
|
-
const on = await isWatching(project.content);
|
|
953
|
+
await setWatching(agentsPlace(project.content), Boolean(body?.on));
|
|
954
|
+
const on = await isWatching(agentsPlace(project.content));
|
|
890
955
|
events.send(studioEvent.watch(on));
|
|
956
|
+
|
|
891
957
|
return { on };
|
|
892
958
|
});
|
|
893
959
|
|
|
@@ -906,46 +972,55 @@ async function saveSnapshots(
|
|
|
906
972
|
cell?: Cell
|
|
907
973
|
) {
|
|
908
974
|
const person = await whoChanges(project.content);
|
|
909
|
-
|
|
910
|
-
//
|
|
975
|
+
|
|
976
|
+
// No captured event: the page that pasted goes to what it made itself.
|
|
911
977
|
return await refusable(() =>
|
|
912
978
|
saveCaptures({ slug: target.slug, person, captures, cell }, project.content)
|
|
913
979
|
);
|
|
914
980
|
}
|
|
915
981
|
|
|
916
982
|
const cellFrom = (value: unknown): Cell | undefined => {
|
|
983
|
+
// SAFETY: each field is checked below before the value is taken as a Cell.
|
|
984
|
+
// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- a request body, checked field by field below
|
|
917
985
|
const cell = value as Partial<Record<keyof Cell, unknown>> | undefined;
|
|
986
|
+
|
|
918
987
|
const fits =
|
|
919
988
|
typeof cell?.section === "string" &&
|
|
920
989
|
(cell.row === undefined || typeof cell.row === "string") &&
|
|
921
990
|
typeof cell.step === "number" &&
|
|
922
991
|
Number.isInteger(cell.step) &&
|
|
923
992
|
cell.step >= 1;
|
|
993
|
+
|
|
994
|
+
// SAFETY: fits checked every field a Cell has.
|
|
924
995
|
return fits ? (cell as Cell) : undefined;
|
|
925
996
|
};
|
|
926
997
|
|
|
927
998
|
async function pasteSnapshots(context: RouteContext) {
|
|
928
999
|
const { body } = context;
|
|
929
1000
|
let pasted: Pasted;
|
|
1001
|
+
|
|
930
1002
|
try {
|
|
931
1003
|
pasted = await readPaste(body ?? {});
|
|
932
1004
|
} catch (error) {
|
|
933
|
-
if (error instanceof
|
|
1005
|
+
if (error instanceof PasteProblemError) {
|
|
934
1006
|
throw new Problems(error.status, [error.message]);
|
|
935
1007
|
}
|
|
1008
|
+
|
|
936
1009
|
throw error;
|
|
937
1010
|
}
|
|
1011
|
+
|
|
938
1012
|
const { saved, large } = await saveSnapshots(
|
|
939
1013
|
context,
|
|
940
1014
|
body ?? {},
|
|
941
1015
|
pasted.captures,
|
|
942
1016
|
cellFrom(body?.cell)
|
|
943
1017
|
);
|
|
1018
|
+
|
|
944
1019
|
return {
|
|
945
1020
|
from: pasted.from,
|
|
946
1021
|
saved: saved.map(({ name, frame }) => ({ name, frame })),
|
|
947
1022
|
images: pasted.images,
|
|
948
|
-
...(large
|
|
1023
|
+
...(large && { large: true as const }),
|
|
949
1024
|
};
|
|
950
1025
|
}
|
|
951
1026
|
|
|
@@ -957,10 +1032,13 @@ async function pasteSnapshots(context: RouteContext) {
|
|
|
957
1032
|
function showOnCanvas({ project, events, pages, body }: RouteContext) {
|
|
958
1033
|
const { slug } = prototypeNamed(project.content, body ?? {});
|
|
959
1034
|
const frame = body?.frame;
|
|
1035
|
+
|
|
960
1036
|
if (typeof frame !== "string" || frame.split("/").length !== 3) {
|
|
961
1037
|
throw new Problems(400, ['Say which frame, as "section/row/frame".']);
|
|
962
1038
|
}
|
|
1039
|
+
|
|
963
1040
|
events.send(studioEvent.show(slug, frame));
|
|
1041
|
+
|
|
964
1042
|
return { pages: pages.listening() };
|
|
965
1043
|
}
|
|
966
1044
|
|
|
@@ -970,43 +1048,58 @@ function showOnCanvas({ project, events, pages, body }: RouteContext) {
|
|
|
970
1048
|
*/
|
|
971
1049
|
async function addBlankFrame({ project, events, body }: RouteContext) {
|
|
972
1050
|
const { slug, view, frame, canvas, component, reveal } = body ?? {};
|
|
1051
|
+
|
|
973
1052
|
if (!(isSlug(slug) && isSlug(view)) || typeof frame !== "string") {
|
|
974
1053
|
throw new Problems(400, ["Say where the frame goes."]);
|
|
975
1054
|
}
|
|
1055
|
+
|
|
976
1056
|
if (component !== undefined) {
|
|
977
1057
|
needsFeature("stickers");
|
|
978
1058
|
}
|
|
1059
|
+
|
|
979
1060
|
if (
|
|
980
1061
|
component !== undefined &&
|
|
1062
|
+
// SAFETY: isInsertable checks every field.
|
|
981
1063
|
!isInsertable(component as Partial<InsertedComponent>)
|
|
982
1064
|
) {
|
|
983
1065
|
throw new Problems(400, ["That is not a component the studio can add."]);
|
|
984
1066
|
}
|
|
1067
|
+
|
|
1068
|
+
// SAFETY: isInsertable checked it just above.
|
|
985
1069
|
const source =
|
|
986
1070
|
component === undefined
|
|
987
1071
|
? BLANK_VIEW
|
|
988
1072
|
: componentView(component as InsertedComponent);
|
|
1073
|
+
|
|
989
1074
|
prototypeNamed(project.content, { slug });
|
|
990
|
-
|
|
1075
|
+
|
|
1076
|
+
const views = await viewFiles(project.content, slug);
|
|
1077
|
+
|
|
1078
|
+
if (views.has(view)) {
|
|
991
1079
|
throw new Problems(409, ["That view already exists."]);
|
|
992
1080
|
}
|
|
1081
|
+
|
|
993
1082
|
const person = await whoChanges(project.content);
|
|
1083
|
+
|
|
994
1084
|
const saved = await writeCanvas(
|
|
995
1085
|
{ slug, person, canvas, views: { [view]: source } },
|
|
996
1086
|
project.content
|
|
997
1087
|
);
|
|
1088
|
+
|
|
998
1089
|
if (saved.problems) {
|
|
999
1090
|
throw new Problems(422, saved.problems);
|
|
1000
1091
|
}
|
|
1092
|
+
|
|
1001
1093
|
// Before the studio reloads to find the view, so the canvas shows it; not
|
|
1002
1094
|
// for a frame drawn where the person is looking.
|
|
1003
1095
|
if (reveal !== false) {
|
|
1004
1096
|
events.send(studioEvent.captured(slug, frame));
|
|
1005
1097
|
}
|
|
1098
|
+
|
|
1006
1099
|
return {
|
|
1007
1100
|
view,
|
|
1008
1101
|
frame,
|
|
1009
|
-
...(saved.canvas && saved.large
|
|
1102
|
+
...(saved.canvas && saved.large && { large: true as const }),
|
|
1010
1103
|
};
|
|
1011
1104
|
}
|
|
1012
1105
|
|
|
@@ -1017,11 +1110,13 @@ async function addBlankFrame({ project, events, body }: RouteContext) {
|
|
|
1017
1110
|
*/
|
|
1018
1111
|
async function changeText({ project, body }: RouteContext) {
|
|
1019
1112
|
const { folder, slug } = prototypeNamed(project.content, body ?? {});
|
|
1113
|
+
|
|
1020
1114
|
const own = join(
|
|
1021
1115
|
folder,
|
|
1022
1116
|
STUDIO_FILES.people,
|
|
1023
1117
|
await whoChanges(project.content)
|
|
1024
1118
|
);
|
|
1119
|
+
|
|
1025
1120
|
// The text as the canvas sends it; editText checks there is some.
|
|
1026
1121
|
const result = await editText(
|
|
1027
1122
|
{ content: project.content, own, slug },
|
|
@@ -1031,9 +1126,11 @@ async function changeText({ project, body }: RouteContext) {
|
|
|
1031
1126
|
place: typeof body?.place === "string" ? body.place : undefined,
|
|
1032
1127
|
}
|
|
1033
1128
|
);
|
|
1129
|
+
|
|
1034
1130
|
if (!("file" in result)) {
|
|
1035
1131
|
throw new Problems(409, [result.reason]);
|
|
1036
1132
|
}
|
|
1133
|
+
|
|
1037
1134
|
return result;
|
|
1038
1135
|
}
|
|
1039
1136
|
|
|
@@ -1044,20 +1141,27 @@ async function changeText({ project, body }: RouteContext) {
|
|
|
1044
1141
|
*/
|
|
1045
1142
|
async function replaceOnCanvas({ project, body }: RouteContext) {
|
|
1046
1143
|
const { folder } = prototypeNamed(project.content, body ?? {});
|
|
1144
|
+
|
|
1047
1145
|
const own = join(
|
|
1048
1146
|
folder,
|
|
1049
1147
|
STUDIO_FILES.people,
|
|
1050
1148
|
await whoChanges(project.content)
|
|
1051
1149
|
);
|
|
1150
|
+
|
|
1052
1151
|
if (typeof body?.undo === "string") {
|
|
1053
1152
|
return await undoReplace(own, body.undo);
|
|
1054
1153
|
}
|
|
1154
|
+
|
|
1055
1155
|
const { find, to, seen } = body ?? {};
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1156
|
+
|
|
1157
|
+
if (!(
|
|
1158
|
+
typeof find === "string" &&
|
|
1159
|
+
typeof to === "string" &&
|
|
1160
|
+
Array.isArray(seen)
|
|
1161
|
+
)) {
|
|
1059
1162
|
throw new Problems(400, ["Say what to find, and what to change it to."]);
|
|
1060
1163
|
}
|
|
1164
|
+
|
|
1061
1165
|
return await replaceText(
|
|
1062
1166
|
own,
|
|
1063
1167
|
find,
|
|
@@ -1072,36 +1176,35 @@ const needsFeature = (name: Feature) => {
|
|
|
1072
1176
|
}
|
|
1073
1177
|
};
|
|
1074
1178
|
|
|
1075
|
-
async function
|
|
1076
|
-
const {
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
);
|
|
1080
|
-
return { annotations };
|
|
1179
|
+
async function loadPicks({ project, prototype }: PrototypeContext) {
|
|
1180
|
+
const { picks } = await readPrototypePicks(prototype.slug, project.content);
|
|
1181
|
+
|
|
1182
|
+
return { picks };
|
|
1081
1183
|
}
|
|
1082
1184
|
|
|
1083
|
-
const
|
|
1185
|
+
const savedPicks = (saved: SavedPicks) => {
|
|
1084
1186
|
if (saved.problems) {
|
|
1085
1187
|
throw new Problems(422, saved.problems);
|
|
1086
1188
|
}
|
|
1087
|
-
|
|
1189
|
+
|
|
1190
|
+
return { picks: saved.picks };
|
|
1088
1191
|
};
|
|
1089
1192
|
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
await
|
|
1193
|
+
const saveOwnPick = async (context: PrototypeContext) =>
|
|
1194
|
+
savedPicks(
|
|
1195
|
+
await savePick(
|
|
1093
1196
|
{
|
|
1094
1197
|
slug: context.prototype.slug,
|
|
1095
1198
|
person: await whoChanges(context.project.content),
|
|
1096
|
-
|
|
1199
|
+
pick: context.body,
|
|
1097
1200
|
},
|
|
1098
1201
|
context.project.content
|
|
1099
1202
|
)
|
|
1100
1203
|
);
|
|
1101
1204
|
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1104
|
-
await
|
|
1205
|
+
const removeOwnPick = async (context: PrototypeContext) =>
|
|
1206
|
+
savedPicks(
|
|
1207
|
+
await removePick(
|
|
1105
1208
|
{
|
|
1106
1209
|
slug: context.prototype.slug,
|
|
1107
1210
|
person: await whoChanges(context.project.content),
|
|
@@ -1115,17 +1218,21 @@ const removeOwnAnnotation = async (context: PrototypeContext) =>
|
|
|
1115
1218
|
async function changeProps({ project, body }: RouteContext) {
|
|
1116
1219
|
needsFeature("inspector");
|
|
1117
1220
|
const { folder } = prototypeNamed(project.content, body ?? {});
|
|
1221
|
+
|
|
1118
1222
|
const result = await editProps(
|
|
1119
1223
|
project.content,
|
|
1120
1224
|
folder,
|
|
1121
1225
|
typeof body?.place === "string" ? body.place : undefined,
|
|
1226
|
+
// SAFETY: an object of prop changes; editProps checks each.
|
|
1122
1227
|
body?.props && typeof body.props === "object"
|
|
1123
1228
|
? (body.props as Record<string, PropChange>)
|
|
1124
1229
|
: undefined
|
|
1125
1230
|
);
|
|
1231
|
+
|
|
1126
1232
|
if (!("file" in result)) {
|
|
1127
1233
|
throw new Problems(409, [result.reason]);
|
|
1128
1234
|
}
|
|
1235
|
+
|
|
1129
1236
|
return result;
|
|
1130
1237
|
}
|
|
1131
1238
|
|
|
@@ -1133,16 +1240,20 @@ async function changeProps({ project, body }: RouteContext) {
|
|
|
1133
1240
|
async function insertIntoView({ project, body }: RouteContext) {
|
|
1134
1241
|
needsFeature("stickers");
|
|
1135
1242
|
const { folder } = prototypeNamed(project.content, body ?? {});
|
|
1243
|
+
|
|
1136
1244
|
const result = await insertComponent(
|
|
1137
1245
|
project.content,
|
|
1138
1246
|
folder,
|
|
1139
1247
|
typeof body?.place === "string" ? body.place : undefined,
|
|
1140
1248
|
typeof body?.position === "string" ? body.position : undefined,
|
|
1249
|
+
// SAFETY: insertComponent checks it with isInsertable.
|
|
1141
1250
|
body?.component as Partial<InsertedComponent> | undefined
|
|
1142
1251
|
);
|
|
1252
|
+
|
|
1143
1253
|
if (!("file" in result)) {
|
|
1144
1254
|
throw new Problems(409, [result.reason]);
|
|
1145
1255
|
}
|
|
1256
|
+
|
|
1146
1257
|
return result;
|
|
1147
1258
|
}
|
|
1148
1259
|
|
|
@@ -1150,16 +1261,21 @@ function shotOf({ request, body, pageBase }: RouteContext) {
|
|
|
1150
1261
|
if (!body) {
|
|
1151
1262
|
throw new Problems(400, ["Say which view to capture."]);
|
|
1152
1263
|
}
|
|
1264
|
+
|
|
1153
1265
|
const site = `http://localhost:${request.socket.localPort}${pageBase}`;
|
|
1266
|
+
|
|
1154
1267
|
return screenshotFrame(site, body);
|
|
1155
1268
|
}
|
|
1156
1269
|
|
|
1157
1270
|
async function screenshotView(context: RouteContext) {
|
|
1158
|
-
|
|
1271
|
+
const shot = await shotOf(context);
|
|
1272
|
+
|
|
1273
|
+
return new Reply(200, shot.image, "image/png");
|
|
1159
1274
|
}
|
|
1160
1275
|
|
|
1161
1276
|
async function snapshotOfView(context: RouteContext): Promise<SnapshotBody> {
|
|
1162
1277
|
const { image, problems } = await shotOf(context);
|
|
1278
|
+
|
|
1163
1279
|
return { image: image.toString("base64"), problems };
|
|
1164
1280
|
}
|
|
1165
1281
|
|
|
@@ -1197,19 +1313,22 @@ async function pictureOfView({
|
|
|
1197
1313
|
response,
|
|
1198
1314
|
}: RouteContext) {
|
|
1199
1315
|
const href = typeof body?.href === "string" ? body.href : "";
|
|
1316
|
+
|
|
1200
1317
|
if (!(body && isViewPage(href))) {
|
|
1201
1318
|
throw new Problems(400, ["Say which view to picture."]);
|
|
1202
1319
|
}
|
|
1320
|
+
|
|
1203
1321
|
const { folder } = prototypeNamed(project.content, href);
|
|
1204
1322
|
const address = viewInFrame(href);
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
) {
|
|
1323
|
+
|
|
1324
|
+
const views = address
|
|
1325
|
+
? await viewFiles(project.content, address.slug)
|
|
1326
|
+
: undefined;
|
|
1327
|
+
|
|
1328
|
+
if (!(address && views?.has(address.view))) {
|
|
1211
1329
|
throw new Problems(NOT_THERE, ["That view is not there yet."]);
|
|
1212
1330
|
}
|
|
1331
|
+
|
|
1213
1332
|
const stamp = Math.max(
|
|
1214
1333
|
await latestChange(
|
|
1215
1334
|
project.content,
|
|
@@ -1220,19 +1339,26 @@ async function pictureOfView({
|
|
|
1220
1339
|
skip: [project.content],
|
|
1221
1340
|
})
|
|
1222
1341
|
);
|
|
1342
|
+
|
|
1223
1343
|
response.setHeader("X-Studio-Stamp", String(stamp));
|
|
1344
|
+
|
|
1224
1345
|
if (Number(body.stamp) === stamp) {
|
|
1225
1346
|
return new Reply(204, "", "image/jpeg");
|
|
1226
1347
|
}
|
|
1348
|
+
|
|
1227
1349
|
if (body.stamp === undefined) {
|
|
1228
1350
|
const last = await pictures.last(body, project.content);
|
|
1351
|
+
|
|
1229
1352
|
if (last && last.stamp !== stamp) {
|
|
1230
1353
|
response.setHeader("X-Studio-Stamp", String(last.stamp));
|
|
1231
1354
|
response.setHeader(STALE_PICTURE_HEADER, "1");
|
|
1355
|
+
|
|
1232
1356
|
return new Reply(200, last.image, "image/jpeg");
|
|
1233
1357
|
}
|
|
1234
1358
|
}
|
|
1359
|
+
|
|
1235
1360
|
const site = `http://localhost:${request.socket.localPort}${pageBase}`;
|
|
1361
|
+
|
|
1236
1362
|
return new Reply(
|
|
1237
1363
|
200,
|
|
1238
1364
|
await pictures.picture(site, body, stamp, project.content),
|
|
@@ -1261,47 +1387,59 @@ async function reviewFileOf(
|
|
|
1261
1387
|
> {
|
|
1262
1388
|
if (!isPageReview(file)) {
|
|
1263
1389
|
const read = parseReviewFile(file);
|
|
1390
|
+
|
|
1264
1391
|
return read.review
|
|
1265
1392
|
? { review: read.review }
|
|
1266
1393
|
: { problems: [REVIEW_FILE_PROBLEMS[read.problem]] };
|
|
1267
1394
|
}
|
|
1395
|
+
|
|
1268
1396
|
const read = parsePageReview(file);
|
|
1397
|
+
|
|
1269
1398
|
if (!read.review) {
|
|
1270
1399
|
return { problems: [PAGE_REVIEW_PROBLEMS[read.problem]] };
|
|
1271
1400
|
}
|
|
1401
|
+
|
|
1272
1402
|
const person = await whoChanges(content);
|
|
1403
|
+
|
|
1273
1404
|
const placed = await refusable(() =>
|
|
1274
1405
|
placeReviewPages({ slug, person, review: read.review }, content)
|
|
1275
1406
|
);
|
|
1407
|
+
|
|
1276
1408
|
return { review: placed.file, pages: placed.added };
|
|
1277
1409
|
}
|
|
1278
1410
|
|
|
1279
1411
|
async function importReviews({ project, url, body, threads }: RouteContext) {
|
|
1280
1412
|
const { slug: prototype } = prototypeOf(project.content, url);
|
|
1281
1413
|
const files: unknown = body?.reviews;
|
|
1414
|
+
|
|
1282
1415
|
if (!Array.isArray(files) || files.length === 0) {
|
|
1283
1416
|
throw new Problems(400, ["Send the reviews to import."]);
|
|
1284
1417
|
}
|
|
1418
|
+
|
|
1285
1419
|
const reviews: ReviewImported[] = [];
|
|
1420
|
+
|
|
1286
1421
|
for (const file of files) {
|
|
1287
1422
|
const read = await reviewFileOf(project.content, prototype, file);
|
|
1423
|
+
|
|
1288
1424
|
if (!read.review) {
|
|
1289
1425
|
reviews.push({ problems: read.problems });
|
|
1290
1426
|
continue;
|
|
1291
1427
|
}
|
|
1292
|
-
|
|
1428
|
+
|
|
1429
|
+
const imported = await threads.importReview(prototype, read.review);
|
|
1293
1430
|
reviews.push(
|
|
1294
|
-
|
|
1295
|
-
? { problems:
|
|
1431
|
+
imported.problems
|
|
1432
|
+
? { problems: imported.problems }
|
|
1296
1433
|
: {
|
|
1297
1434
|
title: read.review.review.title,
|
|
1298
1435
|
reviewer: read.review.reviewer.name,
|
|
1299
|
-
added:
|
|
1300
|
-
skipped:
|
|
1301
|
-
...(read.pages
|
|
1436
|
+
added: imported.added,
|
|
1437
|
+
skipped: imported.skipped,
|
|
1438
|
+
...(read.pages && { pages: read.pages }),
|
|
1302
1439
|
}
|
|
1303
1440
|
);
|
|
1304
1441
|
}
|
|
1442
|
+
|
|
1305
1443
|
return { reviews };
|
|
1306
1444
|
}
|
|
1307
1445
|
|
|
@@ -1312,34 +1450,32 @@ async function acceptSpecSuggestion({
|
|
|
1312
1450
|
threads,
|
|
1313
1451
|
}: RouteContext) {
|
|
1314
1452
|
const id = body?.id;
|
|
1453
|
+
|
|
1315
1454
|
if (typeof id !== "string") {
|
|
1316
1455
|
throw new Problems(400, ["Name the suggestion to accept."]);
|
|
1317
1456
|
}
|
|
1318
|
-
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
threads,
|
|
1326
|
-
});
|
|
1327
|
-
if ("problems" in result) {
|
|
1328
|
-
throw new Problems(result.status, result.problems);
|
|
1329
|
-
}
|
|
1330
|
-
return result.thread;
|
|
1457
|
+
|
|
1458
|
+
const comments = await personComments(
|
|
1459
|
+
{ project, threads },
|
|
1460
|
+
{ slug: url.searchParams.get("slug") }
|
|
1461
|
+
);
|
|
1462
|
+
|
|
1463
|
+
return commentAnswer(await acceptSuggestion(comments, id));
|
|
1331
1464
|
}
|
|
1332
1465
|
|
|
1333
1466
|
const instructionsPath = (url: URL): string => {
|
|
1334
1467
|
const path = url.searchParams.get("path");
|
|
1468
|
+
|
|
1335
1469
|
if (!(path && isEditableMarkdown(path))) {
|
|
1336
1470
|
throw new Problems(400, ["That file is not one of the guidelines."]);
|
|
1337
1471
|
}
|
|
1472
|
+
|
|
1338
1473
|
return path;
|
|
1339
1474
|
};
|
|
1340
1475
|
|
|
1341
1476
|
const loadInstructions = async ({ project, url }: RouteContext) => {
|
|
1342
1477
|
const path = instructionsPath(url);
|
|
1478
|
+
|
|
1343
1479
|
return { path, source: await readText(join(project.content, path)) };
|
|
1344
1480
|
};
|
|
1345
1481
|
|
|
@@ -1356,14 +1492,17 @@ async function saveInstructions({ project, url, body }: RouteContext) {
|
|
|
1356
1492
|
const part = splitPrototypePath(path);
|
|
1357
1493
|
const isSomeonesFile = owner !== undefined || part !== undefined;
|
|
1358
1494
|
const person = isSomeonesFile ? await whoChanges(project.content) : undefined;
|
|
1495
|
+
|
|
1359
1496
|
if (owner && owner !== person) {
|
|
1360
1497
|
throw new Problems(403, ["Those are someone else's guidelines."]);
|
|
1361
1498
|
}
|
|
1499
|
+
|
|
1362
1500
|
// A spec or a document anyone edits: a change made meanwhile is merged
|
|
1363
1501
|
// in, not lost.
|
|
1364
1502
|
const source = await refusable(() =>
|
|
1365
1503
|
writeInstructions(project.content, path, body?.source, body?.base)
|
|
1366
1504
|
);
|
|
1505
|
+
|
|
1367
1506
|
return { path, source };
|
|
1368
1507
|
}
|
|
1369
1508
|
|
|
@@ -1378,19 +1517,23 @@ const GIT_ELSEWHERE =
|
|
|
1378
1517
|
*/
|
|
1379
1518
|
async function loadGit({ project, url, request }: RouteContext) {
|
|
1380
1519
|
const here = isThisMachine(request);
|
|
1520
|
+
|
|
1381
1521
|
if (url.searchParams.get("fetch") === "1" && here) {
|
|
1382
1522
|
await fetchRemote(project.content);
|
|
1383
1523
|
forgetPullRequests();
|
|
1384
1524
|
}
|
|
1525
|
+
|
|
1385
1526
|
const state = await gitStatus(
|
|
1386
1527
|
project.content,
|
|
1387
1528
|
await readGitSettings(project.root)
|
|
1388
1529
|
);
|
|
1530
|
+
|
|
1389
1531
|
return here || !state.repo ? state : { ...state, folder: undefined };
|
|
1390
1532
|
}
|
|
1391
1533
|
|
|
1392
1534
|
async function loadGitBranches({ project, url }: RouteContext) {
|
|
1393
1535
|
const prototype = url.searchParams.get("prototype");
|
|
1536
|
+
|
|
1394
1537
|
return {
|
|
1395
1538
|
branches: prototype
|
|
1396
1539
|
? await prototypeBranches(
|
|
@@ -1416,6 +1559,8 @@ const GIT_STEP_NAMES: Record<GitStepName, true> = {
|
|
|
1416
1559
|
"undo-paused": true,
|
|
1417
1560
|
ask: true,
|
|
1418
1561
|
};
|
|
1562
|
+
|
|
1563
|
+
// SAFETY: GIT_STEP_NAMES has one key per GitStepName.
|
|
1419
1564
|
const GIT_STEPS = Object.keys(GIT_STEP_NAMES) as GitStepName[];
|
|
1420
1565
|
|
|
1421
1566
|
const oneOf = <T extends string>(
|
|
@@ -1423,6 +1568,7 @@ const oneOf = <T extends string>(
|
|
|
1423
1568
|
value: unknown
|
|
1424
1569
|
): value is T => list.some((item) => item === value);
|
|
1425
1570
|
|
|
1571
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- git's problems or the error as it was, sent back as is
|
|
1426
1572
|
const gitProblems = (error: unknown): unknown =>
|
|
1427
1573
|
error instanceof GitError
|
|
1428
1574
|
? new Problems(409, [
|
|
@@ -1441,14 +1587,17 @@ async function takeGitStep({
|
|
|
1441
1587
|
}: RouteContext) {
|
|
1442
1588
|
onlyFromThisMachine(request, GIT_ELSEWHERE);
|
|
1443
1589
|
const step: unknown = body?.step;
|
|
1590
|
+
|
|
1444
1591
|
if (!oneOf<GitStepName>(GIT_STEPS, step)) {
|
|
1445
1592
|
throw new Problems(400, [`A step is one of: ${GIT_STEPS.join(", ")}.`]);
|
|
1446
1593
|
}
|
|
1594
|
+
|
|
1447
1595
|
const settings = await readGitSettings(project.root);
|
|
1448
1596
|
const cwd = project.content;
|
|
1597
|
+
|
|
1449
1598
|
try {
|
|
1450
1599
|
switch (step) {
|
|
1451
|
-
case "branch":
|
|
1600
|
+
case "branch": {
|
|
1452
1601
|
await queueSync(cwd, "step", () =>
|
|
1453
1602
|
createBranch(
|
|
1454
1603
|
cwd,
|
|
@@ -1458,43 +1607,62 @@ async function takeGitStep({
|
|
|
1458
1607
|
)
|
|
1459
1608
|
);
|
|
1460
1609
|
break;
|
|
1461
|
-
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
case "switch": {
|
|
1462
1613
|
await queueSync(cwd, "step", () =>
|
|
1463
1614
|
switchBranch(cwd, String(body?.name ?? ""))
|
|
1464
1615
|
);
|
|
1465
1616
|
break;
|
|
1466
|
-
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
case "switch-to-sync": {
|
|
1467
1620
|
await switchToSyncBranch(cwd, settings);
|
|
1468
1621
|
break;
|
|
1469
|
-
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
case "commit": {
|
|
1470
1625
|
await queueSync(cwd, "step", () =>
|
|
1471
1626
|
commitAll(cwd, String(body?.message ?? ""))
|
|
1472
1627
|
);
|
|
1473
1628
|
break;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1474
1631
|
// Each moves the branch: one running beside a Sync could undo it.
|
|
1475
|
-
case "push":
|
|
1632
|
+
case "push": {
|
|
1476
1633
|
await queueSync(cwd, "step", () => pushBranch(cwd));
|
|
1477
1634
|
break;
|
|
1478
|
-
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
case "sync": {
|
|
1479
1638
|
await queueSync(cwd, "step", () => syncBranch(cwd));
|
|
1480
1639
|
break;
|
|
1481
|
-
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
case "merge": {
|
|
1482
1643
|
await queueSync(cwd, "step", () =>
|
|
1483
1644
|
mergeBranchPullRequest(cwd, settings)
|
|
1484
1645
|
);
|
|
1485
1646
|
break;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1486
1649
|
case "settle": {
|
|
1487
1650
|
const keep = keepOf(body);
|
|
1651
|
+
|
|
1488
1652
|
if (!keep) {
|
|
1489
1653
|
throw new Problems(400, ["keep is mine or theirs."]);
|
|
1490
1654
|
}
|
|
1655
|
+
|
|
1491
1656
|
await queueSync(cwd, "step", () => settlePaused(cwd, keep));
|
|
1492
1657
|
break;
|
|
1493
1658
|
}
|
|
1494
|
-
|
|
1659
|
+
|
|
1660
|
+
case "undo-paused": {
|
|
1495
1661
|
await queueSync(cwd, "step", () => undoPaused(cwd));
|
|
1496
1662
|
break;
|
|
1497
|
-
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
default: {
|
|
1498
1666
|
return await askAgent({
|
|
1499
1667
|
project,
|
|
1500
1668
|
body,
|
|
@@ -1503,12 +1671,14 @@ async function takeGitStep({
|
|
|
1503
1671
|
pageBase,
|
|
1504
1672
|
settings,
|
|
1505
1673
|
});
|
|
1674
|
+
}
|
|
1506
1675
|
}
|
|
1507
1676
|
} catch (error) {
|
|
1508
1677
|
throw gitProblems(error);
|
|
1509
1678
|
} finally {
|
|
1510
1679
|
events.send(studioEvent.git());
|
|
1511
1680
|
}
|
|
1681
|
+
|
|
1512
1682
|
return gitStatus(cwd, settings);
|
|
1513
1683
|
}
|
|
1514
1684
|
|
|
@@ -1523,8 +1693,10 @@ async function runSync({ project, body, events, request }: RouteContext) {
|
|
|
1523
1693
|
const keep = keepOf(body);
|
|
1524
1694
|
const move = typeof body?.move === "string" ? body.move : undefined;
|
|
1525
1695
|
const kind = keep === undefined && move === undefined ? "press" : "choice";
|
|
1696
|
+
|
|
1526
1697
|
return await queueSync(cwd, kind, async (): Promise<SyncResult> => {
|
|
1527
1698
|
let gitError: GitError | undefined;
|
|
1699
|
+
|
|
1528
1700
|
try {
|
|
1529
1701
|
if (move === undefined) {
|
|
1530
1702
|
({ stopped: gitError } = await syncAndUpdate({
|
|
@@ -1540,10 +1712,12 @@ async function runSync({ project, body, events, request }: RouteContext) {
|
|
|
1540
1712
|
if (!(error instanceof GitError)) {
|
|
1541
1713
|
throw error;
|
|
1542
1714
|
}
|
|
1715
|
+
|
|
1543
1716
|
gitError = error;
|
|
1544
1717
|
} finally {
|
|
1545
1718
|
events.send(studioEvent.git());
|
|
1546
1719
|
}
|
|
1720
|
+
|
|
1547
1721
|
return await syncAnswer(cwd, settings, gitError);
|
|
1548
1722
|
});
|
|
1549
1723
|
}
|
|
@@ -1554,7 +1728,7 @@ const syncAnswer = async (
|
|
|
1554
1728
|
stopped: GitError | undefined
|
|
1555
1729
|
): Promise<SyncResult> => ({
|
|
1556
1730
|
git: await gitStatus(cwd, settings),
|
|
1557
|
-
...(stopped
|
|
1731
|
+
...(stopped && { stopped: await stoppedBy(cwd, stopped) }),
|
|
1558
1732
|
});
|
|
1559
1733
|
|
|
1560
1734
|
async function stoppedBy(
|
|
@@ -1564,8 +1738,9 @@ async function stoppedBy(
|
|
|
1564
1738
|
const stopped = {
|
|
1565
1739
|
message: error.message,
|
|
1566
1740
|
output: error.output,
|
|
1567
|
-
...(error.stop
|
|
1741
|
+
...(error.stop && { stop: error.stop }),
|
|
1568
1742
|
};
|
|
1743
|
+
|
|
1569
1744
|
return error.stop === "conflict"
|
|
1570
1745
|
? { ...stopped, clashes: await clashesIn(cwd, error.output.split("\n")) }
|
|
1571
1746
|
: stopped;
|
|
@@ -1573,9 +1748,11 @@ async function stoppedBy(
|
|
|
1573
1748
|
|
|
1574
1749
|
function keepOf(body: RequestBody | undefined): SyncKeep | undefined {
|
|
1575
1750
|
const keep: unknown = body?.keep;
|
|
1751
|
+
|
|
1576
1752
|
if (keep !== undefined && keep !== "mine" && keep !== "theirs") {
|
|
1577
1753
|
throw new Problems(400, ["keep is mine or theirs."]);
|
|
1578
1754
|
}
|
|
1755
|
+
|
|
1579
1756
|
return keep;
|
|
1580
1757
|
}
|
|
1581
1758
|
|
|
@@ -1589,8 +1766,10 @@ async function runPullBase({ project, body, events, request }: RouteContext) {
|
|
|
1589
1766
|
const keep = keepOf(body);
|
|
1590
1767
|
const settings = await readGitSettings(project.root);
|
|
1591
1768
|
const cwd = project.content;
|
|
1769
|
+
|
|
1592
1770
|
return await queueSync(cwd, "step", async (): Promise<SyncResult> => {
|
|
1593
1771
|
let gitError: GitError | undefined;
|
|
1772
|
+
|
|
1594
1773
|
try {
|
|
1595
1774
|
({ stopped: gitError } = await pullBaseAndUpdate({
|
|
1596
1775
|
content: cwd,
|
|
@@ -1601,6 +1780,7 @@ async function runPullBase({ project, body, events, request }: RouteContext) {
|
|
|
1601
1780
|
} finally {
|
|
1602
1781
|
events.send(studioEvent.git());
|
|
1603
1782
|
}
|
|
1783
|
+
|
|
1604
1784
|
return await syncAnswer(cwd, settings, gitError);
|
|
1605
1785
|
});
|
|
1606
1786
|
}
|
|
@@ -1617,6 +1797,7 @@ async function restoreFromSaved({
|
|
|
1617
1797
|
}: RouteContext) {
|
|
1618
1798
|
onlyFromThisMachine(request, GIT_ELSEWHERE);
|
|
1619
1799
|
const cwd = project.content;
|
|
1800
|
+
|
|
1620
1801
|
try {
|
|
1621
1802
|
await queueSync(cwd, "step", () =>
|
|
1622
1803
|
restoreSaved(cwd, {
|
|
@@ -1627,7 +1808,9 @@ async function restoreFromSaved({
|
|
|
1627
1808
|
} catch (error) {
|
|
1628
1809
|
throw gitProblems(error);
|
|
1629
1810
|
}
|
|
1811
|
+
|
|
1630
1812
|
events.send(studioEvent.git());
|
|
1813
|
+
|
|
1631
1814
|
return { saved: await readSaved(cwd) };
|
|
1632
1815
|
}
|
|
1633
1816
|
|
|
@@ -1635,13 +1818,17 @@ async function mergeBranchPullRequest(cwd: string, settings: GitSettings) {
|
|
|
1635
1818
|
forgetPullRequests();
|
|
1636
1819
|
const state = await gitStatus(cwd, settings);
|
|
1637
1820
|
const github = await githubOfRepository(cwd);
|
|
1821
|
+
|
|
1638
1822
|
if (!(state.repo && state.pr?.state === "open" && github)) {
|
|
1639
1823
|
throw new GitError("There is no open pull request to merge.");
|
|
1640
1824
|
}
|
|
1825
|
+
|
|
1641
1826
|
const merged = await mergePullRequest(cwd, github, state.pr.number);
|
|
1827
|
+
|
|
1642
1828
|
if (!merged.merged) {
|
|
1643
1829
|
throw new GitError("GitHub did not merge it.", merged.message);
|
|
1644
1830
|
}
|
|
1831
|
+
|
|
1645
1832
|
await fetchRemote(cwd);
|
|
1646
1833
|
}
|
|
1647
1834
|
|
|
@@ -1657,43 +1844,50 @@ async function askAgent({
|
|
|
1657
1844
|
"project" | "body" | "request" | "threads" | "pageBase"
|
|
1658
1845
|
> & { settings: GitSettings }) {
|
|
1659
1846
|
const ask: unknown = body?.ask;
|
|
1847
|
+
|
|
1660
1848
|
if (!oneOf<GitAsk>(GIT_ASKS, ask)) {
|
|
1661
1849
|
throw new Problems(400, [`Ask for one of: ${GIT_ASKS.join(", ")}.`]);
|
|
1662
1850
|
}
|
|
1851
|
+
|
|
1663
1852
|
const prototype = String(body?.prototype ?? "");
|
|
1664
1853
|
const state = await gitStatus(project.content, settings);
|
|
1854
|
+
|
|
1665
1855
|
if (!(state.repo && state.branch)) {
|
|
1666
1856
|
throw new Problems(409, ["Switch to a branch first."]);
|
|
1667
1857
|
}
|
|
1858
|
+
|
|
1668
1859
|
const { host } = request.headers;
|
|
1669
1860
|
const origin = isLoopbackHost(host) ? undefined : `http://${host}${pageBase}`;
|
|
1670
1861
|
const changed = await branchPrototypes(project.content, settings);
|
|
1862
|
+
|
|
1671
1863
|
const canvases = [...new Set([prototype, ...changed].filter(Boolean))].map(
|
|
1672
1864
|
(name) => ({
|
|
1673
1865
|
prototype: name,
|
|
1674
|
-
...(origin
|
|
1866
|
+
...(origin && { url: `${origin}${prototypePage(name, "canvas")}` }),
|
|
1675
1867
|
})
|
|
1676
1868
|
);
|
|
1869
|
+
|
|
1677
1870
|
const text = gitAskBody(ask, {
|
|
1678
1871
|
base: state.base,
|
|
1679
1872
|
branch: state.branch,
|
|
1680
1873
|
remote: state.remote ?? "origin",
|
|
1681
1874
|
canvases,
|
|
1682
|
-
...(body?.error
|
|
1683
|
-
...(body?.failed
|
|
1684
|
-
});
|
|
1685
|
-
const { name: author } = await readAuthor(project.content);
|
|
1686
|
-
const result = await threads.start({
|
|
1687
|
-
prototype,
|
|
1688
|
-
target: { kind: "prototype" },
|
|
1689
|
-
body: text,
|
|
1690
|
-
for: "agent",
|
|
1691
|
-
author,
|
|
1875
|
+
...(Boolean(body?.error) && { error: String(body?.error) }),
|
|
1876
|
+
...(Boolean(body?.failed) && { step: String(body?.failed) }),
|
|
1692
1877
|
});
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1878
|
+
|
|
1879
|
+
// As sent: a name from before files/ finds the file it became.
|
|
1880
|
+
const comments = await personComments({ project, threads }, prototype);
|
|
1881
|
+
|
|
1882
|
+
const thread = commentAnswer(
|
|
1883
|
+
await startComment(comments, {
|
|
1884
|
+
target: { kind: "prototype" },
|
|
1885
|
+
body: text,
|
|
1886
|
+
for: "agent",
|
|
1887
|
+
})
|
|
1888
|
+
);
|
|
1889
|
+
|
|
1890
|
+
return { thread };
|
|
1697
1891
|
}
|
|
1698
1892
|
|
|
1699
1893
|
const loadGitSettings = async ({ project }: RouteContext) => ({
|
|
@@ -1707,6 +1901,7 @@ function sharingSent(
|
|
|
1707
1901
|
saved: GitSettings
|
|
1708
1902
|
): Pick<GitSettings, "share" | "syncBranch"> {
|
|
1709
1903
|
const share: unknown = body?.share;
|
|
1904
|
+
|
|
1710
1905
|
return {
|
|
1711
1906
|
share: share === "sync" || share === "pull-requests" ? share : saved.share,
|
|
1712
1907
|
syncBranch:
|
|
@@ -1730,12 +1925,14 @@ async function runGitChecks({ project, body }: RouteContext) {
|
|
|
1730
1925
|
realGitProbes,
|
|
1731
1926
|
{ beforePrototypes: "note" }
|
|
1732
1927
|
);
|
|
1928
|
+
|
|
1733
1929
|
return { checks };
|
|
1734
1930
|
}
|
|
1735
1931
|
|
|
1736
1932
|
async function saveGitSettings({ project, body, events }: RouteContext) {
|
|
1737
1933
|
// Base and prefix are always sent.
|
|
1738
1934
|
const saved = await readGitSettings(project.root);
|
|
1935
|
+
|
|
1739
1936
|
const settings = await refusable(() =>
|
|
1740
1937
|
writeGitSettings(project.root, {
|
|
1741
1938
|
base: typeof body?.base === "string" ? body.base : undefined,
|
|
@@ -1743,7 +1940,9 @@ async function saveGitSettings({ project, body, events }: RouteContext) {
|
|
|
1743
1940
|
...sharingSent(body, saved),
|
|
1744
1941
|
})
|
|
1745
1942
|
);
|
|
1943
|
+
|
|
1746
1944
|
events.send(studioEvent.git());
|
|
1945
|
+
|
|
1747
1946
|
return { settings };
|
|
1748
1947
|
}
|
|
1749
1948
|
|
|
@@ -1753,22 +1952,30 @@ const loadBuildSettings = ({ project }: RouteContext) =>
|
|
|
1753
1952
|
/** Turn the build's settings that are sent on or off: `{ review: false }`. */
|
|
1754
1953
|
async function saveBuildSettings({ project, body, events }: RouteContext) {
|
|
1755
1954
|
const sent: Partial<BuildSettings> = {};
|
|
1955
|
+
|
|
1956
|
+
// SAFETY: BUILD_DEFAULTS has every BuildSettings key.
|
|
1756
1957
|
for (const key of Object.keys(BUILD_DEFAULTS) as (keyof BuildSettings)[]) {
|
|
1757
1958
|
const value = body?.[key];
|
|
1959
|
+
|
|
1758
1960
|
if (typeof value === "boolean") {
|
|
1759
1961
|
sent[key] = value;
|
|
1760
1962
|
}
|
|
1761
1963
|
}
|
|
1964
|
+
|
|
1762
1965
|
if (Object.keys(sent).length === 0) {
|
|
1763
1966
|
throw new Problems(400, [
|
|
1764
1967
|
"Send comments, pictures or review, as true or false.",
|
|
1765
1968
|
]);
|
|
1766
1969
|
}
|
|
1970
|
+
|
|
1767
1971
|
const saved = await readBuildSettings(project.root);
|
|
1972
|
+
|
|
1768
1973
|
const settings = await refusable(() =>
|
|
1769
1974
|
writeBuildSettings(project.root, { ...saved, ...sent })
|
|
1770
1975
|
);
|
|
1976
|
+
|
|
1771
1977
|
events.send(studioEvent.workspace());
|
|
1978
|
+
|
|
1772
1979
|
return settings;
|
|
1773
1980
|
}
|
|
1774
1981
|
|
|
@@ -1776,11 +1983,13 @@ const commandsOf = async (project: ProjectFolders): Promise<CommandsAnswer> => {
|
|
|
1776
1983
|
const menu = await readCommandMenu(project.root);
|
|
1777
1984
|
const folders = await skillFolders(project.root);
|
|
1778
1985
|
const commands = await listCommands({ folders, menu });
|
|
1986
|
+
|
|
1779
1987
|
return {
|
|
1780
1988
|
commands,
|
|
1781
1989
|
quick: quickNames(commands, menu),
|
|
1782
1990
|
folder: relative(project.root, folders.team).split(sep).join("/"),
|
|
1783
1991
|
codebaseFolders: codebaseSkills(project.root).shown,
|
|
1992
|
+
// SAFETY: one entry per COMMAND_SWITCHES name, each a boolean.
|
|
1784
1993
|
switches: Object.fromEntries(
|
|
1785
1994
|
COMMAND_SWITCHES.map((which) => [which, switchOn(menu, which)])
|
|
1786
1995
|
) as CommandsAnswer["switches"],
|
|
@@ -1791,6 +2000,7 @@ const loadCommands = ({ project }: RouteContext) => commandsOf(project);
|
|
|
1791
2000
|
|
|
1792
2001
|
async function saveCommandFile({ project, body }: RouteContext) {
|
|
1793
2002
|
const { name, description, body: text, was } = body ?? {};
|
|
2003
|
+
|
|
1794
2004
|
if (
|
|
1795
2005
|
typeof name !== "string" ||
|
|
1796
2006
|
typeof description !== "string" ||
|
|
@@ -1799,6 +2009,7 @@ async function saveCommandFile({ project, body }: RouteContext) {
|
|
|
1799
2009
|
) {
|
|
1800
2010
|
throw new Problems(400, ["Send the command's name, description and body."]);
|
|
1801
2011
|
}
|
|
2012
|
+
|
|
1802
2013
|
const folders = await skillFolders(project.root);
|
|
1803
2014
|
await refusable(() =>
|
|
1804
2015
|
saveCommand(folders, {
|
|
@@ -1808,6 +2019,7 @@ async function saveCommandFile({ project, body }: RouteContext) {
|
|
|
1808
2019
|
was,
|
|
1809
2020
|
})
|
|
1810
2021
|
);
|
|
2022
|
+
|
|
1811
2023
|
// A renamed command keeps its switch.
|
|
1812
2024
|
if (was && was !== name.trim()) {
|
|
1813
2025
|
const menu = await readCommandMenu(project.root);
|
|
@@ -1815,6 +2027,7 @@ async function saveCommandFile({ project, body }: RouteContext) {
|
|
|
1815
2027
|
writeCommandMenu(project.root, menuRenamed(menu, was, name.trim()))
|
|
1816
2028
|
);
|
|
1817
2029
|
}
|
|
2030
|
+
|
|
1818
2031
|
return commandsOf(project);
|
|
1819
2032
|
}
|
|
1820
2033
|
|
|
@@ -1827,47 +2040,62 @@ async function switchCommand({ project, body }: RouteContext) {
|
|
|
1827
2040
|
if (body && "quick" in body) {
|
|
1828
2041
|
return chooseQuick(project, body.quick);
|
|
1829
2042
|
}
|
|
2043
|
+
|
|
1830
2044
|
const which = COMMAND_SWITCHES.find((each) => body && each in body);
|
|
2045
|
+
|
|
1831
2046
|
if (which) {
|
|
1832
2047
|
const on = body?.[which];
|
|
2048
|
+
|
|
1833
2049
|
if (typeof on !== "boolean") {
|
|
1834
2050
|
throw new Problems(400, [`Send ${which} as true or false.`]);
|
|
1835
2051
|
}
|
|
2052
|
+
|
|
1836
2053
|
const menu = await readCommandMenu(project.root);
|
|
1837
2054
|
await refusable(() =>
|
|
1838
2055
|
writeCommandMenu(project.root, { ...menu, [which]: on })
|
|
1839
2056
|
);
|
|
2057
|
+
|
|
1840
2058
|
return commandsOf(project);
|
|
1841
2059
|
}
|
|
2060
|
+
|
|
1842
2061
|
const { name, on } = body ?? {};
|
|
2062
|
+
|
|
1843
2063
|
if (typeof name !== "string" || typeof on !== "boolean") {
|
|
1844
2064
|
throw new Problems(400, ["Send the command's name and on."]);
|
|
1845
2065
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
2066
|
+
|
|
2067
|
+
const commands = await commandsOf(project);
|
|
2068
|
+
|
|
2069
|
+
const command = commands.commands.find((each) => each.name === name);
|
|
2070
|
+
|
|
1849
2071
|
if (!command) {
|
|
1850
2072
|
throw new Problems(404, [`No command is named ${name}.`]);
|
|
1851
2073
|
}
|
|
2074
|
+
|
|
1852
2075
|
const menu = await readCommandMenu(project.root);
|
|
1853
2076
|
await refusable(() =>
|
|
1854
2077
|
writeCommandMenu(project.root, menuWith(menu, command, on))
|
|
1855
2078
|
);
|
|
2079
|
+
|
|
1856
2080
|
return commandsOf(project);
|
|
1857
2081
|
}
|
|
1858
2082
|
|
|
1859
2083
|
async function chooseQuick(project: ProjectFolders, quick: unknown) {
|
|
1860
|
-
const
|
|
2084
|
+
const available = await commandsOf(project);
|
|
2085
|
+
const names = new Set(available.commands.map(({ name }) => name));
|
|
2086
|
+
|
|
1861
2087
|
if (
|
|
1862
2088
|
!Array.isArray(quick) ||
|
|
1863
|
-
quick.some((name) => typeof name !== "string" || !names.
|
|
2089
|
+
quick.some((name) => typeof name !== "string" || !names.has(name))
|
|
1864
2090
|
) {
|
|
1865
2091
|
throw new Problems(400, ["Send the quick bar's commands by name."]);
|
|
1866
2092
|
}
|
|
2093
|
+
|
|
1867
2094
|
const menu = await readCommandMenu(project.root);
|
|
1868
2095
|
await refusable(() =>
|
|
1869
2096
|
writeCommandMenu(project.root, { ...menu, quick: [...new Set(quick)] })
|
|
1870
2097
|
);
|
|
2098
|
+
|
|
1871
2099
|
return commandsOf(project);
|
|
1872
2100
|
}
|
|
1873
2101
|
|
|
@@ -1877,12 +2105,14 @@ async function removeCommandFile({ project, url }: RouteContext) {
|
|
|
1877
2105
|
const folders = await skillFolders(project.root);
|
|
1878
2106
|
await refusable(() => removeCommand(folders, name));
|
|
1879
2107
|
const left = await commandsOf(project);
|
|
2108
|
+
|
|
1880
2109
|
if (!left.commands.some((command) => command.name === name)) {
|
|
1881
2110
|
const menu = await readCommandMenu(project.root);
|
|
1882
2111
|
await refusable(() =>
|
|
1883
2112
|
writeCommandMenu(project.root, menuRenamed(menu, name, undefined))
|
|
1884
2113
|
);
|
|
1885
2114
|
}
|
|
2115
|
+
|
|
1886
2116
|
return commandsOf(project);
|
|
1887
2117
|
}
|
|
1888
2118
|
|
|
@@ -1891,14 +2121,18 @@ const loadTeamDevices = ({ project }: RouteContext) =>
|
|
|
1891
2121
|
|
|
1892
2122
|
async function saveTeamDevices({ project, body, events }: RouteContext) {
|
|
1893
2123
|
const saved = await saveDevices(project.content, body);
|
|
2124
|
+
|
|
1894
2125
|
if (!saved.devices) {
|
|
1895
2126
|
throw new Problems(400, saved.problems);
|
|
1896
2127
|
}
|
|
2128
|
+
|
|
1897
2129
|
events.send(studioEvent.devices());
|
|
2130
|
+
|
|
1898
2131
|
return { devices: saved.devices, problems: [] };
|
|
1899
2132
|
}
|
|
1900
2133
|
|
|
1901
|
-
const BASE64_RE = /^[A-Za-z0-9+/]*={0,2}
|
|
2134
|
+
const BASE64_RE = /^[A-Za-z0-9+/]*={0,2}$/u;
|
|
2135
|
+
|
|
1902
2136
|
/**
|
|
1903
2137
|
* The icon is served under its own address, so it is never a page: opened
|
|
1904
2138
|
* directly, an SVG runs nothing and loads nothing.
|
|
@@ -1911,9 +2145,11 @@ async function saveWorkspace({ project, body, events }: RouteContext) {
|
|
|
1911
2145
|
if (typeof body?.title !== "string") {
|
|
1912
2146
|
throw new Problems(400, ["Send the workspace's name as title."]);
|
|
1913
2147
|
}
|
|
1914
|
-
|
|
2148
|
+
|
|
2149
|
+
const { title } = body;
|
|
1915
2150
|
const workspace = await refusable(() => writeWorkspaceTitle(project, title));
|
|
1916
2151
|
events.send(studioEvent.workspace());
|
|
2152
|
+
|
|
1917
2153
|
return workspace;
|
|
1918
2154
|
}
|
|
1919
2155
|
|
|
@@ -1927,11 +2163,13 @@ async function downloadExtension({ response }: RouteContext) {
|
|
|
1927
2163
|
"The extension isn't built. Build Dex's package, then try again.",
|
|
1928
2164
|
]);
|
|
1929
2165
|
}
|
|
2166
|
+
|
|
1930
2167
|
response.setHeader(
|
|
1931
2168
|
"Content-Disposition",
|
|
1932
2169
|
`attachment; filename="${EXTENSION_FILE}"`
|
|
1933
2170
|
);
|
|
1934
2171
|
response.setHeader("Cache-Control", "no-cache");
|
|
2172
|
+
|
|
1935
2173
|
return new Reply(200, await zipFolder(EXTENSION_DIR), "application/zip");
|
|
1936
2174
|
}
|
|
1937
2175
|
|
|
@@ -1948,17 +2186,21 @@ async function exportFrames({
|
|
|
1948
2186
|
`attachment; filename="${exported.name}"`
|
|
1949
2187
|
);
|
|
1950
2188
|
response.setHeader("Cache-Control", "no-store");
|
|
2189
|
+
|
|
1951
2190
|
return new Reply(200, exported.bytes, "application/zip");
|
|
1952
2191
|
}
|
|
1953
2192
|
|
|
1954
2193
|
async function serveWorkspaceIcon({ project, response }: RouteContext) {
|
|
1955
2194
|
const icon = await readWorkspaceIcon(project);
|
|
2195
|
+
|
|
1956
2196
|
if (!icon) {
|
|
1957
2197
|
throw new Problems(404, ["This workspace has no icon."]);
|
|
1958
2198
|
}
|
|
2199
|
+
|
|
1959
2200
|
response.setHeader("Content-Security-Policy", ICON_POLICY);
|
|
1960
2201
|
response.setHeader("X-Content-Type-Options", "nosniff");
|
|
1961
2202
|
response.setHeader("Cache-Control", "no-cache");
|
|
2203
|
+
|
|
1962
2204
|
return new Reply(200, icon.bytes, icon.type);
|
|
1963
2205
|
}
|
|
1964
2206
|
|
|
@@ -1970,18 +2212,22 @@ async function saveWorkspaceIcon({
|
|
|
1970
2212
|
}: RouteContext) {
|
|
1971
2213
|
onlyFromThisMachine(request, ICON_ELSEWHERE);
|
|
1972
2214
|
const data = body?.data;
|
|
2215
|
+
|
|
1973
2216
|
if (typeof data !== "string" || !BASE64_RE.test(data)) {
|
|
1974
2217
|
throw new Problems(400, ["Send the icon's bytes in base64 as data."]);
|
|
1975
2218
|
}
|
|
2219
|
+
|
|
1976
2220
|
const workspace = await writeWorkspaceIcon(
|
|
1977
2221
|
project,
|
|
1978
2222
|
Buffer.from(data, "base64")
|
|
1979
2223
|
).catch((error: unknown) => {
|
|
1980
|
-
throw new Problems(error instanceof
|
|
2224
|
+
throw new Problems(error instanceof IconRefusedError ? 415 : 422, [
|
|
1981
2225
|
messageOf(error),
|
|
1982
2226
|
]);
|
|
1983
2227
|
});
|
|
2228
|
+
|
|
1984
2229
|
events.send(studioEvent.workspace());
|
|
2230
|
+
|
|
1985
2231
|
return workspace;
|
|
1986
2232
|
}
|
|
1987
2233
|
|
|
@@ -1989,6 +2235,7 @@ async function deleteWorkspaceIcon({ project, request, events }: RouteContext) {
|
|
|
1989
2235
|
onlyFromThisMachine(request, ICON_ELSEWHERE);
|
|
1990
2236
|
const workspace = await refusable(() => removeWorkspaceIcon(project));
|
|
1991
2237
|
events.send(studioEvent.workspace());
|
|
2238
|
+
|
|
1992
2239
|
return workspace;
|
|
1993
2240
|
}
|
|
1994
2241
|
|
|
@@ -1997,30 +2244,35 @@ function pictureOwner({ project, request }: RouteContext) {
|
|
|
1997
2244
|
request,
|
|
1998
2245
|
"Change your picture on the machine Dex runs on."
|
|
1999
2246
|
);
|
|
2247
|
+
|
|
2000
2248
|
return whoChanges(project.content);
|
|
2001
2249
|
}
|
|
2002
2250
|
|
|
2003
2251
|
async function saveAvatar(context: RouteContext) {
|
|
2004
2252
|
const slug = await pictureOwner(context);
|
|
2005
2253
|
const data = context.body?.data;
|
|
2254
|
+
|
|
2006
2255
|
if (typeof data !== "string" || !BASE64_RE.test(data)) {
|
|
2007
2256
|
throw new Problems(400, ["Send the picture's bytes in base64 as data."]);
|
|
2008
2257
|
}
|
|
2258
|
+
|
|
2009
2259
|
const file = await writeAvatar(
|
|
2010
2260
|
context.project.content,
|
|
2011
2261
|
slug,
|
|
2012
2262
|
Buffer.from(data, "base64")
|
|
2013
2263
|
).catch((error: unknown) => {
|
|
2014
|
-
throw new Problems(error instanceof
|
|
2264
|
+
throw new Problems(error instanceof AvatarRefusedError ? 415 : 422, [
|
|
2015
2265
|
messageOf(error),
|
|
2016
2266
|
]);
|
|
2017
2267
|
});
|
|
2268
|
+
|
|
2018
2269
|
return { file };
|
|
2019
2270
|
}
|
|
2020
2271
|
|
|
2021
2272
|
async function deleteAvatar(context: RouteContext) {
|
|
2022
2273
|
const slug = await pictureOwner(context);
|
|
2023
2274
|
await refusable(() => removeAvatar(context.project.content, slug));
|
|
2275
|
+
|
|
2024
2276
|
return {};
|
|
2025
2277
|
}
|
|
2026
2278
|
|
|
@@ -2028,20 +2280,25 @@ async function recordFocus({ project, body }: RouteContext) {
|
|
|
2028
2280
|
const { slug } = prototypeNamed(project.content, body ?? {}, {
|
|
2029
2281
|
mustExist: false,
|
|
2030
2282
|
});
|
|
2283
|
+
|
|
2031
2284
|
await writeFocus(project.content, {
|
|
2032
2285
|
slug,
|
|
2033
2286
|
page: body?.page === "canvas" ? "canvas" : "prototype",
|
|
2034
2287
|
...openPlace(body),
|
|
2035
2288
|
});
|
|
2289
|
+
|
|
2036
2290
|
return {};
|
|
2037
2291
|
}
|
|
2038
2292
|
|
|
2039
2293
|
const loadMe = ({ project }: RouteContext) => readMe(project.content);
|
|
2040
2294
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2295
|
+
/** A change to a file, as a request asks for it. */
|
|
2296
|
+
// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type, anti-slop/no-unknown-returns -- a request body, which each change checks; what a change answers is sent as JSON, whatever it is
|
|
2297
|
+
type PrototypeChange = (body: RequestBody, root: string) => Promise<unknown>;
|
|
2298
|
+
|
|
2299
|
+
// SAFETY: each change checks the body's fields itself.
|
|
2300
|
+
// oxlint-disable-next-line anti-slop/no-known-value-widening -- looked up by the action a request names
|
|
2301
|
+
const PROTOTYPE_CHANGES: Record<string, PrototypeChange> = {
|
|
2045
2302
|
rename: (body, root) =>
|
|
2046
2303
|
setPrototypeTitle(body as ArgumentOf<typeof setPrototypeTitle>, root),
|
|
2047
2304
|
status: (body, root) =>
|
|
@@ -2062,20 +2319,26 @@ async function changePrototypes({ project, body }: RouteContext) {
|
|
|
2062
2319
|
if (!body) {
|
|
2063
2320
|
throw new Problems(400, ["Send a title."]);
|
|
2064
2321
|
}
|
|
2322
|
+
|
|
2065
2323
|
const { action } = body;
|
|
2066
2324
|
const known = isPrototypeChange(action);
|
|
2325
|
+
|
|
2067
2326
|
if (action !== undefined && !known) {
|
|
2068
2327
|
throw new Problems(400, [
|
|
2069
2328
|
`This studio cannot "${action}" a file. Restart it after updating.`,
|
|
2070
2329
|
]);
|
|
2071
2330
|
}
|
|
2331
|
+
|
|
2072
2332
|
if (known) {
|
|
2073
2333
|
const change = PROTOTYPE_CHANGES[action];
|
|
2334
|
+
|
|
2074
2335
|
return (await refusable(() => change(body, project.content))) ?? {};
|
|
2075
2336
|
}
|
|
2337
|
+
|
|
2076
2338
|
// An agent may name any contributor (`owner` from before is the same).
|
|
2077
2339
|
const person =
|
|
2078
2340
|
body.person ?? body.owner ?? (await whoChanges(project.content));
|
|
2341
|
+
|
|
2079
2342
|
const { href } = await refusable(() =>
|
|
2080
2343
|
body.title === undefined
|
|
2081
2344
|
? createUntitledPrototype({ person }, project.content)
|
|
@@ -2084,6 +2347,7 @@ async function changePrototypes({ project, body }: RouteContext) {
|
|
|
2084
2347
|
project.content
|
|
2085
2348
|
)
|
|
2086
2349
|
);
|
|
2350
|
+
|
|
2087
2351
|
return { href };
|
|
2088
2352
|
}
|
|
2089
2353
|
|
|
@@ -2108,9 +2372,11 @@ function studioPages({
|
|
|
2108
2372
|
// Watch is read, changed and told to pages one step at a time, so a page
|
|
2109
2373
|
// that opens while it changes never hears an older value after a newer one.
|
|
2110
2374
|
let watchTurn: Promise<unknown> = Promise.resolve();
|
|
2375
|
+
|
|
2111
2376
|
const inWatchOrder = <T>(step: () => Promise<T>): Promise<T> => {
|
|
2112
2377
|
const next = watchTurn.then(step);
|
|
2113
2378
|
watchTurn = next.catch(() => undefined);
|
|
2379
|
+
|
|
2114
2380
|
return next;
|
|
2115
2381
|
};
|
|
2116
2382
|
|
|
@@ -2126,10 +2392,12 @@ function studioPages({
|
|
|
2126
2392
|
listening: () => open,
|
|
2127
2393
|
async listen(response: ServerResponse): Promise<void> {
|
|
2128
2394
|
const entries = await presence.list();
|
|
2395
|
+
|
|
2129
2396
|
if (response.destroyed) {
|
|
2130
2397
|
// Gone while its presence was read.
|
|
2131
2398
|
return;
|
|
2132
2399
|
}
|
|
2400
|
+
|
|
2133
2401
|
response.writeHead(200, {
|
|
2134
2402
|
"Content-Type": "text/event-stream",
|
|
2135
2403
|
"Cache-Control": "no-cache",
|
|
@@ -2138,13 +2406,16 @@ function studioPages({
|
|
|
2138
2406
|
const write = (event: StudioEvent) => response.write(eventMessage(event));
|
|
2139
2407
|
write(studioEvent.presence(entries));
|
|
2140
2408
|
const stopHearing = events.listen(write);
|
|
2409
|
+
|
|
2141
2410
|
const stopAgents = agents.listen((list) =>
|
|
2142
2411
|
write(studioEvent.agents(list))
|
|
2143
2412
|
);
|
|
2413
|
+
|
|
2144
2414
|
const keepAlive = setInterval(
|
|
2145
2415
|
() => response.write(": keep-alive\n\n"),
|
|
2146
2416
|
KEEP_ALIVE_MS
|
|
2147
2417
|
);
|
|
2418
|
+
|
|
2148
2419
|
open += 1;
|
|
2149
2420
|
following ??= threads.subscribe(threadsChanged);
|
|
2150
2421
|
response.on("close", () => {
|
|
@@ -2152,6 +2423,7 @@ function studioPages({
|
|
|
2152
2423
|
stopHearing();
|
|
2153
2424
|
stopAgents();
|
|
2154
2425
|
open -= 1;
|
|
2426
|
+
|
|
2155
2427
|
if (open === 0) {
|
|
2156
2428
|
following?.then((stop) => stop());
|
|
2157
2429
|
following = undefined;
|
|
@@ -2159,7 +2431,8 @@ function studioPages({
|
|
|
2159
2431
|
});
|
|
2160
2432
|
// In turn with the Watch changes it hears from here on.
|
|
2161
2433
|
await inWatchOrder(async () => {
|
|
2162
|
-
const on = await isWatching(project.content);
|
|
2434
|
+
const on = await isWatching(agentsPlace(project.content));
|
|
2435
|
+
|
|
2163
2436
|
if (!response.destroyed) {
|
|
2164
2437
|
write(studioEvent.watch(on));
|
|
2165
2438
|
}
|
|
@@ -2195,14 +2468,14 @@ type DeclaredRoute<Name extends StudioRouteName> =
|
|
|
2195
2468
|
| ({ prototype: true } & DeclaredMethods<PrototypeContext, Name>)
|
|
2196
2469
|
| ({ prototype?: false } & DeclaredMethods<RouteContext, Name>);
|
|
2197
2470
|
|
|
2198
|
-
const ROUTES
|
|
2471
|
+
const ROUTES = {
|
|
2199
2472
|
...COMMENT_HANDLERS,
|
|
2200
2473
|
canvas: { prototype: true, GET: loadCanvas, PUT: saveCanvas },
|
|
2201
|
-
|
|
2474
|
+
picks: {
|
|
2202
2475
|
prototype: true,
|
|
2203
|
-
GET:
|
|
2204
|
-
PUT:
|
|
2205
|
-
DELETE:
|
|
2476
|
+
GET: loadPicks,
|
|
2477
|
+
PUT: saveOwnPick,
|
|
2478
|
+
DELETE: removeOwnPick,
|
|
2206
2479
|
},
|
|
2207
2480
|
events: {
|
|
2208
2481
|
streams: true,
|
|
@@ -2213,6 +2486,7 @@ const ROUTES: { [Name in StudioRouteName]: DeclaredRoute<Name> } = {
|
|
|
2213
2486
|
GET: listRemovedViews,
|
|
2214
2487
|
POST: trashRemovedViews,
|
|
2215
2488
|
},
|
|
2489
|
+
"view-source": { prototype: true, GET: loadViewSource },
|
|
2216
2490
|
trash: { DELETE: emptyTheTrash },
|
|
2217
2491
|
reviews: { limit: MAX_REVIEW_BYTES, POST: importReviews },
|
|
2218
2492
|
"spec-suggestion": { POST: acceptSpecSuggestion },
|
|
@@ -2278,7 +2552,7 @@ const ROUTES: { [Name in StudioRouteName]: DeclaredRoute<Name> } = {
|
|
|
2278
2552
|
PUT: saveWorkspaceIcon,
|
|
2279
2553
|
DELETE: deleteWorkspaceIcon,
|
|
2280
2554
|
},
|
|
2281
|
-
};
|
|
2555
|
+
} satisfies { [Name in StudioRouteName]: DeclaredRoute<Name> };
|
|
2282
2556
|
|
|
2283
2557
|
const isRouteName = (name: string): name is StudioRouteName =>
|
|
2284
2558
|
Object.hasOwn(ROUTES, name);
|
|
@@ -2286,23 +2560,30 @@ const isRouteName = (name: string): name is StudioRouteName =>
|
|
|
2286
2560
|
async function answer(
|
|
2287
2561
|
route: Route,
|
|
2288
2562
|
context: Omit<RouteContext, "body">
|
|
2563
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- a route's answer is sent as JSON, whatever it is
|
|
2289
2564
|
): Promise<unknown> {
|
|
2290
2565
|
const { request, response, url, project } = context;
|
|
2291
2566
|
const methods = METHODS.filter((method) => route[method]);
|
|
2292
2567
|
const method = methods.find((known) => known === request.method);
|
|
2568
|
+
|
|
2293
2569
|
if (!method) {
|
|
2294
2570
|
response.setHeader("Allow", methods.join(", "));
|
|
2295
2571
|
throw new Problems(405, [`Use ${methods.join(" or ")}.`]);
|
|
2296
2572
|
}
|
|
2573
|
+
|
|
2297
2574
|
const bodyOf = () =>
|
|
2298
2575
|
WITH_BODY.has(method) ? readJson(request, route.limit) : undefined;
|
|
2576
|
+
|
|
2299
2577
|
// The prototype is checked before the body is read.
|
|
2300
2578
|
if (route.prototype) {
|
|
2301
2579
|
const prototype = prototypeOf(project.content, url);
|
|
2302
2580
|
const body = await bodyOf();
|
|
2581
|
+
|
|
2303
2582
|
return route[method]?.({ ...context, prototype, body });
|
|
2304
2583
|
}
|
|
2584
|
+
|
|
2305
2585
|
const body = await bodyOf();
|
|
2586
|
+
|
|
2306
2587
|
return route[method]?.({ ...context, body });
|
|
2307
2588
|
}
|
|
2308
2589
|
|
|
@@ -2310,10 +2591,10 @@ export interface StudioRequestOptions {
|
|
|
2310
2591
|
agents?: AgentTracker;
|
|
2311
2592
|
base?: string;
|
|
2312
2593
|
/**
|
|
2313
|
-
*
|
|
2314
|
-
*
|
|
2594
|
+
* The studio's app, asked each time: the dev server's port is known only
|
|
2595
|
+
* once it listens.
|
|
2315
2596
|
*/
|
|
2316
|
-
desktop?: () =>
|
|
2597
|
+
desktop?: () => ProjectDesktop;
|
|
2317
2598
|
events: EventHub;
|
|
2318
2599
|
format?: Formatter;
|
|
2319
2600
|
launcher?: AgentLauncher;
|
|
@@ -2335,31 +2616,38 @@ export function studioRequests({
|
|
|
2335
2616
|
events,
|
|
2336
2617
|
format = formatter(project.content),
|
|
2337
2618
|
launcher = launchAgent,
|
|
2338
|
-
agents = trackAgents(project.content
|
|
2619
|
+
agents = trackAgents(agentsPlace(project.content)),
|
|
2339
2620
|
server = {},
|
|
2340
2621
|
base = "/",
|
|
2341
|
-
desktop = () => (
|
|
2622
|
+
desktop = () => noDesktop("platform"),
|
|
2342
2623
|
}: StudioRequestOptions): (
|
|
2343
2624
|
request: IncomingMessage,
|
|
2344
2625
|
response: ServerResponse
|
|
2345
2626
|
) => Promise<boolean> {
|
|
2346
2627
|
const pages = studioPages({ project, events, threads, agents });
|
|
2347
2628
|
const pageBase = base.replace(TRAILING_SLASH_RE, "");
|
|
2629
|
+
|
|
2348
2630
|
return async (request, response) => {
|
|
2349
2631
|
const url = new URL(request.url ?? "/", "http://studio.local");
|
|
2632
|
+
|
|
2350
2633
|
if (!url.pathname.startsWith(PREFIX)) {
|
|
2351
2634
|
return false;
|
|
2352
2635
|
}
|
|
2636
|
+
|
|
2353
2637
|
const name = url.pathname.slice(PREFIX.length);
|
|
2638
|
+
|
|
2354
2639
|
try {
|
|
2355
2640
|
// Other websites open in the same browser must not change files.
|
|
2356
2641
|
if (!isAllowedRequest(request.headers, server)) {
|
|
2357
2642
|
throw new Problems(403, ["Not allowed from this site."]);
|
|
2358
2643
|
}
|
|
2644
|
+
|
|
2359
2645
|
if (!isRouteName(name)) {
|
|
2360
2646
|
throw new Problems(404, ["Not found."]);
|
|
2361
2647
|
}
|
|
2648
|
+
|
|
2362
2649
|
const route: Route = ROUTES[name];
|
|
2650
|
+
|
|
2363
2651
|
const answered = await answer(route, {
|
|
2364
2652
|
project,
|
|
2365
2653
|
threads,
|
|
@@ -2373,6 +2661,7 @@ export function studioRequests({
|
|
|
2373
2661
|
response,
|
|
2374
2662
|
url,
|
|
2375
2663
|
});
|
|
2664
|
+
|
|
2376
2665
|
if (!route.streams) {
|
|
2377
2666
|
send(response, answered);
|
|
2378
2667
|
}
|
|
@@ -2381,12 +2670,14 @@ export function studioRequests({
|
|
|
2381
2670
|
response.end();
|
|
2382
2671
|
} else {
|
|
2383
2672
|
// Cloud errors keep their status: 402 when the plan has lapsed.
|
|
2673
|
+
// SAFETY: route errors are Problems or CloudErrors, which have a status and problems; anything else has a message.
|
|
2384
2674
|
const failure = error as Failure;
|
|
2385
2675
|
sendJson(response, failure.status ?? 500, {
|
|
2386
2676
|
problems: failure.problems ?? [failure.message],
|
|
2387
2677
|
});
|
|
2388
2678
|
}
|
|
2389
2679
|
}
|
|
2680
|
+
|
|
2390
2681
|
return true;
|
|
2391
2682
|
};
|
|
2392
2683
|
}
|