@dexhq/canvas 0.15.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 +92 -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 +79 -13
- package/app/canvas/activity.tsx +155 -38
- package/app/canvas/add-to-spec.ts +14 -5
- package/app/canvas/agent-changes.ts +77 -12
- package/app/canvas/anchoring.ts +176 -50
- 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 +23 -4
- package/app/canvas/canvas-corners.tsx +2 -0
- package/app/canvas/canvas-document.ts +140 -23
- package/app/canvas/canvas-input.ts +312 -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 +255 -215
- package/app/canvas/canvas-panels.ts +10 -0
- package/app/canvas/canvas-scene.ts +759 -110
- package/app/canvas/canvas-ui.ts +79 -8
- package/app/canvas/canvas.css +484 -34
- 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 +391 -150
- 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 +154 -0
- package/app/canvas/element-picker.ts +125 -480
- 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 +279 -0
- 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 +396 -103
- 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 +325 -35
- 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 +307 -80
- 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 +739 -327
- package/app/canvas/linked-element.tsx +219 -0
- package/app/canvas/live-page.ts +240 -29
- package/app/canvas/measure-box.tsx +1 -0
- package/app/canvas/mentions.tsx +221 -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 +22 -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 +43 -12
- package/app/canvas/request-node.tsx +165 -0
- package/app/canvas/review-marker.tsx +9 -2
- package/app/canvas/review-panel.tsx +151 -43
- package/app/canvas/row-node.tsx +15 -3
- package/app/canvas/scene-context.tsx +16 -1
- package/app/canvas/section-node.tsx +72 -142
- 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 +36 -8
- 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 +223 -0
- 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 +156 -29
- 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 +22 -7
- package/app/canvas/tool-icons.tsx +37 -56
- 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 +17 -0
- package/app/canvas/unknown-frame.tsx +39 -12
- package/app/canvas/use-activity.ts +57 -2
- package/app/canvas/use-agent-changes.tsx +66 -17
- 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 +43 -16
- 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 +187 -0
- package/app/export/player.tsx +215 -0
- package/app/export.html +31 -0
- package/app/export.tsx +9 -0
- package/app/frame/announce-refreshes.ts +21 -0
- 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 +56 -0
- package/app/frame/studio-view.tsx +2 -0
- package/app/frame/view-exports.ts +240 -0
- package/app/frame/view-loads.ts +187 -0
- package/app/frame/views.ts +86 -51
- package/app/frame.tsx +2 -38
- 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 +264 -12
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +260 -8
- 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 +257 -0
- package/app/icons/glyphs.tsx +80 -79
- 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-flow.ts +2 -1
- 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 +103 -0
- 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 +218 -71
- 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 +247 -76
- package/app/pages/chrome-extension.tsx +4 -2
- package/app/pages/commands-settings.tsx +75 -26
- 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 +72 -19
- 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 +41 -17
- 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 +196 -35
- 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 +40 -12
- 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 +45 -5
- 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 +112 -28
- package/app/ui/reference.tsx +27 -9
- 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 +2 -1
- 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/create.d.mts +5 -5
- package/dist/cli/commands/create.mjs +4 -4
- package/dist/cli/commands/dev.mjs +64 -19
- package/dist/cli/commands/doctor.mjs +3 -1
- package/dist/cli/commands/export.d.mts +40 -0
- package/dist/cli/commands/export.mjs +66 -0
- package/dist/cli/commands/hook.mjs +1 -1
- package/dist/cli/commands/init.d.mts +2 -2
- 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/commands/upgrade.mjs +1 -1
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +20 -20
- package/dist/cli/main.d.mts +68 -5
- package/dist/cli/main.mjs +5 -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 +23 -8
- package/dist/config/project-files.d.mts +8 -2
- package/dist/config/project-files.mjs +44 -41
- package/dist/config/renamed.d.mts +9 -6
- package/dist/config/renamed.mjs +11 -12
- package/dist/content/biome.mjs +15 -10
- package/dist/content/capture.mjs +43 -42
- package/dist/content/commands.d.mts +21 -13
- package/dist/content/commands.mjs +69 -35
- package/dist/content/comments-log.mjs +104 -20
- package/dist/content/component-props.mjs +6 -10
- package/dist/content/content.d.mts +279 -35
- package/dist/content/content.mjs +247 -154
- package/dist/content/devices.mjs +2 -2
- package/dist/content/element-words.d.mts +42 -0
- package/dist/content/element-words.mjs +112 -0
- 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.d.mts +31 -0
- package/dist/content/hosted-person.mjs +69 -0
- 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 +16 -4
- package/dist/content/merge-rules.mjs +46 -17
- 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 +26 -13
- 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.d.mts +24 -14
- package/dist/content/text-edit.mjs +92 -81
- package/dist/content/text-replace.mjs +15 -41
- package/dist/content/thread-module.d.mts +11 -5
- package/dist/content/thread-module.mjs +23 -6
- 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/canvas-presence.d.mts +22 -0
- package/dist/server/canvas-presence.mjs +160 -0
- 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 +12 -8
- package/dist/server/comments/actions.d.mts +17 -64
- package/dist/server/comments/actions.mjs +65 -67
- 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 +27 -38
- 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 +53 -49
- package/dist/server/export/build.d.mts +15 -0
- package/dist/server/export/build.mjs +220 -0
- package/dist/server/export/page.d.mts +25 -0
- package/dist/server/export/page.mjs +40 -0
- package/dist/server/export/plugin.d.mts +33 -0
- package/dist/server/export/plugin.mjs +72 -0
- package/dist/server/export/run.d.mts +9 -0
- package/dist/server/export/run.mjs +61 -0
- package/dist/server/export/save.d.mts +7 -0
- package/dist/server/export/save.mjs +29 -0
- 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/hosted.d.mts +8 -0
- package/dist/server/hosted.mjs +78 -0
- package/dist/server/instructions.mjs +9 -8
- package/dist/server/live-mirror.mjs +85 -22
- package/dist/server/live.mjs +35 -6
- package/dist/server/machine-update.mjs +32 -32
- package/dist/server/me.d.mts +2 -0
- package/dist/server/me.mjs +10 -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 +7 -7
- package/dist/server/notices.mjs +12 -10
- package/dist/server/open-page.mjs +11 -10
- package/dist/server/outcome.d.mts +7 -8
- package/dist/server/own-copies.mjs +22 -12
- package/dist/server/people.d.mts +7 -2
- package/dist/server/people.mjs +10 -6
- package/dist/server/pictures.d.mts +1 -1
- package/dist/server/pictures.mjs +16 -10
- package/dist/server/port.mjs +5 -9
- package/dist/server/prebundle.d.mts +32 -0
- package/dist/server/prebundle.mjs +118 -0
- 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/problems.d.mts +8 -0
- package/dist/server/problems.mjs +13 -0
- 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 +175 -156
- 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 -3
- package/dist/server/source-stamp.mjs +92 -35
- package/dist/server/spec-decisions.mjs +2 -2
- package/dist/server/state.d.mts +25 -16
- package/dist/server/state.mjs +30 -23
- 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 +43 -5
- package/dist/server/thread-source.mjs +63 -41
- 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 +17 -0
- package/dist/server/tools/export.mjs +40 -0
- 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 +80 -73
- 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.d.mts +9 -4
- package/dist/server/vite.mjs +90 -83
- package/dist/server/web-app.mjs +17 -30
- package/dist/server/welcome.mjs +5 -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 +9 -0
- package/dist/setup/apply.mjs +30 -26
- 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 +69 -57
- 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 +9 -14
- package/dist/setup/detect/workspace.d.mts +13 -27
- package/dist/setup/detect/workspace.mjs +33 -138
- package/dist/setup/detect.mjs +24 -18
- package/dist/setup/doctor.d.mts +4 -1
- package/dist/setup/doctor.mjs +21 -18
- 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 +61 -0
- package/dist/setup/migrate/dex-folder.mjs +548 -0
- package/dist/setup/migrate/explorations.mjs +7 -5
- package/dist/setup/migrate/files-folder.mjs +36 -21
- 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 +2 -2
- 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 +16 -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.d.mts +5 -0
- package/dist/setup/migrate/setup-files.mjs +121 -0
- package/dist/setup/migrate/studio-state.d.mts +2 -2
- package/dist/setup/migrate/studio-state.mjs +12 -10
- package/dist/setup/own-app.d.mts +2 -1
- package/dist/setup/own-app.mjs +17 -15
- package/dist/setup/placement.d.mts +1 -1
- package/dist/setup/placement.mjs +25 -22
- package/dist/setup/plan.d.mts +10 -8
- package/dist/setup/plan.mjs +15 -18
- package/dist/setup/project.mjs +12 -9
- package/dist/setup/prompts.d.mts +3 -6
- package/dist/setup/prompts.mjs +58 -56
- package/dist/setup/provider.mjs +3 -2
- package/dist/setup/questions.d.mts +13 -7
- package/dist/setup/questions.mjs +5 -6
- package/dist/setup/starters.d.mts +1 -1
- package/dist/setup/starters.mjs +8 -5
- 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 +24 -4
- package/dist/setup/write.mjs +40 -19
- 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 +138 -63
- package/dist/shared/canvas-core.mjs +227 -86
- 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 +5 -1
- package/dist/shared/comments/routes.mjs +8 -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 +61 -0
- package/dist/shared/export-core.mjs +100 -0
- 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 +12 -5
- package/dist/shared/live-core.mjs +11 -5
- package/dist/shared/live-presence.d.mts +57 -2
- package/dist/shared/live-presence.mjs +102 -13
- 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 +29 -4
- package/dist/shared/page-messages.mjs +55 -16
- package/dist/shared/page-review.mjs +8 -10
- package/dist/shared/people-core.d.mts +61 -25
- package/dist/shared/people-core.mjs +74 -23
- 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/presence-core.d.mts +2 -0
- package/dist/shared/prototypes-core.d.mts +70 -15
- package/dist/shared/prototypes-core.mjs +184 -100
- package/dist/shared/references-core.d.mts +4 -0
- package/dist/shared/references-core.mjs +15 -8
- 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 +12 -3
- package/dist/shared/studio-files.mjs +18 -9
- package/dist/shared/studio-routes.d.mts +41 -31
- package/dist/shared/studio-routes.mjs +6 -1
- package/dist/shared/threads-core.d.mts +373 -36
- package/dist/shared/threads-core.mjs +286 -84
- 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 +106 -286
- 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 +7 -4
- package/src/cli/commands/dev.ts +148 -32
- package/src/cli/commands/doctor.ts +9 -1
- package/src/cli/commands/export.ts +87 -0
- 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 +12 -1
- 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 +45 -17
- package/src/cli/main.ts +32 -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 +63 -8
- package/src/config/project-files.ts +194 -42
- package/src/config/renamed.ts +25 -12
- 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 +115 -45
- package/src/content/comments-log.ts +187 -35
- package/src/content/component-props.ts +134 -23
- package/src/content/content.ts +768 -230
- package/src/content/devices.ts +12 -3
- package/src/content/element-words.ts +200 -0
- 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 +131 -0
- 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 +96 -33
- 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 +95 -23
- 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 +209 -106
- package/src/content/text-replace.ts +130 -61
- package/src/content/thread-module.ts +86 -16
- package/src/content/threads.ts +146 -16
- package/src/content/trash.ts +101 -41
- 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 +266 -0
- 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 +31 -13
- package/src/server/comments/actions.ts +137 -152
- 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 +46 -61
- 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 +130 -86
- package/src/server/export/build.ts +344 -0
- package/src/server/export/page.ts +94 -0
- package/src/server/export/plugin.ts +157 -0
- package/src/server/export/run.ts +91 -0
- package/src/server/export/save.ts +43 -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 +124 -0
- package/src/server/instructions.ts +32 -7
- package/src/server/live-mirror.ts +202 -18
- package/src/server/live.ts +131 -17
- package/src/server/machine-update.ts +170 -38
- package/src/server/me.ts +18 -4
- package/src/server/merge-check.ts +125 -0
- package/src/server/next.ts +30 -8
- package/src/server/notices.ts +79 -17
- 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 +33 -9
- package/src/server/personal-folder.ts +3 -0
- package/src/server/pictures.ts +78 -10
- package/src/server/port.ts +38 -6
- package/src/server/prebundle.ts +265 -0
- package/src/server/preferences.ts +6 -1
- package/src/server/presence.ts +18 -7
- package/src/server/problems.ts +13 -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 +597 -291
- package/src/server/response-budget.ts +29 -6
- package/src/server/restart.ts +36 -3
- package/src/server/roster.ts +51 -9
- package/src/server/saved.ts +16 -6
- package/src/server/source-stamp.ts +224 -39
- package/src/server/spec-decisions.ts +11 -2
- package/src/server/state.ts +74 -40
- 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 +143 -47
- package/src/server/tools/context.ts +95 -112
- package/src/server/tools/describe.ts +10 -35
- package/src/server/tools/export.ts +58 -0
- package/src/server/tools/feedback.ts +47 -22
- package/src/server/tools/place-frame.ts +65 -28
- 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 +57 -11
- package/src/server/vite.ts +254 -133
- package/src/server/web-app.ts +27 -46
- package/src/server/welcome.ts +11 -4
- 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 +139 -44
- 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 +291 -74
- package/src/setup/design-md-setup.ts +48 -11
- package/src/setup/design-md.ts +276 -80
- package/src/setup/design-system-checks.ts +71 -18
- package/src/setup/design-system-guide.ts +7 -0
- package/src/setup/detect/workspace.ts +239 -213
- package/src/setup/detect.ts +95 -26
- package/src/setup/doctor.ts +97 -26
- 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 +957 -0
- package/src/setup/migrate/explorations.ts +7 -3
- package/src/setup/migrate/files-folder.ts +146 -44
- package/src/setup/migrate/frame-notes.ts +253 -0
- package/src/setup/migrate/frame-uids.ts +274 -0
- package/src/setup/migrate/guides.ts +21 -16
- package/src/setup/migrate/manifest-name.ts +183 -0
- package/src/setup/migrate/migrations.ts +35 -7
- 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 +223 -0
- package/src/setup/migrate/studio-state.ts +38 -15
- package/src/setup/own-app.ts +75 -21
- package/src/setup/placement.ts +87 -27
- package/src/setup/plan.ts +109 -35
- package/src/setup/project.ts +77 -13
- package/src/setup/prompts.ts +206 -58
- package/src/setup/provider.ts +20 -2
- package/src/setup/questions.ts +77 -26
- package/src/setup/starters.ts +58 -17
- package/src/setup/templates.ts +66 -20
- package/src/setup/workspace-setup.ts +50 -5
- package/src/setup/write.ts +96 -27
- 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 +643 -161
- 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 +8 -4
- 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 +220 -0
- 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 +63 -12
- package/src/shared/live-presence.ts +234 -14
- package/src/shared/markup-prompt.ts +9 -4
- package/src/shared/open-page-core.ts +15 -8
- package/src/shared/page-messages.ts +94 -18
- package/src/shared/page-review.ts +60 -35
- package/src/shared/paste-arrangement.ts +4 -0
- package/src/shared/people-core.ts +290 -54
- package/src/shared/{annotations-core.ts → picks-core.ts} +125 -96
- package/src/shared/presence-core.ts +2 -0
- package/src/shared/prototypes-core.ts +323 -128
- package/src/shared/references-core.ts +39 -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 +43 -11
- package/src/shared/studio-routes.ts +38 -32
- package/src/shared/threads-core.ts +725 -170
- 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/explore.md +1 -1
- package/templates/methods/handoff.md +2 -2
- package/templates/methods/review.md +9 -4
- package/templates/rules/always.md +1 -1
- package/templates/rules/canvas-frames.md +15 -5
- package/templates/rules/canvas.md +19 -11
- package/templates/rules/commands.md +1 -0
- package/templates/rules/prototypes.md +7 -6
- package/templates/rules/scope.md +2 -2
- package/templates/rules/studio.md +17 -11
- package/templates/skills/boil/SKILL.md +40 -0
- package/templates/skills/comprehend/SKILL.md +57 -0
- package/templates/skills/distill/SKILL.md +173 -0
- package/templates/skills/export-prototype/SKILL.md +36 -0
- package/templates/skills/restrain/SKILL.md +76 -0
- package/templates/skills/riff/SKILL.md +23 -0
- package/templates/skills/riff-deep/SKILL.md +42 -0
- package/templates/skills/riff-max/SKILL.md +48 -0
- package/templates/skills/riff-state/SKILL.md +47 -0
- package/templates/skills/riff-up/SKILL.md +40 -0
- package/templates/skills/riff-wide/SKILL.md +42 -0
- package/templates/starter-prototype/welcome.tsx +8 -4
- package/templates/starters/standalone/README.md +1 -1
- package/templates/starters/standalone/package.json +1 -1
- package/templates/starters/turborepo/README.md +2 -2
- package/templates/starters/turborepo/apps/web/package.json +1 -1
- package/templates/starters/turborepo/apps/web/src/app.tsx +4 -4
- 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/README.md +1 -1
- 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 -133
- package/dist/server/agents.mjs +0 -771
- 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 -155
- 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 -709
- package/src/config/package-manager.ts +0 -93
- package/src/server/agent-env.ts +0 -70
- package/src/server/agents.ts +0 -1220
- package/src/server/channel.ts +0 -1161
- package/src/server/mcp-handover.ts +0 -147
- package/src/server/mcp.ts +0 -293
- 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/content/content.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
// snapshots. Every function takes the studio's content root, so they work in
|
|
3
3
|
// any project. The CLI (cli/main.ts) wires them to `dex <command>`.
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type ExecFileException,
|
|
7
|
+
execFile,
|
|
8
|
+
execFileSync,
|
|
9
|
+
} from "node:child_process";
|
|
6
10
|
import { createHash } from "node:crypto";
|
|
7
11
|
import { existsSync } from "node:fs";
|
|
8
12
|
import {
|
|
@@ -16,19 +20,14 @@ import {
|
|
|
16
20
|
} from "node:fs/promises";
|
|
17
21
|
import { homedir } from "node:os";
|
|
18
22
|
import { join, relative, resolve, sep } from "node:path";
|
|
23
|
+
import { promisify } from "node:util";
|
|
24
|
+
|
|
25
|
+
import { dexRunner, packageManager } from "@dexhq/harness/project";
|
|
26
|
+
|
|
19
27
|
import type { ResolvedDesignSystem } from "../config/design-system.ts";
|
|
20
|
-
import { dexRunner, packageManager } from "../config/package-manager.ts";
|
|
21
|
-
import { features } from "../server/features.ts";
|
|
22
28
|
import { openPresence } from "../server/presence.ts";
|
|
23
29
|
import { prepareState, studioState } from "../server/state.ts";
|
|
24
30
|
import { notRunning, studioFor } from "../server/studio-for.ts";
|
|
25
|
-
import {
|
|
26
|
-
type Authored,
|
|
27
|
-
checkFrameAnchor,
|
|
28
|
-
readAnnotations,
|
|
29
|
-
withAnnotation,
|
|
30
|
-
withoutAnnotation,
|
|
31
|
-
} from "../shared/annotations-core.ts";
|
|
32
31
|
import { TWO_VERSIONS_LEAD } from "../shared/block-merge.ts";
|
|
33
32
|
import {
|
|
34
33
|
appendOwnFrame,
|
|
@@ -36,9 +35,10 @@ import {
|
|
|
36
35
|
type Cell,
|
|
37
36
|
canvasFrames,
|
|
38
37
|
canvasProblems,
|
|
38
|
+
type PageSize,
|
|
39
39
|
placeViewInCell,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
canvasFormProblems,
|
|
41
|
+
stackPiles,
|
|
42
42
|
uniqueId,
|
|
43
43
|
type Viewport,
|
|
44
44
|
viewOf,
|
|
@@ -46,21 +46,28 @@ import {
|
|
|
46
46
|
import type { Canvas, Section, ViewFrame } from "../shared/canvas-file.ts";
|
|
47
47
|
import { isOneOf, isRecord, isText } from "../shared/checks.ts";
|
|
48
48
|
import { defaultDevice } from "../shared/devices.ts";
|
|
49
|
-
import {
|
|
49
|
+
import { jsonInLayout } from "../shared/json-style.ts";
|
|
50
50
|
import { LARGE_CANVAS_BYTES } from "../shared/live-core.ts";
|
|
51
51
|
import { targetForPath } from "../shared/live-presence.ts";
|
|
52
52
|
import {
|
|
53
53
|
combineCanvases,
|
|
54
|
-
copyOnEdit,
|
|
55
54
|
isOthers,
|
|
56
55
|
isOthersRow,
|
|
57
56
|
labelAuthors,
|
|
58
57
|
liftRows,
|
|
58
|
+
othersRowsIn,
|
|
59
59
|
ownRow,
|
|
60
60
|
ownSections,
|
|
61
|
+
savedPart,
|
|
61
62
|
withFrameUids,
|
|
62
|
-
withoutOthersRows,
|
|
63
63
|
} from "../shared/people-core.ts";
|
|
64
|
+
import {
|
|
65
|
+
type Authored,
|
|
66
|
+
checkFrameAnchor,
|
|
67
|
+
readPicks,
|
|
68
|
+
withoutPick,
|
|
69
|
+
withPick,
|
|
70
|
+
} from "../shared/picks-core.ts";
|
|
64
71
|
import type { PresenceTarget } from "../shared/presence-core.ts";
|
|
65
72
|
import {
|
|
66
73
|
framePage,
|
|
@@ -68,6 +75,7 @@ import {
|
|
|
68
75
|
newFileId,
|
|
69
76
|
PROTOTYPES_FOLDER,
|
|
70
77
|
type PrototypeFiles,
|
|
78
|
+
placeOf,
|
|
71
79
|
prototypeFiles,
|
|
72
80
|
prototypePage,
|
|
73
81
|
slugify,
|
|
@@ -82,11 +90,16 @@ import { NOT_RECOGNISED, youOf } from "../shared/studio-routes.ts";
|
|
|
82
90
|
import {
|
|
83
91
|
type AgentAction,
|
|
84
92
|
agentChange,
|
|
93
|
+
describeThread,
|
|
85
94
|
type ThreadChange,
|
|
86
95
|
} from "../shared/threads-core.ts";
|
|
96
|
+
import { withUnknownFields } from "../shared/unknown-fields.ts";
|
|
87
97
|
import { findBiome, formatText } from "./biome.ts";
|
|
88
98
|
import { loadDevices } from "./devices.ts";
|
|
89
99
|
import { inTurn, replaceFile } from "./file-turns.ts";
|
|
100
|
+
import { fileFolderFindings, studioFindings } from "./format-check.ts";
|
|
101
|
+
import { hostedPerson, isHosted } from "./hosted-person.ts";
|
|
102
|
+
import { LAYOUT_FILE, type LayoutState, studioLayout } from "./layout.ts";
|
|
90
103
|
import { checkPrototype, errorLines, findingLine } from "./prototype-checks.ts";
|
|
91
104
|
import {
|
|
92
105
|
clashingViews,
|
|
@@ -169,6 +182,8 @@ export interface CommandValues {
|
|
|
169
182
|
}
|
|
170
183
|
|
|
171
184
|
/** A path as people see it: relative to where they ran the command. */
|
|
185
|
+
const execFileAsync = promisify(execFile);
|
|
186
|
+
|
|
172
187
|
const display = (path: string): string => relative(process.cwd(), path) || ".";
|
|
173
188
|
|
|
174
189
|
const shownIn = (root: string, file: string): string =>
|
|
@@ -176,43 +191,78 @@ const shownIn = (root: string, file: string): string =>
|
|
|
176
191
|
|
|
177
192
|
export const STATUSES = ["exploring", "in-review", "handed-off", "archived"];
|
|
178
193
|
|
|
179
|
-
const DATE_RE = /^\d{4}-\d{2}-\d{2}
|
|
194
|
+
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/u;
|
|
195
|
+
|
|
180
196
|
// A GitHub username, and after it the `_company` that an enterprise's own
|
|
181
197
|
// accounts end with (ana_acme): the only place GitHub puts an underscore.
|
|
182
198
|
const GITHUB_LOGIN_RE =
|
|
183
|
-
/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?:_[a-z\d]+)?$/
|
|
184
|
-
|
|
185
|
-
const
|
|
199
|
+
/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?:_[a-z\d]+)?$/iu;
|
|
200
|
+
|
|
201
|
+
const GITHUB_NOREPLY_RE =
|
|
202
|
+
/^(?:\d+\+)?(?<login>[^@]+)@users\.noreply\.github\.com$/iu;
|
|
203
|
+
|
|
204
|
+
const LEADING_AT_RE = /^@/u;
|
|
186
205
|
const GH_TIMEOUT_MS = 5000;
|
|
187
|
-
const DOC_FILE_RE = /\.md
|
|
206
|
+
const DOC_FILE_RE = /\.md$/u;
|
|
188
207
|
|
|
189
208
|
/** A JSON file, as the shape the caller reads it into. */
|
|
190
209
|
const readJson = async <T>(path: string): Promise<T> => {
|
|
191
210
|
try {
|
|
192
211
|
return JSON.parse(await readFile(path, "utf8"));
|
|
193
212
|
} catch (error) {
|
|
194
|
-
|
|
213
|
+
// SAFETY: readFile and JSON.parse fail with Errors.
|
|
214
|
+
throw new Error(`${display(path)}: ${(error as Error).message}`, {
|
|
215
|
+
cause: error,
|
|
216
|
+
});
|
|
195
217
|
}
|
|
196
218
|
};
|
|
197
219
|
|
|
198
|
-
|
|
199
|
-
|
|
220
|
+
/**
|
|
221
|
+
* One of the format's JSON files, laid out as jsonInLayout lays out every
|
|
222
|
+
* one Dex writes: as it was, or as Biome and Prettier would lay a new one.
|
|
223
|
+
*/
|
|
224
|
+
// oxlint-disable-next-line anti-slop/no-unknown-parameters -- any JSON value: jsonInLayout writes whatever it is given
|
|
225
|
+
const writeJson = async (path: string, value: unknown): Promise<void> =>
|
|
226
|
+
writeFile(
|
|
227
|
+
path,
|
|
228
|
+
jsonInLayout(value, await readFile(path, "utf8").catch(() => undefined))
|
|
229
|
+
);
|
|
200
230
|
|
|
201
231
|
const listFiles = async (path: string, pattern: RegExp): Promise<string[]> => {
|
|
202
232
|
if (!existsSync(path)) {
|
|
203
233
|
return [];
|
|
204
234
|
}
|
|
235
|
+
|
|
205
236
|
const entries = await readdir(path, { withFileTypes: true });
|
|
237
|
+
|
|
206
238
|
return entries
|
|
207
239
|
.filter((entry) => entry.isFile() && pattern.test(entry.name))
|
|
208
240
|
.map((entry) => entry.name.replace(pattern, ""))
|
|
209
|
-
.
|
|
241
|
+
.toSorted();
|
|
210
242
|
};
|
|
211
243
|
|
|
212
244
|
// --- Validation -------------------------------------------------------------
|
|
213
245
|
|
|
214
|
-
/**
|
|
215
|
-
|
|
246
|
+
/** A contributor's fields, as read from JSON before they are checked. */
|
|
247
|
+
interface UncheckedContributor {
|
|
248
|
+
discipline?: unknown;
|
|
249
|
+
git?: unknown;
|
|
250
|
+
github?: unknown;
|
|
251
|
+
name?: unknown;
|
|
252
|
+
slug?: unknown;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** A file's manifest fields, as read from JSON before they are checked. */
|
|
256
|
+
interface UncheckedManifest {
|
|
257
|
+
cover?: unknown;
|
|
258
|
+
created?: unknown;
|
|
259
|
+
description?: unknown;
|
|
260
|
+
status?: unknown;
|
|
261
|
+
tags?: unknown;
|
|
262
|
+
title?: unknown;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* oxlint-disable anti-slop/no-unknown-parameters -- these check JSON as it is read, before it is trusted */
|
|
216
266
|
|
|
217
267
|
/**
|
|
218
268
|
* What is wrong with a contributor's `github`, or undefined: not a GitHub
|
|
@@ -226,13 +276,17 @@ function githubProblem(
|
|
|
226
276
|
if (github === undefined) {
|
|
227
277
|
return;
|
|
228
278
|
}
|
|
279
|
+
|
|
229
280
|
if (!(isText(github) && GITHUB_LOGIN_RE.test(github))) {
|
|
230
281
|
return '"github" must be a GitHub username';
|
|
231
282
|
}
|
|
283
|
+
|
|
232
284
|
const account = github.toLowerCase();
|
|
285
|
+
|
|
233
286
|
if (accounts.has(account)) {
|
|
234
287
|
return `"github" (${github}) is another contributor's too`;
|
|
235
288
|
}
|
|
289
|
+
|
|
236
290
|
accounts.add(account);
|
|
237
291
|
}
|
|
238
292
|
|
|
@@ -240,66 +294,97 @@ export function contributorProblems(contributors: unknown): string[] {
|
|
|
240
294
|
if (!Array.isArray(contributors)) {
|
|
241
295
|
return ["contributors.json must be an array"];
|
|
242
296
|
}
|
|
297
|
+
|
|
243
298
|
const problems: string[] = [];
|
|
244
299
|
const slugs = new Set<unknown>();
|
|
245
300
|
const accounts = new Set<string>();
|
|
246
|
-
|
|
301
|
+
|
|
302
|
+
// SAFETY: each field is checked before it is trusted, and an entry that is
|
|
303
|
+
// null or not an object reads as one with no fields.
|
|
304
|
+
for (const contributor of contributors as (
|
|
305
|
+
| UncheckedContributor
|
|
306
|
+
| null
|
|
307
|
+
| undefined
|
|
308
|
+
)[]) {
|
|
247
309
|
const label = contributor?.slug ?? "(no slug)";
|
|
310
|
+
|
|
248
311
|
if (!isSlug(contributor?.slug)) {
|
|
249
312
|
problems.push(`contributor ${label}: "slug" must be kebab-case`);
|
|
250
313
|
} else if (slugs.has(contributor.slug)) {
|
|
251
314
|
problems.push(`contributor ${label} is listed twice`);
|
|
252
315
|
}
|
|
316
|
+
|
|
253
317
|
slugs.add(contributor?.slug);
|
|
318
|
+
|
|
254
319
|
if (!isText(contributor?.name)) {
|
|
255
320
|
problems.push(`contributor ${label}: "name" is required`);
|
|
256
321
|
}
|
|
322
|
+
|
|
257
323
|
if (!isOneOf(DISCIPLINES, contributor?.discipline)) {
|
|
258
324
|
problems.push(
|
|
259
325
|
`contributor ${label}: "discipline" must be one of ${DISCIPLINES.join(", ")}`
|
|
260
326
|
);
|
|
261
327
|
}
|
|
328
|
+
|
|
262
329
|
const git = contributor?.git;
|
|
330
|
+
|
|
263
331
|
if (!(Array.isArray(git) && git.every(isText))) {
|
|
264
332
|
problems.push(
|
|
265
333
|
`contributor ${label}: "git" must be a list of git user names`
|
|
266
334
|
);
|
|
267
335
|
}
|
|
336
|
+
|
|
268
337
|
const github = githubProblem(contributor?.github, accounts);
|
|
338
|
+
|
|
269
339
|
if (github) {
|
|
270
340
|
problems.push(`contributor ${label}: ${github}`);
|
|
271
341
|
}
|
|
272
342
|
}
|
|
343
|
+
|
|
273
344
|
return problems;
|
|
274
345
|
}
|
|
275
346
|
|
|
276
347
|
export function manifestProblems(manifest: unknown): string[] {
|
|
277
|
-
|
|
348
|
+
// SAFETY: each field is checked before it is trusted, and a manifest that
|
|
349
|
+
// is null or not an object reads as one with no fields.
|
|
350
|
+
const fields = manifest as UncheckedManifest | null | undefined;
|
|
278
351
|
const problems: string[] = [];
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
352
|
+
|
|
353
|
+
if (!isText(fields?.title)) {
|
|
354
|
+
problems.push('"title" must be a non-empty string');
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// The question the file answers, when there is one to put in it.
|
|
358
|
+
if (fields?.description !== undefined && !isText(fields.description)) {
|
|
359
|
+
problems.push('"description" must be a non-empty string when given');
|
|
283
360
|
}
|
|
361
|
+
|
|
284
362
|
if (!isOneOf(STATUSES, fields?.status)) {
|
|
285
363
|
problems.push(`"status" must be one of ${STATUSES.join(", ")}`);
|
|
286
364
|
}
|
|
365
|
+
|
|
287
366
|
// test() reads whatever it is given as a string.
|
|
288
367
|
if (!DATE_RE.test(String(fields?.created ?? ""))) {
|
|
289
368
|
problems.push('"created" must be a YYYY-MM-DD date');
|
|
290
369
|
}
|
|
370
|
+
|
|
291
371
|
const tags = fields?.tags;
|
|
372
|
+
|
|
292
373
|
if (tags !== undefined && !(Array.isArray(tags) && tags.every(isText))) {
|
|
293
374
|
problems.push('"tags" must be a list of strings');
|
|
294
375
|
}
|
|
376
|
+
|
|
295
377
|
if (fields?.cover !== undefined) {
|
|
296
378
|
const cover = checkFrameAnchor(fields.cover, "cover");
|
|
379
|
+
|
|
297
380
|
if ("problems" in cover) {
|
|
298
381
|
problems.push(...cover.problems);
|
|
299
382
|
}
|
|
300
383
|
}
|
|
384
|
+
|
|
301
385
|
return problems;
|
|
302
386
|
}
|
|
387
|
+
/* oxlint-enable anti-slop/no-unknown-parameters */
|
|
303
388
|
|
|
304
389
|
/** contributors.json is missing until Dex first starts there or someone joins. */
|
|
305
390
|
const readContributors = (path: string): Promise<Contributor[]> =>
|
|
@@ -309,14 +394,18 @@ export async function loadStudio(
|
|
|
309
394
|
root: string
|
|
310
395
|
): Promise<{ contributors: Contributor[]; root: string }> {
|
|
311
396
|
const contributors = await readContributors(join(root, "contributors.json"));
|
|
397
|
+
|
|
312
398
|
return { root, contributors };
|
|
313
399
|
}
|
|
314
400
|
|
|
315
401
|
/** The views and docs a prototype's canvas may point at. */
|
|
316
402
|
export async function knownFor(slug: string, root: string): Promise<Known> {
|
|
317
403
|
const paths = prototypePaths(root, slug);
|
|
404
|
+
|
|
405
|
+
const views = await viewFiles(root, slug);
|
|
406
|
+
|
|
318
407
|
return {
|
|
319
|
-
views: [...
|
|
408
|
+
views: [...views.keys()].toSorted(),
|
|
320
409
|
docs: await listFiles(paths.docs, DOC_FILE_RE),
|
|
321
410
|
};
|
|
322
411
|
}
|
|
@@ -331,43 +420,97 @@ export interface CheckReport {
|
|
|
331
420
|
async function prototypeIssues(
|
|
332
421
|
root: string,
|
|
333
422
|
{ slug, path, manifest, problem }: PrototypeFolder,
|
|
334
|
-
designSystem: ResolvedDesignSystem | undefined
|
|
423
|
+
designSystem: ResolvedDesignSystem | undefined,
|
|
424
|
+
layout: LayoutState
|
|
335
425
|
): Promise<CheckReport> {
|
|
336
426
|
// A bad name, or a manifest that is missing or cannot be read.
|
|
337
427
|
if (problem) {
|
|
338
428
|
return { problems: [`${path}: ${problem}`], warnings: [] };
|
|
339
429
|
}
|
|
430
|
+
|
|
340
431
|
// Where each part is on disk, and as the problems name it. prototypePaths
|
|
341
432
|
// has thrown for any name prototypeFiles refuses.
|
|
342
433
|
const paths = prototypePaths(root, slug);
|
|
434
|
+
// SAFETY: prototypePaths has thrown for any name prototypeFiles refuses.
|
|
343
435
|
const files = prototypeFiles(slug) as PrototypeFiles;
|
|
436
|
+
|
|
437
|
+
// The manifest the folder has, prototype.json in one from before.
|
|
438
|
+
const manifestPath =
|
|
439
|
+
paths.manifest === join(root, files.manifest)
|
|
440
|
+
? files.manifest
|
|
441
|
+
: files.legacyManifest;
|
|
442
|
+
|
|
344
443
|
const problems = manifestProblems(manifest).map(
|
|
345
|
-
(
|
|
444
|
+
(each) => `${manifestPath}: ${each}`
|
|
346
445
|
);
|
|
446
|
+
|
|
447
|
+
// Files whose own checks found a problem: the schema needn't say it too.
|
|
448
|
+
const quiet = new Set(problems.length > 0 ? [manifestPath] : []);
|
|
449
|
+
const warnings: string[] = [];
|
|
450
|
+
|
|
451
|
+
// An older studio is said once, of its .layout; a file left behind in a
|
|
452
|
+
// studio that is in this version is said of itself.
|
|
453
|
+
if (manifestPath === files.legacyManifest && layout === "known") {
|
|
454
|
+
warnings.push(
|
|
455
|
+
`${manifestPath}: the manifest's name before file.json; \`npx dex upgrade\` renames it.`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
347
459
|
const { views, docs } = await knownFor(slug, root);
|
|
460
|
+
|
|
348
461
|
for (const [name, people] of await clashingViews(root, slug)) {
|
|
349
462
|
problems.push(
|
|
350
463
|
`${path}: ${people.join(" and ")} each have a view named "${name}"; the canvas shows only ${people[0]}'s. Rename one, and the frames that show it.`
|
|
351
464
|
);
|
|
352
465
|
}
|
|
466
|
+
|
|
353
467
|
// A new file has no view until its first frame is drawn: that is no
|
|
354
468
|
// problem.
|
|
469
|
+
const copied: string[] = [];
|
|
470
|
+
|
|
355
471
|
for (const part of await canvasParts(slug, root)) {
|
|
472
|
+
const found = canvasProblems(part.canvas, { views, docs });
|
|
473
|
+
|
|
474
|
+
if (found.length > 0) {
|
|
475
|
+
quiet.add(shownIn(root, part.file));
|
|
476
|
+
}
|
|
477
|
+
|
|
356
478
|
problems.push(
|
|
357
|
-
...
|
|
358
|
-
...canvasProblems(part.canvas, { views, docs }),
|
|
359
|
-
...rowTitleProblems(part.canvas),
|
|
360
|
-
].map((problem) => `${shownIn(root, part.file)}: ${problem}`)
|
|
479
|
+
...found.map((each) => `${shownIn(root, part.file)}: ${each}`)
|
|
361
480
|
);
|
|
481
|
+
|
|
482
|
+
// The canvas still reads, at worst showing the row twice: only a warning.
|
|
483
|
+
for (const { section, row, author } of othersRowsIn(
|
|
484
|
+
part.canvas,
|
|
485
|
+
part.person
|
|
486
|
+
)) {
|
|
487
|
+
copied.push(
|
|
488
|
+
`${shownIn(root, part.file)}: section "${section}" › row "${row}" is ${author}'s, copied into ${part.person}'s file, so the canvas can show it twice. ${part.person}'s next save in Dex takes the copy out.`
|
|
489
|
+
);
|
|
490
|
+
}
|
|
362
491
|
}
|
|
492
|
+
|
|
363
493
|
// Picks never change what a prototype shows, so a broken file only warns.
|
|
364
|
-
const
|
|
494
|
+
const { problems: picks } = await readPrototypePicks(slug, root);
|
|
495
|
+
|
|
496
|
+
// Each line names its file first: "files/…/picks.json: …".
|
|
497
|
+
for (const line of picks) {
|
|
498
|
+
quiet.add(line.slice(0, line.indexOf(": ")));
|
|
499
|
+
}
|
|
500
|
+
|
|
365
501
|
const findings = await checkPrototype(root, paths.folder, designSystem);
|
|
366
502
|
problems.push(...errorLines(findings));
|
|
503
|
+
// Each path's place, and each file against the published schemas.
|
|
504
|
+
const format = await fileFolderFindings(root, paths.folder, quiet);
|
|
505
|
+
problems.push(...format.problems);
|
|
506
|
+
|
|
367
507
|
return {
|
|
368
508
|
problems,
|
|
369
509
|
warnings: [
|
|
370
|
-
...
|
|
510
|
+
...warnings,
|
|
511
|
+
...format.warnings,
|
|
512
|
+
...copied,
|
|
513
|
+
...picks,
|
|
371
514
|
...findings
|
|
372
515
|
.filter((finding) => finding.level === "warning")
|
|
373
516
|
.map(findingLine),
|
|
@@ -386,54 +529,103 @@ export async function checkStudio(
|
|
|
386
529
|
{ designSystem }: { designSystem?: ResolvedDesignSystem } = {}
|
|
387
530
|
): Promise<CheckReport> {
|
|
388
531
|
const { contributors } = await loadStudio(root);
|
|
532
|
+
const devices = await loadDevices(root);
|
|
533
|
+
|
|
389
534
|
const report: CheckReport = {
|
|
390
535
|
problems: contributorProblems(contributors).map(
|
|
391
536
|
(problem) => `contributors.json: ${problem}`
|
|
392
537
|
),
|
|
393
538
|
// The studio reads past them, so they are only warned of.
|
|
394
|
-
warnings:
|
|
539
|
+
warnings: devices.problems,
|
|
395
540
|
};
|
|
541
|
+
|
|
542
|
+
// files/ itself, the .layout's text and contributors.json, as published.
|
|
543
|
+
const studio = await studioFindings(root, {
|
|
544
|
+
quiet: report.problems.length > 0,
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
report.problems.push(...studio.problems);
|
|
548
|
+
report.warnings.push(...studio.warnings);
|
|
549
|
+
// Files newer than this Dex reads can't be checked by it; older ones are
|
|
550
|
+
// read all the same, and upgrade moves them on.
|
|
551
|
+
const layout = await studioLayout(root);
|
|
552
|
+
|
|
553
|
+
if (layout.state === "newer" && layout.message) {
|
|
554
|
+
report.problems.push(`${LAYOUT_FILE}: ${layout.message}`);
|
|
555
|
+
|
|
556
|
+
return report;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const unreadable = studio.problems.some((line) =>
|
|
560
|
+
line.startsWith(LAYOUT_FILE)
|
|
561
|
+
);
|
|
562
|
+
|
|
563
|
+
if (layout.state === "older" && layout.message && !unreadable) {
|
|
564
|
+
report.warnings.push(`${LAYOUT_FILE}: ${layout.message}`);
|
|
565
|
+
}
|
|
566
|
+
|
|
396
567
|
for (const folder of await walkPrototypes(root)) {
|
|
397
568
|
const { problems, warnings } = await prototypeIssues(
|
|
398
569
|
root,
|
|
399
570
|
folder,
|
|
400
|
-
designSystem
|
|
571
|
+
designSystem,
|
|
572
|
+
layout.state
|
|
401
573
|
);
|
|
574
|
+
|
|
402
575
|
report.problems.push(...problems);
|
|
403
576
|
report.warnings.push(
|
|
404
577
|
...warnings,
|
|
405
578
|
...(await twoVersionsIn(root, folder.folder))
|
|
406
579
|
);
|
|
407
580
|
}
|
|
581
|
+
|
|
408
582
|
return report;
|
|
409
583
|
}
|
|
410
584
|
|
|
411
|
-
|
|
585
|
+
/** Whether Dex's spec merge merges a path in a file's folder. */
|
|
586
|
+
const mergedBySpecs = (path: string): boolean =>
|
|
587
|
+
["spec", "doc"].includes(placeOf(path)?.part ?? "");
|
|
412
588
|
|
|
413
|
-
/**
|
|
589
|
+
/**
|
|
590
|
+
* Specs, notes, slides and docs in a prototype's folder still holding two
|
|
591
|
+
* versions to choose from.
|
|
592
|
+
*/
|
|
414
593
|
async function twoVersionsIn(root: string, folder: string): Promise<string[]> {
|
|
415
594
|
const names = await readdir(folder, { recursive: true }).catch(
|
|
416
|
-
()
|
|
595
|
+
(): string[] => []
|
|
417
596
|
);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
597
|
+
|
|
598
|
+
const merged = names
|
|
599
|
+
.map((name) => name.split(sep).join("/"))
|
|
600
|
+
.filter(mergedBySpecs)
|
|
601
|
+
.toSorted();
|
|
602
|
+
|
|
603
|
+
const warnings = await Promise.all(
|
|
604
|
+
merged.map(async (name) => {
|
|
605
|
+
const file = join(folder, name);
|
|
606
|
+
const text = await readFile(file, "utf8").catch(() => "");
|
|
607
|
+
const pairs = text.split(TWO_VERSIONS_LEAD).length - 1;
|
|
608
|
+
|
|
609
|
+
return pairs > 0
|
|
610
|
+
? [
|
|
611
|
+
`${relative(root, file)}: ${pairs === 1 ? "a paragraph has" : `${pairs} paragraphs have`} two versions, written at the same time: keep one in the spec.`,
|
|
612
|
+
]
|
|
613
|
+
: [];
|
|
614
|
+
})
|
|
615
|
+
);
|
|
616
|
+
|
|
617
|
+
return warnings.flat();
|
|
430
618
|
}
|
|
431
619
|
|
|
432
620
|
/** Every problem in the studio (checkStudio's), without the warnings. */
|
|
433
621
|
export const check = async (
|
|
434
622
|
root: string,
|
|
435
623
|
options: { designSystem?: ResolvedDesignSystem } = {}
|
|
436
|
-
): Promise<string[]> =>
|
|
624
|
+
): Promise<string[]> => {
|
|
625
|
+
const { problems } = await checkStudio(root, options);
|
|
626
|
+
|
|
627
|
+
return problems;
|
|
628
|
+
};
|
|
437
629
|
|
|
438
630
|
// --- Saving the canvas --------------------------------------------------------
|
|
439
631
|
//
|
|
@@ -450,9 +642,11 @@ interface CanvasPart {
|
|
|
450
642
|
}
|
|
451
643
|
|
|
452
644
|
/**
|
|
453
|
-
* Each person's canvas.json in a prototype
|
|
454
|
-
*
|
|
455
|
-
*
|
|
645
|
+
* Each person's canvas.json in a prototype, as this Dex reads it: with the
|
|
646
|
+
* piles a development Dex marked made stacks (stackPiles), which their next
|
|
647
|
+
* save writes. A canvas.json beside the manifest, from before people/, is
|
|
648
|
+
* not read: `dex upgrade` moves it into its person's folder
|
|
649
|
+
* (people-folders.ts).
|
|
456
650
|
*/
|
|
457
651
|
export async function canvasParts(
|
|
458
652
|
slug: string,
|
|
@@ -460,12 +654,16 @@ export async function canvasParts(
|
|
|
460
654
|
): Promise<CanvasPart[]> {
|
|
461
655
|
const paths = prototypePaths(root, slug);
|
|
462
656
|
const parts: CanvasPart[] = [];
|
|
657
|
+
|
|
463
658
|
for (const person of await peopleOf(root, slug)) {
|
|
464
659
|
const file = paths.person(person)?.canvas;
|
|
660
|
+
|
|
465
661
|
if (file && existsSync(file)) {
|
|
466
|
-
|
|
662
|
+
const canvas = stackPiles(await readJson<Canvas>(file));
|
|
663
|
+
parts.push({ person, file, canvas });
|
|
467
664
|
}
|
|
468
665
|
}
|
|
666
|
+
|
|
469
667
|
return parts;
|
|
470
668
|
}
|
|
471
669
|
|
|
@@ -477,9 +675,11 @@ export async function canvasParts(
|
|
|
477
675
|
*/
|
|
478
676
|
const revisionOf = (parts: CanvasPart[], person: string) => {
|
|
479
677
|
const part = parts.find((each) => each.person === person);
|
|
678
|
+
|
|
480
679
|
const hash = part
|
|
481
680
|
? createHash("sha1").update(JSON.stringify(part.canvas)).digest("hex")
|
|
482
681
|
: "";
|
|
682
|
+
|
|
483
683
|
return `${person}:${hash}`;
|
|
484
684
|
};
|
|
485
685
|
|
|
@@ -490,6 +690,7 @@ export async function readCanvasRevision(
|
|
|
490
690
|
root: string
|
|
491
691
|
): Promise<CanvasRevision> {
|
|
492
692
|
const parts = await canvasParts(slug, root);
|
|
693
|
+
|
|
493
694
|
return {
|
|
494
695
|
canvas: combineCanvases(parts),
|
|
495
696
|
person,
|
|
@@ -507,6 +708,7 @@ export async function readCanvas(slug: string, root: string): Promise<Canvas> {
|
|
|
507
708
|
|
|
508
709
|
// A save formats with Biome, which may take its whole timeout.
|
|
509
710
|
const CANVAS_LOCK_STALE_MS = 15_000;
|
|
711
|
+
|
|
510
712
|
/** Run `work` in turn with a prototype's canvas saves (trash.ts too). */
|
|
511
713
|
export const queued = <T>(
|
|
512
714
|
root: string,
|
|
@@ -552,34 +754,63 @@ export function writeCanvas(
|
|
|
552
754
|
return queued(root, save.slug, () => saveCanvasNow(save, root));
|
|
553
755
|
}
|
|
554
756
|
|
|
757
|
+
/**
|
|
758
|
+
* The row a new row goes right under, as the + under it asks: the one
|
|
759
|
+
* before the row `above` names (above the first, the first: as near as it
|
|
760
|
+
* gets), else the last.
|
|
761
|
+
*/
|
|
762
|
+
const rowBefore = <R extends { id: string }>(
|
|
763
|
+
rows: readonly R[],
|
|
764
|
+
above?: string
|
|
765
|
+
): R | undefined => {
|
|
766
|
+
const at = rows.findIndex((row) => row.id === above);
|
|
767
|
+
|
|
768
|
+
return at === -1 ? rows.at(-1) : rows[Math.max(0, at - 1)];
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
/** A canvas and a cell on it. */
|
|
772
|
+
export interface CanvasCell {
|
|
773
|
+
canvas: Canvas;
|
|
774
|
+
cell: Cell;
|
|
775
|
+
}
|
|
776
|
+
|
|
555
777
|
/**
|
|
556
778
|
* A cell the person may add to: theirs, or, in someone else's row, the same
|
|
557
779
|
* step of the person's own row right below it (ownRow; a new one with
|
|
558
|
-
* `newRow`).
|
|
780
|
+
* `newRow`). A new row in someone else's section goes where the cell asks
|
|
781
|
+
* (rowBefore): in the person's own row there, or one right below theirs.
|
|
559
782
|
*/
|
|
560
783
|
export function ownCell(
|
|
561
784
|
canvas: Canvas,
|
|
562
785
|
cell: Cell,
|
|
563
786
|
person: string,
|
|
564
787
|
{ newRow = false }: { newRow?: boolean } = {}
|
|
565
|
-
):
|
|
788
|
+
): CanvasCell {
|
|
566
789
|
const section = canvas.sections.find((entry) => entry.id === cell.section);
|
|
567
790
|
const row = section?.rows.find((entry) => entry.id === cell.row);
|
|
791
|
+
|
|
568
792
|
const theirs = row
|
|
569
793
|
? section && isOthersRow(section, row, person)
|
|
570
794
|
: section && isOthers(section, person);
|
|
795
|
+
|
|
571
796
|
if (!(section && theirs)) {
|
|
572
797
|
return { canvas, cell };
|
|
573
798
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
799
|
+
|
|
800
|
+
const anchor = row ?? rowBefore(section.rows, cell.above);
|
|
801
|
+
|
|
802
|
+
// A new row's place is the person's own row already: it goes in that.
|
|
803
|
+
if (!row && anchor && !isOthersRow(section, anchor, person)) {
|
|
804
|
+
return { canvas, cell: { ...cell, row: anchor.id } };
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
const own = ownRow(section, anchor?.id ?? "main", person, { newRow });
|
|
808
|
+
|
|
580
809
|
return {
|
|
581
810
|
canvas: {
|
|
582
811
|
sections: canvas.sections.map((entry) =>
|
|
812
|
+
// SAFETY: ownRow gives back the section it was given, a Section,
|
|
813
|
+
// with its rows changed.
|
|
583
814
|
entry === section ? (own.section as Section) : entry
|
|
584
815
|
),
|
|
585
816
|
},
|
|
@@ -599,8 +830,10 @@ export function placeViewFrame(
|
|
|
599
830
|
cell,
|
|
600
831
|
view,
|
|
601
832
|
viewport,
|
|
833
|
+
size,
|
|
602
834
|
person,
|
|
603
835
|
newRow,
|
|
836
|
+
stack,
|
|
604
837
|
}: {
|
|
605
838
|
cell: Cell;
|
|
606
839
|
/**
|
|
@@ -610,7 +843,11 @@ export function placeViewFrame(
|
|
|
610
843
|
newRow?: boolean;
|
|
611
844
|
/** Who is placing it: the cell must be in one of their sections. */
|
|
612
845
|
person: string;
|
|
846
|
+
/** The size asked for it: a request's, set on the canvas. */
|
|
847
|
+
size?: PageSize;
|
|
613
848
|
slug: string;
|
|
849
|
+
/** On top of the stack in the cell, rather than a column of its own. */
|
|
850
|
+
stack?: boolean;
|
|
614
851
|
view: string;
|
|
615
852
|
viewport?: Viewport;
|
|
616
853
|
},
|
|
@@ -621,23 +858,31 @@ export function placeViewFrame(
|
|
|
621
858
|
> {
|
|
622
859
|
return queued(root, slug, async () => {
|
|
623
860
|
const saver = person;
|
|
861
|
+
|
|
624
862
|
const { canvas, cell: own } = ownCell(
|
|
625
863
|
await readCanvas(slug, root),
|
|
626
864
|
cell,
|
|
627
865
|
saver,
|
|
628
866
|
{ newRow }
|
|
629
867
|
);
|
|
868
|
+
|
|
630
869
|
const { devices } = await loadDevices(root);
|
|
870
|
+
|
|
631
871
|
const placed = placeViewInCell(canvas, own, {
|
|
632
872
|
view,
|
|
633
873
|
viewport,
|
|
874
|
+
size,
|
|
875
|
+
stack,
|
|
634
876
|
fallback: defaultDevice(devices),
|
|
635
877
|
});
|
|
878
|
+
|
|
636
879
|
if ("problem" in placed) {
|
|
637
880
|
return { problems: [placed.problem] };
|
|
638
881
|
}
|
|
882
|
+
|
|
639
883
|
const uidAt = (on: Canvas | undefined) =>
|
|
640
884
|
canvasFrames(on).find((entry) => entry.key === placed.key)?.frame.uid;
|
|
885
|
+
|
|
641
886
|
if (!placed.added) {
|
|
642
887
|
return {
|
|
643
888
|
key: placed.key,
|
|
@@ -646,13 +891,16 @@ export function placeViewFrame(
|
|
|
646
891
|
uid: uidAt(canvas),
|
|
647
892
|
};
|
|
648
893
|
}
|
|
894
|
+
|
|
649
895
|
const saved = await saveCanvasNow(
|
|
650
896
|
{ slug, canvas: placed.canvas, person: saver },
|
|
651
897
|
root
|
|
652
898
|
);
|
|
899
|
+
|
|
653
900
|
if (saved.problems) {
|
|
654
901
|
return { problems: saved.problems };
|
|
655
902
|
}
|
|
903
|
+
|
|
656
904
|
return {
|
|
657
905
|
key: placed.key,
|
|
658
906
|
added: true,
|
|
@@ -662,6 +910,13 @@ export function placeViewFrame(
|
|
|
662
910
|
});
|
|
663
911
|
}
|
|
664
912
|
|
|
913
|
+
/** A save's canvas and files, its views renamed where they clash. */
|
|
914
|
+
interface FreedNames {
|
|
915
|
+
canvas: Canvas;
|
|
916
|
+
stylesheets: Record<string, string>;
|
|
917
|
+
views: Record<string, string>;
|
|
918
|
+
}
|
|
919
|
+
|
|
665
920
|
/**
|
|
666
921
|
* New views by names someone else's views already have, renamed to the next
|
|
667
922
|
* free name, with the frames in the person's own sections that show them.
|
|
@@ -671,13 +926,10 @@ function freeViewNames(
|
|
|
671
926
|
{ views = {}, stylesheets = {} }: CanvasSave,
|
|
672
927
|
existing: Map<string, ViewFile>,
|
|
673
928
|
person: string
|
|
674
|
-
): {
|
|
675
|
-
canvas: Canvas;
|
|
676
|
-
stylesheets: Record<string, string>;
|
|
677
|
-
views: Record<string, string>;
|
|
678
|
-
} {
|
|
929
|
+
): FreedNames {
|
|
679
930
|
const taken = new Set([...existing.keys(), ...Object.keys(views)]);
|
|
680
931
|
const renamed = new Map<string, string>();
|
|
932
|
+
|
|
681
933
|
for (const name of Object.keys(views)) {
|
|
682
934
|
if ((existing.get(name)?.person ?? person) !== person) {
|
|
683
935
|
const free = uniqueId(name, taken);
|
|
@@ -685,14 +937,18 @@ function freeViewNames(
|
|
|
685
937
|
renamed.set(name, free);
|
|
686
938
|
}
|
|
687
939
|
}
|
|
940
|
+
|
|
688
941
|
if (renamed.size === 0) {
|
|
689
942
|
return { canvas, views, stylesheets };
|
|
690
943
|
}
|
|
944
|
+
|
|
691
945
|
const to = (name: string) => renamed.get(name) ?? name;
|
|
946
|
+
|
|
692
947
|
const rename = (files: Record<string, string>) =>
|
|
693
948
|
Object.fromEntries(
|
|
694
949
|
Object.entries(files).map(([name, text]) => [to(name), text])
|
|
695
950
|
);
|
|
951
|
+
|
|
696
952
|
return {
|
|
697
953
|
views: rename(views),
|
|
698
954
|
stylesheets: rename(stylesheets),
|
|
@@ -706,6 +962,7 @@ function freeViewNames(
|
|
|
706
962
|
...row,
|
|
707
963
|
frames: row.frames.map((frame) => {
|
|
708
964
|
const view = viewOf(frame);
|
|
965
|
+
|
|
709
966
|
return view ? { ...view, view: to(view.view) } : frame;
|
|
710
967
|
}),
|
|
711
968
|
}
|
|
@@ -724,18 +981,23 @@ async function saveCanvasNow(
|
|
|
724
981
|
const paths = prototypePaths(root, slug);
|
|
725
982
|
const { person } = save;
|
|
726
983
|
const own = paths.person(person);
|
|
984
|
+
|
|
727
985
|
if (!own) {
|
|
728
986
|
return { problems: [`"${person}" is not a contributor's slug.`] };
|
|
729
987
|
}
|
|
988
|
+
|
|
730
989
|
const parts = await canvasParts(slug, root);
|
|
990
|
+
|
|
731
991
|
if (
|
|
732
992
|
save.revision !== undefined &&
|
|
733
993
|
save.revision !== revisionOf(parts, person)
|
|
734
994
|
) {
|
|
735
995
|
return { stale: true };
|
|
736
996
|
}
|
|
997
|
+
|
|
737
998
|
const existing = await viewFiles(root, slug);
|
|
738
999
|
const onDisk = combineCanvases(parts);
|
|
1000
|
+
|
|
739
1001
|
// Whose each row is, from disk only: by its own author, else its
|
|
740
1002
|
// section's. What the body claims is not asked, and a row that is not on
|
|
741
1003
|
// disk yet is the saver's.
|
|
@@ -747,14 +1009,20 @@ async function saveCanvasNow(
|
|
|
747
1009
|
])
|
|
748
1010
|
)
|
|
749
1011
|
);
|
|
750
|
-
|
|
1012
|
+
|
|
1013
|
+
const malformed = canvasFormProblems(save.canvas, (section, row) => {
|
|
751
1014
|
const owner = owners.get(`${section.id}/${row.id}`);
|
|
1015
|
+
|
|
752
1016
|
return owner !== undefined && owner !== person;
|
|
753
1017
|
});
|
|
1018
|
+
|
|
754
1019
|
if (malformed.length > 0) {
|
|
755
1020
|
return { problems: malformed };
|
|
756
1021
|
}
|
|
1022
|
+
|
|
1023
|
+
// SAFETY: canvasFormProblems found nothing wrong with it, so it is a Canvas.
|
|
757
1024
|
const sent = (save.canvas as Canvas).sections;
|
|
1025
|
+
|
|
758
1026
|
const labelled: Canvas = {
|
|
759
1027
|
sections: labelAuthors(
|
|
760
1028
|
sent,
|
|
@@ -763,12 +1031,15 @@ async function saveCanvasNow(
|
|
|
763
1031
|
save.revision !== undefined
|
|
764
1032
|
),
|
|
765
1033
|
};
|
|
1034
|
+
|
|
766
1035
|
const renamed = Object.fromEntries(
|
|
767
1036
|
sent.flatMap((section, index) => {
|
|
768
1037
|
const id = labelled.sections[index]?.id;
|
|
1038
|
+
|
|
769
1039
|
return id === undefined || id === section.id ? [] : [[section.id, id]];
|
|
770
1040
|
})
|
|
771
1041
|
);
|
|
1042
|
+
|
|
772
1043
|
// Nobody picks names: a new view by a name someone else has takes the
|
|
773
1044
|
// next free one, and the person's frames follow it.
|
|
774
1045
|
const {
|
|
@@ -776,75 +1047,97 @@ async function saveCanvasNow(
|
|
|
776
1047
|
views,
|
|
777
1048
|
stylesheets,
|
|
778
1049
|
} = freeViewNames(labelled, save, existing, person);
|
|
1050
|
+
|
|
779
1051
|
// A change to someone else's section goes into a copy of it that is the
|
|
780
|
-
// saver's; then only the saver's sections are written,
|
|
781
|
-
// else's stay as their files have them.
|
|
1052
|
+
// saver's; then only the saver's sections are written, without others'
|
|
1053
|
+
// rows, and everyone else's stay as their files have them.
|
|
782
1054
|
const now = new Date().toISOString();
|
|
1055
|
+
|
|
783
1056
|
const lifted = liftRows(
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
1057
|
+
savedPart(onDisk, named, person, {
|
|
1058
|
+
onRevision: save.revision !== undefined,
|
|
1059
|
+
}),
|
|
787
1060
|
person
|
|
788
1061
|
);
|
|
789
|
-
|
|
790
|
-
//
|
|
791
|
-
//
|
|
1062
|
+
|
|
1063
|
+
// Uids keep a frame the same frame when it moves, so picks and comments
|
|
1064
|
+
// follow it: each save gives the saver's frames theirs, and marks the file
|
|
1065
|
+
// as having given them.
|
|
792
1066
|
const given =
|
|
793
1067
|
parts.find((part) => part.person === person)?.canvas.frameUids === true;
|
|
794
|
-
|
|
1068
|
+
|
|
795
1069
|
const sections = ownSections(
|
|
796
|
-
|
|
1070
|
+
withFrameUids(lifted, person, { given, previous: onDisk }),
|
|
797
1071
|
person,
|
|
798
1072
|
now
|
|
799
1073
|
);
|
|
800
|
-
|
|
801
|
-
|
|
1074
|
+
|
|
1075
|
+
const mine: Canvas = { frameUids: true, ...sections };
|
|
802
1076
|
// A teammate's frame, such as one made in a newer Dex, never stops
|
|
803
1077
|
// anyone else saving.
|
|
804
1078
|
const known = await knownFor(slug, root);
|
|
1079
|
+
|
|
805
1080
|
const problems = canvasProblems(mine, {
|
|
806
1081
|
...known,
|
|
807
1082
|
views: [...known.views, ...Object.keys(views)],
|
|
808
1083
|
});
|
|
1084
|
+
|
|
809
1085
|
if (problems.length > 0) {
|
|
810
1086
|
return { problems };
|
|
811
1087
|
}
|
|
1088
|
+
|
|
812
1089
|
const images = save.images ?? {};
|
|
1090
|
+
|
|
813
1091
|
// What the save takes off their canvas, so a removed view can say where it was.
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
|
|
1092
|
+
const current = await canvasParts(slug, root);
|
|
1093
|
+
const before = current.find((part) => part.person === person)?.canvas;
|
|
1094
|
+
|
|
817
1095
|
const removed = nextRemovals(
|
|
818
1096
|
before?.sections ?? [],
|
|
819
1097
|
mine.sections,
|
|
820
1098
|
removalsOf(before),
|
|
821
1099
|
{ by: person, now }
|
|
822
1100
|
);
|
|
1101
|
+
|
|
823
1102
|
const file = own.canvas;
|
|
824
1103
|
const biome = findBiome(root);
|
|
1104
|
+
|
|
825
1105
|
const text: string = await formatText(
|
|
826
1106
|
biome,
|
|
827
1107
|
file,
|
|
828
|
-
|
|
1108
|
+
jsonInLayout(
|
|
1109
|
+
// What a newer Dex wrote that this one doesn't know stays as it was.
|
|
1110
|
+
withUnknownFields(
|
|
1111
|
+
before,
|
|
1112
|
+
removed.length > 0 ? { ...mine, removed } : mine
|
|
1113
|
+
),
|
|
1114
|
+
await readFile(file, "utf8").catch(() => undefined)
|
|
1115
|
+
)
|
|
829
1116
|
);
|
|
1117
|
+
|
|
830
1118
|
// Parsed before anything is written, so a bad format never lands on disk.
|
|
831
1119
|
JSON.parse(text);
|
|
832
1120
|
// The views first, so the canvas never points at a view not yet there,
|
|
833
1121
|
// and each view's images and stylesheet before the view that imports them.
|
|
834
1122
|
const pictures = Object.entries(images);
|
|
1123
|
+
|
|
835
1124
|
if (pictures.length > 0) {
|
|
836
1125
|
await mkdir(paths.images, { recursive: true });
|
|
837
1126
|
}
|
|
838
|
-
|
|
839
|
-
|
|
1127
|
+
|
|
1128
|
+
for (const [name, bytes] of pictures) {
|
|
1129
|
+
await writeFile(paths.image(name), bytes);
|
|
840
1130
|
}
|
|
1131
|
+
|
|
841
1132
|
// A view saved again stays where it is; a new one goes in their views/.
|
|
842
1133
|
const viewFile = (name: string, extension = ".tsx") => {
|
|
843
1134
|
const found = existing.get(name)?.file;
|
|
1135
|
+
|
|
844
1136
|
return found
|
|
845
1137
|
? `${found.slice(0, -".tsx".length)}${extension}`
|
|
846
1138
|
: own.view(name, extension);
|
|
847
1139
|
};
|
|
1140
|
+
|
|
848
1141
|
const unformatted = [
|
|
849
1142
|
...Object.entries(stylesheets).map(([name, css]) => [
|
|
850
1143
|
viewFile(name, ".css"),
|
|
@@ -852,9 +1145,11 @@ async function saveCanvasNow(
|
|
|
852
1145
|
]),
|
|
853
1146
|
...Object.entries(views).map(([name, source]) => [viewFile(name), source]),
|
|
854
1147
|
];
|
|
1148
|
+
|
|
855
1149
|
if (unformatted.length > 0) {
|
|
856
1150
|
await mkdir(own.views, { recursive: true });
|
|
857
1151
|
}
|
|
1152
|
+
|
|
858
1153
|
// Written formatted: a rewrite of a view no page has loaded yet makes Vite
|
|
859
1154
|
// reload every page, the canvas and all its frames.
|
|
860
1155
|
const files = await Promise.all(
|
|
@@ -863,11 +1158,14 @@ async function saveCanvasNow(
|
|
|
863
1158
|
await formatText(biome, path, source),
|
|
864
1159
|
])
|
|
865
1160
|
);
|
|
1161
|
+
|
|
866
1162
|
for (const [path, contents] of files) {
|
|
867
1163
|
await writeFile(path, contents);
|
|
868
1164
|
}
|
|
1165
|
+
|
|
869
1166
|
await mkdir(own.folder, { recursive: true });
|
|
870
1167
|
await replaceFile(file, text);
|
|
1168
|
+
|
|
871
1169
|
return {
|
|
872
1170
|
...(await readCanvasRevision(slug, person, root)),
|
|
873
1171
|
renamed,
|
|
@@ -875,76 +1173,95 @@ async function saveCanvasNow(
|
|
|
875
1173
|
};
|
|
876
1174
|
}
|
|
877
1175
|
|
|
878
|
-
// ---
|
|
1176
|
+
// --- Picks --------------------------------------------------------------------
|
|
879
1177
|
|
|
880
|
-
/** Everyone's
|
|
881
|
-
export interface
|
|
882
|
-
|
|
1178
|
+
/** Everyone's picks on a prototype, each with its author. */
|
|
1179
|
+
export interface PrototypePicks {
|
|
1180
|
+
picks: Authored[];
|
|
883
1181
|
/** What is wrong with each file, by its path in the studio. */
|
|
884
1182
|
problems: string[];
|
|
885
1183
|
}
|
|
886
1184
|
|
|
887
|
-
export type
|
|
888
|
-
| {
|
|
889
|
-
| {
|
|
1185
|
+
export type SavedPicks =
|
|
1186
|
+
| { picks: Authored[]; problems?: undefined }
|
|
1187
|
+
| { picks?: undefined; problems: string[] };
|
|
1188
|
+
|
|
1189
|
+
const PICKS_LOCK_STALE_MS = 5000;
|
|
1190
|
+
const NOT_PICKS = 'must be { "picks": [...] }.';
|
|
890
1191
|
|
|
891
|
-
|
|
892
|
-
|
|
1192
|
+
// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- the file as read: fields Dex doesn't know are written back as they were
|
|
1193
|
+
type PicksJson = Record<string, unknown>;
|
|
893
1194
|
|
|
894
|
-
async function
|
|
1195
|
+
async function picksFile(
|
|
895
1196
|
file: string
|
|
896
|
-
): Promise<{ file?:
|
|
1197
|
+
): Promise<{ file?: PicksJson } | { problem: string }> {
|
|
897
1198
|
let text: string;
|
|
1199
|
+
|
|
898
1200
|
try {
|
|
899
1201
|
text = await readFile(file, "utf8");
|
|
900
1202
|
} catch (error) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1203
|
+
// SAFETY: readFile fails with a Node system error, an Error with a code.
|
|
1204
|
+
const { code, message } = error as NodeJS.ErrnoException;
|
|
1205
|
+
|
|
1206
|
+
return code === "ENOENT" ? {} : { problem: message };
|
|
904
1207
|
}
|
|
1208
|
+
|
|
905
1209
|
try {
|
|
906
1210
|
const parsed: unknown = JSON.parse(text);
|
|
907
|
-
|
|
1211
|
+
|
|
1212
|
+
return isRecord(parsed) && Array.isArray(parsed.picks)
|
|
908
1213
|
? { file: parsed }
|
|
909
|
-
: { problem:
|
|
1214
|
+
: { problem: NOT_PICKS };
|
|
910
1215
|
} catch (error) {
|
|
1216
|
+
// SAFETY: JSON.parse fails with a SyntaxError.
|
|
911
1217
|
return { problem: (error as Error).message };
|
|
912
1218
|
}
|
|
913
1219
|
}
|
|
914
1220
|
|
|
915
1221
|
/**
|
|
916
|
-
* Every person's
|
|
917
|
-
*
|
|
918
|
-
*
|
|
919
|
-
* older Dex wrote, are left in the file and not read.
|
|
1222
|
+
* Every person's picks on a prototype, by person, each with its author. A
|
|
1223
|
+
* file that cannot be read gives problems, never an error, so one person's
|
|
1224
|
+
* broken file hides only their picks.
|
|
920
1225
|
*/
|
|
921
|
-
export async function
|
|
1226
|
+
export async function readPrototypePicks(
|
|
922
1227
|
slug: string,
|
|
923
1228
|
root: string
|
|
924
|
-
): Promise<
|
|
1229
|
+
): Promise<PrototypePicks> {
|
|
925
1230
|
const paths = prototypePaths(root, slug);
|
|
926
|
-
const read:
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
1231
|
+
const read: PrototypePicks = { picks: [], problems: [] };
|
|
1232
|
+
|
|
1233
|
+
const people = await peopleOf(root, slug);
|
|
1234
|
+
|
|
1235
|
+
const files = people.flatMap((person) => {
|
|
1236
|
+
const file = paths.person(person)?.picks;
|
|
1237
|
+
|
|
1238
|
+
return file ? [{ file, person }] : [];
|
|
1239
|
+
});
|
|
1240
|
+
|
|
1241
|
+
const opened = await Promise.all(
|
|
1242
|
+
files.map(async (each) => ({
|
|
1243
|
+
...each,
|
|
1244
|
+
found: await picksFile(each.file),
|
|
1245
|
+
}))
|
|
1246
|
+
);
|
|
1247
|
+
|
|
1248
|
+
for (const { file, found, person } of opened) {
|
|
933
1249
|
if ("problem" in found) {
|
|
934
1250
|
read.problems.push(`${shownIn(root, file)}: ${found.problem}`);
|
|
935
1251
|
continue;
|
|
936
1252
|
}
|
|
1253
|
+
|
|
937
1254
|
if (!found.file) {
|
|
938
1255
|
continue;
|
|
939
1256
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
);
|
|
1257
|
+
|
|
1258
|
+
const { picks, problems } = readPicks(found.file);
|
|
1259
|
+
read.picks.push(...picks.map((pick) => ({ ...pick, author: person })));
|
|
944
1260
|
read.problems.push(
|
|
945
1261
|
...problems.map((problem) => `${shownIn(root, file)}: ${problem}`)
|
|
946
1262
|
);
|
|
947
1263
|
}
|
|
1264
|
+
|
|
948
1265
|
return read;
|
|
949
1266
|
}
|
|
950
1267
|
|
|
@@ -954,73 +1271,87 @@ interface PicksOf {
|
|
|
954
1271
|
slug: string;
|
|
955
1272
|
}
|
|
956
1273
|
|
|
957
|
-
async function
|
|
1274
|
+
async function changePicks(
|
|
958
1275
|
{ slug, person }: PicksOf,
|
|
959
1276
|
change: (
|
|
960
|
-
file:
|
|
961
|
-
) => {
|
|
1277
|
+
file: PicksJson | undefined
|
|
1278
|
+
) => { picks: unknown[] } | { problems: string[] },
|
|
962
1279
|
root: string
|
|
963
|
-
): Promise<
|
|
1280
|
+
): Promise<SavedPicks> {
|
|
964
1281
|
if (person === undefined) {
|
|
965
|
-
return
|
|
1282
|
+
return { problems: [NOT_RECOGNISED] };
|
|
966
1283
|
}
|
|
1284
|
+
|
|
967
1285
|
const own = prototypePaths(root, slug).person(person);
|
|
1286
|
+
|
|
968
1287
|
if (!own) {
|
|
969
|
-
return
|
|
1288
|
+
return {
|
|
970
1289
|
problems: [`"${person}" is not a contributor's slug.`],
|
|
971
|
-
}
|
|
1290
|
+
};
|
|
972
1291
|
}
|
|
1292
|
+
|
|
973
1293
|
const written = await inTurn(
|
|
974
1294
|
root,
|
|
975
|
-
`
|
|
976
|
-
|
|
1295
|
+
`picks-${slug}-${person}`,
|
|
1296
|
+
PICKS_LOCK_STALE_MS,
|
|
977
1297
|
async (): Promise<{ problems: string[] } | undefined> => {
|
|
978
|
-
const found = await
|
|
1298
|
+
const found = await picksFile(own.picks);
|
|
1299
|
+
|
|
979
1300
|
if ("problem" in found) {
|
|
980
1301
|
return {
|
|
981
1302
|
problems: [
|
|
982
|
-
`${shownIn(root, own.
|
|
1303
|
+
`${shownIn(root, own.picks)}: ${found.problem} Fix it or remove it to pick frames.`,
|
|
983
1304
|
],
|
|
984
1305
|
};
|
|
985
1306
|
}
|
|
1307
|
+
|
|
986
1308
|
const changed = change(found.file);
|
|
1309
|
+
|
|
987
1310
|
if ("problems" in changed) {
|
|
988
1311
|
return changed;
|
|
989
1312
|
}
|
|
990
|
-
|
|
991
|
-
|
|
1313
|
+
|
|
1314
|
+
const before = found.file?.picks ?? [];
|
|
1315
|
+
|
|
1316
|
+
if (JSON.stringify(changed.picks) !== JSON.stringify(before)) {
|
|
992
1317
|
await mkdir(own.folder, { recursive: true });
|
|
993
1318
|
await replaceFile(
|
|
994
|
-
own.
|
|
995
|
-
|
|
1319
|
+
own.picks,
|
|
1320
|
+
jsonInLayout(
|
|
1321
|
+
{ ...found.file, ...changed },
|
|
1322
|
+
await readFile(own.picks, "utf8").catch(() => undefined)
|
|
1323
|
+
)
|
|
996
1324
|
);
|
|
997
1325
|
}
|
|
998
1326
|
}
|
|
999
1327
|
);
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1328
|
+
|
|
1329
|
+
if (written) {
|
|
1330
|
+
return written;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
const { picks } = await readPrototypePicks(slug, root);
|
|
1334
|
+
|
|
1335
|
+
return { picks };
|
|
1005
1336
|
}
|
|
1006
1337
|
|
|
1007
1338
|
/**
|
|
1008
|
-
* Put one of the person's picks in their
|
|
1009
|
-
*
|
|
1339
|
+
* Put one of the person's picks in their picks.json, in place of the one
|
|
1340
|
+
* with its id or added, after checking it (pickProblems).
|
|
1010
1341
|
*/
|
|
1011
|
-
export const
|
|
1012
|
-
{
|
|
1342
|
+
export const savePick = (
|
|
1343
|
+
{ pick, ...whose }: PicksOf & { pick: unknown },
|
|
1013
1344
|
root: string
|
|
1014
|
-
): Promise<
|
|
1015
|
-
|
|
1345
|
+
): Promise<SavedPicks> =>
|
|
1346
|
+
changePicks(whose, (file) => withPick(file, pick), root);
|
|
1016
1347
|
|
|
1017
|
-
/** Take one of the person's picks out of their
|
|
1018
|
-
export const
|
|
1348
|
+
/** Take one of the person's picks out of their picks.json. */
|
|
1349
|
+
export const removePick = (
|
|
1019
1350
|
{ id, ...whose }: PicksOf & { id: unknown },
|
|
1020
1351
|
root: string
|
|
1021
|
-
): Promise<
|
|
1352
|
+
): Promise<SavedPicks> =>
|
|
1022
1353
|
isText(id)
|
|
1023
|
-
?
|
|
1354
|
+
? changePicks(whose, (file) => withoutPick(file, id), root)
|
|
1024
1355
|
: Promise.resolve({ problems: ["Say which pick to remove."] });
|
|
1025
1356
|
|
|
1026
1357
|
// --- Creating things ----------------------------------------------------------
|
|
@@ -1088,40 +1419,48 @@ export async function createPrototype(
|
|
|
1088
1419
|
root: string
|
|
1089
1420
|
): Promise<{ folder: string; href: string | undefined; slug: string }> {
|
|
1090
1421
|
const usage = 'Usage: npx dex new --title "<title>" [--person <slug>]';
|
|
1422
|
+
|
|
1091
1423
|
if (!isText(title)) {
|
|
1092
1424
|
throw new Error(`Name the file. ${usage}`);
|
|
1093
1425
|
}
|
|
1426
|
+
|
|
1094
1427
|
if (!isText(person)) {
|
|
1095
1428
|
throw new Error(usage);
|
|
1096
1429
|
}
|
|
1430
|
+
|
|
1097
1431
|
const { contributors } = await loadStudio(root);
|
|
1432
|
+
|
|
1098
1433
|
if (!contributors.some((contributor) => contributor.slug === person)) {
|
|
1099
1434
|
throw new Error(
|
|
1100
1435
|
`"${person}" is not a contributor. Run \`npx dex whoami\` or add them with \`npx dex contributor\`.`
|
|
1101
1436
|
);
|
|
1102
1437
|
}
|
|
1438
|
+
|
|
1103
1439
|
const prototypeSlug = slug === undefined ? freeFileId(root) : slugify(slug);
|
|
1104
1440
|
const paths = prototypePaths(root, prototypeSlug);
|
|
1441
|
+
|
|
1105
1442
|
if (existsSync(paths.folder)) {
|
|
1106
1443
|
throw new Error(`${prototypeFiles(prototypeSlug)?.folder} already exists.`);
|
|
1107
1444
|
}
|
|
1445
|
+
|
|
1108
1446
|
await mkdir(paths.docs, { recursive: true });
|
|
1109
1447
|
// Where the person's views go, there before the first one is.
|
|
1110
1448
|
const views = paths.person(person)?.views;
|
|
1449
|
+
|
|
1111
1450
|
if (views) {
|
|
1112
1451
|
await mkdir(views, { recursive: true });
|
|
1113
1452
|
}
|
|
1114
1453
|
|
|
1115
1454
|
await writeJson(paths.manifest, {
|
|
1116
1455
|
title: title.trim(),
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
: "What question does this file answer?",
|
|
1456
|
+
// Only a question someone gave: never a placeholder for one.
|
|
1457
|
+
...(isText(description) && { description: description.trim() }),
|
|
1120
1458
|
status: "exploring",
|
|
1121
1459
|
created: today ?? new Date().toISOString().slice(0, 10),
|
|
1122
1460
|
createdBy: person,
|
|
1123
1461
|
tags: [],
|
|
1124
1462
|
});
|
|
1463
|
+
|
|
1125
1464
|
const { problems } = await writeCanvas(
|
|
1126
1465
|
{
|
|
1127
1466
|
person,
|
|
@@ -1133,10 +1472,13 @@ export async function createPrototype(
|
|
|
1133
1472
|
},
|
|
1134
1473
|
root
|
|
1135
1474
|
);
|
|
1475
|
+
|
|
1136
1476
|
if (problems) {
|
|
1137
1477
|
throw new Error(problems.join(" "));
|
|
1138
1478
|
}
|
|
1479
|
+
|
|
1139
1480
|
await writeFile(join(paths.docs, ".gitkeep"), "");
|
|
1481
|
+
|
|
1140
1482
|
return {
|
|
1141
1483
|
folder: paths.folder,
|
|
1142
1484
|
slug: prototypeSlug,
|
|
@@ -1150,12 +1492,16 @@ const UNTITLED = "Untitled";
|
|
|
1150
1492
|
const freeFileId = (root: string): string => {
|
|
1151
1493
|
const taken = (candidate: string): boolean => {
|
|
1152
1494
|
const files = prototypeFiles(candidate);
|
|
1495
|
+
|
|
1153
1496
|
return files !== undefined && existsSync(join(root, files.folder));
|
|
1154
1497
|
};
|
|
1498
|
+
|
|
1155
1499
|
let id = newFileId();
|
|
1500
|
+
|
|
1156
1501
|
while (taken(id)) {
|
|
1157
1502
|
id = newFileId();
|
|
1158
1503
|
}
|
|
1504
|
+
|
|
1159
1505
|
return id;
|
|
1160
1506
|
};
|
|
1161
1507
|
|
|
@@ -1176,6 +1522,7 @@ const existingPaths = (root: string, slug: string): PrototypeFiles => {
|
|
|
1176
1522
|
if (!prototypeExists(root, slug)) {
|
|
1177
1523
|
throw new Error("That file does not exist.");
|
|
1178
1524
|
}
|
|
1525
|
+
|
|
1179
1526
|
return prototypePaths(root, slug);
|
|
1180
1527
|
};
|
|
1181
1528
|
|
|
@@ -1187,9 +1534,11 @@ export async function setPrototypeTitle(
|
|
|
1187
1534
|
root: string
|
|
1188
1535
|
): Promise<void> {
|
|
1189
1536
|
const name = String(title ?? "").trim();
|
|
1537
|
+
|
|
1190
1538
|
if (!name) {
|
|
1191
1539
|
throw new Error("Name the file.");
|
|
1192
1540
|
}
|
|
1541
|
+
|
|
1193
1542
|
const file = existingPaths(root, slug).manifest;
|
|
1194
1543
|
await writeJson(file, {
|
|
1195
1544
|
...(await readJson<object>(file)),
|
|
@@ -1205,6 +1554,7 @@ export async function setPrototypeStatus(
|
|
|
1205
1554
|
if (!isOneOf(STATUSES, status)) {
|
|
1206
1555
|
throw new Error(`The status must be one of ${STATUSES.join(", ")}.`);
|
|
1207
1556
|
}
|
|
1557
|
+
|
|
1208
1558
|
const file = existingPaths(root, slug).manifest;
|
|
1209
1559
|
await writeJson(file, { ...(await readJson<object>(file)), status });
|
|
1210
1560
|
}
|
|
@@ -1219,17 +1569,23 @@ export async function setPrototypeCover(
|
|
|
1219
1569
|
root: string
|
|
1220
1570
|
): Promise<void> {
|
|
1221
1571
|
const file = existingPaths(root, slug).manifest;
|
|
1572
|
+
|
|
1222
1573
|
const { cover: _old, ...manifest } = await readJson<{ cover?: unknown }>(
|
|
1223
1574
|
file
|
|
1224
1575
|
);
|
|
1576
|
+
|
|
1225
1577
|
if (cover === null) {
|
|
1226
1578
|
await writeJson(file, manifest);
|
|
1579
|
+
|
|
1227
1580
|
return;
|
|
1228
1581
|
}
|
|
1582
|
+
|
|
1229
1583
|
const checked = checkFrameAnchor(cover, "cover");
|
|
1584
|
+
|
|
1230
1585
|
if ("problems" in checked) {
|
|
1231
1586
|
throw new Error(checked.problems.join(" "));
|
|
1232
1587
|
}
|
|
1588
|
+
|
|
1233
1589
|
await writeJson(file, { ...manifest, cover: checked.frame });
|
|
1234
1590
|
}
|
|
1235
1591
|
|
|
@@ -1250,18 +1606,27 @@ export async function duplicatePrototype(
|
|
|
1250
1606
|
recursive: true,
|
|
1251
1607
|
filter: (path) => splitPrototypeFile(root, path)?.part !== "comments",
|
|
1252
1608
|
});
|
|
1253
|
-
// A copy was never anything else: no name from before files
|
|
1609
|
+
// A copy was never anything else: no name from before files/, and its
|
|
1610
|
+
// manifest is file.json, whatever the original's is called.
|
|
1611
|
+
const copied = prototypePaths(root, copy).manifest;
|
|
1612
|
+
|
|
1254
1613
|
const { was: _was, ...manifest } = await readJson<{
|
|
1255
1614
|
title?: unknown;
|
|
1256
1615
|
was?: unknown;
|
|
1257
|
-
}>(
|
|
1616
|
+
}>(copied);
|
|
1617
|
+
|
|
1618
|
+
if (copied !== to.manifest) {
|
|
1619
|
+
await rm(copied);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1258
1622
|
await writeJson(to.manifest, {
|
|
1259
1623
|
...manifest,
|
|
1260
1624
|
title: `${manifest.title} (copy)`,
|
|
1261
1625
|
status: "exploring",
|
|
1262
1626
|
created: today ?? new Date().toISOString().slice(0, 10),
|
|
1263
|
-
...(person
|
|
1627
|
+
...(person && { createdBy: person }),
|
|
1264
1628
|
});
|
|
1629
|
+
|
|
1265
1630
|
return { href: prototypePage(copy) };
|
|
1266
1631
|
}
|
|
1267
1632
|
|
|
@@ -1293,24 +1658,31 @@ export async function addContributor(
|
|
|
1293
1658
|
`Usage: npx dex contributor --name "<name>" --git "<git user>" --discipline <${DISCIPLINES.join("|")}>`
|
|
1294
1659
|
);
|
|
1295
1660
|
}
|
|
1661
|
+
|
|
1296
1662
|
const login = isText(github) ? github.trim().replace(LEADING_AT_RE, "") : "";
|
|
1663
|
+
|
|
1297
1664
|
if (github !== undefined && !GITHUB_LOGIN_RE.test(login)) {
|
|
1298
1665
|
throw new Error(`"${github}" is not a GitHub username.`);
|
|
1299
1666
|
}
|
|
1667
|
+
|
|
1300
1668
|
const slug = slugify(name);
|
|
1669
|
+
|
|
1301
1670
|
const added: Contributor = {
|
|
1302
1671
|
slug,
|
|
1303
1672
|
name: name.trim(),
|
|
1304
1673
|
git: [git.trim()],
|
|
1305
1674
|
discipline,
|
|
1306
|
-
...(login
|
|
1675
|
+
...(login && { github: login }),
|
|
1307
1676
|
};
|
|
1677
|
+
|
|
1308
1678
|
await changeContributors(root, (contributors) => {
|
|
1309
1679
|
if (contributors.some((contributor) => contributor.slug === slug)) {
|
|
1310
1680
|
throw new Error(`"${slug}" is already a contributor.`);
|
|
1311
1681
|
}
|
|
1682
|
+
|
|
1312
1683
|
return { result: undefined, write: [...contributors, added] };
|
|
1313
1684
|
});
|
|
1685
|
+
|
|
1314
1686
|
return slug;
|
|
1315
1687
|
}
|
|
1316
1688
|
|
|
@@ -1329,9 +1701,14 @@ const changeContributors = <T>(
|
|
|
1329
1701
|
inTurn(root, "contributors", CONTRIBUTORS_LOCK_STALE_MS, async () => {
|
|
1330
1702
|
const path = join(root, "contributors.json");
|
|
1331
1703
|
const { result, write } = change(await readContributors(path));
|
|
1704
|
+
|
|
1332
1705
|
if (write) {
|
|
1333
|
-
await replaceFile(
|
|
1706
|
+
await replaceFile(
|
|
1707
|
+
path,
|
|
1708
|
+
jsonInLayout(write, await readFile(path, "utf8").catch(() => undefined))
|
|
1709
|
+
);
|
|
1334
1710
|
}
|
|
1711
|
+
|
|
1335
1712
|
return result;
|
|
1336
1713
|
});
|
|
1337
1714
|
|
|
@@ -1361,7 +1738,7 @@ export const currentPerson = async (
|
|
|
1361
1738
|
try {
|
|
1362
1739
|
return youOf(await identify(root))?.slug;
|
|
1363
1740
|
} catch {
|
|
1364
|
-
|
|
1741
|
+
// Dex can't tell who you are: undefined.
|
|
1365
1742
|
}
|
|
1366
1743
|
};
|
|
1367
1744
|
|
|
@@ -1374,19 +1751,23 @@ export const currentPerson = async (
|
|
|
1374
1751
|
export async function joinCurrentPerson(
|
|
1375
1752
|
root: string
|
|
1376
1753
|
): Promise<Contributor | undefined> {
|
|
1377
|
-
const [
|
|
1754
|
+
const [gitUser, github] = await Promise.all([
|
|
1378
1755
|
yourGitUser(root),
|
|
1379
1756
|
githubAccountLogin(),
|
|
1380
1757
|
]);
|
|
1758
|
+
|
|
1381
1759
|
const { contributors } = await loadStudio(root);
|
|
1382
|
-
const known = identityFrom(contributors,
|
|
1760
|
+
const known = identityFrom(contributors, gitUser, github);
|
|
1761
|
+
|
|
1383
1762
|
if (!known.newcomer) {
|
|
1384
1763
|
return known.contributor;
|
|
1385
1764
|
}
|
|
1765
|
+
|
|
1386
1766
|
// Decided again from the file as it is now: another save, or another
|
|
1387
1767
|
// process, may have added you, or taken the slug you would have.
|
|
1388
1768
|
const joined = await changeContributors(root, (current) => {
|
|
1389
|
-
const { contributor, newcomer } = identityFrom(current,
|
|
1769
|
+
const { contributor, newcomer } = identityFrom(current, gitUser, github);
|
|
1770
|
+
|
|
1390
1771
|
return newcomer
|
|
1391
1772
|
? {
|
|
1392
1773
|
result: { you: newcomer, added: true },
|
|
@@ -1394,10 +1775,12 @@ export async function joinCurrentPerson(
|
|
|
1394
1775
|
}
|
|
1395
1776
|
: { result: { you: contributor, added: false } };
|
|
1396
1777
|
});
|
|
1778
|
+
|
|
1397
1779
|
if (joined.added && joined.you) {
|
|
1398
1780
|
// Afterwards: a slow or missing GitHub CLI never holds up joining.
|
|
1399
1781
|
linkGithub(root).catch(() => undefined);
|
|
1400
1782
|
}
|
|
1783
|
+
|
|
1401
1784
|
return joined.you;
|
|
1402
1785
|
}
|
|
1403
1786
|
|
|
@@ -1413,6 +1796,7 @@ const gitFolders = new Map<string, string[]>();
|
|
|
1413
1796
|
*/
|
|
1414
1797
|
const gitConfigFiles = (root: string): string[] => {
|
|
1415
1798
|
let folders = gitFolders.get(root);
|
|
1799
|
+
|
|
1416
1800
|
if (!folders) {
|
|
1417
1801
|
const found = git(["rev-parse", "--git-dir", "--git-common-dir"], root);
|
|
1418
1802
|
folders = [
|
|
@@ -1423,12 +1807,15 @@ const gitConfigFiles = (root: string): string[] => {
|
|
|
1423
1807
|
.map((folder) => resolve(root, folder))
|
|
1424
1808
|
),
|
|
1425
1809
|
];
|
|
1810
|
+
|
|
1426
1811
|
if (folders.length > 0) {
|
|
1427
1812
|
gitFolders.set(root, folders);
|
|
1428
1813
|
}
|
|
1429
1814
|
}
|
|
1815
|
+
|
|
1430
1816
|
const home = homedir();
|
|
1431
1817
|
const global = process.env.GIT_CONFIG_GLOBAL;
|
|
1818
|
+
|
|
1432
1819
|
return [
|
|
1433
1820
|
...(global ? [resolve(root, global)] : []),
|
|
1434
1821
|
join(home, ".gitconfig"),
|
|
@@ -1441,22 +1828,27 @@ const gitConfigFiles = (root: string): string[] => {
|
|
|
1441
1828
|
};
|
|
1442
1829
|
|
|
1443
1830
|
/** When and how big each file is, as one string: "" for a file not there. */
|
|
1444
|
-
const stamp = async (files: string[]): Promise<string> =>
|
|
1445
|
-
(
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
() => ""
|
|
1451
|
-
)
|
|
1452
|
-
)
|
|
1831
|
+
const stamp = async (files: string[]): Promise<string> => {
|
|
1832
|
+
const stamps = await Promise.all(
|
|
1833
|
+
files.map((file) =>
|
|
1834
|
+
stat(file)
|
|
1835
|
+
.then(({ mtimeMs, size }) => `${mtimeMs}:${size}`)
|
|
1836
|
+
.catch(() => "")
|
|
1453
1837
|
)
|
|
1454
|
-
)
|
|
1838
|
+
);
|
|
1839
|
+
|
|
1840
|
+
return stamps.join("|");
|
|
1841
|
+
};
|
|
1455
1842
|
|
|
1456
1843
|
const FILE_ORIGIN = "file:";
|
|
1457
1844
|
|
|
1458
1845
|
/** Your git user as git has it: the name as you typed it, and the email. */
|
|
1459
1846
|
export interface GitUser {
|
|
1847
|
+
/**
|
|
1848
|
+
* Hosted, the person's account says who they are: their email is checked,
|
|
1849
|
+
* their name is only what they chose, so it never makes them someone.
|
|
1850
|
+
*/
|
|
1851
|
+
accountEmail?: true;
|
|
1460
1852
|
email: string;
|
|
1461
1853
|
name: string;
|
|
1462
1854
|
}
|
|
@@ -1471,20 +1863,26 @@ const readGitUser = (root: string): GitUser & { files: string[] } => {
|
|
|
1471
1863
|
const fields = git(["config", "--list", "--show-origin", "-z"], root).split(
|
|
1472
1864
|
"\0"
|
|
1473
1865
|
);
|
|
1866
|
+
|
|
1474
1867
|
const files = new Set<string>();
|
|
1475
1868
|
const found: Record<string, string> = {};
|
|
1869
|
+
|
|
1476
1870
|
for (let at = 0; at + 1 < fields.length; at += 2) {
|
|
1477
1871
|
const origin = fields[at] ?? "";
|
|
1478
1872
|
const entry = fields[at + 1] ?? "";
|
|
1873
|
+
|
|
1479
1874
|
if (origin.startsWith(FILE_ORIGIN)) {
|
|
1480
1875
|
files.add(resolve(root, origin.slice(FILE_ORIGIN.length)));
|
|
1481
1876
|
}
|
|
1877
|
+
|
|
1482
1878
|
const split = entry.indexOf("\n");
|
|
1483
1879
|
const key = split === -1 ? entry : entry.slice(0, split);
|
|
1880
|
+
|
|
1484
1881
|
if (key === "user.name" || key === "user.email") {
|
|
1485
1882
|
found[key] = split === -1 ? "" : entry.slice(split + 1);
|
|
1486
1883
|
}
|
|
1487
1884
|
}
|
|
1885
|
+
|
|
1488
1886
|
return {
|
|
1489
1887
|
name: found["user.name"]?.trim() ?? "",
|
|
1490
1888
|
email: found["user.email"]?.trim() ?? "",
|
|
@@ -1504,18 +1902,29 @@ const gitUsers = new Map<
|
|
|
1504
1902
|
* it would read appears or changes.
|
|
1505
1903
|
*/
|
|
1506
1904
|
async function yourGitUser(root: string): Promise<GitUser> {
|
|
1905
|
+
// Hosted, "you" is whoever this request is from, never the machine's git.
|
|
1906
|
+
const person = hostedPerson();
|
|
1907
|
+
|
|
1908
|
+
if (person) {
|
|
1909
|
+
return { name: person.name, email: person.email, accountEmail: true };
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1507
1912
|
const base = gitConfigFiles(root);
|
|
1508
1913
|
const global = process.env.GIT_CONFIG_GLOBAL ?? "";
|
|
1509
1914
|
const kept = gitUsers.get(root);
|
|
1915
|
+
|
|
1510
1916
|
if (kept) {
|
|
1511
1917
|
const now = `${global}>${await stamp([...base, ...kept.files])}`;
|
|
1918
|
+
|
|
1512
1919
|
if (kept.stamp === now) {
|
|
1513
1920
|
return kept;
|
|
1514
1921
|
}
|
|
1515
1922
|
}
|
|
1923
|
+
|
|
1516
1924
|
const read = readGitUser(root);
|
|
1517
1925
|
const at = `${global}>${await stamp([...base, ...read.files])}`;
|
|
1518
1926
|
gitUsers.set(root, { ...read, stamp: at });
|
|
1927
|
+
|
|
1519
1928
|
return read;
|
|
1520
1929
|
}
|
|
1521
1930
|
|
|
@@ -1529,6 +1938,7 @@ const githubHostsFile = (): string => {
|
|
|
1529
1938
|
(process.platform === "win32" && process.env.AppData
|
|
1530
1939
|
? join(process.env.AppData, "GitHub CLI")
|
|
1531
1940
|
: join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "gh"));
|
|
1941
|
+
|
|
1532
1942
|
return join(folder, "hosts.yml");
|
|
1533
1943
|
};
|
|
1534
1944
|
|
|
@@ -1548,23 +1958,27 @@ const SIGNED_OUT_EXIT = 1;
|
|
|
1548
1958
|
* signed out or no CLI; throws when the CLI could not answer (it timed out,
|
|
1549
1959
|
* or was stopped), so that is never taken for signed out.
|
|
1550
1960
|
*/
|
|
1551
|
-
const askGithubCli = (host: string): Promise<string | undefined> =>
|
|
1552
|
-
|
|
1553
|
-
|
|
1961
|
+
const askGithubCli = async (host: string): Promise<string | undefined> => {
|
|
1962
|
+
try {
|
|
1963
|
+
const { stdout } = await execFileAsync(
|
|
1554
1964
|
"gh",
|
|
1555
1965
|
["config", "get", "user", "--host", host],
|
|
1556
|
-
{ timeout: GH_TIMEOUT_MS }
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1966
|
+
{ timeout: GH_TIMEOUT_MS }
|
|
1967
|
+
);
|
|
1968
|
+
|
|
1969
|
+
return stdout.trim() || undefined;
|
|
1970
|
+
} catch (error) {
|
|
1971
|
+
// SAFETY: execFile fails with an ExecFileException: its code is the exit
|
|
1972
|
+
// code, or the system error's when gh could not start.
|
|
1973
|
+
const { code } = error as ExecFileException;
|
|
1974
|
+
|
|
1975
|
+
if (code === SIGNED_OUT_EXIT || code === "ENOENT") {
|
|
1976
|
+
return undefined;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
throw error;
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1568
1982
|
|
|
1569
1983
|
/**
|
|
1570
1984
|
* The account the GitHub CLI is signed in to, or undefined when there is no
|
|
@@ -1574,23 +1988,32 @@ const askGithubCli = (host: string): Promise<string | undefined> =>
|
|
|
1574
1988
|
* not answer is asked again next time.
|
|
1575
1989
|
*/
|
|
1576
1990
|
export async function githubAccountLogin(): Promise<string | undefined> {
|
|
1991
|
+
// The machine's GitHub account is nobody's in particular when hosted.
|
|
1992
|
+
if (isHosted()) {
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1577
1996
|
const host = githubHost();
|
|
1578
1997
|
const file = githubHostsFile();
|
|
1998
|
+
|
|
1579
1999
|
const changed =
|
|
1580
2000
|
(await stamp([file])) ||
|
|
1581
2001
|
String(Math.floor(Date.now() / GITHUB_LOGIN_KEPT_MS));
|
|
2002
|
+
|
|
1582
2003
|
const key = `${host}>${file}>${changed}`;
|
|
2004
|
+
|
|
1583
2005
|
if (githubAccount?.key !== key) {
|
|
1584
2006
|
githubAccount = { key, login: askGithubCli(host) };
|
|
1585
2007
|
}
|
|
2008
|
+
|
|
1586
2009
|
const asked = githubAccount;
|
|
2010
|
+
|
|
1587
2011
|
try {
|
|
1588
2012
|
return await asked.login;
|
|
1589
2013
|
} catch {
|
|
1590
2014
|
if (githubAccount === asked) {
|
|
1591
2015
|
githubAccount = undefined;
|
|
1592
2016
|
}
|
|
1593
|
-
return;
|
|
1594
2017
|
}
|
|
1595
2018
|
}
|
|
1596
2019
|
|
|
@@ -1617,12 +2040,13 @@ export interface Identity {
|
|
|
1617
2040
|
|
|
1618
2041
|
/** Who you are in this workspace (identityFrom). */
|
|
1619
2042
|
export async function identify(root: string): Promise<Identity> {
|
|
1620
|
-
const [{ contributors },
|
|
2043
|
+
const [{ contributors }, gitUser, github] = await Promise.all([
|
|
1621
2044
|
loadStudio(root),
|
|
1622
2045
|
yourGitUser(root),
|
|
1623
2046
|
githubAccountLogin(),
|
|
1624
2047
|
]);
|
|
1625
|
-
|
|
2048
|
+
|
|
2049
|
+
return identityFrom(contributors, gitUser, github);
|
|
1626
2050
|
}
|
|
1627
2051
|
|
|
1628
2052
|
/** The contributor who has `value` among their git names and emails. */
|
|
@@ -1631,6 +2055,7 @@ const gitNamed = (
|
|
|
1631
2055
|
value: string
|
|
1632
2056
|
): Contributor | undefined => {
|
|
1633
2057
|
const said = value.trim().toLowerCase();
|
|
2058
|
+
|
|
1634
2059
|
return said
|
|
1635
2060
|
? contributors.find((contributor) =>
|
|
1636
2061
|
contributor.git.some((name) => name.trim().toLowerCase() === said)
|
|
@@ -1650,48 +2075,61 @@ const gitNamed = (
|
|
|
1650
2075
|
*/
|
|
1651
2076
|
export function identityFrom(
|
|
1652
2077
|
contributors: Contributor[],
|
|
1653
|
-
|
|
2078
|
+
gitUser: GitUser,
|
|
1654
2079
|
github: string | undefined
|
|
1655
2080
|
): Identity {
|
|
1656
2081
|
const account = github?.toLowerCase();
|
|
2082
|
+
|
|
1657
2083
|
const byGithub = account
|
|
1658
2084
|
? contributors.find(
|
|
1659
2085
|
(contributor) => contributor.github?.toLowerCase() === account
|
|
1660
2086
|
)
|
|
1661
2087
|
: undefined;
|
|
1662
|
-
|
|
1663
|
-
const
|
|
2088
|
+
|
|
2089
|
+
const byEmail = gitNamed(contributors, gitUser.email);
|
|
2090
|
+
|
|
2091
|
+
const byName = gitUser.accountEmail
|
|
2092
|
+
? undefined
|
|
2093
|
+
: gitNamed(contributors, gitUser.name);
|
|
2094
|
+
|
|
1664
2095
|
if (byGithub) {
|
|
1665
2096
|
const byGit = byEmail ?? byName;
|
|
2097
|
+
|
|
1666
2098
|
// Your git user is theirs when it names them too: two can share a
|
|
1667
2099
|
// name, never an email.
|
|
1668
2100
|
const theirs = byEmail
|
|
1669
2101
|
? byEmail.slug === byGithub.slug
|
|
1670
|
-
: gitNamed([byGithub],
|
|
2102
|
+
: gitNamed([byGithub], gitUser.name) !== undefined;
|
|
2103
|
+
|
|
1671
2104
|
return {
|
|
1672
2105
|
contributor: byGithub,
|
|
1673
2106
|
github,
|
|
1674
2107
|
via: "github",
|
|
1675
|
-
...(byGit && !theirs
|
|
2108
|
+
...(byGit && !theirs && { gitSays: byGit }),
|
|
1676
2109
|
};
|
|
1677
2110
|
}
|
|
2111
|
+
|
|
1678
2112
|
if (byEmail) {
|
|
1679
2113
|
return { contributor: byEmail, github, via: "git" };
|
|
1680
2114
|
}
|
|
2115
|
+
|
|
1681
2116
|
const nameIsAnothers =
|
|
1682
2117
|
account !== undefined &&
|
|
1683
2118
|
byName?.github !== undefined &&
|
|
1684
2119
|
byName.github.toLowerCase() !== account;
|
|
2120
|
+
|
|
1685
2121
|
if (byName && !nameIsAnothers) {
|
|
1686
2122
|
return { contributor: byName, github, via: "git" };
|
|
1687
2123
|
}
|
|
1688
|
-
|
|
2124
|
+
|
|
2125
|
+
const newcomer = newcomerFrom(contributors, gitUser, github);
|
|
2126
|
+
|
|
1689
2127
|
return {
|
|
1690
2128
|
contributor: undefined,
|
|
1691
2129
|
github,
|
|
1692
2130
|
via: undefined,
|
|
1693
|
-
...(byName
|
|
1694
|
-
...(newcomer
|
|
2131
|
+
...(byName && { gitSays: byName }),
|
|
2132
|
+
...(newcomer && { newcomer }),
|
|
1695
2133
|
};
|
|
1696
2134
|
}
|
|
1697
2135
|
|
|
@@ -1706,7 +2144,7 @@ const UNNAMED_SLUG = "someone";
|
|
|
1706
2144
|
* app's `name[bot]` and its noreply email, GitHub's own Actions and
|
|
1707
2145
|
* Dependabot, and the address GitHub commits from on the web.
|
|
1708
2146
|
*/
|
|
1709
|
-
const BOT_RE = /\[bot\]|^(?:github-actions|dependabot|noreply@github\.com)$/
|
|
2147
|
+
const BOT_RE = /\[bot\]|^(?:github-actions|dependabot|noreply@github\.com)$/iu;
|
|
1710
2148
|
|
|
1711
2149
|
/**
|
|
1712
2150
|
* The contributor someone with this git user and GitHub account would be:
|
|
@@ -1718,34 +2156,46 @@ const BOT_RE = /\[bot\]|^(?:github-actions|dependabot|noreply@github\.com)$/i;
|
|
|
1718
2156
|
*/
|
|
1719
2157
|
function newcomerFrom(
|
|
1720
2158
|
contributors: Contributor[],
|
|
1721
|
-
|
|
2159
|
+
gitUser: GitUser,
|
|
1722
2160
|
github: string | undefined
|
|
1723
2161
|
): Contributor | undefined {
|
|
1724
2162
|
const login = github && GITHUB_LOGIN_RE.test(github) ? github : undefined;
|
|
1725
|
-
|
|
2163
|
+
|
|
2164
|
+
if (
|
|
2165
|
+
[gitUser.name, gitUser.email, login].some(
|
|
2166
|
+
(said) => said && BOT_RE.test(said)
|
|
2167
|
+
)
|
|
2168
|
+
) {
|
|
1726
2169
|
return;
|
|
1727
2170
|
}
|
|
1728
|
-
|
|
2171
|
+
|
|
2172
|
+
const name = gitUser.name || login;
|
|
2173
|
+
|
|
1729
2174
|
if (!name) {
|
|
1730
2175
|
return;
|
|
1731
2176
|
}
|
|
2177
|
+
|
|
1732
2178
|
const base = slugify(name) || slugify(login ?? "") || UNNAMED_SLUG;
|
|
1733
2179
|
const taken = new Set(contributors.map((contributor) => contributor.slug));
|
|
1734
2180
|
let slug = base;
|
|
2181
|
+
|
|
1735
2182
|
for (let count = 2; taken.has(slug); count += 1) {
|
|
1736
2183
|
slug = `${base}-${count}`;
|
|
1737
2184
|
}
|
|
2185
|
+
|
|
1738
2186
|
return {
|
|
1739
2187
|
slug,
|
|
1740
2188
|
name,
|
|
1741
2189
|
git: [name],
|
|
1742
2190
|
discipline: NEWCOMER_DISCIPLINE,
|
|
1743
|
-
...(login
|
|
2191
|
+
...(login && { github: login }),
|
|
1744
2192
|
};
|
|
1745
2193
|
}
|
|
1746
2194
|
|
|
1747
2195
|
export async function whoami(root: string): Promise<Contributor | undefined> {
|
|
1748
|
-
|
|
2196
|
+
const { contributor } = await identify(root);
|
|
2197
|
+
|
|
2198
|
+
return contributor;
|
|
1749
2199
|
}
|
|
1750
2200
|
|
|
1751
2201
|
/**
|
|
@@ -1755,24 +2205,27 @@ export async function whoami(root: string): Promise<Contributor | undefined> {
|
|
|
1755
2205
|
*/
|
|
1756
2206
|
export async function githubLogin(root: string): Promise<string | undefined> {
|
|
1757
2207
|
const account = await githubAccountLogin();
|
|
2208
|
+
|
|
1758
2209
|
if (account && GITHUB_LOGIN_RE.test(account)) {
|
|
1759
2210
|
return account;
|
|
1760
2211
|
}
|
|
2212
|
+
|
|
1761
2213
|
const email = git(["config", "user.email"], root);
|
|
1762
2214
|
const noreply = GITHUB_NOREPLY_RE.exec(email)?.[1];
|
|
2215
|
+
|
|
1763
2216
|
if (noreply && GITHUB_LOGIN_RE.test(noreply)) {
|
|
1764
2217
|
return noreply;
|
|
1765
2218
|
}
|
|
2219
|
+
|
|
1766
2220
|
// Signed in with a token alone (GH_TOKEN, as in a codespace), the CLI's
|
|
1767
2221
|
// config names no one: GitHub itself is asked whose the token is.
|
|
1768
|
-
const login = await
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
);
|
|
2222
|
+
const login = await execFileAsync("gh", ["api", "user", "--jq", ".login"], {
|
|
2223
|
+
cwd: root,
|
|
2224
|
+
timeout: GH_TIMEOUT_MS,
|
|
2225
|
+
})
|
|
2226
|
+
.then(({ stdout }) => stdout.trim())
|
|
2227
|
+
.catch(() => "");
|
|
2228
|
+
|
|
1776
2229
|
return GITHUB_LOGIN_RE.test(login) ? login : undefined;
|
|
1777
2230
|
}
|
|
1778
2231
|
|
|
@@ -1782,15 +2235,20 @@ export async function githubLogin(root: string): Promise<string | undefined> {
|
|
|
1782
2235
|
*/
|
|
1783
2236
|
export async function linkGithub(root: string): Promise<string | undefined> {
|
|
1784
2237
|
const contributor = await whoami(root);
|
|
2238
|
+
|
|
1785
2239
|
if (!contributor || contributor.github) {
|
|
1786
2240
|
return;
|
|
1787
2241
|
}
|
|
2242
|
+
|
|
1788
2243
|
const login = await githubLogin(root);
|
|
2244
|
+
|
|
1789
2245
|
if (!login) {
|
|
1790
2246
|
return;
|
|
1791
2247
|
}
|
|
2248
|
+
|
|
1792
2249
|
return changeContributors(root, (contributors) => {
|
|
1793
2250
|
const entry = contributors.find(({ slug }) => slug === contributor.slug);
|
|
2251
|
+
|
|
1794
2252
|
return entry && !entry.github
|
|
1795
2253
|
? {
|
|
1796
2254
|
result: login,
|
|
@@ -1810,14 +2268,18 @@ export async function linkGithub(root: string): Promise<string | undefined> {
|
|
|
1810
2268
|
*/
|
|
1811
2269
|
export const changedFiles = (base: string, root: string): string[] => {
|
|
1812
2270
|
const mergeBase = git(["merge-base", "HEAD", base], root);
|
|
2271
|
+
|
|
1813
2272
|
const committed = mergeBase
|
|
1814
2273
|
? git(["diff", "--name-only", mergeBase, "HEAD"], root).split("\n")
|
|
1815
2274
|
: [];
|
|
2275
|
+
|
|
1816
2276
|
const working = git(["diff", "--name-only", "HEAD"], root).split("\n");
|
|
2277
|
+
|
|
1817
2278
|
const untracked = git(
|
|
1818
2279
|
["ls-files", "--others", "--exclude-standard", "--full-name"],
|
|
1819
2280
|
root
|
|
1820
2281
|
).split("\n");
|
|
2282
|
+
|
|
1821
2283
|
return [...new Set([...committed, ...working, ...untracked])].filter(Boolean);
|
|
1822
2284
|
};
|
|
1823
2285
|
|
|
@@ -1831,10 +2293,12 @@ export function allowedPrefixes(person: string, root: string): string[] {
|
|
|
1831
2293
|
if (!isSlug(person)) {
|
|
1832
2294
|
return [];
|
|
1833
2295
|
}
|
|
2296
|
+
|
|
1834
2297
|
// Git reports paths from the repository root; the studio may sit anywhere in it.
|
|
1835
2298
|
const repository = git(["rev-parse", "--show-toplevel"], root) || root;
|
|
1836
2299
|
const folder = relative(repository, root);
|
|
1837
2300
|
const studio = folder ? `${folder}/` : "";
|
|
2301
|
+
|
|
1838
2302
|
return [
|
|
1839
2303
|
`${studio}${PROTOTYPES_FOLDER}/*/`,
|
|
1840
2304
|
`${studio}${PROTOTYPES_FOLDER}/*/people/${person}/`,
|
|
@@ -1842,9 +2306,9 @@ export function allowedPrefixes(person: string, root: string): string[] {
|
|
|
1842
2306
|
];
|
|
1843
2307
|
}
|
|
1844
2308
|
|
|
1845
|
-
const PEOPLE_FOLDER_RE = /\/people\/[^/]
|
|
1846
|
-
const STAR_RE = /\*/
|
|
1847
|
-
const SPECIAL_RE = /[.+?^${}()|[\]\\]/
|
|
2309
|
+
const PEOPLE_FOLDER_RE = /\/people\/[^/]+\//u;
|
|
2310
|
+
const STAR_RE = /\*/gu;
|
|
2311
|
+
const SPECIAL_RE = /[.+?^${}()|[\]\\]/gu;
|
|
1848
2312
|
|
|
1849
2313
|
/**
|
|
1850
2314
|
* Whether a file is under a prefix. Someone's people/ folder is theirs even
|
|
@@ -1852,12 +2316,16 @@ const SPECIAL_RE = /[.+?^${}()|[\]\\]/g;
|
|
|
1852
2316
|
*/
|
|
1853
2317
|
const underPrefix = (file: string, prefix: string): boolean => {
|
|
1854
2318
|
const pattern = new RegExp(
|
|
1855
|
-
`^${prefix.
|
|
2319
|
+
`^${prefix.replaceAll(SPECIAL_RE, "\\$&").replaceAll(STAR_RE, "[^/]+")}`,
|
|
2320
|
+
"u"
|
|
1856
2321
|
);
|
|
2322
|
+
|
|
1857
2323
|
const match = pattern.exec(file);
|
|
2324
|
+
|
|
1858
2325
|
if (!match) {
|
|
1859
2326
|
return false;
|
|
1860
2327
|
}
|
|
2328
|
+
|
|
1861
2329
|
return (
|
|
1862
2330
|
PEOPLE_FOLDER_RE.test(prefix) ||
|
|
1863
2331
|
!PEOPLE_FOLDER_RE.test(file.slice(match[0].length - 1))
|
|
@@ -1890,6 +2358,7 @@ export function framePageOf(
|
|
|
1890
2358
|
): string | undefined {
|
|
1891
2359
|
const query = new URLSearchParams(frame.params ?? {});
|
|
1892
2360
|
const search = query.size > 0 ? `?${query}` : "";
|
|
2361
|
+
|
|
1893
2362
|
return framePage(slug, frame.view, search);
|
|
1894
2363
|
}
|
|
1895
2364
|
|
|
@@ -1917,9 +2386,11 @@ async function snapshotOf(
|
|
|
1917
2386
|
slug: string
|
|
1918
2387
|
): Promise<ViewShot | { problem: string }> {
|
|
1919
2388
|
const href = framePageOf(slug, frame);
|
|
2389
|
+
|
|
1920
2390
|
if (!href) {
|
|
1921
2391
|
return { problem: `no snapshot: "${frame.view}" is not a view's name` };
|
|
1922
2392
|
}
|
|
2393
|
+
|
|
1923
2394
|
try {
|
|
1924
2395
|
return await snapshotView(url, {
|
|
1925
2396
|
href,
|
|
@@ -1930,6 +2401,7 @@ async function snapshotOf(
|
|
|
1930
2401
|
if (error instanceof SnapshotError && error.status !== undefined) {
|
|
1931
2402
|
return { problem: `no snapshot (${error.status}): ${error.message}` };
|
|
1932
2403
|
}
|
|
2404
|
+
|
|
1933
2405
|
throw error;
|
|
1934
2406
|
}
|
|
1935
2407
|
}
|
|
@@ -1960,41 +2432,52 @@ export async function snapshot(
|
|
|
1960
2432
|
"Usage: npx dex snapshot --slug <file> [--view <view>] [--url <address>]"
|
|
1961
2433
|
);
|
|
1962
2434
|
}
|
|
2435
|
+
|
|
1963
2436
|
const canvas = await readCanvas(slug, root);
|
|
2437
|
+
|
|
1964
2438
|
if (canvas.sections.length === 0) {
|
|
1965
2439
|
throw new Error(`${slug} has nothing on its canvas to snapshot.`);
|
|
1966
2440
|
}
|
|
2441
|
+
|
|
1967
2442
|
const frames = canvasFrames(canvas).flatMap(({ address, frame }) => {
|
|
1968
2443
|
const view = viewOf(frame);
|
|
2444
|
+
|
|
1969
2445
|
return view && (!only || view.view === only)
|
|
1970
2446
|
? [{ address, frame: view }]
|
|
1971
2447
|
: [];
|
|
1972
2448
|
});
|
|
2449
|
+
|
|
1973
2450
|
if (only && frames.length === 0) {
|
|
1974
2451
|
throw new Error(
|
|
1975
2452
|
`${slug} has no frame on its canvas showing the view "${only}".`
|
|
1976
2453
|
);
|
|
1977
2454
|
}
|
|
2455
|
+
|
|
1978
2456
|
const out = studioState(root).snapshotsOf(slug);
|
|
1979
2457
|
await prepareState(root, out);
|
|
1980
2458
|
const shots: Shot[] = [];
|
|
2459
|
+
|
|
1981
2460
|
for (const { address, frame } of frames) {
|
|
1982
2461
|
for (const scheme of COLOR_SCHEMES) {
|
|
1983
2462
|
const shot = await snapshotOf(url, frame, scheme, slug);
|
|
1984
2463
|
const named = `${address.section}/${address.row}/${address.frame}, ${scheme}`;
|
|
2464
|
+
|
|
1985
2465
|
if ("problem" in shot) {
|
|
1986
2466
|
shots.push({ frame: named, problems: [shot.problem] });
|
|
1987
2467
|
continue;
|
|
1988
2468
|
}
|
|
2469
|
+
|
|
1989
2470
|
// The whole address: frame ids are unique only within their row.
|
|
1990
2471
|
const file = join(
|
|
1991
2472
|
out,
|
|
1992
2473
|
`${address.section}--${address.row}--${address.frame}--${scheme}.png`
|
|
1993
2474
|
);
|
|
2475
|
+
|
|
1994
2476
|
await writeFile(file, shot.image);
|
|
1995
2477
|
shots.push({ file, frame: named, problems: shot.problems });
|
|
1996
2478
|
}
|
|
1997
2479
|
}
|
|
2480
|
+
|
|
1998
2481
|
return shots;
|
|
1999
2482
|
}
|
|
2000
2483
|
|
|
@@ -2007,6 +2490,7 @@ const THREAD_USAGE =
|
|
|
2007
2490
|
|
|
2008
2491
|
/** An agent's action before it is signed with the agent's name. */
|
|
2009
2492
|
type UnsignedAction = WithoutAuthor<AgentAction>;
|
|
2493
|
+
|
|
2010
2494
|
/** Each kind of action without its author (Omit, taken one kind at a time). */
|
|
2011
2495
|
type WithoutAuthor<Action> = Action extends unknown
|
|
2012
2496
|
? Omit<Action, "author">
|
|
@@ -2022,21 +2506,27 @@ const threadChange = (values: CommandValues): ThreadChange | undefined => {
|
|
|
2022
2506
|
const flag = (["acknowledge", "resolve", "dismiss"] as const).find(
|
|
2023
2507
|
(name) => values[name]
|
|
2024
2508
|
);
|
|
2509
|
+
|
|
2025
2510
|
const actions: UnsignedAction[] = [];
|
|
2511
|
+
|
|
2026
2512
|
if (flag === "resolve" || flag === "dismiss") {
|
|
2027
2513
|
actions.push({ action: flag, note: values.note });
|
|
2028
2514
|
} else {
|
|
2029
2515
|
if (flag) {
|
|
2030
2516
|
actions.push({ action: flag });
|
|
2031
2517
|
}
|
|
2518
|
+
|
|
2032
2519
|
if (isText(values.note)) {
|
|
2033
2520
|
actions.push({ action: "reply", message: values.note, ask: values.ask });
|
|
2034
2521
|
}
|
|
2035
2522
|
}
|
|
2523
|
+
|
|
2036
2524
|
if (actions.length === 0) {
|
|
2037
2525
|
return;
|
|
2038
2526
|
}
|
|
2527
|
+
|
|
2039
2528
|
const author = values.agent ?? "Agent";
|
|
2529
|
+
|
|
2040
2530
|
return Object.assign(
|
|
2041
2531
|
{},
|
|
2042
2532
|
...actions.map((action) => agentChange({ ...action, author }))
|
|
@@ -2058,29 +2548,41 @@ export function createContentCommands({
|
|
|
2058
2548
|
root?: string;
|
|
2059
2549
|
}) {
|
|
2060
2550
|
const root = content;
|
|
2551
|
+
|
|
2061
2552
|
/** Which Dex serves this checkout, never only the configured port. */
|
|
2062
2553
|
const running = () =>
|
|
2063
2554
|
studioFor({ content, root: projectRoot, port: Number(port) });
|
|
2555
|
+
|
|
2064
2556
|
const presence = openPresence(root);
|
|
2557
|
+
|
|
2065
2558
|
return {
|
|
2066
2559
|
async whoami(): Promise<void> {
|
|
2067
2560
|
const contributor = await joinCurrentPerson(root);
|
|
2561
|
+
|
|
2068
2562
|
if (!contributor) {
|
|
2069
2563
|
print(NOT_RECOGNISED);
|
|
2070
2564
|
process.exitCode = 1;
|
|
2565
|
+
|
|
2071
2566
|
return;
|
|
2072
2567
|
}
|
|
2568
|
+
|
|
2073
2569
|
print(
|
|
2074
2570
|
`${contributor.slug} (${contributor.name}, ${contributor.discipline})`
|
|
2075
2571
|
);
|
|
2076
2572
|
},
|
|
2077
2573
|
async new(values: CommandValues): Promise<void> {
|
|
2078
2574
|
// Yours unless an agent names another contributor.
|
|
2079
|
-
|
|
2080
|
-
|
|
2575
|
+
let person = values.person ?? values.owner;
|
|
2576
|
+
|
|
2577
|
+
if (person === undefined) {
|
|
2578
|
+
const joined = await joinCurrentPerson(root);
|
|
2579
|
+
person = joined?.slug;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2081
2582
|
if (!person) {
|
|
2082
2583
|
throw new Error(NOT_RECOGNISED);
|
|
2083
2584
|
}
|
|
2585
|
+
|
|
2084
2586
|
const { folder, slug } = await createPrototype(
|
|
2085
2587
|
{
|
|
2086
2588
|
title: values.title,
|
|
@@ -2090,6 +2592,7 @@ export function createContentCommands({
|
|
|
2090
2592
|
},
|
|
2091
2593
|
root
|
|
2092
2594
|
);
|
|
2595
|
+
|
|
2093
2596
|
const canvas = prototypePage(slug, "canvas");
|
|
2094
2597
|
print(`Created ${display(folder)}`);
|
|
2095
2598
|
const found = await running();
|
|
@@ -2109,12 +2612,15 @@ export function createContentCommands({
|
|
|
2109
2612
|
async check(unresolved: string[] = []): Promise<void> {
|
|
2110
2613
|
const { problems, warnings } = await checkStudio(root, { designSystem });
|
|
2111
2614
|
problems.push(...unresolved);
|
|
2615
|
+
|
|
2112
2616
|
for (const warning of warnings) {
|
|
2113
2617
|
print(`! ${warning}`);
|
|
2114
2618
|
}
|
|
2619
|
+
|
|
2115
2620
|
if (problems.length > 0) {
|
|
2116
2621
|
throw new Error(`Dex check failed:\n - ${problems.join("\n - ")}`);
|
|
2117
2622
|
}
|
|
2623
|
+
|
|
2118
2624
|
print(
|
|
2119
2625
|
warnings.length > 0
|
|
2120
2626
|
? `Dex check passed, with ${warnings.length} warning${warnings.length === 1 ? "" : "s"} (the lines with !).`
|
|
@@ -2122,26 +2628,34 @@ export function createContentCommands({
|
|
|
2122
2628
|
);
|
|
2123
2629
|
},
|
|
2124
2630
|
async snapshot(values: CommandValues): Promise<void> {
|
|
2125
|
-
let url = values
|
|
2631
|
+
let { url } = values;
|
|
2632
|
+
|
|
2126
2633
|
if (!url) {
|
|
2127
2634
|
const found = await running();
|
|
2635
|
+
|
|
2128
2636
|
if (found.kind !== "running") {
|
|
2129
2637
|
throw new Error(notRunning(found));
|
|
2130
2638
|
}
|
|
2639
|
+
|
|
2131
2640
|
url = found.url;
|
|
2132
2641
|
}
|
|
2642
|
+
|
|
2133
2643
|
const shots = await snapshot({ ...values, url }, root);
|
|
2134
2644
|
let problems = 0;
|
|
2645
|
+
|
|
2135
2646
|
for (const shot of shots) {
|
|
2136
2647
|
print(shot.file ? display(shot.file) : shot.frame);
|
|
2648
|
+
|
|
2137
2649
|
for (const problem of shot.problems) {
|
|
2138
2650
|
problems += 1;
|
|
2139
2651
|
print(` ! ${problem}`);
|
|
2140
2652
|
}
|
|
2141
2653
|
}
|
|
2654
|
+
|
|
2142
2655
|
print(
|
|
2143
2656
|
`${shots.length} snapshots. Open each one and look before you call the work done.`
|
|
2144
2657
|
);
|
|
2658
|
+
|
|
2145
2659
|
if (problems > 0) {
|
|
2146
2660
|
process.exitCode = 1;
|
|
2147
2661
|
}
|
|
@@ -2151,6 +2665,7 @@ export function createContentCommands({
|
|
|
2151
2665
|
(values.view && `view:${values.view}`) ||
|
|
2152
2666
|
(values.doc && `doc:${values.doc}`) ||
|
|
2153
2667
|
(values.slug ? "prototype" : undefined);
|
|
2668
|
+
|
|
2154
2669
|
if (values.clear) {
|
|
2155
2670
|
await presence.clear({
|
|
2156
2671
|
slug: values.slug,
|
|
@@ -2158,13 +2673,16 @@ export function createContentCommands({
|
|
|
2158
2673
|
agent: values.agent,
|
|
2159
2674
|
});
|
|
2160
2675
|
print("Presence cleared.");
|
|
2676
|
+
|
|
2161
2677
|
return;
|
|
2162
2678
|
}
|
|
2679
|
+
|
|
2163
2680
|
if (!(isSlug(values.slug) && target)) {
|
|
2164
2681
|
throw new Error(
|
|
2165
2682
|
'Usage: npx dex presence --slug <file> [--view <name> | --doc <name>] [--agent "<name>"] [--note "<what>"] [--clear]'
|
|
2166
2683
|
);
|
|
2167
2684
|
}
|
|
2685
|
+
|
|
2168
2686
|
await presence.mark({
|
|
2169
2687
|
slug: values.slug,
|
|
2170
2688
|
target,
|
|
@@ -2176,57 +2694,77 @@ export function createContentCommands({
|
|
|
2176
2694
|
/** Prints the threads waiting for an agent, or all, and returns them. */
|
|
2177
2695
|
async threads(values: CommandValues) {
|
|
2178
2696
|
const threads = openThreads(root);
|
|
2697
|
+
|
|
2179
2698
|
const listed = await threads.list({
|
|
2180
|
-
...(values.slug
|
|
2699
|
+
...(values.slug && { prototype: values.slug }),
|
|
2181
2700
|
status: values.all ? "all" : "waiting",
|
|
2182
2701
|
});
|
|
2702
|
+
|
|
2183
2703
|
if (listed.length === 0) {
|
|
2184
2704
|
print(
|
|
2185
2705
|
values.all ? "No comments yet." : "No comments waiting for an agent."
|
|
2186
2706
|
);
|
|
2707
|
+
|
|
2187
2708
|
return [];
|
|
2188
2709
|
}
|
|
2710
|
+
|
|
2189
2711
|
// Each with its file's title beside its name: a folder may be an id.
|
|
2190
2712
|
const titleOf = await prototypeTitles(root, listed);
|
|
2713
|
+
|
|
2191
2714
|
const described = listed.map((thread) => {
|
|
2192
|
-
const { id, prototype, ...rest } =
|
|
2715
|
+
const { id, prototype, ...rest } = describeThread(thread);
|
|
2193
2716
|
const fileTitle = titleOf(thread);
|
|
2194
|
-
|
|
2717
|
+
|
|
2718
|
+
return { id, prototype, ...(fileTitle && { fileTitle }), ...rest };
|
|
2195
2719
|
});
|
|
2720
|
+
|
|
2196
2721
|
print(JSON.stringify(described, null, 2));
|
|
2722
|
+
|
|
2197
2723
|
return described;
|
|
2198
2724
|
},
|
|
2199
2725
|
async thread(values: CommandValues): Promise<void> {
|
|
2200
2726
|
const change = threadChange(values);
|
|
2727
|
+
|
|
2201
2728
|
if (!(values.id && change)) {
|
|
2202
2729
|
throw new Error(THREAD_USAGE);
|
|
2203
2730
|
}
|
|
2731
|
+
|
|
2204
2732
|
const answered = await openThreads(root).change(values.id, change);
|
|
2733
|
+
|
|
2205
2734
|
if (!answered) {
|
|
2206
2735
|
throw new Error(THREAD_USAGE);
|
|
2207
2736
|
}
|
|
2737
|
+
|
|
2208
2738
|
if (answered.problems) {
|
|
2209
2739
|
throw new Error(answered.problems.join(" "));
|
|
2210
2740
|
}
|
|
2741
|
+
|
|
2211
2742
|
print(`Updated ${values.id}.`);
|
|
2212
2743
|
},
|
|
2213
2744
|
scope(values: CommandValues): void {
|
|
2214
2745
|
const person = values.person ?? values.owner;
|
|
2746
|
+
|
|
2215
2747
|
if (!isSlug(person)) {
|
|
2216
2748
|
throw new Error("Usage: npx dex scope --person <slug> [--base main]");
|
|
2217
2749
|
}
|
|
2750
|
+
|
|
2218
2751
|
const outside = outOfScope(
|
|
2219
2752
|
changedFiles(values.base ?? "main", root),
|
|
2220
2753
|
allowedPrefixes(person, root)
|
|
2221
2754
|
);
|
|
2755
|
+
|
|
2222
2756
|
if (outside.length === 0) {
|
|
2223
2757
|
print(`All changes are inside ${person}'s scope.`);
|
|
2758
|
+
|
|
2224
2759
|
return;
|
|
2225
2760
|
}
|
|
2761
|
+
|
|
2226
2762
|
print(`Changes outside ${person}'s scope (need studio review):`);
|
|
2763
|
+
|
|
2227
2764
|
for (const file of outside) {
|
|
2228
2765
|
print(` ${file}`);
|
|
2229
2766
|
}
|
|
2767
|
+
|
|
2230
2768
|
process.exitCode = 1;
|
|
2231
2769
|
},
|
|
2232
2770
|
};
|